runpane 2.4.215 → 2.4.217

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 (43) hide show
  1. package/README.md +33 -2
  2. package/dist/autopilot.d.ts +16 -0
  3. package/dist/autopilot.d.ts.map +1 -0
  4. package/dist/autopilot.js +376 -0
  5. package/dist/autopilot.js.map +1 -0
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +16 -3
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands.d.ts +47 -0
  10. package/dist/commands.d.ts.map +1 -1
  11. package/dist/commands.js +196 -3
  12. package/dist/commands.js.map +1 -1
  13. package/dist/daemonClient.d.ts.map +1 -1
  14. package/dist/daemonClient.js +25 -1
  15. package/dist/daemonClient.js.map +1 -1
  16. package/dist/docs-index.json +1 -1
  17. package/dist/generated/contract.d.ts +1939 -281
  18. package/dist/generated/contract.d.ts.map +1 -1
  19. package/dist/generated/contract.js +5719 -2946
  20. package/dist/generated/contract.js.map +1 -1
  21. package/dist/localControl.d.ts +28 -5
  22. package/dist/localControl.d.ts.map +1 -1
  23. package/dist/localControl.js +333 -38
  24. package/dist/localControl.js.map +1 -1
  25. package/dist/mcp.js +4 -2
  26. package/dist/mcp.js.map +1 -1
  27. package/dist/mcpTools.d.ts +5 -4
  28. package/dist/mcpTools.d.ts.map +1 -1
  29. package/dist/mcpTools.js +16 -3
  30. package/dist/mcpTools.js.map +1 -1
  31. package/dist/notify.d.ts +72 -5
  32. package/dist/notify.d.ts.map +1 -1
  33. package/dist/notify.js +211 -18
  34. package/dist/notify.js.map +1 -1
  35. package/dist/updateCapacity.d.ts +2 -2
  36. package/dist/updateCapacity.d.ts.map +1 -1
  37. package/dist/updateCapacity.js +4 -1
  38. package/dist/updateCapacity.js.map +1 -1
  39. package/dist/watchLines.d.ts +1 -0
  40. package/dist/watchLines.d.ts.map +1 -1
  41. package/dist/watchLines.js +5 -0
  42. package/dist/watchLines.js.map +1 -1
  43. package/package.json +1 -1
@@ -40,10 +40,13 @@ exports.runPanesFocus = runPanesFocus;
40
40
  exports.runPanelsList = runPanelsList;
41
41
  exports.runPanelsCreate = runPanelsCreate;
42
42
  exports.runPanelsOpen = runPanelsOpen;
43
+ exports.runPanelsClose = runPanelsClose;
43
44
  exports.runPanelsOutput = runPanelsOutput;
44
45
  exports.runPanelsInput = runPanelsInput;
45
46
  exports.runPanelsScreen = runPanelsScreen;
46
47
  exports.runPanelsLastMessage = runPanelsLastMessage;
48
+ exports.runPanelsConversation = runPanelsConversation;
49
+ exports.runConversationHookFromArgv = runConversationHookFromArgv;
47
50
  exports.runReport = runReport;
48
51
  exports.runInbox = runInbox;
49
52
  exports.runInboxAck = runInboxAck;
@@ -51,7 +54,6 @@ exports.runPanelsSubmit = runPanelsSubmit;
51
54
  exports.markSuggestionLine = markSuggestionLine;
52
55
  exports.printPromptNotes = printPromptNotes;
53
56
  exports.runPanelsSubmitComposer = runPanelsSubmitComposer;
54
- exports.runPanelsClose = runPanelsClose;
55
57
  exports.runPanelsWait = runPanelsWait;
56
58
  exports.runPanelsResume = runPanelsResume;
57
59
  exports.runPause = runPause;
@@ -240,6 +242,16 @@ const reportResultSchema = boundaryDecoder_1.boundary.object({
240
242
  report: agentReportSchema,
241
243
  sessionIds: boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string),
242
244
  liveWatchers: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
245
+ warnings: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
246
+ });
247
+ const panelConversationResultSchema = boundaryDecoder_1.boundary.object({
248
+ ok: boundaryDecoder_1.boundary.literal(true),
249
+ paneId: boundaryDecoder_1.boundary.string,
250
+ panelId: boundaryDecoder_1.boundary.string,
251
+ conversationId: boundaryDecoder_1.boundary.string,
252
+ source: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('startup', 'resume', 'clear', 'compact')),
253
+ sure: boundaryDecoder_1.boundary.boolean,
254
+ generation: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
243
255
  });
