@phnx-labs/agents-cli 1.22.105 → 1.22.107

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 (60) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +28 -6
  3. package/dist/browser.js +0 -0
  4. package/dist/commands/exec.d.ts +78 -8
  5. package/dist/commands/exec.js +407 -284
  6. package/dist/commands/resume.d.ts +6 -21
  7. package/dist/commands/resume.js +18 -55
  8. package/dist/commands/run-account-picker.d.ts +11 -0
  9. package/dist/commands/run-account-picker.js +11 -1
  10. package/dist/commands/sessions-resume.d.ts +4 -0
  11. package/dist/commands/sessions-resume.js +132 -49
  12. package/dist/commands/sessions.js +32 -5
  13. package/dist/index.js +0 -0
  14. package/dist/lib/accounting/account-launch.d.ts +54 -0
  15. package/dist/lib/accounting/account-launch.js +117 -0
  16. package/dist/lib/accounting/account-pool-collect.js +2 -1
  17. package/dist/lib/accounting/account-pool.d.ts +2 -0
  18. package/dist/lib/accounting/account-pool.js +1 -0
  19. package/dist/lib/accounting/rotate.d.ts +32 -6
  20. package/dist/lib/accounting/rotate.js +70 -42
  21. package/dist/lib/accounting/usage.d.ts +71 -0
  22. package/dist/lib/accounting/usage.js +160 -11
  23. package/dist/lib/exec-account-home.d.ts +3 -1
  24. package/dist/lib/exec-account-home.js +2 -2
  25. package/dist/lib/exec.d.ts +27 -1
  26. package/dist/lib/exec.js +150 -27
  27. package/dist/lib/hosts/dispatch.d.ts +1 -1
  28. package/dist/lib/hosts/dispatch.js +1 -1
  29. package/dist/lib/models.d.ts +1 -1
  30. package/dist/lib/models.js +4 -4
  31. package/dist/lib/session/actor-sidecar.d.ts +3 -11
  32. package/dist/lib/session/actor-sidecar.js +3 -0
  33. package/dist/lib/session/claude-accounts.d.ts +12 -73
  34. package/dist/lib/session/claude-accounts.js +32 -70
  35. package/dist/lib/session/db.d.ts +1 -1
  36. package/dist/lib/session/db.js +18 -5
  37. package/dist/lib/session/discover.d.ts +4 -0
  38. package/dist/lib/session/discover.js +116 -15
  39. package/dist/lib/session/recovery.d.ts +30 -34
  40. package/dist/lib/session/recovery.js +212 -76
  41. package/dist/lib/session/types.d.ts +2 -0
  42. package/dist/lib/teams/placement-probe.js +1 -1
  43. package/dist/session-tracker/dist/adapters/claude.d.ts +10 -0
  44. package/dist/session-tracker/dist/adapters/claude.js +45 -0
  45. package/dist/session-tracker/dist/hook.sh +191 -0
  46. package/dist/session-tracker/dist/index.d.ts +19 -0
  47. package/dist/session-tracker/dist/index.js +67 -0
  48. package/dist/session-tracker/dist/install-hook.d.ts +19 -0
  49. package/dist/session-tracker/dist/install-hook.js +245 -0
  50. package/dist/session-tracker/dist/prune-state.d.ts +2 -0
  51. package/dist/session-tracker/dist/prune-state.js +7 -0
  52. package/dist/session-tracker/dist/reader.d.ts +7 -0
  53. package/dist/session-tracker/dist/reader.js +151 -0
  54. package/dist/session-tracker/dist/state-file.d.ts +10 -0
  55. package/dist/session-tracker/dist/state-file.js +119 -0
  56. package/dist/session-tracker/dist/types.d.ts +32 -0
  57. package/dist/session-tracker/dist/types.js +1 -0
  58. package/dist/session-tracker/dist/writer.d.ts +12 -0
  59. package/dist/session-tracker/dist/writer.js +27 -0
  60. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.22.107
