@songsid/agend 2.3.5-alpha.7 → 2.3.5-alpha.9

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 (362) hide show
  1. package/dist/accounts-profiles.d.ts +6 -0
  2. package/dist/accounts-profiles.js +16 -0
  3. package/dist/accounts-profiles.js.map +1 -1
  4. package/dist/accounts-view.d.ts +17 -0
  5. package/dist/accounts-view.js +33 -6
  6. package/dist/accounts-view.js.map +1 -1
  7. package/dist/agent-cli-instructions.md +1 -1
  8. package/dist/agent-cli.js +5 -2
  9. package/dist/agent-cli.js.map +1 -1
  10. package/dist/agent-whats-new.js +5 -0
  11. package/dist/agent-whats-new.js.map +1 -1
  12. package/dist/apply-job.d.ts +5 -0
  13. package/dist/apply-job.js +10 -3
  14. package/dist/apply-job.js.map +1 -1
  15. package/dist/auth-api.d.ts +1 -1
  16. package/dist/auth-api.js +4 -2
  17. package/dist/auth-api.js.map +1 -1
  18. package/dist/authority/company-join.d.ts +16 -0
  19. package/dist/authority/company-join.js +37 -0
  20. package/dist/authority/company-join.js.map +1 -0
  21. package/dist/authority/hub-initialization.d.ts +13 -0
  22. package/dist/authority/hub-initialization.js +30 -0
  23. package/dist/authority/hub-initialization.js.map +1 -0
  24. package/dist/backend/claude-code.d.ts +1 -0
  25. package/dist/backend/claude-code.js +13 -0
  26. package/dist/backend/claude-code.js.map +1 -1
  27. package/dist/backend/types.d.ts +4 -0
  28. package/dist/backend/types.js.map +1 -1
  29. package/dist/build-provenance.json +1 -1
  30. package/dist/channel/mcp-tools.js +2 -2
  31. package/dist/channel/mcp-tools.js.map +1 -1
  32. package/dist/claude-model-minimum.d.ts +7 -0
  33. package/dist/claude-model-minimum.js +16 -0
  34. package/dist/claude-model-minimum.js.map +1 -0
  35. package/dist/config-validator.js +2 -1
  36. package/dist/config-validator.js.map +1 -1
  37. package/dist/daemon.d.ts +43 -1
  38. package/dist/daemon.js +176 -27
  39. package/dist/daemon.js.map +1 -1
  40. package/dist/decision-list.d.ts +2 -0
  41. package/dist/decision-list.js +1 -1
  42. package/dist/decision-list.js.map +1 -1
  43. package/dist/fleet-manager.d.ts +75 -3
  44. package/dist/fleet-manager.js +462 -53
  45. package/dist/fleet-manager.js.map +1 -1
  46. package/dist/general-knowledge/skills/concepts/SKILL.md +14 -3
  47. package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
  48. package/dist/general-knowledge/steering/core-rules.md +1 -1
  49. package/dist/hub/catalog.d.ts +1 -1
  50. package/dist/hub/catalog.js +151 -33
  51. package/dist/hub/catalog.js.map +1 -1
  52. package/dist/hub/client.js +4 -0
  53. package/dist/hub/client.js.map +1 -1
  54. package/dist/hub/compose/member.d.ts +6 -0
  55. package/dist/hub/compose/member.js +9 -1
  56. package/dist/hub/compose/member.js.map +1 -1
  57. package/dist/hub/compose/server.d.ts +55 -1
  58. package/dist/hub/compose/server.js +76 -10
  59. package/dist/hub/compose/server.js.map +1 -1
  60. package/dist/hub/directory/directory.d.ts +2 -0
  61. package/dist/hub/directory/directory.js +49 -4
  62. package/dist/hub/directory/directory.js.map +1 -1
  63. package/dist/hub/directory/types.d.ts +2 -0
  64. package/dist/hub/directory/types.js.map +1 -1
  65. package/dist/hub/enrollment-budget.d.ts +6 -0
  66. package/dist/hub/enrollment-budget.js +24 -0
  67. package/dist/hub/enrollment-budget.js.map +1 -0
  68. package/dist/hub/group-policy/admin-api.d.ts +30 -0
  69. package/dist/hub/group-policy/admin-api.js +83 -0
  70. package/dist/hub/group-policy/admin-api.js.map +1 -0
  71. package/dist/hub/group-policy/admin-control.d.ts +34 -0
  72. package/dist/hub/group-policy/admin-control.js +258 -0
  73. package/dist/hub/group-policy/admin-control.js.map +1 -0
  74. package/dist/hub/group-policy/admin-dto.d.ts +9 -1
  75. package/dist/hub/group-policy/admin-dto.js.map +1 -1
  76. package/dist/hub/group-policy/admin-facts.d.ts +17 -0
  77. package/dist/hub/group-policy/admin-facts.js +33 -0
  78. package/dist/hub/group-policy/admin-facts.js.map +1 -0
  79. package/dist/hub/group-policy/admin-impact.d.ts +51 -0
  80. package/dist/hub/group-policy/admin-impact.js +88 -0
  81. package/dist/hub/group-policy/admin-impact.js.map +1 -0
  82. package/dist/hub/group-policy/authorization.d.ts +22 -0
  83. package/dist/hub/group-policy/authorization.js +147 -2
  84. package/dist/hub/group-policy/authorization.js.map +1 -1
  85. package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
  86. package/dist/hub/group-policy/impact-inventory.js +75 -0
  87. package/dist/hub/group-policy/impact-inventory.js.map +1 -0
  88. package/dist/hub/group-policy/resources.d.ts +13 -1
  89. package/dist/hub/group-policy/resources.js +92 -23
  90. package/dist/hub/group-policy/resources.js.map +1 -1
  91. package/dist/hub/group-policy/store.d.ts +11 -0
  92. package/dist/hub/group-policy/store.js +57 -2
  93. package/dist/hub/group-policy/store.js.map +1 -1
  94. package/dist/hub/group-policy/welcome.d.ts +36 -0
  95. package/dist/hub/group-policy/welcome.js +55 -0
  96. package/dist/hub/group-policy/welcome.js.map +1 -0
  97. package/dist/hub/http/compose.d.ts +2 -0
  98. package/dist/hub/http/compose.js +184 -8
  99. package/dist/hub/http/compose.js.map +1 -1
  100. package/dist/hub/http/core.d.ts +2 -0
  101. package/dist/hub/http/core.js +10 -1
  102. package/dist/hub/http/core.js.map +1 -1
  103. package/dist/hub/http/deps.d.ts +10 -0
  104. package/dist/hub/http/schema.js +4 -0
  105. package/dist/hub/http/schema.js.map +1 -1
  106. package/dist/hub/init/browser-certificate.d.ts +6 -1
  107. package/dist/hub/init/browser-certificate.js +22 -1
  108. package/dist/hub/init/browser-certificate.js.map +1 -1
  109. package/dist/hub/init/initializer.d.ts +11 -1
  110. package/dist/hub/init/initializer.js +202 -83
  111. package/dist/hub/init/initializer.js.map +1 -1
  112. package/dist/hub/init/layout.js +1 -1
  113. package/dist/hub/init/layout.js.map +1 -1
  114. package/dist/hub/init/text.js +2 -2
  115. package/dist/hub/init/text.js.map +1 -1
  116. package/dist/hub/init/types.d.ts +32 -4
  117. package/dist/hub/init/types.js.map +1 -1
  118. package/dist/hub/init/web-audit-import.d.ts +12 -0
  119. package/dist/hub/init/web-audit-import.js +39 -0
  120. package/dist/hub/init/web-audit-import.js.map +1 -0
  121. package/dist/hub/init/web-audit.d.ts +30 -0
  122. package/dist/hub/init/web-audit.js +42 -0
  123. package/dist/hub/init/web-audit.js.map +1 -0
  124. package/dist/hub/init/web-error.d.ts +6 -0
  125. package/dist/hub/init/web-error.js +8 -0
  126. package/dist/hub/init/web-error.js.map +1 -0
  127. package/dist/hub/init/web-http.d.ts +9 -0
  128. package/dist/hub/init/web-http.js +103 -0
  129. package/dist/hub/init/web-http.js.map +1 -0
  130. package/dist/hub/init/web.d.ts +118 -0
  131. package/dist/hub/init/web.js +428 -0
  132. package/dist/hub/init/web.js.map +1 -0
  133. package/dist/hub/init/wizard.js +1 -3
  134. package/dist/hub/init/wizard.js.map +1 -1
  135. package/dist/hub/join/client.d.ts +35 -0
  136. package/dist/hub/join/client.js +112 -0
  137. package/dist/hub/join/client.js.map +1 -0
  138. package/dist/hub/join/descriptor.d.ts +45 -0
  139. package/dist/hub/join/descriptor.js +52 -0
  140. package/dist/hub/join/descriptor.js.map +1 -0
  141. package/dist/hub/join/fleet-authority.d.ts +2 -0
  142. package/dist/hub/join/fleet-authority.js +3 -0
  143. package/dist/hub/join/fleet-authority.js.map +1 -0
  144. package/dist/hub/join/http.d.ts +8 -0
  145. package/dist/hub/join/http.js +112 -0
  146. package/dist/hub/join/http.js.map +1 -0
  147. package/dist/hub/join/invitation.d.ts +28 -0
  148. package/dist/hub/join/invitation.js +28 -0
  149. package/dist/hub/join/invitation.js.map +1 -0
  150. package/dist/hub/join/local-journal.d.ts +84 -0
  151. package/dist/hub/join/local-journal.js +65 -0
  152. package/dist/hub/join/local-journal.js.map +1 -0
  153. package/dist/hub/join/local.d.ts +116 -0
  154. package/dist/hub/join/local.js +419 -0
  155. package/dist/hub/join/local.js.map +1 -0
  156. package/dist/hub/join/private.d.ts +3 -0
  157. package/dist/hub/join/private.js +46 -0
  158. package/dist/hub/join/private.js.map +1 -0
  159. package/dist/hub/join/protocol.d.ts +69 -0
  160. package/dist/hub/join/protocol.js +96 -0
  161. package/dist/hub/join/protocol.js.map +1 -0
  162. package/dist/hub/join/receipt.d.ts +42 -0
  163. package/dist/hub/join/receipt.js +75 -0
  164. package/dist/hub/join/receipt.js.map +1 -0
  165. package/dist/hub/join/service.d.ts +177 -0
  166. package/dist/hub/join/service.js +564 -0
  167. package/dist/hub/join/service.js.map +1 -0
  168. package/dist/hub/join/store.d.ts +97 -0
  169. package/dist/hub/join/store.js +87 -0
  170. package/dist/hub/join/store.js.map +1 -0
  171. package/dist/hub/join/trust.d.ts +13 -0
  172. package/dist/hub/join/trust.js +68 -0
  173. package/dist/hub/join/trust.js.map +1 -0
  174. package/dist/hub/member/pairing-api.d.ts +2 -0
  175. package/dist/hub/member/pairing-api.js +7 -1
  176. package/dist/hub/member/pairing-api.js.map +1 -1
  177. package/dist/hub/member/pairing-notices.d.ts +18 -0
  178. package/dist/hub/member/pairing-notices.js +60 -0
  179. package/dist/hub/member/pairing-notices.js.map +1 -0
  180. package/dist/hub/pairing-notices.d.ts +47 -0
  181. package/dist/hub/pairing-notices.js +246 -0
  182. package/dist/hub/pairing-notices.js.map +1 -0
  183. package/dist/hub/pairing.d.ts +39 -1
  184. package/dist/hub/pairing.js +316 -16
  185. package/dist/hub/pairing.js.map +1 -1
  186. package/dist/hub/protocol.d.ts +61 -0
  187. package/dist/hub/protocol.js +8 -1
  188. package/dist/hub/protocol.js.map +1 -1
  189. package/dist/hub/room-read-pacer.d.ts +14 -0
  190. package/dist/hub/room-read-pacer.js +51 -0
  191. package/dist/hub/room-read-pacer.js.map +1 -0
  192. package/dist/hub/rooms.d.ts +7 -1
  193. package/dist/hub/rooms.js +25 -13
  194. package/dist/hub/rooms.js.map +1 -1
  195. package/dist/hub/runtime.d.ts +8 -1
  196. package/dist/hub/runtime.js +13 -0
  197. package/dist/hub/runtime.js.map +1 -1
  198. package/dist/hub/server.d.ts +3 -0
  199. package/dist/hub/server.js +18 -0
  200. package/dist/hub/server.js.map +1 -1
  201. package/dist/hub/session-directory-transition.d.ts +48 -0
  202. package/dist/hub/session-directory-transition.js +118 -0
  203. package/dist/hub/session-directory-transition.js.map +1 -0
  204. package/dist/hub/session-epoch.d.ts +16 -0
  205. package/dist/hub/session-epoch.js +50 -0
  206. package/dist/hub/session-epoch.js.map +1 -0
  207. package/dist/hub/sessions.d.ts +13 -0
  208. package/dist/hub/sessions.js +36 -16
  209. package/dist/hub/sessions.js.map +1 -1
  210. package/dist/hub/settings-api.d.ts +50 -0
  211. package/dist/hub/settings-api.js +92 -0
  212. package/dist/hub/settings-api.js.map +1 -0
  213. package/dist/hub/settings-commit.d.ts +95 -0
  214. package/dist/hub/settings-commit.js +490 -0
  215. package/dist/hub/settings-commit.js.map +1 -0
  216. package/dist/hub/settings-directory-decision.d.ts +433 -0
  217. package/dist/hub/settings-directory-decision.js +236 -0
  218. package/dist/hub/settings-directory-decision.js.map +1 -0
  219. package/dist/hub/settings-directory-proof.d.ts +77 -0
  220. package/dist/hub/settings-directory-proof.js +303 -0
  221. package/dist/hub/settings-directory-proof.js.map +1 -0
  222. package/dist/hub/store.d.ts +12 -2
  223. package/dist/hub/store.js +9 -5
  224. package/dist/hub/store.js.map +1 -1
  225. package/dist/hub/types.d.ts +15 -2
  226. package/dist/hub-host-settings.d.ts +48 -0
  227. package/dist/hub-host-settings.js +85 -0
  228. package/dist/hub-host-settings.js.map +1 -0
  229. package/dist/instance-lifecycle.d.ts +3 -0
  230. package/dist/instance-lifecycle.js +4 -0
  231. package/dist/instance-lifecycle.js.map +1 -1
  232. package/dist/locale.js +54 -30
  233. package/dist/locale.js.map +1 -1
  234. package/dist/login-controller.d.ts +9 -1
  235. package/dist/login-controller.js +20 -1
  236. package/dist/login-controller.js.map +1 -1
  237. package/dist/login-flows.js +4 -2
  238. package/dist/login-flows.js.map +1 -1
  239. package/dist/office-share-page.js +1 -1
  240. package/dist/office-share-page.js.map +1 -1
  241. package/dist/outbound-handlers.js +1 -1
  242. package/dist/outbound-handlers.js.map +1 -1
  243. package/dist/outbound-schemas.d.ts +2 -0
  244. package/dist/outbound-schemas.js +4 -2
  245. package/dist/outbound-schemas.js.map +1 -1
  246. package/dist/pane-port.d.ts +1 -1
  247. package/dist/profile-signins.d.ts +107 -0
  248. package/dist/profile-signins.js +249 -0
  249. package/dist/profile-signins.js.map +1 -0
  250. package/dist/quickstart-api.js +2 -2
  251. package/dist/quickstart-api.js.map +1 -1
  252. package/dist/reply-buttons-controller.d.ts +5 -1
  253. package/dist/reply-buttons-controller.js +8 -4
  254. package/dist/reply-buttons-controller.js.map +1 -1
  255. package/dist/reply-buttons.d.ts +6 -2
  256. package/dist/reply-buttons.js +7 -3
  257. package/dist/reply-buttons.js.map +1 -1
  258. package/dist/scheduler/db.d.ts +10 -0
  259. package/dist/scheduler/db.js +38 -11
  260. package/dist/scheduler/db.js.map +1 -1
  261. package/dist/scheduler/types.d.ts +6 -1
  262. package/dist/settings-api.d.ts +9 -1
  263. package/dist/settings-api.js +200 -4
  264. package/dist/settings-api.js.map +1 -1
  265. package/dist/settings-confirmation.d.ts +1 -1
  266. package/dist/settings-confirmation.js +1 -1
  267. package/dist/settings-confirmation.js.map +1 -1
  268. package/dist/settings-effect.js +58 -0
  269. package/dist/settings-effect.js.map +1 -1
  270. package/dist/settings-http-confirmation.d.ts +3 -0
  271. package/dist/settings-http-confirmation.js +8 -5
  272. package/dist/settings-http-confirmation.js.map +1 -1
  273. package/dist/settings-request-capability.d.ts +5 -0
  274. package/dist/settings-request-capability.js +6 -1
  275. package/dist/settings-request-capability.js.map +1 -1
  276. package/dist/signin-keepalive.d.ts +2 -0
  277. package/dist/signin-keepalive.js +30 -2
  278. package/dist/signin-keepalive.js.map +1 -1
  279. package/dist/structured-signin-transport.d.ts +20 -2
  280. package/dist/structured-signin-transport.js +57 -6
  281. package/dist/structured-signin-transport.js.map +1 -1
  282. package/dist/team-membership.d.ts +7 -0
  283. package/dist/team-membership.js +10 -0
  284. package/dist/team-membership.js.map +1 -0
  285. package/dist/tmux-manager.d.ts +1 -1
  286. package/dist/tmux-manager.js +4 -1
  287. package/dist/tmux-manager.js.map +1 -1
  288. package/dist/topic-commands.js +1 -1
  289. package/dist/topic-commands.js.map +1 -1
  290. package/dist/ui/accounts-keepalive.js +10 -5
  291. package/dist/ui/accounts-manage.js +29 -11
  292. package/dist/ui/accounts-view.js +75 -28
  293. package/dist/ui/backend-signin.js +61 -16
  294. package/dist/ui/hub-attachments.js +3 -3
  295. package/dist/ui/hub-chat-strings.js +2 -0
  296. package/dist/ui/hub-client.js +50 -4
  297. package/dist/ui/hub-company-join-strings.js +74 -0
  298. package/dist/ui/hub-company-join.js +119 -0
  299. package/dist/ui/hub-group-policy.js +175 -0
  300. package/dist/ui/hub-group-strings.js +97 -0
  301. package/dist/ui/hub-owner-strings.js +12 -12
  302. package/dist/ui/hub-pairing-progress-strings.js +15 -0
  303. package/dist/ui/hub-quick-pairing.js +209 -0
  304. package/dist/ui/hub-quick-strings.js +43 -0
  305. package/dist/ui/hub-read-strings.js +7 -0
  306. package/dist/ui/hub-this-hub.js +112 -0
  307. package/dist/ui/hub-welcome.js +102 -0
  308. package/dist/ui/panel-hub.js +217 -28
  309. package/dist/ui/panel-needs.js +1 -1
  310. package/dist/ui/panel-settings.js +7 -4
  311. package/dist/ui/settings-apply.js +12 -5
  312. package/dist/ui/settings-devices.js +2 -2
  313. package/dist/ui/settings-dialogs.js +3 -1
  314. package/dist/ui/settings-hub-company-join.js +90 -0
  315. package/dist/ui/settings-hub-membership.js +20 -5
  316. package/dist/ui/settings-hub-preview.js +74 -0
  317. package/dist/ui/settings-hub-run.js +60 -0
  318. package/dist/ui/settings-hub-section.js +30 -3
  319. package/dist/ui/settings-hub.js +52 -11
  320. package/dist/ui/settings-registry.js +2 -0
  321. package/dist/ui/settings-restart-strings.js +17 -0
  322. package/dist/ui/settings-strings.js +6 -4
  323. package/dist/ui/shared/accounts-keepalive.css +11 -6
  324. package/dist/ui/shared/accounts.css +68 -18
  325. package/dist/ui/shared/app-i18n.js +4 -1
  326. package/dist/ui/shared/app-shell.js +39 -25
  327. package/dist/ui/shared/app.css +9 -8
  328. package/dist/ui/shared/chat-strings.js +13 -13
  329. package/dist/ui/shared/hub-chat.css +12 -0
  330. package/dist/ui/shared/hub-groups.css +28 -0
  331. package/dist/ui/shared/hub-owner.css +19 -1
  332. package/dist/ui/shared/hub.css +8 -1
  333. package/dist/ui/shared/setup-host-text.js +4 -1
  334. package/dist/ui/shared/signin.js +3 -1
  335. package/dist/ui/shared/usage-dialog.js +3 -72
  336. package/dist/ui/shared/usage-meter.js +84 -0
  337. package/dist/ui/shared/web-authorize.js +4 -4
  338. package/dist/ui/structured-signin.js +24 -6
  339. package/dist/update-dispatch.d.ts +32 -4
  340. package/dist/update-dispatch.js +146 -16
  341. package/dist/update-dispatch.js.map +1 -1
  342. package/dist/update-launch.d.ts +1 -1
  343. package/dist/update-launch.js +2 -2
  344. package/dist/update-launch.js.map +1 -1
  345. package/dist/update-marker.d.ts +2 -0
  346. package/dist/update-marker.js.map +1 -1
  347. package/dist/view-api.d.ts +2 -8
  348. package/dist/view-api.js +3 -9
  349. package/dist/view-api.js.map +1 -1
  350. package/dist/web-api.d.ts +7 -1
  351. package/dist/web-api.js +91 -14
  352. package/dist/web-api.js.map +1 -1
  353. package/dist/web-backend-login.d.ts +16 -2
  354. package/dist/web-backend-login.js +14 -0
  355. package/dist/web-backend-login.js.map +1 -1
  356. package/dist/web-notices.d.ts +9 -0
  357. package/dist/web-notices.js +19 -0
  358. package/dist/web-notices.js.map +1 -1
  359. package/dist/web-terminal.d.ts +7 -0
  360. package/dist/web-terminal.js +14 -2
  361. package/dist/web-terminal.js.map +1 -1
  362. package/package.json +1 -1
