@wrongstack/core 0.5.5 → 0.5.7
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/{agent-bridge-B07AYFBk.d.ts → agent-bridge-BKNiE1VH.d.ts} +1 -1
- package/dist/{compactor-BWhJXxsW.d.ts → compactor-RIPuTtWK.d.ts} +1 -1
- package/dist/{config-BgM0BIpz.d.ts → config-BGGuP_Ar.d.ts} +1 -1
- package/dist/{context-CLZXPPYk.d.ts → context-CDRyrkKQ.d.ts} +7 -0
- package/dist/coordination/index.d.ts +10 -9
- package/dist/coordination/index.js +558 -61
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +19 -18
- package/dist/defaults/index.js +521 -64
- package/dist/defaults/index.js.map +1 -1
- package/dist/director-state-BmYi3DGA.d.ts +108 -0
- package/dist/{events-qnDZbrtb.d.ts → events-DPQKFX7W.d.ts} +1 -1
- package/dist/execution/index.d.ts +18 -11
- package/dist/execution/index.js +19 -3
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{index-De4R4rQ7.d.ts → index-Bf9Bpkdc.d.ts} +452 -9
- package/dist/{index-DPLJw_ZI.d.ts → index-j2WyAyML.d.ts} +20 -5
- package/dist/index.d.ts +108 -27
- package/dist/index.js +819 -90
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +9 -9
- package/dist/{mcp-servers-CSMfaBuL.d.ts → mcp-servers-DBdh3cee.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/{multi-agent-Cv8wk47i.d.ts → multi-agent-Cpp7FXUl.d.ts} +11 -3
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-DiCUvEg6.d.ts → path-resolver--g_hKJ7V.d.ts} +2 -2
- package/dist/{director-state-BUxlqkOa.d.ts → plan-templates-Bveo2W8n.d.ts} +37 -76
- package/dist/{provider-runner-3SHqk9zB.d.ts → provider-runner-hl4Il3xS.d.ts} +3 -3
- package/dist/{retry-policy-LLUxJmYY.d.ts → retry-policy-LKS8MHsB.d.ts} +1 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/{secret-scrubber-Z_VXuXQT.d.ts → secret-scrubber-BzQR5BiL.d.ts} +1 -1
- package/dist/{secret-scrubber-BhJTNr9v.d.ts → secret-scrubber-CfMdAJ_l.d.ts} +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/{selector-DB2-byKH.d.ts → selector-C7HqnZJU.d.ts} +1 -1
- package/dist/{session-reader-4jxsYLZ8.d.ts → session-reader-CzfRA6Vk.d.ts} +1 -1
- package/dist/storage/index.d.ts +6 -5
- package/dist/storage/index.js +206 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/{system-prompt-DI4Dtc1I.d.ts → system-prompt-Dl2QY1_B.d.ts} +1 -1
- package/dist/{tool-executor-DSvmOBe6.d.ts → tool-executor-DbAFkHdP.d.ts} +4 -4
- package/dist/types/index.d.ts +15 -15
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Director state checkpoint — written incrementally throughout a fleet
|
|
3
|
+
* run so a crashed director can be inspected (and eventually resumed)
|
|
4
|
+
* instead of leaving only a final `fleet.json` manifest after `shutdown()`.
|
|
5
|
+
*
|
|
6
|
+
* Schema is JSON-friendly and deliberately denormalized. Each mutation
|
|
7
|
+
* triggers an atomic-write of the whole file — small payloads (typically
|
|
8
|
+
* < 10 KB even with dozens of subagents) make this cheap.
|
|
9
|
+
*/
|
|
10
|
+
interface DirectorSubagentState {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
role?: string;
|
|
14
|
+
provider?: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
spawnedAt: string;
|
|
17
|
+
}
|
|
18
|
+
interface DirectorTaskState {
|
|
19
|
+
taskId: string;
|
|
20
|
+
subagentId?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped' | 'timeout';
|
|
23
|
+
assignedAt?: string;
|
|
24
|
+
completedAt?: string;
|
|
25
|
+
iterations?: number;
|
|
26
|
+
toolCalls?: number;
|
|
27
|
+
durationMs?: number;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
interface DirectorStateSnapshot {
|
|
31
|
+
version: 1;
|
|
32
|
+
directorRunId: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
spawnCount: number;
|
|
35
|
+
maxSpawns?: number;
|
|
36
|
+
spawnDepth: number;
|
|
37
|
+
maxSpawnDepth: number;
|
|
38
|
+
directorBudget?: {
|
|
39
|
+
maxCostUsd?: number;
|
|
40
|
+
};
|
|
41
|
+
subagents: DirectorSubagentState[];
|
|
42
|
+
tasks: DirectorTaskState[];
|
|
43
|
+
/** Aggregated usage snapshot. Optional — populated by the Director on save when available. */
|
|
44
|
+
usage?: unknown;
|
|
45
|
+
}
|
|
46
|
+
declare function loadDirectorState(filePath: string): Promise<DirectorStateSnapshot | null>;
|
|
47
|
+
/**
|
|
48
|
+
* In-memory accumulator with atomic-write checkpoint. The Director keeps
|
|
49
|
+
* an instance, mutates it on every spawn/assign/complete/fail event, and
|
|
50
|
+
* the instance debounces writes so a burst of activity collapses into a
|
|
51
|
+
* single disk hit.
|
|
52
|
+
*
|
|
53
|
+
* Supports crash recovery: use `loadDirectorState()` to read an existing
|
|
54
|
+
* checkpoint, then call `DirectorStateCheckpoint.resume(snapshot)` to
|
|
55
|
+
* re-attach to a fleet mid-flight. The lock mechanism ensures no two
|
|
56
|
+
* directors can claim the same checkpoint.
|
|
57
|
+
*/
|
|
58
|
+
declare class DirectorStateCheckpoint {
|
|
59
|
+
private snapshot;
|
|
60
|
+
private readonly filePath;
|
|
61
|
+
private readonly lockPath;
|
|
62
|
+
private timer;
|
|
63
|
+
private readonly debounceMs;
|
|
64
|
+
private writing;
|
|
65
|
+
private rewriteRequested;
|
|
66
|
+
constructor(filePath: string, init: {
|
|
67
|
+
directorRunId: string;
|
|
68
|
+
maxSpawns?: number;
|
|
69
|
+
spawnDepth: number;
|
|
70
|
+
maxSpawnDepth: number;
|
|
71
|
+
directorBudget?: {
|
|
72
|
+
maxCostUsd?: number;
|
|
73
|
+
};
|
|
74
|
+
}, debounceMs?: number);
|
|
75
|
+
/**
|
|
76
|
+
* Attempt to acquire the lock for this checkpoint. Call this before
|
|
77
|
+
* resuming a crashed director run. If it returns false, another
|
|
78
|
+
* director process is still running this fleet — do not resume.
|
|
79
|
+
*/
|
|
80
|
+
acquireLock(): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Release the lock on graceful shutdown. Call `flush()` first to ensure
|
|
83
|
+
* the final checkpoint state is on disk before removing the lock.
|
|
84
|
+
* Without this, the next resume will see a stale-lock and refuse.
|
|
85
|
+
*/
|
|
86
|
+
releaseLock(): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Resume from a snapshot previously loaded via `loadDirectorState()`.
|
|
89
|
+
* Use this when `--resume <runId>` is triggered — the snapshot has
|
|
90
|
+
* the full fleet state (subagents, tasks) from before the crash; the
|
|
91
|
+
* checkpoint continues from there.
|
|
92
|
+
*/
|
|
93
|
+
resume(snapshot: DirectorStateSnapshot): void;
|
|
94
|
+
current(): DirectorStateSnapshot;
|
|
95
|
+
recordSpawn(sub: DirectorSubagentState, spawnCount: number): void;
|
|
96
|
+
recordTaskAssigned(task: DirectorTaskState): void;
|
|
97
|
+
recordTaskStatus(taskId: string, patch: Partial<DirectorTaskState> & {
|
|
98
|
+
status: DirectorTaskState['status'];
|
|
99
|
+
}): void;
|
|
100
|
+
setUsage(usage: unknown): void;
|
|
101
|
+
/** Force a synchronous flush — used by Director.shutdown(). */
|
|
102
|
+
flush(): Promise<void>;
|
|
103
|
+
private bumpUpdatedAt;
|
|
104
|
+
private schedule;
|
|
105
|
+
private persist;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { DirectorStateCheckpoint as D, type DirectorStateSnapshot as a, type DirectorSubagentState as b, type DirectorTaskState as c, loadDirectorState as l };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-
|
|
2
|
-
import { g as Provider, a2 as Context } from '../context-
|
|
3
|
-
import { a as Compactor, C as CompactReport } from '../compactor-
|
|
4
|
-
import { M as MessageSelector } from '../selector-
|
|
5
|
-
import { E as EventBus } from '../events-
|
|
6
|
-
import { c as MiddlewareHandler } from '../system-prompt-
|
|
7
|
-
import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-
|
|
8
|
-
import { r as Agent, R as RunResult } from '../index-
|
|
9
|
-
import { D as DoneCondition } from '../multi-agent-
|
|
1
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-DbAFkHdP.js';
|
|
2
|
+
import { g as Provider, a2 as Context } from '../context-CDRyrkKQ.js';
|
|
3
|
+
import { a as Compactor, C as CompactReport } from '../compactor-RIPuTtWK.js';
|
|
4
|
+
import { M as MessageSelector } from '../selector-C7HqnZJU.js';
|
|
5
|
+
import { E as EventBus } from '../events-DPQKFX7W.js';
|
|
6
|
+
import { c as MiddlewareHandler } from '../system-prompt-Dl2QY1_B.js';
|
|
7
|
+
import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-BGGuP_Ar.js';
|
|
8
|
+
import { r as Agent, R as RunResult } from '../index-j2WyAyML.js';
|
|
9
|
+
import { D as DoneCondition } from '../multi-agent-Cpp7FXUl.js';
|
|
10
10
|
import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-CxuWrsKK.js';
|
|
11
11
|
import { W as WstackPaths } from '../wstack-paths-86YPFktR.js';
|
|
12
|
-
import '../retry-policy-
|
|
12
|
+
import '../retry-policy-LKS8MHsB.js';
|
|
13
13
|
import '../models-registry-Y2xbog0E.js';
|
|
14
14
|
import '../logger-BMQgxvdy.js';
|
|
15
15
|
import '../observability-BhnVLBLS.js';
|
|
16
|
-
import '../secret-scrubber-
|
|
16
|
+
import '../secret-scrubber-CfMdAJ_l.js';
|
|
17
17
|
|
|
18
18
|
interface SkillLoaderOptions {
|
|
19
19
|
paths: WstackPaths;
|
|
@@ -252,6 +252,13 @@ interface AutonomousRunnerOptions {
|
|
|
252
252
|
toolCalls: number;
|
|
253
253
|
}) => void;
|
|
254
254
|
onDone?: (result: AutonomousResult) => void;
|
|
255
|
+
/**
|
|
256
|
+
* When true and `doneCondition.type === 'directive'`, the runner
|
|
257
|
+
* runs the agent with `autonomousContinue: true` so the agent loop
|
|
258
|
+
* handles its own [continue]/[done] markers internally (no outer
|
|
259
|
+
* re-invocation needed). The runner still provides iteration/timeouts.
|
|
260
|
+
*/
|
|
261
|
+
enableAutonomousContinue?: boolean;
|
|
255
262
|
}
|
|
256
263
|
declare class AutonomousRunner {
|
|
257
264
|
private readonly opts;
|
package/dist/execution/index.js
CHANGED
|
@@ -1414,6 +1414,14 @@ var DoneConditionChecker = class {
|
|
|
1414
1414
|
};
|
|
1415
1415
|
}
|
|
1416
1416
|
break;
|
|
1417
|
+
case "directive":
|
|
1418
|
+
if (this.condition.maxIterations && state.iterations >= this.condition.maxIterations) {
|
|
1419
|
+
return { done: true, reason: `max iterations (${this.condition.maxIterations}) reached`, ...state };
|
|
1420
|
+
}
|
|
1421
|
+
if (this.condition.maxToolCalls && state.toolCalls >= this.condition.maxToolCalls) {
|
|
1422
|
+
return { done: true, reason: `max tool calls (${this.condition.maxToolCalls}) reached`, ...state };
|
|
1423
|
+
}
|
|
1424
|
+
break;
|
|
1417
1425
|
}
|
|
1418
1426
|
return { done: false, iterations: state.iterations, toolCalls: state.toolCalls };
|
|
1419
1427
|
}
|
|
@@ -1433,10 +1441,16 @@ var AutonomousRunner = class {
|
|
|
1433
1441
|
const offToolExecuted = this.opts.agent.events?.on?.("tool.executed", () => {
|
|
1434
1442
|
this.toolCalls++;
|
|
1435
1443
|
});
|
|
1444
|
+
const offIterationCompleted = this.opts.agent.events?.on?.("iteration.completed", () => {
|
|
1445
|
+
if (this.opts.enableAutonomousContinue && this.opts.doneCondition.type === "directive") {
|
|
1446
|
+
this.iterations++;
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1436
1449
|
try {
|
|
1437
1450
|
return await this.runLoop();
|
|
1438
1451
|
} finally {
|
|
1439
1452
|
offToolExecuted?.();
|
|
1453
|
+
offIterationCompleted?.();
|
|
1440
1454
|
}
|
|
1441
1455
|
}
|
|
1442
1456
|
async runLoop() {
|
|
@@ -1460,12 +1474,14 @@ var AutonomousRunner = class {
|
|
|
1460
1474
|
const ctrl = new AbortController();
|
|
1461
1475
|
const timeout = setTimeout(() => ctrl.abort(), this.opts.iterationTimeoutMs ?? 3e4);
|
|
1462
1476
|
try {
|
|
1477
|
+
const isDirectiveMode = this.opts.doneCondition.type === "directive" && this.opts.enableAutonomousContinue;
|
|
1463
1478
|
const result = await this.opts.agent.run("", {
|
|
1464
1479
|
signal: ctrl.signal,
|
|
1465
|
-
maxIterations: 1,
|
|
1466
|
-
executionStrategy: "sequential"
|
|
1480
|
+
maxIterations: isDirectiveMode ? this.opts.doneCondition.maxIterations ?? 100 : 1,
|
|
1481
|
+
executionStrategy: "sequential",
|
|
1482
|
+
autonomousContinue: isDirectiveMode ? true : void 0
|
|
1467
1483
|
});
|
|
1468
|
-
this.iterations++;
|
|
1484
|
+
if (!isDirectiveMode) this.iterations++;
|
|
1469
1485
|
if (result.status === "done") {
|
|
1470
1486
|
this.lastOutput = result.finalText;
|
|
1471
1487
|
}
|