@wrongstack/core 0.273.0 → 0.273.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 (60) hide show
  1. package/dist/{agent-bridge-BZ2enORi.d.ts → agent-bridge-DpKIxHhE.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-ehb4xGvd.d.ts → agent-subagent-runner-Dx7fZ1bE.d.ts} +7 -7
  3. package/dist/{brain-BxN2k2HP.d.ts → brain-BDcQaku-.d.ts} +11 -5
  4. package/dist/{compactor-72ug-ZRB.d.ts → compactor-BuSdj3fq.d.ts} +1 -1
  5. package/dist/{config-C8IYxlO8.d.ts → config-CR2yoG8c.d.ts} +54 -4
  6. package/dist/{context-Dw55zZ_Q.d.ts → context-DulAr8Zo.d.ts} +24 -0
  7. package/dist/coordination/index.d.ts +23 -16
  8. package/dist/coordination/index.js +113 -13
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -26
  11. package/dist/defaults/index.js +405 -8
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +15 -15
  14. package/dist/execution/index.js +75 -1
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +6 -6
  18. package/dist/{global-mailbox-C9dsc9Y_.d.ts → global-mailbox-CwcubDkA.d.ts} +1 -1
  19. package/dist/{goal-preamble-NhflDjYb.d.ts → goal-preamble-Bu0a2uCG.d.ts} +9 -9
  20. package/dist/{goal-store-Cx363x7Z.d.ts → goal-store-CTmFuZ8J.d.ts} +1 -1
  21. package/dist/hq/index.d.ts +5 -5
  22. package/dist/{index-B7fHDt0B.d.ts → index-CTq5wU3m.d.ts} +5 -5
  23. package/dist/{index-BbVprU-9.d.ts → index-CxP-HBhX.d.ts} +2 -2
  24. package/dist/index.d.ts +63 -42
  25. package/dist/index.js +598 -56
  26. package/dist/index.js.map +1 -1
  27. package/dist/infrastructure/index.d.ts +6 -6
  28. package/dist/kernel/index.d.ts +11 -11
  29. package/dist/kernel/index.js.map +1 -1
  30. package/dist/{mcp-servers-B6fSRNC1.d.ts → mcp-servers-BQaOE71z.d.ts} +3 -3
  31. package/dist/models/index.d.ts +5 -5
  32. package/dist/{models-registry-4C6Wr91w.d.ts → models-registry-BEcny4kP.d.ts} +1 -1
  33. package/dist/{multi-agent-coordinator-q1skFeNP.d.ts → multi-agent-coordinator-Bx8EFkv2.d.ts} +1 -1
  34. package/dist/{null-fleet-bus-C9rrgQwc.d.ts → null-fleet-bus-BC5ZXCQw.d.ts} +6 -6
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{parallel-eternal-engine-CtXly2Sf.d.ts → parallel-eternal-engine-C345TI3n.d.ts} +9 -9
  37. package/dist/{path-resolver-Bim6G5Jz.d.ts → path-resolver-C-W_wzkF.d.ts} +3 -3
  38. package/dist/{permission-CC7XFYWG.d.ts → permission-CsBGZkxp.d.ts} +1 -1
  39. package/dist/{permission-policy-cYR4RJmw.d.ts → permission-policy-g3Sg0GdZ.d.ts} +2 -2
  40. package/dist/{pipeline-CNVKuQDQ.d.ts → pipeline-xnw_24Z8.d.ts} +2 -2
  41. package/dist/{plan-templates-C4wXMmiM.d.ts → plan-templates-DGaiYEcS.d.ts} +31 -5
  42. package/dist/{provider-model-resolve-DFd3IPpw.d.ts → provider-model-resolve-Cz6OlIOp.d.ts} +3 -3
  43. package/dist/{provider-runner-BpM0mdBE.d.ts → provider-runner-7J0HqF6B.d.ts} +3 -3
  44. package/dist/{retry-policy-BV7nzeAd.d.ts → retry-policy-kqXJOVkX.d.ts} +1 -1
  45. package/dist/sdd/index.d.ts +9 -9
  46. package/dist/{secret-vault-eMBKfheR.d.ts → secret-vault-CMQUr-eB.d.ts} +1 -1
  47. package/dist/security/index.d.ts +5 -5
  48. package/dist/{selector-C4ORTOid.d.ts → selector-B4r34PWR.d.ts} +1 -1
  49. package/dist/{session-event-bridge-CeNpUL9w.d.ts → session-event-bridge-BD3LoyLC.d.ts} +1 -1
  50. package/dist/{session-reader-BepLSnGL.d.ts → session-reader-DjrKGD9c.d.ts} +1 -1
  51. package/dist/storage/index.d.ts +11 -11
  52. package/dist/storage/index.js +377 -11
  53. package/dist/storage/index.js.map +1 -1
  54. package/dist/tools/index.d.ts +2 -2
  55. package/dist/types/index.d.ts +19 -19
  56. package/dist/types/index.js +28 -0
  57. package/dist/types/index.js.map +1 -1
  58. package/dist/utils/index.d.ts +2 -2
  59. package/dist/{worktree-manager-BDuXTaWL.d.ts → worktree-manager-DHdrWQ_7.d.ts} +1 -1
  60. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-ehb4xGvd.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-Dx7fZ1bE.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-B7fHDt0B.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-CNVKuQDQ.js';
