@reticlehq/server 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/LICENSE-ENTERPRISE +1 -1
  2. package/README.md +3 -3
  3. package/SKILL.md +12 -14
  4. package/dist/chromium-launch-options.d.ts +4 -3
  5. package/dist/chromium-launch-options.js +6 -2
  6. package/dist/command/cli/adhoc-suite.d.ts +22 -0
  7. package/dist/command/cli/adhoc-suite.js +90 -19
  8. package/dist/command/cli/adhoc-verdict.d.ts +35 -0
  9. package/dist/command/cli/adhoc-verdict.js +90 -3
  10. package/dist/command/cli/answers/gate-hook-message.d.ts +6 -0
  11. package/dist/command/cli/answers/gate-hook-message.js +6 -0
  12. package/dist/command/cli/auth/cloud-keystore.d.ts +0 -2
  13. package/dist/command/cli/auth/cloud-keystore.js +0 -3
  14. package/dist/command/cli/auth/cloud-session.d.ts +4 -0
  15. package/dist/command/cli/auth/cloud-session.js +2 -0
  16. package/dist/command/cli/cli-doctor.js +7 -5
  17. package/dist/command/cli/cli-flow-commands.d.ts +3 -6
  18. package/dist/command/cli/cli-flow-commands.js +67 -4
  19. package/dist/command/cli/cli-parse.d.ts +8 -1
  20. package/dist/command/cli/cli-parse.js +21 -3
  21. package/dist/command/cli/cli-update-commands.js +8 -1
  22. package/dist/command/cli/cli-verify.d.ts +24 -3
  23. package/dist/command/cli/cli-verify.js +54 -11
  24. package/dist/command/cli/cloud-cli.js +5 -2
  25. package/dist/command/cli/cloud-kit.js +3 -5
  26. package/dist/command/cli/cloud-login.js +21 -3
  27. package/dist/command/cli/demo/demo-page.js +6 -3
  28. package/dist/command/cli/doctor/browser/chromium-hint.d.ts +5 -0
  29. package/dist/command/cli/doctor/browser/chromium-hint.js +5 -0
  30. package/dist/command/cli/launch/cli-launch.d.ts +8 -0
  31. package/dist/command/cli/launch/cli-launch.js +21 -9
  32. package/dist/command/cli/launch/sdk-version-match.d.ts +84 -0
  33. package/dist/command/cli/launch/sdk-version-match.js +206 -0
  34. package/dist/command/cli/lifecycle/daemon-lifecycle.js +2 -16
  35. package/dist/command/cli/ports/resolve/cli-port.d.ts +25 -0
  36. package/dist/command/cli/ports/resolve/cli-port.js +125 -15
  37. package/dist/command/cli/setup-mcp-cli.js +13 -13
  38. package/dist/command/cli/tutorial.d.ts +2 -2
  39. package/dist/command/cli/tutorial.js +21 -7
  40. package/dist/command/cli.js +62 -10
  41. package/dist/command/daemon/binding/daemon-status-probe.d.ts +14 -2
  42. package/dist/command/daemon/binding/daemon-status-probe.js +34 -6
  43. package/dist/command/daemon/daemon-resolve.d.ts +9 -0
  44. package/dist/command/daemon/daemon-resolve.js +1 -1
  45. package/dist/command/daemon/lifetime/daemon-usefulness.d.ts +7 -1
  46. package/dist/command/daemon/lifetime/daemon-usefulness.js +30 -7
  47. package/dist/command/dev/stale-issue-guard.d.ts +3 -4
  48. package/dist/command/dev/stale-issue-guard.js +8 -8
  49. package/dist/command/setup/bringup/connect-lease.d.ts +17 -0
  50. package/dist/command/setup/bringup/connect-lease.js +38 -0
  51. package/dist/command/setup/bringup/dev-server-files.d.ts +68 -0
  52. package/dist/command/setup/bringup/dev-server-files.js +131 -0
  53. package/dist/command/setup/bringup/dev-server-log-cap.d.ts +35 -0
  54. package/dist/command/setup/bringup/dev-server-log-cap.js +121 -0
  55. package/dist/command/setup/bringup/ensure-daemon.d.ts +65 -4
  56. package/dist/command/setup/bringup/ensure-daemon.js +135 -16
  57. package/dist/command/setup/bringup/static-page-server.d.ts +35 -0
  58. package/dist/command/setup/bringup/static-page-server.js +151 -0
  59. package/dist/command/setup/desktop-shape.d.ts +4 -0
  60. package/dist/command/setup/desktop-shape.js +18 -2
  61. package/dist/command/setup/init/init-port.d.ts +15 -0
  62. package/dist/command/setup/init/init-port.js +44 -0
  63. package/dist/command/setup/init/init-runtime.d.ts +1 -1
  64. package/dist/command/setup/init/init-runtime.js +39 -2
  65. package/dist/command/setup/node-effects.d.ts +27 -14
  66. package/dist/command/setup/node-effects.js +80 -44
  67. package/dist/command/setup/probe/loopback-probe-urls.d.ts +7 -0
  68. package/dist/command/setup/probe/loopback-probe-urls.js +40 -0
  69. package/dist/command/setup/probe/page-probe.d.ts +13 -2
  70. package/dist/command/setup/probe/page-probe.js +18 -3
  71. package/dist/command/setup/run-setup.d.ts +26 -1
  72. package/dist/command/setup/run-setup.js +96 -13
  73. package/dist/command/setup/session-pick.d.ts +13 -0
  74. package/dist/command/setup/session-pick.js +20 -0
  75. package/dist/command/setup/setup-command.d.ts +2 -14
  76. package/dist/command/setup/setup-command.js +105 -31
  77. package/dist/command/setup/setup-mcp.js +3 -3
  78. package/dist/command/setup/terminal/wait-progress.d.ts +8 -0
  79. package/dist/command/setup/terminal/wait-progress.js +17 -0
  80. package/dist/features/crawl/crawl-empty.js +1 -1
  81. package/dist/features/crawl/crawl-tools.d.ts +6 -0
  82. package/dist/features/crawl/crawl-tools.js +57 -0
  83. package/dist/features/crawl/crawl.js +171 -157
  84. package/dist/features/exhaust/app-coverage.d.ts +33 -0
  85. package/dist/features/exhaust/app-coverage.js +31 -0
  86. package/dist/features/exhaust/code-coverage.d.ts +47 -0
  87. package/dist/features/exhaust/code-coverage.js +77 -0
  88. package/dist/features/exhaust/exhaust-run.d.ts +33 -0
  89. package/dist/features/exhaust/exhaust-run.js +82 -0
  90. package/dist/features/exhaust/explorer.d.ts +103 -0
  91. package/dist/features/exhaust/explorer.js +195 -0
  92. package/dist/features/exhaust/failure-branches.d.ts +33 -0
  93. package/dist/features/exhaust/failure-branches.js +92 -0
  94. package/dist/features/exhaust/ledger.d.ts +202 -0
  95. package/dist/features/exhaust/ledger.js +252 -0
  96. package/dist/features/exhaust/session-fold.d.ts +31 -0
  97. package/dist/features/exhaust/session-fold.js +79 -0
  98. package/dist/features/exhaust/session-port.d.ts +36 -0
  99. package/dist/features/exhaust/session-port.js +102 -0
  100. package/dist/features/harness/drive-report.d.ts +0 -9
  101. package/dist/features/harness/drive-report.js +18 -0
  102. package/dist/features/harness/driver.js +4 -7
  103. package/dist/features/harness/fill-values.d.ts +6 -0
  104. package/dist/features/harness/fill-values.js +3 -0
  105. package/dist/features/harness/jev-driver.js +30 -13
  106. package/dist/features/harness/openai-driver.js +4 -7
  107. package/dist/features/harness/platform-config.js +5 -6
  108. package/dist/index.d.ts +9 -0
  109. package/dist/index.js +40 -11
  110. package/dist/judgement/domain/domain-model.js +3 -1
  111. package/dist/judgement/oracles/self-instrument.js +4 -2
  112. package/dist/judgement/runs/artifact/replay-mapping.d.ts +2 -2
  113. package/dist/judgement/runs/artifact/replay-mapping.js +44 -9
  114. package/dist/judgement/runs/verification-sync.d.ts +3 -1
  115. package/dist/judgement/runs/verification-sync.js +1 -1
  116. package/dist/language/flows/change/affected.d.ts +9 -0
  117. package/dist/language/flows/change/affected.js +35 -0
  118. package/dist/language/flows/change/gate.d.ts +20 -0
  119. package/dist/language/flows/change/gate.js +12 -1
  120. package/dist/language/flows/flow-author.d.ts +7 -0
  121. package/dist/language/flows/flow-author.js +19 -0
  122. package/dist/language/flows/flow-expect-grammar.js +1 -1
  123. package/dist/language/flows/flow-journey.d.ts +54 -0
  124. package/dist/language/flows/flow-journey.js +119 -0
  125. package/dist/language/flows/flow-replay-run.d.ts +2 -3
  126. package/dist/language/flows/flow-replay-run.js +13 -47
  127. package/dist/language/flows/flow-replay.d.ts +22 -8
  128. package/dist/language/flows/flow-replay.js +55 -9
  129. package/dist/language/flows/flow-result.d.ts +2 -0
  130. package/dist/language/flows/flow-result.js +25 -0
  131. package/dist/language/flows/flow-tools.js +17 -5
  132. package/dist/language/flows/flows.d.ts +10 -1
  133. package/dist/language/flows/flows.js +90 -14
  134. package/dist/language/flows/recording/replay-halt.js +3 -1
  135. package/dist/language/flows/recording/tape/recordings.d.ts +30 -1
  136. package/dist/language/flows/recording/tape/recordings.js +55 -1
  137. package/dist/language/flows/replay.d.ts +19 -0
  138. package/dist/language/flows/replay.js +42 -6
  139. package/dist/language/flows/verify-change-tools.js +5 -2
  140. package/dist/launch-chromium.d.ts +80 -0
  141. package/dist/launch-chromium.js +218 -0
  142. package/dist/memory/cloud/cloud-config.d.ts +11 -2
  143. package/dist/memory/cloud/cloud-config.js +47 -7
  144. package/dist/memory/cloud/cloud-sync.d.ts +4 -1
  145. package/dist/memory/cloud/cloud-sync.js +6 -9
  146. package/dist/memory/cloud/harness-offer.js +5 -6
  147. package/dist/memory/cloud/harness-switch.js +5 -6
  148. package/dist/memory/cloud/sync-cycle.d.ts +68 -3
  149. package/dist/memory/cloud/sync-cycle.js +298 -55
  150. package/dist/memory/cloud/sync-daemon.js +24 -20
  151. package/dist/memory/cloud/sync-disk.js +16 -2
  152. package/dist/memory/intent/intent-shard.d.ts +10 -32
  153. package/dist/memory/intent/intent-shard.js +0 -10
  154. package/dist/memory/journal/drive-flow.d.ts +18 -13
  155. package/dist/memory/journal/drive-flow.js +45 -37
  156. package/dist/memory/journal/on-disk/workspace-tiers.js +2 -0
  157. package/dist/memory/journal/session-end.d.ts +9 -1
  158. package/dist/memory/journal/session-end.js +24 -12
  159. package/dist/memory/project/dir/reticle-dir.d.ts +2 -0
  160. package/dist/memory/project/dir/reticle-dir.js +1 -0
  161. package/dist/memory/project/project-tools.js +3 -1
  162. package/dist/portal/bridge/auth-failure-reason.d.ts +1 -1
  163. package/dist/portal/bridge/auth-failure-reason.js +4 -2
  164. package/dist/portal/bridge/bridge.d.ts +8 -0
  165. package/dist/portal/bridge/bridge.js +43 -2
  166. package/dist/portal/input/js-coverage.d.ts +25 -0
  167. package/dist/portal/input/js-coverage.js +30 -0
  168. package/dist/portal/input/real-input.d.ts +11 -0
  169. package/dist/portal/input/real-input.js +29 -4
  170. package/dist/portal/pool/playwright-launcher.d.ts +6 -0
  171. package/dist/portal/pool/playwright-launcher.js +20 -13
  172. package/dist/portal/session/dev-server/dev-command.d.ts +2 -2
  173. package/dist/portal/session/dev-server/dev-command.js +30 -12
  174. package/dist/portal/session/dev-server/dev-server-probe.js +17 -1
  175. package/dist/portal/session/dev-server/route-status-probe.d.ts +24 -0
  176. package/dist/portal/session/dev-server/route-status-probe.js +57 -0
  177. package/dist/portal/session/facts/observed-state.d.ts +11 -0
  178. package/dist/portal/session/facts/observed-state.js +34 -0
  179. package/dist/portal/session/no-session-diagnosis.d.ts +29 -0
  180. package/dist/portal/session/no-session-diagnosis.js +62 -5
  181. package/dist/portal/session/no-session-next-action.d.ts +13 -0
  182. package/dist/portal/session/no-session-next-action.js +48 -9
  183. package/dist/portal/session/no-session-watch.d.ts +18 -0
  184. package/dist/portal/session/no-session-watch.js +88 -2
  185. package/dist/portal/session/session-health.js +3 -2
  186. package/dist/portal/session/session-manager.d.ts +20 -6
  187. package/dist/portal/session/session-manager.js +19 -3
  188. package/dist/portal/session/session-reaper.d.ts +28 -0
  189. package/dist/portal/session/session-reaper.js +49 -1
  190. package/dist/portal/session/session.d.ts +5 -0
  191. package/dist/portal/session/session.js +15 -19
  192. package/dist/surface/http-server.d.ts +2 -1
  193. package/dist/surface/http-server.js +4 -2
  194. package/dist/surface/mcp/mcp-proxy.d.ts +2 -2
  195. package/dist/surface/mcp/mcp-proxy.js +2 -2
  196. package/dist/surface/mcp/mcp.js +4 -2
  197. package/dist/surface/mcp/proxy/proxy-daemon-probe.d.ts +13 -1
  198. package/dist/surface/mcp/proxy/proxy-daemon-probe.js +27 -2
  199. package/dist/surface/mcp/server-instructions.js +9 -7
  200. package/dist/surface/tools/act/after-match.d.ts +17 -0
  201. package/dist/surface/tools/act/after-match.js +30 -0
  202. package/dist/surface/tools/act/durable.d.ts +69 -0
  203. package/dist/surface/tools/act/durable.js +139 -0
  204. package/dist/surface/tools/act/navigation/navigate-arrival.d.ts +13 -6
  205. package/dist/surface/tools/act/navigation/navigate-arrival.js +47 -10
  206. package/dist/surface/tools/act/navigation/navigate-result.d.ts +1 -12
  207. package/dist/surface/tools/act/navigation/navigate-result.js +21 -3
  208. package/dist/surface/tools/act/proved-controls.d.ts +9 -0
  209. package/dist/surface/tools/act/proved-controls.js +11 -0
  210. package/dist/surface/tools/act/sequence-grade.d.ts +5 -0
  211. package/dist/surface/tools/act/sequence-grade.js +32 -1
  212. package/dist/surface/tools/act-capsule.d.ts +7 -0
  213. package/dist/surface/tools/act-capsule.js +46 -1
  214. package/dist/surface/tools/act-sequence-tool.js +25 -8
  215. package/dist/surface/tools/act-tools.js +26 -50
  216. package/dist/surface/tools/assert/assert-grade.js +12 -1
  217. package/dist/surface/tools/assert/assert-verdict.js +2 -2
  218. package/dist/surface/tools/browser-tools.js +14 -2
  219. package/dist/surface/tools/coverage-tools.js +27 -1
  220. package/dist/surface/tools/error-recovery.js +4 -4
  221. package/dist/surface/tools/feedback-invite.js +6 -4
  222. package/dist/surface/tools/harness-explore.d.ts +3 -2
  223. package/dist/surface/tools/harness-explore.js +7 -6
  224. package/dist/surface/tools/lease-tools.js +15 -6
  225. package/dist/surface/tools/live-call-text.js +4 -1
  226. package/dist/surface/tools/observe-tools.js +9 -1
  227. package/dist/surface/tools/tools.js +4 -0
  228. package/dist/telemetry/argument-shape.d.ts +0 -2
  229. package/dist/telemetry/argument-shape.js +0 -4
  230. package/dist/telemetry/error-class.d.ts +2 -3
  231. package/dist/telemetry/error-class.js +2 -3
  232. package/dist/telemetry/harness-drive.d.ts +0 -2
  233. package/dist/telemetry/harness-drive.js +0 -4
  234. package/dist/wire-journal.d.ts +3 -0
  235. package/dist/wire-journal.js +4 -0
  236. package/dist/workspace-packages.d.ts +0 -2
  237. package/dist/workspace-packages.js +1 -9
  238. package/docs/README.md +4 -2
  239. package/docs/actions.mdx +3 -3
  240. package/docs/agent-cheatsheet.md +4 -4
  241. package/docs/architecture.md +6 -6
  242. package/docs/best-practices.mdx +1 -1
  243. package/docs/capabilities.mdx +32 -1
  244. package/docs/cli/cloud.mdx +14 -4
  245. package/docs/cli/doctor.mdx +4 -0
  246. package/docs/cli/feedback.mdx +2 -2
  247. package/docs/cli/gate.mdx +9 -4
  248. package/docs/cli/update.mdx +10 -0
  249. package/docs/cli.mdx +9 -0
  250. package/docs/desktop.mdx +14 -10
  251. package/docs/environment.mdx +87 -0
  252. package/docs/faq.mdx +18 -16
  253. package/docs/first-drive.md +5 -13
  254. package/docs/flows.md +21 -2
  255. package/docs/frameworks.mdx +29 -10
  256. package/docs/getting-started.md +3 -3
  257. package/docs/http-transport.md +6 -3
  258. package/docs/human-control.md +2 -2
  259. package/docs/index.mdx +16 -6
  260. package/docs/install-agentic.mdx +1 -1
  261. package/docs/install-manual.mdx +1 -1
  262. package/docs/integration-patterns.md +3 -3
  263. package/docs/multi-agent-testing.md +1 -1
  264. package/docs/packages/babel-plugin.mdx +1 -1
  265. package/docs/packages/browser.mdx +2 -2
  266. package/docs/packages/react.mdx +2 -2
  267. package/docs/packages/tauri.mdx +1 -1
  268. package/docs/packages/vite-plugin.mdx +2 -2
  269. package/docs/packages.mdx +9 -9
  270. package/docs/predicates.mdx +50 -5
  271. package/docs/quickstart.mdx +2 -2
  272. package/docs/recipes.mdx +2 -2
  273. package/docs/state-management.mdx +2 -2
  274. package/docs/system-map.md +1 -1
  275. package/docs/telemetry.md +1 -1
  276. package/docs/token-efficiency.md +3 -3
  277. package/docs/tools/act-and-wait.mdx +1 -0
  278. package/docs/tools/act-sequence.mdx +1 -1
  279. package/docs/tools/console.mdx +1 -1
  280. package/docs/tools/inspect.mdx +1 -1
  281. package/docs/tools/network.mdx +1 -1
  282. package/docs/tools/query.mdx +1 -1
  283. package/docs/tools/sessions.mdx +1 -1
  284. package/docs/tools/snapshot.mdx +1 -1
  285. package/docs/tools/state.mdx +1 -1
  286. package/docs/tools/wait-for.mdx +1 -1
  287. package/docs/usage.md +7 -6
  288. package/docs/use-cases.mdx +157 -0
  289. package/docs/vs-screenshots.mdx +3 -3
  290. package/docs/what-is-recorded.md +2 -2
  291. package/docs/what-is-reticle.mdx +17 -20
  292. package/docs/why-reticle.mdx +14 -21
  293. package/package.json +10 -9
  294. package/dist/judgement/capsule/minimize.d.ts +0 -12
  295. package/dist/judgement/capsule/minimize.js +0 -22
  296. package/dist/judgement/phenomena/phenomena.d.ts +0 -27
  297. package/dist/judgement/phenomena/phenomena.js +0 -101
  298. package/dist/language/flows/flow-report.d.ts +0 -22
  299. package/dist/language/flows/flow-report.js +0 -106
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname } from 'node:path';
3
3
  import { homedir } from 'node:os';
