@phnx-labs/agents-cli 1.22.47 → 1.22.50

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 (272) hide show
  1. package/CHANGELOG.md +503 -17
  2. package/README.md +76 -32
  3. package/dist/bootstrap.js +4 -2
  4. package/dist/cli/command-registry.d.ts +1 -0
  5. package/dist/cli/command-registry.js +2 -0
  6. package/dist/commands/accounts.d.ts +58 -0
  7. package/dist/commands/accounts.js +201 -39
  8. package/dist/commands/artifacts.js +7 -6
  9. package/dist/commands/attach.js +1 -1
  10. package/dist/commands/browser.js +501 -103
  11. package/dist/commands/config.d.ts +0 -1
  12. package/dist/commands/config.js +0 -20
  13. package/dist/commands/daemon-test-harness.d.ts +42 -0
  14. package/dist/commands/daemon-test-harness.js +90 -0
  15. package/dist/commands/daemon.d.ts +21 -0
  16. package/dist/commands/daemon.js +147 -12
  17. package/dist/commands/device-config-test-harness.d.ts +11 -0
  18. package/dist/commands/device-config-test-harness.js +59 -0
  19. package/dist/commands/exec.js +76 -16
  20. package/dist/commands/focus.d.ts +14 -0
  21. package/dist/commands/focus.js +48 -5
  22. package/dist/commands/go.d.ts +3 -0
  23. package/dist/commands/go.js +16 -3
  24. package/dist/commands/inspect.js +2 -2
  25. package/dist/commands/lease.d.ts +1 -1
  26. package/dist/commands/lease.js +4 -3
  27. package/dist/commands/mailboxes.js +4 -3
  28. package/dist/commands/menubar.js +11 -4
  29. package/dist/commands/projects.d.ts +16 -1
  30. package/dist/commands/projects.js +58 -64
  31. package/dist/commands/resume.js +1 -1
  32. package/dist/commands/route.js +4 -4
  33. package/dist/commands/routines.js +3 -2
  34. package/dist/commands/run-broadcast.d.ts +1 -1
  35. package/dist/commands/run-broadcast.js +1 -1
  36. package/dist/commands/sessions-picker.d.ts +22 -0
  37. package/dist/commands/sessions-picker.js +48 -9
  38. package/dist/commands/sessions-trace.js +1 -1
  39. package/dist/commands/sessions.js +1 -0
  40. package/dist/commands/setup-secrets.js +23 -0
  41. package/dist/commands/share.d.ts +20 -5
  42. package/dist/commands/share.js +158 -53
  43. package/dist/commands/ssh.js +54 -7
  44. package/dist/commands/teams.d.ts +12 -0
  45. package/dist/commands/teams.js +44 -67
  46. package/dist/commands/traces.d.ts +2 -0
  47. package/dist/commands/traces.js +188 -0
  48. package/dist/commands/view.d.ts +1 -1
  49. package/dist/commands/view.js +17 -34
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +5 -0
  52. package/dist/lib/account-provider-registry.d.ts +9 -0
  53. package/dist/lib/account-provider-registry.js +20 -0
  54. package/dist/lib/accounting/account-pool-collect.d.ts +34 -0
  55. package/dist/lib/accounting/account-pool-collect.js +71 -0
  56. package/dist/lib/accounting/account-pool.d.ts +46 -0
  57. package/dist/lib/accounting/account-pool.js +33 -0
  58. package/dist/lib/accounting/capacity.d.ts +24 -0
  59. package/dist/lib/accounting/capacity.js +30 -0
  60. package/dist/lib/accounting/rotate.d.ts +11 -18
  61. package/dist/lib/accounting/rotate.js +6 -24
  62. package/dist/lib/accounting/usage.d.ts +14 -3
  63. package/dist/lib/accounting/usage.js +64 -18
  64. package/dist/lib/agent-spec/agents.js +11 -9
  65. package/dist/lib/browser/drivers/ssh.d.ts +16 -2
  66. package/dist/lib/browser/drivers/ssh.js +36 -9
  67. package/dist/lib/browser/ipc.js +8 -3
  68. package/dist/lib/browser/profiles.d.ts +35 -101
  69. package/dist/lib/browser/profiles.js +130 -301
  70. package/dist/lib/browser/registry.d.ts +39 -0
  71. package/dist/lib/browser/registry.js +149 -0
  72. package/dist/lib/browser/remote-control.d.ts +8 -6
  73. package/dist/lib/browser/remote-control.js +8 -6
  74. package/dist/lib/browser/resolve-target.d.ts +68 -0
  75. package/dist/lib/browser/resolve-target.js +250 -0
  76. package/dist/lib/browser/runtime-state.d.ts +40 -16
  77. package/dist/lib/browser/runtime-state.js +92 -25
  78. package/dist/lib/browser/service.d.ts +28 -9
  79. package/dist/lib/browser/service.js +139 -62
  80. package/dist/lib/browser/task-index.d.ts +70 -0
  81. package/dist/lib/browser/task-index.js +180 -0
  82. package/dist/lib/byok-usage.js +2 -2
  83. package/dist/lib/claude-statusline.d.ts +29 -0
  84. package/dist/lib/claude-statusline.js +139 -0
  85. package/dist/lib/cloud/host.d.ts +1 -1
  86. package/dist/lib/cloud/host.js +1 -1
  87. package/dist/lib/cloud/rush.js +1 -1
  88. package/dist/lib/computer/computer-rpc.js +2 -2
  89. package/dist/lib/computer/download.d.ts +15 -15
  90. package/dist/lib/computer/download.js +35 -98
  91. package/dist/lib/computer/ssh-tunnel.d.ts +0 -3
  92. package/dist/lib/computer/ssh-tunnel.js +12 -22
  93. package/dist/lib/config-keys.d.ts +2 -8
  94. package/dist/lib/config-keys.js +2 -13
  95. package/dist/lib/crabbox/cli.d.ts +1 -1
  96. package/dist/lib/crabbox/cli.js +2 -2
  97. package/dist/lib/crabbox/lease.d.ts +9 -0
  98. package/dist/lib/crabbox/lease.js +70 -15
  99. package/dist/lib/crabbox/runtimes.js +1 -1
  100. package/dist/lib/daemon/account-state-daemon-service.d.ts +16 -0
  101. package/dist/lib/daemon/account-state-daemon-service.js +26 -0
  102. package/dist/lib/daemon/browser-ipc-service.d.ts +20 -0
  103. package/dist/lib/daemon/browser-ipc-service.js +46 -0
  104. package/dist/lib/daemon/daemon.d.ts +3 -0
  105. package/dist/lib/daemon/daemon.js +212 -444
  106. package/dist/lib/daemon/device-probe-service.d.ts +26 -0
  107. package/dist/lib/daemon/device-probe-service.js +47 -0
  108. package/dist/lib/daemon/keychain-reap-service.d.ts +17 -0
  109. package/dist/lib/daemon/keychain-reap-service.js +32 -0
  110. package/dist/lib/daemon/monitor-engine-service.d.ts +22 -0
  111. package/dist/lib/daemon/monitor-engine-service.js +29 -0
  112. package/dist/lib/daemon/secrets-broker-service.d.ts +20 -0
  113. package/dist/lib/daemon/secrets-broker-service.js +66 -0
  114. package/dist/lib/daemon/self-heal-service.d.ts +27 -0
  115. package/dist/lib/daemon/self-heal-service.js +48 -0
  116. package/dist/lib/daemon/service.d.ts +102 -0
  117. package/dist/lib/daemon/service.js +98 -0
  118. package/dist/lib/daemon/session-index-service.d.ts +22 -0
  119. package/dist/lib/daemon/session-index-service.js +40 -0
  120. package/dist/lib/daemon/state-dir-check-service.d.ts +43 -0
  121. package/dist/lib/daemon/state-dir-check-service.js +63 -0
  122. package/dist/lib/daemon/supervisor.d.ts +87 -0
  123. package/dist/lib/daemon/supervisor.js +298 -0
  124. package/dist/lib/daemon/watchdog-service.d.ts +19 -0
  125. package/dist/lib/daemon/watchdog-service.js +40 -0
  126. package/dist/lib/daemon-health.d.ts +15 -0
  127. package/dist/lib/daemon-health.js +29 -5
  128. package/dist/lib/daemon-services.d.ts +8 -1
  129. package/dist/lib/daemon-services.js +55 -0
  130. package/dist/lib/daemon-ticks.d.ts +13 -2
  131. package/dist/lib/daemon-ticks.js +20 -18
  132. package/dist/lib/device-config.d.ts +0 -2
  133. package/dist/lib/device-config.js +1 -23
  134. package/dist/lib/devices/registry.d.ts +1 -1
  135. package/dist/lib/devices/registry.js +1 -1
  136. package/dist/lib/devices/stats-cache.d.ts +20 -0
  137. package/dist/lib/devices/stats-cache.js +49 -5
  138. package/dist/lib/devices/worker-pick.d.ts +48 -0
  139. package/dist/lib/devices/worker-pick.js +113 -0
  140. package/dist/lib/exec.d.ts +67 -13
  141. package/dist/lib/exec.js +85 -29
  142. package/dist/lib/harness/adapters/cursor.js +8 -11
  143. package/dist/lib/helper-download.d.ts +108 -0
  144. package/dist/lib/helper-download.js +194 -0
  145. package/dist/lib/helper-versions.d.ts +52 -0
  146. package/dist/lib/helper-versions.js +58 -0
  147. package/dist/lib/hooks/cache.js +11 -0
  148. package/dist/lib/hooks/install.js +2 -2
  149. package/dist/lib/hosts/credentials.d.ts +1 -1
  150. package/dist/lib/hosts/credentials.js +1 -1
  151. package/dist/lib/hosts/dispatch.d.ts +7 -1
  152. package/dist/lib/hosts/dispatch.js +24 -5
  153. package/dist/lib/hosts/passthrough.d.ts +8 -15
  154. package/dist/lib/hosts/passthrough.js +19 -16
  155. package/dist/lib/hosts/providers/devices.d.ts +1 -1
  156. package/dist/lib/hosts/providers/devices.js +1 -1
  157. package/dist/lib/hosts/reconnect.d.ts +179 -21
  158. package/dist/lib/hosts/reconnect.js +266 -45
  159. package/dist/lib/installations/migrate.d.ts +4 -5
  160. package/dist/lib/installations/migrate.js +6 -7
  161. package/dist/lib/installations/shims.d.ts +1 -1
  162. package/dist/lib/installations/shims.js +23 -13
  163. package/dist/lib/installations/store.js +6 -3
  164. package/dist/lib/installations/versions.js +73 -48
  165. package/dist/lib/linear-autoclose.d.ts +1 -1
  166. package/dist/lib/linear-autoclose.js +1 -1
  167. package/dist/lib/loop.d.ts +2 -2
  168. package/dist/lib/loop.js +1 -1
  169. package/dist/lib/menubar/download-menubar.d.ts +47 -0
  170. package/dist/lib/menubar/download-menubar.js +60 -0
  171. package/dist/lib/menubar/install-menubar.d.ts +31 -7
  172. package/dist/lib/menubar/install-menubar.js +79 -21
  173. package/dist/lib/menubar/notify-desktop.d.ts +3 -3
  174. package/dist/lib/menubar/notify-desktop.js +6 -6
  175. package/dist/lib/model-tiers.d.ts +1 -1
  176. package/dist/lib/project-probe.d.ts +1 -1
  177. package/dist/lib/project-probe.js +1 -1
  178. package/dist/lib/project-pull.d.ts +1 -1
  179. package/dist/lib/project-pull.js +2 -2
  180. package/dist/lib/projects.d.ts +1 -1
  181. package/dist/lib/projects.js +1 -1
  182. package/dist/lib/sandbox.js +6 -7
  183. package/dist/lib/secrets/download-keychain.d.ts +47 -0
  184. package/dist/lib/secrets/download-keychain.js +70 -0
  185. package/dist/lib/secrets/install-helper.d.ts +20 -1
  186. package/dist/lib/secrets/install-helper.js +44 -3
  187. package/dist/lib/session/active.js +17 -1
  188. package/dist/lib/session/db.d.ts +11 -1
  189. package/dist/lib/session/db.js +138 -6
  190. package/dist/lib/session/discover.d.ts +21 -1
  191. package/dist/lib/session/discover.js +33 -5
  192. package/dist/lib/session/highlights.d.ts +49 -1
  193. package/dist/lib/session/highlights.js +95 -0
  194. package/dist/lib/session/host-link.d.ts +16 -2
  195. package/dist/lib/session/host-link.js +7 -1
  196. package/dist/lib/session/parse.js +33 -1
  197. package/dist/lib/session/remote/remote-list.d.ts +9 -0
  198. package/dist/lib/session/remote/remote-list.js +19 -2
  199. package/dist/lib/session/remote/watch.js +11 -2
  200. package/dist/lib/session/session-cache.d.ts +53 -0
  201. package/dist/lib/session/session-cache.js +88 -0
  202. package/dist/lib/session/state.js +1 -1
  203. package/dist/lib/session/tool-calls.d.ts +2 -0
  204. package/dist/lib/session/tool-calls.js +1 -1
  205. package/dist/lib/session/trajectory-html.d.ts +5 -1
  206. package/dist/lib/session/trajectory-html.js +42 -22
  207. package/dist/lib/session/trajectory-text.js +9 -2
  208. package/dist/lib/session/trajectory.js +53 -4
  209. package/dist/lib/session/types.d.ts +15 -0
  210. package/dist/lib/sha256-asset.d.ts +26 -0
  211. package/dist/lib/sha256-asset.js +41 -0
  212. package/dist/lib/share/backend.d.ts +95 -0
  213. package/dist/lib/share/backend.js +139 -0
  214. package/dist/lib/share/delete.d.ts +6 -2
  215. package/dist/lib/share/delete.js +8 -9
  216. package/dist/lib/share/html.d.ts +22 -0
  217. package/dist/lib/share/html.js +88 -0
  218. package/dist/lib/share/provision.d.ts +18 -4
  219. package/dist/lib/share/provision.js +38 -4
  220. package/dist/lib/share/publish.d.ts +44 -15
  221. package/dist/lib/share/publish.js +58 -26
  222. package/dist/lib/share/worker-template.js +402 -25
  223. package/dist/lib/sqlite.js +16 -3
  224. package/dist/lib/ssh-exec.d.ts +65 -0
  225. package/dist/lib/ssh-exec.js +120 -4
  226. package/dist/lib/startup/command-registry.js +1 -1
  227. package/dist/lib/startup/dev-build.js +3 -3
  228. package/dist/lib/state.d.ts +1 -1
  229. package/dist/lib/state.js +7 -3
  230. package/dist/lib/subagents-registry.js +1 -1
  231. package/dist/lib/teams/agents.d.ts +14 -12
  232. package/dist/lib/teams/agents.js +188 -73
  233. package/dist/lib/teams/api.d.ts +6 -1
  234. package/dist/lib/teams/api.js +2 -0
  235. package/dist/lib/teams/scheduler.d.ts +7 -0
  236. package/dist/lib/teams/scheduler.js +26 -8
  237. package/dist/lib/terminal/index.d.ts +1 -1
  238. package/dist/lib/terminal/types.d.ts +1 -1
  239. package/dist/lib/terminal/types.js +1 -1
  240. package/dist/lib/tmux/orphan-reap.js +1 -1
  241. package/dist/lib/tmux/session.js +31 -0
  242. package/dist/lib/traces/backend.d.ts +29 -0
  243. package/dist/lib/traces/backend.js +46 -0
  244. package/dist/lib/traces/classify.d.ts +52 -0
  245. package/dist/lib/traces/classify.js +72 -0
  246. package/dist/lib/traces/config.d.ts +10 -0
  247. package/dist/lib/traces/config.js +2 -0
  248. package/dist/lib/traces/provision.d.ts +19 -0
  249. package/dist/lib/traces/provision.js +30 -0
  250. package/dist/lib/traces/sync.d.ts +150 -0
  251. package/dist/lib/traces/sync.js +459 -0
  252. package/dist/lib/traces/worker-template.d.ts +4 -0
  253. package/dist/lib/traces/worker-template.js +159 -0
  254. package/dist/lib/types.d.ts +18 -19
  255. package/dist/lib/types.js +14 -0
  256. package/dist/lib/usage-refresh.d.ts +1 -1
  257. package/dist/lib/usage-refresh.js +11 -8
  258. package/dist/lib/workflows.d.ts +1 -1
  259. package/package.json +4 -6
  260. package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
  261. package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +0 -24
  262. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  263. package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
  264. package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +0 -128
  265. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  266. package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +0 -26
  267. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  268. package/dist/lib/secrets/Agents CLI.app/Contents/Resources/AppIcon.icns +0 -0
  269. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +0 -135
  270. package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
  271. package/dist/lib/usage-fleet.d.ts +0 -32
  272. package/dist/lib/usage-fleet.js +0 -125
