@bastani/atomic 0.9.20-alpha.1 → 0.9.20-alpha.10

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 (1175) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/README.md +52 -7
  3. package/dist/builtin/intercom/CHANGELOG.md +34 -0
  4. package/dist/builtin/intercom/README.md +2 -2
  5. package/dist/builtin/intercom/broker/broker.ts +110 -39
  6. package/dist/builtin/intercom/broker/client.ts +8 -1
  7. package/dist/builtin/intercom/broker/send-handler.ts +59 -2
  8. package/dist/builtin/intercom/index.bundle.mjs +162 -18
  9. package/dist/builtin/intercom/live-route-refusal.ts +69 -0
  10. package/dist/builtin/intercom/package.json +3 -5
  11. package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
  12. package/dist/builtin/intercom/session-target.ts +34 -9
  13. package/dist/builtin/intercom/skills/intercom/SKILL.md +47 -16
  14. package/dist/builtin/intercom/types.ts +3 -1
  15. package/dist/builtin/mcp/CHANGELOG.md +13 -0
  16. package/dist/builtin/mcp/OAUTH.md +1 -1
  17. package/dist/builtin/mcp/README.md +3 -1
  18. package/dist/builtin/mcp/index.bundle.mjs +412 -64
  19. package/dist/builtin/mcp/package.json +4 -4
  20. package/dist/builtin/subagents/CHANGELOG.md +63 -0
  21. package/dist/builtin/subagents/README.md +4 -2
  22. package/dist/builtin/subagents/agents/code-simplifier.md +3 -4
  23. package/dist/builtin/subagents/agents/codebase-analyzer.md +3 -4
  24. package/dist/builtin/subagents/agents/codebase-locator.md +2 -3
  25. package/dist/builtin/subagents/agents/codebase-online-researcher.md +5 -6
  26. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -3
  27. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -3
  28. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -3
  29. package/dist/builtin/subagents/agents/debugger.md +8 -7
  30. package/dist/builtin/subagents/agents/worker.md +5 -4
  31. package/dist/builtin/subagents/package.json +4 -4
  32. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
  33. package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
  34. package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
  35. package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
  36. package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
  37. package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
  38. package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
  39. package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
  40. package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
  41. package/dist/builtin/subagents/skills/feedback/SKILL.md +49 -0
  42. package/dist/builtin/subagents/skills/feedback/scripts/scrub.mjs +498 -0
  43. package/dist/builtin/subagents/skills/subagent/SKILL.md +45 -19
  44. package/dist/builtin/subagents/src/extension/index.bundle.mjs +276 -68
  45. package/dist/builtin/web-access/CHANGELOG.md +18 -0
  46. package/dist/builtin/web-access/index.bundle.mjs +372 -300
  47. package/dist/builtin/web-access/package.json +3 -3
  48. package/dist/builtin/workflows/CHANGELOG.md +169 -0
  49. package/dist/builtin/workflows/README.md +20 -33
  50. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  51. package/dist/builtin/workflows/builtin/{chunk-g0csgs7w.js → chunk-18yz7r43.js} +8 -10
  52. package/dist/builtin/workflows/builtin/{chunk-31j2gs7h.js → chunk-1pd5zcfa.js} +4 -6
  53. package/dist/builtin/workflows/builtin/{chunk-xtxcq5tj.js → chunk-24c235x7.js} +17 -1
  54. package/dist/builtin/workflows/builtin/{chunk-6w6cvk6b.js → chunk-2jv44yz7.js} +4 -6
  55. package/dist/builtin/workflows/builtin/{chunk-yeee2jrc.js → chunk-2npg6daz.js} +76 -90
  56. package/dist/builtin/workflows/builtin/{chunk-z29qbehr.js → chunk-7ps7bnb4.js} +4 -6
  57. package/dist/builtin/workflows/builtin/{chunk-zqtm1d2c.js → chunk-ad864596.js} +13 -218
  58. package/dist/builtin/workflows/builtin/{chunk-fg9esgkj.js → chunk-f8jjd90r.js} +4 -6
  59. package/dist/builtin/workflows/builtin/{chunk-a2kdsqn8.js → chunk-gxrhbnaj.js} +5 -3
  60. package/dist/builtin/workflows/builtin/chunk-twefqrv0.js +10666 -0
  61. package/dist/builtin/workflows/builtin/{chunk-ewkkkbak.js → chunk-ynded223.js} +40 -111
  62. package/dist/builtin/workflows/builtin/{chunk-wf741bv3.js → chunk-z5xdqrs6.js} +4 -6
  63. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  64. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  65. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  66. package/dist/builtin/workflows/builtin/goal.js +4 -4
  67. package/dist/builtin/workflows/builtin/index.d.ts +1 -1
  68. package/dist/builtin/workflows/builtin/index.js +12 -12
  69. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  70. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
  71. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  72. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  73. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  74. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  75. package/dist/builtin/workflows/package.json +4 -4
  76. package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
  77. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
  78. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
  79. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
  80. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
  81. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
  82. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
  83. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
  84. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
  85. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
  86. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
  87. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
  88. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
  89. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
  90. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
  91. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
  92. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  93. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
  94. package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
  95. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  96. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
  97. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
  98. package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
  99. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
  100. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
  101. package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
  102. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
  103. package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
  104. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
  105. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  106. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
  107. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
  108. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
  109. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
  110. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
  111. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
  112. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  113. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
  114. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
  115. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
  116. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
  117. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
  118. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
  119. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
  120. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +10 -9
  121. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +4 -4
  122. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +96 -23
  123. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +75 -27
  124. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +72 -26
  125. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +58 -22
  126. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +118 -0
  127. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +70 -29
  128. package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +1 -1
  129. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +95 -32
  130. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +79 -30
  131. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +139 -0
  132. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -4
  133. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  134. package/dist/builtin/workflows/src/authoring.d.ts +6 -1
  135. package/dist/builtin/workflows/src/extension/index.bundle.mjs +25892 -21909
  136. package/dist/builtin/workflows/src/index.js +43029 -6422
  137. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +11 -0
  138. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +17 -1
  139. package/dist/bun/split-loader.js +13 -0
  140. package/dist/bun/split-loader.js.map +1 -1
  141. package/dist/cli/args.d.ts.map +1 -1
  142. package/dist/cli/args.js +17 -6
  143. package/dist/cli/args.js.map +1 -1
  144. package/dist/cli/file-processor.d.ts +1 -1
  145. package/dist/cli/file-processor.d.ts.map +1 -1
  146. package/dist/cli/file-processor.js.map +1 -1
  147. package/dist/config.d.ts +1 -0
  148. package/dist/config.d.ts.map +1 -1
  149. package/dist/config.js +1 -0
  150. package/dist/config.js.map +1 -1
  151. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  152. package/dist/core/agent-session-accessors.js +2 -1
  153. package/dist/core/agent-session-accessors.js.map +1 -1
  154. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  155. package/dist/core/agent-session-auto-compaction.js +49 -14
  156. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  157. package/dist/core/agent-session-bash.d.ts +3 -1
  158. package/dist/core/agent-session-bash.d.ts.map +1 -1
  159. package/dist/core/agent-session-bash.js +27 -14
  160. package/dist/core/agent-session-bash.js.map +1 -1
  161. package/dist/core/agent-session-boundaries.d.ts +68 -0
  162. package/dist/core/agent-session-boundaries.d.ts.map +1 -0
  163. package/dist/core/agent-session-boundaries.js +339 -0
  164. package/dist/core/agent-session-boundaries.js.map +1 -0
  165. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  166. package/dist/core/agent-session-compaction.js +38 -15
  167. package/dist/core/agent-session-compaction.js.map +1 -1
  168. package/dist/core/agent-session-events.d.ts +6 -6
  169. package/dist/core/agent-session-events.d.ts.map +1 -1
  170. package/dist/core/agent-session-events.js +175 -74
  171. package/dist/core/agent-session-events.js.map +1 -1
  172. package/dist/core/agent-session-export.d.ts +1 -1
  173. package/dist/core/agent-session-export.d.ts.map +1 -1
  174. package/dist/core/agent-session-export.js +34 -39
  175. package/dist/core/agent-session-export.js.map +1 -1
  176. package/dist/core/agent-session-extension-bindings.d.ts +3 -2
  177. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  178. package/dist/core/agent-session-extension-bindings.js +274 -70
  179. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  180. package/dist/core/agent-session-message-queue.d.ts +1 -1
  181. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  182. package/dist/core/agent-session-message-queue.js +36 -7
  183. package/dist/core/agent-session-message-queue.js.map +1 -1
  184. package/dist/core/agent-session-methods.d.ts +55 -15
  185. package/dist/core/agent-session-methods.d.ts.map +1 -1
  186. package/dist/core/agent-session-methods.js.map +1 -1
  187. package/dist/core/agent-session-models.d.ts +2 -2
  188. package/dist/core/agent-session-models.d.ts.map +1 -1
  189. package/dist/core/agent-session-models.js +38 -29
  190. package/dist/core/agent-session-models.js.map +1 -1
  191. package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
  192. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  193. package/dist/core/agent-session-persistent-custom-messages.js +2 -1
  194. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  195. package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
  196. package/dist/core/agent-session-post-tool-compaction.js +18 -1
  197. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  198. package/dist/core/agent-session-prompt.d.ts +1 -1
  199. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  200. package/dist/core/agent-session-prompt.js +186 -36
  201. package/dist/core/agent-session-prompt.js.map +1 -1
  202. package/dist/core/agent-session-queue-pause.d.ts +2 -0
  203. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  204. package/dist/core/agent-session-queue-pause.js +15 -3
  205. package/dist/core/agent-session-queue-pause.js.map +1 -1
  206. package/dist/core/agent-session-retry.d.ts +0 -3
  207. package/dist/core/agent-session-retry.d.ts.map +1 -1
  208. package/dist/core/agent-session-retry.js +28 -20
  209. package/dist/core/agent-session-retry.js.map +1 -1
  210. package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
  211. package/dist/core/agent-session-runtime-auth.js +10 -0
  212. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  213. package/dist/core/agent-session-runtime.d.ts +21 -1
  214. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  215. package/dist/core/agent-session-runtime.js +434 -197
  216. package/dist/core/agent-session-runtime.js.map +1 -1
  217. package/dist/core/agent-session-services.d.ts +4 -0
  218. package/dist/core/agent-session-services.d.ts.map +1 -1
  219. package/dist/core/agent-session-services.js +31 -2
  220. package/dist/core/agent-session-services.js.map +1 -1
  221. package/dist/core/agent-session-state.d.ts +10 -2
  222. package/dist/core/agent-session-state.d.ts.map +1 -1
  223. package/dist/core/agent-session-state.js +32 -22
  224. package/dist/core/agent-session-state.js.map +1 -1
  225. package/dist/core/agent-session-summary.d.ts.map +1 -1
  226. package/dist/core/agent-session-summary.js +9 -2
  227. package/dist/core/agent-session-summary.js.map +1 -1
  228. package/dist/core/agent-session-tasks.d.ts +10 -0
  229. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  230. package/dist/core/agent-session-tasks.js +94 -21
  231. package/dist/core/agent-session-tasks.js.map +1 -1
  232. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  233. package/dist/core/agent-session-tool-hooks.js +41 -8
  234. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  235. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  236. package/dist/core/agent-session-tool-registry.js +13 -26
  237. package/dist/core/agent-session-tool-registry.js.map +1 -1
  238. package/dist/core/agent-session-transfer.js.map +1 -1
  239. package/dist/core/agent-session-tree.d.ts.map +1 -1
  240. package/dist/core/agent-session-tree.js +8 -3
  241. package/dist/core/agent-session-tree.js.map +1 -1
  242. package/dist/core/agent-session-types.d.ts +13 -0
  243. package/dist/core/agent-session-types.d.ts.map +1 -1
  244. package/dist/core/agent-session-types.js.map +1 -1
  245. package/dist/core/agent-session.d.ts +36 -10
  246. package/dist/core/agent-session.d.ts.map +1 -1
  247. package/dist/core/agent-session.js +137 -68
  248. package/dist/core/agent-session.js.map +1 -1
  249. package/dist/core/auth-storage.d.ts +5 -3
  250. package/dist/core/auth-storage.d.ts.map +1 -1
  251. package/dist/core/auth-storage.js +18 -5
  252. package/dist/core/auth-storage.js.map +1 -1
  253. package/dist/core/builtin-diagnostics.d.ts +2 -0
  254. package/dist/core/builtin-diagnostics.d.ts.map +1 -0
  255. package/dist/core/builtin-diagnostics.js +14 -0
  256. package/dist/core/builtin-diagnostics.js.map +1 -0
  257. package/dist/core/builtin-packages.d.ts +5 -2
  258. package/dist/core/builtin-packages.d.ts.map +1 -1
  259. package/dist/core/builtin-packages.js +24 -3
  260. package/dist/core/builtin-packages.js.map +1 -1
  261. package/dist/core/builtin-resource-loader.d.ts +4 -0
  262. package/dist/core/builtin-resource-loader.d.ts.map +1 -0
  263. package/dist/core/builtin-resource-loader.js +239 -0
  264. package/dist/core/builtin-resource-loader.js.map +1 -0
  265. package/dist/core/cache-retention.d.ts +4 -0
  266. package/dist/core/cache-retention.d.ts.map +1 -0
  267. package/dist/core/cache-retention.js +58 -0
  268. package/dist/core/cache-retention.js.map +1 -0
  269. package/dist/core/cache-stats.d.ts +7 -1
  270. package/dist/core/cache-stats.d.ts.map +1 -1
  271. package/dist/core/cache-stats.js +34 -4
  272. package/dist/core/cache-stats.js.map +1 -1
  273. package/dist/core/cache-warmer.d.ts +66 -0
  274. package/dist/core/cache-warmer.d.ts.map +1 -0
  275. package/dist/core/cache-warmer.js +313 -0
  276. package/dist/core/cache-warmer.js.map +1 -0
  277. package/dist/core/child-session-options.d.ts +5 -0
  278. package/dist/core/child-session-options.d.ts.map +1 -0
  279. package/dist/core/child-session-options.js +30 -0
  280. package/dist/core/child-session-options.js.map +1 -0
  281. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  282. package/dist/core/compaction/branch-summarization.js +3 -2
  283. package/dist/core/compaction/branch-summarization.js.map +1 -1
  284. package/dist/core/compaction/compaction-boundary.d.ts +29 -1
  285. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  286. package/dist/core/compaction/compaction-boundary.js +48 -10
  287. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  288. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  289. package/dist/core/compaction/compaction-runner.js +18 -5
  290. package/dist/core/compaction/compaction-runner.js.map +1 -1
  291. package/dist/core/compaction/compaction-types.d.ts +7 -0
  292. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  293. package/dist/core/compaction/compaction-types.js.map +1 -1
  294. package/dist/core/compaction/compaction.d.ts +3 -1
  295. package/dist/core/compaction/compaction.d.ts.map +1 -1
  296. package/dist/core/compaction/compaction.js +55 -0
  297. package/dist/core/compaction/compaction.js.map +1 -1
  298. package/dist/core/compaction/fallback-planner.d.ts +1 -0
  299. package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
  300. package/dist/core/compaction/fallback-planner.js +2 -0
  301. package/dist/core/compaction/fallback-planner.js.map +1 -1
  302. package/dist/core/compaction/index.d.ts +1 -0
  303. package/dist/core/compaction/index.d.ts.map +1 -1
  304. package/dist/core/compaction/index.js +1 -0
  305. package/dist/core/compaction/index.js.map +1 -1
  306. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  307. package/dist/core/compaction/range-planner.js +3 -3
  308. package/dist/core/compaction/range-planner.js.map +1 -1
  309. package/dist/core/compaction/session-summarization.d.ts.map +1 -1
  310. package/dist/core/compaction/session-summarization.js +2 -1
  311. package/dist/core/compaction/session-summarization.js.map +1 -1
  312. package/dist/core/compaction/whole-context-stats.d.ts +21 -0
  313. package/dist/core/compaction/whole-context-stats.d.ts.map +1 -0
  314. package/dist/core/compaction/whole-context-stats.js +32 -0
  315. package/dist/core/compaction/whole-context-stats.js.map +1 -0
  316. package/dist/core/crash-log.d.ts +6 -0
  317. package/dist/core/crash-log.d.ts.map +1 -0
  318. package/dist/core/crash-log.js +69 -0
  319. package/dist/core/crash-log.js.map +1 -0
  320. package/dist/core/credential-screening.d.ts +17 -0
  321. package/dist/core/credential-screening.d.ts.map +1 -0
  322. package/dist/core/credential-screening.js +30 -0
  323. package/dist/core/credential-screening.js.map +1 -0
  324. package/dist/core/execution-model-router.d.ts +45 -0
  325. package/dist/core/execution-model-router.d.ts.map +1 -0
  326. package/dist/core/execution-model-router.js +249 -0
  327. package/dist/core/execution-model-router.js.map +1 -0
  328. package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
  329. package/dist/core/export-html/template.js +6 -1
  330. package/dist/core/extensions/agent-events.d.ts +82 -8
  331. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  332. package/dist/core/extensions/agent-events.js.map +1 -1
  333. package/dist/core/extensions/api-types.d.ts +51 -42
  334. package/dist/core/extensions/api-types.d.ts.map +1 -1
  335. package/dist/core/extensions/api-types.js.map +1 -1
  336. package/dist/core/extensions/context-types.d.ts +7 -1
  337. package/dist/core/extensions/context-types.d.ts.map +1 -1
  338. package/dist/core/extensions/context-types.js.map +1 -1
  339. package/dist/core/extensions/event-results.d.ts +10 -6
  340. package/dist/core/extensions/event-results.d.ts.map +1 -1
  341. package/dist/core/extensions/event-results.js.map +1 -1
  342. package/dist/core/extensions/event-types.d.ts +3 -2
  343. package/dist/core/extensions/event-types.d.ts.map +1 -1
  344. package/dist/core/extensions/event-types.js.map +1 -1
  345. package/dist/core/extensions/extension-work.d.ts +14 -0
  346. package/dist/core/extensions/extension-work.d.ts.map +1 -0
  347. package/dist/core/extensions/extension-work.js +73 -0
  348. package/dist/core/extensions/extension-work.js.map +1 -0
  349. package/dist/core/extensions/herdr-file-integration.d.ts +36 -0
  350. package/dist/core/extensions/herdr-file-integration.d.ts.map +1 -0
  351. package/dist/core/extensions/herdr-file-integration.js +60 -0
  352. package/dist/core/extensions/herdr-file-integration.js.map +1 -0
  353. package/dist/core/extensions/host-input.d.ts +51 -0
  354. package/dist/core/extensions/host-input.d.ts.map +1 -0
  355. package/dist/core/extensions/host-input.js +211 -0
  356. package/dist/core/extensions/host-input.js.map +1 -0
  357. package/dist/core/extensions/index.d.ts +4 -2
  358. package/dist/core/extensions/index.d.ts.map +1 -1
  359. package/dist/core/extensions/index.js +0 -3
  360. package/dist/core/extensions/index.js.map +1 -1
  361. package/dist/core/extensions/jiti-loader.d.ts +2 -0
  362. package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
  363. package/dist/core/extensions/jiti-loader.js +3 -0
  364. package/dist/core/extensions/jiti-loader.js.map +1 -0
  365. package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
  366. package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
  367. package/dist/core/extensions/jiti-static-loader.js +3 -0
  368. package/dist/core/extensions/jiti-static-loader.js.map +1 -0
  369. package/dist/core/extensions/loader-api.d.ts +7 -0
  370. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  371. package/dist/core/extensions/loader-api.js +154 -28
  372. package/dist/core/extensions/loader-api.js.map +1 -1
  373. package/dist/core/extensions/loader-bindings.d.ts +24 -0
  374. package/dist/core/extensions/loader-bindings.d.ts.map +1 -0
  375. package/dist/core/extensions/loader-bindings.js +128 -0
  376. package/dist/core/extensions/loader-bindings.js.map +1 -0
  377. package/dist/core/extensions/loader-core.d.ts +2 -1
  378. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  379. package/dist/core/extensions/loader-core.js +92 -14
  380. package/dist/core/extensions/loader-core.js.map +1 -1
  381. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  382. package/dist/core/extensions/loader-host-modules.js +3 -1
  383. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  384. package/dist/core/extensions/loader-rollback.d.ts +14 -0
  385. package/dist/core/extensions/loader-rollback.d.ts.map +1 -0
  386. package/dist/core/extensions/loader-rollback.js +95 -0
  387. package/dist/core/extensions/loader-rollback.js.map +1 -0
  388. package/dist/core/extensions/loader-runtime.d.ts +3 -1
  389. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  390. package/dist/core/extensions/loader-runtime.js +38 -14
  391. package/dist/core/extensions/loader-runtime.js.map +1 -1
  392. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  393. package/dist/core/extensions/loader-virtual-modules.js +9 -2
  394. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  395. package/dist/core/extensions/loader.d.ts +1 -1
  396. package/dist/core/extensions/loader.d.ts.map +1 -1
  397. package/dist/core/extensions/loader.js +1 -1
  398. package/dist/core/extensions/loader.js.map +1 -1
  399. package/dist/core/extensions/provider-types.d.ts +34 -14
  400. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  401. package/dist/core/extensions/provider-types.js.map +1 -1
  402. package/dist/core/extensions/reactive-widget.d.ts +1 -1
  403. package/dist/core/extensions/reactive-widget.js.map +1 -1
  404. package/dist/core/extensions/runner-context.d.ts +4 -0
  405. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  406. package/dist/core/extensions/runner-context.js +25 -0
  407. package/dist/core/extensions/runner-context.js.map +1 -1
  408. package/dist/core/extensions/runner-events.d.ts +24 -6
  409. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  410. package/dist/core/extensions/runner-events.js +153 -58
  411. package/dist/core/extensions/runner-events.js.map +1 -1
  412. package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
  413. package/dist/core/extensions/runner-project-trust.js +2 -4
  414. package/dist/core/extensions/runner-project-trust.js.map +1 -1
  415. package/dist/core/extensions/runner.d.ts +34 -6
  416. package/dist/core/extensions/runner.d.ts.map +1 -1
  417. package/dist/core/extensions/runner.js +223 -24
  418. package/dist/core/extensions/runner.js.map +1 -1
  419. package/dist/core/extensions/runtime-types.d.ts +6 -0
  420. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  421. package/dist/core/extensions/runtime-types.js.map +1 -1
  422. package/dist/core/extensions/tool-types.d.ts +9 -0
  423. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  424. package/dist/core/extensions/tool-types.js.map +1 -1
  425. package/dist/core/extensions/types.d.ts +3 -2
  426. package/dist/core/extensions/types.d.ts.map +1 -1
  427. package/dist/core/extensions/types.js +0 -12
  428. package/dist/core/extensions/types.js.map +1 -1
  429. package/dist/core/extensions/workflow-activity-hub.d.ts +2 -0
  430. package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
  431. package/dist/core/extensions/workflow-activity-hub.js +5 -3
  432. package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
  433. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  434. package/dist/core/extensions/wrapper.js +5 -3
  435. package/dist/core/extensions/wrapper.js.map +1 -1
  436. package/dist/core/fast-model-routing.d.ts +3 -3
  437. package/dist/core/fast-model-routing.d.ts.map +1 -1
  438. package/dist/core/fast-model-routing.js +4 -3
  439. package/dist/core/fast-model-routing.js.map +1 -1
  440. package/dist/core/fast-model-variants.d.ts +30 -0
  441. package/dist/core/fast-model-variants.d.ts.map +1 -1
  442. package/dist/core/fast-model-variants.js +43 -1
  443. package/dist/core/fast-model-variants.js.map +1 -1
  444. package/dist/core/index.d.ts +4 -1
  445. package/dist/core/index.d.ts.map +1 -1
  446. package/dist/core/index.js +2 -0
  447. package/dist/core/index.js.map +1 -1
  448. package/dist/core/mandatory-resource-loader.d.ts +4 -0
  449. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  450. package/dist/core/mandatory-resource-loader.js +29 -1
  451. package/dist/core/mandatory-resource-loader.js.map +1 -1
  452. package/dist/core/mandatory-runtime-tools.d.ts +1 -4
  453. package/dist/core/mandatory-runtime-tools.d.ts.map +1 -1
  454. package/dist/core/mandatory-runtime-tools.js +1 -9
  455. package/dist/core/mandatory-runtime-tools.js.map +1 -1
  456. package/dist/core/messages.d.ts +10 -0
  457. package/dist/core/messages.d.ts.map +1 -1
  458. package/dist/core/messages.js +76 -2
  459. package/dist/core/messages.js.map +1 -1
  460. package/dist/core/model-config.d.ts +178 -10
  461. package/dist/core/model-config.d.ts.map +1 -1
  462. package/dist/core/model-config.js +48 -19
  463. package/dist/core/model-config.js.map +1 -1
  464. package/dist/core/model-registry.d.ts +6 -2
  465. package/dist/core/model-registry.d.ts.map +1 -1
  466. package/dist/core/model-registry.js +12 -2
  467. package/dist/core/model-registry.js.map +1 -1
  468. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  469. package/dist/core/model-resolver-defaults.js +2 -1
  470. package/dist/core/model-resolver-defaults.js.map +1 -1
  471. package/dist/core/model-routing-constraints.d.ts +24 -0
  472. package/dist/core/model-routing-constraints.d.ts.map +1 -0
  473. package/dist/core/model-routing-constraints.js +46 -0
  474. package/dist/core/model-routing-constraints.js.map +1 -0
  475. package/dist/core/model-routing-task.d.ts +4 -0
  476. package/dist/core/model-routing-task.d.ts.map +1 -0
  477. package/dist/core/model-routing-task.js +77 -0
  478. package/dist/core/model-routing-task.js.map +1 -0
  479. package/dist/core/model-runtime-auth.d.ts +2 -2
  480. package/dist/core/model-runtime-auth.d.ts.map +1 -1
  481. package/dist/core/model-runtime-auth.js.map +1 -1
  482. package/dist/core/model-runtime-streaming.d.ts +13 -3
  483. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  484. package/dist/core/model-runtime-streaming.js +16 -5
  485. package/dist/core/model-runtime-streaming.js.map +1 -1
  486. package/dist/core/model-runtime-types.d.ts +2 -2
  487. package/dist/core/model-runtime-types.d.ts.map +1 -1
  488. package/dist/core/model-runtime-types.js.map +1 -1
  489. package/dist/core/model-runtime.d.ts +29 -6
  490. package/dist/core/model-runtime.d.ts.map +1 -1
  491. package/dist/core/model-runtime.js +84 -7
  492. package/dist/core/model-runtime.js.map +1 -1
  493. package/dist/core/package-manager-npm.d.ts.map +1 -1
  494. package/dist/core/package-manager-npm.js +32 -8
  495. package/dist/core/package-manager-npm.js.map +1 -1
  496. package/dist/core/package-manager-resolver.js +3 -1
  497. package/dist/core/package-manager-resolver.js.map +1 -1
  498. package/dist/core/package-manager-types.d.ts +1 -0
  499. package/dist/core/package-manager-types.d.ts.map +1 -1
  500. package/dist/core/package-manager-types.js.map +1 -1
  501. package/dist/core/prompt-templates-async.d.ts +2 -2
  502. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  503. package/dist/core/prompt-templates-async.js +57 -29
  504. package/dist/core/prompt-templates-async.js.map +1 -1
  505. package/dist/core/prompt-templates.d.ts +6 -1
  506. package/dist/core/prompt-templates.d.ts.map +1 -1
  507. package/dist/core/prompt-templates.js +61 -35
  508. package/dist/core/prompt-templates.js.map +1 -1
  509. package/dist/core/provider-composer-internal.d.ts +41 -20
  510. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  511. package/dist/core/provider-composer-internal.js +43 -20
  512. package/dist/core/provider-composer-internal.js.map +1 -1
  513. package/dist/core/provider-composer.d.ts +3 -3
  514. package/dist/core/provider-composer.d.ts.map +1 -1
  515. package/dist/core/provider-composer.js +54 -10
  516. package/dist/core/provider-composer.js.map +1 -1
  517. package/dist/core/remote-catalog-provider.d.ts +8 -1
  518. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  519. package/dist/core/remote-catalog-provider.js +46 -4
  520. package/dist/core/remote-catalog-provider.js.map +1 -1
  521. package/dist/core/resolve-config-value.d.ts +2 -0
  522. package/dist/core/resolve-config-value.d.ts.map +1 -1
  523. package/dist/core/resolve-config-value.js +23 -1
  524. package/dist/core/resolve-config-value.js.map +1 -1
  525. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  526. package/dist/core/resource-loader-assets.js +6 -6
  527. package/dist/core/resource-loader-assets.js.map +1 -1
  528. package/dist/core/resource-loader-core.d.ts +6 -0
  529. package/dist/core/resource-loader-core.d.ts.map +1 -1
  530. package/dist/core/resource-loader-core.js +41 -6
  531. package/dist/core/resource-loader-core.js.map +1 -1
  532. package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
  533. package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
  534. package/dist/core/resource-loader-extension-warnings.js +54 -0
  535. package/dist/core/resource-loader-extension-warnings.js.map +1 -0
  536. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  537. package/dist/core/resource-loader-extensions.js +3 -0
  538. package/dist/core/resource-loader-extensions.js.map +1 -1
  539. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  540. package/dist/core/resource-loader-reload.js +13 -2
  541. package/dist/core/resource-loader-reload.js.map +1 -1
  542. package/dist/core/resource-loader.d.ts +1 -1
  543. package/dist/core/resource-loader.d.ts.map +1 -1
  544. package/dist/core/resource-loader.js +1 -1
  545. package/dist/core/resource-loader.js.map +1 -1
  546. package/dist/core/runtime-credentials.d.ts +2 -0
  547. package/dist/core/runtime-credentials.d.ts.map +1 -1
  548. package/dist/core/runtime-credentials.js +18 -1
  549. package/dist/core/runtime-credentials.js.map +1 -1
  550. package/dist/core/sdk-types.d.ts +18 -5
  551. package/dist/core/sdk-types.d.ts.map +1 -1
  552. package/dist/core/sdk-types.js.map +1 -1
  553. package/dist/core/sdk.d.ts +3 -1
  554. package/dist/core/sdk.d.ts.map +1 -1
  555. package/dist/core/sdk.js +231 -42
  556. package/dist/core/sdk.js.map +1 -1
  557. package/dist/core/session-lifecycle-scope.d.ts +15 -0
  558. package/dist/core/session-lifecycle-scope.d.ts.map +1 -0
  559. package/dist/core/session-lifecycle-scope.js +13 -0
  560. package/dist/core/session-lifecycle-scope.js.map +1 -0
  561. package/dist/core/session-lifecycle-work.d.ts +17 -0
  562. package/dist/core/session-lifecycle-work.d.ts.map +1 -0
  563. package/dist/core/session-lifecycle-work.js +144 -0
  564. package/dist/core/session-lifecycle-work.js.map +1 -0
  565. package/dist/core/session-manager-core.d.ts +19 -6
  566. package/dist/core/session-manager-core.d.ts.map +1 -1
  567. package/dist/core/session-manager-core.js +117 -12
  568. package/dist/core/session-manager-core.js.map +1 -1
  569. package/dist/core/session-manager-entries.d.ts +4 -1
  570. package/dist/core/session-manager-entries.d.ts.map +1 -1
  571. package/dist/core/session-manager-entries.js +8 -0
  572. package/dist/core/session-manager-entries.js.map +1 -1
  573. package/dist/core/session-manager-history.d.ts +16 -1
  574. package/dist/core/session-manager-history.d.ts.map +1 -1
  575. package/dist/core/session-manager-history.js +106 -40
  576. package/dist/core/session-manager-history.js.map +1 -1
  577. package/dist/core/session-manager-list.d.ts +3 -3
  578. package/dist/core/session-manager-list.d.ts.map +1 -1
  579. package/dist/core/session-manager-list.js +89 -74
  580. package/dist/core/session-manager-list.js.map +1 -1
  581. package/dist/core/session-manager-storage.d.ts.map +1 -1
  582. package/dist/core/session-manager-storage.js +10 -7
  583. package/dist/core/session-manager-storage.js.map +1 -1
  584. package/dist/core/session-manager-types.d.ts +41 -4
  585. package/dist/core/session-manager-types.d.ts.map +1 -1
  586. package/dist/core/session-manager-types.js.map +1 -1
  587. package/dist/core/session-manager.d.ts +2 -2
  588. package/dist/core/session-manager.d.ts.map +1 -1
  589. package/dist/core/session-manager.js +1 -1
  590. package/dist/core/session-manager.js.map +1 -1
  591. package/dist/core/session-startup-rollback.d.ts +5 -0
  592. package/dist/core/session-startup-rollback.d.ts.map +1 -0
  593. package/dist/core/session-startup-rollback.js +16 -0
  594. package/dist/core/session-startup-rollback.js.map +1 -0
  595. package/dist/core/settings-manager-basic-accessors.d.ts +5 -0
  596. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  597. package/dist/core/settings-manager-basic-accessors.js +35 -0
  598. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  599. package/dist/core/settings-manager-core.d.ts.map +1 -1
  600. package/dist/core/settings-manager-core.js +4 -0
  601. package/dist/core/settings-manager-core.js.map +1 -1
  602. package/dist/core/settings-manager.d.ts +1 -0
  603. package/dist/core/settings-manager.d.ts.map +1 -1
  604. package/dist/core/settings-manager.js +1 -0
  605. package/dist/core/settings-manager.js.map +1 -1
  606. package/dist/core/settings-types.d.ts +4 -0
  607. package/dist/core/settings-types.d.ts.map +1 -1
  608. package/dist/core/settings-types.js +1 -1
  609. package/dist/core/settings-types.js.map +1 -1
  610. package/dist/core/settings-write-ownership.d.ts +7 -0
  611. package/dist/core/settings-write-ownership.d.ts.map +1 -0
  612. package/dist/core/settings-write-ownership.js +24 -0
  613. package/dist/core/settings-write-ownership.js.map +1 -0
  614. package/dist/core/skill-catalog.d.ts.map +1 -1
  615. package/dist/core/skill-catalog.js +18 -6
  616. package/dist/core/skill-catalog.js.map +1 -1
  617. package/dist/core/slash-commands.js +1 -1
  618. package/dist/core/slash-commands.js.map +1 -1
  619. package/dist/core/structured-output/choice-schema.d.ts +8 -0
  620. package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
  621. package/dist/core/structured-output/choice-schema.js +79 -0
  622. package/dist/core/structured-output/choice-schema.js.map +1 -0
  623. package/dist/core/structured-output/index.d.ts +10 -0
  624. package/dist/core/structured-output/index.d.ts.map +1 -0
  625. package/dist/core/structured-output/index.js +424 -0
  626. package/dist/core/structured-output/index.js.map +1 -0
  627. package/dist/core/structured-output/invalid-output.d.ts +8 -0
  628. package/dist/core/structured-output/invalid-output.d.ts.map +1 -0
  629. package/dist/core/structured-output/invalid-output.js +4 -0
  630. package/dist/core/structured-output/invalid-output.js.map +1 -0
  631. package/dist/core/structured-output/resolver.d.ts +3 -0
  632. package/dist/core/structured-output/resolver.d.ts.map +1 -0
  633. package/dist/core/structured-output/resolver.js +26 -0
  634. package/dist/core/structured-output/resolver.js.map +1 -0
  635. package/dist/core/structured-output/types.d.ts +76 -0
  636. package/dist/core/structured-output/types.d.ts.map +1 -0
  637. package/dist/core/structured-output/types.js +2 -0
  638. package/dist/core/structured-output/types.js.map +1 -0
  639. package/dist/core/system-prompt.d.ts +48 -5
  640. package/dist/core/system-prompt.d.ts.map +1 -1
  641. package/dist/core/system-prompt.js +141 -100
  642. package/dist/core/system-prompt.js.map +1 -1
  643. package/dist/core/tasks/child-command-owner.d.ts +34 -0
  644. package/dist/core/tasks/child-command-owner.d.ts.map +1 -0
  645. package/dist/core/tasks/child-command-owner.js +70 -0
  646. package/dist/core/tasks/child-command-owner.js.map +1 -0
  647. package/dist/core/tasks/contracts.d.ts +6 -0
  648. package/dist/core/tasks/contracts.d.ts.map +1 -1
  649. package/dist/core/tasks/contracts.js.map +1 -1
  650. package/dist/core/tasks/owner-store.d.ts +6 -0
  651. package/dist/core/tasks/owner-store.d.ts.map +1 -1
  652. package/dist/core/tasks/owner-store.js +16 -3
  653. package/dist/core/tasks/owner-store.js.map +1 -1
  654. package/dist/core/tasks/pause.js +1 -1
  655. package/dist/core/tasks/pause.js.map +1 -1
  656. package/dist/core/tasks/supervisor.d.ts +4 -2
  657. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  658. package/dist/core/tasks/supervisor.js +16 -3
  659. package/dist/core/tasks/supervisor.js.map +1 -1
  660. package/dist/core/tools/ask-user-question/ask-user-question.d.ts +4 -1
  661. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  662. package/dist/core/tools/ask-user-question/ask-user-question.js +32 -35
  663. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  664. package/dist/core/tools/ask-user-question/index.d.ts +1 -1
  665. package/dist/core/tools/ask-user-question/index.js.map +1 -1
  666. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
  667. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  668. package/dist/core/tools/ask-user-question/state/key-router.d.ts +1 -1
  669. package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
  670. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
  671. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  672. package/dist/core/tools/ask-user-question/state/row-intent.d.ts +1 -1
  673. package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
  674. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +1 -1
  675. package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
  676. package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts +1 -1
  677. package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -1
  678. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +1 -1
  679. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  680. package/dist/core/tools/ask-user-question/state/state.d.ts +1 -1
  681. package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
  682. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +1 -1
  683. package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
  684. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +1 -1
  685. package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
  686. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +1 -1
  687. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -1
  688. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
  689. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  690. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
  691. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  692. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
  693. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  694. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +1 -1
  695. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -1
  696. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +1 -1
  697. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  698. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  699. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  700. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
  701. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  702. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +1 -1
  703. package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
  704. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
  705. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  706. package/dist/core/tools/bash-pty-native.d.ts +5 -1
  707. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  708. package/dist/core/tools/bash-pty-native.js +15 -7
  709. package/dist/core/tools/bash-pty-native.js.map +1 -1
  710. package/dist/core/tools/bash.d.ts.map +1 -1
  711. package/dist/core/tools/bash.js +32 -24
  712. package/dist/core/tools/bash.js.map +1 -1
  713. package/dist/core/tools/edit.d.ts.map +1 -1
  714. package/dist/core/tools/edit.js +1 -0
  715. package/dist/core/tools/edit.js.map +1 -1
  716. package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
  717. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
  718. package/dist/core/tools/file-mutation-coordinator.js +45 -38
  719. package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
  720. package/dist/core/tools/find.d.ts +2 -2
  721. package/dist/core/tools/find.d.ts.map +1 -1
  722. package/dist/core/tools/find.js +1 -1
  723. package/dist/core/tools/find.js.map +1 -1
  724. package/dist/core/tools/kill.d.ts +2 -2
  725. package/dist/core/tools/kill.d.ts.map +1 -1
  726. package/dist/core/tools/kill.js +3 -4
  727. package/dist/core/tools/kill.js.map +1 -1
  728. package/dist/core/tools/powershell.d.ts +16 -0
  729. package/dist/core/tools/powershell.d.ts.map +1 -1
  730. package/dist/core/tools/read.d.ts +4 -0
  731. package/dist/core/tools/read.d.ts.map +1 -1
  732. package/dist/core/tools/read.js +5 -1
  733. package/dist/core/tools/read.js.map +1 -1
  734. package/dist/core/tools/structured-output.d.ts +9 -6
  735. package/dist/core/tools/structured-output.d.ts.map +1 -1
  736. package/dist/core/tools/structured-output.js +36 -8
  737. package/dist/core/tools/structured-output.js.map +1 -1
  738. package/dist/core/tools/todos.d.ts.map +1 -1
  739. package/dist/core/tools/todos.js +1 -0
  740. package/dist/core/tools/todos.js.map +1 -1
  741. package/dist/core/tools/tool-concurrency.d.ts +23 -0
  742. package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
  743. package/dist/core/tools/tool-concurrency.js +58 -0
  744. package/dist/core/tools/tool-concurrency.js.map +1 -0
  745. package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
  746. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  747. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  748. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  749. package/dist/core/tools/write.d.ts.map +1 -1
  750. package/dist/core/tools/write.js +1 -0
  751. package/dist/core/tools/write.js.map +1 -1
  752. package/dist/core/usage-totals.d.ts.map +1 -1
  753. package/dist/core/usage-totals.js +4 -0
  754. package/dist/core/usage-totals.js.map +1 -1
  755. package/dist/extensions/herdr/index.d.ts.map +1 -1
  756. package/dist/extensions/herdr/index.js +0 -7
  757. package/dist/extensions/herdr/index.js.map +1 -1
  758. package/dist/extensions/llama/client.d.ts +2 -0
  759. package/dist/extensions/llama/client.d.ts.map +1 -1
  760. package/dist/extensions/llama/client.js +6 -2
  761. package/dist/extensions/llama/client.js.map +1 -1
  762. package/dist/extensions/llama/provider.d.ts.map +1 -1
  763. package/dist/extensions/llama/provider.js +18 -4
  764. package/dist/extensions/llama/provider.js.map +1 -1
  765. package/dist/index-extensions.d.ts +1 -1
  766. package/dist/index-extensions.d.ts.map +1 -1
  767. package/dist/index-extensions.js.map +1 -1
  768. package/dist/index.d.ts +13 -4
  769. package/dist/index.d.ts.map +1 -1
  770. package/dist/index.js +8 -3
  771. package/dist/index.js.map +1 -1
  772. package/dist/main-app-mode.d.ts +1 -1
  773. package/dist/main-app-mode.d.ts.map +1 -1
  774. package/dist/main-app-mode.js +3 -2
  775. package/dist/main-app-mode.js.map +1 -1
  776. package/dist/main-session.d.ts.map +1 -1
  777. package/dist/main-session.js +24 -16
  778. package/dist/main-session.js.map +1 -1
  779. package/dist/main.d.ts.map +1 -1
  780. package/dist/main.js +9 -6
  781. package/dist/main.js.map +1 -1
  782. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  783. package/dist/modes/interactive/components/atomic-banner.js +3 -2
  784. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  785. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  786. package/dist/modes/interactive/components/branch-summary-message.js +12 -5
  787. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  788. package/dist/modes/interactive/components/chat-message-renderer.d.ts +5 -1
  789. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  790. package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
  791. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  792. package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
  793. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  794. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  795. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  796. package/dist/modes/interactive/components/compaction-boundary-message.js +30 -12
  797. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  798. package/dist/modes/interactive/components/custom-editor.d.ts +6 -0
  799. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  800. package/dist/modes/interactive/components/custom-editor.js +17 -0
  801. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  802. package/dist/modes/interactive/components/host-input-form-mount.d.ts +1 -1
  803. package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
  804. package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
  805. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  806. package/dist/modes/interactive/components/host-session-picker.d.ts +1 -1
  807. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  808. package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +1 -1
  809. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
  810. package/dist/modes/interactive/components/scroll-widget.d.ts +1 -1
  811. package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
  812. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  813. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  814. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  815. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  816. package/dist/modes/interactive/components/settings-selector-items.js +52 -1
  817. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  818. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  819. package/dist/modes/interactive/components/settings-selector-submenus.js +2 -1
  820. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  821. package/dist/modes/interactive/components/settings-selector-types.d.ts +8 -2
  822. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  823. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  824. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  825. package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
  826. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  827. package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
  828. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
  829. package/dist/modes/interactive/components/startup-identity.js +11 -2
  830. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  831. package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
  832. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  833. package/dist/modes/interactive/components/task-inspector.js +11 -11
  834. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  835. package/dist/modes/interactive/components/task-list.d.ts +9 -3
  836. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  837. package/dist/modes/interactive/components/task-list.js +26 -2
  838. package/dist/modes/interactive/components/task-list.js.map +1 -1
  839. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  840. package/dist/modes/interactive/components/tool-execution.js +14 -9
  841. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  842. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  843. package/dist/modes/interactive/components/tree-selector-content.js +6 -0
  844. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  845. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  846. package/dist/modes/interactive/components/tree-selector-model.js +1 -0
  847. package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
  848. package/dist/modes/interactive/interactive-agent-events.js +20 -10
  849. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  850. package/dist/modes/interactive/interactive-auth-login.js +3 -5
  851. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  852. package/dist/modes/interactive/interactive-auth-routing.js +2 -2
  853. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  854. package/dist/modes/interactive/interactive-autocomplete.js +4 -0
  855. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  856. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  857. package/dist/modes/interactive/interactive-bash-compact.js +13 -6
  858. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  859. package/dist/modes/interactive/interactive-extension-runtime.js +5 -0
  860. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  861. package/dist/modes/interactive/interactive-input-handling.js +2 -2
  862. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  863. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  864. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  865. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  866. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  867. package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
  868. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  869. package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
  870. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  871. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
  872. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  873. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  874. package/dist/modes/interactive/interactive-process-lifecycle.js +13 -1
  875. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  876. package/dist/modes/interactive/interactive-render-chat.js +30 -34
  877. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  878. package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
  879. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  880. package/dist/modes/interactive/interactive-selectors.js +11 -0
  881. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  882. package/dist/modes/interactive/interactive-session-runtime.js +5 -1
  883. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  884. package/dist/modes/interactive/interactive-slash-commands.js +2 -4
  885. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  886. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  887. package/dist/modes/interactive/interactive-startup.js +2 -2
  888. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  889. package/dist/modes/interactive/interactive-tui.d.ts +3 -6
  890. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  891. package/dist/modes/interactive/interactive-tui.js +15 -5
  892. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  893. package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
  894. package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
  895. package/dist/modes/interactive/overlay-line-composite.js +24 -0
  896. package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
  897. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  898. package/dist/modes/interactive-engine/engine-custom-ui.js +3 -1
  899. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  900. package/dist/modes/interactive-engine/engine-input-form.d.ts +1 -1
  901. package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
  902. package/dist/modes/interactive-engine/engine-session-picker.d.ts +1 -1
  903. package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
  904. package/dist/modes/interactive-engine/isolated-auth.d.ts +16 -0
  905. package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
  906. package/dist/modes/interactive-engine/isolated-auth.js +27 -0
  907. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
  908. package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -0
  909. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  910. package/dist/modes/interactive-engine/isolated-runtime.js +19 -2
  911. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  912. package/dist/modes/interactive-engine/protocol.d.ts +1 -1
  913. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  914. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  915. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  916. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  917. package/dist/modes/rpc/rpc-client-api.js +7 -2
  918. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  919. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  920. package/dist/modes/rpc/rpc-command-handler.js +3 -1
  921. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  922. package/dist/modes/rpc/rpc-keybindings-reload.d.ts +1 -1
  923. package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
  924. package/dist/modes/rpc/rpc-provider-auth.d.ts +3 -2
  925. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
  926. package/dist/modes/rpc/rpc-provider-auth.js +2 -2
  927. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  928. package/dist/modes/rpc/rpc-types.d.ts +2 -0
  929. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  930. package/dist/modes/rpc/rpc-types.js.map +1 -1
  931. package/dist/session-id-target.d.ts +31 -0
  932. package/dist/session-id-target.d.ts.map +1 -0
  933. package/dist/session-id-target.js +57 -0
  934. package/dist/session-id-target.js.map +1 -0
  935. package/dist/utils/abort.d.ts.map +1 -1
  936. package/dist/utils/abort.js +29 -4
  937. package/dist/utils/abort.js.map +1 -1
  938. package/dist/utils/child-process.d.ts +1 -0
  939. package/dist/utils/child-process.d.ts.map +1 -1
  940. package/dist/utils/child-process.js +7 -8
  941. package/dist/utils/child-process.js.map +1 -1
  942. package/dist/utils/clipboard-image.d.ts.map +1 -1
  943. package/dist/utils/clipboard-image.js +15 -29
  944. package/dist/utils/clipboard-image.js.map +1 -1
  945. package/dist/utils/clipboard.d.ts.map +1 -1
  946. package/dist/utils/clipboard.js +88 -12
  947. package/dist/utils/clipboard.js.map +1 -1
  948. package/dist/utils/mime.js +1 -1
  949. package/dist/utils/mime.js.map +1 -1
  950. package/dist/utils/shell.d.ts.map +1 -1
  951. package/dist/utils/shell.js +18 -1
  952. package/dist/utils/shell.js.map +1 -1
  953. package/dist/utils/tool-result-images.d.ts +3 -1
  954. package/dist/utils/tool-result-images.d.ts.map +1 -1
  955. package/dist/utils/tool-result-images.js +4 -1
  956. package/dist/utils/tool-result-images.js.map +1 -1
  957. package/dist/utils/wsl.d.ts +3 -0
  958. package/dist/utils/wsl.d.ts.map +1 -0
  959. package/dist/utils/wsl.js +15 -0
  960. package/dist/utils/wsl.js.map +1 -0
  961. package/docs/background-tasks.md +36 -16
  962. package/docs/build.md +6 -16
  963. package/docs/compaction/reference.md +12 -12
  964. package/docs/compaction.md +33 -109
  965. package/docs/computer-use.md +124 -76
  966. package/docs/containerization.md +4 -5
  967. package/docs/custom-provider/api-reference.md +10 -1
  968. package/docs/custom-provider/oauth.md +4 -2
  969. package/docs/custom-provider/registration.md +1 -1
  970. package/docs/custom-provider/streaming.md +8 -3
  971. package/docs/custom-provider.md +44 -2
  972. package/docs/development.md +13 -138
  973. package/docs/docs.json +19 -4
  974. package/docs/environment-variables.md +21 -5
  975. package/docs/extensions/api-reference.md +6 -2
  976. package/docs/extensions/authoring.md +29 -7
  977. package/docs/extensions/events.md +107 -31
  978. package/docs/extensions/examples.md +1 -0
  979. package/docs/extensions/ui.md +3 -4
  980. package/docs/extensions.md +28 -20
  981. package/docs/getting-started/authentication.md +4 -1
  982. package/docs/getting-started/first-session.md +11 -8
  983. package/docs/getting-started/installation.md +14 -6
  984. package/docs/getting-started/project-instructions.md +5 -1
  985. package/docs/guides/configuration.md +10 -5
  986. package/docs/guides/non-interactive.md +2 -2
  987. package/docs/guides.md +8 -17
  988. package/docs/herdr.md +2 -1
  989. package/docs/index.md +2 -2
  990. package/docs/intercom/operations.md +25 -67
  991. package/docs/intercom/reference.md +15 -5
  992. package/docs/intercom.md +16 -7
  993. package/docs/json.md +12 -2
  994. package/docs/keybindings.md +15 -8
  995. package/docs/llama-cpp.md +6 -2
  996. package/docs/mcp-servers.md +93 -0
  997. package/docs/models/evals.md +75 -465
  998. package/docs/models/model-selection.md +35 -116
  999. package/docs/models/reference.md +70 -24
  1000. package/docs/models.md +7 -4
  1001. package/docs/packages/authoring.md +8 -2
  1002. package/docs/packages/reference.md +5 -1
  1003. package/docs/packages.md +7 -3
  1004. package/docs/programmatic.md +3 -1
  1005. package/docs/prompt-templates.md +3 -2
  1006. package/docs/providers/reference.md +2 -2
  1007. package/docs/providers.md +55 -18
  1008. package/docs/quickstart.md +8 -4
  1009. package/docs/reference/cli.md +21 -13
  1010. package/docs/reference.md +3 -6
  1011. package/docs/rpc/examples.md +2 -0
  1012. package/docs/rpc/protocol.md +11 -13
  1013. package/docs/rpc.md +5 -1
  1014. package/docs/sdk/reference.md +62 -267
  1015. package/docs/sdk/structured-decisions.md +94 -0
  1016. package/docs/sdk.md +194 -19
  1017. package/docs/security.md +7 -4
  1018. package/docs/session-format.md +35 -7
  1019. package/docs/sessions.md +12 -6
  1020. package/docs/settings.md +68 -16
  1021. package/docs/skills/authoring.md +7 -1
  1022. package/docs/skills.md +33 -8
  1023. package/docs/subagents/authoring.md +11 -1
  1024. package/docs/subagents/reference.md +97 -10
  1025. package/docs/subagents.md +52 -36
  1026. package/docs/terminal-setup.md +4 -2
  1027. package/docs/termux.md +3 -1
  1028. package/docs/themes/reference.md +4 -1
  1029. package/docs/themes.md +1 -1
  1030. package/docs/tools.md +431 -20
  1031. package/docs/tui/reference.md +13 -14
  1032. package/docs/tui.md +10 -6
  1033. package/docs/usage.md +34 -7
  1034. package/docs/web-access.md +5 -1
  1035. package/docs/windows.md +18 -11
  1036. package/docs/workflows/api-reference.md +112 -27
  1037. package/docs/workflows/authoring.md +345 -33
  1038. package/docs/workflows/builtins.md +22 -28
  1039. package/docs/workflows/operations.md +253 -140
  1040. package/docs/workflows/reliable-design.md +59 -130
  1041. package/docs/workflows/verification.md +40 -14
  1042. package/docs/workflows.md +12 -17
  1043. package/examples/extensions/README.md +1 -0
  1044. package/examples/extensions/custom-provider-anthropic/index.ts +15 -10
  1045. package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
  1046. package/examples/extensions/debug-provider.ts +90 -0
  1047. package/examples/extensions/prompt-customizer.ts +17 -37
  1048. package/examples/extensions/structured-output.ts +6 -0
  1049. package/examples/rpc-client.ts +38 -0
  1050. package/examples/rpc-extension-ui.ts +19 -5
  1051. package/examples/sdk/README.md +1 -1
  1052. package/npm-shrinkwrap.json +506 -713
  1053. package/package.json +13 -11
  1054. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
  1055. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
  1056. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
  1057. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
  1058. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
  1059. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
  1060. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
  1061. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
  1062. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
  1063. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
  1064. package/dist/builtin/workflows/builtin/chunk-m0xfsef8.js +0 -2813
  1065. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
  1066. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
  1067. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
  1068. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  1069. package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
  1070. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
  1071. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
  1072. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
  1073. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
  1074. package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
  1075. package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
  1076. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
  1077. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
  1078. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
  1079. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
  1080. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
  1081. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
  1082. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
  1083. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
  1084. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
  1085. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  1086. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
  1087. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
  1088. package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  1089. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
  1090. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
  1091. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
  1092. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
  1093. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
  1094. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  1095. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
  1096. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
  1097. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
  1098. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
  1099. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
  1100. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
  1101. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
  1102. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
  1103. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
  1104. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
  1105. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
  1106. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
  1107. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
  1108. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
  1109. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
  1110. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
  1111. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
  1112. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
  1113. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
  1114. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
  1115. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
  1116. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  1117. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
  1118. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
  1119. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
  1120. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
  1121. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
  1122. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
  1123. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
  1124. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
  1125. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
  1126. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
  1127. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
  1128. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
  1129. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
  1130. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
  1131. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
  1132. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
  1133. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
  1134. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
  1135. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
  1136. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
  1137. package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  1138. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
  1139. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  1140. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  1141. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  1142. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
  1143. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
  1144. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
  1145. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
  1146. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
  1147. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
  1148. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
  1149. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
  1150. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
  1151. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
  1152. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
  1153. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
  1154. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
  1155. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
  1156. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
  1157. package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  1158. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
  1159. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
  1160. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
  1161. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
  1162. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
  1163. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
  1164. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
  1165. package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
  1166. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
  1167. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
  1168. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
  1169. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
  1170. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
  1171. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
  1172. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +0 -58
  1173. package/docs/models/artificial-analysis-index.md +0 -89
  1174. package/docs/models/pareto-efficiency.md +0 -90
  1175. package/docs/tools/edit.md +0 -378
