@wrongstack/core 0.260.0 → 0.265.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 (99) hide show
  1. package/dist/{agent-bridge-BbskZ7HH.d.ts → agent-bridge-DrkBxszZ.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-BNIGZx18.d.ts → agent-subagent-runner-DM2pP-B6.d.ts} +116 -12
  3. package/dist/{brain-C2yDd7Lw.d.ts → brain-BXd_61kQ.d.ts} +32 -3
  4. package/dist/{compactor-t0R_AIt_.d.ts → compactor-B8pOf45Y.d.ts} +1 -1
  5. package/dist/{config-FG6As4H5.d.ts → config-BMCj_XDs.d.ts} +86 -12
  6. package/dist/{context-JFOVvu6z.d.ts → context-MRk5PhNv.d.ts} +26 -1
  7. package/dist/coordination/index.d.ts +1737 -15
  8. package/dist/coordination/index.js +3152 -494
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/{default-config-CXsDvOmP.d.ts → default-config-B0cj-Hry.d.ts} +11 -1
  11. package/dist/defaults/index.d.ts +28 -28
  12. package/dist/defaults/index.js +1804 -1363
  13. package/dist/defaults/index.js.map +1 -1
  14. package/dist/dispatcher-types.d-BBeXBQgS.d.ts +66 -0
  15. package/dist/execution/index.d.ts +16 -16
  16. package/dist/execution/index.js +933 -672
  17. package/dist/execution/index.js.map +1 -1
  18. package/dist/execution/prompt-enhancer.d.ts +1 -1
  19. package/dist/execution/prompt-enhancer.js +7 -1
  20. package/dist/execution/prompt-enhancer.js.map +1 -1
  21. package/dist/extension/index.d.ts +6 -6
  22. package/dist/extension/index.js.map +1 -1
  23. package/dist/{goal-preamble-B1IXJtLX.d.ts → goal-preamble-DvHDSKSe.d.ts} +26 -10
  24. package/dist/{goal-store-CPXz6Mml.d.ts → goal-store-DtLMySNb.d.ts} +1 -1
  25. package/dist/{index-CebbJB94.d.ts → index-B-ch8K9C.d.ts} +8 -8
  26. package/dist/{index-BPcg4N3M.d.ts → index-CEDeNodM.d.ts} +5 -5
  27. package/dist/index.d.ts +189 -104
  28. package/dist/index.js +24693 -21162
  29. package/dist/index.js.map +1 -1
  30. package/dist/infrastructure/index.d.ts +6 -6
  31. package/dist/infrastructure/index.js +12 -8
  32. package/dist/infrastructure/index.js.map +1 -1
  33. package/dist/kernel/index.d.ts +9 -9
  34. package/dist/kernel/index.js +7 -2
  35. package/dist/kernel/index.js.map +1 -1
  36. package/dist/{llm-selector-DXxI2tlu.d.ts → llm-selector-C0tfTCUe.d.ts} +14 -2
  37. package/dist/{mcp-servers-OwNHo43-.d.ts → mcp-servers-2x4w6Jn9.d.ts} +3 -3
  38. package/dist/models/index.d.ts +5 -5
  39. package/dist/models/index.js +80 -31
  40. package/dist/models/index.js.map +1 -1
  41. package/dist/{models-registry-Djlmq4uB.d.ts → models-registry-DmJlKuNp.d.ts} +1 -1
  42. package/dist/{multi-agent-coordinator-CEmrSCMJ.d.ts → multi-agent-coordinator-DyCkCZnU.d.ts} +2 -2
  43. package/dist/{null-fleet-bus-DT92xqgJ.d.ts → null-fleet-bus-CG9QY2aP.d.ts} +6 -6
  44. package/dist/observability/index.d.ts +2 -2
  45. package/dist/observability/index.js +8 -3
  46. package/dist/observability/index.js.map +1 -1
  47. package/dist/{parallel-eternal-engine-0SItuq5r.d.ts → parallel-eternal-engine-Jw9uhEoT.d.ts} +9 -9
  48. package/dist/{path-resolver-DKBh6Jlo.d.ts → path-resolver-Dy2ej-gE.d.ts} +3 -3
  49. package/dist/{permission-BJ7eO9Vl.d.ts → permission-B9SB45lp.d.ts} +1 -1
  50. package/dist/{permission-policy-DEXOfnpm.d.ts → permission-policy-CkjSXabK.d.ts} +2 -2
  51. package/dist/{pipeline-zflkI2dp.d.ts → pipeline-DPDxH_7m.d.ts} +59 -4
  52. package/dist/{plan-templates-BFXyRkEK.d.ts → plan-templates-CzD9GnAU.d.ts} +32 -8
  53. package/dist/{provider-runner-BC-uywtT.d.ts → provider-runner-DMa70ODu.d.ts} +3 -3
  54. package/dist/{retry-policy-Cavrzmtk.d.ts → retry-policy-CN0khdlj.d.ts} +1 -1
  55. package/dist/sdd/index.d.ts +8 -8
  56. package/dist/sdd/index.js +313 -122
  57. package/dist/sdd/index.js.map +1 -1
  58. package/dist/{secret-vault-CDvDYXWX.d.ts → secret-vault-B2yw84VT.d.ts} +43 -4
  59. package/dist/secret-vault-BAKpgFw_.d.ts +57 -0
  60. package/dist/security/index.d.ts +5 -5
  61. package/dist/security/index.js +411 -225
  62. package/dist/security/index.js.map +1 -1
  63. package/dist/{selector-B7AivHsu.d.ts → selector-CzHh_igB.d.ts} +1 -1
  64. package/dist/{session-event-bridge-BmIDxdJd.d.ts → session-event-bridge-BUI6Jf-4.d.ts} +8 -2
  65. package/dist/{session-reader-DtofsB-2.d.ts → session-reader-CMgdMSRP.d.ts} +1 -1
  66. package/dist/skills/index.js +67 -64
  67. package/dist/skills/index.js.map +1 -1
  68. package/dist/storage/index.d.ts +132 -16
  69. package/dist/storage/index.js +851 -432
  70. package/dist/storage/index.js.map +1 -1
  71. package/dist/tools/index.d.ts +57 -0
  72. package/dist/tools/index.js +411 -0
  73. package/dist/tools/index.js.map +1 -0
  74. package/dist/types/index.d.ts +21 -21
  75. package/dist/types/index.js +928 -711
  76. package/dist/types/index.js.map +1 -1
  77. package/dist/utils/error.d.ts +7 -0
  78. package/dist/utils/error.js +8 -0
  79. package/dist/utils/error.js.map +1 -0
  80. package/dist/utils/index.d.ts +8 -68
  81. package/dist/utils/index.js +20 -10
  82. package/dist/utils/index.js.map +1 -1
  83. package/dist/{wstack-paths-CJjEwPXn.d.ts → wstack-paths-hOpNLmvf.d.ts} +2 -0
  84. package/package.json +5 -1
  85. package/skills/api-design/SKILL.md +1 -1
  86. package/skills/audit-log/SKILL.md +6 -6
  87. package/skills/bug-hunter/SKILL.md +5 -5
  88. package/skills/chimera/SKILL.md +4 -4
  89. package/skills/docker-deploy/SKILL.md +1 -1
  90. package/skills/git-flow/SKILL.md +3 -3
  91. package/skills/multi-agent/SKILL.md +3 -3
  92. package/skills/node-modern/SKILL.md +1 -0
  93. package/skills/observability/SKILL.md +2 -2
  94. package/skills/output-standards/SKILL.md +51 -28
  95. package/skills/refactor-planner/SKILL.md +3 -3
  96. package/skills/security-scanner/SKILL.md +4 -3
  97. package/skills/tech-stack/SKILL.md +1 -2
  98. package/dist/package-outdated-watcher-C70ag2G9.d.ts +0 -581
  99. package/dist/secret-vault-BJDY28ev.d.ts +0 -25
