@reticlehq/server 3.3.0 → 3.5.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 (326) 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 +6 -2
  15. package/dist/command/cli/auth/cloud-session.js +2 -0
  16. package/dist/command/cli/auth/device-flow.d.ts +2 -2
  17. package/dist/command/cli/cli-doctor.js +7 -5
  18. package/dist/command/cli/cli-flow-commands.d.ts +3 -6
  19. package/dist/command/cli/cli-flow-commands.js +67 -4
  20. package/dist/command/cli/cli-parse.d.ts +8 -1
  21. package/dist/command/cli/cli-parse.js +24 -4
  22. package/dist/command/cli/cli-update-commands.js +8 -1
  23. package/dist/command/cli/cli-verify.d.ts +24 -3
  24. package/dist/command/cli/cli-verify.js +54 -11
  25. package/dist/command/cli/cloud-cli.js +64 -2
  26. package/dist/command/cli/cloud-kit.js +3 -5
  27. package/dist/command/cli/cloud-login.d.ts +1 -1
  28. package/dist/command/cli/cloud-login.js +27 -8
  29. package/dist/command/cli/demo/demo-page.js +6 -3
  30. package/dist/command/cli/doctor/browser/chromium-hint.d.ts +5 -0
  31. package/dist/command/cli/doctor/browser/chromium-hint.js +5 -0
  32. package/dist/command/cli/launch/cli-launch.d.ts +8 -0
  33. package/dist/command/cli/launch/cli-launch.js +21 -9
  34. package/dist/command/cli/launch/sdk-version-match.d.ts +84 -0
  35. package/dist/command/cli/launch/sdk-version-match.js +206 -0
  36. package/dist/command/cli/lifecycle/daemon-lifecycle.js +2 -16
  37. package/dist/command/cli/ports/resolve/cli-port.d.ts +25 -0
  38. package/dist/command/cli/ports/resolve/cli-port.js +125 -15
  39. package/dist/command/cli/setup-mcp-cli.js +21 -13
  40. package/dist/command/cli/tutorial.d.ts +2 -2
  41. package/dist/command/cli/tutorial.js +21 -7
  42. package/dist/command/cli.js +79 -11
  43. package/dist/command/daemon/binding/daemon-status-probe.d.ts +14 -2
  44. package/dist/command/daemon/binding/daemon-status-probe.js +34 -6
  45. package/dist/command/daemon/daemon-resolve.d.ts +9 -0
  46. package/dist/command/daemon/daemon-resolve.js +1 -1
  47. package/dist/command/daemon/lifetime/daemon-usefulness.d.ts +7 -1
  48. package/dist/command/daemon/lifetime/daemon-usefulness.js +30 -7
  49. package/dist/command/dev/stale-issue-guard.d.ts +3 -4
  50. package/dist/command/dev/stale-issue-guard.js +8 -8
  51. package/dist/command/setup/bringup/connect-lease.d.ts +17 -0
  52. package/dist/command/setup/bringup/connect-lease.js +38 -0
  53. package/dist/command/setup/bringup/dev-server-files.d.ts +68 -0
  54. package/dist/command/setup/bringup/dev-server-files.js +131 -0
  55. package/dist/command/setup/bringup/dev-server-log-cap.d.ts +35 -0
  56. package/dist/command/setup/bringup/dev-server-log-cap.js +121 -0
  57. package/dist/command/setup/bringup/dev-server-wait.d.ts +2 -0
  58. package/dist/command/setup/bringup/dev-server-wait.js +1 -1
  59. package/dist/command/setup/bringup/ensure-daemon.d.ts +65 -4
  60. package/dist/command/setup/bringup/ensure-daemon.js +135 -16
  61. package/dist/command/setup/bringup/static-page-server.d.ts +35 -0
  62. package/dist/command/setup/bringup/static-page-server.js +151 -0
  63. package/dist/command/setup/desktop-shape.d.ts +4 -0
  64. package/dist/command/setup/desktop-shape.js +18 -2
  65. package/dist/command/setup/init/init-port.d.ts +15 -0
  66. package/dist/command/setup/init/init-port.js +44 -0
  67. package/dist/command/setup/init/init-runtime.d.ts +1 -1
  68. package/dist/command/setup/init/init-runtime.js +91 -9
  69. package/dist/command/setup/node-effects.d.ts +27 -14
  70. package/dist/command/setup/node-effects.js +86 -45
  71. package/dist/command/setup/probe/loopback-probe-urls.d.ts +7 -0
  72. package/dist/command/setup/probe/loopback-probe-urls.js +40 -0
  73. package/dist/command/setup/probe/page-probe.d.ts +13 -2
  74. package/dist/command/setup/probe/page-probe.js +18 -3
  75. package/dist/command/setup/run-setup.d.ts +28 -1
  76. package/dist/command/setup/run-setup.js +103 -15
  77. package/dist/command/setup/session-pick.d.ts +13 -0
  78. package/dist/command/setup/session-pick.js +20 -0
  79. package/dist/command/setup/setup-command.d.ts +2 -14
  80. package/dist/command/setup/setup-command.js +105 -31
  81. package/dist/command/setup/setup-mcp.d.ts +2 -0
  82. package/dist/command/setup/setup-mcp.js +17 -8
  83. package/dist/command/setup/terminal/wait-progress.d.ts +8 -0
  84. package/dist/command/setup/terminal/wait-progress.js +17 -0
  85. package/dist/command/version/peer-announce.d.ts +6 -2
  86. package/dist/command/version/peer-announce.js +8 -6
  87. package/dist/command/version/version-nudge.d.ts +17 -3
  88. package/dist/command/version/version-nudge.js +25 -4
  89. package/dist/features/crawl/crawl-empty.js +1 -1
  90. package/dist/features/crawl/crawl-tools.d.ts +6 -0
  91. package/dist/features/crawl/crawl-tools.js +57 -0
  92. package/dist/features/crawl/crawl.js +171 -157
  93. package/dist/features/exhaust/app-coverage.d.ts +33 -0
  94. package/dist/features/exhaust/app-coverage.js +31 -0
  95. package/dist/features/exhaust/code-coverage.d.ts +47 -0
  96. package/dist/features/exhaust/code-coverage.js +77 -0
  97. package/dist/features/exhaust/exhaust-run.d.ts +33 -0
  98. package/dist/features/exhaust/exhaust-run.js +82 -0
  99. package/dist/features/exhaust/explorer.d.ts +103 -0
  100. package/dist/features/exhaust/explorer.js +195 -0
  101. package/dist/features/exhaust/failure-branches.d.ts +33 -0
  102. package/dist/features/exhaust/failure-branches.js +92 -0
  103. package/dist/features/exhaust/ledger.d.ts +202 -0
  104. package/dist/features/exhaust/ledger.js +252 -0
  105. package/dist/features/exhaust/session-fold.d.ts +31 -0
  106. package/dist/features/exhaust/session-fold.js +79 -0
  107. package/dist/features/exhaust/session-port.d.ts +36 -0
  108. package/dist/features/exhaust/session-port.js +102 -0
  109. package/dist/features/harness/drive-report.d.ts +0 -9
  110. package/dist/features/harness/drive-report.js +18 -0
  111. package/dist/features/harness/driver.js +4 -7
  112. package/dist/features/harness/fill-values.d.ts +10 -0
  113. package/dist/features/harness/fill-values.js +50 -11
  114. package/dist/features/harness/jev-driver.js +30 -13
  115. package/dist/features/harness/openai-driver.d.ts +12 -0
  116. package/dist/features/harness/openai-driver.js +21 -12
  117. package/dist/features/harness/platform-config.js +5 -6
  118. package/dist/features/license/license.d.ts +2 -2
  119. package/dist/index.d.ts +9 -0
  120. package/dist/index.js +56 -19
  121. package/dist/judgement/capsule/capsule-store.d.ts +4 -4
  122. package/dist/judgement/domain/domain-model.js +3 -1
  123. package/dist/judgement/oracles/self-instrument.js +4 -2
  124. package/dist/judgement/runs/artifact/replay-mapping.d.ts +2 -2
  125. package/dist/judgement/runs/artifact/replay-mapping.js +44 -9
  126. package/dist/judgement/runs/verification-sync.d.ts +3 -1
  127. package/dist/judgement/runs/verification-sync.js +1 -1
  128. package/dist/language/flows/change/affected.d.ts +9 -0
  129. package/dist/language/flows/change/affected.js +35 -0
  130. package/dist/language/flows/change/gate.d.ts +20 -0
  131. package/dist/language/flows/change/gate.js +12 -1
  132. package/dist/language/flows/flow-author.d.ts +7 -0
  133. package/dist/language/flows/flow-author.js +19 -0
  134. package/dist/language/flows/flow-expect-grammar.js +1 -1
  135. package/dist/language/flows/flow-journey.d.ts +54 -0
  136. package/dist/language/flows/flow-journey.js +119 -0
  137. package/dist/language/flows/flow-replay-run.d.ts +2 -3
  138. package/dist/language/flows/flow-replay-run.js +13 -47
  139. package/dist/language/flows/flow-replay.d.ts +22 -8
  140. package/dist/language/flows/flow-replay.js +55 -9
  141. package/dist/language/flows/flow-result.d.ts +2 -0
  142. package/dist/language/flows/flow-result.js +25 -0
  143. package/dist/language/flows/flow-tools.js +17 -5
  144. package/dist/language/flows/flows.d.ts +10 -1
  145. package/dist/language/flows/flows.js +90 -14
  146. package/dist/language/flows/recording/replay-halt.js +3 -1
  147. package/dist/language/flows/recording/tape/recordings.d.ts +30 -1
  148. package/dist/language/flows/recording/tape/recordings.js +55 -1
  149. package/dist/language/flows/replay.d.ts +19 -0
  150. package/dist/language/flows/replay.js +42 -6
  151. package/dist/language/flows/verify-change-tools.js +5 -2
  152. package/dist/launch-chromium.d.ts +80 -0
  153. package/dist/launch-chromium.js +218 -0
  154. package/dist/memory/cloud/cloud-config.d.ts +11 -2
  155. package/dist/memory/cloud/cloud-config.js +47 -7
  156. package/dist/memory/cloud/cloud-sync.d.ts +4 -1
  157. package/dist/memory/cloud/cloud-sync.js +6 -9
  158. package/dist/memory/cloud/harness-offer.js +5 -6
  159. package/dist/memory/cloud/harness-switch.js +5 -6
  160. package/dist/memory/cloud/sync-cycle.d.ts +77 -3
  161. package/dist/memory/cloud/sync-cycle.js +325 -55
  162. package/dist/memory/cloud/sync-daemon.js +24 -20
  163. package/dist/memory/cloud/sync-disk.js +16 -2
  164. package/dist/memory/intent/intent-shard.d.ts +10 -32
  165. package/dist/memory/intent/intent-shard.js +0 -10
  166. package/dist/memory/intent/intent-tools.js +8 -3
  167. package/dist/memory/journal/drive-flow.d.ts +18 -13
  168. package/dist/memory/journal/drive-flow.js +45 -37
  169. package/dist/memory/journal/envelope.d.ts +8 -8
  170. package/dist/memory/journal/journal-query.d.ts +14 -0
  171. package/dist/memory/journal/journal-query.js +15 -0
  172. package/dist/memory/journal/on-disk/workspace-tiers.js +2 -0
  173. package/dist/memory/journal/session-end.d.ts +9 -1
  174. package/dist/memory/journal/session-end.js +24 -12
  175. package/dist/memory/project/artifact-root-resolver.d.ts +10 -0
  176. package/dist/memory/project/artifact-root-resolver.js +46 -19
  177. package/dist/memory/project/dir/reticle-dir.d.ts +2 -0
  178. package/dist/memory/project/dir/reticle-dir.js +1 -0
  179. package/dist/memory/project/project-tools.js +3 -1
  180. package/dist/portal/bridge/auth-failure-reason.d.ts +1 -1
  181. package/dist/portal/bridge/auth-failure-reason.js +4 -2
  182. package/dist/portal/bridge/bridge.d.ts +12 -3
  183. package/dist/portal/bridge/bridge.js +49 -3
  184. package/dist/portal/input/js-coverage.d.ts +25 -0
  185. package/dist/portal/input/js-coverage.js +30 -0
  186. package/dist/portal/input/real-input.d.ts +11 -0
  187. package/dist/portal/input/real-input.js +29 -4
  188. package/dist/portal/input/viewport-tools.js +16 -6
  189. package/dist/portal/pool/playwright-launcher.d.ts +6 -0
  190. package/dist/portal/pool/playwright-launcher.js +20 -13
  191. package/dist/portal/session/dev-server/dev-command.d.ts +2 -2
  192. package/dist/portal/session/dev-server/dev-command.js +30 -12
  193. package/dist/portal/session/dev-server/dev-server-probe.js +17 -1
  194. package/dist/portal/session/dev-server/route-status-probe.d.ts +24 -0
  195. package/dist/portal/session/dev-server/route-status-probe.js +57 -0
  196. package/dist/portal/session/facts/observed-state.d.ts +11 -0
  197. package/dist/portal/session/facts/observed-state.js +34 -0
  198. package/dist/portal/session/no-session-diagnosis.d.ts +29 -0
  199. package/dist/portal/session/no-session-diagnosis.js +62 -5
  200. package/dist/portal/session/no-session-next-action.d.ts +13 -0
  201. package/dist/portal/session/no-session-next-action.js +48 -9
  202. package/dist/portal/session/no-session-watch.d.ts +18 -0
  203. package/dist/portal/session/no-session-watch.js +88 -2
  204. package/dist/portal/session/session-health.js +3 -2
  205. package/dist/portal/session/session-manager.d.ts +20 -6
  206. package/dist/portal/session/session-manager.js +19 -3
  207. package/dist/portal/session/session-reaper.d.ts +28 -0
  208. package/dist/portal/session/session-reaper.js +49 -1
  209. package/dist/portal/session/session.d.ts +10 -8
  210. package/dist/portal/session/session.js +24 -32
  211. package/dist/surface/http-server.d.ts +3 -2
  212. package/dist/surface/http-server.js +8 -5
  213. package/dist/surface/mcp/mcp-proxy.d.ts +2 -2
  214. package/dist/surface/mcp/mcp-proxy.js +2 -2
  215. package/dist/surface/mcp/mcp.js +5 -3
  216. package/dist/surface/mcp/proxy/proxy-daemon-probe.d.ts +13 -1
  217. package/dist/surface/mcp/proxy/proxy-daemon-probe.js +27 -2
  218. package/dist/surface/mcp/proxy/proxy-log.js +3 -5
  219. package/dist/surface/mcp/server-instructions.js +9 -7
  220. package/dist/surface/tools/act/after-match.d.ts +17 -0
  221. package/dist/surface/tools/act/after-match.js +30 -0
  222. package/dist/surface/tools/act/durable.d.ts +69 -0
  223. package/dist/surface/tools/act/durable.js +139 -0
  224. package/dist/surface/tools/act/navigation/navigate-arrival.d.ts +13 -6
  225. package/dist/surface/tools/act/navigation/navigate-arrival.js +47 -10
  226. package/dist/surface/tools/act/navigation/navigate-result.d.ts +1 -12
  227. package/dist/surface/tools/act/navigation/navigate-result.js +21 -3
  228. package/dist/surface/tools/act/proved-controls.d.ts +9 -0
  229. package/dist/surface/tools/act/proved-controls.js +11 -0
  230. package/dist/surface/tools/act/sequence-grade.d.ts +5 -0
  231. package/dist/surface/tools/act/sequence-grade.js +32 -1
  232. package/dist/surface/tools/act-capsule.d.ts +7 -0
  233. package/dist/surface/tools/act-capsule.js +46 -1
  234. package/dist/surface/tools/act-sequence-tool.js +25 -8
  235. package/dist/surface/tools/act-tools.js +28 -52
  236. package/dist/surface/tools/assert/assert-grade.js +12 -1
  237. package/dist/surface/tools/assert/assert-verdict.js +2 -2
  238. package/dist/surface/tools/browser-tools.js +14 -2
  239. package/dist/surface/tools/coverage-tools.js +27 -1
  240. package/dist/surface/tools/dynamic-tools.js +29 -2
  241. package/dist/surface/tools/error-recovery.js +5 -6
  242. package/dist/surface/tools/feedback-invite.js +6 -4
  243. package/dist/surface/tools/harness-explore.d.ts +3 -2
  244. package/dist/surface/tools/harness-explore.js +12 -7
  245. package/dist/surface/tools/invoke-tool.js +12 -8
  246. package/dist/surface/tools/lease-tools.js +15 -6
  247. package/dist/surface/tools/live-call-text.js +4 -1
  248. package/dist/surface/tools/observe-tools.js +9 -1
  249. package/dist/surface/tools/tool-kit.d.ts +10 -0
  250. package/dist/surface/tools/tools.js +4 -0
  251. package/dist/telemetry/argument-shape.d.ts +0 -2
  252. package/dist/telemetry/argument-shape.js +1 -5
  253. package/dist/telemetry/error-class.d.ts +2 -3
  254. package/dist/telemetry/error-class.js +2 -3
  255. package/dist/telemetry/harness-drive.d.ts +0 -2
  256. package/dist/telemetry/harness-drive.js +0 -4
  257. package/dist/telemetry/onboarding-firsts.d.ts +2 -2
  258. package/dist/telemetry/onboarding-firsts.js +2 -2
  259. package/dist/wire-journal.d.ts +3 -0
  260. package/dist/wire-journal.js +4 -0
  261. package/dist/workspace-packages.d.ts +0 -2
  262. package/dist/workspace-packages.js +1 -9
  263. package/docs/README.md +4 -2
  264. package/docs/actions.mdx +3 -4
  265. package/docs/agent-cheatsheet.md +4 -4
  266. package/docs/architecture.md +6 -6
  267. package/docs/best-practices.mdx +1 -1
  268. package/docs/capabilities.mdx +32 -1
  269. package/docs/cli/cloud.mdx +20 -8
  270. package/docs/cli/doctor.mdx +4 -0
  271. package/docs/cli/feedback.mdx +2 -2
  272. package/docs/cli/gate.mdx +9 -4
  273. package/docs/cli/update.mdx +10 -0
  274. package/docs/cli.mdx +22 -7
  275. package/docs/desktop.mdx +14 -10
  276. package/docs/environment.mdx +87 -0
  277. package/docs/faq.mdx +18 -16
  278. package/docs/first-drive.md +5 -13
  279. package/docs/flows.md +21 -2
  280. package/docs/frameworks.mdx +29 -10
  281. package/docs/getting-started.md +15 -5
  282. package/docs/http-transport.md +6 -3
  283. package/docs/human-control.md +2 -2
  284. package/docs/index.mdx +16 -6
  285. package/docs/install-agentic.mdx +2 -2
  286. package/docs/install-manual.mdx +1 -1
  287. package/docs/integration-patterns.md +3 -3
  288. package/docs/multi-agent-testing.md +1 -1
  289. package/docs/packages/babel-plugin.mdx +1 -1
  290. package/docs/packages/browser.mdx +2 -2
  291. package/docs/packages/next.mdx +3 -0
  292. package/docs/packages/react.mdx +2 -2
  293. package/docs/packages/tauri.mdx +1 -1
  294. package/docs/packages/vite-plugin.mdx +4 -2
  295. package/docs/packages.mdx +9 -9
  296. package/docs/predicates.mdx +50 -5
  297. package/docs/quickstart.mdx +12 -10
  298. package/docs/recipes.mdx +2 -2
  299. package/docs/state-management.mdx +2 -2
  300. package/docs/system-map.md +1 -1
  301. package/docs/telemetry.md +1 -1
  302. package/docs/token-efficiency.md +3 -3
  303. package/docs/tools/act-and-wait.mdx +1 -0
  304. package/docs/tools/act-sequence.mdx +1 -1
  305. package/docs/tools/act.mdx +1 -1
  306. package/docs/tools/console.mdx +1 -1
  307. package/docs/tools/inspect.mdx +1 -1
  308. package/docs/tools/network.mdx +1 -1
  309. package/docs/tools/query.mdx +1 -1
  310. package/docs/tools/sessions.mdx +1 -1
  311. package/docs/tools/snapshot.mdx +1 -1
  312. package/docs/tools/state.mdx +1 -1
  313. package/docs/tools/wait-for.mdx +1 -1
  314. package/docs/usage.md +7 -7
  315. package/docs/use-cases.mdx +157 -0
  316. package/docs/vs-screenshots.mdx +3 -3
  317. package/docs/what-is-recorded.md +2 -2
  318. package/docs/what-is-reticle.mdx +17 -20
  319. package/docs/why-reticle.mdx +14 -21
  320. package/package.json +10 -9
  321. package/dist/judgement/capsule/minimize.d.ts +0 -12
  322. package/dist/judgement/capsule/minimize.js +0 -22
  323. package/dist/judgement/phenomena/phenomena.d.ts +0 -27
  324. package/dist/judgement/phenomena/phenomena.js +0 -101
  325. package/dist/language/flows/flow-report.d.ts +0 -22
  326. package/dist/language/flows/flow-report.js +0 -106
