@phnx-labs/agents-cli 1.22.47 → 1.22.49

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 (249) hide show
  1. package/CHANGELOG.md +401 -17
  2. package/README.md +66 -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 +206 -32
  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.d.ts +21 -0
  14. package/dist/commands/daemon.js +147 -12
  15. package/dist/commands/exec.js +52 -15
  16. package/dist/commands/focus.d.ts +14 -0
  17. package/dist/commands/focus.js +48 -5
  18. package/dist/commands/go.d.ts +3 -0
  19. package/dist/commands/go.js +16 -3
  20. package/dist/commands/inspect.js +2 -2
  21. package/dist/commands/lease.d.ts +1 -1
  22. package/dist/commands/lease.js +4 -3
  23. package/dist/commands/mailboxes.js +4 -3
  24. package/dist/commands/menubar.js +11 -4
  25. package/dist/commands/projects.d.ts +16 -1
  26. package/dist/commands/projects.js +58 -64
  27. package/dist/commands/resume.js +1 -1
  28. package/dist/commands/route.js +4 -4
  29. package/dist/commands/routines.js +3 -2
  30. package/dist/commands/run-broadcast.d.ts +1 -1
  31. package/dist/commands/run-broadcast.js +1 -1
  32. package/dist/commands/sessions-picker.d.ts +22 -0
  33. package/dist/commands/sessions-picker.js +48 -9
  34. package/dist/commands/sessions-trace.js +1 -1
  35. package/dist/commands/sessions.js +1 -0
  36. package/dist/commands/setup-secrets.js +23 -0
  37. package/dist/commands/share.d.ts +20 -5
  38. package/dist/commands/share.js +152 -52
  39. package/dist/commands/ssh.js +54 -7
  40. package/dist/commands/traces.d.ts +2 -0
  41. package/dist/commands/traces.js +184 -0
  42. package/dist/commands/view.d.ts +1 -1
  43. package/dist/commands/view.js +17 -34
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +5 -0
  46. package/dist/lib/accounting/usage.d.ts +14 -3
  47. package/dist/lib/accounting/usage.js +64 -18
  48. package/dist/lib/agent-spec/agents.js +11 -9
  49. package/dist/lib/browser/drivers/ssh.d.ts +16 -2
  50. package/dist/lib/browser/drivers/ssh.js +36 -9
  51. package/dist/lib/browser/ipc.js +8 -3
  52. package/dist/lib/browser/profiles.d.ts +35 -101
  53. package/dist/lib/browser/profiles.js +130 -301
  54. package/dist/lib/browser/registry.d.ts +39 -0
  55. package/dist/lib/browser/registry.js +149 -0
  56. package/dist/lib/browser/remote-control.d.ts +8 -6
  57. package/dist/lib/browser/remote-control.js +8 -6
  58. package/dist/lib/browser/resolve-target.d.ts +68 -0
  59. package/dist/lib/browser/resolve-target.js +250 -0
  60. package/dist/lib/browser/runtime-state.d.ts +40 -16
  61. package/dist/lib/browser/runtime-state.js +92 -25
  62. package/dist/lib/browser/service.d.ts +28 -9
  63. package/dist/lib/browser/service.js +139 -62
  64. package/dist/lib/browser/task-index.d.ts +70 -0
  65. package/dist/lib/browser/task-index.js +180 -0
  66. package/dist/lib/byok-usage.js +2 -2
  67. package/dist/lib/claude-statusline.d.ts +29 -0
  68. package/dist/lib/claude-statusline.js +139 -0
  69. package/dist/lib/cloud/host.d.ts +1 -1
  70. package/dist/lib/cloud/host.js +1 -1
  71. package/dist/lib/cloud/rush.js +1 -1
  72. package/dist/lib/computer/computer-rpc.js +2 -2
  73. package/dist/lib/computer/download.d.ts +15 -15
  74. package/dist/lib/computer/download.js +35 -98
  75. package/dist/lib/computer/ssh-tunnel.d.ts +0 -3
  76. package/dist/lib/computer/ssh-tunnel.js +12 -22
  77. package/dist/lib/config-keys.d.ts +2 -8
  78. package/dist/lib/config-keys.js +2 -13
  79. package/dist/lib/crabbox/cli.d.ts +1 -1
  80. package/dist/lib/crabbox/cli.js +2 -2
  81. package/dist/lib/crabbox/lease.d.ts +9 -0
  82. package/dist/lib/crabbox/lease.js +70 -15
  83. package/dist/lib/crabbox/runtimes.js +1 -1
  84. package/dist/lib/daemon/account-state-daemon-service.d.ts +16 -0
  85. package/dist/lib/daemon/account-state-daemon-service.js +26 -0
  86. package/dist/lib/daemon/browser-ipc-service.d.ts +20 -0
  87. package/dist/lib/daemon/browser-ipc-service.js +46 -0
  88. package/dist/lib/daemon/daemon.d.ts +3 -0
  89. package/dist/lib/daemon/daemon.js +212 -444
  90. package/dist/lib/daemon/device-probe-service.d.ts +26 -0
  91. package/dist/lib/daemon/device-probe-service.js +47 -0
  92. package/dist/lib/daemon/keychain-reap-service.d.ts +17 -0
  93. package/dist/lib/daemon/keychain-reap-service.js +32 -0
  94. package/dist/lib/daemon/monitor-engine-service.d.ts +22 -0
  95. package/dist/lib/daemon/monitor-engine-service.js +29 -0
  96. package/dist/lib/daemon/secrets-broker-service.d.ts +20 -0
  97. package/dist/lib/daemon/secrets-broker-service.js +66 -0
  98. package/dist/lib/daemon/self-heal-service.d.ts +27 -0
  99. package/dist/lib/daemon/self-heal-service.js +48 -0
  100. package/dist/lib/daemon/service.d.ts +102 -0
  101. package/dist/lib/daemon/service.js +98 -0
  102. package/dist/lib/daemon/session-index-service.d.ts +22 -0
  103. package/dist/lib/daemon/session-index-service.js +40 -0
  104. package/dist/lib/daemon/state-dir-check-service.d.ts +43 -0
  105. package/dist/lib/daemon/state-dir-check-service.js +63 -0
  106. package/dist/lib/daemon/supervisor.d.ts +87 -0
  107. package/dist/lib/daemon/supervisor.js +298 -0
  108. package/dist/lib/daemon/watchdog-service.d.ts +19 -0
  109. package/dist/lib/daemon/watchdog-service.js +40 -0
  110. package/dist/lib/daemon-health.d.ts +15 -0
  111. package/dist/lib/daemon-health.js +29 -5
  112. package/dist/lib/daemon-services.d.ts +8 -1
  113. package/dist/lib/daemon-services.js +55 -0
  114. package/dist/lib/daemon-ticks.d.ts +13 -2
  115. package/dist/lib/daemon-ticks.js +20 -18
  116. package/dist/lib/device-config.d.ts +0 -2
  117. package/dist/lib/device-config.js +1 -23
  118. package/dist/lib/devices/registry.d.ts +1 -1
  119. package/dist/lib/devices/registry.js +1 -1
  120. package/dist/lib/devices/stats-cache.d.ts +20 -0
  121. package/dist/lib/devices/stats-cache.js +49 -5
  122. package/dist/lib/devices/worker-pick.d.ts +48 -0
  123. package/dist/lib/devices/worker-pick.js +113 -0
  124. package/dist/lib/exec.d.ts +67 -13
  125. package/dist/lib/exec.js +85 -29
  126. package/dist/lib/harness/adapters/cursor.js +8 -11
  127. package/dist/lib/helper-download.d.ts +108 -0
  128. package/dist/lib/helper-download.js +194 -0
  129. package/dist/lib/helper-versions.d.ts +52 -0
  130. package/dist/lib/helper-versions.js +58 -0
  131. package/dist/lib/hooks/cache.js +11 -0
  132. package/dist/lib/hooks/install.js +2 -2
  133. package/dist/lib/hosts/credentials.d.ts +1 -1
  134. package/dist/lib/hosts/credentials.js +1 -1
  135. package/dist/lib/hosts/dispatch.d.ts +7 -1
  136. package/dist/lib/hosts/dispatch.js +24 -5
  137. package/dist/lib/hosts/passthrough.d.ts +8 -15
  138. package/dist/lib/hosts/passthrough.js +19 -16
  139. package/dist/lib/hosts/providers/devices.d.ts +1 -1
  140. package/dist/lib/hosts/providers/devices.js +1 -1
  141. package/dist/lib/hosts/reconnect.d.ts +179 -21
  142. package/dist/lib/hosts/reconnect.js +266 -45
  143. package/dist/lib/installations/migrate.d.ts +4 -5
  144. package/dist/lib/installations/migrate.js +6 -7
  145. package/dist/lib/installations/shims.d.ts +1 -1
  146. package/dist/lib/installations/shims.js +23 -13
  147. package/dist/lib/installations/versions.js +25 -2
  148. package/dist/lib/linear-autoclose.d.ts +1 -1
  149. package/dist/lib/linear-autoclose.js +1 -1
  150. package/dist/lib/loop.d.ts +2 -2
  151. package/dist/lib/loop.js +1 -1
  152. package/dist/lib/menubar/download-menubar.d.ts +47 -0
  153. package/dist/lib/menubar/download-menubar.js +60 -0
  154. package/dist/lib/menubar/install-menubar.d.ts +31 -7
  155. package/dist/lib/menubar/install-menubar.js +79 -21
  156. package/dist/lib/menubar/notify-desktop.d.ts +3 -3
  157. package/dist/lib/menubar/notify-desktop.js +6 -6
  158. package/dist/lib/model-tiers.d.ts +1 -1
  159. package/dist/lib/project-probe.d.ts +1 -1
  160. package/dist/lib/project-probe.js +1 -1
  161. package/dist/lib/project-pull.d.ts +1 -1
  162. package/dist/lib/project-pull.js +2 -2
  163. package/dist/lib/projects.d.ts +1 -1
  164. package/dist/lib/projects.js +1 -1
  165. package/dist/lib/sandbox.js +6 -7
  166. package/dist/lib/secrets/download-keychain.d.ts +47 -0
  167. package/dist/lib/secrets/download-keychain.js +70 -0
  168. package/dist/lib/secrets/install-helper.d.ts +20 -1
  169. package/dist/lib/secrets/install-helper.js +44 -3
  170. package/dist/lib/session/active.js +17 -1
  171. package/dist/lib/session/db.d.ts +11 -1
  172. package/dist/lib/session/db.js +138 -6
  173. package/dist/lib/session/discover.d.ts +21 -1
  174. package/dist/lib/session/discover.js +33 -5
  175. package/dist/lib/session/highlights.d.ts +49 -1
  176. package/dist/lib/session/highlights.js +95 -0
  177. package/dist/lib/session/host-link.d.ts +16 -2
  178. package/dist/lib/session/host-link.js +7 -1
  179. package/dist/lib/session/parse.js +33 -1
  180. package/dist/lib/session/remote/remote-list.d.ts +9 -0
  181. package/dist/lib/session/remote/remote-list.js +19 -2
  182. package/dist/lib/session/remote/watch.js +11 -2
  183. package/dist/lib/session/session-cache.d.ts +53 -0
  184. package/dist/lib/session/session-cache.js +88 -0
  185. package/dist/lib/session/state.js +1 -1
  186. package/dist/lib/session/tool-calls.d.ts +2 -0
  187. package/dist/lib/session/tool-calls.js +1 -1
  188. package/dist/lib/session/trajectory-html.d.ts +5 -1
  189. package/dist/lib/session/trajectory-html.js +42 -22
  190. package/dist/lib/session/trajectory-text.js +9 -2
  191. package/dist/lib/session/trajectory.js +53 -4
  192. package/dist/lib/session/types.d.ts +15 -0
  193. package/dist/lib/sha256-asset.d.ts +26 -0
  194. package/dist/lib/sha256-asset.js +41 -0
  195. package/dist/lib/share/backend.d.ts +95 -0
  196. package/dist/lib/share/backend.js +139 -0
  197. package/dist/lib/share/delete.d.ts +6 -2
  198. package/dist/lib/share/delete.js +8 -9
  199. package/dist/lib/share/html.d.ts +22 -0
  200. package/dist/lib/share/html.js +88 -0
  201. package/dist/lib/share/provision.d.ts +18 -4
  202. package/dist/lib/share/provision.js +38 -4
  203. package/dist/lib/share/publish.d.ts +39 -15
  204. package/dist/lib/share/publish.js +55 -26
  205. package/dist/lib/share/worker-template.js +171 -11
  206. package/dist/lib/sqlite.js +16 -3
  207. package/dist/lib/ssh-exec.d.ts +65 -0
  208. package/dist/lib/ssh-exec.js +120 -4
  209. package/dist/lib/startup/command-registry.js +1 -1
  210. package/dist/lib/startup/dev-build.js +3 -3
  211. package/dist/lib/state.d.ts +1 -1
  212. package/dist/lib/state.js +7 -3
  213. package/dist/lib/subagents-registry.js +1 -1
  214. package/dist/lib/terminal/index.d.ts +1 -1
  215. package/dist/lib/terminal/types.d.ts +1 -1
  216. package/dist/lib/terminal/types.js +1 -1
  217. package/dist/lib/tmux/orphan-reap.js +1 -1
  218. package/dist/lib/tmux/session.js +31 -0
  219. package/dist/lib/traces/backend.d.ts +29 -0
  220. package/dist/lib/traces/backend.js +46 -0
  221. package/dist/lib/traces/classify.d.ts +52 -0
  222. package/dist/lib/traces/classify.js +72 -0
  223. package/dist/lib/traces/config.d.ts +10 -0
  224. package/dist/lib/traces/config.js +2 -0
  225. package/dist/lib/traces/provision.d.ts +19 -0
  226. package/dist/lib/traces/provision.js +30 -0
  227. package/dist/lib/traces/sync.d.ts +150 -0
  228. package/dist/lib/traces/sync.js +447 -0
  229. package/dist/lib/traces/worker-template.d.ts +4 -0
  230. package/dist/lib/traces/worker-template.js +159 -0
  231. package/dist/lib/types.d.ts +18 -19
  232. package/dist/lib/types.js +14 -0
  233. package/dist/lib/usage-refresh.d.ts +1 -1
  234. package/dist/lib/usage-refresh.js +11 -8
  235. package/dist/lib/workflows.d.ts +1 -1
  236. package/package.json +4 -6
  237. package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
  238. package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +0 -24
  239. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  240. package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
  241. package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +0 -128
  242. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  243. package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +0 -26
  244. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  245. package/dist/lib/secrets/Agents CLI.app/Contents/Resources/AppIcon.icns +0 -0
  246. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +0 -135
  247. package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
  248. package/dist/lib/usage-fleet.d.ts +0 -32
  249. package/dist/lib/usage-fleet.js +0 -125
