@dxos/plugin-script 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
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/PLUGIN.mdl +9 -9
- package/dist/lib/neutral/{NotebookArticle-E35G2Y2I.mjs → NotebookArticle-AOBB3XGD.mjs} +27 -45
- package/dist/lib/neutral/NotebookArticle-AOBB3XGD.mjs.map +7 -0
- package/dist/lib/neutral/{ScriptArticle-QW26LOKU.mjs → ScriptArticle-I3DOJARR.mjs} +4 -4
- package/dist/lib/neutral/ScriptArticle-I3DOJARR.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.mjs +4 -4
- package/dist/lib/neutral/ScriptPlugin.mjs.map +3 -3
- package/dist/lib/neutral/ScriptPlugin.node.mjs +3 -3
- package/dist/lib/neutral/ScriptPlugin.node.mjs.map +3 -3
- package/dist/lib/neutral/{ScriptProperties-ADTWXG6O.mjs → ScriptProperties-RHDQGMGT.mjs} +148 -148
- package/dist/lib/neutral/ScriptProperties-RHDQGMGT.mjs.map +7 -0
- package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs +35 -0
- package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +6 -6
- package/dist/lib/neutral/capabilities/index.mjs.map +3 -3
- package/dist/lib/neutral/capabilities/node.mjs +5 -5
- package/dist/lib/neutral/capabilities/node.mjs.map +3 -3
- package/dist/lib/neutral/{chunk-ZPFRRBZW.mjs → chunk-652CIABA.mjs} +10 -9
- package/dist/lib/neutral/chunk-652CIABA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TRKXIP2Q.mjs → chunk-6DOWVKIW.mjs} +4 -5
- package/dist/lib/neutral/chunk-6DOWVKIW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BDHDBPVM.mjs → chunk-CHNFYLKW.mjs} +12 -12
- package/dist/lib/neutral/chunk-CHNFYLKW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VXDJH6OL.mjs → chunk-INFWOSTM.mjs} +14 -8
- package/dist/lib/neutral/chunk-INFWOSTM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JAJ64B3E.mjs → chunk-KSVKXCTX.mjs} +2 -2
- package/dist/lib/neutral/chunk-USJ44FIU.mjs +8 -0
- package/dist/lib/neutral/{chunk-O6A5PTB3.mjs.map → chunk-USJ44FIU.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-QV6NCUGM.mjs → chunk-WAGQ77UQ.mjs} +6 -6
- package/dist/lib/neutral/chunk-WAGQ77UQ.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +120 -91
- package/dist/lib/neutral/components/index.mjs.map +4 -4
- package/dist/lib/neutral/containers/index.mjs +5 -3
- package/dist/lib/neutral/containers/index.mjs.map +3 -3
- package/dist/lib/neutral/{create-6LC57CCC.mjs → create-SGHWWTET.mjs} +4 -4
- package/dist/lib/neutral/{create-6LC57CCC.mjs.map → create-SGHWWTET.mjs.map} +4 -4
- package/dist/lib/neutral/{create-object-FZM5ASWM.mjs → create-object-QW66KQWS.mjs} +1 -3
- package/dist/lib/neutral/{create-object-FZM5ASWM.mjs.map → create-object-QW66KQWS.mjs.map} +3 -3
- package/dist/lib/neutral/{create-script-YW437XYZ.mjs → create-script-CIEJOBIU.mjs} +4 -4
- package/dist/lib/neutral/{create-script-YW437XYZ.mjs.map → create-script-CIEJOBIU.mjs.map} +3 -3
- package/dist/lib/neutral/{delete-HCQIQFVP.mjs → delete-72RXVLVI.mjs} +3 -3
- package/dist/lib/neutral/{delete-HCQIQFVP.mjs.map → delete-72RXVLVI.mjs.map} +1 -1
- package/dist/lib/neutral/{deploy-7JVMMHSH.mjs → deploy-PJTJAQZY.mjs} +10 -6
- package/dist/lib/neutral/deploy-PJTJAQZY.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +2 -2
- package/dist/lib/neutral/hooks/index.mjs.map +2 -2
- package/dist/lib/neutral/index.mjs +8 -8
- package/dist/lib/neutral/{inspect-invocations-TAOYDT4H.mjs → inspect-invocations-ZUXVUAML.mjs} +5 -5
- package/dist/lib/neutral/inspect-invocations-ZUXVUAML.mjs.map +7 -0
- package/dist/lib/neutral/{install-function-FJIE2JAI.mjs → install-function-YFDZLVMJ.mjs} +4 -4
- package/dist/lib/neutral/{install-function-FJIE2JAI.mjs.map → install-function-YFDZLVMJ.mjs.map} +1 -1
- package/dist/lib/neutral/{invoke-3HVWY2KF.mjs → invoke-CDRBQ2WA.mjs} +4 -4
- package/dist/lib/neutral/{invoke-3HVWY2KF.mjs.map → invoke-CDRBQ2WA.mjs.map} +1 -1
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/{operation-handler-6IZ7L4L2.mjs → operation-handler-M3B6IRMV.mjs} +3 -3
- package/dist/lib/neutral/{operation-handler-6IZ7L4L2.mjs.map → operation-handler-M3B6IRMV.mjs.map} +1 -1
- package/dist/lib/neutral/operations/index.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +1 -1
- package/dist/lib/neutral/{query-deployed-functions-F4FHJNWO.mjs → query-deployed-functions-RBQMGON2.mjs} +4 -4
- package/dist/lib/neutral/{query-deployed-functions-F4FHJNWO.mjs.map → query-deployed-functions-RBQMGON2.mjs.map} +1 -1
- package/dist/lib/neutral/{react-surface-2TZDZQYA.mjs → react-surface-GEXOZLBC.mjs} +4 -5
- package/dist/lib/neutral/react-surface-GEXOZLBC.mjs.map +7 -0
- package/dist/lib/neutral/{read-RQESBAQI.mjs → read-OY3K5R3V.mjs} +3 -3
- package/dist/lib/neutral/{read-RQESBAQI.mjs.map → read-OY3K5R3V.mjs.map} +3 -3
- package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs +15 -0
- package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs.map +7 -0
- package/dist/lib/neutral/skills/index.mjs +10 -0
- package/dist/lib/neutral/templates/index.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +6 -7
- package/dist/lib/neutral/translations.mjs.map +2 -2
- package/dist/lib/neutral/types/index.mjs +2 -2
- package/dist/lib/neutral/update-Z5VGOLBN.mjs +44 -0
- package/dist/lib/neutral/update-Z5VGOLBN.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compiler.d.ts +1 -2
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +1 -12
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +1 -1
- package/dist/types/src/capabilities/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -3
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
- package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +2 -3
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +18 -21
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +18 -21
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +18 -21
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +20 -23
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +20 -23
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts +8 -0
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts.map +1 -0
- package/dist/types/src/{components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts → containers/ScriptSettings/ScriptSettings.stories.d.ts} +20 -23
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptSettings/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -0
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +6 -15
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -1
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -1
- package/dist/types/src/hooks/template.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 +4 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-script.d.ts.map +1 -1
- package/dist/types/src/skills/functions/create.d.ts.map +1 -0
- package/dist/types/src/skills/functions/definitions.d.ts +75 -0
- package/dist/types/src/skills/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/skills/functions/delete.d.ts +7 -0
- package/dist/types/src/skills/functions/delete.d.ts.map +1 -0
- package/dist/types/src/skills/functions/deploy.d.ts +11 -0
- package/dist/types/src/skills/functions/deploy.d.ts.map +1 -0
- package/dist/types/src/skills/functions/index.d.ts.map +1 -0
- package/dist/types/src/skills/functions/inspect-invocations.d.ts +18 -0
- package/dist/types/src/skills/functions/inspect-invocations.d.ts.map +1 -0
- package/dist/types/src/skills/functions/install-function.d.ts.map +1 -0
- package/dist/types/src/skills/functions/invoke.d.ts +11 -0
- package/dist/types/src/skills/functions/invoke.d.ts.map +1 -0
- package/dist/types/src/skills/functions/query-deployed-functions.d.ts.map +1 -0
- package/dist/types/src/skills/functions/read.d.ts +11 -0
- package/dist/types/src/skills/functions/read.d.ts.map +1 -0
- package/dist/types/src/skills/functions/update.d.ts +16 -0
- package/dist/types/src/skills/functions/update.d.ts.map +1 -0
- package/dist/types/src/skills/index.d.ts +2 -0
- package/dist/types/src/skills/index.d.ts.map +1 -0
- package/dist/types/src/skills/script-skill.d.ts +4 -0
- package/dist/types/src/skills/script-skill.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +1 -4
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -1
- package/dist/types/src/templates/commentary.d.ts +1 -4
- package/dist/types/src/templates/commentary.d.ts.map +1 -1
- package/dist/types/src/testing/test-script.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +18 -21
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +11 -81
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- package/dist/types/src/types/ScriptOperation.d.ts +2 -10
- package/dist/types/src/types/ScriptOperation.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +1 -1
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +75 -74
- package/src/ScriptPlugin.node.ts +2 -2
- package/src/ScriptPlugin.test.ts +1 -1
- package/src/ScriptPlugin.tsx +2 -2
- package/src/capabilities/create-object.ts +0 -2
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/node.ts +1 -1
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +9 -7
- package/src/capabilities/skill-definition.ts +14 -0
- package/src/components/NotebookStack/NotebookCell.tsx +11 -29
- package/src/components/NotebookStack/NotebookStack.stories.tsx +3 -3
- package/src/components/NotebookStack/NotebookStack.tsx +101 -43
- package/src/components/QueryEditor/QueryEditor.stories.tsx +2 -7
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -2
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +7 -8
- package/src/components/index.ts +0 -4
- package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +4 -4
- package/src/containers/NotebookArticle/NotebookArticle.tsx +20 -42
- package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +5 -5
- package/src/containers/ScriptArticle/ScriptArticle.tsx +3 -3
- package/src/containers/ScriptProperties/FunctionBinding.tsx +1 -1
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +1 -1
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +5 -5
- package/src/containers/ScriptProperties/ScriptProperties.tsx +2 -2
- package/src/containers/ScriptProperties/{BlueprintEditor.tsx → SkillEditor.tsx} +22 -22
- package/src/{components/ScriptPluginSettings/ScriptPluginSettings.stories.tsx → containers/ScriptSettings/ScriptSettings.stories.tsx} +4 -4
- package/src/containers/ScriptSettings/ScriptSettings.tsx +47 -0
- package/src/containers/ScriptSettings/index.ts +5 -0
- package/src/containers/index.ts +1 -0
- package/src/e2e/ai.test.ts +14 -11
- package/src/e2e/deploy.test.ts +5 -1
- package/src/hooks/deploy.ts +1 -1
- package/src/index.ts +1 -1
- package/src/operations/create-script.ts +1 -1
- package/src/{blueprints → skills}/functions/create.ts +1 -1
- package/src/{blueprints → skills}/functions/definitions.ts +4 -2
- package/src/{blueprints → skills}/functions/deploy.ts +7 -2
- package/src/{blueprints → skills}/functions/inspect-invocations.ts +2 -2
- package/src/{blueprints → skills}/functions/read.ts +1 -1
- package/src/skills/functions/update.ts +48 -0
- package/src/skills/index.ts +5 -0
- package/src/{blueprints/script-blueprint.ts → skills/script-skill.ts} +12 -12
- package/src/templates/anthropic.ts +1 -1
- package/src/templates/chess-bot.ts +2 -2
- package/src/templates/commentary.ts +4 -4
- package/src/templates/discord.ts +1 -1
- package/src/templates/gmail.ts +1 -1
- package/src/testing/test-notebook.ts +5 -5
- package/src/testing/test-script.ts +1 -1
- package/src/translations.ts +6 -7
- package/src/types/Notebook.ts +9 -13
- package/src/types/ScriptOperation.ts +2 -2
- package/src/util/deploy.ts +7 -3
- package/src/util/functions.ts +3 -3
- package/dist/lib/neutral/NotebookArticle-E35G2Y2I.mjs.map +0 -7
- package/dist/lib/neutral/ScriptArticle-QW26LOKU.mjs.map +0 -7
- package/dist/lib/neutral/ScriptPluginSettings-5AURDJTI.mjs +0 -31
- package/dist/lib/neutral/ScriptPluginSettings-5AURDJTI.mjs.map +0 -7
- package/dist/lib/neutral/ScriptProperties-ADTWXG6O.mjs.map +0 -7
- package/dist/lib/neutral/blueprint-definition-PJ7I3JIQ.mjs +0 -15
- package/dist/lib/neutral/blueprint-definition-PJ7I3JIQ.mjs.map +0 -7
- package/dist/lib/neutral/blueprints/index.mjs +0 -10
- package/dist/lib/neutral/chunk-BDHDBPVM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-O6A5PTB3.mjs +0 -8
- package/dist/lib/neutral/chunk-QV6NCUGM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TRKXIP2Q.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZPFRRBZW.mjs.map +0 -7
- package/dist/lib/neutral/deploy-7JVMMHSH.mjs.map +0 -7
- package/dist/lib/neutral/inspect-invocations-TAOYDT4H.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-2TZDZQYA.mjs.map +0 -7
- package/dist/lib/neutral/update-CO7B6UBS.mjs +0 -63
- package/dist/lib/neutral/update-CO7B6UBS.mjs.map +0 -7
- package/dist/types/src/blueprints/functions/create.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/definitions.d.ts +0 -135
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/delete.d.ts +0 -17
- package/dist/types/src/blueprints/functions/delete.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/deploy.d.ts +0 -21
- package/dist/types/src/blueprints/functions/deploy.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/index.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +0 -28
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/install-function.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/invoke.d.ts +0 -21
- package/dist/types/src/blueprints/functions/invoke.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/read.d.ts +0 -21
- package/dist/types/src/blueprints/functions/read.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/update.d.ts +0 -26
- package/dist/types/src/blueprints/functions/update.d.ts.map +0 -1
- package/dist/types/src/blueprints/index.d.ts +0 -2
- package/dist/types/src/blueprints/index.d.ts.map +0 -1
- package/dist/types/src/blueprints/script-blueprint.d.ts +0 -4
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -6
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts +0 -8
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +0 -1
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts +0 -2
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts.map +0 -1
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts +0 -7
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +0 -1
- package/src/blueprints/functions/update.ts +0 -68
- package/src/blueprints/index.ts +0 -5
- package/src/capabilities/blueprint-definition.ts +0 -19
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.tsx +0 -42
- package/src/components/ScriptPluginSettings/index.ts +0 -5
- /package/dist/lib/neutral/{chunk-JAJ64B3E.mjs.map → chunk-KSVKXCTX.mjs.map} +0 -0
- /package/dist/lib/neutral/{blueprints → skills}/index.mjs.map +0 -0
- /package/dist/types/src/{blueprints → skills}/functions/create.d.ts +0 -0
- /package/dist/types/src/{blueprints → skills}/functions/index.d.ts +0 -0
- /package/dist/types/src/{blueprints → skills}/functions/install-function.d.ts +0 -0
- /package/dist/types/src/{blueprints → skills}/functions/query-deployed-functions.d.ts +0 -0
- /package/src/{blueprints → skills}/functions/delete.ts +0 -0
- /package/src/{blueprints → skills}/functions/index.ts +0 -0
- /package/src/{blueprints → skills}/functions/install-function.ts +0 -0
- /package/src/{blueprints → skills}/functions/invoke.ts +0 -0
- /package/src/{blueprints → skills}/functions/query-deployed-functions.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/anthropic.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/chess-bot.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/commentary.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/data-generator.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/discord.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/email.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex-effect.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/gmail.ts", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/ping.ts", "../../../src/templates/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as LanguageModel from '@effect/ai/LanguageModel';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\nimport * as Stream from 'effect/Stream';\n\nimport { AiService } from '@dxos/ai';\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Anthropic = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.anthropic'),\n name: 'Anthropic Chat',\n description: 'Chat with Anthropic',\n },\n input: Schema.Struct({\n message: Schema.String,\n }),\n output: Schema.Any,\n services: [AiService.AiService],\n});\n\nexport default Anthropic.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ message }) {\n const model = AiService.model('com.anthropic.model.claude-sonnet-4-6.default');\n\n //\n // Basic example.\n //\n const { text } = yield* LanguageModel.generateText({ prompt: message }).pipe(Effect.provide(model));\n\n //\n // Streaming example.\n //\n const parts = yield* LanguageModel.streamText({\n prompt: 'Count from 1 to 5, one number per line.',\n }).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));\n const textDeltas = parts.filter((p) => p.type === 'text-delta');\n const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');\n\n return { response: text, streamText: fullText };\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, DXN, Obj } from '@dxos/echo';\nimport { Chess } from '@dxos/plugin-chess';\nimport { Game, GameRef, loadGame } from '@dxos/plugin-game';\n\nconst ChessBot = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.chessBot'),\n name: 'Chess Bot',\n description: 'Plays a random move in a chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n player: Schema.optional(Schema.Literal('white', 'black')).annotations({\n description: 'The player to play the game as.',\n }),\n }),\n output: Schema.Struct({\n state: Schema.String.annotations({\n description: 'The state of the game as an ASCII art board.',\n }),\n }),\n types: [Game, Chess.State],\n services: [Database.Service],\n});\n\nexport default ChessBot.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ game, player = 'black' }) {\n const { variant } = yield* loadGame(game, Chess.State);\n const chess = new ChessJS();\n chess.loadPgn(variant.pgn ?? '');\n if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {\n return { state: chess.ascii() };\n }\n\n const moves = chess.moves({ verbose: true });\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return { state: chess.ascii() };\n }\n\n chess.move(move.san);\n const newPgn = chess.pgn();\n Obj.update(variant, (variant) => {\n const mutable = variant as Obj.Mutable<typeof variant>;\n mutable.pgn = newPgn;\n });\n yield* Database.flush();\n return { state: chess.ascii() };\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as A from '@automerge/automerge';\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { AppAnnotation } from '@dxos/app-toolkit';\nimport { AiRequest, GenerationObserver } from '@dxos/assistant';\nimport { Operation, Trace } from '@dxos/compute';\nimport { Annotation, Collection, Database, DXN, Filter, Obj, Ref, Relation, URI } from '@dxos/echo';\nimport { Doc } from '@dxos/echo-doc';\nimport { registryLayerNoop } from '@dxos/echo/testing';\nimport { log } from '@dxos/log';\nimport { Chess } from '@dxos/plugin-chess';\nimport { Game, GameRef, loadGame } from '@dxos/plugin-game';\nimport { Markdown } from '@dxos/plugin-markdown';\nimport { Text } from '@dxos/schema';\nimport { HasSubject } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nconst Commentary = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.commentary'),\n name: 'Commentary',\n description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n }),\n output: Schema.Union(\n Schema.Struct({\n documentId: URI.Schema.annotations({\n description: 'The ID of the markdown document that was updated or created.',\n }),\n commentary: Schema.String.annotations({\n description: 'The commentary that was added.',\n }),\n }),\n Schema.Void.annotations({\n description: 'Function did not find anything to comment on.',\n }),\n ),\n types: [Game, Chess.State, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],\n services: [AiService.AiService, Database.Service],\n});\n\nexport default Commentary.pipe(\n Operation.withHandler(\n Effect.fnUntraced(\n function* ({ game: gameRef }) {\n // Load the game and its Chess variant state.\n log.info('load game', { gameRef });\n const { game: chessGame, variant: chessState } = yield* loadGame(gameRef, Chess.State);\n\n // Load the chess position from PGN or FEN.\n const chess = new ChessJS();\n if (chessState.pgn) {\n chess.loadPgn(chessState.pgn);\n } else if (chessState.fen) {\n chess.load(chessState.fen);\n } else {\n log.info('Early return: no pgn or fen');\n return;\n }\n\n // Get the most recent move\n const history = chess.history({ verbose: true });\n if (history.length === 0) {\n throw new Error('No moves have been played yet');\n }\n const lastMove = history[history.length - 1];\n const moveNumber = Math.ceil(history.length / 2);\n const isWhiteMove = history.length % 2 === 1;\n const player = isWhiteMove ? 'White' : 'Black';\n const moveNotation = lastMove.san;\n\n // Generate AI commentary about the move\n const result = yield* new AiRequest.Request({\n observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),\n }).run({\n prompt:\n `Comment on this chess move as if you're commentating a live match for an audience:\\n\\n` +\n `Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\\n` +\n `Current position: ${chess.fen()}\\n` +\n `${chess.isCheck() ? 'The king is in check! ' : ''}` +\n `${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +\n `${chess.isStalemate() ? 'STALEMATE! ' : ''}` +\n `\\nGame so far:\\n${chess.pgn()}`,\n system: COMMENTARY_SYSTEM_PROMPT,\n history: [],\n });\n\n const commentaryText = Function.pipe(\n result,\n Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),\n Option.flatMap((msg) =>\n Function.pipe(\n msg.blocks,\n Array.findLast((block) => block._tag === 'text'),\n Option.map((block) => block.text),\n ),\n ),\n Option.getOrThrowWith(() => new Error('No commentary generated')),\n );\n\n const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\\n\\n${commentaryText}\\n\\n`;\n log.info('commentary', { commentary });\n\n // TODO(wittjosiah): Functions currently don't support traversals.\n // const docs = yield* Database.query(\n // Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),\n // ).run.pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));\n const docs = yield* Database.query(Filter.type(HasSubject.HasSubject)).run.pipe(\n Effect.map((relations) =>\n relations.filter((relation) => {\n // TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.\n try {\n log.info('relation', {\n source: Obj.getURI(Relation.getTarget(relation)),\n game: Obj.getURI(chessGame),\n });\n return Obj.getURI(Relation.getTarget(relation)) === Obj.getURI(chessGame);\n } catch {\n return false;\n }\n }),\n ),\n Effect.map((relations) =>\n relations\n .map((relation) => {\n // TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.\n try {\n return Relation.getSource(relation);\n } catch {\n return undefined;\n }\n })\n .filter((source) => source !== undefined),\n ),\n Effect.map((sources) => {\n const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));\n log.info('docs', { sources, docs });\n return docs;\n }),\n );\n log.info('docs', { count: docs.length });\n\n let document: Markdown.Document;\n if (docs.length === 0) {\n // TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.\n const [properties] = yield* Database.query(Filter.type(DXN.make('org.dxos.type.spaceProperties'))).run;\n const rootCollectionRef = Annotation.get(properties, AppAnnotation.RootCollectionAnnotation).pipe(\n Option.getOrUndefined,\n );\n const rootCollection = rootCollectionRef\n ? yield* Database.load<Collection.Collection>(rootCollectionRef)\n : undefined;\n\n log.info('rootCollection', { rootCollection });\n\n // Create a new markdown document\n const gameName = chessGame.name || 'Chess Game';\n document = yield* Database.add(\n Markdown.make({\n name: `${gameName} Commentary`,\n content: `# ${gameName} Commentary\\n\\n${commentary}`,\n }),\n );\n\n const documentRef = Ref.make(document);\n if (rootCollection) {\n Obj.update(rootCollection, (rootCollection) => {\n rootCollection.objects.push(documentRef);\n });\n }\n\n // Create the HasSubject relation\n yield* Database.add(\n Relation.make(HasSubject.HasSubject, {\n [Relation.Source]: document,\n [Relation.Target]: chessGame,\n }),\n );\n } else {\n document = docs[0];\n\n // Load the text content and append the commentary\n const text = yield* Database.load(document.content);\n const accessor = Doc.createAccessor(text, ['content']);\n accessor.handle.change((doc: A.Doc<Text.Text>) => {\n A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);\n });\n }\n\n log.info('result', { documentId: Obj.getURI(document), commentary });\n\n yield* Database.flush();\n\n return {\n documentId: Obj.getURI(document),\n commentary,\n };\n },\n Effect.provide(\n Layer.mergeAll(\n AiService.model('com.anthropic.model.claude-haiku-4-5.default'),\n ToolResolverService.layerEmpty,\n ToolExecutionService.layerEmpty,\n Trace.writerLayerNoop,\n Database.notAvailable,\n Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Not available.'),\n schedule: () => Effect.die('Not available.'),\n invokePromise: async () => ({ error: new Error('Not available.') }),\n } as any),\n registryLayerNoop,\n ),\n ),\n ),\n ),\n);\n\nconst COMMENTARY_SYSTEM_PROMPT = trim`\n You are a professional chess commentator providing live commentary for a chess match.\n\n # Style\n - Write in an engaging, enthusiastic style as if commentating for a live audience\n - Be concise but informative (2-4 sentences)\n - Explain the strategic implications of the move\n - Note any tactical elements (captures, threats, checks)\n - Comment on the position and what it means for the game\n\n # Format\n - Write in plain text (no markdown formatting in the commentary itself)\n - Be natural and conversational\n - Use chess terminology appropriately but keep it accessible\n\n # Special Situations\n - If it's checkmate, express excitement about the conclusion\n - If it's check, note the pressure on the king\n - If a piece is captured, mention the material exchange\n - Comment on the development of pieces and control of key squares when relevant\n`;\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { Expando, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.data-generator',\n name: 'Data Generator',\n inputSchema: S.Struct({\n documentAmount: S.optional(S.Number),\n textSize: S.optional(S.Number),\n mutationAmount: S.optional(S.Number),\n waitAfterCreation: S.optional(S.Number),\n }),\n\n outputSchema: S.Struct({}),\n\n handler: async ({\n data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },\n context: { space },\n }: any) => {\n space.db.graph.registry.add([Expando]);\n const result: Record<string, any> = {};\n const objects: Expando[] = [];\n\n // Create objects.\n for (let i = 0; i < documentAmount; i++) {\n const obj = space.db.add(\n create(Expando, {\n name: 'scriptGenerated',\n content: randText({ charCount: textSize }),\n }),\n );\n objects.push(obj);\n const objectResult: any = {};\n // Mutate the object.\n for (let i = 0; i < mutationAmount; i++) {\n obj.content = randText({ charCount: textSize });\n }\n objectResult.mutations = mutationAmount;\n objectResult.contentLength = obj.content.length;\n result[obj.id] = objectResult;\n }\n\n // Flush and wait for data to propagate.\n await space.db.flush();\n await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));\n return { createdObjects: objects.length };\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { DXN, EchoObject, EntityId, Filter, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\nimport {\n DiscordConfig,\n DiscordREST,\n DiscordRESTMemoryLive,\n // @ts-ignore\n} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n\nconst MessageSchema = S.Struct({\n id: EntityId,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(\n EchoObject({\n typename: 'com.example.type.message',\n version: '0.1.0',\n }),\n);\n\nconst DEFAULT_AFTER = 1704067200; // 2024-01-01\n\nconst generateSnowflake = (unixTimestamp: number): bigint => {\n const discordEpoch = 1420070400000n; // Discord Epoch (ms)\n return (BigInt(unixTimestamp * 1000) - discordEpoch) << 22n;\n};\n\nexport default defineFunction({\n key: 'org.dxos.script.discord',\n name: 'Discord',\n inputSchema: S.Struct({\n // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n channelId: S.String,\n after: S.optional(S.Number),\n pageSize: S.optional(S.Number),\n queueId: S.String,\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 }, context: { space } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'discord.com' })).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(DXN.tryMake(queueId)!),\n catch: (e: any) => e,\n });\n const backfill = objects.length === 0;\n const newMessages = yield* Ref.make(0);\n const lastMessage = yield* Ref.make(objects.at(-1));\n\n const enqueueMessages = Effect.gen(function* () {\n const rest = yield* DiscordREST;\n\n while (true) {\n const last = yield* Ref.get(lastMessage);\n const options = {\n after: backfill && !last ? `${generateSnowflake(after)}` : last?.foreignId,\n limit: pageSize,\n };\n const messages = yield* rest.getChannelMessages(channelId, options).pipe((res: any) => res.json);\n const queueMessages = messages\n .map((message: any) =>\n create(MessageSchema, {\n id: EntityId.random(),\n foreignId: message.id,\n from: message.author.username,\n created: message.timestamp,\n content: message.content,\n }),\n )\n .toReversed();\n if (queueMessages.length > 0) {\n yield* Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(DXN.tryMake(queueId)!, queueMessages),\n catch: (e: any) => e,\n });\n yield* Ref.update(newMessages, (n: any) => n + queueMessages.length);\n yield* Ref.update(lastMessage, (m: any) => queueMessages.at(-1));\n }\n if (messages.length < pageSize) {\n break;\n }\n }\n }).pipe(\n Effect.provide(DiscordRESTMemoryLive),\n Effect.provide(\n DiscordConfig.layerConfig({\n token: Config.succeed(Redacted.make(token)),\n }),\n ),\n Effect.provide(FetchHttpClient.layer),\n );\n\n yield* enqueueMessages;\n return { newMessages: yield* Ref.get(newMessages) };\n }),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Appends a message to the end of a Document configured through a trigger.\n * Trigger must have a targetDocumentId field set in Meta.\n */\nexport default async ({ data: { bodyText }, context: { space } }: any) => {\n const { email, targetDocumentId: documentId } = JSON.parse(bodyText) as RequestPayload;\n\n const document = await space.db.query({ id: documentId }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${email.from}`,\n `**Subject:** ${email.subject}`,\n `**Date:** ${email.created}`,\n '',\n email.body,\n ].join('\\n');\n\n await space.db.update({ id: contentId }, { content: modifiedContent });\n\n return new Response(JSON.stringify({ success: true }));\n};\n\ntype RequestPayload = {\n email: { from: string; subject: string; created: string; body: string };\n targetDocumentId: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport * as Effect from 'effect/Effect';\nimport * as Schedule from 'effect/Schedule';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst ForexEffect = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forexEffect'),\n name: 'Forex Effect',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default ForexEffect.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const json: any = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((response) => response.json),\n Effect.timeout('5 seconds'),\n Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n\n const rate = json?.data?.rates?.[to];\n if (rate == null) {\n return yield* Effect.fail(new Error(`No rate found for ${from} -> ${to}`));\n }\n\n return rate.toString();\n }, Effect.provide(FetchHttpClient.layer)),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Forex = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forex'),\n name: 'Forex',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default Forex.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const res = yield* Effect.promise(() => fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`));\n const {\n data: { rates },\n } = yield* Effect.promise(() => res.json());\n\n return rates[to].toString();\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { EchoObject, EntityId, Filter, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport {\n FetchHttpClient,\n HttpClient,\n HttpClientRequest,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';\n// @ts-ignore\nimport * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n// @ts-ignore\nimport * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';\n// @ts-ignore\nimport * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.gmail',\n name: 'Gmail',\n inputSchema: S.Struct({\n mailboxId: S.String,\n userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),\n after: S.optional(S.Union(S.Number, S.String)).pipe(\n S.withDecodingDefault(() => format(subDays(new Date(), 30), 'yyyy-MM-dd')),\n ),\n pageSize: S.optional(S.Number).pipe(S.withDecodingDefault(() => 100)),\n // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ context: { space }, data: { mailboxId, userId, after, pageSize } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'gmail.com' })).first(),\n catch: (e: any) => e,\n });\n\n // NOTE: Google API bundles size is v. large and caused runtime issues.\n const makeRequest = (url: string) =>\n Function.pipe(\n url,\n HttpClientRequest.get,\n HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),\n HttpClient.execute,\n Effect.flatMap((res: any) => res.json),\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n\n const listMessages = (userId: string, q: string, pageSize: number, pageToken: string | null) =>\n makeRequest(getUrl(userId, undefined, { q, pageSize, pageToken }));\n\n const getMessage = (userId: string, messageId: string) => makeRequest(getUrl(userId, messageId));\n\n const mailbox = yield* Effect.tryPromise({\n try: () => space.db.query({ id: mailboxId }).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(mailbox.queue.uri),\n catch: (e: any) => e,\n });\n const newMessages = yield* Ref.make([]);\n const nextPage = yield* Ref.make(null);\n\n do {\n const last = objects.at(-1);\n const q = last\n ? `in:inbox after:${Math.floor(new Date(last.created).getTime() / 1000)}`\n : `in:inbox after:${after}`;\n const pageToken = yield* Ref.get(nextPage);\n const { messages, nextPageToken } = yield* listMessages(userId, q, pageSize, pageToken);\n yield* Ref.update(nextPage, () => nextPageToken);\n for (const message of messages) {\n const messageDetails = yield* getMessage(userId, message.id);\n const created = new Date(parseInt(messageDetails.internalDate)).toISOString();\n const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');\n const sender = from && parseFromHeader(from.value);\n // TODO(wittjosiah): Improve parsing of email contents.\n const content =\n messageDetails.payload.body?.data ??\n messageDetails.payload.parts?.find((p: any) => p.mimeType === 'text/plain')?.body.data;\n // Skip the message if content or sender is missing.\n // Skip the message if it's the same as the last message.\n // TODO(wittjosiah): This comparison should be done via foreignId probably.\n if (!content || !sender || created === last?.created) {\n continue;\n }\n const subject = messageDetails.payload.headers.find((h: any) => h.name === 'Subject')?.value;\n const object = create(MessageType, {\n id: EntityId.random(),\n created,\n sender,\n blocks: [\n {\n _tag: 'text',\n text: Buffer.from(content, 'base64').toString('utf-8'),\n },\n ],\n properties: {\n subject,\n threadId: message.threadId,\n },\n });\n // TODO(wittjosiah): Set foreignId in object meta.\n yield* Ref.update(newMessages, (n: any) => [object, ...n]);\n }\n } while (yield* Ref.get(nextPage));\n\n const queueMessages = yield* Ref.get(newMessages);\n if (queueMessages.length > 0) {\n yield* Function.pipe(\n queueMessages,\n Stream.fromIterable,\n Stream.grouped(10),\n Stream.flatMap((batch: any) =>\n Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(mailbox.queue.uri, Chunk.toReadonlyArray(batch)),\n catch: (e: any) => e,\n }),\n ),\n Stream.runDrain,\n );\n }\n\n return { newMessages: queueMessages.length };\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n\nconst getUrl = (userId: string, messageId?: string, params?: Record<string, any>) => {\n const api = new URL(\n [`https://gmail.googleapis.com/gmail/v1/users/${userId}/messages`, messageId].filter(Boolean).join('/'),\n );\n Object.entries(params ?? {})\n .filter(([_, value]) => value != null)\n .forEach(([key, value]) => api.searchParams.set(key, value));\n return api.toString();\n};\n\n/**\n * Parses an email string in the format \"Name <email@example.com>\" into separate name and email components.\n */\nconst parseFromHeader = (value: string): { name?: string; email: string } | undefined => {\n const EMAIL_REGEX = /^([^<]+?)\\s*<([^>]+@[^>]+)>$/;\n const removeOuterQuotes = (str: string) => str.replace(/^['\"]|['\"]$/g, '');\n const match = value.match(EMAIL_REGEX);\n if (match) {\n const [, name, email] = match;\n return {\n name: removeOuterQuotes(name.trim()),\n email: email.trim(),\n };\n }\n};\n\n//\n// Schemas\n// TODO(wittjosiah): These schemas should be imported from @dxos/schema.\n//\n\nconst ActorRole = S.Literal('user', 'assistant');\ntype ActorRole = S.Schema.Type<typeof ActorRole>;\n\nconst ActorSchema = S.Struct({\n identityKey: S.optional(S.String),\n email: S.optional(S.String),\n name: S.optional(S.String),\n role: S.optional(ActorRole),\n});\n\nconst Base = S.Struct({\n pending: S.optional(S.Boolean),\n});\ntype Base = S.Schema.Type<typeof Base>;\nconst Text = S.TaggedStruct('text', {\n mimeType: S.optional(S.String),\n text: S.String,\n ...Base.fields,\n}).pipe(S.mutable);\ninterface Text extends S.Schema.Type<typeof Text> {}\n\nconst MessageType = S.Struct({\n id: EntityId,\n created: S.String.annotations({\n description: 'ISO date string when the message was sent.',\n }),\n sender: ActorSchema.annotations({\n description: 'Identity of the message sender.',\n }),\n blocks: S.Array(Text).annotations({\n description: 'Contents of the message.',\n }),\n properties: S.optional(\n S.mutable(\n S.Record({ key: S.String, value: S.Any }).annotations({\n description: 'Custom properties for specific message types (e.g. attention context, email subject, etc.).',\n }),\n ),\n ),\n}).pipe(\n EchoObject({\n typename: 'org.dxos.type.message',\n version: '0.1.0',\n }),\n);\ntype MessageType = S.Schema.Type<typeof MessageType>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Ping = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.ping'),\n name: 'Ping',\n },\n input: Schema.Any,\n output: Schema.Any,\n});\n\nexport default Ping.pipe(\n Operation.withHandler(\n Effect.fn(function* (data) {\n return data;\n }),\n ),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport anthropic from './anthropic.ts?raw';\nimport chessBot from './chess-bot.ts?raw';\nimport commentary from './commentary.ts?raw';\nimport dataGenerator from './data-generator.ts?raw';\nimport discord from './discord.ts?raw';\nimport email from './email.ts?raw';\nimport forexEffect from './forex-effect.ts?raw';\nimport forex from './forex.ts?raw';\nimport gmail from './gmail.ts?raw';\nimport ping from './ping.ts?raw';\n\nconst removeHeader = (str: string) => str.split('\\n').slice(4).join('\\n');\n\nexport { dataGenerator };\n\nexport type Template = {\n id: string;\n name: string;\n source: string;\n presetId?: string;\n};\n\nexport const templates = [\n {\n id: 'org.dxos.script.ping',\n name: 'Ping',\n source: removeHeader(ping),\n },\n {\n id: 'org.dxos.script.forex',\n name: 'Forex',\n source: removeHeader(forex),\n },\n {\n id: 'org.dxos.script.forex-effect',\n name: 'Forex (Effect)',\n source: removeHeader(forexEffect),\n },\n {\n id: 'org.dxos.script.chess-bot',\n name: 'Chess Bot',\n source: removeHeader(chessBot),\n presetId: 'org.dxos.function.chess-bot',\n },\n {\n id: 'org.dxos.script.email',\n name: 'Email',\n source: removeHeader(email),\n presetId: 'org.dxos.function.email',\n },\n {\n id: 'org.dxos.script.discord',\n name: 'Discord',\n source: removeHeader(discord),\n presetId: 'org.dxos.function.discord',\n },\n {\n id: 'org.dxos.script.gmail',\n name: 'Gmail',\n source: removeHeader(gmail),\n presetId: 'org.dxos.function.gmail',\n },\n {\n id: 'org.dxos.script.data-generator',\n name: 'Data Generator',\n source: removeHeader(dataGenerator),\n presetId: 'org.dxos.function.data-generator',\n },\n {\n id: 'org.dxos.script.anthropic',\n name: 'Anthropic',\n source: removeHeader(anthropic),\n },\n {\n id: 'org.dxos.script.commentary',\n name: 'Commentary',\n source: removeHeader(commentary),\n presetId: 'org.dxos.function.chess.commentary',\n },\n] as const;\n"],
|
|
5
|
+
"mappings": ";AAAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACeA,IAAMA,eAAe,CAACC,QAAgBA,IAAIC,MAAM,IAAA,EAAMC,MAAM,CAAA,EAAGC,KAAK,IAAA;AAW7D,IAAMC,YAAY;EACvB;IACEC,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaC,YAAAA;EACvB;EACA;IACEJ,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaE,aAAAA;EACvB;EACA;IACEL,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaG,oBAAAA;EACvB;EACA;IACEN,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaI,iBAAAA;IACrBC,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaM,aAAAA;IACrBD,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaO,eAAAA;IACrBF,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaQ,aAAAA;IACrBH,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaS,sBAAAA;IACrBJ,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaU,iBAAAA;EACvB;EACA;IACEb,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaW,kBAAAA;IACrBN,UAAU;EACZ;;",
|
|
6
|
+
"names": ["removeHeader", "str", "split", "slice", "join", "templates", "id", "name", "source", "removeHeader", "ping", "forex", "forexEffect", "chessBot", "presetId", "email", "discord", "gmail", "dataGenerator", "anthropic", "commentary"]
|
|
7
|
+
}
|
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
} from "../chunk-2REUEDUA.mjs";
|
|
4
4
|
import "../chunk-J5LGTIGS.mjs";
|
|
5
5
|
|
|
6
|
-
// src/components/index.ts
|
|
7
|
-
import { lazy } from "react";
|
|
8
|
-
|
|
9
6
|
// src/components/NotebookStack/NotebookMenu.tsx
|
|
10
7
|
import React from "react";
|
|
11
8
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
@@ -26,20 +23,23 @@ var NotebookMenu = ({ cell, onCellInsert, onCellDelete }) => {
|
|
|
26
23
|
};
|
|
27
24
|
|
|
28
25
|
// src/components/NotebookStack/NotebookStack.tsx
|
|
29
|
-
import React4 from "react";
|
|
30
|
-
import {
|
|
26
|
+
import React4, { useCallback as useCallback2, useMemo as useMemo2, useState } from "react";
|
|
27
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
28
|
+
import { DropdownMenu as DropdownMenu2, IconButton, ScrollArea, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
31
29
|
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
32
|
-
import {
|
|
30
|
+
import { Mosaic } from "@dxos/react-ui-mosaic";
|
|
31
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
32
|
+
import { arrayMove } from "@dxos/util";
|
|
33
33
|
import { meta as meta3 } from "#meta";
|
|
34
34
|
|
|
35
35
|
// src/components/NotebookStack/NotebookCell.tsx
|
|
36
36
|
import React3, { useCallback, useMemo } from "react";
|
|
37
37
|
import { Surface } from "@dxos/app-framework/ui";
|
|
38
|
-
import { AppSurface
|
|
38
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
39
39
|
import { Obj } from "@dxos/echo";
|
|
40
|
-
import {
|
|
40
|
+
import { Doc } from "@dxos/echo-doc";
|
|
41
41
|
import { invariant } from "@dxos/invariant";
|
|
42
|
-
import { TemplateEditor } from "@dxos/plugin-
|
|
42
|
+
import { TemplateEditor } from "@dxos/plugin-routine/components";
|
|
43
43
|
import { useThemeContext as useThemeContext2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
44
44
|
import { QueryEditor } from "@dxos/react-ui-components";
|
|
45
45
|
import { Editor } from "@dxos/react-ui-editor";
|
|
@@ -60,7 +60,6 @@ import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
|
60
60
|
import { continueKeymap } from "@valtown/codemirror-continue";
|
|
61
61
|
import { tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from "@valtown/codemirror-ts";
|
|
62
62
|
import React2 from "react";
|
|
63
|
-
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
64
63
|
import { useThemeContext } from "@dxos/react-ui";
|
|
65
64
|
import { composable, composableProps } from "@dxos/react-ui";
|
|
66
65
|
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
@@ -76,20 +75,20 @@ var TypescriptEditor = composable(({ classNames, id, role = "article", inputMode
|
|
|
76
75
|
scrollTo,
|
|
77
76
|
extensions: [
|
|
78
77
|
extensions,
|
|
78
|
+
createThemeExtensions({
|
|
79
|
+
monospace: true,
|
|
80
|
+
themeMode,
|
|
81
|
+
syntaxHighlighting: true
|
|
82
|
+
}),
|
|
79
83
|
createBasicExtensions({
|
|
80
84
|
highlightActiveLine: true,
|
|
81
85
|
indentWithTab: true,
|
|
82
86
|
lineNumbers: true,
|
|
83
87
|
lineWrapping: false,
|
|
84
|
-
scrollPastEnd: role
|
|
88
|
+
scrollPastEnd: role === "article",
|
|
85
89
|
search: true,
|
|
86
90
|
...options
|
|
87
91
|
}),
|
|
88
|
-
createThemeExtensions({
|
|
89
|
-
monospace: true,
|
|
90
|
-
themeMode,
|
|
91
|
-
syntaxHighlighting: true
|
|
92
|
-
}),
|
|
93
92
|
InputModeExtensions[inputMode],
|
|
94
93
|
javascript({
|
|
95
94
|
typescript: true
|
|
@@ -168,11 +167,11 @@ var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
|
168
167
|
return cell.source?.target ? [
|
|
169
168
|
createDataExtensions({
|
|
170
169
|
id: cell.id,
|
|
171
|
-
text:
|
|
170
|
+
text: Doc.createAccessor(cell.source.target, [
|
|
172
171
|
"content"
|
|
173
172
|
])
|
|
174
173
|
})
|
|
175
|
-
]
|
|
174
|
+
] : [];
|
|
176
175
|
}, [
|
|
177
176
|
cell.source?.target
|
|
178
177
|
]);
|
|
@@ -200,7 +199,9 @@ var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
|
200
199
|
if (!cell.source?.target) {
|
|
201
200
|
return null;
|
|
202
201
|
}
|
|
203
|
-
return /* @__PURE__ */ React3.createElement(
|
|
202
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
203
|
+
className: "flex flex-col divide-y divide-subdued-separator"
|
|
204
|
+
}, /* @__PURE__ */ React3.createElement(TypescriptEditor, {
|
|
204
205
|
id: cell.id,
|
|
205
206
|
role: "section",
|
|
206
207
|
classNames: editorStyles,
|
|
@@ -224,15 +225,12 @@ var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
|
224
225
|
className: mx("h-full overflow-hidden grid", explorerGraph && !dragging && "grid-rows-[min-content_1fr]")
|
|
225
226
|
}, /* @__PURE__ */ React3.createElement(QueryEditor, {
|
|
226
227
|
id: cell.id,
|
|
227
|
-
classNames:
|
|
228
|
-
editorStyles,
|
|
229
|
-
"border-b border-subdued-separator"
|
|
230
|
-
],
|
|
228
|
+
classNames: editorStyles,
|
|
231
229
|
db,
|
|
232
230
|
value: cell.source.target.content,
|
|
233
231
|
onChange: handleQueryChange
|
|
234
232
|
}), explorerGraph && !dragging && /* @__PURE__ */ React3.createElement(Surface.Surface, {
|
|
235
|
-
type:
|
|
233
|
+
type: AppSurface.Section,
|
|
236
234
|
limit: 1,
|
|
237
235
|
data: {
|
|
238
236
|
subject: explorerGraph,
|
|
@@ -246,7 +244,7 @@ var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
|
246
244
|
}
|
|
247
245
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(TemplateEditor, {
|
|
248
246
|
id: cell.id,
|
|
249
|
-
source: cell.prompt.target.
|
|
247
|
+
source: cell.prompt.target.text,
|
|
250
248
|
lineNumbers: false,
|
|
251
249
|
classNames: editorStyles
|
|
252
250
|
}), /* @__PURE__ */ React3.createElement(NotebookPromptResult, {
|
|
@@ -264,7 +262,7 @@ var NotebookCellValue = ({ cell, graph }) => {
|
|
|
264
262
|
return null;
|
|
265
263
|
}
|
|
266
264
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
267
|
-
className: mx("flex w-full bg-group-surface
|
|
265
|
+
className: mx("flex w-full bg-group-surface text-description font-mono", valueStyles)
|
|
268
266
|
}, name && /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("span", {
|
|
269
267
|
className: "text-success-text"
|
|
270
268
|
}, name), /* @__PURE__ */ React3.createElement("span", {
|
|
@@ -291,22 +289,26 @@ var NotebookTextEditor = ({ extensions: extensionsProp, readOnly, ...props }) =>
|
|
|
291
289
|
const { themeMode } = useThemeContext2();
|
|
292
290
|
const extensions = useMemo(() => {
|
|
293
291
|
return [
|
|
294
|
-
createBasicExtensions2({
|
|
295
|
-
placeholder: t("notebook-markdown.placeholder"),
|
|
296
|
-
readOnly
|
|
297
|
-
}),
|
|
298
292
|
createThemeExtensions2({
|
|
299
293
|
themeMode,
|
|
300
294
|
syntaxHighlighting: true
|
|
301
295
|
}),
|
|
296
|
+
createBasicExtensions2({
|
|
297
|
+
placeholder: t("notebook-markdown.placeholder"),
|
|
298
|
+
readOnly
|
|
299
|
+
}),
|
|
302
300
|
createMarkdownExtensions(),
|
|
303
301
|
decorateMarkdown(),
|
|
304
302
|
extensionsProp
|
|
305
303
|
].filter(isNonNullable2);
|
|
306
304
|
}, [
|
|
307
|
-
extensionsProp
|
|
305
|
+
extensionsProp,
|
|
306
|
+
readOnly,
|
|
307
|
+
themeMode,
|
|
308
|
+
t
|
|
308
309
|
]);
|
|
309
310
|
return /* @__PURE__ */ React3.createElement(Editor.Root, null, /* @__PURE__ */ React3.createElement(Editor.View, {
|
|
311
|
+
classNames: "border",
|
|
310
312
|
...props,
|
|
311
313
|
extensions,
|
|
312
314
|
selectionEnd: true
|
|
@@ -315,46 +317,86 @@ var NotebookTextEditor = ({ extensions: extensionsProp, readOnly, ...props }) =>
|
|
|
315
317
|
|
|
316
318
|
// src/components/NotebookStack/NotebookStack.tsx
|
|
317
319
|
var minSectionHeight = "min-h-[16rem]";
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
+
var getCellId = (cell) => cell.id;
|
|
321
|
+
var NotebookStack = composable2(({ notebook, db, graph, promptResults, onCellInsert, onCellDelete, env, ...props }, forwardedRef) => {
|
|
322
|
+
const [viewport, setViewport] = useState(null);
|
|
323
|
+
const Tile = useCallback2((tileProps) => /* @__PURE__ */ React4.createElement(NotebookSection, {
|
|
324
|
+
...tileProps,
|
|
320
325
|
db,
|
|
321
326
|
graph,
|
|
322
327
|
promptResults,
|
|
323
328
|
onCellInsert,
|
|
324
329
|
onCellDelete,
|
|
325
330
|
env
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
}), [
|
|
332
|
+
db,
|
|
333
|
+
graph,
|
|
334
|
+
promptResults,
|
|
335
|
+
onCellInsert,
|
|
336
|
+
onCellDelete,
|
|
337
|
+
env
|
|
338
|
+
]);
|
|
339
|
+
const eventHandler = useMemo2(() => ({
|
|
340
|
+
id: notebook?.id ?? "notebook",
|
|
341
|
+
// Only the notebook's own cells are droppable; onDrop only reorders within this notebook.
|
|
342
|
+
canDrop: ({ source }) => !!notebook && notebook.cells.some((cell) => cell.id === source.id),
|
|
343
|
+
onDrop: ({ source, target }) => {
|
|
344
|
+
if (!notebook || !target) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const to = target.type === "tile" || target.type === "placeholder" ? target.location : target.type === "container" ? notebook.cells.length : -1;
|
|
348
|
+
const insertIndex = typeof to === "number" && to >= 0 ? Math.floor(to) : -1;
|
|
349
|
+
if (insertIndex < 0) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
Obj2.update(notebook, (notebook2) => {
|
|
353
|
+
const from = notebook2.cells.findIndex((cell) => cell.id === source.id);
|
|
354
|
+
if (from !== -1) {
|
|
355
|
+
arrayMove(notebook2.cells, from, insertIndex);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}), [
|
|
360
|
+
notebook
|
|
361
|
+
]);
|
|
362
|
+
return /* @__PURE__ */ React4.createElement(Mosaic.Root, {
|
|
333
363
|
ref: forwardedRef
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
364
|
+
}, /* @__PURE__ */ React4.createElement(Mosaic.Container, {
|
|
365
|
+
asChild: true,
|
|
366
|
+
orientation: "vertical",
|
|
367
|
+
autoScroll: viewport,
|
|
368
|
+
eventHandler
|
|
369
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
|
|
370
|
+
orientation: "vertical",
|
|
371
|
+
padding: true,
|
|
372
|
+
...composableProps2(props)
|
|
373
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, {
|
|
374
|
+
ref: setViewport
|
|
375
|
+
}, /* @__PURE__ */ React4.createElement(Mosaic.Stack, {
|
|
376
|
+
orientation: "vertical",
|
|
377
|
+
items: notebook?.cells ?? [],
|
|
378
|
+
getId: getCellId,
|
|
379
|
+
Tile
|
|
380
|
+
})))));
|
|
339
381
|
});
|
|
340
|
-
var NotebookSection = ({ cell, db, env, promptResults, onCellInsert, onCellDelete, ...
|
|
382
|
+
var NotebookSection = ({ data: cell, db, env, graph, promptResults, onCellInsert, onCellDelete, ...tileProps }) => {
|
|
341
383
|
const { t } = useTranslation3(meta3.profile.key);
|
|
342
384
|
const resizable = cell.type === "query";
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
asChild: true
|
|
385
|
+
const [dragHandle, setDragHandle] = useState(null);
|
|
386
|
+
return /* @__PURE__ */ React4.createElement(Mosaic.Tile, {
|
|
387
|
+
...tileProps,
|
|
388
|
+
data: cell,
|
|
389
|
+
dragHandle,
|
|
390
|
+
classNames: mx2("grid grid-cols-[min-content_1fr] overflow-visible border border-subdued-separator", resizable && minSectionHeight)
|
|
391
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
392
|
+
className: "flex flex-col p-1 border-e border-subdued-separator dx-attention-surface"
|
|
352
393
|
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
394
|
+
ref: setDragHandle,
|
|
353
395
|
variant: "ghost",
|
|
354
396
|
icon: "ph--dots-six-vertical--regular",
|
|
355
397
|
iconOnly: true,
|
|
356
398
|
label: "Drag handle"
|
|
357
|
-
})
|
|
399
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu2.Root, null, /* @__PURE__ */ React4.createElement(DropdownMenu2.Trigger, {
|
|
358
400
|
asChild: true
|
|
359
401
|
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
360
402
|
variant: "ghost",
|
|
@@ -365,26 +407,17 @@ var NotebookSection = ({ cell, db, env, promptResults, onCellInsert, onCellDelet
|
|
|
365
407
|
cell,
|
|
366
408
|
onCellInsert,
|
|
367
409
|
onCellDelete
|
|
368
|
-
}))
|
|
369
|
-
classNames: "overflow-visible bg-group-surface border border-subdued-separator"
|
|
370
|
-
}, /* @__PURE__ */ React4.createElement(NotebookCell, {
|
|
371
|
-
db,
|
|
372
|
-
cell: cell2,
|
|
373
|
-
env,
|
|
374
|
-
dragging: true
|
|
375
|
-
}))), /* @__PURE__ */ React4.createElement(StackItem.Content, {
|
|
376
|
-
classNames: "overflow-visible"
|
|
377
|
-
}, /* @__PURE__ */ React4.createElement(NotebookCell, {
|
|
410
|
+
}))), /* @__PURE__ */ React4.createElement(NotebookCell, {
|
|
378
411
|
db,
|
|
379
412
|
cell,
|
|
380
413
|
env,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}))
|
|
414
|
+
graph,
|
|
415
|
+
promptResults
|
|
416
|
+
}));
|
|
384
417
|
};
|
|
385
418
|
|
|
386
419
|
// src/components/QueryEditor/QueryEditor.tsx
|
|
387
|
-
import React5, { useState } from "react";
|
|
420
|
+
import React5, { useState as useState2 } from "react";
|
|
388
421
|
import { ModuleResolutionKind, ScriptTarget } from "typescript";
|
|
389
422
|
import queryApi from "@dxos/echo-query/api.d.ts?raw";
|
|
390
423
|
import { useAsyncEffect } from "@dxos/react-ui";
|
|
@@ -402,7 +435,7 @@ var GLOBALS = `
|
|
|
402
435
|
export {};
|
|
403
436
|
`;
|
|
404
437
|
var QueryEditor2 = (props) => {
|
|
405
|
-
const [compiler, setCompiler] =
|
|
438
|
+
const [compiler, setCompiler] = useState2();
|
|
406
439
|
useAsyncEffect(async () => {
|
|
407
440
|
const compiler2 = new Compiler({
|
|
408
441
|
lib: [
|
|
@@ -426,8 +459,8 @@ var QueryEditor2 = (props) => {
|
|
|
426
459
|
|
|
427
460
|
// src/components/ScriptToolbar/ScriptToolbar.tsx
|
|
428
461
|
import { Atom } from "@effect-atom/atom-react";
|
|
429
|
-
import React6, { useMemo as
|
|
430
|
-
import { AppSurface as
|
|
462
|
+
import React6, { useMemo as useMemo3 } from "react";
|
|
463
|
+
import { AppSurface as AppSurface2 } from "@dxos/app-toolkit/ui";
|
|
431
464
|
import { ElevationProvider, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
432
465
|
import { composable as composable3, composableProps as composableProps3 } from "@dxos/react-ui";
|
|
433
466
|
import { Menu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
|
|
@@ -438,7 +471,7 @@ var ScriptToolbar = composable3(({ script, attendableId, role, state, ...props }
|
|
|
438
471
|
const options = useDeployDeps({
|
|
439
472
|
script
|
|
440
473
|
});
|
|
441
|
-
const menuCreator =
|
|
474
|
+
const menuCreator = useMemo3(() => createToolbarActions({
|
|
442
475
|
state,
|
|
443
476
|
script,
|
|
444
477
|
t,
|
|
@@ -451,7 +484,7 @@ var ScriptToolbar = composable3(({ script, attendableId, role, state, ...props }
|
|
|
451
484
|
]);
|
|
452
485
|
const menuActions = useMenuActions(menuCreator);
|
|
453
486
|
return /* @__PURE__ */ React6.createElement(ElevationProvider, {
|
|
454
|
-
elevation: role ===
|
|
487
|
+
elevation: role === AppSurface2.Section.role ? "positioned" : "base"
|
|
455
488
|
}, /* @__PURE__ */ React6.createElement(Menu.Root, {
|
|
456
489
|
...menuActions,
|
|
457
490
|
attendableId
|
|
@@ -487,20 +520,20 @@ var createToolbarActions = ({ state, script, ...options }) => Atom.make((get) =>
|
|
|
487
520
|
});
|
|
488
521
|
|
|
489
522
|
// src/components/TestPanel/TestPanel.tsx
|
|
490
|
-
import React7, { forwardRef, useRef, useState as
|
|
523
|
+
import React7, { forwardRef, useRef, useState as useState3 } from "react";
|
|
491
524
|
import { log } from "@dxos/log";
|
|
492
|
-
import { Avatar, Icon, Input, ScrollArea, Toolbar, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
525
|
+
import { Avatar, Icon, Input, ScrollArea as ScrollArea2, Toolbar, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
493
526
|
import { composable as composable4, composableProps as composableProps4 } from "@dxos/react-ui";
|
|
494
527
|
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
495
|
-
import { mx as
|
|
528
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
496
529
|
import { meta as meta5 } from "#meta";
|
|
497
530
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/TestPanel/TestPanel.tsx";
|
|
498
531
|
var TestPanel = composable4(({ classNames, onInvoke, ...props }, forwardedRef) => {
|
|
499
532
|
const { t } = useTranslation5(meta5.profile.key);
|
|
500
533
|
const inputRef = useRef(null);
|
|
501
|
-
const [input, setInput] =
|
|
502
|
-
const [state, setState] =
|
|
503
|
-
const [history, setHistory] =
|
|
534
|
+
const [input, setInput] = useState3("");
|
|
535
|
+
const [state, setState] = useState3(null);
|
|
536
|
+
const [history, setHistory] = useState3([]);
|
|
504
537
|
const scrollerRef = useRef(null);
|
|
505
538
|
const handleScroll = () => {
|
|
506
539
|
if (scrollerRef.current) {
|
|
@@ -607,11 +640,11 @@ var TestPanel = composable4(({ classNames, onInvoke, ...props }, forwardedRef) =
|
|
|
607
640
|
})));
|
|
608
641
|
});
|
|
609
642
|
var MessageThread = /* @__PURE__ */ forwardRef(({ state, history }, forwardedRef) => {
|
|
610
|
-
return /* @__PURE__ */ React7.createElement(
|
|
643
|
+
return /* @__PURE__ */ React7.createElement(ScrollArea2.Root, {
|
|
611
644
|
orientation: "vertical",
|
|
612
645
|
classNames: "h-full",
|
|
613
646
|
ref: forwardedRef
|
|
614
|
-
}, /* @__PURE__ */ React7.createElement(
|
|
647
|
+
}, /* @__PURE__ */ React7.createElement(ScrollArea2.Viewport, {
|
|
615
648
|
classNames: "gap-6 p-2"
|
|
616
649
|
}, history.map((message, i) => /* @__PURE__ */ React7.createElement("div", {
|
|
617
650
|
key: i,
|
|
@@ -636,14 +669,14 @@ var MessageItem = ({ classNames, message }) => {
|
|
|
636
669
|
const { type, text, data, error } = message;
|
|
637
670
|
const wrapper = "p-1 px-2 rounded-md bg-hover-surface overflow-auto";
|
|
638
671
|
return /* @__PURE__ */ React7.createElement("div", {
|
|
639
|
-
className:
|
|
672
|
+
className: mx3("flex", type === "request" ? "ml-[1rem] justify-end" : "mr-[1rem]", classNames)
|
|
640
673
|
}, error && /* @__PURE__ */ React7.createElement("div", {
|
|
641
|
-
className:
|
|
674
|
+
className: mx3(wrapper, "whitespace-pre text-error-text")
|
|
642
675
|
}, String(error)), text !== void 0 && /* @__PURE__ */ React7.createElement("div", {
|
|
643
|
-
className:
|
|
676
|
+
className: mx3(wrapper, type === "request" && "bg-primary-500 dark:bg-primary-600")
|
|
644
677
|
}, text || "\xD8"), data && /* @__PURE__ */ React7.createElement(JsonHighlighter, {
|
|
645
678
|
data,
|
|
646
|
-
classNames:
|
|
679
|
+
classNames: mx3(wrapper, "text-xs")
|
|
647
680
|
}));
|
|
648
681
|
};
|
|
649
682
|
var RobotAvatar = () => /* @__PURE__ */ React7.createElement(Avatar.Root, null, /* @__PURE__ */ React7.createElement(Avatar.Content, {
|
|
@@ -651,14 +684,10 @@ var RobotAvatar = () => /* @__PURE__ */ React7.createElement(Avatar.Root, null,
|
|
|
651
684
|
variant: "circle",
|
|
652
685
|
icon: "ph--drone--regular"
|
|
653
686
|
}));
|
|
654
|
-
|
|
655
|
-
// src/components/index.ts
|
|
656
|
-
var ScriptPluginSettings = lazy(() => import("../ScriptPluginSettings-5AURDJTI.mjs"));
|
|
657
687
|
export {
|
|
658
688
|
NotebookMenu,
|
|
659
689
|
NotebookStack,
|
|
660
690
|
QueryEditor2 as QueryEditor,
|
|
661
|
-
ScriptPluginSettings,
|
|
662
691
|
ScriptToolbar,
|
|
663
692
|
TestPanel,
|
|
664
693
|
TypescriptEditor
|