@dadado/agent-kit-cli 6.17.0 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dashboard/dashboard-data.mjs +8 -3
  2. package/dashboard/dashboard.html +140 -0
  3. package/dashboard/lib/guards.d.mts +20 -0
  4. package/dashboard/lib/guards.mjs +307 -0
  5. package/dashboard/lib/semantic-model.mjs +228 -1
  6. package/dist/{add-DRV3T42D.js → add-MRI5BXHH.js} +3 -3
  7. package/dist/{chunk-3IEE6Q37.js → chunk-2TX6NJEG.js} +1 -1
  8. package/dist/{chunk-IOQ6YXA3.js → chunk-3HNTNYPR.js} +1 -1
  9. package/dist/{chunk-MEZU47IB.js → chunk-5EBT3V7G.js} +1 -1
  10. package/dist/{chunk-5IJQGIOY.js → chunk-677W4QO3.js} +63 -1
  11. package/dist/{chunk-SKC6QZW4.js → chunk-6WUKLS4D.js} +1 -1
  12. package/dist/{chunk-YO4BLHDT.js → chunk-6XJZLH53.js} +149 -18
  13. package/dist/{chunk-J3YLSHRK.js → chunk-7MUTZHWP.js} +23 -4
  14. package/dist/{chunk-CJ3JAH7L.js → chunk-BGL5DRK2.js} +2 -2
  15. package/dist/{chunk-IJQAFPY3.js → chunk-C4LCOOL4.js} +3 -1
  16. package/dist/chunk-DTSL2RH7.js +433 -0
  17. package/dist/{chunk-4DLMU44M.js → chunk-EBDQYFA4.js} +71 -4
  18. package/dist/{chunk-AQTCXUYS.js → chunk-EOQMAU2J.js} +1 -1
  19. package/dist/{chunk-RAMT55TC.js → chunk-G2Z37XFM.js} +3 -3
  20. package/dist/{chunk-HKZH2IEE.js → chunk-GTP224FI.js} +1 -1
  21. package/dist/{chunk-QYIV6ZP6.js → chunk-HJWSOZXS.js} +52 -12
  22. package/dist/{chunk-AZCPUJJO.js → chunk-IQQQDEQ4.js} +2 -2
  23. package/dist/{chunk-ZFJIJUZ4.js → chunk-MPCNPZJZ.js} +1 -1
  24. package/dist/{hook-2YEC7GT5.js → chunk-NL3I2BWA.js} +104 -113
  25. package/dist/{chunk-WGAOM37Y.js → chunk-OKQ37A7E.js} +9 -9
  26. package/dist/{chunk-WRCXRV2U.js → chunk-P7732A25.js} +10 -0
  27. package/dist/{chunk-6RRG3WOE.js → chunk-Q35TWISF.js} +22 -1
  28. package/dist/{chunk-WA7IBNIL.js → chunk-QBYJNGCD.js} +2 -2
  29. package/dist/chunk-QWTBYXHN.js +751 -0
  30. package/dist/{chunk-SC2DBY2R.js → chunk-R4DUO5DA.js} +1 -0
  31. package/dist/{chunk-2Y27P6KC.js → chunk-SGTTC2JP.js} +4 -3
  32. package/dist/{chunk-TICKIKCQ.js → chunk-U23SLQGX.js} +5 -5
  33. package/dist/chunk-UATQQDVR.js +297 -0
  34. package/dist/{chunk-3YTFXTXH.js → chunk-UXQH2CNC.js} +2 -1
  35. package/dist/{chunk-VBQHBSIB.js → chunk-VJWWJA36.js} +3 -3
  36. package/dist/{chunk-OQNJRQPZ.js → chunk-W3ZJVBNY.js} +7 -4
  37. package/dist/{chunk-XDCCYBCJ.js → chunk-ZMYV6PRE.js} +13 -0
  38. package/dist/{commands-3O2HFLTW.js → commands-NL6UOEP7.js} +51 -17
  39. package/dist/{conflicts-UY6VTYIO.js → conflicts-XMN4PBCZ.js} +8 -8
  40. package/dist/{contribute-RF47NPZ2.js → contribute-QDTEJ42W.js} +4 -4
  41. package/dist/{countdown-JX3DZ2QU.js → countdown-7ONIVAG6.js} +40 -12
  42. package/dist/{dashboard-YNCFISNO.js → dashboard-P65XHYCU.js} +1 -1
  43. package/dist/{dashboard-broadcast-NK7PU72L.js → dashboard-broadcast-GYK34QYL.js} +1 -1
  44. package/dist/{diff-SVFAUOVP.js → diff-RLB7R2NE.js} +5 -5
  45. package/dist/{doctor-ATKYRCT4.js → doctor-OXMDSOXL.js} +11 -11
  46. package/dist/{engine-info-R6GXZ2VO.js → engine-info-BBI5QO5Y.js} +3 -3
  47. package/dist/{ground-control-D2X6CI66.js → ground-control-IDCXN5FK.js} +5 -5
  48. package/dist/hook-B4VUQOQF.js +108 -0
  49. package/dist/index.js +28 -28
  50. package/dist/{init-LUJRWMHC.js → init-BYONEUCW.js} +14 -14
  51. package/dist/{install-VQSO2JR7.js → install-HOR6VR44.js} +14 -14
  52. package/dist/{mission-control-JIF6GFSV.js → mission-control-QJBSZVNI.js} +2 -2
  53. package/dist/{queue-IEOXOBNL.js → queue-OJHKFKK3.js} +55 -11
  54. package/dist/{run-L63NZHAJ.js → run-PFANZJ5Y.js} +175 -27
  55. package/dist/{run-plan-BWJX6R7Q.js → run-plan-7EB4ERSQ.js} +46 -16
  56. package/dist/{scan-BWA64R7I.js → scan-K3T5RQLC.js} +1 -1
  57. package/dist/session-start-OSFSF4OZ.js +74 -0
  58. package/dist/sessions-WQU5DONU.js +102 -0
  59. package/dist/{setup-global-2X5TMDCB.js → setup-global-O34KFL2C.js} +6 -6
  60. package/dist/{status-MOOZCB5D.js → status-QB2FFYUP.js} +8 -8
  61. package/dist/{update-NMSO56CQ.js → update-N2EKKSE7.js} +16 -11
  62. package/package.json +1 -1
  63. package/dist/sessions-O7MYEMCT.js +0 -343