@@ -1,8 +1,21 @@
1
1
  // The Cloudflare Worker that fronts the R2 share bucket.
2
2
  //
3
3
  // One tiny Worker does both sides:
4
- // - PUT /<username>/<slug> — bearer-gated (WRITE_TOKEN secret); writes the body
5
- // to R2 via the BUCKET binding, storing an optional expires-at value plus
4
+ // - PUT /<username>/<slug> — bearer-gated by TWO principals (not a fallback):
5
+ // 1. Static WRITE_TOKEN (BYO Cloudflare) checked first when the presented
6
+ // bearer equals env.WRITE_TOKEN. owner = env.SHARE_NAMESPACE or the
7
+ // path's first segment.
8
+ // 2. Phoenix bearer — otherwise GET ${env.PHOENIX_ID_BASE}/api/v1/auth/me
9
+ // with that bearer → {userId,email}; 401 if absent/invalid.
10
+ // customMetadata.owner = userId (stable). The path's first segment MUST
11
+ // equal handleFromEmail(email) (the public handle, e.g. muqsitnawaz),
12
+ // so one user cannot write another's prefix (403 namespace mismatch).
13
+ // A __handles/<handle> claim binds the handle to the first userId that
14
+ // writes it; a different userId gets 409 handle taken.
15
+ // A managed deployment sets PHOENIX_ID_BASE; BYO sets WRITE_TOKEN; the
16
+ // platform endpoint may set both. Fail loud (401) when neither authenticates.
17
+ // Writes the body to R2 via the BUCKET binding, storing visibility
18
+ // (public|unlisted; org → 400 in P1), owner, an optional expires-at, plus
6
19
  // provenance (agent/session/host/repo/date), a label, and any `--meta`
