@dxos/plugin-script 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (426) hide show
  1. package/dist/lib/browser/DeploymentDialog-GXNRUXF6.mjs +14 -0
  2. package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs +845 -0
  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-J5LGTIGS.mjs +10 -0
  22. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-NWSK27QB.mjs +606 -0
  24. package/dist/lib/browser/chunk-NWSK27QB.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-UX4GHJ5E.mjs +105 -0
  26. package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-WX2NVNFQ.mjs +557 -0
  28. package/dist/lib/browser/chunk-WX2NVNFQ.mjs.map +7 -0
  29. package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-WYR4QHPE.mjs} +8 -5
  30. package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
  31. package/dist/lib/browser/compiler-XRBFQFXO.mjs +161 -0
  32. package/dist/lib/browser/compiler-XRBFQFXO.mjs.map +7 -0
  33. package/dist/lib/browser/index.mjs +137 -103
  34. package/dist/lib/browser/index.mjs.map +4 -4
  35. package/dist/lib/browser/meta.json +1 -1
  36. package/dist/lib/browser/operation-resolver-MUNR376F.mjs +82 -0
  37. package/dist/lib/browser/operation-resolver-MUNR376F.mjs.map +7 -0
  38. package/dist/lib/browser/react-surface-5TEC66UY.mjs +139 -0
  39. package/dist/lib/browser/react-surface-5TEC66UY.mjs.map +7 -0
  40. package/dist/lib/browser/settings-R4WKREUJ.mjs +35 -0
  41. package/dist/lib/browser/settings-R4WKREUJ.mjs.map +7 -0
  42. package/dist/lib/browser/templates/index.mjs +2 -1
  43. package/dist/lib/browser/types/index.mjs +14 -6
  44. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs +15 -0
  45. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs.map +7 -0
  46. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs +846 -0
  47. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs.map +7 -0
  48. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs +150 -0
  49. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs.map +7 -0
  50. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs +69 -0
  51. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs.map +7 -0
  52. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs +18 -0
  53. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs.map +7 -0
  54. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  55. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  56. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs +107 -0
  57. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-5HSJPAK7.mjs} +8 -5
  59. package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  61. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs +114 -0
  63. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-MGWKULCD.mjs +558 -0
  65. package/dist/lib/node-esm/chunk-MGWKULCD.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
  67. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs +271 -0
  69. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
  71. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs +138 -0
  73. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs +607 -0
  75. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs.map +7 -0
  76. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs +162 -0
  77. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs.map +7 -0
  78. package/dist/lib/node-esm/index.mjs +137 -103
  79. package/dist/lib/node-esm/index.mjs.map +4 -4
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs +83 -0
  82. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs.map +7 -0
  83. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs +140 -0
  84. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs.map +7 -0
  85. package/dist/lib/node-esm/settings-OFIMHU7K.mjs +36 -0
  86. package/dist/lib/node-esm/settings-OFIMHU7K.mjs.map +7 -0
  87. package/dist/lib/node-esm/templates/index.mjs +2 -1
  88. package/dist/lib/node-esm/types/index.mjs +14 -6
  89. package/dist/types/src/ScriptPlugin.d.ts +2 -1
  90. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  91. package/dist/types/src/blueprints/index.d.ts +2 -0
  92. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  93. package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
  94. package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  96. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  100. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  104. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
  108. package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
  110. package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/index.d.ts +6 -7
  112. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  113. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  116. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  118. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  120. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/settings/index.d.ts +7 -0
  122. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/settings/settings.d.ts +9 -0
  124. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  125. package/dist/types/src/compiler/compiler.d.ts +1 -1
  126. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  127. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +3 -3
  128. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  129. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +114 -10
  130. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
  132. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  133. package/dist/types/src/components/NotebookContainer.d.ts +8 -0
  134. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  135. package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
  136. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  137. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
  138. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
  139. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
  140. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
  141. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
  142. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  143. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
  144. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  145. package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
  146. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  147. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  148. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  149. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  150. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  151. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  152. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  153. package/dist/types/src/components/ScriptContainer.d.ts +7 -8
  154. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  155. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
  156. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  157. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +241 -2
  158. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  159. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  160. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  161. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
  162. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  163. package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
  164. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  165. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  166. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
  167. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  168. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -3
  169. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  170. package/dist/types/src/components/index.d.ts +3 -1
  171. package/dist/types/src/components/index.d.ts.map +1 -1
  172. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  173. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  174. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  175. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  176. package/dist/types/src/hooks/deploy.d.ts +16 -31
  177. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  178. package/dist/types/src/hooks/format.d.ts +4 -4
  179. package/dist/types/src/hooks/format.d.ts.map +1 -1
  180. package/dist/types/src/hooks/index.d.ts +1 -0
  181. package/dist/types/src/hooks/index.d.ts.map +1 -1
  182. package/dist/types/src/hooks/template.d.ts +6 -16
  183. package/dist/types/src/hooks/template.d.ts.map +1 -1
  184. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  185. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  186. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  187. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  188. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  189. package/dist/types/src/index.d.ts +2 -1
  190. package/dist/types/src/index.d.ts.map +1 -1
  191. package/dist/types/src/meta.d.ts +2 -3
  192. package/dist/types/src/meta.d.ts.map +1 -1
  193. package/dist/types/src/notebook/compute-graph.d.ts +58 -0
  194. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  195. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  196. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  197. package/dist/types/src/notebook/eval.d.ts +13 -0
  198. package/dist/types/src/notebook/eval.d.ts.map +1 -0
  199. package/dist/types/src/notebook/index.d.ts +2 -0
  200. package/dist/types/src/notebook/index.d.ts.map +1 -0
  201. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  202. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  203. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  204. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  205. package/dist/types/src/templates/anthropic.d.ts +8 -0
  206. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  207. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  208. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  209. package/dist/types/src/templates/commentary.d.ts +16 -0
  210. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  211. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  212. package/dist/types/src/templates/discord.d.ts.map +1 -1
  213. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  214. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  215. package/dist/types/src/templates/forex.d.ts +4 -1
  216. package/dist/types/src/templates/forex.d.ts.map +1 -1
  217. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  218. package/dist/types/src/templates/index.d.ts +52 -1
  219. package/dist/types/src/templates/index.d.ts.map +1 -1
  220. package/dist/types/src/templates/ping.d.ts +3 -0
  221. package/dist/types/src/templates/ping.d.ts.map +1 -0
  222. package/dist/types/src/testing/data.d.ts +3 -0
  223. package/dist/types/src/testing/data.d.ts.map +1 -0
  224. package/dist/types/src/testing/index.d.ts +2 -0
  225. package/dist/types/src/testing/index.d.ts.map +1 -0
  226. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  227. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  228. package/dist/types/src/translations.d.ts +31 -5
  229. package/dist/types/src/translations.d.ts.map +1 -1
  230. package/dist/types/src/types/Notebook.d.ts +100 -0
  231. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  232. package/dist/types/src/types/actions.d.ts +40 -0
  233. package/dist/types/src/types/actions.d.ts.map +1 -0
  234. package/dist/types/src/types/capabilities.d.ts +12 -0
  235. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  236. package/dist/types/src/types/events.d.ts +5 -0
  237. package/dist/types/src/types/events.d.ts.map +1 -0
  238. package/dist/types/src/types/index.d.ts +5 -1
  239. package/dist/types/src/types/index.d.ts.map +1 -1
  240. package/dist/types/src/types/types.d.ts +6 -0
  241. package/dist/types/src/types/types.d.ts.map +1 -0
  242. package/dist/types/src/util/deploy.d.ts +4 -4
  243. package/dist/types/src/util/deploy.d.ts.map +1 -1
  244. package/dist/types/src/util/functions.d.ts +6 -3
  245. package/dist/types/src/util/functions.d.ts.map +1 -1
  246. package/dist/types/tsconfig.tsbuildinfo +1 -1
  247. package/package.json +117 -82
  248. package/src/ScriptPlugin.tsx +55 -75
  249. package/src/blueprints/index.ts +5 -0
  250. package/src/blueprints/script-blueprint.ts +24 -0
  251. package/src/capabilities/app-graph-builder/app-graph-builder.ts +55 -0
  252. package/src/capabilities/app-graph-builder/index.ts +7 -0
  253. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +98 -96
  254. package/src/capabilities/artifact-definition/index.ts +7 -0
  255. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  256. package/src/capabilities/blueprint-definition/index.ts +7 -0
  257. package/src/capabilities/compiler/compiler.ts +103 -0
  258. package/src/capabilities/compiler/index.ts +7 -0
  259. package/src/capabilities/index.ts +6 -10
  260. package/src/capabilities/operation-resolver/index.ts +7 -0
  261. package/src/capabilities/operation-resolver/operation-resolver.ts +74 -0
  262. package/src/capabilities/react-surface/index.ts +7 -0
  263. package/src/capabilities/react-surface/react-surface.tsx +118 -0
  264. package/src/capabilities/settings/index.ts +7 -0
  265. package/src/capabilities/settings/settings.ts +32 -0
  266. package/src/compiler/compiler.ts +10 -3
  267. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +37 -26
  268. package/src/components/DeploymentDialog/DeploymentDialog.tsx +41 -50
  269. package/src/components/FrameContainer/FrameContainer.tsx +6 -4
  270. package/src/components/NotebookContainer.stories.tsx +87 -0
  271. package/src/components/NotebookContainer.tsx +270 -0
  272. package/src/components/NotebookStack/NotebookCell.tsx +217 -0
  273. package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
  274. package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
  275. package/src/components/NotebookStack/NotebookStack.tsx +86 -0
  276. package/src/components/NotebookStack/index.ts +6 -0
  277. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  278. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  279. package/src/components/QueryEditor/index.ts +5 -0
  280. package/src/components/ScriptContainer.tsx +50 -35
  281. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +54 -19
  282. package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -36
  283. package/src/components/Settings/ScriptObjectSettings.tsx +136 -29
  284. package/src/components/Settings/ScriptPluginSettings.tsx +11 -21
  285. package/src/components/TestPanel/TestContainer.tsx +7 -7
  286. package/src/components/TestPanel/TestPanel.tsx +42 -19
  287. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +77 -17
  288. package/src/components/TypescriptEditor/TypescriptEditor.tsx +81 -80
  289. package/src/components/index.ts +3 -0
  290. package/src/e2e/ai.test.ts +92 -0
  291. package/src/e2e/deploy.test.ts +64 -0
  292. package/src/hooks/deploy.ts +44 -37
  293. package/src/hooks/format.ts +9 -5
  294. package/src/hooks/index.ts +1 -0
  295. package/src/hooks/template.ts +20 -23
  296. package/src/hooks/useCompiler.ts +24 -0
  297. package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
  298. package/src/hooks/useToolbarState.ts +29 -5
  299. package/src/index.ts +2 -1
  300. package/src/meta.ts +9 -7
  301. package/src/notebook/compute-graph.test.ts +82 -0
  302. package/src/notebook/compute-graph.ts +230 -0
  303. package/src/notebook/eval.ts +105 -0
  304. package/src/notebook/index.ts +5 -0
  305. package/src/notebook/vfs-parser.test.ts +149 -0
  306. package/src/notebook/vfs-parser.ts +451 -0
  307. package/src/templates/anthropic.ts +42 -0
  308. package/src/templates/chess-bot.ts +58 -0
  309. package/src/templates/commentary.ts +232 -0
  310. package/src/templates/data-generator.ts +3 -1
  311. package/src/templates/discord.ts +9 -1
  312. package/src/templates/forex-effect.ts +24 -25
  313. package/src/templates/forex.ts +9 -6
  314. package/src/templates/gmail.ts +22 -11
  315. package/src/templates/index.ts +24 -11
  316. package/src/templates/ping.ts +17 -0
  317. package/src/testing/data.ts +72 -0
  318. package/src/testing/index.ts +5 -0
  319. package/src/testing/simulator.test.ts +40 -0
  320. package/src/translations.ts +34 -7
  321. package/src/types/Notebook.ts +41 -0
  322. package/src/types/actions.ts +45 -0
  323. package/src/types/capabilities.ts +17 -0
  324. package/src/types/events.ts +11 -0
  325. package/src/types/index.ts +5 -1
  326. package/src/types/types.ts +15 -0
  327. package/src/util/deploy.ts +30 -40
  328. package/src/util/functions.ts +56 -23
  329. package/src/vite-env.d.ts +2 -0
  330. package/dist/lib/browser/DeploymentDialog-QZSTVNIS.mjs +0 -12
  331. package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs +0 -265
  332. package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs.map +0 -7
  333. package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs +0 -64
  334. package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs.map +0 -7
  335. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
  336. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
  337. package/dist/lib/browser/chunk-4AUQEB2I.mjs +0 -88
  338. package/dist/lib/browser/chunk-4AUQEB2I.mjs.map +0 -7
  339. package/dist/lib/browser/chunk-5TVBECWH.mjs +0 -15
  340. package/dist/lib/browser/chunk-5TVBECWH.mjs.map +0 -7
  341. package/dist/lib/browser/chunk-B5QYN3AG.mjs +0 -556
  342. package/dist/lib/browser/chunk-B5QYN3AG.mjs.map +0 -7
  343. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  344. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  345. package/dist/lib/browser/chunk-KLGK77UK.mjs +0 -283
  346. package/dist/lib/browser/chunk-KLGK77UK.mjs.map +0 -7
  347. package/dist/lib/browser/chunk-NXKU3BNX.mjs +0 -222
  348. package/dist/lib/browser/chunk-NXKU3BNX.mjs.map +0 -7
  349. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  350. package/dist/lib/browser/chunk-YCZPTTFO.mjs +0 -153
  351. package/dist/lib/browser/chunk-YCZPTTFO.mjs.map +0 -7
  352. package/dist/lib/browser/compiler-O7MNN3XT.mjs +0 -98
  353. package/dist/lib/browser/compiler-O7MNN3XT.mjs.map +0 -7
  354. package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs +0 -89
  355. package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs.map +0 -7
  356. package/dist/lib/browser/react-surface-C4ZTW4QA.mjs +0 -104
  357. package/dist/lib/browser/react-surface-C4ZTW4QA.mjs.map +0 -7
  358. package/dist/lib/browser/settings-A4E4R7VL.mjs +0 -24
  359. package/dist/lib/browser/settings-A4E4R7VL.mjs.map +0 -7
  360. package/dist/lib/node-esm/DeploymentDialog-G6EHEPXN.mjs +0 -13
  361. package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs +0 -266
  362. package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs.map +0 -7
  363. package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs +0 -65
  364. package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs.map +0 -7
  365. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
  366. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
  367. package/dist/lib/node-esm/chunk-35M3CHYE.mjs +0 -16
  368. package/dist/lib/node-esm/chunk-35M3CHYE.mjs.map +0 -7
  369. package/dist/lib/node-esm/chunk-5OGRMRLA.mjs +0 -90
  370. package/dist/lib/node-esm/chunk-5OGRMRLA.mjs.map +0 -7
  371. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  372. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  373. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  374. package/dist/lib/node-esm/chunk-M642JUOZ.mjs +0 -223
  375. package/dist/lib/node-esm/chunk-M642JUOZ.mjs.map +0 -7
  376. package/dist/lib/node-esm/chunk-MPN2DI4P.mjs +0 -557
  377. package/dist/lib/node-esm/chunk-MPN2DI4P.mjs.map +0 -7
  378. package/dist/lib/node-esm/chunk-WXKOIREL.mjs +0 -284
  379. package/dist/lib/node-esm/chunk-WXKOIREL.mjs.map +0 -7
  380. package/dist/lib/node-esm/chunk-ZA36GO4T.mjs +0 -154
  381. package/dist/lib/node-esm/chunk-ZA36GO4T.mjs.map +0 -7
  382. package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs +0 -99
  383. package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs.map +0 -7
  384. package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs +0 -90
  385. package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs.map +0 -7
  386. package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs +0 -105
  387. package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs.map +0 -7
  388. package/dist/lib/node-esm/settings-FZ25DUX4.mjs +0 -25
  389. package/dist/lib/node-esm/settings-FZ25DUX4.mjs.map +0 -7
  390. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  391. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  392. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  393. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  394. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  395. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  396. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  397. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  398. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  399. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  400. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  401. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  402. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  403. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  404. package/dist/types/src/capabilities/settings.d.ts +0 -4
  405. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  406. package/dist/types/src/events.d.ts +0 -4
  407. package/dist/types/src/events.d.ts.map +0 -1
  408. package/dist/types/src/templates/chess.d.ts +0 -3
  409. package/dist/types/src/templates/chess.d.ts.map +0 -1
  410. package/dist/types/src/templates/echo.d.ts +0 -6
  411. package/dist/types/src/templates/echo.d.ts.map +0 -1
  412. package/dist/types/src/types/schema.d.ts +0 -38
  413. package/dist/types/src/types/schema.d.ts.map +0 -1
  414. package/src/capabilities/app-graph-builder.ts +0 -64
  415. package/src/capabilities/blueprint-definition.ts +0 -30
  416. package/src/capabilities/capabilities.ts +0 -12
  417. package/src/capabilities/compiler.ts +0 -34
  418. package/src/capabilities/intent-resolver.ts +0 -77
  419. package/src/capabilities/react-surface.tsx +0 -90
  420. package/src/capabilities/settings.ts +0 -21
  421. package/src/events.ts +0 -11
  422. package/src/templates/chess.ts +0 -47
  423. package/src/templates/echo.ts +0 -8
  424. package/src/types/schema.ts +0 -37
  425. /package/dist/lib/browser/{DeploymentDialog-QZSTVNIS.mjs.map → DeploymentDialog-GXNRUXF6.mjs.map} +0 -0
  426. /package/dist/lib/{node-esm/DeploymentDialog-G6EHEPXN.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
+ `;
@@ -8,6 +8,8 @@ import { Expando, S, create, defineFunction } from 'dxos:functions';
8
8
  import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';
9
9
 
10
10
  export default defineFunction({
11
+ key: 'dxos.org/script/data-generator',
12
+ name: 'Data Generator',
11
13
  inputSchema: S.Struct({
12
14
  documentAmount: S.optional(S.Number),
13
15
  textSize: S.optional(S.Number),
@@ -21,7 +23,7 @@ export default defineFunction({
21
23
  data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
22
24
  context: { space },
23
25
  }: any) => {
24
- await space.db.graph.schemaRegistry.addSchema([Expando]);
26
+ await space.db.graph.schemaRegistry.register([Expando]);
25
27
  const result: Record<string, any> = {};
26
28
  const objects: Expando[] = [];
27
29
 
@@ -13,7 +13,13 @@ import {
13
13
  // @ts-ignore
14
14
  } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';
15
15
  // @ts-ignore
16
- import { Config, Effect, Redacted, Ref } from 'https://esm.sh/effect@3.17.0?bundle=false';
16
+ import * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';
17
+ // @ts-ignore
18
+ import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
19
+ // @ts-ignore
20
+ import * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';
21
+ // @ts-ignore
22
+ import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
17
23
 
18
24
  const MessageSchema = S.Struct({
19
25
  id: ObjectId,
@@ -36,6 +42,8 @@ const generateSnowflake = (unixTimestamp: number): bigint => {
36
42
  };
37
43
 
38
44
  export default defineFunction({
45
+ key: 'dxos.org/script/discord',
46
+ name: 'Discord',
39
47
  inputSchema: S.Struct({
40
48
  // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
41
49
  tick: S.optional(S.String),
@@ -2,37 +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 { Effect, Schedule } from 'https://esm.sh/effect@3.17.0?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';
15
13
 
16
14
  export default defineFunction({
15
+ key: 'dxos.org/script/forex-effect',
16
+ name: 'Forex Effect',
17
17
  description: 'Returns the exchange rate between two currencies.',
18
18
 
19
- inputSchema: S.Struct({
20
- from: S.String.annotations({ description: 'The source currency' }),
21
- 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' }),
22
22
  }),
23
23
 
24
- 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' }),
25
25
 
26
- handler: async ({ data: { from, to } }: any) =>
27
- Effect.gen(function* () {
28
- const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
29
- HttpClient.execute,
30
- Effect.flatMap((res: any) => res.json),
31
- Effect.timeout('1 second'),
32
- Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
33
- Effect.scoped,
34
- );
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
+ );
35
34
 
36
- return res.data.rates[to].toString();
37
- }).pipe(Effect.provide(FetchHttpClient.layer)),
35
+ return (res as any).data.rates[to].toString();
36
+ }, Effect.provide(FetchHttpClient.layer)),
38
37
  });
@@ -2,18 +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({
10
+ key: 'dxos.org/script/forex',
11
+ name: 'Forex',
9
12
  description: 'Returns the exchange rate between two currencies.',
10
13
 
11
- inputSchema: S.Struct({
12
- from: S.String.annotations({ description: 'The source currency' }),
13
- 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' }),
14
17
  }),
15
18
 
16
- handler: async ({ data: { from, to } }: any) => {
19
+ handler: async ({ data: { from, to } }) => {
17
20
  const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);
18
21
  const {
19
22
  data: { rates },
@@ -14,9 +14,21 @@ import {
14
14
  // @ts-ignore
15
15
  import { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';
16
16
  // @ts-ignore
17
- import { Chunk, Effect, Ref, Schedule, Stream, pipe } from 'https://esm.sh/effect@3.17.0?bundle=false';
17
+ import * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';
18
+ // @ts-ignore
19
+ import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
20
+ // @ts-ignore
21
+ import * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';
22
+ // @ts-ignore
23
+ import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
24
+ // @ts-ignore
25
+ import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
26
+ // @ts-ignore
27
+ import * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';
18
28
 
19
29
  export default defineFunction({
30
+ key: 'dxos.org/script/gmail',
31
+ name: 'Gmail',
20
32
  inputSchema: S.Struct({
21
33
  mailboxId: S.String,
22
34
  userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),
@@ -41,7 +53,7 @@ export default defineFunction({
41
53
 
42
54
  // NOTE: Google API bundles size is v. large and caused runtime issues.
43
55
  const makeRequest = (url: string) =>
44
- pipe(
56
+ Function.pipe(
45
57
  url,
46
58
  HttpClientRequest.get,
47
59
  HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),
@@ -80,7 +92,7 @@ export default defineFunction({
80
92
  const messageDetails = yield* getMessage(userId, message.id);
81
93
  const created = new Date(parseInt(messageDetails.internalDate)).toISOString();
82
94
  const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');
83
- const sender = from && parseEmailString(from.value);
95
+ const sender = from && parseFromHeader(from.value);
84
96
  // TODO(wittjosiah): Improve parsing of email contents.
85
97
  const content =
86
98
  messageDetails.payload.body?.data ??
@@ -114,7 +126,7 @@ export default defineFunction({
114
126
 
115
127
  const queueMessages = yield* Ref.get(newMessages);
116
128
  if (queueMessages.length > 0) {
117
- yield* pipe(
129
+ yield* Function.pipe(
118
130
  queueMessages,
119
131
  Stream.fromIterable,
120
132
  Stream.grouped(10),
@@ -145,17 +157,17 @@ const getUrl = (userId: string, messageId?: string, params?: Record<string, any>
145
157
  /**
146
158
  * Parses an email string in the format "Name <email@example.com>" into separate name and email components.
147
159
  */
148
- const parseEmailString = (emailString: string): { name?: string; email: string } | undefined => {
149
- const match = emailString.match(/^([^<]+?)\s*<([^>]+@[^>]+)>$/);
160
+ const parseFromHeader = (value: string): { name?: string; email: string } | undefined => {
161
+ const EMAIL_REGEX = /^([^<]+?)\s*<([^>]+@[^>]+)>$/;
162
+ const removeOuterQuotes = (str: string) => str.replace(/^['"]|['"]$/g, '');
163
+ const match = value.match(EMAIL_REGEX);
150
164
  if (match) {
151
165
  const [, name, email] = match;
152
166
  return {
153
- name: name.trim(),
167
+ name: removeOuterQuotes(name.trim()),
154
168
  email: email.trim(),
155
169
  };
156
170
  }
157
-
158
- return undefined;
159
171
  };
160
172
 
161
173
  //
@@ -163,8 +175,7 @@ const parseEmailString = (emailString: string): { name?: string; email: string }
163
175
  // TODO(wittjosiah): These schemas should be imported from @dxos/schema.
164
176
  //
165
177
 
166
- const ActorRoles = ['user', 'assistant'] as const;
167
- const ActorRole = S.Literal(...ActorRoles);
178
+ const ActorRole = S.Literal('user', 'assistant');
168
179
  type ActorRole = S.Schema.Type<typeof ActorRole>;
169
180
 
170
181
  const ActorSchema = S.Struct({
@@ -2,15 +2,17 @@
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
- import echo from './echo.ts?raw';
10
11
  import email from './email.ts?raw';
11
12
  import forexEffect from './forex-effect.ts?raw';
12
13
  import forex from './forex.ts?raw';
13
14
  import gmail from './gmail.ts?raw';
15
+ import ping from './ping.ts?raw';
14
16
 
15
17
  const removeHeader = (str: string) => str.split('\n').slice(4).join('\n');
16
18
 
@@ -23,11 +25,11 @@ export type Template = {
23
25
  presetId?: string;
24
26
  };
25
27
 
26
- export const templates: Template[] = [
28
+ export const templates = [
27
29
  {
28
- id: 'dxos.org/script/echo',
29
- name: 'Echo',
30
- source: removeHeader(echo),
30
+ id: 'dxos.org/script/ping',
31
+ name: 'Ping',
32
+ source: removeHeader(ping),
31
33
  },
32
34
  {
33
35
  id: 'dxos.org/script/forex',
@@ -46,10 +48,10 @@ export const templates: Template[] = [
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: Template[] = [
75
77
  source: removeHeader(dataGenerator),
76
78
  presetId: 'dxos.org/function/data-generator',
77
79
  },
78
- ];
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
+ },
91
+ ] as const;
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
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,72 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Prompt } from '@dxos/blueprints';
6
+ import { Ref } from '@dxos/echo';
7
+ import { createObject } from '@dxos/echo-db';
8
+ import { PublicKey } from '@dxos/keys';
9
+ import { Markdown } from '@dxos/plugin-markdown/types';
10
+ import { Text } from '@dxos/schema';
11
+
12
+ import { Notebook } from '../types';
13
+
14
+ // TODO(burdon): NOTE: createObject is required for tests.
15
+
16
+ export const createNotebook = (): Notebook.Notebook =>
17
+ Notebook.make({
18
+ cells: [
19
+ {
20
+ id: PublicKey.random().toString(),
21
+ type: 'script',
22
+ source: Ref.make(createObject(Text.make('c = a() + b'))),
23
+ },
24
+ {
25
+ id: PublicKey.random().toString(),
26
+ type: 'script',
27
+ source: Ref.make(createObject(Text.make('a = () => 100'))),
28
+ },
29
+ {
30
+ id: PublicKey.random().toString(),
31
+ type: 'script',
32
+ source: Ref.make(createObject(Text.make('b = 200'))),
33
+ },
34
+ {
35
+ id: PublicKey.random().toString(),
36
+ type: 'script',
37
+ source: Ref.make(createObject(Text.make('d = a() * 2'))),
38
+ },
39
+ {
40
+ id: PublicKey.random().toString(),
41
+ type: 'script',
42
+ source: Ref.make(createObject(Text.make('c + d'))),
43
+ },
44
+ {
45
+ id: PublicKey.random().toString(),
46
+ type: 'prompt',
47
+ prompt: Ref.make(
48
+ createObject(
49
+ Prompt.make({
50
+ instructions: 'Very briefly, what colors are associated with the numbers {{a}} and {{b}}.',
51
+ }),
52
+ ),
53
+ ),
54
+ },
55
+ {
56
+ id: PublicKey.random().toString(),
57
+ type: 'query',
58
+ source: Ref.make(createObject(Text.make(`docs = (type: ${Markdown.Document.typename})`))),
59
+ },
60
+ {
61
+ id: PublicKey.random().toString(),
62
+ type: 'prompt',
63
+ prompt: Ref.make(
64
+ createObject(
65
+ Prompt.make({
66
+ instructions: 'Very briefly, summarize the documents: {{docs}}',
67
+ }),
68
+ ),
69
+ ),
70
+ },
71
+ ],
72
+ });
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './data';
@@ -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
+ });