@wrongstack/core 0.264.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 (87) hide show
  1. package/dist/{agent-bridge-D8sa1vtv.d.ts → agent-bridge-DrkBxszZ.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-c9DLkaas.d.ts → agent-subagent-runner-DM2pP-B6.d.ts} +113 -11
  3. package/dist/{brain-O1IdKPaK.d.ts → brain-BXd_61kQ.d.ts} +31 -2
  4. package/dist/{compactor-BBy0rCtB.d.ts → compactor-B8pOf45Y.d.ts} +1 -1
  5. package/dist/{config-Dz2F3H2K.d.ts → config-BMCj_XDs.d.ts} +80 -12
  6. package/dist/{context-BGSpZNSE.d.ts → context-MRk5PhNv.d.ts} +26 -12
  7. package/dist/coordination/index.d.ts +77 -21
  8. package/dist/coordination/index.js +557 -159
  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 +609 -195
  13. package/dist/defaults/index.js.map +1 -1
  14. package/dist/execution/index.d.ts +16 -16
  15. package/dist/execution/index.js +394 -155
  16. package/dist/execution/index.js.map +1 -1
  17. package/dist/execution/prompt-enhancer.d.ts +2 -2
  18. package/dist/execution/prompt-enhancer.js +1 -1
  19. package/dist/execution/prompt-enhancer.js.map +1 -1
  20. package/dist/extension/index.d.ts +6 -6
  21. package/dist/{goal-preamble-DzjFuN3p.d.ts → goal-preamble-DvHDSKSe.d.ts} +14 -10
  22. package/dist/{goal-store-CxWmCGbH.d.ts → goal-store-DtLMySNb.d.ts} +1 -1
  23. package/dist/{index-CYIQrXVF.d.ts → index-B-ch8K9C.d.ts} +8 -8
  24. package/dist/{index-CbLSI66_.d.ts → index-CEDeNodM.d.ts} +5 -5
  25. package/dist/index.d.ts +183 -52
  26. package/dist/index.js +1779 -673
  27. package/dist/index.js.map +1 -1
  28. package/dist/infrastructure/index.d.ts +6 -6
  29. package/dist/infrastructure/index.js +12 -8
  30. package/dist/infrastructure/index.js.map +1 -1
  31. package/dist/kernel/index.d.ts +9 -9
  32. package/dist/kernel/index.js +1 -1
  33. package/dist/kernel/index.js.map +1 -1
  34. package/dist/{llm-selector-DzxuZnNz.d.ts → llm-selector-C0tfTCUe.d.ts} +14 -2
  35. package/dist/{mcp-servers-DC4QRPUI.d.ts → mcp-servers-2x4w6Jn9.d.ts} +3 -3
  36. package/dist/models/index.d.ts +5 -5
  37. package/dist/models/index.js +74 -30
  38. package/dist/models/index.js.map +1 -1
  39. package/dist/{models-registry-B_siPxqN.d.ts → models-registry-DmJlKuNp.d.ts} +1 -1
  40. package/dist/{multi-agent-coordinator-CK5Jdj9K.d.ts → multi-agent-coordinator-DyCkCZnU.d.ts} +1 -1
  41. package/dist/{null-fleet-bus-DgvD4SCO.d.ts → null-fleet-bus-CG9QY2aP.d.ts} +6 -6
  42. package/dist/observability/index.d.ts +2 -2
  43. package/dist/{parallel-eternal-engine-bK0JQBR_.d.ts → parallel-eternal-engine-Jw9uhEoT.d.ts} +9 -9
  44. package/dist/{path-resolver-BPEDlN38.d.ts → path-resolver-Dy2ej-gE.d.ts} +3 -3
  45. package/dist/{permission-4yvGmMRB.d.ts → permission-B9SB45lp.d.ts} +1 -1
  46. package/dist/{permission-policy-C6XpsBOy.d.ts → permission-policy-CkjSXabK.d.ts} +2 -2
  47. package/dist/{pipeline-CXCeMz8J.d.ts → pipeline-DPDxH_7m.d.ts} +3 -3
  48. package/dist/{plan-templates-BvzRBkJc.d.ts → plan-templates-CzD9GnAU.d.ts} +32 -8
  49. package/dist/{provider-runner-C5aQpDWE.d.ts → provider-runner-DMa70ODu.d.ts} +3 -3
  50. package/dist/{retry-policy-CFhdtRzz.d.ts → retry-policy-CN0khdlj.d.ts} +1 -1
  51. package/dist/sdd/index.d.ts +8 -8
  52. package/dist/sdd/index.js +274 -93
  53. package/dist/sdd/index.js.map +1 -1
  54. package/dist/{secret-vault-CxiVLbt1.d.ts → secret-vault-B2yw84VT.d.ts} +43 -4
  55. package/dist/secret-vault-BAKpgFw_.d.ts +57 -0
  56. package/dist/security/index.d.ts +5 -5
  57. package/dist/security/index.js +204 -23
  58. package/dist/security/index.js.map +1 -1
  59. package/dist/{selector-gIuhRTkN.d.ts → selector-CzHh_igB.d.ts} +1 -1
  60. package/dist/{session-event-bridge-DkvvrpDt.d.ts → session-event-bridge-BUI6Jf-4.d.ts} +1 -1
  61. package/dist/{session-reader-KdfVwkKP.d.ts → session-reader-CMgdMSRP.d.ts} +1 -1
  62. package/dist/storage/index.d.ts +112 -15
  63. package/dist/storage/index.js +419 -81
  64. package/dist/storage/index.js.map +1 -1
  65. package/dist/tools/index.d.ts +2 -2
  66. package/dist/types/index.d.ts +21 -21
  67. package/dist/types/index.js +261 -53
  68. package/dist/types/index.js.map +1 -1
  69. package/dist/utils/index.d.ts +3 -3
  70. package/dist/utils/index.js +3 -5
  71. package/dist/utils/index.js.map +1 -1
  72. package/dist/{wstack-paths-CJjEwPXn.d.ts → wstack-paths-hOpNLmvf.d.ts} +2 -0
  73. package/package.json +1 -1
  74. package/skills/api-design/SKILL.md +1 -1
  75. package/skills/audit-log/SKILL.md +6 -6
  76. package/skills/bug-hunter/SKILL.md +5 -5
  77. package/skills/chimera/SKILL.md +4 -4
  78. package/skills/docker-deploy/SKILL.md +1 -1
  79. package/skills/git-flow/SKILL.md +3 -3
  80. package/skills/multi-agent/SKILL.md +3 -3
  81. package/skills/node-modern/SKILL.md +1 -0
  82. package/skills/observability/SKILL.md +2 -2
  83. package/skills/output-standards/SKILL.md +51 -28
  84. package/skills/refactor-planner/SKILL.md +3 -3
  85. package/skills/security-scanner/SKILL.md +4 -3
  86. package/skills/tech-stack/SKILL.md +1 -2
  87. package/dist/secret-vault-BJDY28ev.d.ts +0 -25
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-c9DLkaas.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-DM2pP-B6.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-CbLSI66_.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-CXCeMz8J.js';
3
- import { E as EventBus, a as EventName, L as Listener } from './brain-O1IdKPaK.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-CFhdtRzz.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-CEDeNodM.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-DPDxH_7m.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-BXd_61kQ.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-CN0khdlj.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-4yvGmMRB.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-BGSpZNSE.js';
9
- import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-Dz2F3H2K.js';
7
+ import { P as PermissionPolicy } from './permission-B9SB45lp.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-MRk5PhNv.js';
9
+ import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-BMCj_XDs.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -130,6 +130,23 @@ declare class FleetUsageAggregator {
130
130
  }
