@desplega.ai/agent-swarm 2.7.10 → 2.8.0

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 (281) hide show
  1. package/dist/acp-adapter-t949vbbp.js +15 -0
  2. package/dist/{actions-b8aqhrsg.js → actions-7e9czc7s.js} +18 -19
  3. package/dist/{amp-adapter-4c165vgn.js → amp-adapter-gv6cbb7d.js} +2 -3
  4. package/dist/{app-m9khefrh.js → app-b9fbkp9v.js} +3 -3
  5. package/dist/{assistant-rh4v3ntz.js → assistant-wjb7v4c7.js} +20 -21
  6. package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-2t37e0fe.js} +1 -1
  7. package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-a35nkyr1.js} +1 -1
  8. package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-gka3zas7.js} +1 -1
  9. package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-65sdnp6c.js} +3 -3
  10. package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-x42tzytw.js} +4 -5
  11. package/dist/{claude-adapter-s5df247c.js → claude-adapter-v221b2fd.js} +7 -8
  12. package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-29eq09wd.js} +2 -2
  13. package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-9m6450zk.js} +2 -2
  14. package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-0q0ptaba.js} +9066 -8818
  15. package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
  16. package/dist/{cli-5wfz00be.js → cli-0jzra9ad.js} +2 -2
  17. package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
  18. package/dist/{cli-eqk5p56g.js → cli-2wnq8jkz.js} +9 -9
  19. package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
  20. package/dist/{cli-rt0ag4x1.js → cli-334z18y3.js} +4 -4
  21. package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
  22. package/dist/{cli-3xddv0rk.js → cli-4txa0ter.js} +5 -7
  23. package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
  24. package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
  25. package/dist/{cli-n07eecjs.js → cli-6t09sdhy.js} +3 -3
  26. package/dist/{cli-38yww4e9.js → cli-6wxjceza.js} +8 -8
  27. package/dist/{cli-5xcb8gxq.js → cli-7b8sbmag.js} +8 -8
  28. package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
  29. package/dist/{cli-mp9aa8g5.js → cli-7p1kvkck.js} +6 -6
  30. package/dist/{cli-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
  31. package/dist/{cli-n9abj89w.js → cli-8fknbnhw.js} +8 -8
  32. package/dist/{cli-xd5ebp64.js → cli-8kzasymh.js} +3 -3
  33. package/dist/{cli-2tsfpc70.js → cli-a7wvp2km.js} +1 -1
  34. package/dist/{cli-kx4c8j05.js → cli-abejgen1.js} +63 -19
  35. package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
  36. package/dist/{cli-yz7v0sh4.js → cli-c55z5chy.js} +4 -6
  37. package/dist/{cli-18qt3few.js → cli-deefvewm.js} +1 -1
  38. package/dist/{cli-jg24scat.js → cli-ee0b971j.js} +3 -3
  39. package/dist/cli-f3vq58d2.js +242 -0
  40. package/dist/{cli-3xcwp3z8.js → cli-ffhtssbp.js} +2 -2
  41. package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
  42. package/dist/{cli-g1px1g2e.js → cli-gxkx0zzp.js} +1 -1
  43. package/dist/{cli-j7d73g1y.js → cli-h38x262p.js} +3035 -354
  44. package/dist/{cli-zjphdj1a.js → cli-j790gp2w.js} +40 -18
  45. package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
  46. package/dist/{cli-td33w98c.js → cli-m23zjcy2.js} +10 -10
  47. package/dist/{cli-8ewkreqd.js → cli-m28atx8q.js} +7 -9
  48. package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
  49. package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
  50. package/dist/{cli-mr97t7cc.js → cli-p1bq50aa.js} +263 -14
  51. package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
  52. package/dist/{cli-nj3x45rw.js → cli-p2gfst4m.js} +52 -43
  53. package/dist/{cli-z9cs5m0w.js → cli-pasjcnmj.js} +12 -12
  54. package/dist/{cli-an1knn2k.js → cli-qa4wdgsy.js} +5 -5
  55. package/dist/{cli-xncjscpm.js → cli-qfedvmcr.js} +50 -24
  56. package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
  57. package/dist/{cli-bxz823sz.js → cli-qsnnd04k.js} +1 -1
  58. package/dist/{cli-cr14kftt.js → cli-qwca7s44.js} +3 -3
  59. package/dist/{cli-7wz05bx3.js → cli-rfywm85n.js} +460 -737
  60. package/dist/{cli-v2fwbnsk.js → cli-rmmpt0wm.js} +6 -6
  61. package/dist/{cli-xbtq4d6s.js → cli-rzsy6nc6.js} +12 -8
  62. package/dist/{cli-0m7rtm11.js → cli-s7t6p9my.js} +1 -1
  63. package/dist/{cli-16phend6.js → cli-sdtt3men.js} +1 -1
  64. package/dist/{cli-pyrxt9gw.js → cli-tk7cjj8h.js} +1 -1
  65. package/dist/{cli-xvymtmv4.js → cli-tqegb8eq.js} +3 -3
  66. package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
  67. package/dist/{cli-h49ejvmc.js → cli-wcg8x116.js} +1 -1
  68. package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
  69. package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
  70. package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
  71. package/dist/{cli-eb2azq8n.js → cli-y97qxcfx.js} +9 -9
  72. package/dist/{cli-55bkx8hh.js → cli-yq3zak69.js} +1 -1
  73. package/dist/cli.js +17 -17
  74. package/dist/{codex-adapter-yr60sme6.js → codex-adapter-30j9bpzd.js} +5 -6
  75. package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
  76. package/dist/{codex-session-runner-pch8x584.js → codex-session-runner-8vp57v8w.js} +5 -6
  77. package/dist/{commands-phjfbkv0.js → commands-bngnz9g7.js} +3 -3
  78. package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
  79. package/dist/{controllers-connect-c4448kwa.js → controllers-connect-e2b4gyxc.js} +19 -20
  80. package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
  81. package/dist/{db-ez6egt6v.js → db-bgm7vkc0.js} +3 -3
  82. package/dist/{db-ef32tbfc.js → db-c6np41ca.js} +10 -2
  83. package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
  84. package/dist/{dispatcher-g3tt9hs9.js → dispatcher-jnybck15.js} +17 -18
  85. package/dist/{dsh-adapter-tcyn3099.js → dsh-adapter-nrhbrjz8.js} +1 -2
  86. package/dist/{easter-egg-3d-e36hk5td.js → easter-egg-3d-533knw22.js} +1 -1
  87. package/dist/{embedding-space-4kyh5qqj.js → embedding-space-crsm2zp0.js} +6 -6
  88. package/dist/{embeddings-6a8v4a6t.js → embeddings-e7z3f27f.js} +1 -1
  89. package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
  90. package/dist/{external-channel-se646snz.js → external-channel-m77wf5z3.js} +2 -2
  91. package/dist/{fx-adapter-yw795hqq.js → fx-adapter-b6w0kf56.js} +7 -8
  92. package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-4sqtebdk.js} +7 -8
  93. package/dist/handlers-kdjcyzdj.js +32 -0
  94. package/dist/heartbeat-xgb036sx.js +43 -0
  95. package/dist/{hook-g3nhexsy.js → hook-5h02c9ga.js} +6 -6
  96. package/dist/{hook-hq93y5ej.js → hook-xsk1jbha.js} +5 -5
  97. package/dist/{http-5a9p4h6y.js → http-txe7qhvn.js} +282 -140
  98. package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
  99. package/dist/index-835xdgnm.js +33 -0
  100. package/dist/index-d469300x.js +37 -0
  101. package/dist/index-rzqwp11g.js +32 -0
  102. package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
  103. package/dist/{index-hgn3c961.js → index-vk63emp7.js} +978 -35
  104. package/dist/{index-3c5pxbge.js → index-ysvbhg5m.js} +1 -1
  105. package/dist/{keepalive-1j4n4dmk.js → keepalive-4zsrce78.js} +3 -3
  106. package/dist/lead-yqt47dkr.js +70 -0
  107. package/dist/{maintenance-dmghacy5.js → maintenance-86jvartk.js} +1 -1
  108. package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-j52kg9pr.js} +2 -2
  109. package/dist/{onboard-52f9t5dm.js → onboard-c2aj5p8q.js} +3 -3
  110. package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
  111. package/dist/{otel-impl-xjqz6wjj.js → otel-impl-yyy203z8.js} +1 -1
  112. package/dist/{pi-mono-adapter-dbxyp0qv.js → pi-mono-adapter-546cd1cc.js} +9 -9
  113. package/dist/{pricing-refresh-ctdr74pd.js → pricing-refresh-1rgzqyzz.js} +2 -3
  114. package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-e70xfeyj.js} +4 -6
  115. package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-q89qe8er.js} +3 -3
  116. package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
  117. package/dist/{render-v2-5b6chvcq.js → render-v2-k6tt107q.js} +3 -3
  118. package/dist/{resume-5a5d2845.js → resume-cnnrjfxa.js} +6 -6
  119. package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
  120. package/dist/{session-access-gj0bjhqg.js → session-access-xkxkjw3n.js} +4 -4
  121. package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-1d5pdwww.js} +2 -2
  122. package/dist/{setup-7ssfakk1.js → setup-se8q7gkc.js} +1 -1
  123. package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
  124. package/dist/{work-objects-bf3syvhq.js → work-objects-1kxnbzy5.js} +20 -21
  125. package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-zqm8apt4.js} +17 -18
  126. package/dist/worker-j6xxtq7p.js +70 -0
  127. package/openapi.json +334 -7
  128. package/package.json +4 -4
  129. package/src/apps/definition.ts +11 -0
  130. package/src/apps/store.ts +28 -8
  131. package/src/be/db/model-profiles.ts +147 -38
  132. package/src/be/db/tasks/read.ts +5 -1
  133. package/src/be/db/workflow-run-definitions.ts +117 -0
  134. package/src/be/db.ts +24 -3
  135. package/src/be/memory/constants.ts +14 -1
  136. package/src/be/memory/key-paths.ts +8 -0
  137. package/src/be/memory/providers/sqlite-store.ts +160 -10
  138. package/src/be/memory/task-learning.ts +79 -14
  139. package/src/be/memory/types.ts +24 -1
  140. package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
  141. package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
  142. package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
  143. package/src/be/model-profile-check.ts +284 -0
  144. package/src/be/model-tier-resolution.ts +112 -12
  145. package/src/be/multi-runtime.ts +27 -0
  146. package/src/be/runtime-pools/routing.ts +52 -4
  147. package/src/be/scripts/typecheck.ts +1 -0
  148. package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
  149. package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
  150. package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
  151. package/src/be/seed-scripts/index.ts +9 -0
  152. package/src/be/steering.ts +8 -2
  153. package/src/commands/onboard/agent-fs-version.ts +1 -1
  154. package/src/commands/runner.ts +32 -1
  155. package/src/fs/provider.ts +17 -3
  156. package/src/heartbeat/heartbeat.ts +12 -1
  157. package/src/heartbeat/index.ts +1 -0
  158. package/src/http/agents.ts +56 -4
  159. package/src/http/apps.ts +3 -1
  160. package/src/http/config.ts +2 -6
  161. package/src/http/index.ts +2 -3
  162. package/src/http/model-profiles.ts +58 -10
  163. package/src/http/poll.ts +36 -3
  164. package/src/http/schedules.ts +42 -3
  165. package/src/http/tasks.ts +37 -12
  166. package/src/http/workflows.ts +15 -2
  167. package/src/prompts/session-templates.ts +1 -1
  168. package/src/providers/acp-targets.ts +11 -6
  169. package/src/providers/amp-adapter.ts +1 -1
  170. package/src/providers/claude-sdk-session.ts +132 -23
  171. package/src/providers/codex-skill-resolver.ts +10 -4
  172. package/src/providers/cursor-adapter.ts +1 -1
  173. package/src/providers/devin-skill-resolver.ts +5 -5
  174. package/src/providers/dsh-adapter.ts +1 -1
  175. package/src/scheduler/schedule-task.ts +1 -0
  176. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  177. package/src/scripts-runtime/swarm-sdk.ts +18 -1
  178. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  179. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  180. package/src/server.ts +2 -0
  181. package/src/slack/app.ts +93 -0
  182. package/src/slack/inbound-dispatch.ts +18 -1
  183. package/src/slack/workspace-guard.ts +345 -0
  184. package/src/tasks/task-terminal-effects.ts +4 -0
  185. package/src/tasks/worker-follow-up.ts +102 -2
  186. package/src/tests/acp-adapter.test.ts +82 -0
  187. package/src/tests/apps-icon.test.ts +120 -0
  188. package/src/tests/chained-task-follow-up.test.ts +248 -0
  189. package/src/tests/check-pr-body.test.ts +40 -0
  190. package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
  191. package/src/tests/claude-sdk-process.fixture.ts +57 -0
  192. package/src/tests/codex-skill-resolver.test.ts +31 -0
  193. package/src/tests/credentials-allowlist.test.ts +470 -0
  194. package/src/tests/db-task-read-contract.test.ts +5 -0
  195. package/src/tests/db-task-write-contract.test.ts +5 -0
  196. package/src/tests/deferred-wake-follow-up.test.ts +47 -0
  197. package/src/tests/docs-index-footprint.test.js +3 -3
  198. package/src/tests/dreaming-learnings.test.ts +1395 -0
  199. package/src/tests/dsh-adapter.test.ts +1 -1
  200. package/src/tests/explicit-model-validation.test.ts +2 -0
  201. package/src/tests/fs-provider.test.ts +42 -0
  202. package/src/tests/heartbeat.test.ts +28 -1
  203. package/src/tests/human-free-reclassify.test.ts +5 -1
  204. package/src/tests/list-endpoint-slimming.test.ts +17 -0
  205. package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
  206. package/src/tests/model-profile-check.test.ts +387 -0
  207. package/src/tests/model-profiles-api.test.ts +528 -1
  208. package/src/tests/profile-claim.test.ts +415 -3
  209. package/src/tests/profile-tier-alias.test.ts +382 -0
  210. package/src/tests/schedule-profile.test.ts +359 -0
  211. package/src/tests/script-connections.test.ts +6 -0
  212. package/src/tests/script-per-script-executor.test.ts +1 -0
  213. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
  214. package/src/tests/seed-scripts.test.ts +2 -2
  215. package/src/tests/slack-inbound-receipts.test.ts +22 -2
  216. package/src/tests/slack-socket-ack.test.ts +16 -1
  217. package/src/tests/slack-workspace-guard.test.ts +905 -0
  218. package/src/tests/steering-core.test.ts +40 -0
  219. package/src/tests/store-progress-learning.test.ts +605 -20
  220. package/src/tests/tool-annotations.test.ts +1 -1
  221. package/src/tests/workflow-convergence.test.ts +46 -40
  222. package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
  223. package/src/tests/workflow-definition-pinning.test.ts +645 -0
  224. package/src/tests/workflow-executors.test.ts +16 -7
  225. package/src/tests/workflow-foreach.test.ts +43 -20
  226. package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
  227. package/src/tests/workflow-profile.test.ts +328 -0
  228. package/src/tools/app-upsert.ts +1 -1
  229. package/src/tools/memory-edit.ts +2 -1
  230. package/src/tools/model-profiles/check-model-profile.ts +63 -0
  231. package/src/tools/schedules/create-schedule.ts +45 -4
  232. package/src/tools/schedules/patch-schedule.ts +50 -4
  233. package/src/tools/schedules/update-schedule.ts +50 -4
  234. package/src/tools/send-task.ts +17 -2
  235. package/src/tools/store-progress.ts +15 -3
  236. package/src/tools/task-action.ts +9 -1
  237. package/src/tools/templates.ts +13 -0
  238. package/src/tools/tool-config.ts +2 -1
  239. package/src/tools/utils.ts +61 -4
  240. package/src/tools/workflows/create-workflow.ts +1 -1
  241. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  242. package/src/tools/workflows/update-workflow.ts +10 -1
  243. package/src/types.ts +56 -1
  244. package/src/utils/credentials.ts +89 -12
  245. package/src/workflows/engine.ts +10 -1
  246. package/src/workflows/executors/agent-task.ts +21 -2
  247. package/src/workflows/executors/foreach.ts +4 -1
  248. package/src/workflows/executors/notify.ts +62 -6
  249. package/src/workflows/executors/sub-workflow.ts +1 -1
  250. package/src/workflows/executors/swarm-script.ts +4 -1
  251. package/src/workflows/foreach-driver.ts +8 -5
  252. package/src/workflows/limits.ts +2 -1
  253. package/src/workflows/model-validation.ts +27 -2
  254. package/src/workflows/patch-definition.ts +3 -1
  255. package/src/workflows/recovery.ts +6 -6
  256. package/src/workflows/resume.ts +9 -9
  257. package/src/workflows/retry-poller.ts +2 -2
  258. package/templates/skills/apps/SKILL.md +2 -0
  259. package/templates/skills/apps/content.md +2 -0
  260. package/templates/skills/code-quality/content.md +12 -0
  261. package/templates/skills/memory/content.md +8 -0
  262. package/templates/skills/scheduling/config.json +1 -1
  263. package/templates/skills/scheduling/content.md +2 -2
  264. package/templates/skills/swarm-docs/content.md +4 -0
  265. package/templates/skills/swarm-extensions/content.md +1 -1
  266. package/templates/skills/swarm-scripts/SKILL.md +1 -1
  267. package/templates/skills/swarm-scripts/content.md +1 -1
  268. package/templates/skills/work-on-task/SKILL.md +2 -0
  269. package/templates/skills/work-on-task/content.md +2 -0
  270. package/templates/workflows/dreaming/content.md +174 -7
  271. package/dist/acp-adapter-srfhs1s9.js +0 -16
  272. package/dist/cli-bzvs88tv.js +0 -339
  273. package/dist/cli-cyn9v8zr.js +0 -748
  274. package/dist/cli-ed6yqpf1.js +0 -779
  275. package/dist/handlers-17wha3ze.js +0 -33
  276. package/dist/heartbeat-gwewgdms.js +0 -42
  277. package/dist/index-8arwq8mw.js +0 -34
  278. package/dist/index-tpw054az.js +0 -38
  279. package/dist/index-waq75j2j.js +0 -31
  280. package/dist/lead-re73kdgc.js +0 -72
  281. package/dist/worker-r8mz7a65.js +0 -72
