@wrongstack/core 0.275.0 → 0.276.2

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 (83) hide show
  1. package/dist/{agent-bridge-D9JkPvJ0.d.ts → agent-bridge-D7A-eu3C.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-CArSFKFl.d.ts → agent-subagent-runner-CEuw4ATz.d.ts} +16 -10
  3. package/dist/{brain-DCkB5_e7.d.ts → brain-BLOyN5ZP.d.ts} +127 -1
  4. package/dist/{compactor-CzSvxM1g.d.ts → compactor-DcBpaJsI.d.ts} +1 -1
  5. package/dist/{config-BzFRKkg7.d.ts → config-Bf5mj-ad.d.ts} +20 -2
  6. package/dist/{context-BrLe8pJy.d.ts → context-CLnUMW5g.d.ts} +40 -2
  7. package/dist/coordination/index.d.ts +43 -24
  8. package/dist/coordination/index.js +849 -648
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +28 -28
  11. package/dist/defaults/index.js +1636 -845
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +16 -16
  14. package/dist/execution/index.js +218 -49
  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 -7
  18. package/dist/extension/index.js.map +1 -1
  19. package/dist/{global-mailbox-CXkugtNQ.d.ts → global-mailbox-Iqfkgmwu.d.ts} +3 -3
  20. package/dist/{goal-store-DUwdbdoY.d.ts → goal-store-DGb6b5Ed.d.ts} +1 -1
  21. package/dist/hq/index.d.ts +6 -6
  22. package/dist/hq/index.js +178 -75
  23. package/dist/hq/index.js.map +1 -1
  24. package/dist/{index-CtlizLTK.d.ts → index-Cn0NOshr.d.ts} +10 -5
  25. package/dist/{index-neOCEy6q.d.ts → index-L4RZN9jJ.d.ts} +2 -2
  26. package/dist/index.d.ts +56 -48
  27. package/dist/index.js +2789 -1546
  28. package/dist/index.js.map +1 -1
  29. package/dist/infrastructure/index.d.ts +6 -6
  30. package/dist/infrastructure/index.js +26 -7
  31. package/dist/infrastructure/index.js.map +1 -1
  32. package/dist/kernel/index.d.ts +20 -12
  33. package/dist/kernel/index.js +55 -9
  34. package/dist/kernel/index.js.map +1 -1
  35. package/dist/{mailbox-types-_7gaY0Rl.d.ts → mailbox-types-DTl7bRH3.d.ts} +3 -1
  36. package/dist/{mcp-servers-MLL6bMlv.d.ts → mcp-servers-CuZGf9fI.d.ts} +4 -4
  37. package/dist/models/index.d.ts +5 -5
  38. package/dist/models/index.js +223 -139
  39. package/dist/models/index.js.map +1 -1
  40. package/dist/{models-registry-CrkcxQ-g.d.ts → models-registry-8XOdxWQu.d.ts} +16 -1
  41. package/dist/{multi-agent-coordinator-Dc_HuG9p.d.ts → multi-agent-coordinator-CiRtKVTk.d.ts} +8 -1
  42. package/dist/{null-fleet-bus-BMZwMin7.d.ts → null-fleet-bus-d9G-bVy9.d.ts} +26 -22
  43. package/dist/observability/index.d.ts +2 -2
  44. package/dist/{path-resolver-uVK4BatM.d.ts → path-resolver-BhIb6mtd.d.ts} +8 -3
  45. package/dist/{permission-CJR1qfOi.d.ts → permission-BCbQDR2s.d.ts} +1 -1
  46. package/dist/{permission-policy-DLVKKk4w.d.ts → permission-policy-C0ikndX_.d.ts} +2 -18
  47. package/dist/{pipeline-BYR-Vdau.d.ts → pipeline-Dl6XbfE7.d.ts} +10 -6
  48. package/dist/{provider-model-resolve-iREK_1lG.d.ts → provider-model-resolve-B70epO19.d.ts} +3 -3
  49. package/dist/{provider-runner-i7SQXZuC.d.ts → provider-runner-DZ808MSM.d.ts} +3 -3
  50. package/dist/{retry-policy-BmY5ooh3.d.ts → retry-policy-Dt3_z8Aj.d.ts} +1 -1
  51. package/dist/sdd/index.d.ts +19 -10
  52. package/dist/sdd/index.js +411 -240
  53. package/dist/sdd/index.js.map +1 -1
  54. package/dist/{secret-vault-C9leEMzr.d.ts → secret-vault-BUJ2d1gB.d.ts} +1 -1
  55. package/dist/security/index.d.ts +5 -5
  56. package/dist/security/index.js +30 -6
  57. package/dist/security/index.js.map +1 -1
  58. package/dist/{selector-qjpee9BF.d.ts → selector-BCkWgdwy.d.ts} +1 -1
  59. package/dist/{session-event-bridge-m7y--I-H.d.ts → session-event-bridge-CMvIO59_.d.ts} +1 -1
  60. package/dist/{session-reader-BjLH4V9n.d.ts → session-reader-C8aiChUu.d.ts} +1 -1
  61. package/dist/skills/index.js +1 -0
  62. package/dist/skills/index.js.map +1 -1
  63. package/dist/storage/index.d.ts +68 -30
  64. package/dist/storage/index.js +839 -528
  65. package/dist/storage/index.js.map +1 -1
  66. package/dist/{strategy-compactor-C2bmlWYg.d.ts → strategy-compactor-DI1OHVbB.d.ts} +10 -10
  67. package/dist/{todos-checkpoint-oDS9IBNS.d.ts → todos-checkpoint-Ddd2CGr0.d.ts} +56 -9
  68. package/dist/{tool-executor-D4YdaJ-M.d.ts → tool-executor-Bmd5Ygoo.d.ts} +45 -10
  69. package/dist/tools/index.d.ts +2 -2
  70. package/dist/tools/index.js.map +1 -1
  71. package/dist/types/index.d.ts +20 -20
  72. package/dist/types/index.js +331 -98
  73. package/dist/types/index.js.map +1 -1
  74. package/dist/utils/index.d.ts +16 -3
  75. package/dist/utils/index.js +159 -83
  76. package/dist/utils/index.js.map +1 -1
  77. package/dist/{worktree-manager-A1Efnvs0.d.ts → worktree-manager-DBdl_5rs.d.ts} +4 -1
  78. package/instructions/agents/shadow-agent.md +3 -3
  79. package/instructions/coordination/director-preamble.md +3 -3
  80. package/instructions/modes/research-web.md +4 -4
  81. package/package.json +1 -1
  82. package/skills/research-web/SKILL.md +26 -26
  83. package/skills/research-web/SKILL.save.md +1 -1
