@wrongstack/core 0.155.0 → 0.250.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-4gc0vfW2.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-Bsueu0J2.d.ts → agent-subagent-runner-Dz-9kiE6.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-eSsrto5d.d.ts} +8 -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 +1986 -146
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -26
  11. package/dist/defaults/index.js +1110 -296
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +45 -16
  14. package/dist/execution/index.js +229 -56
  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-BjJpnLW4.d.ts} +19 -10
  23. package/dist/{index-CI1hRfPt.d.ts → index-Dy8OwfBD.d.ts} +8 -8
  24. package/dist/{index-B5wz-GXm.d.ts → index-IehiNryU.d.ts} +7 -5
  25. package/dist/index.d.ts +438 -128
  26. package/dist/index.js +4989 -849
  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-DfXxCASH.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-DpanBg8D.d.ts} +1 -1
  41. package/dist/{multi-agent-coordinator-BSKSFNhv.d.ts → multi-agent-coordinator-CnbEqpv0.d.ts} +8 -8
  42. package/dist/{null-fleet-bus-CGOez8Le.d.ts → null-fleet-bus-Do1OLYpj.d.ts} +7 -7
  43. package/dist/observability/index.d.ts +2 -2
  44. package/dist/package-outdated-watcher-CA5GGB4C.d.ts +560 -0
  45. package/dist/{parallel-eternal-engine-CYoTKjsz.d.ts → parallel-eternal-engine-UZg1xOzE.d.ts} +13 -9
  46. package/dist/{path-resolver-DuhlmPil.d.ts → path-resolver-BaP06Owy.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-D1n-gQI-.d.ts +493 -0
  50. package/dist/{plan-templates-DbH7lg-t.d.ts → plan-templates-BUVRY0pU.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 +221 -87
  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 +562 -55
  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 +25 -4
  74. package/dist/utils/index.js +45 -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,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-Bsueu0J2.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-Dz-9kiE6.js';
2
2
 
3
3
  /**
4
4
  * In-memory pub/sub transport for agent-to-agent messaging.
@@ -1,12 +1,12 @@
1
- import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-B5wz-GXm.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-BG7UgbDc.js';
3
- import { E as EventBus, c as EventName, L as Listener } from './brain-CS_B0vIE.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-rutAfVeR.js';
1
+ import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-IehiNryU.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-D1n-gQI-.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-sCZ3lCjq.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-BVnkbMET.js';
5
5
  import { L as Logger } from './logger-B63L5bTg.js';
6
6
  import { T as Tracer } from './observability-D-HZN_mF.js';
7
- import { P as PermissionPolicy } from './permission-B7nKnEvQ.js';
8
- import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, l as TextBlock, T as Tool, P as Provider, o as RunOptions } from './context-C7G_MtLV.js';
9
- import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-BaVThgnT.js';
7
+ import { P as PermissionPolicy } from './permission-DbWPbuoA.js';
8
+ import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, n as TextBlock, T as Tool, P as Provider, o as RunOptions } from './context-CLz3z_E8.js';
9
+ import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-eSsrto5d.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -737,7 +737,7 @@ interface SlashCommand {
737
737
  * the model's response starts streaming. `{ metadata }` carries
738
738
  * structured data for the REPL/TUI to act on (e.g. SDD session state).
739
739
  */
740
- run(args: string, ctx: Context): Promise<{
740
+ run(args: string, ctx?: Context | undefined): Promise<{
741
741
  exit?: boolean | undefined;
742
742
  message?: string | undefined;
743
743
  runText?: string | undefined;
@@ -982,6 +982,7 @@ declare class Agent {
982
982
  private readonly _toolHandler;
983
983
  private readonly _responseHandler;
984
984
  private readonly _loopHandler;
985
+ private readonly _logger;
985
986
  constructor(init: AgentInit);
986
987
  get logger(): Logger;
987
988
  get retry(): RetryPolicy;
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-C7G_MtLV.js';
1
+ import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-CLz3z_E8.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -115,6 +115,20 @@ interface EventMap {
115
115
  decision: BrainDecision;
116
116
  at: number;
117
117
  };
118
+ /**
119
+ * Fired by the BrainMonitor when it PROACTIVELY engaged (self-activation):
120
+ * a watched signal (tool-failure streak, error storm) crossed its
121
+ * threshold, the Brain was consulted, and — when the decision called for
122
+ * it — a corrective steer was delivered to the working agent.
123
+ */
124
+ 'brain.intervention': {
125
+ kind: 'tool_failure_streak' | 'error_storm';
126
+ request: BrainDecisionRequest;
127
+ decision: BrainDecision;
128
+ /** True when a steer was actually delivered to the agent. */
129
+ intervened: boolean;
130
+ at: number;
131
+ };
118
132
  'session.started': {
119
133
  id: string;
120
134
  };
@@ -699,6 +713,16 @@ interface EventMap {
699
713
  branch?: string | undefined;
700
714
  error: string;
701
715
  };
716
+ /**
717
+ * Auto-proceed countdown tick, emitted once per second by the REPL while
718
+ * autonomy mode `auto` is counting down to self-driving the next suggestion.
719
+ * `remaining` is the number of whole seconds left. Display-only: the TUI
720
+ * StatusBar renders it as an "auto-proceed in Ns" chip; no consumer should
721
+ * derive behavior from it (the REPL owns the actual timer).
722
+ */
723
+ 'countdown.tick': {
724
+ remaining: number;
725
+ };
702
726
  'memory.remembered': MemoryRememberedPayload;
703
727
  'memory.forgotten': MemoryForgottenPayload;
704
728
  'memory.cleared': MemoryClearedPayload;
@@ -959,4 +983,4 @@ declare class DefaultBrainArbiter implements BrainArbiter {
959
983
  }
960
984
  declare function formatHumanPrompt(request: BrainDecisionRequest): string;
961
985
 
962
- export { type BrainDecision as B, DefaultBrainArbiter as D, EventBus as E, HumanEscalatingBrainArbiter as H, type Listener as L, type MemoryScope as M, ObservableBrainArbiter as O, type ScoredEntry as S, type BrainDecisionRequest as a, type BrainArbiter as b, type EventName as c, type BrainDecisionOption as d, BrainDecisionQueue as e, type BrainDecisionSource as f, type BrainFallback as g, type BrainRisk as h, type DefaultBrainArbiterOptions as i, formatHumanPrompt as j, type MemoryEntry as k, type MemoryStore as l, type MemoryRelevanceContext as m, type EventLogger as n, type EventMap as o, MEMORY_TYPE_LABELS as p, type MemoryClearedPayload as q, type MemoryConsolidatedPayload as r, type MemoryForgottenPayload as s, type MemoryPriority as t, type MemoryRememberedPayload as u, type MemoryType as v, ScopedEventBus as w };
986
+ export { type BrainArbiter as B, DefaultBrainArbiter as D, EventBus as E, HumanEscalatingBrainArbiter as H, type Listener as L, type MemoryScope as M, ObservableBrainArbiter as O, type ScoredEntry as S, type EventName as a, type BrainDecision as b, type BrainDecisionOption as c, BrainDecisionQueue as d, type BrainDecisionRequest as e, type BrainDecisionSource as f, type BrainFallback as g, type BrainRisk as h, type DefaultBrainArbiterOptions as i, formatHumanPrompt as j, type MemoryEntry as k, type MemoryStore as l, type MemoryRelevanceContext as m, type EventLogger as n, type EventMap as o, MEMORY_TYPE_LABELS as p, type MemoryClearedPayload as q, type MemoryConsolidatedPayload as r, type MemoryForgottenPayload as s, type MemoryPriority as t, type MemoryRememberedPayload as u, type MemoryType as v, ScopedEventBus as w };
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-C7G_MtLV.js';
1
+ import { C as Context } from './context-CLz3z_E8.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -1,4 +1,4 @@
1
- import { k as Capabilities, f as Permission } from './context-C7G_MtLV.js';
1
+ import { k as Capabilities, f as Permission } from './context-CLz3z_E8.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -393,6 +393,12 @@ interface IndexingConfig {
393
393
  watchExternal: boolean;
394
394
  /** Debounce window (ms) coalescing rapid edits to the same file. Default: 400. */
395
395
  debounceMs: number;
396
+ /**
397
+ * Watchdog timeout (ms) for a full index run. A run exceeding this is
398
+ * aborted (so it can never wedge the indexing mutex or freeze the terminal)
399
+ * and counts toward the indexing circuit breaker. Default: 120000.
400
+ */
401
+ indexTimeoutMs?: number | undefined;
396
402
  }
397
403
  /**
398
404
  * Saved launch preferences — restored on next boot so the pre-launch prompt
@@ -604,4 +610,4 @@ interface ConfigStore {
604
610
  watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
605
611
  }
606
612
 
607
- export { type AutonomyConfig as A, type SyncCategory as B, type ContextWindowAggressiveOn as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, formatContextWindowModeList as E, type FeaturesConfig as F, getContextWindowMode as G, type HookEvent as H, type InProcessHook as I, isContextWindowModeId as J, listContextWindowModes as K, type LaunchConfig as L, type ModelsRegistry as M, resolveContextWindowPolicy as N, type ProviderConfig as P, type ResolvedProvider as R, type ShellHook as S, type ToolsConfig as T, type WireFamily as W, type ModelsDevPayload as a, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type HookMatcher as e, type HookEntry as f, type ContextWindowPolicy as g, type Config as h, type ConfigStore as i, type ConfigLoader as j, type SyncConfig as k, type HookInput as l, type HookOutcome as m, CONTEXT_WINDOW_MODES as n, type ContextConfig as o, type ContextWindowConfigLike as p, type ContextWindowMode as q, type ContextWindowModeId as r, type ContextWindowThresholds as s, type CustomModelDefinition as t, type IndexingConfig as u, type LogConfig as v, type ModelsDevProvider as w, type PluginConfig as x, type ProviderApiKey as y, type SessionLoggingConfig as z };
613
+ export { type AutonomyConfig as A, type SessionLoggingConfig as B, type ContextWindowAggressiveOn as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type SyncCategory as E, type FeaturesConfig as F, formatContextWindowModeList as G, type HookEvent as H, type InProcessHook as I, getContextWindowMode as J, isContextWindowModeId as K, type LaunchConfig as L, type ModelsRegistry as M, listContextWindowModes as N, resolveContextWindowPolicy as O, type ProviderConfig as P, type ResolvedProvider as R, type ShellHook as S, type ToolsConfig as T, type WireFamily as W, type ModelsDevPayload as a, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type HookMatcher as e, type HookEntry as f, type ContextWindowPolicy as g, type Config as h, type ConfigStore as i, type ConfigLoader as j, type SyncConfig as k, type HookInput as l, type HookOutcome as m, CONTEXT_WINDOW_MODES as n, type ContextConfig as o, type ContextWindowConfigLike as p, type ContextWindowMode as q, type ContextWindowModeId as r, type ContextWindowThresholds as s, type CustomModelDefinition as t, type IndexingConfig as u, type LogConfig as v, type ModelsDevModel as w, type ModelsDevProvider as x, type PluginConfig as y, type ProviderApiKey as z };
@@ -79,6 +79,23 @@ type MessageRole = 'user' | 'assistant' | 'system';
79
79
  interface Message {
80
80
  role: MessageRole;
81
81
  content: string | ContentBlock[];
82
+ /**
83
+ * ISO-8601 timestamp from the originating SessionEvent.
84
+ * Populated by SessionStore.replay() during session load/resume
85
+ * so consumers (WebUI, TUI, exports) can reconstruct the original
86
+ * conversation timeline instead of seeing every message stamped
87
+ * with "now". Absent for in-memory messages created during a live
88
+ * run — those use wall-clock time from the caller.
89
+ */
90
+ ts?: string | undefined;
91
+ /**
92
+ * Pre-computed token estimate for this message, set by
93
+ * ConversationState on append/replace. Used by estimateMessageTokens
94
+ * and estimateRequestTokens to skip the O(n·m) content-block walk
95
+ * on every context-pressure check. Undefined means "not yet computed"
96
+ * — the estimator falls back to walking content blocks.
97
+ */
98
+ _estTokens?: number | undefined;
82
99
  }
83
100
  declare function asBlocks(content: string | ContentBlock[]): ContentBlock[];
84
101
  declare function asText(content: string | ContentBlock[]): string;
@@ -140,6 +157,11 @@ declare const ERROR_CODES: {
140
157
  readonly FS_MKDIR_FAILED: "FS_MKDIR_FAILED";
141
158
  readonly FS_DELETE_FAILED: "FS_DELETE_FAILED";
142
159
  readonly FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED";
160
+ readonly SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED";
161
+ readonly SDD_PARSE_FAILED: "SDD_PARSE_FAILED";
162
+ readonly SDD_INVALID_STATE: "SDD_INVALID_STATE";
163
+ readonly SDD_NOT_READY: "SDD_NOT_READY";
164
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
143
165
  readonly UNKNOWN: "UNKNOWN";
144
166
  };
145
167
  /**
@@ -148,7 +170,7 @@ declare const ERROR_CODES: {
148
170
  * a new code is added to `ERROR_CODES` — no need to keep two lists in sync.
149
171
  */
150
172
  type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
151
- type ErrorSubsystem = 'provider' | 'tool' | 'config' | 'plugin' | 'agent' | 'session' | 'container' | 'fs' | 'general';
173
+ type ErrorSubsystem = 'provider' | 'tool' | 'config' | 'plugin' | 'agent' | 'session' | 'sdd' | 'container' | 'fs' | 'general';
152
174
  type ErrorSeverity = 'fatal' | 'error' | 'warning';
153
175
  declare class WrongStackError extends Error {
154
176
  readonly code: ErrorCode;
@@ -242,6 +264,18 @@ declare class SessionError extends WrongStackError {
242
264
  cause?: unknown | undefined;
243
265
  });
244
266
  }
267
+ /**
268
+ * SDD (Spec-Driven Development) errors — spec validation, parsing, and
269
+ * state machine violations in the AISpecBuilder, TaskFlow, and TaskTracker.
270
+ */
271
+ declare class SddError extends WrongStackError {
272
+ constructor(opts: {
273
+ message: string;
274
+ code: Extract<ErrorCode, 'SDD_VALIDATION_FAILED' | 'SDD_PARSE_FAILED' | 'SDD_INVALID_STATE' | 'SDD_NOT_READY'>;
275
+ context?: Record<string, unknown> | undefined;
276
+ cause?: unknown | undefined;
277
+ });
278
+ }
245
279
  /**
246
280
  * File system operation errors.
247
281
  */
@@ -262,6 +296,7 @@ declare function isPluginError(err: unknown): err is PluginError;
262
296
  declare function isSessionError(err: unknown): err is SessionError;
263
297
  declare function isAgentError(err: unknown): err is AgentError;
264
298
  declare function isFsError(err: unknown): err is FsError;
299
+ declare function isSddError(err: unknown): err is SddError;
265
300
 
266
301
  type Permission = 'auto' | 'confirm' | 'deny';
267
302
  /**
@@ -317,6 +352,13 @@ type ToolStreamEvent<O = unknown> = ToolProgressEvent | ToolFinalEvent<O>;
317
352
  interface Tool<I = unknown, O = unknown> {
318
353
  name: string;
319
354
  description: string;
355
+ /**
356
+ * Pre-computed token estimate for this tool's definition (name +
357
+ * description + JSON-serialized inputSchema). Set by ToolRegistry on
358
+ * registration; consumed by estimateToolDefTokens / estimateRequestTokens
359
+ * to skip redundant JSON.stringify on every context-pressure check.
360
+ */
361
+ _estDefTokens?: number | undefined;
320
362
  usageHint?: string | undefined;
321
363
  /** Optional category for grouping in help lists and system prompts. */
322
364
  category?: string | undefined;
@@ -921,6 +963,16 @@ interface SessionData {
921
963
  events: SessionEvent[];
922
964
  messages: Message[];
923
965
  usage: Usage;
966
+ /** Tool execution records extracted from `tool_call_end` events — used for TUI tool entry rendering on resume. */
967
+ toolCallEnds: Array<{
968
+ name: string;
969
+ id: string;
970
+ durationMs: number;
971
+ ok: boolean;
972
+ outputBytes?: number | undefined;
973
+ outputTokens?: number | undefined;
974
+ outputLines?: number | undefined;
975
+ }>;
924
976
  }
925
977
  interface ResumedSession {
926
978
  writer: SessionWriter;
@@ -972,6 +1024,20 @@ interface SessionWriter {
972
1024
  * Used by the REPL to serialize pending state into `session_end` for proper resume. */
973
1025
  readonly pendingToolUses: string[];
974
1026
  append(event: SessionEvent): Promise<void>;
1027
+ /**
1028
+ * Append a batch of events in one call. Semantically equivalent to calling
1029
+ * `append()` for each event sequentially, but avoids N individual function
1030
+ * calls, scrub/observe cycles, and timer rescheduling. The caller is
1031
+ * responsible for ensuring events are in the correct order.
1032
+ */
1033
+ appendBatch(events: SessionEvent[]): Promise<void>;
1034
+ /**
1035
+ * Flush any buffered events to disk immediately. Use after critical
1036
+ * events (user_input, llm_response) to ensure they survive a crash
1037
+ * or SIGKILL that would otherwise leave them in the in-memory buffer.
1038
+ * Idempotent — safe to call even when the buffer is empty.
1039
+ */
1040
+ flush(): Promise<void>;
975
1041
  close(): Promise<void>;
976
1042
  /**
977
1043
  * Register a file change for later snapshotting.
@@ -1109,6 +1175,12 @@ declare class ConversationState {
1109
1175
  /**
1110
1176
  * Cheap immutable snapshot. Useful for tests and for compaction passes
1111
1177
  * that need a stable view across an async boundary.
1178
+ *
1179
+ * Uses shallow-freeze instead of deep-freeze: only the wrapper object
1180
+ * and the three content arrays are frozen. Individual message/todo
1181
+ * objects are NOT recursively frozen — they are reconstructed via
1182
+ * spread copies and are immutable by convention. This cuts the freeze
1183
+ * count from O(n·m·d) (n=messages, m=content blocks, d=depth) to O(1).
1112
1184
  */
1113
1185
  snapshot(): ReadonlyConversationState;
1114
1186
  appendMessage(message: Message): void;
@@ -1154,9 +1226,13 @@ interface RunEnv {
1154
1226
  readonly tokenCounter: TokenCounter;
1155
1227
  readonly cwd: string;
1156
1228
  readonly projectRoot: string;
1229
+ /** Mutable working directory — starts as `cwd`. */
1230
+ readonly workingDir: string;
1157
1231
  readonly model: string;
1158
1232
  readonly systemPrompt: readonly TextBlock[];
1159
1233
  readonly tools: readonly Tool[];
1234
+ readonly agentId: string;
1235
+ readonly agentName: string;
1160
1236
  }
1161
1237
  /**
1162
1238
  * Build a `RunEnv` view from a Context. The returned object is a shallow
@@ -1173,6 +1249,10 @@ interface TodoItem {
1173
1249
  content: string;
1174
1250
  status: 'pending' | 'in_progress' | 'completed';
1175
1251
  activeForm?: string | undefined;
1252
+ /** When promoted from a plan item, stores the plan item's id. */
1253
+ promotedFromPlan?: string | undefined;
1254
+ /** When promoted from a task, stores the task's id. */
1255
+ promotedFromTask?: string | undefined;
1176
1256
  }
1177
1257
  interface RunOptions {
1178
1258
  signal?: AbortSignal | undefined;
@@ -1195,8 +1275,14 @@ interface ContextInit {
1195
1275
  tokenCounter: TokenCounter;
1196
1276
  cwd: string;
1197
1277
  projectRoot: string;
1278
+ /** Mutable working directory. Defaults to `cwd`. Must stay within `projectRoot`. */
1279
+ workingDir?: string | undefined;
1198
1280
  model: string;
1199
1281
  tools?: Tool[] | undefined;
1282
+ /** Agent id performing this run (e.g. 'leader', 'executor', 'tech-stack'). */
1283
+ agentId?: string | undefined;
1284
+ /** Human-readable agent name. */
1285
+ agentName?: string | undefined;
1200
1286
  }
1201
1287
  /**
1202
1288
  * L1-A: `Context` is the live agent-run object. Its read-only environment
@@ -1205,6 +1291,15 @@ interface ContextInit {
1205
1291
  * `state` accessor). New code should declare the narrower type at its
1206
1292
  * parameter — pass `ctx` for it. Existing tools that accept `Context`
1207
1293
  * still work because `Context` structurally satisfies both.
1294
+ *
1295
+ * The single source of truth for the project directory is `projectRoot`.
1296
+ * All tools (read/write/bash/exec) resolve paths relative to this.
1297
+ * Sessions, config, memory, and logs are also stored under this root.
1298
+ *
1299
+ * There IS a mutable `workingDir` (separate from `projectRoot`) that can be
1300
+ * changed at runtime via `setWorkingDir()`. It starts as `cwd` and allows
1301
+ * the agent and user to navigate within the project without spawning a new
1302
+ * process. All changes must stay inside `projectRoot`.
1208
1303
  */
1209
1304
  declare class Context implements RunEnv {
1210
1305
  messages: Message[];
@@ -1218,9 +1313,24 @@ declare class Context implements RunEnv {
1218
1313
  tokenCounter: TokenCounter;
1219
1314
  cwd: string;
1220
1315
  projectRoot: string;
1316
+ /** Mutable working directory — starts as `cwd`. Change via `setWorkingDir()`. */
1317
+ workingDir: string;
1221
1318
  model: string;
1222
1319
  tools: Tool[];
1223
1320
  meta: Record<string, unknown>;
1321
+ /** Agent id performing this run (e.g. 'leader', 'executor'). */
1322
+ agentId: string;
1323
+ /** Human-readable agent name. */
1324
+ agentName: string;
1325
+ /** Callbacks fired when `setWorkingDir()` changes the working directory. */
1326
+ private _onWorkingDirChanged;
1327
+ /**
1328
+ * Set to true when the conversation gains new tool_use or tool_result
1329
+ * blocks — the only time repairToolUseAdjacency() can find new issues.
1330
+ * buildAndRunRequestPipeline() checks this flag to skip an O(n) scan
1331
+ * on iterations where no tool content was added (pure text responses).
1332
+ */
1333
+ toolAdjacencyDirty: boolean;
1224
1334
  constructor(init: ContextInit);
1225
1335
  /**
1226
1336
  * Observable wrapper over the mutable conversation state. Lazy so
@@ -1252,7 +1362,21 @@ declare class Context implements RunEnv {
1252
1362
  clearFileTracking(): void;
1253
1363
  hasRead(absPath: string): boolean;
1254
1364
  lastReadMtime(absPath: string): number | undefined;
1365
+ /**
1366
+ * Change the working directory for path resolution. Resolves relative paths
1367
+ * against `projectRoot` and validates the result is within the project root.
1368
+ * Fires all registered `onWorkingDirChanged` callbacks.
1369
+ * Returns the resolved absolute path.
1370
+ */
1371
+ setWorkingDir(dir: string): string;
1372
+ /**
1373
+ * Register a callback that fires when the working directory changes.
1374
+ * Returns an unsubscribe function. Callbacks are fired synchronously
1375
+ * inside `setWorkingDir()` — errors in callbacks are swallowed so one
1376
+ * bad listener doesn't prevent others from executing.
1377
+ */
1378
+ onWorkingDirChanged(cb: (newDir: string, oldDir: string) => void): () => void;
1255
1379
  usage(): Usage;
1256
1380
  }
1257
1381
 
1258
- export { type ToolFinalEvent as $, AgentError as A, type MessageRole as B, Context as C, PluginError as D, ERROR_CODES as E, type FileSnapshot as F, type ProviderErrorBody as G, type ReadonlyConversationState as H, type ImageBlock as I, type JSONSchema as J, type RiskTier as K, type RunEnv as L, type Message as M, SessionError as N, type StateChange as O, type Provider as P, type StateChangeHandler as Q, type Request as R, type SessionEvent as S, type Tool as T, type Usage as U, type StopReason as V, type StreamEvent as W, StreamHangError as X, type ThinkingBlock as Y, type ToolCallContext as Z, ToolError as _, type SessionWriter as a, type ToolStreamEvent as a0, WrongStackError as a1, asBlocks as a2, asText as a3, extractRunEnv as a4, isAgentError as a5, isConfigError as a6, isFsError as a7, isImageBlock as a8, isPluginError as a9, isSessionError as aa, isTextBlock as ab, isThinkingBlock as ac, isToolError as ad, isToolResultBlock as ae, isToolUseBlock as af, isWrongStackError as ag, toWrongStackError as ah, wrapAsState as ai, type Response as b, type TokenCounter as c, type CacheStats as d, ProviderError as e, type Permission as f, type ContentBlock as g, type SessionMetadata as h, type SessionStore as i, type ToolProgressEvent as j, type Capabilities as k, type TextBlock as l, type ToolUseBlock as m, type ToolResultBlock as n, type RunOptions as o, type ResumedSession as p, type SessionData as q, type SessionSummary as r, type TodoItem as s, ConversationState as t, ConfigError as u, type ContextInit as v, type ErrorCode as w, type ErrorSeverity as x, type ErrorSubsystem as y, FsError as z };
1382
+ export { ToolError as $, AgentError as A, type MessageRole as B, Context as C, PluginError as D, ERROR_CODES as E, type FileSnapshot as F, type ProviderErrorBody as G, type ReadonlyConversationState as H, type ImageBlock as I, type JSONSchema as J, type RiskTier as K, type RunEnv as L, type Message as M, SddError as N, SessionError as O, type Provider as P, type StateChange as Q, type Request as R, type SessionEvent as S, type Tool as T, type Usage as U, type StateChangeHandler as V, type StopReason as W, type StreamEvent as X, StreamHangError as Y, type ThinkingBlock as Z, type ToolCallContext as _, type SessionWriter as a, type ToolFinalEvent as a0, type ToolStreamEvent as a1, WrongStackError as a2, asBlocks as a3, asText as a4, extractRunEnv as a5, isAgentError as a6, isConfigError as a7, isFsError as a8, isImageBlock as a9, isPluginError as aa, isSddError as ab, isSessionError as ac, isTextBlock as ad, isThinkingBlock as ae, isToolError as af, isToolResultBlock as ag, isToolUseBlock as ah, isWrongStackError as ai, toWrongStackError as aj, wrapAsState as ak, type Response as b, type TokenCounter as c, type CacheStats as d, ProviderError as e, type Permission as f, type ContentBlock as g, type SessionMetadata as h, type SessionStore as i, type ToolProgressEvent as j, type Capabilities as k, type ToolUseBlock as l, type ToolResultBlock as m, type TextBlock as n, type RunOptions as o, type ResumedSession as p, type SessionData as q, type SessionSummary as r, type TodoItem as s, ConversationState as t, ConfigError as u, type ContextInit as v, type ErrorCode as w, type ErrorSeverity as x, type ErrorSubsystem as y, FsError as z };
@@ -1,19 +1,21 @@
1
- export { b as BrainArbiter, B as BrainDecision, d as BrainDecisionOption, e as BrainDecisionQueue, a as BrainDecisionRequest, f as BrainDecisionSource, g as BrainFallback, h as BrainRisk, D as DefaultBrainArbiter, i as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, j as formatHumanPrompt } from '../brain-CS_B0vIE.js';
2
- export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CGOez8Le.js';
3
- import { A as AgentDefinition } from '../multi-agent-coordinator-BSKSFNhv.js';
4
- export { T as AGENT_TOOL_PRESETS, b as AgentBudgetTier, c as AgentCapability, d as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-BSKSFNhv.js';
5
- export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, n as BudgetNegotiationMode, o as BudgetThresholdDecision, p as BudgetThresholdHandler, q as BudgetThresholdSignal, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-Bsueu0J2.js';
6
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BbZU5TPN.js';
7
- import '../context-C7G_MtLV.js';
1
+ export { B as BrainArbiter, b as BrainDecision, c as BrainDecisionOption, d as BrainDecisionQueue, e as BrainDecisionRequest, f as BrainDecisionSource, g as BrainFallback, h as BrainRisk, D as DefaultBrainArbiter, i as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, j as formatHumanPrompt } from '../brain-sCZ3lCjq.js';
2
+ export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-Do1OLYpj.js';
3
+ import { A as AgentDefinition } from '../multi-agent-coordinator-CnbEqpv0.js';
4
+ export { T as AGENT_TOOL_PRESETS, b as AgentBudgetTier, c as AgentCapability, d as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CnbEqpv0.js';
5
+ export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, n as BudgetNegotiationMode, o as BudgetThresholdDecision, p as BudgetThresholdHandler, q as BudgetThresholdSignal, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-Dz-9kiE6.js';
6
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-4gc0vfW2.js';
7
+ export { B as BrainInterventionInput, a as BrainMonitor, b as BrainMonitorOptions, D as DEPENDENCY_FILE_PATTERNS, c as DefaultMailbox, d as DepWatchEntry, e as DepWatcherBridgeOptions, f as DependencyWatcherConfig, G as GlobalMailbox, M as MailToolsOptions, g as MailboxResolver, h as MailboxToolOptions, O as OutdatedNotifyMessage, P as PackageAuthorEntry, i as PackageAuthorLog, j as PackageAuthorTrackerOptions, k as PackageOutdatedEntry, l as PackageOutdatedResult, m as PackageOutdatedWatcherOptions, n as attachDepWatcherBridge, o as detectEcosystem, p as getFullPackageLog, q as getManifestPackages, r as getPackageAuthor, s as getPackagesByAgent, t as mailboxSessionTag, u as makeDependencyWatcherConfig, v as makeMailInboxTool, w as makeMailSendTool, x as makeMailboxTool, y as recordPackageAction, z as resolveMailboxIdentity, A as resolveProjectDir, C as startPackageOutdatedWatcher, E as updatePackageOutdatedStatus } from '../package-outdated-watcher-CA5GGB4C.js';
8
+ import { b as Mailbox } from '../pipeline-D1n-gQI-.js';
9
+ export { h as AgentHeartbeatInput, A as AgentRegistrationInput, f as MailboxAckInput, g as MailboxAgentStatus, d as MailboxMessage, i as MailboxMessageType, e as MailboxQuery, c as MailboxSendInput, j as MailboxTaskContext, k as ReadReceipts, l as RegisteredAgent, n as normalizeRecipient } from '../pipeline-D1n-gQI-.js';
10
+ import '../context-CLz3z_E8.js';
8
11
  import 'node:events';
9
12
  import '../director-state-BfeCUbmk.js';
10
- import '../config-BaVThgnT.js';
11
- import '../index-B5wz-GXm.js';
13
+ import '../config-eSsrto5d.js';
14
+ import '../index-IehiNryU.js';
12
15
  import '../logger-B63L5bTg.js';
13
- import '../pipeline-BG7UgbDc.js';
14
16
  import '../observability-D-HZN_mF.js';
15
- import '../permission-B7nKnEvQ.js';
16
- import '../retry-policy-rutAfVeR.js';
17
+ import '../permission-DbWPbuoA.js';
18
+ import '../retry-policy-BVnkbMET.js';
17
19
 
18
20
  /** Phase 1 · Discovery — map the territory before any work begins. */
19
21
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -42,4 +44,59 @@ declare const DELIVERY_AGENTS: AgentDefinition[];
42
44
  /** Phase 9 · Meta — agents that improve the agent system itself. */
43
45
  declare const META_AGENTS: AgentDefinition[];
44
46
 
45
- export { AgentDefinition, BUILD_AGENTS, DELIVERY_AGENTS, DISCOVERY_AGENTS, DOMAIN_AGENTS, KNOWLEDGE_AGENTS, META_AGENTS, PLANNING_AGENTS, REVIEW_AGENTS, VERIFY_AGENTS };
47
+ /**
48
+ * mailbox-hooks — Tool-execution hooks for mailbox integration.
49
+ *
50
+ * 1. Before each tool call, checks the mailbox for unread high-priority
51
+ * steer messages and emits a `mailbox.unread_count` event.
52
+ * 2. After each tool call, updates the agent heartbeat so other agents
53
+ * know this one is still alive.
54
+ *
55
+ * This gives near-real-time mailbox checking (every tool call, not just
56
+ * iteration boundaries) and powers the "new mail" badge in the WebUI/TUI.
57
+ *
58
+ * @module mailbox-hooks
59
+ */
60
+
61
+ interface MailboxHooksOptions {
62
+ /** The mailbox instance. */
63
+ mailbox: Mailbox;
64
+ /** Agent id for read-receipt and unread-check purposes. */
65
+ agentId: string;
66
+ /** Whether to emit new-mail notifications. Default: true. */
67
+ notifyNewMail?: boolean | undefined;
68
+ /** Whether to update heartbeat. Default: true. */
69
+ heartbeat?: boolean | undefined;
70
+ }
71
+ /**
72
+ * Create a pair of hooks for the tool execution pipeline.
73
+ *
74
+ * Usage:
75
+ * const hooks = createMailboxHooks({ mailbox, agentId });
76
+ * // In the tool executor, before each tool call:
77
+ * await hooks.beforeTool({ events });
78
+ * // After each tool call:
79
+ * await hooks.afterTool();
80
+ *
81
+ * The `beforeTool` hook checks for unread messages and emits
82
+ * `mailbox.unread_count` events. The `afterTool` hook updates
83
+ * the agent heartbeat.
84
+ */
85
+ declare function createMailboxHooks(opts: MailboxHooksOptions): {
86
+ /**
87
+ * Call before each tool execution. Checks mailbox and emits events.
88
+ * @param events — EventBus-like object with emit method.
89
+ */
90
+ beforeTool(events: {
91
+ emit: (type: string, payload: unknown) => void;
92
+ }): Promise<void>;
93
+ /**
94
+ * Call after each tool execution. Updates heartbeat and optionally
95
+ * current tool status.
96
+ */
97
+ afterTool(toolName?: string): Promise<void>;
98
+ /** Reset the cached unread count (e.g., after the agent checks manually). */
99
+ reset(): void;
100
+ };
101
+
102
+ export { AgentDefinition, BUILD_AGENTS, DELIVERY_AGENTS, DISCOVERY_AGENTS, DOMAIN_AGENTS, KNOWLEDGE_AGENTS, META_AGENTS, Mailbox, type MailboxHooksOptions, PLANNING_AGENTS, REVIEW_AGENTS, VERIFY_AGENTS, createMailboxHooks };