@dxos/plugin-script 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +15 -13
- package/dist/lib/neutral/DeploymentDialog-M3AFYQHC.mjs +114 -0
- package/dist/lib/neutral/DeploymentDialog-M3AFYQHC.mjs.map +7 -0
- package/dist/lib/{browser/NotebookContainer-LVGRPFY3.mjs → neutral/NotebookArticle-NV4AHOOS.mjs} +313 -233
- package/dist/lib/neutral/NotebookArticle-NV4AHOOS.mjs.map +7 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs +79 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.mjs +39 -0
- package/dist/lib/neutral/ScriptPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs +27 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs +31 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs.map +7 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs +297 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs.map +7 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs +44 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs +52 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +10 -0
- package/dist/lib/neutral/capabilities/index.mjs +21 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +17 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs +56 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4H6UOE5J.mjs +123 -0
- package/dist/lib/neutral/chunk-4H6UOE5J.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6XGGYOY2.mjs +36 -0
- package/dist/lib/neutral/chunk-6XGGYOY2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GD5SNDAA.mjs +8 -0
- package/dist/lib/neutral/chunk-GD5SNDAA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GYQPDUTK.mjs +105 -0
- package/dist/lib/neutral/chunk-GYQPDUTK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HJ4BY42S.mjs +8 -0
- package/dist/lib/neutral/chunk-HJ4BY42S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs +150 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WEIU4BCS.mjs +52 -0
- package/dist/lib/neutral/chunk-WEIU4BCS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Y3O3YZSE.mjs +345 -0
- package/dist/lib/neutral/chunk-Y3O3YZSE.mjs.map +7 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs +101 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +722 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +17 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-32MZYUAA.mjs +46 -0
- package/dist/lib/neutral/create-32MZYUAA.mjs.map +7 -0
- package/dist/lib/neutral/create-object-FZM5ASWM.mjs +45 -0
- package/dist/lib/neutral/create-object-FZM5ASWM.mjs.map +7 -0
- package/dist/lib/neutral/create-script-6HWJMXMD.mjs +45 -0
- package/dist/lib/neutral/create-script-6HWJMXMD.mjs.map +7 -0
- package/dist/lib/neutral/delete-475DHFZO.mjs +21 -0
- package/dist/lib/neutral/delete-475DHFZO.mjs.map +7 -0
- package/dist/lib/neutral/deploy-VMPGXUR2.mjs +63 -0
- package/dist/lib/neutral/deploy-VMPGXUR2.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +369 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +41 -0
- package/dist/lib/neutral/inspect-invocations-IHZDHE27.mjs +59 -0
- package/dist/lib/neutral/inspect-invocations-IHZDHE27.mjs.map +7 -0
- package/dist/lib/neutral/install-function-UJWJMTZY.mjs +49 -0
- package/dist/lib/neutral/install-function-UJWJMTZY.mjs.map +7 -0
- package/dist/lib/neutral/invoke-M7J6LRZB.mjs +32 -0
- package/dist/lib/neutral/invoke-M7J6LRZB.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/operation-handler-MOATB7ZI.mjs +18 -0
- package/dist/lib/neutral/operation-handler-MOATB7ZI.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/query-deployed-functions-MZUBGLJG.mjs +34 -0
- package/dist/lib/neutral/query-deployed-functions-MZUBGLJG.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-DPK6XU2Y.mjs +120 -0
- package/dist/lib/neutral/react-surface-DPK6XU2Y.mjs.map +7 -0
- package/dist/lib/neutral/read-LWLI7RB2.mjs +26 -0
- package/dist/lib/neutral/read-LWLI7RB2.mjs.map +7 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs +30 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/templates/index.mjs +2 -1
- package/dist/lib/neutral/translations.mjs +105 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/update-HTFIQY2Z.mjs +63 -0
- package/dist/lib/neutral/update-HTFIQY2Z.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +3 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/ScriptPlugin.node.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.test.d.ts +2 -0
- package/dist/types/src/ScriptPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts +11 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts +135 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/delete.d.ts +17 -0
- package/dist/types/src/blueprints/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts +21 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +28 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts +11 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts +21 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts +13 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/read.d.ts +21 -0
- package/dist/types/src/blueprints/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +26 -0
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -0
- 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 +4 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/compiler.d.ts +3 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +16 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +19 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +18 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- 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/FramePanel/FramePanel.d.ts +12 -0
- package/dist/types/src/components/FramePanel/FramePanel.d.ts.map +1 -0
- package/dist/types/src/components/FramePanel/index.d.ts +2 -0
- package/dist/types/src/components/FramePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +5 -4
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +5 -3
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +221 -229
- 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/ScriptPluginSettings/ScriptPluginSettings.d.ts +8 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts +241 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts +2 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +10 -9
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +221 -229
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts +4 -2
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/index.d.ts +0 -1
- package/dist/types/src/components/TestPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +6 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +6 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/DeploymentDialog/DeploymentDialog.d.ts +2 -4
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +240 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts +2 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts +2 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts +10 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +6 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts +8 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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 +27 -30
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +5 -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 +7 -16
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts +7 -0
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- 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/notebook/vfs-parser.d.ts.map +1 -1
- package/dist/types/src/operations/create-script.d.ts +5 -0
- package/dist/types/src/operations/create-script.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/templates/anthropic.d.ts +7 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chat.d.ts.map +1 -1
- package/dist/types/src/templates/chess-bot.d.ts +14 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +15 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +5 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +5 -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 +33 -24
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +2 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.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/testing/test-notebook.d.ts +3 -0
- package/dist/types/src/testing/test-notebook.d.ts.map +1 -0
- package/dist/types/src/testing/test-script.d.ts +7 -0
- package/dist/types/src/testing/test-script.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +222 -91
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +117 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/ScriptCapabilities.d.ts +6 -0
- package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/ScriptEvents.d.ts +3 -0
- package/dist/types/src/types/ScriptEvents.d.ts.map +1 -0
- package/dist/types/src/types/ScriptOperation.d.ts +29 -0
- package/dist/types/src/types/ScriptOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +7 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -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 +185 -102
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +24 -100
- package/src/ScriptPlugin.workerd.ts +18 -0
- package/src/blueprints/functions/create.ts +47 -0
- package/src/blueprints/functions/definitions.ts +332 -0
- package/src/blueprints/functions/delete.ts +23 -0
- package/src/blueprints/functions/deploy.ts +71 -0
- package/src/blueprints/functions/index.ts +19 -0
- package/src/blueprints/functions/inspect-invocations.ts +56 -0
- package/src/blueprints/functions/install-function.ts +56 -0
- package/src/blueprints/functions/invoke.ts +34 -0
- package/src/blueprints/functions/query-deployed-functions.ts +35 -0
- package/src/blueprints/functions/read.ts +29 -0
- package/src/blueprints/functions/update.ts +68 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +55 -0
- package/src/capabilities/app-graph-builder.ts +40 -58
- package/src/capabilities/artifact-definition.ts +99 -98
- package/src/capabilities/blueprint-definition.ts +13 -24
- package/src/capabilities/compiler.ts +100 -23
- package/src/capabilities/create-object.ts +49 -0
- package/src/capabilities/index.ts +13 -9
- package/src/capabilities/node.ts +16 -0
- package/src/capabilities/operation-handler.ts +21 -0
- package/src/capabilities/react-surface.tsx +120 -92
- package/src/capabilities/settings.ts +26 -14
- package/src/compiler/compiler.ts +21 -3
- package/src/components/{FrameContainer/FrameContainer.tsx → FramePanel/FramePanel.tsx} +8 -7
- package/src/components/{FrameContainer → FramePanel}/index.ts +1 -1
- package/src/components/NotebookStack/NotebookCell.tsx +100 -91
- package/src/components/NotebookStack/NotebookMenu.tsx +7 -7
- package/src/components/NotebookStack/NotebookStack.stories.tsx +34 -13
- package/src/components/NotebookStack/NotebookStack.tsx +40 -22
- package/src/components/QueryEditor/QueryEditor.stories.tsx +96 -0
- package/src/components/QueryEditor/QueryEditor.tsx +49 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.tsx +32 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.tsx +42 -0
- package/src/components/ScriptPluginSettings/index.ts +5 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +44 -22
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +43 -48
- package/src/components/TestPanel/TestPanel.tsx +125 -185
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +26 -19
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +74 -71
- package/src/components/index.ts +6 -7
- package/src/constants.ts +7 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +63 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +99 -0
- package/src/containers/DeploymentDialog/index.ts +5 -0
- package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +85 -0
- package/src/containers/NotebookArticle/NotebookArticle.tsx +255 -0
- package/src/containers/NotebookArticle/index.ts +5 -0
- package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +107 -0
- package/src/containers/ScriptArticle/ScriptArticle.tsx +85 -0
- package/src/containers/ScriptArticle/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +102 -0
- package/src/containers/ScriptProperties/FunctionBinding.tsx +83 -0
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +121 -0
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +76 -0
- package/src/containers/ScriptProperties/ScriptProperties.tsx +24 -0
- package/src/containers/ScriptProperties/index.ts +5 -0
- package/src/containers/TestContainer/TestContainer.tsx +44 -0
- package/src/containers/TestContainer/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/e2e/ai.test.ts +93 -0
- package/src/e2e/deploy.test.ts +66 -0
- package/src/hooks/deploy.ts +47 -37
- package/src/hooks/format.ts +10 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +23 -26
- package/src/hooks/useCompiler.ts +25 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -4
- package/src/meta.ts +15 -6
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/{notebook.ts → compute-graph.ts} +66 -19
- package/src/notebook/eval.ts +1 -1
- package/src/notebook/index.ts +1 -1
- package/src/notebook/vfs-parser.ts +10 -3
- package/src/operations/create-script.ts +46 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/templates/anthropic.ts +49 -0
- package/src/templates/chat.ts +1 -1
- package/src/templates/chess-bot.ts +63 -0
- package/src/templates/commentary.ts +248 -0
- package/src/templates/data-generator.ts +2 -2
- package/src/templates/discord.ts +5 -5
- package/src/templates/forex-effect.ts +35 -29
- package/src/templates/forex.ts +27 -17
- package/src/templates/gmail.ts +7 -8
- package/src/templates/index.ts +31 -18
- package/src/templates/ping.ts +22 -5
- package/src/testing/index.ts +2 -1
- package/src/testing/simulator.test.ts +39 -0
- package/src/testing/test-notebook.ts +71 -0
- package/src/testing/test-script.ts +28 -0
- package/src/translations.ts +89 -88
- package/src/types/Notebook.ts +42 -0
- package/src/types/ScriptCapabilities.ts +18 -0
- package/src/types/ScriptEvents.ts +11 -0
- package/src/types/ScriptOperation.ts +42 -0
- package/src/types/Settings.ts +20 -0
- package/src/types/index.ts +6 -2
- package/src/types/types.ts +5 -0
- package/src/util/deploy.ts +33 -41
- package/src/util/functions.ts +35 -30
- 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 +0 -26
- 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 +0 -88
- 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/index.mjs +0 -281
- package/dist/lib/browser/index.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/meta.json +0 -1
- 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/browser/types/index.mjs +0 -13
- package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs +0 -684
- 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 +0 -90
- 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 +0 -28
- 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/index.mjs +0 -282
- package/dist/lib/node-esm/index.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/meta.json +0 -1
- 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/lib/node-esm/templates/index.mjs +0 -10
- package/dist/lib/node-esm/types/index.mjs +0 -14
- 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/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +0 -251
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +0 -4
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +0 -12
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/frame.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/frame.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/index.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.d.ts +0 -10
- package/dist/types/src/components/NotebookContainer.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +0 -248
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptContainer.d.ts +0 -12
- package/dist/types/src/components/ScriptContainer.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +0 -8
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +0 -6
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/index.d.ts +0 -3
- package/dist/types/src/components/Settings/index.d.ts.map +0 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +0 -8
- package/dist/types/src/components/TestPanel/TestContainer.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/testing/data.d.ts +0 -19
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/types/actions.d.ts +0 -66
- package/dist/types/src/types/actions.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/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -87
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -53
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -106
- package/src/components/DeploymentDialog/index.ts +0 -9
- package/src/components/FrameContainer/frame.html +0 -25
- package/src/components/FrameContainer/frame.tsx +0 -51
- package/src/components/NotebookContainer.stories.tsx +0 -32
- package/src/components/NotebookContainer.tsx +0 -124
- package/src/components/ScriptContainer.tsx +0 -69
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -286
- package/src/components/Settings/ScriptPluginSettings.tsx +0 -61
- package/src/components/Settings/index.ts +0 -6
- package/src/components/TestPanel/TestContainer.tsx +0 -27
- package/src/events.ts +0 -11
- package/src/notebook/notebook.test.ts +0 -70
- package/src/templates/chess.ts +0 -49
- package/src/testing/data.ts +0 -47
- package/src/types/actions.ts +0 -53
- package/src/types/schema.ts +0 -48
- /package/dist/lib/{browser/templates → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser/DeploymentDialog-65TWT6S5.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/templates → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types → neutral/templates}/index.mjs.map +0 -0
package/src/hooks/template.ts
CHANGED
|
@@ -2,37 +2,35 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Script } from '@dxos/compute';
|
|
5
6
|
import { Obj } from '@dxos/echo';
|
|
6
|
-
import { FUNCTIONS_PRESET_META_KEY
|
|
7
|
-
import { createMenuAction
|
|
7
|
+
import { FUNCTIONS_PRESET_META_KEY } from '@dxos/functions';
|
|
8
|
+
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
8
9
|
|
|
9
|
-
import { meta } from '../meta';
|
|
10
10
|
import { templates } from '../templates';
|
|
11
11
|
|
|
12
12
|
export type TemplateActionProperties = { type: 'template'; value: string };
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
// TODO(burdon): This should not be in the toolbar (move to create Object dialog).
|
|
16
|
-
return createMenuItemGroup('template-select', {
|
|
17
|
-
label: ['template select group label', { ns: meta.id }],
|
|
18
|
-
variant: 'dropdownMenu',
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const createTemplateSelectActions = (script: ScriptType) => {
|
|
14
|
+
const createTemplateSelectActions = (script: Script.Script) => {
|
|
23
15
|
return templates.map((template) => {
|
|
24
16
|
return createMenuAction<TemplateActionProperties>(
|
|
25
17
|
`template--${template.id}`,
|
|
26
18
|
() => {
|
|
27
|
-
script
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
Obj.update(script, (script) => {
|
|
20
|
+
script.name = template.name;
|
|
21
|
+
const meta = Obj.getMeta(script);
|
|
22
|
+
const oldPresetIndex = meta.keys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
|
|
23
|
+
if (oldPresetIndex >= 0) {
|
|
24
|
+
meta.keys.splice(oldPresetIndex, 1);
|
|
25
|
+
}
|
|
26
|
+
if ('presetId' in template) {
|
|
27
|
+
meta.keys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (script.source?.target) {
|
|
31
|
+
Obj.update(script.source.target, (obj) => {
|
|
32
|
+
obj.content = template.source;
|
|
33
|
+
});
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
36
|
{
|
|
@@ -44,14 +42,13 @@ const createTemplateSelectActions = (script: ScriptType) => {
|
|
|
44
42
|
});
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
export const createTemplateSelect = (script:
|
|
48
|
-
const templateSelectGroup = createTemplateSelectGroup();
|
|
45
|
+
export const createTemplateSelect = (script: Script.Script) => {
|
|
49
46
|
const templateSelectActions = createTemplateSelectActions(script);
|
|
50
47
|
return {
|
|
51
|
-
nodes: [
|
|
48
|
+
nodes: [...templateSelectActions],
|
|
52
49
|
edges: [
|
|
53
|
-
{ source: 'root', target: 'template-select' },
|
|
54
|
-
...templateSelectActions.map((action) => ({ source: 'template-select', target: action.id })),
|
|
50
|
+
{ source: 'root', target: 'template-select', relation: 'child' },
|
|
51
|
+
...templateSelectActions.map((action) => ({ source: 'template-select', target: action.id, relation: 'child' })),
|
|
55
52
|
],
|
|
56
53
|
};
|
|
57
54
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCapabilities, usePluginManager } from '@dxos/app-framework/ui';
|
|
6
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
7
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
import { ScriptEvents } from '#types';
|
|
10
|
+
import { ScriptCapabilities } from '#types';
|
|
11
|
+
|
|
12
|
+
import type { Compiler } from '../compiler';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Asynchronously sets up the compiler and returns it.
|
|
16
|
+
* @returns The compiler instance or undefined if it is not ready.
|
|
17
|
+
*/
|
|
18
|
+
export const useCompiler = (): Compiler | undefined => {
|
|
19
|
+
const manager = usePluginManager();
|
|
20
|
+
useAsyncEffect(async () => {
|
|
21
|
+
await manager.activate(ScriptEvents.SetupCompiler).pipe(runAndForwardErrors);
|
|
22
|
+
}, [manager]);
|
|
23
|
+
const [compiler] = useCapabilities(ScriptCapabilities.Compiler);
|
|
24
|
+
return compiler;
|
|
25
|
+
};
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Function from 'effect/Function';
|
|
6
5
|
import { useCallback, useState } from 'react';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
|
+
import { Script } from '@dxos/compute';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import { ScriptType } from '@dxos/functions';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
|
-
import {
|
|
11
|
+
import { SpaceOperation } from '@dxos/plugin-space';
|
|
13
12
|
import { useClient } from '@dxos/react-client';
|
|
14
13
|
import { type Space } from '@dxos/react-client/echo';
|
|
15
14
|
|
|
15
|
+
import { ScriptOperation } from '#types';
|
|
16
|
+
|
|
16
17
|
import { type Template } from '../templates';
|
|
17
|
-
import { ScriptAction } from '../types';
|
|
18
18
|
import { deployScript } from '../util';
|
|
19
19
|
|
|
20
20
|
type DeploymentStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
@@ -27,7 +27,7 @@ type DeploymentStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
|
27
27
|
* All creation / deployment operations run concurrently for improved performance.
|
|
28
28
|
*/
|
|
29
29
|
export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scriptTemplates: Template[]) => {
|
|
30
|
-
const {
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
31
31
|
const client = useClient();
|
|
32
32
|
const [status, setStatus] = useState<DeploymentStatus>('idle');
|
|
33
33
|
const [error, setError] = useState<Error | undefined>(undefined);
|
|
@@ -39,21 +39,20 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
|
|
|
39
39
|
|
|
40
40
|
const deploymentResults = await Promise.all(
|
|
41
41
|
scriptTemplates.map(async (template) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return deployScript({ space, client, script: result.data.object });
|
|
42
|
+
const createResult = await invokePromise(ScriptOperation.CreateScript, {
|
|
43
|
+
db: space.db,
|
|
44
|
+
initialTemplateId: template.id as any,
|
|
45
|
+
});
|
|
46
|
+
invariant(Obj.instanceOf(Script.Script, createResult.data?.object));
|
|
47
|
+
await invokePromise(SpaceOperation.AddObject, { target: space.db, object: createResult.data.object });
|
|
48
|
+
|
|
49
|
+
return deployScript({ space, client, script: createResult.data.object });
|
|
51
50
|
}),
|
|
52
51
|
);
|
|
53
52
|
|
|
54
53
|
const hasErrors = deploymentResults.some((result) => !result.success);
|
|
55
54
|
setStatus(hasErrors ? 'error' : 'success');
|
|
56
|
-
}, [space,
|
|
55
|
+
}, [space, invokePromise, client, scriptTemplates]);
|
|
57
56
|
|
|
58
57
|
// TODO(burdon): Return onCreateAndDeployScripts.
|
|
59
58
|
return { handleCreateAndDeployScripts, status, error };
|
|
@@ -2,15 +2,40 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
8
10
|
|
|
9
11
|
import { type DeployState } from './deploy';
|
|
10
12
|
|
|
11
13
|
export type ScriptToolbarState = Partial<DeployState>;
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export type ScriptToolbarStateStore = {
|
|
16
|
+
atom: Atom.Writable<ScriptToolbarState>;
|
|
17
|
+
get value(): ScriptToolbarState;
|
|
18
|
+
update: (updater: (current: ScriptToolbarState) => ScriptToolbarState) => void;
|
|
19
|
+
set: <K extends keyof ScriptToolbarState>(key: K, value: ScriptToolbarState[K]) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const useToolbarState = (initialState: ScriptToolbarState = {}): ScriptToolbarStateStore => {
|
|
23
|
+
const registry = useCapability(Capabilities.AtomRegistry);
|
|
24
|
+
const atom = useMemo(() => Atom.make<ScriptToolbarState>(initialState), []);
|
|
25
|
+
|
|
26
|
+
return useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
atom,
|
|
29
|
+
get value() {
|
|
30
|
+
return registry.get(atom);
|
|
31
|
+
},
|
|
32
|
+
update: (updater: (current: ScriptToolbarState) => ScriptToolbarState) => {
|
|
33
|
+
registry.set(atom, updater(registry.get(atom)));
|
|
34
|
+
},
|
|
35
|
+
set: <K extends keyof ScriptToolbarState>(key: K, v: ScriptToolbarState[K]) => {
|
|
36
|
+
registry.set(atom, { ...registry.get(atom), [key]: v });
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
[atom, registry],
|
|
40
|
+
);
|
|
16
41
|
};
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
export * from './components';
|
|
5
|
+
export * from './blueprints';
|
|
7
6
|
export * from './meta';
|
|
7
|
+
export * from './types';
|
|
8
8
|
export * from './util';
|
|
9
|
-
|
|
10
|
-
export * from './ScriptPlugin';
|
package/src/meta.ts
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const meta:
|
|
8
|
-
id: 'dxos.
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.script',
|
|
9
10
|
name: 'Scripts',
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
author: 'DXOS',
|
|
12
|
+
spec: 'PLUGIN.mdl',
|
|
13
|
+
description: trim`
|
|
14
|
+
Write, deploy, and run custom TypeScript functions as ECHO objects directly inside your Composer spaces.
|
|
15
|
+
Scripts execute on the Cloudflare Workers-based EDGE runtime and have access to the full DXOS SDK,
|
|
16
|
+
Effect-TS, and a curated set of third-party libraries including HTTP, JSON, CSV, and date utilities.
|
|
17
|
+
An AI Script assistant wires CRUD, deploy, invoke, and invocation-inspection operations as tools
|
|
18
|
+
so an agent can scaffold, iterate, and test functions entirely within a chat session.
|
|
19
|
+
`,
|
|
12
20
|
icon: 'ph--code--regular',
|
|
21
|
+
iconHue: 'sky',
|
|
13
22
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',
|
|
14
23
|
tags: ['labs'],
|
|
15
24
|
screenshots: ['https://dxos.network/plugin-details-scripts-dark.png'],
|
|
@@ -18,5 +27,5 @@ export const meta: PluginMeta = {
|
|
|
18
27
|
// TODO(ZaymonFC): Configure by scopes?
|
|
19
28
|
export const defaultScriptsForIntegration: Record<string, string[]> = {
|
|
20
29
|
// TODO(wittjosiah): Also include content extraction scripts in the default set.
|
|
21
|
-
'gmail.com': ['dxos.
|
|
30
|
+
'gmail.com': ['org.dxos.script.gmail'],
|
|
22
31
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Registry } from '@effect-atom/atom-react';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
|
|
10
|
+
import { createNotebook } from '#testing';
|
|
11
|
+
|
|
12
|
+
import { ComputeGraph } from './compute-graph';
|
|
13
|
+
|
|
14
|
+
describe('notebook', () => {
|
|
15
|
+
test('parse dependency graph', async () => {
|
|
16
|
+
const registry = Registry.make();
|
|
17
|
+
const notebook = createNotebook();
|
|
18
|
+
const graph = new ComputeGraph(notebook, registry);
|
|
19
|
+
const result = graph.parse();
|
|
20
|
+
|
|
21
|
+
const getId = (i: number) => notebook.cells[i].id;
|
|
22
|
+
|
|
23
|
+
// Check dependencies.
|
|
24
|
+
expect(result.dependencyGraph).toMatchObject({
|
|
25
|
+
[getId(0)]: [getId(1), getId(2)],
|
|
26
|
+
[getId(3)]: [getId(1)],
|
|
27
|
+
[getId(4)]: [getId(0), getId(3)],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Compute values.
|
|
31
|
+
const values = await graph.evaluate();
|
|
32
|
+
expect(values).toEqual({
|
|
33
|
+
[getId(0)]: 300,
|
|
34
|
+
[getId(2)]: 200,
|
|
35
|
+
[getId(3)]: 200,
|
|
36
|
+
[getId(4)]: 500,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('evalScript blocks access to window and document', async () => {
|
|
41
|
+
const registry = Registry.make();
|
|
42
|
+
const notebook = createNotebook();
|
|
43
|
+
// Replace one of the cells with code that tries to access window/document.
|
|
44
|
+
const sourceTarget = notebook.cells[2].source?.target;
|
|
45
|
+
if (sourceTarget) {
|
|
46
|
+
Obj.update(sourceTarget, (sourceTarget) => {
|
|
47
|
+
sourceTarget.content = 'b = typeof window';
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const graph = new ComputeGraph(notebook, registry);
|
|
52
|
+
graph.parse();
|
|
53
|
+
const values = await graph.evaluate();
|
|
54
|
+
|
|
55
|
+
// Should evaluate to 'undefined' since window is blocked.
|
|
56
|
+
expect(values[notebook.cells[2].id]).toBe('undefined');
|
|
57
|
+
|
|
58
|
+
// Test document access.
|
|
59
|
+
if (sourceTarget) {
|
|
60
|
+
Obj.update(sourceTarget, (sourceTarget) => {
|
|
61
|
+
sourceTarget.content = 'b = typeof document';
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
graph.parse();
|
|
65
|
+
const values2 = await graph.evaluate();
|
|
66
|
+
|
|
67
|
+
// Should evaluate to 'undefined' since document is blocked.
|
|
68
|
+
expect(values2[notebook.cells[2].id]).toBe('undefined');
|
|
69
|
+
|
|
70
|
+
// Test that safe globals still work.
|
|
71
|
+
if (sourceTarget) {
|
|
72
|
+
Obj.update(sourceTarget, (sourceTarget) => {
|
|
73
|
+
sourceTarget.content = 'b = Math.max(100, 200)';
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
graph.parse();
|
|
77
|
+
const values3 = await graph.evaluate();
|
|
78
|
+
|
|
79
|
+
// Should evaluate correctly.
|
|
80
|
+
expect(values3[notebook.cells[2].id]).toBe(200);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
6
6
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
|
|
9
|
-
import { type Notebook } from '
|
|
9
|
+
import { type Notebook } from '#types';
|
|
10
10
|
|
|
11
11
|
import { evalScript } from './eval';
|
|
12
12
|
import { type ParsedExpression, VirtualTypeScriptParser } from './vfs-parser';
|
|
@@ -14,35 +14,76 @@ import { type ParsedExpression, VirtualTypeScriptParser } from './vfs-parser';
|
|
|
14
14
|
/**
|
|
15
15
|
* Compute graph that evaluates the notebook cells.
|
|
16
16
|
*/
|
|
17
|
+
// TODO(burdon): Reconcile with @dxos/conductor.
|
|
17
18
|
export class ComputeGraph {
|
|
18
19
|
private readonly _parser = new VirtualTypeScriptParser();
|
|
19
20
|
|
|
20
|
-
private
|
|
21
|
-
private
|
|
21
|
+
private _expressionsAtom = Atom.make<Record<string, ParsedExpression>>({});
|
|
22
|
+
private _valuesByCellIdAtom = Atom.make<Record<string, any>>({});
|
|
23
|
+
private _valuesByNameAtom = Atom.make<Record<string, any>>({});
|
|
22
24
|
|
|
23
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly _notebook: Notebook.Notebook,
|
|
27
|
+
private readonly _registry: Registry.Registry,
|
|
28
|
+
) {}
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
31
|
+
* Atom for parsed expressions by cell ID.
|
|
27
32
|
*/
|
|
28
|
-
get expressions():
|
|
29
|
-
return this.
|
|
33
|
+
get expressions(): Atom.Atom<Record<string, ParsedExpression>> {
|
|
34
|
+
return this._expressionsAtom;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* Get current expressions by cell ID.
|
|
34
39
|
*/
|
|
35
|
-
|
|
36
|
-
return this.
|
|
40
|
+
getExpressions(): Record<string, ParsedExpression> {
|
|
41
|
+
return this._registry.get(this._expressionsAtom);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Atom for computed values by cell ID.
|
|
46
|
+
*/
|
|
47
|
+
get values(): Atom.Atom<Record<string, any>> {
|
|
48
|
+
return this._valuesByCellIdAtom;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get computed values by cell ID.
|
|
53
|
+
*/
|
|
54
|
+
getValues(): Record<string, any> {
|
|
55
|
+
return this._registry.get(this._valuesByCellIdAtom);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Atom for computed values by name.
|
|
60
|
+
*/
|
|
61
|
+
get valuesByName(): Atom.Atom<Record<string, any>> {
|
|
62
|
+
return this._valuesByNameAtom;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get current values by name.
|
|
67
|
+
*/
|
|
68
|
+
getValuesByName(): Record<string, any> {
|
|
69
|
+
return this._registry.get(this._valuesByNameAtom);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get computed value by cell ID.
|
|
74
|
+
*/
|
|
75
|
+
getValue(cellId: string): any {
|
|
76
|
+
return this._registry.get(this._valuesByCellIdAtom)[cellId];
|
|
37
77
|
}
|
|
38
78
|
|
|
39
79
|
/**
|
|
40
80
|
* Compute values.
|
|
41
81
|
*/
|
|
42
|
-
evaluate() {
|
|
82
|
+
async evaluate() {
|
|
43
83
|
// Parse expressions.
|
|
44
84
|
const { expressions, dependencyGraph } = this.parse();
|
|
45
|
-
this.
|
|
85
|
+
this._registry.set(this._valuesByCellIdAtom, {});
|
|
86
|
+
this._registry.set(this._valuesByNameAtom, {});
|
|
46
87
|
|
|
47
88
|
// Create a map of cell IDs to expressions for easy lookup.
|
|
48
89
|
const cellExpressions = new Map<string, ParsedExpression>();
|
|
@@ -65,7 +106,7 @@ export class ComputeGraph {
|
|
|
65
106
|
continue;
|
|
66
107
|
}
|
|
67
108
|
|
|
68
|
-
const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.
|
|
109
|
+
const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.source?.target?.content;
|
|
69
110
|
if (!cellSource) {
|
|
70
111
|
log.error('no source for cell', { cellId });
|
|
71
112
|
continue;
|
|
@@ -90,7 +131,7 @@ export class ComputeGraph {
|
|
|
90
131
|
rhs = rhs.slice(0, -1).trim();
|
|
91
132
|
}
|
|
92
133
|
|
|
93
|
-
const result =
|
|
134
|
+
const result = await this.eval(rhs, valuesByName);
|
|
94
135
|
valuesByName[expr.name] = result;
|
|
95
136
|
if (typeof result !== 'function') {
|
|
96
137
|
valuesByCellId[cellId] = result;
|
|
@@ -98,18 +139,24 @@ export class ComputeGraph {
|
|
|
98
139
|
}
|
|
99
140
|
} else {
|
|
100
141
|
// For expressions without assignment, just evaluate.
|
|
101
|
-
const result =
|
|
142
|
+
const result = await this.eval(cellSource, valuesByName);
|
|
102
143
|
valuesByCellId[cellId] = result;
|
|
103
144
|
}
|
|
104
145
|
} catch (error) {
|
|
146
|
+
// TODO(burdon): Set error state.
|
|
105
147
|
log.error('error evaluating cell', { cellId, error });
|
|
106
148
|
}
|
|
107
149
|
}
|
|
108
150
|
|
|
109
|
-
this.
|
|
151
|
+
this._registry.set(this._valuesByCellIdAtom, valuesByCellId);
|
|
152
|
+
this._registry.set(this._valuesByNameAtom, valuesByName);
|
|
110
153
|
return valuesByCellId;
|
|
111
154
|
}
|
|
112
155
|
|
|
156
|
+
private async eval(source: string, values: Record<string, any>) {
|
|
157
|
+
return evalScript(source, values);
|
|
158
|
+
}
|
|
159
|
+
|
|
113
160
|
/**
|
|
114
161
|
* Parse expressions.
|
|
115
162
|
*/
|
|
@@ -117,7 +164,7 @@ export class ComputeGraph {
|
|
|
117
164
|
const expressions = this._notebook.cells
|
|
118
165
|
.filter((cell) => cell.type === 'script')
|
|
119
166
|
.reduce<Record<string, ParsedExpression>>((acc, cell) => {
|
|
120
|
-
const text = cell.
|
|
167
|
+
const text = cell.source?.target?.content.trim();
|
|
121
168
|
if (text) {
|
|
122
169
|
const parsed = this._parser.parseExpression(text);
|
|
123
170
|
acc[cell.id] = parsed;
|
|
@@ -128,7 +175,7 @@ export class ComputeGraph {
|
|
|
128
175
|
|
|
129
176
|
// Build dependency graph.
|
|
130
177
|
const dependencyGraph = this.buildDependencyGraph(expressions);
|
|
131
|
-
this.
|
|
178
|
+
this._registry.set(this._expressionsAtom, expressions);
|
|
132
179
|
return { expressions, dependencyGraph };
|
|
133
180
|
}
|
|
134
181
|
|
package/src/notebook/eval.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { trim } from '@dxos/util';
|
|
|
7
7
|
/**
|
|
8
8
|
* Evaluate the script (with dependencies as arguments).
|
|
9
9
|
*/
|
|
10
|
-
export const evalScript = (code: string, deps: Record<string, any> = {}) => {
|
|
10
|
+
export const evalScript = async (code: string, deps: Record<string, any> = {}) => {
|
|
11
11
|
// Create a sandboxed environment that blocks access to window and document.
|
|
12
12
|
const sandbox = {
|
|
13
13
|
...deps,
|
package/src/notebook/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export class VirtualTypeScriptParser {
|
|
|
42
42
|
protected compilerOptions: ts.CompilerOptions = {
|
|
43
43
|
target: ts.ScriptTarget.ES2020,
|
|
44
44
|
module: ts.ModuleKind.ESNext,
|
|
45
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
45
46
|
strict: true,
|
|
46
47
|
esModuleInterop: true,
|
|
47
48
|
skipLibCheck: true,
|
|
@@ -91,7 +92,9 @@ export class VirtualTypeScriptParser {
|
|
|
91
92
|
// Analyze each file.
|
|
92
93
|
files.forEach((file) => {
|
|
93
94
|
const sourceFile = env.getSourceFile(file.filename);
|
|
94
|
-
if (!sourceFile || !typeChecker)
|
|
95
|
+
if (!sourceFile || !typeChecker) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
95
98
|
|
|
96
99
|
const fileResults = this.analyzeSourceFile(sourceFile, typeChecker);
|
|
97
100
|
results.push(...fileResults);
|
|
@@ -207,7 +210,9 @@ export class VirtualTypeScriptParser {
|
|
|
207
210
|
signature: ts.Signature | undefined,
|
|
208
211
|
typeChecker: ts.TypeChecker,
|
|
209
212
|
): Array<{ name: string; type: string }> {
|
|
210
|
-
if (!signature)
|
|
213
|
+
if (!signature) {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
211
216
|
|
|
212
217
|
return signature.parameters.map((param) => ({
|
|
213
218
|
name: param.getName(),
|
|
@@ -429,7 +434,9 @@ export class NotebookVirtualParser extends VirtualTypeScriptParser {
|
|
|
429
434
|
const previousExports = new Set<string>();
|
|
430
435
|
for (const [_prevCellId, prevAnalysis] of cellAnalysis) {
|
|
431
436
|
prevAnalysis.exports.forEach((exp) => {
|
|
432
|
-
if (exp.name)
|
|
437
|
+
if (exp.name) {
|
|
438
|
+
previousExports.add(exp.name);
|
|
439
|
+
}
|
|
433
440
|
});
|
|
434
441
|
}
|
|
435
442
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Octokit } from '@octokit/core';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Script, Operation } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { templates } from '../templates';
|
|
11
|
+
import { ScriptOperation } from '../types';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof ScriptOperation.CreateScript> = ScriptOperation.CreateScript.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fnUntraced(function* ({ name, gistUrl, initialTemplateId }) {
|
|
16
|
+
let source = templates[0].source;
|
|
17
|
+
let scriptName = name;
|
|
18
|
+
|
|
19
|
+
const gistId = gistUrl?.split('/').at(-1);
|
|
20
|
+
if (gistId) {
|
|
21
|
+
const octokit = new Octokit();
|
|
22
|
+
const response = yield* Effect.promise(() =>
|
|
23
|
+
octokit.request('GET /gists/{gist_id}', {
|
|
24
|
+
gist_id: gistId,
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
const gistContent = Object.values(response.data.files ?? {})[0]?.content;
|
|
28
|
+
if (gistContent) {
|
|
29
|
+
source = gistContent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (initialTemplateId) {
|
|
34
|
+
const template = templates.find((template) => template.id === initialTemplateId);
|
|
35
|
+
if (template) {
|
|
36
|
+
source = template.source;
|
|
37
|
+
scriptName = scriptName || template.name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { object: Script.make({ name: scriptName, source }) };
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export default handler;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const ScriptPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { ScriptOperationHandlerSet } from './operations';
|