@bastani/atomic 0.9.20-alpha.4 → 0.9.20-alpha.5

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 (245) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/intercom/skills/intercom/SKILL.md +32 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  9. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +3 -3
  11. package/dist/builtin/subagents/agents/debugger.md +7 -5
  12. package/dist/builtin/subagents/agents/worker.md +4 -2
  13. package/dist/builtin/subagents/package.json +1 -1
  14. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
  15. package/dist/builtin/subagents/skills/subagent/SKILL.md +32 -8
  16. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -4
  17. package/dist/builtin/web-access/package.json +1 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +30 -0
  19. package/dist/builtin/workflows/README.md +4 -2
  20. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  21. package/dist/builtin/workflows/builtin/{chunk-n8g2da69.js → chunk-00ywx588.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-d1xqh1rd.js → chunk-55p5dxjk.js} +1 -1
  23. package/dist/builtin/workflows/builtin/{chunk-1dydq7w3.js → chunk-7f381xnq.js} +62 -24
  24. package/dist/builtin/workflows/builtin/{chunk-k18g9me8.js → chunk-7h7s5xdj.js} +1 -1
  25. package/dist/builtin/workflows/builtin/{chunk-n4yxrsm9.js → chunk-e83tc6nr.js} +1 -1
  26. package/dist/builtin/workflows/builtin/{chunk-sn5mchnx.js → chunk-evfb0312.js} +1 -1
  27. package/dist/builtin/workflows/builtin/{chunk-scgprmdj.js → chunk-ne6vh5ct.js} +1 -1
  28. package/dist/builtin/workflows/builtin/{chunk-119kxb28.js → chunk-pfm1kgqz.js} +62 -43
  29. package/dist/builtin/workflows/builtin/{chunk-hnbbb5r0.js → chunk-tdqvdrg1.js} +4 -4
  30. package/dist/builtin/workflows/builtin/{chunk-kf5xpbkz.js → chunk-tvcydq13.js} +1 -1
  31. package/dist/builtin/workflows/builtin/{chunk-9y0f90rd.js → chunk-x2nftpgj.js} +1 -1
  32. package/dist/builtin/workflows/builtin/{chunk-vt9zgr9d.js → chunk-zj5162bh.js} +4 -4
  33. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  34. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  35. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  36. package/dist/builtin/workflows/builtin/goal.js +4 -4
  37. package/dist/builtin/workflows/builtin/index.d.ts +1 -1
  38. package/dist/builtin/workflows/builtin/index.js +12 -12
  39. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  40. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
  41. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  42. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  43. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  44. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  45. package/dist/builtin/workflows/package.json +1 -1
  46. package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
  47. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
  48. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
  49. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
  50. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
  51. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
  52. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
  53. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
  54. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
  55. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
  56. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
  57. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
  58. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
  59. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
  60. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
  61. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
  62. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  63. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
  64. package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
  65. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  66. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
  67. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
  68. package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
  69. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
  70. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
  71. package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
  72. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
  73. package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
  74. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
  75. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  76. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
  77. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
  78. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
  79. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
  80. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
  81. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
  82. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  83. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
  84. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
  85. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
  86. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
  87. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
  88. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
  89. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
  90. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  91. package/dist/builtin/workflows/src/extension/index.bundle.mjs +156 -84
  92. package/dist/builtin/workflows/src/index.js +62 -24
  93. package/dist/core/execution-model-router.d.ts +2 -0
  94. package/dist/core/execution-model-router.d.ts.map +1 -1
  95. package/dist/core/execution-model-router.js +30 -4
  96. package/dist/core/execution-model-router.js.map +1 -1
  97. package/dist/core/model-routing-task.d.ts +1 -1
  98. package/dist/core/model-routing-task.d.ts.map +1 -1
  99. package/dist/core/model-routing-task.js +4 -3
  100. package/dist/core/model-routing-task.js.map +1 -1
  101. package/dist/core/system-prompt.d.ts.map +1 -1
  102. package/dist/core/system-prompt.js +2 -1
  103. package/dist/core/system-prompt.js.map +1 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +1 -1
  107. package/dist/index.js.map +1 -1
  108. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  109. package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
  110. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  111. package/docs/computer-use.md +22 -21
  112. package/docs/getting-started/first-session.md +2 -2
  113. package/docs/getting-started/installation.md +6 -2
  114. package/docs/intercom.md +6 -1
  115. package/docs/models/model-selection.md +11 -7
  116. package/docs/quickstart.md +1 -1
  117. package/docs/skills.md +1 -1
  118. package/docs/subagents/reference.md +2 -2
  119. package/docs/subagents.md +7 -1
  120. package/docs/usage.md +2 -0
  121. package/docs/windows.md +1 -1
  122. package/docs/workflows/api-reference.md +3 -4
  123. package/docs/workflows/builtins.md +2 -2
  124. package/docs/workflows/operations.md +1 -1
  125. package/docs/workflows/reliable-design.md +12 -1
  126. package/docs/workflows/verification.md +8 -8
  127. package/npm-shrinkwrap.json +32 -32
  128. package/package.json +3 -3
  129. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
  130. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
  131. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
  132. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
  133. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
  134. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
  135. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
  136. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
  137. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
  138. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
  139. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
  140. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
  141. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
  142. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  143. package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
  144. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
  145. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
  146. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
  147. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
  148. package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
  149. package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
  150. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
  151. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
  152. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
  153. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
  154. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
  155. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
  156. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
  157. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
  158. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
  159. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  160. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
  161. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
  162. package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  163. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
  164. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
  165. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
  166. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
  167. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
  168. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  169. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
  170. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
  171. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
  172. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
  173. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
  174. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
  175. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
  176. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
  177. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
  178. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
  179. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
  180. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
  181. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
  182. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
  183. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
  184. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
  185. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
  186. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
  187. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
  188. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
  189. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
  190. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  191. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
  192. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
  193. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
  194. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
  195. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
  196. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
  197. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
  198. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
  199. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
  200. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
  201. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
  202. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
  203. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
  204. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
  205. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
  206. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
  207. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
  208. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
  209. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
  210. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
  211. package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  212. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
  213. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  214. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  215. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  216. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
  217. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
  218. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
  219. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
  220. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
  221. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
  222. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
  223. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
  224. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
  225. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
  226. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
  227. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
  228. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
  229. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
  230. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
  231. package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  232. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
  233. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
  234. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
  235. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
  236. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
  237. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
  238. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
  239. package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
  240. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
  241. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
  242. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
  243. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
  244. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
  245. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
