@songsid/agend 2.3.5-alpha.10 → 2.3.5-alpha.11

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 (293) hide show
  1. package/dist/accounts-view.d.ts +14 -0
  2. package/dist/accounts-view.js +22 -6
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/agent-cli-instructions.md +2 -2
  5. package/dist/auth-api.d.ts +48 -16
  6. package/dist/auth-api.js +99 -32
  7. package/dist/auth-api.js.map +1 -1
  8. package/dist/authority/settings-role.d.ts +56 -0
  9. package/dist/authority/settings-role.js +48 -0
  10. package/dist/authority/settings-role.js.map +1 -0
  11. package/dist/backend/claude-code.d.ts +2 -0
  12. package/dist/backend/claude-code.js +16 -3
  13. package/dist/backend/claude-code.js.map +1 -1
  14. package/dist/backend/cli-env-probe.js +6 -2
  15. package/dist/backend/cli-env-probe.js.map +1 -1
  16. package/dist/backend/codex.d.ts +5 -3
  17. package/dist/backend/codex.js +31 -13
  18. package/dist/backend/codex.js.map +1 -1
  19. package/dist/backend/credential-profile.d.ts +2 -0
  20. package/dist/backend/credential-profile.js +2 -0
  21. package/dist/backend/credential-profile.js.map +1 -1
  22. package/dist/backend/kiro.js +1 -1
  23. package/dist/backend/kiro.js.map +1 -1
  24. package/dist/backend/types.d.ts +5 -1
  25. package/dist/backend/types.js.map +1 -1
  26. package/dist/backend-availability.d.ts +15 -0
  27. package/dist/backend-availability.js +37 -1
  28. package/dist/backend-availability.js.map +1 -1
  29. package/dist/build-provenance.json +1 -1
  30. package/dist/bundled-tmux-guard.d.ts +4 -0
  31. package/dist/bundled-tmux-guard.js +7 -0
  32. package/dist/bundled-tmux-guard.js.map +1 -1
  33. package/dist/claude-auth-status.d.ts +20 -8
  34. package/dist/claude-auth-status.js +38 -22
  35. package/dist/claude-auth-status.js.map +1 -1
  36. package/dist/cli-audited.d.ts +60 -0
  37. package/dist/cli-audited.js +84 -0
  38. package/dist/cli-audited.js.map +1 -0
  39. package/dist/cli-capability.d.ts +36 -5
  40. package/dist/cli-capability.js +2 -2
  41. package/dist/cli-capability.js.map +1 -1
  42. package/dist/cli-caps-module.d.ts +5 -1
  43. package/dist/cli-caps-module.js +4 -2
  44. package/dist/cli-caps-module.js.map +1 -1
  45. package/dist/cli-registry-check.js +16 -2
  46. package/dist/cli-registry-check.js.map +1 -1
  47. package/dist/cli-registry.d.ts +56 -4
  48. package/dist/cli-registry.js +1 -1
  49. package/dist/cli-registry.js.map +1 -1
  50. package/dist/cli-spec-antigravity.d.ts +12 -1
  51. package/dist/cli-spec-antigravity.js +13 -1
  52. package/dist/cli-spec-antigravity.js.map +1 -1
  53. package/dist/cli-spec-claude-code.d.ts +9 -0
  54. package/dist/cli-spec-claude-code.js +4 -2
  55. package/dist/cli-spec-claude-code.js.map +1 -1
  56. package/dist/cli-spec-codex.d.ts +10 -1
  57. package/dist/cli-spec-codex.js +5 -3
  58. package/dist/cli-spec-codex.js.map +1 -1
  59. package/dist/cli-spec-grok.d.ts +5 -0
  60. package/dist/cli-spec-grok.js +6 -1
  61. package/dist/cli-spec-grok.js.map +1 -1
  62. package/dist/cli-spec-kiro-cli.d.ts +7 -1
  63. package/dist/cli-spec-kiro-cli.js +7 -3
  64. package/dist/cli-spec-kiro-cli.js.map +1 -1
  65. package/dist/cli-spec-muse.d.ts +2 -0
  66. package/dist/cli-spec-muse.js +3 -1
  67. package/dist/cli-spec-muse.js.map +1 -1
  68. package/dist/cli-spec-opencode.d.ts +11 -1
  69. package/dist/cli-spec-opencode.js +7 -2
  70. package/dist/cli-spec-opencode.js.map +1 -1
  71. package/dist/cli.js +28 -1
  72. package/dist/cli.js.map +1 -1
  73. package/dist/daemon.d.ts +3 -0
  74. package/dist/daemon.js +17 -2
  75. package/dist/daemon.js.map +1 -1
  76. package/dist/fleet-context.d.ts +5 -1
  77. package/dist/fleet-manager.d.ts +337 -69
  78. package/dist/fleet-manager.js +1247 -355
  79. package/dist/fleet-manager.js.map +1 -1
  80. package/dist/fleet-process-handlers.d.ts +1 -1
  81. package/dist/fleet-process-handlers.js +3 -2
  82. package/dist/fleet-process-handlers.js.map +1 -1
  83. package/dist/general-knowledge/skills/concepts/SKILL.md +21 -14
  84. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +9 -8
  85. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
  86. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +27 -20
  87. package/dist/instance-lifecycle.js +4 -2
  88. package/dist/instance-lifecycle.js.map +1 -1
  89. package/dist/instructions.js +29 -6
  90. package/dist/instructions.js.map +1 -1
  91. package/dist/locale.js +119 -75
  92. package/dist/locale.js.map +1 -1
  93. package/dist/login-manager.d.ts +2 -2
  94. package/dist/login-manager.js +3 -2
  95. package/dist/login-manager.js.map +1 -1
  96. package/dist/native-model-catalog.d.ts +20 -0
  97. package/dist/native-model-catalog.js +107 -2
  98. package/dist/native-model-catalog.js.map +1 -1
  99. package/dist/public-web-gateway.js +1 -1
  100. package/dist/public-web-gateway.js.map +1 -1
  101. package/dist/runtime-api.d.ts +1 -1
  102. package/dist/runtime-api.js +104 -12
  103. package/dist/runtime-api.js.map +1 -1
  104. package/dist/runtime-autostart.d.ts +61 -0
  105. package/dist/runtime-autostart.js +161 -0
  106. package/dist/runtime-autostart.js.map +1 -0
  107. package/dist/runtime-background.d.ts +200 -0
  108. package/dist/runtime-background.js +480 -0
  109. package/dist/runtime-background.js.map +1 -0
  110. package/dist/runtime-build-info.js +5 -5
  111. package/dist/runtime-build-info.js.map +1 -1
  112. package/dist/runtime-cli-background.d.ts +92 -0
  113. package/dist/runtime-cli-background.js +336 -0
  114. package/dist/runtime-cli-background.js.map +1 -0
  115. package/dist/runtime-cli-install.d.ts +148 -8
  116. package/dist/runtime-cli-install.js +253 -59
  117. package/dist/runtime-cli-install.js.map +1 -1
  118. package/dist/runtime-cli.d.ts +8 -1
  119. package/dist/runtime-cli.js +206 -44
  120. package/dist/runtime-cli.js.map +1 -1
  121. package/dist/runtime-client-store.d.ts +11 -0
  122. package/dist/runtime-client-store.js +20 -5
  123. package/dist/runtime-client-store.js.map +1 -1
  124. package/dist/runtime-client.d.ts +23 -1
  125. package/dist/runtime-client.js +92 -6
  126. package/dist/runtime-client.js.map +1 -1
  127. package/dist/runtime-connection.d.ts +1 -1
  128. package/dist/runtime-connection.js +1 -1
  129. package/dist/runtime-connection.js.map +1 -1
  130. package/dist/runtime-coordinator.d.ts +95 -1
  131. package/dist/runtime-coordinator.js +344 -10
  132. package/dist/runtime-coordinator.js.map +1 -1
  133. package/dist/runtime-enroll-notice.d.ts +4 -0
  134. package/dist/runtime-enroll-notice.js +21 -0
  135. package/dist/runtime-enroll-notice.js.map +1 -0
  136. package/dist/runtime-enrollment.d.ts +21 -0
  137. package/dist/runtime-enrollment.js +52 -0
  138. package/dist/runtime-enrollment.js.map +1 -0
  139. package/dist/runtime-pane-native.js +4 -4
  140. package/dist/runtime-pane-native.js.map +1 -1
  141. package/dist/runtime-protocol.d.ts +78 -1
  142. package/dist/runtime-protocol.js +95 -5
  143. package/dist/runtime-protocol.js.map +1 -1
  144. package/dist/runtime-remote-accounts.d.ts +12 -0
  145. package/dist/runtime-remote-accounts.js +56 -5
  146. package/dist/runtime-remote-accounts.js.map +1 -1
  147. package/dist/runtime-remote-setup.d.ts +4 -1
  148. package/dist/runtime-remote-setup.js +4 -1
  149. package/dist/runtime-remote-setup.js.map +1 -1
  150. package/dist/runtime-update-controller.d.ts +11 -0
  151. package/dist/runtime-update-controller.js +56 -4
  152. package/dist/runtime-update-controller.js.map +1 -1
  153. package/dist/settings-api.d.ts +13 -1
  154. package/dist/settings-api.js +39 -3
  155. package/dist/settings-api.js.map +1 -1
  156. package/dist/settings-change.d.ts +5 -13
  157. package/dist/settings-change.js.map +1 -1
  158. package/dist/settings-confirmation.d.ts +11 -13
  159. package/dist/settings-confirmation.js +2 -6
  160. package/dist/settings-confirmation.js.map +1 -1
  161. package/dist/settings-effect.d.ts +5 -0
  162. package/dist/settings-effect.js +76 -10
  163. package/dist/settings-effect.js.map +1 -1
  164. package/dist/settings-http-confirmation.d.ts +8 -1
  165. package/dist/settings-http-confirmation.js +39 -13
  166. package/dist/settings-http-confirmation.js.map +1 -1
  167. package/dist/settings-request-capability.d.ts +7 -0
  168. package/dist/settings-request-capability.js +3 -1
  169. package/dist/settings-request-capability.js.map +1 -1
  170. package/dist/setup-i18n.js +4 -4
  171. package/dist/setup-i18n.js.map +1 -1
  172. package/dist/subagent-records.d.ts +45 -0
  173. package/dist/subagent-records.js +214 -0
  174. package/dist/subagent-records.js.map +1 -0
  175. package/dist/subagent-service.d.ts +27 -0
  176. package/dist/subagent-service.js +199 -0
  177. package/dist/subagent-service.js.map +1 -0
  178. package/dist/tmux-manager.d.ts +2 -2
  179. package/dist/tmux-manager.js +5 -3
  180. package/dist/tmux-manager.js.map +1 -1
  181. package/dist/ui/account-identity.js +7 -5
  182. package/dist/ui/accounts-keepalive.js +17 -17
  183. package/dist/ui/accounts-manage.js +34 -34
  184. package/dist/ui/accounts-view.js +63 -21
  185. package/dist/ui/agent-runtime-settings.js +1 -1
  186. package/dist/ui/backend-signin.js +67 -67
  187. package/dist/ui/chat-msg-actions.js +50 -4
  188. package/dist/ui/chat-quote.js +256 -0
  189. package/dist/ui/chat-store.js +9 -4
  190. package/dist/ui/cli-caps.js +7 -7
  191. package/dist/ui/credential-profile-select.js +4 -4
  192. package/dist/ui/general-location.js +1 -1
  193. package/dist/ui/host-install.js +290 -0
  194. package/dist/ui/hub-company-join-strings.js +3 -0
  195. package/dist/ui/hub-company-join.js +20 -2
  196. package/dist/ui/hub-owner-strings.js +5 -4
  197. package/dist/ui/hub-pairing-progress-strings.js +1 -1
  198. package/dist/ui/hub-quick-strings.js +4 -4
  199. package/dist/ui/machine-signin.js +4 -4
  200. package/dist/ui/model-picker.js +68 -0
  201. package/dist/ui/panel-chat.js +73 -13
  202. package/dist/ui/panel-fleet.js +1 -1
  203. package/dist/ui/panel-hub.js +8 -4
  204. package/dist/ui/panel-needs.js +2 -2
  205. package/dist/ui/panel-runtimes.js +232 -33
  206. package/dist/ui/panel-windows-cli.js +1 -1
  207. package/dist/ui/runtime-cli-install.js +99 -20
  208. package/dist/ui/runtime-commands.d.ts +2 -0
  209. package/dist/ui/runtime-commands.js +34 -1
  210. package/dist/ui/runtime-update-status.js +2 -2
  211. package/dist/ui/search-dialog.js +1 -0
  212. package/dist/ui/settings-access-strings.js +1 -1
  213. package/dist/ui/settings-catalog.js +19 -3
  214. package/dist/ui/settings-confirm.js +2 -2
  215. package/dist/ui/settings-devices.js +59 -25
  216. package/dist/ui/settings-dialogs.js +12 -13
  217. package/dist/ui/settings-guests.js +1 -1
  218. package/dist/ui/settings-hub-company-join.js +10 -7
  219. package/dist/ui/settings-hub-connection.js +121 -0
  220. package/dist/ui/settings-hub-membership.js +1 -1
  221. package/dist/ui/settings-hub-run.js +5 -6
  222. package/dist/ui/settings-hub-section.js +3 -6
  223. package/dist/ui/settings-hub.js +12 -7
  224. package/dist/ui/settings-layout.js +6 -6
  225. package/dist/ui/settings-outside.js +87 -19
  226. package/dist/ui/settings-registry.js +2 -1
  227. package/dist/ui/settings-revoke-strings.js +28 -0
  228. package/dist/ui/settings-strings.js +19 -19
  229. package/dist/ui/settings-web-authority.js +11 -4
  230. package/dist/ui/shared/accounts.css +11 -1
  231. package/dist/ui/shared/agend-auth.js +8 -1
  232. package/dist/ui/shared/app-i18n.js +10 -12
  233. package/dist/ui/shared/app-session.js +13 -16
  234. package/dist/ui/shared/app-shell.js +36 -36
  235. package/dist/ui/shared/app.css +35 -2
  236. package/dist/ui/shared/chat-strings.js +4 -4
  237. package/dist/ui/shared/device-roles.js +27 -0
  238. package/dist/ui/shared/host-install.css +10 -0
  239. package/dist/ui/shared/hub-owner.css +6 -0
  240. package/dist/ui/shared/model-picker.css +21 -0
  241. package/dist/ui/shared/runtime-install.css +26 -1
  242. package/dist/ui/shared/setup-host-text.js +4 -4
  243. package/dist/ui/shared/signin-authenticator.js +60 -0
  244. package/dist/ui/shared/signin.js +45 -25
  245. package/dist/ui/shared/subagent-row.css +15 -0
  246. package/dist/ui/shared/usage-dialog.js +1 -1
  247. package/dist/ui/shared/view-strings.js +7 -7
  248. package/dist/ui/shared/web-authorize.js +53 -3
  249. package/dist/ui/signin-authenticator.html +60 -0
  250. package/dist/ui/structured-signin.js +30 -30
  251. package/dist/ui/subagent-row.js +72 -0
  252. package/dist/ui/web-terminal/terminal.js +9 -9
  253. package/dist/update-launch.js +4 -1
  254. package/dist/update-launch.js.map +1 -1
  255. package/dist/update-npm-env.d.ts +70 -0
  256. package/dist/update-npm-env.js +128 -0
  257. package/dist/update-npm-env.js.map +1 -0
  258. package/dist/usage/providers.js +2 -2
  259. package/dist/usage/providers.js.map +1 -1
  260. package/dist/web-api.d.ts +33 -4
  261. package/dist/web-api.js +312 -18
  262. package/dist/web-api.js.map +1 -1
  263. package/dist/web-auth.js +1 -1
  264. package/dist/web-auth.js.map +1 -1
  265. package/dist/web-channel-echo.js +3 -1
  266. package/dist/web-channel-echo.js.map +1 -1
  267. package/dist/web-commands.d.ts +9 -1
  268. package/dist/web-commands.js +7 -1
  269. package/dist/web-commands.js.map +1 -1
  270. package/dist/web-host-install.d.ts +127 -0
  271. package/dist/web-host-install.js +165 -0
  272. package/dist/web-host-install.js.map +1 -0
  273. package/dist/web-remote-access.d.ts +126 -11
  274. package/dist/web-remote-access.js +267 -34
  275. package/dist/web-remote-access.js.map +1 -1
  276. package/dist/web-session.d.ts +11 -3
  277. package/dist/web-session.js.map +1 -1
  278. package/dist/web-signin-device.d.ts +16 -0
  279. package/dist/web-signin-device.js +81 -0
  280. package/dist/web-signin-device.js.map +1 -0
  281. package/dist/web-update.js +3 -1
  282. package/dist/web-update.js.map +1 -1
  283. package/dist/windows-cli-api.js +2 -1
  284. package/dist/windows-cli-api.js.map +1 -1
  285. package/dist/windows-cli-worker.d.ts +14 -0
  286. package/dist/windows-cli-worker.js +145 -1
  287. package/dist/windows-cli-worker.js.map +1 -1
  288. package/dist/windows-cli.d.ts +4 -0
  289. package/dist/windows-cli.js +9 -1
  290. package/dist/windows-cli.js.map +1 -1
  291. package/launcher/agend-install.cjs +16 -3
  292. package/package.json +1 -1
  293. package/templates/runtime-install/install.ps1 +219 -12
