@wrongstack/cli 0.308.6 → 0.308.7

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.
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-T6YAVFXA.js";
28
28
  import {
29
29
  setupPlugins
30
- } from "./chunk-KV6DNQT6.js";
30
+ } from "./chunk-BZJ4MP32.js";
31
31
  import {
32
32
  startCliHqConnection
33
33
  } from "./chunk-FKWHSFX4.js";
@@ -44,7 +44,7 @@ import {
44
44
  import {
45
45
  PLUGIN_AUDIT_ENTRIES,
46
46
  runPluginManagementCommand
47
- } from "./chunk-RK7E3IXT.js";
47
+ } from "./chunk-H6C7SO5H.js";
48
48
  import {
49
49
  configureSimpleUiRuntimeContext,
50
50
  detectProjectFacts,
@@ -113,7 +113,7 @@ import {
113
113
 
114
114
  // src/cli-main.ts
115
115
  import * as path32 from "node:path";
116
- import { FLEET_ROSTER as FLEET_ROSTER6, mailboxSessionTag as mailboxSessionTag5 } from "@wrongstack/core/coordination";
116
+ import { FLEET_ROSTER as FLEET_ROSTER6, mailboxSessionTag as mailboxSessionTag6 } from "@wrongstack/core/coordination";
117
117
  import { TOKENS as TOKENS12 } from "@wrongstack/core/kernel";
118
118
  import { getSessionRegistry } from "@wrongstack/core/storage";
119
119
  import { writeErr as writeErr3 } from "@wrongstack/core/utils";
@@ -1704,7 +1704,7 @@ function subscribeBrainDecisionLog(events) {
1704
1704
  }
1705
1705
 
1706
1706
  // src/fleet/host.ts
1707
- import { randomUUID as randomUUID4 } from "node:crypto";
1707
+ import { randomUUID as randomUUID5 } from "node:crypto";
1708
1708
  import {
1709
1709
  createProjectAgentRoster
1710
1710
  } from "@wrongstack/core/agent-catalog";
@@ -2359,6 +2359,62 @@ function createHostStatusBroadcaster(input) {
2359
2359
  });
2360
2360
  }
2361
2361
 
2362
+ // src/fleet/host-explore-companion.ts
2363
+ import { randomUUID as randomUUID2 } from "node:crypto";
2364
+ import {
2365
+ buildProbeTaskText,
2366
+ DEFAULT_EXPLORE_COMPANION_AGENT_ID,
2367
+ ExploreCompanion,
2368
+ getSharedProjectMailbox as getSharedProjectMailbox3,
2369
+ mailboxSessionTag as mailboxSessionTag2
2370
+ } from "@wrongstack/core/coordination";
2371
+ function createHostExploreCompanion(input) {
2372
+ const { director, events, sessionId, mailboxProjectDir, roster, config } = input;
2373
+ if (config?.enabled === false) return null;
2374
+ const sessionTag = mailboxSessionTag2(sessionId);
2375
+ const mailbox = () => getSharedProjectMailbox3(mailboxProjectDir, events);
2376
+ const template = roster[DEFAULT_EXPLORE_COMPANION_AGENT_ID];
2377
+ let residentId;
2378
+ const ensureResident = async () => {
2379
+ if (residentId) {
2380
+ const alive = director.status().subagents.some((s) => s.id === residentId);
2381
+ if (alive) return residentId;
2382
+ residentId = void 0;
2383
+ }
2384
+ if (!template) throw new Error("explore-companion role missing from roster");
2385
+ const subagentId = await director.spawn({
2386
+ ...template,
2387
+ id: `explore-companion-${sessionTag}`,
2388
+ name: "Explore Companion"
2389
+ });
2390
+ residentId = subagentId;
2391
+ return subagentId;
2392
+ };
2393
+ const options = {
2394
+ events,
2395
+ mailbox: mailbox(),
2396
+ leaderSessionId: sessionId,
2397
+ leaderAgentId: "leader",
2398
+ onProbe: async (probe) => {
2399
+ const subagentId = await ensureResident();
2400
+ const taskId = randomUUID2();
2401
+ await director.assignInternal({
2402
+ id: taskId,
2403
+ description: buildProbeTaskText(probe),
2404
+ subagentId
2405
+ });
2406
+ return { subagentId, taskId };
2407
+ },
2408
+ cooldownMs: config?.cooldownMs,
2409
+ maxPending: config?.maxPending,
2410
+ pollIntervalMs: config?.pollIntervalMs,
2411
+ companionAgentId: `${DEFAULT_EXPLORE_COMPANION_AGENT_ID}@${sessionTag}`
2412
+ };
2413
+ const companion = new ExploreCompanion(options);
2414
+ companion.start();
2415
+ return companion;
2416
+ }
2417
+
2362
2418
  // src/fleet/host-learning-scheduler.ts
