/** * Pure helpers for DshAgentRunner (dsh-runner.ts): the `--json` event * vocabulary, dsh's native tool names → contract kind/canonical input, the * `--patch` YAML that selects model + effort, the version gate, and the * errors a failed invocation maps to. No I/O here, so every piece is * fixture-testable. * * Sources (all from the installed @deepseek-ai/dsh 0.1.7-rc.2 package, then * checked by running it — see dsh-runner.ts's header): * - events: dsh-headless/lib/json-stream-*.js (`projectJsonRun`) * - tool names/params: dsh-tool-{bash,pwsh,fs,fs-search,web,todo, * str-replace-editor,subagent}; MCP tools are `mcp____` * (dsh-mcp-client) * - patch rows: dsh-base/cordis.patch.yml (`agent-default-model`, * `sandbox-policy`), dsh-agent-default-model's Config * (provider, model, reasoningEffort) * - resume refusals: dsh-headless/lib/index.js (`assertAdoptable`) */ import type { AgentMessage } from './agent-runner.js'; import { type ToolKind } from './kimicode-runner-tools.js'; export interface DshUsage { inputTokens?: number; outputTokens?: number; totalTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; reasoningTokens?: number; } /** One `dsh --profile headless --json` line. */ export interface DshEvent { type: 'session' | 'status' | 'thinking' | 'text' | 'tool_call' | 'tool_result' | 'final' | 'error'; sessionId?: string; cwd?: string; phase?: 'turn_start' | 'step_start' | 'step_end' | 'turn_end' | (string & {}); turn?: number; step?: number; usage?: DshUsage; reason?: { kind?: string; error?: { message?: string; code?: string; }; }; text?: string; callId?: string; tool?: string; input?: unknown; status?: 'completed' | 'error'; result?: string; message?: string; truncated?: boolean; } /** Parse one stdout line; null for anything that is not a dsh event. */ export declare function parseDshLine(line: string): DshEvent | null; /** * Contract kind + canonical input for one dsh tool call. dsh-specific * shapes are translated here; names it shares with other CLIs (edit, write, * read, glob, grep, web_fetch, todo_write, mcp__*) go through the shared * canonicalTool. */ export declare function dshCanonicalTool(name: string, rawInput: unknown): { kind: ToolKind; input: Record; }; /** A shell call's exit code, read off dsh's result text: `[exit code: N]` * when non-zero, no marker at all when 0. Undefined when the command did not * exit on its own (signal, timeout, moved to a background job), the call * errored, or the result was truncated (the marker sits at the end). */ export declare function dshShellExitCode(ev: DshEvent): number | undefined; /** Pairs dsh's `tool_call`/`tool_result` by callId into the rich * tool_use/tool_result AgentMessages ToolActivityTracker matches. */ export declare class DshToolCalls { private open; start(ev: DshEvent, sessionId?: string): AgentMessage | null; end(ev: DshEvent, sessionId?: string): AgentMessage | null; /** Calls still open when the process ended: a failed end each, so every * start has an end (an aborted turn is closed by the caller instead). */ flush(sessionId?: string): AgentMessage[]; } /** dsh's shipped default route (dsh-base `agent-default-model`). */ export declare const DSH_DEFAULT_SELECTION: { provider: string; model: string; }; export interface DshSelection { provider: string; model: string; reasoningEffort?: string; } /** * The `agent-default-model` row as a `--patch` overlay. A patch REPLACES a * row's whole `config` (checked with `--dump-config`), so provider and model * are always written. Values are JSON-quoted, which YAML reads as plain * double-quoted scalars. */ export declare function dshModelPatchYaml(sel: DshSelection, piAiRow?: string | null): string; /** The `agent-default-model` row out of `dsh --dump-config` output. Only * plain or quoted scalars count; a `!!js` expression is not a value. */ export declare function parseDumpedSelection(dump: string): Partial; /** dsh is a developer preview with announced breaking changes: this runner * was built against 0.1.7-rc.2 (and `next` 0.2.0-rc.1 keeps the headless * contract), so it accepts 0.1.7 up to, not including, 0.3.0. */ export declare const DSH_SUPPORTED_RANGE = ">=0.1.7-0 <0.3.0"; export declare const DSH_INSTALL_HINT = "npm i -g @deepseek-ai/dsh"; export declare function dshVersionSupported(output: string): { ok: boolean; version?: string; }; /** * The actionable message for a failed invocation, from the `error` event * (failures outside a turn — usage errors, `--session-id` refusals) or the * final `turn_end` reason. `fatal` marks errors a retry cannot fix. */ export declare function dshFailure(errorEvent: string | undefined, turnEnd: DshEvent['reason'] | undefined, resume: string | undefined): { message: string; fatal: boolean; } | null; //# sourceMappingURL=dsh-runner-parse.d.ts.map