substrate-ai 0.5.8 → 0.5.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 { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-
|
|
2
|
+
import { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BWmiveTZ.js";
|
|
3
3
|
import { createLogger } from "../logger-D2fS2ccL.js";
|
|
4
4
|
import { AdapterRegistry } from "../adapter-registry-D2zdMwVu.js";
|
|
5
5
|
import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
|
|
@@ -2969,7 +2969,7 @@ async function runSupervisorAction(options, deps = {}) {
|
|
|
2969
2969
|
await initSchema(expAdapter);
|
|
2970
2970
|
const { runRunAction: runPipeline } = await import(
|
|
2971
2971
|
/* @vite-ignore */
|
|
2972
|
-
"../run-
|
|
2972
|
+
"../run-DZGdLF4h.js"
|
|
2973
2973
|
);
|
|
2974
2974
|
const runStoryFn = async (opts) => {
|
|
2975
2975
|
const exitCode = await runPipeline({
|
|
@@ -12680,6 +12680,20 @@ var AdapterTelemetryPersistence = class {
|
|
|
12680
12680
|
});
|
|
12681
12681
|
}
|
|
12682
12682
|
/**
|
|
12683
|
+
* Delete all telemetry data for a story across all 5 telemetry tables.
|
|
12684
|
+
* Used to purge stale data from prior runs before persisting new data.
|
|
12685
|
+
*/
|
|
12686
|
+
async purgeStoryTelemetry(storyKey) {
|
|
12687
|
+
await this._adapter.transaction(async (adapter) => {
|
|
12688
|
+
await adapter.query("DELETE FROM turn_analysis WHERE story_key = ?", [storyKey]);
|
|
12689
|
+
await adapter.query("DELETE FROM efficiency_scores WHERE story_key = ?", [storyKey]);
|
|
12690
|
+
await adapter.query("DELETE FROM recommendations WHERE story_key = ?", [storyKey]);
|
|
12691
|
+
await adapter.query("DELETE FROM category_stats WHERE story_key = ?", [storyKey]);
|
|
12692
|
+
await adapter.query("DELETE FROM consumer_stats WHERE story_key = ?", [storyKey]);
|
|
12693
|
+
});
|
|
12694
|
+
logger$9.debug({ storyKey }, "Purged stale telemetry data for story");
|
|
12695
|
+
}
|
|
12696
|
+
/**
|
|
12683
12697
|
* Record a named span with arbitrary attributes.
|
|
12684
12698
|
* Currently logs the span at debug level; no DB persistence.
|
|
12685
12699
|
*/
|
|
@@ -12749,6 +12763,9 @@ var TelemetryPersistence = class {
|
|
|
12749
12763
|
async getConsumerStats(storyKey) {
|
|
12750
12764
|
return this._impl.getConsumerStats(storyKey);
|
|
12751
12765
|
}
|
|
12766
|
+
async purgeStoryTelemetry(storyKey) {
|
|
12767
|
+
return this._impl.purgeStoryTelemetry(storyKey);
|
|
12768
|
+
}
|
|
12752
12769
|
/**
|
|
12753
12770
|
* Record a named span with arbitrary attributes.
|
|
12754
12771
|
* Currently logs the span at debug level; no DB persistence.
|
|
@@ -12903,8 +12920,6 @@ var IngestionServer = class {
|
|
|
12903
12920
|
_flushIntervalMs;
|
|
12904
12921
|
_buffer;
|
|
12905
12922
|
_pendingBatches = new Set();
|
|
12906
|
-
/** Map from storyKey → DispatchContext, tracking active dispatches. */
|
|
12907
|
-
_activeDispatches = new Map();
|
|
12908
12923
|
constructor(options = {}) {
|
|
12909
12924
|
this._port = options.port ?? 4318;
|
|
12910
12925
|
this._batchSize = options.batchSize ?? 100;
|
|
@@ -12922,32 +12937,6 @@ var IngestionServer = class {
|
|
|
12922
12937
|
}
|
|
12923
12938
|
this._initPipeline(pipeline);
|
|
12924
12939
|
}
|
|
12925
|
-
/**
|
|
12926
|
-
* Register an active dispatch context for a story.
|
|
12927
|
-
* All OTLP payloads received while this context is active will be stamped
|
|
12928
|
-
* with the dispatch context so per-phase analysis is possible.
|
|
12929
|
-
*
|
|
12930
|
-
* @param storyKey - The story key being dispatched
|
|
12931
|
-
* @param context - The dispatch context to associate with this story
|
|
12932
|
-
*/
|
|
12933
|
-
setActiveDispatch(storyKey, context) {
|
|
12934
|
-
this._activeDispatches.set(storyKey, context);
|
|
12935
|
-
logger$8.debug({
|
|
12936
|
-
storyKey,
|
|
12937
|
-
taskType: context.taskType,
|
|
12938
|
-
phase: context.phase
|
|
12939
|
-
}, "IngestionServer: active dispatch registered");
|
|
12940
|
-
}
|
|
12941
|
-
/**
|
|
12942
|
-
* Clear the active dispatch context for a story.
|
|
12943
|
-
* Should be called after the dispatch completes (success or failure).
|
|
12944
|
-
*
|
|
12945
|
-
* @param storyKey - The story key whose dispatch context should be cleared
|
|
12946
|
-
*/
|
|
12947
|
-
clearActiveDispatch(storyKey) {
|
|
12948
|
-
this._activeDispatches.delete(storyKey);
|
|
12949
|
-
logger$8.debug({ storyKey }, "IngestionServer: active dispatch cleared");
|
|
12950
|
-
}
|
|
12951
12940
|
_initPipeline(pipeline) {
|
|
12952
12941
|
this._buffer = new BatchBuffer({
|
|
12953
12942
|
batchSize: this._batchSize,
|
|
@@ -13098,13 +13087,11 @@ var IngestionServer = class {
|
|
|
13098
13087
|
const body = JSON.parse(bodyStr);
|
|
13099
13088
|
const source = detectSource(body);
|
|
13100
13089
|
const { storyKey, taskType, dispatchId } = this._extractSubstrateAttributes(body);
|
|
13101
|
-
|
|
13102
|
-
if (taskType !== void 0 && dispatchId !== void 0) dispatchContext = {
|
|
13090
|
+
const dispatchContext = taskType !== void 0 && dispatchId !== void 0 ? {
|
|
13103
13091
|
taskType,
|
|
13104
13092
|
phase: taskType,
|
|
13105
13093
|
dispatchId
|
|
13106
|
-
};
|
|
13107
|
-
else if (storyKey !== void 0) dispatchContext = this._activeDispatches.get(storyKey);
|
|
13094
|
+
} : void 0;
|
|
13108
13095
|
const payload = {
|
|
13109
13096
|
body,
|
|
13110
13097
|
source,
|
|
@@ -14852,6 +14839,8 @@ var TelemetryPipeline = class {
|
|
|
14852
14839
|
_efficiencyScorer;
|
|
14853
14840
|
_recommender;
|
|
14854
14841
|
_persistence;
|
|
14842
|
+
/** Stories that have had stale telemetry purged this pipeline lifetime. */
|
|
14843
|
+
_purgedStories = new Set();
|
|
14855
14844
|
constructor(deps) {
|
|
14856
14845
|
this._normalizer = deps.normalizer;
|
|
14857
14846
|
this._turnAnalyzer = deps.turnAnalyzer;
|
|
@@ -15091,6 +15080,13 @@ var TelemetryPipeline = class {
|
|
|
15091
15080
|
*/
|
|
15092
15081
|
async _persistStoryData(storyKey, data) {
|
|
15093
15082
|
const { turns, efficiencyScore, categoryStats, consumerStats, recommendations, dispatchScores } = data;
|
|
15083
|
+
if (!this._purgedStories.has(storyKey)) {
|
|
15084
|
+
this._purgedStories.add(storyKey);
|
|
15085
|
+
await this._persistence.purgeStoryTelemetry(storyKey).catch((err) => logger$7.warn({
|
|
15086
|
+
err,
|
|
15087
|
+
storyKey
|
|
15088
|
+
}, "Failed to purge stale telemetry — continuing with persist"));
|
|
15089
|
+
}
|
|
15094
15090
|
await Promise.all([
|
|
15095
15091
|
turns.length > 0 ? this._persistence.storeTurnAnalysis(storyKey, turns).catch((err) => logger$7.warn({
|
|
15096
15092
|
err,
|
|
@@ -22679,4 +22675,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
|
|
|
22679
22675
|
|
|
22680
22676
|
//#endregion
|
|
22681
22677
|
export { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
|
|
22682
|
-
//# sourceMappingURL=run-
|
|
22678
|
+
//# sourceMappingURL=run-BWmiveTZ.js.map
|