@dxos/plugin-script 0.8.4-main.72ec0f3 → 0.8.4-main.937b3ca

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 (375) hide show
  1. package/dist/lib/browser/DeploymentDialog-GXNRUXF6.mjs +14 -0
  2. package/dist/lib/browser/{NotebookContainer-RTESC4OV.mjs → NotebookContainer-4MM2VAQF.mjs} +267 -239
  3. package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs +149 -0
  5. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs.map +7 -0
  6. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs +68 -0
  7. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs +17 -0
  9. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs.map +7 -0
  10. package/dist/lib/browser/blueprints/index.mjs +8 -0
  11. package/dist/lib/browser/chunk-3O2DQGCP.mjs +113 -0
  12. package/dist/lib/browser/chunk-3O2DQGCP.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-BTWHM6FH.mjs +270 -0
  14. package/dist/lib/browser/chunk-BTWHM6FH.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
  16. package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
  18. package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-IQRLM6JK.mjs +137 -0
  20. package/dist/lib/browser/chunk-IQRLM6JK.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-NWSK27QB.mjs +606 -0
  22. package/dist/lib/browser/chunk-NWSK27QB.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-2G2NA6DQ.mjs → chunk-UX4GHJ5E.mjs} +28 -11
  24. package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
  25. package/dist/lib/browser/{chunk-5JSNQYZZ.mjs → chunk-WX2NVNFQ.mjs} +236 -196
  26. package/dist/lib/browser/chunk-WX2NVNFQ.mjs.map +7 -0
  27. package/dist/lib/browser/{chunk-EB6AXFXO.mjs → chunk-WYR4QHPE.mjs} +1 -1
  28. package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
  29. package/dist/lib/browser/compiler-XRBFQFXO.mjs +161 -0
  30. package/dist/lib/browser/compiler-XRBFQFXO.mjs.map +7 -0
  31. package/dist/lib/browser/index.mjs +96 -125
  32. package/dist/lib/browser/index.mjs.map +4 -4
  33. package/dist/lib/browser/meta.json +1 -1
  34. package/dist/lib/browser/operation-resolver-MUNR376F.mjs +82 -0
  35. package/dist/lib/browser/operation-resolver-MUNR376F.mjs.map +7 -0
  36. package/dist/lib/browser/{react-surface-QEQ3QUQA.mjs → react-surface-5TEC66UY.mjs} +53 -42
  37. package/dist/lib/browser/react-surface-5TEC66UY.mjs.map +7 -0
  38. package/dist/lib/browser/settings-R4WKREUJ.mjs +35 -0
  39. package/dist/lib/browser/settings-R4WKREUJ.mjs.map +7 -0
  40. package/dist/lib/browser/templates/index.mjs +1 -1
  41. package/dist/lib/browser/types/index.mjs +9 -5
  42. package/dist/lib/node-esm/{DeploymentDialog-GL5AUWMR.mjs → DeploymentDialog-EVFV2VJT.mjs} +6 -6
  43. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs.map +7 -0
  44. package/dist/lib/node-esm/{NotebookContainer-SVD3A3D6.mjs → NotebookContainer-QLW5ZYGS.mjs} +267 -239
  45. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs.map +7 -0
  46. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs +150 -0
  47. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs.map +7 -0
  48. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs +69 -0
  49. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs.map +7 -0
  50. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs +18 -0
  51. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs.map +7 -0
  52. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  53. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  54. package/dist/lib/node-esm/{chunk-57JA6XL5.mjs → chunk-4F5FJZ36.mjs} +28 -11
  55. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-IBV2DR36.mjs → chunk-5HSJPAK7.mjs} +1 -1
  57. package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs +114 -0
  59. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs.map +7 -0
  60. package/dist/lib/node-esm/{chunk-IQTBVH4L.mjs → chunk-MGWKULCD.mjs} +236 -196
  61. package/dist/lib/node-esm/chunk-MGWKULCD.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
  63. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs +271 -0
  65. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
  67. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs +138 -0
  69. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs +607 -0
  71. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs.map +7 -0
  72. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs +162 -0
  73. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs.map +7 -0
  74. package/dist/lib/node-esm/index.mjs +96 -125
  75. package/dist/lib/node-esm/index.mjs.map +4 -4
  76. package/dist/lib/node-esm/meta.json +1 -1
  77. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs +83 -0
  78. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs.map +7 -0
  79. package/dist/lib/node-esm/{react-surface-U77YT7VF.mjs → react-surface-O3UDMKOQ.mjs} +53 -42
  80. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs.map +7 -0
  81. package/dist/lib/node-esm/settings-OFIMHU7K.mjs +36 -0
  82. package/dist/lib/node-esm/settings-OFIMHU7K.mjs.map +7 -0
  83. package/dist/lib/node-esm/templates/index.mjs +1 -1
  84. package/dist/lib/node-esm/types/index.mjs +9 -5
  85. package/dist/types/src/ScriptPlugin.d.ts +2 -1
  86. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  87. package/dist/types/src/blueprints/index.d.ts +2 -0
  88. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  89. package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
  90. package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  92. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  94. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  96. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  100. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
  104. package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/index.d.ts +6 -7
  108. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  109. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  110. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  112. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  116. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/settings/index.d.ts +7 -0
  118. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/settings/settings.d.ts +9 -0
  120. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  121. package/dist/types/src/compiler/compiler.d.ts +1 -1
  122. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  123. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  124. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +4 -3
  125. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  126. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  127. package/dist/types/src/components/NotebookContainer.d.ts +3 -5
  128. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
  129. package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -247
  130. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +3 -3
  132. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
  133. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
  134. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
  135. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +5 -1
  136. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
  137. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  138. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  139. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  140. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  141. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  142. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  143. package/dist/types/src/components/ScriptContainer.d.ts +4 -5
  144. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  145. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +2 -2
  146. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  147. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +5 -1
  148. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  149. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  150. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +4 -2
  151. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  152. package/dist/types/src/components/TestPanel/TestContainer.d.ts +1 -1
  153. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  154. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +3 -2
  155. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  156. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
  157. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  158. package/dist/types/src/components/index.d.ts +2 -2
  159. package/dist/types/src/components/index.d.ts.map +1 -1
  160. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  161. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  162. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  163. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  164. package/dist/types/src/hooks/deploy.d.ts +10 -27
  165. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  166. package/dist/types/src/hooks/format.d.ts +2 -2
  167. package/dist/types/src/hooks/format.d.ts.map +1 -1
  168. package/dist/types/src/hooks/index.d.ts +1 -0
  169. package/dist/types/src/hooks/index.d.ts.map +1 -1
  170. package/dist/types/src/hooks/template.d.ts +2 -2
  171. package/dist/types/src/hooks/template.d.ts.map +1 -1
  172. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  173. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  174. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  175. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  176. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  177. package/dist/types/src/index.d.ts +1 -1
  178. package/dist/types/src/index.d.ts.map +1 -1
  179. package/dist/types/src/meta.d.ts +2 -2
  180. package/dist/types/src/meta.d.ts.map +1 -1
  181. package/dist/types/src/notebook/compute-graph.d.ts +24 -11
  182. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
  183. package/dist/types/src/templates/anthropic.d.ts +8 -0
  184. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  185. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  186. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  187. package/dist/types/src/templates/commentary.d.ts +16 -0
  188. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  189. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  190. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  191. package/dist/types/src/templates/forex.d.ts +4 -1
  192. package/dist/types/src/templates/forex.d.ts.map +1 -1
  193. package/dist/types/src/templates/index.d.ts +12 -3
  194. package/dist/types/src/templates/index.d.ts.map +1 -1
  195. package/dist/types/src/templates/ping.d.ts +1 -4
  196. package/dist/types/src/templates/ping.d.ts.map +1 -1
  197. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  198. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  199. package/dist/types/src/translations.d.ts +2 -0
  200. package/dist/types/src/translations.d.ts.map +1 -1
  201. package/dist/types/src/types/Notebook.d.ts +90 -21
  202. package/dist/types/src/types/Notebook.d.ts.map +1 -1
  203. package/dist/types/src/types/actions.d.ts +30 -44
  204. package/dist/types/src/types/actions.d.ts.map +1 -1
  205. package/dist/types/src/types/capabilities.d.ts +12 -0
  206. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  207. package/dist/types/src/types/events.d.ts +5 -0
  208. package/dist/types/src/types/events.d.ts.map +1 -0
  209. package/dist/types/src/types/index.d.ts +2 -0
  210. package/dist/types/src/types/index.d.ts.map +1 -1
  211. package/dist/types/src/util/deploy.d.ts.map +1 -1
  212. package/dist/types/src/util/functions.d.ts.map +1 -1
  213. package/dist/types/tsconfig.tsbuildinfo +1 -1
  214. package/package.json +113 -87
  215. package/src/ScriptPlugin.tsx +36 -75
  216. package/src/blueprints/index.ts +5 -0
  217. package/src/blueprints/script-blueprint.ts +24 -0
  218. package/src/capabilities/app-graph-builder/app-graph-builder.ts +55 -0
  219. package/src/capabilities/app-graph-builder/index.ts +7 -0
  220. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -94
  221. package/src/capabilities/artifact-definition/index.ts +7 -0
  222. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  223. package/src/capabilities/blueprint-definition/index.ts +7 -0
  224. package/src/capabilities/compiler/compiler.ts +103 -0
  225. package/src/capabilities/compiler/index.ts +7 -0
  226. package/src/capabilities/index.ts +6 -10
  227. package/src/capabilities/operation-resolver/index.ts +7 -0
  228. package/src/capabilities/operation-resolver/operation-resolver.ts +74 -0
  229. package/src/capabilities/react-surface/index.ts +7 -0
  230. package/src/capabilities/react-surface/react-surface.tsx +118 -0
  231. package/src/capabilities/settings/index.ts +7 -0
  232. package/src/capabilities/settings/settings.ts +32 -0
  233. package/src/compiler/compiler.ts +10 -3
  234. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +27 -23
  235. package/src/components/DeploymentDialog/DeploymentDialog.tsx +22 -42
  236. package/src/components/FrameContainer/FrameContainer.tsx +4 -2
  237. package/src/components/NotebookContainer.stories.tsx +23 -19
  238. package/src/components/NotebookContainer.tsx +54 -47
  239. package/src/components/NotebookStack/NotebookCell.tsx +22 -19
  240. package/src/components/NotebookStack/NotebookStack.stories.tsx +19 -18
  241. package/src/components/NotebookStack/NotebookStack.tsx +4 -4
  242. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  243. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  244. package/src/components/QueryEditor/index.ts +5 -0
  245. package/src/components/ScriptContainer.tsx +48 -33
  246. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +38 -15
  247. package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -17
  248. package/src/components/Settings/ScriptObjectSettings.tsx +44 -32
  249. package/src/components/Settings/ScriptPluginSettings.tsx +8 -3
  250. package/src/components/TestPanel/TestContainer.tsx +5 -5
  251. package/src/components/TestPanel/TestPanel.tsx +1 -1
  252. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +13 -8
  253. package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -68
  254. package/src/e2e/ai.test.ts +92 -0
  255. package/src/e2e/deploy.test.ts +64 -0
  256. package/src/hooks/deploy.ts +36 -28
  257. package/src/hooks/format.ts +5 -1
  258. package/src/hooks/index.ts +1 -0
  259. package/src/hooks/template.ts +15 -9
  260. package/src/hooks/useCompiler.ts +24 -0
  261. package/src/hooks/useCreateAndDeployScriptTemplates.ts +13 -19
  262. package/src/hooks/useToolbarState.ts +29 -5
  263. package/src/index.ts +1 -1
  264. package/src/meta.ts +2 -2
  265. package/src/notebook/compute-graph.test.ts +20 -8
  266. package/src/notebook/compute-graph.ts +45 -21
  267. package/src/templates/anthropic.ts +42 -0
  268. package/src/templates/chess-bot.ts +58 -0
  269. package/src/templates/commentary.ts +232 -0
  270. package/src/templates/data-generator.ts +1 -1
  271. package/src/templates/forex-effect.ts +22 -27
  272. package/src/templates/forex.ts +7 -6
  273. package/src/templates/index.ts +18 -5
  274. package/src/templates/ping.ts +14 -5
  275. package/src/testing/simulator.test.ts +40 -0
  276. package/src/translations.ts +2 -0
  277. package/src/types/Notebook.ts +10 -10
  278. package/src/types/actions.ts +17 -25
  279. package/src/types/capabilities.ts +17 -0
  280. package/src/types/events.ts +11 -0
  281. package/src/types/index.ts +2 -0
  282. package/src/types/types.ts +1 -1
  283. package/src/util/deploy.ts +23 -29
  284. package/src/util/functions.ts +27 -24
  285. package/src/vite-env.d.ts +2 -0
  286. package/dist/lib/browser/DeploymentDialog-MZX4T77L.mjs +0 -14
  287. package/dist/lib/browser/NotebookContainer-RTESC4OV.mjs.map +0 -7
  288. package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs +0 -147
  289. package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs.map +0 -7
  290. package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs +0 -66
  291. package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +0 -7
  292. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +0 -30
  293. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +0 -7
  294. package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +0 -7
  295. package/dist/lib/browser/chunk-3IJASGG5.mjs +0 -155
  296. package/dist/lib/browser/chunk-3IJASGG5.mjs.map +0 -7
  297. package/dist/lib/browser/chunk-4M7U2WVT.mjs +0 -304
  298. package/dist/lib/browser/chunk-4M7U2WVT.mjs.map +0 -7
  299. package/dist/lib/browser/chunk-5JSNQYZZ.mjs.map +0 -7
  300. package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
  301. package/dist/lib/browser/chunk-GAFCKEII.mjs +0 -646
  302. package/dist/lib/browser/chunk-GAFCKEII.mjs.map +0 -7
  303. package/dist/lib/browser/chunk-LNNCD2H4.mjs +0 -102
  304. package/dist/lib/browser/chunk-LNNCD2H4.mjs.map +0 -7
  305. package/dist/lib/browser/chunk-M6KJPUJK.mjs +0 -111
  306. package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +0 -7
  307. package/dist/lib/browser/chunk-UOQ6NCH3.mjs +0 -15
  308. package/dist/lib/browser/chunk-UOQ6NCH3.mjs.map +0 -7
  309. package/dist/lib/browser/compiler-4KHRSX7J.mjs +0 -86
  310. package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +0 -7
  311. package/dist/lib/browser/intent-resolver-AFJ575VK.mjs +0 -104
  312. package/dist/lib/browser/intent-resolver-AFJ575VK.mjs.map +0 -7
  313. package/dist/lib/browser/react-surface-QEQ3QUQA.mjs.map +0 -7
  314. package/dist/lib/browser/settings-LNLSTZM4.mjs +0 -26
  315. package/dist/lib/browser/settings-LNLSTZM4.mjs.map +0 -7
  316. package/dist/lib/node-esm/NotebookContainer-SVD3A3D6.mjs.map +0 -7
  317. package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs +0 -148
  318. package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs.map +0 -7
  319. package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs +0 -67
  320. package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +0 -7
  321. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +0 -31
  322. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +0 -7
  323. package/dist/lib/node-esm/chunk-55JZVM6K.mjs +0 -16
  324. package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
  325. package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +0 -7
  326. package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +0 -113
  327. package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +0 -7
  328. package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
  329. package/dist/lib/node-esm/chunk-IQTBVH4L.mjs.map +0 -7
  330. package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs +0 -647
  331. package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs.map +0 -7
  332. package/dist/lib/node-esm/chunk-NNHWLRHT.mjs +0 -103
  333. package/dist/lib/node-esm/chunk-NNHWLRHT.mjs.map +0 -7
  334. package/dist/lib/node-esm/chunk-RIE676OW.mjs +0 -156
  335. package/dist/lib/node-esm/chunk-RIE676OW.mjs.map +0 -7
  336. package/dist/lib/node-esm/chunk-YRTA4EHU.mjs +0 -305
  337. package/dist/lib/node-esm/chunk-YRTA4EHU.mjs.map +0 -7
  338. package/dist/lib/node-esm/compiler-DU5NQISX.mjs +0 -87
  339. package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +0 -7
  340. package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs +0 -105
  341. package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs.map +0 -7
  342. package/dist/lib/node-esm/react-surface-U77YT7VF.mjs.map +0 -7
  343. package/dist/lib/node-esm/settings-IUFMOCXY.mjs +0 -27
  344. package/dist/lib/node-esm/settings-IUFMOCXY.mjs.map +0 -7
  345. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  346. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  347. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  348. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  349. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  350. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  351. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  352. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  353. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  354. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  355. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  356. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  357. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  358. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  359. package/dist/types/src/capabilities/settings.d.ts +0 -4
  360. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  361. package/dist/types/src/events.d.ts +0 -4
  362. package/dist/types/src/events.d.ts.map +0 -1
  363. package/dist/types/src/templates/chess.d.ts +0 -3
  364. package/dist/types/src/templates/chess.d.ts.map +0 -1
  365. package/src/capabilities/app-graph-builder.ts +0 -65
  366. package/src/capabilities/blueprint-definition.ts +0 -30
  367. package/src/capabilities/capabilities.ts +0 -12
  368. package/src/capabilities/compiler.ts +0 -34
  369. package/src/capabilities/intent-resolver.ts +0 -86
  370. package/src/capabilities/react-surface.tsx +0 -103
  371. package/src/capabilities/settings.ts +0 -21
  372. package/src/events.ts +0 -11
  373. package/src/templates/chess.ts +0 -49
  374. /package/dist/lib/browser/{DeploymentDialog-MZX4T77L.mjs.map → DeploymentDialog-GXNRUXF6.mjs.map} +0 -0
  375. /package/dist/lib/{node-esm/DeploymentDialog-GL5AUWMR.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -0,0 +1,232 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as A from '@automerge/automerge';
6
+ import { Chess as ChessJS } from 'chess.js';
7
+ import * as Array from 'effect/Array';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Function from 'effect/Function';
10
+ import * as Layer from 'effect/Layer';
11
+ import * as Option from 'effect/Option';
12
+ import * as Schema from 'effect/Schema';
13
+
14
+ import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
15
+ import { AiSession, GenerationObserver } from '@dxos/assistant';
16
+ import { ArtifactId } from '@dxos/assistant';
17
+ import { Database, Filter, Obj, Ref, Relation, Type } from '@dxos/echo';
18
+ import { createDocAccessor } from '@dxos/echo-db';
19
+ import { TracingService, defineFunction } from '@dxos/functions';
20
+ import { log } from '@dxos/log';
21
+ import { Chess } from '@dxos/plugin-chess/types';
22
+ import { Markdown } from '@dxos/plugin-markdown/types';
23
+ import { Collection, Text } from '@dxos/schema';
24
+ import { HasSubject } from '@dxos/types';
25
+ import { trim } from '@dxos/util';
26
+
27
+ export default defineFunction({
28
+ key: 'dxos.org/function/chess/commentary',
29
+ name: 'Commentary',
30
+ description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',
31
+ inputSchema: Schema.Struct({
32
+ game: Type.Ref(Chess.Game).annotations({
33
+ description: 'The chess game to comment on.',
34
+ }),
35
+ }),
36
+ outputSchema: Schema.Union(
37
+ Schema.Struct({
38
+ documentId: ArtifactId.annotations({
39
+ description: 'The ID of the markdown document that was updated or created.',
40
+ }),
41
+ commentary: Schema.String.annotations({
42
+ description: 'The commentary that was added.',
43
+ }),
44
+ }),
45
+ Schema.Void.annotations({
46
+ description: 'Function did not find anything to comment on.',
47
+ }),
48
+ ),
49
+ types: [Chess.Game, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],
50
+ services: [AiService.AiService, Database.Service],
51
+ handler: Effect.fnUntraced(
52
+ function* ({ data: { game: gameRef } }) {
53
+ // Load the chess game
54
+ log.info('load game', { gameRef });
55
+ const chessGame = yield* Database.Service.load(gameRef);
56
+
57
+ // Load the chess position from PGN or FEN
58
+ const chess = new ChessJS();
59
+ if (chessGame.pgn) {
60
+ chess.loadPgn(chessGame.pgn);
61
+ } else if (chessGame.fen) {
62
+ chess.load(chessGame.fen);
63
+ } else {
64
+ log.info('Early return: no pgn or fen');
65
+ return;
66
+ }
67
+
68
+ // Get the most recent move
69
+ const history = chess.history({ verbose: true });
70
+ if (history.length === 0) {
71
+ throw new Error('No moves have been played yet');
72
+ }
73
+ const lastMove = history[history.length - 1];
74
+ const moveNumber = Math.ceil(history.length / 2);
75
+ const isWhiteMove = history.length % 2 === 1;
76
+ const player = isWhiteMove ? 'White' : 'Black';
77
+ const moveNotation = lastMove.san;
78
+
79
+ // Generate AI commentary about the move
80
+ const result = yield* new AiSession().run({
81
+ prompt:
82
+ `Comment on this chess move as if you're commentating a live match for an audience:\n\n` +
83
+ `Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\n` +
84
+ `Current position: ${chess.fen()}\n` +
85
+ `${chess.isCheck() ? 'The king is in check! ' : ''}` +
86
+ `${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +
87
+ `${chess.isStalemate() ? 'STALEMATE! ' : ''}` +
88
+ `\nGame so far:\n${chess.pgn()}`,
89
+ system: COMMENTARY_SYSTEM_PROMPT,
90
+ history: [],
91
+ observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),
92
+ });
93
+
94
+ const commentaryText = Function.pipe(
95
+ result,
96
+ Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
97
+ Option.flatMap((msg) =>
98
+ Function.pipe(
99
+ msg.blocks,
100
+ Array.findLast((block) => block._tag === 'text'),
101
+ Option.map((block) => block.text),
102
+ ),
103
+ ),
104
+ Option.getOrThrowWith(() => new Error('No commentary generated')),
105
+ );
106
+
107
+ const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\n\n${commentaryText}\n\n`;
108
+ log.info('commentary', { commentary });
109
+
110
+ // TODO(wittjosiah): Functions currently don't support traversals.
111
+ // const docs = yield* Database.Service.runQuery(
112
+ // Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),
113
+ // ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));
114
+ const docs = yield* Database.Service.runQuery(Filter.type(HasSubject.HasSubject)).pipe(
115
+ Effect.map((relations) =>
116
+ relations.filter((relation) => {
117
+ // TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.
118
+ try {
119
+ log.info('relation', {
120
+ source: Obj.getDXN(Relation.getTarget(relation)).toString(),
121
+ game: Obj.getDXN(chessGame).toString(),
122
+ });
123
+ return Obj.getDXN(Relation.getTarget(relation)).toString() === Obj.getDXN(chessGame).toString();
124
+ } catch {
125
+ return false;
126
+ }
127
+ }),
128
+ ),
129
+ Effect.map((relations) =>
130
+ relations
131
+ .map((relation) => {
132
+ // TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.
133
+ try {
134
+ return Relation.getSource(relation);
135
+ } catch {
136
+ return undefined;
137
+ }
138
+ })
139
+ .filter((source) => source !== undefined),
140
+ ),
141
+ Effect.map((sources) => {
142
+ const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));
143
+ log.info('docs', { sources, docs });
144
+ return docs;
145
+ }),
146
+ );
147
+ log.info('docs', { count: docs.length });
148
+
149
+ let document: Markdown.Document;
150
+ if (docs.length === 0) {
151
+ // TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.
152
+ const [properties] = yield* Database.Service.runQuery(Filter.typename('dxos.org/type/Properties'));
153
+ const rootCollection = yield* Database.Service.load<Collection.Collection>(
154
+ properties[Collection.Collection.typename],
155
+ );
156
+
157
+ log.info('rootCollection', { rootCollection });
158
+
159
+ // Create a new markdown document
160
+ const gameName = chessGame.name || 'Chess Game';
161
+ document = yield* Database.Service.add(
162
+ Markdown.make({
163
+ name: `${gameName} Commentary`,
164
+ content: `# ${gameName} Commentary\n\n${commentary}`,
165
+ }),
166
+ );
167
+
168
+ const documentRef = Ref.make(document);
169
+ Obj.change(rootCollection, (c) => {
170
+ c.objects.push(documentRef);
171
+ });
172
+
173
+ // Create the HasSubject relation
174
+ yield* Database.Service.add(
175
+ Relation.make(HasSubject.HasSubject, {
176
+ [Relation.Source]: document,
177
+ [Relation.Target]: chessGame,
178
+ completedAt: new Date().toISOString(),
179
+ }),
180
+ );
181
+ } else {
182
+ document = docs[0];
183
+
184
+ // Load the text content and append the commentary
185
+ const text = yield* Database.Service.load(document.content);
186
+ const accessor = createDocAccessor(text, ['content']);
187
+ accessor.handle.change((doc: A.Doc<Text.Text>) => {
188
+ A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);
189
+ });
190
+ }
191
+
192
+ log.info('result', { documentId: Obj.getDXN(document).toString(), commentary });
193
+
194
+ yield* Database.Service.flush();
195
+
196
+ return {
197
+ documentId: Obj.getDXN(document).toString(),
198
+ commentary,
199
+ };
200
+ },
201
+ Effect.provide(
202
+ Layer.mergeAll(
203
+ AiService.model('@anthropic/claude-haiku-4-5'),
204
+ ToolResolverService.layerEmpty,
205
+ ToolExecutionService.layerEmpty,
206
+ TracingService.layerNoop,
207
+ ),
208
+ ),
209
+ ),
210
+ });
211
+
212
+ const COMMENTARY_SYSTEM_PROMPT = trim`
213
+ You are a professional chess commentator providing live commentary for a chess match.
214
+
215
+ # Style
216
+ - Write in an engaging, enthusiastic style as if commentating for a live audience
217
+ - Be concise but informative (2-4 sentences)
218
+ - Explain the strategic implications of the move
219
+ - Note any tactical elements (captures, threats, checks)
220
+ - Comment on the position and what it means for the game
221
+
222
+ # Format
223
+ - Write in plain text (no markdown formatting in the commentary itself)
224
+ - Be natural and conversational
225
+ - Use chess terminology appropriately but keep it accessible
226
+
227
+ # Special Situations
228
+ - If it's checkmate, express excitement about the conclusion
229
+ - If it's check, note the pressure on the king
230
+ - If a piece is captured, mention the material exchange
231
+ - Comment on the development of pieces and control of key squares when relevant
232
+ `;
@@ -23,7 +23,7 @@ export default defineFunction({
23
23
  data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
24
24
  context: { space },
25
25
  }: any) => {
26
- await space.db.graph.schemaRegistry.addSchema([Expando]);
26
+ await space.db.graph.schemaRegistry.register([Expando]);
27
27
  const result: Record<string, any> = {};
28
28
  const objects: Expando[] = [];
29
29
 
@@ -2,41 +2,36 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- // @ts-ignore
6
- import { S, defineFunction } from 'dxos:functions';
7
- import {
8
- FetchHttpClient,
9
- HttpClient,
10
- HttpClientRequest,
11
- // @ts-ignore
12
- } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
13
- // @ts-ignore
14
- import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
15
- // @ts-ignore
16
- import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
5
+ import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
6
+ import * as HttpClient from '@effect/platform/HttpClient';
7
+ import * as HttpClientRequest from '@effect/platform/HttpClientRequest';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Schedule from 'effect/Schedule';
10
+ import * as Schema from 'effect/Schema';
11
+
12
+ import { defineFunction } from '@dxos/functions';
17
13
 
18
14
  export default defineFunction({
19
15
  key: 'dxos.org/script/forex-effect',
20
16
  name: 'Forex Effect',
21
17
  description: 'Returns the exchange rate between two currencies.',
22
18
 
23
- inputSchema: S.Struct({
24
- from: S.String.annotations({ description: 'The source currency' }),
25
- to: S.String.annotations({ description: 'The target currency' }),
19
+ inputSchema: Schema.Struct({
20
+ from: Schema.String.annotations({ description: 'The source currency' }),
21
+ to: Schema.String.annotations({ description: 'The target currency' }),
26
22
  }),
27
23
 
28
- outputSchema: S.String.annotations({ description: 'The exchange rate between the two currencies' }),
24
+ outputSchema: Schema.String.annotations({ description: 'The exchange rate between the two currencies' }),
29
25
 
30
- handler: async ({ data: { from, to } }: any) =>
31
- Effect.gen(function* () {
32
- const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
33
- HttpClient.execute,
34
- Effect.flatMap((res: any) => res.json),
35
- Effect.timeout('1 second'),
36
- Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
37
- Effect.scoped,
38
- );
26
+ handler: Effect.fnUntraced(function* ({ data: { from, to } }) {
27
+ const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
28
+ HttpClient.execute,
29
+ Effect.flatMap((res: any) => res.json),
30
+ Effect.timeout('1 second'),
31
+ Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
32
+ Effect.scoped,
33
+ );
39
34
 
40
- return res.data.rates[to].toString();
41
- }).pipe(Effect.provide(FetchHttpClient.layer)),
35
+ return (res as any).data.rates[to].toString();
36
+ }, Effect.provide(FetchHttpClient.layer)),
42
37
  });
@@ -2,20 +2,21 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- // @ts-ignore
6
- import { S, defineFunction } from 'dxos:functions';
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { defineFunction } from '@dxos/functions';
7
8
 
8
9
  export default defineFunction({
9
10
  key: 'dxos.org/script/forex',
10
11
  name: 'Forex',
11
12
  description: 'Returns the exchange rate between two currencies.',
12
13
 
13
- inputSchema: S.Struct({
14
- from: S.String.annotations({ description: 'The source currency' }),
15
- to: S.String.annotations({ description: 'The target currency' }),
14
+ inputSchema: Schema.Struct({
15
+ from: Schema.String.annotations({ description: 'The source currency' }),
16
+ to: Schema.String.annotations({ description: 'The target currency' }),
16
17
  }),
17
18
 
18
- handler: async ({ data: { from, to } }: any) => {
19
+ handler: async ({ data: { from, to } }) => {
19
20
  const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);
20
21
  const {
21
22
  data: { rates },
@@ -2,8 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import anthropic from './anthropic.ts?raw';
5
6
  import chat from './chat.ts?raw';
6
- import chess from './chess.ts?raw';
7
+ import chessBot from './chess-bot.ts?raw';
8
+ import commentary from './commentary.ts?raw';
7
9
  import dataGenerator from './data-generator.ts?raw';
8
10
  import discord from './discord.ts?raw';
9
11
  import email from './email.ts?raw';
@@ -46,10 +48,10 @@ export const templates = [
46
48
  presetId: 'dxos.org/function/gpt',
47
49
  },
48
50
  {
49
- id: 'dxos.org/script/chess',
50
- name: 'Chess',
51
- source: removeHeader(chess),
52
- presetId: 'dxos.org/function/chess',
51
+ id: 'dxos.org/script/chess-bot',
52
+ name: 'Chess Bot',
53
+ source: removeHeader(chessBot),
54
+ presetId: 'dxos.org/function/chess-bot',
53
55
  },
54
56
  {
55
57
  id: 'dxos.org/script/email',
@@ -75,4 +77,15 @@ export const templates = [
75
77
  source: removeHeader(dataGenerator),
76
78
  presetId: 'dxos.org/function/data-generator',
77
79
  },
80
+ {
81
+ id: 'dxos.org/script/anthropic',
82
+ name: 'Anthropic',
83
+ source: removeHeader(anthropic),
84
+ },
85
+ {
86
+ id: 'dxos.org/script/commentary',
87
+ name: 'Commentary',
88
+ source: removeHeader(commentary),
89
+ presetId: 'dxos.org/function/chess/commentary',
90
+ },
78
91
  ] as const;
@@ -1,8 +1,17 @@
1
1
  //
2
- // Copyright 2024 DXOS.org
2
+ // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- /**
6
- * Echos the request data.
7
- */
8
- export default async ({ data }: any) => data;
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { defineFunction } from '@dxos/functions';
8
+
9
+ export default defineFunction({
10
+ key: 'dxos.org/script/ping',
11
+ name: 'Ping',
12
+ inputSchema: Schema.Any,
13
+
14
+ handler: async ({ data }) => {
15
+ return data;
16
+ },
17
+ });
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { readFile } from 'node:fs/promises';
6
+
7
+ import * as Record from 'effect/Record';
8
+ import { describe, expect, test } from 'vitest';
9
+
10
+ import { bundleFunction } from '@dxos/functions-runtime/bundler';
11
+ import { FunctionWorker } from '@dxos/functions-simulator-cloudflare';
12
+ import { ErrorCodec } from '@dxos/protocols';
13
+
14
+ // Requires downloading assets from R2
15
+ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('Run script in sumulator', () => {
16
+ test('forex-effect', { timeout: 120_000 }, async () => {
17
+ const source = await readFile(new URL('../templates/forex-effect.ts', import.meta.url), 'utf-8');
18
+
19
+ // Bundle and upload.
20
+ const buildResult = await bundleFunction({ source });
21
+ if ('error' in buildResult) {
22
+ throw buildResult.error ?? new Error('Bundle creation failed');
23
+ }
24
+
25
+ const worker = new FunctionWorker({
26
+ mainModule: buildResult.entryPoint,
27
+ modules: Record.map(buildResult.assets, (contents, filename) => ({
28
+ contents: contents as Uint8Array<ArrayBuffer>,
29
+ contentType: filename.endsWith('.wasm') ? 'application/wasm' : 'application/javascript',
30
+ })),
31
+ });
32
+
33
+ const result = await worker.invoke({ from: 'USD', to: 'EUR' });
34
+ console.log(result);
35
+ if (result._kind === 'error') {
36
+ throw ErrorCodec.decode(result.error);
37
+ }
38
+ expect(Number(result.result)).toBeGreaterThan(0);
39
+ });
40
+ });
@@ -19,6 +19,7 @@ export const translations = [
19
19
  'object name placeholder': 'New script',
20
20
  'rename object label': 'Rename script',
21
21
  'delete object label': 'Delete script',
22
+ 'object deleted label': 'Script deleted',
22
23
  },
23
24
  [Notebook.Notebook.typename]: {
24
25
  'typename label': 'Notebook',
@@ -28,6 +29,7 @@ export const translations = [
28
29
  'object name placeholder': 'New notebook',
29
30
  'rename object label': 'Rename notebook',
30
31
  'delete object label': 'Delete notebook',
32
+ 'object deleted label': 'Notebook deleted',
31
33
  },
32
34
  [meta.id]: {
33
35
  'plugin name': 'Scripts',
@@ -6,30 +6,30 @@ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { Prompt } from '@dxos/blueprints';
8
8
  import { Obj, Type } from '@dxos/echo';
9
- import { FormAnnotation } from '@dxos/echo/internal';
9
+ import { FormInputAnnotation } from '@dxos/echo/internal';
10
10
  import { LabelAnnotation } from '@dxos/echo/internal';
11
- import { Text, View } from '@dxos/schema';
11
+ import { Graph } from '@dxos/plugin-explorer/types';
12
+ import { Text } from '@dxos/schema';
12
13
 
13
14
  export type CellType = 'markdown' | 'script' | 'query' | 'prompt' | 'view';
14
15
 
15
- const Cell_ = Schema.Struct({
16
+ export const Cell = Schema.Struct({
16
17
  id: Schema.String,
17
18
  type: Schema.String,
18
19
  name: Schema.optional(Schema.String),
19
20
  // TODO(burdon): Union type.
20
21
  source: Schema.optional(Type.Ref(Text.Text)),
21
22
  prompt: Schema.optional(Type.Ref(Prompt.Prompt)),
22
- view: Schema.optional(Type.Ref(View.View)),
23
+ graph: Schema.optional(Type.Ref(Graph.Graph)),
23
24
  }).pipe(Schema.mutable);
24
- export interface Cell extends Schema.Schema.Type<typeof Cell_> {}
25
- export interface Cell_Encoded extends Schema.Schema.Encoded<typeof Cell_> {}
26
- export const Cell: Schema.Schema<Cell, Cell_Encoded> = Cell_;
25
+
26
+ export interface Cell extends Schema.Schema.Type<typeof Cell> {}
27
27
 
28
28
  export const Notebook = Schema.Struct({
29
29
  name: Schema.String.pipe(Schema.optional),
30
- cells: Cell.pipe(Schema.Array, Schema.mutable, FormAnnotation.set(false)),
30
+ cells: Cell.pipe(Schema.Array, Schema.mutable, FormInputAnnotation.set(false)),
31
31
  }).pipe(
32
- Type.Obj({
32
+ Type.object({
33
33
  typename: 'dxos.org/type/Notebook',
34
34
  version: '0.1.0',
35
35
  }),
@@ -38,4 +38,4 @@ export const Notebook = Schema.Struct({
38
38
 
39
39
  export type Notebook = Schema.Schema.Type<typeof Notebook>;
40
40
 
41
- export const make = (props: Obj.MakeProps<typeof Notebook> = { cells: [] }) => Obj.make(Notebook, props);
41
+ export const make = (props: Obj.MakeProps<typeof Notebook> = { cells: [] }): Notebook => Obj.make(Notebook, props);
@@ -4,15 +4,16 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { SpaceSchema } from '@dxos/client/echo';
7
+ import { Database } from '@dxos/echo';
8
8
  import { Script } from '@dxos/functions';
9
+ import { Operation } from '@dxos/operation';
9
10
 
10
11
  import { meta } from '../meta';
11
12
  import { templates } from '../templates';
12
13
 
13
- import * as Notebook from './Notebook';
14
+ const SCRIPT_OPERATION = `${meta.id}/operation`;
14
15
 
15
- export namespace ScriptAction {
16
+ export namespace ScriptOperation {
16
17
  export const ScriptProps = Schema.Struct({
17
18
  name: Schema.optional(Schema.String),
18
19
  // TODO(wittjosiah): Placeholder annotation?
@@ -23,31 +24,22 @@ export namespace ScriptAction {
23
24
  ),
24
25
  });
25
26
 
26
- export class CreateScript extends Schema.TaggedClass<CreateScript>()(`${meta.id}/action/create-script`, {
27
- input: Schema.extend(
28
- ScriptProps,
29
- Schema.Struct({
30
- space: SpaceSchema,
31
- }),
32
- ),
33
- output: Schema.Struct({
34
- object: Script.Script,
35
- }),
36
- }) {}
37
-
38
27
  export const NotebookProps = Schema.Struct({
39
28
  name: Schema.optional(Schema.String),
40
29
  });
41
30
 
42
- export class CreateNotebook extends Schema.TaggedClass<CreateNotebook>()(`${meta.id}/action/create-notebook`, {
43
- input: Schema.extend(
44
- NotebookProps,
45
- Schema.Struct({
46
- space: SpaceSchema,
31
+ export const CreateScript = Operation.make({
32
+ meta: { key: `${SCRIPT_OPERATION}/create-script`, name: 'Create Script' },
33
+ schema: {
34
+ input: Schema.extend(
35
+ ScriptProps,
36
+ Schema.Struct({
37
+ db: Database.Database,
38
+ }),
39
+ ),
40
+ output: Schema.Struct({
41
+ object: Script.Script,
47
42
  }),
48
- ),
49
- output: Schema.Struct({
50
- object: Notebook.Notebook,
51
- }),
52
- }) {}
43
+ },
44
+ });
53
45
  }
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Atom } from '@effect-atom/atom-react';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+
9
+ import { type Compiler } from '../compiler';
10
+ import { meta } from '../meta';
11
+
12
+ import { type ScriptSettings } from './types';
13
+
14
+ export namespace ScriptCapabilities {
15
+ export const Settings = Capability.make<Atom.Writable<ScriptSettings>>(`${meta.id}/capability/settings`);
16
+ export const Compiler = Capability.make<Compiler>(`${meta.id}/capability/compiler`);
17
+ }
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { ActivationEvent } from '@dxos/app-framework';
6
+
7
+ import { meta } from '../meta';
8
+
9
+ export namespace ScriptEvents {
10
+ export const SetupCompiler = ActivationEvent.make(`${meta.id}/event/setup-compiler`);
11
+ }
@@ -3,5 +3,7 @@
3
3
  //
4
4
 
5
5
  export * from './actions';
6
+ export * from './capabilities';
7
+ export * from './events';
6
8
  export * as Notebook from './Notebook';
7
9
  export * from './types';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { EditorInputMode } from '@dxos/react-ui-editor';
7
+ import { EditorInputMode } from '@dxos/ui-editor';
8
8
 
9
9
  export const ScriptSettings = Schema.mutable(
10
10
  Schema.Struct({