7
20
  // entries in object metadata. Overwriting an existing slug first copies the
8
21
  // current object to <slug>/rev-<ts>-<rand> (revision history) unless
@@ -39,6 +52,10 @@
39
52
  export function renderWorkerScript() {
40
53
  return `// GENERATED by agents-cli agents share setup — do not edit here; edit
41
54
  // src/lib/share/worker-template.ts and re-run setup.
55
+ export const hooks = {
56
+ verifyPhoenixToken: defaultVerifyPhoenixToken,
57
+ };
58
+
42
59
  export default {
43
60
  async fetch(request, env) {
44
61
  const url = new URL(request.url);
@@ -50,15 +67,30 @@ export default {
50
67
  });
51
68
  }
52
69
 
70
+ const firstSeg = path.split('/').filter(Boolean)[0] || '';
71
+ if ((request.method === 'GET' || request.method === 'HEAD') && firstSeg.startsWith('__')) {
72
+ return new Response('not found', { status: 404, headers: { 'content-type': 'text/plain' } });
73
+ }
74
+
53
75
  if (request.method === 'PUT') {
54
- const presented = (request.headers.get('authorization') || '').replace(/^Bearer\\s+/i, '');
55
- if (!env.WRITE_TOKEN || !safeEqual(presented, env.WRITE_TOKEN)) {
56
- return json({ error: 'unauthorized' }, 401);
76
+ const auth = await authorizeWrite(request, env);
77
+ if (auth.error) return auth.error;
78
+ const vis = normalizeVisibility(request.headers.get('x-share-visibility'));
79
+ if (vis.error) return vis.error;
80
+ const visibility = vis.value;
81
+ const segments = path.split('/').filter(Boolean);
82
+ if (auth.kind === 'phoenix') {
83
+ const expected = phoenixHandle(auth);
84
+ if (!expected || segments[0] !== expected) {
85
+ return json({ error: 'namespace mismatch', owner: expected }, 403);
86
+ }
87
+ const claimed = await claimHandle(env.BUCKET, expected, auth.owner);
88
+ if (claimed.error) return claimed.error;
57
89
  }
58
90
  const expiresAt = request.headers.get('x-share-expires-at') || '';
59
91
  // 'unlisted' hides the page from the public gallery + JSON listing while
60
92
  // keeping the direct URL world-readable (capability URL, not secret).
61
- const visibility = (request.headers.get('x-share-visibility') || '').toLowerCase();
93
+ // GET also sends X-Robots-Tag: noindex for unlisted objects.
62
94
  const contentType = request.headers.get('content-type') || 'text/html; charset=utf-8';
63
95
  // Provenance (RUSH-2683): captured client-side from the exec env/git/clock,
64
96
  // never invented here — a header is simply absent when the CLI had nothing
@@ -93,7 +125,12 @@ export default {
93
125
  delete customMetadata[reservedKey];
94
126
  }
95
127
  if (expiresAt) customMetadata['expires-at'] = expiresAt;
96
- if (visibility === 'unlisted') customMetadata['visibility'] = 'unlisted';
128
+ customMetadata['visibility'] = visibility;
129
+ const owner =
130
+ auth.kind === 'phoenix'
131
+ ? auth.owner
132
+ : (env.SHARE_NAMESPACE || segments[0] || 'byo');
133
+ if (owner) customMetadata['owner'] = owner;
97
134
  if (agent) customMetadata['agent'] = agent;
98
135
  if (session) customMetadata['session'] = session;
99
136
  if (host) customMetadata['host'] = host;
@@ -129,7 +166,7 @@ export default {
129
166
  httpMetadata: { contentType },
130
167
  customMetadata,
131
168
  });
132
- return json({ ok: true, url: url.origin + '/' + path, expiresAt: expiresAt || null, unlisted: visibility === 'unlisted' }, 200);
169
+ return json({ ok: true, url: url.origin + '/' + path, expiresAt: expiresAt || null, unlisted: visibility === 'unlisted', visibility }, 200);
133
170
  }
134
171
 
135
172
  if (request.method === 'GET' || request.method === 'HEAD') {
@@ -174,12 +211,32 @@ export default {
174
211
  headers.set('etag', obj.httpEtag);
175
212
  if (!headers.has('content-type')) headers.set('content-type', 'text/html; charset=utf-8');
176
213
  headers.set('cache-control', 'public, max-age=60');
214
+ if (obj.customMetadata && obj.customMetadata.visibility === 'unlisted') {
215
+ headers.set('X-Robots-Tag', 'noindex');
216
+ }
177
217
  return new Response(request.method === 'HEAD' ? null : obj.body, { status: 200, headers });
178
218
  }
179
219
 
180
220
  if (request.method === 'DELETE') {
181
- const presented = (request.headers.get('authorization') || '').replace(/^Bearer\\s+/i, '');
182
- if (!env.WRITE_TOKEN || !safeEqual(presented, env.WRITE_TOKEN)) return json({ error: 'unauthorized' }, 401);
221
+ const auth = await authorizeWrite(request, env);
222
+ if (auth.error) return auth.error;
223
+ if (auth.kind === 'phoenix') {
224
+ const handle = phoenixHandle(auth);
225
+ const uid = sanitizeNamespace(auth.owner);
226
+ const delSegments = path.split('/').filter(Boolean);
227
+ // Handle is the public namespace; userId prefix is still deletable so
228
+ // P1 UUID-namespaced objects the same account published can be taken down.
229
+ // A colliding local-part (same handle, different userId) must not be
230
+ // able to DELETE the claimant's pages — consult the claim the same way PUT does.
231
+ if (delSegments[0] && delSegments[0] === uid) {
232
+ // own leftover UUID prefix
233
+ } else if (delSegments[0] && delSegments[0] === handle) {
234
+ const owned = await assertHandleOwner(env.BUCKET, handle, auth.owner);
235
+ if (owned.error) return owned.error;
236
+ } else {
237
+ return json({ error: 'namespace mismatch', owner: handle || uid }, 403);
238
+ }
239
+ }
183
240
  await env.BUCKET.delete(path);
184
241
  return json({ ok: true, deleted: path }, 200);
185
242
  }
@@ -347,7 +404,7 @@ async function renderRevisions(bucket, origin, key, method) {
347
404
  // before it ever reaches this Worker; see RESERVED_META_KEYS in publish.ts).
348
405
  // One list, reused both to strip a same-named --meta collision on write and
349
406
  // to split arbitrary --meta entries back out on read.
350
- var RESERVED_METADATA_KEYS = ['expires-at', 'visibility', 'agent', 'session', 'host', 'repo', 'date', 'label', 'label-source'];
407
+ var RESERVED_METADATA_KEYS = ['expires-at', 'visibility', 'owner', 'agent', 'session', 'host', 'repo', 'date', 'label', 'label-source'];
351
408
 
352
409
  // Everything in customMetadata that ISN'T one of the reserved provenance/label
353
410
  // keys above — i.e. the caller's own \`--meta key=value\` entries. Surfaced on
@@ -383,5 +440,108 @@ function safeEqual(a, b) {
383
440
  for (let i = 0; i < la; i++) out |= a.charCodeAt(i) ^ b.charCodeAt(i % lb || 0);
384
441
  return out === 0 && la === lb;
385
442
  }
443
+
444
+ // URL-safety, not collision-resistance. Two values that differ only in
445
+ // case/punctuation share a prefix.
446
+ function sanitizeNamespace(s) {
447
+ return String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
448
+ }
449
+
450
+ // Public handle: email local-part, plus-tag stripped. Must match CLI handleFromEmail.
451
+ function handleFromEmail(email) {
452
+ if (!email) return '';
453
+ const local = String(email).split('@')[0] || '';
454
+ const beforePlus = local.split('+')[0] || local;
455
+ return sanitizeNamespace(beforePlus);
456
+ }
457
+
458
+ function phoenixHandle(auth) {
459
+ return handleFromEmail(auth.email) || sanitizeNamespace(auth.owner);
460
+ }
461
+
462
+ // First writer of a handle owns it. Later PUTs from the same userId are fine;
463
+ // a different userId whose email local-part collides gets 409, not a silent overwrite.
464
+ async function assertHandleOwner(bucket, handle, userId) {
465
+ // Pages under the handle already stamp customMetadata.owner = userId.
466
+ // Treat that as the source of truth so a colliding local-part cannot
467
+ // PUT/DELETE another account's objects even if the claim object is missing.
468
+ const list = await bucket.list({ prefix: handle + '/', include: ['customMetadata'] });
469
+ for (const o of list.objects || []) {
470
+ const owner = o.customMetadata && o.customMetadata.owner;
471
+ if (owner && owner !== userId) {
472
+ return { error: json({ error: 'handle taken', handle: handle }, 409) };
473
+ }
474
+ }
475
+ const key = '__handles/' + handle;
476
+ const existing = await bucket.get(key);
477
+ if (!existing) return {};
478
+ const claimed = existing.customMetadata && existing.customMetadata.userId;
479
+ if (claimed && claimed !== userId) {
480
+ return { error: json({ error: 'handle taken', handle: handle }, 409) };
481
+ }
482
+ return {};
483
+ }
484
+
485
+ async function claimHandle(bucket, handle, userId) {
486
+ const owned = await assertHandleOwner(bucket, handle, userId);
487
+ if (owned.error) return owned;
488
+ const key = '__handles/' + handle;
489
+ // Write (or rewrite) so a same-user republish resets object Age against the
490
+ // bucket's 366-day lifecycle — otherwise the claim can expire while pages stay live.
491
+ await bucket.put(key, JSON.stringify({ userId: userId }), {
492
+ httpMetadata: { contentType: 'application/json' },
493
+ customMetadata: { userId: userId, visibility: 'unlisted' },
494
+ });
495
+ return {};
496
+ }
497
+
498
+ // P1 visibility: public | unlisted. 'org' (and anything else) is 400 — org is Phase 2.
499
+ function normalizeVisibility(raw) {
500
+ const v = (raw || '').trim().toLowerCase();
501
+ if (!v || v === 'public') return { value: 'public' };
502
+ if (v === 'unlisted') return { value: 'unlisted' };
503
+ if (v === 'org') return { error: json({ error: 'visibility org is not supported yet' }, 400) };
504
+ return { error: json({ error: 'visibility must be public or unlisted' }, 400) };
505
+ }
506
+
507
+ async function defaultVerifyPhoenixToken(request, env) {
508
+ const presented = (request.headers.get('authorization') || '').replace(/^Bearer\\s+/i, '');
509
+ if (!presented) return null;
510
+ const base = typeof env.PHOENIX_ID_BASE === 'string' ? env.PHOENIX_ID_BASE.replace(/\\/+$/, '') : '';
511
+ if (!base) return null;
512
+ let res;
513
+ try {
514
+ res = await fetch(base + '/api/v1/auth/me', {
515
+ method: 'GET',
516
+ headers: { Authorization: 'Bearer ' + presented },
517
+ });
518
+ } catch {
519
+ return null;
520
+ }
521
+ if (!res.ok) return null;
522
+ let body;
523
+ try {
524
+ body = await res.json();
525
+ } catch {
526
+ return null;
527
+ }
528
+ if (!body || typeof body.userId !== 'string' || !body.userId) return null;
529
+ return { userId: body.userId, email: typeof body.email === 'string' ? body.email : '' };
530
+ }
531
+
532
+ // Two legitimate principals: WRITE_TOKEN equality first (admin/BYO), otherwise
533
+ // the bearer is a Phoenix token and we verify it. 401 when neither authenticates.
534
+ async function authorizeWrite(request, env) {
535
+ const presented = (request.headers.get('authorization') || '').replace(/^Bearer\\s+/i, '');
536
+ if (!presented) return { error: json({ error: 'unauthorized' }, 401) };
537
+ if (env.WRITE_TOKEN && safeEqual(presented, env.WRITE_TOKEN)) {
538
+ return { kind: 'byo', owner: env.SHARE_NAMESPACE || 'byo' };
539
+ }
540
+ const claims = await hooks.verifyPhoenixToken(request, env);
541
+ if (claims && typeof claims.userId === 'string' && claims.userId) {
542
+ return { kind: 'phoenix', owner: claims.userId, email: typeof claims.email === 'string' ? claims.email : '' };
543
+ }
544
+ return { error: json({ error: 'unauthorized' }, 401) };
545
+ }
386
546
  `;
387
547
  }
