@phnx-labs/agents-cli 1.23.16 → 1.23.18
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 +75 -0
- package/README.md +140 -165
- package/dist/bootstrap.js +10 -16
- 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 +1 -1
- package/dist/commands/config.js +0 -4
- 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 +5 -5
- package/dist/commands/exec.js +10 -22
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +3 -3
- package/dist/commands/focus.d.ts +1 -4
- package/dist/commands/focus.js +12 -13
- 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.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/ps.d.ts +0 -1
- package/dist/commands/ps.js +63 -18
- 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.js +11 -11
- 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 +6 -6
- 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/accounting/rotate.js +1 -1
- 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/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 +1 -1
- package/dist/lib/config-keys.js +0 -3
- package/dist/lib/crabbox/cli.js +1 -1
- package/dist/lib/device-config.js +5 -28
- 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/exec.js +1 -1
- package/dist/lib/feed/activity.js +1 -1
- package/dist/lib/fleet/apply.js +1 -1
- package/dist/lib/help.d.ts +0 -1
- package/dist/lib/help.js +2 -10
- 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 +1 -1
- 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/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 +8 -6
- 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/session/active.d.ts +1 -1
- package/dist/lib/session/db.js +3 -3
- 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/presentation.d.ts +0 -7
- package/dist/lib/session/presentation.js +4 -4
- package/dist/lib/session/projection.js +1 -1
- package/dist/lib/session/remote/remote-list.d.ts +2 -0
- package/dist/lib/session/remote/remote-list.js +3 -2
- package/dist/lib/session/remote/watch.js +4 -5
- 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/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/terminal/resolve.js +1 -1
- 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/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/resume.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { resolveSessionMetadataValue } from '../lib/session/selection.js';
|
|
4
|
-
import { sessionOwnerDevice, consumeResumePinned, RESUME_PINNED_ENV } from '../lib/session/resume-owner.js';
|
|
5
|
-
import { machineId } from '../lib/machine-id.js';
|
|
6
|
-
import { takeOverDetachedSession } from '../lib/session/detached.js';
|
|
7
|
-
import { liveSessionProcesses, writePidSessionEntry } from '../lib/session/pid-registry.js';
|
|
8
|
-
import { launchIdentityEnv } from '../lib/launch-identity.js';
|
|
9
|
-
const RESUME_SOURCE_ENV = 'AGENTS_RESUME_SOURCE_JSON';
|
|
10
|
-
export function resumeLocalFallbackSource(session, self = machineId()) {
|
|
11
|
-
return { ...session, machine: self };
|
|
12
|
-
}
|
|
13
|
-
export function buildResumeRemoteArgs(sessionId, prompt, options) {
|
|
14
|
-
const args = ['sessions', 'resume', sessionId, ...(prompt === undefined ? [] : [prompt])];
|
|
15
|
-
if (options.agent)
|
|
16
|
-
args.push('--agent', options.agent);
|
|
17
|
-
if (options.account)
|
|
18
|
-
args.push('--account', options.account);
|
|
19
|
-
if (options.model)
|
|
20
|
-
args.push('--model', options.model);
|
|
21
|
-
if (options.mode)
|
|
22
|
-
args.push('--mode', options.mode);
|
|
23
|
-
if (options.interactive)
|
|
24
|
-
args.push('--interactive');
|
|
25
|
-
if (options.headless)
|
|
26
|
-
args.push('--headless');
|
|
27
|
-
if (options.cwd)
|
|
28
|
-
args.push('--cwd', options.cwd);
|
|
29
|
-
if (options.quiet)
|
|
30
|
-
args.push('--quiet');
|
|
31
|
-
return args;
|
|
32
|
-
}
|
|
33
|
-
export function buildResumeRunArgs(session, prompt, options) {
|
|
34
|
-
const spec = session.agent;
|
|
35
|
-
const args = ['run', spec, ...(prompt === undefined ? [] : [prompt]), '--resume', session.id];
|
|
36
|
-
if (options.account)
|
|
37
|
-
args.push('--account', options.account);
|
|
38
|
-
if (options.model)
|
|
39
|
-
args.push('--model', options.model);
|
|
40
|
-
if (options.mode)
|
|
41
|
-
args.push('--mode', options.mode);
|
|
42
|
-
if (options.interactive)
|
|
43
|
-
args.push('--interactive');
|
|
44
|
-
if (options.headless)
|
|
45
|
-
args.push('--headless');
|
|
46
|
-
if (options.cwd)
|
|
47
|
-
args.push('--cwd', options.cwd);
|
|
48
|
-
if (options.quiet)
|
|
49
|
-
args.push('--quiet');
|
|
50
|
-
return args;
|
|
51
|
-
}
|
|
52
|
-
function consumeResumeSource() {
|
|
53
|
-
const raw = process.env[RESUME_SOURCE_ENV];
|
|
54
|
-
delete process.env[RESUME_SOURCE_ENV];
|
|
55
|
-
if (!raw)
|
|
56
|
-
return undefined;
|
|
57
|
-
try {
|
|
58
|
-
const value = JSON.parse(raw);
|
|
59
|
-
if (typeof value?.id === 'string' && typeof value?.agent === 'string')
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
}
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
export function wantsStrictResume(prompt, options) {
|
|
67
|
-
return (prompt !== undefined ||
|
|
68
|
-
!!options.mode ||
|
|
69
|
-
!!options.interactive ||
|
|
70
|
-
!!options.headless ||
|
|
71
|
-
!!options.cwd ||
|
|
72
|
-
!!options.here);
|
|
73
|
-
}
|
|
74
|
-
export async function runStrictResume(sessionId, prompt, options) {
|
|
75
|
-
const routedHop = consumeResumePinned();
|
|
76
|
-
const pinnedHere = routedHop || !!options.here;
|
|
77
|
-
const routedSource = routedHop ? consumeResumeSource() : undefined;
|
|
78
|
-
if (routedSource && routedSource.id !== sessionId.trim()) {
|
|
79
|
-
console.error(chalk.red(`Resume routing metadata names session ${routedSource.id}, not requested session ${sessionId.trim()}.`));
|
|
80
|
-
process.exitCode = 1;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const outcome = await resolveSessionMetadataValue(sessionId.trim(), { agent: options.agent, local: pinnedHere || options.local });
|
|
84
|
-
if (outcome.kind === 'partial') {
|
|
85
|
-
const offline = outcome.failedPeers;
|
|
86
|
-
console.error(chalk.yellow(`Warning: ${offline.length} device(s) unreachable, not checked: ${offline.join(', ')}`));
|
|
87
|
-
console.error(chalk.red(`No session matching "${sessionId}" on any reachable device (${offline.length} unreachable, not checked).`));
|
|
88
|
-
console.error(chalk.gray(' If it lives on an offline box, wake it (agents devices) or run there: agents ssh <device>'));
|
|
89
|
-
process.exitCode = 1;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (outcome.kind === 'not-found') {
|
|
93
|
-
console.error(chalk.red(`No session matching "${sessionId}".`));
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (outcome.kind === 'ambiguous') {
|
|
98
|
-
console.error(chalk.red(`"${sessionId}" matches ${outcome.candidates.length} sessions. Pass the full session id.`));
|
|
99
|
-
process.exitCode = 1;
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const owner = pinnedHere ? undefined : sessionOwnerDevice(outcome.session);
|
|
103
|
-
if (owner) {
|
|
104
|
-
if (!options.quiet) {
|
|
105
|
-
process.stderr.write(chalk.gray(`[agents] session ${outcome.session.shortId} belongs to ${owner} → resuming there\n`));
|
|
106
|
-
}
|
|
107
|
-
writePidSessionEntry({
|
|
108
|
-
pid: process.pid,
|
|
109
|
-
agent: outcome.session.agent,
|
|
110
|
-
sessionId: outcome.session.id,
|
|
111
|
-
cwd: outcome.session.cwd,
|
|
112
|
-
terminalId: launchIdentityEnv().AGENT_TERMINAL_ID,
|
|
113
|
-
machine: owner,
|
|
114
|
-
startedAtMs: Date.now(),
|
|
115
|
-
});
|
|
116
|
-
const { runOnPeer } = await import('../lib/session/remote-list.js');
|
|
117
|
-
const rc = await runOnPeer(buildResumeRemoteArgs(outcome.session.id, prompt, options), owner, {
|
|
118
|
-
tty: !!process.stdout.isTTY,
|
|
119
|
-
env: {
|
|
120
|
-
[RESUME_PINNED_ENV]: '1',
|
|
121
|
-
[RESUME_SOURCE_ENV]: JSON.stringify(outcome.session),
|
|
122
|
-
},
|
|
123
|
-
sessionId: outcome.session.id,
|
|
124
|
-
});
|
|
125
|
-
if (rc === 'no-target' || rc === 'unreachable') {
|
|
126
|
-
if (!options.quiet) {
|
|
127
|
-
process.stderr.write(chalk.yellow(`[agents] session ${outcome.session.shortId} belongs to ${owner}, which is unreachable; checking for local transcript content before offering replay\n`));
|
|
128
|
-
}
|
|
129
|
-
process.exitCode = await delegateLocalResume(resumeLocalFallbackSource(outcome.session), prompt, options);
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const localSession = pinnedHere ? resumeLocalFallbackSource(outcome.session) : outcome.session;
|
|
134
|
-
await takeOverDetachedSession(localSession.id);
|
|
135
|
-
if (!options.quiet) {
|
|
136
|
-
for (const running of liveSessionProcesses(localSession.id)) {
|
|
137
|
-
process.stderr.write(chalk.yellow(stillRunningNotice(localSession.shortId, running.pid, machineId())));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
process.exitCode = await delegateLocalResume(localSession, prompt, options);
|
|
141
|
-
}
|
|
142
|
-
export function stillRunningNotice(shortId, pid, host) {
|
|
143
|
-
return `An older copy of ${shortId} is still running on ${host} (pid ${pid}). It was left alone.\n`;
|
|
144
|
-
}
|
|
145
|
-
async function delegateLocalResume(session, prompt, options) {
|
|
146
|
-
const args = buildResumeRunArgs(session, prompt, options);
|
|
147
|
-
const child = spawn(process.execPath, [process.argv[1], ...args], {
|
|
148
|
-
stdio: 'inherit',
|
|
149
|
-
env: {
|
|
150
|
-
...process.env,
|
|
151
|
-
[RESUME_SOURCE_ENV]: JSON.stringify(session),
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
return new Promise((resolve) => {
|
|
155
|
-
child.once('error', () => resolve(127));
|
|
156
|
-
child.once('exit', (code, signal) => resolve(code ?? (signal ? 1 : 0)));
|
|
157
|
-
});
|
|
158
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { buildServeEnv, invocation, resolveSecretsBin, SecretsClientError } from '../lib/secrets-client.js';
|
|
4
|
-
import { flagValue } from '../lib/hosts/routing-flag.js';
|
|
5
|
-
import { stripRoutingFlags } from '../lib/hosts/remote-cmd.js';
|
|
6
|
-
import { resolveRemoteDevice } from '../lib/ssh-tunnel.js';
|
|
7
|
-
import { SECRETS_CLI_INSTALL_HINT } from '../lib/secrets-cli.js';
|
|
8
|
-
import { forwardsHelp } from '../lib/help.js';
|
|
9
|
-
export async function rewriteDeviceToHost(argv) {
|
|
10
|
-
if (flagValue(argv, 'host', 'H') !== undefined)
|
|
11
|
-
return argv;
|
|
12
|
-
const device = flagValue(argv, 'device', 'D');
|
|
13
|
-
if (device === undefined)
|
|
14
|
-
return argv;
|
|
15
|
-
const resolved = await resolveRemoteDevice(device, {});
|
|
16
|
-
const stripped = stripRoutingFlags(argv, [{ long: 'device', short: 'D', takesValue: true }]);
|
|
17
|
-
return [...stripped, '--host', `ssh://${resolved.target}`];
|
|
18
|
-
}
|
|
19
|
-
export function registerSecretsCommands(program) {
|
|
20
|
-
forwardsHelp(program
|
|
21
|
-
.command('secrets')
|
|
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.')
|
|
23
|
-
.allowUnknownOption()
|
|
24
|
-
.allowExcessArguments()
|
|
25
|
-
.action(async () => {
|
|
26
|
-
let bin;
|
|
27
|
-
try {
|
|
28
|
-
bin = resolveSecretsBin();
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
if (err instanceof SecretsClientError && err.code === 'SECRETS_BIN_MISSING') {
|
|
32
|
-
console.error(chalk.red('The standalone `secrets` CLI is not installed.'));
|
|
33
|
-
console.error(chalk.gray(`Install it, then re-run this command:`));
|
|
34
|
-
console.error(chalk.cyan(` ${SECRETS_CLI_INSTALL_HINT}`));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
39
|
-
const secretsIndex = process.argv.indexOf('secrets');
|
|
40
|
-
const forwarded = await rewriteDeviceToHost(secretsIndex >= 0 ? process.argv.slice(secretsIndex + 1) : []);
|
|
41
|
-
const { command, prefix } = invocation(bin);
|
|
42
|
-
const res = spawnSync(command, [...prefix, ...forwarded], {
|
|
43
|
-
stdio: 'inherit',
|
|
44
|
-
env: buildServeEnv(),
|
|
45
|
-
});
|
|
46
|
-
if (res.error) {
|
|
47
|
-
console.error(chalk.red(`Failed to run \`secrets\`: ${res.error.message}`));
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
process.exit(res.status ?? 1);
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { setHelpSections } from '../lib/help.js';
|
|
3
|
-
import { findSessionsById } from '../lib/session/db.js';
|
|
4
|
-
import { isCompleteSessionId } from '../lib/session/discover.js';
|
|
5
|
-
import { isBookmarked, listBookmarks, setBookmark } from '../lib/session/bookmarks.js';
|
|
6
|
-
function resolveBookmarkTarget(idQuery) {
|
|
7
|
-
const matches = findSessionsById(idQuery);
|
|
8
|
-
if (matches.length === 0) {
|
|
9
|
-
return isCompleteSessionId(idQuery.trim())
|
|
10
|
-
? { id: idQuery.trim() }
|
|
11
|
-
: { error: `No session matches "${idQuery}".` };
|
|
12
|
-
}
|
|
13
|
-
if (matches.length > 1) {
|
|
14
|
-
const ids = matches.slice(0, 5).map((m) => m.shortId).join(', ');
|
|
15
|
-
return { error: `"${idQuery}" matches ${matches.length} sessions (${ids}…) — use a longer id.` };
|
|
16
|
-
}
|
|
17
|
-
return { id: matches[0].id };
|
|
18
|
-
}
|
|
19
|
-
export function registerSessionsBookmarkCommand(sessionsCmd) {
|
|
20
|
-
const cmd = sessionsCmd
|
|
21
|
-
.command('bookmark')
|
|
22
|
-
.argument('[ids...]', 'Session ids to bookmark (full or short id prefix)')
|
|
23
|
-
.description('Bookmark sessions so they are easy to find again — list them with --bookmarks, or `b` in the browser.')
|
|
24
|
-
.option('--remove', 'Remove the given sessions from bookmarks instead of adding them')
|
|
25
|
-
.option('--list', 'List the bookmarked sessions (the default when no ids are given)')
|
|
26
|
-
.option('--json', 'Output JSON');
|
|
27
|
-
setHelpSections(cmd, {
|
|
28
|
-
examples: `
|
|
29
|
-
# Bookmark a session by its short id (the 8 chars the listing prints)
|
|
30
|
-
agents sessions bookmark 26c27162
|
|
31
|
-
|
|
32
|
-
# See what is bookmarked
|
|
33
|
-
agents sessions bookmark --list
|
|
34
|
-
|
|
35
|
-
# Browse only the bookmarked ones
|
|
36
|
-
agents sessions --bookmarks
|
|
37
|
-
|
|
38
|
-
# Remove it from bookmarks again
|
|
39
|
-
agents sessions bookmark 26c27162 --remove
|
|
40
|
-
`,
|
|
41
|
-
notes: `
|
|
42
|
-
In the interactive browser (\`agents sessions\`), \`*\` bookmarks the highlighted
|
|
43
|
-
session and \`b\` filters the list down to the bookmarked ones.
|
|
44
|
-
|
|
45
|
-
Bookmarks live in ~/.agents/.history/bookmarks.json, keyed by session id, so
|
|
46
|
-
they survive a reindex of the session cache. They are per-machine: session
|
|
47
|
-
sync carries transcripts, not this file.
|
|
48
|
-
`,
|
|
49
|
-
});
|
|
50
|
-
cmd.action((ids, options, self) => {
|
|
51
|
-
const json = self.optsWithGlobals().json === true;
|
|
52
|
-
if (options.list || ids.length === 0) {
|
|
53
|
-
const bookmarked = [...listBookmarks()].sort();
|
|
54
|
-
if (json) {
|
|
55
|
-
process.stdout.write(JSON.stringify({ bookmarks: bookmarked }, null, 2) + '\n');
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (bookmarked.length === 0) {
|
|
59
|
-
console.log(chalk.gray('No bookmarked sessions. Bookmark one with `agents sessions bookmark <id>`.'));
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
for (const id of bookmarked)
|
|
63
|
-
console.log(`${chalk.yellow('★')} ${id}`);
|
|
64
|
-
console.log(chalk.gray(`\n${bookmarked.length} bookmark${bookmarked.length === 1 ? '' : 's'}.`));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const on = !options.remove;
|
|
68
|
-
const results = [];
|
|
69
|
-
for (const idQuery of ids) {
|
|
70
|
-
const resolved = resolveBookmarkTarget(idQuery);
|
|
71
|
-
if ('error' in resolved) {
|
|
72
|
-
results.push({ query: idQuery, error: resolved.error });
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
setBookmark(resolved.id, on);
|
|
76
|
-
results.push({ query: idQuery, id: resolved.id, bookmark: isBookmarked(resolved.id) });
|
|
77
|
-
}
|
|
78
|
-
if (json) {
|
|
79
|
-
process.stdout.write(JSON.stringify({ results }, null, 2) + '\n');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
for (const r of results) {
|
|
83
|
-
if (r.error)
|
|
84
|
-
console.error(chalk.red(r.error));
|
|
85
|
-
else
|
|
86
|
-
console.log(`${r.bookmark ? chalk.yellow('★ bookmarked') : chalk.gray('☆ unbookmarked')} ${r.id}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (results.some((r) => r.error))
|
|
90
|
-
process.exitCode = 1;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import type { SessionMeta } from '@phnx-labs/sessions-cli/reader';
|
|
3
|
-
import { type SessionsBackupClient } from '../lib/session/sync/net-client.js';
|
|
4
|
-
import { type BundleHeader, type BundleRecord } from '../lib/session/bundle.js';
|
|
5
|
-
export declare function registerSessionsExportCommand(sessionsCmd: Command): void;
|
|
6
|
-
interface GlobalSelection {
|
|
7
|
-
since?: string;
|
|
8
|
-
limit?: string;
|
|
9
|
-
all?: boolean;
|
|
10
|
-
agent?: string;
|
|
11
|
-
redact?: boolean;
|
|
12
|
-
encrypt?: boolean;
|
|
13
|
-
toR2?: boolean;
|
|
14
|
-
byo?: boolean;
|
|
15
|
-
output?: string;
|
|
16
|
-
stdout?: boolean;
|
|
17
|
-
host?: string[];
|
|
18
|
-
claude?: boolean;
|
|
19
|
-
codex?: boolean;
|
|
20
|
-
kimi?: boolean;
|
|
21
|
-
grok?: boolean;
|
|
22
|
-
opencode?: boolean;
|
|
23
|
-
antigravity?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare function r2ExportGateError(g: Pick<GlobalSelection, 'toR2' | 'host'>, isConfigured: boolean): string | null;
|
|
26
|
-
export declare function uploadToR2(header: BundleHeader, records: BundleRecord[], resolvedClient?: SessionsBackupClient): Promise<void>;
|
|
27
|
-
export declare function managedUploadEncryptionError(header: BundleHeader, records: BundleRecord[]): string | null;
|
|
28
|
-
export declare function r2KeyForRecord(rec: BundleRecord): string;
|
|
29
|
-
export declare function resolveR2BackupKey(): Buffer | null;
|
|
30
|
-
export declare function selectSessions(metas: SessionMeta[], selectors: string[]): SessionMeta[];
|
|
31
|
-
export {};
|