@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
package/dist/daemon.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { nativePaneToolRefusal } from "./native-pane-tools.js";
2
2
  import { generalByName } from "./general-instance.js";
3
+ import { claudeMinimumError, cliVersionBelow } from "./claude-model-minimum.js";
3
4
  import { quotaNoticeProblem } from "./quota-notice-config.js";
4
5
  import { quotaHistoryCount, quotaAfterInput } from "./pane-quota-history.js";
5
6
  import { dialogScreenText } from "./dialog-screen-text.js";
@@ -199,20 +200,20 @@ export function sameProjectFamily(a, b) {
199
200
  const fx = family(x), fy = family(y);
200
201
  return fx.length > 0 && fx === fy;
201
202
  }
203
+ /** At most this many fleet decisions, and this many team + directory ones, in one instance's Active Decisions. */
204
+ export const ACTIVE_DECISION_CAPS = { fleet: 20, scoped: 20 };
202
205
  /**
203
- * Pick the decisions worth injecting into one instance's system prompt.
204
- *
205
- * `scope: "fleet"` previously bypassed the project check outright, so every
206
- * instance carried every other project's playbook — measured at 8 of 14 here,
207
- * resent on every API call. A fleet decision must now also be relevant: global
208
- * (no project_root), the same project, or the same project family.
209
- *
210
- * `isDispatcher` (a general) opts out of that narrowing on purpose: it routes
211
- * work across all projects, so cross-project rules ("X 文件操作由 Y 負責") are
212
- * precisely what it must know. Narrowing a general would cause misrouting.
206
+ * Bound an instance's already-selected decisions (newest first, as the store orders them): fleet ones and its own team
207
+ * and directory ones are capped apart, AFTER selection, so nobody else's rows take an instance's places.
213
208
  */
