@phnx-labs/agents-cli 1.20.33 → 1.20.35

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 (159) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +32 -2
  3. package/dist/commands/computer-actions.d.ts +15 -0
  4. package/dist/commands/computer-actions.js +120 -22
  5. package/dist/commands/computer.d.ts +23 -0
  6. package/dist/commands/computer.js +45 -3
  7. package/dist/commands/cost.js +17 -12
  8. package/dist/commands/doctor.d.ts +11 -0
  9. package/dist/commands/doctor.js +108 -14
  10. package/dist/commands/events.d.ts +16 -0
  11. package/dist/commands/events.js +173 -0
  12. package/dist/commands/exec.js +6 -1
  13. package/dist/commands/hosts.js +28 -24
  14. package/dist/commands/import.js +1 -1
  15. package/dist/commands/inspect.d.ts +2 -0
  16. package/dist/commands/inspect.js +54 -7
  17. package/dist/commands/logs.d.ts +17 -0
  18. package/dist/commands/logs.js +139 -0
  19. package/dist/commands/models.d.ts +3 -0
  20. package/dist/commands/models.js +27 -8
  21. package/dist/commands/permissions.js +9 -2
  22. package/dist/commands/repo.d.ts +34 -0
  23. package/dist/commands/repo.js +243 -65
  24. package/dist/commands/resource-view.d.ts +20 -0
  25. package/dist/commands/resource-view.js +90 -28
  26. package/dist/commands/rules.js +1 -1
  27. package/dist/commands/secrets-migrate.js +23 -11
  28. package/dist/commands/secrets.d.ts +20 -0
  29. package/dist/commands/secrets.js +93 -17
  30. package/dist/commands/sessions-resume.d.ts +2 -0
  31. package/dist/commands/sessions-resume.js +209 -0
  32. package/dist/commands/sessions-tail.d.ts +10 -0
  33. package/dist/commands/sessions-tail.js +11 -0
  34. package/dist/commands/sessions.d.ts +73 -1
  35. package/dist/commands/sessions.js +273 -53
  36. package/dist/commands/status.d.ts +12 -0
  37. package/dist/commands/status.js +81 -0
  38. package/dist/commands/teams.js +70 -6
  39. package/dist/commands/versions.js +2 -1
  40. package/dist/commands/view.d.ts +42 -0
  41. package/dist/commands/view.js +213 -83
  42. package/dist/commands/wallet.d.ts +6 -0
  43. package/dist/commands/wallet.js +22 -5
  44. package/dist/index.js +61 -32
  45. package/dist/lib/acp/harnesses.d.ts +1 -1
  46. package/dist/lib/acp/harnesses.js +2 -2
  47. package/dist/lib/agents.d.ts +12 -0
  48. package/dist/lib/agents.js +145 -41
  49. package/dist/lib/browser/cdp.js +5 -1
  50. package/dist/lib/browser/chrome.js +20 -0
  51. package/dist/lib/browser/drivers/ssh.d.ts +27 -0
  52. package/dist/lib/browser/drivers/ssh.js +94 -19
  53. package/dist/lib/browser/ipc.d.ts +3 -0
  54. package/dist/lib/browser/ipc.js +13 -9
  55. package/dist/lib/browser/service.js +71 -15
  56. package/dist/lib/daemon.d.ts +35 -0
  57. package/dist/lib/daemon.js +33 -5
  58. package/dist/lib/devices/connect.d.ts +3 -2
  59. package/dist/lib/devices/connect.js +5 -3
  60. package/dist/lib/doctor-diff.js +29 -2
  61. package/dist/lib/drift-sync.d.ts +43 -0
  62. package/dist/lib/drift-sync.js +179 -0
  63. package/dist/lib/events.d.ts +9 -2
  64. package/dist/lib/events.js +70 -11
  65. package/dist/lib/exec.d.ts +15 -0
  66. package/dist/lib/exec.js +43 -11
  67. package/dist/lib/hooks.js +8 -2
  68. package/dist/lib/hosts/dispatch.js +6 -7
  69. package/dist/lib/hosts/logs.d.ts +16 -0
  70. package/dist/lib/hosts/logs.js +45 -0
  71. package/dist/lib/hosts/progress.d.ts +66 -0
  72. package/dist/lib/hosts/progress.js +125 -17
  73. package/dist/lib/hosts/ready.d.ts +23 -2
  74. package/dist/lib/hosts/ready.js +35 -13
  75. package/dist/lib/hosts/reconcile.d.ts +53 -0
  76. package/dist/lib/hosts/reconcile.js +81 -0
  77. package/dist/lib/hosts/tasks.d.ts +8 -0
  78. package/dist/lib/hosts/tasks.js +14 -0
  79. package/dist/lib/permissions.d.ts +4 -0
  80. package/dist/lib/permissions.js +35 -0
  81. package/dist/lib/picker.d.ts +24 -0
  82. package/dist/lib/picker.js +124 -0
  83. package/dist/lib/platform/winpath.d.ts +31 -2
  84. package/dist/lib/platform/winpath.js +133 -24
  85. package/dist/lib/plugin-marketplace.d.ts +30 -0
  86. package/dist/lib/plugin-marketplace.js +215 -2
  87. package/dist/lib/plugins.d.ts +5 -0
  88. package/dist/lib/plugins.js +45 -4
  89. package/dist/lib/pwsh.d.ts +11 -0
  90. package/dist/lib/pwsh.js +13 -0
  91. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  92. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  93. package/dist/lib/secrets/agent.d.ts +42 -1
  94. package/dist/lib/secrets/agent.js +89 -11
  95. package/dist/lib/secrets/bundles.js +40 -9
  96. package/dist/lib/secrets/filestore.js +31 -1
  97. package/dist/lib/secrets/index.d.ts +33 -1
  98. package/dist/lib/secrets/index.js +90 -9
  99. package/dist/lib/secrets/windows.d.ts +74 -0
  100. package/dist/lib/secrets/windows.js +440 -0
  101. package/dist/lib/session/active.d.ts +7 -0
  102. package/dist/lib/session/active.js +11 -3
  103. package/dist/lib/session/discover.js +94 -0
  104. package/dist/lib/session/parse.d.ts +6 -0
  105. package/dist/lib/session/parse.js +283 -2
  106. package/dist/lib/session/pid-registry.d.ts +21 -0
  107. package/dist/lib/session/pid-registry.js +80 -0
  108. package/dist/lib/session/remote-active.d.ts +26 -0
  109. package/dist/lib/session/remote-active.js +141 -0
  110. package/dist/lib/session/remote.js +2 -6
  111. package/dist/lib/session/render.js +1 -1
  112. package/dist/lib/session/sync/config.d.ts +8 -0
  113. package/dist/lib/session/sync/config.js +11 -2
  114. package/dist/lib/session/types.d.ts +1 -1
  115. package/dist/lib/session/types.js +1 -1
  116. package/dist/lib/shims.d.ts +30 -2
  117. package/dist/lib/shims.js +107 -50
  118. package/dist/lib/ssh-exec.d.ts +26 -3
  119. package/dist/lib/ssh-exec.js +45 -3
  120. package/dist/lib/ssh-tunnel.d.ts +24 -5
  121. package/dist/lib/ssh-tunnel.js +60 -62
  122. package/dist/lib/staleness/writers/hooks.js +1 -1
  123. package/dist/lib/startup/command-registry.d.ts +3 -0
  124. package/dist/lib/startup/command-registry.js +6 -0
  125. package/dist/lib/sync-status.d.ts +102 -0
  126. package/dist/lib/sync-status.js +135 -0
  127. package/dist/lib/teams/agents.d.ts +24 -0
  128. package/dist/lib/teams/agents.js +30 -1
  129. package/dist/lib/teams/registry.js +25 -9
  130. package/dist/lib/terminal/backends/ghostty.d.ts +6 -0
  131. package/dist/lib/terminal/backends/ghostty.js +69 -0
  132. package/dist/lib/terminal/backends/index.d.ts +18 -0
  133. package/dist/lib/terminal/backends/index.js +29 -0
  134. package/dist/lib/terminal/backends/iterm.d.ts +6 -0
  135. package/dist/lib/terminal/backends/iterm.js +62 -0
  136. package/dist/lib/terminal/backends/tmux.d.ts +14 -0
  137. package/dist/lib/terminal/backends/tmux.js +23 -0
  138. package/dist/lib/terminal/engine.d.ts +39 -0
  139. package/dist/lib/terminal/engine.js +54 -0
  140. package/dist/lib/terminal/index.d.ts +14 -0
  141. package/dist/lib/terminal/index.js +5 -0
  142. package/dist/lib/terminal/policy.d.ts +11 -0
  143. package/dist/lib/terminal/policy.js +11 -0
  144. package/dist/lib/terminal/quote.d.ts +11 -0
  145. package/dist/lib/terminal/quote.js +13 -0
  146. package/dist/lib/terminal/shell.d.ts +6 -0
  147. package/dist/lib/terminal/shell.js +23 -0
  148. package/dist/lib/terminal/transport.d.ts +15 -0
  149. package/dist/lib/terminal/transport.js +40 -0
  150. package/dist/lib/terminal/types.d.ts +59 -0
  151. package/dist/lib/terminal/types.js +13 -0
  152. package/dist/lib/types.d.ts +27 -1
  153. package/dist/lib/usage.d.ts +30 -0
  154. package/dist/lib/usage.js +159 -2
  155. package/dist/lib/versions.d.ts +7 -3
  156. package/dist/lib/versions.js +10 -5
  157. package/dist/lib/whats-new.d.ts +9 -0
  158. package/dist/lib/whats-new.js +35 -0
  159. package/package.json +1 -1
