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

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 (426) hide show
  1. package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
  2. package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs +845 -0
  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-4N5TLXEJ.mjs +105 -0
  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-QYAREHGH.mjs → chunk-WYR4QHPE.mjs} +8 -5
  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 +139 -103
  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 +14 -6
  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-DQGZ6QHI.mjs +846 -0
  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-AHXJ6NQU.mjs → chunk-5HSJPAK7.mjs} +8 -5
  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-V37R7KB5.mjs +107 -0
  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 +139 -103
  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 +14 -6
  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 +4 -4
  128. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  129. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +244 -13
  130. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
  132. package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
  133. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
  134. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  135. package/dist/types/src/components/NotebookContainer.d.ts +8 -0
  136. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  137. package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
  138. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  139. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
  140. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
  141. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
  142. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
  143. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
  144. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  145. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
  146. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  147. package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
  148. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  149. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  150. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  151. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  152. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  153. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  154. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  155. package/dist/types/src/components/ScriptContainer.d.ts +7 -8
  156. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  157. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
  158. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  159. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +246 -10
  160. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  161. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  162. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  163. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
  164. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  165. package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
  166. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  167. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  168. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
  169. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  170. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
  171. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  172. package/dist/types/src/components/index.d.ts +4 -5
  173. package/dist/types/src/components/index.d.ts.map +1 -1
  174. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  175. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  176. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  177. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  178. package/dist/types/src/hooks/deploy.d.ts +18 -32
  179. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  180. package/dist/types/src/hooks/format.d.ts +4 -4
  181. package/dist/types/src/hooks/format.d.ts.map +1 -1
  182. package/dist/types/src/hooks/index.d.ts +1 -0
  183. package/dist/types/src/hooks/index.d.ts.map +1 -1
  184. package/dist/types/src/hooks/template.d.ts +6 -16
  185. package/dist/types/src/hooks/template.d.ts.map +1 -1
  186. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  187. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  188. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  189. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  190. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  191. package/dist/types/src/index.d.ts +2 -1
  192. package/dist/types/src/index.d.ts.map +1 -1
  193. package/dist/types/src/meta.d.ts +2 -3
  194. package/dist/types/src/meta.d.ts.map +1 -1
  195. package/dist/types/src/notebook/compute-graph.d.ts +58 -0
  196. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  197. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  198. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  199. package/dist/types/src/notebook/eval.d.ts +13 -0
  200. package/dist/types/src/notebook/eval.d.ts.map +1 -0
  201. package/dist/types/src/notebook/index.d.ts +2 -0
  202. package/dist/types/src/notebook/index.d.ts.map +1 -0
  203. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  204. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  205. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  206. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  207. package/dist/types/src/templates/anthropic.d.ts +8 -0
  208. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  209. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  210. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  211. package/dist/types/src/templates/commentary.d.ts +16 -0
  212. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  213. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  214. package/dist/types/src/templates/discord.d.ts.map +1 -1
  215. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  216. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  217. package/dist/types/src/templates/forex.d.ts +4 -1
  218. package/dist/types/src/templates/forex.d.ts.map +1 -1
  219. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  220. package/dist/types/src/templates/index.d.ts +52 -1
  221. package/dist/types/src/templates/index.d.ts.map +1 -1
  222. package/dist/types/src/templates/ping.d.ts +3 -0
  223. package/dist/types/src/templates/ping.d.ts.map +1 -0
  224. package/dist/types/src/testing/data.d.ts +3 -0
  225. package/dist/types/src/testing/data.d.ts.map +1 -0
  226. package/dist/types/src/testing/index.d.ts +2 -0
  227. package/dist/types/src/testing/index.d.ts.map +1 -0
  228. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  229. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  230. package/dist/types/src/translations.d.ts +32 -5
  231. package/dist/types/src/translations.d.ts.map +1 -1
  232. package/dist/types/src/types/Notebook.d.ts +100 -0
  233. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  234. package/dist/types/src/types/actions.d.ts +40 -0
  235. package/dist/types/src/types/actions.d.ts.map +1 -0
  236. package/dist/types/src/types/capabilities.d.ts +12 -0
  237. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  238. package/dist/types/src/types/events.d.ts +5 -0
  239. package/dist/types/src/types/events.d.ts.map +1 -0
  240. package/dist/types/src/types/index.d.ts +5 -1
  241. package/dist/types/src/types/index.d.ts.map +1 -1
  242. package/dist/types/src/types/types.d.ts +6 -0
  243. package/dist/types/src/types/types.d.ts.map +1 -0
  244. package/dist/types/src/util/deploy.d.ts +7 -7
  245. package/dist/types/src/util/deploy.d.ts.map +1 -1
  246. package/dist/types/src/util/functions.d.ts +6 -3
  247. package/dist/types/src/util/functions.d.ts.map +1 -1
  248. package/dist/types/tsconfig.tsbuildinfo +1 -1
  249. package/package.json +123 -84
  250. package/src/ScriptPlugin.tsx +57 -76
  251. package/src/blueprints/index.ts +5 -0
  252. package/src/blueprints/script-blueprint.ts +24 -0
  253. package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
  254. package/src/capabilities/app-graph-builder/index.ts +7 -0
  255. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +103 -105
  256. package/src/capabilities/artifact-definition/index.ts +7 -0
  257. package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
  258. package/src/capabilities/blueprint-definition/index.ts +7 -0
  259. package/src/capabilities/compiler/compiler.ts +103 -0
  260. package/src/capabilities/compiler/index.ts +7 -0
  261. package/src/capabilities/index.ts +6 -10
  262. package/src/capabilities/operation-resolver/index.ts +7 -0
  263. package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
  264. package/src/capabilities/react-surface/index.ts +7 -0
  265. package/src/capabilities/react-surface/react-surface.tsx +119 -0
  266. package/src/capabilities/settings/index.ts +7 -0
  267. package/src/capabilities/settings/settings.ts +33 -0
  268. package/src/compiler/compiler.ts +11 -4
  269. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +45 -22
  270. package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -54
  271. package/src/components/DeploymentDialog/index.ts +1 -1
  272. package/src/components/FrameContainer/FrameContainer.tsx +8 -5
  273. package/src/components/NotebookContainer.stories.tsx +87 -0
  274. package/src/components/NotebookContainer.tsx +271 -0
  275. package/src/components/NotebookStack/NotebookCell.tsx +217 -0
  276. package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
  277. package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
  278. package/src/components/NotebookStack/NotebookStack.tsx +86 -0
  279. package/src/components/NotebookStack/index.ts +6 -0
  280. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  281. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  282. package/src/components/QueryEditor/index.ts +5 -0
  283. package/src/components/ScriptContainer.tsx +52 -36
  284. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +57 -17
  285. package/src/components/ScriptToolbar/ScriptToolbar.tsx +37 -33
  286. package/src/components/Settings/ScriptObjectSettings.tsx +151 -48
  287. package/src/components/Settings/ScriptPluginSettings.tsx +43 -48
  288. package/src/components/TestPanel/TestContainer.tsx +9 -8
  289. package/src/components/TestPanel/TestPanel.tsx +66 -41
  290. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +86 -33
  291. package/src/components/TypescriptEditor/TypescriptEditor.tsx +84 -81
  292. package/src/components/index.ts +3 -0
  293. package/src/e2e/ai.test.ts +92 -0
  294. package/src/e2e/deploy.test.ts +64 -0
  295. package/src/hooks/deploy.ts +49 -42
  296. package/src/hooks/format.ts +9 -5
  297. package/src/hooks/index.ts +1 -0
  298. package/src/hooks/template.ts +20 -23
  299. package/src/hooks/useCompiler.ts +24 -0
  300. package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
  301. package/src/hooks/useToolbarState.ts +29 -4
  302. package/src/index.ts +2 -1
  303. package/src/meta.ts +9 -7
  304. package/src/notebook/compute-graph.test.ts +82 -0
  305. package/src/notebook/compute-graph.ts +230 -0
  306. package/src/notebook/eval.ts +105 -0
  307. package/src/notebook/index.ts +5 -0
  308. package/src/notebook/vfs-parser.test.ts +149 -0
  309. package/src/notebook/vfs-parser.ts +451 -0
  310. package/src/templates/anthropic.ts +42 -0
  311. package/src/templates/chess-bot.ts +58 -0
  312. package/src/templates/commentary.ts +230 -0
  313. package/src/templates/data-generator.ts +10 -4
  314. package/src/templates/discord.ts +12 -4
  315. package/src/templates/forex-effect.ts +24 -25
  316. package/src/templates/forex.ts +9 -6
  317. package/src/templates/gmail.ts +34 -64
  318. package/src/templates/index.ts +24 -11
  319. package/src/templates/ping.ts +17 -0
  320. package/src/testing/data.ts +72 -0
  321. package/src/testing/index.ts +5 -0
  322. package/src/testing/simulator.test.ts +40 -0
  323. package/src/translations.ts +35 -7
  324. package/src/types/Notebook.ts +41 -0
  325. package/src/types/actions.ts +45 -0
  326. package/src/types/capabilities.ts +17 -0
  327. package/src/types/events.ts +11 -0
  328. package/src/types/index.ts +5 -1
  329. package/src/types/types.ts +15 -0
  330. package/src/util/deploy.ts +38 -61
  331. package/src/util/functions.ts +58 -25
  332. package/src/vite-env.d.ts +2 -0
  333. package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
  334. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
  335. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
  336. package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs +0 -64
  337. package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
  338. package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs +0 -249
  339. package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs.map +0 -7
  340. package/dist/lib/browser/chunk-3U6DTUH3.mjs +0 -283
  341. package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
  342. package/dist/lib/browser/chunk-5TVBECWH.mjs +0 -15
  343. package/dist/lib/browser/chunk-5TVBECWH.mjs.map +0 -7
  344. package/dist/lib/browser/chunk-FIM2MVNJ.mjs +0 -555
  345. package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
  346. package/dist/lib/browser/chunk-FMDXKOP7.mjs +0 -233
  347. package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
  348. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  349. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  350. package/dist/lib/browser/chunk-P4HQKUCP.mjs +0 -153
  351. package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
  352. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  353. package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
  354. package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
  355. package/dist/lib/browser/compiler-CXCUA4UQ.mjs +0 -82
  356. package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
  357. package/dist/lib/browser/intent-resolver-7B77IG3N.mjs +0 -91
  358. package/dist/lib/browser/intent-resolver-7B77IG3N.mjs.map +0 -7
  359. package/dist/lib/browser/react-surface-FYYXZA7C.mjs +0 -104
  360. package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
  361. package/dist/lib/browser/settings-KCTBK5TY.mjs +0 -24
  362. package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
  363. package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
  364. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
  365. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
  366. package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs +0 -65
  367. package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
  368. package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs +0 -250
  369. package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs.map +0 -7
  370. package/dist/lib/node-esm/chunk-35M3CHYE.mjs +0 -16
  371. package/dist/lib/node-esm/chunk-35M3CHYE.mjs.map +0 -7
  372. package/dist/lib/node-esm/chunk-7NMI4CEU.mjs +0 -556
  373. package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
  374. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  375. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
  376. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
  377. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  378. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  379. package/dist/lib/node-esm/chunk-QKK3NDHW.mjs +0 -154
  380. package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
  381. package/dist/lib/node-esm/chunk-RT43MACC.mjs +0 -284
  382. package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
  383. package/dist/lib/node-esm/chunk-XJPK3IYI.mjs +0 -234
  384. package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
  385. package/dist/lib/node-esm/compiler-EPFKQXPE.mjs +0 -83
  386. package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
  387. package/dist/lib/node-esm/intent-resolver-FRZGS4TB.mjs +0 -92
  388. package/dist/lib/node-esm/intent-resolver-FRZGS4TB.mjs.map +0 -7
  389. package/dist/lib/node-esm/react-surface-V32NWHKN.mjs +0 -105
  390. package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
  391. package/dist/lib/node-esm/settings-DXZ334A3.mjs +0 -25
  392. package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
  393. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  394. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  395. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  396. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  397. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  398. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  399. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  400. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  401. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  402. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  403. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  404. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  405. package/dist/types/src/capabilities/settings.d.ts +0 -4
  406. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  407. package/dist/types/src/events.d.ts +0 -4
  408. package/dist/types/src/events.d.ts.map +0 -1
  409. package/dist/types/src/templates/chess.d.ts +0 -3
  410. package/dist/types/src/templates/chess.d.ts.map +0 -1
  411. package/dist/types/src/templates/echo.d.ts +0 -6
  412. package/dist/types/src/templates/echo.d.ts.map +0 -1
  413. package/dist/types/src/types/schema.d.ts +0 -38
  414. package/dist/types/src/types/schema.d.ts.map +0 -1
  415. package/src/capabilities/app-graph-builder.ts +0 -64
  416. package/src/capabilities/capabilities.ts +0 -12
  417. package/src/capabilities/compiler.ts +0 -33
  418. package/src/capabilities/intent-resolver.ts +0 -80
  419. package/src/capabilities/react-surface.tsx +0 -89
  420. package/src/capabilities/settings.ts +0 -21
  421. package/src/events.ts +0 -11
  422. package/src/templates/chess.ts +0 -47
  423. package/src/templates/echo.ts +0 -8
  424. package/src/types/schema.ts +0 -37
  425. /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
  426. /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -3,33 +3,40 @@
