@phnx-labs/agents-cli 1.23.18 → 1.23.19
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 +173 -0
- package/dist/bootstrap.js +1 -1
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/config.js +1 -1
- package/dist/commands/detach.js +5 -1
- package/dist/commands/doctor.js +11 -7
- package/dist/commands/exec.d.ts +0 -17
- package/dist/commands/exec.js +16 -50
- package/dist/commands/focus.d.ts +10 -2
- package/dist/commands/focus.js +80 -19
- package/dist/commands/projects-todo.js +10 -5
- package/dist/commands/ps.d.ts +8 -2
- package/dist/commands/ps.js +175 -92
- package/dist/commands/sessions-picker.d.ts +0 -7
- package/dist/commands/sessions-picker.js +5 -299
- package/dist/commands/sessions-stop.js +2 -2
- package/dist/lib/account-registry.d.ts +3 -0
- package/dist/lib/account-registry.js +40 -0
- package/dist/lib/accounting/usage-sync.d.ts +1 -0
- package/dist/lib/accounting/usage-sync.js +20 -3
- package/dist/lib/accounting/usage.d.ts +4 -1
- package/dist/lib/accounting/usage.js +38 -6
- package/dist/lib/agent-spec/agents.js +12 -11
- package/dist/lib/cloud/store.d.ts +5 -1
- package/dist/lib/cloud/store.js +10 -3
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +1 -0
- package/dist/lib/daemon/account-state-daemon-service.js +9 -2
- package/dist/lib/daemon/self-update-service.js +1 -1
- package/dist/lib/device-config.d.ts +2 -1
- package/dist/lib/device-config.js +21 -11
- package/dist/lib/devices/health.d.ts +6 -0
- package/dist/lib/devices/health.js +11 -4
- package/dist/lib/feed/watch.js +2 -1
- package/dist/lib/fleet/apply.d.ts +1 -1
- package/dist/lib/fleet/apply.js +5 -2
- package/dist/lib/fleet-shared-state.d.ts +2 -0
- package/dist/lib/fleet-shared-state.js +3 -1
- package/dist/lib/github/project-prs.js +14 -1
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/installations/versions.js +4 -3
- package/dist/lib/project-root.d.ts +1 -0
- package/dist/lib/project-root.js +11 -3
- package/dist/lib/projects.js +2 -2
- package/dist/lib/quick-todo.d.ts +5 -1
- package/dist/lib/quick-todo.js +14 -1
- package/dist/lib/remote-agents-json.js +4 -2
- package/dist/lib/self-update.d.ts +1 -1
- package/dist/lib/self-update.js +59 -2
- package/dist/lib/session/db.js +1 -1
- package/dist/lib/session/glance-files.d.ts +21 -0
- package/dist/lib/session/glance-files.js +123 -0
- package/dist/lib/session/presentation.d.ts +3 -0
- package/dist/lib/session/preview-digest.d.ts +13 -0
- package/dist/lib/session/preview-digest.js +328 -0
- package/dist/lib/session/remote/remote-list.d.ts +3 -2
- package/dist/lib/session/remote/remote-list.js +12 -6
- package/dist/lib/session/remote/watch.d.ts +2 -0
- package/dist/lib/session/remote/watch.js +86 -5
- package/dist/lib/smart-launch.js +6 -1
- package/dist/lib/teams/placement-probe.d.ts +2 -0
- package/dist/lib/teams/placement-probe.js +8 -3
- package/dist/lib/terminal/engine.d.ts +2 -0
- package/dist/lib/terminal/engine.js +5 -3
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/run-surface.d.ts +1 -0
- package/dist/lib/terminal/run-surface.js +9 -0
- package/package.json +1 -1
- package/dist/lib/onepassword.d.ts +0 -57
- package/dist/lib/onepassword.js +0 -140
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,178 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.19
|
|
4
|
+
|
|
5
|
+
- **`agents projects prs <project> --json` carries `mergeable` and `mergeableState` (PHNX-4326).**
|
|
6
|
+
Every open row had both null, because GitHub's REST PR list never computes them. Each open
|
|
7
|
+
PR the read lists is now read with REST `pulls/{n}` (cached 60 seconds, at most eight at a
|
|
8
|
+
time), the same read and values as the cross-org form and `--number` (`false` / `"dirty"` on
|
|
9
|
+
a conflict). A PR whose read fails keeps both null and the failure is named in `ciError`.
|
|
10
|
+
Source: `src/lib/github/project-prs.ts`.
|
|
11
|
+
- **The Projects tab is retired from `menubar.menu.tabOrder` (PHNX-4326).** `projects` is no
|
|
12
|
+
longer in the default order or required in a stored one; an order or `hiddenTabs` list that
|
|
13
|
+
still names it is accepted and kept in place, so older menus keep working. Source:
|
|
14
|
+
`src/lib/device-config.ts`.
|
|
15
|
+
|
|
16
|
+
- **Cloud tasks nothing has confirmed for a day no longer show as working (PHNX-4326).**
|
|
17
|
+
A `queued`/`allocating`/`running` task whose last update is over 24 hours old is left
|
|
18
|
+
out of the active list and the feed; `agents cloud list` still asks the provider about
|
|
19
|
+
every unsettled task. Source: `src/lib/cloud/store.ts`.
|
|
20
|
+
- **Previous sessions on `agents feed watch --json` arrive with their card text (PHNX-4326).**
|
|
21
|
+
A closed session's row now carries `lastAgentLine`, `request`, `todos`, `artifacts` and
|
|
22
|
+
`importantMessage` like a live row. Before, only 5 of 346 previous rows across the fleet
|
|
23
|
+
had a reply line; on this change's test machine 31 of 41 local previous rows have one
|
|
24
|
+
(the other 10 have no assistant text in their transcript). The text comes from the
|
|
25
|
+
preview digest cached against each transcript, so each transcript is parsed once per
|
|
26
|
+
change: the reset serves what is cached and the stream upserts the rest as it builds
|
|
27
|
+
them. Source: `src/lib/session/remote/watch.ts`, `src/lib/session/preview-digest.ts`.
|
|
28
|
+
- **`agents ps preview` takes several ids (PHNX-4326).** `agents ps preview
|
|
29
|
+
<id> <id> --json` prints one array in argument order, each element the single-id
|
|
30
|
+
envelope plus `query`; an id that does not resolve is an element with `error` set.
|
|
31
|
+
One id still prints the single object. See `docs/menubar.md`. Source:
|
|
32
|
+
`src/commands/ps.ts`.
|
|
33
|
+
- **`agents ps preview --json` carries `subAgents`, `images` and
|
|
34
|
+
`producedArtifacts`, and `todos` folds Claude's task tools (PHNX-4326).** `subAgents` lists each spawned subagent with its
|
|
35
|
+
status and duration, `images` the last six images the session was given, read or
|
|
36
|
+
wrote that still exist on disk, and `todos` now includes `TaskCreate`/`TaskUpdate`
|
|
37
|
+
checklists. `producedArtifacts` is the list a live feed row's `artifacts` holds.
|
|
38
|
+
See `docs/menubar.md`. Source: `src/lib/session/preview-digest.ts`,
|
|
39
|
+
`src/lib/session/glance-files.ts`.
|
|
40
|
+
|
|
41
|
+
- **Accounts added on your personal device reach the workers without a git pull (PHNX-4342).**
|
|
42
|
+
`agents accounts add` writes the account row to `~/.agents/agents.yaml` and only
|
|
43
|
+
commits it locally. A worker learned the row only after a user-repo push and pull, so
|
|
44
|
+
a worker whose `~/.agents` had diverged never saw it. `agents accounts login
|
|
45
|
+
<harness>#<name> --per-device` then failed there with `No grok account '<name>'`. A
|
|
46
|
+
personal or desktop device now publishes its per-device account rows in the fleet state
|
|
47
|
+
it already exchanges with peers. A worker adds any row
|
|
48
|
+
it lacks when the sender is headed and created that row; it never overwrites or
|
|
49
|
+
removes a local row. Only per-device accounts travel this way, and only their identity
|
|
50
|
+
fields; a credential reference never does. Rows added before the `provisioning` field
|
|
51
|
+
existed are not sent; workers already have those from earlier user-repo pulls. Each
|
|
52
|
+
worker still signs in for itself with `--per-device`.
|
|
53
|
+
Source: `cli/src/lib/daemon/account-state-daemon-service.ts`,
|
|
54
|
+
`cli/src/lib/accounting/usage-sync.ts`, `cli/src/lib/account-registry.ts`.
|
|
55
|
+
|
|
56
|
+
- **A Grok account with no balance left reads as out of credits (PHNX-4342).** When xAI
|
|
57
|
+
refuses a turn with `402 Payment Required: Grok Build usage balance exhausted`, that
|
|
58
|
+
account now shows `out of credits` for one hour, and rotation and `--device auto` skip
|
|
59
|
+
it instead of choosing it again. Before this, Grok usage came only from the last
|
|
60
|
+
`billing: fetched credits config` log line, which could be days old, so an exhausted
|
|
61
|
+
account still read as ready. Only that balance message counts; another 402 does not.
|
|
62
|
+
Source: `cli/src/lib/accounting/usage.ts`.
|
|
63
|
+
- **A Grok, Kimi or Muse version with no login of its own reads as signed out.** The
|
|
64
|
+
launcher points these harnesses at their version home (`GROK_HOME`, `KIMI_CODE_HOME`,
|
|
65
|
+
XDG), so they never read the shared `~/.grok` or `~/.kimi-code` login. The account
|
|
66
|
+
check did read it, and listed a version as signed in with that account while the
|
|
67
|
+
harness itself said `Not signed in`. Cursor, Droid and Antigravity keep their
|
|
68
|
+
shared-home lookup. Source: `cli/src/lib/agent-spec/agents.ts`.
|
|
69
|
+
|
|
70
|
+
- **A Codex install whose platform binary npm skipped is now caught and repaired (PHNX-4342).**
|
|
71
|
+
Codex 0.162 reports a missing platform package as `Missing optional dependency
|
|
72
|
+
@openai/codex-linux-x64`, which the launch check did not recognize, so it passed a
|
|
73
|
+
dead binary. Updates committed it, the daemon never healed it, and `agents run codex`
|
|
74
|
+
launched it and exited 1 within a fraction of a second, which showed up as
|
|
75
|
+
`Connection to <device> closed.` after `--device auto`. The check now recognizes that
|
|
76
|
+
wording, so the run repairs the install before it launches, and an update that
|
|
77
|
+
produces one rolls back. Its message now quotes the matching line instead of a stack
|
|
78
|
+
frame. Source: `cli/src/lib/installations/versions.ts`.
|
|
79
|
+
- **`--device auto` no longer says `no ready harness account` when it never heard back (PHNX-4342).**
|
|
80
|
+
When a worker's readiness probe ran past its 8 second budget, the refusal said the
|
|
81
|
+
worker had no ready account even when it had a signed-in one. It now says
|
|
82
|
+
`readiness probe timed out` and counts it in the retry hint, or `readiness probe did
|
|
83
|
+
not answer` for any other silent failure. A worker that did answer `not ready` now
|
|
84
|
+
shows its own reason, for example `no ready harness account (all signed_out)`. That
|
|
85
|
+
reason was being dropped before it reached the message.
|
|
86
|
+
Source: `cli/src/lib/teams/placement-probe.ts`, `cli/src/lib/smart-launch.ts`.
|
|
87
|
+
|
|
88
|
+
- **`agents ps focus` on a headless session stops it before reopening it in a tab (PHNX-4344).**
|
|
89
|
+
Focusing a session that was running headless used to resume a second copy in a new tab
|
|
90
|
+
while the headless process kept running, so two processes wrote to one conversation. Focus
|
|
91
|
+
now stops the headless process first (here, or with `agents ps stop <id> --local` on the
|
|
92
|
+
device that runs it) and clears its detach record, and opens nothing if that device cannot
|
|
93
|
+
be reached or its `ps stop` exits non-zero. The focus picker does the same for each headless
|
|
94
|
+
session it opens. If the tab then fails to open, the error says the headless run was stopped
|
|
95
|
+
and how to resume it. The tab now goes where your live sessions run (`resolveLaunchBackend`), so from
|
|
96
|
+
AGI Menu it opens in the project's VSCodium window instead of the first installed terminal
|
|
97
|
+
app. A session owned by another device opens a local tab running
|
|
98
|
+
`agents run auto --resume <id> --interactive` when there is no TTY, instead of an SSH hop
|
|
99
|
+
that needs one. A session that has already ended, focused with no TTY, now also opens in
|
|
100
|
+
such a tab instead of resuming in place inside the caller (which failed with no terminal and
|
|
101
|
+
still exited 0). When VSCodium never confirms the tab, focus exits 1 and says to approve the
|
|
102
|
+
"Allow 'Agents' extension to open this URI?" prompt. Source: `cli/src/commands/focus.ts`,
|
|
103
|
+
`cli/src/commands/detach.ts`, `cli/src/lib/terminal/engine.ts`.
|
|
104
|
+
- **Sessions from another machine's home now match their project (PHNX-4344).** A session
|
|
105
|
+
recorded on a Linux worker under `/home/<user>/…` now matches a project registered as
|
|
106
|
+
`~/…` on a Mac (and the other way round) when `<user>` is the same user name; `/Users/Shared`
|
|
107
|
+
and other users' homes are not rewritten, so AGI Menu groups those sessions under the right
|
|
108
|
+
project instead of Uncategorized. Source: `cli/src/lib/project-root.ts` (`localizeHome`),
|
|
109
|
+
`cli/src/lib/projects.ts`.
|
|
110
|
+
- **`agents projects todo list --project <name>` and `menubar.menu.todoProject` (PHNX-4344).**
|
|
111
|
+
`--project` lists every open issue in that Linear project (an agents project's Linear
|
|
112
|
+
project, or a Linear project name), due ones first, then the newest, at most 6, with
|
|
113
|
+
`total` the full count. The new `menubar.menu.todoProject` key names the project AGI Menu
|
|
114
|
+
lists and files to-dos in, and rides `agents menubar snapshot --json` `menuPreferences`
|
|
115
|
+
when set. Source: `cli/src/lib/quick-todo.ts`, `cli/src/commands/projects-todo.ts`,
|
|
116
|
+
`cli/src/lib/device-config.ts`.
|
|
117
|
+
- **AGI Menu shows draft pull requests by default (PHNX-4344).** `menubar.menu.githubDrafts`
|
|
118
|
+
now defaults to `true`; `githubBots` stays `false`. Source: `cli/src/lib/device-config.ts`.
|
|
119
|
+
- **`agents ps stop` on another device exits 1 when the remote stop fails (PHNX-4344).** A
|
|
120
|
+
one-shot peer hop (`runOnPeer` without a TTY) now reports a non-zero remote exit as `failed`
|
|
121
|
+
instead of `ok`. Source: `cli/src/lib/session/remote/remote-list.ts`,
|
|
122
|
+
`cli/src/commands/sessions-stop.ts`.
|
|
123
|
+
|
|
124
|
+
- **`agents upgrade` works again on a bun-installed copy.** Every upgrade on a
|
|
125
|
+
bun install failed at the install step with `error: An internal error occurred
|
|
126
|
+
(DependencyLoop)` and left the CLI on the version it already had, because
|
|
127
|
+
`bun add -g <tarball>` refuses to resolve a tarball whose package name is
|
|
128
|
+
already pinned to an exact version in bun's global `package.json` — it keeps
|
|
129
|
+
the old requirement alongside the tarball resolution and reports the package
|
|
130
|
+
as depending on itself (bun 1.3.14). `installPackageWithBun` now clears that
|
|
131
|
+
entry before the install and writes it back as the version actually on disk
|
|
132
|
+
afterwards; the second half matters too, since bun otherwise records the
|
|
133
|
+
tarball's path under the upgrade's temp directory, which is deleted on the way
|
|
134
|
+
out and breaks the next `bun install -g`. An install that fails or is aborted
|
|
135
|
+
puts the entry back, so a failed upgrade no longer leaves the CLI installed
|
|
136
|
+
but unpinned — a state in which `bun remove -g` reports success and removes
|
|
137
|
+
nothing. Neither `bun.lock` nor `trustedDependencies` is involved, and the
|
|
138
|
+
npm install path is unchanged.
|
|
139
|
+
Source: `cli/src/lib/self-update.ts`, `cli/src/lib/self-update.test.ts`.
|
|
140
|
+
|
|
141
|
+
- **An `out of credits` mark no longer strands a Claude account for good.** A run
|
|
142
|
+
refused with "You've hit your monthly spend limit" or "out of usage credits"
|
|
143
|
+
writes a per-account `out_of_credits` mark in `~/.agents/.cache/claude-usage.json`,
|
|
144
|
+
and rotation (`balanced`, `available`) skips a marked account. The mark had no
|
|
145
|
+
expiry, and its only clear was a successful run on that account, which rotation
|
|
146
|
+
never launches. On one box three of four Claude accounts sat marked for up to 14
|
|
147
|
+
days while answering fine, and every `agents run claude` landed on the one login
|
|
148
|
+
that was actually refusing. The mark now records when it was noted and expires
|
|
149
|
+
after one hour (`OUT_OF_CREDITS_REPROBE_MS`), so rotation tries the account again;
|
|
150
|
+
a fresh refusal re-marks it. A mark written by an older CLI reads as expired.
|
|
151
|
+
`agents view` shows `out of credits` only while the mark is live.
|
|
152
|
+
Source: `cli/src/lib/accounting/usage.ts`, `cli/src/lib/accounting/usage.test.ts`.
|
|
153
|
+
|
|
154
|
+
- **Fleet probes follow the configured `platform`, not the discovered one.** A box Tailscale
|
|
155
|
+
reports as Windows but whose sshd lands in WSL, configured `agents devices config <name>
|
|
156
|
+
platform linux`, was dialed as a bash login shell yet handed the PowerShell snippet — so
|
|
157
|
+
`agents devices list --refresh` showed it offline, the `agents ps` fleet roster skipped it as
|
|
158
|
+
"unreachable or no agents CLI", and `agents ps watch` / `agents feed watch` /
|
|
159
|
+
`agents apply` / `agents doctor --check` never reached it, even though `agents ssh <name>`
|
|
160
|
+
worked. Each of those paths now resolves the operator profile before choosing the remote shell,
|
|
161
|
+
the same profile the dial already used. Source: `cli/src/lib/devices/health.ts` (`buildProbeInvocation`),
|
|
162
|
+
`cli/src/lib/session/remote/{remote-list,watch}.ts`, `cli/src/lib/feed/watch.ts`,
|
|
163
|
+
`cli/src/lib/fleet/apply.ts`, `cli/src/lib/teams/placement-probe.ts`,
|
|
164
|
+
`cli/src/lib/accounting/usage-sync.ts`, `cli/src/lib/remote-agents-json.ts`,
|
|
165
|
+
`cli/src/commands/doctor.ts`.
|
|
166
|
+
|
|
167
|
+
- **A bare interactive `agents run <harness>` runs on the machine you typed it on again.**
|
|
168
|
+
Since PHNX-4083 a bare human-facing run (no prompt, real TTY) placed itself like
|
|
169
|
+
`--device auto`, so `agents run claude` on a laptop landed on whichever fleet worker had
|
|
170
|
+
the most headroom, including a Windows box the operator never chose. Placement is now
|
|
171
|
+
opt-in: `--device auto`, `--device <box>`, or the `<harness>@` picker. Headless runs are
|
|
172
|
+
unchanged, and `--local` still pins this machine against a `--where` default. The
|
|
173
|
+
`Run here instead` hint is gone with the default that needed it.
|
|
174
|
+
Source: `cli/src/commands/exec.ts`, `cli/docs/hosts.md`.
|
|
175
|
+
|
|
3
176
|
## 1.23.18
|
|
4
177
|
|
|
5
178
|
- **Fleet hops call peers by the canonical `ps` and `daemon index` spellings (PHNX-4227).**
|
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));
|
package/dist/commands/cloud.js
CHANGED
|
@@ -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) {
|
package/dist/commands/config.js
CHANGED
|
@@ -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,
|
|
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
|
package/dist/commands/detach.js
CHANGED
|
@@ -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;
|
package/dist/commands/doctor.js
CHANGED
|
@@ -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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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),
|
package/dist/commands/exec.d.ts
CHANGED
|
@@ -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;
|
package/dist/commands/exec.js
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
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
|
|
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 --
|
|
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>'
|
|
611
|
-
|
|
612
|
-
forwarded over SSH
|
|
613
|
-
|
|
614
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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}` +
|
package/dist/commands/focus.d.ts
CHANGED
|
@@ -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>;
|
package/dist/commands/focus.js
CHANGED
|
@@ -20,7 +20,9 @@ import { buildPreview } from './sessions-picker.js';
|
|
|
20
20
|
import { multiItemPicker } from '../lib/picker.js';
|
|
21
21
|
import { sessionRecoveryRunArgs } from '../lib/session/recovery.js';
|
|
22
22
|
import { shellQuote, assertValidSshTarget } from '../lib/ssh-exec.js';
|
|
23
|
-
import { openSurfaces, describeLaunch, currentContext,
|
|
23
|
+
import { openSurfaces, describeLaunch, currentContext, resolveLaunchBackend, describeBackendChoice, liveHostSamples, } from '../lib/terminal/index.js';
|
|
24
|
+
import { stopInteractive } from './detach.js';
|
|
25
|
+
import { localizeHome, localProjectFolder } from '../lib/project-root.js';
|
|
24
26
|
import { addressabilityRecoveryHint } from '../lib/terminal/resolve.js';
|
|
25
27
|
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
26
28
|
import { setHelpSections } from '../lib/help.js';
|
|
@@ -381,7 +383,7 @@ async function pickFocusCandidates(sessions, liveById, initialSearch) {
|
|
|
381
383
|
export function focusTargetForResolved(poolMatch, resolved) {
|
|
382
384
|
return poolMatch ?? resolved;
|
|
383
385
|
}
|
|
384
|
-
export async function focusResolvedSession(meta, liveById, self, fallback, attachOnly, reconnectReattach = false) {
|
|
386
|
+
export async function focusResolvedSession(meta, liveById, self, fallback, attachOnly, reconnectReattach = false, deps = {}) {
|
|
385
387
|
const active = liveById.get(meta.id);
|
|
386
388
|
if (active && isAttachableLiveSession(active)) {
|
|
387
389
|
await jumpTo(active, self, fallback, meta.id);
|
|
@@ -400,6 +402,10 @@ export async function focusResolvedSession(meta, liveById, self, fallback, attac
|
|
|
400
402
|
` To see what happened: agents ps preview ${meta.shortId}`));
|
|
401
403
|
}
|
|
402
404
|
const remote = sessionProcessHost(meta, self);
|
|
405
|
+
if (!(deps.interactive ?? isInteractiveTerminal())) {
|
|
406
|
+
await resumeInTab(active ?? activeFromMeta(meta), remote, { ...deps, meta, interactive: false });
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
403
409
|
if (remote) {
|
|
404
410
|
console.log(chalk.gray(`Recovering ${meta.shortId} on ${remote}…`));
|
|
405
411
|
const rc = await runOnPeer(sessionRecoveryRunArgs(meta), remote, { tty: true, sessionId: meta.id });
|
|
@@ -531,7 +537,19 @@ export async function openFocusTabs(targets, self, deps = {}) {
|
|
|
531
537
|
await jumpTo(openable[0].s, self, selectFallback(deps.attachOnly));
|
|
532
538
|
return;
|
|
533
539
|
}
|
|
534
|
-
const
|
|
540
|
+
const ready = [];
|
|
541
|
+
const stopped = new Set();
|
|
542
|
+
for (const p of openable) {
|
|
543
|
+
if (p.plan.kind === 'resume' && p.s.sessionId && isLiveHeadless(p.s)) {
|
|
544
|
+
if (!(await stopHeadlessCopy(p.s, p.s.sessionId, sessionProcessHost(p.s, self))))
|
|
545
|
+
continue;
|
|
546
|
+
stopped.add(p.s);
|
|
547
|
+
}
|
|
548
|
+
ready.push(p);
|
|
549
|
+
}
|
|
550
|
+
if (ready.length === 0)
|
|
551
|
+
return;
|
|
552
|
+
const results = await open(ready.map((p) => ({
|
|
535
553
|
cwd: cwdFor(p.s, byId),
|
|
536
554
|
project: cwdFor(p.s, byId),
|
|
537
555
|
command: p.plan.command,
|
|
@@ -539,12 +557,12 @@ export async function openFocusTabs(targets, self, deps = {}) {
|
|
|
539
557
|
sessionId: p.s.sessionId || undefined,
|
|
540
558
|
})), { backend, packing: 'tabs' });
|
|
541
559
|
results.forEach((r, i) => {
|
|
542
|
-
const p =
|
|
560
|
+
const p = ready[i];
|
|
543
561
|
const line = describeLaunch(r, { verb: 'Opened', label: `${shortId(p.s)} (${p.plan.note})` });
|
|
544
562
|
if (r.ok)
|
|
545
563
|
console.log(line);
|
|
546
564
|
else {
|
|
547
|
-
console.error(chalk.red(line));
|
|
565
|
+
console.error(chalk.red(stopped.has(p.s) ? `${line} ${stoppedNotice(p.s.sessionId)}` : line));
|
|
548
566
|
process.exitCode = 1;
|
|
549
567
|
}
|
|
550
568
|
});
|
|
@@ -575,38 +593,81 @@ async function richMetaById(id) {
|
|
|
575
593
|
return undefined;
|
|
576
594
|
}
|
|
577
595
|
}
|
|
578
|
-
|
|
596
|
+
export function isLiveHeadless(s) {
|
|
597
|
+
return s.context === 'headless' && isRunningLiveSession(s);
|
|
598
|
+
}
|
|
599
|
+
async function stopHeadlessCopy(s, id, remote) {
|
|
600
|
+
if (!remote) {
|
|
601
|
+
console.log(chalk.gray(`${shortId(s)} is running headless (pid ${s.pid}); stopping it so the tab is its only writer.`));
|
|
602
|
+
await stopInteractive(s);
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
console.log(chalk.gray(`${shortId(s)} is running headless on ${remote}; stopping it there so the tab is its only writer.`));
|
|
606
|
+
const rc = await runOnPeer(['ps', 'stop', id, '--local'], remote);
|
|
607
|
+
if (rc === 'ok')
|
|
608
|
+
return true;
|
|
609
|
+
console.error(chalk.red(rc === 'failed'
|
|
610
|
+
? `agents ps stop ${shortId(s)} --local failed on ${remote}, so its headless run may still be live; no second copy was opened.`
|
|
611
|
+
: `Can't reach ${remote} to stop the headless ${shortId(s)}, so no second copy was opened.`));
|
|
612
|
+
process.exitCode = 1;
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
function stoppedNotice(id) {
|
|
616
|
+
return `The headless run was stopped; resume it with agents run auto --resume ${id}`;
|
|
617
|
+
}
|
|
618
|
+
export async function resumeInTab(s, remote, deps = {}) {
|
|
579
619
|
const id = s.sessionId ?? '';
|
|
580
620
|
if (!id) {
|
|
581
621
|
console.log(chalk.yellow('This session has no id to resume.'));
|
|
582
622
|
return;
|
|
583
623
|
}
|
|
584
|
-
|
|
585
|
-
|
|
624
|
+
const headless = isLiveHeadless(s);
|
|
625
|
+
const interactive = deps.interactive ?? isInteractiveTerminal();
|
|
626
|
+
if (remote && interactive) {
|
|
627
|
+
if (headless && !(await stopHeadlessCopy(s, id, remote)))
|
|
628
|
+
return;
|
|
629
|
+
console.log(chalk.gray(`${shortId(s)} has no live terminal on ${remote}; resuming it there over SSH…`));
|
|
586
630
|
const rc = await runOnPeer(sessionRecoveryRunArgs({ id }), remote, { tty: true, sessionId: id });
|
|
587
631
|
if (rc === 'no-target') {
|
|
588
632
|
console.log(chalk.red(`${remote} isn't reachable as a device. Try: agents devices sync`));
|
|
589
633
|
console.log(chalk.gray(` recovery must run on ${remote}, where the indexed session originated`));
|
|
634
|
+
process.exitCode = 1;
|
|
590
635
|
}
|
|
591
636
|
return;
|
|
592
637
|
}
|
|
593
|
-
const meta = (await richMetaById(id)) ?? metaFromActive(s);
|
|
594
|
-
const command = [...buildSessionRecoveryCommand(meta), '--quiet'];
|
|
595
|
-
const
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
|
|
638
|
+
const meta = deps.meta ?? (await richMetaById(id)) ?? metaFromActive(s);
|
|
639
|
+
const command = [...buildSessionRecoveryCommand(meta, !!remote), '--quiet'];
|
|
640
|
+
const recorded = meta.cwd ?? s.cwd;
|
|
641
|
+
const localCwd = recorded ? localizeHome(recorded) : undefined;
|
|
642
|
+
const cwd = localCwd && fs.existsSync(localCwd) ? localCwd : localProjectFolder(recorded) ?? process.cwd();
|
|
643
|
+
const project = localProjectFolder(cwd) ?? cwd;
|
|
644
|
+
const choice = deps.choice !== undefined ? deps.choice : resolveLaunchBackend(currentContext(), await liveHostSamples());
|
|
645
|
+
if (!choice) {
|
|
646
|
+
if (!interactive || remote) {
|
|
647
|
+
console.error(chalk.red(`No terminal this machine can drive to reopen ${shortId(s)}. Run: agents run auto --resume ${id}`));
|
|
648
|
+
process.exitCode = 1;
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (headless && !(await stopHeadlessCopy(s, id, undefined)))
|
|
652
|
+
return;
|
|
599
653
|
await resumeSessionInPlace(meta);
|
|
600
654
|
return;
|
|
601
655
|
}
|
|
602
|
-
|
|
603
|
-
|
|
656
|
+
if (headless && !(await stopHeadlessCopy(s, id, remote)))
|
|
657
|
+
return;
|
|
658
|
+
const what = headless ? 'resuming it' : 'resuming a copy';
|
|
659
|
+
const where = remote ? ` (it runs on ${remote})` : '';
|
|
660
|
+
console.log(chalk.gray(`${shortId(s)} has no live terminal to attach${where}; opening a new tab in ${describeBackendChoice(choice)} and ${what}.`));
|
|
661
|
+
const open = deps.open ?? openSurfaces;
|
|
662
|
+
const results = await open([{ cwd, project, command, agent: s.kind || undefined, sessionId: id }], { backend: choice.backend, packing: 'tabs' });
|
|
604
663
|
const line = describeLaunch(results[0], { verb: 'Resumed', label: shortId(s) });
|
|
605
664
|
if (results[0].ok)
|
|
606
665
|
console.log(line);
|
|
607
666
|
else {
|
|
608
|
-
console.error(chalk.red(line));
|
|
609
|
-
|
|
667
|
+
console.error(chalk.red(headless ? `${line} ${stoppedNotice(id)}` : line));
|
|
668
|
+
if (!headless)
|
|
669
|
+
console.error(chalk.gray(` Resume it in a terminal instead: agents run auto --resume ${meta.id}`));
|
|
610
670
|
process.exitCode = 1;
|
|
611
671
|
}
|
|
612
|
-
}
|
|
672
|
+
}
|
|
673
|
+
const resumeInNewTab = (s, remote) => resumeInTab(s, remote);
|