@phnx-labs/agents-cli 1.23.17 → 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 +66 -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/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/lib/address.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One address grammar for every `--host` an extracted CLI accepts (PHNX-4090).
|
|
3
|
-
*
|
|
4
|
-
* This file is copied verbatim into agents-cli, computer-cli, browser-cli and
|
|
5
|
-
* secrets-cli, each with the same test vectors — deliberately not a published
|
|
6
|
-
* package, so no engine grows a runtime dependency on another. Keep the four
|
|
7
|
-
* copies identical; a change lands in all of them in the same delivery.
|
|
8
|
-
*
|
|
9
|
-
* ssh://[user@]host[:ssh-port] the authority port is the SSH port, never 9222
|
|
10
|
-
* cdp://host[:port] default 9222
|
|
11
|
-
* vnc://host[:port] default 5901
|
|
12
|
-
* tcp://host:port no default — a helper RPC endpoint needs one
|
|
13
|
-
* wss://host/path, ws://… a remote DevTools socket
|
|
14
|
-
* firefox-bidi://host[:port] the browser's BiDi endpoint
|
|
15
|
-
* [user@]host implicit ssh://
|
|
16
|
-
*
|
|
17
|
-
* A query (`?port=9222&os=windows`) is preserved for the consumer that knows
|
|
18
|
-
* what it means. Passwords never travel in an address: `user:secret@host` fails
|
|
19
|
-
* loud, and so does any scheme not listed above.
|
|
20
|
-
*/
|
|
21
|
-
export declare const ADDRESS_SCHEMES: readonly ["ssh", "cdp", "vnc", "tcp", "wss", "ws", "firefox-bidi"];
|
|
22
|
-
export type AddressScheme = (typeof ADDRESS_SCHEMES)[number];
|
|
23
|
-
export declare const DEFAULT_PORTS: Readonly<Partial<Record<AddressScheme, number>>>;
|
|
24
|
-
export interface Address {
|
|
25
|
-
scheme: AddressScheme;
|
|
26
|
-
user?: string;
|
|
27
|
-
host: string;
|
|
28
|
-
port?: number;
|
|
29
|
-
path?: string;
|
|
30
|
-
query: Record<string, string>;
|
|
31
|
-
raw: string;
|
|
32
|
-
}
|
|
33
|
-
export declare function parseAddress(input: string): Address;
|
|
34
|
-
export declare function addressPort(addr: Address): number | undefined;
|
|
35
|
-
export declare function sshTarget(addr: Address): string;
|
|
36
|
-
export declare function sshPortArgs(addr: Address): string[];
|
|
37
|
-
export declare function vncEndpoint(addr: Address): string;
|
|
38
|
-
export declare function tcpEndpoint(addr: Address): string;
|
|
39
|
-
export declare function browserEndpointPort(addr: Address): number | undefined;
|
package/dist/lib/address.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One address grammar for every `--host` an extracted CLI accepts (PHNX-4090).
|
|
3
|
-
*
|
|
4
|
-
* This file is copied verbatim into agents-cli, computer-cli, browser-cli and
|
|
5
|
-
* secrets-cli, each with the same test vectors — deliberately not a published
|
|
6
|
-
* package, so no engine grows a runtime dependency on another. Keep the four
|
|
7
|
-
* copies identical; a change lands in all of them in the same delivery.
|
|
8
|
-
*
|
|
9
|
-
* ssh://[user@]host[:ssh-port] the authority port is the SSH port, never 9222
|
|
10
|
-
* cdp://host[:port] default 9222
|
|
11
|
-
* vnc://host[:port] default 5901
|
|
12
|
-
* tcp://host:port no default — a helper RPC endpoint needs one
|
|
13
|
-
* wss://host/path, ws://… a remote DevTools socket
|
|
14
|
-
* firefox-bidi://host[:port] the browser's BiDi endpoint
|
|
15
|
-
* [user@]host implicit ssh://
|
|
16
|
-
*
|
|
17
|
-
* A query (`?port=9222&os=windows`) is preserved for the consumer that knows
|
|
18
|
-
* what it means. Passwords never travel in an address: `user:secret@host` fails
|
|
19
|
-
* loud, and so does any scheme not listed above.
|
|
20
|
-
*/
|
|
21
|
-
export const ADDRESS_SCHEMES = ['ssh', 'cdp', 'vnc', 'tcp', 'wss', 'ws', 'firefox-bidi'];
|
|
22
|
-
export const DEFAULT_PORTS = {
|
|
23
|
-
ssh: 22,
|
|
24
|
-
cdp: 9222,
|
|
25
|
-
vnc: 5901,
|
|
26
|
-
};
|
|
27
|
-
const SCHEME_SET = new Set(ADDRESS_SCHEMES);
|
|
28
|
-
const IMPLICIT_SSH = /^[A-Za-z0-9._-]+(@[A-Za-z0-9._-]+)?$/;
|
|
29
|
-
export function parseAddress(input) {
|
|
30
|
-
const raw = input.trim();
|
|
31
|
-
if (!raw)
|
|
32
|
-
throw new Error('empty address');
|
|
33
|
-
if (!raw.includes('://')) {
|
|
34
|
-
if (!IMPLICIT_SSH.test(raw) || raw.startsWith('-')) {
|
|
35
|
-
throw new Error(`Invalid address ${JSON.stringify(raw)}. Expected scheme://host or user@host.`);
|
|
36
|
-
}
|
|
37
|
-
const at = raw.indexOf('@');
|
|
38
|
-
return {
|
|
39
|
-
scheme: 'ssh',
|
|
40
|
-
user: at > 0 ? raw.slice(0, at) : undefined,
|
|
41
|
-
host: at > 0 ? raw.slice(at + 1) : raw,
|
|
42
|
-
query: {},
|
|
43
|
-
raw,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
let url;
|
|
47
|
-
try {
|
|
48
|
-
url = new URL(raw);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
throw new Error(`Invalid address ${JSON.stringify(raw)}.`);
|
|
52
|
-
}
|
|
53
|
-
const scheme = url.protocol.replace(/:$/, '');
|
|
54
|
-
if (!SCHEME_SET.has(scheme)) {
|
|
55
|
-
throw new Error(`unsupported address scheme ${JSON.stringify(scheme)} in ${JSON.stringify(raw)}; expected one of ${ADDRESS_SCHEMES.join(', ')}`);
|
|
56
|
-
}
|
|
57
|
-
if (url.password) {
|
|
58
|
-
throw new Error('passwords are not allowed in addresses');
|
|
59
|
-
}
|
|
60
|
-
const host = url.hostname;
|
|
61
|
-
if (!host)
|
|
62
|
-
throw new Error(`Invalid address ${JSON.stringify(raw)}: missing host`);
|
|
63
|
-
const user = url.username ? decodeURIComponent(url.username) : undefined;
|
|
64
|
-
if (user?.startsWith('-') || host.startsWith('-')) {
|
|
65
|
-
throw new Error(`Invalid address ${JSON.stringify(raw)}: host or user cannot start with -`);
|
|
66
|
-
}
|
|
67
|
-
const port = url.port ? Number.parseInt(url.port, 10) : undefined;
|
|
68
|
-
if (port !== undefined && (!Number.isInteger(port) || port <= 0 || port > 65535)) {
|
|
69
|
-
throw new Error(`Invalid address ${JSON.stringify(raw)}: bad port`);
|
|
70
|
-
}
|
|
71
|
-
const query = {};
|
|
72
|
-
url.searchParams.forEach((value, key) => {
|
|
73
|
-
query[key] = value;
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
scheme: scheme,
|
|
77
|
-
user,
|
|
78
|
-
host,
|
|
79
|
-
port,
|
|
80
|
-
path: url.pathname && url.pathname !== '/' ? url.pathname : undefined,
|
|
81
|
-
query,
|
|
82
|
-
raw,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export function addressPort(addr) {
|
|
86
|
-
return addr.port ?? DEFAULT_PORTS[addr.scheme];
|
|
87
|
-
}
|
|
88
|
-
export function sshTarget(addr) {
|
|
89
|
-
if (addr.scheme !== 'ssh') {
|
|
90
|
-
throw new Error(`expected ssh:// or user@host, got ${addr.scheme}:// (${addr.raw})`);
|
|
91
|
-
}
|
|
92
|
-
return addr.user ? `${addr.user}@${addr.host}` : addr.host;
|
|
93
|
-
}
|
|
94
|
-
export function sshPortArgs(addr) {
|
|
95
|
-
if (addr.scheme !== 'ssh') {
|
|
96
|
-
throw new Error(`expected ssh:// or user@host, got ${addr.scheme}:// (${addr.raw})`);
|
|
97
|
-
}
|
|
98
|
-
return addr.port === undefined ? [] : ['-o', `Port=${addr.port}`];
|
|
99
|
-
}
|
|
100
|
-
export function vncEndpoint(addr) {
|
|
101
|
-
if (addr.scheme !== 'vnc') {
|
|
102
|
-
throw new Error(`expected vnc://, got ${addr.scheme}:// (${addr.raw})`);
|
|
103
|
-
}
|
|
104
|
-
return `${addr.host}:${addressPort(addr)}`;
|
|
105
|
-
}
|
|
106
|
-
export function tcpEndpoint(addr) {
|
|
107
|
-
if (addr.scheme !== 'tcp') {
|
|
108
|
-
throw new Error(`expected tcp://, got ${addr.scheme}:// (${addr.raw})`);
|
|
109
|
-
}
|
|
110
|
-
if (addr.port === undefined) {
|
|
111
|
-
throw new Error(`tcp:// requires a port (${addr.raw})`);
|
|
112
|
-
}
|
|
113
|
-
return `${addr.host}:${addr.port}`;
|
|
114
|
-
}
|
|
115
|
-
export function browserEndpointPort(addr) {
|
|
116
|
-
const fromQuery = addr.query.port ? Number.parseInt(addr.query.port, 10) : undefined;
|
|
117
|
-
if (fromQuery !== undefined) {
|
|
118
|
-
if (!Number.isInteger(fromQuery) || fromQuery <= 0 || fromQuery > 65535) {
|
|
119
|
-
throw new Error(`Invalid address ${JSON.stringify(addr.raw)}: bad ?port`);
|
|
120
|
-
}
|
|
121
|
-
return fromQuery;
|
|
122
|
-
}
|
|
123
|
-
if (addr.scheme === 'ssh')
|
|
124
|
-
return 9222;
|
|
125
|
-
if (addr.port !== undefined)
|
|
126
|
-
return addr.port;
|
|
127
|
-
return addr.scheme === 'cdp' ? 9222 : undefined;
|
|
128
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ComputerActionEvent } from '../computer-client.js';
|
|
2
|
-
export declare const TASK_PREVIEW_MAX_CHARS = 200;
|
|
3
|
-
export declare const COMPUTER_INVOCATION_ID: `${string}-${string}-${string}-${string}-${string}`;
|
|
4
|
-
export declare function recordComputerAction(event: ComputerActionEvent, opts?: {
|
|
5
|
-
device?: string;
|
|
6
|
-
}): void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { emit as emitEvent } from '../feed/events.js';
|
|
3
|
-
import { truncate } from '../feed/events.js';
|
|
4
|
-
export const TASK_PREVIEW_MAX_CHARS = 200;
|
|
5
|
-
export const COMPUTER_INVOCATION_ID = randomUUID();
|
|
6
|
-
export function recordComputerAction(event, opts = {}) {
|
|
7
|
-
const { event: _kind, command, invocationId, pid: _enginePid, host, sessionId, launchId, actor: _actor, ...rest } = event;
|
|
8
|
-
const runId = invocationId || COMPUTER_INVOCATION_ID;
|
|
9
|
-
const drivenHost = host ?? opts.device;
|
|
10
|
-
const extra = typeof rest.task === 'string'
|
|
11
|
-
? { ...rest, task: truncate(rest.task, TASK_PREVIEW_MAX_CHARS) }
|
|
12
|
-
: rest;
|
|
13
|
-
try {
|
|
14
|
-
emitEvent('computer.action', {
|
|
15
|
-
command,
|
|
16
|
-
invocationId: runId,
|
|
17
|
-
...(drivenHost ? { host: drivenHost } : {}),
|
|
18
|
-
...(sessionId ? { sessionId } : {}),
|
|
19
|
-
...(launchId ? { launchId } : {}),
|
|
20
|
-
...extra,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type SpawnSyncOptions } from 'child_process';
|
|
2
|
-
interface OpenClawKeychainMigrationOptions {
|
|
3
|
-
account?: string;
|
|
4
|
-
provider?: string;
|
|
5
|
-
agentsBin?: string;
|
|
6
|
-
}
|
|
7
|
-
interface OpenClawKeychainMigrationResult {
|
|
8
|
-
services: Array<{
|
|
9
|
-
envKey: string;
|
|
10
|
-
service: string;
|
|
11
|
-
value: string;
|
|
12
|
-
}>;
|
|
13
|
-
replacedPaths: string[];
|
|
14
|
-
removedEnvPaths: string[];
|
|
15
|
-
unsupportedEnvKeys: string[];
|
|
16
|
-
changed: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface JsonObject {
|
|
19
|
-
[key: string]: unknown;
|
|
20
|
-
}
|
|
21
|
-
export declare function migrateOpenClawConfigToKeychainRefs(config: JsonObject, opts?: OpenClawKeychainMigrationOptions): OpenClawKeychainMigrationResult;
|
|
22
|
-
export declare function buildOpenClawKeychainStoreInvocation(service: string, value: string, account?: string): {
|
|
23
|
-
command: string;
|
|
24
|
-
args: string[];
|
|
25
|
-
options: SpawnSyncOptions & {
|
|
26
|
-
input: string;
|
|
27
|
-
detached: boolean;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
interface OpenClawExecResolverRequest {
|
|
31
|
-
protocolVersion?: number;
|
|
32
|
-
provider?: string;
|
|
33
|
-
ids?: unknown;
|
|
34
|
-
}
|
|
35
|
-
interface OpenClawExecResolverResponse {
|
|
36
|
-
protocolVersion: 1;
|
|
37
|
-
values: Record<string, string>;
|
|
38
|
-
errors?: Record<string, {
|
|
39
|
-
code: string;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
42
|
-
export declare function resolveOpenClawKeychainRequest(request: OpenClawExecResolverRequest, lookup: (service: string) => string): OpenClawExecResolverResponse;
|
|
43
|
-
export {};
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { getCliLaunch } from './cli-entry.js';
|
|
2
|
-
/**
|
|
3
|
-
* argv for writing a bare (non-`agents-cli.`) keychain item via
|
|
4
|
-
* `/usr/bin/security add-generic-password`, deliberately WITHOUT the value: the
|
|
5
|
-
* secret travels over stdin (see below) so it never lands in argv or a `ps`
|
|
6
|
-
* snapshot. Pure — no agents-cli secrets engine involved (this migration writes
|
|
7
|
-
* directly to the OpenClaw account's OWN macOS keychain entries, bypassing the
|
|
8
|
-
* `agents secrets` bundle store entirely), so it's a local helper rather than a
|
|
9
|
-
* process-client call.
|
|
10
|
-
*/
|
|
11
|
-
function buildAddGenericPasswordArgs(account, item) {
|
|
12
|
-
return ['add-generic-password', '-U', '-a', account, '-s', item, '-w'];
|
|
13
|
-
}
|
|
14
|
-
function buildAddGenericPasswordSpawnOptions(value) {
|
|
15
|
-
// Bare security -w prompts twice. Pipe the value twice and detach so it reads
|
|
16
|
-
// stdin instead of prompting on the controlling /dev/tty.
|
|
17
|
-
return {
|
|
18
|
-
input: `${value}\n${value}\n`,
|
|
19
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
20
|
-
timeout: 10_000,
|
|
21
|
-
detached: true,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const OPENCLAW_KEYCHAIN_ACCOUNT = 'openclaw';
|
|
25
|
-
const OPENCLAW_KEYCHAIN_PROVIDER = 'agents_keychain';
|
|
26
|
-
const OPENCLAW_KEYCHAIN_ENV_SERVICES = {
|
|
27
|
-
OPENROUTER_API_KEY: 'openrouter-api-key',
|
|
28
|
-
LINEAR_API_KEY: 'linear-api-key',
|
|
29
|
-
GRAFANA_API_KEY: 'grafana-api-key',
|
|
30
|
-
POSTHOG_API_KEY: 'posthog-api-key',
|
|
31
|
-
};
|
|
32
|
-
function isRecord(value) {
|
|
33
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
34
|
-
}
|
|
35
|
-
function secretRef(provider, service) {
|
|
36
|
-
return { source: 'exec', provider, id: service };
|
|
37
|
-
}
|
|
38
|
-
function openClawPath(parts) {
|
|
39
|
-
return parts.join('.');
|
|
40
|
-
}
|
|
41
|
-
function collectOpenClawEnv(config) {
|
|
42
|
-
const env = isRecord(config.env) ? config.env : null;
|
|
43
|
-
const out = new Map();
|
|
44
|
-
if (!env)
|
|
45
|
-
return out;
|
|
46
|
-
for (const [key, service] of Object.entries(OPENCLAW_KEYCHAIN_ENV_SERVICES)) {
|
|
47
|
-
void service;
|
|
48
|
-
const top = env[key];
|
|
49
|
-
if (typeof top === 'string' && top.trim()) {
|
|
50
|
-
out.set(key, { path: ['env', key], value: top });
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const vars = isRecord(env.vars) ? env.vars : null;
|
|
54
|
-
const nested = vars?.[key];
|
|
55
|
-
if (typeof nested === 'string' && nested.trim()) {
|
|
56
|
-
out.set(key, { path: ['env', 'vars', key], value: nested });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return out;
|
|
60
|
-
}
|
|
61
|
-
function deletePath(config, parts) {
|
|
62
|
-
let current = config;
|
|
63
|
-
for (const part of parts.slice(0, -1)) {
|
|
64
|
-
if (!isRecord(current))
|
|
65
|
-
return false;
|
|
66
|
-
current = current[part];
|
|
67
|
-
}
|
|
68
|
-
if (!isRecord(current))
|
|
69
|
-
return false;
|
|
70
|
-
const key = parts[parts.length - 1];
|
|
71
|
-
if (!(key in current))
|
|
72
|
-
return false;
|
|
73
|
-
delete current[key];
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
function normalizeObject(value) {
|
|
77
|
-
return isRecord(value) ? value : {};
|
|
78
|
-
}
|
|
79
|
-
function ensureOpenClawKeychainProvider(config, opts, agentsBin) {
|
|
80
|
-
const launch = getCliLaunch(['secrets', 'openclaw-keychain', 'resolve', '--account', opts.account], agentsBin);
|
|
81
|
-
const secrets = normalizeObject(config.secrets);
|
|
82
|
-
const providers = normalizeObject(secrets.providers);
|
|
83
|
-
providers[opts.provider] = {
|
|
84
|
-
source: 'exec',
|
|
85
|
-
command: launch.command,
|
|
86
|
-
args: launch.args,
|
|
87
|
-
jsonOnly: true,
|
|
88
|
-
};
|
|
89
|
-
secrets.providers = providers;
|
|
90
|
-
config.secrets = secrets;
|
|
91
|
-
}
|
|
92
|
-
function providerEnvKeyForPath(parts) {
|
|
93
|
-
if (parts.length === 8 &&
|
|
94
|
-
parts[0] === 'plugins' &&
|
|
95
|
-
parts[1] === 'entries' &&
|
|
96
|
-
parts[3] === 'config' &&
|
|
97
|
-
parts[4] === 'mcpServers' &&
|
|
98
|
-
parts[6] === 'env') {
|
|
99
|
-
return parts[7];
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
function serviceForSupportedPath(parts) {
|
|
104
|
-
const envKey = providerEnvKeyForPath(parts);
|
|
105
|
-
if (envKey)
|
|
106
|
-
return OPENCLAW_KEYCHAIN_ENV_SERVICES[envKey] ?? null;
|
|
107
|
-
if (parts.length === 4 && parts[0] === 'models' && parts[1] === 'providers' && parts[3] === 'apiKey') {
|
|
108
|
-
if (parts[2] === 'openrouter')
|
|
109
|
-
return OPENCLAW_KEYCHAIN_ENV_SERVICES.OPENROUTER_API_KEY;
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
function envKeyForService(service) {
|
|
114
|
-
return Object.entries(OPENCLAW_KEYCHAIN_ENV_SERVICES).find(([, known]) => known === service)?.[0] ?? service;
|
|
115
|
-
}
|
|
116
|
-
function assertSameOpenClawSecretValue(envKey, service, existingPath, existingValue, nextPath, nextValue) {
|
|
117
|
-
if (existingValue === nextValue)
|
|
118
|
-
return;
|
|
119
|
-
throw new Error(`OpenClaw credential value mismatch for ${envKey} (${service}): ${existingPath} and ${nextPath} differ. ` +
|
|
120
|
-
`Resolve the plaintext values before migrating to Keychain.`);
|
|
121
|
-
}
|
|
122
|
-
function canReplaceByValue(parts) {
|
|
123
|
-
if (parts.length === 4 && parts[0] === 'models' && parts[1] === 'providers' && parts[3] === 'apiKey')
|
|
124
|
-
return true;
|
|
125
|
-
if (parts.length === 6 && parts[0] === 'plugins' && parts[1] === 'entries' && parts[3] === 'config' && parts[4] === 'webSearch' && parts[5] === 'apiKey')
|
|
126
|
-
return true;
|
|
127
|
-
if (parts.length === 5 && parts[0] === 'tools' && parts[1] === 'web' && parts[2] === 'search' && parts[4] === 'apiKey')
|
|
128
|
-
return true;
|
|
129
|
-
if (parts.length === 4 && parts[0] === 'tools' && parts[1] === 'web' && parts[2] === 'search' && parts[3] === 'apiKey')
|
|
130
|
-
return true;
|
|
131
|
-
return providerEnvKeyForPath(parts) !== null;
|
|
132
|
-
}
|
|
133
|
-
function replaceSupportedSecrets(current, parts, provider, envByValue, env, services, servicePaths, replacedPaths) {
|
|
134
|
-
if (!isRecord(current) && !Array.isArray(current))
|
|
135
|
-
return;
|
|
136
|
-
const entries = Array.isArray(current)
|
|
137
|
-
? current.map((value, index) => [String(index), value])
|
|
138
|
-
: Object.entries(current);
|
|
139
|
-
for (const [key, value] of entries) {
|
|
140
|
-
const childParts = [...parts, key];
|
|
141
|
-
if (typeof value === 'string' && value.trim() && canReplaceByValue(childParts)) {
|
|
142
|
-
const directService = serviceForSupportedPath(childParts);
|
|
143
|
-
const matchedService = directService ?? envByValue.get(value);
|
|
144
|
-
if (matchedService) {
|
|
145
|
-
const envKey = envKeyForService(matchedService);
|
|
146
|
-
const childPath = openClawPath(childParts);
|
|
147
|
-
const existingService = services.get(matchedService);
|
|
148
|
-
if (existingService) {
|
|
149
|
-
assertSameOpenClawSecretValue(envKey, matchedService, servicePaths.get(matchedService) ?? matchedService, existingService.value, childPath, value);
|
|
150
|
-
}
|
|
151
|
-
if (directService) {
|
|
152
|
-
const envEntry = env.get(envKey);
|
|
153
|
-
if (envEntry) {
|
|
154
|
-
assertSameOpenClawSecretValue(envKey, matchedService, openClawPath(envEntry.path), envEntry.value, childPath, value);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
services.set(matchedService, { envKey, service: matchedService, value });
|
|
158
|
-
servicePaths.set(matchedService, childPath);
|
|
159
|
-
current[key] = secretRef(provider, matchedService);
|
|
160
|
-
replacedPaths.push(childPath);
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
replaceSupportedSecrets(value, childParts, provider, envByValue, env, services, servicePaths, replacedPaths);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
export function migrateOpenClawConfigToKeychainRefs(config, opts = {}) {
|
|
168
|
-
const account = opts.account ?? OPENCLAW_KEYCHAIN_ACCOUNT;
|
|
169
|
-
const provider = opts.provider ?? OPENCLAW_KEYCHAIN_PROVIDER;
|
|
170
|
-
const env = collectOpenClawEnv(config);
|
|
171
|
-
const envByValue = new Map();
|
|
172
|
-
for (const [envKey, entry] of env) {
|
|
173
|
-
envByValue.set(entry.value, OPENCLAW_KEYCHAIN_ENV_SERVICES[envKey]);
|
|
174
|
-
}
|
|
175
|
-
const services = new Map();
|
|
176
|
-
const servicePaths = new Map();
|
|
177
|
-
const replacedPaths = [];
|
|
178
|
-
replaceSupportedSecrets(config, [], provider, envByValue, env, services, servicePaths, replacedPaths);
|
|
179
|
-
const removedEnvPaths = [];
|
|
180
|
-
const unsupportedEnvKeys = [];
|
|
181
|
-
for (const [envKey, entry] of env) {
|
|
182
|
-
const service = OPENCLAW_KEYCHAIN_ENV_SERVICES[envKey];
|
|
183
|
-
const mappedService = services.get(service);
|
|
184
|
-
if (!mappedService) {
|
|
185
|
-
unsupportedEnvKeys.push(envKey);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
assertSameOpenClawSecretValue(envKey, service, servicePaths.get(service) ?? service, mappedService.value, openClawPath(entry.path), entry.value);
|
|
189
|
-
if (deletePath(config, entry.path))
|
|
190
|
-
removedEnvPaths.push(openClawPath(entry.path));
|
|
191
|
-
}
|
|
192
|
-
if (services.size > 0) {
|
|
193
|
-
ensureOpenClawKeychainProvider(config, { account, provider }, opts.agentsBin);
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
services: [...services.values()],
|
|
197
|
-
replacedPaths,
|
|
198
|
-
removedEnvPaths,
|
|
199
|
-
unsupportedEnvKeys,
|
|
200
|
-
changed: services.size > 0 || replacedPaths.length > 0 || removedEnvPaths.length > 0,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
export function buildOpenClawKeychainStoreInvocation(service, value, account = OPENCLAW_KEYCHAIN_ACCOUNT) {
|
|
204
|
-
return {
|
|
205
|
-
command: '/usr/bin/security',
|
|
206
|
-
args: buildAddGenericPasswordArgs(account, service),
|
|
207
|
-
options: buildAddGenericPasswordSpawnOptions(value),
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
export function resolveOpenClawKeychainRequest(request, lookup) {
|
|
211
|
-
const ids = Array.isArray(request.ids) ? request.ids.filter((id) => typeof id === 'string') : [];
|
|
212
|
-
const values = {};
|
|
213
|
-
const errors = {};
|
|
214
|
-
for (const id of ids) {
|
|
215
|
-
try {
|
|
216
|
-
values[id] = lookup(id);
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
errors[id] = { code: 'NOT_FOUND' };
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
protocolVersion: 1,
|
|
224
|
-
values,
|
|
225
|
-
...(Object.keys(errors).length > 0 ? { errors } : {}),
|
|
226
|
-
};
|
|
227
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { type SyncAgentSpec } from './sync/agents.js';
|
|
2
|
-
export declare const BUNDLE_KIND = "agents-session-bundle";
|
|
3
|
-
export interface BundleHeader {
|
|
4
|
-
kind: typeof BUNDLE_KIND;
|
|
5
|
-
version: number;
|
|
6
|
-
exportedAt: string;
|
|
7
|
-
origin: string;
|
|
8
|
-
encrypted: boolean;
|
|
9
|
-
redacted: boolean;
|
|
10
|
-
count: number;
|
|
11
|
-
sessions: number;
|
|
12
|
-
}
|
|
13
|
-
export interface BundleRecord {
|
|
14
|
-
agent: string;
|
|
15
|
-
machine: string;
|
|
16
|
-
sessionId: string;
|
|
17
|
-
relKey: string;
|
|
18
|
-
size: number;
|
|
19
|
-
hash: string;
|
|
20
|
-
label?: string;
|
|
21
|
-
encrypted: boolean;
|
|
22
|
-
body: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ParsedBundle {
|
|
25
|
-
header: BundleHeader;
|
|
26
|
-
records: BundleRecord[];
|
|
27
|
-
}
|
|
28
|
-
export interface FileToExport {
|
|
29
|
-
agent: string;
|
|
30
|
-
machine: string;
|
|
31
|
-
sessionId: string;
|
|
32
|
-
relKey: string;
|
|
33
|
-
absPath: string;
|
|
34
|
-
label?: string;
|
|
35
|
-
}
|
|
36
|
-
interface BuildRecordOpts {
|
|
37
|
-
redact: boolean;
|
|
38
|
-
encryptKey: Buffer | null;
|
|
39
|
-
knownSecrets?: readonly string[];
|
|
40
|
-
}
|
|
41
|
-
export declare function specForAgent(agentId: string): SyncAgentSpec | undefined;
|
|
42
|
-
export declare function buildRecord(file: FileToExport, opts: BuildRecordOpts): BundleRecord;
|
|
43
|
-
export declare function makeHeader(args: {
|
|
44
|
-
origin: string;
|
|
45
|
-
exportedAt: string;
|
|
46
|
-
encrypted: boolean;
|
|
47
|
-
redacted: boolean;
|
|
48
|
-
records: BundleRecord[];
|
|
49
|
-
}): BundleHeader;
|
|
50
|
-
export declare function mergeRecords(sets: BundleRecord[][]): BundleRecord[];
|
|
51
|
-
export declare function serializeBundle(header: BundleHeader, records: BundleRecord[]): string;
|
|
52
|
-
export declare function writeBundleFile(outPath: string, wire: string): void;
|
|
53
|
-
export declare function parseBundle(text: string): ParsedBundle;
|
|
54
|
-
export type ImportStatus = 'new' | 'dup' | 'conflict' | 'unknown';
|
|
55
|
-
export interface ImportPlanItem {
|
|
56
|
-
record: BundleRecord;
|
|
57
|
-
targetPath: string;
|
|
58
|
-
status: ImportStatus;
|
|
59
|
-
}
|
|
60
|
-
interface PlanImportOpts {
|
|
61
|
-
decryptKey: Buffer | null;
|
|
62
|
-
}
|
|
63
|
-
export declare function planImport(bundle: ParsedBundle, opts: PlanImportOpts): ImportPlanItem[];
|
|
64
|
-
export interface WriteResult {
|
|
65
|
-
placed: number;
|
|
66
|
-
skipped: number;
|
|
67
|
-
overwritten: number;
|
|
68
|
-
conflicts: number;
|
|
69
|
-
unknown: number;
|
|
70
|
-
}
|
|
71
|
-
interface WriteImportOpts {
|
|
72
|
-
overwrite: boolean;
|
|
73
|
-
decryptKey: Buffer | null;
|
|
74
|
-
}
|
|
75
|
-
export declare function writeImport(plan: ImportPlanItem[], opts: WriteImportOpts): WriteResult;
|
|
76
|
-
export {};
|