3
3
  //
4
4
 
5
5
  import { Octokit } from '@octokit/core';
6
- import React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';
6
+ import React, { type ChangeEvent, useCallback, useState } from 'react';
7
7
 
8
- import { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';
9
- import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
8
+ import { ToolId } from '@dxos/ai';
9
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
10
+ import { SettingsOperation } from '@dxos/app-toolkit';
11
+ import { Blueprint, Template } from '@dxos/blueprints';
12
+ import { Filter, Obj, Ref } from '@dxos/echo';
13
+ import { Function, type Script, getUserFunctionIdInMetadata } from '@dxos/functions';
14
+ import { getInvocationUrl } from '@dxos/functions-runtime';
10
15
  import { log } from '@dxos/log';
11
16
  import { useClient } from '@dxos/react-client';
12
- import { Filter, getMeta, getSpace, Ref, useQuery } from '@dxos/react-client/echo';
13
- import { Button, Clipboard, Input, useControlledState, useTranslation } from '@dxos/react-ui';
14
- import { DataType } from '@dxos/schema';
17
+ import { useQuery } from '@dxos/react-client/echo';
18
+ import { Button, Clipboard, Input, useAsyncEffect, useControlledState, useTranslation } from '@dxos/react-ui';
19
+ import { AccessToken } from '@dxos/types';
20
+ import { kebabize } from '@dxos/util';
15
21
 
16
- import { SCRIPT_PLUGIN } from '../../meta';
22
+ import { meta } from '../../meta';
17
23
 
18
24
  export type ScriptObjectSettingsProps = {
19
- object: ScriptType;
25
+ object: Script.Script;
20
26
  };
21
27
 
22
28
  export const ScriptObjectSettings = ({ object }: ScriptObjectSettingsProps) => {
23
29
  return (
24
30
  <>
25
31
  <Binding object={object} />
32
+ <BlueprintEditor object={object} />
26
33
  <Publishing object={object} />
27
34
  </>
28
35
  );
29
36
  };
30
37
 
31
38
  export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
32
- const { t } = useTranslation(SCRIPT_PLUGIN);
39
+ const { t } = useTranslation(meta.id);
33
40
  return (
34
41
  <Input.Root>
35
42
  <Input.Label>{t('description label')}</Input.Label>
@@ -37,24 +44,118 @@ export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
37
44
  placeholder={t('description placeholder')}
38
45
  value={object.description ?? ''}
39
46
  onChange={(event) => {
40
- object.description = event.target.value;
47
+ Obj.change(object, (o) => {
48
+ o.description = event.target.value;
49
+ });
41
50
  }}
42
51
  />
43
52
  </Input.Root>
44
53
  );
45
54
  };