4
- import { probeCli } from '@reticlehq/init';
4
+ import { probeCli, terminalWidth, wrapForTerminal } from '@reticlehq/init';
5
5
  import { installClosing, tutorialShownSteps } from './tutorial.js';
6
6
  import { setupMcp, knownClientLabels } from '../setup/setup-mcp.js';
7
7
  import { reportInstallSteps } from '../setup/setup-install.js';
@@ -22,7 +22,7 @@ export function handleSetupMcp(reportStep, standalone = true) {
22
22
  writeFileSync(p, contents);
23
23
  },
24
24
  homeDir: () => homedir(),
25
- print: (line) => process.stdout.write(`${line}\n`),
25
+ print: (line) => process.stdout.write(`${wrapForTerminal(line, terminalWidth())}\n`),
26
26
  reportStep,
27
27
  // `probeCli`, not a bare `execFileSync`: on Windows `claude` is a `.cmd` shim that cannot be
28
28
  // spawned without a shell, so the plain call threw ENOENT for every Windows user and the
@@ -46,16 +46,16 @@ export function handleSetupMcp(reportStep, standalone = true) {
46
46
  return;
47
47
  }
48
48
  for (const id of result.registered)
49
- io.print(` registered ${id}`);
49
+ io.print(` ✓ ${id}`);
50
50
  for (const id of result.alreadyThere)