131
131
 
132
132
  type BudgetKind = 'tool_calls' | 'iterations' | 'tokens' | 'timeout' | 'idle_timeout' | 'cost';
133
+ /**
134
+ * Fraction of the wall-clock `timeoutMs` window at which a PROACTIVE extension
135
+ * is negotiated — BEFORE the deadline is actually crossed. The coordinator
136
+ * watchdog (`executeWithTimeout`) arms at `timeoutMs * TIMEOUT_PREEMPT_FRACTION`
137
+ * so a still-progressing subagent gets its ceiling raised while it is below the
138
+ * limit, and never enters a "timed out" state. Reactive enforcement at the real
139
+ * deadline still stands for the no-progress / denied case. Shared so the asking
140
+ * side and any future caller agree on the same lead point.
141
+ */
142
+ declare const TIMEOUT_PREEMPT_FRACTION = 0.85;
143
+ /**
144
+ * Hard safety net for budget negotiation decisions. If no listener responds to
145
+ * `budget.threshold_reached` within this window the negotiation defaults to
146
+ * `'stop'`. Exported so the coordinator's watchdog can reuse the same ceiling
147
+ * without hardcoding a second copy.
148
+ */
149
+ declare const DECISION_TIMEOUT_MS = 60000;
133
150
  declare class BudgetExceededError extends Error {
134
151
  readonly kind: BudgetKind;
135
152
  readonly limit: number;
@@ -215,7 +232,18 @@ type BudgetThresholdHandler = (info: {
215
232
  used: number;
216
233
  limit: number;
217
234
  requestDecision: () => Promise<BudgetThresholdDecision>;
218
- }) => 'throw' | 'continue' | Promise<BudgetThresholdDecision>;
235
+ /**
236
+ * Direct grant/deny hooks for SYNCHRONOUS policy or recording handlers that
237
+ * decide in-process without a wired `budget.threshold_reached` listener
238
+ * (e.g. the coordinator watchdog). `extend` patches the limits in place;
239
+ * `deny` records the intent to stop. Production listener-driven handlers use
240
+ * `requestDecision()` instead and can ignore these.
241
+ */
242
+ extend?: (extra: Partial<BudgetLimits>) => void;
243
+ deny?: () => void;
244
+ }) => 'throw' | 'continue' | 'stop' | {
245
+ extend: Partial<BudgetLimits>;
246
+ } | Promise<BudgetThresholdDecision>;
219
247
  /**
220
248
  * Per-subagent budget enforcement. Each subagent gets its own instance so a
221
249
  * runaway agent can't drain the cost ceiling of its siblings. All record/check
@@ -237,6 +265,12 @@ type BudgetThresholdHandler = (info: {
237
265
  */
