import type { Provider, ThinkingLevel } from "@kenkaiiii/gg-ai"; export interface JsonModeOptions { message: string; provider: Provider; model: string; baseUrl?: string; /** Replaces the whole system prompt. */ systemPrompt?: string; /** * Agent definition body composed with the standard scaffolding (Tools, * project context, return contract, Environment) — the delegation path. */ agentPrompt?: string; /** Whether the composed prompt includes project instruction files. */ agentContext?: "project" | "none"; cwd: string; thinkingLevel?: ThinkingLevel; maxTurns?: number; /** * Tool allow-list forwarded from an agent definition's `tools:` frontmatter. * When set, the sub-agent session registers ONLY these tool names, so a * read-only agent (e.g. `tools: read, grep`) physically cannot call * write/edit/bash. Empty/undefined → full toolset (backward compatible). */ allowedTools?: string[]; /** * MCP servers this sub-agent may connect, derived from the `mcp____*` * entries in its agent definition's `tools:` frontmatter. Only meaningful * alongside `allowedTools` — an allow-listed session otherwise skips MCP * entirely, so a research agent would silently lose live code search. */ allowedMcpServers?: string[]; /** * Stable prompt-cache routing key inherited from the parent ggcoder * process. Without this, each sub-agent session generates a unique * sessionId-derived cache key and starts with a cold cache on providers * that route caching by key (OpenAI Codex, OpenAI Chat, Moonshot). */ promptCacheKey?: string; } /** Minimal surface of `process` that {@link exitAfterFlush} needs. */ export interface ExitHost { stdout: { writableLength: number; once(event: "drain", listener: () => void): unknown; }; exit(code: number): void; setTimeout?: (handler: () => void, ms: number) => { unref?: () => void; }; } /** Grace period before abandoning a stalled stdout pipe and exiting anyway. */ export declare const JSON_MODE_FLUSH_TIMEOUT_MS = 2000; /** * End a finished one-shot JSON-mode run, flushing stdout first. * * Returning from `main()` is not enough. In the desktop build the sub-agent * worker entry IS the app-sidecar bundle (`GG_SUBAGENT_WORKER_ENTRY` defaults * to `process.argv[1]`, and no `cli.js` ships in the app — see * json-mode-flag-parity.test.ts), whose module graph installs long-lived * handles at import time. Those keep the event loop alive forever, so a child * that had already emitted `agent_done` sat idle until the parent's timeout * killed it, surfacing a COMPLETED run as "Sub-agent failed (exit null)". * * A JSON-mode process is one-shot by definition: once the final frame is * written there is nothing left to await, so exit deterministically. */ export declare function exitAfterFlush(code: number, host?: ExitHost): void; export declare function runJsonMode(options: JsonModeOptions): Promise; //# sourceMappingURL=json-mode.d.ts.map