@wrongstack/core 0.250.0 → 0.256.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 (104) hide show
  1. package/dist/{agent-bridge-4gc0vfW2.d.ts → agent-bridge-BrxWHEOm.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-Dz-9kiE6.d.ts → agent-subagent-runner-US741uBH.d.ts} +17 -8
  3. package/dist/{brain-sCZ3lCjq.d.ts → brain-TjEEwSpw.d.ts} +18 -1
  4. package/dist/{compactor-BRfg3QPd.d.ts → compactor-C5sT4U7I.d.ts} +1 -1
  5. package/dist/{config-eSsrto5d.d.ts → config-DuAu23zm.d.ts} +16 -1
  6. package/dist/{context-CLz3z_E8.d.ts → context-CGdgA0q6.d.ts} +13 -0
  7. package/dist/coordination/index.d.ts +14 -14
  8. package/dist/coordination/index.js +153 -2
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +25 -25
  11. package/dist/defaults/index.js +238 -42
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +15 -15
  14. package/dist/execution/index.js +121 -22
  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/{goal-preamble-BjJpnLW4.d.ts → goal-preamble-UiEkbNmW.d.ts} +21 -10
  19. package/dist/{index-Dy8OwfBD.d.ts → index-CC0Mcm05.d.ts} +9 -9
  20. package/dist/{index-IehiNryU.d.ts → index-CitPrI3a.d.ts} +20 -7
  21. package/dist/index.d.ts +112 -42
  22. package/dist/index.js +759 -114
  23. package/dist/index.js.map +1 -1
  24. package/dist/infrastructure/index.d.ts +6 -6
  25. package/dist/infrastructure/index.js +12 -0
  26. package/dist/infrastructure/index.js.map +1 -1
  27. package/dist/kernel/index.d.ts +10 -10
  28. package/dist/kernel/index.js.map +1 -1
  29. package/dist/{llm-selector-D22R4AFz.d.ts → llm-selector-CJ4SyAFE.d.ts} +2 -2
  30. package/dist/{mcp-servers-DfXxCASH.d.ts → mcp-servers-D8YnLaEp.d.ts} +3 -3
  31. package/dist/models/index.d.ts +5 -5
  32. package/dist/{models-registry-DpanBg8D.d.ts → models-registry-ByZCdFuQ.d.ts} +1 -1
  33. package/dist/{multi-agent-coordinator-CnbEqpv0.d.ts → multi-agent-coordinator-DqTUEAeC.d.ts} +1 -1
  34. package/dist/{null-fleet-bus-Do1OLYpj.d.ts → null-fleet-bus-B5mfTJXT.d.ts} +17 -6
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{package-outdated-watcher-CA5GGB4C.d.ts → package-outdated-watcher-BSgR_kK-.d.ts} +24 -3
  37. package/dist/{parallel-eternal-engine-UZg1xOzE.d.ts → parallel-eternal-engine-C0juOszP.d.ts} +24 -10
  38. package/dist/{path-resolver-BaP06Owy.d.ts → path-resolver-CbkT-RMU.d.ts} +3 -3
  39. package/dist/{permission-DbWPbuoA.d.ts → permission-CwBBpCoF.d.ts} +1 -1
  40. package/dist/{permission-policy-AOk0LVsV.d.ts → permission-policy-B8rSu908.d.ts} +39 -2
  41. package/dist/{pipeline-D1n-gQI-.d.ts → pipeline-JG8XoudC.d.ts} +43 -3
  42. package/dist/{plan-templates-BUVRY0pU.d.ts → plan-templates-DPiQMkBz.d.ts} +5 -5
  43. package/dist/{provider-runner-D0HgUqwV.d.ts → provider-runner-hM7EXlLI.d.ts} +3 -3
  44. package/dist/{retry-policy-BVnkbMET.d.ts → retry-policy-Tg7LXkoK.d.ts} +1 -1
  45. package/dist/sdd/index.d.ts +8 -8
  46. package/dist/{secret-vault-CeVNiy_f.d.ts → secret-vault-BkYkJWQs.d.ts} +1 -1
  47. package/dist/security/index.d.ts +4 -4
  48. package/dist/security/index.js +89 -18
  49. package/dist/security/index.js.map +1 -1
  50. package/dist/{selector-Cb4_9-hf.d.ts → selector-DWsqVjGf.d.ts} +1 -1
  51. package/dist/{session-event-bridge-BhtkkFFy.d.ts → session-event-bridge-BAFWdgQ3.d.ts} +1 -1
  52. package/dist/{session-reader-CCOssnBS.d.ts → session-reader-CqRvaL5v.d.ts} +1 -1
  53. package/dist/{skill-Bj6Ezqb8.d.ts → skill-DGIXCtdv.d.ts} +6 -0
  54. package/dist/skills/index.d.ts +1 -1
  55. package/dist/storage/index.d.ts +10 -10
  56. package/dist/storage/index.js +8 -1
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/types/index.d.ts +19 -19
  59. package/dist/types/index.js +95 -25
  60. package/dist/types/index.js.map +1 -1
  61. package/dist/utils/index.d.ts +2 -2
  62. package/dist/utils/index.js +5 -0
  63. package/dist/utils/index.js.map +1 -1
  64. package/package.json +2 -2
  65. package/skills/api-design/SKILL.md +1 -0
  66. package/skills/api-design/SKILL.save.md +26 -0
  67. package/skills/audit-log/SKILL.md +9 -2
  68. package/skills/audit-log/SKILL.save.md +22 -0
  69. package/skills/bug-hunter/SKILL.md +10 -2
  70. package/skills/bug-hunter/SKILL.save.md +33 -0
  71. package/skills/chimera/SKILL.md +12 -18
  72. package/skills/chimera/SKILL.save.md +26 -0
  73. package/skills/docker-deploy/SKILL.md +1 -0
  74. package/skills/docker-deploy/SKILL.save.md +23 -0
  75. package/skills/git-flow/SKILL.md +23 -2
  76. package/skills/git-flow/SKILL.save.md +25 -0
  77. package/skills/multi-agent/SKILL.md +23 -2
  78. package/skills/multi-agent/SKILL.save.md +26 -0
  79. package/skills/node-modern/SKILL.md +2 -1
  80. package/skills/node-modern/SKILL.save.md +21 -0
  81. package/skills/observability/SKILL.md +1 -0
  82. package/skills/observability/SKILL.save.md +34 -0
  83. package/skills/output-standards/SKILL.md +133 -0
  84. package/skills/output-standards/SKILL.save.md +21 -0
  85. package/skills/prompt-engineering/SKILL.md +2 -1
  86. package/skills/prompt-engineering/SKILL.save.md +29 -0
  87. package/skills/react-modern/SKILL.md +2 -1
  88. package/skills/react-modern/SKILL.save.md +24 -0
  89. package/skills/refactor-planner/SKILL.md +9 -2
  90. package/skills/refactor-planner/SKILL.save.md +26 -0
  91. package/skills/research-web/SKILL.md +1 -0
  92. package/skills/research-web/SKILL.save.md +25 -0
  93. package/skills/sdd/SKILL.md +2 -1
  94. package/skills/sdd/SKILL.save.md +19 -0
  95. package/skills/security-scanner/SKILL.md +10 -3
  96. package/skills/security-scanner/SKILL.save.md +23 -0
  97. package/skills/skill-creator/SKILL.md +2 -1
  98. package/skills/skill-creator/SKILL.save.md +20 -0
  99. package/skills/tech-stack/SKILL.md +13 -226
  100. package/skills/tech-stack/SKILL.save.md +25 -0
  101. package/skills/testing/SKILL.md +1 -0
  102. package/skills/testing/SKILL.save.md +22 -0
  103. package/skills/typescript-strict/SKILL.md +2 -1
  104. package/skills/typescript-strict/SKILL.save.md +19 -0
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-Dz-9kiE6.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-US741uBH.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-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';
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-CitPrI3a.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-JG8XoudC.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-TjEEwSpw.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-Tg7LXkoK.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-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';
7
+ import { P as PermissionPolicy } from './permission-CwBBpCoF.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-CGdgA0q6.js';
9
+ import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-DuAu23zm.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -900,6 +900,15 @@ interface PluginCapabilities {
900
900
  slashCommands?: boolean | undefined;
901
901
  /** Will start MCP servers via `api.mcp.start()`. */
902
902
  mcp?: boolean | undefined;
903
+ /**
904
+ * Capabilities required to mutate (wrap, unregister, override) tools
905
+ * the plugin does not own. If empty or omitted, the plugin may only
906
+ * mutate its own tools. Official plugins bypass this check.
907
+ *
908
+ * Example: `['fs.read', 'net.outbound']` allows the plugin to wrap
909
+ * read-only tools, but not `fs.write` or `shell.arbitrary` tools.
910
+ */
911
+ toolMutateCapabilities?: string[] | undefined;
903
912
  }
