/** * The snapshot digest: one model-written description of what a runtime-context * snapshot holds, for a reader who should not have to parse DSH's own state * prose. * * Two properties shape this module. The runtime-context snapshot is already * part of every model request, so describing it discloses nothing new — but the * call is still deployment-controlled (route, cap, deadline) and answers only * what the card asks about. And nothing here may reach the Loader's entry state: * the channel is bound softly, every failure becomes an `unavailable` answer, * and a fault is reported once per kind rather than per request. * * @module dsh-context-snapshot-bar/summary */ import type { Context } from '@deepseek-ai/cordis'; import type { Config } from '../shared/config.ts'; import type { SnapshotSummaryRequest, SnapshotSummaryResponse } from '../shared/types.ts'; /** * The instruction that turns one snapshot into a line-by-line account of it. * * The card draws the answer as a list beside the record it describes, so the * shape is part of the contract: one line per input entry, in input order, and * nothing around them. A digest that reads as prose, or that ends in advice, * stops being a description of what is stored. */ export declare const SYSTEM_PROMPT: string; /** * Digest format version. * * Part of the cache key: an answer written under an earlier instruction keeps * its shape for the life of the process, so a format change has to miss the * cache rather than serve the old shape to the new card. */ export declare const DIGEST_FORMAT = 2; /** * Build the untrusted-input frame for one request. * * The sections travel as JSON so a payload cannot forge a delimiter, and the * language instruction is appended outside the data. * * @param request - the card's request. * @returns the exact user-role text sent to the model. */ export declare function digestInput(request: SnapshotSummaryRequest): string; /** One provider chunk, as far as the digest reads it. */ interface DigestChunk { readonly type: string; readonly text?: string; readonly reason?: { readonly kind?: string; readonly failure?: { readonly code?: string; readonly message?: string; }; }; } /** * Collect the assistant text of one provider stream without importing the * harness assembler: the plugin reads only text deltas, and a bundle that * imports a harness module can fail to load on a harness version that moves it. * * The stream reports a provider or adapter failure as a terminal `finish` chunk * rather than by throwing, so the failure is read here: discarding it would turn * every cause — no adapter, no key, a rejected request — into one silent empty * answer. * * @param chunks - the provider stream. * @returns the trimmed assistant text, or the terminal failure when the stream carried one. */ export declare function collectDigestText(chunks: AsyncIterable): Promise<{ text: string; failure?: string; }>; /** * Answer one request, reusing an identical earlier answer. * * @param ctx - a context whose `llm` service is bound. * @param config - the resolved plugin configuration. * @param request - the card's request. * @returns the answer to send back. */ export declare function answerDigest(ctx: Context, config: Config, request: SnapshotSummaryRequest): Promise; /** * Serve the digest on the plugin's own authenticated channel. * * The route is mounted here rather than through `connection.rpc.handle`: that * helper reaches `webServer` through the Connection service's own context, which * never injects it, so a registration from any other fiber throws * `cannot get property "webServer" without inject` and serves nothing — the * browser then falls through to the static handler, which answers 405 to a POST. * Connection still owns the fence and the Client still calls the channel through * the Connection transport, so this is one route plus the transport's envelope * rather than a second protocol. * * A missing `connection`, `llm`, or `webServer` service leaves the plugin's other * contributions untouched: the cards render without the digest section instead * of failing to load. The registration is an effect, so unloading withdraws the * route with the fiber. * * @param ctx - the plugin's Cordis context. * @param config - the resolved plugin configuration. */ export declare function registerSnapshotSummary(ctx: Context, config: Config): void; export {}; //# sourceMappingURL=index.d.ts.map