import type { IdentityJsonValue } from '../../domain/agent-run/identity.js'; import type { McpComposition } from '../types.js'; /** * Adapter mode selector. `print` (default) uses `-p` + stream-json; `tui` uses interactive TUI * under tmux with jsonl tail (DR-0012). Both modes share the rest of the CLI surface. */ export type ClaudeSpawnMode = 'print' | 'tui'; export interface ClaudeSpawnOptions { tools: string | null; systemPrompt?: string | null; appendSystemPrompt?: string | null; model?: string | null; claudeAgent?: string | null; pluginDirs?: string[] | null; outputStyle?: string | null; needsResume: boolean; sessionId: string; /** Declared MCP privilege surface. Defaults to the ordinary direct surface. */ mcpComposition?: McpComposition; /** Concrete MCP files supplied by a frozen one-shot run configuration. */ mcpConfigPaths?: string[] | null; /** Omit all configured **ambient** hooks for isolated one-shot execution. */ disableHooks?: boolean; /** Compiled benchmark policy guard. Present makes the guard the entire hooks surface. */ benchmarkPolicyGuard?: IdentityJsonValue; /** Explicit partial-message policy; absent reads the daemon setting. */ streamDeltas?: boolean; /** Layer the cortex-slack MCP server on top of the base config. Set by the adapter for sessions * that originate from Slack (channel carries the `slack:` prefix). Direct composition only. */ loadSlackMcp?: boolean; /** Layer the cortex-feishu MCP server on top of the base config. Set by the adapter for sessions * that originate from Feishu (channel carries the `feishu:` prefix). Direct composition only. */ loadFeishuMcp?: boolean; /** Layer the cortex-web MCP server on top of the base config. Set by the adapter for sessions that * originate from the Web UI (channel carries the `web:` prefix), enabling the send_file tool. * Direct composition only. */ loadWebMcp?: boolean; /** Thinking level from the profile's `thinking` field → `--effort ` * (low/medium/high/xhigh/max). Absent → no flag. */ thinking?: string | null; /** Extra CLI options from profile (e.g. {"--thinking": "xhigh"}). */ extraOption?: Record | null; /** DR-0012: select adapter mode. Default 'print' preserves -p stream-json behavior. */ mode?: ClaudeSpawnMode; /** True for user-message-initiated sessions (not thread/scheduled pipeline workers). In print * mode, such sessions additionally get the cortex-tui-bridge MCP interaction tools * (cortex_plan_enter/exit, cortex_ask_user) because the native EnterPlanMode/ExitPlanMode/ * AskUserQuestion are filtered out by headless `-p`. Non-direct compositions never get them. */ isUserInitiated?: boolean; } /** Token-level assistant streaming gate, read for each spawn argument build. */ export declare function isStreamDeltasEnabled(): boolean; export declare function buildSpawnArgs(options: ClaudeSpawnOptions): string[]; /** Cortex agent execution context — surfaces as CORTEX_* env vars so MCP tools * (cortex_context, cortex_schedule_*) can self-discover the current thread/profile/etc. * Optional fields are omitted from env when undefined, so child processes see no key * rather than an empty string. */ export interface CortexAgentContext { threadId?: string | null; profile?: string | null; project?: string | null; sessionName?: string | null; /** Stable Cortex tracking id (decoupled from the backend session id) → CORTEX_SESSION_ID. */ trackSessionId?: string | null; /** Cortex execution record id, surfaced as CORTEX_EXECUTION_ID to subprocess env. */ executionId?: string | null; /** When true, load the restricted thread MCP composition. */ useCoreMcp?: boolean; /** Recursion depth of the owning thread, surfaced as CORTEX_THREAD_DEPTH so the thread_start * MCP tool can forward it and the daemon-side depth guard can cap nested thread spawning. */ threadDepth?: number | null; /** Owning dispatch task id/project (when the agent runs inside a task-dispatched thread), * surfaced as CORTEX_TASK_ID / CORTEX_TASK_PROJECT so `cortex-task spawn` can infer the * current task as the parent of a child task without the agent re-declaring it. */ taskId?: string | null; taskProject?: string | null; taskGeneration?: string | null; } export declare function buildClaudeEnv(channel: string, sessionId: string, callbackSource?: string | null, scheduleTaskId?: string | null, anthropicBaseUrl?: string, extraEnv?: Record, context?: CortexAgentContext, pinnedEnv?: NodeJS.ProcessEnv, benchmarkDeadlineEpochMs?: number): NodeJS.ProcessEnv;