@wrongstack/core 0.291.1 → 0.292.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.
Files changed (127) hide show
  1. package/dist/coordination/director-tools.d.ts.map +1 -1
  2. package/dist/coordination/index.js +113 -113
  3. package/dist/coordination/index.js.map +3 -3
  4. package/dist/core/agent-loop.d.ts.map +1 -1
  5. package/dist/core/agent-response.d.ts.map +1 -1
  6. package/dist/core/context.d.ts +10 -0
  7. package/dist/core/context.d.ts.map +1 -1
  8. package/dist/core/system-prompt-builder.d.ts +20 -1
  9. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  10. package/dist/defaults/index.d.ts +1 -0
  11. package/dist/defaults/index.d.ts.map +1 -1
  12. package/dist/defaults/index.js +3132 -2440
  13. package/dist/defaults/index.js.map +4 -4
  14. package/dist/execution/auto-compaction-middleware.d.ts +34 -2
  15. package/dist/execution/auto-compaction-middleware.d.ts.map +1 -1
  16. package/dist/execution/compaction-core.d.ts +59 -0
  17. package/dist/execution/compaction-core.d.ts.map +1 -1
  18. package/dist/execution/compactor.d.ts.map +1 -1
  19. package/dist/execution/error-handler.d.ts +7 -0
  20. package/dist/execution/error-handler.d.ts.map +1 -1
  21. package/dist/execution/index.d.ts +1 -0
  22. package/dist/execution/index.d.ts.map +1 -1
  23. package/dist/execution/index.js +4677 -3924
  24. package/dist/execution/index.js.map +4 -4
  25. package/dist/execution/intelligent-compactor.d.ts.map +1 -1
  26. package/dist/execution/model-runtime.d.ts.map +1 -1
  27. package/dist/execution/selective-compactor.d.ts +10 -0
  28. package/dist/execution/selective-compactor.d.ts.map +1 -1
  29. package/dist/execution/subagent-compaction.d.ts +24 -0
  30. package/dist/execution/subagent-compaction.d.ts.map +1 -0
  31. package/dist/hq/alerts.d.ts +5 -0
  32. package/dist/hq/alerts.d.ts.map +1 -1
  33. package/dist/hq/auth-audit.d.ts +115 -0
  34. package/dist/hq/auth-audit.d.ts.map +1 -0
  35. package/dist/hq/auth-store.d.ts +98 -2
  36. package/dist/hq/auth-store.d.ts.map +1 -1
  37. package/dist/hq/brain-bridge.d.ts +2 -8
  38. package/dist/hq/brain-bridge.d.ts.map +1 -1
  39. package/dist/hq/bridge-context.d.ts +74 -0
  40. package/dist/hq/bridge-context.d.ts.map +1 -0
  41. package/dist/hq/cost-bridge.d.ts +4 -10
  42. package/dist/hq/cost-bridge.d.ts.map +1 -1
  43. package/dist/hq/fleet-bridge.d.ts +2 -8
  44. package/dist/hq/fleet-bridge.d.ts.map +1 -1
  45. package/dist/hq/index.d.ts +2 -0
  46. package/dist/hq/index.d.ts.map +1 -1
  47. package/dist/hq/index.js +358 -222
  48. package/dist/hq/index.js.map +4 -4
  49. package/dist/hq/protocol/session.d.ts +13 -0
  50. package/dist/hq/protocol/session.d.ts.map +1 -1
  51. package/dist/hq/tool-bridge.d.ts +2 -8
  52. package/dist/hq/tool-bridge.d.ts.map +1 -1
  53. package/dist/hq/worktree-bridge.d.ts +2 -8
  54. package/dist/hq/worktree-bridge.d.ts.map +1 -1
  55. package/dist/index.d.ts +4 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +6054 -4741
  58. package/dist/index.js.map +4 -4
  59. package/dist/infrastructure/index.js +32 -15
  60. package/dist/infrastructure/index.js.map +2 -2
  61. package/dist/infrastructure/provider-cache-ledger.d.ts +48 -0
  62. package/dist/infrastructure/provider-cache-ledger.d.ts.map +1 -0
  63. package/dist/infrastructure/token-counter.d.ts +4 -2
  64. package/dist/infrastructure/token-counter.d.ts.map +1 -1
  65. package/dist/kernel/events/brain-events.d.ts +2 -0
  66. package/dist/kernel/events/brain-events.d.ts.map +1 -1
  67. package/dist/kernel/events/memory-events.d.ts +102 -0
  68. package/dist/kernel/events/memory-events.d.ts.map +1 -1
  69. package/dist/kernel/events/session-events.d.ts +35 -0
  70. package/dist/kernel/events/session-events.d.ts.map +1 -1
  71. package/dist/models/index.js +161 -78
  72. package/dist/models/index.js.map +3 -3
  73. package/dist/models/llm-selector.d.ts.map +1 -1
  74. package/dist/notifications/index.d.ts +40 -0
  75. package/dist/notifications/index.d.ts.map +1 -0
  76. package/dist/notifications/notifier-impl.d.ts +34 -0
  77. package/dist/notifications/notifier-impl.d.ts.map +1 -0
  78. package/dist/notifications/notifier.d.ts +95 -0
  79. package/dist/notifications/notifier.d.ts.map +1 -0
  80. package/dist/notifications/types.d.ts +111 -0
  81. package/dist/notifications/types.d.ts.map +1 -0
  82. package/dist/plugin/api.d.ts +10 -1
  83. package/dist/plugin/api.d.ts.map +1 -1
  84. package/dist/registry/provider-registry.d.ts +1 -1
  85. package/dist/registry/provider-registry.d.ts.map +1 -1
  86. package/dist/security/index.js +15 -15
  87. package/dist/security/index.js.map +3 -3
  88. package/dist/skills/index.js +80 -80
  89. package/dist/skills/index.js.map +3 -3
  90. package/dist/storage/config-loader.d.ts +3 -5
  91. package/dist/storage/config-loader.d.ts.map +1 -1
  92. package/dist/storage/index.js +325 -259
  93. package/dist/storage/index.js.map +4 -4
  94. package/dist/storage/memory-consolidator.d.ts +14 -2
  95. package/dist/storage/memory-consolidator.d.ts.map +1 -1
  96. package/dist/storage/queue-store.d.ts +2 -0
  97. package/dist/storage/queue-store.d.ts.map +1 -1
  98. package/dist/tools/index.js +6 -6
  99. package/dist/tools/index.js.map +3 -3
  100. package/dist/tools/mcp-control.d.ts +1 -1
  101. package/dist/types/config.d.ts +64 -20
  102. package/dist/types/config.d.ts.map +1 -1
  103. package/dist/types/index.js +60 -34
  104. package/dist/types/index.js.map +3 -3
  105. package/dist/types/plugin.d.ts +11 -0
  106. package/dist/types/plugin.d.ts.map +1 -1
  107. package/dist/types/provider.d.ts +31 -0
  108. package/dist/types/provider.d.ts.map +1 -1
  109. package/dist/types/token-counter.d.ts +8 -1
  110. package/dist/types/token-counter.d.ts.map +1 -1
  111. package/dist/utils/cache-key.d.ts +19 -0
  112. package/dist/utils/cache-key.d.ts.map +1 -0
  113. package/dist/utils/compaction-preview.d.ts +8 -0
  114. package/dist/utils/compaction-preview.d.ts.map +1 -0
  115. package/dist/utils/context-breakdown.d.ts +59 -0
  116. package/dist/utils/context-breakdown.d.ts.map +1 -0
  117. package/dist/utils/context-evidence.d.ts +22 -0
  118. package/dist/utils/context-evidence.d.ts.map +1 -1
  119. package/dist/utils/index.d.ts +2 -0
  120. package/dist/utils/index.d.ts.map +1 -1
  121. package/dist/utils/index.js +1730 -1543
  122. package/dist/utils/index.js.map +4 -4
  123. package/dist/utils/token-estimate.d.ts +27 -0
  124. package/dist/utils/token-estimate.d.ts.map +1 -1
  125. package/instructions/llm/memory-consolidator.md +19 -3
  126. package/instructions/system.md +10 -2
  127. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"director-tools.d.ts","sourceRoot":"","sources":["../../src/coordination/director-tools.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,EACL,KAAK,QAAQ,EAId,MAAM,eAAe,CAAC;AAevB,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAuJ/F;AA+CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACtC,IAAI,CA+LN;AA8SD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA4CvD;AAwBD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACtC,IAAI,CAudN;AAyND,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA0D3D;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6CpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA+B1D;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6BvD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAmB1D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAqB7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAoHtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA+E5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAwC1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAiB7D"}
