import type { LocalOpenAiCompatibleRunnerConfig, LocalRunnerAuthMode, LocalRunnerKind, LocalRunnerResponseFormatStrategy } from "@mcoda/shared"; import type { AgentStatusPhase, Provider, ProviderMessage, ProviderUsage } from "../providers/ProviderTypes.js"; import { ToolRegistry } from "../tools/ToolRegistry.js"; import { type ToolContext, type ToolDefinition } from "../tools/ToolTypes.js"; import type { RunLogger } from "./RunLogger.js"; export interface CodaliRuntimeWorkspace { root: string; readOnly?: boolean; } export interface CodaliRuntimeProviderInput { name: "openai-compatible" | "ollama-remote" | "codex-cli" | "claude-cli" | string; model: string; baseUrl?: string; apiKey?: string; timeoutMs?: number; localRunner?: LocalOpenAiCompatibleRunnerConfig; runnerKind?: LocalRunnerKind; authMode?: LocalRunnerAuthMode; dummyBearerToken?: string; headers?: Record; extraBody?: Record; responseFormatStrategy?: LocalRunnerResponseFormatStrategy; healthPath?: string; modelsPath?: string; requireModelInRequest?: boolean; supportsStreaming?: boolean; supportsTools?: boolean; supportsJsonSchema?: boolean; supportsGbnf?: boolean; } export interface CodaliRuntimeDocdexInput { enabled?: boolean; baseUrl?: string; repoRoot?: string; repoId?: string; dagSessionId?: string; apiKey?: string; clientIdentity?: string; credentialSource?: "attached_mswarm_api_key" | string; required?: boolean; allowedOperations?: string[]; capabilities?: Record; immutableRuntimeContext?: boolean; initialize?: boolean; allowWeb?: boolean; allowMemoryWrite?: boolean; allowProfileWrite?: boolean; allowIndexRebuild?: boolean; toolManifest?: CodaliRuntimeToolManifest; } export interface CodaliRuntimeToolManifest extends Record { actualTools?: unknown[]; virtualTools?: unknown[]; actual_tools?: unknown[]; virtual_tools?: unknown[]; } export interface CodaliRuntimeAppToolGatewayContract extends Record { endpoint?: string; readOnly?: boolean; read_only?: boolean; signatureRequired?: boolean; signature_required?: boolean; signature?: string; signatureSecret?: string; signature_secret?: string; signingSecret?: string; signing_secret?: string; secret?: string; } export interface CodaliRuntimeAppToolContract extends Record { name?: string; tool?: string; toolName?: string; tool_name?: string; description?: string; enabled?: boolean; readOnly?: boolean; read_only?: boolean; executionMode?: string; execution_mode?: string; callSchema?: Record; call_schema?: Record; resultContract?: string; result_contract?: string; resultSources?: string[]; result_sources?: string[]; backingTools?: string[]; backing_tools?: string[]; sourcePaths?: string[]; source_paths?: string[]; sourceTypes?: string[]; source_types?: string[]; suppliedSnapshots?: string[]; supplied_snapshots?: string[]; gateway?: CodaliRuntimeAppToolGatewayContract; metadata?: Record; } export type CodaliRuntimeAppToolContracts = Record | CodaliRuntimeAppToolContract[]; export interface CodaliRuntimeToolTelemetryEntry { name: string; backingTool?: string; status: "success" | "failed" | "blocked"; latencyMs: number; errorCode?: string; errorMessage?: string; } export interface CodaliRuntimeDynamicToolSkip { name: string; reason: string; } export interface CodaliRuntimeTelemetry { runId: string; runtime: "codali"; mode: CodaliRuntimePolicy["mode"]; toolCallCount: number; calledTools: string[]; consideredTools: string[]; registeredDynamicTools: string[]; skippedDynamicTools: CodaliRuntimeDynamicToolSkip[]; dynamicToolCalls: CodaliRuntimeToolTelemetryEntry[]; warnings: string[]; } export interface CodaliRuntimeAgentInput { slug: string; adapter: string; provider?: string; model: string; baseUrl?: string; localRunner?: LocalOpenAiCompatibleRunnerConfig; runnerKind?: LocalRunnerKind; authMode?: LocalRunnerAuthMode; supportsTools?: boolean; capabilities?: string[]; contextWindow?: number; maxOutputTokens?: number; } export interface CodaliRuntimePolicy { allowWrites: boolean; allowShell: boolean; allowDestructiveOperations: boolean; allowOutsideWorkspace: boolean; allowedTools?: string[]; deniedTools?: string[]; appToolContracts?: CodaliRuntimeAppToolContracts; appVirtualTools?: string[]; appToolGateway?: CodaliRuntimeAppToolGatewayContract; maxSteps: number; maxToolCalls: number; maxTokens?: number; timeoutMs: number; mode: "tool_loop" | "protocol_loop" | "smart_pipeline" | "patch_json" | "freeform"; } export interface CodaliRuntimeSubagentsInput { enabled?: boolean; maxParallel?: number; maxSubagents?: number; defaultTimeoutMs?: number; allowWrites?: boolean; defaultTools?: string[]; } export interface CodaliRuntimeSessionInput { id?: string; storageDir?: string; resume?: boolean; compactOnFinish?: boolean; loadInstructions?: boolean; includeLocalInstructions?: boolean; focusPaths?: string[]; } export type CodaliRuntimeEvent = { type: "status"; phase: AgentStatusPhase; message?: string; at: string; } | { type: "token"; content: string; at: string; } | { type: "tool_call"; id: string; name: string; args: unknown; at: string; } | { type: "tool_result"; id: string; name: string; ok: boolean; output: string; errorCode?: string; retryable?: boolean; at: string; } | { type: "usage"; usage: ProviderUsage; at: string; } | { type: "subagent_start"; id: string; role: string; goal: string; at: string; } | { type: "subagent_result"; id: string; role: string; status: string; summary: string; at: string; } | { type: "final"; content: string; at: string; } | { type: "error"; message: string; code?: string; retryable?: boolean; at: string; }; export interface CodaliRuntimeInput { task: string; messages?: ProviderMessage[]; workspace: CodaliRuntimeWorkspace; provider: CodaliRuntimeProviderInput; agent?: CodaliRuntimeAgentInput; docdex?: CodaliRuntimeDocdexInput; policy: CodaliRuntimePolicy; response?: { format?: "text" | "json" | "json_schema" | "gbnf"; schema?: Record; grammar?: string; }; streaming?: { enabled: boolean; flushEveryMs?: number; }; metadata?: { jobId?: string; requestId?: string; tenantId?: string; ownerUserId?: string; apiKeyId?: string; agentSlug?: string; }; subagents?: CodaliRuntimeSubagentsInput; session?: CodaliRuntimeSessionInput; onEvent?: (event: CodaliRuntimeEvent) => void | Promise; providerInstance?: Provider; toolRegistry?: ToolRegistry; tools?: ToolDefinition[]; toolContext?: Partial; logger?: RunLogger; } export interface CodaliOpenAIChunkOptions { id?: string; requestId?: string; model: string; created?: number; includeInternalEvents?: boolean; } export interface CodaliRuntimeResult { finalMessage: string; messages: ProviderMessage[]; toolCallsExecuted: number; usage?: ProviderUsage; touchedFiles: string[]; warnings: string[]; events: CodaliRuntimeEvent[]; runId: string; telemetry: CodaliRuntimeTelemetry; session?: { id: string; summaryRefs: string[]; instructionSources: string[]; }; } export declare const codaliEventToOpenAIChatCompletionChunk: (event: CodaliRuntimeEvent, options: CodaliOpenAIChunkOptions) => Record | null; export declare const codaliEventToOpenAISseData: (event: CodaliRuntimeEvent, options: CodaliOpenAIChunkOptions) => string | null; export interface CodaliRuntime { run(): Promise; } export declare const createCodaliRuntime: (input: CodaliRuntimeInput) => CodaliRuntime; export declare const runCodaliTask: (input: CodaliRuntimeInput) => Promise; //# sourceMappingURL=CodaliRuntime.d.ts.map