904
913
  /**
905
914
  * Structured dependency declaration. The string form (`dependsOn: ['foo']`)
@@ -1053,4 +1062,4 @@ interface AgentRunnerOptions {
1053
1062
  */
1054
1063
  declare function makeAgentSubagentRunner(opts: AgentRunnerOptions): SubagentRunner;
1055
1064
 
1056
- export { type AgentBridge as A, type BridgeTransport as B, type CoordinatorStatus as C, type DoneCondition as D, type PluginPipelines as E, FleetBus as F, type ToolRegistryView as G, type ProviderRegistryView as H, type MCPRegistryView as I, type SlashCommandRegistryView as J, type SessionWriterView as K, type MetricsSinkView as L, type MultiAgentCoordinator as M, type Plugin as N, type CoordinatorEvents as O, type PluginAPI as P, type PluginCapabilities as Q, type PluginDependency as R, type SubagentConfig as S, type TaskSpec as T, type SubagentContext as U, type SubagentError as V, type SubagentErrorKind as W, type SubagentRunContext as X, type SubagentRunOutcome as Y, type TaskDelegation as Z, type ProviderFactory 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 AgentFactoryResult as i, type AgentRunnerOptions as j, BudgetExceededError as k, type BudgetKind as l, type BudgetLimits as m, type BudgetNegotiationMode as n, type BudgetThresholdDecision as o, type BudgetThresholdHandler as p, BudgetThresholdSignal as q, type BudgetUsage as r, type FleetEvent as s, type FleetHandler as t, type FleetUsage as u, FleetUsageAggregator as v, SubagentBudget as w, type SubagentUsageSnapshot as x, makeAgentSubagentRunner as y, type SlashCommand as z };
1065
+ export { type AgentBridge as A, type BridgeTransport as B, type CoordinatorStatus as C, type DoneCondition as D, type PluginPipelines as E, FleetBus as F, type ToolRegistryView as G, type ProviderRegistryView as H, type MCPRegistryView as I, type SlashCommandRegistryView as J, type SessionWriterView as K, type MetricsSinkView as L, type MultiAgentCoordinator as M, type PluginCapabilities as N, type Plugin as O, type PluginAPI as P, type CoordinatorEvents as Q, type PluginDependency as R, type SubagentConfig as S, type TaskSpec as T, type SubagentContext as U, type SubagentError as V, type SubagentErrorKind as W, type SubagentRunContext as X, type SubagentRunOutcome as Y, type TaskDelegation as Z, type ProviderFactory 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 AgentFactoryResult as i, type AgentRunnerOptions as j, BudgetExceededError as k, type BudgetKind as l, type BudgetLimits as m, type BudgetNegotiationMode as n, type BudgetThresholdDecision as o, type BudgetThresholdHandler as p, BudgetThresholdSignal as q, type BudgetUsage as r, type FleetEvent as s, type FleetHandler as t, type FleetUsage as u, FleetUsageAggregator as v, SubagentBudget as w, type SubagentUsageSnapshot as x, makeAgentSubagentRunner as y, type SlashCommand as z };
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-CLz3z_E8.js';
1
+ import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-CGdgA0q6.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -374,6 +374,23 @@ interface EventMap {
374
374
  used: number;
375
375
  limit: number;
376
376
  };
