@dxos/plugin-script 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51

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 (415) hide show
  1. package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
  2. package/dist/lib/browser/{NotebookContainer-LVGRPFY3.mjs → NotebookContainer-UQ4I24R6.mjs} +357 -195
  3. package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-NB76645V.mjs +149 -0
  5. package/dist/lib/browser/ScriptContainer-NB76645V.mjs.map +7 -0
  6. package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
  7. package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs +18 -0
  9. package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs.map +7 -0
  10. package/dist/lib/browser/blueprints/index.mjs +8 -0
  11. package/dist/lib/browser/chunk-3BSF5BIA.mjs +113 -0
  12. package/dist/lib/browser/chunk-3BSF5BIA.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-ST3ACVUC.mjs → chunk-4N5TLXEJ.mjs} +29 -12
  14. package/dist/lib/browser/chunk-4N5TLXEJ.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-BKGEAUUH.mjs +270 -0
  16. package/dist/lib/browser/chunk-BKGEAUUH.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-BU6CGVU2.mjs +137 -0
  18. package/dist/lib/browser/chunk-BU6CGVU2.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
  20. package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
  22. package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  24. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-LYMPME7J.mjs +609 -0
  26. package/dist/lib/browser/chunk-LYMPME7J.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-WWCDIB6Z.mjs +557 -0
  28. package/dist/lib/browser/chunk-WWCDIB6Z.mjs.map +7 -0
  29. package/dist/lib/browser/{chunk-EZVXV6DA.mjs → chunk-WYR4QHPE.mjs} +7 -2
  30. package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
  31. package/dist/lib/browser/compiler-VPUVTFQD.mjs +161 -0
  32. package/dist/lib/browser/compiler-VPUVTFQD.mjs.map +7 -0
  33. package/dist/lib/browser/index.mjs +103 -137
  34. package/dist/lib/browser/index.mjs.map +4 -4
  35. package/dist/lib/browser/meta.json +1 -1
  36. package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs +83 -0
  37. package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs.map +7 -0
  38. package/dist/lib/browser/react-surface-FYOQSC6S.mjs +140 -0
  39. package/dist/lib/browser/react-surface-FYOQSC6S.mjs.map +7 -0
  40. package/dist/lib/browser/settings-5SF77MRH.mjs +36 -0
  41. package/dist/lib/browser/settings-5SF77MRH.mjs.map +7 -0
  42. package/dist/lib/browser/templates/index.mjs +2 -1
  43. package/dist/lib/browser/types/index.mjs +12 -7
  44. package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs +15 -0
  45. package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs.map +7 -0
  46. package/dist/lib/node-esm/{NotebookContainer-QY5NJGJI.mjs → NotebookContainer-DQGZ6QHI.mjs} +357 -195
  47. package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs.map +7 -0
  48. package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs +150 -0
  49. package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs.map +7 -0
  50. package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
  51. package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
  52. package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs +19 -0
  53. package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs.map +7 -0
  54. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  55. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  56. package/dist/lib/node-esm/chunk-3CKQUF55.mjs +610 -0
  57. package/dist/lib/node-esm/chunk-3CKQUF55.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-3QBXN6QC.mjs +271 -0
  59. package/dist/lib/node-esm/chunk-3QBXN6QC.mjs.map +7 -0
  60. package/dist/lib/node-esm/{chunk-OG2SIKHE.mjs → chunk-5HSJPAK7.mjs} +7 -2
  61. package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-ECRSTVR6.mjs +558 -0
  63. package/dist/lib/node-esm/chunk-ECRSTVR6.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-KRVL7UYI.mjs +114 -0
  67. package/dist/lib/node-esm/chunk-KRVL7UYI.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
  69. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-U6PXM2HT.mjs +138 -0
  71. package/dist/lib/node-esm/chunk-U6PXM2HT.mjs.map +7 -0
  72. package/dist/lib/node-esm/{chunk-2GVTWESW.mjs → chunk-V37R7KB5.mjs} +29 -12
  73. package/dist/lib/node-esm/chunk-V37R7KB5.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
  75. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
  76. package/dist/lib/node-esm/compiler-WUOSY6MS.mjs +162 -0
  77. package/dist/lib/node-esm/compiler-WUOSY6MS.mjs.map +7 -0
  78. package/dist/lib/node-esm/index.mjs +103 -137
  79. package/dist/lib/node-esm/index.mjs.map +4 -4
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs +84 -0
  82. package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs.map +7 -0
  83. package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs +141 -0
  84. package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs.map +7 -0
  85. package/dist/lib/node-esm/settings-ILI762CY.mjs +37 -0
  86. package/dist/lib/node-esm/settings-ILI762CY.mjs.map +7 -0
  87. package/dist/lib/node-esm/templates/index.mjs +2 -1
  88. package/dist/lib/node-esm/types/index.mjs +12 -7
  89. package/dist/types/src/ScriptPlugin.d.ts +2 -1
  90. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  91. package/dist/types/src/blueprints/index.d.ts +2 -0
  92. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  93. package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
  94. package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  96. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  100. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
  104. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
  108. package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
  110. package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/index.d.ts +6 -7
  112. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  113. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  116. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  118. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  120. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/settings/index.d.ts +7 -0
  122. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
  124. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  125. package/dist/types/src/compiler/compiler.d.ts +1 -1
  126. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  127. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
  128. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  129. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +4 -6
  130. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
  132. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  133. package/dist/types/src/components/NotebookContainer.d.ts +3 -5
  134. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
  135. package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -244
  136. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
  137. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +4 -3
  138. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
  139. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
  140. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
  141. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +5 -4
  142. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
  143. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  144. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  145. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  146. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  147. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  148. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  149. package/dist/types/src/components/ScriptContainer.d.ts +5 -6
  150. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  151. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
  152. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  153. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +5 -4
  154. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  155. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  156. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  157. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +4 -2
  158. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  159. package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
  160. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  161. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  162. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +3 -2
  163. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  164. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
  165. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  166. package/dist/types/src/components/index.d.ts +2 -2
  167. package/dist/types/src/components/index.d.ts.map +1 -1
  168. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  169. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  170. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  171. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  172. package/dist/types/src/hooks/deploy.d.ts +15 -30
  173. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  174. package/dist/types/src/hooks/format.d.ts +4 -4
  175. package/dist/types/src/hooks/format.d.ts.map +1 -1
  176. package/dist/types/src/hooks/index.d.ts +1 -0
  177. package/dist/types/src/hooks/index.d.ts.map +1 -1
  178. package/dist/types/src/hooks/template.d.ts +6 -16
  179. package/dist/types/src/hooks/template.d.ts.map +1 -1
  180. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  181. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  182. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  183. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  184. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  185. package/dist/types/src/index.d.ts +1 -1
  186. package/dist/types/src/index.d.ts.map +1 -1
  187. package/dist/types/src/meta.d.ts +2 -2
  188. package/dist/types/src/meta.d.ts.map +1 -1
  189. package/dist/types/src/notebook/compute-graph.d.ts +58 -0
  190. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  191. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  192. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  193. package/dist/types/src/notebook/eval.d.ts +1 -1
  194. package/dist/types/src/notebook/eval.d.ts.map +1 -1
  195. package/dist/types/src/notebook/index.d.ts +1 -1
  196. package/dist/types/src/notebook/index.d.ts.map +1 -1
  197. package/dist/types/src/templates/anthropic.d.ts +8 -0
  198. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  199. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  200. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  201. package/dist/types/src/templates/commentary.d.ts +16 -0
  202. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  203. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  204. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  205. package/dist/types/src/templates/forex.d.ts +4 -1
  206. package/dist/types/src/templates/forex.d.ts.map +1 -1
  207. package/dist/types/src/templates/index.d.ts +12 -3
  208. package/dist/types/src/templates/index.d.ts.map +1 -1
  209. package/dist/types/src/templates/ping.d.ts +1 -4
  210. package/dist/types/src/templates/ping.d.ts.map +1 -1
  211. package/dist/types/src/testing/data.d.ts +2 -18
  212. package/dist/types/src/testing/data.d.ts.map +1 -1
  213. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  214. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  215. package/dist/types/src/translations.d.ts +4 -3
  216. package/dist/types/src/translations.d.ts.map +1 -1
  217. package/dist/types/src/types/Notebook.d.ts +100 -0
  218. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  219. package/dist/types/src/types/actions.d.ts +30 -56
  220. package/dist/types/src/types/actions.d.ts.map +1 -1
  221. package/dist/types/src/types/capabilities.d.ts +12 -0
  222. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  223. package/dist/types/src/types/events.d.ts +5 -0
  224. package/dist/types/src/types/events.d.ts.map +1 -0
  225. package/dist/types/src/types/index.d.ts +4 -1
  226. package/dist/types/src/types/index.d.ts.map +1 -1
  227. package/dist/types/src/types/types.d.ts +6 -0
  228. package/dist/types/src/types/types.d.ts.map +1 -0
  229. package/dist/types/src/util/deploy.d.ts +4 -4
  230. package/dist/types/src/util/deploy.d.ts.map +1 -1
  231. package/dist/types/src/util/functions.d.ts +3 -3
  232. package/dist/types/src/util/functions.d.ts.map +1 -1
  233. package/dist/types/tsconfig.tsbuildinfo +1 -1
  234. package/package.json +114 -82
  235. package/src/ScriptPlugin.tsx +45 -87
  236. package/src/blueprints/index.ts +5 -0
  237. package/src/blueprints/script-blueprint.ts +24 -0
  238. package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
  239. package/src/capabilities/app-graph-builder/index.ts +7 -0
  240. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -95
  241. package/src/capabilities/artifact-definition/index.ts +7 -0
  242. package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
  243. package/src/capabilities/blueprint-definition/index.ts +7 -0
  244. package/src/capabilities/compiler/compiler.ts +103 -0
  245. package/src/capabilities/compiler/index.ts +7 -0
  246. package/src/capabilities/index.ts +6 -10
  247. package/src/capabilities/operation-resolver/index.ts +7 -0
  248. package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
  249. package/src/capabilities/react-surface/index.ts +7 -0
  250. package/src/capabilities/react-surface/react-surface.tsx +119 -0
  251. package/src/capabilities/settings/index.ts +7 -0
  252. package/src/capabilities/settings/settings.ts +33 -0
  253. package/src/compiler/compiler.ts +10 -3
  254. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +33 -24
  255. package/src/components/DeploymentDialog/DeploymentDialog.tsx +38 -41
  256. package/src/components/FrameContainer/FrameContainer.tsx +6 -4
  257. package/src/components/NotebookContainer.stories.tsx +60 -5
  258. package/src/components/NotebookContainer.tsx +179 -32
  259. package/src/components/NotebookStack/NotebookCell.tsx +84 -84
  260. package/src/components/NotebookStack/NotebookStack.stories.tsx +32 -9
  261. package/src/components/NotebookStack/NotebookStack.tsx +13 -6
  262. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  263. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  264. package/src/components/QueryEditor/index.ts +5 -0
  265. package/src/components/ScriptContainer.tsx +49 -34
  266. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +42 -19
  267. package/src/components/ScriptToolbar/ScriptToolbar.tsx +25 -28
  268. package/src/components/Settings/ScriptObjectSettings.tsx +55 -32
  269. package/src/components/Settings/ScriptPluginSettings.tsx +19 -14
  270. package/src/components/TestPanel/TestContainer.tsx +7 -7
  271. package/src/components/TestPanel/TestPanel.tsx +60 -35
  272. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +14 -9
  273. package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -73
  274. package/src/e2e/ai.test.ts +92 -0
  275. package/src/e2e/deploy.test.ts +64 -0
  276. package/src/hooks/deploy.ts +40 -32
  277. package/src/hooks/format.ts +7 -3
  278. package/src/hooks/index.ts +1 -0
  279. package/src/hooks/template.ts +20 -24
  280. package/src/hooks/useCompiler.ts +24 -0
  281. package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
  282. package/src/hooks/useToolbarState.ts +29 -4
  283. package/src/index.ts +1 -1
  284. package/src/meta.ts +8 -4
  285. package/src/notebook/{notebook.test.ts → compute-graph.test.ts} +31 -19
  286. package/src/notebook/{notebook.ts → compute-graph.ts} +65 -18
  287. package/src/notebook/eval.ts +1 -1
  288. package/src/notebook/index.ts +1 -1
  289. package/src/templates/anthropic.ts +42 -0
  290. package/src/templates/chess-bot.ts +58 -0
  291. package/src/templates/commentary.ts +230 -0
  292. package/src/templates/data-generator.ts +1 -1
  293. package/src/templates/forex-effect.ts +22 -27
  294. package/src/templates/forex.ts +7 -6
  295. package/src/templates/gmail.ts +1 -2
  296. package/src/templates/index.ts +18 -5
  297. package/src/templates/ping.ts +14 -5
  298. package/src/testing/data.ts +34 -9
  299. package/src/testing/simulator.test.ts +40 -0
  300. package/src/translations.ts +4 -3
  301. package/src/types/Notebook.ts +41 -0
  302. package/src/types/actions.ts +18 -26
  303. package/src/types/capabilities.ts +17 -0
  304. package/src/types/events.ts +11 -0
  305. package/src/types/index.ts +4 -1
  306. package/src/types/types.ts +15 -0
  307. package/src/util/deploy.ts +30 -40
  308. package/src/util/functions.ts +32 -28
  309. package/src/vite-env.d.ts +2 -0
  310. package/dist/lib/browser/DeploymentDialog-65TWT6S5.mjs +0 -13
  311. package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +0 -7
  312. package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +0 -149
  313. package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +0 -7
  314. package/dist/lib/browser/app-graph-builder-DPYULSME.mjs +0 -65
  315. package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +0 -7
  316. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
  317. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
  318. package/dist/lib/browser/chunk-5CYLWXRH.mjs +0 -89
  319. package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +0 -7
  320. package/dist/lib/browser/chunk-75LH4EUR.mjs +0 -326
  321. package/dist/lib/browser/chunk-75LH4EUR.mjs.map +0 -7
  322. package/dist/lib/browser/chunk-E7DXDICD.mjs +0 -282
  323. package/dist/lib/browser/chunk-E7DXDICD.mjs.map +0 -7
  324. package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
  325. package/dist/lib/browser/chunk-I3QSGUFJ.mjs +0 -646
  326. package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +0 -7
  327. package/dist/lib/browser/chunk-JO2O7W6J.mjs +0 -254
  328. package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +0 -7
  329. package/dist/lib/browser/chunk-N6M34EUC.mjs +0 -112
  330. package/dist/lib/browser/chunk-N6M34EUC.mjs.map +0 -7
  331. package/dist/lib/browser/chunk-NM4WQS4F.mjs +0 -153
  332. package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +0 -7
  333. package/dist/lib/browser/chunk-OKXN2N7M.mjs +0 -15
  334. package/dist/lib/browser/chunk-OKXN2N7M.mjs.map +0 -7
  335. package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +0 -7
  336. package/dist/lib/browser/compiler-G2N2CG63.mjs +0 -98
  337. package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
  338. package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs +0 -105
  339. package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +0 -7
  340. package/dist/lib/browser/react-surface-76SDTUYG.mjs +0 -127
  341. package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +0 -7
  342. package/dist/lib/browser/settings-ERFKVNUK.mjs +0 -25
  343. package/dist/lib/browser/settings-ERFKVNUK.mjs.map +0 -7
  344. package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
  345. package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +0 -7
  346. package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +0 -150
  347. package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +0 -7
  348. package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs +0 -66
  349. package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +0 -7
  350. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
  351. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
  352. package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +0 -7
  353. package/dist/lib/node-esm/chunk-4X375PGY.mjs +0 -90
  354. package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +0 -7
  355. package/dist/lib/node-esm/chunk-67OVZHI3.mjs +0 -327
  356. package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +0 -7
  357. package/dist/lib/node-esm/chunk-C2ORIPKH.mjs +0 -154
  358. package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +0 -7
  359. package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs +0 -16
  360. package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs.map +0 -7
  361. package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
  362. package/dist/lib/node-esm/chunk-SMFPSKQT.mjs +0 -647
  363. package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +0 -7
  364. package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +0 -114
  365. package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +0 -7
  366. package/dist/lib/node-esm/chunk-VZAFGLD7.mjs +0 -283
  367. package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +0 -7
  368. package/dist/lib/node-esm/chunk-YW36TZ7K.mjs +0 -255
  369. package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +0 -7
  370. package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs +0 -99
  371. package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
  372. package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs +0 -106
  373. package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +0 -7
  374. package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs +0 -128
  375. package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +0 -7
  376. package/dist/lib/node-esm/settings-5TYXQ42N.mjs +0 -26
  377. package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +0 -7
  378. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  379. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  380. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  381. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  382. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  383. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  384. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  385. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  386. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  387. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  388. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  389. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  390. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  391. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  392. package/dist/types/src/capabilities/settings.d.ts +0 -4
  393. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  394. package/dist/types/src/events.d.ts +0 -4
  395. package/dist/types/src/events.d.ts.map +0 -1
  396. package/dist/types/src/notebook/notebook.d.ts +0 -35
  397. package/dist/types/src/notebook/notebook.d.ts.map +0 -1
  398. package/dist/types/src/notebook/notebook.test.d.ts +0 -2
  399. package/dist/types/src/notebook/notebook.test.d.ts.map +0 -1
  400. package/dist/types/src/templates/chess.d.ts +0 -3
  401. package/dist/types/src/templates/chess.d.ts.map +0 -1
  402. package/dist/types/src/types/schema.d.ts +0 -61
  403. package/dist/types/src/types/schema.d.ts.map +0 -1
  404. package/src/capabilities/app-graph-builder.ts +0 -65
  405. package/src/capabilities/blueprint-definition.ts +0 -30
  406. package/src/capabilities/capabilities.ts +0 -12
  407. package/src/capabilities/compiler.ts +0 -34
  408. package/src/capabilities/intent-resolver.ts +0 -87
  409. package/src/capabilities/react-surface.tsx +0 -102
  410. package/src/capabilities/settings.ts +0 -21
  411. package/src/events.ts +0 -11
  412. package/src/templates/chess.ts +0 -49
  413. package/src/types/schema.ts +0 -48
  414. /package/dist/lib/browser/{DeploymentDialog-65TWT6S5.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
  415. /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -1,30 +1,41 @@
1
1
  import {
2
2
  NotebookMenu,
3
3
  NotebookStack
4
- } from "./chunk-75LH4EUR.mjs";
5
- import "./chunk-N6M34EUC.mjs";
4
+ } from "./chunk-BKGEAUUH.mjs";
5
+ import "./chunk-I7CSE6T3.mjs";
6
6
  import {
7
7
  meta
8
- } from "./chunk-EZVXV6DA.mjs";
8
+ } from "./chunk-WYR4QHPE.mjs";
9
+ import "./chunk-J5LGTIGS.mjs";
9
10
 
