@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
@@ -49,8 +49,6 @@ import { FOCUS_REPORTING_ON } from './session/focus-events.js';
49
49
  import { GraphOverlay } from './overlays/graph.js';
50
50
  import { HelpOverlay } from './overlays/help.js';
51
51
  import { applyTheme, attachPalette, createKeybindingsManager, mirrorKeybindingsToEditor, mirrorKittyProtocolToEditor, resolveFdPath, } from './config.js';
52
- import { launchFileReview } from './overlays/file-review.js';
53
- import { openReviewSurfaceById, takeStartupReviewId } from '../inbox/review/launch.js';
54
52
  import { ViewerSurfaceHost } from './session/surface-host.js';
55
53
  import { createInboxSurface } from '../inbox/surface.js';
56
54
  import { loadProfileManifest } from '../../core/profiles/manifest.js';
@@ -76,22 +74,16 @@ import { mark } from '../../core/timing.js';
76
74
  function quoteIfNeeded(word) {
77
75
  return /^[A-Za-z0-9._:@/-]+$/.test(word) ? word : shellQuote(word);
78
76
  }
79
- /** Run the interactive attach session against `nodeId`. Resolves when the
80
- * viewer detaches, the broker goes away, or a signal lands —
81
- * always restoring the terminal first. `canvasName`, when set, attaches over
82
- * a relayed WebSocket to that `remoteCanvas.targets.<name>` instead of the
83
- * local unix socket — see the `--canvas` flag on `attachToLeaf`. */
84
- export async function runAttach(nodeId, observer, canvasName, wakeParked = true,
85
- /** What a caller that just created the node already holds: the node's detail, the person's settings answer, and whether to play the first-prompt animation. */
86
- held,
77
+ export async function runAttach(target, observer, canvasName, wakeParked = true,
87
78
  /** Called synchronously just before the viewer takes the terminal. */
88
79
  onConnected) {
89
80
  // The viewer is its own esbuild bundle with its own copy of the settings cache: install the person's settings before anything
90
81
  // calls readConfig (theme, keybindings, ChatView's field initializers all do). A caller that holds them hands them over.
91
- if (held === undefined)
82
+ const pending = typeof target === 'string' ? undefined : target;
83
+ if (pending === undefined)
92
84
  await loadPersonSettingsViaApi();
93
85
  else
94
- installPersonSettingsDto(held.settings);
86
+ installPersonSettingsDto(pending.settings);
95
87
  // 1. Resolve the attach target (session/connection.ts). Nothing here waits for the broker:
96
88
  // the viewer paints first and `connection.dial()` (revive, connect, hello) runs after it, so a
97
89
  // dial failure is shown by the viewer (see `dialBroker` below). An unknown node is still a plain CLI error.
@@ -101,8 +93,14 @@ onConnected) {
101
93
  // and no collaborator may re-derive it.
102
94
  const role = resolveHelloRole(observer);
103
95
  const clientId = randomUUID();
104
- const connection = await connectToNode(nodeId, canvasName, wakeParked, held?.node);
105
- const { remote, canvasSource, meta, socket } = connection;
96
+ const connection = connectToNode(canvasName, wakeParked);
97
+ const { remote, canvasSource, socket } = connection;
98
+ const bound0 = typeof target === 'string'
99
+ ? await connection.bind(target)
100
+ : { meta: { cwd: target.cwd, profile_id: target.profile_id }, nodeIdentity: undefined };
101
+ const meta = bound0.meta;
102
+ /** True until the create request returns and the node is bound. */
103
+ let starting = pending !== undefined;
106
104
  // 2. Theme + keybindings — pi's components throw "Theme not initialized"
107
105
  // otherwise. One KeybindingsManager feeds BOTH editor and input; the
108
106
  // editor may resolve a separate pi-tui instance, so mirror onto it (and
@@ -128,7 +126,7 @@ onConnected) {
128
126
  cwd: meta.cwd,
129
127
  palette: pal,
130
128
  hideThinking: true,
131
- banner: [...croutonBannerLines(buildBannerInfo(meta)), pal.muted(`Older messages: crtr node inspect transcript ${nodeId}`)],
129
+ banner: [...croutonBannerLines(buildBannerInfo(meta)), ...(typeof target === 'string' ? [pal.muted(`Older messages: crtr node inspect transcript ${target}`)] : [])],
132
130
  // Local only: a remote attach cannot read this canvas's ticket dirs, so it
133
131
  // has nothing to render a page block from.
134
132
  inlinePageBlocks: !remote,
@@ -167,7 +165,7 @@ onConnected) {
167
165
  delete process.env['CRTR_ATTACH_DRAFT'];
168
166
  if (restoredDraft !== undefined)
169
167
  editor.setText(restoredDraft);
170
- const ctx = { nodeId, remote, role, meta, canvasSource, socket, tui, pal, editor, containers };
168
+ const ctx = { nodeId: typeof target === 'string' ? target : '', remote, role, meta, canvasSource, socket, tui, pal, editor, containers };
171
169
  // The pending-request strip below the recap goal line. Its hooks close over
172
170
  // collaborators built later (paneFocus, roster, inbox, setNotice) — all are
173
171
  // constructed before any key or refresh can invoke them.
@@ -181,9 +179,8 @@ onConnected) {
181
179
  });