@@ -41,10 +41,23 @@ function loadNodeSqlite() {
41
41
  process.emitWarning = original;
42
42
  }
43
43
  }
44
- // Keep Node on createRequire() so Vitest doesn't try to prebundle the built-in
45
- // sqlite module as a userland package during test collection.
44
+ // Keep BOTH runtimes on createRequire() so Vitest doesn't try to prebundle the
45
+ // built-in sqlite module as a userland package during test collection.
46
+ //
47
+ // The Bun arm used to be `await import('bun:sqlite' as string)`, which made this
48
+ // a TOP-LEVEL AWAIT. esbuild cannot lower top-level await to CJS, so every test
49
+ // that spawns a subprocess through `tsx` (CJS mode) died at transform time with
50
+ // `Top-level await is currently not supported with the "cjs" output format` --
51
+ // 49 failures across 7 files, none of which touch sqlite. `require` is
52
+ // synchronous, so the await disappears and with it the whole failure class.
53
+ //
54
+ // The specifier is held in a variable, not written inline: a literal
55
+ // `require('bun:sqlite')` is statically analyzable, so bundlers and Vitest's
56
+ // collector try to resolve a module that does not exist off-Bun. That
57
+ // indirection is what the old `as string` cast was doing for the dynamic import.
58
+ const BUN_SQLITE = 'bun:sqlite';
46
59
  const sqliteMod = isBun