@@ -2,31 +2,50 @@ import {
2
2
  runPlanLoop,
3
3
  shouldUseLiveTui,
4
4
  withLiveTui
5
- } from "./chunk-YO4BLHDT.js";
6
- import "./chunk-ZFJIJUZ4.js";
5
+ } from "./chunk-6XJZLH53.js";
6
+ import "./chunk-MPCNPZJZ.js";
7
7
  import {
8
8
  negatedFlag
9
- } from "./chunk-XDCCYBCJ.js";
9
+ } from "./chunk-ZMYV6PRE.js";
10
10
  import {
11
11
  landDispatchOutcome,
12
12
  runDispatchDriver
13
- } from "./chunk-QYIV6ZP6.js";
14
- import "./chunk-7ABY6DYH.js";
13
+ } from "./chunk-HJWSOZXS.js";
15
14
  import {
16
15
  DRIVER_EVENTS_FORMATS
17
- } from "./chunk-SKC6QZW4.js";
16
+ } from "./chunk-6WUKLS4D.js";
17
+ import {
18
+ LEASE_FREE_SLASHES,
19
+ QUEUE_LEASE_INTERRUPT_WAIT_MS,
20
+ QUEUE_LEASE_SESSION_ENV,
21
+ acquirePlanWriterLease,
22
+ acquireQueueLease,
23
+ forwardTermination,
24
+ gateCheckIn,
25
+ holdQueueStatus
26
+ } from "./chunk-DTSL2RH7.js";
18
27
  import {
19
28
  REVIEW_PACK_SLASH,
20
29
  runReviewJob
21
- } from "./chunk-TICKIKCQ.js";
30
+ } from "./chunk-U23SLQGX.js";
31
+ import {
32
+ CLAUDE_SUBAGENT_MODEL_ENV,
33
+ describeResolvedRoles,
34
+ loadRolesContext,
35
+ resolveSubworkerModel,
36
+ resolveWorkerRole
37
+ } from "./chunk-UATQQDVR.js";
38
+ import {
39
+ resolveActivePlanPath
40
+ } from "./chunk-7ABY6DYH.js";
22
41
  import {
23
42
  detectAgentBackend,
24
43
  listDetectBackendIds
25
- } from "./chunk-IJQAFPY3.js";
26
- import "./chunk-MEZU47IB.js";
44
+ } from "./chunk-C4LCOOL4.js";
45
+ import "./chunk-5EBT3V7G.js";
27
46
  import {
28
47
  LAND_ON_GATE_DESCRIPTION
29
- } from "./chunk-CJ3JAH7L.js";
48
+ } from "./chunk-BGL5DRK2.js";
30
49
  import "./chunk-L5V3W3DY.js";
31
50
  import "./chunk-MUTTNRX4.js";
32
51
  import {
@@ -39,21 +58,22 @@ import {
39
58
  resolveOperatorNote,
40
59
  runHeadlessDispatch,
41
60
  unknownSlashMessage
42
- } from "./chunk-2Y27P6KC.js";
61
+ } from "./chunk-SGTTC2JP.js";
43
62
  import {
44
63
  getBackend
45
- } from "./chunk-OQNJRQPZ.js";
64
+ } from "./chunk-W3ZJVBNY.js";
46
65
  import {
47
66
  HITL_UNANSWERED_EXIT_CODE,
48
67
  formatHitlSummary,
49
68
  hitlExitCode
50
- } from "./chunk-WRCXRV2U.js";
69
+ } from "./chunk-P7732A25.js";
51
70
  import "./chunk-WGLPZXNU.js";