182
180
  containers.header.addChild(strip.component);
183
181
  const userConfig = readConfig('user');
184
- const initialWhip = held?.initialWhip ?? process.env['CRTR_ATTACH_INITIAL_WHIP'] === '1';
182
+ const initialWhip = pending?.initialWhip ?? process.env['CRTR_ATTACH_INITIAL_WHIP'] === '1';
185
183
  delete process.env['CRTR_ATTACH_INITIAL_WHIP'];
186
- const startupReviewId = takeStartupReviewId();
187
184
  const startupTicketId = process.env['CRTR_ATTACH_OPEN_TICKET'];
188
185
  if (startupTicketId !== undefined)
189
186
  delete process.env['CRTR_ATTACH_OPEN_TICKET'];
@@ -251,7 +248,7 @@ onConnected) {
251
248
  ...(inboxProfile === undefined ? {} : { profile: inboxProfile }),
252
249
  ...(remote ? {} : { scan: async () => {
253
250
  const client = cliClient();
254
- const [inbox, history] = await Promise.all([client.listHumanInbox(), client.getInboxHistory(nodeId, { state: 'pending' })]);
251
+ const [inbox, history] = await Promise.all([client.listHumanInbox(), client.getInboxHistory(ctx.nodeId === '' ? undefined : ctx.nodeId, { state: 'pending' })]);
255
252
  const merged = new Map();
256
253
  for (const item of inbox.tickets) {
257
254
  const row = inboxRowFromDTO(item);
@@ -336,7 +333,7 @@ onConnected) {
336
333
  const inventory = createEditorInventory(ctx, capabilities, { setNotice, bindings: () => crouterBindings, fdPath, frecency });
337
334
  // Canvas identity (kind/mode/lifecycle) behind the context badge. A remote
338
335
  // attach starts without one, so load it as soon as the viewer exists.
339
- const identity = createNodeIdentity(ctx, connection.nodeIdentity, {
336
+ const identity = createNodeIdentity(ctx, bound0.nodeIdentity, {
340
337
  isTornDown: () => lifecycle.isTornDown(),
341
338
  onChanged: () => {
342
339
  editorChrome.syncContextBadge();
@@ -380,6 +377,10 @@ onConnected) {
380
377
  // is a real TTY, so `surface
381
378
  // inspect` hosts in-place inside it.
382
379
  const openInspector = (section) => {
380
+ if (starting) {
381
+ setNotice('The node is starting — try again in a moment');
382
+ return;
383
+ }
383
384
  if (!inTmux()) {
384
385
  setNotice('Inspector requires tmux');
385
386
  return;
@@ -387,7 +388,7 @@ onConnected) {
387
388
  setNotice(`Opening Inspector (${section})…`);
388
389
  const home = envHomeOverride();
389
390
  const prefix = home === undefined ? '' : `CRTR_HOME=${shellQuote(home)} `;
390
- const cmd = `${prefix}crtr surface inspect ${shellQuote(nodeId)} --section ${section}`;
391
+ const cmd = `${prefix}crtr surface inspect ${shellQuote(ctx.nodeId)} --section ${section}`;
391
392
  execFile('tmux', ['display-popup', '-E', '-T', ` inspector · ${section} `, '-w', '90%', '-h', '85%', ...surfaceTmuxStyleArgs(), cmd], () => {
392
393
  chromeRefresh.refresh();
393
394
  });
@@ -427,7 +428,7 @@ onConnected) {
427
428
  const paneFocus = createPaneFocus(editor, [roster.active, strip.active, ticketPanel.active]);
428
429
  // The GRAPH overlay — a bounded, centered modal navigator over the same
429
430
  // nav-model graph, reading the live ask counts.
430
- const graphOverlay = new GraphOverlay(tui, nodeId, () => chromeRefresh.asks(), pal, crouterBindings, canvasSource, role, (cause) => chromeRefresh.reportFailure('canvas graph refresh', cause), setNotice);
431
+ const graphOverlay = new GraphOverlay(tui, () => ctx.nodeId, () => chromeRefresh.asks(), pal, crouterBindings, canvasSource, role, (cause) => chromeRefresh.reportFailure('canvas graph refresh', cause), setNotice);
431
432
  const helpOverlay = new HelpOverlay(tui, pal);
432
433
  helpOverlay.setBindings(crouterBindings);
433
434
  // The canvas-chrome refresh/poll engine: owns the ask-count map, the
@@ -471,6 +472,7 @@ onConnected) {
471
472
  agentDir: () => sync.state().agentDir,
472
473
  openNodeMetadata: () => openInspector('overview'),
473
474
  isDormant: () => reconnect.isDormant(),
475
+ isStarting: () => starting,
474
476
  copyTarget,
475
477
  moreDetail: () => chatView.moreDetail(),
476
478
  lessDetail: () => chatView.lessDetail(),
@@ -507,7 +509,7 @@ onConnected) {
507
509
  };
508
510
  // `[[…]]` document links: readable names and browser URLs.
509
511
  const documentLinks = createDocumentLinks({
510
- selfNodeId: nodeId,
512
+ selfNodeId: () => ctx.nodeId === '' ? undefined : ctx.nodeId,
511
513
  remote,
512
514
  canvasSource,
513
515
  port: userConfig.document_port,
@@ -515,37 +517,6 @@ onConnected) {
515
517
  onAccessError: (err) => setNotice(`Document links are unavailable: ${err instanceof Error ? err.message : String(err)}`),
516
518
  refresh: () => chatView.refreshMarkdown(),
517
519
  });
518
- const openFileReview = () => {
519
- if (ticketPanel.active()) {
520
- setNotice('Close the open request first (Esc)');
521
- return;
522
- }
523
- // Documents referenced as `[[…]]` sit beside file paths; the picker and
524
- // launcher tell them apart by their brackets.
525
- const candidates = [
526
- ...chatView.getTranscriptDocRefsNewestFirst().map((ref) => `[[${ref}]]`),
527
- ...chatView.getTranscriptFilePathsNewestFirst(),
528
- ];
529
- const review = (file) => {
530
- void launchFileReview(surfaceHost, file, {
531
- originNodeId: nodeId,
532
- onNotice: setNotice,
533
- });
534
- };
535
- // The cockpit's picker slot lives in the base frame, which a full-pane
536
- // surface covers while owning input — so mount the picker on the host's
537
- // own stack before opening the selected review in its window.
538
- if (surfaceHost.hasFullPaneSurface()) {
539
- void surfaceHost
540
- .pickReviewFile({ candidates, cwd: meta.cwd, title: 'Review a file or document named in this transcript' })
541
- .then((file) => {
542
- if (file !== null)
543
- review(file);
544
- });
545
- return;
546
- }
547
- input.openFileReviewPicker(candidates, meta.cwd, review);
548
- };
549
520
  const openProfileFiles = () => {
550
521
  if (remote) {
551
522
  setNotice('Profile file search is unavailable on remote canvases');
@@ -557,7 +528,7 @@ onConnected) {
557
528
  }
558
529
  void canvasSource.listNodes()
559
530
  .then((nodes) => {
560
- const family = relatedNodes(nodes, nodeId);
531
+ const family = relatedNodes(nodes, ctx.nodeId);
561
532
  launchProfileFileSearch({
562
533
  cwd: meta.cwd,
563
534
  nodeDirs: family.map((node) => node.cwd),
@@ -616,6 +587,10 @@ onConnected) {
616
587
  // node and flags, through the `crtr` launcher so it loads the selected
617
588
  // release. A shell hosting the viewer stays alive underneath.
618
589
  const restartViewer = (env = {}) => {
590
+ if (starting) {
591
+ setNotice('The node is starting — try again in a moment');
592
+ return;
593
+ }
619
594
  const draft = editor.getText();
620
595
  // Checked before teardown: a failed exec after it would close the pane and lose the draft.
621
596
  if (process.execve === undefined || Buffer.byteLength(draft) > 100_000) {
@@ -623,7 +598,7 @@ onConnected) {
623
598
  return;
624
599
  }
625
600
  teardown('detach');
626
- const args = ['surface', 'attach', 'to', nodeId, ...(observer ? ['--observer'] : []), ...(canvasName !== undefined ? ['--canvas', canvasName] : [])];
601
+ const args = ['surface', 'attach', 'to', ctx.nodeId, ...(observer ? ['--observer'] : []), ...(canvasName !== undefined ? ['--canvas', canvasName] : [])];
627
602
  process.execve(process.execPath, [process.execPath, ...process.execArgv, process.argv[1], ...args], { ...process.env, ...env, CRTR_ATTACH_DRAFT: draft, CRTR_ATTACH_WAKE_PARKED: '0' });
628
603
  };
629
604
  // One automatic restart per daemon release: if the launcher still loads another release, a second try would loop.
@@ -656,7 +631,7 @@ onConnected) {
656
631
  process.on('unhandledRejection', onUnhandledRejection);
657
632
  const removeRejectionGuard = () => { process.off('unhandledRejection', onUnhandledRejection); };
658
633
  // The `@crtr_node` pane tag, claimed after the startup checkpoint below.
659
- const paneTag = createPaneTag(remote, nodeId);
634
+ const paneTag = createPaneTag(remote, ctx.nodeId === '' ? undefined : ctx.nodeId);
660
635
  // Lifecycle / teardown — always restore the terminal, exactly once
661
636
  // (session/teardown.ts owns the ordering rules and the four end reasons).
662
637
  // `stopLocal` is this viewer's own shutdown: every collaborator it built
@@ -692,7 +667,7 @@ onConnected) {
692
667
  // and this is only ever read once teardown actually runs.
693
668
  lastSocketError: () => startupFailure ?? reconnect.lastSocketError(),
694
669
  undelivered: () => (settled ? [] : [...heldFrames.flatMap((f) => ('text' in f ? [f.text] : [])), ...(editor.getText().trim() === '' ? [] : [editor.getText()])]),
695
- reattachCommand: `crtr surface attach to ${quoteIfNeeded(nodeId)}` +
670
+ reattachCommand: () => `crtr surface attach to ${quoteIfNeeded(ctx.nodeId)}` +
696
671
  (observer ? ' --observer' : '') +
697
672
  (canvasName !== undefined ? ` --canvas ${quoteIfNeeded(canvasName)}` : ''),
698
673
  tagPane: paneTag.pane,
@@ -748,7 +723,7 @@ onConnected) {
748
723
  file,
749
724
  pane: tmux.pane,
750
725
  cwd: meta.cwd,
751
- nodeId,
726
+ nodeId: ctx.nodeId,
752
727
  observer,
753
728
  beforeRespawn: paneTag.clear,
754
729
  });
@@ -864,7 +839,6 @@ onConnected) {
864
839
  // mutating frame and must ride the same capability gate as every other one.
865
840
  cycleModelLadder: (direction) => input.cycleLadder(direction),
866
841
  inspectLoadedCommand: inventory.inspectLoadedCommand,
867
- openFileReview,
868
842
  openProfileFiles,
869
843
  openSearch: () => {
870
844
  if (surfaceHost.hasFullPaneSurface() || ticketPanel.active()) {
@@ -875,6 +849,7 @@ onConnected) {
875
849
  },
876
850
  whip,
877
851
  reloadViewer: () => restartViewer(),
852
+ isStarting: () => starting,
878
853
  });
879
854
  // Registered only now: every collaborator `stopLocal` touches (the key
880
855
  // listener included) finally exists, so a signal cannot race a half-built
@@ -893,7 +868,7 @@ onConnected) {
893
868
  // The viewer is painted and interactive: now revive, connect and say hello. A live viewer's tmux binding install waits for the welcome
894
869
  // so the synchronous tmux sweep cannot block that frame; a parked one installs below, and reconnect's dormancy callback covers a broker that vanishes.
895
870
  const dialBroker = async () => {
896
- mark('viewer.connect_start', { node: nodeId });
871
+ mark('viewer.connect_start', { node: ctx.nodeId });
897
872
  let parked;
898
873
  try {
899
874
  parked = await connection.dial();
@@ -927,7 +902,7 @@ onConnected) {
927
902
  if (t.startsWith('/') || t.startsWith('!'))
928
903
  refused.push(frame.text);
929
904
  else
930
- void cliClient().sendMessage(nodeId, { body: frame.text, from: 'human' }).catch((e) => setNotice(`Couldn't wake node: ${e instanceof Error ? e.message : String(e)}`));
905
+ void cliClient().sendMessage(ctx.nodeId, { body: frame.text, from: 'human' }).catch((e) => setNotice(`Couldn't wake node: ${e instanceof Error ? e.message : String(e)}`));
931
906
  }
932
907
  if (refused.length > 0) {
933
908
  editor.setText([...refused, editor.getText()].filter((x) => x.trim() !== '').join('\n'));
@@ -941,14 +916,49 @@ onConnected) {
941
916
  inventory.setCommands(parked.commands);
942
917
  // A parked conversation has no broker, so the attach bridge never sees it shown.
943
918
  if (!remote)
944
- void cliClient().markNodeRead(nodeId).catch(() => undefined);
919
+ void cliClient().markNodeRead(ctx.nodeId).catch(() => undefined);
945
920
  scheduleTmuxBindingInstall();
946
921
  reconnect.startDormant();
947
922
  };
948
- void dialBroker();
949
- chromeRefresh.start();
950
- if (startupReviewId !== undefined)
951
- void openReviewSurfaceById(surfaceHost, startupReviewId);
923
+ if (pending === undefined) {
924
+ void dialBroker();
925
+ chromeRefresh.start();
926
+ }
927
+ else {
928
+ void (async () => {
929
+ let detail;
930
+ try {
931
+ detail = await pending.created;
932
+ }
933
+ catch (err) {
934
+ if (lifecycle.isTornDown())
935
+ return;
936
+ // No node exists: print the create error and anything typed that was never delivered.
937
+ startupFailure = err instanceof Error ? err.message : String(err);
938
+ process.exitCode = 1;
939
+ teardown('create-failed');
940
+ return;
941
+ }
942
+ if (lifecycle.isTornDown())
943
+ return;
944
+ ctx.nodeId = detail.node_id;
945
+ const bound = await connection.bind(detail.node_id, detail);
946
+ starting = false;
947
+ mark('viewer.node_bound', { node: detail.node_id });
948
+ if (bound.nodeIdentity !== undefined)
949
+ identity.set(bound.nodeIdentity);
950
+ paneTag.bindNode(detail.node_id);
951
+ chatView.setBannerHint(pal.muted(`Older messages: crtr node inspect transcript ${detail.node_id}`));
952
+ chromeRefresh.start();
953
+ void dialBroker();
954
+ })().catch((err) => {
955
+ if (lifecycle.isTornDown())
956
+ return;
957
+ startupFailure = err instanceof Error ? err.message : String(err);
958
+ process.exitCode = 1;
959
+ teardown('broker-gone');
960
+ });
961
+ }
952
962
  if (startupTicketId !== undefined && startupTicketId !== '' && !remote) {
953
963
  // The dashboard opened this conversation for its oldest pending ask: show the ask first.
954
964
  // Resolve it from the same two reads the inbox strip makes (listed tickets, plus pending unlisted pages).
@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process';
3
3
  import { randomUUID } from 'node:crypto';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
- import { announceFallbackEditor, NO_EDITOR_MESSAGE, resolveEditor } from '../../../core/editor-resolver.js';
6
+ import { announceFallbackEditor, NO_EDITOR_MESSAGE, resolveEditor } from '../core/editor-resolver.js';
7
7
  /** Run $EDITOR against a temporary buffer. Terminal ownership stays with the host. */
8
8
  export function editBufferInEditor(buffer) {
9
9
  const tmpFile = join(tmpdir(), `crtr-input-${randomUUID()}.txt`);
@@ -15,9 +15,8 @@ import { pageBodyLines } from './tui/page-body.js';
15
15
  import { docLinksRevision } from '../attach/render/doc-links.js';
16
16
  import { byNewestFirst, inboxRowFromDTO, pageViewFromDTO, settledStatusOf } from './dto-adapt.js';
17
17
  import { PageAdapter } from './page-adapter.js';
18
- import { ReviewAdapter } from './review-adapter.js';
19
- import { createReviewClient } from './review/review-client.js';
20
- import { editBufferInEditor } from './review/roundtrip.js';
18
+ import { editBufferInEditor } from '../editor-roundtrip.js';
19
+ import { openBrowser } from '../open-browser.js';
21
20
  import { daemonErrorMessage, dismissTicketViaDaemon, resolveFailureKind, resolveTicketPage, } from './resolve.js';
22
21
  /** Host-agnostic model for scanning, stable selection, and rendering. */
23
22
  export class InboxController {
@@ -39,7 +38,6 @@ export class InboxController {
39
38
  selectedIndex = 0;
40
39
  screen = 'list';
41
40
  adapter;
42
- reviewAdapter;
43
41
  focusingSource = false;
44
42
  /** The ticket open on the detail screen. */
45
43
  open;
@@ -364,7 +362,7 @@ export class InboxController {
364
362
  this.submittingDir = item.dir;
365
363
  try {
366
364
  if (item.kind === 'review')
367
- await createReviewClient().cancel(item.id, 'Canceled from the inbox.');
365
+ await cliClient().cancelReview(item.id, { reason: 'Canceled from the inbox.' });
368
366
  else
369
367
  await dismissTicketViaDaemon(item.id, { reason: 'Canceled from the inbox.', actor: 'human' });
370
368
  this.status = 'canceled';
@@ -383,7 +381,7 @@ export class InboxController {
383
381
  if (item === undefined)
384
382
  return;
385
383
  if (item.kind === 'review') {
386
- await this.activateReview(item);
384
+ this.activateReview(item);
387
385
  return;
388
386
  }
389
387
  const request = await this.requestOrNull(item.id);
@@ -436,31 +434,15 @@ export class InboxController {
436
434
  this.watchSelected(item.dir);
437
435
  this.markDirty();
438
436
  }
439
- /** A review opens in its own tmux window, which tmux selects at once, so
440
- * the inbox left behind in this pane has nothing more to do: it closes,
441
- * and returning to this window lands on the conversation beneath it. The
442
- * inbox stays up only when the window could not be opened, so its notice
443
- * is read where the person is looking. */
444
- async activateReview(item) {
445
- this.reviewAdapter = new ReviewAdapter({
446
- reviewId: item.id,
447
- host: this.host,
448
- });
449
- let opened = false;
450
- try {
451
- opened = await this.reviewAdapter.start();
452
- }
453
- catch (error) {
454
- this.status = daemonErrorMessage(error);
437
+ /** A review opens in the browser at its canvas page; a runtime with no canvas host has none. */
438
+ activateReview(item) {
439
+ if (item.url === undefined) {
440
+ this.status = 'Reviews open on canvas.northlight.ai; this runtime has no canvas host';
455
441
  }
456
- finally {
457
- this.reviewAdapter = undefined;
442
+ else {
443
+ openBrowser(item.url);
444
+ this.status = 'opened the review in your browser';
458
445
  }
459
- if (opened) {
460
- this.close();
461
- return;
462
- }
463
- await this.rescan();
464
446
  this.markDirty();
465
447
  }
466
448
  /** Seat the selection on a ticket dir, when present in the current list. */
@@ -509,7 +491,6 @@ export class InboxController {
509
491
  return;
510
492
  this.closed = true;
511
493
  this.started = false;
512
- void this.reviewAdapter?.stop();
513
494
  this.leaveDetail();
514
495
  for (const watcher of this.watchers)
515
496
  watcher.close();
@@ -611,7 +592,7 @@ export class InboxController {
611
592
  : '';
612
593
  const footer = selected.kind === 'page'
613
594
  ? [` ${DIM}Enter${RESET} opens the full page ${DIM}↑↓/jk${RESET} select${sendHint} ${DIM}x${RESET} cancel`, ` ${DIM}Page:${RESET} c comment u/d scroll${focusHint} ${DIM}q${RESET} close`]
614
- : [` ${DIM}Enter${RESET} opens the full review ${DIM}↑↓/jk${RESET} select ${DIM}x${RESET} cancel`, ` ${focusHint} ${DIM}q${RESET} close`];
595
+ : [` ${DIM}Enter${RESET} opens the review in your browser ${DIM}↑↓/jk${RESET} select ${DIM}x${RESET} cancel`, ` ${focusHint} ${DIM}q${RESET} close`];
615
596
  // The hints hold the bottom of the pane rather than trailing the preview,
616
597
  // so they stay in one place as the preview grows and shrinks.
617
598
  const room = Math.max(0, rows - footer.length);
@@ -53,6 +53,7 @@ function reviewRowFromDTO(dto) {
53
53
  subtitle: dto.subtitle,
54
54
  blockedSince: dto.blocked_since,
55
55
  source: dto.source,
56
+ ...(dto.url === undefined ? {} : { url: dto.url }),
56
57
  };
57
58
  }
58
59
  export function inboxRowFromDTO(dto) {
@@ -18,14 +18,7 @@ export function pageBodyLines(manifest, displayMarkdown, maxW, paneW) {
18
18
  if (manifest.dialect === 'html')
19
19
  return displayMarkdown === '' ? [`${DIM}HTML page — open in Northlight to read this${RESET}`] : md(displayMarkdown);
20
20
  const lines = displayMarkdown === '' ? [] : md(displayMarkdown);
21
- let priorStep = -1;
22
21
  for (const slot of manifest.slots) {
23
- if (manifest.steps > 1 && slot.step !== priorStep) {
24
- if (lines.length > 0)
25
- lines.push('');
26
- lines.push(`${BOLD}Step ${slot.step + 1}/${manifest.steps}${RESET}`);
27
- priorStep = slot.step;
28
- }
29
22
  if (lines.length > 0)
30
23
  lines.push('');
31
24
  for (const line of wrap(singleLine(describeSlot(slot)), maxW))
@@ -49,16 +49,9 @@ export function renderOverview(state, cols, rows) {
49
49
  if (hasBody)
50
50
  lines.push(` ${DIM}${hline(maxW)}${RESET}`, '');
51
51
  const answer = pageAnswer(state);
52
- let priorStep = -1;
53
52
  let cursorLine;
54
53
  for (let i = 0; i < state.slots.length; i++) {
55
54
  const slot = state.slots[i];
56
- if (state.manifest.steps > 1 && slot.step !== priorStep) {
57
- if (priorStep !== -1)
58
- lines.push('');
59
- lines.push(` ${BOLD}Step ${slot.step + 1}/${state.manifest.steps}${RESET}`);
60
- priorStep = slot.step;
61
- }
62
55
  const response = slot.id === undefined ? undefined : state.responses.get(slot.id);
63
56
  const icon = isResponseBearingSlot(slot) ? (slotAnswered(state, slot) ? `${GREEN}✓${RESET}` : `${DIM}○${RESET}`) : `${DIM}·${RESET}`;
64
57
  const cursor = i === state.currentIndex ? `${CYAN}▸${RESET} ` : ' ';
@@ -0,0 +1,6 @@
1
+ import { execFile } from 'node:child_process';
2
+ /** Open a URL in the person's browser (best-effort, fire-and-forget). */
3
+ export function openBrowser(url) {
4
+ const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
5
+ execFile(cmd, [url], { timeout: 5_000 }, () => { });
6
+ }
@@ -63,8 +63,8 @@ function commentPreview(comment) {
63
63
  comment_id: comment.comment_id,
64
64
  status: comment.status,
65
65
  revision: comment.revision,
66
- anchor: { line: comment.anchor.line, end_line: comment.anchor.end_line },
67
- anchor_state: comment.anchor_state,
66
+ quote: comment.anchor.quote,
67
+ detached: comment.location === null,
68
68
  author: comment.author,
69
69
  updated_by: comment.updated_by,
70
70
  created_at: comment.created_at,
@@ -79,7 +79,7 @@ const humanReviewNew = defineLeaf({
79
79
  help: {
80
80
  name: 'human review new',
81
81
  summary: 'queue a live document review and return its ticket handle immediately',
82
- guide: 'The person reviews the document in the attach viewer alongside a collaborating companion agent. The daemon reads the document as you and snapshots its current revision into the review. When the person submits, their edits are saved as a new revision of the document and the approval is pushed to your inbox. If the document gets a new revision while the review is open, the save is refused as `stale_revision` and the review stays open; do not edit a document while it is under review.',
82
+ guide: 'The person reviews the document in the browser at the canvas host, with a companion agent that edits the document itself while they comment; there is no file or snapshot to review. Needs a cloud runtime with a canvas host, otherwise it fails with `no_canvas_host`. When the person approves, the approval, with the comments and their quotes, is pushed to your inbox.',
83
83
  params: [
84
84
  { kind: 'positional', name: 'document', type: 'string', required: true, constraint: 'The document to review: a name, `<owner>/<name>` or id, `[[ ]]` optional. It must have one head; merge several heads first.' },
85
85
  { kind: 'flag', name: 'subtitle', type: 'string', required: true, constraint: 'One plain-English sentence stating the review needed and why it matters.' },
@@ -87,14 +87,12 @@ const humanReviewNew = defineLeaf({
87
87
  output: [
88
88
  { name: 'review_id', type: 'string', required: true, constraint: 'Daemon-owned review id for the document, comments, and companion.' },
89
89
  { name: 'document', type: 'string', required: true, constraint: 'The reviewed document\'s `<owner>/<name>`.' },
90
- { name: 'review_dir', type: 'string', required: true, constraint: 'Directory containing the review\'s document.md snapshot and immutable result.json.' },
91
90
  { name: 'result_path', type: 'string', required: true, constraint: 'The immutable terminal result path: <review_dir>/result.json.' },
92
- { name: 'follow_up', type: 'string', required: true, constraint: 'The review remains live for the person and companion; approval is delivered to the origin inbox.' },
93
91
  ],
94
92
  outputKind: 'object',
95
93
  effects: [
96
- 'Records your read of the document and creates the durable review, its `document.md` snapshot, and the companion session fork.',
97
- 'On submit, a changed snapshot becomes a new revision authored by the person; this command does not submit an approval.',
94
+ 'Records your read of the document as the review base and creates the durable review and the companion session fork.',
95
+ 'This command does not submit an approval.',
98
96
  ],
99
97
  },
100
98
  run: async (input) => {
@@ -109,24 +107,23 @@ const humanReviewNew = defineLeaf({
109
107
  return {
110
108
  review_id: review.review_id,
111
109
  document: review.document ?? null,
112
- review_dir: review.review_dir,
113
110
  result_path: `${review.review_dir}/result.json`,
114
- follow_up: 'The review is live for the person in the attach viewer with its companion agent. Approval is pushed to the origin inbox when submitted.',
115
111
  };
116
112
  },
117
113
  });
118
114
  const humanReviewCommentCreate = defineLeaf({
119
115
  name: 'create',
120
116
  description: 'add an anchored review comment',
121
- whenToUse: 'recording a new finding or instruction against one or more document lines.',
117
+ whenToUse: 'recording a new finding or instruction against a passage of the document.',
122
118
  help: {
123
119
  name: 'human review comment create',
124
- summary: 'add a daemon-owned comment anchored to document lines',
125
- guide: 'Without --review, the daemon targets the calling companion node\'s open review. Comment text is supplied on stdin; agent comments use whole-line anchors.',
120
+ summary: 'add a daemon-owned comment anchored to quoted document text',
121
+ guide: 'Without --review, the daemon targets the calling companion node\'s open review. Comment text is supplied on stdin; the quote is matched against the document\'s rendered text, whitespace collapsed.',
126
122
  params: [
127
123
  { kind: 'flag', name: 'review', type: 'string', required: false, constraint: 'Review id. Omit only to target the calling companion node\'s open review.' },
128
- { kind: 'flag', name: 'line', type: 'int', required: true, constraint: 'First 1-based document line in the anchor.' },
129
- { kind: 'flag', name: 'end-line', type: 'int', required: false, constraint: 'Last 1-based document line in the anchor. Default: --line.' },
124
+ { kind: 'flag', name: 'quote', type: 'string', required: true, constraint: 'Text to anchor to; it must occur in the current rendered document. When it occurs more than once, the error lists each occurrence with its context: pass --prefix or --suffix.' },
125
+ { kind: 'flag', name: 'prefix', type: 'string', required: false, constraint: 'Up to 32 characters immediately before the quote.' },
126
+ { kind: 'flag', name: 'suffix', type: 'string', required: false, constraint: 'Up to 32 characters immediately after the quote.' },
130
127
  { kind: 'flag', name: 'deliver', type: 'enum', choices: ['wake', 'quiet'], required: false, constraint: 'wake interrupts the companion now; quiet leaves a durable message for its next turn. Default: wake unless the caller is the companion.' },
131
128
  { kind: 'stdin', name: 'text', required: true, constraint: 'Non-empty comment text.' },
132
129
  ],
@@ -144,11 +141,13 @@ const humanReviewCommentCreate = defineLeaf({
144
141
  },
145
142
  run: async (input, context) => {
146
143
  const reviewId = input['review'];
147
- const line = input['line'];
148
- const endLine = input['endLine'];
149
144
  const result = await cliClient().createReviewComment(reviewId, {
150
145
  text: requireCommentText(input['text'], 'create'),
151
- anchor: { line, end_line: endLine ?? line },
146
+ anchor: {
147
+ quote: input['quote'],
148
+ ...(typeof input['prefix'] === 'string' ? { prefix: input['prefix'] } : {}),
149
+ ...(typeof input['suffix'] === 'string' ? { suffix: input['suffix'] } : {}),
150
+ },
152
151
  actor_node_id: nodeActor(),
153
152
  ...(explicitDeliver(input, context) === undefined ? {} : { deliver: explicitDeliver(input, context) }),
154
153
  });
@@ -231,7 +230,7 @@ function commentMutationLeaf(verb) {
231
230
  { name: 'comment_id', type: 'string', required: true, constraint: 'Daemon-owned comment id.' },
232
231
  { name: 'status', type: 'string', required: true, constraint: 'Current comment status: open, resolved, or deleted.' },
233
232
  { name: 'revision', type: 'integer', required: true, constraint: 'Current per-comment revision.' },
234
- { name: 'anchor', type: 'object', required: true, constraint: 'Current whole-line anchor.' },
233
+ { name: 'anchor', type: 'object', required: true, constraint: 'Quoted text anchor.' },
235
234
  { name: 'author', type: 'object', required: true, constraint: 'Daemon-derived human or node attribution.' },
236
235
  { name: 'text', type: 'string', required: true, constraint: 'Stored full comment text.' },
237
236
  { name: 'changed', type: 'boolean', required: true, constraint: 'Whether this invocation changed the comment.' },
@@ -5,7 +5,6 @@ import { InputError } from '../../core/io.js';
5
5
  import { requireScope } from '../../core/errors.js';
6
6
  import { parseWhen } from '../../core/wake.js';
7
7
  import { cliClient, getNodeOrNull, rethrowAsCliError } from '../api-client.js';
8
- import { shellQuote } from '../surface/node/placement.js';
9
8
  function armerId() {
10
9
  const id = envNodeId();
11
10
  if (id === undefined || id === '') {
@@ -41,14 +40,6 @@ function etaHint(fireAt, now) {
41
40
  return ` (~${hrs}h)`;
42
41
  return ` (~${Math.round(ms / 86_400_000)}d)`;
43
42
  }
44
- function deadlineHeredoc(body, nodeId) {
45
- let delimiter = 'CRTR_DEADLINE';
46
- let suffix = 0;
47
- const lines = new Set(body.split('\n'));
48
- while (lines.has(delimiter))
49
- delimiter = `CRTR_DEADLINE_${++suffix}`;
50
- return `crtr cron cancel "$CRTR_CRON_ID"\ncrtr node message send --to ${shellQuote(nodeId)} --tier urgent <<'${delimiter}'\n${body}\n${delimiter}`;
51
- }
52
43
  const nodeWaitDeadline = defineLeaf({
53
44
  name: 'deadline',
54
45
  description: 'race this node’s next wake against one urgent deadline cron',
@@ -93,7 +84,8 @@ const nodeWaitDeadline = defineLeaf({
93
84
  // core/canvas/crons.ts, where the invariant is enforced for every caller).
94
85
  const cron = await cliClient().armCron({
95
86
  name: `deadline:${self}`,
96
- command: deadlineHeredoc(body, self),
87
+ command: '',
88
+ deadline_body: body,
97
89
  fire_at: parsed.fireAt,
98
90
  recur: null,
99
91
  tz: tz ?? null,
@@ -7,7 +7,7 @@ import { formatGesture, matchesPiTuiInput, } from '../../../../core/keybindings/
7
7
  import { writeClipboardTextEverywhere } from '../../../../core/clipboard-text.js';
8
8
  import { runTuiPage } from '../../../../core/tui/page-host.js';
9
9
  import { PAGE_CHROME_ROWS, columns, framed, pageFrame, theme, } from '../../../../core/tui/panel.js';
10
- import { editBufferInEditor } from '../../../../clients/inbox/review/roundtrip.js';
10
+ import { editBufferInEditor } from '../../../../clients/editor-roundtrip.js';
11
11
  import { PLANNED_EVENTS } from '../resolve.js';
12
12
  import { moveDoc, readBody, readOnlyReason, toggleUnlisted, writeBody, writePreview, writeRules, } from './actions.js';
13
13
  import { axesOf, cycleAxis, cycleFacet, facetsOf, payloadRowOf, railEnter, railRowKey, railRowsOf, renderRail, setTypedAxis, typedAxisValue, } from './rail-panel.js';