@wrongstack/core 0.5.6 → 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 +9 -9
- package/dist/coordination/index.js +301 -58
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +18 -18
- package/dist/defaults/index.js +124 -61
- package/dist/defaults/index.js.map +1 -1
- 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-BDnUCRvL.d.ts → index-Bf9Bpkdc.d.ts} +351 -15
- package/dist/{index-DPLJw_ZI.d.ts → index-j2WyAyML.d.ts} +20 -5
- package/dist/index.d.ts +107 -27
- package/dist/index.js +417 -84
- 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/{plan-templates-DaxTCPfk.d.ts → plan-templates-Bveo2W8n.d.ts} +4 -4
- 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 +5 -5
- 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
package/dist/index.js
CHANGED
|
@@ -3755,11 +3755,11 @@ function validateAgainstSchema(value, schema) {
|
|
|
3755
3755
|
walk2(value, schema, "", errors);
|
|
3756
3756
|
return { ok: errors.length === 0, errors };
|
|
3757
3757
|
}
|
|
3758
|
-
function walk2(value, schema,
|
|
3758
|
+
function walk2(value, schema, path25, errors) {
|
|
3759
3759
|
if (schema.enum !== void 0) {
|
|
3760
3760
|
if (!schema.enum.some((e) => deepEqual(e, value))) {
|
|
3761
3761
|
errors.push({
|
|
3762
|
-
path:
|
|
3762
|
+
path: path25 || "<root>",
|
|
3763
3763
|
message: `expected one of ${JSON.stringify(schema.enum)}, got ${JSON.stringify(value)}`
|
|
3764
3764
|
});
|
|
3765
3765
|
return;
|
|
@@ -3768,7 +3768,7 @@ function walk2(value, schema, path24, errors) {
|
|
|
3768
3768
|
if (typeof schema.type === "string") {
|
|
3769
3769
|
if (!checkType(value, schema.type)) {
|
|
3770
3770
|
errors.push({
|
|
3771
|
-
path:
|
|
3771
|
+
path: path25 || "<root>",
|
|
3772
3772
|
message: `expected ${schema.type}, got ${describeType(value)}`
|
|
3773
3773
|
});
|
|
3774
3774
|
return;
|
|
@@ -3778,19 +3778,19 @@ function walk2(value, schema, path24, errors) {
|
|
|
3778
3778
|
const obj = value;
|
|
3779
3779
|
for (const req of schema.required ?? []) {
|
|
3780
3780
|
if (!(req in obj)) {
|
|
3781
|
-
errors.push({ path: joinPath(
|
|
3781
|
+
errors.push({ path: joinPath(path25, req), message: "required property missing" });
|
|
3782
3782
|
}
|
|
3783
3783
|
}
|
|
3784
3784
|
if (schema.properties) {
|
|
3785
3785
|
for (const [key, subSchema] of Object.entries(schema.properties)) {
|
|
3786
3786
|
if (key in obj) {
|
|
3787
|
-
walk2(obj[key], subSchema, joinPath(
|
|
3787
|
+
walk2(obj[key], subSchema, joinPath(path25, key), errors);
|
|
3788
3788
|
}
|
|
3789
3789
|
}
|
|
3790
3790
|
}
|
|
3791
3791
|
}
|
|
3792
3792
|
if (schema.type === "array" && Array.isArray(value) && schema.items) {
|
|
3793
|
-
value.forEach((item, i) => walk2(item, schema.items, `${
|
|
3793
|
+
value.forEach((item, i) => walk2(item, schema.items, `${path25}[${i}]`, errors));
|
|
3794
3794
|
}
|
|
3795
3795
|
}
|
|
3796
3796
|
function checkType(value, type) {
|
|
@@ -7070,6 +7070,14 @@ var DoneConditionChecker = class {
|
|
|
7070
7070
|
};
|
|
7071
7071
|
}
|
|
7072
7072
|
break;
|
|
7073
|
+
case "directive":
|
|
7074
|
+
if (this.condition.maxIterations && state.iterations >= this.condition.maxIterations) {
|
|
7075
|
+
return { done: true, reason: `max iterations (${this.condition.maxIterations}) reached`, ...state };
|
|
7076
|
+
}
|
|
7077
|
+
if (this.condition.maxToolCalls && state.toolCalls >= this.condition.maxToolCalls) {
|
|
7078
|
+
return { done: true, reason: `max tool calls (${this.condition.maxToolCalls}) reached`, ...state };
|
|
7079
|
+
}
|
|
7080
|
+
break;
|
|
7073
7081
|
}
|
|
7074
7082
|
return { done: false, iterations: state.iterations, toolCalls: state.toolCalls };
|
|
7075
7083
|
}
|
|
@@ -7089,10 +7097,16 @@ var AutonomousRunner = class {
|
|
|
7089
7097
|
const offToolExecuted = this.opts.agent.events?.on?.("tool.executed", () => {
|
|
7090
7098
|
this.toolCalls++;
|
|
7091
7099
|
});
|
|
7100
|
+
const offIterationCompleted = this.opts.agent.events?.on?.("iteration.completed", () => {
|
|
7101
|
+
if (this.opts.enableAutonomousContinue && this.opts.doneCondition.type === "directive") {
|
|
7102
|
+
this.iterations++;
|
|
7103
|
+
}
|
|
7104
|
+
});
|
|
7092
7105
|
try {
|
|
7093
7106
|
return await this.runLoop();
|
|
7094
7107
|
} finally {
|
|
7095
7108
|
offToolExecuted?.();
|
|
7109
|
+
offIterationCompleted?.();
|
|
7096
7110
|
}
|
|
7097
7111
|
}
|
|
7098
7112
|
async runLoop() {
|
|
@@ -7116,12 +7130,14 @@ var AutonomousRunner = class {
|
|
|
7116
7130
|
const ctrl = new AbortController();
|
|
7117
7131
|
const timeout = setTimeout(() => ctrl.abort(), this.opts.iterationTimeoutMs ?? 3e4);
|
|
7118
7132
|
try {
|
|
7133
|
+
const isDirectiveMode = this.opts.doneCondition.type === "directive" && this.opts.enableAutonomousContinue;
|
|
7119
7134
|
const result = await this.opts.agent.run("", {
|
|
7120
7135
|
signal: ctrl.signal,
|
|
7121
|
-
maxIterations: 1,
|
|
7122
|
-
executionStrategy: "sequential"
|
|
7136
|
+
maxIterations: isDirectiveMode ? this.opts.doneCondition.maxIterations ?? 100 : 1,
|
|
7137
|
+
executionStrategy: "sequential",
|
|
7138
|
+
autonomousContinue: isDirectiveMode ? true : void 0
|
|
7123
7139
|
});
|
|
7124
|
-
this.iterations++;
|
|
7140
|
+
if (!isDirectiveMode) this.iterations++;
|
|
7125
7141
|
if (result.status === "done") {
|
|
7126
7142
|
this.lastOutput = result.finalText;
|
|
7127
7143
|
}
|
|
@@ -8318,10 +8334,10 @@ function makeSpawnTool(director, roster) {
|
|
|
8318
8334
|
const subagentId = await director.spawn(cfg);
|
|
8319
8335
|
return { subagentId, provider: cfg.provider, model: cfg.model, name: cfg.name };
|
|
8320
8336
|
} catch (err) {
|
|
8321
|
-
if (err instanceof
|
|
8337
|
+
if (err instanceof FleetSpawnBudgetError) {
|
|
8322
8338
|
return { error: err.message, kind: err.kind, limit: err.limit, observed: err.observed };
|
|
8323
8339
|
}
|
|
8324
|
-
if (err instanceof
|
|
8340
|
+
if (err instanceof FleetCostCapError) {
|
|
8325
8341
|
return { error: err.message, kind: err.kind, limit: err.limit, observed: err.observed };
|
|
8326
8342
|
}
|
|
8327
8343
|
return { error: err instanceof Error ? err.message : String(err) };
|
|
@@ -8522,7 +8538,7 @@ function makeFleetHealthTool(director) {
|
|
|
8522
8538
|
}
|
|
8523
8539
|
|
|
8524
8540
|
// src/coordination/director.ts
|
|
8525
|
-
var
|
|
8541
|
+
var FleetSpawnBudgetError = class extends Error {
|
|
8526
8542
|
kind;
|
|
8527
8543
|
limit;
|
|
8528
8544
|
observed;
|
|
@@ -8530,13 +8546,13 @@ var DirectorBudgetError = class extends Error {
|
|
|
8530
8546
|
super(
|
|
8531
8547
|
kind === "max_spawns" ? `Director spawn budget exceeded: tried to spawn #${observed} but maxSpawns is ${limit}` : `Director spawn depth budget exceeded: this director is at depth ${observed} and maxSpawnDepth is ${limit}`
|
|
8532
8548
|
);
|
|
8533
|
-
this.name = "
|
|
8549
|
+
this.name = "FleetSpawnBudgetError";
|
|
8534
8550
|
this.kind = kind;
|
|
8535
8551
|
this.limit = limit;
|
|
8536
8552
|
this.observed = observed;
|
|
8537
8553
|
}
|
|
8538
8554
|
};
|
|
8539
|
-
var
|
|
8555
|
+
var FleetCostCapError = class extends Error {
|
|
8540
8556
|
kind;
|
|
8541
8557
|
limit;
|
|
8542
8558
|
observed;
|
|
@@ -8544,16 +8560,34 @@ var DirectorCostCapError = class extends Error {
|
|
|
8544
8560
|
super(
|
|
8545
8561
|
`Director cost cap exceeded: total fleet spend ${observed.toFixed(4)} exceeds maxCostUsd ${limit.toFixed(4)}`
|
|
8546
8562
|
);
|
|
8547
|
-
this.name = "
|
|
8563
|
+
this.name = "FleetCostCapError";
|
|
8548
8564
|
this.kind = "max_cost_usd";
|
|
8549
8565
|
this.limit = limit;
|
|
8550
8566
|
this.observed = observed;
|
|
8551
8567
|
}
|
|
8552
8568
|
};
|
|
8553
8569
|
var Director = class {
|
|
8570
|
+
/** Alias for the ICoordinator contract. `id` is retained for backward compatibility. */
|
|
8571
|
+
get coordinatorId() {
|
|
8572
|
+
return this.id;
|
|
8573
|
+
}
|
|
8554
8574
|
id;
|
|
8575
|
+
/**
|
|
8576
|
+
* The fleet event bus. Backed by `fleetManager?.fleet` when a FleetManager
|
|
8577
|
+
* is injected; otherwise own FleetBus instance (preserves existing behavior).
|
|
8578
|
+
*/
|
|
8555
8579
|
fleet;
|
|
8580
|
+
/**
|
|
8581
|
+
* Usage rollup. Backed by `fleetManager?.usage` when a FleetManager is
|
|
8582
|
+
* injected; otherwise own FleetUsageAggregator.
|
|
8583
|
+
*/
|
|
8556
8584
|
usage;
|
|
8585
|
+
/**
|
|
8586
|
+
* Optional fleet-level policy container. When provided the Director
|
|
8587
|
+
* delegates spawn budgeting, manifest entries, and checkpointing to it
|
|
8588
|
+
* instead of managing those internally. All other behavior is unchanged.
|
|
8589
|
+
*/
|
|
8590
|
+
fleetManager;
|
|
8557
8591
|
/**
|
|
8558
8592
|
* Director-side bridge endpoint. Subagents are wired to the same
|
|
8559
8593
|
* in-memory transport so the director can `ask()` them synchronously
|
|
@@ -8604,8 +8638,8 @@ var Director = class {
|
|
|
8604
8638
|
/** Debounce timer for periodic manifest writes. */
|
|
8605
8639
|
manifestTimer = null;
|
|
8606
8640
|
manifestDebounceMs;
|
|
8607
|
-
/** Fleet-wide cost cap. Infinity means no cap. */
|
|
8608
|
-
|
|
8641
|
+
/** Fleet-wide cost cap (entire fleet total, distinct from SubagentBudget limits). Infinity means no cap. */
|
|
8642
|
+
maxFleetCostUsd;
|
|
8609
8643
|
/** Max auto-extensions per subagent per budget kind before denying. */
|
|
8610
8644
|
maxBudgetExtensions;
|
|
8611
8645
|
/** Sessions root for direct subagent JSONL reads (fleet_session tool). */
|
|
@@ -8638,7 +8672,7 @@ var Director = class {
|
|
|
8638
8672
|
this.spawnDepth = opts.spawnDepth ?? 0;
|
|
8639
8673
|
this.sessionWriter = opts.sessionWriter ?? null;
|
|
8640
8674
|
this.manifestDebounceMs = opts.manifestDebounceMs ?? 2e3;
|
|
8641
|
-
this.
|
|
8675
|
+
this.maxFleetCostUsd = opts.directorBudget?.maxCostUsd ?? Number.POSITIVE_INFINITY;
|
|
8642
8676
|
this.maxBudgetExtensions = opts.maxBudgetExtensions ?? 2;
|
|
8643
8677
|
this.sessionsRoot = opts.sessionsRoot;
|
|
8644
8678
|
this.directorRunId = opts.directorRunId ?? this.id;
|
|
@@ -8649,6 +8683,7 @@ var Director = class {
|
|
|
8649
8683
|
maxSpawnDepth: this.maxSpawnDepth,
|
|
8650
8684
|
directorBudget: opts.directorBudget
|
|
8651
8685
|
}, opts.checkpointDebounceMs ?? 250) : null;
|
|
8686
|
+
this.fleetManager = opts.fleetManager;
|
|
8652
8687
|
if (this.sharedScratchpadPath) {
|
|
8653
8688
|
void fsp2.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(() => void 0);
|
|
8654
8689
|
}
|
|
@@ -8657,12 +8692,17 @@ var Director = class {
|
|
|
8657
8692
|
{ agentId: this.id, coordinatorId: this.id },
|
|
8658
8693
|
this.transport
|
|
8659
8694
|
);
|
|
8660
|
-
this.
|
|
8661
|
-
|
|
8662
|
-
this.
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8695
|
+
if (this.fleetManager) {
|
|
8696
|
+
this.fleet = this.fleetManager.fleet;
|
|
8697
|
+
this.usage = this.fleetManager.usage;
|
|
8698
|
+
} else {
|
|
8699
|
+
this.fleet = new FleetBus();
|
|
8700
|
+
this.usage = new FleetUsageAggregator(
|
|
8701
|
+
this.fleet,
|
|
8702
|
+
(id) => this.priceLookups.get(id),
|
|
8703
|
+
(id) => this.subagentMeta.get(id)
|
|
8704
|
+
);
|
|
8705
|
+
}
|
|
8666
8706
|
this.coordinator = new DefaultMultiAgentCoordinator(
|
|
8667
8707
|
{ ...opts.config, coordinatorId: this.id },
|
|
8668
8708
|
{ runner: opts.runner }
|
|
@@ -8764,58 +8804,73 @@ var Director = class {
|
|
|
8764
8804
|
* it the `cost` column in `usage.snapshot()` stays at 0.
|
|
8765
8805
|
*/
|
|
8766
8806
|
async spawn(config, priceLookup) {
|
|
8767
|
-
if (this.
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
if (
|
|
8776
|
-
throw new
|
|
8807
|
+
if (this.fleetManager) {
|
|
8808
|
+
const rejection = this.fleetManager.canSpawn(config);
|
|
8809
|
+
if (rejection) {
|
|
8810
|
+
if (rejection.kind === "max_spawn_depth") throw new FleetSpawnBudgetError("max_spawn_depth", rejection.limit, rejection.observed);
|
|
8811
|
+
if (rejection.kind === "max_spawns") throw new FleetSpawnBudgetError("max_spawns", rejection.limit, rejection.observed);
|
|
8812
|
+
if (rejection.kind === "max_cost_usd") throw new FleetCostCapError(rejection.limit, rejection.observed);
|
|
8813
|
+
}
|
|
8814
|
+
} else {
|
|
8815
|
+
if (this.spawnDepth >= this.maxSpawnDepth) {
|
|
8816
|
+
throw new FleetSpawnBudgetError("max_spawn_depth", this.maxSpawnDepth, this.spawnDepth);
|
|
8817
|
+
}
|
|
8818
|
+
if (this.spawnCount >= this.maxSpawns) {
|
|
8819
|
+
throw new FleetSpawnBudgetError("max_spawns", this.maxSpawns, this.spawnCount + 1);
|
|
8820
|
+
}
|
|
8821
|
+
if (this.maxFleetCostUsd < Number.POSITIVE_INFINITY) {
|
|
8822
|
+
const totalCost = this.usage.snapshot().total?.cost ?? 0;
|
|
8823
|
+
if (totalCost >= this.maxFleetCostUsd) {
|
|
8824
|
+
throw new FleetCostCapError(this.maxFleetCostUsd, totalCost);
|
|
8825
|
+
}
|
|
8777
8826
|
}
|
|
8778
8827
|
}
|
|
8779
8828
|
const result = await this.coordinator.spawn(config);
|
|
8780
|
-
this.
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8829
|
+
if (this.fleetManager) {
|
|
8830
|
+
this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
|
|
8831
|
+
} else {
|
|
8832
|
+
this.spawnCount += 1;
|
|
8833
|
+
this.subagentMeta.set(result.subagentId, {
|
|
8834
|
+
provider: config.provider,
|
|
8835
|
+
model: config.model
|
|
8836
|
+
});
|
|
8837
|
+
if (priceLookup) this.priceLookups.set(result.subagentId, priceLookup);
|
|
8838
|
+
}
|
|
8786
8839
|
const subagentBridge = new InMemoryAgentBridge(
|
|
8787
8840
|
{ agentId: result.subagentId, coordinatorId: this.id },
|
|
8788
8841
|
this.transport
|
|
8789
8842
|
);
|
|
8790
8843
|
this.coordinator.setSubagentBridge(result.subagentId, subagentBridge);
|
|
8791
8844
|
this.subagentBridges.set(result.subagentId, subagentBridge);
|
|
8792
|
-
this.
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
role: config.role,
|
|
8796
|
-
provider: config.provider,
|
|
8797
|
-
model: config.model,
|
|
8798
|
-
taskIds: []
|
|
8799
|
-
});
|
|
8800
|
-
const spawnedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8801
|
-
this.stateCheckpoint?.recordSpawn(
|
|
8802
|
-
{
|
|
8803
|
-
id: result.subagentId,
|
|
8845
|
+
if (!this.fleetManager) {
|
|
8846
|
+
this.manifestEntries.set(result.subagentId, {
|
|
8847
|
+
subagentId: result.subagentId,
|
|
8804
8848
|
name: config.name,
|
|
8805
8849
|
role: config.role,
|
|
8806
8850
|
provider: config.provider,
|
|
8807
8851
|
model: config.model,
|
|
8808
|
-
|
|
8809
|
-
}
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8852
|
+
taskIds: []
|
|
8853
|
+
});
|
|
8854
|
+
const spawnedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8855
|
+
this.stateCheckpoint?.recordSpawn(
|
|
8856
|
+
{
|
|
8857
|
+
id: result.subagentId,
|
|
8858
|
+
name: config.name,
|
|
8859
|
+
role: config.role,
|
|
8860
|
+
provider: config.provider,
|
|
8861
|
+
model: config.model,
|
|
8862
|
+
spawnedAt
|
|
8863
|
+
},
|
|
8864
|
+
this.spawnCount
|
|
8865
|
+
);
|
|
8866
|
+
void this.appendSessionEvent({
|
|
8867
|
+
type: "agent_spawned",
|
|
8868
|
+
ts: spawnedAt,
|
|
8869
|
+
agentId: result.subagentId,
|
|
8870
|
+
role: config.role ?? config.name
|
|
8871
|
+
});
|
|
8872
|
+
this.scheduleManifest();
|
|
8873
|
+
}
|
|
8819
8874
|
return result.subagentId;
|
|
8820
8875
|
}
|
|
8821
8876
|
/**
|
|
@@ -8982,8 +9037,12 @@ var Director = class {
|
|
|
8982
9037
|
async assign(task) {
|
|
8983
9038
|
const taskWithId = task.id ? task : { ...task, id: randomUUID() };
|
|
8984
9039
|
if (task.subagentId) {
|
|
8985
|
-
|
|
8986
|
-
|
|
9040
|
+
if (this.fleetManager) {
|
|
9041
|
+
this.fleetManager.addTaskToSubagent(task.subagentId, taskWithId.id);
|
|
9042
|
+
} else {
|
|
9043
|
+
const entry = this.manifestEntries.get(task.subagentId);
|
|
9044
|
+
if (entry) entry.taskIds.push(taskWithId.id);
|
|
9045
|
+
}
|
|
8987
9046
|
}
|
|
8988
9047
|
await this.coordinator.assign(taskWithId);
|
|
8989
9048
|
this.taskDescriptions.set(taskWithId.id, taskWithId.description);
|
|
@@ -9181,8 +9240,9 @@ var Director = class {
|
|
|
9181
9240
|
* still permission-checked normally.
|
|
9182
9241
|
*/
|
|
9183
9242
|
tools(roster) {
|
|
9243
|
+
const effectiveRoster = roster ?? this.roster;
|
|
9184
9244
|
const t2 = [
|
|
9185
|
-
makeSpawnTool(this,
|
|
9245
|
+
makeSpawnTool(this, effectiveRoster),
|
|
9186
9246
|
makeAssignTool(this),
|
|
9187
9247
|
makeAwaitTasksTool(this),
|
|
9188
9248
|
makeAskTool(this),
|
|
@@ -9648,6 +9708,9 @@ function makeDirectorSessionFactory(opts) {
|
|
|
9648
9708
|
}
|
|
9649
9709
|
};
|
|
9650
9710
|
}
|
|
9711
|
+
|
|
9712
|
+
// src/coordination/null-fleet-bus.ts
|
|
9713
|
+
var NULL_FLEET_BUS = new FleetBus();
|
|
9651
9714
|
var DefaultModeStore = class {
|
|
9652
9715
|
activeModeId = null;
|
|
9653
9716
|
modes;
|
|
@@ -10973,10 +11036,10 @@ var AISpecBuilder = class {
|
|
|
10973
11036
|
async saveSession() {
|
|
10974
11037
|
if (!this.sessionPath) return;
|
|
10975
11038
|
try {
|
|
10976
|
-
const
|
|
10977
|
-
const
|
|
10978
|
-
await
|
|
10979
|
-
await
|
|
11039
|
+
const fsp15 = await import('fs/promises');
|
|
11040
|
+
const path25 = await import('path');
|
|
11041
|
+
await fsp15.mkdir(path25.dirname(this.sessionPath), { recursive: true });
|
|
11042
|
+
await fsp15.writeFile(this.sessionPath, JSON.stringify(this.session, null, 2), "utf8");
|
|
10980
11043
|
} catch {
|
|
10981
11044
|
}
|
|
10982
11045
|
}
|
|
@@ -10984,8 +11047,8 @@ var AISpecBuilder = class {
|
|
|
10984
11047
|
async loadSession() {
|
|
10985
11048
|
if (!this.sessionPath) return false;
|
|
10986
11049
|
try {
|
|
10987
|
-
const
|
|
10988
|
-
const raw = await
|
|
11050
|
+
const fsp15 = await import('fs/promises');
|
|
11051
|
+
const raw = await fsp15.readFile(this.sessionPath, "utf8");
|
|
10989
11052
|
const loaded = JSON.parse(raw);
|
|
10990
11053
|
if (loaded?.id && loaded?.phase && loaded?.title) {
|
|
10991
11054
|
this.session = loaded;
|
|
@@ -10999,8 +11062,8 @@ var AISpecBuilder = class {
|
|
|
10999
11062
|
async deleteSession() {
|
|
11000
11063
|
if (!this.sessionPath) return;
|
|
11001
11064
|
try {
|
|
11002
|
-
const
|
|
11003
|
-
await
|
|
11065
|
+
const fsp15 = await import('fs/promises');
|
|
11066
|
+
await fsp15.unlink(this.sessionPath);
|
|
11004
11067
|
} catch {
|
|
11005
11068
|
}
|
|
11006
11069
|
}
|
|
@@ -11678,15 +11741,15 @@ function computeCriticalPath(graph, topoOrder, blockedByMap) {
|
|
|
11678
11741
|
maxId = id;
|
|
11679
11742
|
}
|
|
11680
11743
|
}
|
|
11681
|
-
const
|
|
11744
|
+
const path25 = [];
|
|
11682
11745
|
let current = maxId;
|
|
11683
11746
|
const visited = /* @__PURE__ */ new Set();
|
|
11684
11747
|
while (current && !visited.has(current)) {
|
|
11685
11748
|
visited.add(current);
|
|
11686
|
-
|
|
11749
|
+
path25.unshift(current);
|
|
11687
11750
|
current = prev.get(current) ?? null;
|
|
11688
11751
|
}
|
|
11689
|
-
return
|
|
11752
|
+
return path25;
|
|
11690
11753
|
}
|
|
11691
11754
|
function computeParallelGroups(graph, blockedByMap) {
|
|
11692
11755
|
const groups = [];
|
|
@@ -12396,7 +12459,7 @@ async function startMetricsServer(opts) {
|
|
|
12396
12459
|
const tls = opts.tls;
|
|
12397
12460
|
const useHttps = !!(tls?.cert && tls?.key);
|
|
12398
12461
|
const host = opts.host ?? "127.0.0.1";
|
|
12399
|
-
const
|
|
12462
|
+
const path25 = opts.path ?? "/metrics";
|
|
12400
12463
|
const healthPath = opts.healthPath ?? "/healthz";
|
|
12401
12464
|
const healthRegistry = opts.healthRegistry;
|
|
12402
12465
|
const listener = (req, res) => {
|
|
@@ -12406,7 +12469,7 @@ async function startMetricsServer(opts) {
|
|
|
12406
12469
|
return;
|
|
12407
12470
|
}
|
|
12408
12471
|
const url = req.url.split("?")[0];
|
|
12409
|
-
if (url ===
|
|
12472
|
+
if (url === path25) {
|
|
12410
12473
|
let body;
|
|
12411
12474
|
try {
|
|
12412
12475
|
body = renderPrometheus(opts.sink.snapshot());
|
|
@@ -12470,7 +12533,7 @@ async function startMetricsServer(opts) {
|
|
|
12470
12533
|
const protocol = useHttps ? "https" : "http";
|
|
12471
12534
|
return {
|
|
12472
12535
|
port: boundPort,
|
|
12473
|
-
url: `${protocol}://${host}:${boundPort}${
|
|
12536
|
+
url: `${protocol}://${host}:${boundPort}${path25}`,
|
|
12474
12537
|
close: () => new Promise((resolve5, reject) => {
|
|
12475
12538
|
server.close((err) => err ? reject(err) : resolve5());
|
|
12476
12539
|
})
|
|
@@ -14578,8 +14641,8 @@ var ReportGenerator = class {
|
|
|
14578
14641
|
try {
|
|
14579
14642
|
await stat(this.options.outputDir);
|
|
14580
14643
|
} catch {
|
|
14581
|
-
const { mkdir:
|
|
14582
|
-
await
|
|
14644
|
+
const { mkdir: mkdir11 } = await import('fs/promises');
|
|
14645
|
+
await mkdir11(this.options.outputDir, { recursive: true });
|
|
14583
14646
|
}
|
|
14584
14647
|
}
|
|
14585
14648
|
generateMarkdown(result) {
|
|
@@ -15539,6 +15602,202 @@ function getHelpMessage() {
|
|
|
15539
15602
|
`;
|
|
15540
15603
|
}
|
|
15541
15604
|
var securitySlashCommand = createSecuritySlashCommand();
|
|
15605
|
+
var FleetManager = class {
|
|
15606
|
+
/** The fleet-wide event bus. */
|
|
15607
|
+
fleet;
|
|
15608
|
+
/** Usage rollup across all subagents. */
|
|
15609
|
+
usage;
|
|
15610
|
+
manifestPath;
|
|
15611
|
+
sessionsRoot;
|
|
15612
|
+
directorRunId;
|
|
15613
|
+
/** Spawn cap (lifetime total). Infinity means unlimited. */
|
|
15614
|
+
maxSpawns;
|
|
15615
|
+
/** Nesting cap. */
|
|
15616
|
+
maxSpawnDepth;
|
|
15617
|
+
/** This director's depth in a director chain. Root = 0. */
|
|
15618
|
+
spawnDepth;
|
|
15619
|
+
/** Live spawn counter. */
|
|
15620
|
+
spawnCount = 0;
|
|
15621
|
+
stateCheckpoint;
|
|
15622
|
+
sessionWriter;
|
|
15623
|
+
manifestTimer = null;
|
|
15624
|
+
manifestDebounceMs;
|
|
15625
|
+
/** Fleet-wide cost cap. Infinity = no cap. Distinct from SubagentBudget limits,
|
|
15626
|
+
* which track per-subagent spend — this field caps the entire fleet total. */
|
|
15627
|
+
maxFleetCostUsd;
|
|
15628
|
+
manifestEntries = /* @__PURE__ */ new Map();
|
|
15629
|
+
/** Pending tasks with their descriptions — populated by `addPendingTask`
|
|
15630
|
+
* and cleared by `removePendingTask`. Replaces the host-side `pending`
|
|
15631
|
+
* Map so task descriptions live in one place (FleetManager). */
|
|
15632
|
+
pendingTasks = /* @__PURE__ */ new Map();
|
|
15633
|
+
subagentMeta = /* @__PURE__ */ new Map();
|
|
15634
|
+
priceLookups = /* @__PURE__ */ new Map();
|
|
15635
|
+
constructor(opts = {}) {
|
|
15636
|
+
this.manifestPath = opts.manifestPath;
|
|
15637
|
+
this.sessionsRoot = opts.sessionsRoot;
|
|
15638
|
+
this.directorRunId = opts.directorRunId ?? randomUUID();
|
|
15639
|
+
this.maxSpawns = opts.maxSpawns ?? Number.POSITIVE_INFINITY;
|
|
15640
|
+
this.maxSpawnDepth = opts.maxSpawnDepth ?? 2;
|
|
15641
|
+
this.spawnDepth = opts.spawnDepth ?? 0;
|
|
15642
|
+
this.sessionWriter = opts.sessionWriter ?? null;
|
|
15643
|
+
this.manifestDebounceMs = opts.manifestDebounceMs ?? 2e3;
|
|
15644
|
+
this.maxFleetCostUsd = opts.directorBudget?.maxCostUsd ?? Number.POSITIVE_INFINITY;
|
|
15645
|
+
this.stateCheckpoint = opts.stateCheckpointPath ? new DirectorStateCheckpoint(
|
|
15646
|
+
opts.stateCheckpointPath,
|
|
15647
|
+
{
|
|
15648
|
+
directorRunId: this.directorRunId,
|
|
15649
|
+
maxSpawns: opts.maxSpawns,
|
|
15650
|
+
spawnDepth: this.spawnDepth,
|
|
15651
|
+
maxSpawnDepth: this.maxSpawnDepth,
|
|
15652
|
+
directorBudget: opts.directorBudget
|
|
15653
|
+
},
|
|
15654
|
+
opts.checkpointDebounceMs ?? 250
|
|
15655
|
+
) : null;
|
|
15656
|
+
this.fleet = new FleetBus();
|
|
15657
|
+
this.usage = new FleetUsageAggregator(
|
|
15658
|
+
this.fleet,
|
|
15659
|
+
(id) => this.priceLookups.get(id),
|
|
15660
|
+
(id) => this.subagentMeta.get(id)
|
|
15661
|
+
);
|
|
15662
|
+
}
|
|
15663
|
+
// -----------------------------------------------------------------------
|
|
15664
|
+
// IFleetManager surface
|
|
15665
|
+
// -----------------------------------------------------------------------
|
|
15666
|
+
get fleetBus() {
|
|
15667
|
+
return this.fleet;
|
|
15668
|
+
}
|
|
15669
|
+
snapshot() {
|
|
15670
|
+
return this.usage.snapshot();
|
|
15671
|
+
}
|
|
15672
|
+
getSubagentMeta(id) {
|
|
15673
|
+
return this.subagentMeta.get(id);
|
|
15674
|
+
}
|
|
15675
|
+
/**
|
|
15676
|
+
* Returns null if the spawn is allowed, or an object describing
|
|
15677
|
+
* which cap was exceeded. Does NOT throw — the caller decides
|
|
15678
|
+
* how to surface the rejection.
|
|
15679
|
+
*/
|
|
15680
|
+
canSpawn(config) {
|
|
15681
|
+
if (this.spawnDepth >= this.maxSpawnDepth) {
|
|
15682
|
+
return { kind: "max_spawn_depth", limit: this.maxSpawnDepth, observed: this.spawnDepth };
|
|
15683
|
+
}
|
|
15684
|
+
if (this.spawnCount >= this.maxSpawns) {
|
|
15685
|
+
return { kind: "max_spawns", limit: this.maxSpawns, observed: this.spawnCount + 1 };
|
|
15686
|
+
}
|
|
15687
|
+
if (this.maxFleetCostUsd < Number.POSITIVE_INFINITY) {
|
|
15688
|
+
const totalCost = this.usage.snapshot().total?.cost ?? 0;
|
|
15689
|
+
if (totalCost >= this.maxFleetCostUsd) {
|
|
15690
|
+
return { kind: "max_cost_usd", limit: this.maxFleetCostUsd, observed: totalCost };
|
|
15691
|
+
}
|
|
15692
|
+
}
|
|
15693
|
+
return null;
|
|
15694
|
+
}
|
|
15695
|
+
/**
|
|
15696
|
+
* Records a spawn: increments counter, stores metadata, updates state checkpoint,
|
|
15697
|
+
* and schedules a debounced manifest write. Call AFTER the coordinator
|
|
15698
|
+
* has successfully spawned the subagent.
|
|
15699
|
+
*
|
|
15700
|
+
* @param subagentId The subagent's id (from coordinator.spawn result)
|
|
15701
|
+
* @param config The SubagentConfig that was used
|
|
15702
|
+
* @param priceLookup Optional per-subagent pricing data
|
|
15703
|
+
*/
|
|
15704
|
+
recordSpawn(subagentId, config, priceLookup) {
|
|
15705
|
+
this.spawnCount += 1;
|
|
15706
|
+
this.subagentMeta.set(subagentId, {
|
|
15707
|
+
provider: config.provider,
|
|
15708
|
+
model: config.model
|
|
15709
|
+
});
|
|
15710
|
+
if (priceLookup) this.priceLookups.set(subagentId, priceLookup);
|
|
15711
|
+
this.manifestEntries.set(subagentId, {
|
|
15712
|
+
subagentId,
|
|
15713
|
+
name: config.name,
|
|
15714
|
+
role: config.role,
|
|
15715
|
+
provider: config.provider,
|
|
15716
|
+
model: config.model,
|
|
15717
|
+
taskIds: []
|
|
15718
|
+
});
|
|
15719
|
+
this.stateCheckpoint?.recordSpawn({
|
|
15720
|
+
id: subagentId,
|
|
15721
|
+
name: config.name,
|
|
15722
|
+
role: config.role,
|
|
15723
|
+
provider: config.provider,
|
|
15724
|
+
model: config.model,
|
|
15725
|
+
spawnedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
15726
|
+
}, this.spawnCount);
|
|
15727
|
+
void this.appendSessionEvent({
|
|
15728
|
+
type: "agent_spawned",
|
|
15729
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15730
|
+
agentId: subagentId,
|
|
15731
|
+
role: config.role ?? config.name
|
|
15732
|
+
});
|
|
15733
|
+
this.scheduleManifest();
|
|
15734
|
+
}
|
|
15735
|
+
async writeManifest() {
|
|
15736
|
+
if (!this.manifestPath) return null;
|
|
15737
|
+
const manifest = {
|
|
15738
|
+
version: 1,
|
|
15739
|
+
directorRunId: this.directorRunId,
|
|
15740
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15741
|
+
children: Array.from(this.manifestEntries.values()).map((entry) => ({
|
|
15742
|
+
id: entry.subagentId,
|
|
15743
|
+
name: entry.name,
|
|
15744
|
+
role: entry.role,
|
|
15745
|
+
provider: entry.provider,
|
|
15746
|
+
model: entry.model,
|
|
15747
|
+
taskIds: entry.taskIds
|
|
15748
|
+
})),
|
|
15749
|
+
usage: this.usage.snapshot()
|
|
15750
|
+
};
|
|
15751
|
+
await fsp2.mkdir(path6.dirname(this.manifestPath), { recursive: true });
|
|
15752
|
+
await fsp2.writeFile(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
|
|
15753
|
+
return this.manifestPath;
|
|
15754
|
+
}
|
|
15755
|
+
/**
|
|
15756
|
+
* Attach task ids to an already-spawned subagent. Called by
|
|
15757
|
+
* `Director.assign()` after the coordinator assigns a task.
|
|
15758
|
+
*/
|
|
15759
|
+
addTaskToSubagent(subagentId, taskId) {
|
|
15760
|
+
const entry = this.manifestEntries.get(subagentId);
|
|
15761
|
+
if (entry) entry.taskIds.push(taskId);
|
|
15762
|
+
}
|
|
15763
|
+
/**
|
|
15764
|
+
* Debounced manifest write. Call after any state mutation
|
|
15765
|
+
* (spawn, assign, complete) so a burst collapses into one write.
|
|
15766
|
+
*/
|
|
15767
|
+
scheduleManifest() {
|
|
15768
|
+
if (!this.manifestPath || this.manifestDebounceMs <= 0) return;
|
|
15769
|
+
if (this.manifestTimer) return;
|
|
15770
|
+
this.manifestTimer = setTimeout(() => {
|
|
15771
|
+
this.manifestTimer = null;
|
|
15772
|
+
void this.writeManifest().catch(() => void 0);
|
|
15773
|
+
}, this.manifestDebounceMs);
|
|
15774
|
+
}
|
|
15775
|
+
/** Best-effort session event writer. Swallows failures. */
|
|
15776
|
+
async appendSessionEvent(event) {
|
|
15777
|
+
if (!this.sessionWriter) return;
|
|
15778
|
+
try {
|
|
15779
|
+
await this.sessionWriter.append(event);
|
|
15780
|
+
} catch {
|
|
15781
|
+
}
|
|
15782
|
+
}
|
|
15783
|
+
// -----------------------------------------------------------------------
|
|
15784
|
+
// Pending task management — eliminates host-side state duplication
|
|
15785
|
+
// -----------------------------------------------------------------------
|
|
15786
|
+
addPendingTask(taskId, subagentId, description) {
|
|
15787
|
+
this.pendingTasks.set(taskId, { subagentId, description });
|
|
15788
|
+
}
|
|
15789
|
+
removePendingTask(taskId) {
|
|
15790
|
+
this.pendingTasks.delete(taskId);
|
|
15791
|
+
}
|
|
15792
|
+
getFleetStatus() {
|
|
15793
|
+
const pending = Array.from(this.pendingTasks.entries()).map(([taskId, v]) => ({
|
|
15794
|
+
taskId,
|
|
15795
|
+
description: v.description,
|
|
15796
|
+
subagentId: v.subagentId
|
|
15797
|
+
}));
|
|
15798
|
+
return { pending, live: [] };
|
|
15799
|
+
}
|
|
15800
|
+
};
|
|
15542
15801
|
|
|
15543
15802
|
// src/extension/registry.ts
|
|
15544
15803
|
var ExtensionRegistry = class {
|
|
@@ -15748,6 +16007,50 @@ var ExtensionRegistry = class {
|
|
|
15748
16007
|
}
|
|
15749
16008
|
};
|
|
15750
16009
|
|
|
16010
|
+
// src/core/continue-to-next-iteration.ts
|
|
16011
|
+
function parseContinueDirective(text) {
|
|
16012
|
+
const LINE_MARKERS = /^\s*\[(continue|next step|proceed|done)\]\s*$/gim;
|
|
16013
|
+
let match;
|
|
16014
|
+
let lastDirective = "none";
|
|
16015
|
+
while ((match = LINE_MARKERS.exec(text)) !== null) {
|
|
16016
|
+
const value = (match[1] ?? "").toLowerCase();
|
|
16017
|
+
if (value === "continue" || value === "next step" || value === "proceed") {
|
|
16018
|
+
lastDirective = "continue";
|
|
16019
|
+
} else if (value === "done") {
|
|
16020
|
+
lastDirective = "stop";
|
|
16021
|
+
}
|
|
16022
|
+
}
|
|
16023
|
+
return lastDirective;
|
|
16024
|
+
}
|
|
16025
|
+
var META_KEY = "_autonomousContinue";
|
|
16026
|
+
function setAutonomousContinue(ctx) {
|
|
16027
|
+
ctx.meta[META_KEY] = true;
|
|
16028
|
+
}
|
|
16029
|
+
function consumeAutonomousContinue(ctx) {
|
|
16030
|
+
const val = ctx.meta[META_KEY] === true;
|
|
16031
|
+
delete ctx.meta[META_KEY];
|
|
16032
|
+
return val;
|
|
16033
|
+
}
|
|
16034
|
+
function makeContinueToNextIterationTool() {
|
|
16035
|
+
const inputSchema = {
|
|
16036
|
+
type: "object",
|
|
16037
|
+
properties: {},
|
|
16038
|
+
required: [],
|
|
16039
|
+
description: "Signal that the agent should continue to the next iteration immediately, without waiting for user input. Use this when you have completed a step and want to proceed automatically to the next step in your plan."
|
|
16040
|
+
};
|
|
16041
|
+
return {
|
|
16042
|
+
name: "continue_to_next_iteration",
|
|
16043
|
+
description: "Continue to the next iteration without returning to the user. Call this when you have finished a step and want to keep working autonomously.",
|
|
16044
|
+
permission: "auto",
|
|
16045
|
+
mutating: false,
|
|
16046
|
+
inputSchema,
|
|
16047
|
+
async execute(_input, ctx) {
|
|
16048
|
+
setAutonomousContinue(ctx);
|
|
16049
|
+
return { continue: true };
|
|
16050
|
+
}
|
|
16051
|
+
};
|
|
16052
|
+
}
|
|
16053
|
+
|
|
15751
16054
|
// src/core/iteration-limit.ts
|
|
15752
16055
|
function requestLimitExtension(opts) {
|
|
15753
16056
|
const { events, currentIterations, currentLimit, autoExtend, timeoutMs = 3e4 } = opts;
|
|
@@ -15826,6 +16129,8 @@ var Agent = class {
|
|
|
15826
16129
|
plugins = [];
|
|
15827
16130
|
toolExecutor;
|
|
15828
16131
|
autoExtendLimit;
|
|
16132
|
+
/** Enables autonomous continue: model can signal `[continue]` or call continue_to_next_iteration() to re-run. */
|
|
16133
|
+
autonomousContinue;
|
|
15829
16134
|
tracer;
|
|
15830
16135
|
extensions;
|
|
15831
16136
|
constructor(init) {
|
|
@@ -15840,6 +16145,7 @@ var Agent = class {
|
|
|
15840
16145
|
this.executionStrategy = init.executionStrategy ?? "smart";
|
|
15841
16146
|
this.perIterationOutputCapBytes = init.perIterationOutputCapBytes ?? 1e5;
|
|
15842
16147
|
this.autoExtendLimit = init.autoExtendLimit ?? true;
|
|
16148
|
+
this.autonomousContinue = init.autonomousContinue ?? false;
|
|
15843
16149
|
this.tracer = init.tracer;
|
|
15844
16150
|
this.extensions = init.extensions ?? new ExtensionRegistry();
|
|
15845
16151
|
this.extensions.setLogger(this.container.resolve(TOKENS.Logger));
|
|
@@ -15988,6 +16294,9 @@ var Agent = class {
|
|
|
15988
16294
|
if (controller.signal.aborted) {
|
|
15989
16295
|
return { status: "aborted", iterations };
|
|
15990
16296
|
}
|
|
16297
|
+
if (this.autonomousContinue) {
|
|
16298
|
+
consumeAutonomousContinue(this.ctx);
|
|
16299
|
+
}
|
|
15991
16300
|
const limitCheck = await this.checkIterationLimit(
|
|
15992
16301
|
i,
|
|
15993
16302
|
effectiveLimit,
|
|
@@ -16064,12 +16373,32 @@ var Agent = class {
|
|
|
16064
16373
|
const toolUses = res.content.filter(isToolUseBlock);
|
|
16065
16374
|
if (toolUses.length === 0) {
|
|
16066
16375
|
this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
|
|
16376
|
+
if (this.autonomousContinue && responseResult.directive === "continue") {
|
|
16377
|
+
await this.compactContextIfNeeded();
|
|
16378
|
+
await this.extensions.runAfterIteration(this.ctx, i);
|
|
16379
|
+
continue;
|
|
16380
|
+
}
|
|
16381
|
+
if (this.autonomousContinue && responseResult.directive === "stop") {
|
|
16382
|
+
return { status: "done", iterations, finalText };
|
|
16383
|
+
}
|
|
16067
16384
|
return { status: "done", iterations, finalText };
|
|
16068
16385
|
}
|
|
16069
16386
|
await this.executeTools(toolUses);
|
|
16387
|
+
if (this.autonomousContinue && consumeAutonomousContinue(this.ctx)) {
|
|
16388
|
+
this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
|
|
16389
|
+
await this.compactContextIfNeeded();
|
|
16390
|
+
await this.extensions.runAfterIteration(this.ctx, i);
|
|
16391
|
+
continue;
|
|
16392
|
+
}
|
|
16070
16393
|
this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
|
|
16071
16394
|
await this.compactContextIfNeeded();
|
|
16072
16395
|
await this.extensions.runAfterIteration(this.ctx, i);
|
|
16396
|
+
if (this.autonomousContinue && responseResult.directive === "continue") {
|
|
16397
|
+
continue;
|
|
16398
|
+
}
|
|
16399
|
+
if (this.autonomousContinue && responseResult.directive === "stop") {
|
|
16400
|
+
return { status: "done", iterations, finalText };
|
|
16401
|
+
}
|
|
16073
16402
|
}
|
|
16074
16403
|
}
|
|
16075
16404
|
/**
|
|
@@ -16156,7 +16485,11 @@ var Agent = class {
|
|
|
16156
16485
|
if (!streamed) this.renderer?.write(rendered);
|
|
16157
16486
|
}
|
|
16158
16487
|
}
|
|
16159
|
-
|
|
16488
|
+
let directive = "none";
|
|
16489
|
+
if (this.autonomousContinue && finalText) {
|
|
16490
|
+
directive = parseContinueDirective(finalText);
|
|
16491
|
+
}
|
|
16492
|
+
return { finalText, aborted: false, done: false, directive };
|
|
16160
16493
|
}
|
|
16161
16494
|
/**
|
|
16162
16495
|
* Execute tools and append tool results to context.
|
|
@@ -17749,6 +18082,6 @@ function wrapApiForCapabilityCheck(plugin, api, log, enforce = false) {
|
|
|
17749
18082
|
});
|
|
17750
18083
|
}
|
|
17751
18084
|
|
|
17752
|
-
export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director,
|
|
18085
|
+
export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FleetBus, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, ScopedEventBus, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolError, ToolExecutor, ToolRegistry, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, applyRosterBudget, asBlocks, asText, atomicWrite, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildChildEnv, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, color, compileGlob, compileUserRegex, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, context7Server, contextManagerTool, createAutoExecutor, createContextManagerTool, createDefaultPipelines, createDelegateTool, createMessage, createSecuritySlashCommand, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, downloadGitHubTarball, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatPlan, formatPlanTemplates, formatTodosList, getContextWindowMode, getPlanTemplate, getTemplate, githubServer, googleMapsServer, isAgentError, isConfigError, isContextWindowModeId, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeContinueToNextIterationTool, makeDirectorSessionFactory, matchAny, matchGlob, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, parseContinueDirective, parseSkillRef, projectHash, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resolveContextWindowPolicy, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, safeParse, safeStringify, sanitizeJsonString, savePlan, saveTodosCheckpoint, securitySlashCommand, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
|
|
17753
18086
|
//# sourceMappingURL=index.js.map
|
|
17754
18087
|
//# sourceMappingURL=index.js.map
|