@@ -1,1540 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Visual question server: present a decision to the user as a themed page
4
- * instead of a plain-text prompt, then block until they answer.
5
- *
6
- * The script IS the wait: run it via the shell, it serves the page, prints
7
- * the URL (and tries to open the default browser), and does not exit until
8
- * the user chooses. The answer lands on stdout as one line:
9
- *
10
- * ANSWER: {"optionId":"...","steer":"..."}
11
- *
12
- * Exit codes: 0 answered · 2 timed out, closed without answering, or no
13
- * browser is available (IMPECCABLE_QUESTION_DISABLED, or a detected
14
- * CI/headless/remote environment; IMPECCABLE_QUESTION_FORCE=1 overrides
15
- * detection, --no-open skips it since the caller opens the URL itself).
16
- *
17
- * Payload (JSON file via --payload, or stdin):
18
- * {
19
- * "title": "Choose the visual world",
20
- * "question": "The roll assigned Fillmore Handbill. Keep it, take an alternate, or re-roll.",
21
- * "options": [
22
- * {
23
- * "id": "assigned", // returned verbatim
24
- * "label": "Fillmore Handbill",
25
- * "kicker": "THE ROLL", // optional badge; the assigned option leads
26
- * "lineage": "1966-71 Fillmore ...", // optional
27
- * "thesis": "one line: the idea this direction owns", // optional
28
- * "palette": ["#1a2f5e", "oklch(84% .19 80)", ...], // optional, rendered as chips
29
- * "materials": ["letterpress", "newsprint"], // optional, rendered as tags
30
- * "viewport": "one line: the first-viewport composition", // optional
31
- * "case": "one line: the fusion verdict, honest", // optional
32
- * "verdict": "competitive", // optional routing tier: "wins" |
33
- * // "competitive" | "declined". Declined cards
34
- * // render demoted after the full cards:
35
- * // narrow, quiet, catalog art as a labeled
36
- * // thumb, "Adopt anyway" instead of "Build
37
- * // this". Still choosable; never deleted.
38
- * "kept": "one line: what the direction kept from this declined world",
39
- * "raised": [ { "from": "challenger-x", "raise": "one line" } ],
40
- * // assigned card only: donations taken from
41
- * // declined challengers, rendered as named
42
- * // raise lines under the identity row
43
- * "risk": "one line: the honest risk", // optional
44
- * "body": "fallback prose when the structured fields are absent",
45
- * "comp": ".impeccable/mocks/decision/assigned.webp", // optional; the card's
46
- * // full-fidelity direction comp (the legacy
47
- * // key "sketch" is accepted as an alias). May
48
- * // not exist yet: the page shimmer-waits and
49
- * // polls the slot until the file lands, so
50
- * // serve first and generate after
51
- * "hero": "https://... or /abs/path.webp", // optional inspiration image;
52
- * // rides picture-in-picture when a comp exists
53
- * "board": "https://... or /abs/path.webp" // optional secondary image
54
- * }, ...
55
- * ],
56
- * "reroll": true, // adds a re-roll action (returns {"optionId":"reroll"})
57
- * // or { "registers": ["safer", "bolder"] } to add
58
- * // the register steers beside it: the answer then
59
- * // carries "register" and the agent re-runs
60
- * // concept-seed with --register <value>
61
- * "canon": true, // adds the "Play it straight" standing exit;
62
- * // direction rounds only (returns {"optionId":"canon"})
63
- * "canonCard": { ... }, // optional: the standing exit as a full card with the
64
- * // same anatomy (label, thesis, palette, comp, ...);
65
- * // rendered last and visually subordinate. Without it,
66
- * // canon stays a quiet footer action.
67
- * "steer": true, // adds a free-text steer field returned with any answer
68
- * "followup": true // this round's pick is not terminal: the server
69
- * // stays open awaiting --update with the next
70
- * // round (detached mode only), the page shows a
71
- * // loading hand instead of goodbye, and the
72
- * // answer carries followup:true so --wait knows
73
- * // to keep the table. Use it when a decision has
74
- * // a known second half, e.g. direction first,
75
- * // then the execution contract.
76
- * }
77
- *
78
- * Options render as large cards: the comp leads when present, with the
79
- * inspiration image picture-in-picture; a hero alone renders full-bleed; a
80
- * text-only direction gets its identity from the palette chips and tags.
81
- * Local image paths are served by this server; nothing is uploaded anywhere.
82
- *
83
- * Modes:
84
- * (default) block until answered; ANSWER on stdout; exit 0.
85
- * --schema print the canonical payload example and exit.
86
- * --start for harnesses that cannot leave a shell blocked: daemonize the
87
- * server, print QUESTION URL + QUESTION KEY, exit immediately.
88
- * Never auto-opens a browser: the agent routes the URL to the
89
- * best surface it has (in-app browser first, then the system
90
- * opener); pass --open to force the system browser instead.
91
- * --wait --key K [--poll 60] poll for the answer: exit 0 + ANSWER line,
92
- * exit 3 WAITING (run --wait again), exit 2 server gone,
93
- * exit 4 PAGE CLOSED (the tab went away without an answer;
94
- * re-present, reopen the URL, or fall back).
95
- * --stop --key K kill a daemonized question.
96
- * --update --key K --payload F deliver the next hand after a re-roll: the
97
- * live page swaps to loading cards when the user re-rolls, and
98
- * reloads into this new payload the moment it lands.
99
- *
100
- * node serve-question.mjs --payload question.json [--timeout 900] [--no-open] [--port 0]
101
- */
102
- import http from 'node:http';
103
- import fs from 'node:fs';
104
- import path from 'node:path';
105
- import { spawn } from 'node:child_process';
106
- import { fileURLToPath } from 'node:url';
107
- import { openSystemBrowser } from './lib/open-system-browser.mjs';
108
-
109
- function arg(name, fallback = null) {
110
- const i = process.argv.indexOf(`--${name}`);
111
- if (i === -1) return fallback;
112
- const v = process.argv[i + 1];
113
- return v && !v.startsWith('--') ? v : fallback;
114
- }
115
- const hasFlag = (name) => process.argv.includes(`--${name}`);
116
-
117
- if (process.env.IMPECCABLE_QUESTION_DISABLED) {
118
- console.log('serve-question: disabled in this session (no browser); use the structured question tool instead.');
119
- process.exit(2);
120
- }
121
- // Headless self-detection, applied only where a browser is actually wanted.
122
- // --no-open means the caller opens the URL itself, and --wait / --stop /
123
- // --schema never open anything: --wait polls a daemon whose browser question
124
- // was already settled at --start, --stop kills one, --schema prints text. A
125
- // spurious exit 2 from those breaks the documented loop, which polls --wait
126
- // while it exits 3 and reads --schema before building a payload.
127
- const wantsBrowser = !hasFlag('no-open') && !hasFlag('wait') && !hasFlag('stop') && !hasFlag('schema');
128
- if (wantsBrowser && !process.env.IMPECCABLE_QUESTION_FORCE) {
129
- const headless =
130
- process.env.CI ||
131
- (process.env.SSH_CONNECTION && !process.env.DISPLAY) ||
132
- (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY);
133
- if (headless) {
134
- console.log('serve-question: no browser detected in this environment (CI/headless/remote); use the structured question tool instead. Set IMPECCABLE_QUESTION_FORCE=1 to serve anyway.');
135
- process.exit(2);
136
- }
137
- }
138
-
139
- // Both answer channels (blocking stdout and --wait collection) print through
140
- // this: the ANSWER line, then a directive to open the chosen card's imagery
141
- // when it has any. The card viewing happens at the moment of choice, in the
142
- // working turn, because a build that never reopens the chosen world's board
143
- // and hero calibrates on nothing.
144
- function printAnswer(raw) {
145
- console.log(`ANSWER: ${raw}`);
146
- try {
147
- const a = JSON.parse(raw);
148
- if (a.hero || a.board) {
149
- console.log("CHOSEN CARD: open the chosen world's board and hero images now, before any code. When your harness only reads files, or runs sandboxed, download them INTO the workspace and open the relative path; a sandboxed viewer rejects absolute paths outside it. They set the craft bar the build must reach.");
150
- }
151
- if (a.comp) {
152
- console.log('CHOSEN COMP: the decision comp at that path is compositional option one. On a comp-led build the comp round adds two variations beside it; on a code-led build it returns at the finish review as the critique reference. Never regenerate it from scratch.');
153
- }
154
- if (a.optionId === 'canon') {
155
- console.log('CANON CHOSEN: the user picked the category standard on purpose. Ask once for two or three products this should sit alongside; their craft level becomes the quality bar. Execute the canon at full commitment, conventions embraced without irony or smuggled quirk.');
156
- }
157
- if (a.optionId === 'reroll' && a.register) {
158
- console.log(`REGISTER: the user steered the next hand to the ${a.register} register. Re-run concept-seed with the same key, the next --reroll round, and --register ${a.register}, then follow what it prints; the register is the user's steering, never yours to pre-select.`);
159
- }
160
- if (a.followup && a.optionId !== 'reroll') {
161
- console.log('FOLLOWUP OPEN: the table stays open and the page is showing a loading hand. Deliver the next round now with --update --key <key> --payload <file>, then collect it with --wait; never leave the page waiting on a round you have not sent.');
162
- }
163
- if (a.buildPath === 'comp' || a.buildPath === 'code') {
164
- // The page never writes the flip itself, but "never write it" overstated
165
- // that into a rule the agent then applied to new-work's one-time offer,
166
- // which exists for exactly this case: a flip on a project that had no
167
- // recorded default is the only moment the preference is ever asked for.
168
- const origin = a.buildPathFlipped
169
- ? 'flipped on the page, so it binds this session only, and the page never writes it back; the sole exception is new-work’s one-time offer, on a project that had no recorded default at all, which asks after the round closes and writes the answer to .impeccable/config.json'
170
- : 'the round’s recorded default';
171
- console.log(`BUILD PATH: ${a.buildPath} (${origin}). ${a.buildPath === 'comp'
172
- ? 'Comp-led: the chosen card’s comp is law; generate it before building when it does not exist yet, and the finish review audits the build against it.'
173
- : 'Code-led: no comp is owed; a comp that already rendered rides at the finish review as the critique reference, and the ambition lives in the direction contract.'}`);
174
- }
175
- } catch { /* raw answer */ }
176
- }
177
-
178
- const payloadPath = arg('payload');
179
- const timeoutSec = Number(arg('timeout', '900'));
180
- const portArg = Number(arg('port', '0'));
181
- const QUESTION_DIR = path.join(process.cwd(), '.impeccable', 'questions');
182
- const stateFile = (key) => path.join(QUESTION_DIR, `${key}.state.json`);
183
- const answerFile = (key) => path.join(QUESTION_DIR, `${key}.answer.json`);
184
- // A code-to-comp flip mid-round: the page records it here and --wait
185
- // surfaces it as its own event, because the agent must start generating
186
- // comps while the round is still open. Comp-to-code needs no event; it is
187
- // free and rides the final ANSWER.
188
- const flipFile = (key) => path.join(QUESTION_DIR, `${key}.flip.json`);
189
-
190
- if (hasFlag('schema')) {
191
- console.log(JSON.stringify({
192
- title: 'Choose the visual world',
193
- question: 'The roll assigned Fillmore Handbill. Keep it, take an alternate, or re-roll.',
194
- options: [
195
- { id: 'assigned', label: 'Fillmore Handbill', kicker: 'THE ROLL', lineage: '1966-71 Fillmore psychedelic handbills', thesis: 'The gig poster that treats every release like a one-night stand.', palette: ['#e8452c', '#f5d64c', '#1b2a52', '#f3ead8'], materials: ['letterpress', 'split-fountain ink'], viewport: 'A full-bleed dated bill with the product name in warped display type.', risk: 'Reads nostalgic when the type is set timidly.', raised: [{ from: 'challenger-microfiche', raise: 'The bill now owns its whole viewport as one continuous printed sheet.' }], comp: '.impeccable/mocks/decision/assigned.webp', hero: 'https://impeccable.style/worlds/cards/posters-covers-sleeves-fillmore-handbill-hero.webp', board: 'https://impeccable.style/worlds/cards/posters-covers-sleeves-fillmore-handbill.webp' },
196
- { id: 'model-pick', label: 'The Broadside Ballad', kicker: 'IMPECCABLE’S PICK', lineage: 'street-sold ballad sheets', thesis: 'Every release printed as the day’s ballad sheet.', palette: ['#1f1c18', '#efe5d0', '#a33327'], materials: ['woodcut', 'rag paper'], viewport: 'One tall sheet, the newest release as today’s ballad.', risk: 'Also the direction most runs in this category land on.', comp: '.impeccable/mocks/decision/model-pick.webp' },
197
- { id: 'challenger-teletext', label: 'Teletext Service', verdict: 'competitive', lineage: 'broadcast teletext magazines', thesis: 'The catalog as a broadcast index: pages, not sections.', palette: ['#0000c0', '#ffff00', '#00c000', '#ffffff'], materials: ['block mosaic', 'phosphor glow'], viewport: 'P100 index page, releases as numbered rows.', case: 'Fuses cleanly: releases map to numbered pages; loses narrowly on clarity.', risk: 'Reads retro-novelty when the grid is not strict.', comp: '.impeccable/mocks/decision/challenger-teletext.webp', hero: 'https://impeccable.style/worlds/cards/broadcast-programming-teletext-service-hero.webp' },
198
- { id: 'challenger-microfiche', label: 'Microfiche Reader', verdict: 'declined', lineage: 'library microfiche stations', palette: ['#101418', '#9fb4c0'], materials: ['film grain', 'backlit glass'], case: 'Fuses poorly: listeners do not identify with archival retrieval.', kept: 'Total environmental commitment.', hero: 'https://impeccable.style/worlds/cards/archives-microfiche-reader-hero.webp' },
199
- ],
200
- reroll: { registers: ['safer', 'bolder'] },
201
- buildPath: { value: 'comp', toggle: true },
202
- canon: true,
203
- canonCard: { label: 'The category standard', thesis: 'What this category ships, executed impeccably.', palette: ['#ffffff', '#111827', '#2563eb'], materials: ['clean grid', 'product photography'], viewport: 'The arrangement a visitor expects, at full craft.', risk: 'Indistinguishable from the competition by design.', comp: '.impeccable/mocks/decision/canon.webp' },
204
- steer: true,
205
- }, null, 2));
206
- console.log('\nOption ids return verbatim in ANSWER; "reroll" and "canon" are reserved. hero/board/comp accept URLs or local paths; comp slots may point at files that do not exist yet (serve first, generate after; the page polls until they land, so never block serving on generation). hero on a challenger is the inspiration it draws from and renders picture-in-picture beside the comp, never as the promise of the build. verdict routes rendering: "wins" and "competitive" challengers keep full cards, "declined" ones render demoted after them (narrow, quiet, art as a labeled thumb, "Adopt anyway"), with their kept line on the front; the page reorders declined cards to the end on its own. raised on the assigned card renders each donation as a named raise line. Salience parity: when the assigned card declares no comp (no image generation this round), catalog art on every card demotes to a labeled thumb, so what looks important is the verdict’s call, never rendering luck. canonCard renders the standing exit as a subordinate card with the same anatomy; without it, canon stays a quiet footer action. Include canon only for visual-direction rounds; never present it as your own recommendation. The pick card is a kicker convention, not a field: kicker "IMPECCABLE’S PICK" on your top-ranked grounded candidate, one at most, never in the lead slot. Every card gets the full anatomy, challengers, canon, and declined included: thesis, palette, materials, viewport, risk; the seed already hands you each challenger’s system rules, so a card with no palette chips is an authoring gap, not a data gap. Keep thesis and each fact to one short sentence: the card front shows thesis, identity, and a two-line risk, while first viewport and the case read on the card back behind the Details chip, so long facts cost the reader a flip, not the page its scanability. A card with no imagery at all has no back; its full read renders on the front, so a text-only round loses nothing. A card may instead declare "wireframe" ({"cols":12,"rows":10,"regions":[{"label":"nav rail","x":0,"y":0,"w":3,"h":10,"accent":true}]}): the page draws it as a layout schematic in the media slot; surface-scope rounds use it on code-led builds, it never counts toward salience, and the card keeps its full read on the front. The comp slot carries the card’s full-fidelity direction comp (the legacy key "sketch" is accepted as an alias). Comp aspect follows the surface: portrait at device viewport for native or mobile-first surfaces, landscape otherwise; the page adapts its cards to either. reroll accepts true or { "registers": ["safer", "bolder"] }: the register buttons steer the next hand along the familiar-to-bold axis, the answer carries "register", and you re-run concept-seed with --register <value> for the next round; offer the registers on direction rounds, and never pre-select one. buildPath rides the payload as { "value": "comp"|"code", "toggle": true }: the value is the recorded default (.impeccable/config.json buildPath, or .impeccable/config.local.json where one machine differs) and the toggle renders a footer switch whose flip binds that session only; the ANSWER then carries buildPath plus buildPathFlipped. On a code-led round each card still declares its comp path as a flip reserve: wireframes render, and a flip to comp makes --wait return once with BUILD PATH FLIPPED so you generate the comps into the declared slots while the round stays open; a flip back to code is free, and a comp that already landed stays as the critique reference. The toggle may only be offered when image generation exists: a harness with no image tool and no API key never sets toggle: true, so the choice never renders where comps cannot be made, and code-led simply rides as the untoggleable value. followup: true keeps the table open after a pick for a second round via --update; send the next payload immediately, the page is waiting on it.');
207
- process.exit(0);
208
- }
209
-
210
- if (hasFlag('wait')) {
211
- const key = arg('key');
212
- if (!key) { console.error('serve-question: --wait needs --key'); process.exit(1); }
213
- const pollSec = Number(arg('poll', '60'));
214
- const deadline = Date.now() + pollSec * 1000;
215
- const answered = () => fs.existsSync(answerFile(key));
216
- // Liveness must survive sandboxes: a sandboxed --wait cannot signal the
217
- // daemon (kill throws EPERM even for a living process), so a fresh page
218
- // heartbeat in the state file is the primary proof of life, the kill probe
219
- // is secondary, and EPERM specifically means "exists, but the sandbox
220
- // blocks signals", never "dead". Treating EPERM as death told one session
221
- // the user had walked away while they were still reading the board.
222
- const alive = () => {
223
- try {
224
- const state = JSON.parse(fs.readFileSync(stateFile(key), 'utf8'));
225
- if (state.lastBeat && Date.now() - state.lastBeat < 12000) return true;
226
- try { process.kill(state.pid, 0); return true; }
227
- catch (err) { return err.code === 'EPERM'; }
228
- } catch { return false; }
229
- };
230
- let sawClose = false;
231
- while (Date.now() < deadline) {
232
- if (answered()) break;
233
- // A build-path flip is its own event, not an answer: the round stays
234
- // open, and the agent's job right now is comps, not code.
235
- if (fs.existsSync(flipFile(key))) {
236
- try { fs.rmSync(flipFile(key)); } catch { /* consumed elsewhere */ }
237
- console.log('BUILD PATH FLIPPED: comp (for this session only; never write it to settings). The table is still open and the page shows shimmer where the images will land: generate each open card’s comp into its declared path now, lead first, then collect the answer with --wait again. A card whose comp already exists needs nothing.');
238
- process.exit(0);
239
- }
240
- if (!alive()) {
241
- console.log('serve-question: the question server is gone with no answer. This is a server failure, not a user decision: restart it with --start and the same payload, reopen the URL for the user, and wait again. Never proceed without their choice while their browser session is open.');
242
- process.exit(2);
243
- }
244
- try {
245
- const state = JSON.parse(fs.readFileSync(stateFile(key), 'utf8'));
246
- if (state.lastBeat && Date.now() - state.lastBeat > 15000) { sawClose = true; break; }
247
- } catch { /* state mid-write */ }
248
- await new Promise((r) => setTimeout(r, 1000));
249
- }
250
- if (sawClose && !answered()) {
251
- console.log('PAGE CLOSED: the question page went away without an answer; re-present, reopen the URL, or fall back to the structured question tool');
252
- process.exit(4);
253
- }
254
- if (!answered()) { console.log(`WAITING: no answer yet after ${pollSec}s; run --wait --key ${key} again`); process.exit(3); }
255
- const collected = fs.readFileSync(answerFile(key), 'utf8').trim();
256
- printAnswer(collected);
257
- // A re-roll or a followup-round pick keeps the table open: the server stays
258
- // alive awaiting --update, so only the answer file is consumed. Terminal
259
- // choices clean up fully.
260
- let keepsTableOpen = false;
261
- try {
262
- const parsedAnswer = JSON.parse(collected);
263
- keepsTableOpen = parsedAnswer.optionId === 'reroll' || parsedAnswer.followup === true;
264
- } catch { /* treat as terminal */ }
265
- try { fs.rmSync(answerFile(key)); } catch { /* already gone */ }
266
- if (!keepsTableOpen) { try { fs.rmSync(stateFile(key)); } catch { /* already gone */ } }
267
- process.exit(0);
268
- }
269
-
270
- if (hasFlag('stop')) {
271
- const key = arg('key');
272
- if (!key) { console.error('serve-question: --stop needs --key'); process.exit(1); }
273
- try { process.kill(JSON.parse(fs.readFileSync(stateFile(key), 'utf8')).pid); } catch { /* dead already */ }
274
- try { fs.rmSync(answerFile(key)); } catch {}
275
- try { fs.rmSync(stateFile(key)); } catch {}
276
- console.log('stopped');
277
- process.exit(0);
278
- }
279
-
280
- if (hasFlag('update')) {
281
- const key = arg('key');
282
- if (!key || !payloadPath) { console.error('serve-question: --update needs --key and --payload'); process.exit(1); }
283
- JSON.parse(fs.readFileSync(payloadPath, 'utf8'));
284
- try { process.kill(JSON.parse(fs.readFileSync(stateFile(key), 'utf8')).pid, 0); }
285
- catch { console.error('serve-question: no live question server for that key'); process.exit(2); }
286
- fs.copyFileSync(payloadPath, path.join(QUESTION_DIR, `${key}.next.json`));
287
- console.log('next round delivered; the page reloads itself');
288
- process.exit(0);
289
- }
290
-
291
- if (hasFlag('start')) {
292
- if (!payloadPath) { console.error('serve-question: --start needs --payload <file>'); process.exit(1); }
293
- JSON.parse(fs.readFileSync(payloadPath, 'utf8'));
294
- fs.mkdirSync(QUESTION_DIR, { recursive: true });
295
- const key = arg('key') || Math.random().toString(16).slice(2, 10);
296
- // In start mode the agent is alive and owns browser routing; the server
297
- // only opens the system browser itself when --open forces it.
298
- // The daemon's output lands in a per-key log so a startup failure can say
299
- // what actually went wrong instead of only that it did.
300
- const logFile = path.join(QUESTION_DIR, `${key}.log`);
301
- const logFd = fs.openSync(logFile, 'a');
302
- const child = spawn(process.execPath, [
303
- fileURLToPath(import.meta.url), '--payload', payloadPath, '--detached-serve', '--key', key,
304
- '--timeout', String(timeoutSec), ...(hasFlag('open') ? [] : ['--no-open']),
305
- ], { detached: true, stdio: ['ignore', logFd, logFd] });
306
- child.unref();
307
- fs.closeSync(logFd);
308
- const deadline = Date.now() + 8000;
309
- while (Date.now() < deadline && !fs.existsSync(stateFile(key))) await new Promise((r) => setTimeout(r, 100));
310
- if (!fs.existsSync(stateFile(key))) {
311
- let tail = '';
312
- try { tail = fs.readFileSync(logFile, 'utf8').trim().split('\n').slice(-4).join('\n '); } catch { /* log never written */ }
313
- console.error(`serve-question: server failed to start${tail ? `\n ${tail}` : ''}`);
314
- console.error(`serve-question: log at ${path.relative(process.cwd(), logFile) || logFile}. A sandboxed exec that cannot listen on localhost causes exactly this; rerun this command once through the harness's network-enabled or unsandboxed command tool before falling back.`);
315
- process.exit(1);
316
- }
317
- const state = JSON.parse(fs.readFileSync(stateFile(key), 'utf8'));
318
- console.log(`QUESTION URL: ${state.url}`);
319
- console.log(`QUESTION KEY: ${key}`);
320
- console.log('Open the URL for the user now: in-app browser when the harness has one, otherwise the system opener (macOS `open`, Linux `xdg-open`), otherwise show the URL.');
321
- console.log(`Then collect the answer with: node ${fileURLToPath(import.meta.url)} --wait --key ${key}`);
322
- process.exit(0);
323
- }
324
-
325
- let raw;
326
- if (payloadPath) raw = fs.readFileSync(payloadPath, 'utf8');
327
- else raw = fs.readFileSync(0, 'utf8');
328
-
329
- // Round state is mutable: a re-roll keeps this server alive and --update
330
- // swaps in the next hand, so payload, options, and the local-image table
331
- // rebuild per round.
332
- let payload;
333
- let options;
334
- let localImages = [];
335
- // Build path (comp-led vs code-led): the payload carries the recorded
336
- // default; the page's toggle updates the live value per session. The server
337
- // owns both so the final ANSWER states the path and whether it was flipped
338
- // even when the round never rendered a toggle.
339
- let buildPathDefault = null;
340
- let liveBuildPath = null;
341
-
342
- function loadRound(json) {
343
- const parsed = JSON.parse(json);
344
- if (!parsed || !Array.isArray(parsed.options) || parsed.options.length === 0) {
345
- throw new Error('payload needs an options array');
346
- }
347
- localImages = [];
348
- const imageSrc = (value) => {
349
- if (!value) return null;
350
- if (/^https?:\/\//.test(value)) return value;
351
- const abs = path.resolve(value);
352
- if (!fs.existsSync(abs)) return null;
353
- localImages.push(abs);
354
- return `/img/${localImages.length - 1}`;
355
- };
356
- // Comps stream in after the page is served, so their slots register
357
- // whether or not the file exists yet; /img answers 404 until it lands and
358
- // the page polls the slot. Remote comp URLs pass through untouched.
359
- const compSrc = (value) => {
360
- if (!value) return null;
361
- if (/^https?:\/\//.test(value)) return value;
362
- localImages.push(path.resolve(value));
363
- return `/img/${localImages.length - 1}`;
364
- };
365
- payload = parsed;
366
- const decorate = (option) => ({
367
- ...option,
368
- heroSrc: imageSrc(option.hero),
369
- boardSrc: imageSrc(option.board),
370
- compSrc: compSrc(option.comp ?? option.sketch),
371
- });
372
- options = parsed.options.map(decorate);
373
- // The verdict routes rendering: full cards first, then the canon, then the
374
- // declined cards dead last in their own payload order. The reorder happens
375
- // here so a payload that interleaves them still renders the weighing's
376
- // shape, and the deck reads as a gradient of standing: contenders, the
377
- // familiar door, then the demoted row.
378
- const declined = options.filter((o) => o.verdict === 'declined');
379
- options = options.filter((o) => o.verdict !== 'declined');
380
- // The standing exit as a full card: same anatomy, reserved id, rendered
381
- // subordinate by the page. Without it, canon stays the quiet footer action.
382
- if (parsed.canonCard && typeof parsed.canonCard === 'object') {
383
- options = [...options, { ...decorate(parsed.canonCard), id: 'canon', isCanon: true }];
384
- }
385
- options = [...options, ...declined];
386
- buildPathDefault = (parsed.buildPath && (parsed.buildPath.value === 'comp' || parsed.buildPath.value === 'code'))
387
- ? { value: parsed.buildPath.value, toggle: parsed.buildPath.toggle === true }
388
- : null;
389
- liveBuildPath = buildPathDefault?.value ?? null;
390
- }
391
- try { loadRound(raw); } catch (error) { console.error(`serve-question: ${error.message}`); process.exit(1); }
392
- const detachedKey = hasFlag('detached-serve') ? arg('key') : null;
393
- const nextFile = () => detachedKey ? path.join(QUESTION_DIR, `${detachedKey}.next.json`) : null;
394
-
395
- const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
396
-
397
- function page() {
398
- const flipChip = (label) => `<button type="button" class="chip flip" aria-label="Flip the card"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4a8 8 0 1 1-8 8" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M4 5.5V12h6.5" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg><span>${label}</span></button>`;
399
- const expandChip = `<button type="button" class="chip expand" aria-label="Expand the image"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 15v5h-5M20 9V4h-5M4 15v5h5" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`;
400
- // Structured anatomy: chips and one-line facts render when the payload
401
- // carries them; a plain body falls back to the prose block. Palette chips
402
- // and material tags give a text-only direction an immediate identity that
403
- // no generation luck can distort.
404
- const fact = (label, value, cls = '') => value ? `<p class="fact${cls ? ` ${cls}` : ''}"><span class="fact-label">${label}</span>${esc(value)}</p>` : '';
405
- const demoted = (option) => option.verdict === 'declined';
406
- // The build path (comp-led vs code-led) is a workflow preference, not a
407
- // design decision: the payload carries the recorded default and whether
408
- // the page offers the toggle. On a code-led round a declared comp path is
409
- // a flip reserve, not a face: wireframes render, and the slot only starts
410
- // shimmering when the user flips to comp.
411
- const buildPath = buildPathDefault;
412
- const codeLed = buildPath?.value === 'code';
413
- // Salience parity: a card's imagery weight is capped by the assigned card's.
414
- // When the lead card has no media at all (no image generation this round,
415
- // and no catalog art of its own), full-bleed catalog art beside a text-only
416
- // assigned card would let rendering luck outvote the weighing: users click
417
- // the colorful thing. Declined cards are thumb-only regardless; the verdict
418
- // demoted them, and a full-bleed hero would promote them right back.
419
- const identityRound = !(options[0] && (options[0].compSrc || options[0].heroSrc || options[0].boardSrc));
420
- // A declined card never renders a full media face, comp included: even a
421
- // declared comp would buy back the salience the verdict took away.
422
- const faceComp = (option) => (demoted(option) || codeLed) ? null : option.compSrc;
423
- const thumbOnly = (option) => !faceComp(option) && Boolean(option.heroSrc || option.boardSrc) && (demoted(option) || identityRound);
424
- const hasMedia = (option) => Boolean(faceComp(option) || ((option.heroSrc || option.boardSrc) && !thumbOnly(option)));
425
- // The back exists to keep long facts off a card whose front is an image;
426
- // a card with no art has no flip chip to reach it, so it gets no back and
427
- // the full read lives on the front instead.
428
- const hasBack = (option) => hasMedia(option) && Boolean(option.viewport || option.case || (option.boardSrc && option.heroSrc));
429
- const anatomy = (option) => {
430
- const rows = [];
431
- if (option.thesis) rows.push(`<p class="thesis">${esc(option.thesis)}</p>`);
432
- const idBits = [];
433
- if (Array.isArray(option.palette) && option.palette.length) {
434
- idBits.push(`<span class="swatches">${option.palette.slice(0, 6).map((c) => `<i style="background:${esc(c)}" title="${esc(c)}"></i>`).join('')}</span>`);
435
- }
436
- if (Array.isArray(option.materials) && option.materials.length) {
437
- idBits.push(option.materials.slice(0, 4).map((m) => `<span class="tag">${esc(m)}</span>`).join(''));
438
- }
439
- if (idBits.length) rows.push(`<div class="identity">${idBits.join('')}</div>`);
440
- // Donations from declined challengers render as named raise lines: the
441
- // assigned card arrives already raised by the hand it beat, and the raise
442
- // is readable, because a raise nobody can read did not happen. One raise
443
- // renders inline; several become a compact cycler (click advances), so a
444
- // generous hand cannot blow the card out of proportion.
445
- if (Array.isArray(option.raised) && option.raised.length) {
446
- const nameOf = (id) => options.find((o) => o.id === id)?.label || String(id ?? '');
447
- const raiseLines = option.raised.slice(0, 6).map((r) => `<p class="raise"><span class="fact-label">From ${esc(nameOf(r.from))}</span>${esc(r.raise || r.kept || '')}</p>`);
448
- const raisesHead = (count) => `<div class="raises-head"><span class="fact-label">Improved by Impeccable's worlds</span>${count > 1 ? `<span class="raises-count" data-raises-count>1/${count}</span>` : ''}</div>`;
449
- if (raiseLines.length > 1) {
450
- rows.push(`<div class="raises raises-cycle" role="button" tabindex="0" title="Click or press Enter for the next improvement" aria-label="How Impeccable's worlds improved this direction; activate to see the next improvement">
451
- ${raisesHead(raiseLines.length)}
452
- ${raiseLines.join('')}
453
- <span class="sr-live" aria-live="polite"></span>
454
- </div>`);
455
- } else {
456
- rows.push(`<div class="raises">${raisesHead(1)}${raiseLines[0]}</div>`);
457
- }
458
- }
459
- // Demoted art stays reachable as a labeled thumb: the catalog world
460
- // explains where the direction comes from without buying it back the
461
- // salience the verdict took away.
462
- if (thumbOnly(option)) {
463
- rows.push(`<figure class="inspo" title="Inspiration: the world this direction draws from. Your page will not look like this image."><img src="${esc(option.heroSrc || option.boardSrc)}" alt=""><figcaption>inspired by</figcaption></figure>`);
464
- }
465
- // The front carries only what the choice needs: thesis, identity, and the
466
- // honest risk clamped to two lines. First viewport and the case read on
467
- // the card's back; once the comp lands, the first viewport is a picture.
468
- // With no art there is no back, so the full read fills the room the
469
- // image would have taken.
470
- if (hasMedia(option)) {
471
- rows.push(fact('Risk', option.risk, 'clamp'));
472
- } else {
473
- rows.push(fact('First viewport', option.viewport));
474
- rows.push(fact('The case', option.case));
475
- rows.push(fact('Kept', option.kept));
476
- rows.push(fact('Risk', option.risk));
477
- }
478
- if (!option.thesis && option.body) rows.push(`<p class="detail">${esc(option.body)}</p>`);
479
- else if (option.body && option.thesis && !hasBack(option)) rows.push(`<p class="detail more">${esc(option.body)}</p>`);
480
- return rows.join('\n ');
481
- };
482
- const backFacts = (option) => [
483
- fact('First viewport', option.viewport),
484
- fact('The case', option.case),
485
- fact('Kept', option.kept),
486
- fact('Risk', option.risk),
487
- option.body && option.thesis ? `<p class="detail more">${esc(option.body)}</p>` : '',
488
- ].filter(Boolean).join('\n ');
489
- const media = (option) => {
490
- const inspirationSrc = option.heroSrc || option.boardSrc;
491
- const inspiration = inspirationSrc ? `<figure class="pip" title="Inspiration: the world this direction draws from. Your page will not look like this image.">
492
- <img src="${esc(inspirationSrc)}" alt="">
493
- <figcaption>inspiration</figcaption>
494
- </figure>` : '';
495
- const details = hasBack(option) ? flipChip('Details') : '';
496
- // Thumb-only art renders inside the body via anatomy(), never as a face,
497
- // and a declined card's comp slot is ignored outright.
498
- if (thumbOnly(option)) return '';
499
- if (faceComp(option)) {
500
- const textOnlyFacts = backFacts(option);
501
- return `<div class="media comp-pending" data-comp="${esc(option.compSrc)}">
502
- <div class="shimmer"><span class="comp-note">rendering&hellip;</span></div>
503
- <img class="comp" alt="" hidden>
504
- ${inspiration}
505
- <template class="text-only-facts">${textOnlyFacts}</template>
506
- <div class="chips">${expandChip}${details}</div>
507
- </div>`;
508
- }
509
- if (option.heroSrc || option.boardSrc) {
510
- // Without a comp the catalog art is the card's face; it stays a
511
- // labeled reference so it never reads as the promise of the build.
512
- return `<div class="media" title="Inspiration: the world this direction draws from. Your page will not look like this image.">
513
- <img src="${esc(option.heroSrc || option.boardSrc)}" alt="">
514
- <p class="media-label">inspiration</p>
515
- <div class="chips">${expandChip}${details}</div>
516
- </div>`;
517
- }
518
- return '';
519
- };
520
- // Wireframe media: a code-led card's layout schematic, authored as grid
521
- // regions in the payload and drawn by the page; boxes and labels, no art.
522
- // It fills the media slot only when the card has no imagery, and it never
523
- // counts toward salience or earns a card back: the full read stays on the
524
- // front, exactly like a text-only card.
525
- const wire = (option) => {
526
- const frame = option.wireframe;
527
- if (!frame || !Array.isArray(frame.regions) || !frame.regions.length || media(option) || demoted(option)) return '';
528
- const cols = Number(frame.cols) > 0 ? Number(frame.cols) : 12;
529
- const rows = Number(frame.rows) > 0 ? Number(frame.rows) : 10;
530
- const pct = (n, total) => `${Math.max(0, Math.min(100, (n / total) * 100)).toFixed(2)}%`;
531
- const cells = frame.regions.slice(0, 12).map((region) => {
532
- const x = Number(region.x) || 0;
533
- const y = Number(region.y) || 0;
534
- const w = Math.max(Number(region.w) || 1, 0.5);
535
- const h = Math.max(Number(region.h) || 1, 0.5);
536
- return `<div class="wire-region${region.accent ? ' accent' : ''}" style="left:${pct(x, cols)};top:${pct(y, rows)};width:${pct(w, cols)};height:${pct(h, rows)}"><span>${esc(region.label || '')}</span></div>`;
537
- }).join('');
538
- return `<div class="media wire" role="img" aria-label="Layout schematic">
539
- <div class="wire-field">${cells}</div>
540
- <p class="media-label">layout</p>
541
- </div>`;
542
- };
543
- const chooseLabel = (option) => option.isCanon ? 'Play it straight' : demoted(option) ? 'Adopt anyway' : 'Build this';
544
- const cards = options.map((option, index) => `
545
- <article class="card${option.isCanon ? ' canon' : ''}${demoted(option) ? ' declined' : ''}" style="--fan:${index === 0 ? '0deg' : (index % 2 ? '1.4deg' : '-1.2deg')};--deal:${index * 90}ms" data-id="${esc(option.id)}"${codeLed && option.compSrc && !demoted(option) ? ` data-comp-slot="${esc(option.compSrc)}"` : ''}>
546
- <div class="card-inner">
547
- <div class="face front${index === 0 ? ' lead' : ''}${(media(option) || wire(option)) ? '' : ' text-only'}">
548
- ${option.kicker ? `<span class="kicker">${esc(option.kicker)}</span>` : demoted(option) ? '<span class="kicker declined-k">Declined</span>' : option.isCanon ? '<span class="kicker standing">The standing door</span>' : ''}
549
- ${media(option) || wire(option)}
550
- <div class="body">
551
- ${option.lineage ? `<p class="tier">${esc(option.lineage)}</p>` : ''}
552
- <h2>${esc(option.label)}</h2>
553
- ${anatomy(option)}
554
- <button class="choose" data-id="${esc(option.id)}">${chooseLabel(option)}</button>
555
- </div>
556
- </div>
557
- ${hasBack(option) ? `<div class="face back${index === 0 ? ' lead' : ''}">
558
- ${option.boardSrc ? `<div class="media back-media">
559
- <img src="${esc(option.boardSrc)}" alt="">
560
- <div class="chips">${expandChip}${flipChip('Front')}</div>
561
- </div>` : `<div class="back-head"><p class="tier">The full read &middot; ${esc(option.label)}</p>${flipChip('Front')}</div>`}
562
- <div class="body back-body">
563
- ${option.boardSrc ? `<p class="tier">The full read &middot; ${esc(option.label)}</p>` : ''}
564
- ${backFacts(option)}
565
- <button class="choose" data-id="${esc(option.id)}">${chooseLabel(option)}</button>
566
- </div>
567
- </div>` : ''}
568
- </div>
569
- </article>`).join('\n');
570
- return `<!doctype html>
571
- <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
572
- <title>${esc(payload.title || 'impeccable · decision')}</title>
573
- <link rel="preconnect" href="https://fonts.googleapis.com">
574
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
575
- <link href="https://fonts.googleapis.com/css2?family=Albert+Sans:wght@400;500;600&family=Alumni+Sans:wght@100;400&display=swap" rel="stylesheet">
576
- <style>
577
- /* Neo kinpaku tokens, mirrored from impeccable.style kinpaku-tokens.css */
578
- :root {
579
- color-scheme: dark;
580
- --ks-kinpaku: oklch(84% 0.19 80.46);
581
- --ks-kinpaku-pale: oklch(86% 0.07 84);
582
- --ks-kinpaku-rich: oklch(77% 0.13 82);
583
- --ks-kinpaku-deep: oklch(61% 0.085 78);
584
- --ks-dark-ink: oklch(14% 0.018 95);
585
- --ks-patina: oklch(70% 0.12 188);
586
- --ks-lacquer: oklch(7% 0.006 95);
587
- --ks-lacquer-raised: oklch(11% 0.006 95);
588
- --ks-graphite: oklch(15% 0.008 95);
589
- --ks-graphite-2: oklch(19% 0.008 95);
590
- --ks-champagne: oklch(91% 0 0);
591
- --ks-text: oklch(88% 0 0);
592
- --ks-text-muted: oklch(72% 0 0);
593
- --ks-text-faint: oklch(62% 0 0);
594
- --ks-rule: oklch(78% 0 0 / 0.16);
595
- --ks-font-display: "Alumni Sans", "Albert Sans", Arial, sans-serif;
596
- --ks-font: "Albert Sans", "Avenir Next", "Helvetica Neue", Arial, system-ui, sans-serif;
597
- --ks-mono: "SFMono-Regular", "Roboto Mono", "JetBrains Mono", Consolas, monospace;
598
- /* One inset shared by the content column, the deck's snap padding, and
599
- the sticky footer, so all three align on the same 90rem column. */
600
- --page-inset: max(clamp(1rem, 5vw, 4rem), calc((100vw - 90rem) / 2));
601
- }
602
- * { box-sizing: border-box; margin: 0; }
603
- body { background: var(--ks-lacquer); color: var(--ks-text); font: 15px/1.55 var(--ks-font); padding: 1.8rem clamp(1rem, 5vw, 4rem) 0; min-height: 100dvh; display: flex; flex-direction: column; overflow-x: clip; }
604
- #ambient { position: fixed; inset: -40px; z-index: 0; background-size: cover; background-position: center; filter: blur(34px) saturate(1.05); opacity: 0; transition: opacity .55s ease, background-image .2s; pointer-events: none; }
605
- #scrim { position: fixed; inset: 0; z-index: 0; background: linear-gradient(180deg, oklch(7% 0.006 95 / 0.62), oklch(7% 0.006 95 / 0.78)); pointer-events: none; }
606
- header, main, footer { position: relative; z-index: 1; }
607
- #lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: oklch(4% 0.004 95 / 0.93); cursor: zoom-out; opacity: 0; transition: opacity .25s ease; }
608
- #lightbox[hidden] { display: none; }
609
- #lightbox.open { opacity: 1; }
610
- #lightbox img { max-width: 94vw; max-height: 94vh; border: 1px solid var(--ks-rule); border-radius: 8px; box-shadow: 0 30px 80px oklch(0% 0 0 / 0.6); }
611
- header { width: 100%; max-width: 90rem; margin: 0 auto; }
612
- .brand { display: flex; align-items: center; gap: .55rem; color: var(--ks-kinpaku); }
613
- .brand svg { width: 22px; height: 22px; }
614
- .wordmark { font-family: var(--ks-font-display); font-weight: 400; font-size: 1.125rem; letter-spacing: 0.15em; text-transform: uppercase; line-height: 1; color: var(--ks-kinpaku); }
615
- .headline { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
616
- .headline-die { flex: none; width: 34px; height: 34px; color: var(--ks-kinpaku); }
617
- h1 { font-family: var(--ks-font-display); font-weight: 100; font-size: clamp(2.6rem, 5vw, 4.2rem); letter-spacing: -0.01em; line-height: 1.02; color: var(--ks-champagne); }
618
- .question { color: var(--ks-text-muted); margin-top: .7rem; max-width: 52rem; }
619
- main { flex: 1; display: flex; align-items: center; width: 100%; max-width: 90rem; margin: 0 auto; }
620
- .stage { width: 100%; display: flex; flex-direction: column; gap: 1.5rem; }
621
- /* The deck bleeds to the viewport edges while the first card aligns with the
622
- content column; a carousel cut off at an invisible container edge reads as
623
- a rendering bug, but one cut off at the screen edge reads as more cards. */
624
- .deck-shell { position: relative; width: 100vw; margin-left: calc(50% - 50vw); }
625
- /* One row in a wide viewport, one column in a tall one; the deck scrolls on
626
- its axis with snap points and the arrows page it card by card. */
627
- .grid { --deck-inset: var(--page-inset); display: flex; gap: 1.6rem; width: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 6px var(--deck-inset); scroll-padding-inline: var(--deck-inset); align-items: stretch; }
628
- .grid::-webkit-scrollbar { display: none; }
629
- /* Wide enough that the comp carries the card: at 27vw the imagery read
630
- as a thumbnail above a column of copy, and the copy won the attention
631
- contest the comp is supposed to win. */
632
- .grid > .card { flex: 0 0 clamp(24rem, 34vw, 34rem); scroll-snap-align: center; }
633
- /* Short landscape viewports (13-inch laptops): header, a 34vw card, and the
634
- footer do not fit 800px of height, so the headline compacts and the deck
635
- narrows. Height is the axis that gives; the sticky footer keeps the
636
- round's verbs on screen while a too-tall card scrolls. */
637
- @media (min-aspect-ratio: 1/1) and (max-height: 900px) {
638
- body { padding-top: 1.1rem; }
639
- h1 { font-size: clamp(2rem, 3.4vw, 2.9rem); }
640
- .question { margin-top: .45rem; }
641
- .stage { gap: 1rem; }
642
- .grid > .card { flex-basis: clamp(20rem, 27vw, 27rem); }
643
- .grid > .card.declined { flex-basis: clamp(13rem, 18vw, 18rem); }
644
- }
645
- .nav { position: absolute; z-index: 6; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: oklch(7% 0.006 95 / 0.78); border: 1px solid var(--ks-rule); color: var(--ks-kinpaku); cursor: pointer; backdrop-filter: blur(6px); transition: border-color .2s, color .2s, opacity .2s; }
646
- .nav:hover { border-color: var(--ks-kinpaku-deep); color: var(--ks-kinpaku-pale); }
647
- .nav[disabled] { opacity: .25; cursor: default; }
648
- .nav[hidden] { display: none; }
649
- .nav svg { width: 16px; height: 16px; }
650
- .nav.prev { left: 14px; top: 50%; transform: translateY(-50%); }
651
- .nav.next { right: 14px; top: 50%; transform: translateY(-50%); }
652
- /* A side that hides more cards fades out; a hard edge means the end. */
653
- .fade { position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
654
- .fade-prev { left: 0; top: 0; bottom: 0; width: 88px; background: linear-gradient(90deg, var(--ks-lacquer), transparent); }
655
- .fade-next { right: 0; top: 0; bottom: 0; width: 88px; background: linear-gradient(270deg, var(--ks-lacquer), transparent); }
656
- .deck-shell.can-prev .fade-prev { opacity: 1; }
657
- .deck-shell.can-next .fade-next { opacity: 1; }
658
- @media (max-aspect-ratio: 1/1) {
659
- .grid { flex-direction: column; overflow-x: hidden; overflow-y: auto; scroll-snap-type: y mandatory; max-height: min(68dvh, 44rem); scroll-padding-block: 6px; }
660
- .grid > .card { flex: 0 0 auto; }
661
- /* In the vertical deck the pager is the primary way forward, so it grows
662
- into a labeled pill instead of a bare chevron nobody notices. */
663
- .nav { width: auto; height: 38px; border-radius: 19px; padding: 0 16px; gap: 8px; border-color: var(--ks-kinpaku-deep); background: oklch(7% 0.006 95 / 0.88); font-family: var(--ks-mono); font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; }
664
- .nav svg { transform: rotate(90deg); }
665
- .nav.prev::after { content: "Back"; }
666
- .nav.next::after { content: "More"; }
667
- .nav.prev { left: 50%; top: 6px; transform: translate(-50%, 0); }
668
- .nav.next { right: auto; left: 50%; top: auto; bottom: 6px; transform: translate(-50%, 0); }
669
- .fade-prev { top: 0; left: 0; right: 0; bottom: auto; width: auto; height: 72px; background: linear-gradient(180deg, var(--ks-lacquer), transparent); }
670
- .fade-next { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 72px; background: linear-gradient(0deg, var(--ks-lacquer), transparent); }
671
- /* In the vertical deck the cross axis is horizontal: flex-start would
672
- shrink a declined card to content WIDTH, not height, so it stretches
673
- like every other card and its height is already its own. */
674
- .grid > .card.declined { align-self: stretch; }
675
- /* The sticky bar is a wide-viewport fix. Here it would sit over the
676
- deck's More pager and cost a third of a phone screen, and the deck
677
- already scrolls internally, so the footer stays in the page flow. */
678
- footer { position: static; width: auto; margin: 1rem 0 0; padding: .7rem 0 1.2rem; background: transparent; border-top: 0; backdrop-filter: none; }
679
- }
680
- .card { position: relative; perspective: 1400px; transform: rotate(var(--fan, 0deg)); transition: transform .25s cubic-bezier(.16, 1, .3, 1); }
681
- .card:hover { transform: rotate(0deg) translateY(-4px); }
682
- .card-inner { position: relative; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.16, 1, .3, 1); }
683
- .card.flipped .card-inner { transform: rotateY(180deg); }
684
- .face { background: var(--ks-lacquer-raised); border: 1px solid var(--ks-rule); border-radius: 10px; box-shadow: 0 18px 40px oklch(0% 0 0 / 0.35); overflow: hidden; display: flex; flex-direction: column; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
685
- .face.front { position: relative; height: 100%; }
686
- .face.back { position: absolute; inset: 0; transform: rotateY(180deg); }
687
- /* Only the visible face is interactive: a hidden backface still hit-tests
688
- in Chrome, so the front's pip would otherwise sit invisibly over the
689
- back's chips, showing its zoom cursor and eating the flip-back click. */
690
- .face.back { pointer-events: none; }
691
- .card.flipped .face.back { pointer-events: auto; }
692
- .card.flipped .face.front { pointer-events: none; }
693
- .face.lead { border-color: var(--ks-kinpaku); box-shadow: 0 0 0 1px var(--ks-kinpaku), 0 18px 40px oklch(0% 0 0 / 0.45); }
694
- .card:hover .face { border-color: var(--ks-kinpaku-deep); }
695
- .card:hover .face.lead { border-color: var(--ks-kinpaku); }
696
- @media (prefers-reduced-motion: reduce) { .card-inner { transition: none; } }
697
- .kicker { position: absolute; z-index: 2; top: 12px; left: 12px; padding: 4px 10px; background: var(--ks-kinpaku); color: var(--ks-dark-ink); font-family: var(--ks-mono); font-size: .625rem; letter-spacing: .24em; text-transform: uppercase; border-radius: 4px; }
698
- /* Text-only card: a grounded direction with no rendered card drops the media
699
- region entirely instead of reserving a blank 16:9 void. */
700
- .face.text-only .kicker { position: static; align-self: flex-start; margin: 14px 0 0 14px; }
701
- .face.text-only .body { padding-top: 12px; }
702
- /* 16/10 matches the landscape comp frame; portrait art overrides the
703
- slot with its own exact ratio at load (see the load listener), and the
704
- deck narrows so portrait cards line up side by side. */
705
- .media { position: relative; width: 100%; aspect-ratio: 16/10; flex: none; }
706
- .grid.portrait-media > .card { flex-basis: clamp(14rem, 19vw, 19rem); }
707
- .media img { width: 100%; height: 100%; object-fit: cover; display: block; background: linear-gradient(100deg, var(--ks-graphite) 40%, var(--ks-graphite-2) 50%, var(--ks-graphite) 60%); }
708
- .media > img:not([hidden]) { cursor: zoom-in; }
709
- .face.back { background: var(--ks-lacquer-raised); }
710
- .back-bar { margin-top: auto; background: var(--ks-lacquer-raised); }
711
- .hero-blank { width: 100%; height: 100%; background: linear-gradient(100deg, var(--ks-graphite) 40%, var(--ks-graphite-2) 50%, var(--ks-graphite) 60%); }
712
- .back-bar { flex: none; flex-direction: row; align-items: center; justify-content: space-between; gap: .8rem; }
713
- .chips { position: absolute; z-index: 1; right: 10px; bottom: 10px; display: flex; gap: 6px; }
714
- .chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; font-family: var(--ks-mono); font-size: .625rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ks-text); background: oklch(7% 0.006 95 / 0.72); border: 1px solid var(--ks-rule); border-radius: 5px; cursor: pointer; backdrop-filter: blur(4px); transition: color .2s, border-color .2s; }
715
- .chip:hover { color: var(--ks-kinpaku); border-color: var(--ks-kinpaku-deep); }
716
- .chip svg { width: 12px; height: 12px; }
717
- .body { padding: .95rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
718
- .tier { font-family: var(--ks-mono); font-size: .625rem; letter-spacing: .24em; text-transform: uppercase; color: var(--ks-text-faint); }
719
- h2 { font-family: var(--ks-font); font-size: 1.125rem; font-weight: 500; line-height: 1.35; color: var(--ks-champagne); }
720
- .detail { color: var(--ks-text-muted); font-size: .88rem; white-space: pre-wrap; }
721
- .detail.more { font-size: .8rem; color: var(--ks-text-faint); }
722
- .thesis { color: var(--ks-text); font-size: .95rem; line-height: 1.45; }
723
- .identity { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
724
- .swatches { display: inline-flex; gap: 4px; margin-right: 4px; }
725
- .swatches i { width: 18px; height: 18px; border-radius: 5px; border: 1px solid oklch(100% 0 0 / 0.18); box-shadow: inset 0 0 0 1px oklch(0% 0 0 / 0.25); }
726
- .tag { font-family: var(--ks-mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ks-text-muted); border: 1px solid var(--ks-rule); border-radius: 4px; padding: 3px 7px; }
727
- .fact { font-size: .8rem; color: var(--ks-text-muted); line-height: 1.45; }
728
- .fact-label { display: inline-block; font-family: var(--ks-mono); font-size: .6rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ks-text-faint); margin-right: .55em; transform: translateY(-1px); }
729
- .fact.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
730
- /* The back is the full read: first viewport, the case, the whole risk, and
731
- the board when the world has one. */
732
- .back-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 14px 14px 0; }
733
- .media.back-media { aspect-ratio: 16/6; }
734
- .media.back-media img { width: 100%; height: 100%; object-fit: cover; }
735
- .body.back-body { overflow-y: auto; flex: 1; scrollbar-width: thin; }
736
- /* Inspiration rides picture-in-picture: the catalog world explains where the
737
- direction comes from without promising what the build will look like. */
738
- /* Hovering the inspiration takes over the whole media region; the comp is
739
- the promise, the inspiration is a glance, so the glance must cost nothing. */
740
- .pip { position: absolute; z-index: 2; left: 10px; bottom: 10px; margin: 0; width: 84px; height: 64px; border: 1px solid var(--ks-rule); border-radius: 6px; overflow: hidden; background: var(--ks-lacquer); cursor: zoom-in; transition: left .35s cubic-bezier(.16,1,.3,1), bottom .35s cubic-bezier(.16,1,.3,1), width .35s cubic-bezier(.16,1,.3,1), height .35s cubic-bezier(.16,1,.3,1), border-radius .35s ease; box-shadow: 0 6px 18px oklch(0% 0 0 / 0.45); }
741
- .pip img { display: block; width: 100%; height: 100%; object-fit: cover; }
742
- .pip figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-family: var(--ks-mono); font-size: .5rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ks-text); text-align: center; padding: 3px 0 4px; background: oklch(7% 0.006 95 / 0.72); backdrop-filter: blur(3px); }
743
- .pip:hover { left: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; z-index: 3; }
744
- .comp-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--ks-mono); font-size: .66rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ks-text-faint); }
745
- /* Catalog art standing in for a comp-less card is a reference, and says so
746
- on its face; the same pill later carries "artwork unavailable". */
747
- .media-label { position: absolute; z-index: 2; left: 10px; bottom: 10px; margin: 0; font-family: var(--ks-mono); font-size: .5rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ks-text); padding: 3px 8px 4px; background: oklch(7% 0.006 95 / 0.72); border: 1px solid var(--ks-rule); border-radius: 4px; backdrop-filter: blur(3px); }
748
- /* Art that never arrives collapses to the card's own palette (painted
749
- inline from its swatches) instead of sitting as a dark void wearing a
750
- zoom cursor; the scrim keeps the label legible over saturated fields,
751
- passes clicks through, and the flip chips stay above it. A card with no
752
- palette falls back to the quiet graphite field. */
753
- .media.unavailable { background: linear-gradient(100deg, var(--ks-graphite) 40%, var(--ks-graphite-2) 50%, var(--ks-graphite) 60%); }
754
- .media.unavailable::after { content: ""; position: absolute; inset: 0; z-index: 1; background: oklch(10% 0.008 95 / 0.45); pointer-events: none; }
755
- .media.unavailable .chips { z-index: 2; }
756
- /* A stand-in is honest about being one: dimmed, labeled, and replaced by
757
- the real comp whenever it lands. */
758
- .media.stand-in img.comp { filter: brightness(.72) saturate(.85); }
759
- .media.stand-in .pip { display: none; }
760
- .stand-in-label { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; margin: 0; font-family: var(--ks-mono); font-size: .56rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ks-text); text-align: center; padding: 4px 0 5px; background: oklch(7% 0.006 95 / 0.78); backdrop-filter: blur(3px); }
761
- .media.comp-pending { position: relative; }
762
- .media.comp-pending .shimmer { position: absolute; inset: 0; }
763
- .media img.comp { position: relative; z-index: 1; }
764
- /* The generic .media img display:block would defeat [hidden] and float an
765
- empty block over the shimmer; an unloaded comp must truly not render. */
766
- .media img[hidden] { display: none; }
767
- /* Declined challengers: the weighing demoted them, so the card is narrower
768
- and quieter, its catalog art rides as a labeled thumb in the body, and
769
- the action reads "Adopt anyway". Adoptable, never deleted: the demoted
770
- row is the hand's proof of judgment. */
771
- /* Narrow AND short: without align-self the stretch default drags a thin
772
- declined card to the tallest contender's height, a strange stilt of a
773
- card beside the full hand. */
774
- .grid > .card.declined { flex: 0 0 clamp(15rem, 21vw, 21rem); align-self: flex-start; }
775
- .card.declined .face { background: var(--ks-graphite); }
776
- .card.declined:hover .face { border-color: var(--ks-text-faint); }
777
- .card.declined h2 { font-size: 1rem; color: var(--ks-text); }
778
- .kicker.declined-k { background: transparent; border: 1px solid var(--ks-rule); color: var(--ks-text-faint); }
779
- .card.declined button.choose { background: transparent; color: var(--ks-text-muted); border: 1px solid var(--ks-rule); font-size: .85rem; padding: 8px 22px; }
780
- .card.declined button.choose:hover { background: var(--ks-graphite-2); border-color: var(--ks-text-muted); }
781
- /* Wireframe media: the code-led schematic. Quiet boxes in the card's own
782
- chrome; uniform salience across cards by construction, so it needs no
783
- parity rules. */
784
- .media.wire { background: var(--ks-lacquer); border-bottom: 1px solid var(--ks-rule); }
785
- .wire-field { position: absolute; inset: 12px 12px 26px; }
786
- .wire-region { position: absolute; border: 1px solid oklch(78% 0 0 / 0.26); border-radius: 3px; background: oklch(78% 0 0 / 0.05); display: flex; align-items: center; justify-content: center; overflow: hidden; }
787
- .wire-region span { font-family: var(--ks-mono); font-size: .55rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ks-text-faint); text-align: center; padding: 2px 4px; }
788
- .wire-region.accent { border-color: oklch(84% 0.19 80.46 / 0.5); background: oklch(84% 0.19 80.46 / 0.06); }
789
- .wire-region.accent span { color: var(--ks-kinpaku-rich); }
790
- /* Thumb-scale inspiration: present, labeled, zoomable, and incapable of
791
- outshouting a text-only assigned card. */
792
- .inspo { position: relative; flex: none; margin: 2px 0; width: 104px; height: 64px; border: 1px solid var(--ks-rule); border-radius: 6px; overflow: hidden; cursor: zoom-in; background: var(--ks-lacquer); }
793
- .inspo img { display: block; width: 100%; height: 100%; object-fit: cover; }
794
- .inspo figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-family: var(--ks-mono); font-size: .48rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ks-text); text-align: center; padding: 2px 0 3px; background: oklch(7% 0.006 95 / 0.72); }
795
- /* Raises: the improvements the dealt worlds donated to the assigned
796
- direction, each named for its donor world. Patina, not kinpaku:
797
- provenance, not a call to action. A quiet contained panel, never an
798
- accent side-tab. */
799
- .raises { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; padding: 7px 10px 8px; background: oklch(70% 0.12 188 / 0.06); border: 1px solid oklch(70% 0.12 188 / 0.22); border-radius: 8px; }
800
- .raise { font-size: .78rem; color: var(--ks-text-muted); line-height: 1.45; }
801
- .raise .fact-label { color: var(--ks-patina); }
802
- /* Several kept ideas cycle instead of stacking: one visible at a time, a
803
- counter for the rest, the whole block advances on click. */
804
- .raises-cycle { cursor: pointer; transition: border-color .2s ease; }
805
- .raises-cycle:hover { border-color: oklch(70% 0.12 188 / 0.45); }
806
- .raises-cycle .raise { display: none; }
807
- .raises-cycle .raise.active { display: block; }
808
- .raises-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
809
- .raises-head .fact-label { color: var(--ks-patina); }
810
- .raises-count { font-family: var(--ks-mono); font-size: .58rem; letter-spacing: .14em; color: var(--ks-text-faint); }
811
- .raises-count::after { content: " \\203A"; }
812
- .raises-cycle:hover .raises-count { color: var(--ks-patina); }
813
- .sr-live { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
814
- /* The standing exit as a card: present with full anatomy, never dressed as a
815
- contender. Graphite instead of kinpaku, and it never takes the lead ring. */
816
- .card.canon .face { border-color: var(--ks-rule); background: var(--ks-graphite); }
817
- .card.canon:hover .face { border-color: var(--ks-text-faint); }
818
- .card.canon .kicker.standing { background: transparent; border: 1px solid var(--ks-rule); color: var(--ks-text-faint); }
819
- .card.canon button.choose { background: transparent; color: var(--ks-text); border: 1px solid var(--ks-rule); }
820
- .card.canon button.choose:hover { border-color: var(--ks-text-muted); background: var(--ks-graphite-2); }
821
- button.choose { margin-top: auto; align-self: start; background: var(--ks-kinpaku); color: var(--ks-dark-ink); border: 0; font-family: var(--ks-font); font-size: 1rem; font-weight: 500; line-height: 1.35; padding: 10px 38px; border-radius: 6px; cursor: pointer; transition: background .15s; }
822
- button.choose:hover { background: var(--ks-kinpaku-pale); }
823
- /* The round's verbs stay reachable on short viewports: the footer is a
824
- full-bleed bar stuck to the viewport bottom and the deck scrolls under
825
- it. Same inset as the content column, so the controls stay aligned. */
826
- footer { position: sticky; bottom: 0; z-index: 10; width: 100vw; margin: 1.2rem calc(50% - 50vw) 0; padding: .7rem var(--page-inset) calc(.7rem + env(safe-area-inset-bottom, 0px)); display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; background: oklch(7% 0.006 95 / 0.82); backdrop-filter: blur(10px); border-top: 1px solid var(--ks-rule); }
827
- #steer { flex: 1; min-width: 16rem; background: var(--ks-lacquer-raised); color: var(--ks-text); border: 1px solid var(--ks-rule); border-radius: 7px; padding: .6rem .85rem; font: inherit; }
828
- #steer:focus { outline: none; border-color: var(--ks-patina); }
829
- /* Build-path toggle: a workflow preference surfaced as a quiet segmented
830
- control on the headline row, right-aligned opposite the title, its trade stated in
831
- one line that changes with the selection. The default comes from the
832
- payload (settings); flipping binds this session only, and the agent
833
- learns about a code-to-comp flip live. Rendered only when the payload
834
- offers it, which the agent does only when image generation exists. */
835
- #build-path { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; margin-left: auto; }
836
- .bp-switch { display: inline-flex; border: 1px solid var(--ks-rule); border-radius: 6px; overflow: hidden; }
837
- .bp-note { text-align: right; }
838
- .bp-opt { font-family: var(--ks-mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; padding: 7px 12px; background: transparent; border: 0; color: var(--ks-text-faint); cursor: pointer; transition: color .2s ease, background-color .2s ease; }
839
- .bp-opt + .bp-opt { border-left: 1px solid var(--ks-rule); }
840
- .bp-opt.active { color: var(--ks-dark-ink); background: var(--ks-kinpaku-rich); }
841
- .bp-opt:not(.active):hover { color: var(--ks-text); }
842
- .bp-note { font-family: var(--ks-mono); font-size: .58rem; letter-spacing: .04em; color: var(--ks-text-faint); max-width: 21rem; line-height: 1.5; }
843
- /* Flipping to comp starts billed, minutes-long generation, so it asks
844
- first; flipping back is free and never does. */
845
- #bp-confirm { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: oklch(4% 0.004 95 / 0.72); opacity: 0; transition: opacity .2s ease; }
846
- #bp-confirm[hidden] { display: none; }
847
- #bp-confirm.open { opacity: 1; }
848
- .bp-confirm-panel { max-width: 26rem; margin: 1rem; background: var(--ks-lacquer-raised); border: 1px solid var(--ks-rule); border-radius: 10px; padding: 1.4rem 1.5rem 1.3rem; box-shadow: 0 30px 80px oklch(0% 0 0 / 0.55); }
849
- .bp-confirm-panel h2 { font-family: var(--ks-font); font-size: 1.125rem; font-weight: 500; color: var(--ks-champagne); margin-bottom: .55rem; }
850
- .bp-confirm-panel p { font-size: .875rem; line-height: 1.55; color: var(--ks-text-muted); }
851
- .bp-confirm-actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
852
- .bp-confirm-go { background: var(--ks-kinpaku); color: var(--ks-dark-ink); border: 0; font: inherit; font-weight: 500; padding: 9px 22px; border-radius: 6px; cursor: pointer; }
853
- .bp-confirm-go:hover { background: var(--ks-kinpaku-pale); }
854
- .bp-confirm-stay { background: transparent; color: var(--ks-text-muted); border: 1px solid var(--ks-rule); font: inherit; padding: 9px 18px; border-radius: 6px; cursor: pointer; }
855
- .bp-confirm-stay:hover { color: var(--ks-text); border-color: var(--ks-text-faint); }
856
- .reroll-btn { display: inline-flex; align-items: center; align-self: stretch; gap: 8px; padding: 0 16px; font-family: var(--ks-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ks-kinpaku); background: transparent; border: 1px solid var(--ks-rule); border-radius: 6px; cursor: pointer; transition: border-color .2s ease, color .2s ease; }
857
- .reroll-btn:hover { color: var(--ks-kinpaku-pale); border-color: var(--ks-kinpaku-deep); }
858
- .reroll-btn svg { width: 15px; height: 15px; }
859
- .reroll-btn[disabled] { opacity: .4; cursor: default; }
860
- /* The register steers read quieter than the plain roll: they are exits from
861
- the current register, not the round's main verbs. */
862
- #reroll-safer, #reroll-bolder { color: var(--ks-text-muted); min-height: 38px; }
863
- #reroll-safer:hover, #reroll-bolder:hover { color: var(--ks-text); border-color: var(--ks-text-faint); }
864
- /* The quiet exit: always available, never argued with, visually subordinate
865
- to the dealt cards and the re-roll so it reads as the user's own door,
866
- not a recommendation. */
867
- #canon { align-self: center; padding: 0 4px; font-family: var(--ks-mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; color: inherit; opacity: .45; background: transparent; border: none; border-bottom: 1px dotted currentColor; cursor: pointer; transition: opacity .2s ease; }
868
- #canon:hover { opacity: .85; }
869
- .card.skeleton .media { background: var(--ks-graphite); }
870
- .shimmer { width: 100%; height: 100%; background: linear-gradient(100deg, var(--ks-graphite) 35%, var(--ks-graphite-2) 50%, var(--ks-graphite) 65%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
871
- .card.skeleton .line { height: 11px; border-radius: 4px; background: linear-gradient(100deg, var(--ks-graphite) 35%, var(--ks-graphite-2) 50%, var(--ks-graphite) 65%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
872
- .card.skeleton .line.tier { height: 8px; }
873
- .card.skeleton .line.title { height: 17px; border-radius: 5px; }
874
- .card.skeleton .line.button { height: 38px; width: 128px; border-radius: 6px; margin-top: auto; }
875
- .card.skeleton .w40 { width: 40%; } .card.skeleton .w70 { width: 70%; } .card.skeleton .w90 { width: 90%; } .card.skeleton .w80 { width: 80%; } .card.skeleton .w60 { width: 60%; }
876
- .card.skeleton .body { flex: 1; }
877
- @keyframes shimmer { from { background-position: 120% 0; } to { background-position: -80% 0; } }
878
- @media (prefers-reduced-motion: reduce) { .shimmer, .card.skeleton .line { animation: none; } }
879
- .done { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 7rem 1rem; font-family: var(--ks-font-display); font-size: 1.4rem; color: var(--ks-champagne); text-align: center; }
880
- </style>
881
- <div id="ambient" aria-hidden="true"></div>
882
- <div id="scrim" aria-hidden="true"></div>
883
- <div id="lightbox" hidden><img alt=""></div>
884
- <template id="tpl-expand-chip">${expandChip}</template>
885
- ${buildPath?.toggle ? `<div id="bp-confirm" role="dialog" aria-modal="true" aria-labelledby="bp-confirm-title" hidden>
886
- <div class="bp-confirm-panel">
887
- <h2 id="bp-confirm-title">Flip to comp-first?</h2>
888
- <p>The agent starts rendering a comp for every open card right away, about a minute or two per card on your image provider, and the images land on the cards as they finish. This flip binds this session only.</p>
889
- <div class="bp-confirm-actions">
890
- <button type="button" class="bp-confirm-go" data-confirm>Render comps</button>
891
- <button type="button" class="bp-confirm-stay" data-cancel>Keep code-first</button>
892
- </div>
893
- </div>
894
- </div>` : ''}
895
- <header>
896
- <div class="brand">
897
- <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M5 2.5 L13.5 2.5 L5.5 21.5 L5 21.5 Q2.5 21.5 2.5 19 L2.5 5 Q2.5 2.5 5 2.5 Z"/><path d="M16.5 2.5 L19 2.5 Q21.5 2.5 21.5 5 L21.5 19 Q21.5 21.5 19 21.5 L8.5 21.5 Z"/></svg>
898
- <span class="wordmark">Impeccable</span>
899
- </div>
900
- </header>
901
- <main>
902
- <div class="stage">
903
- <div class="headline">
904
- <svg class="headline-die" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="4" fill="none" stroke="currentColor" stroke-width="1.6"/><circle cx="8.4" cy="8.4" r="1.5" fill="currentColor"/><circle cx="15.6" cy="8.4" r="1.5" fill="currentColor"/><circle cx="8.4" cy="15.6" r="1.5" fill="currentColor"/><circle cx="15.6" cy="15.6" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/></svg>
905
- <h1>${esc(payload.title || 'Choose a direction')}</h1>
906
- ${buildPath?.toggle ? `<div id="build-path" data-default="${buildPath.value}">
907
- <div class="bp-switch" role="radiogroup" aria-label="Build path">
908
- <button type="button" class="bp-opt" data-bp="comp" role="radio" aria-checked="false">Comp first</button>
909
- <button type="button" class="bp-opt" data-bp="code" role="radio" aria-checked="false">Code first</button>
910
- </div>
911
- <p class="bp-note" data-bp-note></p>
912
- </div>` : ''}
913
- </div>
914
- ${payload.question ? `<p class="question">${esc(payload.question)}</p>` : ''}
915
- <div class="deck-shell">
916
- <div class="grid">${cards}</div>
917
- <div class="fade fade-prev" aria-hidden="true"></div>
918
- <div class="fade fade-next" aria-hidden="true"></div>
919
- <button class="nav prev" hidden aria-label="Previous card"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.5 5 8 12l6.5 7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
920
- <button class="nav next" hidden aria-label="Next card"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9.5 5 16 12l-6.5 7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
921
- </div>
922
- </div>
923
- </main>
924
- <footer>
925
- ${payload.steer ? '<input id="steer" placeholder="Optional steer: what should be different or kept?">' : ''}
926
- ${(() => {
927
- if (!payload.reroll) return '';
928
- const die = '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="4" fill="none" stroke="currentColor" stroke-width="1.6"/><circle cx="8.4" cy="8.4" r="1.5" fill="currentColor"/><circle cx="15.6" cy="8.4" r="1.5" fill="currentColor"/><circle cx="8.4" cy="15.6" r="1.5" fill="currentColor"/><circle cx="15.6" cy="15.6" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/></svg>';
929
- const registers = Array.isArray(payload.reroll.registers) ? payload.reroll.registers.filter((r) => r === 'safer' || r === 'bolder') : [];
930
- // The registers are the user's steering wheel on the familiar-to-bold
931
- // axis; the plain re-roll sits between them so the spatial order matches
932
- // the axis it names.
933
- const safer = registers.includes('safer') ? '<button class="reroll-btn" id="reroll-safer" title="Deal the familiar register: conventional grounded directions plus the category standard against named competitors"><span>&larr; Safer hand</span></button>' : '';
934
- const bolder = registers.includes('bolder') ? '<button class="reroll-btn" id="reroll-bolder" title="Deal foreign forms only, at full commitment"><span>Bolder hand &rarr;</span></button>' : '';
935
- return `${safer}<button class="reroll-btn" id="reroll">${die}<span>Re-roll</span></button>${bolder}`;
936
- })()}
937
- ${payload.canon && !payload.canonCard ? '<button id="canon" title="Skip the roll: build the page this category ships, executed impeccably">Play it straight</button>' : ''}
938
- </footer>
939
- <script>
940
- const steer = () => document.getElementById('steer')?.value || '';
941
- // A followup round's pick keeps the tab: the next round arrives via
942
- // --update, so the page shows the loading hand instead of goodbye. Detached
943
- // mode only, and the page must agree with the server: a blocking server
944
- // exits on any pick and has no update channel, so a followup payload there
945
- // still gets the goodbye screen, never a loading hand nothing will resolve.
946
- const FOLLOWUP = ${payload.followup === true && Boolean(detachedKey) ? 'true' : 'false'};
947
- const beat = () => { try { navigator.sendBeacon('/heartbeat'); } catch { fetch('/heartbeat', { method: 'POST' }); } };
948
- beat();
949
- setInterval(beat, 5000);
950
- async function answer(optionId) {
951
- await fetch('/answer', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ optionId, steer: steer() }) });
952
- if (FOLLOWUP) { await awaitNextRound(); return; }
953
- document.body.innerHTML = '<div class="done"><svg viewBox="0 0 24 24" width="38" height="38" fill="oklch(84% 0.19 80.46)" aria-hidden="true"><path d="M5 2.5 L13.5 2.5 L5.5 21.5 L5 21.5 Q2.5 21.5 2.5 19 L2.5 5 Q2.5 2.5 5 2.5 Z"/><path d="M16.5 2.5 L19 2.5 Q21.5 2.5 21.5 5 L21.5 19 Q21.5 21.5 19 21.5 L8.5 21.5 Z"/></svg>Choice recorded. The agent is resuming; you can close this tab.</div>';
954
- }
955
- document.querySelectorAll('button.choose').forEach(b => b.addEventListener('click', () => answer(b.dataset.id)));
956
- document.querySelectorAll('.flip').forEach(b => b.addEventListener('click', (e) => {
957
- e.stopPropagation();
958
- b.closest('.card').classList.toggle('flipped');
959
- }));
960
-
961
- // Raise cycler: click (or Enter) advances to the next donation.
962
- document.querySelectorAll('.raises-cycle').forEach(cycle => {
963
- const raises = [...cycle.querySelectorAll('.raise')];
964
- const count = cycle.querySelector('[data-raises-count]');
965
- let at = 0;
966
- const live = cycle.querySelector('.sr-live');
967
- const show = (announce) => {
968
- raises.forEach((raise, i) => raise.classList.toggle('active', i === at));
969
- if (count) count.textContent = (at + 1) + '/' + raises.length;
970
- // Screen readers hear the raise they just advanced to; the initial
971
- // render stays quiet so page load does not narrate every card.
972
- if (announce && live) live.textContent = 'Improvement ' + (at + 1) + ' of ' + raises.length + ': ' + (raises[at]?.textContent || '');
973
- };
974
- show(false);
975
- const advance = (e) => { e.stopPropagation(); at = (at + 1) % raises.length; show(true); };
976
- cycle.addEventListener('click', advance);
977
- cycle.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); advance(e); } });
978
- });
979
-
980
- // Deal from the stack: cards begin piled at the grid's center, blurred,
981
- // then travel to their seats with a stagger.
982
- const cards = [...document.querySelectorAll('.card')];
983
- // The deal is decoration: a hidden tab throttles rAF, so never let the
984
- // animation hold the cards at opacity 0. Skip it when hidden, and force
985
- // the final state after a beat no matter what the animation did.
986
- setTimeout(() => cards.forEach(c => { c.style.opacity = ''; c.style.transform = ''; c.style.filter = ''; c.style.transition = ''; c.style.zIndex = ''; }), 1600);
987
- if (!matchMedia('(prefers-reduced-motion: reduce)').matches && cards.length && !document.hidden) {
988
- const grid = document.querySelector('.grid').getBoundingClientRect();
989
- const cx = grid.left + grid.width / 2, cy = grid.top + grid.height / 2;
990
- cards.forEach((card, i) => {
991
- const r = card.getBoundingClientRect();
992
- const dx = cx - (r.left + r.width / 2), dy = cy - (r.top + r.height / 2);
993
- card.style.transition = 'none';
994
- card.style.transform = 'translate(' + dx + 'px,' + (dy + 14) + 'px) rotate(' + (i % 2 ? 5 : -4) + 'deg) scale(.9)';
995
- card.style.opacity = '0';
996
- card.style.filter = 'blur(10px)';
997
- card.style.zIndex = String(cards.length - i);
998
- });
999
- requestAnimationFrame(() => requestAnimationFrame(() => {
1000
- cards.forEach((card, i) => {
1001
- const delay = i * 110;
1002
- card.style.transition = 'transform .7s cubic-bezier(.16,1,.3,1) ' + delay + 'ms, opacity .45s ease ' + delay + 'ms, filter .55s ease ' + delay + 'ms';
1003
- card.style.transform = ''; card.style.opacity = '1'; card.style.filter = '';
1004
- card.addEventListener('transitionend', function done(e) {
1005
- if (e.propertyName !== 'transform') return;
1006
- card.style.transition = ''; card.style.opacity = ''; card.style.zIndex = '';
1007
- card.removeEventListener('transitionend', done);
1008
- });
1009
- });
1010
- }));
1011
- }
1012
-
1013
- // Comps stream in after the deal: poll each slot until the file lands,
1014
- // then swap the shimmer for the image. Generation is genuinely slow and a
1015
- // sequential batch puts the last card many minutes out, so patience is the
1016
- // default: a slot only shows its inspiration as a stand-in when it has
1017
- // waited four minutes AND nothing has landed anywhere for four minutes, the
1018
- // stand-in is labeled as such, and polling continues so the real comp
1019
- // still swaps in whenever it arrives. Progress anywhere resets patience.
1020
- const landTracker = { last: Date.now() };
1021
- const pollComp = (m) => {
1022
- const url = m.dataset.comp;
1023
- // A converted slot is the SAME node across flip cycles, so a probe from an
1024
- // earlier cycle can still be in flight when the next one starts. Without a
1025
- // generation stamp its late onload settles the new slot: shimmer stripped,
1026
- // pending state cleared, comp still hidden, live poll stopped.
1027
- const generation = String(Number(m.dataset.pollGen || 0));
1028
- const current = () => String(Number(m.dataset.pollGen || 0)) === generation;
1029
- const img = m.querySelector('img.comp');
1030
- const note = m.querySelector('.comp-note');
1031
- const started = Date.now();
1032
- // A live elapsed count is the difference between "working" and "frozen".
1033
- const tick = setInterval(() => { if (note) note.textContent = 'rendering · ' + Math.round((Date.now() - started) / 1000) + 's'; }, 1000);
1034
- const settle = () => { clearInterval(tick); m.classList.remove('comp-pending', 'stand-in'); m.querySelector('.shimmer')?.remove(); m.querySelector('.stand-in-label')?.remove(); };
1035
- const fallback = () => {
1036
- const pip = m.querySelector('.pip img');
1037
- if (pip) {
1038
- if (m.classList.contains('stand-in')) return false;
1039
- img.src = pip.getAttribute('src'); img.hidden = false;
1040
- m.classList.add('stand-in');
1041
- m.querySelector('.shimmer')?.remove();
1042
- clearInterval(tick);
1043
- const label = document.createElement('p');
1044
- label.className = 'stand-in-label';
1045
- label.textContent = 'inspiration · comp pending';
1046
- m.appendChild(label);
1047
- return false;
1048
- }
1049
-
1050
- // No comp and no inspiration is the text-only card the payload would
1051
- // have rendered without a comp declaration. Bring the complete read
1052
- // forward before removing the now-unreachable back face.
1053
- const card = m.closest('.card');
1054
- const front = card?.querySelector('.face.front');
1055
- const body = front?.querySelector('.body');
1056
- const back = card?.querySelector('.face.back');
1057
- const textOnlyFacts = m.querySelector('template.text-only-facts');
1058
- const choose = body?.querySelector(':scope > button.choose');
1059
- if (body && textOnlyFacts && choose) {
1060
- const plainDetail = body.querySelector(':scope > .detail:not(.more)');
1061
- [...body.children].filter((el) => el.classList.contains('fact') || el.matches('.detail.more')).forEach((el) => el.remove());
1062
- choose.before(textOnlyFacts.content.cloneNode(true));
1063
- if (plainDetail) choose.before(plainDetail);
1064
- }
1065
- card?.classList.remove('flipped');
1066
- front?.classList.add('text-only');
1067
- back?.remove();
1068
- settle();
1069
- m.remove();
1070
- return true;
1071
- };
1072
- const tryLoad = () => {
1073
- // A slot the user flipped back out of either leaves the DOM or, when it
1074
- // was an inspiration face converted in place, stays and loses its
1075
- // pending state. Either way its loop is done.
1076
- if (!m.isConnected || !m.classList.contains('comp-pending') || !current()) { clearInterval(tick); return; }
1077
- const probe = new Image();
1078
- probe.onload = () => {
1079
- // A stale generation also ends this run's clock. tryLoad clears it on
1080
- // re-entry, and an in-flight probe that finishes stale schedules no
1081
- // re-entry, so returning without clearing ran the interval for the rest
1082
- // of the page's life.
1083
- if (!current()) { clearInterval(tick); return; }
1084
- landTracker.last = Date.now();
1085
- const target = m.querySelector('img.comp') || img;
1086
- target.src = probe.src;
1087
- target.hidden = false;
1088
- settle();
1089
- };
1090
- probe.onerror = () => {
1091
- if (!current()) { clearInterval(tick); return; }
1092
- const quiet = Date.now() - landTracker.last > 240000;
1093
- if (Date.now() - started > 240000 && quiet && fallback()) return;
1094
- setTimeout(tryLoad, m.classList.contains('stand-in') ? 5000 : 2500);
1095
- };
1096
- probe.src = url + (url.includes('?') ? '&' : '?') + 't=' + Date.now();
1097
- };
1098
- tryLoad();
1099
- };
1100
- document.querySelectorAll('.media.comp-pending').forEach(pollComp);
1101
-
1102
- // Build-path toggle: the default is the round's recorded preference and
1103
- // flipping binds this session only. Flipping code to comp swaps every
1104
- // reserve slot (data-comp-slot) to its shimmer and tells the server, so
1105
- // the waiting agent starts generating; flipping back is free: pending
1106
- // slots return to their wireframes, a comp that already landed stays.
1107
- const bp = document.getElementById('build-path');
1108
- if (bp) {
1109
- const notes = {
1110
- comp: 'An image sets the bar first and the build must match it. Bolder composition; comps render before code.',
1111
- code: 'Code builds directly; the ambition is written into the contract and audited at the finish. Leaner, faster.',
1112
- };
1113
- const noteEl = bp.querySelector('[data-bp-note]');
1114
- let current = bp.dataset.default;
1115
- const set = (value) => {
1116
- current = value;
1117
- bp.querySelectorAll('.bp-opt').forEach(b => {
1118
- const on = b.dataset.bp === value;
1119
- b.classList.toggle('active', on);
1120
- b.setAttribute('aria-checked', String(on));
1121
- });
1122
- if (noteEl) noteEl.textContent = notes[value];
1123
- };
1124
- set(current);
1125
- const INSPO_TITLE = 'Inspiration: the world this direction draws from. Your page will not look like this image.';
1126
- // Every media slot carries the expand affordance. A slot built here after
1127
- // the deal used to ship without one, so a comp the user waited minutes for
1128
- // could not be opened.
1129
- const ensureChips = (m) => {
1130
- if (m.querySelector('.chips')) return;
1131
- const tpl = document.getElementById('tpl-expand-chip');
1132
- if (!tpl) return;
1133
- const chips = document.createElement('div');
1134
- chips.className = 'chips';
1135
- chips.appendChild(tpl.content.cloneNode(true));
1136
- m.appendChild(chips);
1137
- };
1138
- const shimmerHtml = '<div class="shimmer"><span class="comp-note">rendering&hellip;</span></div><img class="comp" alt="" hidden>';
1139
- const enterComp = () => {
1140
- document.querySelectorAll('.card[data-comp-slot]').forEach(card => {
1141
- const front = card.querySelector('.face.front');
1142
- if (!front || front.querySelector('.media.comp-pending') || front.querySelector('.media img.comp:not([hidden])')) return;
1143
- // On a code-led card the inspiration IS the face. Comp-first demotes it
1144
- // to the corner, so convert that slot in place rather than inserting a
1145
- // second one: two stacked images say the catalog art and the comp are
1146
- // peers, and the whole point of the corner is that they are not.
1147
- const inspo = front.querySelector('.media:not(.wire):not(.comp-pending)');
1148
- let m;
1149
- if (inspo) {
1150
- m = inspo;
1151
- m.dataset.compRestore = 'inspiration';
1152
- m.dataset.comp = card.dataset.compSlot;
1153
- m.classList.add('comp-pending');
1154
- m.removeAttribute('title');
1155
- m.querySelector('.media-label')?.remove();
1156
- const art = m.querySelector(':scope > img');
1157
- if (art) {
1158
- const pip = document.createElement('figure');
1159
- pip.className = 'pip';
1160
- pip.title = INSPO_TITLE;
1161
- const cap = document.createElement('figcaption');
1162
- cap.textContent = 'inspiration';
1163
- pip.append(art, cap);
1164
- m.appendChild(pip);
1165
- }
1166
- m.insertAdjacentHTML('afterbegin', shimmerHtml);
1167
- } else {
1168
- m = document.createElement('div');
1169
- m.className = 'media comp-pending';
1170
- m.dataset.comp = card.dataset.compSlot;
1171
- m.innerHTML = shimmerHtml;
1172
- const wireEl = front.querySelector('.media.wire');
1173
- if (wireEl) { wireEl.hidden = true; front.insertBefore(m, wireEl); }
1174
- else { front.classList.remove('text-only'); front.insertBefore(m, front.querySelector('.body')); }
1175
- }
1176
- ensureChips(m);
1177
- pollComp(m);
1178
- });
1179
- };
1180
- const exitComp = () => {
1181
- document.querySelectorAll('.card[data-comp-slot]').forEach(card => {
1182
- const front = card.querySelector('.face.front');
1183
- const pending = front?.querySelector('.media.comp-pending');
1184
- if (!pending) return; // landed comps stay; they exist either way
1185
- // A converted slot is restored, not removed: the inspiration goes back
1186
- // to being the face, so flipping back leaves the card as it was dealt.
1187
- if (pending.dataset.compRestore === 'inspiration') {
1188
- // Everything the pending state added has to leave, presentation
1189
- // included: a slot that reached stand-in kept its "inspiration comp
1190
- // pending" label beside a fresh one, and a slot whose art had failed
1191
- // came back still marked unavailable.
1192
- pending.classList.remove('comp-pending', 'stand-in');
1193
- delete pending.dataset.compRestore;
1194
- delete pending.dataset.comp;
1195
- pending.dataset.pollGen = String(Number(pending.dataset.pollGen || 0) + 1);
1196
- pending.querySelector('.shimmer')?.remove();
1197
- pending.querySelector('img.comp')?.remove();
1198
- pending.querySelector('.stand-in-label')?.remove();
1199
- pending.querySelectorAll('.media-label').forEach((el) => el.remove());
1200
- const pip = pending.querySelector('.pip');
1201
- const art = pip?.querySelector('img');
1202
- if (art) pending.insertBefore(art, pending.firstChild);
1203
- pip?.remove();
1204
- // No art means the image failed to load before the flip, so hand the
1205
- // slot back to the same honest treatment rather than calling it art.
1206
- const label = document.createElement('p');
1207
- label.className = 'media-label';
1208
- label.textContent = art ? 'inspiration' : 'artwork unavailable';
1209
- pending.insertBefore(label, pending.querySelector('.chips'));
1210
- if (art) pending.title = INSPO_TITLE; else pending.classList.add('unavailable');
1211
- return;
1212
- }
1213
- pending.remove();
1214
- const wireEl = front.querySelector('.media.wire');
1215
- if (wireEl) wireEl.hidden = false;
1216
- else if (!front.querySelector('.media')) front.classList.add('text-only');
1217
- });
1218
- };
1219
- const apply = (value) => {
1220
- set(value);
1221
- fetch('/build-path', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ value }) });
1222
- if (value === 'comp') enterComp(); else exitComp();
1223
- };
1224
- // Flipping to comp starts real generation, so it confirms first; the
1225
- // flip back is free and applies immediately.
1226
- const confirm = document.getElementById('bp-confirm');
1227
- const closeConfirm = () => { confirm.classList.remove('open'); confirm.hidden = true; };
1228
- confirm.querySelector('[data-confirm]').addEventListener('click', () => { closeConfirm(); apply('comp'); });
1229
- confirm.querySelector('[data-cancel]').addEventListener('click', closeConfirm);
1230
- confirm.addEventListener('click', (e) => { if (e.target === confirm) closeConfirm(); });
1231
- document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !confirm.hidden) closeConfirm(); });
1232
- bp.querySelectorAll('.bp-opt').forEach(b => b.addEventListener('click', () => {
1233
- const value = b.dataset.bp;
1234
- if (value === current) return;
1235
- if (value === 'comp') {
1236
- confirm.hidden = false;
1237
- requestAnimationFrame(() => confirm.classList.add('open'));
1238
- return;
1239
- }
1240
- apply(value);
1241
- }));
1242
- }
1243
-
1244
- // A declared image that never loads (missing catalog asset, offline shell)
1245
- // must not sit as a dark void: the slot collapses to the card's own
1246
- // palette, labeled honestly, and the card competes on its facts. Sketch
1247
- // slots are excluded; their polling owns the wait.
1248
- const artFailed = (img) => {
1249
- const m = img.closest('.media');
1250
- if (!m || m.classList.contains('comp-pending') || m.classList.contains('unavailable')) return;
1251
- m.classList.add('unavailable');
1252
- const colors = [...(img.closest('.card')?.querySelectorAll('.swatches i') || [])].map(i => i.style.background).filter(Boolean);
1253
- if (colors.length) m.style.background = 'linear-gradient(135deg, ' + colors.map((c, i) => c + ' ' + Math.round(i * 100 / colors.length) + '% ' + Math.round((i + 1) * 100 / colors.length) + '%').join(', ') + ')';
1254
- m.querySelector('.media-label')?.remove();
1255
- m.querySelector('.chip.expand')?.remove();
1256
- m.removeAttribute('title');
1257
- img.remove();
1258
- const label = document.createElement('p');
1259
- label.className = 'media-label';
1260
- label.textContent = 'artwork unavailable';
1261
- m.appendChild(label);
1262
- };
1263
- document.querySelectorAll('.media:not(.comp-pending) > img').forEach(img => {
1264
- if (img.complete && img.naturalWidth === 0 && img.getAttribute('src')) artFailed(img);
1265
- else img.addEventListener('error', () => artFailed(img), { once: true });
1266
- });
1267
- // A broken inspiration PIP or thumb just leaves; nothing depends on it.
1268
- document.querySelectorAll('.pip img, .inspo img').forEach(img => {
1269
- const gone = () => img.closest('.pip, .inspo')?.remove();
1270
- if (img.complete && img.naturalWidth === 0) gone();
1271
- else img.addEventListener('error', gone, { once: true });
1272
- });
1273
-
1274
- // Every zoom target resolves in ONE delegated listener, in priority order.
1275
- // Delegation is what lets a slot built by a build-path flip work at all, and
1276
- // a single listener is what keeps the targets from fighting: stopPropagation
1277
- // ends bubbling, not other listeners on the same target, so split across two
1278
- // handlers a click on the corner inspiration opened the inspiration and then
1279
- // the comp overwrote it in the lightbox. Per-element handlers elsewhere (the
1280
- // flip chip, the raise cycler) still stop bubbling before the event lands
1281
- // here, so they keep their own behavior.
1282
- document.addEventListener('click', (e) => {
1283
- const target = e.target;
1284
- if (!target || !target.closest) return;
1285
- // The corner inspiration wins over the slot it sits inside.
1286
- const pip = target.closest('.pip, .inspo');
1287
- if (pip) {
1288
- const art = pip.querySelector('img');
1289
- if (art) openLightbox(art);
1290
- return;
1291
- }
1292
- const chip = target.closest('.chip');
1293
- if (chip) {
1294
- // Only expand zooms. Any other chip owns its click and must not fall
1295
- // through to the media underneath it.
1296
- if (!chip.classList.contains('expand')) return;
1297
- const card = chip.closest('.card');
1298
- const face = card && card.classList.contains('flipped') ? '.face.back' : '.face.front';
1299
- const shown = card && card.querySelector(face + ' .media img:not([hidden])');
1300
- if (shown && shown.getAttribute('src')) openLightbox(shown);
1301
- return;
1302
- }
1303
- // The whole image is the zoom target, not just the chip; the chip stays as
1304
- // the visible affordance.
1305
- const media = target.closest('.media');
1306
- if (!media) return;
1307
- const art = media.querySelector(':scope > img:not([hidden])');
1308
- if (art && art.getAttribute('src')) openLightbox(art);
1309
- });
1310
-
1311
- // Deck paging: arrows appear only when the deck overflows its axis, page
1312
- // one card at a time, and follow the aspect-ratio flip between row and column.
1313
- const deck = document.querySelector('.grid');
1314
- const prevBtn = document.querySelector('.nav.prev');
1315
- const nextBtn = document.querySelector('.nav.next');
1316
- const vertical = () => matchMedia('(max-aspect-ratio: 1/1)').matches;
1317
- function updateNav() {
1318
- if (!deck || !prevBtn) return;
1319
- const shell = deck.closest('.deck-shell');
1320
- const v = vertical();
1321
- const overflow = v ? deck.scrollHeight > deck.clientHeight + 4 : deck.scrollWidth > deck.clientWidth + 4;
1322
- prevBtn.hidden = nextBtn.hidden = !overflow;
1323
- const pos = v ? deck.scrollTop : deck.scrollLeft;
1324
- const max = v ? deck.scrollHeight - deck.clientHeight : deck.scrollWidth - deck.clientWidth;
1325
- const canPrev = overflow && pos > 2;
1326
- const canNext = overflow && pos < max - 2;
1327
- prevBtn.toggleAttribute('disabled', !canPrev);
1328
- nextBtn.toggleAttribute('disabled', !canNext);
1329
- shell?.classList.toggle('can-prev', canPrev);
1330
- shell?.classList.toggle('can-next', canNext);
1331
- }
1332
- function pageDeck(dir) {
1333
- const card = deck.querySelector('.card');
1334
- if (!card) return;
1335
- const r = card.getBoundingClientRect();
1336
- const step = (vertical() ? r.height : r.width) + 26;
1337
- deck.scrollBy(vertical() ? { top: dir * step, behavior: 'smooth' } : { left: dir * step, behavior: 'smooth' });
1338
- }
1339
- prevBtn?.addEventListener('click', () => pageDeck(-1));
1340
- nextBtn?.addEventListener('click', () => pageDeck(1));
1341
- deck?.addEventListener('scroll', updateNav, { passive: true });
1342
- addEventListener('resize', updateNav);
1343
- updateNav();
1344
-
1345
- // Ambient: the hovered card's visible art bleeds into the page ground.
1346
- const ambient = document.getElementById('ambient');
1347
- document.querySelectorAll('.card').forEach(card => {
1348
- card.addEventListener('mouseenter', () => {
1349
- const art = card.querySelector('.face.front .media img:not([hidden])') || card.querySelector('.face.front .pip img') || card.querySelector('.face.front .inspo img');
1350
- if (!art || !art.getAttribute('src')) return;
1351
- ambient.style.backgroundImage = 'url("' + art.getAttribute('src') + '")'; ambient.style.opacity = '1';
1352
- });
1353
- card.addEventListener('mouseleave', () => { ambient.style.opacity = '0'; });
1354
- });
1355
-
1356
- // Expand: lightbox for whichever face is showing.
1357
- const lightbox = document.getElementById('lightbox');
1358
- const lightboxImg = lightbox.querySelector('img');
1359
- // Declared, not assigned to a const, so the delegated handlers above can call
1360
- // it wherever they sit in this file.
1361
- function openLightbox(img) {
1362
- lightboxImg.src = img.getAttribute('src');
1363
- lightbox.hidden = false;
1364
- requestAnimationFrame(() => lightbox.classList.add('open'));
1365
- }
1366
- // Portrait art (native / mobile-first surfaces): the slot takes the
1367
- // image's own ratio so nothing crops, and the whole deck narrows so
1368
- // portrait cards sit side by side. Load events don't bubble; capture.
1369
- document.addEventListener('load', (e) => {
1370
- const img = e.target;
1371
- if (!(img instanceof HTMLImageElement) || !img.matches('.media > img')) return;
1372
- if (img.naturalHeight > img.naturalWidth * 1.05) {
1373
- const m = img.closest('.media');
1374
- m.classList.add('portrait');
1375
- m.style.aspectRatio = img.naturalWidth + ' / ' + img.naturalHeight;
1376
- document.querySelector('.grid')?.classList.add('portrait-media');
1377
- }
1378
- }, true);
1379
- const closeLightbox = () => { lightbox.classList.remove('open'); setTimeout(() => { lightbox.hidden = true; }, 250); };
1380
- lightbox.addEventListener('click', closeLightbox);
1381
- document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !lightbox.hidden) closeLightbox(); });
1382
- document.getElementById('canon')?.addEventListener('click', () => answer('canon'));
1383
- const dealAgain = async (register) => {
1384
- await fetch('/answer', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ optionId: 'reroll', steer: steer(), ...(register ? { register } : {}) }) });
1385
- await awaitNextRound();
1386
- };
1387
- async function awaitNextRound() {
1388
- const grid = document.querySelector('.grid');
1389
- const cardsNow = [...grid.querySelectorAll('.card')];
1390
- const g = grid.getBoundingClientRect();
1391
- const cx = g.left + g.width / 2, cy = g.top + g.height / 2;
1392
- if (!matchMedia('(prefers-reduced-motion: reduce)').matches) {
1393
- cardsNow.forEach((card, i) => {
1394
- const r = card.getBoundingClientRect();
1395
- card.style.transition = 'transform .5s cubic-bezier(.5,0,.75,0) ' + (i * 60) + 'ms, opacity .4s ease ' + (i * 60 + 120) + 'ms, filter .45s ease ' + (i * 60) + 'ms';
1396
- card.style.transform = 'translate(' + (cx - (r.left + r.width / 2)) + 'px,' + (cy - (r.top + r.height / 2) + 14) + 'px) rotate(' + (i % 2 ? 6 : -5) + 'deg) scale(.9)';
1397
- card.style.opacity = '0';
1398
- card.style.filter = 'blur(8px)';
1399
- });
1400
- await new Promise(r => setTimeout(r, 700));
1401
- }
1402
- const cardHeight = cardsNow[0] ? cardsNow[0].getBoundingClientRect().height : 0;
1403
- grid.innerHTML = cardsNow.map(() => '<article class="card skeleton"' + (cardHeight ? ' style="height:' + cardHeight + 'px"' : '') + '><div class="card-inner"><div class="face front"><div class="media"><div class="shimmer"></div></div><div class="body"><div class="line tier w40"></div><div class="line title w70"></div><div class="line w90"></div><div class="line w80"></div><div class="line w60"></div><div class="line button"></div></div></div></div></article>').join('');
1404
- document.querySelectorAll('.reroll-btn').forEach(b => b.setAttribute('disabled', ''));
1405
- const poll = setInterval(async () => {
1406
- try {
1407
- const status = await (await fetch('/next-status')).json();
1408
- if (status.ready) { clearInterval(poll); location.reload(); }
1409
- } catch { /* server briefly busy */ }
1410
- }, 1200);
1411
- }
1412
- document.getElementById('reroll')?.addEventListener('click', () => dealAgain());
1413
- document.getElementById('reroll-safer')?.addEventListener('click', () => dealAgain('safer'));
1414
- document.getElementById('reroll-bolder')?.addEventListener('click', () => dealAgain('bolder'));
1415
- </script>`;
1416
- }
1417
-
1418
- const server = http.createServer((req, res) => {
1419
- if (req.method === 'GET' && req.url === '/') {
1420
- const pending = nextFile();
1421
- if (pending && fs.existsSync(pending)) {
1422
- try { loadRound(fs.readFileSync(pending, 'utf8')); fs.rmSync(pending); } catch { /* keep current round */ }
1423
- }
1424
- res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
1425
- res.end(page());
1426
- return;
1427
- }
1428
- if (req.method === 'POST' && req.url === '/heartbeat') {
1429
- res.writeHead(204); res.end();
1430
- if (detachedKey) {
1431
- const now = Date.now();
1432
- if (!server.lastBeatWrite || now - server.lastBeatWrite > 4000) {
1433
- server.lastBeatWrite = now;
1434
- try {
1435
- const state = JSON.parse(fs.readFileSync(stateFile(detachedKey), 'utf8'));
1436
- state.lastBeat = now;
1437
- fs.writeFileSync(stateFile(detachedKey), JSON.stringify(state));
1438
- } catch { /* state file recreated on next beat */ }
1439
- }
1440
- }
1441
- return;
1442
- }
1443
- if (req.method === 'GET' && req.url === '/next-status') {
1444
- const pending = nextFile();
1445
- res.writeHead(200, { 'content-type': 'application/json' });
1446
- res.end(JSON.stringify({ ready: Boolean(pending && fs.existsSync(pending)) }));
1447
- return;
1448
- }
1449
- const imageMatch = req.method === 'GET' && req.url?.match(/^\/img\/(\d+)(?:\?.*)?$/);
1450
- if (imageMatch) {
1451
- const abs = localImages[Number(imageMatch[1])];
1452
- if (!abs || !fs.existsSync(abs)) { res.writeHead(404); res.end(); return; }
1453
- const type = abs.endsWith('.webp') ? 'image/webp'
1454
- : abs.endsWith('.png') ? 'image/png'
1455
- : abs.endsWith('.svg') ? 'image/svg+xml'
1456
- : abs.endsWith('.gif') ? 'image/gif'
1457
- : 'image/jpeg';
1458
- res.writeHead(200, { 'content-type': type });
1459
- fs.createReadStream(abs).pipe(res);
1460
- return;
1461
- }
1462
- if (req.method === 'POST' && req.url === '/build-path') {
1463
- let body = '';
1464
- req.on('data', (chunk) => { body += chunk; });
1465
- req.on('end', () => {
1466
- res.writeHead(200, { 'content-type': 'application/json' });
1467
- res.end('{"ok":true}');
1468
- let value = null;
1469
- try { value = JSON.parse(body).value; } catch { /* ignore */ }
1470
- if (value !== 'comp' && value !== 'code') return;
1471
- const wasComp = liveBuildPath === 'comp';
1472
- liveBuildPath = value;
1473
- // Only a flip TO comp needs the agent mid-round: comps must start
1474
- // rendering into the declared slots. The reverse is free.
1475
- if (detachedKey && value === 'comp' && !wasComp) {
1476
- fs.mkdirSync(QUESTION_DIR, { recursive: true });
1477
- fs.writeFileSync(flipFile(detachedKey), JSON.stringify({ buildPath: 'comp' }) + '\n');
1478
- }
1479
- });
1480
- return;
1481
- }
1482
- if (req.method === 'POST' && req.url === '/answer') {
1483
- let body = '';
1484
- req.on('data', (chunk) => { body += chunk; });
1485
- req.on('end', () => {
1486
- res.writeHead(200, { 'content-type': 'application/json' });
1487
- res.end('{"ok":true}');
1488
- let parsed = {};
1489
- try { parsed = JSON.parse(body); } catch { /* empty steer */ }
1490
- const chosen = options.find((o) => o.id === parsed.optionId);
1491
- const isReroll = parsed.optionId === 'reroll';
1492
- // A followup round's pick is not terminal: the table stays open for the
1493
- // next round (--update), exactly like a re-roll. Detached mode only;
1494
- // the blocking mode has no update channel, so its picks stay terminal.
1495
- const followupOpen = Boolean(detachedKey) && payload.followup === true && !isReroll;
1496
- const answer = JSON.stringify({
1497
- optionId: parsed.optionId ?? null,
1498
- steer: parsed.steer ?? '',
1499
- ...(isReroll && (parsed.register === 'safer' || parsed.register === 'bolder') ? { register: parsed.register } : {}),
1500
- ...(followupOpen ? { followup: true } : {}),
1501
- ...(chosen?.hero || chosen?.board ? { hero: chosen.hero ?? null, board: chosen.board ?? null } : {}),
1502
- ...((chosen?.comp ?? chosen?.sketch) ? { comp: chosen.comp ?? chosen.sketch } : {}),
1503
- ...(liveBuildPath && !isReroll ? { buildPath: liveBuildPath, buildPathFlipped: liveBuildPath !== (buildPathDefault?.value ?? null) } : {}),
1504
- });
1505
- if (detachedKey) {
1506
- fs.mkdirSync(QUESTION_DIR, { recursive: true });
1507
- fs.writeFileSync(answerFile(detachedKey), answer + '\n');
1508
- } else {
1509
- printAnswer(answer);
1510
- }
1511
- // A re-roll or followup pick in detached mode keeps the table open: the
1512
- // client shows a loading hand and reloads when --update delivers the
1513
- // next round.
1514
- if (!((isReroll || followupOpen) && detachedKey)) setTimeout(() => process.exit(0), 150);
1515
- });
1516
- return;
1517
- }
1518
- res.writeHead(404); res.end();
1519
- });
1520
-
1521
- server.listen(portArg, '127.0.0.1', () => {
1522
- const { port } = server.address();
1523
- const url = `http://127.0.0.1:${port}/`;
1524
- if (hasFlag('detached-serve')) {
1525
- fs.mkdirSync(QUESTION_DIR, { recursive: true });
1526
- fs.writeFileSync(stateFile(arg('key')), JSON.stringify({ pid: process.pid, port, url }));
1527
- } else {
1528
- console.log(`QUESTION URL: ${url}`);
1529
- console.log('Waiting for the user to choose in the browser (Ctrl-C aborts)...');
1530
- }
1531
- if (!hasFlag('no-open')) {
1532
- openSystemBrowser(url);
1533
- }
1534
- if (timeoutSec > 0) {
1535
- setTimeout(() => {
1536
- console.log('serve-question: timed out with no answer');
1537
- process.exit(2);
1538
- }, timeoutSec * 1000).unref?.();
1539
- }
1540
- });