@wrongstack/core 0.280.0 → 0.281.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 (95) hide show
  1. package/dist/{agent-subagent-runner-PoqNKiR4.d.ts → agent-subagent-runner-DyOSK2Wy.d.ts} +39 -8
  2. package/dist/{compactor-U3agvUIG.d.ts → compactor-BxddyCFu.d.ts} +1 -1
  3. package/dist/{config-Cr3312zc.d.ts → config-CN-vdDEI.d.ts} +82 -2
  4. package/dist/coordination/index.d.ts +203 -20
  5. package/dist/coordination/index.js +981 -52
  6. package/dist/coordination/index.js.map +1 -1
  7. package/dist/defaults/index.d.ts +26 -30
  8. package/dist/defaults/index.js +382 -30
  9. package/dist/defaults/index.js.map +1 -1
  10. package/dist/{events-Bs2fmldo.d.ts → events-C5hLU0AT.d.ts} +38 -2
  11. package/dist/execution/index.d.ts +16 -16
  12. package/dist/execution/index.js +161 -18
  13. package/dist/execution/index.js.map +1 -1
  14. package/dist/execution/prompt-enhancer.d.ts +1 -1
  15. package/dist/execution/prompt-enhancer.js +12 -3
  16. package/dist/execution/prompt-enhancer.js.map +1 -1
  17. package/dist/extension/index.d.ts +6 -6
  18. package/dist/{global-mailbox-Ct7IorLJ.d.ts → global-mailbox-CHM1QkCi.d.ts} +5 -2
  19. package/dist/{goal-store-C4F6DjC0.d.ts → goal-store-BLGZq16t.d.ts} +1 -1
  20. package/dist/hq/index.d.ts +6 -6
  21. package/dist/hq/index.js +35 -13
  22. package/dist/hq/index.js.map +1 -1
  23. package/dist/{index-nP09-oP2.d.ts → index-BEFWNZYs.d.ts} +1 -2
  24. package/dist/{index-kidebiDh.d.ts → index-C1E-_71T.d.ts} +6 -6
  25. package/dist/index.d.ts +44 -48
  26. package/dist/index.js +14855 -13944
  27. package/dist/index.js.map +1 -1
  28. package/dist/infrastructure/index.d.ts +60 -8
  29. package/dist/infrastructure/index.js.map +1 -1
  30. package/dist/kernel/index.d.ts +11 -11
  31. package/dist/kernel/index.js.map +1 -1
  32. package/dist/{mcp-servers-D910X5_r.d.ts → mcp-servers-EKRAcJDi.d.ts} +97 -4
  33. package/dist/models/index.d.ts +4 -5
  34. package/dist/models/index.js +22 -5
  35. package/dist/models/index.js.map +1 -1
  36. package/dist/{multi-agent-coordinator-CieyUoEL.d.ts → multi-agent-coordinator-IpHCuHUa.d.ts} +29 -1
  37. package/dist/{null-fleet-bus-DkdmZJ_W.d.ts → null-fleet-bus-ZBkKGR9j.d.ts} +105 -7
  38. package/dist/observability/index.d.ts +3 -3
  39. package/dist/{tool-executor-SiE1wlZo.d.ts → parallel-eternal-engine-Cc2CNgmv.d.ts} +6 -202
  40. package/dist/path-resolver-CMS5307d.d.ts +13 -0
  41. package/dist/{permission-Dx6dIqS2.d.ts → permission-B6YAtNFz.d.ts} +1 -1
  42. package/dist/{pipeline-BwAP21_4.d.ts → pipeline-E7_jqGyV.d.ts} +2 -2
  43. package/dist/{provider-model-resolve-CwQNZWt_.d.ts → provider-model-resolve-KgIdiEQ6.d.ts} +118 -5
  44. package/dist/{provider-runner-CYHFImzV.d.ts → provider-runner-DxWXNHL1.d.ts} +3 -3
  45. package/dist/{retry-policy-D4feSLk3.d.ts → retry-policy-V67lBOJz.d.ts} +2 -2
  46. package/dist/sdd/index.d.ts +9 -9
  47. package/dist/sdd/index.js +94 -10
  48. package/dist/sdd/index.js.map +1 -1
  49. package/dist/{permission-policy-C8vJcnX5.d.ts → secret-vault-D7jeyXUQ.d.ts} +119 -3
  50. package/dist/security/index.d.ts +5 -6
  51. package/dist/security/index.js +4 -1
  52. package/dist/security/index.js.map +1 -1
  53. package/dist/{selector-Dy-MzKp1.d.ts → selector-Bx2HgUkU.d.ts} +1 -1
  54. package/dist/{session-event-bridge-CqdiGnfU.d.ts → session-event-bridge-vA2fLV58.d.ts} +1 -1
  55. package/dist/{session-reader-Hk0WbNm9.d.ts → session-reader-B-Fi9L6I.d.ts} +1 -1
  56. package/dist/session-registry-Dvg7i_IA.d.ts +129 -0
  57. package/dist/storage/index.d.ts +71 -142
  58. package/dist/storage/index.js +161 -13
  59. package/dist/storage/index.js.map +1 -1
  60. package/dist/{todos-checkpoint-Bk2uP7Ex.d.ts → todos-checkpoint-B1QVkoa8.d.ts} +23 -5
  61. package/dist/{tool-BkOgs_KL.d.ts → tool-LVSLiE1s.d.ts} +18 -4
  62. package/dist/{strategy-compactor-CQwhbErd.d.ts → tool-executor-BWtYwuPI.d.ts} +210 -12
  63. package/dist/tools/index.d.ts +2 -2
  64. package/dist/tools/index.js.map +1 -1
  65. package/dist/types/index.d.ts +17 -41
  66. package/dist/types/index.js +182 -5085
  67. package/dist/types/index.js.map +1 -1
  68. package/dist/utils/index.d.ts +3 -3
  69. package/dist/utils/index.js +6 -1
  70. package/dist/utils/index.js.map +1 -1
  71. package/dist/{worktree-manager-BjOFF6bt.d.ts → worktree-manager-C6CIilTT.d.ts} +1 -1
  72. package/dist/{wstack-paths-CMl_cYgq.d.ts → wstack-paths-C3K40Qst.d.ts} +2 -0
  73. package/instructions/agents/shadow-agent.md +23 -84
  74. package/instructions/coordination/director-preamble.md +12 -3
  75. package/instructions/coordination/subagent-baseline.md +39 -46
  76. package/instructions/leader-after-task.md +10 -28
  77. package/instructions/llm/llm-selector.md +1 -2
  78. package/instructions/modes/brief-system.md +7 -33
  79. package/instructions/modes/brief.md +5 -20
  80. package/instructions/modes/teach-system.md +12 -72
  81. package/instructions/modes/teach.md +12 -49
  82. package/instructions/sections/tool/commit-hygiene.md +5 -5
  83. package/instructions/sections/tool/context-management-full.md +6 -6
  84. package/instructions/sections/tool/delegation-compact.md +1 -1
  85. package/instructions/sections/tool/delegation-full.md +19 -23
  86. package/instructions/sections/tool/mailbox-full.md +11 -31
  87. package/instructions/sections/tool/mcp-full-control.md +5 -7
  88. package/instructions/sections/tool/mcp-full-use.md +7 -7
  89. package/instructions/system.md +22 -38
  90. package/package.json +1 -29
  91. package/dist/agent-bridge-DXC6QDJ4.d.ts +0 -35
  92. package/dist/logger-D3lV0cUZ.d.ts +0 -101
  93. package/dist/models-registry-CLkoOcHk.d.ts +0 -108
  94. package/dist/path-resolver-XfZ9eLxG.d.ts +0 -67
  95. package/dist/secret-vault-CImt2XrR.d.ts +0 -118
