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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/dist/lib/browser/DeploymentDialog-GXNRUXF6.mjs +14 -0
  2. package/dist/lib/browser/{NotebookContainer-RTESC4OV.mjs → NotebookContainer-4MM2VAQF.mjs} +267 -239
  3. package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs +149 -0
  5. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs.map +7 -0
  6. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs +68 -0
  7. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs +17 -0
  9. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs.map +7 -0
  10. package/dist/lib/browser/blueprints/index.mjs +8 -0
  11. package/dist/lib/browser/chunk-3O2DQGCP.mjs +113 -0
  12. package/dist/lib/browser/chunk-3O2DQGCP.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-BTWHM6FH.mjs +270 -0
  14. package/dist/lib/browser/chunk-BTWHM6FH.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
  16. package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
  18. package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-IQRLM6JK.mjs +137 -0
  20. package/dist/lib/browser/chunk-IQRLM6JK.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-NWSK27QB.mjs +606 -0
  22. package/dist/lib/browser/chunk-NWSK27QB.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-2G2NA6DQ.mjs → chunk-UX4GHJ5E.mjs} +28 -11
  24. package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
  25. package/dist/lib/browser/{chunk-5JSNQYZZ.mjs → chunk-WX2NVNFQ.mjs} +236 -196
  26. package/dist/lib/browser/chunk-WX2NVNFQ.mjs.map +7 -0
  27. package/dist/lib/browser/{chunk-EB6AXFXO.mjs → chunk-WYR4QHPE.mjs} +1 -1
  28. package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
  29. package/dist/lib/browser/compiler-XRBFQFXO.mjs +161 -0
  30. package/dist/lib/browser/compiler-XRBFQFXO.mjs.map +7 -0
  31. package/dist/lib/browser/index.mjs +96 -125
  32. package/dist/lib/browser/index.mjs.map +4 -4
  33. package/dist/lib/browser/meta.json +1 -1
  34. package/dist/lib/browser/operation-resolver-MUNR376F.mjs +82 -0
  35. package/dist/lib/browser/operation-resolver-MUNR376F.mjs.map +7 -0
  36. package/dist/lib/browser/{react-surface-QEQ3QUQA.mjs → react-surface-5TEC66UY.mjs} +53 -42
  37. package/dist/lib/browser/react-surface-5TEC66UY.mjs.map +7 -0
  38. package/dist/lib/browser/settings-R4WKREUJ.mjs +35 -0
  39. package/dist/lib/browser/settings-R4WKREUJ.mjs.map +7 -0
  40. package/dist/lib/browser/templates/index.mjs +1 -1
  41. package/dist/lib/browser/types/index.mjs +9 -5
  42. package/dist/lib/node-esm/{DeploymentDialog-GL5AUWMR.mjs → DeploymentDialog-EVFV2VJT.mjs} +6 -6
  43. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs.map +7 -0
  44. package/dist/lib/node-esm/{NotebookContainer-SVD3A3D6.mjs → NotebookContainer-QLW5ZYGS.mjs} +267 -239
  45. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs.map +7 -0
  46. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs +150 -0
  47. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs.map +7 -0
  48. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs +69 -0
  49. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs.map +7 -0
  50. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs +18 -0
  51. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs.map +7 -0
  52. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  53. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  54. package/dist/lib/node-esm/{chunk-57JA6XL5.mjs → chunk-4F5FJZ36.mjs} +28 -11
  55. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-IBV2DR36.mjs → chunk-5HSJPAK7.mjs} +1 -1
  57. package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs +114 -0
  59. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs.map +7 -0
  60. package/dist/lib/node-esm/{chunk-IQTBVH4L.mjs → chunk-MGWKULCD.mjs} +236 -196
  61. package/dist/lib/node-esm/chunk-MGWKULCD.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
  63. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs +271 -0
  65. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
  67. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs +138 -0
  69. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs +607 -0
  71. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs.map +7 -0
  72. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs +162 -0
  73. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs.map +7 -0
  74. package/dist/lib/node-esm/index.mjs +96 -125
  75. package/dist/lib/node-esm/index.mjs.map +4 -4
  76. package/dist/lib/node-esm/meta.json +1 -1
  77. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs +83 -0
  78. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs.map +7 -0
  79. package/dist/lib/node-esm/{react-surface-U77YT7VF.mjs → react-surface-O3UDMKOQ.mjs} +53 -42
  80. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs.map +7 -0
  81. package/dist/lib/node-esm/settings-OFIMHU7K.mjs +36 -0
  82. package/dist/lib/node-esm/settings-OFIMHU7K.mjs.map +7 -0
  83. package/dist/lib/node-esm/templates/index.mjs +1 -1
  84. package/dist/lib/node-esm/types/index.mjs +9 -5
  85. package/dist/types/src/ScriptPlugin.d.ts +2 -1
  86. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  87. package/dist/types/src/blueprints/index.d.ts +2 -0
  88. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  89. package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
  90. package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  92. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  94. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  96. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  100. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
  104. package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/index.d.ts +6 -7
  108. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  109. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  110. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  112. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  116. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/settings/index.d.ts +7 -0
  118. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/settings/settings.d.ts +9 -0
  120. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  121. package/dist/types/src/compiler/compiler.d.ts +1 -1
  122. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  123. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  124. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +4 -3
  125. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  126. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  127. package/dist/types/src/components/NotebookContainer.d.ts +3 -5
  128. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
  129. package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -247
  130. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +3 -3
  132. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
  133. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
  134. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
  135. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +5 -1
  136. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
  137. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  138. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  139. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  140. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  141. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  142. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  143. package/dist/types/src/components/ScriptContainer.d.ts +4 -5
  144. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  145. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +2 -2
  146. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  147. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +5 -1
  148. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  149. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  150. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +4 -2
  151. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  152. package/dist/types/src/components/TestPanel/TestContainer.d.ts +1 -1
  153. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  154. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +3 -2
  155. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  156. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
  157. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  158. package/dist/types/src/components/index.d.ts +2 -2
  159. package/dist/types/src/components/index.d.ts.map +1 -1
  160. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  161. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  162. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  163. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  164. package/dist/types/src/hooks/deploy.d.ts +10 -27
  165. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  166. package/dist/types/src/hooks/format.d.ts +2 -2
  167. package/dist/types/src/hooks/format.d.ts.map +1 -1
  168. package/dist/types/src/hooks/index.d.ts +1 -0
  169. package/dist/types/src/hooks/index.d.ts.map +1 -1
  170. package/dist/types/src/hooks/template.d.ts +2 -2
  171. package/dist/types/src/hooks/template.d.ts.map +1 -1
  172. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  173. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  174. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  175. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  176. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  177. package/dist/types/src/index.d.ts +1 -1
  178. package/dist/types/src/index.d.ts.map +1 -1
  179. package/dist/types/src/meta.d.ts +2 -2
  180. package/dist/types/src/meta.d.ts.map +1 -1
  181. package/dist/types/src/notebook/compute-graph.d.ts +24 -11
  182. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
  183. package/dist/types/src/templates/anthropic.d.ts +8 -0
  184. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  185. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  186. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  187. package/dist/types/src/templates/commentary.d.ts +16 -0
  188. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  189. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  190. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  191. package/dist/types/src/templates/forex.d.ts +4 -1
  192. package/dist/types/src/templates/forex.d.ts.map +1 -1
  193. package/dist/types/src/templates/index.d.ts +12 -3
  194. package/dist/types/src/templates/index.d.ts.map +1 -1
  195. package/dist/types/src/templates/ping.d.ts +1 -4
  196. package/dist/types/src/templates/ping.d.ts.map +1 -1
  197. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  198. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  199. package/dist/types/src/translations.d.ts +2 -0
  200. package/dist/types/src/translations.d.ts.map +1 -1
  201. package/dist/types/src/types/Notebook.d.ts +90 -21
  202. package/dist/types/src/types/Notebook.d.ts.map +1 -1
  203. package/dist/types/src/types/actions.d.ts +30 -44
  204. package/dist/types/src/types/actions.d.ts.map +1 -1
  205. package/dist/types/src/types/capabilities.d.ts +12 -0
  206. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  207. package/dist/types/src/types/events.d.ts +5 -0
  208. package/dist/types/src/types/events.d.ts.map +1 -0
  209. package/dist/types/src/types/index.d.ts +2 -0
  210. package/dist/types/src/types/index.d.ts.map +1 -1
  211. package/dist/types/src/util/deploy.d.ts.map +1 -1
  212. package/dist/types/src/util/functions.d.ts.map +1 -1
  213. package/dist/types/tsconfig.tsbuildinfo +1 -1
  214. package/package.json +113 -87
  215. package/src/ScriptPlugin.tsx +36 -75
  216. package/src/blueprints/index.ts +5 -0
  217. package/src/blueprints/script-blueprint.ts +24 -0
  218. package/src/capabilities/app-graph-builder/app-graph-builder.ts +55 -0
  219. package/src/capabilities/app-graph-builder/index.ts +7 -0
  220. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -94
  221. package/src/capabilities/artifact-definition/index.ts +7 -0
  222. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  223. package/src/capabilities/blueprint-definition/index.ts +7 -0
  224. package/src/capabilities/compiler/compiler.ts +103 -0
  225. package/src/capabilities/compiler/index.ts +7 -0
  226. package/src/capabilities/index.ts +6 -10
  227. package/src/capabilities/operation-resolver/index.ts +7 -0
  228. package/src/capabilities/operation-resolver/operation-resolver.ts +74 -0
  229. package/src/capabilities/react-surface/index.ts +7 -0
  230. package/src/capabilities/react-surface/react-surface.tsx +118 -0
  231. package/src/capabilities/settings/index.ts +7 -0
  232. package/src/capabilities/settings/settings.ts +32 -0
  233. package/src/compiler/compiler.ts +10 -3
  234. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +27 -23
  235. package/src/components/DeploymentDialog/DeploymentDialog.tsx +22 -42
  236. package/src/components/FrameContainer/FrameContainer.tsx +4 -2
  237. package/src/components/NotebookContainer.stories.tsx +23 -19
  238. package/src/components/NotebookContainer.tsx +54 -47
  239. package/src/components/NotebookStack/NotebookCell.tsx +22 -19
  240. package/src/components/NotebookStack/NotebookStack.stories.tsx +19 -18
  241. package/src/components/NotebookStack/NotebookStack.tsx +4 -4
  242. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  243. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  244. package/src/components/QueryEditor/index.ts +5 -0
  245. package/src/components/ScriptContainer.tsx +48 -33
  246. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +38 -15
  247. package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -17
  248. package/src/components/Settings/ScriptObjectSettings.tsx +44 -32
  249. package/src/components/Settings/ScriptPluginSettings.tsx +8 -3
  250. package/src/components/TestPanel/TestContainer.tsx +5 -5
  251. package/src/components/TestPanel/TestPanel.tsx +1 -1
  252. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +13 -8
  253. package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -68
  254. package/src/e2e/ai.test.ts +92 -0
  255. package/src/e2e/deploy.test.ts +64 -0
  256. package/src/hooks/deploy.ts +36 -28
  257. package/src/hooks/format.ts +5 -1
  258. package/src/hooks/index.ts +1 -0
  259. package/src/hooks/template.ts +15 -9
  260. package/src/hooks/useCompiler.ts +24 -0
  261. package/src/hooks/useCreateAndDeployScriptTemplates.ts +13 -19
  262. package/src/hooks/useToolbarState.ts +29 -5
  263. package/src/index.ts +1 -1
  264. package/src/meta.ts +2 -2
  265. package/src/notebook/compute-graph.test.ts +20 -8
  266. package/src/notebook/compute-graph.ts +45 -21
  267. package/src/templates/anthropic.ts +42 -0
  268. package/src/templates/chess-bot.ts +58 -0
  269. package/src/templates/commentary.ts +232 -0
  270. package/src/templates/data-generator.ts +1 -1
  271. package/src/templates/forex-effect.ts +22 -27
  272. package/src/templates/forex.ts +7 -6
  273. package/src/templates/index.ts +18 -5
  274. package/src/templates/ping.ts +14 -5
  275. package/src/testing/simulator.test.ts +40 -0
  276. package/src/translations.ts +2 -0
  277. package/src/types/Notebook.ts +10 -10
  278. package/src/types/actions.ts +17 -25
  279. package/src/types/capabilities.ts +17 -0
  280. package/src/types/events.ts +11 -0
  281. package/src/types/index.ts +2 -0
  282. package/src/types/types.ts +1 -1
  283. package/src/util/deploy.ts +23 -29
  284. package/src/util/functions.ts +27 -24
  285. package/src/vite-env.d.ts +2 -0
  286. package/dist/lib/browser/DeploymentDialog-MZX4T77L.mjs +0 -14
  287. package/dist/lib/browser/NotebookContainer-RTESC4OV.mjs.map +0 -7
  288. package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs +0 -147
  289. package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs.map +0 -7
  290. package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs +0 -66
  291. package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +0 -7
  292. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +0 -30
  293. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +0 -7
  294. package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +0 -7
  295. package/dist/lib/browser/chunk-3IJASGG5.mjs +0 -155
  296. package/dist/lib/browser/chunk-3IJASGG5.mjs.map +0 -7
  297. package/dist/lib/browser/chunk-4M7U2WVT.mjs +0 -304
  298. package/dist/lib/browser/chunk-4M7U2WVT.mjs.map +0 -7
  299. package/dist/lib/browser/chunk-5JSNQYZZ.mjs.map +0 -7
  300. package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
  301. package/dist/lib/browser/chunk-GAFCKEII.mjs +0 -646
  302. package/dist/lib/browser/chunk-GAFCKEII.mjs.map +0 -7
  303. package/dist/lib/browser/chunk-LNNCD2H4.mjs +0 -102
  304. package/dist/lib/browser/chunk-LNNCD2H4.mjs.map +0 -7
  305. package/dist/lib/browser/chunk-M6KJPUJK.mjs +0 -111
  306. package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +0 -7
  307. package/dist/lib/browser/chunk-UOQ6NCH3.mjs +0 -15
  308. package/dist/lib/browser/chunk-UOQ6NCH3.mjs.map +0 -7
  309. package/dist/lib/browser/compiler-4KHRSX7J.mjs +0 -86
  310. package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +0 -7
  311. package/dist/lib/browser/intent-resolver-AFJ575VK.mjs +0 -104
  312. package/dist/lib/browser/intent-resolver-AFJ575VK.mjs.map +0 -7
  313. package/dist/lib/browser/react-surface-QEQ3QUQA.mjs.map +0 -7
  314. package/dist/lib/browser/settings-LNLSTZM4.mjs +0 -26
  315. package/dist/lib/browser/settings-LNLSTZM4.mjs.map +0 -7
  316. package/dist/lib/node-esm/NotebookContainer-SVD3A3D6.mjs.map +0 -7
  317. package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs +0 -148
  318. package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs.map +0 -7
  319. package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs +0 -67
  320. package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +0 -7
  321. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +0 -31
  322. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +0 -7
  323. package/dist/lib/node-esm/chunk-55JZVM6K.mjs +0 -16
  324. package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
  325. package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +0 -7
  326. package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +0 -113
  327. package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +0 -7
  328. package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
  329. package/dist/lib/node-esm/chunk-IQTBVH4L.mjs.map +0 -7
  330. package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs +0 -647
  331. package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs.map +0 -7
  332. package/dist/lib/node-esm/chunk-NNHWLRHT.mjs +0 -103
  333. package/dist/lib/node-esm/chunk-NNHWLRHT.mjs.map +0 -7
  334. package/dist/lib/node-esm/chunk-RIE676OW.mjs +0 -156
  335. package/dist/lib/node-esm/chunk-RIE676OW.mjs.map +0 -7
  336. package/dist/lib/node-esm/chunk-YRTA4EHU.mjs +0 -305
  337. package/dist/lib/node-esm/chunk-YRTA4EHU.mjs.map +0 -7
  338. package/dist/lib/node-esm/compiler-DU5NQISX.mjs +0 -87
  339. package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +0 -7
  340. package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs +0 -105
  341. package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs.map +0 -7
  342. package/dist/lib/node-esm/react-surface-U77YT7VF.mjs.map +0 -7
  343. package/dist/lib/node-esm/settings-IUFMOCXY.mjs +0 -27
  344. package/dist/lib/node-esm/settings-IUFMOCXY.mjs.map +0 -7
  345. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  346. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  347. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  348. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  349. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  350. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  351. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  352. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  353. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  354. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  355. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  356. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  357. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  358. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  359. package/dist/types/src/capabilities/settings.d.ts +0 -4
  360. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  361. package/dist/types/src/events.d.ts +0 -4
  362. package/dist/types/src/events.d.ts.map +0 -1
  363. package/dist/types/src/templates/chess.d.ts +0 -3
  364. package/dist/types/src/templates/chess.d.ts.map +0 -1
  365. package/src/capabilities/app-graph-builder.ts +0 -65
  366. package/src/capabilities/blueprint-definition.ts +0 -30
  367. package/src/capabilities/capabilities.ts +0 -12
  368. package/src/capabilities/compiler.ts +0 -34
  369. package/src/capabilities/intent-resolver.ts +0 -86
  370. package/src/capabilities/react-surface.tsx +0 -103
  371. package/src/capabilities/settings.ts +0 -21
  372. package/src/events.ts +0 -11
  373. package/src/templates/chess.ts +0 -49
  374. /package/dist/lib/browser/{DeploymentDialog-MZX4T77L.mjs.map → DeploymentDialog-GXNRUXF6.mjs.map} +0 -0
  375. /package/dist/lib/{node-esm/DeploymentDialog-GL5AUWMR.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability, Common } from '@dxos/app-framework';
