@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.
- package/LICENSE-ENTERPRISE +1 -1
- package/README.md +3 -3
- package/SKILL.md +12 -14
- package/dist/chromium-launch-options.d.ts +4 -3
- package/dist/chromium-launch-options.js +6 -2
- package/dist/command/cli/adhoc-suite.d.ts +22 -0
- package/dist/command/cli/adhoc-suite.js +90 -19
- package/dist/command/cli/adhoc-verdict.d.ts +35 -0
- package/dist/command/cli/adhoc-verdict.js +90 -3
- package/dist/command/cli/answers/gate-hook-message.d.ts +6 -0
- package/dist/command/cli/answers/gate-hook-message.js +6 -0
- package/dist/command/cli/auth/cloud-keystore.d.ts +0 -2
- package/dist/command/cli/auth/cloud-keystore.js +0 -3
- package/dist/command/cli/auth/cloud-session.d.ts +6 -2
- package/dist/command/cli/auth/cloud-session.js +2 -0
- package/dist/command/cli/auth/device-flow.d.ts +2 -2
- package/dist/command/cli/cli-doctor.js +7 -5
- package/dist/command/cli/cli-flow-commands.d.ts +3 -6
- package/dist/command/cli/cli-flow-commands.js +67 -4
- package/dist/command/cli/cli-parse.d.ts +8 -1
- package/dist/command/cli/cli-parse.js +24 -4
- package/dist/command/cli/cli-update-commands.js +8 -1
- package/dist/command/cli/cli-verify.d.ts +24 -3
- package/dist/command/cli/cli-verify.js +54 -11
- package/dist/command/cli/cloud-cli.js +64 -2
- package/dist/command/cli/cloud-kit.js +3 -5
- package/dist/command/cli/cloud-login.d.ts +1 -1
- package/dist/command/cli/cloud-login.js +27 -8
- package/dist/command/cli/demo/demo-page.js +6 -3
- package/dist/command/cli/doctor/browser/chromium-hint.d.ts +5 -0
- package/dist/command/cli/doctor/browser/chromium-hint.js +5 -0
- package/dist/command/cli/launch/cli-launch.d.ts +8 -0
- package/dist/command/cli/launch/cli-launch.js +21 -9
- package/dist/command/cli/launch/sdk-version-match.d.ts +84 -0
- package/dist/command/cli/launch/sdk-version-match.js +206 -0
- package/dist/command/cli/lifecycle/daemon-lifecycle.js +2 -16
- package/dist/command/cli/ports/resolve/cli-port.d.ts +25 -0
- package/dist/command/cli/ports/resolve/cli-port.js +125 -15
- package/dist/command/cli/setup-mcp-cli.js +21 -13
- package/dist/command/cli/tutorial.d.ts +2 -2
- package/dist/command/cli/tutorial.js +21 -7
- package/dist/command/cli.js +79 -11
- package/dist/command/daemon/binding/daemon-status-probe.d.ts +14 -2
- package/dist/command/daemon/binding/daemon-status-probe.js +34 -6
- package/dist/command/daemon/daemon-resolve.d.ts +9 -0
- package/dist/command/daemon/daemon-resolve.js +1 -1
- package/dist/command/daemon/lifetime/daemon-usefulness.d.ts +7 -1
- package/dist/command/daemon/lifetime/daemon-usefulness.js +30 -7
- package/dist/command/dev/stale-issue-guard.d.ts +3 -4
- package/dist/command/dev/stale-issue-guard.js +8 -8
- package/dist/command/setup/bringup/connect-lease.d.ts +17 -0
- package/dist/command/setup/bringup/connect-lease.js +38 -0
- package/dist/command/setup/bringup/dev-server-files.d.ts +68 -0
- package/dist/command/setup/bringup/dev-server-files.js +131 -0
- package/dist/command/setup/bringup/dev-server-log-cap.d.ts +35 -0
- package/dist/command/setup/bringup/dev-server-log-cap.js +121 -0
- package/dist/command/setup/bringup/dev-server-wait.d.ts +2 -0
- package/dist/command/setup/bringup/dev-server-wait.js +1 -1
- package/dist/command/setup/bringup/ensure-daemon.d.ts +65 -4
- package/dist/command/setup/bringup/ensure-daemon.js +135 -16
- package/dist/command/setup/bringup/static-page-server.d.ts +35 -0
- package/dist/command/setup/bringup/static-page-server.js +151 -0
- package/dist/command/setup/desktop-shape.d.ts +4 -0
- package/dist/command/setup/desktop-shape.js +18 -2
- package/dist/command/setup/init/init-port.d.ts +15 -0
- package/dist/command/setup/init/init-port.js +44 -0
- package/dist/command/setup/init/init-runtime.d.ts +1 -1
- package/dist/command/setup/init/init-runtime.js +91 -9
- package/dist/command/setup/node-effects.d.ts +27 -14
- package/dist/command/setup/node-effects.js +86 -45
- package/dist/command/setup/probe/loopback-probe-urls.d.ts +7 -0
- package/dist/command/setup/probe/loopback-probe-urls.js +40 -0
- package/dist/command/setup/probe/page-probe.d.ts +13 -2
- package/dist/command/setup/probe/page-probe.js +18 -3
- package/dist/command/setup/run-setup.d.ts +28 -1
- package/dist/command/setup/run-setup.js +103 -15
- package/dist/command/setup/session-pick.d.ts +13 -0
- package/dist/command/setup/session-pick.js +20 -0
- package/dist/command/setup/setup-command.d.ts +2 -14
- package/dist/command/setup/setup-command.js +105 -31
- package/dist/command/setup/setup-mcp.d.ts +2 -0
- package/dist/command/setup/setup-mcp.js +17 -8
- package/dist/command/setup/terminal/wait-progress.d.ts +8 -0
- package/dist/command/setup/terminal/wait-progress.js +17 -0
- package/dist/command/version/peer-announce.d.ts +6 -2
- package/dist/command/version/peer-announce.js +8 -6
- package/dist/command/version/version-nudge.d.ts +17 -3
- package/dist/command/version/version-nudge.js +25 -4
- package/dist/features/crawl/crawl-empty.js +1 -1
- package/dist/features/crawl/crawl-tools.d.ts +6 -0
- package/dist/features/crawl/crawl-tools.js +57 -0
- package/dist/features/crawl/crawl.js +171 -157
- package/dist/features/exhaust/app-coverage.d.ts +33 -0
- package/dist/features/exhaust/app-coverage.js +31 -0
- package/dist/features/exhaust/code-coverage.d.ts +47 -0
- package/dist/features/exhaust/code-coverage.js +77 -0
- package/dist/features/exhaust/exhaust-run.d.ts +33 -0
- package/dist/features/exhaust/exhaust-run.js +82 -0
- package/dist/features/exhaust/explorer.d.ts +103 -0
- package/dist/features/exhaust/explorer.js +195 -0
- package/dist/features/exhaust/failure-branches.d.ts +33 -0
- package/dist/features/exhaust/failure-branches.js +92 -0
- package/dist/features/exhaust/ledger.d.ts +202 -0
- package/dist/features/exhaust/ledger.js +252 -0
- package/dist/features/exhaust/session-fold.d.ts +31 -0
- package/dist/features/exhaust/session-fold.js +79 -0
- package/dist/features/exhaust/session-port.d.ts +36 -0
- package/dist/features/exhaust/session-port.js +102 -0
- package/dist/features/harness/drive-report.d.ts +0 -9
- package/dist/features/harness/drive-report.js +18 -0
- package/dist/features/harness/driver.js +4 -7
- package/dist/features/harness/fill-values.d.ts +10 -0
- package/dist/features/harness/fill-values.js +50 -11
- package/dist/features/harness/jev-driver.js +30 -13
- package/dist/features/harness/openai-driver.d.ts +12 -0
- package/dist/features/harness/openai-driver.js +21 -12
- package/dist/features/harness/platform-config.js +5 -6
- package/dist/features/license/license.d.ts +2 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.js +56 -19
- package/dist/judgement/capsule/capsule-store.d.ts +4 -4
- package/dist/judgement/domain/domain-model.js +3 -1
- package/dist/judgement/oracles/self-instrument.js +4 -2
- package/dist/judgement/runs/artifact/replay-mapping.d.ts +2 -2
- package/dist/judgement/runs/artifact/replay-mapping.js +44 -9
- package/dist/judgement/runs/verification-sync.d.ts +3 -1
- package/dist/judgement/runs/verification-sync.js +1 -1
- package/dist/language/flows/change/affected.d.ts +9 -0
- package/dist/language/flows/change/affected.js +35 -0
- package/dist/language/flows/change/gate.d.ts +20 -0
- package/dist/language/flows/change/gate.js +12 -1
- package/dist/language/flows/flow-author.d.ts +7 -0
- package/dist/language/flows/flow-author.js +19 -0
- package/dist/language/flows/flow-expect-grammar.js +1 -1
- package/dist/language/flows/flow-journey.d.ts +54 -0
- package/dist/language/flows/flow-journey.js +119 -0
- package/dist/language/flows/flow-replay-run.d.ts +2 -3
- package/dist/language/flows/flow-replay-run.js +13 -47
- package/dist/language/flows/flow-replay.d.ts +22 -8
- package/dist/language/flows/flow-replay.js +55 -9
- package/dist/language/flows/flow-result.d.ts +2 -0
- package/dist/language/flows/flow-result.js +25 -0
- package/dist/language/flows/flow-tools.js +17 -5
- package/dist/language/flows/flows.d.ts +10 -1
- package/dist/language/flows/flows.js +90 -14
- package/dist/language/flows/recording/replay-halt.js +3 -1
- package/dist/language/flows/recording/tape/recordings.d.ts +30 -1
- package/dist/language/flows/recording/tape/recordings.js +55 -1
- package/dist/language/flows/replay.d.ts +19 -0
- package/dist/language/flows/replay.js +42 -6
- package/dist/language/flows/verify-change-tools.js +5 -2
- package/dist/launch-chromium.d.ts +80 -0
- package/dist/launch-chromium.js +218 -0
- package/dist/memory/cloud/cloud-config.d.ts +11 -2
- package/dist/memory/cloud/cloud-config.js +47 -7
- package/dist/memory/cloud/cloud-sync.d.ts +4 -1
- package/dist/memory/cloud/cloud-sync.js +6 -9
- package/dist/memory/cloud/harness-offer.js +5 -6
- package/dist/memory/cloud/harness-switch.js +5 -6
- package/dist/memory/cloud/sync-cycle.d.ts +77 -3
- package/dist/memory/cloud/sync-cycle.js +325 -55
- package/dist/memory/cloud/sync-daemon.js +24 -20
- package/dist/memory/cloud/sync-disk.js +16 -2
- package/dist/memory/intent/intent-shard.d.ts +10 -32
- package/dist/memory/intent/intent-shard.js +0 -10
- package/dist/memory/intent/intent-tools.js +8 -3
- package/dist/memory/journal/drive-flow.d.ts +18 -13
- package/dist/memory/journal/drive-flow.js +45 -37
- package/dist/memory/journal/envelope.d.ts +8 -8
- package/dist/memory/journal/journal-query.d.ts +14 -0
- package/dist/memory/journal/journal-query.js +15 -0
- package/dist/memory/journal/on-disk/workspace-tiers.js +2 -0
- package/dist/memory/journal/session-end.d.ts +9 -1
- package/dist/memory/journal/session-end.js +24 -12
- package/dist/memory/project/artifact-root-resolver.d.ts +10 -0
- package/dist/memory/project/artifact-root-resolver.js +46 -19
- package/dist/memory/project/dir/reticle-dir.d.ts +2 -0
- package/dist/memory/project/dir/reticle-dir.js +1 -0
- package/dist/memory/project/project-tools.js +3 -1
- package/dist/portal/bridge/auth-failure-reason.d.ts +1 -1
- package/dist/portal/bridge/auth-failure-reason.js +4 -2
- package/dist/portal/bridge/bridge.d.ts +12 -3
- package/dist/portal/bridge/bridge.js +49 -3
- package/dist/portal/input/js-coverage.d.ts +25 -0
- package/dist/portal/input/js-coverage.js +30 -0
- package/dist/portal/input/real-input.d.ts +11 -0
- package/dist/portal/input/real-input.js +29 -4
- package/dist/portal/input/viewport-tools.js +16 -6
- package/dist/portal/pool/playwright-launcher.d.ts +6 -0
- package/dist/portal/pool/playwright-launcher.js +20 -13
- package/dist/portal/session/dev-server/dev-command.d.ts +2 -2
- package/dist/portal/session/dev-server/dev-command.js +30 -12
- package/dist/portal/session/dev-server/dev-server-probe.js +17 -1
- package/dist/portal/session/dev-server/route-status-probe.d.ts +24 -0
- package/dist/portal/session/dev-server/route-status-probe.js +57 -0
- package/dist/portal/session/facts/observed-state.d.ts +11 -0
- package/dist/portal/session/facts/observed-state.js +34 -0
- package/dist/portal/session/no-session-diagnosis.d.ts +29 -0
- package/dist/portal/session/no-session-diagnosis.js +62 -5
- package/dist/portal/session/no-session-next-action.d.ts +13 -0
- package/dist/portal/session/no-session-next-action.js +48 -9
- package/dist/portal/session/no-session-watch.d.ts +18 -0
- package/dist/portal/session/no-session-watch.js +88 -2
- package/dist/portal/session/session-health.js +3 -2
- package/dist/portal/session/session-manager.d.ts +20 -6
- package/dist/portal/session/session-manager.js +19 -3
- package/dist/portal/session/session-reaper.d.ts +28 -0
- package/dist/portal/session/session-reaper.js +49 -1
- package/dist/portal/session/session.d.ts +10 -8
- package/dist/portal/session/session.js +24 -32
- package/dist/surface/http-server.d.ts +3 -2
- package/dist/surface/http-server.js +8 -5
- package/dist/surface/mcp/mcp-proxy.d.ts +2 -2
- package/dist/surface/mcp/mcp-proxy.js +2 -2
- package/dist/surface/mcp/mcp.js +5 -3
- package/dist/surface/mcp/proxy/proxy-daemon-probe.d.ts +13 -1
- package/dist/surface/mcp/proxy/proxy-daemon-probe.js +27 -2
- package/dist/surface/mcp/proxy/proxy-log.js +3 -5
- package/dist/surface/mcp/server-instructions.js +9 -7
- package/dist/surface/tools/act/after-match.d.ts +17 -0
- package/dist/surface/tools/act/after-match.js +30 -0
- package/dist/surface/tools/act/durable.d.ts +69 -0
- package/dist/surface/tools/act/durable.js +139 -0
- package/dist/surface/tools/act/navigation/navigate-arrival.d.ts +13 -6
- package/dist/surface/tools/act/navigation/navigate-arrival.js +47 -10
- package/dist/surface/tools/act/navigation/navigate-result.d.ts +1 -12
- package/dist/surface/tools/act/navigation/navigate-result.js +21 -3
- package/dist/surface/tools/act/proved-controls.d.ts +9 -0
- package/dist/surface/tools/act/proved-controls.js +11 -0
- package/dist/surface/tools/act/sequence-grade.d.ts +5 -0
- package/dist/surface/tools/act/sequence-grade.js +32 -1
- package/dist/surface/tools/act-capsule.d.ts +7 -0
- package/dist/surface/tools/act-capsule.js +46 -1
- package/dist/surface/tools/act-sequence-tool.js +25 -8
- package/dist/surface/tools/act-tools.js +28 -52
- package/dist/surface/tools/assert/assert-grade.js +12 -1
- package/dist/surface/tools/assert/assert-verdict.js +2 -2
- package/dist/surface/tools/browser-tools.js +14 -2
- package/dist/surface/tools/coverage-tools.js +27 -1
- package/dist/surface/tools/dynamic-tools.js +29 -2
- package/dist/surface/tools/error-recovery.js +5 -6
- package/dist/surface/tools/feedback-invite.js +6 -4
- package/dist/surface/tools/harness-explore.d.ts +3 -2
- package/dist/surface/tools/harness-explore.js +12 -7
- package/dist/surface/tools/invoke-tool.js +12 -8
- package/dist/surface/tools/lease-tools.js +15 -6
- package/dist/surface/tools/live-call-text.js +4 -1
- package/dist/surface/tools/observe-tools.js +9 -1
- package/dist/surface/tools/tool-kit.d.ts +10 -0
- package/dist/surface/tools/tools.js +4 -0
- package/dist/telemetry/argument-shape.d.ts +0 -2
- package/dist/telemetry/argument-shape.js +1 -5
- package/dist/telemetry/error-class.d.ts +2 -3
- package/dist/telemetry/error-class.js +2 -3
- package/dist/telemetry/harness-drive.d.ts +0 -2
- package/dist/telemetry/harness-drive.js +0 -4
- package/dist/telemetry/onboarding-firsts.d.ts +2 -2
- package/dist/telemetry/onboarding-firsts.js +2 -2
- package/dist/wire-journal.d.ts +3 -0
- package/dist/wire-journal.js +4 -0
- package/dist/workspace-packages.d.ts +0 -2
- package/dist/workspace-packages.js +1 -9
- package/docs/README.md +4 -2
- package/docs/actions.mdx +3 -4
- package/docs/agent-cheatsheet.md +4 -4
- package/docs/architecture.md +6 -6
- package/docs/best-practices.mdx +1 -1
- package/docs/capabilities.mdx +32 -1
- package/docs/cli/cloud.mdx +20 -8
- package/docs/cli/doctor.mdx +4 -0
- package/docs/cli/feedback.mdx +2 -2
- package/docs/cli/gate.mdx +9 -4
- package/docs/cli/update.mdx +10 -0
- package/docs/cli.mdx +22 -7
- package/docs/desktop.mdx +14 -10
- package/docs/environment.mdx +87 -0
- package/docs/faq.mdx +18 -16
- package/docs/first-drive.md +5 -13
- package/docs/flows.md +21 -2
- package/docs/frameworks.mdx +29 -10
- package/docs/getting-started.md +15 -5
- package/docs/http-transport.md +6 -3
- package/docs/human-control.md +2 -2
- package/docs/index.mdx +16 -6
- package/docs/install-agentic.mdx +2 -2
- package/docs/install-manual.mdx +1 -1
- package/docs/integration-patterns.md +3 -3
- package/docs/multi-agent-testing.md +1 -1
- package/docs/packages/babel-plugin.mdx +1 -1
- package/docs/packages/browser.mdx +2 -2
- package/docs/packages/next.mdx +3 -0
- package/docs/packages/react.mdx +2 -2
- package/docs/packages/tauri.mdx +1 -1
- package/docs/packages/vite-plugin.mdx +4 -2
- package/docs/packages.mdx +9 -9
- package/docs/predicates.mdx +50 -5
- package/docs/quickstart.mdx +12 -10
- package/docs/recipes.mdx +2 -2
- package/docs/state-management.mdx +2 -2
- package/docs/system-map.md +1 -1
- package/docs/telemetry.md +1 -1
- package/docs/token-efficiency.md +3 -3
- package/docs/tools/act-and-wait.mdx +1 -0
- package/docs/tools/act-sequence.mdx +1 -1
- package/docs/tools/act.mdx +1 -1
- package/docs/tools/console.mdx +1 -1
- package/docs/tools/inspect.mdx +1 -1
- package/docs/tools/network.mdx +1 -1
- package/docs/tools/query.mdx +1 -1
- package/docs/tools/sessions.mdx +1 -1
- package/docs/tools/snapshot.mdx +1 -1
- package/docs/tools/state.mdx +1 -1
- package/docs/tools/wait-for.mdx +1 -1
- package/docs/usage.md +7 -7
- package/docs/use-cases.mdx +157 -0
- package/docs/vs-screenshots.mdx +3 -3
- package/docs/what-is-recorded.md +2 -2
- package/docs/what-is-reticle.mdx +17 -20
- package/docs/why-reticle.mdx +14 -21
- package/package.json +10 -9
- package/dist/judgement/capsule/minimize.d.ts +0 -12
- package/dist/judgement/capsule/minimize.js +0 -22
- package/dist/judgement/phenomena/phenomena.d.ts +0 -27
- package/dist/judgement/phenomena/phenomena.js +0 -101
- package/dist/language/flows/flow-report.d.ts +0 -22
- package/dist/language/flows/flow-report.js +0 -106
|
@@ -64,6 +64,15 @@ export function classifyPort(port, probe) {
|
|
|
64
64
|
* accepts v4-mapped connections — so between the two, every ordinary bind is covered.
|
|
65
65
|
*/
|
|
66
66
|
export const PROBE_HOSTS = ['127.0.0.1', '::1'];
|
|
67
|
+
/**
|
|
68
|
+
* The name the probe gives in its Host header, whichever address it dialled.
|
|
69
|
+
*
|
|
70
|
+
* Node names the dialled address, so the `::1` probe sent `Host: [::1]:4200`. Angular's SSR dev
|
|
71
|
+
* server validates Host, answered 400, and printed `ERROR: Bad Request ("http://[::1]:4200/")` into
|
|
72
|
+
* the user's dev terminal on every sweep, for as long as the daemon ran. The address picks the
|
|
73
|
+
* family; the header says what a browser on this machine would.
|
|
74
|
+
*/
|
|
75
|
+
const PROBE_HOST_HEADER = 'localhost';
|
|
67
76
|
/**
|
|
68
77
|
* Does this port serve a DOCUMENT — i.e. is it a dev server rather than merely something listening?
|
|
69
78
|
*
|
|
@@ -76,7 +85,14 @@ function probeState(port, host) {
|
|
|
76
85
|
// Whether the SOCKET came up is tracked separately from whether a response did, because that is
|
|
77
86
|
// the whole difference between "nothing is there" and "something is there and still compiling".
|
|
78
87
|
let connected = false;
|
|
79
|
-
const req = request({
|
|
88
|
+
const req = request({
|
|
89
|
+
host,
|
|
90
|
+
port,
|
|
91
|
+
path: '/',
|
|
92
|
+
method: 'GET',
|
|
93
|
+
timeout: HTTP_PROBE_TIMEOUT_MS,
|
|
94
|
+
headers: { host: `${PROBE_HOST_HEADER}:${String(port)}` },
|
|
95
|
+
}, (res) => {
|
|
80
96
|
const answer = looksLikeDevServer(res.statusCode ?? 0, res.headers['content-type']);
|
|
81
97
|
res.resume(); // drain, so the socket closes rather than lingering
|
|
82
98
|
resolve(answer ? PortState.SERVES_DOCUMENT : PortState.CLOSED);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What does the route a tab died on answer right now?
|
|
3
|
+
*
|
|
4
|
+
* A route that throws server-side tears the page down and the SDK never reconnects, so the daemon
|
|
5
|
+
* is left with an empty session list and the URL it last saw (#862). The URL alone cannot separate
|
|
6
|
+
* "the route 500s" from "somebody closed the tab" — one plain GET can, and the daemon is the only
|
|
7
|
+
* party placed to make it: the page is gone, the agent is inside an MCP call, and the daemon is on
|
|
8
|
+
* the same machine as the dev server.
|
|
9
|
+
*
|
|
10
|
+
* What it refuses to do, because this runs unattended in a diagnostic loop:
|
|
11
|
+
* - only loopback hostnames — the daemon is localhost-only and a diagnostic must not reach out;
|
|
12
|
+
* - only `http:` — `https:` on localhost means a self-signed certificate, and fetching it with
|
|
13
|
+
* verification off would be a posture change for a status code;
|
|
14
|
+
* - GET only, redirects not followed, the body never read — the status is the only thing that
|
|
15
|
+
* leaves the socket, and it is drained so the connection closes rather than lingers;
|
|
16
|
+
* - an error or a timeout is `undefined`, never a status. No fact is better than a wrong one.
|
|
17
|
+
*
|
|
18
|
+
* Same shape as its neighbour `dev-server-probe.ts`, which asks a port whether it serves a document; this asks
|
|
19
|
+
* one exact path what it answers.
|
|
20
|
+
*/
|
|
21
|
+
/** Short on purpose: a dev server that has not answered a route in this long is not going to. */
|
|
22
|
+
export declare const ROUTE_STATUS_TIMEOUT_MS = 2000;
|
|
23
|
+
/** The HTTP status `url` answers a GET with, or undefined when there is no answer to report. */
|
|
24
|
+
export declare function probeRouteStatus(url: string, timeoutMs?: number): Promise<number | undefined>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What does the route a tab died on answer right now?
|
|
3
|
+
*
|
|
4
|
+
* A route that throws server-side tears the page down and the SDK never reconnects, so the daemon
|
|
5
|
+
* is left with an empty session list and the URL it last saw (#862). The URL alone cannot separate
|
|
6
|
+
* "the route 500s" from "somebody closed the tab" — one plain GET can, and the daemon is the only
|
|
7
|
+
* party placed to make it: the page is gone, the agent is inside an MCP call, and the daemon is on
|
|
8
|
+
* the same machine as the dev server.
|
|
9
|
+
*
|
|
10
|
+
* What it refuses to do, because this runs unattended in a diagnostic loop:
|
|
11
|
+
* - only loopback hostnames — the daemon is localhost-only and a diagnostic must not reach out;
|
|
12
|
+
* - only `http:` — `https:` on localhost means a self-signed certificate, and fetching it with
|
|
13
|
+
* verification off would be a posture change for a status code;
|
|
14
|
+
* - GET only, redirects not followed, the body never read — the status is the only thing that
|
|
15
|
+
* leaves the socket, and it is drained so the connection closes rather than lingers;
|
|
16
|
+
* - an error or a timeout is `undefined`, never a status. No fact is better than a wrong one.
|
|
17
|
+
*
|
|
18
|
+
* Same shape as its neighbour `dev-server-probe.ts`, which asks a port whether it serves a document; this asks
|
|
19
|
+
* one exact path what it answers.
|
|
20
|
+
*/
|
|
21
|
+
import { request } from 'node:http';
|
|
22
|
+
import { isLoopbackHostname } from '@reticlehq/core';
|
|
23
|
+
/** Short on purpose: a dev server that has not answered a route in this long is not going to. */
|
|
24
|
+
export const ROUTE_STATUS_TIMEOUT_MS = 2_000;
|
|
25
|
+
const HTTP = 'http:';
|
|
26
|
+
/** The HTTP status `url` answers a GET with, or undefined when there is no answer to report. */
|
|
27
|
+
export function probeRouteStatus(url, timeoutMs = ROUTE_STATUS_TIMEOUT_MS) {
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = new URL(url);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return Promise.resolve(undefined);
|
|
34
|
+
}
|
|
35
|
+
if (parsed.protocol !== HTTP || !isLoopbackHostname(parsed.hostname)) {
|
|
36
|
+
return Promise.resolve(undefined);
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const req = request({
|
|
40
|
+
host: parsed.hostname,
|
|
41
|
+
port: parsed.port,
|
|
42
|
+
path: `${parsed.pathname}${parsed.search}`,
|
|
43
|
+
method: 'GET',
|
|
44
|
+
timeout: timeoutMs,
|
|
45
|
+
}, (res) => {
|
|
46
|
+
const status = res.statusCode;
|
|
47
|
+
res.resume(); // drain, so the socket closes rather than lingering
|
|
48
|
+
resolve(status);
|
|
49
|
+
});
|
|
50
|
+
req.once('timeout', () => {
|
|
51
|
+
req.destroy();
|
|
52
|
+
resolve(undefined);
|
|
53
|
+
});
|
|
54
|
+
req.once('error', () => resolve(undefined));
|
|
55
|
+
req.end();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -48,6 +48,8 @@ export declare class ObservedState {
|
|
|
48
48
|
actedRefs(): ReadonlySet<string>;
|
|
49
49
|
/** Every driven control's label, for matching across re-renders. */
|
|
50
50
|
actedLabels(): ReadonlySet<string>;
|
|
51
|
+
recordProvedLabel(label: string): void;
|
|
52
|
+
provedLabels(): ReadonlySet<string>;
|
|
51
53
|
/**
|
|
52
54
|
* Record bridge-side sampling as a blind spot.
|
|
53
55
|
*
|
|
@@ -58,3 +60,12 @@ export declare class ObservedState {
|
|
|
58
60
|
noteRateLimited(dropped: number): void;
|
|
59
61
|
blindSpots(): Readonly<Record<string, number>>;
|
|
60
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The snapshot-shaped labels an act reply names its control by: the testid, and `role "name"`.
|
|
65
|
+
*
|
|
66
|
+
* The TESTID first: it is the strongest identity a control has and it survives any re-render.
|
|
67
|
+
* Coverage previously matched only on `role "name"`, so a control with a testid but no accessible
|
|
68
|
+
* name — or on a stack where the act reply carried neither — was unrecognisable after a re-render,
|
|
69
|
+
* and coverage read `exercised: 0` however much work had been done.
|
|
70
|
+
*/
|
|
71
|
+
export declare function controlLabelsOf(payload: unknown): string[];
|
|
@@ -105,6 +105,18 @@ export class ObservedState {
|
|
|
105
105
|
actedLabels() {
|
|
106
106
|
return this.#actedLabels;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Controls whose action came back `verified: "yes"` on a declared consequence — the PROVED level
|
|
110
|
+
* of the coverage ledger. Same label identity as `actedLabels`, so the two compare directly.
|
|
111
|
+
*/
|
|
112
|
+
#provedLabels = new Set();
|
|
113
|
+
recordProvedLabel(label) {
|
|
114
|
+
if (label.length > 0)
|
|
115
|
+
this.#provedLabels.add(label);
|
|
116
|
+
}
|
|
117
|
+
provedLabels() {
|
|
118
|
+
return this.#provedLabels;
|
|
119
|
+
}
|
|
108
120
|
/**
|
|
109
121
|
* Record bridge-side sampling as a blind spot.
|
|
110
122
|
*
|
|
@@ -119,3 +131,25 @@ export class ObservedState {
|
|
|
119
131
|
return this.#blindSpots;
|
|
120
132
|
}
|
|
121
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The snapshot-shaped labels an act reply names its control by: the testid, and `role "name"`.
|
|
136
|
+
*
|
|
137
|
+
* The TESTID first: it is the strongest identity a control has and it survives any re-render.
|
|
138
|
+
* Coverage previously matched only on `role "name"`, so a control with a testid but no accessible
|
|
139
|
+
* name — or on a stack where the act reply carried neither — was unrecognisable after a re-render,
|
|
140
|
+
* and coverage read `exercised: 0` however much work had been done.
|
|
141
|
+
*/
|
|
142
|
+
export function controlLabelsOf(payload) {
|
|
143
|
+
if (typeof payload !== 'object' || null === payload)
|
|
144
|
+
return [];
|
|
145
|
+
const record = payload;
|
|
146
|
+
const labels = [];
|
|
147
|
+
const testid = record['testid'];
|
|
148
|
+
if ('string' === typeof testid && testid.length > 0)
|
|
149
|
+
labels.push(testid);
|
|
150
|
+
const role = record['role'];
|
|
151
|
+
const name = record['name'];
|
|
152
|
+
if ('string' === typeof role && 'string' === typeof name && role.length > 0 && name.length > 0)
|
|
153
|
+
labels.push(`${role} "${name}"`);
|
|
154
|
+
return labels;
|
|
155
|
+
}
|
|
@@ -91,6 +91,20 @@ export interface NoSessionFacts {
|
|
|
91
91
|
* already read it; the message did not.
|
|
92
92
|
*/
|
|
93
93
|
authRefused?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The bridge refused the last hello for something OTHER than its token — a protocol number out of
|
|
96
|
+
* range, or a hello that failed the wire schema outright — and nothing has connected since.
|
|
97
|
+
*
|
|
98
|
+
* The same positive evidence as `authRefused`, with a different fix. Without it the daemon had
|
|
99
|
+
* recorded the refusal and `init` still ended on "the SDK is in the page and never dialled the
|
|
100
|
+
* bridge", about a page that dialled and was turned away. `reason` follows the `cause — fix`
|
|
101
|
+
* shape the bridge writes; the page and project are what the refused hello said about itself.
|
|
102
|
+
*/
|
|
103
|
+
helloRefused?: {
|
|
104
|
+
reason: string;
|
|
105
|
+
url?: string;
|
|
106
|
+
projectId?: string;
|
|
107
|
+
};
|
|
94
108
|
/**
|
|
95
109
|
* The framework `.reticle.json` declares, when there is one.
|
|
96
110
|
*
|
|
@@ -100,6 +114,14 @@ export interface NoSessionFacts {
|
|
|
100
114
|
* hint the agent reads hours later never mentioned it.
|
|
101
115
|
*/
|
|
102
116
|
framework?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The project is a desktop shell (Electron, Tauri), read from the project the way `doctor` reads it.
|
|
119
|
+
*
|
|
120
|
+
* Its page exists only inside its own window, so every "open the app's URL in a browser" and
|
|
121
|
+
* every lease offer below is the wrong move there: it loads the renderer without the shell's IPC
|
|
122
|
+
* bridge or native APIs, which is not the app being verified. Absent means web.
|
|
123
|
+
*/
|
|
124
|
+
desktop?: boolean;
|
|
103
125
|
/**
|
|
104
126
|
* `.reticle.json` files found OUTSIDE this daemon's directory — a workspace app, a repo root.
|
|
105
127
|
*
|
|
@@ -144,6 +166,13 @@ export interface NoSessionFacts {
|
|
|
144
166
|
* or the ring has forgotten — inventing a URL is worse than the silence this exists to end.
|
|
145
167
|
*/
|
|
146
168
|
lastKnownUrl?: string;
|
|
169
|
+
/**
|
|
170
|
+
* What a plain GET of `lastKnownUrl` answered, done out of band by the watch after the session
|
|
171
|
+
* went. The one fact that separates a server error from a closed tab and from an install
|
|
172
|
+
* problem (#808, option 3). Present only when the fetch got an HTTP status back — a failed or
|
|
173
|
+
* timed-out fetch is no fact, and this stays absent rather than guessing.
|
|
174
|
+
*/
|
|
175
|
+
lastKnownStatus?: number;
|
|
147
176
|
}
|
|
148
177
|
/**
|
|
149
178
|
* Every branch ends with this, and `recoveryFor` keys on it to suppress the generic no-session
|
|
@@ -17,6 +17,10 @@ import { DEV_SERVER_PORTS } from '../../command/cli/ports/resolve/cli-port.js';
|
|
|
17
17
|
import { siblingListenerNote } from '../../command/cli/ports/sibling-ports.js';
|
|
18
18
|
import { STALL_AFTER_MS } from './stall-clock.js';
|
|
19
19
|
import { pageTornDownWhileOn } from '@reticlehq/engine/evidence/page-teardown.js';
|
|
20
|
+
/** How every hello-refusal reason the bridge records separates its cause from its fix. */
|
|
21
|
+
const CAUSE_FIX_SEPARATOR = ' — ';
|
|
22
|
+
/** The lowest HTTP status that means the server itself failed to answer the route. */
|
|
23
|
+
const SERVER_ERROR_FLOOR = 500;
|
|
20
24
|
/** The one framework whose most likely cause differs from every other framework's. */
|
|
21
25
|
const NUXT = 'nuxt';
|
|
22
26
|
/**
|
|
@@ -49,6 +53,8 @@ const URL_THEN_LEASE = 'Once you have that URL, open it with reticle_lease {acti
|
|
|
49
53
|
* diagnosed the problem.
|
|
50
54
|
*/
|
|
51
55
|
function leaseAdvice(base, facts) {
|
|
56
|
+
if (true === facts.desktop)
|
|
57
|
+
return DESKTOP_NO_BROWSER;
|
|
52
58
|
const caveat = leaseCaveat(facts.leaseBrowser);
|
|
53
59
|
return caveat === undefined ? base : `${base} ${caveat}`;
|
|
54
60
|
}
|
|
@@ -180,6 +186,25 @@ function slowListenerClause(facts) {
|
|
|
180
186
|
const OPEN_THE_APP = 'Reticle only ever sees a page that is LOADED, so the commonest cause by a distance is that no ' +
|
|
181
187
|
`browser has opened the app yet: run ${OPEN_CMD} with the app's own URL (or ask the ` +
|
|
182
188
|
'human to open it).';
|
|
189
|
+
/**
|
|
190
|
+
* The desktop twin of OPEN_THE_APP. A desktop app's page exists only inside its own window, and the
|
|
191
|
+
* guidance used to send an Electron user to a browser URL — which reaches the renderer's dev server
|
|
192
|
+
* and none of the app around it.
|
|
193
|
+
*/
|
|
194
|
+
const DESKTOP_OPEN_THE_APP = 'This is a desktop app, and Reticle sees it only from inside its own window, so the commonest ' +
|
|
195
|
+
'cause by a distance is that the desktop app is not running: start it yourself, in the ' +
|
|
196
|
+
"background, with the project's desktop dev command (the script that runs `tauri dev`, " +
|
|
197
|
+
'`electron-vite dev`, `electron-forge start` or `electron .`), not the plain web dev server.';
|
|
198
|
+
/** Why the browser and lease routes are withheld for a desktop app. Replaces the lease offer. */
|
|
199
|
+
const DESKTOP_NO_BROWSER = 'Do not open its URL in a browser or with a lease: that loads the renderer outside the desktop ' +
|
|
200
|
+
'shell, without its IPC bridge or native APIs, so it is not the app you are verifying.';
|
|
201
|
+
function openTheApp(facts) {
|
|
202
|
+
return true === facts.desktop ? DESKTOP_OPEN_THE_APP : OPEN_THE_APP;
|
|
203
|
+
}
|
|
204
|
+
/** The "(or run open)" aside — a desktop window is reopened by the app, not by a browser command. */
|
|
205
|
+
function orOpenCommand(facts) {
|
|
206
|
+
return true === facts.desktop ? '' : ` (or run ${OPEN_CMD_BARE})`;
|
|
207
|
+
}
|
|
183
208
|
/**
|
|
184
209
|
* What a machine-wide port scan can and cannot say.
|
|
185
210
|
*
|
|
@@ -334,6 +359,22 @@ export function explainNoSession(facts) {
|
|
|
334
359
|
'while the dev server runs from a shell — they can be reading different `~/.reticle` ' +
|
|
335
360
|
'directories instead. The page says the same thing in the browser console.');
|
|
336
361
|
}
|
|
362
|
+
// Beside the token refusal and for the same reason: a turned-away hello is current, positive
|
|
363
|
+
// evidence, and every branch below reasons from an absence.
|
|
364
|
+
if (facts.helloRefused !== undefined) {
|
|
365
|
+
const { reason: said, url, projectId } = facts.helloRefused;
|
|
366
|
+
const split = said.indexOf(CAUSE_FIX_SEPARATOR);
|
|
367
|
+
const cause = -1 === split ? said : said.slice(0, split);
|
|
368
|
+
const fix = -1 === split ? undefined : said.slice(split + CAUSE_FIX_SEPARATOR.length);
|
|
369
|
+
const page = undefined === url || '' === url ? 'a page' : `the page at ${url}`;
|
|
370
|
+
const project = undefined === projectId ? '' : ` (project ${projectId})`;
|
|
371
|
+
return reason(
|
|
372
|
+
// ponytail: shares the token refusal's code, because a new code is a telemetry wire change
|
|
373
|
+
// and that surface has its own owner; split it out as `hello_refused` there.
|
|
374
|
+
NoSessionReason.AUTH_REFUSED, `no browser session connected: ${page}${project} dialled this daemon and was REFUSED ` +
|
|
375
|
+
`because ${cause}${undefined === fix ? '' : `; fix: ${fix}`}. Only an SDK dials the ` +
|
|
376
|
+
'bridge, so the app is running and instrumented — do not go looking for a stopped dev server.');
|
|
377
|
+
}
|
|
337
378
|
if (everConnected) {
|
|
338
379
|
// A reaped lease first, because it is the one cause with POSITIVE evidence behind it. Calling
|
|
339
380
|
// it "the tab was closed, ask the human to reopen the app" is wrong on every clause (#157):
|
|
@@ -347,9 +388,25 @@ export function explainNoSession(facts) {
|
|
|
347
388
|
`with reticle_lease {action:"acquire", url} and carry on. ${RETRY}`, 'A lease is a headless context, not a human tab, and it takes its cookies with it, so an ' +
|
|
348
389
|
`authenticated app needs signing in again.${alreadyListeningClause(listening)}`);
|
|
349
390
|
}
|
|
391
|
+
// Ranked above TAB_GONE because it is not an absence: the route itself answered. A tab that a
|
|
392
|
+
// 5xx tore down and a tab a human closed produce the same empty list, and until the watch asked
|
|
393
|
+
// the route, they produced the same sentence. Present tense throughout — "answers ... right
|
|
394
|
+
// now" — because a 500 now does not prove the teardown was a 500 then, and saying so would
|
|
395
|
+
// turn an observation into a story.
|
|
396
|
+
if (facts.lastKnownStatus !== undefined &&
|
|
397
|
+
facts.lastKnownStatus >= SERVER_ERROR_FLOOR &&
|
|
398
|
+
facts.lastKnownUrl !== undefined &&
|
|
399
|
+
'' !== facts.lastKnownUrl) {
|
|
400
|
+
return reason(NoSessionReason.ROUTE_SERVER_ERROR, 'no browser session connected, but one WAS connected to this daemon earlier, so the wiring ' +
|
|
401
|
+
`is correct. The page was torn down while on ${facts.lastKnownUrl}, and that route answers ` +
|
|
402
|
+
`HTTP ${String(facts.lastKnownStatus)} right now — a server error in the app, not a closed ` +
|
|
403
|
+
'tab and not an install problem. A route that throws server-side tears the page down and ' +
|
|
404
|
+
'the SDK cannot reconnect to it. Fix the route, then reload the tab' +
|
|
405
|
+
`${orOpenCommand(facts)}.${alreadyListeningClause(listening)} ${RETRY}`);
|
|
406
|
+
}
|
|
350
407
|
return reason(NoSessionReason.TAB_GONE, 'no browser session connected, but one WAS connected to this daemon earlier, so the wiring ' +
|
|
351
408
|
`is correct. ${tabGoneWhat(facts.lastKnownUrl)} Ask the human to reopen ` +
|
|
352
|
-
`the app
|
|
409
|
+
`the app${orOpenCommand(facts)}, or reload the tab. ${leaseAdvice(SELF_SERVE, facts)} ${RETRY}`, alreadyListeningClause(listening).trim());
|
|
353
410
|
}
|
|
354
411
|
// Ranked ahead of every "we have never seen one" branch below, because it is the one fact that
|
|
355
412
|
// OUTRANKS them: those branches all reason from an absence, and this reasons from a recorded
|
|
@@ -360,14 +417,14 @@ export function explainNoSession(facts) {
|
|
|
360
417
|
? `${unattributedListeners(listening)} If the dev server is not running, start it first ` +
|
|
361
418
|
'(the command is in `next_action`).'
|
|
362
419
|
: unattributedListeners(listening);
|
|
363
|
-
return reason(NoSessionReason.APP_NOT_REOPENED, `${RESTARTED_LEAD} ${
|
|
420
|
+
return reason(NoSessionReason.APP_NOT_REOPENED, `${RESTARTED_LEAD} ${openTheApp(facts)} ${leaseAdvice(SELF_SERVE, facts)} ${RETRY}`, `${DO_NOT_REINSTALL} ${listeners} ${rankedCauses(facts)}`);
|
|
364
421
|
}
|
|
365
422
|
// A config found elsewhere outranks every "you may have no SDK" branch below: those reason from
|
|
366
423
|
// an absence in ONE directory, and this is a file we read in another. Ranked here so the reader is
|
|
367
424
|
// never sent through an install on a project that has demonstrably been installed.
|
|
368
425
|
if (!initialized && (facts.configsElsewhere ?? []).length > 0) {
|
|
369
426
|
return reason(NoSessionReason.CONFIG_ELSEWHERE, 'no browser session connected, and this daemon has never seen one. ' +
|
|
370
|
-
`${configsElsewhereClause(facts)} ${
|
|
427
|
+
`${configsElsewhereClause(facts)} ${openTheApp(facts)} ${leaseAdvice(SELF_SERVE, facts)} ${RETRY}`, 'This daemon was started somewhere that is not the project, which is the normal outcome when ' +
|
|
371
428
|
`an editor launches it from your home directory. ${unattributedListeners(listening)} ` +
|
|
372
429
|
`${rankedCauses(facts)}`);
|
|
373
430
|
}
|
|
@@ -399,7 +456,7 @@ export function explainNoSession(facts) {
|
|
|
399
456
|
'the Vite or Babel plugin carries the SDK without that file at all.' +
|
|
400
457
|
`${searchedClause(facts)}${siblingListenerClause(facts)} ${leaseAdvice(URL_THEN_LEASE, facts)}`);
|
|
401
458
|
}
|
|
402
|
-
return reason(NoSessionReason.NO_LISTENER, `${stallClause(facts)}no browser session connected, and this daemon has never seen one. ${
|
|
459
|
+
return reason(NoSessionReason.NO_LISTENER, `${stallClause(facts)}no browser session connected, and this daemon has never seen one. ${openTheApp(facts)} ` +
|
|
403
460
|
'Nothing is listening on the ports Reticle scans either, and the usual reason is a dev ' +
|
|
404
461
|
'server that is not running: start it yourself in the background with the command in ' +
|
|
405
462
|
'`next_action`, tell the human in one line that it is running, then open the app in a ' +
|
|
@@ -428,7 +485,7 @@ export function explainNoSession(facts) {
|
|
|
428
485
|
`plugin. ${unattributedListeners(listening)}${searchedClause(facts)}${siblingListenerClause(facts)}`);
|
|
429
486
|
}
|
|
430
487
|
return reason(NoSessionReason.SDK_NOT_REACHING_DAEMON, `${stallClause(facts)}no browser session connected, and this daemon has never seen one for this project, which is ` +
|
|
431
|
-
`wired for Reticle. ${
|
|
488
|
+
`wired for Reticle. ${openTheApp(facts)} If the page IS open and still does not appear, the SDK ` +
|
|
432
489
|
`is not reaching this daemon (on ${String(port)}). ${leaseAdvice(SELF_SERVE, facts)} ${RETRY}`, `${unattributedListeners(listening)} ${rankedCauses(facts)}`);
|
|
433
490
|
}
|
|
434
491
|
/**
|
|
@@ -69,6 +69,19 @@ interface NextActionFacts {
|
|
|
69
69
|
* action that cannot help and can overwrite it.
|
|
70
70
|
*/
|
|
71
71
|
authRefused?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The bridge refused the last hello for a non-token reason (protocol or wire-contract skew), in
|
|
74
|
+
* the bridge's own `cause — fix` sentence. Current, like `authRefused`: nothing connected since.
|
|
75
|
+
* Every other action below would send the agent to start, open or re-wire an app that is running,
|
|
76
|
+
* instrumented and being turned away.
|
|
77
|
+
*/
|
|
78
|
+
helloRefused?: string;
|
|
79
|
+
/**
|
|
80
|
+
* The url the session that went away was on, from the daemon's own tombstone. Positive evidence
|
|
81
|
+
* about where THIS project's app lives, which the port scan is not: the scan is machine-wide, and
|
|
82
|
+
* its one hit is as likely to be another repo's dev server as this one's.
|
|
83
|
+
*/
|
|
84
|
+
lastKnownUrl?: string;
|
|
72
85
|
}
|
|
73
86
|
export declare function nextActionFor(facts: NextActionFacts): NoSessionNextAction;
|
|
74
87
|
/** The same action as one sentence, for the prose message the human reads. */
|
|
@@ -12,7 +12,29 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Pure. The facts arrive from the watch; nothing here touches the disk or the clock.
|
|
14
14
|
*/
|
|
15
|
-
import { NoSessionAction, ReticleEnv } from '@reticlehq/core';
|
|
15
|
+
import { NoSessionAction, RETICLE_URL_PARAM, ReticleEnv } from '@reticlehq/core';
|
|
16
|
+
/**
|
|
17
|
+
* The departed session's url as a human would type it: the params a Reticle launcher stamps on a
|
|
18
|
+
* lease are stripped, because reopening WITH them would adopt the dead lease's identity. Undefined
|
|
19
|
+
* for a url that does not parse, or one with no port to name (a desktop webview's opaque origin).
|
|
20
|
+
*/
|
|
21
|
+
function reopenableUrl(raw) {
|
|
22
|
+
if (raw === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
let url;
|
|
25
|
+
try {
|
|
26
|
+
url = new URL(raw);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if ('http:' !== url.protocol && 'https:' !== url.protocol)
|
|
32
|
+
return undefined;
|
|
33
|
+
for (const param of Object.values(RETICLE_URL_PARAM))
|
|
34
|
+
url.searchParams.delete(param);
|
|
35
|
+
const port = '' === url.port ? ('https:' === url.protocol ? 443 : 80) : Number(url.port);
|
|
36
|
+
return { url: url.toString(), port };
|
|
37
|
+
}
|
|
16
38
|
/** `reticle init`, the only command here that is Reticle's own and so cannot be wrong. */
|
|
17
39
|
const INIT_COMMAND = 'reticle init';
|
|
18
40
|
const OPEN_COMMAND = 'reticle open';
|
|
@@ -28,6 +50,13 @@ export function nextActionFor(facts) {
|
|
|
28
50
|
if (splitBrain !== undefined) {
|
|
29
51
|
return { action: NoSessionAction.DAEMON_SPLIT, reason: splitBrain };
|
|
30
52
|
}
|
|
53
|
+
if (facts.helloRefused !== undefined) {
|
|
54
|
+
return {
|
|
55
|
+
action: NoSessionAction.OPEN_APP,
|
|
56
|
+
reason: `a page dialled this daemon and was refused (${facts.helloRefused}); do that, then reload ` +
|
|
57
|
+
'the page — the SDK does not retry after a refusal.',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
31
60
|
// `authRefused` is checked here and not only further down, because this branch short-circuits.
|
|
32
61
|
//
|
|
33
62
|
// Both refusal branches below were already written and already right, and neither could be
|
|
@@ -44,16 +73,24 @@ export function nextActionFor(facts) {
|
|
|
44
73
|
if (facts.everConnected && true !== facts.authRefused) {
|
|
45
74
|
const listening = facts.listening;
|
|
46
75
|
const only = 1 === listening.length ? listening[0] : undefined;
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
// The departed session's own url first: it is where this project's app demonstrably was, while
|
|
77
|
+
// a lone port from the scan may belong to anybody.
|
|
78
|
+
const known = reopenableUrl(facts.lastKnownUrl);
|
|
79
|
+
const bound = known !== undefined
|
|
80
|
+
? ` It was last on ${known.url}; reopen that — do not start a second stack.`
|
|
81
|
+
: 0 === listening.length
|
|
82
|
+
? ''
|
|
83
|
+
: only === undefined
|
|
84
|
+
? ` An app is already listening on ${listening.join(', ')}; just open the URL the human names — do not start a second stack.`
|
|
85
|
+
: ` An app is already listening on ${String(only)}; just open ${LOCALHOST}:${String(only)} — do not start a second stack.`;
|
|
86
|
+
const target = known !== undefined
|
|
87
|
+
? { command: `${OPEN_COMMAND} ${known.url}`, port: known.port }
|
|
49
88
|
: only === undefined
|
|
50
|
-
?
|
|
51
|
-
:
|
|
89
|
+
? {}
|
|
90
|
+
: { command: `${OPEN_COMMAND} ${LOCALHOST}:${String(only)}`, port: only };
|
|
52
91
|
return {
|
|
53
92
|
action: NoSessionAction.REOPEN_APP,
|
|
54
|
-
...
|
|
55
|
-
? {}
|
|
56
|
-
: { command: `${OPEN_COMMAND} ${LOCALHOST}:${String(only)}`, port: only }),
|
|
93
|
+
...target,
|
|
57
94
|
reason: 'a session was connected to this daemon earlier, so the wiring is correct — the tab was ' +
|
|
58
95
|
'closed, reloaded, or the lease aged out. Reopen the app, or take one you own with ' +
|
|
59
96
|
'reticle_lease {action:"acquire", url}.' +
|
|
@@ -108,7 +145,9 @@ export function nextActionFor(facts) {
|
|
|
108
145
|
// does not cover, it reported the app was not running.
|
|
109
146
|
reason: 'nothing is listening on the ports Reticle scans, so the app is probably not running — ' +
|
|
110
147
|
'though that scan is narrow, so if it IS up on another port, ask for its URL instead of ' +
|
|
111
|
-
`starting a second one. This is the project's own
|
|
148
|
+
`starting a second one. This is the project's own ` +
|
|
149
|
+
(undefined === dev.script ? 'launcher' : `\`${dev.script}\` script`) +
|
|
150
|
+
` — run it in the ` +
|
|
112
151
|
'background, tell the human it is running, then call reticle_sessions again.',
|
|
113
152
|
};
|
|
114
153
|
}
|
|
@@ -45,6 +45,24 @@ interface NoSessionWatchOptions {
|
|
|
45
45
|
* Omitted on a daemon with no pool, and auto-attach is then simply off.
|
|
46
46
|
*/
|
|
47
47
|
attach?: (url: string) => Promise<unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* The ports THIS project's dev servers announced into the registry the build plugins write.
|
|
50
|
+
*
|
|
51
|
+
* Auto-attach opens a port only when it can be attributed to this project. The port scan is
|
|
52
|
+
* machine-wide, so its one hit is as likely to be another repo's app as this one's — and now that
|
|
53
|
+
* the attach path can launch an installed Chrome, a wrong guess parks a hidden headless browser on
|
|
54
|
+
* somebody else's app. Injected for tests; production reads the registry scoped by projectId/root.
|
|
55
|
+
*/
|
|
56
|
+
ownDevServerPorts?: () => readonly number[];
|
|
57
|
+
/**
|
|
58
|
+
* What the route the last session was on answers right now, as an HTTP status, or undefined
|
|
59
|
+
* when there is no answer to report.
|
|
60
|
+
*
|
|
61
|
+
* Injected so tests can pin the observation without opening a socket. Production (no override)
|
|
62
|
+
* asks the route itself — see route-status-probe. The one fact that separates a route that 500s
|
|
63
|
+
* from a closed tab (#808, option 3).
|
|
64
|
+
*/
|
|
65
|
+
routeStatus?: (url: string) => Promise<number | undefined>;
|
|
48
66
|
/**
|
|
49
67
|
* Where the durable "an app has connected here before" bit lives. The daemon's state home unless
|
|
50
68
|
* a test says otherwise.
|