@wrongstack/core 0.87.0 → 0.89.3
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-C9P_HPez.d.ts → agent-bridge-DbVe1dHT.d.ts} +1 -1
- package/dist/{agent-subagent-runner-2Aq0jOSj.d.ts → agent-subagent-runner-C6eqID1t.d.ts} +477 -476
- package/dist/{events-DnRqXaZ3.d.ts → brain-s9DyD_Vf.d.ts} +185 -92
- package/dist/{compactor-CJq7LQev.d.ts → compactor-DXLxLcmU.d.ts} +2 -2
- package/dist/{config-_DZ7dN-T.d.ts → config-84VaZpH6.d.ts} +45 -38
- package/dist/{context-ToHAp4-U.d.ts → context-CNRYfhUv.d.ts} +1 -1
- package/dist/coordination/index.d.ts +16 -17
- package/dist/coordination/index.js +208 -93
- package/dist/coordination/index.js.map +1 -1
- package/dist/{default-config-DEXI4jsl.d.ts → default-config-CXsDvOmP.d.ts} +3 -1
- package/dist/defaults/index.d.ts +32 -34
- package/dist/defaults/index.js +744 -274
- package/dist/defaults/index.js.map +1 -1
- package/dist/{director-state-CgIc30qi.d.ts → director-state-BfeCUbmk.d.ts} +1 -1
- package/dist/execution/index.d.ts +18 -19
- package/dist/execution/index.js +79 -64
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +9 -10
- package/dist/extension/index.js +8 -6
- package/dist/extension/index.js.map +1 -1
- package/dist/{index-BNOLadHw.d.ts → index-CqrroYcU.d.ts} +13 -15
- package/dist/{index-N0_c4bHQ.d.ts → index-D3Nax3YU.d.ts} +11 -10
- package/dist/index.d.ts +191 -178
- package/dist/index.js +1419 -526
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +9 -9
- package/dist/infrastructure/index.js +16 -5
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +14 -16
- package/dist/kernel/index.js +17 -0
- package/dist/kernel/index.js.map +1 -1
- package/dist/{logger-B72yyPc6.d.ts → logger-B63L5bTg.d.ts} +1 -1
- package/dist/{logger-C_27pj9i.d.ts → logger-B9J5puGM.d.ts} +1 -1
- package/dist/{mcp-servers-Dck3T85_.d.ts → mcp-servers-D3E5ixAR.d.ts} +3 -3
- package/dist/{mode-CHo2XtHs.d.ts → mode-ARA3HrkY.d.ts} +1 -1
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +8 -6
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-Be3osGt5.d.ts → models-registry-B6_KfS65.d.ts} +1 -1
- package/dist/{models-registry-Boz639EI.d.ts → models-registry-DU64QxQa.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-DllpCVkF.d.ts → multi-agent-coordinator-DHNrjPaA.d.ts} +2 -2
- package/dist/{null-fleet-bus-BY0AN-sr.d.ts → null-fleet-bus-BzzciAc4.d.ts} +39 -32
- package/dist/observability/index.d.ts +3 -3
- package/dist/{observability-CoSNZdhX.d.ts → observability-D-HZN_mF.d.ts} +1 -1
- package/dist/{parallel-eternal-engine-D402RASp.d.ts → parallel-eternal-engine-CTpcrb9O.d.ts} +34 -33
- package/dist/{path-resolver-UPFTsDyD.d.ts → path-resolver-B7hgMAVe.d.ts} +3 -3
- package/dist/{permission-14CChMmO.d.ts → permission-BDv7z0mk.d.ts} +7 -2
- package/dist/{permission-policy-gW5htOo1.d.ts → permission-policy-dF74EpDp.d.ts} +2 -2
- package/dist/{system-prompt-C0rLCeyn.d.ts → pipeline-C1Ad9OjI.d.ts} +73 -73
- package/dist/{plan-templates-DRvPgkfZ.d.ts → plan-templates-CNphsz0n.d.ts} +79 -11
- package/dist/{provider-runner-COAJM8tC.d.ts → provider-runner-cqvlB_oS.d.ts} +5 -5
- package/dist/{retry-policy-DSu6O6rD.d.ts → retry-policy-BcmuT_V0.d.ts} +2 -2
- package/dist/sdd/index.d.ts +12 -33
- package/dist/sdd/index.js +110 -50
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-scrubber-yGBFQYju.d.ts → secret-vault-DrOhc2i5.d.ts} +7 -7
- package/dist/security/index.d.ts +4 -5
- package/dist/security/index.js +22 -4
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-11-fm95U.d.ts → selector-C7wcdqMA.d.ts} +1 -1
- package/dist/{session-event-bridge-D0u-x576.d.ts → session-event-bridge-IVzs2GpE.d.ts} +1 -1
- package/dist/{session-reader-BQU-toaN.d.ts → session-reader-DDz1Ek4V.d.ts} +2 -2
- package/dist/{skill-BJeF2DwY.d.ts → skill-BJxzIyyN.d.ts} +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.js +3 -9
- package/dist/skills/index.js.map +1 -1
- package/dist/storage/index.d.ts +134 -14
- package/dist/storage/index.js +982 -248
- package/dist/storage/index.js.map +1 -1
- package/dist/{task-graph-CikNdRTG.d.ts → task-graph-DJBqO0EY.d.ts} +1 -1
- package/dist/types/index.d.ts +26 -28
- package/dist/types/index.js +62 -37
- package/dist/types/index.js.map +1 -1
- package/dist/utils/expect-defined.d.ts +7 -0
- package/dist/utils/expect-defined.js +11 -0
- package/dist/utils/expect-defined.js.map +1 -0
- package/dist/utils/index.d.ts +11 -20
- package/dist/utils/index.js +61 -43
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-BQMvEllz.d.ts → wstack-paths-_lqjzErq.d.ts} +1 -1
- package/package.json +5 -1
- package/dist/memory-CEXuo7sz.d.ts +0 -16
- package/dist/secret-scrubber-3MHDDAtm.d.ts +0 -6
|
@@ -105,4 +105,4 @@ declare class DirectorStateCheckpoint {
|
|
|
105
105
|
private persist;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export {
|
|
108
|
+
export { type DirectorStateSnapshot as D, DirectorStateCheckpoint as a, type DirectorSubagentState as b, type DirectorTaskState as c, loadDirectorState as l };
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, E as EternalAutonomyEngine, c as EternalAutonomyOptions, d as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, e as ParallelEternalEngine, f as ParallelEternalOptions, g as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { M as MessageSelector } from '../selector-
|
|
5
|
-
import { E as EventBus } from '../
|
|
6
|
-
import {
|
|
7
|
-
import { a as SessionEventBridge } from '../session-event-bridge-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { R as RunResult, S as SystemPromptContributor } from '../index-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import '../retry-policy-
|
|
14
|
-
import '../models-registry-
|
|
1
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, E as EternalAutonomyEngine, c as EternalAutonomyOptions, d as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, e as ParallelEternalEngine, f as ParallelEternalOptions, g as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-CTpcrb9O.js';
|
|
2
|
+
import { P as Provider, C as Context } from '../context-CNRYfhUv.js';
|
|
3
|
+
import { C as Compactor, a as CompactReport } from '../compactor-DXLxLcmU.js';
|
|
4
|
+
import { M as MessageSelector } from '../selector-C7wcdqMA.js';
|
|
5
|
+
import { E as EventBus } from '../brain-s9DyD_Vf.js';
|
|
6
|
+
import { d as MiddlewareHandler } from '../pipeline-C1Ad9OjI.js';
|
|
7
|
+
import { a as SessionEventBridge } from '../session-event-bridge-IVzs2GpE.js';
|
|
8
|
+
import { k as ContextWindowAggressiveOn, o as ContextWindowPolicy } from '../config-84VaZpH6.js';
|
|
9
|
+
import { g as Agent, O as DoneCondition } from '../agent-subagent-runner-C6eqID1t.js';
|
|
10
|
+
import { R as RunResult, S as SystemPromptContributor } from '../index-D3Nax3YU.js';
|
|
11
|
+
import { S as SkillLoader, b as SkillManifest, a as SkillEntry } from '../skill-BJxzIyyN.js';
|
|
12
|
+
import { W as WstackPaths } from '../wstack-paths-_lqjzErq.js';
|
|
13
|
+
import '../retry-policy-BcmuT_V0.js';
|
|
14
|
+
import '../models-registry-B6_KfS65.js';
|
|
15
15
|
import '../goal-store-DvWLNu52.js';
|
|
16
|
-
import '../multi-agent-coordinator-
|
|
16
|
+
import '../multi-agent-coordinator-DHNrjPaA.js';
|
|
17
17
|
import 'node:events';
|
|
18
|
-
import '../logger-
|
|
19
|
-
import '../observability-
|
|
20
|
-
import '../permission-
|
|
21
|
-
import '../secret-scrubber-3MHDDAtm.js';
|
|
18
|
+
import '../logger-B63L5bTg.js';
|
|
19
|
+
import '../observability-D-HZN_mF.js';
|
|
20
|
+
import '../permission-BDv7z0mk.js';
|
|
22
21
|
|
|
23
22
|
interface SkillLoaderOptions {
|
|
24
23
|
paths: WstackPaths;
|
package/dist/execution/index.js
CHANGED
|
@@ -6,13 +6,15 @@ import { randomUUID, createHash, randomBytes } from 'crypto';
|
|
|
6
6
|
import * as os from 'os';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
|
|
9
|
-
// src/utils/
|
|
10
|
-
function expectDefined(value) {
|
|
9
|
+
// src/utils/expect-defined.ts
|
|
10
|
+
function expectDefined(value, label) {
|
|
11
11
|
if (value === null || value === void 0) {
|
|
12
12
|
throw new Error("Expected value to be defined");
|
|
13
13
|
}
|
|
14
14
|
return value;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
// src/utils/token-estimate.ts
|
|
16
18
|
var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
|
|
17
19
|
var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
|
|
18
20
|
var ESTIMATE_CACHE_MAX_SIZE = 1e4;
|
|
@@ -100,12 +102,6 @@ function estimateRequestTokensCalibrated(messages, systemPrompt, tools) {
|
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
// src/utils/message-invariants.ts
|
|
103
|
-
function expectDefined2(value) {
|
|
104
|
-
if (value === null || value === void 0) {
|
|
105
|
-
throw new Error("Expected value to be defined");
|
|
106
|
-
}
|
|
107
|
-
return value;
|
|
108
|
-
}
|
|
109
105
|
function repairToolUseAdjacency(messages) {
|
|
110
106
|
const removedToolUses = [];
|
|
111
107
|
const removedToolResults = [];
|
|
@@ -113,7 +109,7 @@ function repairToolUseAdjacency(messages) {
|
|
|
113
109
|
let changed = false;
|
|
114
110
|
const out = [];
|
|
115
111
|
for (let i = 0; i < messages.length; i++) {
|
|
116
|
-
const original =
|
|
112
|
+
const original = expectDefined(messages[i]);
|
|
117
113
|
let msg = original;
|
|
118
114
|
if (hasToolUse(msg)) {
|
|
119
115
|
const nextIds = toolResultIds(messages[i + 1]);
|
|
@@ -613,12 +609,6 @@ var IntelligentCompactor = class {
|
|
|
613
609
|
};
|
|
614
610
|
|
|
615
611
|
// src/models/llm-selector.ts
|
|
616
|
-
function expectDefined3(value) {
|
|
617
|
-
if (value === null || value === void 0) {
|
|
618
|
-
throw new Error("Expected value to be defined");
|
|
619
|
-
}
|
|
620
|
-
return value;
|
|
621
|
-
}
|
|
622
612
|
var DEFAULT_SYSTEM_PROMPT = `You are a context pruning assistant. Given a conversation history and a token budget, decide which message ranges are worth keeping verbatim and which should be collapsed into summaries.
|
|
623
613
|
|
|
624
614
|
Output a JSON object with this structure:
|
|
@@ -659,7 +649,7 @@ function formatMessages(messages, maxChars = 8e3) {
|
|
|
659
649
|
const lines = [];
|
|
660
650
|
let used = 0;
|
|
661
651
|
for (let i = 0; i < messages.length; i++) {
|
|
662
|
-
const m =
|
|
652
|
+
const m = expectDefined(messages[i]);
|
|
663
653
|
const role = m.role.padEnd(10, " ");
|
|
664
654
|
let text;
|
|
665
655
|
if (typeof m.content === "string") {
|
|
@@ -724,7 +714,7 @@ IMPORTANT: Total conversation (${totalTokens} tokens) exceeds budget (${effectiv
|
|
|
724
714
|
let tokenCount = 0;
|
|
725
715
|
let startIdx = 0;
|
|
726
716
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
727
|
-
const m =
|
|
717
|
+
const m = expectDefined(messages[i]);
|
|
728
718
|
const cost = typeof m.content === "string" ? Math.ceil(m.content.length / 4) : m.content.reduce(
|
|
729
719
|
(acc, b) => acc + (b.type === "text" ? Math.ceil(b.text.length / 4) : Math.ceil(JSON.stringify(b).length / 4)),
|
|
730
720
|
0
|
|
@@ -1457,17 +1447,12 @@ function createToolOutputSerializer(opts = {}) {
|
|
|
1457
1447
|
}
|
|
1458
1448
|
|
|
1459
1449
|
// src/execution/tool-executor.ts
|
|
1460
|
-
function expectDefined4(value) {
|
|
1461
|
-
if (value === null || value === void 0) {
|
|
1462
|
-
throw new Error("Expected value to be defined");
|
|
1463
|
-
}
|
|
1464
|
-
return value;
|
|
1465
|
-
}
|
|
1466
1450
|
var ToolExecutor = class {
|
|
1467
1451
|
constructor(registry, opts) {
|
|
1468
1452
|
this.registry = registry;
|
|
1469
1453
|
this.opts = opts;
|
|
1470
1454
|
this.iterationTimeoutMs = opts.iterationTimeoutMs ?? 3e5;
|
|
1455
|
+
this.maxToolTimeoutMs = opts.maxToolTimeoutMs ?? 3e5;
|
|
1471
1456
|
this.serializer = createToolOutputSerializer({
|
|
1472
1457
|
perIterationOutputCapBytes: opts.perIterationOutputCapBytes ?? 1e5
|
|
1473
1458
|
});
|
|
@@ -1476,6 +1461,7 @@ var ToolExecutor = class {
|
|
|
1476
1461
|
opts;
|
|
1477
1462
|
serializer;
|
|
1478
1463
|
iterationTimeoutMs;
|
|
1464
|
+
maxToolTimeoutMs;
|
|
1479
1465
|
/**
|
|
1480
1466
|
* Clear the interactive confirm awaiter so the executor returns
|
|
1481
1467
|
* `ToolConfirmPendingResult` instead of blocking on stdin. Used by
|
|
@@ -1713,7 +1699,10 @@ ${post.additionalContext}` };
|
|
|
1713
1699
|
if (parentSignal.reason instanceof Error) throw parentSignal.reason;
|
|
1714
1700
|
throw new Error(typeof parentSignal.reason === "string" ? parentSignal.reason : "aborted");
|
|
1715
1701
|
}
|
|
1716
|
-
const timeoutMs =
|
|
1702
|
+
const timeoutMs = clampTimeoutMs(
|
|
1703
|
+
tool.timeoutMs ?? this.iterationTimeoutMs,
|
|
1704
|
+
this.maxToolTimeoutMs
|
|
1705
|
+
);
|
|
1717
1706
|
const ctrl = new AbortController();
|
|
1718
1707
|
const timer = setTimeout(() => ctrl.abort(new Error("tool timeout")), timeoutMs);
|
|
1719
1708
|
const combined = AbortSignal.any([parentSignal, ctrl.signal]);
|
|
@@ -1848,6 +1837,12 @@ ${excerpt}`;
|
|
|
1848
1837
|
return void 0;
|
|
1849
1838
|
}
|
|
1850
1839
|
};
|
|
1840
|
+
function clampTimeoutMs(timeoutMs, maxTimeoutMs) {
|
|
1841
|
+
const fallback = 3e5;
|
|
1842
|
+
const finiteTimeout = Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : fallback;
|
|
1843
|
+
const finiteMax = Number.isFinite(maxTimeoutMs) && maxTimeoutMs > 0 ? maxTimeoutMs : fallback;
|
|
1844
|
+
return Math.max(1, Math.min(finiteTimeout, finiteMax));
|
|
1845
|
+
}
|
|
1851
1846
|
var MALFORMED_ARG_MARKERS = ["__raw", "__raw_arguments", "_raw"];
|
|
1852
1847
|
function hasMalformedArguments(input) {
|
|
1853
1848
|
if (!input || typeof input !== "object" || Array.isArray(input)) return false;
|
|
@@ -1858,7 +1853,7 @@ function hasMalformedArguments(input) {
|
|
|
1858
1853
|
function extractMalformedRaw(input) {
|
|
1859
1854
|
if (!hasMalformedArguments(input)) return void 0;
|
|
1860
1855
|
const obj = input;
|
|
1861
|
-
const value = obj[
|
|
1856
|
+
const value = obj[expectDefined(Object.keys(obj)[0])];
|
|
1862
1857
|
if (value === void 0 || value === null) return void 0;
|
|
1863
1858
|
if (typeof value === "string") return value;
|
|
1864
1859
|
try {
|
|
@@ -2756,6 +2751,7 @@ ${recentJournal}` : "No prior iterations.",
|
|
|
2756
2751
|
};
|
|
2757
2752
|
|
|
2758
2753
|
// src/coordination/subagent-budget.ts
|
|
2754
|
+
var TIMEOUT_PREEMPT_FRACTION = 0.85;
|
|
2759
2755
|
var BudgetExceededError = class extends Error {
|
|
2760
2756
|
kind;
|
|
2761
2757
|
limit;
|
|
@@ -3111,15 +3107,7 @@ function makeAgentSubagentRunner(opts) {
|
|
|
3111
3107
|
let budgetError = null;
|
|
3112
3108
|
const onBudgetError = (err) => {
|
|
3113
3109
|
if (err instanceof BudgetThresholdSignal) {
|
|
3114
|
-
|
|
3115
|
-
if (decision === "stop") {
|
|
3116
|
-
budgetError = new BudgetExceededError(err.kind, err.limit, err.used);
|
|
3117
|
-
aborter.abort();
|
|
3118
|
-
}
|
|
3119
|
-
}).catch(() => {
|
|
3120
|
-
budgetError = new BudgetExceededError(err.kind, err.limit, err.used);
|
|
3121
|
-
aborter.abort();
|
|
3122
|
-
});
|
|
3110
|
+
budgetError = err;
|
|
3123
3111
|
return;
|
|
3124
3112
|
}
|
|
3125
3113
|
aborter.abort();
|
|
@@ -3227,15 +3215,23 @@ function makeAgentSubagentRunner(opts) {
|
|
|
3227
3215
|
}
|
|
3228
3216
|
if (budgetError) {
|
|
3229
3217
|
if ("decision" in budgetError) {
|
|
3230
|
-
|
|
3231
|
-
|
|
3218
|
+
try {
|
|
3219
|
+
const decision = await budgetError.decision;
|
|
3220
|
+
if (decision === "stop") {
|
|
3221
|
+
budgetError = new BudgetExceededError(
|
|
3222
|
+
budgetError.kind,
|
|
3223
|
+
budgetError.limit,
|
|
3224
|
+
budgetError.used
|
|
3225
|
+
);
|
|
3226
|
+
} else {
|
|
3227
|
+
budgetError = null;
|
|
3228
|
+
}
|
|
3229
|
+
} catch {
|
|
3232
3230
|
budgetError = new BudgetExceededError(
|
|
3233
3231
|
budgetError.kind,
|
|
3234
3232
|
budgetError.limit,
|
|
3235
3233
|
budgetError.used
|
|
3236
3234
|
);
|
|
3237
|
-
} else {
|
|
3238
|
-
budgetError = null;
|
|
3239
3235
|
}
|
|
3240
3236
|
}
|
|
3241
3237
|
if (budgetError) throw budgetError;
|
|
@@ -6336,15 +6332,38 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
6336
6332
|
}
|
|
6337
6333
|
const start = Date.now();
|
|
6338
6334
|
let timer = null;
|
|
6335
|
+
let preemptedForLimit = null;
|
|
6339
6336
|
const timeoutPromise = new Promise((_, reject) => {
|
|
6340
6337
|
const armFor = (ms) => {
|
|
6341
6338
|
if (timer) clearTimeout(timer);
|
|
6342
6339
|
timer = setTimeout(onTick, Math.max(0, ms));
|
|
6343
6340
|
};
|
|
6344
6341
|
const scheduleNext = () => {
|
|
6345
|
-
const
|
|
6342
|
+
const wallLimit = budget.limits.timeoutMs ?? initialTimeoutMs;
|
|
6343
|
+
const wallRemaining = initialTimeoutMs === void 0 ? Number.POSITIVE_INFINITY : wallLimit - (Date.now() - start);
|
|
6346
6344
|
const idleRemaining = idleLimitMs === void 0 ? Number.POSITIVE_INFINITY : (budget.limits.idleTimeoutMs ?? idleLimitMs) - budget.idleMs();
|
|
6347
|
-
|
|
6345
|
+
const preemptRemaining = initialTimeoutMs === void 0 || preemptedForLimit === wallLimit ? Number.POSITIVE_INFINITY : wallLimit * TIMEOUT_PREEMPT_FRACTION - (Date.now() - start);
|
|
6346
|
+
armFor(Math.max(25, Math.min(wallRemaining, idleRemaining, preemptRemaining)));
|
|
6347
|
+
};
|
|
6348
|
+
const negotiateTimeout = async (used, limit) => {
|
|
6349
|
+
const handler = budget.onThreshold;
|
|
6350
|
+
if (!handler) return "stop";
|
|
6351
|
+
const result = handler({
|
|
6352
|
+
kind: "timeout",
|
|
6353
|
+
used,
|
|
6354
|
+
limit,
|
|
6355
|
+
requestDecision: () => new Promise((resolveDecision) => {
|
|
6356
|
+
budget._events?.emit("budget.threshold_reached", {
|
|
6357
|
+
kind: "timeout",
|
|
6358
|
+
used,
|
|
6359
|
+
limit,
|
|
6360
|
+
timeoutMs: 6e4,
|
|
6361
|
+
extend: (extra) => resolveDecision({ extend: extra }),
|
|
6362
|
+
deny: () => resolveDecision("stop")
|
|
6363
|
+
});
|
|
6364
|
+
})
|
|
6365
|
+
});
|
|
6366
|
+
return typeof result === "string" ? result : await result;
|
|
6348
6367
|
};
|
|
6349
6368
|
const onTick = async () => {
|
|
6350
6369
|
const elapsed = Date.now() - start;
|
|
@@ -6357,6 +6376,21 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
6357
6376
|
reject(new BudgetExceededError("timeout", idleLimit ?? 0, budget.idleMs()));
|
|
6358
6377
|
return;
|
|
6359
6378
|
}
|
|
6379
|
+
if (wallLimit !== void 0 && !wallExceeded && budget.onThreshold && preemptedForLimit !== wallLimit && elapsed >= wallLimit * TIMEOUT_PREEMPT_FRACTION) {
|
|
6380
|
+
try {
|
|
6381
|
+
const decision = await negotiateTimeout(elapsed, wallLimit);
|
|
6382
|
+
if (typeof decision !== "string" && decision.extend.timeoutMs !== void 0) {
|
|
6383
|
+
budget.limits.timeoutMs = decision.extend.timeoutMs;
|
|
6384
|
+
preemptedForLimit = null;
|
|
6385
|
+
} else {
|
|
6386
|
+
preemptedForLimit = wallLimit;
|
|
6387
|
+
}
|
|
6388
|
+
} catch {
|
|
6389
|
+
preemptedForLimit = wallLimit;
|
|
6390
|
+
}
|
|
6391
|
+
scheduleNext();
|
|
6392
|
+
return;
|
|
6393
|
+
}
|
|
6360
6394
|
if (!wallExceeded) {
|
|
6361
6395
|
scheduleNext();
|
|
6362
6396
|
return;
|
|
@@ -6368,28 +6402,15 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
6368
6402
|
return;
|
|
6369
6403
|
}
|
|
6370
6404
|
try {
|
|
6371
|
-
const
|
|
6372
|
-
kind: "timeout",
|
|
6373
|
-
used: elapsed,
|
|
6374
|
-
limit,
|
|
6375
|
-
requestDecision: () => new Promise((resolveDecision) => {
|
|
6376
|
-
budget._events?.emit("budget.threshold_reached", {
|
|
6377
|
-
kind: "timeout",
|
|
6378
|
-
used: elapsed,
|
|
6379
|
-
limit,
|
|
6380
|
-
timeoutMs: 6e4,
|
|
6381
|
-
extend: (extra) => resolveDecision({ extend: extra }),
|
|
6382
|
-
deny: () => resolveDecision("stop")
|
|
6383
|
-
});
|
|
6384
|
-
})
|
|
6385
|
-
});
|
|
6386
|
-
const decision = typeof result === "string" ? result : await result;
|
|
6405
|
+
const decision = await negotiateTimeout(elapsed, limit);
|
|
6387
6406
|
if (decision === "continue" || decision === "throw" || decision === "stop") {
|
|
6407
|
+
preemptedForLimit = null;
|
|
6388
6408
|
armFor(Math.max(1e3, limit));
|
|
6389
6409
|
return;
|
|
6390
6410
|
}
|
|
6391
6411
|
if (decision.extend.timeoutMs !== void 0) {
|
|
6392
6412
|
budget.limits.timeoutMs = decision.extend.timeoutMs;
|
|
6413
|
+
preemptedForLimit = null;
|
|
6393
6414
|
scheduleNext();
|
|
6394
6415
|
return;
|
|
6395
6416
|
}
|
|
@@ -6520,12 +6541,6 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
6520
6541
|
};
|
|
6521
6542
|
|
|
6522
6543
|
// src/execution/parallel-eternal-engine.ts
|
|
6523
|
-
function expectDefined5(value) {
|
|
6524
|
-
if (value === null || value === void 0) {
|
|
6525
|
-
throw new Error("Expected value to be defined");
|
|
6526
|
-
}
|
|
6527
|
-
return value;
|
|
6528
|
-
}
|
|
6529
6544
|
var GOAL_COMPLETE_MARKER2 = /^\s*\[goal[_\s-]?complete\]\s*$/im;
|
|
6530
6545
|
var ParallelEternalEngine = class {
|
|
6531
6546
|
constructor(opts) {
|
|
@@ -6681,7 +6696,7 @@ var ParallelEternalEngine = class {
|
|
|
6681
6696
|
// Fan-out
|
|
6682
6697
|
// -------------------------------------------------------------------------
|
|
6683
6698
|
async fanOut(goal, tasks) {
|
|
6684
|
-
const coordinator =
|
|
6699
|
+
const coordinator = expectDefined(this.coordinator);
|
|
6685
6700
|
const slotCount = Math.min(this.slots, tasks.length);
|
|
6686
6701
|
const routes = this.dispatchEnabled ? await Promise.all(
|
|
6687
6702
|
tasks.slice(0, slotCount).map(
|
|
@@ -6713,7 +6728,7 @@ ${recentJournal}` : "No prior iterations.",
|
|
|
6713
6728
|
const routeInfo = [];
|
|
6714
6729
|
const spawnPromises = [];
|
|
6715
6730
|
for (let i = 0; i < slotCount; i++) {
|
|
6716
|
-
const task =
|
|
6731
|
+
const task = expectDefined(tasks[i]);
|
|
6717
6732
|
const route = routes[i] ?? null;
|
|
6718
6733
|
const subagentId = `parallel-${this.iterations}-${i}`;
|
|
6719
6734
|
const taskId = randomUUID();
|