@@ -12,7 +12,10 @@
12
12
  * Linux: libsecret (GNOME Keyring) via the `secret-tool` CLI. No biometry —
13
13
  * items are unlocked when the keyring is open.
14
14
  *
15
- * Windows: not supported.
15
+ * Windows: Windows Credential Manager (CRED_TYPE_GENERIC,
16
+ * CRED_PERSIST_LOCAL_MACHINE) via a PowerShell P/Invoke shim, with the same
17
+ * AES-256-GCM encrypted-file fallback used on Linux when the credential store
18
+ * is unreachable (no logon session / no powershell.exe). No biometry.
16
19
  *
17
20
  * Items are device-local: the biometry access control requires the OS to
18
21
  * treat them as bound to this device, so cross-machine propagation goes
@@ -24,6 +27,7 @@ import * as fs from 'fs';
24
27
  import * as os from 'os';
25
28
  import * as path from 'path';
26
29
  import { linuxBackend, usesFileFallback as linuxUsesFileFallback } from './linux.js';
30
+ import { windowsBackend, usesFileFallback as windowsUsesFileFallback } from './windows.js';
27
31
  import { getKeychainHelperPath } from './install-helper.js';
28
32
  const SERVICE_PREFIX = 'agents-cli';
29
33
  const SECRETS_ITEM_PREFIX = `${SERVICE_PREFIX}.secrets.`;
