@wrongstack/cli 1.1.1 → 1.1.4

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 (42) hide show
  1. package/dist/{acp-HCGUTFNE.js → acp-MZ5MQBFN.js} +13 -5
  2. package/dist/acp-leader/acp-leader-confirm.d.ts +18 -0
  3. package/dist/acp-leader/acp-leader-context.d.ts +29 -0
  4. package/dist/acp-leader/acp-leader-fleet.d.ts +26 -0
  5. package/dist/acp-leader/acp-leader-host-binding.d.ts +16 -0
  6. package/dist/acp-leader/acp-leader-host.d.ts +80 -0
  7. package/dist/acp-leader/acp-leader-picker.d.ts +21 -0
  8. package/dist/acp-leader/acp-leader-provider.d.ts +85 -0
  9. package/dist/acp-leader/acp-leader-resume.d.ts +10 -0
  10. package/dist/acp-leader/acp-leader-stream.d.ts +82 -0
  11. package/dist/{auth-ANOVZVHE.js → auth-IHQS6AFW.js} +60 -64
  12. package/dist/auth-menu/index.d.ts +1 -2
  13. package/dist/boot/dispatch-webui.d.ts +16 -0
  14. package/dist/{chunk-GRAGMA4B.js → chunk-2LTHDKZX.js} +4 -4
  15. package/dist/chunk-3LEIFO5D.js +65 -0
  16. package/dist/chunk-COGI7EQU.js +1458 -0
  17. package/dist/chunk-GKGWPFW2.js +50 -0
  18. package/dist/{chunk-RAWHRRUJ.js → chunk-I5LJLKA3.js} +198 -197
  19. package/dist/{chunk-5TRZZHMN.js → chunk-JCZ2D3VV.js} +4 -65
  20. package/dist/{chunk-XT3NAHRX.js → chunk-JKTJSLUT.js} +192 -1
  21. package/dist/{chunk-NMXQFQ26.js → chunk-TAE3EGBM.js} +3 -3
  22. package/dist/{chunk-3R3OADC5.js → chunk-ZF4HRR5F.js} +7 -3
  23. package/dist/{cli-context-A6XDEXN5.js → cli-context-E44HQ4ZO.js} +17 -8
  24. package/dist/{cli-main-5UGSW4TO.js → cli-main-OT63I2FX.js} +490 -228
  25. package/dist/{execution-BAP566QC.js → execution-OK34CJKJ.js} +7 -2
  26. package/dist/fleet/acp-live-steer.d.ts +28 -0
  27. package/dist/fleet/acp-permission-bridge.d.ts +49 -0
  28. package/dist/fleet/acp-quota-hold.d.ts +3 -0
  29. package/dist/fleet/acp-quota-reading.d.ts +3 -0
  30. package/dist/fleet/acp-turn-reminders.d.ts +15 -0
  31. package/dist/fleet/acp-wrongstack-bridge.d.ts +42 -0
  32. package/dist/fleet/host-acp.d.ts +20 -2
  33. package/dist/index.js +7 -4
  34. package/dist/{mcp-2XWBJEQN.js → mcp-W7A5HUXV.js} +97 -1
  35. package/dist/mcp-serve-project.d.ts +18 -0
  36. package/dist/{per-subcommand-help-D6J4ZXW2.js → per-subcommand-help-4GYSCMLU.js} +2 -2
  37. package/dist/{short-circuit-flags-CPCT5MWB.js → short-circuit-flags-QEXUS3BY.js} +2 -2
  38. package/dist/{subcommands-VTMIZQBP.js → subcommands-YADUV7IJ.js} +2 -2
  39. package/dist/{webui-server-HIUY3RHD.js → webui-server-CB64CFDG.js} +41 -3
  40. package/package.json +34 -30
  41. package/dist/auth-menu/anthropic-oauth.d.ts +0 -43
  42. package/dist/chunk-ZNNFEKDZ.js +0 -319
@@ -18,14 +18,12 @@ import {
18
18
  import {
19
19
  configureSimpleUiRuntimeContext,
20
20
  detectProjectFacts,
21
- isRestrictedMode,
22
21
  isSafeMode,
23
22
  makeConfirmAwaiter,
24
23
  renderAgentsTemplate,
25
24
  resolveToolRestriction,
26
- unknownRestrictedToolNames,
27
- withRestrictedTools
28
- } from "./chunk-5TRZZHMN.js";
25
+ unknownRestrictedToolNames
26
+ } from "./chunk-JCZ2D3VV.js";
29
27
  import "./chunk-JTTV2EVA.js";
30
28
  import {
31
29
  awaitFirstWrongProxyProbe,
@@ -73,7 +71,7 @@ import {
73
71
  import {
74
72
  renderDeepHelpToString,
75
73
  renderFocusedHelpToString
76
- } from "./chunk-3R3OADC5.js";
74
+ } from "./chunk-ZF4HRR5F.js";
77
75
  import {
78
76
  explainCall,
79
77
  formatExplainedCall,
@@ -111,7 +109,7 @@ import {
111
109
  runAuthLocal,
112
110
  runProviderAuthLogin,
113
111
  validateFamily
114
- } from "./chunk-RAWHRRUJ.js";
112
+ } from "./chunk-I5LJLKA3.js";
115
113
  import "./chunk-ZXX3MJRL.js";
116
114
  import {
117
115
  buildPickableProviders,
@@ -136,14 +134,24 @@ import {
136
134
  createGracefulShutdown,
137
135
  formatAcpAgentList,
138
136
  loadCachedAcpRegistry,
137
+ recordAcpRateLimit,
139
138
  refreshAcpRegistry,
140
- setupProvider
141
- } from "./chunk-ZNNFEKDZ.js";
139
+ setupProvider,
140
+ startAcpTurnReminders,
141
+ wrongstackAcpPermissionPolicy
142
+ } from "./chunk-COGI7EQU.js";
142
143
  import {
144
+ DEFAULT_BRIDGE_SERVERS,
143
145
  createHqCommandDispatcher,
144
146
  createProjectKanbanAssignHandler,
145
- createProjectKanbanTransitionHandler
146
- } from "./chunk-XT3NAHRX.js";
147
+ createProjectKanbanTransitionHandler,
148
+ installedBridgeAgents,
149
+ wrongstackBridgeSetup
150
+ } from "./chunk-JKTJSLUT.js";
151
+ import {
152
+ isRestrictedMode,
153
+ withRestrictedTools
154
+ } from "./chunk-3LEIFO5D.js";
147
155
  import {
148
156
  startCliHqConnection
149
157
  } from "./chunk-76JE54WD.js";
@@ -162,6 +170,11 @@ import {
162
170
  import {
163
171
  parseSpawnFlags
164
172
  } from "./chunk-75OLD563.js";
173
+ import {
174
+ ACP_LEADER_PROVIDER_ID,
175
+ acpLeaderSessionAgent,
176
+ bindAcpLeaderHost
177
+ } from "./chunk-GKGWPFW2.js";
165
178
  import {
166
179
  checkForUpdate
167
180
  } from "./chunk-H53EXXAU.js";
@@ -1008,7 +1021,18 @@ function createPickableProvidersLoader(args) {
1008
1021
  logger,
1009
1022
  reason: "model-picker"
1010
1023
  });
1011
- return buildPickableProviders(modelsRegistry, getConfig());
1024
+ const config = getConfig();
1025
+ const providers = await buildPickableProviders(modelsRegistry, config);
1026
+ const agents = installedBridgeAgents(config.acp);
1027
+ return agents.length > 0 && !providers.some((p) => p.id === ACP_LEADER_PROVIDER_ID) ? [
1028
+ ...providers,
1029
+ {
1030
+ id: ACP_LEADER_PROVIDER_ID,
1031
+ family: "acp",
1032
+ models: agents,
1033
+ modelsLabel: "ACP agent as leader"
1034
+ }
1035
+ ] : providers;
1012
1036
  };
1013
1037
  }
1014
1038
 
@@ -2962,6 +2986,44 @@ import {
2962
2986
  MCPVaultTokenStore
2963
2987
  } from "@wrongstack/mcp";
2964
2988
 
2989
+ // src/acp-leader/acp-leader-host-binding.ts
2990
+ import { randomUUID } from "node:crypto";
2991
+ function createAcpLeaderHost(opts) {
2992
+ const agentFor = (sessionId) => (sessionId ? acpLeaderSessionAgent(sessionId) : void 0) ?? opts.agent;
2993
+ return {
2994
+ events: opts.events,
2995
+ projectRoot: opts.projectRoot,
2996
+ stateDir: opts.stateDir,
2997
+ getConfig: opts.getConfig,
2998
+ permission: (sessionId) => agentFor(sessionId).permission,
2999
+ context: (sessionId) => agentFor(sessionId).ctx,
3000
+ getTool: opts.getTool,
3001
+ runTool: async (name, input, run = {}) => {
3002
+ const agent = agentFor(run.sessionId);
3003
+ const use = { type: "tool_use", id: `acp_fleet_${randomUUID()}`, name, input };
3004
+ const batch = await agent.toolExecutor.executeBatch([use], agent.ctx, "sequential");
3005
+ let result = batch.outputs[0]?.result;
3006
+ if (result?.type === "tool_confirm_pending") {
3007
+ const tool = opts.getTool(name);
3008
+ const approved = { ...use, input: result.input };
3009
+ if (!tool || !await run.approve?.(tool, approved.input)) {
3010
+ return { content: `${name} was not approved by the user.`, isError: true };
3011
+ }
3012
+ result = (await agent.toolExecutor.executeTool(
3013
+ tool,
3014
+ approved,
3015
+ agent.ctx,
3016
+ agent.perIterationOutputCapBytes
3017
+ )).block;
3018
+ }
3019
+ if (!result) return { content: `${name} returned no result.`, isError: true };
3020
+ const content = typeof result.content === "string" ? result.content : JSON.stringify(result.content);
3021
+ return { content, isError: Boolean(result.is_error) };
3022
+ },
3023
+ confirmAwaiter: opts.confirmAwaiter
3024
+ };
3025
+ }
3026
+
2965
3027
  // src/hooks-wiring.ts
2966
3028
  var HookBlockedError = class extends Error {
2967
3029
  constructor(reason) {
@@ -3790,6 +3852,7 @@ async function setupLifecycleAndPlugins(deps) {
3790
3852
  logger.debug(`max-context re-resolve after catalog change failed: ${toErrorMessage3(err)}`);
3791
3853
  });
3792
3854
  });
