substrate-ai 0.19.10 → 0.19.11

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.
package/dist/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
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";
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-NJQHRIYt.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
8
  import "../errors-CZdr5Wqb.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
@@ -1155,7 +1155,8 @@ const SubstrateConfigSchema = z.object({
1155
1155
  budget: BudgetConfigSchema.optional(),
1156
1156
  token_ceilings: TokenCeilingsSchema.optional(),
1157
1157
  dispatch_timeouts: DispatchTimeoutsSchema.optional(),
1158
- telemetry: TelemetryConfigSchema.optional()
1158
+ telemetry: TelemetryConfigSchema.optional(),
1159
+ default_agent: z.string().optional()
1159
1160
  }).strict();
1160
1161
  const PartialSubstrateConfigSchema = z.object({
1161
1162
  config_format_version: z.enum(["1"]).optional(),
@@ -1170,7 +1171,8 @@ const PartialSubstrateConfigSchema = z.object({
1170
1171
  budget: BudgetConfigSchema.partial().optional(),
1171
1172
  token_ceilings: TokenCeilingsSchema.optional(),
1172
1173
  dispatch_timeouts: DispatchTimeoutsSchema.optional(),
1173
- telemetry: TelemetryConfigSchema.partial().optional()
1174
+ telemetry: TelemetryConfigSchema.partial().optional(),
1175
+ default_agent: z.string().optional()
1174
1176
  }).strict();
1175
1177
 
1176
1178
  //#endregion
@@ -2676,7 +2678,7 @@ function mapInternalPhaseToEventPhase(internalPhase) {
2676
2678
  }
2677
2679
  }
2678
2680
  async function runResumeAction(options) {
2679
- const { runId: specifiedRunId, stopAfter, outputFormat, projectRoot, concurrency, pack: packName, events: eventsFlag, registry, maxReviewCycles = 2 } = options;
2681
+ const { runId: specifiedRunId, stopAfter, outputFormat, projectRoot, concurrency, pack: packName, events: eventsFlag, registry, maxReviewCycles = 2, agent: agentId$1 } = options;
2680
2682
  if (stopAfter !== void 0 && !VALID_PHASES.includes(stopAfter)) {
2681
2683
  const errorMsg = `Invalid phase: "${stopAfter}". Valid phases: ${VALID_PHASES.join(", ")}`;
2682
2684
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, errorMsg) + "\n");
@@ -2836,7 +2838,7 @@ async function runFullPipelineFromPhase(options) {
2836
2838
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
2837
2839
  await addTokenUsage(adapter, runId, {
2838
2840
  phase: "analysis",
2839
- agent: "claude-code",
2841
+ agent: agentId ?? "claude-code",
2840
2842
  input_tokens: result.tokenUsage.input,
2841
2843
  output_tokens: result.tokenUsage.output,
2842
2844
  cost_usd: costUsd
@@ -2856,7 +2858,7 @@ async function runFullPipelineFromPhase(options) {
2856
2858
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
2857
2859
  await addTokenUsage(adapter, runId, {
2858
2860
  phase: "planning",
2859
- agent: "claude-code",
2861
+ agent: agentId ?? "claude-code",
2860
2862
  input_tokens: result.tokenUsage.input,
2861
2863
  output_tokens: result.tokenUsage.output,
2862
2864
  cost_usd: costUsd
@@ -2876,7 +2878,7 @@ async function runFullPipelineFromPhase(options) {
2876
2878
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
2877
2879
  await addTokenUsage(adapter, runId, {
2878
2880
  phase: "solutioning",
2879
- agent: "claude-code",
2881
+ agent: agentId ?? "claude-code",
2880
2882
  input_tokens: result.tokenUsage.input,
2881
2883
  output_tokens: result.tokenUsage.output,
2882
2884
  cost_usd: costUsd
@@ -2917,6 +2919,7 @@ async function runFullPipelineFromPhase(options) {
2917
2919
  enableHeartbeat: eventsFlag === true
2918
2920
  },
2919
2921
  projectRoot,
2922
+ agentId,
2920
2923
  ...ingestionServer !== void 0 ? { ingestionServer } : {},
2921
2924
  ...telemetryPersistence !== void 0 ? { telemetryPersistence } : {}
2922
2925
  });
@@ -3005,7 +3008,7 @@ async function runFullPipelineFromPhase(options) {
3005
3008
  const costUsd = (input * 3 + output * 15) / 1e6;
3006
3009
  addTokenUsage(adapter, runId, {
3007
3010
  phase: payload.phase,
3008
- agent: "claude-code",
3011
+ agent: agentId ?? "claude-code",
3009
3012
  input_tokens: input,
3010
3013
  output_tokens: output,
3011
3014
  cost_usd: costUsd
@@ -3092,7 +3095,7 @@ async function runFullPipelineFromPhase(options) {
3092
3095
  }
3093
3096
  }
3094
3097
  function registerResumeCommand(program, _version = "0.0.0", projectRoot = process.cwd(), registry) {
3095
- program.command("resume").description("Resume a previously interrupted pipeline run").option("--run-id <id>", "Pipeline run ID to resume (defaults to latest)").option("--pack <name>", "Methodology pack name", "bmad").option("--stop-after <phase>", "Stop pipeline after this phase completes (overrides saved state)").option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).action(async (opts) => {
3098
+ program.command("resume").description("Resume a previously interrupted pipeline run").option("--run-id <id>", "Pipeline run ID to resume (defaults to latest)").option("--pack <name>", "Methodology pack name", "bmad").option("--stop-after <phase>", "Stop pipeline after this phase completes (overrides saved state)").option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").action(async (opts) => {
3096
3099
  const outputFormat = opts.outputFormat === "json" ? "json" : "human";
3097
3100
  const exitCode = await runResumeAction({
3098
3101
  runId: opts.runId,
@@ -3103,6 +3106,7 @@ function registerResumeCommand(program, _version = "0.0.0", projectRoot = proces
3103
3106
  pack: opts.pack,
3104
3107
  events: opts.events,
3105
3108
  maxReviewCycles: opts.maxReviewCycles,
3109
+ agent: opts.agent,
3106
3110
  registry
3107
3111
  });
3108
3112
  process.exitCode = exitCode;
@@ -3746,7 +3750,7 @@ async function runPostPhaseSupersessionDetection(adapter, amendmentRunId, curren
3746
3750
  }
3747
3751
  }
3748
3752
  async function runAmendAction(options) {
3749
- const { concept: conceptArg, conceptFile, runId: specifiedRunId, stopAfter, from: startPhase, projectRoot, pack: packName, registry: injectedRegistry } = options;
3753
+ const { concept: conceptArg, conceptFile, runId: specifiedRunId, stopAfter, from: startPhase, projectRoot, pack: packName, registry: injectedRegistry, agent: agentId$1 } = options;
3750
3754
  let concept;
3751
3755
  if (conceptFile !== void 0 && conceptFile !== "") try {
3752
3756
  concept = await readFile(conceptFile, "utf-8");
@@ -3844,7 +3848,8 @@ async function runAmendAction(options) {
3844
3848
  db: adapter,
3845
3849
  pack,
3846
3850
  contextCompiler,
3847
- dispatcher
3851
+ dispatcher,
3852
+ agentId: agentId$1
3848
3853
  };
3849
3854
  const phaseOrder = [
3850
3855
  "analysis",
@@ -3888,7 +3893,7 @@ async function runAmendAction(options) {
3888
3893
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3889
3894
  await addTokenUsage(adapter, amendmentRunId, {
3890
3895
  phase: "analysis",
3891
- agent: "claude-code",
3896
+ agent: agentId$1 ?? "claude-code",
3892
3897
  input_tokens: result.tokenUsage.input,
3893
3898
  output_tokens: result.tokenUsage.output,
3894
3899
  cost_usd: costUsd
@@ -3910,7 +3915,7 @@ async function runAmendAction(options) {
3910
3915
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3911
3916
  await addTokenUsage(adapter, amendmentRunId, {
3912
3917
  phase: "planning",
3913
- agent: "claude-code",
3918
+ agent: agentId$1 ?? "claude-code",
3914
3919
  input_tokens: result.tokenUsage.input,
3915
3920
  output_tokens: result.tokenUsage.output,
3916
3921
  cost_usd: costUsd
@@ -3932,7 +3937,7 @@ async function runAmendAction(options) {
3932
3937
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
3933
3938
  await addTokenUsage(adapter, amendmentRunId, {
3934
3939
  phase: "solutioning",
3935
- agent: "claude-code",
3940
+ agent: agentId$1 ?? "claude-code",
3936
3941
  input_tokens: result.tokenUsage.input,
3937
3942
  output_tokens: result.tokenUsage.output,
3938
3943
  cost_usd: costUsd
@@ -4003,7 +4008,7 @@ async function runAmendAction(options) {
4003
4008
  }
4004
4009
  }
4005
4010
  function registerAmendCommand(program, _version = "0.0.0", projectRoot = process.cwd(), registry) {
4006
- program.command("amend").description("Run an amendment pipeline against a completed run and an existing run").option("--concept <text>", "Amendment concept description (inline)").option("--concept-file <path>", "Path to concept file").option("--run-id <id>", "Parent run ID (defaults to latest completed run)").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--from <phase>", "Start pipeline from this phase").option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").action(async (opts) => {
4011
+ program.command("amend").description("Run an amendment pipeline against a completed run and an existing run").option("--concept <text>", "Amendment concept description (inline)").option("--concept-file <path>", "Path to concept file").option("--run-id <id>", "Parent run ID (defaults to latest completed run)").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--from <phase>", "Start pipeline from this phase").option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").action(async (opts) => {
4007
4012
  const exitCode = await runAmendAction({
4008
4013
  concept: opts.concept,
4009
4014
  conceptFile: opts.conceptFile,
@@ -4012,6 +4017,7 @@ function registerAmendCommand(program, _version = "0.0.0", projectRoot = process
4012
4017
  from: opts.from,
4013
4018
  projectRoot: opts.projectRoot,
4014
4019
  pack: opts.pack,
4020
+ agent: opts.agent,
4015
4021
  registry
4016
4022
  });
4017
4023
  process.exitCode = exitCode;
@@ -4547,7 +4553,7 @@ async function runSupervisorAction(options, deps = {}) {
4547
4553
  await initSchema(expAdapter);
4548
4554
  const { runRunAction: runPipeline } = await import(
4549
4555
  /* @vite-ignore */
4550
- "../run-CAMKyu0F.js"
4556
+ "../run-Ds3ucwad.js"
4551
4557
  );
4552
4558
  const runStoryFn = async (opts) => {
4553
4559
  const exitCode = await runPipeline({
@@ -7159,7 +7165,7 @@ function registerBrainstormCommand(program, _version = "0.0.0", projectRoot = pr
7159
7165
  //#region src/cli/commands/retry-escalated.ts
7160
7166
  const logger$3 = createLogger("retry-escalated-cmd");
7161
7167
  async function runRetryEscalatedAction(options) {
7162
- const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry } = options;
7168
+ const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry, agent: agentId$1 } = options;
7163
7169
  const dbRoot = await resolveMainRepoRoot(projectRoot);
7164
7170
  const dbPath = join(dbRoot, ".substrate", "substrate.db");
7165
7171
  const doltDir = join(dbRoot, ".substrate", "state", ".dolt");
@@ -7262,7 +7268,8 @@ async function runRetryEscalatedAction(options) {
7262
7268
  pipelineRunId: pipelineRun.id,
7263
7269
  ...Object.keys(perStoryContextCeilings).length > 0 ? { perStoryContextCeilings } : {}
7264
7270
  },
7265
- projectRoot
7271
+ projectRoot,
7272
+ agentId: agentId$1
7266
7273
  });
7267
7274
  eventBus.on("orchestrator:story-phase-complete", (payload) => {
7268
7275
  try {
@@ -7272,7 +7279,7 @@ async function runRetryEscalatedAction(options) {
7272
7279
  const costUsd = (input * 3 + output * 15) / 1e6;
7273
7280
  addTokenUsage(adapter, pipelineRun.id, {
7274
7281
  phase: payload.phase,
7275
- agent: "claude-code",
7282
+ agent: agentId$1 ?? "claude-code",
7276
7283
  input_tokens: input,
7277
7284
  output_tokens: output,
7278
7285
  cost_usd: costUsd
@@ -7316,7 +7323,7 @@ function registerRetryEscalatedCommand(program, _version = "0.0.0", projectRoot
7316
7323
  const n = parseInt(v, 10);
7317
7324
  if (isNaN(n) || n < 1) throw new Error(`--concurrency must be a positive integer, got: ${v}`);
7318
7325
  return n;
7319
- }, 3).option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").action(async (opts) => {
7326
+ }, 3).option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").action(async (opts) => {
7320
7327
  const outputFormat = opts.outputFormat === "json" ? "json" : "human";
7321
7328
  const exitCode = await runRetryEscalatedAction({
7322
7329
  runId: opts.runId,
@@ -7326,6 +7333,7 @@ function registerRetryEscalatedCommand(program, _version = "0.0.0", projectRoot
7326
7333
  projectRoot: opts.projectRoot,
7327
7334
  concurrency: opts.concurrency,
7328
7335
  pack: opts.pack,
7336
+ agent: opts.agent,
7329
7337
  registry
7330
7338
  });
7331
7339
  process.exitCode = exitCode;
package/dist/index.d.ts CHANGED
@@ -1528,6 +1528,7 @@ declare const SubstrateConfigSchema: z.ZodObject<{
1528
1528
  enabled: z.ZodDefault<z.ZodBoolean>;
1529
1529
  port: z.ZodDefault<z.ZodNumber>;
1530
1530
  }, z.core.$strict>>;
1531
+ default_agent: z.ZodOptional<z.ZodString>;
1531
1532
  }, z.core.$strict>;
1532
1533
  type SubstrateConfig = z.infer<typeof SubstrateConfigSchema>;
1533
1534
 
@@ -5334,7 +5334,7 @@ async function runCreateStory(deps, params) {
5334
5334
  }, "Prompt assembled for create-story");
5335
5335
  const handle = deps.dispatcher.dispatch({
5336
5336
  prompt,
5337
- agent: "claude-code",
5337
+ agent: deps.agentId ?? "claude-code",
5338
5338
  taskType: "create-story",
5339
5339
  outputSchema: CreateStoryResultSchema,
5340
5340
  maxTurns: 50,
@@ -6556,7 +6556,7 @@ async function runDevStory(deps, params) {
6556
6556
  try {
6557
6557
  const handle = deps.dispatcher.dispatch({
6558
6558
  prompt,
6559
- agent: "claude-code",
6559
+ agent: deps.agentId ?? "claude-code",
6560
6560
  taskType: "dev-story",
6561
6561
  timeout: DEFAULT_TIMEOUT_MS$1,
6562
6562
  outputSchema: DevStoryResultSchema,
@@ -7025,7 +7025,7 @@ async function runCodeReview(deps, params) {
7025
7025
  const { prompt } = assembleResult;
7026
7026
  const handle = deps.dispatcher.dispatch({
7027
7027
  prompt,
7028
- agent: "claude-code",
7028
+ agent: deps.agentId ?? "claude-code",
7029
7029
  taskType: "code-review",
7030
7030
  outputSchema: CodeReviewResultSchema,
7031
7031
  workingDirectory: deps.projectRoot,
@@ -7240,7 +7240,7 @@ async function runTestPlan(deps, params) {
7240
7240
  try {
7241
7241
  const handle = deps.dispatcher.dispatch({
7242
7242
  prompt,
7243
- agent: "claude-code",
7243
+ agent: deps.agentId ?? "claude-code",
7244
7244
  taskType: "test-plan",
7245
7245
  timeout: DEFAULT_TIMEOUT_MS,
7246
7246
  outputSchema: TestPlanResultSchema,
@@ -7511,7 +7511,7 @@ async function runTestExpansion(deps, params) {
7511
7511
  const { prompt } = assembleResult;
7512
7512
  const handle = deps.dispatcher.dispatch({
7513
7513
  prompt,
7514
- agent: "claude-code",
7514
+ agent: deps.agentId ?? "claude-code",
7515
7515
  taskType: "test-expansion",
7516
7516
  outputSchema: TestExpansionResultSchema,
7517
7517
  workingDirectory: deps.projectRoot,
@@ -11631,7 +11631,7 @@ function createImplementationOrchestrator(deps) {
11631
11631
  startPhase(storyKey, "dev-story-retry");
11632
11632
  const checkpointRetryHandle = dispatcher.dispatch({
11633
11633
  prompt: checkpointRetryPrompt,
11634
- agent: "claude-code",
11634
+ agent: deps.agentId ?? "claude-code",
11635
11635
  taskType: "dev-story",
11636
11636
  outputSchema: DevStoryResultSchema,
11637
11637
  ...checkpointRetryMaxTurns !== void 0 ? { maxTurns: checkpointRetryMaxTurns } : {},
@@ -11902,7 +11902,7 @@ function createImplementationOrchestrator(deps) {
11902
11902
  incrementDispatches(storyKey);
11903
11903
  const fixHandle = dispatcher.dispatch({
11904
11904
  prompt: buildFixPrompt,
11905
- agent: "claude-code",
11905
+ agent: deps.agentId ?? "claude-code",
11906
11906
  taskType: "build-fix",
11907
11907
  maxTurns: 15,
11908
11908
  workingDirectory: projectRoot ?? process.cwd(),
@@ -12392,7 +12392,7 @@ function createImplementationOrchestrator(deps) {
12392
12392
  }
12393
12393
  const handle = dispatcher.dispatch({
12394
12394
  prompt: fixPrompt,
12395
- agent: "claude-code",
12395
+ agent: deps.agentId ?? "claude-code",
12396
12396
  taskType: "minor-fixes",
12397
12397
  workingDirectory: projectRoot,
12398
12398
  ...autoApproveMaxTurns !== void 0 ? { maxTurns: autoApproveMaxTurns } : {},
@@ -12551,7 +12551,7 @@ function createImplementationOrchestrator(deps) {
12551
12551
  incrementDispatches(storyKey);
12552
12552
  const handle = isMajorRework ? dispatcher.dispatch({
12553
12553
  prompt: fixPrompt,
12554
- agent: "claude-code",
12554
+ agent: deps.agentId ?? "claude-code",
12555
12555
  taskType,
12556
12556
  ...fixModel !== void 0 ? { model: fixModel } : {},
12557
12557
  outputSchema: DevStoryResultSchema,
@@ -12561,7 +12561,7 @@ function createImplementationOrchestrator(deps) {
12561
12561
  ..._otlpEndpoint !== void 0 ? { otlpEndpoint: _otlpEndpoint } : {}
12562
12562
  }) : dispatcher.dispatch({
12563
12563
  prompt: fixPrompt,
12564
- agent: "claude-code",
12564
+ agent: deps.agentId ?? "claude-code",
12565
12565
  taskType,
12566
12566
  ...fixModel !== void 0 ? { model: fixModel } : {},
12567
12567
  ...fixMaxTurns !== void 0 ? { maxTurns: fixMaxTurns } : {},
@@ -13771,7 +13771,7 @@ async function runCritiqueLoop(artifact, phaseId, runId, phase, deps, options =
13771
13771
  try {
13772
13772
  const handle = deps.dispatcher.dispatch({
13773
13773
  prompt: critiquePrompt,
13774
- agent: "claude-code",
13774
+ agent: deps.agentId ?? "claude-code",
13775
13775
  taskType: "critique",
13776
13776
  outputSchema: CritiqueOutputSchema
13777
13777
  });
@@ -13882,7 +13882,7 @@ async function runCritiqueLoop(artifact, phaseId, runId, phase, deps, options =
13882
13882
  try {
13883
13883
  const refineHandle = deps.dispatcher.dispatch({
13884
13884
  prompt: refinePrompt,
13885
- agent: "claude-code",
13885
+ agent: deps.agentId ?? "claude-code",
13886
13886
  taskType: "critique",
13887
13887
  outputSchema: void 0
13888
13888
  });
@@ -14560,7 +14560,7 @@ async function runSteps(steps, deps, runId, phase, params) {
14560
14560
  }
14561
14561
  const handle = deps.dispatcher.dispatch({
14562
14562
  prompt,
14563
- agent: "claude-code",
14563
+ agent: deps.agentId ?? "claude-code",
14564
14564
  taskType: step.taskType,
14565
14565
  outputSchema: step.outputSchema
14566
14566
  });
@@ -14739,7 +14739,7 @@ async function runSteps(steps, deps, runId, phase, params) {
14739
14739
  const elicitPrompt = elicitationTemplate.replace(/\{\{method_name\}\}/g, method.name).replace(/\{\{method_description\}\}/g, method.description).replace(/\{\{output_pattern\}\}/g, method.output_pattern).replace(/\{\{artifact_content\}\}/g, artifactContent);
14740
14740
  const elicitHandle = deps.dispatcher.dispatch({
14741
14741
  prompt: elicitPrompt,
14742
- agent: "claude-code",
14742
+ agent: deps.agentId ?? "claude-code",
14743
14743
  taskType: "elicitation",
14744
14744
  outputSchema: ElicitationOutputSchema
14745
14745
  });
@@ -15083,7 +15083,7 @@ async function runAnalysisPhase(deps, params) {
15083
15083
  };
15084
15084
  const handle = dispatcher.dispatch({
15085
15085
  prompt,
15086
- agent: "claude-code",
15086
+ agent: deps.agentId ?? "claude-code",
15087
15087
  taskType: "analysis",
15088
15088
  outputSchema: AnalysisOutputSchema
15089
15089
  });
@@ -15395,7 +15395,7 @@ async function runPlanningMultiStep(deps, params) {
15395
15395
  correctedPrompt = correctionPrefix + correctedPrompt;
15396
15396
  const retryHandle = deps.dispatcher.dispatch({
15397
15397
  prompt: correctedPrompt,
15398
- agent: "claude-code",
15398
+ agent: deps.agentId ?? "claude-code",
15399
15399
  taskType: "planning-nfrs",
15400
15400
  outputSchema: PlanningNFRsOutputSchema
15401
15401
  });
@@ -15515,7 +15515,7 @@ async function runPlanningPhase(deps, params) {
15515
15515
  };
15516
15516
  const handle = dispatcher.dispatch({
15517
15517
  prompt,
15518
- agent: "claude-code",
15518
+ agent: deps.agentId ?? "claude-code",
15519
15519
  taskType: "planning",
15520
15520
  outputSchema: PlanningOutputSchema
15521
15521
  });
@@ -15815,7 +15815,7 @@ async function runArchitectureGeneration(deps, params) {
15815
15815
  };
15816
15816
  const handle = dispatcher.dispatch({
15817
15817
  prompt,
15818
- agent: "claude-code",
15818
+ agent: deps.agentId ?? "claude-code",
15819
15819
  taskType: "architecture",
15820
15820
  outputSchema: ArchitectureOutputSchema
15821
15821
  });
@@ -15917,7 +15917,7 @@ async function runStoryGeneration(deps, params, gapAnalysis) {
15917
15917
  };
15918
15918
  const handle = dispatcher.dispatch({
15919
15919
  prompt,
15920
- agent: "claude-code",
15920
+ agent: deps.agentId ?? "claude-code",
15921
15921
  taskType: "story-generation",
15922
15922
  outputSchema: StoryGenerationOutputSchema
15923
15923
  });
@@ -16095,7 +16095,7 @@ async function runReadinessCheck(deps, runId) {
16095
16095
  else prompt = prompt.replace(READINESS_UX_PLACEHOLDER, "");
16096
16096
  const handle = dispatcher.dispatch({
16097
16097
  prompt,
16098
- agent: "claude-code",
16098
+ agent: deps.agentId ?? "claude-code",
16099
16099
  taskType: "readiness-check",
16100
16100
  outputSchema: ReadinessOutputSchema
16101
16101
  });
@@ -40374,7 +40374,7 @@ function wireNdjsonEmitter(eventBus, ndjsonEmitter) {
40374
40374
  });
40375
40375
  }
40376
40376
  async function runRunAction(options) {
40377
- const { pack: packName, from: startPhase, stopAfter, concept: conceptArg, conceptFile, stories: storiesArg, concurrency, outputFormat, projectRoot, events: eventsFlag, verbose: verboseFlag, tui: tuiFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, epic: epicNumber, dryRun, maxReviewCycles = 2, engine, registry: injectedRegistry } = options;
40377
+ const { pack: packName, from: startPhase, stopAfter, concept: conceptArg, conceptFile, stories: storiesArg, concurrency, outputFormat, projectRoot, events: eventsFlag, verbose: verboseFlag, tui: tuiFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, epic: epicNumber, dryRun, maxReviewCycles = 2, engine, agent: agentId, registry: injectedRegistry } = options;
40378
40378
  const resolvedEngine = engine ?? "linear";
40379
40379
  if (!VALID_ENGINES.includes(resolvedEngine)) {
40380
40380
  const errorMsg = `Invalid engine '${engine}'. Valid values: ${VALID_ENGINES.join(", ")}`;
@@ -40538,7 +40538,8 @@ async function runRunAction(options) {
40538
40538
  telemetryEnabled: true,
40539
40539
  telemetryPort
40540
40540
  } : {},
40541
- maxReviewCycles
40541
+ maxReviewCycles,
40542
+ agentId
40542
40543
  });
40543
40544
  let storyKeys = [...parsedStoryKeys];
40544
40545
  if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
@@ -40756,7 +40757,7 @@ async function runRunAction(options) {
40756
40757
  const costUsd = (input * 3 + output * 15) / 1e6;
40757
40758
  addTokenUsage(adapter, pipelineRun.id, {
40758
40759
  phase: payload.phase,
40759
- agent: "claude-code",
40760
+ agent: agentId ?? "claude-code",
40760
40761
  input_tokens: input,
40761
40762
  output_tokens: output,
40762
40763
  cost_usd: costUsd,
@@ -40970,7 +40971,8 @@ async function runRunAction(options) {
40970
40971
  pack,
40971
40972
  contextCompiler,
40972
40973
  dispatcher,
40973
- projectRoot
40974
+ projectRoot,
40975
+ agentId
40974
40976
  };
40975
40977
  const sdlcEventBus = eventBus;
40976
40978
  const handlerRegistry = buildSdlcHandlerRegistry({
@@ -40980,7 +40982,8 @@ async function runRunAction(options) {
40980
40982
  db: adapter,
40981
40983
  pack,
40982
40984
  contextCompiler,
40983
- dispatcher
40985
+ dispatcher,
40986
+ agentId
40984
40987
  },
40985
40988
  phases: {
40986
40989
  analysis: runAnalysisPhase,
@@ -41048,6 +41051,7 @@ async function runRunAction(options) {
41048
41051
  },
41049
41052
  projectRoot,
41050
41053
  tokenCeilings,
41054
+ agentId,
41051
41055
  ...ingestionServer !== void 0 ? { ingestionServer } : {},
41052
41056
  ...telemetryPersistence !== void 0 ? { telemetryPersistence } : {},
41053
41057
  ...repoMapInjector !== void 0 ? {
@@ -41161,7 +41165,7 @@ async function runRunAction(options) {
41161
41165
  }
41162
41166
  }
41163
41167
  async function runFullPipeline(options) {
41164
- const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, projectRoot, events: eventsFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, maxReviewCycles = 2, registry: injectedRegistry, tokenCeilings, stories: explicitStories, telemetryEnabled: fullTelemetryEnabled, telemetryPort: fullTelemetryPort } = options;
41168
+ const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, projectRoot, events: eventsFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, maxReviewCycles = 2, registry: injectedRegistry, tokenCeilings, stories: explicitStories, telemetryEnabled: fullTelemetryEnabled, telemetryPort: fullTelemetryPort, agentId } = options;
41165
41169
  if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
41166
41170
  const adapter = createDatabaseAdapter({
41167
41171
  backend: "auto",
@@ -41202,7 +41206,8 @@ async function runFullPipeline(options) {
41202
41206
  db: adapter,
41203
41207
  pack,
41204
41208
  contextCompiler,
41205
- dispatcher
41209
+ dispatcher,
41210
+ agentId
41206
41211
  };
41207
41212
  let effectiveResearch = pack.manifest.research === true;
41208
41213
  if (researchFlag === true) effectiveResearch = true;
@@ -41294,7 +41299,7 @@ async function runFullPipeline(options) {
41294
41299
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
41295
41300
  await addTokenUsage(adapter, runId, {
41296
41301
  phase: "analysis",
41297
- agent: "claude-code",
41302
+ agent: agentId ?? "claude-code",
41298
41303
  input_tokens: result.tokenUsage.input,
41299
41304
  output_tokens: result.tokenUsage.output,
41300
41305
  cost_usd: costUsd
@@ -41319,7 +41324,7 @@ async function runFullPipeline(options) {
41319
41324
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
41320
41325
  await addTokenUsage(adapter, runId, {
41321
41326
  phase: "planning",
41322
- agent: "claude-code",
41327
+ agent: agentId ?? "claude-code",
41323
41328
  input_tokens: result.tokenUsage.input,
41324
41329
  output_tokens: result.tokenUsage.output,
41325
41330
  cost_usd: costUsd
@@ -41347,7 +41352,7 @@ async function runFullPipeline(options) {
41347
41352
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
41348
41353
  await addTokenUsage(adapter, runId, {
41349
41354
  phase: "research",
41350
- agent: "claude-code",
41355
+ agent: agentId ?? "claude-code",
41351
41356
  input_tokens: result.tokenUsage.input,
41352
41357
  output_tokens: result.tokenUsage.output,
41353
41358
  cost_usd: costUsd
@@ -41372,7 +41377,7 @@ async function runFullPipeline(options) {
41372
41377
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
41373
41378
  await addTokenUsage(adapter, runId, {
41374
41379
  phase: "ux-design",
41375
- agent: "claude-code",
41380
+ agent: agentId ?? "claude-code",
41376
41381
  input_tokens: result.tokenUsage.input,
41377
41382
  output_tokens: result.tokenUsage.output,
41378
41383
  cost_usd: costUsd
@@ -41397,7 +41402,7 @@ async function runFullPipeline(options) {
41397
41402
  const costUsd = (result.tokenUsage.input * 3 + result.tokenUsage.output * 15) / 1e6;
41398
41403
  await addTokenUsage(adapter, runId, {
41399
41404
  phase: "solutioning",
41400
- agent: "claude-code",
41405
+ agent: agentId ?? "claude-code",
41401
41406
  input_tokens: result.tokenUsage.input,
41402
41407
  output_tokens: result.tokenUsage.output,
41403
41408
  cost_usd: costUsd
@@ -41456,6 +41461,7 @@ async function runFullPipeline(options) {
41456
41461
  },
41457
41462
  projectRoot,
41458
41463
  tokenCeilings,
41464
+ agentId,
41459
41465
  ...fpIngestionServer !== void 0 ? { ingestionServer: fpIngestionServer } : {},
41460
41466
  ...fpTelemetryPersistence !== void 0 ? { telemetryPersistence: fpTelemetryPersistence } : {}
41461
41467
  });
@@ -41467,7 +41473,7 @@ async function runFullPipeline(options) {
41467
41473
  const costUsd = (input * 3 + output * 15) / 1e6;
41468
41474
  addTokenUsage(adapter, runId, {
41469
41475
  phase: payload.phase,
41470
- agent: "claude-code",
41476
+ agent: agentId ?? "claude-code",
41471
41477
  input_tokens: input,
41472
41478
  output_tokens: output,
41473
41479
  cost_usd: costUsd
@@ -41588,7 +41594,7 @@ async function runFullPipeline(options) {
41588
41594
  }
41589
41595
  }
41590
41596
  function registerRunCommand(program, _version = "0.0.0", projectRoot = process.cwd(), registry) {
41591
- program.command("run").description("Run the autonomous pipeline (use --from to start from a specific phase)").option("--pack <name>", "Methodology pack name", "bmad").option("--from <phase>", "Start from this phase: analysis, planning, solutioning, implementation").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--concept <text>", "Inline concept text (required when --from analysis)").option("--concept-file <path>", "Path to a file containing the concept text").option("--stories <keys>", "Comma-separated story keys (e.g., 10-1,10-2)").option("--epic <n>", "Scope story discovery to a single epic number (e.g., 27)", (v) => parseInt(v, 10)).option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--verbose", "Show detailed pino log output").option("--help-agent", "Print a machine-optimized prompt fragment for AI agents and exit").option("--tui", "Show TUI dashboard").option("--skip-ux", "Skip the UX design phase even if enabled in the pack manifest").option("--research", "Enable the research phase even if not set in the pack manifest").option("--skip-research", "Skip the research phase even if enabled in the pack manifest").option("--skip-preflight", "Skip the pre-flight build check (escape hatch for known-broken projects)").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).option("--dry-run", "Preview routing and repo-map injection without dispatching (Story 28-9)").option("--engine <type>", "Execution engine: linear (default) or graph").action(async (opts) => {
41597
+ program.command("run").description("Run the autonomous pipeline (use --from to start from a specific phase)").option("--pack <name>", "Methodology pack name", "bmad").option("--from <phase>", "Start from this phase: analysis, planning, solutioning, implementation").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--concept <text>", "Inline concept text (required when --from analysis)").option("--concept-file <path>", "Path to a file containing the concept text").option("--stories <keys>", "Comma-separated story keys (e.g., 10-1,10-2)").option("--epic <n>", "Scope story discovery to a single epic number (e.g., 27)", (v) => parseInt(v, 10)).option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--verbose", "Show detailed pino log output").option("--help-agent", "Print a machine-optimized prompt fragment for AI agents and exit").option("--tui", "Show TUI dashboard").option("--skip-ux", "Skip the UX design phase even if enabled in the pack manifest").option("--research", "Enable the research phase even if not set in the pack manifest").option("--skip-research", "Skip the research phase even if enabled in the pack manifest").option("--skip-preflight", "Skip the pre-flight build check (escape hatch for known-broken projects)").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).option("--dry-run", "Preview routing and repo-map injection without dispatching (Story 28-9)").option("--engine <type>", "Execution engine: linear (default) or graph").option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").action(async (opts) => {
41592
41598
  if (opts.helpAgent) {
41593
41599
  process.exitCode = await runHelpAgent();
41594
41600
  return;
@@ -41626,6 +41632,7 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
41626
41632
  maxReviewCycles: opts.maxReviewCycles,
41627
41633
  dryRun: opts.dryRun,
41628
41634
  engine: opts.engine,
41635
+ agent: opts.agent,
41629
41636
  registry
41630
41637
  });
41631
41638
  process.exitCode = exitCode;
@@ -41634,4 +41641,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
41634
41641
 
41635
41642
  //#endregion
41636
41643
  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 };
41637
- //# sourceMappingURL=run-NJQHRIYt.js.map
41644
+ //# sourceMappingURL=run-BLxcApKZ.js.map
@@ -2,7 +2,7 @@ import "./health-DJgGZhW-.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
4
  import "./dist-adzGUKPc.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, runRunAction } from "./run-NJQHRIYt.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, runRunAction } from "./run-BLxcApKZ.js";
6
6
  import "./routing-CcBOCuC9.js";
7
7
  import "./decisions-C0pz9Clx.js";
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.19.10",
3
+ "version": "0.19.11",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",