@dxos/plugin-script 0.8.4-main.67995b8 → 0.8.4-main.ae835ea

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 (304) hide show
  1. package/dist/lib/browser/DeploymentDialog-E5NXT4UQ.mjs +14 -0
  2. package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs +817 -0
  3. package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs +148 -0
  5. package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs.map +7 -0
  6. package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-LEOPGBJD.mjs} +11 -9
  7. package/dist/lib/browser/app-graph-builder-LEOPGBJD.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +30 -0
  9. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-5S5YQNJZ.mjs +304 -0
  11. package/dist/lib/browser/chunk-5S5YQNJZ.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-A5K3TXYA.mjs} +29 -43
  13. package/dist/lib/browser/chunk-A5K3TXYA.mjs.map +7 -0
  14. package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
  15. package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-HCURXADW.mjs +102 -0
  17. package/dist/lib/browser/chunk-HCURXADW.mjs.map +7 -0
  18. package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-HHTOAI2J.mjs} +161 -72
  19. package/dist/lib/browser/chunk-HHTOAI2J.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-IQMYIWHG.mjs} +15 -15
  21. package/dist/lib/browser/chunk-IQMYIWHG.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  23. package/dist/lib/browser/chunk-LI4P25M5.mjs +111 -0
  24. package/dist/lib/browser/chunk-LI4P25M5.mjs.map +7 -0
  25. package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-Q2DGRQRN.mjs} +75 -53
  26. package/dist/lib/browser/chunk-Q2DGRQRN.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
  28. package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
  29. package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
  30. package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-Q4UY2COU.mjs} +9 -5
  31. package/dist/lib/browser/compiler-Q4UY2COU.mjs.map +7 -0
  32. package/dist/lib/browser/index.mjs +109 -44
  33. package/dist/lib/browser/index.mjs.map +3 -3
  34. package/dist/lib/browser/{intent-resolver-S3H2SMUY.mjs → intent-resolver-AMMHATM7.mjs} +40 -24
  35. package/dist/lib/browser/intent-resolver-AMMHATM7.mjs.map +7 -0
  36. package/dist/lib/browser/meta.json +1 -1
  37. package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-X4NATU6B.mjs} +43 -19
  38. package/dist/lib/browser/react-surface-X4NATU6B.mjs.map +7 -0
  39. package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-6UXY7F7D.mjs} +10 -8
  40. package/dist/lib/browser/settings-6UXY7F7D.mjs.map +7 -0
  41. package/dist/lib/browser/templates/index.mjs +2 -1
  42. package/dist/lib/browser/types/index.mjs +8 -4
  43. package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs +15 -0
  44. package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs.map +7 -0
  45. package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs +818 -0
  46. package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs.map +7 -0
  47. package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs +149 -0
  48. package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs.map +7 -0
  49. package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-XJ3MY5BM.mjs} +11 -9
  50. package/dist/lib/node-esm/app-graph-builder-XJ3MY5BM.mjs.map +7 -0
  51. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +31 -0
  52. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-2GVTWESW.mjs +90 -0
  54. package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +7 -0
  55. package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
  56. package/dist/lib/node-esm/chunk-EJLYOSD7.mjs +113 -0
  57. package/dist/lib/node-esm/chunk-EJLYOSD7.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-GA27XSEY.mjs} +29 -43
  59. package/dist/lib/node-esm/chunk-GA27XSEY.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  61. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  62. package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
  63. package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-N2XLVOFB.mjs +103 -0
  65. package/dist/lib/node-esm/chunk-N2XLVOFB.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-O7HXE72S.mjs} +75 -53
  67. package/dist/lib/node-esm/chunk-O7HXE72S.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-OZ6LCME4.mjs} +161 -72
  69. package/dist/lib/node-esm/chunk-OZ6LCME4.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-TUGLYZDT.mjs +305 -0
  71. package/dist/lib/node-esm/chunk-TUGLYZDT.mjs.map +7 -0
  72. package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-UEGPBCSF.mjs} +15 -15
  73. package/dist/lib/node-esm/chunk-UEGPBCSF.mjs.map +7 -0
  74. package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-I6A4KE6E.mjs} +9 -5
  75. package/dist/lib/node-esm/compiler-I6A4KE6E.mjs.map +7 -0
  76. package/dist/lib/node-esm/index.mjs +109 -44
  77. package/dist/lib/node-esm/index.mjs.map +3 -3
  78. package/dist/lib/node-esm/{intent-resolver-OHKNJFCC.mjs → intent-resolver-YKLZQR7U.mjs} +40 -24
  79. package/dist/lib/node-esm/intent-resolver-YKLZQR7U.mjs.map +7 -0
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-LVGLBSTE.mjs} +43 -19
  82. package/dist/lib/node-esm/react-surface-LVGLBSTE.mjs.map +7 -0
  83. package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-O4EZPUE3.mjs} +10 -8
  84. package/dist/lib/node-esm/settings-O4EZPUE3.mjs.map +7 -0
  85. package/dist/lib/node-esm/templates/index.mjs +2 -1
  86. package/dist/lib/node-esm/types/index.mjs +8 -4
  87. package/dist/types/src/ScriptPlugin.d.ts +1 -1
  88. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  90. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
  92. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  94. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/compiler.d.ts +1 -1
  96. package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/index.d.ts +6 -6
  98. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  100. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  101. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  102. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  103. package/dist/types/src/capabilities/settings.d.ts +1 -1
  104. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  105. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
  106. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  107. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +243 -13
  108. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  109. package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
  110. package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
  111. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  112. package/dist/types/src/components/NotebookContainer.d.ts +10 -0
  113. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  114. package/dist/types/src/components/NotebookContainer.stories.d.ts +251 -0
  115. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  116. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
  117. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
  118. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
  119. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
  120. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
  121. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  122. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +245 -0
  123. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  124. package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
  125. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  126. package/dist/types/src/components/ScriptContainer.d.ts +4 -4
  127. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  128. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
  129. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  130. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +242 -10
  131. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  132. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  133. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  134. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
  135. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  136. package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
  137. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  138. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
  139. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  140. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
  141. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  142. package/dist/types/src/components/index.d.ts +3 -4
  143. package/dist/types/src/components/index.d.ts.map +1 -1
  144. package/dist/types/src/events.d.ts.map +1 -1
  145. package/dist/types/src/hooks/deploy.d.ts +17 -16
  146. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  147. package/dist/types/src/hooks/format.d.ts +2 -2
  148. package/dist/types/src/hooks/format.d.ts.map +1 -1
  149. package/dist/types/src/hooks/template.d.ts +4 -14
  150. package/dist/types/src/hooks/template.d.ts.map +1 -1
  151. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  152. package/dist/types/src/index.d.ts +1 -0
  153. package/dist/types/src/index.d.ts.map +1 -1
  154. package/dist/types/src/meta.d.ts +0 -1
  155. package/dist/types/src/meta.d.ts.map +1 -1
  156. package/dist/types/src/notebook/compute-graph.d.ts +45 -0
  157. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  158. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  159. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  160. package/dist/types/src/notebook/eval.d.ts +13 -0
  161. package/dist/types/src/notebook/eval.d.ts.map +1 -0
  162. package/dist/types/src/notebook/index.d.ts +2 -0
  163. package/dist/types/src/notebook/index.d.ts.map +1 -0
  164. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  165. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  166. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  167. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  168. package/dist/types/src/templates/chess.d.ts.map +1 -1
  169. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  170. package/dist/types/src/templates/discord.d.ts.map +1 -1
  171. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  172. package/dist/types/src/templates/forex.d.ts.map +1 -1
  173. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  174. package/dist/types/src/templates/index.d.ts +43 -1
  175. package/dist/types/src/templates/index.d.ts.map +1 -1
  176. package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
  177. package/dist/types/src/templates/ping.d.ts.map +1 -0
  178. package/dist/types/src/testing/data.d.ts +3 -0
  179. package/dist/types/src/testing/data.d.ts.map +1 -0
  180. package/dist/types/src/testing/index.d.ts +2 -0
  181. package/dist/types/src/testing/index.d.ts.map +1 -0
  182. package/dist/types/src/translations.d.ts +30 -5
  183. package/dist/types/src/translations.d.ts.map +1 -1
  184. package/dist/types/src/types/Notebook.d.ts +31 -0
  185. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  186. package/dist/types/src/types/actions.d.ts +54 -0
  187. package/dist/types/src/types/actions.d.ts.map +1 -0
  188. package/dist/types/src/types/index.d.ts +3 -1
  189. package/dist/types/src/types/index.d.ts.map +1 -1
  190. package/dist/types/src/types/types.d.ts +6 -0
  191. package/dist/types/src/types/types.d.ts.map +1 -0
  192. package/dist/types/src/util/deploy.d.ts +7 -7
  193. package/dist/types/src/util/deploy.d.ts.map +1 -1
  194. package/dist/types/src/util/functions.d.ts +6 -3
  195. package/dist/types/src/util/functions.d.ts.map +1 -1
  196. package/dist/types/tsconfig.tsbuildinfo +1 -1
  197. package/package.json +82 -75
  198. package/src/ScriptPlugin.tsx +90 -71
  199. package/src/capabilities/app-graph-builder.ts +9 -8
  200. package/src/capabilities/artifact-definition.ts +7 -4
  201. package/src/capabilities/blueprint-definition.ts +30 -0
  202. package/src/capabilities/compiler.ts +2 -1
  203. package/src/capabilities/index.ts +1 -1
  204. package/src/capabilities/intent-resolver.ts +21 -12
  205. package/src/capabilities/react-surface.tsx +28 -15
  206. package/src/capabilities/settings.ts +3 -3
  207. package/src/compiler/compiler.ts +1 -1
  208. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +39 -20
  209. package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
  210. package/src/components/DeploymentDialog/index.ts +1 -1
  211. package/src/components/FrameContainer/FrameContainer.tsx +3 -2
  212. package/src/components/NotebookContainer.stories.tsx +83 -0
  213. package/src/components/NotebookContainer.tsx +263 -0
  214. package/src/components/NotebookStack/NotebookCell.tsx +208 -0
  215. package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
  216. package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
  217. package/src/components/NotebookStack/NotebookStack.tsx +86 -0
  218. package/src/components/NotebookStack/index.ts +6 -0
  219. package/src/components/ScriptContainer.tsx +7 -6
  220. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
  221. package/src/components/ScriptToolbar/ScriptToolbar.tsx +33 -26
  222. package/src/components/Settings/ScriptObjectSettings.tsx +113 -33
  223. package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
  224. package/src/components/TestPanel/TestContainer.tsx +4 -3
  225. package/src/components/TestPanel/TestPanel.tsx +7 -7
  226. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
  227. package/src/components/TypescriptEditor/TypescriptEditor.tsx +37 -34
  228. package/src/components/index.ts +3 -0
  229. package/src/events.ts +2 -2
  230. package/src/hooks/deploy.ts +23 -24
  231. package/src/hooks/format.ts +4 -4
  232. package/src/hooks/template.ts +6 -15
  233. package/src/hooks/useCreateAndDeployScriptTemplates.ts +6 -5
  234. package/src/index.ts +1 -0
  235. package/src/meta.ts +7 -5
  236. package/src/notebook/compute-graph.test.ts +70 -0
  237. package/src/notebook/compute-graph.ts +206 -0
  238. package/src/notebook/eval.ts +105 -0
  239. package/src/notebook/index.ts +5 -0
  240. package/src/notebook/vfs-parser.test.ts +149 -0
  241. package/src/notebook/vfs-parser.ts +451 -0
  242. package/src/templates/chess.ts +3 -1
  243. package/src/templates/data-generator.ts +9 -3
  244. package/src/templates/discord.ts +12 -4
  245. package/src/templates/forex-effect.ts +7 -3
  246. package/src/templates/forex.ts +3 -1
  247. package/src/templates/gmail.ts +33 -62
  248. package/src/templates/index.ts +6 -6
  249. package/src/testing/data.ts +72 -0
  250. package/src/testing/index.ts +5 -0
  251. package/src/translations.ts +33 -7
  252. package/src/types/Notebook.ts +41 -0
  253. package/src/types/actions.ts +53 -0
  254. package/src/types/index.ts +3 -1
  255. package/src/types/types.ts +15 -0
  256. package/src/util/deploy.ts +27 -44
  257. package/src/util/functions.ts +36 -7
  258. package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
  259. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
  260. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
  261. package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
  262. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
  263. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
  264. package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
  265. package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
  266. package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
  267. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  268. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  269. package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
  270. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  271. package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
  272. package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
  273. package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
  274. package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
  275. package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
  276. package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
  277. package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
  278. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
  279. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
  280. package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
  281. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
  282. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
  283. package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
  284. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  285. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
  286. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  288. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  289. package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
  290. package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
  291. package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
  292. package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
  293. package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
  294. package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
  295. package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
  296. package/dist/types/src/templates/echo.d.ts.map +0 -1
  297. package/dist/types/src/types/schema.d.ts +0 -38
  298. package/dist/types/src/types/schema.d.ts.map +0 -1
  299. package/src/types/schema.ts +0 -37
  300. /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-E5NXT4UQ.mjs.map} +0 -0
  301. /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
  302. /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
  303. /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
  304. /package/src/templates/{echo.ts → ping.ts} +0 -0
