@wrongstack/core 0.155.0 → 0.236.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 (81) hide show
  1. package/dist/{agent-bridge-BbZU5TPN.d.ts → agent-bridge-Cimv7bK7.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-Bsueu0J2.d.ts → agent-subagent-runner-C658wj_c.d.ts} +9 -8
  3. package/dist/{brain-CS_B0vIE.d.ts → brain-sCZ3lCjq.d.ts} +26 -2
  4. package/dist/{compactor-BueGt7LG.d.ts → compactor-BRfg3QPd.d.ts} +1 -1
  5. package/dist/{config-BaVThgnT.d.ts → config-Koq6f3fs.d.ts} +2 -2
  6. package/dist/{context-C7G_MtLV.d.ts → context-CLz3z_E8.d.ts} +126 -2
  7. package/dist/coordination/index.d.ts +70 -13
  8. package/dist/coordination/index.js +1983 -145
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -26
  11. package/dist/defaults/index.js +1105 -289
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +45 -16
  14. package/dist/execution/index.js +224 -53
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +86 -0
  17. package/dist/execution/prompt-enhancer.js +125 -0
  18. package/dist/execution/prompt-enhancer.js.map +1 -0
  19. package/dist/extension/index.d.ts +6 -6
  20. package/dist/extension/index.js +3 -1
  21. package/dist/extension/index.js.map +1 -1
  22. package/dist/{goal-preamble-CbV8pXLD.d.ts → goal-preamble-CnbzyVvl.d.ts} +19 -10
  23. package/dist/{index-CI1hRfPt.d.ts → index-BlMqh5GO.d.ts} +8 -8
  24. package/dist/{index-B5wz-GXm.d.ts → index-C2eSNPsB.d.ts} +7 -5
  25. package/dist/index.d.ts +438 -128
  26. package/dist/index.js +4974 -836
  27. package/dist/index.js.map +1 -1
  28. package/dist/infrastructure/index.d.ts +7 -7
  29. package/dist/infrastructure/index.js +61 -13
  30. package/dist/infrastructure/index.js.map +1 -1
  31. package/dist/kernel/index.d.ts +9 -9
  32. package/dist/kernel/index.js +7 -1
  33. package/dist/kernel/index.js.map +1 -1
  34. package/dist/{llm-selector-CP72f1lC.d.ts → llm-selector-D22R4AFz.d.ts} +2 -2
  35. package/dist/logger-DmmQhf4P.d.ts +65 -0
  36. package/dist/{mcp-servers-CPERR2De.d.ts → mcp-servers-DFbirBv6.d.ts} +3 -3
  37. package/dist/models/index.d.ts +5 -5
  38. package/dist/models/index.js +89 -9
  39. package/dist/models/index.js.map +1 -1
  40. package/dist/{models-registry-D90K9UnM.d.ts → models-registry-CnJRjTXc.d.ts} +1 -1
  41. package/dist/{multi-agent-coordinator-BSKSFNhv.d.ts → multi-agent-coordinator-60weDZoA.d.ts} +8 -8
  42. package/dist/{null-fleet-bus-CGOez8Le.d.ts → null-fleet-bus-1068dEnr.d.ts} +7 -7
  43. package/dist/observability/index.d.ts +2 -2
  44. package/dist/package-outdated-watcher-pzJ5w7y8.d.ts +560 -0
  45. package/dist/{parallel-eternal-engine-CYoTKjsz.d.ts → parallel-eternal-engine-DtG1fjc9.d.ts} +13 -9
  46. package/dist/{path-resolver-DuhlmPil.d.ts → path-resolver-CA1ULU0J.d.ts} +3 -3
  47. package/dist/{permission-B7nKnEvQ.d.ts → permission-DbWPbuoA.d.ts} +1 -1
  48. package/dist/{permission-policy-8-6zBmfA.d.ts → permission-policy-AOk0LVsV.d.ts} +2 -2
  49. package/dist/pipeline-DsmlwTXu.d.ts +493 -0
  50. package/dist/{plan-templates-DbH7lg-t.d.ts → plan-templates-DPABrDvy.d.ts} +18 -7
  51. package/dist/{provider-runner-Cocq0O9E.d.ts → provider-runner-D0HgUqwV.d.ts} +3 -3
  52. package/dist/{retry-policy-rutAfVeR.d.ts → retry-policy-BVnkbMET.d.ts} +1 -1
  53. package/dist/sdd/index.d.ts +8 -8
  54. package/dist/sdd/index.js +215 -79
  55. package/dist/sdd/index.js.map +1 -1
  56. package/dist/{secret-vault-w8MbUe2Q.d.ts → secret-vault-CeVNiy_f.d.ts} +3 -2
  57. package/dist/security/index.d.ts +5 -4
  58. package/dist/security/index.js +155 -13
  59. package/dist/security/index.js.map +1 -1
  60. package/dist/{selector-4vDFZKt3.d.ts → selector-Cb4_9-hf.d.ts} +1 -1
  61. package/dist/{session-event-bridge-DWlvglC2.d.ts → session-event-bridge-BhtkkFFy.d.ts} +4 -2
  62. package/dist/{session-reader-BAtCxdaw.d.ts → session-reader-CCOssnBS.d.ts} +1 -1
  63. package/dist/skills/index.js +171 -21
  64. package/dist/skills/index.js.map +1 -1
  65. package/dist/storage/index.d.ts +150 -12
  66. package/dist/storage/index.js +1041 -214
  67. package/dist/storage/index.js.map +1 -1
  68. package/dist/types/index.d.ts +67 -20
  69. package/dist/types/index.js +557 -52
  70. package/dist/types/index.js.map +1 -1
  71. package/dist/utils/expect-defined.js +3 -1
  72. package/dist/utils/expect-defined.js.map +1 -1
  73. package/dist/utils/index.d.ts +16 -4
  74. package/dist/utils/index.js +40 -14
  75. package/dist/utils/index.js.map +1 -1
  76. package/dist/{wstack-paths-DD50Omgn.d.ts → wstack-paths-CJjEwPXn.d.ts} +14 -1
  77. package/package.json +7 -3
  78. package/skills/chimera/SKILL.md +105 -0
  79. package/skills/research-web/SKILL.md +342 -0
  80. package/dist/logger-B9J5puGM.d.ts +0 -32
  81. package/dist/pipeline-BG7UgbDc.d.ts +0 -239
