@dxos/plugin-assistant 0.7.5-main.5ae2ba8
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,184 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Schema as S } from '@effect/schema';
|
|
6
|
+
import React, { Fragment, useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { attentionSurface, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
10
|
+
import { isNonNullable } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
13
|
+
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
14
|
+
import { type TemplateInput, TemplateInputType, type TemplateType } from '../../types';
|
|
15
|
+
|
|
16
|
+
export type TemplateFormProps = {
|
|
17
|
+
template: TemplateType;
|
|
18
|
+
schema?: S.Schema<any, any, any>;
|
|
19
|
+
commandEditable?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const TemplateForm = ({ template, commandEditable = true }: TemplateFormProps) => {
|
|
23
|
+
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
24
|
+
|
|
25
|
+
usePromptInputs(template);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={mx('flex flex-col w-full overflow-hidden gap-4', groupBorder)}>
|
|
29
|
+
{commandEditable && (
|
|
30
|
+
<div className='flex items-center pl-4'>
|
|
31
|
+
<span className='text-neutral-500'>/</span>
|
|
32
|
+
<Input.Root>
|
|
33
|
+
<Input.TextInput
|
|
34
|
+
placeholder={t('command placeholder')}
|
|
35
|
+
classNames={mx('is-full bg-transparent m-2')}
|
|
36
|
+
value={template.command ?? ''}
|
|
37
|
+
onChange={(event) => {
|
|
38
|
+
template.command = event.target.value.replace(/\w/g, '');
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
</Input.Root>
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
<TemplateEditor template={template} classNames={[attentionSurface, 'min-h-[120px]']} />
|
|
46
|
+
|
|
47
|
+
{(template.inputs?.length ?? 0) > 0 && (
|
|
48
|
+
<div className='grid grid-cols-[10rem_10rem_1fr] gap-1 items-center'>
|
|
49
|
+
{template.inputs?.filter(isNonNullable).map((input) => (
|
|
50
|
+
<Fragment key={input.name}>
|
|
51
|
+
<div className='pis-3 text-blueText'>{input.name}</div>
|
|
52
|
+
|
|
53
|
+
<Input.Root>
|
|
54
|
+
<Select.Root
|
|
55
|
+
value={String(input.type)}
|
|
56
|
+
onValueChange={(type) => {
|
|
57
|
+
input.type = getInputType(type) ?? TemplateInputType.VALUE;
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<Select.TriggerButton placeholder='Type' classNames='is-full' />
|
|
61
|
+
<Select.Portal>
|
|
62
|
+
<Select.Content>
|
|
63
|
+
<Select.Viewport>
|
|
64
|
+
{inputTypes.map(({ value, label }) => (
|
|
65
|
+
<Select.Option key={value} value={String(value)}>
|
|
66
|
+
{label}
|
|
67
|
+
</Select.Option>
|
|
68
|
+
))}
|
|
69
|
+
</Select.Viewport>
|
|
70
|
+
</Select.Content>
|
|
71
|
+
</Select.Portal>
|
|
72
|
+
</Select.Root>
|
|
73
|
+
</Input.Root>
|
|
74
|
+
|
|
75
|
+
<div>
|
|
76
|
+
{input.type !== undefined &&
|
|
77
|
+
[
|
|
78
|
+
TemplateInputType.VALUE,
|
|
79
|
+
TemplateInputType.CONTEXT,
|
|
80
|
+
TemplateInputType.RESOLVER,
|
|
81
|
+
TemplateInputType.SCHEMA,
|
|
82
|
+
].includes(input.type) && (
|
|
83
|
+
<div>
|
|
84
|
+
<Input.Root>
|
|
85
|
+
<Input.TextInput
|
|
86
|
+
placeholder={t('command placeholder')}
|
|
87
|
+
classNames={mx('is-full bg-transparent')}
|
|
88
|
+
value={input.value ?? ''}
|
|
89
|
+
onChange={(event) => {
|
|
90
|
+
input.value = event.target.value;
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</Input.Root>
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
</Fragment>
|
|
98
|
+
))}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const inputTypes = [
|
|
106
|
+
{
|
|
107
|
+
value: TemplateInputType.VALUE,
|
|
108
|
+
label: 'Value',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
value: TemplateInputType.PASS_THROUGH,
|
|
112
|
+
label: 'Pass through',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: TemplateInputType.RETRIEVER,
|
|
116
|
+
label: 'Retriever',
|
|
117
|
+
},
|
|
118
|
+
// {
|
|
119
|
+
// value: TemplateInputType.FUNCTION,
|
|
120
|
+
// label: 'Function',
|
|
121
|
+
// },
|
|
122
|
+
// {
|
|
123
|
+
// value: TemplateInputType.QUERY,
|
|
124
|
+
// label: 'Query',
|
|
125
|
+
// },
|
|
126
|
+
{
|
|
127
|
+
value: TemplateInputType.RESOLVER,
|
|
128
|
+
label: 'Resolver',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
value: TemplateInputType.CONTEXT,
|
|
132
|
+
label: 'Context',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
value: TemplateInputType.SCHEMA,
|
|
136
|
+
label: 'Schema',
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
export const nameRegex = /\{\{([\w-]+)\}\}/;
|
|
141
|
+
|
|
142
|
+
const getInputType = (type: string) => inputTypes.find(({ value }) => String(value) === type)?.value;
|
|
143
|
+
|
|
144
|
+
const usePromptInputs = (template: TemplateType) => {
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
const text = template.source ?? '';
|
|
147
|
+
if (!template.inputs) {
|
|
148
|
+
template.inputs = []; // TODO(burdon): Required?
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const regex = new RegExp(nameRegex, 'g');
|
|
152
|
+
const variables = new Set<string>([...text.matchAll(regex)].map((m) => m[1]));
|
|
153
|
+
|
|
154
|
+
// Create map of unclaimed inputs.
|
|
155
|
+
const unclaimed = new Map<string, TemplateInput>(
|
|
156
|
+
template.inputs?.filter(isNonNullable).map((input) => [input.name, input]),
|
|
157
|
+
);
|
|
158
|
+
const missing: string[] = [];
|
|
159
|
+
Array.from(variables.values()).forEach((name) => {
|
|
160
|
+
if (unclaimed.has(name)) {
|
|
161
|
+
unclaimed.delete(name);
|
|
162
|
+
} else {
|
|
163
|
+
missing.push(name);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Match or create new inputs.
|
|
168
|
+
const values = unclaimed.values();
|
|
169
|
+
missing.forEach((name) => {
|
|
170
|
+
const next = values.next().value;
|
|
171
|
+
if (next) {
|
|
172
|
+
next.name = name;
|
|
173
|
+
} else {
|
|
174
|
+
template.inputs?.push({ name });
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Remove unclaimed (deleted) inputs.
|
|
179
|
+
// TODO(burdon): If user types incorrect name value, it will be deleted. Garbage collect?
|
|
180
|
+
for (const input of values) {
|
|
181
|
+
template.inputs.splice(template.inputs.indexOf(input), 1);
|
|
182
|
+
}
|
|
183
|
+
}, [template.source]);
|
|
184
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// TODO(burdon): Factor out (shared with backend). core/chain (@dxos/chain).
|
|
6
|
+
// TODO(burdon): Agent/plan-and-execute (with tools). Create design doc/ontology of sequence/agent.
|
|
7
|
+
|
|
8
|
+
export type Step = {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Variable = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: 'value' | 'function' | 'query' | 'retriever' | 'pass-through';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type Prompt = Step & {
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
template: string;
|
|
21
|
+
variables: Variable[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type Sequence = Step & {
|
|
25
|
+
runnable: Step[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type Chain = {};
|
|
@@ -0,0 +1,212 @@
|
|
|
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 { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
17
|
+
|
|
18
|
+
import { Thread, type ThreadProps } from './Thread';
|
|
19
|
+
import translations from '../../translations';
|
|
20
|
+
|
|
21
|
+
faker.seed(1);
|
|
22
|
+
|
|
23
|
+
const Render = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
24
|
+
const [processing, setProcessing] = useState(false);
|
|
25
|
+
const [messages, setMessages] = useState<Message[]>(_messages ?? []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setMessages(_messages ?? []);
|
|
28
|
+
}, [_messages]);
|
|
29
|
+
|
|
30
|
+
const handleSubmit = useCallback(
|
|
31
|
+
(text: string) => {
|
|
32
|
+
const request: Message = { id: ObjectId.random(), role: 'user', content: [{ type: 'text', text }] };
|
|
33
|
+
const response: Message = {
|
|
34
|
+
id: ObjectId.random(),
|
|
35
|
+
role: 'assistant',
|
|
36
|
+
content: [{ type: 'text', disposition: 'cot', pending: true, text: faker.lorem.paragraphs(1) }],
|
|
37
|
+
};
|
|
38
|
+
setMessages([...messages, request, response]);
|
|
39
|
+
setProcessing(true);
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
response.content[0].pending = false;
|
|
42
|
+
setMessages([
|
|
43
|
+
...messages,
|
|
44
|
+
request,
|
|
45
|
+
response,
|
|
46
|
+
{
|
|
47
|
+
id: ObjectId.random(),
|
|
48
|
+
role: 'assistant',
|
|
49
|
+
content: [{ type: 'text', text: faker.lorem.paragraphs(1) }],
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
setProcessing(false);
|
|
53
|
+
}, 3_000);
|
|
54
|
+
},
|
|
55
|
+
[messages],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
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
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const meta: Meta<ThreadProps> = {
|
|
72
|
+
title: 'plugins/plugin-automation/Thread',
|
|
73
|
+
render: Render,
|
|
74
|
+
component: Thread,
|
|
75
|
+
decorators: [
|
|
76
|
+
withSignals,
|
|
77
|
+
withClientProvider({
|
|
78
|
+
createIdentity: true,
|
|
79
|
+
createSpace: true,
|
|
80
|
+
}),
|
|
81
|
+
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
82
|
+
withTheme,
|
|
83
|
+
withLayout({ fullscreen: true, tooltips: true, classNames: 'flex justify-center' }),
|
|
84
|
+
],
|
|
85
|
+
parameters: {
|
|
86
|
+
translations,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default meta;
|
|
91
|
+
|
|
92
|
+
type Story = StoryObj<ThreadProps>;
|
|
93
|
+
|
|
94
|
+
const TEST_MESSAGES: Message[] = [
|
|
95
|
+
{
|
|
96
|
+
id: ObjectId.random(),
|
|
97
|
+
role: 'user',
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: faker.lorem.sentence(5),
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: ObjectId.random(),
|
|
107
|
+
role: 'assistant',
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: 'text',
|
|
111
|
+
disposition: 'cot',
|
|
112
|
+
text: Array.from({ length: faker.number.int({ min: 3, max: 5 }) })
|
|
113
|
+
.map((_, idx) => `${idx + 1}. ${faker.lorem.paragraph()}`)
|
|
114
|
+
.join('\n'),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'text',
|
|
118
|
+
text: Array.from({ length: faker.number.int({ min: 2, max: 5 }) })
|
|
119
|
+
.map(() => faker.lorem.paragraphs())
|
|
120
|
+
.join('\n\n'),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'tool_use',
|
|
124
|
+
id: '1234',
|
|
125
|
+
name: 'search',
|
|
126
|
+
input: {},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: ObjectId.random(),
|
|
132
|
+
role: 'user',
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: 'tool_result',
|
|
136
|
+
toolUseId: '1234',
|
|
137
|
+
content: 'This is a tool result.',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: ObjectId.random(),
|
|
143
|
+
role: 'assistant',
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: 'tool_use',
|
|
147
|
+
id: '4567',
|
|
148
|
+
name: 'create',
|
|
149
|
+
input: {},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: ObjectId.random(),
|
|
155
|
+
role: 'user',
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: 'tool_result',
|
|
159
|
+
toolUseId: '4567',
|
|
160
|
+
content: 'This is a tool result.',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: ObjectId.random(),
|
|
166
|
+
role: 'assistant',
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
type: 'text',
|
|
170
|
+
text: faker.lorem.paragraphs(1),
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
export const Default: Story = {
|
|
177
|
+
args: {
|
|
178
|
+
messages: TEST_MESSAGES,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const Input: Story = {
|
|
183
|
+
args: {
|
|
184
|
+
processing: true,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const Collapse: Story = {
|
|
189
|
+
args: {
|
|
190
|
+
collapse: true,
|
|
191
|
+
messages: TEST_MESSAGES,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const Incremental: Story = {
|
|
196
|
+
render: () => {
|
|
197
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
let i = 0;
|
|
200
|
+
const interval = setInterval(() => {
|
|
201
|
+
setMessages((messages) => [...messages, TEST_MESSAGES[i++]]);
|
|
202
|
+
if (i >= TEST_MESSAGES.length) {
|
|
203
|
+
clearInterval(interval);
|
|
204
|
+
}
|
|
205
|
+
}, 2_000);
|
|
206
|
+
|
|
207
|
+
return () => clearInterval(interval);
|
|
208
|
+
}, []);
|
|
209
|
+
|
|
210
|
+
return <Render messages={messages} collapse />;
|
|
211
|
+
},
|
|
212
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type CSSProperties, useCallback, useMemo, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Message } from '@dxos/artifact';
|
|
8
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
9
|
+
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
|
+
import { ScrollContainer, type ScrollController } from '@dxos/react-ui-components';
|
|
12
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
13
|
+
import { keyToFallback } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { ThreadMessage, type ThreadMessageProps } from './ThreadMessage';
|
|
16
|
+
import { messageReducer } from './reducer';
|
|
17
|
+
import { PromptBar, type PromptBarProps } from '../Prompt';
|
|
18
|
+
|
|
19
|
+
export type ThreadProps = ThemedClassName<{
|
|
20
|
+
space?: Space;
|
|
21
|
+
messages?: Message[];
|
|
22
|
+
collapse?: boolean;
|
|
23
|
+
transcription?: boolean;
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
}> &
|
|
26
|
+
Pick<PromptBarProps, 'processing' | 'error' | 'onSubmit' | 'onSuggest' | 'onCancel'> &
|
|
27
|
+
Pick<ThreadMessageProps, 'debug' | 'tools' | 'onPrompt' | 'onDelete'>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Chat thread component.
|
|
31
|
+
*/
|
|
32
|
+
export const Thread = ({
|
|
33
|
+
classNames,
|
|
34
|
+
space,
|
|
35
|
+
messages,
|
|
36
|
+
collapse = true,
|
|
37
|
+
transcription,
|
|
38
|
+
processing,
|
|
39
|
+
error,
|
|
40
|
+
onSubmit,
|
|
41
|
+
onCancel,
|
|
42
|
+
onOpenChange,
|
|
43
|
+
...props
|
|
44
|
+
}: ThreadProps) => {
|
|
45
|
+
const scroller = useRef<ScrollController>(null);
|
|
46
|
+
|
|
47
|
+
const identity = useIdentity();
|
|
48
|
+
const fallbackValue = keyToFallback(identity!.identityKey);
|
|
49
|
+
const userHue = identity!.profile?.data?.hue || fallbackValue.hue;
|
|
50
|
+
|
|
51
|
+
const handleSubmit = useCallback<NonNullable<PromptBarProps['onSubmit']>>(
|
|
52
|
+
(value: string) => {
|
|
53
|
+
onSubmit?.(value);
|
|
54
|
+
scroller.current?.scrollToBottom();
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
[onSubmit],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// TODO(dmaretskyi): This needs to be a separate type: `id` is not a valid ObjectId, this needs to accommodate messageId for deletion.
|
|
61
|
+
const { messages: filteredMessages = [] } = useMemo(() => {
|
|
62
|
+
if (collapse) {
|
|
63
|
+
return (messages ?? []).reduce<{ messages: Message[]; current?: Message }>(messageReducer, {
|
|
64
|
+
messages: [],
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
return { messages: messages ?? [] };
|
|
68
|
+
}
|
|
69
|
+
}, [messages, collapse]);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div role='none' className={mx('flex flex-col grow overflow-hidden', classNames)}>
|
|
73
|
+
<ScrollContainer ref={scroller} fade>
|
|
74
|
+
<div
|
|
75
|
+
role='none'
|
|
76
|
+
className={mx(filteredMessages.length > 0 && 'pbs-6 pbe-6')}
|
|
77
|
+
style={{ '--user-fill': `var(--dx-${userHue}Fill)` } as CSSProperties}
|
|
78
|
+
>
|
|
79
|
+
{filteredMessages.map((message) => (
|
|
80
|
+
<ThreadMessage key={message.id} classNames='px-4 pbe-4' space={space} message={message} {...props} />
|
|
81
|
+
))}
|
|
82
|
+
</div>
|
|
83
|
+
</ScrollContainer>
|
|
84
|
+
|
|
85
|
+
{onSubmit && (
|
|
86
|
+
<PromptBar
|
|
87
|
+
microphone={transcription}
|
|
88
|
+
processing={processing}
|
|
89
|
+
error={error}
|
|
90
|
+
onSubmit={handleSubmit}
|
|
91
|
+
onCancel={onCancel}
|
|
92
|
+
onOpenChange={onOpenChange}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|