substrate-ai 0.20.63 → 0.20.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/adapter-registry-BbVWH3Yv.js +4 -0
  2. package/dist/cli/index.js +93 -23
  3. package/dist/decision-router-DblHY8se.js +97 -0
  4. package/dist/{decisions-4F91LrVD.js → decisions-DilHo99V.js} +2 -2
  5. package/dist/{dist-W2emvN3F.js → dist-K_RRWnBX.js} +2 -2
  6. package/dist/{errors-CKFu8YI9.js → errors-pSiZbn6e.js} +2 -2
  7. package/dist/{experimenter-DxxwicpK.js → experimenter-DT9v2Pto.js} +1 -1
  8. package/dist/health-DC3y-sR6.js +1715 -0
  9. package/dist/health-qhtWYh49.js +8 -0
  10. package/dist/index-c924O9mj.d.ts +1432 -0
  11. package/dist/index.d.ts +132 -736
  12. package/dist/index.js +2 -2
  13. package/dist/interactive-prompt-C7wpE4z4.js +183 -0
  14. package/dist/{health-C-KOZrFJ.js → manifest-read-DDkXC3L_.js} +130 -2013
  15. package/dist/modules/interactive-prompt/index.d.ts +86 -0
  16. package/dist/modules/interactive-prompt/index.js +6 -0
  17. package/dist/recovery-engine-BKGBeBnW.js +281 -0
  18. package/dist/{routing-0ykvBl_4.js → routing-CzF0p6lI.js} +2 -2
  19. package/dist/run-DX95j4_D.js +14 -0
  20. package/dist/{run-CHUFlRbH.js → run-DzB4rgkj.js} +391 -31
  21. package/dist/src/modules/decision-router/index.d.ts +88 -0
  22. package/dist/src/modules/decision-router/index.js +3 -0
  23. package/dist/src/modules/recovery-engine/index.d.ts +1101 -0
  24. package/dist/src/modules/recovery-engine/index.js +5 -0
  25. package/dist/{upgrade-C8LAnB6W.js → upgrade-DxzQ1nss.js} +3 -3
  26. package/dist/{upgrade-CAqLkNUP.js → upgrade-MP9XzrI6.js} +2 -2
  27. package/dist/version-manager-impl-GZDUBt0Q.js +4 -0
  28. package/dist/work-graph-repository-DZyJv5pV.js +265 -0
  29. package/package.json +1 -1
  30. package/dist/adapter-registry-k7ZX3Bz6.js +0 -4
  31. package/dist/health-CJqd1FzY.js +0 -6
  32. package/dist/run-Z_-caE_i.js +0 -9
  33. package/dist/version-manager-impl-DaA_ALYK.js +0 -4
  34. /package/dist/{decisions-C0pz9Clx.js → decisions-CzSIEeGP.js} +0 -0
  35. /package/dist/{routing-CcBOCuC9.js → routing-DFxoKHDt.js} +0 -0
  36. /package/dist/{version-manager-impl-BmOWu8ml.js → version-manager-impl-qFBiO4Eh.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AdapterDiscoveryResult, AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, DiscoveryReport, GeminiCLIAdapter, Recommendation, TypedEventBus } from "./index-c924O9mj.js";
1
2
  import pino from "pino";
2
3
  import { z } from "zod";
3
4
  import { Readable, Writable } from "node:stream";
@@ -732,6 +733,28 @@ interface CostCeilingReachedEvent {
732
733
  /** 'critical' when halt_on is 'all' or 'critical'; absent when 'none' */
733
734
  severity?: string;
734
735
  }
736
+ /**
737
+ * Emitted when --non-interactive mode suppresses a halt decision and applies
738
+ * the default action autonomously instead of prompting the operator.
739
+ *
740
+ * Story 72-2: closes the NDJSON protocol gap — operators can see which halts
741
+ * were auto-skipped and what actions were applied via `substrate report`.
742
+ */
743
+ interface DecisionHaltSkippedNonInteractiveEvent {
744
+ type: 'decision:halt-skipped-non-interactive';
745
+ /** ISO-8601 timestamp generated at emit time */
746
+ ts: string;
747
+ /** Pipeline run ID */
748
+ run_id: string;
749
+ /** Halt decision type that was skipped (e.g., 'halt:escalation', 'cost-ceiling-exhausted') */
750
+ decision_type: string;
751
+ /** Severity of the skipped halt (e.g., 'critical') */
752
+ severity: string;
753
+ /** Action that was applied in place of the operator prompt (e.g., 'continue-autonomous') */
754
+ default_action: string;
755
+ /** Human-readable reason for skipping */
756
+ reason: string;
757
+ }
735
758
  /**
736
759
  * Discriminated union of all pipeline event types.
737
760
  *
@@ -744,8 +767,8 @@ interface CostCeilingReachedEvent {
744
767
  * }
745
768
  * ```
746
769
  */
