substrate-ai 0.19.11 → 0.19.13

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.
@@ -0,0 +1,4 @@
1
+ import { AdapterRegistry } from "./dist-BY9vJ8c2.js";
2
+ import "./adapter-registry-DXLMTmfD.js";
3
+
4
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot } from "../health-DJgGZhW-.js";
2
+ import { FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot } from "../health-CccxcGxy.js";
3
3
  import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
- import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-adzGUKPc.js";
5
+ import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-BY9vJ8c2.js";
6
6
  import "../adapter-registry-DXLMTmfD.js";
7
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BLxcApKZ.js";
8
- import "../errors-CZdr5Wqb.js";
7
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BIITWyr2.js";
8
+ import "../errors-CsyjTWQC.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
11
11
  import "../version-manager-impl-BmOWu8ml.js";
12
- import { registerUpgradeCommand } from "../upgrade-C3-h4asQ.js";
12
+ import { registerUpgradeCommand } from "../upgrade-BK31djfs.js";
13
13
  import { Command } from "commander";
14
14
  import { fileURLToPath } from "url";
15
15
  import { dirname, join, resolve } from "path";
@@ -2678,7 +2678,7 @@ function mapInternalPhaseToEventPhase(internalPhase) {
2678
2678
  }
2679
2679
  }
2680
2680
  async function runResumeAction(options) {
2681
- const { runId: specifiedRunId, stopAfter, outputFormat, projectRoot, concurrency, pack: packName, events: eventsFlag, registry, maxReviewCycles = 2, agent: agentId$1 } = options;
2681
+ const { runId: specifiedRunId, stopAfter, outputFormat, projectRoot, concurrency, pack: packName, events: eventsFlag, registry, maxReviewCycles = 2, agent: agentId } = options;
2682
2682
  if (stopAfter !== void 0 && !VALID_PHASES.includes(stopAfter)) {
2683
2683
  const errorMsg = `Invalid phase: "${stopAfter}". Valid phases: ${VALID_PHASES.join(", ")}`;
2684
2684
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, errorMsg) + "\n");
@@ -2762,7 +2762,8 @@ async function runResumeAction(options) {
2762
2762
  existingRunId: runId,
2763
2763
  projectRoot,
2764
2764
  registry,
2765
- stories: options.stories ?? scopedStories
2765
+ stories: options.stories ?? scopedStories,
2766
+ agentId
2766
2767
  });
2767
2768
  } catch (err) {
2768
2769
  const msg = err instanceof Error ? err.message : String(err);
@@ -2777,7 +2778,7 @@ async function runResumeAction(options) {
2777
2778
  }
2778
2779
  }
2779
2780
  async function runFullPipelineFromPhase(options) {
2780
- const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, events: eventsFlag, existingRunId, projectRoot, registry: injectedRegistry, stories: explicitStories, maxReviewCycles = 2 } = options;
2781
+ const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, events: eventsFlag, existingRunId, projectRoot, registry: injectedRegistry, stories: explicitStories, maxReviewCycles = 2, agentId } = options;
2781
2782
  if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
