@phnx-labs/agents-cli 1.23.18 → 1.23.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +187 -0
  2. package/README.md +1 -1
  3. package/dist/bootstrap.js +1 -1
  4. package/dist/commands/cloud.js +1 -1
  5. package/dist/commands/config.js +1 -1
  6. package/dist/commands/detach.js +5 -1
  7. package/dist/commands/doctor.js +11 -7
  8. package/dist/commands/exec.d.ts +0 -17
  9. package/dist/commands/exec.js +17 -51
  10. package/dist/commands/focus.d.ts +10 -2
  11. package/dist/commands/focus.js +80 -19
  12. package/dist/commands/projects-todo.js +10 -5
  13. package/dist/commands/ps.d.ts +8 -2
  14. package/dist/commands/ps.js +175 -92
  15. package/dist/commands/sessions-picker.d.ts +0 -7
  16. package/dist/commands/sessions-picker.js +5 -299
  17. package/dist/commands/sessions-stop.js +2 -2
  18. package/dist/lib/account-registry.d.ts +3 -0
  19. package/dist/lib/account-registry.js +40 -0
  20. package/dist/lib/accounting/account-pool-collect.d.ts +2 -2
  21. package/dist/lib/accounting/account-pool-collect.js +4 -4
  22. package/dist/lib/accounting/account-pool.d.ts +1 -1
  23. package/dist/lib/accounting/account-pool.js +3 -1
  24. package/dist/lib/accounting/usage-sync.d.ts +1 -0
  25. package/dist/lib/accounting/usage-sync.js +20 -3
  26. package/dist/lib/accounting/usage.d.ts +4 -1
  27. package/dist/lib/accounting/usage.js +38 -6
  28. package/dist/lib/agent-spec/agents.js +12 -11
  29. package/dist/lib/cloud/store.d.ts +5 -1
  30. package/dist/lib/cloud/store.js +10 -3
  31. package/dist/lib/config-keys.d.ts +1 -1
  32. package/dist/lib/config-keys.js +1 -0
  33. package/dist/lib/daemon/account-state-daemon-service.js +9 -2
  34. package/dist/lib/daemon/self-update-service.js +1 -1
  35. package/dist/lib/device-config.d.ts +2 -1
  36. package/dist/lib/device-config.js +21 -11
  37. package/dist/lib/devices/health.d.ts +6 -0
  38. package/dist/lib/devices/health.js +11 -4
  39. package/dist/lib/feed/watch.js +2 -1
  40. package/dist/lib/fleet/apply.d.ts +1 -1
  41. package/dist/lib/fleet/apply.js +5 -2
  42. package/dist/lib/fleet-shared-state.d.ts +2 -0
  43. package/dist/lib/fleet-shared-state.js +3 -1
  44. package/dist/lib/github/project-prs.js +14 -1
  45. package/dist/lib/helper-versions.js +1 -1
  46. package/dist/lib/installations/versions.js +4 -3
  47. package/dist/lib/project-root.d.ts +1 -0
  48. package/dist/lib/project-root.js +11 -3
  49. package/dist/lib/projects.js +2 -2
  50. package/dist/lib/quick-todo.d.ts +5 -1
  51. package/dist/lib/quick-todo.js +14 -1
  52. package/dist/lib/remote-agents-json.js +4 -2
  53. package/dist/lib/self-update.d.ts +1 -1
  54. package/dist/lib/self-update.js +59 -2
  55. package/dist/lib/session/db.js +1 -1
  56. package/dist/lib/session/glance-files.d.ts +21 -0
  57. package/dist/lib/session/glance-files.js +123 -0
  58. package/dist/lib/session/presentation.d.ts +3 -0
  59. package/dist/lib/session/preview-digest.d.ts +13 -0
  60. package/dist/lib/session/preview-digest.js +328 -0
  61. package/dist/lib/session/recovery.d.ts +1 -1
  62. package/dist/lib/session/recovery.js +1 -1
  63. package/dist/lib/session/remote/remote-list.d.ts +3 -2
  64. package/dist/lib/session/remote/remote-list.js +12 -6
  65. package/dist/lib/session/remote/watch.d.ts +2 -0
  66. package/dist/lib/session/remote/watch.js +86 -5
  67. package/dist/lib/smart-launch.js +6 -1
  68. package/dist/lib/teams/placement-probe.d.ts +2 -0
  69. package/dist/lib/teams/placement-probe.js +8 -3
  70. package/dist/lib/terminal/engine.d.ts +2 -0
  71. package/dist/lib/terminal/engine.js +5 -3
  72. package/dist/lib/terminal/index.d.ts +1 -1
  73. package/dist/lib/terminal/index.js +1 -1
  74. package/dist/lib/terminal/run-surface.d.ts +1 -0
  75. package/dist/lib/terminal/run-surface.js +9 -0
  76. package/package.json +1 -1
  77. package/dist/lib/onepassword.d.ts +0 -57
  78. package/dist/lib/onepassword.js +0 -140
