@phnx-labs/agents-cli 1.22.75 → 1.22.77

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 (138) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +20 -8
  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/config.js +27 -4
  11. package/dist/commands/cost.js +6 -4
  12. package/dist/commands/doctor.d.ts +6 -5
  13. package/dist/commands/doctor.js +32 -274
  14. package/dist/commands/exec.d.ts +2 -0
  15. package/dist/commands/exec.js +9 -2
  16. package/dist/commands/harness.d.ts +1 -0
  17. package/dist/commands/harness.js +11 -3
  18. package/dist/commands/hooks.js +7 -6
  19. package/dist/commands/mcp.js +7 -6
  20. package/dist/commands/memory.js +7 -7
  21. package/dist/commands/monitors.js +3 -2
  22. package/dist/commands/open.d.ts +25 -12
  23. package/dist/commands/open.js +24 -10
  24. package/dist/commands/permissions.js +7 -6
  25. package/dist/commands/plugins.js +21 -17
  26. package/dist/commands/route.js +33 -16
  27. package/dist/commands/rules.js +7 -12
  28. package/dist/commands/sessions-share.js +1 -1
  29. package/dist/commands/setup-watchdog.js +2 -2
  30. package/dist/commands/setup.js +22 -1
  31. package/dist/commands/share.js +26 -10
  32. package/dist/commands/skills.js +7 -6
  33. package/dist/commands/subagents.js +7 -6
  34. package/dist/commands/sync.js +81 -10
  35. package/dist/commands/view.js +4 -1
  36. package/dist/commands/watchdog.d.ts +1 -1
  37. package/dist/commands/watchdog.js +10 -10
  38. package/dist/commands/webhook.d.ts +4 -0
  39. package/dist/commands/webhook.js +22 -4
  40. package/dist/commands/workflows.js +7 -6
  41. package/dist/lib/accounting/rotate.d.ts +3 -1
  42. package/dist/lib/accounting/rotate.js +8 -4
  43. package/dist/lib/auth-health.d.ts +2 -0
  44. package/dist/lib/auth-health.js +2 -0
  45. package/dist/lib/browser/chrome.d.ts +21 -0
  46. package/dist/lib/browser/chrome.js +60 -3
  47. package/dist/lib/browser/drivers/local.d.ts +21 -0
  48. package/dist/lib/browser/drivers/local.js +102 -9
  49. package/dist/lib/browser/profiles.d.ts +29 -1
  50. package/dist/lib/browser/profiles.js +50 -1
  51. package/dist/lib/browser/registry.js +10 -3
  52. package/dist/lib/browser/types.d.ts +18 -0
  53. package/dist/lib/config-keys.d.ts +7 -2
  54. package/dist/lib/config-keys.js +17 -2
  55. package/dist/lib/daemon/daemon.js +8 -0
  56. package/dist/lib/daemon/session-summarizer-service.d.ts +24 -0
  57. package/dist/lib/daemon/session-summarizer-service.js +39 -0
  58. package/dist/lib/daemon-services.d.ts +1 -1
  59. package/dist/lib/daemon-services.js +5 -0
  60. package/dist/lib/daemon-ticks.d.ts +2 -2
  61. package/dist/lib/daemon-ticks.js +2 -1
  62. package/dist/lib/deeplink/register.js +10 -9
  63. package/dist/lib/deeplink/url.d.ts +4 -4
  64. package/dist/lib/deeplink/url.js +4 -4
  65. package/dist/lib/device-config.js +25 -0
  66. package/dist/lib/devices/doctor-findings.d.ts +4 -4
  67. package/dist/lib/devices/doctor-findings.js +14 -8
  68. package/dist/lib/devices/registry.js +2 -0
  69. package/dist/lib/devices/stats-cache.d.ts +4 -0
  70. package/dist/lib/devices/stats-cache.js +19 -0
  71. package/dist/lib/drift-sync.d.ts +3 -1
  72. package/dist/lib/drift-sync.js +16 -5
  73. package/dist/lib/exec.d.ts +2 -0
  74. package/dist/lib/exec.js +16 -1
  75. package/dist/lib/fleet-shared-state.d.ts +8 -0
  76. package/dist/lib/git.js +6 -0
  77. package/dist/lib/heal.d.ts +4 -3
  78. package/dist/lib/heal.js +5 -4
  79. package/dist/lib/hosts/ready.d.ts +1 -1
  80. package/dist/lib/hosts/ready.js +16 -4
  81. package/dist/lib/hosts/reconnect.js +4 -2
  82. package/dist/lib/identity/client.d.ts +6 -0
  83. package/dist/lib/identity/index.d.ts +16 -0
  84. package/dist/lib/identity/index.js +25 -1
  85. package/dist/lib/installations/migrate.d.ts +10 -0
  86. package/dist/lib/installations/migrate.js +18 -0
  87. package/dist/lib/profiles.d.ts +2 -0
  88. package/dist/lib/profiles.js +28 -9
  89. package/dist/lib/project-resources.d.ts +23 -0
  90. package/dist/lib/project-resources.js +94 -0
  91. package/dist/lib/reconcile-and-repair.d.ts +109 -0
  92. package/dist/lib/reconcile-and-repair.js +267 -0
  93. package/dist/lib/routers.d.ts +12 -1
  94. package/dist/lib/routers.js +30 -1
  95. package/dist/lib/scheduling/routines.js +8 -2
  96. package/dist/lib/session/active.d.ts +13 -0
  97. package/dist/lib/session/db.d.ts +47 -7
  98. package/dist/lib/session/db.js +114 -12
  99. package/dist/lib/session/mirror.js +58 -0
  100. package/dist/lib/session/remote/watch.js +22 -2
  101. package/dist/lib/session/session-cache.d.ts +19 -0
  102. package/dist/lib/session/session-cache.js +46 -0
  103. package/dist/lib/session/types.d.ts +34 -0
  104. package/dist/lib/share/backend.d.ts +6 -4
  105. package/dist/lib/share/backend.js +10 -8
  106. package/dist/lib/share/config.d.ts +4 -3
  107. package/dist/lib/share/config.js +10 -1
  108. package/dist/lib/share/delete.d.ts +1 -1
  109. package/dist/lib/share/delete.js +1 -1
  110. package/dist/lib/share/html.d.ts +1 -1
  111. package/dist/lib/share/html.js +1 -1
  112. package/dist/lib/share/provision.d.ts +1 -1
  113. package/dist/lib/share/provision.js +2 -2
  114. package/dist/lib/share/publish.d.ts +23 -7
  115. package/dist/lib/share/publish.js +58 -12
  116. package/dist/lib/share/worker-template.js +221 -60
  117. package/dist/lib/startup/command-registry.js +2 -2
  118. package/dist/lib/state.d.ts +58 -1
  119. package/dist/lib/state.js +138 -16
  120. package/dist/lib/summarizer/config.d.ts +46 -0
  121. package/dist/lib/summarizer/config.js +83 -0
  122. package/dist/lib/summarizer/pass.d.ts +45 -0
  123. package/dist/lib/summarizer/pass.js +112 -0
  124. package/dist/lib/summarizer/summarize.d.ts +68 -0
  125. package/dist/lib/summarizer/summarize.js +120 -0
  126. package/dist/lib/teams/agents.d.ts +4 -3
  127. package/dist/lib/teams/agents.js +12 -4
  128. package/dist/lib/teams/scheduler.d.ts +4 -2
  129. package/dist/lib/teams/scheduler.js +6 -6
  130. package/dist/lib/tmux/session.d.ts +2 -0
  131. package/dist/lib/tmux/session.js +7 -1
  132. package/dist/lib/types.d.ts +20 -0
  133. package/dist/lib/verbs.d.ts +23 -0
  134. package/dist/lib/verbs.js +24 -0
  135. package/dist/lib/view-types.d.ts +4 -0
  136. package/dist/lib/watchdog/rotate.d.ts +1 -1
  137. package/dist/lib/watchdog/rotate.js +1 -1
  138. package/package.json +1 -1
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The one model call behind the session summarizer (PHNX-3939).
3
+ *
4
+ * A pure boundary: given the session's first user turn (the goal source) and its
5
+ * live progress (todos / plan / phase off the state engine), it asks a local
6
+ * Anthropic-wire endpoint (Ollama / vLLM / LiteLLM — the same configurable base
7
+ * URL `computer/model.ts` speaks) for a strict JSON `{goal, checkpoints, checklist}`
8
+ * and validates the shape. On ANY failure — network, non-2xx, non-JSON, wrong
9
+ * shape — it returns `undefined`, and the caller records `summaryState: 'skipped'`.
10
+ *
11
+ * NEVER called on the request path: only the background SessionSummarizerService
12
+ * invokes it, debounced and reader-gated.
13
+ */
14
+ import type { TodoProgress } from '../session/types.js';
15
+ /** Live progress fed to the model alongside the goal-bearing prompt. */
16
+ export interface SummarizeProgress {
17
+ /** Latest checklist write (TodoWrite / update_plan), when the session has one. */
18
+ todos?: TodoProgress;
19
+ /** Plan markdown from the last ExitPlanMode, when present. */
20
+ plan?: string;
21
+ /** Coarse lifecycle phase (running / waiting / idle / …), when known. */
22
+ phase?: string;
23
+ }
24
+ /** The validated model output. `at` timestamps are stamped by the caller. */
25
+ export interface SummarizeResult {
26
+ goal: string;
27
+ /** Progress checkpoints, newest last (short lines). */
28
+ checkpoints: string[];
29
+ /** Detailed checklist. */
30
+ checklist: {
31
+ text: string;
32
+ done: boolean;
33
+ }[];
34
+ }
35
+ export interface SummarizeOptions {
36
+ baseUrl: string;
37
+ model: string;
38
+ maxTokens?: number;
39
+ /**
40
+ * API key for the endpoint. Deliberately NOT resolved from `ANTHROPIC_API_KEY`:
41
+ * the summarizer targets an operator-configured local/remote endpoint
42
+ * (Ollama/vLLM/LiteLLM) that typically ignores the key, so forwarding the real
43
+ * Anthropic credential there would leak it. Only an explicit
44
+ * `AGENTS_SUMMARIZER_API_KEY` (or this option) is ever sent; otherwise the
45
+ * header is empty.
46
+ */
47
+ apiKey?: string;
48
+ /** Injectable for tests; defaults to the global fetch. */
49
+ fetchImpl?: typeof fetch;
50
+ /** Abort the request when the daemon tick's deadline elapses. */
51
+ signal?: AbortSignal;
52
+ }
53
+ /** Compose the user message from the goal-bearing prompt and the live progress. */
54
+ export declare function buildSummarizeUserMessage(prompt: string, progress: SummarizeProgress): string;
55
+ /**
56
+ * Coerce an untrusted parsed object into a {@link SummarizeResult}, or undefined
57
+ * when the shape is wrong. Extra/missing optional arrays degrade to `[]` rather
58
+ * than failing, but a non-string goal is a hard reject — a summary with no goal
59
+ * is not a summary.
60
+ */
61
+ export declare function validateSummarizeResult(parsed: unknown): SummarizeResult | undefined;
62
+ /** Strip ``` fences and pull the first {...} block so a chatty model still parses. */
63
+ export declare function extractJsonObject(text: string): string | undefined;
64
+ /**
65
+ * Run one summarization. Returns the validated result, or `undefined` on any
66
+ * failure (the caller then marks the session `summaryState: 'skipped'`).
67
+ */
68
+ export declare function summarize(prompt: string, progress: SummarizeProgress, opts: SummarizeOptions): Promise<SummarizeResult | undefined>;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * The one model call behind the session summarizer (PHNX-3939).
3
+ *
4
+ * A pure boundary: given the session's first user turn (the goal source) and its
5
+ * live progress (todos / plan / phase off the state engine), it asks a local
6
+ * Anthropic-wire endpoint (Ollama / vLLM / LiteLLM — the same configurable base
7
+ * URL `computer/model.ts` speaks) for a strict JSON `{goal, checkpoints, checklist}`
8
+ * and validates the shape. On ANY failure — network, non-2xx, non-JSON, wrong
9
+ * shape — it returns `undefined`, and the caller records `summaryState: 'skipped'`.
10
+ *
11
+ * NEVER called on the request path: only the background SessionSummarizerService
12
+ * invokes it, debounced and reader-gated.
13
+ */
14
+ import { ANTHROPIC_VERSION } from '../computer/model.js';
15
+ const SYSTEM_PROMPT = [
16
+ 'You summarize a coding-agent session for an operator dashboard.',
17
+ 'Reply with ONLY a single JSON object, no prose and no code fences, of exactly this shape:',
18
+ '{"goal": string, "checkpoints": string[], "checklist": [{"text": string, "done": boolean}]}',
19
+ '- goal: 1-2 lines capturing what the user actually asked for, in plain language.',
20
+ '- checkpoints: short lines of concrete progress so far, newest last; [] if none yet.',
21
+ '- checklist: the detailed steps to finish the goal, each with a done flag; [] if unknown.',
22
+ 'Do not invent progress that is not evidenced by the provided context.',
23
+ ].join('\n');
24
+ /** Compose the user message from the goal-bearing prompt and the live progress. */
25
+ export function buildSummarizeUserMessage(prompt, progress) {
26
+ const parts = [`USER REQUEST:\n${prompt.trim()}`];
27
+ if (progress.phase)
28
+ parts.push(`PHASE: ${progress.phase}`);
29
+ if (progress.todos && progress.todos.items.length > 0) {
30
+ const lines = progress.todos.items.map((t) => `- [${t.status === 'completed' ? 'x' : ' '}] ${t.content}`);
31
+ parts.push(`CURRENT CHECKLIST (${progress.todos.done}/${progress.todos.total} done):\n${lines.join('\n')}`);
32
+ }
33
+ if (progress.plan)
34
+ parts.push(`PLAN:\n${progress.plan.trim().slice(0, 4000)}`);
35
+ return parts.join('\n\n');
36
+ }
37
+ /**
38
+ * Coerce an untrusted parsed object into a {@link SummarizeResult}, or undefined
39
+ * when the shape is wrong. Extra/missing optional arrays degrade to `[]` rather
40
+ * than failing, but a non-string goal is a hard reject — a summary with no goal
41
+ * is not a summary.
42
+ */
43
+ export function validateSummarizeResult(parsed) {
44
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
45
+ return undefined;
46
+ const obj = parsed;
47
+ if (typeof obj.goal !== 'string' || obj.goal.trim().length === 0)
48
+ return undefined;
49
+ const checkpoints = Array.isArray(obj.checkpoints)
50
+ ? obj.checkpoints.filter((c) => typeof c === 'string' && c.trim().length > 0).map((c) => c.trim())
51
+ : [];
52
+ const checklist = Array.isArray(obj.checklist)
53
+ ? obj.checklist
54
+ .filter((c) => Boolean(c) && typeof c === 'object' && !Array.isArray(c))
55
+ .map((c) => ({ text: typeof c.text === 'string' ? c.text.trim() : '', done: Boolean(c.done) }))
56
+ .filter((c) => c.text.length > 0)
57
+ : [];
58
+ return { goal: obj.goal.trim(), checkpoints, checklist };
59
+ }
60
+ /** Extract the assistant text from an Anthropic Messages response body. */
61
+ function textFromBody(body) {
62
+ const content = body.content;
63
+ if (!Array.isArray(content))
64
+ return '';
65
+ return content
66
+ .filter((b) => Boolean(b) && typeof b === 'object')
67
+ .filter((b) => b.type === 'text' && typeof b.text === 'string')
68
+ .map((b) => b.text)
69
+ .join('');
70
+ }
71
+ /** Strip ``` fences and pull the first {...} block so a chatty model still parses. */
72
+ export function extractJsonObject(text) {
73
+ const unfenced = text.replace(/```(?:json)?/gi, '').trim();
74
+ const start = unfenced.indexOf('{');
75
+ const end = unfenced.lastIndexOf('}');
76
+ if (start === -1 || end === -1 || end < start)
77
+ return undefined;
78
+ return unfenced.slice(start, end + 1);
79
+ }
80
+ /**
81
+ * Run one summarization. Returns the validated result, or `undefined` on any
82
+ * failure (the caller then marks the session `summaryState: 'skipped'`).
83
+ */
84
+ export async function summarize(prompt, progress, opts) {
85
+ if (!prompt.trim())
86
+ return undefined;
87
+ const baseUrl = opts.baseUrl.replace(/\/+$/, '');
88
+ const doFetch = opts.fetchImpl ?? fetch;
89
+ // Only an explicit summarizer key is ever forwarded — never the ambient
90
+ // ANTHROPIC_API_KEY, which would leak to the operator's local endpoint.
91
+ const apiKey = opts.apiKey ?? process.env.AGENTS_SUMMARIZER_API_KEY ?? '';
92
+ try {
93
+ const res = await doFetch(`${baseUrl}/v1/messages`, {
94
+ method: 'POST',
95
+ headers: {
96
+ 'content-type': 'application/json',
97
+ 'x-api-key': apiKey,
98
+ 'anthropic-version': ANTHROPIC_VERSION,
99
+ },
100
+ body: JSON.stringify({
101
+ model: opts.model,
102
+ max_tokens: opts.maxTokens ?? 512,
103
+ system: SYSTEM_PROMPT,
104
+ messages: [{ role: 'user', content: buildSummarizeUserMessage(prompt, progress) }],
105
+ }),
106
+ ...(opts.signal ? { signal: opts.signal } : {}),
107
+ });
108
+ if (!res.ok)
109
+ return undefined;
110
+ const body = await res.json();
111
+ const text = textFromBody(body);
112
+ const json = extractJsonObject(text);
113
+ if (!json)
114
+ return undefined;
115
+ return validateSummarizeResult(JSON.parse(json));
116
+ }
117
+ catch {
118
+ return undefined;
119
+ }
120
+ }
@@ -569,9 +569,10 @@ export declare class AgentManager {
569
569
  private resolveScheduledPlacement;
570
570
  /**
571
571
  * Place an UNPINNED, non-cloud teammate onto the team pool via the cascade
572
- * (least-loaded), if the team declares one. A no-op for a pinned teammate
573
- * (hostName already set from `--device`), a cloud teammate, or a poolless team —
574
- * leaving hostName null so the local spawn runs unchanged. Shared by spawn()
572
+ * (least-loaded). A poolless team consumes the active worker allowlist and
573
+ * fails loud when none exists; it never silently lands on the orchestrator.
574
+ * A no-op only for a pinned teammate (hostName already set from `--device`) or
575
+ * a cloud teammate. Shared by spawn()
575
576
  * (immediate add-launch) and startReady() (staged launch) so an unpinned pool
576
577
  * teammate schedules identically no matter how it was fired.
577
578
  */
@@ -38,6 +38,7 @@ import { atomicWriteJsonSync } from '../fs-atomic.js';
38
38
  import { resolvePlacement, classifyExclusions, isTransientPlacementBlock, NoViableDeviceError, } from './scheduler.js';
39
39
  import { probePoolSignals } from './placement-probe.js';
40
40
  import { readMaxConcurrentCaps } from '../device-config.js';
41
+ import { filterAutoPool, listWorkerDevices } from '../devices/pool.js';
41
42
  import { redactSecrets, sanitizeForTerminal } from '../redact.js';
42
43
  import chalk from 'chalk';
43
44
  let lastMemoryWarnAt = 0;
@@ -2328,9 +2329,10 @@ export class AgentManager {
2328
2329
  }
2329
2330
  /**
2330
2331
  * Place an UNPINNED, non-cloud teammate onto the team pool via the cascade
2331
- * (least-loaded), if the team declares one. A no-op for a pinned teammate
2332
- * (hostName already set from `--device`), a cloud teammate, or a poolless team —
2333
- * leaving hostName null so the local spawn runs unchanged. Shared by spawn()
2332
+ * (least-loaded). A poolless team consumes the active worker allowlist and
2333
+ * fails loud when none exists; it never silently lands on the orchestrator.
2334
+ * A no-op only for a pinned teammate (hostName already set from `--device`) or
2335
+ * a cloud teammate. Shared by spawn()
2334
2336
  * (immediate add-launch) and startReady() (staged launch) so an unpinned pool
2335
2337
  * teammate schedules identically no matter how it was fired.
2336
2338
  */
@@ -2341,7 +2343,12 @@ export class AgentManager {
2341
2343
  if (!teamMeta)
2342
2344
  return;
2343
2345
  const roster = await this.listByTask(taskName);
2344
- const pool = teamMeta.devices ?? [];
2346
+ // A poolless team is still an automatic placement request: use the same
2347
+ // explicit worker allowlist as `--device auto`. Never silently run it on a
2348
+ // personal/desktop orchestrator merely because `devices` was omitted.
2349
+ const pool = teamMeta.devices?.length
2350
+ ? teamMeta.devices
2351
+ : filterAutoPool(listWorkerDevices());
2345
2352
  const maxConcurrent = pool.length > 1 ? readMaxConcurrentCaps(pool) : undefined;
2346
2353
  // On the start path (opts.probe), gather live signals so the pick is health-,
2347
2354
  // harness-, and load-aware (RUSH-2002); the add path stays the cap-only
@@ -2353,6 +2360,7 @@ export class AgentManager {
2353
2360
  const placeOpts = {
2354
2361
  maxConcurrent,
2355
2362
  signals,
2363
+ defaultDevices: pool,
2356
2364
  agentLabel: this.placementAgentLabel(agent),
2357
2365
  };
2358
2366
  if (signals) {
@@ -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.75",
3
+ "version": "1.22.77",
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",