@desplega.ai/agent-swarm 2.7.6 → 2.7.7

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 (244) hide show
  1. package/dist/{acp-adapter-bp91d37f.js → acp-adapter-7b4vk3h5.js} +5 -4
  2. package/dist/{actions-yj0eeaqh.js → actions-3tt153af.js} +18 -18
  3. package/dist/{amp-adapter-4pg9h34q.js → amp-adapter-njpts0yr.js} +1 -1
  4. package/dist/{anthropic-messages-x4q6rfq5.js → anthropic-messages-xey2skwx.js} +7 -7
  5. package/dist/{app-909e97cr.js → app-nky4378f.js} +3 -3
  6. package/dist/{assistant-qdyb5fyy.js → assistant-jnb669pa.js} +19 -19
  7. package/dist/{azure-openai-responses-s1w5n70z.js → azure-openai-responses-26t7j9ra.js} +5 -5
  8. package/dist/{boot-reembed-fk0s9z18.js → boot-reembed-9mgvaztt.js} +1 -1
  9. package/dist/{boot-reembed-gs1rzrnh.js → boot-reembed-qs2djdej.js} +1 -1
  10. package/dist/{boot-scrub-sweep-4qfd4kfx.js → boot-scrub-sweep-yjpdj7s1.js} +3 -3
  11. package/dist/{boot-seeds-yr00k13d.js → boot-seeds-5cm6ambd.js} +4 -4
  12. package/dist/{boxd-vdmfssd9.js → boxd-nv507va8.js} +1 -1
  13. package/dist/{claude-adapter-qta1f1xn.js → claude-adapter-fn287zmm.js} +5 -4
  14. package/dist/{claude-managed-setup-sc6j4dm0.js → claude-managed-setup-wtdz2mj2.js} +1 -1
  15. package/dist/{claude-sdk-session-zgrz6yvc.js → claude-sdk-session-x91kqyhm.js} +8288 -8224
  16. package/dist/{cli-wp9sp1qb.js → cli-08bmz9z9.js} +1 -1
  17. package/dist/{cli-yy3rhsdw.js → cli-1c6tzt8g.js} +7 -7
  18. package/dist/{cli-q0k1w5zd.js → cli-35rsp8ye.js} +1 -1
  19. package/dist/{cli-xnrwazav.js → cli-3fg0bdcv.js} +1 -1
  20. package/dist/{cli-89knwags.js → cli-5b456bpf.js} +2 -2
  21. package/dist/{cli-drr5v6av.js → cli-5jnhv72d.js} +1 -1
  22. package/dist/{cli-dxae2yg7.js → cli-5zx699j9.js} +2 -2
  23. package/dist/{cli-0at8w34w.js → cli-6g0hb4cp.js} +8 -8
  24. package/dist/{cli-e3r2neck.js → cli-6pfd54vx.js} +5 -5
  25. package/dist/{cli-bsn8nhrq.js → cli-6vcp76qk.js} +3 -3
  26. package/dist/{cli-ekwks2vs.js → cli-72v799xn.js} +1 -1
  27. package/dist/cli-82j36f2m.js +45 -0
  28. package/dist/{cli-yx4kfngt.js → cli-8305gbq0.js} +29 -16
  29. package/dist/{cli-4necwtsv.js → cli-8sckt74b.js} +8 -8
  30. package/dist/{cli-vvpx3gsx.js → cli-95jzxcp3.js} +1 -1
  31. package/dist/{cli-hr2e2fft.js → cli-adeegh7d.js} +7 -7
  32. package/dist/{cli-m48g6p95.js → cli-afkqkrtw.js} +3 -3
  33. package/dist/{cli-0qatpy8q.js → cli-ayayvfg4.js} +24 -4
  34. package/dist/{cli-bqt1mptt.js → cli-az48n0nr.js} +4 -4
  35. package/dist/{cli-zm72anhg.js → cli-bfv7vdg6.js} +9 -9
  36. package/dist/{cli-hgaazk69.js → cli-caj33vcq.js} +5 -5
  37. package/dist/{cli-3ypk9vk1.js → cli-cb2a8pna.js} +1 -1
  38. package/dist/{cli-waqbxg08.js → cli-cppkf404.js} +17 -17
  39. package/dist/{cli-yn4kxs06.js → cli-ddaanqkd.js} +4 -4
  40. package/dist/{cli-386tyxxg.js → cli-e0kmphd6.js} +2 -2
  41. package/dist/{cli-54t00gt8.js → cli-e46hg0xw.js} +1 -1
  42. package/dist/{cli-jm2vfpfd.js → cli-e5bzrn01.js} +1 -1
  43. package/dist/{cli-436532ck.js → cli-excnnjg2.js} +165 -153
  44. package/dist/{cli-71ptav7x.js → cli-ferkkrg9.js} +1 -1
  45. package/dist/{cli-vpf89f34.js → cli-fmjd0t1y.js} +3 -3
  46. package/dist/{cli-pd7vagab.js → cli-fyt2g4wd.js} +3 -3
  47. package/dist/{cli-gdhpcbhf.js → cli-g08zdaec.js} +1 -1
  48. package/dist/{cli-ehq736cn.js → cli-g7s47cc5.js} +4 -4
  49. package/dist/{cli-svj5090z.js → cli-gz6q4eve.js} +3 -3
  50. package/dist/{cli-8snvgs5r.js → cli-je518txm.js} +10 -10
  51. package/dist/{cli-rmmmrjkd.js → cli-jtjtabxe.js} +1 -1
  52. package/dist/{cli-611a1294.js → cli-k0wwfqbg.js} +18 -1
  53. package/dist/{cli-es6va8jk.js → cli-k1nje3v3.js} +38 -43
  54. package/dist/{cli-p5gp8pcx.js → cli-k8196sh2.js} +6 -6
  55. package/dist/{cli-nwj0ee2w.js → cli-k899ehvh.js} +2 -2
  56. package/dist/{cli-decfb6v8.js → cli-m0da8j35.js} +23 -9
  57. package/dist/{cli-he9wchme.js → cli-mkk9rnzz.js} +4 -4
  58. package/dist/{cli-nhrvpaj7.js → cli-n6bv12jn.js} +510 -4
  59. package/dist/{cli-8bc1w0tw.js → cli-nmzhp1b5.js} +14 -12
  60. package/dist/{cli-0yv5z2pg.js → cli-p82cnnjq.js} +1 -1
  61. package/dist/{cli-c60vetmm.js → cli-pc6n7fre.js} +1 -1
  62. package/dist/{cli-xds5f77d.js → cli-pjctyea3.js} +2 -2
  63. package/dist/{cli-xbbndvjy.js → cli-pq73h5mz.js} +3 -3
  64. package/dist/{cli-aa6yxc7m.js → cli-pz4rk021.js} +1 -1
  65. package/dist/{cli-xnqgpshy.js → cli-q3tkegby.js} +1 -1
  66. package/dist/cli-qghe0h66.js +67 -0
  67. package/dist/{cli-zbbwez0r.js → cli-qh4d4tvk.js} +4 -4
  68. package/dist/{cli-w6dt9ged.js → cli-rtt8g4v9.js} +1 -1
  69. package/dist/{cli-1h3wcpbw.js → cli-snpj5zbj.js} +2 -2
  70. package/dist/{cli-a7v854rf.js → cli-tgrv9cjx.js} +263 -12
  71. package/dist/{cli-faxe6thg.js → cli-vz22fyqv.js} +186 -54
  72. package/dist/{cli-k2gzwsj2.js → cli-wk5yrfwd.js} +160 -26
  73. package/dist/{cli-shpbx5ee.js → cli-ws19768n.js} +1641 -49
  74. package/dist/{cli-70r77n04.js → cli-xae4g51r.js} +1 -1
  75. package/dist/{cli-kqdg1bsb.js → cli-yndmfxb3.js} +2 -2
  76. package/dist/{cli-bjb3z51z.js → cli-yyj3j5m4.js} +2 -2
  77. package/dist/cli.js +21 -21
  78. package/dist/{cloudflare-workers-ai-system-one-bm60fjm0.js → cloudflare-workers-ai-system-one-ef2a980q.js} +2 -2
  79. package/dist/{codex-adapter-ayd1fb6h.js → codex-adapter-cf2yxe9m.js} +3 -2
  80. package/dist/{codex-hook-9efm2x1m.js → codex-hook-a0c6g6t6.js} +1 -1
  81. package/dist/{codex-session-runner-jesa32xc.js → codex-session-runner-6vfzdgbd.js} +3 -2
  82. package/dist/{commands-hanewgf2.js → commands-t3mfy7vn.js} +3 -3
  83. package/dist/{controller-dt1n3c1q.js → controller-q7xrbaz0.js} +3 -3
  84. package/dist/{controllers-connect-xx8x64n5.js → controllers-connect-c6nm70kg.js} +19 -19
  85. package/dist/{cursor-adapter-9s4dwwdw.js → cursor-adapter-ftd81ga8.js} +1 -1
  86. package/dist/{db-3vttcbv4.js → db-dk572x25.js} +3 -3
  87. package/dist/{db-9dv0g1ab.js → db-vemtpmcc.js} +4 -2
  88. package/dist/{dispatcher-tx9hd1sv.js → dispatcher-kh7ecxh9.js} +17 -17
  89. package/dist/{dsh-adapter-007y4ejs.js → dsh-adapter-v8628r89.js} +1 -1
  90. package/dist/{e2b-we6hs6q5.js → e2b-fr12yccx.js} +1 -1
  91. package/dist/{e2b-a19d28rz.js → e2b-x6ywzak3.js} +1 -1
  92. package/dist/{easter-egg-3d-rgbrqb8s.js → easter-egg-3d-nenw4x63.js} +1 -1
  93. package/dist/{embedding-space-ny1e2940.js → embedding-space-0jepb239.js} +6 -6
  94. package/dist/{embeddings-2t386t13.js → embeddings-xxt49yxg.js} +1 -1
  95. package/dist/{execute-pksh0ceh.js → execute-1mhw6e4x.js} +1 -1
  96. package/dist/{external-channel-phgmhmd7.js → external-channel-55v12e60.js} +2 -2
  97. package/dist/{fx-adapter-fy8rr921.js → fx-adapter-bs8wqrk5.js} +6 -5
  98. package/dist/{google-generative-ai-8y3m3k4b.js → google-generative-ai-v94hr7h0.js} +5 -5
  99. package/dist/{google-vertex-w3v98n7b.js → google-vertex-g7vr6cf8.js} +5 -5
  100. package/dist/{grok-adapter-q0abvpaj.js → grok-adapter-gpjqmkcq.js} +6 -5
  101. package/dist/handlers-zxmp1ta4.js +32 -0
  102. package/dist/{heartbeat-kadyek8p.js → heartbeat-k42svnr0.js} +20 -20
  103. package/dist/{hook-9k551xnj.js → hook-114m7hap.js} +4 -3
  104. package/dist/{hook-5zs3msf6.js → hook-6nphweh0.js} +24 -9
  105. package/dist/{http-mhz9vw1f.js → http-r8cc4wz7.js} +1025 -173
  106. package/dist/index-a8phxqnk.js +37 -0
  107. package/dist/{index-vdygbq10.js → index-e3s8wmxy.js} +1 -1
  108. package/dist/{index-q361cg2f.js → index-fpk4bcd9.js} +1 -1
  109. package/dist/index-k6h00t4c.js +30 -0
  110. package/dist/{index-rvr00sg7.js → index-nh3wyqdt.js} +1017 -574
  111. package/dist/index-xrz7te8h.js +33 -0
  112. package/dist/{keepalive-w56f32cg.js → keepalive-x060nt9p.js} +3 -3
  113. package/dist/lead-956sd2yc.js +71 -0
  114. package/dist/{maintenance-7mdgxcea.js → maintenance-2xxfexhf.js} +1 -1
  115. package/dist/{mistral-conversations-4pmwj1c0.js → mistral-conversations-3gjpdb4b.js} +4 -4
  116. package/dist/{oauth-refresh-sweep-29txy9vk.js → oauth-refresh-sweep-fckc4ar5.js} +2 -2
  117. package/dist/{onboard-kpsrkarj.js → onboard-zc48j237.js} +3 -3
  118. package/dist/{openai-codex-responses-44j573nm.js → openai-codex-responses-8pbxq9h5.js} +5 -5
  119. package/dist/{openai-completions-a4gee2a8.js → openai-completions-rm00s912.js} +4 -4
  120. package/dist/{openai-decisions-w4qkrcar.js → openai-decisions-8v957r2r.js} +1 -1
  121. package/dist/{openai-responses-rbp6h5kr.js → openai-responses-agxpf96k.js} +5 -5
  122. package/dist/{opencode-adapter-j25vm3rr.js → opencode-adapter-r690h1cr.js} +4 -3
  123. package/dist/{otel-impl-6kkct7a8.js → otel-impl-r5xbh81q.js} +4 -4
  124. package/dist/{pi-mono-adapter-exhkzhn2.js → pi-mono-adapter-c7v8sdec.js} +7 -6
  125. package/dist/{pricing-refresh-n2x7jh6k.js → pricing-refresh-3pmre11v.js} +3 -3
  126. package/dist/{rbac-roles-81ypx6es.js → rbac-roles-3vbshwsb.js} +1 -1
  127. package/dist/{rbac-roles-b5htkjby.js → rbac-roles-910mmkgz.js} +2 -2
  128. package/dist/{render-v2-qn6jmpk4.js → render-v2-pxykkbab.js} +3 -3
  129. package/dist/{resume-wd30wx23.js → resume-adda0bwy.js} +6 -6
  130. package/dist/{runtime-4hsg7h60.js → runtime-fnbm7stk.js} +1 -1
  131. package/dist/{session-access-5qvfevhk.js → session-access-2fvamrdc.js} +4 -4
  132. package/dist/{session-source-backfill-n1czavbr.js → session-source-backfill-08xvv0sm.js} +2 -2
  133. package/dist/{setup-dnb56qy5.js → setup-1aqmvmh1.js} +1 -1
  134. package/dist/{typesafe-system-one-5mavm259.js → typesafe-system-one-0bmqcxfg.js} +2 -2
  135. package/dist/{virtual-modules-76xxv9fs.js → virtual-modules-d2pjk9j1.js} +5 -5
  136. package/dist/{work-objects-4n21tfkm.js → work-objects-9s0yrm5j.js} +20 -20
  137. package/dist/{worker-follow-up-77hvzxww.js → worker-follow-up-3q78fqmr.js} +17 -17
  138. package/dist/worker-y15hy08h.js +71 -0
  139. package/openapi.json +197 -4
  140. package/package.json +5 -5
  141. package/src/apps/definition.ts +6 -5
  142. package/src/be/db/page-theme-tokens.ts +12 -0
  143. package/src/be/db/tasks/read.ts +9 -1
  144. package/src/be/db/tasks/write.ts +19 -0
  145. package/src/be/db-client.ts +107 -7
  146. package/src/be/db.ts +34 -2
  147. package/src/be/migrations/269_pages_design_system.sql +23 -0
  148. package/src/be/seed/schedules-seeder.ts +0 -10
  149. package/src/be/seed-scripts/catalog/catalog-report.inline.ts +2 -0
  150. package/src/be/seed-scripts/catalog/catalog-report.ts +2 -0
  151. package/src/be/seed-scripts/catalog/memory-eval.ts +2 -0
  152. package/src/be/seed-scripts/catalog/swarm-update-check.ts +150 -0
  153. package/src/be/seed-scripts/index.ts +9 -0
  154. package/src/be/seed-skills/bundled-files.generated.json +3 -3
  155. package/src/be/swarm-config-guard.ts +32 -0
  156. package/src/be/task-auto-title-listener.ts +127 -0
  157. package/src/commands/onboard/agent-fs-version.ts +1 -1
  158. package/src/commands/profile-sync.ts +151 -16
  159. package/src/commands/runner.ts +15 -7
  160. package/src/hooks/hook.ts +20 -9
  161. package/src/http/index.ts +3 -0
  162. package/src/http/pages-public.ts +93 -129
  163. package/src/http/pages.ts +94 -21
  164. package/src/pages/browser-sdk.ts +48 -21
  165. package/src/pages/color-literals.ts +115 -0
  166. package/src/pages/page-head.ts +766 -0
  167. package/src/pages/version.ts +3 -0
  168. package/src/providers/amp-adapter.ts +1 -1
  169. package/src/providers/codex-adapter.ts +1 -0
  170. package/src/providers/codex-app-server.ts +27 -1
  171. package/src/providers/pi-mono-extension.ts +30 -15
  172. package/src/tasks/follow-up-gate.ts +318 -0
  173. package/src/tasks/worker-follow-up.ts +21 -1
  174. package/src/tests/codex-app-server.test.ts +59 -0
  175. package/src/tests/codex-gateway-route.test.ts +50 -1
  176. package/src/tests/create-page-tool.test.ts +501 -0
  177. package/src/tests/db-client-busy-retry.test.ts +81 -0
  178. package/src/tests/db-task-read-contract.test.ts +1 -0
  179. package/src/tests/db-task-write-contract.test.ts +2 -0
  180. package/src/tests/db-tasks-read.test.ts +21 -0
  181. package/src/tests/fixtures/pages/head-v1.html +56 -0
  182. package/src/tests/follow-up-gate-shadow.test.ts +513 -0
  183. package/src/tests/identity-field-budget.test.ts +1 -1
  184. package/src/tests/internal-ai/credentials.test.ts +62 -0
  185. package/src/tests/internal-ai/task-title.test.ts +283 -0
  186. package/src/tests/merge-gate-detect-changes.test.ts +145 -0
  187. package/src/tests/page-proxy.test.ts +1 -1
  188. package/src/tests/page-session-dev-cookie.test.ts +188 -0
  189. package/src/tests/pages-frame-ancestors.test.ts +28 -1
  190. package/src/tests/pages-head-v2.test.ts +534 -0
  191. package/src/tests/pages-http.test.ts +330 -0
  192. package/src/tests/pages-public-html.test.ts +43 -0
  193. package/src/tests/pages-storage.test.ts +182 -0
  194. package/src/tests/pages-versioning.test.ts +72 -0
  195. package/src/tests/profile-sync-stale-writeback.test.ts +334 -0
  196. package/src/tests/profile-sync.test.ts +11 -15
  197. package/src/tests/scheduled-task-required-params-migration.test.ts +3 -1
  198. package/src/tests/script-connections.test.ts +2 -0
  199. package/src/tests/seed-registry.test.ts +28 -6
  200. package/src/tests/seed-schedules.test.ts +61 -8
  201. package/src/tests/seed-scripts.test.ts +142 -2
  202. package/src/tests/swarm-diff.test.ts +121 -2
  203. package/src/tests/task-auto-title-config-guard.test.ts +37 -0
  204. package/src/tests/task-auto-title-listener.test.ts +165 -0
  205. package/src/tests/theme-import.test.ts +758 -0
  206. package/src/tests/themes-page-theme.test.ts +155 -0
  207. package/src/tests/themes-presets.test.ts +172 -0
  208. package/src/tests/workflow-script-principal.test.ts +2 -1
  209. package/src/themes/classics.ts +949 -0
  210. package/src/themes/import.ts +420 -0
  211. package/src/themes/page-fields.ts +40 -0
  212. package/src/themes/page-theme.ts +102 -0
  213. package/src/themes/presets.ts +561 -0
  214. package/src/themes/tokens.ts +218 -0
  215. package/src/tools/app-upsert.ts +1 -1
  216. package/src/tools/create-page.ts +118 -12
  217. package/src/tools/utils.ts +33 -0
  218. package/src/types.ts +45 -3
  219. package/src/utils/constants.ts +19 -0
  220. package/src/utils/follow-up-gate-schedule-ids.ts +13 -0
  221. package/src/utils/internal-ai/credentials.ts +146 -93
  222. package/src/utils/internal-ai/index.ts +10 -0
  223. package/src/utils/internal-ai/models.ts +18 -0
  224. package/src/utils/internal-ai/task-title.ts +282 -0
  225. package/src/utils/page-session.ts +37 -0
  226. package/templates/schedules/daily-status-report/content.md +88 -2
  227. package/templates/schedules/daily-swarm-update-check/content.md +16 -40
  228. package/templates/skills/apps/SKILL.md +1 -1
  229. package/templates/skills/apps/content.md +1 -1
  230. package/templates/skills/heartbeat-runbook/content.md +1 -1
  231. package/templates/skills/pages/config.json +1 -1
  232. package/templates/skills/pages/content.md +539 -86
  233. package/templates/skills/pages/files/examples/annotated-pr.html +21 -12
  234. package/templates/skills/pages/files/examples/multiplayer-board.html +41 -41
  235. package/templates/skills/pages/files/examples/report-page.html +125 -124
  236. package/dist/cli-2pnswgh8.js +0 -189
  237. package/dist/handlers-by3sfxyx.js +0 -32
  238. package/dist/index-4f2pvxae.js +0 -37
  239. package/dist/index-98gz7tmp.js +0 -30
  240. package/dist/index-k08z2cak.js +0 -33
  241. package/dist/lead-enq35nqp.js +0 -70
  242. package/dist/worker-gg1576j3.js +0 -70
  243. package/templates/schedules/daily-workflow-health-audit/config.json +0 -19
  244. package/templates/schedules/daily-workflow-health-audit/content.md +0 -191
