@dxos/plugin-assistant 0.7.5-labs.a8b535d
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs +116 -0
- package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs +33 -0
- package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs.map +7 -0
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs +23 -0
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs.map +7 -0
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs +22 -0
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs +110 -0
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs.map +7 -0
- package/dist/lib/browser/chunk-EUMPBC4T.mjs +81 -0
- package/dist/lib/browser/chunk-EUMPBC4T.mjs.map +7 -0
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs +162 -0
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-G7B54APW.mjs +106 -0
- package/dist/lib/browser/chunk-G7B54APW.mjs.map +7 -0
- package/dist/lib/browser/chunk-NFVIZS3B.mjs +1804 -0
- package/dist/lib/browser/chunk-NFVIZS3B.mjs.map +7 -0
- package/dist/lib/browser/chunk-NV7SVHMV.mjs +20 -0
- package/dist/lib/browser/chunk-NV7SVHMV.mjs.map +7 -0
- package/dist/lib/browser/chunk-VZ4W6SHE.mjs +15 -0
- package/dist/lib/browser/chunk-VZ4W6SHE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +218 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs +44 -0
- package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/react-surface-JLXNWOI6.mjs +69 -0
- package/dist/lib/browser/react-surface-JLXNWOI6.mjs.map +7 -0
- package/dist/lib/browser/settings-JTT62IHD.mjs +22 -0
- package/dist/lib/browser/settings-JTT62IHD.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +24 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs +140 -0
- package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-CVHXNHGA.cjs +61 -0
- package/dist/lib/node/ChatContainer-CVHXNHGA.cjs.map +7 -0
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs +53 -0
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs.map +7 -0
- package/dist/lib/node/ai-client-YANJEPO3.cjs +38 -0
- package/dist/lib/node/ai-client-YANJEPO3.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs +122 -0
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs.map +7 -0
- package/dist/lib/node/chunk-37GI4NYH.cjs +183 -0
- package/dist/lib/node/chunk-37GI4NYH.cjs.map +7 -0
- package/dist/lib/node/chunk-GNPXCHFT.cjs +44 -0
- package/dist/lib/node/chunk-GNPXCHFT.cjs.map +7 -0
- package/dist/lib/node/chunk-IXJCGW7U.cjs +130 -0
- package/dist/lib/node/chunk-IXJCGW7U.cjs.map +7 -0
- package/dist/lib/node/chunk-NV4TQQSU.cjs +111 -0
- package/dist/lib/node/chunk-NV4TQQSU.cjs.map +7 -0
- package/dist/lib/node/chunk-XUTDR7HI.cjs +1781 -0
- package/dist/lib/node/chunk-XUTDR7HI.cjs.map +7 -0
- package/dist/lib/node/chunk-ZGH6F5YA.cjs +34 -0
- package/dist/lib/node/chunk-ZGH6F5YA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +226 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-YMMAFVOB.cjs +58 -0
- package/dist/lib/node/intent-resolver-YMMAFVOB.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/react-surface-BSUZQ3HZ.cjs +85 -0
- package/dist/lib/node/react-surface-BSUZQ3HZ.cjs.map +7 -0
- package/dist/lib/node/settings-4YEO7KXF.cjs +36 -0
- package/dist/lib/node/settings-4YEO7KXF.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +46 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs +117 -0
- package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs +34 -0
- package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs.map +7 -0
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs +24 -0
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs +23 -0
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs +111 -0
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-77ARTFBA.mjs +16 -0
- package/dist/lib/node-esm/chunk-77ARTFBA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7JENJTLB.mjs +1805 -0
- package/dist/lib/node-esm/chunk-7JENJTLB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7SV6X6XU.mjs +22 -0
- package/dist/lib/node-esm/chunk-7SV6X6XU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AMQMVQJO.mjs +107 -0
- package/dist/lib/node-esm/chunk-AMQMVQJO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs +163 -0
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LBQGJE5T.mjs +82 -0
- package/dist/lib/node-esm/chunk-LBQGJE5T.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +219 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs +45 -0
- package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs +70 -0
- package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs.map +7 -0
- package/dist/lib/node-esm/settings-S7P5RWQI.mjs +23 -0
- package/dist/lib/node-esm/settings-S7P5RWQI.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +25 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts +2 -0
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-client.d.ts +5 -0
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +183 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/AssistantDialog.d.ts +7 -0
- package/dist/types/src/components/AssistantDialog.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +5 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts +2 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +7 -0
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +17 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +3 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateContainer.d.ts +7 -0
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +10 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts +18 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.d.ts +17 -0
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +10 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +14 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
- package/dist/types/src/components/Thread/index.d.ts +3 -0
- package/dist/types/src/components/Thread/index.d.ts.map +1 -0
- package/dist/types/src/components/Thread/reducer.d.ts +12 -0
- package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/index.d.ts +2 -0
- package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +17 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/email.d.ts +4 -0
- package/dist/types/src/hooks/email.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/invocation-handler.d.ts +5 -0
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.d.ts +76 -0
- package/dist/types/src/hooks/processor.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.test.d.ts +2 -0
- package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +3 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +1 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
- package/dist/types/src/hooks/useServices.d.ts +7 -0
- package/dist/types/src/hooks/useServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +11 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +3 -0
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/testing/test-services.d.ts +5 -0
- package/dist/types/src/testing/test-services.d.ts.map +1 -0
- package/dist/types/src/tools/function.d.ts +5 -0
- package/dist/types/src/tools/function.d.ts.map +1 -0
- package/dist/types/src/tools/index.d.ts +3 -0
- package/dist/types/src/tools/index.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.d.ts +10 -0
- package/dist/types/src/tools/openapi.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.test.d.ts +2 -0
- package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +82 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/chat.d.ts +12 -0
- package/dist/types/src/types/chat.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/service.d.ts +160 -0
- package/dist/types/src/types/service.d.ts.map +1 -0
- package/dist/types/src/types/template.d.ts +40 -0
- package/dist/types/src/types/template.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +37 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +120 -0
- package/src/AssistantPlugin.tsx +105 -0
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +100 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +38 -0
- package/src/capabilities/react-surface.tsx +49 -0
- package/src/capabilities/settings.ts +19 -0
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
- package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
- package/src/components/AmbientDialog/index.ts +5 -0
- package/src/components/AssistantDialog.tsx +31 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +49 -0
- package/src/components/AssistantSettings/index.ts +5 -0
- package/src/components/ChatContainer.tsx +27 -0
- package/src/components/Prompt/Prompt.stories.tsx +79 -0
- package/src/components/Prompt/Prompt.tsx +100 -0
- package/src/components/Prompt/PromptBar.tsx +100 -0
- package/src/components/Prompt/autocomplete.ts +212 -0
- package/src/components/Prompt/index.ts +6 -0
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
- package/src/components/ServiceRegistry/index.ts +5 -0
- package/src/components/TemplateContainer.tsx +21 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +83 -0
- package/src/components/TemplateEditor/TemplateEditor.tsx +76 -0
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +65 -0
- package/src/components/TemplateEditor/TemplateForm.tsx +184 -0
- package/src/components/TemplateEditor/index.ts +5 -0
- package/src/components/TemplateEditor/types.tsx +28 -0
- package/src/components/Thread/Thread.stories.tsx +212 -0
- package/src/components/Thread/Thread.tsx +97 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +268 -0
- package/src/components/Thread/ThreadContainer.tsx +79 -0
- package/src/components/Thread/ThreadMessage.tsx +188 -0
- package/src/components/Thread/ToolInvocations.tsx +104 -0
- package/src/components/Thread/index.ts +6 -0
- package/src/components/Thread/reducer.ts +52 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +69 -0
- package/src/components/Toolbox/Toolbox.tsx +115 -0
- package/src/components/Toolbox/index.ts +5 -0
- package/src/components/index.ts +15 -0
- package/src/hooks/email.ts +49 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/invocation-handler.ts +109 -0
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +228 -0
- package/src/hooks/useChatProcessor.tsx +80 -0
- package/src/hooks/useLocalTriggerManager.ts +82 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/hooks/useTextInputEvents.ts +49 -0
- package/src/index.ts +9 -0
- package/src/meta.ts +18 -0
- package/src/testing/index.ts +6 -0
- package/src/testing/test-functions.ts +11 -0
- package/src/testing/test-services.ts +131 -0
- package/src/tools/function.ts +47 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/openapi.test.ts +224 -0
- package/src/tools/openapi.ts +331 -0
- package/src/translations.ts +49 -0
- package/src/types/chat.ts +11 -0
- package/src/types/index.ts +8 -0
- package/src/types/service.ts +102 -0
- package/src/types/template.ts +34 -0
- package/src/types/types.ts +41 -0
- package/src/typings.d.ts +9 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Prec, type Extension } from '@codemirror/state';
|
|
6
|
+
import {
|
|
7
|
+
EditorView,
|
|
8
|
+
Decoration,
|
|
9
|
+
ViewPlugin,
|
|
10
|
+
keymap,
|
|
11
|
+
type DecorationSet,
|
|
12
|
+
type ViewUpdate,
|
|
13
|
+
WidgetType,
|
|
14
|
+
} from '@codemirror/view';
|
|
15
|
+
|
|
16
|
+
export type AutocompleteOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* Callback triggered when Enter is pressed.
|
|
19
|
+
* @param text The current text in the editor
|
|
20
|
+
* @returns true if the editor should reset the document.
|
|
21
|
+
*/
|
|
22
|
+
onSubmit?: (text: string) => boolean | void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Function that returns a list of suggestions based on the current text.
|
|
26
|
+
* @param text The current text before the cursor
|
|
27
|
+
* @returns Array of suggestion strings
|
|
28
|
+
*/
|
|
29
|
+
onSuggest?: (text: string) => string[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates an autocomplete extension that shows inline suggestions.
|
|
34
|
+
* Pressing Tab will complete the suggestion.
|
|
35
|
+
*/
|
|
36
|
+
export const createAutocompleteExtension = ({ onSubmit, onSuggest }: AutocompleteOptions): Extension => {
|
|
37
|
+
const suggestionPlugin = ViewPlugin.fromClass(
|
|
38
|
+
class {
|
|
39
|
+
_decorations: DecorationSet;
|
|
40
|
+
_currentSuggestion: string | null = null;
|
|
41
|
+
|
|
42
|
+
constructor(view: EditorView) {
|
|
43
|
+
this._decorations = this.computeDecorations(view);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
update(update: ViewUpdate) {
|
|
47
|
+
if (update.docChanged || update.selectionSet) {
|
|
48
|
+
this._decorations = this.computeDecorations(update.view);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private computeDecorations(view: EditorView): DecorationSet {
|
|
53
|
+
const text = view.state.doc.toString();
|
|
54
|
+
const suggestions = onSuggest?.(text) ?? [];
|
|
55
|
+
if (!suggestions.length) {
|
|
56
|
+
this._currentSuggestion = null;
|
|
57
|
+
return Decoration.none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Get the first suggestion.
|
|
61
|
+
this._currentSuggestion = suggestions[0];
|
|
62
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
63
|
+
if (!suffix) {
|
|
64
|
+
return Decoration.none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Always show ghost text at the end of the document.
|
|
68
|
+
return Decoration.set([
|
|
69
|
+
Decoration.widget({
|
|
70
|
+
widget: new InlineSuggestionWidget(suffix),
|
|
71
|
+
side: 1,
|
|
72
|
+
}).range(view.state.doc.length),
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
completeSuggestion(view: EditorView): boolean {
|
|
77
|
+
if (!this._currentSuggestion) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const text = view.state.doc.toString();
|
|
82
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
83
|
+
if (!suffix) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
view.dispatch({
|
|
88
|
+
changes: {
|
|
89
|
+
from: view.state.doc.length,
|
|
90
|
+
insert: suffix,
|
|
91
|
+
},
|
|
92
|
+
selection: {
|
|
93
|
+
anchor: view.state.doc.length + suffix.length,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
decorations: (v) => v._decorations,
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return [
|
|
106
|
+
suggestionPlugin,
|
|
107
|
+
EditorView.theme({
|
|
108
|
+
'.cm-inline-suggestion': {
|
|
109
|
+
opacity: 0.4,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
|
|
113
|
+
// Accept the current suggestion.
|
|
114
|
+
Prec.highest(
|
|
115
|
+
keymap.of([
|
|
116
|
+
{
|
|
117
|
+
key: 'Tab',
|
|
118
|
+
preventDefault: true,
|
|
119
|
+
run: (view) => {
|
|
120
|
+
const plugin = view.plugin(suggestionPlugin);
|
|
121
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: 'ArrowRight',
|
|
126
|
+
preventDefault: true,
|
|
127
|
+
run: (view) => {
|
|
128
|
+
// Only complete if cursor is at the end
|
|
129
|
+
if (view.state.selection.main.head !== view.state.doc.length) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const plugin = view.plugin(suggestionPlugin);
|
|
134
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
key: 'Enter',
|
|
139
|
+
preventDefault: true,
|
|
140
|
+
run: (view) => {
|
|
141
|
+
const text = view.state.doc.toString().trim();
|
|
142
|
+
if (text.length > 0 && onSubmit) {
|
|
143
|
+
const reset = onSubmit(text);
|
|
144
|
+
|
|
145
|
+
// Clear the document after calling onEnter.
|
|
146
|
+
if (reset) {
|
|
147
|
+
view.dispatch({
|
|
148
|
+
changes: {
|
|
149
|
+
from: 0,
|
|
150
|
+
to: view.state.doc.length,
|
|
151
|
+
insert: '',
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return true;
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: 'Shift-Enter',
|
|
162
|
+
preventDefault: true,
|
|
163
|
+
run: (view) => {
|
|
164
|
+
view.dispatch({
|
|
165
|
+
changes: {
|
|
166
|
+
from: view.state.selection.main.head,
|
|
167
|
+
insert: '\n',
|
|
168
|
+
},
|
|
169
|
+
selection: {
|
|
170
|
+
anchor: view.state.selection.main.head + 1,
|
|
171
|
+
head: view.state.selection.main.head + 1,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
return true;
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
key: 'Escape',
|
|
179
|
+
preventDefault: true,
|
|
180
|
+
run: (view) => {
|
|
181
|
+
// Clear the entire document.
|
|
182
|
+
view.dispatch({
|
|
183
|
+
changes: {
|
|
184
|
+
from: 0,
|
|
185
|
+
to: view.state.doc.length,
|
|
186
|
+
insert: '',
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return true;
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
]),
|
|
193
|
+
),
|
|
194
|
+
];
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
class InlineSuggestionWidget extends WidgetType {
|
|
198
|
+
constructor(private suffix: string) {
|
|
199
|
+
super();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override toDOM() {
|
|
203
|
+
const span = document.createElement('span');
|
|
204
|
+
span.textContent = this.suffix;
|
|
205
|
+
span.className = 'cm-inline-suggestion';
|
|
206
|
+
return span;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
override eq(other: InlineSuggestionWidget) {
|
|
210
|
+
return other.suffix === this.suffix;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
11
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
13
|
+
|
|
14
|
+
import { ServiceRegistry } from './ServiceRegistry';
|
|
15
|
+
import { ServiceType } from '../../types';
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof ServiceRegistry> = {
|
|
18
|
+
title: 'plugins/plugin-automation/ServiceRegistry',
|
|
19
|
+
component: ServiceRegistry,
|
|
20
|
+
render: ({ space: _ignore, ...args }) => {
|
|
21
|
+
const space = useSpace();
|
|
22
|
+
if (!space) {
|
|
23
|
+
return <div />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className='h-full w-[300px] overflow-hidden'>
|
|
28
|
+
<ServiceRegistry space={space} {...args} />
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
decorators: [
|
|
33
|
+
withClientProvider({
|
|
34
|
+
createIdentity: true,
|
|
35
|
+
createSpace: true,
|
|
36
|
+
types: [ServiceType],
|
|
37
|
+
}),
|
|
38
|
+
withLayout({ fullscreen: true, tooltips: true, classNames: 'flex justify-center' }),
|
|
39
|
+
withTheme,
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default meta;
|
|
44
|
+
|
|
45
|
+
type Story = StoryObj<typeof ServiceRegistry>;
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {
|
|
48
|
+
args: {},
|
|
49
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Filter, type Space } from '@dxos/client/echo';
|
|
8
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
9
|
+
import { Icon, Input, List, ListItem } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { useServices } from '../../hooks';
|
|
12
|
+
import { categoryIcons, ServiceType } from '../../types';
|
|
13
|
+
|
|
14
|
+
// TODO(burdon): Option to show all/enabled/filter.
|
|
15
|
+
export const ServiceRegistry = ({ space }: { space: Space }) => {
|
|
16
|
+
const matchingServices = useServices(space);
|
|
17
|
+
const enabledServices = useQuery(space, Filter.schema(ServiceType));
|
|
18
|
+
|
|
19
|
+
// Join matching services with enabled services.
|
|
20
|
+
const services = useMemo(() => {
|
|
21
|
+
return matchingServices.map((service) => enabledServices.find((s) => s.serviceId === service.serviceId) ?? service);
|
|
22
|
+
}, [matchingServices, enabledServices]);
|
|
23
|
+
|
|
24
|
+
// TODO(burdon): Reaplce with SpacePlugin intent.
|
|
25
|
+
const handleSetEnabled = (service: ServiceType, enabled: boolean) => {
|
|
26
|
+
if (enabled) {
|
|
27
|
+
space.db.add(service);
|
|
28
|
+
} else {
|
|
29
|
+
// TODO(burdon): Remove or disable?
|
|
30
|
+
space.db.remove(service);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<List classNames='h-full grid auto-rows-[5rem] gap-2 p-2 pis-2 pie-2 overflow-y-auto scrollbar-thin'>
|
|
36
|
+
{services.map((service) => (
|
|
37
|
+
<ServiceItem
|
|
38
|
+
key={service.serviceId}
|
|
39
|
+
service={service}
|
|
40
|
+
enabled={service.enabled}
|
|
41
|
+
setEnabled={(enabled) => handleSetEnabled(service, enabled)}
|
|
42
|
+
/>
|
|
43
|
+
))}
|
|
44
|
+
</List>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const ServiceItem = ({
|
|
49
|
+
service,
|
|
50
|
+
enabled,
|
|
51
|
+
setEnabled,
|
|
52
|
+
}: {
|
|
53
|
+
service: ServiceType;
|
|
54
|
+
enabled?: boolean;
|
|
55
|
+
setEnabled?: (enabled: boolean) => void;
|
|
56
|
+
}) => {
|
|
57
|
+
return (
|
|
58
|
+
<ListItem.Root classNames='flex flex-col gap-1 p-1 overflow-hidden rounded-md border border-separator'>
|
|
59
|
+
<div className='grid grid-cols-[40px_1fr_40px]'>
|
|
60
|
+
<div className='flex gow justify-center items-center'>
|
|
61
|
+
<Icon icon={categoryIcons[service.category ?? 'default'] ?? 'ph--placeholder--regular'} size={6} />
|
|
62
|
+
</div>
|
|
63
|
+
<div className='grow items-center truncate mie-2'>{service.name}</div>
|
|
64
|
+
<div className='flex gow justify-center items-center'>
|
|
65
|
+
<Input.Root>
|
|
66
|
+
<Input.Switch checked={enabled} onClick={() => setEnabled?.(!enabled)} />
|
|
67
|
+
</Input.Root>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<div className='grid grid-cols-[40px_1fr]'>
|
|
71
|
+
<div />
|
|
72
|
+
<div className='text-sm text-subdued line-clamp-2 mie-1'>{service.description}</div>
|
|
73
|
+
</div>
|
|
74
|
+
</ListItem.Root>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
8
|
+
|
|
9
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
10
|
+
import { type TemplateType } from '../types';
|
|
11
|
+
|
|
12
|
+
// TODO(burdon): Attention.
|
|
13
|
+
export const TemplateContainer = ({ template, role }: { template: TemplateType; role: string }) => {
|
|
14
|
+
return (
|
|
15
|
+
<StackItem.Content toolbar={false} role={role} classNames='mli-auto w-full max-w-[50rem]'>
|
|
16
|
+
<TemplateEditor template={template} />
|
|
17
|
+
</StackItem.Content>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default TemplateContainer;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { createSystemPrompt } from '@dxos/artifact';
|
|
11
|
+
import { create } from '@dxos/live-object';
|
|
12
|
+
import { useClient } from '@dxos/react-client';
|
|
13
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
|
+
|
|
16
|
+
import { TemplateEditor, type TemplateEditorProps } from './TemplateEditor';
|
|
17
|
+
import translations from '../../translations';
|
|
18
|
+
import { TemplateType } from '../../types';
|
|
19
|
+
|
|
20
|
+
const TEMPLATE = [
|
|
21
|
+
'{{! System Prompt }}',
|
|
22
|
+
'',
|
|
23
|
+
'You are a machine that is an expert chess player.',
|
|
24
|
+
'The move history of the current game is: {{history}}',
|
|
25
|
+
'If asked to suggest a move explain why it is a good move.',
|
|
26
|
+
'',
|
|
27
|
+
'{{#each artifacts}}',
|
|
28
|
+
'- {{this}}',
|
|
29
|
+
'{{/each}}',
|
|
30
|
+
'',
|
|
31
|
+
'---',
|
|
32
|
+
'',
|
|
33
|
+
'{{input}}',
|
|
34
|
+
'',
|
|
35
|
+
].join('\n');
|
|
36
|
+
|
|
37
|
+
const Render = ({ text }: TemplateEditorProps & { text: string }) => {
|
|
38
|
+
const client = useClient();
|
|
39
|
+
const [template] = useState(() => {
|
|
40
|
+
const space = client.spaces.default;
|
|
41
|
+
return space.db.add(create(TemplateType, { source: text }));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div role='none' className='flex w-[40rem] border border-separator overflow-hidden'>
|
|
46
|
+
<TemplateEditor template={template} />
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const meta: Meta<typeof Render> = {
|
|
52
|
+
title: 'plugins/plugin-automation/TemplateEditor',
|
|
53
|
+
component: TemplateEditor,
|
|
54
|
+
render: Render,
|
|
55
|
+
decorators: [
|
|
56
|
+
withClientProvider({
|
|
57
|
+
createIdentity: true,
|
|
58
|
+
createSpace: true,
|
|
59
|
+
types: [TemplateType],
|
|
60
|
+
}),
|
|
61
|
+
withLayout({ fullscreen: true, classNames: 'flex justify-center' }),
|
|
62
|
+
withTheme,
|
|
63
|
+
],
|
|
64
|
+
parameters: {
|
|
65
|
+
translations,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default meta;
|
|
70
|
+
|
|
71
|
+
type Story = Meta<typeof Render>;
|
|
72
|
+
|
|
73
|
+
export const Default: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
text: TEMPLATE,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const System: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
text: createSystemPrompt(),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { HighlightStyle, LanguageSupport, syntaxHighlighting } from '@codemirror/language';
|
|
6
|
+
import { styleTags, tags } from '@lezer/highlight';
|
|
7
|
+
import { handlebarsLanguage } from '@xiechao/codemirror-lang-handlebars';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
11
|
+
import { useThemeContext, useTranslation, type ThemedClassName } from '@dxos/react-ui';
|
|
12
|
+
import {
|
|
13
|
+
createBasicExtensions,
|
|
14
|
+
createDataExtensions,
|
|
15
|
+
createThemeExtensions,
|
|
16
|
+
useTextEditor,
|
|
17
|
+
} from '@dxos/react-ui-editor';
|
|
18
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
19
|
+
|
|
20
|
+
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
21
|
+
import { type TemplateType } from '../../types';
|
|
22
|
+
|
|
23
|
+
handlebarsLanguage.configure({
|
|
24
|
+
props: [
|
|
25
|
+
styleTags({
|
|
26
|
+
'---': tags.lineComment,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type TemplateEditorProps = ThemedClassName<{
|
|
32
|
+
template: TemplateType;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
export const TemplateEditor = ({ classNames, template }: TemplateEditorProps) => {
|
|
36
|
+
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
37
|
+
const { themeMode } = useThemeContext();
|
|
38
|
+
const { parentRef } = useTextEditor(
|
|
39
|
+
() => ({
|
|
40
|
+
initialValue: template.source,
|
|
41
|
+
extensions: [
|
|
42
|
+
createDataExtensions({
|
|
43
|
+
id: template.id,
|
|
44
|
+
text: template.source !== undefined ? createDocAccessor(template, ['template']) : undefined,
|
|
45
|
+
}),
|
|
46
|
+
createBasicExtensions({
|
|
47
|
+
bracketMatching: false,
|
|
48
|
+
lineWrapping: true,
|
|
49
|
+
placeholder: t('template placeholder'),
|
|
50
|
+
}),
|
|
51
|
+
createThemeExtensions({
|
|
52
|
+
themeMode,
|
|
53
|
+
slots: {
|
|
54
|
+
content: { className: '!p-3' },
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
// https://github.com/xiechao/lang-handlebars
|
|
59
|
+
new LanguageSupport(handlebarsLanguage, syntaxHighlighting(handlebarsHighlightStyle)),
|
|
60
|
+
],
|
|
61
|
+
}),
|
|
62
|
+
[themeMode, prompt],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return <div ref={parentRef} className={mx(classNames)} />;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* https://github.com/xiechao/lang-handlebars/blob/direct/src/highlight.js
|
|
70
|
+
*/
|
|
71
|
+
export const handlebarsHighlightStyle = HighlightStyle.define([
|
|
72
|
+
{ tag: tags.tagName, class: 'text-redText' }, // Braces.
|
|
73
|
+
{ tag: tags.variableName, class: 'text-blueText' },
|
|
74
|
+
{ tag: tags.keyword, class: 'text-greenText' },
|
|
75
|
+
{ tag: tags.comment, class: 'text-subdued' },
|
|
76
|
+
]);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { create } from '@dxos/live-object';
|
|
11
|
+
import { useClient } from '@dxos/react-client';
|
|
12
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
|
+
|
|
15
|
+
import { TemplateForm } from './TemplateForm';
|
|
16
|
+
import translations from '../../translations';
|
|
17
|
+
import { TemplateType } from '../../types';
|
|
18
|
+
|
|
19
|
+
const TEMPLATE = [
|
|
20
|
+
'You are a machine that is an expert chess player.',
|
|
21
|
+
'The move history of the current game is: {{history}}',
|
|
22
|
+
'If asked to suggest a move explain why it is a good move.',
|
|
23
|
+
'',
|
|
24
|
+
'---',
|
|
25
|
+
'',
|
|
26
|
+
'{{input}}',
|
|
27
|
+
].join('\n');
|
|
28
|
+
|
|
29
|
+
const Render = () => {
|
|
30
|
+
const client = useClient();
|
|
31
|
+
const [template] = useState(() => {
|
|
32
|
+
const space = client.spaces.default;
|
|
33
|
+
return space.db.add(create(TemplateType, { source: TEMPLATE }));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div role='none' className='flex w-[40rem] border border-separator overflow-hidden'>
|
|
38
|
+
<TemplateForm template={template} />
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const meta: Meta<typeof TemplateForm> = {
|
|
44
|
+
title: 'plugins/plugin-automation/TemplateForm',
|
|
45
|
+
component: TemplateForm,
|
|
46
|
+
render: Render,
|
|
47
|
+
decorators: [
|
|
48
|
+
withClientProvider({
|
|
49
|
+
createIdentity: true,
|
|
50
|
+
createSpace: true,
|
|
51
|
+
types: [TemplateType],
|
|
52
|
+
}),
|
|
53
|
+
withLayout({ fullscreen: true, classNames: 'flex justify-center' }),
|
|
54
|
+
withTheme,
|
|
55
|
+
],
|
|
56
|
+
parameters: {
|
|
57
|
+
translations,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
|
|
63
|
+
type Story = Meta<typeof TemplateForm>;
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {};
|