@dxos/plugin-script 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b

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