51
- io.print(` already ${id}`);
51
+ io.print(` ✓ ${id} (already set up)`);
52
52
  // Said, not skipped. These are the clients whose format we will not rewrite, and they used to be
53
53
  // counted as registered: the line below is the difference between a user who adds four lines to
54
54
  // one file and a user who believes they are set up and has no tools.
55
55
  for (const client of result.manual) {
56
- io.print(` BY HAND ${client.id}: add the reticle entry to ${client.configPath}`);
56
+ io.print(` ⚠ ${client.id}: add the reticle entry to ${client.configPath} by hand`);
57
57
  if (client.docs !== undefined)
58
- io.print(` see ${client.docs}`);
58
+ io.print(` see ${client.docs}`);
59
59
  }
60
60
  /*
61
61
  * The OTHER agents, which `init` already reaches and this did not.
@@ -75,13 +75,13 @@ export function handleSetupMcp(reportStep, standalone = true) {
75
75
  });
76
76
  // Said on every run, attended or not: a registration only takes effect when the agent re-reads
77
77
  // its config, and an agent that was already open is the commonest reason "it did not work".
78
- io.print('');
79
- io.print('Restart your agent for it to pick up the new server.');
80
- // Only when this IS the whole command. Inside the installer the tour follows, and its own closing
81
- // already names `reticle init` — printing it here too put the same instruction twice, ten lines
82
- // apart, with the tour sandwiched between them.
83
- if (standalone)
78
+ // Only when this IS the whole command. Inside the installer the restart is the first line of the
79
+ // closing's Next list, where it belongs with the other things to do, not between the stages.
80
+ if (standalone) {
81
+ io.print('');
82
+ io.print('Restart your agent for it to pick up the new server.');
84
83
  io.print('Then: cd <your project> && reticle init');
84
+ }
85
85
  }
86
86
  /**
87
87
  * `reticle setup install` — the Node half of the one-line installer.
@@ -100,7 +100,7 @@ export function handleSetupInstall(opts, reportStep) {
100
100
  }
101
101
  // Installation and onboarding are one script, so the tour prints here and is not gated on
102
102
  // anything — see installClosing for the heuristic this replaced and why it reached nobody.
103
- process.stdout.write(`${installClosing()}\n`);
103
+ process.stdout.write(`${wrapForTerminal(installClosing(opts.mcp), terminalWidth())}\n`);
104
104
  // Shown, so the ONBOARD steps are a fact rather than a guess.
105
105
  for (const step of tutorialShownSteps())
106
106
  reportStep(step);
@@ -76,7 +76,7 @@ export declare function tutorialScript(audience: TutorialAudience): TutorialStep
76
76
  * Split from `renderTutorial` so the closing block is a value a caller can assert on, rather than a
77
77
  * string only findable by matching rendered prose.
78
78
  */
