import type { ProfileId } from '../profiles/index.js'; import type { PreProcessorConfig } from '../services/context-preprocessor.js'; import type { KnowledgeManifest, KnowledgeReadiness } from '../services/knowledge-refresh.js'; import type { OpenCodeHealth } from '../services/opencode-health.js'; import type { PromptRegistryHealth } from '../services/prompt-registry.js'; import type { ReferenceHealth } from '../services/reference-fetcher.js'; import type { SetupHealth, SetupManifest } from '../services/setup-health.js'; import type { LessonHealth, LessonMigrationReport, LessonRecord } from '../services/workflow-lessons.js'; export type { CalibrationDriftEntry, SizingCategoryStats, CalibrationResult, CalibrationLesson, } from './velocity-calibration.js'; export type { TestStatus, TestResult, TestSummary, CoverageSummary, CoverageMetric, LintSeverity, LintIssue, LintSummary, EvidenceGenerationStatus, EvidenceGenerationResult, AllEvidenceResult, } from './qa-evidence.js'; export type { ProjectionScope, ProjectionConfidence, BudgetProjection, ProjectionOptions, } from './budget-projection.js'; export type { DashboardChartType, ChartDataPoint, DashboardData, DashboardOptions } from './dashboard.js'; export type { DiagramType, DiagramNodeShape, DiagramNode, DiagramEdge, EdgeCardinality, ClassRelation, DiagramLayoutDirection, DiagramParticipant, StoryMap, AgentDiagramData, DiagramOutputFormat, MaxGraphNode, MaxGraphEdge, MaxGraphJson, } from './diagram.js'; export type { ReportSeverity, ReportFinding, ReportMetric, ReportRecommendation, ReportSection, AgentReportData, ReportOutputFormat, } from './report.js'; export type { ConsentLevel, RedactionRule, ExportFormat, ExportOptions, ExportResult, AuditEntry, } from './telemetry-export.js'; export declare const SUPPORTED_TOOLS: readonly ["cursor", "vscode", "codex", "claude", "agentforce", "windsurf", "jetbrains", "opencode"]; export type SupportedTool = (typeof SUPPORTED_TOOLS)[number]; export type SetupAgentsWorkspaceMode = 'project' | 'advisory'; export type SetupAgentsProfileOwner = `setup-agents:${ProfileId}`; /** Enforcement mode for the recorded-evidence quality gate (GH-525). */ export type SetupAgentsEvidenceGateMode = 'block' | 'warn' | 'off'; export type SetupAgentsStateRecordKind = 'decision' | 'evidence' | 'handoff' | 'review'; export type SetupAgentsReviewStatus = 'pending' | 'approved' | 'blocked' | 'changes'; export type SetupAgentsEvidenceKind = 'command' | 'file' | 'screenshot' | 'trace' | 'report' | 'validation' | 'manual' | 'review' | 'lesson' | 'other'; export type SetupAgentsTaskStatus = 'open' | 'claimed' | 'done' | 'cancelled' | 'blocked' | 'deleted' | 'archived'; export type SetupAgentsTaskEvent = 'created' | 'claimed' | 'done' | 'cancelled' | 'blocked' | 'updated' | 'deleted' | 'archived'; export type SetupAgentsStateRecordBase = { id: string; kind: SetupAgentsStateRecordKind; createdAt: string; summary: string; taskIds: string[]; }; export type SetupAgentsEvidenceRecord = SetupAgentsStateRecordBase & { kind: 'evidence'; owner?: SetupAgentsProfileOwner; evidenceKind: SetupAgentsEvidenceKind; command?: string; path?: string; exitCode?: number; details?: string; /** Measured human-effort minutes — set for `manual` / `review` kinds (GH-445). */ minutes?: number; }; export type SetupAgentsDecisionRecord = SetupAgentsStateRecordBase & { kind: 'decision'; owner: SetupAgentsProfileOwner; rationale?: string; outcome?: string; alternatives?: string[]; evidenceIds?: string[]; }; export type SetupAgentsHandoffRecord = SetupAgentsStateRecordBase & { kind: 'handoff'; from: SetupAgentsProfileOwner; to: SetupAgentsProfileOwner; changedFiles?: string[]; risks?: string[]; nextActions?: string[]; acceptanceCriteria?: string[]; capabilitySignals?: string[]; evidenceIds?: string[]; }; export type SetupAgentsReviewRecord = SetupAgentsStateRecordBase & { kind: 'review'; status: SetupAgentsReviewStatus; requester: SetupAgentsProfileOwner; reviewer?: SetupAgentsProfileOwner; gates: string[]; findings?: string; recommendation?: string; completedAt?: string; returnTarget?: WorkflowPhase; correctionIteration?: number; runId?: string; sourceDigest?: string; }; export type SetupAgentsStateRecord = SetupAgentsEvidenceRecord | SetupAgentsDecisionRecord | SetupAgentsHandoffRecord | SetupAgentsReviewRecord; export type SetupAgentsTaskRoles = { required: string[]; optional: string[]; }; export type SetupAgentsProfileRoutingDecision = { status: 'selected' | 'ambiguous' | 'no-match' | 'unavailable'; source: 'inference' | 'explicit-override' | 'neutral'; ranked: Array<{ profileId: ProfileId; score: number; matched: string[]; }>; selectedProfile: ProfileId | null; suggestedRequiredProfiles: ProfileId[]; suggestedOptionalProfiles: ProfileId[]; acceptedProfiles: ProfileId[]; candidateSpecializations?: Array<'ta' | 'sa' | 'mulesoft' | 'informatica' | 'salesforce-release' | 'mulesoft-release'>; specializationQuestions?: string[]; overrideRationale?: string; }; export type PhaseOverrideAction = 'skip' | 'add' | 'require-gate' | 'remove-gate'; export type PhaseOverride = { phase: WorkflowPhase; action: PhaseOverrideAction; reason?: string; }; export type SetupAgentsTaskType = 'story' | 'epic' | 'subtask'; export type DecompositionVote = { voter: 'ba' | 'ta'; verdict: 'proceed' | 'decompose'; reason: string; suggestedSplits?: string[]; }; export type SetupAgentsTaskRecord = { id: string; kind: 'task'; event: SetupAgentsTaskEvent; summary: string; status: SetupAgentsTaskStatus; owner?: SetupAgentsProfileOwner; mode?: SetupAgentsWorkspaceMode; roles?: SetupAgentsTaskRoles; routing?: SetupAgentsProfileRoutingDecision; declaredPhases?: WorkflowPhase[]; phaseOverrides?: PhaseOverride[]; type?: SetupAgentsTaskType; parentId?: string; /** Structured workflow linkage for phase subtasks. */ runId?: string; phase?: WorkflowPhase; decompositionVotes?: DecompositionVote[]; reason?: string; createdAt: string; updatedAt: string; evidenceIds: string[]; }; export type CommandResult = { record: T; file: string; cwd: string; }; export type CommandListResult = { records: T[]; file: string; cwd: string; }; export type SetupAgentsTaskCreateResult = CommandResult; export type SetupAgentsTaskListResult = CommandListResult; export type SetupAgentsTaskViewResult = CommandResult; export type SetupAgentsTaskClaimResult = CommandResult; export type SetupAgentsTaskDoneResult = CommandResult & { writeBack?: SetupAgentsWriteBackResult; knowledgeUpdates?: string[]; }; export type SetupAgentsTaskUpdateResult = CommandResult; export type SetupAgentsTaskDeleteResult = CommandResult; export type SetupAgentsTaskArchiveResult = CommandResult; export type SetupAgentsEvidenceAddResult = CommandResult; export type SetupAgentsEvidenceListResult = CommandListResult; export type SetupAgentsDecisionAddResult = CommandResult; export type SetupAgentsDecisionListResult = CommandListResult; export type SetupAgentsDecisionRenderResult = { written: Array<{ id: string; path: string; }>; dir: string; cwd: string; }; export type SetupAgentsHandoffCreateResult = CommandResult; export type SetupAgentsHandoffListResult = CommandListResult; export type SetupAgentsOrchestrationConfig = { enabled: boolean; engine: 'native'; mode: SetupAgentsWorkspaceMode; profiles: ProfileId[]; }; export type SetupAgentsNotificationsConfig = { slack?: { webhookEnvVar?: string; }; github?: { issueComment?: boolean; }; }; export type SetupAgentsReleaseCheckConfig = { checks?: Array<'npm-audit' | 'knip' | 'coverage' | 'secret-scan'>; }; export type RuleOverride = { scope?: 'always' | 'auto-attach' | 'description'; globs?: string[]; claudeAlwaysImport?: boolean; }; export type PhaseBudgetEnvelope = { phase?: WorkflowPhase; maxTokens?: number; maxCostCents?: number; maxRetries?: number; maxMinutes?: number; }; export type ArtifactProtectionConfig = { /** Persisted project intent. Mandatory protection cannot be disabled by editing this value. */ enabled: boolean; /** Allows deterministic migrations when the protected artifact inventory changes. */ policyVersion: number; /** Last observed mode. This value is not authoritative repository-ownership evidence. */ repositoryMode: 'customer-repository' | 'salesforce-owned'; /** Only a verified signed policy may establish Salesforce-owned mode. */ classificationSource: 'default' | 'signed-policy'; }; export type SetupAgentsWorkspaceConfig = { version: string; mode: SetupAgentsWorkspaceMode; profiles: ProfileId[]; tools: SupportedTool[]; orchestration: SetupAgentsOrchestrationConfig; notifications?: SetupAgentsNotificationsConfig; releaseCheck?: SetupAgentsReleaseCheckConfig; remote?: { gistId?: string; }; /** Per-profile overrides for Cursor scope and Claude import behavior. */ ruleOverrides?: Partial>; qualityContracts?: QualityContract[]; budgetEnvelopes?: PhaseBudgetEnvelope[]; domains?: DomainId[]; /** * How the engine treats generic/insufficient recorded evidence at gated phase * transitions (ba→architect, document-review→release). `block` rejects the transition, * `warn` emits to stderr but proceeds, `off` disables the check. Project mode * defaults to `block`; advisory mode defaults to `warn`. Persisted values remain explicit. */ evidenceGate?: SetupAgentsEvidenceGateMode; /** * How the engine treats a gated handoff whose *substance* is missing — no * acceptance criteria (or a generic `none`), acceptance criteria without any * mapped evidence, or (for a human-reviewed gate) no recorded review (GH-599). * `block` rejects the transition, `warn` emits to stderr but proceeds, `off` * disables the check. Project mode defaults to `block`; advisory mode defaults to * `warn`. Older project configs therefore migrate fail-closed instead of silently * retaining release-ready behavior. */ gateSubstance?: SetupAgentsEvidenceGateMode; /** Autonomous gate-approval policy (GH-528). Default: disabled (every gate pauses). */ gatePolicy?: SetupAgentsGatePolicyConfig; /** Context pre-processor configuration for reducing large files in delegation packets. */ contextPreProcessor?: PreProcessorConfig; /** * Which FSC white-label country pack to load. Only meaningful when the `fsc` * profile is active. When absent, the `fsc` profile emits its country-neutral * output (existing behavior). Exactly one country per workspace. */ fscWhiteLabel?: FscWhiteLabelCountry; /** Local generated-artifact persistence policy (GH-670). */ artifactProtection?: ArtifactProtectionConfig; }; /** FSC white-label country packs (Mexico, Colombia, Brazil). */ export type FscWhiteLabelCountry = 'mx' | 'co' | 'br'; /** * Policy that lets the engine auto-approve explicitly low-risk gated transitions * instead of pausing for a human (GH-528). Conservative by design: disabled unless * `enabled` is true, and only the listed transitions can ever auto-approve. */ export type SetupAgentsGatePolicyConfig = { /** Master switch. When false/absent every gate pauses for a human (current default). */ enabled?: boolean; /** * Transition keys (e.g. `document-review→release`) eligible for auto-approval. A transition not * listed here always pauses, even when `enabled`. Empty/absent ⇒ none auto-approve. */ autoApproveTransitions?: string[]; }; export type QualityContractMode = 'block' | 'escalate' | 'warn' | 'advisory'; export type PhaseRequiredField = { field: string; description: string; }; export type DomainId = 'healthcare' | 'financial_services' | 'government' | 'defense' | 'education' | 'retail'; export type DomainEscalation = { domains: DomainId[]; additionalChecks: string[]; escalationLevel: 'info' | 'warning' | 'critical'; }; export type QualityContract = { role: string; requiredChecks: string[]; mode: QualityContractMode; requiredFields?: PhaseRequiredField[]; domainEscalation?: DomainEscalation; }; export type WorkflowGateMode = 'none' | 'phase' | 'all'; export type WorkflowSizingLabel = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'; export type WorkflowEstimateConfidence = 'low' | 'medium' | 'high'; export type WorkflowEstimateRecord = { id: string; storyId: string; sizingLabel: WorkflowSizingLabel; soloEstimateDays: number; aiUnguidedEstimateDays: number; aiGuidedDays?: number; confidence: WorkflowEstimateConfidence; declaredBy: string; declaredAt: string; }; export type WorkflowBenchmarkActualSource = 'phase-timeline' | 'task-lifecycle' | null; export type WorkflowBenchmarkResult = { storyId: string; sizingLabel: WorkflowSizingLabel; soloEstimateDays: number; aiUnguidedEstimateDays: number; aiGuidedDays: number | null; actualDays: number | null; actualSource: WorkflowBenchmarkActualSource; vsSoloPct: number | null; vsAiUnguidedPct: number | null; vsAiGuidedPct: number | null; qaIterations: number; evidenceCount: number; status: 'pending' | 'complete'; }; export type WorkflowBenchmarkSummary = { stories: WorkflowBenchmarkResult[]; totalWithActuals: number; avgVsSoloPct: number | null; avgVsAiUnguidedPct: number | null; avgVsAiGuidedPct: number | null; }; export type HistoricalEstimateStats = { count: number; medianSoloDays: number | null; medianAiGuidedDays: number | null; calibrationNote: string | null; }; export type SetupAgentsWorkflowEstimateResult = CommandResult & { historicalStats?: HistoricalEstimateStats; }; export type SetupAgentsWorkflowBenchmarkResult = { result?: WorkflowBenchmarkResult; summary?: WorkflowBenchmarkSummary; file: string; cwd: string; }; export declare const WORKFLOW_PHASES: readonly ["pm", "ba", "architect", "ux", "developer", "security-review", "qa", "document-review", "release"]; export type WorkflowPhase = (typeof WORKFLOW_PHASES)[number]; export type WorkflowPhaseStatus = 'pending' | 'running' | 'done' | 'blocked' | 'skipped' | 'awaiting_clarification'; export type WorkflowPhaseRecord = { phase: WorkflowPhase; status: WorkflowPhaseStatus; taskId: string; handoffId?: string; reviewIds?: string[]; clarificationIds?: string[]; startedAt: string; completedAt?: string; notes?: string; /** Structured failure detail recorded when this phase failed (GH-526). */ correction?: CorrectionPayload; }; /** Severity of a phase failure — drives auto-retry vs human-escalation routing. */ export type CorrectionSeverity = 'low' | 'medium' | 'high'; /** * Structured failure detail produced when a phase fails (e.g. QA), recorded on * the phase record and injected into the re-entered phase's context so the next * attempt sees the specific blocker — not a free-text "qa-fail" note (GH-526). */ export type CorrectionPayload = { /** One-line description of what failed. */ blocker: string; /** Failure severity; high → auto-retry, low → prefer human escalation. */ severity: CorrectionSeverity; /** Optional `file:line` (or file) pointer to where the failure surfaced. */ location?: string; /** Optional concrete remediation hint for the next attempt. */ suggestedFix?: string; /** Evidence record ids backing this correction (test runs, logs, reports). */ evidenceIds?: string[]; /** Phase that receives the correction. Autonomous verification always returns to Developer. */ returnTarget?: WorkflowPhase; /** Immutable autonomous evidence identity. */ identity?: EvidenceIdentity; /** Stable fingerprint used for convergence comparisons. */ fingerprint?: string; status?: 'open' | 'resolved'; }; export type EvidenceIdentity = { runId: string; iteration: number; sourceDigest: string; }; export type WorkflowVerificationLane = 'compile' | 'lint' | 'unit' | 'commands' | 'compiled-cli' | 'bridge' | 'nut' | 'playwright' | 'visual'; export type WorkflowLaneDisposition = { lane: WorkflowVerificationLane; state: 'selected' | 'excluded' | 'blocked'; ruleId: string; reasonCode: string; reason: string; commandId?: string; }; export type WorkflowVerificationResult = EvidenceIdentity & WorkflowLaneDisposition & { id: string; command?: { executable: string; args: string[]; }; status: 'passed' | 'failed' | 'blocked'; exitCode?: number; evidenceId?: string; output?: string; artifactPaths: string[]; startedAt: string; completedAt: string; assertions?: WorkflowAssertionEvidence[]; }; export type WorkflowAssertionEvidence = { assertionId: string; criterionId: string; status: 'passed' | 'failed'; message: string; }; export type WorkflowVerifierContract = { criterionId: string; lane: WorkflowVerificationLane; assertionId: string; description: string; }; export type WorkflowRunBaseline = { capturedAt: string; sourceDigest: string; files: Record; }; export type WorkflowAcceptanceEvidence = EvidenceIdentity & { id: string; criterionId: string; criterion: string; evidenceIds: string[]; assertion: string; status: 'verified' | 'failed' | 'missing'; }; export type WorkflowFinalReport = EvidenceIdentity & { schemaVersion: 1; policyVersion: string; iterations: number; findingsDiscovered: number; findingsResolved: number; acceptanceCriteriaVerified: number; acceptanceCriteriaTotal: number; acceptanceEvidence: WorkflowAcceptanceEvidence[]; lanePlan: WorkflowLaneDisposition[]; commands: WorkflowVerificationResult[]; visualEvidence: Array<{ viewport: string; evidenceIds: string[]; }>; residualRisks: string[]; recommendation: 'GO' | 'NO-GO'; stopReason?: 'scope-architecture-gate' | 'final-release-gate' | 'required-lane-blocked' | 'attempts-exhausted' | 'no-progress' | 'stale-evidence'; }; export type AutonomousRunView = { schemaVersion: 1; runId: string; storyId: string; mode: 'autonomous-v1'; status: WorkflowRunRecord['status']; iteration: number; maxAttempts: number; policyVersion: string; sourceDigest?: string; stopReason?: WorkflowFinalReport['stopReason']; pendingGate?: { phase: WorkflowPhase; reviewId: string; }; lanes: WorkflowLaneDisposition[]; corrections: CorrectionPayload[]; acceptanceEvidence: WorkflowAcceptanceEvidence[]; recommendation: 'GO' | 'NO-GO'; }; export type WorkflowRunRecord = { id: string; storyId: string; gates: WorkflowGateMode; maxIterations: number; qaIterations: number; /** Versioned opt-in controller mode. Missing means the legacy manual workflow. */ deliveryMode?: 'manual' | 'autonomous-v1'; autonomousSchemaVersion?: 1; policyVersion?: string; sourceDigest?: string; baseline?: WorkflowRunBaseline; verificationPlan?: WorkflowLaneDisposition[]; verificationHistory?: WorkflowVerificationResult[]; acceptanceEvidenceHistory?: WorkflowAcceptanceEvidence[]; correctionHistory?: CorrectionPayload[]; consecutiveNoProgress?: number; stopReason?: WorkflowFinalReport['stopReason']; finalReport?: WorkflowFinalReport; invalidatedAutonomousHistory?: Array<{ invalidatedAt: string; reason: string; sourceDigest?: string; finalReport?: WorkflowFinalReport; verificationPlan?: WorkflowLaneDisposition[]; verificationHistory?: WorkflowVerificationResult[]; acceptanceEvidenceHistory?: WorkflowAcceptanceEvidence[]; correctionHistory?: CorrectionPayload[]; }>; phases: WorkflowPhaseRecord[]; status: 'running' | 'paused' | 'done' | 'failed'; createdAt: string; updatedAt: string; rollbackReason?: string; /** * GH-748: set when `workflow run --autonomous` dispatched this phase to the * bridge's async pipeline (chat session) instead of awaiting it inline — * the same background dispatch `workflow execute` uses (GH-746), but this * caller can't just fire-and-forget: it advances the run's phase/gate state * synchronously off the phase's real result, so it pauses here and checks * this spawn's real completion on the next `--resume` instead. Cleared once * that spawn is observed completed (or failed). */ pendingDelegatedPhase?: { phase: WorkflowPhase; spawnSessionId: string; dispatchedAt: string; }; }; export type TaskReconciliationCode = 'legacy-no-workflow' | 'active-workflow' | 'failed-workflow' | 'blocked-phase' | 'pending-review' | 'rejected-review' | 'incomplete-required-phase' | 'run-terminal-conflict' | 'task-terminal-conflict' | 'orphan-phase-task' | 'missing-phase-linkage'; export type TaskReconciliationFinding = { code: TaskReconciliationCode; severity: 'info' | 'warning' | 'error'; message: string; repairable: boolean; }; export type TaskStateProjection = { taskId: string; sourceStatus: SetupAgentsTaskStatus; status: SetupAgentsTaskStatus; latestRunId?: string; latestRunStatus?: WorkflowRunRecord['status']; legacyNoWorkflow: boolean; completionAllowed: boolean; findings: TaskReconciliationFinding[]; }; export type SetupAgentsWorkflowRunResult = { run: WorkflowRunRecord; file: string; cwd: string; }; export type PhasePlanEntry = { phase: WorkflowPhase; profile: string; source: 'always' | 'role-required' | 'role-optional' | 'profile-trigger' | 'override-add' | 'declared'; gateAfter: boolean; overrideApplied?: PhaseOverrideAction; }; export type SetupAgentsWorkflowPhasePlanResult = { plan: PhasePlanEntry[]; skipped: Array<{ phase: WorkflowPhase; reason: string; }>; gates: string[]; cwd: string; }; export type PhaseInstructions = { phase: WorkflowPhase; instructionsDir: string; playbooks: Array<{ filename: string; path: string; exists: boolean; }>; }; export type SetupAgentsWorkflowPlaybooksResult = { phases: PhaseInstructions[]; instructionsDir: string; cwd: string; scaffolded?: string[]; skipped?: string[]; }; export type SetupAgentsEffortMode = 'ai_autonomous' | 'ai_supervised' | 'ai_calibration_baseline' | 'human_manual' | 'human_review'; export type TokenCost = { model: string; inputTokens: number; outputTokens: number; costUsd: number; }; export type EffortEstimateRecord = { id: string; storyId: string; phase: WorkflowPhase; workMode: SetupAgentsEffortMode; actualMinutes: number | null; estimatedUnguidedMinutes: number | null; confidence: WorkflowEstimateConfidence; rationale: string; createdAt: string; tokenCost?: TokenCost; }; export type TokenCostSummary = { totalCostUsd: number; byMode: Partial>; byStory: Record; }; export type EffortSummary = { storyId: string | null; byMode: Record; totalMinutes: number; autonomyPct: number | null; rulesMultiplier: number | null; tokenCost: TokenCostSummary | null; }; export type SetupAgentsWorkflowTelemetryResult = { records: EffortEstimateRecord[]; summary: EffortSummary; file: string; cwd: string; }; export type WorkflowGateKind = 'transition' | 'mid-phase'; export type WorkflowPendingItem = { run: WorkflowRunRecord; pausedPhase: WorkflowPhase; nextPhase?: WorkflowPhase; reviewId: string; kind: WorkflowGateKind; approveCommand: string; resumeCommand: string; }; export type SetupAgentsWorkflowPendingResult = { items: WorkflowPendingItem[]; file: string; cwd: string; }; export type SetupAgentsWorkflowGateResult = { reviewId: string; run: WorkflowRunRecord; file: string; cwd: string; }; export type SetupAgentsReviewRequestResult = CommandResult; export type SetupAgentsReviewListResult = CommandListResult; export type SetupAgentsReviewCompleteResult = CommandResult; export type RulesHealthEntry = { profile: string; file: string; embeddedVersion: string | null; pluginVersion: string; stale: boolean; }; export type PlaybookHealthEntry = { phase: string; file: string; exists: boolean; }; export type DependencyHealthEntry = { id: string; label: string; installed: boolean; version?: string; optional: boolean; }; export type SetupAgentsStatusResult = { openTasks: number; claimedTasks: number; doneTasks: number; pendingReviews: number; blockedHandoffs: number; missingEvidence: number; configFile: string | null; mode: SetupAgentsWorkspaceMode | null; profiles: string[]; cwd: string; rulesHealth: RulesHealthEntry[]; playbookHealth: PlaybookHealthEntry[]; dependencyHealth: DependencyHealthEntry[]; setupHealth: SetupHealth; reconciliation: { healthy: boolean; findings: TaskReconciliationFinding[]; repaired: TaskReconciliationCode[]; }; }; export type SetupAgentsInitResult = { configFile: string; config: SetupAgentsWorkspaceConfig; written: boolean; cwd: string; }; export type SetupLocalResult = { configured: string[]; profiles: ProfileId[]; localState?: { path: string; files: string[]; }; advisory?: { enabled: boolean; path: string; files: string[]; }; openOrchestra?: { enabled: boolean; status: 'available' | 'not-installed'; path: string; files: string[]; command: string; guidance: string; }; cwd: string; setupManifest?: SetupManifest; knowledge?: { manifest: KnowledgeManifest; changedPaths: string[]; }; /** Paths removed because the previous artifact manifest referenced them but this generation no longer does (e.g. a renamed rule filename between plugin versions). */ purgedArtifacts?: string[]; }; export type StaleRuleFile = { file: string; tool: SupportedTool; version: string | null; managedBlocks: boolean; updateMode: 'managed-blocks' | 'full-file'; availableActions: Array<'check' | 'dry-run' | 'update'>; }; /** * Lightweight Result type. Provides explicit success/failure handling * without exceptions. Mirrors the pattern in core/monad/result.ts (profiler). */ export type Result = { ok: true; value: T; } | { ok: false; error: E; }; export declare const ok: (value: T) => Result; export declare const err: (error: E) => Result; export type WorkflowErrorCode = 'phase-not-running' | 'run-not-found' | 'phase-not-found' | 'max-iterations-exceeded' | 'clarification-not-found' | 'review-not-found' | 'phase-substance-missing'; export type WorkflowError = { code: WorkflowErrorCode; message: string; }; export type SprintRecord = { id: string; sprintId: string; event: 'start' | 'close'; startDate?: string; endDate?: string; capacityDays?: number; committedPoints?: number; actualPoints?: number; velocityPct?: number; avgVsSoloPct?: number | null; avgVsAiUnguidedPct?: number | null; createdAt: string; }; export type VelocityLesson = { id: string; sprintId: string; role: string; biasDirection: 'over' | 'under'; biasAvgPct: number; storySample: string[]; createdAt: string; }; export type ReleaseCheckResult = { name: string; status: 'pass' | 'warn' | 'fail'; blocking: boolean; detail: string; evidenceId?: string; }; export type ReleaseCheckReport = { taskId: string; checks: ReleaseCheckResult[]; overallPass: boolean; runAt: string; }; export type SetupAgentsReleaseCheckResult = { report: ReleaseCheckReport; cwd: string; }; export type ClarificationStatus = 'open' | 'answered'; export type ClarificationToRole = 'po' | 'ta'; export type ClarificationRecord = { id: string; runId: string; storyId: string; fromRole: WorkflowPhase; toRole: ClarificationToRole; question: string; answer?: string; status: ClarificationStatus; createdAt: string; answeredAt?: string; }; export type SetupAgentsClarifyResult = CommandResult & { run: WorkflowRunRecord; }; export type SetupAgentsClarifyRespondResult = CommandResult & { run: WorkflowRunRecord; }; export type SetupAgentsClarifyListResult = CommandListResult; export type SetupAgentsVerifyResult = { tool: string | null; profiles: string[]; probePrompt: string | null; hasRules: boolean; cwd: string; setupHealth?: SetupHealth; opencodeHealth?: OpenCodeHealth; referenceHealth?: ReferenceHealth; knowledgeReadiness?: KnowledgeReadiness; promptRegistryHealth?: PromptRegistryHealth; }; export type SetupAgentsUpdateDocReferenceResult = { files: string[]; profiles: string[]; cwd: string; }; export type SetupAgentsUpdateFetchRefsResult = { downloaded: string[]; cached: string[]; failed: string[]; refsDir: string; cwd: string; manifestPath: string; referenceHealth: ReferenceHealth; }; export type SetupAgentsWriteBackResult = { pushed: boolean; target: 'github' | 'jira'; url: string | null; dryRun: boolean; }; export type SetupAgentsWorkflowExecuteResult = { storyId: string; runtime: string; phases: Array<{ phase: WorkflowPhase; status: 'done' | 'failed' | 'skipped' | 'delegated'; exitCode?: number; }>; dryRun: boolean; cwd: string; /** GH-746: true when the phase was dispatched via the bridge instead of running inline (the default inside a chat session; see --foreground). */ background?: boolean; /** The spawn session id returned by the bridge for the delegated phase, when background is true. */ delegatedSessionId?: string; }; export type OperationalLessonRecord = LessonRecord; export type SetupAgentsWorkflowLessonsResult = { lessons: OperationalLessonRecord[]; health: LessonHealth; migration?: LessonMigrationReport; cwd: string; }; export type SetupAgentsCanvasSyncResult = { synced: number; alreadyOk: number; orphansRemoved: number; cacheDir: string; dryRun: boolean; cwd: string; }; export type SetupAgentsCanvasStatusResult = { canvases: Array<{ name: string; state: 'symlink-ok' | 'symlink-wrong' | 'regular' | 'missing'; }>; orphans: string[]; cacheDir: string; cwd: string; }; export type SetupAgentsCanvasCleanResult = { removed: string[]; cacheDir: string; cwd: string; }; export type DashboardHandoffEntry = { id: string; from: string; to: string; summary: string; createdAt: string; taskId: string | null; }; export type SetupAgentsDashboardMetrics = { generatedAt: string; /** Latest mtime among the state inputs used to build this dashboard. */ dataAsOf: string; projectName: string; tasks: { total: number; done: number; claimed: number; open: number; cancelled: number; }; /** Workflow phase subtasks ([pm]/[ba]/…), counted apart from stories so the task * totals reflect real work, not per-phase inflation (GH-602). */ phaseTasks: { total: number; done: number; }; effort: { aiAutonomousHours: number; aiSupervisedHours: number; humanReviewHours: number; humanManualHours: number; /** Back-compat alias = humanManualHours (was the fabricated bucket). */ manualHours: number; totalHours: number; aiRatioPct: number; /** True when any mode is an estimate (no recorded evidence), so the UI shows ★. */ estimated: boolean; }; sizingEstimate: { totalSoloDays: number; totalAiUnguidedDays: number; storiesEstimated: number; } | null; tokenCost: TokenCostSummary | null; velocity: Record; byProfile: Record; storyCycleTimes: Record; phaseCycleTimes: Record; recentHandoffs: DashboardHandoffEntry[]; sizingEstimateDetails: WorkflowEstimateRecord[]; }; export type SetupAgentsDashboardResult = { metrics: SetupAgentsDashboardMetrics; outputPath: string | null; format: 'html' | 'json'; cwd: string; }; export type SpawnCapability = 'unsupported' | 'request-only' | 'parent-tool' | 'local-process'; export type SpawnRequest = { id: string; taskId: string; runId: string; phase: WorkflowPhase; role: string; adapterId: string; contextBundle: string; renderedPrompt: string; ownershipBoundaries: SpawnOwnershipBoundaries; outputContract: SpawnOutputContract; evidenceContract: SpawnEvidenceContract; queueMetadata: SpawnQueueMetadata; /** Runtime-neutral capability tier (deep/standard/fast); each runtime resolves it to a model. */ recommendedTier?: string; /** Runtime-neutral reasoning-effort level (low/medium/high/xhigh) the parent passes to the Agent tool. */ recommendedEffort?: string; createdAt: string; }; export type SpawnOwnershipBoundaries = { files: string[]; readOnly: string[]; forbidden: string[]; }; export type SpawnOutputContract = { expectedType: 'deliverable' | 'review' | 'evidence'; schema?: string; maxTokens?: number; }; export type SpawnEvidenceContract = { requiredTypes: string[]; autoRecord: boolean; }; export type SpawnQueueMetadata = { priority: number; maxConcurrent: number; maxPerTask: number; delegationDepth: number; maxDelegationDepth: number; contextBudgetTokens: number; }; export type SpawnResult = { requestId: string; status: 'completed' | 'failed' | 'timeout' | 'rejected'; sessionId?: string; agentId?: string; runtime: string; role: string; phase: WorkflowPhase; output?: string; artifacts?: string[]; elapsedMs: number; closeStatus: 'success' | 'error' | 'timeout' | 'cancelled'; };