@wrongstack/core 0.3.3 → 0.3.7

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 (52) hide show
  1. package/dist/{agent-bridge-C3DUGjSb.d.ts → agent-bridge-DaOnnHNW.d.ts} +1 -1
  2. package/dist/{compactor-DpJBI1YH.d.ts → compactor-CFky6JKM.d.ts} +1 -1
  3. package/dist/{config-D2qvAxVd.d.ts → config-RlhKLjme.d.ts} +2 -1
  4. package/dist/{context-IovtuTf8.d.ts → context-B1kBj1lY.d.ts} +4 -3
  5. package/dist/coordination/index.d.ts +12 -10
  6. package/dist/coordination/index.js +50 -9
  7. package/dist/coordination/index.js.map +1 -1
  8. package/dist/defaults/index.d.ts +16 -16
  9. package/dist/defaults/index.js +213 -17
  10. package/dist/defaults/index.js.map +1 -1
  11. package/dist/{events-BHIQs4o1.d.ts → events-BBaKeMfb.d.ts} +11 -1
  12. package/dist/execution/index.d.ts +11 -11
  13. package/dist/execution/index.js +54 -1
  14. package/dist/execution/index.js.map +1 -1
  15. package/dist/extension/index.d.ts +6 -6
  16. package/dist/{index-hWNybrNZ.d.ts → index-meJRuQtc.d.ts} +26 -5
  17. package/dist/index.d.ts +26 -26
  18. package/dist/index.js +306 -39
  19. package/dist/index.js.map +1 -1
  20. package/dist/infrastructure/index.d.ts +6 -6
  21. package/dist/kernel/index.d.ts +9 -9
  22. package/dist/kernel/index.js.map +1 -1
  23. package/dist/{mcp-servers-C2OopXOn.d.ts → mcp-servers-Cf4-bJnd.d.ts} +3 -3
  24. package/dist/models/index.d.ts +2 -2
  25. package/dist/models/index.js +1 -0
  26. package/dist/models/index.js.map +1 -1
  27. package/dist/{multi-agent-B9a6sflH.d.ts → multi-agent-D5m66hzB.d.ts} +1 -1
  28. package/dist/observability/index.d.ts +2 -2
  29. package/dist/{path-resolver--59rCou3.d.ts → path-resolver-Bg4OP5fi.d.ts} +2 -2
  30. package/dist/{provider-runner-B39miKRw.d.ts → provider-runner-CU9gnU2E.d.ts} +3 -3
  31. package/dist/sdd/index.d.ts +3 -3
  32. package/dist/secret-scrubber-DyUAWS09.d.ts +54 -0
  33. package/dist/{secret-scrubber-Cuy5afaQ.d.ts → secret-scrubber-Dyh5LVYL.d.ts} +1 -1
  34. package/dist/security/index.d.ts +58 -5
  35. package/dist/security/index.js +95 -6
  36. package/dist/security/index.js.map +1 -1
  37. package/dist/{selector-wT2fv9Fg.d.ts → selector-DBEiwXBk.d.ts} +1 -1
  38. package/dist/{session-reader-CcPi4BQ8.d.ts → session-reader-D-z0AgHs.d.ts} +1 -1
  39. package/dist/{skill-C_7znCIC.d.ts → skill-DayhFUBb.d.ts} +1 -1
  40. package/dist/storage/index.d.ts +5 -5
  41. package/dist/storage/index.js +53 -1
  42. package/dist/storage/index.js.map +1 -1
  43. package/dist/{system-prompt-Dk1qm8ey.d.ts → system-prompt-DNetCecu.d.ts} +1 -1
  44. package/dist/{tool-executor-HsBLGRaA.d.ts → tool-executor-B5bgmEgE.d.ts} +12 -5
  45. package/dist/types/index.d.ts +15 -15
  46. package/dist/types/index.js +59 -2
  47. package/dist/types/index.js.map +1 -1
  48. package/dist/utils/index.d.ts +23 -2
  49. package/dist/utils/index.js +41 -1
  50. package/dist/utils/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/secret-scrubber-CgG2tV2B.d.ts +0 -31
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, l as BridgeMessage, A as AgentBridge, m as AgentBridgeConfig } from './multi-agent-B9a6sflH.js';
1
+ import { B as BridgeTransport, l as BridgeMessage, A as AgentBridge, m as AgentBridgeConfig } from './multi-agent-D5m66hzB.js';
2
2
 
