@phnx-labs/agents-cli 1.20.0 → 1.20.4

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 (111) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +4 -4
  3. package/dist/commands/cli.js +3 -3
  4. package/dist/commands/cloud.js +1 -1
  5. package/dist/commands/commands.js +24 -7
  6. package/dist/commands/exec.js +36 -16
  7. package/dist/commands/feedback.d.ts +7 -0
  8. package/dist/commands/feedback.js +89 -0
  9. package/dist/commands/helper.d.ts +12 -0
  10. package/dist/commands/helper.js +87 -0
  11. package/dist/commands/hooks.js +86 -7
  12. package/dist/commands/import.js +90 -37
  13. package/dist/commands/mcp.js +166 -10
  14. package/dist/commands/packages.js +196 -27
  15. package/dist/commands/permissions.js +21 -6
  16. package/dist/commands/profiles.d.ts +8 -0
  17. package/dist/commands/profiles.js +117 -4
  18. package/dist/commands/pull.js +4 -4
  19. package/dist/commands/routines.js +6 -6
  20. package/dist/commands/rules.js +8 -4
  21. package/dist/commands/secrets-migrate.d.ts +24 -0
  22. package/dist/commands/secrets-migrate.js +198 -0
  23. package/dist/commands/secrets-sync.d.ts +11 -0
  24. package/dist/commands/secrets-sync.js +155 -0
  25. package/dist/commands/secrets.js +74 -39
  26. package/dist/commands/skills.js +22 -5
  27. package/dist/commands/subagents.js +69 -49
  28. package/dist/commands/teams.js +48 -10
  29. package/dist/commands/utils.d.ts +33 -0
  30. package/dist/commands/utils.js +139 -0
  31. package/dist/commands/versions.js +4 -4
  32. package/dist/commands/view.d.ts +6 -0
  33. package/dist/commands/view.js +169 -8
  34. package/dist/commands/workflows.js +29 -6
  35. package/dist/index.js +4 -0
  36. package/dist/lib/acp/client.js +6 -1
  37. package/dist/lib/agents.d.ts +4 -0
  38. package/dist/lib/agents.js +41 -17
  39. package/dist/lib/auto-pull-worker.js +18 -1
  40. package/dist/lib/browser/chrome.js +4 -0
  41. package/dist/lib/browser/drivers/ssh.js +1 -1
  42. package/dist/lib/browser/profiles.d.ts +3 -3
  43. package/dist/lib/browser/profiles.js +3 -3
  44. package/dist/lib/browser/service.js +19 -0
  45. package/dist/lib/browser/types.d.ts +4 -4
  46. package/dist/lib/cli-resources.d.ts +36 -8
  47. package/dist/lib/cli-resources.js +268 -46
  48. package/dist/lib/cloud/factory.d.ts +1 -1
  49. package/dist/lib/cloud/factory.js +1 -1
  50. package/dist/lib/events.d.ts +16 -2
  51. package/dist/lib/events.js +33 -2
  52. package/dist/lib/exec.d.ts +39 -11
  53. package/dist/lib/exec.js +90 -31
  54. package/dist/lib/help.js +11 -5
  55. package/dist/lib/hooks/cache.d.ts +38 -0
  56. package/dist/lib/hooks/cache.js +242 -0
  57. package/dist/lib/hooks/profile.d.ts +33 -0
  58. package/dist/lib/hooks/profile.js +129 -0
  59. package/dist/lib/hooks.d.ts +0 -10
  60. package/dist/lib/hooks.js +68 -15
  61. package/dist/lib/import.d.ts +21 -0
  62. package/dist/lib/import.js +55 -2
  63. package/dist/lib/mcp.d.ts +15 -0
  64. package/dist/lib/mcp.js +40 -0
  65. package/dist/lib/permissions.d.ts +13 -0
  66. package/dist/lib/permissions.js +51 -1
  67. package/dist/lib/plugin-marketplace.d.ts +10 -0
  68. package/dist/lib/plugin-marketplace.js +47 -1
  69. package/dist/lib/plugins.js +15 -1
  70. package/dist/lib/profiles-presets.d.ts +26 -0
  71. package/dist/lib/profiles-presets.js +187 -8
  72. package/dist/lib/profiles.d.ts +34 -0
  73. package/dist/lib/profiles.js +112 -1
  74. package/dist/lib/pty-server.js +27 -3
  75. package/dist/lib/routines-format.d.ts +17 -5
  76. package/dist/lib/routines-format.js +37 -16
  77. package/dist/lib/routines.d.ts +1 -1
  78. package/dist/lib/routines.js +2 -2
  79. package/dist/lib/runner.js +64 -10
  80. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  81. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  82. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +1 -9
  83. package/dist/lib/secrets/bundles.d.ts +18 -22
  84. package/dist/lib/secrets/bundles.js +75 -99
  85. package/dist/lib/secrets/index.d.ts +51 -27
  86. package/dist/lib/secrets/index.js +147 -156
  87. package/dist/lib/secrets/install-helper.d.ts +45 -0
  88. package/dist/lib/secrets/install-helper.js +165 -0
  89. package/dist/lib/secrets/linux.js +4 -4
  90. package/dist/lib/secrets/sync.d.ts +56 -0
  91. package/dist/lib/secrets/sync.js +180 -0
  92. package/dist/lib/session/render.js +4 -4
  93. package/dist/lib/session/types.d.ts +1 -1
  94. package/dist/lib/shims.d.ts +4 -1
  95. package/dist/lib/shims.js +5 -35
  96. package/dist/lib/state.d.ts +14 -1
  97. package/dist/lib/state.js +49 -5
  98. package/dist/lib/teams/agents.d.ts +5 -4
  99. package/dist/lib/teams/agents.js +47 -21
  100. package/dist/lib/teams/api.d.ts +2 -1
  101. package/dist/lib/teams/api.js +4 -3
  102. package/dist/lib/types.d.ts +57 -1
  103. package/dist/lib/types.js +2 -0
  104. package/dist/lib/usage.d.ts +27 -2
  105. package/dist/lib/usage.js +100 -17
  106. package/dist/lib/versions.d.ts +35 -1
  107. package/dist/lib/versions.js +288 -64
  108. package/package.json +13 -12
  109. package/scripts/install-helper.js +97 -0
  110. package/scripts/postinstall.js +16 -0
  111. package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