244
256
  const panelLastMessageResultSchema = boundaryDecoder_1.boundary.union(boundaryDecoder_1.boundary.object({
245
257
  ok: boundaryDecoder_1.boundary.literal(true),
@@ -281,6 +293,10 @@ const panelSummarySchema = boundaryDecoder_1.boundary.object({
281
293
  paused: boundaryDecoder_1.boundary.optional(pausedMarkSchema),
282
294
  resumeId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
283
295
  resumeSource: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('agent-farm', 'configured', 'agent')),
296
+ openedBy: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.object({
297
+ source: boundaryDecoder_1.boundary.enumeration('agent', 'user'),
298
+ panelId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
299
+ })),
284
300
  });
285
301
  exports.repoListResultSchema = boundaryDecoder_1.boundary.object({
286
302
  ok: boundaryDecoder_1.boundary.literal(true),
@@ -681,6 +697,7 @@ const paneArchiveBulkResultSchema = boundaryDecoder_1.boundary.object({
681
697
  ok: boundaryDecoder_1.boundary.boolean,
682
698
  sessionId: boundaryDecoder_1.boundary.string,
683
699
  merged: boundaryDecoder_1.boundary.literal(true),
700
+ closed: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.literal(true)),
684
701
  dryRun: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.literal(true)),
685
702
  removeWorktree: boundaryDecoder_1.boundary.boolean,
686
703
  archived: boundaryDecoder_1.boundary.number,
@@ -739,12 +756,22 @@ const panelOpenResultSchema = boundaryDecoder_1.boundary.object({
739
756
  reused: boundaryDecoder_1.boundary.boolean,
740
757
  });
741
758
  const panelCloseResultSchema = boundaryDecoder_1.boundary.object({
742
- ok: boundaryDecoder_1.boundary.literal(true),
759
+ ok: boundaryDecoder_1.boundary.boolean,
743
760
  generation: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
744
- paneId: boundaryDecoder_1.boundary.string,
761
+ paneId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
745
762
  panelId: boundaryDecoder_1.boundary.string,
746
- type: boundaryDecoder_1.boundary.string,
747
- title: boundaryDecoder_1.boundary.string,
763
+ type: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
764
+ title: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
765
+ closed: boundaryDecoder_1.boundary.boolean,
766
+ forced: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
767
+ alreadyClosed: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
768
+ dryRun: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
769
+ wouldClose: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
770
+ refused: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.object({
771
+ code: boundaryDecoder_1.boundary.enumeration('opened-by-user', 'permanent', 'agent-busy', 'unsent-input', 'input-unknown'),
772
+ message: boundaryDecoder_1.boundary.string,
773
+ next: boundaryDecoder_1.boundary.string,
774
+ })),
748
775
  });
749
776
  exports.panelListResultSchema = boundaryDecoder_1.boundary.object({
750
777
  ok: boundaryDecoder_1.boundary.literal(true),
@@ -839,7 +866,7 @@ exports.panelScreenResultSchema = boundaryDecoder_1.boundary.object({
839
866
  ok: boundaryDecoder_1.boundary.literal(true),
840
867
  panelId: boundaryDecoder_1.boundary.string,
841
868
  paneId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
842
- source: boundaryDecoder_1.boundary.enumeration('alternateScreen', 'scrollback', 'persistedOutput', 'empty'),
869
+ source: boundaryDecoder_1.boundary.enumeration('alternateScreen', 'scrollback', 'persistedOutput', 'empty', 'acpTranscript'),
843
870
  limit: boundaryDecoder_1.boundary.number,
844
871
  returnedLineCount: boundaryDecoder_1.boundary.number,
845
872
  hasMore: boundaryDecoder_1.boundary.boolean,
@@ -923,7 +950,7 @@ const agentDoctorResultSchema = boundaryDecoder_1.boundary.object({
923
950
  })),
924
951
  warnings: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
925
952
  });
926
- const workspaceEntryKindSchema = boundaryDecoder_1.boundary.enumeration('agent.ready', 'agent.busy', 'agent.blocked', 'agent.unknown', 'agent.idle', 'pane.created', 'pane.gone', 'panel.exited', 'panel.stopped', 'panel.paused', 'panel.unpaused', 'pane.associated', 'pane.detached', 'pr.conflicted', 'pr.checks', 'pr.merged', 'pr.closed', 'pr.head', 'pr.base_changed', 'pr.base_deleted', 'pr.review', 'pr.comment', 'pr.stopped', 'github.unavailable', 'github.recovered', 'agent.report', 'agent.report.missing');
953
+ const workspaceEntryKindSchema = boundaryDecoder_1.boundary.enumeration('agent.ready', 'agent.busy', 'agent.blocked', 'agent.unknown', 'agent.idle', 'pane.created', 'pane.gone', 'panel.exited', 'panel.stopped', 'panel.paused', 'panel.unpaused', 'pane.associated', 'pane.detached', 'pr.conflicted', 'pr.checks', 'pr.merged', 'pr.closed', 'pr.head', 'pr.base_changed', 'pr.base_deleted', 'pr.review', 'pr.comment', 'pr.stopped', 'github.unavailable', 'github.recovered', 'agent.report', 'agent.report.missing', 'item.created', 'item.answered', 'session.created', 'session.archived', 'orchestrator.turn_ended');
927
954
  const agentStateSchema = boundaryDecoder_1.boundary.enumeration('blocked', 'working', 'idle', 'unknown');
928
955
  const workspacePanelSummarySchema = boundaryDecoder_1.boundary.object({
929
956
  panelId: boundaryDecoder_1.boundary.string,
@@ -970,6 +997,7 @@ const workspaceEntrySchema = boundaryDecoder_1.boundary.object({
970
997
  lastOutputSource: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('transcript', 'screen')),
971
998
  expectedSince: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
972
999
  screenLines: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
1000
+ itemId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
973
1001
  });
974
1002
  exports.workspaceStateResultSchema = boundaryDecoder_1.boundary.object({
975
1003
  ok: boundaryDecoder_1.boundary.literal(true),
@@ -2177,13 +2205,15 @@ async function runPanesArchiveSession(parsed, sessionId) {
2177
2205
  throw new Error('runpane panes archive --session requires --merged.');
2178
2206
  }
2179
2207
  const request = { sessionId, merged: true };
2208
+ if (parsed.closed)
2209
+ request.closed = true;
2180
2210
  if (parsed.source === 'user' || parsed.source === 'agent')
2181
2211
  request.source = parsed.source;
2182
2212
  if (parsed.dryRun)
2183
2213
  request.dryRun = true;
2184
2214
  if (parsed.removeWorktree)
2185
2215
  request.removeWorktree = true;
2186
- await confirmPaneArchive(parsed, `Archive every Pane in Session ${sessionId} whose work is pushed and whose PR is not still open`);
2216
+ await confirmPaneArchive(parsed, `Archive every Pane in Session ${sessionId} whose work is pushed and whose PR ${request.closed ? 'merged or closed' : 'merged'}`);
2187
2217
  const result = await (0, daemonClient_1.invokeDaemon)('runpane:panes:archive', [request], paneArchiveBulkResultSchema, {
2188
2218
  paneDir: parsed.paneDir,
2189
2219
  // Each Pane refreshes its upstream and may wait for its worktree removal.
@@ -2323,6 +2353,7 @@ async function runPanelsOpen(parsed) {
2323
2353
  noFocus: parsed.noFocus || undefined,
2324
2354
  focus: parsed.focus || undefined,
2325
2355
  source: parsed.source === 'user' || parsed.source === 'agent' ? parsed.source : undefined,
2356
+ callerPanelId: resolveCallerPanelId(),
2326
2357
  };
2327
2358
  await confirmPanelOpen(parsed, request);
2328
2359
  const result = await (0, daemonClient_1.invokeDaemon)('runpane:panels:open', [request], panelOpenResultSchema, {
@@ -2337,6 +2368,46 @@ async function runPanelsOpen(parsed) {
2337
2368
  }
2338
2369
  return 0;
2339
2370
  }
2371
+ async function runPanelsClose(parsed) {
2372
+ const panelId = parsed.panelId?.trim();
2373
+ if (!panelId) {
2374
+ throw new errors_1.RunpaneError('ERR_RUNPANE_INVALID_ARGUMENT', 'runpane panels close requires --panel. Nothing was closed.', 'Find the tab id with `runpane panels list --pane <pane-id> --json`, then pass it with --panel.');
2375
+ }
2376
+ const request = { panelId };
2377
+ if (parsed.dryRun)
2378
+ request.dryRun = true;
2379
+ if (parsed.force)
2380
+ request.force = true;
2381
+ if (parsed.source === 'user' || parsed.source === 'agent')
2382
+ request.source = parsed.source;
2383
+ await confirmPanelClose(parsed, request);
2384
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:panels:close', [request], panelCloseResultSchema, {
2385
+ paneDir: parsed.paneDir,
2386
+ });
2387
+ if (parsed.json) {
2388
+ printJson(result);
2389
+ }
2390
+ else {
2391
+ console.log(describePanelClose(result));
2392
+ }
2393
+ return result.ok ? 0 : 1;
2394
+ }
2395
+ /** One line: closed, already closed, would close, or refused with its message and next step. */
2396
+ function describePanelClose(result) {
2397
+ const label = result.title ? `panel ${result.panelId} (${result.title})` : `panel ${result.panelId}`;
2398
+ if (result.refused) {
2399
+ return `${result.dryRun ? 'Would refuse' : 'Refused'} to close ${label}: ${result.refused.message} Next: ${result.refused.next}`;
2400
+ }
2401
+ if (result.alreadyClosed)
2402
+ return `Panel ${result.panelId} is already closed.`;
2403
+ if (result.dryRun)
2404
+ return `Would close ${label}.`;
2405
+ return result.forced ? `Closed ${label} with --force.` : `Closed ${label}.`;
2406
+ }
2407
+ /** The tab this CLI runs in ($PANE_PANEL_ID), sent so Pane records it as the opener of new tabs. */
2408
+ function resolveCallerPanelId() {
2409
+ return process.env.PANE_PANEL_ID?.trim() || undefined;
2410
+ }
2340
2411
  async function runPanelsOutput(parsed) {
2341
2412
  if (!parsed.panelId) {
2342
2413
  throw new Error('runpane panels output requires --panel.');
@@ -2417,22 +2488,164 @@ async function runPanelsLastMessage(parsed) {
2417
2488
  }
2418
2489
  return result.ok ? 0 : 1;
2419
2490
  }
2420
- /** Where a report is for: explicit --panel (with an optional --pane), else the Pane terminal's own panel. */
2421
- function resolveReportIdentity(parsed, env = process.env) {
2491
+ /**
2492
+ * Which panel a report is for: explicit --panel (with an optional --pane), else the Pane terminal's own
2493
+ * panel. `runpane report` and `runpane panels conversation` share the rule.
2494
+ */
2495
+ function resolveReportIdentity(parsed, env = process.env, command = 'runpane report') {
2422
2496
  if (parsed.paneId || parsed.panelId) {
2423
2497
  if (!parsed.panelId) {
2424
- throw new Error('runpane report --pane also needs --panel <panel-id>. Find it with `runpane panels list --pane <pane-id>`.');
2498
+ throw new Error(`${command} --pane also needs --panel <panel-id>. Find it with \`runpane panels list --pane <pane-id>\`.`);
2425
2499
  }
2426
2500
  return parsed.paneId ? { paneId: parsed.paneId, panelId: parsed.panelId } : { panelId: parsed.panelId };
2427
2501
  }
2428
2502
  const panelId = env.PANE_PANEL_ID?.trim();
2429
2503
  if (!panelId) {
2430
- throw new Error('runpane report cannot tell which panel is reporting. Run it inside a Pane terminal '
2504
+ throw new Error(`${command} cannot tell which panel is reporting. Run it inside a Pane terminal `
2431
2505
  + '(which sets PANE_SESSION_ID and PANE_PANEL_ID), or pass --pane <pane-id> --panel <panel-id>.');
2432
2506
  }
2433
2507
  const paneId = env.PANE_SESSION_ID?.trim();
2434
2508
  return paneId ? { paneId, panelId } : { panelId };
2435
2509
  }
2510
+ async function runPanelsConversation(parsed, env = process.env) {
2511
+ if (parsed.hook)
2512
+ return runPanelsConversationHook(env);
2513
+ if (parsed.conversationId === undefined)
2514
+ throw (0, commands_1.missingConversationError)();
2515
+ const identity = resolveReportIdentity(parsed, env, 'runpane panels conversation');
2516
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:panels:conversation', [{
2517
+ ...identity,
2518
+ conversationId: parsed.conversationId,
2519
+ source: parsed.conversationSource,
2520
+ }], panelConversationResultSchema, {
2521
+ paneDir: parsed.paneDir,
2522
+ });
2523
+ if (parsed.json) {
2524
+ printJson(result);
2525
+ }
2526
+ else {
2527
+ console.log(`Recorded conversation ${result.conversationId} for panel ${result.panelId}.`);
2528
+ }
2529
+ return 0;
2530
+ }
2531
+ /** The SessionStart hook's stdin is a small JSON object; anything larger is not one. */
2532
+ const CONVERSATION_HOOK_MAX_INPUT_BYTES = 64 * 1024;
2533
+ /** Claude Code writes the hook's JSON and closes stdin at once; never wait longer than this for it. */
2534
+ const CONVERSATION_HOOK_INPUT_TIMEOUT_MS = 2_000;
2535
+ /** With the stdin bound, the hook finishes well inside the 5 s timeout its settings entry gives it. */
2536
+ const CONVERSATION_HOOK_DAEMON_TIMEOUT_MS = 2_500;
2537
+ const sessionStartInputSchema = boundaryDecoder_1.boundary.object({
2538
+ session_id: boundaryDecoder_1.boundary.string,
2539
+ source: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.json),
2540
+ hook_event_name: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.json),
2541
+ });
2542
+ /** The conversation a SessionStart hook's JSON names, or null when it names none runpane can pass on. */
2543
+ function conversationFromHookInput(text) {
2544
+ let input;
2545
+ try {
2546
+ input = (0, boundaryDecoder_1.decodeBoundary)(JSON.parse(stripUtf8Bom(text)), sessionStartInputSchema);
2547
+ }
2548
+ catch {
2549
+ return null;
2550
+ }
2551
+ if (input.hook_event_name !== undefined && input.hook_event_name !== 'SessionStart')
2552
+ return null;
2553
+ const conversationId = input.session_id;
2554
+ if (!commands_1.CONVERSATION_ID_PATTERN.test(conversationId))
2555
+ return null;
2556
+ const source = commands_1.CONVERSATION_SOURCES.find((name) => name === input.source);
2557
+ return source ? { conversationId, source } : { conversationId };
2558
+ }
2559
+ /**
2560
+ * `runpane panels conversation --hook`, the command a Claude Code SessionStart hook runs. SessionStart
2561
+ * stdout goes into Claude's context and a failing hook shows in Claude, so this prints nothing and
2562
+ * resolves 0 whatever happens: outside Pane, bad input, Pane not running, an older daemon, any error.
2563
+ */
2564
+ async function runPanelsConversationHook(env = process.env, stdin = process.stdin, paneDir) {
2565
+ try {
2566
+ const panelId = env.PANE_PANEL_ID?.trim();
2567
+ if (!panelId)
2568
+ return 0;
2569
+ const text = await readBoundedInput(stdin, CONVERSATION_HOOK_MAX_INPUT_BYTES, CONVERSATION_HOOK_INPUT_TIMEOUT_MS);
2570
+ if (text === null)
2571
+ return 0;
2572
+ const conversation = conversationFromHookInput(text);
2573
+ if (!conversation)
2574
+ return 0;
2575
+ // An unset paneId is left out of the request, which travels as JSON.
2576
+ const paneId = env.PANE_SESSION_ID?.trim() || undefined;
2577
+ await (0, daemonClient_1.invokeDaemon)('runpane:panels:conversation', [{
2578
+ panelId,
2579
+ paneId,
2580
+ conversationId: conversation.conversationId,
2581
+ source: conversation.source,
2582
+ }], panelConversationResultSchema, { paneDir, timeoutMs: CONVERSATION_HOOK_DAEMON_TIMEOUT_MS });
2583
+ }
2584
+ catch {
2585
+ // Silent by design: a hook that fails must not show in Claude or stop it.
2586
+ }
2587
+ return 0;
2588
+ }
2589
+ /**
2590
+ * `runpane panels conversation --hook` straight from argv, before anything else in the CLI runs (no
2591
+ * managed-CLI handoff, no telemetry, no output). Returns null for any other command line.
2592
+ */
2593
+ async function runConversationHookFromArgv(argv, env = process.env) {
2594
+ if (!isConversationHookArgv(argv))
2595
+ return null;
2596
+ let paneDir;
2597
+ try {
2598
+ const parsed = (0, commands_1.parseRunpaneArgs)(argv);
2599
+ if (parsed.command !== 'panels conversation' || !parsed.hook)
2600
+ return 0;
2601
+ paneDir = parsed.paneDir;
2602
+ }
2603
+ catch {
2604
+ return 0;
2605
+ }
2606
+ return runPanelsConversationHook(env, process.stdin, paneDir);
2607
+ }
2608
+ function isConversationHookArgv(argv) {
2609
+ const words = argv.filter((arg, index) => !arg.startsWith('-') && argv[index - 1] !== '--pane-dir');
2610
+ return words[0] === 'panels' && words[1] === 'conversation' && argv.includes('--hook');
2611
+ }
2612
+ /** Reads a stream to its end, or null when it is a terminal, passes `maxBytes`, fails, or takes longer than `timeoutMs`. */
2613
+ function readBoundedInput(stream, maxBytes, timeoutMs) {
2614
+ if (stream.isTTY)
2615
+ return Promise.resolve(null);
2616
+ return new Promise((resolve) => {
2617
+ const chunks = [];
2618
+ let size = 0;
2619
+ let settled = false;
2620
+ const finish = (value) => {
2621
+ if (settled)
2622
+ return;
2623
+ settled = true;
2624
+ clearTimeout(timer);
2625
+ stream.removeListener('data', onData);
2626
+ stream.removeListener('end', onEnd);
2627
+ stream.removeListener('error', onError);
2628
+ stream.destroy();
2629
+ resolve(value);
2630
+ };
2631
+ const onData = (chunk) => {
2632
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, 'utf8');
2633
+ size += buffer.length;
2634
+ if (size > maxBytes) {
2635
+ finish(null);
2636
+ return;
2637
+ }
2638
+ chunks.push(buffer);
2639
+ };
2640
+ const onEnd = () => finish(Buffer.concat(chunks).toString('utf8'));
2641
+ const onError = () => finish(null);
2642
+ const timer = setTimeout(() => finish(null), timeoutMs);
2643
+ stream.on('data', onData);
2644
+ stream.once('end', onEnd);
2645
+ stream.once('error', onError);
2646
+ stream.resume();
2647
+ });
2648
+ }
2436
2649
  /** The CLIs send one character past the daemon's 16,000 so it still marks an overlong summary truncated. */
2437
2650
  const MAX_SENT_SUMMARY_LENGTH = 16_001;
2438
2651
  async function runReport(parsed, env = process.env) {
@@ -2472,14 +2685,16 @@ function describeReportDelivery(result) {
2472
2685
  const watchers = result.liveWatchers ?? 0;
2473
2686
  const delivered = watchers > 0 ? ` Delivered to ${watchers} waiting watcher${watchers === 1 ? '' : 's'}.` : '';
2474
2687
  const lines = [`Reported ${(0, watchLines_1.describeReport)(result.report)} for panel ${result.panelId}.${sessions}${delivered}`];
2688
+ // The blocked question's card check: posted anyway, but worth fixing next time.
2689
+ const warnings = (result.warnings ?? []).map(warning => `Warning: ${warning}`);
2475
2690
  if (result.sessionIds.length > 0 || watchers > 0)
2476
- return lines;
2691
+ return [...lines, ...warnings];
2477
2692
  const stored = `It is stored on the panel (runpane agents status --panel ${result.panelId})`;
2478
2693
  lines.push(result.liveWatchers === undefined
2479
2694
  ? `No Session recorded this report. ${stored}, and only watchers that list agent.report receive it.`
2480
2695
  : `No Session recorded this report and no watcher was waiting for it. ${stored}, `
2481
2696
  + 'and a watch with a named cursor (runpane watch --as <name> --kinds agent.report) still receives it when it next waits.');
2482
- return lines;
2697
+ return [...lines, ...warnings];
2483
2698
  }
2484
2699
  const inboxItemSchema = boundaryDecoder_1.boundary.object({
2485
2700
  id: boundaryDecoder_1.boundary.string,
@@ -2497,10 +2712,24 @@ const inboxItemSchema = boundaryDecoder_1.boundary.object({
2497
2712
  reason: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
2498
2713
  screenLines: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
2499
2714
  });
2715
+ const inboxAnswerSchema = boundaryDecoder_1.boundary.object({
2716
+ id: boundaryDecoder_1.boundary.string,
2717
+ title: boundaryDecoder_1.boundary.string,
2718
+ answer: boundaryDecoder_1.boundary.string,
2719
+ by: boundaryDecoder_1.boundary.enumeration('you', 'autopilot', 'orchestrator', 'pane'),
2720
+ because: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
2721
+ worker: boundaryDecoder_1.boundary.string,
2722
+ panelId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
2723
+ answeredAt: boundaryDecoder_1.boundary.string,
2724
+ delivered: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('call', 'tab')),
2725
+ undelivered: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
2726
+ decision: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
2727
+ });
2500
2728
  const inboxListResultSchema = boundaryDecoder_1.boundary.object({
2501
2729
  ok: boundaryDecoder_1.boundary.literal(true),
2502
2730
  session: boundaryDecoder_1.boundary.object({ id: boundaryDecoder_1.boundary.string, name: boundaryDecoder_1.boundary.string }),
2503
2731
  items: boundaryDecoder_1.boundary.array(inboxItemSchema),
2732
+ answers: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(inboxAnswerSchema)),
2504
2733
  });
2505
2734
  const inboxAckResultSchema = boundaryDecoder_1.boundary.object({
2506
2735
  ok: boundaryDecoder_1.boundary.literal(true),
@@ -2508,6 +2737,7 @@ const inboxAckResultSchema = boundaryDecoder_1.boundary.object({
2508
2737
  unknown: boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string),
2509
2738
  });
2510
2739
  const MAX_INBOX_DETAIL_LENGTH = 300;
2740
+ const INBOX_DECISION = /^D-\d+$/;
2511
2741
  /** `--session`, else the Session whose orchestrator this terminal is. */
2512
2742
  function inboxSession(parsed, env) {
2513
2743
  return parsed.sessionId?.trim() || env.PANE_ORCHESTRATION_SESSION_ID?.trim() || undefined;
@@ -2524,29 +2754,48 @@ async function runInbox(parsed, env = process.env) {
2524
2754
  }
2525
2755
  if (result.items.length === 0) {
2526
2756
  console.log(`Inbox for ${result.session.name}: nothing unacknowledged.`);
2527
- return 0;
2528
2757
  }
2529
- console.log(`Inbox for ${result.session.name}: ${result.items.length} unacknowledged.`);
2530
- for (const item of result.items)
2531
- console.log(formatInboxItem(item));
2532
- console.log(`Clear handled items with: runpane inbox ack ${result.items.map(item => item.id).join(' ')}`);
2758
+ else {
2759
+ console.log(`Inbox for ${result.session.name}: ${result.items.length} unacknowledged.`);
2760
+ for (const item of result.items)
2761
+ console.log(formatInboxItem(item));
2762
+ console.log(`Clear handled items with: runpane inbox ack ${result.items.map(item => item.id).join(' ')}`);
2763
+ }
2764
+ const unrecorded = (result.answers ?? []).filter(answer => !answer.decision);
2765
+ for (const answer of unrecorded)
2766
+ console.log(formatInboxAnswer(answer));
2767
+ if (unrecorded.length > 0)
2768
+ console.log('Record each with: runpane inbox ack <id> --decision <D-n>');
2533
2769
  return 0;
2534
2770
  }
2771
+ const ANSWERED_BY = { you: 'you', autopilot: 'Autopilot', orchestrator: 'the orchestrator', pane: 'Pane' };
2772
+ /** `<id> ANSWERED <worker>: <title> -> <answer> (by you) needs a D-n`. */
2773
+ function formatInboxAnswer(answer) {
2774
+ return `${answer.id} ANSWERED ${oneLine(answer.worker)}: ${oneLine(answer.title)} -> ${clip(oneLine(answer.answer))} (by ${ANSWERED_BY[answer.by]}) needs a D-n`;
2775
+ }
2535
2776
  async function runInboxAck(parsed, env = process.env) {
2536
2777
  const session = parsed.all ? inboxSession(parsed, env) : parsed.sessionId;
2537
2778
  if (parsed.all && !session) {
2538
2779
  throw new Error('runpane inbox ack --all needs --session <id|name> outside a Session orchestrator.');
2539
2780
  }
2781
+ const decision = parsed.inboxDecision;
2782
+ if (decision !== undefined) {
2783
+ if (parsed.all)
2784
+ throw new errors_1.RunpaneError('ERR_INBOX_INVALID', 'runpane inbox ack --decision records on the items you name, so it can\'t go with --all. Nothing was acknowledged.', 'Pass the item ids from runpane inbox.');
2785
+ if (!INBOX_DECISION.test(decision))
2786
+ throw new errors_1.RunpaneError('ERR_INBOX_INVALID', `--decision must look like D-147; got "${decision}". Nothing was acknowledged.`, 'Pass the D-n from your decision log.');
2787
+ }
2540
2788
  const result = await (0, daemonClient_1.invokeDaemon)('runpane:inbox:ack', [{
2541
2789
  ids: parsed.all ? undefined : parsed.inboxIds,
2542
2790
  session,
2543
2791
  all: parsed.all || undefined,
2792
+ decision,
2544
2793
  }], inboxAckResultSchema, { paneDir: parsed.paneDir });
2545
2794
  if (parsed.json) {
2546
2795
  printJson(result);
2547
2796
  }
2548
2797
  else {
2549
- console.log(`Acknowledged ${result.acknowledged.length} inbox item${result.acknowledged.length === 1 ? '' : 's'}.`);
2798
+ console.log(`Acknowledged ${result.acknowledged.length} inbox item${result.acknowledged.length === 1 ? '' : 's'}${decision && result.acknowledged.length > 0 ? `, recorded as ${decision}` : ''}.`);
2550
2799
  if (result.unknown.length > 0)
2551
2800
  console.log(`Not found (already acknowledged?): ${result.unknown.join(', ')}`);
2552
2801
  }
@@ -2734,22 +2983,6 @@ async function runPanelsSubmitComposer(parsed) {
2734
2983
  }
2735
2984
  return result.ok ? 0 : 1;
2736
2985
  }
2737
- async function runPanelsClose(parsed) {
2738
- if (!parsed.panelId) {
2739
- throw new Error('runpane panels close requires --panel.');
2740
- }
2741
- await (0, daemonActions_1.confirmMutation)(parsed);
2742
- const result = await (0, daemonClient_1.invokeDaemon)('runpane:panels:close', [{ panelId: parsed.panelId }], panelCloseResultSchema, {
2743
- paneDir: parsed.paneDir,
2744
- });
2745
- if (parsed.json) {
2746
- printJson(result);
2747
- }
2748
- else {
2749
- console.log(`Closed ${result.type} tab "${result.title}" (${result.panelId}) in pane ${result.paneId}.`);
2750
- }
2751
- return 0;
2752
- }
2753
2986
  async function runPanelsWait(parsed) {
2754
2987
  if (!parsed.panelId) {
2755
2988
  throw new Error('runpane panels wait requires --panel.');
@@ -2901,6 +3134,41 @@ async function buildPanelCreateRequest(parsed) {
2901
3134
  throw new Error('Use either --focus or --no-focus, not both.');
2902
3135
  }
2903
3136
  const source = parsed.source === 'user' || parsed.source === 'agent' ? parsed.source : undefined;
3137
+ if (parsed.launchArgs && !parsed.agentFarm)
3138
+ throw new Error('--arg is a launch argument for --agent-farm; pass --agent-farm <profile> too.');
3139
+ if (parsed.chat || parsed.agentFarm) {
3140
+ if (parsed.toolCommand)
3141
+ throw new Error('A chat tab runs its agent over ACP, so it takes --agent or --agent-farm, not --tool-command.');
3142
+ if (parsed.agentFarm && parsed.agent && parsed.agent !== 'claude' && parsed.agent !== 'codex')
3143
+ throw new Error('An Agent Farm profile chooses its own agent; drop --agent.');
3144
+ if (!parsed.agentFarm && parsed.agent !== 'claude' && parsed.agent !== 'codex')
3145
+ throw new Error('--chat opens Claude or Codex: pass --agent claude or --agent codex, or --agent-farm <profile>.');
3146
+ if (parsed.asFilePointer || parsed.attachments?.length)
3147
+ throw new Error('--as-file-pointer and --attach are for terminal tabs; send the first prompt with --initial-input.');
3148
+ const initialInput = parsed.initialInputFile ? stripUtf8Bom(readInputSource(parsed.initialInputFile)) : parsed.initialInput;
3149
+ const chat = {};
3150
+ if (parsed.agent === 'claude' || parsed.agent === 'codex')
3151
+ chat.agent = parsed.agent;
3152
+ if (parsed.agentFarm)
3153
+ chat.profile = parsed.agentFarm;
3154
+ if (parsed.launchArgs)
3155
+ chat.args = parsed.launchArgs;
3156
+ if (initialInput)
3157
+ chat.initialInput = initialInput;
3158
+ if (parsed.title)
3159
+ chat.title = parsed.title;
3160
+ return {
3161
+ paneId: parsed.paneId,
3162
+ type: 'chat',
3163
+ chat,
3164
+ noFocus: !parsed.focus && (parsed.noFocus || source === 'agent') ? true : undefined,
3165
+ focus: parsed.focus || undefined,
3166
+ source,
3167
+ callerPanelId: resolveCallerPanelId(),
3168
+ waitReady: parsed.waitReady || undefined,
3169
+ readyTimeoutMs: parsed.readyTimeoutMs,
3170
+ };
3171
+ }
2904
3172
  return {
2905
3173
  paneId: parsed.paneId,
2906
3174
  type: 'terminal',
@@ -2908,6 +3176,7 @@ async function buildPanelCreateRequest(parsed) {
2908
3176
  noFocus: !parsed.focus && (parsed.noFocus || source === 'agent' || Boolean(parsed.agent)) ? true : undefined,
2909
3177
  focus: parsed.focus || undefined,
2910
3178
  source,
3179
+ callerPanelId: resolveCallerPanelId(),
2911
3180
  waitReady: parsed.waitReady || undefined,
2912
3181
  readyTimeoutMs: parsed.readyTimeoutMs,
2913
3182
  };
@@ -2946,6 +3215,7 @@ async function buildPaneCreateRequest(parsed) {
2946
3215
  }));
2947
3216
  applyPaneFocusOptions(parsed, request);
2948
3217
  request.associateSession = parsed.noAssociate ? undefined : resolveAssociateSession(parsed) ?? request.associateSession;
3218
+ request.callerPanelId = resolveCallerPanelId();
2949
3219
  return request;
2950
3220
  }
2951
3221
  if (!parsed.repo) {
@@ -2977,6 +3247,7 @@ async function buildPaneCreateRequest(parsed) {
2977
3247
  noFocus: !parsed.focus && (parsed.noFocus || source === 'agent' || Boolean(parsed.agent)) ? true : undefined,
2978
3248
  focus: parsed.focus || undefined,
2979
3249
  source,
3250
+ callerPanelId: resolveCallerPanelId(),
2980
3251
  associateSession: resolveAssociateSession(parsed),
2981
3252
  };
2982
3253
  return request;
@@ -3224,6 +3495,24 @@ async function confirmPanelOpen(parsed, request) {
3224
3495
  rl.close();
3225
3496
  }
3226
3497
  }
3498
+ async function confirmPanelClose(parsed, request) {
3499
+ if (parsed.yes || request.dryRun) {
3500
+ return;
3501
+ }
3502
+ if (!isInteractiveShell()) {
3503
+ throw new errors_1.RunpaneError('ERR_RUNPANE_CONFIRMATION_REQUIRED', `runpane panels close closes panel ${request.panelId} and needs confirmation, but this shell is not interactive. Nothing was closed.`, 'Rerun with --yes, or with --dry-run to check without closing.');
3504
+ }
3505
+ const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
3506
+ try {
3507
+ const answer = (await rl.question(`Close panel ${request.panelId}? [y/N] `)).trim().toLowerCase();
3508
+ if (answer !== 'y' && answer !== 'yes') {
3509
+ throw new Error('Cancelled.');
3510
+ }
3511
+ }
3512
+ finally {
3513
+ rl.close();
3514
+ }
3515
+ }
3227
3516
  async function confirmPanelCreate(parsed, request) {
3228
3517
  if (parsed.yes) {
3229
3518
  return;
@@ -3231,10 +3520,11 @@ async function confirmPanelCreate(parsed, request) {
3231
3520
  if (!isInteractiveShell()) {
3232
3521
  throw new Error('runpane panels create mutates Pane state. Rerun with --yes in non-interactive shells.');
3233
3522
  }
3234
- const label = 'agent' in request.tool ? request.tool.agent : request.tool.command;
3523
+ const label = request.chat ? request.chat.profile ?? request.chat.agent ?? 'chat' : request.tool && 'agent' in request.tool ? request.tool.agent : request.tool?.command;
3524
+ const kind = request.type === 'chat' ? 'chat tab' : 'terminal panel';
3235
3525
  const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
3236
3526
  try {
3237
- const answer = (await rl.question(`Create a terminal panel for ${label} in pane ${request.paneId}? [y/N] `)).trim().toLowerCase();
3527
+ const answer = (await rl.question(`Create a ${kind} for ${label} in pane ${request.paneId}? [y/N] `)).trim().toLowerCase();
3238
3528
  if (answer !== 'y' && answer !== 'yes') {
3239
3529
  throw new Error('Cancelled.');
3240
3530
  }
@@ -3376,6 +3666,11 @@ function workspaceLabel(kind) {
3376
3666
  'github.recovered': 'GITHUB.RECOVERED',
3377
3667
  'agent.report': 'REPORT',
3378
3668
  'agent.report.missing': 'MISSING REPORT',
3669
+ 'item.created': 'ITEM',
3670
+ 'item.answered': 'ANSWERED',
3671
+ 'session.created': 'SESSION NEW',
3672
+ 'session.archived': 'SESSION ARCHIVED',
3673
+ 'orchestrator.turn_ended': 'TURN ENDED',
3379
3674
  };
3380
3675
  return labels[kind];
3381
3676
  }