@@ -1,427 +0,0 @@
1
- /**
2
- * CLI client for the live variant mode poll/reply protocol.
3
- *
4
- * Usage:
5
- * node <scripts_path>/live-poll.mjs # Block until browser event, print JSON
6
- * node <scripts_path>/live-poll.mjs --stream # Experimental: keep polling; one JSON line per event
7
- * node <scripts_path>/live-poll.mjs --timeout=600000 # Custom timeout (ms); default is long-poll friendly
8
- * node <scripts_path>/live-poll.mjs --reply <id> done # Reply "done" to event <id>
9
- * node <scripts_path>/live-poll.mjs --reply <id> error "msg" # Reply with error
10
- */
11
-
12
- import { execFileSync } from 'node:child_process';
13
- import path from 'node:path';
14
- import { fileURLToPath } from 'node:url';
15
- import { completionAckForAcceptResult, completionTypeForAcceptResult } from './live/completion.mjs';
16
- import { readLiveServerInfo } from './lib/impeccable-paths.mjs';
17
- import { enterLiveRoot } from './live/roots.mjs';
18
- import { instructionsForEvent } from './live/instructions.mjs';
19
-
20
- // Absolute path to a sibling script in this skill's scripts dir, so runtime
21
- // error hints print a directly-runnable command instead of a placeholder.
22
- const SELF_DIR = path.dirname(fileURLToPath(import.meta.url));
23
- const scriptCmd = (name) => `node "${path.join(SELF_DIR, name)}"`;
24
-
25
- // Node's built-in fetch (undici under the hood) enforces a 300s headers
26
- // timeout that can't be lowered per-request. We cap each request below
27
- // that ceiling and loop in `pollOnce` to synthesize a long poll without
28
- // depending on the standalone undici package.
29
- export const PER_REQUEST_TIMEOUT_MS = 270_000;
30
- export const DEFAULT_EVENT_LEASE_MS = 600_000;
31
-
32
- const EVENT_TYPES_NEEDING_AGENT_REPLY = new Set(['generate', 'steer', 'manual_edit_apply', 'carbonize_cleanup', 'variant_mount_failed']);
33
-
34
- function readServerInfo() {
35
- const record = readLiveServerInfo(process.cwd());
36
- if (!record) {
37
- console.error(`No running live server found. Start one with: ${scriptCmd('live.mjs')}`);
38
- process.exit(1);
39
- }
40
- return record.info;
41
- }
42
-
43
- export function buildPollReplyPayload(token, { id, type, message, file, data, sourceEventType }) {
44
- return { token, id, type, message, file, data, sourceEventType };
45
- }
46
-
47
- export function manualApplyPollBanner(event = {}) {
48
- const id = event.id || 'EVENT_ID';
49
- return [
50
- `Manual Apply action required: edit source, then reply with \`live-poll.mjs --reply ${id} done --data '<json>'\`.`,
51
- 'The JSON data must include status, appliedEntryIds, failed, files, and notes; summary counters are only a recovery fallback.',
52
- 'Do not run live-commit-manual-edits.mjs for this leased event.',
53
- 'Do not poll again before replying.',
54
- ].join('\n') + '\n';
55
- }
56
-
57
- /**
58
- * Parse `--reply <id> <status> [--file path] [--data '<json>'] [message]` argv
59
- * into a reply object. Returns null when `--reply` is absent. Throws (code
60
- * INVALID_REPLY_ARGS) when the reply shape is missing its event id/status and
61
- * INVALID_DATA_JSON when `--data` is present but not valid JSON.
62
- */
63
- export function parseReplyArgs(args) {
64
- const replyIdx = args.indexOf('--reply');
65
- if (replyIdx === -1) return null;
66
- const id = args[replyIdx + 1];
67
- const status = args[replyIdx + 2];
68
- validateReplyArgs({ id, status });
69
- const fileIdx = args.indexOf('--file');
70
- const file = fileIdx !== -1 && fileIdx + 1 < args.length ? args[fileIdx + 1] : undefined;
71
- const dataIdx = args.indexOf('--data');
72
- let data;
73
- if (dataIdx !== -1 && dataIdx + 1 < args.length) {
74
- try {
75
- data = JSON.parse(args[dataIdx + 1]);
76
- } catch (err) {
77
- const wrapped = new Error('--data must be valid JSON: ' + err.message);
78
- wrapped.code = 'INVALID_DATA_JSON';
79
- throw wrapped;
80
- }
81
- }
82
- const message = args.find((a, i) =>
83
- i > replyIdx + 2
84
- && !a.startsWith('--')
85
- && i !== fileIdx + 1
86
- && i !== dataIdx + 1
87
- ) || undefined;
88
- return { id, type: status, message, file, data };
89
- }
90
-
91
- function validateReplyArgs({ id, status }) {
92
- const usage = `Usage: ${scriptCmd('live-poll.mjs')} --reply <id> <status> [--file path] [--data '<json>'] [message]`;
93
- if (!id || id.startsWith('--')) {
94
- const err = new Error(`${usage}\nMissing event id after --reply.`);
95
- err.code = 'INVALID_REPLY_ARGS';
96
- throw err;
97
- }
98
- if (['done', 'error', 'complete', 'discard', 'discarded'].includes(id)) {
99
- const err = new Error(`${usage}\nThe value after --reply must be the event id, not the status ${JSON.stringify(id)}. Use --reply EVENT_ID ${id}.`);
100
- err.code = 'INVALID_REPLY_ARGS';
101
- throw err;
102
- }
103
- if (!status || status.startsWith('--')) {
104
- const err = new Error(`${usage}\nMissing reply status after event id ${JSON.stringify(id)}.`);
105
- err.code = 'INVALID_REPLY_ARGS';
106
- throw err;
107
- }
108
- }
109
-
110
- export function requiresAgentReply(event) {
111
- return EVENT_TYPES_NEEDING_AGENT_REPLY.has(event?.type);
112
- }
113
-
114
- export async function postReply(base, token, reply) {
115
- const res = await fetch(`${base}/poll`, {
116
- method: 'POST',
117
- headers: { 'Content-Type': 'application/json' },
118
- body: JSON.stringify(buildPollReplyPayload(token, reply)),
119
- });
120
- if (!res.ok) {
121
- const body = await res.json().catch(() => ({}));
122
- const failureLines = Array.isArray(body.failures)
123
- ? body.failures.map((f) => ` ${f.file}${f.line != null ? `:${f.line}` : ''} ${f.message}`).join('\n')
124
- : null;
125
- const parts = [body.error || res.statusText, body.reason, body.hint, failureLines, body._instructions].filter(Boolean);
126
- throw new Error(parts.join('\n'));
127
- }
128
- }
129
-
130
- export async function fetchServerStatus(base, token) {
131
- const res = await fetch(`${base}/status?token=${token}`);
132
- if (res.status === 401) {
133
- const err = new Error('Authentication failed. The server token may have changed.');
134
- err.code = 'AUTH_FAILED';
135
- throw err;
136
- }
137
- if (!res.ok) {
138
- throw new Error(`Status failed: ${res.status} ${res.statusText}`);
139
- }
140
- return res.json();
141
- }
142
-
143
- export function isEventPending(status, eventId) {
144
- return (status.pendingEvents || []).some((entry) => entry.id === eventId);
145
- }
146
-
147
- export async function waitForEventAck(base, token, eventId, {
148
- pollIntervalMs = 400,
149
- maxWaitMs = 600_000,
150
- } = {}) {
151
- const deadline = Date.now() + maxWaitMs;
152
- while (Date.now() < deadline) {
153
- const status = await fetchServerStatus(base, token);
154
- if (!isEventPending(status, eventId)) return true;
155
- await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
156
- }
157
- return false;
158
- }
159
-
160
- export async function fetchNextEvent(base, token, {
161
- totalDeadline,
162
- types,
163
- resolveTypes,
164
- perRequestTimeoutMs = PER_REQUEST_TIMEOUT_MS,
165
- leaseMs = DEFAULT_EVENT_LEASE_MS,
166
- signal,
167
- } = {}) {
168
- while (true) {
169
- if (totalDeadline && Date.now() >= totalDeadline) {
170
- return { type: 'timeout' };
171
- }
172
-
173
- const remaining = totalDeadline
174
- ? totalDeadline - Date.now()
175
- : PER_REQUEST_TIMEOUT_MS;
176
- const slice = Math.min(Math.max(remaining, 1000), perRequestTimeoutMs);
177
- const query = new URLSearchParams({
178
- token,
179
- timeout: String(slice),
180
- leaseMs: String(leaseMs),
181
- });
182
- const normalizedTypes = normalizePollTypes(resolveTypes ? await resolveTypes() : types);
183
- if (normalizedTypes.length > 0) query.set('types', normalizedTypes.join(','));
184
- const res = await fetch(`${base}/poll?${query}`, { signal });
185
-
186
- if (res.status === 401) {
187
- const err = new Error('Authentication failed. The server token may have changed.');
188
- err.code = 'AUTH_FAILED';
189
- throw err;
190
- }
191
-
192
- if (!res.ok) {
193
- throw new Error(`Poll failed: ${res.status} ${res.statusText}`);
194
- }
195
-
196
- const next = await res.json();
197
- if (next?.type === 'timeout') {
198
- if (totalDeadline && Date.now() < totalDeadline) continue;
199
- if (!totalDeadline) continue;
200
- return next;
201
- }
202
- return next;
203
- }
204
- }
205
-
206
- export async function augmentEventWithAcceptHandling(event, base, token) {
207
- if (event.type !== 'accept' && event.type !== 'discard') return event;
208
-
209
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
210
- const acceptScript = path.join(__dirname, 'live-accept.mjs');
211
- const scriptArgs = buildAcceptScriptArgs(event);
212
-
213
- try {
214
- const out = execFileSync(
215
- 'node',
216
- [acceptScript, ...scriptArgs],
217
- { encoding: 'utf-8', cwd: process.cwd(), timeout: 30_000 },
218
- );
219
- event._acceptResult = JSON.parse(out.trim());
220
- } catch (err) {
221
- event._acceptResult = { handled: false, mode: 'error', error: err.message };
222
- }
223
-
224
- await completeAcceptHandling(event, base, token);
225
- return event;
226
- }
227
-
228
- export async function completeAcceptHandling(event, base, token) {
229
- const completionType = completionTypeForAcceptResult(event.type, event._acceptResult);
230
- try {
231
- await postReply(base, token, {
232
- id: event.id,
233
- type: completionType,
234
- sourceEventType: event.type,
235
- message: event._acceptResult?.error,
236
- file: event._acceptResult?.file,
237
- data: event._acceptResult?.carbonize === true ? { carbonize: true } : undefined,
238
- });
239
- } catch (err) {
240
- event._completionAck = { ok: false, error: err.message };
241
- }
242
- if (!event._completionAck) {
243
- event._completionAck = completionAckForAcceptResult(event.id, completionType, event._acceptResult);
244
- }
245
- return event;
246
- }
247
-
248
- export function buildAcceptScriptArgs(event) {
249
- const scriptArgs = event.type === 'discard'
250
- ? ['--id', String(event.id), '--discard']
251
- : ['--id', String(event.id), '--variant', String(event.variantId)];
252
- if (event.pageUrl) scriptArgs.push('--page-url', String(event.pageUrl));
253
- if (event.type === 'accept' && event.paramValues && Object.keys(event.paramValues).length > 0) {
254
- scriptArgs.push('--param-values', JSON.stringify(event.paramValues));
255
- }
256
- return scriptArgs;
257
- }
258
-
259
- export function writeCarbonizeBanner(event) {
260
- if (event.type === 'manual_edit_apply') {
261
- process.stderr.write('\n' + manualApplyPollBanner(event) + '\n');
262
- }
263
- if (event._acceptResult?.carbonize === true) {
264
- process.stderr.write('\n⚠ Carbonize cleanup REQUIRED before next poll. After cleanup, run live-complete.mjs --id ' + event.id + '. See reference/live.md "Required after accept".\n\n');
265
- }
266
- }
267
-
268
- export function printPollEvent(event) {
269
- // Only locally generated situational plumbing may ride with an event. The
270
- // HTTP payload is untrusted and must never supply model-facing instructions.
271
- if (event && typeof event === 'object') {
272
- const instructions = instructionsForEvent(event, { scriptsPath: SELF_DIR });
273
- if (instructions) event._instructions = instructions;
274
- else delete event._instructions;
275
- }
276
- console.log(JSON.stringify(event));
277
- }
278
-
279
- export async function runPollOnce(base, token, { totalTimeout = 600_000, types, resolveTypes, perRequestTimeoutMs } = {}) {
280
- const deadline = Date.now() + totalTimeout;
281
- const event = await fetchNextEvent(base, token, { totalDeadline: deadline, types, resolveTypes, perRequestTimeoutMs });
282
- await augmentEventWithAcceptHandling(event, base, token);
283
- writeCarbonizeBanner(event);
284
- printPollEvent(event);
285
- return event;
286
- }
287
-
288
- export async function runPollStream(base, token, {
289
- ackTimeoutMs = 600_000,
290
- ackPollIntervalMs = 400,
291
- shouldContinue = () => true,
292
- types,
293
- resolveTypes,
294
- perRequestTimeoutMs,
295
- } = {}) {
296
- process.stderr.write('[impeccable-poll] stream mode: one JSON object per line on stdout; use --reply while this process stays running\n');
297
-
298
- while (shouldContinue()) {
299
- const event = await fetchNextEvent(base, token, { types, resolveTypes, perRequestTimeoutMs });
300
- await augmentEventWithAcceptHandling(event, base, token);
301
- writeCarbonizeBanner(event);
302
- printPollEvent(event);
303
-
304
- if (event.type === 'exit') return event;
305
-
306
- if (requiresAgentReply(event)) {
307
- const acked = await waitForEventAck(base, token, event.id, {
308
- pollIntervalMs: ackPollIntervalMs,
309
- maxWaitMs: ackTimeoutMs,
310
- });
311
- if (!acked) {
312
- const err = new Error(`Timed out waiting for --reply on event ${event.id}`);
313
- err.code = 'ACK_TIMEOUT';
314
- throw err;
315
- }
316
- }
317
- }
318
-
319
- return null;
320
- }
321
-
322
- function handlePollError(err) {
323
- if (err.code === 'AUTH_FAILED') {
324
- console.error(err.message);
325
- console.error(`Try restarting: ${scriptCmd('live-server.mjs')} stop && ${scriptCmd('live.mjs')}`);
326
- process.exit(1);
327
- }
328
- if (err.cause?.code === 'ECONNREFUSED') {
329
- console.error(`Live server not running. Start one with: ${scriptCmd('live.mjs')}`);
330
- process.exit(1);
331
- }
332
- if (err.code === 'ACK_TIMEOUT') {
333
- console.error(err.message);
334
- process.exit(1);
335
- }
336
- console.error('Poll failed:', err.message);
337
- process.exit(1);
338
- }
339
-
340
- export async function pollCli() {
341
- const args = process.argv.slice(2);
342
-
343
- if (args.includes('--help') || args.includes('-h')) {
344
- console.log(`Usage: impeccable poll [options]
345
-
346
- Wait for a browser event from the live variant server, or reply to one.
347
-
348
- Modes:
349
- poll Block until a browser event arrives, print JSON, exit
350
- poll --stream Keep polling; print one JSON line per event (see live.md)
351
- poll --reply <id> done Reply "done" to event <id> (replace or insert generate)
352
- poll --reply <id> steer_done Reply after handling a steer event (unlocks Steer bar)
353
- poll --reply <id> error "msg" Reply with an error message
354
- poll --reply <id> done --data '<json>'
355
- Reply with a structured JSON result (manual_edit_apply)
356
-
357
- Options:
358
- --timeout=MS One-shot poll timeout in ms (default: 600000). Ignored in --stream mode
359
- --types=A,B Lease only these event types
360
- --ack-timeout=MS Stream mode: max wait for --reply after generate/steer (default: 600000)
361
- --file PATH Attach a source file path to the reply (generate/steer flow)
362
- --data JSON Attach a JSON result object to the reply (manual_edit_apply flow). Must be valid JSON
363
- --help Show this help message
364
-
365
- Harness note:
366
- Default one-shot mode is the primary contract, including Codex foreground polling.
367
- --stream is retained for harnesses with measured, reliable incremental stdout.`);
368
- process.exit(0);
369
- }
370
-
371
- const info = readServerInfo();
372
- const base = `http://localhost:${info.port}`;
373
-
374
- // Reply mode: node <scripts_path>/live-poll.mjs --reply <id> <status> [--file path] [--data '<json>'] [message]
375
- if (args.includes('--reply')) {
376
- let reply;
377
- try {
378
- reply = parseReplyArgs(args);
379
- } catch (err) {
380
- console.error(err.message);
381
- process.exit(1);
382
- }
383
-
384
- try {
385
- await postReply(base, info.token, reply);
386
- } catch (err) {
387
- if (err.cause?.code === 'ECONNREFUSED') {
388
- console.error(`Live server not running. Start one with: ${scriptCmd('live.mjs')}`);
389
- } else {
390
- console.error('Reply failed:', err.message);
391
- }
392
- process.exit(1);
393
- }
394
- return;
395
- }
396
-
397
- const streamMode = args.includes('--stream');
398
- const typesArg = args.find((a) => a.startsWith('--types='));
399
- const types = normalizePollTypes(typesArg ? typesArg.slice('--types='.length) : null);
400
- const ackTimeoutArg = args.find((a) => a.startsWith('--ack-timeout='));
401
- const ackTimeoutMs = ackTimeoutArg ? parseInt(ackTimeoutArg.split('=')[1], 10) : 600_000;
402
-
403
- try {
404
- if (streamMode) {
405
- await runPollStream(base, info.token, { ackTimeoutMs, types });
406
- return;
407
- }
408
-
409
- const timeoutArg = args.find((a) => a.startsWith('--timeout='));
410
- const totalTimeout = timeoutArg ? parseInt(timeoutArg.split('=')[1], 10) : 600_000;
411
- await runPollOnce(base, info.token, { totalTimeout, types });
412
- } catch (err) {
413
- handlePollError(err);
414
- }
415
- }
416
-
417
- export function normalizePollTypes(value) {
418
- const values = Array.isArray(value) ? value : String(value || '').split(',');
419
- return [...new Set(values.map((type) => String(type).trim()).filter(Boolean))];
420
- }
421
-
422
- // Auto-execute when run directly
423
- const _running = process.argv[1];
424
- if (_running?.endsWith('live-poll.mjs') || _running?.endsWith('live-poll.mjs/')) {
425
- enterLiveRoot();
426
- pollCli();
427
- }
@@ -1,123 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Recover the next agent action from the durable live-session journal.
4
- */
5
-
6
- import { createLiveSessionStore } from './live/session-store.mjs';
7
- import { enterLiveRoot } from './live/roots.mjs';
8
-
9
- function manualApplyReplyCommand(eventOrId = 'EVENT_ID') {
10
- const id = typeof eventOrId === 'string' ? eventOrId : eventOrId?.id || 'EVENT_ID';
11
- return `live-poll.mjs --reply ${id} done --data '<json>'`;
12
- }
13
-
14
- export function manualApplyResumeHint(event = {}) {
15
- const summary = event.manualApplySummary || summarizeManualApplyEvent(event);
16
- const parts = [];
17
- if (summary.pageUrl) parts.push(`page ${summary.pageUrl}`);
18
- if (summary.chunk) parts.push(`chunk ${summary.chunk.index}/${summary.chunk.total}`);
19
- if (Number.isFinite(summary.opCount)) parts.push(`${summary.opCount} op(s)`);
20
- if (Number.isFinite(summary.entryCount)) parts.push(`${summary.entryCount} entr${summary.entryCount === 1 ? 'y' : 'ies'}`);
21
- if (summary.files?.length) parts.push(`likely files: ${summary.files.join(', ')}`);
22
- const scope = parts.length ? ` (${parts.join(', ')})` : '';
23
- return `Manual Apply pending${scope}. If you have not already leased it, run live-poll.mjs. Apply the source edits from the manual_edit_apply batch, then reply with ${manualApplyReplyCommand(event.id)}. Polling only leases this work item; it does not commit source edits. Do not run live-commit-manual-edits.mjs for this leased event. Do not poll again before replying.`;
24
- }
25
-
26
- function summarizeManualApplyEvent(event = {}) {
27
- const entries = Array.isArray(event.batch?.entries) ? event.batch.entries : [];
28
- const opCount = entries.reduce((sum, entry) => sum + (Array.isArray(entry.ops) ? entry.ops.length : 0), 0);
29
- return {
30
- pageUrl: event.pageUrl || null,
31
- chunk: event.chunk || null,
32
- entryCount: entries.length,
33
- opCount,
34
- files: collectManualApplyFiles(event.batch),
35
- };
36
- }
37
-
38
- function collectManualApplyFiles(batch) {
39
- const files = [];
40
- for (const entry of batch?.entries || []) {
41
- for (const op of entry.ops || []) files.push(op.sourceHint?.file);
42
- }
43
- for (const candidate of batch?.candidates || []) {
44
- files.push(candidate.sourceHint?.relativeFile, candidate.sourceHint?.file);
45
- for (const item of candidate.textMatches || []) files.push(item.file);
46
- for (const item of candidate.objectKeyMatches || []) files.push(item.file);
47
- for (const item of candidate.locatorMatches || []) files.push(item.file);
48
- for (const item of candidate.contextTextMatches || []) files.push(item.file);
49
- }
50
- return [...new Set(files.filter((file) => typeof file === 'string' && file.length > 0))].sort();
51
- }
52
-
53
- /**
54
- * The browser's render truth, folded into a small block the agent reads before
55
- * it decides what to do. `arrivedVariants` only says the agent published;
56
- * `renderState` says whether any of it reached a screen.
57
- */
58
- export function renderSummary(snapshot = {}) {
59
- return {
60
- renderState: snapshot.renderState ?? null,
61
- mountedVariants: Array.isArray(snapshot.mountedVariants) ? snapshot.mountedVariants : [],
62
- mountFailures: Array.isArray(snapshot.mountFailures) ? snapshot.mountFailures : [],
63
- };
64
- }
65
-
66
- export function mountFailureAction(snapshot = {}) {
67
- const failures = Array.isArray(snapshot.mountFailures) ? snapshot.mountFailures : [];
68
- const latest = failures[failures.length - 1];
69
- if (!latest) return null;
70
- const where = latest.url ? ` from ${latest.url}` : '';
71
- const why = latest.error ? ` (${latest.error})` : '';
72
- return `The browser failed to mount variant ${latest.variant}${where}${why}; nothing is on screen. Fix the variant files, then reply with live-poll.mjs --reply ${snapshot?.pendingEvent?.id || snapshot?.id || 'SESSION_ID'} done --file <manifest or source path> for the queued variant_mount_failed event (or republish) so the browser retries.`;
73
- }
74
-
75
- function parseArgs(argv) {
76
- const out = { id: null };
77
- for (let i = 0; i < argv.length; i++) {
78
- const arg = argv[i];
79
- if (arg === '--id') out.id = argv[++i];
80
- else if (arg.startsWith('--id=')) out.id = arg.slice('--id='.length);
81
- else if (arg === '--help' || arg === '-h') out.help = true;
82
- }
83
- return out;
84
- }
85
-
86
- export async function resumeCli() {
87
- const args = parseArgs(process.argv.slice(2));
88
- if (args.help) {
89
- console.log(`Usage: node live-resume.mjs [--id SESSION_ID]\n\nPrint the active durable session checkpoint and the next safe agent action.`);
90
- return;
91
- }
92
-
93
- const store = createLiveSessionStore({ cwd: process.cwd(), sessionId: args.id || undefined });
94
- const snapshot = args.id ? store.getSnapshot(args.id) : store.listActiveSessions()[0] || null;
95
- if (!snapshot) {
96
- console.log(JSON.stringify({ active: false, nextAction: 'No active durable live session found.' }, null, 2));
97
- return;
98
- }
99
-
100
- const pending = snapshot.pendingEvent || null;
101
- const render = renderSummary(snapshot);
102
- // A failed render outranks the generic pending-event hint: the agent needs to
103
- // know the user is staring at an error card, not at variants. A leased manual
104
- // Apply still outranks both, because abandoning that lease loses user edits.
105
- const mountAction = render.renderState === 'failed' ? mountFailureAction(snapshot) : null;
106
- const nextAction = pending?.type === 'manual_edit_apply'
107
- ? manualApplyResumeHint(pending)
108
- : mountAction || (pending
109
- ? `Run live-poll.mjs, handle ${pending.type} ${pending.id}, then acknowledge with live-poll.mjs --reply ${pending.id} done.`
110
- : snapshot.phase === 'carbonize_required'
111
- ? `Finish carbonize cleanup${snapshot.sourceFile ? ` in ${snapshot.sourceFile}` : ''}, then run live-complete.mjs --id ${snapshot.id}.`
112
- : snapshot.phase === 'accept_requested'
113
- ? `Run live-complete.mjs --id ${snapshot.id} after verifying the accepted variant is written.`
114
- : `Inspect ${snapshot.id}; no pending agent event is currently queued.`);
115
-
116
- console.log(JSON.stringify({ active: true, snapshot, pendingEvent: pending, render, nextAction }, null, 2));
117
- }
118
-
119
- const _running = process.argv[1];
120
- if (_running?.endsWith('live-resume.mjs') || _running?.endsWith('live-resume.mjs/')) {
121
- enterLiveRoot();
122
- resumeCli();
123
- }