@@ -11,42 +11,15 @@ import { Dialog } from "./ui-dialog.js";
11
11
  import { ErrorState, Skeleton } from "./ui-states.js";
12
12
  import { Icon } from "./ui-icons.js";
13
13
  import "./view-strings.js";
14
+ import { CompactMeter, resetClock, resetText, tn, usageClock, usageDuration, usageText } from "./usage-meter.js";
15
+ // What this file exported before the meter moved out of it (#3321), for what imports it from here.
16
+ export { usageClock, windowTag, soonestReset } from "./usage-meter.js";
14
17
 
15
- function tn(key, values = {}) {
16
- let s = t(`view.${key}`);
17
- for (const [k, v] of Object.entries(values)) s = s.split(`{${k}}`).join(String(v));
18
- return s;
19
- }
20
18
  const stored = (k) => { try { return localStorage.getItem(k); } catch { return null; } };
21
19
  const store = (k, v) => { try { localStorage.setItem(k, v); } catch { /* this page only */ } };
22
20
 
23
21
  // ── AI usage ── Every provider the fleet's logins report; refreshed every 60 s while this dialog is open (passive).
24
22
  const USAGE_ORDER_KEY = "agend_view_usage_order";
25
- function usageText(fallback, ref) {
26
- if (!ref || typeof ref.key !== "string") return fallback == null ? "" : String(fallback);
27
- return (Array.isArray(ref.args) ? ref.args : []).reduce((text, value, i) => text.split(`{${i}}`).join(String(value)), t(`view.${ref.key}`));
28
- }
29
- function usageDuration(ms) {
30
- const total = Math.max(1, Math.ceil(ms / 60000));
31
- const d = Math.floor(total / 1440), h = Math.floor((total % 1440) / 60), m = total % 60;
32
- if (total >= 2880) return usageText("", { key: "usage.duration.days_hours", args: [d, h] });
33
- if (total >= 60) return usageText("", { key: "usage.duration.hours_minutes", args: [Math.floor(total / 60), m] });
34
- return usageText("", { key: "usage.duration.minutes", args: [total] });
35
- }
36
- function resetText(iso) {
37
- if (!iso) return "";
38
- const ms = new Date(iso).getTime() - Date.now();
39
- if (Number.isNaN(ms)) return "";
40
- if (ms <= 0) return tn("usage.reset.soon");
41
- return usageText("", { key: "usage.reset.in", args: [usageDuration(ms)] });
42
- }
43
- /** "14:05" today, "10/19 14:05" another day, in this browser's time: when last known numbers were read, a window reset. */
44
- export function usageClock(iso, now = Date.now()) {
45
- const at = new Date(iso || "");
46
- if (Number.isNaN(at.getTime())) return "";
47
- const hm = `${String(at.getHours()).padStart(2, "0")}:${String(at.getMinutes()).padStart(2, "0")}`;
48
- return new Date(now).toDateString() === at.toDateString() ? hm : `${at.getMonth() + 1}/${at.getDate()} ${hm}`;
49
- }
50
23
  /**
51
24
  * A row showing its last known numbers (the live read failed; #2236 follow-up): "已過期 · 快取於 14:05" and, for an expiry
52
25
  * or another failure, what to do on a second line (its full text is the mark's tooltip too). A row from an older
@@ -182,25 +155,6 @@ export function compactSlots(p) {
182
155
  }
183
156
  /** The windows a compact line shows, short first. */