3
3
  /**
4
4
  * In-memory pub/sub transport for agent-to-agent messaging.
@@ -1,4 +1,4 @@
1
- import { a0 as Context } from './context-IovtuTf8.js';
1
+ import { a0 as Context } from './context-B1kBj1lY.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -1,5 +1,5 @@
1
1
  import { W as WireFamily } from './models-registry-Y2xbog0E.js';
2
- import { P as Permission } from './context-IovtuTf8.js';
2
+ import { P as Permission } from './context-B1kBj1lY.js';
3
3
 
4
4
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
5
5
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -130,6 +130,7 @@ interface MCPServerConfig {
130
130
  allowedTools?: string[];
131
131
  permission?: Permission;
132
132
  startupTimeoutMs?: number;
133
+ requestTimeoutMs?: number;
133
134
  }
134
135
  interface LogConfig {
135
136
  level: 'error' | 'warn' | 'info' | 'debug' | 'trace';
@@ -859,9 +859,10 @@ declare class Context implements RunEnv {
859
859
  get state(): ConversationState;
860
860
  /**
861
861
  * Register a teardown hook tied to the current run's abort signal. The
862
- * hook fires when the run aborts OR ends normally — Agent.run wires
863
- * this through a RunController. When no run is active the hook fires
864
- * immediately so callers don't leak resources.
862
+ * hook fires when the run aborts or ends normally — Agent.run wires this
863
+ * through a RunController. Hooks registered before a run starts are stored
864
+ * and fired when the next run ends; there is no "immediate fire" when no
865
+ * run is active.
865
866
  *
866
867
  * **Scope:** these hooks fire on the **whole agent run's** abort, not on
867
868
  * an individual tool call. For per-tool teardown of resources owned by
@@ -1,16 +1,16 @@
1
- import { M as MultiAgentConfig, i as SubagentRunner, c as SubagentConfig, k as TaskSpec, j as TaskResult, a as CoordinatorStatus, b as MultiAgentCoordinator, S as SpawnResult, l as BridgeMessage, A as AgentBridge } from '../multi-agent-B9a6sflH.js';
2
- export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-B9a6sflH.js';
3
- import { q as SessionWriter, u as Tool, o as SessionStore } from '../context-IovtuTf8.js';
4
- import { I as InMemoryAgentBridge } from '../agent-bridge-C3DUGjSb.js';
5
- export { a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-C3DUGjSb.js';
6
- import { E as EventBus } from '../events-BHIQs4o1.js';
1
+ import { M as MultiAgentConfig, i as SubagentRunner, c as SubagentConfig, k as TaskSpec, j as TaskResult, a as CoordinatorStatus, b as MultiAgentCoordinator, S as SpawnResult, l as BridgeMessage, A as AgentBridge } from '../multi-agent-D5m66hzB.js';
2
+ export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-D5m66hzB.js';
3
+ import { q as SessionWriter, u as Tool, o as SessionStore } from '../context-B1kBj1lY.js';
4
+ import { I as InMemoryAgentBridge } from '../agent-bridge-DaOnnHNW.js';
5
+ export { a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DaOnnHNW.js';
6
+ import { E as EventBus } from '../events-BBaKeMfb.js';
7
7
  import { EventEmitter } from 'node:events';
8
- import { r as Agent, u as AgentInput } from '../index-hWNybrNZ.js';
8
+ import { r as Agent, u as AgentInput } from '../index-meJRuQtc.js';
9
9
  import '../logger-BMQgxvdy.js';
10
- import '../system-prompt-Dk1qm8ey.js';
10
+ import '../system-prompt-DNetCecu.js';
11
11
  import '../observability-BhnVLBLS.js';
12
- import '../secret-scrubber-CgG2tV2B.js';
13
- import '../config-D2qvAxVd.js';
12
+ import '../secret-scrubber-DyUAWS09.js';
13
+ import '../config-RlhKLjme.js';
14
14
  import '../models-registry-Y2xbog0E.js';
15
15
 
16
16
  /**
@@ -590,7 +590,9 @@ declare class DefaultMultiAgentCoordinator extends EventEmitter implements Multi
590
590
  completeTask(result: TaskResult): void;
591
591
  private tryDispatchNext;
592
592
  private canDispatch;
593
+ private takeNextDispatchableTask;
593
594
  private findIdleSubagent;
595
+ private isIdleSubagent;
594
596
  /**
595
597
  * Returns true iff at least one spawned subagent could still
596
598
  * process a task. A "live" subagent is one that is not stopped
@@ -135,6 +135,10 @@ var DirectorStateCheckpoint = class {
135
135
  this.timer = null;
136
136
  }
137
137
  await this.persist();
138
+ if (this.rewriteRequested) {
139
+ this.rewriteRequested = false;
140
+ await this.persist();
141
+ }
138
142
  }
139
143
  bumpUpdatedAt() {
140
144
  this.snapshot = { ...this.snapshot, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -272,6 +276,13 @@ var InMemoryAgentBridge = class {
272
276
  this.pendingRequests.delete(correlationId);
273
277
  reject(new Error(`Request ${correlationId} timed out after ${timeout}ms`));
274
278
  }, timeout);
279
+ if (this.stopped) {
280
+ clearTimeout(timer);
281
+ this.inflightGuards.delete(correlationId);
282
+ this.pendingRequests.delete(correlationId);
283
+ reject(new Error("Bridge stopped"));
284
+ return;
285
+ }
275
286
  this.pendingRequests.set(correlationId, {
276
287
  resolve,
277
288
  reject,
@@ -893,8 +904,8 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
893
904
  // --- internal dispatching ---------------------------------------------
894
905
  tryDispatchNext() {
895
906
  while (this.canDispatch()) {
896
- const subagentId = this.findIdleSubagent();
897
- if (!subagentId) {
907
+ const dispatchable = this.takeNextDispatchableTask();
908
+ if (!dispatchable) {
898
909
  if (this.pendingTasks.length > 0 && !this.hasLiveSubagent()) {
899
910
  this.drainPendingAsAborted(
900
911
  "No live subagent available \u2014 all stopped or mid-termination"
@@ -902,8 +913,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
902
913
  }
903
914
  return;
904
915
  }
905
- const task = this.pendingTasks.shift();
906
- if (!task) return;
916
+ const { subagentId, task } = dispatchable;
907
917
  this.runDispatched(subagentId, task).catch((err) => {
908
918
  this.recordCompletion({
909
919
  subagentId,
@@ -921,12 +931,26 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
921
931
  const max = this.config.maxConcurrent ?? 4;
922
932
  return this.inFlight < max && this.pendingTasks.length > 0;
923
933
  }
934
+ takeNextDispatchableTask() {
935
+ for (let i = 0; i < this.pendingTasks.length; i++) {
936
+ const task = this.pendingTasks[i];
937
+ const subagentId = task.subagentId ? this.isIdleSubagent(task.subagentId) ? task.subagentId : null : this.findIdleSubagent();
938
+ if (!subagentId) continue;
939
+ this.pendingTasks.splice(i, 1);
940
+ return { subagentId, task };
941
+ }
942
+ return null;
943
+ }
924
944
  findIdleSubagent() {
925
945
  for (const [id, s] of this.subagents) {
926
946
  if (s.status === "idle" && !this.terminating.has(id)) return id;
927
947
  }
928
948
  return null;
929
949
  }
950
+ isIdleSubagent(id) {
951
+ const subagent = this.subagents.get(id);
952
+ return !!subagent && subagent.status === "idle" && !this.terminating.has(id);
953
+ }
930
954
  /**
931
955
  * Returns true iff at least one spawned subagent could still
932
956
  * process a task. A "live" subagent is one that is not stopped
@@ -1111,10 +1135,11 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
1111
1135
  };
1112
1136
  function classifySubagentError(err, hints = {}) {
1113
1137
  const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
1114
- const baseMessage = err instanceof Error ? err.message : String(err);
1115
1138
  if (err instanceof ProviderError) {
1116
- return providerErrorToSubagentError(err, baseMessage, cause);
1139
+ const baseMessage2 = err.describe();
1140
+ return providerErrorToSubagentError(err, baseMessage2, cause);
1117
1141
  }
1142
+ const baseMessage = err instanceof Error ? err.message : String(err);
1118
1143
  if (err instanceof BudgetExceededError) {
1119
1144
  const map = {
1120
1145
  iterations: "budget_iterations",
@@ -1231,7 +1256,7 @@ function makeSpawnTool(director, roster) {
1231
1256
  if (role && !base) {
1232
1257
  return { error: `unknown role "${role}". roster has: ${roster ? Object.keys(roster).join(", ") : "(empty)"}` };
1233
1258
  }
1234
- const cfg = { ...base ?? { name: i.name ?? "subagent" } };
1259
+ const cfg = base ? instantiateRosterConfig(role, base) : { name: i.name ?? "subagent" };
1235
1260
  if (typeof i.name === "string") cfg.name = i.name;
1236
1261
  if (typeof i.provider === "string") cfg.provider = i.provider;
1237
1262
  if (typeof i.model === "string") cfg.model = i.model;
@@ -1251,6 +1276,14 @@ function makeSpawnTool(director, roster) {
1251
1276
  }
1252
1277
  };
1253
1278
  }
1279
+ function instantiateRosterConfig(role, base) {
1280
+ return {
1281
+ ...base,
1282
+ // Roster entries are templates. A director may spawn several
1283
+ // workers with the same role, so never reuse the template id.
1284
+ id: `${role}-${randomUUID().slice(0, 8)}`
1285
+ };
1286
+ }
1254
1287
  function makeAssignTool(director) {
1255
1288
  const inputSchema = {
1256
1289
  type: "object",
@@ -1568,8 +1601,8 @@ var Director = class {
1568
1601
  if (this.spawnCount >= this.maxSpawns) {
1569
1602
  throw new DirectorBudgetError("max_spawns", this.maxSpawns, this.spawnCount + 1);
1570
1603
  }
1571
- this.spawnCount += 1;
1572
1604
  const result = await this.coordinator.spawn(config);
1605
+ this.spawnCount += 1;
1573
1606
  this.subagentMeta.set(result.subagentId, {
1574
1607
  provider: config.provider,
1575
1608
  model: config.model
@@ -2012,7 +2045,7 @@ function createDelegateTool(opts) {
2012
2045
  error: `Unknown role "${i.role}". Available: ${rosterIds.join(", ") || "(no roster configured)"}.`
2013
2046
  };
2014
2047
  }
2015
- cfg = { ...base };
2048
+ cfg = instantiateRosterConfig2(i.role, base);
2016
2049
  if (i.systemPromptOverride) cfg.systemPromptOverride = i.systemPromptOverride;
2017
2050
  if (i.provider) cfg.provider = i.provider;
2018
2051
  if (i.model) cfg.model = i.model;
@@ -2098,6 +2131,14 @@ function createDelegateTool(opts) {
2098
2131
  }
2099
2132
  };
2100
2133
  }
2134
+ function instantiateRosterConfig2(role, base) {
2135
+ return {
2136
+ ...base,
2137
+ // Roster entries are templates. Give each spawn a fresh id so
2138
+ // parallel or repeated delegates can use the same role safely.
2139
+ id: `${role}-${randomUUID().slice(0, 8)}`
2140
+ };
2141
+ }
2101
2142
  function hintForKind(kind, retryable, backoffMs) {
2102
2143
  if (!kind) return void 0;
2103
2144
  switch (kind) {