@rien7/seji 0.0.0 → 0.6.1

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 (414) hide show
  1. package/bin/design-surface.mjs +6 -0
  2. package/bin/postinstall.mjs +19 -0
  3. package/bin/seji.mjs +585 -0
  4. package/dist/agent/host.d.mts +34 -0
  5. package/dist/agent/host.mjs +387 -0
  6. package/dist/agent/messages.d.mts +9 -0
  7. package/dist/agent/messages.mjs +70 -0
  8. package/dist/agent/runtimes.mjs +157 -0
  9. package/dist/cli/app.mjs +321 -0
  10. package/dist/cli/appScan.mjs +284 -0
  11. package/dist/cli/catalog.mjs +78 -0
  12. package/dist/cli/component.mjs +165 -0
  13. package/dist/cli/consolidate.mjs +159 -0
  14. package/dist/cli/cssImport.mjs +68 -0
  15. package/dist/cli/dev.mjs +339 -0
  16. package/dist/cli/doctor.mjs +311 -0
  17. package/dist/cli/init.mjs +338 -0
  18. package/dist/cli/legacyNames.mjs +266 -0
  19. package/dist/cli/migrate.mjs +163 -0
  20. package/dist/cli/prompt.mjs +34 -0
  21. package/dist/cli/propose.mjs +208 -0
  22. package/dist/cli/providers.mjs +344 -0
  23. package/dist/cli/reviewOps.mjs +110 -0
  24. package/dist/cli/semver.mjs +45 -0
  25. package/dist/cli/setup.mjs +360 -0
  26. package/dist/cli/sketches.mjs +47 -0
  27. package/dist/cli/skills.mjs +150 -0
  28. package/dist/cli/snapshot.mjs +107 -0
  29. package/dist/cli/tokenOps.mjs +120 -0
  30. package/dist/cli/types.mjs +191 -0
  31. package/dist/cli/updater.mjs +274 -0
  32. package/dist/components/astIndex.mjs +992 -0
  33. package/dist/components/ops.mjs +1069 -0
  34. package/dist/editor/AgentProposalCard.d.ts +10 -0
  35. package/dist/editor/AgentProposalCard.d.ts.map +1 -0
  36. package/dist/editor/AgentProposalCard.js +31 -0
  37. package/dist/editor/AgentProposalCard.js.map +1 -0
  38. package/dist/editor/App.d.ts +2 -0
  39. package/dist/editor/App.d.ts.map +1 -0
  40. package/dist/editor/App.js +2834 -0
  41. package/dist/editor/App.js.map +1 -0
  42. package/dist/editor/CanvasHud.d.ts +12 -0
  43. package/dist/editor/CanvasHud.d.ts.map +1 -0
  44. package/dist/editor/CanvasHud.js +13 -0
  45. package/dist/editor/CanvasHud.js.map +1 -0
  46. package/dist/editor/CanvasSurface.d.ts +31 -0
  47. package/dist/editor/CanvasSurface.d.ts.map +1 -0
  48. package/dist/editor/CanvasSurface.js +270 -0
  49. package/dist/editor/CanvasSurface.js.map +1 -0
  50. package/dist/editor/CommentPopover.d.ts +17 -0
  51. package/dist/editor/CommentPopover.d.ts.map +1 -0
  52. package/dist/editor/CommentPopover.js +62 -0
  53. package/dist/editor/CommentPopover.js.map +1 -0
  54. package/dist/editor/Comments.d.ts +13 -0
  55. package/dist/editor/Comments.d.ts.map +1 -0
  56. package/dist/editor/Comments.js +41 -0
  57. package/dist/editor/Comments.js.map +1 -0
  58. package/dist/editor/ComponentPage.d.ts +28 -0
  59. package/dist/editor/ComponentPage.d.ts.map +1 -0
  60. package/dist/editor/ComponentPage.js +55 -0
  61. package/dist/editor/ComponentPage.js.map +1 -0
  62. package/dist/editor/ComponentPanel.d.ts +38 -0
  63. package/dist/editor/ComponentPanel.d.ts.map +1 -0
  64. package/dist/editor/ComponentPanel.js +275 -0
  65. package/dist/editor/ComponentPanel.js.map +1 -0
  66. package/dist/editor/Glyph.d.ts +51 -0
  67. package/dist/editor/Glyph.d.ts.map +1 -0
  68. package/dist/editor/Glyph.js +50 -0
  69. package/dist/editor/Glyph.js.map +1 -0
  70. package/dist/editor/History.d.ts +7 -0
  71. package/dist/editor/History.d.ts.map +1 -0
  72. package/dist/editor/History.js +51 -0
  73. package/dist/editor/History.js.map +1 -0
  74. package/dist/editor/Inspector.d.ts +56 -0
  75. package/dist/editor/Inspector.d.ts.map +1 -0
  76. package/dist/editor/Inspector.js +510 -0
  77. package/dist/editor/Inspector.js.map +1 -0
  78. package/dist/editor/LazyMount.d.ts +10 -0
  79. package/dist/editor/LazyMount.d.ts.map +1 -0
  80. package/dist/editor/LazyMount.js +29 -0
  81. package/dist/editor/LazyMount.js.map +1 -0
  82. package/dist/editor/LocaleSwitch.d.ts +3 -0
  83. package/dist/editor/LocaleSwitch.d.ts.map +1 -0
  84. package/dist/editor/LocaleSwitch.js +9 -0
  85. package/dist/editor/LocaleSwitch.js.map +1 -0
  86. package/dist/editor/PreviewFrame.d.ts +10 -0
  87. package/dist/editor/PreviewFrame.d.ts.map +1 -0
  88. package/dist/editor/PreviewFrame.js +22 -0
  89. package/dist/editor/PreviewFrame.js.map +1 -0
  90. package/dist/editor/ProjectIndex.d.ts +12 -0
  91. package/dist/editor/ProjectIndex.d.ts.map +1 -0
  92. package/dist/editor/ProjectIndex.js +43 -0
  93. package/dist/editor/ProjectIndex.js.map +1 -0
  94. package/dist/editor/PromoteComponent.d.ts +28 -0
  95. package/dist/editor/PromoteComponent.d.ts.map +1 -0
  96. package/dist/editor/PromoteComponent.js +33 -0
  97. package/dist/editor/PromoteComponent.js.map +1 -0
  98. package/dist/editor/PromoteForm.d.ts +18 -0
  99. package/dist/editor/PromoteForm.d.ts.map +1 -0
  100. package/dist/editor/PromoteForm.js +35 -0
  101. package/dist/editor/PromoteForm.js.map +1 -0
  102. package/dist/editor/PromoteToken.d.ts +31 -0
  103. package/dist/editor/PromoteToken.d.ts.map +1 -0
  104. package/dist/editor/PromoteToken.js +94 -0
  105. package/dist/editor/PromoteToken.js.map +1 -0
  106. package/dist/editor/StatePreviews.d.ts +28 -0
  107. package/dist/editor/StatePreviews.d.ts.map +1 -0
  108. package/dist/editor/StatePreviews.js +113 -0
  109. package/dist/editor/StatePreviews.js.map +1 -0
  110. package/dist/editor/ValueCombo.d.ts +51 -0
  111. package/dist/editor/ValueCombo.d.ts.map +1 -0
  112. package/dist/editor/ValueCombo.js +260 -0
  113. package/dist/editor/ValueCombo.js.map +1 -0
  114. package/dist/editor/agent/AgentPanel.d.ts +19 -0
  115. package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
  116. package/dist/editor/agent/AgentPanel.js +271 -0
  117. package/dist/editor/agent/AgentPanel.js.map +1 -0
  118. package/dist/editor/agent/Markdown.d.ts +5 -0
  119. package/dist/editor/agent/Markdown.d.ts.map +1 -0
  120. package/dist/editor/agent/Markdown.js +28 -0
  121. package/dist/editor/agent/Markdown.js.map +1 -0
  122. package/dist/editor/agent/agentApi.d.ts +106 -0
  123. package/dist/editor/agent/agentApi.d.ts.map +1 -0
  124. package/dist/editor/agent/agentApi.js +66 -0
  125. package/dist/editor/agent/agentApi.js.map +1 -0
  126. package/dist/editor/agent/toolLines.d.ts +38 -0
  127. package/dist/editor/agent/toolLines.d.ts.map +1 -0
  128. package/dist/editor/agent/toolLines.js +159 -0
  129. package/dist/editor/agent/toolLines.js.map +1 -0
  130. package/dist/editor/agent/useAgent.d.ts +15 -0
  131. package/dist/editor/agent/useAgent.d.ts.map +1 -0
  132. package/dist/editor/agent/useAgent.js +65 -0
  133. package/dist/editor/agent/useAgent.js.map +1 -0
  134. package/dist/editor/api.d.ts +378 -0
  135. package/dist/editor/api.d.ts.map +1 -0
  136. package/dist/editor/api.js +247 -0
  137. package/dist/editor/api.js.map +1 -0
  138. package/dist/editor/camera.d.ts +18 -0
  139. package/dist/editor/camera.d.ts.map +1 -0
  140. package/dist/editor/camera.js +40 -0
  141. package/dist/editor/camera.js.map +1 -0
  142. package/dist/editor/canvas.d.ts +25 -0
  143. package/dist/editor/canvas.d.ts.map +1 -0
  144. package/dist/editor/canvas.js +35 -0
  145. package/dist/editor/canvas.js.map +1 -0
  146. package/dist/editor/changes/ChangesPage.d.ts +25 -0
  147. package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
  148. package/dist/editor/changes/ChangesPage.js +132 -0
  149. package/dist/editor/changes/ChangesPage.js.map +1 -0
  150. package/dist/editor/changes/changeModel.d.ts +25 -0
  151. package/dist/editor/changes/changeModel.d.ts.map +1 -0
  152. package/dist/editor/changes/changeModel.js +81 -0
  153. package/dist/editor/changes/changeModel.js.map +1 -0
  154. package/dist/editor/changes/changeState.d.mts +29 -0
  155. package/dist/editor/changes/changeState.mjs +187 -0
  156. package/dist/editor/chrome/EditorChrome.d.ts +49 -0
  157. package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
  158. package/dist/editor/chrome/EditorChrome.js +21 -0
  159. package/dist/editor/chrome/EditorChrome.js.map +1 -0
  160. package/dist/editor/drafts.d.ts +46 -0
  161. package/dist/editor/drafts.d.ts.map +1 -0
  162. package/dist/editor/drafts.js +38 -0
  163. package/dist/editor/drafts.js.map +1 -0
  164. package/dist/editor/i18n.d.ts +29 -0
  165. package/dist/editor/i18n.d.ts.map +1 -0
  166. package/dist/editor/i18n.js +2320 -0
  167. package/dist/editor/i18n.js.map +1 -0
  168. package/dist/editor/iconStroke.d.ts +6 -0
  169. package/dist/editor/iconStroke.d.ts.map +1 -0
  170. package/dist/editor/iconStroke.js +6 -0
  171. package/dist/editor/iconStroke.js.map +1 -0
  172. package/dist/editor/main.d.ts +2 -0
  173. package/dist/editor/main.d.ts.map +1 -0
  174. package/dist/editor/main.js +14 -0
  175. package/dist/editor/main.js.map +1 -0
  176. package/dist/editor/model.d.ts +16 -0
  177. package/dist/editor/model.d.ts.map +1 -0
  178. package/dist/editor/model.js +11 -0
  179. package/dist/editor/model.js.map +1 -0
  180. package/dist/editor/reasons.d.ts +44 -0
  181. package/dist/editor/reasons.d.ts.map +1 -0
  182. package/dist/editor/reasons.js +131 -0
  183. package/dist/editor/reasons.js.map +1 -0
  184. package/dist/editor/reviewLifecycle.d.ts +8 -0
  185. package/dist/editor/reviewLifecycle.d.ts.map +1 -0
  186. package/dist/editor/reviewLifecycle.js +21 -0
  187. package/dist/editor/reviewLifecycle.js.map +1 -0
  188. package/dist/editor/styles.css +8737 -0
  189. package/dist/editor/tokenMatch.d.ts +59 -0
  190. package/dist/editor/tokenMatch.d.ts.map +1 -0
  191. package/dist/editor/tokenMatch.js +198 -0
  192. package/dist/editor/tokenMatch.js.map +1 -0
  193. package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
  194. package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
  195. package/dist/editor/tokens/ConsolidatePage.js +244 -0
  196. package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
  197. package/dist/editor/tokens/TokenActivity.d.ts +18 -0
  198. package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
  199. package/dist/editor/tokens/TokenActivity.js +18 -0
  200. package/dist/editor/tokens/TokenActivity.js.map +1 -0
  201. package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
  202. package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
  203. package/dist/editor/tokens/TokenDialogs.js +119 -0
  204. package/dist/editor/tokens/TokenDialogs.js.map +1 -0
  205. package/dist/editor/tokens/TokenList.d.ts +21 -0
  206. package/dist/editor/tokens/TokenList.d.ts.map +1 -0
  207. package/dist/editor/tokens/TokenList.js +98 -0
  208. package/dist/editor/tokens/TokenList.js.map +1 -0
  209. package/dist/editor/tokens/TokenPage.d.ts +25 -0
  210. package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
  211. package/dist/editor/tokens/TokenPage.js +108 -0
  212. package/dist/editor/tokens/TokenPage.js.map +1 -0
  213. package/dist/editor/tokens/tokenModel.d.ts +35 -0
  214. package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
  215. package/dist/editor/tokens/tokenModel.js +72 -0
  216. package/dist/editor/tokens/tokenModel.js.map +1 -0
  217. package/dist/editor/ui/Button.d.ts +3 -0
  218. package/dist/editor/ui/Button.d.ts.map +1 -0
  219. package/dist/editor/ui/Button.js +6 -0
  220. package/dist/editor/ui/Button.js.map +1 -0
  221. package/dist/editor/ui/CommentBox.d.ts +23 -0
  222. package/dist/editor/ui/CommentBox.d.ts.map +1 -0
  223. package/dist/editor/ui/CommentBox.js +41 -0
  224. package/dist/editor/ui/CommentBox.js.map +1 -0
  225. package/dist/editor/ui/Icon.d.ts +8 -0
  226. package/dist/editor/ui/Icon.d.ts.map +1 -0
  227. package/dist/editor/ui/Icon.js +6 -0
  228. package/dist/editor/ui/Icon.js.map +1 -0
  229. package/dist/editor/ui/IconButton.d.ts +11 -0
  230. package/dist/editor/ui/IconButton.d.ts.map +1 -0
  231. package/dist/editor/ui/IconButton.js +6 -0
  232. package/dist/editor/ui/IconButton.js.map +1 -0
  233. package/dist/editor/ui/NumberInput.d.ts +14 -0
  234. package/dist/editor/ui/NumberInput.d.ts.map +1 -0
  235. package/dist/editor/ui/NumberInput.js +6 -0
  236. package/dist/editor/ui/NumberInput.js.map +1 -0
  237. package/dist/editor/ui/PageLine.d.ts +14 -0
  238. package/dist/editor/ui/PageLine.d.ts.map +1 -0
  239. package/dist/editor/ui/PageLine.js +7 -0
  240. package/dist/editor/ui/PageLine.js.map +1 -0
  241. package/dist/editor/ui/SearchPicker.d.ts +41 -0
  242. package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
  243. package/dist/editor/ui/SearchPicker.js +82 -0
  244. package/dist/editor/ui/SearchPicker.js.map +1 -0
  245. package/dist/editor/ui/Select.d.ts +19 -0
  246. package/dist/editor/ui/Select.d.ts.map +1 -0
  247. package/dist/editor/ui/Select.js +12 -0
  248. package/dist/editor/ui/Select.js.map +1 -0
  249. package/dist/editor/ui/TokenField.d.ts +14 -0
  250. package/dist/editor/ui/TokenField.d.ts.map +1 -0
  251. package/dist/editor/ui/TokenField.js +41 -0
  252. package/dist/editor/ui/TokenField.js.map +1 -0
  253. package/dist/editor/ui/TokenPicker.d.ts +31 -0
  254. package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
  255. package/dist/editor/ui/TokenPicker.js +26 -0
  256. package/dist/editor/ui/TokenPicker.js.map +1 -0
  257. package/dist/editor/useBuildError.d.ts +7 -0
  258. package/dist/editor/useBuildError.d.ts.map +1 -0
  259. package/dist/editor/useBuildError.js +30 -0
  260. package/dist/editor/useBuildError.js.map +1 -0
  261. package/dist/editor/useLatestRequest.d.ts +22 -0
  262. package/dist/editor/useLatestRequest.d.ts.map +1 -0
  263. package/dist/editor/useLatestRequest.js +49 -0
  264. package/dist/editor/useLatestRequest.js.map +1 -0
  265. package/dist/editor-bundle/editor.css +2 -0
  266. package/dist/editor-bundle/editor.js +83 -0
  267. package/dist/editor-ui.d.ts +15 -0
  268. package/dist/editor-ui.d.ts.map +1 -0
  269. package/dist/editor-ui.js +14 -0
  270. package/dist/editor-ui.js.map +1 -0
  271. package/dist/inspector/runtime.d.ts +18 -0
  272. package/dist/inspector/runtime.d.ts.map +1 -0
  273. package/dist/inspector/runtime.js +1280 -0
  274. package/dist/inspector/runtime.js.map +1 -0
  275. package/dist/preview/main.d.ts +3 -0
  276. package/dist/preview/main.d.ts.map +1 -0
  277. package/dist/preview/main.js +320 -0
  278. package/dist/preview/main.js.map +1 -0
  279. package/dist/preview/preview.css +40 -0
  280. package/dist/runtime/index.d.ts +3 -0
  281. package/dist/runtime/index.d.ts.map +1 -0
  282. package/dist/runtime/index.js +2 -0
  283. package/dist/runtime/index.js.map +1 -0
  284. package/dist/shared/buildError.d.mts +27 -0
  285. package/dist/shared/buildError.mjs +141 -0
  286. package/dist/shared/cameraFit.d.mts +16 -0
  287. package/dist/shared/cameraFit.mjs +47 -0
  288. package/dist/shared/canvasLayout.d.mts +13 -0
  289. package/dist/shared/canvasLayout.mjs +171 -0
  290. package/dist/shared/commentShots.d.mts +12 -0
  291. package/dist/shared/commentShots.mjs +53 -0
  292. package/dist/shared/componentExtract.d.mts +43 -0
  293. package/dist/shared/componentExtract.mjs +136 -0
  294. package/dist/shared/componentMeta.d.mts +26 -0
  295. package/dist/shared/componentMeta.mjs +87 -0
  296. package/dist/shared/componentOps.d.mts +70 -0
  297. package/dist/shared/componentOps.mjs +407 -0
  298. package/dist/shared/componentTarget.d.mts +15 -0
  299. package/dist/shared/componentTarget.mjs +58 -0
  300. package/dist/shared/components.d.mts +30 -0
  301. package/dist/shared/components.mjs +106 -0
  302. package/dist/shared/consolidateCategories.d.mts +2 -0
  303. package/dist/shared/consolidateCategories.mjs +6 -0
  304. package/dist/shared/env.d.mts +4 -0
  305. package/dist/shared/env.mjs +18 -0
  306. package/dist/shared/gitChanges.d.mts +2 -0
  307. package/dist/shared/gitChanges.mjs +30 -0
  308. package/dist/shared/legacyPaths.d.mts +1 -0
  309. package/dist/shared/legacyPaths.mjs +9 -0
  310. package/dist/shared/oklab.d.mts +6 -0
  311. package/dist/shared/oklab.mjs +56 -0
  312. package/dist/shared/optimizeEntries.d.mts +5 -0
  313. package/dist/shared/optimizeEntries.mjs +24 -0
  314. package/dist/shared/packages.d.mts +11 -0
  315. package/dist/shared/packages.mjs +96 -0
  316. package/dist/shared/projectFiles.d.mts +23 -0
  317. package/dist/shared/projectFiles.mjs +72 -0
  318. package/dist/shared/prompt.d.mts +25 -0
  319. package/dist/shared/prompt.mjs +217 -0
  320. package/dist/shared/proposals.d.mts +11 -0
  321. package/dist/shared/proposals.mjs +42 -0
  322. package/dist/shared/protocol.d.ts +122 -0
  323. package/dist/shared/protocol.d.ts.map +1 -0
  324. package/dist/shared/protocol.js +7 -0
  325. package/dist/shared/protocol.js.map +1 -0
  326. package/dist/shared/reviewArchive.d.mts +4 -0
  327. package/dist/shared/reviewArchive.mjs +19 -0
  328. package/dist/shared/reviewStore.d.mts +30 -0
  329. package/dist/shared/reviewStore.mjs +218 -0
  330. package/dist/shared/reviewVerify.d.mts +21 -0
  331. package/dist/shared/reviewVerify.mjs +158 -0
  332. package/dist/shared/sizeModes.d.mts +15 -0
  333. package/dist/shared/sizeModes.mjs +53 -0
  334. package/dist/shared/sketches.d.mts +10 -0
  335. package/dist/shared/sketches.mjs +64 -0
  336. package/dist/shared/snapshotCheck.d.mts +13 -0
  337. package/dist/shared/snapshotCheck.mjs +81 -0
  338. package/dist/shared/timeout.d.mts +1 -0
  339. package/dist/shared/timeout.mjs +15 -0
  340. package/dist/shared/tokens.d.ts +2 -0
  341. package/dist/shared/tokens.d.ts.map +1 -0
  342. package/dist/shared/tokens.js +2 -0
  343. package/dist/shared/tokens.js.map +1 -0
  344. package/dist/shared/types.d.ts +689 -0
  345. package/dist/shared/types.d.ts.map +1 -0
  346. package/dist/shared/types.js +13 -0
  347. package/dist/shared/types.js.map +1 -0
  348. package/dist/shared/wheelRouting.d.mts +9 -0
  349. package/dist/shared/wheelRouting.mjs +31 -0
  350. package/dist/shared/writeScope.mjs +96 -0
  351. package/dist/snapshots/diff.d.mts +28 -0
  352. package/dist/snapshots/diff.mjs +263 -0
  353. package/dist/snapshots/index.d.mts +110 -0
  354. package/dist/snapshots/index.mjs +638 -0
  355. package/dist/snapshots/render.d.mts +24 -0
  356. package/dist/snapshots/render.mjs +250 -0
  357. package/dist/snapshots/toolOps.d.mts +25 -0
  358. package/dist/snapshots/toolOps.mjs +69 -0
  359. package/dist/tokens/adapters/css.mjs +51 -0
  360. package/dist/tokens/adapters/cssInCode.mjs +314 -0
  361. package/dist/tokens/adapters/oxcShared.mjs +80 -0
  362. package/dist/tokens/adapters/preprocessor.mjs +63 -0
  363. package/dist/tokens/adapters/registry.mjs +53 -0
  364. package/dist/tokens/adapters/tailwindcss.mjs +424 -0
  365. package/dist/tokens/adapters/types.mjs +117 -0
  366. package/dist/tokens/consolidate/index.d.mts +42 -0
  367. package/dist/tokens/consolidate/index.mjs +111 -0
  368. package/dist/tokens/consolidate/normalize.mjs +479 -0
  369. package/dist/tokens/consolidate/plan.mjs +726 -0
  370. package/dist/tokens/consolidate/scan.mjs +928 -0
  371. package/dist/tokens/extract.mjs +441 -0
  372. package/dist/tokens/moduleData.d.mts +14 -0
  373. package/dist/tokens/moduleData.mjs +32 -0
  374. package/dist/tokens/opLock.d.mts +4 -0
  375. package/dist/tokens/opLock.mjs +108 -0
  376. package/dist/tokens/ops.d.mts +71 -0
  377. package/dist/tokens/ops.mjs +1511 -0
  378. package/dist/tokens/pipeline.mjs +813 -0
  379. package/dist/tokens/report.d.mts +47 -0
  380. package/dist/tokens/report.mjs +257 -0
  381. package/dist/tokens/rewrite/code.mjs +172 -0
  382. package/dist/tokens/rewrite/css.mjs +154 -0
  383. package/dist/tokens/rewrite/index.mjs +244 -0
  384. package/dist/tokens/rewrite/tailwind.mjs +288 -0
  385. package/dist/tokens/rewrite/text.mjs +116 -0
  386. package/dist/tokens/rewrite/value.mjs +115 -0
  387. package/dist/tokens/usage.d.mts +97 -0
  388. package/dist/tokens/usage.mjs +680 -0
  389. package/dist/vite/agent.d.ts +21 -0
  390. package/dist/vite/agent.d.ts.map +1 -0
  391. package/dist/vite/agent.js +165 -0
  392. package/dist/vite/agent.js.map +1 -0
  393. package/dist/vite/events.d.ts +27 -0
  394. package/dist/vite/events.d.ts.map +1 -0
  395. package/dist/vite/events.js +156 -0
  396. package/dist/vite/events.js.map +1 -0
  397. package/dist/vite/layout.d.ts +2 -0
  398. package/dist/vite/layout.d.ts.map +1 -0
  399. package/dist/vite/layout.js +4 -0
  400. package/dist/vite/layout.js.map +1 -0
  401. package/dist/vite/plugin.d.ts +40 -0
  402. package/dist/vite/plugin.d.ts.map +1 -0
  403. package/dist/vite/plugin.js +1264 -0
  404. package/dist/vite/plugin.js.map +1 -0
  405. package/dist/vite/requestGuard.d.mts +3 -0
  406. package/dist/vite/requestGuard.mjs +43 -0
  407. package/dist/vite/review.d.ts +11 -0
  408. package/dist/vite/review.d.ts.map +1 -0
  409. package/dist/vite/review.js +283 -0
  410. package/dist/vite/review.js.map +1 -0
  411. package/package.json +106 -1
  412. package/skills/seji/SKILL.md +400 -0
  413. package/skills/seji-authoring/SKILL.md +397 -0
  414. package/skills/seji-tokens/SKILL.md +432 -0
