@wrongstack/core 0.87.0 → 0.89.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.
Files changed (49) hide show
  1. package/dist/{agent-bridge-C9P_HPez.d.ts → agent-bridge-B8F2ORwg.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-2Aq0jOSj.d.ts → agent-subagent-runner-CQaLFNnA.d.ts} +3 -2
  3. package/dist/coordination/index.d.ts +7 -7
  4. package/dist/coordination/index.js +183 -56
  5. package/dist/coordination/index.js.map +1 -1
  6. package/dist/{default-config-DEXI4jsl.d.ts → default-config-CXsDvOmP.d.ts} +3 -1
  7. package/dist/defaults/index.d.ts +10 -10
  8. package/dist/defaults/index.js +268 -68
  9. package/dist/defaults/index.js.map +1 -1
  10. package/dist/{events-DnRqXaZ3.d.ts → events-DzyLtja6.d.ts} +6 -0
  11. package/dist/execution/index.d.ts +5 -5
  12. package/dist/execution/index.js +56 -19
  13. package/dist/execution/index.js.map +1 -1
  14. package/dist/extension/index.d.ts +2 -2
  15. package/dist/{index-BNOLadHw.d.ts → index-Ca_lOmKl.d.ts} +2 -2
  16. package/dist/{index-N0_c4bHQ.d.ts → index-Dx-CnrDN.d.ts} +3 -1
  17. package/dist/index.d.ts +24 -21
  18. package/dist/index.js +448 -179
  19. package/dist/index.js.map +1 -1
  20. package/dist/infrastructure/index.d.ts +2 -2
  21. package/dist/infrastructure/index.js +12 -3
  22. package/dist/infrastructure/index.js.map +1 -1
  23. package/dist/kernel/index.d.ts +3 -3
  24. package/dist/kernel/index.js +17 -0
  25. package/dist/kernel/index.js.map +1 -1
  26. package/dist/models/index.js.map +1 -1
  27. package/dist/{multi-agent-coordinator-DllpCVkF.d.ts → multi-agent-coordinator-Da9nd8Ic.d.ts} +1 -1
  28. package/dist/{null-fleet-bus-BY0AN-sr.d.ts → null-fleet-bus-CHJOXv3t.d.ts} +11 -5
  29. package/dist/observability/index.d.ts +1 -1
  30. package/dist/{parallel-eternal-engine-D402RASp.d.ts → parallel-eternal-engine-DyMCj2Pw.d.ts} +4 -3
  31. package/dist/{path-resolver-UPFTsDyD.d.ts → path-resolver-TjBlRKyH.d.ts} +1 -1
  32. package/dist/{plan-templates-DRvPgkfZ.d.ts → plan-templates-D9UhwoGh.d.ts} +1 -1
  33. package/dist/{provider-runner-COAJM8tC.d.ts → provider-runner-BEPWwkxH.d.ts} +1 -1
  34. package/dist/sdd/index.d.ts +3 -3
  35. package/dist/sdd/index.js +89 -19
  36. package/dist/sdd/index.js.map +1 -1
  37. package/dist/security/index.js +18 -2
  38. package/dist/security/index.js.map +1 -1
  39. package/dist/skills/index.js.map +1 -1
  40. package/dist/storage/index.d.ts +4 -4
  41. package/dist/storage/index.js +149 -90
  42. package/dist/storage/index.js.map +1 -1
  43. package/dist/types/index.d.ts +10 -10
  44. package/dist/types/index.js +44 -7
  45. package/dist/types/index.js.map +1 -1
  46. package/dist/utils/index.d.ts +6 -1
  47. package/dist/utils/index.js +51 -3
  48. package/dist/utils/index.js.map +1 -1
  49. package/package.json +1 -1
