@phnx-labs/agents-cli 1.22.74 → 1.22.76

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 (148) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +21 -9
  3. package/dist/bootstrap.js +7 -7
  4. package/dist/cli/command-registry.js +5 -0
  5. package/dist/commands/artifacts-setup.js +1 -1
  6. package/dist/commands/artifacts.js +1 -1
  7. package/dist/commands/auth.js +7 -1
  8. package/dist/commands/browser.js +104 -10
  9. package/dist/commands/commands.js +7 -6
  10. package/dist/commands/computer.d.ts +1 -0
  11. package/dist/commands/computer.js +26 -7
  12. package/dist/commands/config.js +27 -4
  13. package/dist/commands/cost.js +6 -4
  14. package/dist/commands/doctor.d.ts +6 -5
  15. package/dist/commands/doctor.js +32 -274
  16. package/dist/commands/exec.d.ts +2 -0
  17. package/dist/commands/exec.js +9 -2
  18. package/dist/commands/harness.d.ts +1 -0
  19. package/dist/commands/harness.js +11 -3
  20. package/dist/commands/hooks.js +7 -6
  21. package/dist/commands/mcp.js +7 -6
  22. package/dist/commands/memory.js +7 -7
  23. package/dist/commands/monitors.js +3 -2
  24. package/dist/commands/open.d.ts +25 -12
  25. package/dist/commands/open.js +24 -10
  26. package/dist/commands/permissions.js +7 -6
  27. package/dist/commands/plugins.js +21 -17
  28. package/dist/commands/route.js +33 -16
  29. package/dist/commands/rules.js +7 -12
  30. package/dist/commands/sessions-share.js +1 -1
  31. package/dist/commands/setup-watchdog.js +2 -2
  32. package/dist/commands/setup.js +22 -1
  33. package/dist/commands/share.js +26 -10
  34. package/dist/commands/skills.js +7 -6
  35. package/dist/commands/subagents.js +7 -6
  36. package/dist/commands/sync.js +81 -10
  37. package/dist/commands/view.js +4 -1
  38. package/dist/commands/watchdog.d.ts +1 -1
  39. package/dist/commands/watchdog.js +10 -10
  40. package/dist/commands/webhook.d.ts +4 -0
  41. package/dist/commands/webhook.js +22 -4
  42. package/dist/commands/workflows.js +7 -6
  43. package/dist/lib/account-registry.js +27 -6
  44. package/dist/lib/accounting/rotate.d.ts +3 -1
  45. package/dist/lib/accounting/rotate.js +8 -4
  46. package/dist/lib/auth-health.d.ts +2 -0
  47. package/dist/lib/auth-health.js +2 -0
  48. package/dist/lib/browser/chrome.d.ts +21 -0
  49. package/dist/lib/browser/chrome.js +60 -3
  50. package/dist/lib/browser/drivers/local.d.ts +21 -0
  51. package/dist/lib/browser/drivers/local.js +102 -9
  52. package/dist/lib/browser/profiles.d.ts +29 -1
  53. package/dist/lib/browser/profiles.js +50 -1
  54. package/dist/lib/browser/types.d.ts +18 -0
  55. package/dist/lib/computer/computer-rpc.d.ts +6 -1
  56. package/dist/lib/computer/computer-rpc.js +23 -3
  57. package/dist/lib/computer/des.d.ts +1 -0
  58. package/dist/lib/computer/des.js +114 -0
  59. package/dist/lib/computer/rfb-client.d.ts +53 -0
  60. package/dist/lib/computer/rfb-client.js +562 -0
  61. package/dist/lib/config-keys.d.ts +7 -2
  62. package/dist/lib/config-keys.js +17 -2
  63. package/dist/lib/daemon/auth-sync-service.js +3 -0
  64. package/dist/lib/daemon/daemon.js +17 -10
  65. package/dist/lib/daemon/session-summarizer-service.d.ts +24 -0
  66. package/dist/lib/daemon/session-summarizer-service.js +39 -0
  67. package/dist/lib/daemon/usage-sync-service.js +3 -0
  68. package/dist/lib/daemon-services.d.ts +1 -1
  69. package/dist/lib/daemon-services.js +5 -0
  70. package/dist/lib/daemon-ticks.d.ts +2 -2
  71. package/dist/lib/daemon-ticks.js +2 -1
  72. package/dist/lib/daemon-webhooks.js +15 -2
  73. package/dist/lib/deeplink/register.js +10 -9
  74. package/dist/lib/deeplink/url.d.ts +4 -4
  75. package/dist/lib/deeplink/url.js +4 -4
  76. package/dist/lib/device-config.js +25 -0
  77. package/dist/lib/devices/doctor-findings.d.ts +4 -4
  78. package/dist/lib/devices/doctor-findings.js +14 -8
  79. package/dist/lib/devices/registry.js +2 -0
  80. package/dist/lib/devices/stats-cache.d.ts +4 -0
  81. package/dist/lib/devices/stats-cache.js +19 -0
  82. package/dist/lib/drift-sync.d.ts +3 -1
  83. package/dist/lib/drift-sync.js +16 -5
  84. package/dist/lib/exec.d.ts +2 -0
  85. package/dist/lib/exec.js +16 -1
  86. package/dist/lib/fleet-shared-repo-sync.d.ts +12 -0
  87. package/dist/lib/fleet-shared-repo-sync.js +101 -4
  88. package/dist/lib/fleet-shared-state.d.ts +8 -0
  89. package/dist/lib/heal.d.ts +4 -3
  90. package/dist/lib/heal.js +5 -4
  91. package/dist/lib/hosts/ready.d.ts +1 -1
  92. package/dist/lib/hosts/ready.js +16 -4
  93. package/dist/lib/hosts/reconnect.js +4 -2
  94. package/dist/lib/identity/client.d.ts +6 -0
  95. package/dist/lib/identity/index.d.ts +16 -0
  96. package/dist/lib/identity/index.js +25 -1
  97. package/dist/lib/profiles.d.ts +2 -0
  98. package/dist/lib/profiles.js +28 -9
  99. package/dist/lib/reconcile-and-repair.d.ts +109 -0
  100. package/dist/lib/reconcile-and-repair.js +267 -0
  101. package/dist/lib/routers.d.ts +12 -1
  102. package/dist/lib/routers.js +30 -1
  103. package/dist/lib/scheduling/routines.js +8 -2
  104. package/dist/lib/session/active.d.ts +13 -0
  105. package/dist/lib/session/db.d.ts +47 -7
  106. package/dist/lib/session/db.js +114 -12
  107. package/dist/lib/session/mirror.js +58 -0
  108. package/dist/lib/session/remote/remote-list.d.ts +2 -0
  109. package/dist/lib/session/remote/remote-list.js +4 -0
  110. package/dist/lib/session/remote/watch.js +22 -2
  111. package/dist/lib/session/session-cache.d.ts +19 -0
  112. package/dist/lib/session/session-cache.js +46 -0
  113. package/dist/lib/session/types.d.ts +34 -0
  114. package/dist/lib/share/backend.d.ts +6 -4
  115. package/dist/lib/share/backend.js +10 -8
  116. package/dist/lib/share/config.d.ts +4 -3
  117. package/dist/lib/share/config.js +10 -1
  118. package/dist/lib/share/delete.d.ts +1 -1
  119. package/dist/lib/share/delete.js +1 -1
  120. package/dist/lib/share/html.d.ts +1 -1
  121. package/dist/lib/share/html.js +1 -1
  122. package/dist/lib/share/provision.d.ts +1 -1
  123. package/dist/lib/share/provision.js +2 -2
  124. package/dist/lib/share/publish.d.ts +23 -7
  125. package/dist/lib/share/publish.js +58 -12
  126. package/dist/lib/share/worker-template.js +221 -60
  127. package/dist/lib/startup/command-registry.js +2 -2
  128. package/dist/lib/state.d.ts +15 -0
  129. package/dist/lib/state.js +29 -7
  130. package/dist/lib/summarizer/config.d.ts +46 -0
  131. package/dist/lib/summarizer/config.js +83 -0
  132. package/dist/lib/summarizer/pass.d.ts +45 -0
  133. package/dist/lib/summarizer/pass.js +112 -0
  134. package/dist/lib/summarizer/summarize.d.ts +68 -0
  135. package/dist/lib/summarizer/summarize.js +120 -0
  136. package/dist/lib/teams/agents.d.ts +4 -3
  137. package/dist/lib/teams/agents.js +12 -4
  138. package/dist/lib/teams/scheduler.d.ts +4 -2
  139. package/dist/lib/teams/scheduler.js +6 -6
  140. package/dist/lib/tmux/session.d.ts +2 -0
  141. package/dist/lib/tmux/session.js +7 -1
  142. package/dist/lib/types.d.ts +20 -0
  143. package/dist/lib/verbs.d.ts +23 -0
  144. package/dist/lib/verbs.js +24 -0
  145. package/dist/lib/view-types.d.ts +4 -0
  146. package/dist/lib/watchdog/rotate.d.ts +1 -1
  147. package/dist/lib/watchdog/rotate.js +1 -1
  148. package/package.json +1 -1
