@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,1057 @@
1
+ import {
2
+ ARMIN_HEIGHT,
3
+ ARMIN_WIDTH,
4
+ isArminPixel
5
+ } from "./cli-bsky8g7w.js";
6
+ import {
7
+ backgroundAnsi,
8
+ colorToRgb,
9
+ foregroundAnsi,
10
+ formatKeyText,
11
+ getKeybindings,
12
+ indexedColor,
13
+ rgbColor,
14
+ theme,
15
+ visibleWidth
16
+ } from "./cli-s3hwpt9v.js";
17
+ import"./cli-5bfdm1ah.js";
18
+ import"./cli-0m7wct0d.js";
19
+ import"./cli-pqetb83f.js";
20
+ import"./cli-bc05qbss.js";
21
+
22
+ // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/easter-egg-3d.js
23
+ var DEPTH = 0.7;
24
+ var FLY_START = 0.1;
25
+ var FLY_DURATION = 1.3;
26
+ var START_SCALE = 0.1;
27
+ function createModel(columns, rows, pixel, options) {
28
+ const blocks = [];
29
+ for (let row = 0;row < rows; row++) {
30
+ for (let column = 0;column < columns; column++) {
31
+ const color = pixel(column, row);
32
+ if (color)
33
+ blocks.push({ home: [column, row, 0], color });
34
+ }
35
+ }
36
+ return {
37
+ columns,
38
+ rows,
39
+ blocks,
40
+ cameraDistance: options.cameraDistance,
41
+ radius: Math.hypot(columns / 2, rows / 2, 1 + DEPTH / 2),
42
+ widthShare: options.widthShare,
43
+ puzzleMoves: (random) => options.puzzleMoves(random, blocks.length),
44
+ origin: options.origin
45
+ };
46
+ }
47
+ var CORAL = [228, 138, 122];
48
+ var BLUE = [79, 142, 179];
49
+ var YELLOW = [234, 182, 93];
50
+ var PI_LOGO_PIXELS = ["ccc.", "b.c.", "bb.y", "b..y"];
51
+ var PI_LOGO_COLORS = { c: CORAL, b: BLUE, y: YELLOW };
52
+ function piLogoModel(origin) {
53
+ return createModel(4, 4, (column, row) => PI_LOGO_COLORS[PI_LOGO_PIXELS[row][column]], {
54
+ cameraDistance: 10,
55
+ widthShare: 0.35,
56
+ puzzleMoves: (random) => random < 0.4 ? 2 : 1,
57
+ origin
58
+ });
59
+ }
60
+ function arminModel(color) {
61
+ return createModel(ARMIN_WIDTH, ARMIN_HEIGHT, (column, row) => isArminPixel(column, row) ? color : undefined, {
62
+ cameraDistance: 80,
63
+ widthShare: 0.45,
64
+ puzzleMoves: (random, blockCount) => Math.round(blockCount * (0.03 + random * 0.04)),
65
+ origin: undefined
66
+ });
67
+ }
68
+ var PUZZLE_START = FLY_START + FLY_DURATION + 3;
69
+ var PUZZLE_STEP = 0.3;
70
+ var PUZZLE_STEPS = 12;
71
+ var PUZZLE_RETURN = 1;
72
+ var PUZZLE_HOLD = 0.6;
73
+ var PUZZLE_CYCLE = PUZZLE_STEP * PUZZLE_STEPS + PUZZLE_RETURN + PUZZLE_HOLD;
74
+ var PUZZLE_MOVES = [
75
+ [1, 0, 0],
76
+ [-1, 0, 0],
77
+ [0, 1, 0],
78
+ [0, -1, 0],
79
+ [1, 0, 0],
80
+ [-1, 0, 0],
81
+ [0, 1, 0],
82
+ [0, -1, 0],
83
+ [0, 0, 1],
84
+ [0, 0, -1]
85
+ ];
86
+ function shuffleSteps(model, cycle) {
87
+ const { columns, rows } = model;
88
+ let positions = model.blocks.map((block) => block.home);
89
+ const steps = [positions];
90
+ const lastMoved = new Set;
91
+ let random = cycle * 7919 + 1;
92
+ const next = () => hash(random++);
93
+ const key = ([x, y, z]) => ((z + 1) * rows + y) * columns + x;
94
+ for (let step = 0;step < PUZZLE_STEPS; step++) {
95
+ const occupied = new Set(positions.map(key));
96
+ const nextPositions = [...positions];
97
+ const moved = new Set;
98
+ const moveCount = model.puzzleMoves(next());
99
+ for (let move = 0;move < moveCount; move++) {
100
+ const candidates = [];
101
+ for (let block = 0;block < positions.length; block++) {
102
+ if (moved.has(block))
103
+ continue;
104
+ const [x, y, z] = positions[block];
105
+ for (const [dx, dy, dz] of PUZZLE_MOVES) {
106
+ const target = [x + dx, y + dy, z + dz];
107
+ if (target[0] < 0 || target[0] >= columns || target[1] < 0 || target[1] >= rows)
108
+ continue;
109
+ if (target[2] < -1 || target[2] > 1 || occupied.has(key(target)))
110
+ continue;
111
+ candidates.push({ block, target });
112
+ }
113
+ }
114
+ const fresh = candidates.filter((candidate) => !lastMoved.has(candidate.block));
115
+ const pool = fresh.length > 0 ? fresh : candidates;
116
+ const choice = pool[Math.floor(next() * pool.length)];
117
+ if (!choice)
118
+ break;
119
+ occupied.add(key(choice.target));
120
+ nextPositions[choice.block] = choice.target;
121
+ moved.add(choice.block);
122
+ }
123
+ lastMoved.clear();
124
+ for (const block of moved)
125
+ lastMoved.add(block);
126
+ positions = nextPositions;
127
+ steps.push(positions);
128
+ }
129
+ return steps;
130
+ }
131
+ var FRAME_MS = 1000 / 30;
132
+ var DUST_DURATION = 0.35;
133
+ var WAVE_SPREAD = 0.55;
134
+ var WAVE_JITTER = 0.12;
135
+ var DISSOLVE_END = FLY_START + WAVE_SPREAD + WAVE_JITTER + DUST_DURATION;
136
+ var BACKGROUND_FADE = 0.5;
137
+ var EXIT_DURATION = 1.1;
138
+ var STARS_START = 2.5;
139
+ var STARS_FADE = 2;
140
+ var STAR_DENSITY = 0.018;
141
+ var STAR_TINTS = [
142
+ [255, 255, 255],
143
+ [170, 195, 255],
144
+ [255, 225, 170],
145
+ [255, 190, 205]
146
+ ];
147
+ var LOGO_COLOR_STEP = 5;
148
+ var LIGHT_HALO_STRENGTH = 0.3;
149
+ var HALO_RADIUS_X = 6;
150
+ var HALO_RADIUS_Y = 3;
151
+ var HALO_LEVELS = 32;
152
+ var STAR_ALPHA_LEVELS = 8;
153
+ var STAR_FLICKER_LEVELS = 3;
154
+ var HINT_FADE = 0.5;
155
+ var DOT_BITS = [1, 8, 2, 16, 4, 32, 64, 128];
156
+ var BRAILLE = Array.from({ length: 256 }, (_, bits) => String.fromCharCode(10240 + bits));
157
+ var LIGHT = normalize([-0.45, -0.6, 0.75]);
158
+ var HALF_VECTOR = normalize([LIGHT[0], LIGHT[1], LIGHT[2] + 1]);
159
+ function normalize(v) {
160
+ const length = Math.hypot(v[0], v[1], v[2]);
161
+ return [v[0] / length, v[1] / length, v[2] / length];
162
+ }
163
+ function clamp01(value) {
164
+ return value < 0 ? 0 : value > 1 ? 1 : value;
165
+ }
166
+ function smooth(value) {
167
+ const t = clamp01(value);
168
+ return t * t * t * (t * (t * 6 - 15) + 10);
169
+ }
170
+ function easeOut(value) {
171
+ const t = 1 - clamp01(value);
172
+ return 1 - t * t * t;
173
+ }
174
+ function mix(a, b, amount) {
175
+ return [a[0] + (b[0] - a[0]) * amount, a[1] + (b[1] - a[1]) * amount, a[2] + (b[2] - a[2]) * amount];
176
+ }
177
+ function hash(value) {
178
+ let x = Math.imul(value ^ 2654435769, 2246822507);
179
+ x ^= x >>> 13;
180
+ x = Math.imul(x, 3266489909);
181
+ x ^= x >>> 16;
182
+ return (x >>> 0) / 4294967296;
183
+ }
184
+ function isLight([r, g, b]) {
185
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b > 128;
186
+ }
187
+ function toRgb(color) {
188
+ const { r, g, b } = colorToRgb(color);
189
+ return [r, g, b];
190
+ }
191
+ function glyphInk(text, seed) {
192
+ if (text.trim() === "")
193
+ return 0;
194
+ if (/^[.,:;'`\-_·]$/.test(text))
195
+ return 2;
196
+ if (/^[\u2500-\u257f]$/.test(text))
197
+ return 3;
198
+ return 4 + Math.floor(seed * 3);
199
+ }
200
+ var segmenter = new Intl.Segmenter;
201
+ function parseScreen(lines, width, foreground, background) {
202
+ const palette = (index) => toRgb(indexedColor(index));
203
+ return lines.map((line) => {
204
+ const cells = [];
205
+ let fg;
206
+ let bg;
207
+ let dim = false;
208
+ let inverse = false;
209
+ const applySgr = (params) => {
210
+ const codes = params === "" ? ["0"] : params.split(";");
211
+ for (let i2 = 0;i2 < codes.length; i2++) {
212
+ const parts = codes[i2].split(":").map((part) => Number.parseInt(part, 10));
213
+ const code = parts[0] ?? 0;
214
+ if (code === 38 || code === 48) {
215
+ let args;
216
+ if (parts.length > 1) {
217
+ args = parts.slice(1).filter((part) => !Number.isNaN(part));
218
+ } else {
219
+ const kind = Number.parseInt(codes[i2 + 1] ?? "", 10);
220
+ const count = kind === 5 ? 2 : kind === 2 ? 4 : 1;
221
+ args = codes.slice(i2 + 1, i2 + 1 + count).map((part) => Number.parseInt(part, 10));
222
+ i2 += count;
223
+ }
224
+ let color;
225
+ if (args[0] === 5 && args[1] !== undefined)
226
+ color = palette(args[1]);
227
+ else if (args[0] === 2 && args.length >= 4)
228
+ color = [args[1], args[2], args[3]];
229
+ if (color) {
230
+ if (code === 38)
231
+ fg = color;
232
+ else
233
+ bg = color;
234
+ }
235
+ } else if (code === 0) {
236
+ fg = undefined;
237
+ bg = undefined;
238
+ dim = false;
239
+ inverse = false;
240
+ } else if (code === 2)
241
+ dim = true;
242
+ else if (code === 22)
243
+ dim = false;
244
+ else if (code === 7)
245
+ inverse = true;
246
+ else if (code === 27)
247
+ inverse = false;
248
+ else if (code >= 30 && code <= 37)
249
+ fg = palette(code - 30);
250
+ else if (code >= 90 && code <= 97)
251
+ fg = palette(code - 90 + 8);
252
+ else if (code === 39)
253
+ fg = undefined;
254
+ else if (code >= 40 && code <= 47)
255
+ bg = palette(code - 40);
256
+ else if (code >= 100 && code <= 107)
257
+ bg = palette(code - 100 + 8);
258
+ else if (code === 49)
259
+ bg = undefined;
260
+ }
261
+ };
262
+ const pushText = (text) => {
263
+ for (const { segment } of segmenter.segment(text)) {
264
+ const glyphWidth = visibleWidth(segment);
265
+ if (glyphWidth === 0 || cells.length + glyphWidth > width)
266
+ continue;
267
+ let cellFg = fg ?? foreground;
268
+ let cellBg = bg;
269
+ if (inverse) {
270
+ cellFg = bg ?? background;
271
+ cellBg = fg ?? foreground;
272
+ }
273
+ if (dim)
274
+ cellFg = mix(cellFg, cellBg ?? background, 0.4);
275
+ const cell = { text: segment, width: glyphWidth, fg: cellFg, bg: cellBg, delay: 0, ink: 0, seed: 0 };
276
+ cells.push(cell);
277
+ if (glyphWidth === 2)
278
+ cells.push({ ...cell, text: "", width: 0 });
279
+ }
280
+ };
281
+ let i = 0;
282
+ while (i < line.length) {
283
+ const sequenceStart = line.indexOf("\x1B", i);
284
+ if (sequenceStart === -1) {
285
+ pushText(line.slice(i));
286
+ break;
287
+ }
288
+ if (sequenceStart > i)
289
+ pushText(line.slice(i, sequenceStart));
290
+ const kind = line[sequenceStart + 1];
291
+ if (kind === "[") {
292
+ let end = sequenceStart + 2;
293
+ while (end < line.length && (line.charCodeAt(end) < 64 || line.charCodeAt(end) > 126))
294
+ end++;
295
+ if (line[end] === "m")
296
+ applySgr(line.slice(sequenceStart + 2, end));
297
+ i = end + 1;
298
+ } else if (kind === "]" || kind === "_" || kind === "P" || kind === "^") {
299
+ const bell = line.indexOf("\x07", sequenceStart + 2);
300
+ const st = line.indexOf("\x1B\\", sequenceStart + 2);
301
+ if (bell === -1 && st === -1)
302
+ break;
303
+ i = bell !== -1 && (st === -1 || bell < st) ? bell + 1 : st + 2;
304
+ } else {
305
+ i = sequenceStart + 2;
306
+ }
307
+ }
308
+ return cells;
309
+ });
310
+ }
311
+ function rotation(yaw, pitch, roll) {
312
+ const [sy, cy, sx, cx, sz, cz] = [
313
+ Math.sin(yaw),
314
+ Math.cos(yaw),
315
+ Math.sin(pitch),
316
+ Math.cos(pitch),
317
+ Math.sin(roll),
318
+ Math.cos(roll)
319
+ ];
320
+ const ry = [cy, 0, sy, 0, 1, 0, -sy, 0, cy];
321
+ const rx = [1, 0, 0, 0, cx, -sx, 0, sx, cx];
322
+ const rz = [cz, -sz, 0, sz, cz, 0, 0, 0, 1];
323
+ return multiply(rz, multiply(rx, ry));
324
+ }
325
+ function multiply(a, b) {
326
+ const result = new Array(9);
327
+ for (let row = 0;row < 3; row++) {
328
+ for (let column = 0;column < 3; column++) {
329
+ result[row * 3 + column] = a[row * 3] * b[column] + a[row * 3 + 1] * b[3 + column] + a[row * 3 + 2] * b[6 + column];
330
+ }
331
+ }
332
+ return result;
333
+ }
334
+ var SPIN_RAMP = 1.4;
335
+ var SPIN_SPEED = Math.PI * 2 / PUZZLE_CYCLE;
336
+ var SPIN_LINGER = 0.6;
337
+ var FIRST_FRONT_VIEW = PUZZLE_START + PUZZLE_STEP * PUZZLE_STEPS + PUZZLE_RETURN + PUZZLE_HOLD / 2;
338
+ function baseSpinPhase(time) {
339
+ const elapsed = time - FLY_START;
340
+ if (elapsed <= 0)
341
+ return 0;
342
+ const u = elapsed / SPIN_RAMP;
343
+ if (u < 1)
344
+ return SPIN_SPEED * SPIN_RAMP * (u ** 6 - 3 * u ** 5 + 2.5 * u ** 4);
345
+ return SPIN_SPEED * (SPIN_RAMP * 0.5 + elapsed - SPIN_RAMP);
346
+ }
347
+ var SPIN_ALIGNMENT = Math.PI * 2 - baseSpinPhase(FIRST_FRONT_VIEW) % (Math.PI * 2);
348
+ function spinPhase(time) {
349
+ return baseSpinPhase(time) + SPIN_ALIGNMENT * smooth((time - FLY_START) / FLY_DURATION);
350
+ }
351
+ function spinAngle(time) {
352
+ const phase = spinPhase(time);
353
+ return phase - SPIN_LINGER * Math.sin(phase);
354
+ }
355
+
356
+ class BlockRaster {
357
+ bits = new Uint8Array(0);
358
+ counts = new Uint8Array(0);
359
+ rgb = new Float32Array(0);
360
+ haloAmount = new Float32Array(0);
361
+ haloRgb = new Float32Array(0);
362
+ width = 0;
363
+ height = 0;
364
+ depth = new Float32Array(0);
365
+ faceIds = new Uint16Array(0);
366
+ dirty;
367
+ haloDirty;
368
+ cameraDistance;
369
+ constructor(cameraDistance) {
370
+ this.cameraDistance = cameraDistance;
371
+ }
372
+ render(width, height, pose, boxes, background, haloStrength) {
373
+ const dotWidth = width * 2;
374
+ const dotHeight = height * 4;
375
+ if (width !== this.width || height !== this.height) {
376
+ this.width = width;
377
+ this.height = height;
378
+ this.bits = new Uint8Array(width * height);
379
+ this.counts = new Uint8Array(width * height);
380
+ this.rgb = new Float32Array(width * height * 3);
381
+ this.haloAmount = new Float32Array(width * height);
382
+ this.haloRgb = new Float32Array(width * height * 3);
383
+ this.haloDirty = undefined;
384
+ this.depth = new Float32Array(dotWidth * dotHeight).fill(Infinity);
385
+ this.faceIds = new Uint16Array(dotWidth * dotHeight);
386
+ this.dirty = undefined;
387
+ } else if (this.dirty) {
388
+ const { minX: minX2, minY: minY2, maxX: maxX2, maxY: maxY2 } = this.dirty;
389
+ for (let row = minY2;row <= maxY2; row++) {
390
+ this.bits.fill(0, row * width + minX2, row * width + maxX2 + 1);
391
+ this.counts.fill(0, row * width + minX2, row * width + maxX2 + 1);
392
+ this.rgb.fill(0, (row * width + minX2) * 3, (row * width + maxX2 + 1) * 3);
393
+ }
394
+ this.dirty = undefined;
395
+ }
396
+ if (this.haloDirty) {
397
+ const { minX: minX2, minY: minY2, maxX: maxX2, maxY: maxY2 } = this.haloDirty;
398
+ for (let row = minY2;row <= maxY2; row++) {
399
+ this.haloAmount.fill(0, row * width + minX2, row * width + maxX2 + 1);
400
+ this.haloRgb.fill(0, (row * width + minX2) * 3, (row * width + maxX2 + 1) * 3);
401
+ }
402
+ this.haloDirty = undefined;
403
+ }
404
+ const m = rotation(pose.yaw, pose.pitch, pose.roll);
405
+ const { centerX, centerY, scale } = pose;
406
+ const cameraDistance = this.cameraDistance;
407
+ const origin = [m[6] * cameraDistance, m[7] * cameraDistance, m[8] * cameraDistance];
408
+ const light = isLight(background);
409
+ const faces = this.visibleFaces(m, origin, pose, boxes, dotWidth, dotHeight, light);
410
+ if (faces.length === 0)
411
+ return;
412
+ let minX = dotWidth;
413
+ let minY = dotHeight;
414
+ let maxX = -1;
415
+ let maxY = -1;
416
+ for (const face of faces) {
417
+ minX = Math.min(minX, face.minX);
418
+ minY = Math.min(minY, face.minY);
419
+ maxX = Math.max(maxX, face.maxX);
420
+ maxY = Math.max(maxY, face.maxY);
421
+ }
422
+ if (maxX < minX || maxY < minY)
423
+ return;
424
+ const depth = this.depth;
425
+ const faceIds = this.faceIds;
426
+ for (let faceIndex = 0;faceIndex < faces.length; faceIndex++) {
427
+ const face = faces[faceIndex];
428
+ const a = face.axis;
429
+ const u = (a + 1) % 3;
430
+ const v = (a + 2) % 3;
431
+ const originA = origin[a];
432
+ const originU = origin[u];
433
+ const originV = origin[v];
434
+ const stepA = m[a] / scale;
435
+ const stepU = m[u] / scale;
436
+ const stepV = m[v] / scale;
437
+ const sx = (face.minX + 0.5 - centerX) / scale;
438
+ for (let dotY = face.minY;dotY <= face.maxY; dotY++) {
439
+ const sy = (dotY + 0.5 - centerY) / scale;
440
+ let directionA = m[a] * sx + m[3 + a] * sy - m[6 + a] * cameraDistance;
441
+ let directionU = m[u] * sx + m[3 + u] * sy - m[6 + u] * cameraDistance;
442
+ let directionV = m[v] * sx + m[3 + v] * sy - m[6 + v] * cameraDistance;
443
+ let index = dotY * dotWidth + face.minX;
444
+ for (let dotX = face.minX;dotX <= face.maxX; dotX++, index++) {
445
+ const t = (face.plane - originA) / directionA;
446
+ if (t > 0 && t < depth[index]) {
447
+ const hitU = originU + t * directionU;
448
+ const hitV = originV + t * directionV;
449
+ if (hitU >= face.uMin && hitU <= face.uMax && hitV >= face.vMin && hitV <= face.vMax) {
450
+ depth[index] = t;
451
+ faceIds[index] = faceIndex + 1;
452
+ }
453
+ }
454
+ directionA += stepA;
455
+ directionU += stepU;
456
+ directionV += stepV;
457
+ }
458
+ }
459
+ }
460
+ const bits = this.bits;
461
+ const counts = this.counts;
462
+ const rgb = this.rgb;
463
+ let cellMinX = width;
464
+ let cellMinY = height;
465
+ let cellMaxX = -1;
466
+ let cellMaxY = -1;
467
+ for (let dotY = minY;dotY <= maxY; dotY++) {
468
+ let index = dotY * dotWidth + minX;
469
+ for (let dotX = minX;dotX <= maxX; dotX++, index++) {
470
+ const id = faceIds[index];
471
+ if (id === 0)
472
+ continue;
473
+ const face = faces[id - 1];
474
+ const fog = clamp01(0.15 - cameraDistance * (1 - depth[index]) * 0.12) * (light ? 0.5 : 1);
475
+ faceIds[index] = 0;
476
+ depth[index] = Infinity;
477
+ const cellX = dotX >> 1;
478
+ const cellY = dotY >> 2;
479
+ const cell = cellY * width + cellX;
480
+ bits[cell] |= DOT_BITS[(dotY & 3) * 2 + (dotX & 1)];
481
+ counts[cell]++;
482
+ rgb[cell * 3] += face.red + (background[0] - face.red) * fog;
483
+ rgb[cell * 3 + 1] += face.green + (background[1] - face.green) * fog;
484
+ rgb[cell * 3 + 2] += face.blue + (background[2] - face.blue) * fog;
485
+ if (cellX < cellMinX)
486
+ cellMinX = cellX;
487
+ if (cellX > cellMaxX)
488
+ cellMaxX = cellX;
489
+ if (cellY < cellMinY)
490
+ cellMinY = cellY;
491
+ if (cellY > cellMaxY)
492
+ cellMaxY = cellY;
493
+ }
494
+ }
495
+ if (cellMaxX >= 0)
496
+ this.dirty = { minX: cellMinX, minY: cellMinY, maxX: cellMaxX, maxY: cellMaxY };
497
+ if (haloStrength > 0)
498
+ this.renderHalo(haloStrength);
499
+ }
500
+ renderHalo(strength) {
501
+ const cells = this.dirty;
502
+ if (!cells)
503
+ return;
504
+ const { width, height, counts, rgb } = this;
505
+ const minX = Math.max(0, cells.minX - HALO_RADIUS_X);
506
+ const maxX = Math.min(width - 1, cells.maxX + HALO_RADIUS_X);
507
+ const minY = Math.max(0, cells.minY - HALO_RADIUS_Y);
508
+ const maxY = Math.min(height - 1, cells.maxY + HALO_RADIUS_Y);
509
+ const regionWidth = maxX - minX + 1;
510
+ const tent = (radius) => {
511
+ const weights = Array.from({ length: radius * 2 + 1 }, (_, i) => radius + 1 - Math.abs(i - radius));
512
+ const total = weights.reduce((sum, weight) => sum + weight, 0);
513
+ return weights.map((weight) => weight / total);
514
+ };
515
+ const weightsX = tent(HALO_RADIUS_X);
516
+ const weightsY = tent(HALO_RADIUS_Y);
517
+ const rows = cells.maxY - cells.minY + 1;
518
+ const horizontal = new Float32Array(rows * regionWidth * 4);
519
+ for (let y = cells.minY;y <= cells.maxY; y++) {
520
+ for (let x = minX;x <= maxX; x++) {
521
+ let coverage = 0;
522
+ let red = 0;
523
+ let green = 0;
524
+ let blue = 0;
525
+ for (let dx = -HALO_RADIUS_X;dx <= HALO_RADIUS_X; dx++) {
526
+ const sourceX = x + dx;
527
+ if (sourceX < cells.minX || sourceX > cells.maxX)
528
+ continue;
529
+ const source = y * width + sourceX;
530
+ const count = counts[source];
531
+ if (count === 0)
532
+ continue;
533
+ const weight = weightsX[dx + HALO_RADIUS_X] / 8;
534
+ coverage += count * weight;
535
+ red += rgb[source * 3] * weight;
536
+ green += rgb[source * 3 + 1] * weight;
537
+ blue += rgb[source * 3 + 2] * weight;
538
+ }
539
+ const target = ((y - cells.minY) * regionWidth + (x - minX)) * 4;
540
+ horizontal[target] = coverage;
541
+ horizontal[target + 1] = red;
542
+ horizontal[target + 2] = green;
543
+ horizontal[target + 3] = blue;
544
+ }
545
+ }
546
+ for (let y = minY;y <= maxY; y++) {
547
+ for (let x = minX;x <= maxX; x++) {
548
+ let coverage = 0;
549
+ let red = 0;
550
+ let green = 0;
551
+ let blue = 0;
552
+ for (let dy = -HALO_RADIUS_Y;dy <= HALO_RADIUS_Y; dy++) {
553
+ const sourceY = y + dy;
554
+ if (sourceY < cells.minY || sourceY > cells.maxY)
555
+ continue;
556
+ const weight = weightsY[dy + HALO_RADIUS_Y];
557
+ const source = ((sourceY - cells.minY) * regionWidth + (x - minX)) * 4;
558
+ coverage += horizontal[source] * weight;
559
+ red += horizontal[source + 1] * weight;
560
+ green += horizontal[source + 2] * weight;
561
+ blue += horizontal[source + 3] * weight;
562
+ }
563
+ const target = y * width + x;
564
+ const count = counts[target];
565
+ if (count > 0 && count / 8 > coverage) {
566
+ coverage = count / 8;
567
+ red = rgb[target * 3] / count * coverage;
568
+ green = rgb[target * 3 + 1] / count * coverage;
569
+ blue = rgb[target * 3 + 2] / count * coverage;
570
+ }
571
+ if (coverage <= 0)
572
+ continue;
573
+ const amount = Math.round(strength * Math.min(1, coverage) ** 0.7 * HALO_LEVELS) / HALO_LEVELS;
574
+ if (amount <= 0)
575
+ continue;
576
+ this.haloAmount[target] = amount;
577
+ this.haloRgb[target * 3] = Math.round(red / coverage / LOGO_COLOR_STEP) * LOGO_COLOR_STEP;
578
+ this.haloRgb[target * 3 + 1] = Math.round(green / coverage / LOGO_COLOR_STEP) * LOGO_COLOR_STEP;
579
+ this.haloRgb[target * 3 + 2] = Math.round(blue / coverage / LOGO_COLOR_STEP) * LOGO_COLOR_STEP;
580
+ }
581
+ }
582
+ this.haloDirty = { minX, minY, maxX, maxY };
583
+ }
584
+ visibleFaces(m, origin, pose, boxes, dotWidth, dotHeight, lightBackground) {
585
+ const faces = [];
586
+ const cameraDistance = this.cameraDistance;
587
+ for (const box of boxes) {
588
+ for (let a = 0;a < 3; a++) {
589
+ const u = (a + 1) % 3;
590
+ const v = (a + 2) % 3;
591
+ for (const side of [-1, 1]) {
592
+ const plane = side > 0 ? box.max[a] : box.min[a];
593
+ if ((origin[a] - plane) * side <= 0)
594
+ continue;
595
+ const covered = boxes.some((other) => other !== box && (side > 0 ? other.min[a] : other.max[a]) === plane && other.min[u] <= box.min[u] && other.max[u] >= box.max[u] && other.min[v] <= box.min[v] && other.max[v] >= box.max[v]);
596
+ if (covered)
597
+ continue;
598
+ let minX = Infinity;
599
+ let minY = Infinity;
600
+ let maxX = -Infinity;
601
+ let maxY = -Infinity;
602
+ const corner = [0, 0, 0];
603
+ for (const cornerU of [box.min[u], box.max[u]]) {
604
+ for (const cornerV of [box.min[v], box.max[v]]) {
605
+ corner[a] = plane;
606
+ corner[u] = cornerU;
607
+ corner[v] = cornerV;
608
+ const x = m[0] * corner[0] + m[1] * corner[1] + m[2] * corner[2];
609
+ const y = m[3] * corner[0] + m[4] * corner[1] + m[5] * corner[2];
610
+ const z = m[6] * corner[0] + m[7] * corner[1] + m[8] * corner[2];
611
+ const perspective = pose.scale * cameraDistance / (cameraDistance - z);
612
+ const screenX = pose.centerX + x * perspective;
613
+ const screenY = pose.centerY + y * perspective;
614
+ minX = Math.min(minX, screenX);
615
+ minY = Math.min(minY, screenY);
616
+ maxX = Math.max(maxX, screenX);
617
+ maxY = Math.max(maxY, screenY);
618
+ }
619
+ }
620
+ const face = {
621
+ minX: Math.max(0, Math.floor(minX)),
622
+ minY: Math.max(0, Math.floor(minY)),
623
+ maxX: Math.min(dotWidth - 1, Math.ceil(maxX)),
624
+ maxY: Math.min(dotHeight - 1, Math.ceil(maxY))
625
+ };
626
+ if (face.maxX < face.minX || face.maxY < face.minY)
627
+ continue;
628
+ const nx = m[a] * side;
629
+ const ny = m[3 + a] * side;
630
+ const nz = m[6 + a] * side;
631
+ const diffuse = Math.max(0, nx * LIGHT[0] + ny * LIGHT[1] + nz * LIGHT[2]);
632
+ const rim = Math.max(0, nx * 0.8 - nz * 0.3);
633
+ const specular = lightBackground ? 0 : Math.max(0, nx * HALF_VECTOR[0] + ny * HALF_VECTOR[1] + nz * HALF_VECTOR[2]) ** 24 * 0.6 * 255;
634
+ const light = lightBackground ? Math.min(1, 0.55 + diffuse * 0.45 + rim * 0.1) : 0.45 + diffuse * 0.78 + rim * 0.25;
635
+ faces.push({
636
+ axis: a,
637
+ plane,
638
+ uMin: box.min[u],
639
+ uMax: box.max[u],
640
+ vMin: box.min[v],
641
+ vMax: box.max[v],
642
+ ...face,
643
+ red: Math.min(255, box.color[0] * light + specular),
644
+ green: Math.min(255, box.color[1] * light + specular),
645
+ blue: Math.min(255, box.color[2] * light + specular)
646
+ });
647
+ }
648
+ }
649
+ }
650
+ return faces;
651
+ }
652
+ }
653
+ var playing = false;
654
+ async function playEasterEgg3d(tui, screen, egg) {
655
+ if (playing)
656
+ return;
657
+ playing = true;
658
+ const reported = await tui.queryTerminalColors({ timeoutMs: 100 });
659
+ const dark = theme.appearance === "dark";
660
+ const toRgbTuple = (rgb, fallback) => rgb ? [rgb.r, rgb.g, rgb.b] : fallback;
661
+ const colors = {
662
+ foreground: toRgbTuple(reported.foreground, toRgb(theme.colors.text)),
663
+ background: toRgbTuple(reported.background, dark ? [0, 0, 0] : [255, 255, 255])
664
+ };
665
+ if (tui.hasOverlay()) {
666
+ playing = false;
667
+ return;
668
+ }
669
+ const model = egg.kind === "armin" ? arminModel(toRgb(theme.colors.accent)) : piLogoModel({ column: egg.column, row: egg.row });
670
+ const animation = new EasterEgg3dAnimation(tui, screen, model, colors, () => {
671
+ playing = false;
672
+ overlay.hide();
673
+ });
674
+ const overlay = tui.showOverlay(animation, { anchor: "top-left", width: "100%", maxHeight: "100%" });
675
+ }
676
+
677
+ class EasterEgg3dAnimation {
678
+ tui;
679
+ screen;
680
+ model;
681
+ foreground;
682
+ background;
683
+ onDone;
684
+ startTime = performance.now();
685
+ lastRender = performance.now();
686
+ timer;
687
+ exit;
688
+ shuffle;
689
+ screenWidth = -1;
690
+ screenHeight = -1;
691
+ stars = [];
692
+ cells = [];
693
+ ansiCache = new Map;
694
+ raster;
695
+ constructor(tui, screen, model, colors, onDone) {
696
+ this.tui = tui;
697
+ this.screen = screen;
698
+ this.model = model;
699
+ this.raster = new BlockRaster(model.cameraDistance);
700
+ this.foreground = colors.foreground;
701
+ this.background = colors.background;
702
+ this.onDone = onDone;
703
+ this.timer = setInterval(() => {
704
+ if (this.exit && this.exitProgress() >= 1 || performance.now() - this.lastRender > 1000)
705
+ this.finish();
706
+ else
707
+ this.tui.requestRender();
708
+ }, FRAME_MS);
709
+ this.timer.unref?.();
710
+ }
711
+ close() {
712
+ if (this.exit) {
713
+ this.finish();
714
+ return;
715
+ }
716
+ const time = this.elapsed();
717
+ const yaw = spinAngle(time);
718
+ const turn = Math.PI * 2;
719
+ this.exit = {
720
+ start: performance.now(),
721
+ time,
722
+ yaw,
723
+ targetYaw: Math.ceil(yaw / turn) * turn,
724
+ offsets: this.blockOffsets(time)
725
+ };
726
+ }
727
+ handleInput(data) {
728
+ const keybindings = getKeybindings();
729
+ if (keybindings.matches(data, "tui.select.cancel") || keybindings.matches(data, "app.clear"))
730
+ this.close();
731
+ }
732
+ handleMouse(event) {
733
+ if (event.type === "click")
734
+ this.close();
735
+ return { handled: true, render: false };
736
+ }
737
+ invalidate() {
738
+ this.screenWidth = -1;
739
+ this.screenHeight = -1;
740
+ this.ansiCache.clear();
741
+ }
742
+ render(width) {
743
+ const height = Math.max(1, this.tui.terminal.rows);
744
+ const foreground = this.foreground;
745
+ const background = this.background;
746
+ this.lastRender = performance.now();
747
+ if (width !== this.screenWidth || height !== this.screenHeight) {
748
+ this.screenWidth = width;
749
+ this.screenHeight = height;
750
+ this.cells = this.prepareCells(width, foreground);
751
+ this.stars = this.prepareStars(width, height);
752
+ }
753
+ let dissolveTime;
754
+ let pose;
755
+ let hintAlpha;
756
+ let starAlpha;
757
+ let offsets;
758
+ if (this.exit) {
759
+ const progress = this.exitProgress();
760
+ const landing = clamp01(progress / 0.8);
761
+ const settle = 1 - smooth(landing);
762
+ dissolveTime = Math.min(this.exit.time, DISSOLVE_END) * (1 - progress);
763
+ pose = this.pose(width, height, this.flyProgress(this.exit.time) * settle, this.exit.time);
764
+ pose.yaw = this.exit.yaw + (this.exit.targetYaw - this.exit.yaw) * easeOut(landing);
765
+ pose.pitch *= settle;
766
+ pose.roll *= settle;
767
+ hintAlpha = this.hintAlpha(this.exit.time) * (1 - smooth(progress / 0.2));
768
+ starAlpha = this.starAlpha(this.exit.time) * (1 - smooth(progress / 0.3));
769
+ const gather = 1 - smooth(progress / 0.5);
770
+ offsets = this.exit.offsets.map(([x, y, z]) => [x * gather, y * gather, z * gather]);
771
+ } else {
772
+ const time = this.elapsed();
773
+ dissolveTime = time;
774
+ pose = this.pose(width, height, this.flyProgress(time), time);
775
+ hintAlpha = this.hintAlpha(time);
776
+ starAlpha = this.starAlpha(time);
777
+ offsets = this.blockOffsets(time);
778
+ }
779
+ const { columns, rows } = this.model;
780
+ const boxes = this.model.blocks.map((block, index) => {
781
+ const [dx, dy, dz] = offsets[index];
782
+ const x = block.home[0] - columns / 2 + dx;
783
+ const y = block.home[1] - rows / 2 + dy;
784
+ return { min: [x, y, dz - DEPTH / 2], max: [x + 1, y + 1, dz + DEPTH / 2], color: block.color };
785
+ });
786
+ const raster = this.raster;
787
+ raster.render(width, height, pose, boxes, background, isLight(background) ? LIGHT_HALO_STRENGTH : 0);
788
+ const halo = (index, base) => {
789
+ const amount = raster.haloAmount[index];
790
+ if (amount <= 0)
791
+ return base;
792
+ const color = raster.haloRgb;
793
+ return mix(base ?? background, [color[index * 3], color[index * 3 + 1], color[index * 3 + 2]], amount);
794
+ };
795
+ const backgroundFade = smooth(dissolveTime / BACKGROUND_FADE);
796
+ const textFade = smooth(dissolveTime / 0.6) * 0.3;
797
+ const textActive = dissolveTime < DISSOLVE_END || backgroundFade < 1;
798
+ const hint = this.hint(width, height, hintAlpha, background);
799
+ const frame = Math.floor(dissolveTime * 14);
800
+ const now = this.elapsed();
801
+ const starLevel = Math.round(starAlpha * STAR_ALPHA_LEVELS) / STAR_ALPHA_LEVELS;
802
+ const starfield = (index) => {
803
+ if (starLevel <= 0)
804
+ return;
805
+ const star = this.stars[index];
806
+ if (!star)
807
+ return;
808
+ const flicker = Math.round((0.5 + 0.5 * Math.sin(now * star.speed + star.phase)) * STAR_FLICKER_LEVELS) / STAR_FLICKER_LEVELS;
809
+ return {
810
+ text: star.glyph,
811
+ fg: mix(background, mix(foreground, star.tint, 0.5), star.strength * (0.7 + 0.3 * flicker) * starLevel)
812
+ };
813
+ };
814
+ const lines = [];
815
+ for (let row = 0;row < height; row++) {
816
+ const cells = this.cells[row] ?? [];
817
+ let line = "";
818
+ let currentFg = -1;
819
+ let currentBg = -1;
820
+ const emit = (text, fg, bg) => {
821
+ const fgKey = fg ? this.pack(fg) : -1;
822
+ const bgKey = bg ? this.pack(bg) : -1;
823
+ if (fgKey !== currentFg && text !== " ") {
824
+ line += fg ? this.ansi(fgKey, false) : "\x1B[39m";
825
+ currentFg = fgKey;
826
+ }
827
+ if (bgKey !== currentBg) {
828
+ line += bg ? this.ansi(bgKey, true) : "\x1B[49m";
829
+ currentBg = bgKey;
830
+ }
831
+ line += text;
832
+ };
833
+ for (let column = 0;column < width; column++) {
834
+ const index = row * width + column;
835
+ const cell = textActive ? cells[column] : undefined;
836
+ const cellBg = halo(index, cell?.bg && backgroundFade < 1 ? mix(cell.bg, background, backgroundFade) : undefined);
837
+ if (hint && row === hint.row && column >= hint.start && column < hint.start + hint.text.length) {
838
+ const offset = column - hint.start;
839
+ emit(hint.text[offset], offset < hint.keyLength ? hint.keyColor : hint.color, cellBg);
840
+ continue;
841
+ }
842
+ const dots = raster.bits[index];
843
+ if (dots) {
844
+ const step = LOGO_COLOR_STEP * raster.counts[index];
845
+ const rgb = raster.rgb;
846
+ const color = [
847
+ Math.round(rgb[index * 3] / step) * LOGO_COLOR_STEP,
848
+ Math.round(rgb[index * 3 + 1] / step) * LOGO_COLOR_STEP,
849
+ Math.round(rgb[index * 3 + 2] / step) * LOGO_COLOR_STEP
850
+ ];
851
+ emit(BRAILLE[dots], color, cellBg);
852
+ continue;
853
+ }
854
+ if (!cell) {
855
+ const star = starfield(index);
856
+ emit(star?.text ?? " ", star?.fg, cellBg);
857
+ continue;
858
+ }
859
+ const dust = (dissolveTime - cell.delay) / DUST_DURATION;
860
+ if (dust < 0 && cell.width === 2 && !raster.bits[index + 1]) {
861
+ emit(cell.text, mix(cell.fg, background, textFade), cellBg);
862
+ column++;
863
+ continue;
864
+ }
865
+ if (dust < 0 && cell.width === 1) {
866
+ emit(cell.text, mix(cell.fg, background, textFade), cellBg);
867
+ continue;
868
+ }
869
+ const dotCount = dust < 0 ? cell.ink : Math.round(cell.ink * (1 - clamp01(dust)));
870
+ if (dotCount <= 0) {
871
+ const star = starfield(index);
872
+ emit(star?.text ?? " ", star?.fg, cellBg);
873
+ continue;
874
+ }
875
+ let bits = 0;
876
+ let placed = 0;
877
+ for (let attempt = 0;placed < dotCount && attempt < 32; attempt++) {
878
+ const bit = DOT_BITS[Math.floor(hash(cell.seed * 7919 + frame * 131 + attempt) * 8)];
879
+ if (bits & bit)
880
+ continue;
881
+ bits |= bit;
882
+ placed++;
883
+ }
884
+ const fade = textFade + (1 - textFade) * clamp01(dust) ** 0.8;
885
+ emit(BRAILLE[bits], mix(cell.fg, background, fade), cellBg);
886
+ }
887
+ lines.push(`${line}\x1B[0m`);
888
+ }
889
+ return lines;
890
+ }
891
+ elapsed() {
892
+ return (performance.now() - this.startTime) / 1000;
893
+ }
894
+ exitProgress() {
895
+ return this.exit ? clamp01((performance.now() - this.exit.start) / 1000 / EXIT_DURATION) : 0;
896
+ }
897
+ finish() {
898
+ if (!this.timer)
899
+ return;
900
+ clearInterval(this.timer);
901
+ this.timer = undefined;
902
+ this.onDone();
903
+ }
904
+ blockOffsets(time) {
905
+ const blocks = this.model.blocks;
906
+ const home = () => blocks.map(() => [0, 0, 0]);
907
+ if (time < PUZZLE_START)
908
+ return home();
909
+ const cycle = Math.floor((time - PUZZLE_START) / PUZZLE_CYCLE);
910
+ const local = time - PUZZLE_START - cycle * PUZZLE_CYCLE;
911
+ if (this.shuffle?.cycle !== cycle)
912
+ this.shuffle = { cycle, steps: shuffleSteps(this.model, cycle) };
913
+ const steps = this.shuffle.steps;
914
+ const offset = (position, index) => {
915
+ const block = blocks[index].home;
916
+ return [position[0] - block[0], position[1] - block[1], position[2] - block[2]];
917
+ };
918
+ const shuffleEnd = PUZZLE_STEP * PUZZLE_STEPS;
919
+ if (local < shuffleEnd) {
920
+ const step = Math.floor(local / PUZZLE_STEP);
921
+ const progress = smooth((local - step * PUZZLE_STEP) / PUZZLE_STEP);
922
+ return steps[step].map((from, index) => {
923
+ const a = offset(from, index);
924
+ const b = offset(steps[step + 1][index], index);
925
+ return [a[0] + (b[0] - a[0]) * progress, a[1] + (b[1] - a[1]) * progress, a[2] + (b[2] - a[2]) * progress];
926
+ });
927
+ }
928
+ if (local < shuffleEnd + PUZZLE_RETURN) {
929
+ const u = (local - shuffleEnd) / PUZZLE_RETURN;
930
+ const remaining = 1 - smooth(u);
931
+ const arc = Math.sin(Math.PI * clamp01(u)) * 0.8;
932
+ return steps[PUZZLE_STEPS].map((position, index) => {
933
+ const [x, y, z] = offset(position, index);
934
+ return [x * remaining, y * remaining, z * remaining + (index % 2 === 0 ? arc : -arc)];
935
+ });
936
+ }
937
+ return home();
938
+ }
939
+ flyProgress(time) {
940
+ return smooth((time - FLY_START) / FLY_DURATION);
941
+ }
942
+ starAlpha(time) {
943
+ return smooth((time - STARS_START) / STARS_FADE);
944
+ }
945
+ hintAlpha(time) {
946
+ return smooth((time - FLY_START - FLY_DURATION) / HINT_FADE);
947
+ }
948
+ pose(width, height, progress, time) {
949
+ const { columns, rows, cameraDistance, radius, widthShare, origin } = this.model;
950
+ const reach = radius * (cameraDistance / (cameraDistance - radius));
951
+ const startScale = origin ? 2 * (cameraDistance - DEPTH / 2) / cameraDistance : START_SCALE;
952
+ const endScale = Math.max(startScale, Math.min(width * 2 * widthShare, (height * 4 - 8) * 0.48) / reach);
953
+ const endX = width;
954
+ const endY = height * 2 - 2;
955
+ const startX = origin ? origin.column * 2 + columns : endX;
956
+ const startY = origin ? origin.row * 4 + rows : endY;
957
+ return {
958
+ centerX: startX + (endX - startX) * progress,
959
+ centerY: startY + (endY - startY) * progress,
960
+ scale: startScale * (endScale / startScale) ** progress,
961
+ yaw: spinAngle(time),
962
+ pitch: 0.3 * Math.sin(spinPhase(time)) * progress,
963
+ roll: 0.06 * Math.sin(2 * spinPhase(time)) * progress
964
+ };
965
+ }
966
+ hint(width, height, alpha, background) {
967
+ if (alpha <= 0)
968
+ return;
969
+ const key = formatKeyText(getKeybindings().getKeys("tui.select.cancel")[0] ?? "escape");
970
+ const text = `${key} to return`;
971
+ if (text.length > width)
972
+ return;
973
+ return {
974
+ row: height - 2,
975
+ start: Math.floor((width - text.length) / 2),
976
+ text,
977
+ keyLength: key.length,
978
+ keyColor: mix(background, toRgb(theme.colors.muted), alpha),
979
+ color: mix(background, toRgb(theme.colors.dim), alpha)
980
+ };
981
+ }
982
+ prepareStars(width, height) {
983
+ const stars = new Array(width * height);
984
+ for (let index = 0;index < width * height; index++) {
985
+ if (hash(index * 3 + 20973) >= STAR_DENSITY)
986
+ continue;
987
+ const random = (salt) => hash(index * 7 + salt * 40503);
988
+ stars[index] = {
989
+ glyph: BRAILLE[DOT_BITS[Math.floor(random(1) * 8)]],
990
+ tint: STAR_TINTS[Math.floor(random(2) * STAR_TINTS.length)],
991
+ strength: 0.1 + random(3) * 0.12,
992
+ phase: random(4) * Math.PI * 2,
993
+ speed: 0.4 + random(5) * 0.8
994
+ };
995
+ }
996
+ return stars;
997
+ }
998
+ prepareCells(width, foreground) {
999
+ const cells = parseScreen(this.screen, width, foreground, this.background);
1000
+ const height = Math.max(1, this.tui.terminal.rows);
1001
+ const { columns, rows, origin } = this.model;
1002
+ const centerX = origin ? origin.column + columns / 2 : width / 2;
1003
+ const centerY = origin ? origin.row + rows / 4 : height / 2;
1004
+ const farthest = Math.hypot(Math.max(centerX, width - centerX), Math.max(centerY, height - centerY) * 2);
1005
+ for (let row = 0;row < cells.length; row++) {
1006
+ const line = cells[row];
1007
+ for (let column = 0;column < line.length; column++) {
1008
+ const cell = line[column];
1009
+ const owner = cell.width === 0 ? line[column - 1] : cell;
1010
+ const seed = hash(row * 65537 + column);
1011
+ if (cell.width !== 0) {
1012
+ const distance = Math.hypot(column - centerX, (row - centerY) * 2) / farthest;
1013
+ cell.delay = FLY_START + distance * WAVE_SPREAD + seed * WAVE_JITTER;
1014
+ } else {
1015
+ cell.delay = owner.delay;
1016
+ }
1017
+ cell.seed = row * 65537 + column;
1018
+ cell.ink = glyphInk(owner.text, seed);
1019
+ }
1020
+ }
1021
+ if (origin) {
1022
+ for (let row = origin.row;row < origin.row + Math.ceil(rows / 2); row++) {
1023
+ const line = cells[row];
1024
+ if (!line)
1025
+ continue;
1026
+ for (let column = origin.column;column < origin.column + columns; column++) {
1027
+ const cell = line[column];
1028
+ if (cell) {
1029
+ cell.text = " ";
1030
+ cell.width = 1;
1031
+ cell.ink = 0;
1032
+ cell.bg = undefined;
1033
+ }
1034
+ }
1035
+ }
1036
+ }
1037
+ return cells;
1038
+ }
1039
+ pack(color) {
1040
+ return Math.round(color[0]) << 16 | Math.round(color[1]) << 8 | Math.round(color[2]);
1041
+ }
1042
+ ansi(key, isBackground) {
1043
+ const cacheKey = key * 2 + (isBackground ? 1 : 0);
1044
+ let value = this.ansiCache.get(cacheKey);
1045
+ if (value === undefined) {
1046
+ const color = rgbColor(key >> 16 & 255, key >> 8 & 255, key & 255);
1047
+ const mode = theme.getColorMode();
1048
+ value = isBackground ? backgroundAnsi(color, mode) : foregroundAnsi(color, mode);
1049
+ this.ansiCache.set(cacheKey, value);
1050
+ }
1051
+ return value;
1052
+ }
1053
+ }
1054
+ export {
1055
+ EasterEgg3dAnimation,
1056
+ playEasterEgg3d
1057
+ };