@@ -1,12 +1,12 @@
1
- import { e as ProviderError, C as Context, T as Tool, m as ToolUseBlock, n as ToolResultBlock } from './context-C7G_MtLV.js';
2
- import { R as RetryPolicy, E as ErrorHandler, a as RecoveryDecision } from './retry-policy-rutAfVeR.js';
3
- import { C as Compactor, a as CompactReport } from './compactor-BueGt7LG.js';
4
- import { M as ModelsRegistry } from './config-BaVThgnT.js';
5
- import { T as ToolExecutorOptions, a as ToolExecutorStrategy, b as ToolBatchResult } from './index-B5wz-GXm.js';
6
- import { g as Agent, h as AgentFactory } from './agent-subagent-runner-Bsueu0J2.js';
7
- import { b as BrainArbiter } from './brain-CS_B0vIE.js';
1
+ import { e as ProviderError, C as Context, T as Tool, l as ToolUseBlock, m as ToolResultBlock } from './context-CLz3z_E8.js';
2
+ import { R as RetryPolicy, E as ErrorHandler, a as RecoveryDecision } from './retry-policy-BVnkbMET.js';
3
+ import { C as Compactor, a as CompactReport } from './compactor-BRfg3QPd.js';
4
+ import { M as ModelsRegistry } from './config-Koq6f3fs.js';
5
+ import { T as ToolExecutorOptions, a as ToolExecutorStrategy, b as ToolBatchResult } from './index-C2eSNPsB.js';
6
+ import { g as Agent, h as AgentFactory } from './agent-subagent-runner-C658wj_c.js';
7
+ import { B as BrainArbiter } from './brain-sCZ3lCjq.js';
8
8
  import { J as JournalEntry } from './goal-store-CV9Yz2X_.js';
9
- import { D as DispatchClassifier, a as DefaultMultiAgentCoordinator } from './multi-agent-coordinator-BSKSFNhv.js';
9
+ import { D as DispatchClassifier, a as DefaultMultiAgentCoordinator } from './multi-agent-coordinator-60weDZoA.js';
10
10
 