184
157
  export const compactMetrics = (p) => { const { short, long } = compactSlots(p); return [short, long].filter(Boolean); };
185
- /** A window as a few characters ("5h", "7d"); one whose length is not known says its label. */
186
- export function windowTag(m) {
187
- const ms = Number(m && m.windowMs);
188
- if (!(ms > 0)) return usageText(m.label, m.labelI18n);
189
- const h = ms / 3_600_000;
190
- return h < 48 ? tn("usageWindowHours", { n: Math.round(h) }) : tn("usageWindowDays", { n: Math.round(h / 24) });
191
- }
192
- /** A time ahead in one unit, for the narrow column: "45m", "3h", "4d" (rounded down past an hour; the tooltip is exact). */
193
- function coarseDuration(ms) {
194
- const min = Math.max(1, Math.ceil(ms / 60_000));
195
- if (min < 60) return tn("usageWindowMinutes", { n: min });
196
- const h = Math.floor(min / 60);
197
- return h < 48 ? tn("usageWindowHours", { n: h }) : tn("usageWindowDays", { n: Math.floor(h / 24) });
198
- }
199
- /** The soonest reset still ahead among `metrics`: { short: "↻ 2h", full: "resets in 2h 5m" }, or null when none is known. */
200
- export function soonestReset(metrics, now = Date.now()) {
201
- const at = metrics.map((m) => new Date(m.resetsAt || "").getTime()).filter((t) => Number.isFinite(t) && t > now).sort((a, b) => a - b)[0];
202
- return at === undefined ? null : { short: `↻ ${coarseDuration(at - now)}`, full: resetText(new Date(at).toISOString()) };
203
- }
204
158
  /**
205
159
  * The logins grouped by provider for the compact view (nine logins, five of them Claude's: the provider once, then a
206
160
  * line per login), in the order the person set (↑↓): a group where its first login is, its logins in their order.
@@ -214,7 +168,6 @@ export function compactGroups(providers) {
214
168
  });
215
169
  return [...groups.values()];
216
170
  }
217
- const level = (pct) => (pct >= 90 ? "crit" : pct >= 70 ? "warn" : "");
218
171
  /**
219
172
  * #2240: an account whose percent windows come from several pools (agy: Gemini, Claude & others, Gemini 4 Argon) — each
220
173
  * pool with its windows and the tighter one (the most used); null for an account of one pool (its 5h / 7d lines).
@@ -231,28 +184,6 @@ export function compactPools(p) {
231
184
  return [...pools.values()].map((x) => ({ ...x, worst: x.metrics.reduce((a, b) => ((b.used ?? 0) > (a.used ?? 0) ? b : a)) }));
232
185
  }
233
186
  const pctOf = (m) => Math.min(100, Math.max(0, m.used ?? 0));
234
- /** When a window resets, at the clock ("14:05", "10/19 14:05"), for a tooltip; "" when unknown or already past. */
235
- function resetClock(m, now = Date.now()) {
236
- const at = new Date((m && m.resetsAt) || "").getTime();
237
- return Number.isFinite(at) && at > now ? `↻ ${usageClock(m.resetsAt, now)}` : "";
238
- }
239
- /**
240
- * One window on its own line: its few characters ("5h"), a full-width bar, the percent coloured as the full card, and
241
- * when this window resets ("↻ 8m"; the user's ask, 2026-10-23: a week's reset was hidden behind the 5 h one's). A pool's
242
- * line (#2240): the pool's name in place of the window, the reset of the window its percent is, every window (with its
243
- * reset time) in the tooltip.
244
- */
245
- function CompactMeter({ m, tag, title }) {
246
- const bar = useRef(null);
247
- const pct = Math.min(100, Math.max(0, m.used ?? 0)), cls = level(pct);
248
- useLayoutEffect(() => { if (bar.current) bar.current.style.width = `${pct}%`; }, [pct]); // CSSOM (#1300)
249
- const word = cls === "crit" ? tn("usageNear") : cls === "warn" ? tn("usageHigh") : "";
250
- const reset = soonestReset([m]), clock = resetClock(m);
251
- return html`<span class="u-cm" title=${title || `${usageText(m.label, m.labelI18n)}: ${pct.toFixed(0)}%${word ? ` (${word})` : ""}${clock ? ` · ${clock}` : ""}`}>
252
- <span class="u-cm-tag">${tag || windowTag(m)}</span><span class="u-cm-bar"><span ref=${bar} class=${`u-cm-fill ${cls}`}></span></span>
253
- <span class=${`u-cm-pct ${cls}`}>${pct.toFixed(0)}%</span>
254
- <span class="u-cm-reset">${reset ? html`${reset.short}<span class="sr-only"> (${reset.full})</span>` : null}</span></span>`;
255
- }
256
187
  /** What a login says instead of numbers (not logged in, an error), or "" when it has numbers. */
