@dxos/plugin-script 0.8.4-main.66e292d → 0.8.4-main.69d29f4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-OSL6RMPA.mjs +14 -0
- package/dist/lib/browser/{NotebookContainer-MHY3DXDE.mjs → NotebookContainer-NBAXYESH.mjs} +266 -238
- package/dist/lib/browser/NotebookContainer-NBAXYESH.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-WD33CJMI.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-WD33CJMI.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs +68 -0
- package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs +17 -0
- package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-BTWHM6FH.mjs +270 -0
- package/dist/lib/browser/chunk-BTWHM6FH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ULJFT73Q.mjs → chunk-C53UJGSU.mjs} +232 -188
- package/dist/lib/browser/chunk-C53UJGSU.mjs.map +7 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
- package/dist/lib/browser/chunk-TWX2NMZN.mjs +137 -0
- package/dist/lib/browser/chunk-TWX2NMZN.mjs.map +7 -0
- package/dist/lib/browser/chunk-UUR4JNNB.mjs +113 -0
- package/dist/lib/browser/chunk-UUR4JNNB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2G2NA6DQ.mjs → chunk-UX4GHJ5E.mjs} +28 -11
- package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EB6AXFXO.mjs → chunk-WYR4QHPE.mjs} +1 -1
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/chunk-XCN4D3Z5.mjs +606 -0
- package/dist/lib/browser/chunk-XCN4D3Z5.mjs.map +7 -0
- package/dist/lib/browser/compiler-76F3QAXC.mjs +161 -0
- package/dist/lib/browser/compiler-76F3QAXC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +92 -116
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-HUILPPKT.mjs +82 -0
- package/dist/lib/browser/operation-resolver-HUILPPKT.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-R245YN52.mjs → react-surface-O6GKHB2J.mjs} +53 -42
- package/dist/lib/browser/react-surface-O6GKHB2J.mjs.map +7 -0
- package/dist/lib/browser/settings-3ENI25PI.mjs +35 -0
- package/dist/lib/browser/settings-3ENI25PI.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +9 -5
- package/dist/lib/node-esm/{DeploymentDialog-2ULNOZQH.mjs → DeploymentDialog-OGBJPVIX.mjs} +6 -6
- package/dist/lib/node-esm/DeploymentDialog-OGBJPVIX.mjs.map +7 -0
- package/dist/lib/node-esm/{NotebookContainer-U4C2HQ4T.mjs → NotebookContainer-IUAYVJSD.mjs} +266 -238
- package/dist/lib/node-esm/NotebookContainer-IUAYVJSD.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-K7JCEU5Z.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-K7JCEU5Z.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs +69 -0
- package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs +18 -0
- package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.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-57JA6XL5.mjs → chunk-4F5FJZ36.mjs} +28 -11
- package/dist/lib/node-esm/chunk-4F5FJZ36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4QNZMXW6.mjs +607 -0
- package/dist/lib/node-esm/chunk-4QNZMXW6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IBV2DR36.mjs → chunk-5HSJPAK7.mjs} +1 -1
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VJSRZRLI.mjs → chunk-BX5PP6AW.mjs} +232 -188
- package/dist/lib/node-esm/chunk-BX5PP6AW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-G3J76DWP.mjs +114 -0
- package/dist/lib/node-esm/chunk-G3J76DWP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VQPIA4VF.mjs +138 -0
- package/dist/lib/node-esm/chunk-VQPIA4VF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VWOLKNMO.mjs +271 -0
- package/dist/lib/node-esm/chunk-VWOLKNMO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-FNZH6TFN.mjs +162 -0
- package/dist/lib/node-esm/compiler-FNZH6TFN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +92 -116
- 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-JTCIY6HU.mjs +83 -0
- package/dist/lib/node-esm/operation-resolver-JTCIY6HU.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-MHT3PJ6C.mjs → react-surface-RLANMVMB.mjs} +53 -42
- package/dist/lib/node-esm/react-surface-RLANMVMB.mjs.map +7 -0
- package/dist/lib/node-esm/settings-7AYC5VXN.mjs +36 -0
- package/dist/lib/node-esm/settings-7AYC5VXN.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +9 -5
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -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 +9 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +1 -3
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +3 -5
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -250
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +3 -3
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +2 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +4 -5
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +2 -2
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +2 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +4 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +3 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/e2e/ai.test.d.ts +2 -0
- package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
- package/dist/types/src/e2e/deploy.test.d.ts +2 -0
- package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +9 -26
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -2
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts +7 -0
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +24 -11
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
- package/dist/types/src/templates/anthropic.d.ts +8 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +16 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +16 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/forex-effect.d.ts +4 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +4 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +12 -3
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +1 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/types/Notebook.d.ts +88 -19
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- package/dist/types/src/types/actions.d.ts +30 -44
- 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 +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +113 -88
- package/src/ScriptPlugin.tsx +34 -60
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +24 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +55 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -94
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -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 +74 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +118 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +32 -0
- package/src/compiler/compiler.ts +10 -3
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +27 -23
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +22 -42
- package/src/components/FrameContainer/FrameContainer.tsx +4 -2
- package/src/components/NotebookContainer.stories.tsx +23 -19
- package/src/components/NotebookContainer.tsx +51 -40
- package/src/components/NotebookStack/NotebookCell.tsx +16 -15
- package/src/components/NotebookStack/NotebookStack.stories.tsx +19 -18
- package/src/components/NotebookStack/NotebookStack.tsx +4 -4
- package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptContainer.tsx +46 -32
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +38 -15
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -17
- package/src/components/Settings/ScriptObjectSettings.tsx +40 -29
- package/src/components/Settings/ScriptPluginSettings.tsx +8 -3
- package/src/components/TestPanel/TestContainer.tsx +5 -5
- package/src/components/TestPanel/TestPanel.tsx +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +12 -7
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -68
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +33 -26
- package/src/hooks/format.ts +5 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +15 -9
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +13 -19
- package/src/hooks/useToolbarState.ts +29 -5
- package/src/index.ts +1 -1
- package/src/meta.ts +2 -2
- package/src/notebook/compute-graph.test.ts +20 -8
- package/src/notebook/compute-graph.ts +45 -21
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +232 -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/index.ts +18 -5
- package/src/templates/ping.ts +14 -5
- package/src/testing/simulator.test.ts +40 -0
- package/src/types/Notebook.ts +7 -8
- package/src/types/actions.ts +17 -25
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/types.ts +1 -1
- package/src/util/deploy.ts +19 -25
- package/src/util/functions.ts +24 -22
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-5TKNGPVR.mjs +0 -14
- package/dist/lib/browser/NotebookContainer-MHY3DXDE.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.mjs +0 -148
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs +0 -66
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +0 -30
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +0 -7
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ALS6X4HU.mjs +0 -304
- package/dist/lib/browser/chunk-ALS6X4HU.mjs.map +0 -7
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
- package/dist/lib/browser/chunk-M6KJPUJK.mjs +0 -111
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +0 -7
- package/dist/lib/browser/chunk-N5EYLQOT.mjs +0 -647
- package/dist/lib/browser/chunk-N5EYLQOT.mjs.map +0 -7
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs +0 -103
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs.map +0 -7
- package/dist/lib/browser/chunk-SAN5Y7FI.mjs +0 -155
- package/dist/lib/browser/chunk-SAN5Y7FI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ULJFT73Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs +0 -15
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs.map +0 -7
- package/dist/lib/browser/compiler-4KHRSX7J.mjs +0 -86
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TXTBWOVD.mjs +0 -104
- package/dist/lib/browser/intent-resolver-TXTBWOVD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-R245YN52.mjs.map +0 -7
- package/dist/lib/browser/settings-MHJXRGDF.mjs +0 -26
- package/dist/lib/browser/settings-MHJXRGDF.mjs.map +0 -7
- package/dist/lib/node-esm/NotebookContainer-U4C2HQ4T.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.mjs +0 -149
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs +0 -67
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +0 -31
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs +0 -16
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +0 -113
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ND4BPYPR.mjs +0 -156
- package/dist/lib/node-esm/chunk-ND4BPYPR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UEVZP5DN.mjs +0 -648
- package/dist/lib/node-esm/chunk-UEVZP5DN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VJSRZRLI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs +0 -305
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs +0 -104
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs +0 -87
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-D6AVAQRA.mjs +0 -105
- package/dist/lib/node-esm/intent-resolver-D6AVAQRA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-MHT3PJ6C.mjs.map +0 -7
- package/dist/lib/node-esm/settings-BVJORMMJ.mjs +0 -27
- package/dist/lib/node-esm/settings-BVJORMMJ.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.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 -86
- package/src/capabilities/react-surface.tsx +0 -103
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -49
- /package/dist/lib/browser/{DeploymentDialog-5TKNGPVR.mjs.map → DeploymentDialog-OSL6RMPA.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-2ULNOZQH.mjs.map → browser/blueprints/index.mjs.map} +0 -0
package/src/hooks/deploy.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type Client, useClient } from '@dxos/react-client';
|
|
|
11
11
|
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
12
|
import { type TFunction } from '@dxos/react-ui';
|
|
13
13
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
14
|
-
import { errorMessageColors } from '@dxos/
|
|
14
|
+
import { errorMessageColors } from '@dxos/ui-theme';
|
|
15
15
|
|
|
16
16
|
import { meta } from '../meta';
|
|
17
17
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
@@ -25,8 +25,10 @@ export type DeployState = {
|
|
|
25
25
|
error: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
import { type ScriptToolbarStateStore } from './useToolbarState';
|
|
29
|
+
|
|
28
30
|
export type CreateDeployOptions = {
|
|
29
|
-
state:
|
|
31
|
+
state: ScriptToolbarStateStore;
|
|
30
32
|
script: Script.Script;
|
|
31
33
|
fn: Function.Function;
|
|
32
34
|
space?: Space;
|
|
@@ -36,12 +38,14 @@ export type CreateDeployOptions = {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
41
|
+
const { value } = state;
|
|
42
|
+
|
|
39
43
|
// TODO(wittjosiah): Should this be an action?
|
|
40
44
|
const errorItem = createMenuAction('error', () => {}, {
|
|
41
|
-
label:
|
|
45
|
+
label: value.error ?? ['no error label', { ns: meta.id }],
|
|
42
46
|
icon: 'ph--warning-circle--regular',
|
|
43
|
-
hidden: !
|
|
44
|
-
classNames:
|
|
47
|
+
hidden: !value.error,
|
|
48
|
+
classNames: value.error && errorMessageColors,
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
const deployAction = createMenuAction<DeployActionProperties>(
|
|
@@ -51,39 +55,39 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
state.error
|
|
55
|
-
state.deploying
|
|
58
|
+
state.set('error', undefined);
|
|
59
|
+
state.set('deploying', true);
|
|
56
60
|
|
|
57
61
|
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
58
62
|
|
|
59
63
|
if (!result.success) {
|
|
60
64
|
log.catch(result.error);
|
|
61
|
-
state.error
|
|
65
|
+
state.set('error', t('upload failed label'));
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
state.deploying
|
|
68
|
+
state.set('deploying', false);
|
|
65
69
|
},
|
|
66
70
|
{
|
|
67
71
|
type: 'deploy',
|
|
68
|
-
label: [
|
|
69
|
-
icon:
|
|
70
|
-
disabled:
|
|
71
|
-
classNames:
|
|
72
|
+
label: [value.deploying ? 'publishing label' : 'deploy label', { ns: meta.id }],
|
|
73
|
+
icon: value.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
74
|
+
disabled: value.deploying,
|
|
75
|
+
classNames: value.deploying ? '[&_svg]:animate-spin' : '',
|
|
72
76
|
},
|
|
73
77
|
);
|
|
74
78
|
|
|
75
79
|
const copyAction = createMenuAction<DeployActionProperties>(
|
|
76
80
|
'copy',
|
|
77
81
|
async () => {
|
|
78
|
-
if (
|
|
79
|
-
await navigator.clipboard.writeText(
|
|
82
|
+
if (value.functionUrl) {
|
|
83
|
+
await navigator.clipboard.writeText(value.functionUrl);
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
{
|
|
83
87
|
type: 'copy',
|
|
84
88
|
label: ['copy link label', { ns: meta.id }],
|
|
85
89
|
icon: 'ph--link--regular',
|
|
86
|
-
disabled: !
|
|
90
|
+
disabled: !value.functionUrl,
|
|
87
91
|
},
|
|
88
92
|
);
|
|
89
93
|
|
|
@@ -97,29 +101,32 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
97
101
|
};
|
|
98
102
|
};
|
|
99
103
|
|
|
100
|
-
export const useDeployState = ({ state, script }: { state:
|
|
104
|
+
export const useDeployState = ({ state, script }: { state: ScriptToolbarStateStore; script: Script.Script }) => {
|
|
101
105
|
const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
102
106
|
useEffect(() => {
|
|
103
107
|
if (!existingFunctionId) {
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
state.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
state.set(
|
|
112
|
+
'functionUrl',
|
|
113
|
+
getFunctionUrl({
|
|
114
|
+
script,
|
|
115
|
+
fn,
|
|
116
|
+
edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
}, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url, state]);
|
|
113
120
|
|
|
114
121
|
useEffect(() => {
|
|
115
|
-
state.deployed
|
|
116
|
-
}, [script.changed, existingFunctionId, fn, script]);
|
|
122
|
+
state.set('deployed', isScriptDeployed({ script, fn }));
|
|
123
|
+
}, [script.changed, existingFunctionId, fn, script, state]);
|
|
117
124
|
};
|
|
118
125
|
|
|
119
126
|
export const useDeployDeps = ({ script }: { script: Script.Script }) => {
|
|
120
127
|
const client = useClient();
|
|
121
128
|
const space = getSpace(script);
|
|
122
|
-
const [fn] = useQuery(space, Query.type(Function.Function, { source: Ref.make(script) }));
|
|
129
|
+
const [fn] = useQuery(space?.db, Query.type(Function.Function, { source: Ref.make(script) }));
|
|
123
130
|
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
|
|
124
131
|
return { client, space, fn, existingFunctionId };
|
|
125
132
|
};
|
package/src/hooks/format.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { format } from 'prettier';
|
|
|
6
6
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
7
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
8
8
|
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { type Script } from '@dxos/functions';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
@@ -23,12 +24,15 @@ export const createFormat = (script: Script.Script) => {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
+
const formatted = await format(script.source.target!.content, {
|
|
27
28
|
parser: 'typescript',
|
|
28
29
|
plugins: [prettierPluginEstree, prettierPluginTypescript],
|
|
29
30
|
semi: true,
|
|
30
31
|
singleQuote: true,
|
|
31
32
|
});
|
|
33
|
+
Obj.change(script.source.target!, (s) => {
|
|
34
|
+
s.content = formatted;
|
|
35
|
+
});
|
|
32
36
|
} catch (err: any) {
|
|
33
37
|
// TODO(wittjosiah): Show error in UI.
|
|
34
38
|
log.catch(err);
|
package/src/hooks/index.ts
CHANGED
package/src/hooks/template.ts
CHANGED
|
@@ -15,15 +15,21 @@ const createTemplateSelectActions = (script: Script.Script) => {
|
|
|
15
15
|
return createMenuAction<TemplateActionProperties>(
|
|
16
16
|
`template--${template.id}`,
|
|
17
17
|
() => {
|
|
18
|
-
script
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
Obj.change(script, (s) => {
|
|
19
|
+
s.name = template.name;
|
|
20
|
+
const meta = Obj.getMeta(s);
|
|
21
|
+
const oldPresetIndex = meta.keys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
|
|
22
|
+
if (oldPresetIndex >= 0) {
|
|
23
|
+
meta.keys.splice(oldPresetIndex, 1);
|
|
24
|
+
}
|
|
25
|
+
if ('presetId' in template) {
|
|
26
|
+
meta.keys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (script.source?.target) {
|
|
30
|
+
Obj.change(script.source.target, (s) => {
|
|
31
|
+
s.content = template.source;
|
|
32
|
+
});
|
|
27
33
|
}
|
|
28
34
|
},
|
|
29
35
|
{
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCapabilities, usePluginManager } from '@dxos/app-framework/react';
|
|
6
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
7
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
import type { Compiler } from '../compiler';
|
|
10
|
+
import { ScriptEvents } from '../types';
|
|
11
|
+
import { ScriptCapabilities } from '../types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Asynchronously sets up the compiler and returns it.
|
|
15
|
+
* @returns The compiler instance or undefined if it is not ready.
|
|
16
|
+
*/
|
|
17
|
+
export const useCompiler = (): Compiler | undefined => {
|
|
18
|
+
const manager = usePluginManager();
|
|
19
|
+
useAsyncEffect(async () => {
|
|
20
|
+
await manager.activate(ScriptEvents.SetupCompiler).pipe(runAndForwardErrors);
|
|
21
|
+
}, [manager]);
|
|
22
|
+
const [compiler] = useCapabilities(ScriptCapabilities.Compiler);
|
|
23
|
+
return compiler;
|
|
24
|
+
};
|
|
@@ -2,20 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Function from 'effect/Function';
|
|
6
5
|
import { useCallback, useState } from 'react';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
import { useIntentDispatcher } from '@dxos/app-framework/react';
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
10
8
|
import { Obj } from '@dxos/echo';
|
|
11
9
|
import { Script } from '@dxos/functions';
|
|
12
10
|
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import {
|
|
11
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
12
|
import { useClient } from '@dxos/react-client';
|
|
15
13
|
import { type Space } from '@dxos/react-client/echo';
|
|
16
14
|
|
|
17
15
|
import { type Template } from '../templates';
|
|
18
|
-
import {
|
|
16
|
+
import { ScriptOperation } from '../types';
|
|
19
17
|
import { deployScript } from '../util';
|
|
20
18
|
|
|
21
19
|
type DeploymentStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
@@ -28,7 +26,7 @@ type DeploymentStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
|
28
26
|
* All creation / deployment operations run concurrently for improved performance.
|
|
29
27
|
*/
|
|
30
28
|
export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scriptTemplates: Template[]) => {
|
|
31
|
-
const {
|
|
29
|
+
const { invokePromise } = useOperationInvoker();
|
|
32
30
|
const client = useClient();
|
|
33
31
|
const [status, setStatus] = useState<DeploymentStatus>('idle');
|
|
34
32
|
const [error, setError] = useState<Error | undefined>(undefined);
|
|
@@ -40,24 +38,20 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
|
|
|
40
38
|
|
|
41
39
|
const deploymentResults = await Promise.all(
|
|
42
40
|
scriptTemplates.map(async (template) => {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
invariant(Obj.instanceOf(Script.Script, result.data?.object));
|
|
53
|
-
|
|
54
|
-
return deployScript({ space, client, script: result.data.object });
|
|
41
|
+
const createResult = await invokePromise(ScriptOperation.CreateScript, {
|
|
42
|
+
db: space.db,
|
|
43
|
+
initialTemplateId: template.id as any,
|
|
44
|
+
});
|
|
45
|
+
invariant(Obj.instanceOf(Script.Script, createResult.data?.object));
|
|
46
|
+
await invokePromise(SpaceOperation.AddObject, { target: space.db, object: createResult.data.object });
|
|
47
|
+
|
|
48
|
+
return deployScript({ space, client, script: createResult.data.object });
|
|
55
49
|
}),
|
|
56
50
|
);
|
|
57
51
|
|
|
58
52
|
const hasErrors = deploymentResults.some((result) => !result.success);
|
|
59
53
|
setStatus(hasErrors ? 'error' : 'success');
|
|
60
|
-
}, [space,
|
|
54
|
+
}, [space, invokePromise, client, scriptTemplates]);
|
|
61
55
|
|
|
62
56
|
// TODO(burdon): Return onCreateAndDeployScripts.
|
|
63
57
|
return { handleCreateAndDeployScripts, status, error };
|
|
@@ -2,15 +2,39 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { live } from '@dxos/live-object';
|
|
5
|
+
import { Atom, RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useMemo } from 'react';
|
|
8
7
|
|
|
9
8
|
import { type DeployState } from './deploy';
|
|
10
9
|
|
|
11
10
|
export type ScriptToolbarState = Partial<DeployState>;
|
|
12
11
|
|
|
12
|
+
export type ScriptToolbarStateStore = {
|
|
13
|
+
atom: Atom.Writable<ScriptToolbarState>;
|
|
14
|
+
get value(): ScriptToolbarState;
|
|
15
|
+
update: (updater: (current: ScriptToolbarState) => ScriptToolbarState) => void;
|
|
16
|
+
set: <K extends keyof ScriptToolbarState>(key: K, value: ScriptToolbarState[K]) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
13
19
|
// TODO(burdon): Replace with context provider?
|
|
14
|
-
export const useToolbarState = (initialState: ScriptToolbarState = {}) => {
|
|
15
|
-
|
|
20
|
+
export const useToolbarState = (initialState: ScriptToolbarState = {}): ScriptToolbarStateStore => {
|
|
21
|
+
const registry = useContext(RegistryContext);
|
|
22
|
+
const atom = useMemo(() => Atom.make<ScriptToolbarState>(initialState), []);
|
|
23
|
+
const value = useAtomValue(atom);
|
|
24
|
+
|
|
25
|
+
return useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
atom,
|
|
28
|
+
get value() {
|
|
29
|
+
return registry.get(atom);
|
|
30
|
+
},
|
|
31
|
+
update: (updater: (current: ScriptToolbarState) => ScriptToolbarState) => {
|
|
32
|
+
registry.set(atom, updater(registry.get(atom)));
|
|
33
|
+
},
|
|
34
|
+
set: <K extends keyof ScriptToolbarState>(key: K, v: ScriptToolbarState[K]) => {
|
|
35
|
+
registry.set(atom, { ...registry.get(atom), [key]: v });
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
[atom, registry, value],
|
|
39
|
+
);
|
|
16
40
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/script',
|
|
10
10
|
name: 'Scripts',
|
|
11
11
|
description: trim`
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Registry } from '@effect-atom/atom-react';
|
|
5
6
|
import { describe, expect, test } from 'vitest';
|
|
6
7
|
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
|
|
7
10
|
import { createNotebook } from '../testing';
|
|
8
11
|
|
|
9
12
|
import { ComputeGraph } from './compute-graph';
|
|
10
13
|
|
|
11
14
|
describe('notebook', () => {
|
|
12
15
|
test('parse dependency graph', async () => {
|
|
16
|
+
const registry = Registry.make();
|
|
13
17
|
const notebook = createNotebook();
|
|
14
|
-
const graph = new ComputeGraph(notebook);
|
|
18
|
+
const graph = new ComputeGraph(notebook, registry);
|
|
15
19
|
const result = graph.parse();
|
|
16
20
|
|
|
17
21
|
const getId = (i: number) => notebook.cells[i].id;
|
|
@@ -34,13 +38,17 @@ describe('notebook', () => {
|
|
|
34
38
|
});
|
|
35
39
|
|
|
36
40
|
test('evalScript blocks access to window and document', async () => {
|
|
41
|
+
const registry = Registry.make();
|
|
37
42
|
const notebook = createNotebook();
|
|
38
43
|
// Replace one of the cells with code that tries to access window/document.
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
const sourceTarget = notebook.cells[2].source?.target;
|
|
45
|
+
if (sourceTarget) {
|
|
46
|
+
Obj.change(sourceTarget, (t) => {
|
|
47
|
+
t.content = 'b = typeof window';
|
|
48
|
+
});
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
const graph = new ComputeGraph(notebook);
|
|
51
|
+
const graph = new ComputeGraph(notebook, registry);
|
|
44
52
|
graph.parse();
|
|
45
53
|
const values = await graph.evaluate();
|
|
46
54
|
|
|
@@ -48,8 +56,10 @@ describe('notebook', () => {
|
|
|
48
56
|
expect(values[notebook.cells[2].id]).toBe('undefined');
|
|
49
57
|
|
|
50
58
|
// Test document access.
|
|
51
|
-
if (
|
|
52
|
-
|
|
59
|
+
if (sourceTarget) {
|
|
60
|
+
Obj.change(sourceTarget, (t) => {
|
|
61
|
+
t.content = 'b = typeof document';
|
|
62
|
+
});
|
|
53
63
|
}
|
|
54
64
|
graph.parse();
|
|
55
65
|
const values2 = await graph.evaluate();
|
|
@@ -58,8 +68,10 @@ describe('notebook', () => {
|
|
|
58
68
|
expect(values2[notebook.cells[2].id]).toBe('undefined');
|
|
59
69
|
|
|
60
70
|
// Test that safe globals still work.
|
|
61
|
-
if (
|
|
62
|
-
|
|
71
|
+
if (sourceTarget) {
|
|
72
|
+
Obj.change(sourceTarget, (t) => {
|
|
73
|
+
t.content = 'b = Math.max(100, 200)';
|
|
74
|
+
});
|
|
63
75
|
}
|
|
64
76
|
graph.parse();
|
|
65
77
|
const values3 = await graph.evaluate();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
6
6
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
|
|
@@ -18,38 +18,62 @@ import { type ParsedExpression, VirtualTypeScriptParser } from './vfs-parser';
|
|
|
18
18
|
export class ComputeGraph {
|
|
19
19
|
private readonly _parser = new VirtualTypeScriptParser();
|
|
20
20
|
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
21
|
+
private _expressionsAtom = Atom.make<Record<string, ParsedExpression>>({});
|
|
22
|
+
private _valuesByCellIdAtom = Atom.make<Record<string, any>>({});
|
|
23
|
+
private _valuesByNameAtom = Atom.make<Record<string, any>>({});
|
|
24
24
|
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly _notebook: Notebook.Notebook,
|
|
27
|
+
private readonly _registry: Registry.Registry,
|
|
28
|
+
) {}
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
31
|
+
* Atom for parsed expressions by cell ID.
|
|
29
32
|
*/
|
|
30
|
-
get expressions():
|
|
31
|
-
return this.
|
|
33
|
+
get expressions(): Atom.Atom<Record<string, ParsedExpression>> {
|
|
34
|
+
return this._expressionsAtom;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
38
|
+
* Get current expressions by cell ID.
|
|
36
39
|
*/
|
|
37
|
-
|
|
38
|
-
return this.
|
|
40
|
+
getExpressions(): Record<string, ParsedExpression> {
|
|
41
|
+
return this._registry.get(this._expressionsAtom);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
42
|
-
*
|
|
45
|
+
* Atom for computed values by cell ID.
|
|
43
46
|
*/
|
|
44
|
-
get
|
|
45
|
-
return this.
|
|
47
|
+
get values(): Atom.Atom<Record<string, any>> {
|
|
48
|
+
return this._valuesByCellIdAtom;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get computed values by cell ID.
|
|
53
|
+
*/
|
|
54
|
+
getValues(): Record<string, any> {
|
|
55
|
+
return this._registry.get(this._valuesByCellIdAtom);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Atom for computed values by name.
|
|
60
|
+
*/
|
|
61
|
+
get valuesByName(): Atom.Atom<Record<string, any>> {
|
|
62
|
+
return this._valuesByNameAtom;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get current values by name.
|
|
67
|
+
*/
|
|
68
|
+
getValuesByName(): Record<string, any> {
|
|
69
|
+
return this._registry.get(this._valuesByNameAtom);
|
|
46
70
|
}
|
|
47
71
|
|
|
48
72
|
/**
|
|
49
73
|
* Get computed value by cell ID.
|
|
50
74
|
*/
|
|
51
|
-
getValue(cellId: string) {
|
|
52
|
-
return this.
|
|
75
|
+
getValue(cellId: string): any {
|
|
76
|
+
return this._registry.get(this._valuesByCellIdAtom)[cellId];
|
|
53
77
|
}
|
|
54
78
|
|
|
55
79
|
/**
|
|
@@ -58,8 +82,8 @@ export class ComputeGraph {
|
|
|
58
82
|
async evaluate() {
|
|
59
83
|
// Parse expressions.
|
|
60
84
|
const { expressions, dependencyGraph } = this.parse();
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
85
|
+
this._registry.set(this._valuesByCellIdAtom, {});
|
|
86
|
+
this._registry.set(this._valuesByNameAtom, {});
|
|
63
87
|
|
|
64
88
|
// Create a map of cell IDs to expressions for easy lookup.
|
|
65
89
|
const cellExpressions = new Map<string, ParsedExpression>();
|
|
@@ -124,8 +148,8 @@ export class ComputeGraph {
|
|
|
124
148
|
}
|
|
125
149
|
}
|
|
126
150
|
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
151
|
+
this._registry.set(this._valuesByCellIdAtom, valuesByCellId);
|
|
152
|
+
this._registry.set(this._valuesByNameAtom, valuesByName);
|
|
129
153
|
return valuesByCellId;
|
|
130
154
|
}
|
|
131
155
|
|
|
@@ -151,7 +175,7 @@ export class ComputeGraph {
|
|
|
151
175
|
|
|
152
176
|
// Build dependency graph.
|
|
153
177
|
const dependencyGraph = this.buildDependencyGraph(expressions);
|
|
154
|
-
this.
|
|
178
|
+
this._registry.set(this._expressionsAtom, expressions);
|
|
155
179
|
return { expressions, dependencyGraph };
|
|
156
180
|
}
|
|
157
181
|
|
|
@@ -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, Type } 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: Type.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.Service.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.Service.flush();
|
|
56
|
+
return { state: chess.ascii() };
|
|
57
|
+
}),
|
|
58
|
+
});
|