@@ -0,0 +1,102 @@
1
+ /**
2
+ * A live session, as the explorer's port.
3
+ *
4
+ * The one hard part is that a full page load REPLACES the session: the SDK reconnects under the
5
+ * same id (sessionStorage keeps it) but as a new object, and a command in flight on the old one is
6
+ * rejected. So every call reads the CURRENT session, and anything that may have navigated waits for
7
+ * the successor before it answers — the same wait `navigate { reload }` does.
8
+ */
9
+ import { ActionType, ReticleCommand, ReticleTool, SnapshotMode, asRecord, asString, } from '@reticlehq/core';
10
+ import { RELOAD_RECONNECT_TIMEOUT_MS, waitForReconnect, } from '../../portal/session/session-reconnect.js';
11
+ import { isSessionReplacedError } from '../../portal/session/facts/session-replaced.js';
12
+ export function sessionPort(input) {
13
+ let current = input.start;
14
+ /** Wait for the document that replaced `before`. False when none arrived in time. */
15
+ const successor = async (before) => {
16
+ const back = await waitForReconnect({
17
+ current: () => input.sessions.get(before.id),
18
+ previous: before,
19
+ timeoutMs: RELOAD_RECONNECT_TIMEOUT_MS,
20
+ now: input.now,
21
+ sleep: input.sleep,
22
+ });
23
+ const next = input.sessions.get(before.id);
24
+ if (!back || next === undefined)
25
+ return false;
26
+ current = next;
27
+ return true;
28
+ };
29
+ const look = async () => {
30
+ for (let attempt = 0; attempt < 2; attempt += 1) {
31
+ try {
32
+ const res = await current.command(ReticleCommand.SNAPSHOT, {
33
+ mode: SnapshotMode.INTERACTIVE,
34
+ });
35
+ const body = asRecord(res.result);
36
+ const route = asString(asRecord(body['status'])['route']);
37
+ return { tree: asString(body['tree']) ?? '', ...(route === undefined ? {} : { route }) };
38
+ }
39
+ catch (error) {
40
+ // A click that followed a real link leaves the next read on a dead document.
41
+ if (!isSessionReplacedError(error) || !(await successor(current)))
42
+ break;
43
+ }
44
+ }
45
+ return { tree: '' };
46
+ };
47
+ return {
48
+ current: () => current,
49
+ look,
50
+ async reset() {
51
+ const before = current;
52
+ try {
53
+ const res = await before.command(ReticleCommand.NAVIGATE, { url: input.startUrl });
54
+ if (!res.ok)
55
+ return false;
56
+ }
57
+ catch (error) {
58
+ if (!isSessionReplacedError(error))
59
+ return false;
60
+ }
61
+ if (!(await successor(before)))
62
+ return false;
63
+ await input.sleep(input.settleMs);
64
+ return true;
65
+ },
66
+ async act(ref, action, value) {
67
+ const session = current;
68
+ const since = session.elapsed();
69
+ session.beginAction?.(ReticleTool.CRAWL, { ref, action });
70
+ let ok = false;
71
+ let replaced = false;
72
+ try {
73
+ const res = await session.command(ReticleCommand.ACT, {
74
+ ref,
75
+ action: 'fill' === action ? ActionType.FILL : ActionType.CLICK,
76
+ args: value === undefined ? {} : { value },
77
+ });
78
+ ok = res.ok && false !== asRecord(res.result)['dispatched'];
79
+ }
80
+ catch (error) {
81
+ // Following a real link replaces the document mid-command: the click WORKED.
82
+ if (!isSessionReplacedError(error))
83
+ throw error;
84
+ replaced = true;
85
+ ok = true;
86
+ }
87
+ finally {
88
+ session.finishAction?.();
89
+ }
90
+ await input.sleep(input.settleMs);
91
+ const events = session.eventsSince(since);
92
+ if (replaced && (await successor(session)))
93
+ return { ok, events: [...events, ...current.eventsSince(0)] };
94
+ return { ok, events };
95
+ },
96
+ ...(input.setMocks === undefined
97
+ ? {}
98
+ : {
99
+ mock: (rules) => input.setMocks?.(current.url, rules) ?? Promise.resolve(false),
100
+ }),
101
+ };
102
+ }
@@ -61,13 +61,4 @@ export declare function replayedFlows(toolCalls: readonly ToolOutcome[]): {
61
61
  }[];