@@ -1,21 +1,21 @@
1
- import { T as Token, a as Renderer, S as SystemPromptBuilder, H as HookRegistry } from '../pipeline-BYR-Vdau.js';
2
- export { d as BindOptions, C as Container, D as Decorator, F as Factory, b as Middleware, M as MiddlewareHandler, N as NextFn, P as Pipeline, e as PipelineOptions } from '../pipeline-BYR-Vdau.js';
3
- import { c as MemoryStore, B as BrainArbiter } from '../brain-DCkB5_e7.js';
4
- export { E as EventBus, m as EventLogger, n as EventMap, a as EventName, L as Listener, v as ScopedEventBus } from '../brain-DCkB5_e7.js';
5
- import { C as Compactor } from '../compactor-CzSvxM1g.js';
6
- import { j as ConfigLoader, l as ConfigStore, M as ModelsRegistry } from '../config-BzFRKkg7.js';
7
- import { E as ErrorHandler, R as RetryPolicy } from '../retry-policy-BmY5ooh3.js';
1
+ import { T as Token, a as Renderer, S as SystemPromptBuilder, H as HookRegistry } from '../pipeline-Dl6XbfE7.js';
2
+ export { d as BindOptions, C as Container, D as Decorator, F as Factory, b as Middleware, M as MiddlewareHandler, N as NextFn, P as Pipeline, e as PipelineOptions } from '../pipeline-Dl6XbfE7.js';
3
+ import { c as MemoryStore, B as BrainArbiter } from '../brain-BLOyN5ZP.js';
4
+ export { E as EventBus, m as EventLogger, n as EventMap, a as EventName, L as Listener, v as ScopedEventBus } from '../brain-BLOyN5ZP.js';
5
+ import { C as Compactor } from '../compactor-DcBpaJsI.js';
6
+ import { j as ConfigLoader, l as ConfigStore, M as ModelsRegistry } from '../config-Bf5mj-ad.js';
7
+ import { E as ErrorHandler, R as RetryPolicy } from '../retry-policy-Dt3_z8Aj.js';
8
8
  import { I as InputReader } from '../input-reader-E-ffP2ee.js';