47
- ? await import('bun:sqlite')
60
+ ? require(BUN_SQLITE)
48
61
  : loadNodeSqlite();
49
62
  // bun:sqlite exports `Database`; node:sqlite exports `DatabaseSync`.
50
63
  const NativeDatabase = sqliteMod.Database
@@ -13,6 +13,14 @@
13
13
  * smuggled in as part of a remote command, and `sshExec` additionally rejects a
14
14
  * leading `-` so it can never be parsed as an ssh argv flag.
15
15
  */
16
+ /**
17
+ * ssh's own connection-layer failure code — the transport dropped or never came
18
+ * up, as opposed to the remote command choosing an exit status. Defined here,
19
+ * in the layer that owns the ssh invocation, and re-exported by
20
+ * `lib/hosts/reconnect.ts` as `SSH_CONN_FAILURE` so there is one constant for
21
+ * the concept rather than two that can drift apart.
22
+ */
23
+ export declare const SSH_CONN_FAILURE_CODE = 255;
16
24
  export declare const SSH_TARGET_RE: RegExp;
17
25
  export declare function assertValidSshTarget(host: string): void;
18
26
  /** POSIX single-quote a string for safe interpolation into a remote shell command. */
@@ -156,11 +164,68 @@ export interface SshStreamOptions {
156
164
  /** Additional OpenSSH argv placed before the target (for example `-i <path>`). */
157
165
  extraSshArgs?: string[];
158
166
  }
