@wrongstack/core 0.265.1 → 0.268.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 (75) hide show
  1. package/dist/{agent-bridge-DrkBxszZ.d.ts → agent-bridge-UhojbpWx.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DM2pP-B6.d.ts → agent-subagent-runner-Bvtf1o9K.d.ts} +25 -7
  3. package/dist/{brain-BXd_61kQ.d.ts → brain-69wzMKp1.d.ts} +73 -1
  4. package/dist/{compactor-B8pOf45Y.d.ts → compactor-CBQAJoDc.d.ts} +19 -1
  5. package/dist/{config-BMCj_XDs.d.ts → config-VKfOZ-6X.d.ts} +122 -3
  6. package/dist/{context-MRk5PhNv.d.ts → context-C0U8B9NF.d.ts} +88 -1
  7. package/dist/coordination/index.d.ts +57 -161
  8. package/dist/coordination/index.js +471 -177
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -25
  11. package/dist/defaults/index.js +1818 -844
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +72 -16
  14. package/dist/execution/index.js +1270 -265
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +7 -6
  18. package/dist/global-mailbox-KByEFFBa.d.ts +663 -0
  19. package/dist/{goal-preamble-DvHDSKSe.d.ts → goal-preamble-CrYjmdw4.d.ts} +28 -11
  20. package/dist/{goal-store-DtLMySNb.d.ts → goal-store-Y_zdLZ3q.d.ts} +1 -1
  21. package/dist/hq/index.d.ts +195 -0
  22. package/dist/hq/index.js +1884 -0
  23. package/dist/hq/index.js.map +1 -0
  24. package/dist/index-BfaS-f_m.d.ts +82 -0
  25. package/dist/{index-B-ch8K9C.d.ts → index-CtQnmkaS.d.ts} +8 -8
  26. package/dist/{index-CEDeNodM.d.ts → index-gCv830d7.d.ts} +5 -5
  27. package/dist/index.d.ts +124 -47
  28. package/dist/index.js +5600 -2662
  29. package/dist/index.js.map +1 -1
  30. package/dist/infrastructure/index.d.ts +6 -6
  31. package/dist/infrastructure/index.js +117 -19
  32. package/dist/infrastructure/index.js.map +1 -1
  33. package/dist/kernel/index.d.ts +10 -9
  34. package/dist/kernel/index.js.map +1 -1
  35. package/dist/{pipeline-DPDxH_7m.d.ts → mailbox-types-Ct2hJq0P.d.ts} +1 -244
  36. package/dist/{mcp-servers-2x4w6Jn9.d.ts → mcp-servers-HT3Fi7Bl.d.ts} +10 -4
  37. package/dist/models/index.d.ts +5 -5
  38. package/dist/models/index.js +33 -3
  39. package/dist/models/index.js.map +1 -1
  40. package/dist/{models-registry-DmJlKuNp.d.ts → models-registry-Bvcl3Vaa.d.ts} +1 -1
  41. package/dist/{multi-agent-coordinator-DyCkCZnU.d.ts → multi-agent-coordinator-BACjsmkC.d.ts} +1 -1
  42. package/dist/{null-fleet-bus-CG9QY2aP.d.ts → null-fleet-bus-DA7fvhUg.d.ts} +14 -9
  43. package/dist/observability/index.d.ts +2 -2
  44. package/dist/{parallel-eternal-engine-Jw9uhEoT.d.ts → parallel-eternal-engine-Ci71gYu_.d.ts} +11 -15
  45. package/dist/{path-resolver-Dy2ej-gE.d.ts → path-resolver-O1IJnmKE.d.ts} +4 -3
  46. package/dist/{permission-B9SB45lp.d.ts → permission-Bd-57Lbl.d.ts} +1 -1
  47. package/dist/{permission-policy-CkjSXabK.d.ts → permission-policy-uNXC6Kge.d.ts} +2 -3
  48. package/dist/pipeline-BDNvENyV.d.ts +245 -0
  49. package/dist/{plan-templates-CzD9GnAU.d.ts → plan-templates-EMsalEtN.d.ts} +5 -5
  50. package/dist/{llm-selector-C0tfTCUe.d.ts → provider-model-resolve-CEb9x886.d.ts} +40 -3
  51. package/dist/{provider-runner-DMa70ODu.d.ts → provider-runner-DWJbpo70.d.ts} +3 -3
  52. package/dist/{retry-policy-CN0khdlj.d.ts → retry-policy-C3s_lvdK.d.ts} +1 -1
  53. package/dist/sdd/index.d.ts +9 -8
  54. package/dist/sdd/index.js +44 -14
  55. package/dist/sdd/index.js.map +1 -1
  56. package/dist/{secret-vault-B2yw84VT.d.ts → secret-vault-Cgduf5xL.d.ts} +2 -2
  57. package/dist/security/index.d.ts +5 -67
  58. package/dist/security/index.js +129 -99
  59. package/dist/security/index.js.map +1 -1
  60. package/dist/{selector-CzHh_igB.d.ts → selector-47LBnBVk.d.ts} +1 -1
  61. package/dist/{session-event-bridge-BUI6Jf-4.d.ts → session-event-bridge-Cw7oqmW2.d.ts} +1 -1
  62. package/dist/{session-reader-CMgdMSRP.d.ts → session-reader-DD4v2Obw.d.ts} +1 -1
  63. package/dist/storage/index.d.ts +14 -12
  64. package/dist/storage/index.js +144 -120
  65. package/dist/storage/index.js.map +1 -1
  66. package/dist/tools/index.d.ts +4 -2
  67. package/dist/tools/index.js +166 -31
  68. package/dist/tools/index.js.map +1 -1
  69. package/dist/types/index.d.ts +20 -19
  70. package/dist/types/index.js +1358 -476
  71. package/dist/types/index.js.map +1 -1
  72. package/dist/utils/index.d.ts +472 -405
  73. package/dist/utils/index.js +2321 -1193
  74. package/dist/utils/index.js.map +1 -1
  75. package/package.json +5 -1
