@wrongstack/core 0.267.0 → 0.269.0
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-STJ3JwwK.d.ts → agent-bridge-PcHQl_UQ.d.ts} +1 -1
- package/dist/{agent-subagent-runner-CzPGP3jA.d.ts → agent-subagent-runner-SHJW7t8q.d.ts} +8 -8
- package/dist/{brain-Cdg77tVN.d.ts → brain-BYcK__Ym.d.ts} +1 -1
- package/dist/{compactor-iMZ84CXq.d.ts → compactor-C2RKEBtC.d.ts} +1 -1
- package/dist/{config-Du3pYYln.d.ts → config-C_ae2k86.d.ts} +79 -2
- package/dist/{context-dT5Ueund.d.ts → context-Dp87Bcaq.d.ts} +47 -1
- package/dist/coordination/index.d.ts +62 -160
- package/dist/coordination/index.js +566 -149
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +26 -25
- package/dist/defaults/index.js +366 -137
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +72 -16
- package/dist/execution/index.js +267 -55
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +1 -1
- package/dist/extension/index.d.ts +7 -6
- package/dist/global-mailbox-Bvrz1P3f.d.ts +664 -0
- package/dist/{goal-preamble-SulMTowG.d.ts → goal-preamble-CA_4yiGQ.d.ts} +9 -9
- package/dist/{goal-store-CABDwdFE.d.ts → goal-store-DhuJoUNG.d.ts} +1 -1
- package/dist/hq/index.d.ts +204 -0
- package/dist/hq/index.js +1931 -0
- package/dist/hq/index.js.map +1 -0
- package/dist/{index-DtCVWel4.d.ts → index-CZQ6Pwbs.d.ts} +8 -8
- package/dist/{index-Bms0m4oy.d.ts → index-W4VJCzHa.d.ts} +5 -5
- package/dist/{index-IEuxQd-E.d.ts → index-whDfTANu.d.ts} +2 -2
- package/dist/index.d.ts +46 -42
- package/dist/index.js +3472 -1651
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/infrastructure/index.js +48 -21
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +10 -9
- package/dist/{pipeline-BfD2k1rT.d.ts → mailbox-types-Ct2hJq0P.d.ts} +1 -244
- package/dist/{mcp-servers-C2cBTxUR.d.ts → mcp-servers-DJdZiRcv.d.ts} +10 -4
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +4 -3
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-BqGZNJQ-.d.ts → models-registry-C3a-2-Yd.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-B8R43uPz.d.ts → multi-agent-coordinator-CJSpTe5O.d.ts} +1 -1
- package/dist/{null-fleet-bus-CnXa5oTH.d.ts → null-fleet-bus-QVshIsDx.d.ts} +6 -6
- package/dist/observability/index.d.ts +2 -2
- package/dist/{parallel-eternal-engine-DdNnw9BQ.d.ts → parallel-eternal-engine-D9y5Pkcc.d.ts} +9 -15
- package/dist/{path-resolver-COIMLCQL.d.ts → path-resolver-CnQ8SIfh.d.ts} +4 -3
- package/dist/{permission-B75JAi3-.d.ts → permission-CvYQNUqZ.d.ts} +1 -1
- package/dist/{permission-policy-DlR9eJAM.d.ts → permission-policy-D5Ss8j4B.d.ts} +2 -3
- package/dist/pipeline-l_zzFRh3.d.ts +245 -0
- package/dist/{plan-templates-DSIKCXZN.d.ts → plan-templates-NtPgyeJA.d.ts} +6 -5
- package/dist/{provider-model-resolve-BNRsNuJx.d.ts → provider-model-resolve-d5poT5y0.d.ts} +3 -3
- package/dist/{provider-runner-CX7iIvox.d.ts → provider-runner-gkctlQV_.d.ts} +3 -3
- package/dist/{retry-policy-BilV1ujH.d.ts → retry-policy-CtFhfwa8.d.ts} +1 -1
- package/dist/sdd/index.d.ts +9 -8
- package/dist/sdd/index.js +33 -3
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-gkvEZZfE.d.ts → secret-vault-BLsVmTIK.d.ts} +1 -1
- package/dist/security/index.d.ts +5 -5
- package/dist/security/index.js +39 -29
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-Bc7eWtT3.d.ts → selector-CXl2_y9W.d.ts} +1 -1
- package/dist/{session-event-bridge-D-araDEz.d.ts → session-event-bridge-Ccud20CC.d.ts} +1 -1
- package/dist/{session-reader-D7Dapswh.d.ts → session-reader-ZeXQmsmE.d.ts} +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/storage/index.d.ts +16 -12
- package/dist/storage/index.js +273 -100
- package/dist/storage/index.js.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +166 -31
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +22 -21
- package/dist/types/index.js +178 -70
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +22 -3
- package/dist/utils/index.js +197 -25
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -1
- package/skills/chimera/SKILL.md +1 -1
- package/skills/typescript-strict/SKILL.md +3 -3
- package/skills/typescript-strict/SKILL.save.md +1 -1
package/dist/types/index.js
CHANGED
|
@@ -29,6 +29,16 @@ function asText(content) {
|
|
|
29
29
|
if (typeof content === "string") return content;
|
|
30
30
|
return content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
// src/types/tool.ts
|
|
34
|
+
var ToolErrorCategory = /* @__PURE__ */ ((ToolErrorCategory2) => {
|
|
35
|
+
ToolErrorCategory2["TRANSIENT"] = "transient";
|
|
36
|
+
ToolErrorCategory2["NOT_FOUND"] = "not_found";
|
|
37
|
+
ToolErrorCategory2["PERMISSION"] = "permission";
|
|
38
|
+
ToolErrorCategory2["VALIDATION"] = "validation";
|
|
39
|
+
ToolErrorCategory2["FATAL"] = "fatal";
|
|
40
|
+
return ToolErrorCategory2;
|
|
41
|
+
})(ToolErrorCategory || {});
|
|
32
42
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
33
43
|
const dir = path6.dirname(targetPath);
|
|
34
44
|
await fs.mkdir(dir, { recursive: true });
|
|
@@ -504,7 +514,7 @@ function hasToolResult(msg) {
|
|
|
504
514
|
}
|
|
505
515
|
function toolUseIds(msg) {
|
|
506
516
|
const ids = /* @__PURE__ */ new Set();
|
|
507
|
-
if (
|
|
517
|
+
if (msg?.role !== "assistant") return ids;
|
|
508
518
|
for (const block of contentBlocks(msg)) {
|
|
509
519
|
if (block.type === "tool_use") ids.add(block.id);
|
|
510
520
|
}
|
|
@@ -512,7 +522,7 @@ function toolUseIds(msg) {
|
|
|
512
522
|
}
|
|
513
523
|
function toolResultIds(msg) {
|
|
514
524
|
const ids = /* @__PURE__ */ new Set();
|
|
515
|
-
if (
|
|
525
|
+
if (msg?.role !== "user") return ids;
|
|
516
526
|
for (const block of contentBlocks(msg)) {
|
|
517
527
|
if (block.type === "tool_result") ids.add(block.tool_use_id);
|
|
518
528
|
}
|
|
@@ -575,6 +585,41 @@ function truncate(s, max) {
|
|
|
575
585
|
return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
|
|
576
586
|
}
|
|
577
587
|
|
|
588
|
+
// src/utils/tool-subject.ts
|
|
589
|
+
var GLOB_METACHARACTERS = /[*?[\]]/g;
|
|
590
|
+
function escapeGlobSubject(value) {
|
|
591
|
+
return value.replace(GLOB_METACHARACTERS, (char) => `\\${char}`);
|
|
592
|
+
}
|
|
593
|
+
function normalizePathSubject(value) {
|
|
594
|
+
return escapeGlobSubject(value.replace(/\\/g, "/"));
|
|
595
|
+
}
|
|
596
|
+
function isPathSubjectKey(subjectKey) {
|
|
597
|
+
return subjectKey === "path" || subjectKey === "file" || subjectKey === "files";
|
|
598
|
+
}
|
|
599
|
+
function subjectForToolInput(toolName, input, subjectKey) {
|
|
600
|
+
if (!input || typeof input !== "object") return void 0;
|
|
601
|
+
const obj = input;
|
|
602
|
+
if (subjectKey) {
|
|
603
|
+
const value = obj[subjectKey];
|
|
604
|
+
if (typeof value === "string") {
|
|
605
|
+
return isPathSubjectKey(subjectKey) ? normalizePathSubject(value) : escapeGlobSubject(value);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (toolName === "bash" && typeof obj.command === "string") {
|
|
609
|
+
return escapeGlobSubject(obj.command);
|
|
610
|
+
}
|
|
611
|
+
if (typeof obj.path === "string") {
|
|
612
|
+
return normalizePathSubject(obj.path);
|
|
613
|
+
}
|
|
614
|
+
if (typeof obj.url === "string") {
|
|
615
|
+
return escapeGlobSubject(obj.url);
|
|
616
|
+
}
|
|
617
|
+
if (typeof obj.name === "string") {
|
|
618
|
+
return escapeGlobSubject(obj.name);
|
|
619
|
+
}
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
|
|
578
623
|
// src/utils/tool-wire-compact.ts
|
|
579
624
|
var TOOL_DESCRIPTION_MAX_CHARS = 640;
|
|
580
625
|
var SCHEMA_DESCRIPTION_MAX_CHARS = 180;
|
|
@@ -658,7 +703,7 @@ function calState(key) {
|
|
|
658
703
|
return state;
|
|
659
704
|
}
|
|
660
705
|
var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
|
|
661
|
-
var ESTIMATE_CACHE_MAX_SIZE =
|
|
706
|
+
var ESTIMATE_CACHE_MAX_SIZE = 5e4;
|
|
662
707
|
function getCachedEstimate(key, compute) {
|
|
663
708
|
const existing = ESTIMATE_CACHE.get(key);
|
|
664
709
|
if (existing !== void 0) return existing;
|
|
@@ -776,6 +821,7 @@ var GREP_MATCHES_PER_FILE = 3;
|
|
|
776
821
|
var DIFF_INLINE_LINE_LIMIT = 260;
|
|
777
822
|
var DIFF_HUNK_LIMIT = 8;
|
|
778
823
|
var DIFF_HUNK_CONTEXT = 14;
|
|
824
|
+
var GREP_LINE_RE = /^(.+?):(\d+):(.*)$/;
|
|
779
825
|
function createToolOutputSerializer(opts = {}) {
|
|
780
826
|
const capBytes = opts.perIterationOutputCapBytes ?? 1e5;
|
|
781
827
|
function serialize(value, context = {}) {
|
|
@@ -1161,7 +1207,7 @@ ${renderStringList(passthrough, "", 50)}`);
|
|
|
1161
1207
|
return sections.join("\n");
|
|
1162
1208
|
}
|
|
1163
1209
|
function parseGrepContentLine(line) {
|
|
1164
|
-
const match =
|
|
1210
|
+
const match = GREP_LINE_RE.exec(line);
|
|
1165
1211
|
if (!match?.[1] || !match[2]) return void 0;
|
|
1166
1212
|
return { file: match[1], line: match[2], text: match[3] ?? "" };
|
|
1167
1213
|
}
|
|
@@ -1179,22 +1225,20 @@ function compactDiff(diff) {
|
|
|
1179
1225
|
const hunks = lines.filter((line) => line.startsWith("@@")).length;
|
|
1180
1226
|
const added = lines.filter((line) => line.startsWith("+") && !line.startsWith("+++")).length;
|
|
1181
1227
|
const removed = lines.filter((line) => line.startsWith("-") && !line.startsWith("---")).length;
|
|
1182
|
-
const
|
|
1228
|
+
const intervals = [];
|
|
1183
1229
|
let hunkCount = 0;
|
|
1184
1230
|
for (let i = 0; i < lines.length; i++) {
|
|
1185
1231
|
const line = lines[i] ?? "";
|
|
1186
1232
|
if (line.startsWith("diff --git") || line.startsWith("--- ") || line.startsWith("+++ ")) {
|
|
1187
|
-
|
|
1233
|
+
intervals.push([i, i]);
|
|
1188
1234
|
continue;
|
|
1189
1235
|
}
|
|
1190
1236
|
if (!line.startsWith("@@")) continue;
|
|
1191
1237
|
if (hunkCount >= DIFF_HUNK_LIMIT) continue;
|
|
1192
1238
|
hunkCount++;
|
|
1193
|
-
|
|
1194
|
-
selected.add(j);
|
|
1195
|
-
}
|
|
1239
|
+
intervals.push([i, Math.min(lines.length - 1, i + DIFF_HUNK_CONTEXT)]);
|
|
1196
1240
|
}
|
|
1197
|
-
if (
|
|
1241
|
+
if (intervals.length === 0) {
|
|
1198
1242
|
return joinSections([
|
|
1199
1243
|
renderHeader("diff_summary", {
|
|
1200
1244
|
files: fileCount,
|
|
@@ -1207,17 +1251,29 @@ function compactDiff(diff) {
|
|
|
1207
1251
|
`[serializer omitted ${Math.max(0, lines.length - DIFF_INLINE_LINE_LIMIT)} diff line(s)]`
|
|
1208
1252
|
]);
|
|
1209
1253
|
}
|
|
1254
|
+
const merged = [intervals[0]];
|
|
1255
|
+
for (let i = 1; i < intervals.length; i++) {
|
|
1256
|
+
const last = merged[merged.length - 1];
|
|
1257
|
+
const current = intervals[i];
|
|
1258
|
+
if (current[0] <= last[1] + 1) {
|
|
1259
|
+
last[1] = Math.max(last[1], current[1]);
|
|
1260
|
+
} else {
|
|
1261
|
+
merged.push(current);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1210
1264
|
const excerpt = [];
|
|
1211
|
-
let
|
|
1212
|
-
for (const
|
|
1213
|
-
if (
|
|
1214
|
-
const omitted =
|
|
1265
|
+
let prevLine = -1;
|
|
1266
|
+
for (const [start, end] of merged) {
|
|
1267
|
+
if (start > prevLine + 1) {
|
|
1268
|
+
const omitted = prevLine === -1 ? start : start - prevLine - 1;
|
|
1215
1269
|
excerpt.push(`[serializer omitted ${omitted} diff line(s)]`);
|
|
1216
1270
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1271
|
+
for (let j = start; j <= end; j++) {
|
|
1272
|
+
excerpt.push(lines[j] ?? "");
|
|
1273
|
+
}
|
|
1274
|
+
prevLine = end;
|
|
1219
1275
|
}
|
|
1220
|
-
const trailing = lines.length -
|
|
1276
|
+
const trailing = lines.length - prevLine - 1;
|
|
1221
1277
|
if (trailing > 0) excerpt.push(`[serializer omitted ${trailing} trailing diff line(s)]`);
|
|
1222
1278
|
return joinSections([
|
|
1223
1279
|
renderHeader("diff_summary", {
|
|
@@ -1751,6 +1807,17 @@ function normalizeTokenSavingTier(val) {
|
|
|
1751
1807
|
]);
|
|
1752
1808
|
return validTiers.has(val) ? val : "off";
|
|
1753
1809
|
}
|
|
1810
|
+
var DEFAULT_TUI_THINKING_WORD = "thinking";
|
|
1811
|
+
var MAX_TUI_THINKING_WORD_LENGTH = 16;
|
|
1812
|
+
function normalizeTuiThinkingWord(value) {
|
|
1813
|
+
if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
|
|
1814
|
+
const word = value.trim();
|
|
1815
|
+
if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
|
|
1816
|
+
return DEFAULT_TUI_THINKING_WORD;
|
|
1817
|
+
}
|
|
1818
|
+
if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
|
|
1819
|
+
return word;
|
|
1820
|
+
}
|
|
1754
1821
|
|
|
1755
1822
|
// src/types/default-config.ts
|
|
1756
1823
|
var DEFAULT_TOOLS_CONFIG = Object.freeze({
|
|
@@ -2373,11 +2440,10 @@ var DefaultTokenCounter = class {
|
|
|
2373
2440
|
const price = model ? this.priceCache.get(model) : void 0;
|
|
2374
2441
|
if (price) {
|
|
2375
2442
|
this.applyPrice(usage, price);
|
|
2376
|
-
this.
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
} else if (this.registry && this.providerId && model) {
|
|
2443
|
+
this.emitAccounted();
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
if (this.registry && this.providerId && model) {
|
|
2381
2447
|
if (this.priceCache.size >= PRICE_CACHE_MAX_SIZE) {
|
|
2382
2448
|
const keys = [...this.priceCache.keys()];
|
|
2383
2449
|
this.priceCache.delete(keys[0] ?? "");
|
|
@@ -2387,16 +2453,16 @@ var DefaultTokenCounter = class {
|
|
|
2387
2453
|
const p = priceFromModel(m);
|
|
2388
2454
|
this.priceCache.set(model, p);
|
|
2389
2455
|
this.applyPrice(usage, p);
|
|
2390
|
-
this.events?.emit("token.accounted", {
|
|
2391
|
-
usage: this.total(),
|
|
2392
|
-
cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
|
|
2393
|
-
});
|
|
2394
2456
|
}
|
|
2457
|
+
this.emitAccounted();
|
|
2395
2458
|
}).catch(() => {
|
|
2396
2459
|
this.events?.emit("token.cost_estimate_unavailable", { model: model ?? "<unknown>" });
|
|
2460
|
+
this.emitAccounted();
|
|
2397
2461
|
return void 0;
|
|
2398
2462
|
});
|
|
2463
|
+
return;
|
|
2399
2464
|
}
|
|
2465
|
+
this.emitAccounted();
|
|
2400
2466
|
}
|
|
2401
2467
|
/** Synchronous variant for code paths that have already resolved the model. */
|
|
2402
2468
|
accountWithModel(usage, resolved) {
|
|
@@ -2413,10 +2479,7 @@ var DefaultTokenCounter = class {
|
|
|
2413
2479
|
}
|
|
2414
2480
|
this.priceCache.set(resolved.modelId, price);
|
|
2415
2481
|
this.applyPrice(usage, price);
|
|
2416
|
-
this.
|
|
2417
|
-
usage: this.total(),
|
|
2418
|
-
cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
|
|
2419
|
-
});
|
|
2482
|
+
this.emitAccounted();
|
|
2420
2483
|
}
|
|
2421
2484
|
total() {
|
|
2422
2485
|
return {
|
|
@@ -2449,6 +2512,12 @@ var DefaultTokenCounter = class {
|
|
|
2449
2512
|
invalidateCache() {
|
|
2450
2513
|
this.priceCache.clear();
|
|
2451
2514
|
}
|
|
2515
|
+
emitAccounted() {
|
|
2516
|
+
this.events?.emit("token.accounted", {
|
|
2517
|
+
usage: this.total(),
|
|
2518
|
+
cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2452
2521
|
reset() {
|
|
2453
2522
|
this.input = 0;
|
|
2454
2523
|
this.output = 0;
|
|
@@ -2456,6 +2525,9 @@ var DefaultTokenCounter = class {
|
|
|
2456
2525
|
this.cacheWrite = 0;
|
|
2457
2526
|
this.costInput = 0;
|
|
2458
2527
|
this.costOutput = 0;
|
|
2528
|
+
this.lastInput = 0;
|
|
2529
|
+
this.lastCacheRead = 0;
|
|
2530
|
+
this.emitAccounted();
|
|
2459
2531
|
}
|
|
2460
2532
|
applyPrice(usage, price) {
|
|
2461
2533
|
if (price.input) this.costInput += usage.input / 1e6 * price.input;
|
|
@@ -2463,8 +2535,14 @@ var DefaultTokenCounter = class {
|
|
|
2463
2535
|
if (usage.cacheRead && price.cacheRead) {
|
|
2464
2536
|
this.costInput += usage.cacheRead / 1e6 * price.cacheRead;
|
|
2465
2537
|
}
|
|
2466
|
-
|
|
2467
|
-
|
|
2538
|
+
const hasCacheWriteSplit = usage.cacheWrite5m !== void 0 || usage.cacheWrite1h !== void 0;
|
|
2539
|
+
const cacheWrite5m = usage.cacheWrite5m ?? (hasCacheWriteSplit ? 0 : usage.cacheWrite);
|
|
2540
|
+
const cacheWrite1h = usage.cacheWrite1h ?? 0;
|
|
2541
|
+
if (cacheWrite5m && (price.cacheWrite5m ?? price.cacheWrite)) {
|
|
2542
|
+
this.costInput += cacheWrite5m / 1e6 * (price.cacheWrite5m ?? price.cacheWrite ?? 0);
|
|
2543
|
+
}
|
|
2544
|
+
if (cacheWrite1h && (price.cacheWrite1h ?? price.cacheWrite)) {
|
|
2545
|
+
this.costInput += cacheWrite1h / 1e6 * (price.cacheWrite1h ?? price.cacheWrite ?? 0);
|
|
2468
2546
|
}
|
|
2469
2547
|
}
|
|
2470
2548
|
};
|
|
@@ -2473,7 +2551,9 @@ function priceFromModel(m) {
|
|
|
2473
2551
|
input: m.cost?.input,
|
|
2474
2552
|
output: m.cost?.output,
|
|
2475
2553
|
cacheRead: m.cost?.cache_read,
|
|
2476
|
-
cacheWrite: m.cost?.cache_write
|
|
2554
|
+
cacheWrite: m.cost?.cache_write,
|
|
2555
|
+
cacheWrite5m: m.cost?.cache_write_5m ?? m.cost?.cache_write,
|
|
2556
|
+
cacheWrite1h: m.cost?.cache_write_1h ?? (m.cost?.input !== void 0 ? m.cost.input * 2 : void 0)
|
|
2477
2557
|
};
|
|
2478
2558
|
}
|
|
2479
2559
|
function round4(n) {
|
|
@@ -3605,10 +3685,11 @@ var DefaultModelsRegistry = class {
|
|
|
3605
3685
|
capabilities: {
|
|
3606
3686
|
tools: model.tool_call ?? false,
|
|
3607
3687
|
vision: Boolean(model.modalities?.input?.includes("image")),
|
|
3608
|
-
reasoning: model.reasoning ??
|
|
3688
|
+
reasoning: model.reasoning ?? model.reasoningConfig !== void 0,
|
|
3609
3689
|
maxContext: model.limit?.context ?? 0,
|
|
3610
3690
|
maxOutput: model.limit?.output,
|
|
3611
|
-
knowledge: model.knowledge
|
|
3691
|
+
knowledge: model.knowledge,
|
|
3692
|
+
reasoningConfig: model.reasoningConfig
|
|
3612
3693
|
},
|
|
3613
3694
|
cost: model.cost
|
|
3614
3695
|
};
|
|
@@ -4489,7 +4570,7 @@ ${errorDetails}`,
|
|
|
4489
4570
|
return { result, tool, durationMs: Date.now() - start };
|
|
4490
4571
|
}
|
|
4491
4572
|
} else {
|
|
4492
|
-
const suggestedPattern =
|
|
4573
|
+
const suggestedPattern = subjectForToolInput(tool.name, use.input, tool.subjectKey) ?? tool.name;
|
|
4493
4574
|
const pending = {
|
|
4494
4575
|
type: "tool_confirm_pending",
|
|
4495
4576
|
toolUseId: use.id,
|
|
@@ -4535,6 +4616,7 @@ ${post.additionalContext}`;
|
|
|
4535
4616
|
} catch (err) {
|
|
4536
4617
|
const msg = toErrorMessage(err);
|
|
4537
4618
|
const scrubbed = this.opts.secretScrubber.scrub(msg);
|
|
4619
|
+
const { category, retryable, detail } = classifyToolError(err);
|
|
4538
4620
|
this.opts.renderer?.writeToolResult(tool.name, scrubbed, true);
|
|
4539
4621
|
const result = {
|
|
4540
4622
|
type: "tool_result",
|
|
@@ -4545,6 +4627,9 @@ ${post.additionalContext}`;
|
|
|
4545
4627
|
budget = this.budgetForString(result.content, budget);
|
|
4546
4628
|
if (err instanceof Error) span?.recordError(err);
|
|
4547
4629
|
span?.setAttribute("tool.is_error", true);
|
|
4630
|
+
span?.setAttribute("tool.error_category", category);
|
|
4631
|
+
span?.setAttribute("tool.error_retryable", retryable);
|
|
4632
|
+
if (detail) span?.setAttribute("tool.error_detail", detail);
|
|
4548
4633
|
return { result, tool, durationMs: Date.now() - start };
|
|
4549
4634
|
} finally {
|
|
4550
4635
|
span?.end();
|
|
@@ -4556,6 +4641,9 @@ ${post.additionalContext}`;
|
|
|
4556
4641
|
} catch (err) {
|
|
4557
4642
|
const msg = toErrorMessage(err);
|
|
4558
4643
|
const scrubbed = this.opts.secretScrubber.scrub(msg);
|
|
4644
|
+
const { category, retryable, detail } = classifyToolError(err);
|
|
4645
|
+
const tool = this.registry.get(use.name);
|
|
4646
|
+
this.opts.renderer?.writeToolResult(tool?.name ?? use.name, scrubbed, true);
|
|
4559
4647
|
const result = {
|
|
4560
4648
|
type: "tool_result",
|
|
4561
4649
|
tool_use_id: use.id,
|
|
@@ -4563,7 +4651,7 @@ ${post.additionalContext}`;
|
|
|
4563
4651
|
is_error: true
|
|
4564
4652
|
};
|
|
4565
4653
|
budget = this.budgetForString(result.content, budget);
|
|
4566
|
-
return { result, tool
|
|
4654
|
+
return { result, tool, durationMs: 0 };
|
|
4567
4655
|
}
|
|
4568
4656
|
};
|
|
4569
4657
|
if (strategy === "sequential") {
|
|
@@ -4768,38 +4856,6 @@ ${excerpt}`;
|
|
|
4768
4856
|
budgetForString(content, budget) {
|
|
4769
4857
|
return Math.max(0, budget - Buffer.byteLength(content, "utf8"));
|
|
4770
4858
|
}
|
|
4771
|
-
/**
|
|
4772
|
-
* Compute the suggestedPattern string for a tool+input pair.
|
|
4773
|
-
* Matches the logic in DefaultPermissionPolicy so the TUI shows the
|
|
4774
|
-
* same subject that the trust file would use.
|
|
4775
|
-
*/
|
|
4776
|
-
subjectFor(toolName, input, subjectKey) {
|
|
4777
|
-
if (!input || typeof input !== "object") return void 0;
|
|
4778
|
-
const obj = input;
|
|
4779
|
-
const globChars = /[*?[\]]/g;
|
|
4780
|
-
const escapeGlob = (s) => s.replace(globChars, (c) => `\\${c}`);
|
|
4781
|
-
const normalizePath = (s) => escapeGlob(s.replace(/\\/g, "/"));
|
|
4782
|
-
if (subjectKey) {
|
|
4783
|
-
const v = obj[subjectKey];
|
|
4784
|
-
if (typeof v === "string") {
|
|
4785
|
-
const isPathKey = subjectKey === "path" || subjectKey === "file" || subjectKey === "files";
|
|
4786
|
-
return isPathKey ? normalizePath(v) : escapeGlob(v);
|
|
4787
|
-
}
|
|
4788
|
-
}
|
|
4789
|
-
if (toolName === "bash" && typeof obj.command === "string") {
|
|
4790
|
-
return escapeGlob(obj.command);
|
|
4791
|
-
}
|
|
4792
|
-
if (typeof obj.path === "string") {
|
|
4793
|
-
return normalizePath(obj.path);
|
|
4794
|
-
}
|
|
4795
|
-
if (typeof obj.url === "string") {
|
|
4796
|
-
return escapeGlob(obj.url);
|
|
4797
|
-
}
|
|
4798
|
-
if (typeof obj.name === "string") {
|
|
4799
|
-
return escapeGlob(obj.name);
|
|
4800
|
-
}
|
|
4801
|
-
return void 0;
|
|
4802
|
-
}
|
|
4803
4859
|
};
|
|
4804
4860
|
function clampTimeoutMs(timeoutMs, maxTimeoutMs) {
|
|
4805
4861
|
const fallback = 3e5;
|
|
@@ -4827,6 +4883,58 @@ function extractMalformedRaw(input) {
|
|
|
4827
4883
|
}
|
|
4828
4884
|
}
|
|
4829
4885
|
var TOOL_OUTPUT_ARTIFACT_THRESHOLD_BYTES = 64 * 1024;
|
|
4886
|
+
function classifyToolError(err) {
|
|
4887
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
4888
|
+
return { category: "fatal" /* FATAL */, retryable: false, detail: "aborted" };
|
|
4889
|
+
}
|
|
4890
|
+
if (err instanceof Error && "code" in err) {
|
|
4891
|
+
const code = err.code;
|
|
4892
|
+
switch (code) {
|
|
4893
|
+
case "ETIMEDOUT":
|
|
4894
|
+
case "ECONNRESET":
|
|
4895
|
+
case "ECONNREFUSED":
|
|
4896
|
+
case "ENETUNREACH":
|
|
4897
|
+
case "EHOSTUNREACH":
|
|
4898
|
+
return { category: "transient" /* TRANSIENT */, retryable: true, detail: code };
|
|
4899
|
+
case "ENOENT":
|
|
4900
|
+
case "ENOTDIR":
|
|
4901
|
+
return { category: "not_found" /* NOT_FOUND */, retryable: false, detail: code };
|
|
4902
|
+
case "EACCES":
|
|
4903
|
+
case "EPERM":
|
|
4904
|
+
return { category: "permission" /* PERMISSION */, retryable: false, detail: code };
|
|
4905
|
+
case "EBUSY":
|
|
4906
|
+
case "EMFILE":
|
|
4907
|
+
case "ENFILE":
|
|
4908
|
+
return { category: "transient" /* TRANSIENT */, retryable: true, detail: code };
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
if (err instanceof Error && "response" in err) {
|
|
4912
|
+
const response = err.response;
|
|
4913
|
+
const status = response?.status;
|
|
4914
|
+
if (status !== void 0) {
|
|
4915
|
+
if (status === 429 || status === 503 || status === 502 || status === 504) {
|
|
4916
|
+
return { category: "transient" /* TRANSIENT */, retryable: true, detail: `HTTP ${status}` };
|
|
4917
|
+
}
|
|
4918
|
+
if (status === 404 || status === 410) {
|
|
4919
|
+
return { category: "not_found" /* NOT_FOUND */, retryable: false, detail: `HTTP ${status}` };
|
|
4920
|
+
}
|
|
4921
|
+
if (status === 401 || status === 403) {
|
|
4922
|
+
return { category: "permission" /* PERMISSION */, retryable: false, detail: `HTTP ${status}` };
|
|
4923
|
+
}
|
|
4924
|
+
if (status === 400) {
|
|
4925
|
+
return { category: "validation" /* VALIDATION */, retryable: false, detail: `HTTP ${status}` };
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
if (err instanceof Error && err.message.includes("validation")) {
|
|
4930
|
+
return { category: "validation" /* VALIDATION */, retryable: false, detail: "validation" };
|
|
4931
|
+
}
|
|
4932
|
+
return {
|
|
4933
|
+
category: "fatal" /* FATAL */,
|
|
4934
|
+
retryable: false,
|
|
4935
|
+
detail: err instanceof Error ? err.message.slice(0, 100) : String(err).slice(0, 100)
|
|
4936
|
+
};
|
|
4937
|
+
}
|
|
4830
4938
|
async function maybePersistLargeToolOutput(toolName, content, budget) {
|
|
4831
4939
|
const bytes = Buffer.byteLength(content, "utf8");
|
|
4832
4940
|
if (bytes <= Math.min(TOOL_OUTPUT_ARTIFACT_THRESHOLD_BYTES, Math.max(0, budget))) {
|
|
@@ -5409,6 +5517,6 @@ function renderPlainText(meta, events) {
|
|
|
5409
5517
|
return lines.join("\n");
|
|
5410
5518
|
}
|
|
5411
5519
|
|
|
5412
|
-
export { AgentError, CONTEXT_WINDOW_MODES, ConfigError, Context, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SESSION_PRUNE_DAYS, DEFAULT_SPEC_TEMPLATE, DEFAULT_TOOLS_CONFIG, DefaultErrorHandler, DefaultLogger, DefaultModelsRegistry, DefaultPathResolver, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultTokenCounter, ERROR_CODES, FsError, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, MEMORY_TYPE_LABELS, PluginError, ProviderError, SddError, SessionError, StreamHangError, ToolError, ToolExecutor, WrongStackError, asBlocks, asText, buildRecoveryStrategies, classifyFamily, computeTaskProgress, createMessage, decryptConfigSecrets, encryptConfigSecrets, findCriticalPath, formatContextWindowModeList, getContextWindowMode, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSddError, isSecretField, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, migratePlaintextSecrets, noOpLogger, normalizeTokenSavingTier, resolveContextWindowPolicy, rewriteConfigEncrypted, rotateConfigKeys, toWrongStackError, topologicalSort };
|
|
5520
|
+
export { AgentError, CONTEXT_WINDOW_MODES, ConfigError, Context, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SESSION_PRUNE_DAYS, DEFAULT_SPEC_TEMPLATE, DEFAULT_TOOLS_CONFIG, DEFAULT_TUI_THINKING_WORD, DefaultErrorHandler, DefaultLogger, DefaultModelsRegistry, DefaultPathResolver, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultTokenCounter, ERROR_CODES, FsError, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, MAX_TUI_THINKING_WORD_LENGTH, MEMORY_TYPE_LABELS, PluginError, ProviderError, SddError, SessionError, StreamHangError, ToolError, ToolErrorCategory, ToolExecutor, WrongStackError, asBlocks, asText, buildRecoveryStrategies, classifyFamily, computeTaskProgress, createMessage, decryptConfigSecrets, encryptConfigSecrets, findCriticalPath, formatContextWindowModeList, getContextWindowMode, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSddError, isSecretField, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, migratePlaintextSecrets, noOpLogger, normalizeTokenSavingTier, normalizeTuiThinkingWord, resolveContextWindowPolicy, rewriteConfigEncrypted, rotateConfigKeys, toWrongStackError, topologicalSort };
|
|
5413
5521
|
//# sourceMappingURL=index.js.map
|
|
5414
5522
|
//# sourceMappingURL=index.js.map
|