@@ -0,0 +1,387 @@
1
+ // The editor's agent (0.5.0), hosted by the dev server: it finds the agents on this machine
2
+ // through oar, runs one conversation at a time in the app directory and streams its records
3
+ // to the editor's Agent panel. Nothing is stored: every dev server starts a new conversation.
4
+ // Approvals are the agent's own (oar's default launch mode for each runtime).
5
+ //
6
+ // oar provides the runtimes (Claude Code, Codex, Pi), the session (deliver, abort, dispose),
7
+ // the record stream and its fold (reduceSessionView). This adds detection and choice, the
8
+ // opening line in front of the first message, and one event stream for the browser.
9
+ import { randomUUID } from 'node:crypto'
10
+
11
+ import { initialSessionView, reduceSessionView } from '@botiverse/oar/observe'
12
+
13
+ import { withTimeout } from '../shared/timeout.mjs'
14
+ import { editorContextLine, openingContext } from './messages.mjs'
15
+ import { DEFAULT_AGENT, loadRuntimes } from './runtimes.mjs'
16
+
17
+ /** Tool output kept per record for the panel (the agent itself got all of it). */
18
+ const MAX_TOOL_TEXT = 12_000
19
+ const DISPOSE_TIMEOUT_MS = 5000
20
+ /** Listing models starts the agent briefly; a slow one leaves the menu at "default". */
21
+ const LIST_MODELS_TIMEOUT_MS = 20_000
22
+
23
+ export class AgentError extends Error {
24
+ constructor(code, message, status = 400) {
25
+ super(message)
26
+ this.code = code
27
+ this.status = status
28
+ }
29
+ }
30
+
31
+ const slimContent = (content) =>
32
+ Array.isArray(content)
33
+ ? content.map((part) =>
34
+ part?.type === 'text' && typeof part.text === 'string' && part.text.length > MAX_TOOL_TEXT
35
+ ? { ...part, text: `${part.text.slice(0, MAX_TOOL_TEXT)}\n…` }
36
+ : part?.type === 'image'
37
+ ? { type: 'other', value: { image: part.mediaType ?? 'image' } }
38
+ : part,
39
+ )
40
+ : content
41
+
42
+ /** A record as the browser gets it: the frame's native payload dropped, long tool output cut. */
43
+ export function slimRecord(record) {
44
+ if (record?.kind === 'frame' && record.body) {
45
+ const events = Array.isArray(record.body.events)
46
+ ? record.body.events.map((event) => (event && 'content' in event ? { ...event, content: slimContent(event.content) } : event))
47
+ : record.body.events
48
+ return { ...record, body: { ...record.body, native: null, events } }
49
+ }
50
+ if (record?.kind === 'response' && record.content) return { ...record, content: slimContent(record.content) }
51
+ return record
52
+ }
53
+
54
+ const lastEndedTurnId = (view) => {
55
+ for (let index = view.messages.length - 1; index >= 0; index -= 1) {
56
+ const message = view.messages[index]
57
+ if (message.kind === 'turn' && message.outcome) return message.id
58
+ }
59
+ return null
60
+ }
61
+
62
+ /**
63
+ * The agent host of one dev server. `root` is the agent's cwd: the folder holding the design
64
+ * board (`board`, relative to it); `app` is the app relative to it ('.' when they are the same).
65
+ * `loadRuntimes` is injectable for tests (default: oar's runtimes, SEJI_AGENTS).
66
+ */
67
+ export function createAgentHost({ root, board = 'design', app = '.', env = process.env, loadRuntimes: load = loadRuntimes, log = () => {} } = {}) {
68
+ const listeners = new Set()
69
+ let detected = []
70
+ let problems = []
71
+ let detecting = false
72
+ let agentId = null
73
+ // The chosen model and effort (null: the agent's own default), and each agent's model list.
74
+ let model = null
75
+ let effort = null
76
+ const models = new Map()
77
+
78
+ let conversation = 1
79
+ let session = null
80
+ let sessionAgent = null
81
+ let starting = null
82
+ let unsubscribe = null
83
+ let view = initialSessionView()
84
+ let records = []
85
+ let opened = false
86
+ // The last "[Editor]" line sent in this conversation: a new one goes only when it changes.
87
+ let lastContext = null
88
+ let stopping = false
89
+ let lastError = null
90
+ const inputs = new Map()
91
+ const turns = new Map()
92
+ let turnStart = null
93
+ let closed = false
94
+
95
+ const emit = (event) => {
96
+ for (const listener of [...listeners]) {
97
+ try {
98
+ listener(event)
99
+ } catch {
100
+ // a broken stream must not stop the others
101
+ }
102
+ }
103
+ }
104
+
105
+ const entryOf = (id) => detected.find((entry) => entry.id === id) ?? null
106
+
107
+ const status = () => {
108
+ if (detecting && !detected.length) return 'detecting'
109
+ if (!detected.length) return 'none'
110
+ if (stopping) return 'stopping'
111
+ if (starting) return 'starting'
112
+ if (view.status.kind === 'running') return 'working'
113
+ return 'idle'
114
+ }
115
+
116
+ const state = () => {
117
+ const entry = entryOf(sessionAgent ?? agentId)
118
+ return {
119
+ conversation,
120
+ root,
121
+ detecting,
122
+ status: status(),
123
+ agent: entry?.id ?? null,
124
+ agents: detected.map((item) => ({
125
+ id: item.id,
126
+ name: item.name,
127
+ icon: item.icon,
128
+ classifyAs: item.classifyAs ?? item.id,
129
+ version: item.version ?? null,
130
+ })),
131
+ problems,
132
+ model,
133
+ effort,
134
+ models: entry ? models.get(entry.id) ?? { status: 'loading', list: [] } : null,
135
+ session: Boolean(session),
136
+ inputs: Object.fromEntries(inputs),
137
+ turns: Object.fromEntries(turns),
138
+ error: lastError,
139
+ }
140
+ }
141
+
142
+ const emitState = () => emit({ type: 'state', state: state() })
143
+
144
+ /** The models (and effort levels) an agent offers now, listed once per agent and dev server. */
145
+ const listModels = (entry) => {
146
+ if (!entry || models.has(entry.id)) return
147
+ if (typeof entry.runtime.listModels !== 'function') {
148
+ models.set(entry.id, { status: 'none', list: [] })
149
+ return
150
+ }
151
+ models.set(entry.id, { status: 'loading', list: [] })
152
+ const listing = entry.runtime.listModels(entry.installation, { cwd: root, timeoutMs: LIST_MODELS_TIMEOUT_MS })
153
+ void Promise.race([listing, new Promise((resolve) => setTimeout(() => resolve({ kind: 'timeout' }), LIST_MODELS_TIMEOUT_MS + 1000).unref?.())])
154
+ .then((result) => {
155
+ if (result?.kind === 'ok') {
156
+ const list = (result.models ?? [])
157
+ .filter((item) => item && typeof item.id === 'string' && !item.disabled)
158
+ .map((item) => ({
159
+ id: item.id,
160
+ name: item.displayName ?? item.id,
161
+ efforts: [...(item.effortLevels ?? [])],
162
+ defaultEffort: item.defaultEffort ?? null,
163
+ isDefault: item.default === true,
164
+ }))
165
+ models.set(entry.id, { status: 'ok', list })
166
+ } else {
167
+ models.set(entry.id, { status: 'none', list: [], detail: result?.detail ?? result?.reason ?? (result?.kind === 'unauthenticated' ? 'not logged in' : null) })
168
+ }
169
+ })
170
+ .catch((error) => {
171
+ models.set(entry.id, { status: 'none', list: [], detail: error instanceof Error ? error.message : String(error) })
172
+ })
173
+ .finally(() => {
174
+ if (!closed) emitState()
175
+ })
176
+ }
177
+
178
+ /** Ask oar which agents this machine has (never installs or logs in). */
179
+ const detect = async () => {
180
+ detecting = true
181
+ emitState()
182
+ try {
183
+ const loaded = await load({ env, root })
184
+ const found = []
185
+ for (const entry of loaded.entries ?? []) {
186
+ const brand = entry.runtime?.brand ?? { name: entry.id, icon: null }
187
+ let snapshot
188
+ try {
189
+ snapshot = typeof entry.runtime.installation === 'function' ? await entry.runtime.installation() : { kind: 'available' }
190
+ } catch {
191
+ snapshot = { kind: 'unsupported' }
192
+ }
193
+ if (snapshot?.kind === 'available') {
194
+ found.push({ ...entry, installation: snapshot, name: brand.name ?? entry.id, icon: brand.icons?.light ?? brand.icon ?? null, version: snapshot.version ?? null })
195
+ }
196
+ }
197
+ detected = found
198
+ problems = loaded.problems ?? []
199
+ if (!entryOf(agentId)) {
200
+ const ids = found.map((entry) => entry.id)
201
+ agentId = ids.includes(DEFAULT_AGENT) ? DEFAULT_AGENT : ids[0] ?? null
202
+ }
203
+ listModels(entryOf(agentId))
204
+ } finally {
205
+ detecting = false
206
+ emitState()
207
+ }
208
+ return state()
209
+ }
210
+
211
+ const onRecord = (forConversation, record) => {
212
+ if (forConversation !== conversation) return
213
+ const before = view
214
+ view = reduceSessionView(view, record)
215
+ const slim = slimRecord(record)
216
+ records.push(slim)
217
+ emit({ type: 'record', conversation, record: slim })
218
+ if (before.status.kind !== 'running' && view.status.kind === 'running') turnStart = Date.now()
219
+ if (before.status.kind === 'running' && view.status.kind !== 'running') {
220
+ const turnId = lastEndedTurnId(view)
221
+ if (turnId && turnStart) turns.set(turnId, { startedAt: turnStart, endedAt: Date.now() })
222
+ turnStart = null
223
+ }
224
+ if (before.status.kind !== view.status.kind || Boolean(before.exited) !== Boolean(view.exited)) emitState()
225
+ }
226
+
227
+ const startSession = async () => {
228
+ const entry = entryOf(agentId)
229
+ if (!entry) throw new AgentError('no-agent', 'No agent was found on this machine.', 409)
230
+ const forConversation = conversation
231
+ const options = { cwd: root, ...(model ? { model } : {}), ...(model && effort ? { effort } : {}) }
232
+ log(`agent: starting ${entry.name}${model ? ` (${model}${options.effort ? `, ${options.effort}` : ''})` : ''}`)
233
+ const next = await entry.runtime.session(entry.installation, options)
234
+ if (forConversation !== conversation || closed) {
235
+ void withTimeout(next.dispose(), DISPOSE_TIMEOUT_MS).catch(() => {})
236
+ throw new AgentError('cancelled', 'The conversation was replaced while it started.', 409)
237
+ }
238
+ session = next
239
+ sessionAgent = entry.id
240
+ unsubscribe = next.rawEvents((record) => onRecord(forConversation, record), { sessionId: next.id, afterSeq: -1 })
241
+ return next
242
+ }
243
+
244
+ const ensureSession = async () => {
245
+ if (session && view.exited) await newConversation()
246
+ if (session) return session
247
+ if (!starting) {
248
+ lastError = null
249
+ starting = startSession().finally(() => {
250
+ starting = null
251
+ emitState()
252
+ })
253
+ emitState()
254
+ }
255
+ try {
256
+ return await starting
257
+ } catch (error) {
258
+ if (!(error instanceof AgentError && error.code === 'cancelled')) {
259
+ lastError = error instanceof Error ? error.message : String(error)
260
+ emitState()
261
+ }
262
+ throw error instanceof AgentError ? error : new AgentError('start-failed', lastError, 502)
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Send a message (one turn at a time: refused while a turn runs). The first message of a
268
+ * conversation gets the opening in front; an "[Editor]" line from `context` (design, page,
269
+ * frame, selected element) goes in front when it differs from the last one sent.
270
+ * `handoff` only labels it in the panel.
271
+ */
272
+ const send = async ({ text, handoff, context } = {}) => {
273
+ const typed = typeof text === 'string' ? text : ''
274
+ if (!typed.trim()) throw new AgentError('bad-request', 'text is required')
275
+ if (starting || view.status.kind === 'running') throw new AgentError('busy', 'The agent is still working on the last message.', 409)
276
+ const current = await ensureSession()
277
+ const where = editorContextLine(context, { board })
278
+ const head = [opened ? null : openingContext({ board, app }), where && where !== lastContext ? where : null].filter(Boolean)
279
+ const message = head.length ? `${head.join('\n')}\n\n${typed}` : typed
280
+ opened = true
281
+ if (where) lastContext = where
282
+ const inputId = randomUUID()
283
+ inputs.set(inputId, { text: typed, ...(handoff ? { handoff } : {}), at: new Date().toISOString() })
284
+ emitState()
285
+ const result = await current.deliver(message, { when: 'after_turn', inputId, origin: { kind: 'user', source: 'seji' } })
286
+ if (result.landed === 'rejected') {
287
+ inputs.delete(inputId)
288
+ emitState()
289
+ throw new AgentError('rejected', result.reason ?? 'The agent did not take the message.', 409)
290
+ }
291
+ return { inputId, landed: result.landed }
292
+ }
293
+
294
+ /** Stop the running turn; the conversation stays and the next message continues it. */
295
+ const stop = async () => {
296
+ if (!session || view.status.kind !== 'running') return { stopped: false }
297
+ stopping = true
298
+ emitState()
299
+ try {
300
+ const result = await session.abort()
301
+ return { stopped: result.kind === 'accepted' }
302
+ } finally {
303
+ stopping = false
304
+ emitState()
305
+ }
306
+ }
307
+
308
+ const teardown = async () => {
309
+ const old = session
310
+ const oldUnsubscribe = unsubscribe
311
+ session = null
312
+ sessionAgent = null
313
+ unsubscribe = null
314
+ starting = null
315
+ opened = false
316
+ lastContext = null
317
+ if (!old) return
318
+ try {
319
+ if (old.status().value.kind === 'running') await withTimeout(old.abort(), DISPOSE_TIMEOUT_MS)
320
+ } catch {
321
+ // the dispose below ends it
322
+ }
323
+ try {
324
+ await withTimeout(old.dispose(), DISPOSE_TIMEOUT_MS)
325
+ } catch (error) {
326
+ log(`agent: dispose failed: ${error instanceof Error ? error.message : String(error)}`)
327
+ }
328
+ oldUnsubscribe?.()
329
+ }
330
+
331
+ /** New conversation: stop what runs, close the session, clear the panel. */
332
+ async function newConversation() {
333
+ conversation += 1
334
+ const done = teardown()
335
+ view = initialSessionView()
336
+ records = []
337
+ inputs.clear()
338
+ turns.clear()
339
+ turnStart = null
340
+ lastError = null
341
+ emit({ type: 'reset', conversation })
342
+ emitState()
343
+ await done
344
+ return state()
345
+ }
346
+
347
+ /**
348
+ * Switch the agent, model or effort (this dev server only). A new agent starts at its own
349
+ * default model unless one is given; effort only goes with a model. Any change replaces a
350
+ * started conversation; before the first message it only updates the choice.
351
+ */
352
+ const select = async ({ agent, model: nextModel, effort: nextEffort } = {}) => {
353
+ const id = typeof agent === 'string' ? agent : sessionAgent ?? agentId
354
+ if (!entryOf(id)) throw new AgentError('not-found', `Agent ${id} was not found on this machine.`, 404)
355
+ const agentChanged = id !== (sessionAgent ?? agentId)
356
+ const pickedModel = typeof nextModel === 'string' && nextModel ? nextModel : nextModel === undefined && !agentChanged ? model : null
357
+ const pickedEffort = pickedModel && typeof nextEffort === 'string' && nextEffort ? nextEffort : nextEffort === undefined && !agentChanged && pickedModel === model ? effort : null
358
+ const changed = agentChanged || pickedModel !== model || pickedEffort !== effort
359
+ agentId = id
360
+ model = pickedModel
361
+ effort = pickedEffort
362
+ listModels(entryOf(id))
363
+ if (changed && (session || starting || records.length)) await newConversation()
364
+ else emitState()
365
+ return state()
366
+ }
367
+
368
+ const subscribe = (listener) => {
369
+ listeners.add(listener)
370
+ return () => listeners.delete(listener)
371
+ }
372
+
373
+ const close = async () => {
374
+ if (closed) return
375
+ closed = true
376
+ listeners.clear()
377
+ conversation += 1
378
+ await teardown()
379
+ }
380
+
381
+ const ready = detect().catch((error) => {
382
+ problems = [error instanceof Error ? error.message : String(error)]
383
+ emitState()
384
+ })
385
+
386
+ return { ready, state, records: () => records, view: () => view, subscribe, detect, send, stop, newConversation, select, close }
387
+ }
@@ -0,0 +1,9 @@
1
+ export type AgentEditorContext = {
2
+ design: string
3
+ page?: string | null
4
+ frame?: string | null
5
+ element?: { name?: string | null; source?: string | null; anchor?: string | null; text?: string | null } | null
6
+ }
7
+ export declare function openingContext(options?: { board?: string; app?: string }): string
8
+ export declare function normalizeContext(input: unknown): AgentEditorContext | null
9
+ export declare function editorContextLine(input: unknown, options?: { board?: string }): string | null
@@ -0,0 +1,70 @@
1
+ // What the editor's agent is told besides the typed text (0.5.0): an opening in front of the
2
+ // first message of a conversation, and a "where the editor is" line in front of any message
3
+ // whose editor position differs from the last one sent. "Hand to agent" sends the existing
4
+ // prompt (shared/prompt.mjs) as the message.
5
+
6
+ const clip = (value, max) => {
7
+ if (typeof value !== 'string') return null
8
+ const text = value.replace(/\s+/g, ' ').trim()
9
+ if (!text) return null
10
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text
11
+ }
12
+
13
+ /**
14
+ * The opening every new conversation starts with. `board` is the design directory relative
15
+ * to the working directory (the folder holding it); `app` is the app relative to it ('.' when
16
+ * the app holds the board itself).
17
+ */
18
+ export function openingContext({ board = 'design', app = '.' } = {}) {
19
+ const where =
20
+ app && app !== '.'
21
+ ? `The working directory holds the design board \`${board}/\`; the app is \`${app}/\`.`
22
+ : `The working directory is the app; the design board is \`${board}/\`.`
23
+ return [
24
+ `You are working inside seji (\`seji dev\`), driven from its editor panel. ${where}`,
25
+ `Follow the seji skills (seji, seji-authoring, seji-tokens) for everything in \`${board}/\`; use the \`seji\` CLI for ledger status, replies and checks, as the skills say.`,
26
+ 'Each message may start with an "[Editor]" line: what the user is looking at and has selected right now. "this", "here" and "it" refer to that.',
27
+ ].join('\n')
28
+ }
29
+
30
+ /** Only well-formed strings, clipped: the panel's context comes from the browser. */
31
+ export function normalizeContext(input) {
32
+ if (!input || typeof input !== 'object') return null
33
+ const design = clip(input.design, 80)
34
+ if (!design) return null
35
+ const element = input.element && typeof input.element === 'object' ? input.element : null
36
+ return {
37
+ design,
38
+ page: clip(input.page, 80),
39
+ frame: clip(input.frame, 80),
40
+ element: element
41
+ ? {
42
+ name: clip(element.name, 60),
43
+ source: clip(element.source, 200),
44
+ anchor: clip(element.anchor, 80),
45
+ text: clip(element.text, 60),
46
+ }
47
+ : null,
48
+ }
49
+ }
50
+
51
+ /** One line on where the editor is, or null without an open design. */
52
+ export function editorContextLine(input, { board = 'design' } = {}) {
53
+ const context = normalizeContext(input)
54
+ if (!context) return null
55
+ const parts = [`design "${context.design}" (${board}/${context.design}/design.tsx)`]
56
+ if (context.page) parts.push(`page "${context.page}"`)
57
+ if (context.frame) parts.push(`frame "${context.frame}"`)
58
+ let line = `[Editor] ${parts.join(', ')}`
59
+ const element = context.element
60
+ if (element && (element.name || element.source || element.anchor)) {
61
+ const bits = [element.name ? `<${element.name}>` : 'an element']
62
+ if (element.text) bits.push(`"${element.text}"`)
63
+ if (element.source) bits.push(`at ${element.source}`)
64
+ if (element.anchor) bits.push(`(anchor ${element.anchor})`)
65
+ line += `; selected ${bits.join(' ')}`
66
+ } else {
67
+ line += '; nothing selected'
68
+ }
69
+ return `${line}.`
70
+ }
@@ -0,0 +1,157 @@
1
+ // Which agents the editor can drive (0.5.0), through oar (@botiverse/oar, bundled with this
2
+ // tool, never added to the project). Each entry: the oar runtime and the runtime id oar's
3
+ // tool classification uses. Approvals stay with each agent's own settings (oar's defaults).
4
+ //
5
+ // SEJI_AGENTS picks the candidates (comma list; default claude,codex,pi). `fake` (and `fake-b`,
6
+ // a second one) adds a scripted agent for tests and screenshots (oar's scriptedRuntime); `none` finds nothing.
7
+ import { execFile } from 'node:child_process'
8
+ import { fileURLToPath } from 'node:url'
9
+
10
+ import { toolEnv } from '../shared/env.mjs'
11
+
12
+ const DEFAULT_IDS = ['claude', 'codex', 'pi']
13
+ const CLI_BIN = fileURLToPath(new URL('../../bin/seji.mjs', import.meta.url))
14
+
15
+ export function candidateIds(env = process.env) {
16
+ const raw = String(toolEnv('AGENTS', env) ?? '').trim()
17
+ if (!raw) return DEFAULT_IDS
18
+ if (raw === 'none') return []
19
+ return raw.split(',').map((id) => id.trim()).filter(Boolean)
20
+ }
21
+
22
+ const sleep = (ms, signal) =>
23
+ new Promise((resolve) => {
24
+ if (!ms) return resolve()
25
+ const timer = setTimeout(resolve, ms)
26
+ signal?.addEventListener('abort', () => {
27
+ clearTimeout(timer)
28
+ resolve()
29
+ }, { once: true })
30
+ })
31
+
32
+ const runCli = (root, args) =>
33
+ new Promise((resolve, reject) => {
34
+ execFile(process.execPath, [CLI_BIN, ...args], { cwd: root, env: { ...process.env, SEJI_NO_UPDATE: '1' } }, (error, stdout, stderr) => {
35
+ if (error) reject(new Error(String(stderr || error.message).trim()))
36
+ else resolve(String(stdout).trim())
37
+ })
38
+ })
39
+
40
+ /**
41
+ * A scripted agent on oar's `scriptedRuntime`: the same records, folds and controls as a vendor
42
+ * runtime and Claude Code's tool names. It really runs `seji status` for handed-over items, so the canvas and the changes page
43
+ * refresh like with a real agent. For tests and screenshots only.
44
+ */
45
+ export async function fakeRuntime({ root, delayMs = 40, id = 'fake', name = 'Fake agent' }) {
46
+ const { scriptedRuntime } = await import('@botiverse/oar/testing')
47
+ const pause = (signal, factor = 1) => sleep(delayMs * factor, signal)
48
+ const stream = async (turn, text) => {
49
+ for (const piece of text.match(/[\s\S]{1,12}/g) ?? []) {
50
+ if (turn.signal.aborted) return
51
+ turn.say(piece)
52
+ await pause(turn.signal)
53
+ }
54
+ }
55
+ const tool = (turn, name, input, work) =>
56
+ turn.tool(name, JSON.stringify(input), async () => {
57
+ await pause(turn.signal, 4)
58
+ return work ? await work() : 'ok'
59
+ }).catch(() => {})
60
+ const runtime = scriptedRuntime({
61
+ id,
62
+ brand: { name, icon: null },
63
+ model: 'fake-1',
64
+ turn: async (turn) => {
65
+ const text = turn.input
66
+ if (/\bslow\b/i.test(text)) {
67
+ await stream(turn, 'Working on it slowly…')
68
+ await pause(turn.signal, 200)
69
+ return
70
+ }
71
+ // A run of tool calls with a slow command in the middle (the panel's tool group).
72
+ if (/\btools\b/i.test(text)) {
73
+ await stream(turn, 'Looking around first.\n\n')
74
+ await tool(turn, 'Read', { file_path: `${root}/package.json` })
75
+ await tool(turn, 'Read', { file_path: `${root}/src/App.tsx` })
76
+ await tool(turn, 'Edit', { file_path: `${root}/src/App.tsx`, old_string: 'Hello', new_string: 'Hi' })
77
+ await turn.tool('Bash', JSON.stringify({ command: 'pnpm test' }), async () => {
78
+ await pause(turn.signal, 60)
79
+ return 'ok'
80
+ }).catch(() => {})
81
+ await tool(turn, 'Read', { file_path: `${root}/README.md` })
82
+ await stream(turn, 'All done.')
83
+ return
84
+ }
85
+ if (/\bfail\b/i.test(text)) throw new Error('the fake agent was asked to fail')
86
+ // The editor's hand-off: the same prompt `seji prompt` prints.
87
+ const handoff = /^Design: design\/(.+)\/design\.tsx$/m.exec(text)
88
+ if (handoff) {
89
+ const [, design] = handoff
90
+ const items = text.split(/^Items:$/m)[1]?.split(/\n\n/)[0] ?? ''
91
+ const ids = [...items.matchAll(/^- (\S+) \(/gm)].map((match) => match[1])
92
+ await stream(turn, `I'll read the ${ids.length} pending items first, then change the components.\n\n`)
93
+ await tool(turn, 'Read', { file_path: `${root}/design/${design}/review.json` })
94
+ await tool(turn, 'Grep', { pattern: '--ds-accent', path: 'src' }, () => '12 matches')
95
+ await tool(turn, 'Edit', { file_path: `${root}/src/components/Button.tsx`, old_string: 'background: var(--ds-text);\ncolor: white;', new_string: 'background: var(--ds-accent);\ncolor: white;' })
96
+ for (const id of ids.slice(0, 2)) {
97
+ const command = `seji status ${design} ${id} resolved --reply "Done in the editor agent"`
98
+ await tool(turn, 'Bash', { command, description: `Mark ${id} handled` }, () => runCli(root, ['status', design, id, 'resolved', '--reply', 'Done in the editor agent']))
99
+ }
100
+ await stream(
101
+ turn,
102
+ `Done with **${Math.min(ids.length, 2)}** of ${ids.length}:\n\n- Primary buttons now use \`--ds-accent\`\n- The marked items are \`resolved\`\n\n| item | result |\n| --- | --- |\n${ids.map((id, index) => `| ${id} | ${index < 2 ? 'resolved' : 'left open'} |`).join('\n')}\n`,
103
+ )
104
+ return
105
+ }
106
+ await stream(turn, `You said: ${text.split('\n\n').pop()}\n\nNothing to change.`)
107
+ },
108
+ })
109
+ // A model menu like a vendor runtime's. The scripted runtime has no effort channel, so the
110
+ // fake takes `effort` only for a model that lists levels (and refuses it otherwise, like oar).
111
+ const fakeModels = [
112
+ { id: 'fake-1', displayName: 'Fake 1', effortLevels: ['low', 'medium', 'high'], defaultEffort: 'medium' },
113
+ { id: 'fake-mini', displayName: 'Fake mini' },
114
+ ]
115
+ return Object.assign(Object.create(runtime), {
116
+ listModels: async () => ({ kind: 'ok', models: fakeModels }),
117
+ session: (installation, options = {}) => {
118
+ const { effort, ...rest } = options
119
+ const levels = fakeModels.find((item) => item.id === rest.model)?.effortLevels ?? []
120
+ if (effort !== undefined && !levels.includes(effort)) {
121
+ return Promise.reject(new Error(`fake lists no effort "${effort}" for ${rest.model ?? 'its default model'}`))
122
+ }
123
+ return runtime.session(installation, rest)
124
+ },
125
+ })
126
+ }
127
+
128
+ /** `{ id, runtime, classifyAs }` for every candidate oar can load. Never throws. */
129
+ export async function loadRuntimes({ env = process.env, root } = {}) {
130
+ const ids = candidateIds(env)
131
+ const entries = []
132
+ const problems = []
133
+ for (const id of ids) {
134
+ try {
135
+ if (id === 'fake' || id === 'fake-b') {
136
+ // `fake-b`: a second scripted agent, for the switcher.
137
+ const name = id === 'fake' ? 'Fake agent' : 'Fake agent B'
138
+ entries.push({ id, runtime: await fakeRuntime({ root, id, name, delayMs: Number(toolEnv('AGENT_FAKE_DELAY', env) ?? 40) }), classifyAs: 'claude' })
139
+ } else if (id === 'claude') {
140
+ const { claudeRuntime } = await import('@botiverse/oar/runtimes/claude')
141
+ entries.push({ id, runtime: claudeRuntime, classifyAs: 'claude' })
142
+ } else if (id === 'codex') {
143
+ const { codexRuntime } = await import('@botiverse/oar/runtimes/codex')
144
+ entries.push({ id, runtime: codexRuntime, classifyAs: 'codex' })
145
+ } else if (id === 'pi') {
146
+ const { createPiRuntime } = await import('@botiverse/oar/runtimes/pi')
147
+ // The person's own `pi` CLI (their login and settings), one process per session.
148
+ entries.push({ id, runtime: createPiRuntime({ execution: 'subprocess', command: 'pi' }), classifyAs: 'pi' })
149
+ }
150
+ } catch (error) {
151
+ problems.push(`${id}: ${error instanceof Error ? error.message : String(error)}`)
152
+ }
153
+ }
154
+ return { entries, problems }
155
+ }
156
+
157
+ export const DEFAULT_AGENT = 'claude'