@@ -1,9 +1,9 @@
1
1
  export { D as DefaultLogger, a as DefaultLoggerOptions, L as LogFormat } from '../logger-DmmQhf4P.js';
2
- export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-Dy2ej-gE.js';
3
- export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, p as playwrightServer, s as sentinelServer, q as slackServer, z as zaiVisionServer } from '../mcp-servers-2x4w6Jn9.js';
2
+ export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-O1IJnmKE.js';
3
+ export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, p as playwrightServer, s as sentinelServer, q as slackServer, r as sshManagerServer, z as zaiVisionServer } from '../mcp-servers-HT3Fi7Bl.js';
4
4
  import '../logger-B63L5bTg.js';
5
- import '../brain-BXd_61kQ.js';
6
- import '../context-MRk5PhNv.js';
7
- import '../config-BMCj_XDs.js';
5
+ import '../brain-69wzMKp1.js';
6
+ import '../context-C0U8B9NF.js';
7
+ import '../config-VKfOZ-6X.js';
8
8
  import '../path-resolver-CPRj4bFY.js';
9
- import '../compactor-B8pOf45Y.js';
9
+ import '../compactor-CBQAJoDc.js';
@@ -287,11 +287,10 @@ var DefaultTokenCounter = class {
287
287
  const price = model ? this.priceCache.get(model) : void 0;
288
288
  if (price) {
289
289
  this.applyPrice(usage, price);
290
- this.events?.emit("token.accounted", {
291
- usage: this.total(),
292
- cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
293
- });
294
- } else if (this.registry && this.providerId && model) {
290
+ this.emitAccounted();
291
+ return;
292
+ }
293
+ if (this.registry && this.providerId && model) {
295
294
  if (this.priceCache.size >= PRICE_CACHE_MAX_SIZE) {
296
295
  const keys = [...this.priceCache.keys()];
297
296
  this.priceCache.delete(keys[0] ?? "");
@@ -301,16 +300,16 @@ var DefaultTokenCounter = class {
301
300
  const p = priceFromModel(m);
302
301
  this.priceCache.set(model, p);
303
302
  this.applyPrice(usage, p);
304
- this.events?.emit("token.accounted", {
305
- usage: this.total(),
306
- cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
307
- });
308
303
  }
304
+ this.emitAccounted();
309
305
  }).catch(() => {
310
306
  this.events?.emit("token.cost_estimate_unavailable", { model: model ?? "<unknown>" });
307
+ this.emitAccounted();
311
308
  return void 0;
312
309
  });
310
+ return;
313
311
  }
