@phnx-labs/agents-cli 1.20.77 → 1.20.78

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 (70) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +2 -0
  3. package/dist/bin/agents +0 -0
  4. package/dist/commands/doctor.d.ts +9 -0
  5. package/dist/commands/doctor.js +143 -9
  6. package/dist/commands/exec.js +29 -3
  7. package/dist/commands/repo.js +8 -0
  8. package/dist/commands/routines.js +4 -2
  9. package/dist/commands/secrets.js +8 -2
  10. package/dist/commands/sessions-browser.d.ts +45 -3
  11. package/dist/commands/sessions-browser.js +118 -12
  12. package/dist/commands/sessions-export.d.ts +3 -0
  13. package/dist/commands/sessions-export.js +13 -10
  14. package/dist/commands/sessions-picker.d.ts +15 -1
  15. package/dist/commands/sessions-picker.js +58 -4
  16. package/dist/commands/sessions.d.ts +95 -1
  17. package/dist/commands/sessions.js +224 -26
  18. package/dist/commands/ssh.js +9 -1
  19. package/dist/index.js +3 -5
  20. package/dist/lib/agents.d.ts +0 -21
  21. package/dist/lib/agents.js +0 -37
  22. package/dist/lib/auto-pull.d.ts +16 -8
  23. package/dist/lib/auto-pull.js +23 -28
  24. package/dist/lib/daemon.d.ts +9 -41
  25. package/dist/lib/daemon.js +16 -117
  26. package/dist/lib/devices/fleet-divergence.d.ts +101 -0
  27. package/dist/lib/devices/fleet-divergence.js +188 -0
  28. package/dist/lib/devices/fleet-inventory.d.ts +19 -0
  29. package/dist/lib/devices/fleet-inventory.js +57 -0
  30. package/dist/lib/devices/health-report.d.ts +10 -2
  31. package/dist/lib/devices/health-report.js +32 -1
  32. package/dist/lib/git.d.ts +13 -0
  33. package/dist/lib/git.js +102 -4
  34. package/dist/lib/hosts/remote-cmd.js +2 -0
  35. package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +2 -0
  36. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  37. package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
  38. package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +15 -2
  39. package/dist/lib/runner.js +29 -26
  40. package/dist/lib/sandbox.js +0 -16
  41. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  42. package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +2 -0
  43. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  44. package/dist/lib/secrets/Agents CLI.app/Contents/Resources/AppIcon.icns +0 -0
  45. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +13 -1
  46. package/dist/lib/secrets/agent.d.ts +2 -0
  47. package/dist/lib/secrets/agent.js +26 -14
  48. package/dist/lib/secrets/bundles.d.ts +1 -1
  49. package/dist/lib/secrets/bundles.js +16 -8
  50. package/dist/lib/secrets/scope.d.ts +26 -0
  51. package/dist/lib/secrets/scope.js +29 -0
  52. package/dist/lib/secrets/session-store.d.ts +10 -0
  53. package/dist/lib/secrets/session-store.js +64 -11
  54. package/dist/lib/session/active.d.ts +7 -0
  55. package/dist/lib/session/active.js +38 -3
  56. package/dist/lib/session/db.d.ts +37 -0
  57. package/dist/lib/session/db.js +112 -4
  58. package/dist/lib/session/digest.js +126 -21
  59. package/dist/lib/session/discover.d.ts +15 -2
  60. package/dist/lib/session/discover.js +19 -11
  61. package/dist/lib/session/origin-machine.d.ts +18 -0
  62. package/dist/lib/session/origin-machine.js +34 -0
  63. package/dist/lib/session/state.d.ts +1 -0
  64. package/dist/lib/session/state.js +1 -1
  65. package/dist/lib/session/sync/config.js +2 -2
  66. package/dist/lib/smart-launch.d.ts +86 -0
  67. package/dist/lib/smart-launch.js +172 -0
  68. package/package.json +1 -1
  69. package/dist/lib/secrets/account-token.d.ts +0 -20
  70. package/dist/lib/secrets/account-token.js +0 -64
@@ -1,64 +0,0 @@
1
- // Per-account Claude setup-token resolution.
2
- //
3
- // A headless/unattended Claude run should authenticate with the account's
4
- // long-lived `claude setup-token` (exported as a per-account
5
- // `CLAUDE_CODE_OAUTH_TOKEN_<slug>` env var), NOT the interactive OAuth session.
6
- // Claude Code's interactive session uses single-use ROTATING refresh tokens: when
7
- // one machine refreshes, the server invalidates the old refresh token globally, so
8
- // every other machine on that account 401s and gets logged out (Claude Code
9
- // #25609 / #56339). The 1-year setup-token sits earlier in the auth precedence
10
- // (`CLAUDE_CODE_OAUTH_TOKEN`, before subscription login) and does not participate
11
- // in that rotation — so per-account setup-tokens keep the fleet signed in.
12
- //
13
- // The per-account env key encodes the account email. The convention (verified
14
- // against live bundles, e.g. `muqsit@getrush.ai` →
15
- // `CLAUDE_CODE_OAUTH_TOKEN_MUQSIT_AT_GETRUSH_DOT_AI`): upper-case, `@`→`_AT_`,
16
- // `.`→`_DOT_`, any other non-alphanumeric → `_`.
17
- import fs from 'node:fs';
18
- import path from 'node:path';
19
- /** The `CLAUDE_CODE_OAUTH_TOKEN_<slug>` env key for a given account email/id. */
20
- export function accountTokenKey(account) {
21
- const slug = account
22
- .trim()
23
- .toUpperCase()
24
- .replace(/@/g, '_AT_')
25
- .replace(/\./g, '_DOT_')
26
- .replace(/[^A-Z0-9_]/g, '_');
27
- return `CLAUDE_CODE_OAUTH_TOKEN_${slug}`;
28
- }
29
- /**
30
- * Read the signed-in account email for a Claude version home from
31
- * `oauthAccount.emailAddress`. Sync, no keychain, no network. Tries both stores
32
- * the canonical resolver uses (agents.ts getAccountInfo): the shim-set
33
- * `CLAUDE_CONFIG_DIR` location `<home>/.claude/.claude.json` first, then the
34
- * home-level `<home>/.claude.json` (an account signed in via the IDE / direct
35
- * binary without the shim writes there). Returns null when neither has a usable
36
- * email.
37
- */
38
- export function readClaudeAccountEmail(home) {
39
- for (const p of [path.join(home, '.claude', '.claude.json'), path.join(home, '.claude.json')]) {
40
- try {
41
- const email = JSON.parse(fs.readFileSync(p, 'utf-8')).oauthAccount?.emailAddress;
42
- if (typeof email === 'string' && email.trim().length > 0)
43
- return email.trim();
44
- }
45
- catch {
46
- // Missing/unreadable/malformed at this location — try the next.
47
- }
48
- }
49
- return null;
50
- }
51
- /**
52
- * Resolve the per-account setup-token for the account pinned to `home`, looking
53
- * it up in the provided env (the daemon injects the `claude` bundle's
54
- * `CLAUDE_CODE_OAUTH_TOKEN_*` keys). Returns null when the home has no known
55
- * account, or no matching per-account token is present — callers then leave the
56
- * existing ambient/interactive credential untouched (a safe no-op).
57
- */
58
- export function resolveAccountSetupToken(env, home) {
59
- const email = readClaudeAccountEmail(home);
60
- if (!email)
61
- return null;
62
- const token = env[accountTokenKey(email)];
63
- return typeof token === 'string' && token.trim().length > 0 ? token.trim() : null;
64
- }