@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
|
@@ -159,7 +159,7 @@ function renderReport(groups, dim, meta, actions, harnesses) {
|
|
|
159
159
|
out.push(chalk.bold('Insights') + chalk.gray(` ${scope} · ${meta.analyzed} of ${meta.scanned} sessions`));
|
|
160
160
|
if (groups.length === 0) {
|
|
161
161
|
out.push('');
|
|
162
|
-
out.push(chalk.gray(' No sessions in scope. Try a wider --since, or run `
|
|
162
|
+
out.push(chalk.gray(' No sessions in scope. Try a wider --since, or run `sessions --all` to index.'));
|
|
163
163
|
console.log(out.join('\n'));
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
@@ -236,7 +236,7 @@ function renderReport(groups, dim, meta, actions, harnesses) {
|
|
|
236
236
|
out.push(` ${padToWidth(action.priority, 7)} ${padToWidth(action.category, 11)} ` +
|
|
237
237
|
`${String(action.evidenceCount).padStart(8)} ${padToWidth(action.sampleSessionIds.join(', '), 25)} ${action.action}`);
|
|
238
238
|
}
|
|
239
|
-
out.push(chalk.gray(' drill into a sample session: agents
|
|
239
|
+
out.push(chalk.gray(' drill into a sample session: agents trace <id>'));
|
|
240
240
|
}
|
|
241
241
|
out.push('');
|
|
242
242
|
out.push(chalk.bold('What you changed'));
|
|
@@ -472,7 +472,7 @@ function configureInsightsCommand(cmd) {
|
|
|
472
472
|
agents insights --account "Turing Labs" --all
|
|
473
473
|
|
|
474
474
|
# Machine-readable, for a dashboard or a slash command
|
|
475
|
-
agents
|
|
475
|
+
agents insights --agent claude --agent codex --json
|
|
476
476
|
|
|
477
477
|
# Add a written read on what to change
|
|
478
478
|
agents insights --narrative
|
|
@@ -489,7 +489,6 @@ function configureInsightsCommand(cmd) {
|
|
|
489
489
|
The behavioural report parses in-scope transcripts once and caches facets; later runs
|
|
490
490
|
re-read only files that changed. \`--refresh\` forces a full re-read.
|
|
491
491
|
|
|
492
|
-
\`agents insights\` is the top-level alias of \`agents sessions insights\`.
|
|
493
492
|
Repeat \`--agent\` to compare several harnesses in one report.
|
|
494
493
|
|
|
495
494
|
Everything except \`--narrative\` is local and makes no network calls.
|
|
@@ -504,6 +503,3 @@ export function registerInsightsCommand(program) {
|
|
|
504
503
|
registerPerfSubcommand(cmd);
|
|
505
504
|
registerInsightsResourcesCommand(cmd);
|
|
506
505
|
}
|
|
507
|
-
export function registerSessionsInsightsCommand(sessions) {
|
|
508
|
-
configureInsightsCommand(sessions.command('insights'));
|
|
509
|
-
}
|
package/dist/commands/open.js
CHANGED
|
@@ -5,7 +5,7 @@ export function registerOpenCommand(program) {
|
|
|
5
5
|
const callback = program
|
|
6
6
|
.command('_callback [url]', { hidden: true })
|
|
7
7
|
.alias('open')
|
|
8
|
-
.description('OS callback that resumes a session from an agents:// deep link (machine-only; humans use `agents
|
|
8
|
+
.description('OS callback that resumes a session from an agents:// deep link (machine-only; humans use `agents run auto --resume <id>`).')
|
|
9
9
|
.action(async (url) => {
|
|
10
10
|
if (!url) {
|
|
11
11
|
callback.help();
|
package/dist/commands/output.js
CHANGED
|
@@ -330,7 +330,7 @@ function renderSingle(payload, scenario) {
|
|
|
330
330
|
out.push(...headerLines(payload, scenario));
|
|
331
331
|
out.push('');
|
|
332
332
|
if (payload.burn.sessionCount === 0) {
|
|
333
|
-
out.push(chalk.gray('No sessions with cost data found. Run `
|
|
333
|
+
out.push(chalk.gray('No sessions with cost data found. Run `sessions --all` to index, then retry.'));
|
|
334
334
|
console.log(out.join('\n'));
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
@@ -15,7 +15,7 @@ export interface AddProfileOptions {
|
|
|
15
15
|
fromSecrets?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Copy a value from an `
|
|
18
|
+
* Copy a value from an `secrets` bundle into a profile's own keychain
|
|
19
19
|
* item — a one-time copy, not a live link. `spec` is `<bundle>` or
|
|
20
20
|
* `<bundle>:<key>`; the key is required only when the bundle has more than one.
|
|
21
21
|
*
|
|
@@ -48,7 +48,7 @@ export async function ensureProviderToken(provider, signupUrl, fromStdin) {
|
|
|
48
48
|
console.log(chalk.green(`Stored in keychain: ${item}`));
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Copy a value from an `
|
|
51
|
+
* Copy a value from an `secrets` bundle into a profile's own keychain
|
|
52
52
|
* item — a one-time copy, not a live link. `spec` is `<bundle>` or
|
|
53
53
|
* `<bundle>:<key>`; the key is required only when the bundle has more than one.
|
|
54
54
|
*
|
|
@@ -95,7 +95,7 @@ export async function applyFromSecrets(profile, spec, explicitAuthProvider, opts
|
|
|
95
95
|
catch (err) {
|
|
96
96
|
if (!isSecretsClientError(err, 'NOT_FOUND'))
|
|
97
97
|
throw err;
|
|
98
|
-
throw new Error(`Secrets bundle '${bundleName}' not found. List bundles with '
|
|
98
|
+
throw new Error(`Secrets bundle '${bundleName}' not found. List bundles with 'secrets list'.`);
|
|
99
99
|
}
|
|
100
100
|
const keys = Object.keys(bundle.vars);
|
|
101
101
|
const key = requestedKey ?? (keys.length === 1 ? keys[0] : undefined);
|
|
@@ -63,12 +63,13 @@ export function registerProjectTodoCommands(projects) {
|
|
|
63
63
|
});
|
|
64
64
|
const listCmd = todo
|
|
65
65
|
.command('list')
|
|
66
|
-
.description(`Your open quick to-dos and anything assigned to you due today or overdue (at most ${TODO_LIST_LIMIT}).`)
|
|
66
|
+
.description(`Your open quick to-dos and anything assigned to you due today or overdue, or one project's open issues (at most ${TODO_LIST_LIMIT}).`)
|
|
67
|
+
.option('--project <name>', "List this project's open issues instead: an agents project or a Linear project name")
|
|
67
68
|
.option('--json', 'Machine-readable result')
|
|
68
69
|
.action(async (opts) => {
|
|
69
70
|
let listed;
|
|
70
71
|
try {
|
|
71
|
-
listed = await listQuickTodos(new Date());
|
|
72
|
+
listed = await listQuickTodos(new Date(), { project: opts.project, defs: listProjectDefs() });
|
|
72
73
|
}
|
|
73
74
|
catch (err) {
|
|
74
75
|
const error = linearFailure(err);
|
|
@@ -83,7 +84,7 @@ export function registerProjectTodoCommands(projects) {
|
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
86
|
if (listed.todos.length === 0)
|
|
86
|
-
console.log('Nothing to do: no open quick to-dos, nothing due.');
|
|
87
|
+
console.log(opts.project ? `Nothing open in ${opts.project}.` : 'Nothing to do: no open quick to-dos, nothing due.');
|
|
87
88
|
for (const t of listed.todos)
|
|
88
89
|
console.log(todoLine(t));
|
|
89
90
|
if (listed.total > listed.todos.length)
|
|
@@ -93,11 +94,15 @@ export function registerProjectTodoCommands(projects) {
|
|
|
93
94
|
examples: `
|
|
94
95
|
agents projects todo list
|
|
95
96
|
agents projects todo list --json
|
|
97
|
+
agents projects todo list --project rush --json
|
|
96
98
|
`,
|
|
97
99
|
notes: `
|
|
98
100
|
One linear tasks read of your open issues. Due ones come first (earliest due),
|
|
99
|
-
then the newest quick to-dos. --
|
|
100
|
-
project
|
|
101
|
+
then the newest quick to-dos. --project lists every open issue in that
|
|
102
|
+
project instead (anyone's, any cycle), due ones first, then the newest.
|
|
103
|
+
total is the full count; todos holds at most ${TODO_LIST_LIMIT}. --json: { todos:
|
|
104
|
+
[{ identifier, url, title, project, due, priority, state, createdAt, quick }],
|
|
105
|
+
total, error }.
|
|
101
106
|
`,
|
|
102
107
|
});
|
|
103
108
|
todo
|
|
@@ -324,7 +324,7 @@ function renderCard(def, r, remote, fleet, linear, nowMs = Date.now(), milestone
|
|
|
324
324
|
warnings.push({
|
|
325
325
|
severity: crashed >= 10 ? 'critical' : 'continue',
|
|
326
326
|
text: `${crashed} crashed session${crashed === 1 ? '' : 's'} on this project`,
|
|
327
|
-
remediation: 'inspect with agents
|
|
327
|
+
remediation: 'inspect with agents ps --status crashed / clean up stuck worktrees',
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
for (const line of formatProjectWarnings(warnings))
|
package/dist/commands/prune.js
CHANGED
|
@@ -106,7 +106,7 @@ async function runSessionsPrune(options) {
|
|
|
106
106
|
console.log(chalk.gray('Session prune flags are accepted for compatibility but do not delete data.'));
|
|
107
107
|
}
|
|
108
108
|
console.log(chalk.yellow('Session history is durable. agents-cli does not hard-delete session records.'));
|
|
109
|
-
console.log(chalk.gray('Browse sessions with:
|
|
109
|
+
console.log(chalk.gray('Browse sessions with: sessions'));
|
|
110
110
|
}
|
|
111
111
|
async function runRunsPrune(options) {
|
|
112
112
|
const keep = options.keep ? parseInt(options.keep, 10) : 10;
|
package/dist/commands/ps.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
2
|
import { type LiveStatusFilter, type LiveStatusFlags } from './ps-roster.js';
|
|
3
|
+
import type { ActiveSession } from '../lib/session/active.js';
|
|
3
4
|
export declare const PS_STATUSES: readonly LiveStatusFilter[];
|
|
4
5
|
export declare function statusFlags(values: string[] | undefined): LiveStatusFlags;
|
|
5
6
|
export declare function deviceScope(devices: string[] | undefined): string[] | undefined;
|
|
6
7
|
export declare function registerPsCommand(program: Command): void;
|
|
7
|
-
|
|
8
|
-
export declare function renderSessionPreview(query: string, scope: {
|
|
8
|
+
type PreviewScope = {
|
|
9
9
|
agent?: string;
|
|
10
10
|
project?: string;
|
|
11
11
|
local?: boolean;
|
|
@@ -13,4 +13,9 @@ export declare function renderSessionPreview(query: string, scope: {
|
|
|
13
13
|
json?: boolean;
|
|
14
14
|
refresh?: boolean;
|
|
15
15
|
revision?: string;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
|
+
type PreviewJson = Record<string, unknown>;
|
|
18
|
+
export declare function previewJsonFor(query: string, scope: PreviewScope, live: Promise<Map<string, ActiveSession>>): Promise<PreviewJson>;
|
|
19
|
+
export declare function renderSessionPreviews(queries: string[], scope: PreviewScope, read?: typeof previewJsonFor): Promise<void>;
|
|
20
|
+
export declare function renderSessionPreview(query: string, scope: PreviewScope): Promise<void>;
|
|
21
|
+
export {};
|
package/dist/commands/ps.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
3
|
import { setHelpSections } from '../lib/help.js';
|
|
3
4
|
import { indexActiveBySessionId, runLiveRoster } from './ps-roster.js';
|
|
4
|
-
import { buildPreview,
|
|
5
|
+
import { buildPreview, transcriptOnPeerOf } from './sessions-picker.js';
|
|
6
|
+
import { loadSessionPreviewDigest } from '../lib/session/preview-digest.js';
|
|
5
7
|
import { isBookmarked } from '../lib/session/bookmarks.js';
|
|
6
8
|
import { discoverSessions, isCompleteSessionId } from '../lib/session/discover.js';
|
|
7
9
|
import { buildSessionDetailBlock, formatLiveStatusHeadline, notFoundByIdMessage, sessionTranscriptStamp } from '../lib/session/presentation.js';
|
|
8
|
-
import { runOnPeer, shouldIncludeLocal } from '../lib/session/remote-list.js';
|
|
9
|
-
import { applyScopeFilters, metadataResolveOutcome, resolveSessionMetadataValue, resolveSessionQuery, selectorAllowsEarlyExit } from '../lib/session/selection.js';
|
|
10
|
+
import { fetchPeerPreviewEnvelope, runOnPeer, shouldIncludeLocal } from '../lib/session/remote-list.js';
|
|
11
|
+
import { applyScopeFilters, computeLocalMetadataMatches, metadataResolveOutcome, resolveSessionMetadataValue, resolveSessionQuery, selectorAllowsEarlyExit, serializeResolvedSessionsJson } from '../lib/session/selection.js';
|
|
12
|
+
import { NO_FANOUT_ENV } from '../lib/session/remote-active.js';
|
|
10
13
|
import { loadLocalActiveSessions } from '../lib/session/session-cache.js';
|
|
11
14
|
import { machineId } from '../lib/session/sync/config.js';
|
|
12
15
|
import { registerSessionsStopCommand } from './sessions-stop.js';
|
|
13
16
|
import { registerFocusCommand } from './focus.js';
|
|
14
17
|
import { registerDetachCommand } from './detach.js';
|
|
15
18
|
import { registerSessionsMigrateCommand, registerSessionsMigrationsCommand } from './sessions-migrate.js';
|
|
19
|
+
import { registerSessionsWatchCommand } from './sessions-watch.js';
|
|
16
20
|
export const PS_STATUSES = [
|
|
17
21
|
'working',
|
|
18
22
|
'idle',
|
|
@@ -50,7 +54,7 @@ export function registerPsCommand(program) {
|
|
|
50
54
|
.option('--local', 'Only this machine; skip the fleet fan-out')
|
|
51
55
|
.option('-D, --device <target...>', 'Only these devices (alias from `agents devices`, user@host, or `all`; repeatable)')
|
|
52
56
|
.option('--status <state...>', `Only these live states: ${PS_STATUSES.join(', ')} (repeatable or comma-separated)`)
|
|
53
|
-
.option('--bookmarks', 'Only bookmarked sessions (bookmark one with `
|
|
57
|
+
.option('--bookmarks', 'Only bookmarked sessions (bookmark one with `sessions bookmark <id>`)')
|
|
54
58
|
.option('--routines, --routine [name]', 'Only routine-run sessions; pass a name to narrow to one routine (fuzzy name matching)')
|
|
55
59
|
.option('--no-interactive', 'Print the roster instead of opening the picker on a TTY');
|
|
56
60
|
setHelpSections(ps, {
|
|
@@ -79,12 +83,15 @@ export function registerPsCommand(program) {
|
|
|
79
83
|
|
|
80
84
|
# Where migrated sessions went
|
|
81
85
|
agents ps migrations
|
|
86
|
+
|
|
87
|
+
# Stream live and recoverable session rows for a long-lived UI
|
|
88
|
+
agents ps watch --json
|
|
82
89
|
`,
|
|
83
90
|
notes: `
|
|
84
91
|
- On a TTY with no --status, ps opens the session picker filtered to running
|
|
85
92
|
sessions: r toggles that filter, f focuses, enter resumes, y copies the command.
|
|
86
93
|
- Type into a running agent with: agents send --channel session --to <id> --text "continue"
|
|
87
|
-
- Resume an ended session with: agents run --resume <id>
|
|
94
|
+
- Resume an ended session with: agents run auto --resume <id>
|
|
88
95
|
- A session on another device is stopped, detached, or focused there over SSH.
|
|
89
96
|
- Put -D and --status after the verb or after the roster flags, never before a
|
|
90
97
|
verb: they take several values, so 'ps -D box stop <id>' reads 'stop' as a device.
|
|
@@ -110,18 +117,57 @@ export function registerPsCommand(program) {
|
|
|
110
117
|
routine: opts.routine,
|
|
111
118
|
});
|
|
112
119
|
});
|
|
113
|
-
registerSessionsStopCommand(ps
|
|
114
|
-
registerFocusCommand(ps
|
|
115
|
-
registerDetachCommand(ps
|
|
116
|
-
registerSessionsMigrateCommand(ps
|
|
117
|
-
registerSessionsMigrationsCommand(ps
|
|
118
|
-
registerSessionPreviewCommand(ps
|
|
120
|
+
registerSessionsStopCommand(ps);
|
|
121
|
+
registerFocusCommand(ps);
|
|
122
|
+
registerDetachCommand(ps);
|
|
123
|
+
registerSessionsMigrateCommand(ps);
|
|
124
|
+
registerSessionsMigrationsCommand(ps);
|
|
125
|
+
registerSessionPreviewCommand(ps);
|
|
126
|
+
registerSessionsWatchCommand(ps);
|
|
127
|
+
registerPeerResolveCommand(ps);
|
|
119
128
|
}
|
|
120
|
-
|
|
129
|
+
// Fleet protocol: a peer answers another box's selector or launch-id lookup from its own index.
|
|
130
|
+
function registerPeerResolveCommand(ps) {
|
|
131
|
+
ps.command('resolve', { hidden: true })
|
|
132
|
+
.argument('[selector]')
|
|
133
|
+
.option('--launch-id <id>')
|
|
134
|
+
.option('-a, --agent <agent>')
|
|
135
|
+
.option('-p, --project <name>')
|
|
136
|
+
.option('--json')
|
|
137
|
+
.option('--local')
|
|
138
|
+
.action(async (selector, _options, invoked) => {
|
|
139
|
+
const opts = invoked.optsWithGlobals();
|
|
140
|
+
if (!opts.json) {
|
|
141
|
+
console.error(chalk.red('ps resolve requires --json.'));
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
if (opts.launchId !== undefined) {
|
|
145
|
+
const launchId = opts.launchId.trim();
|
|
146
|
+
if (!launchId)
|
|
147
|
+
throw new Error('--launch-id requires a non-empty launch id.');
|
|
148
|
+
const { loadHookSessionIndex } = await import('../lib/session/hook-sessions.js');
|
|
149
|
+
const record = loadHookSessionIndex().byLaunchId.get(launchId);
|
|
150
|
+
process.stdout.write(JSON.stringify({ launchId, sessionId: record?.session_id ?? null }) + '\n');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (process.env[NO_FANOUT_ENV] !== '1') {
|
|
154
|
+
console.error(chalk.red('ps resolve is an internal fleet protocol.'));
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
const trimmed = selector?.trim();
|
|
158
|
+
if (!trimmed) {
|
|
159
|
+
console.error(chalk.red('ps resolve requires a non-empty selector.'));
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
const matches = await computeLocalMetadataMatches(trimmed, { agent: opts.agent, project: opts.project, local: true });
|
|
163
|
+
process.stdout.write(serializeResolvedSessionsJson(matches));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function registerSessionPreviewCommand(parent) {
|
|
121
167
|
const previewCmd = parent
|
|
122
168
|
.command('preview')
|
|
123
|
-
.argument('<id
|
|
124
|
-
.description('Show
|
|
169
|
+
.argument('<id...>', 'Full session IDs or displayed 8-character short IDs')
|
|
170
|
+
.description('Show rich session cards without rendering the full transcripts')
|
|
125
171
|
.option('-a, --agent <agent>', 'Narrow the ID to one agent type/version')
|
|
126
172
|
.option('-p, --project <name>', 'Narrow the ID to one project')
|
|
127
173
|
.option('--local', 'Only this machine; do not resolve the ID across the fleet')
|
|
@@ -131,30 +177,35 @@ export function registerSessionPreviewCommand(parent, group) {
|
|
|
131
177
|
.option('--revision <cursor>', 'Opaque caller-owned activity cursor (any stable value YOU track, e.g. your own feed\'s lastActivityMs) -- passing the SAME value as your last call confirms nothing changed and serves the cache with zero SSH indefinitely; a different value fetches once, still subject to backoff unless --refresh is also set (full ID + single --device only)');
|
|
132
178
|
setHelpSections(previewCmd, {
|
|
133
179
|
examples: `
|
|
134
|
-
# Preview by the 8-character ID shown in agents
|
|
135
|
-
agents
|
|
180
|
+
# Preview by the 8-character ID shown in agents ps
|
|
181
|
+
agents ps preview 407b8dd5
|
|
136
182
|
|
|
137
183
|
# A full UUID resolves on the first device that owns it
|
|
138
|
-
agents
|
|
184
|
+
agents ps preview c70ecdea-6210-4039-9845-246a3a7a9942
|
|
139
185
|
|
|
140
186
|
# Stay on this machine or restrict the authoritative lookup to one peer
|
|
141
|
-
agents
|
|
142
|
-
agents
|
|
187
|
+
agents ps preview 407b8dd5 --local
|
|
188
|
+
agents ps preview 407b8dd5 --device zion
|
|
143
189
|
|
|
144
190
|
# Full ID + one --device: durable-cached fast path (PHNX-3999); force a fresh fetch
|
|
145
|
-
agents
|
|
191
|
+
agents ps preview c70ecdea-6210-4039-9845-246a3a7a9942 --device zion --json --refresh
|
|
192
|
+
|
|
193
|
+
# Several cards in one call: a JSON array in argument order
|
|
194
|
+
agents ps preview 407b8dd5 c70ecdea --json
|
|
146
195
|
`,
|
|
147
196
|
notes: `
|
|
148
197
|
- Full UUIDs are globally unique and may stop the fleet lookup at the first exact hit.
|
|
149
198
|
- Short IDs wait for every selected device so ambiguity is never hidden.
|
|
150
199
|
- Active status is refreshed through the bounded live-state TTL; transcript-derived details use the durable session index.
|
|
151
|
-
- A full UUID with exactly one --device and --json is served from a local durable cache (~45s fresh window); the JSON envelope's "cache" field reports fresh/stale/offline state. --refresh forces one bounded re-fetch
|
|
200
|
+
- A full UUID with exactly one --device and --json is served from a local durable cache (~45s fresh window); the JSON envelope's "cache" field reports fresh/stale/offline state. --refresh forces one bounded re-fetch.
|
|
201
|
+
- With several IDs, --json prints one array in argument order; each element is the single-ID envelope plus "query", and an ID that does not resolve is an element with "error" set. The exit code is 1 only when no ID resolved.
|
|
202
|
+
- Put -D after the verb: 'ps -D box preview <id>' reads 'preview' as a device.
|
|
152
203
|
`,
|
|
153
204
|
});
|
|
154
|
-
previewCmd.action(async (
|
|
205
|
+
previewCmd.action(async (ids) => {
|
|
155
206
|
const options = previewCmd.optsWithGlobals();
|
|
156
207
|
const hosts = [...(options.host ?? []), ...(options.device ?? [])];
|
|
157
|
-
|
|
208
|
+
const scope = {
|
|
158
209
|
agent: options.agent,
|
|
159
210
|
project: options.project,
|
|
160
211
|
local: options.local,
|
|
@@ -162,29 +213,37 @@ export function registerSessionPreviewCommand(parent, group) {
|
|
|
162
213
|
json: options.json,
|
|
163
214
|
refresh: options.refresh,
|
|
164
215
|
revision: options.revision,
|
|
165
|
-
}
|
|
216
|
+
};
|
|
217
|
+
if (ids.length === 1)
|
|
218
|
+
await renderSessionPreview(ids[0], scope);
|
|
219
|
+
else
|
|
220
|
+
await renderSessionPreviews(ids, scope);
|
|
166
221
|
});
|
|
167
222
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
223
|
+
function previewErrorJson(message) {
|
|
224
|
+
return { schemaVersion: 1, session: null, active: null, preview: null, error: message, details: null };
|
|
225
|
+
}
|
|
226
|
+
async function remoteCachedPreviewJson(query, scope) {
|
|
227
|
+
if (!scope.json || scope.local || scope.hosts?.length !== 1
|
|
228
|
+
|| scope.hosts[0] === machineId() || !isCompleteSessionId(query.trim()))
|
|
229
|
+
return undefined;
|
|
230
|
+
const { getRemoteSessionPreview } = await import('../lib/session/remote-preview-cache.js');
|
|
231
|
+
const result = await getRemoteSessionPreview(query.trim(), scope.hosts[0], {
|
|
232
|
+
refresh: scope.refresh,
|
|
233
|
+
revision: scope.revision,
|
|
234
|
+
});
|
|
235
|
+
const envelope = result.envelope;
|
|
236
|
+
return {
|
|
237
|
+
schemaVersion: 1,
|
|
238
|
+
session: envelope?.session ?? null,
|
|
239
|
+
active: result.cache.source === 'live' ? (envelope?.active ?? null) : null,
|
|
240
|
+
preview: envelope?.preview ?? null,
|
|
241
|
+
error: envelope?.error ?? (envelope ? null : result.cache.reason),
|
|
242
|
+
details: envelope?.details ?? null,
|
|
243
|
+
cache: result.cache,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
async function resolvePreviewSession(query, scope) {
|
|
188
247
|
let outcome = await resolveSessionMetadataValue(query, scope);
|
|
189
248
|
if (outcome.kind !== 'resolved'
|
|
190
249
|
&& (!scope.hosts?.length || shouldIncludeLocal(scope.hosts, machineId()))) {
|
|
@@ -201,91 +260,160 @@ export async function renderSessionPreview(query, scope) {
|
|
|
201
260
|
}
|
|
202
261
|
if (outcome.kind === 'partial') {
|
|
203
262
|
const offline = outcome.failedPeers;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
263
|
+
return { errorLines: [
|
|
264
|
+
chalk.yellow(`Warning: ${offline.length} device(s) unreachable, not checked: ${offline.join(', ')}`),
|
|
265
|
+
chalk.red(`No session matching "${query}" on any reachable device (${offline.length} unreachable, not checked).`),
|
|
266
|
+
chalk.gray(' If it lives on an offline box, wake it (agents devices) or run there: agents ssh <device>'),
|
|
267
|
+
] };
|
|
209
268
|
}
|
|
210
|
-
if (outcome.kind === 'not-found')
|
|
211
|
-
notFoundByIdMessage(query)
|
|
212
|
-
|
|
269
|
+
if (outcome.kind === 'not-found')
|
|
270
|
+
return { errorLines: notFoundByIdMessage(query) };
|
|
271
|
+
if (outcome.kind === 'ambiguous') {
|
|
272
|
+
return { errorLines: [
|
|
273
|
+
chalk.red(`Multiple sessions match "${query}" across the fleet:`),
|
|
274
|
+
...outcome.candidates.map((candidate) => {
|
|
275
|
+
const match = candidate.hits[0].session;
|
|
276
|
+
const machines = candidate.hits.map(hit => hit.machine).join(', ');
|
|
277
|
+
return chalk.cyan(` ${match.shortId} ${match.id}`) + chalk.gray(` ${machines} ${match.agent}${match.version ? ` ${match.version}` : ''}`);
|
|
278
|
+
}),
|
|
279
|
+
chalk.gray('Pass the full session ID to narrow it down.'),
|
|
280
|
+
] };
|
|
281
|
+
}
|
|
282
|
+
return { session: outcome.session };
|
|
283
|
+
}
|
|
284
|
+
function localPreviewJson(session, live) {
|
|
285
|
+
const sourceStamp = sessionTranscriptStamp(session);
|
|
286
|
+
const { digest, error, events } = loadSessionPreviewDigest(session);
|
|
287
|
+
return {
|
|
288
|
+
schemaVersion: 1,
|
|
289
|
+
session: {
|
|
290
|
+
id: session.id,
|
|
291
|
+
shortId: session.shortId,
|
|
292
|
+
agent: session.agent,
|
|
293
|
+
version: session.version,
|
|
294
|
+
model: session.model,
|
|
295
|
+
account: session.account,
|
|
296
|
+
machine: session.machine ?? machineId(),
|
|
297
|
+
cwd: session.cwd,
|
|
298
|
+
project: session.project,
|
|
299
|
+
gitBranch: session.gitBranch,
|
|
300
|
+
createdAt: session.timestamp,
|
|
301
|
+
lastActivity: session.lastActivity,
|
|
302
|
+
durationMs: session.durationMs,
|
|
303
|
+
messageCount: session.messageCount,
|
|
304
|
+
tokenCount: session.tokenCount,
|
|
305
|
+
costUsd: session.costUsd,
|
|
306
|
+
label: session.label,
|
|
307
|
+
topic: session.topic,
|
|
308
|
+
ticketId: session.ticketId,
|
|
309
|
+
prUrl: session.prUrl,
|
|
310
|
+
},
|
|
311
|
+
active: live ? {
|
|
312
|
+
status: live.status,
|
|
313
|
+
activity: live.activity,
|
|
314
|
+
awaitingReason: live.awaitingReason,
|
|
315
|
+
lastActivityMs: live.lastActivityMs,
|
|
316
|
+
startedAtMs: live.startedAtMs,
|
|
317
|
+
pid: live.pid,
|
|
318
|
+
host: live.host,
|
|
319
|
+
} : null,
|
|
320
|
+
preview: digest ?? null,
|
|
321
|
+
error: error ?? null,
|
|
322
|
+
details: buildSessionDetailBlock(session, digest, events, sourceStamp),
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async function liveSessionsById() {
|
|
326
|
+
try {
|
|
327
|
+
return indexActiveBySessionId((await loadLocalActiveSessions()).sessions);
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return new Map();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
export async function previewJsonFor(query, scope, live) {
|
|
334
|
+
const cached = await remoteCachedPreviewJson(query, scope);
|
|
335
|
+
if (cached)
|
|
336
|
+
return cached;
|
|
337
|
+
const resolved = await resolvePreviewSession(query, scope);
|
|
338
|
+
if ('errorLines' in resolved)
|
|
339
|
+
return previewErrorJson(resolved.errorLines.map(line => stripVTControlCharacters(line).trim()).join(' '));
|
|
340
|
+
const { session } = resolved;
|
|
341
|
+
const transcriptPeer = transcriptOnPeerOf(session);
|
|
342
|
+
if (transcriptPeer) {
|
|
343
|
+
const fetched = await fetchPeerPreviewEnvelope(session.id, transcriptPeer);
|
|
344
|
+
if (fetched.ok && fetched.envelope && typeof fetched.envelope === 'object' && !Array.isArray(fetched.envelope))
|
|
345
|
+
return fetched.envelope;
|
|
346
|
+
return previewErrorJson(`Session ${session.id} is on ${transcriptPeer}, but that device did not answer (${fetched.ok ? 'invalid-json' : fetched.reason}).`);
|
|
347
|
+
}
|
|
348
|
+
return localPreviewJson(session, (await live).get(session.id));
|
|
349
|
+
}
|
|
350
|
+
export async function renderSessionPreviews(queries, scope, read = previewJsonFor) {
|
|
351
|
+
if (!scope.json) {
|
|
352
|
+
const shown = [];
|
|
353
|
+
for (const [index, query] of queries.entries()) {
|
|
354
|
+
if (index > 0)
|
|
355
|
+
console.log('');
|
|
356
|
+
try {
|
|
357
|
+
shown.push(await printSessionPreview(query, scope));
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
console.error(chalk.red(`${query}: ${err.message}`));
|
|
361
|
+
shown.push(false);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (!shown.some(Boolean))
|
|
365
|
+
process.exitCode = 1;
|
|
213
366
|
return;
|
|
214
367
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const machines = candidate.hits.map(hit => hit.machine).join(', ');
|
|
220
|
-
console.error(chalk.cyan(` ${match.shortId} ${match.id}`) + chalk.gray(` ${machines} ${match.agent}${match.version ? ` ${match.version}` : ''}`));
|
|
368
|
+
const live = liveSessionsById();
|
|
369
|
+
const results = await Promise.all(queries.map(async (query) => {
|
|
370
|
+
try {
|
|
371
|
+
return { query, ...await read(query, scope, live) };
|
|
221
372
|
}
|
|
222
|
-
|
|
373
|
+
catch (err) {
|
|
374
|
+
return { query, ...previewErrorJson(err.message) };
|
|
375
|
+
}
|
|
376
|
+
}));
|
|
377
|
+
console.log(JSON.stringify(results));
|
|
378
|
+
if (results.every(result => result.session === null))
|
|
223
379
|
process.exitCode = 1;
|
|
224
|
-
|
|
380
|
+
}
|
|
381
|
+
export async function renderSessionPreview(query, scope) {
|
|
382
|
+
if (!await printSessionPreview(query, scope))
|
|
383
|
+
process.exitCode = 1;
|
|
384
|
+
}
|
|
385
|
+
async function printSessionPreview(query, scope) {
|
|
386
|
+
const cached = await remoteCachedPreviewJson(query, scope);
|
|
387
|
+
if (cached) {
|
|
388
|
+
console.log(JSON.stringify(cached));
|
|
389
|
+
return true;
|
|
225
390
|
}
|
|
226
|
-
const
|
|
391
|
+
const resolved = await resolvePreviewSession(query, scope);
|
|
392
|
+
if ('errorLines' in resolved) {
|
|
393
|
+
resolved.errorLines.forEach(line => console.error(line));
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
const { session } = resolved;
|
|
227
397
|
const transcriptPeer = transcriptOnPeerOf(session);
|
|
228
398
|
if (transcriptPeer) {
|
|
229
|
-
const args = ['
|
|
399
|
+
const args = ['ps', 'preview', session.id, '--local'];
|
|
230
400
|
if (scope.json)
|
|
231
401
|
args.push('--json');
|
|
232
402
|
const rendered = await runOnPeer(args, transcriptPeer);
|
|
233
403
|
if (rendered === 'no-target') {
|
|
234
404
|
console.error(chalk.red(`Session ${session.id} is on ${transcriptPeer}, but that device is not reachable.`));
|
|
235
|
-
|
|
405
|
+
return false;
|
|
236
406
|
}
|
|
237
|
-
return;
|
|
407
|
+
return true;
|
|
238
408
|
}
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
const loaded = await loadLocalActiveSessions();
|
|
242
|
-
live = indexActiveBySessionId(loaded.sessions).get(session.id);
|
|
243
|
-
}
|
|
244
|
-
catch { }
|
|
409
|
+
const live = (await liveSessionsById()).get(session.id);
|
|
245
410
|
if (scope.json) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
console.log(JSON.stringify({
|
|
249
|
-
schemaVersion: 1,
|
|
250
|
-
session: {
|
|
251
|
-
id: session.id,
|
|
252
|
-
shortId: session.shortId,
|
|
253
|
-
agent: session.agent,
|
|
254
|
-
version: session.version,
|
|
255
|
-
model: session.model,
|
|
256
|
-
account: session.account,
|
|
257
|
-
machine: session.machine ?? machineId(),
|
|
258
|
-
cwd: session.cwd,
|
|
259
|
-
project: session.project,
|
|
260
|
-
gitBranch: session.gitBranch,
|
|
261
|
-
createdAt: session.timestamp,
|
|
262
|
-
lastActivity: session.lastActivity,
|
|
263
|
-
durationMs: session.durationMs,
|
|
264
|
-
messageCount: session.messageCount,
|
|
265
|
-
tokenCount: session.tokenCount,
|
|
266
|
-
costUsd: session.costUsd,
|
|
267
|
-
label: session.label,
|
|
268
|
-
topic: session.topic,
|
|
269
|
-
ticketId: session.ticketId,
|
|
270
|
-
prUrl: session.prUrl,
|
|
271
|
-
},
|
|
272
|
-
active: live ? {
|
|
273
|
-
status: live.status,
|
|
274
|
-
activity: live.activity,
|
|
275
|
-
awaitingReason: live.awaitingReason,
|
|
276
|
-
lastActivityMs: live.lastActivityMs,
|
|
277
|
-
startedAtMs: live.startedAtMs,
|
|
278
|
-
pid: live.pid,
|
|
279
|
-
host: live.host,
|
|
280
|
-
} : null,
|
|
281
|
-
preview: digest ?? null,
|
|
282
|
-
error: error ?? null,
|
|
283
|
-
details: buildSessionDetailBlock(session, digest, events, sourceStamp),
|
|
284
|
-
}));
|
|
285
|
-
return;
|
|
411
|
+
console.log(JSON.stringify(localPreviewJson(session, live)));
|
|
412
|
+
return true;
|
|
286
413
|
}
|
|
287
414
|
const headline = formatLiveStatusHeadline(live, isBookmarked(session.id));
|
|
288
415
|
if (headline)
|
|
289
416
|
console.log(headline);
|
|
290
417
|
console.log(buildPreview(session));
|
|
418
|
+
return true;
|
|
291
419
|
}
|
|
@@ -1997,7 +1997,7 @@ export function registerRoutinesCommands(program) {
|
|
|
1997
1997
|
});
|
|
1998
1998
|
routinesCmd
|
|
1999
1999
|
.command('stop')
|
|
2000
|
-
.description('Stop only the scheduler service. The shared daemon and its
|
|
2000
|
+
.description('Stop only the scheduler service. The shared daemon and its other services (usage sync, session index, watchdog, and the rest) stay running.')
|
|
2001
2001
|
.action(() => {
|
|
2002
2002
|
const daemonRunning = isDaemonRunning();
|
|
2003
2003
|
setDaemonServiceEnabled('scheduler', false);
|
package/dist/commands/send.js
CHANGED
|
@@ -64,7 +64,7 @@ const SHARED_NOTES = `
|
|
|
64
64
|
|
|
65
65
|
--to owner posts one notification to your account (agents auth login). The
|
|
66
66
|
account's preferences, edited in the console Settings page, decide which of
|
|
67
|
-
email, Slack and iMessage it reaches;
|
|
67
|
+
email, Slack and iMessage it reaches; dedup applies there. A box
|
|
68
68
|
with no Phoenix session or worker device token fails loud instead. --to owner
|
|
69
69
|
takes no --channel, --thread or --attach.
|
|
70
70
|
|