@phnx-labs/agents-cli 1.23.23 → 1.23.25
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 +12 -0
- package/dist/commands/exec.js +1 -1
- package/dist/commands/fork.js +9 -0
- package/dist/commands/go.js +2 -1
- package/dist/commands/ps.js +2 -2
- package/dist/commands/run-device-picker.js +2 -1
- package/dist/commands/ssh.js +5 -3
- package/dist/lib/devices/health-report.js +2 -0
- package/dist/lib/devices/health.d.ts +5 -1
- package/dist/lib/devices/health.js +17 -3
- package/dist/lib/devices/pool.d.ts +5 -0
- package/dist/lib/devices/pool.js +26 -13
- package/dist/lib/devices/worker-pick.d.ts +2 -1
- package/dist/lib/devices/worker-pick.js +6 -4
- package/dist/lib/exec.d.ts +1 -0
- package/dist/lib/exec.js +4 -3
- package/dist/lib/hosts/option.d.ts +2 -1
- package/dist/lib/hosts/option.js +9 -1
- package/dist/lib/hosts/passthrough.js +2 -4
- package/dist/lib/hosts/routing-flag.d.ts +2 -0
- package/dist/lib/hosts/routing-flag.js +8 -1
- package/dist/lib/session/active.d.ts +7 -0
- package/dist/lib/session/active.js +49 -41
- package/dist/lib/session/db.d.ts +8 -2
- package/dist/lib/session/db.js +32 -28
- package/dist/lib/session/discover.d.ts +7 -2
- package/dist/lib/session/discover.js +61 -39
- package/dist/lib/session/migrate-targets.js +2 -1
- package/dist/lib/session/presentation.js +2 -0
- package/dist/lib/session/title.d.ts +14 -0
- package/dist/lib/session/title.js +32 -0
- package/dist/lib/smart-launch.js +8 -5
- package/dist/lib/teams/agents.js +2 -1
- package/dist/lib/teams/api.js +5 -4
- package/dist/lib/teams/placement-probe.js +1 -0
- package/dist/lib/teams/scheduler.d.ts +3 -2
- package/dist/lib/teams/scheduler.js +9 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.25
|
|
4
|
+
|
|
5
|
+
- **A Claude turn quiet for over two minutes stays `running` in `agents ps`.** Claude writes nothing to its transcript while it thinks or streams one long tool call, so a live turn turned idle after two minutes. agents-cli now passes the turn state Claude Code records in `<config>/sessions/<pid>.json` (`busy` / `idle`) to the state engine (`@phnx-labs/sessions-cli` 0.8.6): `busy` is `running`, `idle` is `idle`, and other harnesses keep the two-minute window. `agents ps --json` rows carry `quietMs` once a running turn has been silent past two minutes, and `agents ps <id>` shows `quiet Nm` beside `working`. Source: `cli/src/lib/session/active.ts`, `cli/src/lib/session/presentation.ts`.
|
|
6
|
+
|
|
7
|
+
- **One session name everywhere; `--name` reaches Claude (PHNX-4387).** A session's name now resolves once, in the CLI, through `resolveSessionName`: a user rename, then Claude's own current name for the running process, then the label already in the index, then the `agents run --name` launch name, then Claude's generated title. The index and the live roster both use it, so `agents ps`, the extension's tab, sidebar card and status bar agree. Claude's per-process `sessions/<pid>.json` is now read from every config home (version and account homes on fleet workers, not only `~/.claude`), a running session's transcript is re-indexed every tick so a rename reaches the index without waiting for its directory to change, and the extension's echoed tab title is no longer an input. `agents run claude --name <x>` now launches `claude --name <x>` (not on `--resume`); the unused `AGENT_SESSION_NAME` env var is gone. `agents ps --json` rows add `startedAs`, the first prompt the session was started with, with `/goal` and harness-injected turns stripped. Source: `cli/src/lib/session/title.ts`, `cli/src/lib/session/active.ts`, `cli/src/lib/session/discover.ts`, `cli/src/lib/exec.ts`.
|
|
8
|
+
|
|
9
|
+
## 1.23.24
|
|
10
|
+
|
|
11
|
+
- **`agents fork <id> --device <box>` works again, and so does every other command that declares its own `--device`.** The fleet router rejected `--device` on any top-level name missing from its hand-kept list, so `agents fork`, `agents cloud run`, `agents projects status` and `agents projects pull` all failed with "does not support --device". The router now steps aside when the resolved command declares `--device` itself (the `--device` that `addHostOption` adds stays the router's, and `--devices`/`--hosts` route exactly as before), and a test walks the whole command tree so a moved or new command cannot lose `--device` silently. `agents config list --device <name>` now runs its own handler (that device's config read here) instead of being forwarded to the device. The fork sibling starts in the source session's folder (`--cwd`) when it lands on the machine that holds the source session, and `agents ps preview` exits 1 when the hop to the owning device fails, so `agents fork` reports the peer's error instead of "could not read the source". Source: `cli/src/lib/hosts/routing-flag.ts`, `cli/src/lib/hosts/passthrough.ts`, `cli/src/commands/fork.ts`, `cli/src/commands/ps.ts`.
|
|
12
|
+
|
|
13
|
+
- **`--device auto` skips boxes with a nearly full disk and honours `preferred` everywhere.** A device with under 20 GiB free on `/` now reads `disk low` in `agents devices list` and is excluded from automatic placement (reason `disk-low`), since an agent that cannot create its worktree does nothing. Memory pressure is judged by free GiB rather than percent used, so a 120 GiB box at 48% no longer reads `busy` and loses every pick to a small idle box. `agents devices pick` (and so `scripts/test.sh`) and `agents teams` placement now apply the `auto-launch.preferred` boost that `agents run --device auto` already did. `agents devices list --json` adds `autoSkip`, the reason auto placement would pass a device over (`off`, `personal`, `desktop`, `not-a-worker`, `offline`, `unreachable`, `loaded`, `disk-low`), or `null`. Source: `cli/src/lib/devices/health.ts`, `cli/src/lib/devices/pool.ts`, `cli/src/lib/teams/scheduler.ts`.
|
|
14
|
+
|
|
3
15
|
## 1.23.23
|
|
4
16
|
|
|
5
17
|
- **The daemon no longer restarts in a loop on a busy Mac when it posts banners for the whole fleet.** With `interactive.host` set to this machine, `attention-notify` ran its hourly mailbox sweep inside its 10-second tick, and in that mode the sweep began with a full session scan. On a Mac at load ~120 the scan took over 100 s, the daemon restarted for the overrun, and the restarted service ran the sweep again on its first tick (50 restarts in a day on the owner's laptop). The scan now runs beside the tick, one at a time, and the first sweep waits an hour after the service starts. Source: `cli/src/lib/daemon/attention-notify-service.ts`.
|
package/dist/commands/exec.js
CHANGED
|
@@ -425,7 +425,7 @@ export function registerRunCommand(program) {
|
|
|
425
425
|
.option('--since <time>', 'With a bare --resume: only sessions newer than this (default 30d; e.g. 2h, 7d, 4w, or ISO date)')
|
|
426
426
|
.option('-n, --limit <n>', 'With a bare --resume: maximum sessions loaded into the picker (default 200)')
|
|
427
427
|
.option('--session-id <id>', 'Force a NEW conversation to use this exact session UUID (Claude only). This CREATES a session — to resume an existing one, use --resume.', parseExplicitSessionId)
|
|
428
|
-
.option('--name <slug>', 'Name the run
|
|
428
|
+
.option('--name <slug>', 'Name the run. Claude receives it as its own session name (`claude --name`); for every harness it becomes the session label shown in `sessions` and `agents ps` and resolves by it (and `agents events logs <name>` for --device runs) instead of an opaque id. A rename inside the session replaces it. Ignored on --resume. Optional.')
|
|
429
429
|
.option('--notify', 'Post a desktop notification when a headless run finishes. Fired by this process on exit, so it survives whatever launched the run (the menu bar dispatching it, a terminal you closed).')
|
|
430
430
|
.option('--terminal [backend]', "Open this run in a real terminal tab instead of here. Without a value the terminal is detected from your live sessions (`agents ps` host), so it lands where you already work — Ghostty for a Ghostty user, iTerm for an iTerm user. Name one to force it: iterm | ghostty | terminal | tmux | vscodium-agent. This is how the menu bar's New Session opens.")
|
|
431
431
|
.option('--verbose', 'Show detailed execution logs')
|
package/dist/commands/fork.js
CHANGED
|
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { setHelpSections } from '../lib/help.js';
|
|
4
4
|
import { getCliLaunch } from '../lib/cli-entry.js';
|
|
5
5
|
import { buildForkRecap, forkLabelFor } from '../lib/session/fork.js';
|
|
6
|
+
import { isSelfHost } from '../lib/devices/self-host.js';
|
|
6
7
|
function defaultDeps() {
|
|
7
8
|
return {
|
|
8
9
|
runPreview: (sub) => {
|
|
@@ -81,6 +82,14 @@ export async function runFork(sessionArg, options, deps = defaultDeps()) {
|
|
|
81
82
|
changes: digest?.changes,
|
|
82
83
|
});
|
|
83
84
|
const runArgs = ['run', source.agent, recap, '-i', '--strategy', 'balanced', '--name', options.name || `fork of ${label}`];
|
|
85
|
+
const sourceIsHere = !source.machine || isSelfHost(source.machine);
|
|
86
|
+
const landsOnSource = !options.device
|
|
87
|
+
? sourceIsHere
|
|
88
|
+
: sourceIsHere
|
|
89
|
+
? isSelfHost(options.device)
|
|
90
|
+
: options.device.toLowerCase() === source.machine.toLowerCase();
|
|
91
|
+
if (source.cwd && landsOnSource)
|
|
92
|
+
runArgs.push('--cwd', source.cwd);
|
|
84
93
|
if (options.device)
|
|
85
94
|
runArgs.push('--device', options.device);
|
|
86
95
|
if (options.terminal !== undefined) {
|
package/dist/commands/go.js
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { execFile } from 'child_process';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
|
-
import { dedupeByMachineSession, getActiveSessions, findSessionFileForKind, listTerminalsActive, sessionProcessIsLocal, sessionProcessHost } from '../lib/session/active.js';
|
|
5
|
+
import { applySessionNames, dedupeByMachineSession, getActiveSessions, findSessionFileForKind, listTerminalsActive, sessionProcessIsLocal, sessionProcessHost } from '../lib/session/active.js';
|
|
6
6
|
import { isSessionIdShape } from '../lib/session/pid-registry.js';
|
|
7
7
|
import { gatherRemoteActive } from '../lib/session/remote-active.js';
|
|
8
8
|
import { discoverSessions } from '../lib/session/discover.js';
|
|
@@ -241,6 +241,7 @@ export function editorTabsForSelector(selector, tabs, nowMs = Date.now()) {
|
|
|
241
241
|
return tabs.filter((t) => isFocusableEditorTab(t, nowMs) && t.sessionId?.startsWith(selector));
|
|
242
242
|
}
|
|
243
243
|
async function focusEditorTab(tab) {
|
|
244
|
+
applySessionNames([tab]);
|
|
244
245
|
const variant = editorVariantForHost(tab.host);
|
|
245
246
|
for (const spec of focusTabSpecs(variant, tab.workspaceDir, tab.terminalId)) {
|
|
246
247
|
const result = await runLocal(spec, 10_000);
|
package/dist/commands/ps.js
CHANGED
|
@@ -402,11 +402,11 @@ async function printSessionPreview(query, scope) {
|
|
|
402
402
|
if (scope.json)
|
|
403
403
|
args.push('--json');
|
|
404
404
|
const rendered = await runOnPeer(args, transcriptPeer);
|
|
405
|
-
if (rendered === 'no-target') {
|
|
405
|
+
if (rendered === 'no-target' || rendered === 'unreachable') {
|
|
406
406
|
console.error(chalk.red(`Session ${session.id} is on ${transcriptPeer}, but that device is not reachable.`));
|
|
407
407
|
return false;
|
|
408
408
|
}
|
|
409
|
-
return
|
|
409
|
+
return rendered === 'ok';
|
|
410
410
|
}
|
|
411
411
|
const live = (await liveSessionsById()).get(session.id);
|
|
412
412
|
if (scope.json) {
|
package/dist/commands/ssh.js
CHANGED
|
@@ -48,7 +48,7 @@ import { boxAddress, boxStatus, fmtIdleShort, fmtExpiresShort, registerLeaseComm
|
|
|
48
48
|
import { registerSnapshotCommand } from './snapshot.js';
|
|
49
49
|
import { authCellColor, formatCheckedAge, isDeadVerdict, readAuthHealthCache, summarizeHostAuth, summarizeVerdicts, verdictColor, verdictLabel, writeFleetAuthRows, } from '../lib/auth-health.js';
|
|
50
50
|
import { getConfigValue, listConfig, setConfigValue, unsetConfigValue, configKeySpec, autoPoolMode, configuredDeviceRole, listConfiguredDeviceRoles, setConfiguredDeviceRole, } from '../lib/device-config.js';
|
|
51
|
-
import { filterAutoPool, listWorkerDevices } from '../lib/devices/pool.js';
|
|
51
|
+
import { autoPoolSkips, autoSkipReason, filterAutoPool, listWorkerDevices } from '../lib/devices/pool.js';
|
|
52
52
|
import { registerCommandGroups, setHelpSections } from '../lib/help.js';
|
|
53
53
|
import { isSelfHost } from '../lib/devices/self-host.js';
|
|
54
54
|
import { collectHeldWorktrees, collectHeldWorktreesUnder, summarizeHeld, aggregateHeld, pushStrandedBranch, } from '../lib/worktree/held.js';
|
|
@@ -87,6 +87,7 @@ const HEADROOM_BADGE = {
|
|
|
87
87
|
light: chalk.green('● light'),
|
|
88
88
|
busy: chalk.yellow('● busy'),
|
|
89
89
|
loaded: chalk.red('● loaded'),
|
|
90
|
+
'disk-low': chalk.red('● disk low'),
|
|
90
91
|
unknown: chalk.gray('· —'),
|
|
91
92
|
};
|
|
92
93
|
function pctCell(v, width) {
|
|
@@ -1402,7 +1403,7 @@ function registerDevicesCommands(program) {
|
|
|
1402
1403
|
}
|
|
1403
1404
|
if (opts.json) {
|
|
1404
1405
|
const jsonRoles = listConfiguredDeviceRoles(names);
|
|
1405
|
-
const
|
|
1406
|
+
const poolSkips = autoPoolSkips(names, { roles: jsonRoles });
|
|
1406
1407
|
process.stdout.write(JSON.stringify(names.map((name) => {
|
|
1407
1408
|
const config = deviceConfigJson(name);
|
|
1408
1409
|
const health = statsMap?.get(name);
|
|
@@ -1412,7 +1413,8 @@ function registerDevicesCommands(program) {
|
|
|
1412
1413
|
interactive: name === interactiveHost,
|
|
1413
1414
|
...(jsonRoles[name] ? { role: jsonRoles[name] } : {}),
|
|
1414
1415
|
...(typeof description === 'string' && description ? { description } : {}),
|
|
1415
|
-
autoPool:
|
|
1416
|
+
autoPool: poolSkips.get(name) === null,
|
|
1417
|
+
autoSkip: autoSkipReason(poolSkips.get(name) ?? null, health, reg[name].tailscale?.online !== false),
|
|
1416
1418
|
...(config ? { config } : {}),
|
|
1417
1419
|
...(health ? { health: { ...health, headroom: headroom(health) } } : {}),
|
|
1418
1420
|
};
|
|
@@ -53,7 +53,11 @@ interface FleetCapacity {
|
|
|
53
53
|
memFreeBytes: number;
|
|
54
54
|
}
|
|
55
55
|
export declare function fleetCapacity(statsList: Iterable<DeviceStats>): FleetCapacity;
|
|
56
|
-
export type Headroom = 'idle' | 'light' | 'busy' | 'loaded' | 'unknown';
|
|
56
|
+
export type Headroom = 'idle' | 'light' | 'busy' | 'loaded' | 'disk-low' | 'unknown';
|
|
57
|
+
export declare const DISK_FLOOR_BYTES: number;
|
|
58
|
+
export declare const MEM_COMFORT_BYTES: number;
|
|
59
|
+
export declare function blocksPlacement(h: Headroom | undefined): boolean;
|
|
60
|
+
export declare function memPressurePercent(s: Pick<DeviceStats, 'memPercent' | 'memFreeBytes'>): number | undefined;
|
|
57
61
|
export declare function headroom(stats: DeviceStats | undefined): Headroom;
|
|
58
62
|
export declare function buildProbeInvocation(device: DeviceProfile, askpassShimPath: string): {
|
|
59
63
|
args: string[];
|
|
@@ -157,13 +157,27 @@ export function fleetCapacity(statsList) {
|
|
|
157
157
|
}
|
|
158
158
|
return cap;
|
|
159
159
|
}
|
|
160
|
+
const GIB = 1024 ** 3;
|
|
161
|
+
export const DISK_FLOOR_BYTES = 20 * GIB;
|
|
162
|
+
export const MEM_COMFORT_BYTES = 16 * GIB;
|
|
163
|
+
export function blocksPlacement(h) {
|
|
164
|
+
return h === 'loaded' || h === 'disk-low';
|
|
165
|
+
}
|
|
166
|
+
export function memPressurePercent(s) {
|
|
167
|
+
if (s.memFreeBytes !== undefined && s.memFreeBytes >= MEM_COMFORT_BYTES)
|
|
168
|
+
return undefined;
|
|
169
|
+
return s.memPercent;
|
|
170
|
+
}
|
|
160
171
|
export function headroom(stats) {
|
|
161
172
|
if (!stats || !stats.reachable)
|
|
162
173
|
return 'unknown';
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
if (stats.diskFreeBytes !== undefined && stats.diskFreeBytes < DISK_FLOOR_BYTES)
|
|
175
|
+
return 'disk-low';
|
|
176
|
+
const hasSignal = stats.loadPercent !== undefined || stats.memPercent !== undefined;
|
|
177
|
+
if (!hasSignal)
|
|
165
178
|
return 'unknown';
|
|
166
|
-
const
|
|
179
|
+
const signals = [stats.loadPercent, memPressurePercent(stats)].filter((v) => typeof v === 'number');
|
|
180
|
+
const worst = signals.length ? Math.max(...signals) : 0;
|
|
167
181
|
if (worst < 15)
|
|
168
182
|
return 'idle';
|
|
169
183
|
if (worst < 40)
|
|
@@ -30,12 +30,17 @@
|
|
|
30
30
|
* ranker ({@link autoLaunchPreferredSet}, applied by `pickBestDevice`).
|
|
31
31
|
*/
|
|
32
32
|
import { type AutoLaunchPreference, type AutoPoolMode, type ConfiguredDeviceRole } from '../device-config.js';
|
|
33
|
+
import { type DeviceStats } from './health.js';
|
|
33
34
|
interface AutoPoolOptions {
|
|
34
35
|
mode?: AutoPoolMode;
|
|
35
36
|
roles?: Record<string, ConfiguredDeviceRole>;
|
|
36
37
|
roster?: string[];
|
|
37
38
|
autoLaunch?: Record<string, AutoLaunchPreference>;
|
|
38
39
|
}
|
|
40
|
+
export type AutoPoolSkip = 'off' | 'personal' | 'desktop' | 'not-a-worker';
|
|
41
|
+
export declare function autoPoolSkips(pool: string[], opts?: AutoPoolOptions): Map<string, AutoPoolSkip | null>;
|
|
42
|
+
export type AutoSkip = AutoPoolSkip | 'offline' | 'unreachable' | 'loaded' | 'disk-low';
|
|
43
|
+
export declare function autoSkipReason(poolSkip: AutoPoolSkip | null, stats: DeviceStats | undefined, tailnetOnline?: boolean): AutoSkip | null;
|
|
39
44
|
export declare function filterAutoPool(pool: string[], opts?: AutoPoolOptions): string[];
|
|
40
45
|
export declare function autoLaunchPreferredSet(pool: string[], opts?: AutoPoolOptions): Set<string>;
|
|
41
46
|
export declare function isAutoPoolMember(host: string, opts?: AutoPoolOptions): boolean;
|
package/dist/lib/devices/pool.js
CHANGED
|
@@ -31,25 +31,38 @@
|
|
|
31
31
|
*/
|
|
32
32
|
import { autoPoolMode, listConfiguredDeviceRoles, loadAutoLaunchPreferences, } from '../device-config.js';
|
|
33
33
|
import { normalizeHost } from '../machine-id.js';
|
|
34
|
-
|
|
35
|
-
export function
|
|
34
|
+
import { headroom } from './health.js';
|
|
35
|
+
export function autoPoolSkips(pool, opts = {}) {
|
|
36
36
|
const roles = opts.roles ?? listConfiguredDeviceRoles(opts.roster ?? pool);
|
|
37
37
|
const byHost = new Map(Object.entries(roles).map(([name, role]) => [normalizeHost(name), role]));
|
|
38
38
|
const roleOf = (host) => byHost.get(normalizeHost(host));
|
|
39
39
|
const disabled = disabledAutoLaunchSet(pool, opts);
|
|
40
|
-
const
|
|
40
|
+
const workersOnly = (opts.mode ?? autoPoolMode()) !== 'all'
|
|
41
|
+
&& [...byHost.values()].some((role) => role === 'worker');
|
|
42
|
+
return new Map(pool.map((host) => {
|
|
41
43
|
if (disabled.has(normalizeHost(host)))
|
|
42
|
-
return
|
|
44
|
+
return [host, 'off'];
|
|
43
45
|
const role = roleOf(host);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (role === 'personal' || role === 'desktop')
|
|
47
|
+
return [host, role];
|
|
48
|
+
if (workersOnly && role !== 'worker')
|
|
49
|
+
return [host, 'not-a-worker'];
|
|
50
|
+
return [host, null];
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
export function autoSkipReason(poolSkip, stats, tailnetOnline = true) {
|
|
54
|
+
if (poolSkip)
|
|
55
|
+
return poolSkip;
|
|
56
|
+
if (!tailnetOnline)
|
|
57
|
+
return 'offline';
|
|
58
|
+
if (stats && !stats.reachable)
|
|
59
|
+
return 'unreachable';
|
|
60
|
+
const h = headroom(stats);
|
|
61
|
+
return h === 'loaded' || h === 'disk-low' ? h : null;
|
|
62
|
+
}
|
|
63
|
+
export function filterAutoPool(pool, opts = {}) {
|
|
64
|
+
const skips = autoPoolSkips(pool, opts);
|
|
65
|
+
return pool.filter((host) => skips.get(host) === null);
|
|
53
66
|
}
|
|
54
67
|
function disabledAutoLaunchSet(pool, opts) {
|
|
55
68
|
const prefs = opts.autoLaunch ?? loadAutoLaunchPreferences(opts.roster ?? pool);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DevicePlacementSignal } from '../teams/scheduler.js';
|
|
2
2
|
export interface WorkerExclusion {
|
|
3
3
|
device: string;
|
|
4
|
-
reason: 'unreachable' | 'probe timed out' | 'overloaded' | 'wrong-platform' | 'interactive';
|
|
4
|
+
reason: 'unreachable' | 'probe timed out' | 'overloaded' | 'disk low' | 'wrong-platform' | 'interactive';
|
|
5
5
|
}
|
|
6
6
|
interface WorkerPickPlan {
|
|
7
7
|
device: string;
|
|
@@ -18,6 +18,7 @@ interface WorkerPickOptions {
|
|
|
18
18
|
eligibleHosts?: string[];
|
|
19
19
|
localMachine?: string;
|
|
20
20
|
probe?: (pool: string[]) => Promise<Map<string, DevicePlacementSignal>>;
|
|
21
|
+
preferred?: ReadonlySet<string>;
|
|
21
22
|
}
|
|
22
23
|
export declare function resolveWorkerDevice(opts?: WorkerPickOptions): Promise<WorkerPickPlan>;
|
|
23
24
|
export declare function formatNoWorkerError(excluded: WorkerExclusion[], platforms: Set<string>): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { normalizeHost } from '../machine-id.js';
|
|
2
2
|
import { localMachineId } from '../session/origin-machine.js';
|
|
3
3
|
import { loadDevicesSync } from './registry.js';
|
|
4
|
-
import { isAutoPoolMember } from './pool.js';
|
|
4
|
+
import { autoLaunchPreferredSet, isAutoPoolMember } from './pool.js';
|
|
5
|
+
import { blocksPlacement } from './health.js';
|
|
5
6
|
import { formatEmptyAutoPoolError, listOnlineDeviceNames, } from '../smart-launch.js';
|
|
6
7
|
import { pickBestDevice } from '../teams/scheduler.js';
|
|
7
8
|
import { probePoolSignals } from '../teams/placement-probe.js';
|
|
@@ -38,15 +39,16 @@ export async function resolveWorkerDevice(opts = {}) {
|
|
|
38
39
|
excluded.push({ device, reason: signal?.timedOut ? 'probe timed out' : 'unreachable' });
|
|
39
40
|
return false;
|
|
40
41
|
}
|
|
41
|
-
if (signal.headroom
|
|
42
|
-
excluded.push({ device, reason: 'overloaded' });
|
|
42
|
+
if (blocksPlacement(signal.headroom)) {
|
|
43
|
+
excluded.push({ device, reason: signal.headroom === 'disk-low' ? 'disk low' : 'overloaded' });
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
45
46
|
return true;
|
|
46
47
|
});
|
|
47
48
|
if (eligible.length === 0)
|
|
48
49
|
throw new Error(formatNoWorkerError(excluded, wanted));
|
|
49
|
-
const
|
|
50
|
+
const preferred = opts.preferred ?? autoLaunchPreferredSet(onPlatform, { roster: onPlatform });
|
|
51
|
+
const device = pickBestDevice(eligible, [], { signals, preferred });
|
|
50
52
|
return {
|
|
51
53
|
device,
|
|
52
54
|
isLocal: normalizeHost(device) === local,
|
package/dist/lib/exec.d.ts
CHANGED
package/dist/lib/exec.js
CHANGED
|
@@ -292,9 +292,6 @@ export function buildExecEnv(options) {
|
|
|
292
292
|
else {
|
|
293
293
|
delete result.AGENTS_RUN_ACCOUNT_ID;
|
|
294
294
|
}
|
|
295
|
-
if (options.name) {
|
|
296
|
-
result.AGENT_SESSION_NAME = options.name;
|
|
297
|
-
}
|
|
298
295
|
Object.assign(result, actorEnv(resolveActor()));
|
|
299
296
|
return {
|
|
300
297
|
...result,
|
|
@@ -335,6 +332,7 @@ export const AGENT_COMMANDS = {
|
|
|
335
332
|
modelFlag: '--model',
|
|
336
333
|
printFlags: ['--print'],
|
|
337
334
|
verboseFlag: '--verbose',
|
|
335
|
+
nameFlag: '--name',
|
|
338
336
|
resume: { flag: '--resume' },
|
|
339
337
|
},
|
|
340
338
|
codex: {
|
|
@@ -621,6 +619,9 @@ export function buildExecCommand(options) {
|
|
|
621
619
|
else if (options.sessionId && options.agent === 'claude') {
|
|
622
620
|
cmd.push('--session-id', options.sessionId);
|
|
623
621
|
}
|
|
622
|
+
if (options.name && template.nameFlag && !options.resume) {
|
|
623
|
+
cmd.push(template.nameFlag, options.name);
|
|
624
|
+
}
|
|
624
625
|
if (effectiveModel && template.modelFlag) {
|
|
625
626
|
if (tierResolved) {
|
|
626
627
|
if (tierResolved.model) {
|
package/dist/lib/hosts/option.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
const routerDeviceOptions = new WeakSet();
|
|
2
|
+
export function isRouterDeviceOption(option) {
|
|
3
|
+
return routerDeviceOptions.has(option);
|
|
4
|
+
}
|
|
1
5
|
export function addHostOption(cmd) {
|
|
2
|
-
|
|
6
|
+
cmd
|
|
3
7
|
.option('-D, --device <name>', 'Run this command on another machine over SSH instead of locally — a registered device, user@host, or `all` to fan out across every registered device. See `agents devices`.')
|
|
4
8
|
.option('--remote-cwd <dir>', "Working directory on the device for --device runs. Resolves on the REMOTE device — pass a '$HOME'-relative path (single-quoted so your local shell doesn't expand it) or a valid remote absolute path; a local ~ expands here and won't exist there (/Users/you vs /home/you). No effect on 'teams add'.")
|
|
5
9
|
.option('--no-tty', 'Force non-interactive output for --device runs even from a terminal.')
|
|
6
10
|
.option('--any', 'With --device <cap> (a capability tag), pick any matching device instead of erroring when several match.');
|
|
11
|
+
const device = cmd.options.find((o) => o.long === '--device');
|
|
12
|
+
if (device)
|
|
13
|
+
routerDeviceOptions.add(device);
|
|
14
|
+
return cmd;
|
|
7
15
|
}
|
|
@@ -8,7 +8,7 @@ import { resolveRemoteOsSync } from './remote-os.js';
|
|
|
8
8
|
import { machineId } from '../machine-id.js';
|
|
9
9
|
import { isDeviceAuto, resolveDeviceAffinity } from '../smart-launch.js';
|
|
10
10
|
import { isDeviceInteractive, resolveInteractiveDevice, interactiveUnsetError, } from '../devices/interactive-host.js';
|
|
11
|
-
import { flagValue, ROUTING_OPTION_SPECS } from './routing-flag.js';
|
|
11
|
+
import { commandOwnsDeviceFlag, flagValue, ROUTING_OPTION_SPECS } from './routing-flag.js';
|
|
12
12
|
import { loadDevices } from '../devices/registry.js';
|
|
13
13
|
import { isSelfHost } from '../devices/self-host.js';
|
|
14
14
|
import { fanOutDevices, planFleetTargets, runLocalCommand, runOnDevice, } from '../devices/fleet.js';
|
|
@@ -333,9 +333,7 @@ export async function maybeRunOnHost(command, allArgs, opts) {
|
|
|
333
333
|
return false;
|
|
334
334
|
if (OWN_HOST_COMMANDS.has(command))
|
|
335
335
|
return false;
|
|
336
|
-
if (
|
|
337
|
-
return false;
|
|
338
|
-
if (command === 'events' && firstSubcommand(allArgs, 'events') === 'logs')
|
|
336
|
+
if (commandOwnsDeviceFlag(allArgs))
|
|
339
337
|
return false;
|
|
340
338
|
if (command === 'teams') {
|
|
341
339
|
const teamsIdx = allArgs.indexOf('teams');
|
|
@@ -16,9 +16,11 @@ export interface RoutingOccurrence {
|
|
|
16
16
|
export interface ScannedArgv {
|
|
17
17
|
commandIndex?: number;
|
|
18
18
|
routing: RoutingOccurrence[];
|
|
19
|
+
leaf?: Command;
|
|
19
20
|
}
|
|
20
21
|
export declare function setArgvCommandTree(root: Command | undefined): void;
|
|
21
22
|
export declare function scanArgv(args: string[], extra?: StripSpec[]): ScannedArgv;
|
|
22
23
|
export declare function commandTokenIndex(args: string[]): number | undefined;
|
|
23
24
|
export declare function flagValue(args: string[], long: string, short?: string): string | undefined;
|
|
25
|
+
export declare function commandOwnsDeviceFlag(args: string[]): boolean;
|
|
24
26
|
export declare function hasHostRoutingFlag(args: string[]): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRouterDeviceOption } from './option.js';
|
|
1
2
|
export const HOST_ROUTING_SPECS = [
|
|
2
3
|
{ long: 'device', short: 'D', takesValue: true },
|
|
3
4
|
{ long: 'host', short: 'H', takesValue: true },
|
|
@@ -119,7 +120,7 @@ export function scanArgv(args, extra = []) {
|
|
|
119
120
|
routing.push(cluster.occurrence);
|
|
120
121
|
i = cluster.last;
|
|
121
122
|
}
|
|
122
|
-
return { commandIndex, routing };
|
|
123
|
+
return { commandIndex, routing, leaf: chain.length > 1 ? chain[chain.length - 1] : undefined };
|
|
123
124
|
}
|
|
124
125
|
export function commandTokenIndex(args) {
|
|
125
126
|
return scanArgv(args).commandIndex;
|
|
@@ -127,6 +128,12 @@ export function commandTokenIndex(args) {
|
|
|
127
128
|
export function flagValue(args, long, short) {
|
|
128
129
|
return scanArgv(args, [{ long, short, takesValue: true }]).routing.find((r) => r.spec.long === long)?.value;
|
|
129
130
|
}
|
|
131
|
+
export function commandOwnsDeviceFlag(args) {
|
|
132
|
+
const { routing, leaf } = scanArgv(args);
|
|
133
|
+
if (!leaf || !routing.some((r) => r.spec.long === 'device' && r.value !== undefined))
|
|
134
|
+
return false;
|
|
135
|
+
return leaf.options.some((o) => o.long === '--device' && !isRouterDeviceOption(o));
|
|
136
|
+
}
|
|
130
137
|
export function hasHostRoutingFlag(args) {
|
|
131
138
|
return scanArgv(args).routing.some((r) => ['device', 'hosts', 'devices'].includes(r.spec.long) && r.value !== undefined);
|
|
132
139
|
}
|
|
@@ -22,6 +22,7 @@ export declare function filterCachedUnattributed(sessions: ActiveSession[], attr
|
|
|
22
22
|
export type ActiveContext = 'terminal' | 'teams' | 'cloud' | 'headless';
|
|
23
23
|
type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'origin' | 'routineName' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
|
|
24
24
|
export declare function backfillActiveRowsFromMeta(sessions: ActiveSession[], metaById: Map<string, BackfillMeta>): void;
|
|
25
|
+
export declare function applySessionNames(sessions: ActiveSession[]): void;
|
|
25
26
|
export declare function sessionAccountLabel(kind: string, session: Pick<SessionMeta, 'accountId' | 'accountKey' | 'account'>, accounts?: import("../account-registry.js").NativeAccount[]): string | undefined;
|
|
26
27
|
export declare function backfillActiveRowsFromIndex(sessions: ActiveSession[]): void;
|
|
27
28
|
export declare function isRunningLiveSession(s: ActiveSession): boolean;
|
|
@@ -78,6 +79,7 @@ export interface ActiveSession {
|
|
|
78
79
|
lastUserMessage?: string;
|
|
79
80
|
generatedTitle?: string;
|
|
80
81
|
title?: string;
|
|
82
|
+
startedAs?: string;
|
|
81
83
|
recapSource?: RecapSource;
|
|
82
84
|
userPromptClean?: string;
|
|
83
85
|
userPromptKind?: UserPromptKind;
|
|
@@ -122,6 +124,7 @@ export interface ActiveSession {
|
|
|
122
124
|
accountLabel?: string;
|
|
123
125
|
lastActivityMs?: number;
|
|
124
126
|
lastEventMs?: number;
|
|
127
|
+
quietMs?: number;
|
|
125
128
|
status: ActiveStatus;
|
|
126
129
|
phase?: SessionPhase;
|
|
127
130
|
origin?: 'cli' | 'routine';
|
|
@@ -201,6 +204,10 @@ interface LiveSignals {
|
|
|
201
204
|
}
|
|
202
205
|
export declare function clearLiveSignalsCacheForTest(): void;
|
|
203
206
|
export declare function computeLiveSignals(kind: string, sessionFile: string | undefined, cwd: string | undefined, pidAlive: boolean, nowMs?: number): LiveSignals;
|
|
207
|
+
export declare function readTranscriptHead(sessionFile: string): {
|
|
208
|
+
topic?: string;
|
|
209
|
+
startedAs?: string;
|
|
210
|
+
};
|
|
204
211
|
export declare function summarizeMission(prompt: string | null | undefined): string | undefined;
|
|
205
212
|
export declare function listTeamsActive(opts?: {
|
|
206
213
|
localOnly?: boolean;
|