@dxos/plugin-script 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
- package/dist/lib/browser/{NotebookContainer-LVGRPFY3.mjs → NotebookContainer-UQ4I24R6.mjs} +357 -195
- 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-ST3ACVUC.mjs → chunk-4N5TLXEJ.mjs} +29 -12
- 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-J5LGTIGS.mjs.map +7 -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-EZVXV6DA.mjs → chunk-WYR4QHPE.mjs} +7 -2
- 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 +103 -137
- 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 +2 -1
- package/dist/lib/browser/types/index.mjs +12 -7
- 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-QY5NJGJI.mjs → NotebookContainer-DQGZ6QHI.mjs} +357 -195
- 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-OG2SIKHE.mjs → chunk-5HSJPAK7.mjs} +7 -2
- 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-2GVTWESW.mjs → chunk-V37R7KB5.mjs} +29 -12
- 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 +103 -137
- 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 +2 -1
- package/dist/lib/node-esm/types/index.mjs +12 -7
- 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 +2 -2
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +4 -6
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.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 +3 -5
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -244
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +4 -3
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +5 -4
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- 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 +5 -6
- 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 +5 -4
- 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 +4 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
- 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 +3 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- 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 +15 -30
- 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 +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- 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 +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/index.d.ts +1 -1
- package/dist/types/src/notebook/index.d.ts.map +1 -1
- 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/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/index.d.ts +12 -3
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +1 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -18
- package/dist/types/src/testing/data.d.ts.map +1 -1
- 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 +4 -3
- 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 +30 -56
- package/dist/types/src/types/actions.d.ts.map +1 -1
- 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 +4 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- 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 +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +3 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +114 -82
- package/src/ScriptPlugin.tsx +45 -87
- 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} +97 -95
- 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 +10 -3
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +33 -24
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +38 -41
- package/src/components/FrameContainer/FrameContainer.tsx +6 -4
- package/src/components/NotebookContainer.stories.tsx +60 -5
- package/src/components/NotebookContainer.tsx +179 -32
- package/src/components/NotebookStack/NotebookCell.tsx +84 -84
- package/src/components/NotebookStack/NotebookStack.stories.tsx +32 -9
- package/src/components/NotebookStack/NotebookStack.tsx +13 -6
- 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 +49 -34
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +42 -19
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +25 -28
- package/src/components/Settings/ScriptObjectSettings.tsx +55 -32
- package/src/components/Settings/ScriptPluginSettings.tsx +19 -14
- package/src/components/TestPanel/TestContainer.tsx +7 -7
- package/src/components/TestPanel/TestPanel.tsx +60 -35
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +14 -9
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -73
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +40 -32
- package/src/hooks/format.ts +7 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +20 -24
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +1 -1
- package/src/meta.ts +8 -4
- package/src/notebook/{notebook.test.ts → compute-graph.test.ts} +31 -19
- package/src/notebook/{notebook.ts → compute-graph.ts} +65 -18
- package/src/notebook/eval.ts +1 -1
- package/src/notebook/index.ts +1 -1
- 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 +1 -1
- package/src/templates/forex-effect.ts +22 -27
- package/src/templates/forex.ts +7 -6
- package/src/templates/gmail.ts +1 -2
- package/src/templates/index.ts +18 -5
- package/src/templates/ping.ts +14 -5
- package/src/testing/data.ts +34 -9
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +4 -3
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +18 -26
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +4 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +30 -40
- package/src/util/functions.ts +32 -28
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-65TWT6S5.mjs +0 -13
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs +0 -65
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
- package/dist/lib/browser/chunk-5CYLWXRH.mjs +0 -89
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-75LH4EUR.mjs +0 -326
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7DXDICD.mjs +0 -282
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs +0 -646
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO2O7W6J.mjs +0 -254
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6M34EUC.mjs +0 -112
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +0 -7
- package/dist/lib/browser/chunk-NM4WQS4F.mjs +0 -153
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +0 -7
- package/dist/lib/browser/chunk-OKXN2N7M.mjs +0 -15
- package/dist/lib/browser/chunk-OKXN2N7M.mjs.map +0 -7
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +0 -7
- package/dist/lib/browser/compiler-G2N2CG63.mjs +0 -98
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs +0 -105
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-76SDTUYG.mjs +0 -127
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +0 -7
- package/dist/lib/browser/settings-ERFKVNUK.mjs +0 -25
- package/dist/lib/browser/settings-ERFKVNUK.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs +0 -66
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4X375PGY.mjs +0 -90
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs +0 -327
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs +0 -154
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs +0 -16
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs +0 -647
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +0 -114
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs +0 -283
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs +0 -255
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs +0 -99
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs +0 -106
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs +0 -128
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +0 -7
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs +0 -26
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +0 -7
- 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/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-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/notebook/notebook.d.ts +0 -35
- package/dist/types/src/notebook/notebook.d.ts.map +0 -1
- package/dist/types/src/notebook/notebook.test.d.ts +0 -2
- package/dist/types/src/notebook/notebook.test.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/types/schema.d.ts +0 -61
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -65
- package/src/capabilities/blueprint-definition.ts +0 -30
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -34
- package/src/capabilities/intent-resolver.ts +0 -87
- package/src/capabilities/react-surface.tsx +0 -102
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -49
- package/src/types/schema.ts +0 -48
- /package/dist/lib/browser/{DeploymentDialog-65TWT6S5.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → browser/blueprints/index.mjs.map} +0 -0
|
@@ -2,15 +2,28 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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';
|
|
6
11
|
|
|
7
|
-
import {
|
|
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';
|
|
8
18
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
19
|
+
import { log } from '@dxos/log';
|
|
20
|
+
import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
|
|
21
|
+
import { Graph } from '@dxos/plugin-explorer/types';
|
|
11
22
|
import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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';
|
|
14
27
|
|
|
15
28
|
import { meta } from '../meta';
|
|
16
29
|
import { ComputeGraph } from '../notebook';
|
|
@@ -19,22 +32,99 @@ import { type Notebook } from '../types';
|
|
|
19
32
|
import { NotebookMenu, NotebookStack, type NotebookStackProps } from './NotebookStack';
|
|
20
33
|
import { type TypescriptEditorProps } from './TypescriptEditor';
|
|
21
34
|
|
|
35
|
+
const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/markdown'];
|
|
36
|
+
|
|
22
37
|
// TODO(burdon): Support calling named deployed functions (as with sheet).
|
|
23
38
|
|
|
24
|
-
export type NotebookContainerProps =
|
|
25
|
-
role?: string;
|
|
26
|
-
notebook?: Notebook.Notebook;
|
|
27
|
-
} & Pick<TypescriptEditorProps, 'env'>;
|
|
39
|
+
export type NotebookContainerProps = SurfaceComponentProps<Notebook.Notebook, Pick<TypescriptEditorProps, 'env'>>;
|
|
28
40
|
|
|
29
|
-
export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) => {
|
|
41
|
+
export const NotebookContainer = ({ role, subject: notebook, env }: NotebookContainerProps) => {
|
|
30
42
|
const { t } = useTranslation(meta.id);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
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
|
+
);
|
|
33
120
|
|
|
34
121
|
// TODO(burdon): Cache values in context (preserve when switched).
|
|
35
|
-
const handleCompute = useCallback(() => {
|
|
36
|
-
|
|
37
|
-
|
|
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]);
|
|
38
128
|
|
|
39
129
|
const handleRearrange = useCallback<NonNullable<NotebookStackProps['onRearrange']>>(
|
|
40
130
|
(source, target) => {
|
|
@@ -42,39 +132,47 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
42
132
|
const from = notebook.cells.findIndex((cell) => cell.id === source.id);
|
|
43
133
|
const to = notebook.cells.findIndex((cell) => cell.id === target.id);
|
|
44
134
|
if (from != null && to != null) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
});
|
|
49
141
|
}
|
|
50
142
|
},
|
|
51
143
|
[notebook],
|
|
52
144
|
);
|
|
53
145
|
|
|
54
146
|
const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(
|
|
55
|
-
(type, after) => {
|
|
147
|
+
async (type, after) => {
|
|
56
148
|
invariant(notebook);
|
|
57
|
-
const cell: Notebook.Cell = { id: crypto.randomUUID(), type };
|
|
149
|
+
const cell: Types.Mutable<Notebook.Cell> = { id: crypto.randomUUID(), type };
|
|
58
150
|
switch (type) {
|
|
59
151
|
case 'markdown':
|
|
60
152
|
case 'script':
|
|
61
153
|
case 'query': {
|
|
62
|
-
cell.
|
|
154
|
+
cell.source = Ref.make(Text.make());
|
|
63
155
|
break;
|
|
64
156
|
}
|
|
65
157
|
|
|
66
158
|
case 'prompt': {
|
|
67
|
-
if (
|
|
68
|
-
|
|
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 }));
|
|
69
165
|
}
|
|
70
166
|
break;
|
|
71
167
|
}
|
|
72
168
|
}
|
|
73
169
|
|
|
74
170
|
const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;
|
|
75
|
-
|
|
171
|
+
Obj.change(notebook, (n) => {
|
|
172
|
+
n.cells.splice(idx, 0, cell);
|
|
173
|
+
});
|
|
76
174
|
},
|
|
77
|
-
[
|
|
175
|
+
[db, notebook],
|
|
78
176
|
);
|
|
79
177
|
|
|
80
178
|
const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(
|
|
@@ -82,15 +180,17 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
82
180
|
invariant(notebook);
|
|
83
181
|
const idx = notebook.cells.findIndex((cell) => cell.id === id);
|
|
84
182
|
if (idx !== -1) {
|
|
85
|
-
|
|
183
|
+
Obj.change(notebook, (n) => {
|
|
184
|
+
n.cells.splice(idx, 1);
|
|
185
|
+
});
|
|
86
186
|
}
|
|
87
187
|
},
|
|
88
188
|
[notebook],
|
|
89
189
|
);
|
|
90
190
|
|
|
91
191
|
return (
|
|
92
|
-
<
|
|
93
|
-
<Toolbar.Root textBlockWidth>
|
|
192
|
+
<Layout.Main role={role} toolbar>
|
|
193
|
+
<Toolbar.Root disabled={!hasAttention} textBlockWidth>
|
|
94
194
|
<DropdownMenu.Root>
|
|
95
195
|
<DropdownMenu.Trigger asChild>
|
|
96
196
|
<IconButton icon='ph--plus--regular' iconOnly label={t('notebook cell insert label')} />
|
|
@@ -108,17 +208,64 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
108
208
|
<div role='none' className='flex bs-full overflow-hidden -mis-[1px] -mie-[1px]'>
|
|
109
209
|
<NotebookStack
|
|
110
210
|
classNames='container-max-width border-l border-r border-subduedSeparator'
|
|
111
|
-
|
|
211
|
+
db={db}
|
|
112
212
|
notebook={notebook}
|
|
113
213
|
graph={graph}
|
|
114
214
|
env={env}
|
|
215
|
+
promptResults={promptResults}
|
|
115
216
|
onRearrange={handleRearrange}
|
|
116
217
|
onCellInsert={handleCellInsert}
|
|
117
218
|
onCellDelete={handleCellDelete}
|
|
118
219
|
/>
|
|
119
220
|
</div>
|
|
120
|
-
</
|
|
221
|
+
</Layout.Main>
|
|
121
222
|
);
|
|
122
223
|
};
|
|
123
224
|
|
|
124
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
|
+
});
|
|
@@ -4,27 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type Database, Obj } from '@dxos/echo';
|
|
9
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { Graph } from '@dxos/plugin-explorer/types';
|
|
14
|
-
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
15
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
16
|
-
import { useAsyncEffect, useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { TemplateEditor } from '@dxos/plugin-assistant';
|
|
12
|
+
import { useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
17
13
|
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
14
|
+
import { EditorContent, type EditorContentProps } from '@dxos/react-ui-editor';
|
|
18
15
|
import {
|
|
19
|
-
|
|
20
|
-
type EditorProps,
|
|
16
|
+
type BasicExtensionsOptions,
|
|
21
17
|
createBasicExtensions,
|
|
22
18
|
createDataExtensions,
|
|
23
19
|
createMarkdownExtensions,
|
|
24
20
|
createThemeExtensions,
|
|
25
21
|
decorateMarkdown,
|
|
26
|
-
} from '@dxos/
|
|
27
|
-
import { mx } from '@dxos/
|
|
22
|
+
} from '@dxos/ui-editor';
|
|
23
|
+
import { mx } from '@dxos/ui-theme';
|
|
28
24
|
import { isNonNullable } from '@dxos/util';
|
|
29
25
|
|
|
30
26
|
import { meta } from '../../meta';
|
|
@@ -38,86 +34,57 @@ const editorStyles = 'p-2 pis-3';
|
|
|
38
34
|
const valueStyles = 'p-1 pis-3';
|
|
39
35
|
|
|
40
36
|
export type NotebookCellProps = {
|
|
41
|
-
|
|
37
|
+
db?: Database.Database;
|
|
42
38
|
graph?: ComputeGraph;
|
|
43
39
|
dragging?: boolean;
|
|
44
40
|
cell: Notebook.Cell;
|
|
41
|
+
promptResults?: Record<string, string>;
|
|
45
42
|
} & (Pick<NotebookMenuProps, 'onCellInsert' | 'onCellDelete'> & Pick<TypescriptEditorProps, 'env'>);
|
|
46
43
|
|
|
47
|
-
// TODO(burdon):
|
|
48
|
-
export const NotebookCell = ({
|
|
44
|
+
// TODO(burdon): Show evaluation errors.
|
|
45
|
+
export const NotebookCell = ({ db, graph, dragging, cell, promptResults, env }: NotebookCellProps) => {
|
|
49
46
|
const { t } = useTranslation(meta.id);
|
|
50
47
|
|
|
51
|
-
//
|
|
52
|
-
// Common.
|
|
53
|
-
//
|
|
54
48
|
const extensions = useMemo(() => {
|
|
55
|
-
return cell.
|
|
56
|
-
? [
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
return cell.source?.target
|
|
50
|
+
? [
|
|
51
|
+
createDataExtensions({
|
|
52
|
+
id: cell.id,
|
|
53
|
+
text: createDocAccessor(cell.source.target, ['content']),
|
|
54
|
+
}),
|
|
55
|
+
].filter(isNonNullable)
|
|
59
56
|
: [];
|
|
60
|
-
}, [cell.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Query.
|
|
64
|
-
//
|
|
65
|
-
const view = cell.view?.target;
|
|
66
|
-
const builder = useMemo(() => new QueryBuilder(), []);
|
|
67
|
-
useAsyncEffect(async () => {
|
|
68
|
-
if (!space || !cell.script?.target) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (cell.type === 'query') {
|
|
73
|
-
const query = cell.script.target.content;
|
|
74
|
-
const filter = builder.build(query);
|
|
75
|
-
if (filter) {
|
|
76
|
-
const ast = Query.select(filter).ast;
|
|
77
|
-
const view = cell.view?.target;
|
|
78
|
-
if (!view) {
|
|
79
|
-
const graph = Graph.make({ query: { ast } });
|
|
80
|
-
const { view } = await Graph.makeView({ space, presentation: graph });
|
|
81
|
-
cell.view = Ref.make(view);
|
|
82
|
-
} else {
|
|
83
|
-
view.query.ast = ast;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, [space, builder, cell, cell.script?.target?.content]);
|
|
57
|
+
}, [cell.source?.target]);
|
|
58
|
+
|
|
59
|
+
const explorerGraph = cell.graph?.target;
|
|
88
60
|
|
|
89
61
|
const handleQueryChange = useCallback<NonNullable<QueryEditorProps['onChange']>>(
|
|
90
62
|
(value: string) => {
|
|
91
|
-
invariant(cell.
|
|
92
|
-
cell.
|
|
63
|
+
invariant(cell.source?.target);
|
|
64
|
+
Obj.change(cell.source.target, (s) => {
|
|
65
|
+
s.content = value;
|
|
66
|
+
});
|
|
93
67
|
},
|
|
94
68
|
[cell],
|
|
95
69
|
);
|
|
96
70
|
|
|
97
|
-
//
|
|
98
|
-
// Prompt.
|
|
99
|
-
// TODO(burdon): Add values to context or system message (via blueprint?).
|
|
100
|
-
//
|
|
101
|
-
const services = useChatServices({ space, chat: cell.chat?.target });
|
|
102
|
-
const processor = useChatProcessor({ chat: cell.chat?.target, services });
|
|
103
|
-
|
|
104
71
|
switch (cell.type) {
|
|
105
72
|
case 'markdown':
|
|
106
|
-
if (!cell.
|
|
73
|
+
if (!cell.source?.target) {
|
|
107
74
|
return null;
|
|
108
75
|
}
|
|
109
76
|
|
|
110
77
|
return (
|
|
111
|
-
<
|
|
78
|
+
<NotebookTextEditor
|
|
112
79
|
id={cell.id}
|
|
113
80
|
classNames={editorStyles}
|
|
114
|
-
initialValue={cell.
|
|
81
|
+
initialValue={cell.source.target.content}
|
|
115
82
|
extensions={extensions}
|
|
116
83
|
/>
|
|
117
84
|
);
|
|
118
85
|
|
|
119
86
|
case 'script':
|
|
120
|
-
if (!cell.
|
|
87
|
+
if (!cell.source?.target) {
|
|
121
88
|
return null;
|
|
122
89
|
}
|
|
123
90
|
|
|
@@ -127,7 +94,7 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
127
94
|
id={cell.id}
|
|
128
95
|
role='section'
|
|
129
96
|
classNames={editorStyles}
|
|
130
|
-
initialValue={cell.
|
|
97
|
+
initialValue={cell.source.target.content}
|
|
131
98
|
extensions={extensions}
|
|
132
99
|
env={env}
|
|
133
100
|
options={{
|
|
@@ -141,33 +108,42 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
141
108
|
);
|
|
142
109
|
|
|
143
110
|
case 'query':
|
|
144
|
-
if (!cell.
|
|
111
|
+
if (!cell.source?.target) {
|
|
145
112
|
return null;
|
|
146
113
|
}
|
|
147
114
|
|
|
115
|
+
// TODO(burdon): Remove app-framework deps (via render prop).
|
|
148
116
|
return (
|
|
149
|
-
<div
|
|
117
|
+
<div
|
|
118
|
+
className={mx('bs-full overflow-hidden grid', explorerGraph && !dragging && 'grid-rows-[min-content_1fr]')}
|
|
119
|
+
>
|
|
150
120
|
<QueryEditor
|
|
151
121
|
id={cell.id}
|
|
152
|
-
classNames={[editorStyles, 'border-
|
|
153
|
-
db={
|
|
154
|
-
value={cell.
|
|
122
|
+
classNames={[editorStyles, 'border-be border-subduedSeparator']}
|
|
123
|
+
db={db}
|
|
124
|
+
value={cell.source.target.content}
|
|
155
125
|
onChange={handleQueryChange}
|
|
156
126
|
/>
|
|
157
|
-
{
|
|
127
|
+
{explorerGraph && !dragging && <Surface.Surface role='section' limit={1} data={{ subject: explorerGraph }} />}
|
|
158
128
|
</div>
|
|
159
129
|
);
|
|
160
130
|
|
|
131
|
+
// TODO(burdon): Use streaming response from Chat.
|
|
161
132
|
case 'prompt':
|
|
162
|
-
if (!cell.
|
|
133
|
+
if (!cell.prompt?.target) {
|
|
163
134
|
return null;
|
|
164
135
|
}
|
|
165
136
|
|
|
166
137
|
return (
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
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
|
+
</>
|
|
171
147
|
);
|
|
172
148
|
|
|
173
149
|
default:
|
|
@@ -176,8 +152,8 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
176
152
|
};
|
|
177
153
|
|
|
178
154
|
const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
179
|
-
const name = graph?.
|
|
180
|
-
const value = graph?.
|
|
155
|
+
const name = graph?.getExpressions()[cell.id]?.name;
|
|
156
|
+
const value = graph?.getValue(cell.id);
|
|
181
157
|
if (value == null) {
|
|
182
158
|
return null;
|
|
183
159
|
}
|
|
@@ -185,7 +161,7 @@ const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
|
185
161
|
return (
|
|
186
162
|
<div
|
|
187
163
|
className={mx(
|
|
188
|
-
'flex is-full bg-groupSurface border-
|
|
164
|
+
'flex is-full bg-groupSurface border-bs border-subduedSeparator text-description font-mono',
|
|
189
165
|
valueStyles,
|
|
190
166
|
)}
|
|
191
167
|
>
|
|
@@ -200,18 +176,42 @@ const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
|
200
176
|
);
|
|
201
177
|
};
|
|
202
178
|
|
|
203
|
-
const
|
|
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'>) => {
|
|
204
201
|
const { t } = useTranslation(meta.id);
|
|
205
202
|
const { themeMode } = useThemeContext();
|
|
206
203
|
const extensions = useMemo(() => {
|
|
207
204
|
return [
|
|
208
|
-
createBasicExtensions({
|
|
205
|
+
createBasicExtensions({
|
|
206
|
+
placeholder: t('notebook markdown placeholder'),
|
|
207
|
+
readOnly,
|
|
208
|
+
}),
|
|
209
209
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
210
210
|
createMarkdownExtensions(),
|
|
211
211
|
decorateMarkdown(),
|
|
212
|
-
|
|
212
|
+
extensionsProp,
|
|
213
213
|
].filter(isNonNullable);
|
|
214
|
-
}, [
|
|
214
|
+
}, [extensionsProp]);
|
|
215
215
|
|
|
216
|
-
return <
|
|
216
|
+
return <EditorContent {...props} extensions={extensions} selectionEnd />;
|
|
217
217
|
};
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
6
8
|
|
|
7
|
-
import {
|
|
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';
|
|
8
13
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
14
|
|
|
10
15
|
import { createNotebook } from '../../testing';
|
|
@@ -12,21 +17,39 @@ import { translations } from '../../translations';
|
|
|
12
17
|
|
|
13
18
|
import { NotebookStack } from './NotebookStack';
|
|
14
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
|
+
|
|
15
26
|
const meta = {
|
|
16
27
|
title: 'plugins/plugin-script/NotebookStack',
|
|
17
|
-
component:
|
|
18
|
-
decorators: [
|
|
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
|
+
],
|
|
19
46
|
parameters: {
|
|
20
47
|
translations,
|
|
21
48
|
},
|
|
22
|
-
} satisfies Meta<typeof
|
|
49
|
+
} satisfies Meta<typeof NotebookStackStory>;
|
|
23
50
|
|
|
24
51
|
export default meta;
|
|
25
52
|
|
|
26
53
|
type Story = StoryObj<typeof meta>;
|
|
27
54
|
|
|
28
|
-
export const Default: Story = {
|
|
29
|
-
args: {
|
|
30
|
-
notebook: createNotebook(),
|
|
31
|
-
},
|
|
32
|
-
};
|
|
55
|
+
export const Default: Story = {};
|
|
@@ -20,7 +20,7 @@ export type NotebookStackProps = ThemedClassName<
|
|
|
20
20
|
{
|
|
21
21
|
notebook?: Notebook.Notebook;
|
|
22
22
|
onRearrange?: StackProps['onRearrange'];
|
|
23
|
-
} & (Pick<NotebookSectionProps, '
|
|
23
|
+
} & (Pick<NotebookSectionProps, 'db' | 'graph' | 'promptResults' | 'onCellInsert' | 'onCellDelete'> &
|
|
24
24
|
Pick<TypescriptEditorProps, 'env'>)
|
|
25
25
|
>;
|
|
26
26
|
|
|
@@ -37,11 +37,18 @@ export const NotebookStack = ({ classNames, notebook, onRearrange, ...props }: N
|
|
|
37
37
|
|
|
38
38
|
type NotebookSectionProps = NotebookCellProps;
|
|
39
39
|
|
|
40
|
-
const NotebookSection = ({
|
|
40
|
+
const NotebookSection = ({
|
|
41
|
+
cell,
|
|
42
|
+
db,
|
|
43
|
+
env,
|
|
44
|
+
promptResults,
|
|
45
|
+
onCellInsert,
|
|
46
|
+
onCellDelete,
|
|
47
|
+
...props
|
|
48
|
+
}: NotebookSectionProps) => {
|
|
41
49
|
const { t } = useTranslation(meta.id);
|
|
42
|
-
const resizable = cell.type === 'query'
|
|
50
|
+
const resizable = cell.type === 'query';
|
|
43
51
|
|
|
44
|
-
// TOOD(burdon): Set size if no extrinsic size (provider).
|
|
45
52
|
return (
|
|
46
53
|
<StackItem.Root role='section' item={cell} draggable classNames={resizable && minSectionHeight}>
|
|
47
54
|
<StackItem.Heading classNames='bs-full p-1 justify-between attention-surface'>
|
|
@@ -66,13 +73,13 @@ const NotebookSection = ({ cell, space, env, onCellInsert, onCellDelete, ...prop
|
|
|
66
73
|
<StackItem.DragPreview>
|
|
67
74
|
{({ item: cell }) => (
|
|
68
75
|
<StackItem.Content classNames='overflow-visible bg-groupSurface border border-subduedSeparator'>
|
|
69
|
-
<NotebookCell
|
|
76
|
+
<NotebookCell db={db} cell={cell} env={env} dragging />
|
|
70
77
|
</StackItem.Content>
|
|
71
78
|
)}
|
|
72
79
|
</StackItem.DragPreview>
|
|
73
80
|
|
|
74
81
|
<StackItem.Content classNames='overflow-visible'>
|
|
75
|
-
<NotebookCell
|
|
82
|
+
<NotebookCell db={db} cell={cell} env={env} promptResults={promptResults} {...props} />
|
|
76
83
|
</StackItem.Content>
|
|
77
84
|
</StackItem.Root>
|
|
78
85
|
);
|