214
- export function selectRelevantDecisions(all, workDir, isDispatcher = false) {
209
+ export function capActiveDecisions(selected) {
210
+ let fleet = 0, scoped = 0;
211
+ return selected.filter(d => d.scope === "fleet" ? fleet++ < ACTIVE_DECISION_CAPS.fleet : scoped++ < ACTIVE_DECISION_CAPS.scoped);
212
+ }
213
+ export function selectRelevantDecisions(all, workDir, isDispatcher = false, teams = []) {
215
214
  return all.filter(d => {
215
+ if (d.scope === "team")
216
+ return !!d.team && teams.includes(d.team);
216
217
  if (d.project_root === workDir)
217
218
  return true; // own project, any scope
218
219
  if (d.scope !== "fleet")
@@ -1552,6 +1553,12 @@ export class Daemon extends EventEmitter {
1552
1553
  * when a startup scan reaches a real ready prompt, or on wake().
1553
1554
  */
1554
1555
  fatalStartupBlocked = false;
1556
+ /** #3441: one repair budget survives every automatic spawn on this daemon. */
1557
+ modelMinimumRepairUsed = false;
1558
+ modelMinimumFlight = null;
1559
+ modelMinimumBlocked = false;
1560
+ modelMinimumUpdateNotified = false;
1561
+ cliRepairSessionId;
1555
1562
  /** model_error seen mid-turn: notify only if it survives to the idle screen. */
1556
1563
  pendingModelErrorKey = null;
1557
1564
  /** Optional per-instance localhost relay used to observe Muse usage events. */
@@ -2229,6 +2236,12 @@ export class Daemon extends EventEmitter {
2229
2236
  }
2230
2237
  /** The fleet's other same-backend instances' working directories, read at spawn (#984). */
2231
2238
  peerWorkingDirectories;
2239
+ /** This instance's teams (fleet.yaml), read at each spawn: their team decisions join its Active Decisions. */
2240
+ decisionTeams;
2241
+ setDecisionTeams(teams) { this.decisionTeams = teams; }
2242
+ /** The fleet's active decisions (startup snapshot), read at each spawn; absent: the AGEND_DECISIONS env (tests). */
2243
+ decisionSource;
2244
+ setDecisionSource(source) { this.decisionSource = source; }
2232
2245
  setPeerWorkingDirectories(peers) {
2233
2246
  this.peerWorkingDirectories = peers;
2234
2247
  }
@@ -4719,6 +4732,14 @@ export class Daemon extends EventEmitter {
4719
4732
  }
4720
4733
  /** Arm the recovery gates and emit one detected error pattern. */
4721
4734
  emitErrorPattern(ep, key, pane, now) {
4735
+ const minimum = !this.nativePaneLifecycle && this.backend?.binaryName === "claude" && ep.type === "outdated_cli" ? claudeMinimumError(pane) : null;
4736
+ if (minimum) {
4737
+ this.lastErrorNotifiedAt.set(key, now);
4738
+ void this.handleClaudeModelMinimum(minimum).catch(err => {
4739
+ this.logger.warn({ reason: String(err) }, "CLI launch repair failed");
4740
+ });
4741
+ return;
4742
+ }
4722
4743
  // #2795: auth text on the pane proves nothing about the credentials (22 of 22 such matches on the main host were
4723
4744
  // conversation text). It arms nothing here; it only asks the lifecycle's token-free check, and a failing check
4724
4745
  // arms the auth state through confirmAuthFailure().
@@ -10275,9 +10296,9 @@ export class Daemon extends EventEmitter {
10275
10296
  * moment the flag clears.
10276
10297
  */
10277
10298
  refuseFatalStartupDelivery(verdict, status) {
10278
- if (!this.fatalStartupBlocked)
10299
+ if (!this.fatalStartupBlocked && !this.modelMinimumBlocked)
10279
10300
  return false;
10280
- this.logger.error("Delivery refused — CLI is parked on a fatal startup screen");
10301
+ this.logger.error("Delivery refused — CLI startup or model-version repair is held");
10281
10302
  this.failDelivery(verdict, status, "fatal-startup", "blocked-before-write");
10282
10303
  return true;
10283
10304
  }
@@ -12510,9 +12531,10 @@ export class Daemon extends EventEmitter {
12510
12531
  // Comma-separated parts (`file:role.md, file:rules.md`) only when a part is a file ref; otherwise one inline prompt.
12511
12532
  const resolvedCustomPrompt = this.config.systemPrompt ? assembleSystemPrompt(this.config.systemPrompt, promptFiles) : undefined;
12512
12533
  let decisions;
12513
- if (process.env.AGEND_DECISIONS) {
12534
+ const source = this.decisionSource;
12535
+ if (source || process.env.AGEND_DECISIONS) {
12514
12536
  try {
12515
- const all = JSON.parse(process.env.AGEND_DECISIONS);
12537
+ const all = source ? source() : JSON.parse(process.env.AGEND_DECISIONS);
12516
12538
  const workDir = this.config.working_directory;
12517
12539
  // `scope: "fleet"` used to bypass the project check entirely, so a
12518
12540
  // single-project worker inherited every other project's playbook (8 of
@@ -12521,7 +12543,12 @@ export class Daemon extends EventEmitter {
12521
12543
  // same project, or the same project family (worktrees/checkouts of one
12522
12544
  // repo). A general is exempt: it dispatches across all projects, so
12523
12545
  // cross-project routing rules are exactly what it needs.
12524
- decisions = selectRelevantDecisions(all, workDir, this.config.general_topic === true);
12546
+ let teams = [];
12547
+ try {
12548
+ teams = this.decisionTeams?.() ?? [];
12549
+ }
12550
+ catch { /* no team list: fleet and project decisions only */ }
12551
+ decisions = capActiveDecisions(selectRelevantDecisions([...all], workDir, this.config.general_topic === true, teams));
12525
12552
  // Stable ordering so identical decision sets always build byte-identical
12526
12553
  // instructions — otherwise source ordering jitter flips the warmup hash.
12527
12554
  decisions.sort((a, b) => a.title.localeCompare(b.title));
@@ -12641,6 +12668,7 @@ export class Daemon extends EventEmitter {
12641
12668
  effort: this.config.effort,
12642
12669
  kiroUi: this.config.kiro_ui,
12643
12670
  skipResume: this.skipResume,
12671
+ ...(this.cliRepairSessionId ? { resumeSessionId: this.cliRepairSessionId } : {}),
12644
12672
  instructions,
12645
12673
  agentMode: isCliMode ? "cli" : "mcp",
12646
12674
  agentPort: isCliMode ? agentPort : undefined,
@@ -13643,14 +13671,14 @@ export class Daemon extends EventEmitter {
13643
13671
  * Handles confirmation dialogs (trust folder, bypass permissions).
13644
13672
  * Returns true if CLI is ready, false if it failed or got stuck.
13645
13673
  */
13646
- async trySpawn(reuseWindow = false, startupTimeoutMs) {
13674
+ async trySpawn(reuseWindow = false, startupTimeoutMs, repairAdmission) {
13647
13675
  const recoveryOwner = this.collateralOomRecovery ? this.interactionOwner() : null;
13648
13676
  const enter = () => {
13649
13677
  if (recoveryOwner && (!sameInteractionOwner(recoveryOwner, this.interactionOwner())
13650
13678
  || this.startupAborted || this.deliveryWritesStopping || this.runtimeMonitorsFrozen || this.healthCheckPaused)) {
13651
13679
  throw new Error("OOM recovery cancelled: the instance was stopped, paused or replaced while memory was unavailable");
13652
13680
  }
13653
- return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs).catch(err => {
13681
+ return this.trySpawnInsideGate(reuseWindow, startupTimeoutMs, repairAdmission).catch(err => {
13654
13682
  // Includes an in-place binary replacement during asynchronous launch preparation.
13655
13683
  if (err instanceof KiroCompatibilityError)
13656
13684
  this.emit("kiro_compatibility_hold", err.message);
@@ -13675,6 +13703,122 @@ export class Daemon extends EventEmitter {
13675
13703
  this.startupAdmission?.();
13676
13704
  return ready;
13677
13705
  }
13706
+ /** Resolve the installed launcher; never run Claude to discover its version. */
13707
+ async resolveClaudeInstallPath() {
13708
+ const { binaryProbe } = await import("./binary-probe.js");
13709
+ const { resolveBackendBinary } = await import("./backend-availability.js");
13710
+ binaryProbe.invalidate("claude");
13711
+ return await resolveBackendBinary("claude-code") ?? null;
13712
+ }
13713
+ async installedClaudeVersion(path) {
13714
+ const { staticBackendVersion } = await import("./backend-availability.js");
13715
+ return staticBackendVersion("claude-code", path);
13716
+ }
13717
+ /** #3441: only the CLI's own refusal can request this one, non-renewable repair. */
13718
+ handleClaudeModelMinimum(minimum) {
13719
+ if (this.modelMinimumRepairUsed || this.modelMinimumBlocked || this.spawning || this.healthCheckPaused
13720
+ || this.pauseWakeState !== "active" || this.backend?.binaryName !== "claude"
13721
+ || !this.backend.refreshLaunchBinary)
13722
+ return Promise.resolve();
13723
+ if (this.modelMinimumFlight)
13724
+ return this.modelMinimumFlight;
13725
+ const flight = this.repairClaudeModelMinimum(minimum).finally(() => {
13726
+ if (this.modelMinimumFlight === flight)
13727
+ this.modelMinimumFlight = null;
13728
+ });
13729
+ this.modelMinimumFlight = flight;
13730
+ return flight;
13731
+ }
13732
+ async repairClaudeModelMinimum(minimum) {
13733
+ const tmux = this.tmux, backend = this.backend, window = tmux?.getWindowId();
13734
+ let spawn = this.spawnGeneration, claimed = false;
13735
+ const fence = this.launchFenceEpoch, attempt = this.launchAttempt, phase = this.pauseWakeState;
13736
+ const baseCurrent = () => this.tmux === tmux && this.backend === backend && tmux?.getWindowId() === window
13737
+ && this.spawnGeneration === spawn && this.launchFenceEpoch === fence && this.pauseWakeState === phase
13738
+ && !this.startupAborted && !this.deliveryWritesStopping && !this.runtimeMonitorsFrozen && !this.healthCheckPaused;
13739
+ const current = () => baseCurrent() && this.launchAttempt === attempt;
13740
+ const failed = () => new Error(t("inst.cli_repair_failed"));
13741
+ try {
13742
+ // Read the newly resolved install, not a cached old prefix or the running image.
13743
+ const path = await this.resolveClaudeInstallPath();
13744
+ if (!current())
13745
+ return;
13746
+ const version = path ? await this.installedClaudeVersion(path) : null;
13747
+ if (!current())
13748
+ return;
13749
+ if (!version || cliVersionBelow(version, minimum.required)) {
13750
+ if (!this.modelMinimumUpdateNotified) {
13751
+ this.modelMinimumUpdateNotified = true;
13752
+ this.logger.warn({ required: minimum.required, installed: version }, "Claude Code needs an update for this model");
13753
+ this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_update_needed", minimum.required) });
13754
+ }
13755
+ return;
13756
+ }
13757
+ await this.paneWriteLock.run(async () => {
13758
+ if (!current())
13759
+ return;
13760
+ if (!await this.isPaneAuthoritativelyIdle())
13761
+ throw failed();
13762
+ if (!current())
13763
+ return;
13764
+ // Claim before yielding the write lock; queued delivery remains held until readiness settles.
13765
+ this.modelMinimumRepairUsed = true;
13766
+ this.beginSpawn();
13767
+ claimed = true;
13768
+ spawn = this.spawnGeneration;
13769
+ });
13770
+ if (!claimed || !current())
13771
+ return;
13772
+ await this.checkpointSessionId();
13773
+ if (!current())
13774
+ return;
13775
+ let session;
13776
+ if (!this.skipResume) {
13777
+ try {
13778
+ const value = readFileSync(join(this.instanceDir, "session-id"), "utf8").trim();
13779
+ if (/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(value))
13780
+ session = value;
13781
+ }
13782
+ catch { /* Unknown is not permission to select another conversation. */ }
13783
+ }
13784
+ if (!session)
13785
+ throw failed();
13786
+ // Recheck disk evidence after checkpointing; an update may have changed it while we waited.
13787
+ const finalVersion = await this.installedClaudeVersion(path);
13788
+ if (!current())
13789
+ return;
13790
+ if (!finalVersion || cliVersionBelow(finalVersion, minimum.required))
13791
+ throw failed();
13792
+ if (!await this.isPaneAuthoritativelyIdle())
13793
+ throw failed();
13794
+ if (!current())
13795
+ return;
13796
+ this.logger.warn({ running: minimum.running, required: minimum.required, installed: finalVersion }, "Claude model-version refusal — attempting one same-session restart");
13797
+ backend.refreshLaunchBinary(path);
13798
+ this.cliRepairSessionId = session;
13799
+ const ready = await this.trySpawn(true, this.startupBudgetFor(true), next => baseCurrent() && this.launchAttempt === next && next >= attempt && next <= attempt + 1);
13800
+ this.cliRepairSessionId = undefined;
13801
+ if (!baseCurrent() || this.launchAttempt !== attempt + 1)
13802
+ return;
13803
+ if (!ready)
13804
+ throw failed();
13805
+ this.logger.info("Claude model-version restart completed; session retained");
13806
+ this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repaired") });
13807
+ }
13808
+ catch (error) {
13809
+ if (!baseCurrent() || this.launchAttempt > attempt + 1)
13810
+ return;
13811
+ this.modelMinimumBlocked = true;
13812
+ this.healthCheckPaused = true;
13813
+ this.logger.error({ reason: error instanceof Error ? error.message : String(error) }, "Claude model-version repair held; no automatic retry");
13814
+ this.emit("backend_launch_warning", { name: this.name, message: t("inst.cli_repair_failed") });
13815
+ }
13816
+ finally {
13817
+ this.cliRepairSessionId = undefined;
13818
+ if (claimed)
13819
+ this.endSpawn();
13820
+ }
13821
+ }
13678
13822
  /**
13679
13823
  * One fresh pane capture judged as ready && !busy && !dialog. Transcript
13680
13824
  * silence is deliberately NOT the gate: its monitor is inert for muse, so a
@@ -13873,11 +14017,14 @@ export class Daemon extends EventEmitter {
13873
14017
  this.logger.debug({ err }, "what's-new not prepared");
13874
14018
  }
13875
14019
  }
13876
- async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs) {
14020
+ async trySpawnInsideGate(reuseWindow = false, startupTimeoutMs, repairAdmission) {
13877
14021
  if (this.nativePaneLifecycle)
13878
14022
  throw Error("Native relaunch requires its owned exit and a new lifecycle reservation");
14023
+ let expectedAttempt = this.launchAttempt;
14024
+ const admit = () => { this.startupAdmission?.(); if (repairAdmission && !repairAdmission(expectedAttempt))
14025
+ throw new Error("CLI repair superseded by another launch, pause or stop"); };
13879
14026
  this.assertSessionOomAdmission();
13880
- this.startupAdmission?.();
14027
+ admit();
13881
14028
  const launchFence = this.launchFenceEpoch;
13882
14029
  const backendConfig = this.buildBackendConfig();
13883
14030
  // A compatibility refusal is not a failed resume: no configuration, pin, history or pane may change.
@@ -13903,7 +14050,7 @@ export class Daemon extends EventEmitter {
13903
14050
  catch { /* unknown capability → the backend's conservative form */ }
13904
14051
  // Thrown, not `false`: a false verdict reads as "the CLI failed to start" and sends the startup path
13905
14052
  // into its resume-retry / set-the-session-aside handling, for an instance somebody just stopped.
13906
- this.startupAdmission?.();
14053
+ admit();
13907
14054
  this.assertSessionOomAdmission();
13908
14055
  if (launchFence !== this.launchFenceEpoch)
13909
14056
  throw new Error("Launch cancelled: the instance was stopped or paused while the launch was being prepared");
@@ -13962,13 +14109,14 @@ export class Daemon extends EventEmitter {
13962
14109
  // The CLI's own shell sets a zero coredump_filter first (#1113): this pane
13963
14110
  // may belong to a tmux server the fleet did not start, which would hand
13964
14111
  // the CLI its own (full) filter instead of the fleet's.
13965
- this.startupAdmission?.();
14112
+ admit();
13966
14113
  const cmd = coredumpFilterLaunchPrefix() + `${envPrefix} ` + this.backend.buildCommand(launchConfig);
13967
14114
  // Every launched command re-arms the passive-transient check, including a
13968
14115
  // retry inside the same spawn: its load is a new one.
13969
- this.launchAttempt++;
14116
+ expectedAttempt = ++this.launchAttempt;
14117
+ admit();
13970
14118
  await this.prepareQuotaReplayHistory(reuseWindow);
13971
- this.startupAdmission?.();
14119
+ admit();
13972
14120
  this.interactionObservation.reset(this.interactionOwner());
13973
14121
  this.clearInteractionConfirmation();
13974
14122
  // A launch that cannot paint a passive transient (Codex: a fresh start
@@ -13992,12 +14140,12 @@ export class Daemon extends EventEmitter {
13992
14140
  if (this.stormWindow?.observeServerAlive(await this.paneHost.getServerPid(this.tmuxSessionName))) {
13993
14141
  this.emit("tmux_server_crash", this.name);
13994
14142
  }
13995
- this.startupAdmission?.();
14143
+ admit();
13996
14144
  let windowId;
13997
14145
  this.assertSessionOomAdmission();
13998
14146
  if (reuseWindow) {
13999
14147
  this.controlClient?.unregisterWindow(this.tmux.getWindowId());
14000
- await this.tmux.respawnWindow(cmd, resolvedCwd);
14148
+ await this.tmux.respawnWindow(cmd, resolvedCwd, repairAdmission ? admit : undefined);
14001
14149
  windowId = this.tmux.getWindowId();
14002
14150
  }
14003
14151
  else {
@@ -14008,7 +14156,7 @@ export class Daemon extends EventEmitter {
14008
14156
  if (retired && retired !== windowId)
14009
14157
  this.controlClient?.unregisterWindow(retired);
14010
14158
  }
14011
- this.startupAdmission?.();
14159
+ admit();
14012
14160
  this.writeWindowId(windowId);
14013
14161
  // Enable remain-on-exit to capture exit codes on crash
14014
14162
  await this.tmux.setRemainOnExit().catch(err => {
@@ -14043,6 +14191,7 @@ export class Daemon extends EventEmitter {
14043
14191
  else {
14044
14192
  await new Promise(r => setTimeout(r, 10_000));
14045
14193
  }
14194
+ admit();
14046
14195
  // Dismiss confirmation dialogs and verify CLI reached prompt.
14047
14196
  // With remain-on-exit, isWindowAlive() returns true even for dead panes,
14048
14197
  // but a startup crash would already be caught by waitForOutput/waitForIdle above.