9
9
  import { L as Logger } from '../logger-B63L5bTg.js';
10
10
  import { M as ModeStore } from '../mode-CZlO9iU1.js';
11
11
  import { P as PathResolver } from '../path-resolver-CPRj4bFY.js';
12
- import { P as PermissionPolicy, S as SecretScrubber } from '../permission-CJR1qfOi.js';
13
- import { P as ProviderRunner } from '../provider-runner-i7SQXZuC.js';
14
- import { e as TokenCounter, k as SessionStore } from '../context-BrLe8pJy.js';
12
+ import { P as PermissionPolicy, S as SecretScrubber } from '../permission-BCbQDR2s.js';
13
+ import { P as ProviderRunner } from '../provider-runner-DZ808MSM.js';
14
+ import { e as TokenCounter, k as SessionStore } from '../context-CLnUMW5g.js';
15
15
  import { P as PromptLoader } from '../prompt-DLd35n4Q.js';
16
16
  import { S as SkillLoader } from '../skill-DGIXCtdv.js';
17
- import { W as WorktreeManager } from '../worktree-manager-A1Efnvs0.js';
18
- import '../mailbox-types-_7gaY0Rl.js';
17
+ import { W as WorktreeManager } from '../worktree-manager-DBdl_5rs.js';
18
+ import '../mailbox-types-DTl7bRH3.js';
19
19
  import '../observability-D-HZN_mF.js';
20
20
 