@@ -1,18 +1,21 @@
1
- // `agents artifacts share` — publish an HTML file to your own Cloudflare R2
2
- // behind a tiny Worker, and get a shareable link (~$0). See apps/cli/docs/share.md.
1
+ // `agents artifacts share` — publish an HTML file to a shareable link. Signed-in
2
+ // users hit the managed endpoint (share.agents-cli.sh) with the Phoenix bearer;
3
+ // otherwise the existing BYO Cloudflare R2 + Worker path. See cli/docs/observability.md.
3
4
  //
4
5
  // Registered under the `artifacts` group by commands/artifacts.ts; the
5
6
  // provisioning door lives beside it at `agents artifacts setup`
6
7
  // (commands/artifacts-setup.ts), which calls `runShareProvision` below.
7
8
  import { existsSync } from 'node:fs';
8
9
  import { formatBytes } from '../lib/format.js';
10
+ import { Option } from 'commander';
9
11
  import chalk from 'chalk';
10
12
  import { DEFAULT_BUCKET_NAME, DEFAULT_CF_BUNDLE, DEFAULT_SHARE_DOMAIN, DEFAULT_WORKER_NAME, generateWriteToken, readCloudflareCreds, readShareConfig, readWriteToken, readWriteTokenEnv, readWriteTokenFromBundle, storeWriteToken, writeShareConfig, } from '../lib/share/config.js';