62
62
  /** Reduce the raw call log to the actions that actually drove the app. */
63
63
  export declare function drivenSteps(toolCalls: readonly ToolOutcome[]): DrivenStep[];
64
- /**
65
- * The account, as lines.
66
- *
67
- * Proved and not-proved are counted separately and both are stated, because the failure mode this
68
- * whole product exists to prevent is a reader taking "we did twelve things" for "twelve things
69
- * work". `unknown` is deliberately grouped under NOT proved and labelled as undecided evidence
70
- * rather than as a failure — it calls for a better check, not a code change, and collapsing the two
71
- * would send an agent to rewrite working code.
72
- */
73
64
  export declare function describeDrive(toolCalls: readonly ToolOutcome[], savedFlows: readonly string[]): string;
@@ -134,6 +134,18 @@ export function drivenSteps(toolCalls) {
134
134
  * rather than as a failure — it calls for a better check, not a code change, and collapsing the two
135
135
  * would send an agent to rewrite working code.
136
136
  */
137
+ /** The pages the drive's own snapshots reported, in order, each distinct page once. */
138
+ function pagesReached(toolCalls) {
139
+ const pages = [];
140
+ for (const call of toolCalls) {
141
+ if (ReticleTool.SNAPSHOT !== call.name || call.isError)
142
+ continue;
143
+ const route = asString(asRecord(asRecord(call.result)['status'])['route']);
144
+ if (route !== undefined && !pages.includes(route))
145
+ pages.push(route);
146
+ }
147
+ return pages;
148
+ }
137
149
  export function describeDrive(toolCalls, savedFlows) {
138
150
  const steps = drivenSteps(toolCalls);
139
151
  const replays = replayedFlows(toolCalls);
@@ -166,10 +178,16 @@ export function describeDrive(toolCalls, savedFlows) {
166
178
  const proved = steps.filter((step) => Verified.YES === step.verified);
167
179
  const failed = steps.filter((step) => Verified.NO === step.verified);
168
180
  const undecided = steps.filter((step) => Verified.YES !== step.verified && Verified.NO !== step.verified);
181
+ const pages = pagesReached(toolCalls);
169
182
  const lines = [
170
183
  ...(replayLine === undefined ? [] : [replayLine]),
171
184
  `Drove ${String(steps.length)} action(s): ${String(proved.length)} proved, ` +
172
185
  `${String(failed.length)} failed, ${String(undecided.length)} not decided.`,
186
+ // How DEEP it got. An action count reads the same for a checkout walked to its receipt and for
187
+ // eleven clicks on the home page; the pages reached are what tell them apart.
188
+ ...(0 === pages.length
189
+ ? []
190
+ : [`Reached ${String(pages.length)} page(s): ${pages.join(' → ')}.`]),
173
191
  ];
174
192
  for (const step of steps.slice(0, MAX_LISTED)) {
175
193
  const verdict = step.verified ?? 'nothing declared';
@@ -11,7 +11,7 @@
11
11
  * purpose.
12
12
  */
13
13
  import { z } from 'zod';
14
- import { ReticleEnv, apiKeyFrom } from '@reticlehq/core';
14
+ import { ReticleEnv, platformCredentialFrom } from '@reticlehq/core';
15
15
  /**
16
16
  * The default driver model.
17
17
  *
@@ -91,13 +91,10 @@ export function harnessOptionsFromEnv(env) {
91
91
  *
92
92
  * An explicit `ANTHROPIC_API_KEY` still wins: someone who exported one meant it.
93
93
  */
94
- const cloudKey = apiKeyFrom(env);
95
- const cloudUrl = env[ReticleEnv.CLOUD_URL];
96
- if (cloudKey === undefined || 0 === cloudKey.length)
94
+ const cloud = platformCredentialFrom(env);
95
+ if (cloud === undefined)
97
96
  return undefined;
98
- if (cloudUrl === undefined || 0 === cloudUrl.length)
99
- return undefined;
100
- return withOptions(cloudKey, cloudUrl);
97
+ return withOptions(cloud.apiKey, cloud.url);
101
98
  }
102
99
  /** Build a driver backed by the Messages API. */
103
100
  export function harnessDriver(options) {
@@ -31,6 +31,7 @@
31
31
  * wrong verdict. Nothing here touches what is judged.
32
32
  */
33
33
  import { type HarnessDriverOptions } from './driver.js';
34
+ import { type OpenAiDriverOptions } from './openai-driver.js';
34
35
  /** What the caller must be able to do for values to survive past this drive. */
35
36
  export interface FillCache {
36
37
  get(label: string): string | undefined;
@@ -61,7 +62,16 @@ export declare function needsGeneration(label: string): boolean;
61
62
  */
62
63
  export declare function fillValues(deps: {
63
64
  cache?: FillCache;
65
+ /** GPT, the generator a Jev drive pairs with. Asked ahead of `generator` when both are set. */
66
+ openai?: OpenAiDriverOptions;
67
+ /** Anthropic, for a machine that holds only that key. */
64
68
  generator?: HarnessDriverOptions;
65
69
  /** One line about where the drive is, so a value suits the page it is typed on. */
66
70
  context?: () => string;
71
+ /**
72
+ * A value the user SUPPLIED for this field — the same `RETICLE_SECRET_<FIELD>` replay reads for
73
+ * a redacted one. Checked first so a drive gets past a login, and never cached: the cache is a
74
+ * file on disk.
75
+ */
76
+ secret?: (label: string) => string | undefined;
67
77
  }): (label: string) => Promise<string>;
@@ -31,6 +31,7 @@
31
31
  * wrong verdict. Nothing here touches what is judged.
32
32
  */
33
33
  import { DEFAULT_HARNESS_BASE_URL, } from './driver.js';
34
+ import { DEFAULT_OPENAI_MODEL, OPENAI_REASONING_EFFORT, openAiCompletionsUrl, } from './openai-driver.js';
34
35
  /** Deliberately small. A field value is a phrase; anything longer is the model misunderstanding. */
35
36
  const MAX_TOKENS = 64;
36
37
  const ANTHROPIC_VERSION = '2023-06-01';
@@ -87,6 +88,40 @@ const PROMPT = (label, context) => `A test harness is filling in a form field on
87
88
  `Reply with ONLY the value to type. No quotes, no explanation, no markdown. It must be something a ` +
88
89
  `real user would plausibly enter, and short. If the field wants an identifier or a code, invent a ` +
89
90
  `well-formed one.`;
91
+ /**
92
+ * A model's one-line answer as a field value, or nothing. A model asked for one value occasionally
93
+ * answers with a sentence about the value; anything long enough to be prose is not a field value,
94
+ * and typing prose proves nothing about the app.
95
+ */
96
+ function asValue(raw) {
97
+ const text = raw?.trim().split('\n')[0];
98
+ if (text === undefined || 0 === text.length)
99
+ return undefined;
100
+ return 80 < text.length ? undefined : text.replace(/^["']|["']$/g, '');
101
+ }
102
+ /** One string from GPT over Chat Completions — directly, or through the platform with its key. */
103
+ async function generateWithOpenAi(options, label, context) {
104
+ const call = options.fetch ?? ((url, init) => fetch(url, init));
105
+ try {
106
+ const res = await call(openAiCompletionsUrl(options), {
107
+ method: 'POST',
108
+ headers: { 'content-type': 'application/json', authorization: `Bearer ${options.apiKey}` },
109
+ body: JSON.stringify({
110
+ model: options.model ?? DEFAULT_OPENAI_MODEL,
111
+ max_completion_tokens: MAX_TOKENS,
112
+ reasoning_effort: OPENAI_REASONING_EFFORT,
113
+ messages: [{ role: 'user', content: PROMPT(label, context) }],
114
+ }),
115
+ });
116
+ if (!res.ok)
117
+ return undefined;
118
+ const parsed = JSON.parse(await res.text());
119
+ return asValue(parsed.choices?.[0]?.message?.content ?? undefined);
120
+ }
121
+ catch {
122
+ return undefined;
123
+ }
124
+ }
90
125
  /** One string from a generating model, or nothing. Never throws: a drive must not fail over a field. */
91
126
  async function generateOne(options, label, context) {
92
127
  const call = options.fetch ?? ((url, init) => fetch(url, init));
@@ -109,17 +144,10 @@ async function generateOne(options, label, context) {
109
144
  return undefined;
110
145
  const parsed = JSON.parse(await res.text());
111
146
  const content = parsed.content ?? [];
112
- const text = content
147
+ return asValue(content
113
148
  .filter((block) => 'text' === block.type)
114
149
  .map((block) => block.text ?? '')
115
- .join('')
116
- .trim()
117
- .split('\n')[0];
118
- if (text === undefined || 0 === text.length)
119
- return undefined;
120
- // A model asked for one value occasionally answers with a sentence about the value. Anything
121
- // long enough to be prose is not a field value, and typing prose proves nothing about the app.
122
- return 80 < text.length ? undefined : text.replace(/^["']|["']$/g, '');
150
+ .join(''));
123
151
  }
124
152
  catch {
125
153
  // Offline, refused, rate-limited, malformed. All the same answer: use the heuristic.
@@ -135,14 +163,25 @@ async function generateOne(options, label, context) {
135
163
  export function fillValues(deps) {
136
164
  let spent = 0;
137
165
  return async (label) => {
166
+ const supplied = deps.secret?.(label);
167
+ if (supplied !== undefined && supplied.length > 0)
168
+ return supplied;
138
169
  const cached = deps.cache?.get(label);
139
170
  if (cached !== undefined)
140
171
  return cached;
141
172
  const fallback = heuristicFillValue(label);
142
- if (deps.generator === undefined || !needsGeneration(label) || MAX_PER_DRIVE <= spent)
173
+ const { openai, generator } = deps;
174
+ if ((openai === undefined && generator === undefined) ||
175
+ !needsGeneration(label) ||
176
+ MAX_PER_DRIVE <= spent)
143
177
  return fallback;
144
178
  spent += 1;
145
- const generated = await generateOne(deps.generator, label, deps.context?.() ?? '');
179
+ const context = deps.context?.() ?? '';
180
+ const generated = openai !== undefined
181
+ ? await generateWithOpenAi(openai, label, context)
182
+ : generator !== undefined
183
+ ? await generateOne(generator, label, context)
184
+ : undefined;
146
185
  if (generated === undefined)
147
186
  return fallback;
148
187
  // Cached under the LABEL, not the ref: refs expire with the page, labels are what the next drive
@@ -21,7 +21,7 @@
21
21
  * exist because this product is the verdict, and a verdict sourced from a model's confidence is the
22
22
  * thing Reticle sells the absence of.
23
23
  */
24
- import { RETICLE_URL_PARAM, ReticleEnv, ReticleTool, apiKeyFrom, asRecord, parseInteractive, } from '@reticlehq/core';
24
+ import { RETICLE_URL_PARAM, ReticleEnv, ReticleTool, platformCredentialFrom, asRecord, parseInteractive, } from '@reticlehq/core';
25
25
  import { FINISH_TOOL } from './harness.js';
26
26
  import { heuristicFillValue } from './fill-values.js';
27
27
  export const DEFAULT_JEV_MODEL = 'jev-latest';
@@ -55,12 +55,15 @@ const Tool = {
55
55
  RECORD: ReticleTool.RECORD,
56
56
  FLOW_SAVE: ReticleTool.FLOW_SAVE,
57
57
  FLOW_REPLAY: ReticleTool.FLOW_REPLAY,
58
+ NAVIGATE: ReticleTool.NAVIGATE,
58
59
  FINISH: FINISH_TOOL.name,
59
60
  };
60
61
  /** The synthetic option meaning "stop driving". Not a tool arg — a key in the choice set. */
61
62
  const FINISH_OPTION = 'finish';
62
63
  /** The synthetic option meaning "I cannot tell from this page; look again". */
63
64
  const RELOOK_OPTION = 'look_again';
65
+ /** Back to the page before this one — a dead end used to end the whole drive where it stood. */
66
+ const BACK_OPTION = 'go_back';
64
67
  /**
65
68
  * Tools the model may route to, beyond acting on a control.
66
69
  *
@@ -244,14 +247,11 @@ export function jevOptionsFromEnv(env) {
244
247
  };
245
248
  }
246
249
  // The ordinary path: the key the user minted on the platform, against the platform's own proxy.
247
- // Reticle never ships a Jev key, so without a base URL to send it to this is not a usable driver.
248
- const cloudKey = apiKeyFrom(env);
249
- const cloudUrl = env[ReticleEnv.CLOUD_URL];
250
- if (cloudKey === undefined || 0 === cloudKey.length)
250
+ // Reticle never ships a Jev key; the URL is the configured platform, else the hosted service.
251
+ const cloud = platformCredentialFrom(env);
252
+ if (cloud === undefined)
251
253
  return undefined;
252
- if (cloudUrl === undefined || 0 === cloudUrl.length)
253
- return undefined;
254
- return { apiKey: cloudKey, baseUrl: cloudUrl };
254
+ return { apiKey: cloud.apiKey, baseUrl: cloud.url };
255
255
  }
256
256
  /** Strip the snapshot's list marker, so a description reads as a phrase rather than a bullet. */
257
257
  function cleanDesc(desc) {
@@ -287,6 +287,8 @@ function readState(history) {
287
287
  saved: [],
288
288
  tree: undefined,
289
289
  route: undefined,
290
+ pages: [],
291
+ proved: [],
290
292
  replayed: [],
291
293
  acted: [],
292
294
  blocked: [],
@@ -333,13 +335,22 @@ function readState(history) {
333
335
  if ('string' === typeof tree)
334
336
  state.tree = tree;
335
337
  const route = asRecord(result['status'])['route'];
336
- if ('string' === typeof route)
338
+ if ('string' === typeof route) {
337
339
  state.route = appRoute(route);
340
+ if (state.pages.at(-1) !== route)
341
+ state.pages.push(route);
342
+ }
338
343
  }
344
+ if (Tool.NAVIGATE === outcome.name)
345
+ state.tree = undefined;
339
346
  if (Tool.ACT_AND_WAIT === outcome.name) {
340
347
  const ref = asRecord(outcome.args)['ref'];
341
348
  const failure = asRecord(outcome.result)['error'];
342
349
  const refused = outcome.isError && 'string' === typeof failure && failure.includes(DANGEROUS_ARG);
350
+ const until = asRecord(asRecord(outcome.args)['until']);
351
+ const signal = until['name'];
352
+ if ('yes' === asRecord(outcome.result)['verified'] && 'string' === typeof signal)
353
+ state.proved.push(signal);
343
354
  if ('string' === typeof ref) {
344
355
  // A refused act never happened, so it is not something this drive has driven. Recording
345
356
  // it as driven would retire the control after an attempt that never reached the app.
@@ -550,7 +561,7 @@ export function jevDriver(options) {
550
561
  // ── the one real decision ────────────────────────────────────────────────────────────────
551
562
  // What the drive is currently for: the first plan step that is not a replay. Replays are all
552
563
  // done by the time we reach here, so whatever is left is the intent nobody has proved.
553
- const objective = plan.find((step) => PLAN_REPLAY !== step.kind);
564
+ const objective = plan.find((step) => PLAN_REPLAY !== step.kind && !drive.proved.includes(step.target));
554
565
  const candidates = candidatesFrom(drive.tree);
555
566
  /**
556
567
  * A page with nothing to act on ends the DRIVE, not just the journey.
@@ -567,11 +578,15 @@ export function jevDriver(options) {
567
578
  return only(request(Tool.RECORD, { action: 'stop', recordingName: drive.open.name }), 'nothing interactive on this page; wind up');
568
579
  }
569
580
  const criteria = {
570
- [FINISH_OPTION]: 'Stop driving: the app has been covered, or nothing here leads anywhere new.',
581
+ [FINISH_OPTION]: 'Stop driving: every journey started here reached its end state, or nothing leads anywhere new.',
571
582
  [RELOOK_OPTION]: 'Look at the page again without acting, because this reading looks incomplete.',
572
583
  [OBSERVE_OPTION]: 'Read what the application DID since the last action — the requests it made and what it logged. Choose this when something was driven and it is not yet clear whether it worked.',
573
584
  [STATE_OPTION]: "Read the application's own state, which is the strongest evidence there is and the one thing a screen cannot fake.",
574
585
  };
586
+ const previous = drive.pages.at(-2);
587
+ if (previous !== undefined)
588
+ criteria[BACK_OPTION] =
589
+ `Go back to ${previous}: this page is a dead end, or a journey started there is not finished.`;
575
590
  for (const candidate of candidates) {
576
591
  const verb = actionFor(candidate.role);
577
592
  const already = drive.acted.includes(candidate.ref) ? ' (already driven once)' : '';
@@ -580,12 +595,12 @@ export function jevDriver(options) {
580
595
  const response = await callJev({ apiKey: options.apiKey, model, baseUrl, path, doFetch }, buildState(input.system, input.history, drive, objective), {
581
596
  next_action: {
582
597
  type: 'choice',
583
- instructions: 'Which single action best advances coverage of this application right now? Prefer a control that completes a real user journey, and prefer something not already driven.',
598
+ instructions: 'Which single action carries the current user journey forward toward its END state — a submitted form, a saved record, a confirmation? Finish the journey this page started before opening a new one; prefer something not already driven only once it is finished.',
584
599
  criteria,
585
600
  },
586
601
  journey_complete: {
587
602
  type: 'noul',
588
- instructions: 'The application has been meaningfully covered by the actions driven so far, and further clicking would add nothing.',
603
+ instructions: 'Every journey started so far has been carried to its end state and checked there, and further driving would add nothing.',
589
604
  },
590
605
  });
591
606
  const usage = {
@@ -602,6 +617,8 @@ export function jevDriver(options) {
602
617
  }
603
618
  if (RELOOK_OPTION === chosen)
604
619
  return only(request(Tool.SNAPSHOT, { mode: 'interactive' }), 'look again', usage);
620
+ if (BACK_OPTION === chosen && previous !== undefined)
621
+ return only(request(Tool.NAVIGATE, { url: previous }), `back to ${previous}`, usage);
605
622
  // Routing to a READ rather than an action. Neither changes the app, so neither is recorded as
606
623
  // something driven — they are how the drive finds out whether what it drove worked.
607
624
  if (OBSERVE_OPTION === chosen)
@@ -42,5 +42,17 @@ export interface OpenAiDriverOptions {
42
42
  * OpenAI key, which is the entire point of the proxy.
43
43
  */
44
44
  export declare function openAiOptionsFromEnv(env: Record<string, string | undefined>): OpenAiDriverOptions | undefined;
45
+ /**
46
+ * Where a Chat Completions call goes. The platform does not expose `/v1/chat/completions`; it
47
+ * exposes its own path and forwards. A base URL that is not OpenAI's is the platform's, which is
48
+ * the only other thing this talks to.
49
+ */
50
+ export declare function openAiCompletionsUrl(options: Pick<OpenAiDriverOptions, 'baseUrl'>): string;
51
+ /**
52
+ * The small GPT models refuse function tools on Chat Completions while reasoning is on: measured,
53
+ * `gpt-5.6-luna` answers 400 to the first request that carries tools. A driving turn is a choice,
54
+ * not a plan, so no hidden reasoning is also the right depth and the cheapest one.
55
+ */
56
+ export declare const OPENAI_REASONING_EFFORT = "none";
45
57
  /** Build a driver backed by Chat Completions. */
46
58
  export declare function openAiDriver(options: OpenAiDriverOptions): ModelDriver;
@@ -17,7 +17,7 @@
17
17
  * it is reported below so the number is visible rather than assumed.
18
18
  */
19
19
  import { z } from 'zod';
20
- import { ReticleEnv, apiKeyFrom } from '@reticlehq/core';
20
+ import { ReticleEnv, platformCredentialFrom } from '@reticlehq/core';
21
21
  /**
22
22
  * The default model.
23
23
  *
@@ -71,13 +71,10 @@ export function openAiOptionsFromEnv(env) {
71
71
  const direct = env[ReticleEnv.HARNESS_OPENAI_KEY];
72
72
  if (direct !== undefined && 0 < direct.length)
73
73
  return withModel({ apiKey: direct });
74
- const cloudKey = apiKeyFrom(env);
75
- const cloudUrl = env[ReticleEnv.CLOUD_URL];
76
- if (cloudKey === undefined || 0 === cloudKey.length)
74
+ const cloud = platformCredentialFrom(env);
75
+ if (cloud === undefined)
77
76
  return undefined;
78
- if (cloudUrl === undefined || 0 === cloudUrl.length)
79
- return undefined;
80
- return withModel({ apiKey: cloudKey, baseUrl: cloudUrl });
77
+ return withModel({ apiKey: cloud.apiKey, baseUrl: cloud.url });
81
78
  }
82
79
  function toWireTool(tool) {
83
80
  return {
@@ -142,17 +139,28 @@ function parseArgs(raw) {
142
139
  return {};
143
140
  }
144
141
  }
142
+ /**
143
+ * Where a Chat Completions call goes. The platform does not expose `/v1/chat/completions`; it
144
+ * exposes its own path and forwards. A base URL that is not OpenAI's is the platform's, which is
145
+ * the only other thing this talks to.
146
+ */
147
+ export function openAiCompletionsUrl(options) {
148
+ const baseUrl = options.baseUrl ?? DEFAULT_OPENAI_BASE_URL;
149
+ return `${baseUrl}${DEFAULT_OPENAI_BASE_URL === baseUrl ? OPENAI_PATH : PLATFORM_PATH}`;
150
+ }
151
+ /**
152
+ * The small GPT models refuse function tools on Chat Completions while reasoning is on: measured,
153
+ * `gpt-5.6-luna` answers 400 to the first request that carries tools. A driving turn is a choice,
154
+ * not a plan, so no hidden reasoning is also the right depth and the cheapest one.
155
+ */
156
+ export const OPENAI_REASONING_EFFORT = 'none';
145
157
  /** Build a driver backed by Chat Completions. */
146
158
  export function openAiDriver(options) {
147
159
  const model = options.model ?? DEFAULT_OPENAI_MODEL;
148
- const baseUrl = options.baseUrl ?? DEFAULT_OPENAI_BASE_URL;
149
160
  const doFetch = options.fetch ?? ((url, init) => fetch(url, init));
150
- // The platform does not expose `/v1/chat/completions`; it exposes its own path and forwards. A
151
- // base URL that is not OpenAI's is the platform's, which is the only other thing this talks to.
152
- const path = DEFAULT_OPENAI_BASE_URL === baseUrl ? OPENAI_PATH : PLATFORM_PATH;
153
161
  return {
154
162
  async turn(input) {
155
- const response = await doFetch(`${baseUrl}${path}`, {
163
+ const response = await doFetch(openAiCompletionsUrl(options), {
156
164
  method: 'POST',
157
165
  headers: {
158
166
  'content-type': 'application/json',
@@ -161,6 +169,7 @@ export function openAiDriver(options) {
161
169
  body: JSON.stringify({
162
170
  model,
163
171
  max_completion_tokens: MAX_TOKENS,
172
+ reasoning_effort: OPENAI_REASONING_EFFORT,
164
173
  tools: input.tools.map(toWireTool),
165
174
  messages: [{ role: 'system', content: input.system }, ...toWireMessages(input.history)],
166
175
  }),
@@ -16,7 +16,7 @@
16
16
  * - it never overrides someone who was EXPLICIT. A driver named in the call, or set in the
17
17
  * environment, wins over the stored preference. Precedence lives in the caller.
18
18
  */
19
- import { ReticleEnv, apiKeyFrom } from '@reticlehq/core';
19
+ import { platformCredentialFrom } from '@reticlehq/core';
20
20
  const CONFIG_PATH = '/v1/model/config';
21
21
  /**
22
22
  * How long the daemon will wait for a preference before driving without it.
@@ -68,12 +68,11 @@ function parse(body) {
68
68
  * warning printed on a path that then works correctly is how people learn to ignore stderr.
69
69
  */
70
70
  export async function fetchPlatformConfig(env, doFetch = (url, init) => fetch(url, init), timeoutMs = TIMEOUT_MS) {
71
- const key = apiKeyFrom(env);
72
- const host = env[ReticleEnv.CLOUD_URL];
73
- if (key === undefined || 0 === key.length)
74
- return undefined;
75
- if (host === undefined || 0 === host.length)
71
+ const cloud = platformCredentialFrom(env);
72
+ if (cloud === undefined)
76
73
  return undefined;
74
+ const key = cloud.apiKey;
75
+ const host = cloud.url;
77
76
  const controller = new AbortController();
78
77
  const timer = setTimeout(() => {
79
78
  controller.abort();
@@ -39,14 +39,14 @@ declare const LicensePayloadSchema: z.ZodObject<{
39
39
  exp: z.ZodNumber;
40
40
  features: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
41
41
  }, "strip", z.ZodTypeAny, {
42
- lid: string;
43
42
  org: string;
43
+ lid: string;
44
44
  plan: string;
45
45
  exp: number;
46
46
  features?: string[] | undefined;
47
47
  }, {
48
- lid: string;
49
48
  org: string;
49
+ lid: string;
50
50
  plan: string;
51
51
  exp: number;
52
52
  features?: string[] | undefined;
package/dist/index.d.ts CHANGED
@@ -15,6 +15,15 @@ export type { ToolDeps, ToolDef } from './surface/tools/tools.js';
15
15
  export { createToolInvoker, UNKNOWN_TOOL_ERROR } from './surface/tools/tool-invoker.js';
16
16
  export { runTool, SESSION_BOUND_TOOLS, SESSION_EXEMPT_TOOLS } from './surface/tools/invoke-tool.js';
17
17
  export type { ToolInvoker } from './surface/tools/tool-invoker.js';
18
+ /**
19
+ * The port-presence check the CLI commands (`drive`, `verify`, `status`, `doctor`, `kill`) all share,
20
+ * re-exported so a consumer embedding `start()` in its own process can refuse a taken port the same
21
+ * honest way instead of letting a raw `EADDRINUSE` stack out — the gap `@reticlehq/test`'s
22
+ * `bootSession()` had (reticlehq/reticle#1141): it called `start()` directly with no pre-flight probe.
23
+ */
24
+ export { probePresence, describePresence, PortPresence, } from './command/daemon/binding/port-presence.js';
25
+ export { probeDaemon } from './surface/mcp/proxy/proxy-daemon-probe.js';
26
+ export { fetchStatus } from './command/daemon/binding/daemon-status-probe.js';
18
27
  export { BaselineStore, normalizeLines, diffLines } from './memory/project/baselines.js';
19
28
  export { RecordingStore } from './language/flows/recording/tape/recordings.js';
20
29
  export type { RecordedStep, CompiledProgram } from './language/flows/recording/tape/recordings.js';