@@ -56,22 +56,21 @@ import {
56
56
  releaseApprovalCancellationNotificationClaim2,
57
57
  updateApprovalRequestNotifications2,
58
58
  init_db4
59
- } from "./cli-k2gzwsj2.js";
59
+ } from "./cli-wk5yrfwd.js";
60
60
  import {
61
61
  externalChannelToolError2,
62
62
  isBlockExternalEnabled2,
63
63
  getChannelBlockReason2,
64
64
  init_external_channel
65
- } from "./cli-w6dt9ged.js";
65
+ } from "./cli-rtt8g4v9.js";
66
66
  import {
67
67
  getSlackApp2,
68
68
  init_app3
69
- } from "./cli-waqbxg08.js";
69
+ } from "./cli-cppkf404.js";
70
70
  import {
71
- DEFAULT_MODEL,
72
71
  resolveCredential,
73
72
  init_credentials
74
- } from "./cli-436532ck.js";
73
+ } from "./cli-excnnjg2.js";
75
74
  import {
76
75
  isMultiRuntimeEnabled,
77
76
  init_multi_runtime2
@@ -79,16 +78,19 @@ import {
79
78
  import {
80
79
  revokeRuntimeTokensForRuntime,
81
80
  init_users
82
- } from "./cli-drr5v6av.js";
81
+ } from "./cli-5jnhv72d.js";
83
82
  import {
84
83
  TERMINAL_TASK_STATUSES,
85
84
  init_types4
86
- } from "./cli-nhrvpaj7.js";
85
+ } from "./cli-n6bv12jn.js";
87
86
  import {
88
87
  getSlackConfiguration,
89
88
  isSlackConfigured,
90
89
  init_config4
91
90
  } from "./cli-eetzmsy5.js";