@@ -1,581 +0,0 @@
1
- import { b as Mailbox, c as MailboxSendInput, d as MailboxMessage, e as MailboxQuery, f as MailboxAckInput, g as MailboxAgentStatus, A as AgentRegistrationInput, h as AgentHeartbeatInput, i as ClientRegistrationInput, j as ClientHeartbeatInput, k as ClientStatus } from './pipeline-zflkI2dp.js';
2
- import { E as EventBus, B as BrainArbiter } from './brain-C2yDd7Lw.js';
3
- import { C as Context, T as Tool } from './context-JFOVvu6z.js';
4
-
5
- /**
6
- * DefaultMailbox — append-only JSONL inter-agent mailbox (per-session).
7
- *
8
- * Stores messages under `<sessionDir>/_mailbox.jsonl`. Every send appends
9
- * one line. Query reads and filters all lines. Ack rewrites changed
10
- * messages in-place via atomic write.
11
- *
12
- * For cross-session communication, use GlobalMailbox instead.
13
- *
14
- * @module DefaultMailbox
15
- */
16
-
17
- declare class DefaultMailbox implements Mailbox {
18
- private readonly filePath;
19
- constructor(sessionDir: string);
20
- get mailboxPath(): string;
21
- send(input: MailboxSendInput): Promise<MailboxMessage>;
22
- query(q: MailboxQuery): Promise<MailboxMessage[]>;
23
- ack(input: MailboxAckInput): Promise<MailboxMessage | null>;
24
- getAgentStatuses(): Promise<MailboxAgentStatus[]>;
25
- getOnlineAgents(): Promise<MailboxAgentStatus[]>;
26
- registerAgent(_input: AgentRegistrationInput): Promise<void>;
27
- heartbeat(_input: AgentHeartbeatInput): Promise<void>;
28
- unreadCount(forAgentId: string): Promise<number>;
29
- close(): Promise<void>;
30
- clearAll(): Promise<void>;
31
- registerClient(_input: ClientRegistrationInput): Promise<void>;
32
- clientHeartbeat(_input: ClientHeartbeatInput): Promise<void>;
33
- getClientStatuses(): Promise<ClientStatus[]>;
34
- private _readAll;
35
- }
36
-
37
- /**
38
- * BrainMonitor — the Brain's SELF-ACTIVATION layer.
39
- *
40
- * The BrainArbiter alone is reactive: subsystems (director, autophase,
41
- * eternal engine) ask it questions. The monitor closes the loop the other
42
- * way — it WATCHES the live EventBus for distress signals, consults the
43
- * Brain proactively, and when the decision calls for it, INTERVENES in the
44
- * running work by delivering a corrective steer to the working agent
45
- * (steers are folded into the agent's conversation before its next step
46
- * via the mailbox loop, so no new plumbing is needed).
47
- *
48
- * Watched signals (v1):
49
- * - tool-failure streak — the same tool failing N times consecutively
50
- * (default 3). Classic stuck-loop: the agent keeps retrying an
51
- * approach that does not work.
52
- * - error storm — N `error` events within a sliding window (default
53
- * 4 in 60s). Something is systematically wrong.
54
- *
55
- * Decision contract: every consultation offers [steer | continue] with
56
- * fallback `continue`, at `medium` risk. Degradation is safe by design:
57
- * - tiered brain with an LLM layer → a real judgement call, with the
58
- * LLM's rationale becoming the steer text;
59
- * - policy-only brain → fallback `continue` → observe, never interfere.
60
- *
61
- * Every engagement (whether or not it intervened) emits
62
- * `brain.intervention` for the TUI/WebUI surfaces, and is rate-limited by
63
- * a per-signal cooldown so the Brain never spams the agent.
64
- *
65
- * @module brain-monitor
66
- */
67
-
68
- interface BrainInterventionInput {
69
- subject: string;
70
- body: string;
71
- }
72
- interface BrainMonitorOptions {
73
- events: EventBus;
74
- brain: BrainArbiter;
75
- /**
76
- * Deliver a corrective steer to the working agent(s). Hosts typically
77
- * send a `steer` mail to this session's leader via the project
78
- * GlobalMailbox — the agent loop injects it before the next LLM call.
79
- */
80
- intervene: (input: BrainInterventionInput) => Promise<void>;
81
- /** Consecutive failures of the SAME tool before engaging. Default 3. */
82
- toolFailureStreak?: number | undefined;
83
- /** Number of `error` events within the window before engaging. Default 4. */
84
- errorStormCount?: number | undefined;
85
- /** Sliding window for the error storm signal (ms). Default 60_000. */
86
- errorStormWindowMs?: number | undefined;
87
- /** Minimum gap between engagements of the same signal kind (ms). Default 120_000. */
88
- cooldownMs?: number | undefined;
89
- }
90
- declare class BrainMonitor {
91
- private readonly opts;
92
- private readonly failStreaks;
93
- private errorTimestamps;
94
- private readonly lastEngagedAt;
95
- private readonly unsubscribers;
96
- private engaging;
97
- private readonly toolFailureStreak;
98
- private readonly errorStormCount;
99
- private readonly errorStormWindowMs;
100
- private readonly cooldownMs;
101
- constructor(opts: BrainMonitorOptions);
102
- start(): void;
103
- stop(): void;
104
- private engage;
105
- private maybeIntervene;
106
- }
107
-
108
- /**
109
- * GlobalMailbox — project-level inter-agent mailbox with cross-session support.
110
- *
111
- * Stores messages at `~/.wrongstack/projects/<slug>/_mailbox.jsonl` so all
112
- * sessions (terminals, WebUIs) working on the same project share one inbox.
113
- *
114
- * Features:
115
- * - Agent registration + heartbeat (agents go stale after 60s without heartbeat)
116
- * - Per-recipient read receipts (readBy[agentId] = ISO8601)
117
- * - Atomic file-locking for concurrent multi-process writes
118
- * - Unread count for new-mail notifications
119
- * - Online agent list
120
- *
121
- * @module GlobalMailbox
122
- */
123
-
124
- /**
125
- * Derive the project-level mailbox directory path.
126
- *
127
- * Delegates to the CANONICAL `projectSlug()` from wstack-paths so every
128
- * surface (CLI, TUI, WebUI, mailbox tool, loop checker) lands in the exact
129
- * same `~/.wrongstack/projects/<slug>/` directory. A previous inline copy
130
- * skipped the leading/trailing-hyphen strip, which silently split agents
131
- * working on projects with non-alphanumeric name edges into TWO mailboxes.
132
- *
133
- * @param projectRoot — absolute path to the project root
134
- * @param globalRoot — `~/.wrongstack` (or custom global root)
135
- */
136
- declare function resolveProjectDir(projectRoot: string, globalRoot: string): string;
137
- declare class GlobalMailbox implements Mailbox {
138
- /** Path to the JSONL message file. */
139
- readonly messagePath: string;
140
- /** Path to the JSON agent registry file. */
141
- readonly registryPath: string;
142
- /** Path to the JSON client registry file. */
143
- readonly clientRegistryPath: string;
144
- /** Optional event bus for emitting agent registration/heartbeat events. */
145
- private readonly _events?;
146
- /**
147
- * Local cache of the agent registry to avoid re-reading on every call.
148
- * Time-bounded: the registry file is shared ACROSS PROCESSES (that's the
149
- * whole point of GlobalMailbox), so a cache served forever would never see
150
- * agents registered by other sessions. Writers always bypass it.
151
- */
152
- private _registryCache;
153
- /** When the registry cache was last refreshed from disk (epoch ms). */
154
- private _registryCacheAt;
155
- /**
156
- * Local cache of the client registry to avoid re-reading on every call.
157
- * Same reasoning as agent registry cache.
158
- */
159
- private _clientRegistryCache;
160
- /** When the client registry cache was last refreshed from disk (epoch ms). */
161
- private _clientRegistryCacheAt;
162
- /** Last time each local agent sent a heartbeat (throttle). */
163
- private _lastHeartbeat;
164
- /** Last time each local client sent a heartbeat (throttle). */
165
- private _lastClientHeartbeat;
166
- /**
167
- * @param projectDir — `~/.wrongstack/projects/<slug>/`
168
- * @param events — optional EventBus for real-time TUI/WebUI notifications
169
- */
170
- constructor(projectDir: string, events?: EventBus);
171
- send(input: MailboxSendInput): Promise<MailboxMessage>;
172
- query(q: MailboxQuery): Promise<MailboxMessage[]>;
173
- ack(input: MailboxAckInput): Promise<MailboxMessage | null>;
174
- unreadCount(forAgentId: string): Promise<number>;
175
- registerAgent(input: AgentRegistrationInput): Promise<void>;
176
- heartbeat(input: AgentHeartbeatInput): Promise<void>;
177
- getAgentStatuses(): Promise<MailboxAgentStatus[]>;
178
- getOnlineAgents(): Promise<MailboxAgentStatus[]>;
179
- registerClient(input: ClientRegistrationInput): Promise<void>;
180
- clientHeartbeat(input: ClientHeartbeatInput): Promise<void>;
181
- getClientStatuses(): Promise<ClientStatus[]>;
182
- close(): Promise<void>;
183
- clearAll(): Promise<void>;
184
- private _readMessages;
185
- private _ensureRegistry;
186
- private _readRegistry;
187
- private _pruneStaleInPlace;
188
- private _writeRegistry;
189
- private _ensureClientRegistry;
190
- private _readClientRegistry;
191
- private _pruneStaleClientsInPlace;
192
- private _writeClientRegistry;
193
- }
194
-
195
- /**
196
- * mailbox-tool — Tool that exposes the inter-agent mailbox to agents.
197
- *
198
- * Sub-commands: check, send, ack, query, status, online, unread
199
- *
200
- * Uses the project-level GlobalMailbox for cross-session communication.
201
- * Agents are auto-registered on first use with heartbeat tracking.
202
- * Read receipts track who read each message and when.
203
- *
204
- * @module mailbox-tool
205
- */
206
-
207
- type MailboxResolver = (ctx: Context) => Mailbox;
208
- interface MailboxToolOptions {
209
- /**
210
- * How to obtain a Mailbox instance given the execution Context.
211
- * Default: derives project dir from ctx and creates a GlobalMailbox.
212
- */
213
- resolveMailbox?: MailboxResolver | undefined;
214
- /**
215
- * Agent id of the caller — used as default "from" on send.
216
- * Default: 'leader' for the main agent, or derived from ctx.meta.
217
- */
218
- agentId?: string | undefined;
219
- /** Session id for cross-session communication. Default: derived from ctx. */
220
- sessionId?: string | undefined;
221
- /**
222
- * Project directory where the mailbox is stored.
223
- * Default: derived from ctx.projectRoot (may differ from wpaths.projectDir).
224
- * For correct cross-session sharing, pass `wpaths.projectDir` from the caller.
225
- */
226
- projectDir?: string | undefined;
227
- /**
228
- * EventBus for emitting mailbox.agent_registered and mailbox.agent_heartbeat
229
- * events so the TUI/WebUI can update the online agent count in the status bar.
230
- * When omitted, events are not emitted and the status bar count stays at 0.
231
- */
232
- events?: EventBus | undefined;
233
- }
234
- /**
235
- * Compact, deterministic tag for a session id — 8 hex chars of its sha256.
236
- * Session ids are date-sharded paths ("2026-06-11/10-48-34Z_model_e66c");
237
- * the tag keeps mailbox identities short, filesystem-safe, and stable for
238
- * the lifetime of the session (including across process restarts/resumes).
239
- */
240
- declare function mailboxSessionTag(sessionId: string): string;
241
- /**
242
- * Resolve the caller's mailbox identity from the execution Context.
243
- *
244
- * Shared by the `mailbox` power-tool, the thin `mail_send`/`mail_inbox`
245
- * tools, the agent-loop checker, and the /mailbox slash command so every
246
- * surface agrees on who is talking:
247
- * - base id: ctx.meta.agentId → ctx.agentId field (subagents) → fallback
248
- * - unique id: `<base>@<sessionTag>` — SESSION-bound, not pid-bound. Every
249
- * session has its own id, so two leader sessions on the same project
250
- * never collide (pids can be recycled by the OS), and a resumed session
251
- * keeps its identity: read state survives a restart instead of
252
- * re-flooding old broadcasts. Derived LIVE from ctx.session.id so an
253
- * in-process session swap (resume / session.new / project switch) moves
254
- * the identity with it. `ctx.meta.globalAgentId` remains an explicit
255
- * override for hosts that manage identity themselves.
256
- */
257
- declare function resolveMailboxIdentity(ctx: Context, fallbackBase?: string): {
258
- baseId: string;
259
- callerId: string;
260
- name: string;
261
- role?: string | undefined;
262
- sessionId: string;
263
- };
264
- declare function makeMailboxTool(opts?: MailboxToolOptions): Tool;
265
-
266
- /**
267
- * mail-tools — thin, high-affordance wrappers over the project mailbox.
268
- *
269
- * The multi-action `mailbox` tool is the power surface; these two exist
270
- * because explicit verbs ("send a mail", "read my inbox") are what makes
271
- * agents USE the mailbox autonomously — a model reaches for `mail_send`
272
- * mid-task far more readily than for `mailbox action=send ...`.
273
- *
274
- * mail_send — message one agent (`to: "leader@a1b2c3d4"`), every leader
275
- * (`to: "leader"`), or everyone (`to: "*"`)
276
- * mail_inbox — read unread mail (unique id + base alias + broadcasts),
277
- * marking it read so it isn't re-injected next iteration
278
- *
279
- * Both share the identity convention with the agent-loop checker
280
- * (`<base>@<sessionTag>`, see mailbox-attach) via `resolveMailboxIdentity`.
281
- *
282
- * @module mail-tools
283
- */
284
-
285
- interface MailToolsOptions {
286
- /** How to obtain a Mailbox given the execution Context (tests). */
287
- resolveMailbox?: MailboxResolver | undefined;
288
- /** Project dir for the shared mailbox. Prefer wpaths.projectDir. */
289
- projectDir?: string | undefined;
290
- /** EventBus for mailbox.agent_registered / heartbeat surface events. */
291
- events?: EventBus | undefined;
292
- }
293
- declare function makeMailSendTool(opts?: MailToolsOptions): Tool;
294
- declare function makeMailInboxTool(opts?: MailToolsOptions): Tool;
295
-
296
- /**
297
- * dep-watcher — File-change → Mailbox bridge for dependency monitoring.
298
- *
299
- * Watches dependency manifest files (package.json, go.mod, Cargo.toml, etc.)
300
- * and when they change (create/update), posts a message to the inter-agent
301
- * mailbox. A tech-stack analysis agent can then pick up the message and
302
- * run a full tech-stack validation, feeding results back to the coding LLM.
303
- *
304
- * This module is a *config factory*, not a watcher itself. It produces
305
- * configuration that the file-watcher plugin (`watch_start`) can consume,
306
- * plus a callback that posts to a Mailbox instance.
307
- *
308
- * Usage:
309
- * const cfg = makeDependencyWatcherConfig({
310
- * projectRoot: '/path/to/project',
311
- * mailbox,
312
- * targetAgent: 'tech-stack-agent',
313
- * });
314
- * // cfg.watchPaths → pass to watch_start
315
- * // cfg.onChange → call on file-watcher:changed events
316
- *
317
- * @module dep-watcher
318
- */
319
-
320
- /**
321
- * Files that declare project dependencies. When any of these change
322
- * (create/update), a mailbox message triggers a tech-stack audit.
323
- */
324
- declare const DEPENDENCY_FILE_PATTERNS: ReadonlyArray<string>;
325
- interface DepWatchEntry {
326
- /** Relative path from project root that changed. */
327
- path: string;
328
- /** Event type from the file watcher: 'change', 'add', 'delete' (rare). */
329
- event: string;
330
- /** ISO8601 timestamp of when the change was detected. */
331
- timestamp: string;
332
- }
333
- interface DependencyWatcherConfig {
334
- /** Paths to pass to `watch_start` — the project-root-relative dependency files. */
335
- watchPaths: string[];
336
- /** Callback to invoke when a dependency file changes. Posts to mailbox. */
337
- onChange: (entry: DepWatchEntry) => Promise<void>;
338
- /** Debounce window in ms — multiple changes to the same file within this window are collapsed. */
339
- debounceMs: number;
340
- }
341
- interface DependencyWatcherOptions {
342
- /** Absolute path to the project root. */
343
- projectRoot: string;
344
- /** The mailbox instance where messages will be posted. */
345
- mailbox: Mailbox;
346
- /** Agent id that should receive the tech-stack audit task. */
347
- targetAgent?: string | undefined;
348
- /** Agent id of the watcher (sender). */
349
- watcherAgentId?: string | undefined;
350
- /** Debounce window in ms. Default: 3000 (3 seconds). */
351
- debounceMs?: number | undefined;
352
- /** Only watch these specific patterns. Defaults to DEPENDENCY_FILE_PATTERNS. */
353
- patterns?: string[] | undefined;
354
- }
355
- /**
356
- * Build a dependency watcher configuration. The returned `watchPaths` can be
357
- * passed directly to the `watch_start` tool, and `onChange` should be wired
358
- * to the `file-watcher:changed` custom event.
359
- *
360
- * When a dependency file changes, `onChange` posts a high-priority `assign`
361
- * message to the mailbox targeting the tech-stack agent, with the changed
362
- * file path and event type in the body.
363
- */
364
- declare function makeDependencyWatcherConfig(opts: DependencyWatcherOptions): DependencyWatcherConfig;
365
-
366
- /**
367
- * dep-watcher-bridge — Bridges the file-watcher plugin's custom events
368
- * to the dependency watcher → mailbox pipeline.
369
- *
370
- * The file-watcher plugin emits `file-watcher:changed` custom events
371
- * when files change. This module subscribes to those events, filters
372
- * for dependency manifests (package.json, go.mod, etc.), and posts
373
- * assign messages to the inter-agent mailbox for tech-stack audit.
374
- *
375
- * Returns a dispose function that unsubscribes from the event bus.
376
- *
377
- * @module dep-watcher-bridge
378
- */
379
-
380
- interface DepWatcherBridgeOptions {
381
- /** The event bus to subscribe to (same bus the file-watcher plugin emits on). */
382
- events: EventBus;
383
- /** The mailbox instance where dep-change notifications will be posted. */
384
- mailbox: Mailbox;
385
- /** Absolute project root — used to build watch paths and match file patterns. */
386
- projectRoot: string;
387
- /** Agent id the tech-stack audit tasks should target. Default: 'tech-stack'. */
388
- targetAgent?: string | undefined;
389
- /** Agent id of the watcher/sender. Default: 'dep-watcher'. */
390
- watcherAgentId?: string | undefined;
391
- /** Debounce window in ms. Default: 3000 (3 seconds). */
392
- debounceMs?: number | undefined;
393
- }
394
- /**
395
- * Wire the file-watcher's `file-watcher:changed` events into the
396
- * dependency watcher → mailbox pipeline.
397
- *
398
- * Returns a dispose function. Call it to unsubscribe when the
399
- * session ends or the watcher is no longer needed.
400
- *
401
- * Usage:
402
- * const dispose = attachDepWatcherBridge({
403
- * events: ctx.events,
404
- * mailbox: new DefaultMailbox(sessionDir),
405
- * projectRoot: ctx.projectRoot,
406
- * });
407
- * // ... session runs ...
408
- * dispose(); // clean up on exit
409
- */
410
- declare function attachDepWatcherBridge(opts: DepWatcherBridgeOptions): () => void;
411
-
412
- /**
413
- * package-author-tracker — Tracks which agent added which package to which manifest.
414
- *
415
- * Stores a per-project JSON log in the global project directory:
416
- * ~/.wrongstack/projects/<slug-hash>/package-authors.json
417
- *
418
- * Each entry records: manifest path, package name, version range at time of add,
419
- * agent id/name, timestamp, and session id.
420
- *
421
- * Used by the tech-stack agent and outdated-watcher to route outdated-package
422
- * notifications back to the agent that originally added the package.
423
- *
424
- * @module package-author-tracker
425
- */
426
- interface PackageAuthorEntry {
427
- /** Absolute or relative path to the manifest (package.json, go.mod, etc.). */
428
- manifestPath: string;
429
- /** Exact package name as it appears in the manifest. */
430
- packageName: string;
431
- /** Version specifier at time of install (e.g. "^1.2.0", "latest", "file:..."). */
432
- versionSpec: string;
433
- /** Ecosystem: 'npm', 'cargo', 'go', 'pip', 'gem', 'composer', 'nuget', etc. */
434
- ecosystem: string;
435
- /** Agent id that performed the install (e.g. 'leader', 'executor', 'tech-stack'). */
436
- agentId: string;
437
- /** Human-readable agent name. */
438
- agentName?: string | undefined;
439
- /** Session that performed the install. */
440
- sessionId?: string | undefined;
441
- /** ISO8601 timestamp. */
442
- timestamp: string;
443
- /** Whether this package is currently flagged as outdated. */
444
- outdated?: boolean | undefined;
445
- /** Latest version available (set by outdated checker). */
446
- latestVersion?: string | undefined;
447
- }
448
- interface PackageAuthorLog {
449
- /** Project root this log belongs to. */
450
- projectRoot: string;
451
- /** All entries, newest last. */
452
- entries: PackageAuthorEntry[];
453
- /** Last time the log was compacted. */
454
- lastCompactedAt?: string | undefined;
455
- }
456
- interface PackageAuthorTrackerOptions {
457
- /** Directory where the JSON log is stored. Usually the global project dir. */
458
- storageDir: string;
459
- /** Project root for reference. */
460
- projectRoot: string;
461
- /** Max entries before auto-compaction. Default: 10000. */
462
- maxEntries?: number | undefined;
463
- }
464
- /**
465
- * Detect the ecosystem from a manifest filename.
466
- */
467
- declare function detectEcosystem(manifestPath: string): string;
468
- /**
469
- * Record that an agent added (or updated) a package to a manifest file.
470
- *
471
- * If the same (manifestPath, packageName) entry already exists, the previous
472
- * entry is kept (for audit trail) and a new entry is appended.
473
- */
474
- declare function recordPackageAction(opts: PackageAuthorTrackerOptions, entry: Omit<PackageAuthorEntry, 'timestamp'>): Promise<void>;
475
- /**
476
- * Get the most recent author entry for a given (manifest, package) pair.
477
- * Returns undefined if no entry exists.
478
- */
479
- declare function getPackageAuthor(opts: Pick<PackageAuthorTrackerOptions, 'storageDir' | 'projectRoot'>, manifestPath: string, packageName: string): Promise<PackageAuthorEntry | undefined>;
480
- /**
481
- * Get all packages in a manifest that have an author on record.
482
- */
483
- declare function getManifestPackages(opts: Pick<PackageAuthorTrackerOptions, 'storageDir' | 'projectRoot'>, manifestPath: string): Promise<PackageAuthorEntry[]>;
484
- /**
485
- * Get all packages last tracked by a specific agent.
486
- * Returns a Map from (manifestPath, packageName) → entry.
487
- */
488
- declare function getPackagesByAgent(opts: Pick<PackageAuthorTrackerOptions, 'storageDir' | 'projectRoot'>, agentId: string): Promise<Map<string, PackageAuthorEntry>>;
489
- /**
490
- * Update the outdated status of a package entry (adds or replaces the entry
491
- * for the given manifest+package, appending to the log for audit).
492
- */
493
- declare function updatePackageOutdatedStatus(opts: PackageAuthorTrackerOptions, manifestPath: string, packageName: string, outdated: boolean, latestVersion?: string | undefined): Promise<void>;
494
- /**
495
- * Return the full log (for debugging/auditing).
496
- */
497
- declare function getFullPackageLog(opts: Pick<PackageAuthorTrackerOptions, 'storageDir' | 'projectRoot'>): Promise<PackageAuthorLog>;
498
-
499
- /**
500
- * package-outdated-watcher — Periodically checks installed packages for outdated
501
- * versions and notifies the agent that originally added each package.
502
- *
503
- * Architecture:
504
- * 1. Polls the mailbox for `assign` messages from the tech-stack agent
505
- * containing outdated package results.
506
- * 2. For each outdated package, looks up the original author via
507
- * `package-author-tracker`.
508
- * 3. Sends a high-priority `note` message to the original author (or
509
- * broadcasts to `*` if the author is unknown or no longer online).
510
- *
511
- * The watcher can also be triggered directly via `checkOutdated` for
512
- * on-demand checks (e.g. on a timer, or when the user requests it).
513
- *
514
- * Usage:
515
- * const dispose = startPackageOutdatedWatcher({
516
- * mailbox,
517
- * storageDir: wpaths.globalDir,
518
- * projectRoot,
519
- * pollIntervalMs: 60 * 60 * 1000, // 1 hour
520
- * onNotify: async (msg) => mailbox.send(msg),
521
- * onLog: (m) => console.log(`[pkg-outdated-watcher] ${m}`),
522
- * });
523
- *
524
- * @module package-outdated-watcher
525
- */
526
-
527
- interface PackageOutdatedEntry {
528
- /** Package name. */
529
- name: string;
530
- /** Currently installed version. */
531
- currentVersion: string;
532
- /** Latest stable version available. */
533
- latestVersion: string;
534
- /** semver major.minor.patch wanted range (from lockfile). */
535
- wantedVersion: string;
536
- /** Manifest file this package belongs to. */
537
- manifestPath: string;
538
- /** Ecosystem: 'npm', 'cargo', 'go', etc. */
539
- ecosystem: string;
540
- }
541
- interface PackageOutdatedResult {
542
- /** All outdated entries. */
543
- outdated: PackageOutdatedEntry[];
544
- /** Packages that are up-to-date. */
545
- upToDate: string[];
546
- /** Whether the check failed. */
547
- checkFailed: boolean;
548
- }
549
- interface PackageOutdatedWatcherOptions {
550
- /** The mailbox for sending notifications and receiving tech-stack results. */
551
- mailbox: Mailbox;
552
- /** Package-author-tracker options. */
553
- packageTrackerOpts: Pick<PackageAuthorTrackerOptions, 'storageDir' | 'projectRoot'>;
554
- /** Polling interval in ms. Default: 60 * 60 * 1000 (1 hour). */
555
- pollIntervalMs?: number | undefined;
556
- /** Agent id that runs this watcher. Default: 'pkg-outdated-watcher'. */
557
- watcherAgentId?: string | undefined;
558
- /** Agent id of the tech-stack agent to watch for results. Default: 'tech-stack'. */
559
- techStackAgentId?: string | undefined;
560
- /** Called to send a notification to an agent. */
561
- onNotify: (msg: OutdatedNotifyMessage) => Promise<void>;
562
- /** Called for log output. */
563
- onLog?: ((msg: string) => void) | undefined;
564
- /** Called on errors. */
565
- onError?: ((err: unknown) => void) | undefined;
566
- }
567
- interface OutdatedNotifyMessage {
568
- from: string;
569
- to: string;
570
- subject: string;
571
- body: string;
572
- priority: 'high' | 'normal' | 'low';
573
- }
574
- /**
575
- * Start the package outdated watcher.
576
- *
577
- * Returns a dispose function that stops polling and cleans up.
578
- */
579
- declare function startPackageOutdatedWatcher(opts: PackageOutdatedWatcherOptions): () => void;
580
-
581
- export { resolveProjectDir as A, type BrainInterventionInput as B, startPackageOutdatedWatcher as C, DEPENDENCY_FILE_PATTERNS as D, updatePackageOutdatedStatus as E, GlobalMailbox as G, type MailToolsOptions as M, type OutdatedNotifyMessage as O, type PackageAuthorEntry as P, BrainMonitor as a, type BrainMonitorOptions as b, DefaultMailbox as c, type DepWatchEntry as d, type DepWatcherBridgeOptions as e, type DependencyWatcherConfig as f, type MailboxResolver as g, type MailboxToolOptions as h, type PackageAuthorLog as i, type PackageAuthorTrackerOptions as j, type PackageOutdatedEntry as k, type PackageOutdatedResult as l, type PackageOutdatedWatcherOptions as m, attachDepWatcherBridge as n, detectEcosystem as o, getFullPackageLog as p, getManifestPackages as q, getPackageAuthor as r, getPackagesByAgent as s, mailboxSessionTag as t, makeDependencyWatcherConfig as u, makeMailInboxTool as v, makeMailSendTool as w, makeMailboxTool as x, recordPackageAction as y, resolveMailboxIdentity as z };
@@ -1,25 +0,0 @@
1
- /**
2
- * SecretVault encrypts secrets-at-rest in config files. The wire format is
3
- * `enc:v1:<base64-iv>:<base64-tag>:<base64-ciphertext>`. Plaintext strings
4
- * (those that do not match this prefix) are passed through unchanged so that
5
- * existing configs and env-var-derived values keep working.
6
- *
7
- * The vault is intentionally NOT designed to defeat a determined local
8
- * attacker who can read both the config file and the key file — that level
9
- * of secrecy needs the OS keychain. The goal is to keep keys from being
10
- * visible in screen shares, accidental log captures, and `cat config.json`
11
- * over someone's shoulder.
12
- */
13
- interface SecretVault {
14
- encrypt(plaintext: string): string;
15
- decrypt(value: string): string;
16
- isEncrypted(value: string): boolean;
17
- }
18
- /**
19
- * No-op SecretVault that passes values through unchanged.
20
- * Used in contexts where encryption is not needed — e.g. reading/writing
21
- * config sections that contain no secret fields (models, settings, etc.).
22
- */
23
- declare const noOpVault: SecretVault;
24
-
25
- export { type SecretVault as S, noOpVault as n };