package/dist/web-api.js CHANGED
@@ -8,7 +8,7 @@ import { classifyWebPeer, confirmAfterBody, noAuthority } from "./authority/web-
8
8
  import { guestChatRefusal, guestCommandText, guestDeliveries, GUEST_PREF_MAX_BYTES, GUEST_SEARCHES, guestFrameData, guestHistory, guestMessages, guestOwnPrefs, guestPollBody, guestPrefs, guestRequestOf, guestSeesMessage, guestStatus } from "./web-guest-access.js";
9
9
  import { withSpawnHoldReply } from "./spawn-hold-reply.js";
10
10
  import { binaryProbe } from "./binary-probe.js";
11
- import { settingsRequestExecution, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
11
+ import { settingsRequestExecution, settingsRequestLocalAdmin, settingsRequestRequester, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
12
12
  import { readBoundedWebBody } from "./web-body.js";
13
13
  import { APP_ICON_MAX_BYTES } from "./web-app-icon.js";
14
14
  import { withAppIconLinks } from "./web-icons.js";
@@ -21,6 +21,9 @@ import { SKIN_WIRE_BYTES } from "./web-office-skins.js";
21
21
  import { gatewayRequestContext } from "./web-request-context.js";
22
22
  import { crossInstanceVisibility } from "./cross-instance-notice.js";
23
23
  import { permitWebContinuation } from "./web-continuation.js";
24
+ import { HOST_CLI_PATHS, isRuntimeCliInstallPath } from "./settings-effect.js";
25
+ import { hostUpdateAckError } from "./web-host-install.js";
26
+ import { LATEST_ACK_FIELD } from "./cli-audited.js";
24
27
  /**
25
28
  * Web UI HTTP API handler.
26
29
  * All /ui/* routes are handled here, extracted from fleet-manager.ts.
@@ -67,7 +70,7 @@ import { handleWindowsCliRequest, nativeCliAuthorization } from "./windows-cli-a
67
70
  import { createNativeInstance, handleNativeInstanceRequest } from "./native-instance-api.js";
68
71
  import { handleAgentRuntimeChange } from "./agent-runtime-api.js";
69
72
  import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance } from "./native-instance-registry.js";
70
- import { handleNativeModelCatalog } from "./native-model-catalog.js";
73
+ import { handleNativeModelCatalog, refreshNativeModelCatalog } from "./native-model-catalog.js";
71
74
  import { claudeDocumentedModels } from "./model-catalog-defaults.js";
72
75
  import { handleRuntimeRequest } from "./runtime-api.js";
73
76
  import { taskBoardOffNames } from "./dashboard-permissions.js";
@@ -1559,6 +1562,124 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
1559
1562
  catch { /* response ended */ } });
