@desplega.ai/agent-swarm 1.160.0 → 1.162.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 (398) hide show
  1. package/README.md +4 -3
  2. package/dist/{acp-adapter-2mjwcsfh.js → acp-adapter-74m73ae9.js} +163 -49
  3. package/dist/{actions-e43rxskr.js → actions-4sr14gnt.js} +42 -38
  4. package/dist/{anthropic-messages-5qx80j9k.js → anthropic-messages-8xxrzky9.js} +22 -26
  5. package/dist/{app-mc7xfagn.js → app-pt68fbwp.js} +17 -14
  6. package/dist/{artifact-3v5t9jtg.js → artifact-fey7dvj9.js} +3 -2
  7. package/dist/{assistant-sedkzv3b.js → assistant-cv3jytks.js} +43 -39
  8. package/dist/{azure-openai-responses-nfb21z9a.js → azure-openai-responses-f5cqsyj8.js} +15 -10
  9. package/dist/{boot-reembed-m3656j2n.js → boot-reembed-4ht4gqth.js} +17 -14
  10. package/dist/{boot-reembed-cqz9swn5.js → boot-reembed-nxpcvpj9.js} +16 -13
  11. package/dist/{boot-scrub-logs-xbxf5d7w.js → boot-scrub-logs-k93kyw8k.js} +13 -10
  12. package/dist/boot-seeds-1skcrs0e.js +32 -0
  13. package/dist/{claude-adapter-dc6289mc.js → claude-adapter-r5g0tzge.js} +39 -30
  14. package/dist/{claude-managed-adapter-naaw51me.js → claude-managed-adapter-yxkfxg8j.js} +6 -5
  15. package/dist/{claude-managed-setup-eacvchx0.js → claude-managed-setup-pkyrgshb.js} +27 -27
  16. package/dist/{claude-sdk-session-bqp2xvym.js → claude-sdk-session-jxyxnrwd.js} +8041 -7910
  17. package/dist/{cli-4derpgyk.js → cli-2hhfhfq5.js} +6 -1
  18. package/dist/{cli-rykfmgwg.js → cli-2x0e561b.js} +1 -1
  19. package/dist/{cli-tzx2ke1v.js → cli-2zy95vhm.js} +137 -64
  20. package/dist/{cli-0x01kwrd.js → cli-4cwxn7gp.js} +47 -186
  21. package/dist/{cli-xjcywfsf.js → cli-4dcpaefp.js} +12 -11
  22. package/dist/{cli-v7fn5gms.js → cli-4x0csdjq.js} +164 -76
  23. package/dist/{cli-12tszpk9.js → cli-5bcd7sfy.js} +91 -29
  24. package/dist/{cli-jz4w45qt.js → cli-5k6k8ta3.js} +190 -50
  25. package/dist/{cli-tpq83z89.js → cli-5xhpb3kv.js} +20 -19
  26. package/dist/{cli-r1mxd1xh.js → cli-7af8yhav.js} +6 -179
  27. package/dist/{cli-jajnsm8q.js → cli-7tre70zp.js} +18160 -31345
  28. package/dist/{cli-447dt1h3.js → cli-8ev9xqnx.js} +218 -25
  29. package/dist/cli-bsky8g7w.js +449 -0
  30. package/dist/{cli-0z2v4nhw.js → cli-cat6h73s.js} +1 -1
  31. package/dist/{cli-25fcq4b4.js → cli-cebmgwsc.js} +15 -11
  32. package/dist/{cli-shkxm1vn.js → cli-cvatsam7.js} +189 -13
  33. package/dist/{cli-2658f6at.js → cli-cvk6yzw5.js} +6 -8
  34. package/dist/cli-dbmwby6a.js +9 -0
  35. package/dist/{cli-ptr8h7kp.js → cli-eg0b3p0k.js} +5 -218
  36. package/dist/cli-f9w1semm.js +413 -0
  37. package/dist/{cli-523679eh.js → cli-g739zqzt.js} +6 -5
  38. package/dist/{cli-dv6cdjs2.js → cli-gd4favx9.js} +28 -7
  39. package/dist/{cli-c8a36vcc.js → cli-gpqpmns7.js} +2 -2
  40. package/dist/{cli-5nbmpy8w.js → cli-hb5c2x5y.js} +1 -1
  41. package/dist/{cli-741yb0xx.js → cli-hmsw1gpy.js} +55 -169
  42. package/dist/{cli-qydf22qq.js → cli-jf7wmv1r.js} +2562 -735
  43. package/dist/{cli-mfe5btp9.js → cli-jxs2ygaw.js} +317 -121
  44. package/dist/{cli-kmcpfwn2.js → cli-jyy6pm2f.js} +19 -3
  45. package/dist/cli-kdkwd3yr.js +615 -0
  46. package/dist/{cli-6cs6wzxt.js → cli-kh04eqwe.js} +2 -2
  47. package/dist/{cli-9hsgwz4w.js → cli-kp42yek0.js} +1309 -391
  48. package/dist/cli-ma3zvh39.js +10404 -0
  49. package/dist/{cli-ybgv4kw2.js → cli-mbssg1xv.js} +9 -2
  50. package/dist/{cli-jsp14b6c.js → cli-mzfth0bp.js} +38 -1
  51. package/dist/{cli-r2ap2czm.js → cli-nexqx4ve.js} +6 -0
  52. package/dist/{cli-f8gy6r2r.js → cli-nq7yqw7b.js} +19 -8
  53. package/dist/{cli-10nhj6xq.js → cli-nt8hecg9.js} +34 -33
  54. package/dist/cli-p0r8sxj5.js +303 -0
  55. package/dist/{cli-58e8yr0d.js → cli-pkd6s2wy.js} +4 -2
  56. package/dist/{cli-a8dvhzrt.js → cli-q24re23n.js} +7 -5
  57. package/dist/cli-qjjvzwzd.js +222 -0
  58. package/dist/cli-qrgt5bqf.js +189 -0
  59. package/dist/{cli-et8m9xsv.js → cli-rfjw9jw2.js} +22 -10
  60. package/dist/{cli-7e398j1h.js → cli-rj0gqwwp.js} +3 -3
  61. package/dist/{cli-btfv8y88.js → cli-rnyzn44p.js} +2 -2
  62. package/dist/{cli-d5czme6m.js → cli-s3hwpt9v.js} +4754 -4945
  63. package/dist/{cli-0jwe9034.js → cli-sptrj5f5.js} +3 -3
  64. package/dist/{cli-0q3avq3s.js → cli-sqvfa090.js} +19 -11
  65. package/dist/{cli-azhgzetg.js → cli-swfmp1fx.js} +27 -27
  66. package/dist/{cli-jyk0ynw2.js → cli-t845n9xk.js} +23 -10
  67. package/dist/{cli-zpep9q5e.js → cli-tcen9p5w.js} +20 -15
  68. package/dist/{cli-74h9hscv.js → cli-tre4bdgq.js} +1 -1
  69. package/dist/{cli-pm1rst0h.js → cli-twrh04ap.js} +30 -15
  70. package/dist/{cli-phsaj4xq.js → cli-v0pvvhfq.js} +1 -1
  71. package/dist/{cli-ydmcgve1.js → cli-vc9bp061.js} +5 -5
  72. package/dist/{cli-g2whhdrf.js → cli-vxe6qa4h.js} +1 -1
  73. package/dist/{cli-vctdqs5h.js → cli-vy3ed88x.js} +15 -2
  74. package/dist/{cli-br0qdrnp.js → cli-vyqs9ya8.js} +18 -18
  75. package/dist/{cli-cpvsaqsw.js → cli-w0bwte75.js} +8 -5
  76. package/dist/cli-wbvnn6tk.js +861 -0
  77. package/dist/{cli-r94z9p1z.js → cli-wgbezhw2.js} +3 -0
  78. package/dist/{cli-evvtk35y.js → cli-wjgs5wxe.js} +7 -7
  79. package/dist/cli-wxkkd0e0.js +33 -0
  80. package/dist/{cli-0wgxmwf6.js → cli-xk79303e.js} +20 -7
  81. package/dist/{cli-ktmyrtpn.js → cli-xqpk3rp7.js} +33 -10
  82. package/dist/{cli-ygwm91nt.js → cli-yy6dew39.js} +1 -1
  83. package/dist/cli-zp38xvtm.js +9487 -0
  84. package/dist/{cli-tfky2838.js → cli-zvhd3f64.js} +4 -4
  85. package/dist/{cli-jayjpjmb.js → cli-zxqx25nz.js} +66 -23
  86. package/dist/cli.js +40 -32
  87. package/dist/{cloudflare-workers-ai-system-one-k6fbxw9d.js → cloudflare-workers-ai-system-one-k8ddqjkq.js} +8 -6
  88. package/dist/{codex-adapter-nmxcatww.js → codex-adapter-esvmnhn7.js} +24 -23
  89. package/dist/{codex-hook-20me6byw.js → codex-hook-m73jmqgx.js} +19 -3
  90. package/dist/{codex-login-w6fz4xbz.js → codex-login-cf7mzsgg.js} +2 -2
  91. package/dist/{codex-session-runner-90aa80ev.js → codex-session-runner-ban9excr.js} +24 -23
  92. package/dist/{commands-8wcq1kn7.js → commands-75413p2n.js} +13 -10
  93. package/dist/{db-j40kc4se.js → db-7f5pecwg.js} +17 -10
  94. package/dist/{dispatcher-4zqy768d.js → dispatcher-fh9at8nz.js} +41 -37
  95. package/dist/dsh-adapter-wpze65d4.js +24 -0
  96. package/dist/{e2b-ez07znam.js → e2b-gjgdjp91.js} +12 -9
  97. package/dist/easter-egg-3d-3w5c2n4c.js +1057 -0
  98. package/dist/{execute-6e7qeyk4.js → execute-f50wg9nh.js} +203 -49
  99. package/dist/{google-generative-ai-k6n5nbpp.js → google-generative-ai-jxxpnegy.js} +2 -2
  100. package/dist/{google-vertex-44xxtcvp.js → google-vertex-x7q1angm.js} +5 -5
  101. package/dist/{handlers-kjdce1w5.js → handlers-w13787bb.js} +44 -40
  102. package/dist/{hook-r2t4bqfg.js → hook-46g1jrvx.js} +34 -20
  103. package/dist/{hook-czx13n12.js → hook-4tpts2ry.js} +25 -21
  104. package/dist/{http-3bbb19be.js → http-19pzbfrt.js} +1440 -283
  105. package/dist/{index-668me3f0.js → index-8fd4dm4h.js} +42 -38
  106. package/dist/{index-fg0dsp6c.js → index-dqmp15bq.js} +41 -37
  107. package/dist/{index-kkv84jq9.js → index-qb4q1y3e.js} +41 -37
  108. package/dist/index-s75wc4wd.js +33 -0
  109. package/dist/{index-zg7vp46x.js → index-scptvdxg.js} +64 -38
  110. package/dist/{keepalive-yra8dy57.js → keepalive-xa5ts9cd.js} +15 -12
  111. package/dist/{lead-va0pad2c.js → lead-qp4xkvjq.js} +59 -54
  112. package/dist/{maintenance-hqewtmyg.js → maintenance-rm5885hm.js} +17 -14
  113. package/dist/{mistral-conversations-pc3ntnxt.js → mistral-conversations-rw7fbt22.js} +4 -4
  114. package/dist/{node-a5e00qhp.js → node-8zkdq42h.js} +834 -833
  115. package/dist/node-f0ykebbv.js +2107 -0
  116. package/dist/node-wyamey5r.js +19 -0
  117. package/dist/{oauth-refresh-sweep-7rdt1m9n.js → oauth-refresh-sweep-1csdfebf.js} +14 -11
  118. package/dist/{onboard-j6ms6d0x.js → onboard-r6b78cs4.js} +10 -10
  119. package/dist/{openai-codex-responses-bbancrr0.js → openai-codex-responses-efvrgrq3.js} +4 -4
  120. package/dist/{openai-completions-jpaj5g2b.js → openai-completions-bbbrrz4z.js} +12 -8
  121. package/dist/{openai-responses-200k1wx4.js → openai-responses-9jjyrcm1.js} +15 -10
  122. package/dist/{opencode-adapter-89rabkw2.js → opencode-adapter-kb3g6pkf.js} +12 -9
  123. package/dist/{otel-impl-a792rjz0.js → otel-impl-0y9knpky.js} +6 -6
  124. package/dist/{pi-mono-adapter-g7qzvr3v.js → pi-mono-adapter-z6s1bme2.js} +128 -37
  125. package/dist/{pricing-refresh-wx0tp7cb.js → pricing-refresh-mth26tgp.js} +15 -12
  126. package/dist/{rbac-roles-8tzawacv.js → rbac-roles-kwntb23q.js} +17 -12
  127. package/dist/rbac-roles-vpk4ebm8.js +45 -0
  128. package/dist/{registry-v5wytg0s.js → registry-km6t1jd2.js} +1 -1
  129. package/dist/{render-v2-mm7zswb8.js → render-v2-hcm7h00y.js} +17 -14
  130. package/dist/{runtime-zyssgse0.js → runtime-vfjsfsc5.js} +5 -4
  131. package/dist/{setup-8y70ys6t.js → setup-hbyzd65h.js} +2 -2
  132. package/dist/{virtual-modules-6nmk7h3n.js → virtual-modules-9bv7ry91.js} +9 -7
  133. package/dist/{work-objects-fg6xkb0n.js → work-objects-m09sxnhe.js} +44 -40
  134. package/dist/{worker-wmwhxsph.js → worker-0h35rvk4.js} +59 -54
  135. package/dist/{x-n3e0v3xa.js → x-f1gt1pz3.js} +2 -2
  136. package/openapi.json +699 -26
  137. package/package.json +19 -11
  138. package/src/azure-devops/api.ts +121 -0
  139. package/src/azure-devops/auth.ts +78 -0
  140. package/src/azure-devops/handlers.ts +413 -0
  141. package/src/azure-devops/index.ts +27 -0
  142. package/src/azure-devops/templates.ts +108 -0
  143. package/src/azure-devops/types.ts +90 -0
  144. package/src/be/api-drain.ts +184 -0
  145. package/src/be/db/tasks/read.ts +32 -7
  146. package/src/be/db/tasks/write.ts +21 -4
  147. package/src/be/db-client.ts +11 -2
  148. package/src/be/db-retention.ts +95 -32
  149. package/src/be/db.ts +44 -19
  150. package/src/be/memory/constants.ts +16 -0
  151. package/src/be/memory/graph-expansion.ts +8 -1
  152. package/src/be/memory/index-content.ts +20 -1
  153. package/src/be/memory/key-guard.ts +93 -0
  154. package/src/be/memory/key-paths.ts +103 -0
  155. package/src/be/memory/link-resolver.ts +29 -3
  156. package/src/be/memory/providers/sqlite-store.ts +152 -45
  157. package/src/be/memory/raters/llm-summarizer.ts +10 -4
  158. package/src/be/memory/raters/llm.ts +15 -5
  159. package/src/be/memory/raters/store.ts +6 -3
  160. package/src/be/memory/raters/types.ts +11 -0
  161. package/src/be/memory/reranker.ts +38 -7
  162. package/src/be/memory/types.ts +12 -1
  163. package/src/be/migrations/190_memory_rating_model.sql +7 -0
  164. package/src/be/migrations/191_context_versions_previous_index.sql +8 -0
  165. package/src/be/migrations/192_favorites_agent_fs_path.sql +36 -0
  166. package/src/be/onboarding.ts +7 -1
  167. package/src/be/pricing-normalize.ts +4 -2
  168. package/src/be/scripts/typecheck.ts +4 -3
  169. package/src/be/seed-pricing.ts +16 -0
  170. package/src/be/seed-prompt-templates.ts +1 -0
  171. package/src/be/swarm-config-guard.ts +46 -17
  172. package/src/be/task-citations.ts +11 -5
  173. package/src/be/users.ts +3 -0
  174. package/src/cli.tsx +3 -2
  175. package/src/comb/agent-fs.ts +39 -0
  176. package/src/comb/config.ts +37 -0
  177. package/src/comb/markers.ts +37 -0
  178. package/src/comb/review-batch.ts +486 -0
  179. package/src/comb/templates.ts +88 -0
  180. package/src/commands/claude-managed-setup.ts +33 -31
  181. package/src/commands/context-preamble.ts +4 -1
  182. package/src/commands/hook.ts +2 -1
  183. package/src/commands/provider-credentials.ts +28 -15
  184. package/src/commands/runner.ts +458 -110
  185. package/src/commands/templates.ts +10 -0
  186. package/src/e2b/env.ts +2 -0
  187. package/src/extensions/catalog.generated.json +17 -0
  188. package/src/extensions/contract-types.generated.ts +1 -1
  189. package/src/fs/agent-fs-provider.ts +106 -2
  190. package/src/github/handlers.ts +10 -74
  191. package/src/github/reactions.ts +119 -138
  192. package/src/github/task-reactions.ts +34 -11
  193. package/src/heartbeat/heartbeat.ts +4 -0
  194. package/src/hooks/codex-hook.ts +25 -1
  195. package/src/hooks/hook.ts +14 -1
  196. package/src/hooks/pr-body-guard.ts +983 -0
  197. package/src/http/agents.ts +1 -1
  198. package/src/http/all-routes.ts +1 -0
  199. package/src/http/assets.ts +5 -17
  200. package/src/http/comb.ts +131 -0
  201. package/src/http/core.ts +14 -1
  202. package/src/http/extensions.ts +51 -27
  203. package/src/http/fs.ts +9 -17
  204. package/src/http/index.ts +27 -9
  205. package/src/http/mcp-user.ts +8 -13
  206. package/src/http/mcp.ts +19 -12
  207. package/src/http/memory.ts +80 -14
  208. package/src/http/onboarding.ts +21 -2
  209. package/src/http/poll.ts +30 -3
  210. package/src/http/realtime.ts +62 -0
  211. package/src/http/request-principal.ts +22 -0
  212. package/src/http/session-data.ts +6 -4
  213. package/src/http/stats.ts +1 -0
  214. package/src/http/status.ts +34 -2
  215. package/src/http/tasks.ts +17 -3
  216. package/src/http/users.ts +1 -1
  217. package/src/http/webhooks.ts +120 -2
  218. package/src/kv-reserved-namespaces.ts +10 -5
  219. package/src/providers/claude-adapter.ts +84 -16
  220. package/src/providers/claude-managed-adapter.ts +29 -2
  221. package/src/providers/codex-adapter.ts +1 -1
  222. package/src/providers/codex-skill-resolver.ts +6 -0
  223. package/src/providers/dsh-adapter.ts +204 -7
  224. package/src/providers/opencode-adapter.ts +24 -3
  225. package/src/providers/pi-mono-adapter.ts +154 -5
  226. package/src/providers/pi-mono-extension.ts +1 -1
  227. package/src/providers/pricing-sources.md +5 -1
  228. package/src/providers/reasoning-effort.ts +10 -2
  229. package/src/providers/types.ts +1 -1
  230. package/src/rbac/legacy-policy.ts +3 -0
  231. package/src/rbac/permissions.ts +14 -0
  232. package/src/realtime/auth.ts +63 -1
  233. package/src/realtime/tickets.ts +52 -0
  234. package/src/realtime/transport.ts +51 -22
  235. package/src/scripts-runtime/types/stdlib.d.ts +13 -5
  236. package/src/scripts-runtime/types/swarm-extension.d.ts +7 -3
  237. package/src/scripts-runtime/types/swarm-sdk.d.ts +13 -5
  238. package/src/tasks/context-key.ts +38 -1
  239. package/src/telemetry-context.ts +175 -0
  240. package/src/telemetry-contract/EVENTS.md +81 -0
  241. package/src/telemetry-contract/SOURCE.json +9 -0
  242. package/src/telemetry-contract/catalog.json +1335 -0
  243. package/src/telemetry-contract/index.ts +60 -0
  244. package/src/telemetry-contract/types.gen.ts +1971 -0
  245. package/src/telemetry-identity.ts +129 -0
  246. package/src/telemetry-snapshot.ts +211 -0
  247. package/src/telemetry-trigger.ts +125 -0
  248. package/src/telemetry-types.typetest.ts +40 -0
  249. package/src/telemetry.ts +271 -67
  250. package/src/tests/api-drain-e2e.test.ts +249 -0
  251. package/src/tests/api-drain-worker-e2e.test.ts +216 -0
  252. package/src/tests/api-drain.test.ts +351 -0
  253. package/src/tests/azure-devops-auth.test.ts +100 -0
  254. package/src/tests/azure-devops-handlers.test.ts +324 -0
  255. package/src/tests/azure-devops-webhook-malformed.test.ts +96 -0
  256. package/src/tests/claude-default-route.test.ts +260 -0
  257. package/src/tests/claude-managed-adapter.test.ts +47 -0
  258. package/src/tests/claude-managed-setup.test.ts +48 -0
  259. package/src/tests/claude-prompt-body-once.test.ts +117 -0
  260. package/src/tests/claude-routes-e2e.test.ts +316 -0
  261. package/src/tests/comb-config-guard.test.ts +38 -0
  262. package/src/tests/comb-links.test.ts +162 -0
  263. package/src/tests/comb-markers.test.ts +68 -0
  264. package/src/tests/comb-review-batch.test.ts +770 -0
  265. package/src/tests/comb-status.test.ts +152 -0
  266. package/src/tests/context-versions-retention.test.ts +314 -0
  267. package/src/tests/core-auth.test.ts +7 -0
  268. package/src/tests/db-retention.test.ts +14 -14
  269. package/src/tests/db-task-read-contract.test.ts +3 -0
  270. package/src/tests/db-task-write-contract.test.ts +3 -0
  271. package/src/tests/docs-index-footprint.test.js +3 -3
  272. package/src/tests/dsh-adapter.test.ts +134 -2
  273. package/src/tests/dsh-usage.test.ts +153 -0
  274. package/src/tests/extensions-catalog.test.ts +1 -0
  275. package/src/tests/extensions-example-deploy-awareness.test.ts +301 -0
  276. package/src/tests/extensions-http.test.ts +137 -10
  277. package/src/tests/extensions-mcp-tools.test.ts +28 -0
  278. package/src/tests/favorites-agent-fs-path.test.ts +226 -0
  279. package/src/tests/fetch-resolved-env.test.ts +24 -0
  280. package/src/tests/fixtures/azure-devops/pull-request-commented.json +129 -0
  281. package/src/tests/fixtures/azure-devops/pull-request-created.json +88 -0
  282. package/src/tests/fixtures/fake-claude-routes.ts +229 -0
  283. package/src/tests/github-handlers-reactions.test.ts +486 -0
  284. package/src/tests/github-reactions.test.ts +280 -0
  285. package/src/tests/harness-cli-version.test.ts +62 -0
  286. package/src/tests/http-api-integration.test.ts +21 -0
  287. package/src/tests/http-task-write-ownership.test.ts +24 -1
  288. package/src/tests/internal-ai/complete-structured.test.ts +94 -0
  289. package/src/tests/internal-ai/credentials.test.ts +22 -0
  290. package/src/tests/internal-ai/models.test.ts +36 -2
  291. package/src/tests/internal-ai/schema-parity.test.ts +25 -1
  292. package/src/tests/internal-ai/summarize-session.test.ts +23 -7
  293. package/src/tests/mcp-user-route.test.ts +133 -0
  294. package/src/tests/memory-key-paths.test.ts +1055 -0
  295. package/src/tests/memory-link-resolver.test.ts +34 -0
  296. package/src/tests/memory-rate-endpoint.test.ts +66 -0
  297. package/src/tests/memory-rater-llm-summarizer.test.ts +2 -1
  298. package/src/tests/memory-rater-llm.test.ts +73 -0
  299. package/src/tests/memory-rater-store.test.ts +31 -0
  300. package/src/tests/memory-reranker.test.ts +40 -0
  301. package/src/tests/onboarding.test.ts +108 -0
  302. package/src/tests/opencode-adapter.test.ts +57 -0
  303. package/src/tests/opencode-plugin.test.ts +4 -0
  304. package/src/tests/pi-codemode.test.ts +82 -4
  305. package/src/tests/pi-mono-adapter.test.ts +265 -2
  306. package/src/tests/pr-body-leaks.test.ts +789 -0
  307. package/src/tests/preload.ts +14 -0
  308. package/src/tests/provider-registration.test.ts +0 -2
  309. package/src/tests/providers/pi-cost.test.ts +190 -4
  310. package/src/tests/rbac-engine.test.ts +25 -1
  311. package/src/tests/realtime-room-auth.test.ts +104 -1
  312. package/src/tests/realtime-tickets.test.ts +74 -0
  313. package/src/tests/realtime-transport.test.ts +131 -4
  314. package/src/tests/runner-api-drain.test.ts +301 -0
  315. package/src/tests/runner-fallback-output.test.ts +61 -0
  316. package/src/tests/runner-fenced-json-output.test.ts +178 -0
  317. package/src/tests/runner-slot-reconcile.test.ts +199 -0
  318. package/src/tests/script-connections.test.ts +6 -0
  319. package/src/tests/send-task-requested-by.test.ts +133 -15
  320. package/src/tests/session-costs-recompute-all-providers.test.ts +23 -0
  321. package/src/tests/task-lifecycle-telemetry.test.ts +8 -3
  322. package/src/tests/task-reactions.test.ts +29 -6
  323. package/src/tests/telemetry-context.test.ts +314 -0
  324. package/src/tests/telemetry-init.test.ts +51 -19
  325. package/src/tests/telemetry-snapshot.test.ts +229 -0
  326. package/src/tests/telemetry-trigger.test.ts +200 -0
  327. package/src/tests/template-registry-helpers.ts +1 -0
  328. package/src/tests/vcs-azure-devops.test.ts +73 -0
  329. package/src/tests/webhooks-task-blocked.test.ts +23 -0
  330. package/src/tests/workflow-agent-task-retry.test.ts +363 -0
  331. package/src/tests/workflow-definition-telemetry.test.ts +4 -4
  332. package/src/tests/workflow-llm.test.ts +14 -0
  333. package/src/tools/context-diff.ts +20 -0
  334. package/src/tools/extension-install.ts +27 -16
  335. package/src/tools/memory-edit.ts +47 -3
  336. package/src/tools/memory-search.ts +13 -1
  337. package/src/tools/memory-store.ts +55 -3
  338. package/src/tools/poll-task.ts +20 -1
  339. package/src/tools/send-task.ts +9 -1
  340. package/src/tools/task-action.ts +11 -0
  341. package/src/types.ts +45 -8
  342. package/src/utils/api-drain.ts +24 -0
  343. package/src/utils/constants.ts +57 -16
  344. package/src/utils/credentials.test.ts +31 -1
  345. package/src/utils/credentials.ts +20 -9
  346. package/src/utils/dsh-usage.ts +53 -0
  347. package/src/utils/harness-cli-version.ts +6 -4
  348. package/src/utils/internal-ai/complete-structured.ts +26 -3
  349. package/src/utils/internal-ai/credentials.ts +23 -9
  350. package/src/utils/internal-ai/index.ts +8 -1
  351. package/src/utils/internal-ai/models.ts +34 -8
  352. package/src/utils/internal-ai/summarize-session.ts +22 -8
  353. package/src/utils/pr-body-leaks.ts +172 -0
  354. package/src/utils/secret-scrubber.ts +8 -0
  355. package/src/utils/task-attachment-links.ts +14 -8
  356. package/src/vcs/azure-devops.ts +80 -0
  357. package/src/vcs/index.ts +5 -1
  358. package/src/vcs/types.ts +2 -2
  359. package/src/workflows/recovery.ts +26 -1
  360. package/src/workflows/resume.ts +31 -4
  361. package/src/workflows/task-step-routing.ts +75 -2
  362. package/templates/community/open-prompt-showreel/PLAYBOOK.md +336 -0
  363. package/templates/community/open-prompt-showreel/README.md +33 -0
  364. package/templates/community/open-prompt-showreel/example/tla-races/facts.ts +145 -0
  365. package/templates/community/open-prompt-showreel/example/tla-races/facts.v3.json +140 -0
  366. package/templates/community/open-prompt-showreel/example/tla-races/music.mist-city.json +8 -0
  367. package/templates/community/open-prompt-showreel/example/tla-races/reel.html +805 -0
  368. package/templates/community/open-prompt-showreel/example/tla-races/smoke.sh +48 -0
  369. package/templates/community/open-prompt-showreel/lead-prompt.md +89 -0
  370. package/templates/community/open-prompt-showreel/setup.sh +167 -0
  371. package/templates/community/open-prompt-showreel/skills/motion-design-replication/SKILL.md +85 -0
  372. package/templates/community/open-prompt-showreel/skills/motion-design-video-analysis/SKILL.md +115 -0
  373. package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +147 -0
  374. package/templates/community/open-prompt-showreel/skills/video-generation/SKILL.md +195 -0
  375. package/templates/community/open-prompt-showreel/tools/fetch-music.sh +65 -0
  376. package/templates/community/open-prompt-showreel/tools/music-analyze.py +69 -0
  377. package/templates/community/open-prompt-showreel/tools/music-current.sh +34 -0
  378. package/templates/community/open-prompt-showreel/tools/music-cut.sh +36 -0
  379. package/templates/community/open-prompt-showreel/tools/music-refine.py +39 -0
  380. package/templates/community/open-prompt-showreel/tools/render.mjs +157 -0
  381. package/templates/community/open-prompt-showreel/tools/sheet.sh +44 -0
  382. package/templates/community/open-prompt-showreel/tools/web-compress.sh +17 -0
  383. package/templates/community/open-prompt-showreel/tools/x-reencode.sh +21 -0
  384. package/templates/extensions/README.md +1 -0
  385. package/templates/extensions/deploy-awareness/README.md +28 -0
  386. package/templates/extensions/deploy-awareness/hooks.ts +152 -0
  387. package/templates/extensions/deploy-awareness/manifest.json +8 -0
  388. package/templates/skills/memory/config.json +2 -2
  389. package/templates/skills/memory/content.md +59 -5
  390. package/templates/skills/swarm-extensions/config.json +1 -1
  391. package/templates/skills/swarm-extensions/content.md +28 -5
  392. package/tsconfig.json +3 -0
  393. package/dist/boot-seeds-gsetbs5y.js +0 -28
  394. package/dist/cli-j490egb5.js +0 -5632
  395. package/dist/cli-tjf4cn8z.js +0 -9119
  396. package/dist/cli-tmqt7dpj.js +0 -572
  397. package/dist/dsh-adapter-mpnzgztj.js +0 -19
  398. package/dist/index-7aj368tw.js +0 -30
