@dxos/plugin-script 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe

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