4
+
5
+ - **A bare interactive run places itself like `--device auto` (PHNX-4083).**
6
+ `agents run <harness>` with no prompt on a real TTY (no `--json`) now
7
+ auto-places onto a fleet worker — the same engine, pool, and banner as
8
+ `--device auto` — instead of always running on the machine you typed it at;
9
+ headless runs (any prompt, `--json`, teams/routines/hooks) are unchanged and
10
+ still run in place. To keep a local interactive run, pass
11
+ `--device <this machine>` or pick this machine (listed first) in the
12
+ `<harness>@` device picker; when placement finds no healthy device (empty
13
+ pool, or the PHNX-4051 stale-usage refusal) the run fails loud with the
14
+ placement error plus `Run here instead: agents run <harness> --device
15
+ <this machine>` — never a silent local fallback. Source:
16
+ `src/commands/exec.ts`, `src/commands/run-account-picker.ts`.
17
+
18
+ - **Run pickers move to `#` (account) and `@` (device), `#@` asks both
19
+ (PHNX-4083).** `agents run claude#` now opens the account picker (the old
20
+ `claude@` menu, same rows and code path); `agents run claude@` opens the new
21
+ fleet device picker — this machine first, offline rows disabled, cached-state
22
+ age in the prompt — and `claude#@` asks the account first, then the device,
23
+ dispatching with the picked account label. A picker combined with an explicit
24
+ pin of the same thing (`claude@2.1.218#`, `claude#work#`, `claude@@`) or a
25
+ conflicting flag (`--account`, `--device`/`--on`/`--computer`/`--host`) fails
26
+ loud; a cancelled menu launches nothing. Source: `src/commands/exec.ts`,
27
+ `src/lib/hosts/dispatch.ts`.
28
+
29
+ ## 1.22.106
30
+
31
+ - Fixed release packages omitting the session-tracking hook. Release qualification now uses the complete CLI build, so installed agents can record the account that owns each native session.
32
+
33
+ - **Resume conversations by account with one shared picker (PHNX-3940).** `ag run claude --resume` opens the same history picker as `agents sessions resume --agent claude`; `claude#work` applies `--account work`. Selected conversations retain their account, model, permissions, cwd and run options while using the installed binary. Canonical account homes and short Codex homes are discovered independently of version installs. Explicit terminal backends work with session IDs. Native context is verified after cold discovery, and archived replay requires an explicit choice. Origin account identity survives alias updates and index rescans; a model refusal does not disable unrelated models or accounts.
34
+
3
35
  ## 1.22.105
4
36
 
5
37
  - Computer setup installs standalone Computer CLI 0.1.2, whose application code is obfuscated before compilation to increase inspection effort. Agents continues to provide permissions and session tracking through its adapter.
package/README.md CHANGED
@@ -202,11 +202,15 @@ agents run claude "refactor auth module" --mode edit --fallback codex,antigravit
202
202
  # Picks the signed-in account you haven't used recently.
203
203
  agents run claude "summarize recent commits" --strategy balanced
204
204
 
205
- # Or choose one account/version interactively for only this run.
206
- agents run claude@
207
- agents run codex@ "review this branch"
208
- agents run claude@ --device auto # pick the device, then choose there
209
- agents run claude@ --device yosemite-s0 # choose from one device's accounts
205
+ # Or choose one account/version interactively for only this run (# = account picker).
206
+ agents run claude#
207
+ agents run codex# "review this branch"
208
+ agents run claude# --device auto # pick the device, then choose there
209
+ agents run claude# --device yosemite-s0 # choose from one device's accounts
210
+
211
+ # @ picks the device instead; #@ asks both (account first, then device).
212
+ agents run claude@ # pick the device for this run
213
+ agents run claude#@ # pick the account, then the device
210
214
  ```
211
215
 
212
216
  `--strategy balanced` spreads work across available versions of the same agent -- useful when you have multiple accounts and want to avoid burning through one. When a Claude run reports a session limit, agents-cli records the stated reset time, shows `session-limited` in `agents view`, and excludes that account until the reset. When every account is rate-limited, the run exits nonzero naming each excluded account and the earliest window reset (use `--strategy pinned` to force a rate-limited default) -- it never launches into an exhausted account. A logged-out default is never forced: unpinned dispatch picks a signed-in version on the execution device instead of dying on a credential-less default home.
@@ -431,6 +435,24 @@ Both targets are on-demand backups only; neither enables background session sync
431
435
 
432
436
  ### Resume anywhere — and stay resumed
433
437
 
438
+ Omit the session ID to choose from an interactive history picker with descriptions
439
+ and conversation previews. These commands use the same picker and account filter:
440
+
441
+ ```bash
442
+ ag run claude --resume
443
+ agents sessions resume --agent claude
444
+
445
+ ag run claude#work --resume
446
+ agents sessions resume --agent claude --account work
447
+ ```
448
+
449
+ Resume restores the conversation's account, model, mode and working directory with
450
+ the currently installed harness. Updating that binary does not select a different
451
+ account. `agents sessions resume <id> --vscodium` opens the selected conversation in
452
+ VSCodium. If only archived context remains, the CLI asks before starting a new
453
+ conversation from it; a missing transcript fails before launching an agent.
454
+
455
+
434
456
  Pick up any past conversation and drop it back into a terminal:
435
457
 
436
458
  ```bash
