import type { AgentAdapter, AgentSpawnConfig } from '../../agent-adapter/index.js'; import type { AgentHandle, AgentResult } from '../../core/types/agent-types.js'; export interface AgentConfig { model: string; backend: string; mode: string | null; /** PI `--provider` (protocol). null → defaults to "anthropic". Only used for backend='pi'. */ provider?: string | null; extraEnv?: Record; extraOption?: Record; /** DR-0012: Claude adapter mode (print/tui). Only meaningful for backend='claude'. */ claudeBackend?: 'print' | 'tui'; } export interface RunAgentOptions { profileName?: string | null; sessionId?: string | null; sessionKey?: string | null; channel?: string; files?: unknown[]; callbackSource?: string | null; scheduleTaskId?: string | null; isUserInitiated?: boolean; project?: string; trigger?: string; /** Cortex execution context surfaced to the MCP server child as CORTEX_THREAD_ID/PROFILE/PROJECT/SESSION_NAME env vars. * Read by the cortex_context / cortex_schedule_* MCP tools so LLMs can self-discover their thread and target schedules * at the current thread / session without guessing IDs. */ threadId?: string | null; sessionName?: string | null; /** Cortex execution record id, surfaced as CORTEX_EXECUTION_ID to subprocess env. */ executionId?: string | null; /** When true, load only core MCP server (remote_* tools). Used by template thread sessions. * Default (undefined/false) loads full MCP config with cortex-ext tools. */ useCoreMcp?: boolean; /** Recursion depth of the owning thread, surfaced to the spawned agent as CORTEX_THREAD_DEPTH * so the thread_start MCP tool can forward it for the depth guard. */ threadDepth?: number | null; /** Owning dispatch task id/project, surfaced as CORTEX_TASK_ID / CORTEX_TASK_PROJECT so * `cortex-task spawn` can infer the current task as the parent of a child task. */ taskId?: string | null; taskProject?: string | null; onProgress?: ((progress: any) => void) | null; onAssistantMessage?: ((msg: string) => void) | null; onToolUse?: ((name: string, input: any) => void) | null; onFallback?: (current: AgentConfig, next: AgentConfig, result: AgentResult | null, error?: Error) => Promise; [key: string]: any; } /** * Build the gateway sub-path for a PI provider's models.json override, following the gateway's URL * convention `/m//`. The `mode` selects the gateway route (gateway.yaml owns the * upstream + keys); the `provider` is both the PI `--provider` and the gateway endpoint segment. * * `provider` is required for pi profiles (validated at load time — no default, no fallback). Returns * undefined when `mode` is absent — the PI adapter then falls back to the default `/` path * (direct per-provider routing, no `/m/` mode indirection). * * Keeping this derivation in code (not in the profile) means profiles only carry the logical * `mode` name; no gateway path string leaks into profiles.json. */ export declare function buildPiGatewaySubPath(mode: string | null, provider: string): string | undefined; /** Plugins that load only for sessions originating from a specific platform channel. * Mirrors the channel-gated MCP loading (loadFeishuMcp = channel.startsWith('feishu:')): * the cortex-feishu skill bundle is only relevant when the user is working inside Feishu, * so it is stripped from non-Feishu sessions even when listed in an agent's pluginDirs. */ export declare const CHANNEL_SCOPED_PLUGINS: ReadonlyArray<{ plugin: string; channelPrefix: string; }>; /** Drop channel-scoped plugin dirs whose channel prefix the current session does not match. * Non-scoped plugins always pass through. Matched by the plugin dir's final path segment * (basename) so substrings like `cortex-feishu-x` are not affected. */ export declare function filterChannelScopedPlugins(dirs: string[] | undefined, channel: string | undefined): string[] | undefined; declare function buildSpawnConfig(options: RunAgentOptions, config: AgentConfig, anthropicBaseUrl: string | undefined): AgentSpawnConfig; export declare function runWithAdapter(adapter: AgentAdapter, message: string, options: RunAgentOptions, config: AgentConfig, anthropicBaseUrl: string | undefined): AgentHandle; export declare function runAgentOnce(message: string, options: RunAgentOptions, config: AgentConfig): AgentHandle; export declare function runAgent(message: string, options?: RunAgentOptions): AgentHandle; /** Returns true when every mode in the profile's fallback chain is currently rate-limited. * Enables job runners to skip claiming/running when all paths are blocked. */ export declare function allConfigsRateLimited(profileName: string | null): boolean; export declare const _test: { runWithAdapter: typeof runWithAdapter; buildSpawnConfig: typeof buildSpawnConfig; filterChannelScopedPlugins: typeof filterChannelScopedPlugins; }; export { closeSession, closeSessionsByPrefix, closeAllSessions, _test as claudeTest, } from '../../agent-adapter/claude/adapter.js'; export { shutdownCodex, buildMcpBlock } from '../../agent-adapter/codex/adapter.js'; export { getCurrentPlanFilePath } from '../../agent-adapter/claude/event-parser.js';