@zergai/ztc 0.23.0-beta.1 → 0.24.0-beta.1

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 (146) hide show
  1. package/README.md +299 -13
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/ztc-audio-darwin-arm64 +0 -0
  4. package/bin/ztc-capture-darwin-arm64 +0 -0
  5. package/bin/ztc-tui-darwin-arm64 +0 -0
  6. package/bin/zterm-darwin-arm64 +2 -2
  7. package/dist/agent/agent.js +57 -14
  8. package/dist/agent/backends/http_error.d.ts +2 -0
  9. package/dist/agent/backends/http_error.js +2 -0
  10. package/dist/agent/backends/router_gate.d.ts +3 -2
  11. package/dist/agent/backends/router_gate.js +5 -4
  12. package/dist/agent/backends/router_keys.d.ts +14 -0
  13. package/dist/agent/backends/router_keys.js +19 -0
  14. package/dist/agent/backends/router_refusal.d.ts +5 -3
  15. package/dist/agent/backends/router_refusal.js +28 -6
  16. package/dist/agent/backends/types.d.ts +1 -1
  17. package/dist/agent/backends/zrouter_stream.js +10 -6
  18. package/dist/agent/commands/agent_cli.d.ts +11 -1
  19. package/dist/agent/commands/agent_cli.js +295 -38
  20. package/dist/agent/commands/diff.js +4 -1
  21. package/dist/agent/commands/help.js +4 -1
  22. package/dist/agent/commands/plan.js +3 -1
  23. package/dist/agent/commands/session_redaction.d.ts +16 -0
  24. package/dist/agent/commands/session_redaction.js +77 -0
  25. package/dist/agent/commands/settings.js +144 -0
  26. package/dist/agent/commands/types.d.ts +5 -0
  27. package/dist/agent/commands/usage_spec.d.ts +4 -0
  28. package/dist/agent/commands/usage_spec.js +10 -4
  29. package/dist/agent/runtime/policy.d.ts +25 -0
  30. package/dist/agent/runtime/policy.js +154 -26
  31. package/dist/agent/runtime/source_verification.js +6 -2
  32. package/dist/agent/runtime/tool_runtime.js +81 -3
  33. package/dist/agent/tools/apply_patch.js +678 -131
  34. package/dist/agent/tools/bus_message.d.ts +26 -1
  35. package/dist/agent/tools/bus_message.js +126 -10
  36. package/dist/agent/tools/file.d.ts +16 -1
  37. package/dist/agent/tools/file.js +43 -5
  38. package/dist/agent/tools/index.d.ts +1 -1
  39. package/dist/agent/tools/index.js +1 -1
  40. package/dist/agent/tools/pane.js +5 -0
  41. package/dist/agent/tools/search.js +5 -1
  42. package/dist/agent/tools/supervision.js +16 -2
  43. package/dist/agent/tools/types.d.ts +22 -0
  44. package/dist/app/mirror_startup.d.ts +7 -5
  45. package/dist/app/mirror_startup.js +7 -5
  46. package/dist/app/navigator_mirrors.d.ts +20 -0
  47. package/dist/app/navigator_mirrors.js +36 -0
  48. package/dist/app/workspace_layout_controller.d.ts +11 -2
  49. package/dist/app/workspace_layout_controller.js +13 -2
  50. package/dist/batch/worktree.js +9 -1
  51. package/dist/cli_ratatui.d.ts +264 -12
  52. package/dist/cli_ratatui.js +1198 -103
  53. package/dist/config/types.d.ts +29 -0
  54. package/dist/desktop/daily/source_baseline.js +3 -1
  55. package/dist/diagnostics/session_export.d.ts +1 -0
  56. package/dist/diagnostics/session_export.js +229 -26
  57. package/dist/emulation/tool_adapters.js +42 -5
  58. package/dist/headless.js +24 -5
  59. package/dist/instance_registry.d.ts +7 -0
  60. package/dist/mcp/workspace_server.d.ts +12 -1
  61. package/dist/mcp/workspace_server.js +75 -8
  62. package/dist/panes/agent_cli.d.ts +60 -3
  63. package/dist/panes/agent_cli.js +169 -16
  64. package/dist/panes/agent_pane_sessions.d.ts +22 -0
  65. package/dist/panes/agent_pane_sessions.js +111 -0
  66. package/dist/panes/agent_panes.d.ts +77 -3
  67. package/dist/panes/agent_panes.js +199 -10
  68. package/dist/panes/agent_profiles.d.ts +5 -0
  69. package/dist/panes/agent_profiles.js +7 -0
  70. package/dist/panes/agent_resume.d.ts +134 -0
  71. package/dist/panes/agent_resume.js +155 -0
  72. package/dist/panes/agent_sessions/claude_head.d.ts +32 -0
  73. package/dist/panes/agent_sessions/claude_head.js +122 -0
  74. package/dist/panes/agent_sessions/claude_store.d.ts +59 -0
  75. package/dist/panes/agent_sessions/claude_store.js +223 -0
  76. package/dist/panes/agent_sessions/codex_head.d.ts +55 -0
  77. package/dist/panes/agent_sessions/codex_head.js +161 -0
  78. package/dist/panes/agent_sessions/codex_store.d.ts +43 -0
  79. package/dist/panes/agent_sessions/codex_store.js +187 -0
  80. package/dist/panes/agent_sessions/controller.d.ts +74 -0
  81. package/dist/panes/agent_sessions/controller.js +110 -0
  82. package/dist/panes/agent_sessions/cut_json.d.ts +14 -0
  83. package/dist/panes/agent_sessions/cut_json.js +109 -0
  84. package/dist/panes/agent_sessions/limits.d.ts +48 -0
  85. package/dist/panes/agent_sessions/limits.js +48 -0
  86. package/dist/panes/agent_sessions/scan.d.ts +49 -0
  87. package/dist/panes/agent_sessions/scan.js +86 -0
  88. package/dist/panes/agent_sessions/store_fs.d.ts +51 -0
  89. package/dist/panes/agent_sessions/store_fs.js +128 -0
  90. package/dist/panes/agent_sessions/stores.d.ts +36 -0
  91. package/dist/panes/agent_sessions/stores.js +89 -0
  92. package/dist/panes/agent_sessions/title.d.ts +9 -0
  93. package/dist/panes/agent_sessions/title.js +51 -0
  94. package/dist/panes/agent_sessions/types.d.ts +48 -0
  95. package/dist/panes/agent_sessions/types.js +2 -0
  96. package/dist/panes/reply_arbitrator.d.ts +39 -0
  97. package/dist/panes/reply_arbitrator.js +185 -0
  98. package/dist/panes/reply_modes.d.ts +291 -0
  99. package/dist/panes/reply_modes.js +598 -0
  100. package/dist/runtime_info.js +11 -2
  101. package/dist/session.js +4 -2
  102. package/dist/simulation/living/context.d.ts +8 -8
  103. package/dist/simulation/living/types.d.ts +5 -5
  104. package/dist/simulation/toolkit/dynamic_state.d.ts +1 -1
  105. package/dist/ui/ratatui/ipc_path.d.ts +5 -0
  106. package/dist/ui/ratatui/ipc_path.js +23 -3
  107. package/dist/ui/ratatui/pane_credential_broker.d.ts +23 -8
  108. package/dist/ui/ratatui/pane_credential_broker.js +49 -14
  109. package/dist/ui/ratatui/pane_relay.d.ts +5 -2
  110. package/dist/ui/ratatui/pane_relay.js +86 -19
  111. package/dist/ui/ratatui/process.js +3 -0
  112. package/dist/ui/ratatui/protocol.d.ts +50 -1
  113. package/dist/ui/ratatui/protocol.js +56 -0
  114. package/dist/ui/ratatui/relay_policy.d.ts +39 -0
  115. package/dist/ui/ratatui/relay_policy.js +94 -0
  116. package/dist/ui/ratatui/screen_privacy.d.ts +15 -0
  117. package/dist/ui/ratatui/screen_privacy.js +24 -0
  118. package/dist/ui/scrollback.js +8 -0
  119. package/dist/ui/widgets/agent_sessions_panel.d.ts +139 -0
  120. package/dist/ui/widgets/agent_sessions_panel.js +542 -0
  121. package/dist/ui/widgets/log_view.d.ts +5 -1
  122. package/dist/ui/widgets/log_view.js +40 -4
  123. package/dist/utils/atomic_write.js +9 -11
  124. package/dist/utils/canonical_path.d.ts +19 -0
  125. package/dist/utils/canonical_path.js +44 -0
  126. package/dist/utils/compaction.d.ts +2 -1
  127. package/dist/utils/compaction.js +3 -1
  128. package/dist/utils/git_directory_names.d.ts +51 -0
  129. package/dist/utils/git_directory_names.js +429 -0
  130. package/dist/utils/temporary_write_root.d.ts +6 -1
  131. package/dist/utils/temporary_write_root.js +32 -2
  132. package/dist/utils/tool_result_message.d.ts +4 -1
  133. package/dist/utils/tool_result_message.js +6 -2
  134. package/dist/web/bus_hold.d.ts +70 -0
  135. package/dist/web/bus_hold.js +118 -0
  136. package/dist/web/mirror_client.d.ts +7 -3
  137. package/dist/web/mirror_client.js +61 -23
  138. package/dist/web/mirror_route_gate.d.ts +40 -0
  139. package/dist/web/mirror_route_gate.js +71 -0
  140. package/dist/web/mirror_stream.d.ts +147 -22
  141. package/dist/web/mirror_stream.js +350 -83
  142. package/dist/web/pane_credentials.d.ts +32 -1
  143. package/dist/web/pane_credentials.js +62 -2
  144. package/dist/workspace_collision.js +11 -2
  145. package/dist/zlm-embed.mjs +940 -273
  146. package/package.json +34 -12
