@phnx-labs/agents-cli 1.22.35 → 1.22.37
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 +666 -2
- package/README.md +75 -35
- package/dist/bin/agents +0 -0
- package/dist/bootstrap.d.ts +15 -0
- package/dist/bootstrap.js +1211 -0
- package/dist/commands/accounts.d.ts +4 -11
- package/dist/commands/accounts.js +159 -27
- package/dist/commands/attach.js +17 -4
- package/dist/commands/audit.d.ts +8 -8
- package/dist/commands/audit.js +57 -47
- package/dist/commands/browser.js +15 -11
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/commands.js +0 -11
- package/dist/commands/computer-actions.js +33 -0
- package/dist/commands/computer-sessions-picker.d.ts +21 -0
- package/dist/commands/computer-sessions-picker.js +141 -0
- package/dist/commands/computer.d.ts +16 -0
- package/dist/commands/computer.js +37 -0
- package/dist/commands/config.d.ts +17 -0
- package/dist/commands/config.js +401 -0
- package/dist/commands/cp.d.ts +84 -0
- package/dist/commands/cp.js +231 -0
- package/dist/commands/daemon.js +243 -14
- package/dist/commands/detach-core.d.ts +1 -1
- package/dist/commands/detach-core.js +12 -2
- package/dist/commands/detach.js +1 -1
- package/dist/commands/doctor.js +64 -5
- package/dist/commands/events.d.ts +24 -12
- package/dist/commands/events.js +144 -28
- package/dist/commands/exec.js +85 -41
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +16 -8
- package/dist/commands/focus.d.ts +33 -1
- package/dist/commands/focus.js +177 -17
- package/dist/commands/funnel.d.ts +1 -1
- package/dist/commands/go.js +9 -8
- package/dist/commands/harness-wizard.d.ts +1 -0
- package/dist/commands/harness-wizard.js +18 -20
- package/dist/commands/harness.d.ts +2 -0
- package/dist/commands/harness.js +59 -26
- package/dist/commands/hooks.js +0 -11
- package/dist/commands/inspect.d.ts +94 -1
- package/dist/commands/inspect.js +866 -40
- package/dist/commands/lease.d.ts +4 -4
- package/dist/commands/lease.js +6 -6
- package/dist/commands/login.js +0 -13
- package/dist/commands/logs.d.ts +2 -2
- package/dist/commands/logs.js +2 -2
- package/dist/commands/mcp.js +7 -2
- package/dist/commands/memory.js +7 -2
- package/dist/commands/message.d.ts +1 -1
- package/dist/commands/message.js +37 -6
- package/dist/commands/models.js +4 -0
- package/dist/commands/monitors.d.ts +0 -1
- package/dist/commands/monitors.js +199 -16
- package/dist/commands/open.d.ts +18 -0
- package/dist/commands/open.js +57 -0
- package/dist/commands/packages.js +2 -107
- package/dist/commands/plugins.js +6 -3
- package/dist/commands/profiles.d.ts +1 -0
- package/dist/commands/profiles.js +16 -160
- package/dist/commands/projects.d.ts +28 -0
- package/dist/commands/projects.js +125 -5
- package/dist/commands/reconnect.js +9 -3
- package/dist/commands/repo.js +42 -1
- package/dist/commands/resource-view.d.ts +17 -0
- package/dist/commands/resource-view.js +36 -14
- package/dist/commands/resume.js +9 -2
- package/dist/commands/routines.d.ts +0 -2
- package/dist/commands/routines.js +473 -289
- package/dist/commands/secrets.js +52 -9
- package/dist/commands/sessions-export.d.ts +47 -0
- package/dist/commands/sessions-export.js +116 -6
- package/dist/commands/sessions-import.d.ts +17 -0
- package/dist/commands/sessions-import.js +114 -6
- package/dist/commands/sessions-migrate.d.ts +27 -0
- package/dist/commands/sessions-migrate.js +50 -9
- package/dist/commands/sessions-picker.js +23 -4
- package/dist/commands/sessions-resume.d.ts +5 -3
- package/dist/commands/sessions-resume.js +30 -8
- package/dist/commands/sessions-watch.d.ts +2 -0
- package/dist/commands/sessions-watch.js +53 -0
- package/dist/commands/sessions.d.ts +66 -3
- package/dist/commands/sessions.js +298 -47
- package/dist/commands/set.d.ts +1 -1
- package/dist/commands/set.js +2 -2
- package/dist/commands/setup-browser.js +2 -2
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/setup-preferences.js +1 -1
- package/dist/commands/setup-share.js +34 -4
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.js +26 -0
- package/dist/commands/share.d.ts +67 -0
- package/dist/commands/share.js +275 -12
- package/dist/commands/skills.js +0 -11
- package/dist/commands/snapshot.js +1 -1
- package/dist/commands/ssh.d.ts +18 -0
- package/dist/commands/ssh.js +549 -210
- package/dist/commands/sync.d.ts +5 -0
- package/dist/commands/sync.js +212 -32
- package/dist/commands/teams.d.ts +13 -0
- package/dist/commands/teams.js +187 -30
- package/dist/commands/tickets.d.ts +2 -0
- package/dist/commands/tickets.js +43 -0
- package/dist/commands/update.js +2 -4
- package/dist/commands/usage.js +5 -3
- package/dist/commands/versions.js +11 -5
- package/dist/commands/view.js +15 -7
- package/dist/commands/webhook.d.ts +2 -2
- package/dist/commands/webhook.js +7 -7
- package/dist/index.d.ts +18 -2
- package/dist/index.js +53 -1264
- package/dist/lib/account-catalog.d.ts +18 -0
- package/dist/lib/account-catalog.js +38 -0
- package/dist/lib/account-provider-registry.d.ts +18 -0
- package/dist/lib/account-provider-registry.js +59 -0
- package/dist/lib/account-registry.d.ts +40 -0
- package/dist/lib/account-registry.js +239 -0
- package/dist/lib/account-schema.d.ts +44 -0
- package/dist/lib/account-schema.js +91 -0
- package/dist/lib/account-state-service.d.ts +21 -0
- package/dist/lib/account-state-service.js +60 -0
- package/dist/lib/activity.d.ts +1 -1
- package/dist/lib/activity.js +8 -1
- package/dist/lib/add-dir.d.ts +80 -0
- package/dist/lib/add-dir.js +241 -0
- package/dist/lib/agent-cli-commands.d.ts +11 -0
- package/dist/lib/agent-cli-commands.js +30 -0
- package/dist/lib/agents.js +44 -36
- package/dist/lib/answer-router.js +1 -1
- package/dist/lib/audit/log.d.ts +10 -27
- package/dist/lib/audit/log.js +20 -33
- package/dist/lib/auth-health.d.ts +9 -2
- package/dist/lib/auth-health.js +42 -9
- package/dist/lib/auto-pull-worker.js +7 -3
- package/dist/lib/auto-pull.d.ts +44 -3
- package/dist/lib/auto-pull.js +88 -5
- package/dist/lib/binary-shadow.d.ts +28 -0
- package/dist/lib/binary-shadow.js +121 -0
- package/dist/lib/brand.js +9 -3
- package/dist/lib/browser/ipc.d.ts +30 -0
- package/dist/lib/browser/ipc.js +81 -4
- package/dist/lib/browser/profiles.d.ts +3 -2
- package/dist/lib/browser/profiles.js +65 -22
- package/dist/lib/browser/service.d.ts +4 -0
- package/dist/lib/browser/service.js +30 -3
- package/dist/lib/browser/sessions-list.d.ts +22 -2
- package/dist/lib/browser/sessions-list.js +54 -6
- package/dist/lib/browser/stream.d.ts +2 -0
- package/dist/lib/browser/stream.js +1 -0
- package/dist/lib/browser/types.d.ts +19 -0
- package/dist/lib/byok-usage.d.ts +9 -2
- package/dist/lib/byok-usage.js +133 -31
- package/dist/lib/cli-entry.d.ts +11 -0
- package/dist/lib/cli-entry.js +46 -0
- package/dist/lib/cloud/host.d.ts +1 -1
- package/dist/lib/cloud/host.js +2 -2
- package/dist/lib/cloud/registry.js +1 -1
- package/dist/lib/cloud/types.d.ts +1 -1
- package/dist/lib/commands.d.ts +2 -0
- package/dist/lib/commands.js +2 -0
- package/dist/lib/computer/sessions-list.d.ts +150 -0
- package/dist/lib/computer/sessions-list.js +363 -0
- package/dist/lib/config-keys.d.ts +86 -0
- package/dist/lib/config-keys.js +193 -0
- package/dist/lib/config-machine-keys.d.ts +12 -0
- package/dist/lib/config-machine-keys.js +17 -0
- package/dist/lib/config-transfer.js +3 -4
- package/dist/lib/crabbox/cli.d.ts +2 -2
- package/dist/lib/crabbox/cli.js +3 -3
- package/dist/lib/daemon-health.d.ts +22 -0
- package/dist/lib/daemon-health.js +33 -3
- package/dist/lib/daemon-services.d.ts +50 -0
- package/dist/lib/daemon-services.js +147 -0
- package/dist/lib/daemon-ticks.d.ts +35 -66
- package/dist/lib/daemon-ticks.js +77 -159
- package/dist/lib/daemon.d.ts +72 -4
- package/dist/lib/daemon.js +792 -202
- package/dist/lib/deeplink/register.d.ts +49 -0
- package/dist/lib/deeplink/register.js +253 -0
- package/dist/lib/deeplink/url.d.ts +34 -0
- package/dist/lib/deeplink/url.js +78 -0
- package/dist/lib/device-config.d.ts +124 -29
- package/dist/lib/device-config.js +346 -141
- package/dist/lib/devices/config-migration.d.ts +42 -0
- package/dist/lib/devices/config-migration.js +203 -0
- package/dist/lib/devices/connect.js +14 -7
- package/dist/lib/devices/doctor-findings.d.ts +4 -1
- package/dist/lib/devices/doctor-findings.js +20 -1
- package/dist/lib/devices/harness-inventory.d.ts +11 -2
- package/dist/lib/devices/harness-inventory.js +0 -0
- package/dist/lib/devices/health.d.ts +1 -1
- package/dist/lib/devices/health.js +1 -1
- package/dist/lib/devices/pending.d.ts +22 -1
- package/dist/lib/devices/pending.js +67 -2
- package/dist/lib/devices/registry.d.ts +0 -25
- package/dist/lib/devices/registry.js +2 -83
- package/dist/lib/devices/resolve-profile.d.ts +20 -0
- package/dist/lib/devices/resolve-profile.js +44 -0
- package/dist/lib/devices/rollout-verify.d.ts +101 -0
- package/dist/lib/devices/rollout-verify.js +193 -0
- package/dist/lib/devices/ssh-config.js +10 -6
- package/dist/lib/event-families.d.ts +28 -0
- package/dist/lib/event-families.js +159 -0
- package/dist/lib/event-stream.d.ts +9 -1
- package/dist/lib/event-stream.js +26 -9
- package/dist/lib/events.d.ts +9 -1
- package/dist/lib/events.js +21 -6
- package/dist/lib/exec.d.ts +30 -0
- package/dist/lib/exec.js +219 -121
- package/dist/lib/feed-broadcast.d.ts +25 -0
- package/dist/lib/feed-broadcast.js +33 -0
- package/dist/lib/feed.d.ts +1 -1
- package/dist/lib/feed.js +12 -2
- package/dist/lib/fleet/capture.js +15 -0
- package/dist/lib/fleet/manifest.js +9 -0
- package/dist/lib/fleet/types.d.ts +9 -0
- package/dist/lib/fleet-status.js +10 -8
- package/dist/lib/git.d.ts +20 -6
- package/dist/lib/git.js +121 -17
- package/dist/lib/hosts/dispatch.d.ts +8 -3
- package/dist/lib/hosts/dispatch.js +29 -3
- package/dist/lib/hosts/logs.d.ts +2 -2
- package/dist/lib/hosts/logs.js +2 -2
- package/dist/lib/hosts/option.js +1 -1
- package/dist/lib/hosts/passthrough.d.ts +2 -3
- package/dist/lib/hosts/passthrough.js +10 -24
- package/dist/lib/hosts/progress.js +2 -2
- package/dist/lib/hosts/providers/devices.d.ts +3 -3
- package/dist/lib/hosts/providers/devices.js +18 -12
- package/dist/lib/hosts/ready.d.ts +5 -1
- package/dist/lib/hosts/ready.js +9 -3
- package/dist/lib/hosts/reconcile.d.ts +2 -2
- package/dist/lib/hosts/reconcile.js +2 -2
- package/dist/lib/hosts/registry.js +14 -9
- package/dist/lib/hosts/remote-cmd.js +1 -1
- package/dist/lib/hosts/remote-os.d.ts +9 -6
- package/dist/lib/hosts/remote-os.js +13 -6
- package/dist/lib/hosts/routing-flag.d.ts +23 -0
- package/dist/lib/hosts/routing-flag.js +41 -0
- package/dist/lib/hosts/run-target.js +1 -1
- package/dist/lib/hosts/session-index.js +1 -1
- package/dist/lib/hosts/tasks.d.ts +6 -6
- package/dist/lib/hosts/tasks.js +4 -4
- package/dist/lib/hosts/types.js +1 -2
- package/dist/lib/installations/resolve.js +2 -8
- package/dist/lib/isolation-boundary-report.js +0 -1
- package/dist/lib/linear-cache.d.ts +7 -0
- package/dist/lib/linear-cache.js +31 -4
- package/dist/lib/linear-project-counts.d.ts +1 -1
- package/dist/lib/linear-project-counts.js +2 -3
- package/dist/lib/linear-projects.js +1 -1
- package/dist/lib/loop.d.ts +2 -2
- package/dist/lib/loop.js +1 -1
- package/dist/lib/mailbox-target.d.ts +1 -1
- package/dist/lib/mailbox-target.js +1 -1
- package/dist/lib/manifest.js +7 -4
- package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
- package/dist/lib/menubar/snapshot.d.ts +3 -2
- package/dist/lib/menubar/snapshot.js +6 -2
- package/dist/lib/migrate-fold.d.ts +33 -0
- package/dist/lib/migrate-fold.js +130 -0
- package/dist/lib/migrate.d.ts +34 -34
- package/dist/lib/migrate.js +106 -128
- package/dist/lib/model-tier-overrides.d.ts +1 -1
- package/dist/lib/model-tier-overrides.js +15 -2
- package/dist/lib/monitors/config.d.ts +17 -3
- package/dist/lib/monitors/config.js +52 -18
- package/dist/lib/monitors/engine.d.ts +32 -1
- package/dist/lib/monitors/engine.js +94 -11
- package/dist/lib/monitors/fingerprint.d.ts +46 -0
- package/dist/lib/monitors/fingerprint.js +100 -0
- package/dist/lib/monitors/remote.d.ts +47 -0
- package/dist/lib/monitors/remote.js +81 -0
- package/dist/lib/monitors/state.d.ts +39 -0
- package/dist/lib/monitors/state.js +56 -0
- package/dist/lib/onepassword.d.ts +17 -0
- package/dist/lib/onepassword.js +52 -22
- package/dist/lib/open-url.js +1 -1
- package/dist/lib/picker.d.ts +14 -2
- package/dist/lib/picker.js +35 -13
- package/dist/lib/placement.d.ts +1 -1
- package/dist/lib/placement.js +1 -1
- package/dist/lib/pr-land-detach.d.ts +32 -0
- package/dist/lib/pr-land-detach.js +79 -0
- package/dist/lib/profiles-presets.js +13 -0
- package/dist/lib/profiles.d.ts +2 -0
- package/dist/lib/profiles.js +44 -1
- package/dist/lib/project-focus.d.ts +1 -1
- package/dist/lib/project-focus.js +1 -1
- package/dist/lib/project-probe.d.ts +4 -1
- package/dist/lib/project-probe.js +5 -4
- package/dist/lib/project-resources.js +2 -18
- package/dist/lib/project-root.d.ts +16 -0
- package/dist/lib/project-root.js +20 -2
- package/dist/lib/projects.d.ts +20 -1
- package/dist/lib/projects.js +78 -1
- package/dist/lib/refresh-coordinator.d.ts +24 -0
- package/dist/lib/refresh-coordinator.js +52 -0
- package/dist/lib/registry.d.ts +2 -2
- package/dist/lib/registry.js +1 -1
- package/dist/lib/resource-aliases.d.ts +13 -0
- package/dist/lib/resource-aliases.js +26 -0
- package/dist/lib/resources/types.d.ts +1 -1
- package/dist/lib/resources.d.ts +16 -0
- package/dist/lib/resources.js +66 -10
- package/dist/lib/rotate.d.ts +3 -4
- package/dist/lib/rotate.js +4 -5
- package/dist/lib/routine-activation.d.ts +22 -2
- package/dist/lib/routine-activation.js +63 -16
- package/dist/lib/routine-context.d.ts +9 -2
- package/dist/lib/routine-context.js +21 -6
- package/dist/lib/routines-project.d.ts +58 -48
- package/dist/lib/routines-project.js +190 -159
- package/dist/lib/routines.d.ts +41 -6
- package/dist/lib/routines.js +92 -34
- package/dist/lib/run-defaults.d.ts +5 -0
- package/dist/lib/run-defaults.js +11 -1
- package/dist/lib/runner.d.ts +10 -8
- package/dist/lib/runner.js +122 -39
- package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
- package/dist/lib/secrets/agent.d.ts +10 -3
- package/dist/lib/secrets/agent.js +43 -8
- package/dist/lib/secrets/bundles.d.ts +1 -0
- package/dist/lib/secrets/bundles.js +92 -80
- package/dist/lib/secrets/index.js +32 -9
- package/dist/lib/secrets/install-helper.d.ts +4 -4
- package/dist/lib/secrets/install-helper.js +4 -4
- package/dist/lib/secrets/push.d.ts +40 -6
- package/dist/lib/secrets/push.js +58 -11
- package/dist/lib/secrets/read-backoff.d.ts +1 -1
- package/dist/lib/secrets/read-backoff.js +1 -1
- package/dist/lib/secrets/remote.d.ts +24 -0
- package/dist/lib/secrets/remote.js +54 -4
- package/dist/lib/self-update.d.ts +108 -0
- package/dist/lib/self-update.js +276 -1
- package/dist/lib/session/active.d.ts +89 -5
- package/dist/lib/session/active.js +165 -10
- package/dist/lib/session/actor-sidecar.d.ts +1 -1
- package/dist/lib/session/actor-sidecar.js +2 -1
- package/dist/lib/session/db.d.ts +176 -2
- package/dist/lib/session/db.js +484 -17
- package/dist/lib/session/discover.js +27 -4
- package/dist/lib/session/hook-sessions.js +2 -2
- package/dist/lib/session/host-link.d.ts +2 -2
- package/dist/lib/session/host-link.js +2 -2
- package/dist/lib/session/pid-registry.d.ts +21 -0
- package/dist/lib/session/pid-registry.js +57 -0
- package/dist/lib/session/remote-active.js +15 -1
- package/dist/lib/session/remote.js +2 -2
- package/dist/lib/session/session-cache.d.ts +14 -7
- package/dist/lib/session/session-cache.js +51 -9
- package/dist/lib/session/state.d.ts +2 -2
- package/dist/lib/session/state.js +1 -1
- package/dist/lib/session/sync/config.d.ts +10 -10
- package/dist/lib/session/sync/config.js +10 -10
- package/dist/lib/session/sync/r2.d.ts +34 -0
- package/dist/lib/session/sync/r2.js +123 -0
- package/dist/lib/session/throughput.d.ts +1 -1
- package/dist/lib/session/throughput.js +1 -1
- package/dist/lib/session/types.d.ts +23 -1
- package/dist/lib/session/types.js +15 -0
- package/dist/lib/session/viewing-in.d.ts +1 -1
- package/dist/lib/session/viewing-in.js +1 -1
- package/dist/lib/session/watch.d.ts +101 -0
- package/dist/lib/session/watch.js +242 -0
- package/dist/lib/share/config.d.ts +4 -0
- package/dist/lib/share/config.js +1 -0
- package/dist/lib/share/provision.d.ts +38 -0
- package/dist/lib/share/provision.js +50 -0
- package/dist/lib/share/publish.d.ts +40 -1
- package/dist/lib/share/publish.js +116 -3
- package/dist/lib/share/worker-template.js +71 -6
- package/dist/lib/shims.d.ts +17 -3
- package/dist/lib/shims.js +98 -26
- package/dist/lib/signin-badge.js +3 -2
- package/dist/lib/skills.js +2 -0
- package/dist/lib/smart-launch.d.ts +8 -8
- package/dist/lib/smart-launch.js +80 -59
- package/dist/lib/ssh-exec.d.ts +1 -1
- package/dist/lib/ssh-exec.js +1 -1
- package/dist/lib/staleness/prune.d.ts +88 -0
- package/dist/lib/staleness/prune.js +69 -0
- package/dist/lib/staleness/registry.d.ts +1 -1
- package/dist/lib/staleness/writers/commands.js +34 -2
- package/dist/lib/staleness/writers/hooks.js +16 -0
- package/dist/lib/staleness/writers/kinds.d.ts +6 -0
- package/dist/lib/staleness/writers/skills.js +19 -0
- package/dist/lib/staleness/writers/subagents.d.ts +2 -3
- package/dist/lib/staleness/writers/subagents.js +0 -4
- package/dist/lib/staleness/writers/types.d.ts +32 -0
- package/dist/lib/startup/command-registry.d.ts +6 -12
- package/dist/lib/startup/command-registry.js +11 -31
- package/dist/lib/startup/dev-build.d.ts +10 -0
- package/dist/lib/startup/dev-build.js +13 -1
- package/dist/lib/startup/spellcheck.d.ts +18 -0
- package/dist/lib/startup/spellcheck.js +45 -0
- package/dist/lib/state.d.ts +36 -9
- package/dist/lib/state.js +96 -46
- package/dist/lib/subagents-registry.d.ts +0 -7
- package/dist/lib/subagents-registry.js +38 -65
- package/dist/lib/subagents.d.ts +0 -33
- package/dist/lib/subagents.js +0 -75
- package/dist/lib/sync-umbrella.js +1 -1
- package/dist/lib/teams/agents.d.ts +41 -1
- package/dist/lib/teams/agents.js +187 -9
- package/dist/lib/teams/api.d.ts +11 -1
- package/dist/lib/teams/api.js +11 -2
- package/dist/lib/teams/delivery.d.ts +41 -0
- package/dist/lib/teams/delivery.js +60 -0
- package/dist/lib/teams/registry.d.ts +14 -0
- package/dist/lib/teams/registry.js +51 -1
- package/dist/lib/teams/remoteWorktree.d.ts +19 -0
- package/dist/lib/teams/remoteWorktree.js +29 -0
- package/dist/lib/teams/scheduler.d.ts +1 -1
- package/dist/lib/teams/scheduler.js +1 -1
- package/dist/lib/teams/worktree.d.ts +24 -0
- package/dist/lib/teams/worktree.js +42 -0
- package/dist/lib/terminal/backends/vscodium-agent.d.ts +10 -1
- package/dist/lib/terminal/backends/vscodium-agent.js +16 -5
- package/dist/lib/terminal/engine.d.ts +4 -0
- package/dist/lib/terminal/engine.js +8 -2
- package/dist/lib/terminal/types.d.ts +21 -2
- package/dist/lib/testdata/refresh-coordinator-worker.d.ts +1 -0
- package/dist/lib/testdata/refresh-coordinator-worker.js +23 -0
- package/dist/lib/tickets/list.d.ts +53 -0
- package/dist/lib/tickets/list.js +153 -0
- package/dist/lib/tmux/orphan-reap.d.ts +320 -0
- package/dist/lib/tmux/orphan-reap.js +644 -0
- package/dist/lib/tmux/session.d.ts +68 -3
- package/dist/lib/tmux/session.js +95 -5
- package/dist/lib/triggers/handlers.d.ts +20 -0
- package/dist/lib/triggers/handlers.js +6 -1
- package/dist/lib/types.d.ts +46 -34
- package/dist/lib/usage-fleet.d.ts +32 -0
- package/dist/lib/usage-fleet.js +125 -0
- package/dist/lib/usage-refresh.d.ts +3 -3
- package/dist/lib/usage-refresh.js +19 -16
- package/dist/lib/usage.d.ts +51 -47
- package/dist/lib/usage.js +145 -153
- package/dist/lib/version-duplicates.js +2 -2
- package/dist/lib/versions.d.ts +56 -13
- package/dist/lib/versions.js +195 -45
- package/dist/lib/watchdog/log.d.ts +1 -1
- package/dist/lib/watchdog/log.js +3 -3
- package/dist/lib/watchdog/rotate.d.ts +6 -6
- package/dist/lib/watchdog/rotate.js +6 -6
- package/dist/lib/workflows.d.ts +1 -1
- package/dist/lib/yaml-io.d.ts +47 -0
- package/dist/lib/yaml-io.js +55 -0
- package/package.json +2 -1
- package/scripts/install-helper.js +2 -2
- package/scripts/postinstall.js +23 -20
- package/dist/commands/defaults.d.ts +0 -7
- package/dist/commands/defaults.js +0 -107
- package/dist/commands/export.d.ts +0 -11
- package/dist/commands/export.js +0 -215
- package/dist/commands/helper.d.ts +0 -12
- package/dist/commands/helper.js +0 -87
- package/dist/commands/hosts.d.ts +0 -11
- package/dist/commands/hosts.js +0 -330
- package/dist/commands/lock.d.ts +0 -12
- package/dist/commands/lock.js +0 -70
- package/dist/commands/pull.d.ts +0 -17
- package/dist/commands/pull.js +0 -39
- package/dist/commands/push.d.ts +0 -14
- package/dist/commands/push.js +0 -30
- package/dist/commands/wallet.d.ts +0 -20
- package/dist/commands/wallet.js +0 -216
- package/dist/commands/worktree.d.ts +0 -19
- package/dist/commands/worktree.js +0 -272
- package/dist/lib/account-labels.d.ts +0 -24
- package/dist/lib/account-labels.js +0 -72
- package/dist/lib/auto-dispatch-linear.d.ts +0 -18
- package/dist/lib/auto-dispatch-linear.js +0 -107
- package/dist/lib/auto-dispatch-provider.d.ts +0 -10
- package/dist/lib/auto-dispatch-provider.js +0 -30
- package/dist/lib/auto-dispatch.d.ts +0 -93
- package/dist/lib/auto-dispatch.js +0 -128
- package/dist/lib/export.d.ts +0 -72
- package/dist/lib/export.js +0 -269
- package/dist/lib/lock.d.ts +0 -93
- package/dist/lib/lock.js +0 -207
- package/dist/lib/wallet/index.d.ts +0 -78
- package/dist/lib/wallet/index.js +0 -253
|
@@ -24,21 +24,22 @@ import { promisify } from 'util';
|
|
|
24
24
|
import { listActiveTasks } from '../cloud/store.js';
|
|
25
25
|
import { AgentManager } from '../teams/agents.js';
|
|
26
26
|
import { getTerminalsDir } from '../state.js';
|
|
27
|
-
import { readPidSessionEntry, listPidSessionEntries, prunePidSessionRegistry } from './pid-registry.js';
|
|
27
|
+
import { readPidSessionEntry, listPidSessionEntries, prunePidSessionRegistry, sessionIdFromLivePid, isSessionIdShape, } from './pid-registry.js';
|
|
28
28
|
import { readSessionActorRecord, writeSessionAliasRecord } from './actor-sidecar.js';
|
|
29
29
|
import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord } from './hook-sessions.js';
|
|
30
30
|
import { buildClaudeLabelMap, getAgentSessionDirs } from './discover.js';
|
|
31
31
|
import { buildRunNameMap } from './run-names.js';
|
|
32
|
-
import { latestSessionFileForCwd, findSessionsByShortIds } from './db.js';
|
|
32
|
+
import { latestSessionFileForCwd, findSessionsByShortIds, findSessionMachinesByIds } from './db.js';
|
|
33
33
|
import { extractSessionTopic } from './prompt.js';
|
|
34
34
|
import { readSessionTailWithRaw } from './tail.js';
|
|
35
35
|
import { parseSession } from './parse.js';
|
|
36
36
|
import { computeTokPerSec } from './throughput.js';
|
|
37
37
|
import { inferSessionState } from './state.js';
|
|
38
|
-
import { isSessionTrackedAgent, SESSION_AGENTS } from './types.js';
|
|
38
|
+
import { isSessionTrackedAgent, SESSION_AGENTS, AG_TMUX_NAME_RE } from './types.js';
|
|
39
39
|
import { AGENTS } from '../agents.js';
|
|
40
40
|
import { detectProvenance } from './provenance.js';
|
|
41
41
|
import { loadDevices } from '../devices/registry.js';
|
|
42
|
+
import { machineId, normalizeHost } from '../machine-id.js';
|
|
42
43
|
import { presenceFromStore } from './detached.js';
|
|
43
44
|
import { classifyHostLink, HOST_HEARTBEAT_STALE_MS } from './host-link.js';
|
|
44
45
|
import { mapBounded } from '../concurrency.js';
|
|
@@ -274,7 +275,7 @@ export function agentKindFromComm(commRaw) {
|
|
|
274
275
|
* and validating there would silently drop grok/kimi/antigravity — the exact
|
|
275
276
|
* harness-parity gap we are fixing.
|
|
276
277
|
*/
|
|
277
|
-
const AG_NAME_RE =
|
|
278
|
+
const AG_NAME_RE = AG_TMUX_NAME_RE;
|
|
278
279
|
/** Agent kind from an `ag-<agent>-<shortid>` tmux session name, else undefined. */
|
|
279
280
|
export function agentKindFromName(sessName) {
|
|
280
281
|
const m = AG_NAME_RE.exec(sessName);
|
|
@@ -867,6 +868,7 @@ export function summarizeMission(prompt) {
|
|
|
867
868
|
export async function listTeamsActive(opts = {}) {
|
|
868
869
|
const mgr = new AgentManager(undefined, undefined, undefined, undefined, undefined, opts.localOnly ?? false);
|
|
869
870
|
const running = await mgr.listRunning();
|
|
871
|
+
const self = machineId();
|
|
870
872
|
return running.map((a) => {
|
|
871
873
|
// The teammate's OWN transcript is `remoteSessionId` (captured from its first
|
|
872
874
|
// stream event). `parentSessionId` is the ORCHESTRATOR that spawned the team
|
|
@@ -880,11 +882,27 @@ export async function listTeamsActive(opts = {}) {
|
|
|
880
882
|
const pidAlive = a.pid ? isPidAlive(a.pid) : true;
|
|
881
883
|
const { state, tokPerSec } = computeLiveSignals(a.agentType, sessionFile, a.cwd ?? undefined, pidAlive);
|
|
882
884
|
const resolvedId = ownSessionId ?? sessionIdFromFile(sessionFile);
|
|
885
|
+
// A remote teams teammate (`teams add --device <peer>`) EXECUTES on that
|
|
886
|
+
// peer, not on this orchestrator box — but it gets no host-dispatch index
|
|
887
|
+
// row, so `foldExecutionMachine` can't reach it and the self-stamp in
|
|
888
|
+
// `commands/sessions.ts` would claim it, listing a peer's teammate under
|
|
889
|
+
// `--device <orchestrator>` (SES-GAP-10). Attribute the row to the execution
|
|
890
|
+
// host and mark the dispatcher, the same shape `run --device` gets: `machine`
|
|
891
|
+
// survives the cross-machine fan-out because `parseRemoteActive` keeps an
|
|
892
|
+
// `offloadedFrom` row's own machine, and `offloadedFrom` is COMPARED to this
|
|
893
|
+
// box by `sessionProcessIsLocal` (never merely tested), so a third box seeing
|
|
894
|
+
// this row over the fan-out reads it as the peer's, not its own. A local
|
|
895
|
+
// teammate (no `hostName`, or pinned to this box) is left unattributed for
|
|
896
|
+
// the self-stamp.
|
|
897
|
+
const execHost = a.hostName ? normalizeHost(a.hostName) : undefined;
|
|
898
|
+
const offloaded = execHost !== undefined && execHost !== self;
|
|
883
899
|
return applyState({
|
|
884
900
|
context: 'teams',
|
|
885
901
|
kind: a.agentType,
|
|
886
902
|
pid: a.pid ?? undefined,
|
|
887
903
|
sessionId: resolvedId,
|
|
904
|
+
machine: offloaded ? execHost : undefined,
|
|
905
|
+
offloadedFrom: offloaded ? self : undefined,
|
|
888
906
|
orchestratorSessionId: a.parentSessionId ?? undefined,
|
|
889
907
|
cwd: a.cwd ?? undefined,
|
|
890
908
|
label: a.name ?? undefined,
|
|
@@ -1214,11 +1232,16 @@ export function readAncestorSessionEntry(pid, ppidMap, kind, readEntry = readPid
|
|
|
1214
1232
|
* as its own headless row. Two exceptions keep their own row: a candidate with
|
|
1215
1233
|
* its own registry entry — on its pid OR on a wrapper ancestor strictly below
|
|
1216
1234
|
* the pid it would fold into (the shim's entry lands on the cmd.exe
|
|
1217
|
-
* intermediary on Windows) —
|
|
1218
|
-
*
|
|
1235
|
+
* intermediary on Windows) — a child whose live argv carries `--session-id`
|
|
1236
|
+
* (RUSH-2384: empty by-pid must not fold a real session into a parent and
|
|
1237
|
+
* drop it from the active set) — and a child of a *different* agent kind
|
|
1238
|
+
* (claude shelling out to codex is a real second session, not a fork).
|
|
1219
1239
|
* Returns the kept roots plus, per root pid, how many descendants folded in.
|
|
1240
|
+
*
|
|
1241
|
+
* `hasLiveSessionId` defaults to reading `--session-id` from the live process
|
|
1242
|
+
* argv; tests inject a pure predicate so they do not need real agent pids.
|
|
1220
1243
|
*/
|
|
1221
|
-
export function foldSubordinateAgents(candidates, ppidMap, readEntry) {
|
|
1244
|
+
export function foldSubordinateAgents(candidates, ppidMap, readEntry, hasLiveSessionId = (pid) => sessionIdFromLivePid(pid) != null) {
|
|
1222
1245
|
const kindByPid = new Map(candidates.map(c => [c.pid, c.kind]));
|
|
1223
1246
|
const nearestSameKindAncestor = (pid, kind) => {
|
|
1224
1247
|
let cur = ppidMap.get(pid);
|
|
@@ -1234,9 +1257,13 @@ export function foldSubordinateAgents(candidates, ppidMap, readEntry) {
|
|
|
1234
1257
|
// Own launch identity: a matching-kind registry entry on the candidate or on
|
|
1235
1258
|
// any wrapper between it and the pid it would fold into (exclusive). Entries
|
|
1236
1259
|
// above the fold target belong to that ancestor's session, not this one.
|
|
1260
|
+
// A live `--session-id` on argv is also own identity (RUSH-2384) — the
|
|
1261
|
+
// registry is often empty while the process still names its session.
|
|
1237
1262
|
const hasOwnSession = (c, stopPid) => {
|
|
1238
1263
|
if (readEntry(c.pid)?.agent === c.kind)
|
|
1239
1264
|
return true;
|
|
1265
|
+
if (hasLiveSessionId(c.pid))
|
|
1266
|
+
return true;
|
|
1240
1267
|
let cur = ppidMap.get(c.pid);
|
|
1241
1268
|
const seen = new Set();
|
|
1242
1269
|
while (cur && cur > 1 && cur !== stopPid && !seen.has(cur)) {
|
|
@@ -1366,11 +1393,13 @@ async function listUnattributedActiveLive(attributed) {
|
|
|
1366
1393
|
// path). Absent entirely (direct launch outside agents-cli) → heuristic.
|
|
1367
1394
|
const entry = readPidSessionEntry(pid) ?? readAncestorSessionEntry(pid, ppidMap, kind);
|
|
1368
1395
|
// Exact session id, in priority: (1) the id we recorded at launch (Claude,
|
|
1369
|
-
// known up front via --session-id); (2) the
|
|
1396
|
+
// known up front via --session-id); (2) the live process's own argv
|
|
1397
|
+
// `--session-id` (RUSH-2384 — by-pid is often empty mid-run while the
|
|
1398
|
+
// process still advertises the id); (3) the agent's OWN SessionStart hook,
|
|
1370
1399
|
// authoritative for non-Claude and for agents we didn't launch, joined by
|
|
1371
1400
|
// launchId/terminalId/pid and kind-guarded against a stale reused-pid file;
|
|
1372
|
-
// (
|
|
1373
|
-
let exactId = entry?.sessionId;
|
|
1401
|
+
// (4) the newest-jsonl heuristic (sessionIdFromFile, below).
|
|
1402
|
+
let exactId = entry?.sessionId ?? sessionIdFromLivePid(pid);
|
|
1374
1403
|
// The hook record (when we fall to it) also carries the SessionStart `ts` — the
|
|
1375
1404
|
// real session-start epoch. Capture it so terminal/headless rows get a
|
|
1376
1405
|
// `startedAtMs` instead of rendering "0s ago" (they set none before this).
|
|
@@ -1386,6 +1415,16 @@ async function listUnattributedActiveLive(attributed) {
|
|
|
1386
1415
|
});
|
|
1387
1416
|
exactId = hookRec?.session_id;
|
|
1388
1417
|
}
|
|
1418
|
+
// RUSH-2501: the hook-sessions index (terminals/sessions/) is populated only
|
|
1419
|
+
// by @agents/session-tracker, which is not deployed on most fleet machines.
|
|
1420
|
+
// The DEPLOYED SessionStart hook writes to state/sessions/<pid>.json instead.
|
|
1421
|
+
// Try that path when the index lookup found nothing, so cursor/grok/kimi/droid
|
|
1422
|
+
// agents (which carry no --session-id argv) can be attributed.
|
|
1423
|
+
if (!exactId) {
|
|
1424
|
+
const stateRec = readStateSessionRecord(pid, entry?.startedAtMs);
|
|
1425
|
+
if (stateRec)
|
|
1426
|
+
exactId = stateRec.session_id;
|
|
1427
|
+
}
|
|
1389
1428
|
const cwd = cwds[i] ?? entry?.cwd ?? undefined;
|
|
1390
1429
|
const sessionFile = findSessionFileForKind(kind, cwd, exactId);
|
|
1391
1430
|
const topic = sessionFile ? quickExtractTopic(sessionFile) : undefined;
|
|
@@ -1670,9 +1709,34 @@ export async function getActiveSessions(opts = {}) {
|
|
|
1670
1709
|
foldPresence(merged);
|
|
1671
1710
|
await foldTmuxClients(merged);
|
|
1672
1711
|
foldHostLink(merged);
|
|
1712
|
+
// Runs before the row leaves this box so every consumer — local render, the
|
|
1713
|
+
// `--json` a peer answers a fan-out with, the browser's device filter — sees
|
|
1714
|
+
// the EXECUTION host rather than the dispatcher (RUSH-2479).
|
|
1715
|
+
foldExecutionMachine(merged, recordedMachineLookup(merged), machineId());
|
|
1673
1716
|
annotateOrchestratorLabels(merged);
|
|
1674
1717
|
return merged;
|
|
1675
1718
|
}
|
|
1719
|
+
/**
|
|
1720
|
+
* True when a live agent process on this host carries `--session-id <id>` in
|
|
1721
|
+
* its argv. RUSH-2384 last-resort for `agents message`: getActiveSessions can
|
|
1722
|
+
* still miss a row (teams status flap, attributed-ancestor skip), but the
|
|
1723
|
+
* process table + argv are ground truth for "this session is alive and
|
|
1724
|
+
* mailbox-reachable". Only UUID-shaped ids are accepted so a short prefix
|
|
1725
|
+
* never false-matches.
|
|
1726
|
+
*/
|
|
1727
|
+
export async function isSessionIdLiveOnProcessTable(sessionId, deps = {}) {
|
|
1728
|
+
if (!isSessionIdShape(sessionId))
|
|
1729
|
+
return false;
|
|
1730
|
+
const readTable = deps.readTable ?? (async () => readProcessTable());
|
|
1731
|
+
const sessionIdOf = deps.sessionIdOf ?? sessionIdFromLivePid;
|
|
1732
|
+
for (const row of await readTable()) {
|
|
1733
|
+
if (!row.kind)
|
|
1734
|
+
continue;
|
|
1735
|
+
if (sessionIdOf(row.pid) === sessionId)
|
|
1736
|
+
return true;
|
|
1737
|
+
}
|
|
1738
|
+
return false;
|
|
1739
|
+
}
|
|
1676
1740
|
/**
|
|
1677
1741
|
* Fold tmux's attached-client count onto every tmux-hosted row.
|
|
1678
1742
|
*
|
|
@@ -1748,6 +1812,97 @@ export async function foldTmuxClients(rows) {
|
|
|
1748
1812
|
* bury the real signal. A session sitting idle — or worse, waiting on a
|
|
1749
1813
|
* question — with no client attached is the stranded case: nobody is coming.
|
|
1750
1814
|
*/
|
|
1815
|
+
/**
|
|
1816
|
+
* Attribute each live row to the machine the session actually EXECUTES on.
|
|
1817
|
+
*
|
|
1818
|
+
* A host-dispatched run (`agents run --device <peer>`) leaves a live process on
|
|
1819
|
+
* the DISPATCHING box — the ssh/TTY shim — carrying the remote run's session id.
|
|
1820
|
+
* Nothing about that local process knows the agent is on the peer, so the row
|
|
1821
|
+
* was tagged with THIS machine: `--device <dispatcher>` then claimed a session
|
|
1822
|
+
* that is not running here, and its preview dead-ended at "full transcript not
|
|
1823
|
+
* indexed here" because the transcript lives on the peer (RUSH-2479).
|
|
1824
|
+
*
|
|
1825
|
+
* The dispatch already recorded the truth. `registerHostSession` /
|
|
1826
|
+
* `registerInteractiveHostSession` write the index row with
|
|
1827
|
+
* `machine: normalizeHost(task.host)` (`lib/hosts/session-index.ts:55,134`), so
|
|
1828
|
+
* this folds that recorded machine back onto the live row. Every consumer then
|
|
1829
|
+
* agrees on one owner: the `--host`/`--device` scope, the browser's device
|
|
1830
|
+
* filter, `_remote`/preview routing (`liveSessionToMeta`), and the id resolver.
|
|
1831
|
+
*
|
|
1832
|
+
* Two rows are deliberately left alone:
|
|
1833
|
+
* - one the cross-machine fan-out already attributed to a peer — that is the
|
|
1834
|
+
* peer's own self-report, which outranks this box's index copy;
|
|
1835
|
+
* - one whose indexed machine IS this box — nothing was offloaded.
|
|
1836
|
+
*
|
|
1837
|
+
* Pure over the array; `machineOf` is injected so the join is unit-tested
|
|
1838
|
+
* without a SQLite index.
|
|
1839
|
+
*/
|
|
1840
|
+
export function foldExecutionMachine(rows, machineOf, self) {
|
|
1841
|
+
for (const s of rows) {
|
|
1842
|
+
if (!s.sessionId)
|
|
1843
|
+
continue;
|
|
1844
|
+
if (s.machine && s.machine !== self)
|
|
1845
|
+
continue;
|
|
1846
|
+
const recorded = machineOf(s.sessionId);
|
|
1847
|
+
if (!recorded || recorded === self)
|
|
1848
|
+
continue;
|
|
1849
|
+
s.machine = recorded;
|
|
1850
|
+
s.offloadedFrom = self;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Is the PROCESS behind this row running on this machine?
|
|
1855
|
+
*
|
|
1856
|
+
* `machine` answers a different question — "where does the agent execute" —
|
|
1857
|
+
* which is what a `--device` scope, preview routing, and resume ownership need.
|
|
1858
|
+
* For an offloaded run the two answers diverge: {@link foldExecutionMachine}
|
|
1859
|
+
* points `machine` at the peer, while the shim process, its tmux pane, and its
|
|
1860
|
+
* terminal window are all still HERE. `offloadedFrom` marks exactly that row.
|
|
1861
|
+
*
|
|
1862
|
+
* Any caller reaching for a LOCAL pid, pane, or window must ask this rather
|
|
1863
|
+
* than `machine === self`. A local tmux pane id (`%N`) handed to a peer's tmux
|
|
1864
|
+
* server does not fail — pane ids are small per-server integers, so it can
|
|
1865
|
+
* resolve against an unrelated pane and attach the user to someone else's
|
|
1866
|
+
* session. That is why this predicate exists instead of ten copies of the
|
|
1867
|
+
* comparison.
|
|
1868
|
+
*/
|
|
1869
|
+
export function sessionProcessIsLocal(s, self) {
|
|
1870
|
+
// `offloadedFrom` names WHICH box holds the shim, so it must be compared, not
|
|
1871
|
+
// merely tested. These rows travel: `--active --json` spreads them verbatim
|
|
1872
|
+
// and the fan-out preserves their foreign `machine`, so a THIRD box sees
|
|
1873
|
+
// `{machine: B, offloadedFrom: A}` — a shim that is emphatically not its own.
|
|
1874
|
+
// Answering "local" there sends the caller down the local-tmux path with
|
|
1875
|
+
// A's pane id, attaching an unrelated pane on C: the same hazard this
|
|
1876
|
+
// predicate exists to prevent, one machine over.
|
|
1877
|
+
if (s.offloadedFrom)
|
|
1878
|
+
return s.offloadedFrom === self;
|
|
1879
|
+
return !s.machine || s.machine === self;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* The machine to reach for this session's PROCESS — its pid, tmux pane, and
|
|
1883
|
+
* window — or `undefined` when that process is right here.
|
|
1884
|
+
*
|
|
1885
|
+
* Not the same as `machine`, which is where the AGENT executes. For an offloaded
|
|
1886
|
+
* run the process lives on the dispatcher (`offloadedFrom`) while the agent runs
|
|
1887
|
+
* on the peer, so a caller that ssh'd to `machine` would carry the dispatcher's
|
|
1888
|
+
* pane id to a box that never had it.
|
|
1889
|
+
*/
|
|
1890
|
+
export function sessionProcessHost(s, self) {
|
|
1891
|
+
if (sessionProcessIsLocal(s, self))
|
|
1892
|
+
return undefined;
|
|
1893
|
+
return s.offloadedFrom ?? s.machine;
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* The index lookup behind {@link foldExecutionMachine}. One batched query for
|
|
1897
|
+
* every live row (`findSessionMachinesByIds`), not a per-row `SELECT *` —
|
|
1898
|
+
* `getActiveSessions` is a hot path the daemon, menubar, and watchdog all poll.
|
|
1899
|
+
* Best-effort: an unavailable DB yields an empty map, leaving rows attributed
|
|
1900
|
+
* to this box rather than failing the whole live view.
|
|
1901
|
+
*/
|
|
1902
|
+
function recordedMachineLookup(rows) {
|
|
1903
|
+
const byId = findSessionMachinesByIds(rows.map((s) => s.sessionId).filter((id) => !!id));
|
|
1904
|
+
return (id) => byId.get(id);
|
|
1905
|
+
}
|
|
1751
1906
|
export function foldHostLink(rows) {
|
|
1752
1907
|
for (const s of rows) {
|
|
1753
1908
|
// Cloud tasks have no local pid, window, or tmux server; there is no host
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import fs from 'fs';
|
|
18
18
|
import path from 'path';
|
|
19
19
|
import { getHistoryDir } from '../state.js';
|
|
20
|
+
import { isAgentTmuxAlias } from './types.js';
|
|
20
21
|
function sidecarDir() {
|
|
21
22
|
return path.join(getHistoryDir(), 'by-session');
|
|
22
23
|
}
|
|
@@ -34,7 +35,7 @@ function recordPath(sessionId) {
|
|
|
34
35
|
return path.join(sidecarDir(), `${sessionId}.json`);
|
|
35
36
|
}
|
|
36
37
|
function isSafeAlias(alias) {
|
|
37
|
-
return
|
|
38
|
+
return isAgentTmuxAlias(alias);
|
|
38
39
|
}
|
|
39
40
|
function hasRecordData(record) {
|
|
40
41
|
return typeof record.actor === 'string'
|
package/dist/lib/session/db.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import type { SessionAgentId, SessionEvent, SessionMeta } from './types.js';
|
|
|
11
11
|
import { type IndexedToolCall } from './tool-calls.js';
|
|
12
12
|
/** Current schema version; bumped when migrations are added. Exported so tests
|
|
13
13
|
* assert against the constant instead of hardcoding a number that every bump
|
|
14
|
-
* then has to chase (docs/
|
|
15
|
-
export declare const SCHEMA_VERSION =
|
|
14
|
+
* then has to chase (docs/sessions.md calls the constant the source of truth). */
|
|
15
|
+
export declare const SCHEMA_VERSION = 39;
|
|
16
16
|
/**
|
|
17
17
|
* Bump to force `agents sessions backfill resources` to re-derive every
|
|
18
18
|
* session's skill/slash-command tallies on its next run (resource_scan_ledger
|
|
@@ -81,6 +81,13 @@ export interface SessionRow {
|
|
|
81
81
|
/** NULL means "not yet computed" (a row scanned before this field existed) — see rowToMeta. */
|
|
82
82
|
used_browser: number | null;
|
|
83
83
|
used_computer: number | null;
|
|
84
|
+
/**
|
|
85
|
+
* Epoch ms the transcript file was first confirmed gone while content survived
|
|
86
|
+
* (RUSH-2436); NULL = live/never archived. Optional because the scanner upsert
|
|
87
|
+
* write-payload never sets it — the INSERT column list omits it, so a rescan
|
|
88
|
+
* preserves the sticky stamp; it is written only by querySessions.
|
|
89
|
+
*/
|
|
90
|
+
archived_at?: number | null;
|
|
84
91
|
}
|
|
85
92
|
/** File stat snapshot used to detect changes between scan runs. */
|
|
86
93
|
export interface ScanStamp {
|
|
@@ -403,6 +410,26 @@ export declare function writeSessionPreviewCache<T>(entry: {
|
|
|
403
410
|
fileSize: number | null;
|
|
404
411
|
preview: T;
|
|
405
412
|
}): void;
|
|
413
|
+
/**
|
|
414
|
+
* The session's durable user-turn text, as stored in the `session_text` FTS
|
|
415
|
+
* `content` column at scan time (all harnesses, keyed by session_id). This is
|
|
416
|
+
* the content that survives the transcript file being deleted (RUSH-2436): the
|
|
417
|
+
* render path reads it so a file-gone session still shows its user prompts, and
|
|
418
|
+
* querySessions uses its presence to tell a genuine archived session (has
|
|
419
|
+
* content) from a phantom (a stale/moved file_path with none). Returns undefined
|
|
420
|
+
* when no row exists; an empty string when a row exists but carried no content.
|
|
421
|
+
*/
|
|
422
|
+
export declare function readSessionContent(id: string): string | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* Read the last-computed preview digest for a session by id, validated against
|
|
425
|
+
* the session row's OWN stored file stamp rather than a live `fs.stat` — the
|
|
426
|
+
* transcript file is gone, so there is nothing on disk to stat, but the preview
|
|
427
|
+
* cache was written with the same `file_mtime_ms`/`file_size` the sessions row
|
|
428
|
+
* still records, so the join re-establishes that stamp. Backs the file-gone
|
|
429
|
+
* render/preview path (RUSH-2436). Returns undefined when no cached digest
|
|
430
|
+
* survives for this session.
|
|
431
|
+
*/
|
|
432
|
+
export declare function readArchivedSessionPreview<T>(id: string): T | undefined;
|
|
406
433
|
/** Plugin provenance already indexed for resources used by one session. */
|
|
407
434
|
export declare function getSessionPlugins(id: string): string[];
|
|
408
435
|
export type UsageRollupGroup = 'agent' | 'project' | 'day' | 'account';
|
|
@@ -562,6 +589,16 @@ export interface TopCostSession {
|
|
|
562
589
|
*/
|
|
563
590
|
export declare function topSessionsByCost(n: number, options?: QueryOptions): TopCostSession[];
|
|
564
591
|
/** Look up a single session by its unique ID. */
|
|
592
|
+
/**
|
|
593
|
+
* Batch-resolve session ids to the machine each one runs on, in ONE indexed
|
|
594
|
+
* query. `getActiveSessions` needs only this column for every live row, and
|
|
595
|
+
* `getSessionById` would re-`prepare` a `SELECT *` and materialize a full
|
|
596
|
+
* `SessionMeta` per id to read it — mirrors {@link findSessionsByShortIds}'s
|
|
597
|
+
* single-round-trip pattern. Ids absent from the index are simply absent from
|
|
598
|
+
* the map. Best-effort: an unavailable DB yields an empty map, so the live view
|
|
599
|
+
* still renders (the caller then leaves rows attributed to this box).
|
|
600
|
+
*/
|
|
601
|
+
export declare function findSessionMachinesByIds(ids: string[]): Map<string, string>;
|
|
565
602
|
export declare function getSessionById(id: string): SessionMeta | null;
|
|
566
603
|
/**
|
|
567
604
|
* Resolve a full-or-partial session id against the index, exact-first then
|
|
@@ -570,6 +607,12 @@ export declare function getSessionById(id: string): SessionMeta | null;
|
|
|
570
607
|
* short id. An exact hit short-circuits so a complete id never also drags in its
|
|
571
608
|
* prefix siblings. `scope` narrows by agent / version / project (cwd) so an
|
|
572
609
|
* ambiguous prefix disambiguates against the caller's context.
|
|
610
|
+
*
|
|
611
|
+
* Routes through the full querySessions existence check (NOT skipExistenceCheck)
|
|
612
|
+
* on purpose (RUSH-2436): that check now KEEPS a file-gone session whose user
|
|
613
|
+
* turns still live in session_text (flagged archived) and only suppresses a
|
|
614
|
+
* contentless phantom — so `agents sessions <id>` resolves an archived session
|
|
615
|
+
* instead of failing with "No session found", while a phantom id still misses.
|
|
573
616
|
*/
|
|
574
617
|
export declare function findSessionsById(idQuery: string, scope?: Pick<QueryOptions, 'agent' | 'version' | 'cwd' | 'project'>): SessionMeta[];
|
|
575
618
|
/**
|
|
@@ -631,3 +674,134 @@ export declare function getRowCount(): {
|
|
|
631
674
|
* Returns the number of session rows updated.
|
|
632
675
|
*/
|
|
633
676
|
export declare function updateSessionFilePaths(oldPrefix: string, newPrefix: string): number;
|
|
677
|
+
/** Per-kind capture tallies for a browser task. Counts only -- never the bytes. */
|
|
678
|
+
export interface BrowserCaptureCounts {
|
|
679
|
+
screenshot: number;
|
|
680
|
+
pdf: number;
|
|
681
|
+
recording: number;
|
|
682
|
+
download: number;
|
|
683
|
+
}
|
|
684
|
+
/** One durable browser-task row. `machine` defaults to this device. */
|
|
685
|
+
export interface BrowserSessionRecord {
|
|
686
|
+
task: string;
|
|
687
|
+
profile: string;
|
|
688
|
+
sessionId?: string;
|
|
689
|
+
launchId?: string;
|
|
690
|
+
actor?: string;
|
|
691
|
+
machine?: string;
|
|
692
|
+
startedAt?: number;
|
|
693
|
+
lastActivity?: number;
|
|
694
|
+
counts?: Partial<BrowserCaptureCounts>;
|
|
695
|
+
captureDir?: string;
|
|
696
|
+
capturesRemote?: string;
|
|
697
|
+
}
|
|
698
|
+
/** One durable computer-use invocation row. `machine` defaults to this device. */
|
|
699
|
+
export interface ComputerSessionRecord {
|
|
700
|
+
invocationId: string;
|
|
701
|
+
sessionId?: string;
|
|
702
|
+
launchId?: string;
|
|
703
|
+
actor?: string;
|
|
704
|
+
machine?: string;
|
|
705
|
+
startedAt?: number;
|
|
706
|
+
lastActivity?: number;
|
|
707
|
+
actionCount?: number;
|
|
708
|
+
taskPreview?: string;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Upsert one browser task's durable metadata.
|
|
712
|
+
*
|
|
713
|
+
* Called at task START. This executes INSIDE the browser daemon (daemon.ts
|
|
714
|
+
* constructs BrowserService; ipc.ts dispatches `start` to it), which makes the
|
|
715
|
+
* shared daemon a writer of this DB — but the identity it writes is RESOLVED IN
|
|
716
|
+
* THE CALLING CLI PROCESS and forwarded over IPC, never resolved here. That
|
|
717
|
+
* distinction is the whole fix: resolving it daemon-side would attribute every
|
|
718
|
+
* task to the daemon's own actor (the RUSH-2020 bug).
|
|
719
|
+
*
|
|
720
|
+
* `agents browser stop` deliberately does NOT delete this row: the whole point
|
|
721
|
+
* is that the link outlives the task.
|
|
722
|
+
*
|
|
723
|
+
* Identity fields are only ever widened, never blanked. A later capture-count
|
|
724
|
+
* update carries no session id, and `COALESCE(excluded.…, browser_sessions.…)`
|
|
725
|
+
* keeps the one recorded at start rather than overwriting it with NULL --
|
|
726
|
+
* otherwise the second write would undo exactly what the first was for.
|
|
727
|
+
*/
|
|
728
|
+
export declare function recordBrowserSession(record: BrowserSessionRecord): void;
|
|
729
|
+
/**
|
|
730
|
+
* Upsert one computer-use invocation's durable metadata.
|
|
731
|
+
*
|
|
732
|
+
* `action_count` accumulates: a `computer run` loop emits many actions under one
|
|
733
|
+
* invocation id, and each arrives as its own call, so the count is incremented
|
|
734
|
+
* rather than replaced. Identity is widened-only, for the same reason as above.
|
|
735
|
+
*/
|
|
736
|
+
export declare function recordComputerSession(record: ComputerSessionRecord): void;
|
|
737
|
+
/** A stored browser row as read back, with counts rehydrated. */
|
|
738
|
+
export interface StoredBrowserSession extends Required<Pick<BrowserSessionRecord, 'task' | 'profile'>> {
|
|
739
|
+
sessionId?: string;
|
|
740
|
+
launchId?: string;
|
|
741
|
+
actor?: string;
|
|
742
|
+
machine: string;
|
|
743
|
+
startedAt: number;
|
|
744
|
+
lastActivity?: number;
|
|
745
|
+
counts: BrowserCaptureCounts;
|
|
746
|
+
captureDir?: string;
|
|
747
|
+
capturesRemote?: string;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Stored browser tasks, newest first; optionally scoped to one profile.
|
|
751
|
+
*
|
|
752
|
+
* A PROFILE-SCOPED read is deliberately unbounded. These rows are the identity
|
|
753
|
+
* for capture dirs that still exist on disk, and dropping the oldest ones would
|
|
754
|
+
* silently regress exactly those tasks to `unlinked` — the symptom this whole
|
|
755
|
+
* change removes, reappearing at a higher threshold. The row count is already
|
|
756
|
+
* bounded by the tasks that profile has ever run, and each row is a short
|
|
757
|
+
* metadata record. Only the unscoped read (every profile, used for overviews)
|
|
758
|
+
* takes a ceiling, since that one has no natural bound.
|
|
759
|
+
*/
|
|
760
|
+
export declare function listBrowserSessionRecords(profile?: string, opts?: {
|
|
761
|
+
limit?: number;
|
|
762
|
+
}): StoredBrowserSession[];
|
|
763
|
+
/** One stored browser task by its (profile, task) key, or null. */
|
|
764
|
+
export declare function getBrowserSessionRecord(profile: string, task: string): StoredBrowserSession | null;
|
|
765
|
+
/** A stored computer-use invocation as read back. */
|
|
766
|
+
export interface StoredComputerSession {
|
|
767
|
+
invocationId: string;
|
|
768
|
+
sessionId?: string;
|
|
769
|
+
launchId?: string;
|
|
770
|
+
actor?: string;
|
|
771
|
+
machine: string;
|
|
772
|
+
startedAt: number;
|
|
773
|
+
lastActivity?: number;
|
|
774
|
+
actionCount: number;
|
|
775
|
+
taskPreview?: string;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Retention for the tool-session tables.
|
|
779
|
+
*
|
|
780
|
+
* These are the durable answer to a ledger that prunes at 7 days, so they are
|
|
781
|
+
* deliberately long-lived — but "durable" is not "unbounded". `computer_sessions`
|
|
782
|
+
* takes one row per `agents computer` CLI PROCESS (`COMPUTER_INVOCATION_ID` is
|
|
783
|
+
* minted per process), and an agent driving a desktop invokes that hundreds of
|
|
784
|
+
* times a day, so an unbounded table would grow without limit and be read in
|
|
785
|
+
* full on every listing.
|
|
786
|
+
*/
|
|
787
|
+
export declare const TOOL_SESSION_MAX_AGE_DAYS = 365;
|
|
788
|
+
/** Default ceiling on rows one listing will read. */
|
|
789
|
+
export declare const TOOL_SESSION_LIST_LIMIT = 2000;
|
|
790
|
+
/**
|
|
791
|
+
* Drop tool-session rows past {@link TOOL_SESSION_MAX_AGE_DAYS}.
|
|
792
|
+
*
|
|
793
|
+
* Called from the listing path, never from the write hot path: an
|
|
794
|
+
* `agents computer` action must not pay for a table sweep (see the fail-soft
|
|
795
|
+
* note on `recordComputerSession`'s caller). Returns rows deleted.
|
|
796
|
+
*/
|
|
797
|
+
export declare function pruneToolSessions(maxAgeDays?: number): number;
|
|
798
|
+
/**
|
|
799
|
+
* Stored computer-use invocations, newest first, bounded.
|
|
800
|
+
*
|
|
801
|
+
* The limit is a real ceiling, not a nicety: `--json` serializes whatever this
|
|
802
|
+
* returns, so an unbounded read would dump the entire table on every call.
|
|
803
|
+
*/
|
|
804
|
+
export declare function listComputerSessionRecords(opts?: {
|
|
805
|
+
limit?: number;
|
|
806
|
+
startedBeforeMs?: number;
|
|
807
|
+
}): StoredComputerSession[];
|