@@ -1,18 +1,18 @@
1
1
  import { h as Specification, e as SpecStatus, S as SpecAnalysis, g as SpecValidationResult, f as SpecTemplate, b as SpecRequirement } from '../spec-TBi3Jr6T.js';
2
2
  import { d as TaskGraph, e as TaskNode, i as TaskFilter, j as TaskSort, c as TaskProgress, T as TaskType, a as TaskPriority } from '../task-graph-u1q9Jkyk.js';
3
- import { E as EventBus, B as BrainArbiter } from '../events-Bs2fmldo.js';
4
- import { h as Agent, i as AgentFactory, g as TaskResult, D as DoneCondition } from '../agent-subagent-runner-PoqNKiR4.js';
5
- import { W as WorktreeManager } from '../worktree-manager-BjOFF6bt.js';
6
- import '../tool-BkOgs_KL.js';
7
- import '../permission-Dx6dIqS2.js';
8
- import '../index-kidebiDh.js';
3
+ import { E as EventBus, B as BrainArbiter } from '../events-C5hLU0AT.js';
4
+ import { A as Agent, a as AgentFactory, g as TaskResult, D as DoneCondition } from '../agent-subagent-runner-DyOSK2Wy.js';
5
+ import { W as WorktreeManager } from '../worktree-manager-C6CIilTT.js';
6
+ import '../tool-LVSLiE1s.js';
7
+ import '../permission-B6YAtNFz.js';
8
+ import '../index-C1E-_71T.js';
9
9
  import '../logger-B63L5bTg.js';