257
188
  function rowNote(p) {
258
189
  if (p.status === "error") return usageText(p.error || tn("usage.error_fallback"), p.errorI18n);
@@ -0,0 +1,84 @@
1
+ // The usage meter, in a module of its own: one window as a few characters ("5h"), a bar, the percent and its reset ("↻ 8m"). The Usage panel's
2
+ // compact rows (usage-dialog.js) and Settings → Accounts (accounts-view.js) draw it, so both show the same thing.
3
+ // A module of its own (#3321): a tab opened before an upgrade keeps the usage-dialog.js it had (header-tools.js loads it with the shell), and a
4
+ // named import of something that file never exported breaks the link of whatever imports it — here the whole Settings page. This file has a new
5
+ // address, so a tab that has never loaded it fetches it, and usage-dialog.js (old or new) never needs it to be there. Everything it uses from the
6
+ // shared modules is what those modules have always exported.
7
+ import { html, useLayoutEffect, useRef } from "./app-html.js";
8
+ import { t } from "./app-i18n.js";
9
+ import "./view-strings.js";
10
+
11
+ export function tn(key, values = {}) {
12
+ let s = t(`view.${key}`);
13
+ for (const [k, v] of Object.entries(values)) s = s.split(`{${k}}`).join(String(v));
14
+ return s;
15
+ }
16
+ export function usageText(fallback, ref) {
17
+ if (!ref || typeof ref.key !== "string") return fallback == null ? "" : String(fallback);
18
+ return (Array.isArray(ref.args) ? ref.args : []).reduce((text, value, i) => text.split(`{${i}}`).join(String(value)), t(`view.${ref.key}`));
19
+ }
20
+ export function usageDuration(ms) {
21
+ const total = Math.max(1, Math.ceil(ms / 60000));
22
+ const d = Math.floor(total / 1440), h = Math.floor((total % 1440) / 60), m = total % 60;
23
+ if (total >= 2880) return usageText("", { key: "usage.duration.days_hours", args: [d, h] });
24
+ if (total >= 60) return usageText("", { key: "usage.duration.hours_minutes", args: [Math.floor(total / 60), m] });
25
+ return usageText("", { key: "usage.duration.minutes", args: [total] });
26
+ }
27
+ export function resetText(iso) {
28
+ if (!iso) return "";
29
+ const ms = new Date(iso).getTime() - Date.now();
30
+ if (Number.isNaN(ms)) return "";
31
+ if (ms <= 0) return tn("usage.reset.soon");
32
+ return usageText("", { key: "usage.reset.in", args: [usageDuration(ms)] });
33
+ }
34
+ /** "14:05" today, "10/19 14:05" another day, in this browser's time: when last known numbers were read, a window reset. */
35
+ export function usageClock(iso, now = Date.now()) {
36
+ const at = new Date(iso || "");
37
+ if (Number.isNaN(at.getTime())) return "";
38
+ const hm = `${String(at.getHours()).padStart(2, "0")}:${String(at.getMinutes()).padStart(2, "0")}`;
39
+ return new Date(now).toDateString() === at.toDateString() ? hm : `${at.getMonth() + 1}/${at.getDate()} ${hm}`;
40
+ }
41
+ /** A window as a few characters ("5h", "7d"); one whose length is not known says its label. */
42
+ export function windowTag(m) {
43
+ const ms = Number(m && m.windowMs);
44
+ if (!(ms > 0)) return usageText(m.label, m.labelI18n);
45
+ const h = ms / 3_600_000;
46
+ return h < 48 ? tn("usageWindowHours", { n: Math.round(h) }) : tn("usageWindowDays", { n: Math.round(h / 24) });
47
+ }
48
+ /** A time ahead in one unit, for the narrow column: "45m", "3h", "4d" (rounded down past an hour; the tooltip is exact). */
49
+ function coarseDuration(ms) {
50
+ const min = Math.max(1, Math.ceil(ms / 60_000));
51
+ if (min < 60) return tn("usageWindowMinutes", { n: min });
52
+ const h = Math.floor(min / 60);
53
+ return h < 48 ? tn("usageWindowHours", { n: h }) : tn("usageWindowDays", { n: Math.floor(h / 24) });
54
+ }
55
+ /** The soonest reset still ahead among `metrics`: { short: "↻ 2h", full: "resets in 2h 5m" }, or null when none is known. */
56
+ export function soonestReset(metrics, now = Date.now()) {
57
+ const at = metrics.map((m) => new Date(m.resetsAt || "").getTime()).filter((t) => Number.isFinite(t) && t > now).sort((a, b) => a - b)[0];
58
+ return at === undefined ? null : { short: `↻ ${coarseDuration(at - now)}`, full: resetText(new Date(at).toISOString()) };
59
+ }
60
+ export const level = (pct) => (pct >= 90 ? "crit" : pct >= 70 ? "warn" : "");
61
+ /** When a window resets, at the clock ("14:05", "10/19 14:05"), for a tooltip; "" when unknown or already past. */
62
+ export function resetClock(m, now = Date.now()) {
63
+ const at = new Date((m && m.resetsAt) || "").getTime();
64
+ return Number.isFinite(at) && at > now ? `↻ ${usageClock(m.resetsAt, now)}` : "";
65
+ }
66
+ /**
67
+ * One window on its own line: its few characters ("5h"), a full-width bar, the percent coloured as the full card, and
68
+ * when this window resets ("↻ 8m"; the user's ask, 2026-10-23: a week's reset was hidden behind the 5 h one's). A pool's
69
+ * line (#2240): the pool's name in place of the window, the reset of the window its percent is, every window (with its
70
+ * reset time) in the tooltip.
71
+ * Exported (#3321) so Settings → Accounts draws its 5h / week windows with this same meter and thresholds (70% / 90%): `m` needs
72
+ * `used` (0–100), `resetsAt` and either `windowMs` or `label`; `tag` overrides the window's few characters.
73
+ */
74
+ export function CompactMeter({ m, tag, title }) {
75
+ const bar = useRef(null);
76
+ const pct = Math.min(100, Math.max(0, m.used ?? 0)), cls = level(pct);
77
+ useLayoutEffect(() => { if (bar.current) bar.current.style.width = `${pct}%`; }, [pct]); // CSSOM (#1300)
78
+ const word = cls === "crit" ? tn("usageNear") : cls === "warn" ? tn("usageHigh") : "";
79
+ const reset = soonestReset([m]), clock = resetClock(m);
80
+ return html`<span class="u-cm" title=${title || `${usageText(m.label, m.labelI18n)}: ${pct.toFixed(0)}%${word ? ` (${word})` : ""}${clock ? ` · ${clock}` : ""}`}>
81
+ <span class="u-cm-tag">${tag || windowTag(m)}</span><span class="u-cm-bar"><span ref=${bar} class=${`u-cm-fill ${cls}`}></span></span>
82
+ <span class=${`u-cm-pct ${cls}`}>${pct.toFixed(0)}%</span>
83
+ <span class="u-cm-reset">${reset ? html`${reset.short}<span class="sr-only"> (${reset.full})</span>` : null}</span></span>`;
84
+ }
@@ -14,8 +14,8 @@ register("webauth", {
14
14
  sent: "Sent — confirm it in your DM within 5 minutes.",
15
15
  reason_disabled: "Web authority is turned off.",
16
16
  reason_loopback_only: "Only this computer can authorize, and this browser is not on it.",
17
- reason_no_account: "This browser was not signed in as an account (agend web): sign in with /web to authorize.",
18
- reason_host_sign_in: "To speak as this computer's admin, sign in again on this computer with agend web --code.",
17
+ reason_no_account: "This browser has no chat-account identity. Open General in Telegram or Discord and send /web to sign in as your account.",
18
+ reason_host_sign_in: "This browser no longer has this computer's admin authority. This sign-in cannot be renewed on this page.",
19
19
  reason_not_admin: "Your account is not a fleet admin here.",
20
20
  reason_not_admin_session: "Guests can't authorize.",
21
21
  reason_token_rotated: "The dashboard's token changed: sign in again.",
@@ -43,8 +43,8 @@ register("webauth", {
43
43
  sent: "已送出——請在 5 分鐘內到私訊確認。",
44
44
  reason_disabled: "網頁授權已關閉。",
45
45
  reason_loopback_only: "只有這台電腦可以授權,而這個瀏覽器不在這台電腦上。",
46
- reason_no_account: "這個瀏覽器不是用帳號登入的(agend web):請用 /web 登入後再授權。",
47
- reason_host_sign_in: "要以這台電腦的管理者身分發言,請在這台電腦上執行 agend web --code 重新登入。",
46
+ reason_no_account: "這個瀏覽器沒有聊天帳號身分。請到 Telegram 或 Discord 的 General 傳送 /web,以你的帳號登入。",
47
+ reason_host_sign_in: "這個瀏覽器已沒有這台電腦的管理者授權。這個頁面無法重新取得這個登入的授權。",
48
48
  reason_not_admin: "你的帳號在這裡不是 fleet 管理者。",
49
49
  reason_not_admin_session: "訪客無法授權。",
50
50
  reason_token_rotated: "儀表板的 token 已變更:請重新登入。",
@@ -22,6 +22,9 @@ export const SIGNIN_STRINGS = {
22
22
  error_backend_signin_local_only: "Backend sign-in is available only on this computer. Use the local setup page, or sign in later.",
23
23
  error_signin_session_expired: "This setup session has ended. Reopen setup on the host.",
24
24
  error_expired: "This login attempt expired. Start a new attempt.",
25
+ error_busy: "Another sign-in is already running. Finish or cancel it, then try again.",
26
+ error_signin_busy: "Another sign-in is already running. Finish or cancel it, then try again.",
27
+ error_signin_profile_unknown: "This account is not in the list. Add it with + Add account in Settings → Accounts, then sign in.",
25
28
  error_auth_unconfirmed: "The CLI exited, but credentials could not be verified. Retry or sign in later.",
26
29
  error_provider_rejected: "The provider rejected this sign-in. Retry or sign in later.",
27
30
  // #3190 Part 3c: a profile on a paired computer (the dashboard's Accounts view).
@@ -56,6 +59,9 @@ export const SIGNIN_STRINGS = {
56
59
  error_backend_signin_local_only: "後端登入只能在這台電腦上進行。請使用本機的設定頁,或稍後登入。",
57
60
  error_signin_session_expired: "這個設定工作階段已結束。請在主機上重新開啟設定。",
58
61
  error_expired: "這次登入已過期。請重新開始。",
62
+ error_busy: "已有另一個登入正在進行。請等它結束或先取消,再試一次。",
63
+ error_signin_busy: "已有另一個登入正在進行。請等它結束或先取消,再試一次。",
64
+ error_signin_profile_unknown: "清單裡沒有這個帳號。請先在 設定 → 帳號 用 + 新增帳號 加入,再登入。",
59
65
  error_auth_unconfirmed: "CLI 已結束,但無法確認憑證。請重試或稍後登入。",
60
66
  error_provider_rejected: "平台拒絕了這次登入。請重試或稍後登入。",
61
67
  // #3190 Part 3c:配對電腦上的憑證設定檔(儀表板的「帳號」頁)。
@@ -79,8 +85,19 @@ const pageLang = doc => /^zh/i.test(doc?.documentElement?.lang || "") ? "zh-TW"
79
85
  * `machine` (#3190 Part 3c): these cards are for ONE credential profile on a paired computer (the endpoint carries `?machine=&profile=`). The dialog around them says
80
86
  * so, so the setup page's heading and lead are not repeated; there is no "sign in later" (this is an explicit request); and a sign-in again asks nothing about
81
87
  * Kiro (Claude Code's own sign-in replaces the login; it signs nothing out first).
88
+ *
89
+ * `dashboard` (#3321 S01, S12): the cards are inside the dashboard, where the dialog's own title names the CLI and the question "Sign in again?" is asked in the dashboard's
90
+ * own confirmation (`ask`) — the setup page's heading, lead and "You can continue setup" are not repeated, and the browser's `confirm()` is not used.
91
+ *
92
+ * `dialog: true` (#3212, named accounts on this host): the cards are inside Settings → Accounts' sign-in dialog for ONE account, which says WHICH account in its title; it
93
+ * is the same screen for the default account and a named one. So the rest of what the first-install page needs is left out too: no "Check sign-ins" button (the cards read
94
+ * themselves every second) and no "Sign in later" (nothing would remember it). `focus` (a backend id) then shows only that backend's card: the default account's checklist may
95
+ * hold others. The setup page and the installer's `?backend_signins=` list do not pass `dialog`, and look as they did.
96
+ *
97
+ * `started` (run id → void): called with the id of the run a press of Sign in in THESE cards started (not one that was already running when they were drawn). The account dialog
98
+ * keeps it, to end exactly that run when it closes.
82
99
  */
83
- export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, changed = () => {}, lang, machine = false, ask, dashboard = false } = {}) {
100
+ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, changed = () => {}, lang, machine = false, ask, dashboard = false, dialog = false, focus, started = () => {} } = {}) {
84
101
  const doc = root.ownerDocument;
85
102
  let view = null, busy = false, disposed = false, timer = null, generation = 0, message = "", rendered = "";
86
103
  const language = () => (lang ? lang() : pageLang(doc)) === "zh-TW" ? "zh-TW" : "en";
@@ -102,7 +119,7 @@ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, change
102
119
  async function perform(data) {
103
120
  if (busy || disposed) return;
104
121
  busy = true; generation++; message = ""; render();
105
- try { const next = await request(data); if (!disposed) accept(next); }
122
+ try { const next = await request(data); if (!disposed) { accept(next); if (data?.operation === "start" && typeof next?.login?.id === "string") started(next.login.id); } }
106
123
  catch (error) { if (!disposed) message = String(error?.message || "error"); }
107
124
  finally { busy = false; if (!disposed) render(); }
108
125
  }
@@ -114,8 +131,9 @@ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, change
114
131
  // "continue setup" are not repeated there.
115
132
  if (!machine && !dashboard) { el("h2", tr("heading")); el("p", tr("lead")); }
116
133
  if (message) { const alert = el("p", errorText(message)); alert.setAttribute("role", "alert"); }
117
- if (!view) { button(root, tr("check"), () => perform({ operation: "refresh" })); return; }
118
- for (const backend of view.selected) {
134
+ // In the account dialog the cards read themselves every second, so there is no Check sign-ins — except when the first read failed and there is nothing to show: then it is the Retry.
135
+ if (!view) { if (!dialog || message) button(root, tr("check"), () => perform({ operation: "refresh" })); return; }
136
+ for (const backend of dialog && focus ? view.selected.filter(b => b === focus) : view.selected) {
119
137
  const card = el("section"); card.dataset.backend = backend;
120
138
  el("h3", name(backend), card);
121
139
  const state = view.states[backend], pending = view.pending.includes(backend), skipped = view.skipped.includes(backend);
@@ -158,9 +176,9 @@ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, change
158
176
  await perform({ operation: "start", backend, relogin });
159
177
  });
160
178
  }
161
- if (pending && !skipped && !machine) button(card, tr("later"), () => perform({ operation: "skip", backend }));
179
+ if (pending && !skipped && !machine && !dialog) button(card, tr("later"), () => perform({ operation: "skip", backend }));
162
180
  }
163
- button(root, tr("check"), () => perform({ operation: "refresh" }));
181
+ if (!dialog) button(root, tr("check"), () => perform({ operation: "refresh" }));
164
182
  if (view.ready && !machine && !dashboard) el("p", tr("ready"));
165
183
  }
166
184
  async function poll() {
@@ -1,16 +1,39 @@
1
1
  export interface DispatchDeps {
2
- run(command: string, args: string[], timeoutMs: number): Promise<{
2
+ /** `env.PATH` (#3440) replaces PATH for that one program: an npm is asked in the PATH the update will run with. */
3
+ run(command: string, args: string[], timeoutMs: number, env?: {
4
+ PATH: string;
5
+ }): Promise<{
3
6
  status: number | null;
4
7
  stdout: string;
5
8
  }>;
6
9
  readFile(path: string): Promise<string>;
7
10
  realpath(path: string): Promise<string>;
11
+ /** An executable file there (#3440). */
12
+ isExecutable?(path: string): Promise<boolean>;
13
+ /** The package directory this code runs from — whose global root the npm asked must have (#3440). Null: unknown. */
14
+ packageDir?: string | null;
15
+ /** The Node running this process (#3440): the npm beside it is a candidate when AgEnD runs on a plain Node. */
16
+ execPath?: string;
17
+ /** This process's PATH (#3440): where PATH's `npm` lives. */
18
+ pathEnv?: string;
8
19
  }
9
20
  export declare const defaultDispatchDeps: DispatchDeps;
21
+ /**
22
+ * #3440: the `npm` beside a POSIX global install of this package: `<prefix>/lib/node_modules/@songsid/agend` →
23
+ * `<prefix>/bin/npm`, run by `<prefix>/bin/node`. npm takes its global prefix from the Node that runs it, and its
24
+ * `#!/usr/bin/env node` would pick PATH's Node — the same system one that hid the install — so the prefix's own Node runs
25
+ * it explicitly. Null for anything else (a checkout, a Windows prefix). (From the 雲晴家 fleet operator's patch.)
26
+ */
27
+ export declare function colocatedNpm(packageDir: string | null | undefined, platform?: NodeJS.Platform): {
28
+ command: string;
29
+ args: string[];
30
+ } | null;
31
+ /** `npmDir` (#3440): the directory of the npm that proved this install — the update runs with it first on PATH. */
10
32
  export type InstalledAgend = {
11
33
  ok: true;
12
34
  agend: string;
13
35
  version: string;
36
+ npmDir?: string;
14
37
  } | {
15
38
  ok: false;
16
39
  reason: string;
@@ -19,10 +42,15 @@ export type InstalledAgend = {
19
42
  export declare function resolveInstalledAgend(deps?: DispatchDeps): Promise<InstalledAgend>;
20
43
  /**
21
44
  * `<installed agend> update`, 2 s from now, from a detached `sh`. Service callers must wrap it in an independent scope before launch. The
22
- * path is a positional argument, never spliced into the script.
45
+ * path is a positional argument, never spliced into the script. #3440: the agend's own bin directory (`<prefix>/bin`,
46
+ * where its `npm` and `node` live) goes first on PATH, so the CLI's npm checks and install use the npm that installed
47
+ * it, not a system npm the service's PATH happens to list first. (From the 雲晴家 fleet operator's patch.) That also puts
48
+ * every global package's bin ahead of the system tools for the updater's run — as in an nvm user's own shell.
23
49
  */
24
- export declare const DELAYED_UPDATE_SCRIPT = "sleep 2 && exec \"$1\" update";
25
- export declare function updateCommand(agend: string): {
50
+ export declare const DELAYED_UPDATE_SCRIPT = "sleep 2 && PATH=\"${1%/*}:$PATH\" && export PATH && exec \"$1\" update";
51
+ /** #3443 review: with the proving npm's directory (`$2`, data) ahead of the agend's own — it may hold no npm (a custom prefix). */
52
+ export declare const DELAYED_UPDATE_SCRIPT_NPM = "sleep 2 && PATH=\"$2:${1%/*}:$PATH\" && export PATH && exec \"$1\" update";
53
+ export declare function updateCommand(agend: string, npmDir?: string): {
26
54
  command: string;
27
55
  args: string[];
28
56
  };
@@ -5,16 +5,23 @@
5
5
  * replaces). No unverified fallback: when npm cannot say where it installed AgEnD, or what it says does not hold
6
6
  * together, `/update` refuses and says to run `agend update` from a shell.
7
7
  *
8
+ * #3440: which `npm` is asked matters. A fleet service's PATH can put a system npm (e.g. `/usr/bin/npm`) ahead of the
9
+ * nvm Node that installed AgEnD, and that npm's global root has no AgEnD in it. The npm that manages THIS running
10
+ * package is the one asked: an npm is accepted only when its global root is the running package's own root. With the
11
+ * patch from the 雲晴家 fleet operator, who verified it on the original failing machine.
12
+ *
8
13
  * Runs on the fleet's event loop: every step is async and bounded.
9
14
  */
10
15
  import { execFile } from "./child-process.js";
11
- import { readFile, realpath } from "node:fs/promises";
12
- import { join } from "node:path";
16
+ import { access, readFile, realpath } from "node:fs/promises";
17
+ import { constants } from "node:fs";
18
+ import { basename, delimiter, dirname, isAbsolute, join } from "node:path";
19
+ import { fileURLToPath } from "node:url";
13
20
  import { promisify } from "node:util";
14
21
  export const defaultDispatchDeps = {
15
- run: async (command, args, timeoutMs) => {
22
+ run: async (command, args, timeoutMs, env) => {
16
23
  try {
17
- const { stdout } = await promisify(execFile)(command, args, { encoding: "utf8", timeout: timeoutMs });
24
+ const { stdout } = await promisify(execFile)(command, args, { encoding: "utf8", timeout: timeoutMs, ...(env ? { env: { ...process.env, ...env } } : {}) });
18
25
  return { status: 0, stdout: String(stdout) };
19
26
  }
20
27
  catch (err) {
@@ -24,15 +31,131 @@ export const defaultDispatchDeps = {
24
31
  },
25
32
  readFile: path => readFile(path, "utf8"),
26
33
  realpath: path => realpath(path),
34
+ isExecutable: async (path) => { try {
35
+ await access(path, constants.X_OK);
36
+ return true;
37
+ }
38
+ catch {
39
+ return false;
40
+ } },
41
+ packageDir: fileURLToPath(new URL("..", import.meta.url)),
42
+ execPath: process.execPath,
27
43
  };
28
- /** npm's global root and prefix → the installed package, its bin target, and the bin link that must lead to it. */
29
- export async function resolveInstalledAgend(deps = defaultDispatchDeps) {
44
+ /**
45
+ * #3440: the `npm` beside a POSIX global install of this package: `<prefix>/lib/node_modules/@songsid/agend` →
46
+ * `<prefix>/bin/npm`, run by `<prefix>/bin/node`. npm takes its global prefix from the Node that runs it, and its
47
+ * `#!/usr/bin/env node` would pick PATH's Node — the same system one that hid the install — so the prefix's own Node runs
48
+ * it explicitly. Null for anything else (a checkout, a Windows prefix). (From the 雲晴家 fleet operator's patch.)
49
+ */
50
+ export function colocatedNpm(packageDir, platform = process.platform) {
51
+ if (!packageDir || platform === "win32")
52
+ return null;
53
+ const pkg = packageDir.replace(/\/+$/, "");
54
+ const scope = dirname(pkg), root = dirname(scope), lib = dirname(root);
55
+ if (basename(pkg) !== "agend" || basename(scope) !== "@songsid" || basename(root) !== "node_modules" || basename(lib) !== "lib")
56
+ return null;
57
+ const bin = join(dirname(lib), "bin");
58
+ return { command: join(bin, "node"), args: [join(bin, "npm")] };
59
+ }
60
+ async function runningInstall(deps) {
61
+ if (!deps.packageDir)
62
+ return { kind: "checkout" };
63
+ let real;
64
+ try {
65
+ real = await deps.realpath(deps.packageDir);
66
+ }
67
+ catch (err) {
68
+ const code = err.code;
69
+ return { kind: "unreadable", reason: `cannot read where the running AgEnD is installed (${deps.packageDir}${typeof code === "string" ? `: ${code}` : ""}), so it cannot tell which install to update` };
70
+ }
71
+ const scope = dirname(real), root = dirname(scope);
72
+ return basename(real) === "agend" && basename(scope) === "@songsid" && basename(root) === "node_modules" ? { kind: "global", root } : { kind: "checkout" };
73
+ }
74
+ /** `npm root -g` / `npm prefix -g`, run as bare `npm` — in `env.PATH` when given, the way the update will run it. */
75
+ async function askNpm(deps, env) {
30
76
  const last = (text) => text.trim().split("\n").pop()?.trim() ?? "";
31
- const [root, prefix] = await Promise.all([deps.run("npm", ["root", "-g"], 15_000), deps.run("npm", ["prefix", "-g"], 15_000)]);
32
- if (root.status !== 0 || prefix.status !== 0 || !last(root.stdout) || !last(prefix.stdout)) {
33
- return { ok: false, reason: "npm could not say where AgEnD is installed" };
77
+ const ask = (what) => deps.run("npm", [what, "-g"], 15_000, env);
78
+ const [root, prefix] = await Promise.all([ask("root"), ask("prefix")]);
79
+ return root.status === 0 && prefix.status === 0 && last(root.stdout) && last(prefix.stdout) ? { root: last(root.stdout), prefix: last(prefix.stdout) } : null;
80
+ }
81
+ /**
82
+ * #3440: the npm that manages the running install — never merely the first one on the fleet's PATH — PROVED IN THE
83
+ * ENVIRONMENT THE UPDATE WILL RUN IN (#3442/#3443 review). The updater runs bare `npm` (its checks and install), and npm
84
+ * runs on the first `node` its PATH finds, from which it takes its global prefix. So each candidate is a launch PATH —
85
+ * an optional directory first, then the install's own bin (`<prefix>/bin`, as the launch script puts it), then the
86
+ * fleet's PATH — and `npm root -g` is asked under exactly that PATH. Candidates, in order:
87
+ * 1. nothing extra: the install's bin first (its own npm and Node — the 雲晴家 operator's colocated npm — or, with no
88
+ * npm there, PATH's npm on the Node that order picks);
89
+ * 2. the directory of the Node running AgEnD, when an npm is beside it (AgEnD on a plain Node);
90
+ * 3. the first PATH directory holding an npm, ahead of the install's bin.
91
+ * One is accepted only when its global root IS the running package's root; its directory (2, 3) is then `npmDir`, which
92
+ * the launch puts first — so what runs is what was proved. None: a refusal naming the root and what each answered.
93
+ * A source checkout keeps the old rule: PATH's npm as it is.
94
+ */
95
+ async function npmForRunningInstall(deps) {
96
+ const running = await runningInstall(deps);
97
+ if (running.kind === "unreadable")
98
+ return { reason: running.reason };
99
+ if (running.kind === "checkout")
100
+ return (await askNpm(deps)) ?? { reason: "npm could not say where AgEnD is installed" };
101
+ const expected = running.root;
102
+ const executable = deps.isExecutable ?? defaultDispatchDeps.isExecutable;
103
+ const pathEnv = deps.pathEnv ?? process.env.PATH ?? "";
104
+ // <prefix>/lib/node_modules → <prefix>/bin, where the colocated npm and its Node live (the 雲晴家 operator's colocatedNpm).
105
+ const ownBin = dirname(colocatedNpm(join(expected, "@songsid", "agend"))?.args[0] ?? join(dirname(dirname(expected)), "bin", "npm"));
106
+ const firstNpmOnPath = async (path) => {
107
+ for (const dir of path.split(delimiter))
108
+ if (dir && isAbsolute(dir) && await executable(join(dir, "npm")))
109
+ return join(dir, "npm");
110
+ return null;
111
+ };
112
+ const candidates = [];
113
+ const own = await firstNpmOnPath([ownBin, pathEnv].join(delimiter));
114
+ candidates.push({ label: own ? (dirname(own) === ownBin ? own : `${own} (PATH's)`) : "npm on PATH" });
115
+ const nodeDir = dirname(deps.execPath ?? process.execPath);
116
+ if (nodeDir !== ownBin && await executable(join(nodeDir, "npm")))
117
+ candidates.push({ npmDir: nodeDir, label: `${join(nodeDir, "npm")} (beside the Node running AgEnD)` });
118
+ const onPath = await firstNpmOnPath(pathEnv);
119
+ if (onPath && dirname(onPath) !== ownBin && dirname(onPath) !== nodeDir)
120
+ candidates.push({ npmDir: dirname(onPath), label: `${onPath} (first on PATH, ahead of ${ownBin})` });
121
+ const tried = [];
122
+ const realRoot = async (answer) => {
123
+ if (!answer)
124
+ return null;
125
+ try {
126
+ return await deps.realpath(answer.root);
127
+ }
128
+ catch {
129
+ return answer.root;
130
+ }
131
+ };
132
+ for (const c of candidates) {
133
+ const answer = await askNpm(deps, { PATH: [c.npmDir, ownBin, pathEnv].filter(Boolean).join(delimiter) });
134
+ const root = await realRoot(answer);
135
+ tried.push(`${c.label} → ${root ?? "no answer"}`);
136
+ if (!answer || root !== expected)
137
+ continue;
138
+ // #3443 review: the launch's `${1%/*}` is the bin of the prefix npm REPORTS (agend = <prefix>/bin/agend), which a
139
+ // symlinked prefix makes differ from the bin guessed from the real root. Proved again in that exact PATH, or refused.
140
+ const launchBin = join(answer.prefix, "bin");
141
+ if (launchBin !== ownBin) {
142
+ const again = await askNpm(deps, { PATH: [c.npmDir, launchBin, pathEnv].filter(Boolean).join(delimiter) });
143
+ const againRoot = await realRoot(again);
144
+ if (!again || againRoot !== expected || again.prefix !== answer.prefix) {
145
+ tried.push(`${c.label}, in the launch PATH (${launchBin} first) → ${againRoot ?? "no answer"}`);
146
+ continue;
147
+ }
148
+ }
149
+ return { ...answer, ...(c.npmDir ? { npmDir: c.npmDir } : {}) };
34
150
  }
35
- const pkgDir = join(last(root.stdout), "@songsid", "agend");
151
+ return { reason: `no npm here manages the running AgEnD: expected the npm whose global root is ${expected} (tried ${tried.join("; ")})` };
152
+ }
153
+ /** npm's global root and prefix → the installed package, its bin target, and the bin link that must lead to it. */
154
+ export async function resolveInstalledAgend(deps = defaultDispatchDeps) {
155
+ const found = await npmForRunningInstall(deps);
156
+ if ("reason" in found)
157
+ return { ok: false, reason: found.reason };
158
+ const pkgDir = join(found.root, "@songsid", "agend");
36
159
  const notAgend = { ok: false, reason: `${pkgDir} is not an installed AgEnD package` };
37
160
  let parsed;
38
161
  try {
@@ -50,7 +173,7 @@ export async function resolveInstalledAgend(deps = defaultDispatchDeps) {
50
173
  : typeof bin === "object" && bin !== null && !Array.isArray(bin) && typeof bin.agend === "string" ? bin.agend : null;
51
174
  if (manifest.name !== "@songsid/agend" || typeof manifest.version !== "string" || !manifest.version || !binRel)
52
175
  return notAgend;
53
- const agend = join(last(prefix.stdout), "bin", "agend");
176
+ const agend = join(found.prefix, "bin", "agend");
54
177
  let target, linked;
55
178
  try {
56
179
  [target, linked] = await Promise.all([deps.realpath(join(pkgDir, binRel)), deps.realpath(agend)]);
@@ -60,14 +183,21 @@ export async function resolveInstalledAgend(deps = defaultDispatchDeps) {
60
183
  }
61
184
  if (target !== linked)
62
185
  return { ok: false, reason: `${agend} leads to ${linked}, not the installed package's ${target}` };
63
- return { ok: true, agend, version: manifest.version };
186
+ return { ok: true, agend, version: manifest.version, ...(found.npmDir ? { npmDir: found.npmDir } : {}) };
64
187
  }
65
188
  /**
66
189
  * `<installed agend> update`, 2 s from now, from a detached `sh`. Service callers must wrap it in an independent scope before launch. The
67
- * path is a positional argument, never spliced into the script.
190
+ * path is a positional argument, never spliced into the script. #3440: the agend's own bin directory (`<prefix>/bin`,
191
+ * where its `npm` and `node` live) goes first on PATH, so the CLI's npm checks and install use the npm that installed
192
+ * it, not a system npm the service's PATH happens to list first. (From the 雲晴家 fleet operator's patch.) That also puts
193
+ * every global package's bin ahead of the system tools for the updater's run — as in an nvm user's own shell.
68
194
  */
69
- export const DELAYED_UPDATE_SCRIPT = 'sleep 2 && exec "$1" update';
70
- export function updateCommand(agend) {
71
- return { command: "sh", args: ["-c", DELAYED_UPDATE_SCRIPT, "sh", agend] };
195
+ export const DELAYED_UPDATE_SCRIPT = 'sleep 2 && PATH="${1%/*}:$PATH" && export PATH && exec "$1" update';
196
+ /** #3443 review: with the proving npm's directory (`$2`, data) ahead of the agend's own — it may hold no npm (a custom prefix). */
197
+ export const DELAYED_UPDATE_SCRIPT_NPM = 'sleep 2 && PATH="$2:${1%/*}:$PATH" && export PATH && exec "$1" update';
198
+ export function updateCommand(agend, npmDir) {
199
+ return npmDir && isAbsolute(npmDir)
200
+ ? { command: "sh", args: ["-c", DELAYED_UPDATE_SCRIPT_NPM, "sh", agend, npmDir] }
201
+ : { command: "sh", args: ["-c", DELAYED_UPDATE_SCRIPT, "sh", agend] };
72
202
  }
73
203
  //# sourceMappingURL=update-dispatch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-dispatch.js","sourceRoot":"","sources":["../src/update-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAQtC,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC/C,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QA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M,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IAC1G,MAAM,CAAC;QAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,yCAAyC,EAAE,CAAC;IAAC,CAAC;IAC1F,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,aAAa,MAAM,iCAAiC,MAAM,EAAE,EAAE,CAAC;IAC1H,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3G,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oEAAoE,CAAC;AAC1G,mIAAmI;AACnI,MAAM,CAAC,MAAM,yBAAyB,GAAG,uEAAuE,CAAC;AACjH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAe;IAC1D,OAAO,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;QACjC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE;QACjF,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC"}
@@ -69,7 +69,7 @@ export type UpdateLaunch = {
69
69
  reason: string;
70
70
  };
71
71
  /** Same UID, no privileged or remote manager, no credentials in argv. No unsafe detached fallback. */
72
- export declare function resolveUpdateLaunch(agend: string, deps?: UpdateLaunchDeps): Promise<UpdateLaunch>;
72
+ export declare function resolveUpdateLaunch(agend: string, deps?: UpdateLaunchDeps, npmDir?: string): Promise<UpdateLaunch>;
73
73
  /** Spawn/manager refusal and nonzero updater exit are visible; exit 75 is the existing pending hand-off. */
74
74
  export declare function watchUpdateLaunch(child: Pick<ChildProcess, "once">, fail: (message: string) => void, logPath?: string,
75
75
  /** Byte offset into the log file at which this run's output begins. */
@@ -201,8 +201,8 @@ export function inServiceCgroup(text) {
201
201
  return manager === null ? null : manager !== false;
202
202
  }
203
203
  /** Same UID, no privileged or remote manager, no credentials in argv. No unsafe detached fallback. */
204
- export async function resolveUpdateLaunch(agend, deps = defaultUpdateLaunchDeps) {
205
- const plain = updateCommand(agend);
204
+ export async function resolveUpdateLaunch(agend, deps = defaultUpdateLaunchDeps, npmDir) {
205
+ const plain = updateCommand(agend, npmDir);
206
206
  if (deps.platform !== "linux")
207
207
  return { ok: true, ...plain };
208
208
  let before;