@@ -83,11 +83,17 @@ export interface TaskSteeringFields {
83
83
 
84
84
  type SteeringAgent = Pick<Agent, "isLead" | "provider" | "harnessProvider">;
85
85
 
86
+ function supportedModesForTask(task: AgentTask, provider: ProviderName): SteerMode[] {
87
+ return provider === "claude" && task.providerMeta?.transport === "sdk"
88
+ ? ["steer", "queue"]
89
+ : PROVIDER_STEER_CAPABILITIES[provider];
90
+ }
91
+
86
92
  function steeringFieldsFor(task: AgentTask, agent: SteeringAgent | null): TaskSteeringFields {
87
93
  const provider = agent?.harnessProvider ?? agent?.provider ?? task.provider;
88
94
  return {
89
95
  isLeadTask: agent?.isLead ?? false,
90
- supportedSteerModes: provider ? PROVIDER_STEER_CAPABILITIES[provider] : [],
96
+ supportedSteerModes: provider ? supportedModesForTask(task, provider) : [],
91
97
  };
92
98
  }
93
99
 
@@ -339,7 +345,7 @@ export async function requestSteering(args: RequestSteeringArgs): Promise<SteerR
339
345
  const currentTask = await getTaskById(args.taskId);
340
346
  if (!currentTask) throw new SteeringRequestError("Task not found", 404);
341
347
  const provider = await providerForTask(currentTask);
342
- const supportedModes = PROVIDER_STEER_CAPABILITIES[provider];
348
+ const supportedModes = supportedModesForTask(currentTask, provider);
343
349
 
344
350
  if (onUnsupported === "fail" && !supportedModes.includes(requestedMode)) {
345
351
  const supported = supportedModes.length > 0 ? supportedModes.join(", ") : "none";
@@ -2,4 +2,4 @@
2
2
  * agent-fs image tag bundled by `agent-swarm onboard --yes`.
3
3
  * `bun run bump:agent-fs` rewrites it together with the other pins.
4
4
  */
5
- export const AGENT_FS_VERSION = "0.18.16";
5
+ export const AGENT_FS_VERSION = "0.18.18";
@@ -83,6 +83,7 @@ import { MASKED_SECRET_VALUE } from "../utils/config-secrets.ts";
83
83
  import { getMcpBaseUrl } from "../utils/constants.ts";
84
84
  import { getContextWindowSize } from "../utils/context-window.ts";
85
85
  import {
86
+ CredentialAllowlistError,
86
87
  type CredentialSelection,
87
88
  ModelWindowExhaustedError,
88
89
  normalizeProviderKeyAliases,
@@ -911,6 +912,14 @@ export async function fetchResolvedEnv(
911
912
  * unset so an exhausted default model never blocks configuration loading.
912
913
  */
913
914
  enforceModelCapacity?: boolean;
915
+ /**
916
+ * The claimed profile's pooled-key allowlist (trigger `credentialAllowlist`).
917
+ * Forwarded to `resolveCredentialPools`, which throws
918
+ * `CredentialAllowlistError` when it matches no key.
919
+ */
920
+ credentialAllowlist?: Record<string, string[]>;
921
+ /** The profile that carries `credentialAllowlist`, for the error message. */
922
+ resolvedProfile?: string;
914
923
  },
915
924
  ): Promise<ResolvedEnvResult> {
916
925
  const env: Record<string, string | undefined> = { ...baseEnv };
@@ -1080,6 +1089,8 @@ export async function fetchResolvedEnv(
1080
1089
  model: effectiveModel,
1081
1090
  localBlocks: sessionContext?.localBlocks,
1082
1091
  enforceModelCapacity: sessionContext?.enforceModelCapacity,
1092
+ allowedKeySuffixes: sessionContext?.credentialAllowlist,
1093
+ allowlistProfile: sessionContext?.resolvedProfile,
1083
1094
  });
1084
1095
 
1085
1096
  return { env, credentialEnv, credentialSelections, resolvedProvider, scriptsOnlyConfigValue };
@@ -2471,6 +2482,9 @@ export async function getPausedTasksFromAPI(config: ApiConfig): Promise<
2471
2482
  status?: string;
2472
2483
  contextKey?: string;
2473
2484
  requestedBy?: Trigger["requestedBy"];
2485
+ /** The profile claim applied, and its pooled-key allowlist read again at fetch. */
2486
+ resolvedProfile?: string;
2487
+ credentialAllowlist?: Record<string, string[]>;
2474
2488
  }>
2475
2489
  > {
2476
2490
  const headers: Record<string, string> = {
@@ -2508,6 +2522,8 @@ export async function getPausedTasksFromAPI(config: ApiConfig): Promise<
2508
2522
  output?: string;
2509
2523
  status?: string;
2510
2524
  requestedBy?: Trigger["requestedBy"];
2525
+ resolvedProfile?: string;
2526
+ credentialAllowlist?: Record<string, string[]>;
2511
2527
  }>;
2512
2528
  };
2513
2529
  return data.tasks || [];
@@ -4254,6 +4270,9 @@ export async function spawnProviderProcess(
4254
4270
  contextKey?: string;
4255
4271
  /** Forwarded to fetchResolvedEnv → resolveCredentialPools — see RunnerState.modelWindowBlocks. */
4256
4272
  localBlocks?: Map<string, number>;
4273
+ /** Claim-time profile (task.resolvedProfile) and its pooled-key allowlist. */
4274
+ resolvedProfile?: string;
4275
+ credentialAllowlist?: Record<string, string[]>;
4257
4276
  },
4258
4277
  logDir: string,
4259
4278
  ): Promise<RunningTask> {
@@ -4288,10 +4307,15 @@ export async function spawnProviderProcess(
4288
4307
  modelTier: opts.modelTier,
4289
4308
  localBlocks: opts.localBlocks,
4290
4309
  enforceModelCapacity: true,
4310
+ credentialAllowlist: opts.credentialAllowlist,
4311
+ resolvedProfile: opts.resolvedProfile,
4291
4312
  },
4292
4313
  ));
