import type { Provider, ThinkingLevel } from "@kenkaiiii/gg-ai"; import type { AgentDefinition } from "../core/agents.js"; import type { AgentSession } from "../core/agent-session.js"; export declare const SUB_AGENT_MAX_TURNS = 50; /** * Sub-agents get at most ONE turn-budget extension. A child's extensions run * inside a single parent turn, so a child extending itself twice multiplies * against the parent's own budget. */ export declare const SUB_AGENT_MAX_TURN_EXTENSIONS = 1; export declare const SUB_AGENT_MAX_OUTPUT_CHARS = 100000; export declare const SUB_AGENT_MAX_OUTPUT_LINES = 500; export declare const SUB_AGENT_MAX_STDERR_CHARS = 10000; export declare const SUB_AGENT_TIMEOUT_MS: number; /** * The single tool-free turn a timed-out worker gets to answer from what it has * gathered. Anyone waiting on a time-limited child must allow for it. */ export declare const SUB_AGENT_TIMEOUT_RECOVERY_MS = 60000; export declare const SUB_AGENT_DEPTH_ENV = "GG_SUBAGENT_DEPTH"; export declare const MAX_BLOCKING_SUBAGENT_DEPTH = 3; export interface SubAgentTokenUsage { /** Fresh, non-cached input reported by the normalized provider adapter. */ input: number; output: number; cacheRead?: number; /** Fresh input written into the provider cache (separate on Anthropic). */ cacheWrite?: number; } export interface SubAgentSelection { agentDef?: AgentDefinition; provider: Provider; parentModel: string; model: string; /** Thinking level the child runs at — see {@link subAgentThinkingLevel}. */ thinkingLevel: ThinkingLevel | undefined; } export declare function resolveAgentDefinition(agents: AgentDefinition[], requestedName?: string): AgentDefinition | undefined; export declare function selectSubAgent(agents: AgentDefinition[], requestedName: string | undefined, provider: Provider, parentModel: string, parentThinkingLevel?: ThinkingLevel): SubAgentSelection; /** * Resolve which model a named agent runs on. * * Sub-agents never get a weaker model of their own: no `model:` frontmatter, * `inherit`, and the legacy `fast` all run on the parent's model. An explicit * model id is honoured as written, since that is a choice the user made in * their own agent definition. */ export declare function resolveAgentModel(agentDef: AgentDefinition | undefined, parentModel: string): string; /** * OpenAI children inherit the parent's selection, including Ultra (resolved * by the transport), as in Codex. A pinned model with a lower ceiling is * capped to its supported ladder. Other providers keep their lowest-rung * policy. Resolve again from the original parent selection on fallback. */ export declare function subAgentThinkingLevel(provider: Provider, model: string, parentThinkingLevel?: ThinkingLevel): ThinkingLevel | undefined; /** * Render the agent roster for a tool description. * * Both delegation tools use this: the dispatcher picks an agent from the tool * schema alone, so a tool that omits the roster leaves the model guessing a * name — which either errors or, worse, silently spawns a generic child. */ export declare function renderAgentRoster(agents: readonly AgentDefinition[]): string; /** One child started by a recorded `spawn_agent` call. */ export interface SpawnedTaskArgs { task_name?: string; task?: string; agent?: string; } /** * The children a recorded `spawn_agent` call started, for rebuilding history: * `{ tasks: [...] }` today, or the single `{ task_name, task, agent }` that * sessions saved before batch launch carry. Untrusted session data, so only * string fields are kept. */ export declare function spawnedTasks(args: unknown): SpawnedTaskArgs[]; export declare function subAgentCacheKey(parentCacheKey: string | undefined, model: string, agentName?: string): string | undefined; export declare function currentSubAgentDepth(env?: NodeJS.ProcessEnv): number; export declare function childSubAgentEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; export declare function resolveSubAgentCliEntry(): string; /** * Run one sub-agent prompt and resolve to the error the agent loop stopped on, * if it stopped on one. * * `prompt()` resolving is not proof the child finished. The loop ends some runs * by emitting an `error` event and then returning normally — repeated invalid * tool arguments, a provider that stopped responding, a tool call that never * closed — because an interactive user sees that error and simply sends * another message. A sub-agent has nobody to do that, so its host must treat * the event as a failed turn; otherwise the parent receives the child's * mid-task narration ("Let me re-read…") as if it were the final report. */ export declare function promptSubAgent(session: Pick, task: string): Promise; export declare function boundSubAgentOutput(raw: string): string;