377
+ /**
378
+ * Fired by `DefaultTokenCounter` after each call to `account()` /
379
+ * `accountWithModel()` updates its internal state. The payload carries
380
+ * the live snapshot so subscribers (notably the TUI's `StatusBar`) can
381
+ * re-render fresh token/cost/cache data immediately instead of waiting
382
+ * for a slow polling interval. Cost fields may be zero when the model
383
+ * is unknown to the ModelsRegistry — that is already signalled separately
384
+ * by `token.cost_estimate_unavailable`.
385
+ */
386
+ 'token.accounted': {
387
+ usage: Usage;
388
+ cost: {
389
+ input: number;
390
+ output: number;
391
+ total: number;
392
+ };
393
+ };
377
394
  /**
378
395
  * Fired when the subagent budget hits a soft limit and the coordinator
379
396
  * is being asked for an extension. The coordinator should call `extend()`
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-CLz3z_E8.js';
1
+ import { C as Context } from './context-CGdgA0q6.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-CLz3z_E8.js';
1
+ import { k as Capabilities, f as Permission } from './context-CGdgA0q6.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -374,6 +374,14 @@ interface FeaturesConfig {
374
374
  modelsRegistry: boolean;
375
375
  /** Discover + load skills from disk. */
376
376
  skills: boolean;