10
- import '../pipeline-BwAP21_4.js';
10
+ import '../pipeline-E7_jqGyV.js';
11
11
  import '../mailbox-types-BGZWrYTJ.js';
12
- import '../config-Cr3312zc.js';
12
+ import '../config-CN-vdDEI.js';
13
13
  import '../observability-D-HZN_mF.js';
14
14
  import '../secret-scrubber-3MHDDAtm.js';
15
- import '../retry-policy-D4feSLk3.js';
15
+ import '../retry-policy-V67lBOJz.js';
16
16
 
17
17
  interface TaskStore {
18
18
  saveGraph(graph: TaskGraph): Promise<void>;
package/dist/sdd/index.js CHANGED
@@ -3892,20 +3892,32 @@ var TOOLS = {
3892
3892
  /** Web research. */
3893
3893
  research: ["read", "grep", "glob", "search", "fetch", "mailbox"]
3894
3894
  };
3895
+ var promptCache = /* @__PURE__ */ new Map();
3896
+ var candidateCache = /* @__PURE__ */ new Map();
3895
3897
  function agentPrompt(id) {
3898
+ const envDir = process.env["WRONGSTACK_AGENT_INSTRUCTIONS_DIR"] ?? "";
3899
+ const cacheKey = `${envDir}\0${id}`;
3900
+ const cached = promptCache.get(cacheKey);
3901
+ if (cached !== void 0) return cached;
3896
3902
  const fileName = `${id}.md`;
3897
- for (const dir of agentPromptDirCandidates()) {
3903
+ let resolved = "";
3904
+ for (const dir of agentPromptDirCandidates(envDir)) {
3898
3905
  try {
3899
- return readFileSync(path5.join(dir, fileName), "utf8").trimEnd();
3906
+ resolved = readFileSync(path5.join(dir, fileName), "utf8").trimEnd();
3907
+ break;
3900
3908
  } catch {
3901
3909
  }
3902
3910
  }
3903
- return "";
3911
+ promptCache.set(cacheKey, resolved);
3912
+ return resolved;
3904
3913
  }
3905
- function agentPromptDirCandidates() {
3906
- const here = path5.dirname(fileURLToPath(import.meta.url));
3907
- const explicitDir = process.env["WRONGSTACK_AGENT_INSTRUCTIONS_DIR"];
3914
+ function agentPromptDirCandidates(envDir) {
3908
3915
  const globalRoot = process.env["WRONGSTACK_HOME"] || path5.join(os.homedir(), ".wrongstack");
3916
+ const candKey = `${envDir}\0${globalRoot}`;
3917
+ const cached = candidateCache.get(candKey);
3918
+ if (cached !== void 0) return cached;
3919
+ const here = path5.dirname(fileURLToPath(import.meta.url));
3920
+ const explicitDir = envDir || void 0;
3909
3921
  const candidates = [
3910
3922
  ...explicitDir ? [path5.resolve(explicitDir)] : [],
3911
3923
  path5.join(globalRoot, "instructions", "agents"),
@@ -3915,7 +3927,9 @@ function agentPromptDirCandidates() {
3915
3927
  path5.resolve(here, "../instructions/agents"),
3916
3928
  path5.resolve(here, "instructions/agents")
3917
3929
  ];
3918
- return candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));
3930
+ const ordered = candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));
3931
+ candidateCache.set(candKey, ordered);
3932
+ return ordered;
3919
3933
  }