@@ -0,0 +1,805 @@
1
+ <!doctype html>
2
+ <html><head><meta charset="utf-8"><style>html,body{margin:0;background:#000}canvas{display:block}</style></head>
3
+ <body><canvas id="c"></canvas>
4
+ <script>
5
+ // TLA+ races reel. Deterministic: render(f) draws frame f from scratch (except particles, which are pure functions of f too).
6
+ const qs = new URLSearchParams(location.search);
7
+ const W = +qs.get("w") || 1920, H = +qs.get("h") || 1080;
8
+ const PORT = H > W;
9
+ const S = Math.min(W, H) / 1080;
10
+ const FPS = 30, N = 720;
11
+ const cv = document.getElementById("c");
12
+ cv.width = W; cv.height = H;
13
+ let ctx = cv.getContext("2d");
14
+ const tmp = document.createElement("canvas"); tmp.width = W; tmp.height = H;
15
+ const tctx = tmp.getContext("2d");
16
+
17
+ // ---------- palette + type ----------
18
+ const C = {
19
+ bg: "#07070a", ink: "#f3efe6", dim: "#77747c", faint: "#3a3940",
20
+ amber: "#f6a723", amberHi: "#ffd27a", red: "#ff4b4b", green: "#34e38a", cyan: "#7fd6ff",
21
+ };
22
+ const G = "SG", M = "JB", I = "IS"; // Space Grotesk, JetBrains Mono, Instrument Serif Italic
23
+ const font = (fam, px, w = 400) => fam === I ? `italic ${px}px ${I}` : `${w} ${px}px ${fam}`;
24
+
25
+ // ---------- math ----------
26
+ const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
27
+ const lerp = (a, b, t) => a + (b - a) * t;
28
+ const prog = (f, a, b) => clamp((f - a) / (b - a));
29
+ const eOutExpo = (t) => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t));
30
+ const eInExpo = (t) => (t <= 0 ? 0 : Math.pow(2, 10 * t - 10));
31
+ const eOutCubic = (t) => 1 - Math.pow(1 - t, 3);
32
+ const eInCubic = (t) => t * t * t;
33
+ const eIO = (t) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);
34
+ const eOutBack = (t) => { const c1 = 1.9, c3 = c1 + 1; return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2); };
35
+ const pulse = (f, f0, decay = 6) => (f < f0 ? 0 : Math.exp(-(f - f0) / decay));
36
+ function rng(seed) { return () => { seed |= 0; seed = (seed + 0x6d2b79f5) | 0; let t = Math.imul(seed ^ (seed >>> 15), 1 | seed); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
37
+ const fmt = (n) => Math.round(n).toLocaleString("en-US");
38
+ const num = (s) => +String(s).replace(/[^0-9]/g, "");
39
+ function hexA(hex, a) { const n = parseInt(hex.slice(1), 16); return `rgba(${n >> 16},${(n >> 8) & 255},${n & 255},${a})`; }
40
+ function mix(h1, h2, t) { const a = parseInt(h1.slice(1), 16), b = parseInt(h2.slice(1), 16); const c = (s) => Math.round(lerp((a >> s) & 255, (b >> s) & 255, t)); return `rgb(${c(16)},${c(8)},${c(0)})`; }
41
+
42
+ // ---------- facts (injected) ----------
43
+ let F, TILES, TRACE, STATES_TODAY, STATES_SIMPLE, VIEWS, GREENS, AMBERS;
44
+ function initFacts(facts) {
45
+ F = facts;
46
+ const hb = F.hbFixes.filter((h) => h.state === "MERGED" && h.testOnMain);
47
+ TILES = [
48
+ ...hb.map((h) => ({ tag: `HEARTBEAT · BUG ${h.bug}`, title: h.bugTitle, pinned: "failing", end: "green", pr: h.pr, prState: "merged" })),
49
+ ...F.cx.filter((c, i) => F.cx.findIndex((x) => x.id === c.id) === i).map((c0) => {
50
+ const same = F.cx.filter((x) => x.id === c0.id), c = { ...c0, failing: same.some((x) => x.failing) };
51
+ const fl = F.flips.find((x) => x.id === c.id);
52
+ const end = !c.failing ? "green" : fl && fl.state === "OPEN" ? "amber" : "red";
53
+ return { tag: `WORKFLOWS · ${c.id}`, title: c.title, pinned: "test.failing", end, pr: fl ? fl.pr : null, prState: fl ? fl.state.toLowerCase() : null };
54
+ }),
55
+ ];
56
+ const b1 = hb.find((h) => h.bug === 1) || hb[0];
57
+ TRACE = { title: b1.bugTitle, inv: b1.invariant, steps: b1.trace, bug: b1.bug };
58
+ STATES_TODAY = num(F.heartbeat.states[0]);
59
+ STATES_SIMPLE = num(F.heartbeat.states[2]);
60
+ VIEWS = num(F.heartbeat.statusViews[2]);
61
+ GREENS = TILES.filter((t) => t.end === "green").length;
62
+ AMBERS = TILES.filter((t) => t.end === "amber").length;
63
+ buildTree();
64
+ buildGrid();
65
+ }
66
+
67
+ // ---------- state graph ----------
68
+ const MAXD = 9;
69
+ let NODES = [], EDGES = [], LEAF = -1;
70
+ function buildTree() {
71
+ const r = rng(7);
72
+ NODES = [{ d: 0, p: -1, kids: [], j: 0 }];
73
+ let front = [0];
74
+ for (let d = 1; d <= MAXD; d++) {
75
+ const next = [];
76
+ for (const id of front) {
77
+ let k = d <= 2 ? 3 : [0, 1, 2, 2, 2, 3, 3, 4][Math.floor(r() * 8)];
78
+ if (d === MAXD) k = Math.min(k, 2);
79
+ for (let i = 0; i < k && NODES.length < 3600; i++) {
80
+ const n = { d, p: id, kids: [], j: r() };
81
+ NODES.push(n); NODES[id].kids.push(NODES.length - 1); next.push(NODES.length - 1);
82
+ }
83
+ }
84
+ front = next;
85
+ }
86
+ // radial layout by leaf count
87
+ const leaves = (i) => (NODES[i].leaves = NODES[i].kids.length ? NODES[i].kids.reduce((s, k) => s + leaves(k), 0) : 1);
88
+ leaves(0);
89
+ const place = (i, a0, a1) => {
90
+ const n = NODES[i]; n.a = (a0 + a1) / 2 + (n.d ? (n.j - 0.5) * 0.004 : 0);
91
+ n.r = n.d === 0 ? 0 : 58 * Math.pow(n.d, 0.93) * (1 + (n.j - 0.5) * 0.06);
92
+ let a = a0; for (const k of n.kids) { const span = ((a1 - a0) * NODES[k].leaves) / n.leaves; place(k, a, a + span); a += span; }
93
+ };
94
+ place(0, 0, Math.PI * 2);
95
+ NODES.forEach((n, i) => { n.x = Math.cos(n.a) * n.r; n.y = Math.sin(n.a) * n.r; n.birth = n.d === 0 ? 24 : 25 + (n.d - 1) * 15 + n.j * 13; if (n.p >= 0) EDGES.push([n.p, i, 0]); });
96
+ // cross edges: interleavings that converge on the same state
97
+ const byD = {}; NODES.forEach((n, i) => (byD[n.d] = byD[n.d] || []).push(i));
98
+ for (let d = 2; d < MAXD; d++) {
99
+ const arr = byD[d].slice().sort((a, b) => NODES[a].a - NODES[b].a);
100
+ for (let q = 0; q + 1 < arr.length; q++) {
101
+ const nb = NODES[arr[q + 1]];
102
+ if (r() < 0.22 && nb.kids.length) EDGES.push([arr[q], nb.kids[0], 1]);
103
+ }
104
+ }
105
+ // counterexample leaf: deepest leaf pointing up-right on screen at freeze
106
+ const rotF = rot(165);
107
+ let best = 1e9;
108
+ NODES.forEach((n, i) => { if (n.d === MAXD) { const s = Math.abs(Math.atan2(Math.sin(n.a + rotF + 0.55), Math.cos(n.a + rotF + 0.55))); if (s < best) { best = s; LEAF = i; } } });
109
+ PATH = []; for (let i = LEAF; i >= 0; i = NODES[i].p) PATH.unshift(i);
110
+ }
111
+ let PATH = [];
112
+ const rot = (f) => 0.09 * (Math.min(f, 165) / FPS) - 0.35;
113
+
114
+ // ---------- layout ----------
115
+ const L = PORT
116
+ ? { treeX: W / 2, treeY: H * 0.545, fit: W * 0.37, textX: W / 2, align: "center", hexR: 128 * S }
117
+ : { treeX: W * 0.70, treeY: H * 0.52, fit: H * 0.42, textX: 128 * S, align: "left", hexR: 140 * S };
118
+
119
+ // ---------- text ----------
120
+ function parse(markup) { // "*word*" = accent
121
+ const out = []; let acc = false;
122
+ for (const raw of markup.split(" ")) {
123
+ let w = raw, a = acc;
124
+ if (w.startsWith("*")) { a = true; w = w.slice(1); acc = true; }
125
+ if (w.endsWith("*") || w.match(/\*[.,:!]$/)) { w = w.replace("*", ""); acc = false; }
126
+ out.push({ w, a });
127
+ }
128
+ return out;
129
+ }
130
+ function kinetic(markup, o) {
131
+ const f = o.f, size = o.size * S, lh = size * (o.lh || 1.08);
132
+ const words = parse(markup).map((t) => {
133
+ const fnt = t.a && o.accent !== false ? font(I, size * 1.14) : font(o.fam || G, size, o.weight || 500);
134
+ ctx.font = fnt; return { ...t, fnt, wd: ctx.measureText(t.w).width, sp: ctx.measureText(" ").width };
135
+ });
136
+ const maxW = (o.maxW || 1e9) * S, lines = [[]]; let lw = 0;
137
+ for (const w of words) { if (w.w === "|") { lines.push([]); lw = 0; continue; } if (lw + w.wd > maxW && lines.at(-1).length) { lines.push([]); lw = 0; } lines.at(-1).push(w); lw += w.wd + w.sp; }
138
+ let k = 0;
139
+ lines.forEach((line, li) => {
140
+ const tw = line.reduce((s, w, i) => s + w.wd + (i < line.length - 1 ? w.sp : 0), 0);
141
+ let x = o.align === "center" ? o.x - tw / 2 : o.x;
142
+ const y = o.y + li * lh;
143
+ for (const w of line) {
144
+ const s0 = o.start + k * (o.stagger ?? 3);
145
+ const pin = eOutExpo(prog(f, s0, s0 + 20));
146
+ const pout = o.end != null ? eInCubic(prog(f, o.end + k * 1.5, o.end + k * 1.5 + 10)) : 0;
147
+ if (pin > 0 && pout < 1) {
148
+ ctx.save();
149
+ ctx.beginPath(); ctx.rect(x - size, y - size * 1.02, w.wd + size * 2, size * 1.34); ctx.clip();
150
+ const dy = (1 - pin) * size * 0.95 - pout * size * 0.95;
151
+ const b = (1 - pin) * 9 + pout * 8;
152
+ if (b > 0.4) ctx.filter = `blur(${b.toFixed(1)}px)`;
153
+ ctx.globalAlpha = (o.alpha ?? 1) * pin * (1 - pout);
154
+ ctx.font = w.fnt; ctx.fillStyle = w.a ? o.accentColor || C.amber : o.color || C.ink;
155
+ ctx.textBaseline = "alphabetic";
156
+ ctx.fillText(w.w, x, y + dy);
157
+ ctx.restore();
158
+ }
159
+ x += w.wd + w.sp; k++;
160
+ }
161
+ });
162
+ return lines.length * lh;
163
+ }
164
+ function mono(text, x, y, o = {}) {
165
+ ctx.save(); ctx.font = font(M, (o.size || 14) * S, o.weight || 500);
166
+ ctx.fillStyle = o.color || C.dim; ctx.globalAlpha = o.alpha ?? 1; ctx.textAlign = o.align || "left";
167
+ if (o.track) ctx.letterSpacing = `${o.track * S}px`;
168
+ let t = text;
169
+ if (o.type != null) { const n = Math.floor(o.type); t = text.slice(0, n); }
170
+ ctx.fillText(t, x, y);
171
+ if (o.cursor && o.type != null && o.type < text.length + 6 && Math.floor(o.f / 4) % 2 === 0) {
172
+ const w = ctx.measureText(t).width, dx = o.align === "center" ? w / 2 : o.align === "right" ? 0 : w;
173
+ ctx.fillRect(x + dx + 3 * S, y - (o.size || 14) * S * 0.8, (o.size || 14) * S * 0.55, (o.size || 14) * S * 0.95);
174
+ }
175
+ ctx.restore();
176
+ }
177
+
178
+ // ---------- background / hud / texture ----------
179
+ const grain = document.createElement("canvas"); grain.width = grain.height = 256;
180
+ { const g = grain.getContext("2d"), id = g.createImageData(256, 256), r = rng(3); for (let i = 0; i < id.data.length; i += 4) { const v = r() * 255; id.data[i] = id.data[i + 1] = id.data[i + 2] = v; id.data[i + 3] = 255; } g.putImageData(id, 0, 0); }
181
+ function background(f, glowColor, gx, gy, gAmt) {
182
+ ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);
183
+ // dot grid, slow drift
184
+ const sp = 44 * S, ox = (f * 0.35) % sp, oy = (f * 0.18) % sp;
185
+ ctx.fillStyle = "rgba(255,255,255,0.045)";
186
+ for (let x = -sp + ox; x < W + sp; x += sp) for (let y = -sp + oy; y < H + sp; y += sp) ctx.fillRect(x, y, 1.6 * S, 1.6 * S);
187
+ const g = ctx.createRadialGradient(gx, gy, 0, gx, gy, Math.max(W, H) * 0.55);
188
+ g.addColorStop(0, hexA(glowColor, 0.16 * gAmt)); g.addColorStop(1, hexA(glowColor, 0));
189
+ ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);
190
+ }
191
+ function finish(f) {
192
+ // vignette
193
+ const v = ctx.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.35, W / 2, H / 2, Math.max(W, H) * 0.75);
194
+ v.addColorStop(0, "rgba(0,0,0,0)"); v.addColorStop(1, "rgba(0,0,0,0.6)");
195
+ ctx.fillStyle = v; ctx.fillRect(0, 0, W, H);
196
+ // grain
197
+ ctx.save(); ctx.globalAlpha = 0.055; ctx.globalCompositeOperation = "overlay";
198
+ const r = rng(f * 13 + 1); const p = ctx.createPattern(grain, "repeat");
199
+ ctx.translate(-r() * 256, -r() * 256); ctx.fillStyle = p; ctx.fillRect(0, 0, W + 256, H + 256); ctx.restore();
200
+ }
201
+ const SECTIONS = [[0, "01", "SEARCH"], [180, "02", "COUNTEREXAMPLE"], [300, "03", "PINNED"], [420, "04", "FIXED"], [540, "05", "SIMPLER"], [645, "06", "AGENT SWARM"]];
202
+ function hud(f) {
203
+ const a = eOutCubic(prog(f, 4, 22));
204
+ const m = 40 * S, top = 44 * S, bot = H - 36 * S;
205
+ ctx.save(); ctx.globalAlpha = a * 0.9;
206
+ mono("AGENT SWARM — TLA+ / RACES", m, top, { size: 12, track: 2.2, color: C.dim });
207
+ const sec = SECTIONS.filter((s) => f >= s[0]).at(-1);
208
+ const since = f - sec[0];
209
+ mono(`${sec[1]} / ${sec[2]}`, m, bot, { size: 12, track: 2.2, color: C.dim, type: since * 1.6 + 3 });
210
+ const s = Math.floor(f / FPS), fr = f % FPS;
211
+ const tc = `00:00:${String(s).padStart(2, "0")}:${String(fr).padStart(2, "0")}`;
212
+ mono(`REC ${tc}`, W - m, top, { size: 12, track: 2.2, align: "right", color: C.dim });
213
+ ctx.fillStyle = C.red; ctx.globalAlpha = a * (Math.floor(f / 15) % 2 ? 0.35 : 1);
214
+ ctx.font = font(M, 12 * S, 500); ctx.letterSpacing = `${2.2 * S}px`;
215
+ const tw = ctx.measureText(`REC ${tc}`).width;
216
+ ctx.beginPath(); ctx.arc(W - m - tw - 12 * S, top - 4.5 * S, 3.5 * S, 0, 7); ctx.fill();
217
+ // progress
218
+ ctx.globalAlpha = a * 0.9; const pw = 150 * S;
219
+ ctx.fillStyle = C.faint; ctx.fillRect(W - m - pw, bot - 4 * S, pw, 1.5 * S);
220
+ ctx.fillStyle = C.amber; ctx.fillRect(W - m - pw, bot - 4 * S, pw * (f / (N - 1)), 1.5 * S);
221
+ // provenance
222
+ mono(`facts read live · origin/main @ ${F.mainSha}`, W / 2, bot, { size: 11, track: 1.6, align: "center", color: C.faint, alpha: a });
223
+ // corner ticks
224
+ ctx.strokeStyle = hexA(C.ink, 0.22); ctx.lineWidth = 1.2 * S; const k = 14 * S, c = 22 * S;
225
+ for (const [x, y, sx, sy] of [[c, c, 1, 1], [W - c, c, -1, 1], [c, H - c, 1, -1], [W - c, H - c, -1, -1]]) {
226
+ ctx.beginPath(); ctx.moveTo(x, y + sy * k); ctx.lineTo(x, y); ctx.lineTo(x + sx * k, y); ctx.stroke();
227
+ }
228
+ ctx.restore();
229
+ }
230
+ function glitch(f, amt, seed) {
231
+ if (amt < 0.02) return;
232
+ tctx.clearRect(0, 0, W, H); tctx.drawImage(cv, 0, 0);
233
+ const r = rng(seed * 997 + f);
234
+ const n = Math.floor(4 + amt * 14);
235
+ for (let i = 0; i < n; i++) {
236
+ const y = r() * H, h = (6 + r() * 60) * S, dx = (r() - 0.5) * 140 * S * amt;
237
+ ctx.drawImage(tmp, 0, y, W, h, dx, y, W, h);
238
+ }
239
+ // chromatic split
240
+ ctx.save(); ctx.globalCompositeOperation = "lighter"; ctx.globalAlpha = 0.28 * amt;
241
+ ctx.drawImage(tmp, 7 * S * amt, 0); ctx.globalAlpha = 0.18 * amt; ctx.drawImage(tmp, -7 * S * amt, 0); ctx.restore();
242
+ }
243
+
244
+ // ---------- tree drawing ----------
245
+ const DCOL = Array.from({ length: MAXD + 1 }, (_, d) => d < 5 ? mix("#ffd27a", "#f6a723", d / 5) : mix("#f6a723", "#e2551c", (d - 5) / 4));
246
+ const NCOL = DCOL.map((c, d) => (d < 3 ? "#fff1cf" : c));
247
+ function treeCam(f, zoomOverride) {
248
+ const front = clamp((f - 19) / 15, 0, MAXD);
249
+ const fitZoom = L.fit / (58 * Math.pow(MAXD + 0.5, 0.93));
250
+ const z = zoomOverride ?? L.fit / (58 * Math.pow(Math.max(1.4, front + 0.7), 0.93));
251
+ return { z: Math.max(z, fitZoom), rot: rot(f) };
252
+ }
253
+ function tp(n, cam, cx = L.treeX, cy = L.treeY) {
254
+ const c = Math.cos(cam.rot), s = Math.sin(cam.rot);
255
+ return [cx + (n.x * c - n.y * s) * cam.z, cy + (n.x * s + n.y * c) * cam.z];
256
+ }
257
+ function drawTree(f, o) {
258
+ const cam = o.cam, dim = o.dim ?? 1, birthOf = o.birth || ((n) => n.birth);
259
+ ctx.save(); ctx.globalCompositeOperation = "lighter";
260
+ ctx.lineCap = "round";
261
+ // edges
262
+ for (const [a, b, cross] of EDGES) {
263
+ const A = NODES[a], B = NODES[b];
264
+ const bb = birthOf(B), p = eOutCubic(prog(f, bb - 7, bb));
265
+ if (p <= 0) continue;
266
+ const [x1, y1] = o.pos ? o.pos(a) : tp(A, cam), [x2, y2] = o.pos ? o.pos(b) : tp(B, cam);
267
+ const flash = pulse(f, bb, 9);
268
+ const al = (cross ? 0.10 : 0.2 + 0.1 * (1 - B.d / MAXD)) * dim * (o.edgeAlpha ?? 1) + flash * 0.55 * dim;
269
+ if (al < 0.01) continue;
270
+ ctx.strokeStyle = flash > 0.2 ? mix(C.amber, "#fff3d6", flash * 0.7) : DCOL[B.d];
271
+ ctx.globalAlpha = al; ctx.lineWidth = (cross ? 0.7 : 1.1) * S * (o.lw ?? 1);
272
+ ctx.beginPath(); ctx.moveTo(x1, y1); ctx.lineTo(lerp(x1, x2, p), lerp(y1, y2, p)); ctx.stroke();
273
+ }
274
+ // nodes
275
+ for (let i = 0; i < NODES.length; i++) {
276
+ const n = NODES[i], bb = birthOf(n);
277
+ if (f < bb) continue;
278
+ const [x, y] = o.pos ? o.pos(i) : tp(n, cam);
279
+ const fl = pulse(f, bb, 7), pop = eOutBack(prog(f, bb, bb + 8));
280
+ const rr = (n.d === 0 ? 5 : 1.5 + 1.2 * (1 - n.d / MAXD)) * S * pop * (1 + fl * 1.6) * (o.nodeScale ?? 1);
281
+ ctx.globalAlpha = clamp((0.55 + fl * 0.45) * dim * (o.nodeAlpha ?? 1));
282
+ ctx.fillStyle = fl > 0.25 ? "#fff1cf" : NCOL[n.d];
283
+ ctx.beginPath(); ctx.arc(x, y, rr, 0, 7); ctx.fill();
284
+ }
285
+ ctx.restore();
286
+ }
287
+
288
+ // ---------- scene 1: search (0-180) ----------
289
+ function drawPath(f, cam) {
290
+ const pts = PATH.map((i) => tp(NODES[i], cam));
291
+ const p = eOutCubic(prog(f, 165, 174)) * (pts.length - 1);
292
+ ctx.save(); ctx.globalCompositeOperation = "lighter"; ctx.lineCap = "round"; ctx.lineJoin = "round";
293
+ for (const [lw, al] of [[10, 0.14], [4, 0.35], [2, 1]]) {
294
+ ctx.strokeStyle = C.red; ctx.globalAlpha = al; ctx.lineWidth = lw * S; ctx.beginPath();
295
+ ctx.moveTo(...pts[0]);
296
+ for (let i = 1; i <= Math.floor(p); i++) ctx.lineTo(...pts[i]);
297
+ const fi = Math.floor(p), fr = p - fi; if (fi + 1 < pts.length) ctx.lineTo(lerp(pts[fi][0], pts[fi + 1][0], fr), lerp(pts[fi][1], pts[fi + 1][1], fr));
298
+ ctx.stroke();
299
+ }
300
+ PATH.forEach((id, i) => { if (i <= p) { const [x, y] = pts[i]; ctx.fillStyle = C.red; ctx.globalAlpha = 1; ctx.beginPath(); ctx.arc(x, y, 3.2 * S, 0, 7); ctx.fill(); } });
301
+ const [lx, ly] = pts.at(-1), fp = prog(f, 173, 180);
302
+ if (fp > 0) {
303
+ for (let k = 0; k < 2; k++) { const q = clamp(fp * 1.3 - k * 0.3); ctx.strokeStyle = C.red; ctx.globalAlpha = (1 - q) * 0.9; ctx.lineWidth = 2 * S; ctx.beginPath(); ctx.arc(lx, ly, (8 + q * 60) * S, 0, 7); ctx.stroke(); }
304
+ ctx.globalAlpha = 1; ctx.fillStyle = "#fff"; ctx.beginPath(); ctx.arc(lx, ly, 5 * S, 0, 7); ctx.fill();
305
+ }
306
+ ctx.restore();
307
+ return pts;
308
+ }
309
+ function opener(f) {
310
+ if (f >= 30) return;
311
+ const word = "TLA+", size = (PORT ? 250 : 300) * S;
312
+ const col = eInExpo(prog(f, 17, 27)); // collapse into the root
313
+ ctx.save(); ctx.font = font(M, size, 700); ctx.textBaseline = "middle";
314
+ const tw = ctx.measureText(word).width;
315
+ const [rx, ry] = [L.treeX, L.treeY];
316
+ const cx = lerp(PORT ? W / 2 : W / 2, rx, col), cy = lerp(H / 2, ry, col);
317
+ ctx.translate(cx, cy); ctx.scale(1 - col * 0.97, 1 - col * 0.97);
318
+ let x = -tw / 2;
319
+ for (let i = 0; i < word.length; i++) {
320
+ const ch = word[i], cw = ctx.measureText(ch).width, s0 = i * 3, p = eOutExpo(prog(f, s0, s0 + 10));
321
+ ctx.save(); ctx.globalAlpha = p * (1 - col * 0.5);
322
+ if (p < 1) ctx.filter = `blur(${((1 - p) * 14).toFixed(1)}px)`;
323
+ ctx.fillStyle = i === 3 ? C.amber : C.ink;
324
+ ctx.fillText(ch, x, (1 - p) * size * 0.3); ctx.restore(); x += cw;
325
+ }
326
+ ctx.restore();
327
+ mono("A MODEL CHECKER · TLC", PORT ? W / 2 : W / 2, H / 2 + size * 0.52, { size: 14, track: 5, color: C.amber, align: "center", type: (f - 6) * 2, alpha: 1 - col });
328
+ if (col > 0.6) { ctx.save(); ctx.globalCompositeOperation = "lighter"; ctx.fillStyle = "#fff1cf"; ctx.globalAlpha = (col - 0.6) * 2.5; ctx.beginPath(); ctx.arc(rx, ry, 9 * S, 0, 7); ctx.fill(); ctx.restore(); }
329
+ }
330
+ function scene1(f) {
331
+ opener(f);
332
+ const cam = treeCam(f);
333
+ const freeze = f >= 165;
334
+ const dim = freeze ? lerp(1, 0.32, eOutCubic(prog(f, 165, 170))) : 1;
335
+ // beat pulse glow at tree center
336
+ const beat = f < 160 && f >= 30 ? pulse(f, Math.floor(f / 15) * 15, 8) : 0; // on the 120 BPM grid (beat = 15 frames, drop at 420)
337
+ const [rx, ry] = tp(NODES[0], cam);
338
+ ctx.save(); ctx.globalCompositeOperation = "lighter";
339
+ const gr = ctx.createRadialGradient(rx, ry, 0, rx, ry, 260 * S);
340
+ gr.addColorStop(0, hexA(C.amber, 0.10 + beat * 0.12)); gr.addColorStop(1, hexA(C.amber, 0));
341
+ ctx.fillStyle = gr; ctx.fillRect(0, 0, W, H); ctx.restore();
342
+ // ripple rings on each new depth
343
+ for (let d = 1; d <= MAXD; d++) {
344
+ const f0 = 25 + (d - 1) * 15, p = prog(f, f0, f0 + 24);
345
+ if (p <= 0 || p >= 1) continue;
346
+ ctx.save(); ctx.strokeStyle = C.amber; ctx.globalAlpha = (1 - p) * 0.35 * dim; ctx.lineWidth = 1.2 * S;
347
+ ctx.beginPath(); ctx.arc(rx, ry, 58 * Math.pow(d, 0.93) * cam.z * (0.9 + 0.2 * eOutCubic(p)), 0, 7); ctx.stroke(); ctx.restore();
348
+ }
349
+ drawTree(f, { cam, dim });
350
+ // counterexample path
351
+ if (f >= 165) {
352
+ const pts = drawPath(f, cam);
353
+ const [lx, ly] = pts.at(-1);
354
+ // label with leader
355
+ const la = eOutExpo(prog(f, 169, 178));
356
+ if (la > 0) {
357
+ const right = lx > W - 420 * S; const tx = lx + (right ? -40 : 70) * S, ty = ly - (right ? 64 : 50) * S;
358
+ ctx.save(); ctx.strokeStyle = C.red; ctx.globalAlpha = la; ctx.lineWidth = 1.2 * S;
359
+ ctx.beginPath(); ctx.moveTo(lx, ly); ctx.lineTo(lerp(lx, tx - 8 * S, la), lerp(ly, ty + 8 * S, la)); ctx.stroke(); ctx.restore();
360
+ mono(`${TRACE.inv} — VIOLATED`, tx, ty, { size: 17, weight: 700, color: C.red, track: 2, type: prog(f, 170, 178) * 30, cursor: true, f, align: right ? "right" : "left" });
361
+ }
362
+ }
363
+ if (false) {
364
+ const pts = PATH.map((i) => tp(NODES[i], cam));
365
+ const p = eOutCubic(prog(f, 165, 174)) * (pts.length - 1);
366
+ ctx.save(); ctx.globalCompositeOperation = "lighter"; ctx.lineCap = "round"; ctx.lineJoin = "round";
367
+ for (const [lw, al] of [[10, 0.14], [4, 0.35], [2, 1]]) {
368
+ ctx.strokeStyle = C.red; ctx.globalAlpha = al; ctx.lineWidth = lw * S; ctx.beginPath();
369
+ ctx.moveTo(...pts[0]);
370
+ for (let i = 1; i <= Math.floor(p); i++) ctx.lineTo(...pts[i]);
371
+ const fi = Math.floor(p), fr = p - fi; if (fi + 1 < pts.length) ctx.lineTo(lerp(pts[fi][0], pts[fi + 1][0], fr), lerp(pts[fi][1], pts[fi + 1][1], fr));
372
+ ctx.stroke();
373
+ }
374
+ PATH.forEach((id, i) => { if (i <= p) { const [x, y] = pts[i]; ctx.fillStyle = C.red; ctx.globalAlpha = 1; ctx.beginPath(); ctx.arc(x, y, 3.2 * S, 0, 7); ctx.fill(); } });
375
+ // leaf flare
376
+ const [lx, ly] = pts.at(-1), fp = prog(f, 173, 180);
377
+ if (fp > 0) {
378
+ for (let k = 0; k < 2; k++) { const q = clamp(fp * 1.3 - k * 0.3); ctx.strokeStyle = C.red; ctx.globalAlpha = (1 - q) * 0.9; ctx.lineWidth = 2 * S; ctx.beginPath(); ctx.arc(lx, ly, (8 + q * 60) * S, 0, 7); ctx.stroke(); }
379
+ ctx.globalAlpha = 1; ctx.fillStyle = "#fff"; ctx.beginPath(); ctx.arc(lx, ly, 5 * S, 0, 7); ctx.fill();
380
+ }
381
+ ctx.restore();
382
+ // label with leader
383
+ const la = eOutExpo(prog(f, 169, 178));
384
+ if (la > 0) {
385
+ const right = lx > W - 420 * S; const tx = lx + (right ? -40 : 70) * S, ty = ly - (right ? 64 : 50) * S;
386
+ ctx.save(); ctx.strokeStyle = C.red; ctx.globalAlpha = la; ctx.lineWidth = 1.2 * S;
387
+ ctx.beginPath(); ctx.moveTo(lx, ly); ctx.lineTo(lerp(lx, tx - 8 * S, la), lerp(ly, ty + 8 * S, la)); ctx.stroke(); ctx.restore();
388
+ mono(`${TRACE.inv} — VIOLATED`, tx, ty, { size: 17, weight: 700, color: C.red, track: 2, type: prog(f, 170, 178) * 30, cursor: true, f, align: right ? "right" : "left" });
389
+ }
390
+ }
391
+ // headline
392
+ const tOut = 158;
393
+ if (PORT) {
394
+ kinetic("A model checker | walks *every* interleaving.", { f, x: W / 2, y: H * 0.145, size: 70, weight: 600, align: "center", maxW: 900, start: 30, end: tOut, stagger: 4 });
395
+ } else {
396
+ kinetic("A model checker", { f, x: L.textX, y: H * 0.33, size: 88, weight: 600, start: 30, end: tOut, stagger: 4 });
397
+ kinetic("walks *every*", { f, x: L.textX, y: H * 0.33 + 96 * S, size: 88, weight: 600, start: 44, end: tOut + 3, stagger: 4 });
398
+ kinetic("interleaving.", { f, x: L.textX, y: H * 0.33 + 192 * S, size: 88, weight: 600, start: 54, end: tOut + 6, stagger: 4 });
399
+ }
400
+ // state counter (exponential)
401
+ const p = prog(f, 25, 155), k = 6.2;
402
+ const v = STATES_TODAY * (Math.exp(k * p) - 1) / (Math.exp(k) - 1);
403
+ const ca = eOutCubic(prog(f, 30, 44)) * (1 - eInCubic(prog(f, 166, 176)));
404
+ const cx = PORT ? W / 2 : L.textX, cy = PORT ? H * 0.925 : H * 0.8;
405
+ if (ca > 0) {
406
+ mono("REACHABLE STATES · HEARTBEAT MODEL", cx, cy - 58 * S, { size: 13, track: 2.4, color: C.amber, alpha: ca, align: PORT ? "center" : "left" });
407
+ ctx.save(); ctx.globalAlpha = ca; ctx.font = font(M, 58 * S, 600); ctx.fillStyle = C.ink; ctx.textAlign = PORT ? "center" : "left";
408
+ ctx.fillText(fmt(v), cx, cy); ctx.restore();
409
+ const done = pulse(f, 155, 10);
410
+ if (f >= 155) mono("EXHAUSTIVE", cx + (PORT ? 0 : 330 * S), cy + (PORT ? 30 : -6) * S, { size: 13, track: 2.4, color: C.amberHi, alpha: ca * (0.6 + done * 0.4), align: PORT ? "center" : "left", type: (f - 155) * 1.5 });
411
+ }
412
+ }
413
+
414
+ // ---------- scene 2: counterexample as a timeline (180-300) ----------
415
+ function laneGeom() {
416
+ const x0 = PORT ? 110 * S : 330 * S, x1 = PORT ? W - 90 * S : W - 190 * S;
417
+ return PORT ? { x0, x1, hb: H * 0.5, ax: H * 0.635, wk: H * 0.77 } : { x0, x1, hb: H * 0.47, ax: H * 0.63, wk: H * 0.79 };
418
+ }
419
+ function laneOf(step) { if (/^Hb/.test(step)) return "hb"; if (/^(Age)$/.test(step)) return "ax"; return "wk"; }
420
+ function scene2(f) {
421
+ const g = laneGeom(), steps = TRACE.steps, n = steps.length;
422
+ const xs = steps.map((_, i) => lerp(g.x0 + 60 * S, g.x1 - 40 * S, n === 1 ? 0 : i / (n - 1)));
423
+ const T0 = 195, stepF = (i) => T0 + i * 15;
424
+ const slam = stepF(n - 1);
425
+ const out = eInCubic(prog(f, 282, 296));
426
+ const fade = 1 - out;
427
+ // zoom-in punch from the tree (180-194)
428
+ if (f < 200) {
429
+ const zp = eInExpo(prog(f, 180, 191));
430
+ const cam = treeCam(179); const [lx, ly] = tp(NODES[LEAF], cam);
431
+ // draw the frozen tree once into the offscreen buffer, then zoom + blur it as a single image
432
+ if (f < 191) {
433
+ const live = ctx; tctx.setTransform(1, 0, 0, 1, 0, 0); tctx.clearRect(0, 0, W, H);
434
+ ctx = tctx; drawTree(179, { cam, dim: 0.32 * (1 - zp) }); drawPath(179, cam); ctx = live;
435
+ ctx.save(); ctx.translate(lx, ly); ctx.scale(1 + zp * 22, 1 + zp * 22); ctx.translate(-lx, -ly);
436
+ if (zp > 0.02) ctx.filter = `blur(${(zp * 3).toFixed(1)}px)`;
437
+ ctx.drawImage(tmp, 0, 0);
438
+ ctx.restore();
439
+ }
440
+ // red disc from the leaf fills the frame...
441
+ const dp = eInCubic(prog(f, 182, 190));
442
+ if (f < 192 && dp > 0) { ctx.save(); ctx.fillStyle = C.red; ctx.beginPath(); ctx.arc(lx, ly, dp * Math.hypot(W, H) * 1.05, 0, 7); ctx.fill(); ctx.restore(); }
443
+ // ...then squashes into the time axis
444
+ if (f >= 192) {
445
+ const sq = eOutExpo(prog(f, 192, 200)), hh = lerp(H, 2 * S, sq), yc = lerp(H / 2, g.ax, sq);
446
+ ctx.save(); ctx.fillStyle = C.red; ctx.fillRect(0, yc - hh / 2, W, hh); ctx.restore();
447
+ }
448
+ }
449
+ // ghost invariant name, outline type behind the lanes
450
+ {
451
+ const gp = eOutCubic(prog(f, 200, 240)), hit = f >= slam ? 0.6 + pulse(f, slam, 8) * 0.4 : 0;
452
+ ctx.save(); ctx.font = font(M, (PORT ? 118 : 250) * S, 800); ctx.textAlign = "center"; ctx.textBaseline = "middle";
453
+ ctx.lineWidth = 1.5 * S; ctx.strokeStyle = hit ? C.red : C.ink; ctx.globalAlpha = fade * (0.05 * gp + hit * 0.07);
454
+ ctx.strokeText(TRACE.inv, W / 2 + (1 - gp) * 60 * S - (f - 200) * 0.6 * S, (g.hb + g.wk) / 2); ctx.restore();
455
+ }
456
+ // axis draws out from center
457
+ const ap = f < 199 ? 0 : 1;
458
+ ctx.save(); ctx.globalAlpha = fade;
459
+ const mid = (g.x0 + g.x1) / 2;
460
+ ctx.strokeStyle = C.red; ctx.lineWidth = 2 * S; ctx.globalAlpha = fade * 0.9;
461
+ ctx.beginPath(); ctx.moveTo(lerp(mid, g.x0, ap), g.ax); ctx.lineTo(lerp(mid, g.x1, ap), g.ax); ctx.stroke();
462
+ // tick marks
463
+ for (let i = 0; i <= 40; i++) { const x = lerp(g.x0, g.x1, i / 40); if (Math.abs(x - mid) > Math.abs(lerp(0, g.x1 - mid, ap))) continue; ctx.fillStyle = C.red; ctx.globalAlpha = fade * 0.4; ctx.fillRect(x, g.ax - (i % 5 ? 3 : 7) * S, 1 * S, (i % 5 ? 6 : 14) * S); }
464
+ mono("TIME →", g.x1, g.ax + 30 * S, { size: 11, track: 2, color: C.red, alpha: fade * ap * 0.8, align: "right" });
465
+ ctx.restore();
466
+ // lanes
467
+ const la = eOutExpo(prog(f, 196, 212)) * fade;
468
+ for (const [key, label, col] of [["hb", "HEARTBEAT", C.amber], ["wk", "WORKER", C.cyan]]) {
469
+ const y = g[key];
470
+ ctx.save(); ctx.globalAlpha = la * 0.35; ctx.strokeStyle = col; ctx.setLineDash([2 * S, 7 * S]); ctx.lineWidth = 1.2 * S;
471
+ ctx.beginPath(); ctx.moveTo(g.x0, y); ctx.lineTo(lerp(g.x0, g.x1, la), y); ctx.stroke(); ctx.restore();
472
+ mono(label, g.x0 - (PORT ? 0 : 30) * S, y + (PORT ? -36 : 6) * S, { size: 16, weight: 600, track: 3, color: col, alpha: la, align: PORT ? "left" : "right" });
473
+ }
474
+ // worker "live" bar from its first step to the playhead
475
+ const iStart = steps.findIndex((s) => laneOf(s) === "wk");
476
+ const head = lerp(xs[0], g.x1, eIO(prog(f, T0, 288)));
477
+ if (iStart >= 0 && f >= stepF(iStart)) {
478
+ const xa = xs[iStart], xb = Math.max(xa, head), xk = xs[n - 1];
479
+ ctx.save(); ctx.globalAlpha = fade; ctx.lineCap = "round";
480
+ // live part
481
+ ctx.strokeStyle = C.green; ctx.lineWidth = 5 * S; ctx.shadowColor = C.green; ctx.shadowBlur = 14 * S;
482
+ ctx.beginPath(); ctx.moveTo(xa, g.wk); ctx.lineTo(Math.min(xb, f >= slam ? xk : xb), g.wk); ctx.stroke();
483
+ // killed part
484
+ if (f >= slam && xb > xk) { ctx.strokeStyle = C.red; ctx.shadowColor = C.red; ctx.setLineDash([10 * S, 8 * S]); ctx.beginPath(); ctx.moveTo(xk, g.wk); ctx.lineTo(xb, g.wk); ctx.stroke(); }
485
+ ctx.restore();
486
+ // pulses travelling along the live bar
487
+ for (let k = 0; k < 4; k++) { const px = xa + (((f - stepF(iStart)) * 9 * S + k * 140 * S) % Math.max(1, (Math.min(xb, f >= slam ? xk : xb) - xa))); ctx.save(); ctx.globalAlpha = fade * 0.9; ctx.fillStyle = "#d9fff0"; ctx.beginPath(); ctx.arc(px, g.wk, 2.6 * S, 0, 7); ctx.fill(); ctx.restore(); }
488
+ mono(f >= slam + 4 ? "STILL RUNNING" : "RUNNING", xa, g.wk + 34 * S, { size: 12, track: 2.2, color: f >= slam + 4 ? C.red : C.green, alpha: fade * 0.85 });
489
+ }
490
+ // steps
491
+ steps.forEach((s, i) => {
492
+ const f0 = stepF(i), p = eOutBack(prog(f, f0, f0 + 10)), a = clamp(prog(f, f0, f0 + 6)) * fade;
493
+ if (a <= 0) return;
494
+ const lane = laneOf(s), y = g[lane], x = xs[i];
495
+ const col = lane === "hb" ? C.amber : lane === "wk" ? C.cyan : C.red;
496
+ const hit = pulse(f, f0, 6);
497
+ // stem to axis
498
+ ctx.save(); ctx.globalAlpha = a * 0.5; ctx.strokeStyle = col; ctx.lineWidth = 1 * S;
499
+ ctx.beginPath(); ctx.moveTo(x, g.ax); ctx.lineTo(x, lerp(g.ax, y, eOutCubic(prog(f, f0, f0 + 8)))); ctx.stroke(); ctx.restore();
500
+ // chip
501
+ ctx.save(); ctx.globalAlpha = a; ctx.font = font(M, 23 * S, 600);
502
+ const tw = ctx.measureText(s).width, pw = tw + 36 * S, ph = 50 * S;
503
+ ctx.translate(x, y); ctx.scale(p, p);
504
+ ctx.fillStyle = "#101014"; ctx.strokeStyle = col; ctx.lineWidth = 1.5 * S; ctx.shadowColor = col; ctx.shadowBlur = (8 + hit * 30) * S;
505
+ ctx.beginPath(); ctx.roundRect(-pw / 2, -ph / 2, pw, ph, 25 * S); ctx.fill(); ctx.shadowBlur = 0; ctx.stroke();
506
+ ctx.fillStyle = mix(col, "#ffffff", hit * 0.6); ctx.textAlign = "center"; ctx.textBaseline = "middle"; ctx.fillText(s, 0, 1 * S);
507
+ ctx.restore();
508
+ // index
509
+ mono(String(i + 1).padStart(2, "0"), x, g.ax + 30 * S, { size: 11, track: 1.5, color: C.dim, alpha: a, align: "center" });
510
+ });
511
+ // read arrow (heartbeat reads the task) and the slam
512
+ const iRead = steps.findIndex((s) => /Read/.test(s));
513
+ if (iRead >= 0) {
514
+ const f0 = stepF(iRead) + 4, p = eOutCubic(prog(f, f0, f0 + 9));
515
+ if (p > 0) { ctx.save(); ctx.globalAlpha = fade * 0.8; ctx.strokeStyle = C.amber; ctx.setLineDash([4 * S, 6 * S]); ctx.lineWidth = 1.4 * S; ctx.beginPath(); ctx.moveTo(xs[iRead], g.hb + 22 * S); ctx.lineTo(xs[iRead], lerp(g.hb + 22 * S, g.wk - 10 * S, p)); ctx.stroke(); ctx.restore(); }
516
+ }
517
+ if (f >= slam - 2) {
518
+ const x = xs[n - 1], p = eInExpo(prog(f, slam - 2, slam + 1));
519
+ ctx.save(); ctx.globalAlpha = fade; ctx.strokeStyle = C.red; ctx.lineWidth = 5 * S; ctx.shadowColor = C.red; ctx.shadowBlur = 20 * S; ctx.lineCap = "round";
520
+ ctx.beginPath(); ctx.moveTo(x, g.hb + 22 * S); ctx.lineTo(x, lerp(g.hb + 22 * S, g.wk, p)); ctx.stroke(); ctx.restore();
521
+ if (f >= slam) {
522
+ const q = prog(f, slam, slam + 18);
523
+ ctx.save(); ctx.globalAlpha = fade * (1 - q); ctx.strokeStyle = C.red; ctx.lineWidth = 3 * S; ctx.beginPath(); ctx.arc(x, g.wk, (10 + eOutCubic(q) * 160) * S, 0, 7); ctx.stroke(); ctx.restore();
524
+ // X mark
525
+ const xp = eOutBack(prog(f, slam, slam + 8)), xr = 22 * S * xp;
526
+ ctx.save(); ctx.globalAlpha = fade; ctx.strokeStyle = "#fff"; ctx.lineWidth = 4 * S; ctx.lineCap = "round"; ctx.shadowColor = C.red; ctx.shadowBlur = 24 * S;
527
+ ctx.beginPath(); ctx.moveTo(x - xr, g.wk - xr); ctx.lineTo(x + xr, g.wk + xr); ctx.moveTo(x + xr, g.wk - xr); ctx.lineTo(x - xr, g.wk + xr); ctx.stroke(); ctx.restore();
528
+ mono(`${TRACE.inv} VIOLATED`, x, g.wk + 70 * S, { size: 15, weight: 700, track: 2.4, color: C.red, alpha: fade, align: PORT ? "right" : "center", type: (f - slam) * 2.2, cursor: true, f });
529
+ }
530
+ }
531
+ // headline
532
+ const hx = PORT ? W / 2 : L.textX, al = PORT ? "center" : "left";
533
+ mono(`COUNTEREXAMPLE · BUG ${TRACE.bug} · ${steps.length} STEPS`, hx, PORT ? H * 0.16 : H * 0.17, { size: 16, track: 2.6, color: C.red, align: al, type: (f - 196) * 1.6, alpha: fade });
534
+ kinetic(TRACE.title.replace(/\blive\b/, "*live*") + ".", { f, x: hx, y: PORT ? H * 0.225 : H * 0.28, size: PORT ? 68 : 84, weight: 600, align: al, maxW: PORT ? 920 : 1500, start: 200, end: 280, stagger: 3, accentColor: C.green });
535
+ }
536
+
537
+ // ---------- scenes 3+4: tiles (300-560) ----------
538
+ let GRID;
539
+ function buildGrid() {
540
+ const n = TILES.length;
541
+ const cols = PORT ? 3 : Math.ceil(n / 2), rows = Math.ceil(n / cols);
542
+ const tall = PORT && rows > 3;
543
+ const tw = (PORT ? 300 : 306) * S, th = (tall ? 184 : PORT ? 206 : 200) * S, gap = (tall ? 18 : 22) * S;
544
+ const cy = tall ? H * 0.645 : PORT ? H * 0.615 : H * 0.62;
545
+ const top = cy - (rows * th + (rows - 1) * gap) / 2;
546
+ GRID = TILES.map((t, i) => {
547
+ const r = Math.floor(i / cols), inRow = Math.min(cols, n - r * cols), c = i % cols;
548
+ const rowW = inRow * tw + (inRow - 1) * gap;
549
+ return { x: W / 2 - rowW / 2 + c * (tw + gap), y: top + r * (th + gap), w: tw, h: th, t };
550
+ });
551
+ }
552
+ function wrap(text, fnt, maxW, maxLines) {
553
+ ctx.font = fnt; const words = text.split(" "), lines = [""];
554
+ for (const w of words) { const t = lines.at(-1) ? lines.at(-1) + " " + w : w; if (ctx.measureText(t).width > maxW && lines.at(-1)) lines.push(w); else lines[lines.length - 1] = t; }
555
+ if (lines.length > maxLines) { lines.length = maxLines; lines[maxLines - 1] = lines[maxLines - 1].replace(/\s*\S*$/, "") + "…"; }
556
+ return lines;
557
+ }
558
+ const scanX = (f) => { const l = GRID[0].x - 160 * S, r = Math.max(...GRID.map((g) => g.x + g.w)) + 160 * S; return lerp(l, r, eIO(prog(f, 420, 446))); };
559
+ function tileFlipF(g) { const l = GRID[0].x - 160 * S, r = Math.max(...GRID.map((q) => q.x + q.w)) + 160 * S; const target = (g.x + g.w / 2 - l) / (r - l); // invert eIO numerically
560
+ let lo = 0, hi = 1; for (let k = 0; k < 20; k++) { const m = (lo + hi) / 2; if (eIO(m) < target) lo = m; else hi = m; } return 420 + lo * 26; }
561
+ function tiles(f) {
562
+ const dz = 1 + 0.05 * prog(f, 300, 540) + pulse(f, 420, 10) * 0.02, dr = lerp(-0.012, 0.006, eIO(prog(f, 300, 540)));
563
+ ctx.save(); ctx.translate(W / 2, H * 0.6); ctx.rotate(dr); ctx.scale(dz, dz); ctx.translate(-W / 2, -H * 0.6);
564
+ GRID.forEach((g, i) => {
565
+ const t = g.t, f0 = 304 + i * 7;
566
+ const pin = eOutBack(prog(f, f0, f0 + 12)), a = clamp(prog(f, f0, f0 + 5));
567
+ if (a <= 0) return;
568
+ // collapse to center (540-560)
569
+ const cf = 538 + i * 1.2, cp = eInCubic(prog(f, cf, cf + 12));
570
+ if (cp >= 1) return;
571
+ const ff = tileFlipF(g), flipP = prog(f, ff, ff + 10);
572
+ const flipping = t.end === "green" && flipP > 0 && flipP < 1;
573
+ const after = f >= ff;
574
+ const state = !after ? "red" : t.end;
575
+ const col = state === "green" ? C.green : state === "amber" ? C.amber : C.red;
576
+ const cx = g.x + g.w / 2, cy = g.y + g.h / 2;
577
+ const tx = lerp(cx, L.treeX, cp), ty = lerp(cy, L.treeY, cp);
578
+ ctx.save();
579
+ ctx.translate(tx, ty + (1 - pin) * 30 * S);
580
+ const sy = t.end === "green" && flipP > 0 ? Math.abs(Math.cos(Math.PI * flipP)) : 1;
581
+ const sc = lerp(0.9, 1, pin) * (1 - cp);
582
+ const punch = 1 + pulse(f, ff, 5) * (t.end === "green" ? 0.06 : 0.02) * (after ? 1 : 0);
583
+ ctx.scale(sc * punch, sc * Math.max(0.02, sy) * punch);
584
+ ctx.globalAlpha = a * (1 - cp);
585
+ const x = -g.w / 2, y = -g.h / 2;
586
+ // red breath during the silence
587
+ const breath = f >= 400 && f < 420 ? 0.5 + 0.5 * Math.sin((f - 400) * 0.6) : 0;
588
+ ctx.fillStyle = state === "green" ? "#0c1812" : state === "amber" ? "#17130b" : "#150c0d";
589
+ ctx.shadowColor = col; ctx.shadowBlur = (state === "green" ? 36 : 18 + breath * 22) * S;
590
+ ctx.beginPath(); ctx.roundRect(x, y, g.w, g.h, 14 * S); ctx.fill(); ctx.shadowBlur = 0;
591
+ ctx.strokeStyle = col; ctx.lineWidth = 1.5 * S; ctx.globalAlpha = a * (state === "red" ? 0.75 + breath * 0.25 : 1);
592
+ if (state === "amber") ctx.setLineDash([6 * S, 5 * S]);
593
+ ctx.stroke(); ctx.setLineDash([]); ctx.globalAlpha = a;
594
+ const pad = 18 * S;
595
+ mono(t.tag, x + pad, y + pad + 12 * S, { size: 12, track: 2, color: state === "red" ? "#b98a8a" : col });
596
+ const lines = wrap(t.title, font(G, 19 * S, 500), g.w - pad * 2, 4);
597
+ ctx.font = font(G, 19 * S, 500); ctx.fillStyle = C.ink;
598
+ lines.forEach((ln, k) => ctx.fillText(ln, x + pad, y + pad + 48 * S + k * 24 * S));
599
+ // status line
600
+ const sl = y + g.h - pad;
601
+ let status, sc2 = col;
602
+ if (state === "red") status = `● ${t.pinned}`;
603
+ else if (state === "green") status = t.pr ? `✓ passing · #${t.pr} ${t.prState}` : "✓ passing on main";
604
+ else status = `◌ test.failing · fix #${t.pr} ${t.prState}`;
605
+ mono(status, x + pad, sl, { size: 13, weight: 600, color: sc2, type: after ? (f - ff) * 2.4 : 99, track: 0.5 });
606
+ ctx.restore();
607
+ // shockwave + particles on green flips
608
+ if (t.end === "green" && f >= ff + 5) {
609
+ const q = prog(f, ff + 5, ff + 35);
610
+ if (q < 1) {
611
+ ctx.save(); ctx.globalCompositeOperation = "lighter";
612
+ ctx.strokeStyle = C.green; ctx.globalAlpha = (1 - q) * 0.8; ctx.lineWidth = 2 * S;
613
+ ctx.beginPath(); ctx.roundRect(cx - g.w / 2 - q * 120 * S, cy - g.h / 2 - q * 120 * S, g.w + q * 240 * S, g.h + q * 240 * S, (14 + q * 60) * S); ctx.stroke();
614
+ const r = rng(i * 31 + 5);
615
+ for (let k = 0; k < 40; k++) {
616
+ const ang = r() * Math.PI * 2, sp = (80 + r() * 380) * S, life = 0.5 + r() * 0.5, qq = clamp(q / life);
617
+ if (qq >= 1) continue;
618
+ const d = sp * eOutCubic(qq);
619
+ ctx.globalAlpha = (1 - qq) * 0.9; ctx.fillStyle = r() < 0.3 ? "#eafff3" : C.green;
620
+ ctx.beginPath(); ctx.arc(cx + Math.cos(ang) * (g.w * 0.3 + d), cy + Math.sin(ang) * (g.h * 0.3 + d), (1.2 + r() * 2.2) * S, 0, 7); ctx.fill();
621
+ }
622
+ ctx.restore();
623
+ }
624
+ }
625
+ });
626
+ ctx.restore();
627
+ // scanline
628
+ if (f >= 414 && f < 450) {
629
+ const x = f < 420 ? GRID[0].x - 160 * S : scanX(f), a = f < 420 ? prog(f, 414, 420) : 1 - prog(f, 442, 450);
630
+ ctx.save(); ctx.globalCompositeOperation = "lighter";
631
+ const gr = ctx.createLinearGradient(x - 140 * S, 0, x, 0); gr.addColorStop(0, hexA(C.green, 0)); gr.addColorStop(1, hexA(C.green, 0.22 * a));
632
+ ctx.fillStyle = gr; ctx.fillRect(x - 140 * S, 0, 140 * S, H);
633
+ ctx.fillStyle = C.green; ctx.globalAlpha = a; ctx.fillRect(x - 1 * S, 0, 2 * S, H); ctx.restore();
634
+ }
635
+ }
636
+ function scene3(f) {
637
+ // bridge: the X travels into the first tile (290-306)
638
+ const hx = PORT ? W / 2 : W / 2, al = "center";
639
+ kinetic(PORT ? "Each race, pinned | as a *failing* test." : "Each race, pinned as a *failing* test.", { f, x: hx, y: PORT ? H * 0.2 : H * 0.215, size: PORT ? 64 : 80, weight: 600, align: al, maxW: PORT ? 900 : 1600, start: 306, end: 396, stagger: 3, accentColor: C.red });
640
+ const nFail = TILES.length, nTests = TILES.filter((t) => t.tag.startsWith("HEARTBEAT")).length + F.cx.length;
641
+ mono(`${nFail} COUNTEREXAMPLES → ${nTests} RED TESTS`, hx, PORT ? H * 0.2 + 150 * S : H * 0.215 + 56 * S, { size: 14, track: 2.6, color: "#c86a6a", align: al, type: (f - 330) * 1.4, alpha: 1 - prog(f, 396, 404) });
642
+ }
643
+ function scene4(f) {
644
+ const hx = W / 2;
645
+ kinetic(PORT ? "Then a fix PR | turns it *green.*" : "Then a fix PR turns it *green.*", { f, x: hx, y: PORT ? H * 0.2 : H * 0.215, size: PORT ? 64 : 80, weight: 600, align: "center", maxW: PORT ? 900 : 1600, start: 424, end: 532, stagger: 3, accentColor: C.green });
646
+ const t = AMBERS ? `${GREENS} FIXED ON MAIN · ${AMBERS} WITH A FIX PR IN REVIEW` : `ALL ${GREENS} FIXED ON MAIN`;
647
+ mono(t, hx, PORT ? H * 0.2 + 150 * S : H * 0.215 + 56 * S, { size: 14, track: 2.6, color: C.green, align: "center", type: (f - 448) * 1.6, cursor: true, f, alpha: 1 - prog(f, 530, 540) });
648
+ }
649
+
650
+ // ---------- scene 5: collapse to the simpler design (540-645) ----------
651
+ function hexVerts(cx, cy, r, n, rotA = 0) { return Array.from({ length: n }, (_, i) => { const a = -Math.PI / 2 + (i * 2 * Math.PI) / n + rotA; return [cx + Math.cos(a) * r, cy + Math.sin(a) * r]; }); }
652
+ function scene5(f) {
653
+ const cam = treeCam(999, L.fit / (58 * Math.pow(MAXD + 0.5, 0.93)));
654
+ cam.rot = rot(165) + (f - 540) * 0.004;
655
+ const birth = (n) => 552 + n.d * 2.6 + n.j * 3;
656
+ const V = hexVerts(L.treeX, L.treeY, L.hexR, VIEWS);
657
+ const pos = (i) => {
658
+ const n = NODES[i], [x, y] = tp(n, cam), s = 585 + (MAXD - n.d) * 2.2 + n.j * 6, e = eIO(prog(f, s, s + 26));
659
+ const [vx, vy] = V[i % VIEWS];
660
+ return [lerp(x, vx, e), lerp(y, vy, e)];
661
+ };
662
+ const imp = prog(f, 585, 628);
663
+ if (f < 645) {
664
+ // bloom behind
665
+ ctx.save(); ctx.globalCompositeOperation = "lighter";
666
+ const gr = ctx.createRadialGradient(L.treeX, L.treeY, 0, L.treeX, L.treeY, 520 * S);
667
+ gr.addColorStop(0, hexA(C.amber, 0.12 + pulse(f, 555, 10) * 0.25)); gr.addColorStop(1, hexA(C.amber, 0));
668
+ ctx.fillStyle = gr; ctx.fillRect(0, 0, W, H); ctx.restore();
669
+ drawTree(f, { cam, birth, pos, dim: 1, edgeAlpha: 1 - eOutCubic(imp) * 0.95, nodeAlpha: 1 - imp * 0.4 });
670
+ }
671
+ hexMark(f, V);
672
+ // numbers
673
+ const today = STATES_TODAY, simple = STATES_SIMPLE;
674
+ const rp = eIO(prog(f, 590, 628));
675
+ const v = Math.exp(lerp(Math.log(today), Math.log(simple), rp));
676
+ const a = eOutCubic(prog(f, 556, 572)) * (1 - eInCubic(prog(f, 640, 652)));
677
+ const cx = PORT ? W / 2 : L.textX, al = PORT ? "center" : "left";
678
+ const y0 = PORT ? H * 0.17 : H * 0.36;
679
+ mono("REACHABLE STATES · HEARTBEAT MODEL", cx, y0, { size: 13, track: 2.4, color: C.amber, alpha: a, align: al });
680
+ ctx.save(); ctx.globalAlpha = a; ctx.font = font(M, (PORT ? 92 : 104) * S, 600); ctx.fillStyle = rp > 0.98 ? mix(C.ink, C.amberHi, pulse(f, 628, 12)) : C.ink; ctx.textAlign = al;
681
+ ctx.fillText(fmt(v), cx, y0 + (PORT ? 100 : 112) * S); ctx.restore();
682
+ // before / after labels
683
+ const labA = 1 - eOutCubic(prog(f, 596, 606)), labB = eOutCubic(prog(f, 612, 624));
684
+ kinetic("today", { f, x: cx, y: y0 + (PORT ? 170 : 190) * S, size: 44, align: al, start: 562, end: 596, stagger: 2, alpha: a, color: C.dim });
685
+ kinetic("a *simpler* design, proposed.", { f, x: cx, y: y0 + (PORT ? 170 : 190) * S, size: 44, align: al, maxW: PORT ? 900 : 700, start: 606, end: 640, stagger: 3, alpha: a, color: C.dim });
686
+ // strike-through ghost of the old number
687
+ if (rp > 0.5) mono(`was ${fmt(today)}`, cx, y0 + (PORT ? 225 : 250) * S, { size: 15, track: 1.6, color: C.faint, alpha: a * prog(f, 618, 630), align: al });
688
+ }
689
+ // The Agent Swarm logo (apps/ui/public/logo.png == docs-site/public/logo.png == agent-swarm.dev/logo.png).
690
+ // 512px source, #CE9010. Center hex is pointy-top; stroke midline radius 163.4px, stroke ~20.8px (measured).
691
+ let LOGO = null;
692
+ const LOGO_COL = "#ce9010", LOGO_MID = 163.4 / 512, LOGO_STROKE = 20.8 / 512;
693
+ function markTarget() { return PORT ? { x: W / 2, y: H * 0.37, r: 94 * S } : { x: W / 2 - 362 * S, y: H * 0.47, r: 88 * S }; }
694
+ function hexMark(f, V0) {
695
+ // the collapsed graph: VIEWS nodes on a ring; the ring settles onto the logo's center hex, then the honeycomb arrives
696
+ const ringP = eOutCubic(prog(f, 612, 640));
697
+ if (ringP <= 0) return;
698
+ const endP = eIO(prog(f, 638, 664));
699
+ const T = markTarget();
700
+ const cx = lerp(L.treeX, T.x, endP), cy = lerp(L.treeY, T.y, endP), r = lerp(L.hexR, T.r, endP);
701
+ const spin = eIO(prog(f, 638, 684)) * (Math.PI / 3);
702
+ const V = hexVerts(cx, cy, r, VIEWS, spin);
703
+ const D = T.r / LOGO_MID; // logo draw size at which its center hex == our ring
704
+ const mk = eOutCubic(prog(f, 660, 684)); // ring -> logo
705
+ const comb = eOutCubic(prog(f, 666, 690)); // honeycomb in
706
+ ctx.save(); ctx.lineJoin = "miter";
707
+ // ring: thin amber glow line thickening into the logo stroke weight and colour
708
+ const lw = lerp(lerp(2, 4, endP) * S, D * LOGO_STROKE, mk);
709
+ ctx.globalCompositeOperation = mk < 1 ? "lighter" : "source-over";
710
+ ctx.strokeStyle = mix(C.amber, LOGO_COL, mk); ctx.lineWidth = lw; ctx.shadowColor = C.amber; ctx.shadowBlur = 18 * S * (1 - mk);
711
+ ctx.globalAlpha = 1 - eInCubic(prog(f, 684, 692));
712
+ ctx.beginPath();
713
+ const segs = VIEWS * ringP;
714
+ for (let i = 0; i <= Math.floor(segs) && i < VIEWS; i++) {
715
+ const [x, y] = V[i]; if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
716
+ }
717
+ const fi = Math.floor(segs), fr = segs - fi;
718
+ if (fi < VIEWS) { const [x1, y1] = V[fi], [x2, y2] = V[(fi + 1) % VIEWS]; ctx.lineTo(lerp(x1, x2, fr), lerp(y1, y2, fr)); } else ctx.closePath();
719
+ ctx.stroke();
720
+ // nodes shrink into the corners
721
+ ctx.globalCompositeOperation = "lighter"; ctx.globalAlpha = 1;
722
+ ctx.shadowBlur = 24 * S; ctx.fillStyle = "#fff1cf";
723
+ V.forEach(([x, y], i) => { const pp = pulse(f, 600 + i * 3, 10); const rr = (5 + pp * 5) * S * (1 - mk); if (rr > 0.2) { ctx.beginPath(); ctx.arc(x, y, rr, 0, 7); ctx.fill(); } });
724
+ ctx.restore();
725
+ // the real logo: honeycomb cells grow in from the center hex, then the PNG takes over pixel-exact
726
+ if (LOGO && comb > 0) {
727
+ ctx.save(); ctx.globalCompositeOperation = "source-over";
728
+ // warm glow behind the mark
729
+ const g = ctx.createRadialGradient(T.x, T.y, 0, T.x, T.y, D * 0.9);
730
+ g.addColorStop(0, hexA(C.amber, 0.10 * comb)); g.addColorStop(1, hexA(C.amber, 0));
731
+ ctx.fillStyle = g; ctx.fillRect(T.x - D, T.y - D, 2 * D, 2 * D);
732
+ // reveal: circular clip expanding from the center
733
+ ctx.beginPath(); ctx.arc(T.x, T.y, D * 0.3 + D * 0.5 * comb, 0, 7); ctx.clip();
734
+ ctx.globalAlpha = comb; ctx.imageSmoothingEnabled = true; ctx.imageSmoothingQuality = "high";
735
+ const sc = 1 + (1 - comb) * 0.06;
736
+ ctx.drawImage(LOGO, T.x - (D * sc) / 2, T.y - (D * sc) / 2, D * sc, D * sc);
737
+ ctx.restore();
738
+ }
739
+ if (f < 640 && ringP > 0.3) mono(`${VIEWS} STATUS VIEWS`, L.treeX, L.treeY + 6 * S, { size: 12, track: 2.2, color: C.amberHi, align: "center", alpha: prog(f, 622, 630) * (1 - prog(f, 636, 644)) });
740
+ }
741
+
742
+ // ---------- scene 6: end card (645-720) ----------
743
+ function scene6(f) {
744
+ const lx = PORT ? W / 2 : W / 2 - 190 * S, ly = PORT ? H * 0.575 : H * 0.47 + 36 * S;
745
+ const al = PORT ? "center" : "left";
746
+ // letters
747
+ const word = "Agent Swarm"; ctx.save(); ctx.font = font(G, 112 * S, 600); ctx.textBaseline = "alphabetic";
748
+ const tw = ctx.measureText(word).width; let x = PORT ? lx - tw / 2 : lx;
749
+ for (let i = 0; i < word.length; i++) {
750
+ const ch = word[i], cw = ctx.measureText(ch).width, s0 = 662 + i * 1.6, p = eOutExpo(prog(f, s0, s0 + 16));
751
+ ctx.save(); ctx.beginPath(); ctx.rect(x - 4, ly - 120 * S, cw + 8, 150 * S); ctx.clip();
752
+ ctx.globalAlpha = p; ctx.fillStyle = C.ink; if (p < 1) ctx.filter = `blur(${((1 - p) * 8).toFixed(1)}px)`;
753
+ ctx.fillText(ch, x, ly + (1 - p) * 110 * S); ctx.restore(); x += cw;
754
+ }
755
+ ctx.restore();
756
+ kinetic("Races found by a *model checker.*", { f, x: PORT ? W / 2 : lx + 4 * S, y: ly + 70 * S, size: 38, align: al, start: 674, stagger: 3, color: C.dim, maxW: PORT ? 900 : 1200 });
757
+ mono("AGENT-SWARM.DEV", PORT ? W / 2 : lx + 6 * S, ly + 124 * S, { size: 15, track: 4.5, color: C.amber, align: al, type: (f - 684) * 1.3 });
758
+ mono(`Music: ${F.music.credit} · Specs: specs/tla on main`, W / 2, H - 70 * S, { size: 11, track: 1, color: C.faint, align: "center", alpha: prog(f, 680, 690) });
759
+ }
760
+
761
+ // ---------- master ----------
762
+ function shake(f) {
763
+ let a = pulse(f, 255, 5) * 16 + pulse(f, 420, 6) * 9 + pulse(f, 165, 3) * 4;
764
+ return [Math.sin(f * 2.3) * a * S, Math.cos(f * 3.1) * a * S];
765
+ }
766
+ function render(f) {
767
+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = 1; ctx.filter = "none"; ctx.globalCompositeOperation = "source-over";
768
+ // backdrop glow by act
769
+ let gc = C.amber, gx = L.treeX, gy = L.treeY, ga = 1;
770
+ if (f >= 180 && f < 300) { gc = C.red; gx = W / 2; gy = H * 0.6; ga = 0.6 + pulse(f, 255, 10); }
771
+ if (f >= 300 && f < 420) { gc = C.red; gx = W / 2; gy = H * 0.62; ga = 0.55; }
772
+ if (f >= 420 && f < 540) { gc = C.green; gx = W / 2; gy = H * 0.62; ga = 0.5 + pulse(f, 420, 12) * 0.6; }
773
+ if (f >= 645) { gc = C.amber; gx = W / 2; gy = H * 0.5; ga = 1.1; }
774
+ if (f >= 405 && f < 420) ga *= 0.4;
775
+ background(f, gc, gx, gy, ga);
776
+ const [sx, sy] = shake(f);
777
+ ctx.save(); ctx.translate(sx, sy);
778
+ // global drop punch-in
779
+ const punch = 1 + pulse(f, 420, 8) * 0.035 + pulse(f, 255, 6) * 0.02;
780
+ ctx.translate(W / 2, H / 2); ctx.scale(punch, punch); ctx.translate(-W / 2, -H / 2);
781
+ if (f < 180) scene1(f);
782
+ if (f >= 180 && f < 300) scene2(f);
783
+ if (f >= 300 && f < 562) tiles(f);
784
+ if (f >= 300 && f < 420) scene3(f);
785
+ if (f >= 420 && f < 545) scene4(f);
786
+ if (f >= 540) scene5(f);
787
+ if (f >= 645) scene6(f);
788
+ ctx.restore();
789
+ // silence at 405-420: darken everything but the tiles glow; flash frames
790
+
791
+ if (f >= 420 && f < 425) { ctx.fillStyle = hexA(C.green, 0.09 * (1 - prog(f, 420, 425))); ctx.fillRect(0, 0, W, H); }
792
+ if (f >= 555 && f < 561) { ctx.fillStyle = hexA(C.amberHi, 0.18 * (1 - prog(f, 555, 561))); ctx.fillRect(0, 0, W, H); }
793
+ glitch(f, (f >= 255 && f < 263 ? 1 - prog(f, 255, 263) : 0) + (f >= 420 && f < 424 ? 0.6 : 0) + (f >= 165 && f < 167 ? 0.5 : 0), 1);
794
+ hud(f);
795
+ finish(f);
796
+ }
797
+ window.__ready = (async () => {})();
798
+ window.boot = async (facts, fonts, logo) => {
799
+ LOGO = new Image(); LOGO.src = logo; await LOGO.decode();
800
+ for (const [name, b64] of fonts) { const buf = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)); const ff = new FontFace(name, buf); await ff.load(); document.fonts.add(ff); }
801
+ initFacts(facts);
802
+ return { tiles: TILES.length, greens: GREENS, ambers: AMBERS, nodes: NODES.length, edges: EDGES.length, leafD: NODES[LEAF].d };
803
+ };
804
+ window.frame = (f) => { render(f); return cv.toDataURL("image/png"); };
805
+ </script></body></html>