377
+ /**
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.
383
+ */
384
+ tokenSavingMode?: boolean | undefined;
377
385
  }
378
386
  interface AutonomyConfig {
379
387
  /** ms to wait before auto-proceeding in 'auto' mode. Default: 45000. */
@@ -514,6 +522,13 @@ interface Config {
514
522
  * re-tried first at the start of every user turn. See `createFallbackModelExtension`.
515
523
  */
516
524
  fallbackModels?: string[] | undefined;
525
+ /**
526
+ * When `true` (the default) and `fallbackModels` is empty, a fallback chain
527
+ * is derived automatically from the other keyed providers/models so 429s
528
+ * recover out of the box. Set `false` to disable the smart default and only
529
+ * use an explicit `fallbackModels` list. Toggle via `/fallback auto on|off`.
530
+ */
531
+ fallbackAuto?: boolean | undefined;
517
532
  /**
518
533
  * Lifecycle shell hooks, keyed by event. Each command receives the hook
519
534
  * `HookInput` JSON on stdin; a JSON `HookOutcome` on stdout (and exit code 2
@@ -1331,6 +1331,19 @@ declare class Context implements RunEnv {
1331
1331
  * on iterations where no tool content was added (pure text responses).
1332
1332
  */
1333
1333
  toolAdjacencyDirty: boolean;
1334
+ /**
1335
+ * H1: pre-computed total-request token estimate from the most recent
1336
+ * `estimateRequestTokens()` call in the agent loop's pre-flight step.
1337
+ * The middleware that decides when to compact, the `emitContextPct`
1338
+ * helper that drives the live context-fill bar, and the pre-flight
1339
+ * itself all need this number; previously each one walked the same
1340
+ * messages/system/tools arrays independently. Stashing it here lets
1341
+ * the three call sites share a single compute per iteration.
1342
+ *
1343
+ * The value is the **uncalibrated** total. Callers that want the
1344
+ * calibrated number apply the per-(provider,model) ratio themselves.
1345
+ */
1346
+ lastRequestTokens: number | undefined;
1334
1347
  constructor(init: ContextInit);
1335
1348
  /**
1336
1349
  * Observable wrapper over the mutable conversation state. Lazy so
@@ -1,21 +1,21 @@
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';
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-TjEEwSpw.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-B5mfTJXT.js';
3
+ import { A as AgentDefinition } from '../multi-agent-coordinator-DqTUEAeC.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-DqTUEAeC.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-US741uBH.js';
6
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BrxWHEOm.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-BSgR_kK-.js';
8
+ import { b as Mailbox } from '../pipeline-JG8XoudC.js';
9
+ export { h as AgentHeartbeatInput, A as AgentRegistrationInput, f as MailboxAckInput, g as MailboxAgentStatus, d as MailboxMessage, l as MailboxMessageType, e as MailboxQuery, c as MailboxSendInput, m as MailboxTaskContext, n as ReadReceipts, o as RegisteredAgent, p as normalizeRecipient } from '../pipeline-JG8XoudC.js';
10
+ import '../context-CGdgA0q6.js';
11
11
  import 'node:events';
12
12
  import '../director-state-BfeCUbmk.js';
13
- import '../config-eSsrto5d.js';
14
- import '../index-IehiNryU.js';
13
+ import '../config-DuAu23zm.js';
14
+ import '../index-CitPrI3a.js';
15
15
  import '../logger-B63L5bTg.js';
16
16
  import '../observability-D-HZN_mF.js';
17
- import '../permission-DbWPbuoA.js';
18
- import '../retry-policy-BVnkbMET.js';
17
+ import '../permission-CwBBpCoF.js';
18
+ import '../retry-policy-Tg7LXkoK.js';
19
19
 
20
20
  /** Phase 1 · Discovery — map the territory before any work begins. */
21
21
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -6701,6 +6701,17 @@ var Director = class _Director {
6701
6701
  * default cap.
6702
6702
  */
6703
6703
  taskCompletedListener = null;
6704
+ /**
6705
+ * Unsub handles for the two `FleetBus.filter()` calls installed in the
6706
+ * constructor for timeout-heartbeat tracking. Without capturing these
6707
+ * and calling them in `shutdown()`, repeated Director construction
6708
+ * (tests, hot reloads, `--director` restarts) accumulates 2 dangling
6709
+ * listeners per Director on the FleetBus, slowly drifting the
6710
+ * EventEmitter past its default cap. Mirrors the rationale on
6711
+ * `taskCompletedListener` above.
6712
+ */
6713
+ toolExecFilter = null;
6714
+ budgetFilter = null;
6704
6715
  /** Optional LLM classifier for smart dispatch. Passed from options. */
6705
6716
  dispatchClassifier;
6706
6717
  /** Leader agent's current context pressure (full request tokens). */
@@ -6838,10 +6849,10 @@ var Director = class _Director {
6838
6849
  const extendCounts = /* @__PURE__ */ new Map();
6839
6850
  const progressBySubagent = /* @__PURE__ */ new Map();
6840
6851
  const lastTimeoutProgress = /* @__PURE__ */ new Map();
6841
- this.fleet.filter("tool.executed", (e) => {
6852
+ this.toolExecFilter = this.fleet.filter("tool.executed", (e) => {
6842
6853
  progressBySubagent.set(e.subagentId, (progressBySubagent.get(e.subagentId) ?? 0) + 1);
6843
6854
  });
6844
- this.fleet.filter("budget.threshold_reached", (e) => {
6855
+ this.budgetFilter = this.fleet.filter("budget.threshold_reached", (e) => {
6845
6856
  const payload = e.payload;
6846
6857
  if (e.subagentId.startsWith("bug-hunter-") || e.subagentId.startsWith("refactor-planner-") || e.subagentId.startsWith("critic-")) {
6847
6858
  return;
@@ -7372,6 +7383,14 @@ var Director = class _Director {
7372
7383
  this.coordinator.off("task.completed", this.taskCompletedListener);
7373
7384
  this.taskCompletedListener = null;
7374
7385
  }
7386
+ if (this.toolExecFilter) {
7387
+ this.toolExecFilter();
7388
+ this.toolExecFilter = null;
7389
+ }
7390
+ if (this.budgetFilter) {
7391
+ this.budgetFilter();
7392
+ this.budgetFilter = null;
7393
+ }
7375
7394
  await this.coordinator.stopAll();
7376
7395
  for (const b of this.subagentBridges.values()) {
7377
7396
  await b.stop().catch((err) => this.logShutdownError("subagent_bridge_stop", err));
@@ -10041,6 +10060,14 @@ var DefaultMailbox = class {
10041
10060
  await fsp6.writeFile(this.filePath, "", "utf8");
10042
10061
  });
10043
10062
  }
10063
+ // ── Client registry stubs (not applicable per-session) ─────────────────
10064
+ async registerClient(_input) {
10065
+ }
10066
+ async clientHeartbeat(_input) {
10067
+ }
10068
+ async getClientStatuses() {
10069
+ return [];
10070
+ }
10044
10071
  // ── Internal ──────────────────────────────────────────────────────────
10045
10072
  async _readAll() {
10046
10073
  try {
@@ -10217,7 +10244,9 @@ function wstackGlobalRoot() {
10217
10244
 
10218
10245
  // src/coordination/global-mailbox.ts
10219
10246
  var MAILBOX_FILE2 = "_mailbox.jsonl";
10247
+ var CLIENT_REGISTRY_FILE = "_mailbox.clients.json";
10220
10248
  var AGENT_STALE_MS = 6e4;
10249
+ var CLIENT_STALE_MS = 6e4;
10221
10250
  var HEARTBEAT_THROTTLE_MS = 5e3;
10222
10251
  var REGISTRY_CACHE_TTL_MS = 2e3;
10223
10252
  var LINE_SEPARATOR2 = "\n";
@@ -10229,6 +10258,8 @@ var GlobalMailbox = class {
10229
10258
  messagePath;
10230
10259
  /** Path to the JSON agent registry file. */
10231
10260
  registryPath;
10261
+ /** Path to the JSON client registry file. */
10262
+ clientRegistryPath;
10232
10263
  /** Optional event bus for emitting agent registration/heartbeat events. */
10233
10264
  _events;
10234
10265
  /**
@@ -10240,8 +10271,17 @@ var GlobalMailbox = class {
10240
10271
  _registryCache = null;
10241
10272
  /** When the registry cache was last refreshed from disk (epoch ms). */
10242
10273
  _registryCacheAt = 0;
10274
+ /**
10275
+ * Local cache of the client registry to avoid re-reading on every call.
10276
+ * Same reasoning as agent registry cache.
10277
+ */
10278
+ _clientRegistryCache = null;
10279
+ /** When the client registry cache was last refreshed from disk (epoch ms). */
10280
+ _clientRegistryCacheAt = 0;
10243
10281
  /** Last time each local agent sent a heartbeat (throttle). */
10244
10282
  _lastHeartbeat = /* @__PURE__ */ new Map();
10283
+ /** Last time each local client sent a heartbeat (throttle). */
10284
+ _lastClientHeartbeat = /* @__PURE__ */ new Map();
10245
10285
  /**
10246
10286
  * @param projectDir — `~/.wrongstack/projects/<slug>/`
10247
10287
  * @param events — optional EventBus for real-time TUI/WebUI notifications
@@ -10249,6 +10289,7 @@ var GlobalMailbox = class {
10249
10289
  constructor(projectDir, events) {
10250
10290
  this.messagePath = path4.join(projectDir, MAILBOX_FILE2);
10251
10291
  this.registryPath = path4.join(projectDir, "_mailbox.registry.json");
10292
+ this.clientRegistryPath = path4.join(projectDir, CLIENT_REGISTRY_FILE);
10252
10293
  this._events = events;
10253
10294
  }
10254
10295
  // ── Messages ────────────────────────────────────────────────────────────
@@ -10430,9 +10471,74 @@ var GlobalMailbox = class {
10430
10471
  const all = await this.getAgentStatuses();
10431
10472
  return all.filter((a) => a.online);
10432
10473
  }
10474
+ // ── Client registry ─────────────────────────────────────────────────────
10475
+ async registerClient(input) {
10476
+ await this._ensureClientRegistry();
10477
+ const now = (/* @__PURE__ */ new Date()).toISOString();
10478
+ const client = {
10479
+ clientId: input.clientId,
10480
+ sessionId: input.sessionId,
10481
+ name: input.name,
10482
+ source: input.source,
10483
+ registeredAt: now,
10484
+ lastSeenAt: now,
10485
+ pid: input.pid
10486
+ };
10487
+ await withFileLock(this.clientRegistryPath, async () => {
10488
+ const registry = await this._readClientRegistry({ fresh: true });
10489
+ this._pruneStaleClientsInPlace(registry);
10490
+ registry.set(input.clientId, client);
10491
+ this._clientRegistryCache = registry;
10492
+ this._clientRegistryCacheAt = Date.now();
10493
+ await this._writeClientRegistry(registry);
10494
+ });
10495
+ this._events?.emitCustom("mailbox.client_registered", {
10496
+ clientId: input.clientId,
10497
+ sessionId: input.sessionId,
10498
+ name: input.name,
10499
+ source: input.source
10500
+ });
10501
+ }
10502
+ async clientHeartbeat(input) {
10503
+ const last = this._lastClientHeartbeat.get(input.clientId) ?? 0;
10504
+ const now = Date.now();
10505
+ if (now - last < HEARTBEAT_THROTTLE_MS) return;
10506
+ this._lastClientHeartbeat.set(input.clientId, now);
10507
+ await this._ensureClientRegistry();
10508
+ await withFileLock(this.clientRegistryPath, async () => {
10509
+ const registry = await this._readClientRegistry({ fresh: true });
10510
+ this._pruneStaleClientsInPlace(registry);
10511
+ const client = registry.get(input.clientId);
10512
+ if (client) {
10513
+ client.lastSeenAt = (/* @__PURE__ */ new Date()).toISOString();
10514
+ }
10515
+ this._clientRegistryCache = registry;
10516
+ this._clientRegistryCacheAt = Date.now();
10517
+ await this._writeClientRegistry(registry);
10518
+ });
10519
+ this._events?.emitCustom("mailbox.client_heartbeat", {
10520
+ clientId: input.clientId
10521
+ });
10522
+ }
10523
+ async getClientStatuses() {
10524
+ await this._ensureClientRegistry();
10525
+ const registry = await this._readClientRegistry();
10526
+ this._pruneStaleClientsInPlace(registry);
10527
+ const now = Date.now();
10528
+ return Array.from(registry.values()).map((c) => ({
10529
+ clientId: c.clientId,
10530
+ name: c.name,
10531
+ source: c.source,
10532
+ sessionId: c.sessionId,
10533
+ lastSeenAt: c.lastSeenAt,
10534
+ online: now - new Date(c.lastSeenAt).getTime() < CLIENT_STALE_MS,
10535
+ pid: c.pid
10536
+ })).sort((a, b) => b.lastSeenAt.localeCompare(a.lastSeenAt));
10537
+ }
10433
10538
  // ── Lifecycle ───────────────────────────────────────────────────────────
10434
10539
  async close() {
10435
10540
  this._registryCache = null;
10541
+ this._clientRegistryCache = null;
10436
10542
  }
10437
10543
  async clearAll() {
10438
10544
  await withFileLock(this.messagePath, async () => {
@@ -10511,6 +10617,51 @@ var GlobalMailbox = class {
10511
10617
  await fsp6.writeFile(tmp, JSON.stringify(obj, null, 2), "utf8");
10512
10618
  await fsp6.rename(tmp, this.registryPath);
10513
10619
  }
10620
+ // ── Client registry internals ───────────────────────────────────────────
10621
+ async _ensureClientRegistry() {
10622
+ await fsp6.mkdir(path4.dirname(this.clientRegistryPath), { recursive: true });
10623
+ }
10624
+ async _readClientRegistry(opts) {
10625
+ if (!opts?.fresh && this._clientRegistryCache && Date.now() - this._clientRegistryCacheAt < REGISTRY_CACHE_TTL_MS) {
10626
+ return new Map(this._clientRegistryCache);
10627
+ }
10628
+ try {
10629
+ const raw = await fsp6.readFile(this.clientRegistryPath, "utf8");
10630
+ const data = JSON.parse(raw);
10631
+ const map = /* @__PURE__ */ new Map();
10632
+ for (const [id, client] of Object.entries(data)) {
10633
+ map.set(id, client);
10634
+ }
10635
+ this._clientRegistryCache = map;
10636
+ this._clientRegistryCacheAt = Date.now();
10637
+ return new Map(map);
10638
+ } catch (err) {
10639
+ if (err.code === "ENOENT") {
10640
+ const empty = /* @__PURE__ */ new Map();
10641
+ this._clientRegistryCache = empty;
10642
+ this._clientRegistryCacheAt = Date.now();
10643
+ return empty;
10644
+ }
10645
+ throw err;
10646
+ }
10647
+ }
10648
+ _pruneStaleClientsInPlace(registry) {
10649
+ const cutoff = Date.now() - CLIENT_STALE_MS;
10650
+ for (const client of registry.values()) {
10651
+ if (new Date(client.lastSeenAt).getTime() < cutoff) {
10652
+ client.lastSeenAt = new Date(cutoff).toISOString();
10653
+ }
10654
+ }
10655
+ }
10656
+ async _writeClientRegistry(registry) {
10657
+ const obj = {};
10658
+ for (const [id, client] of registry) {
10659
+ obj[id] = client;
10660
+ }
10661
+ const tmp = `${this.clientRegistryPath}.${randomUUID().slice(0, 8)}.tmp`;
10662
+ await fsp6.writeFile(tmp, JSON.stringify(obj, null, 2), "utf8");
10663
+ await fsp6.rename(tmp, this.clientRegistryPath);
10664
+ }
10514
10665
  };
10515
10666
  function defaultResolveProjectDir(ctx) {
10516
10667
  return resolveProjectDir(ctx.projectRoot, wstackGlobalRoot());