@@ -4,7 +4,16 @@ import type { PaneCommandTransport } from '../ui/ratatui/pane_relay.js';
4
4
  import type { PaneSessionSpec } from '../panes/types.js';
5
5
  import type { MuxSessionState, RustEvent } from '../ui/ratatui/protocol.js';
6
6
  import { type WorkspacePresetHost } from './workspace_presets.js';
7
- /** Owner entry point; process I/O remains on the canonical pane transport. */
7
+ import type { AgentCliId } from '../panes/agent_cli.js';
8
+ /** A saved Claude Code or Codex pane's run, started on the session its launch held; null runs its saved command as saved. */
9
+ export type AgentSessionRun = (paneId: number, session: {
10
+ cli: AgentCliId;
11
+ id: string;
12
+ }) => Promise<string | null>;
13
+ /**
14
+ * Owner entry point; process I/O remains on the canonical pane transport. RESUME_AGENT_CLI runs a saved Claude Code or
15
+ * Codex pane whose launch held a session (agent_pane_sessions.ts) on that session, as resuming it does.
16
+ */
8
17
  export declare function createWorkspaceLayoutController(transport: PaneCommandTransport, specs: () => PaneSessionSpec[], resume: (paneId: number) => Promise<void>, presetHost?: WorkspacePresetHost, nativeOwner?: {
9
18
  isRestoring?: () => boolean;
10
19
  beginRestore?: () => () => void;
@@ -22,7 +31,7 @@ export declare function createWorkspaceLayoutController(transport: PaneCommandTr
22
31
  state: MuxSessionState;
23
32
  preservePaneIds: number[];
24
33
  }>;
25
- }, restoreSpecs?: (state: MuxSessionState) => void): {
34
+ }, restoreSpecs?: (state: MuxSessionState) => void, resumeAgentCli?: AgentSessionRun): {
26
35
  execute: (args: string[]) => Promise<string>;
27
36
  restoreSnapshot: (state: unknown) => Promise<Extract<RustEvent, {
28
37
  type: 'session_restored';
@@ -3,8 +3,12 @@ import { WorkspaceLayoutStore } from '../workspace_layout.js';
3
3
  import { linkWorkspaceAgentSessions } from '../workspace_agent.js';
4
4
  import { sanitizeMuxSessionState, resolveMuxPersistenceOptions, validateWorkspaceState, MAX_WORKSPACE_PANES } from '../ui/ratatui/mux_persistence.js';
5
5
  import { openWorkspacePreset } from './workspace_presets.js';
6
- /** Owner entry point; process I/O remains on the canonical pane transport. */
7
- export function createWorkspaceLayoutController(transport, specs, resume, presetHost, nativeOwner, restoreSpecs) {
6
+ import { agentPaneSession } from '../panes/agent_pane_sessions.js';
7
+ /**
8
+ * Owner entry point; process I/O remains on the canonical pane transport. RESUME_AGENT_CLI runs a saved Claude Code or
9
+ * Codex pane whose launch held a session (agent_pane_sessions.ts) on that session, as resuming it does.
10
+ */
11
+ export function createWorkspaceLayoutController(transport, specs, resume, presetHost, nativeOwner, restoreSpecs, resumeAgentCli) {
8
12
  const requireStable = () => { if (nativeOwner?.isRestoring?.())
9
13
  throw new Error('A workspace restore is in progress; try again when it finishes.'); };
10
14
  const requireInactive = () => { if (!transport.hasCapability?.('inactive_workspace_restore'))
@@ -127,6 +131,13 @@ export function createWorkspaceLayoutController(transport, specs, resume, preset
127
131
  const pane = state.panes.find(p => p.id === paneId);
128
132
  if (!pane || pane.agent_session || !['process', 'command'].includes(pane.pane_type))
129
133
  throw new Error('Run requires an inactive ordinary process pane; use /layout resume for a saved agent.');
134
+ // Its saved command would start a Claude Code session over again by its --session-id, in a pane no one knows.
135
+ const session = resumeAgentCli ? agentPaneSession(pane.command, pane.args) : null;
136
+ if (session && resumeAgentCli) {
137
+ const resumed = await resumeAgentCli(paneId, session);
138
+ if (resumed !== null)
139
+ return resumed;
140
+ }
130
141
  await request({ type: 'restart_pane', pane_id: paneId }, event => (event.type === 'pane_created' && event.pane_id === paneId) || (event.type === 'pane_state' && event.panes.some(p => p.id === paneId && p.is_alive)));
131
142
  return `Started saved command in pane ${paneId}.`;
132
143
  }
@@ -23,9 +23,17 @@ export function slugify(input) {
23
23
  .slice(0, 60)
24
24
  || 'task';
25
25
  }
26
+ /**
27
+ * Options every git run here takes first, as runtime_info's probes do. /batch runs git in the work tree and in the
28
+ * worktrees its workers write to, in ZTC's own process and outside any sandbox they run under: core.fsmonitor=false
29
+ * keeps a core.fsmonitor command in the repository's config from running on an add, a diff or a commit, and
30
+ * safe.bareRepository=explicit keeps git from taking a bare repository planted there for the repository and running
31
+ * its config. Both leave normal work trees and linked worktrees working.
32
+ */
33
+ const GIT_OPTIONS = ['-c', 'core.fsmonitor=false', '-c', 'safe.bareRepository=explicit'];
26
34
  /** Run a git command in a given directory. */
27
35
  async function git(args, cwd) {
28
- const { stdout } = await execFileAsync('git', args, { cwd, maxBuffer: 10 * 1024 * 1024 });
36
+ const { stdout } = await execFileAsync('git', [...GIT_OPTIONS, ...args], { cwd, maxBuffer: 10 * 1024 * 1024 });
29
37
  return stdout.trim();
30
38
  }
31
39
  /** Get the repository root from any directory inside it. */
@@ -1,6 +1,7 @@
1
1
  import { type DesktopRuntime } from './desktop/runtime.js';
2
2
  import { TuiProcess, NullTuiProcess, HeadlessPaneManager } from './ui/ratatui/index.js';
3
3
  import { getMirrorCommandUsages, isRichSlashUsage } from './agent/commands/mirror_usages.js';
4
+ import type { WindowClosedEvent } from './ui/ratatui/protocol.js';
4
5
  import { type Session } from './session.js';
5
6
  import { type RuntimeInfo, type RuntimeInfoOptions } from './runtime_info.js';
6
7
  export { buildDesktopUpdateRelaunchContext, buildHotRestartArgs, requestColonyCellRestart, } from './app/restart.js';
@@ -280,6 +281,17 @@ export declare class RatatuiApp {
280
281
  private busyScopeChoice;
281
282
  private busyScopeChoicePending;
282
283
  private pendingBusTrigger;
284
+ /** A bus message that pendingBusTrigger waits on is in the conversation already, not only among agentPaneAsksWaiting. */
285
+ private busMessageInConversation;
286
+ /**
287
+ * An agent's messages (ztc_message, but for the parent's control commands) that reached this ZTC on its parent's bus
288
+ * before it could take one, oldest first; null once it can, and in a ZTC that joins no parent's bus. A ZTC pane or a
289
+ * colony cell joins as it starts, and the mirror hands it at once what it held for it; startup then restores the
290
+ * session the pane resumes, which replaces its conversation, and last submits the task the pane was opened with. So
291
+ * they wait until startup is done and that task's turn has ended (admitWaitingAgentMessages): the pane's model gets
292
+ * the restored conversation and its task first, and each message after them, in the order they came.
293
+ */
294
+ private waitingAgentMessages;
283
295
  private flushingQueue;
284
296
  private agentTurnOwner;
285
297
  /** Required selects published to the mirror, by id, with their option values. */
@@ -366,6 +378,11 @@ export declare class RatatuiApp {
366
378
  private statusLinePanelWidget;
367
379
  private colorPanelWidget;
368
380
  private resumePanelWidget;
381
+ /** The Claude Code and Codex sessions picker (/claude resume, /codex sessions): Main's alone. */
382
+ private agentSessionsPanelWidget;
383
+ private agentSessionsControllerInstance;
384
+ /** Main's screen is read by no one until then, a moment after the sessions picker closes (mainScreenReadRefusal). */
385
+ private mainScreenPrivateUntil;
369
386
  private navigatorPanelWidget;
370
387
  private rewindPanelWidget;
371
388
  /**
@@ -460,6 +477,35 @@ export declare class RatatuiApp {
460
477
  private childPaneIds;
461
478
  /** Panes running the user's own Claude Code or Codex, by pane id. */
462
479
  private readonly agentCliPanes;
480
+ /**
481
+ * The messages a Claude Code or Codex pane sent Main that Main owes an answer (answersAgentPane), by message id. The
482
+ * end of the work on one answers it (answerAgentPanes): the end of the turn that read it, or of the turns that go on
483
+ * with that work.
484
+ */
485
+ private readonly agentPaneAsks;
486
+ /**
487
+ * The messages agent panes sent Main that came while it was busy or waited on the person, in the order they came:
488
+ * they wait out of the conversation for a turn of their own (admitAgentPaneAsksWaiting), since the turn running, or
489
+ * the one that goes on from the person's reply, would read them with its own work and answer them with it.
490
+ */
491
+ private agentPaneAsksWaiting;
492
+ /**
493
+ * Main's exchanges with the Claude Code and Codex panes it answers by itself (panes/reply_modes.ts): each one's reply
494
+ * mode, which the pane that started it chose or the person's default, and the automatic answers sent in it.
495
+ */
496
+ private readonly replyExchanges;
497
+ /**
498
+ * The messages agent panes sent Main after their exchange stopped, by pane, in the order they came: they wait out of the
499
+ * conversation for the person, whose next message here gives them a turn of their own (resumeAgentPaneExchanges).
500
+ */
501
+ private readonly agentPaneMessagesHeld;
502
+ /**
503
+ * Per agent pane, what Main still has to say to it once an arbitrator has decided on its answer: whatever Main says to
504
+ * that pane meanwhile goes in after it, in order.
505
+ */
506
+ private readonly agentPaneSaying;
507
+ /** The bus transport Main speaks on while it runs the workspace (overseerBusTransport); its answers go out on it. */
508
+ private mainBusTransport;
463
509
  private colonyPaneIds;
464
510
  /** Cache of latest pane list from pane_state events (including colony panes, filtered in switcher) */
465
511
  private knownPanes;
@@ -584,6 +630,11 @@ export declare class RatatuiApp {
584
630
  */
585
631
  private ownPaneId;
586
632
  private defaultPaneTitle;
633
+ /**
634
+ * Who this ZTC is on its bus while it runs the workspace: bus member 0, named as its pane is, "Main" or the name
635
+ * /rename gave it, which list_panes and the pane's header give it too.
636
+ */
637
+ private mainBusMember;
587
638
  private ownPaneTitle;
588
639
  private syncOwnPaneTitle;
589
640
  private paneActivityTransport;
@@ -730,13 +781,153 @@ export declare class RatatuiApp {
730
781
  */
731
782
  private registerMirrorPaneFallbacks;
732
783
  /**
733
- * The overseer's MESSAGE while this ZTC runs no mirror (it started without one, or /mirror stop stopped it): there is
734
- * no bus, so it is typed into the panes it is for. One for this ZTC itself reaches its own agent, as a mirror's member
735
- * 0 hands it over. A Claude Code or Codex pane gets it as a mirror types it in (registerMirrorPaneFallbacks); any other
736
- * pane, as the prompt "[Message from Overseer]: …". A broadcast reaches the ZTC panes, the members a bus would have,
737
- * and no shell, which would run it as a command.
784
+ * Main's MESSAGE while this ZTC runs no mirror (it started without one, or /mirror stop stopped it): there is no bus,
785
+ * so it is typed into the panes it is for. One for this ZTC itself reaches its own agent, as a mirror's member 0
786
+ * hands it over. A Claude Code or Codex pane gets it as a mirror types it in (registerMirrorPaneFallbacks); any other
787
+ * pane, as the prompt "[Message from Main]: …", Main named as its pane is. A broadcast reaches the ZTC panes, the
788
+ * members a bus would have, and no shell, which would run it as a command.
738
789
  */
739
790
  private typeOverseerMessage;
791
+ /**
792
+ * Whether Main owes MSG an answer when the turn that reads it ends: a plain message for Main itself from a Claude Code
793
+ * or Codex pane, whose agent hears only what is typed into it. One sent to every agent, a request that asks for a
794
+ * reply with send_message, and a ZTC pane's or the browser's message get none.
795
+ */
796
+ private answersAgentPane;
797
+ /**
798
+ * The turn OWNER runs reads MESSAGES: each agent pane's message among them that no turn has read yet is its to answer,
799
+ * as is one a turn before it passed on to it. One still owed after a turn that stopped for the person is the turn's
800
+ * only when it goes on from their reply: a turn that brings a prompt of the person's own since then isn't, and that
801
+ * pane hears its turn was interrupted instead.
802
+ */
803
+ private adoptAgentPaneAsks;
804
+ /**
805
+ * Main's wait on the person ended with nothing going on from it (WHY: they closed its question without answering it,
806
+ * cancelled its plan or took it to edit): each agent pane whose message waited on them hears that Main stopped, and
807
+ * why, and the message is no longer owed.
808
+ */
809
+ private closeWaitingAgentPaneAsks;
810
+ /**
811
+ * Main's conversation no longer holds some messages agent panes sent it (/clear, /rewind): each pane whose owed
812
+ * message no turn is working on any more hears that Main won't answer it.
813
+ */
814
+ private dropClearedAgentPaneAsks;
815
+ /**
816
+ * A turn couldn't start because this session is paused for a workspace overlap: each agent pane whose message waits
817
+ * for it hears so, once, and its answer comes when the person continues the session (/sessions continue).
818
+ */
819
+ private tellAgentPanesPaused;
820
+ /**
821
+ * This process is about to hand Main to another session: every agent pane Main owes an answer, for a message it read
822
+ * or one still waiting for its turn, hears that Main won't answer it, and its line is typed in before the hand-over.
823
+ */
824
+ private closeAgentPaneAsksForSwitch;
825
+ /**
826
+ * The turn OWNER ran ended waiting on the person, for their answer to a question or their approval of a plan (ON):
827
+ * each agent pane whose message it read hears so now. The messages stay owed, for the turn that goes on from the
828
+ * person's reply (adoptAgentPaneAsks), as of the messages there are now, with what this turn wrote on them (TEXT) for
829
+ * that turn's answer to carry, and what its model sent their panes, which follows that answer.
830
+ */
831
+ private deferAgentPaneAsks;
832
+ /**
833
+ * The turn OWNER ended with its work going on in a turn ZTC starts by itself: the plan turn its model asked for, the
834
+ * turn that reads the person's steering, the next step of a /goal. Each of its agent panes' messages that KEEP picks
835
+ * (every one, unless given) waits for that turn, with what this one wrote on it (TEXT) and what its model sent the
836
+ * pane, and the pane hears nothing yet. GOAL_ID: the /goal that goes on with the work.
837
+ */
838
+ private passAgentPaneAsks;
839
+ /**
840
+ * Main's bus transport as its model's tools use it (send_message, ask_ztc_pane), over INNER, Main's own
841
+ * (mainBusTransport): a message for an agent pane the running turn owes an answer waits, to go out right after that
842
+ * answer when the work on it ends, and the tool says so (a held send). Every other message goes out on INNER at once.
843
+ * None passes for one of Main's answers.
844
+ */
845
+ private answerFirstTransport;
846
+ /** What the messages Main's model sends the agent panes do to their exchanges with Main (BusTransport.replyModes). */
847
+ private replyModeHost;
848
+ /** The name pane PANE_ID goes by, as list_panes gives it: its title, else its program's name. */
849
+ private agentPaneTitle;
850
+ /**
851
+ * What Main says of a message a pane posts to its mirror, before the mirror delivers it (onBusMessageCheck): a reply
852
+ * mode that names an arbitrator the person didn't set up is refused; for an agent pane's message Main answers by itself,
853
+ * the sender's send_message says what the message does to their exchange, or that Main holds it for the person.
854
+ */
855
+ private checkAgentPaneBusMessage;
856
+ /** MSG, an agent pane's message that came after its exchange stopped, waits for the person, and pane 0 says so. */
857
+ private holdAgentPaneMessage;
858
+ /**
859
+ * The exchange with pane PANE_ID stopped: its messages still waiting for a turn of their own wait for the person
860
+ * instead, and nothing waits to start a turn for them alone.
861
+ */
862
+ private holdWaitingAgentPaneMessages;
863
+ /**
864
+ * Pane PANE_ID closed: its messages still waiting for a turn of their own (agentPaneAsksWaiting) go, and nothing waits
865
+ * to start a turn for them alone.
866
+ */
867
+ private dropWaitingAgentPaneMessages;
868
+ /**
869
+ * The messages pane PANE_ID sent while its exchange was stopped (agentPaneMessagesHeld) wait for a turn of their own
870
+ * now, as messages that came while Main was busy do. Returns whether there were any.
871
+ */
872
+ private releaseHeldAgentPaneMessages;
873
+ /**
874
+ * The person sent Main a message of their own: every exchange with an agent pane starts its count again, and one that
875
+ * had stopped goes on, saying so, its pane's held messages getting a turn of their own after the person's.
876
+ */
877
+ private resumeAgentPaneExchanges;
878
+ /** SAY runs once what Main is saying to pane PANE_ID now has gone in (agentPaneSaying), and what follows waits for it. */
879
+ private afterAgentPaneSaying;
880
+ /** SAYING is what Main is saying to pane PANE_ID until it settles. */
881
+ private trackAgentPaneSaying;
882
+ /** What the current turn wrote after PRE_RUN_IDS: its assistant text, in order, without reasoning or tool rows. */
883
+ private turnAnswerText;
884
+ /**
885
+ * The work on the agent panes' messages the turn OWNER read has ended with it: each of those panes hears ANSWER, once,
886
+ * however many it sent, then what the model sent it meanwhile (answerFirstTransport).
887
+ */
888
+ private answerAgentPanes;
889
+ /**
890
+ * The pane of each of ASKS hears ANSWER, once however many of them it sent, once pane 0's transcript has reached the
891
+ * renderer, so read_pane 0 holds what Main showed. An answer carries what Main wrote on those messages in earlier
892
+ * turns ahead of its own text. Then the pane hears what Main's model sent it meanwhile (answerFirstTransport), which
893
+ * keeps waiting, for the answer, while the messages wait on the person. A pane closed since hears nothing. An older
894
+ * renderer, without the atomic transcript, has a turn's answer printed to scrollback only once the turn has finished
895
+ * (until then it is in the live frame, a few rows high), so there the pane hears it just after (NOW: at once anyway).
896
+ */
897
+ private tellAgentPanes;
898
+ /** What tellAgentPanes says, now, or after what Main is still saying to a pane (agentPaneSaying). */
899
+ private sayToAgentPanes;
900
+ /**
901
+ * Main's answer to agent pane PANE_ID (FROM), made by SAID, goes in as the reply mode of their exchange has it, then
902
+ * HELD, what Main's model sent the pane meanwhile. A wait on the person, or an end with no answer to come, goes in as it
903
+ * is: no automatic answer the person isn't in on. Otherwise it is the exchange's next automatic answer: it goes in,
904
+ * the last its cap allows saying so, and pane 0 saying the exchange stopped; or, after the first, the arbitrator its
905
+ * mode names decides first, pane 0 showing the decision, and the pane hears instead that the exchange stopped, and
906
+ * why, unless it goes on (the promise returned is that decision's); or, once the exchange has stopped, it is not sent.
907
+ * A cap the person's default was lowered to, below the answers already sent, stops it now: pane 0 says so, and the
908
+ * pane hears that instead of the answer.
909
+ */
910
+ private answerAgentPane;
911
+ /**
912
+ * ANSWER, Main's answer to agent pane PANE_ID (FROM; SAID makes it again as it goes in), as the exchange's gate has it
913
+ * now (see answerAgentPane): SEND types it in, SEND_HELD what Main's model sent the pane meanwhile. A decision of an
914
+ * arbitrator's that comes once the exchange's count has started again (the person's message, a new mode) is about a
915
+ * count that no longer stands: pane 0 says so, and the answer goes as the exchange has it then.
916
+ */
917
+ private deliverAgentPaneAnswer;
918
+ /**
919
+ * The credentials no arbitrator reads (knownSecrets): those ZTC's settings and environment hold, and the profile's Zerg
920
+ * Router sign-in as router-auth.json holds it now, whether or not it has expired.
921
+ */
922
+ private arbitratorSecrets;
923
+ /**
924
+ * How read_pane 0 reads the work on the message MESSAGE_ID whole: with as many lines as pane 0 has rows from that
925
+ * message to the end, every answer shown in full, and its live frame below (LINES); and, while the person's reading
926
+ * cap still reveals some of it, about how long the rest takes (REVEAL_SECONDS).
927
+ */
928
+ private paneZeroReadFrom;
929
+ /** Ship pane 0's transcript to the renderer now, outside the rebuild throttle, so read_pane 0 holds what is shown. */
930
+ private shipTranscriptNow;
740
931
  private resolveOwnQuestion;
741
932
  private handleQuestionAnswer;
742
933
  private handleApprovalAnswer;
@@ -860,6 +1051,22 @@ export declare class RatatuiApp {
860
1051
  private createWorkspaceLayoutOwner;
861
1052
  private formatTime;
862
1053
  private waitForTuiEvent;
1054
+ /**
1055
+ * Ask ZTerm to close tab WINDOW_ID and the panes in it, as the person's ×, middle-click, Close Tab and close-tab key do
1056
+ * (workspace spec §5.2). With CONFIRMED the owner has already asked the person, so ZTerm shows no close sheet. Resolves
1057
+ * with ZTerm's window_closed for this request: closed; partly_closed, with the panes it kept (pinned panes, and Main's);
1058
+ * cancelled, when the person cancelled its sheet; or refused (Main's tab, the only tab, a tab it doesn't have), in its
1059
+ * words. Sends nothing to a renderer without desktop_close_window_v1. Rejects on an error ZTerm names for the request,
1060
+ * and when it hasn't answered within WINDOW_CLOSE_TIMEOUT_MS.
1061
+ *
1062
+ * A timeout is not a cancel. ZTerm's sheet has no deadline: the person can still close the tab after this rejects, and
1063
+ * its late window_closed reaches no caller (the saved workspace still drops the tab, as on every window_closed). While
1064
+ * that sheet is up, ZTerm refuses any other unconfirmed close that would ask ("Another tab's close is waiting for an
1065
+ * answer"). So a caller must not report the tab as kept when this times out; say it may yet close.
1066
+ */
1067
+ closeWindow(windowId: number, options?: {
1068
+ confirmed?: boolean;
1069
+ }): Promise<WindowClosedEvent>;
863
1070
  /**
864
1071
  * Emergency mux snapshot captured synchronously during SIGTERM/SIGINT,
865
1072
  * before child process 'close' events delete panes from the manager.
@@ -972,6 +1179,11 @@ export declare class RatatuiApp {
972
1179
  * scrollback and show a mostly blank pane.
973
1180
  */
974
1181
  private forceTranscriptRebuildOnNextRender;
1182
+ /**
1183
+ * Everything a rendered message depends on besides the message itself, as the transcript's render cache keys it. A
1184
+ * change here (resize, thinking visibility) invalidates every entry.
1185
+ */
1186
+ private transcriptConfigKey;
975
1187
  /**
976
1188
  * Atomic transcript rebuild: render every message via
977
1189
  * `messageToScrollbackLines` and ship the entire transcript in one
@@ -1092,6 +1304,28 @@ export declare class RatatuiApp {
1092
1304
  * Handle an incoming bus message (from browser user or another ZTC).
1093
1305
  */
1094
1306
  private handleBusMessage;
1307
+ /**
1308
+ * Add MSG, an agent's message for this ZTC, to the conversation as MESSAGE_TEXT, which pane 0 and the mirror show as
1309
+ * DISPLAY_TEXT. One from an agent pane Main answers (ASKER) is owed an answer, and Main's model reads right after it
1310
+ * who sent it and how its answer goes back: the note is the host's, and the transcript leaves it out
1311
+ * (isHostPromptMessage).
1312
+ */
1313
+ private addAgentMessage;
1314
+ /**
1315
+ * The agent panes' messages that waited for Main (agentPaneAsksWaiting) go into the conversation, in order, now.
1316
+ * Returns whether there were any.
1317
+ */
1318
+ private admitAgentPaneAsksWaiting;
1319
+ /**
1320
+ * The agent panes' messages that waited for Main get their turn now, if Main is free and nothing else is about to
1321
+ * start one: a wait the person closed with nothing after it leaves the queue paused, and its dispatch with it.
1322
+ */
1323
+ private runAgentPaneAsksWaiting;
1324
+ /**
1325
+ * From now on this ZTC takes an agent's message as it comes; take those that waited (waitingAgentMessages), in the
1326
+ * order they came, after the conversation startup restored and the turn of the task it was started with.
1327
+ */
1328
+ private admitWaitingAgentMessages;
1095
1329
  /**
1096
1330
  * Collapse the input to a single text segment with the cursor at `offset`.
1097
1331
  * Used by completion (slash / path / @-mention) which operates on plain text.
@@ -1254,7 +1488,7 @@ export declare class RatatuiApp {
1254
1488
  /** A transient choice shares the existing terminal and mirror widget contract. */
1255
1489
  private chooseBusyInputRoute;
1256
1490
  private retireBusyInputRouting;
1257
- /** Restore only an empty composer; retain a competing draft in the transcript. */
1491
+ /** Restore only an empty composer; retain a competing draft in the transcript. Says where it went, if anywhere. */
1258
1492
  private restoreBusyDraft;
1259
1493
  /**
1260
1494
  * `routerAttempt`: the steering takes the person's one real attempt past a Zerg Router refusal (see
@@ -1287,12 +1521,6 @@ export declare class RatatuiApp {
1287
1521
  * episode.
1288
1522
  */
1289
1523
  private accountGoalFinalTurn;
1290
- /**
1291
- * Account the just-finished turn against the active /goal and, if it should
1292
- * keep going, re-submit a continuation prompt (which re-enters runAgent and
1293
- * eventually lands back here — the loop). All stop conditions live in
1294
- * goalManager.onTurnComplete; this method only reacts to the decision.
1295
- */
1296
1524
  /**
1297
1525
  * Point the R7 task pin at the goal that is now driving.
1298
1526
  *
@@ -1303,6 +1531,13 @@ export declare class RatatuiApp {
1303
1531
  * objective.
1304
1532
  */
1305
1533
  private syncGoalPin;
1534
+ /**
1535
+ * Account the just-finished turn against the active /goal and, if it should
1536
+ * keep going, re-submit a continuation prompt (which re-enters runAgent and
1537
+ * eventually lands back here — the loop). All stop conditions live in
1538
+ * goalManager.onTurnComplete; this method only reacts to the decision. It
1539
+ * says whether it started the goal's next turn.
1540
+ */
1306
1541
  private maybeContinueGoal;
1307
1542
  /** Post a /goal status line to both the terminal transcript and the mirror. */
1308
1543
  private publishCurrentGoal;
@@ -1740,6 +1975,23 @@ export declare class RatatuiApp {
1740
1975
  * can never make `/resume` feel hung.
1741
1976
  */
1742
1977
  private openResumePanel;
1978
+ /**
1979
+ * Why Main's screen (pane 0) can't be read now: while it shows the person's sessions picker, whose titles are their
1980
+ * opening prompts, and for a moment after it closes, so a read the renderer answered from a frame that still held it
1981
+ * is refused too. No other pane, agent or mirror viewer reads it then (workspace spec §14).
1982
+ */
1983
+ private mainScreenReadRefusal;
1984
+ /**
1985
+ * The person's Claude Code and Codex sessions, Main's alone (see CommandContext.agentSessions): read only when they
1986
+ * open the picker or resume, and never sent anywhere.
1987
+ */
1988
+ private agentSessions;
1989
+ /**
1990
+ * Open the Claude Code or Codex sessions picker in Main (/claude resume, /codex sessions…). It paints at once and
1991
+ * fills as each session file's head is read; nothing is read before the person asks. In the desktop app Main takes
1992
+ * the keyboard while it is open, and gives it back to the pane that had it when it closes without opening one.
1993
+ */
1994
+ private openAgentSessionsPicker;
1743
1995
  /** /rewind and two idle Escapes open the picker only between turns. */
1744
1996
  private openRewindPanelWhenIdle;
1745
1997
  /**