@@ -47,15 +51,36 @@ export function serializeRef(ref) {
47
51
  return `${ref.provider}:${ref.value}`;
48
52
  }
49
53
  function assertSupportedPlatform() {
50
- if (process.platform !== 'darwin' && process.platform !== 'linux') {
51
- throw new Error('agents secrets requires macOS Keychain or Linux libsecret.\n' +
52
- 'Windows is not supported — use environment variables or a .env file instead.\n' +
53
- 'WSL2 is supported (libsecret via gnome-keyring).');
54
+ if (process.platform !== 'darwin' && process.platform !== 'linux' && process.platform !== 'win32') {
55
+ throw new Error('agents secrets requires macOS Keychain, Linux libsecret, or Windows Credential Manager.\n' +
56
+ 'Use environment variables or a .env file on unsupported platforms.');
54
57
  }
55
58
  }
56
59
  function isLinux() {
57
60
  return process.platform === 'linux';
58
61
  }
62
+ function isWindows() {
63
+ return process.platform === 'win32';
64
+ }
65
+ /**
66
+ * Guard a secret value before it is written to the current platform's primary
67
+ * backend.
68
+ *
69
+ * A value is empty on every platform → always rejected. Embedded newlines are
70
+ * rejected ONLY on darwin: the macOS batch read path (`get-batch`, see
71
+ * getKeychainTokens) is newline-delimited, so a value with a newline would
72
+ * corrupt record framing on read. Linux (secret-tool), Windows (Credential
73
+ * Manager stores the raw UTF-8 blob and emits base64), and the encrypted-file
74
+ * fallback all store raw bytes and round-trip multiline values (PEM / SSH keys)
75
+ * faithfully, so they accept newlines. `platform` is injectable for tests.
76
+ */
77
+ export function assertValueStorable(value, platform = process.platform) {
78
+ if (!value || !value.trim())
79
+ throw new Error('Secret value is empty.');
80
+ if (platform === 'darwin' && /[\r\n]/.test(value)) {
81
+ throw new Error('Secret value contains newlines, which are not supported.');
82
+ }
83
+ }
59
84
  /** Build the keychain item name for a profile provider token. */
60
85
  export function profileKeychainItem(provider) {
61
86
  return `${SERVICE_PREFIX}.${provider}.token`;
@@ -74,6 +99,13 @@ export function setKeychainBackendForTest(b) {
74
99
  backend = b;
75
100
  return prev;
76
101
  }
102
+ /** True when a test backend is installed (real keychain / biometry bypassed).
103
+ * Callers that gate on the live secrets-agent broker use this to stay hermetic —
104
+ * with an in-memory backend there is no real keychain to dedup, so the broker
105
+ * fast-path must not engage. Always false in production (`backend` is null). */
106
+ export function isKeychainBackendOverridden() {
107
+ return backend !== null;
108
+ }
77
109
  /**
78
110
  * Items whose name does NOT start with `agents-cli.` belong to another
79
111
  * application (e.g. Anthropic's `Claude Code-credentials-*`). Their ACL
@@ -93,6 +125,8 @@ export function hasKeychainToken(item) {
93
125
  assertSupportedPlatform();
94
126
  if (isLinux())
95
127
  return linuxBackend.has(item);
128
+ if (isWindows())
129
+ return windowsBackend.has(item);
96
130
  if (!isOurItem(item)) {
97
131
  return spawnSync('/usr/bin/security', ['find-generic-password', '-a', os.userInfo().username, '-s', item], {
98
132
  stdio: ['ignore', 'ignore', 'ignore'],
@@ -116,6 +150,8 @@ export function getKeychainToken(item) {
116
150
  assertSupportedPlatform();
117
151
  if (isLinux())
118
152
  return linuxBackend.get(item);
153
+ if (isWindows())
154
+ return windowsBackend.get(item);
119
155
  if (!isOurItem(item)) {
120
156
  const sec = spawnSync('/usr/bin/security', ['find-generic-password', '-a', os.userInfo().username, '-s', item, '-w'], {
121
157
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -177,6 +213,15 @@ export function getKeychainTokens(items) {
177
213
  }
178
214
  return result;
179
215
  }
216
+ if (isWindows()) {
217
+ for (const item of items) {
218
+ try {
219
+ result.set(item, windowsBackend.get(item));
220
+ }
221
+ catch { /* missing — skip */ }
222
+ }
223
+ return result;
224
+ }
180
225
  const bin = getKeychainHelperPath();
