@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,845 @@
1
+ import {
2
+ NotebookMenu,
3
+ NotebookStack
4
+ } from "./chunk-BTWHM6FH.mjs";
5
+ import "./chunk-I7CSE6T3.mjs";
6
+ import {
7
+ meta
8
+ } from "./chunk-WYR4QHPE.mjs";
9
+ import "./chunk-J5LGTIGS.mjs";
10
+
11
+ // src/components/NotebookContainer.tsx
12
+ import { RegistryContext } from "@effect-atom/atom-react";
13
+ import * as Cause from "effect/Cause";
14
+ import * as Effect from "effect/Effect";
15
+ import * as Exit from "effect/Exit";
16
+ import React, { useCallback, useContext, useMemo, useState } from "react";
17
+ import { Agent } from "@dxos/assistant-toolkit";
18
+ import { Blueprint, Prompt } from "@dxos/blueprints";
19
+ import { Filter, Obj, Query, Ref } from "@dxos/echo";
20
+ import { QueryBuilder } from "@dxos/echo-query";
21
+ import { FunctionInvocationService, TracingService } from "@dxos/functions";
22
+ import { invariant as invariant2 } from "@dxos/invariant";
23
+ import { log as log2 } from "@dxos/log";
24
+ import { useComputeRuntimeCallback } from "@dxos/plugin-automation";
25
+ import { Graph } from "@dxos/plugin-explorer/types";
26
+ import { DropdownMenu, IconButton, Toolbar, useTranslation } from "@dxos/react-ui";
27
+ import { useAttention } from "@dxos/react-ui-attention";
28
+ import { Layout } from "@dxos/react-ui-mosaic";
29
+ import { Text, View } from "@dxos/schema";
30
+ import { isNonNullable } from "@dxos/util";
31
+
32
+ // src/notebook/compute-graph.ts
33
+ import { Atom } from "@effect-atom/atom-react";
34
+ import { log } from "@dxos/log";
35
+
36
+ // src/notebook/eval.ts
37
+ import { trim } from "@dxos/util";
38
+ var evalScript = async (code, deps = {}) => {
39
+ const sandbox = {
40
+ ...deps,
41
+ // Block access to global objects.
42
+ console: void 0,
43
+ document: void 0,
44
+ global: void 0,
45
+ globalThis: void 0,
46
+ self: void 0,
47
+ window: void 0,
48
+ // Allow some safe globals.
49
+ Array,
50
+ Boolean,
51
+ Date,
52
+ Error,
53
+ JSON,
54
+ Map,
55
+ Math,
56
+ Number,
57
+ Object,
58
+ Promise,
59
+ RegExp,
60
+ Set,
61
+ String,
62
+ // Functions.
63
+ isFinite,
64
+ isNaN,
65
+ parseFloat,
66
+ parseInt
67
+ };
68
+ const sandboxKeys = Object.keys(sandbox);
69
+ const sandboxValues = Object.values(sandbox);
70
+ const fn2 = new Function(...sandboxKeys, trim`
71
+ 'use strict';
72
+ return ${code};
73
+ `);
74
+ return fn2(...sandboxValues);
75
+ };
76
+ var builtIns = /* @__PURE__ */ new Set([
77
+ // Types.
78
+ "Array",
79
+ "Date",
80
+ "Error",
81
+ "JSON",
82
+ "Map",
83
+ "Math",
84
+ "Number",
85
+ "Object",
86
+ "Promise",
87
+ "RegExp",
88
+ "Set",
89
+ "String",
90
+ // Functions.
91
+ "isFinite",
92
+ "isNaN",
93
+ "parseFloat",
94
+ "parseInt"
95
+ ]);
96
+ var systemDefinitions = trim`
97
+ interface Array<T> { length: number; [n: number]: T; }
98
+ interface Boolean {}
99
+ interface Function {}
100
+ interface IArguments {}
101
+ interface Number {}
102
+ interface Object {}
103
+ interface RegExp {}
104
+ interface String { length: number; }
105
+
106
+ interface CallableFunction extends Function {}
107
+ interface NewableFunction extends Function {}
108
+
109
+ declare var console: { log(...args: any[]): void };
110
+ `;
111
+
112
+ // src/notebook/vfs-parser.ts
113
+ import { createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
114
+ import ts from "typescript";
115
+ import { invariant } from "@dxos/invariant";
116
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/notebook/vfs-parser.ts";
117
+ var systemFiles = [
118
+ {
119
+ filename: "/lib.d.ts",
120
+ content: systemDefinitions
121
+ }
122
+ ];
123
+ var VirtualTypeScriptParser = class {
124
+ compilerOptions = {
125
+ target: ts.ScriptTarget.ES2020,
126
+ module: ts.ModuleKind.ESNext,
127
+ strict: true,
128
+ esModuleInterop: true,
129
+ skipLibCheck: true,
130
+ forceConsistentCasingInfilenames: true,
131
+ jsx: ts.JsxEmit.React,
132
+ noLib: true
133
+ };
134
+ /**
135
+ * Parse a single expression or statement.
136
+ */
137
+ parseExpression(input) {
138
+ invariant(input.trim() !== "", "input must not be empty", {
139
+ F: __dxlog_file,
140
+ L: 57,
141
+ S: this,
142
+ A: [
143
+ "input.trim() !== ''",
144
+ "'input must not be empty'"
145
+ ]
146
+ });
147
+ const files = [
148
+ {
149
+ filename: "/temp.ts",
150
+ content: input
151
+ }
152
+ ];
153
+ const analysis = this.analyzeFiles(files);
154
+ if (analysis.length === 0) {
155
+ const sourcefilename = "/temp.ts";
156
+ const env = this.createEnvironment([
157
+ {
158
+ filename: sourcefilename,
159
+ content: input
160
+ }
161
+ ]);
162
+ const sourceFile = env.getSourceFile(sourcefilename);
163
+ const typeChecker = env.languageService.getProgram()?.getTypeChecker();
164
+ if (sourceFile && typeChecker) {
165
+ const assignmentInfo = this.findAssignmentExpression(sourceFile, typeChecker);
166
+ if (assignmentInfo) {
167
+ return assignmentInfo;
168
+ }
169
+ const references = this.findAllReferences(sourceFile, typeChecker);
170
+ return {
171
+ references
172
+ };
173
+ }
174
+ }
175
+ return analysis[0];
176
+ }
177
+ /**
178
+ * Analyze multiple files with full type information.
179
+ */
180
+ analyzeFiles(files) {
181
+ const env = this.createEnvironment(files);
182
+ const results = [];
183
+ const typeChecker = env.languageService.getProgram()?.getTypeChecker();
184
+ files.forEach((file) => {
185
+ const sourceFile = env.getSourceFile(file.filename);
186
+ if (!sourceFile || !typeChecker) return;
187
+ const fileResults = this.analyzeSourceFile(sourceFile, typeChecker);
188
+ results.push(...fileResults);
189
+ });
190
+ return results;
191
+ }
192
+ /**
193
+ * Analyze a source file with type information.
194
+ */
195
+ analyzeSourceFile(sourceFile, typeChecker) {
196
+ const results = [];
197
+ const visit = (node) => {
198
+ if (ts.isFunctionDeclaration(node) && node.name) {
199
+ const symbol = typeChecker.getSymbolAtLocation(node.name);
200
+ const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node);
201
+ const signature = type && typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];
202
+ results.push({
203
+ name: node.name.text,
204
+ type: "function",
205
+ parameters: this.extractParameters(signature, typeChecker),
206
+ returnType: signature ? typeChecker.typeToString(signature.getReturnType()) : "any",
207
+ references: this.findReferences(node, sourceFile, typeChecker)
208
+ });
209
+ } else if (ts.isVariableStatement(node)) {
210
+ node.declarationList.declarations.forEach((declaration) => {
211
+ if (ts.isIdentifier(declaration.name)) {
212
+ const symbol = typeChecker.getSymbolAtLocation(declaration.name);
213
+ const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
214
+ let kind = "variable";
215
+ let parameters;
216
+ let returnType;
217
+ let value;
218
+ const typeString = type ? typeChecker.typeToString(type) : "any";
219
+ if (declaration.initializer) {
220
+ if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
221
+ kind = "function";
222
+ const funcType = typeChecker.getTypeAtLocation(declaration.initializer);
223
+ const signature = typeChecker.getSignaturesOfType(funcType, ts.SignatureKind.Call)[0];
224
+ if (signature) {
225
+ parameters = this.extractParameters(signature, typeChecker);
226
+ returnType = typeChecker.typeToString(signature.getReturnType());
227
+ }
228
+ } else {
229
+ if (ts.isNumericLiteral(declaration.initializer)) {
230
+ value = Number(declaration.initializer.text);
231
+ } else if (ts.isStringLiteral(declaration.initializer)) {
232
+ value = declaration.initializer.text;
233
+ }
234
+ }
235
+ }
236
+ const refs = declaration.initializer ? this.findReferences(declaration.initializer, sourceFile, typeChecker) : [];
237
+ results.push({
238
+ name: declaration.name.text,
239
+ type: kind,
240
+ valueType: typeString,
241
+ value,
242
+ parameters,
243
+ returnType,
244
+ references: refs
245
+ });
246
+ }
247
+ });
248
+ } else if (ts.isClassDeclaration(node) && node.name) {
249
+ results.push({
250
+ name: node.name.text,
251
+ type: "class",
252
+ references: this.findReferences(node, sourceFile, typeChecker)
253
+ });
254
+ } else if (ts.isInterfaceDeclaration(node)) {
255
+ results.push({
256
+ name: node.name.text,
257
+ type: "interface",
258
+ references: this.findReferences(node, sourceFile, typeChecker)
259
+ });
260
+ }
261
+ ts.forEachChild(node, visit);
262
+ };
263
+ visit(sourceFile);
264
+ return results;
265
+ }
266
+ /**
267
+ * Extract parameter information from a signature.
268
+ */
269
+ extractParameters(signature, typeChecker) {
270
+ if (!signature) return [];
271
+ return signature.parameters.map((param) => ({
272
+ name: param.getName(),
273
+ type: typeChecker.typeToString(typeChecker.getTypeOfSymbolAtLocation(param, param.valueDeclaration))
274
+ }));
275
+ }
276
+ /**
277
+ * Find all references to variables used in a node.
278
+ */
279
+ findReferences(node, _sourceFile, _typeChecker) {
280
+ const references = /* @__PURE__ */ new Set();
281
+ const localSymbols = /* @__PURE__ */ new Set();
282
+ const collectLocalSymbols = (node2) => {
283
+ if (ts.isFunctionDeclaration(node2) || ts.isArrowFunction(node2) || ts.isFunctionExpression(node2)) {
284
+ node2.parameters.forEach((param) => {
285
+ if (ts.isIdentifier(param.name)) {
286
+ localSymbols.add(param.name.text);
287
+ }
288
+ });
289
+ }
290
+ if (ts.isVariableDeclaration(node2) && ts.isIdentifier(node2.name)) {
291
+ localSymbols.add(node2.name.text);
292
+ }
293
+ ts.forEachChild(node2, collectLocalSymbols);
294
+ };
295
+ collectLocalSymbols(node);
296
+ const findRefs = (node2) => {
297
+ if (ts.isIdentifier(node2)) {
298
+ if (!localSymbols.has(node2.text)) {
299
+ const parent = node2.parent;
300
+ const isDeclaration = ts.isVariableDeclaration(parent) && parent.name === node2 || ts.isFunctionDeclaration(parent) && parent.name === node2 || ts.isParameter(parent) && parent.name === node2;
301
+ if (!isDeclaration && !this.isBuiltIn(node2.text)) {
302
+ references.add(node2.text);
303
+ }
304
+ }
305
+ }
306
+ ts.forEachChild(node2, findRefs);
307
+ };
308
+ findRefs(node);
309
+ return Array.from(references);
310
+ }
311
+ /**
312
+ * Check if a name is a built-in global.
313
+ */
314
+ isBuiltIn(name) {
315
+ return builtIns.has(name);
316
+ }
317
+ /**
318
+ * Find assignment expressions in a source file.
319
+ */
320
+ findAssignmentExpression(sourceFile, typeChecker) {
321
+ let result = null;
322
+ const visit = (node) => {
323
+ if (ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression)) {
324
+ const expr = node.expression;
325
+ if (expr.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isIdentifier(expr.left)) {
326
+ const type = typeChecker.getTypeAtLocation(expr.right);
327
+ const typeString = typeChecker.typeToString(type);
328
+ let value;
329
+ if (ts.isNumericLiteral(expr.right)) {
330
+ value = Number(expr.right.text);
331
+ } else if (ts.isStringLiteral(expr.right)) {
332
+ value = expr.right.text;
333
+ }
334
+ const references = this.findReferences(expr.right, sourceFile, typeChecker);
335
+ result = {
336
+ name: expr.left.text,
337
+ type: "variable",
338
+ valueType: typeString,
339
+ value,
340
+ references
341
+ };
342
+ }
343
+ }
344
+ if (!result) {
345
+ ts.forEachChild(node, visit);
346
+ }
347
+ };
348
+ visit(sourceFile);
349
+ return result;
350
+ }
351
+ /**
352
+ * Find all identifier references in a source file.
353
+ */
354
+ findAllReferences(sourceFile, _typeChecker) {
355
+ const references = /* @__PURE__ */ new Set();
356
+ const visit = (node) => {
357
+ if (ts.isIdentifier(node)) {
358
+ const parent = node.parent;
359
+ const isDeclaration = ts.isVariableDeclaration(parent) && parent.name === node || ts.isFunctionDeclaration(parent) && parent.name === node || ts.isParameter(parent) && parent.name === node;
360
+ const isAssignmentTarget = ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && parent.left === node;
361
+ if (!isDeclaration && !isAssignmentTarget && !this.isBuiltIn(node.text)) {
362
+ references.add(node.text);
363
+ }
364
+ }
365
+ ts.forEachChild(node, visit);
366
+ };
367
+ visit(sourceFile);
368
+ return Array.from(references);
369
+ }
370
+ createEnvironment(files) {
371
+ const allFiles = [
372
+ ...systemFiles,
373
+ ...files
374
+ ];
375
+ const fileMap = /* @__PURE__ */ new Map();
376
+ allFiles.forEach(({ filename, content }) => {
377
+ fileMap.set(filename, content);
378
+ });
379
+ const system = createSystem(fileMap);
380
+ return createVirtualTypeScriptEnvironment(system, allFiles.map(({ filename }) => filename), ts, this.compilerOptions);
381
+ }
382
+ };
383
+
384
+ // src/notebook/compute-graph.ts
385
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/notebook/compute-graph.ts";
386
+ var ComputeGraph = class {
387
+ _notebook;
388
+ _registry;
389
+ _parser = new VirtualTypeScriptParser();
390
+ _expressionsAtom = Atom.make({});
391
+ _valuesByCellIdAtom = Atom.make({});
392
+ _valuesByNameAtom = Atom.make({});
393
+ constructor(_notebook, _registry) {
394
+ this._notebook = _notebook;
395
+ this._registry = _registry;
396
+ }
397
+ /**
398
+ * Atom for parsed expressions by cell ID.
399
+ */
400
+ get expressions() {
401
+ return this._expressionsAtom;
402
+ }
403
+ /**
404
+ * Get current expressions by cell ID.
405
+ */
406
+ getExpressions() {
407
+ return this._registry.get(this._expressionsAtom);
408
+ }
409
+ /**
410
+ * Atom for computed values by cell ID.
411
+ */
412
+ get values() {
413
+ return this._valuesByCellIdAtom;
414
+ }
415
+ /**
416
+ * Get computed values by cell ID.
417
+ */
418
+ getValues() {
419
+ return this._registry.get(this._valuesByCellIdAtom);
420
+ }
421
+ /**
422
+ * Atom for computed values by name.
423
+ */
424
+ get valuesByName() {
425
+ return this._valuesByNameAtom;
426
+ }
427
+ /**
428
+ * Get current values by name.
429
+ */
430
+ getValuesByName() {
431
+ return this._registry.get(this._valuesByNameAtom);
432
+ }
433
+ /**
434
+ * Get computed value by cell ID.
435
+ */
436
+ getValue(cellId) {
437
+ return this._registry.get(this._valuesByCellIdAtom)[cellId];
438
+ }
439
+ /**
440
+ * Compute values.
441
+ */
442
+ async evaluate() {
443
+ const { expressions, dependencyGraph } = this.parse();
444
+ this._registry.set(this._valuesByCellIdAtom, {});
445
+ this._registry.set(this._valuesByNameAtom, {});
446
+ const cellExpressions = /* @__PURE__ */ new Map();
447
+ Object.entries(expressions).forEach(([id, expr]) => {
448
+ cellExpressions.set(id, expr);
449
+ });
450
+ const evaluationOrder = this.topologicalSort(Object.keys(expressions), dependencyGraph);
451
+ const valuesByName = {};
452
+ const valuesByCellId = {};
453
+ for (const cellId of evaluationOrder) {
454
+ const expr = cellExpressions.get(cellId);
455
+ if (!expr) {
456
+ log.error("no expression for cell", {
457
+ cellId
458
+ }, {
459
+ F: __dxlog_file2,
460
+ L: 105,
461
+ S: this,
462
+ C: (f, a) => f(...a)
463
+ });
464
+ continue;
465
+ }
466
+ const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.source?.target?.content;
467
+ if (!cellSource) {
468
+ log.error("no source for cell", {
469
+ cellId
470
+ }, {
471
+ F: __dxlog_file2,
472
+ L: 111,
473
+ S: this,
474
+ C: (f, a) => f(...a)
475
+ });
476
+ continue;
477
+ }
478
+ try {
479
+ if (expr.name && expr.value !== void 0) {
480
+ valuesByName[expr.name] = expr.value;
481
+ valuesByCellId[cellId] = expr.value;
482
+ } else if (expr.name) {
483
+ const equalIndex = cellSource.indexOf("=");
484
+ if (equalIndex !== -1) {
485
+ let rhs = cellSource.substring(equalIndex + 1).trim();
486
+ if (rhs.endsWith(";")) {
487
+ rhs = rhs.slice(0, -1).trim();
488
+ }
489
+ const result = await this.eval(rhs, valuesByName);
490
+ valuesByName[expr.name] = result;
491
+ if (typeof result !== "function") {
492
+ valuesByCellId[cellId] = result;
493
+ }
494
+ }
495
+ } else {
496
+ const result = await this.eval(cellSource, valuesByName);
497
+ valuesByCellId[cellId] = result;
498
+ }
499
+ } catch (error) {
500
+ log.error("error evaluating cell", {
501
+ cellId,
502
+ error
503
+ }, {
504
+ F: __dxlog_file2,
505
+ L: 147,
506
+ S: this,
507
+ C: (f, a) => f(...a)
508
+ });
509
+ }
510
+ }
511
+ this._registry.set(this._valuesByCellIdAtom, valuesByCellId);
512
+ this._registry.set(this._valuesByNameAtom, valuesByName);
513
+ return valuesByCellId;
514
+ }
515
+ async eval(source, values) {
516
+ return evalScript(source, values);
517
+ }
518
+ /**
519
+ * Parse expressions.
520
+ */
521
+ parse() {
522
+ const expressions = this._notebook.cells.filter((cell) => cell.type === "script").reduce((acc, cell) => {
523
+ const text = cell.source?.target?.content.trim();
524
+ if (text) {
525
+ const parsed = this._parser.parseExpression(text);
526
+ acc[cell.id] = parsed;
527
+ }
528
+ return acc;
529
+ }, {});
530
+ const dependencyGraph = this.buildDependencyGraph(expressions);
531
+ this._registry.set(this._expressionsAtom, expressions);
532
+ return {
533
+ expressions,
534
+ dependencyGraph
535
+ };
536
+ }
537
+ topologicalSort(nodes, dependencies) {
538
+ const visited = /* @__PURE__ */ new Set();
539
+ const result = [];
540
+ const visit = (node) => {
541
+ if (visited.has(node)) {
542
+ return;
543
+ }
544
+ visited.add(node);
545
+ const deps = dependencies[node] || [];
546
+ deps.forEach((dep) => visit(dep));
547
+ result.push(node);
548
+ };
549
+ nodes.forEach((node) => visit(node));
550
+ return result;
551
+ }
552
+ buildDependencyGraph(expressions) {
553
+ const nameToCellId = /* @__PURE__ */ new Map();
554
+ Object.entries(expressions).forEach(([id, expr]) => {
555
+ if (expr.name) {
556
+ nameToCellId.set(expr.name, id);
557
+ }
558
+ });
559
+ const graph = {};
560
+ Object.entries(expressions).forEach(([id, expr]) => {
561
+ if (expr.references && expr.references.length > 0) {
562
+ const dependencyCellIds = expr.references.map((ref) => nameToCellId.get(ref)).filter((cellId) => cellId !== void 0 && cellId !== id);
563
+ if (dependencyCellIds.length > 0) {
564
+ graph[id] = dependencyCellIds;
565
+ }
566
+ }
567
+ });
568
+ return graph;
569
+ }
570
+ };
571
+
572
+ // src/components/NotebookContainer.tsx
573
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/NotebookContainer.tsx";
574
+ var INCLUDE_BLUEPRINTS = [
575
+ "dxos.org/blueprint/assistant",
576
+ "dxos.org/blueprint/markdown"
577
+ ];
578
+ var NotebookContainer = ({ role, subject: notebook, env }) => {
579
+ const { t } = useTranslation(meta.id);
580
+ const registry = useContext(RegistryContext);
581
+ const db = notebook && Obj.getDatabase(notebook);
582
+ const attendableId = notebook ? Obj.getDXN(notebook).toString() : "";
583
+ const { hasAttention } = useAttention(attendableId);
584
+ const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [
585
+ notebook,
586
+ registry
587
+ ]);
588
+ const [queryValues, setQueryValues] = useState({});
589
+ const handleExecQueries = useCallback(async () => {
590
+ invariant2(db, void 0, {
591
+ F: __dxlog_file3,
592
+ L: 53,
593
+ S: void 0,
594
+ A: [
595
+ "db",
596
+ ""
597
+ ]
598
+ });
599
+ const builder = new QueryBuilder();
600
+ for (const cell of notebook?.cells ?? []) {
601
+ if (cell.type === "query") {
602
+ if (cell.source?.target) {
603
+ const source = cell.source.target.content;
604
+ const { name, filter } = builder.build(source);
605
+ if (filter) {
606
+ const ast = Query.select(filter).ast;
607
+ const graph2 = cell.graph?.target;
608
+ if (!graph2) {
609
+ const { view } = await View.makeFromDatabase({
610
+ db
611
+ });
612
+ const newGraph = Graph.make({
613
+ query: {
614
+ ast
615
+ },
616
+ view
617
+ });
618
+ Obj.change(notebook, (n) => {
619
+ const c = n.cells.find((c2) => c2.id === cell.id);
620
+ if (c) {
621
+ c.graph = Ref.make(newGraph);
622
+ c.name = name;
623
+ }
624
+ });
625
+ } else {
626
+ Obj.change(graph2, () => {
627
+ graph2.query.ast = ast;
628
+ });
629
+ }
630
+ }
631
+ }
632
+ if (cell.name && cell.graph?.target) {
633
+ const graph2 = Obj.getSnapshot(cell.graph?.target);
634
+ const query = Query.fromAst(graph2.query.ast);
635
+ const objects = await db.query(query).run();
636
+ const objectIds = objects?.map((obj) => obj.id);
637
+ setQueryValues((prev) => ({
638
+ ...prev,
639
+ [cell.name]: objectIds
640
+ }));
641
+ }
642
+ }
643
+ }
644
+ }, [
645
+ db,
646
+ notebook,
647
+ graph
648
+ ]);
649
+ const [promptResults, setPromptResults] = useState({});
650
+ const handleExecPrompts = useComputeRuntimeCallback(db?.spaceId, Effect.fnUntraced(function* () {
651
+ invariant2(graph, void 0, {
652
+ F: __dxlog_file3,
653
+ L: 97,
654
+ S: this,
655
+ A: [
656
+ "graph",
657
+ ""
658
+ ]
659
+ });
660
+ const prompts = notebook?.cells.filter((cell) => cell.type === "prompt").map((cell) => cell.prompt).filter(isNonNullable) ?? [];
661
+ for (const prompt of prompts) {
662
+ yield* runPrompt({
663
+ prompt,
664
+ input: {
665
+ ...queryValues,
666
+ ...graph.getValuesByName()
667
+ },
668
+ onResult: (result) => setPromptResults((prev) => ({
669
+ ...prev,
670
+ [prompt.dxn.toString()]: result
671
+ }))
672
+ });
673
+ }
674
+ }), [
675
+ notebook,
676
+ graph,
677
+ queryValues
678
+ ]);
679
+ const handleCompute = useCallback(async () => {
680
+ await graph?.evaluate();
681
+ await handleExecQueries();
682
+ await handleExecPrompts();
683
+ }, [
684
+ graph,
685
+ handleExecQueries,
686
+ handleExecPrompts
687
+ ]);
688
+ const handleRearrange = useCallback((source, target) => {
689
+ invariant2(notebook, void 0, {
690
+ F: __dxlog_file3,
691
+ L: 130,
692
+ S: void 0,
693
+ A: [
694
+ "notebook",
695
+ ""
696
+ ]
697
+ });
698
+ const from = notebook.cells.findIndex((cell) => cell.id === source.id);
699
+ const to = notebook.cells.findIndex((cell) => cell.id === target.id);
700
+ if (from != null && to != null) {
701
+ Obj.change(notebook, (n) => {
702
+ const cell = n.cells.splice(from, 1)[0];
703
+ if (cell) {
704
+ n.cells.splice(to, 0, cell);
705
+ }
706
+ });
707
+ }
708
+ }, [
709
+ notebook
710
+ ]);
711
+ const handleCellInsert = useCallback(async (type, after) => {
712
+ invariant2(notebook, void 0, {
713
+ F: __dxlog_file3,
714
+ L: 147,
715
+ S: void 0,
716
+ A: [
717
+ "notebook",
718
+ ""
719
+ ]
720
+ });
721
+ const cell = {
722
+ id: crypto.randomUUID(),
723
+ type
724
+ };
725
+ switch (type) {
726
+ case "markdown":
727
+ case "script":
728
+ case "query": {
729
+ cell.source = Ref.make(Text.make());
730
+ break;
731
+ }
732
+ case "prompt": {
733
+ if (db) {
734
+ const objects = await db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
735
+ const blueprints = objects.filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key)).map((blueprint) => Ref.make(blueprint));
736
+ cell.prompt = Ref.make(Prompt.make({
737
+ instructions: "",
738
+ blueprints
739
+ }));
740
+ }
741
+ break;
742
+ }
743
+ }
744
+ const idx = after ? notebook.cells.findIndex((cell2) => cell2.id === after) : notebook.cells.length;
745
+ Obj.change(notebook, (n) => {
746
+ n.cells.splice(idx, 0, cell);
747
+ });
748
+ }, [
749
+ db,
750
+ notebook
751
+ ]);
752
+ const handleCellDelete = useCallback((id) => {
753
+ invariant2(notebook, void 0, {
754
+ F: __dxlog_file3,
755
+ L: 179,
756
+ S: void 0,
757
+ A: [
758
+ "notebook",
759
+ ""
760
+ ]
761
+ });
762
+ const idx = notebook.cells.findIndex((cell) => cell.id === id);
763
+ if (idx !== -1) {
764
+ Obj.change(notebook, (n) => {
765
+ n.cells.splice(idx, 1);
766
+ });
767
+ }
768
+ }, [
769
+ notebook
770
+ ]);
771
+ return /* @__PURE__ */ React.createElement(Layout.Main, {
772
+ role,
773
+ toolbar: true
774
+ }, /* @__PURE__ */ React.createElement(Toolbar.Root, {
775
+ disabled: !hasAttention,
776
+ textBlockWidth: true
777
+ }, /* @__PURE__ */ React.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React.createElement(DropdownMenu.Trigger, {
778
+ asChild: true
779
+ }, /* @__PURE__ */ React.createElement(IconButton, {
780
+ icon: "ph--plus--regular",
781
+ iconOnly: true,
782
+ label: t("notebook cell insert label")
783
+ })), /* @__PURE__ */ React.createElement(NotebookMenu, {
784
+ onCellInsert: handleCellInsert
785
+ })), /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
786
+ icon: "ph--play--fill",
787
+ iconOnly: true,
788
+ label: t("compute label"),
789
+ classNames: "text-green-500",
790
+ onClick: handleCompute
791
+ })), /* @__PURE__ */ React.createElement("div", {
792
+ role: "none",
793
+ className: "flex bs-full overflow-hidden -mis-[1px] -mie-[1px]"
794
+ }, /* @__PURE__ */ React.createElement(NotebookStack, {
795
+ classNames: "container-max-width border-l border-r border-subduedSeparator",
796
+ db,
797
+ notebook,
798
+ graph,
799
+ env,
800
+ promptResults,
801
+ onRearrange: handleRearrange,
802
+ onCellInsert: handleCellInsert,
803
+ onCellDelete: handleCellDelete
804
+ })));
805
+ };
806
+ var NotebookContainer_default = NotebookContainer;
807
+ var runPrompt = Effect.fn(function* ({ prompt, input, onResult }) {
808
+ const inputData = {
809
+ prompt,
810
+ input
811
+ };
812
+ const tracer = yield* TracingService;
813
+ const trace = yield* tracer.traceInvocationStart({
814
+ target: void 0,
815
+ payload: {
816
+ data: {}
817
+ }
818
+ });
819
+ const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop), Effect.exit);
820
+ Exit.match(result, {
821
+ onFailure: (cause) => {
822
+ const error = Cause.prettyErrors(cause)[0];
823
+ log2.error(error.message, error.cause ?? error.stack, {
824
+ F: __dxlog_file3,
825
+ L: 257,
826
+ S: this,
827
+ C: (f, a) => f(...a)
828
+ });
829
+ onResult(error.message);
830
+ },
831
+ onSuccess: (result2) => {
832
+ onResult(result2.note);
833
+ }
834
+ });
835
+ yield* tracer.traceInvocationEnd({
836
+ trace,
837
+ // TODO(dmaretskyi): Might miss errors.
838
+ exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : void 0
839
+ });
840
+ });
841
+ export {
842
+ NotebookContainer,
843
+ NotebookContainer_default as default
844
+ };
845
+ //# sourceMappingURL=NotebookContainer-4MM2VAQF.mjs.map