46
55
 
56
+ const BlueprintEditor = ({ object }: ScriptObjectSettingsProps) => {
57
+ const { t } = useTranslation(meta.id);
58
+ const db = Obj.getDatabase(object);
59
+ const [fn] = useQuery(db, Filter.type(Function.Function, { source: Ref.make(object) }));
60
+ const blueprints = useQuery(db, Filter.type(Blueprint.Blueprint));
61
+
62
+ const [creating, setCreating] = useState(false);
63
+ const [instructions, setInstructions] = useState<string>(`You can run the script "${object.name ?? 'script'}".`);
64
+ const blueprintKey = `dxos.org/blueprint/${kebabize(object.name ?? 'script')}`;
65
+ const existingBlueprint = blueprints.find((bp) => bp.key === blueprintKey);
66
+
67
+ useAsyncEffect(async () => {
68
+ if (!existingBlueprint) {
69
+ return;
70
+ }
71
+ const source = await existingBlueprint.instructions.source.load();
72
+ setInstructions(source.content ?? '');
73
+ }, [existingBlueprint]);
74
+
75
+ const handleSave = useCallback(async () => {
76
+ if (!db) {
77
+ return;
78
+ }
79
+
80
+ setCreating(true);
81
+ try {
82
+ if (existingBlueprint) {
83
+ const text = await existingBlueprint.instructions.source.load();
84
+ Obj.change(text, (t) => {
85
+ t.content = instructions;
86
+ });
87
+ if (fn?.key) {
88
+ const toolId = ToolId.make(fn.key);
89
+ if (!existingBlueprint.tools?.includes(toolId)) {
90
+ Obj.change(existingBlueprint, (b) => {
91
+ b.tools = [...(b.tools ?? []), toolId];
92
+ });
93
+ }
94
+ }
95
+ } else if (fn?.key) {
96
+ db.add(
97
+ Blueprint.make({
98
+ key: blueprintKey,
99
+ name: object.name ?? 'Script',
100
+ instructions: Template.make({
101
+ source: instructions,
102
+ }),
103
+ tools: [ToolId.make(fn.key)],
104
+ }),
105
+ );
106
+ }
107
+ await db.flush();
108
+ } finally {
109
+ setCreating(false);
110
+ }
111
+ }, [db, existingBlueprint, fn, blueprintKey, object.name, instructions]);
112
+
113
+ return (
114
+ <div className='flex flex-col gap-4 mlb-cardSpacingBlock'>
115
+ <div>
116
+ <h2>{t('blueprint editor label', { default: 'Blueprint' })}</h2>
117
+ <p className='text-description text-sm'>
118
+ {t('blueprint editor description', {
119
+ default: 'Create a blueprint that exposes this script as a tool.',
120
+ })}
121
+ </p>
122
+ </div>
123
+ <Input.Root>
124
+ <div role='none' className='flex flex-col gap-1'>
125
+ <Input.Label>{t('blueprint instructions label', { default: 'Instructions' })}</Input.Label>
126
+ <Input.TextArea
127
+ placeholder={t('blueprint instructions placeholder', {
128
+ default: 'Describe how this tool should be used.',
129
+ })}
130
+ rows={6}
131
+ value={instructions}
132
+ onChange={(event) => setInstructions(event.target.value)}
133
+ classNames='resize-y'
134
+ />
135
+ </div>
136
+ </Input.Root>
137
+ <div className='flex justify-end gap-2'>
138
+ <Button disabled={(!existingBlueprint && !fn?.key) || creating} onClick={handleSave}>
139
+ {t(creating ? 'creating label' : 'create blueprint label', {
140
+ default: creating ? 'Creating…' : 'Create blueprint',
141
+ })}
142
+ </Button>
143
+ </div>
144
+ </div>
145
+ );
146
+ };
147
+
47
148
  const Binding = ({ object }: ScriptObjectSettingsProps) => {
48
- const { t } = useTranslation(SCRIPT_PLUGIN);
149
+ const { t } = useTranslation(meta.id);
49
150
  const client = useClient();
50
- const space = getSpace(object);
51
- const [fn] = useQuery(space, Filter.type(FunctionType, { source: Ref.make(object) }));
151
+ const db = Obj.getDatabase(object);
152
+ const [fn] = useQuery(db, Filter.type(Function.Function, { source: Ref.make(object) }));
52
153
 
53
- const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));
154
+ const functionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
54
155
  const functionUrl =