8
+ import { createKvsStore } from '@dxos/effect';
9
+
10
+ import { meta } from '../../meta';
11
+ import { ScriptCapabilities, ScriptSettings } from '../../types';
12
+
13
+ export default Capability.makeModule(() =>
14
+ Effect.sync(() => {
15
+ const settingsAtom = createKvsStore({
16
+ key: meta.id,
17
+ schema: ScriptSettings,
18
+ defaultValue: () => ({
19
+ editorInputMode: 'vscode' as const,
20
+ }),
21
+ });
22
+
23
+ return [
24
+ Capability.contributes(ScriptCapabilities.Settings, settingsAtom),
25
+ Capability.contributes(Common.Capability.Settings, {
26
+ prefix: meta.id,
27
+ schema: ScriptSettings,
28
+ atom: settingsAtom,
29
+ }),
30
+ ];
31
+ }),
32
+ );
@@ -12,6 +12,8 @@ import ts from 'typescript';
12
12
 
13
13
  import { invariant } from '@dxos/invariant';
14
14
 
15
+ const GLOBALS = 'globals.d.ts';
16
+
15
17
  const defaultOptions: ts.CompilerOptions = {
16
18
  lib: ['DOM', 'es2022'],
17
19
  target: ts.ScriptTarget.ES2022,
@@ -23,16 +25,21 @@ export class Compiler {
23
25
 
24
26
  constructor(private readonly _options: ts.CompilerOptions = defaultOptions) {}
25
27
 
26
- async initialize(): Promise<void> {
28
+ async initialize(globals?: string): Promise<void> {
27
29
  if (this._env) {
28
30
  return;
29
31
  }
30
32
 
31
33
  // TODO(wittjosiah): Figure out how to get workers working in plugin packages.
32
34
  // https://github.com/val-town/codemirror-ts?tab=readme-ov-file#setup-worker
33
- this._fsMap = await createDefaultMapFromCDN(this._options, '5.5.4', true, ts);
35
+ this._fsMap = await createDefaultMapFromCDN(this._options, '5.7.2', true, ts);
36
+ if (globals) {
37
+ this._fsMap.set(GLOBALS, globals);
38
+ }
39
+
40
+ const rootFiles = globals ? [GLOBALS] : [];
34
41
  const system = createSystem(this._fsMap);
35
- this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);
42
+ this._env = createVirtualTypeScriptEnvironment(system, rootFiles, ts, this._options);
36
43
  }
37
44
 
38
45
  get environment() {
@@ -3,9 +3,9 @@
3
3
  //
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React from 'react';
6
+ import React, { useMemo } from 'react';
7
7
 
8
- import { IntentPlugin } from '@dxos/app-framework';
8
+ import { OperationPlugin } from '@dxos/app-framework';
9
9
  import { withPluginManager } from '@dxos/app-framework/testing';
10
10
  import { Obj } from '@dxos/echo';
11
11
  import { ClientPlugin } from '@dxos/plugin-client';
@@ -15,44 +15,48 @@ import { AccessToken } from '@dxos/types';
15
15
 
16
16
  import { translations } from '../../translations';
17
17
 
18
- import { DeploymentDialog, type DeploymentDialogProps } from './DeploymentDialog';
19
-
20
- const DefaultStory = (props: DeploymentDialogProps) => {
18
+ import { DeploymentDialog } from './DeploymentDialog';
19
+
20
+ // TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
21
+ const DeploymentDialogStory = () => {
22
+ const accessToken = useMemo(
23
+ () =>
24
+ Obj.make(AccessToken.AccessToken, {
25
+ source: 'example.com',
26
+ token: 'example-token',
27
+ }),
28
+ [],
29
+ );
30
+ const scriptTemplates = useMemo(
31
+ () => [
32
+ { id: 't-1', name: 'Script 1', source: 'template1' },
33
+ { id: 't-2', name: 'Script 2', source: 'template2' },
34
+ { id: 't-3', name: 'Script 3', source: 'template3' },
35
+ ],
36
+ [],
37
+ );
21
38
  return (
22
39
  <Dialog.Root defaultOpen={true}>
23
- <DeploymentDialog {...props} />
40
+ <DeploymentDialog accessToken={accessToken} scriptTemplates={scriptTemplates} />
24
41
  </Dialog.Root>
25
42
  );
26
43
  };
27
44
 
28
45
  const meta = {
29
46
  title: 'plugins/plugin-script/DeploymentDialog',
30
- component: DeploymentDialog,
31
- render: DefaultStory,
47
+ component: DeploymentDialogStory,
32
48
  parameters: { translations },
33
49
  // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
34
50
  decorators: [
35
51
  withTheme,
36
52
  withPluginManager({
37
- plugins: [IntentPlugin(), ClientPlugin({})],
53
+ plugins: [OperationPlugin(), ClientPlugin({})],
38
54
  }),
39
55
  ],
40
- } satisfies Meta<typeof DefaultStory>;
56
+ } satisfies Meta<typeof DeploymentDialogStory>;
41
57
 
42
58
  export default meta;
43
59
 
44
60
  type Story = StoryObj<typeof meta>;
45
61
 
46
- export const Default: Story = {
47
- args: {
48
- accessToken: Obj.make(AccessToken.AccessToken, {
49
- source: 'example.com',
50
- token: 'example-token',
51
- }),
52
- scriptTemplates: [
53
- { id: 't-1', name: 'Script 1', source: 'template1' },
54
- { id: 't-2', name: 'Script 2', source: 'template2' },
55
- { id: 't-3', name: 'Script 3', source: 'template3' },
56
- ],
57
- },
58
- };
62
+ export const Default: Story = {};
@@ -4,8 +4,8 @@
4
4
 
5
5
  import React, { useEffect, useMemo } from 'react';
6
6
 
7
- import { LayoutAction, createIntent } from '@dxos/app-framework';
8
- import { useIntentDispatcher } from '@dxos/app-framework/react';
7
+ import { Common } from '@dxos/app-framework';
8
+ import { useOperationInvoker } from '@dxos/app-framework/react';
9
9
  import { getSpace } from '@dxos/react-client/echo';
10
10
  import { Button, Dialog, IconButton, useTranslation } from '@dxos/react-ui';
11
11
  import { type AccessToken } from '@dxos/types';
@@ -33,53 +33,33 @@ export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDia
33
33
  // TODO(ZaymonFC): Thinking further. All of this should get moved to intents to run async in the background.
34
34
  // Deployment shouldn't be tied to the lifecycle of the dialogue component.
35
35
  const { handleCreateAndDeployScripts, status } = useCreateAndDeployScriptTemplates(space, scriptTemplates);
36
- const { dispatchPromise: dispatch } = useIntentDispatcher();
36
+ const { invokePromise } = useOperationInvoker();
37
37
 
38
38
  useEffect(() => {
39
39
  if (status === 'success') {
40
40
  // TODO(ZaymonFC): We can probably re-use this toast for normal script deployment.
41
- void dispatch(
42
- createIntent(LayoutAction.AddToast, {
43
- part: 'toast',
44
- subject: {
45
- id: `${meta.id}/deployment-success`,
46
- icon: 'ph--check--regular',
47
- duration: Infinity,
48
- title: ['script deployment toast label', { ns: meta.id, count: scriptTemplates.length }],
49
- description: ['script deployment toast description', { ns: meta.id, count: scriptTemplates.length }],
50
- closeLabel: ['script deployment toast close label', { ns: meta.id, count: scriptTemplates.length }],
51
- },
52
- }),
53
- );
54
- void dispatch(
55
- createIntent(LayoutAction.UpdateDialog, {
56
- part: 'dialog',
57
- options: { state: false },
58
- }),
59
- );
41
+ void invokePromise(Common.LayoutOperation.AddToast, {
42
+ id: `${meta.id}/deployment-success`,
43
+ icon: 'ph--check--regular',
44
+ duration: Infinity,
45
+ title: ['script deployment toast label', { ns: meta.id, count: scriptTemplates.length }],
46
+ description: ['script deployment toast description', { ns: meta.id, count: scriptTemplates.length }],
47
+ closeLabel: ['script deployment toast close label', { ns: meta.id, count: scriptTemplates.length }],
48
+ });
49
+ void invokePromise(Common.LayoutOperation.UpdateDialog, { state: false });
60
50
  }
61
51
  if (status === 'error') {
62
- void dispatch(
63
- createIntent(LayoutAction.UpdateDialog, {
64
- part: 'dialog',
65
- options: { state: false },
66
- }),
67
- );
68
- void dispatch(
69
- createIntent(LayoutAction.AddToast, {
70
- part: 'toast',
71
- subject: {
72
- id: `${meta.id}/deployment-error`,
73
- icon: 'ph--warning--regular',
74
- duration: Infinity,
75
- title: ['script deployment error toast label', { ns: meta.id, count: scriptTemplates.length }],
76
- description: ['script deployment error toast description', { ns: meta.id, count: scriptTemplates.length }],
77
- closeLabel: ['script deployment error toast close label', { ns: meta.id, count: scriptTemplates.length }],
78
- },
79
- }),
80
- );
52
+ void invokePromise(Common.LayoutOperation.UpdateDialog, { state: false });
53
+ void invokePromise(Common.LayoutOperation.AddToast, {
54
+ id: `${meta.id}/deployment-error`,
55
+ icon: 'ph--warning--regular',
56
+ duration: Infinity,
57
+ title: ['script deployment error toast label', { ns: meta.id, count: scriptTemplates.length }],
58
+ description: ['script deployment error toast description', { ns: meta.id, count: scriptTemplates.length }],
59
+ closeLabel: ['script deployment error toast close label', { ns: meta.id, count: scriptTemplates.length }],
60
+ });
81
61
  }
82
- }, [status, dispatch]);
62
+ }, [status, invokePromise]);
83
63
 
84
64
  return (
85
65
  <Dialog.Content>
@@ -9,9 +9,9 @@ import { type BundleResult } from '@dxos/functions-runtime/bundler';
9
9
  import { invariant } from '@dxos/invariant';
10
10
  import { log } from '@dxos/log';
11
11
  import { useClient } from '@dxos/react-client';
12
- import { baseSurface, mx } from '@dxos/react-ui-theme';
13
12
  import { createProtoRpcPeer } from '@dxos/rpc';
14
13
  import { createIFramePort } from '@dxos/rpc-tunnel';
14
+ import { baseSurface, mx } from '@dxos/ui-theme';
15
15
 
16
16
  export type FrameContainerProps = {
17
17
  containerUrl: string;
@@ -49,7 +49,9 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
49
49
  invariant(result.sourceHash, 'Source hash is required.');
50
50
  const sourceHash = Buffer.from(result.sourceHash).toString('hex');
51
51
  const src =
52
- 'bundle' in result ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(result.bundle)}` : undefined;
52
+ 'bundle' in result
53
+ ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(new TextDecoder().decode(Object.values(result.bundle as any)[0] as Uint8Array))}`
54
+ : undefined;
53
55
 
54
56
  return (
55
57
  <>
@@ -3,10 +3,10 @@
3
3
  //
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
6
7
  import React from 'react';
7
8
 
8
9
  import { SERVICES_CONFIG } from '@dxos/ai/testing';
9
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
10
10
  import { withPluginManager } from '@dxos/app-framework/testing';
11
11
  import { Agent } from '@dxos/assistant-toolkit';
12
12
  import { Filter } from '@dxos/echo';
@@ -16,7 +16,7 @@ import { AutomationPlugin } from '@dxos/plugin-automation';
16
16
  import { ClientPlugin } from '@dxos/plugin-client';
17
17
  import { ExplorerPlugin } from '@dxos/plugin-explorer';
18
18
  import { Markdown, MarkdownPlugin } from '@dxos/plugin-markdown';
19
- import { SpacePlugin } from '@dxos/plugin-space';
19
+ import { corePlugins } from '@dxos/plugin-testing';
20
20
  import { Config, useClient } from '@dxos/react-client';
21
21
  import { useQuery } from '@dxos/react-client/echo';
22
22
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
@@ -28,20 +28,21 @@ import { Notebook } from '../types';
28
28
 
29
29
  import { NotebookContainer } from './NotebookContainer';
30
30
 
31
- const meta = {
31
+ const meta: Meta<typeof NotebookContainer> = {
32
32
  title: 'plugins/plugin-script/NotebookContainer',
33
33
  component: NotebookContainer,
34
34
  render: (args) => {
35
35
  const client = useClient();
36
36
  const space = client.spaces.default;
37
37
  const notebooks = useQuery(space?.db, Filter.type(Notebook.Notebook));
38
- return <NotebookContainer {...args} notebook={notebooks[0]} />;
38
+ return <NotebookContainer {...args} subject={notebooks[0]} />;
39
39
  },
40
40
  decorators: [
41
41
  withTheme,
42
- withLayout({ container: 'column', classNames: 'is-prose' }),
42
+ withLayout({ layout: 'column', classNames: 'is-proseMaxWidth' }),
43
43
  withPluginManager({
44
44
  plugins: [
45
+ ...corePlugins(),
45
46
  ClientPlugin({
46
47
  // TODO(wittjosiah): ComputeRuntime requires edge to be configured or it will throw.
47
48
  config: new Config({
@@ -50,20 +51,18 @@ const meta = {
50
51
  },
51
52
  }),
52
53
  types: [...DataTypes, Notebook.Notebook, Function.Function, Markdown.Document],
53
- onClientInitialized: async ({ client }) => {
54
- await client.halo.createIdentity();
55
- await client.spaces.waitUntilReady();
56
- const space = client.spaces.default;
57
- await space.waitUntilReady();
54
+ onClientInitialized: ({ client }) =>
55
+ Effect.gen(function* () {
56
+ yield* Effect.promise(() => client.halo.createIdentity());
57
+ yield* Effect.promise(() => client.spaces.waitUntilReady());
58
+ const space = client.spaces.default;
59
+ yield* Effect.promise(() => space.waitUntilReady());
58
60
 
59
- space.db.add(createNotebook());
60
- space.db.add(Markdown.make({ content: '# Hello World' }));
61
- space.db.add(serializeFunction(Agent.prompt));
62
- },
61
+ space.db.add(createNotebook());
62
+ space.db.add(Markdown.make({ content: '# Hello World' }));
63
+ space.db.add(serializeFunction(Agent.prompt));
64
+ }),
63
65
  }),
64
- SpacePlugin({}),
65
- SettingsPlugin(),
66
- IntentPlugin(),
67
66
  AssistantPlugin(),
68
67
  AutomationPlugin(),
69
68
  ExplorerPlugin(),
@@ -74,10 +73,15 @@ const meta = {
74
73
  parameters: {
75
74
  translations,
76
75
  },
77
- } satisfies Meta<typeof NotebookContainer>;
76
+ };
78
77
 
79
78
  export default meta;
80
79
 
81
80
  type Story = StoryObj<typeof meta>;
82
81
 
83
- export const Default: Story = {};
82
+ export const Default: Story = {
83
+ args: {
84
+ role: 'article',
85
+ subject: undefined as any,
86
+ },
87
+ };
@@ -2,27 +2,26 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { RegistryContext } from '@effect-atom/atom-react';
5
6
  import * as Cause from 'effect/Cause';
6
7
  import * as Effect from 'effect/Effect';
7
8
  import * as Exit from 'effect/Exit';
8
- import React, { useCallback, useMemo, useState } from 'react';
9
+ import React, { useCallback, useContext, useMemo, useState } from 'react';
9
10
 
11
+ import { type SurfaceComponentProps } from '@dxos/app-framework/react';
10
12
  import { Agent } from '@dxos/assistant-toolkit';
11
13
  import { Blueprint, Prompt } from '@dxos/blueprints';
12
14
  import { Filter, Obj, Query, Ref } from '@dxos/echo';
13
15
  import { QueryBuilder } from '@dxos/echo-query';
14
- import { type FunctionDefinition, FunctionInvocationService } from '@dxos/functions';
15
- import { InvocationTracer } from '@dxos/functions-runtime';
16
- import { TracingServiceExt } from '@dxos/functions-runtime';
16
+ import { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';
17
17
  import { invariant } from '@dxos/invariant';
18
18
  import { log } from '@dxos/log';
19
19
  import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
20
20
  import { Graph } from '@dxos/plugin-explorer/types';
21
- import { getSpace } from '@dxos/react-client/echo';
22
21
  import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
23
22
  import { useAttention } from '@dxos/react-ui-attention';
24
- import { StackItem } from '@dxos/react-ui-stack';
25
- import { Text } from '@dxos/schema';
23
+ import { Layout } from '@dxos/react-ui-mosaic';
24
+ import { Text, View } from '@dxos/schema';
26
25
  import { isNonNullable } from '@dxos/util';
27
26
 
28
27
  import { meta } from '../meta';
@@ -36,24 +35,22 @@ const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/
36
35
 
37
36
  // TODO(burdon): Support calling named deployed functions (as with sheet).
38
37
 
39
- export type NotebookContainerProps = {
40
- role?: string;
41
- notebook?: Notebook.Notebook;
42
- } & Pick<TypescriptEditorProps, 'env'>;
38
+ export type NotebookContainerProps = SurfaceComponentProps<Notebook.Notebook, Pick<TypescriptEditorProps, 'env'>>;
43
39
 
44
- export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) => {
40
+ export const NotebookContainer = ({ role, subject: notebook, env }: NotebookContainerProps) => {
45
41
  const { t } = useTranslation(meta.id);
46
- const space = getSpace(notebook);
42
+ const registry = useContext(RegistryContext);
43
+ const db = notebook && Obj.getDatabase(notebook);
47
44
  const attendableId = notebook ? Obj.getDXN(notebook).toString() : '';
48
45
  const { hasAttention } = useAttention(attendableId);
49
46
 
50
47
  // TODO(burdon): Consolidate execution and state (with graph).
51
48
  // Generalize ComputeGraph evaluation function (using effects).
52
- const graph = useMemo(() => notebook && new ComputeGraph(notebook), [notebook]);
49
+ const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [notebook, registry]);
53
50
 
54
51
  const [queryValues, setQueryValues] = useState<Record<string, any>>({});
55
52
  const handleExecQueries = useCallback(async () => {
56
- invariant(space);
53
+ invariant(db);
57
54
 
58
55
  const builder = new QueryBuilder();
59
56
  for (const cell of notebook?.cells ?? []) {
@@ -63,35 +60,39 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
63
60
  const { name, filter } = builder.build(source);
64
61
  if (filter) {
65
62
  const ast = Query.select(filter).ast;
66
- const view = cell.view?.target;
67
- if (!view) {
68
- const graph = Graph.make({ query: { ast } });
69
- const { view } = await Graph.makeView({
70
- space,
71
- presentation: graph,
63
+ const graph = cell.graph?.target;
64
+ if (!graph) {
65
+ const { view } = await View.makeFromDatabase({ db });
66
+ const newGraph = Graph.make({ query: { ast }, view });
67
+ Obj.change(notebook!, (n) => {
68
+ const c = n.cells.find((c) => c.id === cell.id);
69
+ if (c) {
70
+ c.graph = Ref.make(newGraph);
71
+ c.name = name;
72
+ }
72
73
  });
73
- cell.view = Ref.make(view);
74
- cell.name = name;
75
74
  } else {
76
- view.query.ast = ast;
75
+ Obj.change(graph, () => {
76
+ graph.query.ast = ast;
77
+ });
77
78
  }
78
79
  }
79
80
  }
80
81
 
81
- if (cell.name && cell.view?.target) {
82
- const view = Obj.getSnapshot(cell.view?.target);
83
- const query = Query.fromAst(view.query.ast);
84
- const result = await space?.db.query(query).run();
85
- const objectIds = result?.objects?.map((obj) => obj.id);
82
+ if (cell.name && cell.graph?.target) {
83
+ const graph = Obj.getSnapshot(cell.graph?.target);
84
+ const query = Query.fromAst(graph.query.ast);
85
+ const objects = await db.query(query).run();
86
+ const objectIds = objects?.map((obj) => obj.id);
86
87
  setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));
87
88
  }
88
89
  }
89
90
  }
90
- }, [space, notebook, graph]);
91
+ }, [db, notebook, graph]);
91
92
 
92
93
  const [promptResults, setPromptResults] = useState<Record<string, string>>({});
93
94
  const handleExecPrompts = useComputeRuntimeCallback(
94
- space,
95
+ db?.spaceId,
95
96
  Effect.fnUntraced(function* () {
96
97
  invariant(graph);
97
98
 
@@ -104,7 +105,7 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
104
105
  for (const prompt of prompts) {
105
106
  yield* runPrompt({
106
107
  prompt,
107
- input: { ...queryValues, ...graph.valuesByName.value },
108
+ input: { ...queryValues, ...graph.getValuesByName() },
108
109
  onResult: (result) =>
109
110
  setPromptResults((prev) => ({
110
111
  ...prev,
@@ -130,10 +131,12 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
130
131
  const from = notebook.cells.findIndex((cell) => cell.id === source.id);
131
132
  const to = notebook.cells.findIndex((cell) => cell.id === target.id);
132
133
  if (from != null && to != null) {
133
- const cell = notebook.cells.splice(from, 1)[0];
134
- if (cell) {
135
- notebook.cells.splice(to, 0, cell);
136
- }
134
+ Obj.change(notebook, (n) => {
135
+ const cell = n.cells.splice(from, 1)[0];
136
+ if (cell) {
137
+ n.cells.splice(to, 0, cell);
138
+ }
139
+ });
137
140
  }
138
141
  },
139
142
  [notebook],
@@ -152,9 +155,9 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
152
155
  }
153
156
 
154
157
  case 'prompt': {
155
- if (space) {
156
- const result = await space.db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
157
- const blueprints = result.objects
158
+ if (db) {
159
+ const objects = await db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
160
+ const blueprints = objects
158
161
  .filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key))
159
162
  .map((blueprint) => Ref.make(blueprint));
160
163
  cell.prompt = Ref.make(Prompt.make({ instructions: '', blueprints }));
@@ -164,9 +167,11 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
164
167
  }
165
168
 
166
169
  const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;
167
- notebook.cells.splice(idx, 0, cell);
170
+ Obj.change(notebook, (n) => {
171
+ n.cells.splice(idx, 0, cell);
172
+ });
168
173
  },
169
- [space, notebook],
174
+ [db, notebook],
170
175
  );
171
176
 
172
177
  const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(
@@ -174,14 +179,16 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
174
179
  invariant(notebook);
175
180
  const idx = notebook.cells.findIndex((cell) => cell.id === id);
176
181
  if (idx !== -1) {
177
- notebook.cells.splice(idx, 1);
182
+ Obj.change(notebook, (n) => {
183
+ n.cells.splice(idx, 1);
184
+ });
178
185
  }
179
186
  },
180
187
  [notebook],
181
188
  );
182
189
 
183
190
  return (
184
- <StackItem.Content toolbar>
191
+ <Layout.Main role={role} toolbar>
185
192
  <Toolbar.Root disabled={!hasAttention} textBlockWidth>
186
193
  <DropdownMenu.Root>
187
194
  <DropdownMenu.Trigger asChild>
@@ -200,7 +207,7 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
200
207
  <div role='none' className='flex bs-full overflow-hidden -mis-[1px] -mie-[1px]'>
201
208
  <NotebookStack
202
209
  classNames='container-max-width border-l border-r border-subduedSeparator'
203
- space={space}
210
+ db={db}
204
211
  notebook={notebook}
205
212
  graph={graph}
206
213
  env={env}
@@ -210,7 +217,7 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
210
217
  onCellDelete={handleCellDelete}
211
218
  />
212
219
  </div>
213
- </StackItem.Content>
220
+ </Layout.Main>
214
221
  );
215
222
  };
216
223
 
@@ -230,7 +237,7 @@ const runPrompt = Effect.fn(function* ({
230
237
  prompt,
231
238
  input,
232
239
  };
233
- const tracer = yield* InvocationTracer;
240
+ const tracer = yield* TracingService;
234
241
  const trace = yield* tracer.traceInvocationStart({
235
242
  target: undefined,
236
243
  payload: {
@@ -240,7 +247,7 @@ const runPrompt = Effect.fn(function* ({
240
247
 
241
248
  // Invoke the function.
242
249
  const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
243
- Effect.provide(TracingServiceExt.layerQueue(trace.invocationTraceQueue)),
250
+ Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),
244
251
  Effect.exit,
245
252
  );
246
253