@@ -7,69 +7,82 @@ import React from 'react';
7
7
  import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
8
8
  import { InvocationTraceContainer } from '@dxos/devtools';
9
9
  import { Obj } from '@dxos/echo';
10
- import { ScriptType } from '@dxos/functions';
10
+ import { Script } from '@dxos/functions';
11
11
  import { SettingsStore } from '@dxos/local-storage';
12
12
  import { getSpace } from '@dxos/react-client/echo';
13
13
  import { StackItem } from '@dxos/react-ui-stack';
14
14
  import { type DataType } from '@dxos/schema';
15
15
 
16
- import { ScriptCapabilities } from './capabilities';
17
16
  import {
18
17
  DEPLOYMENT_DIALOG,
19
18
  DeploymentDialog,
19
+ NotebookContainer,
20
20
  ScriptContainer,
21
- ScriptPluginSettings,
22
21
  ScriptObjectSettings,
22
+ ScriptPluginSettings,
23
23
  ScriptProperties,
24
24
  TestContainer,
25
25
  } from '../components';
26
26
  import { meta } from '../meta';
27
- import { type ScriptSettingsProps } from '../types';
27
+ import { Notebook, type ScriptSettings } from '../types';
28
+
29
+ import { ScriptCapabilities } from './capabilities';
28
30
 
