@wrongstack/cli 0.24.0 → 0.31.1
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/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as path24 from 'path';
|
|
3
3
|
import * as fsp3 from 'fs/promises';
|
|
4
|
-
import { color, DefaultPathResolver, TOKENS, DefaultSystemPromptBuilder, makeAutonomyPromptContributor, ToolRegistry, createContextManagerTool, EventBus, SlashCommandRegistry, createDelegateTool, FLEET_ROSTER, createMcpControlTool, EternalAutonomyEngine, DefaultLogger, DefaultModelsRegistry, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, ProviderRegistry, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, loadPlan, createDefaultPipelines, AutoCompactionMiddleware,
|
|
4
|
+
import { color, DefaultPathResolver, TOKENS, DefaultSystemPromptBuilder, makeAutonomyPromptContributor, ToolRegistry, createContextManagerTool, EventBus, SlashCommandRegistry, createDelegateTool, FLEET_ROSTER, createMcpControlTool, EternalAutonomyEngine, DefaultLogger, DefaultModelsRegistry, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, ProviderRegistry, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, loadPlan, createDefaultPipelines, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, loadPlugins, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, resolveWstackPaths, DefaultSecretVault, migratePlaintextSecrets, DefaultConfigLoader, DefaultSessionReader, ToolAuditLog, DefaultSessionRewinder, DefaultSessionStore, atomicWrite, DefaultPluginAPI, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, repairToolUseAdjacency, getContextWindowMode, resolveContextWindowPolicy, AGENTS_BY_PHASE, dispatchAgent, formatTodosList, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, DefaultTaskStore, TaskTracker, renderProgress, renderTaskGraph, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, emptyGoal, buildGoalPreamble, formatGoal, pendingBtwCount, setBtwNote, decryptConfigSecrets, encryptConfigSecrets as encryptConfigSecrets$1, InputBuilder, FsError, ERROR_CODES, SpecVersioning, ParallelEternalEngine, allServers as allServers$1 } from '@wrongstack/core';
|
|
5
5
|
import { createRequire } from 'module';
|
|
6
6
|
import * as os3 from 'os';
|
|
7
7
|
import os3__default from 'os';
|
|
@@ -10420,6 +10420,13 @@ async function runRepl(opts) {
|
|
|
10420
10420
|
activeCtrl = runCtrl2;
|
|
10421
10421
|
try {
|
|
10422
10422
|
const runResult = await opts.agent.run(runBlocks, { signal: runCtrl2.signal });
|
|
10423
|
+
opts.onAgentIterationComplete?.(
|
|
10424
|
+
estimateRequestTokensCalibrated(
|
|
10425
|
+
opts.agent.ctx.messages,
|
|
10426
|
+
opts.agent.ctx.systemPrompt,
|
|
10427
|
+
opts.agent.ctx.tools ?? []
|
|
10428
|
+
).total
|
|
10429
|
+
);
|
|
10423
10430
|
if (runResult.status === "done" && runResult.finalText) {
|
|
10424
10431
|
const specSaved = await trySaveSpecFromAIOutput(runResult.finalText);
|
|
10425
10432
|
if (specSaved) {
|
|
@@ -10549,6 +10556,13 @@ ${taskList}`;
|
|
|
10549
10556
|
);
|
|
10550
10557
|
}
|
|
10551
10558
|
const result = await opts.agent.run(routed.blocks, { signal: runCtrl.signal });
|
|
10559
|
+
opts.onAgentIterationComplete?.(
|
|
10560
|
+
estimateRequestTokensCalibrated(
|
|
10561
|
+
opts.agent.ctx.messages,
|
|
10562
|
+
opts.agent.ctx.systemPrompt,
|
|
10563
|
+
opts.agent.ctx.tools ?? []
|
|
10564
|
+
).total
|
|
10565
|
+
);
|
|
10552
10566
|
if (result.status === "aborted") {
|
|
10553
10567
|
opts.renderer.writeWarning("Aborted.");
|
|
10554
10568
|
} else if (result.status === "failed") {
|
|
@@ -10647,6 +10661,13 @@ ${color.dim(
|
|
|
10647
10661
|
activeCtrl = nextCtrl;
|
|
10648
10662
|
try {
|
|
10649
10663
|
const nextResult = await opts.agent.run(nextBlocks, { signal: nextCtrl.signal });
|
|
10664
|
+
opts.onAgentIterationComplete?.(
|
|
10665
|
+
estimateRequestTokensCalibrated(
|
|
10666
|
+
opts.agent.ctx.messages,
|
|
10667
|
+
opts.agent.ctx.systemPrompt,
|
|
10668
|
+
opts.agent.ctx.tools ?? []
|
|
10669
|
+
).total
|
|
10670
|
+
);
|
|
10650
10671
|
if (nextResult.status === "done" && nextResult.finalText?.trim() === "DONE") {
|
|
10651
10672
|
opts.renderer.write(color.dim("\n \u21B3 [autonomy] agent reports task complete.\n"));
|
|
10652
10673
|
}
|
|
@@ -10666,6 +10687,13 @@ ${color.dim(
|
|
|
10666
10687
|
activeCtrl = suggestCtrl;
|
|
10667
10688
|
try {
|
|
10668
10689
|
const suggestResult = await opts.agent.run(suggestBlocks, { signal: suggestCtrl.signal });
|
|
10690
|
+
opts.onAgentIterationComplete?.(
|
|
10691
|
+
estimateRequestTokensCalibrated(
|
|
10692
|
+
opts.agent.ctx.messages,
|
|
10693
|
+
opts.agent.ctx.systemPrompt,
|
|
10694
|
+
opts.agent.ctx.tools ?? []
|
|
10695
|
+
).total
|
|
10696
|
+
);
|
|
10669
10697
|
if (suggestResult.status === "done" && suggestResult.finalText) {
|
|
10670
10698
|
opts.renderer.write(
|
|
10671
10699
|
`
|
|
@@ -11196,7 +11224,10 @@ async function execute(deps) {
|
|
|
11196
11224
|
getParallelEngine,
|
|
11197
11225
|
skillLoader,
|
|
11198
11226
|
agentsMonitorController,
|
|
11199
|
-
fleetStreamController
|
|
11227
|
+
fleetStreamController,
|
|
11228
|
+
// Report context pressure to the Director after each iteration so
|
|
11229
|
+
// the spawn pre-check (maxLeaderContextLoad) stays accurate.
|
|
11230
|
+
onAgentIterationComplete: director ? (tokens) => director.setLeaderContextPressure(tokens) : void 0
|
|
11200
11231
|
});
|
|
11201
11232
|
} finally {
|
|
11202
11233
|
await webuiPromise.catch(() => void 0);
|
|
@@ -11220,7 +11251,8 @@ async function execute(deps) {
|
|
|
11220
11251
|
getParallelEngine,
|
|
11221
11252
|
skillLoader,
|
|
11222
11253
|
agentsMonitorController,
|
|
11223
|
-
fleetStreamController
|
|
11254
|
+
fleetStreamController,
|
|
11255
|
+
onAgentIterationComplete: director ? (tokens) => director.setLeaderContextPressure(tokens) : void 0
|
|
11224
11256
|
});
|
|
11225
11257
|
}
|
|
11226
11258
|
} finally {
|
|
@@ -12398,9 +12430,9 @@ async function setupCompaction(params) {
|
|
|
12398
12430
|
autoCompactor = new AutoCompactionMiddleware(
|
|
12399
12431
|
compactor,
|
|
12400
12432
|
effectiveMaxContext,
|
|
12401
|
-
//
|
|
12402
|
-
//
|
|
12403
|
-
(ctx) =>
|
|
12433
|
+
// Calibrated estimator: recordActualUsage() is called after each API
|
|
12434
|
+
// response so this converges on real token counts for compaction decisions.
|
|
12435
|
+
(ctx) => estimateRequestTokensCalibrated(ctx.messages, ctx.systemPrompt, ctx.tools ?? []).total,
|
|
12404
12436
|
{
|
|
12405
12437
|
warn: config.context.warnThreshold,
|
|
12406
12438
|
soft: config.context.softThreshold,
|