@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,818 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ NotebookMenu,
4
+ NotebookStack
5
+ } from "./chunk-NQN3JE2R.mjs";
6
+ import "./chunk-6H4FYMCX.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, View } 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 graph2 = cell.graph?.target;
592
+ if (!graph2) {
593
+ const { view } = await View.makeFromSpace({
594
+ space
595
+ });
596
+ const graph3 = Graph.make({
597
+ query: {
598
+ ast
599
+ },
600
+ view
601
+ });
602
+ cell.graph = Ref.make(graph3);
603
+ cell.name = name;
604
+ } else {
605
+ graph2.query.ast = ast;
606
+ }
607
+ }
608
+ }
609
+ if (cell.name && cell.graph?.target) {
610
+ const graph2 = Obj.getSnapshot(cell.graph?.target);
611
+ const query = Query.fromAst(graph2.query.ast);
612
+ const objects = await space?.db.query(query).run();
613
+ const objectIds = 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: 93,
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: 126,
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: 141,
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 objects = await space.db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
710
+ const blueprints = 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: 171,
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: 247,
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-7RCEXND7.mjs.map