10
11
  // src/components/NotebookContainer.tsx
11
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
12
- import React, { useCallback, useMemo } from "react";
13
- import { Ref } from "@dxos/echo";
12
+ import { RegistryContext } from "@effect-atom/atom-react";
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, useContext, 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, TracingService } from "@dxos/functions";
14
22
  import { invariant as invariant2 } from "@dxos/invariant";
15
- import { Assistant } from "@dxos/plugin-assistant";
16
- import { getSpace } from "@dxos/react-client/echo";
23
+ import { log as log2 } from "@dxos/log";
24
+ import { useComputeRuntimeCallback } from "@dxos/plugin-automation";
25
+ import { Graph } from "@dxos/plugin-explorer/types";
17
26
  import { DropdownMenu, IconButton, Toolbar, useTranslation } from "@dxos/react-ui";
18
- import { StackItem } from "@dxos/react-ui-stack";
19
- import { DataType } from "@dxos/schema";
27
+ import { Layout } from "@dxos/react-ui";
28
+ import { useAttention } from "@dxos/react-ui-attention";
29
+ import { Text, View } from "@dxos/schema";
30
+ import { isNonNullable } from "@dxos/util";
20
31
 
21
- // src/notebook/notebook.ts
22
- import { signal } from "@preact/signals-core";
32
+ // src/notebook/compute-graph.ts
33
+ import { Atom } from "@effect-atom/atom-react";
23
34
  import { log } from "@dxos/log";