55
- functionPath &&
56
- getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? '', {
57
- spaceId: space?.id,
156
+ functionId &&
157
+ getInvocationUrl(functionId, client.config.values.runtime?.services?.edge?.url ?? '', {
158
+ spaceId: db?.spaceId,
58
159
  });
59
160
 
60
161
  const [binding, setBinding] = useControlledState(fn?.binding ?? '');
@@ -66,7 +167,9 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
66
167
  );
67
168
 
68
169
  const handleBindingBlur = useCallback(() => {
69
- fn.binding = binding;
170
+ Obj.change(fn, (f) => {
171
+ f.binding = binding;
172
+ });
70
173
  }, [fn, binding]);
71
174
 
72
175
  if (!fn || !functionUrl) {
@@ -85,7 +188,9 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
85
188
  disabled
86
189
  value={functionUrl}
87
190
  onChange={(event) => {
88
- fn.name = event.target.value;
191
+ Obj.change(fn, (f) => {
192
+ f.name = event.target.value;
193
+ });
89
194
  }}
90
195
  />
91
196
  <Clipboard.IconButton value={functionUrl} />
@@ -109,14 +214,14 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
109
214
 
110
215
  // TODO(burdon): Move to separate tab?
111
216
  const Publishing = ({ object }: ScriptObjectSettingsProps) => {
112
- const { t } = useTranslation(SCRIPT_PLUGIN);
113
- const { dispatchPromise: dispatch } = useIntentDispatcher();
114
- const space = getSpace(object);
115
- const [githubToken] = useQuery(space, Filter.type(DataType.AccessToken, { source: 'github.com' }));
116
- const gistKey = getMeta(object).keys.find(({ source }) => source === 'github.com');
217
+ const { t } = useTranslation(meta.id);
218
+ const { invokePromise } = useOperationInvoker();
219
+ const db = Obj.getDatabase(object);
220
+ const [githubToken] = useQuery(db, Filter.type(AccessToken.AccessToken, { source: 'github.com' }));
221
+ const gistKey = Obj.getMeta(object).keys.find(({ source }) => source === 'github.com');
117
222
  const [gistUrl, setGistUrl] = useState<string | undefined>();
118
223
 
119
- useEffect(() => {
224
+ useAsyncEffect(async () => {
120
225
  const token = githubToken?.token;
121
226
  const gistId = gistKey?.id;
122
227
  if (!token || !gistId) {
@@ -124,25 +229,24 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
124
229
  return;
125
230
  }
126
231
 
127
- const timeout = setTimeout(async () => {
128
- try {
129
- const octokit = new Octokit({ auth: githubToken.token });
130
- const response = await octokit.request('GET /gists/{gist_id}', {
131
- gist_id: gistId,
132
- });
133
- setGistUrl(response.data.html_url);
134
- } catch (err) {
135
- log.catch(err);
136
- setGistUrl(undefined);
137
- }
138
- });
139
-
140
- return () => clearTimeout(timeout);
232
+ try {
233
+ const octokit = new Octokit({ auth: githubToken.token });
234
+ const response = await octokit.request('GET /gists/{gist_id}', {
235
+ gist_id: gistId,
236
+ });
237
+ setGistUrl(response.data.html_url);
238
+ } catch (err) {
239
+ log.catch(err);
240
+ setGistUrl(undefined);
241
+ }
141
242
  }, [githubToken, gistKey]);
142
243
 
143
244
  const handleOpenTokenManager = useCallback(
144
- () => dispatch(createIntent(SettingsAction.Open, { plugin: 'dxos.org/plugin/token-manager' })),
145
- [],
245
+ () =>
246
+ invokePromise(SettingsOperation.Open, {
247
+ plugin: 'dxos.org/plugin/token-manager',
248
+ }),
249
+ [invokePromise],
146
250
  );
147
251
 
148
252
  const [publishing, setPublishing] = useState(false);
@@ -155,7 +259,7 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
155
259
 
156
260
  try {
157
261
  // TODO(wittjosiah): Factor out to intent.
158
- const meta = getMeta(object);
262
+ const meta = Obj.getMeta(object);
159
263
  const githubKey = meta.keys.find(({ source }) => source === 'github.com');
160
264
  const gistId = githubKey?.id;
161
265
  if (gistId) {
@@ -168,8 +272,11 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
168
272
  public: true,
169
273
  files,
170
274
  });
171
- if (response.data.id) {
172
- meta.keys.push({ source: 'github.com', id: response.data.id });
275
+ const gistId = response.data.id;
276
+ if (gistId) {
277
+ Obj.change(object, (obj) => {
278
+ Obj.getMeta(obj).keys.push({ source: 'github.com', id: gistId });
279
+ });
173
280
  }
174
281
  }
175
282
  } finally {
@@ -200,7 +307,3 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
200
307
  </div>
201
308
  );
202
309
  };
203
-
204
- // TODO(wittjosiah): Factor out.
205
- // From https://stackoverflow.com/a/67243723/2804332
206
- const kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
@@ -4,68 +4,63 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
8
7
  import { useClient } from '@dxos/react-client';
9
8
  import { Button, Select, useTranslation } from '@dxos/react-ui';
10
- import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
11
- import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
9
+ import { Settings } from '@dxos/react-ui-form';
10
+ import { type EditorInputMode, EditorInputModes } from '@dxos/ui-editor';
12
11
 
13
12
  import { meta } from '../../meta';
14
- import { type ScriptSettingsProps } from '../../types';
13
+ import { type ScriptSettings } from '../../types';
14
+ import { getAccessCredential } from '../../util';
15
15
 
16
- export const ScriptPluginSettings = ({ settings }: { settings: ScriptSettingsProps }) => {
16
+ export type ScriptPluginSettingsComponentProps = {
17
+ settings: ScriptSettings;
18
+ onSettingsChange: (fn: (current: ScriptSettings) => ScriptSettings) => void;
19
+ };
20
+
21
+ export const ScriptPluginSettings = ({ settings, onSettingsChange }: ScriptPluginSettingsComponentProps) => {
17
22
  const { t } = useTranslation(meta.id);
18
23
  const client = useClient();
19
24
 
20
25
  // TODO(burdon): Check token.
21
26
  const handleAuthenticate = async () => {
22
27
  const { identityKey } = client.halo.identity.get()!;
23
- await client.halo.writeCredentials([
24
- {
25
- issuer: identityKey,
26
- issuanceDate: new Date(),
27
- subject: {
28
- id: identityKey,
29
- assertion: {
30
- '@type': 'dxos.halo.credentials.ServiceAccess',
31
- serverName: 'hub.dxos.network',
32
- serverKey: identityKey,
33
- identityKey,
34
- capabilities: ['composer:beta'],
35
- },
36
- },
37
- } satisfies Credential,
38
- ]);
28
+ await client.halo.writeCredentials([getAccessCredential(identityKey)]);
39
29
  };
40
30
 
41
31
  return (
42
- <DeprecatedFormContainer>
43
- {/* TODO(wittjosiah): Hide outside of dev environments. */}
44
- <DeprecatedFormInput label={t('authenticate action label')}>
45
- <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>
46
- </DeprecatedFormInput>
32
+ <Settings.Root>
33
+ <Settings.Section title={t('settings title', { ns: meta.id })}>
34
+ <Settings.Group>
35
+ {/* TODO(wittjosiah): Hide outside of dev environments. */}
36
+ <Settings.ItemInput title={t('authenticate action label')}>
37
+ <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>
38
+ </Settings.ItemInput>
47
39
 
48
- <DeprecatedFormInput label={t('editor input mode label')}>
49
- <Select.Root
50
- value={settings.editorInputMode ?? 'default'}
51
- onValueChange={(value) => {
52
- settings.editorInputMode = value as EditorInputMode;
53
- }}
54
- >
55
- <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
56
- <Select.Portal>
57
- <Select.Content>
58
- <Select.Viewport>
59
- {EditorInputModes.map((mode) => (
60
- <Select.Option key={mode} value={mode}>
61
- {t(`settings editor input mode ${mode} label`)}
62
- </Select.Option>
63
- ))}
64
- </Select.Viewport>
65
- </Select.Content>
66
- </Select.Portal>
67
- </Select.Root>
68
- </DeprecatedFormInput>
69
- </DeprecatedFormContainer>
40
+ <Settings.ItemInput title={t('editor input mode label')}>
41
+ <Select.Root
42
+ value={settings.editorInputMode ?? 'default'}
43
+ onValueChange={(value) => {
44
+ onSettingsChange((s) => ({ ...s, editorInputMode: value as EditorInputMode }));
45
+ }}
46
+ >
47
+ <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
48
+ <Select.Portal>
49
+ <Select.Content>
50
+ <Select.Viewport>
51
+ {EditorInputModes.map((mode) => (
52
+ <Select.Option key={mode} value={mode}>
53
+ {t(`settings editor input mode ${mode} label`)}
54
+ </Select.Option>
55
+ ))}
56
+ </Select.Viewport>
57
+ <Select.Arrow />
58
+ </Select.Content>
59
+ </Select.Portal>
60
+ </Select.Root>
61
+ </Settings.ItemInput>
62
+ </Settings.Group>
63
+ </Settings.Section>
64
+ </Settings.Root>
70
65
  );
71
66
  };
@@ -4,23 +4,24 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type ScriptType } from '@dxos/functions';
8
- import { StackItem } from '@dxos/react-ui-stack';
7
+ import { type Script } from '@dxos/functions';
8
+ import { Layout } from '@dxos/react-ui';
9
9
 
10
- import { TestPanel } from './TestPanel';
11
10
  import { useDeployState, useToolbarState } from '../../hooks';
12
11
 
12
+ import { TestPanel } from './TestPanel';
13
+
13
14
  export type TestContainerProps = {
14
15
  role: string;
15
- script: ScriptType;
16
+ script: Script.Script;
16
17
  };
17
18
 
18
- export const TestContainer = ({ script }: TestContainerProps) => {
19
+ export const TestContainer = ({ role, script }: TestContainerProps) => {
19
20
  const state = useToolbarState();
20
21
  useDeployState({ state, script });
21
22
  return (
22
- <StackItem.Content>
23
- <TestPanel functionUrl={state.functionUrl} />
24
- </StackItem.Content>
23
+ <Layout.Main role={role}>
24
+ <TestPanel functionUrl={state.value.functionUrl} />
25
+ </Layout.Main>
25
26
  );
26
27
  };
@@ -5,18 +5,23 @@
5
5
  import React, { forwardRef, useEffect, useRef, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
- import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
8
+ import { Avatar, Icon, Input, ScrollArea, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
9
9
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
10
- import { errorText, mx } from '@dxos/react-ui-theme';
10
+ import { errorText, mx } from '@dxos/ui-theme';
11
11
 
12
- import { SCRIPT_PLUGIN } from '../../meta';
12
+ import { meta } from '../../meta';
13
13
 
14
14
  type State = 'pending' | 'responding';
15
15
 
16
16
  /**
17
17
  * Request or response.
18
18
  */
19
- type Message = { type: 'request' | 'response'; text?: string; data?: any; error?: Error };
19
+ type Message = {
20
+ type: 'request' | 'response';
21
+ text?: string;
22
+ data?: any;
23
+ error?: Error;
24
+ };
20
25
 
21
26
  export type TestPanelProps = ThemedClassName<{
22
27
  functionUrl?: string;
@@ -24,7 +29,7 @@ export type TestPanelProps = ThemedClassName<{
24
29
 
25
30
  // TODO(burdon): Need persistent history (currently lost when switching tabs)..
26
31
  export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
27
- const { t } = useTranslation(SCRIPT_PLUGIN);
32
+ const { t } = useTranslation(meta.id);
28
33
 
29
34
  const inputRef = useRef<HTMLInputElement>(null);
30
35
  const [input, setInput] = useState('');
@@ -41,7 +46,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
41
46
  }
42
47
  };
43
48
 
44
- const controller = useRef<AbortController>();
49
+ const controller = useRef<AbortController>(null);
45
50
  useEffect(() => {
46
51
  return () => {
47
52
  handleStop();
@@ -50,7 +55,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
50
55
 
51
56
  const handleStop = () => {
52
57
  controller.current?.abort('stop');
53
- controller.current = undefined;
58
+ controller.current = null;
54
59
  };
55
60
 
56
61
  const handleClear = () => {
@@ -61,8 +66,16 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
61
66
  inputRef.current?.focus();
62
67
  };
63
68
 
64
- const handleResponse = ({ text, data, error }: { text?: string; data?: any; error?: Error } = {}) => {
65
- controller.current = undefined;
69
+ const handleResponse = ({
70
+ text,
71
+ data,
72
+ error,
73
+ }: {
74
+ text?: string;
75
+ data?: any;
76
+ error?: Error;
77
+ } = {}) => {
78
+ controller.current = null;
66
79
  setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);
67
80
  setResult('');
68
81
  setState(null);
@@ -108,7 +121,9 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
108
121
  // Check for error.
109
122
  if (!response.ok) {
110
123
  const text = await response.text();
111
- handleResponse({ error: new Error(text || response.statusText || String(response.status)) });
124
+ handleResponse({
125
+ error: new Error(text || response.statusText || String(response.status)),
126
+ });
112
127
  return;
113
128
  }
114
129
 
@@ -159,11 +174,11 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
159
174
  };
160
175
 
161
176
  return (
162
- <div className={mx('flex flex-col h-full overflow-hidden', classNames)}>
177
+ <div className={mx('flex flex-col bs-full overflow-hidden', classNames)}>
163
178
  {/* TODO(burdon): Replace with Thread. */}
164
179
  <MessageThread ref={scrollerRef} state={state} result={result} history={history} />
165
180
  {/* TODO(burdon): Replace with Form based on the function's input schema. */}
166
- <Toolbar.Root classNames='p-2'>
181
+ <Toolbar.Root>
167
182
  <Input.Root>
168
183
  <Input.TextInput
169
184
  ref={inputRef}
@@ -174,12 +189,20 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
174
189
  onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}
175
190
  />
176
191
  </Input.Root>
177
- <Toolbar.Button onClick={() => handleRequest(input)}>
178
- <Icon icon='ph--play--regular' size={4} />
179
- </Toolbar.Button>
180
- <Toolbar.Button onClick={() => (state ? handleStop() : handleClear())}>
181
- <Icon icon={state ? 'ph--stop--regular' : 'ph--trash--regular'} size={4} />
182
- </Toolbar.Button>
192
+ <Toolbar.IconButton
193
+ icon='ph--play--regular'
194
+ size={4}
195
+ label='Execute'
196
+ iconOnly
197
+ onClick={() => handleRequest(input)}
198
+ />
199
+ <Toolbar.IconButton
200
+ icon={state ? 'ph--stop--regular' : 'ph--trash--regular'}
201
+ size={4}
202
+ label={state ? 'Stop' : 'Clear'}
203
+ iconOnly
204
+ onClick={() => (state ? handleStop() : handleClear())}
205
+ />
183
206
  </Toolbar.Root>
184
207
  </div>
185
208
  );
@@ -196,36 +219,38 @@ type MessageThreadProps = {
196
219
  const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
197
220
  ({ state, history, result }: MessageThreadProps, forwardedRef) => {
198
221
  return (
199
- <div ref={forwardedRef} className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>
200
- {history.map((message, i) => (
201
- <div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
202
- <div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
203
- <div className='overflow-auto'>
204
- <MessageItem message={message} />
205
- </div>
206
- </div>
207
- ))}
208
-
209
- {result?.length > 0 && (
210
- <div className='grid grid-cols-[2rem_1fr_2rem]'>
211
- <div className='p-1'>
212
- {(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
213
- <Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
214
- )}
222
+ <ScrollArea.Root orientation='vertical' classNames='bs-full' ref={forwardedRef}>
223
+ <ScrollArea.Viewport classNames='gap-6 p-2'>
224
+ {history.map((message, i) => (
225
+ <div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
226
+ <div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
227
+ <div className='overflow-auto'>
228
+ <MessageItem message={message} />
229
+ </div>
215
230
  </div>
216
- <div className='overflow-auto'>
217
- <MessageItem message={{ type: 'response', text: result }} />
231
+ ))}
232
+
233
+ {result?.length > 0 && (
234
+ <div className='grid grid-cols-[2rem_1fr_2rem]'>
235
+ <div className='p-1'>
236
+ {(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
237
+ <Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
238
+ )}
239
+ </div>
240
+ <div className='overflow-auto'>
241
+ <MessageItem message={{ type: 'response', text: result }} />
242
+ </div>
218
243
  </div>
219
- </div>
220
- )}
221
- </div>
244
+ )}
245
+ </ScrollArea.Viewport>
246
+ </ScrollArea.Root>
222
247
  );
223
248
  },
224
249
  );
225
250
 
226
251
  const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {
227
252
  const { type, text, data, error } = message;
228
- const wrapper = 'p-1 px-2 rounded-md bg-hoverSurface overflow-auto';
253
+ const wrapper = 'p-1 pli-2 rounded-md bg-hoverSurface overflow-auto';
229
254
  return (
230
255
  <div className={mx('flex', type === 'request' ? 'ml-[1rem] justify-end' : 'mr-[1rem]', classNames)}>
231
256
  {error && <div className={mx(wrapper, 'whitespace-pre', errorText)}>{String(error)}</div>}
@@ -237,7 +262,7 @@ const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message
237
262
  )}
238
263
 
239
264
  {data && (
240
- <SyntaxHighlighter language='json' className={mx(wrapper, 'px-8 py-2 text-xs')}>
265
+ <SyntaxHighlighter language='json' className={mx(wrapper, 'text-xs')}>
241
266
  {JSON.stringify(data, null, 2)}
242
267
  </SyntaxHighlighter>
243
268
  )}