package/CHANGELOG.md CHANGED
@@ -1,5 +1,192 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.20
4
+
5
+ - **Balanced and available rotation never pick an API-key account (owner decision 2026-10-12).**
6
+ A provider account whose credential is an `api-key` or `bearer-token` (OpenRouter,
7
+ an Anthropic or OpenAI API key, LiteLLM, a proxy) bills per token, yet it joined the
8
+ automatic pool beside subscription logins (RUSH-3182). For example, `agents run claude`
9
+ could land on `openrouter-primary` and run Claude through OpenRouter at API prices.
10
+ Only a `setup-token` provider account now joins the pool, beside native logins.
11
+ An api-key account still runs when named: `--account <name>`, a binding, or
12
+ `agents accounts default`. A harness whose only accounts are API keys gets no
13
+ automatic pick from them.
14
+ Source: `cli/src/lib/accounting/account-pool.ts`, `cli/src/lib/accounting/account-pool.test.ts`,
15
+ `cli/src/lib/accounting/account-pool-collect.test.ts`.
16
+
17
+ ## 1.23.19
18
+
19
+ - **`agents projects prs <project> --json` carries `mergeable` and `mergeableState` (PHNX-4326).**
20
+ Every open row had both null, because GitHub's REST PR list never computes them. Each open
21
+ PR the read lists is now read with REST `pulls/{n}` (cached 60 seconds, at most eight at a
22
+ time), the same read and values as the cross-org form and `--number` (`false` / `"dirty"` on
23
+ a conflict). A PR whose read fails keeps both null and the failure is named in `ciError`.
24
+ Source: `src/lib/github/project-prs.ts`.
25
+ - **The Projects tab is retired from `menubar.menu.tabOrder` (PHNX-4326).** `projects` is no
26
+ longer in the default order or required in a stored one; an order or `hiddenTabs` list that
27
+ still names it is accepted and kept in place, so older menus keep working. Source:
28
+ `src/lib/device-config.ts`.
29
+
30
+ - **Cloud tasks nothing has confirmed for a day no longer show as working (PHNX-4326).**
31
+ A `queued`/`allocating`/`running` task whose last update is over 24 hours old is left
32
+ out of the active list and the feed; `agents cloud list` still asks the provider about
33
+ every unsettled task. Source: `src/lib/cloud/store.ts`.
34
+ - **Previous sessions on `agents feed watch --json` arrive with their card text (PHNX-4326).**
35
+ A closed session's row now carries `lastAgentLine`, `request`, `todos`, `artifacts` and
36
+ `importantMessage` like a live row. Before, only 5 of 346 previous rows across the fleet
37
+ had a reply line; on this change's test machine 31 of 41 local previous rows have one
38
+ (the other 10 have no assistant text in their transcript). The text comes from the
39
+ preview digest cached against each transcript, so each transcript is parsed once per
40
+ change: the reset serves what is cached and the stream upserts the rest as it builds
41
+ them. Source: `src/lib/session/remote/watch.ts`, `src/lib/session/preview-digest.ts`.
42
+ - **`agents ps preview` takes several ids (PHNX-4326).** `agents ps preview
43
+ <id> <id> --json` prints one array in argument order, each element the single-id
44
+ envelope plus `query`; an id that does not resolve is an element with `error` set.
45
+ One id still prints the single object. See `docs/menubar.md`. Source:
46
+ `src/commands/ps.ts`.
47
+ - **`agents ps preview --json` carries `subAgents`, `images` and
48
+ `producedArtifacts`, and `todos` folds Claude's task tools (PHNX-4326).** `subAgents` lists each spawned subagent with its
49
+ status and duration, `images` the last six images the session was given, read or
50
+ wrote that still exist on disk, and `todos` now includes `TaskCreate`/`TaskUpdate`
51
+ checklists. `producedArtifacts` is the list a live feed row's `artifacts` holds.
52
+ See `docs/menubar.md`. Source: `src/lib/session/preview-digest.ts`,
53
+ `src/lib/session/glance-files.ts`.
54
+
55
+ - **Accounts added on your personal device reach the workers without a git pull (PHNX-4342).**
56
+ `agents accounts add` writes the account row to `~/.agents/agents.yaml` and only
57
+ commits it locally. A worker learned the row only after a user-repo push and pull, so
58
+ a worker whose `~/.agents` had diverged never saw it. `agents accounts login
59
+ <harness>#<name> --per-device` then failed there with `No grok account '<name>'`. A
60
+ personal or desktop device now publishes its per-device account rows in the fleet state
61
+ it already exchanges with peers. A worker adds any row
62
+ it lacks when the sender is headed and created that row; it never overwrites or
63
+ removes a local row. Only per-device accounts travel this way, and only their identity
64
+ fields; a credential reference never does. Rows added before the `provisioning` field
65
+ existed are not sent; workers already have those from earlier user-repo pulls. Each
66
+ worker still signs in for itself with `--per-device`.
67
+ Source: `cli/src/lib/daemon/account-state-daemon-service.ts`,
68
+ `cli/src/lib/accounting/usage-sync.ts`, `cli/src/lib/account-registry.ts`.
69
+
70
+ - **A Grok account with no balance left reads as out of credits (PHNX-4342).** When xAI
71
+ refuses a turn with `402 Payment Required: Grok Build usage balance exhausted`, that
72
+ account now shows `out of credits` for one hour, and rotation and `--device auto` skip
73
+ it instead of choosing it again. Before this, Grok usage came only from the last
74
+ `billing: fetched credits config` log line, which could be days old, so an exhausted
75
+ account still read as ready. Only that balance message counts; another 402 does not.
76
+ Source: `cli/src/lib/accounting/usage.ts`.
77
+ - **A Grok, Kimi or Muse version with no login of its own reads as signed out.** The
78
+ launcher points these harnesses at their version home (`GROK_HOME`, `KIMI_CODE_HOME`,
79
+ XDG), so they never read the shared `~/.grok` or `~/.kimi-code` login. The account
80
+ check did read it, and listed a version as signed in with that account while the
81
+ harness itself said `Not signed in`. Cursor, Droid and Antigravity keep their
82
+ shared-home lookup. Source: `cli/src/lib/agent-spec/agents.ts`.
83
+
84
+ - **A Codex install whose platform binary npm skipped is now caught and repaired (PHNX-4342).**
85
+ Codex 0.162 reports a missing platform package as `Missing optional dependency
86
+ @openai/codex-linux-x64`, which the launch check did not recognize, so it passed a
87
+ dead binary. Updates committed it, the daemon never healed it, and `agents run codex`
88
+ launched it and exited 1 within a fraction of a second, which showed up as
89
+ `Connection to <device> closed.` after `--device auto`. The check now recognizes that
90
+ wording, so the run repairs the install before it launches, and an update that
91
+ produces one rolls back. Its message now quotes the matching line instead of a stack
92
+ frame. Source: `cli/src/lib/installations/versions.ts`.
93
+ - **`--device auto` no longer says `no ready harness account` when it never heard back (PHNX-4342).**
94
+ When a worker's readiness probe ran past its 8 second budget, the refusal said the
95
+ worker had no ready account even when it had a signed-in one. It now says
96
+ `readiness probe timed out` and counts it in the retry hint, or `readiness probe did
97
+ not answer` for any other silent failure. A worker that did answer `not ready` now
98
+ shows its own reason, for example `no ready harness account (all signed_out)`. That
99
+ reason was being dropped before it reached the message.
100
+ Source: `cli/src/lib/teams/placement-probe.ts`, `cli/src/lib/smart-launch.ts`.
101
+
102
+ - **`agents ps focus` on a headless session stops it before reopening it in a tab (PHNX-4344).**
103
+ Focusing a session that was running headless used to resume a second copy in a new tab
104
+ while the headless process kept running, so two processes wrote to one conversation. Focus
105
+ now stops the headless process first (here, or with `agents ps stop <id> --local` on the
106
+ device that runs it) and clears its detach record, and opens nothing if that device cannot
107
+ be reached or its `ps stop` exits non-zero. The focus picker does the same for each headless
108
+ session it opens. If the tab then fails to open, the error says the headless run was stopped
109
+ and how to resume it. The tab now goes where your live sessions run (`resolveLaunchBackend`), so from
110
+ AGI Menu it opens in the project's VSCodium window instead of the first installed terminal
111
+ app. A session owned by another device opens a local tab running
112
+ `agents run auto --resume <id> --interactive` when there is no TTY, instead of an SSH hop
113
+ that needs one. A session that has already ended, focused with no TTY, now also opens in
114
+ such a tab instead of resuming in place inside the caller (which failed with no terminal and
115
+ still exited 0). When VSCodium never confirms the tab, focus exits 1 and says to approve the
116
+ "Allow 'Agents' extension to open this URI?" prompt. Source: `cli/src/commands/focus.ts`,
117
+ `cli/src/commands/detach.ts`, `cli/src/lib/terminal/engine.ts`.
118
+ - **Sessions from another machine's home now match their project (PHNX-4344).** A session
119
+ recorded on a Linux worker under `/home/<user>/…` now matches a project registered as
120
+ `~/…` on a Mac (and the other way round) when `<user>` is the same user name; `/Users/Shared`
121
+ and other users' homes are not rewritten, so AGI Menu groups those sessions under the right
122
+ project instead of Uncategorized. Source: `cli/src/lib/project-root.ts` (`localizeHome`),
123
+ `cli/src/lib/projects.ts`.
124
+ - **`agents projects todo list --project <name>` and `menubar.menu.todoProject` (PHNX-4344).**
125
+ `--project` lists every open issue in that Linear project (an agents project's Linear
126
+ project, or a Linear project name), due ones first, then the newest, at most 6, with
127
+ `total` the full count. The new `menubar.menu.todoProject` key names the project AGI Menu
128
+ lists and files to-dos in, and rides `agents menubar snapshot --json` `menuPreferences`
129
+ when set. Source: `cli/src/lib/quick-todo.ts`, `cli/src/commands/projects-todo.ts`,
130
+ `cli/src/lib/device-config.ts`.
131
+ - **AGI Menu shows draft pull requests by default (PHNX-4344).** `menubar.menu.githubDrafts`
132
+ now defaults to `true`; `githubBots` stays `false`. Source: `cli/src/lib/device-config.ts`.
133
+ - **`agents ps stop` on another device exits 1 when the remote stop fails (PHNX-4344).** A
134
+ one-shot peer hop (`runOnPeer` without a TTY) now reports a non-zero remote exit as `failed`
135
+ instead of `ok`. Source: `cli/src/lib/session/remote/remote-list.ts`,
136
+ `cli/src/commands/sessions-stop.ts`.
137
+
138
+ - **`agents upgrade` works again on a bun-installed copy.** Every upgrade on a
139
+ bun install failed at the install step with `error: An internal error occurred
140
+ (DependencyLoop)` and left the CLI on the version it already had, because
141
+ `bun add -g <tarball>` refuses to resolve a tarball whose package name is
142
+ already pinned to an exact version in bun's global `package.json` — it keeps
143
+ the old requirement alongside the tarball resolution and reports the package
144
+ as depending on itself (bun 1.3.14). `installPackageWithBun` now clears that
145
+ entry before the install and writes it back as the version actually on disk
146
+ afterwards; the second half matters too, since bun otherwise records the
147
+ tarball's path under the upgrade's temp directory, which is deleted on the way
148
+ out and breaks the next `bun install -g`. An install that fails or is aborted
149
+ puts the entry back, so a failed upgrade no longer leaves the CLI installed
150
+ but unpinned — a state in which `bun remove -g` reports success and removes
151
+ nothing. Neither `bun.lock` nor `trustedDependencies` is involved, and the
152
+ npm install path is unchanged.
153
+ Source: `cli/src/lib/self-update.ts`, `cli/src/lib/self-update.test.ts`.
154
+
155
+ - **An `out of credits` mark no longer strands a Claude account for good.** A run
156
+ refused with "You've hit your monthly spend limit" or "out of usage credits"
157
+ writes a per-account `out_of_credits` mark in `~/.agents/.cache/claude-usage.json`,
158
+ and rotation (`balanced`, `available`) skips a marked account. The mark had no
159
+ expiry, and its only clear was a successful run on that account, which rotation
160
+ never launches. On one box three of four Claude accounts sat marked for up to 14
161
+ days while answering fine, and every `agents run claude` landed on the one login
162
+ that was actually refusing. The mark now records when it was noted and expires
163
+ after one hour (`OUT_OF_CREDITS_REPROBE_MS`), so rotation tries the account again;
164
+ a fresh refusal re-marks it. A mark written by an older CLI reads as expired.
165
+ `agents view` shows `out of credits` only while the mark is live.
166
+ Source: `cli/src/lib/accounting/usage.ts`, `cli/src/lib/accounting/usage.test.ts`.
167
+
168
+ - **Fleet probes follow the configured `platform`, not the discovered one.** A box Tailscale
169
+ reports as Windows but whose sshd lands in WSL, configured `agents devices config <name>
170
+ platform linux`, was dialed as a bash login shell yet handed the PowerShell snippet — so
171
+ `agents devices list --refresh` showed it offline, the `agents ps` fleet roster skipped it as
172
+ "unreachable or no agents CLI", and `agents ps watch` / `agents feed watch` /
173
+ `agents apply` / `agents doctor --check` never reached it, even though `agents ssh <name>`
174
+ worked. Each of those paths now resolves the operator profile before choosing the remote shell,
175
+ the same profile the dial already used. Source: `cli/src/lib/devices/health.ts` (`buildProbeInvocation`),
176
+ `cli/src/lib/session/remote/{remote-list,watch}.ts`, `cli/src/lib/feed/watch.ts`,
177
+ `cli/src/lib/fleet/apply.ts`, `cli/src/lib/teams/placement-probe.ts`,
178
+ `cli/src/lib/accounting/usage-sync.ts`, `cli/src/lib/remote-agents-json.ts`,
179
+ `cli/src/commands/doctor.ts`.
180
+
181
+ - **A bare interactive `agents run <harness>` runs on the machine you typed it on again.**
182
+ Since PHNX-4083 a bare human-facing run (no prompt, real TTY) placed itself like
183
+ `--device auto`, so `agents run claude` on a laptop landed on whichever fleet worker had
184
+ the most headroom, including a Windows box the operator never chose. Placement is now
185
+ opt-in: `--device auto`, `--device <box>`, or the `<harness>@` picker. Headless runs are
186
+ unchanged, and `--local` still pins this machine against a `--where` default. The
187
+ `Run here instead` hint is gone with the default that needed it.
188
+ Source: `cli/src/commands/exec.ts`, `cli/docs/hosts.md`.
189
+
3
190
  ## 1.23.18
