import type { AgentFailureCategory } from '../types/agent-failure.js'; import type { CanonicalWorkflowResumeFrame } from '../types/workflow-resume.js'; /** * Type definitions for utils module. * * Contains session log types and NDJSON record types * used by SessionManager and its consumers. */ /** Session log entry */ export interface SessionLog { task: string; projectDir: string; workflowName: string; iterations: number; startTime: string; endTime?: string; status: 'running' | 'completed' | 'aborted'; history: Array<{ step: string; persona: string; instruction: string; status: string; timestamp: string; content: string; error?: string; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; /** Matched rule index (0-based) when rules-based detection was used */ matchedRuleIndex?: number; /** How the rule match was detected */ matchedRuleMethod?: string; /** Method used by status judgment phase */ matchMethod?: string; /** Machine-readable provider-normalized failure classification */ failureCategory?: AgentFailureCategory; }>; } export interface NdjsonWorkflowStart { type: 'workflow_start'; task: string; workflowName: string; startTime: string; } export type NdjsonWorkflowStackEntry = CanonicalWorkflowResumeFrame; /** * Canonical identity for a step's participation in a parallel invocation. * * This is intentionally small and contains only stable workflow/step * identity, never prompts, responses, or provider data. It is optional so * older session logs remain valid. */ export type NdjsonParallelRole = 'parent' | 'direct_participant' | 'workflow_call_participant'; export interface NdjsonParallelMetadata { readonly role: NdjsonParallelRole; readonly participationId: string; readonly parentParticipationId?: string; } export interface NdjsonWorkflowCallStart { type: 'workflow_call_start'; workflow: string; step: string; childWorkflow: string; callInstance: number; stack: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; timestamp: string; } export interface NdjsonWorkflowCallComplete { type: 'workflow_call_complete'; workflow: string; step: string; childWorkflow: string; callInstance: number; stack: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; status: 'completed' | 'aborted' | 'failed'; returnValue?: string; abortKind?: string; abortReason?: string; reason?: string; timestamp: string; } export interface NdjsonStepStart { type: 'step_start'; step: string; persona: string; iteration: number; timestamp: string; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; instruction?: string; provider?: string; providerSource?: string; model?: string; modelSource?: string; providerOptions?: unknown; providerOptionsSources?: Record; } export interface NdjsonStepComplete { type: 'step_complete'; step: string; persona: string; iteration: number; status: string; content: string; instruction: string; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; matchedRuleIndex?: number; matchedRuleMethod?: string; matchMethod?: string; error?: string; failureCategory?: AgentFailureCategory; timestamp: string; } export interface NdjsonWorkflowComplete { type: 'workflow_complete'; iterations: number; endTime: string; publicationId?: string; } export interface NdjsonWorkflowAbort { type: 'workflow_abort'; iterations: number; reason: string; failureCategory?: AgentFailureCategory; endTime: string; publicationId?: string; } export interface NdjsonPhaseStart { type: 'phase_start'; step: string; iteration?: number; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; phase: 1 | 2 | 3; phaseName: 'execute' | 'report' | 'judge'; phaseExecutionId?: string; timestamp: string; instruction?: string; systemPrompt?: string; userInstruction?: string; } export interface NdjsonPhaseComplete { type: 'phase_complete'; step: string; iteration?: number; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; phase: 1 | 2 | 3; phaseName: 'execute' | 'report' | 'judge'; phaseExecutionId?: string; status: string; content?: string; timestamp: string; error?: string; } export interface NdjsonPhaseJudgeStage { type: 'phase_judge_stage'; step: string; iteration?: number; workflow?: string; stack?: NdjsonWorkflowStackEntry[]; parallel?: NdjsonParallelMetadata; phase: 3; phaseName: 'judge'; phaseExecutionId?: string; stage: 1 | 2 | 3; method: 'structured_output' | 'phase3_tag' | 'ai_judge'; status: 'done' | 'error' | 'skipped'; instruction: string; response: string; timestamp: string; } export interface NdjsonInteractiveStart { type: 'interactive_start'; timestamp: string; } export interface NdjsonInteractiveEnd { type: 'interactive_end'; confirmed: boolean; task?: string; timestamp: string; } export type NdjsonCompanionReviewTrigger = 'quiet' | 'forced' | 'completion' | 'commit'; export type NdjsonCompanionReviewMode = 'completion' | 'live'; export interface NdjsonCompanionReviewRound { type: 'companion_review_round'; step: string; reviewMode: NdjsonCompanionReviewMode; companion: string; trigger: NdjsonCompanionReviewTrigger; digest: string; changedLines: number; findingCount: number; reviewerFindings: NdjsonCompanionAcceptedFinding[]; moderator?: NdjsonCompanionModeratorAudit; acceptedFindings: NdjsonCompanionAcceptedFinding[]; zeroReason?: NdjsonCompanionZeroReason; runPathNamespace?: string[]; timestamp: string; } export interface NdjsonCompanionQueueCoalesced { type: 'companion_queue_coalesced'; step: string; companion: string; replaced: { trigger: NdjsonCompanionReviewTrigger; digest: string; changedLines: number; observedGeneration: number; }; replacement: { trigger: NdjsonCompanionReviewTrigger; digest: string; changedLines: number; observedGeneration: number; }; runPathNamespace?: string[]; timestamp: string; } export type NdjsonCompanionCallPurpose = 'selector' | 'reviewer' | 'moderator'; export type NdjsonCompanionCallStatus = 'completed' | 'failed'; export interface NdjsonCompanionUsage { inputTokens?: number; outputTokens?: number; totalTokens?: number; cachedInputTokens?: number; cacheCreationInputTokens?: number; cacheReadInputTokens?: number; usageMissing: boolean; reason?: string; } export interface NdjsonCompanionCall { type: 'companion_call'; step: string; agent: string; purpose: NdjsonCompanionCallPurpose; attempt: number; status: NdjsonCompanionCallStatus; provider: string; model?: string; runPathNamespace?: string[]; sessionIdAvailable: boolean; sessionId?: string; promptResolved: boolean; systemPrompt?: string; systemPromptTruncated?: boolean; prompt?: string; promptTruncated?: boolean; response?: string; responseTruncated?: boolean; structuredOutput?: string; structuredOutputTruncated?: boolean; usage: NdjsonCompanionUsage; error?: string; errorTruncated?: boolean; timestamp: string; } export type NdjsonCompanionZeroReason = 'reviewer_returned_no_findings' | 'moderator_rejected_all_findings'; export interface NdjsonCompanionModeratorDecision { action: 'accept' | 'reject'; sourceIndex: number; } export interface NdjsonCompanionModeratorAudit { name: string; invoked: boolean; reason?: 'reviewer_result_empty' | 'not_configured'; decisions: NdjsonCompanionModeratorDecision[]; } export interface NdjsonCompanionAcceptedFinding { severity: 'must_fix' | 'should_fix' | 'nit'; file: string; line: number; finding: string; } export type NdjsonCompanionReviewPhase = 'initial' | 'live' | 'fix' | 'completion'; export type NdjsonCompanionReviewSkipReason = 'companion_disabled' | 'companion_not_configured' | 'companion_runtime_unavailable' | 'selector_empty' | 'empty_diff' | 'unchanged_digest' | 'below_minimum_changed_lines'; export interface NdjsonCompanionReviewSkipped { type: 'companion_review_skipped'; step: string; companion?: string; phase: NdjsonCompanionReviewPhase; reason: NdjsonCompanionReviewSkipReason; fixRound?: number; observedGeneration?: number; runPathNamespace?: string[]; timestamp: string; } export type NdjsonRecord = NdjsonWorkflowStart | NdjsonWorkflowCallStart | NdjsonWorkflowCallComplete | NdjsonStepStart | NdjsonStepComplete | NdjsonWorkflowComplete | NdjsonWorkflowAbort | NdjsonPhaseStart | NdjsonPhaseComplete | NdjsonPhaseJudgeStage | NdjsonInteractiveStart | NdjsonInteractiveEnd | NdjsonCompanionReviewRound | NdjsonCompanionQueueCoalesced | NdjsonCompanionCall | NdjsonCompanionReviewSkipped; //# sourceMappingURL=types.d.ts.map