21
21
  declare const TOKENS: {
@@ -84,6 +84,14 @@ declare class RunController {
84
84
  * Register a teardown hook. Returns an unsubscribe function so callers
85
85
  * can opt out before the hook fires (e.g. when a tool finishes cleanly
86
86
  * before abort happens).
87
+ *
88
+ * If the controller has already drained its hooks (a prior abort() or
89
+ * dispose() ran), the new hook is fired immediately on a best-effort
90
+ * basis — otherwise a hook registered after teardown would be silently
91
+ * dropped and the resource it cleans up would leak. The returned
92
+ * unsubscribe is a no-op in that case (the hook has already run). Errors
93
+ * from the immediate run are routed through `errorSink` like any other
94
+ * cleanup failure.
87
95
  */
88
96
  onAbort(fn: () => void | Promise<void>): () => void;
89
97
  /**
@@ -8,7 +8,11 @@ var ERROR_CODES = {
8
8
  // Container / Registry
9
9
  CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
10
10
  CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
11
- CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY"};
11
+ CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
12
+ REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
13
+ REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
14
+ // General
15
+ VALIDATION_ERROR: "VALIDATION_ERROR"};
12
16
  var WrongStackError = class extends Error {
13
17
  code;
14
18
  subsystem;
@@ -64,6 +68,7 @@ var Container = class {
64
68
  factory,
65
69
  singleton: opts.singleton ?? true,
66
70
  decorators: [],
71
+ hasCache: false,
67
72
  owner: opts.owner ?? "core"
68
73
  });
69
74
  }
@@ -81,6 +86,7 @@ var Container = class {
81
86
  factory,
82
87
  singleton: opts.singleton ?? existing.singleton,
83
88
  decorators: existing.decorators,
89
+ hasCache: false,
84
90
  owner: opts.owner ?? existing.owner
85
91
  });
86
92
  }
@@ -96,6 +102,7 @@ var Container = class {
96
102
  }
97
103
  existing.decorators.push(decorator);
98
104
  existing.cache = void 0;
105
+ existing.hasCache = false;
99
106
  existing.owner = `${existing.owner}+${owner}`;
100
107
  }
101
108
  resolve(token) {
@@ -108,7 +115,7 @@ var Container = class {
108
115
  context: { token: token.description }
109
116
  });
110
117
  }
111
- if (entry.singleton && entry.cache !== void 0) {
118
+ if (entry.singleton && entry.hasCache) {
112
119
  return entry.cache;
113
120
  }
114
121
  if (this.resolving.has(token)) {
@@ -128,6 +135,7 @@ var Container = class {
128
135
  }
129
136
  if (entry.singleton) {
130
137
  entry.cache = value;
138
+ entry.hasCache = true;
131
139
  }
132
140
  return value;
133
141
  } finally {
@@ -198,7 +206,7 @@ var Container = class {
198
206
  owner: entry.owner,
199
207
  singleton: entry.singleton,
200
208
  decoratorCount: entry.decorators.length,
201
- cached: entry.cache !== void 0
209
+ cached: entry.hasCache
202
210
  };
203
211
  }
204
212
  };
@@ -323,7 +331,12 @@ var Pipeline = class {
323
331
  const errorHandler = this.errorHandler;
324
332
  const dispatch = async (i, value) => {
325
333
  if (i <= index) {
326
- throw new Error(`Pipeline: next() called multiple times in "${chain[index]?.name}"`);
334
+ throw new WrongStackError({
335
+ message: `Pipeline: next() called multiple times in "${chain[index]?.name}"`,
336
+ code: ERROR_CODES.VALIDATION_ERROR,
337
+ subsystem: "container",
338
+ context: { middleware: chain[index]?.name }
339
+ });
327
340
  }
328
341
  index = i;
329
342
  const mw = chain[i];
@@ -347,13 +360,23 @@ var Pipeline = class {
347
360
  indexOf(name, optional = false) {
348
361
  const idx = this.chain.findIndex((m) => m.name === name);
349
362
  if (idx === -1 && !optional) {
350
- throw new Error(`Pipeline: middleware "${name}" not found`);
363
+ throw new WrongStackError({
364
+ message: `Pipeline: middleware "${name}" not found`,
365
+ code: ERROR_CODES.REGISTRY_NOT_FOUND,
366
+ subsystem: "container",
367
+ context: { middleware: name }
368
+ });
351
369
  }
352
370
  return idx;
353
371
  }
354
372
  ensureUnique(name) {
355
373
  if (this.chain.some((m) => m.name === name)) {
356
- throw new Error(`Pipeline: middleware "${name}" already registered`);
374
+ throw new WrongStackError({
375
+ message: `Pipeline: middleware "${name}" already registered`,
376
+ code: ERROR_CODES.REGISTRY_DUPLICATE,
377
+ subsystem: "container",
378
+ context: { middleware: name }
379
+ });
357
380
  }
358
381
  }
359
382
  };
@@ -376,7 +399,10 @@ var EventBus = class {
376
399
  return () => this.off(event, fn);
377
400
  }
378
401
  off(event, fn) {
379
- this.listeners.get(event)?.delete(fn);
402
+ const set = this.listeners.get(event);
403
+ if (!set) return;
404
+ set.delete(fn);
405
+ if (set.size === 0) this.listeners.delete(event);
380
406
  }
381
407
  once(event, fn) {
382
408
  const wrapper = (payload) => {
@@ -435,8 +461,9 @@ var EventBus = class {
435
461
  }
436
462
  emit(event, payload) {
437
463
  const set = this.listeners.get(event);
438
- if (set) {
439
- for (const fn of set) {
464
+ if (set && set.size > 0) {
465
+ const snapshot = [...set];
466
+ for (const fn of snapshot) {
440
467
  try {
441
468
  fn(payload);
442
469
  } catch (err) {
@@ -717,8 +744,27 @@ var RunController = class {
717
744
  * Register a teardown hook. Returns an unsubscribe function so callers
718
745
  * can opt out before the hook fires (e.g. when a tool finishes cleanly
719
746
  * before abort happens).
747
+ *
748
+ * If the controller has already drained its hooks (a prior abort() or
749
+ * dispose() ran), the new hook is fired immediately on a best-effort
750
+ * basis — otherwise a hook registered after teardown would be silently
751
+ * dropped and the resource it cleans up would leak. The returned
752
+ * unsubscribe is a no-op in that case (the hook has already run). Errors
753
+ * from the immediate run are routed through `errorSink` like any other
754
+ * cleanup failure.
720
755
  */
721
756
  onAbort(fn) {
757
+ if (this.hooksDrained) {
758
+ void (async () => {
759
+ try {
760
+ await fn();
761
+ } catch (err) {
762
+ this.errorSink(err, "RunController.onAbort(post-drain)");
763
+ }
764
+ })();
765
+ return () => {
766
+ };
767
+ }
722
768
  this.hooks.push(fn);
723
769
  return () => {
724
770
  const idx = this.hooks.indexOf(fn);