@@ -1,21 +1,21 @@
1
1
  /**
2
- * Secret bundles -- named sets of keychain-backed environment variables.
2
+ * Secret bundles named sets of keychain-backed environment variables.
3
3
  *
4
4
  * Bundle metadata (name, description, vars map) is stored in the macOS
5
- * Keychain as a JSON blob under `agents-cli.bundles.<name>`. Bundles created
6
- * with `--icloud-sync` write the metadata to the iCloud-synced keychain so
7
- * the full bundle definition (not just secret values) propagates across
8
- * the user's Macs. Nothing about secrets ever lives in plaintext on disk.
5
+ * Keychain as a JSON blob under `agents-cli.bundles.<name>`. Secret values
6
+ * live one per keychain item under `agents-cli.secrets.<bundle>.<key>`.
7
+ * Every item is device-local and gated by Touch ID / device passcode — see
8
+ * src/lib/secrets/index.ts for the access-control story. Nothing about
9
+ * secrets ever lives in plaintext on disk.
9
10
  *
10
- * Secret values keep their old layout: one keychain item per key under
11
- * `agents-cli.secrets.<bundle>.<key>`, sync-state matching the bundle's
12
- * `icloud_sync` flag.
11
+ * Cross-machine sync is handled by src/lib/secrets/sync.ts via an explicit
12
+ * encrypted export/import flow; the bundle layer is sync-agnostic.
13
13
  */
14
14
  import * as fs from 'fs';
15
15
  import * as os from 'os';
16
16
  import * as path from 'path';
17
17
  import * as yaml from 'yaml';
18
- import { deleteKeychainToken, getKeychainToken, getKeychainTokensBatch, hasKeychainToken, listKeychainItems, parseBundleValue, resolveRef, secretsKeychainItem, setKeychainToken, } from './index.js';
18
+ import { deleteKeychainToken, getKeychainToken, getKeychainTokens, hasKeychainToken, listKeychainItems, parseBundleValue, resolveRef, secretsKeychainItem, setKeychainToken, } from './index.js';
19
19
  import { emit } from '../events.js';
20
20
  /** Allowed values for a secret's `type` metadata field. */
