substrate-ai 0.4.8 → 0.4.10
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, TelemetryPersistence, VALID_PHASES, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDispatcher, createDoltClient, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initializeDolt, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runMigrations, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-
|
|
2
|
+
import { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, TelemetryPersistence, VALID_PHASES, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDispatcher, createDoltClient, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initializeDolt, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runMigrations, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BErnJT9a.js";
|
|
3
3
|
import { createLogger } from "../logger-D2fS2ccL.js";
|
|
4
4
|
import { AdapterRegistry } from "../adapter-registry-Cd-7lG5v.js";
|
|
5
5
|
import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
|
|
@@ -2709,7 +2709,7 @@ async function runSupervisorAction(options, deps = {}) {
|
|
|
2709
2709
|
const expDb = expDbWrapper.db;
|
|
2710
2710
|
const { runRunAction: runPipeline } = await import(
|
|
2711
2711
|
/* @vite-ignore */
|
|
2712
|
-
"../run-
|
|
2712
|
+
"../run-BbdWeKiB.js"
|
|
2713
2713
|
);
|
|
2714
2714
|
const runStoryFn = async (opts) => {
|
|
2715
2715
|
const exitCode = await runPipeline({
|
package/dist/index.d.ts
CHANGED
|
@@ -551,6 +551,24 @@ interface PipelineContractVerificationSummaryEvent {
|
|
|
551
551
|
/** 'pass' if zero mismatches, 'fail' otherwise */
|
|
552
552
|
verdict: 'pass' | 'fail';
|
|
553
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Emitted when the RoutingResolver selects a model for a dispatch.
|
|
556
|
+
*/
|
|
557
|
+
interface RoutingModelSelectedEvent {
|
|
558
|
+
type: 'routing:model-selected';
|
|
559
|
+
/** ISO-8601 timestamp generated at emit time */
|
|
560
|
+
ts: string;
|
|
561
|
+
/** Unique dispatch ID */
|
|
562
|
+
dispatch_id: string;
|
|
563
|
+
/** Task type (e.g. 'dev-story', 'test-plan', 'code-review') */
|
|
564
|
+
task_type: string;
|
|
565
|
+
/** Routing phase that matched (e.g. 'generate', 'explore', 'review') */
|
|
566
|
+
phase: string;
|
|
567
|
+
/** Selected model ID */
|
|
568
|
+
model: string;
|
|
569
|
+
/** How the model was selected: 'phase', 'baseline', 'override' */
|
|
570
|
+
source: string;
|
|
571
|
+
}
|
|
554
572
|
/**
|
|
555
573
|
* Discriminated union of all pipeline event types.
|
|
556
574
|
*
|
|
@@ -563,7 +581,7 @@ interface PipelineContractVerificationSummaryEvent {
|
|
|
563
581
|
* }
|
|
564
582
|
* ```
|
|
565
583
|
*/
|
|
566
|
-
type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | PipelinePreFlightFailureEvent | 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; //#endregion
|
|
584
|
+
type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | PipelinePreFlightFailureEvent | 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; //#endregion
|
|
567
585
|
//#region src/core/errors.d.ts
|
|
568
586
|
|
|
569
587
|
/**
|
|
@@ -2810,6 +2810,43 @@ const PIPELINE_EVENT_METADATA = [
|
|
|
2810
2810
|
}
|
|
2811
2811
|
]
|
|
2812
2812
|
},
|
|
2813
|
+
{
|
|
2814
|
+
type: "routing:model-selected",
|
|
2815
|
+
description: "Model routing resolver selected a model for a dispatch.",
|
|
2816
|
+
when: "When a story dispatch uses model routing and the resolver returns a non-null model.",
|
|
2817
|
+
fields: [
|
|
2818
|
+
{
|
|
2819
|
+
name: "ts",
|
|
2820
|
+
type: "string",
|
|
2821
|
+
description: "Timestamp."
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
name: "dispatch_id",
|
|
2825
|
+
type: "string",
|
|
2826
|
+
description: "Unique dispatch ID."
|
|
2827
|
+
},
|
|
2828
|
+
{
|
|
2829
|
+
name: "task_type",
|
|
2830
|
+
type: "string",
|
|
2831
|
+
description: "Task type (dev-story, test-plan, code-review)."
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
name: "phase",
|
|
2835
|
+
type: "string",
|
|
2836
|
+
description: "Routing phase that matched (generate, explore, review)."
|
|
2837
|
+
},
|
|
2838
|
+
{
|
|
2839
|
+
name: "model",
|
|
2840
|
+
type: "string",
|
|
2841
|
+
description: "Selected model ID."
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
name: "source",
|
|
2845
|
+
type: "string",
|
|
2846
|
+
description: "How selected: phase, baseline, or override."
|
|
2847
|
+
}
|
|
2848
|
+
]
|
|
2849
|
+
},
|
|
2813
2850
|
{
|
|
2814
2851
|
type: "pipeline:pre-flight-failure",
|
|
2815
2852
|
description: "Pre-flight build check failed before any story was dispatched. Pipeline aborts immediately.",
|
|
@@ -3273,6 +3310,9 @@ Patterns for \`substrate supervisor --output-format json\` events:
|
|
|
3273
3310
|
|
|
3274
3311
|
### On \`supervisor:experiment:error\`
|
|
3275
3312
|
- Report error. Suggest running without \`--experiment\` for a clean run.
|
|
3313
|
+
|
|
3314
|
+
### On \`routing:model-selected\`
|
|
3315
|
+
- Informational. Log which model was selected for the dispatch and why (phase config, baseline, or override).
|
|
3276
3316
|
`;
|
|
3277
3317
|
}
|
|
3278
3318
|
/**
|
|
@@ -12528,11 +12568,15 @@ var EfficiencyScorer = class {
|
|
|
12528
12568
|
return sum / turns.length;
|
|
12529
12569
|
}
|
|
12530
12570
|
/**
|
|
12531
|
-
* Average I/O ratio:
|
|
12571
|
+
* Average I/O ratio: totalInput / max(outputTokens, 1) per turn.
|
|
12572
|
+
* Total input = inputTokens (fresh) + cacheReadTokens (cached).
|
|
12532
12573
|
*/
|
|
12533
12574
|
_computeAvgIoRatio(turns) {
|
|
12534
12575
|
if (turns.length === 0) return 0;
|
|
12535
|
-
const sum = turns.reduce((acc, t) =>
|
|
12576
|
+
const sum = turns.reduce((acc, t) => {
|
|
12577
|
+
const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
|
|
12578
|
+
return acc + totalInput / Math.max(t.outputTokens, 1);
|
|
12579
|
+
}, 0);
|
|
12536
12580
|
return sum / turns.length;
|
|
12537
12581
|
}
|
|
12538
12582
|
/**
|
|
@@ -12550,7 +12594,10 @@ var EfficiencyScorer = class {
|
|
|
12550
12594
|
const result = [];
|
|
12551
12595
|
for (const [model, groupTurns] of groups) {
|
|
12552
12596
|
const cacheHitRate = groupTurns.reduce((acc, t) => acc + t.cacheHitRate, 0) / groupTurns.length;
|
|
12553
|
-
const avgIoRatio = groupTurns.reduce((acc, t) =>
|
|
12597
|
+
const avgIoRatio = groupTurns.reduce((acc, t) => {
|
|
12598
|
+
const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
|
|
12599
|
+
return acc + totalInput / Math.max(t.outputTokens, 1);
|
|
12600
|
+
}, 0) / groupTurns.length;
|
|
12554
12601
|
const totalCostUsd = groupTurns.reduce((acc, t) => acc + t.costUsd, 0);
|
|
12555
12602
|
const totalOutputTokens = groupTurns.reduce((acc, t) => acc + t.outputTokens, 0);
|
|
12556
12603
|
const costPer1KOutputTokens = totalCostUsd / Math.max(totalOutputTokens, 1) * 1e3;
|
|
@@ -12597,7 +12644,10 @@ var EfficiencyScorer = class {
|
|
|
12597
12644
|
}
|
|
12598
12645
|
_computeIoRatioSubScoreForGroup(turns) {
|
|
12599
12646
|
if (turns.length === 0) return 0;
|
|
12600
|
-
const avg = turns.reduce((acc, t) =>
|
|
12647
|
+
const avg = turns.reduce((acc, t) => {
|
|
12648
|
+
const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
|
|
12649
|
+
return acc + totalInput / Math.max(t.outputTokens, 1);
|
|
12650
|
+
}, 0) / turns.length;
|
|
12601
12651
|
return this._clamp(100 - (avg - 1) * 20, 0, 100);
|
|
12602
12652
|
}
|
|
12603
12653
|
_computeContextManagementSubScoreForGroup(turns) {
|
|
@@ -12628,7 +12678,9 @@ const EXACT_CATEGORY_MAP = new Map([
|
|
|
12628
12678
|
["list_files", "file_reads"],
|
|
12629
12679
|
["run_command", "tool_outputs"],
|
|
12630
12680
|
["memory_read", "system_prompts"],
|
|
12631
|
-
["web_fetch", "tool_outputs"]
|
|
12681
|
+
["web_fetch", "tool_outputs"],
|
|
12682
|
+
["api_request", "conversation_history"],
|
|
12683
|
+
["tool_decision", "tool_outputs"]
|
|
12632
12684
|
]);
|
|
12633
12685
|
const PREFIX_PATTERNS = [
|
|
12634
12686
|
{
|
|
@@ -13441,9 +13493,10 @@ var LogTurnAnalyzer = class {
|
|
|
13441
13493
|
let runningContext = 0;
|
|
13442
13494
|
const turns = merged.map(({ representative: log$2, inputTokens, outputTokens, cacheReadTokens, costUsd }, idx) => {
|
|
13443
13495
|
const prevContext = runningContext;
|
|
13444
|
-
runningContext += inputTokens;
|
|
13496
|
+
runningContext += inputTokens + cacheReadTokens;
|
|
13445
13497
|
const freshTokens = inputTokens - cacheReadTokens;
|
|
13446
|
-
const
|
|
13498
|
+
const totalInput = inputTokens + cacheReadTokens;
|
|
13499
|
+
const cacheHitRate = totalInput > 0 ? cacheReadTokens / totalInput : 0;
|
|
13447
13500
|
return {
|
|
13448
13501
|
spanId: log$2.spanId ?? log$2.logId,
|
|
13449
13502
|
turnNumber: idx + 1,
|
|
@@ -21548,4 +21601,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
|
|
|
21548
21601
|
|
|
21549
21602
|
//#endregion
|
|
21550
21603
|
export { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, TelemetryPersistence, VALID_PHASES, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDispatcher, createDoltClient, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initializeDolt, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runMigrations, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
|
|
21551
|
-
//# sourceMappingURL=run-
|
|
21604
|
+
//# sourceMappingURL=run-BErnJT9a.js.map
|