1560
1563
  return true;
1561
1564
  }
1565
+ /**
1566
+ * AGEND-133 (upstream #3521): installing a CLI on the AgEnD host from the dashboard (web-host-install.ts). The gate is the sign-in routes' own — a signed-in admin
1567
+ * session on the local surface; never the CLI's header token (an agent's), a guest, a read session, or the public link (refused before the body is read, and again
1568
+ * after it). `GET` reads the current install; `POST` `{ backend }` starts one — the browser names a CLI, the server looks up the registry's command, nothing it sends
1569
+ * is ever run; `POST …/cancel` `{}` stops the running one. Every answer is no-store.
1570
+ */
1571
+ const HOST_INSTALL_STATUS = { not_allowed: 403, unsupported: 400, already: 409, not_installed: 409, up_to_date: 409, version_unreadable: 409, busy: 409, shutting_down: 503, failed: 500 };
1572
+ function handleHostInstall(req, res, url, ctx, path, method) {
1573
+ res.setHeader("Cache-Control", "private, no-store");
1574
+ res.setHeader("X-Content-Type-Options", "nosniff");
1575
+ const reading = method === "GET";
1576
+ if (gatewayRequestContext(req)) {
1577
+ json(res, reading ? 404 : 403, { error: "install_not_over_public_link" });
1578
+ return true;
1579
+ }
1580
+ const who = () => {
1581
+ if (isSettingsReplay(req)) {
1582
+ const requester = settingsRequestRequester(req);
1583
+ if (!requester || !settingsRequestLocalAdmin(req))
1584
+ return { error: "install_needs_a_local_admin", status: 403 };
1585
+ return requester;
1586
+ }
1587
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
1588
+ if (v.kind !== "allow")
1589
+ return { error: WEB_TOKEN_INVALID_MESSAGE, status: 401 };
1590
+ if (v.via !== "session" || v.session.tier !== "admin" || v.session.surface !== "local")
1591
+ return { error: "install_needs_a_local_admin", status: 403 };
1592
+ return { handle: v.session.handle, label: v.session.label };
1593
+ };
1594
+ const first = who();
1595
+ if ("error" in first) {
1596
+ json(res, first.status, { error: first.error });
1597
+ return true;
1598
+ }
1599
+ const installs = ctx.webHostInstalls;
1600
+ if (!installs) {
1601
+ json(res, 404, { error: "install_unavailable" });
1602
+ return true;
1603
+ }
1604
+ if (reading && path === "/ui/host-install" && [...url.searchParams.keys()].length === 0) {
1605
+ try {
1606
+ json(res, 200, { install: installs.view() });
1607
+ }
1608
+ catch {
1609
+ json(res, 503, { error: "install_unavailable" });
1610
+ }
1611
+ return true;
1612
+ }
1613
+ // Cancel only takes something away (any local admin may stop it, as `/login cancel`): it is not a held change. Install and Update (AGEND-136) are, and run only as the gate's confirmed replay.
1614
+ if (method !== "POST" || (path !== "/ui/host-install/cancel" && !HOST_CLI_PATHS.has(path))) {
1615
+ json(res, 404, { error: "not_found" });
1616
+ return true;
1617
+ }
1618
+ (async () => {
1619
+ let bytes;
1620
+ try {
1621
+ bytes = await readBoundedWebBody(req, 1024);
1622
+ }
1623
+ catch {
1624
+ json(res, 413, { error: "install_body_bound" });
1625
+ return;
1626
+ }
1627
+ if (!permitWebContinuation(req, res, ctx))
1628
+ return;
1629
+ const now = who();
1630
+ if ("error" in now) {
1631
+ json(res, now.status, { error: now.error });
1632
+ return;
1633
+ }
1634
+ if (now.handle !== first.handle) {
1635
+ json(res, 409, { error: "install_session_changed" });
1636
+ return;
1637
+ }
1638
+ let body;
1639
+ try {
1640
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1641
+ }
1642
+ catch {
1643
+ json(res, 400, { error: "install_json" });
1644
+ return;
1645
+ }
1646
+ if (path === "/ui/host-install/cancel") {
1647
+ if (!z.strictObject({}).safeParse(body).success) {
1648
+ json(res, 400, { error: "install_args" });
1649
+ return;
1650
+ }
1651
+ json(res, 200, { cancelled: await installs.cancel() });
1652
+ return;
1653
+ }
1654
+ // AGEND-154 (Prism P2-1 on #3552): an update may carry `acceptLatestUnaudited: true` (only the page that knows the named exception sends it); the request and the registry must agree (below).
1655
+ const parsed = z.strictObject({ backend: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/), ...(path === "/ui/host-update" ? { [LATEST_ACK_FIELD]: z.literal(true).optional() } : {}) }).safeParse(body);
1656
+ if (!parsed.success) {
1657
+ json(res, 400, { error: "install_args" });
1658
+ return;
1659
+ }
1660
+ if (!isSettingsReplay(req) || !settingsRequestExecution(req)) {
1661
+ json(res, 403, { error: "install_confirmation_required" });
1662
+ return;
1663
+ }
1664
+ if (path === "/ui/host-update") {
1665
+ const ackError = hostUpdateAckError(parsed.data.backend, parsed.data[LATEST_ACK_FIELD]);
1666
+ if (ackError) {
1667
+ json(res, 409, { error: ackError });
1668
+ return;
1669
+ }
1670
+ }
1671
+ // AGEND-136: `POST /ui/host-update { backend }` is the same request for an update: the server picks the command and the audited release; the page sends only the CLI's id.
1672
+ const result = await installs.begin(now, parsed.data.backend, settingsRequestExecution(req), path === "/ui/host-update" ? "update" : "install");
1673
+ if ("error" in result)
1674
+ json(res, HOST_INSTALL_STATUS[result.error] ?? 409, { error: result.error, ...(result.message ? { message: result.message } : {}) });
1675
+ else
1676
+ json(res, 200, result);
1677
+ })().catch(() => { try {
1678
+ json(res, 500, { error: "install_request_failed" });
1679
+ }
1680
+ catch { /* response ended */ } });
1681
+ return true;
1682
+ }
1562
1683
  /**
1563
1684
  * #3212 PR 2: Settings → Accounts — `POST /ui/accounts/<backend>` `{ name }` adds a named account (a credential profile's
1564
1685
  * folder); `DELETE /ui/accounts/<backend>/<name>` `{ confirm: <name> }` removes one (accounts-profiles.ts: every refusal
@@ -2368,7 +2489,7 @@ export function handleWebRequest(req, res, url, ctx) {
2368
2489
  // the panel instead of comparing null against a missing credential.
2369
2490
  if (path.startsWith("/ui")) {
2370
2491
  const approved = isSettingsReplay(req) && method === "POST"
2371
- && (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path))
2492
+ && (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path) || HOST_CLI_PATHS.has(path) || isRuntimeCliInstallPath(path))
2372
2493
  ? settingsRequestExecution(req) : undefined;
2373
2494
  if (approved) {
2374
2495
  try {
@@ -2464,6 +2585,77 @@ export function handleWebRequest(req, res, url, ctx) {
2464
2585
  }
2465
2586
  // ── Backend detection ─────────────────────────────────
2466
2587
  // #2072: the model a Settings field offers — the cached catalog of that backend (that instance's account's). Read only.
2588
+ if (method === "POST" && path === "/ui/models/refresh") {
2589
+ const admission = adminAdmissionOf(req, url, ctx);
2590
+ if (!admission) {
2591
+ json(res, 403, { error: "admin_required" });
2592
+ return true;
2593
+ }
2594
+ void (async () => {
2595
+ let body;
2596
+ try {
2597
+ body = await parseBody(req);
2598
+ }
2599
+ catch {
2600
+ json(res, 400, { error: "Invalid JSON" });
2601
+ return;
2602
+ }
2603
+ if (!permitWebContinuation(req, res, ctx))
2604
+ return;
2605
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2606
+ json(res, 403, { error: "admin_required" });
2607
+ return;
2608
+ }
2609
+ if (!body || Array.isArray(body) || typeof body !== "object" || Object.keys(body).some(k => !["backend", "instance", "runtime", "machineId", "profile"].includes(k))) {
2610
+ json(res, 400, { error: "invalid model target" });
2611
+ return;
2612
+ }
2613
+ const backend = body.backend, instance = body.instance ?? null;
2614
+ if (typeof backend !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(backend) || (instance !== null && (typeof instance !== "string" || !isSafeInstanceName(instance)))) {
2615
+ json(res, 400, { error: "invalid model target" });
2616
+ return;
2617
+ }
2618
+ const runtime = body.runtime, machineId = body.machineId, profile = body.profile;
2619
+ if (runtime !== undefined && runtime !== "windows" && runtime !== "wsl" || machineId !== undefined && (typeof machineId !== "string" || !/^[a-f0-9-]{36}$/i.test(machineId)) || profile !== undefined && (typeof profile !== "string" || profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile))) {
2620
+ json(res, 400, { error: "invalid model target" });
2621
+ return;
2622
+ }
2623
+ const target = { backend, instance, ...(runtime ? { runtime: runtime } : {}), ...(machineId ? { machineId: machineId } : {}), ...(profile !== undefined ? { profile: profile } : {}) };
2624
+ let result;
2625
+ try {
2626
+ result = await refreshNativeModelCatalog(req, url, ctx, target);
2627
+ // Recheck after runtime selection, before any portable probe is admitted.
2628
+ if (!permitWebContinuation(req, res, ctx))
2629
+ return;
2630
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2631
+ json(res, 403, { error: "admin_required" });
2632
+ return;
2633
+ }
2634
+ if (!result) {
2635
+ if (machineId || !ctx.refreshModelCatalogFor) {
2636
+ json(res, 503, { error: "model_refresh_unavailable" });
2637
+ return;
2638
+ }
2639
+ result = await (profile !== undefined ? ctx.refreshModelCatalogFor(backend, instance, { profile: profile }) : ctx.refreshModelCatalogFor(backend, instance));
2640
+ }
2641
+ }
2642
+ catch {
2643
+ if (!permitWebContinuation(req, res, ctx))
2644
+ return;
2645
+ json(res, 503, { error: "model_refresh_unavailable" });
2646
+ return;
2647
+ }
2648
+ if (!permitWebContinuation(req, res, ctx))
2649
+ return;
2650
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2651
+ json(res, 403, { error: "admin_required" });
2652
+ return;
2653
+ }
2654
+ json(res, 200, { backend, ...result });
2655
+ })().catch(() => { if (!res.headersSent)
2656
+ json(res, 500, { error: "model_refresh_failed" }); });
2657
+ return true;
2658
+ }
2467
2659
  if (method === "GET" && path === "/ui/models") {
2468
2660
  const backend = url.searchParams.get("backend") ?? "";
2469
2661
  const instance = url.searchParams.get("instance");
@@ -2481,11 +2673,16 @@ export function handleWebRequest(req, res, url, ctx) {
2481
2673
  json(res, 400, { error: "Invalid model catalog options" });
2482
2674
  return true;
2483
2675
  }
2676
+ const profile = url.searchParams.get("profile");
2677
+ if (profile !== null && profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile)) {
2678
+ json(res, 400, { error: "Invalid model account" });
2679
+ return true;
2680
+ }
2484
2681
  if (handleNativeModelCatalog(req, res, url, ctx))
2485
2682
  return true;
2486
- const models = ctx.modelCatalogFor?.(backend, instance) ?? [];
2683
+ const models = (profile !== null ? ctx.modelCatalogFor?.(backend, instance, { profile }) : ctx.modelCatalogFor?.(backend, instance)) ?? [];
2487
2684
  const answerCatalog = () => {
2488
- if (backend === "claude-code" && !models.length) {
2685
+ if (backend === "claude-code" && !models.length && !profile) {
2489
2686
  const version = ctx.backendAvailabilityRows?.().find(row => row.backend === backend)?.version;
2490
2687
  json(res, 200, { backend, models: claudeDocumentedModels(version), source: "official-catalog" });
2491
2688
  }
@@ -2493,7 +2690,7 @@ export function handleWebRequest(req, res, url, ctx) {
2493
2690
  json(res, 200, { backend, models });
2494
2691
  };
2495
2692
  // The existing catalog belongs to this instance/account and always wins.
2496
- if (models.length || !ctx.cliModelCatalogFor) {
2693
+ if (models.length || !ctx.cliModelCatalogFor || profile !== null) {
2497
2694
  answerCatalog();
2498
2695
  return true;
2499
2696
  }
@@ -2855,6 +3052,38 @@ export function handleWebRequest(req, res, url, ctx) {
2855
3052
  // ── #1218: the Log tab ─────────────────────────────────
2856
3053
  // An instance's steps, read on demand from its own transcript (log-service.ts). Read-only, and offered on the public
2857
3054
  // link on purpose (the user's decision): the same masking applies to every viewer. Passive (web-auth.ts).
3055
+ // Deliberately absent from public gateway, guest, View and Hub projections.
3056
+ if (method === "GET" && path === "/ui/subagents") {
3057
+ const admission = adminAdmissionOf(req, url, ctx), name = url.searchParams.get("instance") ?? "";
3058
+ if (!admission || gatewayRequestContext(req) || guestRequestOf(req)) {
3059
+ json(res, 403, { error: "admin_only" });
3060
+ return true;
3061
+ }
3062
+ if (!name || name.length > 128 || !safeInstanceSegment(name)) {
3063
+ json(res, 400, { error: "invalid instance" });
3064
+ return true;
3065
+ }
3066
+ if (!ctx.subagentRuns) {
3067
+ json(res, 404, { error: "not available" });
3068
+ return true;
3069
+ }
3070
+ void ctx.subagentRuns(name).then(answer => {
3071
+ if (res.destroyed)
3072
+ return;
3073
+ if (adminAdmissionOf(req, url, ctx) !== admission || gatewayRequestContext(req) || guestRequestOf(req)) {
3074
+ json(res, 403, { error: "admin_only" });
3075
+ return;
3076
+ }
3077
+ if (answer.status === "busy") {
3078
+ res.setHeader("Retry-After", "2");
3079
+ json(res, 429, { error: "busy" });
3080
+ return;
3081
+ }
3082
+ json(res, 200, answer);
3083
+ }).catch(() => { if (!res.destroyed)
3084
+ json(res, 503, { error: "unavailable" }); });
3085
+ return true;
3086
+ }
2858
3087
  if (method === "GET" && path === "/ui/steps") {
2859
3088
  const p = url.searchParams;
2860
3089
  const instance = p.get("instance") ?? "";
@@ -3604,6 +3833,8 @@ export function handleWebRequest(req, res, url, ctx) {
3604
3833
  return handleBrowserBackendSignIns(req, res, url, ctx);
3605
3834
  if (path === "/ui/backend-login" || path.startsWith("/ui/backend-login/"))
3606
3835
  return handleBackendLogin(req, res, url, ctx, path, method);
3836
+ if (path === "/ui/host-install" || path === "/ui/host-install/cancel" || path === "/ui/host-update")
3837
+ return handleHostInstall(req, res, url, ctx, path, method);
3607
3838
  // #3292: before the accounts prefix — its Add pattern (`POST /ui/accounts/<backend>`) would read "keep-alive" as a backend.
3608
3839
  if (path === "/ui/accounts/keep-alive")
3609
3840
  return handleAccountKeepAlive(req, res, url, ctx, method);
@@ -3653,16 +3884,19 @@ export function handleWebRequest(req, res, url, ctx) {
3653
3884
  return true;
3654
3885
  }
3655
3886
  // ── #3008: connections from outside (a web-only fleet) ──
3656
- // GET /ui/outside: the state (any admin; over the outside link too, read-only). Everything that changes it is this
3657
- // computer's admin's, on this computer (the fleet asks the live session each time; the public link refuses these
3658
- // routes outright): POST /ui/outside/enroll (a new secret, shown once), POST /ui/outside/enroll/confirm {code},
3659
- // POST /ui/outside/remove, POST /ui/outside/switch {on}. Never a guest (not in GUEST_ROUTES).
3887
+ // GET /ui/outside: the state (any admin; over the outside link too, read-only). What changes it is an admin's, over a
3888
+ // direct connection (the fleet asks the live session each time; the public link refuses these routes outright):
3889
+ // POST /ui/outside/enroll (a new secret, shown once; AGEND-122: {code} — the current one — while the owner's stricter
3890
+ // option is on and this is not the AgEnD computer), POST /ui/outside/enroll/confirm {code}, POST /ui/outside/remove
3891
+ // ({code} likewise), POST /ui/outside/strict {on, code?} (your own "ask for my code" switch) and POST /ui/outside/switch {on} — the
3892
+ // switch stays this computer's admin's, on a web-only fleet. Each acts on the caller's own authenticator only (per admin).
3893
+ // Never a guest (not in GUEST_ROUTES).
3660
3894
  if (method === "GET" && path === "/ui/outside") {
3661
3895
  res.setHeader("Cache-Control", "no-store");
3662
- json(res, 200, ctx.webOutsideStatus?.(req) ?? { webOnly: false, here: false, enrolled: false, enrolledAt: null, outside: false, pausedForMs: 0, link: null });
3896
+ json(res, 200, ctx.webOutsideStatus?.(req) ?? { webOnly: false, here: false, manage: false, codeNeeded: false, strict: false, enrolled: false, enrolledAt: null, outside: false, pausedForMs: 0, link: null });
3663
3897
  return true;
3664
3898
  }
3665
- if (method === "POST" && (path === "/ui/outside/enroll" || path === "/ui/outside/enroll/confirm" || path === "/ui/outside/remove" || path === "/ui/outside/switch")) {
3899
+ if (method === "POST" && (path === "/ui/outside/enroll" || path === "/ui/outside/enroll/confirm" || path === "/ui/outside/remove" || path === "/ui/outside/switch" || path === "/ui/outside/strict")) {
3666
3900
  if (gatewayRequestContext(req)) {
3667
3901
  json(res, 403, { error: "outside_not_here" });
3668
3902
  return true;
@@ -3679,12 +3913,27 @@ export function handleWebRequest(req, res, url, ctx) {
3679
3913
  if (!permitWebContinuation(req, res, ctx))
3680
3914
  return;
3681
3915
  res.setHeader("Cache-Control", "no-store");
3916
+ // AGEND-122: replacing or removing the authenticator asks for the current code while the owner's stricter option is on
3917
+ // and this is not the AgEnD computer's own browser (the fleet decides); the answer to a missing or wrong one is its own.
3918
+ const stepCode = body && typeof body === "object" && typeof body.code === "string" && body.code.length <= 32 ? body.code : undefined;
3919
+ const refusal = (r) => {
3920
+ if (r.error === "paused") {
3921
+ res.setHeader("Retry-After", String(Math.ceil((r.retryAfterMs ?? 60_000) / 1000)));
3922
+ json(res, 429, { error: "paused", retryAfterMs: r.retryAfterMs ?? null });
3923
+ return;
3924
+ }
3925
+ json(res, r.error === "wrong" ? 401 : r.error === "unavailable" ? 503 : r.error === "code_required" ? 400 : 403, { error: r.error === "not_here" ? "outside_not_here" : r.error });
3926
+ };
3682
3927
  if (path === "/ui/outside/enroll") {
3683
- const r = ctx.webOutsideBeginEnrollment?.(req) ?? null;
3928
+ const r = ctx.webOutsideBeginEnrollment?.(req, stepCode) ?? null;
3684
3929
  if (!r) {
3685
3930
  json(res, 403, { error: "outside_not_here" });
3686
3931
  return;
3687
3932
  }
3933
+ if ("error" in r) {
3934
+ refusal(r);
3935
+ return;
3936
+ }
3688
3937
  json(res, 200, r);
3689
3938
  return;
3690
3939
  }
@@ -3695,11 +3944,15 @@ export function handleWebRequest(req, res, url, ctx) {
3695
3944
  return;
3696
3945
  }
3697
3946
  const r = ctx.webOutsideConfirmEnrollment?.(req, code) ?? "not_here";
3698
- json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : 400, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
3947
+ json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : r === "full" ? 409 : 400, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
3699
3948
  return;
3700
3949
  }
3701
3950
  if (path === "/ui/outside/remove") {
3702
- const r = ctx.webOutsideRemove?.(req) ?? "not_here";
3951
+ const r = ctx.webOutsideRemove?.(req, stepCode) ?? "not_here";
3952
+ if (typeof r === "object") {
3953
+ refusal(r);
3954
+ return;
3955
+ }
3703
3956
  json(res, r === "ok" ? 200 : r === "unsaved" ? 503 : 403, r === "ok" ? { ok: true } : { error: r === "unsaved" ? "unsaved" : "outside_not_here" });
3704
3957
  return;
3705
3958
  }
@@ -3708,6 +3961,16 @@ export function handleWebRequest(req, res, url, ctx) {
3708
3961
  json(res, 400, { error: "on must be true or false" });
3709
3962
  return;
3710
3963
  }
3964
+ if (path === "/ui/outside/strict") {
3965
+ // AGEND-122 (per admin): the caller's OWN "ask for my code" switch — on needs their app and asks nothing, off asks their current code.
3966
+ const sr = ctx.webOutsideStrict?.(req, on, stepCode) ?? "not_here";
3967
+ if (typeof sr === "object") {
3968
+ refusal(sr);
3969
+ return;
3970
+ }
3971
+ json(res, sr === "ok" ? 200 : sr === "not_here" ? 403 : sr === "unsaved" ? 503 : 409, sr === "ok" ? { ok: true } : { error: sr === "not_here" ? "outside_not_here" : sr });
3972
+ return;
3973
+ }
3711
3974
  const r = ctx.webOutsideSwitch?.(req, on) ?? "not_here";
3712
3975
  json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : 409, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
3713
3976
  })().catch(err => {
@@ -3992,6 +4255,10 @@ export function handleWebRequest(req, res, url, ctx) {
3992
4255
  json(res, 400, { error: "args too long" });
3993
4256
  return;
3994
4257
  }
4258
+ if (body.action !== undefined && !["refresh", "more", "refreshAll"].includes(body.action)) {
4259
+ json(res, 400, { error: "invalid model action" });
4260
+ return;
4261
+ }
3995
4262
  if (body.confirm !== undefined && !(typeof body.confirm === "string" && /^[0-9a-f]{32}$/.test(body.confirm))) {
3996
4263
  json(res, 400, { error: "invalid confirmation" });
3997
4264
  return;
@@ -4023,9 +4290,33 @@ export function handleWebRequest(req, res, url, ctx) {
4023
4290
  guestCommandsRunning.add(account);
4024
4291
  ctx.guestCommandRuns?.record(account);
4025
4292
  }
4293
+ if (isNativePaneInstance(ctx.fleetConfig?.instances[instance]) && body.action) {
4294
+ if (command !== "model" || body.action !== "refresh" || body.args) {
4295
+ json(res, 400, { error: "invalid model action" });
4296
+ return;
4297
+ }
4298
+ const target = ctx.fleetConfig.instances[instance];
4299
+ try {
4300
+ const refreshed = await refreshNativeModelCatalog(req, url, ctx, { backend: target.backend, instance });
4301
+ if (!stillAuthorized(req, res, url, ctx))
4302
+ return;
4303
+ if (!refreshed || ctx.fleetConfig?.instances[instance] !== target || !nativeCliAuthorization(req, url, ctx)) {
4304
+ json(res, 409, { error: "model target changed" });
4305
+ return;
4306
+ }
4307
+ json(res, 200, { choices: { current: target.model ?? null, options: refreshed.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] } });
4308
+ }
4309
+ catch {
4310
+ if (stillAuthorized(req, res, url, ctx))
4311
+ json(res, 503, { error: t("model.refresh_failed") });
4312
+ }
4313
+ return;
4314
+ }
4026
4315
  try {
4027
4316
  const { authority } = confirmAfterBody(arrival, webAuthorityOf(req, url, ctx, instance));
4028
- const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
4317
+ const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm, ...(body.action ? { action: body.action } : {}) }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
4318
+ if (!stillAuthorized(req, res, url, ctx))
4319
+ return;
4029
4320
  json(res, r.status, r.body);
4030
4321
  }
4031
4322
  finally {
@@ -5030,7 +5321,7 @@ function webDeliveryFailure(err) {
5030
5321
  if (/No warm slot is free/.test(message))
5031
5322
  return { reason: "wake_capacity", error: "No slot is free to wake this instance. Retry when another instance is idle." };
5032
5323
  if (/login|log in|sign in|\bauth(?:entication|orization)?\b|credential|api.?key/i.test(message))
5033
- return { reason: "wake_credentials", error: "The instance could not sign in. Sign it in from Settings → Agents → AI sign-ins and API keys → Accounts, or send /login in chat, then retry." };
5324
+ return { reason: "wake_credentials", error: "The instance could not sign in. Connect its AI account in Settings → Agents → AI accounts and API keys → Accounts, or send /login in chat, then retry." };
5034
5325
  if (/timed? out|timeout/i.test(message))
5035
5326
  return { reason: "wake_timeout", error: "The instance did not become ready in time. Retry, or check its status in Fleet." };
5036
5327
  if (/Cannot wake stopped|no longer configured/.test(message))
@@ -5702,7 +5993,10 @@ function shellBodyTag(req, ctx, mode, viewer) {
5702
5993
  ownerCssState = "unknown";
5703
5994
  }
5704
5995
  const attr = (v) => String(v ?? "").replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
5705
- return `<body data-mode="${mode}"${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
5996
+ const admission = evaluateWebRequest(req, new URL(req.url ?? "/", "http://localhost"), ctx.webToken ?? null, ctx.webSessions, { touch: false });
5997
+ const childMark = mode === "full" && !gatewayRequestContext(req) && !viewer?.guest && admission.kind === "allow"
5998
+ && (admission.via !== "session" || admission.session.tier === "admin");
5999
+ return `<body data-mode="${mode}"${childMark ? ' data-subagents="1"' : ""}${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
5706
6000
  + ` data-preview-boot="${attr(p?.previewOrigin ? p.boot : "")}" data-preview-reason="${attr(p ? p.reason : "Previews are not available on this fleet.")}"`
5707
6001
  // #1554: no availability asked (the public link, or not the full app) still says why, in the page's language.
5708
6002
  + ` data-preview-reason-code="${attr(p ? p.code ?? "" : gatewayRequestContext(req) ? "publicLink" : "notOffered")}"`