@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,149 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, expect, test } from 'vitest';
6
+
7
+ import { NotebookVirtualParser, VirtualTypeScriptParser } from './vfs-parser';
8
+
9
+ describe('vfs-parser', () => {
10
+ test('parse simple assignments', () => {
11
+ const parser = new VirtualTypeScriptParser();
12
+
13
+ const tests = [
14
+ {
15
+ input: 'const a = 1',
16
+ expected: {
17
+ name: 'a',
18
+ type: 'variable',
19
+ },
20
+ },
21
+ {
22
+ input: 'a = 1',
23
+ expected: {
24
+ name: 'a',
25
+ type: 'variable',
26
+ },
27
+ },
28
+ ];
29
+
30
+ tests.forEach(({ input, expected }) => {
31
+ const result = parser.parseExpression(input);
32
+ expect(result, input).toMatchObject(expected);
33
+ });
34
+ });
35
+
36
+ test('parse variable with references', () => {
37
+ const parser = new VirtualTypeScriptParser();
38
+
39
+ const tests = [
40
+ {
41
+ input: 'const y = x * 2',
42
+ expected: {
43
+ name: 'y',
44
+ type: 'variable',
45
+ references: ['x'],
46
+ },
47
+ },
48
+ {
49
+ input: 'y = x * 2',
50
+ expected: {
51
+ name: 'y',
52
+ type: 'variable',
53
+ references: ['x'],
54
+ },
55
+ },
56
+ ];
57
+
58
+ tests.forEach(({ input, expected }) => {
59
+ const result = parser.parseExpression(input);
60
+ expect(result, input).toMatchObject(expected);
61
+ });
62
+ });
63
+
64
+ test('parse simple expression with references', () => {
65
+ const parser = new VirtualTypeScriptParser();
66
+
67
+ const result = parser.parseExpression('(a + b) * c');
68
+ expect(result).toMatchObject({
69
+ references: ['a', 'b', 'c'],
70
+ });
71
+ });
72
+
73
+ test('parse single expression', () => {
74
+ const parser = new VirtualTypeScriptParser();
75
+
76
+ const result = parser.parseExpression('const add = (a: number, b: number): number => a + b;');
77
+ expect(result).toMatchObject({
78
+ name: 'add',
79
+ type: 'function',
80
+ valueType: expect.stringContaining('(a: number, b: number) => number'),
81
+ returnType: 'number',
82
+ parameters: [
83
+ { name: 'a', type: 'number' },
84
+ { name: 'b', type: 'number' },
85
+ ],
86
+ });
87
+ });
88
+
89
+ test('analyze multiple files', () => {
90
+ const parser = new VirtualTypeScriptParser();
91
+
92
+ const files = [
93
+ {
94
+ filename: '/test.ts',
95
+ content: 'export const PI = 3.14159;\nexport function square(x: number): number { return x * x; }',
96
+ },
97
+ ];
98
+
99
+ const results = parser.analyzeFiles(files);
100
+ expect(results).toHaveLength(2);
101
+ expect(results[0]).toMatchObject({
102
+ name: 'PI',
103
+ type: 'variable',
104
+ valueType: '3.14159',
105
+ });
106
+ expect(results[1]).toMatchObject({
107
+ name: 'square',
108
+ type: 'function',
109
+ returnType: 'number',
110
+ parameters: [{ name: 'x', type: 'number' }],
111
+ });
112
+ });
113
+
114
+ test('notebook cell analysis', () => {
115
+ const parser = new NotebookVirtualParser();
116
+
117
+ const cells = [
118
+ { id: 'cell1', code: 'const x: number = 10;' },
119
+ { id: 'cell2', code: 'const y = x * 2;' },
120
+ { id: 'cell3', code: 'console.log(y);' },
121
+ ];
122
+
123
+ const analysis = parser.analyzeNotebook(cells);
124
+
125
+ // Cell 1 exports x.
126
+ const cell1 = analysis.get('cell1');
127
+ expect(cell1?.exports).toHaveLength(1);
128
+ expect(cell1?.exports[0]).toMatchObject({
129
+ name: 'x',
130
+ type: 'variable',
131
+ valueType: 'number',
132
+ });
133
+ expect(cell1?.imports).toHaveLength(0);
134
+
135
+ // Cell 2 imports x and exports y.
136
+ const cell2 = analysis.get('cell2');
137
+ expect(cell2?.exports).toHaveLength(1);
138
+ expect(cell2?.exports[0]).toMatchObject({
139
+ name: 'y',
140
+ type: 'variable',
141
+ });
142
+ expect(cell2?.imports).toContain('x');
143
+
144
+ // Cell 3 imports y.
145
+ const cell3 = analysis.get('cell3');
146
+ expect(cell3?.exports).toHaveLength(0);
147
+ expect(cell3?.imports).toContain('y');
148
+ });
149
+ });
@@ -0,0 +1,451 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { createSystem, createVirtualTypeScriptEnvironment } from '@typescript/vfs';
6
+ import ts from 'typescript';
7
+
8
+ import { invariant } from '@dxos/invariant';
9
+
10
+ import { builtIns, systemDefinitions } from './eval';
11
+
12
+ /**
13
+ * Default system definitions.
14
+ */
15
+ const systemFiles: VirtualFile[] = [
16
+ {
17
+ filename: '/lib.d.ts',
18
+ content: systemDefinitions,
19
+ },
20
+ ];
21
+
22
+ export type ParsedExpression = {
23
+ name?: string;
24
+ type?: 'function' | 'variable' | 'class' | 'interface';
25
+ value?: any;
26
+ valueType?: string;
27
+ parameters?: Array<{ name: string; type: string }>;
28
+ returnType?: string;
29
+ references?: string[];
30
+ };
31
+
32
+ export type VirtualFile = {
33
+ filename: string;
34
+ content: string;
35
+ };
36
+
37
+ /**
38
+ * TypeScript parser using Virtual File System for browser compatibility.
39
+ * This provides full TypeScript analysis including type information.
40
+ */
41
+ export class VirtualTypeScriptParser {
42
+ protected compilerOptions: ts.CompilerOptions = {
43
+ target: ts.ScriptTarget.ES2020,
44
+ module: ts.ModuleKind.ESNext,
45
+ strict: true,
46
+ esModuleInterop: true,
47
+ skipLibCheck: true,
48
+ forceConsistentCasingInfilenames: true,
49
+ jsx: ts.JsxEmit.React,
50
+ noLib: true, // Don't automatically include default lib files.
51
+ };
52
+
53
+ /**
54
+ * Parse a single expression or statement.
55
+ */
56
+ parseExpression(input: string): ParsedExpression {
57
+ invariant(input.trim() !== '', 'input must not be empty');
58
+ const files: VirtualFile[] = [{ filename: '/temp.ts', content: input }];
59
+ const analysis = this.analyzeFiles(files);
60
+
61
+ // If no declarations found, check for standalone expression references.
62
+ if (analysis.length === 0) {
63
+ const sourcefilename = '/temp.ts';
64
+ const env = this.createEnvironment([{ filename: sourcefilename, content: input }]);
65
+ const sourceFile = env.getSourceFile(sourcefilename);
66
+ const typeChecker = env.languageService.getProgram()?.getTypeChecker();
67
+
68
+ if (sourceFile && typeChecker) {
69
+ // Check for assignment expressions.
70
+ const assignmentInfo = this.findAssignmentExpression(sourceFile, typeChecker);
71
+ if (assignmentInfo) {
72
+ return assignmentInfo;
73
+ }
74
+
75
+ const references = this.findAllReferences(sourceFile, typeChecker);
76
+ return { references };
77
+ }
78
+ }
79
+
80
+ return analysis[0];
81
+ }
82
+
83
+ /**
84
+ * Analyze multiple files with full type information.
85
+ */
86
+ analyzeFiles(files: VirtualFile[]): ParsedExpression[] {
87
+ const env = this.createEnvironment(files);
88
+ const results: ParsedExpression[] = [];
89
+ const typeChecker = env.languageService.getProgram()?.getTypeChecker();
90
+
91
+ // Analyze each file.
92
+ files.forEach((file) => {
93
+ const sourceFile = env.getSourceFile(file.filename);
94
+ if (!sourceFile || !typeChecker) return;
95
+
96
+ const fileResults = this.analyzeSourceFile(sourceFile, typeChecker);
97
+ results.push(...fileResults);
98
+ });
99
+
100
+ return results;
101
+ }
102
+
103
+ /**
104
+ * Analyze a source file with type information.
105
+ */
106
+ protected analyzeSourceFile(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression[] {
107
+ const results: ParsedExpression[] = [];
108
+
109
+ const visit = (node: ts.Node) => {
110
+ // Function declarations.
111
+ if (ts.isFunctionDeclaration(node) && node.name) {
112
+ const symbol = typeChecker.getSymbolAtLocation(node.name);
113
+ const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node);
114
+ const signature = type && typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];
115
+
116
+ results.push({
117
+ name: node.name.text,
118
+ type: 'function',
119
+ parameters: this.extractParameters(signature, typeChecker),
120
+ returnType: signature ? typeChecker.typeToString(signature.getReturnType()) : 'any',
121
+ references: this.findReferences(node, sourceFile, typeChecker),
122
+ });
123
+ }
124
+
125
+ // Variable declarations.
126
+ else if (ts.isVariableStatement(node)) {
127
+ node.declarationList.declarations.forEach((declaration) => {
128
+ if (ts.isIdentifier(declaration.name)) {
129
+ const symbol = typeChecker.getSymbolAtLocation(declaration.name);
130
+ const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
131
+
132
+ let kind: 'function' | 'variable' = 'variable';
133
+ let parameters: Array<{ name: string; type: string }> | undefined;
134
+ let returnType: string | undefined;
135
+ let value: any;
136
+
137
+ // Get the type string.
138
+ const typeString = type ? typeChecker.typeToString(type) : 'any';
139
+
140
+ // Check if it's a function.
141
+ if (declaration.initializer) {
142
+ if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
143
+ kind = 'function';
144
+ const funcType = typeChecker.getTypeAtLocation(declaration.initializer);
145
+ const signature = typeChecker.getSignaturesOfType(funcType, ts.SignatureKind.Call)[0];
146
+ if (signature) {
147
+ parameters = this.extractParameters(signature, typeChecker);
148
+ returnType = typeChecker.typeToString(signature.getReturnType());
149
+ }
150
+ } else {
151
+ // Extract literal values
152
+ if (ts.isNumericLiteral(declaration.initializer)) {
153
+ value = Number(declaration.initializer.text);
154
+ } else if (ts.isStringLiteral(declaration.initializer)) {
155
+ value = declaration.initializer.text;
156
+ }
157
+ }
158
+ }
159
+
160
+ // Find references in the initializer only.
161
+ const refs = declaration.initializer
162
+ ? this.findReferences(declaration.initializer, sourceFile, typeChecker)
163
+ : [];
164
+
165
+ results.push({
166
+ name: declaration.name.text,
167
+ type: kind,
168
+ valueType: typeString,
169
+ value,
170
+ parameters,
171
+ returnType,
172
+ references: refs,
173
+ });
174
+ }
175
+ });
176
+ }
177
+
178
+ // Class declarations.
179
+ else if (ts.isClassDeclaration(node) && node.name) {
180
+ results.push({
181
+ name: node.name.text,
182
+ type: 'class',
183
+ references: this.findReferences(node, sourceFile, typeChecker),
184
+ });
185
+ }
186
+
187
+ // Interface declarations.
188
+ else if (ts.isInterfaceDeclaration(node)) {
189
+ results.push({
190
+ name: node.name.text,
191
+ type: 'interface',
192
+ references: this.findReferences(node, sourceFile, typeChecker),
193
+ });
194
+ }
195
+
196
+ ts.forEachChild(node, visit);
197
+ };
198
+
199
+ visit(sourceFile);
200
+ return results;
201
+ }
202
+
203
+ /**
204
+ * Extract parameter information from a signature.
205
+ */
206
+ private extractParameters(
207
+ signature: ts.Signature | undefined,
208
+ typeChecker: ts.TypeChecker,
209
+ ): Array<{ name: string; type: string }> {
210
+ if (!signature) return [];
211
+
212
+ return signature.parameters.map((param) => ({
213
+ name: param.getName(),
214
+ type: typeChecker.typeToString(typeChecker.getTypeOfSymbolAtLocation(param, param.valueDeclaration!)),
215
+ }));
216
+ }
217
+
218
+ /**
219
+ * Find all references to variables used in a node.
220
+ */
221
+ private findReferences(node: ts.Node, _sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {
222
+ const references = new Set<string>();
223
+ const localSymbols = new Set<string>();
224
+
225
+ // First, collect local symbols (parameters, local variables).
226
+ const collectLocalSymbols = (node: ts.Node) => {
227
+ if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
228
+ node.parameters.forEach((param) => {
229
+ if (ts.isIdentifier(param.name)) {
230
+ localSymbols.add(param.name.text);
231
+ }
232
+ });
233
+ }
234
+
235
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name)) {
236
+ localSymbols.add(node.name.text);
237
+ }
238
+
239
+ ts.forEachChild(node, collectLocalSymbols);
240
+ };
241
+
242
+ collectLocalSymbols(node);
243
+
244
+ // Then find all identifier references.
245
+ const findRefs = (node: ts.Node) => {
246
+ if (ts.isIdentifier(node)) {
247
+ // Skip if it's a local symbol.
248
+ if (!localSymbols.has(node.text)) {
249
+ // Check if it's a reference (not a declaration).
250
+ const parent = node.parent;
251
+ const isDeclaration =
252
+ (ts.isVariableDeclaration(parent) && parent.name === node) ||
253
+ (ts.isFunctionDeclaration(parent) && parent.name === node) ||
254
+ (ts.isParameter(parent) && parent.name === node);
255
+
256
+ if (!isDeclaration && !this.isBuiltIn(node.text)) {
257
+ references.add(node.text);
258
+ }
259
+ }
260
+ }
261
+ ts.forEachChild(node, findRefs);
262
+ };
263
+
264
+ findRefs(node);
265
+ return Array.from(references);
266
+ }
267
+
268
+ /**
269
+ * Check if a name is a built-in global.
270
+ */
271
+ protected isBuiltIn(name: string): boolean {
272
+ return builtIns.has(name);
273
+ }
274
+
275
+ /**
276
+ * Find assignment expressions in a source file.
277
+ */
278
+ private findAssignmentExpression(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression | null {
279
+ let result: ParsedExpression | null = null;
280
+
281
+ const visit = (node: ts.Node) => {
282
+ if (ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression)) {
283
+ const expr = node.expression;
284
+ if (expr.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isIdentifier(expr.left)) {
285
+ const type = typeChecker.getTypeAtLocation(expr.right);
286
+ const typeString = typeChecker.typeToString(type);
287
+
288
+ // Get the literal value if it's a literal.
289
+ let value: any;
290
+ if (ts.isNumericLiteral(expr.right)) {
291
+ value = Number(expr.right.text);
292
+ } else if (ts.isStringLiteral(expr.right)) {
293
+ value = expr.right.text;
294
+ }
295
+
296
+ // Find references in the right-hand side.
297
+ const references = this.findReferences(expr.right, sourceFile, typeChecker);
298
+
299
+ result = {
300
+ name: expr.left.text,
301
+ type: 'variable',
302
+ valueType: typeString,
303
+ value,
304
+ references,
305
+ };
306
+ }
307
+ }
308
+ if (!result) {
309
+ ts.forEachChild(node, visit);
310
+ }
311
+ };
312
+
313
+ visit(sourceFile);
314
+ return result;
315
+ }
316
+
317
+ /**
318
+ * Find all identifier references in a source file.
319
+ */
320
+ protected findAllReferences(sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {
321
+ const references = new Set<string>();
322
+
323
+ const visit = (node: ts.Node) => {
324
+ if (ts.isIdentifier(node)) {
325
+ // Skip if it's a declaration.
326
+ const parent = node.parent;
327
+ const isDeclaration =
328
+ (ts.isVariableDeclaration(parent) && parent.name === node) ||
329
+ (ts.isFunctionDeclaration(parent) && parent.name === node) ||
330
+ (ts.isParameter(parent) && parent.name === node);
331
+
332
+ // Skip if it's the left-hand side of an assignment.
333
+ const isAssignmentTarget =
334
+ ts.isBinaryExpression(parent) &&
335
+ parent.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
336
+ parent.left === node;
337
+
338
+ if (!isDeclaration && !isAssignmentTarget && !this.isBuiltIn(node.text)) {
339
+ references.add(node.text);
340
+ }
341
+ }
342
+ ts.forEachChild(node, visit);
343
+ };
344
+
345
+ visit(sourceFile);
346
+ return Array.from(references);
347
+ }
348
+
349
+ protected createEnvironment(files: VirtualFile[]) {
350
+ const allFiles = [...systemFiles, ...files];
351
+
352
+ const fileMap = new Map<string, string>();
353
+ allFiles.forEach(({ filename, content }) => {
354
+ fileMap.set(filename, content);
355
+ });
356
+
357
+ const system = createSystem(fileMap);
358
+ return createVirtualTypeScriptEnvironment(
359
+ system,
360
+ allFiles.map(({ filename }) => filename),
361
+ ts,
362
+ this.compilerOptions,
363
+ );
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Notebook-specific parser with dependency analysis.
369
+ */
370
+ export class NotebookVirtualParser extends VirtualTypeScriptParser {
371
+ /**
372
+ * Analyze notebook cells with full type checking.
373
+ */
374
+ analyzeNotebook(cells: Array<{ id: string; code: string }>) {
375
+ // Create cumulative environment where each cell can see previous cells.
376
+ const cumulativeCode: string[] = [];
377
+ const cellAnalysis: Map<
378
+ string,
379
+ {
380
+ exports: ParsedExpression[];
381
+ imports: string[];
382
+ errors: ts.Diagnostic[];
383
+ }
384
+ > = new Map();
385
+
386
+ cells.forEach((cell) => {
387
+ // Create files for all cells up to current.
388
+ const files: VirtualFile[] = [];
389
+
390
+ // Add previous cells as context.
391
+ if (cumulativeCode.length > 0) {
392
+ files.push({
393
+ filename: '/context.ts',
394
+ content: cumulativeCode.join('\n'),
395
+ });
396
+ }
397
+
398
+ // Add current cell.
399
+ const filename = `/cell/${cell.id}.ts`;
400
+ files.push({
401
+ filename,
402
+ content: cell.code,
403
+ });
404
+
405
+ // Create environment.
406
+ const env = this.createEnvironment(files);
407
+
408
+ // Get diagnostics (errors).
409
+ const diagnostics = env.languageService.getSemanticDiagnostics(filename);
410
+
411
+ // Analyze current cell.
412
+ const sourceFile = env.getSourceFile(filename);
413
+ const typeChecker = env.languageService.getProgram()?.getTypeChecker();
414
+
415
+ if (sourceFile && typeChecker) {
416
+ const exports = this.analyzeSourceFile(sourceFile, typeChecker);
417
+
418
+ // Find all references in the current cell.
419
+ const allRefs = new Set<string>();
420
+ exports.forEach((exp) => {
421
+ exp.references?.forEach((ref) => allRefs.add(ref));
422
+ });
423
+
424
+ // Also check for references not in exports (e.g., console.log(y)).
425
+ const additionalRefs = this.findAllReferences(sourceFile, typeChecker);
426
+ additionalRefs.forEach((ref) => allRefs.add(ref));
427
+
428
+ // Determine which references are imports from previous cells.
429
+ const previousExports = new Set<string>();
430
+ for (const [_prevCellId, prevAnalysis] of cellAnalysis) {
431
+ prevAnalysis.exports.forEach((exp) => {
432
+ if (exp.name) previousExports.add(exp.name);
433
+ });
434
+ }
435
+
436
+ const imports = Array.from(allRefs).filter((ref) => previousExports.has(ref));
437
+
438
+ cellAnalysis.set(cell.id, {
439
+ exports,
440
+ imports,
441
+ errors: diagnostics,
442
+ });
443
+ }
444
+
445
+ // Add current cell code to cumulative.
446
+ cumulativeCode.push(cell.code);
447
+ });
448
+
449
+ return cellAnalysis;
450
+ }
451
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as LanguageModel from '@effect/ai/LanguageModel';
6
+ import * as Chunk from 'effect/Chunk';
7
+ import * as Effect from 'effect/Effect';
8
+ import * as Schema from 'effect/Schema';
9
+ import * as Stream from 'effect/Stream';
10
+
11
+ import { AiService } from '@dxos/ai';
12
+ import { defineFunction } from '@dxos/functions';
13
+
14
+ export default defineFunction({
15
+ key: 'dxos.org/script/anthropic',
16
+ name: 'Anthropic Chat',
17
+ description: 'Chat with Anthropic',
18
+ inputSchema: Schema.Struct({
19
+ message: Schema.String,
20
+ }),
21
+ services: [AiService.AiService],
22
+ handler: ({ data }) => {
23
+ return Effect.gen(function* () {
24
+ const model = (yield* AiService.AiService).model('@anthropic/claude-sonnet-4-5');
25
+ //
26
+ // Basic example.
27
+ //
28
+ const { text } = yield* LanguageModel.generateText({ prompt: data.message }).pipe(Effect.provide(model));
29
+
30
+ //
31
+ // Streaming example.
32
+ //
33
+ const parts = yield* LanguageModel.streamText({
34
+ prompt: 'Count from 1 to 5, one number per line.',
35
+ }).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));
36
+ const textDeltas = parts.filter((p) => p.type === 'text-delta');
37
+ const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');
38
+
39
+ return { response: text, streamText: fullText };
40
+ });
41
+ },
42
+ });
@@ -0,0 +1,58 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Chess as ChessJS } from 'chess.js';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ import { Database, Obj, Type } from '@dxos/echo';
10
+ import { defineFunction } from '@dxos/functions';
11
+ import { Chess } from '@dxos/plugin-chess/types';
12
+
13
+ export default defineFunction({
14
+ key: 'dxos.org/script/chess-bot',
15
+ name: 'Chess Bot',
16
+ description: 'Plays a random move in a chess game.',
17
+
18
+ inputSchema: Schema.Struct({
19
+ game: Type.Ref(Chess.Game).annotations({
20
+ description: 'The chess game to comment on.',
21
+ }),
22
+ player: Schema.optional(Schema.Literal('white', 'black')).annotations({
23
+ description: 'The player to play the game as.',
24
+ }),
25
+ }),
26
+
27
+ outputSchema: Schema.Struct({
28
+ state: Schema.String.annotations({
29
+ description: 'The state of the game as an ASCII art board.',
30
+ }),
31
+ }),
32
+
33
+ types: [Chess.Game],
34
+ services: [Database.Service],
35
+
36
+ handler: Effect.fnUntraced(function* ({ data: { game, player = 'black' } }) {
37
+ const loadedGame = yield* Database.Service.load(game);
38
+ const chess = new ChessJS();
39
+ chess.loadPgn(loadedGame.pgn ?? '');
40
+ if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {
41
+ return { state: chess.ascii() };
42
+ }
43
+
44
+ const moves = chess.moves({ verbose: true });
45
+ const move = moves[Math.floor(Math.random() * moves.length)];
46
+ if (!move) {
47
+ return { state: chess.ascii() };
48
+ }
49
+
50
+ chess.move(move.san);
51
+ const newPgn = chess.pgn();
52
+ Obj.change(loadedGame, (g) => {
53
+ g.pgn = newPgn;
54
+ });
55
+ yield* Database.Service.flush();
56
+ return { state: chess.ascii() };
57
+ }),
58
+ });