@dxos/plugin-script 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f

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