@dxos/plugin-automation 0.7.5-labs.e27f9b9 → 0.7.5-labs.f400bbc
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-ITYXSN5Z.mjs +132 -0
- package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-OFDNNRLE.mjs} +4 -7
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs.map → chunk-OFDNNRLE.mjs.map} +3 -3
- package/dist/lib/browser/chunk-U7QLNY2S.mjs +8 -0
- package/dist/lib/browser/chunk-U7QLNY2S.mjs.map +7 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs +119 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs.map +7 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs +56 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -372
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs +27 -0
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs.map +7 -0
- package/dist/lib/node/{chunk-WWU5FVAO.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -131
- package/dist/lib/node/AutomationPanel-X33HHDMQ.cjs.map +7 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs +148 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs.map +7 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs +40 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-ORMEYEBE.cjs} +7 -10
- package/dist/lib/node/{chunk-5VF5JKUN.cjs.map → chunk-ORMEYEBE.cjs.map} +3 -3
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs +72 -0
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -373
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5HYLBDC3.cjs → react-surface-2WRVAPGR.cjs} +9 -28
- package/dist/lib/node/react-surface-2WRVAPGR.cjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs +133 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-6MUUH67V.mjs} +4 -7
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs.map → chunk-6MUUH67V.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs +10 -0
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs +120 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs.map +7 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs +57 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +22 -372
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-SS5WCRJ2.mjs → react-surface-QWLPOYXO.mjs} +5 -28
- package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/{ai-client.d.ts → complementary-panel.d.ts} +2 -3
- package/dist/types/src/capabilities/complementary-panel.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +1 -180
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- 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/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -11
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +1 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -92
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +23 -71
- package/src/AutomationPlugin.tsx +9 -64
- package/src/capabilities/complementary-panel.ts +56 -0
- package/src/capabilities/index.ts +1 -5
- package/src/capabilities/react-surface.tsx +1 -13
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +56 -49
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -5
- package/src/components/index.ts +0 -7
- package/src/index.ts +2 -3
- package/src/meta.ts +3 -3
- package/src/testing/index.ts +1 -1
- package/src/testing/{testing.ts → test-functions.ts} +0 -7
- package/src/translations.ts +2 -29
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs +0 -8
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs +0 -12
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs.map +0 -7
- package/dist/lib/browser/ai-client-AARXEMMJ.mjs +0 -22
- package/dist/lib/browser/ai-client-AARXEMMJ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs +0 -162
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs.map +0 -7
- package/dist/lib/browser/chunk-5SLV6AUA.mjs +0 -1367
- package/dist/lib/browser/chunk-5SLV6AUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-7XADMUOW.mjs +0 -205
- package/dist/lib/browser/chunk-7XADMUOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-HZ4TA7HY.mjs +0 -15
- package/dist/lib/browser/chunk-HZ4TA7HY.mjs.map +0 -7
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs +0 -283
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAVNWHNE.mjs +0 -242
- package/dist/lib/browser/chunk-RAVNWHNE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-754MPV7H.mjs +0 -29
- package/dist/lib/browser/intent-resolver-754MPV7H.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs +0 -50
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -24
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-LRDEDGXI.cjs +0 -26
- package/dist/lib/node/AutomationPanel-LRDEDGXI.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs +0 -33
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs.map +0 -7
- package/dist/lib/node/ai-client-SA35GN5Q.cjs +0 -38
- package/dist/lib/node/ai-client-SA35GN5Q.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs +0 -178
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs.map +0 -7
- package/dist/lib/node/chunk-6VMSH4P6.cjs +0 -1364
- package/dist/lib/node/chunk-6VMSH4P6.cjs.map +0 -7
- package/dist/lib/node/chunk-HEYQONXC.cjs +0 -302
- package/dist/lib/node/chunk-HEYQONXC.cjs.map +0 -7
- package/dist/lib/node/chunk-LU4HQWJD.cjs +0 -226
- package/dist/lib/node/chunk-LU4HQWJD.cjs.map +0 -7
- package/dist/lib/node/chunk-WWU5FVAO.cjs.map +0 -7
- package/dist/lib/node/chunk-ZS5RZ7RM.cjs +0 -34
- package/dist/lib/node/chunk-ZS5RZ7RM.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-CNVBSG4E.cjs +0 -44
- package/dist/lib/node/intent-resolver-CNVBSG4E.cjs.map +0 -7
- package/dist/lib/node/react-surface-5HYLBDC3.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -46
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs +0 -9
- package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs +0 -13
- package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs +0 -23
- package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs +0 -163
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs +0 -284
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs +0 -206
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ISYLEDVU.mjs +0 -16
- package/dist/lib/node-esm/chunk-ISYLEDVU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs +0 -243
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs +0 -1368
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs +0 -30
- package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SS5WCRJ2.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -25
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/artifacts.stories.d.ts +0 -16
- package/dist/types/src/artifacts.stories.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -8
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/index.d.ts +0 -4
- package/dist/types/src/components/ChatContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +0 -14
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +0 -8
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/index.d.ts +0 -2
- package/dist/types/src/components/MarkdownViewer/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
- package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
- package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ScrollContainer.d.ts +0 -15
- package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.d.ts +0 -11
- package/dist/types/src/components/Thread/StatusLine.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts +0 -9
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.d.ts +0 -9
- package/dist/types/src/components/Thread/Tabbed.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts +0 -8
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -10
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -12
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.d.ts +0 -13
- package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts +0 -9
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -2
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/hooks/email.d.ts +0 -4
- package/dist/types/src/hooks/email.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.d.ts +0 -65
- package/dist/types/src/hooks/processor.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.test.d.ts +0 -2
- package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/dist/types/src/hooks/useServiceRegistry.d.ts +0 -3
- package/dist/types/src/hooks/useServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/presets.d.ts +0 -9
- package/dist/types/src/presets.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -4
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/registry.d.ts +0 -9
- package/dist/types/src/types/registry.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -196
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/artifacts.stories.tsx +0 -241
- package/src/capabilities/ai-client.ts +0 -19
- package/src/capabilities/app-graph-builder.ts +0 -156
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -27
- package/src/components/ChatContainer/ChatContainer.tsx +0 -117
- package/src/components/ChatContainer/index.ts +0 -8
- package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +0 -56
- package/src/components/MarkdownViewer/MarkdownViewer.tsx +0 -79
- package/src/components/MarkdownViewer/index.ts +0 -5
- package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
- package/src/components/PromptEditor/PromptEditor.tsx +0 -222
- package/src/components/PromptEditor/index.ts +0 -5
- package/src/components/PromptEditor/prompt-extension.ts +0 -43
- package/src/components/PromptEditor/types.tsx +0 -28
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -48
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -75
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/components/Thread/ScrollContainer.tsx +0 -92
- package/src/components/Thread/StatusLine.stories.tsx +0 -52
- package/src/components/Thread/StatusLine.tsx +0 -76
- package/src/components/Thread/Tabbed.stories.tsx +0 -52
- package/src/components/Thread/Tabbed.tsx +0 -72
- package/src/components/Thread/Thread.stories.tsx +0 -190
- package/src/components/Thread/Thread.tsx +0 -156
- package/src/components/Thread/ThreadMessage.tsx +0 -195
- package/src/components/Thread/ToggleContainer.stories.tsx +0 -111
- package/src/components/Thread/ToggleContainer.tsx +0 -103
- package/src/components/Thread/index.ts +0 -5
- package/src/hooks/email.ts +0 -49
- package/src/hooks/index.ts +0 -8
- package/src/hooks/invocation-handler.ts +0 -109
- package/src/hooks/processor.test.ts +0 -15
- package/src/hooks/processor.ts +0 -201
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- package/src/hooks/useServiceRegistry.ts +0 -22
- package/src/presets.ts +0 -248
- package/src/tools/function.ts +0 -47
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -227
- package/src/tools/openapi.ts +0 -331
- package/src/types/index.ts +0 -7
- package/src/types/registry.ts +0 -89
- package/src/types/schema.ts +0 -120
- package/src/types/types.ts +0 -21
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type KeyboardEventHandler, useCallback, useMemo, useRef, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type Message } from '@dxos/artifact';
|
|
8
|
-
import { IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import { Spinner } from '@dxos/react-ui-sfx';
|
|
10
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
11
|
-
|
|
12
|
-
import { ScrollContainer, type ScrollController } from './ScrollContainer';
|
|
13
|
-
import { ThreadMessage, type ThreadMessageProps } from './ThreadMessage';
|
|
14
|
-
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
15
|
-
|
|
16
|
-
export type ThreadProps = {
|
|
17
|
-
messages?: Message[];
|
|
18
|
-
streaming?: boolean;
|
|
19
|
-
onSubmit?: (message: string) => void;
|
|
20
|
-
onStop?: () => void;
|
|
21
|
-
} & Pick<ThreadMessageProps, 'collapse' | 'debug' | 'onSuggest' | 'onDelete'>;
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Factor out scroll logic.
|
|
24
|
-
export const Thread = ({
|
|
25
|
-
messages,
|
|
26
|
-
streaming,
|
|
27
|
-
collapse,
|
|
28
|
-
debug,
|
|
29
|
-
onSubmit,
|
|
30
|
-
onStop,
|
|
31
|
-
onSuggest,
|
|
32
|
-
onDelete,
|
|
33
|
-
}: ThreadProps) => {
|
|
34
|
-
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
35
|
-
const scroller = useRef<ScrollController>(null);
|
|
36
|
-
|
|
37
|
-
const [text, setText] = useState('');
|
|
38
|
-
const handleKeyDown = useCallback<KeyboardEventHandler<HTMLInputElement>>(
|
|
39
|
-
(ev) => {
|
|
40
|
-
switch (ev.key) {
|
|
41
|
-
case 'Escape': {
|
|
42
|
-
setText('');
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
case 'Enter': {
|
|
47
|
-
const value = text.trim();
|
|
48
|
-
if (value.length > 0) {
|
|
49
|
-
scroller.current?.scrollToBottom();
|
|
50
|
-
onSubmit?.(value);
|
|
51
|
-
setText('');
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[text],
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Reduce message blocks into collections of messages that contain related contiguous blocks.
|
|
62
|
-
* For example, collapse all tool request/response pairs into a single message.
|
|
63
|
-
*/
|
|
64
|
-
// TODO(dmaretskyi): This needs to be a separate type: `id` is not a valid ObjectId, this needs to accommodate messageId for deletion.
|
|
65
|
-
const { messages: lines = [] } = useMemo(() => {
|
|
66
|
-
if (!collapse) {
|
|
67
|
-
return { messages: messages ?? [] };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (messages ?? []).reduce<{ messages: Message[]; current?: Message }>(
|
|
71
|
-
({ current, messages }, message) => {
|
|
72
|
-
let i = 0;
|
|
73
|
-
for (const block of message.content) {
|
|
74
|
-
switch (block.type) {
|
|
75
|
-
case 'tool_use':
|
|
76
|
-
case 'tool_result': {
|
|
77
|
-
if (current) {
|
|
78
|
-
current.content.push(block);
|
|
79
|
-
} else {
|
|
80
|
-
current = {
|
|
81
|
-
id: [message.id, i].join('_'),
|
|
82
|
-
role: message.role,
|
|
83
|
-
content: [block],
|
|
84
|
-
};
|
|
85
|
-
messages.push(current);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
case 'text':
|
|
91
|
-
default: {
|
|
92
|
-
current = undefined;
|
|
93
|
-
messages.push({
|
|
94
|
-
id: [message.id, i].join('_'),
|
|
95
|
-
role: message.role,
|
|
96
|
-
content: [block],
|
|
97
|
-
});
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
i++;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return { current, messages };
|
|
106
|
-
},
|
|
107
|
-
{ messages: [] as Message[] },
|
|
108
|
-
);
|
|
109
|
-
}, [messages, collapse]);
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div className='flex flex-col grow overflow-hidden'>
|
|
113
|
-
<ScrollContainer ref={scroller} classNames='py-2 gap-2 overflow-x-hidden'>
|
|
114
|
-
{lines.map((message) => (
|
|
115
|
-
<ThreadMessage
|
|
116
|
-
key={message.id}
|
|
117
|
-
classNames='px-4'
|
|
118
|
-
message={message}
|
|
119
|
-
collapse={collapse}
|
|
120
|
-
debug={debug}
|
|
121
|
-
onSuggest={onSuggest}
|
|
122
|
-
onDelete={onDelete}
|
|
123
|
-
/>
|
|
124
|
-
))}
|
|
125
|
-
</ScrollContainer>
|
|
126
|
-
|
|
127
|
-
{onSubmit && (
|
|
128
|
-
<div className='flex p-4 gap-3 items-center'>
|
|
129
|
-
<Spinner active={streaming} />
|
|
130
|
-
<Input.Root>
|
|
131
|
-
<Input.TextInput
|
|
132
|
-
autoFocus
|
|
133
|
-
classNames='px-2 bg-base rounded'
|
|
134
|
-
placeholder={t('chat input placeholder')}
|
|
135
|
-
value={text}
|
|
136
|
-
onChange={(ev) => setText(ev.target.value)}
|
|
137
|
-
onKeyDown={handleKeyDown}
|
|
138
|
-
/>
|
|
139
|
-
</Input.Root>
|
|
140
|
-
{onStop && (
|
|
141
|
-
<IconButton
|
|
142
|
-
disabled={!streaming}
|
|
143
|
-
classNames={mx('!p-1 !opacity-20 transition', streaming && '!opacity-80')}
|
|
144
|
-
variant='ghost'
|
|
145
|
-
size={5}
|
|
146
|
-
onClick={onStop}
|
|
147
|
-
icon='ph--x--regular'
|
|
148
|
-
label={t('chat stop')}
|
|
149
|
-
iconOnly
|
|
150
|
-
/>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type FC } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type MessageContentBlock, type Message } from '@dxos/artifact';
|
|
8
|
-
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { Button, ButtonGroup, Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
-
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
12
|
-
import { safeParseJson } from '@dxos/util';
|
|
13
|
-
|
|
14
|
-
import { StatusLine } from './StatusLine';
|
|
15
|
-
import { ToggleContainer } from './ToggleContainer';
|
|
16
|
-
import { MarkdownViewer } from '../MarkdownViewer';
|
|
17
|
-
|
|
18
|
-
export type ThreadMessageProps = ThemedClassName<{
|
|
19
|
-
message: Message;
|
|
20
|
-
collapse?: boolean;
|
|
21
|
-
debug?: boolean;
|
|
22
|
-
onSuggest?: (text: string) => void;
|
|
23
|
-
onDelete?: (id: string) => void;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
27
|
-
classNames,
|
|
28
|
-
message,
|
|
29
|
-
collapse,
|
|
30
|
-
debug,
|
|
31
|
-
onSuggest,
|
|
32
|
-
onDelete,
|
|
33
|
-
}) => {
|
|
34
|
-
if (typeof message !== 'object') {
|
|
35
|
-
return <div className={mx(classNames)}>{message}</div>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const { role, content = [] } = message;
|
|
39
|
-
|
|
40
|
-
// TODO(burdon): Factor out tool blocks.
|
|
41
|
-
const tools = content.filter((block) => block.type === 'tool_use' || block.type === 'tool_result');
|
|
42
|
-
if (collapse && tools.length > 0) {
|
|
43
|
-
let request: MessageContentBlock & { type: 'tool_use' };
|
|
44
|
-
const lines = tools.map((tool) => {
|
|
45
|
-
switch (tool.type) {
|
|
46
|
-
case 'tool_use': {
|
|
47
|
-
request = tool;
|
|
48
|
-
// TODO(burdon): Get plugin name.
|
|
49
|
-
return `Calling ${tool.name}...`;
|
|
50
|
-
}
|
|
51
|
-
case 'tool_result': {
|
|
52
|
-
if (!request) {
|
|
53
|
-
return 'Error';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return `Processed ${request.name}`;
|
|
57
|
-
}
|
|
58
|
-
default:
|
|
59
|
-
return 'Error';
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div className={mx('flex', classNames)}>
|
|
65
|
-
<div className='w-full p-1 px-2 overflow-hidden rounded-md bg-base'>
|
|
66
|
-
<ToggleContainer title={<StatusLine lines={lines} autoAdvance />} toggle>
|
|
67
|
-
<Json data={content[content.length - 1]} classNames='!p-1 text-xs' />
|
|
68
|
-
</ToggleContainer>
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div className={mx('flex flex-col shrink-0 gap-2')}>
|
|
76
|
-
{debug && (
|
|
77
|
-
<div className='text-xs text-subdued'>
|
|
78
|
-
{message.id}{' '}
|
|
79
|
-
{onDelete && (
|
|
80
|
-
<span className='cursor-pointer underline' onClick={() => onDelete(message.id)}>
|
|
81
|
-
delete
|
|
82
|
-
</span>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
{content.map((block, idx) => (
|
|
87
|
-
<div key={idx} className={mx('flex', classNames, block.type === 'text' && role === 'user' && 'justify-end')}>
|
|
88
|
-
<Block role={role} block={block} onSuggest={onSuggest ?? (() => {})} />
|
|
89
|
-
</div>
|
|
90
|
-
))}
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const Block = ({
|
|
96
|
-
block,
|
|
97
|
-
role,
|
|
98
|
-
onSuggest,
|
|
99
|
-
}: Pick<Message, 'role'> & { block: MessageContentBlock; onSuggest: (text: string) => void }) => {
|
|
100
|
-
const Component = componentMap[block.type] ?? componentMap.default;
|
|
101
|
-
return (
|
|
102
|
-
<div
|
|
103
|
-
className={mx(
|
|
104
|
-
'p-1 px-2 overflow-hidden rounded-md',
|
|
105
|
-
(block.type !== 'text' || block.disposition) && 'w-full bg-base',
|
|
106
|
-
block.type === 'text' && role === 'user' && 'bg-blue-200 dark:bg-blue-800',
|
|
107
|
-
)}
|
|
108
|
-
>
|
|
109
|
-
<Component block={block} onSuggest={onSuggest} />
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const titles: Record<string, string> = {
|
|
115
|
-
['cot' as const]: 'Chain of thought',
|
|
116
|
-
|
|
117
|
-
// TODO(burdon): Only show if debugging.
|
|
118
|
-
['tool_use' as const]: 'Tool request',
|
|
119
|
-
['tool_result' as const]: 'Tool result',
|
|
120
|
-
|
|
121
|
-
['artifact' as const]: 'Artifact',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
type BlockComponent = FC<{ block: MessageContentBlock; onSuggest: (text: string) => void }>;
|
|
125
|
-
|
|
126
|
-
const componentMap: Record<string, BlockComponent> = {
|
|
127
|
-
text: ({ block }) => {
|
|
128
|
-
invariant(block.type === 'text');
|
|
129
|
-
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
130
|
-
if (!title) {
|
|
131
|
-
return (
|
|
132
|
-
<MarkdownViewer content={block.text} classNames={[block.disposition === 'cot' && 'text-sm text-subdued']} />
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<ToggleContainer
|
|
138
|
-
title={title}
|
|
139
|
-
icon={
|
|
140
|
-
block.pending ? (
|
|
141
|
-
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
|
|
142
|
-
) : undefined
|
|
143
|
-
}
|
|
144
|
-
defaultOpen={block.disposition === 'cot'}
|
|
145
|
-
toggle
|
|
146
|
-
>
|
|
147
|
-
<MarkdownViewer content={block.text} classNames={[block.disposition === 'cot' && 'text-sm text-subdued']} />
|
|
148
|
-
</ToggleContainer>
|
|
149
|
-
);
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
json: ({ block, onSuggest }) => {
|
|
153
|
-
invariant(block.type === 'json');
|
|
154
|
-
|
|
155
|
-
switch (block.disposition) {
|
|
156
|
-
case 'suggest': {
|
|
157
|
-
const { text = '' }: { text: string } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
158
|
-
return <Button onClick={() => onSuggest(text)}>{text}</Button>;
|
|
159
|
-
}
|
|
160
|
-
case 'select': {
|
|
161
|
-
const { options = [] }: { options: string[] } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
162
|
-
return (
|
|
163
|
-
<ButtonGroup>
|
|
164
|
-
{options.map((option) => (
|
|
165
|
-
<Button key={option} onClick={() => onSuggest(option)}>
|
|
166
|
-
{option}
|
|
167
|
-
</Button>
|
|
168
|
-
))}
|
|
169
|
-
</ButtonGroup>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
default: {
|
|
173
|
-
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
174
|
-
return (
|
|
175
|
-
<ToggleContainer title={title ?? 'JSON'} toggle>
|
|
176
|
-
<Json data={safeParseJson(block.json ?? block)} classNames='!p-1 text-xs' />
|
|
177
|
-
</ToggleContainer>
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
default: ({ block }) => {
|
|
184
|
-
let title = titles[block.type];
|
|
185
|
-
if (block.type === 'tool_use') {
|
|
186
|
-
title = `Tool [${block.name}]`; // TODO(burdon): Get label from tool.
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<ToggleContainer title={title ?? 'JSON'} toggle>
|
|
191
|
-
<Json data={block} classNames='!p-1 text-xs' />
|
|
192
|
-
</ToggleContainer>
|
|
193
|
-
);
|
|
194
|
-
},
|
|
195
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { computed, type ReadonlySignal, signal } from '@preact/signals-core';
|
|
8
|
-
import { type StoryObj, type Meta } from '@storybook/react';
|
|
9
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
10
|
-
|
|
11
|
-
import { faker } from '@dxos/random';
|
|
12
|
-
import { Icon, Input, Toolbar } from '@dxos/react-ui';
|
|
13
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
14
|
-
import { withLayout, withTheme, withSignals } from '@dxos/storybook-utils';
|
|
15
|
-
|
|
16
|
-
import { ToggleContainer, type ToggleContainerProps } from './ToggleContainer';
|
|
17
|
-
import { MarkdownViewer } from '../MarkdownViewer';
|
|
18
|
-
|
|
19
|
-
class Generator {
|
|
20
|
-
private readonly _current = signal<string>(faker.lorem.sentence(5));
|
|
21
|
-
private readonly _lines = signal<string[]>([]);
|
|
22
|
-
private _running: NodeJS.Timeout | undefined;
|
|
23
|
-
|
|
24
|
-
readonly count = computed(() => this._lines.value.length);
|
|
25
|
-
readonly text: ReadonlySignal<string[]> = computed(() => [...this._lines.value, this._current.value]);
|
|
26
|
-
|
|
27
|
-
start() {
|
|
28
|
-
this.stop();
|
|
29
|
-
this._running = setInterval(() => {
|
|
30
|
-
if (this._current.value.length > 0) {
|
|
31
|
-
this._current.value += ' ';
|
|
32
|
-
}
|
|
33
|
-
this._current.value += faker.lorem.words(Math.ceil(Math.random() * 2));
|
|
34
|
-
if (Math.random() > 0.95) {
|
|
35
|
-
this._lines.value = [...this._lines.value, this._current.value + '.'];
|
|
36
|
-
this._current.value = '';
|
|
37
|
-
}
|
|
38
|
-
}, 100);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
stop() {
|
|
42
|
-
if (this._running) {
|
|
43
|
-
clearInterval(this._running);
|
|
44
|
-
this._running = undefined;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const Render = ({ shrinkX, ...props }: ToggleContainerProps) => {
|
|
50
|
-
const generator = useMemo(() => new Generator(), []);
|
|
51
|
-
const [running, setRunning] = useState(false);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (running) {
|
|
54
|
-
generator.start();
|
|
55
|
-
} else {
|
|
56
|
-
generator.stop();
|
|
57
|
-
}
|
|
58
|
-
}, [running]);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div className='flex flex-col w-[500px]'>
|
|
62
|
-
<Toolbar.Root classNames='p-4'>
|
|
63
|
-
<Input.Root>
|
|
64
|
-
<Input.Switch checked={running} onCheckedChange={(checked) => setRunning(checked)} />
|
|
65
|
-
</Input.Root>
|
|
66
|
-
<div className='grow' />
|
|
67
|
-
<div>{generator.count.value}</div>
|
|
68
|
-
</Toolbar.Root>
|
|
69
|
-
<div className='flex p-4'>
|
|
70
|
-
<div className={mx('border border-border rounded-md p-2', !shrinkX && 'w-full')}>
|
|
71
|
-
<ToggleContainer
|
|
72
|
-
{...props}
|
|
73
|
-
shrinkX={shrinkX}
|
|
74
|
-
toggle
|
|
75
|
-
icon={
|
|
76
|
-
running ? (
|
|
77
|
-
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
|
|
78
|
-
) : undefined
|
|
79
|
-
}
|
|
80
|
-
>
|
|
81
|
-
<MarkdownViewer classNames='text-sm' content={generator.text.value.join('\n\n')} />
|
|
82
|
-
</ToggleContainer>
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const meta: Meta<typeof ToggleContainer> = {
|
|
90
|
-
title: 'plugins/plugin-automation/ToggleContainer',
|
|
91
|
-
component: ToggleContainer,
|
|
92
|
-
render: Render,
|
|
93
|
-
decorators: [withSignals, withTheme, withLayout({ fullscreen: true, classNames: 'justify-center bg-base' })],
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default meta;
|
|
97
|
-
|
|
98
|
-
type Story = StoryObj<typeof ToggleContainer>;
|
|
99
|
-
|
|
100
|
-
export const Default: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
title: 'Markdown',
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const Shrink: Story = {
|
|
107
|
-
args: {
|
|
108
|
-
title: 'Markdown',
|
|
109
|
-
shrinkX: true,
|
|
110
|
-
},
|
|
111
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
export type ToggleContainerProps = ThemedClassName<
|
|
11
|
-
PropsWithChildren<{
|
|
12
|
-
title?: string | JSX.Element;
|
|
13
|
-
icon?: JSX.Element;
|
|
14
|
-
toggle?: boolean;
|
|
15
|
-
defaultOpen?: boolean;
|
|
16
|
-
duration?: number;
|
|
17
|
-
/** Should shrink the width when closed. */
|
|
18
|
-
shrinkX?: boolean;
|
|
19
|
-
}>
|
|
20
|
-
>;
|
|
21
|
-
|
|
22
|
-
// TODO(burdon): Externalize toggle state.
|
|
23
|
-
export const ToggleContainer = ({
|
|
24
|
-
title,
|
|
25
|
-
icon,
|
|
26
|
-
toggle,
|
|
27
|
-
defaultOpen,
|
|
28
|
-
duration = 400,
|
|
29
|
-
shrinkX = false,
|
|
30
|
-
children,
|
|
31
|
-
classNames,
|
|
32
|
-
}: ToggleContainerProps) => {
|
|
33
|
-
const [expand, setExpand] = useState(defaultOpen || !toggle);
|
|
34
|
-
const [expandX, setExpandX] = useState(shrinkX ? expand : true);
|
|
35
|
-
const [expandY, setExpandY] = useState(expand);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
let t: NodeJS.Timeout;
|
|
39
|
-
if (expand) {
|
|
40
|
-
if (shrinkX) {
|
|
41
|
-
setExpandX(true);
|
|
42
|
-
}
|
|
43
|
-
t = setTimeout(
|
|
44
|
-
() => {
|
|
45
|
-
setExpandY(true);
|
|
46
|
-
},
|
|
47
|
-
shrinkX ? duration : 0,
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
setExpandY(false);
|
|
51
|
-
if (shrinkX) {
|
|
52
|
-
t = setTimeout(() => {
|
|
53
|
-
setExpandX(false);
|
|
54
|
-
}, duration);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return () => clearTimeout(t);
|
|
59
|
-
}, [expand]);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={mx('overflow-hidden', classNames)}>
|
|
63
|
-
{title && (
|
|
64
|
-
<div
|
|
65
|
-
className='flex gap-1 py-1 items-center text-sm text-subdued cursor-pointer select-none'
|
|
66
|
-
onClick={toggle ? () => setExpand((open) => !open) : undefined}
|
|
67
|
-
>
|
|
68
|
-
{toggle && (
|
|
69
|
-
<div className='flex w-[24px] h-[24px] items-center justify-center'>
|
|
70
|
-
<Icon
|
|
71
|
-
size={4}
|
|
72
|
-
icon={'ph--caret-right--regular'}
|
|
73
|
-
style={{ transitionDuration: `${shrinkX ? duration * 2 : duration}ms` }}
|
|
74
|
-
classNames={['transition transition-transform ease-in-out', expand ? 'rotate-90' : 'transform-none']}
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
)}
|
|
78
|
-
<div className='flex-1 pis-1 pie-1 truncate'>{title}</div>
|
|
79
|
-
{icon}
|
|
80
|
-
</div>
|
|
81
|
-
)}
|
|
82
|
-
<div
|
|
83
|
-
style={{ transitionDuration: `${duration}ms` }}
|
|
84
|
-
className={mx(
|
|
85
|
-
'grid transition-[grid-template-columns] ease-in-out',
|
|
86
|
-
expandX ? 'grid-cols-[1fr]' : 'grid-cols-[0fr]',
|
|
87
|
-
)}
|
|
88
|
-
>
|
|
89
|
-
<div className='overflow-hidden'>
|
|
90
|
-
<div
|
|
91
|
-
style={{ transitionDuration: `${duration}ms` }}
|
|
92
|
-
className={mx(
|
|
93
|
-
'grid transition-[grid-template-rows] ease-in-out',
|
|
94
|
-
expandY ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
|
|
95
|
-
)}
|
|
96
|
-
>
|
|
97
|
-
<div className={mx('flex overflow-hidden transition-opacity')}>{children}</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
};
|
package/src/hooks/email.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { findObjectWithForeignKey } from '@dxos/echo-db';
|
|
6
|
-
import { foreignKey } from '@dxos/echo-schema';
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
import { MailboxType } from '@dxos/plugin-inbox/types';
|
|
9
|
-
import { MessageType } from '@dxos/plugin-space/types';
|
|
10
|
-
import { type Space, Filter, create, makeRef } from '@dxos/react-client/echo';
|
|
11
|
-
|
|
12
|
-
export const SOURCE_ID = 'hub.dxos.network/api/mailbox';
|
|
13
|
-
|
|
14
|
-
export const handleEmail = async (space: Space, data: any) => {
|
|
15
|
-
const { messages } = data;
|
|
16
|
-
|
|
17
|
-
// Create mailbox if doesn't exist.
|
|
18
|
-
const { objects: mailboxes } = await space.db.query(Filter.schema(MailboxType)).run();
|
|
19
|
-
const mailbox = mailboxes[0] ?? space.db.add(create(MailboxType, { messages: [] }));
|
|
20
|
-
|
|
21
|
-
log.info('messages', { count: messages.length, existingMailbox: mailboxes.length > 0 });
|
|
22
|
-
|
|
23
|
-
const { objects } = await space.db.query(Filter.schema(MessageType)).run();
|
|
24
|
-
for (const message of messages) {
|
|
25
|
-
let object = findObjectWithForeignKey(objects, { source: SOURCE_ID, id: String(message.id) });
|
|
26
|
-
if (!object) {
|
|
27
|
-
object = space.db.add(
|
|
28
|
-
create(
|
|
29
|
-
MessageType,
|
|
30
|
-
{
|
|
31
|
-
sender: { email: message.from },
|
|
32
|
-
timestamp: new Date(message.created).toISOString(),
|
|
33
|
-
text: message.body,
|
|
34
|
-
properties: {
|
|
35
|
-
subject: message.subject,
|
|
36
|
-
to: [{ email: message.to }],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
keys: [foreignKey(SOURCE_ID, String(message.id))],
|
|
41
|
-
},
|
|
42
|
-
),
|
|
43
|
-
);
|
|
44
|
-
mailbox.messages?.push(makeRef(object));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return 200;
|
|
49
|
-
};
|