29
31
  export default () =>
30
32
  contributes(Capabilities.ReactSurface, [
31
33
  createSurface({
32
34
  id: `${meta.id}/plugin-settings`,
33
35
  role: 'article',
34
- filter: (data): data is { subject: SettingsStore<ScriptSettingsProps> } =>
36
+ filter: (data): data is { subject: SettingsStore<ScriptSettings> } =>
35
37
  data.subject instanceof SettingsStore && data.subject.prefix === meta.id,
36
38
  component: ({ data: { subject } }) => <ScriptPluginSettings settings={subject.value} />,
37
39
  }),
38
40
  createSurface({
39
- id: `${meta.id}/article`,
40
- role: 'article',
41
- filter: (data): data is { subject: ScriptType } => Obj.instanceOf(ScriptType, data.subject),
41
+ id: `${meta.id}/script/article`,
42
+ role: ['article', 'section'],
43
+ filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
42
44
  component: ({ data, role }) => {
43
45
  const compiler = useCapability(ScriptCapabilities.Compiler);
44
46
  // TODO(dmaretskyi): Since settings store is not reactive, this would break on the script plugin being enabled without a page reload.
45
- const settings = useCapability(Capabilities.SettingsStore).getStore<ScriptSettingsProps>(meta.id)?.value;
47
+ const settings = useCapability(Capabilities.SettingsStore).getStore<ScriptSettings>(meta.id)?.value;
46
48
  return <ScriptContainer role={role} script={data.subject} settings={settings} env={compiler.environment} />;
47
49
  },
48
50
  }),
51
+ createSurface({
52
+ id: `${meta.id}/notebook/article`,
53
+ role: 'article',
54
+ filter: (data): data is { subject: Notebook.Notebook } => Obj.instanceOf(Notebook.Notebook, data.subject),
55
+ component: ({ data, role }) => {
56
+ const compiler = useCapability(ScriptCapabilities.Compiler);
57
+ return <NotebookContainer role={role} notebook={data.subject} env={compiler.environment} />;
58
+ },
59
+ }),
60
+ // TODO(burdon): Standardize PluginSettings vs ObjectSettings.
61
+ // TODO(burdon): Why is ScriptProperties different from ScriptObjectSettings?
49
62
  createSurface({
50
63
  id: `${meta.id}/companion/base-settings`,
51
64
  role: 'base-object-settings',
52
- filter: (data): data is { subject: ScriptType } => Obj.instanceOf(ScriptType, data.subject),
65
+ filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
53
66
  component: ({ data }) => <ScriptProperties object={data.subject} />,
54
67
  }),
55
68
  createSurface({
56
69
  id: `${meta.id}/companion/settings`,
57
70
  role: 'object-settings',
58
- filter: (data): data is { subject: ScriptType } => Obj.instanceOf(ScriptType, data.subject),
71
+ filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
59
72
  component: ({ data }) => <ScriptObjectSettings object={data.subject} />,
60
73
  }),
61
74
  createSurface({
62
75
  id: `${meta.id}/companion/execute`,
63
76
  role: 'article',
64
- filter: (data): data is { companionTo: ScriptType } =>
65
- Obj.instanceOf(ScriptType, data.companionTo) && data.subject === 'execute',
77
+ filter: (data): data is { companionTo: Script.Script } =>
78
+ Obj.instanceOf(Script.Script, data.companionTo) && data.subject === 'execute',
66
79
  component: ({ data, role }) => <TestContainer script={data.companionTo} role={role} />,
67
80
  }),
68
81
  createSurface({
69
82
  id: `${meta.id}/companion/logs`,
70
83
  role: 'article',
71
- filter: (data): data is { companionTo: ScriptType } =>
72
- Obj.instanceOf(ScriptType, data.companionTo) && data.subject === 'logs',
84
+ filter: (data): data is { companionTo: Script.Script } =>
85
+ Obj.instanceOf(Script.Script, data.companionTo) && data.subject === 'logs',
73
86
  component: ({ data, role }) => {
74
87
  const space = getSpace(data.companionTo);
75
88
  return (
@@ -6,16 +6,16 @@ import { Capabilities, contributes } from '@dxos/app-framework';
6
6
  import { live } from '@dxos/live-object';
7
7
 
8
8
  import { meta } from '../meta';
9
- import { ScriptSettingsSchema } from '../types';
9
+ import { ScriptSettings } from '../types';
10
10
 
11
11
  export default () => {
12
- const settings = live(ScriptSettingsSchema, {
12
+ const settings = live<ScriptSettings>({
13
13
  editorInputMode: 'vscode',
14
14
  });
15
15
 
16
16
  return contributes(Capabilities.Settings, {
17
17
  prefix: meta.id,
18
- schema: ScriptSettingsSchema,
18
+ schema: ScriptSettings,
19
19
  value: settings,
20
20
  });
21
21
  };
@@ -3,10 +3,10 @@
3
3
  //
4
4
 
5
5
  import {
6
+ type VirtualTypeScriptEnvironment,
6
7
  createDefaultMapFromCDN,
7
8
  createSystem,
8
9
  createVirtualTypeScriptEnvironment,
9
- type VirtualTypeScriptEnvironment,
10
10
  } from '@typescript/vfs';
11
11
  import ts from 'typescript';
12
12
 
@@ -2,38 +2,57 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
8
+ import { IntentPlugin } from '@dxos/app-framework';
9
+ import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { Obj } from '@dxos/echo';
11
+ import { ClientPlugin } from '@dxos/plugin-client';
10
12
  import { Dialog } from '@dxos/react-ui';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
13
+ import { withTheme } from '@dxos/react-ui/testing';
14
+ import { DataType } from '@dxos/schema';
12
15
 
13
16
  import { translations } from '../../translations';
14
- import { DeploymentDialog } from '../DeploymentDialog/DeploymentDialog';
15
17
 
16
- export const Default = {
17
- args: {
18
- accessToken: { value: 'example-token' },
19
- scripts: [
20
- { label: 'Script 1', templateId: 'template1' },
21
- { label: 'Script 2', templateId: 'template2' },
22
- { label: 'Script 3', templateId: 'template3' },
23
- ],
24
- },
25
- render: (args: any) => (
18
+ import { DeploymentDialog, type DeploymentDialogProps } from './DeploymentDialog';
19
+
20
+ const DefaultStory = (props: DeploymentDialogProps) => {
21
+ return (
26
22
  <Dialog.Root defaultOpen={true}>
27
- <DeploymentDialog {...args} />
23
+ <DeploymentDialog {...props} />
28
24
  </Dialog.Root>
29
- ),
25
+ );
30
26
  };
31
27
 
32
- const meta: Meta = {
28
+ const meta = {
33
29
  title: 'plugins/plugin-script/DeploymentDialog',
34
30
  component: DeploymentDialog,
31
+ render: DefaultStory,
35
32
  parameters: { translations },
36
- decorators: [withTheme, withLayout()],
37
- };
33
+ // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
34
+ decorators: [
35
+ withTheme,
36
+ withPluginManager({
37
+ plugins: [IntentPlugin(), ClientPlugin({})],
38
+ }),
39
+ ],
40
+ } satisfies Meta<typeof DefaultStory>;
38
41
 
39
42
  export default meta;
43
+
44
+ type Story = StoryObj<typeof meta>;
45
+
46
+ export const Default: Story = {
47
+ args: {
48
+ accessToken: Obj.make(DataType.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
+ };
@@ -4,29 +4,29 @@
4
4
 
5
5
  import React, { useEffect, useMemo } from 'react';
6
6
 
7
- import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
7
+ import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
8
8
  import { getSpace } from '@dxos/react-client/echo';
9
9
  import { Button, Dialog, Icon, useTranslation } from '@dxos/react-ui';
10
10
  import { type DataType } from '@dxos/schema';
11
11
 
12
12
  import { useCreateAndDeployScriptTemplates } from '../../hooks/useCreateAndDeployScriptTemplates';
13
- import { SCRIPT_PLUGIN } from '../../meta';
13
+ import { meta } from '../../meta';
14
14
  import { type Template } from '../../templates';
15
15
 
16
- export const DEPLOYMENT_DIALOG = `${SCRIPT_PLUGIN}/deployment/dialog`;
16
+ export const DEPLOYMENT_DIALOG = `${meta.id}/deployment/dialog`;
17
17
 
18
18
  // TODO(ZaymonFC):
19
- // - Show activity and feedback to the user.
20
- // - Only take an array of templateIds and get the name from the data.
21
- // - Pending / onError states.
19
+ // - Show activity and feedback to the user.
20
+ // - Only take an array of templateIds and get the name from the data.
21
+ // - Pending / onError states.
22
22
 
23
- type DeploymentDialogProps = {
23
+ export type DeploymentDialogProps = {
24
24
  accessToken: DataType.AccessToken;
25
25
  scriptTemplates: Template[];
26
26
  };
27
27
 
28
28
  export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDialogProps) => {
29
- const { t } = useTranslation(SCRIPT_PLUGIN);
29
+ const { t } = useTranslation(meta.id);
30
30
  const space = useMemo(() => getSpace(accessToken), [accessToken]);
31
31
 
32
32
  // TODO(ZaymonFC): Thinking further. All of this should get moved to intents to run async in the background.
@@ -41,12 +41,12 @@ export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDia
41
41
  createIntent(LayoutAction.AddToast, {
42
42
  part: 'toast',
43
43
  subject: {
44
- id: `${SCRIPT_PLUGIN}/deployment-success`,
44
+ id: `${meta.id}/deployment-success`,
45
45
  icon: 'ph--check--regular',
46
46
  duration: Infinity,
47
- title: ['script deployment toast label', { ns: SCRIPT_PLUGIN, count: scriptTemplates.length }],
48
- description: ['script deployment toast description', { ns: SCRIPT_PLUGIN, count: scriptTemplates.length }],
49
- closeLabel: ['script deployment toast close label', { ns: SCRIPT_PLUGIN, count: scriptTemplates.length }],
47
+ title: ['script deployment toast label', { ns: meta.id, count: scriptTemplates.length }],
48
+ description: ['script deployment toast description', { ns: meta.id, count: scriptTemplates.length }],
49
+ closeLabel: ['script deployment toast close label', { ns: meta.id, count: scriptTemplates.length }],
50
50
  },
51
51
  }),
52
52
  );
@@ -58,18 +58,12 @@ export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDia
58
58
  createIntent(LayoutAction.AddToast, {
59
59
  part: 'toast',
60
60
  subject: {
61
- id: `${SCRIPT_PLUGIN}/deployment-error`,
61
+ id: `${meta.id}/deployment-error`,
62
62
  icon: 'ph--warning--regular',
63
63
  duration: Infinity,
64
- title: ['script deployment error toast label', { ns: SCRIPT_PLUGIN, count: scriptTemplates.length }],
65
- description: [
66
- 'script deployment error toast description',
67
- { ns: SCRIPT_PLUGIN, count: scriptTemplates.length },
68
- ],
69
- closeLabel: [
70
- 'script deployment error toast close label',
71
- { ns: SCRIPT_PLUGIN, count: scriptTemplates.length },
72
- ],
64
+ title: ['script deployment error toast label', { ns: meta.id, count: scriptTemplates.length }],
65
+ description: ['script deployment error toast description', { ns: meta.id, count: scriptTemplates.length }],
66
+ closeLabel: ['script deployment error toast close label', { ns: meta.id, count: scriptTemplates.length }],
73
67
  },
74
68
  }),
75
69
  );
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { DeploymentDialog, DEPLOYMENT_DIALOG } from './DeploymentDialog';
5
+ import { DEPLOYMENT_DIALOG, DeploymentDialog } from './DeploymentDialog';
6
6
 
7
7
  export { DEPLOYMENT_DIALOG };
8
8
 
@@ -48,7 +48,8 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
48
48
  // Encodes compiled code via URL.
49
49
  invariant(result.sourceHash, 'Source hash is required.');
50
50
  const sourceHash = Buffer.from(result.sourceHash).toString('hex');
51
- const src = result.bundle && `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(result.bundle)}`;
51
+ const src =
52
+ 'bundle' in result ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(result.bundle)}` : undefined;
52
53
 
53
54
  return (
54
55
  <>
@@ -68,7 +69,7 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
68
69
  {
69
70
  timestamp: result.timestamp,
70
71
  sourceHash,
71
- error: result.error,
72
+ error: 'error' in result ? result.error : undefined,
72
73
  src,
73
74
  },
74
75
  undefined,
@@ -0,0 +1,83 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React from 'react';
7
+
8
+ import { SERVICES_CONFIG } from '@dxos/ai/testing';
9
+ import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
10
+ import { withPluginManager } from '@dxos/app-framework/testing';
11
+ import { Agent } from '@dxos/assistant-toolkit';
12
+ import { Filter } from '@dxos/echo';
13
+ import { Function, serializeFunction } from '@dxos/functions';
14
+ import { AssistantPlugin } from '@dxos/plugin-assistant';
15
+ import { AutomationPlugin } from '@dxos/plugin-automation';
16
+ import { ClientPlugin } from '@dxos/plugin-client';
17
+ import { ExplorerPlugin } from '@dxos/plugin-explorer';
18
+ import { Markdown, MarkdownPlugin } from '@dxos/plugin-markdown';
19
+ import { SpacePlugin } from '@dxos/plugin-space';
20
+ import { Config, useClient } from '@dxos/react-client';
21
+ import { useQuery } from '@dxos/react-client/echo';
22
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
23
+ import { DataTypes } from '@dxos/schema';
24
+
25
+ import { createNotebook } from '../testing';
26
+ import { translations } from '../translations';
27
+ import { Notebook } from '../types';
28
+
29
+ import { NotebookContainer } from './NotebookContainer';
30
+
31
+ const meta = {
32
+ title: 'plugins/plugin-script/NotebookContainer',
33
+ component: NotebookContainer,
34
+ render: (args) => {
35
+ const client = useClient();
36
+ const space = client.spaces.default;
37
+ const notebooks = useQuery(space?.db, Filter.type(Notebook.Notebook));
38
+ return <NotebookContainer {...args} notebook={notebooks[0]} />;
39
+ },
40
+ decorators: [
41
+ withTheme,
42
+ withLayout({ container: 'column', classNames: 'is-prose' }),
43
+ withPluginManager({
44
+ plugins: [
45
+ ClientPlugin({
46
+ // TODO(wittjosiah): ComputeRuntime requires edge to be configured or it will throw.
47
+ config: new Config({
48
+ runtime: {
49
+ services: SERVICES_CONFIG.REMOTE,
50
+ },
51
+ }),
52
+ 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();
58
+
59
+ space.db.add(createNotebook());
60
+ space.db.add(Markdown.makeDocument({ content: '# Hello World' }));
61
+ space.db.add(serializeFunction(Agent.prompt));
62
+ },
63
+ }),
64
+ SpacePlugin({}),
65
+ SettingsPlugin(),
66
+ IntentPlugin(),
67
+ AssistantPlugin(),
68
+ AutomationPlugin(),
69
+ ExplorerPlugin(),
70
+ MarkdownPlugin(),
71
+ ],
72
+ }),
73
+ ],
74
+ parameters: {
75
+ translations,
76
+ },
77
+ } satisfies Meta<typeof NotebookContainer>;
78
+
79
+ export default meta;
80
+
81
+ type Story = StoryObj<typeof meta>;
82
+
83
+ export const Default: Story = {};
@@ -0,0 +1,263 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Cause from 'effect/Cause';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Exit from 'effect/Exit';
8
+ import * as Layer from 'effect/Layer';
9
+ import React, { useCallback, useMemo, useState } from 'react';
10
+
11
+ import { Agent } from '@dxos/assistant-toolkit';
12
+ import { Blueprint, Prompt } from '@dxos/blueprints';
13
+ import { Filter, Obj, Query, Ref } from '@dxos/echo';
14
+ import { QueryBuilder } from '@dxos/echo-query';
15
+ import {
16
+ ComputeEventLogger,
17
+ type FunctionDefinition,
18
+ FunctionInvocationService,
19
+ InvocationTracer,
20
+ TracingService,
21
+ } from '@dxos/functions';
22
+ import { invariant } from '@dxos/invariant';
23
+ import { log } from '@dxos/log';
24
+ import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
25
+ import { Graph } from '@dxos/plugin-explorer/types';
26
+ import { fullyQualifiedId } from '@dxos/react-client/echo';
27
+ import { getSpace } from '@dxos/react-client/echo';
28
+ import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
29
+ import { useAttention } from '@dxos/react-ui-attention';
30
+ import { StackItem } from '@dxos/react-ui-stack';
31
+ import { DataType } from '@dxos/schema';
32
+ import { isNonNullable } from '@dxos/util';
33
+
34
+ import { meta } from '../meta';
35
+ import { ComputeGraph } from '../notebook';
36
+ import { type Notebook } from '../types';
37
+
38
+ import { NotebookMenu, NotebookStack, type NotebookStackProps } from './NotebookStack';
39
+ import { type TypescriptEditorProps } from './TypescriptEditor';
40
+
41
+ const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/markdown'];
42
+
43
+ // TODO(burdon): Support calling named deployed functions (as with sheet).
44
+
45
+ export type NotebookContainerProps = {
46
+ role?: string;
47
+ notebook?: Notebook.Notebook;
48
+ } & Pick<TypescriptEditorProps, 'env'>;
49
+
50
+ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) => {
51
+ const { t } = useTranslation(meta.id);
52
+ const space = getSpace(notebook);
53
+ const attendableId = fullyQualifiedId(notebook);
54
+ const { hasAttention } = useAttention(attendableId);
55
+
56
+ // TODO(burdon): Consolidate execution and state (with graph).
57
+ // Generalize ComputeGraph evaluation function (using effects).
58
+ const graph = useMemo(() => notebook && new ComputeGraph(notebook), [notebook]);
59
+
60
+ const [queryValues, setQueryValues] = useState<Record<string, any>>({});
61
+ const handleExecQueries = useCallback(async () => {
62
+ invariant(space);
63
+
64
+ const builder = new QueryBuilder();
65
+ for (const cell of notebook?.cells ?? []) {
66
+ if (cell.type === 'query') {
67
+ if (cell.source?.target) {
68
+ const source = cell.source.target.content;
69
+ const { name, filter } = builder.build(source);
70
+ if (filter) {
71
+ const ast = Query.select(filter).ast;
72
+ const view = cell.view?.target;
73
+ if (!view) {
74
+ const graph = Graph.make({ query: { ast } });
75
+ const { view } = await Graph.makeView({ space, presentation: graph });
76
+ cell.view = Ref.make(view);
77
+ cell.name = name;
78
+ } else {
79
+ view.query.ast = ast;
80
+ }
81
+ }
82
+ }
83
+
84
+ if (cell.name && cell.view?.target) {
85
+ const view = Obj.getSnapshot(cell.view?.target);
86
+ const query = Query.fromAst(view.query.ast);
87
+ const result = await space?.db.query(query).run();
88
+ const objectIds = result?.objects?.map((obj) => obj.id);
89
+ setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));
90
+ }
91
+ }
92
+ }
93
+ }, [space, notebook, graph]);
94
+
95
+ const [promptResults, setPromptResults] = useState<Record<string, string>>({});
96
+ const handleExecPrompts = useComputeRuntimeCallback(
97
+ space,
98
+ Effect.fnUntraced(function* () {
99
+ invariant(graph);
100
+
101
+ const prompts =
102
+ notebook?.cells
103
+ .filter((cell) => cell.type === 'prompt')
104
+ .map((cell) => cell.prompt)
105
+ .filter(isNonNullable) ?? [];
106
+
107
+ for (const prompt of prompts) {
108
+ yield* runPrompt({
109
+ prompt,
110
+ input: { ...queryValues, ...graph.valuesByName.value },
111
+ onResult: (result) => setPromptResults((prev) => ({ ...prev, [prompt.dxn.toString()]: result })),
112
+ });
113
+ }
114
+ }),
115
+ [notebook, graph, queryValues],
116
+ );
117
+
118
+ // TODO(burdon): Cache values in context (preserve when switched).
119
+ const handleCompute = useCallback(async () => {
120
+ // TODO(burdon): Generalize executors (dependencies).
121
+ await graph?.evaluate();
122
+ await handleExecQueries();
123
+ await handleExecPrompts();
124
+ }, [graph, handleExecQueries, handleExecPrompts]);
125
+
126
+ const handleRearrange = useCallback<NonNullable<NotebookStackProps['onRearrange']>>(
127
+ (source, target) => {
128
+ invariant(notebook);
129
+ const from = notebook.cells.findIndex((cell) => cell.id === source.id);
130
+ const to = notebook.cells.findIndex((cell) => cell.id === target.id);
131
+ if (from != null && to != null) {
132
+ const cell = notebook.cells.splice(from, 1)[0];
133
+ if (cell) {
134
+ notebook.cells.splice(to, 0, cell);
135
+ }
136
+ }
137
+ },
138
+ [notebook],
139
+ );
140
+
141
+ const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(
142
+ async (type, after) => {
143
+ invariant(notebook);
144
+ const cell: Notebook.Cell = { id: crypto.randomUUID(), type };
145
+ switch (type) {
146
+ case 'markdown':
147
+ case 'script':
148
+ case 'query': {
149
+ cell.source = Ref.make(DataType.makeText());
150
+ break;
151
+ }
152
+
153
+ case 'prompt': {
154
+ if (space) {
155
+ const result = await space.db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
156
+ const blueprints = result.objects
157
+ .filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key))
158
+ .map((blueprint) => Ref.make(blueprint));
159
+ cell.prompt = Ref.make(Prompt.make({ instructions: '', blueprints }));
160
+ }
161
+ break;
162
+ }
163
+ }
164
+
165
+ const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;
166
+ notebook.cells.splice(idx, 0, cell);
167
+ },
168
+ [space, notebook],
169
+ );
170
+
171
+ const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(
172
+ (id) => {
173
+ invariant(notebook);
174
+ const idx = notebook.cells.findIndex((cell) => cell.id === id);
175
+ if (idx !== -1) {
176
+ notebook.cells.splice(idx, 1);
177
+ }
178
+ },
179
+ [notebook],
180
+ );
181
+
182
+ return (
183
+ <StackItem.Content toolbar>
184
+ <Toolbar.Root disabled={!hasAttention} textBlockWidth>
185
+ <DropdownMenu.Root>
186
+ <DropdownMenu.Trigger asChild>
187
+ <IconButton icon='ph--plus--regular' iconOnly label={t('notebook cell insert label')} />
188
+ </DropdownMenu.Trigger>
189
+ <NotebookMenu onCellInsert={handleCellInsert} />
190
+ </DropdownMenu.Root>
191
+ <Toolbar.IconButton
192
+ icon='ph--play--fill'
193
+ iconOnly
194
+ label={t('compute label')}
195
+ classNames='text-green-500'
196
+ onClick={handleCompute}
197
+ />
198
+ </Toolbar.Root>
199
+ <div role='none' className='flex bs-full overflow-hidden -mis-[1px] -mie-[1px]'>
200
+ <NotebookStack
201
+ classNames='container-max-width border-l border-r border-subduedSeparator'
202
+ space={space}
203
+ notebook={notebook}
204
+ graph={graph}
205
+ env={env}
206
+ promptResults={promptResults}
207
+ onRearrange={handleRearrange}
208
+ onCellInsert={handleCellInsert}
209
+ onCellDelete={handleCellDelete}
210
+ />
211
+ </div>
212
+ </StackItem.Content>
213
+ );
214
+ };
215
+
216
+ export default NotebookContainer;
217
+
218
+ // TODO(wittjosiah): Factor out. Copied from PromptContainer in stories-assistant.
219
+ const runPrompt = Effect.fn(function* ({
220
+ prompt,
221
+ input,
222
+ onResult,
223
+ }: {
224
+ prompt: Ref.Ref<Prompt.Prompt>;
225
+ input: Record<string, any>;
226
+ onResult: (result: string) => void;
227
+ }) {
228
+ const inputData: FunctionDefinition.Input<typeof Agent.prompt> = { prompt, input };
229
+ const tracer = yield* InvocationTracer;
230
+ const trace = yield* tracer.traceInvocationStart({
231
+ target: undefined,
232
+ payload: {
233
+ data: {},
234
+ },
235
+ });
236
+
237
+ // Invoke the function.
238
+ const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
239
+ Effect.provide(
240
+ ComputeEventLogger.layerFromTracing.pipe(
241
+ Layer.provideMerge(TracingService.layerQueue(trace.invocationTraceQueue)),
242
+ ),
243
+ ),
244
+ Effect.exit,
245
+ );
246
+
247
+ Exit.match(result, {
248
+ onFailure: (cause) => {
249
+ const error = Cause.prettyErrors(cause)[0];
250
+ log.error(error.message, error.cause ?? error.stack);
251
+ onResult(error.message);
252
+ },
253
+ onSuccess: (result: any) => {
254
+ onResult(result.note);
255
+ },
256
+ });
257
+
258
+ yield* tracer.traceInvocationEnd({
259
+ trace,
260
+ // TODO(dmaretskyi): Might miss errors.
261
+ exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,
262
+ });
263
+ });