@phnx-labs/agents-cli 1.22.84 → 1.22.86
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 +96 -0
- package/README.md +80 -53
- package/dist/bootstrap.d.ts +7 -6
- package/dist/bootstrap.js +20 -27
- package/dist/cli/command-registry.js +5 -1
- package/dist/commands/accounts.d.ts +6 -13
- package/dist/commands/accounts.js +330 -143
- package/dist/commands/alias.js +7 -3
- package/dist/commands/apply.js +1 -1
- package/dist/commands/auth-mint.d.ts +7 -3
- package/dist/commands/auth-mint.js +21 -9
- package/dist/commands/auth.js +2 -3
- package/dist/commands/browser.js +10 -10
- package/dist/commands/daemon.d.ts +7 -3
- package/dist/commands/daemon.js +40 -25
- package/dist/commands/doctor.js +28 -2
- package/dist/commands/exec.js +87 -39
- package/dist/commands/fleet-capture.js +21 -2
- package/dist/commands/harness-wizard.js +2 -2
- package/dist/commands/lease.js +7 -12
- package/dist/commands/profiles.d.ts +2 -2
- package/dist/commands/profiles.js +20 -13
- package/dist/commands/repo.js +3 -3
- package/dist/commands/run-account-picker.d.ts +3 -3
- package/dist/commands/run-account-picker.js +29 -30
- package/dist/commands/secrets-passthrough.d.ts +20 -0
- package/dist/commands/secrets-passthrough.js +43 -0
- package/dist/commands/setup-accounts.d.ts +3 -2
- package/dist/commands/setup-accounts.js +4 -4
- package/dist/commands/setup-secrets.d.ts +16 -21
- package/dist/commands/setup-secrets.js +43 -224
- package/dist/commands/ssh.js +2 -2
- package/dist/commands/sync.js +1 -1
- package/dist/commands/update.d.ts +10 -0
- package/dist/commands/update.js +43 -40
- package/dist/commands/versions.d.ts +11 -11
- package/dist/commands/versions.js +131 -83
- package/dist/commands/view.d.ts +1 -9
- package/dist/commands/view.js +41 -55
- package/dist/commands/webhook.js +5 -5
- package/dist/commands/workflows.js +2 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +13 -42
- package/dist/lib/account-capabilities.d.ts +1 -1
- package/dist/lib/account-capabilities.js +1 -1
- package/dist/lib/account-catalog.d.ts +121 -6
- package/dist/lib/account-catalog.js +421 -7
- package/dist/lib/account-registry.d.ts +8 -30
- package/dist/lib/account-registry.js +36 -79
- package/dist/lib/account-schema.d.ts +1 -1
- package/dist/lib/account-schema.js +1 -1
- package/dist/lib/accounting/account-pool-collect.js +16 -4
- package/dist/lib/accounting/rotate.d.ts +20 -7
- package/dist/lib/accounting/rotate.js +89 -13
- package/dist/lib/accounting/usage.js +11 -16
- package/dist/lib/accounts/add.d.ts +138 -0
- package/dist/lib/accounts/add.js +651 -0
- package/dist/lib/accounts/migrate.d.ts +117 -0
- package/dist/lib/accounts/migrate.js +536 -0
- package/dist/lib/accounts/slots.d.ts +13 -0
- package/dist/lib/accounts/slots.js +100 -0
- package/dist/lib/agent-spec/agents.d.ts +16 -0
- package/dist/lib/agent-spec/agents.js +38 -4
- package/dist/lib/app-bundle-install.js +5 -4
- package/dist/lib/auth-health.d.ts +3 -0
- package/dist/lib/auth-health.js +11 -0
- package/dist/lib/auth-mint.d.ts +52 -16
- package/dist/lib/auth-mint.js +117 -39
- package/dist/lib/browser/chrome.d.ts +1 -1
- package/dist/lib/browser/chrome.js +5 -5
- package/dist/lib/byok-usage.js +3 -3
- package/dist/lib/claude-account-token.d.ts +47 -3
- package/dist/lib/claude-account-token.js +172 -50
- package/dist/lib/cloud/antigravity.js +4 -4
- package/dist/lib/cloud/cursor.js +4 -4
- package/dist/lib/crabbox/cli.d.ts +1 -1
- package/dist/lib/crabbox/cli.js +6 -6
- package/dist/lib/crabbox/runtimes.d.ts +3 -3
- package/dist/lib/crabbox/runtimes.js +5 -5
- package/dist/lib/daemon/account-state-daemon-service.d.ts +37 -1
- package/dist/lib/daemon/account-state-daemon-service.js +199 -3
- package/dist/lib/daemon/auth-sync-service.js +32 -1
- package/dist/lib/daemon/daemon.d.ts +6 -16
- package/dist/lib/daemon/daemon.js +52 -97
- package/dist/lib/daemon/daemon.test-fixture.d.ts +7 -9
- package/dist/lib/daemon/daemon.test-fixture.js +22 -40
- package/dist/lib/daemon/harness-update-service.d.ts +1 -1
- package/dist/lib/daemon/harness-update-service.js +1 -1
- package/dist/lib/daemon/runner.d.ts +15 -3
- package/dist/lib/daemon/runner.js +49 -24
- package/dist/lib/daemon-health.d.ts +1 -2
- package/dist/lib/daemon-health.js +7 -6
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +1 -11
- package/dist/lib/daemon-webhooks.d.ts +8 -7
- package/dist/lib/daemon-webhooks.js +10 -9
- package/dist/lib/device-config.js +1 -1
- package/dist/lib/devices/doctor-findings.d.ts +1 -1
- package/dist/lib/devices/harness-inventory.d.ts +39 -0
- package/dist/lib/devices/harness-inventory.js +126 -4
- package/dist/lib/doctor-diff.js +2 -1
- package/dist/lib/exec-account-home.d.ts +38 -0
- package/dist/lib/exec-account-home.js +164 -0
- package/dist/lib/exec.d.ts +30 -0
- package/dist/lib/exec.js +101 -31
- package/dist/lib/fleet/apply.d.ts +2 -2
- package/dist/lib/fleet/apply.js +4 -4
- package/dist/lib/fleet/auth-sync.js +4 -3
- package/dist/lib/fleet-shared-repo-sync.js +6 -9
- package/dist/lib/harness/adapter.d.ts +7 -7
- package/dist/lib/harness/adapter.js +10 -6
- package/dist/lib/harness/adapters/grok.js +8 -3
- package/dist/lib/harness/adapters/muse.js +1 -1
- package/dist/lib/harness/adapters/opencode.js +12 -3
- package/dist/lib/harness-auth-capabilities.d.ts +61 -0
- package/dist/lib/harness-auth-capabilities.js +52 -0
- package/dist/lib/helper-versions.d.ts +6 -4
- package/dist/lib/helper-versions.js +5 -4
- package/dist/lib/hosts/credential-transport.d.ts +10 -0
- package/dist/lib/hosts/credential-transport.js +37 -0
- package/dist/lib/hosts/dispatch.d.ts +7 -0
- package/dist/lib/hosts/dispatch.js +13 -6
- package/dist/lib/identity/client.d.ts +3 -3
- package/dist/lib/identity/client.js +3 -3
- package/dist/lib/installations/index.d.ts +1 -1
- package/dist/lib/installations/index.js +1 -1
- package/dist/lib/installations/migrate.js +9 -0
- package/dist/lib/installations/resolve.js +1 -1
- package/dist/lib/installations/shims.d.ts +21 -4
- package/dist/lib/installations/shims.js +86 -5
- package/dist/lib/installations/store.d.ts +43 -0
- package/dist/lib/installations/store.js +75 -7
- package/dist/lib/installations/versions.js +1 -1
- package/dist/lib/menubar/install-menubar.d.ts +3 -3
- package/dist/lib/menubar/install-menubar.js +3 -3
- package/dist/lib/native-accounts.d.ts +35 -0
- package/dist/lib/native-accounts.js +41 -0
- package/dist/lib/net-close.d.ts +11 -0
- package/dist/lib/net-close.js +25 -0
- package/dist/lib/openclaw-keychain.js +27 -1
- package/dist/lib/profiles.js +22 -9
- package/dist/lib/project-resources.js +1 -1
- package/dist/lib/reserved-stores.d.ts +53 -0
- package/dist/lib/reserved-stores.js +120 -0
- package/dist/lib/secrets-client.d.ts +199 -0
- package/dist/lib/secrets-client.js +718 -0
- package/dist/lib/secrets-policy.d.ts +235 -0
- package/dist/lib/secrets-policy.js +505 -0
- package/dist/lib/secrets-types.d.ts +188 -0
- package/dist/lib/secrets-types.js +24 -0
- package/dist/lib/self-heal/checks/shims.js +5 -3
- package/dist/lib/service-manifest.js +3 -4
- package/dist/lib/session/db.d.ts +18 -0
- package/dist/lib/session/db.js +47 -14
- package/dist/lib/session/sync/config.js +2 -2
- package/dist/lib/sha256-asset.d.ts +11 -16
- package/dist/lib/sha256-asset.js +11 -16
- package/dist/lib/share/config.js +14 -5
- package/dist/lib/signin-badge.d.ts +26 -0
- package/dist/lib/signin-badge.js +42 -0
- package/dist/lib/staleness/detectors/workflows.js +3 -105
- package/dist/lib/staleness/writers/workflows.js +2 -1
- package/dist/lib/state.d.ts +7 -4
- package/dist/lib/state.js +18 -7
- package/dist/lib/sync-umbrella.js +2 -2
- package/dist/lib/teams/agents.js +1 -1
- package/dist/lib/types.d.ts +74 -33
- package/dist/lib/view-types.d.ts +6 -3
- package/dist/lib/workflows-registry.d.ts +71 -0
- package/dist/lib/workflows-registry.js +280 -0
- package/dist/lib/workflows.d.ts +21 -21
- package/dist/lib/workflows.js +12 -327
- package/package.json +2 -3
- package/scripts/postinstall.js +35 -30
- package/dist/commands/secrets-import.d.ts +0 -18
- package/dist/commands/secrets-import.js +0 -74
- package/dist/commands/secrets-migrate.d.ts +0 -25
- package/dist/commands/secrets-migrate.js +0 -334
- package/dist/commands/secrets-rotate-passphrase.d.ts +0 -17
- package/dist/commands/secrets-rotate-passphrase.js +0 -96
- package/dist/commands/secrets-sync.d.ts +0 -11
- package/dist/commands/secrets-sync.js +0 -153
- package/dist/commands/secrets-vault.d.ts +0 -10
- package/dist/commands/secrets-vault.js +0 -130
- package/dist/commands/secrets.d.ts +0 -212
- package/dist/commands/secrets.js +0 -3030
- package/dist/lib/accounts/connect.d.ts +0 -176
- package/dist/lib/accounts/connect.js +0 -453
- package/dist/lib/daemon/keychain-reap-service.d.ts +0 -17
- package/dist/lib/daemon/keychain-reap-service.js +0 -32
- package/dist/lib/daemon/secrets-broker-service.d.ts +0 -21
- package/dist/lib/daemon/secrets-broker-service.js +0 -51
- package/dist/lib/secrets/agent.d.ts +0 -358
- package/dist/lib/secrets/agent.js +0 -1291
- package/dist/lib/secrets/audit.d.ts +0 -46
- package/dist/lib/secrets/audit.js +0 -101
- package/dist/lib/secrets/bundles.d.ts +0 -290
- package/dist/lib/secrets/bundles.js +0 -1547
- package/dist/lib/secrets/download-keychain.d.ts +0 -47
- package/dist/lib/secrets/download-keychain.js +0 -70
- package/dist/lib/secrets/drivers/rush.d.ts +0 -14
- package/dist/lib/secrets/drivers/rush.js +0 -90
- package/dist/lib/secrets/fallback.d.ts +0 -48
- package/dist/lib/secrets/fallback.js +0 -48
- package/dist/lib/secrets/filestore.d.ts +0 -222
- package/dist/lib/secrets/filestore.js +0 -1099
- package/dist/lib/secrets/headless.d.ts +0 -43
- package/dist/lib/secrets/headless.js +0 -56
- package/dist/lib/secrets/icloud-import.d.ts +0 -79
- package/dist/lib/secrets/icloud-import.js +0 -206
- package/dist/lib/secrets/index.d.ts +0 -451
- package/dist/lib/secrets/index.js +0 -1568
- package/dist/lib/secrets/install-helper.d.ts +0 -72
- package/dist/lib/secrets/install-helper.js +0 -245
- package/dist/lib/secrets/lease.d.ts +0 -25
- package/dist/lib/secrets/lease.js +0 -44
- package/dist/lib/secrets/linux.d.ts +0 -77
- package/dist/lib/secrets/linux.js +0 -393
- package/dist/lib/secrets/list-filter.d.ts +0 -109
- package/dist/lib/secrets/list-filter.js +0 -261
- package/dist/lib/secrets/mcp.d.ts +0 -93
- package/dist/lib/secrets/mcp.js +0 -211
- package/dist/lib/secrets/profiles.d.ts +0 -10
- package/dist/lib/secrets/profiles.js +0 -13
- package/dist/lib/secrets/push.d.ts +0 -133
- package/dist/lib/secrets/push.js +0 -273
- package/dist/lib/secrets/rc-hygiene.d.ts +0 -63
- package/dist/lib/secrets/rc-hygiene.js +0 -143
- package/dist/lib/secrets/read-backoff.d.ts +0 -27
- package/dist/lib/secrets/read-backoff.js +0 -64
- package/dist/lib/secrets/reaper.d.ts +0 -90
- package/dist/lib/secrets/reaper.js +0 -243
- package/dist/lib/secrets/remote.d.ts +0 -152
- package/dist/lib/secrets/remote.js +0 -344
- package/dist/lib/secrets/reserved-sync.d.ts +0 -66
- package/dist/lib/secrets/reserved-sync.js +0 -147
- package/dist/lib/secrets/scope.d.ts +0 -26
- package/dist/lib/secrets/scope.js +0 -29
- package/dist/lib/secrets/session-store.d.ts +0 -107
- package/dist/lib/secrets/session-store.js +0 -342
- package/dist/lib/secrets/sync-backend.d.ts +0 -48
- package/dist/lib/secrets/sync-backend.js +0 -13
- package/dist/lib/secrets/sync-commands.d.ts +0 -21
- package/dist/lib/secrets/sync-commands.js +0 -21
- package/dist/lib/secrets/sync.d.ts +0 -48
- package/dist/lib/secrets/sync.js +0 -237
- package/dist/lib/secrets/unlock-hints.d.ts +0 -27
- package/dist/lib/secrets/unlock-hints.js +0 -36
- package/dist/lib/secrets/usage-db.d.ts +0 -46
- package/dist/lib/secrets/usage-db.js +0 -96
- package/dist/lib/secrets/vault-age-helper.d.ts +0 -1
- package/dist/lib/secrets/vault-age-helper.js +0 -34
- package/dist/lib/secrets/vault.d.ts +0 -49
- package/dist/lib/secrets/vault.js +0 -399
- package/dist/lib/secrets/windows.d.ts +0 -81
- package/dist/lib/secrets/windows.js +0 -556
- package/scripts/install-helper.js +0 -97
- /package/dist/lib/{secrets/sync-passphrase.d.ts → sync-passphrase.d.ts} +0 -0
- /package/dist/lib/{secrets/sync-passphrase.js → sync-passphrase.js} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved per-harness credential stores (PHNX-3940 / PHNX-3989).
|
|
3
|
+
*
|
|
4
|
+
* One store name per `ALL_AGENT_IDS` entry: `__<harness>__`. A user-created
|
|
5
|
+
* bundle can never collide (the standalone rejects `__`-prefixed names unless
|
|
6
|
+
* explicitly allowed). The legacy `auth` bundle remains a readable alias for
|
|
7
|
+
* `__claude__` — this module does not migrate data.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately a LEAF module (no import of `claude-account-token.ts` or
|
|
10
|
+
* `secrets-policy.ts`): both of those need these constants, and
|
|
11
|
+
* `claude-account-token.ts` is itself a dependency of `secrets-policy.ts`'s
|
|
12
|
+
* fleet-sync helpers — importing this module's exports from `secrets-policy.js`
|
|
13
|
+
* instead would form a real circular import that throws
|
|
14
|
+
* `ReferenceError: Cannot access '...' before initialization` under real ESM
|
|
15
|
+
* evaluation order (reproduced running this suite outside vitest's
|
|
16
|
+
* mock-tolerant transform). Keep it a leaf; `secrets-policy.ts` re-exports it
|
|
17
|
+
* for the existing public surface.
|
|
18
|
+
*/
|
|
19
|
+
import { bundleExistsSync, bundleBackendSync, isSecretsClientError } from './secrets-client.js';
|
|
20
|
+
import { AGENT_IDS } from './types.js';
|
|
21
|
+
/** Legacy readable alias for `__claude__`. Not migrated in this track. */
|
|
22
|
+
export const AUTH_STORE_ALIAS = 'auth';
|
|
23
|
+
/** The one reserved bundle name most callers actually need. */
|
|
24
|
+
export const AUTH_BUNDLE_NAME = AUTH_STORE_ALIAS;
|
|
25
|
+
/**
|
|
26
|
+
* The reserved `auth` bundle holds per-account Claude setup-tokens for
|
|
27
|
+
* unattended usage/probe and MUST be file-backed (headless, fleet-shareable —
|
|
28
|
+
* credential-management.md invariant 7). The standalone enforces the same
|
|
29
|
+
* rule on its write path (`WRONG_BACKEND`); agents-cli asserts it on every
|
|
30
|
+
* read so a keychain/vault-backed `auth` left over from an older layout fails
|
|
31
|
+
* loud instead of silently being ignored by usage/probe (SEC-GAP-3).
|
|
32
|
+
*/
|
|
33
|
+
export const AUTH_BUNDLE_BACKEND = 'file';
|
|
34
|
+
export const RESERVED_BUNDLE_NAMES = new Set([AUTH_BUNDLE_NAME]);
|
|
35
|
+
export function isReservedBundleName(name) {
|
|
36
|
+
return RESERVED_BUNDLE_NAMES.has(name.trim().toLowerCase());
|
|
37
|
+
}
|
|
38
|
+
/** Thrown when the reserved `auth` bundle is found on the wrong backend. */
|
|
39
|
+
export class ReservedBundleWrongBackendError extends Error {
|
|
40
|
+
bundle;
|
|
41
|
+
backend;
|
|
42
|
+
constructor(bundle, backend) {
|
|
43
|
+
super(`Bundle '${bundle}' is reserved for file-backed setup-tokens (headless, fleet-shareable). ` +
|
|
44
|
+
`A ${backend}-backed '${bundle}' bundle is ignored by usage/probe instead of authenticating. ` +
|
|
45
|
+
`Recreate it as file-backed: agents secrets delete ${bundle} --yes && agents secrets create ${bundle} --backend file`);
|
|
46
|
+
this.name = 'ReservedBundleWrongBackendError';
|
|
47
|
+
this.bundle = bundle;
|
|
48
|
+
this.backend = backend;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Fail loud when the reserved `auth` bundle is on any backend but `file`. */
|
|
52
|
+
export function assertReservedAuthBackend(backend) {
|
|
53
|
+
if (backend !== AUTH_BUNDLE_BACKEND)
|
|
54
|
+
throw new ReservedBundleWrongBackendError(AUTH_STORE_ALIAS, backend);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* True for the wrong-backend refusal in either shape: raised here from a
|
|
58
|
+
* read-side check, or returned by the standalone (`WRONG_BACKEND`) when its
|
|
59
|
+
* own write/resolve guard fired.
|
|
60
|
+
*/
|
|
61
|
+
export function isReservedBundleBackendError(error) {
|
|
62
|
+
return error instanceof ReservedBundleWrongBackendError || isSecretsClientError(error, 'WRONG_BACKEND');
|
|
63
|
+
}
|
|
64
|
+
export const RESERVED_STORES = Object.fromEntries(AGENT_IDS.map((id) => [id, `__${id}__`]));
|
|
65
|
+
export function reservedStoreName(harness) {
|
|
66
|
+
const name = RESERVED_STORES[harness];
|
|
67
|
+
if (!name)
|
|
68
|
+
throw new Error(`No reserved store for '${harness}'.`);
|
|
69
|
+
return name;
|
|
70
|
+
}
|
|
71
|
+
export function isReservedStoreName(name) {
|
|
72
|
+
const n = name.trim().toLowerCase();
|
|
73
|
+
if (n === AUTH_STORE_ALIAS)
|
|
74
|
+
return true;
|
|
75
|
+
return AGENT_IDS.some((id) => RESERVED_STORES[id].toLowerCase() === n);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Fail loud at the write boundary: only a setup-token or an API key may enter
|
|
79
|
+
* a reserved store. Rotating OAuth/session credentials stay in their slot on
|
|
80
|
+
* the device that minted them.
|
|
81
|
+
*/
|
|
82
|
+
export function assertStorableCredentialKind(kind, harness) {
|
|
83
|
+
if (kind === 'setup-token' || kind === 'api-key')
|
|
84
|
+
return;
|
|
85
|
+
throw new Error(storableCredentialRefusal(kind, harness));
|
|
86
|
+
}
|
|
87
|
+
function storableCredentialRefusal(kind, harness) {
|
|
88
|
+
if (harness === 'codex')
|
|
89
|
+
return 'codex: auth.json is a rotating session; add an API key instead';
|
|
90
|
+
if (harness === 'droid')
|
|
91
|
+
return 'droid: refresh tokens are single-use and collapse the fleet when copied; add a FACTORY_API_KEY instead';
|
|
92
|
+
if (harness === 'claude')
|
|
93
|
+
return 'claude: native OAuth (.credentials.json) is a rotating session; mint a setup-token instead';
|
|
94
|
+
if (harness === 'grok')
|
|
95
|
+
return 'grok: auth.json is a rotating session; add an XAI_API_KEY instead';
|
|
96
|
+
if (harness === 'kimi' || harness === 'antigravity')
|
|
97
|
+
return `${harness}: no portable worker credential; log in per device`;
|
|
98
|
+
const who = harness ?? 'this harness';
|
|
99
|
+
return `${who}: reserved stores accept only a setup-token or an API key, not '${kind}'`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether the local reserved `auth` bundle exists and is on the expected
|
|
103
|
+
* (file) backend. `ok: true` on a missing bundle — nothing to be wrong about.
|
|
104
|
+
* Read-only status probe (`agents doctor`, `agents fleet apply`); an
|
|
105
|
+
* unreachable standalone is treated the same as "bundle absent" so a
|
|
106
|
+
* diagnostic never crashes over one optional finding.
|
|
107
|
+
*/
|
|
108
|
+
export function inspectReservedAuthBundle() {
|
|
109
|
+
let exists;
|
|
110
|
+
try {
|
|
111
|
+
exists = bundleExistsSync(AUTH_BUNDLE_NAME);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return { exists: false, backend: null, ok: true };
|
|
115
|
+
}
|
|
116
|
+
if (!exists)
|
|
117
|
+
return { exists: false, backend: null, ok: true };
|
|
118
|
+
const backend = bundleBackendSync(AUTH_BUNDLE_NAME);
|
|
119
|
+
return { exists: true, backend, ok: backend === AUTH_BUNDLE_BACKEND };
|
|
120
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { SecretsBundle, SecretsBackend, ResolveBundleOptions, WriteBundleOptions, BundleEntryInfo, RenameOptions, RotateOptions, BundleValue, KeychainReadContext, SecretRef, AgentStatusEntry, PushBundleOptions, PushBundleResult, RemoteBundleSummary, PullOptions, RcSecretFinding } from './secrets-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wire contract, mirrored from `secrets-cli/src/protocol.ts`. Both sides MUST
|
|
4
|
+
* agree byte-for-byte; this is the shared schema of the seam, the one thing an
|
|
5
|
+
* independent client legitimately re-declares rather than imports.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
8
|
+
export interface SecretsContext {
|
|
9
|
+
/** Bundle allowlist; absent ⇒ full trust (the local agents client today). */
|
|
10
|
+
allowedBundles?: string[];
|
|
11
|
+
/** Opaque scope the standalone folds into resolution — the harness name. */
|
|
12
|
+
scope?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Serialize `Map`s the way the server's `decodeWire` expects to receive them. */
|
|
15
|
+
export declare function encodeWire(value: unknown): unknown;
|
|
16
|
+
/** Reconstruct `Map`s from the server's `encodeWire`'d reply. */
|
|
17
|
+
export declare function decodeWire(value: unknown): unknown;
|
|
18
|
+
/** Carries the server's `{code, message}`, or a client-side transport code. */
|
|
19
|
+
export declare class SecretsClientError extends Error {
|
|
20
|
+
readonly code: string;
|
|
21
|
+
constructor(code: string, message: string);
|
|
22
|
+
/**
|
|
23
|
+
* Serialize to a plain `{code, message}`. A consumer that folds a failure into
|
|
24
|
+
* a structure it later `JSON.stringify`s (a teammate's meta.json, a failure
|
|
25
|
+
* record, a spawn env) must never make the serializer chase this Error's
|
|
26
|
+
* internal references and throw `Converting circular structure to JSON`
|
|
27
|
+
* mid-launch — the value here is the two fields a caller actually needs.
|
|
28
|
+
*/
|
|
29
|
+
toJSON(): {
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** True when `error` is a {@link SecretsClientError}, optionally with the given code. */
|
|
35
|
+
export declare function isSecretsClientError(error: unknown, code?: string): error is SecretsClientError;
|
|
36
|
+
/** True when `error` is a {@link SecretsClientError} from the transport itself (the
|
|
37
|
+
* standalone was unreachable/unusable), not a data error it answered with. */
|
|
38
|
+
export declare function isSecretsTransportError(error: unknown): error is SecretsClientError;
|
|
39
|
+
export declare const SECRETS_ITEM_PREFIX = "agents-cli.secrets.";
|
|
40
|
+
/** The raw item holding one bundle key's value. */
|
|
41
|
+
export declare function secretsKeychainItem(bundle: string, key: string): string;
|
|
42
|
+
/** The raw item holding a profile provider's token (`agents-cli.<provider>.token`). */
|
|
43
|
+
export declare function profileKeychainItem(provider: string): string;
|
|
44
|
+
/** The bundle-var form that points a key at its own raw item. */
|
|
45
|
+
export declare function keychainRef(key: string): string;
|
|
46
|
+
export type { BundleValue, SecretRef };
|
|
47
|
+
/**
|
|
48
|
+
* Parse a bundle value into either a literal string or a typed secret ref. A
|
|
49
|
+
* `{ value }` object is an escaped literal (a URL that happens to start with a
|
|
50
|
+
* ref prefix is never misread as a reference).
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseBundleValue(raw: BundleValue): {
|
|
53
|
+
literal: string;
|
|
54
|
+
} | {
|
|
55
|
+
ref: SecretRef;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the standalone `secrets` executable: `$SECRETS_BIN` if set, else the
|
|
59
|
+
* `secrets` command on PATH — resolved with `findInPath`, which skips agents-cli's
|
|
60
|
+
* own shims dir. That skip is load-bearing, not tidiness: before PHNX-3989 the
|
|
61
|
+
* shims dir carried a `secrets` command shim that `exec`s `agents secrets`, it
|
|
62
|
+
* sits FIRST on PATH, and it survives an in-place upgrade (its baked entrypoint
|
|
63
|
+
* still exists). A plain `which secrets` returned that shim, so `agents secrets`
|
|
64
|
+
* → shim → `agents secrets` → … spawned an unbounded process chain on every box
|
|
65
|
+
* upgraded from 1.22.84 (the whole fleet, via R5 auto-update). A `secrets` inside
|
|
66
|
+
* our shims dir can never be the standalone, so it is not a candidate at all.
|
|
67
|
+
* Cached for the process. A miss throws with install guidance — there is NO
|
|
68
|
+
* fallback to the embedded engine (DIST-1).
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveSecretsBin(): string;
|
|
71
|
+
/**
|
|
72
|
+
* How to invoke the resolved binary. A `.js`/`.mjs`/`.cjs` entrypoint (a dev
|
|
73
|
+
* build, or `$SECRETS_BIN` pointing at `dist/index.js`) is run through this
|
|
74
|
+
* process's Node so it works without an executable bit and on Windows; an
|
|
75
|
+
* installed `secrets` shim/binary is spawned directly. Exported so a caller
|
|
76
|
+
* that needs to run an interactive standalone verb directly (e.g. `secrets
|
|
77
|
+
* migrate`, which isn't in this client's op table) can build the same argv.
|
|
78
|
+
*/
|
|
79
|
+
export declare function invocation(bin: string): {
|
|
80
|
+
command: string;
|
|
81
|
+
prefix: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Spawn env for the child, applied to a base env (defaults to `process.env`):
|
|
85
|
+
*
|
|
86
|
+
* - `SECRETS_HOME` defaults to the user agents dir so the standalone adopts the
|
|
87
|
+
* existing stores in place (MIG-1); an explicit value in the base env wins.
|
|
88
|
+
* - The standalone renamed every `AGENTS_SECRETS_*` knob to `SECRETS_*`, so a
|
|
89
|
+
* caller env still carrying the old `AGENTS_SECRETS_PASSPHRASE` (the name
|
|
90
|
+
* agents-cli's own engine reads — filestore/linux/windows) would be invisible
|
|
91
|
+
* to `secrets`, which reads only `SECRETS_PASSPHRASE`. Forward it so the child
|
|
92
|
+
* can decrypt the very file store agents-cli wrote, rather than silently
|
|
93
|
+
* provisioning a fresh machine-local key. An explicit `SECRETS_PASSPHRASE`
|
|
94
|
+
* wins — this only bridges the rename, it never overrides.
|
|
95
|
+
*
|
|
96
|
+
* Exported for the seam test (a pure env mapping, no spawn).
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildServeEnv(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
99
|
+
/**
|
|
100
|
+
* Send one operation to the standalone secrets CLI and await its typed result.
|
|
101
|
+
* Verifies the executable speaks protocol v1 once per process (cached), then
|
|
102
|
+
* spawns `secrets __serve` for the operation. Throws a {@link SecretsClientError}
|
|
103
|
+
* carrying the server's `{code, message}` on failure.
|
|
104
|
+
*/
|
|
105
|
+
export declare function secretsRequest<T = unknown>(op: string, args?: unknown[], context?: SecretsContext): Promise<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Synchronous sibling of {@link secretsRequest} for the consumers that resolve
|
|
108
|
+
* secrets on a synchronous path (e.g. building a child env before spawn).
|
|
109
|
+
* Bounded by a spawn timeout. POSIX only.
|
|
110
|
+
*/
|
|
111
|
+
export declare function secretsRequestSync<T = unknown>(op: string, args?: unknown[], context?: SecretsContext): T;
|
|
112
|
+
/** Test hook: forget the cached binary + handshake so a new env is re-resolved. */
|
|
113
|
+
export declare function _resetSecretsClientForTest(): void;
|
|
114
|
+
export declare function readAndResolveBundleEnv(name: string, opts?: ResolveBundleOptions, context?: SecretsContext): Promise<{
|
|
115
|
+
bundle: SecretsBundle;
|
|
116
|
+
env: Record<string, string>;
|
|
117
|
+
}>;
|
|
118
|
+
export declare function readAndResolveBundleEnvSync(name: string, opts?: ResolveBundleOptions, context?: SecretsContext): {
|
|
119
|
+
bundle: SecretsBundle;
|
|
120
|
+
env: Record<string, string>;
|
|
121
|
+
};
|
|
122
|
+
export declare function listBundles(context?: SecretsContext): Promise<SecretsBundle[]>;
|
|
123
|
+
export declare function listBundlesSync(context?: SecretsContext): SecretsBundle[];
|
|
124
|
+
/**
|
|
125
|
+
* Per-key kind breakdown (`literal`/`file`/`onepassword`/…) of an already-resolved
|
|
126
|
+
* bundle — the cosmetic `[secrets] Resolved <name>: N keys (…)` summary line. Pure
|
|
127
|
+
* over the bundle document server-side; the wrapper forwards the object the caller
|
|
128
|
+
* already holds from {@link readAndResolveBundleEnv} so the same shape is described.
|
|
129
|
+
*/
|
|
130
|
+
export declare function describeBundle(bundle: SecretsBundle, context?: SecretsContext): Promise<BundleEntryInfo[]>;
|
|
131
|
+
export declare function readBundle(name: string, context?: SecretsContext): Promise<SecretsBundle>;
|
|
132
|
+
export declare function readBundleSync(name: string, context?: SecretsContext): SecretsBundle;
|
|
133
|
+
export declare function bundleExists(name: string, context?: SecretsContext): Promise<boolean>;
|
|
134
|
+
export declare function bundleExistsSync(name: string, context?: SecretsContext): boolean;
|
|
135
|
+
export declare function bundleBackend(name: string, context?: SecretsContext): Promise<SecretsBackend>;
|
|
136
|
+
export declare function bundleBackendSync(name: string, context?: SecretsContext): SecretsBackend;
|
|
137
|
+
export declare function writeBundle(bundle: SecretsBundle, opts?: WriteBundleOptions, context?: SecretsContext): Promise<void>;
|
|
138
|
+
export declare function writeBundleWithItems(bundle: SecretsBundle, items: Map<string, string>, opts?: WriteBundleOptions, context?: SecretsContext): Promise<void>;
|
|
139
|
+
export declare function writeBundleWithItemsSync(bundle: SecretsBundle, items: Map<string, string>, opts?: WriteBundleOptions, context?: SecretsContext): void;
|
|
140
|
+
export declare function deleteBundle(name: string, context?: SecretsContext): Promise<boolean>;
|
|
141
|
+
export declare function deleteBundleSync(name: string, context?: SecretsContext): boolean;
|
|
142
|
+
/** Rename a bundle: metadata and raw items move together; the source is deleted last. */
|
|
143
|
+
export declare function renameBundle(oldName: string, newName: string, opts?: RenameOptions, context?: SecretsContext): Promise<void>;
|
|
144
|
+
export declare function renameBundleSync(oldName: string, newName: string, opts?: RenameOptions, context?: SecretsContext): void;
|
|
145
|
+
/** Rotate one keychain-backed key's value in place, preserving or patching its meta. */
|
|
146
|
+
export declare function rotateBundleSecret(bundle: SecretsBundle, key: string, opts: RotateOptions, context?: SecretsContext): Promise<void>;
|
|
147
|
+
export declare function rotateBundleSecretSync(bundle: SecretsBundle, key: string, opts: RotateOptions, context?: SecretsContext): void;
|
|
148
|
+
export declare function agentPing(): Promise<{
|
|
149
|
+
reachable: boolean;
|
|
150
|
+
cliVersion?: string;
|
|
151
|
+
}>;
|
|
152
|
+
export declare function agentPingSync(): {
|
|
153
|
+
reachable: boolean;
|
|
154
|
+
cliVersion?: string;
|
|
155
|
+
};
|
|
156
|
+
export declare function agentStatus(): Promise<AgentStatusEntry[]>;
|
|
157
|
+
export declare function agentLock(name?: string): Promise<number>;
|
|
158
|
+
export declare function ensureAgentRunning(timeoutMs?: number): Promise<boolean>;
|
|
159
|
+
export declare function getKeychainToken(item: string, context?: KeychainReadContext): Promise<string>;
|
|
160
|
+
export declare function getKeychainTokenSync(item: string, context?: KeychainReadContext): string;
|
|
161
|
+
export declare function setKeychainToken(item: string, value: string, opts?: {
|
|
162
|
+
noAcl?: boolean;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
export declare function setKeychainTokenSync(item: string, value: string, opts?: {
|
|
165
|
+
noAcl?: boolean;
|
|
166
|
+
}): void;
|
|
167
|
+
export declare function hasKeychainToken(item: string): Promise<boolean>;
|
|
168
|
+
export declare function hasKeychainTokenSync(item: string): boolean;
|
|
169
|
+
export declare function deleteKeychainToken(item: string): Promise<boolean>;
|
|
170
|
+
export declare function deleteKeychainTokenSync(item: string): boolean;
|
|
171
|
+
export declare function listKeychainItems(prefix: string): Promise<string[]>;
|
|
172
|
+
/**
|
|
173
|
+
* True when `keychain`-backend items are being routed to the standalone's
|
|
174
|
+
* encrypted file store (headless Linux/Windows with no reachable keyring):
|
|
175
|
+
* on such a host no test or probe can reach a real OS keychain.
|
|
176
|
+
*/
|
|
177
|
+
export declare function keychainUsesFileFallback(): Promise<boolean>;
|
|
178
|
+
export declare function storeGet(backend: SecretsBackend, item: string): Promise<string>;
|
|
179
|
+
export declare function storeGetSync(backend: SecretsBackend, item: string): string;
|
|
180
|
+
export declare function storeHas(backend: SecretsBackend, item: string): Promise<boolean>;
|
|
181
|
+
export declare function storeHasSync(backend: SecretsBackend, item: string): boolean;
|
|
182
|
+
export declare function storeSet(backend: SecretsBackend, item: string, value: string): Promise<void>;
|
|
183
|
+
export declare function storeSetSync(backend: SecretsBackend, item: string, value: string): void;
|
|
184
|
+
export declare function storeDelete(backend: SecretsBackend, item: string): Promise<boolean>;
|
|
185
|
+
export declare function remoteResolveEnv(target: string, bundle: string, opts?: {
|
|
186
|
+
osLookupName?: string;
|
|
187
|
+
}): Promise<Record<string, string>>;
|
|
188
|
+
export declare function pushBundleToHost(bundle: string, host: string, opts: PushBundleOptions): Promise<PushBundleResult>;
|
|
189
|
+
export declare function pushBundleToHostAsync(bundle: string, host: string, opts: PushBundleOptions): Promise<PushBundleResult>;
|
|
190
|
+
export declare function listRemoteBundles(context?: SecretsContext): Promise<RemoteBundleSummary[]>;
|
|
191
|
+
export declare function pullBundle(name: string, opts: PullOptions, context?: SecretsContext): Promise<SecretsBundle>;
|
|
192
|
+
export declare function scanUserRcFiles(homeDir?: string, context?: SecretsContext): Promise<RcSecretFinding[]>;
|
|
193
|
+
export declare function scanUserRcFilesSync(homeDir?: string, context?: SecretsContext): RcSecretFinding[];
|
|
194
|
+
export declare function masterPassphraseInEnv(context?: SecretsContext): Promise<boolean>;
|
|
195
|
+
export declare function masterPassphraseInEnvSync(context?: SecretsContext): boolean;
|
|
196
|
+
/** True for a dynamic-loader or language-interpreter override env var. */
|
|
197
|
+
export declare function isLoaderOrInterpreterEnv(name: string): boolean;
|
|
198
|
+
/** Strip loader/interpreter overrides from an env before it reaches a spawned child. */
|
|
199
|
+
export declare function sanitizeProcessEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|