11
11
  declare class DefaultRetryPolicy implements RetryPolicy {
12
12
  shouldRetry(err: Error | ProviderError, attempt: number): boolean;
@@ -94,6 +94,10 @@ declare class HybridCompactor implements Compactor {
94
94
  declare class ToolExecutor {
95
95
  private readonly registry;
96
96
  private opts;
97
+ /** Minimum gap between coalesced `partial_output` tool.progress emits. */
98
+ static readonly PROGRESS_EMIT_INTERVAL_MS = 100;
99
+ /** Max chars of accumulated stream text carried per coalesced emit. */
100
+ static readonly PROGRESS_TAIL_CHARS = 16384;
97
101
  private readonly serializer;
98
102
  private readonly iterationTimeoutMs;
99
103
  private readonly maxToolTimeoutMs;
@@ -523,4 +527,4 @@ declare class ParallelEternalEngine {
523
527
  private persistState;
524
528
  }
525
529
 
526
- export { type CompactorOptions as C, DefaultErrorHandler as D, EternalAutonomyEngine as E, HybridCompactor as H, type IterationStage as I, type ParallelEngineState as P, type RecoveryStrategy as R, ToolExecutor as T, DefaultRetryPolicy as a, type EternalAutonomyOptions as b, type EternalEngineState as c, ParallelEternalEngine as d, type ParallelEternalOptions as e, type ParallelIterationStage as f, DEFAULT_RECOVERY_STRATEGIES as g, buildRecoveryStrategies as h };
530
+ export { type CompactorOptions as C, DEFAULT_RECOVERY_STRATEGIES as D, EternalAutonomyEngine as E, HybridCompactor as H, type IterationStage as I, type ParallelEngineState as P, type RecoveryStrategy as R, ToolExecutor as T, DefaultErrorHandler as a, DefaultRetryPolicy as b, type EternalAutonomyOptions as c, type EternalEngineState as d, ParallelEternalEngine as e, type ParallelEternalOptions as f, type ParallelIterationStage as g, buildRecoveryStrategies as h };
@@ -1,6 +1,6 @@
1
- import { E as EventBus } from './brain-CS_B0vIE.js';
2
- import { M as ModelsRegistry, b as ResolvedModel } from './config-BaVThgnT.js';
3
- import { c as TokenCounter, U as Usage, d as CacheStats } from './context-C7G_MtLV.js';
1
+ import { E as EventBus } from './brain-sCZ3lCjq.js';
2
+ import { M as ModelsRegistry, b as ResolvedModel } from './config-Koq6f3fs.js';
3
+ import { c as TokenCounter, U as Usage, d as CacheStats } from './context-CLz3z_E8.js';
4
4
  import { P as PathResolver } from './path-resolver-CPRj4bFY.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { T as Tool, C as Context, f as Permission } from './context-C7G_MtLV.js';
1
+ import { T as Tool, C as Context, f as Permission } from './context-CLz3z_E8.js';
2
2
 
3
3
  interface SecretScrubber {
4
4
  scrub(text: string): string;
@@ -1,6 +1,6 @@
1
- import { T as Tool, C as Context } from './context-C7G_MtLV.js';
1
+ import { T as Tool, C as Context } from './context-CLz3z_E8.js';
2
2
  import { I as InputReader } from './input-reader-E-ffP2ee.js';
3
- import { P as PermissionPolicy, a as PermissionDecision } from './permission-B7nKnEvQ.js';
3
+ import { P as PermissionPolicy, a as PermissionDecision } from './permission-DbWPbuoA.js';
4
4
 
5
5
  interface PermissionPolicyOptions {
6
6
  trustFile: string;
@@ -0,0 +1,493 @@
1
+ import { T as Tool, n as TextBlock, g as ContentBlock } from './context-CLz3z_E8.js';
2
+ import { H as HookEvent, e as HookMatcher, I as InProcessHook, S as ShellHook, f as HookEntry } from './config-Koq6f3fs.js';
3
+
4
+ /**
5
+ * Mailbox — persistent inter-agent messaging system with cross-session support.
6
+ *
7
+ * Agents can leave notes for specific agents or broadcast to all. Each agent
8
+ * periodically checks the mailbox or retrieves messages via tool calls.
9
+ *
10
+ * ## Cross-session communication
11
+ *
12
+ * The mailbox is stored at **project level** (`~/.wrongstack/projects/<slug>/_mailbox.jsonl`),
13
+ * so agents in different terminal sessions / WebUI tabs working on the same
14
+ * project can communicate live.
15
+ *
16
+ * ## Agent registration
17
+ *
18
+ * Every agent that uses the mailbox registers itself with a heartbeat.
19
+ * Other agents can discover online agents via `getOnlineAgents()`.
20
+ * Stale agents (no heartbeat > 60s) are pruned automatically.
21
+ *
22
+ * ## Read receipts
23
+ *
24
+ * Each message tracks per-recipient read status via a `readBy` map:
25
+ * `{ "agentId": "ISO8601" }`. When agent X reads a message, its entry
26
+ * is added. The WebUI shows who read what and when.
27
+ *
28
+ * @module mailbox-types
29
+ */
30
+ type MailboxMessageType = 'note' | 'ask' | 'assign' | 'steer' | 'btw' | 'broadcast' | 'status' | 'result';
31
+ /**
32
+ * Per-recipient read status. `readBy` maps agentId → ISO8601 timestamp of
33
+ * when that agent first read the message. An empty map means unread by all.
34
+ */
35
+ interface ReadReceipts {
36
+ [agentId: string]: string;
37
+ }
38
+ interface MailboxMessage {
39
+ /** Unique message id (UUID). */
40
+ id: string;
41
+ /** Sender agent id. */
42
+ from: string;
43
+ /** Recipient agent id, or '*' for broadcast. */
44
+ to: string;
45
+ /** Message category. */
46
+ type: MailboxMessageType;
47
+ /** Short subject line — one sentence. */
48
+ subject: string;
49
+ /** Full message content. */
50
+ body: string;
51
+ /** Priority — high priority messages surface first. */
52
+ priority: 'low' | 'normal' | 'high';
53
+ /**
54
+ * Per-recipient read receipts. agentId → ISO8601 when they first read it.
55
+ * Replaces the old single `read: boolean` + `readAt` fields.
56
+ */
57
+ readBy: ReadReceipts;
58
+ /** Has any recipient acted on / completed this? */
59
+ completed: boolean;
60
+ /** Who completed it (agentId). */
61
+ completedBy?: string | undefined;
62
+ /** Optional summary of what happened after handling. */
63
+ outcome?: string | undefined;
64
+ /** ISO8601 — when the message was sent. */
65
+ timestamp: string;
66
+ /** ISO8601 — when the message was marked complete. */
67
+ completedAt?: string | undefined;
68
+ /** If this is a reply, the id of the parent message. */
69
+ replyTo?: string | undefined;
70
+ /** For assign-type messages — task context for agent discovery. */
71
+ taskContext?: MailboxTaskContext | undefined;
72
+ /** Session id of the sender. Enables cross-session communication. */
73
+ senderSessionId?: string | undefined;
74
+ }
75
+ interface MailboxTaskContext {
76
+ /** The role that should handle this task (e.g. "tech-stack", "audit-log"). */
77
+ agentRole?: string | undefined;
78
+ /** Human-readable agent name (e.g. "Tesla (Executor)"). */
79
+ agentName?: string | undefined;
80
+ /** Task id if already assigned via coordinator. */
81
+ taskId?: string | undefined;
82
+ /** Current task status. */
83
+ status?: 'pending' | 'in_progress' | 'completed' | 'failed' | undefined;
84
+ }
85
+ interface RegisteredAgent {
86
+ /** Unique agent id. */
87
+ agentId: string;
88
+ /** Session id this agent belongs to. */
89
+ sessionId: string;
90
+ /** Human-readable name. */
91
+ name: string;
92
+ /** Role (e.g. "leader", "tech-stack", "bug-hunter"). */
93
+ role?: string | undefined;
94
+ /** Current status. */
95
+ status: 'idle' | 'running' | 'streaming' | 'waiting_user' | 'error';
96
+ /** Current tool being executed, if any. */
97
+ currentTool?: string | undefined;
98
+ /** Current task description. */
99
+ currentTask?: string | undefined;
100
+ /** Iteration count so far. */
101
+ iterations: number;
102
+ /** Tool calls so far. */
103
+ toolCalls: number;
104
+ /** ISO8601 — registered at. */
105
+ registeredAt: string;
106
+ /** ISO8601 — last heartbeat (updated on every mailbox op). */
107
+ lastSeenAt: string;
108
+ /** Which process registered this agent (PID). */
109
+ pid: number;
110
+ /** Where the agent is running (e.g. "cli", "webui"). */
111
+ source?: 'cli' | 'webui' | 'mcp' | 'acp' | undefined;
112
+ }
113
+ interface MailboxAgentStatus {
114
+ /** Agent id. */
115
+ agentId: string;
116
+ /** Human-readable name. */
117
+ name: string;
118
+ /** Role. */
119
+ role?: string | undefined;
120
+ /** Session id. */
121
+ sessionId: string;
122
+ /** Current status. */
123
+ status: 'idle' | 'running' | 'streaming' | 'waiting_user' | 'error' | 'offline';
124
+ /** Current tool being executed, if any. */
125
+ currentTool?: string | undefined;
126
+ /** Current task description. */
127
+ currentTask?: string | undefined;
128
+ /** Iteration count so far. */
129
+ iterations: number;
130
+ /** Tool calls so far. */
131
+ toolCalls: number;
132
+ /** ISO8601 — last activity timestamp. */
133
+ lastActivityAt: string;
134
+ /** ISO8601 — last heartbeat. */
135
+ lastSeenAt: string;
136
+ /** Whether this agent is currently online (heartbeat within threshold). */
137
+ online: boolean;
138
+ /** Which process. */
139
+ pid: number;
140
+ /** Source. */
141
+ source?: 'cli' | 'webui' | 'mcp' | 'acp' | undefined;
142
+ }
143
+ interface MailboxQuery {
144
+ /** Filter by recipient agent id. */
145
+ to?: string | undefined;
146
+ /** Filter by sender agent id. */
147
+ from?: string | undefined;
148
+ /** Only messages unread by this agent. */
149
+ unreadBy?: string | undefined;
150
+ /** Only incomplete messages. */
151
+ incompleteOnly?: boolean | undefined;
152
+ /** Filter by message type. */
153
+ type?: MailboxMessageType | undefined;
154
+ /** Filter by priority (>= this level). */
155
+ minPriority?: 'low' | 'normal' | 'high' | undefined;
156
+ /** Maximum number of messages to return. */
157
+ limit?: number | undefined;
158
+ /** ISO8601 — only messages after this timestamp. */
159
+ since?: string | undefined;
160
+ }
161
+ /**
162
+ * Normalize a recipient address. `"all"` (any casing) is an accepted
163
+ * spelling of the broadcast address and is canonicalized to `'*'` at send
164
+ * time — both agents and humans reach for "all" naturally, and a literal
165
+ * "all" recipient would otherwise be deliverable to nobody. The word is
166
+ * therefore RESERVED: no agent may register under the base id "all".
167
+ */
168
+ declare function normalizeRecipient(to: string): string;
169
+ interface MailboxSendInput {
170
+ /** Sender agent id. */
171
+ from: string;
172
+ /** Recipient agent id, '*' for broadcast (alias: "all"). */
173
+ to: string;
174
+ /** Message category. */
175
+ type: MailboxMessageType;
176
+ /** Short subject line. */
177
+ subject: string;
178
+ /** Full message content. */
179
+ body: string;
180
+ /** Priority. Default: 'normal'. */
181
+ priority?: 'low' | 'normal' | 'high' | undefined;
182
+ /** If replying, the id of the parent message. */
183
+ replyTo?: string | undefined;
184
+ /** Task context for assign-type messages. */
185
+ taskContext?: MailboxTaskContext | undefined;
186
+ }
187
+ interface MailboxAckInput {
188
+ /** Message id to acknowledge. */
189
+ messageId: string;
190
+ /** Agent id of who is reading/acking. */
191
+ readerId: string;
192
+ /** Mark as read by this agent? Defaults to true if not specified. */
193
+ read?: boolean | undefined;
194
+ /** Mark as completed? */
195
+ completed?: boolean | undefined;
196
+ /** Optional outcome summary. */
197
+ outcome?: string | undefined;
198
+ }
199
+ interface AgentRegistrationInput {
200
+ agentId: string;
201
+ sessionId: string;
202
+ name: string;
203
+ role?: string | undefined;
204
+ pid: number;
205
+ source?: 'cli' | 'webui' | 'mcp' | 'acp' | undefined;
206
+ }
207
+ interface AgentHeartbeatInput {
208
+ agentId: string;
209
+ status?: RegisteredAgent['status'] | undefined;
210
+ currentTool?: string | undefined;
211
+ currentTask?: string | undefined;
212
+ iterations?: number | undefined;
213
+ toolCalls?: number | undefined;
214
+ }
215
+ interface Mailbox {
216
+ /** Send a message. Returns the created message. */
217
+ send(input: MailboxSendInput): Promise<MailboxMessage>;
218
+ /** Query messages matching criteria. */
219
+ query(query: MailboxQuery): Promise<MailboxMessage[]>;
220
+ /** Acknowledge a message (read/complete). Returns updated message. */
221
+ ack(input: MailboxAckInput): Promise<MailboxMessage | null>;
222
+ /** Get a snapshot of online/offline agents and their current tasks. */
223
+ getAgentStatuses(): Promise<MailboxAgentStatus[]>;
224
+ /**
225
+ * Get only online agents (heartbeat within 60s).
226
+ * Useful for "who can I talk to right now?" queries.
227
+ */
228
+ getOnlineAgents(): Promise<MailboxAgentStatus[]>;
229
+ /**
230
+ * Register an agent. Called once per agent on first mailbox use.
231
+ * Subsequent calls are idempotent — they update lastSeenAt.
232
+ */
233
+ registerAgent(input: AgentRegistrationInput): Promise<void>;
234
+ /**
235
+ * Update agent heartbeat and optional status fields.
236
+ * Called periodically (every tool call / iteration).
237
+ */
238
+ heartbeat(input: AgentHeartbeatInput): Promise<void>;
239
+ /**
240
+ * Count unread messages for a specific agent.
241
+ * Used for "new mail" notifications without pulling full message bodies.
242
+ */
243
+ unreadCount(forAgentId: string): Promise<number>;
244
+ /** Close and flush any pending writes. */
245
+ close(): Promise<void>;
246
+ /**
247
+ * Delete all messages from the mailbox file.
248
+ * Agents and read receipts are preserved; only messages are cleared.
249
+ */
250
+ clearAll(): Promise<void>;
251
+ }
252
+
253
+ /** Model capabilities relevant to prompt composition. */
254
+ interface ModelCapabilities {
255
+ maxContextTokens: number;
256
+ supportsTools: boolean;
257
+ supportsVision: boolean;
258
+ supportsReasoning: boolean;
259
+ }
260
+ interface BuildContext {
261
+ cwd: string;
262
+ projectRoot: string;
263
+ tools: Tool[];
264
+ /** Provider id (e.g. "anthropic", "minimax-coding-plan"). */
265
+ provider?: string | undefined;
266
+ /** Model id (e.g. "claude-sonnet-4-6", "MiniMax-M2.7"). */
267
+ model?: string | undefined;
268
+ /**
269
+ * True when the prompt is being built for a SUBAGENT, not the host
270
+ * agent. Subagents are scoped to a single task — they should NOT see
271
+ * the host's strategic plan board (which is anchoring the host across
272
+ * turns, not steering individual subtasks). The plan-injection
273
+ * layer short-circuits when this flag is set.
274
+ */
275
+ subagent?: boolean | undefined;
276
+ /**
277
+ * List of currently online agents in the shared mailbox system.
278
+ * Includes agents from all sessions (TUI, WebUI, CLI) in the same project.
279
+ */
280
+ onlineAgents?: MailboxAgentStatus[] | undefined;
281
+ }
282
+ interface SystemPromptBuilder {
283
+ build(ctx: BuildContext): Promise<TextBlock[]>;
284
+ }
285
+
286
+ /**
287
+ * Registry of lifecycle hooks (both in-process and shell). One instance is
288
+ * shared per session: the boot path loads `config.hooks` as shell entries and
289
+ * plugins add in-process entries via `PluginAPI.registerHook`. The
290
+ * `HookRunner` reads from it at each lifecycle phase.
291
+ */
292
+ declare class HookRegistry {
293
+ private readonly entries;
294
+ /** Register an in-process hook. Returns an unsubscribe function. */
295
+ registerInProcess(event: HookEvent, matcher: HookMatcher | undefined, hook: InProcessHook, owner?: string | undefined): () => void;
296
+ /** Register a single shell hook. Returns an unsubscribe function. */
297
+ registerShell(event: HookEvent, hook: ShellHook): () => void;
298
+ /** Bulk-load shell hooks from a `config.hooks` map. */
299
+ loadShellHooks(hooks: Partial<Record<HookEvent, ShellHook[]>> | undefined): void;
300
+ /** All entries registered for an event, in registration order. */
301
+ list(event: HookEvent): readonly HookEntry[];
302
+ /** True when any entry is registered for the event. */
303
+ has(event: HookEvent): boolean;
304
+ /** Drop every registered hook (used in teardown / tests). */
305
+ clear(): void;
306
+ private remove;
307
+ }
308
+ /**
309
+ * Does a hook matcher apply to a tool name? `*` (or empty) matches everything;
310
+ * otherwise the matcher is a case-insensitive pipe-delimited list of exact
311
+ * tool names (`"edit|write"`). Non-tool events pass `undefined` and always match.
312
+ */
313
+ declare function hookMatcherMatches(matcher: HookMatcher, toolName: string | undefined): boolean;
314
+
315
+ interface Renderer {
316
+ write(text: string | TextBlock): void;
317
+ writeLine(text?: string): void;
318
+ writeBlock(block: ContentBlock): void;
319
+ writeToolCall(name: string, input: unknown): void;
320
+ writeToolResult(name: string, content: unknown, isError: boolean): void;
321
+ writeDiff(unifiedDiff: string): void;
322
+ writeWarning(text: string): void;
323
+ writeError(text: string): void;
324
+ writeInfo(text: string): void;
325
+ clear(): void;
326
+ }
327
+
328
+ /**
329
+ * Container — dependency injection with explicit bind / override / decorate.
330
+ *
331
+ * Invariants:
332
+ * bind() — throws if token already bound
333
+ * override() — throws if nothing to replace
334
+ * decorate() — stacks; cached value cleared on register
335
+ */
336
+ type Token<T> = symbol & {
337
+ readonly __type?: T;
338
+ };
339
+ type Factory<T> = (c: Container) => T;
340
+ type Decorator<T> = (inner: T, c: Container) => T;
341
+ interface BindOptions {
342
+ singleton?: boolean | undefined;
343
+ owner?: string | undefined;
344
+ }
345
+ declare class Container {
346
+ private readonly entries;
347
+ /**
348
+ * Tokens currently mid-resolve. Tracked so we can detect circular
349
+ * dependencies (A → B → A) and throw a structured error instead of
350
+ * overflowing the call stack with "Maximum call stack size exceeded".
351
+ *
352
+ * Not a memoization cache — the per-entry `cache` field is the source
353
+ * of truth for "have I built this before?". This set only lives for
354
+ * the duration of a single resolve call.
355
+ */
356
+ private readonly resolving;
357
+ bind<T>(token: Token<T>, factory: Factory<T>, opts?: BindOptions): void;
358
+ override<T>(token: Token<T>, factory: Factory<T>, opts?: BindOptions): void;
359
+ decorate<T>(token: Token<T>, decorator: Decorator<T>, owner?: string): void;
360
+ resolve<T>(token: Token<T>): T;
361
+ /**
362
+ * Build a human-readable description of the dependency cycle that
363
+ * caused the resolution to re-enter. Lists the tokens in the order
364
+ * they were entered, then appends the re-entered token to close the
365
+ * loop. Falls back to a generic message if the resolving set is
366
+ * somehow empty (shouldn't happen, but defensive).
367
+ */
368
+ private describeCycle;
369
+ has<T>(token: Token<T>): boolean;
370
+ /**
371
+ * Resolve a token if it is bound, otherwise return undefined.
372
+ * Unlike resolve(), this does not throw if the token is unbound.
373
+ */
374
+ safeResolve<T>(token: Token<T>): T | undefined;
375
+ ownerOf<T>(token: Token<T>): string | undefined;
376
+ /**
377
+ * Remove a token's binding (along with any decorators stacked on it).
378
+ * Returns true if the token existed. Use this to withdraw temporary
379
+ * bindings installed by a short-lived run or plugin — without it, the
380
+ * entry persists in the map forever.
381
+ */
382
+ unbind<T>(token: Token<T>): boolean;
383
+ /**
384
+ * Drop every binding. Intended for tests and short-lived CLI invocations
385
+ * that rebuild the container from scratch. Production code should prefer
386
+ * `unbind` on the specific tokens it owns.
387
+ */
388
+ clear(): void;
389
+ list(): Array<{
390
+ token: symbol;
391
+ owner: string;
392
+ }>;
393
+ /**
394
+ * Inspect a binding's full shape, including decorator count and whether
395
+ * a singleton value is cached. Returns null if the token is unbound.
396
+ * Decorator and factory function references are not exposed — only counts
397
+ * and metadata, to keep internal state hidden.
398
+ */
399
+ inspect<T>(token: Token<T>): {
400
+ owner: string;
401
+ singleton: boolean;
402
+ decoratorCount: number;
403
+ cached: boolean;
404
+ } | null;
405
+ }
406
+
407
+ /**
408
+ * Pipeline — Koa-style middleware chain with named middleware
409
+ * and position-aware insertion. Generic over input type T.
410
+ */
411
+ type NextFn<T> = (value: T) => Promise<T>;
412
+ type MiddlewareHandler<T> = (value: T, next: NextFn<T>) => Promise<T>;
413
+ /**
414
+ * Called when a middleware crashes (throws or rejects). Used by the
415
+ * Pipeline's error boundary to log the offender without aborting the run.
416
+ *
417
+ * Return `'rethrow'` to propagate the error (default for core middleware),
418
+ * or `'swallow'` to skip past the crashing middleware and continue with the
419
+ * value the previous one produced. Plugin middleware should usually be
420
+ * swallowed so one bad plugin can't kill an agent run.
421
+ */
422
+ type PipelineErrorPolicy = 'rethrow' | 'swallow';
423
+ interface PipelineErrorEvent {
424
+ middleware: string;
425
+ owner?: string | undefined;
426
+ err: unknown;
427
+ }
428
+ type PipelineErrorHandler = (ev: PipelineErrorEvent) => PipelineErrorPolicy | Promise<PipelineErrorPolicy>;
429
+ interface Middleware<T> {
430
+ name: string;
431
+ handler: MiddlewareHandler<T>;
432
+ owner?: string | undefined;
433
+ }
434
+ interface PipelineOptions {
435
+ /** When true and the target middleware is not found, operations silently no-op instead of throwing. */
436
+ optional?: boolean | undefined;
437
+ }
438
+ /**
439
+ * Read-only view of a pipeline. Returned to consumers (plugins, hooks)
440
+ * so they can inspect but not mutate the chain.
441
+ */
442
+ interface ReadonlyPipeline<T> {
443
+ readonly size: number;
444
+ list(): readonly string[];
445
+ run(input: T): Promise<T>;
446
+ }
447
+ declare class Pipeline<T> {
448
+ private readonly chain;
449
+ private errorHandler?;
450
+ /**
451
+ * Install an error boundary. When a middleware throws or rejects, the
452
+ * handler is called and decides whether to swallow (continue with the
453
+ * pre-handler value) or rethrow. Without a handler, errors propagate.
454
+ *
455
+ * Wire one per pipeline at boot — the host CLI typically installs a
456
+ * single boundary that logs to the operational log and emits a
457
+ * `pipeline.error` event for /diag.
458
+ */
459
+ setErrorHandler(handler: PipelineErrorHandler | undefined): this;
460
+ use(mw: Middleware<T> | Middleware<unknown>): this;
461
+ prepend(mw: Middleware<T>): this;
462
+ /**
463
+ * Insert middleware at an explicit index. Out-of-range indices are clamped.
464
+ * Use this when insertBefore/insertAfter are insufficient (e.g. to place
465
+ * a middleware at a known position regardless of named targets).
466
+ */
467
+ insertAt(index: number, mw: Middleware<T>): this;
468
+ /**
469
+ * Insert mw immediately before the first occurrence of target.
470
+ * If called multiple times with the same target, each call inserts
471
+ * before the target's current position — so after insertBefore('B', X)
472
+ * then insertBefore('B', Y), the order is Y → X → B.
473
+ */
474
+ insertBefore(target: string, mw: Middleware<T>, opts?: PipelineOptions): this;
475
+ /**
476
+ * Insert mw immediately after the first occurrence of target.
477
+ * If called multiple times with the same target, each call inserts
478
+ * after the target's current position — so after insertAfter('B', X)
479
+ * then insertAfter('B', Y), the order is B → X → Y.
480
+ */
481
+ insertAfter(target: string, mw: Middleware<T>, opts?: PipelineOptions): this;
482
+ replace(target: string, mw: Middleware<T>, opts?: PipelineOptions): this;
483
+ remove(name: string, opts?: PipelineOptions): this;
484
+ list(): readonly string[];
485
+ size(): number;
486
+ /** Return a read-only view suitable for passing to plugins. */
487
+ asReadonly(): ReadonlyPipeline<T>;
488
+ run(input: T): Promise<T>;
489
+ private indexOf;
490
+ private ensureUnique;
491
+ }
492
+
493
+ export { type AgentRegistrationInput as A, type BuildContext as B, Container as C, type Decorator as D, type Factory as F, HookRegistry as H, type MiddlewareHandler as M, type NextFn as N, Pipeline as P, type ReadonlyPipeline as R, type SystemPromptBuilder as S, type Token as T, type Renderer as a, type Mailbox as b, type MailboxSendInput as c, type MailboxMessage as d, type MailboxQuery as e, type MailboxAckInput as f, type MailboxAgentStatus as g, type AgentHeartbeatInput as h, type MailboxMessageType as i, type MailboxTaskContext as j, type ReadReceipts as k, type RegisteredAgent as l, type ModelCapabilities as m, normalizeRecipient as n, type BindOptions as o, type Middleware as p, type PipelineOptions as q, hookMatcherMatches as r };
@@ -1,9 +1,9 @@
1
- import { E as EventBus, M as MemoryScope, k as MemoryEntry, l as MemoryStore, m as MemoryRelevanceContext, S as ScoredEntry } from './brain-CS_B0vIE.js';
2
- import { S as SecretScrubber } from './permission-B7nKnEvQ.js';
3
- import { i as SessionStore, h as SessionMetadata, a as SessionWriter, p as ResumedSession, q as SessionData, r as SessionSummary, g as ContentBlock, S as SessionEvent, s as TodoItem, t as ConversationState } from './context-C7G_MtLV.js';
4
- import { A as AttachmentStore, a as AddAttachmentInput, b as AttachmentRef, c as Attachment } from './session-reader-BAtCxdaw.js';
5
- import { W as WstackPaths } from './wstack-paths-DD50Omgn.js';
6
- import { i as ConfigStore, h as Config, j as ConfigLoader, k as SyncConfig } from './config-BaVThgnT.js';
1
+ import { E as EventBus, M as MemoryScope, k as MemoryEntry, l as MemoryStore, m as MemoryRelevanceContext, S as ScoredEntry } from './brain-sCZ3lCjq.js';
2
+ import { S as SecretScrubber } from './permission-DbWPbuoA.js';
3
+ import { i as SessionStore, h as SessionMetadata, a as SessionWriter, p as ResumedSession, q as SessionData, r as SessionSummary, g as ContentBlock, S as SessionEvent, s as TodoItem, t as ConversationState } from './context-CLz3z_E8.js';
4
+ import { A as AttachmentStore, a as AddAttachmentInput, b as AttachmentRef, c as Attachment } from './session-reader-CCOssnBS.js';
5
+ import { W as WstackPaths } from './wstack-paths-CJjEwPXn.js';
6
+ import { i as ConfigStore, h as Config, j as ConfigLoader, k as SyncConfig } from './config-Koq6f3fs.js';
7
7
  import { S as SecretVault } from './secret-vault-BJDY28ev.js';
8
8
 
9
9
  interface SessionStoreOptions {
@@ -70,6 +70,11 @@ declare class DefaultSessionStore implements SessionStore {
70
70
  /**
71
71
  * Delete a session and all associated files: JSONL, summary, plan/todos
72
72
  * sidecars, and the session directory (fleet.json, shared/, subagents/).
73
+ *
74
+ * Individual file deletions are best-effort (logged as structured warnings),
75
+ * but a tombstone is always written so readIndex() filters this session out.
76
+ * If the session directory itself can't be removed, the error is surfaced
77
+ * to the caller so prune() can report it.
73
78
  */
74
79
  private deleteSession;
75
80
  delete(id: string): Promise<void>;
@@ -608,8 +613,14 @@ declare function deriveTodosFromPlanItem(plan: PlanFile, idOrIndex: string, subt
608
613
  content: string;
609
614
  status: 'pending' | 'in_progress' | 'completed';
610
615
  activeForm?: string | undefined;
616
+ promotedFromPlan?: string | undefined;
611
617
  }>;
612
618
  } | null;
619
+ /**
620
+ * Load, modify, and save the plan file under a file-level lock.
621
+ * Prevents races from parallel tool invocations (e.g. batch_tool_use).
622
+ */
623
+ declare function mutatePlan(filePath: string, sessionId: string, fn: (plan: PlanFile) => PlanFile | Promise<PlanFile>): Promise<PlanFile>;
613
624
  /**
614
625
  * Optional: attach a state-listener so meta operations (storing a plan
615
626
  * id on ctx.meta) trigger a save. Currently a stub — plans don't live
@@ -639,4 +650,4 @@ declare function listPlanTemplates(): PlanTemplate[];
639
650
  declare function getPlanTemplate(name: string): PlanTemplate | undefined;
640
651
  declare function formatPlanTemplates(): string;
641
652
 
642
- export { type AbandonedSession as A, getPlanTemplate as B, type ConfigLoaderOptions as C, DEFAULT_CONFIG_MIGRATIONS as D, listPlanTemplates as E, FileMemoryBackend as F, loadPlan as G, loadTodosCheckpoint as H, parseEntries as I, removePlanItem as J, runConfigMigrations as K, savePlan as L, type MemoryBackend as M, saveTodosCheckpoint as N, setPlanItemStatus as O, type PersistedQueueItem as P, QueueStore as Q, RecoveryLock as R, SessionAnalyzer as S, type TodosCheckpointFile as T, type AttachmentStoreOptions as a, type ConfigMigration as b, ConfigMigrationError as c, type ConfigSource as d, DefaultAttachmentStore as e, DefaultConfigLoader as f, DefaultConfigStore as g, DefaultMemoryStore as h, DefaultSessionStore as i, type FileMemoryBackendOptions as j, type MemoryStoreOptions as k, type MigrationContext as l, type MigrationResult as m, type PlanFile as n, type PlanItem as o, type PlanTemplate as p, type RecoveryLockOptions as q, type SessionStoreOptions as r, addPlanItem as s, attachPlanCheckpoint as t, attachTodosCheckpoint as u, clearPlan as v, deriveTodosFromPlanItem as w, emptyPlan as x, formatPlan as y, formatPlanTemplates as z };
653
+ export { type AbandonedSession as A, getPlanTemplate as B, type ConfigLoaderOptions as C, DEFAULT_CONFIG_MIGRATIONS as D, listPlanTemplates as E, FileMemoryBackend as F, loadPlan as G, loadTodosCheckpoint as H, mutatePlan as I, parseEntries as J, removePlanItem as K, runConfigMigrations as L, type MemoryBackend as M, savePlan as N, saveTodosCheckpoint as O, type PersistedQueueItem as P, QueueStore as Q, RecoveryLock as R, SessionAnalyzer as S, type TodosCheckpointFile as T, setPlanItemStatus as U, type AttachmentStoreOptions as a, type ConfigMigration as b, ConfigMigrationError as c, type ConfigSource as d, DefaultAttachmentStore as e, DefaultConfigLoader as f, DefaultConfigStore as g, DefaultMemoryStore as h, DefaultSessionStore as i, type FileMemoryBackendOptions as j, type MemoryStoreOptions as k, type MigrationContext as l, type MigrationResult as m, type PlanFile as n, type PlanItem as o, type PlanTemplate as p, type RecoveryLockOptions as q, type SessionStoreOptions as r, addPlanItem as s, attachPlanCheckpoint as t, attachTodosCheckpoint as u, clearPlan as v, deriveTodosFromPlanItem as w, emptyPlan as x, formatPlan as y, formatPlanTemplates as z };
@@ -1,8 +1,8 @@
1
- import { E as EventBus } from './brain-CS_B0vIE.js';
1
+ import { E as EventBus } from './brain-sCZ3lCjq.js';
2
2
  import { L as Logger } from './logger-B63L5bTg.js';
3
3
  import { T as Tracer } from './observability-D-HZN_mF.js';
4
- import { P as Provider, R as Request, C as Context, b as Response } from './context-C7G_MtLV.js';
5
- import { R as RetryPolicy } from './retry-policy-rutAfVeR.js';
4
+ import { P as Provider, R as Request, C as Context, b as Response } from './context-CLz3z_E8.js';
5
+ import { R as RetryPolicy } from './retry-policy-BVnkbMET.js';
6
6
 
7
7
  /**
8
8
  * Options passed to a ProviderRunner when calling the provider.
@@ -1,4 +1,4 @@
1
- import { C as Context, b as Response, e as ProviderError } from './context-C7G_MtLV.js';
1
+ import { C as Context, b as Response, e as ProviderError } from './context-CLz3z_E8.js';
2
2
 
3
3
  type RecoveryDecision = {
4
4
  /**
@@ -1,15 +1,15 @@
1
1
  import { h as Specification, S as SpecAnalysis, g as SpecValidationResult, e as SpecStatus, 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 } from '../brain-CS_B0vIE.js';
4
- import { D as DoneCondition, g as Agent, h as AgentFactory, f as TaskResult } from '../agent-subagent-runner-Bsueu0J2.js';
5
- import '../context-C7G_MtLV.js';
6
- import '../index-B5wz-GXm.js';
3
+ import { E as EventBus } from '../brain-sCZ3lCjq.js';
4
+ import { D as DoneCondition, g as Agent, h as AgentFactory, f as TaskResult } from '../agent-subagent-runner-C658wj_c.js';
5
+ import '../context-CLz3z_E8.js';
6
+ import '../index-C2eSNPsB.js';
7
7
  import '../logger-B63L5bTg.js';
8
- import '../pipeline-BG7UgbDc.js';
9
- import '../config-BaVThgnT.js';
8
+ import '../pipeline-DsmlwTXu.js';
9
+ import '../config-Koq6f3fs.js';
10
10
  import '../observability-D-HZN_mF.js';
11
- import '../permission-B7nKnEvQ.js';
12
- import '../retry-policy-rutAfVeR.js';
11
+ import '../permission-DbWPbuoA.js';
12
+ import '../retry-policy-BVnkbMET.js';
13
13
 
14
14
  declare class SpecParser {
15
15
  parse(content: string): Specification;