/** * Runtime contract for model-backed providers. * * Warden's analysis pipeline builds prompts, handles retry policy, parses * findings, and aggregates report data. Runtime interfaces are backend * capabilities underneath that pipeline. Runtimes expose skill execution, * auxiliary model tasks, and synthesis tasks. * * Runtime implementations are responsible for backend-specific execution * details such as model identifiers, stream events, authentication side * channels, stderr/diagnostics, telemetry attributes, tool loops, and usage * normalization. Callers should be able to switch runtimes without changing * hunk parsing, extraction repair, deduplication, fix gates, or reporting. */ import { z } from 'zod'; import type { Span } from '@sentry/node'; import type { Effort, ToolConfig } from '../../config/schema.js'; import type { TraceRecorder } from '../../sentry-trace.js'; import type { UsageStats } from '../../types/index.js'; export declare const RuntimeNameSchema: z.ZodEnum<{ pi: "pi"; claude: "claude"; }>; export type RuntimeName = z.infer; export type SkillRunStatus = 'success' | 'provider_error' | 'auth_error' | 'turn_limit' | 'budget_limit' | 'aborted' | 'structured_output_error'; export interface SkillRunOptions { maxTurns?: number; model?: string; effort?: Effort; abortController?: AbortController; } export interface SkillRunRequest { /** Optional legacy Anthropic API key, used only when a runtime targets Anthropic-compatible models. */ apiKey?: string; systemPrompt: string; userPrompt: string; repoPath: string; skillName: string; options: SkillRunOptions; tools?: ToolConfig; /** * Allow explicitly requested mutating tools for trusted internal writer tasks. * Normal skill analysis keeps this false so hunks remain read-only. */ allowMutatingTools?: boolean; /** Optional parent span used to attach runtime telemetry to a hunk trace. */ parentSpan?: Span; /** Optional recorder used to persist runtime child spans in structured traces. */ traceRecorder?: TraceRecorder; /** Provider-specific settings consumed only by the selected runtime adapter. */ providerOptions?: unknown; } export interface SkillRunResult { status: SkillRunStatus; text: string; errors: string[]; usage: UsageStats; responseId?: string; responseModel?: string; sessionId?: string; durationMs?: number; durationApiMs?: number; numTurns?: number; } export interface SkillRunResponse { result?: SkillRunResult; /** Authentication error surfaced by the runtime, if available out-of-band. */ authError?: string; /** Captured runtime stderr or diagnostics for clearer failures. */ stderr?: string; } export interface AuxiliaryTool { name: string; description?: string; inputSchema: Record; } export type AuxiliaryTask = 'extraction' | 'deduplication' | 'fix_evaluation'; export type SynthesisTask = 'consolidation' | 'skill_build'; export type AuxiliaryRunResult = { success: true; data: T; usage: UsageStats; } | { success: false; error: string; usage: UsageStats; }; interface AuxiliaryRunRequestBase { task: AuxiliaryTask; /** Skill or agent name that owns this auxiliary call, when available. */ agentName?: string; apiKey?: string; prompt: string; schema: z.ZodType; model?: string; maxTokens?: number; timeout?: number; maxRetries?: number; } interface AuxiliaryRunRequestWithoutTools extends AuxiliaryRunRequestBase { tools?: undefined; executeTool?: undefined; maxIterations?: undefined; } interface AuxiliaryRunRequestWithTools extends AuxiliaryRunRequestBase { tools: AuxiliaryTool[]; executeTool: (name: string, input: Record) => Promise; maxIterations?: number; } export type AuxiliaryRunRequest = AuxiliaryRunRequestWithoutTools | AuxiliaryRunRequestWithTools; export interface SynthesisRunRequest { task: SynthesisTask; /** Skill or agent name that owns this synthesis call, when available. */ agentName?: string; apiKey?: string; prompt: string; schema: z.ZodType; model?: string; maxTokens?: number; timeout?: number; maxRetries?: number; } export interface Runtime { readonly name: RuntimeName; runSkill(request: SkillRunRequest): Promise; runAuxiliary(request: AuxiliaryRunRequest): Promise>; runSynthesis(request: SynthesisRunRequest): Promise>; } export {}; //# sourceMappingURL=types.d.ts.map