@north-light/cli 0.3.707 → 0.3.709

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 (278) hide show
  1. package/dist/api/client.d.ts +1 -2
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/crons.d.ts +3 -0
  6. package/dist/api/dto/human.d.ts +9 -6
  7. package/dist/api/dto/inbox.d.ts +2 -0
  8. package/dist/api/dto/review-comments.d.ts +12 -35
  9. package/dist/api/dto/reviews.d.ts +3 -10
  10. package/dist/api/routes.d.ts +0 -1
  11. package/dist/api/routes.js +1 -1
  12. package/dist/builtin-memory/05-kinds/review/companion/00-base.md +2 -2
  13. package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
  14. package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
  15. package/dist/clients/attach/chrome/canvas-panels.js +1 -1
  16. package/dist/clients/attach/chrome/inbox-strip.js +1 -1
  17. package/dist/clients/attach/chrome/roster.js +6 -6
  18. package/dist/clients/attach/chrome/status-line.d.ts +1 -1
  19. package/dist/clients/attach/chrome/status-line.js +1 -1
  20. package/dist/clients/attach/chrome/ticket-panel.js +1 -1
  21. package/dist/clients/attach/input/capabilities.js +1 -1
  22. package/dist/clients/attach/input/controller.d.ts +4 -1
  23. package/dist/clients/attach/input/controller.js +3 -3
  24. package/dist/clients/attach/input/overlay-owner.d.ts +0 -1
  25. package/dist/clients/attach/input/overlay-owner.js +1 -1
  26. package/dist/clients/attach/overlays/graph.d.ts +3 -2
  27. package/dist/clients/attach/overlays/graph.js +1 -1
  28. package/dist/clients/attach/render/chat-view.d.ts +2 -0
  29. package/dist/clients/attach/render/chat-view.js +1 -1
  30. package/dist/clients/attach/render/doc-links.d.ts +1 -1
  31. package/dist/clients/attach/session/chrome-refresh.js +1 -1
  32. package/dist/clients/attach/session/connection.d.ts +10 -9
  33. package/dist/clients/attach/session/connection.js +1 -1
  34. package/dist/clients/attach/session/context.d.ts +1 -1
  35. package/dist/clients/attach/session/document-links.d.ts +1 -1
  36. package/dist/clients/attach/session/document-links.js +1 -1
  37. package/dist/clients/attach/session/identity.d.ts +2 -0
  38. package/dist/clients/attach/session/identity.js +1 -1
  39. package/dist/clients/attach/session/input-wiring.d.ts +2 -0
  40. package/dist/clients/attach/session/input-wiring.js +1 -1
  41. package/dist/clients/attach/session/keys.d.ts +2 -2
  42. package/dist/clients/attach/session/keys.js +1 -1
  43. package/dist/clients/attach/session/pane-tag.d.ts +3 -1
  44. package/dist/clients/attach/session/pane-tag.js +1 -1
  45. package/dist/clients/attach/session/reconnect.js +1 -1
  46. package/dist/clients/attach/session/surface-host.d.ts +0 -5
  47. package/dist/clients/attach/session/surface-host.js +1 -1
  48. package/dist/clients/attach/session/teardown.d.ts +2 -2
  49. package/dist/clients/attach/session/teardown.js +9 -7
  50. package/dist/clients/attach/viewer.d.ts +7 -5
  51. package/dist/clients/attach/viewer.js +571 -584
  52. package/dist/clients/editor-roundtrip.js +3 -0
  53. package/dist/clients/inbox/controller.d.ts +1 -6
  54. package/dist/clients/inbox/controller.js +1 -1
  55. package/dist/clients/inbox/dto-adapt.js +1 -1
  56. package/dist/clients/inbox/tui/page-body.js +1 -1
  57. package/dist/clients/inbox/tui/render.js +2 -2
  58. package/dist/clients/open-browser.d.ts +2 -0
  59. package/dist/clients/open-browser.js +1 -0
  60. package/dist/clients/surfaces/host.d.ts +0 -6
  61. package/dist/commands/human/review.js +1 -1
  62. package/dist/commands/node/wait.js +2 -6
  63. package/dist/commands/sys/context/admin/shell.js +1 -1
  64. package/dist/core/broker-client/client.d.ts +6 -3
  65. package/dist/core/broker-client/client.js +1 -1
  66. package/dist/core/canvas/crons.d.ts +11 -1
  67. package/dist/core/canvas/crons.js +14 -14
  68. package/dist/core/canvas/executions.js +1 -1
  69. package/dist/core/canvas/schema-pg/025-review-anchors.sql +19 -0
  70. package/dist/core/canvas/schema-pg/026-cron-deadline-body.sql +9 -0
  71. package/dist/core/canvas/schema-pg/027-cron-fires.sql +4 -0
  72. package/dist/core/canvas/schema-version.d.ts +1 -1
  73. package/dist/core/canvas/schema-version.js +1 -1
  74. package/dist/core/command.js +5 -5
  75. package/dist/core/feed/messages.d.ts +5 -0
  76. package/dist/core/feed/messages.js +5 -5
  77. package/dist/core/human/page-markdown.js +10 -12
  78. package/dist/core/human/tickets.js +1 -1
  79. package/dist/core/human/types.d.ts +4 -6
  80. package/dist/core/keybindings/attach-control.d.ts +0 -3
  81. package/dist/core/keybindings/attach-control.js +1 -1
  82. package/dist/core/keybindings/catalog.d.ts +1 -1
  83. package/dist/core/keybindings/catalog.js +1 -1
  84. package/dist/core/review/anchors.d.ts +28 -0
  85. package/dist/core/review/anchors.js +6 -0
  86. package/dist/core/review/comments.d.ts +2 -2
  87. package/dist/core/review/comments.js +7 -8
  88. package/dist/core/review/companion.d.ts +2 -1
  89. package/dist/core/review/companion.js +1 -1
  90. package/dist/core/review/document.d.ts +4 -17
  91. package/dist/core/review/document.js +1 -2
  92. package/dist/core/review/fork.js +2 -4
  93. package/dist/core/review/project.d.ts +1 -1
  94. package/dist/core/review/project.js +2 -2
  95. package/dist/core/review/realize.js +1 -1
  96. package/dist/core/review/stage.d.ts +2 -9
  97. package/dist/core/review/stage.js +1 -1
  98. package/dist/core/review/types.d.ts +16 -12
  99. package/dist/core/review/types.js +1 -1
  100. package/dist/core/runtime/bearings.js +4 -4
  101. package/dist/core/runtime/boot-root.js +4 -4
  102. package/dist/core/runtime/broker-cli.js +3 -3
  103. package/dist/core/runtime/broker-extension-render.js +1 -1
  104. package/dist/core/runtime/lifecycle.js +2 -2
  105. package/dist/core/runtime/revive.js +2 -2
  106. package/dist/core/runtime/runner/blaxel/client.d.ts +4 -0
  107. package/dist/core/runtime/runner/blaxel/client.js +1 -1
  108. package/dist/core/runtime/runner/blaxel/runner.d.ts +2 -3
  109. package/dist/core/runtime/runner/blaxel/runner.js +3 -3
  110. package/dist/core/runtime/runner/delete-sandboxes.d.ts +5 -0
  111. package/dist/core/runtime/runner/delete-sandboxes.js +6 -1
  112. package/dist/core/runtime/runner/types.d.ts +19 -3
  113. package/dist/core/runtime/tmux-bindings.js +3 -3
  114. package/dist/daemon/api/bridge.d.ts +5 -0
  115. package/dist/daemon/api/bridge.js +3 -3
  116. package/dist/daemon/api/canvas-host.js +1 -1
  117. package/dist/daemon/api/document-page.d.ts +12 -1
  118. package/dist/daemon/api/document-page.js +6 -6
  119. package/dist/daemon/api/handlers/crons.d.ts +2 -0
  120. package/dist/daemon/api/handlers/crons.js +1 -1
  121. package/dist/daemon/api/handlers/inbox.js +1 -1
  122. package/dist/daemon/api/handlers/nodes.js +1 -1
  123. package/dist/daemon/api/handlers/review-comments.js +1 -1
  124. package/dist/daemon/api/handlers/reviews.js +1 -1
  125. package/dist/daemon/api/map.js +2 -2
  126. package/dist/daemon/api/operations.js +1 -1
  127. package/dist/daemon/api/review-page.d.ts +3 -0
  128. package/dist/daemon/api/review-page.js +13 -0
  129. package/dist/daemon/broker-memory-cap.d.ts +9 -0
  130. package/dist/daemon/broker-memory-cap.js +2 -0
  131. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  132. package/dist/daemon/broker-signals/bus.js +1 -1
  133. package/dist/daemon/cron/ended.d.ts +3 -0
  134. package/dist/daemon/cron/ended.js +2 -2
  135. package/dist/daemon/cron/lease-recovery.js +1 -1
  136. package/dist/daemon/cron/machine-fire.d.ts +9 -2
  137. package/dist/daemon/cron/machine-fire.js +1 -1
  138. package/dist/daemon/cron/passes.js +1 -1
  139. package/dist/daemon/cron-run.js +2 -2
  140. package/dist/daemon/crtrd.js +14 -14
  141. package/dist/daemon/machine-daemon.js +1 -1
  142. package/dist/daemon/machine-link/client.js +1 -1
  143. package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
  144. package/dist/daemon/reconcilers/idle-sandbox.d.ts +1 -1
  145. package/dist/daemon/reconcilers/idle-sandbox.js +2 -2
  146. package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
  147. package/dist/daemon/review/comment-notify.js +2 -2
  148. package/dist/daemon/review/deliver.d.ts +2 -2
  149. package/dist/daemon/review/deliver.js +6 -2
  150. package/dist/daemon/review/finish.js +1 -1
  151. package/dist/doc-editor/Geist-Variable.woff2 +0 -0
  152. package/dist/doc-editor/GeistMono-Variable.woff2 +0 -0
  153. package/dist/doc-editor/editor.css +1 -1
  154. package/dist/doc-editor/review.css +2 -0
  155. package/dist/doc-editor/review.js +149 -0
  156. package/dist/pi-extensions/canvas-review-boundary.js +3 -3
  157. package/docs/sdk/release-notes.md +6 -0
  158. package/package.json +13 -4
  159. package/packages/crouter-api/dist/api/client.js +0 -3
  160. package/packages/crouter-api/dist/api/contract.js +1 -1
  161. package/packages/crouter-api/dist/api/routes.js +0 -1
  162. package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +3 -3
  163. package/packages/crouter-api/dist/clients/attach/chrome/inbox-strip.js +5 -5
  164. package/packages/crouter-api/dist/clients/attach/chrome/roster.js +17 -28
  165. package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +2 -7
  166. package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +1 -1
  167. package/packages/crouter-api/dist/clients/attach/input/capabilities.js +2 -1
  168. package/packages/crouter-api/dist/clients/attach/input/controller.js +17 -3
  169. package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +0 -7
  170. package/packages/crouter-api/dist/clients/attach/overlays/graph.js +4 -3
  171. package/packages/crouter-api/dist/clients/attach/render/chat-view.js +9 -0
  172. package/packages/crouter-api/dist/clients/attach/session/chrome-refresh.js +6 -3
  173. package/packages/crouter-api/dist/clients/attach/session/connection.js +53 -53
  174. package/packages/crouter-api/dist/clients/attach/session/document-links.js +1 -1
  175. package/packages/crouter-api/dist/clients/attach/session/identity.js +1 -0
  176. package/packages/crouter-api/dist/clients/attach/session/input-wiring.js +4 -3
  177. package/packages/crouter-api/dist/clients/attach/session/keys.js +11 -5
  178. package/packages/crouter-api/dist/clients/attach/session/pane-tag.js +7 -1
  179. package/packages/crouter-api/dist/clients/attach/session/reconnect.js +3 -3
  180. package/packages/crouter-api/dist/clients/attach/session/surface-host.js +0 -17
  181. package/packages/crouter-api/dist/clients/attach/session/teardown.js +7 -4
  182. package/packages/crouter-api/dist/clients/attach/viewer.js +77 -67
  183. package/packages/crouter-api/dist/clients/{inbox/review/roundtrip.js → editor-roundtrip.js} +1 -1
  184. package/packages/crouter-api/dist/clients/inbox/controller.js +12 -31
  185. package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +1 -0
  186. package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +0 -7
  187. package/packages/crouter-api/dist/clients/inbox/tui/render.js +0 -7
  188. package/packages/crouter-api/dist/clients/open-browser.js +6 -0
  189. package/packages/crouter-api/dist/commands/human/review.js +17 -18
  190. package/packages/crouter-api/dist/commands/node/wait.js +2 -10
  191. package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +1 -1
  192. package/packages/crouter-api/dist/core/broker-client/client.js +20 -10
  193. package/packages/crouter-api/dist/core/canvas/crons.js +26 -10
  194. package/packages/crouter-api/dist/core/canvas/executions.js +7 -2
  195. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  196. package/packages/crouter-api/dist/core/command.js +3 -0
  197. package/packages/crouter-api/dist/core/feed/messages.js +15 -0
  198. package/packages/crouter-api/dist/core/human/page-markdown.js +2 -6
  199. package/packages/crouter-api/dist/core/human/tickets.js +2 -11
  200. package/packages/crouter-api/dist/core/keybindings/attach-control.js +0 -1
  201. package/packages/crouter-api/dist/core/keybindings/catalog.js +1 -3
  202. package/packages/crouter-api/dist/core/review/anchors.js +91 -0
  203. package/packages/crouter-api/dist/core/review/comments.js +27 -46
  204. package/packages/crouter-api/dist/core/review/companion.js +5 -9
  205. package/packages/crouter-api/dist/core/review/document.js +17 -89
  206. package/packages/crouter-api/dist/core/review/project.js +2 -1
  207. package/packages/crouter-api/dist/core/review/types.js +2 -2
  208. package/packages/crouter-api/dist/core/runtime/bearings.js +2 -2
  209. package/packages/crouter-api/dist/core/runtime/lifecycle.js +3 -0
  210. package/packages/crouter-api/dist/core/runtime/revive.js +5 -25
  211. package/packages/crouter-api/dist/core/runtime/runner/blaxel/client.js +15 -8
  212. package/packages/crouter-api/dist/core/runtime/runner/blaxel/runner.js +60 -19
  213. package/packages/crouter-api/dist/core/runtime/runner/delete-sandboxes.js +18 -2
  214. package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +0 -5
  215. package/packages/crouter-api/dist/daemon/api/map.js +2 -6
  216. package/packages/crouter-api/dist/daemon/api/operations.js +2 -2
  217. package/packages/crouter-api/dist/daemon/broker-signals/bus.js +1 -1
  218. package/packages/crouter-api/dist/daemon/cron/ended.js +22 -11
  219. package/packages/crouter-api/dist/daemon/cron/machine-fire.js +69 -6
  220. package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
  221. package/packages/crouter-api/dist/daemon/review/deliver.js +4 -3
  222. package/packages/crouter-api/dist/daemon/review/finish.js +26 -47
  223. package/packages/crouter-api/package.json +1 -1
  224. package/packages/crouter-identity/package.json +1 -1
  225. package/packages/crouter-plugin/package.json +3 -3
  226. package/runtime.lock.json +1740 -505
  227. package/dist/clients/attach/overlays/file-review.d.ts +0 -10
  228. package/dist/clients/attach/overlays/file-review.js +0 -2
  229. package/dist/clients/inbox/review/anchors.d.ts +0 -41
  230. package/dist/clients/inbox/review/anchors.js +0 -1
  231. package/dist/clients/inbox/review/comments-client.d.ts +0 -74
  232. package/dist/clients/inbox/review/comments-client.js +0 -1
  233. package/dist/clients/inbox/review/companion-pane.d.ts +0 -47
  234. package/dist/clients/inbox/review/companion-pane.js +0 -1
  235. package/dist/clients/inbox/review/document-surface.d.ts +0 -212
  236. package/dist/clients/inbox/review/document-surface.js +0 -2
  237. package/dist/clients/inbox/review/frame.d.ts +0 -57
  238. package/dist/clients/inbox/review/frame.js +0 -1
  239. package/dist/clients/inbox/review/keys.d.ts +0 -69
  240. package/dist/clients/inbox/review/keys.js +0 -1
  241. package/dist/clients/inbox/review/launch.d.ts +0 -16
  242. package/dist/clients/inbox/review/launch.js +0 -1
  243. package/dist/clients/inbox/review/live-source.d.ts +0 -24
  244. package/dist/clients/inbox/review/live-source.js +0 -1
  245. package/dist/clients/inbox/review/nvim.d.ts +0 -15
  246. package/dist/clients/inbox/review/nvim.js +0 -1
  247. package/dist/clients/inbox/review/remap.d.ts +0 -51
  248. package/dist/clients/inbox/review/remap.js +0 -1
  249. package/dist/clients/inbox/review/review-client.d.ts +0 -43
  250. package/dist/clients/inbox/review/review-client.js +0 -1
  251. package/dist/clients/inbox/review/roundtrip.js +0 -3
  252. package/dist/clients/inbox/review/state.d.ts +0 -153
  253. package/dist/clients/inbox/review/state.js +0 -4
  254. package/dist/clients/inbox/review-adapter.d.ts +0 -17
  255. package/dist/clients/inbox/review-adapter.js +0 -1
  256. package/dist/core/review/remap.d.ts +0 -24
  257. package/dist/core/review/remap.js +0 -19
  258. package/dist/core/review/signal.d.ts +0 -5
  259. package/dist/core/review/signal.js +0 -1
  260. package/dist/core/runtime/starting-screen.d.ts +0 -12
  261. package/dist/core/runtime/starting-screen.js +0 -9
  262. package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +0 -146
  263. package/packages/crouter-api/dist/clients/inbox/review/anchors.js +0 -89
  264. package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +0 -103
  265. package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +0 -109
  266. package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +0 -1268
  267. package/packages/crouter-api/dist/clients/inbox/review/frame.js +0 -309
  268. package/packages/crouter-api/dist/clients/inbox/review/keys.js +0 -133
  269. package/packages/crouter-api/dist/clients/inbox/review/launch.js +0 -170
  270. package/packages/crouter-api/dist/clients/inbox/review/live-source.js +0 -160
  271. package/packages/crouter-api/dist/clients/inbox/review/nvim.js +0 -43
  272. package/packages/crouter-api/dist/clients/inbox/review/remap.js +0 -157
  273. package/packages/crouter-api/dist/clients/inbox/review/review-client.js +0 -125
  274. package/packages/crouter-api/dist/clients/inbox/review/state.js +0 -315
  275. package/packages/crouter-api/dist/clients/inbox/review-adapter.js +0 -43
  276. package/packages/crouter-api/dist/core/review/signal.js +0 -12
  277. package/packages/crouter-api/dist/core/termrender/code-doc.js +0 -92
  278. /package/dist/clients/{inbox/review/roundtrip.d.ts → editor-roundtrip.d.ts} +0 -0
