@phnx-labs/agents-cli 1.22.113 → 1.22.115
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 +139 -0
- package/README.md +32 -113
- package/dist/browser.js +0 -0
- package/dist/cli/command-registry.d.ts +0 -60
- package/dist/cli/command-registry.js +57 -66
- package/dist/commands/accounts.d.ts +3 -77
- package/dist/commands/accounts.js +13 -366
- package/dist/commands/apply.d.ts +0 -4
- package/dist/commands/apply.js +3 -3
- package/dist/commands/audit.js +1 -1
- package/dist/commands/auth.js +0 -2
- package/dist/commands/browser-picker.d.ts +3 -6
- package/dist/commands/browser-picker.js +2 -2
- package/dist/commands/browser-sessions-picker.d.ts +2 -1
- package/dist/commands/browser.d.ts +53 -0
- package/dist/commands/browser.js +199 -9
- package/dist/commands/computer-sessions-picker.d.ts +2 -1
- package/dist/commands/computer.d.ts +14 -19
- package/dist/commands/computer.js +65 -10
- package/dist/commands/config.js +46 -2
- package/dist/commands/daemon.d.ts +0 -23
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/detach-core.d.ts +2 -1
- package/dist/commands/detach.d.ts +0 -3
- package/dist/commands/detach.js +3 -3
- package/dist/commands/doctor.d.ts +2 -3
- package/dist/commands/doctor.js +0 -11
- package/dist/commands/events.d.ts +1 -3
- package/dist/commands/events.js +4 -7
- package/dist/commands/exec.d.ts +0 -1
- package/dist/commands/exec.js +2 -7
- package/dist/commands/feed-watch.js +52 -8
- package/dist/commands/feed.d.ts +3 -3
- package/dist/commands/feed.js +1 -1
- package/dist/commands/focus.d.ts +4 -4
- package/dist/commands/focus.js +1 -1
- package/dist/commands/go.d.ts +0 -17
- package/dist/commands/go.js +2 -19
- package/dist/commands/harness-hooks.d.ts +0 -7
- package/dist/commands/harness-hooks.js +1 -1
- package/dist/commands/harness-wizard.d.ts +2 -2
- package/dist/commands/harness.d.ts +3 -8
- package/dist/commands/harness.js +1 -1
- package/dist/commands/inspect.d.ts +2 -3
- package/dist/commands/inspect.js +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/mcp.js +8 -83
- package/dist/commands/memory.js +4 -47
- package/dist/commands/message.d.ts +1 -1
- package/dist/commands/message.js +7 -7
- package/dist/commands/plugins.js +1 -93
- package/dist/commands/projects.d.ts +2 -18
- package/dist/commands/projects.js +89 -3
- package/dist/commands/repo.js +0 -44
- package/dist/commands/resource-view.d.ts +3 -2
- package/dist/commands/resume.d.ts +0 -1
- package/dist/commands/resume.js +5 -2
- package/dist/commands/routines.d.ts +1 -3
- package/dist/commands/routines.js +1 -1
- package/dist/commands/run-account-picker.d.ts +2 -1
- package/dist/commands/run-broadcast.d.ts +2 -1
- package/dist/commands/run-device-picker.d.ts +2 -1
- package/dist/commands/secrets-passthrough.d.ts +14 -0
- package/dist/commands/secrets-passthrough.js +23 -4
- package/dist/commands/send.d.ts +4 -4
- package/dist/commands/send.js +6 -51
- package/dist/commands/sessions-backfill.d.ts +2 -35
- package/dist/commands/sessions-backfill.js +1 -1
- package/dist/commands/sessions-backup-setup.js +1 -1
- package/dist/commands/sessions-bookmark.d.ts +0 -10
- package/dist/commands/sessions-bookmark.js +1 -1
- package/dist/commands/sessions-inject.d.ts +2 -3
- package/dist/commands/sessions-inject.js +8 -17
- package/dist/commands/sessions-picker-factory.d.ts +4 -14
- package/dist/commands/sessions-picker-factory.js +2 -2
- package/dist/commands/sessions-picker.d.ts +3 -9
- package/dist/commands/sessions-picker.js +2 -2
- package/dist/commands/sessions-resume.d.ts +2 -4
- package/dist/commands/sessions-resume.js +0 -6
- package/dist/commands/sessions-share.d.ts +5 -7
- package/dist/commands/sessions-share.js +98 -49
- package/dist/commands/sessions-stats.d.ts +2 -1
- package/dist/commands/sessions-stop.d.ts +0 -3
- package/dist/commands/sessions-stop.js +1 -1
- package/dist/commands/sessions-tail.d.ts +2 -1
- package/dist/commands/sessions-trace.d.ts +4 -6
- package/dist/commands/sessions-trace.js +1 -1
- package/dist/commands/sessions.d.ts +13 -104
- package/dist/commands/sessions.js +11 -18
- package/dist/commands/setup-browser.js +18 -2
- package/dist/commands/setup-computer.js +20 -6
- package/dist/commands/setup-mine.d.ts +0 -6
- package/dist/commands/setup-mine.js +1 -1
- package/dist/commands/setup-secrets.js +24 -4
- package/dist/commands/setup-terminal.d.ts +3 -0
- package/dist/commands/setup-terminal.js +22 -0
- package/dist/commands/setup.d.ts +3 -4
- package/dist/commands/setup.js +21 -11
- package/dist/commands/skills.js +0 -8
- package/dist/commands/ssh.d.ts +6 -0
- package/dist/commands/ssh.js +92 -233
- package/dist/commands/sync.js +14 -5
- package/dist/commands/teams-picker.d.ts +2 -5
- package/dist/commands/teams-picker.js +2 -2
- package/dist/commands/teams.d.ts +1 -7
- package/dist/commands/teams.js +2 -2
- package/dist/commands/tmux.d.ts +1 -1
- package/dist/commands/tmux.js +1 -1
- package/dist/commands/traces.js +1 -1
- package/dist/commands/upgrade.d.ts +2 -1
- package/dist/commands/utils.d.ts +1 -1
- package/dist/commands/utils.js +1 -1
- package/dist/lib/account-capabilities.d.ts +2 -1
- package/dist/lib/account-catalog.d.ts +4 -13
- package/dist/lib/account-catalog.js +1 -1
- package/dist/lib/account-registry.d.ts +3 -4
- package/dist/lib/account-registry.js +1 -1
- package/dist/lib/accounting/account-launch.d.ts +4 -3
- package/dist/lib/accounting/account-pool.d.ts +2 -1
- package/dist/lib/accounting/rotate.d.ts +3 -9
- package/dist/lib/accounting/rotate.js +2 -14
- package/dist/lib/accounting/usage-sync.d.ts +5 -4
- package/dist/lib/accounting/usage.d.ts +7 -31
- package/dist/lib/accounting/usage.js +4 -4
- package/dist/lib/accounts/add.d.ts +0 -5
- package/dist/lib/accounts/add.js +1 -7
- package/dist/lib/accounts/migrate.d.ts +8 -8
- package/dist/lib/accounts/migrate.js +1 -1
- package/dist/lib/acp/client.d.ts +3 -2
- package/dist/lib/acp/harnesses.d.ts +2 -2
- package/dist/lib/acp/harnesses.js +1 -1
- package/dist/lib/acp/run.d.ts +2 -1
- package/dist/lib/actor.d.ts +3 -2
- package/dist/lib/add-dir.d.ts +2 -17
- package/dist/lib/add-dir.js +2 -6
- package/dist/lib/address.d.ts +56 -0
- package/dist/lib/address.js +143 -0
- package/dist/lib/agent-spec/agents.d.ts +12 -28
- package/dist/lib/agent-spec/agents.js +2 -6
- package/dist/lib/agent-spec/primitives.d.ts +0 -7
- package/dist/lib/agent-spec/primitives.js +0 -6
- package/dist/lib/agent-spec/types.d.ts +2 -1
- package/dist/lib/analytics/dashboard.d.ts +1 -5
- package/dist/lib/analytics/dashboard.js +0 -2
- package/dist/lib/analytics/mix-commands.d.ts +0 -7
- package/dist/lib/analytics/mix-commands.js +3 -3
- package/dist/lib/analytics/recipes.d.ts +0 -12
- package/dist/lib/analytics/recipes.js +7 -31
- package/dist/lib/analytics/usage-db.d.ts +5 -32
- package/dist/lib/analytics/usage-db.js +1 -70
- package/dist/lib/answer-router.d.ts +7 -6
- package/dist/lib/answer-router.js +5 -11
- package/dist/lib/artifact-actions.d.ts +0 -4
- package/dist/lib/artifacts-client.d.ts +20 -0
- package/dist/lib/artifacts-client.js +46 -0
- package/dist/lib/ask-classifier.d.ts +3 -4
- package/dist/lib/ask-classifier.js +0 -7
- package/dist/lib/auth-health.d.ts +3 -46
- package/dist/lib/auth-health.js +3 -3
- package/dist/lib/auth-mint.d.ts +6 -6
- package/dist/lib/auth-mint.js +7 -7
- package/dist/lib/bench/runner.d.ts +2 -2
- package/dist/lib/bench/runner.js +1 -1
- package/dist/lib/bench/storage.d.ts +0 -1
- package/dist/lib/bench/storage.js +1 -1
- package/dist/lib/boot-profile.d.ts +0 -2
- package/dist/lib/boot-profile.js +0 -4
- package/dist/lib/brand.d.ts +0 -6
- package/dist/lib/brand.js +1 -1
- package/dist/lib/browser/arc-discovery.d.ts +4 -12
- package/dist/lib/browser/arc-discovery.js +1 -1
- package/dist/lib/browser/cdp.d.ts +1 -1
- package/dist/lib/browser/chrome.d.ts +2 -2
- package/dist/lib/browser/chrome.js +0 -4
- package/dist/lib/browser/chromium-discovery.d.ts +3 -2
- package/dist/lib/browser/drivers/arc.d.ts +3 -20
- package/dist/lib/browser/drivers/arc.js +2 -7
- package/dist/lib/browser/drivers/firefox.d.ts +2 -6
- package/dist/lib/browser/drivers/firefox.js +1 -1
- package/dist/lib/browser/drivers/local.d.ts +2 -1
- package/dist/lib/browser/drivers/ssh.d.ts +2 -3
- package/dist/lib/browser/drivers/ssh.js +0 -7
- package/dist/lib/browser/firefox-discovery.d.ts +4 -3
- package/dist/lib/browser/har.d.ts +8 -7
- package/dist/lib/browser/hygiene.d.ts +2 -3
- package/dist/lib/browser/hygiene.js +1 -1
- package/dist/lib/browser/ipc.d.ts +4 -3
- package/dist/lib/browser/ipc.js +1 -1
- package/dist/lib/browser/login-detection.d.ts +1 -8
- package/dist/lib/browser/registry.d.ts +2 -1
- package/dist/lib/browser/remote-control.d.ts +0 -7
- package/dist/lib/browser/remote-control.js +2 -2
- package/dist/lib/browser/resolve-target.d.ts +2 -6
- package/dist/lib/browser/resolve-target.js +3 -3
- package/dist/lib/browser/runtime-state.d.ts +59 -4
- package/dist/lib/browser/runtime-state.js +99 -18
- package/dist/lib/browser/service.d.ts +4 -4
- package/dist/lib/browser/service.js +21 -1
- package/dist/lib/browser/sessions-list.d.ts +0 -10
- package/dist/lib/browser/sessions-list.js +3 -3
- package/dist/lib/browser/stream.d.ts +2 -1
- package/dist/lib/browser/task-index.d.ts +4 -4
- package/dist/lib/browser/task-index.js +1 -1
- package/dist/lib/browser/types.d.ts +0 -20
- package/dist/lib/browser/types.js +1 -34
- package/dist/lib/browser/upload.d.ts +0 -27
- package/dist/lib/budget/ledger.d.ts +0 -2
- package/dist/lib/budget/ledger.js +1 -1
- package/dist/lib/budget/live-cloud.d.ts +2 -1
- package/dist/lib/budget/preflight.d.ts +3 -5
- package/dist/lib/budget/preflight.js +1 -1
- package/dist/lib/catchup.d.ts +2 -1
- package/dist/lib/channels/owner-forward.d.ts +5 -4
- package/dist/lib/channels/owner-sink.js +2 -2
- package/dist/lib/channels/providers/desktop.js +1 -1
- package/dist/lib/channels/providers/rush.d.ts +2 -1
- package/dist/lib/channels/registry.d.ts +1 -1
- package/dist/lib/channels/registry.js +1 -1
- package/dist/lib/channels/resolve.d.ts +3 -2
- package/dist/lib/channels/send.d.ts +5 -4
- package/dist/lib/cli-resources.d.ts +3 -9
- package/dist/lib/cli-resources.js +4 -2
- package/dist/lib/cloud/cursor.d.ts +1 -2
- package/dist/lib/cloud/cursor.js +1 -1
- package/dist/lib/cloud/dispatch.d.ts +2 -1
- package/dist/lib/cloud/dispatch.js +1 -1
- package/dist/lib/cloud/factory.d.ts +0 -2
- package/dist/lib/cloud/factory.js +1 -1
- package/dist/lib/cloud/rush.d.ts +3 -11
- package/dist/lib/cloud/rush.js +1 -1
- package/dist/lib/cloud/session-index.d.ts +2 -1
- package/dist/lib/cloud/types.d.ts +2 -1
- package/dist/lib/cloudflare/creds.d.ts +10 -0
- package/dist/lib/cloudflare/creds.js +46 -0
- package/dist/lib/cloudflare/provision.d.ts +35 -0
- package/dist/lib/cloudflare/provision.js +144 -0
- package/dist/lib/codex-policy.d.ts +2 -1
- package/dist/lib/commands.d.ts +7 -7
- package/dist/lib/commands.js +1 -1
- package/dist/lib/comms-render.d.ts +1 -1
- package/dist/lib/computer/context.d.ts +11 -3
- package/dist/lib/computer/context.js +2 -2
- package/dist/lib/computer/policy.d.ts +0 -12
- package/dist/lib/computer/policy.js +1 -1
- package/dist/lib/computer/sessions-list.d.ts +55 -0
- package/dist/lib/computer/sessions-list.js +168 -1
- package/dist/lib/computer-client.d.ts +3 -3
- package/dist/lib/computer-client.js +0 -1
- package/dist/lib/concurrency.d.ts +2 -1
- package/dist/lib/config-keys.d.ts +16 -3
- package/dist/lib/config-keys.js +47 -2
- package/dist/lib/convert.d.ts +0 -12
- package/dist/lib/convert.js +1 -12
- package/dist/lib/crabbox/cli.d.ts +6 -24
- package/dist/lib/crabbox/cli.js +2 -28
- package/dist/lib/crabbox/lease.d.ts +5 -6
- package/dist/lib/crabbox/lease.js +1 -1
- package/dist/lib/crabbox/progress.d.ts +2 -1
- package/dist/lib/crabbox/setup-copy.d.ts +2 -3
- package/dist/lib/crabbox/setup-copy.js +1 -1
- package/dist/lib/daemon/account-state-daemon-service.d.ts +1 -1
- package/dist/lib/daemon/attention-notify-service.d.ts +2 -1
- package/dist/lib/daemon/catchup-service.d.ts +2 -1
- package/dist/lib/daemon/daemon.d.ts +4 -4
- package/dist/lib/daemon/daemon.js +9 -2
- package/dist/lib/daemon/feed-stream-service.d.ts +23 -0
- package/dist/lib/daemon/feed-stream-service.js +40 -0
- package/dist/lib/daemon/harness-update-service.d.ts +2 -19
- package/dist/lib/daemon/harness-update-service.js +3 -3
- package/dist/lib/daemon/runner.d.ts +3 -3
- package/dist/lib/daemon/self-update-service.d.ts +1 -16
- package/dist/lib/daemon/self-update-service.js +6 -6
- package/dist/lib/daemon/state-dir-check-service.d.ts +2 -1
- package/dist/lib/daemon/supervisor.d.ts +3 -2
- package/dist/lib/daemon-services.d.ts +3 -2
- package/dist/lib/daemon-services.js +5 -0
- package/dist/lib/daemon-webhooks.d.ts +1 -1
- package/dist/lib/deeplink/register.d.ts +3 -13
- package/dist/lib/deeplink/register.js +3 -3
- package/dist/lib/deeplink/url.d.ts +3 -2
- package/dist/lib/device-config.d.ts +4 -15
- package/dist/lib/device-config.js +164 -8
- package/dist/lib/devices/connect.d.ts +51 -6
- package/dist/lib/devices/connect.js +169 -21
- package/dist/lib/devices/discovery-policy.d.ts +3 -2
- package/dist/lib/devices/doctor-findings.js +1 -1
- package/dist/lib/devices/doctor-overview-cache.d.ts +3 -2
- package/dist/lib/devices/fleet-divergence.d.ts +2 -1
- package/dist/lib/devices/fleet.d.ts +3 -4
- package/dist/lib/devices/fleet.js +1 -1
- package/dist/lib/devices/harness-inventory.d.ts +3 -2
- package/dist/lib/devices/health-report.d.ts +3 -2
- package/dist/lib/devices/health.d.ts +1 -8
- package/dist/lib/devices/health.js +1 -1
- package/dist/lib/devices/interactive-host.d.ts +0 -2
- package/dist/lib/devices/interactive-host.js +1 -1
- package/dist/lib/devices/known-hosts.d.ts +2 -20
- package/dist/lib/devices/known-hosts.js +2 -2
- package/dist/lib/devices/pool.d.ts +2 -1
- package/dist/lib/devices/resolve-target.d.ts +2 -2
- package/dist/lib/devices/rollout-verify.d.ts +3 -2
- package/dist/lib/devices/stats-cache.d.ts +3 -2
- package/dist/lib/devices/sync.d.ts +6 -5
- package/dist/lib/devices/worker-pick.d.ts +3 -12
- package/dist/lib/devices/worker-pick.js +1 -1
- package/dist/lib/diff-text.d.ts +2 -1
- package/dist/lib/doctor-diff.d.ts +2 -1
- package/dist/lib/drift-sync.d.ts +3 -2
- package/dist/lib/drift.d.ts +3 -3
- package/dist/lib/drift.js +1 -1
- package/dist/lib/event-families.d.ts +0 -6
- package/dist/lib/event-families.js +3 -3
- package/dist/lib/event-provenance.d.ts +2 -1
- package/dist/lib/events-ingest.d.ts +4 -3
- package/dist/lib/exec-account-home.d.ts +2 -4
- package/dist/lib/exec-account-home.js +1 -1
- package/dist/lib/exec-bounded.d.ts +3 -4
- package/dist/lib/exec-bounded.js +1 -1
- package/dist/lib/exec.d.ts +6 -18
- package/dist/lib/exec.js +1 -1
- package/dist/lib/factory/snapshot.d.ts +2 -2
- package/dist/lib/factory/snapshot.js +1 -1
- package/dist/lib/feed/activity-stream.d.ts +2 -5
- package/dist/lib/feed/activity-stream.js +2 -2
- package/dist/lib/feed/activity.d.ts +8 -33
- package/dist/lib/feed/activity.js +8 -8
- package/dist/lib/feed/answer.d.ts +3 -2
- package/dist/lib/feed/attention.js +5 -1
- package/dist/lib/feed/envelope.d.ts +79 -0
- package/dist/lib/feed/envelope.js +23 -0
- package/dist/lib/feed/events.d.ts +8 -47
- package/dist/lib/feed/events.js +9 -141
- package/dist/lib/feed/feed.d.ts +9 -42
- package/dist/lib/feed/feed.js +1 -60
- package/dist/lib/feed/hub-server.d.ts +86 -0
- package/dist/lib/feed/hub-server.js +334 -0
- package/dist/lib/feed/hub.d.ts +95 -0
- package/dist/lib/feed/hub.js +255 -0
- package/dist/lib/feed/pr-status.d.ts +0 -2
- package/dist/lib/feed/pr-status.js +1 -5
- package/dist/lib/feed/tool-activity.d.ts +108 -0
- package/dist/lib/feed/tool-activity.js +313 -0
- package/dist/lib/feed/tools.d.ts +198 -0
- package/dist/lib/feed/tools.js +265 -0
- package/dist/lib/feed/watch.d.ts +51 -52
- package/dist/lib/feed/watch.js +147 -17
- package/dist/lib/feed-broadcast.d.ts +5 -47
- package/dist/lib/feed-broadcast.js +9 -9
- package/dist/lib/feed-outcome.d.ts +3 -6
- package/dist/lib/feed-outcome.js +2 -2
- package/dist/lib/feed-policy.d.ts +5 -6
- package/dist/lib/feed-policy.js +2 -2
- package/dist/lib/feed-post.d.ts +3 -4
- package/dist/lib/feed-post.js +1 -1
- package/dist/lib/feed-ranking.d.ts +2 -2
- package/dist/lib/feed-ranking.js +1 -1
- package/dist/lib/fleet/apply.d.ts +5 -6
- package/dist/lib/fleet/apply.js +4 -4
- package/dist/lib/fleet/manifest.d.ts +2 -1
- package/dist/lib/fleet/remote-login.d.ts +18 -36
- package/dist/lib/fleet/remote-login.js +20 -19
- package/dist/lib/fleet/types.d.ts +0 -8
- package/dist/lib/fleet-cache.d.ts +1 -18
- package/dist/lib/fleet-cache.js +0 -5
- package/dist/lib/fleet-shared-repo-sync.d.ts +3 -3
- package/dist/lib/fleet-shared-repo-sync.js +1 -1
- package/dist/lib/fleet-shared-state.d.ts +3 -2
- package/dist/lib/format.d.ts +3 -2
- package/dist/lib/format.js +1 -1
- package/dist/lib/friction-heuristics.d.ts +2 -1
- package/dist/lib/fs-walk.d.ts +2 -1
- package/dist/lib/fuzzy.d.ts +2 -1
- package/dist/lib/gemini-settings.d.ts +0 -1
- package/dist/lib/gemini-settings.js +1 -1
- package/dist/lib/git.d.ts +7 -81
- package/dist/lib/git.js +2 -199
- package/dist/lib/github/gh-overload.d.ts +0 -4
- package/dist/lib/github/gh-overload.js +2 -2
- package/dist/lib/github/project-prs.d.ts +118 -0
- package/dist/lib/github/project-prs.js +173 -0
- package/dist/lib/github/rest.d.ts +2 -1
- package/dist/lib/harness/exec-config-version.d.ts +2 -1
- package/dist/lib/harness-auth-capabilities.d.ts +5 -4
- package/dist/lib/harness-connection-test.d.ts +2 -1
- package/dist/lib/heal.d.ts +3 -20
- package/dist/lib/heal.js +2 -39
- package/dist/lib/help.d.ts +3 -2
- package/dist/lib/helper-download.d.ts +0 -12
- package/dist/lib/helper-download.js +2 -2
- package/dist/lib/helper-versions.d.ts +2 -1
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hooks/install.d.ts +8 -49
- package/dist/lib/hooks/install.js +2 -96
- package/dist/lib/hooks/match.d.ts +2 -1
- package/dist/lib/hosts/credential-transport.d.ts +0 -2
- package/dist/lib/hosts/credential-transport.js +1 -1
- package/dist/lib/hosts/dispatch.d.ts +2 -24
- package/dist/lib/hosts/dispatch.js +2 -2
- package/dist/lib/hosts/logs.d.ts +2 -1
- package/dist/lib/hosts/passthrough.d.ts +1 -1
- package/dist/lib/hosts/passthrough.js +0 -1
- package/dist/lib/hosts/progress.d.ts +0 -5
- package/dist/lib/hosts/progress.js +1 -1
- package/dist/lib/hosts/ready.d.ts +3 -4
- package/dist/lib/hosts/ready.js +0 -8
- package/dist/lib/hosts/reconcile.d.ts +2 -8
- package/dist/lib/hosts/reconcile.js +1 -1
- package/dist/lib/hosts/reconnect.d.ts +4 -11
- package/dist/lib/hosts/reconnect.js +2 -2
- package/dist/lib/hosts/registry.d.ts +1 -1
- package/dist/lib/hosts/remote-cmd.d.ts +55 -4
- package/dist/lib/hosts/remote-cmd.js +125 -8
- package/dist/lib/hosts/remote-cmd.test-fixture.d.ts +2 -0
- package/dist/lib/hosts/remote-cmd.test-fixture.js +22 -0
- package/dist/lib/hosts/session-index.d.ts +3 -2
- package/dist/lib/hosts/ssh-config.d.ts +2 -3
- package/dist/lib/hosts/ssh-config.js +0 -10
- package/dist/lib/humans.d.ts +0 -2
- package/dist/lib/humans.js +2 -2
- package/dist/lib/import.d.ts +4 -3
- package/dist/lib/installations/installation-lock.d.ts +0 -2
- package/dist/lib/installations/installation-lock.js +2 -2
- package/dist/lib/installations/launch-gate.d.ts +0 -9
- package/dist/lib/installations/launch-gate.js +1 -1
- package/dist/lib/installations/migrate.d.ts +0 -11
- package/dist/lib/installations/migrate.js +1 -1
- package/dist/lib/installations/shims.d.ts +1 -1
- package/dist/lib/installations/shims.js +2 -2
- package/dist/lib/installations/update-runtime.js +1 -1
- package/dist/lib/linear-cache.d.ts +2 -1
- package/dist/lib/linux-userns.d.ts +2 -3
- package/dist/lib/linux-userns.js +0 -4
- package/dist/lib/loop.d.ts +2 -1
- package/dist/lib/mailbox-gc.d.ts +2 -1
- package/dist/lib/mailbox-target.d.ts +2 -1
- package/dist/lib/mailbox.d.ts +0 -6
- package/dist/lib/mailbox.js +1 -1
- package/dist/lib/manifest.d.ts +0 -14
- package/dist/lib/manifest.js +2 -2
- package/dist/lib/mcp-registry.d.ts +2 -1
- package/dist/lib/mcp.js +17 -11
- package/dist/lib/memory.d.ts +2 -13
- package/dist/lib/memory.js +4 -4
- package/dist/lib/menubar/download-menubar.d.ts +0 -2
- package/dist/lib/menubar/download-menubar.js +1 -5
- package/dist/lib/menubar/install-menubar.d.ts +3 -14
- package/dist/lib/menubar/install-menubar.js +3 -3
- package/dist/lib/menubar/migrate-prefs.d.ts +53 -0
- package/dist/lib/menubar/migrate-prefs.js +168 -0
- package/dist/lib/menubar/resolve-version.d.ts +1 -9
- package/dist/lib/menubar/resolve-version.js +4 -4
- package/dist/lib/menubar/snapshot.d.ts +24 -2
- package/dist/lib/menubar/snapshot.js +26 -0
- package/dist/lib/model-tier-overrides.d.ts +3 -2
- package/dist/lib/monitors/config.d.ts +0 -2
- package/dist/lib/monitors/config.js +0 -4
- package/dist/lib/monitors/engine.d.ts +1 -1
- package/dist/lib/monitors/remote.d.ts +3 -2
- package/dist/lib/monitors/sources/webhook.d.ts +2 -15
- package/dist/lib/monitors/sources/webhook.js +1 -38
- package/dist/lib/monitors/state.d.ts +4 -7
- package/dist/lib/monitors/state.js +2 -2
- package/dist/lib/notify.d.ts +1 -1
- package/dist/lib/notify.js +1 -1
- package/dist/lib/onepassword.d.ts +5 -14
- package/dist/lib/onepassword.js +0 -64
- package/dist/lib/open-url.d.ts +3 -2
- package/dist/lib/openclaw-keychain.d.ts +4 -17
- package/dist/lib/openclaw-keychain.js +3 -33
- package/dist/lib/operator.d.ts +2 -2
- package/dist/lib/operator.js +1 -1
- package/dist/lib/output/git-output.d.ts +4 -14
- package/dist/lib/output/git-output.js +1 -1
- package/dist/lib/owner-message.d.ts +3 -29
- package/dist/lib/owner-message.js +3 -3
- package/dist/lib/packages/output-home.d.ts +2 -4
- package/dist/lib/packages/output-home.js +2 -2
- package/dist/lib/perf/db.d.ts +0 -2
- package/dist/lib/perf/db.js +2 -7
- package/dist/lib/permissions-registry.d.ts +2 -3
- package/dist/lib/permissions-registry.js +0 -4
- package/dist/lib/permissions.d.ts +6 -16
- package/dist/lib/permissions.js +2 -15
- package/dist/lib/picker.d.ts +6 -5
- package/dist/lib/placement.d.ts +3 -6
- package/dist/lib/placement.js +0 -17
- package/dist/lib/platform/posixpath.d.ts +2 -1
- package/dist/lib/platform/winpath.d.ts +2 -1
- package/dist/lib/plugins/plugin-marketplace.d.ts +2 -2
- package/dist/lib/plugins/plugin-marketplace.js +1 -1
- package/dist/lib/pr-land-detach.d.ts +2 -1
- package/dist/lib/probe.d.ts +4 -1
- package/dist/lib/probe.js +5 -2
- package/dist/lib/profiles-presets.d.ts +2 -1
- package/dist/lib/profiles.d.ts +3 -9
- package/dist/lib/profiles.js +1 -9
- package/dist/lib/project-doctor.d.ts +2 -1
- package/dist/lib/project-launch.d.ts +2 -2
- package/dist/lib/project-probe.d.ts +4 -3
- package/dist/lib/project-pull.d.ts +2 -1
- package/dist/lib/project-resources.d.ts +2 -2
- package/dist/lib/project-resources.js +1 -1
- package/dist/lib/project-root.d.ts +2 -6
- package/dist/lib/project-root.js +1 -1
- package/dist/lib/project-schedule.d.ts +2 -1
- package/dist/lib/project-status.d.ts +2 -16
- package/dist/lib/project-status.js +3 -3
- package/dist/lib/pwsh.d.ts +33 -0
- package/dist/lib/pwsh.js +56 -0
- package/dist/lib/reconcile-and-repair.d.ts +5 -4
- package/dist/lib/redact.d.ts +15 -1
- package/dist/lib/redact.js +105 -3
- package/dist/lib/refresh-coordinator.d.ts +2 -1
- package/dist/lib/refresh.d.ts +9 -4
- package/dist/lib/refresh.js +92 -72
- package/dist/lib/remote-agents-json.d.ts +3 -2
- package/dist/lib/reserved-stores.d.ts +0 -2
- package/dist/lib/reserved-stores.js +3 -5
- package/dist/lib/resource-content-diff.d.ts +0 -2
- package/dist/lib/resource-content-diff.js +1 -1
- package/dist/lib/resource-patterns.d.ts +2 -1
- package/dist/lib/resource-profiles.d.ts +2 -8
- package/dist/lib/resource-profiles.js +3 -27
- package/dist/lib/resources/workflows.d.ts +1 -1
- package/dist/lib/resources.d.ts +4 -9
- package/dist/lib/resources.js +1 -1
- package/dist/lib/routine-context.d.ts +2 -5
- package/dist/lib/routine-context.js +2 -2
- package/dist/lib/routine-notify-owner.d.ts +8 -7
- package/dist/lib/routine-notify-owner.js +5 -5
- package/dist/lib/routine-process-cleanup.d.ts +2 -1
- package/dist/lib/routine-readiness.d.ts +0 -2
- package/dist/lib/routine-readiness.js +0 -7
- package/dist/lib/routines-project.d.ts +3 -4
- package/dist/lib/routines-project.js +1 -1
- package/dist/lib/rules/compile.d.ts +3 -25
- package/dist/lib/rules/compile.js +1 -1
- package/dist/lib/rules/compose.d.ts +3 -9
- package/dist/lib/rules/rules.d.ts +4 -15
- package/dist/lib/rules/rules.js +1 -64
- package/dist/lib/run-defaults.d.ts +1 -1
- package/dist/lib/run-notify.d.ts +2 -1
- package/dist/lib/run-trace-sync.d.ts +1 -1
- package/dist/lib/run-trace-sync.js +1 -1
- package/dist/lib/scheduler.d.ts +2 -1
- package/dist/lib/scheduling/routines.d.ts +9 -21
- package/dist/lib/scheduling/routines.js +3 -46
- package/dist/lib/secrets-cli.d.ts +11 -0
- package/dist/lib/secrets-cli.js +30 -0
- package/dist/lib/secrets-client.d.ts +0 -17
- package/dist/lib/secrets-client.js +7 -28
- package/dist/lib/secrets-policy.d.ts +12 -17
- package/dist/lib/secrets-policy.js +5 -5
- package/dist/lib/secrets-types.d.ts +3 -2
- package/dist/lib/secrets-types.js +2 -1
- package/dist/lib/self-heal/checks/install-staging.js +1 -1
- package/dist/lib/self-heal/registry.d.ts +3 -2
- package/dist/lib/self-heal/types.d.ts +1 -1
- package/dist/lib/self-heal/types.js +1 -1
- package/dist/lib/self-update.d.ts +5 -5
- package/dist/lib/self-update.js +4 -4
- package/dist/lib/session/actor-sidecar.d.ts +3 -2
- package/dist/lib/session/artifacts.d.ts +0 -2
- package/dist/lib/session/artifacts.js +1 -1
- package/dist/lib/session/bash-command.d.ts +2 -7
- package/dist/lib/session/bundle.d.ts +4 -6
- package/dist/lib/session/bundle.js +1 -5
- package/dist/lib/session/cloud.d.ts +0 -4
- package/dist/lib/session/cloud.js +2 -15
- package/dist/lib/session/detached.d.ts +9 -1
- package/dist/lib/session/detached.js +31 -2
- package/dist/lib/session/digest.d.ts +2 -2
- package/dist/lib/session/digest.js +1 -1
- package/dist/lib/session/fork.d.ts +3 -2
- package/dist/lib/session/highlights.d.ts +6 -5
- package/dist/lib/session/hook-sessions.d.ts +2 -1
- package/dist/lib/session/host-link.d.ts +2 -1
- package/dist/lib/session/inject.d.ts +1 -1
- package/dist/lib/session/inject.js +1 -1
- package/dist/lib/session/insights.d.ts +3 -15
- package/dist/lib/session/insights.js +2 -2
- package/dist/lib/session/local-tmux-attach.d.ts +2 -18
- package/dist/lib/session/local-tmux-attach.js +1 -1
- package/dist/lib/session/migrations.d.ts +0 -1
- package/dist/lib/session/migrations.js +1 -1
- package/dist/lib/session/mirror.d.ts +5 -8
- package/dist/lib/session/mirror.js +2 -2
- package/dist/lib/session/parse.d.ts +1 -32
- package/dist/lib/session/parse.js +4 -4
- package/dist/lib/session/presence.d.ts +2 -1
- package/dist/lib/session/prompt.d.ts +3 -2
- package/dist/lib/session/prompt.js +38 -1
- package/dist/lib/session/recovery.d.ts +3 -2
- package/dist/lib/session/remote/peer-stream.d.ts +26 -7
- package/dist/lib/session/remote/peer-stream.js +35 -8
- package/dist/lib/session/remote/remote-bundle.d.ts +2 -1
- package/dist/lib/session/remote/remote-list.d.ts +5 -5
- package/dist/lib/session/remote/remote.d.ts +4 -3
- package/dist/lib/session/remote/watch.d.ts +2 -7
- package/dist/lib/session/remote/watch.js +3 -3
- package/dist/lib/session/remote-active.d.ts +2 -1
- package/dist/lib/session/render.d.ts +2 -2
- package/dist/lib/session/render.js +1 -1
- package/dist/lib/session/resume-owner.d.ts +1 -1
- package/dist/lib/session/resume-owner.js +1 -1
- package/dist/lib/session/run-names.d.ts +2 -1
- package/dist/lib/session/session-cache.d.ts +7 -26
- package/dist/lib/session/session-cache.js +2 -8
- package/dist/lib/session/share-html.d.ts +1 -21
- package/dist/lib/session/share-html.js +1 -1
- package/dist/lib/session/shell-programs.d.ts +2 -1
- package/dist/lib/session/state.d.ts +41 -8
- package/dist/lib/session/state.js +112 -11
- package/dist/lib/session/stream-render.d.ts +2 -1
- package/dist/lib/session/sync/agents.d.ts +0 -4
- package/dist/lib/session/sync/agents.js +0 -0
- package/dist/lib/session/sync/backend.d.ts +8 -8
- package/dist/lib/session/sync/backend.js +3 -3
- package/dist/lib/session/sync/managed-config.d.ts +0 -8
- package/dist/lib/session/sync/managed-key.d.ts +0 -2
- package/dist/lib/session/sync/managed-key.js +1 -1
- package/dist/lib/session/sync/provision.d.ts +1 -1
- package/dist/lib/session/sync/provision.js +2 -2
- package/dist/lib/session/sync/r2.d.ts +4 -1
- package/dist/lib/session/sync/r2.js +4 -7
- package/dist/lib/session/sync/transcript-crypto.d.ts +2 -1
- package/dist/lib/session/tail.d.ts +2 -1
- package/dist/lib/session/team-filter.d.ts +1 -1
- package/dist/lib/session/throughput.d.ts +2 -3
- package/dist/lib/session/throughput.js +1 -1
- package/dist/lib/session/timeline-pass.d.ts +3 -42
- package/dist/lib/session/timeline-pass.js +4 -4
- package/dist/lib/session/timeline.d.ts +3 -13
- package/dist/lib/session/timeline.js +3 -3
- package/dist/lib/session/tool-calls.d.ts +2 -2
- package/dist/lib/session/tool-calls.js +1 -1
- package/dist/lib/session/tool-index.d.ts +0 -8
- package/dist/lib/session/tool-index.js +2 -2
- package/dist/lib/session/tool-store.d.ts +2 -1
- package/dist/lib/session/trajectory-compare.d.ts +2 -1
- package/dist/lib/session/trajectory-lineage.d.ts +2 -1
- package/dist/lib/session/trajectory-text.d.ts +3 -2
- package/dist/lib/session/trajectory.d.ts +2 -1
- package/dist/lib/session/viewing-in.d.ts +2 -1
- package/dist/lib/sessions-client.js +0 -3
- package/dist/lib/settings-manifest.d.ts +2 -1
- package/dist/lib/setup-tool-install.d.ts +3 -0
- package/dist/lib/setup-tool-install.js +26 -0
- package/dist/lib/setup-tool-status.d.ts +22 -0
- package/dist/lib/setup-tool-status.js +215 -0
- package/dist/lib/share-runtime.d.ts +11 -0
- package/dist/lib/share-runtime.js +63 -0
- package/dist/lib/shim-heal.d.ts +1 -5
- package/dist/lib/shim-heal.js +0 -6
- package/dist/lib/smart-launch.d.ts +5 -10
- package/dist/lib/smart-launch.js +4 -12
- package/dist/lib/snapshot.d.ts +3 -2
- package/dist/lib/ssh-exec.d.ts +49 -4
- package/dist/lib/ssh-exec.js +119 -0
- package/dist/lib/ssh-tunnel.d.ts +3 -2
- package/dist/lib/staleness/checkers/permissions.d.ts +0 -2
- package/dist/lib/staleness/checkers/permissions.js +1 -1
- package/dist/lib/staleness/fingerprint.d.ts +0 -7
- package/dist/lib/staleness/fingerprint.js +1 -1
- package/dist/lib/staleness/prune.d.ts +3 -2
- package/dist/lib/staleness/registry.d.ts +1 -1
- package/dist/lib/staleness/writers/sources.d.ts +0 -8
- package/dist/lib/staleness/writers/sources.js +1 -1
- package/dist/lib/startup/command-registry.d.ts +6 -4
- package/dist/lib/startup/command-registry.js +11 -8
- package/dist/lib/state.d.ts +1 -3
- package/dist/lib/state.js +3 -6
- package/dist/lib/storage/selection.d.ts +2 -2
- package/dist/lib/storage/selection.js +2 -2
- package/dist/lib/subagents-registry.d.ts +4 -3
- package/dist/lib/subagents.d.ts +2 -1
- package/dist/lib/subagents.js +3 -2
- package/dist/lib/summarizer/pass.d.ts +3 -6
- package/dist/lib/summarizer/pass.js +2 -2
- package/dist/lib/summarizer/summarize.d.ts +4 -3
- package/dist/lib/sync-passphrase.d.ts +3 -2
- package/dist/lib/sync-status.d.ts +3 -16
- package/dist/lib/sync-status.js +2 -2
- package/dist/lib/sync-umbrella.d.ts +9 -3
- package/dist/lib/sync-umbrella.js +18 -10
- package/dist/lib/system-run-sync.d.ts +2 -1
- package/dist/lib/teams/agents.d.ts +2 -4
- package/dist/lib/teams/agents.js +1 -1
- package/dist/lib/teams/forEach.d.ts +3 -2
- package/dist/lib/teams/pr-watch.d.ts +4 -11
- package/dist/lib/teams/pr-watch.js +4 -4
- package/dist/lib/teams/registry.d.ts +2 -3
- package/dist/lib/teams/registry.js +1 -1
- package/dist/lib/teams/remoteWorktree.d.ts +0 -16
- package/dist/lib/teams/remoteWorktree.js +3 -3
- package/dist/lib/teams/scheduler.d.ts +6 -5
- package/dist/lib/teams/scheduler.js +1 -1
- package/dist/lib/teams/supervisor.d.ts +4 -3
- package/dist/lib/teams/worktree.d.ts +0 -9
- package/dist/lib/teams/worktree.js +0 -32
- package/dist/lib/term-client.d.ts +44 -0
- package/dist/lib/term-client.js +117 -0
- package/dist/lib/terminal/inject.d.ts +3 -16
- package/dist/lib/terminal/inject.js +1 -29
- package/dist/lib/terminal/resolve.d.ts +3 -9
- package/dist/lib/terminal/resolve.js +3 -7
- package/dist/lib/tmux/binary.d.ts +2 -1
- package/dist/lib/tmux/orphan-reap.d.ts +6 -7
- package/dist/lib/tmux/orphan-reap.js +1 -1
- package/dist/lib/tmux/session.d.ts +4 -3
- package/dist/lib/traces/backend.d.ts +1 -2
- package/dist/lib/traces/backend.js +1 -2
- package/dist/lib/traces/classify.d.ts +3 -2
- package/dist/lib/traces/config.d.ts +0 -8
- package/dist/lib/traces/insights.d.ts +2 -1
- package/dist/lib/traces/phenotype.d.ts +3 -3
- package/dist/lib/traces/provision.d.ts +2 -4
- package/dist/lib/traces/provision.js +3 -3
- package/dist/lib/traces/schema2-build.d.ts +1 -1
- package/dist/lib/traces/schema2-danger.d.ts +2 -1
- package/dist/lib/traces/schema2.d.ts +5 -4
- package/dist/lib/traces/segments.d.ts +4 -20
- package/dist/lib/traces/segments.js +3 -3
- package/dist/lib/traces/sync.d.ts +2 -3
- package/dist/lib/traces/sync.js +1 -1
- package/dist/lib/triggers/handlers.d.ts +4 -13
- package/dist/lib/triggers/handlers.js +1 -1
- package/dist/lib/triggers/webhook.d.ts +5 -27
- package/dist/lib/triggers/webhook.js +4 -4
- package/dist/lib/types.d.ts +11 -9
- package/dist/lib/usage-refresh.d.ts +4 -10
- package/dist/lib/usage-refresh.js +3 -8
- package/dist/lib/verbs.d.ts +2 -1
- package/dist/lib/version-duplicates.d.ts +2 -3
- package/dist/lib/version-duplicates.js +3 -33
- package/dist/lib/version.d.ts +2 -1
- package/dist/lib/warn-unpushed.d.ts +2 -1
- package/dist/lib/watchdog/history.d.ts +3 -2
- package/dist/lib/watchdog/log.d.ts +0 -6
- package/dist/lib/watchdog/log.js +1 -1
- package/dist/lib/watchdog/rotate.d.ts +2 -26
- package/dist/lib/watchdog/rotate.js +4 -12
- package/dist/lib/watchdog/runner.d.ts +0 -7
- package/dist/lib/watchdog/runner.js +4 -4
- package/dist/lib/watchdog/service.d.ts +2 -2
- package/dist/lib/watchdog/service.js +1 -1
- package/dist/lib/watchdog/watchdog-agent.d.ts +2 -1
- package/dist/lib/watchdog/watchdog.d.ts +2 -1
- package/dist/lib/watchdog/watchdogTail.d.ts +2 -1
- package/dist/lib/workflows-registry.d.ts +3 -2
- package/dist/lib/workflows.d.ts +4 -7
- package/dist/lib/workflows.js +1 -1
- package/dist/lib/worktree/held.d.ts +4 -28
- package/dist/lib/worktree/held.js +3 -3
- package/package.json +3 -5
- package/scripts/postinstall.js +5 -4
- package/dist/commands/artifacts-setup.d.ts +0 -53
- package/dist/commands/artifacts-setup.js +0 -161
- package/dist/commands/artifacts.d.ts +0 -18
- package/dist/commands/artifacts.js +0 -58
- package/dist/commands/attach.d.ts +0 -12
- package/dist/commands/attach.js +0 -86
- package/dist/commands/auth-mint.d.ts +0 -12
- package/dist/commands/auth-mint.js +0 -108
- package/dist/commands/pty.d.ts +0 -20
- package/dist/commands/pty.js +0 -404
- package/dist/commands/reconnect.d.ts +0 -46
- package/dist/commands/reconnect.js +0 -115
- package/dist/commands/share.d.ts +0 -293
- package/dist/commands/share.js +0 -1424
- package/dist/lib/config-machine-keys.d.ts +0 -14
- package/dist/lib/config-machine-keys.js +0 -21
- package/dist/lib/pty-client.d.ts +0 -49
- package/dist/lib/pty-client.js +0 -315
- package/dist/lib/pty-server.d.ts +0 -59
- package/dist/lib/pty-server.js +0 -653
- package/dist/lib/share/analytics.d.ts +0 -13
- package/dist/lib/share/analytics.js +0 -45
- package/dist/lib/share/backend.d.ts +0 -120
- package/dist/lib/share/backend.js +0 -176
- package/dist/lib/share/capture.d.ts +0 -31
- package/dist/lib/share/capture.js +0 -174
- package/dist/lib/share/config.d.ts +0 -72
- package/dist/lib/share/config.js +0 -211
- package/dist/lib/share/delete.d.ts +0 -122
- package/dist/lib/share/delete.js +0 -173
- package/dist/lib/share/html.d.ts +0 -22
- package/dist/lib/share/html.js +0 -88
- package/dist/lib/share/http-error.d.ts +0 -52
- package/dist/lib/share/http-error.js +0 -65
- package/dist/lib/share/og.d.ts +0 -25
- package/dist/lib/share/og.js +0 -84
- package/dist/lib/share/provision.d.ts +0 -127
- package/dist/lib/share/provision.js +0 -285
- package/dist/lib/share/publish.d.ts +0 -388
- package/dist/lib/share/publish.js +0 -818
- package/dist/lib/share/worker-template.d.ts +0 -27
- package/dist/lib/share/worker-template.js +0 -2424
- package/dist/lib/storage/index.d.ts +0 -14
- package/dist/lib/storage/index.js +0 -14
- package/dist/lib/storage/visibility.d.ts +0 -82
- package/dist/lib/storage/visibility.js +0 -99
package/dist/commands/pty.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PTY Commands
|
|
3
|
-
*
|
|
4
|
-
* CLI commands for managing interactive PTY sessions.
|
|
5
|
-
* Auto-starts the sidecar server on first use.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* agents pty start [--rows 24 --cols 120 --shell zsh --cwd /path]
|
|
9
|
-
* agents pty exec <id> <command>
|
|
10
|
-
* agents pty read <id> [--ms 200]
|
|
11
|
-
* agents pty write <id> <input>
|
|
12
|
-
* agents pty screen <id>
|
|
13
|
-
* agents pty signal <id> [INT|TERM|KILL]
|
|
14
|
-
* agents pty list
|
|
15
|
-
* agents pty stop <id>
|
|
16
|
-
* agents pty server [start|stop|status]
|
|
17
|
-
*/
|
|
18
|
-
import chalk from 'chalk';
|
|
19
|
-
import { ptyRequest, unescapeInput } from '../lib/pty-client.js';
|
|
20
|
-
import { isPtyServerRunning, runPtyServer, getPtyPidPath, getPtyLogPath } from '../lib/pty-server.js';
|
|
21
|
-
import * as fs from 'fs';
|
|
22
|
-
import { setHelpSections } from '../lib/help.js';
|
|
23
|
-
/** Register the `agents pty` command tree. */
|
|
24
|
-
export function registerPtyCommands(program) {
|
|
25
|
-
const pty = program
|
|
26
|
-
.command('pty')
|
|
27
|
-
.description('Drive interactive terminal programs from AI agents. Use this for REPLs, TUIs, or anything needing a real terminal.');
|
|
28
|
-
setHelpSections(pty, {
|
|
29
|
-
examples: `
|
|
30
|
-
# Start a session (returns a session ID)
|
|
31
|
-
SID=$(agents pty start)
|
|
32
|
-
|
|
33
|
-
# Run a command (non-blocking)
|
|
34
|
-
agents pty exec $SID "python3"
|
|
35
|
-
|
|
36
|
-
# Wait, then see what's on screen (clean text, no ANSI)
|
|
37
|
-
sleep 1 && agents pty screen $SID
|
|
38
|
-
|
|
39
|
-
# Type input (supports escapes: \\n \\t \\e \\xHH)
|
|
40
|
-
agents pty write $SID "print('hello')\\n"
|
|
41
|
-
|
|
42
|
-
# Read again
|
|
43
|
-
agents pty screen $SID
|
|
44
|
-
|
|
45
|
-
# Clean up
|
|
46
|
-
agents pty stop $SID
|
|
47
|
-
`,
|
|
48
|
-
notes: `
|
|
49
|
-
Use cases:
|
|
50
|
-
- Drive REPLs (python, node, irb) from agent code
|
|
51
|
-
- Automate TUI programs (npm init, interactive wizards)
|
|
52
|
-
- Test CLI tools that require a real PTY
|
|
53
|
-
- Run the 'agents' CLI itself from another agent
|
|
54
|
-
|
|
55
|
-
The PTY server auto-starts on first use and runs in the background.
|
|
56
|
-
Health: 'agents pty server status'.
|
|
57
|
-
`,
|
|
58
|
-
});
|
|
59
|
-
// --- Session lifecycle ---
|
|
60
|
-
const startCmd = pty
|
|
61
|
-
.command('start')
|
|
62
|
-
.description('Start a new PTY session and return its ID. The session persists until you stop it.')
|
|
63
|
-
.option('-r, --rows <n>', 'Terminal height in rows', '24')
|
|
64
|
-
.option('-c, --cols <n>', 'Terminal width in columns', '120')
|
|
65
|
-
.option('-s, --shell <shell>', 'Shell to launch (defaults to $SHELL, e.g., zsh, bash)')
|
|
66
|
-
.option('-d, --cwd <dir>', 'Working directory for the shell')
|
|
67
|
-
.option('--json', 'Output full session metadata as JSON');
|
|
68
|
-
setHelpSections(startCmd, {
|
|
69
|
-
examples: `
|
|
70
|
-
# Start a session and capture its ID
|
|
71
|
-
SID=$(agents pty start)
|
|
72
|
-
|
|
73
|
-
# Start a Python REPL in a specific directory
|
|
74
|
-
agents pty start --shell python3 --cwd /tmp
|
|
75
|
-
|
|
76
|
-
# Start a wider terminal for TUI programs
|
|
77
|
-
agents pty start --cols 160 --rows 40
|
|
78
|
-
`,
|
|
79
|
-
});
|
|
80
|
-
startCmd.action(async (opts) => {
|
|
81
|
-
const params = {
|
|
82
|
-
rows: parseInt(opts.rows, 10),
|
|
83
|
-
cols: parseInt(opts.cols, 10),
|
|
84
|
-
};
|
|
85
|
-
if (opts.shell)
|
|
86
|
-
params.shell = opts.shell;
|
|
87
|
-
if (opts.cwd)
|
|
88
|
-
params.cwd = opts.cwd;
|
|
89
|
-
const res = await ptyRequest('start', undefined, params);
|
|
90
|
-
if (!res.ok) {
|
|
91
|
-
console.error(chalk.red(res.error));
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
if (opts.json) {
|
|
95
|
-
console.log(JSON.stringify(res));
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
console.log(res.id);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const execCmd = pty
|
|
102
|
-
.command('exec <id> <command>')
|
|
103
|
-
.description('Send a command to a PTY session. Returns immediately (non-blocking). Use screen or read to see output.')
|
|
104
|
-
.option('--wait <ms>', 'Wait this many milliseconds then return the screen (convenience for quick commands)', '0')
|
|
105
|
-
.option('--json', 'Output as JSON');
|
|
106
|
-
setHelpSections(execCmd, {
|
|
107
|
-
examples: `
|
|
108
|
-
# Run a command and return immediately
|
|
109
|
-
agents pty exec $SID "ls -la"
|
|
110
|
-
|
|
111
|
-
# Run a command and wait 500ms to see output
|
|
112
|
-
agents pty exec $SID "git status" --wait 500
|
|
113
|
-
|
|
114
|
-
# Start a long-running process (returns right away)
|
|
115
|
-
agents pty exec $SID "npm run dev"
|
|
116
|
-
`,
|
|
117
|
-
});
|
|
118
|
-
execCmd.action(async (id, command, opts) => {
|
|
119
|
-
const res = await ptyRequest('exec', id, { command });
|
|
120
|
-
if (!res.ok) {
|
|
121
|
-
console.error(chalk.red(res.error));
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
const waitMs = parseInt(opts.wait, 10);
|
|
125
|
-
if (waitMs > 0) {
|
|
126
|
-
// Wait then return screen
|
|
127
|
-
await new Promise(r => setTimeout(r, waitMs));
|
|
128
|
-
const screen = await ptyRequest('screen', id);
|
|
129
|
-
if (opts.json) {
|
|
130
|
-
console.log(JSON.stringify(screen));
|
|
131
|
-
}
|
|
132
|
-
else if (screen.ok) {
|
|
133
|
-
console.log(screen.screen);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (opts.json) {
|
|
137
|
-
console.log(JSON.stringify(res));
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
const readCmd = pty
|
|
141
|
-
.command('read <id>')
|
|
142
|
-
.description('Read raw output from the PTY (includes ANSI codes). Use screen for clean text instead.')
|
|
143
|
-
.option('-m, --ms <ms>', 'Wait up to this many milliseconds for new output (50-5000)', '200')
|
|
144
|
-
.option('--json', 'Output as JSON');
|
|
145
|
-
setHelpSections(readCmd, {
|
|
146
|
-
examples: `
|
|
147
|
-
# Read pending output (wait up to 200ms)
|
|
148
|
-
agents pty read $SID
|
|
149
|
-
|
|
150
|
-
# Read with longer wait for slow commands
|
|
151
|
-
agents pty read $SID --ms 1000
|
|
152
|
-
`,
|
|
153
|
-
});
|
|
154
|
-
readCmd.action(async (id, opts) => {
|
|
155
|
-
const ms = parseInt(opts.ms, 10);
|
|
156
|
-
const res = await ptyRequest('read', id, { ms });
|
|
157
|
-
if (!res.ok) {
|
|
158
|
-
console.error(chalk.red(res.error));
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
if (opts.json) {
|
|
162
|
-
console.log(JSON.stringify(res));
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
if (res.output)
|
|
166
|
-
process.stdout.write(res.output);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
const writeCmd = pty
|
|
170
|
-
.command('write <id> <input>')
|
|
171
|
-
.description('Send keystrokes to the PTY (like typing into the terminal). Processes escape sequences by default.')
|
|
172
|
-
.option('--raw', 'Send input literally without processing \\n \\t \\e \\xHH escape codes')
|
|
173
|
-
.option('--json', 'Output as JSON');
|
|
174
|
-
setHelpSections(writeCmd, {
|
|
175
|
-
examples: `
|
|
176
|
-
# Send Enter key
|
|
177
|
-
agents pty write $SID "\\n"
|
|
178
|
-
|
|
179
|
-
# Type a command and press Enter
|
|
180
|
-
agents pty write $SID "ls -la\\n"
|
|
181
|
-
|
|
182
|
-
# Send Ctrl-C (interrupt signal)
|
|
183
|
-
agents pty write $SID "\\x03"
|
|
184
|
-
|
|
185
|
-
# Send Escape key
|
|
186
|
-
agents pty write $SID "\\e"
|
|
187
|
-
|
|
188
|
-
# Send literal backslash-n (not newline)
|
|
189
|
-
agents pty write $SID "\\\\n" --raw
|
|
190
|
-
`,
|
|
191
|
-
});
|
|
192
|
-
writeCmd.action(async (id, input, opts) => {
|
|
193
|
-
const processed = opts.raw ? input : unescapeInput(input);
|
|
194
|
-
const res = await ptyRequest('write', id, { input: processed });
|
|
195
|
-
if (!res.ok) {
|
|
196
|
-
console.error(chalk.red(res.error));
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
if (opts.json) {
|
|
200
|
-
console.log(JSON.stringify(res));
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
const screenCmd = pty
|
|
204
|
-
.command('screen <id>')
|
|
205
|
-
.description('Render the terminal screen as clean text (no ANSI codes). This is what a human sees looking at the terminal.')
|
|
206
|
-
.option('--json', 'Output as JSON (includes cursor position and dimensions)');
|
|
207
|
-
setHelpSections(screenCmd, {
|
|
208
|
-
examples: `
|
|
209
|
-
# See what's currently on screen
|
|
210
|
-
agents pty screen $SID
|
|
211
|
-
|
|
212
|
-
# Get screen with cursor position as JSON
|
|
213
|
-
agents pty screen $SID --json
|
|
214
|
-
`,
|
|
215
|
-
notes: `
|
|
216
|
-
Use this (not read) when you want clean text for an LLM to parse.
|
|
217
|
-
`,
|
|
218
|
-
});
|
|
219
|
-
screenCmd.action(async (id, opts) => {
|
|
220
|
-
const res = await ptyRequest('screen', id);
|
|
221
|
-
if (!res.ok) {
|
|
222
|
-
console.error(chalk.red(res.error));
|
|
223
|
-
process.exit(1);
|
|
224
|
-
}
|
|
225
|
-
if (opts.json) {
|
|
226
|
-
console.log(JSON.stringify(res));
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
console.log(res.screen);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
const signalCmd = pty
|
|
233
|
-
.command('signal <id> [signal]')
|
|
234
|
-
.description('Send a POSIX signal to the running process. Defaults to INT (Ctrl-C).');
|
|
235
|
-
setHelpSections(signalCmd, {
|
|
236
|
-
examples: `
|
|
237
|
-
# Send Ctrl-C (interrupt)
|
|
238
|
-
agents pty signal $SID INT
|
|
239
|
-
|
|
240
|
-
# Terminate gracefully
|
|
241
|
-
agents pty signal $SID TERM
|
|
242
|
-
|
|
243
|
-
# Force kill
|
|
244
|
-
agents pty signal $SID KILL
|
|
245
|
-
`,
|
|
246
|
-
});
|
|
247
|
-
signalCmd.action(async (id, signal) => {
|
|
248
|
-
const res = await ptyRequest('signal', id, { signal: signal || 'INT' });
|
|
249
|
-
if (!res.ok) {
|
|
250
|
-
console.error(chalk.red(res.error));
|
|
251
|
-
process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
pty
|
|
255
|
-
.command('resize <id>')
|
|
256
|
-
.description('Resize a PTY session')
|
|
257
|
-
.option('-r, --rows <n>', 'Terminal rows')
|
|
258
|
-
.option('-c, --cols <n>', 'Terminal columns')
|
|
259
|
-
.action(async (id, opts) => {
|
|
260
|
-
const params = {};
|
|
261
|
-
if (opts.rows)
|
|
262
|
-
params.rows = parseInt(opts.rows, 10);
|
|
263
|
-
if (opts.cols)
|
|
264
|
-
params.cols = parseInt(opts.cols, 10);
|
|
265
|
-
const res = await ptyRequest('resize', id, params);
|
|
266
|
-
if (!res.ok) {
|
|
267
|
-
console.error(chalk.red(res.error));
|
|
268
|
-
process.exit(1);
|
|
269
|
-
}
|
|
270
|
-
console.log(`${res.cols}x${res.rows}`);
|
|
271
|
-
});
|
|
272
|
-
const stopCmd = pty
|
|
273
|
-
.command('stop <id>')
|
|
274
|
-
.description('Stop a PTY session and clean up. The session ID becomes invalid.');
|
|
275
|
-
setHelpSections(stopCmd, {
|
|
276
|
-
examples: `
|
|
277
|
-
# Stop a session by ID
|
|
278
|
-
agents pty stop $SID
|
|
279
|
-
`,
|
|
280
|
-
});
|
|
281
|
-
stopCmd.action(async (id) => {
|
|
282
|
-
const res = await ptyRequest('stop', id);
|
|
283
|
-
if (!res.ok) {
|
|
284
|
-
console.error(chalk.red(res.error));
|
|
285
|
-
process.exit(1);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
// --- Session listing ---
|
|
289
|
-
const listCmd = pty
|
|
290
|
-
.command('list')
|
|
291
|
-
.description('List all active PTY sessions (running or idle).')
|
|
292
|
-
.option('--json', 'Output as JSON');
|
|
293
|
-
setHelpSections(listCmd, {
|
|
294
|
-
examples: `
|
|
295
|
-
# List all active sessions
|
|
296
|
-
agents pty list
|
|
297
|
-
`,
|
|
298
|
-
});
|
|
299
|
-
listCmd.action(async (opts) => {
|
|
300
|
-
const res = await ptyRequest('list');
|
|
301
|
-
if (!res.ok) {
|
|
302
|
-
console.error(chalk.red(res.error));
|
|
303
|
-
process.exit(1);
|
|
304
|
-
}
|
|
305
|
-
if (opts.json) {
|
|
306
|
-
console.log(JSON.stringify(res.sessions));
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (res.sessions.length === 0) {
|
|
310
|
-
console.log(chalk.gray('No active PTY sessions'));
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
for (const s of res.sessions) {
|
|
314
|
-
const age = formatAge(Date.now() - s.started_at);
|
|
315
|
-
const status = s.exited
|
|
316
|
-
? chalk.red(`exited (${s.exit_code})`)
|
|
317
|
-
: s.app_active
|
|
318
|
-
? chalk.yellow(`running: ${s.active_command}`)
|
|
319
|
-
: chalk.green('idle');
|
|
320
|
-
console.log(` ${chalk.bold(s.id)} pid=${s.pid} ${s.shell} ${s.cols}x${s.rows} ${age} ${status}`);
|
|
321
|
-
console.log(` ${chalk.gray(s.cwd)}`);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
// --- Server management ---
|
|
325
|
-
const serverCmd = pty
|
|
326
|
-
.command('server')
|
|
327
|
-
.description('Manage the PTY sidecar server (auto-starts on first use, usually you do not need this).');
|
|
328
|
-
serverCmd
|
|
329
|
-
.command('start')
|
|
330
|
-
.description('Start the PTY server manually (auto-starts on first pty command anyway).')
|
|
331
|
-
.action(async () => {
|
|
332
|
-
if (isPtyServerRunning()) {
|
|
333
|
-
const pidPath = getPtyPidPath();
|
|
334
|
-
const pid = fs.existsSync(pidPath) ? fs.readFileSync(pidPath, 'utf-8').trim() : '?';
|
|
335
|
-
console.log(chalk.yellow(`PTY server already running (PID: ${pid})`));
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
// Use ptyRequest which auto-starts the server
|
|
339
|
-
const res = await ptyRequest('ping');
|
|
340
|
-
if (res.ok) {
|
|
341
|
-
console.log(chalk.green(`PTY server started (PID: ${res.pid})`));
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
console.error(chalk.red('Failed to start PTY server'));
|
|
345
|
-
process.exit(1);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
serverCmd
|
|
349
|
-
.command('stop')
|
|
350
|
-
.description('Stop the PTY server and kill all active sessions.')
|
|
351
|
-
.action(async () => {
|
|
352
|
-
if (!isPtyServerRunning()) {
|
|
353
|
-
console.log(chalk.yellow('PTY server is not running'));
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
const pidPath = getPtyPidPath();
|
|
357
|
-
try {
|
|
358
|
-
const pid = parseInt(fs.readFileSync(pidPath, 'utf-8').trim(), 10);
|
|
359
|
-
process.kill(pid, 'SIGTERM');
|
|
360
|
-
console.log(chalk.green('PTY server stopped'));
|
|
361
|
-
}
|
|
362
|
-
catch {
|
|
363
|
-
console.error(chalk.red('Failed to stop PTY server'));
|
|
364
|
-
process.exit(1);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
serverCmd
|
|
368
|
-
.command('status')
|
|
369
|
-
.description('Check if the PTY server is running and how many sessions are active.')
|
|
370
|
-
.action(async () => {
|
|
371
|
-
const running = isPtyServerRunning();
|
|
372
|
-
console.log(` Status: ${running ? chalk.green('running') : chalk.gray('stopped')}`);
|
|
373
|
-
if (running) {
|
|
374
|
-
try {
|
|
375
|
-
const res = await ptyRequest('ping');
|
|
376
|
-
if (res.ok) {
|
|
377
|
-
console.log(` PID: ${res.pid}`);
|
|
378
|
-
console.log(` Sessions: ${res.sessions}`);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
catch { }
|
|
382
|
-
}
|
|
383
|
-
const logPath = getPtyLogPath();
|
|
384
|
-
console.log(` Log: ${logPath}`);
|
|
385
|
-
});
|
|
386
|
-
// Internal: run server in foreground (spawned by auto-start)
|
|
387
|
-
pty
|
|
388
|
-
.command('_server', { hidden: true })
|
|
389
|
-
.description('Run PTY server (internal)')
|
|
390
|
-
.action(async () => {
|
|
391
|
-
await runPtyServer();
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
/** Format a millisecond duration as a compact human-readable string (e.g. "5m", "2h 30m"). */
|
|
395
|
-
function formatAge(ms) {
|
|
396
|
-
const secs = Math.floor(ms / 1000);
|
|
397
|
-
if (secs < 60)
|
|
398
|
-
return `${secs}s`;
|
|
399
|
-
const mins = Math.floor(secs / 60);
|
|
400
|
-
if (mins < 60)
|
|
401
|
-
return `${mins}m`;
|
|
402
|
-
const hours = Math.floor(mins / 60);
|
|
403
|
-
return `${hours}h ${mins % 60}m`;
|
|
404
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `agents reconnect [session-id]` — get me back into an agent terminal whose ssh
|
|
3
|
-
* link dropped.
|
|
4
|
-
*
|
|
5
|
-
* The auto-reconnect in lib/hosts/reconnect.ts already re-attaches a live remote
|
|
6
|
-
* pane over its own bounded backoff on a transient blink. This is the MANUAL
|
|
7
|
-
* recovery for after it gave up — a sustained outage, or a VS Code terminal tab
|
|
8
|
-
* that closed with the dead ssh client. One verb that always tries hardest to put
|
|
9
|
-
* you back into that agent: attach the live pane if it still exists, else resume
|
|
10
|
-
* the session; live pane > resumed copy > a clear message about what was lost.
|
|
11
|
-
*
|
|
12
|
-
* It delegates to `focus`, which already does exactly attach-else-resume for a
|
|
13
|
-
* resolved id ({@link focusAction} → `focusResolvedSession`), so there is no second
|
|
14
|
-
* recovery path to keep in sync. What `reconnect` adds is the recovery framing and,
|
|
15
|
-
* with no id, targeting the MOST RECENT session in this shell's directory — the one
|
|
16
|
-
* that most likely just dropped — instead of opening the full fleet picker.
|
|
17
|
-
*/
|
|
18
|
-
import type { Command } from 'commander';
|
|
19
|
-
import type { SessionMeta } from '../lib/session/types.js';
|
|
20
|
-
/**
|
|
21
|
-
* The recency signal a no-id reconnect targets: last activity if the scan
|
|
22
|
-
* computed one, else the creation time. A row with neither parseable sorts last.
|
|
23
|
-
* Pure so target selection is unit-tested without the scanner.
|
|
24
|
-
*/
|
|
25
|
-
export declare function sessionRecency(s: Pick<SessionMeta, 'lastActivity' | 'timestamp'>): number;
|
|
26
|
-
/**
|
|
27
|
-
* Pick the session to reconnect when the user gave no id: the most recently
|
|
28
|
-
* active one in scope — the terminal that most likely just dropped. Pure; returns
|
|
29
|
-
* undefined for an empty scope so the caller can print guidance.
|
|
30
|
-
*/
|
|
31
|
-
export declare function pickMostRecentSession(sessions: SessionMeta[]): SessionMeta | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve the no-id target: prefer the most recent session started from THIS
|
|
34
|
-
* directory (the shell the user is reconnecting from), falling back to the most
|
|
35
|
-
* recent session anywhere when the current directory has none. Best-effort — a
|
|
36
|
-
* discovery failure yields undefined, never throws. Injectable `discover` keeps
|
|
37
|
-
* the two-step scope preference testable without touching the real scanner.
|
|
38
|
-
*/
|
|
39
|
-
export declare function resolveRecentTarget(cwd: string, discover?: (opts: {
|
|
40
|
-
cwd?: string;
|
|
41
|
-
all?: boolean;
|
|
42
|
-
since?: string;
|
|
43
|
-
limit?: number;
|
|
44
|
-
}) => Promise<SessionMeta[]>): Promise<SessionMeta | undefined>;
|
|
45
|
-
export declare function reconnectAction(id: string | undefined): Promise<void>;
|
|
46
|
-
export declare function registerReconnectCommand(program: Command): void;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `agents reconnect [session-id]` — get me back into an agent terminal whose ssh
|
|
3
|
-
* link dropped.
|
|
4
|
-
*
|
|
5
|
-
* The auto-reconnect in lib/hosts/reconnect.ts already re-attaches a live remote
|
|
6
|
-
* pane over its own bounded backoff on a transient blink. This is the MANUAL
|
|
7
|
-
* recovery for after it gave up — a sustained outage, or a VS Code terminal tab
|
|
8
|
-
* that closed with the dead ssh client. One verb that always tries hardest to put
|
|
9
|
-
* you back into that agent: attach the live pane if it still exists, else resume
|
|
10
|
-
* the session; live pane > resumed copy > a clear message about what was lost.
|
|
11
|
-
*
|
|
12
|
-
* It delegates to `focus`, which already does exactly attach-else-resume for a
|
|
13
|
-
* resolved id ({@link focusAction} → `focusResolvedSession`), so there is no second
|
|
14
|
-
* recovery path to keep in sync. What `reconnect` adds is the recovery framing and,
|
|
15
|
-
* with no id, targeting the MOST RECENT session in this shell's directory — the one
|
|
16
|
-
* that most likely just dropped — instead of opening the full fleet picker.
|
|
17
|
-
*/
|
|
18
|
-
import chalk from 'chalk';
|
|
19
|
-
import { focusAction } from './focus.js';
|
|
20
|
-
import { discoverSessions } from '../lib/session/discover.js';
|
|
21
|
-
import { setHelpSections } from '../lib/help.js';
|
|
22
|
-
/**
|
|
23
|
-
* The recency signal a no-id reconnect targets: last activity if the scan
|
|
24
|
-
* computed one, else the creation time. A row with neither parseable sorts last.
|
|
25
|
-
* Pure so target selection is unit-tested without the scanner.
|
|
26
|
-
*/
|
|
27
|
-
export function sessionRecency(s) {
|
|
28
|
-
const t = Date.parse(s.lastActivity ?? s.timestamp ?? '');
|
|
29
|
-
return Number.isFinite(t) ? t : Number.NEGATIVE_INFINITY;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Pick the session to reconnect when the user gave no id: the most recently
|
|
33
|
-
* active one in scope — the terminal that most likely just dropped. Pure; returns
|
|
34
|
-
* undefined for an empty scope so the caller can print guidance.
|
|
35
|
-
*/
|
|
36
|
-
export function pickMostRecentSession(sessions) {
|
|
37
|
-
let best;
|
|
38
|
-
for (const s of sessions) {
|
|
39
|
-
if (!best || sessionRecency(s) > sessionRecency(best))
|
|
40
|
-
best = s;
|
|
41
|
-
}
|
|
42
|
-
return best;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the no-id target: prefer the most recent session started from THIS
|
|
46
|
-
* directory (the shell the user is reconnecting from), falling back to the most
|
|
47
|
-
* recent session anywhere when the current directory has none. Best-effort — a
|
|
48
|
-
* discovery failure yields undefined, never throws. Injectable `discover` keeps
|
|
49
|
-
* the two-step scope preference testable without touching the real scanner.
|
|
50
|
-
*/
|
|
51
|
-
export async function resolveRecentTarget(cwd, discover = discoverSessions) {
|
|
52
|
-
try {
|
|
53
|
-
const here = await discover({ cwd, since: '7d', limit: 200 });
|
|
54
|
-
const local = pickMostRecentSession(here);
|
|
55
|
-
if (local)
|
|
56
|
-
return local;
|
|
57
|
-
const any = await discover({ all: true, since: '7d', limit: 200 });
|
|
58
|
-
return pickMostRecentSession(any);
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export async function reconnectAction(id) {
|
|
65
|
-
if (id) {
|
|
66
|
-
// focus already attaches a live pane or recovers a dropped one for a resolved
|
|
67
|
-
// id — on the origin device for a remote session. Reconnect is that path with
|
|
68
|
-
// a recovery-first name; no reason to duplicate the resolution/attach logic.
|
|
69
|
-
await focusAction(id, {});
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const recent = await resolveRecentTarget(process.cwd());
|
|
73
|
-
if (!recent) {
|
|
74
|
-
console.log(chalk.gray('No recent session to reconnect from here.'));
|
|
75
|
-
console.log(chalk.gray(' reconnect a specific one: agents reconnect <session-id>'));
|
|
76
|
-
console.log(chalk.gray(' or pick from the fleet: agents sessions'));
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const where = recent.machine ? ` on ${recent.machine}` : '';
|
|
80
|
-
console.log(chalk.gray(`Reconnecting ${recent.shortId}${where} (most recent here)…`));
|
|
81
|
-
await focusAction(recent.id, {});
|
|
82
|
-
}
|
|
83
|
-
export function registerReconnectCommand(program) {
|
|
84
|
-
// Deprecated: superseded by `agents sessions resume`, which does the same
|
|
85
|
-
// attach-else-recover and additionally takes a tmux alias. Hidden + warned +
|
|
86
|
-
// functional for one release. Bare `reconnect` targeted the most recent
|
|
87
|
-
// session in this directory; that default now lives on `resume`'s picker.
|
|
88
|
-
const cmd = program
|
|
89
|
-
.command('reconnect', { hidden: true })
|
|
90
|
-
.argument('[session-id]', 'Session id/prefix to reconnect (default: the most recent session started here)')
|
|
91
|
-
.description('Deprecated — use `agents sessions resume` instead.')
|
|
92
|
-
.action(async (id) => {
|
|
93
|
-
console.warn(chalk.yellow('`agents reconnect` is deprecated — use `agents sessions resume` instead:'));
|
|
94
|
-
console.warn(chalk.gray(` agents sessions resume${id ? ` ${id}` : ''}`));
|
|
95
|
-
await reconnectAction(id);
|
|
96
|
-
});
|
|
97
|
-
setHelpSections(cmd, {
|
|
98
|
-
examples: `
|
|
99
|
-
# Reconnect the session that just dropped in this shell (most recent here)
|
|
100
|
-
agents reconnect
|
|
101
|
-
|
|
102
|
-
# Reconnect one specific agent terminal by id/prefix
|
|
103
|
-
agents reconnect 74b13b0b
|
|
104
|
-
|
|
105
|
-
# Same, spelled under the sessions group
|
|
106
|
-
agents sessions reconnect 74b13b0b
|
|
107
|
-
`,
|
|
108
|
-
notes: `
|
|
109
|
-
- Best-effort recovery: a living remote tmux pane is JOINED (a second client, no fork); a dropped one is RESUMED on its origin device (a copy if it was mid-run, a /continue if idle).
|
|
110
|
-
- With no id, targets the most recent session started from this directory (the terminal that most likely just dropped), not the full fleet picker. Falls back to the most recent session anywhere when this directory has none.
|
|
111
|
-
- This is the manual companion to the automatic reconnect that runs during a live 'agents run --device <box>' when the network blinks; use it after that gave up or the terminal tab closed.
|
|
112
|
-
- Deprecated: use 'agents sessions resume' — it attaches a live pane, foregrounds a headless session, or recovers an ended one.
|
|
113
|
-
`,
|
|
114
|
-
});
|
|
115
|
-
}
|