@dxos/plugin-script 0.8.4-main.1da679c → 0.8.4-main.21d9917
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-GXNRUXF6.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs +845 -0
- package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-X6GCYZZW.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-3O2DQGCP.mjs +113 -0
- package/dist/lib/browser/chunk-3O2DQGCP.mjs.map +7 -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-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-IQRLM6JK.mjs +137 -0
- package/dist/lib/browser/chunk-IQRLM6JK.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-NWSK27QB.mjs +606 -0
- package/dist/lib/browser/chunk-NWSK27QB.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-WX2NVNFQ.mjs +557 -0
- package/dist/lib/browser/chunk-WX2NVNFQ.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/compiler-XRBFQFXO.mjs +161 -0
- package/dist/lib/browser/compiler-XRBFQFXO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +137 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-MUNR376F.mjs +82 -0
- package/dist/lib/browser/operation-resolver-MUNR376F.mjs.map +7 -0
- package/dist/lib/browser/react-surface-5TEC66UY.mjs +139 -0
- package/dist/lib/browser/react-surface-5TEC66UY.mjs.map +7 -0
- package/dist/lib/browser/settings-R4WKREUJ.mjs +35 -0
- package/dist/lib/browser/settings-R4WKREUJ.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-EVFV2VJT.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs +846 -0
- package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.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-AHXJ6NQU.mjs → chunk-5HSJPAK7.mjs} +8 -5
- package/dist/lib/node-esm/chunk-5HSJPAK7.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-KN6SQYUF.mjs +114 -0
- package/dist/lib/node-esm/chunk-KN6SQYUF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MGWKULCD.mjs +558 -0
- package/dist/lib/node-esm/chunk-MGWKULCD.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-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/chunk-YEWLTVBT.mjs +138 -0
- package/dist/lib/node-esm/chunk-YEWLTVBT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs +607 -0
- package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-ORJAXDN7.mjs +162 -0
- package/dist/lib/node-esm/compiler-ORJAXDN7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +137 -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-CLE4ZCC5.mjs +83 -0
- package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs +140 -0
- package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs.map +7 -0
- package/dist/lib/node-esm/settings-OFIMHU7K.mjs +36 -0
- package/dist/lib/node-esm/settings-OFIMHU7K.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 +3 -3
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +114 -10
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.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 +241 -2
- 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 +3 -3
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -1
- 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 +16 -31
- 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 +31 -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 +4 -4
- 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 +117 -82
- package/src/ScriptPlugin.tsx +55 -75
- 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} +98 -96
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +74 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +118 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +32 -0
- package/src/compiler/compiler.ts +10 -3
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +37 -26
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +41 -50
- package/src/components/FrameContainer/FrameContainer.tsx +6 -4
- package/src/components/NotebookContainer.stories.tsx +87 -0
- package/src/components/NotebookContainer.tsx +270 -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 +50 -35
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +54 -19
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -36
- package/src/components/Settings/ScriptObjectSettings.tsx +136 -29
- package/src/components/Settings/ScriptPluginSettings.tsx +11 -21
- package/src/components/TestPanel/TestContainer.tsx +7 -7
- package/src/components/TestPanel/TestPanel.tsx +42 -19
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +77 -17
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +81 -80
- 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 +44 -37
- 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 +14 -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 +3 -1
- package/src/templates/discord.ts +9 -1
- package/src/templates/forex-effect.ts +24 -25
- package/src/templates/forex.ts +9 -6
- package/src/templates/gmail.ts +22 -11
- 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 +34 -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 +30 -40
- package/src/util/functions.ts +56 -23
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-QZSTVNIS.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs +0 -265
- package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs +0 -64
- package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
- package/dist/lib/browser/chunk-4AUQEB2I.mjs +0 -88
- package/dist/lib/browser/chunk-4AUQEB2I.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-B5QYN3AG.mjs +0 -556
- package/dist/lib/browser/chunk-B5QYN3AG.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-KLGK77UK.mjs +0 -283
- package/dist/lib/browser/chunk-KLGK77UK.mjs.map +0 -7
- package/dist/lib/browser/chunk-NXKU3BNX.mjs +0 -222
- package/dist/lib/browser/chunk-NXKU3BNX.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-YCZPTTFO.mjs +0 -153
- package/dist/lib/browser/chunk-YCZPTTFO.mjs.map +0 -7
- package/dist/lib/browser/compiler-O7MNN3XT.mjs +0 -98
- package/dist/lib/browser/compiler-O7MNN3XT.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs +0 -89
- package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-C4ZTW4QA.mjs +0 -104
- package/dist/lib/browser/react-surface-C4ZTW4QA.mjs.map +0 -7
- package/dist/lib/browser/settings-A4E4R7VL.mjs +0 -24
- package/dist/lib/browser/settings-A4E4R7VL.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-G6EHEPXN.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs +0 -266
- package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs +0 -65
- package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-35M3CHYE.mjs +0 -16
- package/dist/lib/node-esm/chunk-35M3CHYE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5OGRMRLA.mjs +0 -90
- package/dist/lib/node-esm/chunk-5OGRMRLA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.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-M642JUOZ.mjs +0 -223
- package/dist/lib/node-esm/chunk-M642JUOZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MPN2DI4P.mjs +0 -557
- package/dist/lib/node-esm/chunk-MPN2DI4P.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WXKOIREL.mjs +0 -284
- package/dist/lib/node-esm/chunk-WXKOIREL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZA36GO4T.mjs +0 -154
- package/dist/lib/node-esm/chunk-ZA36GO4T.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs +0 -99
- package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs +0 -90
- package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs +0 -105
- package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs.map +0 -7
- package/dist/lib/node-esm/settings-FZ25DUX4.mjs +0 -25
- package/dist/lib/node-esm/settings-FZ25DUX4.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/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/blueprint-definition.ts +0 -30
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -34
- package/src/capabilities/intent-resolver.ts +0 -77
- package/src/capabilities/react-surface.tsx +0 -90
- 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-QZSTVNIS.mjs.map → DeploymentDialog-GXNRUXF6.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-G6EHEPXN.mjs.map → browser/blueprints/index.mjs.map} +0 -0
|
@@ -5,31 +5,38 @@
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
6
|
import React, { type ChangeEvent, useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ToolId } from '@dxos/ai';
|
|
9
|
+
import { SettingsOperation } from '@dxos/app-framework';
|
|
10
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
11
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
12
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
13
|
+
import { Function, type Script, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
14
|
+
import { getInvocationUrl } from '@dxos/functions-runtime';
|
|
10
15
|
import { log } from '@dxos/log';
|
|
11
16
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import {
|
|
17
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
13
18
|
import { Button, Clipboard, Input, useAsyncEffect, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
|
-
import {
|
|
19
|
+
import { AccessToken } from '@dxos/types';
|
|
20
|
+
import { kebabize } from '@dxos/util';
|
|
15
21
|
|
|
16
|
-
import {
|
|
22
|
+
import { meta } from '../../meta';
|
|
17
23
|
|
|
18
24
|
export type ScriptObjectSettingsProps = {
|
|
19
|
-
object:
|
|
25
|
+
object: Script.Script;
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export const ScriptObjectSettings = ({ object }: ScriptObjectSettingsProps) => {
|
|
23
29
|
return (
|
|
24
30
|
<>
|
|
25
31
|
<Binding object={object} />
|
|
32
|
+
<BlueprintEditor object={object} />
|
|
26
33
|
<Publishing object={object} />
|
|
27
34
|
</>
|
|
28
35
|
);
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
32
|
-
const { t } = useTranslation(
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
33
40
|
return (
|
|
34
41
|
<Input.Root>
|
|
35
42
|
<Input.Label>{t('description label')}</Input.Label>
|
|
@@ -37,24 +44,118 @@ export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
37
44
|
placeholder={t('description placeholder')}
|
|
38
45
|
value={object.description ?? ''}
|
|
39
46
|
onChange={(event) => {
|
|
40
|
-
object
|
|
47
|
+
Obj.change(object, (o) => {
|
|
48
|
+
o.description = event.target.value;
|
|
49
|
+
});
|
|
41
50
|
}}
|
|
42
51
|
/>
|
|
43
52
|
</Input.Root>
|
|
44
53
|
);
|
|
45
54
|
};
|
|
46
55
|
|
|
56
|
+
const BlueprintEditor = ({ object }: ScriptObjectSettingsProps) => {
|
|
57
|
+
const { t } = useTranslation(meta.id);
|
|
58
|
+
const db = Obj.getDatabase(object);
|
|
59
|
+
const [fn] = useQuery(db, Filter.type(Function.Function, { source: Ref.make(object) }));
|
|
60
|
+
const blueprints = useQuery(db, Filter.type(Blueprint.Blueprint));
|
|
61
|
+
|
|
62
|
+
const [creating, setCreating] = useState(false);
|
|
63
|
+
const [instructions, setInstructions] = useState<string>(`You can run the script "${object.name ?? 'script'}".`);
|
|
64
|
+
const blueprintKey = `dxos.org/blueprint/${kebabize(object.name ?? 'script')}`;
|
|
65
|
+
const existingBlueprint = blueprints.find((bp) => bp.key === blueprintKey);
|
|
66
|
+
|
|
67
|
+
useAsyncEffect(async () => {
|
|
68
|
+
if (!existingBlueprint) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const source = await existingBlueprint.instructions.source.load();
|
|
72
|
+
setInstructions(source.content ?? '');
|
|
73
|
+
}, [existingBlueprint]);
|
|
74
|
+
|
|
75
|
+
const handleSave = useCallback(async () => {
|
|
76
|
+
if (!db) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setCreating(true);
|
|
81
|
+
try {
|
|
82
|
+
if (existingBlueprint) {
|
|
83
|
+
const text = await existingBlueprint.instructions.source.load();
|
|
84
|
+
Obj.change(text, (t) => {
|
|
85
|
+
t.content = instructions;
|
|
86
|
+
});
|
|
87
|
+
if (fn?.key) {
|
|
88
|
+
const toolId = ToolId.make(fn.key);
|
|
89
|
+
if (!existingBlueprint.tools?.includes(toolId)) {
|
|
90
|
+
Obj.change(existingBlueprint, (b) => {
|
|
91
|
+
b.tools = [...(b.tools ?? []), toolId];
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else if (fn?.key) {
|
|
96
|
+
db.add(
|
|
97
|
+
Blueprint.make({
|
|
98
|
+
key: blueprintKey,
|
|
99
|
+
name: object.name ?? 'Script',
|
|
100
|
+
instructions: Template.make({
|
|
101
|
+
source: instructions,
|
|
102
|
+
}),
|
|
103
|
+
tools: [ToolId.make(fn.key)],
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
await db.flush();
|
|
108
|
+
} finally {
|
|
109
|
+
setCreating(false);
|
|
110
|
+
}
|
|
111
|
+
}, [db, existingBlueprint, fn, blueprintKey, object.name, instructions]);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div className='flex flex-col gap-4 mlb-cardSpacingBlock'>
|
|
115
|
+
<div>
|
|
116
|
+
<h2>{t('blueprint editor label', { default: 'Blueprint' })}</h2>
|
|
117
|
+
<p className='text-description text-sm'>
|
|
118
|
+
{t('blueprint editor description', {
|
|
119
|
+
default: 'Create a blueprint that exposes this script as a tool.',
|
|
120
|
+
})}
|
|
121
|
+
</p>
|
|
122
|
+
</div>
|
|
123
|
+
<Input.Root>
|
|
124
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
125
|
+
<Input.Label>{t('blueprint instructions label', { default: 'Instructions' })}</Input.Label>
|
|
126
|
+
<Input.TextArea
|
|
127
|
+
placeholder={t('blueprint instructions placeholder', {
|
|
128
|
+
default: 'Describe how this tool should be used.',
|
|
129
|
+
})}
|
|
130
|
+
rows={6}
|
|
131
|
+
value={instructions}
|
|
132
|
+
onChange={(event) => setInstructions(event.target.value)}
|
|
133
|
+
classNames='resize-y'
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</Input.Root>
|
|
137
|
+
<div className='flex justify-end gap-2'>
|
|
138
|
+
<Button disabled={(!existingBlueprint && !fn?.key) || creating} onClick={handleSave}>
|
|
139
|
+
{t(creating ? 'creating label' : 'create blueprint label', {
|
|
140
|
+
default: creating ? 'Creating…' : 'Create blueprint',
|
|
141
|
+
})}
|
|
142
|
+
</Button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
47
148
|
const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
48
|
-
const { t } = useTranslation(
|
|
149
|
+
const { t } = useTranslation(meta.id);
|
|
49
150
|
const client = useClient();
|
|
50
|
-
const
|
|
51
|
-
const [fn] = useQuery(
|
|
151
|
+
const db = Obj.getDatabase(object);
|
|
152
|
+
const [fn] = useQuery(db, Filter.type(Function.Function, { source: Ref.make(object) }));
|
|
52
153
|
|
|
53
|
-
const functionId = fn && getUserFunctionIdInMetadata(getMeta(fn));
|
|
154
|
+
const functionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
|
|
54
155
|
const functionUrl =
|
|
55
156
|
functionId &&
|
|
56
157
|
getInvocationUrl(functionId, client.config.values.runtime?.services?.edge?.url ?? '', {
|
|
57
|
-
spaceId:
|
|
158
|
+
spaceId: db?.spaceId,
|
|
58
159
|
});
|
|
59
160
|
|
|
60
161
|
const [binding, setBinding] = useControlledState(fn?.binding ?? '');
|
|
@@ -66,7 +167,9 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
66
167
|
);
|
|
67
168
|
|
|
68
169
|
const handleBindingBlur = useCallback(() => {
|
|
69
|
-
fn
|
|
170
|
+
Obj.change(fn, (f) => {
|
|
171
|
+
f.binding = binding;
|
|
172
|
+
});
|
|
70
173
|
}, [fn, binding]);
|
|
71
174
|
|
|
72
175
|
if (!fn || !functionUrl) {
|
|
@@ -85,7 +188,9 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
85
188
|
disabled
|
|
86
189
|
value={functionUrl}
|
|
87
190
|
onChange={(event) => {
|
|
88
|
-
fn
|
|
191
|
+
Obj.change(fn, (f) => {
|
|
192
|
+
f.name = event.target.value;
|
|
193
|
+
});
|
|
89
194
|
}}
|
|
90
195
|
/>
|
|
91
196
|
<Clipboard.IconButton value={functionUrl} />
|
|
@@ -109,11 +214,11 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
109
214
|
|
|
110
215
|
// TODO(burdon): Move to separate tab?
|
|
111
216
|
const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
112
|
-
const { t } = useTranslation(
|
|
113
|
-
const {
|
|
114
|
-
const
|
|
115
|
-
const [githubToken] = useQuery(
|
|
116
|
-
const gistKey = getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
217
|
+
const { t } = useTranslation(meta.id);
|
|
218
|
+
const { invokePromise } = useOperationInvoker();
|
|
219
|
+
const db = Obj.getDatabase(object);
|
|
220
|
+
const [githubToken] = useQuery(db, Filter.type(AccessToken.AccessToken, { source: 'github.com' }));
|
|
221
|
+
const gistKey = Obj.getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
117
222
|
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
118
223
|
|
|
119
224
|
useAsyncEffect(async () => {
|
|
@@ -137,8 +242,11 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
137
242
|
}, [githubToken, gistKey]);
|
|
138
243
|
|
|
139
244
|
const handleOpenTokenManager = useCallback(
|
|
140
|
-
() =>
|
|
141
|
-
|
|
245
|
+
() =>
|
|
246
|
+
invokePromise(SettingsOperation.Open, {
|
|
247
|
+
plugin: 'dxos.org/plugin/token-manager',
|
|
248
|
+
}),
|
|
249
|
+
[invokePromise],
|
|
142
250
|
);
|
|
143
251
|
|
|
144
252
|
const [publishing, setPublishing] = useState(false);
|
|
@@ -151,7 +259,7 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
151
259
|
|
|
152
260
|
try {
|
|
153
261
|
// TODO(wittjosiah): Factor out to intent.
|
|
154
|
-
const meta = getMeta(object);
|
|
262
|
+
const meta = Obj.getMeta(object);
|
|
155
263
|
const githubKey = meta.keys.find(({ source }) => source === 'github.com');
|
|
156
264
|
const gistId = githubKey?.id;
|
|
157
265
|
if (gistId) {
|
|
@@ -164,8 +272,11 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
164
272
|
public: true,
|
|
165
273
|
files,
|
|
166
274
|
});
|
|
167
|
-
|
|
168
|
-
|
|
275
|
+
const gistId = response.data.id;
|
|
276
|
+
if (gistId) {
|
|
277
|
+
Obj.change(object, (obj) => {
|
|
278
|
+
Obj.getMeta(obj).keys.push({ source: 'github.com', id: gistId });
|
|
279
|
+
});
|
|
169
280
|
}
|
|
170
281
|
}
|
|
171
282
|
} finally {
|
|
@@ -196,7 +307,3 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
196
307
|
</div>
|
|
197
308
|
);
|
|
198
309
|
};
|
|
199
|
-
|
|
200
|
-
// TODO(wittjosiah): Factor out.
|
|
201
|
-
// From https://stackoverflow.com/a/67243723/2804332
|
|
202
|
-
const kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
|
|
@@ -4,38 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
7
|
import { useClient } from '@dxos/react-client';
|
|
9
8
|
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
11
9
|
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
10
|
+
import { type EditorInputMode, EditorInputModes } from '@dxos/ui-editor';
|
|
12
11
|
|
|
13
12
|
import { meta } from '../../meta';
|
|
14
|
-
import { type
|
|
13
|
+
import { type ScriptSettings } from '../../types';
|
|
14
|
+
import { getAccessCredential } from '../../util';
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export type ScriptPluginSettingsComponentProps = {
|
|
17
|
+
settings: ScriptSettings;
|
|
18
|
+
onSettingsChange: (fn: (current: ScriptSettings) => ScriptSettings) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ScriptPluginSettings = ({ settings, onSettingsChange }: ScriptPluginSettingsComponentProps) => {
|
|
17
22
|
const { t } = useTranslation(meta.id);
|
|
18
23
|
const client = useClient();
|
|
19
24
|
|
|
20
25
|
// TODO(burdon): Check token.
|
|
21
26
|
const handleAuthenticate = async () => {
|
|
22
27
|
const { identityKey } = client.halo.identity.get()!;
|
|
23
|
-
await client.halo.writeCredentials([
|
|
24
|
-
{
|
|
25
|
-
issuer: identityKey,
|
|
26
|
-
issuanceDate: new Date(),
|
|
27
|
-
subject: {
|
|
28
|
-
id: identityKey,
|
|
29
|
-
assertion: {
|
|
30
|
-
'@type': 'dxos.halo.credentials.ServiceAccess',
|
|
31
|
-
serverName: 'hub.dxos.network',
|
|
32
|
-
serverKey: identityKey,
|
|
33
|
-
identityKey,
|
|
34
|
-
capabilities: ['composer:beta'],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
} satisfies Credential,
|
|
38
|
-
]);
|
|
28
|
+
await client.halo.writeCredentials([getAccessCredential(identityKey)]);
|
|
39
29
|
};
|
|
40
30
|
|
|
41
31
|
return (
|
|
@@ -51,7 +41,7 @@ export const ScriptPluginSettings = ({ settings }: { settings: ScriptSettingsPro
|
|
|
51
41
|
<Select.Root
|
|
52
42
|
value={settings.editorInputMode ?? 'default'}
|
|
53
43
|
onValueChange={(value) => {
|
|
54
|
-
|
|
44
|
+
onSettingsChange((s) => ({ ...s, editorInputMode: value as EditorInputMode }));
|
|
55
45
|
}}
|
|
56
46
|
>
|
|
57
47
|
<Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
7
|
+
import { type Script } from '@dxos/functions';
|
|
8
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
9
9
|
|
|
10
10
|
import { useDeployState, useToolbarState } from '../../hooks';
|
|
11
11
|
|
|
@@ -13,15 +13,15 @@ import { TestPanel } from './TestPanel';
|
|
|
13
13
|
|
|
14
14
|
export type TestContainerProps = {
|
|
15
15
|
role: string;
|
|
16
|
-
script:
|
|
16
|
+
script: Script.Script;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const TestContainer = ({ script }: TestContainerProps) => {
|
|
19
|
+
export const TestContainer = ({ role, script }: TestContainerProps) => {
|
|
20
20
|
const state = useToolbarState();
|
|
21
21
|
useDeployState({ state, script });
|
|
22
22
|
return (
|
|
23
|
-
<
|
|
24
|
-
<TestPanel functionUrl={state.functionUrl} />
|
|
25
|
-
</
|
|
23
|
+
<Layout.Main role={role}>
|
|
24
|
+
<TestPanel functionUrl={state.value.functionUrl} />
|
|
25
|
+
</Layout.Main>
|
|
26
26
|
);
|
|
27
27
|
};
|
|
@@ -7,16 +7,21 @@ import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
|
-
import { errorText, mx } from '@dxos/
|
|
10
|
+
import { errorText, mx } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
13
|
|
|
14
14
|
type State = 'pending' | 'responding';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Request or response.
|
|
18
18
|
*/
|
|
19
|
-
type Message = {
|
|
19
|
+
type Message = {
|
|
20
|
+
type: 'request' | 'response';
|
|
21
|
+
text?: string;
|
|
22
|
+
data?: any;
|
|
23
|
+
error?: Error;
|
|
24
|
+
};
|
|
20
25
|
|
|
21
26
|
export type TestPanelProps = ThemedClassName<{
|
|
22
27
|
functionUrl?: string;
|
|
@@ -24,7 +29,7 @@ export type TestPanelProps = ThemedClassName<{
|
|
|
24
29
|
|
|
25
30
|
// TODO(burdon): Need persistent history (currently lost when switching tabs)..
|
|
26
31
|
export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
27
|
-
const { t } = useTranslation(
|
|
32
|
+
const { t } = useTranslation(meta.id);
|
|
28
33
|
|
|
29
34
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
30
35
|
const [input, setInput] = useState('');
|
|
@@ -41,7 +46,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
41
46
|
}
|
|
42
47
|
};
|
|
43
48
|
|
|
44
|
-
const controller = useRef<AbortController>();
|
|
49
|
+
const controller = useRef<AbortController>(null);
|
|
45
50
|
useEffect(() => {
|
|
46
51
|
return () => {
|
|
47
52
|
handleStop();
|
|
@@ -50,7 +55,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
50
55
|
|
|
51
56
|
const handleStop = () => {
|
|
52
57
|
controller.current?.abort('stop');
|
|
53
|
-
controller.current =
|
|
58
|
+
controller.current = null;
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
const handleClear = () => {
|
|
@@ -61,8 +66,16 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
61
66
|
inputRef.current?.focus();
|
|
62
67
|
};
|
|
63
68
|
|
|
64
|
-
const handleResponse = ({
|
|
65
|
-
|
|
69
|
+
const handleResponse = ({
|
|
70
|
+
text,
|
|
71
|
+
data,
|
|
72
|
+
error,
|
|
73
|
+
}: {
|
|
74
|
+
text?: string;
|
|
75
|
+
data?: any;
|
|
76
|
+
error?: Error;
|
|
77
|
+
} = {}) => {
|
|
78
|
+
controller.current = null;
|
|
66
79
|
setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);
|
|
67
80
|
setResult('');
|
|
68
81
|
setState(null);
|
|
@@ -108,7 +121,9 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
108
121
|
// Check for error.
|
|
109
122
|
if (!response.ok) {
|
|
110
123
|
const text = await response.text();
|
|
111
|
-
handleResponse({
|
|
124
|
+
handleResponse({
|
|
125
|
+
error: new Error(text || response.statusText || String(response.status)),
|
|
126
|
+
});
|
|
112
127
|
return;
|
|
113
128
|
}
|
|
114
129
|
|
|
@@ -159,11 +174,11 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
159
174
|
};
|
|
160
175
|
|
|
161
176
|
return (
|
|
162
|
-
<div className={mx('flex flex-col
|
|
177
|
+
<div className={mx('flex flex-col bs-full overflow-hidden', classNames)}>
|
|
163
178
|
{/* TODO(burdon): Replace with Thread. */}
|
|
164
179
|
<MessageThread ref={scrollerRef} state={state} result={result} history={history} />
|
|
165
180
|
{/* TODO(burdon): Replace with Form based on the function's input schema. */}
|
|
166
|
-
<Toolbar.Root
|
|
181
|
+
<Toolbar.Root>
|
|
167
182
|
<Input.Root>
|
|
168
183
|
<Input.TextInput
|
|
169
184
|
ref={inputRef}
|
|
@@ -174,12 +189,20 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
174
189
|
onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}
|
|
175
190
|
/>
|
|
176
191
|
</Input.Root>
|
|
177
|
-
<Toolbar.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
<Toolbar.IconButton
|
|
193
|
+
icon='ph--play--regular'
|
|
194
|
+
size={4}
|
|
195
|
+
label='Execute'
|
|
196
|
+
iconOnly
|
|
197
|
+
onClick={() => handleRequest(input)}
|
|
198
|
+
/>
|
|
199
|
+
<Toolbar.IconButton
|
|
200
|
+
icon={state ? 'ph--stop--regular' : 'ph--trash--regular'}
|
|
201
|
+
size={4}
|
|
202
|
+
label={state ? 'Stop' : 'Clear'}
|
|
203
|
+
iconOnly
|
|
204
|
+
onClick={() => (state ? handleStop() : handleClear())}
|
|
205
|
+
/>
|
|
183
206
|
</Toolbar.Root>
|
|
184
207
|
</div>
|
|
185
208
|
);
|
|
@@ -196,7 +219,7 @@ type MessageThreadProps = {
|
|
|
196
219
|
const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
197
220
|
({ state, history, result }: MessageThreadProps, forwardedRef) => {
|
|
198
221
|
return (
|
|
199
|
-
<div ref={forwardedRef} className='flex flex-col gap-6
|
|
222
|
+
<div ref={forwardedRef} className='flex flex-col gap-6 bs-full p-2 overflow-x-hidden overflow-y-auto'>
|
|
200
223
|
{history.map((message, i) => (
|
|
201
224
|
<div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
202
225
|
<div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
|
|
@@ -225,7 +248,7 @@ const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
|
225
248
|
|
|
226
249
|
const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {
|
|
227
250
|
const { type, text, data, error } = message;
|
|
228
|
-
const wrapper = 'p-1
|
|
251
|
+
const wrapper = 'p-1 pli-2 rounded-md bg-hoverSurface overflow-auto';
|
|
229
252
|
return (
|
|
230
253
|
<div className={mx('flex', type === 'request' ? 'ml-[1rem] justify-end' : 'mr-[1rem]', classNames)}>
|
|
231
254
|
{error && <div className={mx(wrapper, 'whitespace-pre', errorText)}>{String(error)}</div>}
|
|
@@ -2,36 +2,96 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import React, { useMemo } from 'react';
|
|
6
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
|
+
import { createObject } from '@dxos/react-client/echo';
|
|
10
|
+
import { Toolbar } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
13
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
14
|
+
import { createDataExtensions } from '@dxos/ui-editor';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
18
|
+
|
|
19
|
+
const SCRIPT = trim`
|
|
20
|
+
x * 2
|
|
21
|
+
`;
|
|
9
22
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
const DefaultStory = (props: TypescriptEditorProps) => {
|
|
24
|
+
const object = useMemo(() => createObject({ content: SCRIPT }), []);
|
|
25
|
+
const [result, setResult] = useState<object | undefined>({});
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
// TODO(burdon): Make this work.
|
|
28
|
+
// const object = useMemo(() => Text.make(templates[1].source), []);
|
|
29
|
+
// const script = useMemo(
|
|
30
|
+
// () =>
|
|
31
|
+
// Obj.make(ScriptType, {
|
|
32
|
+
// source: Ref.make(createObject({ content: templates[0].source })),
|
|
33
|
+
// }),
|
|
34
|
+
// [object],
|
|
35
|
+
// );
|
|
15
36
|
|
|
16
|
-
|
|
37
|
+
const extensions = useMemo(
|
|
38
|
+
() => [
|
|
39
|
+
createDataExtensions({
|
|
40
|
+
id: object.id,
|
|
41
|
+
text: createDocAccessor(object, ['content']),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
[],
|
|
45
|
+
);
|
|
17
46
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
47
|
+
const handleRun = useCallback(async () => {
|
|
48
|
+
try {
|
|
49
|
+
const definitions: [string, any][] = [['x', 100]];
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
52
|
+
const result = new Function(...definitions.map(([name]) => name), `return ${object.content.trim()}`)(
|
|
53
|
+
...definitions.map(([, value]) => value),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
setResult({
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
result,
|
|
59
|
+
});
|
|
60
|
+
} catch (err) {
|
|
61
|
+
setResult({
|
|
62
|
+
timestamp: Date.now(),
|
|
63
|
+
error: String(err),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [object]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Layout.Main toolbar>
|
|
70
|
+
{/* <ScriptToolbar script={script} state={{}} /> */}
|
|
71
|
+
<Toolbar.Root>
|
|
72
|
+
<Toolbar.Button onClick={handleRun}>Run</Toolbar.Button>
|
|
73
|
+
</Toolbar.Root>
|
|
74
|
+
<div role='none' className='grid grid-rows-[1fr_min-content] bs-full overflow-hidden text-sm'>
|
|
75
|
+
<TypescriptEditor {...props} initialValue={object.content} extensions={extensions} />
|
|
76
|
+
<Json data={result} classNames='shrink-0 p-2 border-bs border-subduedSeparator' />
|
|
77
|
+
</div>
|
|
78
|
+
</Layout.Main>
|
|
79
|
+
);
|
|
24
80
|
};
|
|
25
81
|
|
|
26
82
|
const meta = {
|
|
27
83
|
title: 'plugins/plugin-script/TypescriptEditor',
|
|
28
|
-
component: TypescriptEditor
|
|
84
|
+
component: TypescriptEditor,
|
|
29
85
|
render: DefaultStory,
|
|
30
|
-
decorators: [withTheme],
|
|
86
|
+
decorators: [withTheme, withLayout({ layout: 'column', classNames: 'is-proseMaxWidth' })],
|
|
31
87
|
} satisfies Meta<typeof DefaultStory>;
|
|
32
88
|
|
|
33
89
|
export default meta;
|
|
34
90
|
|
|
35
91
|
type Story = StoryObj<typeof meta>;
|
|
36
92
|
|
|
37
|
-
export const Default: Story = {
|
|
93
|
+
export const Default: Story = {
|
|
94
|
+
args: {
|
|
95
|
+
id: 'test',
|
|
96
|
+
},
|
|
97
|
+
};
|