@phnx-labs/agents-cli 1.22.84 → 1.22.85
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 +57 -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/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 +32 -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 +28 -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 +15 -0
- package/dist/lib/installations/shims.js +69 -0
- 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 +191 -0
- package/dist/lib/secrets-client.js +710 -0
- package/dist/lib/secrets-policy.d.ts +222 -0
- package/dist/lib/secrets-policy.js +483 -0
- package/dist/lib/secrets-types.d.ts +188 -0
- package/dist/lib/secrets-types.js +24 -0
- 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 +4 -29
- 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
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export type SecretAuditEvent = 'secrets.get' | 'secrets.unlocked' | 'secrets.create' | 'secrets.import' | 'secrets.export' | 'secrets.view' | 'secrets.lease-denied' | 'secrets.lease-expire';
|
|
2
|
-
export interface SecretAuditParams {
|
|
3
|
-
/** Which audit event this is — a read (`secrets.get`) or an unlock grant. */
|
|
4
|
-
event: SecretAuditEvent;
|
|
5
|
-
/** Bundle name (never a value). */
|
|
6
|
-
bundle?: string;
|
|
7
|
-
/** Raw keychain item/service name for `secrets get <item>` (never a value). */
|
|
8
|
-
item?: string;
|
|
9
|
-
/** Free-form operation/caller label, e.g. 'export to shell', 'unlock'. */
|
|
10
|
-
operation?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Where the read/grant originated: agent | session | reveal | raw-item |
|
|
13
|
-
* remote | sync-push | broker | broker+durable.
|
|
14
|
-
*/
|
|
15
|
-
source?: string;
|
|
16
|
-
status?: 'success' | 'error';
|
|
17
|
-
/** Env/key NAMES exposed — names only, never values. */
|
|
18
|
-
keys?: string[];
|
|
19
|
-
keyCount?: number;
|
|
20
|
-
/** Subset of `keys` backed by the OS keychain — names only. */
|
|
21
|
-
keychainKeys?: string[];
|
|
22
|
-
/** Count of resolved values by kind (literal / keychain / env / ...). */
|
|
23
|
-
kindCounts?: Record<string, number>;
|
|
24
|
-
/**
|
|
25
|
-
* Resolving agent/harness identity the access was scoped to (`*` = a global
|
|
26
|
-
* grant readable by every harness). Falls back to `$AGENTS_AGENT_NAME`.
|
|
27
|
-
*/
|
|
28
|
-
agent?: string;
|
|
29
|
-
/** Remote host the value was pulled from, when applicable. */
|
|
30
|
-
host?: string;
|
|
31
|
-
/** Grant lifetime in ms (`secrets.unlocked` only). */
|
|
32
|
-
ttlMs?: number;
|
|
33
|
-
error?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The agent/harness identity to attribute a secret access to. Explicit callers
|
|
37
|
-
* (the bundle reader knows the scope it resolved under) win; otherwise fall back
|
|
38
|
-
* to the ambient `$AGENTS_AGENT_NAME` set on every agent launch.
|
|
39
|
-
*/
|
|
40
|
-
export declare function resolveAuditAgent(explicit?: string): string | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Emit one value-free secret audit event to the raw/operational event stream and
|
|
43
|
-
* the persisted audit log. Only ever pass metadata — the secret value must never
|
|
44
|
-
* reach this function.
|
|
45
|
-
*/
|
|
46
|
-
export declare function emitSecretAudit(p: SecretAuditParams): void;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical audit emitter for every `agents secrets` lifecycle/access event.
|
|
3
|
-
*
|
|
4
|
-
* This is the ONE write path for secret events. Every path that creates,
|
|
5
|
-
* imports, exports, views, reads a VALUE from, or unlocks a bundle funnels its
|
|
6
|
-
* audit through here, so the operational event stream — `agents events`, backed
|
|
7
|
-
* by the dated append-only `~/.agents/.history/events/` audit log — carries a uniform,
|
|
8
|
-
* value-free provenance record: bundle, key NAMES, the resolving agent/harness
|
|
9
|
-
* identity, operation, source, status. The ts / host / session / caller fields
|
|
10
|
-
* are filled in by `emit()` itself. The secret VALUE is never part of the
|
|
11
|
-
* payload; this helper only ever receives metadata, and `emit()`'s
|
|
12
|
-
* `sanitizePayload` is a second redaction layer.
|
|
13
|
-
*
|
|
14
|
-
* The same call also mirrors the event into the per-bundle usage read-model DB
|
|
15
|
-
* (`~/.agents/secrets/secrets.db`, lib/secrets/usage-db.ts) so `secrets view` /
|
|
16
|
-
* `list` / `activity` can answer "how often / how recently / by whom was this
|
|
17
|
-
* bundle used?" without scanning the whole event stream — a DERIVED index fed
|
|
18
|
-
* off this chokepoint, not a second write path a caller has to remember.
|
|
19
|
-
*
|
|
20
|
-
* The event vocabulary, all audit-level and non-milestone (so they surface in
|
|
21
|
-
* `agents events` and the persisted audit trail, but are NOT required in the
|
|
22
|
-
* curated `agents feed` surface):
|
|
23
|
-
* - `secrets.get` — a value was READ (exec inject, export, `view --reveal`,
|
|
24
|
-
* raw `get <item>`, remote resolve, sync push,
|
|
25
|
-
* `run --secrets`, and every other bundle read).
|
|
26
|
-
* - `secrets.unlocked` — a bundle was GRANTED into the secrets broker / durable
|
|
27
|
-
* session by `agents secrets unlock`, then readable
|
|
28
|
-
* prompt-free for the grant TTL.
|
|
29
|
-
* - `secrets.create` — a new bundle was created.
|
|
30
|
-
* - `secrets.import` — keys were imported into a bundle (file / ssh / 1password).
|
|
31
|
-
* - `secrets.export` — a bundle's values were exported (file / shell / ssh /
|
|
32
|
-
* 1password). Exporting also READS the values, so the
|
|
33
|
-
* underlying resolve emits its own `secrets.get`.
|
|
34
|
-
* - `secrets.view` — a bundle's (masked) metadata was inspected via `view`.
|
|
35
|
-
*/
|
|
36
|
-
import { emit } from '../feed/events.js';
|
|
37
|
-
import { recordSecretUsage } from './usage-db.js';
|
|
38
|
-
/**
|
|
39
|
-
* Map each audit event onto the usage-DB kind it is counted as. `secrets.get` is
|
|
40
|
-
* the injection/read access; the rest map 1:1 to their lifecycle kind.
|
|
41
|
-
*/
|
|
42
|
-
const USAGE_KIND = {
|
|
43
|
-
'secrets.get': 'access',
|
|
44
|
-
'secrets.unlocked': 'unlock',
|
|
45
|
-
'secrets.create': 'create',
|
|
46
|
-
'secrets.import': 'import',
|
|
47
|
-
'secrets.export': 'export',
|
|
48
|
-
'secrets.view': 'view',
|
|
49
|
-
'secrets.lease-denied': 'access',
|
|
50
|
-
'secrets.lease-expire': 'access',
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* The agent/harness identity to attribute a secret access to. Explicit callers
|
|
54
|
-
* (the bundle reader knows the scope it resolved under) win; otherwise fall back
|
|
55
|
-
* to the ambient `$AGENTS_AGENT_NAME` set on every agent launch.
|
|
56
|
-
*/
|
|
57
|
-
export function resolveAuditAgent(explicit) {
|
|
58
|
-
const a = explicit || process.env.AGENTS_AGENT_NAME;
|
|
59
|
-
return a && a.length > 0 ? a : undefined;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Emit one value-free secret audit event to the raw/operational event stream and
|
|
63
|
-
* the persisted audit log. Only ever pass metadata — the secret value must never
|
|
64
|
-
* reach this function.
|
|
65
|
-
*/
|
|
66
|
-
export function emitSecretAudit(p) {
|
|
67
|
-
const agent = resolveAuditAgent(p.agent);
|
|
68
|
-
emit(p.event, {
|
|
69
|
-
module: 'secrets',
|
|
70
|
-
...(p.bundle !== undefined ? { bundle: p.bundle } : {}),
|
|
71
|
-
...(p.item !== undefined ? { item: p.item } : {}),
|
|
72
|
-
...(p.operation !== undefined ? { operation: p.operation } : {}),
|
|
73
|
-
...(p.source !== undefined ? { source: p.source } : {}),
|
|
74
|
-
...(p.status !== undefined ? { status: p.status } : {}),
|
|
75
|
-
...(p.keys !== undefined ? { keys: p.keys } : {}),
|
|
76
|
-
...(p.keyCount !== undefined ? { keyCount: p.keyCount } : {}),
|
|
77
|
-
...(p.keychainKeys !== undefined ? { keychainKeys: p.keychainKeys } : {}),
|
|
78
|
-
...(p.kindCounts !== undefined ? { kindCounts: p.kindCounts } : {}),
|
|
79
|
-
...(agent !== undefined ? { agent } : {}),
|
|
80
|
-
...(p.host !== undefined ? { host: p.host } : {}),
|
|
81
|
-
...(p.ttlMs !== undefined ? { ttlMs: p.ttlMs } : {}),
|
|
82
|
-
...(p.error !== undefined ? { error: p.error } : {}),
|
|
83
|
-
});
|
|
84
|
-
// Mirror the event into the per-bundle usage read-model so `secrets view` /
|
|
85
|
-
// `list` / `activity` can report frequency and recency without scanning the
|
|
86
|
-
// whole event stream. Fed off THIS chokepoint alongside the events.jsonl
|
|
87
|
-
// write, never a second write path. Per-bundle only — a raw `secrets get
|
|
88
|
-
// <item>` has no bundle, so it stays in the events.jsonl audit but is not
|
|
89
|
-
// counted as bundle usage. Best-effort inside usage-db (swallows errors).
|
|
90
|
-
if (p.bundle) {
|
|
91
|
-
recordSecretUsage({
|
|
92
|
-
bundle: p.bundle,
|
|
93
|
-
event: USAGE_KIND[p.event],
|
|
94
|
-
agent,
|
|
95
|
-
host: p.host,
|
|
96
|
-
source: p.source,
|
|
97
|
-
status: p.status,
|
|
98
|
-
keyCount: p.keyCount,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secret bundles — named sets of environment variables backed by a secret store.
|
|
3
|
-
* Metadata lives under `agents-cli.bundles.<name>`; values under
|
|
4
|
-
* `agents-cli.secrets.<bundle>.<key>`. Backends: `keychain` (default),
|
|
5
|
-
* `file` (headless/passphrase), and `vault` (age-encrypted, user-synced).
|
|
6
|
-
*/
|
|
7
|
-
import { type BundleValue, type SecretRef } from './index.js';
|
|
8
|
-
/** Which store carries a bundle's items. */
|
|
9
|
-
export type SecretsBackend = 'keychain' | 'file' | 'vault';
|
|
10
|
-
/** Disable the broker-only guard for in-memory keychain tests. */
|
|
11
|
-
export declare function setKeychainAgentOnlyBypassForTest(bypass: boolean): void;
|
|
12
|
-
/**
|
|
13
|
-
* Discover a bundle's backend by location. File store is checked first (a plain
|
|
14
|
-
* existence test, no passphrase); absent/locked vault falls back to keychain.
|
|
15
|
-
*/
|
|
16
|
-
export declare function bundleBackend(name: string): SecretsBackend;
|
|
17
|
-
/** Allowed values for a secret's `type` metadata field. */
|
|
18
|
-
export declare const SECRET_TYPES: readonly ["api-key", "token", "password", "url", "database-url", "ssh-key", "certificate", "webhook", "note"];
|
|
19
|
-
export type SecretType = typeof SECRET_TYPES[number];
|
|
20
|
-
/** Per-secret metadata; absent fields are omitted at write time. */
|
|
21
|
-
export interface VarMeta {
|
|
22
|
-
type?: SecretType;
|
|
23
|
-
/** Future-dated ISO date ('YYYY-MM-DD'). */
|
|
24
|
-
expires?: string;
|
|
25
|
-
note?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Bundle prompt policy. `hold` (default): one Touch ID per hold window (~7d),
|
|
29
|
-
* then silent via the secrets-agent. `always`: prompt every read. `never`: no
|
|
30
|
-
* biometry ACL — least-safe, automation-only. Configurable via `secrets.policy`;
|
|
31
|
-
* persisted under the legacy `tier` key for cross-version sync.
|
|
32
|
-
*/
|
|
33
|
-
export type SecretsPolicy = 'always' | 'hold' | 'never';
|
|
34
|
-
/** A named set of environment variable definitions backed by secret stores. */
|
|
35
|
-
export interface SecretsBundle {
|
|
36
|
-
name: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
allow_exec?: boolean;
|
|
39
|
-
/** Absent ⇒ `keychain`. */
|
|
40
|
-
backend?: SecretsBackend;
|
|
41
|
-
/** Absent ⇒ configured default (`hold`). */
|
|
42
|
-
policy?: SecretsPolicy;
|
|
43
|
-
created_at?: string;
|
|
44
|
-
updated_at?: string;
|
|
45
|
-
last_used?: string;
|
|
46
|
-
vars: Record<string, BundleValue>;
|
|
47
|
-
meta?: Record<string, VarMeta>;
|
|
48
|
-
}
|
|
49
|
-
export interface LegacyBundleCandidate {
|
|
50
|
-
name: string;
|
|
51
|
-
file: string;
|
|
52
|
-
keys: string[];
|
|
53
|
-
}
|
|
54
|
-
export declare const BUNDLE_NAME_PATTERN: RegExp;
|
|
55
|
-
export declare const ENV_KEY_PATTERN: RegExp;
|
|
56
|
-
export declare const BUNDLE_KEY_PATTERN: RegExp;
|
|
57
|
-
export declare const BUNDLE_META_PREFIX = "agents-cli.bundles.";
|
|
58
|
-
export declare const RESERVED_ENV_NAMES: Set<string>;
|
|
59
|
-
/**
|
|
60
|
-
* Reserved FILE-BACKED bundle for long-lived setup tokens. Must be file-backed;
|
|
61
|
-
* a keychain/vault `auth` bundle is a misconfiguration and is ignored.
|
|
62
|
-
*/
|
|
63
|
-
export declare const AUTH_BUNDLE_NAME = "auth";
|
|
64
|
-
export declare const AUTH_BUNDLE_BACKEND: SecretsBackend;
|
|
65
|
-
export declare const RESERVED_BUNDLE_NAMES: Set<string>;
|
|
66
|
-
export declare function isReservedBundleName(name: string): boolean;
|
|
67
|
-
/** Thrown when a reserved bundle is written or resolved on the wrong backend. */
|
|
68
|
-
export declare class ReservedBundleWrongBackendError extends Error {
|
|
69
|
-
readonly bundle: string;
|
|
70
|
-
readonly backend: SecretsBackend;
|
|
71
|
-
constructor(bundle: string, backend: SecretsBackend);
|
|
72
|
-
}
|
|
73
|
-
/** Fail loud when a reserved bundle is on the wrong backend. */
|
|
74
|
-
export declare function assertReservedBundleBackend(name: string, backend: SecretsBackend): void;
|
|
75
|
-
/**
|
|
76
|
-
* Check the reserved `auth` bundle. `ok` is true when absent or file-backed.
|
|
77
|
-
*
|
|
78
|
-
* Read-only status probe (`agents doctor`, `agents fleet apply`) — unlike the
|
|
79
|
-
* destructive-write guards `bundleExists()`/`hasKeychainToken()` document
|
|
80
|
-
* themselves as failing loud for, a diagnostic MUST NOT crash the whole
|
|
81
|
-
* command because ONE optional finding could not reach the keychain (e.g. the
|
|
82
|
-
* macOS Keychain helper source is unavailable — PHNX-3385). Treat an
|
|
83
|
-
* unreachable keychain the same as "bundle absent": nothing to warn about.
|
|
84
|
-
*/
|
|
85
|
-
export declare function inspectReservedAuthBundle(): {
|
|
86
|
-
exists: boolean;
|
|
87
|
-
backend: SecretsBackend | null;
|
|
88
|
-
ok: boolean;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* After a file-backed import, verify the keys actually decrypt. Import used to
|
|
92
|
-
* report success for ciphertext sealed under a forwarded passphrase this process
|
|
93
|
-
* does not hold.
|
|
94
|
-
*/
|
|
95
|
-
export declare function assertFileBundleDecryptable(name: string, keys: string[]): void;
|
|
96
|
-
export declare function bundleToEnvPrefix(name: string): string;
|
|
97
|
-
export declare function isReservedEnvName(key: string): boolean;
|
|
98
|
-
export declare function bundleKeyToEnvKey(key: string): string;
|
|
99
|
-
export declare function isLoaderOrInterpreterEnv(name: string): boolean;
|
|
100
|
-
export declare function sanitizeProcessEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
101
|
-
/** Validate a bundle name against the allowed pattern. Throws on invalid input. */
|
|
102
|
-
export declare function validateBundleName(name: string): void;
|
|
103
|
-
export declare function validateEnvKey(key: string): void;
|
|
104
|
-
/** Assert that `t` is one of the known SECRET_TYPES. Throws with the allowed list otherwise. */
|
|
105
|
-
export declare function validateSecretType(t: string): asserts t is SecretType;
|
|
106
|
-
/**
|
|
107
|
-
* Validate a future `expires` date. Accepts strict 'YYYY-MM-DD'; end-of-day UTC
|
|
108
|
-
* means "today" is past.
|
|
109
|
-
*/
|
|
110
|
-
export declare function validateExpiresFutureDated(iso: string): void;
|
|
111
|
-
export declare function bundleExists(name: string): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Thrown for file-store ciphertext that will not decrypt (lost/rotated key or
|
|
114
|
-
* tampered store). Narrow: temporarily-locked bundles are recoverable and must
|
|
115
|
-
* not be collapsed here.
|
|
116
|
-
*/
|
|
117
|
-
export declare class BundleUndecryptableError extends Error {
|
|
118
|
-
constructor(message: string);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Read a bundle, returning null only when metadata is present but permanently
|
|
122
|
-
* unreadable (`BundleUndecryptableError`). Other failures — including temporary
|
|
123
|
-
* lockout — rethrow so a healthy bundle is never deleted by mistake.
|
|
124
|
-
*/
|
|
125
|
-
export declare function readBundleIfDecryptable(name: string): SecretsBundle | null;
|
|
126
|
-
export declare function readBundle(name: string): SecretsBundle;
|
|
127
|
-
/** Default policy for bundles without an explicit one (`secrets.policy`). */
|
|
128
|
-
export declare function secretsDefaultPolicy(): SecretsPolicy;
|
|
129
|
-
/** Effective prompt policy of a bundle. */
|
|
130
|
-
export declare function bundlePolicy(bundle: SecretsBundle): SecretsPolicy;
|
|
131
|
-
/** Options for writeBundle. */
|
|
132
|
-
export interface WriteBundleOptions {
|
|
133
|
-
/**
|
|
134
|
-
* Skip evicting the broker-held copy. Only for no-op writers such as
|
|
135
|
-
* stampLastUsed; mutating writes must evict so stale values aren't served.
|
|
136
|
-
*/
|
|
137
|
-
skipBrokerEviction?: boolean;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Whether a bundle write should evict the broker-held copy. Exported for tests.
|
|
141
|
-
* Skips when the writer opted out, the broker is disabled, or a test backend is
|
|
142
|
-
* active (so tests don't evict the user's real unlocks).
|
|
143
|
-
*/
|
|
144
|
-
export declare function shouldEvictAfterBundleWrite(skipRequested: boolean, noAgentEnv: string | undefined, backendOverridden: boolean): boolean;
|
|
145
|
-
export declare function writeBundle(bundle: SecretsBundle, opts?: WriteBundleOptions): void;
|
|
146
|
-
export declare function writeBundleWithItems(bundle: SecretsBundle, items: Map<string, string>, opts?: WriteBundleOptions): void;
|
|
147
|
-
export declare function deleteBundle(name: string): boolean;
|
|
148
|
-
declare function readBundleMetaIndex(): string[] | null;
|
|
149
|
-
declare function writeBundleMetaIndex(services: string[]): void;
|
|
150
|
-
declare function addBundleToMetaIndex(name: string): void;
|
|
151
|
-
declare function removeBundleFromMetaIndex(name: string): void;
|
|
152
|
-
/** Test-only accessors for the metadata-name index. Never called in production. */
|
|
153
|
-
export declare const __metaIndexForTest: {
|
|
154
|
-
read: typeof readBundleMetaIndex;
|
|
155
|
-
write: typeof writeBundleMetaIndex;
|
|
156
|
-
add: typeof addBundleToMetaIndex;
|
|
157
|
-
remove: typeof removeBundleFromMetaIndex;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Re-write keychain metadata items without the biometry ACL. The caller supplies
|
|
161
|
-
* the JSON already read, so contents are preserved and no extra read is issued.
|
|
162
|
-
* Exported for tests.
|
|
163
|
-
*/
|
|
164
|
-
export declare function healKeychainBundleMetadata(metaJsonByName: Map<string, string>): number;
|
|
165
|
-
/**
|
|
166
|
-
* One-time driver for healKeychainBundleMetadata. macOS + real keychain only;
|
|
167
|
-
* gated by a sentinel. Best-effort: a heal failure never breaks listing.
|
|
168
|
-
*/
|
|
169
|
-
export declare function healKeychainBundleMetadataAclOnce(metaJsonByName: Map<string, string>): void;
|
|
170
|
-
export declare function listBundles(): SecretsBundle[];
|
|
171
|
-
export interface BundleEntryInfo {
|
|
172
|
-
key: string;
|
|
173
|
-
kind: 'literal' | 'keychain' | 'env' | 'file' | 'exec';
|
|
174
|
-
detail: string;
|
|
175
|
-
}
|
|
176
|
-
export declare function describeBundle(bundle: SecretsBundle): BundleEntryInfo[];
|
|
177
|
-
export declare function stampLastUsed(bundle: SecretsBundle): void;
|
|
178
|
-
/** Options for resolveBundleEnv. */
|
|
179
|
-
export interface ResolveBundleOptions {
|
|
180
|
-
caller?: string;
|
|
181
|
-
/** Harness type whose unlock may be reused. */
|
|
182
|
-
agent?: string;
|
|
183
|
-
/** Duration shown in the Touch ID prompt. */
|
|
184
|
-
duration?: string;
|
|
185
|
-
/** Allow this call to raise an interactive biometric prompt. */
|
|
186
|
-
interactiveUnlock?: boolean;
|
|
187
|
-
/** Skip the broker fast-path and read from the keychain directly. */
|
|
188
|
-
noAgent?: boolean;
|
|
189
|
-
/** Resolve only from an already-unlocked broker snapshot; fail before prompting. */
|
|
190
|
-
agentOnly?: boolean;
|
|
191
|
-
/** Inject only these keys. Errors if any requested key is absent. */
|
|
192
|
-
keys?: string[];
|
|
193
|
-
/** Skip the per-key expiry gate. */
|
|
194
|
-
allowExpired?: boolean;
|
|
195
|
-
/** `process` projects dotted keys to shell-safe env names; `storage` preserves them. */
|
|
196
|
-
keyMode?: 'process' | 'storage';
|
|
197
|
-
}
|
|
198
|
-
export declare function canCacheResolvedEnv(bundle: SecretsBundle, selectedKeys: Set<string>, keyMode: ResolveBundleOptions['keyMode']): boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Apply --keys and --allow-expired to a broker snapshot so the fast path
|
|
201
|
-
* mirrors the slow path's gates. Exported for tests.
|
|
202
|
-
*/
|
|
203
|
-
export declare function filterAgentHitBySubsetAndExpiry(hit: {
|
|
204
|
-
bundle: SecretsBundle;
|
|
205
|
-
env: Record<string, string>;
|
|
206
|
-
}, opts: ResolveBundleOptions): {
|
|
207
|
-
bundle: SecretsBundle;
|
|
208
|
-
env: Record<string, string>;
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* Fail loud when remote bundle resolution is asked for flags the SSH resolver
|
|
212
|
-
* does not yet thread. Exported so callers share the same error text.
|
|
213
|
-
*/
|
|
214
|
-
export declare function assertRemoteBundleFlagsUnsupported(bundleName: string, host: string, opts: {
|
|
215
|
-
keys?: string[];
|
|
216
|
-
allowExpired?: boolean;
|
|
217
|
-
}, flagLabels: {
|
|
218
|
-
keysFlag: string;
|
|
219
|
-
allowExpiredFlag: string;
|
|
220
|
-
}): void;
|
|
221
|
-
export declare function resolveBundleEnv(bundle: SecretsBundle, _opts?: ResolveBundleOptions): Record<string, string>;
|
|
222
|
-
/**
|
|
223
|
-
* True when the current process is a background / non-interactive context that
|
|
224
|
-
* must NEVER raise a Keychain biometry prompt on the interactive user's screen.
|
|
225
|
-
* Re-exported from ./headless.js — the detector lives there so the raw-read
|
|
226
|
-
* path in index.ts can share it without a bundles↔index import cycle. See that
|
|
227
|
-
* module for the full contract.
|
|
228
|
-
*/
|
|
229
|
-
export { isHeadlessSecretsContext, isAgentInvocationContext } from './headless.js';
|
|
230
|
-
/**
|
|
231
|
-
* Read a bundle's metadata AND resolve its env in a single Touch ID prompt.
|
|
232
|
-
* `readBundle` + `resolveBundleEnv` used to issue two LAContext calls (two
|
|
233
|
-
* prompts). This collapses them into one batch that includes the metadata item.
|
|
234
|
-
*/
|
|
235
|
-
export declare function readAndResolveBundleEnv(name: string, opts?: ResolveBundleOptions): {
|
|
236
|
-
bundle: SecretsBundle;
|
|
237
|
-
env: Record<string, string>;
|
|
238
|
-
};
|
|
239
|
-
export declare function humanUnlockDuration(ms: number): string;
|
|
240
|
-
export declare function keychainRef(key: string): string;
|
|
241
|
-
/** Options for rotateBundleSecret. */
|
|
242
|
-
export interface RotateOptions {
|
|
243
|
-
/** New plaintext value to write into keychain (replaces the old one). */
|
|
244
|
-
newValue: string;
|
|
245
|
-
/** When true, drop existing meta for this key. Mutually exclusive with `meta`. */
|
|
246
|
-
clearMeta?: boolean;
|
|
247
|
-
/** Patch to merge into existing meta. Undefined fields preserve current values. */
|
|
248
|
-
meta?: Partial<VarMeta>;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Rotate a keychain-backed secret. Errors if the key is absent; preserves meta
|
|
252
|
-
* unless cleared or patched.
|
|
253
|
-
*/
|
|
254
|
-
export declare function rotateBundleSecret(bundle: SecretsBundle, key: string, opts: RotateOptions): void;
|
|
255
|
-
/**
|
|
256
|
-
* Reconcile keychain value items to the bundle's current policy. macOS gates
|
|
257
|
-
* reads on each item's ACL, not the bundle's declared policy, so a policy change
|
|
258
|
-
* alone would leave stale ACLs. hold/always → never strips ACL; never → *
|
|
259
|
-
* re-attaches it. Non-keychain backends no-op.
|
|
260
|
-
*/
|
|
261
|
-
export declare function reAclBundleItems(bundle: SecretsBundle): void;
|
|
262
|
-
/** Options for renameBundle. */
|
|
263
|
-
export interface RenameOptions {
|
|
264
|
-
/** Overwrite an existing destination bundle. */
|
|
265
|
-
force?: boolean;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Rename a bundle: copy metadata + keychain values to the new name, then delete
|
|
269
|
-
* the source. Steps are ordered so a copy-phase failure leaves the source intact.
|
|
270
|
-
*/
|
|
271
|
-
export declare function renameBundle(oldName: string, newName: string, opts?: RenameOptions): void;
|
|
272
|
-
/**
|
|
273
|
-
* The item store (keychain or encrypted file) for a bundle's per-key secrets.
|
|
274
|
-
* Pass the resolved backend (`bundle.backend ?? 'keychain'`).
|
|
275
|
-
*/
|
|
276
|
-
export declare function bundleItemStore(backend: SecretsBackend | undefined, opts?: {
|
|
277
|
-
noAcl?: boolean;
|
|
278
|
-
}): {
|
|
279
|
-
set(item: string, value: string): void;
|
|
280
|
-
delete(item: string): boolean;
|
|
281
|
-
get(item: string): string;
|
|
282
|
-
has(item: string): boolean;
|
|
283
|
-
};
|
|
284
|
-
export declare function keychainItemsForBundle(bundle: SecretsBundle): Array<{
|
|
285
|
-
key: string;
|
|
286
|
-
item: string;
|
|
287
|
-
}>;
|
|
288
|
-
export declare function parseDotenv(content: string): Record<string, string>;
|
|
289
|
-
export declare function migrateLegacyBundles(confirmBundle: (candidate: LegacyBundleCandidate) => boolean | Promise<boolean>): Promise<number>;
|
|
290
|
-
export type { SecretRef };
|