3
- import { E as EventBus, a as EventName, L as Listener } from './brain-BxN2k2HP.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-BV7nzeAd.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-CTq5wU3m.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-xnw_24Z8.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-BDcQaku-.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-kqXJOVkX.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-CC7XFYWG.js';
8
- import { U as Usage, C as Context, J as JSONSchema, c as Request, d as Response, i as ContentBlock, q as TextBlock, T as Tool, P as Provider, t as RunOptions } from './context-Dw55zZ_Q.js';
9
- import { W as WireFamily, H as HookEvent, f as HookMatcher, I as InProcessHook, C as Config } from './config-C8IYxlO8.js';
7
+ import { P as PermissionPolicy } from './permission-CsBGZkxp.js';
8
+ import { U as Usage, C as Context, J as JSONSchema, c as Request, d as Response, i as ContentBlock, q as TextBlock, T as Tool, P as Provider, t as RunOptions } from './context-DulAr8Zo.js';
9
+ import { W as WireFamily, H as HookEvent, f as HookMatcher, I as InProcessHook, C as Config } from './config-CR2yoG8c.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, l as ToolProgressEvent, T as Tool, m as ToolOutputMetadata } from './context-Dw55zZ_Q.js';
1
+ import { U as Usage, C as Context, l as ToolProgressEvent, T as Tool, m as ToolOutputMetadata } from './context-DulAr8Zo.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -503,13 +503,16 @@ interface EventMap {
503
503
  };
504
504
  /**
505
505
  * Fired on every `iteration.completed`. UIs subscribe to render a live
506
- * context-window fill bar per agent (e.g. "67% ████████░░"). The
507
- * `load` fraction matches the threshold levels: 0–0.6 green, 0.6–0.75
508
- * yellow, 0.75+ red.
506
+ * context-window fill bar per agent (e.g. "67% ████████░░"). `load` is
507
+ * clamped to 0..1 so every live surface renders at most 100%; diagnostics
508
+ * can still detect over-budget states from `tokens > maxContext` or
509
+ * `rawLoad`.
509
510
  */
