@phnx-labs/agents-cli 1.22.46 → 1.22.49
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/CHANGELOG.md +663 -0
- package/LICENSE +102 -182
- package/README.md +96 -49
- package/dist/bootstrap.js +4 -2
- package/dist/cli/command-registry.d.ts +2 -1
- package/dist/cli/command-registry.js +6 -2
- package/dist/commands/accounts.d.ts +58 -0
- package/dist/commands/accounts.js +243 -25
- package/dist/commands/artifacts.js +7 -6
- package/dist/commands/attach.js +1 -1
- package/dist/commands/auth.js +7 -5
- package/dist/commands/browser-sessions-picker.js +9 -7
- package/dist/commands/browser.js +711 -62
- package/dist/commands/config.d.ts +0 -1
- package/dist/commands/config.js +26 -24
- package/dist/commands/cost.d.ts +1 -1
- package/dist/commands/daemon.d.ts +21 -0
- package/dist/commands/daemon.js +147 -12
- package/dist/commands/detach.d.ts +13 -0
- package/dist/commands/detach.js +11 -8
- package/dist/commands/exec.js +107 -53
- package/dist/commands/feed-watch.d.ts +2 -0
- package/dist/commands/feed-watch.js +28 -0
- package/dist/commands/feed.js +27 -0
- package/dist/commands/feedback.js +3 -19
- package/dist/commands/focus.d.ts +14 -0
- package/dist/commands/focus.js +48 -5
- package/dist/commands/go.d.ts +3 -0
- package/dist/commands/go.js +16 -3
- package/dist/commands/insights.d.ts +1 -1
- package/dist/commands/insights.js +2 -2
- package/dist/commands/inspect.js +2 -2
- package/dist/commands/lease.d.ts +1 -1
- package/dist/commands/lease.js +7 -6
- package/dist/commands/mailboxes.js +4 -3
- package/dist/commands/menubar.js +11 -4
- package/dist/commands/projects.d.ts +16 -1
- package/dist/commands/projects.js +58 -64
- package/dist/commands/resume.js +1 -1
- package/dist/commands/route.js +4 -4
- package/dist/commands/routines.js +4 -3
- package/dist/commands/run-broadcast.d.ts +1 -1
- package/dist/commands/run-broadcast.js +1 -1
- package/dist/commands/sessions-picker-factory.d.ts +2 -1
- package/dist/commands/sessions-picker-factory.js +1 -1
- package/dist/commands/sessions-picker.d.ts +22 -0
- package/dist/commands/sessions-picker.js +48 -9
- package/dist/commands/sessions-stop.d.ts +24 -0
- package/dist/commands/sessions-stop.js +66 -0
- package/dist/commands/sessions-trace.d.ts +82 -0
- package/dist/commands/sessions-trace.js +387 -0
- package/dist/commands/sessions.js +5 -0
- package/dist/commands/setup-secrets.js +23 -0
- package/dist/commands/share.d.ts +20 -5
- package/dist/commands/share.js +152 -52
- package/dist/commands/ssh.d.ts +15 -0
- package/dist/commands/ssh.js +243 -18
- package/dist/commands/teams.js +34 -2
- package/dist/commands/traces.d.ts +2 -0
- package/dist/commands/traces.js +184 -0
- package/dist/commands/view.d.ts +2 -0
- package/dist/commands/view.js +32 -62
- package/dist/commands/watchdog.js +9 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/account-capabilities.d.ts +4 -0
- package/dist/lib/account-capabilities.js +13 -9
- package/dist/lib/account-registry.d.ts +2 -0
- package/dist/lib/account-registry.js +30 -2
- package/dist/lib/accounting/rotate.d.ts +9 -0
- package/dist/lib/accounting/rotate.js +12 -2
- package/dist/lib/accounting/usage.d.ts +84 -6
- package/dist/lib/accounting/usage.js +293 -75
- package/dist/lib/agent-modes.js +29 -1
- package/dist/lib/agent-spec/agents.d.ts +4 -3
- package/dist/lib/agent-spec/agents.js +25 -15
- package/dist/lib/analytics/mix-commands.d.ts +1 -1
- package/dist/lib/analytics/mix-commands.js +2 -2
- package/dist/lib/auth-health.d.ts +13 -3
- package/dist/lib/auth-health.js +50 -8
- package/dist/lib/browser/devices.d.ts +19 -0
- package/dist/lib/browser/devices.js +23 -0
- package/dist/lib/browser/drivers/ssh.d.ts +16 -2
- package/dist/lib/browser/drivers/ssh.js +36 -9
- package/dist/lib/browser/ipc.d.ts +1 -1
- package/dist/lib/browser/ipc.js +40 -9
- package/dist/lib/browser/profiles.d.ts +104 -65
- package/dist/lib/browser/profiles.js +277 -165
- package/dist/lib/browser/registry.d.ts +39 -0
- package/dist/lib/browser/registry.js +149 -0
- package/dist/lib/browser/remote-control.d.ts +28 -2
- package/dist/lib/browser/remote-control.js +35 -3
- package/dist/lib/browser/resolve-target.d.ts +68 -0
- package/dist/lib/browser/resolve-target.js +250 -0
- package/dist/lib/browser/runtime-state.d.ts +44 -11
- package/dist/lib/browser/runtime-state.js +98 -15
- package/dist/lib/browser/service.d.ts +65 -9
- package/dist/lib/browser/service.js +196 -61
- package/dist/lib/browser/sessions-list.d.ts +1 -3
- package/dist/lib/browser/sessions-list.js +3 -16
- package/dist/lib/browser/task-index.d.ts +70 -0
- package/dist/lib/browser/task-index.js +180 -0
- package/dist/lib/browser/types.d.ts +12 -1
- package/dist/lib/byok-usage.js +2 -2
- package/dist/lib/claude-statusline.d.ts +29 -0
- package/dist/lib/claude-statusline.js +139 -0
- package/dist/lib/cloud/host.d.ts +1 -1
- package/dist/lib/cloud/host.js +1 -1
- package/dist/lib/cloud/rush.js +1 -1
- package/dist/lib/codex-policy.d.ts +11 -1
- package/dist/lib/codex-policy.js +20 -5
- package/dist/lib/computer/computer-rpc.js +2 -2
- package/dist/lib/computer/download.d.ts +15 -15
- package/dist/lib/computer/download.js +35 -98
- package/dist/lib/computer/ssh-tunnel.d.ts +0 -3
- package/dist/lib/computer/ssh-tunnel.js +12 -22
- package/dist/lib/config-keys.d.ts +6 -11
- package/dist/lib/config-keys.js +18 -19
- package/dist/lib/crabbox/cli.d.ts +1 -1
- package/dist/lib/crabbox/cli.js +2 -2
- package/dist/lib/crabbox/lease.d.ts +9 -0
- package/dist/lib/crabbox/lease.js +70 -15
- package/dist/lib/crabbox/runtimes.js +1 -1
- package/dist/lib/daemon/account-state-daemon-service.d.ts +16 -0
- package/dist/lib/daemon/account-state-daemon-service.js +26 -0
- package/dist/lib/daemon/browser-ipc-service.d.ts +20 -0
- package/dist/lib/daemon/browser-ipc-service.js +46 -0
- package/dist/lib/daemon/daemon.d.ts +3 -0
- package/dist/lib/daemon/daemon.js +212 -444
- package/dist/lib/daemon/device-probe-service.d.ts +26 -0
- package/dist/lib/daemon/device-probe-service.js +47 -0
- package/dist/lib/daemon/keychain-reap-service.d.ts +17 -0
- package/dist/lib/daemon/keychain-reap-service.js +32 -0
- package/dist/lib/daemon/monitor-engine-service.d.ts +22 -0
- package/dist/lib/daemon/monitor-engine-service.js +29 -0
- package/dist/lib/daemon/runner.js +15 -2
- package/dist/lib/daemon/secrets-broker-service.d.ts +20 -0
- package/dist/lib/daemon/secrets-broker-service.js +66 -0
- package/dist/lib/daemon/self-heal-service.d.ts +27 -0
- package/dist/lib/daemon/self-heal-service.js +48 -0
- package/dist/lib/daemon/service.d.ts +102 -0
- package/dist/lib/daemon/service.js +98 -0
- package/dist/lib/daemon/session-index-service.d.ts +22 -0
- package/dist/lib/daemon/session-index-service.js +40 -0
- package/dist/lib/daemon/state-dir-check-service.d.ts +43 -0
- package/dist/lib/daemon/state-dir-check-service.js +63 -0
- package/dist/lib/daemon/supervisor.d.ts +87 -0
- package/dist/lib/daemon/supervisor.js +298 -0
- package/dist/lib/daemon/watchdog-service.d.ts +19 -0
- package/dist/lib/daemon/watchdog-service.js +40 -0
- package/dist/lib/daemon-health.d.ts +15 -0
- package/dist/lib/daemon-health.js +29 -5
- package/dist/lib/daemon-services.d.ts +8 -1
- package/dist/lib/daemon-services.js +55 -0
- package/dist/lib/daemon-ticks.d.ts +13 -2
- package/dist/lib/daemon-ticks.js +22 -20
- package/dist/lib/device-config.d.ts +25 -10
- package/dist/lib/device-config.js +90 -39
- package/dist/lib/devices/config-migration.d.ts +7 -0
- package/dist/lib/devices/config-migration.js +67 -3
- package/dist/lib/devices/health.d.ts +27 -2
- package/dist/lib/devices/health.js +39 -9
- package/dist/lib/devices/interactive-host.d.ts +15 -0
- package/dist/lib/devices/interactive-host.js +53 -0
- package/dist/lib/devices/registry.d.ts +61 -4
- package/dist/lib/devices/registry.js +94 -38
- package/dist/lib/devices/stats-cache.d.ts +26 -0
- package/dist/lib/devices/stats-cache.js +59 -7
- package/dist/lib/devices/worker-pick.d.ts +48 -0
- package/dist/lib/devices/worker-pick.js +113 -0
- package/dist/lib/exec.d.ts +70 -14
- package/dist/lib/exec.js +110 -38
- package/dist/lib/feed/answer.d.ts +29 -0
- package/dist/lib/feed/answer.js +145 -0
- package/dist/lib/feed/attention.d.ts +83 -0
- package/dist/lib/feed/attention.js +0 -0
- package/dist/lib/feed/feed.d.ts +109 -0
- package/dist/lib/feed/feed.js +154 -3
- package/dist/lib/feed/pr-status.d.ts +14 -0
- package/dist/lib/feed/pr-status.js +47 -0
- package/dist/lib/feed/watch.d.ts +59 -0
- package/dist/lib/feed/watch.js +180 -0
- package/dist/lib/fleet/capture.js +6 -0
- package/dist/lib/fleet/remote-login.js +8 -3
- package/dist/lib/fleet/types.d.ts +17 -0
- package/dist/lib/harness/adapter.d.ts +11 -0
- package/dist/lib/harness/adapters/claude.js +38 -24
- package/dist/lib/harness/adapters/codex.js +2 -4
- package/dist/lib/harness/adapters/cursor.js +8 -11
- package/dist/lib/helper-download.d.ts +108 -0
- package/dist/lib/helper-download.js +194 -0
- package/dist/lib/helper-versions.d.ts +52 -0
- package/dist/lib/helper-versions.js +58 -0
- package/dist/lib/hooks/cache.js +19 -0
- package/dist/lib/hooks/install.js +2 -2
- package/dist/lib/hooks/match.d.ts +3 -0
- package/dist/lib/hooks/match.js +25 -0
- package/dist/lib/hosts/credentials.d.ts +1 -1
- package/dist/lib/hosts/credentials.js +1 -1
- package/dist/lib/hosts/dispatch.d.ts +7 -1
- package/dist/lib/hosts/dispatch.js +24 -5
- package/dist/lib/hosts/passthrough.d.ts +8 -15
- package/dist/lib/hosts/passthrough.js +35 -16
- package/dist/lib/hosts/providers/devices.d.ts +1 -1
- package/dist/lib/hosts/providers/devices.js +1 -1
- package/dist/lib/hosts/reconnect.d.ts +179 -21
- package/dist/lib/hosts/reconnect.js +266 -45
- package/dist/lib/hosts/registry.js +7 -0
- package/dist/lib/installations/migrate.d.ts +4 -5
- package/dist/lib/installations/migrate.js +6 -7
- package/dist/lib/installations/shims.d.ts +1 -1
- package/dist/lib/installations/shims.js +23 -13
- package/dist/lib/installations/versions.js +25 -2
- package/dist/lib/linear-autoclose.d.ts +1 -1
- package/dist/lib/linear-autoclose.js +1 -1
- package/dist/lib/loop.d.ts +2 -2
- package/dist/lib/loop.js +1 -1
- package/dist/lib/menubar/download-menubar.d.ts +47 -0
- package/dist/lib/menubar/download-menubar.js +60 -0
- package/dist/lib/menubar/install-menubar.d.ts +44 -7
- package/dist/lib/menubar/install-menubar.js +105 -23
- package/dist/lib/menubar/notify-desktop.d.ts +3 -3
- package/dist/lib/menubar/notify-desktop.js +6 -6
- package/dist/lib/model-tiers.d.ts +1 -1
- package/dist/lib/open-url.d.ts +60 -2
- package/dist/lib/open-url.js +167 -12
- package/dist/lib/project-probe.d.ts +1 -1
- package/dist/lib/project-probe.js +1 -1
- package/dist/lib/project-pull.d.ts +1 -1
- package/dist/lib/project-pull.js +2 -2
- package/dist/lib/projects.d.ts +1 -1
- package/dist/lib/projects.js +1 -1
- package/dist/lib/refresh-coordinator.d.ts +1 -1
- package/dist/lib/refresh-coordinator.js +1 -1
- package/dist/lib/sandbox.js +6 -7
- package/dist/lib/secrets/download-keychain.d.ts +47 -0
- package/dist/lib/secrets/download-keychain.js +70 -0
- package/dist/lib/secrets/install-helper.d.ts +20 -1
- package/dist/lib/secrets/install-helper.js +44 -3
- package/dist/lib/session/active.d.ts +67 -0
- package/dist/lib/session/active.js +86 -2
- package/dist/lib/session/db.d.ts +11 -1
- package/dist/lib/session/db.js +142 -8
- package/dist/lib/session/discover.d.ts +23 -1
- package/dist/lib/session/discover.js +44 -10
- package/dist/lib/session/highlights.d.ts +49 -1
- package/dist/lib/session/highlights.js +95 -0
- package/dist/lib/session/host-link.d.ts +16 -2
- package/dist/lib/session/host-link.js +7 -1
- package/dist/lib/session/parse.js +33 -1
- package/dist/lib/session/prompt.d.ts +35 -0
- package/dist/lib/session/prompt.js +56 -0
- package/dist/lib/session/remote/remote-list.d.ts +9 -0
- package/dist/lib/session/remote/remote-list.js +19 -2
- package/dist/lib/session/remote/watch.d.ts +1 -1
- package/dist/lib/session/remote/watch.js +17 -3
- package/dist/lib/session/render.js +7 -3
- package/dist/lib/session/session-cache.d.ts +53 -0
- package/dist/lib/session/session-cache.js +93 -1
- package/dist/lib/session/state.js +1 -1
- package/dist/lib/session/tool-calls.d.ts +2 -0
- package/dist/lib/session/tool-calls.js +1 -1
- package/dist/lib/session/trajectory-compare.d.ts +47 -0
- package/dist/lib/session/trajectory-compare.js +116 -0
- package/dist/lib/session/trajectory-html.d.ts +19 -0
- package/dist/lib/session/trajectory-html.js +770 -0
- package/dist/lib/session/trajectory-lineage.d.ts +92 -0
- package/dist/lib/session/trajectory-lineage.js +195 -0
- package/dist/lib/session/trajectory-text.d.ts +37 -0
- package/dist/lib/session/trajectory-text.js +284 -0
- package/dist/lib/session/trajectory.d.ts +102 -0
- package/dist/lib/session/trajectory.js +384 -0
- package/dist/lib/session/types.d.ts +15 -0
- package/dist/lib/sha256-asset.d.ts +26 -0
- package/dist/lib/sha256-asset.js +41 -0
- package/dist/lib/share/backend.d.ts +95 -0
- package/dist/lib/share/backend.js +139 -0
- package/dist/lib/share/delete.d.ts +6 -2
- package/dist/lib/share/delete.js +8 -9
- package/dist/lib/share/html.d.ts +22 -0
- package/dist/lib/share/html.js +88 -0
- package/dist/lib/share/provision.d.ts +18 -4
- package/dist/lib/share/provision.js +38 -4
- package/dist/lib/share/publish.d.ts +39 -15
- package/dist/lib/share/publish.js +55 -26
- package/dist/lib/share/worker-template.js +171 -11
- package/dist/lib/sqlite.js +16 -3
- package/dist/lib/ssh-exec.d.ts +65 -0
- package/dist/lib/ssh-exec.js +120 -4
- package/dist/lib/startup/command-registry.d.ts +3 -1
- package/dist/lib/startup/command-registry.js +6 -3
- package/dist/lib/startup/dev-build.js +3 -3
- package/dist/lib/state.d.ts +2 -2
- package/dist/lib/state.js +11 -5
- package/dist/lib/subagents-registry.js +1 -1
- package/dist/lib/teams/agents.js +9 -0
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/inject.d.ts +19 -0
- package/dist/lib/terminal/inject.js +19 -9
- package/dist/lib/terminal/types.d.ts +1 -1
- package/dist/lib/terminal/types.js +1 -1
- package/dist/lib/tmux/orphan-reap.js +1 -1
- package/dist/lib/tmux/session.d.ts +46 -13
- package/dist/lib/tmux/session.js +204 -27
- package/dist/lib/traces/backend.d.ts +29 -0
- package/dist/lib/traces/backend.js +46 -0
- package/dist/lib/traces/classify.d.ts +52 -0
- package/dist/lib/traces/classify.js +72 -0
- package/dist/lib/traces/config.d.ts +10 -0
- package/dist/lib/traces/config.js +2 -0
- package/dist/lib/traces/provision.d.ts +19 -0
- package/dist/lib/traces/provision.js +30 -0
- package/dist/lib/traces/sync.d.ts +150 -0
- package/dist/lib/traces/sync.js +447 -0
- package/dist/lib/traces/worker-template.d.ts +4 -0
- package/dist/lib/traces/worker-template.js +159 -0
- package/dist/lib/types.d.ts +34 -19
- package/dist/lib/types.js +14 -0
- package/dist/lib/usage-backoff.d.ts +2 -1
- package/dist/lib/usage-backoff.js +60 -19
- package/dist/lib/usage-refresh.d.ts +18 -4
- package/dist/lib/usage-refresh.js +68 -19
- package/dist/lib/watchdog/log.d.ts +1 -1
- package/dist/lib/watchdog/log.js +1 -1
- package/dist/lib/watchdog/runner.d.ts +36 -45
- package/dist/lib/watchdog/runner.js +150 -119
- package/dist/lib/watchdog/service.d.ts +0 -1
- package/dist/lib/watchdog/service.js +0 -1
- package/dist/lib/watchdog/watchdog-agent.d.ts +38 -0
- package/dist/lib/watchdog/watchdog-agent.js +59 -0
- package/dist/lib/watchdog/watchdog.d.ts +11 -2
- package/dist/lib/watchdog/watchdog.js +37 -104
- package/dist/lib/workflows.d.ts +1 -1
- package/package.json +5 -7
- package/dist/commands/usage.d.ts +0 -27
- package/dist/commands/usage.js +0 -96
- package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +0 -24
- package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +0 -128
- package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +0 -24
- package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +0 -123
- package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
- package/dist/lib/usage-fleet.d.ts +0 -32
- package/dist/lib/usage-fleet.js +0 -125
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { type Host } from './types.js';
|
|
2
2
|
/** ssh's connection-layer failure code — the signal that the link dropped rather
|
|
3
|
-
* than the remote command exiting on its own.
|
|
3
|
+
* than the remote command exiting on its own. Re-exported from ssh-exec.ts, which
|
|
4
|
+
* owns the ssh invocation, so the two cannot drift apart. */
|
|
4
5
|
export declare const SSH_CONN_FAILURE = 255;
|
|
5
6
|
/** What a would-be-255 remote-origin exit code is remapped to by
|
|
6
7
|
* {@link wrapRemoteExitCode} — see the file header. Never produced by the ssh
|
|
7
8
|
* transport itself, so it can never be confused with {@link SSH_CONN_FAILURE}. */
|
|
8
9
|
export declare const REMOTE_EXIT_255_REMAPPED = 254;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
10
|
+
/**
|
|
11
|
+
* How long the loop keeps trying across an UNPRODUCTIVE streak before giving up.
|
|
12
|
+
*
|
|
13
|
+
* A wall-clock window, not an attempt count, because what it has to outlast is
|
|
14
|
+
* measured in minutes: a laptop lid close, a Wi-Fi handoff, a VPN or Tailscale
|
|
15
|
+
* re-auth, a router reboot. The previous `MAX_ATTEMPTS = 6` over a 2/4/8/16/30/30
|
|
16
|
+
* backoff gave up after about **90 seconds** — shorter than any of them
|
|
17
|
+
* (RUSH-3125). Worse, timers are suspended across sleep, so on wake the whole
|
|
18
|
+
* backoff fired back-to-back before the network was up and the budget was gone in
|
|
19
|
+
* seconds.
|
|
20
|
+
*
|
|
21
|
+
* It bounds the STREAK, not the session: a reattach that reconnects and HOLDS
|
|
22
|
+
* resets it to zero ({@link refillsBudget}), so a session that blinks all day
|
|
23
|
+
* still reconnects every time. That is the property the file header insists on,
|
|
24
|
+
* and a flat total would break it — this changes only how a *streak* is bounded.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RECONNECT_WINDOW_MS: number;
|
|
15
27
|
/** How long a reattach must hold the remote pane before it counts as a genuine
|
|
16
28
|
* reconnection that refills the budget. Measured on the interactive attach ALONE
|
|
17
29
|
* — the preflight probe has already returned by then, so this is not the connect
|
|
@@ -22,8 +34,13 @@ export declare const MAX_ATTEMPTS = 6;
|
|
|
22
34
|
export declare const MIN_HOLD_MS = 10000;
|
|
23
35
|
export interface ReconnectState {
|
|
24
36
|
/** Consecutive unproductive reattaches since the last genuine reconnection — one
|
|
25
|
-
* that reached the host and held for {@link MIN_HOLD_MS}.
|
|
37
|
+
* that reached the host and held for {@link MIN_HOLD_MS}. Drives the backoff
|
|
38
|
+
* curve and the human-facing attempt number; no longer the give-up condition. */
|
|
26
39
|
attempt: number;
|
|
40
|
+
/** Wall-clock ms burned on the current unproductive streak — the waits plus the
|
|
41
|
+
* time each failed attach itself took. Compared against
|
|
42
|
+
* {@link RECONNECT_WINDOW_MS}; reset to 0 by a reattach that held. */
|
|
43
|
+
unproductiveMs: number;
|
|
27
44
|
}
|
|
28
45
|
export interface ReconnectOutcome {
|
|
29
46
|
/** Exit code of the run (initial) or the last re-attach. */
|
|
@@ -45,6 +62,7 @@ export type ReconnectDecision = {
|
|
|
45
62
|
action: 'retry';
|
|
46
63
|
waitMs: number;
|
|
47
64
|
state: ReconnectState;
|
|
65
|
+
remainingMs: number;
|
|
48
66
|
};
|
|
49
67
|
export declare function initialReconnectState(): ReconnectState;
|
|
50
68
|
/** Exponential backoff capped at {@link MAX_BACKOFF_MS}: 2s, 4s, 8s, 16s, 30s… */
|
|
@@ -67,28 +85,43 @@ export declare function refillsBudget(outcome: ReconnectOutcome): boolean;
|
|
|
67
85
|
* - a 255 from an attempt that reconnected AND held ({@link refillsBudget})
|
|
68
86
|
* refills the budget first; every other 255 counts against it, so a host that
|
|
69
87
|
* stays unreachable — and a link that keeps dropping the attach immediately —
|
|
70
|
-
* both give up
|
|
88
|
+
* both give up once the retry window closes.
|
|
71
89
|
*/
|
|
72
90
|
export declare function reconnectStep(state: ReconnectState, outcome: ReconnectOutcome): ReconnectDecision;
|
|
73
|
-
/**
|
|
74
|
-
export declare function
|
|
91
|
+
/** "14m51s", "51s" — a duration a waiting human can read at a glance. */
|
|
92
|
+
export declare function formatDuration(ms: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Notice shown before each reconnect wait.
|
|
95
|
+
*
|
|
96
|
+
* Says how long is left in the window rather than "attempt 2/6": with a
|
|
97
|
+
* wall-clock budget the attempt number no longer tells the user when this stops,
|
|
98
|
+
* and "how much longer will it keep trying" is the actual question during an
|
|
99
|
+
* outage. Ctrl-C is advertised because a user who wants their shell back should
|
|
100
|
+
* not have to guess whether interrupting is safe — it is (the agent keeps
|
|
101
|
+
* running on the peer, which is the whole point).
|
|
102
|
+
*/
|
|
103
|
+
export declare function reconnectNotice(target: ReconnectTarget, host: string, attempt: number, waitMs: number, remainingMs: number): string;
|
|
75
104
|
/** Notice shown once the retry budget is spent on a host that stayed UNREACHABLE.
|
|
76
105
|
* Hands back the one verb that re-enters the terminal — attach the live pane if it
|
|
77
106
|
* survived, else resume. */
|
|
78
|
-
export declare function exhaustedNotice(
|
|
107
|
+
export declare function exhaustedNotice(target: ReconnectTarget, host: string): string;
|
|
79
108
|
/** Notice shown when the budget is spent the OTHER way: the last reattach reached
|
|
80
109
|
* the host and the connection dropped again within {@link MIN_HOLD_MS}. Saying
|
|
81
110
|
* "couldn't reconnect" there would be false — it did reconnect and could not stay
|
|
82
111
|
* — and the user needs to know the link, not the host, is the problem. It claims
|
|
83
112
|
* no count of successful reconnections: the budget can also be spent by a run of
|
|
84
113
|
* unreachable attempts followed by one that reconnected and dropped straight out. */
|
|
85
|
-
export declare function unstableNotice(
|
|
114
|
+
export declare function unstableNotice(target: ReconnectTarget, host: string): string;
|
|
86
115
|
/** Notice shown when a reattach stops on a remapped remote-side exit
|
|
87
116
|
* ({@link REMOTE_EXIT_255_REMAPPED} — a would-be-255 the remote command decided
|
|
88
117
|
* on for its own reasons, not the ssh transport dropping; see
|
|
89
118
|
* {@link wrapRemoteExitCode}). Distinct from {@link exhaustedNotice}, which is
|
|
90
119
|
* only for a genuinely spent retry budget. */
|
|
91
|
-
export declare function remoteExitNotice(
|
|
120
|
+
export declare function remoteExitNotice(target: ReconnectTarget, host: string): string;
|
|
121
|
+
/** Shown when the user Ctrl-Cs out of the wait. The agent is untouched — it is
|
|
122
|
+
* detached on the peer — so this says how to get back rather than implying the
|
|
123
|
+
* work was lost. */
|
|
124
|
+
export declare function interruptedNotice(target: ReconnectTarget, host: string): string;
|
|
92
125
|
/**
|
|
93
126
|
* Wrap `cmd` in `bash -lc` (the login-shell pattern `buildRemoteAgentsInvocation`
|
|
94
127
|
* in remote-cmd.ts uses for its own POSIX callers — see its doc comment for why
|
|
@@ -107,17 +140,141 @@ export declare function remoteExitNotice(sessionId: string, host: string): strin
|
|
|
107
140
|
* mock needed).
|
|
108
141
|
*/
|
|
109
142
|
export declare function wrapRemoteExitCode(cmd: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* How a dropped run is named when we go back for it.
|
|
145
|
+
*
|
|
146
|
+
* `session` is the direct case: the id was known before the link died — Claude
|
|
147
|
+
* is handed one up front, and a resumed run already has one.
|
|
148
|
+
*
|
|
149
|
+
* `launch` is what makes reconnect work for every OTHER harness (RUSH-3125).
|
|
150
|
+
* Their real session id is coined on the peer, and the launcher used to read it
|
|
151
|
+
* back over SSH *after* the stream returned — i.e. over the link that had just
|
|
152
|
+
* dropped. That read fails exactly when it matters, leaving `reconnectId`
|
|
153
|
+
* undefined and the process exiting straight to a shell, which is why a Grok tab
|
|
154
|
+
* got no reconnect at all while a Claude tab beside it got a countdown. The
|
|
155
|
+
* launch id is minted locally before the connection exists, so it survives the
|
|
156
|
+
* drop; the peer maps it to the real session with a purely local lookup.
|
|
157
|
+
*/
|
|
158
|
+
export type ReconnectTarget = {
|
|
159
|
+
kind: 'session';
|
|
160
|
+
id: string;
|
|
161
|
+
} | {
|
|
162
|
+
kind: 'launch';
|
|
163
|
+
id: string;
|
|
164
|
+
};
|
|
165
|
+
/** The short form shown to a human. Both kinds are uuid-shaped, so 8 chars reads the same. */
|
|
166
|
+
export declare function targetLabel(target: ReconnectTarget): string;
|
|
167
|
+
/**
|
|
168
|
+
* The command to hand a user whose reconnect gave up.
|
|
169
|
+
*
|
|
170
|
+
* A `session` target has a real id, so `agents sessions resume <id>` does the
|
|
171
|
+
* same attach-else-recover the loop was attempting. The full id is labeled on
|
|
172
|
+
* its own `Session` line, not only inside the command (RUSH-3227). (It used to
|
|
173
|
+
* say `agents reconnect`, which is deprecated and hidden — `commands/reconnect.ts`
|
|
174
|
+
* — so the advice printed at the worst possible moment was itself stale; RUSH-3125.)
|
|
175
|
+
*
|
|
176
|
+
* A `launch` target has no id a user-facing verb accepts: the mapping lives in
|
|
177
|
+
* the peer's hook records, which is exactly why reconnect uses it. So point at
|
|
178
|
+
* the peer's own resolver rather than inventing a launch-id selector on every
|
|
179
|
+
* local command for a string no human ever types.
|
|
180
|
+
*/
|
|
181
|
+
export declare function recoveryHint(target: ReconnectTarget, host: string): string;
|
|
182
|
+
/**
|
|
183
|
+
* Notice shown when an interactive remote connection has ended and the user is
|
|
184
|
+
* back at a local shell — clean detach, agent exit, or a drop that is NOT
|
|
185
|
+
* about to auto-reconnect. The OpenSSH close line (`Shared connection to …
|
|
186
|
+
* closed.`) names the host and nothing else; this is the handle they need to
|
|
187
|
+
* get back in (RUSH-3227).
|
|
188
|
+
*/
|
|
189
|
+
export declare function connectionEndedNotice(target: ReconnectTarget, host: string, opts?: {
|
|
190
|
+
dropped?: boolean;
|
|
191
|
+
}): string;
|
|
192
|
+
/**
|
|
193
|
+
* Banner printed when an interactive `--device` run whose session id is already
|
|
194
|
+
* known (Claude's forced id, or a resume) is about to take the TTY. The TUI
|
|
195
|
+
* will cover this; it survives in scrollback so the id exists *while* the
|
|
196
|
+
* connection exists, not only after it dies (RUSH-3227 plan B). Launch-id
|
|
197
|
+
* targets are not a resume handle — do not print them here.
|
|
198
|
+
*/
|
|
199
|
+
export declare function connectionStartedNotice(target: ReconnectTarget, host: string): string | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* The id to print as an interactive `--device` stream starts. Resume is a
|
|
202
|
+
* real session id (`resolveHostSessionId` returns undefined on `--resume`);
|
|
203
|
+
* Claude's forced id is the other. `run auto` is excluded: its forwarded
|
|
204
|
+
* `--session-id` is only real if the remote pick is Claude.
|
|
205
|
+
*/
|
|
206
|
+
export declare function startConnectionTarget(opts: {
|
|
207
|
+
agent: string;
|
|
208
|
+
hostSessionId?: string;
|
|
209
|
+
resumeId?: string;
|
|
210
|
+
}): ReconnectTarget | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Decide what happens after an interactive `--device` stream returns.
|
|
213
|
+
*
|
|
214
|
+
* Auto-reconnect only when the link dropped (255) AND the run is tmux-hosted
|
|
215
|
+
* (`willReconnect`). `--raw` is not wrapped, so it never reconnects — but it
|
|
216
|
+
* still prints the session id: the user is at a shell, and EXEC-55 does not
|
|
217
|
+
* exempt raw (RUSH-3227). Bundling the notice behind `!isRaw` was the miss.
|
|
218
|
+
*/
|
|
219
|
+
export declare function afterInteractiveRemoteExit(opts: {
|
|
220
|
+
target?: ReconnectTarget;
|
|
221
|
+
host: string;
|
|
222
|
+
exitCode: number;
|
|
223
|
+
/** True when auto-reconnect will take over (tmux-hosted, not `--raw`). */
|
|
224
|
+
willReconnect: boolean;
|
|
225
|
+
}): {
|
|
226
|
+
reconnect: boolean;
|
|
227
|
+
notice: string | undefined;
|
|
228
|
+
};
|
|
229
|
+
/** What the launcher knows about a run once its interactive stream has returned. */
|
|
230
|
+
export interface ReconnectTargetInputs {
|
|
231
|
+
/** The harness (or {@link RUN_AUTO_KEYWORD}) that was dispatched. */
|
|
232
|
+
agent: string;
|
|
233
|
+
/** An id forced by the launcher up front — Claude's `--session-id`. */
|
|
234
|
+
sessionId?: string;
|
|
235
|
+
/** An id read back off the peer AFTER the stream returned. Absent on a drop. */
|
|
236
|
+
resolvedId?: string;
|
|
237
|
+
/** The id of a run that was resuming an existing session. */
|
|
238
|
+
resumeId?: string;
|
|
239
|
+
/** The launcher-minted AGENT_LAUNCH_ID, known before the connection existed. */
|
|
240
|
+
launchId?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Choose how to name the dropped run when going back for it.
|
|
244
|
+
*
|
|
245
|
+
* Order matters, and the last clause is the fix (RUSH-3125):
|
|
246
|
+
*
|
|
247
|
+
* 1. `run auto` prefers `resolvedId` — the harness the remote ACTUALLY picked,
|
|
248
|
+
* which the launcher's own `--session-id` (adopted only by Claude) may not
|
|
249
|
+
* name. Every other agent prefers the id the launcher forced.
|
|
250
|
+
* 2. `resumeId` covers a run that was continuing a known session.
|
|
251
|
+
* 3. **`launchId` last, and it is what makes this work at all off-Claude.**
|
|
252
|
+
* Every id above either came from the launcher or was read back over SSH —
|
|
253
|
+
* and that read happens after the stream returned, i.e. over the link that
|
|
254
|
+
* just died, so on a real drop it yields nothing. Falling through to the
|
|
255
|
+
* launch id means the reconnect no longer depends on reaching the host to
|
|
256
|
+
* learn what to reconnect to; the peer resolves it locally instead.
|
|
257
|
+
*
|
|
258
|
+
* Returns undefined only when the launcher has no handle at all (a hookless
|
|
259
|
+
* harness with no forced id), which is the one case reconnect genuinely cannot
|
|
260
|
+
* serve. Pure, so the precedence is unit-tested without SSH.
|
|
261
|
+
*/
|
|
262
|
+
export declare function pickReconnectTarget(inputs: ReconnectTargetInputs): ReconnectTarget | undefined;
|
|
110
263
|
/**
|
|
111
264
|
* The remote command a reattach runs — the peer's own recovery verb
|
|
112
|
-
* (`agents sessions focus
|
|
265
|
+
* (`agents sessions focus … --local`), wrapped by {@link wrapRemoteExitCode}
|
|
113
266
|
* so a stray remote-origin 255 (from this command, whatever produces it — see the
|
|
114
267
|
* file header) can never masquerade as a network drop. No `--attach-only`: focus
|
|
115
268
|
* joins the live pane when it survived, else RESUMES the session in place, so a
|
|
116
269
|
* reattach landing after the pane died recovers the agent instead of dead-ending
|
|
117
270
|
* (RUSH-2085). Split out from {@link reattachRemoteSession} so it is unit-tested
|
|
118
271
|
* without SSH — mirrors `remoteAgentsJsonCommand` in lib/remote-agents-json.ts.
|
|
272
|
+
*
|
|
273
|
+
* A `launch` target passes `--launch-id`, which focus resolves against the hook
|
|
274
|
+
* records on the peer itself — no network read from this side, which is the
|
|
275
|
+
* whole point (see {@link ReconnectTarget}).
|
|
119
276
|
*/
|
|
120
|
-
export declare function reattachRemoteCommand(
|
|
277
|
+
export declare function reattachRemoteCommand(target: ReconnectTarget): string;
|
|
121
278
|
/**
|
|
122
279
|
* Re-attach the live remote tmux pane for `sessionId` by driving the peer's own
|
|
123
280
|
* `agents sessions focus`. A fast, un-multiplexed preflight probe (`ssh … true`)
|
|
@@ -129,18 +286,19 @@ export declare function reattachRemoteCommand(sessionId: string): string;
|
|
|
129
286
|
* clean detach; other = session ended), whether this attempt connected, and how
|
|
130
287
|
* long the attach held — the two inputs {@link refillsBudget} decides on.
|
|
131
288
|
*/
|
|
132
|
-
export declare function reattachRemoteSession(host: Host,
|
|
289
|
+
export declare function reattachRemoteSession(host: Host, target: ReconnectTarget): ReconnectOutcome;
|
|
133
290
|
export interface ReconnectLoopOpts {
|
|
134
291
|
host: Host;
|
|
135
|
-
|
|
292
|
+
target: ReconnectTarget;
|
|
136
293
|
/** The exit code from the initial interactive run (which, having run the agent,
|
|
137
294
|
* is treated as a connected attempt). */
|
|
138
295
|
initialExit: number;
|
|
139
296
|
/** Injected for tests: the real re-attach and wait are swapped for deterministic
|
|
140
297
|
* fakes so the loop's control flow is exercised without SSH. Production uses the
|
|
141
|
-
* real {@link reattachRemoteSession} +
|
|
142
|
-
reattach?: (host: Host,
|
|
143
|
-
|
|
298
|
+
* real {@link reattachRemoteSession} + {@link waitOrInterrupt}. */
|
|
299
|
+
reattach?: (host: Host, target: ReconnectTarget) => ReconnectOutcome;
|
|
300
|
+
/** Resolves 'interrupted' when the user Ctrl-Cs out of the backoff. */
|
|
301
|
+
wait?: (ms: number) => Promise<'elapsed' | 'interrupted'>;
|
|
144
302
|
write?: (s: string) => void;
|
|
145
303
|
}
|
|
146
304
|
/**
|