312
+ this.emitAccounted();
314
313
  }
315
314
  /** Synchronous variant for code paths that have already resolved the model. */
316
315
  accountWithModel(usage, resolved) {
@@ -327,10 +326,7 @@ var DefaultTokenCounter = class {
327
326
  }
328
327
  this.priceCache.set(resolved.modelId, price);
329
328
  this.applyPrice(usage, price);
330
- this.events?.emit("token.accounted", {
331
- usage: this.total(),
332
- cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
333
- });
329
+ this.emitAccounted();
334
330
  }
335
331
  total() {
336
332
  return {
@@ -363,6 +359,12 @@ var DefaultTokenCounter = class {
363
359
  invalidateCache() {
364
360
  this.priceCache.clear();
365
361
  }
362
+ emitAccounted() {
363
+ this.events?.emit("token.accounted", {
364
+ usage: this.total(),
365
+ cost: { input: this.costInput, output: this.costOutput, total: this.costInput + this.costOutput }
366
+ });
367
+ }
366
368
  reset() {
367
369
  this.input = 0;
368
370
  this.output = 0;
@@ -370,6 +372,9 @@ var DefaultTokenCounter = class {
370
372
  this.cacheWrite = 0;
371
373
  this.costInput = 0;
372
374
  this.costOutput = 0;
375
+ this.lastInput = 0;
376
+ this.lastCacheRead = 0;
377
+ this.emitAccounted();
373
378
  }
374
379
  applyPrice(usage, price) {
375
380
  if (price.input) this.costInput += usage.input / 1e6 * price.input;
@@ -377,8 +382,14 @@ var DefaultTokenCounter = class {
377
382
  if (usage.cacheRead && price.cacheRead) {
378
383
  this.costInput += usage.cacheRead / 1e6 * price.cacheRead;
379
384
  }
380
- if (usage.cacheWrite && price.cacheWrite) {
381
- this.costInput += usage.cacheWrite / 1e6 * price.cacheWrite;
385
+ const hasCacheWriteSplit = usage.cacheWrite5m !== void 0 || usage.cacheWrite1h !== void 0;
386
+ const cacheWrite5m = usage.cacheWrite5m ?? (hasCacheWriteSplit ? 0 : usage.cacheWrite);
387
+ const cacheWrite1h = usage.cacheWrite1h ?? 0;
388
+ if (cacheWrite5m && (price.cacheWrite5m ?? price.cacheWrite)) {
389
+ this.costInput += cacheWrite5m / 1e6 * (price.cacheWrite5m ?? price.cacheWrite ?? 0);
390
+ }
391
+ if (cacheWrite1h && (price.cacheWrite1h ?? price.cacheWrite)) {
392
+ this.costInput += cacheWrite1h / 1e6 * (price.cacheWrite1h ?? price.cacheWrite ?? 0);
382
393
  }
383
394
  }
384
395
  };
@@ -387,7 +398,9 @@ function priceFromModel(m) {
387
398
  input: m.cost?.input,
388
399
  output: m.cost?.output,
389
400
  cacheRead: m.cost?.cache_read,
390
- cacheWrite: m.cost?.cache_write
401
+ cacheWrite: m.cost?.cache_write,
402
+ cacheWrite5m: m.cost?.cache_write_5m ?? m.cost?.cache_write,
403
+ cacheWrite1h: m.cost?.cache_write_1h ?? (m.cost?.input !== void 0 ? m.cost.input * 2 : void 0)
391
404
  };
392
405
  }
393
406
  function round4(n) {
@@ -513,6 +526,19 @@ var miniMaxVisionServer = () => ({
513
526
  allowedTools: ["understand_image"],
514
527
  permission: "auto"
515
528
  });
529
+ var sshManagerServer = () => ({
530
+ name: "ssh",
531
+ description: "Remote SSH management \u2014 execute commands, transfer files, tunnels, health checks (mcp-ssh-manager)",
532
+ transport: "stdio",
533
+ command: "npx",
534
+ args: ["-y", "mcp-ssh-manager"],
535
+ env: {
536
+ MCP_SSH_COMPACT_JSON: "true",
537
+ MCP_SSH_DEFAULT_TIMEOUT: "120000"
538
+ },
539
+ permission: "confirm",
540
+ requestTimeoutMs: 18e4
541
+ });
516
542
  var allServers = () => ({
517
543
  filesystem: { ...filesystemServer(), enabled: false },
518
544
  github: { ...githubServer(), enabled: false },
@@ -526,7 +552,8 @@ var allServers = () => ({
526
552
  sentinel: { ...sentinelServer(), enabled: false },
527
553
  "zai-vision": { ...zaiVisionServer(), enabled: false },
528
554
  "minimax-vision": { ...miniMaxVisionServer(), enabled: false },
529
- playwright: { ...playwrightServer(), enabled: false }
555
+ playwright: { ...playwrightServer(), enabled: false },
556
+ ssh: { ...sshManagerServer(), enabled: false }
530
557
  });
531
558
 
532
559
  // src/utils/expect-defined.ts
@@ -631,6 +658,76 @@ function isEmptyMessage(msg) {
631
658
  return msg.content.length === 0;
632
659
  }
633
660
 
661
+ // src/utils/tool-wire-compact.ts
662
+ var TOOL_DESCRIPTION_MAX_CHARS = 640;
663
+ var SCHEMA_DESCRIPTION_MAX_CHARS = 180;
664
+ var compactCache = /* @__PURE__ */ new WeakMap();
665
+ function compactToolDefinitionForWire(tool, opts = {}) {
666
+ const useDefaultOptions = opts.descriptionMaxChars === void 0 && opts.schemaDescriptionMaxChars === void 0;
667
+ if (useDefaultOptions && typeof tool === "object" && tool !== null) {
668
+ const cached = compactCache.get(tool);
669
+ if (cached) return cached;
670
+ }
671
+ const compact = {
672
+ name: tool.name,
673
+ description: compactDescription(
674
+ tool.description ?? "",
675
+ opts.descriptionMaxChars ?? TOOL_DESCRIPTION_MAX_CHARS
676
+ ),
677
+ inputSchema: compactSchemaDescriptions(
678
+ tool.inputSchema,
679
+ opts.schemaDescriptionMaxChars ?? SCHEMA_DESCRIPTION_MAX_CHARS
680
+ )
681
+ };
682
+ if (useDefaultOptions && typeof tool === "object" && tool !== null) {
683
+ compactCache.set(tool, compact);
684
+ }
685
+ return compact;
686
+ }
687
+ function compactSchemaDescriptions(schema, maxDescriptionChars = SCHEMA_DESCRIPTION_MAX_CHARS) {
688
+ const compact = compactSchemaNode(schema, maxDescriptionChars);
689
+ return isRecord(compact) ? compact : { type: "object", properties: {} };
690
+ }
691
+ function compactSchemaNode(node, maxDescriptionChars) {
692
+ if (Array.isArray(node)) {
693
+ return node.map((item) => compactSchemaNode(item, maxDescriptionChars));
694
+ }
695
+ if (!isRecord(node)) return node;
696
+ const out = {};
697
+ for (const [key, value] of Object.entries(node)) {
698
+ if (key === "description" && typeof value === "string") {
699
+ out[key] = compactDescription(value, maxDescriptionChars);
700
+ } else {
701
+ out[key] = compactSchemaNode(value, maxDescriptionChars);
702
+ }
703
+ }
704
+ return out;
705
+ }
706
+ function compactDescription(text, maxChars) {
707
+ const normalized = text.replace(/\s+/g, " ").trim();
708
+ if (normalized.length <= maxChars) return normalized;
709
+ if (maxChars <= 20) return normalized.slice(0, maxChars);
710
+ const hardLimit = maxChars - 12;
711
+ const boundary = findSemanticBoundary(normalized, hardLimit);
712
+ const head = normalized.slice(0, boundary > 0 ? boundary : hardLimit).trimEnd();
713
+ return `${head} ...`;
714
+ }
715
+ function findSemanticBoundary(text, limit) {
716
+ const punctuation = Math.max(
717
+ text.lastIndexOf(". ", limit),
718
+ text.lastIndexOf("; ", limit),
719
+ text.lastIndexOf(": ", limit)
720
+ );
721
+ if (punctuation >= Math.floor(limit * 0.45)) return punctuation + 1;
722
+ const comma = text.lastIndexOf(", ", limit);
723
+ if (comma >= Math.floor(limit * 0.6)) return comma + 1;
724
+ const space = text.lastIndexOf(" ", limit);
725
+ return space >= Math.floor(limit * 0.6) ? space : limit;
726
+ }
727
+ function isRecord(value) {
728
+ return !!value && typeof value === "object" && !Array.isArray(value);
729
+ }
730
+
634
731
  // src/utils/token-estimate.ts
635
732
  var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
636
733
  var CALIBRATION_GLOBAL_KEY = "__global__";
@@ -697,7 +794,8 @@ function estimateMessageTokens(messages) {
697
794
  function estimateToolDefTokens(tool) {
698
795
  const cached = tool._estDefTokens;
699
796
  if (typeof cached === "number" && cached > 0) return cached;
700
- return RoughTokenEstimate(tool.name) + RoughTokenEstimate(tool.description ?? "") + RoughTokenEstimate(JSON.stringify(tool.inputSchema));
797
+ const compact = compactToolDefinitionForWire(tool);
798
+ return RoughTokenEstimate(tool.name) + RoughTokenEstimate(compact.description) + RoughTokenEstimate(JSON.stringify(compact.inputSchema));
701
799
  }
702
800
  function estimateRequestTokens(messages, systemPrompt, tools, calibrationKey = CALIBRATION_GLOBAL_KEY) {
703
801
  let messagesTokens = 0;
@@ -1009,6 +1107,6 @@ function createContextManagerTool(opts = {}) {
1009
1107
  }
1010
1108
  var contextManagerTool = createContextManagerTool();
1011
1109
 
1012
- export { DefaultLogger, DefaultPathResolver, DefaultTokenCounter, allServers, awsServer, blockServer, braveSearchServer, context7Server, contextManagerTool, createContextManagerTool, everArtServer, filesystemServer, githubServer, googleMapsServer, miniMaxVisionServer, playwrightServer, sentinelServer, slackServer, zaiVisionServer };
1110
+ export { DefaultLogger, DefaultPathResolver, DefaultTokenCounter, allServers, awsServer, blockServer, braveSearchServer, context7Server, contextManagerTool, createContextManagerTool, everArtServer, filesystemServer, githubServer, googleMapsServer, miniMaxVisionServer, playwrightServer, sentinelServer, slackServer, sshManagerServer, zaiVisionServer };
1013
1111
  //# sourceMappingURL=index.js.map
1014
1112
  //# sourceMappingURL=index.js.map