@dxos/plugin-script 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f
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.
- package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs +845 -0
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs +113 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs.map +7 -0
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs +105 -0
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs +270 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs.map +7 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs +137 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs.map +7 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs +609 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs.map +7 -0
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs +557 -0
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6ZHHWU6S.mjs → chunk-WYR4QHPE.mjs} +9 -6
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/compiler-VPUVTFQD.mjs +161 -0
- package/dist/lib/browser/compiler-VPUVTFQD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +147 -109
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs +83 -0
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs +140 -0
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs.map +7 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs +36 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +10 -0
- package/dist/lib/browser/types/index.mjs +18 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs +846 -0
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs +610 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs +271 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AEB5TPEW.mjs → chunk-5HSJPAK7.mjs} +9 -6
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs +558 -0
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs +114 -0
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs +138 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs +107 -0
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs +162 -0
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +147 -109
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs +84 -0
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs +141 -0
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs.map +7 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs +37 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +11 -0
- package/dist/lib/node-esm/templates/index.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +19 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
- package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +7 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +4 -4
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +244 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +8 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +7 -8
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +246 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +5 -4
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/e2e/ai.test.d.ts +2 -0
- package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
- package/dist/types/src/e2e/deploy.test.d.ts +2 -0
- package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +18 -32
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +4 -4
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +6 -16
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts +7 -0
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/templates/anthropic.d.ts +8 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +16 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +16 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +4 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +4 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +54 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +3 -0
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +3 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +94 -176
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +100 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +40 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +12 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +6 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +7 -7
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +128 -83
- package/src/ScriptPlugin.tsx +59 -78
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +24 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +105 -106
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +119 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +33 -0
- package/src/compiler/compiler.ts +11 -4
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +47 -24
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -54
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +8 -5
- package/src/components/FrameContainer/frame.tsx +1 -1
- package/src/components/NotebookContainer.stories.tsx +87 -0
- package/src/components/NotebookContainer.tsx +271 -0
- package/src/components/NotebookStack/NotebookCell.tsx +217 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptContainer.tsx +52 -35
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +57 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +37 -33
- package/src/components/Settings/ScriptObjectSettings.tsx +151 -48
- package/src/components/Settings/ScriptPluginSettings.tsx +43 -48
- package/src/components/TestPanel/TestContainer.tsx +13 -7
- package/src/components/TestPanel/TestPanel.tsx +66 -41
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +86 -33
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +84 -81
- package/src/components/index.ts +3 -0
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +49 -42
- package/src/hooks/format.ts +9 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +21 -24
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -1
- package/src/meta.ts +9 -7
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/compute-graph.ts +230 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +451 -0
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +230 -0
- package/src/templates/data-generator.ts +11 -5
- package/src/templates/discord.ts +12 -4
- package/src/templates/email.ts +2 -2
- package/src/templates/forex-effect.ts +24 -25
- package/src/templates/forex.ts +9 -6
- package/src/templates/gmail.ts +35 -65
- package/src/templates/index.ts +26 -11
- package/src/templates/ping.ts +17 -0
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +42 -12
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +45 -0
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +9 -0
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +38 -61
- package/src/util/functions.ts +58 -25
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-RPPPWEEL.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs +0 -261
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs +0 -64
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs +0 -249
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs.map +0 -7
- package/dist/lib/browser/chunk-3FU4QZVP.mjs +0 -364
- package/dist/lib/browser/chunk-3FU4QZVP.mjs.map +0 -7
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs +0 -557
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-6ZHHWU6S.mjs.map +0 -7
- package/dist/lib/browser/chunk-LA66DQGU.mjs +0 -153
- package/dist/lib/browser/chunk-LA66DQGU.mjs.map +0 -7
- package/dist/lib/browser/chunk-QJH7I2UV.mjs +0 -233
- package/dist/lib/browser/chunk-QJH7I2UV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs +0 -40
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-YSQMXTYO.mjs +0 -15
- package/dist/lib/browser/chunk-YSQMXTYO.mjs.map +0 -7
- package/dist/lib/browser/compiler-W4BYJYTL.mjs +0 -82
- package/dist/lib/browser/compiler-W4BYJYTL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs +0 -90
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs.map +0 -7
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs +0 -105
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs.map +0 -7
- package/dist/lib/browser/settings-Z22D6JVJ.mjs +0 -24
- package/dist/lib/browser/settings-Z22D6JVJ.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -13
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs +0 -33
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs +0 -278
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs +0 -80
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs +0 -265
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs.map +0 -7
- package/dist/lib/node/chunk-AU2FOE26.cjs +0 -369
- package/dist/lib/node/chunk-AU2FOE26.cjs.map +0 -7
- package/dist/lib/node/chunk-BUOBOT3V.cjs +0 -179
- package/dist/lib/node/chunk-BUOBOT3V.cjs.map +0 -7
- package/dist/lib/node/chunk-HCRW6T3G.cjs +0 -60
- package/dist/lib/node/chunk-HCRW6T3G.cjs.map +0 -7
- package/dist/lib/node/chunk-OSBMUJ4T.cjs +0 -580
- package/dist/lib/node/chunk-OSBMUJ4T.cjs.map +0 -7
- package/dist/lib/node/chunk-QG2X6J74.cjs +0 -52
- package/dist/lib/node/chunk-QG2X6J74.cjs.map +0 -7
- package/dist/lib/node/chunk-YO5W2IPQ.cjs +0 -251
- package/dist/lib/node/chunk-YO5W2IPQ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZEV3VARQ.cjs +0 -34
- package/dist/lib/node/chunk-ZEV3VARQ.cjs.map +0 -7
- package/dist/lib/node/compiler-TFSJRLL4.cjs +0 -104
- package/dist/lib/node/compiler-TFSJRLL4.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -225
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs +0 -100
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-EUKPDFU3.cjs +0 -120
- package/dist/lib/node/react-surface-EUKPDFU3.cjs.map +0 -7
- package/dist/lib/node/settings-WO53FLYZ.cjs +0 -38
- package/dist/lib/node/settings-WO53FLYZ.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -34
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-IA4CH6WZ.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs +0 -262
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs +0 -65
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs +0 -16
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AEB5TPEW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs +0 -558
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs +0 -234
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs +0 -154
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs +0 -41
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs +0 -365
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs +0 -83
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs +0 -91
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs +0 -106
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs.map +0 -7
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs +0 -25
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -14
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/templates/echo.d.ts +0 -6
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -40
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -64
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -80
- package/src/capabilities/react-surface.tsx +0 -89
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -47
- package/src/templates/echo.ts +0 -8
- package/src/types.ts +0 -42
- /package/dist/lib/browser/{DeploymentDialog-RPPPWEEL.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
- /package/dist/lib/browser/{types.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-IA4CH6WZ.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types.mjs.map → browser/templates/index.mjs.map} +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Cause from 'effect/Cause';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Exit from 'effect/Exit';
|
|
9
|
+
import type * as Types from 'effect/Types';
|
|
10
|
+
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
11
|
+
|
|
12
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
13
|
+
import { Agent } from '@dxos/assistant-toolkit';
|
|
14
|
+
import { Blueprint, Prompt } from '@dxos/blueprints';
|
|
15
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
16
|
+
import { QueryBuilder } from '@dxos/echo-query';
|
|
17
|
+
import { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';
|
|
18
|
+
import { invariant } from '@dxos/invariant';
|
|
19
|
+
import { log } from '@dxos/log';
|
|
20
|
+
import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
|
|
21
|
+
import { Graph } from '@dxos/plugin-explorer/types';
|
|
22
|
+
import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
23
|
+
import { Layout } from '@dxos/react-ui';
|
|
24
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
25
|
+
import { Text, View } from '@dxos/schema';
|
|
26
|
+
import { isNonNullable } from '@dxos/util';
|
|
27
|
+
|
|
28
|
+
import { meta } from '../meta';
|
|
29
|
+
import { ComputeGraph } from '../notebook';
|
|
30
|
+
import { type Notebook } from '../types';
|
|
31
|
+
|
|
32
|
+
import { NotebookMenu, NotebookStack, type NotebookStackProps } from './NotebookStack';
|
|
33
|
+
import { type TypescriptEditorProps } from './TypescriptEditor';
|
|
34
|
+
|
|
35
|
+
const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/markdown'];
|
|
36
|
+
|
|
37
|
+
// TODO(burdon): Support calling named deployed functions (as with sheet).
|
|
38
|
+
|
|
39
|
+
export type NotebookContainerProps = SurfaceComponentProps<Notebook.Notebook, Pick<TypescriptEditorProps, 'env'>>;
|
|
40
|
+
|
|
41
|
+
export const NotebookContainer = ({ role, subject: notebook, env }: NotebookContainerProps) => {
|
|
42
|
+
const { t } = useTranslation(meta.id);
|
|
43
|
+
const registry = useContext(RegistryContext);
|
|
44
|
+
const db = notebook && Obj.getDatabase(notebook);
|
|
45
|
+
const attendableId = notebook ? Obj.getDXN(notebook).toString() : '';
|
|
46
|
+
const { hasAttention } = useAttention(attendableId);
|
|
47
|
+
|
|
48
|
+
// TODO(burdon): Consolidate execution and state (with graph).
|
|
49
|
+
// Generalize ComputeGraph evaluation function (using effects).
|
|
50
|
+
const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [notebook, registry]);
|
|
51
|
+
|
|
52
|
+
const [queryValues, setQueryValues] = useState<Record<string, any>>({});
|
|
53
|
+
const handleExecQueries = useCallback(async () => {
|
|
54
|
+
invariant(db);
|
|
55
|
+
|
|
56
|
+
const builder = new QueryBuilder();
|
|
57
|
+
for (const cell of notebook?.cells ?? []) {
|
|
58
|
+
if (cell.type === 'query') {
|
|
59
|
+
if (cell.source?.target) {
|
|
60
|
+
const source = cell.source.target.content;
|
|
61
|
+
const { name, filter } = builder.build(source);
|
|
62
|
+
if (filter) {
|
|
63
|
+
const ast = Query.select(filter).ast;
|
|
64
|
+
const graph = cell.graph?.target;
|
|
65
|
+
if (!graph) {
|
|
66
|
+
const { view } = await View.makeFromDatabase({ db });
|
|
67
|
+
const newGraph = Graph.make({ query: { ast }, view });
|
|
68
|
+
Obj.change(notebook!, (n) => {
|
|
69
|
+
const c = n.cells.find((c) => c.id === cell.id);
|
|
70
|
+
if (c) {
|
|
71
|
+
c.graph = Ref.make(newGraph);
|
|
72
|
+
c.name = name;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
Obj.change(graph, (g) => {
|
|
77
|
+
g.query.ast = ast as Obj.Mutable<typeof ast>;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (cell.name && cell.graph?.target) {
|
|
84
|
+
const graph = Obj.getSnapshot(cell.graph?.target);
|
|
85
|
+
const query = Query.fromAst(graph.query.ast);
|
|
86
|
+
const objects = await db.query(query).run();
|
|
87
|
+
const objectIds = objects?.map((obj) => obj.id);
|
|
88
|
+
setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [db, notebook, graph]);
|
|
93
|
+
|
|
94
|
+
const [promptResults, setPromptResults] = useState<Record<string, string>>({});
|
|
95
|
+
const handleExecPrompts = useComputeRuntimeCallback(
|
|
96
|
+
db?.spaceId,
|
|
97
|
+
Effect.fnUntraced(function* () {
|
|
98
|
+
invariant(graph);
|
|
99
|
+
|
|
100
|
+
const prompts =
|
|
101
|
+
notebook?.cells
|
|
102
|
+
.filter((cell) => cell.type === 'prompt')
|
|
103
|
+
.map((cell) => cell.prompt)
|
|
104
|
+
.filter(isNonNullable) ?? [];
|
|
105
|
+
|
|
106
|
+
for (const prompt of prompts) {
|
|
107
|
+
yield* runPrompt({
|
|
108
|
+
prompt,
|
|
109
|
+
input: { ...queryValues, ...graph.getValuesByName() },
|
|
110
|
+
onResult: (result) =>
|
|
111
|
+
setPromptResults((prev) => ({
|
|
112
|
+
...prev,
|
|
113
|
+
[prompt.dxn.toString()]: result,
|
|
114
|
+
})),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
[notebook, graph, queryValues],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// TODO(burdon): Cache values in context (preserve when switched).
|
|
122
|
+
const handleCompute = useCallback(async () => {
|
|
123
|
+
// TODO(burdon): Generalize executors (dependencies).
|
|
124
|
+
await graph?.evaluate();
|
|
125
|
+
await handleExecQueries();
|
|
126
|
+
await handleExecPrompts();
|
|
127
|
+
}, [graph, handleExecQueries, handleExecPrompts]);
|
|
128
|
+
|
|
129
|
+
const handleRearrange = useCallback<NonNullable<NotebookStackProps['onRearrange']>>(
|
|
130
|
+
(source, target) => {
|
|
131
|
+
invariant(notebook);
|
|
132
|
+
const from = notebook.cells.findIndex((cell) => cell.id === source.id);
|
|
133
|
+
const to = notebook.cells.findIndex((cell) => cell.id === target.id);
|
|
134
|
+
if (from != null && to != null) {
|
|
135
|
+
Obj.change(notebook, (n) => {
|
|
136
|
+
const cell = n.cells.splice(from, 1)[0];
|
|
137
|
+
if (cell) {
|
|
138
|
+
n.cells.splice(to, 0, cell);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[notebook],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(
|
|
147
|
+
async (type, after) => {
|
|
148
|
+
invariant(notebook);
|
|
149
|
+
const cell: Types.Mutable<Notebook.Cell> = { id: crypto.randomUUID(), type };
|
|
150
|
+
switch (type) {
|
|
151
|
+
case 'markdown':
|
|
152
|
+
case 'script':
|
|
153
|
+
case 'query': {
|
|
154
|
+
cell.source = Ref.make(Text.make());
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
case 'prompt': {
|
|
159
|
+
if (db) {
|
|
160
|
+
const objects = await db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
|
|
161
|
+
const blueprints = objects
|
|
162
|
+
.filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key))
|
|
163
|
+
.map((blueprint) => Ref.make(blueprint));
|
|
164
|
+
cell.prompt = Ref.make(Prompt.make({ instructions: '', blueprints }));
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;
|
|
171
|
+
Obj.change(notebook, (n) => {
|
|
172
|
+
n.cells.splice(idx, 0, cell);
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
[db, notebook],
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(
|
|
179
|
+
(id) => {
|
|
180
|
+
invariant(notebook);
|
|
181
|
+
const idx = notebook.cells.findIndex((cell) => cell.id === id);
|
|
182
|
+
if (idx !== -1) {
|
|
183
|
+
Obj.change(notebook, (n) => {
|
|
184
|
+
n.cells.splice(idx, 1);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
[notebook],
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<Layout.Main role={role} toolbar>
|
|
193
|
+
<Toolbar.Root disabled={!hasAttention} textBlockWidth>
|
|
194
|
+
<DropdownMenu.Root>
|
|
195
|
+
<DropdownMenu.Trigger asChild>
|
|
196
|
+
<IconButton icon='ph--plus--regular' iconOnly label={t('notebook cell insert label')} />
|
|
197
|
+
</DropdownMenu.Trigger>
|
|
198
|
+
<NotebookMenu onCellInsert={handleCellInsert} />
|
|
199
|
+
</DropdownMenu.Root>
|
|
200
|
+
<Toolbar.IconButton
|
|
201
|
+
icon='ph--play--fill'
|
|
202
|
+
iconOnly
|
|
203
|
+
label={t('compute label')}
|
|
204
|
+
classNames='text-green-500'
|
|
205
|
+
onClick={handleCompute}
|
|
206
|
+
/>
|
|
207
|
+
</Toolbar.Root>
|
|
208
|
+
<div role='none' className='flex bs-full overflow-hidden -mis-[1px] -mie-[1px]'>
|
|
209
|
+
<NotebookStack
|
|
210
|
+
classNames='container-max-width border-l border-r border-subduedSeparator'
|
|
211
|
+
db={db}
|
|
212
|
+
notebook={notebook}
|
|
213
|
+
graph={graph}
|
|
214
|
+
env={env}
|
|
215
|
+
promptResults={promptResults}
|
|
216
|
+
onRearrange={handleRearrange}
|
|
217
|
+
onCellInsert={handleCellInsert}
|
|
218
|
+
onCellDelete={handleCellDelete}
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
</Layout.Main>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export default NotebookContainer;
|
|
226
|
+
|
|
227
|
+
// TODO(wittjosiah): Factor out. Copied from PromptArticle in plugin-assistant.
|
|
228
|
+
const runPrompt = Effect.fn(function* ({
|
|
229
|
+
prompt,
|
|
230
|
+
input,
|
|
231
|
+
onResult,
|
|
232
|
+
}: {
|
|
233
|
+
prompt: Ref.Ref<Prompt.Prompt>;
|
|
234
|
+
input: Record<string, any>;
|
|
235
|
+
onResult: (result: string) => void;
|
|
236
|
+
}) {
|
|
237
|
+
const inputData: FunctionDefinition.Input<typeof Agent.prompt> = {
|
|
238
|
+
prompt,
|
|
239
|
+
input,
|
|
240
|
+
};
|
|
241
|
+
const tracer = yield* TracingService;
|
|
242
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
243
|
+
target: undefined,
|
|
244
|
+
payload: {
|
|
245
|
+
data: {},
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Invoke the function.
|
|
250
|
+
const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
|
|
251
|
+
Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),
|
|
252
|
+
Effect.exit,
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
Exit.match(result, {
|
|
256
|
+
onFailure: (cause) => {
|
|
257
|
+
const error = Cause.prettyErrors(cause)[0];
|
|
258
|
+
log.error(error.message, error.cause ?? error.stack);
|
|
259
|
+
onResult(error.message);
|
|
260
|
+
},
|
|
261
|
+
onSuccess: (result: any) => {
|
|
262
|
+
onResult(result.note);
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
yield* tracer.traceInvocationEnd({
|
|
267
|
+
trace,
|
|
268
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
269
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type Database, Obj } from '@dxos/echo';
|
|
9
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { TemplateEditor } from '@dxos/plugin-assistant';
|
|
12
|
+
import { useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
14
|
+
import { EditorContent, type EditorContentProps } from '@dxos/react-ui-editor';
|
|
15
|
+
import {
|
|
16
|
+
type BasicExtensionsOptions,
|
|
17
|
+
createBasicExtensions,
|
|
18
|
+
createDataExtensions,
|
|
19
|
+
createMarkdownExtensions,
|
|
20
|
+
createThemeExtensions,
|
|
21
|
+
decorateMarkdown,
|
|
22
|
+
} from '@dxos/ui-editor';
|
|
23
|
+
import { mx } from '@dxos/ui-theme';
|
|
24
|
+
import { isNonNullable } from '@dxos/util';
|
|
25
|
+
|
|
26
|
+
import { meta } from '../../meta';
|
|
27
|
+
import { type ComputeGraph } from '../../notebook';
|
|
28
|
+
import { type Notebook } from '../../types';
|
|
29
|
+
import { TypescriptEditor, type TypescriptEditorProps } from '../TypescriptEditor';
|
|
30
|
+
|
|
31
|
+
import { type NotebookMenuProps } from './NotebookMenu';
|
|
32
|
+
|
|
33
|
+
const editorStyles = 'p-2 pis-3';
|
|
34
|
+
const valueStyles = 'p-1 pis-3';
|
|
35
|
+
|
|
36
|
+
export type NotebookCellProps = {
|
|
37
|
+
db?: Database.Database;
|
|
38
|
+
graph?: ComputeGraph;
|
|
39
|
+
dragging?: boolean;
|
|
40
|
+
cell: Notebook.Cell;
|
|
41
|
+
promptResults?: Record<string, string>;
|
|
42
|
+
} & (Pick<NotebookMenuProps, 'onCellInsert' | 'onCellDelete'> & Pick<TypescriptEditorProps, 'env'>);
|
|
43
|
+
|
|
44
|
+
// TODO(burdon): Show evaluation errors.
|
|
45
|
+
export const NotebookCell = ({ db, graph, dragging, cell, promptResults, env }: NotebookCellProps) => {
|
|
46
|
+
const { t } = useTranslation(meta.id);
|
|
47
|
+
|
|
48
|
+
const extensions = useMemo(() => {
|
|
49
|
+
return cell.source?.target
|
|
50
|
+
? [
|
|
51
|
+
createDataExtensions({
|
|
52
|
+
id: cell.id,
|
|
53
|
+
text: createDocAccessor(cell.source.target, ['content']),
|
|
54
|
+
}),
|
|
55
|
+
].filter(isNonNullable)
|
|
56
|
+
: [];
|
|
57
|
+
}, [cell.source?.target]);
|
|
58
|
+
|
|
59
|
+
const explorerGraph = cell.graph?.target;
|
|
60
|
+
|
|
61
|
+
const handleQueryChange = useCallback<NonNullable<QueryEditorProps['onChange']>>(
|
|
62
|
+
(value: string) => {
|
|
63
|
+
invariant(cell.source?.target);
|
|
64
|
+
Obj.change(cell.source.target, (s) => {
|
|
65
|
+
s.content = value;
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
[cell],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
switch (cell.type) {
|
|
72
|
+
case 'markdown':
|
|
73
|
+
if (!cell.source?.target) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<NotebookTextEditor
|
|
79
|
+
id={cell.id}
|
|
80
|
+
classNames={editorStyles}
|
|
81
|
+
initialValue={cell.source.target.content}
|
|
82
|
+
extensions={extensions}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
case 'script':
|
|
87
|
+
if (!cell.source?.target) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<TypescriptEditor
|
|
94
|
+
id={cell.id}
|
|
95
|
+
role='section'
|
|
96
|
+
classNames={editorStyles}
|
|
97
|
+
initialValue={cell.source.target.content}
|
|
98
|
+
extensions={extensions}
|
|
99
|
+
env={env}
|
|
100
|
+
options={{
|
|
101
|
+
placeholder: t('notebook cell placeholder'),
|
|
102
|
+
highlightActiveLine: false,
|
|
103
|
+
lineNumbers: false,
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
<NotebookCellValue cell={cell} graph={graph} />
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
case 'query':
|
|
111
|
+
if (!cell.source?.target) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// TODO(burdon): Remove app-framework deps (via render prop).
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
className={mx('bs-full overflow-hidden grid', explorerGraph && !dragging && 'grid-rows-[min-content_1fr]')}
|
|
119
|
+
>
|
|
120
|
+
<QueryEditor
|
|
121
|
+
id={cell.id}
|
|
122
|
+
classNames={[editorStyles, 'border-be border-subduedSeparator']}
|
|
123
|
+
db={db}
|
|
124
|
+
value={cell.source.target.content}
|
|
125
|
+
onChange={handleQueryChange}
|
|
126
|
+
/>
|
|
127
|
+
{explorerGraph && !dragging && <Surface.Surface role='section' limit={1} data={{ subject: explorerGraph }} />}
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// TODO(burdon): Use streaming response from Chat.
|
|
132
|
+
case 'prompt':
|
|
133
|
+
if (!cell.prompt?.target) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<>
|
|
139
|
+
<TemplateEditor
|
|
140
|
+
id={cell.id}
|
|
141
|
+
template={cell.prompt.target.instructions}
|
|
142
|
+
lineNumbers={false}
|
|
143
|
+
classNames={editorStyles}
|
|
144
|
+
/>
|
|
145
|
+
<NotebookPromptResult cell={cell} promptResults={promptResults} />
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
155
|
+
const name = graph?.getExpressions()[cell.id]?.name;
|
|
156
|
+
const value = graph?.getValue(cell.id);
|
|
157
|
+
if (value == null) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div
|
|
163
|
+
className={mx(
|
|
164
|
+
'flex is-full bg-groupSurface border-bs border-subduedSeparator text-description font-mono',
|
|
165
|
+
valueStyles,
|
|
166
|
+
)}
|
|
167
|
+
>
|
|
168
|
+
{name && (
|
|
169
|
+
<>
|
|
170
|
+
<span className='text-successText'>{name}</span>
|
|
171
|
+
<span className='text-description'> = </span>
|
|
172
|
+
</>
|
|
173
|
+
)}
|
|
174
|
+
<span>{value}</span>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const NotebookPromptResult = ({ cell, promptResults }: NotebookCellProps) => {
|
|
180
|
+
if (!cell.prompt) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const value = promptResults?.[cell.prompt.dxn.toString()];
|
|
185
|
+
if (value == null) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div className={mx('flex is-full bg-groupSurface text-description border-bs border-subduedSeparator', valueStyles)}>
|
|
191
|
+
<NotebookTextEditor readOnly value={value} />
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const NotebookTextEditor = ({
|
|
197
|
+
extensions: extensionsProp,
|
|
198
|
+
readOnly,
|
|
199
|
+
...props
|
|
200
|
+
}: EditorContentProps & Pick<BasicExtensionsOptions, 'readOnly'>) => {
|
|
201
|
+
const { t } = useTranslation(meta.id);
|
|
202
|
+
const { themeMode } = useThemeContext();
|
|
203
|
+
const extensions = useMemo(() => {
|
|
204
|
+
return [
|
|
205
|
+
createBasicExtensions({
|
|
206
|
+
placeholder: t('notebook markdown placeholder'),
|
|
207
|
+
readOnly,
|
|
208
|
+
}),
|
|
209
|
+
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
210
|
+
createMarkdownExtensions(),
|
|
211
|
+
decorateMarkdown(),
|
|
212
|
+
extensionsProp,
|
|
213
|
+
].filter(isNonNullable);
|
|
214
|
+
}, [extensionsProp]);
|
|
215
|
+
|
|
216
|
+
return <EditorContent {...props} extensions={extensions} selectionEnd />;
|
|
217
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { DropdownMenu, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
import { meta } from '../../meta';
|
|
10
|
+
import { type Notebook } from '../../types';
|
|
11
|
+
|
|
12
|
+
export type NotebookMenuProps = {
|
|
13
|
+
cell?: Notebook.Cell;
|
|
14
|
+
onCellInsert?: (type: Notebook.CellType, after: string | undefined) => void;
|
|
15
|
+
onCellDelete?: (id: string) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// TODO(burdon): Better way to organize menu?
|
|
19
|
+
export const NotebookMenu = ({ cell, onCellInsert, onCellDelete }: NotebookMenuProps) => {
|
|
20
|
+
const { t } = useTranslation(meta.id);
|
|
21
|
+
return (
|
|
22
|
+
<DropdownMenu.Portal>
|
|
23
|
+
<DropdownMenu.Content>
|
|
24
|
+
<DropdownMenu.Viewport>
|
|
25
|
+
<DropdownMenu.Item onClick={() => onCellInsert?.('script', cell?.id)}>
|
|
26
|
+
{t('notebook cell insert script label')}
|
|
27
|
+
</DropdownMenu.Item>
|
|
28
|
+
<DropdownMenu.Item onClick={() => onCellInsert?.('prompt', cell?.id)}>
|
|
29
|
+
{t('notebook cell insert prompt label')}
|
|
30
|
+
</DropdownMenu.Item>
|
|
31
|
+
<DropdownMenu.Item onClick={() => onCellInsert?.('query', cell?.id)}>
|
|
32
|
+
{t('notebook cell insert query label')}
|
|
33
|
+
</DropdownMenu.Item>
|
|
34
|
+
<DropdownMenu.Item onClick={() => onCellInsert?.('markdown', cell?.id)}>
|
|
35
|
+
{t('notebook cell insert markdown label')}
|
|
36
|
+
</DropdownMenu.Item>
|
|
37
|
+
{cell && onCellDelete && (
|
|
38
|
+
<DropdownMenu.Item onClick={() => onCellDelete?.(cell.id)}>
|
|
39
|
+
{t('notebook cell delete label')}
|
|
40
|
+
</DropdownMenu.Item>
|
|
41
|
+
)}
|
|
42
|
+
</DropdownMenu.Viewport>
|
|
43
|
+
<DropdownMenu.Arrow />
|
|
44
|
+
</DropdownMenu.Content>
|
|
45
|
+
</DropdownMenu.Portal>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { AutomationPlugin } from '@dxos/plugin-automation';
|
|
11
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
13
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
14
|
+
|
|
15
|
+
import { createNotebook } from '../../testing';
|
|
16
|
+
import { translations } from '../../translations';
|
|
17
|
+
|
|
18
|
+
import { NotebookStack } from './NotebookStack';
|
|
19
|
+
|
|
20
|
+
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
21
|
+
const NotebookStackStory = () => {
|
|
22
|
+
const notebook = useMemo(() => createNotebook(), []);
|
|
23
|
+
return <NotebookStack notebook={notebook} />;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const meta = {
|
|
27
|
+
title: 'plugins/plugin-script/NotebookStack',
|
|
28
|
+
component: NotebookStackStory,
|
|
29
|
+
decorators: [
|
|
30
|
+
withTheme(),
|
|
31
|
+
withLayout({ layout: 'column', classNames: 'is-proseMaxWidth' }),
|
|
32
|
+
withPluginManager({
|
|
33
|
+
plugins: [
|
|
34
|
+
...corePlugins(),
|
|
35
|
+
ClientPlugin({
|
|
36
|
+
onClientInitialized: ({ client }) =>
|
|
37
|
+
Effect.gen(function* () {
|
|
38
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
39
|
+
yield* Effect.promise(() => client.spaces.waitUntilReady());
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
AutomationPlugin(),
|
|
43
|
+
],
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
parameters: {
|
|
47
|
+
translations,
|
|
48
|
+
},
|
|
49
|
+
} satisfies Meta<typeof NotebookStackStory>;
|
|
50
|
+
|
|
51
|
+
export default meta;
|
|
52
|
+
|
|
53
|
+
type Story = StoryObj<typeof meta>;
|
|
54
|
+
|
|
55
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { DropdownMenu, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { Stack, StackItem, type StackProps } from '@dxos/react-ui-stack';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
|
+
import { type Notebook } from '../../types';
|
|
12
|
+
import { type TypescriptEditorProps } from '../TypescriptEditor';
|
|
13
|
+
|
|
14
|
+
import { NotebookCell, type NotebookCellProps } from './NotebookCell';
|
|
15
|
+
import { NotebookMenu } from './NotebookMenu';
|
|
16
|
+
|
|
17
|
+
const minSectionHeight = 'min-bs-[16rem]';
|
|
18
|
+
|
|
19
|
+
export type NotebookStackProps = ThemedClassName<
|
|
20
|
+
{
|
|
21
|
+
notebook?: Notebook.Notebook;
|
|
22
|
+
onRearrange?: StackProps['onRearrange'];
|
|
23
|
+
} & (Pick<NotebookSectionProps, 'db' | 'graph' | 'promptResults' | 'onCellInsert' | 'onCellDelete'> &
|
|
24
|
+
Pick<TypescriptEditorProps, 'env'>)
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Option for narrow rail (with compact buttons that align with first button in toolbar).
|
|
28
|
+
export const NotebookStack = ({ classNames, notebook, onRearrange, ...props }: NotebookStackProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Stack classNames={classNames} orientation='vertical' size='contain' rail onRearrange={onRearrange}>
|
|
31
|
+
{notebook?.cells.map((cell, i) => (
|
|
32
|
+
<NotebookSection key={i} cell={cell} {...props} />
|
|
33
|
+
))}
|
|
34
|
+
</Stack>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type NotebookSectionProps = NotebookCellProps;
|
|
39
|
+
|
|
40
|
+
const NotebookSection = ({
|
|
41
|
+
cell,
|
|
42
|
+
db,
|
|
43
|
+
env,
|
|
44
|
+
promptResults,
|
|
45
|
+
onCellInsert,
|
|
46
|
+
onCellDelete,
|
|
47
|
+
...props
|
|
48
|
+
}: NotebookSectionProps) => {
|
|
49
|
+
const { t } = useTranslation(meta.id);
|
|
50
|
+
const resizable = cell.type === 'query';
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<StackItem.Root role='section' item={cell} draggable classNames={resizable && minSectionHeight}>
|
|
54
|
+
<StackItem.Heading classNames='bs-full p-1 justify-between attention-surface'>
|
|
55
|
+
<StackItem.DragHandle asChild>
|
|
56
|
+
<IconButton variant='ghost' icon='ph--dots-six-vertical--regular' iconOnly label='Drag handle' />
|
|
57
|
+
</StackItem.DragHandle>
|
|
58
|
+
<DropdownMenu.Root>
|
|
59
|
+
<DropdownMenu.Trigger asChild>
|
|
60
|
+
<IconButton
|
|
61
|
+
variant='ghost'
|
|
62
|
+
icon='ph--dots-three--regular'
|
|
63
|
+
iconOnly
|
|
64
|
+
label={t('notebook cell insert label')}
|
|
65
|
+
/>
|
|
66
|
+
</DropdownMenu.Trigger>
|
|
67
|
+
<NotebookMenu cell={cell} onCellInsert={onCellInsert} onCellDelete={onCellDelete} />
|
|
68
|
+
</DropdownMenu.Root>
|
|
69
|
+
{resizable && <StackItem.ResizeHandle />}
|
|
70
|
+
</StackItem.Heading>
|
|
71
|
+
|
|
72
|
+
{/* TODO(burdon): Move drag preview to outer stack (uniformly). */}
|
|
73
|
+
<StackItem.DragPreview>
|
|
74
|
+
{({ item: cell }) => (
|
|
75
|
+
<StackItem.Content classNames='overflow-visible bg-groupSurface border border-subduedSeparator'>
|
|
76
|
+
<NotebookCell db={db} cell={cell} env={env} dragging />
|
|
77
|
+
</StackItem.Content>
|
|
78
|
+
)}
|
|
79
|
+
</StackItem.DragPreview>
|
|
80
|
+
|
|
81
|
+
<StackItem.Content classNames='overflow-visible'>
|
|
82
|
+
<NotebookCell db={db} cell={cell} env={env} promptResults={promptResults} {...props} />
|
|
83
|
+
</StackItem.Content>
|
|
84
|
+
</StackItem.Root>
|
|
85
|
+
);
|
|
86
|
+
};
|