@@ -45,6 +45,8 @@ export interface PlacementTeam {
45
45
  * is never second-guessed.
46
46
  */
47
47
  export interface PlacementOptions {
48
+ /** Worker pool used when the team does not declare an explicit device pool. */
49
+ defaultDevices?: string[];
48
50
  maxConcurrent?: Record<string, number>;
49
51
  /**
50
52
  * Live per-device signals (RUSH-2002). When present, the many-device pick
@@ -144,8 +146,8 @@ export declare function classifyExclusions(devices: string[], roster: RosterEntr
144
146
  */
145
147
  export declare function pickBestDevice(devices: string[], roster: RosterEntry[], opts?: PlacementOptions): string;
146
148
  /**
147
- * Resolve where a teammate runs. Returns `{ device: null }` for a local run
148
- * (no pin, no pool, or the chosen device is the local machine) and
149
+ * Resolve where a teammate runs. Returns `{ device: null }` only when the
150
+ * explicitly/default-selected device is the local machine, and
149
151
  * `{ device: <name> }` for a remote placement. See the cascade in the module
150
152
  * header. Throws {@link NoViableDeviceError} when a required pool has no viable
151
153
  * host — the caller surfaces it at `teams start` rather than falling back local.
@@ -9,7 +9,7 @@
9
9
  * 1. teammate has an explicit `--device` pin → that device
10
10
  * 2. else the team pool has exactly one device → that device (whole team)
11
11
  * 3. else the team pool has many devices → best-viable pick
12
- * 4. else (no pin, no pool) → null == run local
12
+ * 4. else (no pin, no pool) → active worker pool
13
13
  *
14
14
  * Step 3 is cap-, health-, and harness-aware (RUSH-2002). When the caller
15
15
  * supplies live {@link DevicePlacementSignal}s (probed reachability, headroom,
@@ -294,8 +294,8 @@ export function pickBestDevice(devices, roster, opts) {
294
294
  })[0];
295
295
  }
296
296
  /**
297
- * Resolve where a teammate runs. Returns `{ device: null }` for a local run
298
- * (no pin, no pool, or the chosen device is the local machine) and
297
+ * Resolve where a teammate runs. Returns `{ device: null }` only when the
298
+ * explicitly/default-selected device is the local machine, and
299
299
  * `{ device: <name> }` for a remote placement. See the cascade in the module
300
300
  * header. Throws {@link NoViableDeviceError} when a required pool has no viable
301
301
  * host — the caller surfaces it at `teams start` rather than falling back local.
@@ -306,10 +306,10 @@ export function resolvePlacement(team, explicitDevice, roster, opts) {
306
306
  if (explicitDevice) {
307
307
  return { device: isLocalDevice(explicitDevice) ? null : explicitDevice };
308
308
  }
309
- const pool = team.devices ?? [];
310
- // 4. No pool → local, exactly like today.
309
+ const pool = team.devices?.length ? team.devices : (opts?.defaultDevices ?? []);
310
+ // An omitted pool means automatic worker placement, never implicit local.
311
311
  if (pool.length === 0)
312
- return { device: null };
312
+ throw new NoViableDeviceError([], opts?.agentLabel);
313
313
  // 2. Pool of one → the whole team runs there. Respect the choice for
314
314
  // load/cap/reachability, but still fail loud when the agent is provably
315
315
  // NOT installed there — running it would be futile.
@@ -25,6 +25,8 @@ export declare const AGENTS_TMUX_HISTORY_LIMIT = 20000;
25
25
  * these defaults, silently. Same shape as AGENT_HOOK_SCHEMA below.
26
26
  */
27
27
  export declare const AGENTS_TMUX_CONFIG_SCHEMA = 1;
28
+ /** Source one user config without tmux's quiet flag, preserving path bytes. */
29
+ export declare function userConfigSourceLine(value: string): string;
28
30
  /** Provenance written alongside each live tmux session. */
29
31
  export interface SessionMeta {
30
32
  name: string;
@@ -55,6 +55,10 @@ let startupConfigSequence = 0;
55
55
  function tmuxConfigArgument(value) {
56
56
  return `"${value.replace(/([\\"$])/g, '\\$1')}"`;
57
57
  }
58
+ /** Source one user config without tmux's quiet flag, preserving path bytes. */
59
+ export function userConfigSourceLine(value) {
60
+ return `source-file ${tmuxConfigArgument(value)}`;
61
+ }
58
62
  /**
59
63
  * tmux loads `-f` instead of its normal user config, so put agents-cli's
60
64
  * defaults first and explicitly source the first user config tmux would have
@@ -90,7 +94,9 @@ function writeStartupConfig(env) {
90
94
  'bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-no-clear',
91
95
  ];
92
96
  for (const userConfig of userConfigs) {
93
- lines.push(`source-file -q ${tmuxConfigArgument(userConfig)}`);
97
+ // Do not suppress parse/read failures: a broken user config must fail the
98
+ // launch visibly instead of producing a silently half-configured server.
99
+ lines.push(userConfigSourceLine(userConfig));
94
100
  }
95
101
  fs.writeFileSync(startupConfig, `${lines.join('\n')}\n`, { mode: 0o600 });
96
102
  return startupConfig;
@@ -1204,6 +1204,26 @@ export interface BrowserProfileConfig {
1204
1204
  }>;
1205
1205
  /** Preset name to use when `--endpoint` is not passed to `start`. */
1206
1206
  defaultEndpoint?: string;
1207
+ /**
1208
+ * How `agents browser` obtains a live browser for this profile (PHNX-3967):
1209
+ * - `launch` (default when absent): agents-cli spawns the browser itself
1210
+ * under a managed `--user-data-dir` when nothing is serving CDP on the port.
1211
+ * - `attach-only`: agents-cli NEVER spawns a rival window. It attaches to a
1212
+ * browser the user (or a one-time command) already started with remote
1213
+ * debugging, and fails loud with a relaunch hint when none is there. This
1214
+ * is how "enforce one window" is expressed — Arc is inherently attach-only,
1215
+ * and a canonical signed-in Comet uses it so agents can't spawn a second,
1216
+ * logged-out instance. Pairs with a durable {@link userDataDir}.
1217
+ */
1218
+ launchPolicy?: 'attach-only' | 'launch';
1219
+ /**
1220
+ * Absolute durable `--user-data-dir` for this profile's browser (PHNX-3967).
1221
+ * When absent, an attach-only profile resolves a default durable dir outside
1222
+ * `~/.agents/.cache` (`getBrowserDurableDir()`), so a one-time sign-in survives
1223
+ * quit+relaunch and `profiles remove`'s cache sweep. Also the value the
1224
+ * ownership guard compares a running instance against to reject a port-squatter.
1225
+ */
1226
+ userDataDir?: string;
1207
1227
  chrome?: {
1208
1228
  headless?: boolean;
1209
1229
  args?: string[];
@@ -0,0 +1,23 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * The ONE place that defines the CLI's standard short-form verb aliases.
4
+ *
5
+ * These are the canonical short forms an agent or user reaches for on a
6
+ * command group's CRUD verbs — `ls` for `list`, `rm` for `remove`, and so on.
7
+ * They are NOT cross-verb synonyms (`info`/`install`/`create`); those are
8
+ * per-command back-compat aliases owned by the individual commands.
9
+ *
10
+ * Apply them with {@link withAliases} so every group stays in lockstep instead
11
+ * of each command hand-rolling its own `.alias('rm')`.
12
+ */
13
+ export declare const CANONICAL_ALIASES: {
14
+ readonly list: readonly ["ls"];
15
+ readonly view: readonly ["show"];
16
+ readonly add: readonly [];
17
+ readonly remove: readonly ["rm"];
18
+ readonly rename: readonly ["mv"];
19
+ readonly edit: readonly [];
20
+ };
21
+ export type CanonicalVerb = keyof typeof CANONICAL_ALIASES;
22
+ /** Apply the standard aliases for `verb` to an already-created subcommand, returning it. */
23
+ export declare function withAliases(cmd: Command, verb: CanonicalVerb): Command;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The ONE place that defines the CLI's standard short-form verb aliases.
3
+ *
4
+ * These are the canonical short forms an agent or user reaches for on a
5
+ * command group's CRUD verbs — `ls` for `list`, `rm` for `remove`, and so on.
6
+ * They are NOT cross-verb synonyms (`info`/`install`/`create`); those are
7
+ * per-command back-compat aliases owned by the individual commands.
8
+ *
9
+ * Apply them with {@link withAliases} so every group stays in lockstep instead
10
+ * of each command hand-rolling its own `.alias('rm')`.
11
+ */
12
+ export const CANONICAL_ALIASES = {
13
+ list: ['ls'],
14
+ view: ['show'],
15
+ add: [],
16
+ remove: ['rm'],
17
+ rename: ['mv'],
18
+ edit: [],
19
+ };
20
+ /** Apply the standard aliases for `verb` to an already-created subcommand, returning it. */
21
+ export function withAliases(cmd, verb) {
22
+ const aliases = CANONICAL_ALIASES[verb];
23
+ return aliases.length ? cmd.aliases([...aliases]) : cmd;
24
+ }
@@ -23,12 +23,16 @@ export interface ViewJsonVersion {
23
23
  launchable: boolean;
24
24
  /** Live cached authentication verdict for this installed version. */
25
25
  authVerdict: AuthVerdict | null;
26
+ /** Epoch milliseconds when authVerdict was last checked, or null if absent. */
27
+ authCheckedAt: number | null;
26
28
  email: string | null;
27
29
  accountId?: string | null;
28
30
  organizationType?: string | null;
29
31
  organizationName?: string | null;
30
32
  plan: string | null;
31
33
  usageStatus: 'available' | 'rate_limited' | 'out_of_credits' | null;
34
+ /** ISO timestamp of the usage snapshot behind usageStatus, or null if absent. */
35
+ usageCapturedAt: string | null;
32
36
  overageCredits?: {
33
37
  amount: number;
34
38
  currency: string;
@@ -166,7 +166,7 @@ export declare function isWatchdogRotateEnabled(): boolean;
166
166
  * Persist `watchdog.rotate: on|off`. Called by the `agents watchdog rotate
167
167
  * on|off` subcommand (commands/watchdog.ts) — the rotate-only switch the
168
168
  * Factory migration uses so a user who opted out of autoRotate keeps nudging
169
- * (rather than `agents watchdog off`, which disables the whole watchdog here).
169
+ * (rather than `agents watchdog disable`, which disables the whole watchdog here).
170
170
  */
171
171
  export declare function setWatchdogRotateEnabled(on: boolean): void;
172
172
  export interface RotateGateResult {
@@ -291,7 +291,7 @@ export function isWatchdogRotateEnabled() {
291
291
  * Persist `watchdog.rotate: on|off`. Called by the `agents watchdog rotate
292
292
  * on|off` subcommand (commands/watchdog.ts) — the rotate-only switch the
293
293
  * Factory migration uses so a user who opted out of autoRotate keeps nudging
294
- * (rather than `agents watchdog off`, which disables the whole watchdog here).
294
+ * (rather than `agents watchdog disable`, which disables the whole watchdog here).
295
295
  */
296
296
  export function setWatchdogRotateEnabled(on) {
297
297
  const meta = readMeta();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.22.74",
3
+ "version": "1.22.76",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",