export type ProviderRole = "system" | "user" | "assistant" | "tool"; export type LocalRunnerKind = "vllm" | "llama-cpp" | "llama-cpp-python" | "stable-diffusion-cpp" | "lm-studio" | "localai" | "sglang" | "tgi" | "custom"; export type LocalRunnerAuthMode = "none" | "bearer" | "dummy-bearer"; export type LocalRunnerResponseFormatStrategy = "openai" | "json-object" | "json-schema" | "gbnf" | "prompt-only" | "none"; export interface LocalOpenAiCompatibleRunnerConfig { baseUrl?: string; endpoint?: string; apiBaseUrl?: string; 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 ProviderMessage { role: ProviderRole; content: string; name?: string; toolCallId?: string; } export interface ProviderUsage { inputTokens?: number; outputTokens?: number; totalTokens?: number; } 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; immutableRuntimeContext?: boolean; required?: boolean; allowedOperations?: string[]; capabilities?: Record; initialize?: boolean; allowWeb?: boolean; allowMemoryWrite?: boolean; allowProfileWrite?: boolean; allowIndexRebuild?: boolean; toolManifest?: Record; } export interface CodaliRuntimeAgentInput { slug: string; adapter: string; provider?: string; model: string; baseUrl?: string; 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; capabilities?: string[]; contextWindow?: number; maxOutputTokens?: number; } export interface CodaliRuntimePolicy { allowWrites: boolean; allowShell: boolean; allowDestructiveOperations: boolean; allowOutsideWorkspace: boolean; allowedTools?: string[]; deniedTools?: string[]; appToolContracts?: Record | Array>; appVirtualTools?: string[]; appToolGateway?: Record; 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: string; 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?: unknown; toolRegistry?: unknown; tools?: unknown[]; toolContext?: Record; logger?: unknown; } 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 interface CodaliRuntimeTelemetry { runId: string; runtime: "codali"; mode: CodaliRuntimePolicy["mode"]; toolCallCount: number; calledTools: string[]; consideredTools: string[]; registeredDynamicTools: string[]; skippedDynamicTools: Array<{ name: string; reason: string; }>; dynamicToolCalls: Array<{ name: string; backingTool?: string; status: "success" | "failed" | "blocked"; latencyMs: number; errorCode?: string; errorMessage?: string; }>; warnings: string[]; } export interface CodaliJobStageDefinition { id: string; kind: string; role?: string; title?: string; goal?: string; prompt?: string; dependsOn?: string[]; optional?: boolean; maxSteps?: number; maxToolCalls?: number; timeoutMs?: number; mode?: CodaliRuntimePolicy["mode"]; agent?: CodaliRuntimeAgentInput; provider?: CodaliRuntimeProviderInput; response?: CodaliRuntimeInput["response"]; outputSchema?: Record; metadata?: Record; } export interface CodaliJobBudgets { maxRuntimeMs?: number; maxToolCalls?: number; maxFollowups?: number; maxParallelStages?: number; } export interface CodaliJobAgentPolicy { defaultAgent?: CodaliRuntimeAgentInput; defaultProvider?: CodaliRuntimeProviderInput; stageAgents?: Record; stageProviders?: Record; preferSmallLocal?: boolean; allowCloudFallback?: boolean; metadata?: Record; } export interface MswarmCodaliJob { id?: string; jobType: string; input?: unknown; context?: Record; tenant?: Record; requester?: Record; toolManifest?: Record; stages?: CodaliJobStageDefinition[]; budgets?: CodaliJobBudgets; agentPolicy?: CodaliJobAgentPolicy; response?: { format?: "text" | "json" | "json_schema"; schema?: Record; requireEvidence?: boolean; metadata?: Record; }; metadata?: Record; } export interface CodaliJobEvent { type: string; at?: string; runId?: string; jobId?: string; stageId?: string; kind?: string; status?: string; [key: string]: unknown; } export interface CodaliJobRuntimeInput { request: MswarmCodaliJob; runtime: Omit & { messages?: ProviderMessage[]; metadata?: CodaliRuntimeInput["metadata"]; onEvent?: CodaliRuntimeInput["onEvent"]; }; onEvent?: (event: CodaliJobEvent) => void | Promise; } export interface CodaliJobRuntimeError { stageId?: string; code: string; message: string; retryable?: boolean; } export interface CodaliJobStageResult { id: string; kind: string; status: "completed" | "failed" | "skipped"; attempt: number; output: string; toolCallsExecuted: number; warnings: string[]; durationMs: number; agentSlug?: string; model?: string; error?: CodaliJobRuntimeError; } export interface CodaliJobTelemetry { runId: string; runtime: "codali"; mode: "job"; jobId: string; jobType: string; status: "succeeded" | "failed" | "partial" | "needs_clarification"; stageCount: number; toolCallCount: number; calledTools: string[]; consideredTools: string[]; warnings: string[]; errors: CodaliJobRuntimeError[]; stages: Array<{ id: string; kind: string; status: string; attempt: number; durationMs: number; toolCallsExecuted: number; agentSlug?: string; model?: string; errorCode?: string; }>; } export interface CodaliJobRuntimeResult { output: string; status: CodaliJobTelemetry["status"]; runId: string; jobId: string; jobType: string; stages: CodaliJobStageResult[]; usage?: ProviderUsage; toolCallsExecuted: number; touchedFiles: string[]; warnings: string[]; errors: CodaliJobRuntimeError[]; telemetry: CodaliJobTelemetry; messages?: ProviderMessage[]; events?: CodaliJobEvent[]; } export type CodaliGatewayMode = "fast" | "balanced" | "deep" | "cheap" | "image"; export type CodaliGatewayStatus = "succeeded" | "failed" | "partial" | "needs_clarification"; export interface MswarmCodaliGatewayPolicy { [key: string]: unknown; allowedTools?: string[]; deniedTools?: string[]; appToolContracts?: Record | Array>; appVirtualTools?: string[]; appToolGateway?: Record; maxIterations?: number; maxRuntimeMs?: number; maxToolCalls?: number; maxModelCalls?: number; maxEvidenceItems?: number; maxContextPackTokens?: number; allowWrites?: false; allowShell?: false; allowDestructiveOperations?: false; allowOutsideWorkspace?: false; requireFinalLargeModel?: boolean; allowDegradedFinalAnswer?: boolean; allowImageWorker?: boolean; } export interface MswarmCodaliGateway { id?: string; query: string; mode?: CodaliGatewayMode; product?: Record; tenant?: Record; requester?: Record; conversation?: { id?: string; messages?: Array<{ role: "system" | "user" | "assistant"; content: string; }>; }; docdex?: CodaliRuntimeInput["docdex"]; tools?: Record; policy?: MswarmCodaliGatewayPolicy; agentPolicy?: Record; stageAgents?: Record; response?: Record; metadata?: Record; } export interface CodaliGatewayTrace { runId: string; mode: CodaliGatewayMode; status: CodaliGatewayStatus; iterations: number; toolCallCount: number; modelCallCount: number; consideredTools: string[]; calledTools: string[]; warnings: string[]; errors: string[]; toolCalls: Array>; modelCalls: Array>; events: Array>; metadata?: Record; } export interface CodaliGatewayResult { runId: string; status: CodaliGatewayStatus; answer: string; sources: Array>; confidence: "high" | "medium" | "low"; evidence: Array>; contextPack?: Record; finalModel?: Record; trace: CodaliGatewayTrace; telemetry: Record; metadata?: Record; } export interface CodaliGatewayProviderRequest { messages: ProviderMessage[]; tools?: unknown[]; toolChoice?: unknown; maxTokens?: number; temperature?: number; responseFormat?: { type: "json" | "json_schema" | "text" | "gbnf"; schema?: Record; grammar?: string; }; stream?: boolean; onToken?: (token: string) => void; onEvent?: (event: unknown) => void; streamFlushMs?: number; } export interface CodaliGatewayProvider { name: string; generate(request: CodaliGatewayProviderRequest): Promise<{ message: ProviderMessage; toolCalls?: unknown[]; usage?: ProviderUsage; raw?: unknown; }>; } export interface CodaliGatewayOptions { provider: CodaliGatewayProvider; taskRunner?: { run(input: Record): Promise>; }; agentInventory?: unknown[]; workerOptions?: Record; finalSynthesizerOptions?: Record; } export interface CodaliGatewayEvent { type: string; at?: string; runId?: string; status?: CodaliGatewayStatus; mode?: CodaliGatewayMode; [key: string]: unknown; } export interface MswarmCodaliChatMessage { role: string; content: string | Array<{ type: string; text?: string; }>; } export interface MswarmCodaliAgent { slug: string; adapter: string; provider?: string; model: string; baseUrl?: string; apiKey?: string; 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; capabilities?: string[]; contextWindow?: number; maxOutputTokens?: number; } export interface MswarmCodaliWorkspace { root: string; readOnly?: boolean; } export interface MswarmCodaliDocdex { enabled?: boolean; baseUrl?: string; repoRoot?: string; repoId?: string; dagSessionId?: string; apiKey?: string; clientIdentity?: string; credentialSource?: "attached_mswarm_api_key" | string; immutableRuntimeContext?: boolean; required?: boolean; allowedOperations?: string[]; capabilities?: Record; initialize?: boolean; allowWeb?: boolean; allowMemoryWrite?: boolean; allowProfileWrite?: boolean; allowIndexRebuild?: boolean; toolManifest?: Record; } export interface MswarmCodaliPolicy { allowTools?: boolean; allowedTools?: string[]; deniedTools?: string[]; appToolContracts?: Record | Array>; appVirtualTools?: string[]; appToolGateway?: Record; allowShell?: boolean; allowWrites?: boolean; allowDestructiveOperations?: boolean; allowOutsideWorkspace?: boolean; maxRuntimeMs?: number; maxToolCalls?: number; maxOutputTokens?: number; } export interface MswarmCodaliSession extends CodaliRuntimeSessionInput { } export interface MswarmCodaliSubagents extends CodaliRuntimeSubagentsInput { } export interface MswarmCodaliInvocationInput { jobId: string; requestId: string; model: string; messages: MswarmCodaliChatMessage[]; agent: MswarmCodaliAgent; workspace?: MswarmCodaliWorkspace; docdex?: MswarmCodaliDocdex; policy?: MswarmCodaliPolicy; session?: MswarmCodaliSession; subagents?: MswarmCodaliSubagents; attachedMswarmApiKey?: string; temperature?: number; responseFormat?: Record | null; stream?: boolean; codaliGateway?: MswarmCodaliGateway; codaliJob?: MswarmCodaliJob; onOpenAIChunk?: (chunk: Record) => void | Promise; onRuntimeEvent?: (event: CodaliRuntimeEvent) => void | Promise; onJobEvent?: (event: CodaliJobEvent) => void | Promise; onGatewayEvent?: (event: CodaliGatewayEvent) => void | Promise; runCodali?: (input: CodaliRuntimeInput) => Promise; runCodaliJob?: (input: CodaliJobRuntimeInput) => Promise; runCodaliGateway?: (request: MswarmCodaliGateway, options: CodaliGatewayOptions) => Promise; } export declare const MSWARM_CODALI_FEEDBACK_SUBMISSION_SCHEMA_VERSION: "codali.feedback_submission.v1"; export declare const MSWARM_CODALI_PRODUCT_METADATA_SCHEMA_VERSION: "codali.product_metadata.v1"; export type MswarmCodaliFeedbackSubmissionVisibility = "requester" | "conversation" | "product" | "tenant"; export interface MswarmCodaliFeedbackSubmissionMetadata { schema_version: typeof MSWARM_CODALI_FEEDBACK_SUBMISSION_SCHEMA_VERSION; run_id: string; deletion_group_id: string; target: { record_type: "gateway_record"; record_id: string; role: "codali_gateway_answer" | "codali_job_result" | "codali_runtime_result"; metadata?: Record; }; candidate_records: Array<{ record_type: "gateway_record"; record_id: string; role: "codali_gateway_answer" | "codali_job_result" | "codali_runtime_result"; metadata?: Record; }>; product_scope?: Record; requester_scope: { visibility: MswarmCodaliFeedbackSubmissionVisibility; tenant_wide: boolean; requester_hash?: string; conversation_hash?: string; requester_type?: string; metadata?: Record; }; source: { runtime: "mswarm"; job_id: string; request_id: string; agent_slug: string; session_id?: string; }; raw_trace_included: false; } export interface MswarmCodaliProductDatasetCollectionMetadata { accepted?: boolean; status: string; record_count?: number; object_count?: number; replayed?: boolean; fallback_used?: boolean; errors?: string[]; record_counts?: Record; } export interface MswarmCodaliProductMetadata { schema_version: typeof MSWARM_CODALI_PRODUCT_METADATA_SCHEMA_VERSION; run_id: string; trace_id: string; context_pack_id?: string; dataset_collection: MswarmCodaliProductDatasetCollectionMetadata; privacy_flags: { local_only: boolean; upload_allowed: boolean; export_allowed: boolean; training_allowed: boolean; raw_trace_included: false; contains_personal_data?: boolean; contains_tenant_private_data?: boolean; contains_customer_data?: boolean; }; record_counts: { dataset_records?: number; sources: number; evidence: number; tool_calls: number; model_calls: number; context_packs: number; final_answers: number; warnings: number; errors: number; }; feedback_ref: { schema_version: typeof MSWARM_CODALI_FEEDBACK_SUBMISSION_SCHEMA_VERSION; run_id: string; deletion_group_id: string; target: MswarmCodaliFeedbackSubmissionMetadata["target"]; candidate_record_count: number; product_scope?: Record; requester_scope: MswarmCodaliFeedbackSubmissionMetadata["requester_scope"]; raw_trace_included: false; }; called_tools: string[]; model_tiers: Array<{ role?: string; tier?: string; model?: string; provider?: string; agent_slug?: string; }>; warnings: string[]; errors: string[]; latency_ms?: number; latency: { total_ms?: number; model_ms?: number; tool_ms?: number; }; } export interface MswarmCodaliInvocationResult { output: string; usage?: ProviderUsage; runtimeResult: CodaliRuntimeResult | CodaliJobRuntimeResult | CodaliGatewayResult; jobResult?: CodaliJobRuntimeResult; gatewayResult?: CodaliGatewayResult; openAIChunks: Record[]; metadata: { provider: string; adapter: string; local_model: string; agent_slug: string; runtime: "codali"; run_id: string; tool_calls_executed: number; called_tools: string[]; dynamic_tools_considered: string[]; dynamic_tools_registered: string[]; dynamic_tools_skipped: Array<{ name: string; reason: string; }>; tool_call_details: CodaliRuntimeTelemetry["dynamicToolCalls"]; telemetry?: CodaliRuntimeTelemetry | CodaliJobTelemetry | Record; codali_job_id?: string; codali_job_type?: string; codali_job_status?: CodaliJobRuntimeResult["status"]; codali_job_stage_count?: number; codali_job_stages?: CodaliJobTelemetry["stages"]; codali_job_errors?: CodaliJobRuntimeError[]; codali_gateway_id?: string; codali_gateway_status?: CodaliGatewayStatus; codali_gateway_mode?: CodaliGatewayMode; codali_gateway_task_count?: number; codali_gateway_tool_call_count?: number; codali_gateway_model_call_count?: number; codali_gateway_source_count?: number; codali_gateway_evidence_count?: number; codali_gateway_warnings?: string[]; codali_gateway_errors?: string[]; codali_gateway_trace?: CodaliGatewayTrace; feedback_submission?: MswarmCodaliFeedbackSubmissionMetadata; codali_product_metadata?: MswarmCodaliProductMetadata; touched_files: string[]; warnings: string[]; mode: CodaliRuntimeInput["policy"]["mode"]; session_id?: string; }; } export declare class MswarmCodaliExecutor { invoke(input: MswarmCodaliInvocationInput): Promise; } //# sourceMappingURL=codali-executor.d.ts.map