4
191
 
5
192
  - **Fleet hops call peers by the canonical `ps` and `daemon index` spellings (PHNX-4227).**
package/README.md CHANGED
@@ -213,7 +213,7 @@ agents run claude@ # pick the device for this run
213
213
  agents run claude#@ # pick the account, then the device
214
214
  ```
215
215
 
216
- `--strategy balanced` spreads work across available versions of the same agent -- useful when you have multiple accounts and want to avoid burning through one. When a Claude run reports a session limit, agents-cli records the stated reset time, shows `session-limited` in `agents view`, and excludes that account until the reset. When every account is rate-limited, the run exits nonzero naming each excluded account and the earliest window reset (use `--strategy pinned` to force a rate-limited default) -- it never launches into an exhausted account. A logged-out default is never forced: unpinned dispatch picks a signed-in version on the execution device instead of dying on a credential-less default home.
216
+ `--strategy balanced` spreads work across available versions of the same agent -- useful when you have multiple accounts and want to avoid burning through one. It picks only subscription logins and setup-tokens; an API-key account (OpenRouter, an Anthropic or OpenAI key) bills per token, so it runs only when you name it with `--account`. When a Claude run reports a session limit, agents-cli records the stated reset time, shows `session-limited` in `agents view`, and excludes that account until the reset. When every account is rate-limited, the run exits nonzero naming each excluded account and the earliest window reset (use `--strategy pinned` to force a rate-limited default) -- it never launches into an exhausted account. A logged-out default is never forced: unpinned dispatch picks a signed-in version on the execution device instead of dying on a credential-less default home.
217
217
 
218
218
  ### Don't care which harness? `agents run auto`
219
219
 
package/dist/bootstrap.js CHANGED
@@ -228,7 +228,7 @@ async function installResolvedPackage(metadata) {
228
228
  try {
229
229
  await sweepStaleInstallStaging(packageRoot);
230
230
  if (detectPackageManager(packageRoot) === 'bun') {
231
- await installPackageWithBun(tarball);
231
+ await installPackageWithBun(tarball, deriveGlobalPrefix(packageRoot));
232
232
  }
233
233
  else {
234
234
  await installPackageIntoPrefix(tarball, deriveGlobalPrefix(packageRoot));
@@ -253,7 +253,7 @@ Examples:
253
253
  const providerId = options.provider;
254
254
  const status = options.status;
255
255
  const limit = parseInt(options.limit, 10) || 20;
256
- const activeTasks = listActiveTasks();
256
+ const activeTasks = listActiveTasks({ includeStale: true });
257
257
  if (activeTasks.length > 0) {
258
258
  const byProvider = new Map();
259
259
  for (const t of activeTasks) {
@@ -416,7 +416,7 @@ export function registerConfigCommand(program) {
416
416
  agents config set devices.mac-mini.max-agents 4
417
417
  agents config set updates.auto off
418
418
  agents config set updates.claude.auto off
419
- agents config set menubar.menu.tabOrder home,goals,sessions,projects,inbox
419
+ agents config set menubar.menu.tabOrder home,goals,sessions,inbox
420
420
  agents config set menubar.menu.pinnedProjects '["Rush","AGI Menu"]'
421
421
  agents config set menubar.menu.homeGoals company,myDay
422
422
  agents config set menubar.statusbar.goalCountdown on
@@ -7,7 +7,7 @@ import { killSession } from '../lib/tmux/index.js';
7
7
  import { getDefaultSocketPath } from '../lib/tmux/paths.js';
8
8
  import { getAgentsInvocation } from '../lib/daemon/daemon.js';
9
9
  import { captureProcessStartTime } from '../lib/platform/process.js';
10
- import { writeDetachRecord } from '../lib/session/detached.js';
10
+ import { clearDetachRecord, writeDetachRecord } from '../lib/session/detached.js';
11
11
  import { getLogsDir } from '../lib/state.js';
12
12
  import { runOnPeer } from '../lib/session/remote-list.js';
13
13
  import { buildBackgroundArgv, resolveDetachTarget, resolveOne } from './detach-core.js';
@@ -41,11 +41,15 @@ export async function stopInteractive(s, socket = getDefaultSocketPath()) {
41
41
  process.kill(s.pid, 'SIGTERM');
42
42
  }
43
43
  catch {
44
+ if (s.sessionId)
45
+ clearDetachRecord(s.sessionId);
44
46
  return;
45
47
  }
46
48
  }
47
49
  if (s.pid && s.pid > 0)
48
50
  await waitForExit(s.pid);
51
+ if (s.sessionId)
52
+ clearDetachRecord(s.sessionId);
49
53
  }
50
54
  async function waitForExit(pid, timeoutMs = 5000) {
51
55
  const deadline = Date.now() + timeoutMs;
@@ -14,6 +14,7 @@ import { resolveHost } from '../lib/hosts/registry.js';
14
14
  import { sshExecAsync } from '../lib/ssh-exec.js';
15
15
  import { hostIdentityArgs, sshTargetFor } from '../lib/hosts/types.js';
16
16
  import { deviceIdentityArgs } from '../lib/devices/connect.js';
17
+ import { resolveDeviceProfile } from '../lib/devices/resolve-profile.js';
17
18
  import { machineId, normalizeHost } from '../lib/session/sync/config.js';
18
19
  import { findAmbiguousDevicePins } from '../lib/scheduling/routines.js';
19
20
  import { findLeakedDaemons } from '../lib/daemon/leaked-daemons.js';
@@ -192,12 +193,15 @@ async function resolveFleetTargets(opts) {
192
193
  const localName = machineId();
193
194
  return Object.values(registry)
194
195
  .filter((d) => normalizeHost(d.name) !== localName)
195
- .map((d) => ({
196
- name: d.name,
197
- sshTarget: d.name,
198
- os: d.platform !== 'unknown' ? d.platform : undefined,
199
- extraSshArgs: deviceIdentityArgs(d),
200
- }));
196
+ .map((d) => {
197
+ const platform = resolveDeviceProfile(d).platform;
198
+ return {
199
+ name: d.name,
200
+ sshTarget: d.name,
201
+ os: platform !== 'unknown' ? platform : undefined,
202
+ extraSshArgs: deviceIdentityArgs(d),
203
+ };
204
+ });
201
205
  }
202
206
  async function probeFleetTarget(target) {
203
207
  const forwarded = ['teams', 'doctor', '--json'];
@@ -1001,7 +1005,7 @@ async function runDevicesCheck(opts, cwd) {
1001
1005
  const remoteTargets = remoteFleetTargets(planned, self)
1002
1006
  .map((t) => ({
1003
1007
  name: t.device.name,
1004
- platform: t.device.platform,
1008
+ platform: resolveDeviceProfile(t.device).platform,
1005
1009
  skip: t.skip,
1006
1010
  dialTarget: fleetDialTarget(t.device),
1007
1011
  extraSshArgs: deviceIdentityArgs(t.device),
@@ -128,23 +128,6 @@ export declare function runAutoDefaultsToAffinity(options: {
128
128
  computer?: string;
129
129
  local?: boolean;
130
130
  }, env?: NodeJS.ProcessEnv): boolean;
131
- export declare function bareInteractiveRunDefaultsToDeviceAuto(options: {
132
- host?: string;
133
- device?: string;
134
- on?: string;
135
- computer?: string;
136
- resume?: string | boolean;
137
- lease?: string | boolean;
138
- box?: string;
139
- cloud?: boolean;
140
- local?: boolean;
141
- }, run: {
142
- prompt?: string;
143
- devicePickerRequested?: boolean;
144
- }, surface: {
145
- tty: boolean;
146
- json?: boolean;
147
- }, env?: NodeJS.ProcessEnv): boolean;
148
131
  export declare function hostInteractiveNeedsCorrelationId(runAgent: string, hostSessionId: string | undefined, resumeId: string | undefined): boolean;
149
132
  export declare function isInsideGitWorkTree(cwd: string): boolean;
150
133
  export declare function gitToplevel(cwd: string): string | null;
@@ -5,7 +5,6 @@ import { RUN_AUTO_KEYWORD } from '../lib/types.js';
5
5
  import { setHelpSections } from '../lib/help.js';
6
6
  import { formatModeSupportTable } from '../lib/agent-modes.js';
7
7
  import { isInteractiveTerminal, isPromptCancelled, requireInteractiveSelection } from './utils.js';
8
- import { isHumanFacingRun } from './run-account-picker.js';
9
8
  import { getUserAgentsDir, readMeta } from '../lib/state.js';
10
9
  import { parseLoopInterval } from '../lib/loop.js';
11
10
  import { AGENTS, resolveAgentName, isAgentHardDeprecated, hardDeprecationError } from '../lib/agents.js';
@@ -116,17 +115,6 @@ export function runAutoDefaultsToAffinity(options, env = process.env) {
116
115
  return false;
117
116
  return env.AGENTS_REMOTE_INTERACTIVE !== '1';
118
117
  }
119
- export function bareInteractiveRunDefaultsToDeviceAuto(options, run, surface, env = process.env) {
120
- if (run.prompt !== undefined)
121
- return false;
122
- if (!isHumanFacingRun({ tty: surface.tty, json: surface.json === true }))
123
- return false;
124
- if (run.devicePickerRequested)
125
- return false;
126
- if (options.resume !== undefined || options.lease || options.box || options.cloud)
127
- return false;
128
- return runAutoDefaultsToAffinity(options, env);
129
- }
130
118
  export function hostInteractiveNeedsCorrelationId(runAgent, hostSessionId, resumeId) {
131
119
  if (resumeId)
132
120
  return false;
@@ -343,7 +331,7 @@ export async function resolveRunCwd(options, opts) {
343
331
  }
344
332
  }
345
333
  async function handleTerminalHandoff(agentSpec, options, prompt) {
346
- const { parseTerminalFlag, openRunInTerminal, toHostSamples, currentContext } = await import('../lib/terminal/index.js');
334
+ const { parseTerminalFlag, openRunInTerminal, liveHostSamples, currentContext } = await import('../lib/terminal/index.js');
347
335
  const parsed = parseTerminalFlag(options.terminal);
348
336
  if (parsed.error) {
349
337
  console.error(chalk.red(parsed.error));
@@ -378,13 +366,7 @@ async function handleTerminalHandoff(agentSpec, options, prompt) {
378
366
  process.exit(1);
379
367
  }
380
368
  const cwd = await resolveRunCwd(options, { forRemote: false });
381
- const { getActiveSessions } = await import('../lib/session/active.js');
382
- let sessions = [];
383
- try {
384
- sessions = await toHostSamples(await getActiveSessions());
385
- }
386
- catch {
387
- }
369
+ const sessions = await liveHostSamples();
388
370
  const result = await openRunInTerminal({
389
371
  argv: process.argv.slice(2),
390
372
  forced: parsed.backend,
@@ -464,7 +446,7 @@ export function registerRunCommand(program) {
464
446
  .option('--until <signal>', 'Loop stop condition. `signal` reads <runDir>/loop-signal.json {continue,reason} each iteration; absent or continue:false stops (fail-closed). Loop only.')
465
447
  .option('--interval <dur>', 'Loop delay between iterations ("0" back-to-back, "30m" paces). Loop only.')
466
448
  .option('--where <spec>', 'Where this run\'s body executes (one placement door): local | device:<name> | auto | lease[:backend] | cloud[:provider]. Expands to --device/--lease/--cloud. Do not combine with those flags. See docs/00-concepts.md#placement.')
467
- .option('--local', 'Run on this machine. A bare interactive run otherwise places itself like --device auto; --local pins it here. Same as --where local or --device <this machine>.')
449
+ .option('--local', 'Run on this machine, the default for a bare run. Pins it against --where defaults and run-auto affinity. Same as --where local or --device <this machine>.')
468
450
  .option('-D, --device <name>', 'Offload this run onto another machine over SSH — a registered device, or user@host. Pass "auto" to pick the least-loaded reachable device where the requested agent is installed and signed in, keeping the run local when no remote is better, or "interactive" for the machine pinned as interactive.host (the box a human is sitting at). Naming this machine runs locally, no SSH. Same as --where device:<name>. See `agents devices`.')
469
451
  .option('--remote-cwd <dir>', "Explicit device working directory for --device runs, used VERBATIM (overrides --cwd; usually --cwd suffices — it re-roots a local-home path onto the remote home). Pass a single-quoted '$HOME/…' or a valid remote absolute path; a local ~ expands here and won't exist there (/Users/you vs /home/you).")
470
452
  .option('--no-follow', 'With --device, dispatch detached and return immediately (track via `agents devices ps` and `agents events logs`).')
@@ -495,10 +477,9 @@ export function registerRunCommand(program) {
495
477
  # Headless, can edit: have the agent make changes
496
478
  agents run claude "fix lint errors in src/" --mode edit
497
479
 
498
- # Interactive (TUI): a bare run places itself like --device auto (a fleet
499
- # worker, TUI forwarded over SSH); --local keeps it on this machine
480
+ # Interactive (TUI): a bare run starts on this machine
500
481
  agents run claude
501
- agents run claude --local # stay local (or pick this machine in claude@)
482
+ agents run claude --device auto # ...or let the fleet place it (TUI over SSH)
502
483
 
503
484
  # Pick a signed-in account/version for only this run (# = account picker)
504
485
  agents run claude#
@@ -607,13 +588,11 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
607
588
  with an explicit pin of the same thing (--account, --device/--on/
608
589
  --computer/--host) or with --strategy/--balanced/--resume/--lease/--box.
609
590
 
610
- Interactive placement: a bare 'agents run <harness>' (no prompt, real TTY)
611
- places itself like --device auto — a fleet worker runs it, with the TUI
612
- forwarded over SSH. Headless runs (any prompt, --json, no TTY) are
613
- unchanged: they run in place. To stay on this machine, pass --local
614
- (--device <this machine> means the same), or pick this machine (listed
615
- first) in the '<harness>@' device picker. When placement finds no
616
- healthy device the run fails loud and names the local spelling.
591
+ Interactive placement: a bare 'agents run <harness>' runs on this
592
+ machine. Placement is opt-in: --device auto (a fleet worker runs it,
593
+ TUI forwarded over SSH), --device <box>, or the '<harness>@' device
594
+ picker. When automatic placement finds no healthy device the run fails
595
+ loud rather than silently running here.
617
596
 
618
597
  Fallback: --fallback codex,antigravity retries on rate-limit failure via /continue handoff. Each entry accepts @version.
619
598
 
@@ -626,7 +605,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
626
605
  given. --cloud is mutually exclusive with --device/--lease and with
627
606
  local-run flags (--loop, --resume, --secrets, --terminal, …).
628
607
 
629
- Resume: --resume <id> resolves full IDs locally first, then fleet-wide, and recovers on the source device with its cwd/mode. Resume preserves the conversation account and uses the installed binary; starting a new conversation from archived context requires an explicit choice. With auto as the agent (agents run auto --resume <id>) the harness is inferred from the session; a named agent must match it. A bare --resume opens the session picker for the last 30 days of this project (up to 200 rows); --all widens it to every directory and lifts the 30d window, --teams adds team-spawned sessions, --since <time> and -n/--limit <n> set the window and row cap. These four only filter the picker: they are refused next to --resume <id> or without --resume.
608
+ Resume: --resume <id> resolves full IDs locally first, then fleet-wide, and recovers on the source device with its cwd/mode. Resume preserves the conversation account (an API-key account only when named with --account; otherwise it continues on a subscription account) and uses the installed binary; starting a new conversation from archived context requires an explicit choice. With auto as the agent (agents run auto --resume <id>) the harness is inferred from the session; a named agent must match it. A bare --resume opens the session picker for the last 30 days of this project (up to 200 rows); --all widens it to every directory and lifts the 30d window, --teams adds team-spawned sessions, --since <time> and -n/--limit <n> set the window and row cap. These four only filter the picker: they are refused next to --resume <id> or without --resume.
630
609
 
631
610
  Passthrough: everything after -- is forwarded verbatim to the underlying agent CLI.
632
611
  agents run kimi -- --plan --some-native-flag value
@@ -961,27 +940,14 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
961
940
  if (!isSelfHost(pickedDevice))
962
941
  options.device = pickedDevice;
963
942
  }
964
- const defaultPlacement = bareInteractiveRunDefaultsToDeviceAuto(options, { prompt, devicePickerRequested }, { tty: isInteractiveTerminal(), json: options.json });
965
- if (defaultPlacement)
966
- options.device = 'auto';
967
943
  {
968
944
  const { applyDeviceAutoToOptions } = await import('../lib/smart-launch.js');
969
- let result;
970
- try {
971
- result = await applyDeviceAutoToOptions(options, {
972
- accountPickerRequested,
973
- agent: normalizedAgentSpec.split('#')[0].split('@')[0] === RUN_AUTO_KEYWORD
974
- ? undefined
975
- : (resolveAgentName(normalizedAgentSpec.split('#')[0].split('@')[0]) ?? undefined),
976
- });
977
- }
978
- catch (err) {
979
- if (!defaultPlacement)
980
- throw err;
981
- console.error(chalk.red(err.message));
982
- console.error(chalk.gray(`Run here instead: agents run ${runBaseAgentName} --local`));
983
- process.exit(1);
984
- }
945
+ const result = await applyDeviceAutoToOptions(options, {
946
+ accountPickerRequested,
947
+ agent: normalizedAgentSpec.split('#')[0].split('@')[0] === RUN_AUTO_KEYWORD
948
+ ? undefined
949
+ : (resolveAgentName(normalizedAgentSpec.split('#')[0].split('@')[0]) ?? undefined),
950
+ });
985
951
  if (!options.quiet && result.banner) {
986
952
  const { hostLabel, deviceHint, acctNote } = result.banner;
987
953
  process.stderr.write(chalk.gray(`[agents] device=auto → ${hostLabel}` +
@@ -4,7 +4,7 @@ import { type ActiveSession } from '../lib/session/active.js';
4
4
  import { type SessionMeta } from '@phnx-labs/sessions-cli/reader';
5
5
  export { looksLikeTmuxAlias, resolveTmuxAliasState, shouldAttachLocalTmuxAliasBeforeFleet, type TmuxAliasState } from '../lib/session/local-tmux-attach.js';
6
6
  import { type LiveStatusFilter } from './ps-roster.js';
7
- import { openSurfaces, type Backend } from '../lib/terminal/index.js';
7
+ import { openSurfaces, type Backend, type LaunchBackendChoice } from '../lib/terminal/index.js';
8
8
  interface FocusOptions {
9
9
  launchId?: string;
10
10
  local?: boolean;
@@ -52,7 +52,7 @@ export declare function focusAction(id: string | undefined, opts: FocusOptions):
52
52
  export declare function isAttachableLiveSession(session: ActiveSession): boolean;
53
53
  export declare function dedupeSessionsByLogicalId(rows: SessionMeta[], self?: string): SessionMeta[];
54
54
  export declare function focusTargetForResolved(poolMatch: SessionMeta | undefined, resolved: SessionMeta): SessionMeta;
55
- export declare function focusResolvedSession(meta: SessionMeta, liveById: Map<string, ActiveSession>, self: string, fallback: UnreachableFallback, attachOnly: boolean, reconnectReattach?: boolean): Promise<void>;
55
+ export declare function focusResolvedSession(meta: SessionMeta, liveById: Map<string, ActiveSession>, self: string, fallback: UnreachableFallback, attachOnly: boolean, reconnectReattach?: boolean, deps?: TakeoverDeps): Promise<void>;
56
56
  export declare function focusSelectedSession(meta: SessionMeta, active: ActiveSession | undefined, self: string): Promise<void>;
57
57
  type FocusSurfacePlan = {
58
58
  kind: 'attach';
@@ -81,3 +81,11 @@ interface OpenFocusTabsDeps {
81
81
  }
82
82
  export declare function openFocusTabs(targets: ActiveSession[], self: string, deps?: OpenFocusTabsDeps): Promise<void>;
83
83
  export declare function metaFromActive(s: ActiveSession): SessionMeta;
84
+ export declare function isLiveHeadless(s: ActiveSession): boolean;
85
+ export interface TakeoverDeps {
86
+ open?: OpenSurfacesFn;
87
+ choice?: LaunchBackendChoice | null;
88
+ interactive?: boolean;
89
+ meta?: SessionMeta;
90
+ }
91
+ export declare function resumeInTab(s: ActiveSession, remote: string | undefined, deps?: TakeoverDeps): Promise<void>;