181
226
  const child = spawnSync(bin, ['get-batch', os.userInfo().username, ...items], {
182
227
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -226,16 +271,17 @@ export function setKeychainToken(item, value) {
226
271
  return;
227
272
  }
228
273
  assertSupportedPlatform();
229
- if (!value || !value.trim())
230
- throw new Error('Secret value is empty.');
231
- if (/[\r\n]/.test(value))
232
- throw new Error('Secret value contains newlines, which are not supported.');
274
+ assertValueStorable(value);
233
275
  if (/[\x00=\r\n]/.test(item))
234
276
  throw new Error('Secret item name contains invalid characters.');
235
277
  if (isLinux()) {
236
278
  linuxBackend.set(item, value);
237
279
  return;
238
280
  }
281
+ if (isWindows()) {
282
+ windowsBackend.set(item, value);
283
+ return;
284
+ }
239
285
  // Bare (non-`agents-cli.`) items are written WITHOUT the biometry ACL so
240
286
  // they round-trip with the no-prompt read path in getKeychainToken (which
241
287
  // also uses /usr/bin/security for non-our items). This is what lets a
@@ -273,6 +319,8 @@ export function deleteKeychainToken(item) {
273
319
  assertSupportedPlatform();
274
320
  if (isLinux())
275
321
  return linuxBackend.delete(item);
322
+ if (isWindows())
323
+ return windowsBackend.delete(item);
276
324
  const bin = getKeychainHelperPath();
277
325
  return spawnSync(bin, ['delete', item, os.userInfo().username], {
278
326
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -293,6 +341,8 @@ export function keychainUsesFileFallback() {
293
341
  return false;
294
342
  if (isLinux())
295
343
  return linuxUsesFileFallback();
344
+ if (isWindows())
345
+ return windowsUsesFileFallback();
296
346
  return false;
297
347
  }
298
348
  /** Enumerate keychain/keyring item names starting with the given prefix. */
@@ -302,6 +352,8 @@ export function listKeychainItems(prefix) {
302
352
  assertSupportedPlatform();
303
353
  if (isLinux())
304
354
  return linuxBackend.list(prefix);
355
+ if (isWindows())
356
+ return windowsBackend.list(prefix);
305
357
  const bin = getKeychainHelperPath();
306
358
  const result = spawnSync(bin, ['list', prefix], {
307
359
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -313,6 +365,33 @@ export function listKeychainItems(prefix) {
313
365
  const out = result.stdout?.toString() || '';
314
366
  return out.split('\n').map((s) => s.trim()).filter(Boolean);
315
367
  }
368
+ /**
369
+ * Enumerate ONLY legacy file-based-keychain item names with the given prefix —
370
+ * the items that still carry a pre-migration (trusted-app) ACL and pop a
371
+ * separate auth sheet on read. Items already in the data-protection keychain are
372
+ * excluded (they need no migration). Silent (attributes only, never decrypts).
373
+ *
374
+ * macOS only: on Linux / the test backend there is no separate legacy keychain,
375
+ * so this returns []. Used by `agents secrets migrate-acl` to rewrite only the
376
+ * stragglers instead of every item (which would be a Touch ID storm).
377
+ */
378
+ export function listLegacyKeychainItems(prefix) {
379
+ if (backend)
380
+ return [];
381
+ assertSupportedPlatform();
382
+ if (isLinux())
383
+ return [];
384
+ const bin = getKeychainHelperPath();
385
+ const result = spawnSync(bin, ['list-legacy', prefix], {
386
+ stdio: ['ignore', 'pipe', 'pipe'],
387
+ });
388
+ if (result.status !== 0) {
389
+ const msg = result.stderr?.toString().trim();
390
+ throw new Error(msg || `Failed to enumerate legacy keychain items with prefix '${prefix}'.`);
391
+ }
392
+ const out = result.stdout?.toString() || '';
393
+ return out.split('\n').map((s) => s.trim()).filter(Boolean);
394
+ }
316
395
  /**
317
396
  * One-time upgrade for a keychain item that was written by a previous helper
318
397
  * generation with a trusted-app ACL. The helper reads the legacy item
@@ -327,6 +406,8 @@ export function migrateKeychainItem(item) {
327
406
  assertSupportedPlatform();
328
407
  if (isLinux())
329
408
  return linuxBackend.has(item);
409
+ if (isWindows())
410
+ return windowsBackend.has(item);
330
411
  const bin = getKeychainHelperPath();
331
412
  const result = spawnSync(bin, ['migrate-acl', item, os.userInfo().username], {
332
413
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Windows secret storage via Windows Credential Manager (wincred).
3
+ *
4
+ * Primary backend: the Credential Manager `advapi32` API (CredReadW /
5
+ * CredWriteW / CredDeleteW / CredEnumerateW), reached through a static
6
+ * PowerShell script that P/Invokes the C# shim below. PowerShell (Windows
7
+ * PowerShell 5.1) ships with every supported Windows, so there is no separate
8
+ * install step. Items are stored as CRED_TYPE_GENERIC with
9
+ * CRED_PERSIST_LOCAL_MACHINE — device-local, matching the biometry-bound model
10
+ * on macOS (src/lib/secrets/index.ts).
11
+ *
12
+ * Zero injection surface: the PS script is a single STATIC constant. All
13
+ * dynamic data rides in the child ENV (target name, list prefix) or STDIN (the
14
+ * secret value) — nothing is string-interpolated into the script. The child is
15
+ * spawned with a spawnSync ARGV ARRAY (`-EncodedCommand <base64>`), never a
16
+ * shell string.
17
+ *
18
+ * Headless fallback: when Credential Manager is unreachable (no logon session —
19
+ * ERROR_NO_SUCH_LOGON_SESSION 1312 — or powershell.exe missing from PATH), we
20
+ * transparently switch to the AES-256-GCM encrypted-file store in
21
+ * ./filestore.ts, exactly like the Linux locked-collection fallback. The
22
+ * decision is cached per process; one stderr line is emitted the first time.
23
+ *
24
+ * Item names are stored VERBATIM as the credential TargetName
25
+ * (`agents-cli.bundles.<name>` / `agents-cli.secrets.<bundle>.<key>` — the
26
+ * scheme shared with the file store, see ./filestore.ts) so `list` returns item
27
+ * names directly.
28
+ */
29
+ import type { KeychainBackend } from './index.js';
30
+ export { encryptForFallback, decryptForFallback, fileBackend, type EncFile, } from './filestore.js';
31
+ /**
32
+ * CRED_MAX_CREDENTIAL_BLOB_SIZE — Credential Manager rejects a generic
33
+ * credential blob larger than 2560 bytes with an opaque CredWrite failure. We
34
+ * guard against it in `set` with a clear message. Only pathologically large
35
+ * bundle metadata could hit this; such an item should live in a file-backed
36
+ * bundle (AGENTS_SECRETS_PASSPHRASE) instead.
37
+ */
38
+ export declare const CRED_MAX_CREDENTIAL_BLOB_SIZE = 2560;
39
+ /**
40
+ * True when secret operations currently route to the encrypted-file store
41
+ * instead of Windows Credential Manager. Mirrors linux.ts:usesFileFallback so
42
+ * `listBundles()` doesn't double-count file-backed bundles under the fallback.
43
+ */
44
+ export declare function usesFileFallback(): boolean;
45
+ export declare function hasCredManToken(item: string): boolean;
46
+ export declare function getCredManToken(item: string): string;
47
+ export declare function setCredManToken(item: string, value: string): void;
48
+ export declare function deleteCredManToken(item: string): boolean;
49
+ export declare function listCredManItems(prefix: string): string[];
50
+ /**
51
+ * Parse the target names printed by the `list` op (one per line), keeping only
52
+ * those starting with `prefix` and deduping. Same contract as
53
+ * parseSecretToolItems (linux.ts). Exported for tests.
54
+ */
55
+ export declare function parseWindowsCredList(output: string, prefix: string): string[];
56
+ /**
57
+ * KeychainBackend implementation for Windows. Routes through Windows Credential
58
+ * Manager (via PowerShell P/Invoke) with a transparent encrypted-file fallback
59
+ * when the credential store is unreachable.
60
+ */
61
+ export declare const windowsBackend: KeychainBackend;
62
+ /**
63
+ * Test-only: reset module state so independent test cases don't bleed
64
+ * availability / fallback decisions across each other. Pass `forceAvailable` to
65
+ * pin the powershell-availability probe (skips the real spawn); pass `fileDir`
66
+ * to redirect the encrypted-file store to a temp dir. File-store state lives in
67
+ * ./filestore.ts and is reset there.
68
+ */
69
+ export declare function _resetForTest(opts?: {
70
+ fileDir?: string | null;
71
+ forceFileFallback?: boolean;
72
+ passphrase?: string | null;
73
+ forceAvailable?: boolean | null;
74
+ }): void;