@phnx-labs/agents-cli 1.22.56 → 1.22.58

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 (146) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +4 -4
  3. package/dist/bootstrap.js +11 -2
  4. package/dist/cli/command-registry.d.ts +0 -1
  5. package/dist/cli/command-registry.js +0 -3
  6. package/dist/commands/accounts.js +7 -3
  7. package/dist/commands/apply.js +10 -2
  8. package/dist/commands/exec.js +1 -1
  9. package/dist/commands/fork.d.ts +23 -10
  10. package/dist/commands/fork.js +115 -58
  11. package/dist/commands/hooks.js +4 -4
  12. package/dist/commands/insights.d.ts +7 -5
  13. package/dist/commands/insights.js +16 -9
  14. package/dist/commands/monitors.js +11 -0
  15. package/dist/commands/perf.d.ts +16 -7
  16. package/dist/commands/perf.js +29 -20
  17. package/dist/commands/prune.js +5 -3
  18. package/dist/commands/routines.d.ts +8 -0
  19. package/dist/commands/routines.js +57 -3
  20. package/dist/commands/rules.js +1 -1
  21. package/dist/commands/sessions-picker.d.ts +11 -0
  22. package/dist/commands/sessions-picker.js +16 -0
  23. package/dist/commands/sessions.js +1 -0
  24. package/dist/commands/share.d.ts +14 -0
  25. package/dist/commands/share.js +43 -2
  26. package/dist/commands/ssh.js +24 -14
  27. package/dist/commands/status.js +1 -1
  28. package/dist/commands/sync.js +83 -7
  29. package/dist/commands/traces.js +7 -0
  30. package/dist/commands/trash.d.ts +2 -2
  31. package/dist/commands/trash.js +2 -6
  32. package/dist/commands/versions.d.ts +2 -2
  33. package/dist/commands/versions.js +1 -10
  34. package/dist/commands/view.d.ts +2 -2
  35. package/dist/commands/view.js +7 -6
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +14 -0
  38. package/dist/lib/account-registry.d.ts +5 -1
  39. package/dist/lib/account-registry.js +47 -14
  40. package/dist/lib/accounting/capacity.d.ts +18 -7
  41. package/dist/lib/accounting/capacity.js +19 -8
  42. package/dist/lib/accounting/usage-ingest.d.ts +1 -0
  43. package/dist/lib/accounting/usage-ingest.js +75 -0
  44. package/dist/lib/accounting/usage-sync.d.ts +97 -0
  45. package/dist/lib/accounting/usage-sync.js +203 -0
  46. package/dist/lib/accounting/usage.d.ts +48 -2
  47. package/dist/lib/accounting/usage.js +79 -2
  48. package/dist/lib/agent-spec/agents.js +1 -1
  49. package/dist/lib/analytics/mix-commands.d.ts +8 -7
  50. package/dist/lib/analytics/mix-commands.js +50 -73
  51. package/dist/lib/auth-mint.d.ts +11 -1
  52. package/dist/lib/auth-mint.js +21 -6
  53. package/dist/lib/browser/ipc.d.ts +8 -0
  54. package/dist/lib/browser/ipc.js +87 -0
  55. package/dist/lib/browser/service.d.ts +19 -0
  56. package/dist/lib/browser/service.js +96 -11
  57. package/dist/lib/browser/sessions-list.js +10 -1
  58. package/dist/lib/daemon/daemon.js +5 -0
  59. package/dist/lib/daemon/runner.d.ts +3 -0
  60. package/dist/lib/daemon/runner.js +95 -53
  61. package/dist/lib/daemon/usage-sync-service.d.ts +21 -0
  62. package/dist/lib/daemon/usage-sync-service.js +42 -0
  63. package/dist/lib/daemon-services.d.ts +1 -1
  64. package/dist/lib/daemon-services.js +5 -0
  65. package/dist/lib/device-config.d.ts +17 -6
  66. package/dist/lib/device-config.js +25 -11
  67. package/dist/lib/devices/connect.d.ts +17 -8
  68. package/dist/lib/devices/connect.js +31 -14
  69. package/dist/lib/devices/pool.d.ts +4 -3
  70. package/dist/lib/devices/pool.js +13 -5
  71. package/dist/lib/doctor-diff.js +77 -7
  72. package/dist/lib/exec.d.ts +6 -41
  73. package/dist/lib/exec.js +6 -41
  74. package/dist/lib/fleet/manifest.d.ts +17 -0
  75. package/dist/lib/fleet/manifest.js +26 -0
  76. package/dist/lib/git.d.ts +13 -1
  77. package/dist/lib/git.js +36 -7
  78. package/dist/lib/harness/adapter.d.ts +7 -7
  79. package/dist/lib/harness/adapters/claude.js +3 -2
  80. package/dist/lib/hooks/install.d.ts +27 -11
  81. package/dist/lib/hooks/install.js +42 -17
  82. package/dist/lib/hosts/reconnect.d.ts +52 -203
  83. package/dist/lib/hosts/reconnect.js +64 -284
  84. package/dist/lib/hosts/remote-cmd.d.ts +9 -0
  85. package/dist/lib/hosts/remote-cmd.js +22 -0
  86. package/dist/lib/installations/migrate.d.ts +6 -120
  87. package/dist/lib/installations/migrate.js +27 -259
  88. package/dist/lib/installations/shims.d.ts +13 -95
  89. package/dist/lib/installations/shims.js +22 -139
  90. package/dist/lib/installations/store.js +1 -1
  91. package/dist/lib/installations/versions.d.ts +26 -133
  92. package/dist/lib/installations/versions.js +41 -204
  93. package/dist/lib/perf/db.d.ts +1 -1
  94. package/dist/lib/perf/db.js +1 -1
  95. package/dist/lib/plugins/skills.d.ts +8 -1
  96. package/dist/lib/plugins/skills.js +18 -2
  97. package/dist/lib/refresh.d.ts +9 -0
  98. package/dist/lib/refresh.js +3 -1
  99. package/dist/lib/routine-readiness.d.ts +15 -1
  100. package/dist/lib/routine-readiness.js +41 -0
  101. package/dist/lib/sandbox.d.ts +4 -1
  102. package/dist/lib/sandbox.js +30 -1
  103. package/dist/lib/secrets/agent.d.ts +80 -225
  104. package/dist/lib/secrets/agent.js +139 -401
  105. package/dist/lib/secrets/bundles.d.ts +73 -222
  106. package/dist/lib/secrets/bundles.js +168 -467
  107. package/dist/lib/secrets/reaper.d.ts +28 -70
  108. package/dist/lib/secrets/reaper.js +30 -85
  109. package/dist/lib/secrets/remote.d.ts +42 -129
  110. package/dist/lib/secrets/remote.js +55 -173
  111. package/dist/lib/self-heal/checks/install-staging.d.ts +4 -0
  112. package/dist/lib/self-heal/checks/install-staging.js +96 -0
  113. package/dist/lib/self-heal/registry.js +2 -0
  114. package/dist/lib/self-heal/types.d.ts +1 -1
  115. package/dist/lib/self-update.d.ts +23 -0
  116. package/dist/lib/self-update.js +50 -0
  117. package/dist/lib/session/active.d.ts +16 -32
  118. package/dist/lib/session/active.js +10 -68
  119. package/dist/lib/session/db.d.ts +24 -36
  120. package/dist/lib/session/db.js +143 -44
  121. package/dist/lib/session/discover.d.ts +6 -58
  122. package/dist/lib/session/discover.js +5 -43
  123. package/dist/lib/session/fork.d.ts +45 -26
  124. package/dist/lib/session/fork.js +32 -95
  125. package/dist/lib/session/parse.d.ts +1 -19
  126. package/dist/lib/session/parse.js +2 -15
  127. package/dist/lib/session/tool-calls.d.ts +43 -1
  128. package/dist/lib/session/tool-calls.js +74 -44
  129. package/dist/lib/session/tool-store.d.ts +33 -2
  130. package/dist/lib/session/tool-store.js +56 -3
  131. package/dist/lib/staleness/writers/sources.d.ts +5 -0
  132. package/dist/lib/staleness/writers/sources.js +2 -1
  133. package/dist/lib/startup/command-registry.d.ts +8 -2
  134. package/dist/lib/startup/command-registry.js +12 -4
  135. package/dist/lib/sync-status.d.ts +22 -0
  136. package/dist/lib/sync-status.js +27 -0
  137. package/dist/lib/sync-umbrella.d.ts +9 -0
  138. package/dist/lib/sync-umbrella.js +21 -2
  139. package/dist/lib/traces/insights.d.ts +47 -14
  140. package/dist/lib/traces/insights.js +92 -21
  141. package/dist/lib/traces/phenotype.d.ts +23 -3
  142. package/dist/lib/traces/phenotype.js +72 -24
  143. package/dist/lib/traces/sync.d.ts +15 -0
  144. package/dist/lib/traces/sync.js +104 -19
  145. package/dist/lib/traces/worker-template.js +154 -1
  146. package/package.json +1 -1
