@dxos/plugin-script 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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-IIOXAS47.mjs +138 -0
- package/dist/lib/browser/DeploymentDialog-IIOXAS47.mjs.map +7 -0
- package/dist/lib/browser/NotebookContainer-VVZOKGRC.mjs +850 -0
- package/dist/lib/browser/NotebookContainer-VVZOKGRC.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-A5SSIUH6.mjs +93 -0
- package/dist/lib/browser/ScriptContainer-A5SSIUH6.mjs.map +7 -0
- package/dist/lib/browser/ScriptObjectSettings-HYYC7KXC.mjs +294 -0
- package/dist/lib/browser/ScriptObjectSettings-HYYC7KXC.mjs.map +7 -0
- package/dist/lib/browser/ScriptPluginSettings-UTWA7CBT.mjs +55 -0
- package/dist/lib/browser/ScriptPluginSettings-UTWA7CBT.mjs.map +7 -0
- package/dist/lib/browser/ScriptProperties-HREPUE65.mjs +28 -0
- package/dist/lib/browser/ScriptProperties-HREPUE65.mjs.map +7 -0
- package/dist/lib/browser/TestContainer-D4Y2K2TT.mjs +39 -0
- package/dist/lib/browser/TestContainer-D4Y2K2TT.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-YMZEJBAZ.mjs +17 -0
- package/dist/lib/browser/blueprint-definition-YMZEJBAZ.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-6IXFDTAI.mjs +113 -0
- package/dist/lib/browser/chunk-6IXFDTAI.mjs.map +7 -0
- package/dist/lib/browser/chunk-ATTZUDT7.mjs +67 -0
- package/dist/lib/browser/chunk-ATTZUDT7.mjs.map +7 -0
- package/dist/lib/browser/chunk-G3XIOLLI.mjs +174 -0
- package/dist/lib/browser/chunk-G3XIOLLI.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J7PGML5B.mjs +105 -0
- package/dist/lib/browser/chunk-J7PGML5B.mjs.map +7 -0
- package/dist/lib/browser/chunk-MUEVLYXJ.mjs +397 -0
- package/dist/lib/browser/chunk-MUEVLYXJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-PLDBKKYO.mjs +789 -0
- package/dist/lib/browser/chunk-PLDBKKYO.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q66L5EUR.mjs +20 -0
- package/dist/lib/browser/chunk-Q66L5EUR.mjs.map +7 -0
- package/dist/lib/browser/chunk-TW27W3EL.mjs +29 -0
- package/dist/lib/browser/chunk-TW27W3EL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EZVXV6DA.mjs → chunk-WYR4QHPE.mjs} +7 -2
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZYU2LP6U.mjs +11 -0
- package/dist/lib/browser/chunk-ZYU2LP6U.mjs.map +7 -0
- package/dist/lib/browser/compiler-53G6ZHQM.mjs +99 -0
- package/dist/lib/browser/compiler-53G6ZHQM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +120 -136
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-CYEISDDK.mjs +79 -0
- package/dist/lib/browser/operation-resolver-CYEISDDK.mjs.map +7 -0
- package/dist/lib/browser/react-surface-26P6HAFD.mjs +141 -0
- package/dist/lib/browser/react-surface-26P6HAFD.mjs.map +7 -0
- package/dist/lib/browser/settings-76UM7442.mjs +36 -0
- package/dist/lib/browser/settings-76UM7442.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +12 -6
- package/dist/lib/node-esm/DeploymentDialog-ZHPHEV2H.mjs +139 -0
- package/dist/lib/node-esm/DeploymentDialog-ZHPHEV2H.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-ZLWTNMQA.mjs +851 -0
- package/dist/lib/node-esm/NotebookContainer-ZLWTNMQA.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-S4UKQAWP.mjs +94 -0
- package/dist/lib/node-esm/ScriptContainer-S4UKQAWP.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptObjectSettings-C5QBRERY.mjs +295 -0
- package/dist/lib/node-esm/ScriptObjectSettings-C5QBRERY.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptPluginSettings-MFACDW4R.mjs +56 -0
- package/dist/lib/node-esm/ScriptPluginSettings-MFACDW4R.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptProperties-FMNIX3KU.mjs +29 -0
- package/dist/lib/node-esm/ScriptProperties-FMNIX3KU.mjs.map +7 -0
- package/dist/lib/node-esm/TestContainer-AO45YPGV.mjs +40 -0
- package/dist/lib/node-esm/TestContainer-AO45YPGV.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-5MGY6BRQ.mjs +18 -0
- package/dist/lib/node-esm/blueprint-definition-5MGY6BRQ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5BG7OJGQ.mjs +176 -0
- package/dist/lib/node-esm/chunk-5BG7OJGQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OG2SIKHE.mjs → chunk-5HSJPAK7.mjs} +7 -2
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-H46R2RS5.mjs +790 -0
- package/dist/lib/node-esm/chunk-H46R2RS5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JGN7TDJH.mjs +69 -0
- package/dist/lib/node-esm/chunk-JGN7TDJH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OQGBKNYU.mjs → chunk-QG6ANK4B.mjs} +34 -17
- package/dist/lib/node-esm/chunk-QG6ANK4B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-S7DSCLOW.mjs +31 -0
- package/dist/lib/node-esm/chunk-S7DSCLOW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TZ2EBTPQ.mjs +22 -0
- package/dist/lib/node-esm/chunk-TZ2EBTPQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UFBVE33O.mjs +12 -0
- package/dist/lib/node-esm/chunk-UFBVE33O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WWD5LUU6.mjs +114 -0
- package/dist/lib/node-esm/chunk-WWD5LUU6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZDJ2FI7E.mjs +398 -0
- package/dist/lib/node-esm/chunk-ZDJ2FI7E.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-HHQW7EP3.mjs +100 -0
- package/dist/lib/node-esm/compiler-HHQW7EP3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +120 -136
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-HFFDXWND.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-HFFDXWND.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-THCIK266.mjs +142 -0
- package/dist/lib/node-esm/react-surface-THCIK266.mjs.map +7 -0
- package/dist/lib/node-esm/settings-CCHDPLFJ.mjs +37 -0
- package/dist/lib/node-esm/settings-CCHDPLFJ.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +12 -6
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
- package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +7 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- 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 +8 -10
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +26 -8
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/index.d.ts +1 -0
- package/dist/types/src/components/NotebookStack/index.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/ScriptToolbar/ScriptToolbar.d.ts +8 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +27 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -7
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/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/{components → containers}/DeploymentDialog/DeploymentDialog.stories.d.ts +25 -6
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts +3 -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 +3 -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/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptObjectSettings/ScriptObjectSettings.d.ts +7 -0
- package/dist/types/src/containers/ScriptObjectSettings/ScriptObjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptObjectSettings/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptObjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptPluginSettings/ScriptPluginSettings.d.ts +8 -0
- package/dist/types/src/containers/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptPluginSettings/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptPluginSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts +3 -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 +3 -0
- package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +9 -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 +17 -31
- 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 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- 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/templates/anthropic.d.ts +8 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +16 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +16 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/forex-effect.d.ts +4 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +4 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +52 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +3 -0
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +2 -9
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +11 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +108 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +30 -48
- package/dist/types/src/types/actions.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +12 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +3 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +114 -79
- package/src/ScriptPlugin.tsx +44 -85
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +31 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -95
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +121 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +33 -0
- package/src/compiler/compiler.ts +10 -3
- package/src/components/FrameContainer/FrameContainer.tsx +6 -5
- package/src/components/FrameContainer/frame.html +21 -21
- package/src/components/NotebookStack/NotebookCell.tsx +215 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +33 -15
- package/src/components/NotebookStack/NotebookStack.tsx +55 -82
- package/src/components/NotebookStack/index.ts +1 -0
- package/src/components/QueryEditor/QueryEditor.stories.tsx +102 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +46 -23
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +28 -31
- package/src/components/TestPanel/TestPanel.tsx +61 -36
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +26 -25
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +70 -74
- package/src/components/index.ts +4 -9
- package/src/constants.ts +7 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +61 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +99 -0
- package/src/containers/DeploymentDialog/index.ts +7 -0
- package/src/containers/NotebookContainer/NotebookContainer.stories.tsx +87 -0
- package/src/containers/NotebookContainer/NotebookContainer.tsx +268 -0
- package/src/containers/NotebookContainer/index.ts +7 -0
- package/src/containers/ScriptContainer/ScriptContainer.tsx +84 -0
- package/src/containers/ScriptContainer/index.ts +7 -0
- package/src/{components/Settings → containers/ScriptObjectSettings}/ScriptObjectSettings.tsx +55 -50
- package/src/containers/ScriptObjectSettings/index.ts +7 -0
- package/src/{components/Settings → containers/ScriptPluginSettings}/ScriptPluginSettings.tsx +19 -14
- package/src/containers/ScriptPluginSettings/index.ts +7 -0
- package/src/containers/ScriptProperties/ScriptProperties.tsx +33 -0
- package/src/containers/ScriptProperties/index.ts +7 -0
- package/src/containers/TestContainer/TestContainer.tsx +28 -0
- package/src/containers/TestContainer/index.ts +7 -0
- package/src/containers/index.ts +13 -0
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +43 -35
- package/src/hooks/format.ts +8 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +22 -26
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -1
- package/src/meta.ts +8 -4
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/{notebook.ts → compute-graph.ts} +75 -33
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +1 -1
- package/src/notebook/vfs-parser.ts +43 -82
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +231 -0
- package/src/templates/data-generator.ts +1 -1
- package/src/templates/forex-effect.ts +22 -27
- package/src/templates/forex.ts +7 -6
- package/src/templates/gmail.ts +1 -2
- package/src/templates/index.ts +24 -11
- package/src/templates/ping.ts +17 -0
- package/src/testing/data.ts +43 -8
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +11 -3
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +23 -27
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +4 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +30 -40
- package/src/util/functions.ts +32 -28
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-7FNPALCV.mjs +0 -12
- package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs +0 -578
- package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-24LLLTLB.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-24LLLTLB.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-DXWTBOND.mjs +0 -282
- package/dist/lib/browser/chunk-DXWTBOND.mjs.map +0 -7
- package/dist/lib/browser/chunk-ETFBQURU.mjs +0 -254
- package/dist/lib/browser/chunk-ETFBQURU.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-I3THDIT5.mjs +0 -90
- package/dist/lib/browser/chunk-I3THDIT5.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-NNYSARXK.mjs +0 -153
- package/dist/lib/browser/chunk-NNYSARXK.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-SRSEZWDY.mjs +0 -646
- package/dist/lib/browser/chunk-SRSEZWDY.mjs.map +0 -7
- package/dist/lib/browser/chunk-SWBZUZDX.mjs +0 -80
- package/dist/lib/browser/chunk-SWBZUZDX.mjs.map +0 -7
- package/dist/lib/browser/chunk-VFJJA4WR.mjs +0 -88
- package/dist/lib/browser/chunk-VFJJA4WR.mjs.map +0 -7
- package/dist/lib/browser/compiler-G2N2CG63.mjs +0 -98
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FYZRLYNT.mjs +0 -105
- package/dist/lib/browser/intent-resolver-FYZRLYNT.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CFRYAL2P.mjs +0 -127
- package/dist/lib/browser/react-surface-CFRYAL2P.mjs.map +0 -7
- package/dist/lib/browser/settings-L3HCZRBP.mjs +0 -24
- package/dist/lib/browser/settings-L3HCZRBP.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-AKAGR37W.mjs +0 -13
- package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs +0 -579
- package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.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-5IKGUOMI.mjs +0 -154
- package/dist/lib/node-esm/chunk-5IKGUOMI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7MR2L4T3.mjs +0 -283
- package/dist/lib/node-esm/chunk-7MR2L4T3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C33FKUSC.mjs +0 -91
- package/dist/lib/node-esm/chunk-C33FKUSC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs +0 -16
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OQGBKNYU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PMQ3D535.mjs +0 -647
- package/dist/lib/node-esm/chunk-PMQ3D535.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U4CZGISN.mjs +0 -255
- package/dist/lib/node-esm/chunk-U4CZGISN.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-ZF5ULKED.mjs +0 -81
- package/dist/lib/node-esm/chunk-ZF5ULKED.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs +0 -99
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-6J3CFL5T.mjs +0 -106
- package/dist/lib/node-esm/intent-resolver-6J3CFL5T.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NPKEO7SA.mjs +0 -128
- package/dist/lib/node-esm/react-surface-NPKEO7SA.mjs.map +0 -7
- package/dist/lib/node-esm/settings-YWGZP4EW.mjs +0 -25
- package/dist/lib/node-esm/settings-YWGZP4EW.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +0 -1
- 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/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 -231
- 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 -39
- 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/templates/echo.d.ts +0 -6
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -35
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -65
- package/src/capabilities/blueprint-definition.ts +0 -30
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -34
- package/src/capabilities/intent-resolver.ts +0 -87
- package/src/capabilities/react-surface.tsx +0 -102
- package/src/capabilities/settings.ts +0 -21
- package/src/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/NotebookContainer.stories.tsx +0 -36
- package/src/components/NotebookContainer.tsx +0 -82
- package/src/components/ScriptContainer.tsx +0 -69
- 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 -38
- package/src/templates/chess.ts +0 -49
- package/src/templates/echo.ts +0 -8
- package/src/types/schema.ts +0 -42
- /package/dist/lib/browser/{DeploymentDialog-7FNPALCV.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-AKAGR37W.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -6,7 +6,18 @@ import { createSystem, createVirtualTypeScriptEnvironment } from '@typescript/vf
|
|
|
6
6
|
import ts from 'typescript';
|
|
7
7
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
import { builtIns, systemDefinitions } from './eval';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default system definitions.
|
|
14
|
+
*/
|
|
15
|
+
const systemFiles: VirtualFile[] = [
|
|
16
|
+
{
|
|
17
|
+
filename: '/lib.d.ts',
|
|
18
|
+
content: systemDefinitions,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
10
21
|
|
|
11
22
|
export type ParsedExpression = {
|
|
12
23
|
name?: string;
|
|
@@ -50,7 +61,7 @@ export class VirtualTypeScriptParser {
|
|
|
50
61
|
// If no declarations found, check for standalone expression references.
|
|
51
62
|
if (analysis.length === 0) {
|
|
52
63
|
const sourcefilename = '/temp.ts';
|
|
53
|
-
const env = this.createEnvironment([{ filename: sourcefilename, content: input }
|
|
64
|
+
const env = this.createEnvironment([{ filename: sourcefilename, content: input }]);
|
|
54
65
|
const sourceFile = env.getSourceFile(sourcefilename);
|
|
55
66
|
const typeChecker = env.languageService.getProgram()?.getTypeChecker();
|
|
56
67
|
|
|
@@ -73,7 +84,7 @@ export class VirtualTypeScriptParser {
|
|
|
73
84
|
* Analyze multiple files with full type information.
|
|
74
85
|
*/
|
|
75
86
|
analyzeFiles(files: VirtualFile[]): ParsedExpression[] {
|
|
76
|
-
const env = this.createEnvironment(
|
|
87
|
+
const env = this.createEnvironment(files);
|
|
77
88
|
const results: ParsedExpression[] = [];
|
|
78
89
|
const typeChecker = env.languageService.getProgram()?.getTypeChecker();
|
|
79
90
|
|
|
@@ -96,7 +107,7 @@ export class VirtualTypeScriptParser {
|
|
|
96
107
|
const results: ParsedExpression[] = [];
|
|
97
108
|
|
|
98
109
|
const visit = (node: ts.Node) => {
|
|
99
|
-
// Function declarations
|
|
110
|
+
// Function declarations.
|
|
100
111
|
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
101
112
|
const symbol = typeChecker.getSymbolAtLocation(node.name);
|
|
102
113
|
const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
@@ -123,7 +134,7 @@ export class VirtualTypeScriptParser {
|
|
|
123
134
|
let returnType: string | undefined;
|
|
124
135
|
let value: any;
|
|
125
136
|
|
|
126
|
-
// Get the type string
|
|
137
|
+
// Get the type string.
|
|
127
138
|
const typeString = type ? typeChecker.typeToString(type) : 'any';
|
|
128
139
|
|
|
129
140
|
// Check if it's a function.
|
|
@@ -146,7 +157,7 @@ export class VirtualTypeScriptParser {
|
|
|
146
157
|
}
|
|
147
158
|
}
|
|
148
159
|
|
|
149
|
-
// Find references in the initializer only
|
|
160
|
+
// Find references in the initializer only.
|
|
150
161
|
const refs = declaration.initializer
|
|
151
162
|
? this.findReferences(declaration.initializer, sourceFile, typeChecker)
|
|
152
163
|
: [];
|
|
@@ -164,7 +175,7 @@ export class VirtualTypeScriptParser {
|
|
|
164
175
|
});
|
|
165
176
|
}
|
|
166
177
|
|
|
167
|
-
// Class declarations
|
|
178
|
+
// Class declarations.
|
|
168
179
|
else if (ts.isClassDeclaration(node) && node.name) {
|
|
169
180
|
results.push({
|
|
170
181
|
name: node.name.text,
|
|
@@ -212,42 +223,42 @@ export class VirtualTypeScriptParser {
|
|
|
212
223
|
const localSymbols = new Set<string>();
|
|
213
224
|
|
|
214
225
|
// First, collect local symbols (parameters, local variables).
|
|
215
|
-
const collectLocalSymbols = (
|
|
216
|
-
if (ts.isFunctionDeclaration(
|
|
217
|
-
|
|
226
|
+
const collectLocalSymbols = (node: ts.Node) => {
|
|
227
|
+
if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
228
|
+
node.parameters.forEach((param) => {
|
|
218
229
|
if (ts.isIdentifier(param.name)) {
|
|
219
230
|
localSymbols.add(param.name.text);
|
|
220
231
|
}
|
|
221
232
|
});
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
if (ts.isVariableDeclaration(
|
|
225
|
-
localSymbols.add(
|
|
235
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name)) {
|
|
236
|
+
localSymbols.add(node.name.text);
|
|
226
237
|
}
|
|
227
238
|
|
|
228
|
-
ts.forEachChild(
|
|
239
|
+
ts.forEachChild(node, collectLocalSymbols);
|
|
229
240
|
};
|
|
230
241
|
|
|
231
242
|
collectLocalSymbols(node);
|
|
232
243
|
|
|
233
244
|
// Then find all identifier references.
|
|
234
|
-
const findRefs = (
|
|
235
|
-
if (ts.isIdentifier(
|
|
236
|
-
// Skip if it's a local symbol
|
|
237
|
-
if (!localSymbols.has(
|
|
245
|
+
const findRefs = (node: ts.Node) => {
|
|
246
|
+
if (ts.isIdentifier(node)) {
|
|
247
|
+
// Skip if it's a local symbol.
|
|
248
|
+
if (!localSymbols.has(node.text)) {
|
|
238
249
|
// Check if it's a reference (not a declaration).
|
|
239
|
-
const parent =
|
|
250
|
+
const parent = node.parent;
|
|
240
251
|
const isDeclaration =
|
|
241
|
-
(ts.isVariableDeclaration(parent) && parent.name ===
|
|
242
|
-
(ts.isFunctionDeclaration(parent) && parent.name ===
|
|
243
|
-
(ts.isParameter(parent) && parent.name ===
|
|
252
|
+
(ts.isVariableDeclaration(parent) && parent.name === node) ||
|
|
253
|
+
(ts.isFunctionDeclaration(parent) && parent.name === node) ||
|
|
254
|
+
(ts.isParameter(parent) && parent.name === node);
|
|
244
255
|
|
|
245
|
-
if (!isDeclaration && !this.isBuiltIn(
|
|
246
|
-
references.add(
|
|
256
|
+
if (!isDeclaration && !this.isBuiltIn(node.text)) {
|
|
257
|
+
references.add(node.text);
|
|
247
258
|
}
|
|
248
259
|
}
|
|
249
260
|
}
|
|
250
|
-
ts.forEachChild(
|
|
261
|
+
ts.forEachChild(node, findRefs);
|
|
251
262
|
};
|
|
252
263
|
|
|
253
264
|
findRefs(node);
|
|
@@ -274,7 +285,7 @@ export class VirtualTypeScriptParser {
|
|
|
274
285
|
const type = typeChecker.getTypeAtLocation(expr.right);
|
|
275
286
|
const typeString = typeChecker.typeToString(type);
|
|
276
287
|
|
|
277
|
-
// Get the literal value if it's a literal
|
|
288
|
+
// Get the literal value if it's a literal.
|
|
278
289
|
let value: any;
|
|
279
290
|
if (ts.isNumericLiteral(expr.right)) {
|
|
280
291
|
value = Number(expr.right.text);
|
|
@@ -282,7 +293,7 @@ export class VirtualTypeScriptParser {
|
|
|
282
293
|
value = expr.right.text;
|
|
283
294
|
}
|
|
284
295
|
|
|
285
|
-
// Find references in the right-hand side
|
|
296
|
+
// Find references in the right-hand side.
|
|
286
297
|
const references = this.findReferences(expr.right, sourceFile, typeChecker);
|
|
287
298
|
|
|
288
299
|
result = {
|
|
@@ -336,15 +347,17 @@ export class VirtualTypeScriptParser {
|
|
|
336
347
|
}
|
|
337
348
|
|
|
338
349
|
protected createEnvironment(files: VirtualFile[]) {
|
|
350
|
+
const allFiles = [...systemFiles, ...files];
|
|
351
|
+
|
|
339
352
|
const fileMap = new Map<string, string>();
|
|
340
|
-
|
|
353
|
+
allFiles.forEach(({ filename, content }) => {
|
|
341
354
|
fileMap.set(filename, content);
|
|
342
355
|
});
|
|
343
356
|
|
|
344
357
|
const system = createSystem(fileMap);
|
|
345
358
|
return createVirtualTypeScriptEnvironment(
|
|
346
359
|
system,
|
|
347
|
-
|
|
360
|
+
allFiles.map(({ filename }) => filename),
|
|
348
361
|
ts,
|
|
349
362
|
this.compilerOptions,
|
|
350
363
|
);
|
|
@@ -359,7 +372,7 @@ export class NotebookVirtualParser extends VirtualTypeScriptParser {
|
|
|
359
372
|
* Analyze notebook cells with full type checking.
|
|
360
373
|
*/
|
|
361
374
|
analyzeNotebook(cells: Array<{ id: string; code: string }>) {
|
|
362
|
-
// Create cumulative environment where each cell can see previous cells
|
|
375
|
+
// Create cumulative environment where each cell can see previous cells.
|
|
363
376
|
const cumulativeCode: string[] = [];
|
|
364
377
|
const cellAnalysis: Map<
|
|
365
378
|
string,
|
|
@@ -390,7 +403,7 @@ export class NotebookVirtualParser extends VirtualTypeScriptParser {
|
|
|
390
403
|
});
|
|
391
404
|
|
|
392
405
|
// Create environment.
|
|
393
|
-
const env = this.createEnvironment(
|
|
406
|
+
const env = this.createEnvironment(files);
|
|
394
407
|
|
|
395
408
|
// Get diagnostics (errors).
|
|
396
409
|
const diagnostics = env.languageService.getSemanticDiagnostics(filename);
|
|
@@ -436,55 +449,3 @@ export class NotebookVirtualParser extends VirtualTypeScriptParser {
|
|
|
436
449
|
return cellAnalysis;
|
|
437
450
|
}
|
|
438
451
|
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Globals.
|
|
442
|
-
*/
|
|
443
|
-
const builtIns = new Set([
|
|
444
|
-
// Types.
|
|
445
|
-
'Array',
|
|
446
|
-
'Date',
|
|
447
|
-
'Error',
|
|
448
|
-
'JSON',
|
|
449
|
-
'Map',
|
|
450
|
-
'Math',
|
|
451
|
-
'Number',
|
|
452
|
-
'Promise',
|
|
453
|
-
'Object',
|
|
454
|
-
'RegExp',
|
|
455
|
-
'Set',
|
|
456
|
-
'String',
|
|
457
|
-
|
|
458
|
-
// Functions.
|
|
459
|
-
'console',
|
|
460
|
-
'document',
|
|
461
|
-
'global',
|
|
462
|
-
'isFinite',
|
|
463
|
-
'isNaN',
|
|
464
|
-
'parseFloat',
|
|
465
|
-
'parseInt',
|
|
466
|
-
'process',
|
|
467
|
-
'window',
|
|
468
|
-
]);
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Default system definitions.
|
|
472
|
-
*/
|
|
473
|
-
const systemFiles: VirtualFile[] = [
|
|
474
|
-
{
|
|
475
|
-
filename: '/lib.d.ts',
|
|
476
|
-
content: trim`
|
|
477
|
-
interface Array<T> { length: number; [n: number]: T; }
|
|
478
|
-
interface Boolean {}
|
|
479
|
-
interface Function {}
|
|
480
|
-
interface IArguments {}
|
|
481
|
-
interface Number {}
|
|
482
|
-
interface Object {}
|
|
483
|
-
interface RegExp {}
|
|
484
|
-
interface String { length: number; }
|
|
485
|
-
interface CallableFunction extends Function {}
|
|
486
|
-
interface NewableFunction extends Function {}
|
|
487
|
-
declare var console: { log(...args: any[]): void };
|
|
488
|
-
`,
|
|
489
|
-
},
|
|
490
|
-
];
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { defineFunction } from '@dxos/functions';
|
|
13
|
+
|
|
14
|
+
export default defineFunction({
|
|
15
|
+
key: 'dxos.org/script/anthropic',
|
|
16
|
+
name: 'Anthropic Chat',
|
|
17
|
+
description: 'Chat with Anthropic',
|
|
18
|
+
inputSchema: Schema.Struct({
|
|
19
|
+
message: Schema.String,
|
|
20
|
+
}),
|
|
21
|
+
services: [AiService.AiService],
|
|
22
|
+
handler: ({ data }) => {
|
|
23
|
+
return Effect.gen(function* () {
|
|
24
|
+
const model = (yield* AiService.AiService).model('@anthropic/claude-sonnet-4-5');
|
|
25
|
+
//
|
|
26
|
+
// Basic example.
|
|
27
|
+
//
|
|
28
|
+
const { text } = yield* LanguageModel.generateText({ prompt: data.message }).pipe(Effect.provide(model));
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// Streaming example.
|
|
32
|
+
//
|
|
33
|
+
const parts = yield* LanguageModel.streamText({
|
|
34
|
+
prompt: 'Count from 1 to 5, one number per line.',
|
|
35
|
+
}).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));
|
|
36
|
+
const textDeltas = parts.filter((p) => p.type === 'text-delta');
|
|
37
|
+
const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');
|
|
38
|
+
|
|
39
|
+
return { response: text, streamText: fullText };
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { Database, Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { defineFunction } from '@dxos/functions';
|
|
11
|
+
import { Chess } from '@dxos/plugin-chess/types';
|
|
12
|
+
|
|
13
|
+
export default defineFunction({
|
|
14
|
+
key: 'dxos.org/script/chess-bot',
|
|
15
|
+
name: 'Chess Bot',
|
|
16
|
+
description: 'Plays a random move in a chess game.',
|
|
17
|
+
|
|
18
|
+
inputSchema: Schema.Struct({
|
|
19
|
+
game: Ref.Ref(Chess.Game).annotations({
|
|
20
|
+
description: 'The chess game to comment on.',
|
|
21
|
+
}),
|
|
22
|
+
player: Schema.optional(Schema.Literal('white', 'black')).annotations({
|
|
23
|
+
description: 'The player to play the game as.',
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
26
|
+
|
|
27
|
+
outputSchema: Schema.Struct({
|
|
28
|
+
state: Schema.String.annotations({
|
|
29
|
+
description: 'The state of the game as an ASCII art board.',
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
|
|
33
|
+
types: [Chess.Game],
|
|
34
|
+
services: [Database.Service],
|
|
35
|
+
|
|
36
|
+
handler: Effect.fnUntraced(function* ({ data: { game, player = 'black' } }) {
|
|
37
|
+
const loadedGame = yield* Database.load(game);
|
|
38
|
+
const chess = new ChessJS();
|
|
39
|
+
chess.loadPgn(loadedGame.pgn ?? '');
|
|
40
|
+
if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {
|
|
41
|
+
return { state: chess.ascii() };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const moves = chess.moves({ verbose: true });
|
|
45
|
+
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
46
|
+
if (!move) {
|
|
47
|
+
return { state: chess.ascii() };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
chess.move(move.san);
|
|
51
|
+
const newPgn = chess.pgn();
|
|
52
|
+
Obj.change(loadedGame, (g) => {
|
|
53
|
+
g.pgn = newPgn;
|
|
54
|
+
});
|
|
55
|
+
yield* Database.flush();
|
|
56
|
+
return { state: chess.ascii() };
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
@@ -0,0 +1,231 @@
|
|
|
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 { AiSession, GenerationObserver } from '@dxos/assistant';
|
|
16
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
17
|
+
import { Database, Filter, Obj, Ref, Relation } from '@dxos/echo';
|
|
18
|
+
import { Collection } from '@dxos/echo';
|
|
19
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
20
|
+
import { TracingService, defineFunction } from '@dxos/functions';
|
|
21
|
+
import { log } from '@dxos/log';
|
|
22
|
+
import { Chess } from '@dxos/plugin-chess/types';
|
|
23
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
24
|
+
import { Text } from '@dxos/schema';
|
|
25
|
+
import { HasSubject } from '@dxos/types';
|
|
26
|
+
import { trim } from '@dxos/util';
|
|
27
|
+
|
|
28
|
+
export default defineFunction({
|
|
29
|
+
key: 'dxos.org/function/chess/commentary',
|
|
30
|
+
name: 'Commentary',
|
|
31
|
+
description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',
|
|
32
|
+
inputSchema: Schema.Struct({
|
|
33
|
+
game: Ref.Ref(Chess.Game).annotations({
|
|
34
|
+
description: 'The chess game to comment on.',
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
outputSchema: Schema.Union(
|
|
38
|
+
Schema.Struct({
|
|
39
|
+
documentId: ArtifactId.annotations({
|
|
40
|
+
description: 'The ID of the markdown document that was updated or created.',
|
|
41
|
+
}),
|
|
42
|
+
commentary: Schema.String.annotations({
|
|
43
|
+
description: 'The commentary that was added.',
|
|
44
|
+
}),
|
|
45
|
+
}),
|
|
46
|
+
Schema.Void.annotations({
|
|
47
|
+
description: 'Function did not find anything to comment on.',
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
types: [Chess.Game, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],
|
|
51
|
+
services: [AiService.AiService, Database.Service],
|
|
52
|
+
handler: Effect.fnUntraced(
|
|
53
|
+
function* ({ data: { game: gameRef } }) {
|
|
54
|
+
// Load the chess game
|
|
55
|
+
log.info('load game', { gameRef });
|
|
56
|
+
const chessGame = yield* Database.load(gameRef);
|
|
57
|
+
|
|
58
|
+
// Load the chess position from PGN or FEN
|
|
59
|
+
const chess = new ChessJS();
|
|
60
|
+
if (chessGame.pgn) {
|
|
61
|
+
chess.loadPgn(chessGame.pgn);
|
|
62
|
+
} else if (chessGame.fen) {
|
|
63
|
+
chess.load(chessGame.fen);
|
|
64
|
+
} else {
|
|
65
|
+
log.info('Early return: no pgn or fen');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Get the most recent move
|
|
70
|
+
const history = chess.history({ verbose: true });
|
|
71
|
+
if (history.length === 0) {
|
|
72
|
+
throw new Error('No moves have been played yet');
|
|
73
|
+
}
|
|
74
|
+
const lastMove = history[history.length - 1];
|
|
75
|
+
const moveNumber = Math.ceil(history.length / 2);
|
|
76
|
+
const isWhiteMove = history.length % 2 === 1;
|
|
77
|
+
const player = isWhiteMove ? 'White' : 'Black';
|
|
78
|
+
const moveNotation = lastMove.san;
|
|
79
|
+
|
|
80
|
+
// Generate AI commentary about the move
|
|
81
|
+
const result = yield* new AiSession().run({
|
|
82
|
+
prompt:
|
|
83
|
+
`Comment on this chess move as if you're commentating a live match for an audience:\n\n` +
|
|
84
|
+
`Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\n` +
|
|
85
|
+
`Current position: ${chess.fen()}\n` +
|
|
86
|
+
`${chess.isCheck() ? 'The king is in check! ' : ''}` +
|
|
87
|
+
`${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +
|
|
88
|
+
`${chess.isStalemate() ? 'STALEMATE! ' : ''}` +
|
|
89
|
+
`\nGame so far:\n${chess.pgn()}`,
|
|
90
|
+
system: COMMENTARY_SYSTEM_PROMPT,
|
|
91
|
+
history: [],
|
|
92
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const commentaryText = Function.pipe(
|
|
96
|
+
result,
|
|
97
|
+
Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
|
|
98
|
+
Option.flatMap((msg) =>
|
|
99
|
+
Function.pipe(
|
|
100
|
+
msg.blocks,
|
|
101
|
+
Array.findLast((block) => block._tag === 'text'),
|
|
102
|
+
Option.map((block) => block.text),
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
Option.getOrThrowWith(() => new Error('No commentary generated')),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\n\n${commentaryText}\n\n`;
|
|
109
|
+
log.info('commentary', { commentary });
|
|
110
|
+
|
|
111
|
+
// TODO(wittjosiah): Functions currently don't support traversals.
|
|
112
|
+
// const docs = yield* Database.runQuery(
|
|
113
|
+
// Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),
|
|
114
|
+
// ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));
|
|
115
|
+
const docs = yield* Database.runQuery(Filter.type(HasSubject.HasSubject)).pipe(
|
|
116
|
+
Effect.map((relations) =>
|
|
117
|
+
relations.filter((relation) => {
|
|
118
|
+
// TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.
|
|
119
|
+
try {
|
|
120
|
+
log.info('relation', {
|
|
121
|
+
source: Obj.getDXN(Relation.getTarget(relation)).toString(),
|
|
122
|
+
game: Obj.getDXN(chessGame).toString(),
|
|
123
|
+
});
|
|
124
|
+
return Obj.getDXN(Relation.getTarget(relation)).toString() === Obj.getDXN(chessGame).toString();
|
|
125
|
+
} catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
),
|
|
130
|
+
Effect.map((relations) =>
|
|
131
|
+
relations
|
|
132
|
+
.map((relation) => {
|
|
133
|
+
// TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.
|
|
134
|
+
try {
|
|
135
|
+
return Relation.getSource(relation);
|
|
136
|
+
} catch {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.filter((source) => source !== undefined),
|
|
141
|
+
),
|
|
142
|
+
Effect.map((sources) => {
|
|
143
|
+
const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));
|
|
144
|
+
log.info('docs', { sources, docs });
|
|
145
|
+
return docs;
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
log.info('docs', { count: docs.length });
|
|
149
|
+
|
|
150
|
+
let document: Markdown.Document;
|
|
151
|
+
if (docs.length === 0) {
|
|
152
|
+
// TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.
|
|
153
|
+
const [properties] = yield* Database.runQuery(Filter.typename('dxos.org/type/Properties'));
|
|
154
|
+
const rootCollection = yield* Database.load<Collection.Collection>(properties[Collection.Collection.typename]);
|
|
155
|
+
|
|
156
|
+
log.info('rootCollection', { rootCollection });
|
|
157
|
+
|
|
158
|
+
// Create a new markdown document
|
|
159
|
+
const gameName = chessGame.name || 'Chess Game';
|
|
160
|
+
document = yield* Database.add(
|
|
161
|
+
Markdown.make({
|
|
162
|
+
name: `${gameName} Commentary`,
|
|
163
|
+
content: `# ${gameName} Commentary\n\n${commentary}`,
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const documentRef = Ref.make(document);
|
|
168
|
+
Obj.change(rootCollection, (c) => {
|
|
169
|
+
c.objects.push(documentRef);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Create the HasSubject relation
|
|
173
|
+
yield* Database.add(
|
|
174
|
+
Relation.make(HasSubject.HasSubject, {
|
|
175
|
+
[Relation.Source]: document,
|
|
176
|
+
[Relation.Target]: chessGame,
|
|
177
|
+
completedAt: new Date().toISOString(),
|
|
178
|
+
}),
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
document = docs[0];
|
|
182
|
+
|
|
183
|
+
// Load the text content and append the commentary
|
|
184
|
+
const text = yield* Database.load(document.content);
|
|
185
|
+
const accessor = createDocAccessor(text, ['content']);
|
|
186
|
+
accessor.handle.change((doc: A.Doc<Text.Text>) => {
|
|
187
|
+
A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
log.info('result', { documentId: Obj.getDXN(document).toString(), commentary });
|
|
192
|
+
|
|
193
|
+
yield* Database.flush();
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
documentId: Obj.getDXN(document).toString(),
|
|
197
|
+
commentary,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
Effect.provide(
|
|
201
|
+
Layer.mergeAll(
|
|
202
|
+
AiService.model('@anthropic/claude-haiku-4-5'),
|
|
203
|
+
ToolResolverService.layerEmpty,
|
|
204
|
+
ToolExecutionService.layerEmpty,
|
|
205
|
+
TracingService.layerNoop,
|
|
206
|
+
),
|
|
207
|
+
),
|
|
208
|
+
),
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const COMMENTARY_SYSTEM_PROMPT = trim`
|
|
212
|
+
You are a professional chess commentator providing live commentary for a chess match.
|
|
213
|
+
|
|
214
|
+
# Style
|
|
215
|
+
- Write in an engaging, enthusiastic style as if commentating for a live audience
|
|
216
|
+
- Be concise but informative (2-4 sentences)
|
|
217
|
+
- Explain the strategic implications of the move
|
|
218
|
+
- Note any tactical elements (captures, threats, checks)
|
|
219
|
+
- Comment on the position and what it means for the game
|
|
220
|
+
|
|
221
|
+
# Format
|
|
222
|
+
- Write in plain text (no markdown formatting in the commentary itself)
|
|
223
|
+
- Be natural and conversational
|
|
224
|
+
- Use chess terminology appropriately but keep it accessible
|
|
225
|
+
|
|
226
|
+
# Special Situations
|
|
227
|
+
- If it's checkmate, express excitement about the conclusion
|
|
228
|
+
- If it's check, note the pressure on the king
|
|
229
|
+
- If a piece is captured, mention the material exchange
|
|
230
|
+
- Comment on the development of pieces and control of key squares when relevant
|
|
231
|
+
`;
|
|
@@ -23,7 +23,7 @@ export default defineFunction({
|
|
|
23
23
|
data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
|
|
24
24
|
context: { space },
|
|
25
25
|
}: any) => {
|
|
26
|
-
await space.db.graph.schemaRegistry.
|
|
26
|
+
await space.db.graph.schemaRegistry.register([Expando]);
|
|
27
27
|
const result: Record<string, any> = {};
|
|
28
28
|
const objects: Expando[] = [];
|
|
29
29
|
|
|
@@ -2,41 +2,36 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?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';
|
|
11
|
+
|
|
12
|
+
import { defineFunction } from '@dxos/functions';
|
|
17
13
|
|
|
18
14
|
export default defineFunction({
|
|
19
15
|
key: 'dxos.org/script/forex-effect',
|
|
20
16
|
name: 'Forex Effect',
|
|
21
17
|
description: 'Returns the exchange rate between two currencies.',
|
|
22
18
|
|
|
23
|
-
inputSchema:
|
|
24
|
-
from:
|
|
25
|
-
to:
|
|
19
|
+
inputSchema: Schema.Struct({
|
|
20
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
21
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
26
22
|
}),
|
|
27
23
|
|
|
28
|
-
outputSchema:
|
|
24
|
+
outputSchema: Schema.String.annotations({ description: 'The exchange rate between the two currencies' }),
|
|
29
25
|
|
|
30
|
-
handler:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
26
|
+
handler: Effect.fnUntraced(function* ({ data: { from, to } }) {
|
|
27
|
+
const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
|
|
28
|
+
HttpClient.execute,
|
|
29
|
+
Effect.flatMap((res: any) => res.json),
|
|
30
|
+
Effect.timeout('5 seconds'),
|
|
31
|
+
Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
|
|
32
|
+
Effect.scoped,
|
|
33
|
+
);
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
return (res as any).data.rates[to].toString();
|
|
36
|
+
}, Effect.provide(FetchHttpClient.layer)),
|
|
42
37
|
});
|
package/src/templates/forex.ts
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { defineFunction } from '@dxos/functions';
|
|
7
8
|
|
|
8
9
|
export default defineFunction({
|
|
9
10
|
key: 'dxos.org/script/forex',
|
|
10
11
|
name: 'Forex',
|
|
11
12
|
description: 'Returns the exchange rate between two currencies.',
|
|
12
13
|
|
|
13
|
-
inputSchema:
|
|
14
|
-
from:
|
|
15
|
-
to:
|
|
14
|
+
inputSchema: Schema.Struct({
|
|
15
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
16
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
16
17
|
}),
|
|
17
18
|
|
|
18
|
-
handler: async ({ data: { from, to } }
|
|
19
|
+
handler: async ({ data: { from, to } }) => {
|
|
19
20
|
const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);
|
|
20
21
|
const {
|
|
21
22
|
data: { rates },
|