@@ -63,61 +63,61 @@ export async function preWaitForViewSocket(nodeId) {
63
63
  await new Promise((r) => setTimeout(r, 100));
64
64
  }
65
65
  }
66
- /** Resolve the attach target and build the not-yet-connected socket. Rejects with
67
- * a plain `InputError` for an unknown node — no terminal has been taken over yet. */
68
- export async function connectToNode(nodeId, canvasName, wakeParked = true, known) {
66
+ /** Build the not-yet-connected socket and canvas source. No node is resolved or dialed until `bind` names one: a viewer whose root is
67
+ * still being created paints first and binds when the create returns. `bind` rejects with a plain `InputError` for an unknown node. */
68
+ export function connectToNode(canvasName, wakeParked = true) {
69
69
  // An imported Mac has no local canvas API: its canvas and its brokers' viewer channels are reached through the cloud control plane,
70
70
  // so attach without `--canvas` dials the cloud with the person's sign-in. It is still the person's own attach, not a `--canvas` view:
71
71
  // `remote` stays false, so the viewer claims the controller role like any local attach.
72
72
  const remote = canvasName !== undefined;
73
73
  const machine = remote ? undefined : readMachineConfig();
74
- // Attach must NOT silently honor a durable `crtr canvas use` selection: the
75
- // local branch has a hard local-unix-socket assumption baked into its
76
- // not-found and reconnect-give-up handling, so an implicit remote redirect
77
- // (from a `canvas use cloud` some other command left active) would be
78
- // surprising for a command whose whole meaning is "attach to a node on THIS
79
- // canvas". Go remote ONLY when `--canvas` was passed on THIS invocation —
80
- // never fall through to resolveCanvasSource's activeCanvas precedence, which
81
- // is right for `node inspect`/`canvas browse` but not here.
74
+ // Attach must NOT silently honor a durable `crtr canvas use` selection: go remote ONLY when `--canvas` was passed on THIS invocation —
75
+ // never fall through to resolveCanvasSource's activeCanvas precedence, which is right for `node inspect`/`canvas browse` but not here.
82
76
  const canvasSource = canvasName !== undefined ? cliCanvasSource({ canvasName }) : new ApiCanvasSource();
83
- // A remote node id never exists in THIS machine's canvas.db, so the local
84
- // not-found guard is wrong for `--canvas`. Build a minimal local `meta`
85
- // stand-in instead: `meta.cwd` is a legitimately viewer-local concern
86
- // (theming, this pane's own git status) — not a remote-node concern — so
87
- // pointing it at the CLI's own cwd is correct, not a hack. The `getRow`-based
88
- // reconnect give-up is the other local-canvas dependency `--canvas` must skip;
89
- // it gates on `remote` at its own use site, not here.
90
- let meta;
91
- let nodeIdentity;
92
- let transport;
93
- if (canvasName !== undefined) {
94
- meta = { cwd: process.cwd() };
95
- transport = new RelayTransport(nodeId, resolveRemoteCanvasTarget(canvasName));
96
- }
97
- else {
98
- // A caller that just created the node already holds its detail: no second read.
99
- const localMeta = known ?? await canvasSource.getNode(nodeId);
100
- if (localMeta === null) {
101
- throw new InputError({
102
- error: 'not_found',
103
- message: `no node: ${nodeId}`,
104
- received: nodeId,
105
- next: 'List nodes with `crtr node inspect list`.',
106
- });
107
- }
108
- meta = localMeta;
109
- nodeIdentity = localMeta;
110
- if (machine !== undefined) {
111
- // On a Mac the viewer's WebSocket upgrade alone admits the attach: it authorizes, revives and waits for the broker once, and its channel
112
- // is the viewer's. A focus of a parked node dials without waking it; the upgrade's `node_dormant` refusal says the node is parked.
113
- transport = new RelayTransport(nodeId, await machineRelayTarget(machine.apiUrl, machine.directoryUrl), wakeParked);
77
+ const socket = new BrokerClient(undefined);
78
+ let boundId;
79
+ const nodeId = () => {
80
+ if (boundId === undefined)
81
+ throw new Error('attach has no node yet');
82
+ return boundId;
83
+ };
84
+ /** Build the transport for `id` and give it to the socket. A remote node id never exists in THIS machine's canvas.db, so `--canvas`
85
+ * skips the local lookup and uses the CLI's own cwd as `meta` (theming and this pane's git status are viewer-local concerns). */
86
+ const bind = async (id, known) => {
87
+ boundId = id;
88
+ let transport;
89
+ let meta;
90
+ let nodeIdentity;
91
+ if (canvasName !== undefined) {
92
+ meta = { cwd: process.cwd() };
93
+ transport = new RelayTransport(id, resolveRemoteCanvasTarget(canvasName));
114
94
  }
115
95
  else {
116
- // The attach ensure runs in `dial()`; the viewer connects through crtrd's Unix-socket WebSocket bridge.
117
- transport = new RelayTransport(nodeId, { socketPath: apiSocketPath() });
96
+ // A caller that just created the node already holds its detail: no second read.
97
+ const localMeta = known ?? await canvasSource.getNode(id);
98
+ if (localMeta === null) {
99
+ throw new InputError({
100
+ error: 'not_found',
101
+ message: `no node: ${id}`,
102
+ received: id,
103
+ next: 'List nodes with `crtr node inspect list`.',
104
+ });
105
+ }
106
+ meta = localMeta;
107
+ nodeIdentity = localMeta;
108
+ if (machine !== undefined) {
109
+ // On a Mac the viewer's WebSocket upgrade alone admits the attach: it authorizes, revives and waits for the broker once, and its channel
110
+ // is the viewer's. A focus of a parked node dials without waking it; the upgrade's `node_dormant` refusal says the node is parked.
111
+ transport = new RelayTransport(id, await machineRelayTarget(machine.apiUrl, machine.directoryUrl), wakeParked);
112
+ }
113
+ else {
114
+ // The attach ensure runs in `dial()`; the viewer connects through crtrd's Unix-socket WebSocket bridge.
115
+ transport = new RelayTransport(id, { socketPath: apiSocketPath() });
116
+ }
118
117
  }
119
- }
120
- const socket = new BrokerClient(nodeId, { transport });
118
+ socket.bindTransport(transport);
119
+ return { meta, nodeIdentity };
120
+ };
121
121
  const local = canvasName === undefined && machine === undefined;
122
122
  /** One error shape for a connect-time failure. */
123
123
  const toAttachError = (err) => {
@@ -129,19 +129,19 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
129
129
  return new InputError({
130
130
  error: 'no_broker',
131
131
  message: err.message,
132
- received: nodeId,
132
+ received: nodeId(),
133
133
  next: 'Focus or revive the node first — attach needs a running headless broker.',
134
134
  });
135
135
  }
136
136
  return new InputError({
137
137
  error: 'socket_error',
138
- message: `could not attach to node ${nodeId}: ${String(err?.message ?? err)}`,
139
- received: nodeId,
138
+ message: `could not attach to node ${nodeId()}: ${String(err?.message ?? err)}`,
139
+ received: nodeId(),
140
140
  next: 'Check the node has a running headless broker.',
141
141
  });
142
142
  };
143
143
  const parkedSnapshot = async () => {
144
- const saved = await cliClient().getSnapshot(nodeId);
144
+ const saved = await cliClient().getSnapshot(nodeId());
145
145
  // The API DTO stays dependency-light and structural; this viewer is the
146
146
  // consumer that knows the complete broker snapshot contract.
147
147
  return { snapshot: saved.snapshot, commands: saved.commands };
@@ -151,7 +151,7 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
151
151
  // Attach revives a dormant node (B2 acceptance): the server-side ensureAttach runs reviveNode (the ONE sanctioned launcher)
152
152
  // and waits for the broker's view socket. The daemon, not the broker, owns attending viewer presence.
153
153
  try {
154
- const attach = await cliClient().ensureAttach(nodeId, { resume: true, revive: true, wakeParked });
154
+ const attach = await cliClient().ensureAttach(nodeId(), { resume: true, revive: true, wakeParked });
155
155
  // A parked node focused without waking has deliberately no socket to wait for.
156
156
  if (attach.parked)
157
157
  return await parkedSnapshot();
@@ -159,7 +159,7 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
159
159
  catch (err) {
160
160
  rethrowAsCliError(err, 'The node may be finalized or otherwise not attachable.');
161
161
  }
162
- await preWaitForViewSocket(nodeId);
162
+ await preWaitForViewSocket(nodeId());
163
163
  }
164
164
  try {
165
165
  await new Promise((resolve, reject) => {
@@ -181,5 +181,5 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
181
181
  mark('viewer.transport_open');
182
182
  return undefined;
183
183
  };
184
- return { remote, canvasSource, meta, nodeIdentity, socket, dial };
184
+ return { remote, canvasSource, socket, bind, dial };
185
185
  }
@@ -29,7 +29,7 @@ export function createDocumentLinks(opts) {
29
29
  }, () => { rosterLoaded = false; });
30
30
  };
31
31
  const context = {
32
- selfNodeId: opts.selfNodeId,
32
+ get selfNodeId() { return opts.selfNodeId(); },
33
33
  nodeName: (nodeId) => {
34
34
  const name = names.get(nodeId);
35
35
  if (name === undefined)
@@ -11,6 +11,7 @@ export function createNodeIdentity(ctx, initial, hooks) {
11
11
  let identity = initial;
12
12
  return {
13
13
  current: () => identity,
14
+ set: (value) => { identity = value; hooks.onChanged(); },
14
15
  refresh: () => {
15
16
  void ctx.canvasSource
16
17
  .getNode(ctx.nodeId)
@@ -21,7 +21,7 @@ import { defaultAgentDir } from '../config.js';
21
21
  /** Construct the viewer's one capability authority. */
22
22
  export function createViewerCapabilitiesForInput(ctx, isBrokerOffline) {
23
23
  return createViewerCapabilities({
24
- nodeId: ctx.nodeId,
24
+ get nodeId() { return ctx.nodeId; },
25
25
  profileId: ctx.meta.profile_id ?? undefined,
26
26
  remote: ctx.remote,
27
27
  role: ctx.role,
@@ -45,7 +45,7 @@ export function lessDetailNotice(change) {
45
45
  }
46
46
  /** Build the viewer's InputController with every hook answered. */
47
47
  export function createInputController(ctx, km, capabilities, hooks) {
48
- const { nodeId, socket, tui, editor, containers } = ctx;
48
+ const { socket, tui, editor, containers } = ctx;
49
49
  const { setNotice } = hooks;
50
50
  // Auth pickers — viewer-local OAuth/API-key flows against the SAME auth.json
51
51
  // the broker uses (broker + viewer share a filesystem in the tmux-local attach
@@ -129,6 +129,7 @@ export function createInputController(ctx, km, capabilities, hooks) {
129
129
  // broker (it goes to crtrd via `cliClient`), so leaving it wired for an
130
130
  // observer would let a read-only viewer wake and message the node.
131
131
  isDormant: hooks.isDormant,
132
+ isStarting: hooks.isStarting,
132
133
  onDormantSubmit: !capabilities.permits('wake-dormant') ? undefined : (msgText) => {
133
134
  void (async () => {
134
135
  try {
@@ -137,7 +138,7 @@ export function createInputController(ctx, km, capabilities, hooks) {
137
138
  // (verbatim, no "From … — N updates" digest; see coalesce()), exactly
138
139
  // like the live path. NOT `CRTR_NODE_ID`: direct keyboard input is
139
140
  // the human, not whatever node owns the shell that launched us.
140
- const res = await cliClient().sendMessage(nodeId, { body: msgText, from: 'human' });
141
+ const res = await cliClient().sendMessage(ctx.nodeId, { body: msgText, from: 'human' });
141
142
  setNotice(res.revived ? '↻ waking node…' : '✉ delivered — node reads on next wake');
142
143
  }
143
144
  catch (err) {
@@ -16,6 +16,13 @@ const CLEAR_OR_DETACH_MS = 1000;
16
16
  export function installGlobalKeys(ctx, hooks) {
17
17
  const { tui, editor } = ctx;
18
18
  let lastClearOrDetachAt = 0;
19
+ // The one starting check for every node-relative action; detach, clear, help, search, the inbox and the request strip work without a node.
20
+ const needsNode = (run) => () => {
21
+ if (hooks.isStarting())
22
+ hooks.setNotice('The node is starting — try again in a moment');
23
+ else
24
+ run();
25
+ };
19
26
  const actions = {
20
27
  'crtr.attach.detach': hooks.detach,
21
28
  'crtr.attach.clear-or-detach': () => {
@@ -30,18 +37,17 @@ export function installGlobalKeys(ctx, hooks) {
30
37
  hooks.setNotice(`Editor cleared — press ${hooks.detachHint()} again to cancel the agent`);
31
38
  tui.requestRender();
32
39
  },
33
- 'crtr.attach.graph.toggle': hooks.toggleGraph,
40
+ 'crtr.attach.graph.toggle': needsNode(hooks.toggleGraph),
34
41
  'crtr.attach.help.toggle': hooks.toggleHelp,
35
42
  'crtr.attach.inbox.toggle': hooks.toggleInbox,
36
43
  'crtr.attach.inbox-strip': hooks.toggleInboxStrip,
37
44
  // A plain broker frame, so this works locally and remotely alike; the broker gates observers on controller role.
38
45
  'crtr.attach.model-ladder.next': () => hooks.cycleModelLadder('forward'),
39
46
  'crtr.attach.model-ladder.previous': () => hooks.cycleModelLadder('backward'),
40
- 'crtr.attach.command.inspect': hooks.inspectLoadedCommand,
41
- 'crtr.attach.file-review': hooks.openFileReview,
42
- 'crtr.attach.profile-files': hooks.openProfileFiles,
47
+ 'crtr.attach.command.inspect': needsNode(hooks.inspectLoadedCommand),
48
+ 'crtr.attach.profile-files': needsNode(hooks.openProfileFiles),
43
49
  'crtr.attach.search': hooks.openSearch,
44
- 'crtr.attach.whip': hooks.whip,
50
+ 'crtr.attach.whip': needsNode(hooks.whip),
45
51
  'crtr.attach.reload-viewer': hooks.reloadViewer,
46
52
  };
47
53
  return tui.addInputListener((data) => {
@@ -31,10 +31,16 @@ export function createPaneTag(remote, nodeId, io = realPaneTagIo) {
31
31
  set: () => {
32
32
  pane = io.currentPane();
33
33
  claimAttachPane(pane, ownerPid, io.writeOption);
34
- tagAttachPane(remote, pane, nodeId, io.writeOption);
34
+ if (nodeId !== undefined)
35
+ tagAttachPane(remote, pane, nodeId, io.writeOption);
35
36
  tagAttachViewerPane(pane, io.writeOption);
36
37
  stampAttachPane(remote, pane, io.writeOption);
37
38
  },
39
+ bindNode: (id) => {
40
+ nodeId = id;
41
+ if (pane !== undefined)
42
+ tagAttachPane(remote, pane, id, io.writeOption);
43
+ },
38
44
  stamp: () => {
39
45
  if (remote || pane === undefined || pane === '')
40
46
  return;
@@ -13,7 +13,7 @@ const RECONNECT_ACTIVE_DELAY_CAP_MS = 1_000;
13
13
  /** Dormant by choice — low-rate patience. */
14
14
  const RECONNECT_DORMANT_DELAY_MS = 3_000;
15
15
  export function createReconnect(ctx, hooks) {
16
- const { nodeId, socket, canvasSource } = ctx;
16
+ const { socket, canvasSource } = ctx;
17
17
  let lastSocketError;
18
18
  let reconnecting = false;
19
19
  let viewerDormant = false;
@@ -86,7 +86,7 @@ export function createReconnect(ctx, hooks) {
86
86
  // `--canvas`, so `getRow` works for both cases — always attempt it.
87
87
  let row;
88
88
  try {
89
- row = await canvasSource.getRow(nodeId);
89
+ row = await canvasSource.getRow(ctx.nodeId);
90
90
  }
91
91
  catch {
92
92
  row = undefined;
@@ -168,7 +168,7 @@ export function createReconnect(ctx, hooks) {
168
168
  // attach closed that way before the session's first welcome is a refusal,
169
169
  // not a broker to redial; a plain drop or a 1011 "no running broker" is redialed.
170
170
  if (hooks.remote && hooks.role === 'controller' && refusedByRelay && !welcomed) {
171
- lastSocketError = `the remote canvas refused the attach to ${nodeId}. A writable attach needs message permission on the node; with read permission only, attach with --observer.`;
171
+ lastSocketError = `the remote canvas refused the attach to ${ctx.nodeId}. A writable attach needs message permission on the node; with read permission only, attach with --observer.`;
172
172
  hooks.teardown('broker-gone');
173
173
  return;
174
174
  }
@@ -2,7 +2,6 @@ import { truncateToWidth, } from '@earendil-works/pi-tui';
2
2
  import { cliClient } from '../../../commands/api-client.js';
3
3
  import { focusViewer } from '../../../core/runtime/focus-viewer.js';
4
4
  import { daemonErrorMessage } from '../../inbox/resolve.js';
5
- import { buildFileReviewPicker } from '../overlays/file-review.js';
6
5
  import { reportInvariant as report } from './invariant.js';
7
6
  import { SurfaceFrame } from './surface-frame.js';
8
7
  const SURFACE_OVERLAY_OPTIONS = {
@@ -120,22 +119,6 @@ export class ViewerSurfaceHost {
120
119
  return false;
121
120
  }
122
121
  }
123
- pickReviewFile(spec) {
124
- return new Promise((resolve) => {
125
- let handle;
126
- let settled = false;
127
- const settle = (value) => {
128
- if (settled)
129
- return;
130
- settled = true;
131
- resolve(value);
132
- handle.close();
133
- };
134
- const picker = buildFileReviewPicker(spec.candidates, spec.cwd, (file) => settle(file), () => settle(null), (message) => this.notice(message));
135
- handle = this.mount(titled(picker.component, spec.title), { focus: picker.focus });
136
- handle.onClose(() => settle(null));
137
- });
138
- }
139
122
  /** Offer wheel input to the topmost surface only. */
140
123
  handleWheel(direction, lines) {
141
124
  return this.stack[this.stack.length - 1]?.component.handleWheel?.(direction, lines) ?? false;
@@ -25,7 +25,7 @@
25
25
  import { closePane, currentTmux, inTmux } from '../../../core/runtime/placement-tmux.js';
26
26
  import { FOCUS_REPORTING_OFF } from './focus-events.js';
27
27
  export function createTeardown(s, hooks) {
28
- const { tui, socket, nodeId, remote } = s;
28
+ const { tui, socket, remote } = s;
29
29
  let restored = false;
30
30
  const restore = () => {
31
31
  if (restored)
@@ -69,9 +69,12 @@ export function createTeardown(s, hooks) {
69
69
  // buy immediate cleanup (future work).
70
70
  if (reason === 'broker-gone') {
71
71
  const msg = hooks.lastSocketError() ??
72
- `broker gone — node ${nodeId} is no longer running its engine.`;
73
- process.stderr.write(`\n${msg}\nReattach with: ${hooks.reattachCommand}\n`);
72
+ `broker gone — node ${s.nodeId} is no longer running its engine.`;
73
+ process.stderr.write(`\n${msg}\nReattach with: ${hooks.reattachCommand()}\n`);
74
74
  }
75
+ // No node id exists, so there is nothing to reattach to and nothing to claim about the server's state: print the error alone.
76
+ if (reason === 'create-failed')
77
+ process.stderr.write(`\n${hooks.lastSocketError() ?? 'creating the node failed'}\n`);
75
78
  const unsent = hooks.undelivered();
76
79
  if (unsent.length > 0)
77
80
  process.stderr.write(`\nNot delivered:\n${unsent.join('\n---\n')}\n`);
@@ -80,7 +83,7 @@ export function createTeardown(s, hooks) {
80
83
  // (siblings in a swap-pane window survive); the daemon reconciles the
81
84
  // now-gone viewer row.
82
85
  if (reason === 'node-done') {
83
- process.stderr.write(`\n✓ node ${nodeId} finished — final report submitted.\n`);
86
+ process.stderr.write(`\n✓ node ${s.nodeId} finished — final report submitted.\n`);
84
87
  const pane = hooks.tagPane() ?? process.env['TMUX_PANE'] ?? currentTmux()?.pane;
85
88
  if (!remote && pane !== undefined && inTmux())
86
89
  closePane(pane);