1
+ {"version":3,"file":"director-tools.d.ts","sourceRoot":"","sources":["../../src/coordination/director-tools.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,EACL,KAAK,QAAQ,EAId,MAAM,eAAe,CAAC;AAevB,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAwJ/F;AA+CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACtC,IAAI,CA+LN;AA8SD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6CvD;AAwBD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACtC,IAAI,CAudN;AAyND,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA0D3D;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6CpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA+B1D;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6BvD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAmB1D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAqB7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAoHtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA+E5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAwC1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAiB7D"}
@@ -328,6 +328,112 @@ function expectDefined(value, label) {
328
328
  return value;
329
329
  }
330
330
 
331
+ // src/utils/message-invariants.ts
332
+ function repairToolUseAdjacency(messages) {
333
+ const removedToolUses = [];
334
+ const removedToolResults = [];
335
+ let removedMessages = 0;
336
+ let changed = false;
337
+ const out = [];
338
+ for (let i = 0; i < messages.length; i++) {
339
+ const original = expectDefined(messages[i]);
340
+ let msg = original;
341
+ if (hasToolUse(msg)) {
342
+ const nextIds = toolResultIds(messages[i + 1]);
343
+ const filtered = mapContent(msg, (blocks) => {
344
+ const next = [];
345
+ for (const block of blocks) {
346
+ if (block.type === "tool_use" && !nextIds.has(block.id)) {
347
+ removedToolUses.push(block.id);
348
+ changed = true;
349
+ continue;
350
+ }
351
+ next.push(block);
352
+ }
353
+ return next;
354
+ });
355
+ msg = filtered ?? msg;
356
+ }
357
+ if (hasToolResult(msg)) {
358
+ const allowed = toolUseIds(out[out.length - 1]);
359
+ const filtered = mapContent(msg, (blocks) => {
360
+ const next = [];
361
+ for (const block of blocks) {
362
+ if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
363
+ removedToolResults.push(block.tool_use_id);
364
+ changed = true;
365
+ continue;
366
+ }
367
+ next.push(block);
368
+ }
369
+ return next;
370
+ });
371
+ msg = filtered ?? msg;
372
+ }
373
+ if (isEmptyMessage(msg)) {
374
+ removedMessages++;
375
+ changed = true;
376
+ continue;
377
+ }
378
+ out.push(msg);
379
+ }
380
+ return {
381
+ messages: changed ? out : messages,
382
+ report: { changed, removedToolUses, removedToolResults, removedMessages }
383
+ };
384
+ }
385
+ function hasToolUse(msg) {
386
+ return contentBlocks(msg).some((b) => b.type === "tool_use");
387
+ }
388
+ function hasToolResult(msg) {
389
+ return contentBlocks(msg).some((b) => b.type === "tool_result");
390
+ }
391
+ function toolUseIds(msg) {
392
+ const ids = /* @__PURE__ */ new Set();
393
+ if (msg?.role !== "assistant") return ids;
394
+ for (const block of contentBlocks(msg)) {
395
+ if (block.type === "tool_use") ids.add(block.id);
396
+ }
397
+ return ids;
398
+ }
399
+ function toolResultIds(msg) {
400
+ const ids = /* @__PURE__ */ new Set();
401
+ if (msg?.role !== "user") return ids;
402
+ for (const block of contentBlocks(msg)) {
403
+ if (block.type === "tool_result") ids.add(block.tool_use_id);
404
+ }
405
+ return ids;
406
+ }
407
+ function contentBlocks(msg) {
408
+ return msg && Array.isArray(msg.content) ? msg.content : [];
409
+ }
410
+ function mapContent(msg, fn) {
411
+ if (!Array.isArray(msg.content)) return msg;
412
+ const next = fn(msg.content);
413
+ if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
414
+ return msg;
415
+ }
416
+ return { ...msg, content: next };
417
+ }
418
+ function hasMeaningfulContent(content) {
419
+ if (typeof content === "string") return content.trim().length > 0;
420
+ for (const block of content) {
421
+ if (block.type === "text") {
422
+ if (block.text.trim().length > 0) return true;
423
+ continue;
424
+ }
425
+ if (block.type === "thinking") {
426
+ if (block.thinking.trim().length > 0 || block.signature) return true;
427
+ continue;
428
+ }
429
+ return true;
430
+ }
431
+ return false;
432
+ }
433
+ function isEmptyMessage(msg) {
434
+ return !hasMeaningfulContent(msg.content);
435
+ }
436
+
331
437
  // src/utils/glob-expand.ts