747
- type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | PipelinePreFlightFailureEvent | PipelineProfileStaleEvent | PipelineContractMismatchEvent | PipelineContractVerificationSummaryEvent | StoryPhaseEvent | StoryDoneEvent | StoryEscalationEvent | StoryWarnEvent | StoryLogEvent | PipelineHeartbeatEvent | StoryStallEvent | StoryZeroDiffEscalationEvent | StoryBuildVerificationFailedEvent | StoryBuildVerificationPassedEvent | StoryInterfaceChangeWarningEvent | StoryMetricsEvent | SupervisorPollEvent | SupervisorKillEvent | SupervisorRestartEvent | SupervisorAbortEvent | SupervisorSummaryEvent | SupervisorAnalysisCompleteEvent | SupervisorAnalysisErrorEvent | SupervisorExperimentStartEvent | SupervisorExperimentSkipEvent | SupervisorExperimentRecommendationsEvent | SupervisorExperimentCompleteEvent | SupervisorExperimentErrorEvent | RoutingModelSelectedEvent | PipelinePhaseStartEvent | PipelinePhaseCompleteEvent | StoryAutoApprovedEvent | VerificationCheckCompleteEvent | VerificationStoryCompleteEvent | CostWarningEvent | CostCeilingReachedEvent; //#endregion
748
- //#region packages/core/dist/types.d.ts
770
+ type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | PipelinePreFlightFailureEvent | PipelineProfileStaleEvent | PipelineContractMismatchEvent | PipelineContractVerificationSummaryEvent | StoryPhaseEvent | StoryDoneEvent | StoryEscalationEvent | StoryWarnEvent | StoryLogEvent | PipelineHeartbeatEvent | StoryStallEvent | StoryZeroDiffEscalationEvent | StoryBuildVerificationFailedEvent | StoryBuildVerificationPassedEvent | StoryInterfaceChangeWarningEvent | StoryMetricsEvent | SupervisorPollEvent | SupervisorKillEvent | SupervisorRestartEvent | SupervisorAbortEvent | SupervisorSummaryEvent | SupervisorAnalysisCompleteEvent | SupervisorAnalysisErrorEvent | SupervisorExperimentStartEvent | SupervisorExperimentSkipEvent | SupervisorExperimentRecommendationsEvent | SupervisorExperimentCompleteEvent | SupervisorExperimentErrorEvent | RoutingModelSelectedEvent | PipelinePhaseStartEvent | PipelinePhaseCompleteEvent | StoryAutoApprovedEvent | VerificationCheckCompleteEvent | VerificationStoryCompleteEvent | CostWarningEvent | CostCeilingReachedEvent | DecisionHaltSkippedNonInteractiveEvent; //#endregion
771
+ //#region src/core/errors.d.ts
749
772
 
750
773
  /**
751
774
  * Exhaustive list of all PipelineEvent `type` discriminant strings.
@@ -754,734 +777,6 @@ type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | PipelinePreFli
754
777
  * tests to ensure PIPELINE_EVENT_METADATA in help-agent.ts never falls
755
778
  * out of sync with the actual event type definitions.
756
779
  */