3855
+ const confirmAwaiter = makeConfirmAwaiter(reader);
3793
3856
  const agent = createAgent({
3794
3857
  container,
3795
3858
  tools: toolRegistry,
@@ -3798,13 +3861,24 @@ async function setupLifecycleAndPlugins(deps) {
3798
3861
  pipelines,
3799
3862
  context,
3800
3863
  config,
3801
- confirmAwaiter: makeConfirmAwaiter(reader),
3864
+ confirmAwaiter,
3802
3865
  hookRunner,
3803
3866
  tracer: deps.tracer,
3804
3867
  fullConfig: config,
3805
3868
  source: "cli"
3806
3869
  });
3807
3870
  agent.extensions.register(createLifecycleHooksExtension(hookRunner));
3871
+ bindAcpLeaderHost(
3872
+ createAcpLeaderHost({
3873
+ agent,
3874
+ events,
3875
+ projectRoot: wpaths.projectRoot,
3876
+ stateDir: wpaths.projectDir,
3877
+ getConfig: () => configStore.get(),
3878
+ getTool: (name) => toolRegistry.get(name),
3879
+ confirmAwaiter
3880
+ })
3881
+ );
3808
3882
  const mcpTokenStore = new MCPVaultTokenStore(
3809
3883
  path6.join(wpaths.projectDir, "mcp-auth.json"),
3810
3884
  vault
@@ -4071,7 +4145,7 @@ function setupProviderRuntime(deps) {
4071
4145
  const buildProviderForId2 = (providerId) => buildProviderForIdRuntime({ config: cfg, providerRegistry, logger }, providerId);
4072
4146
  const buildProviderForModel = async (providerId, modelId) => {
4073
4147
  const provider = buildProviderForId2(providerId);
4074
- if (!cfg.features.modelsRegistry) return provider;
4148
+ if (!cfg.features.modelsRegistry || providerId === ACP_LEADER_PROVIDER_ID) return provider;
4075
4149
  const { cfg: resolvedCfg } = resolveProviderCfg2(providerId);
4076
4150
  return withCatalogCapabilities(
4077
4151
  modelsRegistry,
@@ -6424,7 +6498,7 @@ async function bootCliRuntime(cliCtx, state) {
6424
6498
 
6425
6499
  // src/cli-main-orchestration.ts
6426
6500
  import { mailboxSessionTag as mailboxSessionTag8 } from "@wrongstack/core/coordination";
6427
- import { TOKENS as TOKENS16 } from "@wrongstack/core/kernel";
6501
+ import { TOKENS as TOKENS17 } from "@wrongstack/core/kernel";
6428
6502
  import { createPolicySandboxApprover, setSandboxExpansionApprover } from "@wrongstack/core/sandbox";
6429
6503
 
6430
6504
  // src/cli-eternal-flag.ts
@@ -6494,7 +6568,7 @@ import {
6494
6568
  createBrainRuntime,
6495
6569
  resolveBrainConfigDefaults
6496
6570
  } from "@wrongstack/core/execution";
6497
- import { TOKENS as TOKENS14 } from "@wrongstack/core/kernel";
6571
+ import { TOKENS as TOKENS15 } from "@wrongstack/core/kernel";
6498
6572
  import {
6499
6573
  createMcpControlTool,
6500
6574
  createMcpUseTool,
@@ -6610,21 +6684,27 @@ function createSubagentWrongTraceHookRunner(sessionId, emit) {
6610
6684
  }
6611
6685
 
6612
6686
  // src/fleet/host.ts
6613
- import { randomUUID as randomUUID8 } from "node:crypto";
6687
+ import { randomUUID as randomUUID9 } from "node:crypto";
6614
6688
  import { createProjectAgentRoster } from "@wrongstack/core/agent-catalog";
6615
6689
  import {
6616
6690
  areSubagentsAllowedForSession as areSubagentsAllowedForSession2,
6617
6691
  FLEET_ROSTER as FLEET_ROSTER2,
6618
- resolveProjectDir as resolveProjectDir2
6692
+ resolveProjectDir as resolveProjectDir3
6619
6693
  } from "@wrongstack/core/coordination";
6620
6694
  import { ToolRegistry as ToolRegistry3 } from "@wrongstack/core/registry";
6621
6695
  import {
6622
6696
  AgentError
6623
6697
  } from "@wrongstack/core/types";
6624
- import { wstackGlobalRoot as wstackGlobalRoot2 } from "@wrongstack/core/utils";
6698
+ import { wstackGlobalRoot as wstackGlobalRoot3 } from "@wrongstack/core/utils";
6625
6699
 
6626
6700
  // src/fleet/host-acp-runner.ts
6627
- import { randomUUID } from "node:crypto";
6701
+ import { randomUUID as randomUUID2 } from "node:crypto";
6702
+ import { TOKENS as TOKENS9 } from "@wrongstack/core/kernel";
6703
+ import {
6704
+ AutoApprovePermissionPolicy,
6705
+ subagentYoloPlus,
6706
+ ToolCapabilities
6707
+ } from "@wrongstack/core/security";
6628
6708
 
6629
6709
  // src/fleet/host-event-bridge.ts
6630
6710
  import * as path11 from "node:path";
@@ -6977,6 +7057,26 @@ function publishAcpLiveProgress(opts) {
6977
7057
  });
6978
7058
  return;
6979
7059
  }
7060
+ case "turn_usage": {
7061
+ const t = event.tokens;
7062
+ fleet?.emit({
7063
+ subagentId,
7064
+ taskId,
7065
+ ts,
7066
+ type: "provider.response",
7067
+ payload: {
7068
+ provider: "acp",
7069
+ usage: {
7070
+ input: t?.input ?? 0,
7071
+ output: t?.output ?? 0,
7072
+ cacheRead: t?.cacheRead ?? 0,
7073
+ cacheWrite: t?.cacheWrite ?? 0
7074
+ },
7075
+ costUsd: event.costUsd
7076
+ }
7077
+ });
7078
+ return;
7079
+ }
6980
7080
  default:
6981
7081
  return;
6982
7082
  }
@@ -6992,15 +7092,42 @@ function safeJson(value) {
6992
7092
 
6993
7093
  // src/fleet/host-acp-runner.ts
6994
7094
  function acpCommandOpts() {
6995
- let overrides;
7095
+ let acp;
6996
7096
  try {
6997
- overrides = this.deps.configStore.get()?.acp?.agents;
7097
+ acp = this.deps.configStore.get()?.acp;
6998
7098
  } catch {
6999
- overrides = void 0;
7099
+ acp = void 0;
7000
7100
  }
7101
+ const overrides = acp?.agents;
7001
7102
  return {
7002
7103
  ...overrides ? { overrides } : {},
7104
+ projectRoot: this.deps.projectRoot,
7105
+ bridge: { projectRoot: this.deps.projectRoot, config: acp?.bridge },
7106
+ // The worker answers to the same rules as WrongStack's own subagents:
7107
+ // the user's deny rules, the destructive and credential guards, YOLO+.
7108
+ // Every capability is granted; the guards, not an allowlist, gate it.
7109
+ permissions: (ctx) => {
7110
+ const leaderPolicy = this.deps.container.safeResolve(TOKENS9.PermissionPolicy);
7111
+ const policy = new AutoApprovePermissionPolicy(Object.values(ToolCapabilities), {
7112
+ yoloPlus: () => subagentYoloPlus({
7113
+ sessionId: ctx.sessionId,
7114
+ leaderPolicy,
7115
+ fallback: () => this.deps.configStore.get().autonomy?.yoloPlus === true
7116
+ })
7117
+ });
7118
+ return wrongstackAcpPermissionPolicy({
7119
+ evaluate: (tool, input, scope) => policy.evaluate(tool, input, scope),
7120
+ getTool: (name) => this.deps.toolRegistry.get(name),
7121
+ projectRoot: this.deps.projectRoot,
7122
+ allowMcp: !isRestrictedMode({}),
7123
+ onRefused: (call, reason) => this.deps.container.safeResolve(TOKENS9.Logger)?.info(`acp worker ${ctx.subagentId}: refused ${call.tool} \u2014 ${reason}`)
7124
+ });
7125
+ },
7003
7126
  publishLive: (ctx, task, event) => {
7127
+ if (event.type === "rate_limit") {
7128
+ recordAcpRateLimit(ctx.config.role ?? ctx.config.name ?? ctx.subagentId, event.info);
7129
+ return;
7130
+ }
7004
7131
  publishAcpLiveProgress({
7005
7132
  event,
7006
7133
  subagentId: ctx.subagentId,
@@ -7014,7 +7141,7 @@ function acpCommandOpts() {
7014
7141
  };
7015
7142
  }
7016
7143
  async function spawnACP(subagentId, task, config) {
7017
- const taskId = randomUUID();
7144
+ const taskId = randomUUID2();
7018
7145
  await this.ensureCoordinator(config);
7019
7146
  const coordinator = this.getCoordinator();
7020
7147
  const acpRunner = await this.buildACPRunner(subagentId);
@@ -7052,7 +7179,41 @@ import {
7052
7179
  makeACPSubagentRunner,
7053
7180
  resolveAcpAgentCommand
7054
7181
  } from "@wrongstack/acp";
7182
+ import { getSharedProjectMailbox as getSharedProjectMailbox4, resolveProjectDir as resolveProjectDir2 } from "@wrongstack/core/coordination";
7055
7183
  import { ToolValidationError } from "@wrongstack/core/types";
7184
+ import { wstackGlobalRoot as wstackGlobalRoot2 } from "@wrongstack/core/utils";
7185
+
7186
+ // src/fleet/acp-live-steer.ts
7187
+ import { sessionNoteHub } from "@wrongstack/core/coordination";
7188
+ import { toErrorMessage as toErrorMessage7 } from "@wrongstack/core/utils";
7189
+ function steerMessage(note) {
7190
+ const head = `[WrongStack ${note.kind} from ${note.from}${note.subject ? ` \u2014 ${note.subject}` : ""}]`;
7191
+ return `${head}
7192
+ ${note.body}`;
7193
+ }
7194
+ function registerAcpSteerInbox(ctx, _task, steer, hub = sessionNoteHub, onUndelivered = () => {
7195
+ }) {
7196
+ const sessionId = ctx.sessionId;
7197
+ if (!sessionId) return void 0;
7198
+ const name = ctx.config.name;
7199
+ return hub.register({
7200
+ sessionId,
7201
+ agentId: ctx.subagentId,
7202
+ ...name && name !== ctx.subagentId ? { aliases: [name] } : {},
7203
+ // A steer interrupts the worker's generation; peer chatter must not.
7204
+ ignorePeerBroadcasts: true,
7205
+ deliver: (note) => {
7206
+ steer(steerMessage(note)).then(
7207
+ (outcome) => {
7208
+ if (outcome !== "injected") onUndelivered(outcome);
7209
+ },
7210
+ (err) => onUndelivered(toErrorMessage7(err))
7211
+ );
7212
+ }
7213
+ });
7214
+ }
7215
+
7216
+ // src/fleet/host-acp.ts
7056
7217
  function buildAcpSubagentRunner(subagentId, options) {
7057
7218
  const cmd = resolveAcpAgentCommand(subagentId, options?.overrides, options?.live);
7058
7219
  if (!cmd) {
@@ -7062,10 +7223,39 @@ function buildAcpSubagentRunner(subagentId, options) {
7062
7223
  context: { requested: subagentId }
7063
7224
  });
7064
7225
  }
7226
+ const bridgeSetup = options?.bridge ? wrongstackBridgeSetup(subagentId, options.bridge.projectRoot, options.bridge.config) : void 0;
7227
+ const mailboxProjectRoot = options?.bridge?.projectRoot;
7228
+ const mailboxEnabled = bridgeSetup !== void 0 && (options?.bridge?.config?.servers ?? DEFAULT_BRIDGE_SERVERS).includes("mailbox");
7229
+ const permissions = options?.permissions;
7230
+ const sessionSetup = bridgeSetup || permissions ? (task, ctx) => ({
7231
+ ...bridgeSetup?.(task, ctx),
7232
+ ...permissions ? { permissionPolicy: permissions(ctx) } : {}
7233
+ }) : void 0;
7234
+ const projectRoot = options?.projectRoot;
7065
7235
  return makeACPSubagentRunner({
7066
7236
  ...cmd,
7237
+ ...projectRoot ? { cwd: projectRoot, projectRoot } : {},
7067
7238
  permissionPolicy: defaultPermissionPolicy,
7068
- ...options?.publishLive ? { publishLive: options.publishLive } : {}
7239
+ // Claude asks before edits and commands only in `default`; left in the
7240
+ // user's own mode (often `auto`) it would never consult the policy.
7241
+ ...permissions ? { initialModeId: "default" } : {},
7242
+ ...permissions && subagentId === "claude-code" ? { requireInitialMode: true } : {},
7243
+ ...options?.publishLive ? { publishLive: options.publishLive } : {},
7244
+ ...sessionSetup ? { sessionSetup } : {},
7245
+ // The leader's `session_note` to a running worker joins its turn.
7246
+ onTurnLive: (ctx, task, steer) => {
7247
+ const stopNotes = registerAcpSteerInbox(ctx, task, steer);
7248
+ const stopMail = mailboxEnabled && mailboxProjectRoot ? startAcpTurnReminders({
7249
+ steer,
7250
+ unreadCount: () => getSharedProjectMailbox4(
7251
+ resolveProjectDir2(mailboxProjectRoot, wstackGlobalRoot2())
7252
+ ).unreadCount(ctx.subagentId, ctx.sessionId)
7253
+ }) : void 0;
7254
+ return () => {
7255
+ stopNotes?.();
7256
+ stopMail?.();
7257
+ };
7258
+ }
7069
7259
  });
7070
7260
  }
7071
7261
 
@@ -7077,7 +7267,7 @@ import {
7077
7267
  } from "@wrongstack/core/coordination";
7078
7268
  import {
7079
7269
  clampSubagentCapabilities,
7080
- ToolCapabilities,
7270
+ ToolCapabilities as ToolCapabilities2,
7081
7271
  WIDE_SUBAGENT_CAPABILITIES
7082
7272
  } from "@wrongstack/core/security";
7083
7273
  import { makePreferSideConflictResolver } from "@wrongstack/sdd";
@@ -7191,12 +7381,12 @@ function resolveSubagentCapabilities(subCfg, toolsForAllow) {
7191
7381
  if (subCfg.allowedCapabilities) {
7192
7382
  return clampSubagentCapabilities([
7193
7383
  ...subCfg.allowedCapabilities,
7194
- ToolCapabilities.COORDINATION_RESULT_SUBMIT
7384
+ ToolCapabilities2.COORDINATION_RESULT_SUBMIT
7195
7385
  ]).granted;
7196
7386
  }
7197
7387
  const allow = subCfg.tools;
7198
7388
  if (allow && allow.length === 0) {
7199
- return clampSubagentCapabilities([ToolCapabilities.COORDINATION_RESULT_SUBMIT]).granted;
7389
+ return clampSubagentCapabilities([ToolCapabilities2.COORDINATION_RESULT_SUBMIT]).granted;
7200
7390
  }
7201
7391
  if (!allow) return WIDE_SUBAGENT_CAPABILITIES;
7202
7392
  const caps = new Set(WIDE_SUBAGENT_CAPABILITIES);
@@ -7433,12 +7623,12 @@ import {
7433
7623
  makeFleetEmitTool,
7434
7624
  postSessionNote as postSessionNote2
7435
7625
  } from "@wrongstack/core/coordination";
7436
- import { TOKENS as TOKENS9 } from "@wrongstack/core/kernel";
7626
+ import { TOKENS as TOKENS10 } from "@wrongstack/core/kernel";
7437
7627
  import { formatMemoryEvidenceBlock } from "@wrongstack/core/utils";
7438
7628
  import { getSageSurface } from "@wrongstack/sage";
7439
7629
 
7440
7630
  // src/fleet/host-director-builder.ts
7441
- import { randomUUID as randomUUID2 } from "node:crypto";
7631
+ import { randomUUID as randomUUID3 } from "node:crypto";
7442
7632
  import * as path13 from "node:path";
7443
7633
  import {
7444
7634
  DEFAULT_MAX_FLEET_SPAWNS,
@@ -7464,7 +7654,7 @@ function createHostFleetManager(opts) {
7464
7654
  function prepareHostDirectorRuntime(input) {
7465
7655
  const { config, deps, opts } = input;
7466
7656
  const coordinatorConfig = {
7467
- coordinatorId: randomUUID2(),
7657
+ coordinatorId: randomUUID3(),
7468
7658
  doneCondition: { type: "all_tasks_done" },
7469
7659
  maxConcurrent: opts.maxConcurrent ?? 4
7470
7660
  };
@@ -7662,7 +7852,7 @@ function registerCoordinatorLifecycleHandlers(input) {
7662
7852
 
7663
7853
  // src/fleet/host-director-services.ts
7664
7854
  import {
7665
- getSharedProjectMailbox as getSharedProjectMailbox4,
7855
+ getSharedProjectMailbox as getSharedProjectMailbox5,
7666
7856
  mailboxSessionTag as mailboxSessionTag2
7667
7857
  } from "@wrongstack/core/coordination";
7668
7858
 
@@ -7850,7 +8040,7 @@ function createHostStatusBroadcaster(input) {
7850
8040
  const { events, sessionId, mailboxProjectDir, subagentName, config } = input;
7851
8041
  return createFleetStatusBroadcaster({
7852
8042
  events,
7853
- mailboxFactory: () => getSharedProjectMailbox4(mailboxProjectDir(), events),
8043
+ mailboxFactory: () => getSharedProjectMailbox5(mailboxProjectDir(), events),
7854
8044
  sessionTag: () => mailboxSessionTag2(sessionId),
7855
8045
  subagentName,
7856
8046
  config
@@ -7858,13 +8048,13 @@ function createHostStatusBroadcaster(input) {
7858
8048
  }
7859
8049
 
7860
8050
  // src/fleet/host-explore-companion.ts
7861
- import { randomUUID as randomUUID3 } from "node:crypto";
8051
+ import { randomUUID as randomUUID4 } from "node:crypto";
7862
8052
  import {
7863
8053
  buildProbeTaskText,
7864
8054
  DEFAULT_EXPLORE_COMPANION_AGENT_ID,
7865
8055
  ExploreCompanion,
7866
8056
  formatSubagentStructuredReport,
7867
- getSharedProjectMailbox as getSharedProjectMailbox5,
8057
+ getSharedProjectMailbox as getSharedProjectMailbox6,
7868
8058
  mailboxSessionTag as mailboxSessionTag3,
7869
8059
  postSessionNote
7870
8060
  } from "@wrongstack/core/coordination";
@@ -7875,7 +8065,7 @@ function createHostExploreCompanion(input) {
7875
8065
  const { director, events, sessionId, mailboxProjectDir, roster, config } = input;
7876
8066
  if (config?.enabled === false) return null;
7877
8067
  const sessionTag = mailboxSessionTag3(sessionId);
7878
- const mailbox = () => getSharedProjectMailbox5(mailboxProjectDir, events);
8068
+ const mailbox = () => getSharedProjectMailbox6(mailboxProjectDir, events);
7879
8069
  const template = roster[DEFAULT_EXPLORE_COMPANION_AGENT_ID];
7880
8070
  let residentId;
7881
8071
  let active2;
@@ -7917,7 +8107,7 @@ function createHostExploreCompanion(input) {
7917
8107
  ...template,
7918
8108
  // Unique incarnation: late removal of an old resident cannot remove
7919
8109
  // its replacement, including after a registry eviction/recreation.
7920
- id: `explore-companion-${sessionTag}-${randomUUID3().slice(0, 8)}`,
8110
+ id: `explore-companion-${sessionTag}-${randomUUID4().slice(0, 8)}`,
7921
8111
  name: "Explore Companion",
7922
8112
  // The resident belongs to the conversation it explores for. Without the
7923
8113
  // stamp the coordinator files it under the host's own session, and every
@@ -7940,7 +8130,7 @@ function createHostExploreCompanion(input) {
7940
8130
  leaderSessionId: sessionId,
7941
8131
  leaderAgentId: "leader",
7942
8132
  onProbe: async (probe2) => {
7943
- const taskId = randomUUID3();
8133
+ const taskId = randomUUID4();
7944
8134
  let resolve11;
7945
8135
  const done = new Promise((finish) => {
7946
8136
  resolve11 = finish;
@@ -8104,7 +8294,7 @@ function createExploreCompanionRegistry(input) {
8104
8294
  }
8105
8295
 
8106
8296
  // src/fleet/host-memory-companion.ts
8107
- import { randomUUID as randomUUID4 } from "node:crypto";
8297
+ import { randomUUID as randomUUID5 } from "node:crypto";
8108
8298
  import { memoryReviewReason } from "@wrongstack/sage";
8109
8299
 
8110
8300
  // src/fleet/memory-companion-evidence.ts
@@ -8330,7 +8520,7 @@ var HostMemoryCompanion = class {
8330
8520
  const resident = await this.spawnBounded(
8331
8521
  constrainMemoryCompanion({
8332
8522
  ...template,
8333
- id: `memory-companion-${randomUUID4()}`,
8523
+ id: `memory-companion-${randomUUID5()}`,
8334
8524
  name: "Memory Companion",
8335
8525
  role: "memory-curator",
8336
8526
  originSessionId: sessionId,
@@ -8347,7 +8537,7 @@ var HostMemoryCompanion = class {
8347
8537
  }
8348
8538
  session.probes++;
8349
8539
  const agentId = session.resident;
8350
- const taskId = randomUUID4();
8540
+ const taskId = randomUUID5();
8351
8541
  this.send(
8352
8542
  sessionId,
8353
8543
  "[memory:checking]",
@@ -8513,7 +8703,7 @@ ${JSON.stringify({
8513
8703
  };
8514
8704
 
8515
8705
  // src/fleet/host-skill-companion.ts
8516
- import { createHash as createHash2, randomUUID as randomUUID5 } from "node:crypto";
8706
+ import { createHash as createHash2, randomUUID as randomUUID6 } from "node:crypto";
8517
8707
  import {
8518
8708
  extractSkillMentions,
8519
8709
  isSkillRecommendable,
@@ -8526,7 +8716,7 @@ import {
8526
8716
 
8527
8717
  // src/fleet/skill-companion-policy.ts
8528
8718
  import { makeSubagentResultTool as makeSubagentResultTool3 } from "@wrongstack/core/coordination";
8529
- import { ToolCapabilities as ToolCapabilities2 } from "@wrongstack/core/security";
8719
+ import { ToolCapabilities as ToolCapabilities3 } from "@wrongstack/core/security";
8530
8720
  import { skillPromptExclusionReasons } from "@wrongstack/core/skills";
8531
8721
  var SKILL_COMPANION_ROLE = "skill-companion";
8532
8722
  var SKILL_COMPANION_ID_PREFIX = "skill-companion-";
@@ -8558,7 +8748,7 @@ function constrainSkillCompanion(config) {
8558
8748
  tools: [],
8559
8749
  disabledTools: void 0,
8560
8750
  capabilities: [],
8561
- allowedCapabilities: [ToolCapabilities2.COORDINATION_RESULT_SUBMIT],
8751
+ allowedCapabilities: [ToolCapabilities3.COORDINATION_RESULT_SUBMIT],
8562
8752
  skillNames: [],
8563
8753
  skillPool: [],
8564
8754
  skillContent: void 0,
@@ -8846,7 +9036,7 @@ var HostSkillCompanion = class {
8846
9036
  const agentId = await this.resident(sessionId, session);
8847
9037
  if (!agentId || !this.current(sessionId, session)) return;
8848
9038
  session.probes++;
8849
- const taskId = randomUUID5();
9039
+ const taskId = randomUUID6();
8850
9040
  let timeout;
8851
9041
  const completed = new Promise((resolve11) => {
8852
9042
  this.active = { taskId, agentId, settle: resolve11 };
@@ -8918,7 +9108,7 @@ ${JSON.stringify({
8918
9108
  session.resident = void 0;
8919
9109
  if (session.resident) return session.resident;
8920
9110
  const config = constrainSkillCompanion({
8921
- id: `${SKILL_COMPANION_ID_PREFIX}${randomUUID5()}`,
9111
+ id: `${SKILL_COMPANION_ID_PREFIX}${randomUUID6()}`,
8922
9112
  name: "Skill Companion",
8923
9113
  role: SKILL_COMPANION_ROLE,
8924
9114
  originSessionId: sessionId,
@@ -9076,7 +9266,7 @@ async function buildDirector(host) {
9076
9266
  projectRoot: host.deps.projectRoot,
9077
9267
  roster: host.roster,
9078
9268
  memory: () => {
9079
- const port = host.deps.container.safeResolve(TOKENS9.MemoryStore);
9269
+ const port = host.deps.container.safeResolve(TOKENS10.MemoryStore);
9080
9270
  return port ? getSageSurface(port) : void 0;
9081
9271
  },
9082
9272
  enabled: (sessionId) => {
@@ -9164,7 +9354,7 @@ async function buildDirector(host) {
9164
9354
  (n) => coordinator.setMaxConcurrent(n),
9165
9355
  { maxConcurrent: host.getMaxConcurrent(), ...adaptiveConfig },
9166
9356
  void 0,
9167
- host.deps.container.safeResolve(TOKENS9.Logger)
9357
+ host.deps.container.safeResolve(TOKENS10.Logger)
9168
9358
  );
9169
9359
  }
9170
9360
  const runner = await host.buildSubagentRunner(config);
@@ -9412,11 +9602,11 @@ import {
9412
9602
  recordDirectiveOutcomes,
9413
9603
  recordSkillOutcome
9414
9604
  } from "@wrongstack/core/agent-catalog";
9415
- import { TOKENS as TOKENS10 } from "@wrongstack/core/kernel";
9605
+ import { TOKENS as TOKENS11 } from "@wrongstack/core/kernel";
9416
9606
  function captureCompletedTaskLearningForHost(result, deps, subjects, onCaptured) {
9417
9607
  const subject = subjects.get(result.subagentId);
9418
9608
  if (!subject) return;
9419
- const logger = deps.container.safeResolve(TOKENS10.Logger);
9609
+ const logger = deps.container.safeResolve(TOKENS11.Logger);
9420
9610
  const graded = result.status !== "stopped";
9421
9611
  const succeeded = result.status === "success";
9422
9612
  if (graded && subject.skills.length > 0) {
@@ -9886,7 +10076,7 @@ var HostShadowManager = class {
9886
10076
  };
9887
10077
 
9888
10078
  // src/fleet/host-subagent-factory.ts
9889
- import { randomUUID as randomUUID6 } from "node:crypto";
10079
+ import { randomUUID as randomUUID7 } from "node:crypto";
9890
10080
  import { existsSync, statSync } from "node:fs";
9891
10081
  import * as path15 from "node:path";
9892
10082
  import {
@@ -9905,7 +10095,7 @@ import {
9905
10095
  import {
9906
10096
  DEFAULT_SUBAGENT_BASELINE,
9907
10097
  FLEET_ROSTER,
9908
- getSharedProjectMailbox as getSharedProjectMailbox6,
10098
+ getSharedProjectMailbox as getSharedProjectMailbox7,
9909
10099
  resolveSubagentModelTarget as resolveSubagentModelTarget2
9910
10100
  } from "@wrongstack/core/coordination";
9911
10101
  import { installDesignStudioMiddleware as installDesignStudioMiddleware2 } from "@wrongstack/core/design";
@@ -9916,9 +10106,9 @@ import {
9916
10106
  ToolExecutor as ToolExecutor2
9917
10107
  } from "@wrongstack/core/execution";
9918
10108
  import { DefaultTokenCounter } from "@wrongstack/core/infrastructure";
9919
- import { EventBus, TOKENS as TOKENS12 } from "@wrongstack/core/kernel";
10109
+ import { EventBus, TOKENS as TOKENS13 } from "@wrongstack/core/kernel";
9920
10110
  import { ToolRegistry as ToolRegistry2 } from "@wrongstack/core/registry";
9921
- import { AutoApprovePermissionPolicy, subagentYoloPlus } from "@wrongstack/core/security";
10111
+ import { AutoApprovePermissionPolicy as AutoApprovePermissionPolicy2, subagentYoloPlus as subagentYoloPlus2 } from "@wrongstack/core/security";
9922
10112
  import { createSessionEventBridge as createSessionEventBridge3, resolveSessionLoggingConfig as resolveSessionLoggingConfig2 } from "@wrongstack/core/storage";
9923
10113
 
9924
10114
  // src/fleet/host-context.ts
@@ -9935,7 +10125,7 @@ import {
9935
10125
  resolveRoleSkillCandidates,
9936
10126
  runtimeToolReferencesFromText
9937
10127
  } from "@wrongstack/core/agent-catalog";
9938
- import { TOKENS as TOKENS11 } from "@wrongstack/core/kernel";
10128
+ import { TOKENS as TOKENS12 } from "@wrongstack/core/kernel";
9939
10129
  import { activeLimits, positiveLimit } from "@wrongstack/core/types";
9940
10130
  import { formatMemoryEvidenceBlock as formatMemoryEvidenceBlock2, formatProjectSuppliedBlock } from "@wrongstack/core/utils";
9941
10131
  import { formatMemoryHintsDetailed, getSageRetrieval } from "@wrongstack/sage";
@@ -10120,7 +10310,7 @@ function composeAddendumOnly(role, skillName, augmentation) {
10120
10310
  ].join("\n");
10121
10311
  }
10122
10312
  async function retrieveHostSubagentMemory(deps, getLeaderMode, subCfg, taskContext, owningSessionId) {
10123
- const memoryPort = deps.container.safeResolve(TOKENS11.MemoryStore);
10313
+ const memoryPort = deps.container.safeResolve(TOKENS12.MemoryStore);
10124
10314
  const memory = memoryPort ? getSageRetrieval(memoryPort) : void 0;
10125
10315
  if (!memory?.retrieveForAudience) return void 0;
10126
10316
  const contextualTaskType = typeof taskContext?.["taskType"] === "string" ? taskContext["taskType"] : void 0;
@@ -10355,7 +10545,7 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
10355
10545
  }
10356
10546
  let onlineAgents = [];
10357
10547
  try {
10358
- const subagentMailbox = getSharedProjectMailbox6(host.mailboxProjectDir());
10548
+ const subagentMailbox = getSharedProjectMailbox7(host.mailboxProjectDir());
10359
10549
  onlineAgents = await subagentMailbox.getAgentStatuses();
10360
10550
  } catch {
10361
10551
  }
@@ -10418,7 +10608,7 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
10418
10608
  if (rolePrompt) {
10419
10609
  baseSystem.push({ type: "text", text: rolePrompt });
10420
10610
  }
10421
- const subagentName = effectiveCfg.id ?? effectiveCfg.name ?? `sub_${randomUUID6().slice(0, 8)}`;
10611
+ const subagentName = effectiveCfg.id ?? effectiveCfg.name ?? `sub_${randomUUID7().slice(0, 8)}`;
10422
10612
  if (effectiveCfg.role) {
10423
10613
  host.recordLearningRole(subagentName, effectiveCfg.role, skillResolution.selected);
10424
10614
  }
@@ -10493,16 +10683,16 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
10493
10683
  effectiveCfg,
10494
10684
  (allow) => host.filterTools([...allow])
10495
10685
  );
10496
- const leaderPolicy = host.deps.container.safeResolve(TOKENS12.PermissionPolicy);
10686
+ const leaderPolicy = host.deps.container.safeResolve(TOKENS13.PermissionPolicy);
10497
10687
  const subagentPolicyOptions = {
10498
- yoloPlus: () => subagentYoloPlus({
10688
+ yoloPlus: () => subagentYoloPlus2({
10499
10689
  sessionId: owningSessionId,
10500
10690
  leaderPolicy,
10501
10691
  fallback: () => host.deps.configStore.get().autonomy?.yoloPlus === true
10502
10692
  })
10503
10693
  };
10504
10694
  const toolExecutor = new ToolExecutor2(baseRegistry, {
10505
- permissionPolicy: new AutoApprovePermissionPolicy(subAllowedCaps, subagentPolicyOptions),
10695
+ permissionPolicy: new AutoApprovePermissionPolicy2(subAllowedCaps, subagentPolicyOptions),
10506
10696
  secretScrubber: host.deps.secretScrubber,
10507
10697
  renderer: host.deps.renderer,
10508
10698
  events,
@@ -10540,7 +10730,7 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
10540
10730
  events,
10541
10731
  pipelines,
10542
10732
  context: ctx,
10543
- permissionPolicy: new AutoApprovePermissionPolicy(subAllowedCaps, subagentPolicyOptions),
10733
+ permissionPolicy: new AutoApprovePermissionPolicy2(subAllowedCaps, subagentPolicyOptions),
10544
10734
  toolExecutor,
10545
10735
  tracer: host.deps.tracer,
10546
10736
  loopDetection: config.tools?.loopDetection,
@@ -10621,14 +10811,14 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
10621
10811
  }
10622
10812
 
10623
10813
  // src/fleet/host-supervisor.ts
10624
- import { randomUUID as randomUUID7 } from "node:crypto";
10814
+ import { randomUUID as randomUUID8 } from "node:crypto";
10625
10815
  import {
10626
10816
  dispatchAgent,
10627
10817
  FleetSupervisor,
10628
10818
  mailboxSessionTag as mailboxSessionTag4,
10629
10819
  postSessionNote as postSessionNote3
10630
10820
  } from "@wrongstack/core/coordination";
10631
- import { toErrorMessage as toErrorMessage7 } from "@wrongstack/core/utils/error";
10821
+ import { toErrorMessage as toErrorMessage8 } from "@wrongstack/core/utils/error";
10632
10822
 
10633
10823
  // src/fleet/supervisor-registry.ts
10634
10824
  var active = null;
@@ -10674,7 +10864,7 @@ function createHostFleetSupervisor(input) {
10674
10864
  ].filter((part) => typeof part === "string" && part.trim().length > 0).join("\n\n");
10675
10865
  const subagentId = await director.spawn({
10676
10866
  ...template ?? { name: "fleet helper", role: "executor" },
10677
- id: `helper-${randomUUID7().slice(0, 8)}`,
10867
+ id: `helper-${randomUUID8().slice(0, 8)}`,
10678
10868
  name: `fleet helper (${routed.role})`,
10679
10869
  role: routed.role,
10680
10870
  systemPromptOverride: helperPrompt,
@@ -10684,7 +10874,7 @@ function createHostFleetSupervisor(input) {
10684
10874
  });
10685
10875
  return { subagentId };
10686
10876
  } catch (err) {
10687
- return { error: toErrorMessage7(err) };
10877
+ return { error: toErrorMessage8(err) };
10688
10878
  }
10689
10879
  },
10690
10880
  steerAgent: async (subagentId, subject, body) => {
@@ -10722,7 +10912,7 @@ function createHostFleetSupervisor(input) {
10722
10912
  // src/fleet/host-task-result-report.ts
10723
10913
  import {
10724
10914
  formatSubagentStructuredReport as formatSubagentStructuredReport2,
10725
- getSharedProjectMailbox as getSharedProjectMailbox7,
10915
+ getSharedProjectMailbox as getSharedProjectMailbox8,
10726
10916
  mailboxSessionTag as mailboxSessionTag5
10727
10917
  } from "@wrongstack/core/coordination";
10728
10918
  async function reportTaskResultToLeader({
@@ -10734,7 +10924,7 @@ async function reportTaskResultToLeader({
10734
10924
  }) {
10735
10925
  try {
10736
10926
  const leaderId2 = getLeaderMailboxId?.() ?? `leader@${mailboxSessionTag5(sessionId)}`;
10737
- const mailbox = getSharedProjectMailbox7(mailboxProjectDir, events);
10927
+ const mailbox = getSharedProjectMailbox8(mailboxProjectDir, events);
10738
10928
  const ok = n.status === "success";
10739
10929
  const MAX_BODY = 700;
10740
10930
  const failureText = [
@@ -10762,8 +10952,43 @@ ${n.partialText}` : ""
10762
10952
 
10763
10953
  // src/fleet/routing.ts
10764
10954
  import { makeAgentSubagentRunner, NULL_FLEET_BUS } from "@wrongstack/core/coordination";
10765
- import { TOKENS as TOKENS13 } from "@wrongstack/core/kernel";
10955
+ import { TOKENS as TOKENS14 } from "@wrongstack/core/kernel";
10766
10956
  import { expectDefined as expectDefined2 } from "@wrongstack/core/utils";
10957
+
10958
+ // src/fleet/acp-quota-hold.ts
10959
+ var DEFAULT_HOLD_MS = 15 * 6e4;
10960
+ var holds = /* @__PURE__ */ new Map();
10961
+ function isQuotaError(err) {
10962
+ return !!err && typeof err === "object" && err.kind === "provider_quota";
10963
+ }
10964
+ async function runWithQuotaHold(agentId, start, now = Date.now) {
10965
+ const hold = holds.get(agentId);
10966
+ if (hold) {
10967
+ const left = hold.until - now();
10968
+ if (left > 0) {
10969
+ const at = new Date(hold.until).toLocaleTimeString([], {
10970
+ hour: "2-digit",
10971
+ minute: "2-digit"
10972
+ });
10973
+ throw {
10974
+ ...hold.error,
10975
+ message: `${hold.error.message} \u2014 not started: ${agentId} is held until ${at}`,
10976
+ backoffMs: left
10977
+ };
10978
+ }
10979
+ holds.delete(agentId);
10980
+ }
10981
+ try {
10982
+ return await start();
10983
+ } catch (err) {
10984
+ if (isQuotaError(err)) {
10985
+ holds.set(agentId, { until: now() + (err.backoffMs ?? DEFAULT_HOLD_MS), error: err });
10986
+ }
10987
+ throw err;
10988
+ }
10989
+ }
10990
+
10991
+ // src/fleet/routing.ts
10767
10992
  function buildRoutingRunner(config, host) {
10768
10993
  const standardRunner = makeAgentSubagentRunner({
10769
10994
  factory: host.makeSubagentFactory(config),
@@ -10773,8 +10998,10 @@ function buildRoutingRunner(config, host) {
10773
10998
  const subCfg = ctx.config;
10774
10999
  if (subCfg.provider === "acp") {
10775
11000
  const cacheKey = subCfg.role ?? subCfg.name ?? expectDefined2(subCfg.id);
10776
- const runner = await host.buildACPRunner(cacheKey);
10777
- return runner(task, ctx);
11001
+ return runWithQuotaHold(cacheKey, async () => {
11002
+ const runner = await host.buildACPRunner(cacheKey);
11003
+ return runner(task, ctx);
11004
+ });
10778
11005
  }
10779
11006
  return standardRunner(task, ctx);
10780
11007
  };
@@ -10956,7 +11183,7 @@ var MultiAgentHost = class {
10956
11183
  return selectSubagentTools(this.deps.toolRegistry.list(), this.directorToolsByName, allow);
10957
11184
  }
10958
11185
  mailboxProjectDir() {
10959
- return this.opts.mailboxProjectDir ?? resolveProjectDir2(this.deps.projectRoot, wstackGlobalRoot2());
11186
+ return this.opts.mailboxProjectDir ?? resolveProjectDir3(this.deps.projectRoot, wstackGlobalRoot3());
10960
11187
  }
10961
11188
  buildFleetSupervisor(config) {
10962
11189
  this.fleetSupervisor = createHostFleetSupervisor({
@@ -11067,7 +11294,7 @@ var MultiAgentHost = class {
11067
11294
  context: { sessionId: originSessionId, phase: "subagentPolicy" }
11068
11295
  });
11069
11296
  }
11070
- const taskId = randomUUID8();
11297
+ const taskId = randomUUID9();
11071
11298
  if (!this.director)
11072
11299
  throw new AgentError({
11073
11300
  message: "Director is not initialized",
@@ -11396,7 +11623,7 @@ function setupBrainAndOrchestration(deps) {
11396
11623
  getSystemOneJudge: () => resolveTypeSafeJudge({
11397
11624
  config: configStore.get?.() ?? config,
11398
11625
  feature: "brain",
11399
- logger: container.safeResolve(TOKENS14.Logger)
11626
+ logger: container.safeResolve(TOKENS15.Logger)
11400
11627
  }),
11401
11628
  ledger: {
11402
11629
  getPath: () => ledgerEnabled ? ledgerPath : void 0,
@@ -11468,7 +11695,7 @@ function setupBrainAndOrchestration(deps) {
11468
11695
  ),
11469
11696
  events
11470
11697
  );
11471
- container.bind(TOKENS14.BrainArbiter, () => brain);
11698
+ container.bind(TOKENS15.BrainArbiter, () => brain);
11472
11699
  const {
11473
11700
  brainLog,
11474
11701
  getTierStats: brainTierStats,
@@ -11538,7 +11765,7 @@ function setupBrainAndOrchestration(deps) {
11538
11765
  providerRegistry,
11539
11766
  configStore,
11540
11767
  modelsRegistry,
11541
- fallbackProfileManager: container.resolve(TOKENS14.FallbackProfileManager),
11768
+ fallbackProfileManager: container.resolve(TOKENS15.FallbackProfileManager),
11542
11769
  events,
11543
11770
  systemPromptBuilder: promptBuilder,
11544
11771
  session,
@@ -11547,7 +11774,7 @@ function setupBrainAndOrchestration(deps) {
11547
11774
  cwd,
11548
11775
  skillLoader,
11549
11776
  tracer: deps.tracer,
11550
- secretScrubber: container.resolve(TOKENS14.SecretScrubber),
11777
+ secretScrubber: container.resolve(TOKENS15.SecretScrubber),
11551
11778
  // WrongTrace lock gate for every spawned worker — same fail-open
11552
11779
  // coordination the leader's executor enforces (lifecycle-plugins).
11553
11780
  // Registered unconditionally to mirror the leader registration.
@@ -11596,7 +11823,7 @@ function setupBrainAndOrchestration(deps) {
11596
11823
  }
11597
11824
  );
11598
11825
  const delegationTracker = new DelegationTracker({ events });
11599
- container.bind(TOKENS14.DelegationTracker, () => delegationTracker);
11826
+ container.bind(TOKENS15.DelegationTracker, () => delegationTracker);
11600
11827
  teardownHandlers.push(() => delegationTracker.dispose());
11601
11828
  try {
11602
11829
  const restoredEvents = sessResult.restoredEvents;
@@ -11630,9 +11857,10 @@ function setupBrainAndOrchestration(deps) {
11630
11857
  getJudge: () => resolveTypeSafeJudge({
11631
11858
  config: configStore.get?.() ?? config,
11632
11859
  feature: "modelTier",
11633
- logger: container.safeResolve(TOKENS14.Logger)
11860
+ logger: container.safeResolve(TOKENS15.Logger)
11634
11861
  })
11635
- })
11862
+ }),
11863
+ externalAgents: installedBridgeAgents(config.acp)
11636
11864
  })
11637
11865
  );
11638
11866
  toolRegistry.exposeToProvider("delegate");
@@ -11658,7 +11886,7 @@ function setupBrainAndOrchestration(deps) {
11658
11886
  }
11659
11887
  toolRegistry.register(
11660
11888
  createSessionRenameTool({
11661
- rename: (sessionId, name) => container.resolve(TOKENS14.SessionStore).rename(sessionId, name),
11889
+ rename: (sessionId, name) => container.resolve(TOKENS15.SessionStore).rename(sessionId, name),
11662
11890
  events
11663
11891
  })
11664
11892
  );
@@ -11679,7 +11907,7 @@ function setupBrainAndOrchestration(deps) {
11679
11907
  }
11680
11908
 
11681
11909
  // src/wiring/cli-slash-commands-setup.ts
11682
- import { TOKENS as TOKENS15 } from "@wrongstack/core/kernel";
11910
+ import { TOKENS as TOKENS16 } from "@wrongstack/core/kernel";
11683
11911
 
11684
11912
  // src/wiring/command-host-adapters.ts
11685
11913
  import { color as color5, isStdinTTY } from "@wrongstack/core/utils";
@@ -13070,7 +13298,7 @@ import {
13070
13298
  STATUSLINE_ITEMS
13071
13299
  } from "@wrongstack/core/statusline";
13072
13300
  import { ERROR_CODES, FsError } from "@wrongstack/core/types";
13073
- import { atomicWrite as atomicWrite2, resolveWstackPaths, toErrorMessage as toErrorMessage8 } from "@wrongstack/core/utils";
13301
+ import { atomicWrite as atomicWrite2, resolveWstackPaths, toErrorMessage as toErrorMessage9 } from "@wrongstack/core/utils";
13074
13302
  var CONFIG_ENV = "WRONGSTACK_STATUSLINE_CONFIG";
13075
13303
  var STATUSLINE_CONFIG_VERSION = 4;
13076
13304
  var STATUSLINE_CONFIG_KEYS = STATUSLINE_ITEMS;
@@ -13227,7 +13455,7 @@ async function saveStatuslineConfig(config) {
13227
13455
  );
13228
13456
  } catch (error) {
13229
13457
  throw new FsError({
13230
- message: toErrorMessage8(error),
13458
+ message: toErrorMessage9(error),
13231
13459
  code: error instanceof Error && error.message.includes("mkdir") ? ERROR_CODES.FS_MKDIR_FAILED : ERROR_CODES.FS_ATOMIC_WRITE_FAILED,
13232
13460
  path: configPath,
13233
13461
  cause: error
@@ -13311,8 +13539,8 @@ function estimateTokens(messages) {
13311
13539
 
13312
13540
  // src/slash-commands/acp.ts
13313
13541
  import {
13314
- EnsembleRegistry,
13315
13542
  defaultPermissionPolicy as defaultPermissionPolicy2,
13543
+ EnsembleRegistry,
13316
13544
  probeAcpAgents,
13317
13545
  renderAcpBenchText,
13318
13546
  renderEnsembleText,
@@ -13321,7 +13549,7 @@ import {
13321
13549
  runEnsemble,
13322
13550
  runOneAcpTask
13323
13551
  } from "@wrongstack/acp";
13324
- import { toErrorMessage as toErrorMessage9 } from "@wrongstack/core/utils";
13552
+ import { toErrorMessage as toErrorMessage10 } from "@wrongstack/core/utils";
13325
13553
  function buildAcpCommand(opts) {
13326
13554
  return {
13327
13555
  name: "acp",
@@ -13374,6 +13602,13 @@ function buildAcpCommand(opts) {
13374
13602
  }
13375
13603
  };
13376
13604
  }
13605
+ function readBridgeConfig(opts) {
13606
+ try {
13607
+ return opts.configStore?.get()?.acp?.bridge;
13608
+ } catch {
13609
+ return void 0;
13610
+ }
13611
+ }
13377
13612
  function readOverrides(opts) {
13378
13613
  try {
13379
13614
  return opts.configStore?.get()?.acp?.agents;
@@ -13394,7 +13629,7 @@ Run \`/acp\` to see them, or \`/acp probe <id>\` to test one.`
13394
13629
  };
13395
13630
  } catch (err) {
13396
13631
  return {
13397
- message: `ACP registry sync failed: ${toErrorMessage9(err)}
13632
+ message: `ACP registry sync failed: ${toErrorMessage10(err)}
13398
13633
  The bundled offline catalog is still available via \`/acp\`.`
13399
13634
  };
13400
13635
  }
@@ -13517,7 +13752,7 @@ async function parallelAgents(rest, overrides, live, opts) {
13517
13752
  const summary = await opts.onSpawn(task, { provider: "acp", name: id });
13518
13753
  dispatched.push(` \u2022 ${id}: ${summary}`);
13519
13754
  } catch (err) {
13520
- skipped.push({ id, reason: toErrorMessage9(err) });
13755
+ skipped.push({ id, reason: toErrorMessage10(err) });
13521
13756
  }
13522
13757
  }
13523
13758
  const lines = [
@@ -13542,7 +13777,7 @@ async function parallelAgents(rest, overrides, live, opts) {
13542
13777
  });
13543
13778
  return { message: renderEnsembleText(result) };
13544
13779
  } catch (err) {
13545
- return { message: `Ensemble failed: ${toErrorMessage9(err)}` };
13780
+ return { message: `Ensemble failed: ${toErrorMessage10(err)}` };
13546
13781
  }
13547
13782
  }
13548
13783
  async function runSingle(agentId, rest, overrides, live, opts) {
@@ -13575,7 +13810,7 @@ Run \`/acp\` to see available agents.`
13575
13810
  return { message: `Dispatched '${agentId}' as a background ACP subagent.
13576
13811
  ${summary}` };
13577
13812
  } catch (err) {
13578
- return { message: `Background spawn failed: ${toErrorMessage9(err)}` };
13813
+ return { message: `Background spawn failed: ${toErrorMessage10(err)}` };
13579
13814
  }
13580
13815
  }
13581
13816
  opts.renderer.writeInfo(`Running task on '${agentId}'\u2026
@@ -13591,6 +13826,7 @@ ${summary}` };
13591
13826
  projectRoot: opts.projectRoot,
13592
13827
  sessionId: opts.context?.eventSessionId(),
13593
13828
  permissionPolicy: defaultPermissionPolicy2,
13829
+ sessionSetup: wrongstackBridgeSetup(agentId, opts.projectRoot, readBridgeConfig(opts)),
13594
13830
  onProgress: (event) => {
13595
13831
  const line = formatProgress(event);
13596
13832
  if (line) opts.renderer.writeInfo(` ${line}
@@ -13607,7 +13843,7 @@ ${body}
13607
13843
  } catch (err) {
13608
13844
  const e = err;
13609
13845
  const detail = e.kind ? `[${e.kind}] ` : "";
13610
- const message = e.message ?? toErrorMessage9(err);
13846
+ const message = e.message ?? toErrorMessage10(err);
13611
13847
  return { message: `ACP agent '${agentId}' failed: ${detail}${message}` };
13612
13848
  }
13613
13849
  }
@@ -14007,7 +14243,6 @@ function buildAuthCommand(opts) {
14007
14243
  `${color12.bold("OAuth sign-in")}`,
14008
14244
  "",
14009
14245
  ` Run ${color12.cyan("wstack auth login chatgpt")} \u2014 ChatGPT Plus/Pro (\u2192 openai-codex)`,
14010
- ` Run ${color12.cyan("wstack auth login claude")} \u2014 Claude Pro/Max (\u2192 anthropic-oauth)`,
14011
14246
  ` Run ${color12.cyan("wstack auth login copilot")} \u2014 GitHub Copilot (\u2192 github-copilot)`,
14012
14247
  ` Run ${color12.cyan("wstack auth login openrouter")} \u2014 OpenRouter API key (\u2192 openrouter)`
14013
14248
  ].join("\n")
@@ -14353,7 +14588,7 @@ ${color13.dim("YOLO enabled; tool calls run without approval unless an explicit
14353
14588
  }
14354
14589
 
14355
14590
  // src/slash-commands/brain.ts
14356
- import { randomUUID as randomUUID9 } from "node:crypto";
14591
+ import { randomUUID as randomUUID10 } from "node:crypto";
14357
14592
  import { color as color16 } from "@wrongstack/core/utils";
14358
14593
 
14359
14594
  // src/slash-commands/brain-council.ts
@@ -14966,7 +15201,7 @@ function buildBrainCommand(opts) {
14966
15201
  }
14967
15202
  try {
14968
15203
  const decision = await opts.brain.decide({
14969
- id: `brain-ask-${randomUUID9()}`,
15204
+ id: `brain-ask-${randomUUID10()}`,
14970
15205
  sessionId: opts.context?.session.id,
14971
15206
  source: "user",
14972
15207
  question,
@@ -15514,7 +15749,7 @@ function buildClearCommand(opts) {
15514
15749
  // src/slash-commands/codebase-map.ts
15515
15750
  import * as fs6 from "node:fs/promises";
15516
15751
  import * as path18 from "node:path";
15517
- import { color as color18, toErrorMessage as toErrorMessage10 } from "@wrongstack/core/utils";
15752
+ import { color as color18, toErrorMessage as toErrorMessage11 } from "@wrongstack/core/utils";
15518
15753
  import {
15519
15754
  ATLAS_DIR,
15520
15755
  checkProjectAtlasFreshness,
@@ -15671,7 +15906,7 @@ function buildCodebaseMapCommand(opts) {
15671
15906
  )
15672
15907
  };
15673
15908
  } catch (err) {
15674
- return { message: `${color18.red("codebase-map failed:")} ${toErrorMessage10(err)}` };
15909
+ return { message: `${color18.red("codebase-map failed:")} ${toErrorMessage11(err)}` };
15675
15910
  }
15676
15911
  }
15677
15912
  };
@@ -15744,7 +15979,7 @@ function renderFreshness(report) {
15744
15979
  }
15745
15980
 
15746
15981
  // src/slash-commands/codebase-reindex.ts
15747
- import { color as color19, toErrorMessage as toErrorMessage11 } from "@wrongstack/core/utils";
15982
+ import { color as color19, toErrorMessage as toErrorMessage12 } from "@wrongstack/core/utils";
15748
15983
  import { resetIndexCircuitBreaker, runStartupIndex } from "@wrongstack/tools";
15749
15984
  function buildCodebaseReindexCommand(opts) {
15750
15985
  return {
@@ -15776,7 +16011,7 @@ ${color19.yellow(" corrupt index detected \u2014 rebuilt from scratch")}` : "")
15776
16011
  ${color19.yellow(` ${r.errors.length} error(s) reported`)}` : "");
15777
16012
  return { message: summary };
15778
16013
  } catch (err) {
15779
- const msg = `${color19.red("Codebase reindex failed:")} ${toErrorMessage11(err)}`;
16014
+ const msg = `${color19.red("Codebase reindex failed:")} ${toErrorMessage12(err)}`;
15780
16015
  return { message: msg };
15781
16016
  }
15782
16017
  }
@@ -15784,7 +16019,7 @@ ${color19.yellow(` ${r.errors.length} error(s) reported`)}` : "");
15784
16019
  }
15785
16020
 
15786
16021
  // src/slash-commands/collab.ts
15787
- import { color as color20, toErrorMessage as toErrorMessage12, truncate } from "@wrongstack/core/utils";
16022
+ import { color as color20, toErrorMessage as toErrorMessage13, truncate } from "@wrongstack/core/utils";
15788
16023
  function buildCollabCommand(opts) {
15789
16024
  return {
15790
16025
  name: "collab",
@@ -15862,7 +16097,7 @@ async function historyCommand(opts, sessionId, args) {
15862
16097
  }
15863
16098
  } catch (err) {
15864
16099
  return {
15865
- message: color20.yellow(`Failed to read session: ${toErrorMessage12(err)}`)
16100
+ message: color20.yellow(`Failed to read session: ${toErrorMessage13(err)}`)
15866
16101
  };
15867
16102
  }
15868
16103
  const tail = events.slice(-limit);
@@ -16780,7 +17015,7 @@ ${description}`
16780
17015
  // src/slash-commands/delegate.ts
16781
17016
  import { AGENT_CATALOG, AGENTS_BY_PHASE } from "@wrongstack/core/agent-catalog";
16782
17017
  import { dispatchAgent as dispatchAgent2 } from "@wrongstack/core/coordination";
16783
- import { color as color23, toErrorMessage as toErrorMessage13 } from "@wrongstack/core/utils";
17018
+ import { color as color23, toErrorMessage as toErrorMessage14 } from "@wrongstack/core/utils";
16784
17019
  function buildDelegateCommand(opts) {
16785
17020
  return {
16786
17021
  name: "delegate",
@@ -16899,7 +17134,7 @@ async function spawnAgent(opts, role, _task, _name, header) {
16899
17134
  opts.renderer.write(msg);
16900
17135
  return { message: msg };
16901
17136
  } catch (err) {
16902
- const msg = `${color23.red("\u2717 Spawn failed")}: ${toErrorMessage13(err)}`;
17137
+ const msg = `${color23.red("\u2717 Spawn failed")}: ${toErrorMessage14(err)}`;
16903
17138
  opts.renderer.writeWarning(msg);
16904
17139
  return { message: msg };
16905
17140
  }
@@ -17406,7 +17641,7 @@ function buildStatsCommand(opts) {
17406
17641
  // src/slash-commands/doctor.ts
17407
17642
  import * as fs8 from "node:fs/promises";
17408
17643
  import * as path20 from "node:path";
17409
- import { atomicWrite as atomicWrite3, color as color26, toErrorMessage as toErrorMessage14, withFileLock as withFileLock2 } from "@wrongstack/core/utils";
17644
+ import { atomicWrite as atomicWrite3, color as color26, toErrorMessage as toErrorMessage15, withFileLock as withFileLock2 } from "@wrongstack/core/utils";
17410
17645
 
17411
17646
  // src/config-doctor.ts
17412
17647
  import { isSecretField } from "@wrongstack/core/security";
@@ -17999,7 +18234,7 @@ async function runSessionsDoctor(opts, rest) {
17999
18234
  try {
18000
18235
  report = await diagnoseSessions({ sessionsDir });
18001
18236
  } catch (err) {
18002
- return { message: `${color26.red("Session scan failed")} ${toErrorMessage14(err)}` };
18237
+ return { message: `${color26.red("Session scan failed")} ${toErrorMessage15(err)}` };
18003
18238
  }
18004
18239
  const lines = [`${color26.bold("WrongStack")} ${color26.dim("\u2014 Session Doctor")}`, ""];
18005
18240
  const gb = (bytes) => bytes >= 1e9 ? `${(bytes / 1e9).toFixed(2)} GB` : `${(bytes / 1e6).toFixed(1)} MB`;
@@ -18050,7 +18285,7 @@ async function runSessionsDoctor(opts, rest) {
18050
18285
  try {
18051
18286
  lines.push(` ${color26.green("\u2713")} re-indexed ${await store.rebuildIndex()} session(s)`);
18052
18287
  } catch (err) {
18053
- lines.push(` ${color26.red("\u2717")} catalog rebuild failed: ${toErrorMessage14(err)}`);
18288
+ lines.push(` ${color26.red("\u2717")} catalog rebuild failed: ${toErrorMessage15(err)}`);
18054
18289
  }
18055
18290
  }
18056
18291
  for (const failure of repair.failed) {
@@ -18204,7 +18439,7 @@ function buildDoctorCommand(opts) {
18204
18439
  parsed = JSON.parse(stripBom(raw));
18205
18440
  } catch (err) {
18206
18441
  errorCount++;
18207
- const msg = toErrorMessage14(err);
18442
+ const msg = toErrorMessage15(err);
18208
18443
  lines.push(` ${color26.red("\u2717")} invalid JSON \u2014 ${msg}`);
18209
18444
  if (!applyFixes) {
18210
18445
  fixableCount++;
@@ -18574,7 +18809,7 @@ import {
18574
18809
  resolveAcpAgentCommand as resolveAcpAgentCommand3,
18575
18810
  runEnsemble as runEnsemble2
18576
18811
  } from "@wrongstack/acp";
18577
- import { toErrorMessage as toErrorMessage15 } from "@wrongstack/core/utils";
18812
+ import { toErrorMessage as toErrorMessage16 } from "@wrongstack/core/utils";
18578
18813
  function buildEnsembleCommand(opts) {
18579
18814
  return {
18580
18815
  name: "ensemble",
@@ -18664,7 +18899,7 @@ function buildEnsembleCommand(opts) {
18664
18899
  });
18665
18900
  return { message: renderEnsembleText2(result) };
18666
18901
  } catch (err) {
18667
- return { message: `Ensemble failed: ${toErrorMessage15(err)}` };
18902
+ return { message: `Ensemble failed: ${toErrorMessage16(err)}` };
18668
18903
  }
18669
18904
  }
18670
18905
  };
@@ -18756,7 +18991,7 @@ import {
18756
18991
  parseModelRef as parseModelRef3,
18757
18992
  simulateFallbackFailover
18758
18993
  } from "@wrongstack/core/agent";
18759
- import { color as color30, toErrorMessage as toErrorMessage16, updateJsonObjectFile as updateJsonObjectFile4 } from "@wrongstack/core/utils";
18994
+ import { color as color30, toErrorMessage as toErrorMessage17, updateJsonObjectFile as updateJsonObjectFile4 } from "@wrongstack/core/utils";
18760
18995
 
18761
18996
  // src/slash-commands/fallback-chain-view.ts
18762
18997
  import { runtimeFallbackChain, smartDefaultFallbackChain } from "@wrongstack/core/agent";
@@ -19338,7 +19573,7 @@ ${color30.dim("Add favorites first: /fallback fav add <ref>, or fix provider mod
19338
19573
  };
19339
19574
  } catch (err) {
19340
19575
  return {
19341
- message: `${color30.red("fallback error")}: ${toErrorMessage16(err)}`
19576
+ message: `${color30.red("fallback error")}: ${toErrorMessage17(err)}`
19342
19577
  };
19343
19578
  }
19344
19579
  }
@@ -20285,7 +20520,7 @@ When the error confidence is low (< 0.85) or the problem spans multiple files,
20285
20520
  import { AGENTS_BY_PHASE as AGENTS_BY_PHASE2, summarizeDispatchLog } from "@wrongstack/core/agent-catalog";
20286
20521
  import { dispatchAgent as dispatchAgent3 } from "@wrongstack/core/coordination";
20287
20522
  import { sandboxTierForAgent } from "@wrongstack/core/sandbox";
20288
- import { color as color32, toErrorMessage as toErrorMessage17 } from "@wrongstack/core/utils";
20523
+ import { color as color32, toErrorMessage as toErrorMessage18 } from "@wrongstack/core/utils";
20289
20524
  var PHASE_ORDER = [
20290
20525
  { phase: "discovery", label: "1 \xB7 Discovery" },
20291
20526
  { phase: "planning", label: "2 \xB7 Planning" },
@@ -20601,7 +20836,7 @@ async function handleSpawn(opts, subargs) {
20601
20836
  const id = await opts.onFleetSpawn(role);
20602
20837
  spawned.push(id);
20603
20838
  } catch (err) {
20604
- const warnMsg = `${color32.red("\u2717 Spawn failed")} for slot ${i + 1}: ${toErrorMessage17(err)}`;
20839
+ const warnMsg = `${color32.red("\u2717 Spawn failed")} for slot ${i + 1}: ${toErrorMessage18(err)}`;
20605
20840
  opts.renderer.writeWarning(warnMsg);
20606
20841
  }
20607
20842
  }
@@ -20711,7 +20946,7 @@ ${msg2}` };
20711
20946
  const id = await opts.onFleetSpawn(decision.role);
20712
20947
  lines.push(` ${color32.green("\u2713 spawned")} ${color32.bold(decision.role)} as ${color32.dim(id)}`);
20713
20948
  } catch (err) {
20714
- lines.push(` ${color32.amber("\u26A0 spawn failed:")} ${toErrorMessage17(err)}`);
20949
+ lines.push(` ${color32.amber("\u26A0 spawn failed:")} ${toErrorMessage18(err)}`);
20715
20950
  }
20716
20951
  } else {
20717
20952
  lines.push(` ${color32.dim("(no fleet active \u2014 try spawning a task)")}`);
@@ -21076,7 +21311,7 @@ import {
21076
21311
  color as color34,
21077
21312
  configureChildEnvGitIdentity as configureChildEnvGitIdentity2,
21078
21313
  getChildEnvGitIdentity,
21079
- toErrorMessage as toErrorMessage18,
21314
+ toErrorMessage as toErrorMessage19,
21080
21315
  updateJsonObjectFile as updateJsonObjectFile5
21081
21316
  } from "@wrongstack/core/utils";
21082
21317
  function looksLikeEmail(s) {
@@ -21191,7 +21426,7 @@ function buildGitIdCommand(opts) {
21191
21426
  message: `${color34.red("Unknown subcommand")} "${sub}". Try ${color34.dim("/gitid")}, ${color34.dim("/gitid set <name...> <email>")}, or ${color34.dim("/gitid help")}.`
21192
21427
  };
21193
21428
  } catch (err) {
21194
- return { message: `${color34.red("gitid error")}: ${toErrorMessage18(err)}` };
21429
+ return { message: `${color34.red("gitid error")}: ${toErrorMessage19(err)}` };
21195
21430
  }
21196
21431
  }
21197
21432
  };
@@ -21391,12 +21626,22 @@ ${formatGoal(next, 0)}`,
21391
21626
  refinerModel: refinerTarget?.model,
21392
21627
  onUsage: (usage2, source) => journalGoalRefineUsage(opts, usage2, source)
21393
21628
  });
21394
- const updated = {
21395
- ...current,
21396
- refinedGoal: refined.refinedGoal,
21397
- deliverables: refined.deliverables
21398
- };
21399
- await saveGoal(goalPath, updated, opts.events);
21629
+ let updated;
21630
+ await updateGoal(
21631
+ goalPath,
21632
+ (latest) => {
21633
+ if (!latest || latest.goal !== current.goal) return latest;
21634
+ updated = {
21635
+ ...latest,
21636
+ refinedGoal: refined.refinedGoal,
21637
+ deliverables: refined.deliverables
21638
+ };
21639
+ return updated;
21640
+ },
21641
+ opts.events
21642
+ );
21643
+ if (!updated)
21644
+ return { message: "The mission changed while it was being refined; nothing was applied." };
21400
21645
  return { message: `\u2713 Mission refined.
21401
21646
 
21402
21647
  ${formatGoal(updated)}` };
@@ -21839,6 +22084,7 @@ function buildHelpCommand(opts) {
21839
22084
  }
21840
22085
 
21841
22086
  // src/slash-commands/init.ts
22087
+ import { constants as fsConstants2 } from "node:fs";
21842
22088
  import * as fs10 from "node:fs/promises";
21843
22089
  import * as path23 from "node:path";
21844
22090
  import { color as color36 } from "@wrongstack/core/utils";
@@ -21855,12 +22101,15 @@ function buildInitCommand(opts) {
21855
22101
  const detected = await detectProjectFacts(root);
21856
22102
  const body = renderAgentsTemplate(detected);
21857
22103
  await fs10.mkdir(dir, { recursive: true });
21858
- let backedUp = false;
22104
+ let backedUp;
21859
22105
  if (!isFirstInit) {
21860
22106
  try {
21861
- await fs10.copyFile(file, `${file}.bak`);
21862
- backedUp = true;
21863
- } catch {
22107
+ const current = await fs10.readFile(file, "utf8");
22108
+ backedUp = current === body ? void 0 : await backupWithoutClobbering(file, current);
22109
+ } catch (err) {
22110
+ const msg = `Did not rewrite ${file}: could not back it up first (${err instanceof Error ? err.message : String(err)}).`;
22111
+ opts.renderer.writeWarning(msg);
22112
+ return { message: msg };
21864
22113
  }
21865
22114
  }
21866
22115
  await fs10.writeFile(file, body, "utf8");
@@ -21875,7 +22124,7 @@ function buildInitCommand(opts) {
21875
22124
  lines.push(wroteMsg);
21876
22125
  opts.renderer.writeInfo(wroteMsg);
21877
22126
  if (backedUp) {
21878
- const backupLine = `Backed up the previous AGENTS.md to ${file}.bak`;
22127
+ const backupLine = `Backed up the previous AGENTS.md to ${backedUp}`;
21879
22128
  opts.renderer.writeInfo(backupLine);
21880
22129
  lines.push(backupLine);
21881
22130
  }
@@ -21902,6 +22151,19 @@ function buildInitCommand(opts) {
21902
22151
  }
21903
22152
  };
21904
22153
  }
22154
+ async function backupWithoutClobbering(file, current) {
22155
+ const primary = `${file}.bak`;
22156
+ try {
22157
+ await fs10.copyFile(file, primary, fsConstants2.COPYFILE_EXCL);
22158
+ return primary;
22159
+ } catch (err) {
22160
+ if (err.code !== "EEXIST") throw err;
22161
+ }
22162
+ if (await fs10.readFile(primary, "utf8") === current) return primary;
22163
+ const stamped = `${file}.${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.bak`;
22164
+ await fs10.copyFile(file, stamped, fsConstants2.COPYFILE_EXCL);
22165
+ return stamped;
22166
+ }
21905
22167
  async function fileExists(filePath) {
21906
22168
  try {
21907
22169
  await fs10.access(filePath);
@@ -23759,16 +24021,16 @@ function buildKanbanCommand(opts) {
23759
24021
 
23760
24022
  // src/slash-commands/mailbox.ts
23761
24023
  import {
23762
- getSharedProjectMailbox as getSharedProjectMailbox8,
24024
+ getSharedProjectMailbox as getSharedProjectMailbox9,
23763
24025
  mailboxSessionTag as mailboxSessionTag6,
23764
24026
  resolveMailboxIdentity,
23765
- resolveProjectDir as resolveProjectDir3
24027
+ resolveProjectDir as resolveProjectDir4
23766
24028
  } from "@wrongstack/core/coordination";
23767
- import { color as color42, wstackGlobalRoot as wstackGlobalRoot3 } from "@wrongstack/core/utils";
24029
+ import { color as color42, wstackGlobalRoot as wstackGlobalRoot4 } from "@wrongstack/core/utils";
23768
24030
  function buildMailbox(opts) {
23769
- const projectDir = opts.paths?.projectDir ?? resolveProjectDir3(opts.projectRoot, wstackGlobalRoot3());
24031
+ const projectDir = opts.paths?.projectDir ?? resolveProjectDir4(opts.projectRoot, wstackGlobalRoot4());
23770
24032
  try {
23771
- return getSharedProjectMailbox8(projectDir);
24033
+ return getSharedProjectMailbox9(projectDir);
23772
24034
  } catch {
23773
24035
  return null;
23774
24036
  }
@@ -24090,15 +24352,15 @@ function buildMailboxCommand(opts) {
24090
24352
 
24091
24353
  // src/slash-commands/mailbox-demo.ts
24092
24354
  import {
24093
- getSharedProjectMailbox as getSharedProjectMailbox9,
24094
- resolveProjectDir as resolveProjectDir4
24355
+ getSharedProjectMailbox as getSharedProjectMailbox10,
24356
+ resolveProjectDir as resolveProjectDir5
24095
24357
  } from "@wrongstack/core/coordination";
24096
- import { wstackGlobalRoot as wstackGlobalRoot4 } from "@wrongstack/core/utils";
24358
+ import { wstackGlobalRoot as wstackGlobalRoot5 } from "@wrongstack/core/utils";
24097
24359
  var DEMO_AGENT_ID = "mailbox-demo";
24098
24360
  function buildMailbox2(opts) {
24099
- const projectDir = opts.paths?.projectDir ?? resolveProjectDir4(opts.projectRoot, wstackGlobalRoot4());
24361
+ const projectDir = opts.paths?.projectDir ?? resolveProjectDir5(opts.projectRoot, wstackGlobalRoot5());
24100
24362
  try {
24101
- return getSharedProjectMailbox9(projectDir);
24363
+ return getSharedProjectMailbox10(projectDir);
24102
24364
  } catch {
24103
24365
  return null;
24104
24366
  }
@@ -24288,8 +24550,8 @@ import * as fs11 from "node:fs/promises";
24288
24550
  import * as os3 from "node:os";
24289
24551
  import * as path24 from "node:path";
24290
24552
  import { cliSpawnArgs as cliSpawnArgs2 } from "@wrongstack/core/utils";
24291
- import { resolveProjectDir as resolveProjectDir5 } from "@wrongstack/core/coordination";
24292
- import { wstackGlobalRoot as wstackGlobalRoot5 } from "@wrongstack/core/utils";
24553
+ import { resolveProjectDir as resolveProjectDir6 } from "@wrongstack/core/coordination";
24554
+ import { wstackGlobalRoot as wstackGlobalRoot6 } from "@wrongstack/core/utils";
24293
24555
  function buildMailboxServeCommand(opts) {
24294
24556
  return {
24295
24557
  name: "mailbox-serve",
@@ -24328,7 +24590,7 @@ function buildMailboxServeCommand(opts) {
24328
24590
  else if (tok === "--host" || tok === "--port") flags.push(tok);
24329
24591
  }
24330
24592
  const cwd = opts.paths?.projectDir ?? opts.cwd;
24331
- const projectDir = resolveProjectDir5(cwd, wstackGlobalRoot5());
24593
+ const projectDir = resolveProjectDir6(cwd, wstackGlobalRoot6());
24332
24594
  const tokenPath = path24.join(projectDir, ".mailbox.token");
24333
24595
  const pidFile = path24.join(
24334
24596
  os3.tmpdir(),
@@ -24711,12 +24973,12 @@ function errorMessage(err) {
24711
24973
  }
24712
24974
 
24713
24975
  // src/slash-commands/memory.ts
24714
- import { toErrorMessage as toErrorMessage24 } from "@wrongstack/core/utils";
24976
+ import { toErrorMessage as toErrorMessage25 } from "@wrongstack/core/utils";
24715
24977
  import { getSageSurface as getSageSurface5 } from "@wrongstack/sage";
24716
24978
  import { runSearchRace } from "@wrongstack/vector-memory";
24717
24979
 
24718
24980
  // src/slash-commands/memory-audience.ts
24719
- import { toErrorMessage as toErrorMessage19 } from "@wrongstack/core/utils";
24981
+ import { toErrorMessage as toErrorMessage20 } from "@wrongstack/core/utils";
24720
24982
  function parseAudienceFlags(tokens) {
24721
24983
  const out = { errors: [] };
24722
24984
  for (let i = 0; i < tokens.length; i++) {
@@ -24845,7 +25107,7 @@ async function runAudienceMemory(store, rest) {
24845
25107
  message: `Remembered \`${memory.id}\` for ${formatAudienceSelector(memory.audience)}: ${memory.text}`
24846
25108
  };
24847
25109
  } catch (err) {
24848
- return { message: `Could not remember: ${toErrorMessage19(err)}` };
25110
+ return { message: `Could not remember: ${toErrorMessage20(err)}` };
24849
25111
  }
24850
25112
  }
24851
25113
  if (sub === "clear") {
@@ -24857,7 +25119,7 @@ async function runAudienceMemory(store, rest) {
24857
25119
  message: `Cleared audience scope from \`${id}\` \u2014 it is now general project memory.`
24858
25120
  };
24859
25121
  } catch (err) {
24860
- return { message: `Could not clear audience: ${toErrorMessage19(err)}` };
25122
+ return { message: `Could not clear audience: ${toErrorMessage20(err)}` };
24861
25123
  }
24862
25124
  }
24863
25125
  if (sub === "search" || sub === "find") {
@@ -25015,7 +25277,7 @@ async function runAudienceMemory(store, rest) {
25015
25277
  }
25016
25278
 
25017
25279
  // src/slash-commands/memory-compact.ts
25018
- import { toErrorMessage as toErrorMessage20 } from "@wrongstack/core/utils";
25280
+ import { toErrorMessage as toErrorMessage21 } from "@wrongstack/core/utils";
25019
25281
  import { getSageSurface as getSageSurface2 } from "@wrongstack/sage";
25020
25282
  var COMPACT_SYSTEM_PROMPT = `You are a memory curator. Your task is to review, deduplicate, and improve a set of long-term memory entries.
25021
25283
 
@@ -25127,7 +25389,7 @@ async function runCompact(opts) {
25127
25389
  responseText = response.content.filter((b) => b.type === "text").map((b) => b.text).join("").trim();
25128
25390
  } catch (err) {
25129
25391
  return {
25130
- message: `LLM call failed: ${toErrorMessage20(err)}`
25392
+ message: `LLM call failed: ${toErrorMessage21(err)}`
25131
25393
  };
25132
25394
  }
25133
25395
  if (!responseText) {
@@ -25143,7 +25405,7 @@ ${responseText.slice(0, 500)}` };
25143
25405
  parsed = JSON.parse(jsonMatch[0]);
25144
25406
  } catch (err) {
25145
25407
  return {
25146
- message: `Failed to parse LLM response: ${toErrorMessage20(err)}
25408
+ message: `Failed to parse LLM response: ${toErrorMessage21(err)}
25147
25409
 
25148
25410
  Raw response:
25149
25411
  ${responseText.slice(0, 500)}`
@@ -25216,7 +25478,7 @@ ${responseText.slice(0, 500)}`
25216
25478
  }
25217
25479
  }
25218
25480
  } catch (err) {
25219
- errors.push(`${op.action} failed for ${op.targets.join(", ")}: ${toErrorMessage20(err)}`);
25481
+ errors.push(`${op.action} failed for ${op.targets.join(", ")}: ${toErrorMessage21(err)}`);
25220
25482
  }
25221
25483
  }
25222
25484
  const lines = ["## Memory Compact \u2014 Complete"];
@@ -25717,7 +25979,7 @@ function formatSearchRace(race) {
25717
25979
  }
25718
25980
 
25719
25981
  // src/slash-commands/memory-gather.ts
25720
- import { toErrorMessage as toErrorMessage21 } from "@wrongstack/core/utils";
25982
+ import { toErrorMessage as toErrorMessage22 } from "@wrongstack/core/utils";
25721
25983
  import { getSageSurface as getSageSurface3, SAGE_KINDS } from "@wrongstack/sage";
25722
25984
  async function runPathMemory(store, targetPath, includeAncestors) {
25723
25985
  const Sage = getSageSurface3(store);
@@ -25888,12 +26150,12 @@ async function runGatherCommand(Sage, rest) {
25888
26150
  }
25889
26151
  return { message: lines.join("\n") };
25890
26152
  } catch (err) {
25891
- return { message: `gather failed: ${toErrorMessage21(err)}` };
26153
+ return { message: `gather failed: ${toErrorMessage22(err)}` };
25892
26154
  }
25893
26155
  }
25894
26156
 
25895
26157
  // src/slash-commands/memory-purge-domain-terms.ts
25896
- import { toErrorMessage as toErrorMessage22 } from "@wrongstack/core/utils";
26158
+ import { toErrorMessage as toErrorMessage23 } from "@wrongstack/core/utils";
25897
26159
  var DOMAIN_TERM_TAG2 = "domain-term";
25898
26160
  async function runPurgeDomainTerms(Sage, rest) {
25899
26161
  if (!Sage) return requiresSage("purge-domain-terms");
@@ -25947,7 +26209,7 @@ This is a one-off migration that permanently removes every SAGE memory tagged \`
25947
26209
  });
25948
26210
  deleted++;
25949
26211
  } catch (err) {
25950
- failures.push(`${t.id}: ${toErrorMessage22(err)}`);
26212
+ failures.push(`${t.id}: ${toErrorMessage23(err)}`);
25951
26213
  }
25952
26214
  }
25953
26215
  const tagSummary = /* @__PURE__ */ new Map();
@@ -25973,7 +26235,7 @@ The \`${DOMAIN_TERM_TAG2}\` tag is now absent from the live corpus. Run \`/memor
25973
26235
  };
25974
26236
  } catch (err) {
25975
26237
  return {
25976
- message: `purge-domain-terms failed: ${toErrorMessage22(err)}`
26238
+ message: `purge-domain-terms failed: ${toErrorMessage23(err)}`
25977
26239
  };
25978
26240
  }
25979
26241
  }
@@ -26107,7 +26369,7 @@ async function runStats(opts) {
26107
26369
 
26108
26370
  // src/slash-commands/memory-triage.ts
26109
26371
  import { resolveTypeSafeJudge as resolveTypeSafeJudge2 } from "@wrongstack/core/typesafe";
26110
- import { toErrorMessage as toErrorMessage23 } from "@wrongstack/core/utils";
26372
+ import { toErrorMessage as toErrorMessage24 } from "@wrongstack/core/utils";
26111
26373
  import {
26112
26374
  createSystemOneTriage,
26113
26375
  fileTriageProposals,
@@ -26231,7 +26493,7 @@ Usage: /memory triage [--dry-run|--apply] [--limit N] [--max-phase3 N] [--max-ph
26231
26493
  systemOne
26232
26494
  });
26233
26495
  } catch (err) {
26234
- return { message: `Triage failed: ${toErrorMessage23(err)}` };
26496
+ return { message: `Triage failed: ${toErrorMessage24(err)}` };
26235
26497
  }
26236
26498
  if (!dryRun) {
26237
26499
  const applyReport = await applyDispatch(Sage, report);
@@ -26291,7 +26553,7 @@ async function applyDispatch(Sage, report) {
26291
26553
  autoOk++;
26292
26554
  } catch (err) {
26293
26555
  autoFail++;
26294
- lines.push(` \u2717 Failed to update ${action.memoryId}: ${toErrorMessage23(err)}`);
26556
+ lines.push(` \u2717 Failed to update ${action.memoryId}: ${toErrorMessage24(err)}`);
26295
26557
  }
26296
26558
  }
26297
26559
  lines.push(`**Auto-apply:** ${autoOk} succeeded, ${autoFail} failed`);
@@ -26315,7 +26577,7 @@ async function applyDispatch(Sage, report) {
26315
26577
  } catch (err) {
26316
26578
  mergeFail++;
26317
26579
  lines.push(
26318
- ` \u2717 Failed to merge ${merge.supersededId} \u2192 ${merge.keeperId}: ${toErrorMessage23(err)}`
26580
+ ` \u2717 Failed to merge ${merge.supersededId} \u2192 ${merge.keeperId}: ${toErrorMessage24(err)}`
26319
26581
  );
26320
26582
  }
26321
26583
  }
@@ -26401,7 +26663,7 @@ function buildMemoryCommand(opts) {
26401
26663
  message: `Remembered \`${memory.id}\` [${memory.kind}] ${memory.text}${tags}`
26402
26664
  };
26403
26665
  } catch (err) {
26404
- return { message: `Could not remember: ${toErrorMessage24(err)}` };
26666
+ return { message: `Could not remember: ${toErrorMessage25(err)}` };
26405
26667
  }
26406
26668
  }
26407
26669
  case "update":
@@ -26439,7 +26701,7 @@ function buildMemoryCommand(opts) {
26439
26701
  message: `Updated \`${memory.id}\` [${memory.kind}|${memory.status}] ${memory.text}`
26440
26702
  };
26441
26703
  } catch (err) {
26442
- return { message: `Could not update: ${toErrorMessage24(err)}` };
26704
+ return { message: `Could not update: ${toErrorMessage25(err)}` };
26443
26705
  }
26444
26706
  }
26445
26707
  case "delete":
@@ -26454,7 +26716,7 @@ function buildMemoryCommand(opts) {
26454
26716
  await Sage.deleteSage(id, reason, { force: true });
26455
26717
  return { message: `Deleted \`${id}\`.` };
26456
26718
  } catch (err) {
26457
- return { message: `Could not delete: ${toErrorMessage24(err)}` };
26719
+ return { message: `Could not delete: ${toErrorMessage25(err)}` };
26458
26720
  }
26459
26721
  }
26460
26722
  case "forget":
@@ -26718,7 +26980,7 @@ function buildMemoryCommand(opts) {
26718
26980
  File size reduced. Audit-logged as \`memory.log_compacted\`.`
26719
26981
  };
26720
26982
  } catch (err) {
26721
- return { message: `Compaction failed: ${toErrorMessage24(err)}` };
26983
+ return { message: `Compaction failed: ${toErrorMessage25(err)}` };
26722
26984
  }
26723
26985
  }
26724
26986
  case "stats": {
@@ -27201,7 +27463,7 @@ function buildModelCapsCommand(opts) {
27201
27463
  import {
27202
27464
  ToolValidationError as ToolValidationError3
27203
27465
  } from "@wrongstack/core/types";
27204
- import { color as color46, toErrorMessage as toErrorMessage25, updateJsonObjectFile as updateJsonObjectFile6 } from "@wrongstack/core/utils";
27466
+ import { color as color46, toErrorMessage as toErrorMessage26, updateJsonObjectFile as updateJsonObjectFile6 } from "@wrongstack/core/utils";
27205
27467
  async function patchProfileConfig(mutate, profileConfigPath) {
27206
27468
  return updateJsonObjectFile6(profileConfigPath, async (config) => {
27207
27469
  await backupCurrent(void 0, profileConfigPath);
@@ -27410,7 +27672,7 @@ function buildModelsCommand(opts) {
27410
27672
  };
27411
27673
  } catch (err) {
27412
27674
  return {
27413
- message: `${color46.red("models error")}: ${toErrorMessage25(err)}`
27675
+ message: `${color46.red("models error")}: ${toErrorMessage26(err)}`
27414
27676
  };
27415
27677
  }
27416
27678
  }
@@ -27566,7 +27828,7 @@ function handleList2(opts) {
27566
27828
  // src/slash-commands/nextsteps-mode.ts
27567
27829
  import { noOpVault as noOpVault3 } from "@wrongstack/core/security";
27568
27830
  import { NEXT_STEPS_MODES as NEXT_STEPS_MODES2, resolveNextStepsMode } from "@wrongstack/core/types";
27569
- import { color as color48, toErrorMessage as toErrorMessage26 } from "@wrongstack/core/utils";
27831
+ import { color as color48, toErrorMessage as toErrorMessage27 } from "@wrongstack/core/utils";
27570
27832
  var NEXT_STEPS_LIMIT_PRESETS = [5, 10, 20, 50, 100, 0];
27571
27833
  var UNLIMITED_WORDS = /* @__PURE__ */ new Set(["unlimited", "inf", "infinite", "\u221E", "sonsuz", "0"]);
27572
27834
  function parseNextStepsLimit(raw) {
@@ -27655,7 +27917,7 @@ function buildNextStepsModeCommand(opts) {
27655
27917
  (target) => apply(target)
27656
27918
  );
27657
27919
  } catch (err) {
27658
- return { message: `${color48.red("Failed to save")}: ${toErrorMessage26(err)}` };
27920
+ return { message: `${color48.red("Failed to save")}: ${toErrorMessage27(err)}` };
27659
27921
  }
27660
27922
  const liveAutonomy = { ...opts.configStore.get().autonomy ?? {} };
27661
27923
  apply(liveAutonomy);
@@ -27910,7 +28172,7 @@ import {
27910
28172
  readSessionPermissionOverrides,
27911
28173
  setSessionPermissionOverrides
27912
28174
  } from "@wrongstack/core/security";
27913
- import { color as color50, toErrorMessage as toErrorMessage27 } from "@wrongstack/core/utils";
28175
+ import { color as color50, toErrorMessage as toErrorMessage28 } from "@wrongstack/core/utils";
27914
28176
  var HELP2 = [
27915
28177
  "Usage:",
27916
28178
  " /permissions List this session\u2019s allow/deny rules",
@@ -27996,7 +28258,7 @@ ${formatPermissionRules(rules)}` };
27996
28258
 
27997
28259
  ${formatExplainedCall(explained)}` };
27998
28260
  } catch (err) {
27999
- return { message: color50.red(`Explain failed: ${toErrorMessage27(err)}`) };
28261
+ return { message: color50.red(`Explain failed: ${toErrorMessage28(err)}`) };
28000
28262
  }
28001
28263
  }
28002
28264
  let next;
@@ -28051,7 +28313,7 @@ ${HELP2}`) };
28051
28313
  try {
28052
28314
  await setSessionPermissionOverrides(ctx, next);
28053
28315
  } catch (err) {
28054
- return { message: color50.red(`Could not save the session rule: ${toErrorMessage27(err)}`) };
28316
+ return { message: color50.red(`Could not save the session rule: ${toErrorMessage28(err)}`) };
28055
28317
  }
28056
28318
  return { message: color50.green(done) };
28057
28319
  }
@@ -28915,7 +29177,7 @@ function buildPruneCommand(opts) {
28915
29177
 
28916
29178
  // src/slash-commands/refiner.ts
28917
29179
  import { noOpVault as noOpVault4 } from "@wrongstack/core/security";
28918
- import { color as color54, toErrorMessage as toErrorMessage28 } from "@wrongstack/core/utils";
29180
+ import { color as color54, toErrorMessage as toErrorMessage29 } from "@wrongstack/core/utils";
28919
29181
  function buildRefinerCommand(opts) {
28920
29182
  const help = [
28921
29183
  "Usage:",
@@ -29015,7 +29277,7 @@ function buildRefinerCommand(opts) {
29015
29277
  };
29016
29278
  } catch (err) {
29017
29279
  return {
29018
- message: `${color54.red("refiner error")}: ${toErrorMessage28(err)}`
29280
+ message: `${color54.red("refiner error")}: ${toErrorMessage29(err)}`
29019
29281
  };
29020
29282
  }
29021
29283
  }
@@ -29037,7 +29299,7 @@ function buildRefinerCommand(opts) {
29037
29299
  };
29038
29300
  } catch (err) {
29039
29301
  return {
29040
- message: `${color54.red("refiner error")}: ${toErrorMessage28(err)}`
29302
+ message: `${color54.red("refiner error")}: ${toErrorMessage29(err)}`
29041
29303
  };
29042
29304
  }
29043
29305
  }
@@ -30504,11 +30766,11 @@ ${sddHelp()}`
30504
30766
  // src/slash-commands/session.ts
30505
30767
  import * as path26 from "node:path";
30506
30768
  import { extractInterruptedTools, SessionRecovery as SessionRecovery2 } from "@wrongstack/core/storage";
30507
- import { color as color57, toErrorMessage as toErrorMessage30 } from "@wrongstack/core/utils";
30769
+ import { color as color57, toErrorMessage as toErrorMessage31 } from "@wrongstack/core/utils";
30508
30770
 
30509
30771
  // src/slash-commands/session-live-status.ts
30510
30772
  import { getSessionRegistry as getSessionRegistry3 } from "@wrongstack/core/storage";
30511
- import { color as color56, isPidAlive as isPidAlive2, toErrorMessage as toErrorMessage29 } from "@wrongstack/core/utils";
30773
+ import { color as color56, isPidAlive as isPidAlive2, toErrorMessage as toErrorMessage30 } from "@wrongstack/core/utils";
30512
30774
  function statusIcon2(status) {
30513
30775
  switch (status) {
30514
30776
  case "active":
@@ -30803,7 +31065,7 @@ async function killSession(sessionId, confirm) {
30803
31065
  };
30804
31066
  } catch (err) {
30805
31067
  return {
30806
- message: color56.red(`Failed to kill session: ${toErrorMessage29(err)}`)
31068
+ message: color56.red(`Failed to kill session: ${toErrorMessage30(err)}`)
30807
31069
  };
30808
31070
  }
30809
31071
  }
@@ -30874,7 +31136,7 @@ function buildLoadCommand(opts) {
30874
31136
  message: name ? color57.green(`Renamed ${targetId} \u2192 "${name}"`) : color57.green(`Cleared name on ${targetId} (title: "${summary.title}")`)
30875
31137
  };
30876
31138
  } catch (err) {
30877
- return { message: color57.red(`Rename failed: ${toErrorMessage30(err)}`) };
31139
+ return { message: color57.red(`Rename failed: ${toErrorMessage31(err)}`) };
30878
31140
  }
30879
31141
  }
30880
31142
  if (first === "move") {
@@ -30904,7 +31166,7 @@ function buildLoadCommand(opts) {
30904
31166
  });
30905
31167
  return { message: color57.green(describeSessionMove(result)) };
30906
31168
  } catch (err) {
30907
- return { message: color57.red(`Move failed: ${toErrorMessage30(err)}`) };
31169
+ return { message: color57.red(`Move failed: ${toErrorMessage31(err)}`) };
30908
31170
  }
30909
31171
  }
30910
31172
  if (first === "archive") {
@@ -30924,7 +31186,7 @@ function buildLoadCommand(opts) {
30924
31186
  )
30925
31187
  };
30926
31188
  } catch (err) {
30927
- return { message: color57.red(`Archive failed: ${toErrorMessage30(err)}`) };
31189
+ return { message: color57.red(`Archive failed: ${toErrorMessage31(err)}`) };
30928
31190
  }
30929
31191
  }
30930
31192
  if (!apply) {
@@ -30964,7 +31226,7 @@ function buildLoadCommand(opts) {
30964
31226
  message: result.action === "rehydrated" ? color57.green(`Rehydrated ${targetId}`) : color57.dim(`Rehydrate ${result.action}: ${targetId}`)
30965
31227
  };
30966
31228
  } catch (err) {
30967
- return { message: color57.red(`Rehydrate failed: ${toErrorMessage30(err)}`) };
31229
+ return { message: color57.red(`Rehydrate failed: ${toErrorMessage31(err)}`) };
30968
31230
  }
30969
31231
  }
30970
31232
  if (first === "delete") {
@@ -30995,7 +31257,7 @@ function buildLoadCommand(opts) {
30995
31257
  await opts.sessionStore.delete(targetId);
30996
31258
  return { message: color57.green(`Deleted session ${targetId}`) };
30997
31259
  } catch (err) {
30998
- return { message: color57.red(`Delete failed: ${toErrorMessage30(err)}`) };
31260
+ return { message: color57.red(`Delete failed: ${toErrorMessage31(err)}`) };
30999
31261
  }
31000
31262
  }
31001
31263
  const showIncomplete = parts.includes("--incomplete") || parts.includes("-i");
@@ -31157,7 +31419,7 @@ import {
31157
31419
  isReasoningEffort as isReasoningEffort2,
31158
31420
  REASONING_EFFORT_LEVELS as REASONING_EFFORT_LEVELS2
31159
31421
  } from "@wrongstack/core/types";
31160
- import { color as color58, expectDefined as expectDefined9, toErrorMessage as toErrorMessage31, updateJsonObjectFile as updateJsonObjectFile7 } from "@wrongstack/core/utils";
31422
+ import { color as color58, expectDefined as expectDefined9, toErrorMessage as toErrorMessage32, updateJsonObjectFile as updateJsonObjectFile7 } from "@wrongstack/core/utils";
31161
31423
  import { catalogProviderIdFor as catalogProviderIdFor5 } from "@wrongstack/providers";
31162
31424
  async function resolveCatalogModelIds(registry, config, providerIds) {
31163
31425
  const out = /* @__PURE__ */ new Map();
@@ -31697,7 +31959,7 @@ function buildSetModelCommand(opts) {
31697
31959
  };
31698
31960
  } catch (err) {
31699
31961
  return {
31700
- message: `${color58.red("setmodel error")}: ${toErrorMessage31(err)}`
31962
+ message: `${color58.red("setmodel error")}: ${toErrorMessage32(err)}`
31701
31963
  };
31702
31964
  }
31703
31965
  }
@@ -32030,7 +32292,7 @@ ${help}`) };
32030
32292
  import { execFile as execFile2 } from "node:child_process";
32031
32293
  import { access as access3 } from "node:fs/promises";
32032
32294
  import * as path27 from "node:path";
32033
- import { color as color60, toErrorMessage as toErrorMessage32 } from "@wrongstack/core/utils";
32295
+ import { color as color60, toErrorMessage as toErrorMessage33 } from "@wrongstack/core/utils";
32034
32296
  import { parseNextSteps } from "@wrongstack/tools/next-steps";
32035
32297
  function readGitStatus(projectRoot, includeBranch) {
32036
32298
  const args = ["status", "--short"];
@@ -32171,7 +32433,7 @@ function buildSuggestCommand(opts) {
32171
32433
  return { message: formatSuggestions(suggestions) };
32172
32434
  } catch (err) {
32173
32435
  if (!isCurrent()) return superseded();
32174
- const msg = `Suggestion generation failed: ${toErrorMessage32(err)}`;
32436
+ const msg = `Suggestion generation failed: ${toErrorMessage33(err)}`;
32175
32437
  opts.renderer.writeWarning(msg);
32176
32438
  return { message: msg };
32177
32439
  }
@@ -32480,7 +32742,7 @@ function buildThemeCommand(opts) {
32480
32742
 
32481
32743
  // src/slash-commands/tier.ts
32482
32744
  import { leaderTierPolicy, listTierIds, resolveTier } from "@wrongstack/core/coordination";
32483
- import { color as color62, toErrorMessage as toErrorMessage33, updateJsonObjectFile as updateJsonObjectFile8 } from "@wrongstack/core/utils";
32745
+ import { color as color62, toErrorMessage as toErrorMessage34, updateJsonObjectFile as updateJsonObjectFile8 } from "@wrongstack/core/utils";
32484
32746
  var LEADER_MODES = ["off", "propose", "auto"];
32485
32747
  var DECIMAL_RE2 = /^(?:\d+(?:\.\d*)?|\.\d+)$/;
32486
32748
  var INTEGER_RE2 = /^\d+$/;
@@ -32797,7 +33059,7 @@ function buildTierCommand(opts) {
32797
33059
  message: `${color62.red("Unknown subcommand")} "${sub}". Try ${color62.dim("/tier")} or ${color62.dim("/tier help")}.`
32798
33060
  };
32799
33061
  } catch (err) {
32800
- return { message: `${color62.red("tier error")}: ${toErrorMessage33(err)}` };
33062
+ return { message: `${color62.red("tier error")}: ${toErrorMessage34(err)}` };
32801
33063
  }
32802
33064
  }
32803
33065
  };
@@ -34289,7 +34551,7 @@ function buildSecurityCommand(opts) {
34289
34551
  import { color as color74 } from "@wrongstack/core/utils";
34290
34552
 
34291
34553
  // src/slash-commands/settings-mutations.ts
34292
- import { color as color72, toErrorMessage as toErrorMessage34 } from "@wrongstack/core/utils";
34554
+ import { color as color72, toErrorMessage as toErrorMessage35 } from "@wrongstack/core/utils";
34293
34555
 
34294
34556
  // src/slash-commands/settings-context-mutations.ts
34295
34557
  import { color as color66 } from "@wrongstack/core/utils";
@@ -35453,7 +35715,7 @@ async function executeSettingsSubcommand(sub, rest, opts) {
35453
35715
  };
35454
35716
  } catch (err) {
35455
35717
  return {
35456
- message: `${color72.red("Settings error")}: ${toErrorMessage34(err)}`
35718
+ message: `${color72.red("Settings error")}: ${toErrorMessage35(err)}`
35457
35719
  };
35458
35720
  }
35459
35721
  }
@@ -36021,7 +36283,7 @@ function buildSidebarCommand(opts) {
36021
36283
  }
36022
36284
 
36023
36285
  // src/slash-commands/spawn-agents.ts
36024
- import { toErrorMessage as toErrorMessage35 } from "@wrongstack/core/utils";
36286
+ import { toErrorMessage as toErrorMessage36 } from "@wrongstack/core/utils";
36025
36287
  function buildSpawnCommand(opts) {
36026
36288
  return {
36027
36289
  name: "spawn",
@@ -36058,7 +36320,7 @@ function buildSpawnCommand(opts) {
36058
36320
  const summary = Object.keys(parsed).length > 0 ? await opts.onSpawn(description, parsed) : await opts.onSpawn(description);
36059
36321
  return { message: summary };
36060
36322
  } catch (err) {
36061
- return { message: `Spawn failed: ${toErrorMessage35(err)}` };
36323
+ return { message: `Spawn failed: ${toErrorMessage36(err)}` };
36062
36324
  }
36063
36325
  }
36064
36326
  };
@@ -36343,7 +36605,7 @@ function buildSupervisorCommand(opts) {
36343
36605
  }
36344
36606
 
36345
36607
  // src/slash-commands/tasks.ts
36346
- import { randomUUID as randomUUID10 } from "node:crypto";
36608
+ import { randomUUID as randomUUID11 } from "node:crypto";
36347
36609
  import {
36348
36610
  addPlanItem as addPlanItem2,
36349
36611
  formatPlan as formatPlan2,
@@ -36508,7 +36770,7 @@ ${formatPlan2(updated)}`;
36508
36770
  const title = parts.join(" ");
36509
36771
  const now = (/* @__PURE__ */ new Date()).toISOString();
36510
36772
  file.tasks.push({
36511
- id: `task_${randomUUID10()}`,
36773
+ id: `task_${randomUUID11()}`,
36512
36774
  title,
36513
36775
  type,
36514
36776
  priority,
@@ -36678,7 +36940,7 @@ ${formatTaskProgress(file.tasks)}`;
36678
36940
  ];
36679
36941
  if (found.item.description) {
36680
36942
  todos.push({
36681
- id: `todo_${randomUUID10()}`,
36943
+ id: `todo_${randomUUID11()}`,
36682
36944
  content: found.item.description.slice(0, 200),
36683
36945
  status: "pending",
36684
36946
  promotedFromTask: found.item.id
@@ -36764,7 +37026,7 @@ ${formatTaskProgress(file.tasks)}`;
36764
37026
  // src/slash-commands/techstack.ts
36765
37027
  import * as fs15 from "node:fs/promises";
36766
37028
  import * as path30 from "node:path";
36767
- import { color as color78, toErrorMessage as toErrorMessage36 } from "@wrongstack/core/utils";
37029
+ import { color as color78, toErrorMessage as toErrorMessage37 } from "@wrongstack/core/utils";
36768
37030
  async function discoverPackageFiles(projectRoot) {
36769
37031
  const files = [];
36770
37032
  const rootPkg = path30.join(projectRoot, "package.json");
@@ -36972,7 +37234,7 @@ function buildTechStackCommand(opts) {
36972
37234
  message: `TechStack remediation finished: ${applied} applied, ${failed} failed, ${skipped} skipped.`
36973
37235
  };
36974
37236
  } catch (err) {
36975
- const msg = `TechStack remediation failed: ${toErrorMessage36(err)}`;
37237
+ const msg = `TechStack remediation failed: ${toErrorMessage37(err)}`;
36976
37238
  opts.renderer.writeWarning(msg);
36977
37239
  return { message: msg };
36978
37240
  } finally {
@@ -36991,7 +37253,7 @@ function buildTechStackCommand(opts) {
36991
37253
  message: `TechStack inventory complete: ${snapshot.workspaces.length} workspaces, ${snapshot.dependencies.length} dependencies (fingerprint: ${snapshot.fingerprint})`
36992
37254
  };
36993
37255
  } catch (err) {
36994
- const msg = `TechStack inventory failed: ${toErrorMessage36(err)}`;
37256
+ const msg = `TechStack inventory failed: ${toErrorMessage37(err)}`;
36995
37257
  opts.renderer.writeWarning(msg);
36996
37258
  return { message: msg };
36997
37259
  }
@@ -37006,7 +37268,7 @@ function buildTechStackCommand(opts) {
37006
37268
  );
37007
37269
  }
37008
37270
  } catch (err) {
37009
- discoveryNote = color78.red(`Could not scan for package files: ${toErrorMessage36(err)}`);
37271
+ discoveryNote = color78.red(`Could not scan for package files: ${toErrorMessage37(err)}`);
37010
37272
  }
37011
37273
  const task = buildTechStackTask({
37012
37274
  projectRoot: opts.projectRoot,
@@ -37046,7 +37308,7 @@ function buildTechStackCommand(opts) {
37046
37308
  });
37047
37309
  return { message: summary };
37048
37310
  } catch (err) {
37049
- const msg = `Tech stack scan failed: ${toErrorMessage36(err)}`;
37311
+ const msg = `Tech stack scan failed: ${toErrorMessage37(err)}`;
37050
37312
  opts.renderer.writeWarning(msg);
37051
37313
  return { message: msg };
37052
37314
  }
@@ -37055,7 +37317,7 @@ function buildTechStackCommand(opts) {
37055
37317
  }
37056
37318
 
37057
37319
  // src/slash-commands/telegram-settings.ts
37058
- import { color as color80, toErrorMessage as toErrorMessage37 } from "@wrongstack/core/utils";
37320
+ import { color as color80, toErrorMessage as toErrorMessage38 } from "@wrongstack/core/utils";
37059
37321
 
37060
37322
  // src/slash-commands/telegram-setup.ts
37061
37323
  import { color as color79 } from "@wrongstack/core/utils";
@@ -37553,7 +37815,7 @@ function buildTelegramSettingsCommand(opts) {
37553
37815
  };
37554
37816
  } catch (err) {
37555
37817
  return {
37556
- message: `${color80.red("Settings error")}: ${toErrorMessage37(err)}`
37818
+ message: `${color80.red("Settings error")}: ${toErrorMessage38(err)}`
37557
37819
  };
37558
37820
  }
37559
37821
  }
@@ -37561,7 +37823,7 @@ function buildTelegramSettingsCommand(opts) {
37561
37823
  }
37562
37824
 
37563
37825
  // src/slash-commands/todos.ts
37564
- import { randomUUID as randomUUID11 } from "node:crypto";
37826
+ import { randomUUID as randomUUID12 } from "node:crypto";
37565
37827
  import { formatTodosList as formatTodosList2 } from "@wrongstack/core/utils";
37566
37828
  import { todoTool as todoTool3 } from "@wrongstack/tools";
37567
37829
  function findTodo(todos, query) {
@@ -37621,7 +37883,7 @@ function buildTodosCommand(opts) {
37621
37883
  return { message: "This Todo list is a Kanban projection. Add the task in Kanban." };
37622
37884
  }
37623
37885
  const item = {
37624
- id: `todo_${Date.now()}_${randomUUID11().slice(0, 7)}`,
37886
+ id: `todo_${Date.now()}_${randomUUID12().slice(0, 7)}`,
37625
37887
  content: restJoined,
37626
37888
  status: "pending"
37627
37889
  };
@@ -37726,7 +37988,7 @@ import {
37726
37988
  normalizeToolDescriptionMode,
37727
37989
  normalizeToolResultRenderMode,
37728
37990
  setToolResultRenderMode,
37729
- toErrorMessage as toErrorMessage38
37991
+ toErrorMessage as toErrorMessage39
37730
37992
  } from "@wrongstack/core/utils";
37731
37993
 
37732
37994
  // src/slash-commands/tool-auto-thin-commands.ts
@@ -38251,7 +38513,7 @@ function buildToolCommand(opts) {
38251
38513
  try {
38252
38514
  return { message: await cmdEnableAll() };
38253
38515
  } catch (err) {
38254
- return { message: `${color82.red("Error")}: ${toErrorMessage38(err)}` };
38516
+ return { message: `${color82.red("Error")}: ${toErrorMessage39(err)}` };
38255
38517
  }
38256
38518
  }
38257
38519
  if (sub === "autothin" || sub === "auto-thin") {
@@ -38279,7 +38541,7 @@ function buildToolCommand(opts) {
38279
38541
  };
38280
38542
  }
38281
38543
  } catch (err) {
38282
- return { message: `${color82.red("Error")}: ${toErrorMessage38(err)}` };
38544
+ return { message: `${color82.red("Error")}: ${toErrorMessage39(err)}` };
38283
38545
  }
38284
38546
  }
38285
38547
  const name = parts[0] ?? "";
@@ -38293,7 +38555,7 @@ function buildToolCommand(opts) {
38293
38555
  for (const t of targets) results.push(await cmdDisable(t));
38294
38556
  return { message: results.join("\n") };
38295
38557
  } catch (err) {
38296
- return { message: `${color82.red("Error")}: ${toErrorMessage38(err)}` };
38558
+ return { message: `${color82.red("Error")}: ${toErrorMessage39(err)}` };
38297
38559
  }
38298
38560
  }
38299
38561
  if (sub === "enable") {
@@ -38305,7 +38567,7 @@ function buildToolCommand(opts) {
38305
38567
  for (const t of targets) results.push(await cmdEnable(t));
38306
38568
  return { message: results.join("\n") };
38307
38569
  } catch (err) {
38308
- return { message: `${color82.red("Error")}: ${toErrorMessage38(err)}` };
38570
+ return { message: `${color82.red("Error")}: ${toErrorMessage39(err)}` };
38309
38571
  }
38310
38572
  }
38311
38573
  const action = parts[1]?.toLowerCase();
@@ -38318,7 +38580,7 @@ function buildToolCommand(opts) {
38318
38580
  try {
38319
38581
  return { message: action === "disable" ? await cmdDisable(name) : await cmdEnable(name) };
38320
38582
  } catch (err) {
38321
- return { message: `${color82.red("Error")}: ${toErrorMessage38(err)}` };
38583
+ return { message: `${color82.red("Error")}: ${toErrorMessage39(err)}` };
38322
38584
  }
38323
38585
  }
38324
38586
  if (!opts.toolRegistry.get(name) && !opts.toolRegistry.isDisabled(name)) {
@@ -38358,7 +38620,7 @@ function buildToolCommand(opts) {
38358
38620
  };
38359
38621
  } catch (err) {
38360
38622
  return {
38361
- message: `${color82.red("Could not save tool setting")}: ${toErrorMessage38(err)}`
38623
+ message: `${color82.red("Could not save tool setting")}: ${toErrorMessage39(err)}`
38362
38624
  };
38363
38625
  }
38364
38626
  }
@@ -38378,7 +38640,7 @@ function buildToolCommand(opts) {
38378
38640
  };
38379
38641
  } catch (err) {
38380
38642
  return {
38381
- message: `${color82.red("Could not save tool setting")}: ${toErrorMessage38(err)}`
38643
+ message: `${color82.red("Could not save tool setting")}: ${toErrorMessage39(err)}`
38382
38644
  };
38383
38645
  }
38384
38646
  }
@@ -39306,7 +39568,7 @@ function summaryLine(findings, fixable, handoffs, power) {
39306
39568
  // src/slash-commands/working-dir.ts
39307
39569
  import * as fs17 from "node:fs/promises";
39308
39570
  import * as path32 from "node:path";
39309
- import { color as color85, toErrorMessage as toErrorMessage39 } from "@wrongstack/core/utils";
39571
+ import { color as color85, toErrorMessage as toErrorMessage40 } from "@wrongstack/core/utils";
39310
39572
  function buildWorkingDirCommand(_opts) {
39311
39573
  return {
39312
39574
  name: "working_dir",
@@ -39363,7 +39625,7 @@ function buildWorkingDirCommand(_opts) {
39363
39625
  ctx.setWorkingDir(resolved);
39364
39626
  } catch (err) {
39365
39627
  return {
39366
- message: color85.red(toErrorMessage39(err))
39628
+ message: color85.red(toErrorMessage40(err))
39367
39629
  };
39368
39630
  }
39369
39631
  const prevRel = path32.relative(ctx.projectRoot, previous) || ".";
@@ -39806,15 +40068,15 @@ function setupCliSlashCommands(params) {
39806
40068
  return built;
39807
40069
  },
39808
40070
  getConfig: () => config,
39809
- fallbackProfileManager: container.resolve(TOKENS15.FallbackProfileManager)
40071
+ fallbackProfileManager: container.resolve(TOKENS16.FallbackProfileManager)
39810
40072
  }) : void 0;
39811
40073
  const slashCmds = buildCommandHostSlashCommands({
39812
40074
  registry: slashRegistry,
39813
40075
  toolRegistry,
39814
40076
  ...createCommandHostAdapters({ agent, toolRegistry, interruptController, reader }),
39815
40077
  paths: wpaths,
39816
- compactor: container.resolve(TOKENS15.Compactor),
39817
- permissionPolicy: container.resolve(TOKENS15.PermissionPolicy),
40078
+ compactor: container.resolve(TOKENS16.Compactor),
40079
+ permissionPolicy: container.resolve(TOKENS16.PermissionPolicy),
39818
40080
  sessionStore,
39819
40081
  sessionRef,
39820
40082
  skillLoader,
@@ -39904,7 +40166,7 @@ function setupCliSlashCommands(params) {
39904
40166
  ...createEternalCommandHandlers({
39905
40167
  agent,
39906
40168
  projectRoot,
39907
- compactor: container.resolve(TOKENS15.Compactor),
40169
+ compactor: container.resolve(TOKENS16.Compactor),
39908
40170
  effectiveMaxContext: effectiveMaxContextRef,
39909
40171
  onIteration: broadcastEternalIteration,
39910
40172
  onStage: broadcastAutonomyStage,
@@ -40244,7 +40506,7 @@ async function setupCommandHostState(input) {
40244
40506
  // src/wiring/dep-watcher.ts
40245
40507
  import * as path33 from "node:path";
40246
40508
  import {
40247
- getSharedProjectMailbox as getSharedProjectMailbox10,
40509
+ getSharedProjectMailbox as getSharedProjectMailbox11,
40248
40510
  startPackageOutdatedWatcher,
40249
40511
  startTechStackConsumer
40250
40512
  } from "@wrongstack/core/coordination";
@@ -40293,7 +40555,7 @@ function setupDepWatcherConsumers(deps) {
40293
40555
  let offSessionEnded;
40294
40556
  try {
40295
40557
  const projectDir = path33.join(globalRoot, "projects", projectSlug);
40296
- const tsMailbox = getSharedProjectMailbox10(projectDir, events);
40558
+ const tsMailbox = getSharedProjectMailbox11(projectDir, events);
40297
40559
  const fileAuthorOpts = {
40298
40560
  storageDir: projectDir,
40299
40561
  projectRoot
@@ -40399,7 +40661,7 @@ function setupDepWatcherConsumers(deps) {
40399
40661
  if (depWatcherEnabled) {
40400
40662
  try {
40401
40663
  const projectDir = path33.join(globalRoot, "projects", projectSlug);
40402
- const pkgMailbox = getSharedProjectMailbox10(projectDir, events);
40664
+ const pkgMailbox = getSharedProjectMailbox11(projectDir, events);
40403
40665
  const pkgTrackerOpts = {
40404
40666
  storageDir: projectDir,
40405
40667
  projectRoot
@@ -41510,13 +41772,13 @@ async function wireCliOrchestration(cliCtx, state, boot) {
41510
41772
  brain,
41511
41773
  renderer,
41512
41774
  reader,
41513
- permissionPolicy: container.resolve(TOKENS16.PermissionPolicy),
41775
+ permissionPolicy: container.resolve(TOKENS17.PermissionPolicy),
41514
41776
  contextMeta: agent.ctx.meta,
41515
41777
  configStore
41516
41778
  });
41517
41779
  if (state.config.autonomy?.yoloPlus === true) setYoloPlusMode(true);
41518
41780
  setSandboxExpansionApprover(
41519
- createPolicySandboxApprover(() => container.resolve(TOKENS16.PermissionPolicy))
41781
+ createPolicySandboxApprover(() => container.resolve(TOKENS17.PermissionPolicy))
41520
41782
  );
41521
41783
  setupCliSlashCommands({
41522
41784
  slashRegistry,
@@ -41720,13 +41982,13 @@ async function wireCliOrchestration(cliCtx, state, boot) {
41720
41982
  // src/wiring/cli-execute-builder.ts
41721
41983
  import { FLEET_ROSTER as FLEET_ROSTER5 } from "@wrongstack/core/coordination";
41722
41984
  import { gatedEnhancerReasoning } from "@wrongstack/core/execution";
41723
- import { TOKENS as TOKENS17 } from "@wrongstack/core/kernel";
41985
+ import { TOKENS as TOKENS18 } from "@wrongstack/core/kernel";
41724
41986
 
41725
41987
  // src/auth-menu/panel-service.ts
41726
- import { toErrorMessage as toErrorMessage41 } from "@wrongstack/core/utils";
41988
+ import { toErrorMessage as toErrorMessage42 } from "@wrongstack/core/utils";
41727
41989
 
41728
41990
  // src/auth-menu/panel-flow-bridge.ts
41729
- import { toErrorMessage as toErrorMessage40 } from "@wrongstack/core/utils";
41991
+ import { toErrorMessage as toErrorMessage41 } from "@wrongstack/core/utils";
41730
41992
  var ANSI_RE = /\u001b\[[0-9;]*m/g;
41731
41993
  function stripAnsi(text) {
41732
41994
  return text.replace(ANSI_RE, "");
@@ -41769,7 +42031,7 @@ async function runFlow(run, onSuccess) {
41769
42031
  return { ok };
41770
42032
  } catch (err) {
41771
42033
  if (isCancel(err)) return { ok: false, message: "Cancelled." };
41772
- return { ok: false, message: toErrorMessage40(err) };
42034
+ return { ok: false, message: toErrorMessage41(err) };
41773
42035
  }
41774
42036
  }
41775
42037
  function plainMaskedKey(key) {
@@ -41949,13 +42211,13 @@ function createAuthPanelHost(deps) {
41949
42211
  deps.profileConfigPath
41950
42212
  );
41951
42213
  } catch (err) {
41952
- return toErrorMessage41(err);
42214
+ return toErrorMessage42(err);
41953
42215
  }
41954
42216
  if (result === null && deps.onProvidersChanged) {
41955
42217
  try {
41956
42218
  await deps.onProvidersChanged();
41957
42219
  } catch (err) {
41958
- return `Saved, but live config reload failed: ${toErrorMessage41(err)}`;
42220
+ return `Saved, but live config reload failed: ${toErrorMessage42(err)}`;
41959
42221
  }
41960
42222
  }
41961
42223
  return result;
@@ -42900,7 +43162,7 @@ async function runCliExecution(params) {
42900
43162
  governanceHandle,
42901
43163
  setConfig
42902
43164
  } = params;
42903
- const { execute } = await import("./execution-BAP566QC.js");
43165
+ const { execute } = await import("./execution-OK34CJKJ.js");
42904
43166
  return execute(
42905
43167
  toExecuteDeps({
42906
43168
  core: {
@@ -43035,11 +43297,11 @@ async function runCliExecution(params) {
43035
43297
  },
43036
43298
  agent,
43037
43299
  setPermissionYolo: (enabled) => {
43038
- container.resolve(TOKENS17.PermissionPolicy).setYolo?.(enabled);
43300
+ container.resolve(TOKENS18.PermissionPolicy).setYolo?.(enabled);
43039
43301
  agent.ctx.meta["yolo"] = enabled;
43040
43302
  },
43041
43303
  setLogLevel: (level) => {
43042
- container.resolve(TOKENS17.Logger).level = level;
43304
+ container.resolve(TOKENS18.Logger).level = level;
43043
43305
  },
43044
43306
  sessionBridge,
43045
43307
  autoCompactor,
@@ -43318,4 +43580,4 @@ export {
43318
43580
  CLI_VERSION,
43319
43581
  runInteractive
43320
43582
  };
43321
- //# sourceMappingURL=cli-main-5UGSW4TO.js.map
43583
+ //# sourceMappingURL=cli-main-OT63I2FX.js.map