@phnx-labs/agents-cli 1.23.17 → 1.23.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +239 -0
- package/README.md +140 -165
- package/dist/bootstrap.js +11 -17
- package/dist/cli/command-registry.d.ts +1 -2
- package/dist/cli/command-registry.js +1 -10
- package/dist/commands/accounts.js +7 -7
- package/dist/commands/cloud-transcripts.d.ts +0 -1
- package/dist/commands/cloud-transcripts.js +2 -2
- package/dist/commands/cloud.js +2 -2
- package/dist/commands/config.js +1 -5
- package/dist/commands/cost.js +1 -1
- package/dist/commands/daemon-index.js +0 -1
- package/dist/commands/detach.d.ts +1 -1
- package/dist/commands/detach.js +10 -6
- package/dist/commands/doctor.js +11 -7
- package/dist/commands/exec.d.ts +0 -17
- package/dist/commands/exec.js +26 -72
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +3 -3
- package/dist/commands/focus.d.ts +11 -6
- package/dist/commands/focus.js +91 -31
- package/dist/commands/fork.d.ts +0 -1
- package/dist/commands/fork.js +7 -16
- package/dist/commands/harness-wizard.js +1 -1
- package/dist/commands/harness.js +1 -1
- package/dist/commands/insights.d.ts +0 -1
- package/dist/commands/insights.js +3 -7
- package/dist/commands/open.js +1 -1
- package/dist/commands/output.js +1 -1
- package/dist/commands/profiles.d.ts +1 -1
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/projects-todo.js +10 -5
- package/dist/commands/projects.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/ps.d.ts +8 -3
- package/dist/commands/ps.js +238 -110
- package/dist/commands/routines.js +1 -1
- package/dist/commands/send.js +1 -1
- package/dist/commands/sessions-backfill.d.ts +0 -1
- package/dist/commands/sessions-backfill.js +3 -6
- package/dist/commands/sessions-browser.d.ts +0 -10
- package/dist/commands/sessions-browser.js +19 -25
- package/dist/commands/sessions-migrate.d.ts +2 -2
- package/dist/commands/sessions-migrate.js +13 -13
- package/dist/commands/sessions-optimize.d.ts +0 -1
- package/dist/commands/sessions-optimize.js +0 -3
- package/dist/commands/sessions-picker.d.ts +0 -7
- package/dist/commands/sessions-picker.js +16 -310
- package/dist/commands/sessions-resume.d.ts +16 -15
- package/dist/commands/sessions-resume.js +101 -269
- package/dist/commands/sessions-stats.d.ts +0 -1
- package/dist/commands/sessions-stats.js +5 -8
- package/dist/commands/sessions-stop.d.ts +1 -1
- package/dist/commands/sessions-stop.js +8 -8
- package/dist/commands/sessions-trace.d.ts +1 -1
- package/dist/commands/sessions-trace.js +40 -17
- package/dist/commands/sessions-watch.js +2 -2
- package/dist/commands/sessions.test-fixture.d.ts +1 -0
- package/dist/commands/sessions.test-fixture.js +14 -0
- package/dist/commands/setup-browser.js +4 -4
- package/dist/commands/setup-computer.js +4 -4
- package/dist/commands/setup-fleet.js +1 -1
- package/dist/commands/setup-preferences.js +1 -1
- package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
- package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
- package/dist/commands/setup.js +3 -1
- package/dist/commands/ssh.js +4 -5
- package/dist/commands/sync.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/utils.d.ts +0 -1
- package/dist/commands/utils.js +0 -10
- package/dist/index.js +0 -71
- package/dist/lib/account-registry.d.ts +3 -0
- package/dist/lib/account-registry.js +40 -0
- package/dist/lib/accounting/usage-sync.d.ts +1 -0
- package/dist/lib/accounting/usage-sync.js +20 -3
- package/dist/lib/accounting/usage.d.ts +4 -1
- package/dist/lib/accounting/usage.js +38 -6
- package/dist/lib/agent-spec/agents.js +12 -11
- package/dist/lib/analytics/mix-commands.js +1 -1
- package/dist/lib/auth-mint.js +2 -2
- package/dist/lib/browser-client.d.ts +0 -1
- package/dist/lib/browser-client.js +0 -3
- package/dist/lib/cloud/antigravity.js +1 -1
- package/dist/lib/cloud/cursor.js +3 -3
- package/dist/lib/cloud/store.d.ts +5 -1
- package/dist/lib/cloud/store.js +10 -3
- package/dist/lib/cloudflare/creds.js +2 -2
- package/dist/lib/computer/context.d.ts +4 -21
- package/dist/lib/computer/context.js +3 -24
- package/dist/lib/computer/policy.d.ts +0 -10
- package/dist/lib/computer/policy.js +0 -28
- package/dist/lib/computer-client.d.ts +0 -44
- package/dist/lib/computer-client.js +17 -121
- package/dist/lib/config-keys.d.ts +2 -2
- package/dist/lib/config-keys.js +1 -3
- package/dist/lib/crabbox/cli.js +1 -1
- package/dist/lib/daemon/account-state-daemon-service.js +9 -2
- package/dist/lib/daemon/self-update-service.js +1 -1
- package/dist/lib/device-config.d.ts +2 -1
- package/dist/lib/device-config.js +26 -39
- package/dist/lib/devices/connect.d.ts +1 -1
- package/dist/lib/devices/connect.js +3 -6
- package/dist/lib/devices/doctor-findings.d.ts +2 -1
- package/dist/lib/devices/doctor-findings.js +4 -4
- package/dist/lib/devices/health.d.ts +6 -0
- package/dist/lib/devices/health.js +11 -4
- package/dist/lib/exec.js +1 -1
- package/dist/lib/feed/activity.js +1 -1
- package/dist/lib/feed/watch.js +2 -1
- package/dist/lib/fleet/apply.d.ts +1 -1
- package/dist/lib/fleet/apply.js +6 -3
- package/dist/lib/fleet-shared-state.d.ts +2 -0
- package/dist/lib/fleet-shared-state.js +3 -1
- package/dist/lib/github/project-prs.js +14 -1
- package/dist/lib/help.d.ts +0 -1
- package/dist/lib/help.js +2 -10
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/option.js +1 -1
- package/dist/lib/hosts/passthrough.d.ts +0 -1
- package/dist/lib/hosts/passthrough.js +2 -26
- package/dist/lib/hosts/reconnect.js +5 -5
- package/dist/lib/hosts/remote-cmd.d.ts +3 -5
- package/dist/lib/hosts/remote-cmd.js +15 -20
- package/dist/lib/hosts/remote-session-id.js +1 -1
- package/dist/lib/installations/active-check.js +1 -1
- package/dist/lib/installations/migrate.js +4 -15
- package/dist/lib/installations/versions.js +5 -4
- package/dist/lib/launch-log.js +3 -6
- package/dist/lib/owner-notify.d.ts +1 -6
- package/dist/lib/owner-notify.js +0 -2
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -8
- package/dist/lib/permissions.js +1 -1
- package/dist/lib/project-root.d.ts +1 -0
- package/dist/lib/project-root.js +11 -3
- package/dist/lib/projects.js +2 -2
- package/dist/lib/quick-todo.d.ts +5 -1
- package/dist/lib/quick-todo.js +14 -1
- package/dist/lib/redact.d.ts +0 -1
- package/dist/lib/redact.js +0 -4
- package/dist/lib/remote-agents-json.d.ts +3 -1
- package/dist/lib/remote-agents-json.js +12 -8
- package/dist/lib/reserved-stores.js +1 -1
- package/dist/lib/scheduling/routines.d.ts +0 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/self-update.d.ts +1 -1
- package/dist/lib/self-update.js +59 -2
- package/dist/lib/session/active.d.ts +1 -1
- package/dist/lib/session/db.js +4 -4
- package/dist/lib/session/detached.d.ts +0 -1
- package/dist/lib/session/detached.js +0 -23
- package/dist/lib/session/discover.d.ts +2 -2
- package/dist/lib/session/glance-files.d.ts +21 -0
- package/dist/lib/session/glance-files.js +123 -0
- package/dist/lib/session/presentation.d.ts +3 -7
- package/dist/lib/session/presentation.js +4 -4
- package/dist/lib/session/preview-digest.d.ts +13 -0
- package/dist/lib/session/preview-digest.js +328 -0
- package/dist/lib/session/projection.js +1 -1
- package/dist/lib/session/remote/remote-list.d.ts +5 -2
- package/dist/lib/session/remote/remote-list.js +15 -8
- package/dist/lib/session/remote/watch.d.ts +2 -0
- package/dist/lib/session/remote/watch.js +90 -10
- package/dist/lib/session/remote-active.js +1 -1
- package/dist/lib/session/resume-command.d.ts +0 -1
- package/dist/lib/session/resume-command.js +1 -4
- package/dist/lib/session/resume-owner.d.ts +0 -2
- package/dist/lib/session/resume-owner.js +0 -6
- package/dist/lib/session/selection.d.ts +4 -5
- package/dist/lib/session/selection.js +2 -2
- package/dist/lib/session/sync/config.d.ts +0 -25
- package/dist/lib/session/sync/config.js +0 -62
- package/dist/lib/session/sync/managed-config.d.ts +0 -1
- package/dist/lib/session/sync/managed-config.js +0 -3
- package/dist/lib/session/sync/worker-template.js +1 -1
- package/dist/lib/sessions-client.d.ts +0 -16
- package/dist/lib/sessions-client.js +1 -187
- package/dist/lib/smart-launch.js +6 -1
- package/dist/lib/startup/command-registry.d.ts +2 -0
- package/dist/lib/startup/command-registry.js +36 -3
- package/dist/lib/startup/root-command.d.ts +0 -1
- package/dist/lib/startup/root-command.js +0 -21
- package/dist/lib/sync-umbrella.js +1 -1
- package/dist/lib/teams/placement-probe.d.ts +2 -0
- package/dist/lib/teams/placement-probe.js +8 -3
- package/dist/lib/terminal/engine.d.ts +2 -0
- package/dist/lib/terminal/engine.js +5 -3
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/resolve.js +1 -1
- package/dist/lib/terminal/run-surface.d.ts +1 -0
- package/dist/lib/terminal/run-surface.js +9 -0
- package/dist/lib/watchdog/rotate.js +1 -1
- package/dist/lib/watchdog/watchdog.d.ts +1 -1
- package/dist/lib/watchdog/watchdog.js +2 -2
- package/package.json +1 -1
- package/dist/commands/browser.d.ts +0 -7
- package/dist/commands/browser.js +0 -139
- package/dist/commands/computer.d.ts +0 -48
- package/dist/commands/computer.js +0 -244
- package/dist/commands/resume.d.ts +0 -23
- package/dist/commands/resume.js +0 -158
- package/dist/commands/secrets-passthrough.d.ts +0 -3
- package/dist/commands/secrets-passthrough.js +0 -52
- package/dist/commands/sessions-bookmark.d.ts +0 -2
- package/dist/commands/sessions-bookmark.js +0 -92
- package/dist/commands/sessions-export.d.ts +0 -31
- package/dist/commands/sessions-export.js +0 -409
- package/dist/commands/sessions-import.d.ts +0 -6
- package/dist/commands/sessions-import.js +0 -343
- package/dist/commands/sessions-inject.d.ts +0 -14
- package/dist/commands/sessions-inject.js +0 -143
- package/dist/commands/sessions-picker-factory.d.ts +0 -24
- package/dist/commands/sessions-picker-factory.js +0 -59
- package/dist/commands/sessions-render.d.ts +0 -11
- package/dist/commands/sessions-render.js +0 -119
- package/dist/commands/sessions-share.d.ts +0 -15
- package/dist/commands/sessions-share.js +0 -171
- package/dist/commands/sessions.d.ts +0 -122
- package/dist/commands/sessions.js +0 -1760
- package/dist/lib/address.d.ts +0 -39
- package/dist/lib/address.js +0 -128
- package/dist/lib/computer/record.d.ts +0 -6
- package/dist/lib/computer/record.js +0 -25
- package/dist/lib/onepassword.d.ts +0 -57
- package/dist/lib/onepassword.js +0 -140
- package/dist/lib/openclaw-keychain.d.ts +0 -43
- package/dist/lib/openclaw-keychain.js +0 -227
- package/dist/lib/session/bundle.d.ts +0 -76
- package/dist/lib/session/bundle.js +0 -146
- package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
- package/dist/lib/session/remote/remote-bundle.js +0 -40
- package/dist/lib/session/remote/remote.d.ts +0 -35
- package/dist/lib/session/remote/remote.js +0 -198
- package/dist/lib/session/remote-bundle.d.ts +0 -1
- package/dist/lib/session/remote-bundle.js +0 -1
- package/dist/lib/session/remote.d.ts +0 -1
- package/dist/lib/session/remote.js +0 -1
- package/dist/lib/session/sync/agents.d.ts +0 -24
- package/dist/lib/session/sync/agents.js +0 -0
- package/dist/lib/session/sync/backend.d.ts +0 -22
- package/dist/lib/session/sync/backend.js +0 -44
- package/dist/lib/session/sync/managed-key.d.ts +0 -5
- package/dist/lib/session/sync/managed-key.js +0 -87
- package/dist/lib/session/sync/net-client.d.ts +0 -29
- package/dist/lib/session/sync/net-client.js +0 -87
- package/dist/lib/session/sync/r2.d.ts +0 -20
- package/dist/lib/session/sync/r2.js +0 -103
- package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
- package/dist/lib/session/sync/transcript-crypto.js +0 -115
package/dist/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,57 +0,0 @@
|
|
|
1
|
-
interface OpItemSummary {
|
|
2
|
-
id: string;
|
|
3
|
-
title: string;
|
|
4
|
-
category: string;
|
|
5
|
-
vault: {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export interface OpField {
|
|
11
|
-
id: string;
|
|
12
|
-
label: string;
|
|
13
|
-
type: string;
|
|
14
|
-
value?: string;
|
|
15
|
-
purpose?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface OpItem extends OpItemSummary {
|
|
18
|
-
fields: OpField[];
|
|
19
|
-
}
|
|
20
|
-
interface ImportableSecret {
|
|
21
|
-
envKey: string;
|
|
22
|
-
itemTitle: string;
|
|
23
|
-
fieldLabel: string;
|
|
24
|
-
value: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
}
|
|
27
|
-
interface SkippedField {
|
|
28
|
-
itemTitle: string;
|
|
29
|
-
fieldLabel: string;
|
|
30
|
-
reason: string;
|
|
31
|
-
}
|
|
32
|
-
export declare function getItem(itemId: string, vaultName: string): OpItem;
|
|
33
|
-
export declare function toEnvKey(title: string): string;
|
|
34
|
-
export declare function slugify(name: string): string;
|
|
35
|
-
export declare function itemToSecret(item: OpItem): {
|
|
36
|
-
secret: ImportableSecret;
|
|
37
|
-
} | {
|
|
38
|
-
skipped: SkippedField;
|
|
39
|
-
};
|
|
40
|
-
export declare function extractSecrets(items: OpItemSummary[], vaultName: string): {
|
|
41
|
-
secrets: ImportableSecret[];
|
|
42
|
-
skipped: SkippedField[];
|
|
43
|
-
};
|
|
44
|
-
interface PasswordItemTemplate {
|
|
45
|
-
title: string;
|
|
46
|
-
category: 'PASSWORD';
|
|
47
|
-
tags: string[];
|
|
48
|
-
fields: Array<{
|
|
49
|
-
id: string;
|
|
50
|
-
type: 'CONCEALED';
|
|
51
|
-
purpose: 'PASSWORD';
|
|
52
|
-
label: string;
|
|
53
|
-
value: string;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
export declare function buildPasswordItemTemplate(title: string, value: string): PasswordItemTemplate;
|
|
57
|
-
export {};
|
package/dist/lib/onepassword.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'child_process';
|
|
2
|
-
function runOp(args, input) {
|
|
3
|
-
const result = spawnSync('op', args, {
|
|
4
|
-
stdio: [input !== undefined ? 'pipe' : 'ignore', 'pipe', 'pipe'],
|
|
5
|
-
encoding: 'utf-8',
|
|
6
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
7
|
-
input,
|
|
8
|
-
});
|
|
9
|
-
if (result.error) {
|
|
10
|
-
if (result.error.code === 'ENOENT') {
|
|
11
|
-
return { ok: false, error: '1Password CLI not found. Install: brew install 1password-cli' };
|
|
12
|
-
}
|
|
13
|
-
return { ok: false, error: result.error.message };
|
|
14
|
-
}
|
|
15
|
-
if (result.status !== 0) {
|
|
16
|
-
const stderr = result.stderr?.trim() || '';
|
|
17
|
-
if (stderr.includes('not signed in') || stderr.includes('sign in') || stderr.includes('no active session')) {
|
|
18
|
-
return { ok: false, error: 'Not signed in to 1Password. Run: op signin' };
|
|
19
|
-
}
|
|
20
|
-
return { ok: false, error: stderr || `op exited with code ${result.status}` };
|
|
21
|
-
}
|
|
22
|
-
return { ok: true, stdout: result.stdout };
|
|
23
|
-
}
|
|
24
|
-
export function getItem(itemId, vaultName) {
|
|
25
|
-
const result = runOp(['item', 'get', itemId, '--vault', vaultName, '--format=json', '--reveal']);
|
|
26
|
-
if (!result.ok)
|
|
27
|
-
throw new Error(result.error);
|
|
28
|
-
return JSON.parse(result.stdout);
|
|
29
|
-
}
|
|
30
|
-
export function toEnvKey(title) {
|
|
31
|
-
return title
|
|
32
|
-
.toUpperCase()
|
|
33
|
-
.replace(/[^A-Z0-9]+/g, '_')
|
|
34
|
-
.replace(/^_+|_+$/g, '')
|
|
35
|
-
.replace(/^(\d)/, '_$1');
|
|
36
|
-
}
|
|
37
|
-
export function slugify(name) {
|
|
38
|
-
return name
|
|
39
|
-
.toLowerCase()
|
|
40
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
41
|
-
.replace(/^-+|-+$/g, '');
|
|
42
|
-
}
|
|
43
|
-
const IMPORTABLE_FIELD_TYPES = new Set([
|
|
44
|
-
'CONCEALED', 'concealed',
|
|
45
|
-
'STRING', 'string', 'text', 'TEXT',
|
|
46
|
-
'URL', 'url',
|
|
47
|
-
]);
|
|
48
|
-
const SKIP_FIELD_LABELS = new Set(['username', 'notesPlain', 'notes']);
|
|
49
|
-
const NOTES_FIELD_LABELS = new Set(['notesplain', 'notes']);
|
|
50
|
-
function pickBestField(fields) {
|
|
51
|
-
const dominated = fields.filter((f) => IMPORTABLE_FIELD_TYPES.has(f.type) &&
|
|
52
|
-
f.value &&
|
|
53
|
-
!SKIP_FIELD_LABELS.has(f.label?.toLowerCase() || ''));
|
|
54
|
-
if (dominated.length === 0)
|
|
55
|
-
return null;
|
|
56
|
-
const concealed = dominated.find((f) => f.type.toLowerCase() === 'concealed');
|
|
57
|
-
if (concealed)
|
|
58
|
-
return concealed;
|
|
59
|
-
const secretLabels = ['credential', 'password', 'secret', 'key', 'token', 'api_key', 'apikey'];
|
|
60
|
-
const labeled = dominated.find((f) => secretLabels.includes(f.label?.toLowerCase() || ''));
|
|
61
|
-
if (labeled)
|
|
62
|
-
return labeled;
|
|
63
|
-
return dominated[0];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The item's notes, if any — a NOTES-purpose field (1Password's `notesPlain`)
|
|
67
|
-
* or a field labelled notes/notesPlain, whichever carries a non-empty value.
|
|
68
|
-
* Returns undefined when the item has no notes. This is descriptive metadata
|
|
69
|
-
* only; it is deliberately independent of value selection and is never picked
|
|
70
|
-
* as the secret value (see SKIP_FIELD_LABELS / pickBestField).
|
|
71
|
-
*/
|
|
72
|
-
function pickNotes(fields) {
|
|
73
|
-
const notes = fields.find((f) => f.value != null &&
|
|
74
|
-
f.value.trim() !== '' &&
|
|
75
|
-
(f.purpose?.toUpperCase() === 'NOTES' ||
|
|
76
|
-
NOTES_FIELD_LABELS.has(f.label?.toLowerCase() || '')));
|
|
77
|
-
const value = notes?.value?.trim();
|
|
78
|
-
return value ? value : undefined;
|
|
79
|
-
}
|
|
80
|
-
export function itemToSecret(item) {
|
|
81
|
-
const field = pickBestField(item.fields || []);
|
|
82
|
-
if (!field) {
|
|
83
|
-
return { skipped: { itemTitle: item.title, fieldLabel: '*', reason: 'no importable fields' } };
|
|
84
|
-
}
|
|
85
|
-
if (field.value.includes('\n')) {
|
|
86
|
-
return {
|
|
87
|
-
skipped: {
|
|
88
|
-
itemTitle: item.title,
|
|
89
|
-
fieldLabel: field.label,
|
|
90
|
-
reason: 'contains newlines (keychain limitation)',
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
const secret = {
|
|
95
|
-
envKey: toEnvKey(item.title),
|
|
96
|
-
itemTitle: item.title,
|
|
97
|
-
fieldLabel: field.label,
|
|
98
|
-
value: field.value,
|
|
99
|
-
};
|
|
100
|
-
const description = pickNotes(item.fields || []);
|
|
101
|
-
if (description)
|
|
102
|
-
secret.description = description;
|
|
103
|
-
return { secret };
|
|
104
|
-
}
|
|
105
|
-
export function extractSecrets(items, vaultName) {
|
|
106
|
-
const secrets = [];
|
|
107
|
-
const skipped = [];
|
|
108
|
-
for (const summary of items) {
|
|
109
|
-
let item;
|
|
110
|
-
try {
|
|
111
|
-
item = getItem(summary.id, vaultName);
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
skipped.push({
|
|
115
|
-
itemTitle: summary.title,
|
|
116
|
-
fieldLabel: '*',
|
|
117
|
-
reason: err.message,
|
|
118
|
-
});
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const result = itemToSecret(item);
|
|
122
|
-
if ('skipped' in result) {
|
|
123
|
-
skipped.push(result.skipped);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
secrets.push(result.secret);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return { secrets, skipped };
|
|
130
|
-
}
|
|
131
|
-
export function buildPasswordItemTemplate(title, value) {
|
|
132
|
-
return {
|
|
133
|
-
title,
|
|
134
|
-
category: 'PASSWORD',
|
|
135
|
-
tags: ['agents-cli'],
|
|
136
|
-
fields: [
|
|
137
|
-
{ id: 'password', type: 'CONCEALED', purpose: 'PASSWORD', label: 'password', value },
|
|
138
|
-
],
|
|
139
|
-
};
|
|
140
|
-
}
|
|
@@ -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
|
-
}
|