757
- /**
758
- * Core types for Substrate
759
- * Shared type definitions used across all modules
760
- */
761
- /** Unique identifier for a task in the DAG */
762
- type TaskId$1 = string;
763
- /** Unique identifier for a worker/agent instance */
764
-
765
- /** Unique identifier for a registered agent type */
766
- type AgentId$1 = string;
767
- /** Status of an individual task */
768
-
769
- /** Billing mode for a worker/agent */
770
- type BillingMode$1 = 'subscription' | 'api' | 'free';
771
-
772
- //#endregion
773
- //#region packages/core/dist/events/types.d.ts
774
- /** Severity level for errors and log messages */
775
- /**
776
- * Base event type primitives for the TypedEventBus system.
777
- *
778
- * These types are the foundation of the event bus contract.
779
- * All event maps must satisfy EventMap; all handlers must satisfy EventHandler<T>.
780
- */
781
- /**
782
- * Base constraint for event maps.
783
- * Each key is an event name (string), and the value is the payload type.
784
- *
785
- * Using `object` (not `Record<string, unknown>`) so that TypeScript interfaces
786
- * with named properties (without index signatures) satisfy the constraint.
787
- * TypeScript interfaces extend `object` but may not extend `Record<string, unknown>`
788
- * unless they have an explicit index signature.
789
- */
790
- type EventMap = object;
791
- /**
792
- * A typed event handler function for payload type T.
793
- */
794
- type EventHandler<T> = (payload: T) => void;
795
-
796
- //#endregion
797
- //#region packages/core/dist/events/event-bus.d.ts
798
- //# sourceMappingURL=types.d.ts.map
799
- /**
800
- * A type-safe event bus parameterized over an event map E.
801
- *
802
- * @example
803
- * const bus: TypedEventBus<CoreEvents & SdlcEvents> = createEventBus()
804
- * bus.on('orchestrator:story-complete', ({ storyKey }) => { ... })
805
- */
806
- interface TypedEventBus$1<E extends EventMap> {
807
- /**
808
- * Emit an event with a typed payload.
809
- * All registered handlers for this event key are called synchronously.
810
- */
811
- emit<K extends keyof E>(event: K, payload: E[K]): void;
812
- /**
813
- * Register a handler for an event.
814
- */
815
- on<K extends keyof E>(event: K, handler: EventHandler<E[K]>): void;
816
- /**
817
- * Unregister a previously registered handler.
818
- */
819
- off<K extends keyof E>(event: K, handler: EventHandler<E[K]>): void;
820
- }
821
-
822
- //#endregion
823
- //#region packages/core/dist/dispatch/types.d.ts
824
- /**
825
- * Concrete implementation of TypedEventBus backed by Node.js EventEmitter.
826
- *
827
- * Dispatch is SYNCHRONOUS — all handlers run before emit() returns (per ADR-004).
828
- * maxListeners is set to 100 to avoid spurious warnings in large systems.
829
- *
830
- * @example
831
- * const bus = new TypedEventBusImpl<CoreEvents & SdlcEvents>()
832
- * bus.on('orchestrator:story-complete', ({ storyKey }) => { ... })
833
- * bus.emit('orchestrator:story-complete', { storyKey: '1-1', reviewCycles: 1 })
834
- */
835
-
836
- /**
837
- * Logger interface compatible with both pino-style loggers and console.
838
- * Methods accept any argument pattern: (msg: string) or (obj: unknown, msg?: string).
839
- */
840
- interface ILogger {
841
- info(...args: unknown[]): void;
842
- warn(...args: unknown[]): void;
843
- error(...args: unknown[]): void;
844
- debug(...args: unknown[]): void;
845
- }
846
-
847
- //#endregion
848
- //#region packages/core/dist/config/errors.d.ts
849
- //# sourceMappingURL=types.d.ts.map
850
- /**
851
- * Config-specific error classes for @substrate-ai/core.
852
- *
853
- * AdtError is defined here as the canonical base class. ConfigError and
854
- * ConfigIncompatibleFormatError extend it. The monolith's src/core/errors.ts
855
- * re-exports AdtError from here so that all error classes share the same
856
- * base class instance — enabling instanceof checks to work across the
857
- * monolith/core boundary.
858
- */
859
- /** Base error class for all Substrate errors */
860
- declare class AdtError extends Error {
861
- readonly code: string;
862
- readonly context: Record<string, unknown>;
863
- constructor(message: string, code: string, context?: Record<string, unknown>);
864
- toJSON(): Record<string, unknown>;
865
- }
866
- /** Error thrown when configuration is invalid or missing */
867
- declare class ConfigError extends AdtError {
868
- constructor(message: string, context?: Record<string, unknown>);
869
- }
870
- /** Error thrown when a config file uses an incompatible format version */
871
- declare class ConfigIncompatibleFormatError extends AdtError {
872
- constructor(message: string, context?: Record<string, unknown>);
873
- }
874
-
875
- //#endregion
876
- //#region packages/core/dist/adapters/types.d.ts
877
- //# sourceMappingURL=errors.d.ts.map
878
- /**
879
- * A spawn command descriptor that the orchestrator uses to invoke a CLI agent.
880
- * Contains all information needed to execute an agent process.
881
- */
882
- interface SpawnCommand$1 {
883
- /** The binary to execute (e.g., "claude", "codex", "gemini") */
884
- binary: string;
885
- /** Arguments to pass to the binary */
886
- args: string[];
887
- /** Optional environment variable overrides */
888
- env?: Record<string, string>;
889
- /** Optional list of environment variable keys to unset in the child process */
890
- unsetEnvKeys?: string[];
891
- /** Working directory for the process */
892
- cwd: string;
893
- /** Optional data to pipe to stdin */
894
- stdin?: string;
895
- /** Optional timeout in milliseconds */
896
- timeoutMs?: number;
897
- }
898
- /**
899
- * Options passed to adapter methods for each invocation.
900
- * Controls execution context for a specific task run.
901
- */
902
- interface AdapterOptions$1 {
903
- /** Path to the git worktree for this task */
904
- worktreePath: string;
905
- /** Billing mode to use for this execution */
906
- billingMode: BillingMode$1;
907
- /** Optional model identifier override */
908
- model?: string;
909
- /** Optional additional CLI flags to append */
910
- additionalFlags?: string[];
911
- /** Optional API key override (used when billingMode is 'api') */
912
- apiKey?: string;
913
- /** Optional maximum agentic turns (passed as --max-turns to Claude CLI) */
914
- maxTurns?: number;
915
- /**
916
- * Optional OTLP endpoint URL for telemetry export (Story 27-9).
917
- * When set, injects OTLP env vars into the spawned process so that
918
- * Claude Code exports telemetry to the local IngestionServer.
919
- * Example: "http://localhost:4318"
920
- */
921
- otlpEndpoint?: string;
922
- /**
923
- * Optional story key for OTEL resource attribute tagging.
924
- * Injected as `substrate.story_key` via OTEL_RESOURCE_ATTRIBUTES
925
- * so the telemetry pipeline can group spans/events per story.
926
- */
927
- storyKey?: string;
928
- /**
929
- * Optional maximum context tokens. Historically passed as --max-context-tokens to
930
- * Claude CLI; that flag was removed in Claude Code v2.x and is now silently ignored
931
- * by the claude-adapter. The field remains on the options shape for backward compat
932
- * with callers (Story 30-8 efficiency-gated retry logic) but no longer constrains
933
- * dispatch behavior. --max-turns continues to bound dispatch length.
934
- */
935
- maxContextTokens?: number;
936
- /**
937
- * Optional optimization directives derived from prior stories' telemetry (Story 30-6).
938
- * When set, appended to the system prompt to guide the sub-agent toward efficient patterns.
939
- * Generated by TelemetryAdvisor.formatOptimizationDirectives().
940
- */
941
- optimizationDirectives?: string;
942
- /** Dispatch context: task type (create-story, dev-story, code-review, etc.) for OTLP attribution */
943
- taskType?: string;
944
- /** Dispatch context: unique dispatch ID for per-dispatch telemetry correlation */
945
- dispatchId?: string;
946
- }
947
- /**
948
- * Capabilities reported by an adapter for this CLI agent.
949
- * Used for routing and planning decisions.
950
- */
951
- interface AdapterCapabilities$1 {
952
- /** Whether the agent outputs structured JSON */
953
- supportsJsonOutput: boolean;
954
- /** Whether the agent supports streaming output */
955
- supportsStreaming: boolean;
956
- /** Whether the agent supports subscription-based billing */
957
- supportsSubscriptionBilling: boolean;
958
- /** Whether the agent supports API-key-based billing */
959
- supportsApiBilling: boolean;
960
- /** Whether the agent can generate task planning graphs */
961
- supportsPlanGeneration: boolean;
962
- /** Maximum context tokens the agent supports */
963
- maxContextTokens: number;
964
- /** Task types this agent can handle */
965
- supportedTaskTypes: string[];
966
- /** Programming languages the agent supports */
967
- supportedLanguages: string[];
968
- /**
969
- * Timeout multiplier relative to default dispatch timeouts.
970
- * Agents that are slower (e.g., Codex) declare a multiplier > 1.0
971
- * so the dispatcher scales timeouts automatically.
972
- * Default: 1.0 (no scaling).
973
- */
974
- timeoutMultiplier?: number;
975
- /**
976
- * Whether the agent supports a --system-prompt flag.
977
- * Claude Code: true. Codex/Gemini: false.
978
- * When false, system-level instructions must be embedded in the prompt itself.
979
- */
980
- supportsSystemPrompt?: boolean;
981
- /**
982
- * Whether the agent exports OTLP telemetry (spans, metrics, logs).
983
- * Claude Code: true. Codex/Gemini: false.
984
- * When false, telemetry is heuristic-only (character-based token estimates).
985
- */
986
- supportsOtlpExport?: boolean;
987
- /**
988
- * Whether the dispatcher should append a YAML output format reminder to prompts.
989
- * Claude Code: false (follows methodology pack format instructions reliably).
990
- * Codex/Gemini: true (need explicit final nudge to emit fenced YAML blocks).
991
- */
992
- requiresYamlSuffix?: boolean;
993
- /**
994
- * Default maximum review cycles for this agent backend.
995
- * Claude Code: 2 (converges quickly). Codex: 3 (needs more iterations).
996
- * Overridden by explicit --max-review-cycles CLI flag.
997
- */
998
- defaultMaxReviewCycles?: number;
999
- }
1000
- /**
1001
- * Result returned from an adapter health check.
1002
- * Indicates whether the CLI binary is present and functional.
1003
- */
1004
- interface AdapterHealthResult$1 {
1005
- /** Whether the adapter is considered healthy and usable */
1006
- healthy: boolean;
1007
- /** Detected version string of the CLI binary */
1008
- version?: string;
1009
- /** Full path to the CLI binary, if resolved */
1010
- cliPath?: string;
1011
- /** Error message when healthy is false */
1012
- error?: string;
1013
- /** Detected billing mode(s) available for this adapter */
1014
- detectedBillingModes?: BillingMode$1[];
1015
- /** Whether the CLI supports headless/non-interactive mode */
1016
- supportsHeadless: boolean;
1017
- }
1018
- /**
1019
- * Parsed result from a task execution.
1020
- * Normalized representation from CLI agent JSON output.
1021
- */
1022
- interface TaskResult$2 {
1023
- /** Task identifier this result belongs to */
1024
- taskId?: TaskId$1;
1025
- /** Whether the task completed successfully */
1026
- success: boolean;
1027
- /** Primary output content from the agent */
1028
- output: string;
1029
- /** Error message if the task failed */
1030
- error?: string;
1031
- /** Raw exit code from the CLI process */
1032
- exitCode: number;
1033
- /** Execution metadata */
1034
- metadata?: {
1035
- executionTime?: number;
1036
- tokensUsed?: TokenEstimate$1;
1037
- };
1038
- /**
1039
- * True when the dispatcher's AdapterOutputNormalizer exhausted all
1040
- * normalization strategies without extracting parseable YAML.
1041
- * Authoritative signal for the 'adapter-format' root cause category (story 53-10).
1042
- * Optional — existing callers without the field continue to compile unchanged.
1043
- */
1044
- adapterError?: boolean;
1045
- }
1046
- /**
1047
- * Token usage estimate for budget tracking.
1048
- */
1049
- interface TokenEstimate$1 {
1050
- /** Estimated input tokens */
1051
- input: number;
1052
- /** Estimated output tokens */
1053
- output: number;
1054
- /** Total token estimate */
1055
- total: number;
1056
- }
1057
- /**
1058
- * Request input for plan generation.
1059
- */
1060
- interface PlanRequest$1 {
1061
- /** High-level goal or description of work to plan */
1062
- goal: string;
1063
- /** Additional context for the planning agent */
1064
- context?: string;
1065
- /** Maximum number of tasks to generate */
1066
- maxTasks?: number;
1067
- }
1068
- /**
1069
- * Parsed result from a plan generation invocation.
1070
- */
1071
- interface PlanParseResult$1 {
1072
- /** Whether plan generation succeeded */
1073
- success: boolean;
1074
- /** Parsed list of planned task descriptions */
1075
- tasks: PlannedTask$1[];
1076
- /** Error message if plan generation failed */
1077
- error?: string;
1078
- /** Raw output for debugging */
1079
- rawOutput?: string;
1080
- }
1081
- /**
1082
- * A single task entry in a generated plan.
1083
- */
1084
- interface PlannedTask$1 {
1085
- /** Task title */
1086
- title: string;
1087
- /** Detailed description */
1088
- description: string;
1089
- /** Estimated complexity (1-10) */
1090
- complexity?: number;
1091
- /** Other task titles this task depends on */
1092
- dependencies?: string[];
1093
- }
1094
- /**
1095
- * Result from a single adapter discovery attempt.
1096
- */
1097
- interface AdapterDiscoveryResult {
1098
- /** Adapter id that was tried */
1099
- adapterId: AgentId$1;
1100
- /** Display name of the adapter */
1101
- displayName: string;
1102
- /** Health check result */
1103
- healthResult: AdapterHealthResult$1;
1104
- /** Whether the adapter was registered (healthy) */
1105
- registered: boolean;
1106
- }
1107
- /**
1108
- * Summary result from discoverAndRegister().
1109
- */
1110
- interface DiscoveryReport {
1111
- /** Number of adapters successfully registered */
1112
- registeredCount: number;
1113
- /** Number of adapters that failed health checks */
1114
- failedCount: number;
1115
- /** Per-adapter detail results */
1116
- results: AdapterDiscoveryResult[];
1117
- }
1118
-
1119
- //#endregion
1120
- //#region packages/core/dist/adapters/worker-adapter.d.ts
1121
- //# sourceMappingURL=types.d.ts.map
1122
- /**
1123
- * WorkerAdapter — the interface every CLI agent adapter must implement.
1124
- *
1125
- * Adapters are responsible for:
1126
- * 1. Verifying their CLI binary is installed and responsive (healthCheck)
1127
- * 2. Constructing the spawn command to execute a task (buildCommand)
1128
- * 3. Constructing the spawn command for plan generation (buildPlanningCommand)
1129
- * 4. Parsing task result output from the CLI (parseOutput)
1130
- * 5. Parsing plan result output from the CLI (parsePlanOutput)
1131
- * 6. Estimating token usage for budget tracking (estimateTokens)
1132
- * 7. Reporting their capabilities for routing decisions (getCapabilities)
1133
- */
1134
- interface WorkerAdapter$1 {
1135
- /**
1136
- * Unique identifier for this adapter type.
1137
- * Used as the Map key in AdapterRegistry.
1138
- * @example "claude-code"
1139
- */
1140
- readonly id: AgentId$1;
1141
- /**
1142
- * Human-readable display name for the adapter.
1143
- * @example "Claude Code"
1144
- */
1145
- readonly displayName: string;
1146
- /**
1147
- * Semantic version of this adapter implementation.
1148
- * @example "1.0.0"
1149
- */
1150
- readonly adapterVersion: string;
1151
- /**
1152
- * Verify that the underlying CLI binary is installed, accessible, and
1153
- * able to respond in headless/non-interactive mode.
1154
- *
1155
- * This method must NOT throw — failures should be captured in the returned
1156
- * AdapterHealthResult.
1157
- *
1158
- * @returns A promise resolving to health check details
1159
- *
1160
- * @example
1161
- * ```typescript
1162
- * const result = await adapter.healthCheck()
1163
- * if (!result.healthy) console.error(result.error)
1164
- * ```
1165
- */
1166
- healthCheck(): Promise<AdapterHealthResult$1>;
1167
- /**
1168
- * Generate the spawn command to execute a coding task.
1169
- *
1170
- * The returned SpawnCommand must set `cwd` to options.worktreePath so the
1171
- * CLI agent operates in the correct git worktree (NFR10).
1172
- *
1173
- * @param prompt Prompt or description of the task to execute
1174
- * @param options Per-invocation execution options
1175
- * @returns SpawnCommand ready to be executed by the orchestrator
1176
- *
1177
- * @example
1178
- * ```typescript
1179
- * const cmd = adapter.buildCommand('Fix the failing tests', { worktreePath: '/tmp/wt', billingMode: 'api' })
1180
- * // spawn(cmd.binary, cmd.args, { cwd: cmd.cwd, env: { ...process.env, ...cmd.env } })
1181
- * ```
1182
- */
1183
- buildCommand(prompt: string, options: AdapterOptions$1): SpawnCommand$1;
1184
- /**
1185
- * Generate the spawn command to invoke the CLI agent for plan generation.
1186
- *
1187
- * @param request Plan request with goal and context
1188
- * @param options Per-invocation execution options
1189
- * @returns SpawnCommand for the planning invocation
1190
- */
1191
- buildPlanningCommand(request: PlanRequest$1, options: AdapterOptions$1): SpawnCommand$1;
1192
- /**
1193
- * Parse the raw CLI process output into a normalized TaskResult.
1194
- *
1195
- * This method must handle all output variations including:
1196
- * - Valid JSON stdout
1197
- * - Non-JSON stdout (fallback)
1198
- * - Non-zero exit codes
1199
- * - Combined stdout + stderr
1200
- *
1201
- * @param stdout Standard output captured from the CLI process
1202
- * @param stderr Standard error captured from the CLI process
1203
- * @param exitCode Exit code from the CLI process
1204
- * @returns Normalized TaskResult
1205
- */
1206
- parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult$2;
1207
- /**
1208
- * Parse the raw CLI output from a planning invocation into a PlanParseResult.
1209
- *
1210
- * @param stdout Standard output from the planning invocation
1211
- * @param stderr Standard error from the planning invocation
1212
- * @param exitCode Exit code from the planning invocation
1213
- * @returns Parsed plan result
1214
- */
1215
- parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult$1;
1216
- /**
1217
- * Estimate the token count for a given prompt string.
1218
- *
1219
- * Used for pre-execution budget checks. Implementations may use heuristics
1220
- * (e.g., character count / 3) when exact tokenizers are unavailable.
1221
- *
1222
- * @param prompt The prompt text to estimate
1223
- * @returns TokenEstimate with input, output, and total projections
1224
- *
1225
- * @example
1226
- * ```typescript
1227
- * const estimate = adapter.estimateTokens('Fix the failing tests in auth.ts')
1228
- * if (estimate.total > budgetCap) throw new BudgetExceededError(...)
1229
- * ```
1230
- */
1231
- estimateTokens(prompt: string): TokenEstimate$1;
1232
- /**
1233
- * Return the capabilities of this adapter's underlying CLI agent.
1234
- *
1235
- * The returned object is used by the orchestrator for:
1236
- * - Routing decisions (which adapter handles which task type)
1237
- * - Plan generation eligibility
1238
- * - Budget mode selection
1239
- *
1240
- * @returns AdapterCapabilities for this agent
1241
- */
1242
- getCapabilities(): AdapterCapabilities$1;
1243
- }
1244
-
1245
- //#endregion
1246
- //#region packages/core/dist/adapters/adapter-registry.d.ts
1247
- /**
1248
- * AdapterRegistry — public interface for the adapter registry.
1249
- *
1250
- * Defined here (not in types.ts) to avoid a circular dependency between
1251
- * types.ts and worker-adapter.ts. AdapterRegistry references WorkerAdapter,
1252
- * which is defined in this file, so placing it here keeps the dep graph acyclic.
1253
- *
1254
- * The concrete implementation (AdapterRegistry class) lives in the monolith
1255
- * until Epic 41. This interface exposes only the public method surface.
1256
- *
1257
- * Usage:
1258
- * ```typescript
1259
- * const registry: AdapterRegistry = new ConcreteAdapterRegistry()
1260
- * const report = await registry.discoverAndRegister()
1261
- * const claude = registry.get('claude-code')
1262
- * ```
1263
- */
1264
- /**
1265
- * AdapterRegistry manages the lifecycle of WorkerAdapter instances.
1266
- *
1267
- * Usage:
1268
- * ```typescript
1269
- * const registry = new AdapterRegistry()
1270
- * const report = await registry.discoverAndRegister()
1271
- * const claude = registry.get('claude-code')
1272
- * ```
1273
- */
1274
- declare class AdapterRegistry {
1275
- private readonly _adapters;
1276
- /**
1277
- * Register an adapter by its id.
1278
- * Overwrites any existing adapter with the same id.
1279
- */
1280
- register(adapter: WorkerAdapter$1): void;
1281
- /**
1282
- * Retrieve a registered adapter by id.
1283
- * @returns The adapter, or undefined if not registered
1284
- */
1285
- get(id: AgentId$1): WorkerAdapter$1 | undefined;
1286
- /**
1287
- * Return all registered adapters as an array.
1288
- */
1289
- getAll(): WorkerAdapter$1[];
1290
- /**
1291
- * Return all registered adapters that support plan generation.
1292
- */
1293
- getPlanningCapable(): WorkerAdapter$1[];
1294
- /**
1295
- * Instantiate all built-in adapters, run health checks sequentially,
1296
- * and register those that pass.
1297
- *
1298
- * Failed adapters are included in the report but do NOT prevent startup.
1299
- *
1300
- * @returns Discovery report with per-adapter results
1301
- */
1302
- discoverAndRegister(): Promise<DiscoveryReport>;
1303
- }
1304
-
1305
- //#endregion
1306
- //#region packages/core/dist/adapters/claude-adapter.d.ts
1307
- //# sourceMappingURL=adapter-registry.d.ts.map
1308
- /**
1309
- * Adapter for the Claude Code CLI agent.
1310
- *
1311
- * Capabilities: JSON output, streaming, both billing modes, plan generation.
1312
- * Health check: runs `claude --version` to verify install.
1313
- * Billing detection: detects subscription vs API via version output or env.
1314
- */
1315
- declare class ClaudeCodeAdapter implements WorkerAdapter$1 {
1316
- readonly id: AgentId$1;
1317
- readonly displayName = "Claude Code";
1318
- readonly adapterVersion = "1.0.0";
1319
- private readonly _logger;
1320
- constructor(logger?: ILogger);
1321
- /**
1322
- * Verify the `claude` binary is installed and responsive.
1323
- * Detects subscription vs API billing mode.
1324
- */
1325
- healthCheck(): Promise<AdapterHealthResult$1>;
1326
- /**
1327
- * Build spawn command for a coding task.
1328
- * Uses: `claude -p --model <model> --dangerously-skip-permissions --system-prompt <minimal>`
1329
- * Prompt is delivered via stdin (not CLI arg) to avoid E2BIG on large prompts.
1330
- */
1331
- buildCommand(prompt: string, options: AdapterOptions$1): SpawnCommand$1;
1332
- /**
1333
- * Build spawn command for plan generation.
1334
- */
1335
- buildPlanningCommand(request: PlanRequest$1, options: AdapterOptions$1): SpawnCommand$1;
1336
- /**
1337
- * Parse Claude Code JSON output into a TaskResult.
1338
- */
1339
- parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult$2;
1340
- /**
1341
- * Parse Claude plan generation output.
1342
- */
1343
- parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult$1;
1344
- /**
1345
- * Estimate token count using character-based heuristic.
1346
- */
1347
- estimateTokens(prompt: string): TokenEstimate$1;
1348
- /**
1349
- * Return Claude Code capabilities.
1350
- */
1351
- getCapabilities(): AdapterCapabilities$1;
1352
- private _detectBillingModes;
1353
- private _buildPlanningPrompt;
1354
- }
1355
-
1356
- //#endregion
1357
- //#region packages/core/dist/adapters/codex-adapter.d.ts
1358
- //# sourceMappingURL=claude-adapter.d.ts.map
1359
- /**
1360
- * Adapter for the OpenAI Codex CLI agent.
1361
- *
1362
- * Codex CLI uses stdin for the prompt and outputs JSON when --json flag is used.
1363
- * Codex supports subscription billing (via `codex login`) and API key billing.
1364
- */
1365
- declare class CodexCLIAdapter implements WorkerAdapter$1 {
1366
- readonly id: AgentId$1;
1367
- readonly displayName = "Codex CLI";
1368
- readonly adapterVersion = "1.0.0";
1369
- private readonly _logger;
1370
- constructor(logger?: ILogger);
1371
- /**
1372
- * Verify the `codex` binary is installed and responsive.
1373
- */
1374
- healthCheck(): Promise<AdapterHealthResult$1>;
1375
- /**
1376
- * Build spawn command for a coding task.
1377
- * Uses: `codex exec` with prompt delivered via stdin.
1378
- *
1379
- * Do NOT use --json: it produces a JSONL event stream that prevents
1380
- * extractYamlBlock from finding the structured result block in stdout.
1381
- * Raw text output is required (same rationale as Claude adapter).
1382
- */
1383
- buildCommand(prompt: string, options: AdapterOptions$1): SpawnCommand$1;
1384
- /**
1385
- * Build spawn command for plan generation.
1386
- * Uses codex exec with a JSON plan generation prompt via stdin.
1387
- */
1388
- buildPlanningCommand(request: PlanRequest$1, options: AdapterOptions$1): SpawnCommand$1;
1389
- /**
1390
- * Parse Codex CLI output into a TaskResult.
1391
- *
1392
- * With raw text mode (no --json), stdout is the agent's direct output.
1393
- * YAML extraction happens in the dispatcher's extractYamlBlock, not here.
1394
- */
1395
- parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult$2;
1396
- /**
1397
- * Parse Codex plan generation output.
1398
- */
1399
- parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult$1;
1400
- /**
1401
- * Estimate token count using character-based heuristic.
1402
- */
1403
- estimateTokens(prompt: string): TokenEstimate$1;
1404
- /**
1405
- * Return Codex CLI capabilities.
1406
- */
1407
- getCapabilities(): AdapterCapabilities$1;
1408
- private _buildPlanningPrompt;
1409
- }
1410
-
1411
- //#endregion
1412
- //#region packages/core/dist/adapters/gemini-adapter.d.ts
1413
- //# sourceMappingURL=codex-adapter.d.ts.map
1414
- /**
1415
- * Adapter for the Google Gemini CLI agent.
1416
- *
1417
- * Gemini CLI follows similar patterns to Claude Code: prompt via `-p` flag,
1418
- * JSON output via `--output-format json`, and model via `--model`.
1419
- */
1420
- declare class GeminiCLIAdapter implements WorkerAdapter$1 {
1421
- readonly id: AgentId$1;
1422
- readonly displayName = "Gemini CLI";
1423
- readonly adapterVersion = "1.0.0";
1424
- private readonly _logger;
1425
- constructor(logger?: ILogger);
1426
- /**
1427
- * Verify the `gemini` binary is installed and responsive.
1428
- * Detects subscription vs API billing mode.
1429
- */
1430
- healthCheck(): Promise<AdapterHealthResult$1>;
1431
- /**
1432
- * Build spawn command for a coding task.
1433
- * Uses: `gemini -p <prompt> --output-format json --model <model>`
1434
- */
1435
- buildCommand(prompt: string, options: AdapterOptions$1): SpawnCommand$1;
1436
- /**
1437
- * Build spawn command for plan generation.
1438
- */
1439
- buildPlanningCommand(request: PlanRequest$1, options: AdapterOptions$1): SpawnCommand$1;
1440
- /**
1441
- * Parse Gemini CLI JSON output into a TaskResult.
1442
- */
1443
- parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult$2;
1444
- /**
1445
- * Parse Gemini plan generation output.
1446
- */
1447
- parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult$1;
1448
- /**
1449
- * Estimate token count using character-based heuristic.
1450
- */
1451
- estimateTokens(prompt: string): TokenEstimate$1;
1452
- /**
1453
- * Return Gemini CLI capabilities.
1454
- */
1455
- getCapabilities(): AdapterCapabilities$1;
1456
- private _detectBillingModes;
1457
- private _buildPlanningPrompt;
1458
- }
1459
-
1460
- //#endregion
1461
- //#region packages/core/dist/monitor/recommendation-types.d.ts
1462
- //# sourceMappingURL=gemini-adapter.d.ts.map
1463
- /**
1464
- * Recommendation Types — data structures for the routing recommendations engine.
1465
- * Migrated to @substrate-ai/core (Story 41-7)
1466
- */
1467
- type ConfidenceLevel = 'low' | 'medium' | 'high';
1468
- interface Recommendation {
1469
- task_type: string;
1470
- current_agent: string;
1471
- recommended_agent: string;
1472
- reason: string;
1473
- confidence: ConfidenceLevel;
1474
- current_success_rate: number;
1475
- recommended_success_rate: number;
1476
- current_avg_tokens: number;
1477
- recommended_avg_tokens: number;
1478
- improvement_percentage: number;
1479
- sample_size_current: number;
1480
- sample_size_recommended: number;
1481
- }
1482
-
1483
- //#endregion
1484
- //#region src/core/errors.d.ts
1485
780
  /** Error thrown when task configuration is invalid */
