@dxos/plugin-script 0.8.3 → 0.8.4-main.1c7ec43d41
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/README.md +15 -13
- package/dist/lib/browser/DeploymentDialog-6DBF3V6C.mjs +112 -0
- package/dist/lib/browser/DeploymentDialog-6DBF3V6C.mjs.map +7 -0
- package/dist/lib/browser/NotebookContainer-RO4NJRYH.mjs +760 -0
- package/dist/lib/browser/NotebookContainer-RO4NJRYH.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-2OPBAXFB.mjs +79 -0
- package/dist/lib/browser/ScriptContainer-2OPBAXFB.mjs.map +7 -0
- package/dist/lib/browser/ScriptProperties-NRXG4PBX.mjs +304 -0
- package/dist/lib/browser/ScriptProperties-NRXG4PBX.mjs.map +7 -0
- package/dist/lib/browser/TestContainer-JNFPLAJX.mjs +44 -0
- package/dist/lib/browser/TestContainer-JNFPLAJX.mjs.map +7 -0
- package/dist/lib/browser/access-token-created-QX2T7AXK.mjs +37 -0
- package/dist/lib/browser/access-token-created-QX2T7AXK.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +58 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-K6K54DEE.mjs +105 -0
- package/dist/lib/browser/chunk-K6K54DEE.mjs.map +7 -0
- package/dist/lib/browser/chunk-KF6H7J5N.mjs +81 -0
- package/dist/lib/browser/chunk-KF6H7J5N.mjs.map +7 -0
- package/dist/lib/browser/chunk-MI6X5CTJ.mjs +336 -0
- package/dist/lib/browser/chunk-MI6X5CTJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-NRKFVW2L.mjs +49 -0
- package/dist/lib/browser/chunk-NRKFVW2L.mjs.map +7 -0
- package/dist/lib/browser/containers/index.mjs +17 -0
- package/dist/lib/browser/containers/index.mjs.map +7 -0
- package/dist/lib/browser/create-K6FDPHFX.mjs +44 -0
- package/dist/lib/browser/create-K6FDPHFX.mjs.map +7 -0
- package/dist/lib/browser/create-script-TUYHIH4R.mjs +45 -0
- package/dist/lib/browser/create-script-TUYHIH4R.mjs.map +7 -0
- package/dist/lib/browser/delete-PAUWA2QM.mjs +21 -0
- package/dist/lib/browser/delete-PAUWA2QM.mjs.map +7 -0
- package/dist/lib/browser/deploy-CXVW54JJ.mjs +62 -0
- package/dist/lib/browser/deploy-CXVW54JJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +179 -193
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/inspect-invocations-LEOEP5I2.mjs +59 -0
- package/dist/lib/browser/inspect-invocations-LEOEP5I2.mjs.map +7 -0
- package/dist/lib/browser/install-function-5N24Q45W.mjs +51 -0
- package/dist/lib/browser/install-function-5N24Q45W.mjs.map +7 -0
- package/dist/lib/browser/invoke-5QVEZ3X5.mjs +33 -0
- package/dist/lib/browser/invoke-5QVEZ3X5.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/query-deployed-functions-FVD7NYPA.mjs +30 -0
- package/dist/lib/browser/query-deployed-functions-FVD7NYPA.mjs.map +7 -0
- package/dist/lib/browser/read-FFOSK6A3.mjs +26 -0
- package/dist/lib/browser/read-FFOSK6A3.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +10 -0
- package/dist/lib/browser/translations.mjs +104 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -0
- package/dist/lib/browser/update-PJS5GG3Y.mjs +63 -0
- package/dist/lib/browser/update-PJS5GG3Y.mjs.map +7 -0
- package/dist/lib/node-esm/DeploymentDialog-A5BZHUJB.mjs +113 -0
- package/dist/lib/node-esm/DeploymentDialog-A5BZHUJB.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-DPT65MA7.mjs +761 -0
- package/dist/lib/node-esm/NotebookContainer-DPT65MA7.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-UKD7QORM.mjs +80 -0
- package/dist/lib/node-esm/ScriptContainer-UKD7QORM.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptProperties-FQXEOJKG.mjs +305 -0
- package/dist/lib/node-esm/ScriptProperties-FQXEOJKG.mjs.map +7 -0
- package/dist/lib/node-esm/TestContainer-Y4XVV7KQ.mjs +45 -0
- package/dist/lib/node-esm/TestContainer-Y4XVV7KQ.mjs.map +7 -0
- package/dist/lib/node-esm/access-token-created-JOL3XE2U.mjs +38 -0
- package/dist/lib/node-esm/access-token-created-JOL3XE2U.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +59 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2DZNF5NG.mjs +82 -0
- package/dist/lib/node-esm/chunk-2DZNF5NG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-47VGEN37.mjs +50 -0
- package/dist/lib/node-esm/chunk-47VGEN37.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-QTUPYAZ7.mjs +107 -0
- package/dist/lib/node-esm/chunk-QTUPYAZ7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XFM2BEHY.mjs +338 -0
- package/dist/lib/node-esm/chunk-XFM2BEHY.mjs.map +7 -0
- package/dist/lib/node-esm/containers/index.mjs +18 -0
- package/dist/lib/node-esm/containers/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-VWULFYRC.mjs +45 -0
- package/dist/lib/node-esm/create-VWULFYRC.mjs.map +7 -0
- package/dist/lib/node-esm/create-script-G7FAWI3E.mjs +46 -0
- package/dist/lib/node-esm/create-script-G7FAWI3E.mjs.map +7 -0
- package/dist/lib/node-esm/delete-YXLT7J27.mjs +22 -0
- package/dist/lib/node-esm/delete-YXLT7J27.mjs.map +7 -0
- package/dist/lib/node-esm/deploy-MXVZXAUC.mjs +63 -0
- package/dist/lib/node-esm/deploy-MXVZXAUC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +179 -193
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/inspect-invocations-TVAKGYX5.mjs +60 -0
- package/dist/lib/node-esm/inspect-invocations-TVAKGYX5.mjs.map +7 -0
- package/dist/lib/node-esm/install-function-ST3VABJH.mjs +52 -0
- package/dist/lib/node-esm/install-function-ST3VABJH.mjs.map +7 -0
- package/dist/lib/node-esm/invoke-64WDU55Y.mjs +34 -0
- package/dist/lib/node-esm/invoke-64WDU55Y.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +15 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/query-deployed-functions-2VCNGQ7X.mjs +31 -0
- package/dist/lib/node-esm/query-deployed-functions-2VCNGQ7X.mjs.map +7 -0
- package/dist/lib/node-esm/read-PECQUAPS.mjs +27 -0
- package/dist/lib/node-esm/read-PECQUAPS.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +11 -0
- package/dist/lib/node-esm/templates/index.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +105 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +15 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/update-XDFTGSPP.mjs +64 -0
- package/dist/lib/node-esm/update-XDFTGSPP.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/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 +141 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/delete.d.ts +18 -0
- package/dist/types/src/blueprints/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts +22 -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 +29 -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 +22 -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 +22 -0
- package/dist/types/src/blueprints/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +27 -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 +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- 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/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 +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 +16 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +240 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/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 +237 -10
- 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 +8 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +13 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -7
- 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/containers/DeploymentDialog/DeploymentDialog.d.ts +9 -0
- 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/NotebookContainer/NotebookContainer.d.ts +7 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts +2 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts +10 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptContainer/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 +31 -32
- 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 +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/operations/access-token-created.d.ts +5 -0
- package/dist/types/src/operations/access-token-created.d.ts.map +1 -0
- 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/definitions.d.ts +29 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.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 +12 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +13 -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 +54 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +4 -0
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/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 +224 -176
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +120 -0
- package/dist/types/src/types/Notebook.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/capabilities.d.ts +9 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- 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 +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 +158 -91
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +30 -81
- package/src/blueprints/functions/create.ts +47 -0
- package/src/blueprints/functions/definitions.ts +323 -0
- package/src/blueprints/functions/delete.ts +23 -0
- package/src/blueprints/functions/deploy.ts +70 -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 +35 -0
- package/src/blueprints/functions/query-deployed-functions.ts +31 -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 -57
- package/src/capabilities/artifact-definition.ts +105 -107
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/compiler.ts +100 -22
- package/src/capabilities/create-object.ts +48 -0
- package/src/capabilities/index.ts +13 -9
- package/src/capabilities/operation-handler.ts +21 -0
- package/src/capabilities/react-surface.tsx +121 -80
- package/src/capabilities/settings.ts +26 -14
- package/src/compiler/compiler.ts +18 -4
- package/src/components/{FrameContainer/FrameContainer.tsx → FramePanel/FramePanel.tsx} +10 -8
- package/src/components/{FrameContainer → FramePanel}/index.ts +1 -1
- package/src/components/NotebookStack/NotebookCell.tsx +226 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +53 -0
- package/src/components/NotebookStack/NotebookStack.tsx +97 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/QueryEditor/QueryEditor.stories.tsx +96 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -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 +56 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +43 -41
- package/src/components/TestPanel/TestPanel.tsx +124 -185
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +89 -34
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +88 -78
- package/src/components/index.ts +7 -5
- 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/NotebookContainer/NotebookContainer.stories.tsx +85 -0
- package/src/containers/NotebookContainer/NotebookContainer.tsx +254 -0
- package/src/containers/NotebookContainer/index.ts +5 -0
- package/src/containers/ScriptContainer/ScriptContainer.stories.tsx +106 -0
- package/src/containers/ScriptContainer/ScriptContainer.tsx +85 -0
- package/src/containers/ScriptContainer/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +101 -0
- package/src/containers/ScriptProperties/FunctionBinding.tsx +83 -0
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +121 -0
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +75 -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 +54 -45
- package/src/hooks/format.ts +10 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +24 -26
- package/src/hooks/useCompiler.ts +25 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +16 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +8 -4
- package/src/meta.ts +10 -8
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/compute-graph.ts +230 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +458 -0
- package/src/operations/access-token-created.ts +37 -0
- package/src/operations/create-script.ts +46 -0
- package/src/operations/definitions.ts +40 -0
- package/src/operations/index.ts +12 -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 +249 -0
- package/src/templates/data-generator.ts +11 -5
- package/src/templates/discord.ts +14 -6
- package/src/templates/email.ts +2 -2
- package/src/templates/forex-effect.ts +35 -25
- package/src/templates/forex.ts +27 -15
- package/src/templates/gmail.ts +38 -68
- package/src/templates/index.ts +38 -23
- package/src/templates/ping.ts +25 -0
- package/src/testing/index.ts +6 -0
- package/src/testing/simulator.test.ts +39 -0
- package/src/testing/test-notebook.ts +71 -0
- package/src/testing/test-script.ts +29 -0
- package/src/translations.ts +96 -67
- package/src/types/Notebook.ts +45 -0
- package/src/types/Settings.ts +20 -0
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +8 -0
- package/src/types/types.ts +5 -0
- package/src/util/deploy.ts +40 -61
- package/src/util/functions.ts +59 -25
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-RPPPWEEL.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs +0 -261
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs +0 -64
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs +0 -249
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs.map +0 -7
- package/dist/lib/browser/chunk-3FU4QZVP.mjs +0 -364
- package/dist/lib/browser/chunk-3FU4QZVP.mjs.map +0 -7
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs +0 -557
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-6ZHHWU6S.mjs +0 -28
- package/dist/lib/browser/chunk-6ZHHWU6S.mjs.map +0 -7
- package/dist/lib/browser/chunk-LA66DQGU.mjs +0 -153
- package/dist/lib/browser/chunk-LA66DQGU.mjs.map +0 -7
- package/dist/lib/browser/chunk-QJH7I2UV.mjs +0 -233
- package/dist/lib/browser/chunk-QJH7I2UV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs +0 -40
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-YSQMXTYO.mjs +0 -15
- package/dist/lib/browser/chunk-YSQMXTYO.mjs.map +0 -7
- package/dist/lib/browser/compiler-W4BYJYTL.mjs +0 -82
- package/dist/lib/browser/compiler-W4BYJYTL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs +0 -90
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs.map +0 -7
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs +0 -105
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs.map +0 -7
- package/dist/lib/browser/settings-Z22D6JVJ.mjs +0 -24
- package/dist/lib/browser/settings-Z22D6JVJ.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -13
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs +0 -33
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs +0 -278
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs +0 -80
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs +0 -265
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs.map +0 -7
- package/dist/lib/node/chunk-AU2FOE26.cjs +0 -369
- package/dist/lib/node/chunk-AU2FOE26.cjs.map +0 -7
- package/dist/lib/node/chunk-BUOBOT3V.cjs +0 -179
- package/dist/lib/node/chunk-BUOBOT3V.cjs.map +0 -7
- package/dist/lib/node/chunk-HCRW6T3G.cjs +0 -60
- package/dist/lib/node/chunk-HCRW6T3G.cjs.map +0 -7
- package/dist/lib/node/chunk-OSBMUJ4T.cjs +0 -580
- package/dist/lib/node/chunk-OSBMUJ4T.cjs.map +0 -7
- package/dist/lib/node/chunk-QG2X6J74.cjs +0 -52
- package/dist/lib/node/chunk-QG2X6J74.cjs.map +0 -7
- package/dist/lib/node/chunk-YO5W2IPQ.cjs +0 -251
- package/dist/lib/node/chunk-YO5W2IPQ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZEV3VARQ.cjs +0 -34
- package/dist/lib/node/chunk-ZEV3VARQ.cjs.map +0 -7
- package/dist/lib/node/compiler-TFSJRLL4.cjs +0 -104
- package/dist/lib/node/compiler-TFSJRLL4.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -225
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs +0 -100
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-EUKPDFU3.cjs +0 -120
- package/dist/lib/node/react-surface-EUKPDFU3.cjs.map +0 -7
- package/dist/lib/node/settings-WO53FLYZ.cjs +0 -38
- package/dist/lib/node/settings-WO53FLYZ.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -34
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-IA4CH6WZ.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs +0 -262
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs +0 -65
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs +0 -16
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AEB5TPEW.mjs +0 -30
- package/dist/lib/node-esm/chunk-AEB5TPEW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs +0 -558
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs +0 -234
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs +0 -154
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs +0 -41
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs +0 -365
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs +0 -83
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs +0 -91
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs +0 -106
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs.map +0 -7
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs +0 -25
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -14
- package/dist/types/src/capabilities/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 +0 -11
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +0 -18
- 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/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 -7
- 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/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/templates/echo.d.ts +0 -6
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -40
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -80
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -39
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -112
- 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/ScriptContainer.tsx +0 -67
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -206
- package/src/components/Settings/ScriptPluginSettings.tsx +0 -71
- package/src/components/Settings/index.ts +0 -6
- package/src/components/TestPanel/TestContainer.tsx +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -47
- package/src/templates/echo.ts +0 -8
- package/src/types.ts +0 -42
- /package/dist/lib/browser/{DeploymentDialog-RPPPWEEL.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{types.mjs.map → templates/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-IA4CH6WZ.mjs.map → browser/types/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{types.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Script, Operation } from '@dxos/compute';
|
|
8
|
+
import { Database } from '@dxos/echo';
|
|
9
|
+
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
|
|
12
|
+
import { templates } from '../templates';
|
|
13
|
+
|
|
14
|
+
const SCRIPT_OPERATION = `${meta.id}.operation`;
|
|
15
|
+
|
|
16
|
+
export const ScriptProps = Schema.Struct({
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
|
+
gistUrl: Schema.optional(Schema.String.annotations({ title: 'Import from Gist (url)' })),
|
|
19
|
+
initialTemplateId: Schema.Literal(...templates.map(({ id }) => id)).pipe(
|
|
20
|
+
Schema.annotations({ title: 'Template' }),
|
|
21
|
+
Schema.optional,
|
|
22
|
+
),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const NotebookProps = Schema.Struct({
|
|
26
|
+
name: Schema.optional(Schema.String),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const CreateScript = Operation.make({
|
|
30
|
+
meta: { key: `${SCRIPT_OPERATION}.create-script`, name: 'Create Script' },
|
|
31
|
+
input: Schema.extend(
|
|
32
|
+
ScriptProps,
|
|
33
|
+
Schema.Struct({
|
|
34
|
+
db: Database.Database,
|
|
35
|
+
}),
|
|
36
|
+
),
|
|
37
|
+
output: Schema.Struct({
|
|
38
|
+
object: Script.Script,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
|
+
|
|
7
|
+
export * as ScriptOperation from './definitions';
|
|
8
|
+
|
|
9
|
+
export const ScriptOperationHandlerSet = OperationHandlerSet.lazy(
|
|
10
|
+
() => import('./access-token-created'),
|
|
11
|
+
() => import('./create-script'),
|
|
12
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as LanguageModel from '@effect/ai/LanguageModel';
|
|
6
|
+
import * as Chunk from 'effect/Chunk';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
|
+
import * as Stream from 'effect/Stream';
|
|
10
|
+
|
|
11
|
+
import { AiService } from '@dxos/ai';
|
|
12
|
+
import { Operation } from '@dxos/compute';
|
|
13
|
+
|
|
14
|
+
const Anthropic = Operation.make({
|
|
15
|
+
meta: {
|
|
16
|
+
key: 'org.dxos.script.anthropic',
|
|
17
|
+
name: 'Anthropic Chat',
|
|
18
|
+
description: 'Chat with Anthropic',
|
|
19
|
+
},
|
|
20
|
+
input: Schema.Struct({
|
|
21
|
+
message: Schema.String,
|
|
22
|
+
}),
|
|
23
|
+
output: Schema.Any,
|
|
24
|
+
services: [AiService.AiService],
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default Anthropic.pipe(
|
|
28
|
+
Operation.withHandler(
|
|
29
|
+
Effect.fn(function* ({ message }) {
|
|
30
|
+
const model = (yield* AiService.AiService).model('@anthropic/claude-sonnet-4-5');
|
|
31
|
+
|
|
32
|
+
//
|
|
33
|
+
// Basic example.
|
|
34
|
+
//
|
|
35
|
+
const { text } = yield* LanguageModel.generateText({ prompt: message }).pipe(Effect.provide(model));
|
|
36
|
+
|
|
37
|
+
//
|
|
38
|
+
// Streaming example.
|
|
39
|
+
//
|
|
40
|
+
const parts = yield* LanguageModel.streamText({
|
|
41
|
+
prompt: 'Count from 1 to 5, one number per line.',
|
|
42
|
+
}).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));
|
|
43
|
+
const textDeltas = parts.filter((p) => p.type === 'text-delta');
|
|
44
|
+
const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');
|
|
45
|
+
|
|
46
|
+
return { response: text, streamText: fullText };
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
);
|
package/src/templates/chat.ts
CHANGED
|
@@ -76,7 +76,7 @@ export default async ({ data: { bodyText }, context: { space, ai } }: any) => {
|
|
|
76
76
|
|
|
77
77
|
const getContext = async ({ space }: any) => {
|
|
78
78
|
let context = '';
|
|
79
|
-
const { objects: docs } = await space.crud.query({ __typename: 'dxos.
|
|
79
|
+
const { objects: docs } = await space.crud.query({ __typename: 'org.dxos.type.document' }).run();
|
|
80
80
|
for (const doc of docs) {
|
|
81
81
|
const { content } = await space.crud.query({ id: doc.content }).first();
|
|
82
82
|
context += content + '\n\n';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
10
|
+
import { Database, Obj } from '@dxos/echo';
|
|
11
|
+
import { Chess } from '@dxos/plugin-chess/types';
|
|
12
|
+
import { GameRef, Game, loadGame } from '@dxos/plugin-game/types';
|
|
13
|
+
|
|
14
|
+
const ChessBot = Operation.make({
|
|
15
|
+
meta: {
|
|
16
|
+
key: 'org.dxos.script.chess-bot',
|
|
17
|
+
name: 'Chess Bot',
|
|
18
|
+
description: 'Plays a random move in a chess game.',
|
|
19
|
+
},
|
|
20
|
+
input: Schema.Struct({
|
|
21
|
+
game: GameRef(Chess.State).annotations({
|
|
22
|
+
description: 'The chess game to comment on.',
|
|
23
|
+
}),
|
|
24
|
+
player: Schema.optional(Schema.Literal('white', 'black')).annotations({
|
|
25
|
+
description: 'The player to play the game as.',
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
output: Schema.Struct({
|
|
29
|
+
state: Schema.String.annotations({
|
|
30
|
+
description: 'The state of the game as an ASCII art board.',
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
types: [Game, Chess.State],
|
|
34
|
+
services: [Database.Service],
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default ChessBot.pipe(
|
|
38
|
+
Operation.withHandler(
|
|
39
|
+
Effect.fnUntraced(function* ({ game, player = 'black' }) {
|
|
40
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
41
|
+
const chess = new ChessJS();
|
|
42
|
+
chess.loadPgn(variant.pgn ?? '');
|
|
43
|
+
if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {
|
|
44
|
+
return { state: chess.ascii() };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const moves = chess.moves({ verbose: true });
|
|
48
|
+
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
49
|
+
if (!move) {
|
|
50
|
+
return { state: chess.ascii() };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
chess.move(move.san);
|
|
54
|
+
const newPgn = chess.pgn();
|
|
55
|
+
Obj.update(variant, (variant) => {
|
|
56
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
57
|
+
mutable.pgn = newPgn;
|
|
58
|
+
});
|
|
59
|
+
yield* Database.flush();
|
|
60
|
+
return { state: chess.ascii() };
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as A from '@automerge/automerge';
|
|
6
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
7
|
+
import * as Array from 'effect/Array';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Function from 'effect/Function';
|
|
10
|
+
import * as Layer from 'effect/Layer';
|
|
11
|
+
import * as Option from 'effect/Option';
|
|
12
|
+
import * as Schema from 'effect/Schema';
|
|
13
|
+
|
|
14
|
+
import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
|
|
15
|
+
import { AiRequest, GenerationObserver } from '@dxos/assistant';
|
|
16
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
17
|
+
import { Trace, Operation, OperationRegistry } from '@dxos/compute';
|
|
18
|
+
import { Database, Filter, Obj, Ref, Relation } from '@dxos/echo';
|
|
19
|
+
import { Collection } from '@dxos/echo';
|
|
20
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
21
|
+
import { log } from '@dxos/log';
|
|
22
|
+
import { Chess } from '@dxos/plugin-chess/types';
|
|
23
|
+
import { Game, GameRef, loadGame } from '@dxos/plugin-game/types';
|
|
24
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
25
|
+
import { Text } from '@dxos/schema';
|
|
26
|
+
import { HasSubject } from '@dxos/types';
|
|
27
|
+
import { trim } from '@dxos/util';
|
|
28
|
+
|
|
29
|
+
const Commentary = Operation.make({
|
|
30
|
+
meta: {
|
|
31
|
+
key: 'org.dxos.function.chess.commentary',
|
|
32
|
+
name: 'Commentary',
|
|
33
|
+
description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',
|
|
34
|
+
},
|
|
35
|
+
input: Schema.Struct({
|
|
36
|
+
game: GameRef(Chess.State).annotations({
|
|
37
|
+
description: 'The chess game to comment on.',
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
output: Schema.Union(
|
|
41
|
+
Schema.Struct({
|
|
42
|
+
documentId: ArtifactId.annotations({
|
|
43
|
+
description: 'The ID of the markdown document that was updated or created.',
|
|
44
|
+
}),
|
|
45
|
+
commentary: Schema.String.annotations({
|
|
46
|
+
description: 'The commentary that was added.',
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
Schema.Void.annotations({
|
|
50
|
+
description: 'Function did not find anything to comment on.',
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
types: [Game, Chess.State, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],
|
|
54
|
+
services: [AiService.AiService, Database.Service],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default Commentary.pipe(
|
|
58
|
+
Operation.withHandler(
|
|
59
|
+
Effect.fnUntraced(
|
|
60
|
+
function* ({ game: gameRef }) {
|
|
61
|
+
// Load the game and its Chess variant state.
|
|
62
|
+
log.info('load game', { gameRef });
|
|
63
|
+
const { game: chessGame, variant: chessState } = yield* loadGame(gameRef, Chess.State);
|
|
64
|
+
|
|
65
|
+
// Load the chess position from PGN or FEN.
|
|
66
|
+
const chess = new ChessJS();
|
|
67
|
+
if (chessState.pgn) {
|
|
68
|
+
chess.loadPgn(chessState.pgn);
|
|
69
|
+
} else if (chessState.fen) {
|
|
70
|
+
chess.load(chessState.fen);
|
|
71
|
+
} else {
|
|
72
|
+
log.info('Early return: no pgn or fen');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Get the most recent move
|
|
77
|
+
const history = chess.history({ verbose: true });
|
|
78
|
+
if (history.length === 0) {
|
|
79
|
+
throw new Error('No moves have been played yet');
|
|
80
|
+
}
|
|
81
|
+
const lastMove = history[history.length - 1];
|
|
82
|
+
const moveNumber = Math.ceil(history.length / 2);
|
|
83
|
+
const isWhiteMove = history.length % 2 === 1;
|
|
84
|
+
const player = isWhiteMove ? 'White' : 'Black';
|
|
85
|
+
const moveNotation = lastMove.san;
|
|
86
|
+
|
|
87
|
+
// Generate AI commentary about the move
|
|
88
|
+
const result = yield* new AiRequest({
|
|
89
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),
|
|
90
|
+
}).run({
|
|
91
|
+
prompt:
|
|
92
|
+
`Comment on this chess move as if you're commentating a live match for an audience:\n\n` +
|
|
93
|
+
`Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\n` +
|
|
94
|
+
`Current position: ${chess.fen()}\n` +
|
|
95
|
+
`${chess.isCheck() ? 'The king is in check! ' : ''}` +
|
|
96
|
+
`${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +
|
|
97
|
+
`${chess.isStalemate() ? 'STALEMATE! ' : ''}` +
|
|
98
|
+
`\nGame so far:\n${chess.pgn()}`,
|
|
99
|
+
system: COMMENTARY_SYSTEM_PROMPT,
|
|
100
|
+
history: [],
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const commentaryText = Function.pipe(
|
|
104
|
+
result,
|
|
105
|
+
Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
|
|
106
|
+
Option.flatMap((msg) =>
|
|
107
|
+
Function.pipe(
|
|
108
|
+
msg.blocks,
|
|
109
|
+
Array.findLast((block) => block._tag === 'text'),
|
|
110
|
+
Option.map((block) => block.text),
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
Option.getOrThrowWith(() => new Error('No commentary generated')),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\n\n${commentaryText}\n\n`;
|
|
117
|
+
log.info('commentary', { commentary });
|
|
118
|
+
|
|
119
|
+
// TODO(wittjosiah): Functions currently don't support traversals.
|
|
120
|
+
// const docs = yield* Database.runQuery(
|
|
121
|
+
// Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),
|
|
122
|
+
// ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));
|
|
123
|
+
const docs = yield* Database.runQuery(Filter.type(HasSubject.HasSubject)).pipe(
|
|
124
|
+
Effect.map((relations) =>
|
|
125
|
+
relations.filter((relation) => {
|
|
126
|
+
// TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.
|
|
127
|
+
try {
|
|
128
|
+
log.info('relation', {
|
|
129
|
+
source: Obj.getDXN(Relation.getTarget(relation)).toString(),
|
|
130
|
+
game: Obj.getDXN(chessGame).toString(),
|
|
131
|
+
});
|
|
132
|
+
return Obj.getDXN(Relation.getTarget(relation)).toString() === Obj.getDXN(chessGame).toString();
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
),
|
|
138
|
+
Effect.map((relations) =>
|
|
139
|
+
relations
|
|
140
|
+
.map((relation) => {
|
|
141
|
+
// TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.
|
|
142
|
+
try {
|
|
143
|
+
return Relation.getSource(relation);
|
|
144
|
+
} catch {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
.filter((source) => source !== undefined),
|
|
149
|
+
),
|
|
150
|
+
Effect.map((sources) => {
|
|
151
|
+
const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));
|
|
152
|
+
log.info('docs', { sources, docs });
|
|
153
|
+
return docs;
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
156
|
+
log.info('docs', { count: docs.length });
|
|
157
|
+
|
|
158
|
+
let document: Markdown.Document;
|
|
159
|
+
if (docs.length === 0) {
|
|
160
|
+
// TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.
|
|
161
|
+
const [properties] = yield* Database.runQuery(Filter.typename('org.dxos.type.spaceProperties'));
|
|
162
|
+
const rootCollection = yield* Database.load<Collection.Collection>(
|
|
163
|
+
properties[Collection.Collection.typename],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
log.info('rootCollection', { rootCollection });
|
|
167
|
+
|
|
168
|
+
// Create a new markdown document
|
|
169
|
+
const gameName = chessGame.name || 'Chess Game';
|
|
170
|
+
document = yield* Database.add(
|
|
171
|
+
Markdown.make({
|
|
172
|
+
name: `${gameName} Commentary`,
|
|
173
|
+
content: `# ${gameName} Commentary\n\n${commentary}`,
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const documentRef = Ref.make(document);
|
|
178
|
+
Obj.update(rootCollection, (rootCollection) => {
|
|
179
|
+
rootCollection.objects.push(documentRef);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Create the HasSubject relation
|
|
183
|
+
yield* Database.add(
|
|
184
|
+
Relation.make(HasSubject.HasSubject, {
|
|
185
|
+
[Relation.Source]: document,
|
|
186
|
+
[Relation.Target]: chessGame,
|
|
187
|
+
completedAt: new Date().toISOString(),
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
190
|
+
} else {
|
|
191
|
+
document = docs[0];
|
|
192
|
+
|
|
193
|
+
// Load the text content and append the commentary
|
|
194
|
+
const text = yield* Database.load(document.content);
|
|
195
|
+
const accessor = createDocAccessor(text, ['content']);
|
|
196
|
+
accessor.handle.change((doc: A.Doc<Text.Text>) => {
|
|
197
|
+
A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
log.info('result', { documentId: Obj.getDXN(document).toString(), commentary });
|
|
202
|
+
|
|
203
|
+
yield* Database.flush();
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
documentId: Obj.getDXN(document).toString(),
|
|
207
|
+
commentary,
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
Effect.provide(
|
|
211
|
+
Layer.mergeAll(
|
|
212
|
+
AiService.model('@anthropic/claude-haiku-4-5'),
|
|
213
|
+
ToolResolverService.layerEmpty,
|
|
214
|
+
ToolExecutionService.layerEmpty,
|
|
215
|
+
Trace.writerLayerNoop,
|
|
216
|
+
Database.notAvailable,
|
|
217
|
+
Layer.succeed(Operation.Service, {
|
|
218
|
+
invoke: () => Effect.die('Not available.'),
|
|
219
|
+
schedule: () => Effect.die('Not available.'),
|
|
220
|
+
invokePromise: async () => ({ error: new Error('Not available.') }),
|
|
221
|
+
} as any),
|
|
222
|
+
Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
),
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const COMMENTARY_SYSTEM_PROMPT = trim`
|
|
230
|
+
You are a professional chess commentator providing live commentary for a chess match.
|
|
231
|
+
|
|
232
|
+
# Style
|
|
233
|
+
- Write in an engaging, enthusiastic style as if commentating for a live audience
|
|
234
|
+
- Be concise but informative (2-4 sentences)
|
|
235
|
+
- Explain the strategic implications of the move
|
|
236
|
+
- Note any tactical elements (captures, threats, checks)
|
|
237
|
+
- Comment on the position and what it means for the game
|
|
238
|
+
|
|
239
|
+
# Format
|
|
240
|
+
- Write in plain text (no markdown formatting in the commentary itself)
|
|
241
|
+
- Be natural and conversational
|
|
242
|
+
- Use chess terminology appropriately but keep it accessible
|
|
243
|
+
|
|
244
|
+
# Special Situations
|
|
245
|
+
- If it's checkmate, express excitement about the conclusion
|
|
246
|
+
- If it's check, note the pressure on the king
|
|
247
|
+
- If a piece is captured, mention the material exchange
|
|
248
|
+
- Comment on the development of pieces and control of key squares when relevant
|
|
249
|
+
`;
|
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { Expando, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';
|
|
9
9
|
|
|
10
10
|
export default defineFunction({
|
|
11
|
+
key: 'org.dxos.script.data-generator',
|
|
12
|
+
name: 'Data Generator',
|
|
11
13
|
inputSchema: S.Struct({
|
|
12
14
|
documentAmount: S.optional(S.Number),
|
|
13
15
|
textSize: S.optional(S.Number),
|
|
14
16
|
mutationAmount: S.optional(S.Number),
|
|
17
|
+
waitAfterCreation: S.optional(S.Number),
|
|
15
18
|
}),
|
|
16
19
|
|
|
17
20
|
outputSchema: S.Struct({}),
|
|
18
21
|
|
|
19
|
-
handler: async ({
|
|
20
|
-
|
|
22
|
+
handler: async ({
|
|
23
|
+
data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
|
|
24
|
+
context: { space },
|
|
25
|
+
}: any) => {
|
|
26
|
+
await space.db.graph.schemaRegistry.register([Expando]);
|
|
21
27
|
const result: Record<string, any> = {};
|
|
22
28
|
const objects: Expando[] = [];
|
|
23
29
|
|
|
@@ -42,7 +48,7 @@ export default defineFunction({
|
|
|
42
48
|
|
|
43
49
|
// Flush and wait for data to propagate.
|
|
44
50
|
await space.db.flush();
|
|
45
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
46
|
-
return
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));
|
|
52
|
+
return { createdObjects: objects.length };
|
|
47
53
|
},
|
|
48
54
|
});
|
package/src/templates/discord.ts
CHANGED
|
@@ -3,17 +3,23 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { DXN, EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.
|
|
8
|
+
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
9
9
|
import {
|
|
10
10
|
DiscordConfig,
|
|
11
11
|
DiscordREST,
|
|
12
12
|
DiscordRESTMemoryLive,
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.
|
|
14
|
+
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
import
|
|
16
|
+
import * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
|
|
17
23
|
|
|
18
24
|
const MessageSchema = S.Struct({
|
|
19
25
|
id: ObjectId,
|
|
@@ -23,7 +29,7 @@ const MessageSchema = S.Struct({
|
|
|
23
29
|
content: S.String,
|
|
24
30
|
}).pipe(
|
|
25
31
|
EchoObject({
|
|
26
|
-
typename: 'example.
|
|
32
|
+
typename: 'com.example.type.message',
|
|
27
33
|
version: '0.1.0',
|
|
28
34
|
}),
|
|
29
35
|
);
|
|
@@ -36,6 +42,8 @@ const generateSnowflake = (unixTimestamp: number): bigint => {
|
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
export default defineFunction({
|
|
45
|
+
key: 'org.dxos.script.discord',
|
|
46
|
+
name: 'Discord',
|
|
39
47
|
inputSchema: S.Struct({
|
|
40
48
|
// TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
|
|
41
49
|
tick: S.optional(S.String),
|
|
@@ -52,7 +60,7 @@ export default defineFunction({
|
|
|
52
60
|
handler: ({ data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 }, context: { space } }: any) =>
|
|
53
61
|
Effect.gen(function* () {
|
|
54
62
|
const { token } = yield* Effect.tryPromise({
|
|
55
|
-
try: () => space.db.query(Filter.typename('dxos.
|
|
63
|
+
try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'discord.com' })).first(),
|
|
56
64
|
catch: (e: any) => e,
|
|
57
65
|
});
|
|
58
66
|
const { objects } = yield* Effect.tryPromise({
|
package/src/templates/email.ts
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
export default async ({ data: { bodyText }, context: { space } }: any) => {
|
|
10
10
|
const { email, targetDocumentId: documentId } = JSON.parse(bodyText) as RequestPayload;
|
|
11
11
|
|
|
12
|
-
const document = await space.db.query({ id: documentId }
|
|
12
|
+
const document = await space.db.query({ id: documentId }).first();
|
|
13
13
|
|
|
14
14
|
const contentId = document.content['/'].split(':')[3];
|
|
15
|
-
const documentContent = await space.db.query({ id: contentId }
|
|
15
|
+
const documentContent = await space.db.query({ id: contentId }).first();
|
|
16
16
|
const modifiedContent = [
|
|
17
17
|
documentContent.content,
|
|
18
18
|
'',
|
|
@@ -2,37 +2,47 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.14.21&bundle=false';
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import { Effect, Schedule } from 'https://esm.sh/effect@3.14.21?bundle=false';
|
|
5
|
+
import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
|
|
6
|
+
import * as HttpClient from '@effect/platform/HttpClient';
|
|
7
|
+
import * as HttpClientRequest from '@effect/platform/HttpClientRequest';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Schedule from 'effect/Schedule';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
description: 'Returns the exchange rate between two currencies.',
|
|
12
|
+
import { Operation } from '@dxos/compute';
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const ForexEffect = Operation.make({
|
|
15
|
+
meta: {
|
|
16
|
+
key: 'org.dxos.script.forex-effect',
|
|
17
|
+
name: 'Forex Effect',
|
|
18
|
+
description: 'Returns the exchange rate between two currencies.',
|
|
19
|
+
},
|
|
20
|
+
input: Schema.Struct({
|
|
21
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
22
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
22
23
|
}),
|
|
24
|
+
output: Schema.Any,
|
|
25
|
+
});
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
27
|
+
export default ForexEffect.pipe(
|
|
28
|
+
Operation.withHandler(
|
|
29
|
+
Effect.fnUntraced(function* ({ from: rawFrom, to: rawTo }) {
|
|
30
|
+
const from = rawFrom.toUpperCase();
|
|
31
|
+
const to = rawTo.toUpperCase();
|
|
32
|
+
const json: any = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
|
|
29
33
|
HttpClient.execute,
|
|
30
|
-
Effect.flatMap((
|
|
31
|
-
Effect.timeout('
|
|
34
|
+
Effect.flatMap((response) => response.json),
|
|
35
|
+
Effect.timeout('5 seconds'),
|
|
32
36
|
Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
|
|
33
37
|
Effect.scoped,
|
|
34
38
|
);
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
40
|
+
const rate = json?.data?.rates?.[to];
|
|
41
|
+
if (rate == null) {
|
|
42
|
+
return yield* Effect.fail(new Error(`No rate found for ${from} -> ${to}`));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return rate.toString();
|
|
46
|
+
}, Effect.provide(FetchHttpClient.layer)),
|
|
47
|
+
),
|
|
48
|
+
);
|
package/src/templates/forex.ts
CHANGED
|
@@ -2,23 +2,35 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
description: 'Returns the exchange rate between two currencies.',
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const Forex = Operation.make({
|
|
11
|
+
meta: {
|
|
12
|
+
key: 'org.dxos.script.forex',
|
|
13
|
+
name: 'Forex',
|
|
14
|
+
description: 'Returns the exchange rate between two currencies.',
|
|
15
|
+
},
|
|
16
|
+
input: Schema.Struct({
|
|
17
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
18
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
14
19
|
}),
|
|
20
|
+
output: Schema.Any,
|
|
21
|
+
});
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
export default Forex.pipe(
|
|
24
|
+
Operation.withHandler(
|
|
25
|
+
Effect.fn(function* ({ from: rawFrom, to: rawTo }) {
|
|
26
|
+
const from = rawFrom.toUpperCase();
|
|
27
|
+
const to = rawTo.toUpperCase();
|
|
28
|
+
const res = yield* Effect.promise(() => fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`));
|
|
29
|
+
const {
|
|
30
|
+
data: { rates },
|
|
31
|
+
} = yield* Effect.promise(() => res.json());
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
return rates[to].toString();
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
);
|