167
+ /**
168
+ * The DEC private modes a full-screen remote app turns ON and, when it exits
169
+ * cleanly, turns back off itself. A remote agent TUI killed by a dropped link
170
+ * never gets to, so they stay enabled on the LOCAL terminal after ssh is gone:
171
+ * focus reporting (1004) and the mode/colour-scheme reports (996/997) then make
172
+ * the terminal emit answerback sequences at a shell that is not expecting them,
173
+ * which is the `^[[?997;1n ^[[I ^[[O` litter seen after a drop (RUSH-3125). Also
174
+ * resets bracketed paste (2004), the alternate screen (1049), mouse tracking
175
+ * (1000/1002/1003/1006), and re-shows the cursor (25) — every one of which a TUI
176
+ * leaves armed the same way.
177
+ */
178
+ export declare const TERMINAL_MODE_RESET: string;
179
+ /**
180
+ * Put the local terminal back the way ssh found it.
181
+ *
182
+ * Two independent kinds of state survive a hard ssh death, and BOTH have to be
183
+ * undone or the next thing the user sees is corrupted:
184
+ *
185
+ * - **termios** (kernel side): `-tt` puts the tty in raw mode, so a killed ssh
186
+ * leaves it with echo and line-editing off. `saved` is the `stty -g` snapshot
187
+ * taken before the spawn; restoring it is exact, unlike guessing at `sane`.
188
+ * - **DEC private modes** (terminal side): see {@link TERMINAL_MODE_RESET}.
189
+ *
190
+ * Then drain whatever the terminal already answered back into the input buffer.
191
+ * Without the drain those bytes are not merely cosmetic — they are still queued
192
+ * on the tty, so the NEXT attach hands them straight to the agent as if the user
193
+ * had typed them.
194
+ *
195
+ * Best-effort by construction: this runs while recovering from a failure, so a
196
+ * missing `stty`, a non-TTY stdin, or a closed stream must never turn a
197
+ * recoverable drop into a thrown error.
198
+ */
199
+ export declare function restoreLocalTerminal(saved: string | undefined, opts: {
200
+ drainStdin: boolean;
201
+ }): void;
202
+ /** `stty -g` snapshot of the local tty, or undefined when there is nothing to snapshot. */
203
+ export declare function saveLocalTerminal(): string | undefined;
159
204
  /**
160
205
  * Foreground counterpart to `sshExec`: run `remoteCmd` on `target` with the
161
206
  * local stdio wired straight through (`stdio: 'inherit'`), so output streams as
162
207
  * it is produced and — with `tty` — keystrokes reach a remote picker. Blocks
163
208
  * until the remote command exits and returns its exit code (255 is ssh's own
164
209
  * connection-layer failure; any other non-zero is the remote command's code).
210
+ *
211
+ * On a `tty` stream the local terminal state is snapshotted before the spawn and
212
+ * restored after it. ssh restores termios itself when it exits cleanly, so this
213
+ * is for the case that matters here: the link dying under a full-screen agent
214
+ * TUI, which leaves the tty raw and the TUI's DEC modes armed. Doing it HERE
215
+ * rather than in the reconnect loop means every caller that opens an interactive
216
+ * remote stream is covered, not just the one that noticed (RUSH-3125).
217
+ *
218
+ * **The stdin drain is gated on an ABNORMAL exit, and the distinction is not
219
+ * cosmetic.** Resetting termios and the DEC modes is idempotent — on a clean
220
+ * exit ssh and the remote TUI have already done it, so re-doing it changes
221
+ * nothing. Draining stdin is destructive: it discards whatever the user has
222
+ * typed ahead. On a clean exit those bytes are legitimate type-ahead the
223
+ * resuming shell should receive, and eating them would be a new bug in every
224
+ * caller of this function (`runInteractiveOnHost`, the remote-tmux attach in
225
+ * commands/go.ts, the remote secrets browse) rather than a fix. Only an
226
+ * abnormal exit — ssh killed by a signal (`status === null`) or its own
227
+ * connection-layer failure (255) — produces the answerback storm the drain
228
+ * exists to clear, because only then did the TUI die without sending its own
229
+ * mode resets.
165
230
  */
166
231
  export declare function sshStream(target: string, remoteCmd: string, opts?: SshStreamOptions): number;
@@ -18,6 +18,14 @@ import { getCacheDir } from './state.js';
18
18
  * smuggled in as part of a remote command, and `sshExec` additionally rejects a
19
19
  * leading `-` so it can never be parsed as an ssh argv flag.
20
20
  */
21
+ /**
22
+ * ssh's own connection-layer failure code — the transport dropped or never came
23
+ * up, as opposed to the remote command choosing an exit status. Defined here,
24
+ * in the layer that owns the ssh invocation, and re-exported by
25
+ * `lib/hosts/reconnect.ts` as `SSH_CONN_FAILURE` so there is one constant for
26
+ * the concept rather than two that can drift apart.
27
+ */
28
+ export const SSH_CONN_FAILURE_CODE = 255;
21
29
  export const SSH_TARGET_RE = /^[a-zA-Z0-9._-]+(@[a-zA-Z0-9._-]+)?$/;
