@wrongstack/core 0.10.3 → 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/{agent-subagent-runner-DuRtZmhl.d.ts → agent-subagent-runner-DpZTLdBe.d.ts} +1 -1
- package/dist/{config-CJXBka2r.d.ts → config-BUEGM4JP.d.ts} +2 -0
- package/dist/coordination/index.d.ts +6 -6
- package/dist/coordination/index.js +414 -71
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +8 -8
- package/dist/defaults/index.js +388 -57
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +5 -5
- package/dist/execution/index.js +47 -5
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +2 -2
- package/dist/{index-DnBHrz2y.d.ts → index-pXJdVLe0.d.ts} +1 -1
- package/dist/{index-DAHEM_II.d.ts → index-ysfO_DlX.d.ts} +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +635 -242
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +2 -2
- package/dist/infrastructure/index.js +2 -1
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +2 -2
- package/dist/{mcp-servers-BgINZzuo.d.ts → mcp-servers-BzB3r7_c.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-CjG-FZKj.d.ts → multi-agent-coordinator-DOXSgtom.d.ts} +5 -1
- package/dist/{null-fleet-bus-B3WdVY9i.d.ts → null-fleet-bus-CAQDGsKc.d.ts} +59 -3
- package/dist/{plan-templates-BUP4o-ds.d.ts → plan-templates-BZMi-VpU.d.ts} +1 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/sdd/index.js +40 -3
- package/dist/sdd/index.js.map +1 -1
- package/dist/storage/index.d.ts +2 -2
- package/dist/{tool-executor-D87-_5Of.d.ts → tool-executor-BAi4WI2d.d.ts} +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +76 -1
- package/dist/utils/index.js +171 -5
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-
|
|
1
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-BAi4WI2d.js';
|
|
2
2
|
import { m as Provider, d as Context } from '../context-7u93AcGD.js';
|
|
3
3
|
import { a as Compactor, C as CompactReport } from '../compactor-D1RHFRmF.js';
|
|
4
4
|
import { M as MessageSelector } from '../selector-DmXxpFyM.js';
|
|
5
5
|
import { E as EventBus } from '../events-BrQiweXN.js';
|
|
6
6
|
import { b as MiddlewareHandler } from '../system-prompt-CM6zOhd2.js';
|
|
7
7
|
import { a as SessionEventBridge, J as JournalEntry } from '../goal-store-BeRsj7YX.js';
|
|
8
|
-
import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-
|
|
9
|
-
import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-
|
|
8
|
+
import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-BUEGM4JP.js';
|
|
9
|
+
import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-ysfO_DlX.js';
|
|
10
10
|
import { D as DoneCondition } from '../multi-agent-C8Z1i__e.js';
|
|
11
|
-
import { A as AgentFactory } from '../agent-subagent-runner-
|
|
12
|
-
import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-
|
|
11
|
+
import { A as AgentFactory } from '../agent-subagent-runner-DpZTLdBe.js';
|
|
12
|
+
import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-DOXSgtom.js';
|
|
13
13
|
import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-CxuWrsKK.js';
|
|
14
14
|
import { a as WstackPaths } from '../wstack-paths-eMXnY1_X.js';
|
|
15
15
|
import '../retry-policy-KF18W4dg.js';
|
package/dist/execution/index.js
CHANGED
|
@@ -80,13 +80,18 @@ function estimateRequestTokens(messages, systemPrompt, tools) {
|
|
|
80
80
|
for (const t of tools) {
|
|
81
81
|
toolsTokens += estimateToolDefTokens(t);
|
|
82
82
|
}
|
|
83
|
+
const total = messagesTokens + systemTokens + toolsTokens;
|
|
83
84
|
return {
|
|
84
85
|
messages: messagesTokens,
|
|
85
86
|
systemPrompt: systemTokens,
|
|
86
87
|
tools: toolsTokens,
|
|
87
|
-
total
|
|
88
|
+
total
|
|
88
89
|
};
|
|
89
90
|
}
|
|
91
|
+
function estimateRequestTokensCalibrated(messages, systemPrompt, tools) {
|
|
92
|
+
const result = estimateRequestTokens(messages, systemPrompt, tools);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
// src/utils/message-invariants.ts
|
|
92
97
|
function repairToolUseAdjacency(messages) {
|
|
@@ -1159,7 +1164,7 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
1159
1164
|
}
|
|
1160
1165
|
handler() {
|
|
1161
1166
|
return async (ctx, next) => {
|
|
1162
|
-
const tokens = this._estimator ? this._estimator(ctx) :
|
|
1167
|
+
const tokens = this._estimator ? this._estimator(ctx) : estimateRequestTokensCalibrated(ctx.messages, ctx.systemPrompt, ctx.tools ?? []).total;
|
|
1163
1168
|
const load = tokens / this._maxContext;
|
|
1164
1169
|
const policy = this.policyProvider?.(ctx);
|
|
1165
1170
|
const thresholds = policy?.thresholds ?? {
|
|
@@ -5648,6 +5653,10 @@ var NICKNAME_POOL = {
|
|
|
5648
5653
|
"pasteur": { name: "Pasteur", domain: "biology" },
|
|
5649
5654
|
"hawking": { name: "Hawking", domain: "cosmology" },
|
|
5650
5655
|
"sagan": { name: "Sagan", domain: "cosmology" },
|
|
5656
|
+
// Exploration & navigation
|
|
5657
|
+
"columbus": { name: "Columbus", domain: "exploration" },
|
|
5658
|
+
"polo": { name: "Polo", domain: "exploration" },
|
|
5659
|
+
"magellan": { name: "Magellan", domain: "exploration" },
|
|
5651
5660
|
// Chemistry / materials
|
|
5652
5661
|
"lavoisier": { name: "Lavoisier", domain: "chemistry" },
|
|
5653
5662
|
"mendeleev": { name: "Mendeleev", domain: "chemistry" }
|
|
@@ -5702,7 +5711,7 @@ function formatRole(role) {
|
|
|
5702
5711
|
}
|
|
5703
5712
|
|
|
5704
5713
|
// src/coordination/multi-agent-coordinator.ts
|
|
5705
|
-
var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
5714
|
+
var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends EventEmitter {
|
|
5706
5715
|
coordinatorId;
|
|
5707
5716
|
config;
|
|
5708
5717
|
runner;
|
|
@@ -5717,8 +5726,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
5717
5726
|
* names) to memorable ones here — that's what surfaces in the fleet monitor.
|
|
5718
5727
|
*/
|
|
5719
5728
|
usedNicknames = /* @__PURE__ */ new Set();
|
|
5729
|
+
/** Maps subagentId → nickname key (e.g. 'einstein'). Used to free the slot on remove(). */
|
|
5730
|
+
subagentNicknames = /* @__PURE__ */ new Map();
|
|
5720
5731
|
pendingTasks = [];
|
|
5721
5732
|
completedResults = [];
|
|
5733
|
+
/** Prevents completedResults from growing unbounded in long-running coordinators. */
|
|
5734
|
+
static MAX_COMPLETED_RESULTS = 1e4;
|
|
5722
5735
|
totalIterations = 0;
|
|
5723
5736
|
inFlight = 0;
|
|
5724
5737
|
/**
|
|
@@ -5773,7 +5786,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
5773
5786
|
* Explicit, human-chosen names — including nicknames already assigned by
|
|
5774
5787
|
* `Director.spawn()` — are left untouched, so this never double-assigns.
|
|
5775
5788
|
*/
|
|
5776
|
-
withNickname(subagent) {
|
|
5789
|
+
withNickname(subagent, subagentId) {
|
|
5777
5790
|
const role = subagent.role ?? "subagent";
|
|
5778
5791
|
const name = subagent.name?.trim() ?? "";
|
|
5779
5792
|
const isPlaceholder = name === "" || name.toLowerCase() === role.toLowerCase() || name === "subagent" || name === "adhoc" || name === "generic" || /^slot-/.test(name);
|
|
@@ -5781,11 +5794,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
5781
5794
|
const nickname = assignNickname(role, this.usedNicknames);
|
|
5782
5795
|
const baseKey = nickname.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
5783
5796
|
this.usedNicknames.add(baseKey);
|
|
5797
|
+
this.subagentNicknames.set(subagentId, baseKey);
|
|
5784
5798
|
return { ...subagent, name: nickname };
|
|
5785
5799
|
}
|
|
5786
5800
|
async spawn(subagent) {
|
|
5787
|
-
subagent = this.withNickname(subagent);
|
|
5788
5801
|
const id = subagent.id || randomUUID();
|
|
5802
|
+
subagent = this.withNickname(subagent, id);
|
|
5789
5803
|
if (this.subagents.has(id)) {
|
|
5790
5804
|
throw new Error(`Subagent id "${id}" already exists \u2014 refusing to overwrite`);
|
|
5791
5805
|
}
|
|
@@ -6227,6 +6241,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
6227
6241
|
}
|
|
6228
6242
|
recordCompletion(result) {
|
|
6229
6243
|
this.completedResults.push(result);
|
|
6244
|
+
if (this.completedResults.length > _DefaultMultiAgentCoordinator.MAX_COMPLETED_RESULTS) {
|
|
6245
|
+
this.completedResults.splice(
|
|
6246
|
+
0,
|
|
6247
|
+
this.completedResults.length - _DefaultMultiAgentCoordinator.MAX_COMPLETED_RESULTS
|
|
6248
|
+
);
|
|
6249
|
+
}
|
|
6230
6250
|
this.totalIterations += result.iterations;
|
|
6231
6251
|
if (this.inFlight > 0) {
|
|
6232
6252
|
this.inFlight--;
|
|
@@ -6296,7 +6316,29 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
6296
6316
|
}
|
|
6297
6317
|
this.subagents.delete(subagentId);
|
|
6298
6318
|
this.terminating.delete(subagentId);
|
|
6319
|
+
const nicknameKey = this.subagentNicknames.get(subagentId);
|
|
6320
|
+
if (nicknameKey) {
|
|
6321
|
+
this.usedNicknames.delete(nicknameKey);
|
|
6322
|
+
this.subagentNicknames.delete(subagentId);
|
|
6323
|
+
}
|
|
6324
|
+
const orphaned = this.pendingTasks.filter((t) => t.subagentId === subagentId);
|
|
6299
6325
|
this.pendingTasks = this.pendingTasks.filter((t) => t.subagentId !== subagentId);
|
|
6326
|
+
for (const t of orphaned) {
|
|
6327
|
+
const synthetic = {
|
|
6328
|
+
subagentId,
|
|
6329
|
+
taskId: t.id,
|
|
6330
|
+
status: "stopped",
|
|
6331
|
+
error: {
|
|
6332
|
+
kind: "aborted_by_parent",
|
|
6333
|
+
message: `Subagent "${subagentId}" was removed while task "${t.id}" was pending`,
|
|
6334
|
+
retryable: false
|
|
6335
|
+
},
|
|
6336
|
+
iterations: 0,
|
|
6337
|
+
toolCalls: 0,
|
|
6338
|
+
durationMs: 0
|
|
6339
|
+
};
|
|
6340
|
+
this.recordCompletion(synthetic);
|
|
6341
|
+
}
|
|
6300
6342
|
this.fleetBus?.emit({
|
|
6301
6343
|
subagentId,
|
|
6302
6344
|
ts: Date.now(),
|