79
- export declare function tutorialNextSteps(audience: TutorialAudience): string;
79
+ export declare function tutorialNextSteps(audience: TutorialAudience, restartAgent?: boolean): string;
80
80
  /**
81
81
  * What the installer prints when it has finished.
82
82
  *
@@ -87,7 +87,7 @@ export declare function tutorialNextSteps(audience: TutorialAudience): string;
87
87
  * It ends with the tour's OWN closing, which already names `reticle init`. Adding a second "Next:"
88
88
  * under it would be the same instruction twice in ten lines.
89
89
  */
90
- export declare function installClosing(): string;
90
+ export declare function installClosing(registered?: boolean): string;
91
91
  export declare function renderTutorial(audience: TutorialAudience): string;
92
92
  export type DemoPlan = {
93
93
  ok: true;
@@ -91,7 +91,7 @@ export function tutorialScript(audience) {
91
91
  * Split from `renderTutorial` so the closing block is a value a caller can assert on, rather than a
92
92
  * string only findable by matching rendered prose.
93
93
  */
94
- export function tutorialNextSteps(audience) {
94
+ export function tutorialNextSteps(audience, restartAgent = false) {
95
95
  const lines = TutorialAudience.AGENT === audience
96
96
  ? [
97
97
  'Next:',
@@ -101,12 +101,15 @@ export function tutorialNextSteps(audience) {
101
101
  ]
102
102
  : [
103
103
  'Next:',
104
- ' cd <your project> && reticle init # wire Reticle into the app',
104
+ ...(restartAgent
105
+ ? [' restart your agent # it loads new tools only when it starts']
106
+ : []),
107
+ ' cd <your project> && reticle init # wire Reticle into the app',
105
108
  ' npm run dev # then load it in a browser',
106
109
  ' reticle status # confirms the app connected, or says why not',
107
110
  '',
108
- 'Then ask your agent to drive one real flow and report the verdict. That is the install',
109
- 'proving itself, and it is the agent’s job rather than a command you run.',
111
+ // One line: the terminal wraps it at the reader's width, not ours.
112
+ 'Then ask your agent to drive one real flow and report the verdict. That is the install proving itself, and it is the agent’s job rather than a command you run.',
110
113
  ];
111
114
  return lines.join('\n');
112
115
  }
@@ -120,14 +123,25 @@ export function tutorialNextSteps(audience) {
120
123
  * It ends with the tour's OWN closing, which already names `reticle init`. Adding a second "Next:"
121
124
  * under it would be the same instruction twice in ten lines.
122
125
  */
123
- export function installClosing() {
126
+ export function installClosing(registered = true) {
127
+ // One line a step. The reasons are for `reticle tutorial`; right after an install they turned a
128
+ // four-step idea into twenty-five lines of prose between the reader and the next command.
129
+ const steps = tutorialScript(TutorialAudience.HUMAN).map((step, index) => ` ${String(index + 1)}. ${INSTALL_SAYS[step.id] ?? step.say}`);
124
130
  return [
125
131
  '',
126
- 'Reticle is installed. Here is what it does, in four steps:',
132
+ '✓ Reticle is installed. How it works:',
133
+ ...steps,
127
134
  '',
128
- renderTutorial(TutorialAudience.HUMAN),
135
+ tutorialNextSteps(TutorialAudience.HUMAN, registered),
129
136
  ].join('\n');
130
137
  }
138
+ /**
139
+ * Tour steps reworded for a reader who has no app wired yet. The in-app tour's "That panel is
140
+ * Reticle" points at a panel on screen; straight after an install there is none to point at.
141
+ */
142
+ const INSTALL_SAYS = {
143
+ connect: 'Once `reticle init` wires your app, a Reticle panel appears in it: your proof the SDK is connected.',
144
+ };
131
145
  export function renderTutorial(audience) {
132
146
  const steps = tutorialScript(audience)
133
147
  .map((step, index) => {
@@ -15,7 +15,9 @@ import { splitBrainFields, withNextAction } from './cli/status-fields.js';
15
15
  import { reticleStateHome } from './daemon/daemon.js';
16
16
  import { handleMcp } from './cli/mcp-command.js';
17
17
  import { handleReport } from './cli/report-command.js';
18
- import { resolveDaemonForProject } from './daemon/daemon-resolve.js';
18
+ import { daemonProjectAt, resolveDaemonForProject } from './daemon/daemon-resolve.js';
19
+ import { pickDaemonPortToBind } from './daemon/binding/free-port.js';
20
+ import { portForInit, portFromEnv } from './setup/init/init-port.js';
19
21
  import { daemonStartOptions } from './cli/daemon-start-options.js';
20
22
  import { handleWatch, handleCapsules, handleGate, loadNamedFlows, resolveChangedFiles, } from './cli/cli-flow-commands.js';
21
23
  import { RETICLE_DEFAULT_PORT, ReticleDir, ReticleEnv, devServersForProject, } from '@reticlehq/core';
@@ -49,19 +51,38 @@ import { continueAfterInit } from './setup/init/init-runtime.js';
49
51
  import { handleDoctor } from './cli/cli-doctor.js';
50
52
  import { serverInitHost } from './setup/init/init-host.js';
51
53
  import { describeLicense } from '../features/license/license.js';
52
- import { isLikelyDevServerPort, devServerPortWarning, readProjectPort, readProjectId, } from './cli/ports/resolve/cli-port.js';
53
- import { DAEMON_INNER_COMMAND, PORT_FLAG, parseCliArgs, CLI_USAGE } from './cli/cli-parse.js';
54
+ import { isLikelyDevServerPort, devServerPortWarning, readProjectPort, readProjectId, workspacePortConflict, projectDirOf, } from './cli/ports/resolve/cli-port.js';
55
+ import { nodeSpawner, readTextFile, reexecAtVersion, versionMatchNote, versionToMatch, } from './cli/launch/sdk-version-match.js';
56
+ import { DAEMON_INNER_COMMAND, PORT_FLAG, parseCliArgs, CLI_USAGE, dialsTheDaemon, } from './cli/cli-parse.js';
54
57
  import { handleFeedback, handleIdentify, handleTelemetry } from '../telemetry/feedback-cli.js';
55
58
  import { installDaemonTelemetry } from '../telemetry/daemon-telemetry.js';
56
59
  import { reportCliRun } from '../telemetry/cli-telemetry.js';
57
60
  // Re-exported so existing imports (and the CLI tests) keep resolving from '@/cli.js'.
58
61
  export { parseCliArgs, CLI_USAGE };
59
- function handleInit(parsed) {
62
+ async function handleInit(parsed) {
60
63
  const cwd = process.cwd();
64
+ // RETICLE_PORT counts as explicit, as it does for every other command: resolved once here, so the
65
+ // port written into the project and the port the runtime phase binds are the same number.
66
+ const explicit = parsed.port ?? portFromEnv(process.env);
67
+ const port = await portForInit(explicit, readProjectPort(cwd), readProjectId(cwd), {
68
+ // The registry names a daemon's owner; an older daemon that never registered is known by the
69
+ // projects its connected pages announced.
70
+ daemonProjects: async (p) => {
71
+ const claimed = daemonProjectAt(p, reticleStateHome());
72
+ if (claimed !== undefined && claimed.length > 0)
73
+ return [claimed];
74
+ const { sessions } = summarizeStatus(await fetchStatus(p));
75
+ return [
76
+ ...new Set(sessions.flatMap((s) => (s.projectId === undefined ? [] : [s.projectId]))),
77
+ ];
78
+ },
79
+ daemonPresent: async (p) => presenceIsUsable(await probePresence(p, { tcpOpen: probeDaemon, status: fetchStatus })),
80
+ pickPort: (p) => pickDaemonPortToBind(p),
81
+ });
61
82
  const io = buildNodeIo(cwd, serverInitHost());
62
83
  const result = runInit({
63
84
  cwd,
64
- port: parsed.port,
85
+ port,
65
86
  mcp: parsed.mcp,
66
87
  dryRun: parsed.dryRun,
67
88
  install: parsed.install,
@@ -76,7 +97,7 @@ function handleInit(parsed) {
76
97
  deferOutcome: true,
77
98
  continuesToRuntime: true !== parsed.filesOnly && true !== parsed.dryRun,
78
99
  }, io);
79
- void continueAfterInit(parsed, result, io, cwd);
100
+ await continueAfterInit({ ...parsed, port }, result, io, cwd);
80
101
  }
81
102
  // `serve`, `stop` and `restart` live in `cli/lifecycle/daemon-lifecycle.ts`: one idea, and the
82
103
  // largest group this file could give up without splitting something that belongs together.
@@ -524,6 +545,26 @@ export function main() {
524
545
  if (licenseKey !== undefined)
525
546
  process.env[LICENSE_KEY_ENV] = licenseKey;
526
547
  const argv = process.argv.slice(2);
548
+ // Before anything reports or writes: a CLI a major away from the project's SDK makes every verdict
549
+ // `version_skew`, and the unpinned `npx @reticlehq/server` every agent entry uses resolves the
550
+ // LATEST major whatever the project installed. Hand the same arguments to the matching release and
551
+ // step aside — it reports its own run. See cli/launch/sdk-version-match.ts.
552
+ const matchVersion = versionToMatch({
553
+ argv,
554
+ cliVersion: SERVER_VERSION,
555
+ env: process.env,
556
+ projectDir: projectDirOf(process.cwd()),
557
+ readFile: readTextFile,
558
+ });
559
+ if (matchVersion !== undefined) {
560
+ process.stderr.write(`${versionMatchNote(matchVersion, SERVER_VERSION)}\n`);
561
+ reexecAtVersion(matchVersion, argv, process.env, {
562
+ spawn: nodeSpawner,
563
+ exit: (code) => process.exit(code),
564
+ warn: (line) => process.stderr.write(`${line}\n`),
565
+ });
566
+ return;
567
+ }
527
568
  // Every invocation passes through here — the single chokepoint for the "how often is it used / how
528
569
  // many distinct machines + projects" metrics. Fire-and-forget: a metric must never delay or fail a run.
529
570
  //
@@ -549,14 +590,20 @@ export function main() {
549
590
  void runCloudCommand(argv).then((code) => process.exit(code));
550
591
  return;
551
592
  }
552
- const portEnv = process.env[ReticleEnv.PORT];
553
- const envPort = portEnv !== undefined ? parseInt(portEnv, 10) : undefined;
593
+ const envPort = portFromEnv(process.env);
554
594
  const projectPort = readProjectPort(process.cwd());
555
595
  // Say so rather than letting the daemon fight the dev server for the port and fail with an
556
596
  // EADDRINUSE that mentions neither file nor cause.
557
597
  if (projectPort !== undefined && isLikelyDevServerPort(projectPort)) {
558
598
  process.stderr.write(`${devServerPortWarning(projectPort)}\n`);
559
599
  }
600
+ // A monorepo root whose wired apps disagree on a port: nothing is picked, and without this line the
601
+ // default below would be — another project's daemon, answered as if it were this one.
602
+ const portConflict = projectPort === undefined && envPort === undefined && !argv.includes(PORT_FLAG)
603
+ ? workspacePortConflict(process.cwd())
604
+ : undefined;
605
+ if (portConflict !== undefined)
606
+ process.stderr.write(`${portConflict}\n`);
560
607
  // Registry BEFORE the default, and after both explicit sources.
561
608
  //
562
609
  // This is the line that ends the split brain. Build plugins have always asked the registry which
@@ -573,6 +620,11 @@ export function main() {
573
620
  // Headed by default; hidden only where there is no display to be headed on. A run nobody can see
574
621
  // is a run nobody trusts, and every "did it actually do anything?" cost a human round-trip.
575
622
  const parsed = parseCliArgs(argv, defaultPort, process.env['CI'] !== undefined);
623
+ // The refusal the line above promised. Printing it and carrying on let the default port answer
624
+ // anyway, for whichever project's daemon owned it.
625
+ if (portConflict !== undefined && dialsTheDaemon(parsed)) {
626
+ process.exit(1);
627
+ }
576
628
  switch (parsed.kind) {
577
629
  case 'error':
578
630
  // Two audiences, two channels. The structured line is for logs and scripts; the plain text is
@@ -583,7 +635,7 @@ export function main() {
583
635
  process.exit(1);
584
636
  break;
585
637
  case 'init':
586
- handleInit(parsed);
638
+ void handleInit(parsed);
587
639
  break;
588
640
  case 'serve':
589
641
  handleServe(parsed);
@@ -669,7 +721,7 @@ export function main() {
669
721
  void handleHunt(parsed.dir);
670
722
  break;
671
723
  case 'gate':
672
- void handleGate(parsed.files, parsed.since, parsed.hook);
724
+ void handleGate(parsed.files, parsed.since, parsed.hook, parsed.acceptCoverage);
673
725
  break;
674
726
  case 'report':
675
727
  void handleReport(parsed.session, parsed.hook);
@@ -1,5 +1,15 @@
1
- /** GET the daemon's /status JSON. Resolves to the parsed body, or undefined on any failure. */
2
- export declare function fetchStatus(port: number): Promise<unknown>;
1
+ /**
2
+ * GET the daemon's /status JSON. Resolves to the parsed body, or undefined on any failure —
3
+ * including a body that is not a Reticle daemon's, so every caller reads a stranger as absent and
4
+ * `probePresence` calls the port FOREIGN.
5
+ *
6
+ * `host` defaults to loopback, which is every caller's actual target — except `bootSession`
7
+ * (reticlehq/reticle#1165 review), whose Bridge can bind a non-default host via `RETICLE_HOST`.
8
+ * Hardcoding loopback here made that preflight check the wrong address.
9
+ */
10
+ export declare function fetchStatus(port: number, host?: string,
11
+ /** Also tell the daemon a setup run is waiting on it, so it does not idle out mid-wait. */
12
+ hold?: boolean): Promise<unknown>;
3
13
  /** One connected tab as `reticle status` reports it — the at-a-glance health line. */
4
14
  interface StatusSession {
5
15
  sessionId: string;
@@ -16,6 +26,8 @@ interface StatusSession {
16
26
  pendingMarks: number;
17
27
  /** The tab is attached and answering nothing — see Session.unresponsive. Absent on an older daemon. */
18
28
  unresponsive?: true;
29
+ /** Since the SDK last sent anything, heartbeats included. Absent on a body that did not say. */
30
+ lastSeenMs?: number;
19
31
  }
20
32
  /**
21
33
  * Reduce the daemon's /status JSON to the compact view `reticle status` prints. Pure: narrows the
@@ -1,5 +1,6 @@
1
1
  import * as http from 'node:http';
2
- import { LOOPBACK_HOST, STATUS_PATH } from '@reticlehq/core';
2
+ import { z } from 'zod';
3
+ import { LOOPBACK_HOST, STATUS_HOLD_QUERY, STATUS_PATH } from '@reticlehq/core';
3
4
  import { loopbackAgent } from '../../../surface/loopback-agent.js';
4
5
  /**
5
6
  * The impure half of `probePresence`: ask the port whether a Reticle daemon is answering.
@@ -15,13 +16,38 @@ import { loopbackAgent } from '../../../surface/loopback-agent.js';
15
16
  */
16
17
  /** How long the daemon /status probe waits before giving up — a local loopback call is near-instant. */
17
18
  const STATUS_PROBE_TIMEOUT_MS = 1000;
18
- /** GET the daemon's /status JSON. Resolves to the parsed body, or undefined on any failure. */
19
- export function fetchStatus(port) {
19
+ /**
20
+ * The fields every Reticle daemon's `/status` has carried, which no stranger's is likely to.
21
+ *
22
+ * Any JSON used to count. An unrelated MCP server on the port init chose answered `/status` with its
23
+ * own body, was adopted as the daemon, the page's bridge dial got WebSocket 404s, and init blamed the
24
+ * dev server. `contract` is NOT required: a daemon from before it existed is still Reticle, and has
25
+ * to be recognised as one so init can replace it as skewed rather than call it a stranger.
26
+ */
27
+ const ReticleStatusSchema = z
28
+ .object({
29
+ running: z.literal(true),
30
+ version: z.string().min(1),
31
+ sessions: z.array(z.unknown()),
32
+ })
33
+ .passthrough();
34
+ /**
35
+ * GET the daemon's /status JSON. Resolves to the parsed body, or undefined on any failure —
36
+ * including a body that is not a Reticle daemon's, so every caller reads a stranger as absent and
37
+ * `probePresence` calls the port FOREIGN.
38
+ *
39
+ * `host` defaults to loopback, which is every caller's actual target — except `bootSession`
40
+ * (reticlehq/reticle#1165 review), whose Bridge can bind a non-default host via `RETICLE_HOST`.
41
+ * Hardcoding loopback here made that preflight check the wrong address.
42
+ */
43
+ export function fetchStatus(port, host = LOOPBACK_HOST,
44
+ /** Also tell the daemon a setup run is waiting on it, so it does not idle out mid-wait. */
45
+ hold = false) {
20
46
  return new Promise((resolve) => {
21
47
  const req = http.get({
22
- host: LOOPBACK_HOST,
48
+ host,
23
49
  port,
24
- path: STATUS_PATH,
50
+ path: hold ? `${STATUS_PATH}?${STATUS_HOLD_QUERY}=1` : STATUS_PATH,
25
51
  timeout: STATUS_PROBE_TIMEOUT_MS,
26
52
  // Shares the proxy's keep-alive agent: the proxy calls this on every reconnect, and a socket
27
53
  // per probe is the same churn the POST leg was fixed for.
@@ -32,7 +58,8 @@ export function fetchStatus(port) {
32
58
  res.on('data', (chunk) => (body += chunk));
33
59
  res.on('end', () => {
34
60
  try {
35
- resolve(JSON.parse(body));
61
+ const parsed = ReticleStatusSchema.safeParse(JSON.parse(body));
62
+ resolve(parsed.success ? parsed.data : undefined);
36
63
  }
37
64
  catch {
38
65
  resolve(undefined);
@@ -80,6 +107,7 @@ export function summarizeStatus(payload) {
80
107
  stale: true === r['stale'],
81
108
  pendingMarks: 'number' === typeof r['pendingMarks'] ? r['pendingMarks'] : 0,
82
109
  ...(true === r['unresponsive'] ? { unresponsive: true } : {}),
110
+ ...('number' === typeof r['lastSeenMs'] ? { lastSeenMs: r['lastSeenMs'] } : {}),
83
111
  };
84
112
  })
85
113
  .filter((s) => s !== null);
@@ -16,6 +16,15 @@
16
16
  * This module is the one answer both sides now use. It is pure and injectable: no process spawning,
17
17
  * no port binding, nothing that needs a real `~/.reticle` to test.
18
18
  */
19
+ import { type DaemonRegistryEntry } from '@reticlehq/core/artifacts';
20
+ /**
21
+ * Every well-formed registry entry in `home`.
22
+ *
23
+ * A corrupt or half-written entry is skipped rather than thrown on: the registry is written by other
24
+ * processes that can be killed mid-write, and one bad file must not make a machine's daemons
25
+ * undiscoverable. Validated through core's schema so a shape change cannot silently pass here.
26
+ */
27
+ export declare function readDaemonRegistry(home: string): DaemonRegistryEntry[];
19
28
  /**
20
29
  * The port of the live daemon serving `projectId`, or undefined when this project has none.
21
30
  *
@@ -26,7 +26,7 @@ import { DaemonRegistryEntrySchema, daemonRegistryPort, pickDaemonPort, } from '
26
26
  * processes that can be killed mid-write, and one bad file must not make a machine's daemons
27
27
  * undiscoverable. Validated through core's schema so a shape change cannot silently pass here.
28
28
  */
29
- function readDaemonRegistry(home) {
29
+ export function readDaemonRegistry(home) {
30
30
  let files;
31
31
  try {
32
32
  files = readdirSync(home);
@@ -21,6 +21,12 @@
21
21
  */
22
22
  export declare function noteToolCall(): void;
23
23
  export declare function everServedToolCall(): boolean;
24
+ /**
25
+ * How long one hold from a setup run keeps the daemon from idling out. `init` renews it on a timer
26
+ * well inside this window for as long as it runs, so a run that dies stops holding within it.
27
+ */
28
+ export declare const SETUP_HOLD_MS = 60000;
29
+ export declare function noteSetupHold(now: number): void;
24
30
  /** Tests only. */
25
31
  export declare function resetDaemonUsefulness(): void;
26
32
  interface UsefulnessFacts {
@@ -56,5 +62,5 @@ interface IdlePool {
56
62
  * clause the shutdown watcher could never fire on the many daemons that spawn in a directory with
57
63
  * no app and sit there for the length of an editor session.
58
64
  */
59
- export declare function buildIdlePredicate(agentConnected: () => boolean, sessions: IdleSessions, pool: IdlePool): () => boolean;
65
+ export declare function buildIdlePredicate(agentConnected: () => boolean, sessions: IdleSessions, pool: IdlePool, now?: () => number): () => boolean;
60
66
  export {};
@@ -19,6 +19,7 @@
19
19
  * anybody could lose. When it does shut down, the MCP proxy reconnects and `ensureDaemon` spawns a
20
20
  * fresh one on the next call, which is a path already exercised hundreds of times a day.
21
21
  */
22
+ import { STATUS_HOLD_MS } from '@reticlehq/core';
22
23
  /** Set the first time any tool is dispatched through runTool — the chokepoint every path shares. */
23
24
  let servedToolCall = false;
24
25
  export function noteToolCall() {
@@ -27,9 +28,30 @@ export function noteToolCall() {
27
28
  export function everServedToolCall() {
28
29
  return servedToolCall;
29
30
  }
31
+ /**
32
+ * How long one hold from a setup run keeps the daemon from idling out. `init` renews it on a timer
33
+ * well inside this window for as long as it runs, so a run that dies stops holding within it.
34
+ */
35
+ export const SETUP_HOLD_MS = STATUS_HOLD_MS;
36
+ /**
37
+ * When a setup run last said it is waiting on this daemon — see STATUS_HOLD_QUERY.
38
+ *
39
+ * `init` starts the daemon and can then wait on the app longer than the idle grace: a cold desktop
40
+ * build, a slow first compile. The daemon counted none of that as activity, idled out
41
+ * (`reticle_daemon_idle_exit`) while init was still waiting for the app to dial it, and the app came
42
+ * up to a closed port.
43
+ */
44
+ let setupHeldAt;
45
+ export function noteSetupHold(now) {
46
+ setupHeldAt = now;
47
+ }
48
+ function setupHolding(now) {
49
+ return undefined !== setupHeldAt && now - setupHeldAt < SETUP_HOLD_MS;
50
+ }
30
51
  /** Tests only. */
31
52
  export function resetDaemonUsefulness() {
32
53
  servedToolCall = false;
54
+ setupHeldAt = undefined;
33
55
  }
34
56
  /**
35
57
  * True when the daemon has done nothing for anyone and has nothing to lose by exiting.
@@ -49,13 +71,14 @@ export function isUselessDaemon(facts) {
49
71
  * clause the shutdown watcher could never fire on the many daemons that spawn in a directory with
50
72
  * no app and sit there for the length of an editor session.
51
73
  */
52
- export function buildIdlePredicate(agentConnected, sessions, pool) {
53
- return () => (!agentConnected() ||
54
- isUselessDaemon({
55
- servedToolCall: everServedToolCall(),
56
- everConnected: sessions.everConnected(),
57
- activeLeases: pool.activeCount(),
58
- })) &&
74
+ export function buildIdlePredicate(agentConnected, sessions, pool, now = () => Date.now()) {
75
+ return () => !setupHolding(now()) &&
76
+ (!agentConnected() ||
77
+ isUselessDaemon({
78
+ servedToolCall: everServedToolCall(),
79
+ everConnected: sessions.everConnected(),
80
+ activeLeases: pool.activeCount(),
81
+ })) &&
59
82
  0 === sessions.count() &&
60
83
  0 === pool.activeCount();
61
84
  }
@@ -8,10 +8,9 @@
8
8
  *
9
9
  * ## Why `fixed-pending-release` is an accepted answer
10
10
  *
11
- * Work fixed on an unreleased branch is legitimately still open; the issue closes when the version
12
- * ships. The label is what tells a contributor not to start, so the label — not the closure — is
13
- * what this guard is actually asking for. That is also why the fix is cheap: nobody has to change
14
- * when they close things, only to say so.
11
+ * Work that is already ON the release branch is legitimately still open; the issue closes when the
12
+ * version ships. The label is that fact. It is not a fact about an open pull request. Applying it
13
+ * there is what told contributors a fix had shipped when the pull request was still unmerged.
15
14
  *
16
15
  * Pure. The git log and the GitHub lookup belong to the caller, which is what makes every branch
17
16
  * below testable without a network or a repo.
@@ -8,10 +8,9 @@
8
8
  *
9
9
  * ## Why `fixed-pending-release` is an accepted answer
10
10
  *
11
- * Work fixed on an unreleased branch is legitimately still open; the issue closes when the version
12
- * ships. The label is what tells a contributor not to start, so the label — not the closure — is
13
- * what this guard is actually asking for. That is also why the fix is cheap: nobody has to change
14
- * when they close things, only to say so.
11
+ * Work that is already ON the release branch is legitimately still open; the issue closes when the
12
+ * version ships. The label is that fact. It is not a fact about an open pull request. Applying it
13
+ * there is what told contributors a fix had shipped when the pull request was still unmerged.
15
14
  *
16
15
  * Pure. The git log and the GitHub lookup belong to the caller, which is what makes every branch
17
16
  * below testable without a network or a repo.
@@ -61,9 +60,10 @@ export function staleIssues(claimed, issues) {
61
60
  /** The message the guard prints. Held here so the check and its tests cannot describe it differently. */
62
61
  export function staleIssueReport(stale) {
63
62
  const list = stale.map((n) => `#${String(n)}`).join(', ');
63
+ const pronoun = 1 === stale.length ? 'it' : 'them';
64
64
  return (`${list} ${1 === stale.length ? 'is' : 'are'} still OPEN, and a commit on this branch says it ` +
65
- `closes ${1 === stale.length ? 'it' : 'them'}. Anyone browsing the tracker reads that as work ` +
66
- `nobody has started. Close ${1 === stale.length ? 'it' : 'them'}, or label ` +
67
- `${1 === stale.length ? 'it' : 'them'} \`${PENDING_RELEASE_LABEL}\` if the fix is waiting on a ` +
68
- `release. This has cost three contributors an evening each; it is not bookkeeping.`);
65
+ `closes ${pronoun}. Anyone browsing the tracker reads that as work nobody has started. Close ` +
66
+ `${pronoun} when this merges. Do not apply \`${PENDING_RELEASE_LABEL}\` from an open pull ` +
67
+ `request: that label means the fix is already on the release branch and waiting for the version ` +
68
+ `to ship. Applying it earlier is what sent contributors away from work that was not merged.`);
69
69
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The connect proof for a run with no system browser to lean on: `init --no-open`, CI, a container,
3
+ * an agent, or a launcher that failed.
4
+ *
5
+ * Opens the app in a lease on the daemon at `port`, over the MCP transport every daemon serves --
6
+ * the same route `reticle verify` takes, so there is no second browser stack and no second daemon
7
+ * fighting this one for the port.
8
+ */
9
+ /** A lease this run opened, and the way to hand it back; or why it could not be opened. */
10
+ type LeaseOutcome = {
11
+ readonly sessionId: string;
12
+ readonly release: () => Promise<void>;
13
+ } | {
14
+ readonly failed: string;
15
+ };
16
+ export declare function openLeaseFor(port: number, url: string, token: string | undefined): Promise<LeaseOutcome>;
17
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The connect proof for a run with no system browser to lean on: `init --no-open`, CI, a container,
3
+ * an agent, or a launcher that failed.
4
+ *
5
+ * Opens the app in a lease on the daemon at `port`, over the MCP transport every daemon serves --
6
+ * the same route `reticle verify` takes, so there is no second browser stack and no second daemon
7
+ * fighting this one for the port.
8
+ */
9
+ import { acquireLease, connectOverSse, endpointFor, releaseLease, } from '../../cli/adhoc-verdict.js';
10
+ const reason = (error) => (error instanceof Error ? error.message : String(error));
11
+ export async function openLeaseFor(port, url, token) {
12
+ let caller;
13
+ try {
14
+ caller = await connectOverSse(endpointFor(port, token));
15
+ }
16
+ catch (error) {
17
+ return { failed: `could not reach the daemon on port ${String(port)}: ${reason(error)}` };
18
+ }
19
+ const close = () => caller.close().catch(() => undefined);
20
+ try {
21
+ const got = await acquireLease(caller, url);
22
+ if ('failed' in got) {
23
+ await close();
24
+ return { failed: got.failed.join(' ') };
25
+ }
26
+ return {
27
+ sessionId: got.leased,
28
+ release: async () => {
29
+ await releaseLease(caller, got.leased);
30
+ await close();
31
+ },
32
+ };
33
+ }
34
+ catch (error) {
35
+ await close();
36
+ return { failed: reason(error) };
37
+ }
38
+ }