@phnx-labs/agents-cli 1.22.106 → 1.22.109
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 +78 -0
- package/README.md +9 -5
- package/dist/commands/daemon.js +45 -40
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/exec.d.ts +78 -8
- package/dist/commands/exec.js +276 -53
- package/dist/commands/monitors.js +15 -2
- package/dist/commands/routines.js +46 -6
- package/dist/commands/run-account-picker.d.ts +11 -0
- package/dist/commands/run-account-picker.js +11 -1
- package/dist/commands/sessions-backup-setup.d.ts +12 -0
- package/dist/commands/sessions-backup-setup.js +65 -0
- package/dist/commands/sessions-resume.d.ts +14 -1
- package/dist/commands/sessions-resume.js +56 -9
- package/dist/commands/sessions.js +2 -0
- package/dist/commands/share.js +15 -2
- package/dist/commands/sync.js +30 -1
- package/dist/lib/accounts/slots.js +7 -0
- package/dist/lib/agent-spec/agents.d.ts +60 -8
- package/dist/lib/agent-spec/agents.js +118 -45
- package/dist/lib/daemon/daemon.d.ts +34 -1
- package/dist/lib/daemon/daemon.js +63 -9
- package/dist/lib/daemon/leaked-daemons.d.ts +60 -0
- package/dist/lib/daemon/leaked-daemons.js +180 -0
- package/dist/lib/devices/doctor-findings.d.ts +7 -1
- package/dist/lib/devices/doctor-findings.js +32 -1
- package/dist/lib/hooks/install.js +70 -63
- package/dist/lib/hosts/dispatch.d.ts +1 -1
- package/dist/lib/hosts/dispatch.js +1 -1
- package/dist/lib/models.js +76 -5
- package/dist/lib/session/cloud.js +3 -1
- package/dist/lib/session/parse.d.ts +1 -0
- package/dist/lib/session/parse.js +136 -2
- package/dist/lib/session/recovery.d.ts +9 -1
- package/dist/lib/session/recovery.js +14 -4
- package/dist/lib/session/tool-calls.d.ts +1 -1
- package/dist/lib/session/tool-calls.js +40 -5
- package/dist/lib/share/backend.d.ts +23 -0
- package/dist/lib/share/backend.js +24 -0
- package/dist/lib/share/provision.d.ts +12 -0
- package/dist/lib/share/provision.js +30 -0
- package/dist/lib/share/worker-template.js +273 -0
- package/dist/lib/terminal/engine.js +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.22.109
|
|
4
|
+
|
|
5
|
+
- **`agents sessions backup-setup` provisions the managed session-backup endpoint (PHNX-3726).** The operator command that deploys `sessions.agents-cli.sh` — the Cloudflare Worker + R2 bucket a signed-in user's `agents sessions export --to-r2` backs up to with no `r2.backups` bucket of their own. Mirrors `agents traces setup`: reads Cloudflare credentials from the `cloudflare` secrets bundle (`agents secrets exec cloudflare -- agents sessions backup-setup`), idempotent (re-running redeploys the current Worker template in place). It is NOT a per-user step — signing in with `agents auth login` is all a user does; this is how the first-party endpoint itself is deployed. The Worker it deploys is Phoenix-only with no static token (PHNX-3726). Source: `cli/src/commands/sessions-backup-setup.ts`, `cli/src/lib/session/sync/provision.ts` (+ `provision.test.ts`), `cli/docs/sessions.md`.
|
|
6
|
+
|
|
7
|
+
- **`agents doctor` flags a leaked daemon no owner record names (W4, PHNX-3736).**
|
|
8
|
+
A headless e2e session launched `agents __daemon-run` under
|
|
9
|
+
`HOME=/tmp/pin-e2e-<pid>` and never stopped it; the daemon ran 4+ days,
|
|
10
|
+
invisible to the pid-file takeover because it keeps its own pid file under the
|
|
11
|
+
temp home. `agents doctor` now reports any same-uid `__daemon-run` whose pid is
|
|
12
|
+
neither the service manager's unit main PID nor the recorded `daemon.pid` —
|
|
13
|
+
checked against both the caller's HOME and the real account home, so a
|
|
14
|
+
test-harness caller never accuses the production daemon — as a `leaked-daemon`
|
|
15
|
+
warning carrying the process's HOME and start time, with a `kill <pid>`
|
|
16
|
+
remediation. Source: `cli/src/lib/daemon/leaked-daemons.ts`,
|
|
17
|
+
`cli/src/lib/devices/doctor-findings.ts`.
|
|
18
|
+
|
|
19
|
+
- **`agents daemon start` refuses under a redirected HOME unless
|
|
20
|
+
`AGENTS_ALLOW_TEST_DAEMON=1` (W4, PHNX-3736).** RUSH-3021 gated auto-start from
|
|
21
|
+
a sandbox/test HOME but left the explicit `startDaemon()` open — the path the
|
|
22
|
+
e2e harness took to leak the `/tmp/pin-e2e-<pid>` daemon. The launch now throws
|
|
23
|
+
`RedirectedHomeDaemonError` (printed without a stack, exit 1); a deliberate
|
|
24
|
+
test/e2e launch opts in with `AGENTS_ALLOW_TEST_DAEMON=1` and owns stopping
|
|
25
|
+
what it starts. Reporting an already-running daemon — and therefore
|
|
26
|
+
`agents daemon stop` of a leaked one — is not gated. Auto-start side effects
|
|
27
|
+
(`routines add`, webhook fires, `monitors add`) state the refusal and leave
|
|
28
|
+
the foreground command green, the same tier split as the auto-start circuit
|
|
29
|
+
breaker; only the explicit start commands fail loud. Source:
|
|
30
|
+
`cli/src/lib/daemon/daemon.ts` (`startDaemon`).
|
|
31
|
+
|
|
32
|
+
- **The managed share Worker now proxies same-origin human collaboration to Prix (PHNX-3835).** The Cloudflare Worker that fronts a managed share gains a `/__collab/*` transport so authorized humans can review a hosted artifact together (comments now; agent mentions/wake-up later). It stays the trust boundary exactly as the page GET does: every `/__collab` request loads the R2 object FIRST (a missing/just-deleted share 404s, so existence is never enumerable), re-derives the share id (`SHA-256(ownerId + NUL + normalized path)`), current revision (etag), owner, visibility, org domain, and producer provenance SERVER-SIDE from R2 metadata — the browser-supplied `share` is a lookup key only, never trusted as identity — then reuses the EXACT page read gate (me/org identity gate + private viewer-token gate) with every denial normalized to 404. Public/unlisted readers may read anonymously; every write additionally requires a verified signed-in Phoenix human; private still requires its share token. It proxies to the Prix `/v1/artifact-collaboration` routes (`context`, `threads` list/create, thread replies, comment/thread PATCH, SSE `events`, and a best-effort authenticated `purge` on share delete) with the service token in `Authorization` (never surfaced to the browser) plus trusted `X-Artifact-*` / `X-Phoenix-Actor-*` headers, preserves the client `Idempotency-Key` and `Last-Event-ID`, streams SSE through unbuffered (cancel/disconnect propagated), and marks every collaboration response `no-store`. A visibility downgrade is immediate (re-gated per request) and a deleted share drops its comments the instant the object is gone. The whole surface fails closed (404) when `PRIX_ARTIFACT_COLLAB_BASE` / `ARTIFACT_COLLAB_SERVICE_TOKEN` are absent — so BYO endpoints (no Phoenix identity) never expose it and the artifact page GET is unaffected — and stays dormant until an operator sets both secrets, which `agents artifacts share update`/`setup` now apply on a managed deploy (both or neither). Because the Worker template changed, already-deployed managed endpoints read `outdated` until re-run through `agents artifacts share update`. Source: `cli/src/lib/share/worker-template.ts`, `cli/src/lib/share/provision.ts`, `cli/src/lib/share/backend.ts`, `cli/src/commands/share.ts`, `cli/docs/share.md`.
|
|
33
|
+
|
|
34
|
+
- **`agents sync --dry-run` no longer mutates every native home (PHNX-3923).** The umbrella verb (bare `agents sync`, including `--local`/`--yes`/`--json`) ignored `--dry-run` entirely: it ran the full reconcile, evicted central browser profiles, verified, and repaired — mutating every installed version home despite the preview flag. The umbrella composes only mutating stages (repo `git pull`, `refresh()` reconcile, device sync, `repairAfterSync`) with no non-mutating preview, so it now refuses `--dry-run` LOUD and up front — before any change — and points at the scoped path (`agents sync <agent> --dry-run`), which honors it non-destructively. `--json` reports `{ ok: false, mode: 'umbrella', dryRun: true, error, hint, installedAgents }`. Source: `cli/src/commands/sync.ts`.
|
|
35
|
+
|
|
36
|
+
- Terminal session resumes preserve follow-up prompts, including spaces and shell characters. Remote terminals use the origin directory or explicit `--cwd`; run pickers retain `--remote-cwd` precedence, and home-relative paths expand on the target. An invalid remote directory or failed terminal launch reports failure.
|
|
37
|
+
|
|
38
|
+
- Publishes the session-resume fixes from the unshipped 1.22.108 candidate: account homes refresh their session tracker, Codex hook trust follows registration, empty local picks are skipped, and remote picks are validated on their origin device. The 1.22.108 tag is preserved; npm publication resumes with this patch after correcting its release notes.
|
|
39
|
+
|
|
40
|
+
- **`agents view` shows OpenCode's real model, account, plan, and last-active (PHNX-3982).** The OpenCode row was the only one in the table with nothing usable in it — `1.18.15 (default) default id:meta+openai+opencode-go` — while every other harness showed a model, an email, and a plan. Three separate reads were pointed at the wrong place. (1) The model came from `<home>/.opencode/settings.json`, which is agents-cli's own plugin-enablement file; OpenCode reads `~/.config/opencode/opencode.{jsonc,json}`, and ships no catalog default, so the row fell through to the literal placeholder `default`. Both spellings are now read comment-tolerantly, and when nothing is configured the row shows the model OpenCode itself will start with, from the selection it persists to `$XDG_STATE_HOME/opencode/model.json`. (2) The account showed only the provider join because the code asserted OpenCode's `auth.json` carries no identity — it does, for `type: 'oauth'` providers, in the same namespaced JWT claims `case 'codex'` already decodes, so the email and plan now render (secrets are never read out, only claims). (3) `lastActive` was blank because the per-file session walk finds nothing for a harness that keeps every session in one sqlite file; it now dates from `opencode.db`. Live usage *windows* remain unavailable for OpenCode — it records no rate-limit state locally and each provider would need its own reader. Source: `cli/src/lib/agent-spec/agents.ts`, `cli/src/lib/models.ts`.
|
|
41
|
+
|
|
42
|
+
## 1.22.108
|
|
43
|
+
|
|
44
|
+
- Account sync now refreshes the native session-tracking hook in every account home, replacing stale registrations from previous CLI installations so new sessions retain their account identity. Codex tracker installation also refreshes hook trust so headless runs can execute the registered hook.
|
|
45
|
+
|
|
46
|
+
- Resume selection validates peer-owned transcripts on their origin device instead of treating a missing local copy as a missing session. Local empty picks are still skipped; explicit local replay still requires readable local content.
|
|
47
|
+
|
|
48
|
+
- **The resume picker skips a local session with no transcript before opening a
|
|
49
|
+
tab (PHNX-4080).** Empty local selections are reported as skipped, and a batch
|
|
50
|
+
with nothing left to resume exits 1. Peer-owned sessions and mirror entries are
|
|
51
|
+
validated on their origin device. Explicit local replay still requires readable
|
|
52
|
+
local content; the executing device refuses recovery when no transcript exists.
|
|
53
|
+
Source: `src/commands/sessions-resume.ts`, `src/lib/session/recovery.ts`.
|
|
54
|
+
|
|
55
|
+
## 1.22.107
|
|
56
|
+
|
|
57
|
+
- **A bare interactive run places itself like `--device auto` (PHNX-4083).**
|
|
58
|
+
`agents run <harness>` with no prompt on a real TTY (no `--json`) now
|
|
59
|
+
auto-places onto a fleet worker — the same engine, pool, and banner as
|
|
60
|
+
`--device auto` — instead of always running on the machine you typed it at;
|
|
61
|
+
headless runs (any prompt, `--json`, teams/routines/hooks) are unchanged and
|
|
62
|
+
still run in place. To keep a local interactive run, pass
|
|
63
|
+
`--device <this machine>` or pick this machine (listed first) in the
|
|
64
|
+
`<harness>@` device picker; when placement finds no healthy device (empty
|
|
65
|
+
pool, or the PHNX-4051 stale-usage refusal) the run fails loud with the
|
|
66
|
+
placement error plus `Run here instead: agents run <harness> --device
|
|
67
|
+
<this machine>` — never a silent local fallback. Source:
|
|
68
|
+
`src/commands/exec.ts`, `src/commands/run-account-picker.ts`.
|
|
69
|
+
|
|
70
|
+
- **Run pickers move to `#` (account) and `@` (device), `#@` asks both
|
|
71
|
+
(PHNX-4083).** `agents run claude#` now opens the account picker (the old
|
|
72
|
+
`claude@` menu, same rows and code path); `agents run claude@` opens the new
|
|
73
|
+
fleet device picker — this machine first, offline rows disabled, cached-state
|
|
74
|
+
age in the prompt — and `claude#@` asks the account first, then the device,
|
|
75
|
+
dispatching with the picked account label. A picker combined with an explicit
|
|
76
|
+
pin of the same thing (`claude@2.1.218#`, `claude#work#`, `claude@@`) or a
|
|
77
|
+
conflicting flag (`--account`, `--device`/`--on`/`--computer`/`--host`) fails
|
|
78
|
+
loud; a cancelled menu launches nothing. Source: `src/commands/exec.ts`,
|
|
79
|
+
`src/lib/hosts/dispatch.ts`.
|
|
80
|
+
|
|
3
81
|
## 1.22.106
|
|
4
82
|
|
|
5
83
|
- Fixed release packages omitting the session-tracking hook. Release qualification now uses the complete CLI build, so installed agents can record the account that owns each native session.
|
package/README.md
CHANGED
|
@@ -202,11 +202,15 @@ agents run claude "refactor auth module" --mode edit --fallback codex,antigravit
|
|
|
202
202
|
# Picks the signed-in account you haven't used recently.
|
|
203
203
|
agents run claude "summarize recent commits" --strategy balanced
|
|
204
204
|
|
|
205
|
-
# Or choose one account/version interactively for only this run.
|
|
206
|
-
agents run claude
|
|
207
|
-
agents run codex
|
|
208
|
-
agents run claude
|
|
209
|
-
agents run claude
|
|
205
|
+
# Or choose one account/version interactively for only this run (# = account picker).
|
|
206
|
+
agents run claude#
|
|
207
|
+
agents run codex# "review this branch"
|
|
208
|
+
agents run claude# --device auto # pick the device, then choose there
|
|
209
|
+
agents run claude# --device yosemite-s0 # choose from one device's accounts
|
|
210
|
+
|
|
211
|
+
# @ picks the device instead; #@ asks both (account first, then device).
|
|
212
|
+
agents run claude@ # pick the device for this run
|
|
213
|
+
agents run claude#@ # pick the account, then the device
|
|
210
214
|
```
|
|
211
215
|
|
|
212
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.
|
package/dist/commands/daemon.js
CHANGED
|
@@ -21,7 +21,8 @@ import { execFileSync } from 'child_process';
|
|
|
21
21
|
import * as fs from 'fs';
|
|
22
22
|
import * as path from 'path';
|
|
23
23
|
import { setHelpSections } from '../lib/help.js';
|
|
24
|
-
import { getDaemonStatus, isDaemonRunning, isDaemonWedged, readDaemonLog, startDaemon, stopDaemon, signalDaemonReload, findSurvivingStateDirDaemons, getDaemonLogPath, isDaemonAutostartCircuitOpen, } from '../lib/daemon/daemon.js';
|
|
24
|
+
import { getDaemonStatus, isDaemonRunning, isDaemonWedged, readDaemonLog, startDaemon, stopDaemon, signalDaemonReload, findSurvivingStateDirDaemons, getDaemonLogPath, isDaemonAutostartCircuitOpen, RedirectedHomeDaemonError, } from '../lib/daemon/daemon.js';
|
|
25
|
+
import { listDaemonRunProcesses } from '../lib/daemon/leaked-daemons.js';
|
|
25
26
|
import { getConfigValue, setConfigValue, isDaemonEnabled } from '../lib/device-config.js';
|
|
26
27
|
import { readSubsystemHealth, readAllSubsystemHealth, SUBSYSTEM_BROWSER_IPC, SUBSYSTEM_DAEMON_START, } from '../lib/daemon-health.js';
|
|
27
28
|
import { DAEMON_SERVICE_IDS, listDaemonServiceStates, setDaemonServiceEnabled, getDaemonServicesConfigPath, queueDaemonServiceRestart, } from '../lib/daemon-services.js';
|
|
@@ -32,6 +33,27 @@ import { parseDuration } from '../lib/hooks/cache.js';
|
|
|
32
33
|
import { registerFunnelCommand } from './funnel.js';
|
|
33
34
|
import { DEFAULT_WEBHOOK_PORT, DEFAULT_WEBHOOK_RATE_LIMIT, addHostedReceiver, getDaemonWebhooksConfigPath, hostedReceiverPort, readDaemonWebhooksConfig, removeHostedReceiver, } from '../lib/daemon-webhooks.js';
|
|
34
35
|
import { parseFunnelPort } from '../lib/funnel.js';
|
|
36
|
+
// ─── Process scanning — which install owns the pid, and every duplicate ──────
|
|
37
|
+
/**
|
|
38
|
+
* startDaemon for the explicit start/restart commands: the redirected-HOME
|
|
39
|
+
* refusal (W4, PHNX-3736) is user-actionable, not an engineering bug, so it
|
|
40
|
+
* prints without a stack and exits 1. Anything else (a genuinely unspawnable
|
|
41
|
+
* binary) still throws. Kept local to this command rather than in bootstrap's
|
|
42
|
+
* catch list — a bootstrap.ts edit selects the 54s non-interactive suite into
|
|
43
|
+
* the required impact gate, and this change's budget cannot carry it.
|
|
44
|
+
*/
|
|
45
|
+
function startDaemonClean() {
|
|
46
|
+
try {
|
|
47
|
+
return startDaemon();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err instanceof RedirectedHomeDaemonError) {
|
|
51
|
+
console.error(chalk.red(err.message));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
35
57
|
/**
|
|
36
58
|
* Provably absent, or null when unknowable.
|
|
37
59
|
*
|
|
@@ -188,19 +210,14 @@ function entryFromTokens(tokens) {
|
|
|
188
210
|
return tokens.length >= 2 ? tokens[tokens.length - 2] : null;
|
|
189
211
|
}
|
|
190
212
|
/**
|
|
191
|
-
* Every live `__daemon-run` process on this box,
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* A substring/regex test anywhere in the full command line is not enough: an
|
|
198
|
-
* `agents run claude "<prompt>"` invocation whose prompt happens to quote the
|
|
199
|
-
* literal text `__daemon-run` (this ticket's own brief does) matches that test
|
|
200
|
-
* too, and was observed producing false "duplicate daemon" rows. Requiring it
|
|
201
|
-
* to be the LAST whitespace-delimited token is the actual invariant.
|
|
213
|
+
* Every live `__daemon-run` process on this box, enriched with display
|
|
214
|
+
* metadata (entry/version/entryMissing). The raw `ps` scan and its
|
|
215
|
+
* last-token `__daemon-run` invariant live in
|
|
216
|
+
* `lib/daemon/leaked-daemons.ts` (`listDaemonRunProcesses`) — shared with the
|
|
217
|
+
* doctor's leaked-daemon detection so the two can never disagree on what a
|
|
218
|
+
* daemon process is.
|
|
202
219
|
*
|
|
203
|
-
* This
|
|
220
|
+
* This box-wide scan is deliberately NOT the duplicate-detection scope
|
|
204
221
|
* (RUSH-2368): a `__daemon-run` under a different HOME serves a different
|
|
205
222
|
* `getDaemonDir()` and is not a duplicate of THIS device's daemon, however
|
|
206
223
|
* `ps` sees it — a leaked vitest fixture under its own `/tmp` HOME matched
|
|
@@ -209,35 +226,14 @@ function entryFromTokens(tokens) {
|
|
|
209
226
|
* `findSurvivingStateDirDaemons` has already confirmed as real duplicates.
|
|
210
227
|
*/
|
|
211
228
|
function scanDaemonProcesses() {
|
|
212
|
-
if (process.platform === 'win32')
|
|
213
|
-
return [];
|
|
214
|
-
let out;
|
|
215
|
-
try {
|
|
216
|
-
out = execFileSync('ps', ['-eo', 'pid=,uid=,args='], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
return [];
|
|
220
|
-
}
|
|
221
229
|
const found = [];
|
|
222
|
-
for (const
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
continue;
|
|
226
|
-
const args = m[3].trim();
|
|
227
|
-
const tokens = args.split(/\s+/);
|
|
228
|
-
if (tokens.length === 0 || tokens[tokens.length - 1] !== '__daemon-run')
|
|
229
|
-
continue;
|
|
230
|
-
const pid = parseInt(m[1], 10);
|
|
231
|
-
if (isNaN(pid))
|
|
232
|
-
continue;
|
|
233
|
-
const uidParsed = parseInt(m[2], 10);
|
|
234
|
-
const uid = isNaN(uidParsed) ? null : uidParsed;
|
|
235
|
-
const entry = entryFromTokens(tokens);
|
|
236
|
-
const version = entry ? resolveVersionNear(entry, pid) : null;
|
|
230
|
+
for (const p of listDaemonRunProcesses()) {
|
|
231
|
+
const entry = entryFromTokens(p.tokens);
|
|
232
|
+
const version = entry ? resolveVersionNear(entry, p.pid) : null;
|
|
237
233
|
// Asks whether the code is on disk for the NEXT launch -- what a restart and
|
|
238
234
|
// every other reader will see -- not what this pid currently has mapped.
|
|
239
235
|
const entryMissing = entry ? entryAbsent(entry) : false;
|
|
240
|
-
found.push({ pid, entry, version, entryMissing, uid });
|
|
236
|
+
found.push({ pid: p.pid, entry, version, entryMissing, uid: p.uid });
|
|
241
237
|
}
|
|
242
238
|
return found;
|
|
243
239
|
}
|
|
@@ -905,6 +901,15 @@ export function registerDaemonCommand(program) {
|
|
|
905
901
|
'agents daemon start' still starts it explicitly, same as
|
|
906
902
|
'systemctl start' on a disabled unit.
|
|
907
903
|
|
|
904
|
+
Under a redirected HOME (a test/e2e harness), 'agents daemon start'
|
|
905
|
+
REFUSES to launch: a daemon started there keeps its own pid file under
|
|
906
|
+
the temp home and leaks, invisible to the real install (W4, PHNX-3736).
|
|
907
|
+
'daemon restart' inherits the same guard — it stops first, so run it
|
|
908
|
+
with the same opt-in. A deliberate test launch sets
|
|
909
|
+
AGENTS_ALLOW_TEST_DAEMON=1 — and the harness owns stopping what it
|
|
910
|
+
started. 'agents doctor' flags any leaked daemon that already exists,
|
|
911
|
+
with its HOME and start time.
|
|
912
|
+
|
|
908
913
|
'agents daemon services enable|disable|restart <id>' applies live (no
|
|
909
914
|
daemon restart) for supervisor-managed services that were registered at
|
|
910
915
|
boot. browser-ipc is also registered while disabled, specifically so a
|
|
@@ -924,7 +929,7 @@ export function registerDaemonCommand(program) {
|
|
|
924
929
|
cmd.command('start')
|
|
925
930
|
.description('Start the daemon. Bypasses daemon.enabled — this is the deliberate override.')
|
|
926
931
|
.action(() => {
|
|
927
|
-
const result =
|
|
932
|
+
const result = startDaemonClean();
|
|
928
933
|
if (result.method === 'already-running') {
|
|
929
934
|
console.log(chalk.yellow(`Daemon already running (PID: ${result.pid})`));
|
|
930
935
|
}
|
|
@@ -977,7 +982,7 @@ export function registerDaemonCommand(program) {
|
|
|
977
982
|
for (const s of stop.surviving)
|
|
978
983
|
console.log(chalk.red(` surviving: ${s}`));
|
|
979
984
|
}
|
|
980
|
-
const result =
|
|
985
|
+
const result = startDaemonClean();
|
|
981
986
|
if (result.pid)
|
|
982
987
|
console.log(chalk.green(`Daemon started (PID: ${result.pid}, ${result.method})`));
|
|
983
988
|
else
|
package/dist/commands/doctor.js
CHANGED
|
@@ -16,6 +16,7 @@ import { hostIdentityArgs, sshTargetFor } from '../lib/hosts/types.js';
|
|
|
16
16
|
import { deviceIdentityArgs } from '../lib/devices/connect.js';
|
|
17
17
|
import { machineId, normalizeHost } from '../lib/session/sync/config.js';
|
|
18
18
|
import { findAmbiguousDevicePins } from '../lib/scheduling/routines.js';
|
|
19
|
+
import { findLeakedDaemons } from '../lib/daemon/leaked-daemons.js';
|
|
19
20
|
import chalk from 'chalk';
|
|
20
21
|
import { checkAllClis, collectTeamsDoctorData } from '../lib/teams/agents.js';
|
|
21
22
|
import { AGENTS, ALL_AGENT_IDS, resolveAgentName, formatAgentError, getAccountInfo } from '../lib/agents.js';
|
|
@@ -478,6 +479,10 @@ async function runDevicesDoctor(opts) {
|
|
|
478
479
|
// remote boxes self-report it in their own `agents doctor --json`.
|
|
479
480
|
ownerSink: await probeOwnerSink(readMeta()),
|
|
480
481
|
binaryShadows: detectAgentsBinaryShadows(),
|
|
482
|
+
// A `__daemon-run` no unit main PID or daemon.pid owns (W4, PHNX-3736) —
|
|
483
|
+
// the /tmp/pin-e2e leak class the registry-scoped duplicate check cannot
|
|
484
|
+
// see. Local only: a remote box self-reports in its own doctor.
|
|
485
|
+
leakedDaemons: findLeakedDaemons(),
|
|
481
486
|
}));
|
|
482
487
|
accounts[localName] = r.inventory?.signIn ?? {};
|
|
483
488
|
continue;
|
|
@@ -1478,6 +1483,8 @@ export function registerDoctorCommand(program) {
|
|
|
1478
1483
|
// Can the owner-delivery lane (feed/notify) escalate a block from this
|
|
1479
1484
|
// box? A factory that cannot escalate is not healthy (RUSH-2262).
|
|
1480
1485
|
ownerSink: await probeOwnerSink(readMeta()),
|
|
1486
|
+
// A `__daemon-run` no unit main PID or daemon.pid owns (W4, PHNX-3736).
|
|
1487
|
+
leakedDaemons: findLeakedDaemons(),
|
|
1481
1488
|
});
|
|
1482
1489
|
if (opts.json) {
|
|
1483
1490
|
const overviewPayload = {
|
package/dist/commands/exec.d.ts
CHANGED
|
@@ -10,13 +10,24 @@ import type { ExecEffort } from '../lib/exec.js';
|
|
|
10
10
|
import { RUN_AUTO_KEYWORD } from '../lib/types.js';
|
|
11
11
|
/** Validate a caller-supplied session id before it reaches tmux, paths, indexes, or remote dispatch. */
|
|
12
12
|
export declare function parseExplicitSessionId(value: string): string;
|
|
13
|
-
export interface
|
|
14
|
-
|
|
13
|
+
export interface RunPickerMarkers {
|
|
14
|
+
accountPicker: boolean;
|
|
15
|
+
devicePicker: boolean;
|
|
15
16
|
normalizedAgentSpec: string;
|
|
16
17
|
valid: boolean;
|
|
18
|
+
reason?: string;
|
|
17
19
|
}
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Parse the trailing picker markers on an `agents run` agent spec. A terminal
|
|
22
|
+
* run of `#`/`@` characters requests the account picker (`#`) and/or the
|
|
23
|
+
* device picker (`@`) — each at most once, in either order (`claude#@`,
|
|
24
|
+
* `claude@#`). Stripping them yields the normalized spec (`claude#work@` →
|
|
25
|
+
* `claude#work`, version pins and `#label` account pins intact). A picker
|
|
26
|
+
* cannot combine with an explicit pin of what it picks: `claude@2.1.218#`
|
|
27
|
+
* (the account picker already chooses the version — the old `claude@2.1.218@`
|
|
28
|
+
* rule), `claude#work#`, `claude@@`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseRunPickerMarkers(agentSpec: string): RunPickerMarkers;
|
|
20
31
|
/**
|
|
21
32
|
* The `--device` alias family — the flags that mean "dispatch this run to another
|
|
22
33
|
* machine over SSH". `--device` is canonical; `--on`/`--computer` are hidden
|
|
@@ -31,11 +42,29 @@ export declare function hostTargetGiven(options: {
|
|
|
31
42
|
on?: string;
|
|
32
43
|
computer?: string;
|
|
33
44
|
}): string[];
|
|
34
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Return every option whose selection semantics conflict with an account
|
|
47
|
+
* choice (`agent#`). Device routing is deliberately absent: the marker rides
|
|
48
|
+
* the hop and the peer picks from ITS slots.
|
|
49
|
+
*/
|
|
35
50
|
export declare function runAccountPickerConflicts(options: {
|
|
36
51
|
resume?: string | boolean;
|
|
37
52
|
strategy?: string;
|
|
38
53
|
balanced?: boolean;
|
|
54
|
+
lease?: string | boolean;
|
|
55
|
+
box?: string;
|
|
56
|
+
account?: string;
|
|
57
|
+
host?: string;
|
|
58
|
+
device?: string;
|
|
59
|
+
on?: string;
|
|
60
|
+
computer?: string;
|
|
61
|
+
}): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Return every option that already decides where the run lands, so a device
|
|
64
|
+
* choice (`agent@`) would be silently ignored: any explicit host flag, and the
|
|
65
|
+
* lease/box paths, which own placement outright.
|
|
66
|
+
*/
|
|
67
|
+
export declare function runDevicePickerConflicts(options: {
|
|
39
68
|
lease?: string | boolean;
|
|
40
69
|
box?: string;
|
|
41
70
|
host?: string;
|
|
@@ -47,11 +76,15 @@ export { RUN_AUTO_KEYWORD };
|
|
|
47
76
|
/**
|
|
48
77
|
* Whether `run auto` should default its host layer to the affinity pick (the
|
|
49
78
|
* same machinery as `--device auto`). False when the caller pinned any host
|
|
50
|
-
* flag, and false when this process was itself dispatched by a host run —
|
|
51
|
-
* dispatcher exports AGENTS_RUN_AUTO_HOST_RESOLVED=1 into the remote SHELL
|
|
79
|
+
* flag, and false when this process was itself dispatched by a host run —
|
|
80
|
+
* the dispatcher exports AGENTS_RUN_AUTO_HOST_RESOLVED=1 into the remote SHELL
|
|
52
81
|
* (hosts/dispatch.ts remoteRunShellPrelude) because it already resolved the
|
|
53
82
|
* host layer, and re-picking here would chain-hop the run across the fleet.
|
|
54
|
-
*
|
|
83
|
+
* An INTERACTIVE dispatch of a named harness also reaches the remote as a bare
|
|
84
|
+
* `agents run <harness>` (its argv forwards without the routing flag), so the
|
|
85
|
+
* interactive prelude's AGENTS_REMOTE_INTERACTIVE=1 counts as "already placed"
|
|
86
|
+
* too — without it the remote would re-place the run and ping-pong across the
|
|
87
|
+
* fleet. Pure so the pinning matrix is unit-testable.
|
|
55
88
|
*/
|
|
56
89
|
export declare function runAutoDefaultsToAffinity(options: {
|
|
57
90
|
host?: string;
|
|
@@ -59,6 +92,43 @@ export declare function runAutoDefaultsToAffinity(options: {
|
|
|
59
92
|
on?: string;
|
|
60
93
|
computer?: string;
|
|
61
94
|
}, env?: NodeJS.ProcessEnv): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Whether a bare human-facing `agents run <harness>` — no prompt, so an
|
|
97
|
+
* interactive TUI run — defaults its placement to `--device auto` (PHNX-4083).
|
|
98
|
+
* A marker left off is decided for you: no `#` means balanced rotation, and no
|
|
99
|
+
* `@` (and no other placement flag) now means automatic device placement — the
|
|
100
|
+
* same engine as `--device auto`, whose pool never contains a box marked
|
|
101
|
+
* `personal`. ALL of these must hold:
|
|
102
|
+
*
|
|
103
|
+
* - no prompt (headless runs — teams, routines, hooks, `run <agent> "…"` —
|
|
104
|
+
* keep running in place, unchanged);
|
|
105
|
+
* - a human-facing surface: a real TTY and no `--json`. This is the same
|
|
106
|
+
* two-condition gate `signInLaunchDecision` uses in run-account-picker.ts —
|
|
107
|
+
* reused here through isHumanFacingRun, not re-derived;
|
|
108
|
+
* - no device-picker marker (`agent@` already chose the device; picking this
|
|
109
|
+
* machine there is a plain local run);
|
|
110
|
+
* - no `--resume` / `--lease` / `--box` / `--cloud` (those own placement);
|
|
111
|
+
* - the host layer is unpinned and this process is not itself a dispatched
|
|
112
|
+
* hop — delegated to runAutoDefaultsToAffinity, which encodes both.
|
|
113
|
+
*
|
|
114
|
+
* Pure so the default-placement matrix is unit-testable.
|
|
115
|
+
*/
|
|
116
|
+
export declare function bareInteractiveRunDefaultsToDeviceAuto(options: {
|
|
117
|
+
host?: string;
|
|
118
|
+
device?: string;
|
|
119
|
+
on?: string;
|
|
120
|
+
computer?: string;
|
|
121
|
+
resume?: string | boolean;
|
|
122
|
+
lease?: string | boolean;
|
|
123
|
+
box?: string;
|
|
124
|
+
cloud?: boolean;
|
|
125
|
+
}, run: {
|
|
126
|
+
prompt?: string;
|
|
127
|
+
devicePickerRequested?: boolean;
|
|
128
|
+
}, surface: {
|
|
129
|
+
tty: boolean;
|
|
130
|
+
json?: boolean;
|
|
131
|
+
}, env?: NodeJS.ProcessEnv): boolean;
|
|
62
132
|
/**
|
|
63
133
|
* Whether an interactive host dispatch must mint a correlation launch id and
|
|
64
134
|
* resolve the remote session via the launch-id join (RUSH-2034), rather than
|