@@ -446,7 +468,7 @@ agents run auto --resume 019fd0c8-b3e9-77a2-a1a4-444698c4d897 # adapt if its ac
446
468
 
447
469
  ### Send an agent to the background — and bring it back
448
470
 
449
- Running 30 agents and drowning in terminal tabs? `agents sessions detach <id>` stops a session's interactive process and keeps it working **headless** in the background -- it drives its task to done unattended, no tab, lower cost. `agents sessions resume <id>` brings it back through the same origin-device recovery decision: native resume in the exact origin home (healthy login, or a rotated injectable account on a usage limit), or same-harness `/continue` as last resort when that home is unavailable, with the full indexed history (including whatever it did while backgrounded).
471
+ Running 30 agents and drowning in terminal tabs? `agents sessions detach <id>` stops a session's interactive process and keeps it working **headless** in the background -- it drives its task to done unattended, no tab, lower cost. `agents sessions resume <id>` brings it back through the same origin-device recovery decision: native resume in the owned account home, or an explicitly chosen same-harness `/continue` replay when native context is unavailable.
450
472
 
451
473
  ```
452
474
  agents sessions detach a1b2c3d4 # go headless in the background, keep working
package/dist/browser.js CHANGED
File without changes
@@ -10,13 +10,24 @@ import type { ExecEffort } from '../lib/exec.js';
10
10
  import { RUN_AUTO_KEYWORD } from '../lib/types.js';
11
11
  /** Validate a caller-supplied session id before it reaches tmux, paths, indexes, or remote dispatch. */
12
12
  export declare function parseExplicitSessionId(value: string): string;
13
- export interface RunAccountPickerRequest {
14
- requested: boolean;
13
+ export interface RunPickerMarkers {
14
+ accountPicker: boolean;
15
+ devicePicker: boolean;
15
16
  normalizedAgentSpec: string;
16
17
  valid: boolean;
18
+ reason?: string;
17
19
  }
18
- /** Distinguish a terminal account-picker marker from an explicit @version pin. */
19
- export declare function parseRunAccountPickerRequest(agentSpec: string): RunAccountPickerRequest;
20
+ /**
21
+ * Parse the trailing picker markers on an `agents run` agent spec. A terminal
22
+ * run of `#`/`@` characters requests the account picker (`#`) and/or the
23
+ * device picker (`@`) — each at most once, in either order (`claude#@`,
24
+ * `claude@#`). Stripping them yields the normalized spec (`claude#work@` →
25
+ * `claude#work`, version pins and `#label` account pins intact). A picker
26
+ * cannot combine with an explicit pin of what it picks: `claude@2.1.218#`
27
+ * (the account picker already chooses the version — the old `claude@2.1.218@`
28
+ * rule), `claude#work#`, `claude@@`.
29
+ */
30
+ export declare function parseRunPickerMarkers(agentSpec: string): RunPickerMarkers;
20
31
  /**
21
32
  * The `--device` alias family — the flags that mean "dispatch this run to another
22
33
  * machine over SSH". `--device` is canonical; `--on`/`--computer` are hidden
@@ -31,11 +42,29 @@ export declare function hostTargetGiven(options: {
31
42
  on?: string;
32
43
  computer?: string;
33
44
  }): string[];
34
- /** Return every option whose selection semantics conflict with an account choice. */
45
+ /**
46
+ * Return every option whose selection semantics conflict with an account
47
+ * choice (`agent#`). Device routing is deliberately absent: the marker rides
48
+ * the hop and the peer picks from ITS slots.
49
+ */
35
50
  export declare function runAccountPickerConflicts(options: {
36
51
  resume?: string | boolean;
37
52
  strategy?: string;
38
53
  balanced?: boolean;
54
+ lease?: string | boolean;
55
+ box?: string;
56
+ account?: string;
57
+ host?: string;
58
+ device?: string;
59
+ on?: string;
60
+ computer?: string;
61
+ }): string[];
62
+ /**
63
+ * Return every option that already decides where the run lands, so a device
64
+ * choice (`agent@`) would be silently ignored: any explicit host flag, and the
65
+ * lease/box paths, which own placement outright.
66
+ */
67
+ export declare function runDevicePickerConflicts(options: {
39
68
  lease?: string | boolean;
40
69
  box?: string;
41
70
  host?: string;
@@ -47,11 +76,15 @@ export { RUN_AUTO_KEYWORD };
47
76
  /**
48
77
  * Whether `run auto` should default its host layer to the affinity pick (the
49
78
  * same machinery as `--device auto`). False when the caller pinned any host
50
- * flag, and false when this process was itself dispatched by a host run — the
51
- * dispatcher exports AGENTS_RUN_AUTO_HOST_RESOLVED=1 into the remote SHELL
79
+ * flag, and false when this process was itself dispatched by a host run —
80
+ * the dispatcher exports AGENTS_RUN_AUTO_HOST_RESOLVED=1 into the remote SHELL
52
81
  * (hosts/dispatch.ts remoteRunShellPrelude) because it already resolved the
53
82
  * host layer, and re-picking here would chain-hop the run across the fleet.
54
- * Pure so the pinning matrix is unit-testable.
83
+ * An INTERACTIVE dispatch of a named harness also reaches the remote as a bare
84
+ * `agents run <harness>` (its argv forwards without the routing flag), so the
85
+ * interactive prelude's AGENTS_REMOTE_INTERACTIVE=1 counts as "already placed"
86
+ * too — without it the remote would re-place the run and ping-pong across the
87
+ * fleet. Pure so the pinning matrix is unit-testable.
55
88
  */
56
89
  export declare function runAutoDefaultsToAffinity(options: {
57
90
  host?: string;
@@ -59,6 +92,43 @@ export declare function runAutoDefaultsToAffinity(options: {
59
92
  on?: string;
60
93
  computer?: string;
61
94
  }, env?: NodeJS.ProcessEnv): boolean;
95
+ /**
96
+ * Whether a bare human-facing `agents run <harness>` — no prompt, so an
97
+ * interactive TUI run — defaults its placement to `--device auto` (PHNX-4083).
98
+ * A marker left off is decided for you: no `#` means balanced rotation, and no
99
+ * `@` (and no other placement flag) now means automatic device placement — the
100
+ * same engine as `--device auto`, whose pool never contains a box marked
101
+ * `personal`. ALL of these must hold:
102
+ *
103
+ * - no prompt (headless runs — teams, routines, hooks, `run <agent> "…"` —
104
+ * keep running in place, unchanged);
105
+ * - a human-facing surface: a real TTY and no `--json`. This is the same
106
+ * two-condition gate `signInLaunchDecision` uses in run-account-picker.ts —
107
+ * reused here through isHumanFacingRun, not re-derived;
108
+ * - no device-picker marker (`agent@` already chose the device; picking this
109
+ * machine there is a plain local run);
110
+ * - no `--resume` / `--lease` / `--box` / `--cloud` (those own placement);
111
+ * - the host layer is unpinned and this process is not itself a dispatched
112
+ * hop — delegated to runAutoDefaultsToAffinity, which encodes both.
113
+ *
114
+ * Pure so the default-placement matrix is unit-testable.
115
+ */
116
+ export declare function bareInteractiveRunDefaultsToDeviceAuto(options: {
117
+ host?: string;
118
+ device?: string;
119
+ on?: string;
120
+ computer?: string;
121
+ resume?: string | boolean;
122
+ lease?: string | boolean;
123
+ box?: string;
124
+ cloud?: boolean;
125
+ }, run: {
126
+ prompt?: string;
127
+ devicePickerRequested?: boolean;
128
+ }, surface: {
129
+ tty: boolean;
130
+ json?: boolean;
131
+ }, env?: NodeJS.ProcessEnv): boolean;
62
132
  /**
63
133
  * Whether an interactive host dispatch must mint a correlation launch id and
64
134
  * resolve the remote session via the launch-id join (RUSH-2034), rather than