332
438
  import * as fsp from "node:fs/promises";
333
439
  import { isAbsolute, resolve } from "node:path";
@@ -455,112 +561,6 @@ async function expandGlob(pattern) {
455
561
  return [...results];
456
562
  }
457
563
 
458
- // src/utils/message-invariants.ts
459
- function repairToolUseAdjacency(messages) {
460
- const removedToolUses = [];
461
- const removedToolResults = [];
462
- let removedMessages = 0;
463
- let changed = false;
464
- const out = [];
465
- for (let i = 0; i < messages.length; i++) {
466
- const original = expectDefined(messages[i]);
467
- let msg = original;
468
- if (hasToolUse(msg)) {
469
- const nextIds = toolResultIds(messages[i + 1]);
470
- const filtered = mapContent(msg, (blocks) => {
471
- const next = [];
472
- for (const block of blocks) {
473
- if (block.type === "tool_use" && !nextIds.has(block.id)) {
474
- removedToolUses.push(block.id);
475
- changed = true;
476
- continue;
477
- }
478
- next.push(block);
479
- }
480
- return next;
481
- });
482
- msg = filtered ?? msg;
483
- }
484
- if (hasToolResult(msg)) {
485
- const allowed = toolUseIds(out[out.length - 1]);
486
- const filtered = mapContent(msg, (blocks) => {
487
- const next = [];
488
- for (const block of blocks) {
489
- if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
490
- removedToolResults.push(block.tool_use_id);
491
- changed = true;
492
- continue;
493
- }
494
- next.push(block);
495
- }
496
- return next;
497
- });
498
- msg = filtered ?? msg;
499
- }
500
- if (isEmptyMessage(msg)) {
501
- removedMessages++;
502
- changed = true;
503
- continue;
504
- }
505
- out.push(msg);
506
- }
507
- return {
508
- messages: changed ? out : messages,
509
- report: { changed, removedToolUses, removedToolResults, removedMessages }
510
- };
511
- }
512
- function hasToolUse(msg) {
513
- return contentBlocks(msg).some((b) => b.type === "tool_use");
514
- }
515
- function hasToolResult(msg) {
516
- return contentBlocks(msg).some((b) => b.type === "tool_result");
517
- }
518
- function toolUseIds(msg) {
519
- const ids = /* @__PURE__ */ new Set();
520
- if (msg?.role !== "assistant") return ids;
521
- for (const block of contentBlocks(msg)) {
522
- if (block.type === "tool_use") ids.add(block.id);
523
- }
524
- return ids;
525
- }
526
- function toolResultIds(msg) {
527
- const ids = /* @__PURE__ */ new Set();
528
- if (msg?.role !== "user") return ids;
529
- for (const block of contentBlocks(msg)) {
530
- if (block.type === "tool_result") ids.add(block.tool_use_id);
531
- }
532
- return ids;
533
- }
534
- function contentBlocks(msg) {
535
- return msg && Array.isArray(msg.content) ? msg.content : [];
536
- }
537
- function mapContent(msg, fn) {
538
- if (!Array.isArray(msg.content)) return msg;
539
- const next = fn(msg.content);
540
- if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
541
- return msg;
542
- }
543
- return { ...msg, content: next };
544
- }
545
- function hasMeaningfulContent(content) {
546
- if (typeof content === "string") return content.trim().length > 0;
547
- for (const block of content) {
548
- if (block.type === "text") {
549
- if (block.text.trim().length > 0) return true;
550
- continue;
551
- }
552
- if (block.type === "thinking") {
553
- if (block.thinking.trim().length > 0 || block.signature) return true;
554
- continue;
555
- }
556
- return true;
557
- }
558
- return false;
559
- }
560
- function isEmptyMessage(msg) {
561
- return !hasMeaningfulContent(msg.content);
562
- }
563
-
564
564
  // src/utils/safe-json.ts