1486
781
  declare class TaskConfigError extends AdtError {
1487
782
  constructor(message: string, context?: Record<string, unknown>);
@@ -2507,10 +1802,111 @@ interface OrchestratorEvents {
2507
1802
  freshFindings: unknown[];
2508
1803
  recoveryDurationMs: number;
2509
1804
  };
2510
- }
2511
-
2512
- //#endregion
1805
+ /**
1806
+ * Story 72-2: A critical halt decision was skipped under --non-interactive mode.
1807
+ *
1808
+ * Emitted when the pipeline would have prompted the operator (interactive stdin
1809
+ * read) but --non-interactive suppressed stdin and auto-applied the default
1810
+ * action instead. Operators reviewing the run via `substrate report` can see
1811
+ * which halts were auto-skipped and what actions were applied.
1812
+ *
1813
+ * Mirror of CoreEvents['decision:halt-skipped-non-interactive']; both must stay
1814
+ * in sync.
1815
+ */
1816
+ 'decision:halt-skipped-non-interactive': {
1817
+ runId: string;
1818
+ /** Halt decision type that was skipped (e.g., 'halt:escalation', 'halt:critical'). */
1819
+ decisionType: string;
1820
+ /** Severity of the skipped halt (e.g., 'critical'). */
1821
+ severity: string;
1822
+ /** Action that was applied in place of the operator prompt (e.g., 'continue'). */
1823
+ defaultAction: string;
1824
+ /** Human-readable reason for skipping (e.g., 'non-interactive: stdin prompt suppressed'). */
1825
+ reason: string;
1826
+ };
1827
+ /**
1828
+ * Story 72-1: A halt-able decision was routed and the policy requires halting.
1829
+ * Emitted when routeDecision() returns halt=true for a given policy.
1830
+ * Mirror of CoreEvents['decision:halt']; both must stay in sync.
1831
+ */
1832
+ 'decision:halt': {
1833
+ runId: string;
1834
+ /** The decision type that triggered the halt (e.g., 'cost-ceiling-exhausted'). */
1835
+ decisionType: string;
1836
+ /** Severity of the decision (e.g., 'critical', 'fatal'). */
1837
+ severity: string;
1838
+ /** Human-readable reason for the halt. */
1839
+ reason: string;
1840
+ };
1841
+ /**
1842
+ * Story 72-1: A halt-able decision was routed and the policy allows autonomous action.
1843
+ * Emitted when routeDecision() returns halt=false for a given policy.
1844
+ * Caller applies defaultAction without operator intervention.
1845
+ * Mirror of CoreEvents['decision:autonomous']; both must stay in sync.
1846
+ */
1847
+ 'decision:autonomous': {
1848
+ runId: string;
1849
+ /** The decision type that was routed autonomously (e.g., 'build-verification-failure'). */
1850
+ decisionType: string;
1851
+ /** Severity of the decision (e.g., 'info', 'warning', 'critical'). */
1852
+ severity: string;
1853
+ /** The action applied autonomously (e.g., 'escalate-without-halt', 'continue-autonomous'). */
1854
+ defaultAction: string;
1855
+ /** Human-readable reason for autonomous action. */
1856
+ reason: string;
1857
+ };
1858
+ /**
1859
+ * Story 73-1: Tier A auto-retry — recovery engine re-dispatched a story
1860
+ * with diagnosis + findings prepended to the retry prompt.
1861
+ *
1862
+ * Mirror of CoreEvents['recovery:tier-a-retry']; both must stay in sync.
1863
+ */
1864
+ 'recovery:tier-a-retry': {
1865
+ runId: string;
1866
+ storyKey: string;
1867
+ rootCause: string;
1868
+ attempt: number;
1869
+ retryBudgetRemaining: number;
1870
+ };
1871
+ /**
1872
+ * Story 73-1: Tier B re-scope proposal — recovery engine appended a
1873
+ * re-scope proposal to RunManifest.pending_proposals.
1874
+ *
1875
+ * Mirror of CoreEvents['recovery:tier-b-proposal']; both must stay in sync.
1876
+ */
1877
+ 'recovery:tier-b-proposal': {
1878
+ runId: string;
1879
+ storyKey: string;
1880
+ rootCause: string;
1881
+ attempts: number;
1882
+ suggestedAction: string;
1883
+ blastRadius: string[];
1884
+ };
1885
+ /**
1886
+ * Story 73-1: Tier C halt — recovery engine determined a halt is required.
1887
+ * The orchestrator yields to the Decision Router / Interactive Prompt (Story 73-2).
1888
+ *
1889
+ * Mirror of CoreEvents['recovery:tier-c-halt']; both must stay in sync.
1890
+ */
1891
+ 'recovery:tier-c-halt': {
1892
+ runId: string;
1893
+ storyKey: string;
1894
+ rootCause: string;
1895
+ };
1896
+ /**
1897
+ * Story 73-1: Safety valve — pending_proposals count reached 5 or more.
1898
+ * The orchestrator exits the main loop with code 1.
1899
+ *
1900
+ * Mirror of CoreEvents['pipeline:halted-pending-proposals']; both must stay
1901
+ * in sync.
1902
+ */
1903
+ 'pipeline:halted-pending-proposals': {
1904
+ runId: string;
1905
+ pendingProposalsCount: number;
1906
+ };
1907
+ } //#endregion
2513
1908
  //#region src/core/event-bus.d.ts