238
266
  declare class SubagentBudget {
239
267
  readonly limits: Readonly<BudgetLimits>;
268
+ /** Patch one or more budget limits in-place after construction.
269
+ * Used by the coordinator watchdog when granting an extension.
270
+ * All fields are optional — only provided fields are updated.
271
+ * This is the single write path for limit mutations so that future
272
+ * validation or side-effects live in one place (M1). */
273
+ patchLimits(ext: Partial<BudgetLimits>): void;
240
274
  private iterations;
241
275
  private toolCalls;
242
276
  private tokenInput;
@@ -263,6 +297,32 @@ declare class SubagentBudget {
263
297
  * Used to emit `budget.threshold_reached` events in `'auto'` mode.
264
298
  */
265
299
  _events?: EventBus | undefined;
300
+ /**
301
+ * Guard against dual-path races between the coordinator watchdog
302
+ * (`executeWithTimeout`) and the budget's own `checkTimeout()`.
303
+ * Both paths detect `elapsed >= timeoutMs` and can emit
304
+ * `budget.threshold_reached` for kind `'timeout'` simultaneously.
305
+ * Set to the current `timeoutMs` ceiling by the coordinator BEFORE
306
+ * calling `onThreshold`, and cleared after the negotiation resolves.
307
+ * `checkTimeout()` skips its wall-clock check while this is set so
308
+ * the coordinator's watchdog is the sole source of wall-clock timeout
309
+ * events — `checkTimeout()` focuses exclusively on `idle_timeout`.
310
+ */
311
+ private _watchdogActive;
312
+ /** Returns the timeout ceiling currently being negotiated by the watchdog,
313
+ * or `undefined` when no wall-clock negotiation is in flight.
314
+ * Used by `executeWithTimeout` to detect a stale lock (M3). */
315
+ get watchdogActive(): number | undefined;
316
+ /** Called by the coordinator watchdog BEFORE calling `onThreshold` so that
317
+ * `checkTimeout()` skips its wall-clock check for this ceiling. Prevents
318
+ * the budget's own `checkTimeout()` from emitting a second
319
+ * `budget.threshold_reached` event while the watchdog is already
320
+ * negotiating the same wall-clock deadline (C1). */
321
+ setWatchdogNegotiation(timeoutMs: number): void;
322
+ /** Clears the watchdog guard after negotiation resolves. Called in the
323
+ * `finally` block of both the pre-empt and deadline branches so it fires
324
+ * on every exit path: grant, deny, throw, or error. */
325
+ clearWatchdogNegotiation(): void;
266
326
  /**
267
327
  * Negotiation mode — controls whether a threshold hit tries to emit
268
328
  * `budget.threshold_reached` and wait for a coordinator decision, or
@@ -320,6 +380,24 @@ declare class SubagentBudget {
320
380
  * Returns the kinds that were found to be exceeded (for logging/debugging).
321
381
  */
322
382
  private checkLimits;
383
+ /**
384
+ * Invoke `onThreshold` once for `entry` on the NO-LISTENER path and report
385
+ * whether it decided synchronously. Returns `true` when the handler returned
386
+ * a synchronous decision (already honored — an `extend` patched the limits),
387
+ * or `false` when it returned a Promise (async; the caller hard-stops, since
388
+ * there is no listener to resolve the negotiation). The handler is given the
389
+ * full info shape (`requestDecision` plus direct `extend`/`deny`) so both
390
+ * recording handlers and policy handlers work without a wired listener.
391
+ */
392
+ private _invokeHandlerSync;
393
+ /**
394
+ * Emit `budget.threshold_reached` and resolve to the listener's verdict.
395
+ * Resolves to `'stop'` immediately when there is no listener (or no bus) so
396
+ * no negotiation can hang and no fallback timer leaks. Mirrors the
397
+ * coordinator watchdog's own request path so both agree on the no-listener
398
+ * default.
399
+ */
400
+ private _busRequestDecision;
323
401
  /**
324
402
  * Per-kind in-flight negotiation Promises. Each budget kind can have its
325
403
  * own concurrent negotiation — e.g. iterations and timeout can both
@@ -415,6 +493,15 @@ interface SubagentConfig {
415
493
  * default reaper for delegated subagents (see `applyRosterBudget`).
416
494
  */
417
495
  idleTimeoutMs?: number | undefined;
496
+ /**
497
+ * Fraction of `timeoutMs` at which the proactive pre-empt fires (0.0–1.0).
498
+ * At this point the watchdog negotiates a ceiling extension while the
499
+ * agent is still under its limit, so a progressing agent gets its
500
+ * ceiling raised before ever entering a timed-out state.
501
+ * Defaults to `TIMEOUT_PREEMPT_FRACTION` (0.85). Lower values fire earlier;
502
+ * higher values fire closer to the deadline. Ignored when `timeoutMs` is unset.
503
+ */
504
+ preemptFraction?: number | undefined;
418
505
  tools?: string[] | undefined;
419
506
  /**
420
507
  * Tools to explicitly disable for this subagent. These tools will be
@@ -966,8 +1053,23 @@ interface Plugin {
966
1053
  * defaultConfig: { ttl: 3600, maxSize: 100 }
967
1054
  */
968
1055
  defaultConfig?: Record<string, unknown>;
969
- setup(api: PluginAPI): void | Promise<void>;
970
- teardown?(api: PluginAPI): void | Promise<void>;
1056
+ /**
1057
+ * Called by the host to activate the plugin. Receives the `PluginAPI`
1058
+ * and an optional `AbortSignal` the plugin should respect for
1059
+ * cancellation and timeout. `setup` must complete before the plugin is
1060
+ * considered loaded; if it times out the plugin is rejected.
1061
+ */
1062
+ setup(api: PluginAPI, opts?: {
1063
+ signal?: AbortSignal | undefined;
1064
+ }): void | Promise<void>;
1065
+ /**
1066
+ * Called by the host during unload. Receives the same `PluginAPI` instance
1067
+ * the plugin saw during `setup` and an optional `AbortSignal`. Teardown
1068
+ * is best-effort — a timeout does not prevent other plugins from unloading.
1069
+ */
1070
+ teardown?(api: PluginAPI, opts?: {
1071
+ signal?: AbortSignal | undefined;
1072
+ }): void | Promise<void>;
971
1073
  /**
972
1074
  * Optional health check. Called by the host (e.g. `/diag plugins` slash
973
1075
  * command or health endpoint) to surface plugin status. Return
@@ -1084,4 +1186,4 @@ interface AgentRunnerOptions {
1084
1186
  */
1085
1187
  declare function makeAgentSubagentRunner(opts: AgentRunnerOptions): SubagentRunner;
1086
1188
 
1087
- export { type ProviderFactory as $, type AgentBridge as A, type BridgeTransport as B, type CoordinatorStatus as C, type DoneCondition as D, type BudgetThresholdDecision as E, FleetBus as F, type BudgetThresholdHandler as G, BudgetThresholdSignal as H, type BudgetUsage as I, type CoordinatorEvents as J, type FleetEvent as K, type FleetHandler as L, type MultiAgentCoordinator as M, type PluginDependency as N, SubagentBudget as O, type PluginAPI as P, type SubagentContext as Q, type SubagentError as R, type SubagentConfig as S, type TaskSpec as T, type SubagentErrorKind as U, type SubagentRunContext as V, type SubagentRunOutcome as W, type SubagentUsageSnapshot as X, type TaskDelegation as Y, makeAgentSubagentRunner as Z, withDisabledToolFiltering as _, type BridgeMessage as a, type AgentBridgeConfig as b, type MultiAgentConfig as c, type SubagentRunner as d, type SpawnResult as e, type TaskResult as f, Agent as g, type AgentFactory as h, type FleetUsage as i, FleetUsageAggregator as j, type SlashCommand as k, type PluginPipelines as l, type ToolRegistryView as m, type ProviderRegistryView as n, type MCPRegistryView as o, type SlashCommandRegistryView as p, type SessionWriterView as q, type MetricsSinkView as r, type PluginCapabilities as s, type Plugin as t, type AgentFactoryResult as u, type AgentRunnerOptions as v, BudgetExceededError as w, type BudgetKind as x, type BudgetLimits as y, type BudgetNegotiationMode as z };
1189
+ export { makeAgentSubagentRunner as $, type AgentBridge as A, type BridgeTransport as B, type CoordinatorStatus as C, type DoneCondition as D, type BudgetNegotiationMode as E, FleetBus as F, type BudgetThresholdDecision as G, type BudgetThresholdHandler as H, BudgetThresholdSignal as I, type BudgetUsage as J, type CoordinatorEvents as K, DECISION_TIMEOUT_MS as L, type MultiAgentCoordinator as M, type FleetEvent as N, type FleetHandler as O, type PluginAPI as P, SubagentBudget as Q, type SubagentContext as R, type SubagentConfig as S, type TaskSpec as T, type SubagentError as U, type SubagentErrorKind as V, type SubagentRunContext as W, type SubagentRunOutcome as X, type SubagentUsageSnapshot as Y, TIMEOUT_PREEMPT_FRACTION as Z, type TaskDelegation as _, type BridgeMessage as a, withDisabledToolFiltering as a0, type ProviderFactory as a1, type AgentBridgeConfig as b, type MultiAgentConfig as c, type SubagentRunner as d, type SpawnResult as e, type TaskResult as f, Agent as g, type AgentFactory as h, type FleetUsage as i, FleetUsageAggregator as j, type SlashCommand as k, type PluginPipelines as l, type ToolRegistryView as m, type ProviderRegistryView as n, type MCPRegistryView as o, type SlashCommandRegistryView as p, type SessionWriterView as q, type MetricsSinkView as r, type PluginCapabilities as s, type PluginDependency as t, type Plugin as u, type AgentFactoryResult as v, type AgentRunnerOptions as w, BudgetExceededError as x, type BudgetKind as y, type BudgetLimits as z };
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-BGSpZNSE.js';
1
+ import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-MRk5PhNv.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -256,8 +256,16 @@ interface EventMap {
256
256
  id: string;
257
257
  event: ToolProgressEvent;
258
258
  };
259
+ /** Cache hit on session store load — used by observability layers. */
260
+ 'storage.cache_hit': {
261
+ sessionId: string;
262
+ store: string;
263
+ filePath: string;
264
+ operation: string;
265
+ durationMs: number;
266
+ };
259
267
  /**
260
- * Fired when a tool call needs user confirmation and no confirmHandler
268
+ * Fired when a tool call needs confirmation
261
269
  * is registered on the executor. The TUI renders a confirmation dialog
262
270
  * from this event. Resolution is driven by calling the resolve function
263
271
  * passed in the payload with a decision string ('yes' | 'no' | 'always' | 'deny').
@@ -801,6 +809,27 @@ interface EventMap {
801
809
  durationMs?: number;
802
810
  traceId?: string;
803
811
  };
812
+ /**
813
+ * Real-time client status event. Emitted by TUI/CLI/WebUI to report current
814
+ * session stats (tool calls, tokens, model, mode, cost). Broadcast immediately
815
+ * to all WebUI clients via setup-events.ts and written to status.json for
816
+ * external watchers.
817
+ */
818
+ 'client.status': {
819
+ clientType: string;
820
+ clientId: string;
821
+ projectHash: string;
822
+ agentCount: number;
823
+ model: string;
824
+ mode: string;
825
+ toolCalls: number;
826
+ inputTokens: number;
827
+ outputTokens: number;
828
+ cacheTokens: number;
829
+ costUsd: number;
830
+ timestamp: number;
831
+ projectSlug: string;
832
+ };
804
833
  error: {
805
834
  err: Error;
806
835
  phase: string;
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-BGSpZNSE.js';
1
+ import { C as Context } from './context-MRk5PhNv.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-BGSpZNSE.js';
1
+ import { k as Capabilities, f as Permission } from './context-MRk5PhNv.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -224,6 +224,25 @@ interface ModelsRegistry {
224
224
  ageSeconds(): Promise<number>;
225
225
  }
226
226
 
227
+ /**
228
+ * Token-saving mode tier levels. Controls how aggressively the system prompt
229
+ * is compacted to reduce per-request token consumption.
230
+ *
231
+ * - 'off' — Full prompt, all tools, complete guidance (no reduction)
232
+ * - 'minimal' — TIER1 tools only (~10), stripped guidance (~3-4k tokens saved)
233
+ * - 'light' — Core + memory tools (~14), common patterns, minimal guidance
234
+ * - 'medium' — Most development tools (~24), some guidance (default when `true`)
235
+ * - 'aggressive' — Maximum savings before tools become unusable (~4-5k tokens saved)
236
+ */
237
+ type TokenSavingTier = 'off' | 'minimal' | 'light' | 'medium' | 'aggressive';
238
+ /**
239
+ * Normalize a TokenSavingTier value, handling backward-compatible boolean inputs.
240
+ * - `true` → 'medium' (existing behavior)
241
+ * - `false` → 'off'
242
+ * - string values are returned as-is after validation
243
+ * - `undefined` → 'off'
244
+ */
245
+ declare function normalizeTokenSavingTier(val?: TokenSavingTier | boolean): TokenSavingTier;
227
246
  interface ContextConfig {
228
247
  /** Context-window policy mode. Controls compaction thresholds and preservation depth. */
229
248
  mode?: ContextWindowModeId | undefined;
@@ -252,6 +271,30 @@ interface ContextConfig {
252
271
  /** Enable LLM-driven selective compaction (default: false for backward compat). */
253
272
  llmSelector?: boolean | undefined;
254
273
  }
274
+ /**
275
+ * Runtime configuration for the process circuit breaker (the one owned by the
276
+ * ProcessRegistry that gates `bash`/`exec`). Toggle via `/settings breaker`.
277
+ *
278
+ * The breaker itself is a low-level primitive (`packages/tools/.../circuit-breaker.ts`)
279
+ * that is on by default; this section controls whether the registry actually
280
+ * participates in it and how it auto-recovers.
281
+ */
282
+ interface CircuitBreakerRuntimeConfig {
283
+ /**
284
+ * Enable circuit-breaker protection. When false (the default), the breaker
285
+ * is bypassed — `bash`/`exec` calls always proceed regardless of failure
286
+ * history. When true, the breaker trips on repeated failures / slow calls /
287
+ * bursts and blocks further calls until it recovers.
288
+ */
289
+ enabled?: boolean | undefined;
290
+ /**
291
+ * When the breaker trips, automatically kill all tracked processes AND
292
+ * reset the breaker to closed after this delay (ms). 0 = disabled (manual
293
+ * recovery only via `/kill reset`). Only effective when `enabled` is true.
294
+ * While armed, the statusline shows a live countdown to the kill/reset.
295
+ */
296
+ autoKillResetMs?: number | undefined;
297
+ }
255
298
  interface ToolsConfig {
256
299
  defaultExecutionStrategy: 'parallel' | 'sequential' | 'smart';
257
300
  maxIterations: number;
@@ -263,6 +306,14 @@ interface ToolsConfig {
263
306
  * limit by 100 when hit. Set to false to require user confirmation.
264
307
  */
265
308
  autoExtendLimit?: boolean | undefined;
309
+ /**
310
+ * When true, file tools (read/write/edit/grep/glob/install) are confined to
311
+ * the project root and `set_working_dir` may not leave it. Default: false —
312
+ * tools may access paths outside the project root, still subject to each
313
+ * tool's permission tier (writes/edits prompt for confirmation). Toggle via
314
+ * `/settings` ("Filesystem access").
315
+ */
316
+ restrictToProjectRoot?: boolean | undefined;
266
317
  }
267
318
  interface ProviderApiKey {
268
319
  /** Short human-readable label (e.g. "personal", "work", "rate-limit-backup"). */
@@ -278,10 +329,12 @@ interface ProviderApiKey {
278
329
  interface ProviderConfig {
279
330
  type: string;
280
331
  /**
281
- * Legacy single-key field. Still honored as a fallback when `apiKeys`
282
- * is empty. When `apiKeys`/`activeKey` are present, the config loader
283
- * mirrors the active entry into this field so downstream consumers
284
- * (provider construction, wire adapters) need no changes.
332
+ * Legacy single-key field. Still honored as a read fallback when `apiKeys`
333
+ * is empty (for configs not yet migrated to multi-key format). After key
334
+ * management operations (`writeKeysBack`), this field is **cleared** to
335
+ * prevent accidental serialization of the plaintext key. Consumers that
336
+ * need the active API key should use `resolveActiveApiKey()` (cli) or
337
+ * resolve from `apiKeys[]` directly — never read `cfg.apiKey` in new code.
285
338
  */
286
339
  apiKey?: string | undefined;
287
340
  /** Multiple keys for the same provider — pick one with `activeKey`. */
@@ -375,13 +428,23 @@ interface FeaturesConfig {
375
428
  /** Discover + load skills from disk. */
376
429
  skills: boolean;
377
430
  /**
378
- * Token-saving mode: when enabled, non-essential tools are omitted,
379
- * skill descriptions are trimmed, and the system prompt is shortened
380
- * to reduce per-request token consumption without compromising core
381
- * functionality. Enable with `--token-saving-mode` or
382
- * `features.tokenSavingMode: true` in config.
431
+ * Token-saving mode tier. Controls how aggressively the system prompt
432
+ * is compacted to reduce per-request token consumption.
433
+ *
434
+ * - 'off' — Full prompt, all tools, complete guidance
435
+ * - 'minimal' — TIER1 tools only, stripped guidance (~3-4k tokens saved)
436
+ * - 'light' — Core + memory tools, common patterns, minimal guidance
437
+ * - 'medium' — Most development tools, some guidance
438
+ * - 'aggressive' — Maximum savings before tools become unusable (~4-5k tokens)
439
+ *
440
+ * Boolean values are accepted for backward compatibility:
441
+ * - `true` → 'medium'
442
+ * - `false` → 'off'
443
+ *
444
+ * Enable via CLI: `--token-saving-tier <level>` or `--token-saving-mode` (maps to 'medium').
445
+ * Configure via: `features.tokenSavingMode: "minimal"` in config.
383
446
  */
384
- tokenSavingMode?: boolean | undefined;
447
+ tokenSavingMode?: TokenSavingTier | boolean | undefined;
385
448
  /**
386
449
  * Allow tools to read/write paths outside the project root directory.
387
450
  * When true (default), tools can access any path on the filesystem.
@@ -563,6 +626,11 @@ interface Config {
563
626
  configScope?: 'global' | 'project' | undefined;
564
627
  /** Automatic codebase symbol-index maintenance (session-start + live updates). */
565
628
  indexing?: IndexingConfig | undefined;
629
+ /**
630
+ * Process circuit-breaker protection (gates `bash`/`exec` on repeated
631
+ * failures). Default off — toggle with `/settings breaker on|off`.
632
+ */
633
+ circuitBreaker?: CircuitBreakerRuntimeConfig | undefined;
566
634
  /** Saved launch preferences — restored on next boot for one-line confirmation. */
567
635
  launch?: LaunchConfig | undefined;
568
636
  /**
@@ -631,4 +699,4 @@ interface ConfigStore {
631
699
  watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
632
700
  }
633
701
 
634
- 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 };
702
+ export { type AutonomyConfig as A, type ProviderApiKey as B, type ContextWindowAggressiveOn as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type SessionLoggingConfig as E, type FeaturesConfig as F, type SyncCategory as G, type HookEvent as H, type InProcessHook as I, type ToolsConfig as J, formatContextWindowModeList as K, type LaunchConfig as L, type ModelsRegistry as M, getContextWindowMode as N, isContextWindowModeId as O, type ProviderConfig as P, listContextWindowModes as Q, type ResolvedProvider as R, type ShellHook as S, type TokenSavingTier as T, normalizeTokenSavingTier as U, resolveContextWindowPolicy as V, 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 CircuitBreakerRuntimeConfig as o, type ContextConfig as p, type ContextWindowConfigLike as q, type ContextWindowMode as r, type ContextWindowModeId as s, type ContextWindowThresholds as t, type CustomModelDefinition as u, type IndexingConfig as v, type LogConfig as w, type ModelsDevModel as x, type ModelsDevProvider as y, type PluginConfig as z };
@@ -309,6 +309,11 @@ type Permission = 'auto' | 'confirm' | 'deny';
309
309
  * - `destructive` — irreversible or broadside effects (recursive deletes, db drops, etc.)
310
310
  */
311
311
  type RiskTier = 'safe' | 'standard' | 'destructive';
312
+ /**
313
+ * Icon identifiers for tools — each UI (WebUI/TUI/REPL) maps these to its own icon library.
314
+ * Add the icon directly on each Tool so all UIs consume the same canonical value.
315
+ */
316
+ type ToolIconId = 'file' | 'edit' | 'search' | 'folder' | 'terminal' | 'web' | 'git' | 'tree' | 'code' | 'test' | 'package' | 'document' | 'scaffold' | 'todo' | 'plan' | 'task' | 'meta' | 'index' | 'json' | 'diff' | 'logs' | 'settings' | 'fallback';
312
317
  interface JSONSchema {
313
318
  type?: string | undefined;
314
319
  properties?: Record<string, JSONSchema>;
@@ -405,6 +410,12 @@ interface Tool<I = unknown, O = unknown> {
405
410
  * treated conservatively by guards.
406
411
  */
407
412
  capabilities?: readonly string[] | undefined;
413
+ /**
414
+ * Icon identifier for this tool — consumed by all UIs (WebUI/TUI/REPL) to
415
+ * render a tool-specific icon instead of a generic fallback.
416
+ * Each UI maps this id to its own icon library.
417
+ */
418
+ icon?: ToolIconId | undefined;
408
419
  execute(input: I, ctx: Context, opts: {
409
420
  signal: AbortSignal;
410
421
  }): Promise<O>;
@@ -1285,6 +1296,13 @@ interface ContextInit {
1285
1296
  projectRoot: string;
1286
1297
  /** Mutable working directory. Defaults to `cwd`. Must stay within `projectRoot`. */
1287
1298
  workingDir?: string | undefined;
1299
+ /**
1300
+ * When false, file tools and `setWorkingDir()` are confined to `projectRoot`.
1301
+ * Defaults to `false` (restrictive) when omitted so directly-constructed
1302
+ * contexts (tests, embedded callers) keep the safe behavior; the runtime
1303
+ * passes the config-derived value (default `true` — permissive) explicitly.
1304
+ */
1305
+ allowOutsideProjectRoot?: boolean | undefined;
1288
1306
  model: string;
1289
1307
  tools?: Tool[] | undefined;
1290
1308
  /** Agent id performing this run (e.g. 'leader', 'executor', 'tech-stack'). */
@@ -1299,12 +1317,6 @@ interface ContextInit {
1299
1317
  * `session.traceId` automatically.
1300
1318
  */
1301
1319
  traceId?: string | undefined;
1302
- /**
1303
- * Allow tools to read/write paths outside the project root directory.
1304
- * When true, tools can access any path on the filesystem.
1305
- * When false or undefined, tools are restricted to the project root.
1306
- */
1307
- allowOutsideProjectRoot?: boolean | undefined;
1308
1320
  }
1309
1321
  /**
1310
1322
  * L1-A: `Context` is the live agent-run object. Its read-only environment
@@ -1337,6 +1349,13 @@ declare class Context implements RunEnv {
1337
1349
  projectRoot: string;
1338
1350
  /** Mutable working directory — starts as `cwd`. Change via `setWorkingDir()`. */
1339
1351
  workingDir: string;
1352
+ /**
1353
+ * When true, file tools (via `_util.ts`) and `setWorkingDir()` reject paths
1354
+ * outside `projectRoot`. When false, those boundary checks are bypassed so
1355
+ * tools may reach paths outside the project (still gated by permission
1356
+ * tiers). Mutable so `/settings` can toggle it live on the running session.
1357
+ */
1358
+ allowOutsideProjectRoot: boolean;
1340
1359
  model: string;
1341
1360
  tools: Tool[];
1342
1361
  meta: Record<string, unknown>;
@@ -1350,11 +1369,6 @@ declare class Context implements RunEnv {
1350
1369
  * so storage operations can include it in `storage.*` events.
1351
1370
  */
1352
1371
  traceId: string | undefined;
1353
- /**
1354
- * When true, tools can access any path on the filesystem.
1355
- * When false or undefined, tools are restricted to the project root.
1356
- */
1357
- allowOutsideProjectRoot: boolean;
1358
1372
  /** Callbacks fired when `setWorkingDir()` changes the working directory. */
1359
1373
  private _onWorkingDirChanged;
1360
1374
  /**
@@ -1425,4 +1439,4 @@ declare class Context implements RunEnv {
1425
1439
  usage(): Usage;
1426
1440
  }
1427
1441
 
1428
- 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 };
1442
+ 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 ToolIconId as a1, type ToolStreamEvent as a2, WrongStackError as a3, asBlocks as a4, asText as a5, extractRunEnv as a6, isAgentError as a7, isConfigError as a8, isFsError as a9, isImageBlock as aa, isPluginError as ab, isSddError as ac, isSessionError as ad, isTextBlock as ae, isThinkingBlock as af, isToolError as ag, isToolResultBlock as ah, isToolUseBlock as ai, isWrongStackError as aj, toWrongStackError as ak, wrapAsState as al, 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 };