@dxos/plugin-script 0.8.4-main.67995b8 → 0.8.4-main.ae835ea
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-E5NXT4UQ.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs +817 -0
- package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs +148 -0
- package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-LEOPGBJD.mjs} +11 -9
- package/dist/lib/browser/app-graph-builder-LEOPGBJD.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +30 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-5S5YQNJZ.mjs +304 -0
- package/dist/lib/browser/chunk-5S5YQNJZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-A5K3TXYA.mjs} +29 -43
- package/dist/lib/browser/chunk-A5K3TXYA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
- package/dist/lib/browser/chunk-HCURXADW.mjs +102 -0
- package/dist/lib/browser/chunk-HCURXADW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-HHTOAI2J.mjs} +161 -72
- package/dist/lib/browser/chunk-HHTOAI2J.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-IQMYIWHG.mjs} +15 -15
- package/dist/lib/browser/chunk-IQMYIWHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-LI4P25M5.mjs +111 -0
- package/dist/lib/browser/chunk-LI4P25M5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-Q2DGRQRN.mjs} +75 -53
- package/dist/lib/browser/chunk-Q2DGRQRN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-Q4UY2COU.mjs} +9 -5
- package/dist/lib/browser/compiler-Q4UY2COU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +109 -44
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-S3H2SMUY.mjs → intent-resolver-AMMHATM7.mjs} +40 -24
- package/dist/lib/browser/intent-resolver-AMMHATM7.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-X4NATU6B.mjs} +43 -19
- package/dist/lib/browser/react-surface-X4NATU6B.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-6UXY7F7D.mjs} +10 -8
- package/dist/lib/browser/settings-6UXY7F7D.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +8 -4
- package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs +818 -0
- package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs +149 -0
- package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-XJ3MY5BM.mjs} +11 -9
- package/dist/lib/node-esm/app-graph-builder-XJ3MY5BM.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +31 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs +90 -0
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
- package/dist/lib/node-esm/chunk-EJLYOSD7.mjs +113 -0
- package/dist/lib/node-esm/chunk-EJLYOSD7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-GA27XSEY.mjs} +29 -43
- package/dist/lib/node-esm/chunk-GA27XSEY.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-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-N2XLVOFB.mjs +103 -0
- package/dist/lib/node-esm/chunk-N2XLVOFB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-O7HXE72S.mjs} +75 -53
- package/dist/lib/node-esm/chunk-O7HXE72S.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-OZ6LCME4.mjs} +161 -72
- package/dist/lib/node-esm/chunk-OZ6LCME4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TUGLYZDT.mjs +305 -0
- package/dist/lib/node-esm/chunk-TUGLYZDT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-UEGPBCSF.mjs} +15 -15
- package/dist/lib/node-esm/chunk-UEGPBCSF.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-I6A4KE6E.mjs} +9 -5
- package/dist/lib/node-esm/compiler-I6A4KE6E.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +109 -44
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-OHKNJFCC.mjs → intent-resolver-YKLZQR7U.mjs} +40 -24
- package/dist/lib/node-esm/intent-resolver-YKLZQR7U.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-LVGLBSTE.mjs} +43 -19
- package/dist/lib/node-esm/react-surface-LVGLBSTE.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-O4EZPUE3.mjs} +10 -8
- package/dist/lib/node-esm/settings-O4EZPUE3.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +8 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.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 +243 -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.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +10 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +251 -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 +245 -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/ScriptContainer.d.ts +4 -4
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +242 -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 +2 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -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 +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +17 -16
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +4 -14
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +45 -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/chess.d.ts.map +1 -1
- 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.map +1 -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 +43 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
- 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/translations.d.ts +30 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +31 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +54 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -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 +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 +82 -75
- package/src/ScriptPlugin.tsx +90 -71
- package/src/capabilities/app-graph-builder.ts +9 -8
- package/src/capabilities/artifact-definition.ts +7 -4
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +2 -1
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +21 -12
- package/src/capabilities/react-surface.tsx +28 -15
- package/src/capabilities/settings.ts +3 -3
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +39 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +3 -2
- package/src/components/NotebookContainer.stories.tsx +83 -0
- package/src/components/NotebookContainer.tsx +263 -0
- package/src/components/NotebookStack/NotebookCell.tsx +208 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +7 -6
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +33 -26
- package/src/components/Settings/ScriptObjectSettings.tsx +113 -33
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestContainer.tsx +4 -3
- package/src/components/TestPanel/TestPanel.tsx +7 -7
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +37 -34
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +23 -24
- package/src/hooks/format.ts +4 -4
- package/src/hooks/template.ts +6 -15
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +6 -5
- package/src/index.ts +1 -0
- package/src/meta.ts +7 -5
- package/src/notebook/compute-graph.test.ts +70 -0
- package/src/notebook/compute-graph.ts +206 -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/chess.ts +3 -1
- package/src/templates/data-generator.ts +9 -3
- package/src/templates/discord.ts +12 -4
- package/src/templates/forex-effect.ts +7 -3
- package/src/templates/forex.ts +3 -1
- package/src/templates/gmail.ts +33 -62
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +33 -7
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +27 -44
- package/src/util/functions.ts +36 -7
- package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -38
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -37
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-E5NXT4UQ.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
|
@@ -7,69 +7,82 @@ import React from 'react';
|
|
|
7
7
|
import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
|
|
8
8
|
import { InvocationTraceContainer } from '@dxos/devtools';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import {
|
|
10
|
+
import { Script } from '@dxos/functions';
|
|
11
11
|
import { SettingsStore } from '@dxos/local-storage';
|
|
12
12
|
import { getSpace } from '@dxos/react-client/echo';
|
|
13
13
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
14
14
|
import { type DataType } from '@dxos/schema';
|
|
15
15
|
|
|
16
|
-
import { ScriptCapabilities } from './capabilities';
|
|
17
16
|
import {
|
|
18
17
|
DEPLOYMENT_DIALOG,
|
|
19
18
|
DeploymentDialog,
|
|
19
|
+
NotebookContainer,
|
|
20
20
|
ScriptContainer,
|
|
21
|
-
ScriptPluginSettings,
|
|
22
21
|
ScriptObjectSettings,
|
|
22
|
+
ScriptPluginSettings,
|
|
23
23
|
ScriptProperties,
|
|
24
24
|
TestContainer,
|
|
25
25
|
} from '../components';
|
|
26
26
|
import { meta } from '../meta';
|
|
27
|
-
import { type
|
|
27
|
+
import { Notebook, type ScriptSettings } from '../types';
|
|
28
|
+
|
|
29
|
+
import { ScriptCapabilities } from './capabilities';
|
|
28
30
|
|
|
29
31
|
export default () =>
|
|
30
32
|
contributes(Capabilities.ReactSurface, [
|
|
31
33
|
createSurface({
|
|
32
34
|
id: `${meta.id}/plugin-settings`,
|
|
33
35
|
role: 'article',
|
|
34
|
-
filter: (data): data is { subject: SettingsStore<
|
|
36
|
+
filter: (data): data is { subject: SettingsStore<ScriptSettings> } =>
|
|
35
37
|
data.subject instanceof SettingsStore && data.subject.prefix === meta.id,
|
|
36
38
|
component: ({ data: { subject } }) => <ScriptPluginSettings settings={subject.value} />,
|
|
37
39
|
}),
|
|
38
40
|
createSurface({
|
|
39
|
-
id: `${meta.id}/article`,
|
|
40
|
-
role: 'article',
|
|
41
|
-
filter: (data): data is { subject:
|
|
41
|
+
id: `${meta.id}/script/article`,
|
|
42
|
+
role: ['article', 'section'],
|
|
43
|
+
filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
|
|
42
44
|
component: ({ data, role }) => {
|
|
43
45
|
const compiler = useCapability(ScriptCapabilities.Compiler);
|
|
44
46
|
// TODO(dmaretskyi): Since settings store is not reactive, this would break on the script plugin being enabled without a page reload.
|
|
45
|
-
const settings = useCapability(Capabilities.SettingsStore).getStore<
|
|
47
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<ScriptSettings>(meta.id)?.value;
|
|
46
48
|
return <ScriptContainer role={role} script={data.subject} settings={settings} env={compiler.environment} />;
|
|
47
49
|
},
|
|
48
50
|
}),
|
|
51
|
+
createSurface({
|
|
52
|
+
id: `${meta.id}/notebook/article`,
|
|
53
|
+
role: 'article',
|
|
54
|
+
filter: (data): data is { subject: Notebook.Notebook } => Obj.instanceOf(Notebook.Notebook, data.subject),
|
|
55
|
+
component: ({ data, role }) => {
|
|
56
|
+
const compiler = useCapability(ScriptCapabilities.Compiler);
|
|
57
|
+
return <NotebookContainer role={role} notebook={data.subject} env={compiler.environment} />;
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
// TODO(burdon): Standardize PluginSettings vs ObjectSettings.
|
|
61
|
+
// TODO(burdon): Why is ScriptProperties different from ScriptObjectSettings?
|
|
49
62
|
createSurface({
|
|
50
63
|
id: `${meta.id}/companion/base-settings`,
|
|
51
64
|
role: 'base-object-settings',
|
|
52
|
-
filter: (data): data is { subject:
|
|
65
|
+
filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
|
|
53
66
|
component: ({ data }) => <ScriptProperties object={data.subject} />,
|
|
54
67
|
}),
|
|
55
68
|
createSurface({
|
|
56
69
|
id: `${meta.id}/companion/settings`,
|
|
57
70
|
role: 'object-settings',
|
|
58
|
-
filter: (data): data is { subject:
|
|
71
|
+
filter: (data): data is { subject: Script.Script } => Obj.instanceOf(Script.Script, data.subject),
|
|
59
72
|
component: ({ data }) => <ScriptObjectSettings object={data.subject} />,
|
|
60
73
|
}),
|
|
61
74
|
createSurface({
|
|
62
75
|
id: `${meta.id}/companion/execute`,
|
|
63
76
|
role: 'article',
|
|
64
|
-
filter: (data): data is { companionTo:
|
|
65
|
-
Obj.instanceOf(
|
|
77
|
+
filter: (data): data is { companionTo: Script.Script } =>
|
|
78
|
+
Obj.instanceOf(Script.Script, data.companionTo) && data.subject === 'execute',
|
|
66
79
|
component: ({ data, role }) => <TestContainer script={data.companionTo} role={role} />,
|
|
67
80
|
}),
|
|
68
81
|
createSurface({
|
|
69
82
|
id: `${meta.id}/companion/logs`,
|
|
70
83
|
role: 'article',
|
|
71
|
-
filter: (data): data is { companionTo:
|
|
72
|
-
Obj.instanceOf(
|
|
84
|
+
filter: (data): data is { companionTo: Script.Script } =>
|
|
85
|
+
Obj.instanceOf(Script.Script, data.companionTo) && data.subject === 'logs',
|
|
73
86
|
component: ({ data, role }) => {
|
|
74
87
|
const space = getSpace(data.companionTo);
|
|
75
88
|
return (
|
|
@@ -6,16 +6,16 @@ import { Capabilities, contributes } from '@dxos/app-framework';
|
|
|
6
6
|
import { live } from '@dxos/live-object';
|
|
7
7
|
|
|
8
8
|
import { meta } from '../meta';
|
|
9
|
-
import {
|
|
9
|
+
import { ScriptSettings } from '../types';
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
|
-
const settings = live(
|
|
12
|
+
const settings = live<ScriptSettings>({
|
|
13
13
|
editorInputMode: 'vscode',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
return contributes(Capabilities.Settings, {
|
|
17
17
|
prefix: meta.id,
|
|
18
|
-
schema:
|
|
18
|
+
schema: ScriptSettings,
|
|
19
19
|
value: settings,
|
|
20
20
|
});
|
|
21
21
|
};
|
package/src/compiler/compiler.ts
CHANGED
|
@@ -2,38 +2,57 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
8
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
10
12
|
import { Dialog } from '@dxos/react-ui';
|
|
11
|
-
import {
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
|
+
import { DataType } from '@dxos/schema';
|
|
12
15
|
|
|
13
16
|
import { translations } from '../../translations';
|
|
14
|
-
import { DeploymentDialog } from '../DeploymentDialog/DeploymentDialog';
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{ label: 'Script 1', templateId: 'template1' },
|
|
21
|
-
{ label: 'Script 2', templateId: 'template2' },
|
|
22
|
-
{ label: 'Script 3', templateId: 'template3' },
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
render: (args: any) => (
|
|
18
|
+
import { DeploymentDialog, type DeploymentDialogProps } from './DeploymentDialog';
|
|
19
|
+
|
|
20
|
+
const DefaultStory = (props: DeploymentDialogProps) => {
|
|
21
|
+
return (
|
|
26
22
|
<Dialog.Root defaultOpen={true}>
|
|
27
|
-
<DeploymentDialog {...
|
|
23
|
+
<DeploymentDialog {...props} />
|
|
28
24
|
</Dialog.Root>
|
|
29
|
-
)
|
|
25
|
+
);
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
const meta
|
|
28
|
+
const meta = {
|
|
33
29
|
title: 'plugins/plugin-script/DeploymentDialog',
|
|
34
30
|
component: DeploymentDialog,
|
|
31
|
+
render: DefaultStory,
|
|
35
32
|
parameters: { translations },
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
34
|
+
decorators: [
|
|
35
|
+
withTheme,
|
|
36
|
+
withPluginManager({
|
|
37
|
+
plugins: [IntentPlugin(), ClientPlugin({})],
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
38
41
|
|
|
39
42
|
export default meta;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<typeof meta>;
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
accessToken: Obj.make(DataType.AccessToken, {
|
|
49
|
+
source: 'example.com',
|
|
50
|
+
token: 'example-token',
|
|
51
|
+
}),
|
|
52
|
+
scriptTemplates: [
|
|
53
|
+
{ id: 't-1', name: 'Script 1', source: 'template1' },
|
|
54
|
+
{ id: 't-2', name: 'Script 2', source: 'template2' },
|
|
55
|
+
{ id: 't-3', name: 'Script 3', source: 'template3' },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { getSpace } from '@dxos/react-client/echo';
|
|
9
9
|
import { Button, Dialog, Icon, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type DataType } from '@dxos/schema';
|
|
11
11
|
|
|
12
12
|
import { useCreateAndDeployScriptTemplates } from '../../hooks/useCreateAndDeployScriptTemplates';
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
14
|
import { type Template } from '../../templates';
|
|
15
15
|
|
|
16
|
-
export const DEPLOYMENT_DIALOG = `${
|
|
16
|
+
export const DEPLOYMENT_DIALOG = `${meta.id}/deployment/dialog`;
|
|
17
17
|
|
|
18
18
|
// TODO(ZaymonFC):
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
19
|
+
// - Show activity and feedback to the user.
|
|
20
|
+
// - Only take an array of templateIds and get the name from the data.
|
|
21
|
+
// - Pending / onError states.
|
|
22
22
|
|
|
23
|
-
type DeploymentDialogProps = {
|
|
23
|
+
export type DeploymentDialogProps = {
|
|
24
24
|
accessToken: DataType.AccessToken;
|
|
25
25
|
scriptTemplates: Template[];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDialogProps) => {
|
|
29
|
-
const { t } = useTranslation(
|
|
29
|
+
const { t } = useTranslation(meta.id);
|
|
30
30
|
const space = useMemo(() => getSpace(accessToken), [accessToken]);
|
|
31
31
|
|
|
32
32
|
// TODO(ZaymonFC): Thinking further. All of this should get moved to intents to run async in the background.
|
|
@@ -41,12 +41,12 @@ export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDia
|
|
|
41
41
|
createIntent(LayoutAction.AddToast, {
|
|
42
42
|
part: 'toast',
|
|
43
43
|
subject: {
|
|
44
|
-
id: `${
|
|
44
|
+
id: `${meta.id}/deployment-success`,
|
|
45
45
|
icon: 'ph--check--regular',
|
|
46
46
|
duration: Infinity,
|
|
47
|
-
title: ['script deployment toast label', { ns:
|
|
48
|
-
description: ['script deployment toast description', { ns:
|
|
49
|
-
closeLabel: ['script deployment toast close label', { ns:
|
|
47
|
+
title: ['script deployment toast label', { ns: meta.id, count: scriptTemplates.length }],
|
|
48
|
+
description: ['script deployment toast description', { ns: meta.id, count: scriptTemplates.length }],
|
|
49
|
+
closeLabel: ['script deployment toast close label', { ns: meta.id, count: scriptTemplates.length }],
|
|
50
50
|
},
|
|
51
51
|
}),
|
|
52
52
|
);
|
|
@@ -58,18 +58,12 @@ export const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDia
|
|
|
58
58
|
createIntent(LayoutAction.AddToast, {
|
|
59
59
|
part: 'toast',
|
|
60
60
|
subject: {
|
|
61
|
-
id: `${
|
|
61
|
+
id: `${meta.id}/deployment-error`,
|
|
62
62
|
icon: 'ph--warning--regular',
|
|
63
63
|
duration: Infinity,
|
|
64
|
-
title: ['script deployment error toast label', { ns:
|
|
65
|
-
description: [
|
|
66
|
-
|
|
67
|
-
{ ns: SCRIPT_PLUGIN, count: scriptTemplates.length },
|
|
68
|
-
],
|
|
69
|
-
closeLabel: [
|
|
70
|
-
'script deployment error toast close label',
|
|
71
|
-
{ ns: SCRIPT_PLUGIN, count: scriptTemplates.length },
|
|
72
|
-
],
|
|
64
|
+
title: ['script deployment error toast label', { ns: meta.id, count: scriptTemplates.length }],
|
|
65
|
+
description: ['script deployment error toast description', { ns: meta.id, count: scriptTemplates.length }],
|
|
66
|
+
closeLabel: ['script deployment error toast close label', { ns: meta.id, count: scriptTemplates.length }],
|
|
73
67
|
},
|
|
74
68
|
}),
|
|
75
69
|
);
|
|
@@ -48,7 +48,8 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
|
|
|
48
48
|
// Encodes compiled code via URL.
|
|
49
49
|
invariant(result.sourceHash, 'Source hash is required.');
|
|
50
50
|
const sourceHash = Buffer.from(result.sourceHash).toString('hex');
|
|
51
|
-
const src =
|
|
51
|
+
const src =
|
|
52
|
+
'bundle' in result ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(result.bundle)}` : undefined;
|
|
52
53
|
|
|
53
54
|
return (
|
|
54
55
|
<>
|
|
@@ -68,7 +69,7 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
|
|
|
68
69
|
{
|
|
69
70
|
timestamp: result.timestamp,
|
|
70
71
|
sourceHash,
|
|
71
|
-
error: result.error,
|
|
72
|
+
error: 'error' in result ? result.error : undefined,
|
|
72
73
|
src,
|
|
73
74
|
},
|
|
74
75
|
undefined,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { SERVICES_CONFIG } from '@dxos/ai/testing';
|
|
9
|
+
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
10
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
11
|
+
import { Agent } from '@dxos/assistant-toolkit';
|
|
12
|
+
import { Filter } from '@dxos/echo';
|
|
13
|
+
import { Function, serializeFunction } from '@dxos/functions';
|
|
14
|
+
import { AssistantPlugin } from '@dxos/plugin-assistant';
|
|
15
|
+
import { AutomationPlugin } from '@dxos/plugin-automation';
|
|
16
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
17
|
+
import { ExplorerPlugin } from '@dxos/plugin-explorer';
|
|
18
|
+
import { Markdown, MarkdownPlugin } from '@dxos/plugin-markdown';
|
|
19
|
+
import { SpacePlugin } from '@dxos/plugin-space';
|
|
20
|
+
import { Config, useClient } from '@dxos/react-client';
|
|
21
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
22
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
23
|
+
import { DataTypes } from '@dxos/schema';
|
|
24
|
+
|
|
25
|
+
import { createNotebook } from '../testing';
|
|
26
|
+
import { translations } from '../translations';
|
|
27
|
+
import { Notebook } from '../types';
|
|
28
|
+
|
|
29
|
+
import { NotebookContainer } from './NotebookContainer';
|
|
30
|
+
|
|
31
|
+
const meta = {
|
|
32
|
+
title: 'plugins/plugin-script/NotebookContainer',
|
|
33
|
+
component: NotebookContainer,
|
|
34
|
+
render: (args) => {
|
|
35
|
+
const client = useClient();
|
|
36
|
+
const space = client.spaces.default;
|
|
37
|
+
const notebooks = useQuery(space?.db, Filter.type(Notebook.Notebook));
|
|
38
|
+
return <NotebookContainer {...args} notebook={notebooks[0]} />;
|
|
39
|
+
},
|
|
40
|
+
decorators: [
|
|
41
|
+
withTheme,
|
|
42
|
+
withLayout({ container: 'column', classNames: 'is-prose' }),
|
|
43
|
+
withPluginManager({
|
|
44
|
+
plugins: [
|
|
45
|
+
ClientPlugin({
|
|
46
|
+
// TODO(wittjosiah): ComputeRuntime requires edge to be configured or it will throw.
|
|
47
|
+
config: new Config({
|
|
48
|
+
runtime: {
|
|
49
|
+
services: SERVICES_CONFIG.REMOTE,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
types: [...DataTypes, Notebook.Notebook, Function.Function, Markdown.Document],
|
|
53
|
+
onClientInitialized: async ({ client }) => {
|
|
54
|
+
await client.halo.createIdentity();
|
|
55
|
+
await client.spaces.waitUntilReady();
|
|
56
|
+
const space = client.spaces.default;
|
|
57
|
+
await space.waitUntilReady();
|
|
58
|
+
|
|
59
|
+
space.db.add(createNotebook());
|
|
60
|
+
space.db.add(Markdown.makeDocument({ content: '# Hello World' }));
|
|
61
|
+
space.db.add(serializeFunction(Agent.prompt));
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
SpacePlugin({}),
|
|
65
|
+
SettingsPlugin(),
|
|
66
|
+
IntentPlugin(),
|
|
67
|
+
AssistantPlugin(),
|
|
68
|
+
AutomationPlugin(),
|
|
69
|
+
ExplorerPlugin(),
|
|
70
|
+
MarkdownPlugin(),
|
|
71
|
+
],
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
parameters: {
|
|
75
|
+
translations,
|
|
76
|
+
},
|
|
77
|
+
} satisfies Meta<typeof NotebookContainer>;
|
|
78
|
+
|
|
79
|
+
export default meta;
|
|
80
|
+
|
|
81
|
+
type Story = StoryObj<typeof meta>;
|
|
82
|
+
|
|
83
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Cause from 'effect/Cause';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Exit from 'effect/Exit';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Agent } from '@dxos/assistant-toolkit';
|
|
12
|
+
import { Blueprint, Prompt } from '@dxos/blueprints';
|
|
13
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
14
|
+
import { QueryBuilder } from '@dxos/echo-query';
|
|
15
|
+
import {
|
|
16
|
+
ComputeEventLogger,
|
|
17
|
+
type FunctionDefinition,
|
|
18
|
+
FunctionInvocationService,
|
|
19
|
+
InvocationTracer,
|
|
20
|
+
TracingService,
|
|
21
|
+
} from '@dxos/functions';
|
|
22
|
+
import { invariant } from '@dxos/invariant';
|
|
23
|
+
import { log } from '@dxos/log';
|
|
24
|
+
import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
|
|
25
|
+
import { Graph } from '@dxos/plugin-explorer/types';
|
|
26
|
+
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
27
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
28
|
+
import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
29
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
30
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
31
|
+
import { DataType } from '@dxos/schema';
|
|
32
|
+
import { isNonNullable } from '@dxos/util';
|
|
33
|
+
|
|
34
|
+
import { meta } from '../meta';
|
|
35
|
+
import { ComputeGraph } from '../notebook';
|
|
36
|
+
import { type Notebook } from '../types';
|
|
37
|
+
|
|
38
|
+
import { NotebookMenu, NotebookStack, type NotebookStackProps } from './NotebookStack';
|
|
39
|
+
import { type TypescriptEditorProps } from './TypescriptEditor';
|
|
40
|
+
|
|
41
|
+
const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/markdown'];
|
|
42
|
+
|
|
43
|
+
// TODO(burdon): Support calling named deployed functions (as with sheet).
|
|
44
|
+
|
|
45
|
+
export type NotebookContainerProps = {
|
|
46
|
+
role?: string;
|
|
47
|
+
notebook?: Notebook.Notebook;
|
|
48
|
+
} & Pick<TypescriptEditorProps, 'env'>;
|
|
49
|
+
|
|
50
|
+
export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) => {
|
|
51
|
+
const { t } = useTranslation(meta.id);
|
|
52
|
+
const space = getSpace(notebook);
|
|
53
|
+
const attendableId = fullyQualifiedId(notebook);
|
|
54
|
+
const { hasAttention } = useAttention(attendableId);
|
|
55
|
+
|
|
56
|
+
// TODO(burdon): Consolidate execution and state (with graph).
|
|
57
|
+
// Generalize ComputeGraph evaluation function (using effects).
|
|
58
|
+
const graph = useMemo(() => notebook && new ComputeGraph(notebook), [notebook]);
|
|
59
|
+
|
|
60
|
+
const [queryValues, setQueryValues] = useState<Record<string, any>>({});
|
|
61
|
+
const handleExecQueries = useCallback(async () => {
|
|
62
|
+
invariant(space);
|
|
63
|
+
|
|
64
|
+
const builder = new QueryBuilder();
|
|
65
|
+
for (const cell of notebook?.cells ?? []) {
|
|
66
|
+
if (cell.type === 'query') {
|
|
67
|
+
if (cell.source?.target) {
|
|
68
|
+
const source = cell.source.target.content;
|
|
69
|
+
const { name, filter } = builder.build(source);
|
|
70
|
+
if (filter) {
|
|
71
|
+
const ast = Query.select(filter).ast;
|
|
72
|
+
const view = cell.view?.target;
|
|
73
|
+
if (!view) {
|
|
74
|
+
const graph = Graph.make({ query: { ast } });
|
|
75
|
+
const { view } = await Graph.makeView({ space, presentation: graph });
|
|
76
|
+
cell.view = Ref.make(view);
|
|
77
|
+
cell.name = name;
|
|
78
|
+
} else {
|
|
79
|
+
view.query.ast = ast;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (cell.name && cell.view?.target) {
|
|
85
|
+
const view = Obj.getSnapshot(cell.view?.target);
|
|
86
|
+
const query = Query.fromAst(view.query.ast);
|
|
87
|
+
const result = await space?.db.query(query).run();
|
|
88
|
+
const objectIds = result?.objects?.map((obj) => obj.id);
|
|
89
|
+
setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, [space, notebook, graph]);
|
|
94
|
+
|
|
95
|
+
const [promptResults, setPromptResults] = useState<Record<string, string>>({});
|
|
96
|
+
const handleExecPrompts = useComputeRuntimeCallback(
|
|
97
|
+
space,
|
|
98
|
+
Effect.fnUntraced(function* () {
|
|
99
|
+
invariant(graph);
|
|
100
|
+
|
|
101
|
+
const prompts =
|
|
102
|
+
notebook?.cells
|
|
103
|
+
.filter((cell) => cell.type === 'prompt')
|
|
104
|
+
.map((cell) => cell.prompt)
|
|
105
|
+
.filter(isNonNullable) ?? [];
|
|
106
|
+
|
|
107
|
+
for (const prompt of prompts) {
|
|
108
|
+
yield* runPrompt({
|
|
109
|
+
prompt,
|
|
110
|
+
input: { ...queryValues, ...graph.valuesByName.value },
|
|
111
|
+
onResult: (result) => setPromptResults((prev) => ({ ...prev, [prompt.dxn.toString()]: result })),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
[notebook, graph, queryValues],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// TODO(burdon): Cache values in context (preserve when switched).
|
|
119
|
+
const handleCompute = useCallback(async () => {
|
|
120
|
+
// TODO(burdon): Generalize executors (dependencies).
|
|
121
|
+
await graph?.evaluate();
|
|
122
|
+
await handleExecQueries();
|
|
123
|
+
await handleExecPrompts();
|
|
124
|
+
}, [graph, handleExecQueries, handleExecPrompts]);
|
|
125
|
+
|
|
126
|
+
const handleRearrange = useCallback<NonNullable<NotebookStackProps['onRearrange']>>(
|
|
127
|
+
(source, target) => {
|
|
128
|
+
invariant(notebook);
|
|
129
|
+
const from = notebook.cells.findIndex((cell) => cell.id === source.id);
|
|
130
|
+
const to = notebook.cells.findIndex((cell) => cell.id === target.id);
|
|
131
|
+
if (from != null && to != null) {
|
|
132
|
+
const cell = notebook.cells.splice(from, 1)[0];
|
|
133
|
+
if (cell) {
|
|
134
|
+
notebook.cells.splice(to, 0, cell);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[notebook],
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(
|
|
142
|
+
async (type, after) => {
|
|
143
|
+
invariant(notebook);
|
|
144
|
+
const cell: Notebook.Cell = { id: crypto.randomUUID(), type };
|
|
145
|
+
switch (type) {
|
|
146
|
+
case 'markdown':
|
|
147
|
+
case 'script':
|
|
148
|
+
case 'query': {
|
|
149
|
+
cell.source = Ref.make(DataType.makeText());
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
case 'prompt': {
|
|
154
|
+
if (space) {
|
|
155
|
+
const result = await space.db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
|
|
156
|
+
const blueprints = result.objects
|
|
157
|
+
.filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key))
|
|
158
|
+
.map((blueprint) => Ref.make(blueprint));
|
|
159
|
+
cell.prompt = Ref.make(Prompt.make({ instructions: '', blueprints }));
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;
|
|
166
|
+
notebook.cells.splice(idx, 0, cell);
|
|
167
|
+
},
|
|
168
|
+
[space, notebook],
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(
|
|
172
|
+
(id) => {
|
|
173
|
+
invariant(notebook);
|
|
174
|
+
const idx = notebook.cells.findIndex((cell) => cell.id === id);
|
|
175
|
+
if (idx !== -1) {
|
|
176
|
+
notebook.cells.splice(idx, 1);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
[notebook],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<StackItem.Content toolbar>
|
|
184
|
+
<Toolbar.Root disabled={!hasAttention} textBlockWidth>
|
|
185
|
+
<DropdownMenu.Root>
|
|
186
|
+
<DropdownMenu.Trigger asChild>
|
|
187
|
+
<IconButton icon='ph--plus--regular' iconOnly label={t('notebook cell insert label')} />
|
|
188
|
+
</DropdownMenu.Trigger>
|
|
189
|
+
<NotebookMenu onCellInsert={handleCellInsert} />
|
|
190
|
+
</DropdownMenu.Root>
|
|
191
|
+
<Toolbar.IconButton
|
|
192
|
+
icon='ph--play--fill'
|
|
193
|
+
iconOnly
|
|
194
|
+
label={t('compute label')}
|
|
195
|
+
classNames='text-green-500'
|
|
196
|
+
onClick={handleCompute}
|
|
197
|
+
/>
|
|
198
|
+
</Toolbar.Root>
|
|
199
|
+
<div role='none' className='flex bs-full overflow-hidden -mis-[1px] -mie-[1px]'>
|
|
200
|
+
<NotebookStack
|
|
201
|
+
classNames='container-max-width border-l border-r border-subduedSeparator'
|
|
202
|
+
space={space}
|
|
203
|
+
notebook={notebook}
|
|
204
|
+
graph={graph}
|
|
205
|
+
env={env}
|
|
206
|
+
promptResults={promptResults}
|
|
207
|
+
onRearrange={handleRearrange}
|
|
208
|
+
onCellInsert={handleCellInsert}
|
|
209
|
+
onCellDelete={handleCellDelete}
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
</StackItem.Content>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export default NotebookContainer;
|
|
217
|
+
|
|
218
|
+
// TODO(wittjosiah): Factor out. Copied from PromptContainer in stories-assistant.
|
|
219
|
+
const runPrompt = Effect.fn(function* ({
|
|
220
|
+
prompt,
|
|
221
|
+
input,
|
|
222
|
+
onResult,
|
|
223
|
+
}: {
|
|
224
|
+
prompt: Ref.Ref<Prompt.Prompt>;
|
|
225
|
+
input: Record<string, any>;
|
|
226
|
+
onResult: (result: string) => void;
|
|
227
|
+
}) {
|
|
228
|
+
const inputData: FunctionDefinition.Input<typeof Agent.prompt> = { prompt, input };
|
|
229
|
+
const tracer = yield* InvocationTracer;
|
|
230
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
231
|
+
target: undefined,
|
|
232
|
+
payload: {
|
|
233
|
+
data: {},
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Invoke the function.
|
|
238
|
+
const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
|
|
239
|
+
Effect.provide(
|
|
240
|
+
ComputeEventLogger.layerFromTracing.pipe(
|
|
241
|
+
Layer.provideMerge(TracingService.layerQueue(trace.invocationTraceQueue)),
|
|
242
|
+
),
|
|
243
|
+
),
|
|
244
|
+
Effect.exit,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
Exit.match(result, {
|
|
248
|
+
onFailure: (cause) => {
|
|
249
|
+
const error = Cause.prettyErrors(cause)[0];
|
|
250
|
+
log.error(error.message, error.cause ?? error.stack);
|
|
251
|
+
onResult(error.message);
|
|
252
|
+
},
|
|
253
|
+
onSuccess: (result: any) => {
|
|
254
|
+
onResult(result.note);
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
yield* tracer.traceInvocationEnd({
|
|
259
|
+
trace,
|
|
260
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
261
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,
|
|
262
|
+
});
|
|
263
|
+
});
|