91
+ import {
92
+ DEFAULT_MODEL
93
+ } from "./cli-82j36f2m.js";
92
94
  import {
93
95
  DEFAULT_OPENROUTER_BASE_URL,
94
96
  getOpenRouterBaseUrl,
@@ -127,7 +129,7 @@ import {
127
129
  import {
128
130
  getAppUrl,
129
131
  init_constants3
130
- } from "./cli-611a1294.js";
132
+ } from "./cli-k0wwfqbg.js";
131
133
  import {
132
134
  isEnvFlagEnabled,
133
135
  init_env_flag
@@ -155,7 +157,7 @@ async function notifyAutomationPreflightFailure(preflight) {
155
157
  return;
156
158
  }
157
159
  try {
158
- const { getSlackApp } = await import("./app-909e97cr.js");
160
+ const { getSlackApp } = await import("./app-nky4378f.js");
159
161
  const app = getSlackApp();
160
162
  if (!app) {
161
163
  console.warn("[Automation Preflight] Slack not available, cannot send notification");
@@ -4551,7 +4553,7 @@ async function runClaimedStep(def, runId, ctx, node, registry, existingStep, ste
4551
4553
  }
4552
4554
  const waiting = await checkpointStepWaiting(runId, stepId, ctx);
4553
4555
  if (waiting && result.waitFor === "workflow.child.finished") {
4554
- const { resumeFromChildRun } = await import("./resume-wd30wx23.js");
4556
+ const { resumeFromChildRun } = await import("./resume-adda0bwy.js");
4555
4557
  await resumeFromChildRun(stepId, registry);
4556
4558
  }
4557
4559
  return { outcome: waiting ? "waiting" : "completed", successors: [] };
@@ -5056,7 +5058,7 @@ async function runForeachDrive(runId, parentNodeId, registry) {
5056
5058
  if (drive.successors.length > 0) {
5057
5059
  await walkGraph(workflow.definition, runId, ctx, drive.successors, registry, workflow.id, getSecretInputKeys(workflow.input));
5058
5060
  } else {
5059
- const { finalizeOrWait } = await import("./resume-wd30wx23.js");
5061
+ const { finalizeOrWait } = await import("./resume-adda0bwy.js");
5060
5062
  await finalizeOrWait(runId);
5061
5063
  }
5062
5064
  return drive;
@@ -5199,7 +5201,7 @@ async function startChild(input) {
5199
5201
  const parked = await getDbClient2().get("UPDATE workflow_run_steps SET status = 'waiting' WHERE id = ? AND status = 'running' RETURNING id", [child.id]);
5200
5202
  if (parked && result.waitFor === "workflow.child.finished") {
5201
5203
  ownedChildren.delete(child.id);
5202
- const { resumeFromChildRun } = await import("./resume-wd30wx23.js");
5204
+ const { resumeFromChildRun } = await import("./resume-adda0bwy.js");
5203
5205
  await resumeFromChildRun(child.id, registry);
5204
5206
  }
5205
5207
  return null;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_package,
3
3
  package_default
4
- } from "./cli-e3r2neck.js";
4
+ } from "./cli-6pfd54vx.js";
5
5
 
6
6
  // src/commands/shared/client-config.ts
7
7
  init_package();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDb2,
3
3
  init_db4
4
- } from "./cli-k2gzwsj2.js";
4
+ } from "./cli-wk5yrfwd.js";
5
5
  import {
6
6
  openAICompatibleProviderIds,
7
7
  withRegistryCatalogSections,
@@ -6,11 +6,11 @@ import {
6
6
  getResolvedConfig2,
7
7
  getAllUsers2,
8
8
  init_db4
9
- } from "./cli-k2gzwsj2.js";
9
+ } from "./cli-wk5yrfwd.js";
10
10
  import {
11
11
  getUserGrant2,
12
12
  init_rbac_roles
13
- } from "./cli-rmmmrjkd.js";
13
+ } from "./cli-jtjtabxe.js";
14
14
  import {
15
15
  scrubSecrets,
16
16
  init_secret_scrubber
@@ -2,19 +2,19 @@ import {
2
2
  getKv2,
3
3
  upsertKv2,
4
4
  init_db4
5
- } from "./cli-k2gzwsj2.js";
5
+ } from "./cli-wk5yrfwd.js";
6
6
  import {
7
7
  resolveIdentity,
8
8
  init_identity,
9
9
  recordUnmappedIdentity,
10
10
  init_unmapped_identities
11
- } from "./cli-shpbx5ee.js";
11
+ } from "./cli-ws19768n.js";
12
12
  import {
13
13
  findUserByExternalId,
14
14
  findOrCreateUserByEmail,
15
15
  linkIdentity,
16
16
  init_users
17
- } from "./cli-drr5v6av.js";
17
+ } from "./cli-5jnhv72d.js";
18
18
  import {
19
19
  __esm
20
20
  } from "./cli-242037k3.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  lazyApi,
