@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.
Files changed (259) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +80 -53
  3. package/dist/bootstrap.d.ts +7 -6
  4. package/dist/bootstrap.js +20 -27
  5. package/dist/cli/command-registry.js +5 -1
  6. package/dist/commands/accounts.d.ts +6 -13
  7. package/dist/commands/accounts.js +330 -143
  8. package/dist/commands/alias.js +7 -3
  9. package/dist/commands/apply.js +1 -1
  10. package/dist/commands/auth-mint.d.ts +7 -3
  11. package/dist/commands/auth-mint.js +21 -9
  12. package/dist/commands/auth.js +2 -3
  13. package/dist/commands/browser.js +10 -10
  14. package/dist/commands/daemon.d.ts +7 -3
  15. package/dist/commands/daemon.js +40 -25
  16. package/dist/commands/doctor.js +28 -2
  17. package/dist/commands/exec.js +87 -39
  18. package/dist/commands/fleet-capture.js +21 -2
  19. package/dist/commands/harness-wizard.js +2 -2
  20. package/dist/commands/lease.js +7 -12
  21. package/dist/commands/profiles.d.ts +2 -2
  22. package/dist/commands/profiles.js +20 -13
  23. package/dist/commands/repo.js +3 -3
  24. package/dist/commands/run-account-picker.d.ts +3 -3
  25. package/dist/commands/run-account-picker.js +29 -30
  26. package/dist/commands/secrets-passthrough.d.ts +20 -0
  27. package/dist/commands/secrets-passthrough.js +43 -0
  28. package/dist/commands/setup-accounts.d.ts +3 -2
  29. package/dist/commands/setup-accounts.js +4 -4
  30. package/dist/commands/setup-secrets.d.ts +16 -21
  31. package/dist/commands/setup-secrets.js +43 -224
  32. package/dist/commands/ssh.js +2 -2
  33. package/dist/commands/sync.js +1 -1
  34. package/dist/commands/update.d.ts +10 -0
  35. package/dist/commands/update.js +43 -40
  36. package/dist/commands/versions.d.ts +11 -11
  37. package/dist/commands/versions.js +131 -83
  38. package/dist/commands/view.d.ts +1 -9
  39. package/dist/commands/view.js +41 -55
  40. package/dist/commands/webhook.js +5 -5
  41. package/dist/commands/workflows.js +2 -1
  42. package/dist/index.d.ts +12 -12
  43. package/dist/index.js +13 -42
  44. package/dist/lib/account-capabilities.d.ts +1 -1
  45. package/dist/lib/account-capabilities.js +1 -1
  46. package/dist/lib/account-catalog.d.ts +121 -6
  47. package/dist/lib/account-catalog.js +421 -7
  48. package/dist/lib/account-registry.d.ts +8 -30
  49. package/dist/lib/account-registry.js +36 -79
  50. package/dist/lib/account-schema.d.ts +1 -1
  51. package/dist/lib/account-schema.js +1 -1
  52. package/dist/lib/accounting/account-pool-collect.js +16 -4
  53. package/dist/lib/accounting/rotate.d.ts +20 -7
  54. package/dist/lib/accounting/rotate.js +89 -13
  55. package/dist/lib/accounting/usage.js +11 -16
  56. package/dist/lib/accounts/add.d.ts +138 -0
  57. package/dist/lib/accounts/add.js +651 -0
  58. package/dist/lib/accounts/migrate.d.ts +117 -0
  59. package/dist/lib/accounts/migrate.js +536 -0
  60. package/dist/lib/accounts/slots.d.ts +13 -0
  61. package/dist/lib/accounts/slots.js +100 -0
  62. package/dist/lib/agent-spec/agents.d.ts +16 -0
  63. package/dist/lib/agent-spec/agents.js +38 -4
  64. package/dist/lib/app-bundle-install.js +5 -4
  65. package/dist/lib/auth-health.d.ts +3 -0
  66. package/dist/lib/auth-health.js +11 -0
  67. package/dist/lib/auth-mint.d.ts +52 -16
  68. package/dist/lib/auth-mint.js +117 -39
  69. package/dist/lib/browser/chrome.d.ts +1 -1
  70. package/dist/lib/browser/chrome.js +5 -5
  71. package/dist/lib/byok-usage.js +3 -3
  72. package/dist/lib/claude-account-token.d.ts +47 -3
  73. package/dist/lib/claude-account-token.js +172 -50
  74. package/dist/lib/cloud/antigravity.js +4 -4
  75. package/dist/lib/cloud/cursor.js +4 -4
  76. package/dist/lib/crabbox/cli.d.ts +1 -1
  77. package/dist/lib/crabbox/cli.js +6 -6
  78. package/dist/lib/crabbox/runtimes.d.ts +3 -3
  79. package/dist/lib/crabbox/runtimes.js +5 -5
  80. package/dist/lib/daemon/account-state-daemon-service.d.ts +37 -1
  81. package/dist/lib/daemon/account-state-daemon-service.js +199 -3
  82. package/dist/lib/daemon/auth-sync-service.js +32 -1
  83. package/dist/lib/daemon/daemon.d.ts +6 -16
  84. package/dist/lib/daemon/daemon.js +52 -97
  85. package/dist/lib/daemon/daemon.test-fixture.d.ts +7 -9
  86. package/dist/lib/daemon/daemon.test-fixture.js +22 -40
  87. package/dist/lib/daemon/harness-update-service.d.ts +1 -1
  88. package/dist/lib/daemon/harness-update-service.js +1 -1
  89. package/dist/lib/daemon/runner.d.ts +15 -3
  90. package/dist/lib/daemon/runner.js +49 -24
  91. package/dist/lib/daemon-health.d.ts +1 -2
  92. package/dist/lib/daemon-health.js +7 -6
  93. package/dist/lib/daemon-services.d.ts +1 -1
  94. package/dist/lib/daemon-services.js +1 -11
  95. package/dist/lib/daemon-webhooks.d.ts +8 -7
  96. package/dist/lib/daemon-webhooks.js +10 -9
  97. package/dist/lib/device-config.js +1 -1
  98. package/dist/lib/devices/doctor-findings.d.ts +1 -1
  99. package/dist/lib/devices/harness-inventory.d.ts +39 -0
  100. package/dist/lib/devices/harness-inventory.js +126 -4
  101. package/dist/lib/doctor-diff.js +2 -1
  102. package/dist/lib/exec-account-home.d.ts +38 -0
  103. package/dist/lib/exec-account-home.js +164 -0
  104. package/dist/lib/exec.d.ts +30 -0
  105. package/dist/lib/exec.js +101 -31
  106. package/dist/lib/fleet/apply.d.ts +2 -2
  107. package/dist/lib/fleet/apply.js +4 -4
  108. package/dist/lib/fleet/auth-sync.js +4 -3
  109. package/dist/lib/fleet-shared-repo-sync.js +6 -9
  110. package/dist/lib/harness/adapter.d.ts +7 -7
  111. package/dist/lib/harness/adapter.js +10 -6
  112. package/dist/lib/harness/adapters/grok.js +8 -3
  113. package/dist/lib/harness/adapters/muse.js +1 -1
  114. package/dist/lib/harness/adapters/opencode.js +12 -3
  115. package/dist/lib/harness-auth-capabilities.d.ts +61 -0
  116. package/dist/lib/harness-auth-capabilities.js +52 -0
  117. package/dist/lib/helper-versions.d.ts +6 -4
  118. package/dist/lib/helper-versions.js +5 -4
  119. package/dist/lib/hosts/credential-transport.d.ts +10 -0
  120. package/dist/lib/hosts/credential-transport.js +37 -0
  121. package/dist/lib/hosts/dispatch.d.ts +7 -0
  122. package/dist/lib/hosts/dispatch.js +13 -6
  123. package/dist/lib/identity/client.d.ts +3 -3
  124. package/dist/lib/identity/client.js +3 -3
  125. package/dist/lib/installations/index.d.ts +1 -1
  126. package/dist/lib/installations/index.js +1 -1
  127. package/dist/lib/installations/migrate.js +9 -0
  128. package/dist/lib/installations/resolve.js +1 -1
  129. package/dist/lib/installations/shims.d.ts +21 -4
  130. package/dist/lib/installations/shims.js +86 -5
  131. package/dist/lib/installations/store.d.ts +43 -0
  132. package/dist/lib/installations/store.js +75 -7
  133. package/dist/lib/installations/versions.js +1 -1
  134. package/dist/lib/menubar/install-menubar.d.ts +3 -3
  135. package/dist/lib/menubar/install-menubar.js +3 -3
  136. package/dist/lib/native-accounts.d.ts +35 -0
  137. package/dist/lib/native-accounts.js +41 -0
  138. package/dist/lib/net-close.d.ts +11 -0
  139. package/dist/lib/net-close.js +25 -0
  140. package/dist/lib/openclaw-keychain.js +27 -1
  141. package/dist/lib/profiles.js +22 -9
  142. package/dist/lib/project-resources.js +1 -1
  143. package/dist/lib/reserved-stores.d.ts +53 -0
  144. package/dist/lib/reserved-stores.js +120 -0
  145. package/dist/lib/secrets-client.d.ts +199 -0
  146. package/dist/lib/secrets-client.js +718 -0
  147. package/dist/lib/secrets-policy.d.ts +235 -0
  148. package/dist/lib/secrets-policy.js +505 -0
  149. package/dist/lib/secrets-types.d.ts +188 -0
  150. package/dist/lib/secrets-types.js +24 -0
  151. package/dist/lib/self-heal/checks/shims.js +5 -3
  152. package/dist/lib/service-manifest.js +3 -4
  153. package/dist/lib/session/db.d.ts +18 -0
  154. package/dist/lib/session/db.js +47 -14
  155. package/dist/lib/session/sync/config.js +2 -2
  156. package/dist/lib/sha256-asset.d.ts +11 -16
  157. package/dist/lib/sha256-asset.js +11 -16
  158. package/dist/lib/share/config.js +14 -5
  159. package/dist/lib/signin-badge.d.ts +26 -0
  160. package/dist/lib/signin-badge.js +42 -0
  161. package/dist/lib/staleness/detectors/workflows.js +3 -105
  162. package/dist/lib/staleness/writers/workflows.js +2 -1
  163. package/dist/lib/state.d.ts +7 -4
  164. package/dist/lib/state.js +18 -7
  165. package/dist/lib/sync-umbrella.js +2 -2
  166. package/dist/lib/teams/agents.js +1 -1
  167. package/dist/lib/types.d.ts +74 -33
  168. package/dist/lib/view-types.d.ts +6 -3
  169. package/dist/lib/workflows-registry.d.ts +71 -0
  170. package/dist/lib/workflows-registry.js +280 -0
  171. package/dist/lib/workflows.d.ts +21 -21
  172. package/dist/lib/workflows.js +12 -327
  173. package/package.json +2 -3
  174. package/scripts/postinstall.js +35 -30
  175. package/dist/commands/secrets-import.d.ts +0 -18
  176. package/dist/commands/secrets-import.js +0 -74
  177. package/dist/commands/secrets-migrate.d.ts +0 -25
  178. package/dist/commands/secrets-migrate.js +0 -334
  179. package/dist/commands/secrets-rotate-passphrase.d.ts +0 -17
  180. package/dist/commands/secrets-rotate-passphrase.js +0 -96
  181. package/dist/commands/secrets-sync.d.ts +0 -11
  182. package/dist/commands/secrets-sync.js +0 -153
  183. package/dist/commands/secrets-vault.d.ts +0 -10
  184. package/dist/commands/secrets-vault.js +0 -130
  185. package/dist/commands/secrets.d.ts +0 -212
  186. package/dist/commands/secrets.js +0 -3030
  187. package/dist/lib/accounts/connect.d.ts +0 -176
  188. package/dist/lib/accounts/connect.js +0 -453
  189. package/dist/lib/daemon/keychain-reap-service.d.ts +0 -17
  190. package/dist/lib/daemon/keychain-reap-service.js +0 -32
  191. package/dist/lib/daemon/secrets-broker-service.d.ts +0 -21
  192. package/dist/lib/daemon/secrets-broker-service.js +0 -51
  193. package/dist/lib/secrets/agent.d.ts +0 -358
  194. package/dist/lib/secrets/agent.js +0 -1291
  195. package/dist/lib/secrets/audit.d.ts +0 -46
  196. package/dist/lib/secrets/audit.js +0 -101
  197. package/dist/lib/secrets/bundles.d.ts +0 -290
  198. package/dist/lib/secrets/bundles.js +0 -1547
  199. package/dist/lib/secrets/download-keychain.d.ts +0 -47
  200. package/dist/lib/secrets/download-keychain.js +0 -70
  201. package/dist/lib/secrets/drivers/rush.d.ts +0 -14
  202. package/dist/lib/secrets/drivers/rush.js +0 -90
  203. package/dist/lib/secrets/fallback.d.ts +0 -48
  204. package/dist/lib/secrets/fallback.js +0 -48
  205. package/dist/lib/secrets/filestore.d.ts +0 -222
  206. package/dist/lib/secrets/filestore.js +0 -1099
  207. package/dist/lib/secrets/headless.d.ts +0 -43
  208. package/dist/lib/secrets/headless.js +0 -56
  209. package/dist/lib/secrets/icloud-import.d.ts +0 -79
  210. package/dist/lib/secrets/icloud-import.js +0 -206
  211. package/dist/lib/secrets/index.d.ts +0 -451
  212. package/dist/lib/secrets/index.js +0 -1568
  213. package/dist/lib/secrets/install-helper.d.ts +0 -72
  214. package/dist/lib/secrets/install-helper.js +0 -245
  215. package/dist/lib/secrets/lease.d.ts +0 -25
  216. package/dist/lib/secrets/lease.js +0 -44
  217. package/dist/lib/secrets/linux.d.ts +0 -77
  218. package/dist/lib/secrets/linux.js +0 -393
  219. package/dist/lib/secrets/list-filter.d.ts +0 -109
  220. package/dist/lib/secrets/list-filter.js +0 -261
  221. package/dist/lib/secrets/mcp.d.ts +0 -93
  222. package/dist/lib/secrets/mcp.js +0 -211
  223. package/dist/lib/secrets/profiles.d.ts +0 -10
  224. package/dist/lib/secrets/profiles.js +0 -13
  225. package/dist/lib/secrets/push.d.ts +0 -133
  226. package/dist/lib/secrets/push.js +0 -273
  227. package/dist/lib/secrets/rc-hygiene.d.ts +0 -63
  228. package/dist/lib/secrets/rc-hygiene.js +0 -143
  229. package/dist/lib/secrets/read-backoff.d.ts +0 -27
  230. package/dist/lib/secrets/read-backoff.js +0 -64
  231. package/dist/lib/secrets/reaper.d.ts +0 -90
  232. package/dist/lib/secrets/reaper.js +0 -243
  233. package/dist/lib/secrets/remote.d.ts +0 -152
  234. package/dist/lib/secrets/remote.js +0 -344
  235. package/dist/lib/secrets/reserved-sync.d.ts +0 -66
  236. package/dist/lib/secrets/reserved-sync.js +0 -147
  237. package/dist/lib/secrets/scope.d.ts +0 -26
  238. package/dist/lib/secrets/scope.js +0 -29
  239. package/dist/lib/secrets/session-store.d.ts +0 -107
  240. package/dist/lib/secrets/session-store.js +0 -342
  241. package/dist/lib/secrets/sync-backend.d.ts +0 -48
  242. package/dist/lib/secrets/sync-backend.js +0 -13
  243. package/dist/lib/secrets/sync-commands.d.ts +0 -21
  244. package/dist/lib/secrets/sync-commands.js +0 -21
  245. package/dist/lib/secrets/sync.d.ts +0 -48
  246. package/dist/lib/secrets/sync.js +0 -237
  247. package/dist/lib/secrets/unlock-hints.d.ts +0 -27
  248. package/dist/lib/secrets/unlock-hints.js +0 -36
  249. package/dist/lib/secrets/usage-db.d.ts +0 -46
  250. package/dist/lib/secrets/usage-db.js +0 -96
  251. package/dist/lib/secrets/vault-age-helper.d.ts +0 -1
  252. package/dist/lib/secrets/vault-age-helper.js +0 -34
  253. package/dist/lib/secrets/vault.d.ts +0 -49
  254. package/dist/lib/secrets/vault.js +0 -399
  255. package/dist/lib/secrets/windows.d.ts +0 -81
  256. package/dist/lib/secrets/windows.js +0 -556
  257. package/scripts/install-helper.js +0 -97
  258. /package/dist/lib/{secrets/sync-passphrase.d.ts → sync-passphrase.d.ts} +0 -0
  259. /package/dist/lib/{secrets/sync-passphrase.js → sync-passphrase.js} +0 -0