2782
2783
  const adapter = createDatabaseAdapter({
2783
2784
  backend: "auto",
@@ -2807,7 +2808,8 @@ async function runFullPipelineFromPhase(options) {
2807
2808
  db: adapter,
2808
2809
  pack,
2809
2810
  contextCompiler,
2810
- dispatcher
2811
+ dispatcher,
2812
+ agentId
2811
2813
  };
2812
2814
  const phaseOrchestrator = createPhaseOrchestrator({
2813
2815
  db: adapter,
@@ -3210,7 +3212,7 @@ async function runStatusAction(options) {
3210
3212
  if (run === void 0) run = await getLatestRun(adapter);
3211
3213
  }
3212
3214
  if (run === void 0) {
3213
- const { inspectProcessTree } = await import("../health-Cd_psXRz.js");
3215
+ const { inspectProcessTree } = await import("../health-UPGHMvMV.js");
3214
3216
  const substrateDirPath = join(projectRoot, ".substrate");
3215
3217
  const processInfo = inspectProcessTree({
3216
3218
  projectRoot,
@@ -3750,7 +3752,7 @@ async function runPostPhaseSupersessionDetection(adapter, amendmentRunId, curren
3750
3752
  }
3751
3753
  }
3752
3754
  async function runAmendAction(options) {
3753
- const { concept: conceptArg, conceptFile, runId: specifiedRunId, stopAfter, from: startPhase, projectRoot, pack: packName, registry: injectedRegistry, agent: agentId$1 } = options;
3755
+ const { concept: conceptArg, conceptFile, runId: specifiedRunId, stopAfter, from: startPhase, projectRoot, pack: packName, registry: injectedRegistry, agent: agentId } = options;
3754
3756
  let concept;
3755
3757
  if (conceptFile !== void 0 && conceptFile !== "") try {
3756
3758
  concept = await readFile(conceptFile, "utf-8");
@@ -3849,7 +3851,7 @@ async function runAmendAction(options) {
3849
3851
  pack,
3850
3852
  contextCompiler,
3851
3853
  dispatcher,
3852
- agentId: agentId$1
3854
+ agentId
3853
3855
  };
3854
3856
  const phaseOrder = [
3855
3857
  "analysis",
@@ -3893,7 +3895,7 @@ async function runAmendAction(options) {
3893
3895
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3894
3896
  await addTokenUsage(adapter, amendmentRunId, {
3895
3897
  phase: "analysis",
3896
- agent: agentId$1 ?? "claude-code",
3898
+ agent: agentId ?? "claude-code",
3897
3899
  input_tokens: result.tokenUsage.input,
3898
3900
  output_tokens: result.tokenUsage.output,
3899
3901
  cost_usd: costUsd
@@ -3915,7 +3917,7 @@ async function runAmendAction(options) {
3915
3917
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3916
3918
  await addTokenUsage(adapter, amendmentRunId, {
3917
3919
  phase: "planning",
3918
- agent: agentId$1 ?? "claude-code",
3920
+ agent: agentId ?? "claude-code",
3919
3921
  input_tokens: result.tokenUsage.input,
3920
3922
  output_tokens: result.tokenUsage.output,
3921
3923
  cost_usd: costUsd
@@ -3937,7 +3939,7 @@ async function runAmendAction(options) {
3937
3939
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3938
3940
  await addTokenUsage(adapter, amendmentRunId, {
3939
3941
  phase: "solutioning",
3940
- agent: agentId$1 ?? "claude-code",
3942
+ agent: agentId ?? "claude-code",
3941
3943
  input_tokens: result.tokenUsage.input,
3942
3944
  output_tokens: result.tokenUsage.output,
3943
3945
  cost_usd: costUsd
@@ -4097,7 +4099,7 @@ function defaultSupervisorDeps() {
4097
4099
  if (cached === null) {
4098
4100
  const { AdapterRegistry: AR } = await import(
4099
4101
  /* @vite-ignore */
4100
- "../adapter-registry-BVAkrT-E.js"
4102
+ "../adapter-registry-DXqPeMXA.js"
4101
4103
  );
4102
4104
  cached = new AR();
4103
4105
  await cached.discoverAndRegister();
@@ -4539,11 +4541,11 @@ async function runSupervisorAction(options, deps = {}) {
4539
4541
  try {
4540
4542
  const { createExperimenter } = await import(
4541
4543
  /* @vite-ignore */
4542
- "../experimenter-DxQ7CQHb.js"
4544
+ "../experimenter-D5i1C7u8.js"
4543
4545
  );
4544
4546
  const { getLatestRun: getLatest } = await import(
4545
4547
  /* @vite-ignore */
4546
- "../decisions-CTvoZrPH.js"
4548
+ "../decisions-zz_jtWQz.js"
4547
4549
  );
4548
4550
  const expAdapter = createDatabaseAdapter({
4549
4551
  backend: "auto",
@@ -4553,7 +4555,7 @@ async function runSupervisorAction(options, deps = {}) {
4553
4555
  await initSchema(expAdapter);
4554
4556
  const { runRunAction: runPipeline } = await import(
4555
4557
  /* @vite-ignore */
4556
- "../run-Ds3ucwad.js"
4558
+ "../run-B056zOp4.js"
4557
4559
  );
4558
4560
  const runStoryFn = async (opts) => {
4559
4561
  const exitCode = await runPipeline({
@@ -5083,7 +5085,7 @@ async function runMetricsAction(options) {
5083
5085
  const routingConfigPath = join(dbDir, "routing.yml");
5084
5086
  let routingConfig = null;
5085
5087
  if (existsSync$1(routingConfigPath)) try {
5086
- const { loadModelRoutingConfig } = await import("../routing-Vzz2S3bc.js");
5088
+ const { loadModelRoutingConfig } = await import("../routing-7MdlUyW-.js");
5087
5089
  routingConfig = loadModelRoutingConfig(routingConfigPath);
5088
5090
  } catch {}
5089
5091
  if (routingConfig === null) routingConfig = {
@@ -7165,7 +7167,7 @@ function registerBrainstormCommand(program, _version = "0.0.0", projectRoot = pr
7165
7167
  //#region src/cli/commands/retry-escalated.ts
7166
7168
  const logger$3 = createLogger("retry-escalated-cmd");
7167
7169
  async function runRetryEscalatedAction(options) {
7168
- const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry, agent: agentId$1 } = options;
7170
+ const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry, agent: agentId } = options;
7169
7171
  const dbRoot = await resolveMainRepoRoot(projectRoot);
7170
7172
  const dbPath = join(dbRoot, ".substrate", "substrate.db");
7171
7173
  const doltDir = join(dbRoot, ".substrate", "state", ".dolt");
@@ -7269,7 +7271,7 @@ async function runRetryEscalatedAction(options) {
7269
7271
  ...Object.keys(perStoryContextCeilings).length > 0 ? { perStoryContextCeilings } : {}
7270
7272
  },
7271
7273
  projectRoot,
7272
- agentId: agentId$1
7274
+ agentId
7273
7275
  });
7274
7276
  eventBus.on("orchestrator:story-phase-complete", (payload) => {
7275
7277
  try {
@@ -7279,7 +7281,7 @@ async function runRetryEscalatedAction(options) {
7279
7281
  const costUsd = (input * 3 + output * 15) / 1e6;
7280
7282
  addTokenUsage(adapter, pipelineRun.id, {
7281
7283
  phase: payload.phase,
7282
- agent: agentId$1 ?? "claude-code",
7284
+ agent: agentId ?? "claude-code",
7283
7285
  input_tokens: input,
7284
7286
  output_tokens: output,
7285
7287
  cost_usd: costUsd
@@ -8161,8 +8163,8 @@ async function createProgram() {
8161
8163
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
8162
8164
  function checkForUpdatesInBackground(currentVersion) {
8163
8165
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
8164
- import("../upgrade-BtaFOZk0.js").then(async () => {
8165
- const { createVersionManager } = await import("../version-manager-impl-CCk76_D8.js");
8166
+ import("../upgrade-PRTRKTut.js").then(async () => {
8167
+ const { createVersionManager } = await import("../version-manager-impl-CwP9Bofo.js");
8166
8168
  const vm = createVersionManager();
8167
8169
  const result = await vm.checkForUpdates();
8168
8170
  if (result.updateAvailable) {
@@ -1,4 +1,4 @@
1
- import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-adzGUKPc.js";
1
+ import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-BY9vJ8c2.js";
2
2
  import "./decisions-C0pz9Clx.js";
3
3
 
4
4
  export { getLatestRun };
@@ -116,7 +116,9 @@ function extractYamlBlock(output) {
116
116
  const fencedResult = extractLastFencedYaml(output);
117
117
  if (fencedResult !== null) return fencedResult;
118
118
  const stripped = stripTrailingFence(output);
119
- return extractUnfencedYaml(stripped);
119
+ const unfenced = extractUnfencedYaml(stripped);
120
+ if (unfenced !== null) return unfenced;
121
+ return extractJsonAsYaml(output);
120
122
  }
121
123
  /**
122
124
  * Strip a trailing markdown fence that wraps the entire remaining output.
@@ -172,6 +174,32 @@ function extractUnfencedYaml(output) {
172
174
  return yamlText !== "" ? yamlText : null;
173
175
  }
174
176
  /**
177
+ * Try to extract a JSON object from the output and convert it to YAML.
178
+ *
179
+ * Scans for JSON objects (delimited by { ... }) that contain at least one
180
+ * anchor key. Tries the last such object. Converts via yaml.dump so
181
+ * downstream parseYamlResult can validate it with the same Zod schema.
182
+ */
183
+ function extractJsonAsYaml(output) {
184
+ const jsonPattern = /\{[\s\S]*?\n\}/g;
185
+ let lastJsonObj = null;
186
+ let match;
187
+ while ((match = jsonPattern.exec(output)) !== null) {
188
+ const candidate = match[0];
189
+ if (!YAML_ANCHOR_KEYS.some((key) => candidate.includes(key.replace(":", "")))) continue;
190
+ try {
191
+ const parsed = JSON.parse(candidate);
192
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) lastJsonObj = parsed;
193
+ } catch {}
194
+ }
195
+ if (lastJsonObj === null) return null;
196
+ try {
197
+ return yaml.dump(lastJsonObj, { lineWidth: -1 });
198
+ } catch {
199
+ return null;
200
+ }
201
+ }
202
+ /**
175
203
  * Check if a line starts with one of the known anchor keys.
176
204
  */
177
205
  function isAnchorLine(line) {
@@ -8782,10 +8810,14 @@ var CodexCLIAdapter = class {
8782
8810
  }
8783
8811
  /**
8784
8812
  * Build spawn command for a coding task.
8785
- * Uses: `codex exec --json` with prompt delivered via stdin.
8813
+ * Uses: `codex exec` with prompt delivered via stdin.
8814
+ *
8815
+ * Do NOT use --json: it produces a JSONL event stream that prevents
8816
+ * extractYamlBlock from finding the structured result block in stdout.
8817
+ * Raw text output is required (same rationale as Claude adapter).
8786
8818
  */
8787
8819
  buildCommand(prompt, options) {
8788
- const args = ["exec", "--json"];
8820
+ const args = ["exec"];
8789
8821
  if (options.additionalFlags && options.additionalFlags.length > 0) args.push(...options.additionalFlags);
8790
8822
  const envEntries = {};
8791
8823
  if (options.apiKey) envEntries.OPENAI_API_KEY = options.apiKey;
@@ -8822,7 +8854,10 @@ var CodexCLIAdapter = class {
8822
8854
  };
8823
8855
  }
8824
8856
  /**
8825
- * Parse Codex CLI JSON output into a TaskResult.
8857
+ * Parse Codex CLI output into a TaskResult.
8858
+ *
8859
+ * With raw text mode (no --json), stdout is the agent's direct output.
8860
+ * YAML extraction happens in the dispatcher's extractYamlBlock, not here.
8826
8861
  */
8827
8862
  parseOutput(stdout, stderr, exitCode) {
8828
8863
  if (exitCode !== 0) return {
@@ -8831,41 +8866,11 @@ var CodexCLIAdapter = class {
8831
8866
  error: stderr || `Process exited with code ${String(exitCode)}`,
8832
8867
  exitCode
8833
8868
  };
8834
- if (stdout.trim() === "") return {
8869
+ return {
8835
8870
  success: true,
8836
- output: "",
8871
+ output: stdout,
8837
8872
  exitCode
8838
8873
  };
8839
- try {
8840
- const parsed = JSON.parse(stdout.trim());
8841
- const success = parsed.status === "success" || parsed.status === "completed" || parsed.status === void 0 && !parsed.error;
8842
- const inputTokens = parsed.tokens?.input ?? 0;
8843
- const outputTokens = parsed.tokens?.output ?? 0;
8844
- const totalTokens = parsed.tokens?.total ?? inputTokens + outputTokens;
8845
- const hasTokens = inputTokens > 0 || outputTokens > 0;
8846
- const tokensUsed = hasTokens ? {
8847
- input: inputTokens,
8848
- output: outputTokens,
8849
- total: totalTokens
8850
- } : void 0;
8851
- const executionTime = parsed.executionTime;
8852
- return {
8853
- success: success && !parsed.error,
8854
- output: parsed.output ?? parsed.result ?? stdout,
8855
- ...parsed.error ? { error: parsed.error } : {},
8856
- exitCode,
8857
- metadata: {
8858
- ...executionTime !== void 0 ? { executionTime } : {},
8859
- ...tokensUsed !== void 0 ? { tokensUsed } : {}
8860
- }
8861
- };
8862
- } catch {
8863
- return {
8864
- success: true,
8865
- output: stdout,
8866
- exitCode
8867
- };
8868
- }
8869
8874
  }
8870
8875
  /**
8871
8876
  * Parse Codex plan generation output.
@@ -10243,4 +10248,4 @@ async function callLLM(params) {
10243
10248
 
10244
10249
  //#endregion
10245
10250
  export { ADVISORY_NOTES, AdapterRegistry, AdtError, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, Categorizer, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, ConsumerAnalyzer, CostTrackerConfigSchema, DEFAULT_CONFIG, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, DoltNotInstalled, DoltQueryError, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, GeminiCLIAdapter, GlobalSettingsSchema, IngestionServer, LogTurnAnalyzer, ModelRoutingConfigSchema, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProviderPolicySchema, ProvidersSchema, Recommender, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TASK_TYPE_PHASE_MAP, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryConfigSchema, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, VersionManagerImpl, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, callLLM, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDatabaseAdapter as createDatabaseAdapter$1, createDecision, createDoltClient, createExperimenter, createPipelineRun, createRequirement, createVersionManager, detectInterfaceChanges, determineVerdict, getActiveDecisions, getAllCostEntriesFiltered, getArtifactByTypeForRun, getArtifactsByRun, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getModelTier, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRequirements, listRunMetrics, loadModelRoutingConfig, loadParentRunDecisions, registerArtifact, resolvePromptFile, supersedeDecision, tagRunAsBaseline, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics };
10246
- //# sourceMappingURL=dist-adzGUKPc.js.map
10251
+ //# sourceMappingURL=dist-BY9vJ8c2.js.map
@@ -1,4 +1,4 @@
1
- import { AdtError } from "./dist-adzGUKPc.js";
1
+ import { AdtError } from "./dist-BY9vJ8c2.js";
2
2
 
3
3
  //#region src/core/errors.ts
4
4
  /** Error thrown when task configuration is invalid */
@@ -71,4 +71,4 @@ var TaskGraphIncompatibleFormatError = class extends AdtError {
71
71
 
72
72
  //#endregion
73
73
  export { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError };
74
- //# sourceMappingURL=errors-CZdr5Wqb.js.map
74
+ //# sourceMappingURL=errors-CsyjTWQC.js.map
@@ -1,3 +1,3 @@
1
- import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-adzGUKPc.js";
1
+ import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-BY9vJ8c2.js";
2
2
 
3
3
  export { createExperimenter };
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-adzGUKPc.js";
2
+ import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-BY9vJ8c2.js";
3
3
  import { createRequire } from "module";
4
4
  import { dirname, join } from "path";
5
5
  import { existsSync, readFileSync } from "node:fs";
@@ -1930,4 +1930,4 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
1930
1930
 
1931
1931
  //#endregion
1932
1932
  export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN$1 as STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createStateStore, detectCycles, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, runHealthAction, validateStoryKey };
1933
- //# sourceMappingURL=health-DJgGZhW-.js.map
1933
+ //# sourceMappingURL=health-CccxcGxy.js.map
@@ -1,6 +1,6 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-DJgGZhW-.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-CccxcGxy.js";
2
2
  import "./logger-KeHncl-f.js";
3
- import "./dist-adzGUKPc.js";
3
+ import "./dist-BY9vJ8c2.js";
4
4
  import "./decisions-C0pz9Clx.js";
5
5
 
6
6
  export { inspectProcessTree };
package/dist/index.d.ts CHANGED
@@ -1211,7 +1211,11 @@ declare class CodexCLIAdapter implements WorkerAdapter$1 {
1211
1211
  healthCheck(): Promise<AdapterHealthResult$1>;
1212
1212
  /**
1213
1213
  * Build spawn command for a coding task.
1214
- * Uses: `codex exec --json` with prompt delivered via stdin.
1214
+ * Uses: `codex exec` with prompt delivered via stdin.
1215
+ *
1216
+ * Do NOT use --json: it produces a JSONL event stream that prevents
1217
+ * extractYamlBlock from finding the structured result block in stdout.
1218
+ * Raw text output is required (same rationale as Claude adapter).
1215
1219
  */
1216
1220
  buildCommand(prompt: string, options: AdapterOptions$1): SpawnCommand$1;
1217
1221
  /**
@@ -1220,7 +1224,10 @@ declare class CodexCLIAdapter implements WorkerAdapter$1 {
1220
1224
  */
1221
1225
  buildPlanningCommand(request: PlanRequest$1, options: AdapterOptions$1): SpawnCommand$1;
1222
1226
  /**
1223
- * Parse Codex CLI JSON output into a TaskResult.
1227
+ * Parse Codex CLI output into a TaskResult.
1228
+ *
1229
+ * With raw text mode (no --json), stdout is the agent's direct output.
1230
+ * YAML extraction happens in the dispatcher's extractYamlBlock, not here.
1224
1231
  */
1225
1232
  parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult$2;
1226
1233
  /**
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { childLogger, createLogger, logger } from "./logger-KeHncl-f.js";
2
2
  import { assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry } from "./helpers-CElYrONe.js";
3
- import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-adzGUKPc.js";
3
+ import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-BY9vJ8c2.js";
4
4
  import "./adapter-registry-DXLMTmfD.js";
5
- import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-CZdr5Wqb.js";
5
+ import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-CsyjTWQC.js";
6
6
 
7
7
  //#region src/core/di.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-adzGUKPc.js";
1
+ import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-BY9vJ8c2.js";
2
2
  import "./routing-CcBOCuC9.js";
3
3
 
4
4
  export { loadModelRoutingConfig };
@@ -1,8 +1,8 @@
1
- import "./health-DJgGZhW-.js";
1
+ import "./health-CccxcGxy.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
- import "./dist-adzGUKPc.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, runRunAction } from "./run-BLxcApKZ.js";
4
+ import "./dist-BY9vJ8c2.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, runRunAction } from "./run-BIITWyr2.js";
6
6
  import "./routing-CcBOCuC9.js";
7
7
  import "./decisions-C0pz9Clx.js";
8
8
 
@@ -1,7 +1,7 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, detectCycles, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveMainRepoRoot, validateStoryKey } from "./health-DJgGZhW-.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, detectCycles, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveMainRepoRoot, validateStoryKey } from "./health-CccxcGxy.js";
2
2
  import { createLogger } from "./logger-KeHncl-f.js";
3
3
  import { TypedEventBusImpl, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-CElYrONe.js";
4
- import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-adzGUKPc.js";
4
+ import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-BY9vJ8c2.js";
5
5
  import { basename, dirname, extname, join } from "path";
6
6
  import { access, readFile, readdir, stat } from "fs/promises";
7
7
  import { EventEmitter } from "node:events";
@@ -10540,7 +10540,7 @@ function checkProfileStaleness(projectRoot) {
10540
10540
  * @returns A fully-configured ImplementationOrchestrator ready to call run()
10541
10541
  */
10542
10542
  function createImplementationOrchestrator(deps) {
10543
- const { db, pack, contextCompiler, dispatcher, eventBus, config, projectRoot, tokenCeilings, stateStore, telemetryPersistence, ingestionServer, repoMapInjector, maxRepoMapTokens } = deps;
10543
+ const { db, pack, contextCompiler, dispatcher, eventBus, config, projectRoot, tokenCeilings, stateStore, telemetryPersistence, ingestionServer, repoMapInjector, maxRepoMapTokens, agentId } = deps;
10544
10544
  const logger$22 = createLogger("implementation-orchestrator");
10545
10545
  const telemetryAdvisor = db !== void 0 ? createTelemetryAdvisor({ db }) : void 0;
10546
10546
  const wgRepo = new WorkGraphRepository(db);
@@ -11096,7 +11096,8 @@ function createImplementationOrchestrator(deps) {
11096
11096
  dispatcher,
11097
11097
  projectRoot,
11098
11098
  tokenCeilings,
11099
- otlpEndpoint: _otlpEndpoint
11099
+ otlpEndpoint: _otlpEndpoint,
11100
+ agentId
11100
11101
  }, {
11101
11102
  epicId: storyKey.split("-")[0] ?? storyKey,
11102
11103
  storyKey,
@@ -11274,7 +11275,8 @@ function createImplementationOrchestrator(deps) {
11274
11275
  dispatcher,
11275
11276
  projectRoot,
11276
11277
  tokenCeilings,
11277
- otlpEndpoint: _otlpEndpoint
11278
+ otlpEndpoint: _otlpEndpoint,
11279
+ agentId
11278
11280
  }, {
11279
11281
  storyKey,
11280
11282
  storyFilePath: storyFilePath ?? "",
@@ -11382,6 +11384,7 @@ function createImplementationOrchestrator(deps) {
11382
11384
  otlpEndpoint: _otlpEndpoint,
11383
11385
  repoMapInjector,
11384
11386
  maxRepoMapTokens,
11387
+ agentId,
11385
11388
  ...config.perStoryContextCeilings?.[storyKey] !== void 0 ? { maxContextTokens: config.perStoryContextCeilings[storyKey] } : {},
11386
11389
  ...storyOptions?.optimizationDirectives !== void 0 ? { optimizationDirectives: storyOptions.optimizationDirectives } : {}
11387
11390
  }, {
@@ -11467,6 +11470,7 @@ function createImplementationOrchestrator(deps) {
11467
11470
  otlpEndpoint: _otlpEndpoint,
11468
11471
  repoMapInjector,
11469
11472
  maxRepoMapTokens,
11473
+ agentId,
11470
11474
  ...config.perStoryContextCeilings?.[storyKey] !== void 0 ? { maxContextTokens: config.perStoryContextCeilings[storyKey] } : {},
11471
11475
  ...storyOptions?.optimizationDirectives !== void 0 ? { optimizationDirectives: storyOptions.optimizationDirectives } : {}
11472
11476
  }, {
@@ -12029,6 +12033,7 @@ function createImplementationOrchestrator(deps) {
12029
12033
  otlpEndpoint: _otlpEndpoint,
12030
12034
  repoMapInjector,
12031
12035
  maxRepoMapTokens,
12036
+ agentId,
12032
12037
  ...config.perStoryContextCeilings?.[storyKey] !== void 0 ? { maxContextTokens: config.perStoryContextCeilings[storyKey] } : {}
12033
12038
  }, {
12034
12039
  storyKey,
@@ -12073,6 +12078,7 @@ function createImplementationOrchestrator(deps) {
12073
12078
  otlpEndpoint: _otlpEndpoint,
12074
12079
  repoMapInjector,
12075
12080
  maxRepoMapTokens,
12081
+ agentId,
12076
12082
  ...config.perStoryContextCeilings?.[storyKey] !== void 0 ? { maxContextTokens: config.perStoryContextCeilings[storyKey] } : {}
12077
12083
  }, {
12078
12084
  storyKey,
@@ -12280,7 +12286,8 @@ function createImplementationOrchestrator(deps) {
12280
12286
  dispatcher,
12281
12287
  projectRoot,
12282
12288
  tokenCeilings,
12283
- otlpEndpoint: _otlpEndpoint
12289
+ otlpEndpoint: _otlpEndpoint,
12290
+ agentId
12284
12291
  }, {
12285
12292
  storyKey,
12286
12293
  storyFilePath: storyFilePath ?? "",
@@ -41641,4 +41648,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
41641
41648
 
41642
41649
  //#endregion
41643
41650
  export { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
41644
- //# sourceMappingURL=run-BLxcApKZ.js.map
41651
+ //# sourceMappingURL=run-BIITWyr2.js.map
@@ -1,4 +1,4 @@
1
- import { createVersionManager } from "./dist-adzGUKPc.js";
1
+ import { createVersionManager } from "./dist-BY9vJ8c2.js";
2
2
  import { execSync, spawn } from "child_process";
3
3
  import * as readline from "readline";
4
4
 
@@ -123,4 +123,4 @@ function registerUpgradeCommand(program) {
123
123
 
124
124
  //#endregion
125
125
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
126
- //# sourceMappingURL=upgrade-C3-h4asQ.js.map
126
+ //# sourceMappingURL=upgrade-BK31djfs.js.map
@@ -1,5 +1,5 @@
1
- import "./dist-adzGUKPc.js";
1
+ import "./dist-BY9vJ8c2.js";
2
2
  import "./version-manager-impl-BmOWu8ml.js";
3
- import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-C3-h4asQ.js";
3
+ import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-BK31djfs.js";
4
4
 
5
5
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
@@ -1,4 +1,4 @@
1
- import { VersionManagerImpl, createVersionManager } from "./dist-adzGUKPc.js";
1
+ import { VersionManagerImpl, createVersionManager } from "./dist-BY9vJ8c2.js";
2
2
  import "./version-manager-impl-BmOWu8ml.js";
3
3
 
4
4
  export { createVersionManager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.19.11",
3
+ "version": "0.19.13",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- import { AdapterRegistry } from "./dist-adzGUKPc.js";
2
- import "./adapter-registry-DXLMTmfD.js";
3
-
4
- export { AdapterRegistry };