22
30
  export function assertValidSshTarget(host) {
23
31
  if (host.startsWith('-') || !SSH_TARGET_RE.test(host)) {
@@ -314,20 +322,128 @@ export function sshExecRawStream(target, remoteCmd, opts) {
314
322
  export function sshReachable(target, timeoutMs = 10000) {
315
323
  return sshExec(target, 'true', { timeoutMs, multiplex: true }).code === 0;
316
324
  }
325
+ /**
326
+ * The DEC private modes a full-screen remote app turns ON and, when it exits
327
+ * cleanly, turns back off itself. A remote agent TUI killed by a dropped link
328
+ * never gets to, so they stay enabled on the LOCAL terminal after ssh is gone:
329
+ * focus reporting (1004) and the mode/colour-scheme reports (996/997) then make
330
+ * the terminal emit answerback sequences at a shell that is not expecting them,
331
+ * which is the `^[[?997;1n ^[[I ^[[O` litter seen after a drop (RUSH-3125). Also
332
+ * resets bracketed paste (2004), the alternate screen (1049), mouse tracking
333
+ * (1000/1002/1003/1006), and re-shows the cursor (25) — every one of which a TUI
334
+ * leaves armed the same way.
335
+ */
336
+ export const TERMINAL_MODE_RESET = '\x1b[?1004l\x1b[?996l\x1b[?997l\x1b[?2004l\x1b[?1049l'
337
+ + '\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?25h';
338
+ /**
339
+ * Put the local terminal back the way ssh found it.
340
+ *
341
+ * Two independent kinds of state survive a hard ssh death, and BOTH have to be
342
+ * undone or the next thing the user sees is corrupted:
343
+ *
344
+ * - **termios** (kernel side): `-tt` puts the tty in raw mode, so a killed ssh
345
+ * leaves it with echo and line-editing off. `saved` is the `stty -g` snapshot
346
+ * taken before the spawn; restoring it is exact, unlike guessing at `sane`.
347
+ * - **DEC private modes** (terminal side): see {@link TERMINAL_MODE_RESET}.
348
+ *
349
+ * Then drain whatever the terminal already answered back into the input buffer.
350
+ * Without the drain those bytes are not merely cosmetic — they are still queued
351
+ * on the tty, so the NEXT attach hands them straight to the agent as if the user
352
+ * had typed them.
353
+ *
354
+ * Best-effort by construction: this runs while recovering from a failure, so a
355
+ * missing `stty`, a non-TTY stdin, or a closed stream must never turn a
356
+ * recoverable drop into a thrown error.
357
+ */
358
+ export function restoreLocalTerminal(saved, opts) {
359
+ try {
360
+ if (saved)
361
+ spawnSync('stty', [saved], { stdio: ['inherit', 'ignore', 'ignore'] });
362
+ }
363
+ catch { /* no stty, or stdin is not a tty — nothing to restore */ }
364
+ try {
365
+ if (process.stdout.isTTY)
366
+ process.stdout.write(TERMINAL_MODE_RESET);
367
+ }
368
+ catch { /* stream closed */ }
369
+ try {
370
+ if (process.stdin.isTTY)
371
+ process.stdin.setRawMode?.(false);
372
+ }
373
+ catch { /* stdin not controllable in this context */ }
374
+ // The DRAIN is the one destructive step here, so it is opt-in per exit. See
375
+ // {@link sshStream} for why it must not run on a clean exit.
376
+ if (!opts.drainStdin)
377
+ return;
378
+ try {
379
+ // read() on a paused non-flowing stdin returns the buffered bytes and
380
+ // discards them; the loop clears a burst rather than one chunk.
381
+ if (process.stdin.isTTY) {
382
+ while (process.stdin.read() !== null) { /* discard */ }
383
+ }
384
+ }
385
+ catch { /* stdin not readable in this context */ }
386
+ }
387
+ /** `stty -g` snapshot of the local tty, or undefined when there is nothing to snapshot. */
388
+ export function saveLocalTerminal() {
389
+ if (!process.stdin.isTTY)
390
+ return undefined;
391
+ try {
392
+ const r = spawnSync('stty', ['-g'], { stdio: ['inherit', 'pipe', 'ignore'], encoding: 'utf-8' });
393
+ const out = r.status === 0 ? r.stdout?.trim() : '';
394
+ return out || undefined;
395
+ }
396
+ catch {
397
+ return undefined;
398
+ }
399
+ }
317
400
  /**
318
401
  * Foreground counterpart to `sshExec`: run `remoteCmd` on `target` with the
319
402
  * local stdio wired straight through (`stdio: 'inherit'`), so output streams as
320
403
  * it is produced and — with `tty` — keystrokes reach a remote picker. Blocks
321
404
  * until the remote command exits and returns its exit code (255 is ssh's own
322
405
  * connection-layer failure; any other non-zero is the remote command's code).
406
+ *
407
+ * On a `tty` stream the local terminal state is snapshotted before the spawn and
408
+ * restored after it. ssh restores termios itself when it exits cleanly, so this
409
+ * is for the case that matters here: the link dying under a full-screen agent
410
+ * TUI, which leaves the tty raw and the TUI's DEC modes armed. Doing it HERE
411
+ * rather than in the reconnect loop means every caller that opens an interactive
412
+ * remote stream is covered, not just the one that noticed (RUSH-3125).
413
+ *
414
+ * **The stdin drain is gated on an ABNORMAL exit, and the distinction is not
415
+ * cosmetic.** Resetting termios and the DEC modes is idempotent — on a clean
416
+ * exit ssh and the remote TUI have already done it, so re-doing it changes
417
+ * nothing. Draining stdin is destructive: it discards whatever the user has
418
+ * typed ahead. On a clean exit those bytes are legitimate type-ahead the
419
+ * resuming shell should receive, and eating them would be a new bug in every
420
+ * caller of this function (`runInteractiveOnHost`, the remote-tmux attach in
421
+ * commands/go.ts, the remote secrets browse) rather than a fix. Only an
422
+ * abnormal exit — ssh killed by a signal (`status === null`) or its own
423
+ * connection-layer failure (255) — produces the answerback storm the drain
424
+ * exists to clear, because only then did the TUI die without sending its own
425
+ * mode resets.
323
426
  */
324
427
  export function sshStream(target, remoteCmd, opts = {}) {
325
428
  assertValidSshTarget(target);
326
429
  const mux = opts.multiplex === false ? [] : controlOpts();
327
430
  const tty = opts.tty ? ['-tt'] : [];
328
431
  const args = [...sshConnectOpts(mux, opts.hostKeyOpts), ...(opts.extraSshArgs ?? []), ...tty, target, remoteCmd];
329
- const res = spawnSync('ssh', args, { stdio: 'inherit' });
330
- if (typeof res.status === 'number')
331
- return res.status;
332
- return 255; // spawn error / signal treat as a connection-layer failure
432
+ const saved = opts.tty ? saveLocalTerminal() : undefined;
433
+ let abnormal = true; // a throw before/inside the spawn is abnormal by definition
434
+ try {
435
+ const res = spawnSync('ssh', args, { stdio: 'inherit' });
436
+ const code = typeof res.status === 'number' ? res.status : 255;
437
+ // Killed by a signal (no numeric status) or ssh's own connection-layer
438
+ // failure — the two shapes in which the remote TUI never got to reset the
439
+ // terminal. Any other code is ssh exiting normally with the remote's status.
440
+ abnormal = res.status === null || code === SSH_CONN_FAILURE_CODE;
441
+ return code;
442
+ }
443
+ finally {
444
+ // `finally`, because the abnormal exits are precisely the ones that leave
445
+ // the terminal wrecked — but the drain within it is gated (see the doc).
446
+ if (opts.tty)
447
+ restoreLocalTerminal(saved, { drainStdin: abnormal });
448
+ }
333
449
  }
@@ -10,7 +10,7 @@ const LOADED_COMMAND_NAMES = [
10
10
  'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade', 'sessions',
11
11
  'teams', 'cloud', 'message', 'send', 'notify', 'feed',
12
12
  'mailboxes', 'mailbox', 'artifacts', 'webhooks',
13
- 'humans', 'daemon',
13
+ 'humans', 'daemon', 'traces',
14
14
  ];
15
15
  const INLINE_COMMAND_NAMES = [
16
16
  'perms', 'exec', 'jobs', 'cron', 'check', 'resources', 'hq', '_internal',
@@ -22,12 +22,12 @@ import * as path from 'path';
22
22
  * looking for `.git`.
23
23
  *
24
24
  * That package root does not always hold `.git` itself, though — this repo is a
25
- * monorepo where the package lives at `apps/cli` and `.git` sits one level
25
+ * monorepo where the package lives at `cli` and `.git` sits one level
26
26
  * higher, at the true repo root. `.git` is therefore searched for in a SMALL,
27
27
  * bounded set of ancestors above the package root (see
28
28
  * `DEV_BUILD_GIT_ANCESTOR_DEPTH`), not just the package root itself — a source
29
- * checkout run via tsx/ts-node from `apps/cli/src/` or built to
30
- * `apps/cli/dist/` must still be recognized. The bound keeps this well short of
29
+ * checkout run via tsx/ts-node from `cli/src/` or built to
30
+ * `cli/dist/` must still be recognized. The bound keeps this well short of
31
31
  * an unrelated ancestor repo: a real Homebrew npm-global install's package root
32
32
  * sits 3 directories below `/opt/homebrew` (`lib/node_modules/@phnx-labs/…`),
33
33
  * so a depth of 2 finds this repo's `.git` while staying short of Homebrew's.
@@ -31,7 +31,7 @@ export declare function getHumansFilePath(): string;
31
31
  * file against `schema/agents-yaml.schema.json`. Exported so
32
32
  * `lib/devices/config-migration.ts` rewrites a device doc with the same header.
33
33
  */
34
- export declare const META_HEADER = "# agents-cli metadata\n# Auto-generated - do not edit manually\n# https://github.com/phnx-labs/agents-cli\n# yaml-language-server: $schema=https://raw.githubusercontent.com/phnx-labs/agents-cli/main/apps/cli/schema/agents-yaml.schema.json\n\n";
34
+ export declare const META_HEADER = "# agents-cli metadata\n# Auto-generated - do not edit manually\n# https://github.com/phnx-labs/agents-cli\n# yaml-language-server: $schema=https://raw.githubusercontent.com/phnx-labs/agents-cli/main/cli/schema/agents-yaml.schema.json\n\n";
35
35
  /** Root of the system data directory (~/.agents/.system/). */
36
36
  export declare function getAgentsDir(): string;
37
37
  /** Root of the system data directory (~/.agents/.system/). */
package/dist/lib/state.js CHANGED
@@ -168,7 +168,7 @@ const USER_PROMPTCUTS_FILE = path.join(USER_AGENTS_DIR, 'hooks', 'promptcuts.yam
168
168
  export const META_HEADER = `# agents-cli metadata
169
169
  # Auto-generated - do not edit manually
170
170
  # https://github.com/phnx-labs/agents-cli
171
- # yaml-language-server: $schema=https://raw.githubusercontent.com/phnx-labs/agents-cli/main/apps/cli/schema/agents-yaml.schema.json
171
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/phnx-labs/agents-cli/main/cli/schema/agents-yaml.schema.json
172
172
 
173
173
  `;
174
174
  // ─── Root getters ─────────────────────────────────────────────────────────────
@@ -895,7 +895,6 @@ const META_KEY_SCOPE = {
895
895
  actors: 'central',
896
896
  seededPresets: 'central',
897
897
  hooks: 'central',
898
- browser: 'central',
899
898
  config: 'central',
900
899
  hosts: 'central',
901
900
  fleet: 'central',
@@ -910,7 +909,12 @@ const META_KEY_SCOPE = {
910
909
  * in central is stale and must be migrated out). A key NOT listed here — e.g. one
911
910
  * a newer CLI version added — is preserved verbatim, never dropped + synced away.
912
911
  */
913
- const KNOWN_META_KEYS = new Set(Object.keys(META_KEY_SCOPE));
912
+ const KNOWN_META_KEYS = new Set([
913
+ ...Object.keys(META_KEY_SCOPE),
914
+ // Removed browser-profile store. Kept only as a serializer tombstone so the
915
+ // first registry read can migrate it into this device's file and delete it.
916
+ 'browser',
917
+ ]);
914
918
  /**
915
919
  * Serialize the central (synced) meta to `agents.yaml` WITHOUT destroying the
916
920
  * hand-written comments in the committed file.
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * The per-agent `transform`/metadata parsers are the escape hatch: they live in
29
29
  * `subagents.ts` and are referenced by the table, so the generic engine has zero
30
- * per-agent branches. See the integration tiers in `docs/subagents.md`.
30
+ * per-agent branches. See `docs/orchestration.md`.
31
31
  */
32
32
  import * as fs from 'fs';
33
33
  import * as path from 'path';
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Public entry point. Callers typically use `openSurfaces` (a batch with a
6
6
  * layout policy) or `openSurface` (a single request), and `availableBackends` /
7
- * `detectCurrentBackend` to pick a target. See docs/terminal-engine.md.
7
+ * `detectCurrentBackend` to pick a target. See docs/interfaces.md.
8
8
  */
9
9
  export type { Backend, SplitDirection, Layout, EngineContext, LaunchSpec, LaunchRequest, LaunchResult, TerminalBackend, } from './types.js';
10
10
  export { currentContext } from './types.js';
@@ -5,7 +5,7 @@
5
5
  * command, in a chosen terminal backend (iTerm / Ghostty / tmux), on this
6
6
  * machine or a remote host. This is distinct from cloud providers
7
7
  * (src/lib/cloud), which dispatch autonomous headless tasks; a terminal surface
8
- * is attended and live. See docs/terminal-engine.md.
8
+ * is attended and live. See docs/interfaces.md.
9
9
  */
10
10
  /** An interactive terminal backend the engine can drive. */
11
11
  export type Backend = 'iterm' | 'ghostty' | 'tmux' | 'vscodium-agent' | 'terminal';
@@ -5,7 +5,7 @@
5
5
  * command, in a chosen terminal backend (iTerm / Ghostty / tmux), on this
6
6
  * machine or a remote host. This is distinct from cloud providers
7
7
  * (src/lib/cloud), which dispatch autonomous headless tasks; a terminal surface
8
- * is attended and live. See docs/terminal-engine.md.
8
+ * is attended and live. See docs/interfaces.md.
9
9
  */
10
10
  /** Snapshot the live process context. */
11
11
  export function currentContext() {
@@ -172,7 +172,7 @@ export const DETACHED_HELPER_RULES = [CLAUDE_BG_DAEMON];
172
172
  export function isProtectedAgentsService(args) {
173
173
  return /\b__daemon-run\b/.test(args)
174
174
  || /\bsecrets\s+_agent-run\b/.test(args)
175
- || /\bMenubarHelper\b/.test(args)
175
+ || /\bAGI Menu\b/.test(args)
176
176
  || /\bAgents CLI\.app\b/.test(args);
177
177
  }
178
178
  /** Is this pid currently running? Signal-0 probe, matching `platform/process.ts`. */