@@ -2,13 +2,7 @@ import type { AgentId } from '../types.js';
2
2
  import { compareVersions } from '../agent-spec/primitives.js';
3
3
  export * from './store.js';
4
4
  import { type PrunableKind } from '../staleness/prune.js';
5
- /**
6
- * Resource selection for syncing to a version.
7
- * Each field can be:
8
- * - 'all' - sync all available resources of this type
9
- * - string[] - sync only these specific resources
10
- * - undefined - skip this resource type
11
- */
5
+ /** Resource selection for syncing to a version: 'all', a name list, or undefined (skip). */
12
6
  export interface ResourceSelection {
13
7
  commands?: string[] | 'all';
14
8
  skills?: string[] | 'all';
@@ -20,14 +14,7 @@ export interface ResourceSelection {
20
14
  plugins?: string[] | 'all';
21
15
  workflows?: string[] | 'all';
22
16
  }
23
- /**
24
- * Available resources in ~/.agents/ for syncing.
25
- *
26
- * `promptcuts` is a boolean, not a list — there is at most one
27
- * ~/.agents/promptcuts.yaml file. It is NOT version-scoped: the
28
- * expand-promptcuts hook reads it directly, so no per-version copy
29
- * is made and no sync step is needed.
30
- */
17
+ /** Resources available in ~/.agents/ for syncing. `promptcuts` is a boolean because it is a single, version-unscoped file. */
31
18
  export interface AvailableResources {
32
19
  commands: string[];
33
20
  skills: string[];
@@ -40,14 +27,9 @@ export interface AvailableResources {
40
27
  workflows: string[];
41
28
  promptcuts: boolean;
42
29
  }
43
- /**
44
- * Get all available resources from ~/.agents/.
45
- */
30
+ /** Discover all resources available for syncing from ~/.agents/. */
46
31
  export declare function getAvailableResources(cwd?: string): AvailableResources;
47
- /**
48
- * Get what's ACTUALLY synced to a version by inspecting the version home.
49
- * This is the source of truth - not the tracking in agents.yaml.
50
- */
32
+ /** Return what's actually synced to a version home (source of truth, not agents.yaml tracking). */
51
33
  export declare function getActuallySyncedResources(agent: AgentId, version: string, options?: {
52
34
  cwd?: string;
53
35
  }): AvailableResources;
@@ -60,103 +42,49 @@ export interface ProjectOnlyResources {
60
42
  plugins: Set<string>;
61
43
  workflows: Set<string>;
62
44
  }
63
- /**
64
- * Names that exist ONLY in the project's `.agents/` layer (no matching entry in
65
- * user/system/extra layers). Sync intentionally skips project-layer commands,
66
- * skills, hooks, subagents, plugins, and workflows for security — see the
67
- * defense comments above each sync branch in syncResourcesToVersion. Without
68
- * this filter, those names would forever appear in the "New resources" diff
69
- * because they live in `available` but never reach `actuallySynced`.
70
- */
45
+ /** Names that exist only in the project's `.agents/` layer. Sync skips project-layer resources for security, so filter them out of the "new resources" diff. */
71
46
  export declare function getProjectOnlyResources(cwd?: string): ProjectOnlyResources;
72
- /**
73
- * Compare available resources with what's ACTUALLY synced to version home.
74
- * Returns only NEW resources that haven't been synced yet.
75
- * Source of truth: the actual files/config, NOT agents.yaml tracking.
76
- *
77
- * `projectOnly` (recommended): the result of `getProjectOnlyResources(cwd)`.
78
- * Names listed there are filtered out for kinds that sync intentionally
79
- * excludes the project layer — otherwise they would re-appear as "new"
80
- * on every run and "Yes, sync all new" would silently do nothing for them.
81
- */
47
+ /** Return resources in `available` that are not yet synced to the version home. `projectOnly` filters project-layer resources that sync skips for security. */
82
48
  export declare function getNewResources(available: AvailableResources, actuallySynced: AvailableResources, projectOnly?: ProjectOnlyResources): AvailableResources;
83
- /**
84
- * Check if there are any new resources to sync.
85
- * When version is provided, uses version-specific capability checks.
86
- */
49
+ /** Return true when `diff` contains any resources the agent/version actually supports. */
87
50
  export declare function hasNewResources(diff: AvailableResources, agent?: AgentId, version?: string): boolean;
88
- /**
89
- * Prompt user to select which NEW resources to sync.
90
- * Only shows resources that haven't been synced yet.
91
- */
51
+ /** Prompt the user to select which new resources to sync. */
92
52
  export declare function promptNewResourceSelection(agent: AgentId, newResources: AvailableResources, version?: string): Promise<ResourceSelection | null>;
93
- /**
94
- * Prompt user to select which resources to sync from ~/.agents/.
95
- * Returns the selection, or null if user cancels.
96
- */
53
+ /** Prompt the user to select which resources to sync from ~/.agents/. */
97
54
  export declare function promptResourceSelection(agent: AgentId): Promise<ResourceSelection | null>;
98
55
  /** Parsed agent@version specification from CLI input. */
99
56
  export interface AgentSpec {
100
57
  agent: AgentId;
101
58
  version: string;
102
59
  }
103
- /**
104
- * Parse agent@version syntax.
105
- * Examples:
106
- * "claude@1.5.0" -> { agent: "claude", version: "1.5.0" }
107
- * "claude" -> { agent: "claude", version: "latest" }
108
- * "codex@latest" -> { agent: "codex", version: "latest" }
109
- */
60
+ /** Parse an `agent@version` spec; bare agent means `latest`. */
110
61
  export declare function parseAgentSpec(spec: string): AgentSpec | null;
111
- /**
112
- * Get the latest available version from npm for an agent.
113
- */
114
62
  export declare function getLatestNpmVersion(agent: AgentId): Promise<string | null>;
115
- /**
116
- * Get the oldest published version from npm for an agent.
117
- */
118
63
  export declare function getOldestNpmVersion(agent: AgentId): Promise<string | null>;
119
- /**
120
- * Check if 'latest' version is already installed (by resolving to actual version).
121
- */
64
+ /** Check whether the npm `latest` version is installed. */
122
65
  export declare function isLatestInstalled(agent: AgentId): Promise<{
123
66
  installed: boolean;
124
67
  version: string | null;
125
68
  }>;
126
- /**
127
- * Check if 'oldest' published version is already installed (by resolving to actual version).
128
- */
69
+ /** Check whether the npm `oldest` version is installed. */
129
70
  export declare function isOldestInstalled(agent: AgentId): Promise<{
130
71
  installed: boolean;
131
72
  version: string | null;
132
73
  }>;
133
74
  /**
134
- * List every version directory for an agent, including ones missing the
135
- * binary (typically home-only leftovers from a prior `removeVersion`).
136
- *
137
- * Used by `agents prune cleanup` to surface stale installs that the regular
138
- * `listInstalledVersions` filters out. Do NOT use elsewhere — every other
139
- * call site assumes a working binary.
75
+ * List every version directory for an agent, including home-only leftovers, for
76
+ * `agents prune cleanup` only. Do NOT use elsewhere — every other call site
77
+ * assumes a working binary.
140
78
  */
141
79
  export declare function listInstalledVersionDirs(agent: AgentId): Array<{
142
80
  version: string;
143
81
  hasBinary: boolean;
144
82
  }>;
145
- /**
146
- * Set the global default version for an agent.
147
- */
83
+ /** Set (or clear) the global default version for an agent. */
148
84
  export declare function setGlobalDefault(agent: AgentId, version: string | undefined): void;
149
- /**
150
- * Set (or clear, with `undefined`) the preferred isolated version.
151
- *
152
- * Deliberately does NOT touch the launcher, the bare shim, the `~/.<agent>` config
153
- * symlink or the global default — the five things `setDefaultVersion` does. This is
154
- * a pointer inside the sandbox, so it stays inside the sandbox.
155
- */
85
+ /** Set (or clear) the preferred isolated version without touching the launcher, shim, or global default. */
156
86
  export declare function setIsolatedDefault(agent: AgentId, version: string | undefined): void;
157
- /**
158
- * Install a specific version of an agent.
159
- */
87
+ /** Install a specific version of an agent. */
160
88
  export declare function installVersion(agent: AgentId, version: string, onProgress?: (message: string) => void, opts?: {
161
89
  clean?: boolean;
162
90
  }): Promise<{
@@ -204,7 +132,7 @@ export declare function reconcileStaleLatestDir(agent: AgentId, installedVersion
204
132
  * re-install) without collision and gives a chronological audit trail.
205
133
  *
206
134
  * The whole versionDir moves — including `home/` (transcripts, sessions). The
207
- * user can recover everything via `agents trash restore <agent>@<version>`.
135
+ * user can recover everything via `agents restore <agent>@<version>`.
208
136
  * Nothing is ever hard-deleted.
209
137
  */
210
138
  export declare function softDeleteVersionDir(agent: AgentId, version: string): string | null;
@@ -212,7 +140,7 @@ export declare function softDeleteVersionDir(agent: AgentId, version: string): s
212
140
  * Remove a specific version of an agent.
213
141
  *
214
142
  * Soft-delete only: moves the entire version directory (including `home/`)
215
- * to ~/.agents/.system/trash/versions/. Recoverable via `agents trash restore`.
143
+ * to ~/.agents/.system/trash/versions/. Recoverable via `agents restore`.
216
144
  * Nothing is hard-deleted.
217
145
  */
218
146
  export declare function removeVersion(agent: AgentId, version: string): boolean;
@@ -270,24 +198,7 @@ export interface HealedVersionPointers {
270
198
  * isolated-only agent are left untouched.
271
199
  */
272
200
  export declare function healDanglingVersionPointers(agent: AgentId, cwd: string): Promise<HealedVersionPointers>;
273
- /**
274
- * Normalize a user-supplied @version token across CLI subcommands.
275
- *
276
- * undefined / "" / "default" / "pinned" -> undefined (caller falls back to project pin or global default)
277
- * "any" -> undefined (caller imposes no version constraint — e.g. resume across any version)
278
- * "latest" -> highest installed version (process.exit if none installed)
279
- * "oldest" -> lowest installed version (process.exit if none installed)
280
- * "x.y.z" (installed) -> "x.y.z"
281
- * "x.y.z" (not installed) -> process.exit with installed-list hint
282
- *
283
- * `pinned` is a synonym for `default`: both name the project pin / global
284
- * default, which the caller resolves.
285
- *
286
- * Use this anywhere the user can type `agents <cmd> claude@<token>` to keep the
287
- * vocabulary consistent. Subcommands with different semantics for `latest`
288
- * (install/remove/use, where `latest` means npm-latest) keep their existing
289
- * parsing.
290
- */
201
+ /** Normalize a user-supplied `@version` token. `default`/`pinned`/`any` → undefined; `latest`/`oldest` → extreme installed version; concrete versions must be installed. */
291
202
  export declare function resolveVersionAlias(agent: AgentId, raw: string | undefined | null): string | undefined;
292
203
  /**
293
204
  * Loose variant of resolveVersionAlias for record-filter contexts (sessions,
@@ -535,44 +446,26 @@ export interface InstalledAgentTargetResult {
535
446
  directAgents: AgentId[];
536
447
  versionSelections: Map<AgentId, string[]>;
537
448
  }
538
- /**
539
- * Thrown when the user references an agent@version that is not installed.
540
- * Carries the parsed (agentId, version) so callers can react — e.g. prompt
541
- * to install it on demand — without having to parse the error message.
542
- */
449
+ /** Thrown when an `agent@version` target is not installed; carries the parsed ids so callers can react without parsing the message. */
543
450
  export declare class VersionNotInstalledError extends Error {
544
451
  readonly agentId: AgentId;
545
452
  readonly version: string;
546
453
  readonly installedVersions: readonly string[];
547
454
  constructor(agentId: AgentId, version: string, installedVersions: readonly string[]);
548
455
  }
549
- /**
550
- * Resolve a comma-separated --agents list into concrete version selections.
551
- * Bare agents target the default version, or the newest installed version when no default exists.
552
- * Explicit agent@version targets only that installed version.
553
- */
456
+ /** Resolve a comma-separated `--agents` list into concrete installed version selections. */
554
457
  export declare function resolveAgentVersionTargets(value: string, availableAgents: readonly AgentId[], options?: {
555
458
  allVersions?: boolean;
556
459
  }): VersionSelectionResult;
557
- /**
558
- * Resolve a comma-separated --agents list into install/apply targets.
559
- * Bare agents target the default version (or newest installed version) when managed,
560
- * and fall back to the agent's effective HOME when unmanaged.
561
- * Explicit agent@version targets only that installed version.
562
- */
460
+ /** Resolve a comma-separated `--agents` list into install/apply targets, distinguishing managed versions from direct homes. */
563
461
  export declare function resolveInstalledAgentTargets(value: string, availableAgents: readonly AgentId[], options?: {
564
462
  allVersions?: boolean;
565
463
  }): InstalledAgentTargetResult;
566
- /**
567
- * Resolve configured manifest targets into direct homes and managed versions.
568
- */
464
+ /** Resolve configured manifest targets into direct homes and managed versions. */
569
465
  export declare function resolveConfiguredAgentTargets(agents: readonly AgentId[] | undefined, agentVersions: Partial<Record<AgentId, string[]>> | undefined, availableAgents: readonly AgentId[], options?: {
570
466
  allVersions?: boolean;
571
467
  }): InstalledAgentTargetResult;
572
- /**
573
- * Prompt user to select agents and versions for resource installation.
574
- * Returns selected agents and their version selections.
575
- */
468
+ /** Prompt the user to select agents and versions for resource installation. */
576
469
  export declare function promptAgentVersionSelection(availableAgents: AgentId[], options?: {
577
470
  skipPrompts?: boolean;
578
471
  }): Promise<VersionSelectionResult>;