@phnx-labs/agents-cli 1.22.121 → 1.22.123
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 +316 -0
- package/README.md +53 -53
- package/dist/bootstrap.js +22 -17
- package/dist/cli/command-registry.d.ts +0 -1
- package/dist/cli/command-registry.js +2 -12
- package/dist/commands/auth.js +13 -4
- package/dist/commands/browser.js +3 -4
- package/dist/commands/cloud-transcripts.d.ts +7 -0
- package/dist/commands/cloud-transcripts.js +100 -0
- package/dist/commands/cloud.js +5 -0
- package/dist/commands/computer.d.ts +0 -12
- package/dist/commands/computer.js +14 -124
- package/dist/commands/config.js +5 -4
- package/dist/commands/daemon-index.d.ts +2 -0
- package/dist/commands/daemon-index.js +44 -0
- package/dist/commands/daemon.js +13 -8
- package/dist/commands/doctor.js +3 -4
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.js +35 -7
- package/dist/commands/feed-watch.js +12 -0
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +7 -4
- package/dist/commands/insights.js +3 -1
- package/dist/commands/inspect.js +1 -1
- package/dist/commands/logs.js +2 -1
- package/dist/commands/mailboxes.js +1 -1
- package/dist/commands/models.js +1 -1
- package/dist/commands/projects.js +3 -3
- package/dist/commands/prune.js +6 -28
- package/dist/commands/ps-roster.d.ts +0 -1
- package/dist/commands/ps-roster.js +2 -21
- package/dist/commands/ps.js +13 -1
- package/dist/commands/recordings.d.ts +2 -0
- package/dist/commands/recordings.js +117 -0
- package/dist/commands/routines.js +1 -1
- package/dist/commands/secrets-passthrough.js +3 -3
- package/dist/commands/send.js +33 -20
- package/dist/commands/sessions-backfill.d.ts +1 -0
- package/dist/commands/sessions-backfill.js +48 -13
- package/dist/commands/sessions-migrate.d.ts +1 -1
- package/dist/commands/sessions-migrate.js +11 -10
- package/dist/commands/sessions-optimize.d.ts +1 -0
- package/dist/commands/sessions-optimize.js +7 -4
- package/dist/commands/sessions-resume.js +8 -1
- package/dist/commands/sessions-stats.d.ts +2 -0
- package/dist/commands/sessions-stats.js +24 -7
- package/dist/commands/sessions.d.ts +5 -11
- package/dist/commands/sessions.js +8 -236
- package/dist/commands/setup-computer.js +1 -2
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/sync.js +101 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/testdata/feed-hub.js +11 -0
- package/dist/commands/trash.d.ts +0 -1
- package/dist/commands/trash.js +74 -10
- package/dist/lib/accounting/usage-sync.js +7 -0
- package/dist/lib/agent-modes.d.ts +1 -1
- package/dist/lib/agent-modes.js +11 -5
- package/dist/lib/auth-mint.d.ts +4 -0
- package/dist/lib/auth-mint.js +6 -4
- package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
- package/dist/lib/browser/native-history.test-fixture.js +43 -0
- package/dist/lib/browser/paths.d.ts +5 -0
- package/dist/lib/browser/paths.js +7 -1
- package/dist/lib/browser/sessions-list.d.ts +28 -1
- package/dist/lib/browser/sessions-list.js +137 -25
- package/dist/lib/channels/providers/rush.d.ts +2 -1
- package/dist/lib/channels/providers/rush.js +2 -2
- package/dist/lib/channels/providers/session.d.ts +1 -0
- package/dist/lib/channels/providers/session.js +23 -12
- package/dist/lib/channels/registry.d.ts +9 -2
- package/dist/lib/channels/send.d.ts +5 -10
- package/dist/lib/channels/send.js +88 -50
- package/dist/lib/cloud/rush.d.ts +6 -0
- package/dist/lib/cloud/rush.js +18 -3
- package/dist/lib/computer-client.d.ts +19 -0
- package/dist/lib/computer-client.js +104 -0
- package/dist/lib/config-keys.d.ts +5 -1
- package/dist/lib/config-keys.js +14 -11
- package/dist/lib/daemon/auth-sync-service.js +13 -0
- package/dist/lib/daemon/daemon.js +20 -23
- package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
- package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
- package/dist/lib/daemon-services.d.ts +2 -1
- package/dist/lib/daemon-services.js +17 -10
- package/dist/lib/daemon-webhooks.d.ts +1 -1
- package/dist/lib/daemon-webhooks.js +1 -1
- package/dist/lib/device-config.d.ts +4 -1
- package/dist/lib/device-config.js +58 -8
- package/dist/lib/devices/doctor-findings.d.ts +2 -3
- package/dist/lib/devices/doctor-findings.js +10 -19
- package/dist/lib/event-provenance.d.ts +1 -0
- package/dist/lib/event-provenance.js +2 -0
- package/dist/lib/exec.d.ts +1 -0
- package/dist/lib/exec.js +20 -15
- package/dist/lib/feed/pr-status.d.ts +5 -1
- package/dist/lib/feed/pr-status.js +44 -3
- package/dist/lib/feed/tool-activity.js +9 -6
- package/dist/lib/feed/tools.d.ts +4 -1
- package/dist/lib/feed/tools.js +8 -11
- package/dist/lib/feed-broadcast.d.ts +5 -3
- package/dist/lib/feed-broadcast.js +47 -36
- package/dist/lib/fleet-shared-state.d.ts +5 -0
- package/dist/lib/fleet-shared-state.js +8 -0
- package/dist/lib/github/project-prs.d.ts +4 -1
- package/dist/lib/github/project-prs.js +20 -7
- package/dist/lib/help.d.ts +1 -0
- package/dist/lib/help.js +8 -0
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/passthrough.js +5 -9
- package/dist/lib/hosts/remote-cmd.d.ts +2 -7
- package/dist/lib/hosts/remote-cmd.js +14 -22
- package/dist/lib/hosts/routing-flag.d.ts +22 -0
- package/dist/lib/hosts/routing-flag.js +127 -14
- package/dist/lib/identity/index.d.ts +22 -0
- package/dist/lib/identity/index.js +3 -0
- package/dist/lib/installations/migrate.d.ts +7 -0
- package/dist/lib/installations/migrate.js +99 -88
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/launch-identity.d.ts +6 -1
- package/dist/lib/launch-identity.js +12 -2
- package/dist/lib/menubar/install-menubar.d.ts +1 -0
- package/dist/lib/menubar/install-menubar.js +8 -5
- package/dist/lib/menubar/snapshot.js +2 -3
- package/dist/lib/notify.d.ts +7 -14
- package/dist/lib/notify.js +29 -75
- package/dist/lib/owner-message.d.ts +4 -6
- package/dist/lib/owner-message.js +12 -11
- package/dist/lib/owner-notify-tokens.d.ts +49 -0
- package/dist/lib/owner-notify-tokens.js +214 -0
- package/dist/lib/owner-notify.d.ts +75 -0
- package/dist/lib/owner-notify.js +144 -0
- package/dist/lib/plugins/plugins.d.ts +7 -1
- package/dist/lib/plugins/plugins.js +26 -5
- package/dist/lib/pr-land-detach.js +2 -2
- package/dist/lib/recordings/config.d.ts +11 -0
- package/dist/lib/recordings/config.js +54 -0
- package/dist/lib/recordings/identity.d.ts +12 -0
- package/dist/lib/recordings/identity.js +57 -0
- package/dist/lib/recordings/ledger.d.ts +16 -0
- package/dist/lib/recordings/ledger.js +141 -0
- package/dist/lib/recordings/model.d.ts +29 -0
- package/dist/lib/recordings/model.js +28 -0
- package/dist/lib/recordings/pipeline.d.ts +44 -0
- package/dist/lib/recordings/pipeline.js +272 -0
- package/dist/lib/recordings/process.d.ts +17 -0
- package/dist/lib/recordings/process.js +94 -0
- package/dist/lib/recordings/service.d.ts +15 -0
- package/dist/lib/recordings/service.js +45 -0
- package/dist/lib/recordings/settle.d.ts +21 -0
- package/dist/lib/recordings/settle.js +92 -0
- package/dist/lib/recordings/transcode.d.ts +13 -0
- package/dist/lib/recordings/transcode.js +44 -0
- package/dist/lib/refresh.js +4 -1
- package/dist/lib/reminders.d.ts +0 -1
- package/dist/lib/reminders.js +1 -1
- package/dist/lib/reserved-stores.d.ts +3 -0
- package/dist/lib/reserved-stores.js +13 -0
- package/dist/lib/routine-notify-owner.d.ts +3 -23
- package/dist/lib/routine-notify-owner.js +26 -107
- package/dist/lib/rush-api.d.ts +1 -0
- package/dist/lib/rush-api.js +1 -0
- package/dist/lib/scheduling/routines.d.ts +1 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/session/active.d.ts +18 -2
- package/dist/lib/session/active.js +47 -37
- package/dist/lib/session/cloud.js +18 -45
- package/dist/lib/session/db.d.ts +3 -1
- package/dist/lib/session/db.js +64 -32
- package/dist/lib/session/glance-files.d.ts +4 -3
- package/dist/lib/session/glance-files.js +31 -0
- package/dist/lib/session/inject-target.js +12 -2
- package/dist/lib/session/pid-registry.d.ts +2 -0
- package/dist/lib/session/pid-registry.js +6 -2
- package/dist/lib/session/presentation.d.ts +21 -0
- package/dist/lib/session/presentation.js +198 -0
- package/dist/lib/session/projection.js +9 -2
- package/dist/lib/sqlite.d.ts +3 -1
- package/dist/lib/sqlite.js +7 -3
- package/dist/lib/staleness/index.js +12 -0
- package/dist/lib/staleness/types.d.ts +5 -0
- package/dist/lib/standalone-tools.js +1 -1
- package/dist/lib/startup/command-registry.js +10 -5
- package/dist/lib/state.d.ts +2 -5
- package/dist/lib/state.js +3 -11
- package/dist/lib/sync-delete.d.ts +21 -0
- package/dist/lib/sync-delete.js +113 -0
- package/dist/lib/terminal/inject.js +1 -1
- package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
- package/dist/lib/testdata/owner-notify-api.js +102 -0
- package/dist/lib/trash.d.ts +14 -0
- package/dist/lib/trash.js +75 -0
- package/dist/lib/types.d.ts +0 -34
- package/package.json +1 -3
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -68
- package/dist/commands/humans.d.ts +0 -2
- package/dist/commands/humans.js +0 -83
- package/dist/commands/modes.d.ts +0 -2
- package/dist/commands/modes.js +0 -134
- package/dist/commands/monitors.d.ts +0 -2
- package/dist/commands/monitors.js +0 -1070
- package/dist/commands/reminders.d.ts +0 -2
- package/dist/commands/reminders.js +0 -49
- package/dist/lib/channels/owner-forward.d.ts +0 -25
- package/dist/lib/channels/owner-forward.js +0 -78
- package/dist/lib/channels/owner-sink.d.ts +0 -10
- package/dist/lib/channels/owner-sink.js +0 -26
- package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
- package/dist/lib/daemon/monitor-engine-service.js +0 -25
- package/dist/lib/humans.d.ts +0 -12
- package/dist/lib/humans.js +0 -64
- package/dist/lib/monitors/config.d.ts +0 -77
- package/dist/lib/monitors/config.js +0 -405
- package/dist/lib/monitors/dispatch.d.ts +0 -10
- package/dist/lib/monitors/dispatch.js +0 -72
- package/dist/lib/monitors/engine.d.ts +0 -45
- package/dist/lib/monitors/engine.js +0 -243
- package/dist/lib/monitors/fingerprint.d.ts +0 -3
- package/dist/lib/monitors/fingerprint.js +0 -43
- package/dist/lib/monitors/pid-watch.d.ts +0 -4
- package/dist/lib/monitors/pid-watch.js +0 -14
- package/dist/lib/monitors/remote.d.ts +0 -31
- package/dist/lib/monitors/remote.js +0 -63
- package/dist/lib/monitors/sources/command.d.ts +0 -4
- package/dist/lib/monitors/sources/command.js +0 -20
- package/dist/lib/monitors/sources/device.d.ts +0 -3
- package/dist/lib/monitors/sources/device.js +0 -31
- package/dist/lib/monitors/sources/failure.d.ts +0 -5
- package/dist/lib/monitors/sources/failure.js +0 -25
- package/dist/lib/monitors/sources/file.d.ts +0 -4
- package/dist/lib/monitors/sources/file.js +0 -46
- package/dist/lib/monitors/sources/http.d.ts +0 -3
- package/dist/lib/monitors/sources/http.js +0 -25
- package/dist/lib/monitors/sources/index.d.ts +0 -5
- package/dist/lib/monitors/sources/index.js +0 -22
- package/dist/lib/monitors/sources/poll.d.ts +0 -1
- package/dist/lib/monitors/sources/poll.js +0 -1
- package/dist/lib/monitors/sources/types.d.ts +0 -9
- package/dist/lib/monitors/sources/webhook.d.ts +0 -3
- package/dist/lib/monitors/sources/webhook.js +0 -3
- package/dist/lib/monitors/sources/ws.d.ts +0 -4
- package/dist/lib/monitors/sources/ws.js +0 -35
- package/dist/lib/monitors/state.d.ts +0 -51
- package/dist/lib/monitors/state.js +0 -221
- /package/dist/{lib/monitors/sources/types.js → commands/testdata/feed-hub.d.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { resolveArtifactsBin } from '../lib/artifacts-client.js';
|
|
4
|
+
import { setDaemonServiceEnabled } from '../lib/daemon-services.js';
|
|
5
|
+
import { assertDaemonEnabled } from '../lib/device-config.js';
|
|
6
|
+
import { setHelpSections } from '../lib/help.js';
|
|
7
|
+
import { resolveRecordingDirectory, writeRecordingDirectory } from '../lib/recordings/config.js';
|
|
8
|
+
import { RecordingLedger } from '../lib/recordings/ledger.js';
|
|
9
|
+
import { RecordingPipeline } from '../lib/recordings/pipeline.js';
|
|
10
|
+
import { candidateForFile } from '../lib/recordings/settle.js';
|
|
11
|
+
import { resolveFfmpegBin } from '../lib/recordings/transcode.js';
|
|
12
|
+
async function applyDaemonState(startIfStopped) {
|
|
13
|
+
const { ensureDaemonStarted, isDaemonRunning, signalDaemonReload } = await import('../lib/daemon/daemon.js');
|
|
14
|
+
if (isDaemonRunning()) {
|
|
15
|
+
if (!signalDaemonReload())
|
|
16
|
+
throw new Error('Could not signal the daemon to reload recording settings.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (startIfStopped && !ensureDaemonStarted()) {
|
|
20
|
+
throw new Error('The daemon did not start. Run `agents daemon doctor`, then retry.');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function registerRecordingsCommand(program) {
|
|
24
|
+
const command = program
|
|
25
|
+
.command('recordings')
|
|
26
|
+
.description('Publish finished CleanShot recordings as organization-only artifacts.');
|
|
27
|
+
setHelpSections(command, {
|
|
28
|
+
examples: `# Detect CleanShot's export folder and start the daemon-owned watcher
|
|
29
|
+
agents recordings watch
|
|
30
|
+
|
|
31
|
+
# Watch another folder instead
|
|
32
|
+
agents recordings watch --dir ~/Movies/CleanShot
|
|
33
|
+
|
|
34
|
+
# Inspect queued, failed, and published recordings
|
|
35
|
+
agents recordings list
|
|
36
|
+
|
|
37
|
+
# Publish one existing recording through the same pipeline
|
|
38
|
+
agents recordings upload ./demo.mov
|
|
39
|
+
|
|
40
|
+
# Stop watching; already published artifacts stay published
|
|
41
|
+
agents recordings unwatch`,
|
|
42
|
+
notes: `The watcher is opt-in and runs inside the agents daemon. A recording becomes
|
|
43
|
+
eligible after its size remains unchanged for 10 seconds. The original file is never
|
|
44
|
+
modified: ffmpeg creates a temporary 1080p/30fps upload copy, then artifacts publishes
|
|
45
|
+
it with organization-only visibility and no expiry.
|
|
46
|
+
|
|
47
|
+
Requires ffmpeg and the standalone artifacts CLI. Sign in to artifacts with an
|
|
48
|
+
organization email before files arrive; personal inbox identities are refused.`,
|
|
49
|
+
});
|
|
50
|
+
const watch = command.command('watch')
|
|
51
|
+
.description('Enable the daemon-owned CleanShot watcher and persist its folder.')
|
|
52
|
+
.option('--dir <path>', 'Recording folder (default: CleanShot exportPath on macOS)')
|
|
53
|
+
.action(async (options) => {
|
|
54
|
+
assertDaemonEnabled();
|
|
55
|
+
resolveFfmpegBin();
|
|
56
|
+
resolveArtifactsBin();
|
|
57
|
+
const directory = await resolveRecordingDirectory(options.dir);
|
|
58
|
+
await writeRecordingDirectory(directory);
|
|
59
|
+
setDaemonServiceEnabled('recordings', true);
|
|
60
|
+
await applyDaemonState(true);
|
|
61
|
+
console.log(chalk.green(`Watching recordings in ${directory}`));
|
|
62
|
+
});
|
|
63
|
+
setHelpSections(watch, {
|
|
64
|
+
examples: `agents recordings watch
|
|
65
|
+
agents recordings watch --dir ~/Movies/CleanShot`,
|
|
66
|
+
notes: 'Enables the recordings daemon service on this device. Re-running updates the watched folder.',
|
|
67
|
+
});
|
|
68
|
+
const unwatch = command.command('unwatch')
|
|
69
|
+
.description('Disable the recordings watcher on this device.')
|
|
70
|
+
.action(async () => {
|
|
71
|
+
setDaemonServiceEnabled('recordings', false);
|
|
72
|
+
await applyDaemonState(false);
|
|
73
|
+
console.log(chalk.green('Recording watcher disabled.'));
|
|
74
|
+
});
|
|
75
|
+
setHelpSections(unwatch, {
|
|
76
|
+
examples: 'agents recordings unwatch',
|
|
77
|
+
notes: 'Disables future discovery and cancels an upload currently owned by the watcher.',
|
|
78
|
+
});
|
|
79
|
+
const list = command.command('list')
|
|
80
|
+
.description('List the local recording ledger with upload status and URL.')
|
|
81
|
+
.option('--json', 'Emit ledger rows as JSON')
|
|
82
|
+
.action(async (options, invoked) => {
|
|
83
|
+
const rows = await new RecordingLedger().list();
|
|
84
|
+
if (options.json === true || invoked.optsWithGlobals().json === true) {
|
|
85
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (rows.length === 0) {
|
|
89
|
+
console.log(chalk.dim('No recordings have been discovered.'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
for (const row of rows) {
|
|
93
|
+
const status = row.status.padEnd(11);
|
|
94
|
+
console.log(`${status} ${path.basename(row.path)}${row.url ? `\n ${row.url}` : ''}`);
|
|
95
|
+
if (row.error)
|
|
96
|
+
console.log(chalk.yellow(` ${row.error}`));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
setHelpSections(list, {
|
|
100
|
+
examples: `agents recordings list
|
|
101
|
+
agents recordings list --json`,
|
|
102
|
+
notes: 'The ledger lives at ~/.agents/recordings/ledger.json and is reused after daemon restarts.',
|
|
103
|
+
});
|
|
104
|
+
const upload = command.command('upload <file>')
|
|
105
|
+
.description('Transcode and publish one recording through the watcher pipeline.')
|
|
106
|
+
.action(async (file) => {
|
|
107
|
+
resolveFfmpegBin();
|
|
108
|
+
const candidate = await candidateForFile(file);
|
|
109
|
+
const pipeline = new RecordingPipeline();
|
|
110
|
+
const row = await pipeline.upload(candidate);
|
|
111
|
+
console.log(row.url);
|
|
112
|
+
});
|
|
113
|
+
setHelpSections(upload, {
|
|
114
|
+
examples: 'agents recordings upload ./CleanShot\ 2026-10-08\ at\ 4.51.47\ AM.mov',
|
|
115
|
+
notes: 'Runs the same identity check, ffmpeg transcode, metadata, ledger, and artifacts upload path as the daemon.',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -857,7 +857,7 @@ export function registerRoutinesCommands(program) {
|
|
|
857
857
|
.option('--workflow <name>', 'Run an installed workflow (~/.agents/workflows/<name>) via `agents run`. Mutually exclusive with --agent.')
|
|
858
858
|
.option('--command <sh>', 'Run a plain shell command directly (no agent, no auth, no sandbox) — for deterministic housekeeping routines. Mutually exclusive with --agent and --workflow; --prompt is not used.')
|
|
859
859
|
.option('-p, --prompt <prompt>', 'Task instruction for the agent')
|
|
860
|
-
.option('-m, --mode <mode>', "Execution mode: plan (read-only), edit (can write files), auto (the default; more autonomous than edit, mechanism per-harness — see `agents
|
|
860
|
+
.option('-m, --mode <mode>', "Execution mode: plan (read-only), edit (can write files), auto (the default; more autonomous than edit, mechanism per-harness — see `agents run --help`), or skip (bypass all permission prompts). 'full' accepted as alias for skip.", 'auto')
|
|
861
861
|
.option('-e, --effort <effort>', 'Reasoning effort: low | medium | high | xhigh | max | auto', 'auto')
|
|
862
862
|
.option('-t, --timeout <timeout>', 'Kill the agent if it runs longer than this (e.g., 10m, 2h, 3d, 1w; max 1w)', '10m')
|
|
863
863
|
.option('--timezone <tz>', 'Interpret schedule in this timezone (e.g., America/Los_Angeles)')
|
|
@@ -5,6 +5,7 @@ import { flagValue } from '../lib/hosts/routing-flag.js';
|
|
|
5
5
|
import { stripRoutingFlags } from '../lib/hosts/remote-cmd.js';
|
|
6
6
|
import { resolveRemoteDevice } from '../lib/ssh-tunnel.js';
|
|
7
7
|
import { SECRETS_CLI_INSTALL_HINT } from '../lib/secrets-cli.js';
|
|
8
|
+
import { forwardsHelp } from '../lib/help.js';
|
|
8
9
|
export async function rewriteDeviceToHost(argv) {
|
|
9
10
|
if (flagValue(argv, 'host', 'H') !== undefined)
|
|
10
11
|
return argv;
|
|
@@ -16,12 +17,11 @@ export async function rewriteDeviceToHost(argv) {
|
|
|
16
17
|
return [...stripped, '--host', `ssh://${resolved.target}`];
|
|
17
18
|
}
|
|
18
19
|
export function registerSecretsCommands(program) {
|
|
19
|
-
program
|
|
20
|
+
forwardsHelp(program
|
|
20
21
|
.command('secrets')
|
|
21
22
|
.description('Named bundles of env variables — passthrough to the standalone `secrets` CLI. Run `agents secrets --help` (or `agents setup secrets`) for the full subcommand list.')
|
|
22
23
|
.allowUnknownOption()
|
|
23
24
|
.allowExcessArguments()
|
|
24
|
-
.helpOption(false)
|
|
25
25
|
.action(async () => {
|
|
26
26
|
let bin;
|
|
27
27
|
try {
|
|
@@ -48,5 +48,5 @@ export function registerSecretsCommands(program) {
|
|
|
48
48
|
process.exit(1);
|
|
49
49
|
}
|
|
50
50
|
process.exit(res.status ?? 1);
|
|
51
|
-
});
|
|
51
|
+
}));
|
|
52
52
|
}
|
package/dist/commands/send.js
CHANGED
|
@@ -3,12 +3,17 @@ import { die } from '../lib/format.js';
|
|
|
3
3
|
import { setHelpSections } from '../lib/help.js';
|
|
4
4
|
import { readMeta } from '../lib/state.js';
|
|
5
5
|
import { sendMessage, isOwnerAlias } from '../lib/channels/send.js';
|
|
6
|
-
import { ownerMessageComposer } from '../lib/owner-message.js';
|
|
7
6
|
import { fireTraceSyncInBackground } from '../lib/run-trace-sync.js';
|
|
8
7
|
function mergeAttachments(opts) {
|
|
9
8
|
const list = [...(opts.attach ?? []), ...(opts.attachment ?? [])];
|
|
10
9
|
return list.length ? list : undefined;
|
|
11
10
|
}
|
|
11
|
+
function terminalOptions(opts) {
|
|
12
|
+
const { pane, socket, enter, combined } = opts;
|
|
13
|
+
if (pane === undefined && socket === undefined && enter !== false && !combined)
|
|
14
|
+
return undefined;
|
|
15
|
+
return { pane, socket, enter, combined };
|
|
16
|
+
}
|
|
12
17
|
function toInput(positionalText, opts) {
|
|
13
18
|
return {
|
|
14
19
|
text: opts.text,
|
|
@@ -20,24 +25,15 @@ function toInput(positionalText, opts) {
|
|
|
20
25
|
urls: opts.url,
|
|
21
26
|
from: opts.from,
|
|
22
27
|
dryRun: opts.dryRun,
|
|
28
|
+
terminal: terminalOptions(opts),
|
|
23
29
|
};
|
|
24
30
|
}
|
|
25
31
|
async function runSend(positionalText, opts) {
|
|
26
32
|
const meta = readMeta();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const positional = (positionalText ?? '').trim();
|
|
32
|
-
const raw = flagged || positional;
|
|
33
|
-
const bothDiffer = flagged !== '' && positional !== '' && flagged !== positional;
|
|
34
|
-
if (raw && !bothDiffer) {
|
|
35
|
-
ownerCompose = ownerMessageComposer(raw);
|
|
36
|
-
input = { ...input, text: ownerCompose('plain'), positionalText: undefined };
|
|
37
|
-
fireTraceSyncInBackground({ disabled: Boolean(opts.dryRun) });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const out = await sendMessage(input, meta, ownerCompose);
|
|
33
|
+
const input = toInput(positionalText, opts);
|
|
34
|
+
if (isOwnerAlias(opts.to))
|
|
35
|
+
fireTraceSyncInBackground({ disabled: Boolean(opts.dryRun) });
|
|
36
|
+
const out = await sendMessage(input, meta);
|
|
41
37
|
if ('error' in out) {
|
|
42
38
|
die(out.error);
|
|
43
39
|
}
|
|
@@ -69,27 +65,41 @@ const SHARED_NOTES = `
|
|
|
69
65
|
message - CONTROL a running agent through its mailbox
|
|
70
66
|
send --channel session - type text + Enter into a running agent's terminal
|
|
71
67
|
|
|
72
|
-
--to owner
|
|
73
|
-
|
|
68
|
+
--to owner posts one notification to your account (agents auth login). The
|
|
69
|
+
account's preferences, edited in the console Settings page, decide which of
|
|
70
|
+
email, Slack and iMessage it reaches; quiet hours and dedup apply there. A box
|
|
71
|
+
with no Phoenix session or worker device token fails loud instead. --to owner
|
|
72
|
+
takes no --channel, --thread or --attach.
|
|
74
73
|
|
|
75
74
|
--channel session resolves --to (a session id or unique prefix, the
|
|
76
75
|
<shortid> of an ag-<agent>-<shortid> tmux name, or a %pane id) among the
|
|
77
76
|
live sessions on this machine; add --device <name> for a session on
|
|
78
77
|
another box. --attach, --thread and --from are refused on this channel.
|
|
79
78
|
--device runs the whole send on that box, for every channel, not just session.
|
|
79
|
+
|
|
80
|
+
The session channel types the text exactly as given: surrounding spaces and
|
|
81
|
+
newlines are kept, and --text "" presses Enter alone. By default the text
|
|
82
|
+
and Enter are two writes (what Ink TUIs such as Claude need); --combined
|
|
83
|
+
fuses them, --no-enter types without submitting. --pane (with an optional
|
|
84
|
+
--socket) addresses a tmux pane directly, without session lookup, and
|
|
85
|
+
replaces --to. These four options are refused on every other channel.
|
|
80
86
|
`;
|
|
81
87
|
export function registerSendCommand(program) {
|
|
82
88
|
const sendCmd = program
|
|
83
89
|
.command('send [text]')
|
|
84
90
|
.description('Deliver a message through a channel provider (imessage, slack, desktop, mailbox, session, …). Prefer --text/--to flags.')
|
|
85
91
|
.option('--text <text>', 'message body (preferred over positional text)')
|
|
86
|
-
.option('--to <target>', 'recipient id, or "owner" for
|
|
92
|
+
.option('--to <target>', 'recipient id, or "owner" for your account\'s notification preferences')
|
|
87
93
|
.option('--channel <name>', 'channel / provider (required unless --to owner)')
|
|
88
94
|
.option('--thread <id>', 'channel thread id / timestamp')
|
|
89
95
|
.option('--attach <path...>', 'local file attachment path (repeatable)')
|
|
90
96
|
.option('--attachment <path...>', 'alias of --attach')
|
|
91
97
|
.option('--url <url...>', 'link or remote media URL to include in the body (repeatable)')
|
|
92
98
|
.option('--from <who>', 'sender label (mailbox)')
|
|
99
|
+
.option('--pane <id>', 'session channel: tmux pane id to type into directly (e.g. %3), instead of --to')
|
|
100
|
+
.option('--socket <path>', 'session channel: tmux socket the --pane lives on')
|
|
101
|
+
.option('--no-enter', 'session channel: type the text without pressing Enter')
|
|
102
|
+
.option('--combined', 'session channel: send text + Enter as one write')
|
|
93
103
|
.option('--json', 'output JSON')
|
|
94
104
|
.option('--dry-run', 'resolve + build but do not send');
|
|
95
105
|
setHelpSections(sendCmd, {
|
|
@@ -104,8 +114,11 @@ export function registerSendCommand(program) {
|
|
|
104
114
|
agents send --channel session --to 4b2f1a9c --text "continue"
|
|
105
115
|
agents send --channel session --to 4b2f1a9c --text "continue" --device yosemite-s0
|
|
106
116
|
|
|
107
|
-
#
|
|
108
|
-
agents send --
|
|
117
|
+
# Type into a known tmux pane, without pressing Enter
|
|
118
|
+
agents send --channel session --pane %3 --socket /tmp/agents/tmux.sock --text "draft" --no-enter
|
|
119
|
+
|
|
120
|
+
# Attach a local file (explicit channels only)
|
|
121
|
+
agents send --channel slack --to "#eng" --text "screenshot" --attach ./out/cover.png
|
|
109
122
|
|
|
110
123
|
# Legacy positional text still works
|
|
111
124
|
agents send "hi" --channel desktop --to local
|
|
@@ -52,4 +52,5 @@ export interface TitleBackfillEnvelope {
|
|
|
52
52
|
}
|
|
53
53
|
export declare function runTitlesBackfill(options: TitleBackfillOptions): Promise<TitleBackfillEnvelope>;
|
|
54
54
|
export declare function registerSessionsBackfillCommand(sessionsCmd: Command): void;
|
|
55
|
+
export declare function registerBackfillCommand(parent: Command, invocation: string): void;
|
|
55
56
|
export {};
|
|
@@ -18,12 +18,20 @@ function parseAgent(value) {
|
|
|
18
18
|
throw new Error(`Unknown session agent: ${name}`);
|
|
19
19
|
return { agent: name, version: separator < 0 ? undefined : value.slice(separator + 1) || undefined };
|
|
20
20
|
}
|
|
21
|
+
function assertTimeFilters(options) {
|
|
22
|
+
for (const [flag, value] of [['--since', options.since], ['--until', options.until]]) {
|
|
23
|
+
if (value !== undefined && parseTimeFilter(value) === 0) {
|
|
24
|
+
throw new Error(`${flag} must be a duration like 7d or an ISO date (got "${value}")`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
21
28
|
function mergeHosts(options) {
|
|
22
29
|
const values = [options.host, options.device].flatMap((value) => value === undefined ? [] : Array.isArray(value) ? value : [value]);
|
|
23
30
|
return [...new Set(values)];
|
|
24
31
|
}
|
|
25
32
|
export async function backfillToolsLocal(options, oneBatch = false) {
|
|
26
33
|
const { agent, version } = parseAgent(options.agent);
|
|
34
|
+
assertTimeFilters(options);
|
|
27
35
|
const sessions = await discoverSessions({
|
|
28
36
|
agent,
|
|
29
37
|
version,
|
|
@@ -91,6 +99,8 @@ function peerArgs(options) {
|
|
|
91
99
|
return args;
|
|
92
100
|
}
|
|
93
101
|
export async function runToolsBackfill(options) {
|
|
102
|
+
parseAgent(options.agent);
|
|
103
|
+
assertTimeFilters(options);
|
|
94
104
|
const hosts = mergeHosts(options);
|
|
95
105
|
const includeLocal = options.local === true || hosts.length === 0;
|
|
96
106
|
const fanOut = options.local !== true && (options.fleet === true || hosts.length > 0);
|
|
@@ -142,6 +152,7 @@ export async function runToolsBackfill(options) {
|
|
|
142
152
|
}
|
|
143
153
|
async function runResourceBackfill(options) {
|
|
144
154
|
const { agent, version } = parseAgent(options.agent);
|
|
155
|
+
assertTimeFilters(options);
|
|
145
156
|
await discoverSessions({
|
|
146
157
|
agent,
|
|
147
158
|
version,
|
|
@@ -193,23 +204,39 @@ export async function runTitlesBackfill(options) {
|
|
|
193
204
|
};
|
|
194
205
|
}
|
|
195
206
|
export function registerSessionsBackfillCommand(sessionsCmd) {
|
|
196
|
-
|
|
197
|
-
|
|
207
|
+
registerBackfillCommand(sessionsCmd, 'agents sessions backfill');
|
|
208
|
+
}
|
|
209
|
+
export function registerBackfillCommand(parent, invocation) {
|
|
210
|
+
const backfill = parent.command('backfill').description('Populate derived session data explicitly.');
|
|
211
|
+
const tools = backfill
|
|
212
|
+
.command('tools')
|
|
213
|
+
.description('Parse historical tool calls once into the local SQLite index.')
|
|
214
|
+
.option('-a, --agent <agent>', 'Only this agent, optionally pinned to a version (e.g. codex, claude@2.1.45)')
|
|
215
|
+
.option('-p, --project <name>', 'Only sessions from this project')
|
|
216
|
+
.option('--since <time>', 'Only sessions newer than this (e.g. 2h, 7d, 4w, or an ISO date)')
|
|
217
|
+
.option('--until <time>', 'Only sessions older than this (ISO timestamp)')
|
|
218
|
+
.option('--unmanaged', 'Include sessions from your own ~/.<agent> installs')
|
|
219
|
+
.option('--team, --teams', 'Include team-spawned sessions')
|
|
220
|
+
.option('--local', 'Only this machine')
|
|
221
|
+
.option('--fleet', 'Every registered online compute device, each keeping its own index')
|
|
222
|
+
.option('-D, --device <target...>', 'Only these devices (repeatable); cannot be combined with --local')
|
|
223
|
+
.option('--json', 'Emit the machine-readable result');
|
|
198
224
|
setHelpSections(tools, {
|
|
199
225
|
examples: `
|
|
200
226
|
# Backfill this machine once; reruns resume and skip completed transcripts
|
|
201
|
-
|
|
227
|
+
${invocation} tools
|
|
202
228
|
|
|
203
229
|
# Backfill every online compute device, keeping each index local
|
|
204
|
-
|
|
230
|
+
${invocation} tools --fleet --json
|
|
205
231
|
|
|
206
232
|
# Narrow the historical work
|
|
207
|
-
|
|
233
|
+
${invocation} tools --agent codex --since 7d
|
|
208
234
|
`,
|
|
209
235
|
notes: `
|
|
210
236
|
- This command is the only historical transcript parse for tool indexing. Tool queries never trigger it.
|
|
211
237
|
- New and changed sessions are indexed during their normal incremental scan.
|
|
212
238
|
- No embeddings, vector database, network model, or semantic processing is used.
|
|
239
|
+
- Peers are driven with \`agents sessions backfill tools --local\`, which every released CLI understands.
|
|
213
240
|
`,
|
|
214
241
|
});
|
|
215
242
|
tools.action(async (_options, command) => {
|
|
@@ -237,21 +264,29 @@ export function registerSessionsBackfillCommand(sessionsCmd) {
|
|
|
237
264
|
process.exitCode = 1;
|
|
238
265
|
}
|
|
239
266
|
});
|
|
240
|
-
const resources = backfill
|
|
267
|
+
const resources = backfill
|
|
268
|
+
.command('resources')
|
|
269
|
+
.description('Derive historical skill/slash-command usage once into the local SQLite index.')
|
|
270
|
+
.option('-a, --agent <agent>', 'Only this agent, optionally pinned to a version (e.g. claude, codex@0.116.0)')
|
|
271
|
+
.option('-p, --project <name>', 'Only sessions from this project')
|
|
272
|
+
.option('--since <time>', 'Only sessions newer than this (e.g. 2h, 7d, 4w, or an ISO date)')
|
|
273
|
+
.option('--until <time>', 'Only sessions older than this (ISO timestamp)')
|
|
274
|
+
.option('--team, --teams', 'Include team-spawned sessions')
|
|
275
|
+
.option('--json', 'Emit the machine-readable result');
|
|
241
276
|
setHelpSections(resources, {
|
|
242
277
|
examples: `
|
|
243
278
|
# Fold every historical session on this machine into the usage index
|
|
244
|
-
|
|
279
|
+
${invocation} resources
|
|
245
280
|
|
|
246
281
|
# Narrow the historical work
|
|
247
|
-
|
|
282
|
+
${invocation} resources --agent claude --since 30d
|
|
248
283
|
|
|
249
284
|
# Machine-readable summary
|
|
250
|
-
|
|
285
|
+
${invocation} resources --json
|
|
251
286
|
`,
|
|
252
287
|
notes: `
|
|
253
288
|
- Populates session_resource_usage for sessions indexed before the usage signal shipped. New/changed sessions are recorded on their normal scan; this is the one-shot catch-up read by \`agents sessions stats\`.
|
|
254
|
-
- Local-only: the signal is derived per machine from its own transcripts. Run it on each box (or over \`agents ssh <host>
|
|
289
|
+
- Local-only: the signal is derived per machine from its own transcripts. Run it on each box (or over \`agents ssh <host> ${invocation} resources\`).
|
|
255
290
|
- Reruns skip transcripts already current (resource_scan_ledger); bump the extractor version to force a full re-derive.
|
|
256
291
|
- Only slash commands and \`Skill\` tool calls are recorded — auto-triggered skills emit no signal.
|
|
257
292
|
`,
|
|
@@ -286,13 +321,13 @@ export function registerSessionsBackfillCommand(sessionsCmd) {
|
|
|
286
321
|
setHelpSections(titles, {
|
|
287
322
|
examples: `
|
|
288
323
|
# Catch this machine up now (the daemon otherwise does a couple every 2 min)
|
|
289
|
-
|
|
324
|
+
${invocation} titles
|
|
290
325
|
|
|
291
326
|
# Re-title one session after correcting its first message
|
|
292
|
-
|
|
327
|
+
${invocation} titles --session 6fc1db18 --refresh
|
|
293
328
|
|
|
294
329
|
# Machine-readable
|
|
295
|
-
|
|
330
|
+
${invocation} titles --limit 20 --json
|
|
296
331
|
`,
|
|
297
332
|
notes: `
|
|
298
333
|
- The headline ladder is: \`/rename\` label > this generated title > the user's first message. It is never the agent's latest turn.
|
|
@@ -17,5 +17,5 @@ export declare function buildMigrateResumeCommands(opts: {
|
|
|
17
17
|
socketFlag: string;
|
|
18
18
|
};
|
|
19
19
|
export declare function rehydrateCommand(source: SessionMeta): string[];
|
|
20
|
-
export declare function registerSessionsMigrationsCommand(sessionsCmd: Command): void;
|
|
20
|
+
export declare function registerSessionsMigrationsCommand(sessionsCmd: Command, group?: 'sessions' | 'ps'): void;
|
|
21
21
|
export {};
|
|
@@ -58,11 +58,11 @@ export function registerSessionsMigrateCommand(sessionsCmd, group = 'sessions')
|
|
|
58
58
|
- --mode resume attempts a native '<agent> --resume' on the target — faithful, but best-effort:
|
|
59
59
|
the target agent must have the session registered, so migrate falls back to rehydrate when it can't.
|
|
60
60
|
- The source is stopped only AFTER the target's session is confirmed live; --keep skips the stop (copy).
|
|
61
|
-
- Every migrate appends to the ledger — see 'agents
|
|
61
|
+
- Every migrate appends to the ledger — see 'agents ${group} migrations' for where each session went.
|
|
62
62
|
`,
|
|
63
63
|
});
|
|
64
64
|
cmd.action(async (sessionId, options) => {
|
|
65
|
-
await sessionsMigrateAction(sessionId, options);
|
|
65
|
+
await sessionsMigrateAction(sessionId, options, group);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
function fail(message) {
|
|
@@ -375,7 +375,7 @@ export function rehydrateCommand(source) {
|
|
|
375
375
|
].join(' ');
|
|
376
376
|
return [cli, prompt];
|
|
377
377
|
}
|
|
378
|
-
async function sessionsMigrateAction(sessionId, options) {
|
|
378
|
+
async function sessionsMigrateAction(sessionId, options, group) {
|
|
379
379
|
if (options.mode && options.mode !== 'resume' && options.mode !== 'rehydrate') {
|
|
380
380
|
fail(`--mode must be 'resume' or 'rehydrate' (got "${options.mode}").`);
|
|
381
381
|
}
|
|
@@ -411,7 +411,7 @@ async function sessionsMigrateAction(sessionId, options) {
|
|
|
411
411
|
}
|
|
412
412
|
recordMigration({ ...base, status: 'completed' });
|
|
413
413
|
console.log(chalk.green(`\nMigrated ${source.shortId} to ${target.name}${options.keep ? ' (copy)' : ''}.`) +
|
|
414
|
-
chalk.gray(
|
|
414
|
+
chalk.gray(` Tracked in 'agents ${group} migrations'.`));
|
|
415
415
|
}
|
|
416
416
|
async function stopSource(source, active) {
|
|
417
417
|
const mux = active?.provenance?.mux;
|
|
@@ -432,22 +432,23 @@ async function stopSource(source, active) {
|
|
|
432
432
|
else
|
|
433
433
|
console.log(chalk.yellow(` Source tmux session ${name} was already gone.`));
|
|
434
434
|
}
|
|
435
|
-
export function registerSessionsMigrationsCommand(sessionsCmd) {
|
|
436
|
-
sessionsCmd
|
|
435
|
+
export function registerSessionsMigrationsCommand(sessionsCmd, group = 'sessions') {
|
|
436
|
+
const cmd = sessionsCmd
|
|
437
437
|
.command('migrations')
|
|
438
438
|
.description('Show the migration ledger — sessions handed off to/from other machines.')
|
|
439
439
|
.option('--json', 'Output the raw ledger as JSON')
|
|
440
|
-
.option('--session <id>', 'Only rows whose session id starts with this fragment')
|
|
441
|
-
|
|
440
|
+
.option('--session <id>', 'Only rows whose session id starts with this fragment');
|
|
441
|
+
cmd.action((options) => {
|
|
442
|
+
const json = cmd.optsWithGlobals().json === true;
|
|
442
443
|
let recs = readMigrations();
|
|
443
444
|
if (options.session)
|
|
444
445
|
recs = recs.filter((r) => r.sessionId.startsWith(options.session) || r.shortId.startsWith(options.session));
|
|
445
|
-
if (
|
|
446
|
+
if (json) {
|
|
446
447
|
console.log(JSON.stringify(recs, null, 2));
|
|
447
448
|
return;
|
|
448
449
|
}
|
|
449
450
|
if (recs.length === 0) {
|
|
450
|
-
console.log(chalk.gray(
|
|
451
|
+
console.log(chalk.gray(`No migrations recorded yet. Move one: agents ${group} migrate --auto`));
|
|
451
452
|
return;
|
|
452
453
|
}
|
|
453
454
|
recs.reverse();
|
|
@@ -2,7 +2,10 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { optimizeSessionSearchIndex } from '../lib/session/db.js';
|
|
3
3
|
import { setHelpSections } from '../lib/help.js';
|
|
4
4
|
export function registerSessionsOptimizeCommand(sessionsCmd) {
|
|
5
|
-
|
|
5
|
+
registerOptimizeCommand(sessionsCmd, 'agents sessions optimize');
|
|
6
|
+
}
|
|
7
|
+
export function registerOptimizeCommand(parent, invocation) {
|
|
8
|
+
const cmd = parent
|
|
6
9
|
.command('optimize')
|
|
7
10
|
.description('Compact the session search index (FTS5), reclaiming bloat from repeated re-indexing')
|
|
8
11
|
.option('--json', 'Emit machine-readable JSON')
|
|
@@ -23,14 +26,14 @@ export function registerSessionsOptimizeCommand(sessionsCmd) {
|
|
|
23
26
|
setHelpSections(cmd, {
|
|
24
27
|
examples: `
|
|
25
28
|
# Compact the session/tool search index once it has grown fragmented
|
|
26
|
-
|
|
29
|
+
${invocation}
|
|
27
30
|
|
|
28
31
|
# Machine-readable segment counts
|
|
29
|
-
|
|
32
|
+
${invocation} --json
|
|
30
33
|
|
|
31
34
|
# Wire it to a weekly routine so the index never re-bloats
|
|
32
35
|
agents routines add sessions-optimize --schedule "0 4 * * 0" --agent claude \\
|
|
33
|
-
--prompt "Run:
|
|
36
|
+
--prompt "Run: ${invocation}"
|
|
34
37
|
`,
|
|
35
38
|
notes: `
|
|
36
39
|
- FTS5 appends a segment on every insert and tombstones every delete; the scanner delete+inserts a session's docs on each rescan and never self-merges, so \`tool_call_text_data\` / \`session_text_data\` bloat with unmerged segments — GBs of index for tens of MB of content, and queries slow down.
|
|
@@ -20,6 +20,7 @@ import { buildResumeRemoteArgs, runStrictResume, wantsStrictResume } from './res
|
|
|
20
20
|
import { toRemotePortable } from '../lib/project-root.js';
|
|
21
21
|
import { attachLocalLiveSelector } from '../lib/session/local-tmux-attach.js';
|
|
22
22
|
import { sessionHeadline } from '../lib/session/title.js';
|
|
23
|
+
import { stripRoutingFlags } from '../lib/hosts/remote-cmd.js';
|
|
23
24
|
export const CONFIRM_THRESHOLD = 5;
|
|
24
25
|
export function registerSessionsResumeCommand(sessionsCmd) {
|
|
25
26
|
const cmd = sessionsCmd
|
|
@@ -290,9 +291,15 @@ export async function sessionsResumeAction(query, prompt, options) {
|
|
|
290
291
|
if (opened !== items.length)
|
|
291
292
|
process.exitCode = 1;
|
|
292
293
|
}
|
|
294
|
+
const RUN_RESUME_PICKER_SPECS = [
|
|
295
|
+
{ long: 'all', takesValue: false },
|
|
296
|
+
{ long: 'teams', takesValue: false },
|
|
297
|
+
{ long: 'since', takesValue: true },
|
|
298
|
+
{ long: 'limit', short: 'n', takesValue: true },
|
|
299
|
+
];
|
|
293
300
|
export function buildSelectedResumeArgs(id, prompt, options) {
|
|
294
301
|
if (options.runArgs) {
|
|
295
|
-
const args =
|
|
302
|
+
const args = stripRoutingFlags(options.runArgs, RUN_RESUME_PICKER_SPECS);
|
|
296
303
|
const boundary = args.indexOf('--');
|
|
297
304
|
const index = args.findIndex((arg, i) => (boundary < 0 || i < boundary) && (arg === '--resume' || arg === '--resume='));
|
|
298
305
|
if (index < 0)
|
|
@@ -10,4 +10,6 @@ export declare function diffZeroInvoked(installed: InstalledResource[], invoked:
|
|
|
10
10
|
name: string;
|
|
11
11
|
}>): InstalledResource[];
|
|
12
12
|
export declare function registerSessionsStatsCommand(sessionsCmd: Command): void;
|
|
13
|
+
export declare function registerInsightsResourcesCommand(insightsCmd: Command): void;
|
|
14
|
+
export declare function resolveStatsAgent(values: unknown[]): string | undefined;
|
|
13
15
|
export {};
|
|
@@ -38,8 +38,13 @@ function installedResources(kindFilter, pluginFilter, cwd) {
|
|
|
38
38
|
return [...byKey.values()];
|
|
39
39
|
}
|
|
40
40
|
export function registerSessionsStatsCommand(sessionsCmd) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
configureStatsCommand(sessionsCmd.command('stats'), 'agents sessions stats');
|
|
42
|
+
}
|
|
43
|
+
export function registerInsightsResourcesCommand(insightsCmd) {
|
|
44
|
+
configureStatsCommand(insightsCmd.command('resources'), 'agents insights resources');
|
|
45
|
+
}
|
|
46
|
+
function configureStatsCommand(stats, spelling) {
|
|
47
|
+
stats
|
|
43
48
|
.description('Which skills/commands you actually invoke, and which installed ones are dead weight.')
|
|
44
49
|
.option('--kind <kind>', 'Limit to one kind: skill or command')
|
|
45
50
|
.option('--plugin <name>', "Only this plugin's resources (r.plugin), not every resource a plugin-touching session used")
|
|
@@ -57,16 +62,16 @@ export function registerSessionsStatsCommand(sessionsCmd) {
|
|
|
57
62
|
setHelpSections(stats, {
|
|
58
63
|
examples: `
|
|
59
64
|
# Most-invoked skills and commands, plus the installed ones you never invoke
|
|
60
|
-
|
|
65
|
+
${spelling}
|
|
61
66
|
|
|
62
67
|
# Just the dead weight — installed but never explicitly invoked
|
|
63
|
-
|
|
68
|
+
${spelling} --zero
|
|
64
69
|
|
|
65
70
|
# Skills only, last 30 days, machine-readable
|
|
66
|
-
|
|
71
|
+
${spelling} --kind skill --since 30d --json
|
|
67
72
|
|
|
68
73
|
# One plugin's resources, least-used first
|
|
69
|
-
|
|
74
|
+
${spelling} --plugin rush --bottom
|
|
70
75
|
|
|
71
76
|
# Backfill historical sessions first if coverage is low
|
|
72
77
|
agents sessions backfill resources
|
|
@@ -76,11 +81,23 @@ export function registerSessionsStatsCommand(sessionsCmd) {
|
|
|
76
81
|
- Skill invocations are recorded for Claude and Kimi; slash-commands for Claude only. Other harnesses contribute nothing to these counts.
|
|
77
82
|
- Counts come from the SQLite index. New/changed sessions are recorded on their normal scan; run \`agents sessions backfill resources\` once to fold in historical sessions (a low coverage line means it hasn't run).
|
|
78
83
|
- --plugin filters the resource rows (this plugin's skills/commands), distinct from the top-level \`agents sessions --plugin\` which filters SESSIONS.
|
|
84
|
+
- The window is all time unless --since narrows it. \`agents insights resources\` and \`agents sessions stats\` are the same report; --json keeps \`kind: "sessions-stats"\` under either spelling.
|
|
79
85
|
`,
|
|
80
86
|
});
|
|
81
87
|
}
|
|
88
|
+
export function resolveStatsAgent(values) {
|
|
89
|
+
const agents = [...new Set(values.flatMap(v => (Array.isArray(v) ? v : v === undefined ? [] : [v])).map(String))];
|
|
90
|
+
if (agents.length > 1) {
|
|
91
|
+
console.error(chalk.red(`error: resource usage filters on one --agent; got ${agents.join(', ')}`));
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
return agents[0];
|
|
95
|
+
}
|
|
82
96
|
async function statsAction(cmd) {
|
|
83
|
-
const
|
|
97
|
+
const agentValues = [];
|
|
98
|
+
for (let c = cmd; c; c = c.parent)
|
|
99
|
+
agentValues.push(c.opts().agent);
|
|
100
|
+
const opts = { ...cmd.optsWithGlobals(), agent: resolveStatsAgent(agentValues) };
|
|
84
101
|
const kind = normalizeKind(opts.kind);
|
|
85
102
|
const sinceMs = opts.since ? parseTimeFilter(opts.since) : undefined;
|
|
86
103
|
const top = resolveTop(opts.top);
|