/** * The output-tool contract (spec §9.2/§10.1): the two tools a step may call to submit its result, and * the pure helpers for reading one back out of a turn. * * Which tool was called IS the discriminator between a result and a question batch, replacing the * `{result} | {questions}` union the text path has to sniff (`agent-output.ts`). Providers pick between * tools far more reliably than between branches of a union inside one payload. * * No host/PI deps — the host imports these names to register the tools, the engine to read them back. */ import { type TSchema } from "typebox"; import { SUBMIT_QUESTIONS_TOOL, SUBMIT_RESULT_TOOL } from "../flow/output-tool-names.ts"; import type { SubmittedOutput } from "./types.ts"; export { SUBMIT_QUESTIONS_TOOL, SUBMIT_RESULT_TOOL }; /** Every tool name the engine will read a payload from. A host registers exactly these. */ export declare const OUTPUT_TOOL_NAMES: readonly string[]; /** * The `workflow_submit_result` parameter schema for a step whose contract is `outputSchema`. * * The result is WRAPPED in an object because tool parameters must be one — `outputSchema` itself may be * any schema, including a bare string or array. */ export declare function submitResultParameters(outputSchema: TSchema): TSchema; /** The `workflow_submit_questions` parameter schema — framework-owned and identical for every step. */ export declare function submitQuestionsParameters(): TSchema; /** Tag written by framework-owned submission handlers into PI tool-result details. */ export declare const WORKFLOW_STEP_SUBMISSION_TYPE: "kimchi-workflow-step-submission"; /** Framework-owned identity that attributes a persisted submission to one workflow attempt. */ export interface StepSubmissionIdentity { readonly runId: string; readonly path: string; readonly attempt: number; } /** Durable handoff from a workflow submission tool to the bridge settling its logical run. */ export interface WorkflowStepSubmissionDetails extends StepSubmissionIdentity { readonly type: typeof WORKFLOW_STEP_SUBMISSION_TYPE; readonly kind: "result" | "questions"; /** The validated tool arguments, kept wrapped exactly as the engine expects them. */ readonly payload: unknown; } /** Read a framework submission record defensively from an untrusted PI session entry. */ export declare function readSubmissionDetails(details: unknown): WorkflowStepSubmissionDetails | undefined; /** Whether a durable submission belongs to the workflow attempt currently being settled. */ export declare function isSubmissionForIdentity(details: WorkflowStepSubmissionDetails, identity: StepSubmissionIdentity): boolean; /** Adapt persisted submission details to the engine's existing tool-call-shaped contract. */ export declare function submittedOutputFromDetails(details: WorkflowStepSubmissionDetails): SubmittedOutput; /** What a submitted tool call carried, with the tool identity resolved to a kind. */ export type SubmittedPayload = { readonly kind: "result"; readonly value: unknown; } | { readonly kind: "questions"; readonly value: unknown; } /** The tool was called, but its arguments cannot be read as a payload at all. */ | { readonly kind: "malformed"; readonly tool: string; readonly reason: string; }; /** * Read a submitted call's payload. Returns undefined for a call this contract does not own, so an * unrelated tool the model happened to use last can never be mistaken for the step's output. */ export declare function readSubmittedPayload(submitted: SubmittedOutput | undefined): SubmittedPayload | undefined; /** True when `name` is one of the output tools — used by hosts scanning a transcript. */ export declare function isOutputToolName(name: string): boolean; //# sourceMappingURL=output-tools.d.ts.map