@@ -753,6 +753,12 @@ declare class EventBus {
753
753
  */
754
754
  onRegex(regex: RegExp, fn: (event: string, payload: unknown) => void): () => void;
755
755
  emit<E extends EventName>(event: E, payload: EventMap[E]): void;
756
+ /**
757
+ * Emit a plugin-defined event that is intentionally outside EventMap.
758
+ * Custom events are delivered to wildcard/pattern listeners only; typed
759
+ * listeners remain reserved for core EventMap keys.
760
+ */
761
+ emitCustom(event: string, payload: unknown): void;
756
762
  clear(): void;
757
763
  /**
758
764
  * V2-D: introspection helper. Pass an `event` to count handlers for a
@@ -1,19 +1,19 @@
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-D402RASp.js';
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-DyMCj2Pw.js';
2
2
  import { m as Provider, d as Context } from '../context-ToHAp4-U.js';
3
3
  import { a as Compactor, C as CompactReport } from '../compactor-CJq7LQev.js';
4
4
  import { M as MessageSelector } from '../selector-11-fm95U.js';
5
- import { E as EventBus } from '../events-DnRqXaZ3.js';
5
+ import { E as EventBus } from '../events-DzyLtja6.js';
6
6
  import { b as MiddlewareHandler } from '../system-prompt-C0rLCeyn.js';
7
7
  import { a as SessionEventBridge } from '../session-event-bridge-D0u-x576.js';
8
8
  import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-_DZ7dN-T.js';
9
- import { A as Agent, D as DoneCondition } from '../agent-subagent-runner-2Aq0jOSj.js';
10
- import { R as RunResult, S as SystemPromptContributor } from '../index-N0_c4bHQ.js';
9
+ import { A as Agent, D as DoneCondition } from '../agent-subagent-runner-CQaLFNnA.js';
10
+ import { R as RunResult, S as SystemPromptContributor } from '../index-Dx-CnrDN.js';
11
11
  import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-BJeF2DwY.js';
12
12
  import { a as WstackPaths } from '../wstack-paths-BQMvEllz.js';
13
13
  import '../retry-policy-DSu6O6rD.js';
14
14
  import '../models-registry-Be3osGt5.js';
15
15
  import '../goal-store-DvWLNu52.js';
16
- import '../multi-agent-coordinator-DllpCVkF.js';
16
+ import '../multi-agent-coordinator-Da9nd8Ic.js';
17
17
  import 'node:events';
18
18
  import '../logger-B72yyPc6.js';
19
19
  import '../observability-CoSNZdhX.js';
@@ -1468,6 +1468,7 @@ var ToolExecutor = class {
1468
1468
  this.registry = registry;
1469
1469
  this.opts = opts;
1470
1470
  this.iterationTimeoutMs = opts.iterationTimeoutMs ?? 3e5;
1471
+ this.maxToolTimeoutMs = opts.maxToolTimeoutMs ?? 3e5;
1471
1472
  this.serializer = createToolOutputSerializer({
1472
1473
  perIterationOutputCapBytes: opts.perIterationOutputCapBytes ?? 1e5
1473
1474
  });
@@ -1476,6 +1477,7 @@ var ToolExecutor = class {
1476
1477
  opts;
1477
1478
  serializer;
1478
1479
  iterationTimeoutMs;
1480
+ maxToolTimeoutMs;
1479
1481
  /**
1480
1482
  * Clear the interactive confirm awaiter so the executor returns
1481
1483
  * `ToolConfirmPendingResult` instead of blocking on stdin. Used by
@@ -1713,7 +1715,10 @@ ${post.additionalContext}` };
1713
1715
  if (parentSignal.reason instanceof Error) throw parentSignal.reason;
1714
1716
  throw new Error(typeof parentSignal.reason === "string" ? parentSignal.reason : "aborted");
1715
1717
  }
1716
- const timeoutMs = tool.timeoutMs ?? this.iterationTimeoutMs;
1718
+ const timeoutMs = clampTimeoutMs(
1719
+ tool.timeoutMs ?? this.iterationTimeoutMs,
1720
+ this.maxToolTimeoutMs
1721
+ );
1717
1722
  const ctrl = new AbortController();
1718
1723
  const timer = setTimeout(() => ctrl.abort(new Error("tool timeout")), timeoutMs);
1719
1724
  const combined = AbortSignal.any([parentSignal, ctrl.signal]);
@@ -1848,6 +1853,12 @@ ${excerpt}`;
1848
1853
  return void 0;
1849
1854
  }
1850
1855
  };
1856
+ function clampTimeoutMs(timeoutMs, maxTimeoutMs) {
1857
+ const fallback = 3e5;
1858
+ const finiteTimeout = Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : fallback;
1859
+ const finiteMax = Number.isFinite(maxTimeoutMs) && maxTimeoutMs > 0 ? maxTimeoutMs : fallback;
1860
+ return Math.max(1, Math.min(finiteTimeout, finiteMax));
1861
+ }
1851
1862
  var MALFORMED_ARG_MARKERS = ["__raw", "__raw_arguments", "_raw"];
1852
1863
  function hasMalformedArguments(input) {
1853
1864
  if (!input || typeof input !== "object" || Array.isArray(input)) return false;
@@ -2756,6 +2767,7 @@ ${recentJournal}` : "No prior iterations.",
2756
2767
  };
2757
2768
 
2758
2769
  // src/coordination/subagent-budget.ts
2770
+ var TIMEOUT_PREEMPT_FRACTION = 0.85;
2759
2771
  var BudgetExceededError = class extends Error {
2760
2772
  kind;
2761
2773
  limit;
@@ -6336,15 +6348,38 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6336
6348
  }
6337
6349
  const start = Date.now();
6338
6350
  let timer = null;
6351
+ let preemptedForLimit = null;
6339
6352
  const timeoutPromise = new Promise((_, reject) => {
6340
6353
  const armFor = (ms) => {
6341
6354
  if (timer) clearTimeout(timer);
6342
6355
  timer = setTimeout(onTick, Math.max(0, ms));
6343
6356
  };
6344
6357
  const scheduleNext = () => {
6345
- const wallRemaining = initialTimeoutMs === void 0 ? Number.POSITIVE_INFINITY : (budget.limits.timeoutMs ?? initialTimeoutMs) - (Date.now() - start);
6358
+ const wallLimit = budget.limits.timeoutMs ?? initialTimeoutMs;
6359
+ const wallRemaining = initialTimeoutMs === void 0 ? Number.POSITIVE_INFINITY : wallLimit - (Date.now() - start);
6346
6360
  const idleRemaining = idleLimitMs === void 0 ? Number.POSITIVE_INFINITY : (budget.limits.idleTimeoutMs ?? idleLimitMs) - budget.idleMs();
6347
- armFor(Math.max(25, Math.min(wallRemaining, idleRemaining)));
6361
+ const preemptRemaining = initialTimeoutMs === void 0 || preemptedForLimit === wallLimit ? Number.POSITIVE_INFINITY : wallLimit * TIMEOUT_PREEMPT_FRACTION - (Date.now() - start);
6362
+ armFor(Math.max(25, Math.min(wallRemaining, idleRemaining, preemptRemaining)));
6363
+ };
6364
+ const negotiateTimeout = async (used, limit) => {
6365
+ const handler = budget.onThreshold;
6366
+ if (!handler) return "stop";
6367
+ const result = handler({
6368
+ kind: "timeout",
6369
+ used,
6370
+ limit,
6371
+ requestDecision: () => new Promise((resolveDecision) => {
6372
+ budget._events?.emit("budget.threshold_reached", {
6373
+ kind: "timeout",
6374
+ used,
6375
+ limit,
6376
+ timeoutMs: 6e4,
6377
+ extend: (extra) => resolveDecision({ extend: extra }),
6378
+ deny: () => resolveDecision("stop")
6379
+ });
6380
+ })
6381
+ });
6382
+ return typeof result === "string" ? result : await result;
6348
6383
  };
6349
6384
  const onTick = async () => {
6350
6385
  const elapsed = Date.now() - start;
@@ -6357,6 +6392,21 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6357
6392
  reject(new BudgetExceededError("timeout", idleLimit ?? 0, budget.idleMs()));
6358
6393
  return;
6359
6394
  }
6395
+ if (wallLimit !== void 0 && !wallExceeded && budget.onThreshold && preemptedForLimit !== wallLimit && elapsed >= wallLimit * TIMEOUT_PREEMPT_FRACTION) {
6396
+ try {
6397
+ const decision = await negotiateTimeout(elapsed, wallLimit);
6398
+ if (typeof decision !== "string" && decision.extend.timeoutMs !== void 0) {
6399
+ budget.limits.timeoutMs = decision.extend.timeoutMs;
6400
+ preemptedForLimit = null;
6401
+ } else {
6402
+ preemptedForLimit = wallLimit;
6403
+ }
6404
+ } catch {
6405
+ preemptedForLimit = wallLimit;
6406
+ }
6407
+ scheduleNext();
6408
+ return;
6409
+ }
6360
6410
  if (!wallExceeded) {
6361
6411
  scheduleNext();
6362
6412
  return;
@@ -6368,28 +6418,15 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6368
6418
  return;
6369
6419
  }
6370
6420
  try {
6371
- const result = budget.onThreshold({
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;
6421
+ const decision = await negotiateTimeout(elapsed, limit);
6387
6422
  if (decision === "continue" || decision === "throw" || decision === "stop") {
6423
+ preemptedForLimit = null;
6388
6424
  armFor(Math.max(1e3, limit));
6389
6425
  return;
6390
6426
  }
6391
6427
  if (decision.extend.timeoutMs !== void 0) {
6392
6428
  budget.limits.timeoutMs = decision.extend.timeoutMs;
6429
+ preemptedForLimit = null;
6393
6430
  scheduleNext();
6394
6431
  return;
6395
6432
  }