3
3
  init_lazy
4
- } from "./cli-1h3wcpbw.js";
4
+ } from "./cli-snpj5zbj.js";
5
5
  import {
6
6
  __esm
7
7
  } from "./cli-242037k3.js";
@@ -9,7 +9,7 @@ import {
9
9
  acquireOAuthRefreshLock,
10
10
  releaseOAuthRefreshLock,
11
11
  init_oauth
12
- } from "./cli-k2gzwsj2.js";
12
+ } from "./cli-wk5yrfwd.js";
13
13
  import {
14
14
  generateRandomCodeVerifier,
15
15
  generateRandomState,
@@ -0,0 +1,67 @@
1
+ import {
2
+ completeStructuredWithModel
3
+ } from "./cli-vz22fyqv.js";
4
+ import {
5
+ SummaryWithRatingsSchema,
6
+ BASE_SUMMARIZE_PROMPT,
7
+ buildSummaryWithRatingsPrompt,
8
+ init_llm
9
+ } from "./cli-rvtm68yy.js";
10
+ import {
11
+ _Array_,
12
+ Optional,
13
+ _Object_,
14
+ Number2,
15
+ String2,
16
+ init_build,
17
+ init_credentials
18
+ } from "./cli-excnnjg2.js";
19
+ import {
20
+ init_models2
21
+ } from "./cli-82j36f2m.js";
22
+
23
+ // src/utils/internal-ai/index.ts
24
+ init_credentials();
25
+ init_models2();
26
+
27
+ // src/utils/internal-ai/summarize-session.ts
28
+ init_build();
29
+ init_llm();
30
+ var summaryToolSchema = _Object_({
31
+ summary: String2(),
32
+ ratings: _Array_(_Object_({
33
+ id: String2({ minLength: 1 }),
34
+ score: Number2({ minimum: 0, maximum: 1 }),
35
+ reasoning: String2({ minLength: 1, maxLength: 500 }),
36
+ referencesSource: Optional(String2({ maxLength: 512 }))
37
+ }))
38
+ });
39
+ async function summarizeSession(opts) {
40
+ if (opts.transcript.length <= 100)
41
+ return null;
42
+ const taskLine = opts.taskContext.prompt ? `
43
+ Task: ${opts.taskContext.prompt}` : "";
44
+ const basePrompt = `${BASE_SUMMARIZE_PROMPT}${taskLine}
45
+
46
+ Transcript:
47
+ ${opts.transcript}`;
48
+ const userPrompt = buildSummaryWithRatingsPrompt(basePrompt, opts.retrievals);
49
+ const runner = opts._completeStructured ?? completeStructuredWithModel;
50
+ const result = await runner({
51
+ zodSchema: SummaryWithRatingsSchema,
52
+ toolSchema: summaryToolSchema,
53
+ toolName: "record_session_summary",
54
+ toolDescription: "Record the high-value learnings extracted from this session, plus per-memory ratings of any retrievals.",
55
+ systemPrompt: "You are an expert at extracting durable, generalizable learnings from agent sessions.",
56
+ userPrompt,
57
+ callerTag: `session-summary:${opts.harness}`,
58
+ apiUrl: opts.apiUrl,
59
+ apiKey: opts.apiKey,
60
+ env: opts.env,
61
+ signal: opts.signal,
62
+ retries: 3,
63
+ ...opts._credentialOverride ? { _credentialOverride: opts._credentialOverride } : {}
64
+ });
65
+ return result ? { ...result.data, model: result.model } : null;
66
+ }
67
+ export { summarizeSession };
@@ -7,21 +7,21 @@ import {
7
7
  tierConfigKey,
8
8
  init_model_tier_keys,
9
9
  init_db4
10
- } from "./cli-k2gzwsj2.js";
10
+ } from "./cli-wk5yrfwd.js";
11
11
  import {
12
12
  ensureRbacSeedsSynced2,
13
13
  init_rbac_roles
14
- } from "./cli-rmmmrjkd.js";
14
+ } from "./cli-jtjtabxe.js";
15
15
  import {
16
16
  seedPricingFromModelsDev,
17
17
  init_seed_pricing
18
- } from "./cli-c60vetmm.js";
18
+ } from "./cli-pc6n7fre.js";
19
19
  import {
20
20
  MODEL_TIERS,
21
21
  DEFAULT_MODEL_TIER_MAP,
22
22
  ProviderNameSchema,
23
23
  init_types4
24
- } from "./cli-nhrvpaj7.js";
24
+ } from "./cli-n6bv12jn.js";
25
25
  import {
26
26
  __esm
27
27
  } from "./cli-242037k3.js";