52
- import "./chunk-6RRG3WOE.js";
71
+ import "./chunk-Q35TWISF.js";
53
72
  import "./chunk-QTON2GQX.js";
54
73
  import {
55
74
  logger
56
75
  } from "./chunk-ZB43YMHW.js";
76
+ import "./chunk-PFEUZXVT.js";
57
77
  import "./chunk-C4Q77GGJ.js";
58
78
  import "./chunk-5B4DVO6C.js";
59
79
 
@@ -68,6 +88,13 @@ function displayPath(target, home = homedir()) {
68
88
  const prefix = resolvedHome.endsWith(path.sep) ? resolvedHome : `${resolvedHome}${path.sep}`;
69
89
  return target.startsWith(prefix) ? `~${path.sep}${target.slice(prefix.length)}` : target;
70
90
  }
91
+ async function dispatchSubworkerEnv(backendRequest, runRoles, note, whichFn) {
92
+ const detected = await detectAgentBackend(backendRequest, whichFn);
93
+ if (!detected.ok) return void 0;
94
+ const sub = resolveSubworkerModel({ backend: detected.id, roles: runRoles.roles });
95
+ if (sub.warning) note(`roles: ${sub.warning}`);
96
+ return sub.model && detected.id === "claude" ? { [CLAUDE_SUBAGENT_MODEL_ENV]: sub.model } : void 0;
97
+ }
71
98
  async function executeRun(input) {
72
99
  const root = path.resolve(input.cwd);
73
100
  const slash = normalizeSlashName(input.slash);
@@ -90,6 +117,33 @@ async function executeRun(input) {
90
117
  if (input.note !== void 0 && slash !== DRIVER_DISPATCH_SLASH) {
91
118
  return { exitCode: 1, error: `--note only applies to ${DRIVER_DISPATCH_SLASH}` };
92
119
  }
120
+ let backendRequest = input.backend.trim() || "auto";
121
+ let model = input.model?.trim() || void 0;
122
+ let runRoles;
123
+ let dispatchEnv;
124
+ const rolesWarnings = [];
125
+ if (kind === "run-plan" || slash === DRIVER_DISPATCH_SLASH) {
126
+ const ctx = await loadRolesContext(root, kind === "run-plan");
127
+ if (!ctx.ok) return { exitCode: 1, error: ctx.error };
128
+ const worker = resolveWorkerRole({
129
+ flagBackend: input.backend,
130
+ flagModel: input.model,
131
+ plan: ctx.plan,
132
+ roles: ctx.roles,
133
+ defaultBackend: "auto"
134
+ });
135
+ rolesWarnings.push(...worker.warnings);
136
+ backendRequest = worker.backend;
137
+ model = worker.model;
138
+ runRoles = {
139
+ roles: ctx.roles,
140
+ backendSource: worker.backendSource,
141
+ ...worker.modelSource ? { modelSource: worker.modelSource } : {}
142
+ };
143
+ }
144
+ const rolesNote = (line) => input.events ? process.stderr.write(`${line}
145
+ `) : console.log(line);
146
+ for (const warning of rolesWarnings) rolesNote(`roles: ${warning}`);
93
147
  if (input.events) {
94
148
  if (slash !== DRIVER_DISPATCH_SLASH) {
95
149
  return {
@@ -100,21 +154,39 @@ async function executeRun(input) {
100
154
  const exitCode = await runDispatchDriver({
101
155
  root,
102
156
  slash: DRIVER_DISPATCH_SLASH,
103
- backend: input.backend,
104
- model: input.model,
157
+ backend: backendRequest,
158
+ model,
159
+ ...runRoles ? { env: await dispatchSubworkerEnv(backendRequest, runRoles, rolesNote, input.whichFn) } : {},
105
160
  dryRun: input.dryRun,
106
161
  noHitl: input.noHitl === true,
107
162
  landOnGate: input.landOnGate === true,
108
163
  events: input.events,
109
164
  ...input.note !== void 0 ? { note: input.note } : {},
110
- whichFn: input.whichFn
165
+ whichFn: input.whichFn,
166
+ ...input.lease ? { lease: input.lease } : {}
111
167
  });
112
168
  return { exitCode };
113
169
  }
114
- const detected = await detectAgentBackend(input.backend, input.whichFn);
170
+ const detected = await detectAgentBackend(backendRequest, input.whichFn);
115
171
  if (!detected.ok) {
116
172
  return { exitCode: 1, error: detected.message };
117
173
  }
174
+ if (runRoles && kind !== "run-plan") {
175
+ const sub = resolveSubworkerModel({ backend: detected.id, roles: runRoles.roles });
176
+ if (sub.warning) console.log(`roles: ${sub.warning}`);
177
+ if (sub.model && detected.id === "claude") {
178
+ dispatchEnv = { [CLAUDE_SUBAGENT_MODEL_ENV]: sub.model };
179
+ }
180
+ console.log(
181
+ describeResolvedRoles({
182
+ backendId: detected.id,
183
+ backendSource: runRoles.backendSource,
184
+ ...model ? { model } : {},
185
+ ...model && runRoles.modelSource ? { modelSource: runRoles.modelSource } : {},
186
+ subworker: sub
187
+ })
188
+ );
189
+ }
118
190
  if (kind === "run-plan") {
119
191
  let backend;
120
192
  try {
@@ -133,7 +205,8 @@ async function executeRun(input) {
133
205
  root,
134
206
  maxTicks: input.maxTicks,
135
207
  sleepSeconds: input.sleepSeconds,
136
- model: input.model,
208
+ model,
209
+ ...runRoles ? { roles: runRoles } : {},
137
210
  dryRun: false,
138
211
  backend,
139
212
  noHitl: input.noHitl === true,
@@ -178,27 +251,94 @@ async function executeRun(input) {
178
251
  console.log(`Dispatch: ${slash} via ${detected.id}`);
179
252
  console.log(`Command file: ${path.relative(root, file.path)}`);
180
253
  console.log(`Log: ${path.relative(root, logPath)}`);
254
+ let lease = null;
255
+ let nestedSession = null;
256
+ const checkIn = gateCheckIn(root, () => lease?.session ?? nestedSession, input.lease);
257
+ let restoreQueue = null;
258
+ if (slash !== DRIVER_DISPATCH_SLASH && !LEASE_FREE_SLASHES.has(slash)) {
259
+ const writer = acquirePlanWriterLease(root, `agent-kit run ${slash}`, {
260
+ ...input.lease,
261
+ onLost: () => console.log(
262
+ "Queue lease lost: another session replaced this one's lease. Another session may be writing this workspace's plans."
263
+ )
264
+ });
265
+ if (writer.kind === "refused") return { exitCode: 1, error: writer.message };
266
+ if (writer.kind === "nested") {
267
+ nestedSession = writer.lease.session;
268
+ console.log(
269
+ `Queue lease: running under session ${writer.lease.session} (dispatcher pid ${writer.lease.dispatcher.pid}).`
270
+ );
271
+ } else {
272
+ lease = writer.handle;
273
+ if (lease.takeover) {
274
+ console.log(
275
+ `Queue lease: took over a stale lease (${lease.takeover.reason}); the takeover is logged in HANDOFF.`
276
+ );
277
+ }
278
+ if (slash === "continue-plan") {
279
+ const active = await resolveActivePlanPath(root);
280
+ restoreQueue = holdQueueStatus(root, {
281
+ plan: active ? path.basename(active) : "the active plan",
282
+ who: `agent-kit run continue-plan session ${lease.session}`,
283
+ at: (/* @__PURE__ */ new Date()).toISOString()
284
+ });
285
+ }
286
+ }
287
+ } else if (slash === DRIVER_DISPATCH_SLASH) {
288
+ const acquired = acquireQueueLease(root, {
289
+ ...input.lease,
290
+ onLost: () => console.log(
291
+ "Queue lease lost: another session replaced this one's lease. Another /run-plan-all may be writing this queue."
292
+ )
293
+ });
294
+ if (!acquired.ok) return { exitCode: 1, error: acquired.message };
295
+ lease = acquired.handle;
296
+ if (lease.takeover) {
297
+ console.log(
298
+ `Queue lease: took over a stale lease (${lease.takeover.reason}); the takeover is logged in HANDOFF.`
299
+ );
300
+ }
301
+ }
302
+ const previousSession = process.env[QUEUE_LEASE_SESSION_ENV];
303
+ if (lease) process.env[QUEUE_LEASE_SESSION_ENV] = lease.session;
304
+ const live = shouldUseLiveTui({ plain: input.plain });
305
+ const offTermination = lease && !live ? forwardTermination(
306
+ () => lease?.agent(),
307
+ () => {
308
+ restoreQueue?.();
309
+ lease?.releaseAfterAgent(QUEUE_LEASE_INTERRUPT_WAIT_MS);
310
+ process.exit(130);
311
+ },
312
+ { signals: ["SIGINT", "SIGTERM", "SIGHUP"] }
313
+ ) : () => {
314
+ };
181
315
  try {
182
316
  const dispatch = {
183
317
  backendId: detected.id,
184
318
  bin: detected.bin,
185
319
  workspace: root,
186
320
  prompt,
187
- model: input.model,
188
- logPath
321
+ model,
322
+ logPath,
323
+ ...dispatchEnv ? { env: dispatchEnv } : {}
189
324
  };
190
- const result = shouldUseLiveTui({ plain: input.plain }) ? await withLiveTui(
325
+ const spawned = (info) => lease?.setAgent(info.pid);
326
+ const result = live ? await withLiveTui(
191
327
  { root, backend: detected.id, logPath, noHitl: input.noHitl === true },
192
328
  (seams) => runHeadlessDispatch({
193
329
  ...dispatch,
194
- hitl: seams.hitl,
330
+ hitl: { ...seams.hitl, checkIn },
195
331
  render: seams.render,
196
- onSpawn: seams.onSpawn,
332
+ onSpawn: (info) => {
333
+ spawned(info);
334
+ seams.onSpawn(info);
335
+ },
197
336
  log: seams.log
198
337
  })
199
338
  ) : await runHeadlessDispatch({
200
339
  ...dispatch,
201
- hitl: { policy: input.noHitl ? "off" : "prompt" }
340
+ hitl: { policy: input.noHitl ? "off" : "prompt", checkIn },
341
+ onSpawn: spawned
202
342
  });
203
343
  for (const line of formatHitlSummary(result.hitl)) console.log(line);
204
344
  const exitCode = hitlExitCode(result.exitCode, result.hitl);
@@ -216,6 +356,14 @@ async function executeRun(input) {
216
356
  return { exitCode };
217
357
  } catch (err) {
218
358
  return { exitCode: 1, error: String(err) };
359
+ } finally {
360
+ offTermination();
361
+ restoreQueue?.();
362
+ lease?.release();
363
+ if (lease) {
364
+ if (previousSession === void 0) delete process.env[QUEUE_LEASE_SESSION_ENV];
365
+ else process.env[QUEUE_LEASE_SESSION_ENV] = previousSession;
366
+ }
219
367
  }
220
368
  }
221
369
  var runDispatchArgs = {
@@ -226,8 +374,8 @@ var runDispatchArgs = {
226
374
  },
227
375
  backend: {
228
376
  type: "string",
229
- description: `Agent CLI (${listDetectBackendIds().join(" | ")}; default: auto)`,
230
- default: "auto"
377
+ description: `Agent CLI (${listDetectBackendIds().join(" | ")}; default: auto; run-plan and run-plan-all read config roles.worker first)`,
378
+ default: ""
231
379
  },
232
380
  model: {
233
381
  type: "string",
@@ -1,35 +1,41 @@
1
1
  import {
2
2
  runPlanLoop
3
- } from "./chunk-YO4BLHDT.js";
4
- import "./chunk-ZFJIJUZ4.js";
3
+ } from "./chunk-6XJZLH53.js";
4
+ import "./chunk-MPCNPZJZ.js";
5
5
  import {
6
6
  negatedFlag
7
- } from "./chunk-XDCCYBCJ.js";
8
- import "./chunk-7ABY6DYH.js";
7
+ } from "./chunk-ZMYV6PRE.js";
9
8
  import {
10
9
  DRIVER_EVENTS_FORMATS
11
- } from "./chunk-SKC6QZW4.js";
10
+ } from "./chunk-6WUKLS4D.js";
11
+ import "./chunk-DTSL2RH7.js";
12
+ import {
13
+ loadRolesContext,
14
+ resolveWorkerRole
15
+ } from "./chunk-UATQQDVR.js";
16
+ import "./chunk-7ABY6DYH.js";
12
17
  import {
13
18
  detectAgentBackend,
14
19
  listDetectBackendIds
15
- } from "./chunk-IJQAFPY3.js";
20
+ } from "./chunk-C4LCOOL4.js";
16
21
  import {
17
22
  LAND_ON_GATE_DESCRIPTION
18
- } from "./chunk-CJ3JAH7L.js";
23
+ } from "./chunk-BGL5DRK2.js";
19
24
  import "./chunk-L5V3W3DY.js";
20
25
  import "./chunk-MUTTNRX4.js";
21
26
  import {
22
27
  getBackend
23
- } from "./chunk-OQNJRQPZ.js";
28
+ } from "./chunk-W3ZJVBNY.js";
24
29
  import {
25
30
  HITL_UNANSWERED_EXIT_CODE
26
- } from "./chunk-WRCXRV2U.js";
31
+ } from "./chunk-P7732A25.js";
27
32
  import "./chunk-WGLPZXNU.js";
28
- import "./chunk-6RRG3WOE.js";
33
+ import "./chunk-Q35TWISF.js";
29
34
  import "./chunk-QTON2GQX.js";
30
35
  import {
31
36
  logger
32
37
  } from "./chunk-ZB43YMHW.js";
38
+ import "./chunk-PFEUZXVT.js";
33
39
  import "./chunk-C4Q77GGJ.js";
34
40
  import "./chunk-5B4DVO6C.js";
35
41
 
@@ -54,7 +60,7 @@ var runPlanCommand = defineCommand({
54
60
  },
55
61
  model: {
56
62
  type: "string",
57
- description: "Optional model id passed to the agent backend",
63
+ description: "Optional model id passed to the agent backend (default: plan worker_model, then config roles.worker.model)",
58
64
  default: ""
59
65
  },
60
66
  sleep: {
@@ -64,8 +70,8 @@ var runPlanCommand = defineCommand({
64
70
  },
65
71
  backend: {
66
72
  type: "string",
67
- description: `Agent backend (${listDetectBackendIds().join(" | ")}; default: cursor-agent)`,
68
- default: "cursor-agent"
73
+ description: `Agent backend (${listDetectBackendIds().join(" | ")}; default: plan worker_backend, then config roles.worker.backend, then cursor-agent)`,
74
+ default: ""
69
75
  },
70
76
  "dry-run": {
71
77
  type: "boolean",
@@ -117,9 +123,28 @@ var runPlanCommand = defineCommand({
117
123
  process.exitCode = 1;
118
124
  return;
119
125
  }
126
+ const root = path.resolve(args.cwd);
127
+ const rolesCtx = await loadRolesContext(root, true);
128
+ if (!rolesCtx.ok) {
129
+ logger.error(rolesCtx.error);
130
+ process.exitCode = 1;
131
+ return;
132
+ }
133
+ const worker = resolveWorkerRole({
134
+ flagBackend: String(args.backend ?? ""),
135
+ flagModel: String(args.model ?? ""),
136
+ plan: rolesCtx.plan,
137
+ roles: rolesCtx.roles,
138
+ defaultBackend: "cursor-agent"
139
+ });
140
+ for (const warning of worker.warnings) {
141
+ if (events) process.stderr.write(`roles: ${warning}
142
+ `);
143
+ else logger.warn(`roles: ${warning}`);
144
+ }
120
145
  let backend;
121
146
  try {
122
- const requested = String(args.backend);
147
+ const requested = worker.backend;
123
148
  if (requested === "auto") {
124
149
  const detected = await detectAgentBackend("auto");
125
150
  if (!detected.ok) {
@@ -148,10 +173,15 @@ var runPlanCommand = defineCommand({
148
173
  }
149
174
  }
150
175
  const code = await runPlanLoop({
151
- root: path.resolve(args.cwd),
176
+ root,
152
177
  maxTicks,
153
178
  sleepSeconds,
154
- model: args.model ? String(args.model) : void 0,
179
+ model: worker.model,
180
+ roles: {
181
+ roles: rolesCtx.roles,
182
+ backendSource: worker.backendSource,
183
+ ...worker.modelSource ? { modelSource: worker.modelSource } : {}
184
+ },
155
185
  dryRun: Boolean(args["dry-run"]),
156
186
  backend,
157
187
  noHitl: negatedFlag(args, "hitl"),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runScanner
3
- } from "./chunk-SC2DBY2R.js";
3
+ } from "./chunk-R4DUO5DA.js";
4
4
  import "./chunk-F6C3GFKV.js";
5
5
  import {
6
6
  logger
@@ -0,0 +1,74 @@
1
+ import {
2
+ AUDIT_SESSION_LIST_TIMEOUT_MS,
3
+ CURSOR_AWARENESS_SPAWN_TIMEOUT_MS,
4
+ LIVE_AGENTS_SECTION_DEADLINE_MS,
5
+ LIVE_AGENTS_SECTION_MAX_CHARS,
6
+ LIVE_AGENTS_SECTION_MAX_ROWS,
7
+ LIVE_AGENTS_SECTION_MAX_WORKTREES,
8
+ PUBLIC_INBOUND_SPAWN_TIMEOUT_MS,
9
+ SESSION_START_SECTION_DEADLINE_MS,
10
+ buildSessionStartAdditionalContext,
11
+ colonyHostSection,
12
+ cursorAwarenessSection,
13
+ detachedAuditSessionsSection,
14
+ formatLiveAgentsSection,
15
+ formatSessionAge,
16
+ listDetachedAuditSessions,
17
+ liveAgentsSection,
18
+ parseScreenDetachedAuditSessions,
19
+ parseTmuxDetachedAuditSessions,
20
+ parseUnprocessedDogfoodItems,
21
+ publicInboundSection,
22
+ resolveSessionRoot,
23
+ runSectionWithDeadline,
24
+ sectionAttemptNeedsStamp,
25
+ shouldEmitCursorAwarenessNudge,
26
+ updateCheckSection,
27
+ withDeadline
28
+ } from "./chunk-NL3I2BWA.js";
29
+ import "./chunk-2YU2H7I6.js";
30
+ import "./chunk-QWTBYXHN.js";
31
+ import "./chunk-DTSL2RH7.js";
32
+ import "./chunk-MCH3E46V.js";
33
+ import "./chunk-4CRBUEJ6.js";
34
+ import "./chunk-L5V3W3DY.js";
35
+ import "./chunk-MUTTNRX4.js";
36
+ import "./chunk-HAFRAXGV.js";
37
+ import "./chunk-IQQQDEQ4.js";
38
+ import "./chunk-PFEUZXVT.js";
39
+ import "./chunk-VJWWJA36.js";
40
+ import "./chunk-EOQMAU2J.js";
41
+ import "./chunk-WS6OX2IG.js";
42
+ import "./chunk-3HNTNYPR.js";
43
+ import "./chunk-677W4QO3.js";
44
+ import "./chunk-7HDQEK6T.js";
45
+ import "./chunk-C4Q77GGJ.js";
46
+ import "./chunk-5B4DVO6C.js";
47
+ export {
48
+ AUDIT_SESSION_LIST_TIMEOUT_MS,
49
+ CURSOR_AWARENESS_SPAWN_TIMEOUT_MS,
50
+ LIVE_AGENTS_SECTION_DEADLINE_MS,
51
+ LIVE_AGENTS_SECTION_MAX_CHARS,
52
+ LIVE_AGENTS_SECTION_MAX_ROWS,
53
+ LIVE_AGENTS_SECTION_MAX_WORKTREES,
54
+ PUBLIC_INBOUND_SPAWN_TIMEOUT_MS,
55
+ SESSION_START_SECTION_DEADLINE_MS,
56
+ buildSessionStartAdditionalContext,
57
+ colonyHostSection,
58
+ cursorAwarenessSection,
59
+ detachedAuditSessionsSection,
60
+ formatLiveAgentsSection,
61
+ formatSessionAge,
62
+ listDetachedAuditSessions,
63
+ liveAgentsSection,
64
+ parseScreenDetachedAuditSessions,
65
+ parseTmuxDetachedAuditSessions,
66
+ parseUnprocessedDogfoodItems,
67
+ publicInboundSection,
68
+ resolveSessionRoot,
69
+ runSectionWithDeadline,
70
+ sectionAttemptNeedsStamp,
71
+ shouldEmitCursorAwarenessNudge,
72
+ updateCheckSection,
73
+ withDeadline
74
+ };
@@ -0,0 +1,102 @@
1
+ import {
2
+ cleanChatTitle,
3
+ collectChats,
4
+ collectLiveRoster,
5
+ formatChatAge,
6
+ renderLiveRoster,
7
+ shellQuote
8
+ } from "./chunk-QWTBYXHN.js";
9
+ import "./chunk-DTSL2RH7.js";
10
+ import "./chunk-C4Q77GGJ.js";
11
+
12
+ // src/commands/sessions.ts
13
+ import path from "path";
14
+ import { defineCommand } from "citty";
15
+ var VENDOR_LABEL = {
16
+ claude: "Claude Code",
17
+ codex: "Codex",
18
+ cursor: "Cursor"
19
+ };
20
+ var TITLE_COLUMN = 48;
21
+ function vendorLabel(vendor) {
22
+ return VENDOR_LABEL[vendor] ?? vendor;
23
+ }
24
+ function renderChatSessions(chats, opts) {
25
+ const now = opts.now ?? Date.now();
26
+ const needsCd = path.resolve(opts.cwd ?? opts.workspace) !== path.resolve(opts.workspace);
27
+ const lines = [];
28
+ const claude = chats.vendors.find((v) => v.vendor === "claude");
29
+ if (claude?.status !== "ok") {
30
+ lines.push(`No saved Claude Code chats for ${opts.workspace}.`);
31
+ lines.push(
32
+ "The agent CLI saves sessions per folder: start `claude` in this folder to create one."
33
+ );
34
+ } else {
35
+ const shown = claude.sessions.length;
36
+ const count = shown < claude.total ? `${shown} newest of ${claude.total}` : `${claude.total} saved`;
37
+ lines.push(`Claude Code chats for ${opts.workspace} (${count})`);
38
+ lines.push("");
39
+ const ageWidth = Math.max(...claude.sessions.map((s) => formatChatAge(s.modified, now).length));
40
+ for (const s of claude.sessions) {
41
+ const title = cleanChatTitle(s.title ?? "(untitled)", TITLE_COLUMN).padEnd(TITLE_COLUMN);
42
+ const age = formatChatAge(s.modified, now).padEnd(ageWidth);
43
+ lines.push(` ${title} ${age} ${s.id.slice(0, 8)} claude --resume ${s.id}`);
44
+ }
45
+ if (needsCd) {
46
+ lines.push("");
47
+ lines.push(`Resume from that folder: cd ${shellQuote(opts.workspace)} first.`);
48
+ }
49
+ }
50
+ const unsupported = chats.vendors.filter((v) => v.status === "unsupported");
51
+ if (unsupported.length > 0) {
52
+ lines.push("");
53
+ lines.push(unsupported.map((v) => `${vendorLabel(v.vendor)}: not supported yet`).join(" \xB7 "));
54
+ }
55
+ return lines.join("\n");
56
+ }
57
+ var sessionsCommand = defineCommand({
58
+ meta: {
59
+ name: "sessions",
60
+ description: "List this folder's saved agent chats with the command that resumes each one; --live lists the agents running in it now"
61
+ },
62
+ args: {
63
+ json: {
64
+ type: "boolean",
65
+ description: "Print {withheld, vendors[]} as JSON (one envelope per vendor); with --live, the roster as JSON",
66
+ default: false
67
+ },
68
+ live: {
69
+ type: "boolean",
70
+ description: "Read-only roster of live agents in this workspace: queue lease, agent processes (pid, age, cwd), worktrees in use, recent transcripts, audit sessions",
71
+ default: false
72
+ },
73
+ cwd: {
74
+ type: "string",
75
+ description: "Workspace folder whose chats to list (default: current directory)"
76
+ }
77
+ },
78
+ async run({ args }) {
79
+ const cwd = process.cwd();
80
+ const workspace = path.resolve(cwd, typeof args.cwd === "string" && args.cwd ? args.cwd : ".");
81
+ if (args.live) {
82
+ const { listDetachedAuditSessions } = await import("./session-start-OSFSF4OZ.js");
83
+ const roster = await collectLiveRoster(workspace, { listAudit: listDetachedAuditSessions });
84
+ process.stdout.write(
85
+ args.json ? `${JSON.stringify(roster, null, 2)}
86
+ ` : `${renderLiveRoster(roster)}
87
+ `
88
+ );
89
+ return;
90
+ }
91
+ const chats = collectChats({ cwd: workspace });
92
+ process.stdout.write(
93
+ args.json ? `${JSON.stringify(chats, null, 2)}
94
+ ` : `${renderChatSessions(chats, { workspace, cwd })}
95
+ `
96
+ );
97
+ }
98
+ });
99
+ export {
100
+ renderChatSessions,
101
+ sessionsCommand
102
+ };
@@ -2,17 +2,17 @@ import {
2
2
  classifyInstallError,
3
3
  isNonInteractive,
4
4
  pathCliStatus
5
- } from "./chunk-WA7IBNIL.js";
5
+ } from "./chunk-QBYJNGCD.js";
6
6
  import {
7
7
  assessEnvironment
8
8
  } from "./chunk-B3VR5YBQ.js";
9
- import "./chunk-AZCPUJJO.js";
9
+ import "./chunk-IQQQDEQ4.js";
10
10
  import "./chunk-PFEUZXVT.js";
11
- import "./chunk-VBQHBSIB.js";
12
- import "./chunk-AQTCXUYS.js";
11
+ import "./chunk-VJWWJA36.js";
12
+ import "./chunk-EOQMAU2J.js";
13
13
  import "./chunk-WS6OX2IG.js";
14
- import "./chunk-IOQ6YXA3.js";
15
- import "./chunk-5IJQGIOY.js";
14
+ import "./chunk-3HNTNYPR.js";
15
+ import "./chunk-677W4QO3.js";
16
16
  import {
17
17
  KIT_VERSION,
18
18
  pinnedCliSpec
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  detectWorkspaceParent,
3
3
  workspaceParentAdvisoryLines
4
- } from "./chunk-3IEE6Q37.js";
4
+ } from "./chunk-2TX6NJEG.js";
5
5
  import {
6
6
  createReadinessReport
7
7
  } from "./chunk-PNFF6OU3.js";
8
8
  import {
9
9
  runScanner
10
- } from "./chunk-SC2DBY2R.js";
10
+ } from "./chunk-R4DUO5DA.js";
11
11
  import "./chunk-F6C3GFKV.js";
12
12
  import {
13
13
  logger
@@ -15,21 +15,21 @@ import {
15
15
  import {
16
16
  npxPinned,
17
17
  pathCliStatus
18
- } from "./chunk-WA7IBNIL.js";
18
+ } from "./chunk-QBYJNGCD.js";
19
19
  import {
20
20
  assessEnvironment
21
21
  } from "./chunk-B3VR5YBQ.js";
22
- import "./chunk-AZCPUJJO.js";
22
+ import "./chunk-IQQQDEQ4.js";
23
23
  import "./chunk-PFEUZXVT.js";
24
- import "./chunk-VBQHBSIB.js";
25
- import "./chunk-AQTCXUYS.js";
24
+ import "./chunk-VJWWJA36.js";
25
+ import "./chunk-EOQMAU2J.js";
26
26
  import "./chunk-WS6OX2IG.js";
27
27
  import {
28
28
  MANIFEST_RELATIVE_PATH,
29
29
  loadAgentKitManifest,
30
30
  resolveProtectedGlobs
31
- } from "./chunk-IOQ6YXA3.js";
32
- import "./chunk-5IJQGIOY.js";
31
+ } from "./chunk-3HNTNYPR.js";
32
+ import "./chunk-677W4QO3.js";
33
33
  import {
34
34
  KIT_VERSION
35
35
  } from "./chunk-7HDQEK6T.js";