@phnx-labs/agents-cli 1.23.23 → 1.23.24
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 +6 -0
- package/dist/commands/fork.js +9 -0
- 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/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/migrate-targets.js +2 -1
- package/dist/lib/smart-launch.js +8 -5
- package/dist/lib/teams/agents.js +2 -1
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.24
|
|
4
|
+
|
|
5
|
+
- **`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`.
|
|
6
|
+
|
|
7
|
+
- **`--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`.
|
|
8
|
+
|
|
3
9
|
## 1.23.23
|
|
4
10
|
|
|
5
11
|
- **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/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/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/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
|
}
|
package/dist/lib/smart-launch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { queryAffinityRollup } from './session/db.js';
|
|
2
2
|
import { localMachineId } from './session/origin-machine.js';
|
|
3
3
|
import { loadDevicesSync } from './devices/registry.js';
|
|
4
|
+
import { blocksPlacement } from './devices/health.js';
|
|
4
5
|
import { autoLaunchPreferredSet, describeAutoPool, filterAutoPool, isAutoPoolMember } from './devices/pool.js';
|
|
5
6
|
import { normalizeHost } from './machine-id.js';
|
|
6
7
|
import { probePoolSignals } from './teams/placement-probe.js';
|
|
@@ -56,7 +57,7 @@ export function formatNoHealthyDeviceError(pool, signals, agent) {
|
|
|
56
57
|
const excluded = pool.map((key) => {
|
|
57
58
|
const signal = signals.get(key);
|
|
58
59
|
let reason;
|
|
59
|
-
if (signal?.reachable === true && signal.headroom
|
|
60
|
+
if (signal?.reachable === true && !blocksPlacement(signal.headroom) && signal.installed === undefined) {
|
|
60
61
|
if (signal.timedOut)
|
|
61
62
|
timedOutCount++;
|
|
62
63
|
reason = signal.timedOut ? 'readiness probe timed out' : 'readiness probe did not answer';
|
|
@@ -64,9 +65,11 @@ export function formatNoHealthyDeviceError(pool, signals, agent) {
|
|
|
64
65
|
else if (signal?.reachable === true) {
|
|
65
66
|
reason = signal.headroom === 'loaded'
|
|
66
67
|
? 'overloaded'
|
|
67
|
-
: signal.
|
|
68
|
-
?
|
|
69
|
-
:
|
|
68
|
+
: signal.headroom === 'disk-low'
|
|
69
|
+
? 'disk low'
|
|
70
|
+
: signal.installed !== true || signal.signedIn !== true
|
|
71
|
+
? `no ready harness account${signal.reason ? ` (${signal.reason})` : ''}`
|
|
72
|
+
: 'ineligible';
|
|
70
73
|
}
|
|
71
74
|
else if (signal?.timedOut) {
|
|
72
75
|
timedOutCount++;
|
|
@@ -119,7 +122,7 @@ export async function resolveDeviceAuto(agent, opts = {}) {
|
|
|
119
122
|
}
|
|
120
123
|
const eligiblePool = pool.filter((key) => {
|
|
121
124
|
const signal = signals.get(key);
|
|
122
|
-
if (signal?.reachable !== true || signal.headroom
|
|
125
|
+
if (signal?.reachable !== true || blocksPlacement(signal.headroom))
|
|
123
126
|
return false;
|
|
124
127
|
if (!agent)
|
|
125
128
|
return opts.probe ? true : signal.installed === true && signal.signedIn === true;
|
package/dist/lib/teams/agents.js
CHANGED
|
@@ -29,7 +29,7 @@ import { atomicWriteJsonSync } from '../fs-atomic.js';
|
|
|
29
29
|
import { resolvePlacement, classifyExclusions, isTransientPlacementBlock, NoViableDeviceError, } from './scheduler.js';
|
|
30
30
|
import { probePoolSignals } from './placement-probe.js';
|
|
31
31
|
import { readMaxConcurrentCaps } from '../device-config.js';
|
|
32
|
-
import { filterAutoPool, listWorkerDevices } from '../devices/pool.js';
|
|
32
|
+
import { autoLaunchPreferredSet, filterAutoPool, listWorkerDevices } from '../devices/pool.js';
|
|
33
33
|
import { redactSecrets, sanitizeForTerminal } from '../redact.js';
|
|
34
34
|
import chalk from 'chalk';
|
|
35
35
|
let lastMemoryWarnAt = 0;
|
|
@@ -1640,6 +1640,7 @@ export class AgentManager {
|
|
|
1640
1640
|
const placeOpts = {
|
|
1641
1641
|
maxConcurrent,
|
|
1642
1642
|
signals,
|
|
1643
|
+
preferred: autoLaunchPreferredSet(pool, { roster: pool }),
|
|
1643
1644
|
defaultDevices: pool,
|
|
1644
1645
|
agentLabel: this.placementAgentLabel(agent),
|
|
1645
1646
|
};
|
|
@@ -83,6 +83,7 @@ export function mergePlacementSignal(stats, readiness) {
|
|
|
83
83
|
headroom: stats ? headroom(stats) : undefined,
|
|
84
84
|
loadPercent: stats?.loadPercent,
|
|
85
85
|
memPercent: stats?.memPercent,
|
|
86
|
+
memFreeBytes: stats?.memFreeBytes,
|
|
86
87
|
installed: readiness?.installed,
|
|
87
88
|
signedIn: readiness?.signedIn,
|
|
88
89
|
pickerEligible: readiness?.pickerEligible,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Headroom } from '../devices/health.js';
|
|
2
2
|
export interface DevicePlacementSignal {
|
|
3
3
|
reachable?: boolean;
|
|
4
4
|
timedOut?: boolean;
|
|
5
5
|
headroom?: Headroom;
|
|
6
6
|
loadPercent?: number;
|
|
7
7
|
memPercent?: number;
|
|
8
|
+
memFreeBytes?: number;
|
|
8
9
|
installed?: boolean;
|
|
9
10
|
signedIn?: boolean;
|
|
10
11
|
pickerEligible?: boolean;
|
|
@@ -20,7 +21,7 @@ interface PlacementOptions {
|
|
|
20
21
|
agentLabel?: string;
|
|
21
22
|
preferred?: ReadonlySet<string>;
|
|
22
23
|
}
|
|
23
|
-
type ExclusionReason = 'unreachable' | 'probe-timed-out' | 'overloaded' | 'capped' | 'not-installed';
|
|
24
|
+
type ExclusionReason = 'unreachable' | 'probe-timed-out' | 'overloaded' | 'disk-low' | 'capped' | 'not-installed';
|
|
24
25
|
interface ExcludedDevice {
|
|
25
26
|
device: string;
|
|
26
27
|
reason: ExclusionReason;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { machineId } from '../machine-id.js';
|
|
1
|
+
import { machineId, normalizeHost } from '../machine-id.js';
|
|
2
|
+
import { blocksPlacement, memPressurePercent } from '../devices/health.js';
|
|
2
3
|
export class NoViableDeviceError extends Error {
|
|
3
4
|
excluded;
|
|
4
5
|
agentLabel;
|
|
@@ -32,7 +33,9 @@ export function formatNoViableMessage(excluded, agentLabel) {
|
|
|
32
33
|
? " Add a device to the pool, raise a cap, or wait for the pool to free up / come back online ('agents devices ping')."
|
|
33
34
|
: allCapped
|
|
34
35
|
? " Raise a cap with 'agents devices config <name> agents.max-concurrent N' or add a device to the pool."
|
|
35
|
-
:
|
|
36
|
+
: excluded.some((e) => e.reason === 'disk-low')
|
|
37
|
+
? ' Free disk on a disk-low box (agents need at least 20G free), or add a device to the pool.'
|
|
38
|
+
: ' Add a device to the pool, raise a cap, or bring an overloaded box under load.';
|
|
36
39
|
const reasons = allCapped
|
|
37
40
|
? excluded.map((e) => `${e.device} (${e.detail})`).join(', ')
|
|
38
41
|
: perDevice;
|
|
@@ -97,7 +100,7 @@ export function pickLeastLoaded(devices, roster, maxConcurrent) {
|
|
|
97
100
|
function loadCost(s) {
|
|
98
101
|
if (!s)
|
|
99
102
|
return undefined;
|
|
100
|
-
const vals = [s.loadPercent, s
|
|
103
|
+
const vals = [s.loadPercent, memPressurePercent(s)].filter((v) => typeof v === 'number');
|
|
101
104
|
return vals.length ? Math.max(...vals) : undefined;
|
|
102
105
|
}
|
|
103
106
|
function headroomTier(h) {
|
|
@@ -124,8 +127,8 @@ export function classifyExclusions(devices, roster, opts) {
|
|
|
124
127
|
excluded.push({ device: d, reason: 'not-installed' });
|
|
125
128
|
continue;
|
|
126
129
|
}
|
|
127
|
-
if (s?.headroom
|
|
128
|
-
excluded.push({ device: d, reason: 'overloaded' });
|
|
130
|
+
if (blocksPlacement(s?.headroom)) {
|
|
131
|
+
excluded.push({ device: d, reason: s?.headroom === 'disk-low' ? 'disk-low' : 'overloaded' });
|
|
129
132
|
continue;
|
|
130
133
|
}
|
|
131
134
|
const cap = caps[d];
|
|
@@ -169,7 +172,7 @@ export function pickBestDevice(devices, roster, opts) {
|
|
|
169
172
|
return signedIn;
|
|
170
173
|
const preferred = opts?.preferred;
|
|
171
174
|
if (preferred && preferred.size > 0) {
|
|
172
|
-
const pref = (preferred.has(a) ? 0 : 1) - (preferred.has(b) ? 0 : 1);
|
|
175
|
+
const pref = (preferred.has(normalizeHost(a)) ? 0 : 1) - (preferred.has(normalizeHost(b)) ? 0 : 1);
|
|
173
176
|
if (pref !== 0)
|
|
174
177
|
return pref;
|
|
175
178
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phnx-labs/agents-cli",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.24",
|
|
4
4
|
"description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|