2363
2419
  import {
2364
2420
  LearningOptimizationScheduler,
@@ -3003,7 +3059,7 @@ function aggregateFleetUsage(completed) {
3003
3059
  }
3004
3060
 
3005
3061
  // src/fleet/host-subagent-factory.ts
3006
- import { randomUUID as randomUUID2 } from "node:crypto";
3062
+ import { randomUUID as randomUUID3 } from "node:crypto";
3007
3063
  import { existsSync, statSync } from "node:fs";
3008
3064
  import * as path6 from "node:path";
3009
3065
  import {
@@ -3021,7 +3077,7 @@ import {
3021
3077
  import {
3022
3078
  DEFAULT_SUBAGENT_BASELINE,
3023
3079
  FLEET_ROSTER,
3024
- getSharedProjectMailbox as getSharedProjectMailbox3,
3080
+ getSharedProjectMailbox as getSharedProjectMailbox4,
3025
3081
  resolveSubagentModelTarget as resolveSubagentModelTarget2
3026
3082
  } from "@wrongstack/core/coordination";
3027
3083
  import { installDesignStudioMiddleware } from "@wrongstack/core/design";
@@ -3464,7 +3520,7 @@ ${message} Falling back to the assigned checkout.` : `${message} Falling back to
3464
3520
  }
3465
3521
  let onlineAgents = [];
3466
3522
  try {
3467
- const subagentMailbox = getSharedProjectMailbox3(host.mailboxProjectDir());
3523
+ const subagentMailbox = getSharedProjectMailbox4(host.mailboxProjectDir());
3468
3524
  onlineAgents = await subagentMailbox.getAgentStatuses();
3469
3525
  } catch {
3470
3526
  }
@@ -3531,7 +3587,7 @@ ${audienceMemory.map((text) => `- ${text}`).join("\n")}`
3531
3587
  if (rolePrompt) {
3532
3588
  baseSystem.push({ type: "text", text: rolePrompt });
3533
3589
  }
3534
- const subagentName = effectiveCfg.id ?? effectiveCfg.name ?? `sub_${randomUUID2().slice(0, 8)}`;
3590
+ const subagentName = effectiveCfg.id ?? effectiveCfg.name ?? `sub_${randomUUID3().slice(0, 8)}`;
3535
3591
  if (effectiveCfg.role) {
3536
3592
  host.recordLearningRole(subagentName, effectiveCfg.role, skillResolution.selected);
3537
3593
  }
@@ -3680,12 +3736,12 @@ ${audienceMemory.map((text) => `- ${text}`).join("\n")}`
3680
3736
  }
3681
3737
 
3682
3738
  // src/fleet/host-supervisor.ts
3683
- import { randomUUID as randomUUID3 } from "node:crypto";
3739
+ import { randomUUID as randomUUID4 } from "node:crypto";
3684
3740
  import {
3685
3741
  dispatchAgent,
3686
3742
  FleetSupervisor,
3687
- getSharedProjectMailbox as getSharedProjectMailbox4,
3688
- mailboxSessionTag as mailboxSessionTag2
3743
+ getSharedProjectMailbox as getSharedProjectMailbox5,
3744
+ mailboxSessionTag as mailboxSessionTag3
3689
3745
  } from "@wrongstack/core/coordination";
3690
3746
  import { toErrorMessage as toErrorMessage2 } from "@wrongstack/core/utils/error";
3691
3747
 
@@ -3711,8 +3767,8 @@ function createHostFleetSupervisor(input) {
3711
3767
  getLeaderMailboxId
3712
3768
  } = input;
3713
3769
  if (!director || !brain || supervisorConfig?.enabled === false) return null;
3714
- const supTag = () => mailboxSessionTag2(sessionId);
3715
- const mailbox = () => getSharedProjectMailbox4(mailboxProjectDir, events);
3770
+ const supTag = () => mailboxSessionTag3(sessionId);
3771
+ const mailbox = () => getSharedProjectMailbox5(mailboxProjectDir, events);
3716
3772
  const supervisor = new FleetSupervisor({
3717
3773
  events,
3718
3774
  fleet: director.fleet,
@@ -3738,7 +3794,7 @@ function createHostFleetSupervisor(input) {
3738
3794
  ].filter((part) => typeof part === "string" && part.trim().length > 0).join("\n\n");
3739
3795
  const subagentId = await director.spawn({
3740
3796
  ...template ?? { name: "fleet helper", role: "executor" },
3741
- id: `helper-${randomUUID3().slice(0, 8)}`,
3797
+ id: `helper-${randomUUID4().slice(0, 8)}`,
3742
3798
  name: `fleet helper (${routed.role})`,
3743
3799
  role: routed.role,
3744
3800
  systemPromptOverride: helperPrompt
@@ -3780,8 +3836,8 @@ function createHostFleetSupervisor(input) {
3780
3836
  // src/fleet/host-task-result-report.ts
3781
3837
  import {
3782
3838
  formatSubagentStructuredReport,
3783
- getSharedProjectMailbox as getSharedProjectMailbox5,
3784
- mailboxSessionTag as mailboxSessionTag3
3839
+ getSharedProjectMailbox as getSharedProjectMailbox6,
3840
+ mailboxSessionTag as mailboxSessionTag4
3785
3841
  } from "@wrongstack/core/coordination";
3786
3842
  async function reportTaskResultToLeader({
3787
3843
  notification: n,
@@ -3791,8 +3847,8 @@ async function reportTaskResultToLeader({
3791
3847
  getLeaderMailboxId
3792
3848
  }) {
3793
3849
  try {
3794
- const leaderId2 = getLeaderMailboxId?.() ?? `leader@${mailboxSessionTag3(sessionId)}`;
3795
- const mailbox = getSharedProjectMailbox5(mailboxProjectDir, events);
3850
+ const leaderId2 = getLeaderMailboxId?.() ?? `leader@${mailboxSessionTag4(sessionId)}`;
3851
+ const mailbox = getSharedProjectMailbox6(mailboxProjectDir, events);
3796
3852
  const ok = n.status === "success";
3797
3853
  const MAX_BODY = 700;
3798
3854
  const failureText = [
@@ -3895,6 +3951,11 @@ var MultiAgentHost = class {
3895
3951
  * buildDirector() (when a BrainArbiter is available), stopped in
3896
3952
  * dispose(). Also published to the supervisor registry for /supervisor. */
3897
3953
  fleetSupervisor = null;
3954
+ /** ExploreCompanion — state-triggered background codebase explorer behind
3955
+ * the leader. Built in buildDirector() (unless disabled via
3956
+ * fleet.exploreCompanion.enabled=false), stopped in dispose(). Probes are
3957
+ * assigned to a lazily-spawned resident `explore-companion` subagent. */
3958
+ exploreCompanion = null;
3898
3959
  /** Built-ins plus lazily-resolved project-created roles. */
3899
3960
  roster;
3900
3961
  /** Live roster surface shared by spawn_subagent and the blocking delegate tool. */
@@ -4009,6 +4070,14 @@ var MultiAgentHost = class {
4009
4070
  });
4010
4071
  this.statusBroadcaster.start();
4011
4072
  this.buildFleetSupervisor(config);
4073
+ this.exploreCompanion = createHostExploreCompanion({
4074
+ director: this.director,
4075
+ events: this.deps.events,
4076
+ sessionId: this.deps.session.id,
4077
+ mailboxProjectDir: this.mailboxProjectDir(),
4078
+ roster: this.roster,
4079
+ config: config.fleet?.exploreCompanion
4080
+ });
4012
4081
  this.directorOffHandles.push(
4013
4082
  ...registerDirectorBudgetAndContextBridges({
4014
4083
  director: this.director,
@@ -4096,7 +4165,7 @@ var MultiAgentHost = class {
4096
4165
  return this.acpRunnerCache.get(subagentId);
4097
4166
  }
4098
4167
  async spawnACP(subagentId, task, config) {
4099
- const taskId = randomUUID4();
4168
+ const taskId = randomUUID5();
4100
4169
  await this.ensureCoordinator(config);
4101
4170
  const coordinator = this.getCoordinator();
4102
4171
  const acpRunner = await this.buildACPRunner(subagentId);
@@ -4208,7 +4277,7 @@ var MultiAgentHost = class {
4208
4277
  return result;
4209
4278
  }
4210
4279
  async _spawnAndAssign(subagentConfig, description = "", opts) {
4211
- const taskId = randomUUID4();
4280
+ const taskId = randomUUID5();
4212
4281
  if (!this.director)
4213
4282
  throw new AgentError({
4214
4283
  message: "Director is not initialized",
@@ -4354,6 +4423,8 @@ var MultiAgentHost = class {
4354
4423
  this.fleetSupervisor?.stop();
4355
4424
  if (this.fleetSupervisor) setActiveFleetSupervisor(null);
4356
4425
  this.fleetSupervisor = null;
4426
+ this.exploreCompanion?.stop();
4427
+ this.exploreCompanion = null;
4357
4428
  this.adaptiveConcurrencyController?.dispose();
4358
4429
  this.adaptiveConcurrencyController = void 0;
4359
4430
  if (this.director) {
@@ -4412,7 +4483,7 @@ function setupBrainAndOrchestration(deps) {
4412
4483
  cwd,
4413
4484
  wpaths,
4414
4485
  teardownHandlers,
4415
- mailboxSessionTag: mailboxSessionTag6,
4486
+ mailboxSessionTag: mailboxSessionTag7,
4416
4487
  brainMailbox,
4417
4488
  agentMonitor,
4418
4489
  manifestPath,
@@ -4565,9 +4636,9 @@ function setupBrainAndOrchestration(deps) {
4565
4636
  // trigger corrective steers to the leader agent.
4566
4637
  leaderSessionId: () => context.session?.id ?? session.id,
4567
4638
  intervene: async ({ subject, body }) => {
4568
- const leaderUniqueId = `leader@${mailboxSessionTag6(session.id)}`;
4639
+ const leaderUniqueId = `leader@${mailboxSessionTag7(session.id)}`;
4569
4640
  await brainMailbox.send({
4570
- from: `brain@${mailboxSessionTag6(session.id)}`,
4641
+ from: `brain@${mailboxSessionTag7(session.id)}`,
4571
4642
  to: leaderUniqueId,
4572
4643
  type: "steer",
4573
4644
  subject,
@@ -6156,7 +6227,7 @@ ${res.out}` };
6156
6227
  const orchestrator = new PhaseOrchestrator({
6157
6228
  graph,
6158
6229
  ctx: {
6159
- executeTask: async (task, phaseId, env) => {
6230
+ executeTask: async (task, phaseId, env, signal) => {
6160
6231
  const phase = graph.phases.get(phaseId);
6161
6232
  const phaseName = phase?.name ?? phaseId;
6162
6233
  let agentName = task.assignee;
@@ -6169,7 +6240,7 @@ ${res.out}` };
6169
6240
  return runOnce(
6170
6241
  buildTaskPrompt(task, phaseName, goal),
6171
6242
  `goal-${agentName}`.slice(0, 48),
6172
- abort.signal,
6243
+ signal ? AbortSignal.any([abort.signal, signal]) : abort.signal,
6173
6244
  env?.cwd
6174
6245
  );
6175
6246
  },
@@ -6284,7 +6355,7 @@ ${res.out}` };
6284
6355
  const orchestrator = new PhaseOrchestrator({
6285
6356
  graph,
6286
6357
  ctx: {
6287
- executeTask: async (task, phaseId, env) => {
6358
+ executeTask: async (task, phaseId, env, signal) => {
6288
6359
  const phase = graph.phases.get(phaseId);
6289
6360
  const phaseName = phase?.name ?? phaseId;
6290
6361
  let agentName = task.assignee;
@@ -6297,7 +6368,7 @@ ${res.out}` };
6297
6368
  return runOnce(
6298
6369
  buildTaskPrompt(task, phaseName, title),
6299
6370
  "goal-" + agentName.slice(0, 48),
6300
- abort.signal,
6371
+ signal ? AbortSignal.any([abort.signal, signal]) : abort.signal,
6301
6372
  env?.cwd
6302
6373
  );
6303
6374
  },
@@ -8937,7 +9008,7 @@ ${color13.dim("YOLO enabled; tool calls run without approval unless an explicit
8937
9008
  }
8938
9009
 
8939
9010
  // src/slash-commands/brain.ts
8940
- import { randomUUID as randomUUID5 } from "node:crypto";
9011
+ import { randomUUID as randomUUID6 } from "node:crypto";
8941
9012
  import { color as color16 } from "@wrongstack/core/utils";
8942
9013
 
8943
9014
  // src/slash-commands/brain-council.ts
@@ -9547,7 +9618,7 @@ function buildBrainCommand(opts) {
9547
9618
  }
9548
9619
  try {
9549
9620
  const decision = await opts.brain.decide({
9550
- id: `brain-ask-${randomUUID5()}`,
9621
+ id: `brain-ask-${randomUUID6()}`,
9551
9622
  sessionId: opts.context?.session.id,
9552
9623
  source: "user",
9553
9624
  question,
@@ -11925,7 +11996,7 @@ function buildDoctorCommand(opts) {
11925
11996
  ].join("\n");
11926
11997
  async function loadPluginSchemas() {
11927
11998
  try {
11928
- const { BUILTIN_PLUGIN_FACTORIES } = await import("./plugins-XRGWC3NJ.js");
11999
+ const { BUILTIN_PLUGIN_FACTORIES } = await import("./plugins-EEKHCMBE.js");
11929
12000
  const settled = await Promise.allSettled(BUILTIN_PLUGIN_FACTORIES.map((f) => f()));
11930
12001
  const loaded = [];
11931
12002
  for (const s of settled) {
@@ -15740,7 +15811,7 @@ function buildKanbanAgentPrompt(board, task, assignment) {
15740
15811
  const dependencyLines = (task.dependsOn ?? []).map((depId) => board.tasks.find((candidate) => candidate.id === depId)).filter((dep) => Boolean(dep)).map((dep) => `- ${dep.title} [${dep.status}] (${dep.id})`);
15741
15812
  const checks = task.successCriteria?.map((check) => `- ${check.description}`).join("\n");
15742
15813
  const metrics = task.goalMetrics?.map(
15743
- (metric) => `- ${metric.name}: ${metric.current ?? "n/a"}${metric.target !== void 0 ? ` / ${metric.target}` : ""}${metric.unit ? ` ${metric.unit}` : ""} [${metric.status}]`
15814
+ (metric) => `- ${metric.name}: ${metric.current ?? "n/a"}${metric.target !== void 0 ? ` / ${metric.direction === "at_most" ? "\u2264" : "\u2265"} ${metric.target}` : ""}${metric.unit ? ` ${metric.unit}` : ""} [${metric.status}]`
15744
15815
  ).join("\n");
15745
15816
  const chain = task.chain ? [
15746
15817
  `chainId: ${task.chain.chainId}`,
@@ -16648,8 +16719,8 @@ function buildKanbanCommand(opts) {
16648
16719
 
16649
16720
  // src/slash-commands/mailbox.ts
16650
16721
  import {
16651
- getSharedProjectMailbox as getSharedProjectMailbox6,
16652
- mailboxSessionTag as mailboxSessionTag4,
16722
+ getSharedProjectMailbox as getSharedProjectMailbox7,
16723
+ mailboxSessionTag as mailboxSessionTag5,
16653
16724
  resolveMailboxIdentity,
16654
16725
  resolveProjectDir as resolveProjectDir2
16655
16726
  } from "@wrongstack/core/coordination";
@@ -16657,7 +16728,7 @@ import { color as color37, wstackGlobalRoot as wstackGlobalRoot2 } from "@wrongs
16657
16728
  function buildMailbox(opts) {
16658
16729
  const projectDir = opts.paths?.projectDir ?? resolveProjectDir2(opts.projectRoot, wstackGlobalRoot2());
16659
16730
  try {
16660
- return getSharedProjectMailbox6(projectDir);
16731
+ return getSharedProjectMailbox7(projectDir);
16661
16732
  } catch {
16662
16733
  return null;
16663
16734
  }
@@ -16667,7 +16738,7 @@ function leaderId(opts) {
16667
16738
  const identity = resolveMailboxIdentity(opts.context);
16668
16739
  return { id: identity.callerId, base: identity.baseId };
16669
16740
  }
16670
- return { id: `leader@${mailboxSessionTag4("default")}`, base: "leader" };
16741
+ return { id: `leader@${mailboxSessionTag5("default")}`, base: "leader" };
16671
16742
  }
16672
16743
  function fmtAge3(iso) {
16673
16744
  const ms = Date.now() - new Date(iso).getTime();
@@ -16977,7 +17048,7 @@ function buildMailboxCommand(opts) {
16977
17048
 
16978
17049
  // src/slash-commands/mailbox-demo.ts
16979
17050
  import {
16980
- getSharedProjectMailbox as getSharedProjectMailbox7,
17051
+ getSharedProjectMailbox as getSharedProjectMailbox8,
16981
17052
  resolveProjectDir as resolveProjectDir3
16982
17053
  } from "@wrongstack/core/coordination";
16983
17054
  import { wstackGlobalRoot as wstackGlobalRoot3 } from "@wrongstack/core/utils";
@@ -16985,7 +17056,7 @@ var DEMO_AGENT_ID = "mailbox-demo";
16985
17056
  function buildMailbox2(opts) {
16986
17057
  const projectDir = opts.paths?.projectDir ?? resolveProjectDir3(opts.projectRoot, wstackGlobalRoot3());
16987
17058
  try {
16988
- return getSharedProjectMailbox7(projectDir);
17059
+ return getSharedProjectMailbox8(projectDir);
16989
17060
  } catch {
16990
17061
  return null;
16991
17062
  }
@@ -26802,7 +26873,7 @@ function buildSupervisorCommand(opts) {
26802
26873
  }
26803
26874
 
26804
26875
  // src/slash-commands/tasks.ts
26805
- import { randomUUID as randomUUID6 } from "node:crypto";
26876
+ import { randomUUID as randomUUID7 } from "node:crypto";
26806
26877
  import {
26807
26878
  addPlanItem as addPlanItem2,
26808
26879
  emptyPlan as emptyPlan2,
@@ -26965,7 +27036,7 @@ ${formatPlan2(updated)}`;
26965
27036
  const title = parts.join(" ");
26966
27037
  const now = (/* @__PURE__ */ new Date()).toISOString();
26967
27038
  file.tasks.push({
26968
- id: `task_${randomUUID6()}`,
27039
+ id: `task_${randomUUID7()}`,
26969
27040
  title,
26970
27041
  type,
26971
27042
  priority,
@@ -27135,7 +27206,7 @@ ${formatTaskProgress(file.tasks)}`;
27135
27206
  ];
27136
27207
  if (found.item.description) {
27137
27208
  todos.push({
27138
- id: `todo_${randomUUID6()}`,
27209
+ id: `todo_${randomUUID7()}`,
27139
27210
  content: found.item.description.slice(0, 200),
27140
27211
  status: "pending",
27141
27212
  promotedFromTask: found.item.id
@@ -28018,7 +28089,7 @@ function buildTelegramSettingsCommand(opts) {
28018
28089
  }
28019
28090
 
28020
28091
  // src/slash-commands/todos.ts
28021
- import { randomUUID as randomUUID7 } from "node:crypto";
28092
+ import { randomUUID as randomUUID8 } from "node:crypto";
28022
28093
  import { formatTodosList as formatTodosList2 } from "@wrongstack/core/utils";
28023
28094
  import { todoTool as todoTool3 } from "@wrongstack/tools";
28024
28095
  function findTodo(todos, query) {
@@ -28077,7 +28148,7 @@ function buildTodosCommand(opts) {
28077
28148
  return { message: "This Todo list is a Kanban projection. Add the task in Kanban." };
28078
28149
  }
28079
28150
  const item = {
28080
- id: `todo_${Date.now()}_${randomUUID7().slice(0, 7)}`,
28151
+ id: `todo_${Date.now()}_${randomUUID8().slice(0, 7)}`,
28081
28152
  content: restJoined,
28082
28153
  status: "pending"
28083
28154
  };
@@ -30099,7 +30170,7 @@ async function spawnAgent2(director, role, task, maxIterations) {
30099
30170
  // src/wiring/dep-watcher.ts
30100
30171
  import * as path22 from "node:path";
30101
30172
  import {
30102
- getSharedProjectMailbox as getSharedProjectMailbox8,
30173
+ getSharedProjectMailbox as getSharedProjectMailbox9,
30103
30174
  startPackageOutdatedWatcher,
30104
30175
  startTechStackConsumer
30105
30176
  } from "@wrongstack/core/coordination";
@@ -30119,7 +30190,7 @@ function setupDepWatcherConsumers(deps) {
30119
30190
  if (dwCfg?.["enabled"] === true) {
30120
30191
  try {
30121
30192
  const projectDir = path22.join(globalRoot, "projects", projectSlug);
30122
- const tsMailbox = getSharedProjectMailbox8(projectDir, events);
30193
+ const tsMailbox = getSharedProjectMailbox9(projectDir, events);
30123
30194
  const fileAuthorOpts = {
30124
30195
  storageDir: projectDir,
30125
30196
  projectRoot
@@ -30152,7 +30223,7 @@ function setupDepWatcherConsumers(deps) {
30152
30223
  if (dwCfg?.["enabled"] === true) {
30153
30224
  try {
30154
30225
  const projectDir = path22.join(globalRoot, "projects", projectSlug);
30155
- const pkgMailbox = getSharedProjectMailbox8(projectDir, events);
30226
+ const pkgMailbox = getSharedProjectMailbox9(projectDir, events);
30156
30227
  const pkgTrackerOpts = {
30157
30228
  storageDir: projectDir,
30158
30229
  projectRoot
@@ -30195,7 +30266,7 @@ function setupDepWatcherConsumers(deps) {
30195
30266
 
30196
30267
  // src/wiring/dep-watcher-bridge.ts
30197
30268
  import * as path23 from "node:path";
30198
- import { attachDepWatcherBridge, getSharedProjectMailbox as getSharedProjectMailbox9 } from "@wrongstack/core/coordination";
30269
+ import { attachDepWatcherBridge, getSharedProjectMailbox as getSharedProjectMailbox10 } from "@wrongstack/core/coordination";
30199
30270
  function setupDepWatcherBridge(deps) {
30200
30271
  const { config, wpaths, projectRoot, events, logger, teardownHandlers } = deps;
30201
30272
  const fwCfg = config.extensions?.["file-watcher"];
@@ -30204,7 +30275,7 @@ function setupDepWatcherBridge(deps) {
30204
30275
  if (dwCfg?.["enabled"] === true) {
30205
30276
  try {
30206
30277
  const projectDir = path23.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
30207
- const dwMailbox = getSharedProjectMailbox9(projectDir, events);
30278
+ const dwMailbox = getSharedProjectMailbox10(projectDir, events);
30208
30279
  depWatcherDispose = attachDepWatcherBridge({
30209
30280
  events,
30210
30281
  mailbox: dwMailbox,
@@ -30540,7 +30611,7 @@ function setupHqTelemetry(deps) {
30540
30611
  agentMonitor,
30541
30612
  brainMailbox,
30542
30613
  teardownHandlers,
30543
- mailboxSessionTag: mailboxSessionTag6,
30614
+ mailboxSessionTag: mailboxSessionTag7,
30544
30615
  hqPublisherRef,
30545
30616
  mcpRegistry
30546
30617
  } = deps;
@@ -30549,7 +30620,7 @@ function setupHqTelemetry(deps) {
30549
30620
  const hqCommandController = {
30550
30621
  steerMailbox: brainMailbox,
30551
30622
  interruptLeader: () => false,
30552
- sessionTag: () => mailboxSessionTag6(session.id),
30623
+ sessionTag: () => mailboxSessionTag7(session.id),
30553
30624
  allowRunCommand: () => flags["hq-allow-exec"] === true
30554
30625
  };
30555
30626
  const hqOnCommand = createHqCommandDispatcher(hqCommandController);
@@ -30704,7 +30775,7 @@ function setupHqTelemetry(deps) {
30704
30775
 
30705
30776
  // src/wiring/lifecycle-plugins.ts
30706
30777
  import * as path28 from "node:path";
30707
- import { getSharedProjectMailbox as getSharedProjectMailbox10 } from "@wrongstack/core/coordination";
30778
+ import { getSharedProjectMailbox as getSharedProjectMailbox11 } from "@wrongstack/core/coordination";
30708
30779
  import { CouncilOrchestrator, OneShotOrchestrator as OneShotOrchestrator2 } from "@wrongstack/core/execution";
30709
30780
  import { countShellHooks, HookRegistry, HookRunner, shellHooksEqual } from "@wrongstack/core/hooks";
30710
30781
  import { allServers as allServers3 } from "@wrongstack/core/infrastructure";
@@ -31764,7 +31835,7 @@ async function setupLifecycleAndPlugins(deps) {
31764
31835
  registerMcpObservability(healthRegistry, metricsSink, mcpRegistry);
31765
31836
  const slashRegistry = new SlashCommandRegistry();
31766
31837
  const hqPublisherRef = { current: void 0 };
31767
- const brainMailbox = getSharedProjectMailbox10(
31838
+ const brainMailbox = getSharedProjectMailbox11(
31768
31839
  wpaths.projectDir,
31769
31840
  events,
31770
31841
  () => hqPublisherRef.current
@@ -31825,7 +31896,8 @@ async function setupLifecycleAndPlugins(deps) {
31825
31896
  historyFile: wpaths.historyFile,
31826
31897
  syncConfig: wpaths.syncConfig,
31827
31898
  projectDir: wpaths.projectDir,
31828
- projectGoal: wpaths.projectGoal
31899
+ projectGoal: wpaths.projectGoal,
31900
+ projectRoot: wpaths.projectRoot
31829
31901
  },
31830
31902
  hookRegistry,
31831
31903
  mailbox: brainMailbox,
@@ -33384,7 +33456,7 @@ async function runInteractive(cliCtx) {
33384
33456
  cwd,
33385
33457
  wpaths,
33386
33458
  teardownHandlers,
33387
- mailboxSessionTag: mailboxSessionTag5,
33459
+ mailboxSessionTag: mailboxSessionTag6,
33388
33460
  brainMailbox,
33389
33461
  agentMonitor,
33390
33462
  manifestPath,
@@ -33415,7 +33487,7 @@ async function runInteractive(cliCtx) {
33415
33487
  agentMonitor,
33416
33488
  brainMailbox,
33417
33489
  teardownHandlers,
33418
- mailboxSessionTag: mailboxSessionTag5,
33490
+ mailboxSessionTag: mailboxSessionTag6,
33419
33491
  hqPublisherRef,
33420
33492
  mcpRegistry
33421
33493
  });
@@ -33748,4 +33820,4 @@ export {
33748
33820
  CLI_VERSION,
33749
33821
  runInteractive
33750
33822
  };
33751
- //# sourceMappingURL=cli-main-HCCYX3D5.js.map
33823
+ //# sourceMappingURL=cli-main-L3T4KJKU.js.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Host wiring for the ExploreCompanion — the state-triggered background
3
+ * codebase explorer behind the leader agent.
4
+ *
5
+ * Mirrors `host-supervisor.ts`: a thin builder that wires the core
6
+ * `ExploreCompanion` observer (coordination/explore-companion.ts) to the
7
+ * director, the project mailbox, and the host session. Built in
8
+ * `buildDirector()`, stopped in `dispose()`.
9
+ *
10
+ * Resident model: one `explore-companion` subagent is spawned lazily on the
11
+ * FIRST probe (never eagerly — an idle session pays nothing) and holds a
12
+ * stable subagent id so subsequent probes reuse it. When the resident is
13
+ * gone (removed/reaped/never spawned), the next probe spawns a fresh one.
14
+ * Probes are `assignInternal`ed, never awaited — the leader is never
15
+ * blocked, and internal tasks stay out of the leader-visible task surface
16
+ * (same treatment as shadow passes).
17
+ *
18
+ * @module host-explore-companion
19
+ */
20
+ import { type Director, ExploreCompanion } from '@wrongstack/core/coordination';
21
+ import type { EventBus } from '@wrongstack/core/kernel';
22
+ import type { SubagentConfig } from '@wrongstack/core/types';
23
+ /** Config block for the explore-companion host wiring (FleetConfig.exploreCompanion). */
24
+ export interface HostExploreCompanionConfig {
25
+ /** Kill switch. Default true. */
26
+ enabled?: boolean | undefined;
27
+ /** Min gap between probes on the same subject (ms). Default 120_000. */
28
+ cooldownMs?: number | undefined;
29
+ /** Pending probe queue cap. Default 8. */
30
+ maxPending?: number | undefined;
31
+ /** Mailbox poll interval for explicit asks (ms). Default 5_000. */
32
+ pollIntervalMs?: number | undefined;
33
+ }
34
+ export interface HostExploreCompanionInput {
35
+ director: Director;
36
+ events: EventBus;
37
+ sessionId: string;
38
+ mailboxProjectDir: string;
39
+ roster: Record<string, SubagentConfig>;
40
+ config?: HostExploreCompanionConfig | undefined;
41
+ }
42
+ export declare function createHostExploreCompanion(input: HostExploreCompanionInput): ExploreCompanion | null;
43
+ //# sourceMappingURL=host-explore-companion.d.ts.map
@@ -53,6 +53,11 @@ export declare class MultiAgentHost {
53
53
  * buildDirector() (when a BrainArbiter is available), stopped in
54
54
  * dispose(). Also published to the supervisor registry for /supervisor. */
55
55
  private fleetSupervisor;
56
+ /** ExploreCompanion — state-triggered background codebase explorer behind
57
+ * the leader. Built in buildDirector() (unless disabled via
58
+ * fleet.exploreCompanion.enabled=false), stopped in dispose(). Probes are
59
+ * assigned to a lazily-spawned resident `explore-companion` subagent. */
60
+ private exploreCompanion;
56
61
  /** Built-ins plus lazily-resolved project-created roles. */
57
62
  private readonly roster;
58
63
  constructor(deps: MultiAgentDeps, opts?: MultiAgentHostOptions);
package/dist/index.js CHANGED
@@ -1863,12 +1863,12 @@ var loaders = {
1863
1863
  providers: async () => (await import("./providers-models-4FAKM2WO.js")).providersCmd,
1864
1864
  models: async () => (await import("./providers-models-4FAKM2WO.js")).modelsCmd,
1865
1865
  mcp: async () => (await import("./mcp-CMLFHRG2.js")).mcpCmd,
1866
- plugin: async () => (await import("./plugin-usage-PTEETL3J.js")).pluginCmd,
1867
- plugins: async () => (await import("./plugin-usage-PTEETL3J.js")).pluginCmd,
1866
+ plugin: async () => (await import("./plugin-usage-26LIIW3P.js")).pluginCmd,
1867
+ plugins: async () => (await import("./plugin-usage-26LIIW3P.js")).pluginCmd,
1868
1868
  diag: async () => (await import("./diag-doctor-WTBHPOMB.js")).diagCmd,
1869
1869
  doctor: async () => (await import("./diag-doctor-WTBHPOMB.js")).doctorCmd,
1870
1870
  export: async () => (await import("./export-CCUXRJOU.js")).exportCmd,
1871
- usage: async () => (await import("./plugin-usage-PTEETL3J.js")).usageCmd,
1871
+ usage: async () => (await import("./plugin-usage-26LIIW3P.js")).usageCmd,
1872
1872
  version: async () => (await import("./version-help-TFD6VPF3.js")).versionCmd,
1873
1873
  help: async () => (await import("./version-help-TFD6VPF3.js")).helpCmd,
1874
1874
  projects: async () => (await import("./projects-XE76NFNZ.js")).projectsCmd,
@@ -4466,7 +4466,7 @@ async function initializeCli(argv) {
4466
4466
  async function main(argv) {
4467
4467
  const cliCtx = await initializeCli(argv);
4468
4468
  if (typeof cliCtx === "number") return cliCtx;
4469
- const { runInteractive } = await import("./cli-main-HCCYX3D5.js");
4469
+ const { runInteractive } = await import("./cli-main-L3T4KJKU.js");
4470
4470
  return runInteractive(cliCtx);
4471
4471
  }
4472
4472
 
@@ -14,6 +14,15 @@ export declare const OFFICIAL_PLUGINS: readonly [{
14
14
  export interface PluginManagementDeps {
15
15
  config: Config;
16
16
  configPath: string;
17
+ /** Override `~/.wrongstack` for tests. Defaults to the real home dir. */
18
+ globalRoot?: string | undefined;
19
+ /** Injectable package-manager runner for tests. */
20
+ runPackageManager?: ((pm: string, args: readonly string[], cwd: string) => Promise<PackageManagerRunResult>) | undefined;
21
+ }
22
+ export interface PackageManagerRunResult {
23
+ code: number | null;
24
+ stdout: string;
25
+ stderr: string;
17
26
  }
18
27
  export interface PluginManagementResult {
19
28
  code: number;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runPluginManagementCommand
3
- } from "./chunk-RK7E3IXT.js";
3
+ } from "./chunk-H6C7SO5H.js";
4
4
  import {
5
5
  restoreFlags
6
6
  } from "./chunk-CSAPOCBP.js";
@@ -41,4 +41,4 @@ export {
41
41
  pluginCmd,
42
42
  usageCmd
43
43
  };
44
- //# sourceMappingURL=plugin-usage-PTEETL3J.js.map
44
+ //# sourceMappingURL=plugin-usage-26LIIW3P.js.map
@@ -7,8 +7,8 @@ import {
7
7
  pluginNameFromSpec,
8
8
  setupPlugins,
9
9
  warnIfDeprecatedPluginName
10
- } from "./chunk-KV6DNQT6.js";
11
- import "./chunk-RK7E3IXT.js";
10
+ } from "./chunk-BZJ4MP32.js";
11
+ import "./chunk-H6C7SO5H.js";
12
12
  import "./chunk-TYO2OVAD.js";
13
13
  import "./chunk-7OCVIDC7.js";
14
14
  export {
@@ -21,4 +21,4 @@ export {
21
21
  setupPlugins,
22
22
  warnIfDeprecatedPluginName
23
23
  };
24
- //# sourceMappingURL=plugins-XRGWC3NJ.js.map
24
+ //# sourceMappingURL=plugins-EEKHCMBE.js.map