11
- import { addCustomDomain, configureBucketLifecycle, createBucket, deployWorker, enableWorkersDev, findZoneId, hashWorkerScript, updateWorker, setWorkerSecret, } from '../lib/share/provision.js';
12
- import { publishFile, resolveShareUsername, parseMetaEntries } from '../lib/share/publish.js';
13
+ import { addCustomDomain, configureBucketLifecycle, createBucket, deployWorker, enableWorkersDev, findZoneId, hashWorkerScript, putWorkerSecret, updateWorker, WORKER_PHOENIX_ID_BASE_SECRET, setWorkerSecret, } from '../lib/share/provision.js';
14
+ import { publishFile, resolveShareUsername, parseMetaEntries, resolveShareVisibility, } from '../lib/share/publish.js';
13
15
  import { deleteShare, resolveDeleteTarget } from '../lib/share/delete.js';
14
16
  import { renderWorkerScript } from '../lib/share/worker-template.js';
15
17
  import { analyticsEnabled } from '../lib/share/analytics.js';
18
+ import { phoenixIdBaseForDeploy, resolveShareBackend, } from '../lib/share/backend.js';
16
19
  import { resolveGitHubUsername } from '../lib/git.js';
17
20
  import { setHelpSections } from '../lib/help.js';
18
21
  export function formatSharePublishResult(result, json = false) {
@@ -29,8 +32,16 @@ export function formatSharePublishResult(result, json = false) {
29
32
  lines.push(chalk.dim(` expires ${new Date(result.expiresAt).toLocaleString()}`));
30
33
  else
31
34
  lines.push(chalk.dim(' expires never'));
32
- if (result.unlisted)
33
- lines.push(chalk.dim(' unlisted (hidden from gallery / share list)'));
35
+ const visibility = result.visibility ?? (result.unlisted ? 'unlisted' : 'public');
36
+ if (visibility === 'unlisted') {
37
+ lines.push(chalk.dim(' visibility: unlisted (noindex, hidden from gallery)'));
38
+ }
39
+ else if (visibility === 'me' || visibility === 'org') {
40
+ lines.push(chalk.dim(` visibility: ${visibility} (login required, hidden from gallery)`));
41
+ }
42
+ else {
43
+ lines.push(chalk.dim(` visibility: ${visibility}`));
44
+ }
34
45
  return lines.join('\n');
35
46
  }
36
47
  /** Compare the configured endpoint's last-deployed template hash against the
@@ -100,25 +111,42 @@ export function parseShareListing(user, body) {
100
111
  });
101
112
  return { user, count: objects.length, objects };
102
113
  }
114
+ /** Namespace for list/revisions: managed uses the Phoenix handle (email
115
+ * local-part); BYO still resolves GitHub username (gh / git config / --for-user). */
116
+ async function namespaceForBackend(backend, githubUser) {
117
+ if (backend.kind === 'managed')
118
+ return backend.namespace;
119
+ return resolveShareUsername({ githubUser: githubUser || backend.namespace || undefined });
120
+ }
103
121
  /** Fetch and parse the machine-readable listing of the caller's namespace from the
104
122
  * Worker's `?format=json` route. Fails loud when share was never configured, when
105
123
  * the deployed template is known-outdated (RUSH-2449 templateHash), or when the
106
124
  * live response proves the route is absent (404 or a non-JSON 200 = the old HTML
107
- * gallery) — never a silent empty/wrong result. */
125
+ * gallery) — never a silent empty/wrong result. Signed-in users hit the managed
126
+ * endpoint; BYO still uses `readShareConfig()`. */
108
127
  export async function runShareList(opts = {}) {
109
- const cfg = opts.config ?? readShareConfig();
110
- if (!cfg) {
111
- throw new Error("Not set up yet. Run 'agents artifacts setup' (provision your own endpoint) or 'agents artifacts share join' (use an existing one).");
112
- }
113
- // A known-stale template can't have the listing route — say so before any network
114
- // call. 'unknown' (provisioned before templateHash tracking) is attempted, then
115
- // caught by the response checks below if the route turns out to be absent.
116
- const templateStatus = shareTemplateStatus(cfg);
117
- if (templateStatus === 'outdated') {
118
- throw new Error(OUTDATED_TEMPLATE_HINT);
128
+ const backend = resolveShareBackend({
129
+ githubUser: opts.githubUser,
130
+ config: opts.config,
131
+ writeToken: opts.writeToken,
132
+ byo: opts.byo,
133
+ session: opts.phoenixSession,
134
+ requireToken: false,
135
+ });
136
+ // Managed: the platform Worker is current; skip the BYO template-hash gate.
137
+ // A known-stale BYO template can't have the listing route — say so before any
138
+ // network call. 'unknown' (provisioned before templateHash tracking) is
139
+ // attempted, then caught by the response checks below if the route is absent.
140
+ let templateStatus = 'current';
141
+ if (backend.kind === 'byo') {
142
+ const cfg = opts.config ?? readShareConfig();
143
+ templateStatus = cfg ? shareTemplateStatus(cfg) : 'unknown';
144
+ if (templateStatus === 'outdated') {
145
+ throw new Error(OUTDATED_TEMPLATE_HINT);
146
+ }
119
147
  }
120
- const user = await resolveShareUsername({ githubUser: opts.githubUser });
121
- const listUrl = `${cfg.baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(user)}?format=json`;
148
+ const user = await namespaceForBackend(backend, opts.githubUser);
149
+ const listUrl = `${backend.baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(user)}?format=json`;
122
150
  const fetchListing = opts.fetchListing ?? defaultListingFetch;
123
151
  const res = await fetchListing(listUrl);
124
152
  if (res.status === 404) {
@@ -128,18 +156,22 @@ export async function runShareList(opts = {}) {
128
156
  // endpoint predates the listing route entirely. The recorded templateHash
129
157
  // disambiguates: a 'current' template HAS the route, so its 404 means an empty
130
158
  // namespace ("nothing published"); otherwise the route may be absent, so point
131
- // at `agents artifacts share update`.
159
+ // at `agents artifacts share update`. Managed is always 'current'.
132
160
  if (templateStatus === 'current') {
133
161
  return { user, count: 0, objects: [] };
134
162
  }
135
163
  throw new Error(OUTDATED_TEMPLATE_HINT);
136
164
  }
137
165
  if (res.status !== 200) {
138
- throw new Error(`Listing failed (${res.status}) for ${listUrl}. Check the endpoint is reachable, or that 'agents artifacts setup' completed.`);
166
+ throw new Error(`Listing failed (${res.status}) for ${listUrl}. Check the endpoint is reachable, or that 'agents artifacts setup' / 'agents auth login' completed.`);
139
167
  }
140
168
  if (!/application\/json/i.test(res.contentType)) {
141
169
  // A 200 that isn't JSON means the old Worker ignored ?format=json and served
142
- // the HTML gallery — the deployed template is outdated.
170
+ // the HTML gallery — the deployed template is outdated. Managed never hits
171
+ // this (platform Worker is current); fail loud if it somehow does.
172
+ if (backend.kind === 'managed') {
173
+ throw new Error(`Managed listing at ${listUrl} did not return JSON (${res.contentType || 'no content-type'}).`);
174
+ }
143
175
  throw new Error(OUTDATED_TEMPLATE_HINT);
144
176
  }
145
177
  const parsed = parseShareListing(user, res.body);
@@ -239,22 +271,34 @@ export function parseShareRevisions(key, body) {
239
271
  * or a bare slug resolved against the caller's own namespace) — reuses
240
272
  * {@link resolveDeleteTarget} rather than re-deriving the key. */
241
273
  export async function runShareRevisions(target, opts = {}) {
242
- const cfg = opts.config ?? readShareConfig();
243
- if (!cfg) {
244
- throw new Error("Not set up yet. Run 'agents artifacts setup' (provision your own endpoint) or 'agents artifacts share join' (use an existing one).");
245
- }
246
- const templateStatus = shareTemplateStatus(cfg);
247
- if (templateStatus === 'outdated') {
248
- throw new Error(OUTDATED_TEMPLATE_HINT);
274
+ const backend = resolveShareBackend({
275
+ githubUser: opts.githubUser,
276
+ config: opts.config,
277
+ writeToken: opts.writeToken,
278
+ byo: opts.byo,
279
+ session: opts.session,
280
+ requireToken: false,
281
+ });
282
+ if (backend.kind === 'byo') {
283
+ const cfg = opts.config ?? readShareConfig();
284
+ if (cfg && shareTemplateStatus(cfg) === 'outdated') {
285
+ throw new Error(OUTDATED_TEMPLATE_HINT);
286
+ }
249
287
  }
250
- const { key } = await resolveDeleteTarget(target, { githubUser: opts.githubUser });
251
- const revUrl = `${cfg.baseUrl.replace(/\/+$/, '')}/${key}?revisions=json`;
288
+ const githubUser = backend.kind === 'managed'
289
+ ? backend.namespace
290
+ : opts.githubUser || backend.namespace || undefined;
291
+ const { key } = await resolveDeleteTarget(target, { githubUser });
292
+ const revUrl = `${backend.baseUrl.replace(/\/+$/, '')}/${key}?revisions=json`;
252
293
  const fetchListing = opts.fetchListing ?? defaultListingFetch;
253
294
  const res = await fetchListing(revUrl);
254
295
  if (res.status !== 200) {
255
- throw new Error(`Revisions lookup failed (${res.status}) for ${revUrl}. Check the endpoint is reachable, or that 'agents artifacts setup' completed.`);
296
+ throw new Error(`Revisions lookup failed (${res.status}) for ${revUrl}. Check the endpoint is reachable, or that 'agents artifacts setup' / 'agents auth login' completed.`);
256
297
  }
257
298
  if (!/application\/json/i.test(res.contentType)) {
299
+ if (backend.kind === 'managed') {
300
+ throw new Error(`Managed revisions at ${revUrl} did not return JSON (${res.contentType || 'no content-type'}).`);
301
+ }
258
302
  throw new Error(OUTDATED_TEMPLATE_HINT);
259
303
  }
260
304
  return parseShareRevisions(key, res.body);
@@ -390,13 +434,16 @@ const SHARE_DELETE_NOTES = `
390
434
  export function registerShareCommands(artifactsCmd) {
391
435
  const shareCmd = artifactsCmd
392
436
  .command('share')
393
- .description('Publish an HTML file to your own Cloudflare R2 and get a shareable link (~$0).')
437
+ .description('Publish an HTML file to a shareable link — managed if signed in, otherwise your Cloudflare R2.')
394
438
  .argument('[file]', 'file to publish (HTML or any static asset)')
395
- .option('--slug <slug>', 'custom URL slug under your namespace (default: <project>-<feature>-<hash>)')
396
- .option('--github-user <user>', 'GitHub username for the share namespace (default: resolved from gh/git config)')
439
+ .option('--slug <slug>', 'custom URL slug under your namespace (default: <feature>-<16hex>)')
440
+ .option('--github-user <user>', 'GitHub username for the share namespace (default: resolved from gh/git config; ignored on the managed endpoint)')
397
441
  .option('--expire <spec>', "auto-expire (default 30d). e.g. 12h, 30d, 2026-08-01, or 'never'")
398
- .option('--unlisted', 'hide from the public gallery and `agents artifacts share list` (direct URL still works)')
399
- .option('--private', 'alias of --unlisted')
442
+ .addOption(new Option('--visibility <level>', 'public | unlisted | me | org (default public). unlisted is a capability URL; me/org require a Phoenix session and are hidden from the gallery')
443
+ .choices(['public', 'unlisted', 'me', 'org'])
444
+ .default('public'))
445
+ .addOption(new Option('--unlisted', 'hidden alias of --visibility unlisted').hideHelp())
446
+ .addOption(new Option('--private', 'hidden alias of --visibility unlisted').hideHelp())
400
447
  .option('--force', 'publish even when the file contains emails or credential-shaped strings')
401
448
  .option('--no-cover', 'skip the OG preview image (HTML pages get one by default)')
402
449
  .option('--no-analytics', 'skip injecting the Cloudflare Web Analytics beacon')
@@ -417,11 +464,16 @@ export function registerShareCommands(artifactsCmd) {
417
464
  }
418
465
  try {
419
466
  const meta = parseMetaEntries(opts.meta);
467
+ const visibility = resolveShareVisibility({
468
+ visibility: opts.visibility,
469
+ unlisted: opts.unlisted === true || opts.private === true,
470
+ });
420
471
  const result = await publishFile(file, {
421
472
  slug: opts.slug,
422
473
  githubUser: opts.githubUser,
423
474
  expire: opts.expire,
424
- unlisted: opts.unlisted === true || opts.private === true,
475
+ visibility,
476
+ unlisted: visibility === 'unlisted',
425
477
  force: opts.force,
426
478
  cover: opts.cover,
427
479
  analytics: opts.analytics,
@@ -438,11 +490,12 @@ export function registerShareCommands(artifactsCmd) {
438
490
  });
439
491
  setHelpSections(shareCmd, {
440
492
  examples: `
441
- # Publish an HTML file — auto OG cover, default 30d expiry, shareable link
493
+ # Signed in? Just publish — no Cloudflare setup (managed endpoint)
494
+ agents auth login
442
495
  agents artifacts share ./out/plan.html
443
496
 
444
- # Hide from the public gallery (direct URL still works) and expire sooner
445
- agents artifacts share ./out/report.html --unlisted --expire 12h
497
+ # Hide from the public gallery (direct URL still works, noindex) and expire sooner
498
+ agents artifacts share ./out/report.html --visibility unlisted --expire 12h
446
499
 
447
500
  # Permanent public page (opt out of the default 30d expiry)
448
501
  agents artifacts share ./out/landing.html --slug landing --expire never
@@ -464,11 +517,21 @@ ${SHARE_DELETE_EXAMPLES}
464
517
  agents artifacts share update
465
518
  `,
466
519
  notes: `
520
+ Signed-in users publish to the managed endpoint (share.agents-cli.sh/<handle>/…)
521
+ with the Phoenix session — no Cloudflare account, bucket, or write token. The
522
+ handle is the local-part of the signed-in email; the default slug is
523
+ <readable>-<16hex>. Without a session, the existing BYO Cloudflare path still
524
+ applies (setup / join). HTML is stored as one object: local images are inlined
525
+ and Chrome-saved file:// TOC links become in-page hashes.
526
+
467
527
  Default expiry is 30d so an accidental publish decays. Pass --expire never for
468
- a permanent link. --unlisted / --private hides the page from the public gallery
469
- and agents artifacts share list; the direct URL is still world-readable
470
- (unlisted, not secret). A pre-publish scan refuses emails and credential-shaped
471
- strings unless --force is passed.
528
+ a permanent link. --visibility unlisted (hidden aliases: --unlisted / --private)
529
+ hides the page from the public gallery and agents artifacts share list; the
530
+ direct URL is still world-readable (unlisted, not secret) and GET sends
531
+ X-Robots-Tag: noindex. --visibility me requires a Phoenix session and is only
532
+ visible to the signed-in owner; --visibility org requires the same and is
533
+ visible to members of the same Phoenix organization. A pre-publish scan
534
+ refuses emails and credential-shaped strings unless --force is passed.
472
535
 
473
536
  Every publish carries provenance auto-captured from the exec env/git/clock
474
537
  (agent, session, host, repo, date) — never invented, only sent when present —
@@ -549,11 +612,27 @@ ${SHARE_DELETE_NOTES}
549
612
  .command('status')
550
613
  .description('Show the configured share endpoint and namespace.')
551
614
  .action(async () => {
615
+ let backend;
616
+ try {
617
+ backend = resolveShareBackend({ requireToken: false });
618
+ }
619
+ catch (e) {
620
+ console.log(chalk.dim(e.message));
621
+ return;
622
+ }
623
+ if (backend.kind === 'managed') {
624
+ console.log(`${chalk.bold('backend')} ${chalk.green('managed')}`);
625
+ console.log(`${chalk.bold('endpoint')} ${chalk.green(backend.baseUrl)}`);
626
+ console.log(`${chalk.bold('namespace')} ${chalk.cyan(`${backend.baseUrl}/${backend.namespace}`)}`);
627
+ console.log(chalk.dim("Phoenix session — no Cloudflare setup. Force BYO with AGENTS_SHARE_BACKEND=byo."));
628
+ return;
629
+ }
552
630
  const cfg = readShareConfig();
553
631
  if (!cfg) {
554
632
  console.log(chalk.dim("Not configured. Run 'agents artifacts setup' or 'agents artifacts share join'."));
555
633
  return;
556
634
  }
635
+ console.log(`${chalk.bold('backend')} ${chalk.green('byo')}`);
557
636
  console.log(`${chalk.bold('endpoint')} ${chalk.green(cfg.baseUrl)}`);
558
637
  console.log(chalk.dim(`worker ${cfg.workerName} · bucket ${cfg.bucketName} · account ${cfg.accountId || 'missing'}`));
559
638
  if (!cfg.accountId) {
@@ -620,9 +699,10 @@ ${SHARE_DELETE_NOTES}
620
699
  `,
621
700
  notes: `
622
701
  Lists the ACTIVE pages in your namespace — expired links and the sibling .png OG
623
- covers are omitted (it mirrors the public gallery). It reads the endpoint's JSON
624
- listing route, which ships with the current Worker template. If your deployed
625
- Worker predates this feature the command says so and points you at 'agents
702
+ covers are omitted (it mirrors the public gallery). Signed-in users list the
703
+ managed endpoint (share.agents-cli.sh/<handle>); otherwise BYO. It reads the
704
+ endpoint's JSON listing route, which ships with the current Worker template. If
705
+ a BYO Worker predates this feature the command says so and points you at 'agents
626
706
  artifacts share update' (RUSH-2449) rather than returning a wrong or empty result
627
707
  — see 'agents artifacts share status' for whether an update is due.
628
708
 
@@ -669,13 +749,27 @@ ${SHARE_DELETE_NOTES}
669
749
  (pass --no-revision at publish time to skip it) — this is history, never
670
750
  shown on the public gallery or in 'agents artifacts share list' beyond its
671
751
  count. Each revision's own URL is still directly reachable and honors its own
672
- recorded expiry.
752
+ recorded expiry. Signed-in users resolve a bare slug against the managed
753
+ Phoenix namespace; otherwise BYO (GitHub username / --for-user).
673
754
  `,
674
755
  });
675
756
  shareCmd
676
757
  .command('analytics')
677
758
  .description('Show the Cloudflare Web Analytics status for this share endpoint.')
678
759
  .action(async () => {
760
+ let backend;
761
+ try {
762
+ backend = resolveShareBackend({ requireToken: false });
763
+ }
764
+ catch (e) {
765
+ console.log(chalk.dim(e.message));
766
+ return;
767
+ }
768
+ if (backend.kind === 'managed') {
769
+ console.log(chalk.yellow('Cloudflare Web Analytics is a BYO feature.'));
770
+ console.log(chalk.dim(`You're on the managed endpoint (${backend.baseUrl}). Per-page analytics for the managed endpoint is not in this release — provision your own Cloudflare with 'agents artifacts setup --analytics-token <token>', or force BYO with AGENTS_SHARE_BACKEND=byo.`));
771
+ return;
772
+ }
679
773
  const cfg = readShareConfig();
680
774
  if (!cfg) {
681
775
  console.log(chalk.dim("Not configured. Run 'agents artifacts setup' or 'agents artifacts share join'."));
@@ -755,6 +849,11 @@ export async function runShareProvision(opts) {
755
849
  spin.warn(`Zone for ${requestedDomain} not visible to this token — staying on workers.dev`);
756
850
  }
757
851
  }
852
+ const phoenixIdBase = phoenixIdBaseForDeploy({ managed: opts.managed }, { baseUrl, domain });
853
+ if (phoenixIdBase) {
854
+ await putWorkerSecret(apiToken, accountId, workerName, WORKER_PHOENIX_ID_BASE_SECRET, phoenixIdBase, provisionOpts);
855
+ spin.text = `Worker '${workerName}' Phoenix ID base set`;
856
+ }
758
857
  spin.succeed('Provisioned');
759
858
  const cfg = {
760
859
  baseUrl,
@@ -780,9 +879,10 @@ export async function runShareProvision(opts) {
780
879
  * current `worker-template.ts`. Reuses the existing account/worker/bucket and
781
880
  * write token from `readShareConfig()`/the `share` bundle — never creates a
782
881
  * bucket, touches routes/domains, or regenerates the token (see
783
- * `updateWorker` in `lib/share/provision.ts` for how the token survives the
784
- * re-upload). Idempotent: no-ops when the deployed hash already matches
785
- * unless `force`. */
882
+ * `updateWorker` in `lib/share/provision.ts` for how the token — and, on a
883
+ * managed endpoint, `PHOENIX_ID_BASE` — survives the re-upload). Idempotent:
884
+ * no-ops the script upload when the deployed hash already matches unless
885
+ * `force`; a managed endpoint still re-applies `PHOENIX_ID_BASE`. */
786
886
  export async function runShareUpdate(opts = {}) {
787
887
  const cfg = readShareConfig();
788
888
  if (!cfg) {
@@ -798,7 +898,12 @@ export async function runShareUpdate(opts = {}) {
798
898
  }
799
899
  const writeToken = readWriteToken();
800
900
  const script = renderWorkerScript();
801
- const provisionOpts = { ...(opts.request ? { request: opts.request } : {}), force: opts.force };
901
+ const phoenixIdBase = phoenixIdBaseForDeploy({ managed: opts.managed }, cfg);
902
+ const provisionOpts = {
903
+ ...(opts.request ? { request: opts.request } : {}),
904
+ force: opts.force,
905
+ ...(phoenixIdBase !== undefined ? { phoenixIdBase } : {}),
906
+ };
802
907
  const result = await updateWorker(apiToken, accountId, cfg.workerName, cfg.bucketName, script, writeToken, cfg.templateHash, provisionOpts);
803
908
  if (!result.skipped) {
804
909
  writeShareConfig({ ...cfg, accountId, templateHash: result.templateHash });
@@ -124,11 +124,18 @@ function pctCell(v, width) {
124
124
  * header — which defeats the scannability this column exists for. */
125
125
  const SPEC_WIDTH_MIN = 12;
126
126
  /** The static hardware as one compact cell — `12c 64G 1T`: cores, total RAM,
127
- * total root disk via fmtBytes. `—` when the probe never saw the box (specs
128
- * ride the long-TTL static tier, so a warm cache almost always has them).
127
+ * total root disk via fmtBytes. `—` only when no probe has ever seen the box.
128
+ *
129
+ * Deliberately NOT gated on `reachable`: hardware does not change while a
130
+ * machine is down, so an offline device keeps rendering the spec from its last
131
+ * successful probe (`retainHardwareFacts`, RUSH-3096) rather than blanking a
132
+ * fact that is still true. The volatile columns beside it — load, mem, disk
133
+ * used — stay `—`, and `fleetCapacity` still counts only reachable boxes, so
134
+ * a down machine never contributes to usable capacity.
135
+ *
129
136
  * Unpadded; {@link renderDeviceTable} pads to the measured column width. */
130
137
  function specText(stats) {
131
- if (!stats?.reachable || !stats.ncpu)
138
+ if (!stats?.ncpu)
132
139
  return '—';
133
140
  return `${stats.ncpu}c ${fmtBytes(stats.memTotalBytes)} ${fmtBytes(stats.diskTotalBytes)}`;
134
141
  }
@@ -225,7 +232,17 @@ export function renderDeviceTable(reg, names, self, statsMap, full = false, inte
225
232
  // "offline" while its live load/mem sit one column over (RUSH-1965).
226
233
  const offline = deviceOnlineState(d, stats) === 'offline';
227
234
  if (offline) {
228
- lines.push(fitDeviceRow(`${marker}${label}${plat} ${chalk.gray('offline')}`, role, desc, width));
235
+ // The spec cell rides the offline row: hardware is what the box IS, not
236
+ // what it is doing, so it stays legible while the machine is down
237
+ // (RUSH-3096). The live columns are omitted rather than dashed — there is
238
+ // no current load/mem/disk to report for a box that did not answer.
239
+ //
240
+ // The explicit gap is load-bearing: `specCell` pads to the MEASURED
241
+ // column width, so the widest spec on the fleet pads to nothing and the
242
+ // marker would collide with it ("455Goffline"). An online row gets its
243
+ // separation for free from `pctCell`'s right-alignment; this one has no
244
+ // numeric cell to lean on.
245
+ lines.push(fitDeviceRow(`${marker}${label}${plat} ${specCell(stats, specWidth)} ${chalk.gray('offline')}`, role, desc, width));
229
246
  continue;
230
247
  }
231
248
  const relay = !isSelf && d.tailscale?.online && !d.tailscale.direct ? chalk.yellow(' relay') : '';
@@ -1085,7 +1102,7 @@ function registerDevicesCommands(program) {
1085
1102
  registerLeaseCommand(devicesCmd);
1086
1103
  registerSnapshotCommand(devicesCmd);
1087
1104
  registerCommandGroups(devicesCmd, [
1088
- { title: 'Discover & register', names: ['sync', 'register', 'add', 'ignore', 'unignore', 'ignored', 'rm'] },
1105
+ { title: 'Discover & register', names: ['sync', 'register', 'add', 'ignore', 'unignore', 'ignored', 'remove'] },
1089
1106
  { title: 'Inspect', names: ['list', 'show', 'status', 'ping', 'harnesses', 'accounts', 'snapshot'] },
1090
1107
  { title: 'Disposable devices', names: ['lease'] },
1091
1108
  { title: 'Configure a device', names: ['config', 'describe', 'render'] },
@@ -1997,6 +2014,36 @@ function registerDevicesCommands(program) {
1997
2014
  await runFleetPing({ ...opts, verbose });
1998
2015
  });
1999
2016
  const csvList = (s) => s ? s.split(',').map((x) => x.trim()).filter(Boolean) : undefined;
2017
+ devicesCmd
2018
+ .command('pick')
2019
+ .description('Print the device automatic placement would choose for offloaded machine work (the suite, a build) — least-loaded, reachable, POSIX, never the box you are sitting at. Writes just the name to stdout so scripts can consume it.')
2020
+ .option('--json', 'output the pick plus every candidate and exclusion reason')
2021
+ .option('--platform <list>', 'comma-separated platforms to allow (default: linux,macos)')
2022
+ .action(async (opts) => {
2023
+ const { resolveWorkerDevice } = await import('../lib/devices/worker-pick.js');
2024
+ let plan;
2025
+ try {
2026
+ plan = await resolveWorkerDevice({ platforms: csvList(opts.platform) });
2027
+ }
2028
+ catch (err) {
2029
+ // Fail loud with the resolver's own message. Never print a device name
2030
+ // we did not actually pick: a caller reading stdout would ship a tree to it.
2031
+ console.error(err instanceof Error ? err.message : String(err));
2032
+ process.exitCode = 1;
2033
+ return;
2034
+ }
2035
+ if (opts.json) {
2036
+ console.log(JSON.stringify(plan, null, 2));
2037
+ return;
2038
+ }
2039
+ // stdout is the name alone (`box="$(agents devices pick)"`); the human
2040
+ // detail goes to stderr so it never pollutes that capture.
2041
+ const detail = plan.candidates
2042
+ .map((c) => `${c.device}:${c.loadPercent === undefined ? '?' : `${Math.round(c.loadPercent)}%`}`)
2043
+ .join(' ');
2044
+ console.error(chalk.gray(`[agents] worker=${plan.device}${plan.isLocal ? ' (this machine)' : ''} candidates: ${detail}`));
2045
+ console.log(plan.device);
2046
+ });
2000
2047
  const harnessInvOpts = (opts) => ({
2001
2048
  agents: csvList(opts.agents),
2002
2049
  devices: csvList(opts.device ?? opts.devices),
@@ -2156,8 +2203,8 @@ email) into a single row. Use \`agents devices harnesses\` for the per-install v
2156
2203
  }
2157
2204
  });
2158
2205
  devicesCmd
2159
- .command('rm <name>')
2160
- .alias('remove')
2206
+ .command('remove <name>')
2207
+ .alias('rm')
2161
2208
  .description('Remove a device from the registry.')
2162
2209
  .action(async (name) => {
2163
2210
  const ok = await removeDevice(name);
@@ -7,9 +7,11 @@
7
7
  */
8
8
  import type { Command } from 'commander';
9
9
  import { AgentManager, AgentStatus, type TaskType } from '../lib/teams/agents.js';
10
+ import type { DispatchOptions } from '../lib/cloud/types.js';
10
11
  import { type TaskInfo } from '../lib/teams/api.js';
11
12
  import { type TeamRow } from './teams-picker.js';
12
13
  import { type TeamSpawner } from '../lib/session/db.js';
14
+ import type { AgentProcess } from '../lib/teams/agents.js';
13
15
  type TeamRegistry = Record<string, {
14
16
  created_at: string;
15
17
  description?: string;
@@ -106,6 +108,16 @@ export declare function staleRepoError(params: {
106
108
  * the teammate itself so we don't need the original --cloud CLI args.
107
109
  */
108
110
  export declare function wireCloudDispatcher(mgr: AgentManager): void;
111
+ export declare function cloudDispatchOptions(agent: Pick<AgentProcess, 'prompt' | 'agentType' | 'cloudRepo' | 'cloudBranch' | 'model'>): DispatchOptions;
112
+ /**
113
+ * Single-wave start used by `teams start` without --watch. startReady()
114
+ * terminalizes a placement/spawn/cloud/dependency failure to FAILED with
115
+ * evidence rather than leaving it PENDING, so a teammate that failed this wave
116
+ * appears in neither `launched` nor `still_pending` — it must be diffed against
117
+ * the pre-wave roster and reported explicitly, or the wave reads as a success.
118
+ * A wave that only produced failures sets a non-zero exit code.
119
+ */
120
+ export declare function runOneWave(mgr: AgentManager, team: string, json: boolean): Promise<void>;
109
121
  export declare function buildTeamRowsFromSnapshots(registry: TeamRegistry, agents: TeamListAgentSnapshot[],
110
122
  /** team name -> the session that spawned it (see teamSpawners). */
111
123
  spawners?: Map<string, TeamSpawner>): {