510
511
  'ctx.pct': {
511
- /** Fraction of maxContext currently in use (0–1+. Can exceed 1 when over budget). */
512
+ /** Fraction of maxContext currently in use, clamped to 0..1 for display. */
512
513
  load: number;
514
+ /** Unclamped fraction when available. Can exceed 1 when over budget. */
515
+ rawLoad?: number | undefined;
513
516
  /** Estimated total tokens (system + tools + messages). */
514
517
  tokens: number;
515
518
  /** Provider's max context window. */
@@ -781,7 +784,10 @@ interface EventMap {
781
784
  */
782
785
  'subagent.ctx_pct': {
783
786
  subagentId: string;
787
+ /** Fraction of maxContext currently in use, clamped to 0..1 for display. */
784
788
  load: number;
789
+ /** Unclamped fraction when available. Can exceed 1 when over budget. */
790
+ rawLoad?: number | undefined;
785
791
  tokens: number;
786
792
  maxContext: number;
787
793
  };
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-Dw55zZ_Q.js';
1
+ import { C as Context } from './context-DulAr8Zo.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -1,4 +1,4 @@
1
- import { a as ReasoningConfig, n as Capabilities, h as Permission, o as ReasoningEffort, p as CacheTtl } from './context-Dw55zZ_Q.js';
1
+ import { a as ReasoningConfig, n as Capabilities, h as Permission, o as ReasoningEffort, p as CacheTtl } from './context-DulAr8Zo.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -448,6 +448,30 @@ interface ToolsConfig {
448
448
  * `/settings` ("Filesystem access").
449
449
  */
450
450
  restrictToProjectRoot?: boolean | undefined;
451
+ /**
452
+ * Per-command policy for the `exec` tool's allowlist. The tool ships a
453
+ * curated default allowlist of dev/build commands; this extends or trims it.
454
+ *
455
+ * SECURITY: `allow` EXPANDS what the agent may execute, so it is honored only
456
+ * from TRUSTED config (`~/.wrongstack/config.json`) — the config loader
457
+ * strips `tools.exec.allow` from the untrusted, repo-committed
458
+ * `<project>/.wrongstack/config.json`. `deny` only ever REMOVES commands, so
459
+ * it is honored from any source.
460
+ */
461
+ exec?: ExecToolConfig | undefined;
462
+ }
463
+ /** Allow/deny extension of the `exec` tool's built-in command allowlist. */
464
+ interface ExecToolConfig {
465
+ /**
466
+ * Extra command names to add to the allowlist (e.g. `["make", "dotnet"]`).
467
+ * Trusted sources only — stripped from in-project repo config.
468
+ */
469
+ allow?: string[] | undefined;
470
+ /**
471
+ * Command names to remove from the allowlist. Honored from any source —
472
+ * removing a command can only narrow what runs, so it is always safe.
473
+ */
474
+ deny?: string[] | undefined;
451
475
  }
452
476
  type ToolDescriptionMode = 'extend' | 'simple';
453
477
  type ToolDescriptionModeConfig = Record<string, ToolDescriptionMode | undefined>;
@@ -640,8 +664,34 @@ interface FeaturesConfig {
640
664
  allowOutsideProjectRoot?: boolean | undefined;
641
665
  }
642
666
  interface AutonomyConfig {
667
+ /** Default autonomy mode at startup. Default: "off". */
668
+ defaultMode?: 'off' | 'suggest' | 'auto' | undefined;
643
669
  /** ms to wait before auto-proceeding in 'auto' mode. Default: 45000. */
644
670
  autoProceedDelayMs?: number | undefined;
671
+ /** Maximum consecutive auto-proceed turns before pausing. 0 = unlimited. Default: 50. */
672
+ autoProceedMaxIterations?: number | undefined;
673
+ /** Template used for YOLO+auto suggestions. Must include {{suggestion}}. */
674
+ autonomyNextPrompt?: string | undefined;
675
+ /** Animate the terminal/window title while the agent is active. Default: true. */
676
+ terminalTitleAnimation?: boolean | undefined;
677
+ /** Persisted YOLO preference mirrored into top-level config.yolo at runtime. Default: false. */
678
+ yolo?: boolean | undefined;
679
+ /** Stream fleet/subagent output into the main TUI chat. Default: true. */
680
+ streamFleet?: boolean | undefined;
681
+ /** Ring terminal bell when an agent run completes. Default: false. */
682
+ chime?: boolean | undefined;
683
+ /** Ask for confirmation before interrupt/exit. Default: true. */
684
+ confirmExit?: boolean | undefined;
685
+ /** Terminal mouse tracking preference. Default: false. */
686
+ mouseMode?: boolean | undefined;
687
+ /** Enable prompt refinement before sending. Default: true. */
688
+ enhance?: boolean | undefined;
689
+ /** Prompt-refinement preview countdown in ms. Default: 60000. */
690
+ enhanceDelayMs?: number | undefined;
691
+ /** Prompt-refinement language mode. Default: "original". */
692
+ enhanceLanguage?: 'original' | 'english' | undefined;
693
+ /** TUI statusline density. Default: "detailed". */
694
+ statuslineMode?: 'minimum' | 'detailed' | undefined;
645
695
  /** Single short word shown in the TUI rainbow working-state chip. Default: "thinking". */
646
696
  thinkingWord?: string | undefined;
647
697
  }
@@ -809,8 +859,8 @@ interface Config {
809
859
  debugStream?: boolean | undefined;
810
860
  /**
811
861
  * Where settings are persisted. 'global' → ~/.wrongstack/config.json
812
- * (default). 'project' → ~/.wrongstack/projects/<slug>/config.local.json.
813
- * When 'project', provider/model/autonomy/ux settings are saved per-project.
862
+ * (default). 'project' → <project>/.wrongstack/config.json.
863
+ * When 'project', safe settings are saved per-project.
814
864
  */
815
865
  configScope?: 'global' | 'project' | undefined;
816
866
  /** Automatic codebase symbol-index maintenance (session-start + live updates). */
@@ -903,4 +953,4 @@ interface ConfigStore {
903
953
  watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
904
954
  }
905
955
 
906
- export { formatContextWindowModeList as $, type AdaptiveConcurrencyConfig as A, type LogConfig as B, type Config as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, MAX_TUI_THINKING_WORD_LENGTH as E, type FeaturesConfig as F, type ModelRuntimeCacheConfig as G, type HookEvent as H, type InProcessHook as I, type ModelRuntimeConfig as J, type ModelRuntimeParametersConfig as K, type LaunchConfig as L, type ModelsRegistry as M, type ModelRuntimeReasoningConfig as N, type ModelsDevProvider as O, type ProviderConfig as P, type PluginConfig as Q, type ResolvedProvider as R, type ShellHook as S, type TokenSavingTier as T, type ProviderApiKey as U, type SessionLoggingConfig as V, type WireFamily as W, type SyncCategory as X, type ToolDescriptionMode as Y, type ToolDescriptionModeConfig as Z, type ToolsConfig as _, type ModelsDevPayload as a, getContextWindowMode as a0, isContextWindowModeId as a1, listContextWindowModes as a2, normalizeTokenSavingTier as a3, normalizeTuiThinkingWord as a4, resolveContextWindowPolicy as a5, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type ModelsDevModel as e, type HookMatcher as f, type HookEntry as g, type ContextWindowAggressiveOn as h, type ContextWindowPolicy as i, type ConfigStore as j, type ConfigLoader as k, type SyncConfig as l, type HookInput as m, type HookOutcome as n, type AutonomyConfig as o, CONTEXT_WINDOW_MODES as p, type CircuitBreakerRuntimeConfig as q, type ContextConfig as r, type ContextWindowConfigLike as s, type ContextWindowMode as t, type ContextWindowModeId as u, type ContextWindowThresholds as v, type CustomModelDefinition as w, DEFAULT_TUI_THINKING_WORD as x, type HqClientConfig as y, type IndexingConfig as z };
956
+ export { type ToolsConfig as $, type AdaptiveConcurrencyConfig as A, type LogConfig as B, type Config as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type ExecToolConfig as E, type FeaturesConfig as F, MAX_TUI_THINKING_WORD_LENGTH as G, type HookEvent as H, type InProcessHook as I, type ModelRuntimeCacheConfig as J, type ModelRuntimeConfig as K, type LaunchConfig as L, type ModelsRegistry as M, type ModelRuntimeParametersConfig as N, type ModelRuntimeReasoningConfig as O, type ProviderConfig as P, type ModelsDevProvider as Q, type ResolvedProvider as R, type ShellHook as S, type TokenSavingTier as T, type PluginConfig as U, type ProviderApiKey as V, type WireFamily as W, type SessionLoggingConfig as X, type SyncCategory as Y, type ToolDescriptionMode as Z, type ToolDescriptionModeConfig as _, type ModelsDevPayload as a, formatContextWindowModeList as a0, getContextWindowMode as a1, isContextWindowModeId as a2, listContextWindowModes as a3, normalizeTokenSavingTier as a4, normalizeTuiThinkingWord as a5, resolveContextWindowPolicy as a6, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type ModelsDevModel as e, type HookMatcher as f, type HookEntry as g, type ContextWindowAggressiveOn as h, type ContextWindowPolicy as i, type ConfigStore as j, type ConfigLoader as k, type SyncConfig as l, type HookInput as m, type HookOutcome as n, type AutonomyConfig as o, CONTEXT_WINDOW_MODES as p, type CircuitBreakerRuntimeConfig as q, type ContextConfig as r, type ContextWindowConfigLike as s, type ContextWindowMode as t, type ContextWindowModeId as u, type ContextWindowThresholds as v, type CustomModelDefinition as w, DEFAULT_TUI_THINKING_WORD as x, type HqClientConfig as y, type IndexingConfig as z };
@@ -1190,6 +1190,30 @@ interface SessionStore {
1190
1190
  * number of sessions indexed.
1191
1191
  */
1192
1192
  rebuildIndex?(): Promise<number>;
1193
+ /**
1194
+ * Streaming event-level search. Walks the JSONL once without buffering
1195
+ * the whole file, calling `predicate(event, eventIndex, ts)` for each
1196
+ * parsed event. Stops as soon as `limit` matches are collected (when
1197
+ * provided) and yields only the matching events back to the caller.
1198
+ *
1199
+ * Implementations that don't support streaming MUST omit this method;
1200
+ * the SessionReader fallback path will then call `load()` instead. The
1201
+ * method is intentionally non-throwing for missing files — a missing
1202
+ * session yields an empty array, matching `load()` semantics for ENOENT.
1203
+ *
1204
+ * @param id Session id (with or without the `.jsonl` suffix).
1205
+ * @param predicate Returns true to keep the event in the result set.
1206
+ * @param opts.limit Maximum number of hits to keep. Omit for unbounded.
1207
+ * @param opts.signal Optional AbortSignal for early termination.
1208
+ */
1209
+ searchEvents?(id: string, predicate: (event: SessionEvent, eventIndex: number, ts: string) => boolean, opts?: {
1210
+ limit?: number | undefined;
1211
+ signal?: AbortSignal | undefined;
1212
+ }): Promise<Array<{
1213
+ event: SessionEvent;
1214
+ eventIndex: number;
1215
+ ts: string;
1216
+ }>>;
1193
1217
  }
1194
1218
  interface SessionWriter {
1195
1219
  readonly id: string;
@@ -1,25 +1,25 @@
1
- import { E as EventBus, B as BrainArbiter, f as BrainDecisionOption, k as BrainRisk, h as BrainDecisionRequest, e as BrainDecision, i as BrainDecisionSource } from '../brain-BxN2k2HP.js';
2
- export { g as BrainDecisionQueue, j as BrainFallback, D as DefaultBrainArbiter, l as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, w as formatHumanPrompt } from '../brain-BxN2k2HP.js';
3
- import { H as FleetManager, s as Director } from '../null-fleet-bus-C9rrgQwc.js';
4
- 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, 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, 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-C9rrgQwc.js';
5
- import { b as AgentDefinition } from '../multi-agent-coordinator-q1skFeNP.js';
6
- export { T as AGENT_TOOL_PRESETS, c as AgentBudgetTier, d as AgentCapability, A 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-q1skFeNP.js';
7
- import { F as FleetBus } from '../agent-subagent-runner-ehb4xGvd.js';
8
- export { h as AgentFactory, v as AgentFactoryResult, w as AgentRunnerOptions, x as BudgetExceededError, y as BudgetKind, z as BudgetLimits, E as BudgetNegotiationMode, G as BudgetThresholdDecision, H as BudgetThresholdHandler, I as BudgetThresholdSignal, J as BudgetUsage, L as DECISION_TIMEOUT_MS, N as FleetEvent, O as FleetHandler, i as FleetUsage, j as FleetUsageAggregator, Q as SubagentBudget, Y as SubagentUsageSnapshot, Z as TIMEOUT_PREEMPT_FRACTION, $ as makeAgentSubagentRunner, a0 as withDisabledToolFiltering } from '../agent-subagent-runner-ehb4xGvd.js';
9
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BZ2enORi.js';
1
+ import { E as EventBus, B as BrainArbiter, f as BrainDecisionOption, k as BrainRisk, h as BrainDecisionRequest, e as BrainDecision, i as BrainDecisionSource } from '../brain-BDcQaku-.js';
2
+ export { g as BrainDecisionQueue, j as BrainFallback, D as DefaultBrainArbiter, l as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, w as formatHumanPrompt } from '../brain-BDcQaku-.js';
3
+ import { H as FleetManager, s as Director } from '../null-fleet-bus-BC5ZXCQw.js';
4
+ 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, 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, 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-BC5ZXCQw.js';
5
+ import { b as AgentDefinition } from '../multi-agent-coordinator-Bx8EFkv2.js';
6
+ export { T as AGENT_TOOL_PRESETS, c as AgentBudgetTier, d as AgentCapability, A 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-Bx8EFkv2.js';
7
+ import { F as FleetBus } from '../agent-subagent-runner-Dx7fZ1bE.js';
8
+ export { h as AgentFactory, v as AgentFactoryResult, w as AgentRunnerOptions, x as BudgetExceededError, y as BudgetKind, z as BudgetLimits, E as BudgetNegotiationMode, G as BudgetThresholdDecision, H as BudgetThresholdHandler, I as BudgetThresholdSignal, J as BudgetUsage, L as DECISION_TIMEOUT_MS, N as FleetEvent, O as FleetHandler, i as FleetUsage, j as FleetUsageAggregator, Q as SubagentBudget, Y as SubagentUsageSnapshot, Z as TIMEOUT_PREEMPT_FRACTION, $ as makeAgentSubagentRunner, a0 as withDisabledToolFiltering } from '../agent-subagent-runner-Dx7fZ1bE.js';
9
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DpKIxHhE.js';
10
10
  import { b as Mailbox, c as MailboxSendInput, M as MailboxMessage, d as MailboxQuery, e as MailboxAckInput, f as MailboxAckBatchInput, a as MailboxAgentStatus, A as AgentRegistrationInput, g as AgentHeartbeatInput, P as PurgeOptions, j as PurgeResult, C as ClientRegistrationInput, h as ClientHeartbeatInput, i as ClientStatus } from '../mailbox-types-Ct2hJq0P.js';
11
11
  export { k as MailboxMessageType, l as MailboxTaskContext, R as ReadReceipts, m as RegisteredAgent, n as normalizeRecipient } from '../mailbox-types-Ct2hJq0P.js';
12
- export { G as GlobalMailbox, aw as resolveProjectDir } from '../global-mailbox-C9dsc9Y_.js';
13
- import { C as Context, T as Tool } from '../context-Dw55zZ_Q.js';
14
- import { A as AdaptiveConcurrencyConfig } from '../config-C8IYxlO8.js';
12
+ export { G as GlobalMailbox, aw as resolveProjectDir } from '../global-mailbox-CwcubDkA.js';
13
+ import { C as Context, T as Tool } from '../context-DulAr8Zo.js';
14
+ import { A as AdaptiveConcurrencyConfig } from '../config-CR2yoG8c.js';
15
15
  import 'node:events';
16
16
  import '../logger-B63L5bTg.js';
17
17
  import '../director-state-BfeCUbmk.js';
18
- import '../index-B7fHDt0B.js';
19
- import '../pipeline-CNVKuQDQ.js';
18
+ import '../index-CTq5wU3m.js';
19
+ import '../pipeline-xnw_24Z8.js';
20
20
  import '../observability-D-HZN_mF.js';
21
- import '../permission-CC7XFYWG.js';
22
- import '../retry-policy-BV7nzeAd.js';
21
+ import '../permission-CsBGZkxp.js';
22
+ import '../retry-policy-kqXJOVkX.js';
23
23
 
24
24
  /** Phase 1 · Discovery — map the territory before any work begins. */
25
25
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -94,6 +94,13 @@ declare class DefaultMailbox implements Mailbox {
94
94
  private _readNewMessagesOnly;
95
95
  /** Parse a JSONL string into MailboxMessage[], including migration. */
96
96
  private _parseLines;
97
+ /**
98
+ * Stat the mailbox file under the assumption that we are holding the
99
+ * file lock, and that a write to the file has just completed. Returns
100
+ * the (mtimeMs, size) pair, or (-1, -1) if the file does not exist
101
+ * (e.g. ackMany/purgeStale on a session that has never sent a message).
102
+ */
103
+ private _statUnderLockOrAbsent;
97
104
  private _readAllCached;
98
105
  private _setMessageCache;
99
106
  private _pushToCache;
@@ -9172,6 +9172,91 @@ var DefaultSessionStore = class _DefaultSessionStore {
9172
9172
  }
9173
9173
  }
9174
9174
  }
9175
+ /**
9176
+ * Streaming search over a session's JSONL. Walks the file once, parses
9177
+ * each event lazily, and yields only the events that match `predicate`.
9178
+ * Stops as soon as `opts.limit` matches are collected.
9179
+ *
9180
+ * Why this exists: `load()` parses the entire file into memory and
9181
+ * rebuilds `messages`/`toolCallEnds` for every caller. `search()` only
9182
+ * needs to know which events contain matching text — a per-line
9183
+ * predicate is enough. The full parse work (and the `_loadCache` poll)
9184
+ * is wasted in that case.
9185
+ *
9186
+ * Memory: O(hits) regardless of file size. Disk: one linear scan,
9187
+ * terminated at `limit` if the caller asked for one.
9188
+ *
9189
+ * Errors: missing file yields []. Corrupt lines are skipped (same
9190
+ * policy as `load()`). Aborting via `signal` rejects with `AbortError`.
9191
+ */
9192
+ async searchEvents(id, predicate, opts) {
9193
+ const file = this.sessionPath(id, ".jsonl");
9194
+ const limit = opts?.limit;
9195
+ const signal = opts?.signal;
9196
+ const out = [];
9197
+ let stat7;
9198
+ try {
9199
+ stat7 = await fsp6.stat(file);
9200
+ } catch (err) {
9201
+ if (err.code === "ENOENT") return [];
9202
+ throw err;
9203
+ }
9204
+ if (stat7.size === 0) return [];
9205
+ let fh;
9206
+ try {
9207
+ fh = await fsp6.open(file, "r");
9208
+ const CHUNK = 64 * 1024;
9209
+ const buf = Buffer.alloc(CHUNK);
9210
+ let leftover = "";
9211
+ let eventIndex = 0;
9212
+ for (let position = 0; ; position += buf.byteLength) {
9213
+ if (signal?.aborted) {
9214
+ const reason = signal.reason ?? new DOMException("Aborted", "AbortError");
9215
+ throw reason;
9216
+ }
9217
+ const { bytesRead } = await fh.read(buf, 0, CHUNK, position);
9218
+ if (bytesRead === 0) break;
9219
+ const text = leftover + buf.subarray(0, bytesRead).toString("utf8");
9220
+ const parts = text.split("\n");
9221
+ leftover = parts.pop() ?? "";
9222
+ for (const line of parts) {
9223
+ if (!line) continue;
9224
+ let ev;
9225
+ try {
9226
+ const parsed = JSON.parse(line);
9227
+ if (parsed === null || typeof parsed !== "object" || typeof parsed.type !== "string" || typeof parsed.ts !== "string") {
9228
+ continue;
9229
+ }
9230
+ ev = parsed;
9231
+ } catch {
9232
+ continue;
9233
+ }
9234
+ if (predicate(ev, eventIndex, ev.ts)) {
9235
+ out.push({ event: ev, eventIndex, ts: ev.ts });
9236
+ if (limit !== void 0 && out.length >= limit) {
9237
+ return out;
9238
+ }
9239
+ }
9240
+ eventIndex++;
9241
+ }
9242
+ }
9243
+ if (leftover.trim()) {
9244
+ try {
9245
+ const parsed = JSON.parse(leftover);
9246
+ if (parsed !== null && typeof parsed === "object" && typeof parsed.type === "string" && typeof parsed.ts === "string") {
9247
+ const ev = parsed;
9248
+ if (predicate(ev, eventIndex, ev.ts)) {
9249
+ out.push({ event: ev, eventIndex, ts: ev.ts });
9250
+ }
9251
+ }
9252
+ } catch {
9253
+ }
9254
+ }
9255
+ return out;
9256
+ } finally {
9257
+ if (fh) await fh.close().catch(() => void 0);
9258
+ }
9259
+ }
9175
9260
  async list(limit = 20) {
9176
9261
  try {
9177
9262
  await ensureDir(this.dir);
@@ -10832,6 +10917,9 @@ var DefaultMailbox = class {
10832
10917
  await withFileLock(this.filePath, async () => {
10833
10918
  await fsp6.appendFile(this.filePath, line, "utf8");
10834
10919
  this._pushToCache(msg);
10920
+ const { mtime, size } = await this._statUnderLockOrAbsent();
10921
+ this._messageCacheMtime = mtime;
10922
+ this._messageCacheSize = size;
10835
10923
  });
10836
10924
  return msg;
10837
10925
  }
@@ -10910,7 +10998,8 @@ var DefaultMailbox = class {
10910
10998
  const serialized = all.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
10911
10999
  await fsp6.writeFile(this.filePath, serialized, "utf8");
10912
11000
  }
10913
- this._setMessageCache(all);
11001
+ const { mtime, size } = await this._statUnderLockOrAbsent();
11002
+ this._setMessageCache(all, mtime, size);
10914
11003
  });
10915
11004
  return updated;
10916
11005
  }
@@ -10967,7 +11056,8 @@ var DefaultMailbox = class {
10967
11056
  async clearAll() {
10968
11057
  await withFileLock(this.filePath, async () => {
10969
11058
  await fsp6.writeFile(this.filePath, "", "utf8");
10970
- this._setMessageCache([]);
11059
+ const { mtime, size } = await this._statUnderLockOrAbsent();
11060
+ this._setMessageCache([], mtime, size);
10971
11061
  });
10972
11062
  }
10973
11063
  async purgeStale(opts) {
@@ -11000,7 +11090,8 @@ var DefaultMailbox = class {
11000
11090
  const content = kept.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
11001
11091
  await fsp6.writeFile(this.filePath, content, "utf8");
11002
11092
  }
11003
- this._setMessageCache(kept);
11093
+ const { mtime, size } = await this._statUnderLockOrAbsent();
11094
+ this._setMessageCache(kept, mtime, size);
11004
11095
  });
11005
11096
  return {
11006
11097
  completedPurged,
@@ -11079,6 +11170,23 @@ var DefaultMailbox = class {
11079
11170
  }
11080
11171
  return messages;
11081
11172
  }
11173
+ /**
11174
+ * Stat the mailbox file under the assumption that we are holding the
11175
+ * file lock, and that a write to the file has just completed. Returns
11176
+ * the (mtimeMs, size) pair, or (-1, -1) if the file does not exist
11177
+ * (e.g. ackMany/purgeStale on a session that has never sent a message).
11178
+ */
11179
+ async _statUnderLockOrAbsent() {
11180
+ try {
11181
+ const st = await fsp6.stat(this.filePath);
11182
+ return { mtime: st.mtimeMs, size: st.size };
11183
+ } catch (err) {
11184
+ if (err.code === "ENOENT") {
11185
+ return { mtime: -1, size: -1 };
11186
+ }
11187
+ throw err;
11188
+ }
11189
+ }
11082
11190
  async _readAllCached() {
11083
11191
  try {
11084
11192
  const st = await fsp6.stat(this.filePath);
@@ -11118,16 +11226,8 @@ var DefaultMailbox = class {
11118
11226
  }
11119
11227
  this._messageCache = messages;
11120
11228
  this._buildIndexes(messages);
11121
- if (mtime !== void 0 && size !== void 0) {
11122
- this._messageCacheMtime = mtime;
11123
- this._messageCacheSize = size;
11124
- return;
11125
- }
11126
- void fsp6.stat(this.filePath).then((st) => {
11127
- this._messageCacheMtime = st.mtimeMs;
11128
- this._messageCacheSize = st.size;
11129
- }).catch(() => {
11130
- });
11229
+ this._messageCacheMtime = mtime;
11230
+ this._messageCacheSize = size;
11131
11231
  }
11132
11232
  _pushToCache(msg) {
11133
11233
  if (this._messageCache === null) return;