@@ -1,130 +0,0 @@
1
- /**
2
- * `agents secrets vault` — unlock/lock the age-encrypted synced-secrets file
3
- * at ~/.agents/vault.age (distinct from `agents secrets unlock|lock`, which
4
- * holds keychain bundles in the secrets-agent).
5
- *
6
- * Formerly top-level `agents login` / `agents logout`.
7
- */
8
- import chalk from 'chalk';
9
- import * as fs from 'fs';
10
- import { readStdinSync } from '../lib/format.js';
11
- import { clearVaultKey, createVault, getVaultSession, joinVault, unlock, vaultExists, vaultPath, } from '../lib/secrets/vault.js';
12
- import { setHelpSections } from '../lib/help.js';
13
- import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
14
- async function promptPassword(message) {
15
- if (!isInteractiveTerminal()) {
16
- throw new Error('A password is required. Run from a TTY or pass --password-stdin.');
17
- }
18
- const { password } = await import('@inquirer/prompts');
19
- return password({ message, mask: true });
20
- }
21
- async function readPassword(opts, message) {
22
- if (opts.passwordStdin) {
23
- const value = readStdinSync();
24
- if (!value)
25
- throw new Error('No password received on stdin.');
26
- return value.replace(/\r?\n$/, '');
27
- }
28
- return promptPassword(message);
29
- }
30
- async function chooseFreshMode(opts) {
31
- if (opts.create && opts.join)
32
- throw new Error('--create and --join are mutually exclusive.');
33
- if (opts.create)
34
- return 'create';
35
- if (opts.join)
36
- return 'join';
37
- if (!isInteractiveTerminal()) {
38
- throw new Error('No synced secrets file exists. Pass --create or --join <vault.age> in a non-interactive shell.');
39
- }
40
- const { select } = await import('@inquirer/prompts');
41
- return select({
42
- message: 'No synced secrets vault found. What do you want to do?',
43
- choices: [
44
- { name: 'Create a new vault', value: 'create' },
45
- { name: 'Join with an existing vault.age file', value: 'join' },
46
- ],
47
- });
48
- }
49
- function formatRemaining(expiresAt) {
50
- const ms = expiresAt - Date.now();
51
- if (ms <= 0)
52
- return 'expired';
53
- const mins = Math.round(ms / 60000);
54
- if (mins < 60)
55
- return `${mins} minute${mins === 1 ? '' : 's'}`;
56
- const hours = Math.round(mins / 60);
57
- if (hours < 24)
58
- return `${hours} hour${hours === 1 ? '' : 's'}`;
59
- const days = Math.round(hours / 24);
60
- return `${days} day${days === 1 ? '' : 's'}`;
61
- }
62
- /** Register `agents secrets vault unlock|lock` under the secrets parent. */
63
- export function registerSecretsVaultCommands(secretsCmd) {
64
- const vault = secretsCmd
65
- .command('vault')
66
- .description('Unlock or lock the age-encrypted synced-secrets file (~/.agents/vault.age)');
67
- setHelpSections(vault, {
68
- examples: `agents secrets vault unlock
69
- agents secrets vault unlock --create
70
- agents secrets vault unlock --join ~/Downloads/vault.age
71
- agents secrets vault lock`,
72
- notes: `This is the synced vault passphrase cache — not \`agents secrets unlock\`, which holds keychain bundles in the secrets-agent after Touch ID.
73
- Harness OAuth sign-out is \`agents accounts logout\` (OAuth native logins only).`,
74
- });
75
- vault
76
- .command('unlock')
77
- .description('Unlock synced secrets for this shell session')
78
- .option('--create', 'Create a new encrypted synced-secrets file at ~/.agents/vault.age')
79
- .option('--join <path>', 'Copy and unlock an existing vault.age file')
80
- .option('--force', 'Replace an existing synced-secrets file when used with --create or --join')
81
- .option('--password-stdin', 'Read the master password from stdin')
82
- .action(async (opts) => {
83
- try {
84
- if (opts.force && !opts.create && !opts.join) {
85
- throw new Error('--force can only be used with --create or --join.');
86
- }
87
- if (vaultExists() && !opts.create && !opts.join) {
88
- const password = await readPassword(opts, 'Master password');
89
- unlock(password);
90
- const session = getVaultSession();
91
- const ttl = session.loggedIn ? formatRemaining(session.expiresAt) : '8 hours';
92
- console.log(chalk.green(`Unlocked. Synced secrets available for ${ttl}.`));
93
- return;
94
- }
95
- const mode = await chooseFreshMode(opts);
96
- if (mode === 'join') {
97
- let source = opts.join;
98
- if (!source) {
99
- if (!isInteractiveTerminal())
100
- throw new Error('--join needs a vault.age path.');
101
- const { input } = await import('@inquirer/prompts');
102
- source = await input({
103
- message: 'Path to existing vault.age',
104
- validate: (value) => fs.existsSync(value) || 'File not found.',
105
- });
106
- }
107
- const password = await readPassword(opts, 'Master password');
108
- joinVault(password, source, { overwrite: opts.force });
109
- console.log(chalk.green(`Unlocked. Copied synced secrets file to ${vaultPath()}.`));
110
- return;
111
- }
112
- const password = await readPassword(opts, 'Choose a master password');
113
- createVault(password, { overwrite: opts.force });
114
- console.log(chalk.green(`Unlocked. Created synced secrets file at ${vaultPath()}.`));
115
- }
116
- catch (err) {
117
- if (isPromptCancelled(err))
118
- return;
119
- console.error(chalk.red(err.message));
120
- process.exit(1);
121
- }
122
- });
123
- vault
124
- .command('lock')
125
- .description('Forget the cached synced-secrets key')
126
- .action(() => {
127
- clearVaultKey();
128
- console.log(chalk.green('Locked. Synced secrets require unlock again.'));
129
- });
130
- }
@@ -1,212 +0,0 @@
1
- /**
2
- * Secrets bundle management commands.
3
- *
4
- * Registers the `agents secrets` command tree for creating, viewing,
5
- * and managing named bundles of environment variables backed by macOS
6
- * Keychain. Bundles are injected at run time via `agents run --secrets`.
7
- */
8
- import { type Command } from 'commander';
9
- import { SSH_TARGET_RE, assertValidSshTarget } from '../lib/ssh-exec.js';
10
- import { quoteWin32ExecArg } from '../lib/platform/index.js';
11
- import { bundleEnvToDotenv } from '../lib/secrets/push.js';
12
- export { bundleEnvToDotenv };
13
- import { type SecretsBackend, type SecretsBundle, type SecretsPolicy } from '../lib/secrets/bundles.js';
14
- import { type SecretsListFilterOpts } from '../lib/secrets/list-filter.js';
15
- import { type SecretLease } from '../lib/secrets/lease.js';
16
- import { type BundleUsageSummary } from '../lib/secrets/usage-db.js';
17
- /** Read all available data from stdin synchronously, trimmed. */
18
- /**
19
- * Read the raw `.env` text for `import --from <path|->`. A `-` reads the .env
20
- * from stdin (the SSH push path: `export --device` pipes the resolved dotenv over
21
- * ssh stdin, which has no `/dev/stdin` on a Windows remote); any other value is
22
- * a filesystem path.
23
- */
24
- export declare function readImportDotenv(from: string): string;
25
- /** Where `secrets import` pulls keys from, parsed off the unified `--from`. */
26
- export type ImportSource = {
27
- kind: 'dotenv';
28
- path: string;
29
- } | {
30
- kind: '1password';
31
- vault?: string;
32
- } | {
33
- kind: 'icloud';
34
- };
35
- /**
36
- * Parse the unified `--from <source>` value: a .env path (`-` reads stdin),
37
- * `1password:<vault>` (bare `1password` prompts for the vault), or `icloud`
38
- * (legacy iCloud Keychain bundles). The deprecated `--from-1password --vault`
39
- * pair maps onto the 1password source. A file literally named `icloud` or
40
- * `1password` can still be imported via an explicit path (`./icloud`).
41
- */
42
- export declare function parseImportSource(opts: {
43
- from?: string;
44
- from1password?: boolean;
45
- vault?: string;
46
- }): ImportSource;
47
- /**
48
- * Build the remote `agents secrets unlock` argv for `unlock --device`. `--all`
49
- * forwards verbatim; otherwise the explicit bundle names. A `--ttl` is passed
50
- * through as-is so the REMOTE parses its own duration (its platform rules, its
51
- * defaults). Shared with the command action so the wiring is unit-testable
52
- * without a live SSH session.
53
- */
54
- export declare function resolveUnlockTtlMs(ttl: string | undefined, until: string | undefined, now?: number): number;
55
- /**
56
- * Decide what an `unlock` holds: the whole bundle env, or — with --keys — only
57
- * the resolved subset behind a lease that scopes the broker entry (agent.ts
58
- * re-selects on load) and its own expiry. Fails closed: createSecretLease throws
59
- * on an unknown or empty key subset. The unlock action's single scoping seam,
60
- * exported so the whole-bundle vs scoped-subset decision is unit-testable without
61
- * a live broker.
62
- */
63
- export declare function scopeHeldEnv(input: {
64
- bundle: string;
65
- env: Record<string, string>;
66
- keys: string | null;
67
- ttlMs: number;
68
- harness: string;
69
- sleepPersist: boolean;
70
- }): {
71
- heldEnv: Record<string, string>;
72
- lease?: SecretLease;
73
- };
74
- export declare function buildRemoteUnlockArgs(names: string[], opts: {
75
- all?: boolean;
76
- ttl?: string;
77
- until?: string;
78
- durable?: boolean;
79
- }): string[];
80
- /**
81
- * Build the remote `agents secrets list` argv for `list --device`. Every filter
82
- * must be forwarded: `browseRemote` sends this argv verbatim, so a flag left out
83
- * here is not an error — the remote just lists everything, and
84
- * `secrets list --device zion --expired` reports every bundle on zion as expired.
85
- * Silent and wrong beats loud and wrong only for the person who wrote the bug.
86
- *
87
- * Values pass through unparsed so the REMOTE validates them under its own rules,
88
- * matching how `--ttl` is forwarded by buildRemoteUnlockArgs.
89
- */
90
- export declare function buildRemoteListArgs(opts: SecretsListFilterOpts & {
91
- json?: boolean;
92
- sort?: string;
93
- limit?: string;
94
- }, query?: string): string[];
95
- export { SSH_TARGET_RE, assertValidSshTarget };
96
- /**
97
- * Build the child environment for `agents secrets exec`. Strips
98
- * loader/interpreter hijack vars (matching agent spawns in exec.ts) and never
99
- * forwards AGENTS_SECRETS_PASSPHRASE — the master decryption key must not reach
100
- * the executed command.
101
- */
102
- export declare function buildSecretsExecEnv(parentEnv: NodeJS.ProcessEnv, secretEnv: Record<string, string>): NodeJS.ProcessEnv;
103
- /**
104
- * Encrypt a resolved env map to an offline bundle file using AES-256-GCM
105
- * (the same EncFile envelope as the per-item file store). Inner plaintext is
106
- * JSON so multi-line values round-trip losslessly. Written with mode 0600;
107
- * the passphrase must be supplied explicitly — never auto-provisioned.
108
- */
109
- export declare function exportBundleToFile(env: Record<string, string>, filePath: string, passphrase: string): void;
110
- /**
111
- * Decrypt and parse an offline bundle file produced by exportBundleToFile.
112
- * Throws on a missing file, an invalid JSON envelope, or a wrong passphrase.
113
- */
114
- export declare function importBundleFromFile(filePath: string, passphrase: string): Record<string, string>;
115
- /** Compact span for a fixed duration: "45m" / "19h" / "2d". Shared by
116
- * `compactRemaining` (a countdown) and the POLICY column's hold-window
117
- * annotation (a fixed length) so the two can never round onto different unit
118
- * thresholds and disagree about the same number of milliseconds. */
119
- export declare function compactDurationMs(ms: number): string;
120
- /** The POLICY column for `secrets list`. `hold` is a duration, not a mode — it
121
- * means "prompt once, then stay silent for this long" — so the column states
122
- * the window (`hold 7d`) rather than the bare tier name, and appends `· held Nd`
123
- * while the secrets-agent is actually caching the bundle. `always` and `never`
124
- * carry no window and gain nothing here. `holdMs` is the configured global hold
125
- * (`secretsHoldMs()`), passed in rather than read so this stays pure; `held`
126
- * maps bundle name → expiry epoch-ms (from agentStatus()). */
127
- export declare function renderPolicyCol(b: SecretsBundle, holdMs: number, held?: Map<string, number>): string;
128
- /** The hold-window line at the top of `secrets status`. Names the `hold` policy
129
- * the window belongs to — the rename in #1604 left this surface still saying
130
- * "daily", the one name the CLI no longer accepts in its own help. Pure so the
131
- * vocabulary is pinned by a test rather than re-drifting on the next rename. */
132
- export declare function renderHoldSummary(holdStr: string, configured: boolean): string;
133
- /** The empty-broker line under the hold summary. Named here, beside
134
- * `renderHoldSummary`, for the same reason: it is the second line the rename
135
- * left saying `daily`, and a test pins both. */
136
- export declare const NO_BUNDLES_HELD_LINE = "No bundles held. The next read of each hold-policy bundle will prompt once, then hold.";
137
- /** Human-readable hold window for `secrets status`. Sub-hour values render in
138
- * minutes (so a near-floor `holdMs` never shows a confusing "0 hours"), whole
139
- * hours up to 2 days, whole days beyond. Pure — unit-tested. */
140
- export declare function formatHoldWindow(ms: number): string;
141
- /** A broker hold expiry, or null once it has lapsed. One definition of "held",
142
- * shared by the POLICY column, the `--held` filter, and the JSON payload, so the
143
- * three can never disagree about the same bundle. */
144
- export declare function liveHold(expiresAt: number | undefined, now?: number): number | null;
145
- /**
146
- * Compact one-line usage summary for `secrets view` — each recorded event with
147
- * its count and how long ago it last happened ("accessed 42× (last 2h ago) ·
148
- * exported 3× (last 1d ago)"). Empty string when nothing has been recorded yet.
149
- * Pure — unit-tested.
150
- */
151
- export declare function formatUsageLine(summary: BundleUsageSummary | undefined): string;
152
- /**
153
- * The held-state line for `secrets view`: whether the secrets-agent currently
154
- * holds this bundle (so reads are prompt-free) and for how long, or that Touch
155
- * ID is required on the next read. Only meaningful for keychain bundles on macOS
156
- * — file/vault backends have no broker to hold, and a `never`-policy bundle is
157
- * always readable — so both return an empty line and the caller skips it.
158
- * `heldExpiresAt` is the max expiry across every held scope.
159
- */
160
- export declare function renderViewStatusLine(b: SecretsBundle, heldExpiresAt: number | null): string;
161
- /**
162
- * The EXPIRING cell. Counts keys needing attention — already expired plus due
163
- * within 30 days — and colours by the worst of the two: red once anything has
164
- * lapsed, yellow while everything is merely upcoming.
165
- *
166
- * Expired keys used to be invisible here. `countExpiringSoon` requires
167
- * `d >= 0`, so a bundle whose token died last month rendered `-`, identical to
168
- * one with no expiry at all; the only places it surfaced were `secrets view`
169
- * and a hard abort at inject time, i.e. after it had already broken something.
170
- */
171
- export declare function renderExpiringCol(b: SecretsBundle, now?: number): string;
172
- /**
173
- * Resolve an existing import target bundle (inheriting its backend) or create a
174
- * new one with the requested backend. Refuses to silently downgrade a
175
- * keychain-backed bundle to `file` — shared by every `import` source so the
176
- * guard can't drift between them.
177
- *
178
- * `force` additionally recreates a bundle whose METADATA RECORD is present but
179
- * undecryptable — a file store whose key was lost or rotated out from under it.
180
- * That is precisely the state provisioning exists to repair (import is how a box
181
- * gets its bundles back), and without this the import dies on `readBundle` and
182
- * the only route left is deleting the record by hand on an already-degraded
183
- * store. It is gated on `--force` on purpose: recreating unconditionally would
184
- * destroy a perfectly healthy bundle for someone who merely forgot to set
185
- * `AGENTS_SECRETS_PASSPHRASE`, which is the hazard `readBundleIfDecryptable`
186
- * exists to describe. `--force` already means "overwrite what is there".
187
- */
188
- export declare function resolveImportBundle(name: string, backendOpt: string | undefined, synced?: boolean, force?: boolean): SecretsBundle;
189
- /** Register the `agents secrets` command tree. */
190
- export declare function registerSecretsCommands(program: Command): void;
191
- /** Validate a prompt-policy value, throwing a clear message on a bad one (the
192
- * caller's try/catch renders it and exits). Accepts the legacy `biometry` /
193
- * `session` / `none` tokens as aliases for `always` / `daily` / `never` so older
194
- * flags and scripts keep working. `never`/`none` is the no-biometry-ACL tier —
195
- * accepted here, then gated behind a loud confirmation in the command layer. */
196
- export declare function parsePolicyOpt(raw: string | undefined): SecretsPolicy;
197
- /**
198
- * Gate a create/switch to the `never` prompt-policy behind an explicit,
199
- * deliberate acknowledgement — it is the least-safe tier (no user-presence
200
- * check on any read). Returns:
201
- * - `'ok'` — not `never`, or already acknowledged via `--i-understand`.
202
- * - `'prompt'` — interactive shell: caller must run a loud confirm prompt.
203
- * Throws in a non-interactive shell when the flag is absent, so a headless
204
- * `create --policy never` can't silently downgrade a bundle's protection.
205
- */
206
- export declare function assertNeverPolicyAcknowledged(policy: SecretsPolicy | undefined, opts: {
207
- iUnderstand?: boolean;
208
- interactive: boolean;
209
- }): 'ok' | 'prompt';
210
- /** Validate a --backend value, exiting with a clear message on a bad one. */
211
- export declare function secretsDefaultBackend(): SecretsBackend;
212
- export { quoteWin32ExecArg };