@phnx-labs/agents-cli 1.23.17 → 1.23.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +239 -0
- package/README.md +140 -165
- package/dist/bootstrap.js +11 -17
- package/dist/cli/command-registry.d.ts +1 -2
- package/dist/cli/command-registry.js +1 -10
- package/dist/commands/accounts.js +7 -7
- package/dist/commands/cloud-transcripts.d.ts +0 -1
- package/dist/commands/cloud-transcripts.js +2 -2
- package/dist/commands/cloud.js +2 -2
- package/dist/commands/config.js +1 -5
- package/dist/commands/cost.js +1 -1
- package/dist/commands/daemon-index.js +0 -1
- package/dist/commands/detach.d.ts +1 -1
- package/dist/commands/detach.js +10 -6
- package/dist/commands/doctor.js +11 -7
- package/dist/commands/exec.d.ts +0 -17
- package/dist/commands/exec.js +26 -72
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +3 -3
- package/dist/commands/focus.d.ts +11 -6
- package/dist/commands/focus.js +91 -31
- package/dist/commands/fork.d.ts +0 -1
- package/dist/commands/fork.js +7 -16
- package/dist/commands/harness-wizard.js +1 -1
- package/dist/commands/harness.js +1 -1
- package/dist/commands/insights.d.ts +0 -1
- package/dist/commands/insights.js +3 -7
- package/dist/commands/open.js +1 -1
- package/dist/commands/output.js +1 -1
- package/dist/commands/profiles.d.ts +1 -1
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/projects-todo.js +10 -5
- package/dist/commands/projects.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/ps.d.ts +8 -3
- package/dist/commands/ps.js +238 -110
- package/dist/commands/routines.js +1 -1
- package/dist/commands/send.js +1 -1
- package/dist/commands/sessions-backfill.d.ts +0 -1
- package/dist/commands/sessions-backfill.js +3 -6
- package/dist/commands/sessions-browser.d.ts +0 -10
- package/dist/commands/sessions-browser.js +19 -25
- package/dist/commands/sessions-migrate.d.ts +2 -2
- package/dist/commands/sessions-migrate.js +13 -13
- package/dist/commands/sessions-optimize.d.ts +0 -1
- package/dist/commands/sessions-optimize.js +0 -3
- package/dist/commands/sessions-picker.d.ts +0 -7
- package/dist/commands/sessions-picker.js +16 -310
- package/dist/commands/sessions-resume.d.ts +16 -15
- package/dist/commands/sessions-resume.js +101 -269
- package/dist/commands/sessions-stats.d.ts +0 -1
- package/dist/commands/sessions-stats.js +5 -8
- package/dist/commands/sessions-stop.d.ts +1 -1
- package/dist/commands/sessions-stop.js +8 -8
- package/dist/commands/sessions-trace.d.ts +1 -1
- package/dist/commands/sessions-trace.js +40 -17
- package/dist/commands/sessions-watch.js +2 -2
- package/dist/commands/sessions.test-fixture.d.ts +1 -0
- package/dist/commands/sessions.test-fixture.js +14 -0
- package/dist/commands/setup-browser.js +4 -4
- package/dist/commands/setup-computer.js +4 -4
- package/dist/commands/setup-fleet.js +1 -1
- package/dist/commands/setup-preferences.js +1 -1
- package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
- package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
- package/dist/commands/setup.js +3 -1
- package/dist/commands/ssh.js +4 -5
- package/dist/commands/sync.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/utils.d.ts +0 -1
- package/dist/commands/utils.js +0 -10
- package/dist/index.js +0 -71
- package/dist/lib/account-registry.d.ts +3 -0
- package/dist/lib/account-registry.js +40 -0
- package/dist/lib/accounting/usage-sync.d.ts +1 -0
- package/dist/lib/accounting/usage-sync.js +20 -3
- package/dist/lib/accounting/usage.d.ts +4 -1
- package/dist/lib/accounting/usage.js +38 -6
- package/dist/lib/agent-spec/agents.js +12 -11
- package/dist/lib/analytics/mix-commands.js +1 -1
- package/dist/lib/auth-mint.js +2 -2
- package/dist/lib/browser-client.d.ts +0 -1
- package/dist/lib/browser-client.js +0 -3
- package/dist/lib/cloud/antigravity.js +1 -1
- package/dist/lib/cloud/cursor.js +3 -3
- package/dist/lib/cloud/store.d.ts +5 -1
- package/dist/lib/cloud/store.js +10 -3
- package/dist/lib/cloudflare/creds.js +2 -2
- package/dist/lib/computer/context.d.ts +4 -21
- package/dist/lib/computer/context.js +3 -24
- package/dist/lib/computer/policy.d.ts +0 -10
- package/dist/lib/computer/policy.js +0 -28
- package/dist/lib/computer-client.d.ts +0 -44
- package/dist/lib/computer-client.js +17 -121
- package/dist/lib/config-keys.d.ts +2 -2
- package/dist/lib/config-keys.js +1 -3
- package/dist/lib/crabbox/cli.js +1 -1
- package/dist/lib/daemon/account-state-daemon-service.js +9 -2
- package/dist/lib/daemon/self-update-service.js +1 -1
- package/dist/lib/device-config.d.ts +2 -1
- package/dist/lib/device-config.js +26 -39
- package/dist/lib/devices/connect.d.ts +1 -1
- package/dist/lib/devices/connect.js +3 -6
- package/dist/lib/devices/doctor-findings.d.ts +2 -1
- package/dist/lib/devices/doctor-findings.js +4 -4
- package/dist/lib/devices/health.d.ts +6 -0
- package/dist/lib/devices/health.js +11 -4
- package/dist/lib/exec.js +1 -1
- package/dist/lib/feed/activity.js +1 -1
- package/dist/lib/feed/watch.js +2 -1
- package/dist/lib/fleet/apply.d.ts +1 -1
- package/dist/lib/fleet/apply.js +6 -3
- package/dist/lib/fleet-shared-state.d.ts +2 -0
- package/dist/lib/fleet-shared-state.js +3 -1
- package/dist/lib/github/project-prs.js +14 -1
- package/dist/lib/help.d.ts +0 -1
- package/dist/lib/help.js +2 -10
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/option.js +1 -1
- package/dist/lib/hosts/passthrough.d.ts +0 -1
- package/dist/lib/hosts/passthrough.js +2 -26
- package/dist/lib/hosts/reconnect.js +5 -5
- package/dist/lib/hosts/remote-cmd.d.ts +3 -5
- package/dist/lib/hosts/remote-cmd.js +15 -20
- package/dist/lib/hosts/remote-session-id.js +1 -1
- package/dist/lib/installations/active-check.js +1 -1
- package/dist/lib/installations/migrate.js +4 -15
- package/dist/lib/installations/versions.js +5 -4
- package/dist/lib/launch-log.js +3 -6
- package/dist/lib/owner-notify.d.ts +1 -6
- package/dist/lib/owner-notify.js +0 -2
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -8
- package/dist/lib/permissions.js +1 -1
- package/dist/lib/project-root.d.ts +1 -0
- package/dist/lib/project-root.js +11 -3
- package/dist/lib/projects.js +2 -2
- package/dist/lib/quick-todo.d.ts +5 -1
- package/dist/lib/quick-todo.js +14 -1
- package/dist/lib/redact.d.ts +0 -1
- package/dist/lib/redact.js +0 -4
- package/dist/lib/remote-agents-json.d.ts +3 -1
- package/dist/lib/remote-agents-json.js +12 -8
- package/dist/lib/reserved-stores.js +1 -1
- package/dist/lib/scheduling/routines.d.ts +0 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/self-update.d.ts +1 -1
- package/dist/lib/self-update.js +59 -2
- package/dist/lib/session/active.d.ts +1 -1
- package/dist/lib/session/db.js +4 -4
- package/dist/lib/session/detached.d.ts +0 -1
- package/dist/lib/session/detached.js +0 -23
- package/dist/lib/session/discover.d.ts +2 -2
- package/dist/lib/session/glance-files.d.ts +21 -0
- package/dist/lib/session/glance-files.js +123 -0
- package/dist/lib/session/presentation.d.ts +3 -7
- package/dist/lib/session/presentation.js +4 -4
- package/dist/lib/session/preview-digest.d.ts +13 -0
- package/dist/lib/session/preview-digest.js +328 -0
- package/dist/lib/session/projection.js +1 -1
- package/dist/lib/session/remote/remote-list.d.ts +5 -2
- package/dist/lib/session/remote/remote-list.js +15 -8
- package/dist/lib/session/remote/watch.d.ts +2 -0
- package/dist/lib/session/remote/watch.js +90 -10
- package/dist/lib/session/remote-active.js +1 -1
- package/dist/lib/session/resume-command.d.ts +0 -1
- package/dist/lib/session/resume-command.js +1 -4
- package/dist/lib/session/resume-owner.d.ts +0 -2
- package/dist/lib/session/resume-owner.js +0 -6
- package/dist/lib/session/selection.d.ts +4 -5
- package/dist/lib/session/selection.js +2 -2
- package/dist/lib/session/sync/config.d.ts +0 -25
- package/dist/lib/session/sync/config.js +0 -62
- package/dist/lib/session/sync/managed-config.d.ts +0 -1
- package/dist/lib/session/sync/managed-config.js +0 -3
- package/dist/lib/session/sync/worker-template.js +1 -1
- package/dist/lib/sessions-client.d.ts +0 -16
- package/dist/lib/sessions-client.js +1 -187
- package/dist/lib/smart-launch.js +6 -1
- package/dist/lib/startup/command-registry.d.ts +2 -0
- package/dist/lib/startup/command-registry.js +36 -3
- package/dist/lib/startup/root-command.d.ts +0 -1
- package/dist/lib/startup/root-command.js +0 -21
- package/dist/lib/sync-umbrella.js +1 -1
- package/dist/lib/teams/placement-probe.d.ts +2 -0
- package/dist/lib/teams/placement-probe.js +8 -3
- package/dist/lib/terminal/engine.d.ts +2 -0
- package/dist/lib/terminal/engine.js +5 -3
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/resolve.js +1 -1
- package/dist/lib/terminal/run-surface.d.ts +1 -0
- package/dist/lib/terminal/run-surface.js +9 -0
- package/dist/lib/watchdog/rotate.js +1 -1
- package/dist/lib/watchdog/watchdog.d.ts +1 -1
- package/dist/lib/watchdog/watchdog.js +2 -2
- package/package.json +1 -1
- package/dist/commands/browser.d.ts +0 -7
- package/dist/commands/browser.js +0 -139
- package/dist/commands/computer.d.ts +0 -48
- package/dist/commands/computer.js +0 -244
- package/dist/commands/resume.d.ts +0 -23
- package/dist/commands/resume.js +0 -158
- package/dist/commands/secrets-passthrough.d.ts +0 -3
- package/dist/commands/secrets-passthrough.js +0 -52
- package/dist/commands/sessions-bookmark.d.ts +0 -2
- package/dist/commands/sessions-bookmark.js +0 -92
- package/dist/commands/sessions-export.d.ts +0 -31
- package/dist/commands/sessions-export.js +0 -409
- package/dist/commands/sessions-import.d.ts +0 -6
- package/dist/commands/sessions-import.js +0 -343
- package/dist/commands/sessions-inject.d.ts +0 -14
- package/dist/commands/sessions-inject.js +0 -143
- package/dist/commands/sessions-picker-factory.d.ts +0 -24
- package/dist/commands/sessions-picker-factory.js +0 -59
- package/dist/commands/sessions-render.d.ts +0 -11
- package/dist/commands/sessions-render.js +0 -119
- package/dist/commands/sessions-share.d.ts +0 -15
- package/dist/commands/sessions-share.js +0 -171
- package/dist/commands/sessions.d.ts +0 -122
- package/dist/commands/sessions.js +0 -1760
- package/dist/lib/address.d.ts +0 -39
- package/dist/lib/address.js +0 -128
- package/dist/lib/computer/record.d.ts +0 -6
- package/dist/lib/computer/record.js +0 -25
- package/dist/lib/onepassword.d.ts +0 -57
- package/dist/lib/onepassword.js +0 -140
- package/dist/lib/openclaw-keychain.d.ts +0 -43
- package/dist/lib/openclaw-keychain.js +0 -227
- package/dist/lib/session/bundle.d.ts +0 -76
- package/dist/lib/session/bundle.js +0 -146
- package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
- package/dist/lib/session/remote/remote-bundle.js +0 -40
- package/dist/lib/session/remote/remote.d.ts +0 -35
- package/dist/lib/session/remote/remote.js +0 -198
- package/dist/lib/session/remote-bundle.d.ts +0 -1
- package/dist/lib/session/remote-bundle.js +0 -1
- package/dist/lib/session/remote.d.ts +0 -1
- package/dist/lib/session/remote.js +0 -1
- package/dist/lib/session/sync/agents.d.ts +0 -24
- package/dist/lib/session/sync/agents.js +0 -0
- package/dist/lib/session/sync/backend.d.ts +0 -22
- package/dist/lib/session/sync/backend.js +0 -44
- package/dist/lib/session/sync/managed-key.d.ts +0 -5
- package/dist/lib/session/sync/managed-key.js +0 -87
- package/dist/lib/session/sync/net-client.d.ts +0 -29
- package/dist/lib/session/sync/net-client.js +0 -87
- package/dist/lib/session/sync/r2.d.ts +0 -20
- package/dist/lib/session/sync/r2.js +0 -103
- package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
- package/dist/lib/session/sync/transcript-crypto.js +0 -115
package/dist/commands/exec.js
CHANGED
|
@@ -5,7 +5,6 @@ import { RUN_AUTO_KEYWORD } from '../lib/types.js';
|
|
|
5
5
|
import { setHelpSections } from '../lib/help.js';
|
|
6
6
|
import { formatModeSupportTable } from '../lib/agent-modes.js';
|
|
7
7
|
import { isInteractiveTerminal, isPromptCancelled, requireInteractiveSelection } from './utils.js';
|
|
8
|
-
import { isHumanFacingRun } from './run-account-picker.js';
|
|
9
8
|
import { getUserAgentsDir, readMeta } from '../lib/state.js';
|
|
10
9
|
import { parseLoopInterval } from '../lib/loop.js';
|
|
11
10
|
import { AGENTS, resolveAgentName, isAgentHardDeprecated, hardDeprecationError } from '../lib/agents.js';
|
|
@@ -116,17 +115,6 @@ export function runAutoDefaultsToAffinity(options, env = process.env) {
|
|
|
116
115
|
return false;
|
|
117
116
|
return env.AGENTS_REMOTE_INTERACTIVE !== '1';
|
|
118
117
|
}
|
|
119
|
-
export function bareInteractiveRunDefaultsToDeviceAuto(options, run, surface, env = process.env) {
|
|
120
|
-
if (run.prompt !== undefined)
|
|
121
|
-
return false;
|
|
122
|
-
if (!isHumanFacingRun({ tty: surface.tty, json: surface.json === true }))
|
|
123
|
-
return false;
|
|
124
|
-
if (run.devicePickerRequested)
|
|
125
|
-
return false;
|
|
126
|
-
if (options.resume !== undefined || options.lease || options.box || options.cloud)
|
|
127
|
-
return false;
|
|
128
|
-
return runAutoDefaultsToAffinity(options, env);
|
|
129
|
-
}
|
|
130
118
|
export function hostInteractiveNeedsCorrelationId(runAgent, hostSessionId, resumeId) {
|
|
131
119
|
if (resumeId)
|
|
132
120
|
return false;
|
|
@@ -343,7 +331,7 @@ export async function resolveRunCwd(options, opts) {
|
|
|
343
331
|
}
|
|
344
332
|
}
|
|
345
333
|
async function handleTerminalHandoff(agentSpec, options, prompt) {
|
|
346
|
-
const { parseTerminalFlag, openRunInTerminal,
|
|
334
|
+
const { parseTerminalFlag, openRunInTerminal, liveHostSamples, currentContext } = await import('../lib/terminal/index.js');
|
|
347
335
|
const parsed = parseTerminalFlag(options.terminal);
|
|
348
336
|
if (parsed.error) {
|
|
349
337
|
console.error(chalk.red(parsed.error));
|
|
@@ -378,13 +366,7 @@ async function handleTerminalHandoff(agentSpec, options, prompt) {
|
|
|
378
366
|
process.exit(1);
|
|
379
367
|
}
|
|
380
368
|
const cwd = await resolveRunCwd(options, { forRemote: false });
|
|
381
|
-
const
|
|
382
|
-
let sessions = [];
|
|
383
|
-
try {
|
|
384
|
-
sessions = await toHostSamples(await getActiveSessions());
|
|
385
|
-
}
|
|
386
|
-
catch {
|
|
387
|
-
}
|
|
369
|
+
const sessions = await liveHostSamples();
|
|
388
370
|
const result = await openRunInTerminal({
|
|
389
371
|
argv: process.argv.slice(2),
|
|
390
372
|
forced: parsed.backend,
|
|
@@ -420,7 +402,7 @@ export function registerRunCommand(program) {
|
|
|
420
402
|
.option('-e, --effort <effort>', 'Reasoning effort: low | medium | high | xhigh | max | auto (claude and codex only)', 'auto')
|
|
421
403
|
.option('--model <model>', 'Cost tier (cheap|default|best|ultra) or a concrete model id; tiers resolve per harness+version to a supported model')
|
|
422
404
|
.option('--env <key=value>', 'Pass environment variable to the agent (repeatable, e.g., --env DEBUG=1 --env API_KEY=xyz)', (val, prev) => [...prev, val], [])
|
|
423
|
-
.option('--secrets <bundle>', 'Inject a secrets bundle (repeatable). Values resolve from macOS Keychain at run time. See `
|
|
405
|
+
.option('--secrets <bundle>', 'Inject a secrets bundle (repeatable). Values resolve from macOS Keychain at run time. See `secrets --help`.', (val, prev) => [...prev, val], [])
|
|
424
406
|
.option('--no-auto-secrets', 'Skip auto-injection of secrets declared by a workflow\'s frontmatter `secrets:` field. Has no effect on bare-agent runs.')
|
|
425
407
|
.option('--secrets-keys <keys>', 'Inject only this comma-separated subset of keys from --secrets bundles (e.g. KEY1,KEY2). Missing keys are an error. Applies to all --secrets bundles on this run.')
|
|
426
408
|
.option('--allow-expired', 'Inject secrets even if their expiry date has passed (overrides the pre-run expiry abort).')
|
|
@@ -443,9 +425,9 @@ export function registerRunCommand(program) {
|
|
|
443
425
|
.option('--since <time>', 'With a bare --resume: only sessions newer than this (default 30d; e.g. 2h, 7d, 4w, or ISO date)')
|
|
444
426
|
.option('-n, --limit <n>', 'With a bare --resume: maximum sessions loaded into the picker (default 200)')
|
|
445
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)
|
|
446
|
-
.option('--name <slug>', 'Name the run — seeds the session label so it shows up as `<name>` in `agents
|
|
428
|
+
.option('--name <slug>', 'Name the run — seeds the session label so it shows up as `<name>` in `sessions` and `agents ps` and resolves by it (and `agents events logs <name>` for --device runs) instead of an opaque id. An agent-generated title later refines the label; your name shows until then. Optional.')
|
|
447
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).')
|
|
448
|
-
.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
|
|
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.")
|
|
449
431
|
.option('--verbose', 'Show detailed execution logs')
|
|
450
432
|
.option('--raw', 'Keep this interactive run direct when the device has opted into tmux wrapping. A no-op under the default tmux-off configuration; equivalent to AGENTS_NO_TMUX=1.')
|
|
451
433
|
.option('--no-tmux', 'Keep this run direct when tmux wrapping is enabled for the device. Same effect as --raw / AGENTS_NO_TMUX=1; it is a no-op under the default tmux-off configuration.')
|
|
@@ -464,7 +446,7 @@ export function registerRunCommand(program) {
|
|
|
464
446
|
.option('--until <signal>', 'Loop stop condition. `signal` reads <runDir>/loop-signal.json {continue,reason} each iteration; absent or continue:false stops (fail-closed). Loop only.')
|
|
465
447
|
.option('--interval <dur>', 'Loop delay between iterations ("0" back-to-back, "30m" paces). Loop only.')
|
|
466
448
|
.option('--where <spec>', 'Where this run\'s body executes (one placement door): local | device:<name> | auto | lease[:backend] | cloud[:provider]. Expands to --device/--lease/--cloud. Do not combine with those flags. See docs/00-concepts.md#placement.')
|
|
467
|
-
.option('--local', 'Run on this machine
|
|
449
|
+
.option('--local', 'Run on this machine, the default for a bare run. Pins it against --where defaults and run-auto affinity. Same as --where local or --device <this machine>.')
|
|
468
450
|
.option('-D, --device <name>', 'Offload this run onto another machine over SSH — a registered device, or user@host. Pass "auto" to pick the least-loaded reachable device where the requested agent is installed and signed in, keeping the run local when no remote is better, or "interactive" for the machine pinned as interactive.host (the box a human is sitting at). Naming this machine runs locally, no SSH. Same as --where device:<name>. See `agents devices`.')
|
|
469
451
|
.option('--remote-cwd <dir>', "Explicit device working directory for --device runs, used VERBATIM (overrides --cwd; usually --cwd suffices — it re-roots a local-home path onto the remote home). Pass a single-quoted '$HOME/…' or a valid remote absolute path; a local ~ expands here and won't exist there (/Users/you vs /home/you).")
|
|
470
452
|
.option('--no-follow', 'With --device, dispatch detached and return immediately (track via `agents devices ps` and `agents events logs`).')
|
|
@@ -495,10 +477,9 @@ export function registerRunCommand(program) {
|
|
|
495
477
|
# Headless, can edit: have the agent make changes
|
|
496
478
|
agents run claude "fix lint errors in src/" --mode edit
|
|
497
479
|
|
|
498
|
-
# Interactive (TUI): a bare run
|
|
499
|
-
# worker, TUI forwarded over SSH); --local keeps it on this machine
|
|
480
|
+
# Interactive (TUI): a bare run starts on this machine
|
|
500
481
|
agents run claude
|
|
501
|
-
agents run claude --
|
|
482
|
+
agents run claude --device auto # ...or let the fleet place it (TUI over SSH)
|
|
502
483
|
|
|
503
484
|
# Pick a signed-in account/version for only this run (# = account picker)
|
|
504
485
|
agents run claude#
|
|
@@ -607,26 +588,24 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
607
588
|
with an explicit pin of the same thing (--account, --device/--on/
|
|
608
589
|
--computer/--host) or with --strategy/--balanced/--resume/--lease/--box.
|
|
609
590
|
|
|
610
|
-
Interactive placement: a bare 'agents run <harness>'
|
|
611
|
-
|
|
612
|
-
forwarded over SSH
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
first) in the '<harness>@' device picker. When placement finds no
|
|
616
|
-
healthy device the run fails loud and names the local spelling.
|
|
591
|
+
Interactive placement: a bare 'agents run <harness>' runs on this
|
|
592
|
+
machine. Placement is opt-in: --device auto (a fleet worker runs it,
|
|
593
|
+
TUI forwarded over SSH), --device <box>, or the '<harness>@' device
|
|
594
|
+
picker. When automatic placement finds no healthy device the run fails
|
|
595
|
+
loud rather than silently running here.
|
|
617
596
|
|
|
618
597
|
Fallback: --fallback codex,antigravity retries on rate-limit failure via /continue handoff. Each entry accepts @version.
|
|
619
598
|
|
|
620
599
|
Cloud placement: --cloud sends the run to the agent's native vendor cloud
|
|
621
|
-
(claude→rush, codex→codex, droid→factory, antigravity→antigravity) — the
|
|
600
|
+
(claude→rush, codex→codex, cursor→cursor, droid→factory, antigravity→antigravity) — the
|
|
622
601
|
same dispatch as agents cloud run --agent <agent>, tracked by agents
|
|
623
602
|
cloud list/status/logs/cancel/message. --provider overrides the routing;
|
|
624
603
|
--repo/--branch/--cloud-env refine the task. Agents without a native
|
|
625
|
-
cloud (kimi, grok,
|
|
604
|
+
cloud (kimi, grok, opencode, …) fail loud unless --provider is
|
|
626
605
|
given. --cloud is mutually exclusive with --device/--lease and with
|
|
627
606
|
local-run flags (--loop, --resume, --secrets, --terminal, …).
|
|
628
607
|
|
|
629
|
-
Resume: --resume <id> resolves full IDs locally first, then fleet-wide, and recovers on the source device with its cwd/mode. Resume preserves the conversation account and uses the installed binary; starting a new conversation from archived context requires an explicit choice. agents
|
|
608
|
+
Resume: --resume <id> resolves full IDs locally first, then fleet-wide, and recovers on the source device with its cwd/mode. Resume preserves the conversation account and uses the installed binary; starting a new conversation from archived context requires an explicit choice. With auto as the agent (agents run auto --resume <id>) the harness is inferred from the session; a named agent must match it. A bare --resume opens the session picker for the last 30 days of this project (up to 200 rows); --all widens it to every directory and lifts the 30d window, --teams adds team-spawned sessions, --since <time> and -n/--limit <n> set the window and row cap. These four only filter the picker: they are refused next to --resume <id> or without --resume.
|
|
630
609
|
|
|
631
610
|
Passthrough: everything after -- is forwarded verbatim to the underlying agent CLI.
|
|
632
611
|
agents run kimi -- --plan --some-native-flag value
|
|
@@ -781,7 +760,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
781
760
|
const { sessionsResumeAction } = await import('./sessions-resume.js');
|
|
782
761
|
const { toRemotePortable } = await import('../lib/project-root.js');
|
|
783
762
|
const device = options.host || options.device || options.on || options.computer;
|
|
784
|
-
await sessionsResumeAction(
|
|
763
|
+
await sessionsResumeAction({
|
|
785
764
|
agent: normalizedAgentSpec.split('#')[0] === RUN_AUTO_KEYWORD ? undefined : normalizedAgentSpec.split('#')[0],
|
|
786
765
|
account: options.account,
|
|
787
766
|
model: options.model,
|
|
@@ -832,19 +811,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
832
811
|
let resolvedRecoveryTarget;
|
|
833
812
|
if (typeof options.resume === 'string' && options.resume.trim()) {
|
|
834
813
|
const selector = options.resume.trim();
|
|
835
|
-
const
|
|
836
|
-
try {
|
|
837
|
-
const parsed = JSON.parse(process.env.AGENTS_RESUME_SOURCE_JSON ?? 'null');
|
|
838
|
-
return parsed?.id === selector ? parsed : undefined;
|
|
839
|
-
}
|
|
840
|
-
catch {
|
|
841
|
-
return undefined;
|
|
842
|
-
}
|
|
843
|
-
})();
|
|
844
|
-
delete process.env.AGENTS_RESUME_SOURCE_JSON;
|
|
845
|
-
const outcome = injectedSource
|
|
846
|
-
? { kind: 'resolved', session: injectedSource }
|
|
847
|
-
: await (await import('../lib/session/selection.js')).resolveSessionMetadataValue(selector, { agent: runBaseAgentId ?? undefined });
|
|
814
|
+
const outcome = await (await import('../lib/session/selection.js')).resolveSessionMetadataValue(selector, { agent: runBaseAgentId ?? undefined });
|
|
848
815
|
if (outcome.kind === 'partial') {
|
|
849
816
|
const offline = outcome.failedPeers;
|
|
850
817
|
console.error(chalk.yellow(`Warning: ${offline.length} device(s) unreachable, not checked: ${offline.join(', ')}`));
|
|
@@ -864,7 +831,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
864
831
|
const [requestedAgent] = normalizedAgentSpec.split('#')[0].split('@');
|
|
865
832
|
if (!autoHarnessRequested && requestedAgent !== resolvedResumeSource.agent) {
|
|
866
833
|
console.error(chalk.red(`Session ${resolvedResumeSource.shortId} belongs to ${resolvedResumeSource.agent}, not ${requestedAgent}. ` +
|
|
867
|
-
`Use: agents
|
|
834
|
+
`Use: agents run auto --resume ${resolvedResumeSource.id}`));
|
|
868
835
|
process.exit(1);
|
|
869
836
|
}
|
|
870
837
|
if (command.getOptionValueSource('mode') === 'default') {
|
|
@@ -973,27 +940,14 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
973
940
|
if (!isSelfHost(pickedDevice))
|
|
974
941
|
options.device = pickedDevice;
|
|
975
942
|
}
|
|
976
|
-
const defaultPlacement = bareInteractiveRunDefaultsToDeviceAuto(options, { prompt, devicePickerRequested }, { tty: isInteractiveTerminal(), json: options.json });
|
|
977
|
-
if (defaultPlacement)
|
|
978
|
-
options.device = 'auto';
|
|
979
943
|
{
|
|
980
944
|
const { applyDeviceAutoToOptions } = await import('../lib/smart-launch.js');
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
: (resolveAgentName(normalizedAgentSpec.split('#')[0].split('@')[0]) ?? undefined),
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
catch (err) {
|
|
991
|
-
if (!defaultPlacement)
|
|
992
|
-
throw err;
|
|
993
|
-
console.error(chalk.red(err.message));
|
|
994
|
-
console.error(chalk.gray(`Run here instead: agents run ${runBaseAgentName} --local`));
|
|
995
|
-
process.exit(1);
|
|
996
|
-
}
|
|
945
|
+
const result = await applyDeviceAutoToOptions(options, {
|
|
946
|
+
accountPickerRequested,
|
|
947
|
+
agent: normalizedAgentSpec.split('#')[0].split('@')[0] === RUN_AUTO_KEYWORD
|
|
948
|
+
? undefined
|
|
949
|
+
: (resolveAgentName(normalizedAgentSpec.split('#')[0].split('@')[0]) ?? undefined),
|
|
950
|
+
});
|
|
997
951
|
if (!options.quiet && result.banner) {
|
|
998
952
|
const { hostLabel, deviceHint, acctNote } = result.banner;
|
|
999
953
|
process.stderr.write(chalk.gray(`[agents] device=auto → ${hostLabel}` +
|
|
@@ -1513,7 +1467,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
|
|
|
1513
1467
|
if (options.follow === false) {
|
|
1514
1468
|
const handle = task.name ?? task.id;
|
|
1515
1469
|
console.log(chalk.green(`Dispatched to ${host.name}${task.name ? ` as "${task.name}"` : ''}.`) + '\n' +
|
|
1516
|
-
chalk.gray(` Status: agents
|
|
1470
|
+
chalk.gray(` Status: agents ps preview ${handle}`) + chalk.gray(' (compact digest — use this)') + '\n' +
|
|
1517
1471
|
chalk.gray(` Raw log: agents events logs ${handle} -f`) + chalk.gray(' (heavy, only if needed)'));
|
|
1518
1472
|
process.exit(0);
|
|
1519
1473
|
}
|
package/dist/commands/feed.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type OpenBlock } from '../lib/feed/feed.js';
|
|
|
3
3
|
import { type OutcomeGroup, type SessionOutcomeHint } from '../lib/feed-outcome.js';
|
|
4
4
|
import { filterBlocksForFeed } from '../lib/ask-classifier.js';
|
|
5
5
|
import { type FeedSessionSignal } from '../lib/feed-ranking.js';
|
|
6
|
-
export declare const FEED_POST_HELP = "\nExamples:\n # Title (subject) + body. Phone broadcasts put title first, body after a\n # blank line, then a \"Sent from agent/session on host\" footer.\n agents feed post --title \"CHANGELOG pushed\" \"Watching CI and mac-mini E2E\"\n agents feed post --title \"Cover ready\" \"render at ./out/cover.png\" --attach ./out/cover.png\n agents feed post --title \"Ready for review\" \"PR opened, waiting on prix-cloud\" --json\n\n # Worth interrupting someone over - reaches sinks gated on minLevel: important:\n agents feed post --title \"npm token expired\" \"Cannot publish the release\" --level important\n\n # Also raise a local desktop banner on THIS machine (same notifier as run\n # --notify), on top of any configured broadcast - useful when you are at the box:\n agents feed post --title \"Build green\" \"all checks passed\" --notify\n\n # Stuck: opens a needs-you block and always broadcasts at important:\n agents feed post --title \"Force-push denied\" \"git-guard blocked PR #1749\" --blocked\n agents feed post --title \"Publish or wait?\" \"npm publish now or after review\" --blocked --option publish --option wait\n agents feed post --title \"Delete preview env?\" \"stale preview still running\" --blocked --default \"leave it\"\n\n # Exhaust self-serve FIRST. A block is for what you genuinely cannot do:\n # a credential only the user holds, a decision only they can make, an\n # approval only they can give. Not \"should I do the obvious next step?\".\n\n # Outside a run, pass the session explicitly:\n agents feed post --title \"Manual note\" \"context for the next agent\" --session 00998b0e-2d15-4d2f-a58b-974a886c9b47\n\nIdentity (session, agent, host, runtime, pid, launchId) is stamped automatically\nand rides the phone footer of feed.broadcast {message}. Domain facts (tickets,\nPRs) are not CLI flags - the ticket is joined from the session index at post\ntime. No em-dashes in title/body - they are scrubbed on the way out.\n\nConfigure where a post is mirrored under feed.broadcast in agents.yaml - see\ndocs/observability.md. A channel sink may set message: with placeholders such\nas {message} and {ticket}; a missing placeholder skips that sink. A milestone is always recorded, but it does not reach\nthe owner when the sink has minLevel: important. Add --level important for a\nphone-worthy successful update. Use --blocked only when work cannot continue.\nWith no sinks configured, an important post or a block reaches the owner through\nyour account (agents auth login); a block is a needs_you event
|
|
6
|
+
export declare const FEED_POST_HELP = "\nExamples:\n # Title (subject) + body. Phone broadcasts put title first, body after a\n # blank line, then a \"Sent from agent/session on host\" footer.\n agents feed post --title \"CHANGELOG pushed\" \"Watching CI and mac-mini E2E\"\n agents feed post --title \"Cover ready\" \"render at ./out/cover.png\" --attach ./out/cover.png\n agents feed post --title \"Ready for review\" \"PR opened, waiting on prix-cloud\" --json\n\n # Worth interrupting someone over - reaches sinks gated on minLevel: important:\n agents feed post --title \"npm token expired\" \"Cannot publish the release\" --level important\n\n # Also raise a local desktop banner on THIS machine (same notifier as run\n # --notify), on top of any configured broadcast - useful when you are at the box:\n agents feed post --title \"Build green\" \"all checks passed\" --notify\n\n # Stuck: opens a needs-you block and always broadcasts at important:\n agents feed post --title \"Force-push denied\" \"git-guard blocked PR #1749\" --blocked\n agents feed post --title \"Publish or wait?\" \"npm publish now or after review\" --blocked --option publish --option wait\n agents feed post --title \"Delete preview env?\" \"stale preview still running\" --blocked --default \"leave it\"\n\n # Exhaust self-serve FIRST. A block is for what you genuinely cannot do:\n # a credential only the user holds, a decision only they can make, an\n # approval only they can give. Not \"should I do the obvious next step?\".\n\n # Outside a run, pass the session explicitly:\n agents feed post --title \"Manual note\" \"context for the next agent\" --session 00998b0e-2d15-4d2f-a58b-974a886c9b47\n\nIdentity (session, agent, host, runtime, pid, launchId) is stamped automatically\nand rides the phone footer of feed.broadcast {message}. Domain facts (tickets,\nPRs) are not CLI flags - the ticket is joined from the session index at post\ntime. No em-dashes in title/body - they are scrubbed on the way out.\n\nConfigure where a post is mirrored under feed.broadcast in agents.yaml - see\ndocs/observability.md. A channel sink may set message: with placeholders such\nas {message} and {ticket}; a missing placeholder skips that sink. A milestone is always recorded, but it does not reach\nthe owner when the sink has minLevel: important. Add --level important for a\nphone-worthy successful update. Use --blocked only when work cannot continue.\nWith no sinks configured, an important post or a block reaches the owner through\nyour account (agents auth login); a block is a needs_you event. The account's\npreferences pick email, Slack or iMessage.\n";
|
|
7
7
|
export declare function formatFeedMastheadRight(blocks: OpenBlock[]): string;
|
|
8
8
|
export declare function formatFeedReplyHint(block: Pick<OpenBlock, 'host' | 'sessionId' | 'generation' | 'ts'>): string;
|
|
9
9
|
export declare function parseRemoteFeed(stdout: string, machine: string): OpenBlock[];
|
package/dist/commands/feed.js
CHANGED
|
@@ -62,8 +62,8 @@ as {message} and {ticket}; a missing placeholder skips that sink. A milestone is
|
|
|
62
62
|
the owner when the sink has minLevel: important. Add --level important for a
|
|
63
63
|
phone-worthy successful update. Use --blocked only when work cannot continue.
|
|
64
64
|
With no sinks configured, an important post or a block reaches the owner through
|
|
65
|
-
your account (agents auth login); a block is a needs_you event
|
|
66
|
-
|
|
65
|
+
your account (agents auth login); a block is a needs_you event. The account's
|
|
66
|
+
preferences pick email, Slack or iMessage.
|
|
67
67
|
`;
|
|
68
68
|
const FEED_NO_FANOUT_ENV = 'AGENTS_FEED_LOCAL';
|
|
69
69
|
export function formatFeedMastheadRight(blocks) {
|
|
@@ -217,7 +217,7 @@ function renderBlock(b, localHost, indent = '') {
|
|
|
217
217
|
}
|
|
218
218
|
if (b.needy) {
|
|
219
219
|
console.log(`${indent} ${chalk.yellow('needy:')} ${b.needy.askCountLastHour}/${b.needy.threshold} asks in the last hour`);
|
|
220
|
-
console.log(`${indent} ${chalk.dim(`inspect:
|
|
220
|
+
console.log(`${indent} ${chalk.dim(`inspect: sessions ${b.sessionId}`)}`);
|
|
221
221
|
}
|
|
222
222
|
if (!b.answer && !b.parkedAt && b.kind !== 'control') {
|
|
223
223
|
console.log(`${indent} ${chalk.dim(formatFeedReplyHint(b))}`);
|
package/dist/commands/focus.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type ActiveSession } from '../lib/session/active.js';
|
|
|
4
4
|
import { type SessionMeta } from '@phnx-labs/sessions-cli/reader';
|
|
5
5
|
export { looksLikeTmuxAlias, resolveTmuxAliasState, shouldAttachLocalTmuxAliasBeforeFleet, type TmuxAliasState } from '../lib/session/local-tmux-attach.js';
|
|
6
6
|
import { type LiveStatusFilter } from './ps-roster.js';
|
|
7
|
-
import { openSurfaces, type Backend } from '../lib/terminal/index.js';
|
|
7
|
+
import { openSurfaces, type Backend, type LaunchBackendChoice } from '../lib/terminal/index.js';
|
|
8
8
|
interface FocusOptions {
|
|
9
9
|
launchId?: string;
|
|
10
10
|
local?: boolean;
|
|
@@ -46,16 +46,13 @@ interface FocusOptions {
|
|
|
46
46
|
export declare function inheritFocusOptions(child: FocusOptions, parent?: Command): FocusOptions;
|
|
47
47
|
export declare function mergeFocusHosts(opts: FocusOptions): string[];
|
|
48
48
|
export declare function focusHeader(statuses: LiveStatusFilter[], hosts: string[]): string;
|
|
49
|
-
export declare function registerFocusCommand(program: Command
|
|
50
|
-
group?: 'sessions' | 'ps';
|
|
51
|
-
hidden?: boolean;
|
|
52
|
-
}): void;
|
|
49
|
+
export declare function registerFocusCommand(program: Command): void;
|
|
53
50
|
export declare function selectFallback(attachOnly: boolean | undefined): UnreachableFallback;
|
|
54
51
|
export declare function focusAction(id: string | undefined, opts: FocusOptions): Promise<void>;
|
|
55
52
|
export declare function isAttachableLiveSession(session: ActiveSession): boolean;
|
|
56
53
|
export declare function dedupeSessionsByLogicalId(rows: SessionMeta[], self?: string): SessionMeta[];
|
|
57
54
|
export declare function focusTargetForResolved(poolMatch: SessionMeta | undefined, resolved: SessionMeta): SessionMeta;
|
|
58
|
-
export declare function focusResolvedSession(meta: SessionMeta, liveById: Map<string, ActiveSession>, self: string, fallback: UnreachableFallback, attachOnly: boolean, reconnectReattach?: boolean): Promise<void>;
|
|
55
|
+
export declare function focusResolvedSession(meta: SessionMeta, liveById: Map<string, ActiveSession>, self: string, fallback: UnreachableFallback, attachOnly: boolean, reconnectReattach?: boolean, deps?: TakeoverDeps): Promise<void>;
|
|
59
56
|
export declare function focusSelectedSession(meta: SessionMeta, active: ActiveSession | undefined, self: string): Promise<void>;
|
|
60
57
|
type FocusSurfacePlan = {
|
|
61
58
|
kind: 'attach';
|
|
@@ -84,3 +81,11 @@ interface OpenFocusTabsDeps {
|
|
|
84
81
|
}
|
|
85
82
|
export declare function openFocusTabs(targets: ActiveSession[], self: string, deps?: OpenFocusTabsDeps): Promise<void>;
|
|
86
83
|
export declare function metaFromActive(s: ActiveSession): SessionMeta;
|
|
84
|
+
export declare function isLiveHeadless(s: ActiveSession): boolean;
|
|
85
|
+
export interface TakeoverDeps {
|
|
86
|
+
open?: OpenSurfacesFn;
|
|
87
|
+
choice?: LaunchBackendChoice | null;
|
|
88
|
+
interactive?: boolean;
|
|
89
|
+
meta?: SessionMeta;
|
|
90
|
+
}
|
|
91
|
+
export declare function resumeInTab(s: ActiveSession, remote: string | undefined, deps?: TakeoverDeps): Promise<void>;
|
package/dist/commands/focus.js
CHANGED
|
@@ -20,7 +20,9 @@ import { buildPreview } from './sessions-picker.js';
|
|
|
20
20
|
import { multiItemPicker } from '../lib/picker.js';
|
|
21
21
|
import { sessionRecoveryRunArgs } from '../lib/session/recovery.js';
|
|
22
22
|
import { shellQuote, assertValidSshTarget } from '../lib/ssh-exec.js';
|
|
23
|
-
import { openSurfaces, describeLaunch, currentContext,
|
|
23
|
+
import { openSurfaces, describeLaunch, currentContext, resolveLaunchBackend, describeBackendChoice, liveHostSamples, } from '../lib/terminal/index.js';
|
|
24
|
+
import { stopInteractive } from './detach.js';
|
|
25
|
+
import { localizeHome, localProjectFolder } from '../lib/project-root.js';
|
|
24
26
|
import { addressabilityRecoveryHint } from '../lib/terminal/resolve.js';
|
|
25
27
|
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
26
28
|
import { setHelpSections } from '../lib/help.js';
|
|
@@ -57,10 +59,9 @@ export function focusHeader(statuses, hosts) {
|
|
|
57
59
|
function statusWord(status) {
|
|
58
60
|
return status === 'orphaned' ? 'orphaned' : status;
|
|
59
61
|
}
|
|
60
|
-
export function registerFocusCommand(program
|
|
61
|
-
const group = opts.group ?? 'sessions';
|
|
62
|
+
export function registerFocusCommand(program) {
|
|
62
63
|
const cmd = program
|
|
63
|
-
.command('focus'
|
|
64
|
+
.command('focus')
|
|
64
65
|
.argument('[selector]', 'Session id/prefix, agent@version, or topic/path search')
|
|
65
66
|
.option('--launch-id <id>', 'Target the run by its launcher AGENT_LAUNCH_ID instead of a session id (resolved from this machine\'s hook records)')
|
|
66
67
|
.option('--local', 'Only this machine (skip the cross-host sweep)')
|
|
@@ -105,22 +106,22 @@ export function registerFocusCommand(program, opts = {}) {
|
|
|
105
106
|
setHelpSections(cmd, {
|
|
106
107
|
examples: `
|
|
107
108
|
# Focus a session directly (attach a living pane, otherwise recover it)
|
|
108
|
-
agents
|
|
109
|
+
agents ps focus a1b2c3d4
|
|
109
110
|
|
|
110
111
|
# Multi-select live sessions; each opens as a tab in this terminal
|
|
111
|
-
agents
|
|
112
|
+
agents ps focus
|
|
112
113
|
|
|
113
114
|
# Scope the picker to one device's orphaned sessions
|
|
114
|
-
agents
|
|
115
|
+
agents ps focus --orphan --device yosemite-s0
|
|
115
116
|
|
|
116
117
|
# Resolve latest on yosemite-s0, then pick from that version's sessions
|
|
117
|
-
agents
|
|
118
|
+
agents ps focus claude@latest --device yosemite-s0
|
|
118
119
|
|
|
119
120
|
# Attach only — refuse if nothing is joinable
|
|
120
|
-
agents
|
|
121
|
+
agents ps focus a1b2c3d4 --attach-only
|
|
121
122
|
|
|
122
123
|
# Pick from live sessions on this machine only
|
|
123
|
-
agents
|
|
124
|
+
agents ps focus --local
|
|
124
125
|
`,
|
|
125
126
|
notes: `
|
|
126
127
|
- space toggles a session, enter opens the selected set; a single check + enter opens just one.
|
|
@@ -152,7 +153,7 @@ export async function focusAction(id, opts) {
|
|
|
152
153
|
if (!resolved) {
|
|
153
154
|
console.error(chalk.red(`No session recorded for launch id ${opts.launchId} on ${machineId()}.`));
|
|
154
155
|
console.error(chalk.gray(' The run may have failed before its SessionStart hook fired.'));
|
|
155
|
-
console.error(chalk.gray(' Look for it: agents
|
|
156
|
+
console.error(chalk.gray(' Look for it: agents ps'));
|
|
156
157
|
process.exitCode = 1;
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
@@ -278,7 +279,7 @@ export async function focusAction(id, opts) {
|
|
|
278
279
|
}
|
|
279
280
|
if (activeById.size === 0) {
|
|
280
281
|
const scope = describeScope(statuses, hosts);
|
|
281
|
-
console.log(chalk.gray(`No live sessions to focus${scope}. To resume a past one: agents
|
|
282
|
+
console.log(chalk.gray(`No live sessions to focus${scope}. To resume a past one: agents run auto --resume`));
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
284
285
|
const header = focusHeader(statuses, hosts);
|
|
@@ -382,7 +383,7 @@ async function pickFocusCandidates(sessions, liveById, initialSearch) {
|
|
|
382
383
|
export function focusTargetForResolved(poolMatch, resolved) {
|
|
383
384
|
return poolMatch ?? resolved;
|
|
384
385
|
}
|
|
385
|
-
export async function focusResolvedSession(meta, liveById, self, fallback, attachOnly, reconnectReattach = false) {
|
|
386
|
+
export async function focusResolvedSession(meta, liveById, self, fallback, attachOnly, reconnectReattach = false, deps = {}) {
|
|
386
387
|
const active = liveById.get(meta.id);
|
|
387
388
|
if (active && isAttachableLiveSession(active)) {
|
|
388
389
|
await jumpTo(active, self, fallback, meta.id);
|
|
@@ -398,9 +399,13 @@ export async function focusResolvedSession(meta, liveById, self, fallback, attac
|
|
|
398
399
|
if (reconnectReattach) {
|
|
399
400
|
console.error(chalk.yellow(`\nWarning: ${meta.shortId}'s pane is gone (reboot, tmux crash, or agent exited).`));
|
|
400
401
|
console.error(chalk.gray(` Prior context is in the transcript — starting recovery.\n` +
|
|
401
|
-
` To see what happened: agents
|
|
402
|
+
` To see what happened: agents ps preview ${meta.shortId}`));
|
|
402
403
|
}
|
|
403
404
|
const remote = sessionProcessHost(meta, self);
|
|
405
|
+
if (!(deps.interactive ?? isInteractiveTerminal())) {
|
|
406
|
+
await resumeInTab(active ?? activeFromMeta(meta), remote, { ...deps, meta, interactive: false });
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
404
409
|
if (remote) {
|
|
405
410
|
console.log(chalk.gray(`Recovering ${meta.shortId} on ${remote}…`));
|
|
406
411
|
const rc = await runOnPeer(sessionRecoveryRunArgs(meta), remote, { tty: true, sessionId: meta.id });
|
|
@@ -532,7 +537,19 @@ export async function openFocusTabs(targets, self, deps = {}) {
|
|
|
532
537
|
await jumpTo(openable[0].s, self, selectFallback(deps.attachOnly));
|
|
533
538
|
return;
|
|
534
539
|
}
|
|
535
|
-
const
|
|
540
|
+
const ready = [];
|
|
541
|
+
const stopped = new Set();
|
|
542
|
+
for (const p of openable) {
|
|
543
|
+
if (p.plan.kind === 'resume' && p.s.sessionId && isLiveHeadless(p.s)) {
|
|
544
|
+
if (!(await stopHeadlessCopy(p.s, p.s.sessionId, sessionProcessHost(p.s, self))))
|
|
545
|
+
continue;
|
|
546
|
+
stopped.add(p.s);
|
|
547
|
+
}
|
|
548
|
+
ready.push(p);
|
|
549
|
+
}
|
|
550
|
+
if (ready.length === 0)
|
|
551
|
+
return;
|
|
552
|
+
const results = await open(ready.map((p) => ({
|
|
536
553
|
cwd: cwdFor(p.s, byId),
|
|
537
554
|
project: cwdFor(p.s, byId),
|
|
538
555
|
command: p.plan.command,
|
|
@@ -540,12 +557,12 @@ export async function openFocusTabs(targets, self, deps = {}) {
|
|
|
540
557
|
sessionId: p.s.sessionId || undefined,
|
|
541
558
|
})), { backend, packing: 'tabs' });
|
|
542
559
|
results.forEach((r, i) => {
|
|
543
|
-
const p =
|
|
560
|
+
const p = ready[i];
|
|
544
561
|
const line = describeLaunch(r, { verb: 'Opened', label: `${shortId(p.s)} (${p.plan.note})` });
|
|
545
562
|
if (r.ok)
|
|
546
563
|
console.log(line);
|
|
547
564
|
else {
|
|
548
|
-
console.error(chalk.red(line));
|
|
565
|
+
console.error(chalk.red(stopped.has(p.s) ? `${line} ${stoppedNotice(p.s.sessionId)}` : line));
|
|
549
566
|
process.exitCode = 1;
|
|
550
567
|
}
|
|
551
568
|
});
|
|
@@ -576,38 +593,81 @@ async function richMetaById(id) {
|
|
|
576
593
|
return undefined;
|
|
577
594
|
}
|
|
578
595
|
}
|
|
579
|
-
|
|
596
|
+
export function isLiveHeadless(s) {
|
|
597
|
+
return s.context === 'headless' && isRunningLiveSession(s);
|
|
598
|
+
}
|
|
599
|
+
async function stopHeadlessCopy(s, id, remote) {
|
|
600
|
+
if (!remote) {
|
|
601
|
+
console.log(chalk.gray(`${shortId(s)} is running headless (pid ${s.pid}); stopping it so the tab is its only writer.`));
|
|
602
|
+
await stopInteractive(s);
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
console.log(chalk.gray(`${shortId(s)} is running headless on ${remote}; stopping it there so the tab is its only writer.`));
|
|
606
|
+
const rc = await runOnPeer(['ps', 'stop', id, '--local'], remote);
|
|
607
|
+
if (rc === 'ok')
|
|
608
|
+
return true;
|
|
609
|
+
console.error(chalk.red(rc === 'failed'
|
|
610
|
+
? `agents ps stop ${shortId(s)} --local failed on ${remote}, so its headless run may still be live; no second copy was opened.`
|
|
611
|
+
: `Can't reach ${remote} to stop the headless ${shortId(s)}, so no second copy was opened.`));
|
|
612
|
+
process.exitCode = 1;
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
function stoppedNotice(id) {
|
|
616
|
+
return `The headless run was stopped; resume it with agents run auto --resume ${id}`;
|
|
617
|
+
}
|
|
618
|
+
export async function resumeInTab(s, remote, deps = {}) {
|
|
580
619
|
const id = s.sessionId ?? '';
|
|
581
620
|
if (!id) {
|
|
582
621
|
console.log(chalk.yellow('This session has no id to resume.'));
|
|
583
622
|
return;
|
|
584
623
|
}
|
|
585
|
-
|
|
586
|
-
|
|
624
|
+
const headless = isLiveHeadless(s);
|
|
625
|
+
const interactive = deps.interactive ?? isInteractiveTerminal();
|
|
626
|
+
if (remote && interactive) {
|
|
627
|
+
if (headless && !(await stopHeadlessCopy(s, id, remote)))
|
|
628
|
+
return;
|
|
629
|
+
console.log(chalk.gray(`${shortId(s)} has no live terminal on ${remote}; resuming it there over SSH…`));
|
|
587
630
|
const rc = await runOnPeer(sessionRecoveryRunArgs({ id }), remote, { tty: true, sessionId: id });
|
|
588
631
|
if (rc === 'no-target') {
|
|
589
632
|
console.log(chalk.red(`${remote} isn't reachable as a device. Try: agents devices sync`));
|
|
590
633
|
console.log(chalk.gray(` recovery must run on ${remote}, where the indexed session originated`));
|
|
634
|
+
process.exitCode = 1;
|
|
591
635
|
}
|
|
592
636
|
return;
|
|
593
637
|
}
|
|
594
|
-
const meta = (await richMetaById(id)) ?? metaFromActive(s);
|
|
595
|
-
const command = [...buildSessionRecoveryCommand(meta), '--quiet'];
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
|
|
638
|
+
const meta = deps.meta ?? (await richMetaById(id)) ?? metaFromActive(s);
|
|
639
|
+
const command = [...buildSessionRecoveryCommand(meta, !!remote), '--quiet'];
|
|
640
|
+
const recorded = meta.cwd ?? s.cwd;
|
|
641
|
+
const localCwd = recorded ? localizeHome(recorded) : undefined;
|
|
642
|
+
const cwd = localCwd && fs.existsSync(localCwd) ? localCwd : localProjectFolder(recorded) ?? process.cwd();
|
|
643
|
+
const project = localProjectFolder(cwd) ?? cwd;
|
|
644
|
+
const choice = deps.choice !== undefined ? deps.choice : resolveLaunchBackend(currentContext(), await liveHostSamples());
|
|
645
|
+
if (!choice) {
|
|
646
|
+
if (!interactive || remote) {
|
|
647
|
+
console.error(chalk.red(`No terminal this machine can drive to reopen ${shortId(s)}. Run: agents run auto --resume ${id}`));
|
|
648
|
+
process.exitCode = 1;
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (headless && !(await stopHeadlessCopy(s, id, undefined)))
|
|
652
|
+
return;
|
|
600
653
|
await resumeSessionInPlace(meta);
|
|
601
654
|
return;
|
|
602
655
|
}
|
|
603
|
-
|
|
604
|
-
|
|
656
|
+
if (headless && !(await stopHeadlessCopy(s, id, remote)))
|
|
657
|
+
return;
|
|
658
|
+
const what = headless ? 'resuming it' : 'resuming a copy';
|
|
659
|
+
const where = remote ? ` (it runs on ${remote})` : '';
|
|
660
|
+
console.log(chalk.gray(`${shortId(s)} has no live terminal to attach${where}; opening a new tab in ${describeBackendChoice(choice)} and ${what}.`));
|
|
661
|
+
const open = deps.open ?? openSurfaces;
|
|
662
|
+
const results = await open([{ cwd, project, command, agent: s.kind || undefined, sessionId: id }], { backend: choice.backend, packing: 'tabs' });
|
|
605
663
|
const line = describeLaunch(results[0], { verb: 'Resumed', label: shortId(s) });
|
|
606
664
|
if (results[0].ok)
|
|
607
665
|
console.log(line);
|
|
608
666
|
else {
|
|
609
|
-
console.error(chalk.red(line));
|
|
610
|
-
|
|
667
|
+
console.error(chalk.red(headless ? `${line} ${stoppedNotice(id)}` : line));
|
|
668
|
+
if (!headless)
|
|
669
|
+
console.error(chalk.gray(` Resume it in a terminal instead: agents run auto --resume ${meta.id}`));
|
|
611
670
|
process.exitCode = 1;
|
|
612
671
|
}
|
|
613
|
-
}
|
|
672
|
+
}
|
|
673
|
+
const resumeInNewTab = (s, remote) => resumeInTab(s, remote);
|
package/dist/commands/fork.d.ts
CHANGED
|
@@ -14,6 +14,5 @@ export interface ForkDeps {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export declare function runFork(sessionArg: string, options: ForkOptions, deps?: ForkDeps): Promise<void>;
|
|
17
|
-
export declare function registerSessionsForkCommand(sessionsCmd: Command): void;
|
|
18
17
|
export declare function registerForkCommand(program: Command): void;
|
|
19
18
|
export {};
|
package/dist/commands/fork.js
CHANGED
|
@@ -6,7 +6,7 @@ import { buildForkRecap, forkLabelFor } from '../lib/session/fork.js';
|
|
|
6
6
|
function defaultDeps() {
|
|
7
7
|
return {
|
|
8
8
|
runPreview: (sub) => {
|
|
9
|
-
const p = getCliLaunch(['
|
|
9
|
+
const p = getCliLaunch(['ps', 'preview', ...sub]);
|
|
10
10
|
const r = spawnSync(p.command, p.args, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'inherit'] });
|
|
11
11
|
return { status: r.status, stdout: r.stdout ?? '' };
|
|
12
12
|
},
|
|
@@ -20,16 +20,16 @@ function defaultDeps() {
|
|
|
20
20
|
const FORK_HELP = {
|
|
21
21
|
examples: `
|
|
22
22
|
# Fork a session by (partial) id — launches a same-harness sibling seeded with a recap
|
|
23
|
-
agents
|
|
23
|
+
agents fork 4f3a9c21
|
|
24
24
|
|
|
25
25
|
# Name the fork's session label
|
|
26
|
-
agents
|
|
26
|
+
agents fork 4f3a9c21 --name "try redis instead"
|
|
27
27
|
|
|
28
28
|
# Place the sibling on a fleet worker instead of here
|
|
29
|
-
agents
|
|
29
|
+
agents fork 4f3a9c21 --device auto
|
|
30
30
|
|
|
31
31
|
# Open the sibling in a fresh terminal tab where you work
|
|
32
|
-
agents
|
|
32
|
+
agents fork 4f3a9c21 --terminal
|
|
33
33
|
`,
|
|
34
34
|
notes: `
|
|
35
35
|
- 'resume' continues the SAME conversation; 'fork' launches a NEW same-harness
|
|
@@ -93,8 +93,8 @@ export async function runFork(sessionArg, options, deps = defaultDeps()) {
|
|
|
93
93
|
const child = deps.launch(runArgs);
|
|
94
94
|
process.exitCode = child.status ?? 0;
|
|
95
95
|
}
|
|
96
|
-
export function
|
|
97
|
-
const cmd =
|
|
96
|
+
export function registerForkCommand(program) {
|
|
97
|
+
const cmd = program
|
|
98
98
|
.command('fork <session>')
|
|
99
99
|
.description('Branch a session into a new same-harness sibling, seeded with a recap so it continues the work. The original is untouched.')
|
|
100
100
|
.option('--name <label>', 'Session label for the fork (default: "fork of <original>")')
|
|
@@ -103,12 +103,3 @@ export function registerSessionsForkCommand(sessionsCmd) {
|
|
|
103
103
|
setHelpSections(cmd, FORK_HELP);
|
|
104
104
|
cmd.action((session, options) => runFork(session, options));
|
|
105
105
|
}
|
|
106
|
-
export function registerForkCommand(program) {
|
|
107
|
-
const cmd = program
|
|
108
|
-
.command('fork <session>', { hidden: true })
|
|
109
|
-
.description('Alias for `agents sessions fork` — branch a session into a new same-harness sibling.')
|
|
110
|
-
.option('--name <label>', 'Session label for the fork (default: "fork of <original>")')
|
|
111
|
-
.option('--device <host>', 'Place the sibling on a fleet device (name or "auto"); defaults to here')
|
|
112
|
-
.option('--terminal [backend]', 'Open the sibling in a real terminal tab (iterm | ghostty | terminal | tmux | vscodium-agent) instead of in-place');
|
|
113
|
-
cmd.action((session, options) => runFork(session, options));
|
|
114
|
-
}
|
|
@@ -71,7 +71,7 @@ async function askKeySource(io, draft, provider) {
|
|
|
71
71
|
message: `How should '${provider}' get its key?`,
|
|
72
72
|
choices: [
|
|
73
73
|
{ name: 'Type a key now', value: TYPE_NOW },
|
|
74
|
-
{ name: 'Use an existing
|
|
74
|
+
{ name: 'Use an existing secrets bundle', value: FROM_SECRETS },
|
|
75
75
|
],
|
|
76
76
|
})
|
|
77
77
|
: TYPE_NOW;
|
package/dist/commands/harness.js
CHANGED
|
@@ -391,7 +391,7 @@ Examples:
|
|
|
391
391
|
# Copy an existing harness and swap only the model
|
|
392
392
|
agents harness fork deepseek deepseek-chat --model deepseek/deepseek-chat-v3
|
|
393
393
|
|
|
394
|
-
# Attach an account whose credential came from
|
|
394
|
+
# Attach an account whose credential came from a secrets bundle
|
|
395
395
|
agents harness fork claude corp --model gpt-x --account corp
|
|
396
396
|
|
|
397
397
|
# No args, in an interactive terminal: walks through source, preset/model, name, key
|