@@ -4,7 +4,7 @@ import {
4
4
  claimKv2,
5
5
  deleteKv2,
6
6
  init_db4
7
- } from "./cli-k2gzwsj2.js";
7
+ } from "./cli-wk5yrfwd.js";
8
8
  import {
9
9
  isEnvFlagEnabled,
10
10
  init_env_flag
@@ -1566,7 +1566,7 @@ function modelsAreEqual(a, b) {
1566
1566
  return getModelType(a) === getModelType(b) && a.id === b.id && a.provider === b.provider;
1567
1567
  }
1568
1568
  var KNOWN_MODEL_TYPES, EXTENDED_THINKING_LEVELS;
1569
- var init_models2 = __esm(() => {
1569
+ var init_models = __esm(() => {
1570
1570
  init_lazy();
1571
1571
  init_context();
1572
1572
  init_credential_store();
@@ -1584,4 +1584,4 @@ var init_models2 = __esm(() => {
1584
1584
  EXTENDED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
1585
1585
  });
1586
1586
 
1587
- export { lazyStream, lazyApi, init_lazy, defaultProviderAuthContext, init_context, InMemoryCredentialStore, init_credential_store, ModelsError, InMemoryModelsStore, init_models_store, AI_TELEMETRY_SCHEMA, getModelType, isModelType, assertChatModel, assertImageModel, assertClassifierModel, assertClassifierInputSupported, imageErrorResult, classifierErrorResult, init_model_operations, contentText, getSystemMessageText, renderSystemMessageUpdate, init_text, createInitialSystemMessage, normalizeContext, getInitialSystemMessage, withoutInitialSystemMessage, getCurrentTools, getCurrentSystemMessage, getCurrentSystemPrompt, collapseSystemMessages, resolveTranscript, toToolDeclaration, declarationsEqual, getToolStateChanges, getDeclaredTools, hasToolRedefinitions, hasNonAdditiveToolChanges, resolveTranscriptTools, init_transcript, createModels, createProvider, hasApi, calculateCost, getSupportedThinkingLevels, clampThinkingLevel, modelsAreEqual, exports_models, init_models2 };
1587
+ export { lazyStream, lazyApi, init_lazy, defaultProviderAuthContext, init_context, InMemoryCredentialStore, init_credential_store, ModelsError, InMemoryModelsStore, init_models_store, AI_TELEMETRY_SCHEMA, getModelType, isModelType, assertChatModel, assertImageModel, assertClassifierModel, assertClassifierInputSupported, imageErrorResult, classifierErrorResult, init_model_operations, contentText, getSystemMessageText, renderSystemMessageUpdate, init_text, createInitialSystemMessage, normalizeContext, getInitialSystemMessage, withoutInitialSystemMessage, getCurrentTools, getCurrentSystemMessage, getCurrentSystemPrompt, collapseSystemMessages, resolveTranscript, toToolDeclaration, declarationsEqual, getToolStateChanges, getDeclaredTools, hasToolRedefinitions, hasNonAdditiveToolChanges, resolveTranscriptTools, init_transcript, createModels, createProvider, hasApi, calculateCost, getSupportedThinkingLevels, clampThinkingLevel, modelsAreEqual, exports_models, init_models };
@@ -7,9 +7,8 @@ import {
7
7
  init_steering_enabled
8
8
  } from "./cli-4sydckyj.js";
9
9
  import {
10
- init_templates4
11
- } from "./cli-2pnswgh8.js";
12
- import {
10
+ registerTemplate,
11
+ init_registry3,
13
12
  resolveTemplateAsync,
14
13
  init_resolver,
15
14
  init_session_templates
@@ -22,7 +21,7 @@ import {
22
21
  buildAgentFsLiveUrl,
23
22
  buildCombFileUrl,
24
23
  init_constants3
25
- } from "./cli-611a1294.js";
24
+ } from "./cli-k0wwfqbg.js";
26
25
  import {
27
26
  scrubSecrets,
28
27
  init_secret_scrubber
@@ -254,6 +253,186 @@ what you learned about your strengths. Edit this file directly.
254
253
  }
255
254
  var init_defaults = () => {};
256
255
 
256
+ // src/commands/templates.ts
257
+ var init_templates4 = __esm(() => {
258
+ init_registry3();
259
+ registerTemplate({
260
+ eventType: "task.trigger.assigned",
261
+ header: "",
262
+ defaultBody: `{{work_on_task_cmd}} {{task_id}}{{task_desc_section}}{{attachments_section}}{{output_instructions}}`,
263
+ variables: [
264
+ { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
265
+ { name: "task_id", description: "Task ID" },
266
+ { name: "task_desc_section", description: "Task description section or empty string" },
267
+ {
268
+ name: "attachments_section",
269
+ description: "Ready-to-run fetch recipe per task attachment (or empty string if none) — lets the agent download an attachment in one call instead of discovering the path/provider itself"
270
+ },
271
+ {
272
+ name: "output_instructions",
273
+ description: "Output format instructions (with outputSchema if present, or generic store-progress)"
274
+ }
275
+ ],
276
+ category: "task_lifecycle"
277
+ });
278
+ registerTemplate({
279
+ eventType: "task.trigger.offered",
280
+ header: "",
281
+ defaultBody: `{{review_offered_task_cmd}} {{task_id}}{{task_desc_section}}
282
+
283
+ Accept if you have capacity and skills. Reject with a reason if you cannot handle it.`,
284
+ variables: [
285
+ { name: "review_offered_task_cmd", description: "Formatted /review-offered-task command" },
286
+ { name: "task_id", description: "Task ID" },
287
+ { name: "task_desc_section", description: "Task description section or empty string" }
288
+ ],
289
+ category: "task_lifecycle"
290
+ });
291
+ registerTemplate({
292
+ eventType: "task.profile_sync_rejection",
293
+ header: "",
294
+ defaultBody: `=== PERSISTED PROFILE SYNC REJECTION ===
295
+ A {{timestamp}} sync of {{field_label}} did not reach the database. Disk size: {{disk_size}}; DB size: {{db_size}}; budget: {{budget}}; delta: {{delta}}.
296
+ Audit event: {{event_id}}. {{recovery_guidance}}
297
+ === END PROFILE SYNC REJECTION ===
298
+
299
+ `,
300
+ variables: [
301
+ { name: "timestamp", description: "UTC timestamp of the rejected sync" },
302
+ { name: "field_label", description: "Profile field and its harness-specific file path" },
303
+ { name: "disk_size", description: "Rejected local file size" },
304
+ { name: "db_size", description: "Stored database field size" },
305
+ { name: "budget", description: "Configured field budget" },
306
+ { name: "delta", description: "Signed size delta" },
307
+ { name: "event_id", description: "Persisted audit event ID" },
308
+ { name: "recovery_guidance", description: "Accurate field-specific recovery instructions" }
309
+ ],
310
+ category: "task_lifecycle"
311
+ });
312
+ registerTemplate({
313
+ eventType: "task.nudge.empty_final_turn",
314
+ header: "",
315
+ defaultBody: `Your last turn returned no text and no tool call. Finish now: if the task needs a result, call store-progress with it.`,
316
+ variables: [],
317
+ category: "task_lifecycle"
318
+ });
319
+ registerTemplate({
320
+ eventType: "task.trigger.unread_mentions",
321
+ header: "",
322
+ defaultBody: `You have {{mention_count}} mention(s) in chat channels.
323
+
324
+ 1. Use \`read-messages\` with unreadOnly: true to see them
325
+ 2. Respond to questions or requests directed at you
326
+ 3. If a message requires work, create a task using \`send-task\``,
327
+ variables: [{ name: "mention_count", description: "Number of unread mentions or 'unread'" }],
328
+ category: "task_lifecycle"
329
+ });
330
+ registerTemplate({
331
+ eventType: "task.trigger.pool_available",
332
+ header: "",
333
+ defaultBody: `{{task_count}} task(s) available in the pool.
334
+
335
+ 1. Run \`get-tasks\` with unassigned: true to browse
336
+ 2. Pick one matching your skills
337
+ 3. Run \`task-action\` with action: "claim" and taskId: "<id>"
338
+
339
+ Note: Claims are first-come-first-serve. If claim fails, pick another.`,
340
+ variables: [{ name: "task_count", description: "Number of available pool tasks" }],
341
+ category: "task_lifecycle"
342
+ });
343
+ registerTemplate({
344
+ eventType: "task.trigger.channel_activity",
345
+ header: "",
346
+ defaultBody: `## Slack Channel Activity
347
+
348
+ {{message_count}} new message(s) in monitored Slack channels:
349
+
350
+ {{messages_detail}}
351
+ ## Your Task
352
+
353
+ Review these messages and decide if any require action:
354
+ 1. If a message is a question or request, respond using \`slack-reply\` or create a task with \`send-task\`
355
+ 2. If a message is informational, no action needed
356
+ 3. Use \`slack-read\` with the channelId to get more context if needed`,
357
+ variables: [
358
+ { name: "message_count", description: "Number of new messages" },
359
+ {
360
+ name: "messages_detail",
361
+ description: "Formatted list of messages with channel and user info"
362
+ }
363
+ ],
364
+ category: "task_lifecycle"
365
+ });
366
+ registerTemplate({
367
+ eventType: "task.resumption.with_progress",
368
+ header: "",
369
+ defaultBody: `{{work_on_task_cmd}} {{task_id}}
370
+
371
+ **RESUMED TASK** - This task was interrupted during a deployment and is being resumed.
372
+
373
+ Task: "{{task_description}}"{{attachments_section}}
374
+
375
+ Previous Progress:
376
+ {{progress}}
377
+
378
+ Continue from where you left off. Review the progress above and complete the remaining work.{{completion_instructions}}`,
379
+ variables: [
380
+ { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
381
+ { name: "task_id", description: "Task ID" },
382
+ { name: "task_description", description: "Original task description" },
383
+ { name: "attachments_section", description: "Task attachment fetch recipes" },
384
+ { name: "progress", description: "Previous progress text" },
385
+ {
386
+ name: "completion_instructions",
387
+ description: "Completion instructions (empty for providers without MCP)"
388
+ }
389
+ ],
390
+ category: "task_lifecycle"
391
+ });
392
+ registerTemplate({
393
+ eventType: "task.resumption.no_progress",
394
+ header: "",
395
+ defaultBody: `{{work_on_task_cmd}} {{task_id}}
396
+
397
+ **RESUMED TASK** - This task was interrupted during a deployment and is being resumed.
398
+
399
+ Task: "{{task_description}}"{{attachments_section}}
400
+
401
+ No progress was saved before the interruption. Start the task fresh but be aware files may have been partially modified.{{completion_instructions}}`,
402
+ variables: [
403
+ { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
404
+ { name: "task_id", description: "Task ID" },
405
+ { name: "task_description", description: "Original task description" },
406
+ { name: "attachments_section", description: "Task attachment fetch recipes" },
407
+ {
408
+ name: "completion_instructions",
409
+ description: "Completion instructions (empty for providers without MCP)"
410
+ }
411
+ ],
412
+ category: "task_lifecycle"
413
+ });
414
+ registerTemplate({
415
+ eventType: "task.output.schema",
416
+ header: "",
417
+ defaultBody: `
418
+
419
+ **Required Output Format**: When completing this task, you MUST call store-progress with output that is valid JSON conforming to this schema:
420
+ \`\`\`json
421
+ {{schema}}
422
+ \`\`\`
423
+ Call store-progress with status "completed" and your JSON output. If your output doesn't match the schema, the tool call will fail and you should fix and retry.`,
424
+ variables: [{ name: "schema", description: "Required output JSON schema" }],
425
+ category: "task_lifecycle"
426
+ });
427
+ registerTemplate({
428
+ eventType: "task.output.generic",
429
+ header: "",
430
+ defaultBody: '\n\nWhen done, use `store-progress` with status: "completed" and include your output.',
431
+ variables: [],
432
+ category: "task_lifecycle"
433
+ });
434
+ });
435
+
257
436
  // src/prompts/base-prompt.ts
258
437
  function claudeMdSourcePath(provider) {
259
438
  return provider === "claude" ? "~/.claude/CLAUDE.md" : "/workspace/CLAUDE.md";
@@ -1031,6 +1210,7 @@ var init_context_preamble = __esm(() => {
1031
1210
  });
1032
1211
 
1033
1212
  // src/commands/profile-sync.ts
1213
+ import { rename } from "node:fs/promises";
1034
1214
  function contentSha256(content) {
1035
1215
  return new Bun.CryptoHasher("sha256").update(content).digest("hex");
1036
1216
  }
@@ -1154,7 +1334,30 @@ async function prependProfileSyncRejectionBanner(prompt, config, fetchImpl = fet
1154
1334
  return banner ? { prompt: prependContextPreamble(prompt, banner), injected: true } : { prompt, injected: false };
1155
1335
  }
1156
1336
  async function writeIdentityBaselines(baselines) {
1157
- await Bun.write(IDENTITY_BASELINES_PATH, JSON.stringify(baselines));
1337
+ const write = () => writeFileAtomic(IDENTITY_BASELINES_PATH, JSON.stringify(baselines));
1338
+ const locked = await withFileLock(IDENTITY_BASELINES_LOCK_PATH, write, {
1339
+ waitMs: BASELINES_LOCK_WAIT_MS
1340
+ });
1341
+ if (!locked.acquired)
1342
+ await write();
1343
+ }
1344
+ function bootIdentityBaselines(profile, setupScriptFile, agentId = "unknown") {
1345
+ const baselines = {};
1346
+ if (profile.soulMd)
1347
+ baselines.soulMd = contentSha256(profile.soulMd);
1348
+ if (profile.identityMd)
1349
+ baselines.identityMd = contentSha256(profile.identityMd);
1350
+ if (profile.toolsMd)
1351
+ baselines.toolsMd = contentSha256(profile.toolsMd);
1352
+ if (typeof profile.heartbeatMd === "string") {
1353
+ baselines.heartbeatMd = contentSha256(profile.heartbeatMd);
1354
+ }
1355
+ if (profile.claudeMd)
1356
+ baselines.claudeMd = contentSha256(profile.claudeMd);
1357
+ const setupContent = setupScriptFile === undefined ? null : extractSetupScriptContent(setupScriptFile, agentId);
1358
+ if (setupContent)
1359
+ baselines.setupScript = contentSha256(setupContent);
1360
+ return baselines;
1158
1361
  }
1159
1362
  async function readIdentityBaselines(readFile = readFileIfExists) {
1160
1363
  try {
@@ -1166,6 +1369,30 @@ async function readIdentityBaselines(readFile = readFileIfExists) {
1166
1369
  return null;
1167
1370
  }
1168
1371
  }
1372
+ async function advanceIdentityBaselines(synced, io = PROFILE_FILE_IO) {
1373
+ if (Object.keys(synced).length === 0)
1374
+ return;
1375
+ const update = async () => {
1376
+ const baselines = await readIdentityBaselines(io.readFile) ?? {};
1377
+ for (const [field, content] of Object.entries(synced)) {
1378
+ baselines[field] = contentSha256(content);
1379
+ }
1380
+ await io.writeFile(IDENTITY_BASELINES_PATH, JSON.stringify(baselines));
1381
+ };
1382
+ try {
1383
+ const locked = await withFileLock(io.baselinesLockPath ?? IDENTITY_BASELINES_LOCK_PATH, update, {
1384
+ waitMs: BASELINES_LOCK_WAIT_MS
1385
+ });
1386
+ if (locked.acquired)
1387
+ return;
1388
+ if (locked.reason === "unsupported")
1389
+ return await update();
1390
+ console.warn(`[profile-sync] identity baselines not advanced: lock ${locked.reason}`);
1391
+ } catch (err) {
1392
+ const msg = err instanceof Error ? err.message : String(err);
1393
+ console.warn(scrubSecrets(`[profile-sync] identity baselines not advanced: ${msg}`));
1394
+ }
1395
+ }
1169
1396
  function fetchWithSyncTimeout(fetchImpl = fetch) {
1170
1397
  return (input, init) => fetchImpl(input, {
1171
1398
  ...init,
@@ -1326,9 +1553,14 @@ async function readFileIfExists(path) {
1326
1553
  return;
1327
1554
  }
1328
1555
  }
1556
+ async function writeFileAtomic(path, content) {
1557
+ const tmp = `${path}.${process.pid}.${crypto.randomUUID()}.tmp`;
1558
+ await Bun.write(tmp, content);
1559
+ await rename(tmp, path);
1560
+ }
1329
1561
  async function collectProfilePayloads(fields, changeSource, readFile = readFileIfExists, claudeMdPath = CLAUDE_MD_PATH, agentId = "unknown") {
1330
1562
  const payloads = [];
1331
- const baselines = changeSource === "session_sync" ? await readIdentityBaselines(readFile) : null;
1563
+ const baselines = await readIdentityBaselines(readFile);
1332
1564
  if (fields.includes("identity")) {
1333
1565
  const updates = buildIdentityPayload({
1334
1566
  soulMd: await readFile(SOUL_MD_PATH),
@@ -1355,7 +1587,7 @@ async function collectProfilePayloads(fields, changeSource, readFile = readFileI
1355
1587
  const raw = await readFile(SETUP_SCRIPT_PATH);
1356
1588
  if (raw !== undefined) {
1357
1589
  const content = extractSetupScriptContent(raw, agentId);
1358
- if (content !== null) {
1590
+ if (content !== null && baselines?.setupScript !== contentSha256(content)) {
1359
1591
  payloads.push({ label: "setup", body: { setupScript: content, changeSource } });
1360
1592
  }
1361
1593
  }
@@ -1381,10 +1613,20 @@ async function postProfileUpdate(opts, payload) {
1381
1613
  } catch {}
1382
1614
  console.warn(scrubSecrets(`[profile-sync] ${payload.label} sync failed: HTTP ${resp.status}${detail ? ` — ${detail}` : ""}`));
1383
1615
  }
1616
+ return resp.ok;
1384
1617
  } catch (err) {
1385
1618
  const msg = err instanceof Error ? err.message : String(err);
1386
1619
  console.warn(scrubSecrets(`[profile-sync] ${payload.label} sync errored: ${msg}`));
1620
+ return false;
1621
+ }
1622
+ }
1623
+ function baselineFieldsOf(payload) {
1624
+ const fields = {};
1625
+ for (const [field, value] of Object.entries(payload.body)) {
1626
+ if (field !== "changeSource" && typeof value === "string")
1627
+ fields[field] = value;
1387
1628
  }
1629
+ return fields;
1388
1630
  }
1389
1631
  async function syncProfileFilesToServer(opts) {
1390
1632
  const changeSource = opts.changeSource ?? "session_sync";
@@ -1392,15 +1634,19 @@ async function syncProfileFilesToServer(opts) {
1392
1634
  const claudeMdPath = opts.claudeMdPath ?? CLAUDE_MD_PATH;
1393
1635
  const claudeUnderLock = fields.includes("claude") && syncsHookOwnedClaudeMd(claudeMdPath, changeSource);
1394
1636
  const unlockedFields = claudeUnderLock ? fields.filter((f) => f !== "claude") : fields;
1395
- const payloads = await collectProfilePayloads(unlockedFields, changeSource, readFileIfExists, claudeMdPath, opts.agentId);
1637
+ const io = opts.io ?? PROFILE_FILE_IO;
1638
+ const payloads = await collectProfilePayloads(unlockedFields, changeSource, io.readFile, claudeMdPath, opts.agentId);
1639
+ const synced = {};
1396
1640
  for (const payload of payloads) {
1397
- await postProfileUpdate(opts, payload);
1641
+ if (await postProfileUpdate(opts, payload))
1642
+ Object.assign(synced, baselineFieldsOf(payload));
1398
1643
  }
1644
+ await advanceIdentityBaselines(synced, io);
1399
1645
  if (claudeUnderLock) {
1400
1646
  const { path: lockPath = CLAUDE_MD_LOCK_PATH, waitMs = RUNNER_LOCK_WAIT_MS } = opts.claudeMdLock ?? {};
1401
1647
  const bounded = { ...opts, fetchImpl: fetchWithSyncTimeout(opts.fetchImpl) };
1402
1648
  const locked = await withFileLock(lockPath, async () => {
1403
- const claude = await collectProfilePayloads(["claude"], changeSource, readFileIfExists, claudeMdPath, opts.agentId);
1649
+ const claude = await collectProfilePayloads(["claude"], changeSource, io.readFile, claudeMdPath, opts.agentId);
1404
1650
  for (const payload of claude)
1405
1651
  await postProfileUpdate(bounded, payload);
1406
1652
  }, { waitMs });
@@ -1410,7 +1656,7 @@ async function syncProfileFilesToServer(opts) {
1410
1656
  }
1411
1657
  }
1412
1658
  }
1413
- var SOUL_MD_PATH = "/workspace/SOUL.md", IDENTITY_MD_PATH = "/workspace/IDENTITY.md", TOOLS_MD_PATH = "/workspace/TOOLS.md", HEARTBEAT_MD_PATH = "/workspace/HEARTBEAT.md", SETUP_SCRIPT_PATH = "/workspace/start-up.sh", IDENTITY_BASELINES_PATH = "/tmp/identity-baselines.json", PROFILE_FIELD_DETAILS, PROFILE_SYNC_REJECTED = "system.profile_sync_rejected", PROFILE_SYNC_RECONCILED = "system.profile_sync_reconciled", CLAUDE_MD_PATH, CLAUDE_MD_LINEAGE_PATH, CLAUDE_MD_LOCK_PATH, CLAUDE_MD_SYNC_TIMEOUT_MS = 1e4, RUNNER_LOCK_WAIT_MS = 15000, SHA256_HEX, WORKSPACE_CLAUDE_MD_PATH = "/workspace/CLAUDE.md", IDENTITY_FILE_MIN_LENGTH = 500, SETUP_MARKER_START = "# === Agent-managed setup (from DB) ===", SETUP_MARKER_END = "# === End agent-managed setup ===";
1659
+ var SOUL_MD_PATH = "/workspace/SOUL.md", IDENTITY_MD_PATH = "/workspace/IDENTITY.md", TOOLS_MD_PATH = "/workspace/TOOLS.md", HEARTBEAT_MD_PATH = "/workspace/HEARTBEAT.md", SETUP_SCRIPT_PATH = "/workspace/start-up.sh", IDENTITY_BASELINES_PATH = "/tmp/identity-baselines.json", PROFILE_FIELD_DETAILS, PROFILE_SYNC_REJECTED = "system.profile_sync_rejected", PROFILE_SYNC_RECONCILED = "system.profile_sync_reconciled", IDENTITY_BASELINES_LOCK_PATH, BASELINES_LOCK_WAIT_MS = 5000, PROFILE_FILE_IO, CLAUDE_MD_PATH, CLAUDE_MD_LINEAGE_PATH, CLAUDE_MD_LOCK_PATH, CLAUDE_MD_SYNC_TIMEOUT_MS = 1e4, RUNNER_LOCK_WAIT_MS = 15000, SHA256_HEX, WORKSPACE_CLAUDE_MD_PATH = "/workspace/CLAUDE.md", IDENTITY_FILE_MIN_LENGTH = 500, SETUP_MARKER_START = "# === Agent-managed setup (from DB) ===", SETUP_MARKER_END = "# === End agent-managed setup ===";
1414
1660
  var init_profile_sync = __esm(() => {
1415
1661
  init_resolver();
1416
1662
  init_constants3();
@@ -1437,10 +1683,15 @@ var init_profile_sync = __esm(() => {
1437
1683
  recoveryGuidance: `Inspect and shrink the live ${TOOLS_MD_PATH} first, moving durable tail content into memory. After a worker restart, use ${TOOLS_MD_PATH}.pre-boot-<timestamp>.bak as the fallback copy of the rejected content.`
1438
1684
  }
1439
1685
  };
1686
+ IDENTITY_BASELINES_LOCK_PATH = `${IDENTITY_BASELINES_PATH}.lock`;
1687
+ PROFILE_FILE_IO = {
1688
+ readFile: readFileIfExists,
1689
+ writeFile: writeFileAtomic
1690
+ };
1440
1691
  CLAUDE_MD_PATH = `${process.env.HOME}/.claude/CLAUDE.md`;
1441
1692
  CLAUDE_MD_LINEAGE_PATH = `${CLAUDE_MD_PATH}.lineage.json`;
1442
1693
  CLAUDE_MD_LOCK_PATH = `${CLAUDE_MD_PATH}.lock`;
1443
1694
  SHA256_HEX = /^[0-9a-f]{64}$/;
1444
1695
  });
1445
1696
 
1446
- export { generateDefaultClaudeMd2, generateDefaultSoulMd2, generateDefaultIdentityMd2, generateDefaultToolsMd2, matchesDefaultIdentityMd, matchesDefaultClaudeMd, init_defaults, getBasePrompt, getTaskContextPrompt, init_base_prompt, IDENTITY_FIELD_BUDGETS, checkIdentityFieldBudget, IdentityFieldBudgetError, init_identity_field_budget, withFileLock, init_file_lock, taskAttachmentFetchCommand, taskAttachmentDisplayUrl, init_task_attachment_links, prependContextPreamble, buildContextPreamble, buildResumeContextPreamble, init_context_preamble, contentSha256, prependProfileSyncRejectionBanner, writeIdentityBaselines, readIdentityBaselines, CLAUDE_MD_PATH, CLAUDE_MD_LINEAGE_PATH, CLAUDE_MD_LOCK_PATH, fetchWithSyncTimeout, parseClaudeMdLineage, claudeMdPendingRecord, parseClaudeMdPendingRecord, hookWrittenLineage, effectiveClaudeMdLineage, claudeMdLineageOf, planClaudeMdSync, WORKSPACE_CLAUDE_MD_PATH, warnProfileFileTooLarge, writeProfileFileFromDb, resolveClaudeMdPath, buildIndependentIdentityPayloads, syncProfileFilesToServer, init_profile_sync };
1697
+ export { generateDefaultClaudeMd2, generateDefaultSoulMd2, generateDefaultIdentityMd2, generateDefaultToolsMd2, matchesDefaultIdentityMd, matchesDefaultClaudeMd, init_defaults, init_templates4, getBasePrompt, getTaskContextPrompt, init_base_prompt, IDENTITY_FIELD_BUDGETS, checkIdentityFieldBudget, IdentityFieldBudgetError, init_identity_field_budget, withFileLock, init_file_lock, taskAttachmentFetchCommand, taskAttachmentDisplayUrl, init_task_attachment_links, prependContextPreamble, buildContextPreamble, buildResumeContextPreamble, init_context_preamble, contentSha256, prependProfileSyncRejectionBanner, PROFILE_FILE_IO, writeIdentityBaselines, bootIdentityBaselines, readIdentityBaselines, advanceIdentityBaselines, CLAUDE_MD_PATH, CLAUDE_MD_LINEAGE_PATH, CLAUDE_MD_LOCK_PATH, fetchWithSyncTimeout, parseClaudeMdLineage, claudeMdPendingRecord, parseClaudeMdPendingRecord, hookWrittenLineage, effectiveClaudeMdLineage, claudeMdLineageOf, planClaudeMdSync, WORKSPACE_CLAUDE_MD_PATH, warnProfileFileTooLarge, writeProfileFileFromDb, resolveClaudeMdPath, buildIndependentIdentityPayloads, syncProfileFilesToServer, init_profile_sync };