1909
+
2514
1910
  //# sourceMappingURL=event-bus.types.d.ts.map
2515
1911
  /**
2516
1912
  * Backward-compatible type alias: TypedEventBus specialized to OrchestratorEvents.
@@ -2519,7 +1915,7 @@ interface OrchestratorEvents {
2519
1915
  * This alias ensures those declarations continue to enforce OrchestratorEvents
2520
1916
  * handler types rather than defaulting to Record<string, unknown>.
2521
1917
  */
2522
- type TypedEventBus = TypedEventBus$1<OrchestratorEvents>;
1918
+ type TypedEventBus$1 = TypedEventBus<OrchestratorEvents>;
2523
1919
  /**
2524
1920
  * Concrete implementation specialized to OrchestratorEvents.
2525
1921
  *
@@ -2541,7 +1937,7 @@ type TypedEventBus = TypedEventBus$1<OrchestratorEvents>;
2541
1937
  * @example
2542
1938
  * const bus = createEventBus()
2543
1939
  */
2544
- declare function createEventBus(): TypedEventBus;
1940
+ declare function createEventBus(): TypedEventBus$1;
2545
1941
 
2546
1942
  //#endregion
2547
1943
  //#region src/core/di.d.ts
@@ -3055,5 +2451,5 @@ interface TuiState {
3055
2451
  //#endregion
3056
2452
  //# sourceMappingURL=types.d.ts.map
3057
2453
 
3058
- export { AdapterCapabilities, AdapterDiscoveryResult, AdapterHealthResult, AdapterOptions, AdapterRegistry, AdtError, AgentCapability, AgentId, BaseService, BillingMode, BudgetExceededError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, CostRecord, DiscoveryReport, EscalationIssue, GeminiCLIAdapter, GitError, LogLevel, OrchestratorEvents, PipelineCompleteEvent, PipelineEvent, PipelinePhase, PipelineStartEvent, PlanParseResult, PlanRequest, PlannedTask, RecoveryError, ServiceRegistry, SessionConfig, SessionStatus, SpawnCommand, StoryDoneEvent, StoryEscalationEvent, StoryLogEvent, StoryPhaseEvent, StoryPhaseLabel, StoryStatus, StoryWarnEvent, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, TaskId, TaskNode, TaskPriority, TaskResult, TaskStatus, TokenEstimate, TuiApp, TuiLogEntry, TuiState, TuiStoryState, TuiView, TypedEventBus, WorkerAdapter, WorkerError, WorkerId, WorkerNotFoundError, assertDefined, childLogger, createEventBus, createLogger, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, logger, printNonTtyWarning, sleep, withRetry };
2454
+ export { AdapterCapabilities, AdapterDiscoveryResult, AdapterHealthResult, AdapterOptions, AdapterRegistry, AdtError, AgentCapability, AgentId, BaseService, BillingMode, BudgetExceededError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, CostRecord, DiscoveryReport, EscalationIssue, GeminiCLIAdapter, GitError, LogLevel, OrchestratorEvents, PipelineCompleteEvent, PipelineEvent, PipelinePhase, PipelineStartEvent, PlanParseResult, PlanRequest, PlannedTask, RecoveryError, ServiceRegistry, SessionConfig, SessionStatus, SpawnCommand, StoryDoneEvent, StoryEscalationEvent, StoryLogEvent, StoryPhaseEvent, StoryPhaseLabel, StoryStatus, StoryWarnEvent, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, TaskId, TaskNode, TaskPriority, TaskResult, TaskStatus, TokenEstimate, TuiApp, TuiLogEntry, TuiState, TuiStoryState, TuiView, TypedEventBus$1 as TypedEventBus, WorkerAdapter, WorkerError, WorkerId, WorkerNotFoundError, assertDefined, childLogger, createEventBus, createLogger, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, logger, printNonTtyWarning, sleep, withRetry };
3059
2455
  //# sourceMappingURL=index.d.ts.map