565
565
  function safeParse(input, maxBytes = 5e6) {
566
566
  if (Buffer.byteLength(input, "utf8") > maxBytes) {
@@ -5235,8 +5235,8 @@ function createDelegateTool(opts) {
5235
5235
  };
5236
5236
  return {
5237
5237
  name: "delegate",
5238
- description: "Hand a piece of work to a subagent and wait for its result. Has own context, LLM call, auto-extending budget. Can continue remaining work with a fresh subagent on partial completion (maxHandoffs, default 1). Workers cannot recursively spawn. Use roster roles when possible; otherwise pass `name` + `task`.",
5239
- usageHint: "Set `task` to a complete instruction. Pick `role` from roster or pass `name` for free-form. Override `timeoutMs`/`maxIterations`/`maxToolCalls` only when needed.",
5238
+ description: "Hand a piece of work to a subagent and block until it returns. This call is synchronous: the leader's iteration pauses for the full duration of the subagent's run. (Multiple `delegate` calls fired in the same assistant turn still parallelize through the provider's parallel-tool-call surface, but each one eats wall-clock time \u2014 so for fan-out you actually control, reach for the async path below.) Use `delegate` when your next step genuinely needs the subagent's verdict \u2014 a review, a fact-check, a sign-off. Has own context, own LLM call, auto-extending budget, and a partial-completion handoff path (maxHandoffs, default 1). Workers cannot recursively spawn.\n\n**Do NOT use `delegate` for fan-out you control.** Multiple sequential `delegate` calls each block the leader, wasting wall-clock time. For independent investigations you want to run in parallel \u2014 security scan + bug hunt + perf review on the same PR \u2014 use the async tool family: `spawn_subagent` to create each worker (returns a `subagentId` immediately), `assign_task` to queue work on it (returns a `taskId` immediately), then the `await_tasks` tool with `{mode: 'any'}` to fold the first useful result into the next decision while the rest keep churning. Reach for `delegate` only when the result gates your next move.",
5239
+ usageHint: "Set `task` to a complete instruction. Pick `role` from roster or pass `name` for free-form. Raise `maxHandoffs` (default 1, cap 8) for multi-day or multi-refactor tasks; pass larger `timeoutMs`/`maxIterations`/`maxToolCalls` only when needed. For parallel work, use `spawn_subagent` + `assign_task` + `await_tasks` instead.",
5240
5240
  permission: "auto",
5241
5241
  mutating: false,
5242
5242
  managesOwnTimeout: true,
@@ -6511,8 +6511,8 @@ function makeSpawnTool(director, roster) {
6511
6511
  };
6512
6512
  return {
6513
6513
  name: "spawn_subagent",
6514
- description: "Create a new subagent under this director. Returns the subagent id.",
6515
- usageHint: "Pass `role` (matches the roster), `description` (smart dispatch to best agent), or `name` + `provider`/`model`. Returns `{ subagentId }`.",
6514
+ description: "Create a new subagent under this director (own LLM context, own budget). NON-BLOCKING: returns a `subagentId` immediately without triggering any model call. Pair with `assign_task` to send work and `await_tasks` to retrieve the result later \u2014 this is the async-delegation pattern that lets the leader keep working while the subagent runs in its own context.",
6515
+ usageHint: "Pass `role` (matches the roster), `description` (smart dispatch to best agent), or `name` + `provider`/`model`. Returns `{ subagentId }`. Use this instead of `delegate` when you want to fan out to multiple subagents or keep the leader unblocked while work runs in parallel.",
6516
6516
  permission: "auto",
6517
6517
  mutating: false,
6518
6518
  capabilities: [ToolCapabilities.SUBAGENT_SPAWN],
@@ -6994,7 +6994,7 @@ function makeAssignTool(director) {
6994
6994
  };
6995
6995
  return {
6996
6996
  name: "assign_task",
6997
- description: "Hand a task to a previously spawned subagent. Returns the task id.",
6997
+ description: "Queue a task on a previously spawned subagent. NON-BLOCKING: returns a `taskId` IMMEDIATELY \u2014 the subagent processes the task on its next iteration with its own LLM budget. The `taskId` is the durable handle for retrieving the result later via `await_tasks`, `roll_up`, or `ask_result`. Many `assign_task` calls can be in flight in parallel against the same or different subagents. This is the primary tool for fan-out work; do NOT use `delegate` to spawn multiple investigations sequentially.",
6998
6998
  permission: "auto",
6999
6999
  mutating: false,
7000
7000
  capabilities: [ToolCapabilities.SUBAGENT_SPAWN],
@@ -7521,7 +7521,7 @@ function resultErrorText(result) {
7521
7521
  function makeAwaitTasksTool(director) {
7522
7522
  return {
7523
7523
  name: "await_tasks",
7524
- description: 'Wait for assigned tasks. mode:"all" (default) blocks until EVERY named task completes and returns all results. mode:"any" returns as soon as AT LEAST ONE completes \u2014 use it for independent tasks so you can handle each finisher immediately (reassign work, spawn helpers) instead of idling on the slowest; call again with the returned `pending` ids to pick up the next finisher.',
7524
+ description: 'Block until one or more `taskId`s complete, then return their results. The subagents keep running in the background \u2014 only the leader\'s iteration pauses, which is the point: this is the correct tool to retrieve a result you started earlier with `assign_task`. mode:"all" (default) blocks until EVERY named task completes. mode:"any" returns as soon as AT LEAST ONE completes \u2014 use it for independent tasks so you can handle each finisher immediately (reassign work, spawn helpers) instead of idling on the slowest; call again with the returned `pending` ids to pick up the next finisher. The pattern "fan out via assign_task, then await_tasks({mode:\'any\'})" is the async replacement for serial `delegate` calls.',
7525
7525
  permission: "auto",
7526
7526
  mutating: false,
7527
7527
  capabilities: [ToolCapabilities.COORDINATION_FLEET_READ],
@@ -8192,7 +8192,7 @@ function hashStr(s) {
8192
8192
  }
8193
8193
 
8194
8194
  // src/types/provider.ts
8195
- var CONTEXT_OVERFLOW_RE = /context.length|context.window|max.*tokens?.*exceeded|prompt is too long|too long|exceeds the context|\btokens\b.*exceed|context_length_exceeded/i;
8195
+ var CONTEXT_OVERFLOW_RE = /context.length|context.window|maximum context|max.*tokens?.*exceeded|prompt is too long|too long|exceeds the context|\btokens\b.*exceed|too many tokens|reduce the length|resulted in \d+ tokens|input.{0,12}too (?:large|long)|context_length_exceeded/i;
8196
8196
  var CONTENT_FILTER_RE = /content.(filter|policy|moderation)|safety (system|filter)/i;
8197
8197
  var QUOTA_EXHAUSTED_RE = /(?:insufficient|exhausted|depleted|exceeded|no|not enough)[-_\s]*(?:quota|credit|balance)|(?:quota|credit|balance)[-_\s]*(?:exhausted|depleted|exceeded|insufficient)|billing[_\s-]*(?:hard[_\s-]*)?limit|payment required|spending limit|plan limit/i;
8198
8198
  function classifyProviderError(status, body, message) {