/** * Text/tool serialization for the inline wire path, plus server-side web * search injection. Reasoning and opaque replay histories remain Core-owned; * this limited serializer refuses them instead of inventing Responses items. * @module dsh-github-copilot/serialize */ import type { GenerateOptions, RequestMessage, ToolSchema } from '@deepseek-ai/dsh-llm'; import type { ResponsesWebSearchToolType } from './plan.ts'; import type { InlineConfig } from './config.ts'; /** Mapped only after the selected model's native capability checks succeed. */ export interface ResponsesReasoningOptions { readonly effort: string; readonly summary: 'auto'; } /** Keep Core-owned reasoning provenance and opaque replay state out of this serializer. */ export declare function hasResponsesReplayContext(messages: readonly RequestMessage[]): boolean; /** Thrown for content whose projection must remain with Core. */ export declare class UnsupportedContentError extends Error { constructor(detail: string); } /** * Stable short hash (FNV-1a variant) for synthesizing item ids. * @param input - any string. * @returns an 8-character base36 string. */ export declare function shortHash(input: string): string; /** * Split a harness call id into the Responses `call_id`/`id` pair. Harness * ids produced by the pi-ai adapter carry the `call_id|item_id` shape; ids * from other origins get a synthesized item id. * @param id - the harness tool-call id. * @returns the call id and item id. */ export declare function splitCallId(id: string): { callId: string; itemId: string; }; export declare function flattenText(content: readonly unknown[]): string; /** Detect a grounded sandbox denial in either current tool-role or retained legacy message layout. */ export declare function hasToolResultText(message: RequestMessage, needle: string): boolean; /** * Serialize one dsh message into Responses input items. * @param message - the harness message. * @returns the wire input items; may be empty for content-free messages. * @throws UnsupportedContentError for image or Core-owned reasoning/replay content. */ export declare function serializeMessage(message: RequestMessage, pairedCallIds?: ReadonlySet): unknown[]; /** * Return call ids that have both an assistant function call and a user tool * result. Responses rejects either half when replayed alone, which can happen * when a prior provider/tool failure ended the step before persistence wrote * the matching result. */ export declare function pairedToolCallIds(messages: readonly RequestMessage[]): ReadonlySet; /** * Build the wire tools array: function tools (optionally stripped of the * variants shadowed by server-side web tools) plus the server-side web * search tool in the candidate's verified spelling. * @param tools - the harness tool schemas. * @param stripServerTools - whether to drop the shadowed function variants. * @param webSearchToolType - the Responses spelling the probe verified. * @returns the wire tools array. */ export declare function wireTools(tools: readonly ToolSchema[] | undefined, stripServerTools: boolean, webSearchToolType: ResponsesWebSearchToolType): unknown[]; /** * Build the complete Responses request body for one inline call. * @param request - the harness request. * @param cfg - the wire controls. * @param model - the model the plan resolved (config override or the loop's * route model); the same model the capability probe verified. * @param webSearchToolType - the Responses spelling the probe verified; the * wire must send exactly the spelling that passed. * @returns the JSON body to POST. */ export declare function buildWireBody(request: GenerateOptions, cfg: Pick, model: string, webSearchToolType: ResponsesWebSearchToolType, reasoning?: ResponsesReasoningOptions): unknown; /** * Build the Anthropic Messages wire tools array: function tools (optionally * stripped of the `web_search` variant, which shadows the server-side tool) * plus the server-side web search tool. Function tools carry no `type`. * @param tools - the harness tool schemas. * @param stripServerTools - whether to drop the shadowed function variants. * @returns the wire tools array. */ export declare function anthropicWireTools(tools: readonly ToolSchema[] | undefined, stripServerTools: boolean): unknown[]; /** * Serialize one dsh message into Anthropic Messages content items. * Assistant messages aggregate their blocks into one content array * (reasoning without a usable signature becomes plain text). * @param message - the harness message. * @returns the Anthropic content items for this message. * @throws UnsupportedContentError for image content. */ export declare function serializeAnthropicMessage(message: RequestMessage): unknown[]; /** * Build the complete Anthropic Messages request body for one inline call. * The system prompt goes to the top-level `system` field (unlike the * Responses wire, the Anthropic gateway keeps server-side web_search native * with a top-level system). * @param request - the harness request. * @param cfg - the wire controls. * @param model - the model the plan resolved (config override or the loop's * route model); the same model the capability probe verified. * @returns the JSON body to POST. */ export declare function buildAnthropicWireBody(request: GenerateOptions, cfg: Pick, model: string): unknown; //# sourceMappingURL=serialize.d.ts.map