@dxos/plugin-automation 0.7.5-main.ff8607b → 0.7.5-staging.2ff1350
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/AutomationPanel-NCKK3CFN.mjs +8 -0
- package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-AZPLZJ5H.mjs +12 -0
- package/dist/lib/browser/ChatContainer-AZPLZJ5H.mjs.map +7 -0
- package/dist/lib/browser/ai-client-T2PBJISL.mjs +22 -0
- package/dist/lib/browser/ai-client-T2PBJISL.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-F22H4YBQ.mjs +111 -0
- package/dist/lib/browser/app-graph-builder-F22H4YBQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-67KDIIM6.mjs +15 -0
- package/dist/lib/browser/chunk-67KDIIM6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DQ7ZSYJJ.mjs → chunk-HZSTXZWK.mjs} +3 -1
- package/dist/lib/browser/chunk-HZSTXZWK.mjs.map +7 -0
- package/dist/lib/browser/chunk-L2YLAKCS.mjs +151 -0
- package/dist/lib/browser/chunk-L2YLAKCS.mjs.map +7 -0
- package/dist/lib/{node-esm/AutomationPanel-MW42U6I4.mjs → browser/chunk-LJ7F4KDM.mjs} +26 -15
- package/dist/lib/browser/chunk-LJ7F4KDM.mjs.map +7 -0
- package/dist/lib/browser/chunk-M4MWUOUC.mjs +382 -0
- package/dist/lib/browser/chunk-M4MWUOUC.mjs.map +7 -0
- package/dist/lib/browser/chunk-U435IUIA.mjs +1775 -0
- package/dist/lib/browser/chunk-U435IUIA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +127 -42
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-MONKAKTY.mjs +30 -0
- package/dist/lib/browser/intent-resolver-MONKAKTY.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-7QWCWE4K.mjs +58 -0
- package/dist/lib/browser/react-surface-7QWCWE4K.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -3
- package/dist/lib/node/AutomationPanel-6COLKRIB.cjs +26 -0
- package/dist/lib/node/AutomationPanel-6COLKRIB.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-SBEUFMQ3.cjs +33 -0
- package/dist/lib/node/ChatContainer-SBEUFMQ3.cjs.map +7 -0
- package/dist/lib/node/ai-client-L5GUSAER.cjs +38 -0
- package/dist/lib/node/ai-client-L5GUSAER.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-OCSH5R6U.cjs +123 -0
- package/dist/lib/node/app-graph-builder-OCSH5R6U.cjs.map +7 -0
- package/dist/lib/node/{chunk-TQEDPRY5.cjs → chunk-BAQRBGOJ.cjs} +7 -4
- package/dist/lib/node/chunk-BAQRBGOJ.cjs.map +7 -0
- package/dist/lib/node/chunk-BZFAEBME.cjs +1747 -0
- package/dist/lib/node/chunk-BZFAEBME.cjs.map +7 -0
- package/dist/lib/node/chunk-K3F5JNZ6.cjs +394 -0
- package/dist/lib/node/chunk-K3F5JNZ6.cjs.map +7 -0
- package/dist/lib/node/chunk-NUOYHYAF.cjs +174 -0
- package/dist/lib/node/chunk-NUOYHYAF.cjs.map +7 -0
- package/dist/lib/node/{AutomationPanel-H5WE4FIU.cjs → chunk-V4L7LTWM.cjs} +34 -18
- package/dist/lib/node/chunk-V4L7LTWM.cjs.map +7 -0
- package/dist/lib/node/chunk-VNBYGJ4K.cjs +34 -0
- package/dist/lib/node/chunk-VNBYGJ4K.cjs.map +7 -0
- package/dist/lib/node/index.cjs +157 -86
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-KQGTYVF2.cjs +45 -0
- package/dist/lib/node/intent-resolver-KQGTYVF2.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-S6U5ISJ6.cjs → react-surface-IXKIJFRP.cjs} +31 -12
- package/dist/lib/node/react-surface-IXKIJFRP.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +17 -6
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs +9 -0
- package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-JCDLYMDZ.mjs +13 -0
- package/dist/lib/node-esm/ChatContainer-JCDLYMDZ.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs +23 -0
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-XSM7DETF.mjs +112 -0
- package/dist/lib/node-esm/app-graph-builder-XSM7DETF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-53FFD4VO.mjs +1776 -0
- package/dist/lib/node-esm/chunk-53FFD4VO.mjs.map +7 -0
- package/dist/lib/{browser/AutomationPanel-KT3YFV56.mjs → node-esm/chunk-AWAU4BHR.mjs} +27 -14
- package/dist/lib/node-esm/chunk-AWAU4BHR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JFHI22MF.mjs → chunk-IG4GSWZN.mjs} +3 -1
- package/dist/lib/node-esm/chunk-IG4GSWZN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K5NNSGIV.mjs +152 -0
- package/dist/lib/node-esm/chunk-K5NNSGIV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RAT3GSJP.mjs +383 -0
- package/dist/lib/node-esm/chunk-RAT3GSJP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs +16 -0
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +127 -42
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-XSZRLU6V.mjs +31 -0
- package/dist/lib/node-esm/intent-resolver-XSZRLU6V.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-FZAAAXGR.mjs +59 -0
- package/dist/lib/node-esm/react-surface-FZAAAXGR.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +14 -3
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- 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 +23 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- 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 +3 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- 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.map +1 -1
- 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/AssistantDialog.d.ts +6 -0
- package/dist/types/src/components/AssistantDialog/AssistantDialog.d.ts.map +1 -0
- package/dist/types/src/components/AssistantDialog/index.d.ts +2 -0
- package/dist/types/src/components/AssistantDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +6 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/index.d.ts +4 -0
- package/dist/types/src/components/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +13 -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/PromptEditor/PromptEditor.d.ts +1 -2
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +1 -1
- 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/Thread/Thread.d.ts +15 -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 +8 -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 +13 -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/TriggerEditor/TriggerEditor.d.ts +1 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +13 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +75 -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 +7 -0
- package/dist/types/src/hooks/useChatProcessor.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/meta.d.ts +1 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +3 -1
- 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 +95 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/registry.d.ts +10 -0
- package/dist/types/src/types/registry.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +161 -3
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +19 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/package.json +59 -40
- package/src/AutomationPlugin.tsx +51 -14
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +83 -110
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +4 -0
- package/src/capabilities/intent-resolver.ts +26 -0
- package/src/capabilities/react-surface.tsx +21 -6
- 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/AssistantDialog.tsx +23 -0
- package/src/components/AssistantDialog/index.ts +5 -0
- package/src/components/ChatContainer/ChatContainer.tsx +19 -0
- package/src/components/ChatContainer/index.ts +9 -0
- package/src/components/Prompt/Prompt.stories.tsx +79 -0
- package/src/components/Prompt/Prompt.tsx +79 -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/PromptEditor/PromptEditor.stories.tsx +3 -3
- package/src/components/PromptEditor/PromptEditor.tsx +3 -3
- 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/Thread/Thread.stories.tsx +210 -0
- package/src/components/Thread/Thread.tsx +106 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +245 -0
- package/src/components/Thread/ThreadContainer.tsx +67 -0
- package/src/components/Thread/ThreadMessage.tsx +187 -0
- package/src/components/Thread/ToolInvocations.tsx +86 -0
- package/src/components/Thread/index.ts +6 -0
- package/src/components/Thread/reducer.ts +52 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +66 -0
- package/src/components/Toolbox/Toolbox.tsx +89 -0
- package/src/components/Toolbox/index.ts +5 -0
- package/src/components/TriggerEditor/TriggerEditor.tsx +18 -11
- package/src/components/index.ts +10 -1
- package/src/hooks/index.ts +6 -0
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +218 -0
- package/src/hooks/useChatProcessor.tsx +75 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/hooks/useTextInputEvents.ts +49 -0
- package/src/meta.ts +2 -0
- package/src/testing/index.ts +2 -1
- package/src/testing/{testing.ts → test-functions.ts} +9 -2
- 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 +17 -2
- package/src/types/index.ts +2 -0
- package/src/types/registry.ts +26 -0
- package/src/types/schema.ts +95 -1
- package/src/types/types.ts +22 -0
- package/src/typings.d.ts +9 -0
- package/dist/lib/browser/AssistantPanel-NTOUHOWA.mjs +0 -339
- package/dist/lib/browser/AssistantPanel-NTOUHOWA.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-KT3YFV56.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-6FSMLMT4.mjs +0 -131
- package/dist/lib/browser/app-graph-builder-6FSMLMT4.mjs.map +0 -7
- package/dist/lib/browser/chunk-4ODBJDXM.mjs +0 -10
- package/dist/lib/browser/chunk-4ODBJDXM.mjs.map +0 -7
- package/dist/lib/browser/chunk-DL6LB2NI.mjs +0 -43
- package/dist/lib/browser/chunk-DL6LB2NI.mjs.map +0 -7
- package/dist/lib/browser/chunk-DQ7ZSYJJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-5YTE5MRE.mjs +0 -34
- package/dist/lib/browser/react-surface-5YTE5MRE.mjs.map +0 -7
- package/dist/lib/node/AssistantPanel-U7GDWPRC.cjs +0 -359
- package/dist/lib/node/AssistantPanel-U7GDWPRC.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-H5WE4FIU.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-65TBXO3I.cjs +0 -147
- package/dist/lib/node/app-graph-builder-65TBXO3I.cjs.map +0 -7
- package/dist/lib/node/chunk-JNDMZQH7.cjs +0 -68
- package/dist/lib/node/chunk-JNDMZQH7.cjs.map +0 -7
- package/dist/lib/node/chunk-JUSXT4U5.cjs +0 -43
- package/dist/lib/node/chunk-JUSXT4U5.cjs.map +0 -7
- package/dist/lib/node/chunk-TQEDPRY5.cjs.map +0 -7
- package/dist/lib/node/react-surface-S6U5ISJ6.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-M67P24GS.mjs +0 -340
- package/dist/lib/node-esm/AssistantPanel-M67P24GS.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-MW42U6I4.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-4SD4F3KN.mjs +0 -132
- package/dist/lib/node-esm/app-graph-builder-4SD4F3KN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GIAYUM5I.mjs +0 -45
- package/dist/lib/node-esm/chunk-GIAYUM5I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JFHI22MF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XVIEXSEZ.mjs +0 -12
- package/dist/lib/node-esm/chunk-XVIEXSEZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RWTR3TKT.mjs +0 -35
- package/dist/lib/node-esm/react-surface-RWTR3TKT.mjs.map +0 -7
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -227
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
|
@@ -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
|
+
}
|
|
@@ -28,7 +28,7 @@ const template = [
|
|
|
28
28
|
'{input}',
|
|
29
29
|
].join('\n');
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const Render = () => {
|
|
32
32
|
const client = useClient();
|
|
33
33
|
const [chain] = useState(() => {
|
|
34
34
|
const space = client.spaces.default;
|
|
@@ -49,8 +49,8 @@ const DefaultStory = () => {
|
|
|
49
49
|
export const Default = {};
|
|
50
50
|
|
|
51
51
|
const meta: Meta = {
|
|
52
|
-
title: 'plugins/plugin-automation/
|
|
53
|
-
render:
|
|
52
|
+
title: 'plugins/plugin-automation/PromptEditor',
|
|
53
|
+
render: Render,
|
|
54
54
|
decorators: [
|
|
55
55
|
withClientProvider({ createIdentity: true, createSpace: true, types: [ChainType, ChainPromptType] }),
|
|
56
56
|
withLayout({ fullscreen: true, classNames: 'flex justify-center m-2' }),
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useTextEditor,
|
|
15
15
|
} from '@dxos/react-ui-editor';
|
|
16
16
|
import { attentionSurface, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
17
|
-
import {
|
|
17
|
+
import { isNonNullable } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
import { nameRegex, promptExtension } from './prompt-extension';
|
|
20
20
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
@@ -69,7 +69,7 @@ const usePromptInputs = (prompt: ChainPromptType) => {
|
|
|
69
69
|
|
|
70
70
|
// Create map of unclaimed inputs.
|
|
71
71
|
const unclaimed = new Map<string, ChainInput>(
|
|
72
|
-
prompt.inputs?.filter(
|
|
72
|
+
prompt.inputs?.filter(isNonNullable).map((input) => [input.name, input]),
|
|
73
73
|
);
|
|
74
74
|
const missing: string[] = [];
|
|
75
75
|
Array.from(variables.values()).forEach((name) => {
|
|
@@ -161,7 +161,7 @@ export const PromptEditor = ({ prompt, commandEditable = true }: PromptEditorPro
|
|
|
161
161
|
{/* TODO(zan): Improve layout with grid */}
|
|
162
162
|
<table className='w-full table-fixed border-collapse my-2'>
|
|
163
163
|
<tbody>
|
|
164
|
-
{prompt.inputs?.filter(
|
|
164
|
+
{prompt.inputs?.filter(isNonNullable).map((input) => (
|
|
165
165
|
<tr key={input.name}>
|
|
166
166
|
<td className='w-[160px] p-1 font-mono text-sm whitespace-nowrap truncate'>
|
|
167
167
|
<code className='px-2'>{input.name}</code>
|
|
@@ -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,210 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { type Message } from '@dxos/artifact';
|
|
13
|
+
import { ObjectId } from '@dxos/echo-schema';
|
|
14
|
+
import { faker } from '@dxos/random';
|
|
15
|
+
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
16
|
+
|
|
17
|
+
import { Thread, type ThreadProps } from './Thread';
|
|
18
|
+
import translations from '../../translations';
|
|
19
|
+
|
|
20
|
+
faker.seed(1);
|
|
21
|
+
|
|
22
|
+
const Render = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
23
|
+
const [processing, setProcessing] = useState(false);
|
|
24
|
+
const [messages, setMessages] = useState<Message[]>(_messages ?? []);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setMessages(_messages ?? []);
|
|
27
|
+
}, [_messages]);
|
|
28
|
+
|
|
29
|
+
const handleSubmit = useCallback(
|
|
30
|
+
(text: string) => {
|
|
31
|
+
const request: Message = { id: ObjectId.random(), role: 'user', content: [{ type: 'text', text }] };
|
|
32
|
+
const response: Message = {
|
|
33
|
+
id: ObjectId.random(),
|
|
34
|
+
role: 'assistant',
|
|
35
|
+
content: [{ type: 'text', disposition: 'cot', pending: true, text: faker.lorem.paragraphs(1) }],
|
|
36
|
+
};
|
|
37
|
+
setMessages([...messages, request, response]);
|
|
38
|
+
setProcessing(true);
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
response.content[0].pending = false;
|
|
41
|
+
setMessages([
|
|
42
|
+
...messages,
|
|
43
|
+
request,
|
|
44
|
+
response,
|
|
45
|
+
{
|
|
46
|
+
id: ObjectId.random(),
|
|
47
|
+
role: 'assistant',
|
|
48
|
+
content: [{ type: 'text', text: faker.lorem.paragraphs(1) }],
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
setProcessing(false);
|
|
52
|
+
}, 3_000);
|
|
53
|
+
},
|
|
54
|
+
[messages],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className='flex grow justify-center overflow-center bg-baseSurface'>
|
|
59
|
+
<div className='flex w-[30rem] bg-white dark:bg-black'>
|
|
60
|
+
<Thread
|
|
61
|
+
{...props}
|
|
62
|
+
messages={messages}
|
|
63
|
+
processing={processing}
|
|
64
|
+
onSubmit={handleSubmit}
|
|
65
|
+
onCancel={() => setProcessing(false)}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const meta: Meta<ThreadProps> = {
|
|
73
|
+
title: 'plugins/plugin-automation/Thread',
|
|
74
|
+
render: Render,
|
|
75
|
+
component: Thread,
|
|
76
|
+
decorators: [
|
|
77
|
+
withSignals,
|
|
78
|
+
withTheme,
|
|
79
|
+
withLayout({ fullscreen: true, tooltips: true }),
|
|
80
|
+
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
81
|
+
],
|
|
82
|
+
parameters: {
|
|
83
|
+
translations,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default meta;
|
|
88
|
+
|
|
89
|
+
type Story = StoryObj<ThreadProps>;
|
|
90
|
+
|
|
91
|
+
const TEST_MESSAGES: Message[] = [
|
|
92
|
+
{
|
|
93
|
+
id: ObjectId.random(),
|
|
94
|
+
role: 'user',
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: faker.lorem.sentence(5),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: ObjectId.random(),
|
|
104
|
+
role: 'assistant',
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: 'text',
|
|
108
|
+
disposition: 'cot',
|
|
109
|
+
text: Array.from({ length: faker.number.int({ min: 3, max: 5 }) })
|
|
110
|
+
.map((_, idx) => `${idx + 1}. ${faker.lorem.paragraph()}`)
|
|
111
|
+
.join('\n'),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: 'text',
|
|
115
|
+
text: Array.from({ length: faker.number.int({ min: 2, max: 5 }) })
|
|
116
|
+
.map(() => faker.lorem.paragraphs())
|
|
117
|
+
.join('\n\n'),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'tool_use',
|
|
121
|
+
id: '1234',
|
|
122
|
+
name: 'search',
|
|
123
|
+
input: {},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: ObjectId.random(),
|
|
129
|
+
role: 'user',
|
|
130
|
+
content: [
|
|
131
|
+
{
|
|
132
|
+
type: 'tool_result',
|
|
133
|
+
toolUseId: '1234',
|
|
134
|
+
content: 'This is a tool result.',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: ObjectId.random(),
|
|
140
|
+
role: 'assistant',
|
|
141
|
+
content: [
|
|
142
|
+
{
|
|
143
|
+
type: 'tool_use',
|
|
144
|
+
id: '4567',
|
|
145
|
+
name: 'create',
|
|
146
|
+
input: {},
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: ObjectId.random(),
|
|
152
|
+
role: 'user',
|
|
153
|
+
content: [
|
|
154
|
+
{
|
|
155
|
+
type: 'tool_result',
|
|
156
|
+
toolUseId: '4567',
|
|
157
|
+
content: 'This is a tool result.',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: ObjectId.random(),
|
|
163
|
+
role: 'assistant',
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
type: 'text',
|
|
167
|
+
text: faker.lorem.paragraphs(1),
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
export const Default: Story = {
|
|
174
|
+
args: {
|
|
175
|
+
// debug: true,
|
|
176
|
+
messages: TEST_MESSAGES,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const Input: Story = {
|
|
181
|
+
args: {
|
|
182
|
+
processing: true,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const Collapse: Story = {
|
|
187
|
+
args: {
|
|
188
|
+
collapse: true,
|
|
189
|
+
messages: TEST_MESSAGES,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const Incremental: Story = {
|
|
194
|
+
render: () => {
|
|
195
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
let i = 0;
|
|
198
|
+
const interval = setInterval(() => {
|
|
199
|
+
setMessages((messages) => [...messages, TEST_MESSAGES[i++]]);
|
|
200
|
+
if (i >= TEST_MESSAGES.length) {
|
|
201
|
+
clearInterval(interval);
|
|
202
|
+
}
|
|
203
|
+
}, 2_000);
|
|
204
|
+
|
|
205
|
+
return () => clearInterval(interval);
|
|
206
|
+
}, []);
|
|
207
|
+
|
|
208
|
+
return <Render messages={messages} collapse />;
|
|
209
|
+
},
|
|
210
|
+
};
|