3920
3934
  function isDirectory(candidate) {
3921
3935
  try {
@@ -5810,6 +5824,30 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5810
5824
  results() {
5811
5825
  return this.completedResults;
5812
5826
  }
5827
+ /** Defensive snapshot of the still-queued (not yet dispatched) tasks. */
5828
+ listPendingTasks() {
5829
+ return this.pendingTasks.map((t) => ({ ...t }));
5830
+ }
5831
+ /**
5832
+ * Re-pin a still-PENDING task to a different subagent (`undefined` =
5833
+ * unpin, any idle worker may take it), then try to dispatch. Returns
5834
+ * `false` when the task is not in the pending queue — already
5835
+ * dispatched, completed, or unknown. Running tasks can never be pulled;
5836
+ * they can only be steered or terminated. The mutation is synchronous
5837
+ * (same tick as the check), so it cannot race a concurrent dispatch:
5838
+ * `tryDispatchNext` runs on this same call stack or a later one.
5839
+ *
5840
+ * The task keeps its id, so waiters, the report-back notifier, and
5841
+ * checkpoint bookkeeping resolve unchanged when it eventually completes.
5842
+ */
5843
+ retargetPendingTask(taskId, subagentId) {
5844
+ const task = this.pendingTasks.find((t) => t.id === taskId);
5845
+ if (!task) return false;
5846
+ if (subagentId !== void 0 && !this.subagents.has(subagentId)) return false;
5847
+ task.subagentId = subagentId;
5848
+ this.tryDispatchNext();
5849
+ return true;
5850
+ }
5813
5851
  /**
5814
5852
  * Wait for one or more tasks to complete and return their results.
5815
5853
  * If a task is already done when called, returns immediately.
@@ -5837,6 +5875,43 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5837
5875
  })
5838
5876
  );
5839
5877
  }
5878
+ /**
5879
+ * Wait until AT LEAST ONE of the named tasks completes. Returns every
5880
+ * requested result already available at that moment (drain-what's-done)
5881
+ * plus the ids still outstanding, so callers can loop "handle finishers,
5882
+ * re-await the remainder" instead of blocking on the whole batch.
5883
+ *
5884
+ * Unlike `awaitTasks`, this never rejects and deliberately does NOT
5885
+ * inherit `config.timeoutMs` — a "return whatever is done" call has no
5886
+ * business timing out unless the caller asks for a window explicitly.
5887
+ */
5888
+ async awaitTasksAny(taskIds, opts) {
5889
+ const ids = new Set(taskIds);
5890
+ const completed = this.completedResults.filter((r) => ids.has(r.taskId));
5891
+ if (completed.length > 0 || ids.size === 0) {
5892
+ const done = new Set(completed.map((r) => r.taskId));
5893
+ return { completed, pending: taskIds.filter((id) => !done.has(id)) };
5894
+ }
5895
+ return new Promise((resolve4) => {
5896
+ let timer;
5897
+ const handler = ({ result }) => {
5898
+ if (!ids.has(result.taskId)) return;
5899
+ if (timer) clearTimeout(timer);
5900
+ this.off("task.completed", handler);
5901
+ resolve4({
5902
+ completed: [result],
5903
+ pending: taskIds.filter((id) => id !== result.taskId)
5904
+ });
5905
+ };
5906
+ if (opts?.timeoutMs !== void 0) {
5907
+ timer = setTimeout(() => {
5908
+ this.off("task.completed", handler);
5909
+ resolve4({ completed: [], pending: [...taskIds], timedOut: true });
5910
+ }, opts.timeoutMs);
5911
+ }
5912
+ this.on("task.completed", handler);
5913
+ });
5914
+ }
5840
5915
  /**
5841
5916
  * Manual completion — for callers that drive subagents without a runner
5842
5917
  * (e.g. external orchestrators). When a runner is configured the coordinator
@@ -9137,14 +9212,21 @@ function makeCommandVerifier(options = {}) {
9137
9212
  });
9138
9213
  };
9139
9214
  }
9215
+ var textCache = /* @__PURE__ */ new Map();
9216
+ var rootCandidates;
9140
9217
  function readBundledInstructionText(relativePath) {
9218
+ const cached = textCache.get(relativePath);
9219
+ if (cached !== void 0) return cached;
9220
+ let resolved = "";
9141
9221
  for (const root of instructionRootCandidates()) {
9142
9222
  try {
9143
- return readFileSync(path5.join(root, relativePath), "utf8").trimEnd();
9223
+ resolved = readFileSync(path5.join(root, relativePath), "utf8").trimEnd();
9224
+ break;
9144
9225
  } catch {
9145
9226
  }
9146
9227
  }
9147
- return "";
9228
+ textCache.set(relativePath, resolved);
9229
+ return resolved;
9148
9230
  }
9149
9231
  function renderInstructionTemplate(template, values) {
9150
9232
  return template.replace(
@@ -9153,13 +9235,15 @@ function renderInstructionTemplate(template, values) {
9153
9235
  );
9154
9236
  }
9155
9237
  function instructionRootCandidates() {
9238
+ if (rootCandidates !== void 0) return rootCandidates;
9156
9239
  const here = path5.dirname(fileURLToPath(import.meta.url));
9157
9240
  const candidates = [
9158
9241
  path5.resolve(here, "../../instructions"),
9159
9242
  path5.resolve(here, "../instructions"),
9160
9243
  path5.resolve(here, "instructions")
9161
9244
  ];
9162
- return candidates.sort((a, b) => Number(!isDirectory2(a)) - Number(!isDirectory2(b)));
9245
+ rootCandidates = candidates.sort((a, b) => Number(!isDirectory2(a)) - Number(!isDirectory2(b)));
9246
+ return rootCandidates;
9163
9247
  }
9164
9248
  function isDirectory2(candidate) {
9165
9249
  try {