24
35
 
25
36
  // src/notebook/eval.ts
26
37
  import { trim } from "@dxos/util";
27
- var evalScript = (code, deps = {}) => {
38
+ var evalScript = async (code, deps = {}) => {
28
39
  const sandbox = {
29
40
  ...deps,
30
41
  // Block access to global objects.
@@ -56,11 +67,11 @@ var evalScript = (code, deps = {}) => {
56
67
  };
57
68
  const sandboxKeys = Object.keys(sandbox);
58
69
  const sandboxValues = Object.values(sandbox);
59
- const fn = new Function(...sandboxKeys, trim`
70
+ const fn2 = new Function(...sandboxKeys, trim`
60
71
  'use strict';
61
72
  return ${code};
62
73
  `);
63
- return fn(...sandboxValues);
74
+ return fn2(...sandboxValues);
64
75
  };
65
76
  var builtIns = /* @__PURE__ */ new Set([
66
77
  // Types.
@@ -102,19 +113,6 @@ var systemDefinitions = trim`
102
113
  import { createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
103
114
  import ts from "typescript";
104
115
  import { invariant } from "@dxos/invariant";
105
- function _define_property(obj, key, value) {
106
- if (key in obj) {
107
- Object.defineProperty(obj, key, {
108
- value,
109
- enumerable: true,
110
- configurable: true,
111
- writable: true
112
- });
113
- } else {
114
- obj[key] = value;
115
- }
116
- return obj;
117
- }
118
116
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/notebook/vfs-parser.ts";
119
117
  var systemFiles = [
120
118
  {
@@ -123,6 +121,16 @@ var systemFiles = [
123
121
  }
124
122
  ];
125
123
  var VirtualTypeScriptParser = class {
124
+ compilerOptions = {
125
+ target: ts.ScriptTarget.ES2020,
126
+ module: ts.ModuleKind.ESNext,
127
+ strict: true,
128
+ esModuleInterop: true,
129
+ skipLibCheck: true,
130
+ forceConsistentCasingInfilenames: true,
131
+ jsx: ts.JsxEmit.React,
132
+ noLib: true
133
+ };
126
134
  /**
127
135
  * Parse a single expression or statement.
128
136
  */
@@ -371,54 +379,70 @@ var VirtualTypeScriptParser = class {
371
379
  const system = createSystem(fileMap);
372
380
  return createVirtualTypeScriptEnvironment(system, allFiles.map(({ filename }) => filename), ts, this.compilerOptions);
373
381
  }
374
- constructor() {
375
- _define_property(this, "compilerOptions", {
376
- target: ts.ScriptTarget.ES2020,
377
- module: ts.ModuleKind.ESNext,
378
- strict: true,
379
- esModuleInterop: true,
380
- skipLibCheck: true,
381
- forceConsistentCasingInfilenames: true,
382
- jsx: ts.JsxEmit.React,
383
- noLib: true
384
- });
385
- }
386
382
  };
387
383
 
388
- // src/notebook/notebook.ts
389
- function _define_property2(obj, key, value) {
390
- if (key in obj) {
391
- Object.defineProperty(obj, key, {
392
- value,
393
- enumerable: true,
394
- configurable: true,
395
- writable: true
396
- });
397
- } else {
398
- obj[key] = value;
399
- }
400
- return obj;
401
- }
402
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/notebook/notebook.ts";
384
+ // src/notebook/compute-graph.ts
385
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/notebook/compute-graph.ts";
403
386
  var ComputeGraph = class {
387
+ _notebook;
388
+ _registry;
389
+ _parser = new VirtualTypeScriptParser();
390
+ _expressionsAtom = Atom.make({});
391
+ _valuesByCellIdAtom = Atom.make({});
392
+ _valuesByNameAtom = Atom.make({});
393
+ constructor(_notebook, _registry) {
394
+ this._notebook = _notebook;
395
+ this._registry = _registry;
396
+ }
404
397
  /**
405
- * Parsed expressions by cell ID.
398
+ * Atom for parsed expressions by cell ID.
406
399
  */
407
400
  get expressions() {
408
- return this._expressions;
401
+ return this._expressionsAtom;
409
402
  }
410
403
  /**
411
- * Computed values by cell ID.
404
+ * Get current expressions by cell ID.
405
+ */
406
+ getExpressions() {
407
+ return this._registry.get(this._expressionsAtom);
408
+ }
409
+ /**
410
+ * Atom for computed values by cell ID.
412
411
  */
413
412
  get values() {
414
- return this._values;
413
+ return this._valuesByCellIdAtom;
414
+ }
415
+ /**
416
+ * Get computed values by cell ID.
417
+ */
418
+ getValues() {
419
+ return this._registry.get(this._valuesByCellIdAtom);
420
+ }
421
+ /**
422
+ * Atom for computed values by name.
423
+ */
424
+ get valuesByName() {
425
+ return this._valuesByNameAtom;
426
+ }
427
+ /**
428
+ * Get current values by name.
429
+ */
430
+ getValuesByName() {
431
+ return this._registry.get(this._valuesByNameAtom);
432
+ }
433
+ /**
434
+ * Get computed value by cell ID.
435
+ */
436
+ getValue(cellId) {
437
+ return this._registry.get(this._valuesByCellIdAtom)[cellId];
415
438
  }
416
439
  /**
417
440
  * Compute values.
418
441
  */
419
- evaluate() {
442
+ async evaluate() {
420
443
  const { expressions, dependencyGraph } = this.parse();
421
- this._values.value = {};
444
+ this._registry.set(this._valuesByCellIdAtom, {});
445
+ this._registry.set(this._valuesByNameAtom, {});
422
446
  const cellExpressions = /* @__PURE__ */ new Map();
423
447
  Object.entries(expressions).forEach(([id, expr]) => {
424
448
  cellExpressions.set(id, expr);
@@ -433,19 +457,19 @@ var ComputeGraph = class {
433
457
  cellId
434
458
  }, {
435
459
  F: __dxlog_file2,
436
- L: 64,
460
+ L: 105,
437
461
  S: this,
438
462
  C: (f, a) => f(...a)
439
463
  });
440
464
  continue;
441
465
  }
442
- const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.script?.target?.content;
466
+ const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.source?.target?.content;
443
467
  if (!cellSource) {
444
468
  log.error("no source for cell", {
445
469
  cellId
446
470
  }, {
447
471
  F: __dxlog_file2,
448
- L: 70,
472
+ L: 111,
449
473
  S: this,
450
474
  C: (f, a) => f(...a)
451
475
  });
@@ -462,14 +486,14 @@ var ComputeGraph = class {
462
486
  if (rhs.endsWith(";")) {
463
487
  rhs = rhs.slice(0, -1).trim();
464
488
  }
465
- const result = evalScript(rhs, valuesByName);
489
+ const result = await this.eval(rhs, valuesByName);
466
490
  valuesByName[expr.name] = result;
467
491
  if (typeof result !== "function") {
468
492
  valuesByCellId[cellId] = result;
469
493
  }
470
494
  }
471
495
  } else {
472
- const result = evalScript(cellSource, valuesByName);
496
+ const result = await this.eval(cellSource, valuesByName);
473
497
  valuesByCellId[cellId] = result;
474
498
  }
475
499
  } catch (error) {
@@ -478,21 +502,25 @@ var ComputeGraph = class {
478
502
  error
479
503
  }, {
480
504
  F: __dxlog_file2,
481
- L: 105,
505
+ L: 147,
482
506
  S: this,
483
507
  C: (f, a) => f(...a)
484
508
  });
485
509
  }
486
510
  }
487
- this._values.value = valuesByCellId;
511
+ this._registry.set(this._valuesByCellIdAtom, valuesByCellId);
512
+ this._registry.set(this._valuesByNameAtom, valuesByName);
488
513
  return valuesByCellId;
489
514
  }
515
+ async eval(source, values) {
516
+ return evalScript(source, values);
517
+ }
490
518
  /**
491
519
  * Parse expressions.
492
520
  */
493
521
  parse() {
494
522
  const expressions = this._notebook.cells.filter((cell) => cell.type === "script").reduce((acc, cell) => {
495
- const text = cell.script?.target?.content.trim();
523
+ const text = cell.source?.target?.content.trim();
496
524
  if (text) {
497
525
  const parsed = this._parser.parseExpression(text);
498
526
  acc[cell.id] = parsed;
@@ -500,7 +528,7 @@ var ComputeGraph = class {
500
528
  return acc;
501
529
  }, {});
502
530
  const dependencyGraph = this.buildDependencyGraph(expressions);
503
- this._expressions.value = expressions;
531
+ this._registry.set(this._expressionsAtom, expressions);
504
532
  return {
505
533
  expressions,
506
534
  dependencyGraph
@@ -539,145 +567,279 @@ var ComputeGraph = class {
539
567
  });
540
568
  return graph;
541
569
  }
542
- constructor(_notebook) {
543
- _define_property2(this, "_notebook", void 0);
544
- _define_property2(this, "_parser", void 0);
545
- _define_property2(this, "_expressions", void 0);
546
- _define_property2(this, "_values", void 0);
547
- this._notebook = _notebook;
548
- this._parser = new VirtualTypeScriptParser();
549
- this._expressions = signal({});
550
- this._values = signal({});
551
- }
552
570
  };
553
571
 
554
572
  // src/components/NotebookContainer.tsx
555
573
  var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/NotebookContainer.tsx";
556
- var NotebookContainer = ({ notebook, env }) => {
557
- var _effect = _useSignals();
558
- try {
559
- const { t } = useTranslation(meta.id);
560
- const space = getSpace(notebook);
561
- const graph = useMemo(() => notebook && new ComputeGraph(notebook), [
562
- notebook
563
- ]);
564
- const handleCompute = useCallback(() => {
565
- graph?.evaluate();
566
- }, [
567
- graph
568
- ]);
569
- const handleRearrange = useCallback((source, target) => {
570
- invariant2(notebook, void 0, {
571
- F: __dxlog_file3,
572
- L: 41,
573
- S: void 0,
574
- A: [
575
- "notebook",
576
- ""
577
- ]
578
- });
579
- const from = notebook.cells.findIndex((cell) => cell.id === source.id);
580
- const to = notebook.cells.findIndex((cell) => cell.id === target.id);
581
- if (from != null && to != null) {
582
- const cell = notebook.cells.splice(from, 1)[0];
583
- if (cell) {
584
- notebook.cells.splice(to, 0, cell);
574
+ var INCLUDE_BLUEPRINTS = [
575
+ "dxos.org/blueprint/assistant",
576
+ "dxos.org/blueprint/markdown"
577
+ ];
578
+ var NotebookContainer = ({ role, subject: notebook, env }) => {
579
+ const { t } = useTranslation(meta.id);
580
+ const registry = useContext(RegistryContext);
581
+ const db = notebook && Obj.getDatabase(notebook);
582
+ const attendableId = notebook ? Obj.getDXN(notebook).toString() : "";
583
+ const { hasAttention } = useAttention(attendableId);
584
+ const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [
585
+ notebook,
586
+ registry
587
+ ]);
588
+ const [queryValues, setQueryValues] = useState({});
589
+ const handleExecQueries = useCallback(async () => {
590
+ invariant2(db, void 0, {
591
+ F: __dxlog_file3,
592
+ L: 54,
593
+ S: void 0,
594
+ A: [
595
+ "db",
596
+ ""
597
+ ]
598
+ });
599
+ const builder = new QueryBuilder();
600
+ for (const cell of notebook?.cells ?? []) {
601
+ if (cell.type === "query") {
602
+ if (cell.source?.target) {
603
+ const source = cell.source.target.content;
604
+ const { name, filter } = builder.build(source);
605
+ if (filter) {
606
+ const ast = Query.select(filter).ast;
607
+ const graph2 = cell.graph?.target;
608
+ if (!graph2) {
609
+ const { view } = await View.makeFromDatabase({
610
+ db
611
+ });
612
+ const newGraph = Graph.make({
613
+ query: {
614
+ ast
615
+ },
616
+ view
617
+ });
618
+ Obj.change(notebook, (n) => {
619
+ const c = n.cells.find((c2) => c2.id === cell.id);
620
+ if (c) {
621
+ c.graph = Ref.make(newGraph);
622
+ c.name = name;
623
+ }
624
+ });
625
+ } else {
626
+ Obj.change(graph2, (g) => {
627
+ g.query.ast = ast;
628
+ });
629
+ }
630
+ }
631
+ }
632
+ if (cell.name && cell.graph?.target) {
633
+ const graph2 = Obj.getSnapshot(cell.graph?.target);
634
+ const query = Query.fromAst(graph2.query.ast);
635
+ const objects = await db.query(query).run();
636
+ const objectIds = objects?.map((obj) => obj.id);
637
+ setQueryValues((prev) => ({
638
+ ...prev,
639
+ [cell.name]: objectIds
640
+ }));
585
641
  }
586
642
  }
587
- }, [
588
- notebook
589
- ]);
590
- const handleCellInsert = useCallback((type, after) => {
591
- invariant2(notebook, void 0, {
592
- F: __dxlog_file3,
593
- L: 56,
594
- S: void 0,
595
- A: [
596
- "notebook",
597
- ""
598
- ]
643
+ }
644
+ }, [
645
+ db,
646
+ notebook,
647
+ graph
648
+ ]);
649
+ const [promptResults, setPromptResults] = useState({});
650
+ const handleExecPrompts = useComputeRuntimeCallback(db?.spaceId, Effect.fnUntraced(function* () {
651
+ invariant2(graph, void 0, {
652
+ F: __dxlog_file3,
653
+ L: 98,
654
+ S: this,
655
+ A: [
656
+ "graph",
657
+ ""
658
+ ]
659
+ });
660
+ const prompts = notebook?.cells.filter((cell) => cell.type === "prompt").map((cell) => cell.prompt).filter(isNonNullable) ?? [];
661
+ for (const prompt of prompts) {
662
+ yield* runPrompt({
663
+ prompt,
664
+ input: {
665
+ ...queryValues,
666
+ ...graph.getValuesByName()
667
+ },
668
+ onResult: (result) => setPromptResults((prev) => ({
669
+ ...prev,
670
+ [prompt.dxn.toString()]: result
671
+ }))
599
672
  });
600
- const cell = {
601
- id: crypto.randomUUID(),
602
- type
603
- };
604
- switch (type) {
605
- case "markdown":
606
- case "script":
607
- case "query": {
608
- cell.script = Ref.make(DataType.makeText());
609
- break;
673
+ }
674
+ }), [
675
+ notebook,
676
+ graph,
677
+ queryValues
678
+ ]);
679
+ const handleCompute = useCallback(async () => {
680
+ await graph?.evaluate();
681
+ await handleExecQueries();
682
+ await handleExecPrompts();
683
+ }, [
684
+ graph,
685
+ handleExecQueries,
686
+ handleExecPrompts
687
+ ]);
688
+ const handleRearrange = useCallback((source, target) => {
689
+ invariant2(notebook, void 0, {
690
+ F: __dxlog_file3,
691
+ L: 131,
692
+ S: void 0,
693
+ A: [
694
+ "notebook",
695
+ ""
696
+ ]
697
+ });
698
+ const from = notebook.cells.findIndex((cell) => cell.id === source.id);
699
+ const to = notebook.cells.findIndex((cell) => cell.id === target.id);
700
+ if (from != null && to != null) {
701
+ Obj.change(notebook, (n) => {
702
+ const cell = n.cells.splice(from, 1)[0];
703
+ if (cell) {
704
+ n.cells.splice(to, 0, cell);
610
705
  }
611
- case "prompt": {
612
- if (space) {
613
- cell.chat = Ref.make(Assistant.makeChat({
614
- queue: space.queues.create()
615
- }));
616
- }
617
- break;
706
+ });
707
+ }
708
+ }, [
709
+ notebook
710
+ ]);
711
+ const handleCellInsert = useCallback(async (type, after) => {
712
+ invariant2(notebook, void 0, {
713
+ F: __dxlog_file3,
714
+ L: 148,
715
+ S: void 0,
716
+ A: [
717
+ "notebook",
718
+ ""
719
+ ]
720
+ });
721
+ const cell = {
722
+ id: crypto.randomUUID(),
723
+ type
724
+ };
725
+ switch (type) {
726
+ case "markdown":
727
+ case "script":
728
+ case "query": {
729
+ cell.source = Ref.make(Text.make());
730
+ break;
731
+ }
732
+ case "prompt": {
733
+ if (db) {
734
+ const objects = await db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
735
+ const blueprints = objects.filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key)).map((blueprint) => Ref.make(blueprint));
736
+ cell.prompt = Ref.make(Prompt.make({
737
+ instructions: "",
738
+ blueprints
739
+ }));
618
740
  }
741
+ break;
619
742
  }
620
- const idx = after ? notebook.cells.findIndex((cell2) => cell2.id === after) : notebook.cells.length;
621
- notebook.cells.splice(idx, 0, cell);
622
- }, [
623
- space,
624
- notebook
625
- ]);
626
- const handleCellDelete = useCallback((id) => {
627
- invariant2(notebook, void 0, {
628
- F: __dxlog_file3,
629
- L: 82,
630
- S: void 0,
631
- A: [
632
- "notebook",
633
- ""
634
- ]
743
+ }
744
+ const idx = after ? notebook.cells.findIndex((cell2) => cell2.id === after) : notebook.cells.length;
745
+ Obj.change(notebook, (n) => {
746
+ n.cells.splice(idx, 0, cell);
747
+ });
748
+ }, [
749
+ db,
750
+ notebook
751
+ ]);
752
+ const handleCellDelete = useCallback((id) => {
753
+ invariant2(notebook, void 0, {
754
+ F: __dxlog_file3,
755
+ L: 180,
756
+ S: void 0,
757
+ A: [
758
+ "notebook",
759
+ ""
760
+ ]
761
+ });
762
+ const idx = notebook.cells.findIndex((cell) => cell.id === id);
763
+ if (idx !== -1) {
764
+ Obj.change(notebook, (n) => {
765
+ n.cells.splice(idx, 1);
635
766
  });
636
- const idx = notebook.cells.findIndex((cell) => cell.id === id);
637
- if (idx !== -1) {
638
- notebook.cells.splice(idx, 1);
639
- }
640
- }, [
641
- notebook
642
- ]);
643
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
644
- toolbar: true
645
- }, /* @__PURE__ */ React.createElement(Toolbar.Root, {
646
- textBlockWidth: true
647
- }, /* @__PURE__ */ React.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React.createElement(DropdownMenu.Trigger, {
648
- asChild: true
649
- }, /* @__PURE__ */ React.createElement(IconButton, {
650
- icon: "ph--plus--regular",
651
- iconOnly: true,
652
- label: t("notebook cell insert label")
653
- })), /* @__PURE__ */ React.createElement(NotebookMenu, {
654
- onCellInsert: handleCellInsert
655
- })), /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
656
- icon: "ph--play--fill",
657
- iconOnly: true,
658
- label: t("compute label"),
659
- classNames: "text-green-500",
660
- onClick: handleCompute
661
- })), /* @__PURE__ */ React.createElement("div", {
662
- role: "none",
663
- className: "flex bs-full overflow-hidden -mis-[1px] -mie-[1px]"
664
- }, /* @__PURE__ */ React.createElement(NotebookStack, {
665
- classNames: "container-max-width border-l border-r border-subduedSeparator",
666
- space,
667
- notebook,
668
- graph,
669
- env,
670
- onRearrange: handleRearrange,
671
- onCellInsert: handleCellInsert,
672
- onCellDelete: handleCellDelete
673
- })));
674
- } finally {
675
- _effect.f();
676
- }
767
+ }
768
+ }, [
769
+ notebook
770
+ ]);
771
+ return /* @__PURE__ */ React.createElement(Layout.Main, {
772
+ role,
773
+ toolbar: true
774
+ }, /* @__PURE__ */ React.createElement(Toolbar.Root, {
775
+ disabled: !hasAttention,
776
+ textBlockWidth: true
777
+ }, /* @__PURE__ */ React.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React.createElement(DropdownMenu.Trigger, {
778
+ asChild: true
779
+ }, /* @__PURE__ */ React.createElement(IconButton, {
780
+ icon: "ph--plus--regular",
781
+ iconOnly: true,
782
+ label: t("notebook cell insert label")
783
+ })), /* @__PURE__ */ React.createElement(NotebookMenu, {
784
+ onCellInsert: handleCellInsert
785
+ })), /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
786
+ icon: "ph--play--fill",
787
+ iconOnly: true,
788
+ label: t("compute label"),
789
+ classNames: "text-green-500",
790
+ onClick: handleCompute
791
+ })), /* @__PURE__ */ React.createElement("div", {
792
+ role: "none",
793
+ className: "flex bs-full overflow-hidden -mis-[1px] -mie-[1px]"
794
+ }, /* @__PURE__ */ React.createElement(NotebookStack, {
795
+ classNames: "container-max-width border-l border-r border-subduedSeparator",
796
+ db,
797
+ notebook,
798
+ graph,
799
+ env,
800
+ promptResults,
801
+ onRearrange: handleRearrange,
802
+ onCellInsert: handleCellInsert,
803
+ onCellDelete: handleCellDelete
804
+ })));
677
805
  };
678
806
  var NotebookContainer_default = NotebookContainer;
807
+ var runPrompt = Effect.fn(function* ({ prompt, input, onResult }) {
808
+ const inputData = {
809
+ prompt,
810
+ input
811
+ };
812
+ const tracer = yield* TracingService;
813
+ const trace = yield* tracer.traceInvocationStart({
814
+ target: void 0,
815
+ payload: {
816
+ data: {}
817
+ }
818
+ });
819
+ const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop), Effect.exit);
820
+ Exit.match(result, {
821
+ onFailure: (cause) => {
822
+ const error = Cause.prettyErrors(cause)[0];
823
+ log2.error(error.message, error.cause ?? error.stack, {
824
+ F: __dxlog_file3,
825
+ L: 258,
826
+ S: this,
827
+ C: (f, a) => f(...a)
828
+ });
829
+ onResult(error.message);
830
+ },
831
+ onSuccess: (result2) => {
832
+ onResult(result2.note);
833
+ }
834
+ });
835
+ yield* tracer.traceInvocationEnd({
836
+ trace,
837
+ // TODO(dmaretskyi): Might miss errors.
838
+ exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : void 0
839
+ });
840
+ });
679
841
  export {
680
842
  NotebookContainer,
681
843
  NotebookContainer_default as default
682
844
  };
683
- //# sourceMappingURL=NotebookContainer-LVGRPFY3.mjs.map
845
+ //# sourceMappingURL=NotebookContainer-UQ4I24R6.mjs.map