4293
4314
  } catch (err) {
4294
- if (err instanceof ModelWindowExhaustedError && realTaskId) {
4315
+ if (
4316
+ (err instanceof ModelWindowExhaustedError || err instanceof CredentialAllowlistError) &&
4317
+ realTaskId
4318
+ ) {
4295
4319
  const reason = err.message;
4296
4320
  console.warn(`[${opts.role}] ${reason}`);
4297
4321
  await ensureTaskFinished(
@@ -7081,6 +7105,8 @@ export async function runAgent(config: RunnerConfig, opts: RunnerOptions) {
7081
7105
  vcsRepo: task.vcsRepo,
7082
7106
  contextKey: (task as { contextKey?: string }).contextKey,
7083
7107
  localBlocks: state.modelWindowBlocks,
7108
+ resolvedProfile: task.resolvedProfile,
7109
+ credentialAllowlist: task.credentialAllowlist,
7084
7110
  },
7085
7111
  logDir,
7086
7112
  );
@@ -7703,6 +7729,11 @@ export async function runAgent(config: RunnerConfig, opts: RunnerOptions) {
7703
7729
  vcsRepo: taskVcsRepo,
7704
7730
  contextKey: taskContextKey,
7705
7731
  localBlocks: state.modelWindowBlocks,
7732
+ resolvedProfile: (trigger.task as { resolvedProfile?: string } | undefined)
7733
+ ?.resolvedProfile,
7734
+ credentialAllowlist: (
7735
+ trigger.task as { credentialAllowlist?: Record<string, string[]> } | undefined
7736
+ )?.credentialAllowlist,
7706
7737
  },
7707
7738
  logDir,
7708
7739
  );
@@ -117,8 +117,13 @@ export function normalizeStoredKey(key: string): string {
117
117
  if (!trimmed || trimmed.includes("\0")) {
118
118
  throw new FilesError("Provider", "Stored file key must be a non-empty path");
119
119
  }
120
- if (trimmed.split("/").some(isParentSegment)) {
121
- throw new FilesError("Provider", "Stored file key must not contain parent path segments");
120
+ // Match normalizeName: reject empty and "." segments so a stored key stays a
121
+ // concrete relative file path (not a directory-like or ambiguous path).
122
+ if (trimmed.split("/").some((part) => !part || part === "." || isParentSegment(part))) {
123
+ throw new FilesError(
124
+ "Provider",
125
+ "Stored file key must not contain empty or parent path segments",
126
+ );
122
127
  }
123
128
  return trimmed;
124
129
  }
@@ -156,13 +161,22 @@ export function fileObjectFromHeaders(
156
161
  overrides: Partial<FileObject> = {},
157
162
  ): FileObject {
158
163
  const sizeHeader = headers.get("content-length");
164
+ let sizeBytes: number | undefined;
165
+ if (sizeHeader) {
166
+ const parsed = Number(sizeHeader);
167
+ // Malformed / negative / non-finite Content-Length must not leak NaN into
168
+ // metadata consumers — omit the field instead (#2671).
169
+ if (Number.isFinite(parsed) && parsed >= 0) {
170
+ sizeBytes = parsed;
171
+ }
172
+ }
159
173
  return {
160
174
  providerId,
161
175
  key: providerPath(scope),
162
176
  taskId: scope.taskId,
163
177
  name: scope.name,
164
178
  contentType: headers.get("content-type") ?? undefined,
165
- sizeBytes: sizeHeader ? Number(sizeHeader) : undefined,
179
+ sizeBytes,
166
180
  etag: headers.get("etag") ?? undefined,
167
181
  sha256: headers.get("x-agent-fs-content-hash") ?? undefined,
168
182
  version: headers.get("x-agent-fs-version") ?? undefined,
@@ -115,6 +115,17 @@ const SKIP_AUTO_RESUME_TYPES = new Set([
115
115
  // Configuration (env var overrides)
116
116
  // ============================================================================
117
117
 
118
+ /**
119
+ * Parse HEARTBEAT_INTERVAL_MS: a positive integer, or the 90-second default.
120
+ *
121
+ * `Number("Infinity")` is truthy, so `Number(value) || 90_000` let a non-finite
122
+ * interval through to `setInterval` (#2714).
123
+ */
124
+ export function parseHeartbeatIntervalMs(raw: string | undefined): number {
125
+ const value = Number(raw);
126
+ return Number.isInteger(value) && value > 0 ? value : 90_000;
127
+ }
128
+
118
129
  /**
119
130
  * Default heartbeat interval: 90 seconds.
120
131
  *
@@ -124,7 +135,7 @@ const SKIP_AUTO_RESUME_TYPES = new Set([
124
135
  * silently ignored — even across a restart. Keep these as functions.
125
136
  */
126
137
  function defaultIntervalMs(): number {
127
- return Number(process.env.HEARTBEAT_INTERVAL_MS) || 90_000;
138
+ return parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS);
128
139
  }
129
140
 
130
141
  /** Stall threshold: tasks with fresh worker heartbeat but no task update for this many minutes */
@@ -1,6 +1,7 @@
1
1
  export {
2
2
  getBootEpochMs,
3
3
  getRebootAffectedTasks,
4
+ parseHeartbeatIntervalMs,
4
5
  runRebootSweep,
5
6
  startHeartbeat,
6
7
  stopHeartbeat,
@@ -35,6 +35,7 @@ import {
35
35
  } from "../be/db/model-profiles";
36
36
  import { createEvent } from "../be/events";
37
37
  import { setAgentHarnessCliVersion } from "../be/harness-model-support";
38
+ import { checkProfileForAgent, formatProfileCheckFailures } from "../be/model-profile-check";
38
39
  import {
39
40
  sanitizeModelTierOverrides,
40
41
  setAgentModelTierOverrides,
@@ -65,6 +66,8 @@ import {
65
66
  AgentStatusSchema,
66
67
  AgentWithTasksSchema,
67
68
  DeliveryModeSchema,
69
+ type ProfileCheckResult,
70
+ ProfileCheckResultSchema,
68
71
  type ProfileSyncConflict,
69
72
  type ProviderName,
70
73
  ProviderNameSchema,
@@ -286,7 +289,7 @@ const updateAgentRuntimeRoute = route({
286
289
  pattern: ["api", "agents", null, "runtime"],
287
290
  summary: "Update an agent's runtime harness and default model",
288
291
  description:
289
- "Updates `agents.harness_provider` and agent-scoped runtime config. The settings apply to future provider sessions. For `model`, `reasoning_effort`, and `claude.transport`: omit the field to leave it unchanged, send `null` to clear the corresponding override, or send a value to set it. A `model` the model catalog does not list is a 400 unless `allow_custom_model` is true. A `latest:` alias is not accepted here (aliases resolve for a task's model and for `MODEL_TIER_*` values); `reasoning_effort` must be one the harness and model support. `profile` sets the agent's default model profile (same tri-state): it must exist and run on `harness_provider`, and it cannot be sent with `model`. Sending `model`, or changing the model or effort override by any path, clears the default profile.",
292
+ "Updates `agents.harness_provider` and agent-scoped runtime config. The settings apply to future provider sessions. For `model`, `reasoning_effort`, and `claude.transport`: omit the field to leave it unchanged, send `null` to clear the corresponding override, or send a value to set it. A `model` the model catalog does not list is a 400 unless `allow_custom_model` is true. A `latest:` alias is not accepted here (aliases resolve for a task's model and for `MODEL_TIER_*` values); `reasoning_effort` must be one the harness and model support. `profile` sets the agent's default model profile (same tri-state): it must exist, run on `harness_provider` and pass the profile check (`GET /api/agents/{id}/profile-check`) against it, and it cannot be sent with `model`. A failing check is a 400 `{ error, check }`; a passing one returns the result as `profileCheck`. Sending `model`, or changing the model or effort override by any path, clears the default profile.",
290
293
  tags: ["Agents"],
291
294
  params: z.object({ id: z.string() }),
292
295
  query: z.object({ repoId: z.string().optional() }),
@@ -300,8 +303,12 @@ const updateAgentRuntimeRoute = route({
300
303
  claude: ClaudeRuntimeConfigSchema.optional(),
301
304
  }),
302
305
  responses: {
303
- 200: { description: "Updated agent row", schema: AgentWithCapacitySchema },
304
- 400: { description: "Validation error" },
306
+ 200: {
307
+ description:
308
+ "Updated agent row. `profileCheck` is set when the body set `profile`, so warnings show.",
309
+ schema: AgentWithCapacitySchema.extend({ profileCheck: ProfileCheckResultSchema.optional() }),
310
+ },
311
+ 400: { description: "Validation error, or `{ error, check }` when the profile check fails" },
305
312
  404: { description: "Agent not found" },
306
313
  },
307
314
  });
@@ -642,6 +649,22 @@ const getAgentCredentialStatusRoute = route({
642
649
  },
643
650
  });
644
651
 
652
+ const getAgentProfileCheckRoute = route({
653
+ method: "get",
654
+ path: "/api/agents/{id}/profile-check",
655
+ pattern: ["api", "agents", null, "profile-check"],
656
+ summary: "Check whether an agent can run a model profile",
657
+ description:
658
+ "Read-only. Judges the profile's harness, model, the agent's credential report and the profile's credential allowlist. Each row is pass, warn, fail or unverified; `ok` is false only when a row fails. Never returns a secret value.",
659
+ tags: ["Agents"],
660
+ params: z.object({ id: z.string() }),
661
+ query: z.object({ profile: z.string().trim().min(1) }),
662
+ responses: {
663
+ 200: { description: "The check result", schema: ProfileCheckResultSchema },
664
+ 404: { description: "Agent or profile not found" },
665
+ },
666
+ });
667
+
645
668
  const listCredentialStatusRoute = route({
646
669
  method: "get",
647
670
  path: "/api/agents/credential-status",
@@ -1182,6 +1205,7 @@ export async function handleAgentsRest(
1182
1205
  const { harness_provider, model, allow_custom_model, reasoning_effort, profile, acp, claude } =
1183
1206
  parsed.body;
1184
1207
 
1208
+ let profileCheck: ProfileCheckResult | null = null;
1185
1209
  if (typeof profile === "string") {
1186
1210
  if (model !== undefined) {
1187
1211
  jsonError(res, "Send `profile` or `model`, not both", 400);
@@ -1200,6 +1224,15 @@ export async function handleAgentsRest(
1200
1224
  );
1201
1225
  return true;
1202
1226
  }
1227
+ // Judged against the body's harness: a PATCH that also switches it is
1228
+ // checked against the new one.
1229
+ profileCheck = await checkProfileForAgent(parsed.params.id, profile, {
1230
+ harness: harness_provider,
1231
+ });
1232
+ if (profileCheck && !profileCheck.ok) {
1233
+ json(res, { error: formatProfileCheckFailures(profileCheck), check: profileCheck }, 400);
1234
+ return true;
1235
+ }
1203
1236
  }
1204
1237
 
1205
1238
  if (acp && harness_provider !== "acp") {
@@ -1439,7 +1472,10 @@ export async function handleAgentsRest(
1439
1472
  jsonError(res, "Agent not found", 404);
1440
1473
  return true;
1441
1474
  }
1442
- updateAgentRuntimeRoute.respond(res, 200, await agentWithCapacity(agent));
1475
+ updateAgentRuntimeRoute.respond(res, 200, {
1476
+ ...(await agentWithCapacity(agent)),
1477
+ ...(profileCheck ? { profileCheck } : {}),
1478
+ });
1443
1479
  return true;
1444
1480
  }
1445
1481
 
@@ -1577,6 +1613,22 @@ export async function handleAgentsRest(
1577
1613
  return true;
1578
1614
  }
1579
1615
 
1616
+ if (getAgentProfileCheckRoute.match(req.method, pathSegments)) {
1617
+ const parsed = await getAgentProfileCheckRoute.parse(req, res, pathSegments, queryParams);
1618
+ if (!parsed) return true;
1619
+ if (!(await getAgentById(parsed.params.id))) {
1620
+ jsonError(res, "Agent not found", 404);
1621
+ return true;
1622
+ }
1623
+ const result = await checkProfileForAgent(parsed.params.id, parsed.query.profile);
1624
+ if (!result) {
1625
+ jsonError(res, `Model profile "${parsed.query.profile}" not found`, 404);
1626
+ return true;
1627
+ }
1628
+ getAgentProfileCheckRoute.respond(res, 200, result);
1629
+ return true;
1630
+ }
1631
+
1580
1632
  if (getAgent.match(req.method, pathSegments)) {
1581
1633
  const parsed = await getAgent.parse(req, res, pathSegments, queryParams);
1582
1634
  if (!parsed) return true;
package/src/http/apps.ts CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  import { getAgentById, getAppVersion, getAppVersions, getTaskById } from "../be/db";
66
66
  import type { RbacResource } from "../rbac";
67
67
  import { can } from "../rbac";
68
- import { AgentTaskStatusSchema } from "../types";
68
+ import { AgentTaskStatusSchema, AppIconSchema } from "../types";
69
69
  import { getRequestAuth } from "../utils/request-auth-context";
70
70
  import { scrubObject } from "../utils/secret-scrubber";
71
71
  import { resolveHttpFavoriteOwner } from "./favorite-owner";
@@ -139,6 +139,8 @@ const AppSummarySchema = z.object({
139
139
  id: z.string(),
140
140
  name: z.string(),
141
141
  description: z.string().optional(),
142
+ /** Projected from `definition.icon` (see `extractIcon` in `src/apps/store.ts`). */
143
+ icon: AppIconSchema.optional(),
142
144
  createdAt: z.string(),
143
145
  updatedAt: z.string(),
144
146
  });
@@ -9,6 +9,7 @@ import {
9
9
  maskSecrets,
10
10
  } from "../be/db";
11
11
  import { modelProfileRefError } from "../be/db/model-profiles";
12
+ import { runtimeReadsRepoSecrets } from "../be/model-profile-check";
12
13
  import {
13
14
  AGENT_MAX_TASKS_CONFIG_KEY,
14
15
  resetAgentMaxTasksMirror,
@@ -59,12 +60,7 @@ export function readsRepoSecrets(
59
60
  agent: { isLead?: boolean } | null | undefined,
60
61
  ): boolean {
61
62
  if (auth?.kind !== "agent" || !auth.runtimeId) return true;
62
- return can({
63
- principal: { kind: "agent", agentId: auth.agentId, isLead: agent?.isLead ?? false },
64
- verb: "config.read.secrets",
65
- resource: { kind: "none" },
66
- source: "http",
67
- }).allow;
63
+ return runtimeReadsRepoSecrets({ id: auth.agentId, isLead: agent?.isLead });
68
64
  }
69
65
 
70
66
  export async function requestSecretReadScope(
package/src/http/index.ts CHANGED
@@ -858,9 +858,8 @@ httpServer
858
858
  // restart — which is what the Configuration page's "Restart required"
859
859
  // badge promises for HEARTBEAT_DISABLE / HEARTBEAT_INTERVAL_MS.
860
860
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
861
- const { startHeartbeat } = await import("../heartbeat");
862
- const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
863
- startHeartbeat(heartbeatMs);
861
+ const { parseHeartbeatIntervalMs, startHeartbeat } = await import("../heartbeat");
862
+ startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
864
863
  }
865
864
 
866
865
  startPoolRouting();
@@ -21,6 +21,8 @@ import { explicitModelError } from "../be/model-validation";
21
21
  import { supportedReasoningLevels } from "../providers/reasoning-effort";
22
22
  import { can } from "../rbac";
23
23
  import {
24
+ type ModelProfileCredentials,
25
+ ModelProfileCredentialsSchema,
24
26
  ModelProfileNameSchema,
25
27
  ModelProfileSchema,
26
28
  type ProviderName,
@@ -28,6 +30,7 @@ import {
28
30
  type ReasoningEffort,
29
31
  ReasoningEffortSchema,
30
32
  } from "../types";
33
+ import { getModelAwareCredentialVars, PROVIDER_CREDENTIAL_VARS } from "../utils/credentials";
31
34
  import { agentFirstPrincipal } from "./request-principal";
32
35
  import { route } from "./route-def";
33
36
  import { jsonError } from "./utils";
@@ -68,7 +71,7 @@ const createProfile = route({
68
71
  pattern: ["api", "model-profiles"],
69
72
  summary: "Create a model profile",
70
73
  description:
71
- "A profile runs on one harness. `model` must run on that harness and be in the model catalog unless `allowCustomModel` is true (a gateway id, a fresh launch); a `latest:` alias is accepted and resolves at claim. `effort` must be a level the harness and model support. Operator only (the shared API key).",
74
+ "A profile runs on one harness. `model` must run on that harness and be in the model catalog unless `allowCustomModel` is true (a gateway id, a fresh launch); a `latest:` alias is accepted and resolves at claim. `effort` must be a level the harness and model support. `credentials` pins which pooled keys the profile uses: per credential var of the harness, the last 5 characters of each allowed key (`CODEX_OAUTH` is not supported). Operator only (the shared API key).",
72
75
  tags: ["Models"],
73
76
  rbac: { permission: "models.profiles.write" },
74
77
  body: z.object({
@@ -78,6 +81,7 @@ const createProfile = route({
78
81
  effort: ReasoningEffortSchema.nullable().optional(),
79
82
  allowCustomModel: z.boolean().optional().default(false),
80
83
  description: z.string().trim().max(500).nullable().optional(),
84
+ credentials: ModelProfileCredentialsSchema.nullable().optional(),
81
85
  }),
82
86
  responses: {
83
87
  201: { description: "Profile created", schema: ModelProfileSchema },
@@ -93,7 +97,7 @@ const updateProfile = route({
93
97
  pattern: ["api", "model-profiles", null],
94
98
  summary: "Update a model profile",
95
99
  description:
96
- "Changes the model, effort, custom-model flag or description; the name and harness are fixed. Omit a field to keep it; `effort: null` clears it. Applies to tasks claimed after the change. Operator only (the shared API key).",
100
+ "Changes the model, effort, custom-model flag, description or credential allowlist; the name and harness are fixed. Omit a field to keep it; `effort: null` and `credentials: null` clear it. Applies to tasks claimed after the change. Operator only (the shared API key).",
97
101
  tags: ["Models"],
98
102
  rbac: { permission: "models.profiles.write" },
99
103
  params: z.object({ name: z.string() }),
@@ -102,6 +106,7 @@ const updateProfile = route({
102
106
  effort: ReasoningEffortSchema.nullable().optional(),
103
107
  allowCustomModel: z.boolean().optional(),
104
108
  description: z.string().trim().max(500).nullable().optional(),
109
+ credentials: ModelProfileCredentialsSchema.nullable().optional(),
105
110
  }),
106
111
  responses: {
107
112
  200: { description: "Profile updated", schema: ModelProfileSchema },
@@ -117,7 +122,7 @@ const deleteProfile = route({
117
122
  pattern: ["api", "model-profiles", null],
118
123
  summary: "Delete a model profile",
119
124
  description:
120
- "Refused (409) for a shipped `<harness>-<tier>` seed (edit it instead; it would come back at the next boot), and while an agent has the profile as its default or a task holds it (unfinished, or superseded and still owed its resume). Operator only (the shared API key).",
125
+ "Refused (409) for a shipped `<harness>-<tier>` seed (edit it instead; it would come back at the next boot), and while an agent has the profile as its default, a schedule names it, or a task holds it (unfinished, or superseded and still owed its resume). Operator only (the shared API key).",
121
126
  tags: ["Models"],
122
127
  rbac: { permission: "models.profiles.write" },
123
128
  params: z.object({ name: z.string() }),
@@ -129,12 +134,53 @@ const deleteProfile = route({
129
134
  },
130
135
  });
131
136
 
132
- /** Why `harness` + `model` + `effort` is not a valid profile, or null. */
137
+ /**
138
+ * Why a credential allowlist does not fit the profile, or null. Each var must
139
+ * be a credential var the harness loads for this model (harnesses that pick
140
+ * the key by model prefix load a subset).
141
+ */
142
+ function credentialsError(
143
+ harness: ProviderName,
144
+ model: string,
145
+ credentials: ModelProfileCredentials | null | undefined,
146
+ ): string | null {
147
+ if (!credentials) return null;
148
+ // Only the vars the worker loads for this model (`selectCredentials`): an
149
+ // entry for any other var picks nothing, yet the profile check would still
150
+ // judge the agent's pool on it.
151
+ const base = PROVIDER_CREDENTIAL_VARS[harness] ?? [];
152
+ const allowed = new Set(base.length > 0 ? getModelAwareCredentialVars(harness, model) : []);
153
+ for (const [envVar, suffixes] of Object.entries(credentials)) {
154
+ if (envVar === "CODEX_OAUTH") {
155
+ return "A credential allowlist for CODEX_OAUTH is not supported in v1.";
156
+ }
157
+ if (!allowed.has(envVar)) {
158
+ return `"${envVar}" is not a credential var of the ${harness} harness${
159
+ allowed.size > 0 ? ` (expected one of ${[...allowed].join(", ")})` : ""
160
+ }.`;
161
+ }
162
+ if (suffixes.length === 0) return `The allowlist for ${envVar} is empty.`;
163
+ }
164
+ return null;
165
+ }
166
+
167
+ /** Each var's suffixes once, in first-seen order. */
168
+ function dedupeCredentials(
169
+ credentials: ModelProfileCredentials | null | undefined,
170
+ ): ModelProfileCredentials | null | undefined {
171
+ if (!credentials) return credentials;
172
+ return Object.fromEntries(
173
+ Object.entries(credentials).map(([envVar, suffixes]) => [envVar, [...new Set(suffixes)]]),
174
+ );
175
+ }
176
+
177
+ /** Why `harness` + `model` + `effort` + `credentials` is not a valid profile, or null. */
133
178
  async function profileValueError(input: {
134
179
  harness: ProviderName;
135
180
  model: string;
136
181
  effort: ReasoningEffort | null | undefined;
137
182
  allowCustomModel: boolean;
183
+ credentials?: ModelProfileCredentials | null;
138
184
  }): Promise<string | null> {
139
185
  const modelError = await explicitModelError({
140
186
  model: input.model,
@@ -152,7 +198,7 @@ async function profileValueError(input: {
152
198
  ) {
153
199
  return `Effort "${input.effort}" is not supported by ${input.model} on ${input.harness}.`;
154
200
  }
155
- return null;
201
+ return credentialsError(input.harness, input.model, input.credentials);
156
202
  }
157
203
 
158
204
  /** Gate a write on `models.profiles.write`; writes a 403 and returns false on denial. */
@@ -206,7 +252,7 @@ export async function handleModelProfiles(
206
252
  const parsed = await createProfile.parse(req, res, pathSegments, queryParams);
207
253
  if (!parsed) return true;
208
254
  if (!(await canWriteProfiles(req, res, myAgentId))) return true;
209
- const body = parsed.body;
255
+ const body = { ...parsed.body, credentials: dedupeCredentials(parsed.body.credentials) };
210
256
  const error = await profileValueError({ ...body, effort: body.effort ?? null });
211
257
  if (error) {
212
258
  jsonError(res, error, 400);
@@ -232,12 +278,13 @@ export async function handleModelProfiles(
232
278
  jsonError(res, "Model profile not found", 404);
233
279
  return true;
234
280
  }
235
- const body = parsed.body;
281
+ const body = { ...parsed.body, credentials: dedupeCredentials(parsed.body.credentials) };
236
282
  const error = await profileValueError({
237
283
  harness: current.harness,
238
284
  model: body.model ?? current.model,
239
285
  effort: body.effort === undefined ? current.effort : body.effort,
240
286
  allowCustomModel: body.allowCustomModel ?? current.allowCustomModel,
287
+ credentials: body.credentials === undefined ? current.credentials : body.credentials,
241
288
  });
242
289
  if (error) {
243
290
  jsonError(res, error, 400);
@@ -272,10 +319,11 @@ export async function handleModelProfiles(
272
319
  return true;
273
320
  }
274
321
  const refs = await modelProfileReferences(current.name);
275
- if (refs.agentIds.length > 0 || refs.openTaskCount > 0) {
322
+ if (refs.agentIds.length > 0 || refs.openTaskCount > 0 || refs.scheduleIds.length > 0) {
323
+ const schedules = refs.scheduleIds.length > 0 ? ` (${refs.scheduleIds.join(", ")})` : "";
276
324
  jsonError(
277
325
  res,
278
- `"${current.name}" is in use: default of ${refs.agentIds.length} agent(s), held by ${refs.openTaskCount} unfinished or awaiting-resume task(s).`,
326
+ `"${current.name}" is in use: default of ${refs.agentIds.length} agent(s), held by ${refs.openTaskCount} unfinished or awaiting-resume task(s), named by ${refs.scheduleIds.length} schedule(s)${schedules}.`,
279
327
  409,
280
328
  );
281
329
  return true;
@@ -286,7 +334,7 @@ export async function handleModelProfiles(
286
334
  if (outcome === "in-use") {
287
335
  jsonError(
288
336
  res,
289
- `"${current.name}" is in use by a task or an agent default created just now.`,
337
+ `"${current.name}" is in use by a task, a schedule or an agent default created just now.`,
290
338
  409,
291
339
  );
292
340
  return true;
package/src/http/poll.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  updateAgentStatusFromCapacity,
26
26
  upsertChannelActivityCursor,
27
27
  } from "../be/db";
28
+ import { checkProfileForAgent } from "../be/model-profile-check";
28
29
  import {
29
30
  parseModelTierOverridesHeader,
30
31
  recordClaimModelResolution,
@@ -36,7 +37,12 @@ import { hasCapability } from "../server";
36
37
  import { fetchChannelActivity } from "../slack/channel-activity";
37
38
  import { type TaskModelPinFields, taskModelPin } from "../tasks/model-pin";
38
39
  import { emitTaskTelemetry, resolveTriggerSurface } from "../telemetry-trigger";
39
- import { AgentTaskSchema, BudgetRefusedTriggerSchema, TaskAttachmentSchema } from "../types";
40
+ import {
41
+ AgentTaskSchema,
42
+ BudgetRefusedTriggerSchema,
43
+ ModelProfileCredentialsSchema,
44
+ TaskAttachmentSchema,
45
+ } from "../types";
40
46
  import { ensure } from "../utils/business-use";
41
47
  import { isLeadChannelMonitoringEnabled } from "../utils/lead-monitor-channels";
42
48
  import { isMultiRuntimeEnabled } from "../utils/multi-runtime";
@@ -109,6 +115,8 @@ const PollTaskAssignedTriggerSchema = z.object({
109
115
  triggerSurface: z.string().optional(),
110
116
  task: AgentTaskSchema.extend({
111
117
  attachments: z.array(PollTriggerAttachmentSchema),
118
+ // The claimed profile's pooled-key allowlist. Trigger only, not stored on the task.
119
+ credentialAllowlist: ModelProfileCredentialsSchema.optional(),
112
120
  }),
113
121
  requestedBy: TaskRequestedBySchema.optional(),
114
122
  });
@@ -225,6 +233,7 @@ async function claimModelFields(
225
233
  modelSource: undefined,
226
234
  modelAlias: undefined,
227
235
  resolvedProfile: undefined,
236
+ credentialAllowlist: undefined,
228
237
  };
229
238
  try {
230
239
  return {
@@ -559,9 +568,33 @@ export async function handlePoll(
559
568
  // worker (runbooks/model-tiers.md § Harness compatibility). Filter before the
560
569
  // budget gate so an incompatible first candidate never drives a refusal.
561
570
  const harness = agent.harnessProvider ?? agent.provider ?? null;
571
+ // A pool task with an explicit `profile` also waits for an agent that passes
572
+ // the profile check, judged on the task repo's config as the worker loads it.
573
+ // Memoized per poll: one check per profile name and repo.
574
+ const profileOk = new Map<string, boolean>();
575
+ const includeRepoSecrets = readsRepoSecrets(getRequestAuth(req), agent);
576
+ const passesProfileCheck = async (
577
+ profile: string,
578
+ vcsRepo: string | null | undefined,
579
+ ): Promise<boolean> => {
580
+ const memoKey = JSON.stringify([profile, vcsRepo ?? null]);
581
+ const cached = profileOk.get(memoKey);
582
+ if (cached !== undefined) return cached;
583
+ const result = await checkProfileForAgent(myAgentId, profile, {
584
+ vcsRepo,
585
+ includeRepoSecrets,
586
+ });
587
+ const ok = result?.ok !== false;
588
+ profileOk.set(memoKey, ok);
589
+ return ok;
590
+ };
562
591
  // The filter runs inside the paginated scan, so incompatible rows never use up the limit.
563
- const unassignedIds = await getUnassignedTaskIdsForAgent(myAgentId, 5, (task) =>
564
- poolTaskRunsOnHarness(task, harness),
592
+ const unassignedIds = await getUnassignedTaskIdsForAgent(
593
+ myAgentId,
594
+ 5,
595
+ async (task) =>
596
+ (await poolTaskRunsOnHarness(task, harness)) &&
597
+ (!task.profile || (await passesProfileCheck(task.profile, task.vcsRepo))),
565
598
  );
566
599
  // Budget admission gate (Phase 3). Pool path is workers-only —
567
600
  // per-agent budgets matter most here, but we still check global.