@dxos/plugin-script 0.8.4-main.67995b8 → 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-NBAXYESH.mjs +845 -0
- 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-C53UJGSU.mjs +557 -0
- 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-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.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-UX4GHJ5E.mjs +105 -0
- package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-WYR4QHPE.mjs} +8 -5
- 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 +138 -103
- 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-O6GKHB2J.mjs +139 -0
- 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 +2 -1
- package/dist/lib/browser/types/index.mjs +14 -6
- package/dist/lib/node-esm/DeploymentDialog-OGBJPVIX.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-OGBJPVIX.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-IUAYVJSD.mjs +846 -0
- 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-4F5FJZ36.mjs +107 -0
- 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-AHXJ6NQU.mjs → chunk-5HSJPAK7.mjs} +8 -5
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BX5PP6AW.mjs +558 -0
- 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-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.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 +138 -103
- 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-RLANMVMB.mjs +140 -0
- 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 +2 -1
- package/dist/lib/node-esm/types/index.mjs +14 -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 +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 +4 -4
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +244 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +8 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +7 -8
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +246 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -5
- 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 +18 -32
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +4 -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 +6 -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 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/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/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +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/gmail.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 +3 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/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 +32 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +100 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +40 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- 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 +5 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +7 -7
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +120 -85
- package/src/ScriptPlugin.tsx +56 -76
- 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} +103 -98
- 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 +11 -4
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +45 -22
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -54
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +8 -5
- package/src/components/NotebookContainer.stories.tsx +87 -0
- package/src/components/NotebookContainer.tsx +271 -0
- package/src/components/NotebookStack/NotebookCell.tsx +217 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- 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 +52 -36
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +57 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +37 -33
- package/src/components/Settings/ScriptObjectSettings.tsx +151 -48
- package/src/components/Settings/ScriptPluginSettings.tsx +43 -48
- package/src/components/TestPanel/TestContainer.tsx +9 -8
- package/src/components/TestPanel/TestPanel.tsx +43 -20
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +86 -33
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +84 -81
- package/src/components/index.ts +3 -0
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +49 -42
- package/src/hooks/format.ts +9 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +20 -23
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
- package/src/hooks/useToolbarState.ts +29 -5
- package/src/index.ts +2 -1
- package/src/meta.ts +9 -7
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/compute-graph.ts +230 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +451 -0
- 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 +10 -4
- package/src/templates/discord.ts +12 -4
- package/src/templates/forex-effect.ts +24 -25
- package/src/templates/forex.ts +9 -6
- package/src/templates/gmail.ts +34 -64
- package/src/templates/index.ts +24 -11
- package/src/templates/ping.ts +17 -0
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +35 -7
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +45 -0
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +5 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +38 -61
- package/src/util/functions.ts +58 -25
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs +0 -64
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs +0 -283
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-5TVBECWH.mjs +0 -15
- package/dist/lib/browser/chunk-5TVBECWH.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs +0 -555
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs +0 -233
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs +0 -153
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs +0 -82
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs +0 -89
- package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs +0 -104
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs +0 -24
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs +0 -65
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-35M3CHYE.mjs +0 -16
- package/dist/lib/node-esm/chunk-35M3CHYE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs +0 -556
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs +0 -154
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs +0 -284
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs +0 -234
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs +0 -83
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs +0 -90
- package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs +0 -105
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs +0 -25
- package/dist/lib/node-esm/settings-DXZ334A3.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/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/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 -38
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -64
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -77
- package/src/capabilities/react-surface.tsx +0 -89
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -47
- package/src/templates/echo.ts +0 -8
- package/src/types/schema.ts +0 -37
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-OSL6RMPA.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/blueprints/index.mjs.map} +0 -0
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,232 @@
|
|
|
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, Type } from '@dxos/echo';
|
|
18
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
19
|
+
import { TracingService, defineFunction } from '@dxos/functions';
|
|
20
|
+
import { log } from '@dxos/log';
|
|
21
|
+
import { Chess } from '@dxos/plugin-chess/types';
|
|
22
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
23
|
+
import { Collection, Text } from '@dxos/schema';
|
|
24
|
+
import { HasSubject } from '@dxos/types';
|
|
25
|
+
import { trim } from '@dxos/util';
|
|
26
|
+
|
|
27
|
+
export default defineFunction({
|
|
28
|
+
key: 'dxos.org/function/chess/commentary',
|
|
29
|
+
name: 'Commentary',
|
|
30
|
+
description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',
|
|
31
|
+
inputSchema: Schema.Struct({
|
|
32
|
+
game: Type.Ref(Chess.Game).annotations({
|
|
33
|
+
description: 'The chess game to comment on.',
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
outputSchema: Schema.Union(
|
|
37
|
+
Schema.Struct({
|
|
38
|
+
documentId: ArtifactId.annotations({
|
|
39
|
+
description: 'The ID of the markdown document that was updated or created.',
|
|
40
|
+
}),
|
|
41
|
+
commentary: Schema.String.annotations({
|
|
42
|
+
description: 'The commentary that was added.',
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
Schema.Void.annotations({
|
|
46
|
+
description: 'Function did not find anything to comment on.',
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
types: [Chess.Game, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],
|
|
50
|
+
services: [AiService.AiService, Database.Service],
|
|
51
|
+
handler: Effect.fnUntraced(
|
|
52
|
+
function* ({ data: { game: gameRef } }) {
|
|
53
|
+
// Load the chess game
|
|
54
|
+
log.info('load game', { gameRef });
|
|
55
|
+
const chessGame = yield* Database.Service.load(gameRef);
|
|
56
|
+
|
|
57
|
+
// Load the chess position from PGN or FEN
|
|
58
|
+
const chess = new ChessJS();
|
|
59
|
+
if (chessGame.pgn) {
|
|
60
|
+
chess.loadPgn(chessGame.pgn);
|
|
61
|
+
} else if (chessGame.fen) {
|
|
62
|
+
chess.load(chessGame.fen);
|
|
63
|
+
} else {
|
|
64
|
+
log.info('Early return: no pgn or fen');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Get the most recent move
|
|
69
|
+
const history = chess.history({ verbose: true });
|
|
70
|
+
if (history.length === 0) {
|
|
71
|
+
throw new Error('No moves have been played yet');
|
|
72
|
+
}
|
|
73
|
+
const lastMove = history[history.length - 1];
|
|
74
|
+
const moveNumber = Math.ceil(history.length / 2);
|
|
75
|
+
const isWhiteMove = history.length % 2 === 1;
|
|
76
|
+
const player = isWhiteMove ? 'White' : 'Black';
|
|
77
|
+
const moveNotation = lastMove.san;
|
|
78
|
+
|
|
79
|
+
// Generate AI commentary about the move
|
|
80
|
+
const result = yield* new AiSession().run({
|
|
81
|
+
prompt:
|
|
82
|
+
`Comment on this chess move as if you're commentating a live match for an audience:\n\n` +
|
|
83
|
+
`Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\n` +
|
|
84
|
+
`Current position: ${chess.fen()}\n` +
|
|
85
|
+
`${chess.isCheck() ? 'The king is in check! ' : ''}` +
|
|
86
|
+
`${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +
|
|
87
|
+
`${chess.isStalemate() ? 'STALEMATE! ' : ''}` +
|
|
88
|
+
`\nGame so far:\n${chess.pgn()}`,
|
|
89
|
+
system: COMMENTARY_SYSTEM_PROMPT,
|
|
90
|
+
history: [],
|
|
91
|
+
observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const commentaryText = Function.pipe(
|
|
95
|
+
result,
|
|
96
|
+
Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
|
|
97
|
+
Option.flatMap((msg) =>
|
|
98
|
+
Function.pipe(
|
|
99
|
+
msg.blocks,
|
|
100
|
+
Array.findLast((block) => block._tag === 'text'),
|
|
101
|
+
Option.map((block) => block.text),
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
Option.getOrThrowWith(() => new Error('No commentary generated')),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\n\n${commentaryText}\n\n`;
|
|
108
|
+
log.info('commentary', { commentary });
|
|
109
|
+
|
|
110
|
+
// TODO(wittjosiah): Functions currently don't support traversals.
|
|
111
|
+
// const docs = yield* Database.Service.runQuery(
|
|
112
|
+
// Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),
|
|
113
|
+
// ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));
|
|
114
|
+
const docs = yield* Database.Service.runQuery(Filter.type(HasSubject.HasSubject)).pipe(
|
|
115
|
+
Effect.map((relations) =>
|
|
116
|
+
relations.filter((relation) => {
|
|
117
|
+
// TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.
|
|
118
|
+
try {
|
|
119
|
+
log.info('relation', {
|
|
120
|
+
source: Obj.getDXN(Relation.getTarget(relation)).toString(),
|
|
121
|
+
game: Obj.getDXN(chessGame).toString(),
|
|
122
|
+
});
|
|
123
|
+
return Obj.getDXN(Relation.getTarget(relation)).toString() === Obj.getDXN(chessGame).toString();
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
),
|
|
129
|
+
Effect.map((relations) =>
|
|
130
|
+
relations
|
|
131
|
+
.map((relation) => {
|
|
132
|
+
// TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.
|
|
133
|
+
try {
|
|
134
|
+
return Relation.getSource(relation);
|
|
135
|
+
} catch {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
.filter((source) => source !== undefined),
|
|
140
|
+
),
|
|
141
|
+
Effect.map((sources) => {
|
|
142
|
+
const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));
|
|
143
|
+
log.info('docs', { sources, docs });
|
|
144
|
+
return docs;
|
|
145
|
+
}),
|
|
146
|
+
);
|
|
147
|
+
log.info('docs', { count: docs.length });
|
|
148
|
+
|
|
149
|
+
let document: Markdown.Document;
|
|
150
|
+
if (docs.length === 0) {
|
|
151
|
+
// TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.
|
|
152
|
+
const [properties] = yield* Database.Service.runQuery(Filter.typename('dxos.org/type/Properties'));
|
|
153
|
+
const rootCollection = yield* Database.Service.load<Collection.Collection>(
|
|
154
|
+
properties[Collection.Collection.typename],
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
log.info('rootCollection', { rootCollection });
|
|
158
|
+
|
|
159
|
+
// Create a new markdown document
|
|
160
|
+
const gameName = chessGame.name || 'Chess Game';
|
|
161
|
+
document = yield* Database.Service.add(
|
|
162
|
+
Markdown.make({
|
|
163
|
+
name: `${gameName} Commentary`,
|
|
164
|
+
content: `# ${gameName} Commentary\n\n${commentary}`,
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const documentRef = Ref.make(document);
|
|
169
|
+
Obj.change(rootCollection, (c) => {
|
|
170
|
+
c.objects.push(documentRef);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Create the HasSubject relation
|
|
174
|
+
yield* Database.Service.add(
|
|
175
|
+
Relation.make(HasSubject.HasSubject, {
|
|
176
|
+
[Relation.Source]: document,
|
|
177
|
+
[Relation.Target]: chessGame,
|
|
178
|
+
completedAt: new Date().toISOString(),
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
} else {
|
|
182
|
+
document = docs[0];
|
|
183
|
+
|
|
184
|
+
// Load the text content and append the commentary
|
|
185
|
+
const text = yield* Database.Service.load(document.content);
|
|
186
|
+
const accessor = createDocAccessor(text, ['content']);
|
|
187
|
+
accessor.handle.change((doc: A.Doc<Text.Text>) => {
|
|
188
|
+
A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
log.info('result', { documentId: Obj.getDXN(document).toString(), commentary });
|
|
193
|
+
|
|
194
|
+
yield* Database.Service.flush();
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
documentId: Obj.getDXN(document).toString(),
|
|
198
|
+
commentary,
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
Effect.provide(
|
|
202
|
+
Layer.mergeAll(
|
|
203
|
+
AiService.model('@anthropic/claude-haiku-4-5'),
|
|
204
|
+
ToolResolverService.layerEmpty,
|
|
205
|
+
ToolExecutionService.layerEmpty,
|
|
206
|
+
TracingService.layerNoop,
|
|
207
|
+
),
|
|
208
|
+
),
|
|
209
|
+
),
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const COMMENTARY_SYSTEM_PROMPT = trim`
|
|
213
|
+
You are a professional chess commentator providing live commentary for a chess match.
|
|
214
|
+
|
|
215
|
+
# Style
|
|
216
|
+
- Write in an engaging, enthusiastic style as if commentating for a live audience
|
|
217
|
+
- Be concise but informative (2-4 sentences)
|
|
218
|
+
- Explain the strategic implications of the move
|
|
219
|
+
- Note any tactical elements (captures, threats, checks)
|
|
220
|
+
- Comment on the position and what it means for the game
|
|
221
|
+
|
|
222
|
+
# Format
|
|
223
|
+
- Write in plain text (no markdown formatting in the commentary itself)
|
|
224
|
+
- Be natural and conversational
|
|
225
|
+
- Use chess terminology appropriately but keep it accessible
|
|
226
|
+
|
|
227
|
+
# Special Situations
|
|
228
|
+
- If it's checkmate, express excitement about the conclusion
|
|
229
|
+
- If it's check, note the pressure on the king
|
|
230
|
+
- If a piece is captured, mention the material exchange
|
|
231
|
+
- Comment on the development of pieces and control of key squares when relevant
|
|
232
|
+
`;
|
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { Expando, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';
|
|
9
9
|
|
|
10
10
|
export default defineFunction({
|
|
11
|
+
key: 'dxos.org/script/data-generator',
|
|
12
|
+
name: 'Data Generator',
|
|
11
13
|
inputSchema: S.Struct({
|
|
12
14
|
documentAmount: S.optional(S.Number),
|
|
13
15
|
textSize: S.optional(S.Number),
|
|
14
16
|
mutationAmount: S.optional(S.Number),
|
|
17
|
+
waitAfterCreation: S.optional(S.Number),
|
|
15
18
|
}),
|
|
16
19
|
|
|
17
20
|
outputSchema: S.Struct({}),
|
|
18
21
|
|
|
19
|
-
handler: async ({
|
|
20
|
-
|
|
22
|
+
handler: async ({
|
|
23
|
+
data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
|
|
24
|
+
context: { space },
|
|
25
|
+
}: any) => {
|
|
26
|
+
await space.db.graph.schemaRegistry.register([Expando]);
|
|
21
27
|
const result: Record<string, any> = {};
|
|
22
28
|
const objects: Expando[] = [];
|
|
23
29
|
|
|
@@ -42,7 +48,7 @@ export default defineFunction({
|
|
|
42
48
|
|
|
43
49
|
// Flush and wait for data to propagate.
|
|
44
50
|
await space.db.flush();
|
|
45
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));
|
|
46
52
|
return { createdObjects: objects.length };
|
|
47
53
|
},
|
|
48
54
|
});
|
package/src/templates/discord.ts
CHANGED
|
@@ -3,17 +3,23 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { DXN, EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.
|
|
8
|
+
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
9
9
|
import {
|
|
10
10
|
DiscordConfig,
|
|
11
11
|
DiscordREST,
|
|
12
12
|
DiscordRESTMemoryLive,
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.
|
|
14
|
+
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
import
|
|
16
|
+
import * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
|
|
17
23
|
|
|
18
24
|
const MessageSchema = S.Struct({
|
|
19
25
|
id: ObjectId,
|
|
@@ -36,6 +42,8 @@ const generateSnowflake = (unixTimestamp: number): bigint => {
|
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
export default defineFunction({
|
|
45
|
+
key: 'dxos.org/script/discord',
|
|
46
|
+
name: 'Discord',
|
|
39
47
|
inputSchema: S.Struct({
|
|
40
48
|
// TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
|
|
41
49
|
tick: S.optional(S.String),
|
|
@@ -2,37 +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 { Effect, Schedule } from 'https://esm.sh/effect@3.14.21?bundle=false';
|
|
5
|
+
import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
|
|
6
|
+
import * as HttpClient from '@effect/platform/HttpClient';
|
|
7
|
+
import * as HttpClientRequest from '@effect/platform/HttpClientRequest';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Schedule from 'effect/Schedule';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
11
|
+
|
|
12
|
+
import { defineFunction } from '@dxos/functions';
|
|
15
13
|
|
|
16
14
|
export default defineFunction({
|
|
15
|
+
key: 'dxos.org/script/forex-effect',
|
|
16
|
+
name: 'Forex Effect',
|
|
17
17
|
description: 'Returns the exchange rate between two currencies.',
|
|
18
18
|
|
|
19
|
-
inputSchema:
|
|
20
|
-
from:
|
|
21
|
-
to:
|
|
19
|
+
inputSchema: Schema.Struct({
|
|
20
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
21
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
22
22
|
}),
|
|
23
23
|
|
|
24
|
-
outputSchema:
|
|
24
|
+
outputSchema: Schema.String.annotations({ description: 'The exchange rate between the two currencies' }),
|
|
25
25
|
|
|
26
|
-
handler:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
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('1 second'),
|
|
31
|
+
Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
|
|
32
|
+
Effect.scoped,
|
|
33
|
+
);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
return (res as any).data.rates[to].toString();
|
|
36
|
+
}, Effect.provide(FetchHttpClient.layer)),
|
|
38
37
|
});
|
package/src/templates/forex.ts
CHANGED
|
@@ -2,18 +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({
|
|
10
|
+
key: 'dxos.org/script/forex',
|
|
11
|
+
name: 'Forex',
|
|
9
12
|
description: 'Returns the exchange rate between two currencies.',
|
|
10
13
|
|
|
11
|
-
inputSchema:
|
|
12
|
-
from:
|
|
13
|
-
to:
|
|
14
|
+
inputSchema: Schema.Struct({
|
|
15
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
16
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
14
17
|
}),
|
|
15
18
|
|
|
16
|
-
handler: async ({ data: { from, to } }
|
|
19
|
+
handler: async ({ data: { from, to } }) => {
|
|
17
20
|
const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);
|
|
18
21
|
const {
|
|
19
22
|
data: { rates },
|
package/src/templates/gmail.ts
CHANGED
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import {
|
|
9
|
+
FetchHttpClient,
|
|
9
10
|
HttpClient,
|
|
10
11
|
HttpClientRequest,
|
|
11
|
-
FetchHttpClient,
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
} from 'https://esm.sh/@effect/platform@0.
|
|
13
|
+
} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
import { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
import
|
|
17
|
+
import * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
import * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
import * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';
|
|
18
28
|
|
|
19
29
|
export default defineFunction({
|
|
30
|
+
key: 'dxos.org/script/gmail',
|
|
31
|
+
name: 'Gmail',
|
|
20
32
|
inputSchema: S.Struct({
|
|
21
33
|
mailboxId: S.String,
|
|
22
34
|
userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),
|
|
@@ -41,7 +53,7 @@ export default defineFunction({
|
|
|
41
53
|
|
|
42
54
|
// NOTE: Google API bundles size is v. large and caused runtime issues.
|
|
43
55
|
const makeRequest = (url: string) =>
|
|
44
|
-
pipe(
|
|
56
|
+
Function.pipe(
|
|
45
57
|
url,
|
|
46
58
|
HttpClientRequest.get,
|
|
47
59
|
HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),
|
|
@@ -80,7 +92,7 @@ export default defineFunction({
|
|
|
80
92
|
const messageDetails = yield* getMessage(userId, message.id);
|
|
81
93
|
const created = new Date(parseInt(messageDetails.internalDate)).toISOString();
|
|
82
94
|
const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');
|
|
83
|
-
const sender = from &&
|
|
95
|
+
const sender = from && parseFromHeader(from.value);
|
|
84
96
|
// TODO(wittjosiah): Improve parsing of email contents.
|
|
85
97
|
const content =
|
|
86
98
|
messageDetails.payload.body?.data ??
|
|
@@ -98,7 +110,7 @@ export default defineFunction({
|
|
|
98
110
|
sender,
|
|
99
111
|
blocks: [
|
|
100
112
|
{
|
|
101
|
-
|
|
113
|
+
_tag: 'text',
|
|
102
114
|
text: Buffer.from(content, 'base64').toString('utf-8'),
|
|
103
115
|
},
|
|
104
116
|
],
|
|
@@ -114,7 +126,7 @@ export default defineFunction({
|
|
|
114
126
|
|
|
115
127
|
const queueMessages = yield* Ref.get(newMessages);
|
|
116
128
|
if (queueMessages.length > 0) {
|
|
117
|
-
yield* pipe(
|
|
129
|
+
yield* Function.pipe(
|
|
118
130
|
queueMessages,
|
|
119
131
|
Stream.fromIterable,
|
|
120
132
|
Stream.grouped(10),
|
|
@@ -145,17 +157,17 @@ const getUrl = (userId: string, messageId?: string, params?: Record<string, any>
|
|
|
145
157
|
/**
|
|
146
158
|
* Parses an email string in the format "Name <email@example.com>" into separate name and email components.
|
|
147
159
|
*/
|
|
148
|
-
const
|
|
149
|
-
const
|
|
160
|
+
const parseFromHeader = (value: string): { name?: string; email: string } | undefined => {
|
|
161
|
+
const EMAIL_REGEX = /^([^<]+?)\s*<([^>]+@[^>]+)>$/;
|
|
162
|
+
const removeOuterQuotes = (str: string) => str.replace(/^['"]|['"]$/g, '');
|
|
163
|
+
const match = value.match(EMAIL_REGEX);
|
|
150
164
|
if (match) {
|
|
151
165
|
const [, name, email] = match;
|
|
152
166
|
return {
|
|
153
|
-
name: name.trim(),
|
|
167
|
+
name: removeOuterQuotes(name.trim()),
|
|
154
168
|
email: email.trim(),
|
|
155
169
|
};
|
|
156
170
|
}
|
|
157
|
-
|
|
158
|
-
return undefined;
|
|
159
171
|
};
|
|
160
172
|
|
|
161
173
|
//
|
|
@@ -163,8 +175,7 @@ const parseEmailString = (emailString: string): { name?: string; email: string }
|
|
|
163
175
|
// TODO(wittjosiah): These schemas should be imported from @dxos/schema.
|
|
164
176
|
//
|
|
165
177
|
|
|
166
|
-
const
|
|
167
|
-
const ActorRole = S.Literal(...ActorRoles);
|
|
178
|
+
const ActorRole = S.Literal('user', 'assistant');
|
|
168
179
|
type ActorRole = S.Schema.Type<typeof ActorRole>;
|
|
169
180
|
|
|
170
181
|
const ActorSchema = S.Struct({
|
|
@@ -174,57 +185,16 @@ const ActorSchema = S.Struct({
|
|
|
174
185
|
role: S.optional(ActorRole),
|
|
175
186
|
});
|
|
176
187
|
|
|
177
|
-
const
|
|
188
|
+
const Base = S.Struct({
|
|
178
189
|
pending: S.optional(S.Boolean),
|
|
179
190
|
});
|
|
180
|
-
type
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
S.
|
|
184
|
-
|
|
185
|
-
disposition: S.optional(S.String),
|
|
186
|
-
text: S.String,
|
|
187
|
-
}),
|
|
188
|
-
).pipe(S.mutable);
|
|
189
|
-
type TextContentBlock = S.Schema.Type<typeof TextContentBlock>;
|
|
190
|
-
const JsonContentBlock = S.extend(
|
|
191
|
-
AbstractContentBlock,
|
|
192
|
-
S.Struct({
|
|
193
|
-
type: S.Literal('json'),
|
|
194
|
-
disposition: S.optional(S.String),
|
|
195
|
-
data: S.String,
|
|
196
|
-
}),
|
|
197
|
-
).pipe(S.mutable);
|
|
198
|
-
type JsonContentBlock = S.Schema.Type<typeof JsonContentBlock>;
|
|
199
|
-
const Base64ImageSource = S.Struct({
|
|
200
|
-
type: S.Literal('base64'),
|
|
201
|
-
mediaType: S.String,
|
|
202
|
-
data: S.String,
|
|
191
|
+
type Base = S.Schema.Type<typeof Base>;
|
|
192
|
+
const Text = S.TaggedStruct('text', {
|
|
193
|
+
mimeType: S.optional(S.String),
|
|
194
|
+
text: S.String,
|
|
195
|
+
...Base.fields,
|
|
203
196
|
}).pipe(S.mutable);
|
|
204
|
-
|
|
205
|
-
type: S.Literal('http'),
|
|
206
|
-
url: S.String,
|
|
207
|
-
}).pipe(S.mutable);
|
|
208
|
-
const ImageSource = S.Union(Base64ImageSource, HttpImageSource);
|
|
209
|
-
type ImageSource = S.Schema.Type<typeof ImageSource>;
|
|
210
|
-
const ImageContentBlock = S.extend(
|
|
211
|
-
AbstractContentBlock,
|
|
212
|
-
S.Struct({
|
|
213
|
-
type: S.Literal('image'),
|
|
214
|
-
id: S.optional(S.String),
|
|
215
|
-
source: S.optional(ImageSource),
|
|
216
|
-
}),
|
|
217
|
-
).pipe(S.mutable);
|
|
218
|
-
type ImageContentBlock = S.Schema.Type<typeof ImageContentBlock>;
|
|
219
|
-
const ReferenceContentBlock = S.extend(
|
|
220
|
-
AbstractContentBlock,
|
|
221
|
-
S.Struct({
|
|
222
|
-
type: S.Literal('reference'),
|
|
223
|
-
reference: S.Any,
|
|
224
|
-
}),
|
|
225
|
-
).pipe(S.mutable);
|
|
226
|
-
type ReferenceContentBlock = S.Schema.Type<typeof ReferenceContentBlock>;
|
|
227
|
-
const MessageContentBlock = S.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
|
|
197
|
+
interface Text extends S.Schema.Type<typeof Text> {}
|
|
228
198
|
|
|
229
199
|
const MessageType = S.Struct({
|
|
230
200
|
id: ObjectId,
|
|
@@ -234,7 +204,7 @@ const MessageType = S.Struct({
|
|
|
234
204
|
sender: ActorSchema.annotations({
|
|
235
205
|
description: 'Identity of the message sender.',
|
|
236
206
|
}),
|
|
237
|
-
blocks: S.Array(
|
|
207
|
+
blocks: S.Array(Text).annotations({
|
|
238
208
|
description: 'Contents of the message.',
|
|
239
209
|
}),
|
|
240
210
|
properties: S.optional(
|