import { type ProfileId } from '../profiles/index.js'; import type { WorkflowPhase } from '../types/index.js'; import { type PreProcessorConfig } from './context-preprocessor.js'; import type { KnowledgeReadiness } from './knowledge-refresh.js'; import { type LessonRecord } from './workflow-lessons.js'; export type DelegationReference = { path: string; title: string; source: 'playbook' | 'skill' | 'doc'; }; export type TrimReport = { originalChars: number; finalChars: number; trimmedSections: Array<{ section: 'evidence' | 'lessons' | 'priorPhases' | 'decisions' | 'projectKnowledge' | 'playbooks' | 'profileRules'; removedItems: number; charsReclaimed: number; }>; }; export type DelegationPacket = { taskId: string; runId: string; phase: WorkflowPhase; profile: ProfileId; profileRules: string | null; projectKnowledge: string | null; permissions: string | null; playbooks: string[]; references: DelegationReference[]; context: DelegationContext; expectedDeliverable: string; constraints: string[]; routing?: { status: 'selected' | 'ambiguous' | 'no-match' | 'unavailable'; source: 'inference' | 'explicit-override' | 'neutral'; ranked: Array<{ profileId: ProfileId; score: number; matched: string[]; }>; acceptedProfiles: ProfileId[]; requiredGates: string[]; expectedEvidence: string[]; overrideRationale?: string; }; trimReport?: TrimReport; knowledgeReadiness?: KnowledgeReadiness; knowledgeBootstrapRequired?: boolean; }; export type DelegationContext = { goal: string; decisions: DelegationDecision[]; evidence: DelegationEvidence[]; lessons?: LessonRecord[]; clarifications: DelegationClarification[]; priorPhases: DelegationPhaseOutcome[]; acceptanceCriteria: string[]; }; export type DelegationDecision = { id: string; owner: string; summary: string; rationale?: string; }; export type DelegationEvidence = { id: string; owner: string; summary: string; kind: string; }; export type DelegationClarification = { question: string; answer: string; fromRole: string; toRole: string; }; export type DelegationPhaseOutcome = { phase: WorkflowPhase; status: string; profile: ProfileId; }; export type SubAgentResponse = { type: 'deliverable'; content: string; artifacts?: string[]; tokenUsage?: ParsedTokenUsage; } | { type: 'clarification'; question: string; toRole?: string; options?: string[]; } | { type: 'blocked'; reason: string; }; export type ParsedTokenUsage = { inputTokens: number; outputTokens: number; model?: string; costUsd?: number; }; export type BuildPacketOptions = { cwd: string; taskId: string; runId: string; phase: WorkflowPhase; goal: string; priorPhases?: DelegationPhaseOutcome[]; runtimeTarget?: 'claude' | 'cursor' | 'codex' | 'generic'; maxContextChars?: number; maxPlaybookChars?: number; totalBudgetChars?: number; includeTrimReport?: boolean; preProcessorConfig?: PreProcessorConfig; }; export declare function buildDelegationPacket(options: BuildPacketOptions): Promise; export declare function estimatePacketChars(packet: DelegationPacket): number; type ApplyBudgetOptions = { includeTrimReport?: boolean; }; export declare function applyTotalBudget(packet: DelegationPacket, budget: number, options?: ApplyBudgetOptions): DelegationPacket; export declare function renderPacketAsPrompt(packet: DelegationPacket): string; export declare function parseSubAgentResponse(stdout: string, exitCode?: number): SubAgentResponse | null; export declare function parseTokenUsage(stdout: string): ParsedTokenUsage | null; /** * Detects whether project-knowledge.md is still the unfilled generated template: * the placeholder comments the generator writes are intact and no naming-convention * row has been populated. Returns false when the file has been meaningfully filled. */ export declare function projectKnowledgeIsTemplate(content: string): boolean; export {};