21
21
  export const SECRET_TYPES = [
@@ -63,6 +63,17 @@ export function isLoaderOrInterpreterEnv(name) {
63
63
  'CDPATH',
64
64
  ].includes(upper);
65
65
  }
66
+ export function sanitizeProcessEnv(env = process.env) {
67
+ const out = {};
68
+ for (const [k, v] of Object.entries(env)) {
69
+ if (v === undefined)
70
+ continue;
71
+ if (isLoaderOrInterpreterEnv(k))
72
+ continue;
73
+ out[k] = v;
74
+ }
75
+ return out;
76
+ }
66
77
  /** Validate a bundle name against the allowed pattern. Throws on invalid input. */
67
78
  export function validateBundleName(name) {
68
79
  if (!BUNDLE_NAME_PATTERN.test(name)) {
@@ -125,11 +136,12 @@ export function readBundle(name) {
125
136
  if (!parsed || typeof parsed !== 'object') {
126
137
  throw new Error(`Bundle '${name}' is malformed.`);
127
138
  }
139
+ // Unknown fields on the JSON (e.g. legacy sync flags) are silently dropped
140
+ // here; the SecretsBundle shape is the only source of truth.
128
141
  const bundle = {
129
142
  name,
130
143
  description: parsed.description,
131
144
  allow_exec: Boolean(parsed.allow_exec),
132
- icloud_sync: Boolean(parsed.icloud_sync),
133
145
  vars: parsed.vars && typeof parsed.vars === 'object' ? parsed.vars : {},
134
146
  };
135
147
  if (typeof parsed.created_at === 'string')
@@ -146,7 +158,7 @@ export function readBundle(name) {
146
158
  }
147
159
  return bundle;
148
160
  }
149
- export function writeBundle(bundle, opts = {}) {
161
+ export function writeBundle(bundle) {
150
162
  validateBundleName(bundle.name);
151
163
  for (const key of Object.keys(bundle.vars)) {
152
164
  validateEnvKey(key);
@@ -179,7 +191,6 @@ export function writeBundle(bundle, opts = {}) {
179
191
  const payload = {
180
192
  description: bundle.description,
181
193
  allow_exec: bundle.allow_exec ? true : undefined,
182
- icloud_sync: bundle.icloud_sync ? true : undefined,
183
194
  created_at: bundle.created_at,
184
195
  updated_at: bundle.updated_at,
185
196
  last_used: bundle.last_used,
@@ -187,10 +198,8 @@ export function writeBundle(bundle, opts = {}) {
187
198
  meta,
188
199
  };
189
200
  const json = JSON.stringify(payload);
190
- setKeychainToken(bundleMetaItem(bundle.name), json, Boolean(bundle.icloud_sync));
191
- if (opts.emitEvent !== false) {
192
- emit('secrets.set', { bundle: bundle.name });
193
- }
201
+ setKeychainToken(bundleMetaItem(bundle.name), json);
202
+ emit('secrets.set', { bundle: bundle.name });
194
203
  }
195
204
  export function deleteBundle(name) {
196
205
  validateBundleName(name);
@@ -220,7 +229,7 @@ export function listBundles() {
220
229
  // SecItemCopyMatching calls collapses the prompt to one. Mirrors the pattern
221
230
  // already used by resolveBundleEnv for runtime secret injection.
222
231
  const itemsToFetch = names.map(bundleMetaItem);
223
- const fetched = getKeychainTokensBatch(itemsToFetch, false, 'list secrets bundles');
232
+ const fetched = getKeychainTokens(itemsToFetch);
224
233
  const out = [];
225
234
  for (const name of names) {
226
235
  const json = fetched.get(bundleMetaItem(name));
@@ -240,7 +249,6 @@ export function listBundles() {
240
249
  name,
241
250
  description: parsed.description,
242
251
  allow_exec: Boolean(parsed.allow_exec),
243
- icloud_sync: Boolean(parsed.icloud_sync),
244
252
  vars: parsed.vars && typeof parsed.vars === 'object' ? parsed.vars : {},
245
253
  };
246
254
  if (typeof parsed.created_at === 'string')
@@ -294,90 +302,63 @@ function stampLastUsed(bundle) {
294
302
  }
295
303
  try {
296
304
  bundle.last_used = new Date(nowMs).toISOString();
297
- writeBundle(bundle, { emitEvent: false });
305
+ writeBundle(bundle);
298
306
  }
299
307
  catch {
300
308
  // Swallow — telemetry must never block secret resolution.
301
309
  }
302
310
  }
303
- export function resolveBundleEnv(bundle, opts = {}) {
311
+ // Walk the bundle and produce a flat env map. Every keychain: ref is gathered
312
+ // into a single batch read so macOS shows ONE Touch ID prompt for the whole
313
+ // bundle — including the metadata fetch that already happened in readBundle
314
+ // (the helper's auth context survives across separate invocations only via
315
+ // the per-process LAContext, so we still get one prompt for the batch even
316
+ // if metadata triggered an earlier one). Literals/env/file/exec refs are
317
+ // resolved inline and never reach the keychain.
318
+ export function resolveBundleEnv(bundle, _opts = {}) {
304
319
  stampLastUsed(bundle);
305
320
  const parsedByKey = new Map();
306
321
  const keychainItemsToFetch = [];
307
- const keychainKeys = [];
308
- const kindCounts = {};
309
322
  for (const [key, raw] of Object.entries(bundle.vars)) {
310
323
  const parsed = parseBundleValue(raw);
311
324
  parsedByKey.set(key, parsed);
312
- const kind = 'literal' in parsed ? 'literal' : parsed.ref.provider;
313
- kindCounts[kind] = (kindCounts[kind] ?? 0) + 1;
314
325
  if ('ref' in parsed && parsed.ref.provider === 'keychain') {
315
- const item = secretsKeychainItem(bundle.name, parsed.ref.value);
316
- keychainItemsToFetch.push(item);
317
- keychainKeys.push(key);
326
+ keychainItemsToFetch.push(secretsKeychainItem(bundle.name, parsed.ref.value));
318
327
  }
319
328
  }
320
- const keys = Object.keys(bundle.vars).sort();
321
- keychainKeys.sort();
322
- const emitReadAudit = (status, err) => {
323
- emit('secrets.get', {
324
- bundle: bundle.name,
325
- caller: opts.caller,
326
- status,
327
- keyCount: keys.length,
328
- keys,
329
- keychainKeys,
330
- kindCounts,
331
- error: err instanceof Error ? err.message : (err ? String(err) : undefined),
332
- });
333
- };
334
- // Build the localizedReason shown under the Touch ID prompt. Lowercase verb
335
- // phrase per Apple HIG — the system prepends "<App> is required to ".
336
- const reason = opts.caller
337
- ? `read ${bundle.name} secrets (for ${opts.caller})`
338
- : `read ${bundle.name} secrets`;
339
- try {
340
- // Single helper invocation, one biometric prompt.
341
- const fetched = keychainItemsToFetch.length > 0
342
- ? getKeychainTokensBatch(keychainItemsToFetch, bundle.icloud_sync, reason)
343
- : new Map();
344
- // Second pass: assemble env. Keychain values come from the batch; everything
345
- // else is resolved inline (literals and env/file/exec refs don't prompt).
346
- const env = {};
347
- for (const [key] of Object.entries(bundle.vars)) {
348
- const parsed = parsedByKey.get(key);
349
- if ('literal' in parsed) {
350
- env[key] = parsed.literal;
351
- continue;
352
- }
353
- if (parsed.ref.provider === 'keychain') {
354
- const item = secretsKeychainItem(bundle.name, parsed.ref.value);
355
- const value = fetched.get(item);
356
- if (value === undefined) {
357
- throw new Error(`Bundle '${bundle.name}' key '${key}': keychain item '${item}' not found. ` +
358
- `Run: agents secrets add ${bundle.name} ${key}`);
359
- }
360
- env[key] = value;
361
- continue;
362
- }
363
- try {
364
- env[key] = resolveRef(parsed.ref, {
365
- allowExec: bundle.allow_exec,
366
- iCloudSync: bundle.icloud_sync,
367
- keychainItemFor: (shortId) => secretsKeychainItem(bundle.name, shortId),
368
- });
369
- }
370
- catch (err) {
371
- throw new Error(`Bundle '${bundle.name}' key '${key}': ${err.message}`);
329
+ const fetched = keychainItemsToFetch.length > 0
330
+ ? getKeychainTokens(keychainItemsToFetch)
331
+ : new Map();
332
+ const env = {};
333
+ for (const [key, raw] of Object.entries(bundle.vars)) {
334
+ const parsed = parsedByKey.get(key);
335
+ if ('literal' in parsed) {
336
+ env[key] = parsed.literal;
337
+ continue;
338
+ }
339
+ if (parsed.ref.provider === 'keychain') {
340
+ const item = secretsKeychainItem(bundle.name, parsed.ref.value);
341
+ const value = fetched.get(item);
342
+ if (value === undefined) {
343
+ throw new Error(`Bundle '${bundle.name}' key '${key}': keychain item '${item}' not found. ` +
344
+ `Run: agents secrets add ${bundle.name} ${key}`);
372
345
  }
346
+ env[key] = value;
347
+ continue;
348
+ }
349
+ try {
350
+ env[key] = resolveRef(parsed.ref, {
351
+ allowExec: bundle.allow_exec,
352
+ keychainItemFor: (shortId) => secretsKeychainItem(bundle.name, shortId),
353
+ });
354
+ }
355
+ catch (err) {
356
+ throw new Error(`Bundle '${bundle.name}' key '${key}': ${err.message}`);
373
357
  }
374
- emitReadAudit('success');
375
- return env;
376
- }
377
- catch (err) {
378
- emitReadAudit('error', err);
379
- throw err;
380
358
  }
359
+ // `caller` is intentionally unused; see ResolveBundleOptions.
360
+ void _opts.caller;
361
+ return env;
381
362
  }
382
363
  /**
383
364
  * Read a bundle's metadata AND resolve its env in a single Touch ID prompt.
@@ -406,10 +387,8 @@ export function readAndResolveBundleEnv(name, opts = {}) {
406
387
  const reason = opts.caller
407
388
  ? `read ${name} secrets (for ${opts.caller})`
408
389
  : `read ${name} secrets`;
409
- // icloud_sync flag is unknown until we parse metadata, but the helper's
410
- // get-batch uses kSecAttrSynchronizableAny so it finds both synced and
411
- // device-local items in one shot.
412
- const fetched = getKeychainTokensBatch([metaItem, ...secretItems], false, reason);
390
+ void reason;
391
+ const fetched = getKeychainTokens([metaItem, ...secretItems]);
413
392
  const json = fetched.get(metaItem);
414
393
  if (json === undefined) {
415
394
  throw new Error(`Secrets bundle '${name}' not found.`);
@@ -428,7 +407,6 @@ export function readAndResolveBundleEnv(name, opts = {}) {
428
407
  name,
429
408
  description: parsed.description,
430
409
  allow_exec: Boolean(parsed.allow_exec),
431
- icloud_sync: Boolean(parsed.icloud_sync),
432
410
  vars: parsed.vars && typeof parsed.vars === 'object' ? parsed.vars : {},
433
411
  };
434
412
  if (typeof parsed.created_at === 'string')
@@ -490,7 +468,6 @@ export function readAndResolveBundleEnv(name, opts = {}) {
490
468
  try {
491
469
  env[key] = resolveRef(p.ref, {
492
470
  allowExec: bundle.allow_exec,
493
- iCloudSync: bundle.icloud_sync,
494
471
  keychainItemFor: (shortId) => secretsKeychainItem(bundle.name, shortId),
495
472
  });
496
473
  }
@@ -529,7 +506,7 @@ export function rotateBundleSecret(bundle, key, opts) {
529
506
  }
530
507
  const shortId = raw.slice('keychain:'.length);
531
508
  const item = secretsKeychainItem(bundle.name, shortId);
532
- setKeychainToken(item, opts.newValue, bundle.icloud_sync);
509
+ setKeychainToken(item, opts.newValue);
533
510
  if (opts.clearMeta) {
534
511
  if (bundle.meta)
535
512
  delete bundle.meta[key];
@@ -560,8 +537,8 @@ export function rotateBundleSecret(bundle, key, opts) {
560
537
  * 4) write new bundle metadata
561
538
  * 5) delete the old per-key keychain items + old metadata
562
539
  *
563
- * Steps 1-4 are reversible. If 5 partially fails (e.g. iCloud Keychain
564
- * hiccup), running `rename` again is a safe no-op for the source items.
540
+ * Steps 1-4 are reversible. If 5 partially fails, running `rename` again is
541
+ * a safe no-op for the source items.
565
542
  */
566
543
  export function renameBundle(oldName, newName, opts = {}) {
567
544
  validateBundleName(oldName);
@@ -579,7 +556,7 @@ export function renameBundle(oldName, newName, opts = {}) {
579
556
  }
580
557
  const dest = readBundle(newName);
581
558
  for (const { item } of keychainItemsForBundle(dest)) {
582
- deleteKeychainToken(item, dest.icloud_sync);
559
+ deleteKeychainToken(item);
583
560
  }
584
561
  deleteBundle(newName);
585
562
  }
@@ -592,15 +569,15 @@ export function renameBundle(oldName, newName, opts = {}) {
592
569
  continue;
593
570
  const shortId = raw.slice('keychain:'.length);
594
571
  const newItem = secretsKeychainItem(newName, shortId);
595
- const value = getKeychainToken(oldItem, source.icloud_sync);
596
- setKeychainToken(newItem, value, source.icloud_sync);
572
+ const value = getKeychainToken(oldItem);
573
+ setKeychainToken(newItem, value);
597
574
  }
598
575
  // writeBundle preserves source.created_at and refreshes updated_at.
599
576
  const renamed = { ...source, name: newName };
600
577
  writeBundle(renamed);
601
578
  // Cleanup: delete the old per-key keychain items, then the old metadata.
602
579
  for (const { item: oldItem } of sourceItems) {
603
- deleteKeychainToken(oldItem, source.icloud_sync);
580
+ deleteKeychainToken(oldItem);
604
581
  }
605
582
  deleteBundle(oldName);
606
583
  emit('secrets.rename', { from: oldName, to: newName });
@@ -674,7 +651,6 @@ export async function migrateLegacyBundles(confirmBundle) {
674
651
  name,
675
652
  description: parsed.description,
676
653
  allow_exec: Boolean(parsed.allow_exec),
677
- icloud_sync: Boolean(parsed.icloud_sync),
678
654
  vars: parsed.vars && typeof parsed.vars === 'object' ? parsed.vars : {},
679
655
  };
680
656
  const keys = Object.keys(bundle.vars);
@@ -1,14 +1,23 @@
1
1
  /**
2
2
  * Cross-platform secure credential storage.
3
3
  *
4
- * macOS: Uses Keychain via signed Swift helper (Agents CLI.app) or `security` CLI.
5
- * Linux: Uses libsecret (GNOME Keyring) via `secret-tool` CLI.
6
- * Windows: Not yet supported.
4
+ * macOS: every keychain operation goes through the signed `Agents CLI.app`
5
+ * helper. The helper attaches a biometry-or-passcode access control to every
6
+ * item it writes, so the OS itself gates decryption with Touch ID. A single
7
+ * LAContext lives for the helper's process lifetime, so a batch read pops
8
+ * Touch ID once and reuses the assertion for every item in the same batch.
9
+ * No /usr/bin/security fast path: that path bypasses the helper's ACL,
10
+ * exposes items to the legacy password sheet, and would defeat the model.
7
11
  *
8
- * The .app embeds a provisioning profile that grants the application-identifier
9
- * + keychain-access-groups entitlement macOS requires for kSecAttrSynchronizable
10
- * writes (iCloud Keychain). For device-local writes the helper is invoked with
11
- * the `nosync` arg.
12
+ * Linux: libsecret (GNOME Keyring) via the `secret-tool` CLI. No biometry —
13
+ * items are unlocked when the keyring is open.
14
+ *
15
+ * Windows: not supported.
16
+ *
17
+ * Items are device-local: the biometry access control requires the OS to
18
+ * treat them as bound to this device, so cross-machine propagation goes
19
+ * through the explicit export/import flow in src/lib/secrets/sync.ts
20
+ * rather than the system's cloud-keychain path.
12
21
  */
13
22
  /** Supported secret resolution backends. */
14
23
  export type SecretProvider = 'keychain' | 'env' | 'file' | 'exec';
@@ -44,33 +53,50 @@ export declare function secretsKeychainItem(bundle: string, key: string): string
44
53
  * tests) is destructive and would require an interactive Keychain unlock.
45
54
  */
46
55
  export interface KeychainBackend {
47
- has(item: string, sync: boolean): boolean;
48
- get(item: string, sync: boolean): string;
49
- set(item: string, value: string, sync: boolean): void;
50
- delete(item: string, sync: boolean): boolean;
56
+ has(item: string): boolean;
57
+ get(item: string): string;
58
+ set(item: string, value: string): void;
59
+ delete(item: string): boolean;
51
60
  list(prefix: string): string[];
52
61
  }
53
62
  /** Install a custom keychain backend (test only). Returns the previous backend so callers can restore. */
54
63
  export declare function setKeychainBackendForTest(b: KeychainBackend | null): KeychainBackend | null;
55
- /** Check if a keychain/keyring item exists. */
56
- export declare function hasKeychainToken(item: string, sync?: boolean): boolean;
57
- /** Retrieve a secret value from the keychain/keyring. Throws if not found. */
58
- export declare function getKeychainToken(item: string, sync?: boolean): string;
64
+ /** Check if a keychain/keyring item exists. Never prompts for biometry. */
65
+ export declare function hasKeychainToken(item: string): boolean;
59
66
  /**
60
- * Read multiple keychain items, returning a Map keyed by item name. Missing or
61
- * unreadable items are simply absent from the map (the caller decides whether a
62
- * given key was required).
67
+ * Retrieve a secret value from the keychain/keyring. Throws if not found.
63
68
  *
64
- * On macOS this uses the signed helper's `get-batch` command so one LAContext
65
- * can satisfy all protected item reads for the bundle.
69
+ * On macOS this triggers Touch ID (or reuses an assertion held by an earlier
70
+ * call in the same process). For bundles, prefer getKeychainTokens() so a
71
+ * single biometric prompt covers every key in the batch.
66
72
  */
67
- export declare function getKeychainTokensBatch(items: string[], sync?: boolean, reason?: string): Map<string, string>;
68
- /** Store or update a secret value in the keychain/keyring. iCloud-synced when sync=true (macOS only). */
69
- export declare function setKeychainToken(item: string, value: string, sync?: boolean): void;
70
- /** Delete a keychain/keyring item. Returns true if it existed. */
71
- export declare function deleteKeychainToken(item: string, sync?: boolean): boolean;
73
+ export declare function getKeychainToken(item: string): string;
74
+ /**
75
+ * Batch-read multiple keychain items behind a single Touch ID prompt. The
76
+ * macOS helper holds one LAContext for its whole process: the first protected
77
+ * item triggers Touch ID, every later item in the same invocation reuses the
78
+ * assertion. Missing items are absent from the returned map (caller decides
79
+ * whether that's an error).
80
+ *
81
+ * On Linux or when a test backend is installed, falls back to individual
82
+ * lookups — no biometric prompt path on those platforms.
83
+ */
84
+ export declare function getKeychainTokens(items: string[]): Map<string, string>;
85
+ /** Store or update a secret value in the keychain/keyring. Device-local; biometry-gated on macOS. */
86
+ export declare function setKeychainToken(item: string, value: string): void;
87
+ /** Delete a keychain/keyring item. Returns true if it existed. Never prompts for biometry. */
88
+ export declare function deleteKeychainToken(item: string): boolean;
72
89
  /** Enumerate keychain/keyring item names starting with the given prefix. */
73
90
  export declare function listKeychainItems(prefix: string): string[];
91
+ /**
92
+ * One-time upgrade for a keychain item that was written by a previous helper
93
+ * generation with a trusted-app ACL. The helper reads the legacy item
94
+ * (which may pop the password sheet once), then deletes and re-adds it with
95
+ * the biometry access control. Returns true if the item was rewritten, false
96
+ * if no item by that name exists. macOS only — Linux backends have no ACL
97
+ * concept, so the call is a no-op there.
98
+ */
99
+ export declare function migrateKeychainItem(item: string): boolean;
74
100
  /** Options controlling how secret refs are resolved. */
75
101
  export interface ResolveOptions {
76
102
  /** Translate a short keychain ID to a fully namespaced item name. */
@@ -79,8 +105,6 @@ export interface ResolveOptions {
79
105
  allowExec?: boolean;
80
106
  /** Restrict env: refs to this allowlist. When undefined, any env var may be read. */
81
107
  envAllowlist?: string[];
82
- /** Read keychain refs from the iCloud-synced keychain backend. */
83
- iCloudSync?: boolean;
84
108
  }
85
109
  /** Resolve a secret ref to its plaintext value using the appropriate provider. */
86
110
  export declare function resolveRef(ref: SecretRef, opts?: ResolveOptions): string;