@dxos/plugin-assistant 0.8.3-main.672df60 → 0.8.3-staging.0fa589b
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/{AssistantDialog-UAZSN6GT.mjs → AssistantDialog-MQOOR364.mjs} +5 -4
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +321 -0
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-UTN3AO5U.mjs → ChatContainer-C2NEAS3A.mjs} +5 -4
- package/dist/lib/browser/{TemplateContainer-AKUYL4AV.mjs → TemplateContainer-QQHVOTSI.mjs} +2 -2
- package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +7 -0
- package/dist/lib/browser/{ai-client-COXVUC6V.mjs → ai-client-MK2ZZII2.mjs} +12 -8
- package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-56OZ5RW4.mjs → app-graph-builder-E4H5DCOJ.mjs} +52 -33
- package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NBSPGIHL.mjs → chunk-AAOKC2JN.mjs} +17 -15
- package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6SD7S7W5.mjs → chunk-BI6AHRNJ.mjs} +8 -8
- package/dist/lib/browser/{chunk-6SD7S7W5.mjs.map → chunk-BI6AHRNJ.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-Q6XE3O3E.mjs → chunk-JO4W3MF7.mjs} +44 -73
- package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +7 -0
- package/dist/lib/browser/chunk-MEGMOFJB.mjs +16 -0
- package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3F44MBHU.mjs → chunk-UE3IZ4PN.mjs} +1 -1
- package/dist/lib/browser/{chunk-3F44MBHU.mjs.map → chunk-UE3IZ4PN.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +84 -30
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-GWELYIX2.mjs → intent-resolver-3UICTGPM.mjs} +12 -8
- package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-DGS34EON.mjs → react-surface-LXCNUSZN.mjs} +29 -14
- package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +7 -0
- package/dist/lib/browser/{settings-BTFB7IQ6.mjs → settings-XRHXVWGB.mjs} +4 -4
- package/dist/lib/browser/settings-XRHXVWGB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{AssistantDialog-RTB5Q7FP.cjs → AssistantDialog-AN4Z6YUV.cjs} +9 -8
- package/dist/lib/node/{AssistantDialog-RTB5Q7FP.cjs.map → AssistantDialog-AN4Z6YUV.cjs.map} +1 -1
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +344 -0
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-P3JL4VZ7.cjs → ChatContainer-VKYBQHUB.cjs} +9 -8
- package/dist/lib/node/{ChatContainer-P3JL4VZ7.cjs.map → ChatContainer-VKYBQHUB.cjs.map} +1 -1
- package/dist/lib/node/{TemplateContainer-CTG2MB4W.cjs → TemplateContainer-JZF2DCCG.cjs} +5 -5
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +7 -0
- package/dist/lib/node/{ai-client-R2CGEYZW.cjs → ai-client-7HNSMUMT.cjs} +14 -10
- package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-QLF353LH.cjs → app-graph-builder-PPR5B5KU.cjs} +63 -44
- package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +7 -0
- package/dist/lib/node/chunk-FUAGEO7Q.cjs +52 -0
- package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +7 -0
- package/dist/lib/node/{chunk-BWL5A3O5.cjs → chunk-IKZBMHSW.cjs} +14 -14
- package/dist/lib/node/{chunk-BWL5A3O5.cjs.map → chunk-IKZBMHSW.cjs.map} +3 -3
- package/dist/lib/node/{chunk-UNVDZOLA.cjs → chunk-LMDJEGZ2.cjs} +28 -26
- package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +7 -0
- package/dist/lib/node/{chunk-PG7YNQ4R.cjs → chunk-NIDICM57.cjs} +66 -96
- package/dist/lib/node/chunk-NIDICM57.cjs.map +7 -0
- package/dist/lib/node/{chunk-TS3H5OSX.cjs → chunk-QGPWY6GW.cjs} +4 -4
- package/dist/lib/node/{chunk-TS3H5OSX.cjs.map → chunk-QGPWY6GW.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +129 -73
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{intent-resolver-U7663JU7.cjs → intent-resolver-QSWGTKON.cjs} +17 -13
- package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-QXZTILW6.cjs → react-surface-D3NBYRZ6.cjs} +41 -26
- package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +7 -0
- package/dist/lib/node/{settings-LBJMT6YB.cjs → settings-2JXLKYGE.cjs} +7 -7
- package/dist/lib/node/settings-2JXLKYGE.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +14 -14
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AssistantDialog-DONAO6SA.mjs → AssistantDialog-6WEMLUPU.mjs} +5 -4
- package/dist/lib/{browser/AssistantDialog-UAZSN6GT.mjs.map → node-esm/AssistantDialog-6WEMLUPU.mjs.map} +1 -1
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +322 -0
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-FVIGCDIG.mjs → ChatContainer-3MVBTUJN.mjs} +5 -4
- package/dist/lib/{browser/ChatContainer-UTN3AO5U.mjs.map → node-esm/ChatContainer-3MVBTUJN.mjs.map} +1 -1
- package/dist/lib/node-esm/{TemplateContainer-IVDQ4XQG.mjs → TemplateContainer-SOEWY2ZN.mjs} +2 -2
- package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-client-I5LXHMOZ.mjs → ai-client-XGZBJ6BE.mjs} +12 -8
- package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-5YX5TKKT.mjs → app-graph-builder-3SY5MBIK.mjs} +52 -33
- package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +18 -0
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs → chunk-3UEZLJ2V.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs.map → chunk-3UEZLJ2V.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-TQYSF2GS.mjs → chunk-J6UXXZGJ.mjs} +17 -15
- package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MNH6E6EB.mjs → chunk-OD574YIU.mjs} +44 -73
- package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GJE4WCUJ.mjs → chunk-UCOFKNKN.mjs} +8 -8
- package/dist/lib/node-esm/{chunk-GJE4WCUJ.mjs.map → chunk-UCOFKNKN.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +84 -30
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-N5TM3RTL.mjs → intent-resolver-E6MXTYAU.mjs} +12 -8
- package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-FTKGQQD2.mjs → react-surface-7HA5EDWY.mjs} +29 -14
- package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-TGCCAH5D.mjs → settings-5IAY6BT4.mjs} +4 -4
- package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +2 -2
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +2 -2
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +9 -0
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +8 -3
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintEditor/index.d.ts +1 -2
- package/dist/types/src/components/BlueprintEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TemplateContainer.d.ts +2 -2
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.d.ts +3 -3
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +8 -8
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/parser/filter-generator.d.ts +1 -1
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/queue-logger.d.ts +11 -0
- package/dist/types/src/queue-logger.d.ts.map +1 -0
- package/dist/types/src/stories/Query.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Research.stories.d.ts +1 -1
- package/dist/types/src/stories/Research.stories.d.ts.map +1 -1
- package/dist/types/src/testing/test-blueprint.d.ts +4 -10
- package/dist/types/src/testing/test-blueprint.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +15 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/chat.d.ts +13 -10
- package/dist/types/src/types/chat.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +88 -9
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts +3 -23
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -6
- package/package.json +71 -68
- package/src/AssistantPlugin.tsx +30 -7
- package/src/capabilities/ai-client.ts +11 -6
- package/src/capabilities/app-graph-builder.ts +69 -54
- package/src/capabilities/capabilities.ts +3 -2
- package/src/capabilities/intent-resolver.ts +12 -5
- package/src/capabilities/react-surface.tsx +23 -19
- package/src/capabilities/settings.ts +2 -2
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -0
- package/src/components/BlueprintContainer.tsx +148 -0
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +2 -2
- package/src/components/BlueprintEditor/BlueprintEditor.tsx +31 -21
- package/src/components/BlueprintEditor/index.ts +1 -3
- package/src/components/PromptSettings.tsx +1 -1
- package/src/components/TemplateContainer.tsx +5 -2
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
- package/src/components/Thread/Thread.stories.tsx +19 -27
- package/src/components/Thread/ThreadContainer.stories.tsx +11 -12
- package/src/components/Thread/ThreadContainer.tsx +3 -4
- package/src/components/Thread/reducer.ts +3 -3
- package/src/components/index.ts +1 -1
- package/src/events.ts +11 -0
- package/src/hooks/processor.ts +4 -4
- package/src/hooks/useContextProvider.ts +13 -16
- package/src/hooks/useMessageQueue.ts +3 -2
- package/src/index.ts +2 -0
- package/src/parser/filter-generator.test.ts +1 -1
- package/src/parser/filter-generator.ts +1 -1
- package/src/queue-logger.ts +125 -0
- package/src/stories/Query.stories.tsx +28 -29
- package/src/stories/Research.stories.tsx +32 -46
- package/src/stories/test-data.ts +12 -12
- package/src/testing/test-blueprint.ts +14 -6
- package/src/testing/test-services.ts +6 -6
- package/src/tools/function.ts +2 -2
- package/src/tools/openapi.test.ts +7 -13
- package/src/tools/openapi.ts +5 -5
- package/src/translations.ts +19 -5
- package/src/types/chat.ts +3 -4
- package/src/types/service.ts +8 -4
- package/src/types/template.ts +11 -3
- package/dist/lib/browser/BlueprintEditor-DGV4KJDM.mjs +0 -45
- package/dist/lib/browser/BlueprintEditor-DGV4KJDM.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs.map +0 -7
- package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-56OZ5RW4.mjs.map +0 -7
- package/dist/lib/browser/chunk-NBSPGIHL.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q6XE3O3E.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-GWELYIX2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DGS34EON.mjs.map +0 -7
- package/dist/lib/browser/settings-BTFB7IQ6.mjs.map +0 -7
- package/dist/lib/node/BlueprintEditor-43VM3XPO.cjs +0 -72
- package/dist/lib/node/BlueprintEditor-43VM3XPO.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-CTG2MB4W.cjs.map +0 -7
- package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-QLF353LH.cjs.map +0 -7
- package/dist/lib/node/chunk-PG7YNQ4R.cjs.map +0 -7
- package/dist/lib/node/chunk-UNVDZOLA.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-U7663JU7.cjs.map +0 -7
- package/dist/lib/node/react-surface-QXZTILW6.cjs.map +0 -7
- package/dist/lib/node/settings-LBJMT6YB.cjs.map +0 -7
- package/dist/lib/node-esm/BlueprintEditor-CTARB2FO.mjs +0 -47
- package/dist/lib/node-esm/BlueprintEditor-CTARB2FO.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-5YX5TKKT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MNH6E6EB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TQYSF2GS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-N5TM3RTL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-FTKGQQD2.mjs.map +0 -7
- package/dist/lib/node-esm/settings-TGCCAH5D.mjs.map +0 -7
- /package/dist/lib/{node-esm/AssistantDialog-DONAO6SA.mjs.map → browser/AssistantDialog-MQOOR364.mjs.map} +0 -0
- /package/dist/lib/{node-esm/ChatContainer-FVIGCDIG.mjs.map → browser/ChatContainer-C2NEAS3A.mjs.map} +0 -0
|
@@ -7,10 +7,10 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { Message } from '@dxos/ai';
|
|
11
11
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
12
12
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
13
|
-
import {
|
|
13
|
+
import { Obj } from '@dxos/echo';
|
|
14
14
|
import { faker } from '@dxos/random';
|
|
15
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
16
|
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
@@ -29,12 +29,11 @@ const DefaultStory = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
|
29
29
|
|
|
30
30
|
const handleSubmit = useCallback(
|
|
31
31
|
(text: string) => {
|
|
32
|
-
const request: Message =
|
|
33
|
-
const response: Message = {
|
|
34
|
-
id: Type.ObjectId.random(),
|
|
32
|
+
const request: Message = Obj.make(Message, { role: 'user', content: [{ type: 'text', text }] });
|
|
33
|
+
const response: Message = Obj.make(Message, {
|
|
35
34
|
role: 'assistant',
|
|
36
35
|
content: [{ type: 'text', disposition: 'cot', pending: true, text: faker.lorem.paragraphs(1) }],
|
|
37
|
-
};
|
|
36
|
+
});
|
|
38
37
|
setMessages([...messages, request, response]);
|
|
39
38
|
setProcessing(true);
|
|
40
39
|
setTimeout(() => {
|
|
@@ -43,11 +42,10 @@ const DefaultStory = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
|
43
42
|
...messages,
|
|
44
43
|
request,
|
|
45
44
|
response,
|
|
46
|
-
{
|
|
47
|
-
id: Type.ObjectId.random(),
|
|
45
|
+
Obj.make(Message, {
|
|
48
46
|
role: 'assistant',
|
|
49
47
|
content: [{ type: 'text', text: faker.lorem.paragraphs(1) }],
|
|
50
|
-
},
|
|
48
|
+
}),
|
|
51
49
|
]);
|
|
52
50
|
setProcessing(false);
|
|
53
51
|
}, 3_000);
|
|
@@ -89,8 +87,7 @@ export default meta;
|
|
|
89
87
|
type Story = StoryObj<ThreadProps>;
|
|
90
88
|
|
|
91
89
|
const TEST_MESSAGES: Message[] = [
|
|
92
|
-
{
|
|
93
|
-
id: Type.ObjectId.random(),
|
|
90
|
+
Obj.make(Message, {
|
|
94
91
|
role: 'user',
|
|
95
92
|
content: [
|
|
96
93
|
{
|
|
@@ -98,9 +95,8 @@ const TEST_MESSAGES: Message[] = [
|
|
|
98
95
|
text: faker.lorem.sentence(5),
|
|
99
96
|
},
|
|
100
97
|
],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: Type.ObjectId.random(),
|
|
98
|
+
}),
|
|
99
|
+
Obj.make(Message, {
|
|
104
100
|
role: 'assistant',
|
|
105
101
|
content: [
|
|
106
102
|
{
|
|
@@ -123,9 +119,8 @@ const TEST_MESSAGES: Message[] = [
|
|
|
123
119
|
input: {},
|
|
124
120
|
},
|
|
125
121
|
],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
id: Type.ObjectId.random(),
|
|
122
|
+
}),
|
|
123
|
+
Obj.make(Message, {
|
|
129
124
|
role: 'user',
|
|
130
125
|
content: [
|
|
131
126
|
{
|
|
@@ -134,9 +129,8 @@ const TEST_MESSAGES: Message[] = [
|
|
|
134
129
|
content: 'This is a tool result.',
|
|
135
130
|
},
|
|
136
131
|
],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: Type.ObjectId.random(),
|
|
132
|
+
}),
|
|
133
|
+
Obj.make(Message, {
|
|
140
134
|
role: 'assistant',
|
|
141
135
|
content: [
|
|
142
136
|
{
|
|
@@ -146,9 +140,8 @@ const TEST_MESSAGES: Message[] = [
|
|
|
146
140
|
input: {},
|
|
147
141
|
},
|
|
148
142
|
],
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
id: Type.ObjectId.random(),
|
|
143
|
+
}),
|
|
144
|
+
Obj.make(Message, {
|
|
152
145
|
role: 'user',
|
|
153
146
|
content: [
|
|
154
147
|
{
|
|
@@ -157,9 +150,8 @@ const TEST_MESSAGES: Message[] = [
|
|
|
157
150
|
content: 'This is a tool result.',
|
|
158
151
|
},
|
|
159
152
|
],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
id: Type.ObjectId.random(),
|
|
153
|
+
}),
|
|
154
|
+
Obj.make(Message, {
|
|
163
155
|
role: 'assistant',
|
|
164
156
|
content: [
|
|
165
157
|
{
|
|
@@ -167,7 +159,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
167
159
|
text: faker.lorem.paragraphs(1),
|
|
168
160
|
},
|
|
169
161
|
],
|
|
170
|
-
},
|
|
162
|
+
}),
|
|
171
163
|
];
|
|
172
164
|
|
|
173
165
|
export const Default: Story = {
|
|
@@ -7,7 +7,7 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { EdgeAiServiceClient, Message } from '@dxos/ai';
|
|
11
11
|
import {
|
|
12
12
|
Capabilities,
|
|
13
13
|
Events,
|
|
@@ -19,8 +19,7 @@ import {
|
|
|
19
19
|
} from '@dxos/app-framework';
|
|
20
20
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
21
21
|
import { remoteServiceEndpoints } from '@dxos/artifact-testing';
|
|
22
|
-
import {
|
|
23
|
-
import { createQueueDxn, create, Query, Filter } from '@dxos/echo-schema';
|
|
22
|
+
import { Filter, Obj, Query, Type } from '@dxos/echo';
|
|
24
23
|
import { invariant } from '@dxos/invariant';
|
|
25
24
|
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
26
25
|
import { ChessType } from '@dxos/plugin-chess/types';
|
|
@@ -58,7 +57,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
58
57
|
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
59
58
|
const tools = useCapabilities(Capabilities.Tools);
|
|
60
59
|
|
|
61
|
-
const
|
|
60
|
+
const aiClient = useMemo(() => new EdgeAiServiceClient({ endpoint: endpoints.ai }), []);
|
|
62
61
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
63
62
|
|
|
64
63
|
// TODO(burdon): Replace with useChatProcessor.
|
|
@@ -81,19 +80,19 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
81
80
|
}, [aiClient, tools, space, dispatch, artifactDefinitions]);
|
|
82
81
|
|
|
83
82
|
// Queue.
|
|
84
|
-
const [queueDxn, setQueueDxn] = useState<string>(() =>
|
|
83
|
+
const [queueDxn, setQueueDxn] = useState<string>(() => space.queues.create().dxn.toString());
|
|
85
84
|
const queue = useQueue<Message>(Type.DXN.tryParse(queueDxn));
|
|
86
85
|
|
|
87
86
|
useEffect(() => {
|
|
88
87
|
if (space) {
|
|
89
|
-
setQueueDxn(
|
|
88
|
+
setQueueDxn(space.queues.create().dxn.toString());
|
|
90
89
|
}
|
|
91
90
|
}, [space]);
|
|
92
91
|
|
|
93
92
|
useEffect(() => {
|
|
94
93
|
if (queue?.objects.length === 0 && !queue.isLoading && prompts.length > 0) {
|
|
95
|
-
queue.append([
|
|
96
|
-
|
|
94
|
+
void queue.append([
|
|
95
|
+
Obj.make(Message, {
|
|
97
96
|
role: 'assistant',
|
|
98
97
|
content: prompts.map(
|
|
99
98
|
(prompt) =>
|
|
@@ -130,7 +129,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
130
129
|
await processor.request(message, {
|
|
131
130
|
history: queue.objects,
|
|
132
131
|
onComplete: (messages) => {
|
|
133
|
-
queue.append(messages);
|
|
132
|
+
void queue.append(messages);
|
|
134
133
|
},
|
|
135
134
|
});
|
|
136
135
|
});
|
|
@@ -174,7 +173,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
174
173
|
iconOnly
|
|
175
174
|
label='Clear history'
|
|
176
175
|
icon='ph--trash--regular'
|
|
177
|
-
onClick={() => setQueueDxn(
|
|
176
|
+
onClick={() => setQueueDxn(space.queues.create().dxn.toString())}
|
|
178
177
|
/>
|
|
179
178
|
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
180
179
|
</Input.Root>
|
|
@@ -262,7 +261,7 @@ export const WithInitialItems: Story = {
|
|
|
262
261
|
args: {
|
|
263
262
|
debug: true,
|
|
264
263
|
items: [
|
|
265
|
-
|
|
264
|
+
Obj.make(ChessType, {
|
|
266
265
|
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
|
|
267
266
|
}),
|
|
268
267
|
],
|
|
@@ -275,7 +274,7 @@ const Fallback = ({ error }: { error?: Error }) => {
|
|
|
275
274
|
<div role='none' className='overflow-auto p-8 attention-surface grid place-items-center'>
|
|
276
275
|
<p
|
|
277
276
|
role='alert'
|
|
278
|
-
className={mx(descriptionMessage, 'break-words rounded-
|
|
277
|
+
className={mx(descriptionMessage, 'break-words rounded-md p-8', errorString.length < 256 && 'text-lg')}
|
|
279
278
|
>
|
|
280
279
|
{error ? errorString : 'error'}
|
|
281
280
|
</p>
|
|
@@ -6,9 +6,8 @@ import React, { useCallback, type FC, useEffect } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { type AssociatedArtifact } from '@dxos/artifact';
|
|
9
|
+
import { DXN, Ref } from '@dxos/echo';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { DXN } from '@dxos/keys';
|
|
11
|
-
import { refFromDXN } from '@dxos/live-object';
|
|
12
11
|
import { log } from '@dxos/log';
|
|
13
12
|
import { getSpace } from '@dxos/react-client/echo';
|
|
14
13
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -50,7 +49,7 @@ export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
|
50
49
|
void dispatch(
|
|
51
50
|
createIntent(CollaborationActions.InsertContent, {
|
|
52
51
|
target: associatedArtifact,
|
|
53
|
-
object:
|
|
52
|
+
object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
54
53
|
label: 'View proposal',
|
|
55
54
|
}),
|
|
56
55
|
);
|
|
@@ -72,7 +71,7 @@ export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
|
72
71
|
void processor.request(text, {
|
|
73
72
|
history: messageQueue.objects,
|
|
74
73
|
onComplete: (messages) => {
|
|
75
|
-
messageQueue.append(messages);
|
|
74
|
+
void messageQueue.append(messages);
|
|
76
75
|
},
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -27,8 +27,8 @@ export const messageReducer: Reducer<{ messages: Message[]; current?: Message },
|
|
|
27
27
|
id: [message.id, i].join('_'),
|
|
28
28
|
role: message.role,
|
|
29
29
|
content: [block],
|
|
30
|
-
};
|
|
31
|
-
messages.push(current);
|
|
30
|
+
} as any;
|
|
31
|
+
messages.push(current as any);
|
|
32
32
|
}
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
@@ -40,7 +40,7 @@ export const messageReducer: Reducer<{ messages: Message[]; current?: Message },
|
|
|
40
40
|
id: [message.id, i].join('_'),
|
|
41
41
|
role: message.role,
|
|
42
42
|
content: [block],
|
|
43
|
-
});
|
|
43
|
+
} as any);
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -16,6 +16,6 @@ export * from './Toolbox';
|
|
|
16
16
|
// Repro: open assistant dialog then close.
|
|
17
17
|
// https://github.com/microsoft/fluentui/issues/34020
|
|
18
18
|
export const AssistantDialog = lazy(() => import('./AssistantDialog'));
|
|
19
|
-
export const
|
|
19
|
+
export const BlueprintContainer = lazy(() => import('./BlueprintContainer'));
|
|
20
20
|
export const ChatContainer = lazy(() => import('./ChatContainer'));
|
|
21
21
|
export const TemplateContainer = lazy(() => import('./TemplateContainer'));
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Events } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { ASSISTANT_PLUGIN } from './meta';
|
|
8
|
+
|
|
9
|
+
export namespace AssistantEvents {
|
|
10
|
+
export const AiClientReady = Events.createStateEvent(`${ASSISTANT_PLUGIN}/ai-client-ready`);
|
|
11
|
+
}
|
package/src/hooks/processor.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_EDGE_MODEL,
|
|
9
9
|
type ExecutableTool,
|
|
10
|
-
type
|
|
10
|
+
type AiServiceClient,
|
|
11
11
|
type GenerateRequest,
|
|
12
12
|
type Message,
|
|
13
13
|
type MessageContentBlock,
|
|
@@ -86,7 +86,7 @@ export class ChatProcessor {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
constructor(
|
|
89
|
-
private readonly _ai:
|
|
89
|
+
private readonly _ai: AiServiceClient,
|
|
90
90
|
private _tools?: ExecutableTool[],
|
|
91
91
|
private _artifacts?: ArtifactDefinition[],
|
|
92
92
|
private readonly _extensions?: ToolContextExtensions,
|
|
@@ -177,7 +177,7 @@ export class ChatProcessor {
|
|
|
177
177
|
} catch (err) {
|
|
178
178
|
log.catch(err);
|
|
179
179
|
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
180
|
-
this.error.value = new
|
|
180
|
+
this.error.value = new AiServiceOverloadedError('AI service overloaded', { cause: err });
|
|
181
181
|
} else {
|
|
182
182
|
this.error.value = new Error('AI service error', { cause: err });
|
|
183
183
|
}
|
|
@@ -233,6 +233,6 @@ export class ChatProcessor {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
// TODO(wittjosiah): Move to ai-service-client.
|
|
236
|
-
export class
|
|
236
|
+
export class AiServiceOverloadedError extends Error {
|
|
237
237
|
code = 'AI_SERVICE_OVERLOADED';
|
|
238
238
|
}
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
-
import {
|
|
9
|
-
import { Obj, type Type } from '@dxos/echo';
|
|
10
|
-
import { getObjectDXN, getLabel } from '@dxos/echo-schema';
|
|
11
|
-
import { log } from '@dxos/log';
|
|
8
|
+
import { type Space } from '@dxos/client/echo';
|
|
9
|
+
import { Filter, Obj, type Type } from '@dxos/echo';
|
|
12
10
|
|
|
13
11
|
export type ContextProvider = {
|
|
14
12
|
query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
|
|
@@ -31,27 +29,26 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
|
|
|
31
29
|
const { objects } = await space.db
|
|
32
30
|
.query(Filter.or(...artifactSchemas.map((schema) => Filter.type(schema as Type.Schema))))
|
|
33
31
|
.run();
|
|
32
|
+
|
|
34
33
|
return (
|
|
35
34
|
objects
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
// TODO(burdon): Remove cast ??? (+ two instances below).
|
|
36
|
+
// .map((object) => {
|
|
37
|
+
// log.info('object', { object, label: Obj.getLabel(object as any) });
|
|
38
|
+
// return object;
|
|
39
|
+
// })
|
|
40
|
+
.filter((object) => stringMatch(query, Obj.getLabel(object as any) ?? ''))
|
|
41
41
|
// TODO(dmaretskyi): `Type.getDXN` (at the point of writing) didn't work here as it was schema-only.
|
|
42
|
-
.filter((object) => !!
|
|
42
|
+
.filter((object) => !!Obj.getDXN(object as Obj.Any))
|
|
43
43
|
.map((object) => ({
|
|
44
|
-
uri:
|
|
45
|
-
label:
|
|
44
|
+
uri: Obj.getDXN(object as any)!.toString(),
|
|
45
|
+
label: Obj.getLabel(object as any) ?? '',
|
|
46
46
|
}))
|
|
47
47
|
);
|
|
48
48
|
},
|
|
49
49
|
resolveMetadata: async ({ uri }) => {
|
|
50
50
|
const object = await space.db.query(Filter.ids(uri)).first();
|
|
51
|
-
return {
|
|
52
|
-
uri,
|
|
53
|
-
label: getLabel(Obj.getSchema(object)!, object) ?? '',
|
|
54
|
-
};
|
|
51
|
+
return { uri, label: Obj.getLabel(object) ?? '' };
|
|
55
52
|
},
|
|
56
53
|
};
|
|
57
54
|
}, [space, artifactDefinitions]);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Message } from '@dxos/ai';
|
|
8
|
-
import {
|
|
8
|
+
import { createQueueDXN } from '@dxos/echo-schema';
|
|
9
9
|
import { getSpace, useQueue } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
11
|
import { type AIChatType } from '../types';
|
|
@@ -13,8 +13,9 @@ import { type AIChatType } from '../types';
|
|
|
13
13
|
export const useMessageQueue = (chat?: AIChatType) => {
|
|
14
14
|
const space = getSpace(chat);
|
|
15
15
|
const queueDxn = useMemo(() => {
|
|
16
|
+
// TODO(dmaretskyi): Chat.queue.dxn should be a valid DXN already.
|
|
16
17
|
const dxn = space && chat?.queue.dxn;
|
|
17
|
-
return dxn ?
|
|
18
|
+
return dxn ? createQueueDXN(space.id, dxn.parts.at(-1)) : undefined;
|
|
18
19
|
}, [space, chat?.queue.dxn]);
|
|
19
20
|
|
|
20
21
|
return useQueue<Message>(queueDxn);
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Blueprint, type BlueprintEvent, type BlueprintLogger } from '@dxos/assistant';
|
|
6
|
+
import { getSpace, Ref, type Queue, type Space } from '@dxos/client/echo';
|
|
7
|
+
import { DXN, Key, Obj } from '@dxos/echo';
|
|
8
|
+
import {
|
|
9
|
+
InvocationOutcome,
|
|
10
|
+
InvocationTraceEndEvent,
|
|
11
|
+
InvocationTraceEventType,
|
|
12
|
+
InvocationTraceStartEvent,
|
|
13
|
+
TraceEvent,
|
|
14
|
+
type InvocationTraceEvent,
|
|
15
|
+
} from '@dxos/functions';
|
|
16
|
+
import { invariant } from '@dxos/invariant';
|
|
17
|
+
import { QueueSubspaceTags } from '@dxos/keys';
|
|
18
|
+
|
|
19
|
+
export class QueueLogger implements BlueprintLogger {
|
|
20
|
+
private _space: Space;
|
|
21
|
+
private _invocationTraceQueue: Queue<InvocationTraceEvent>;
|
|
22
|
+
|
|
23
|
+
constructor(private readonly blueprint: Blueprint) {
|
|
24
|
+
const space = getSpace(blueprint);
|
|
25
|
+
invariant(space, 'Space not found');
|
|
26
|
+
this._space = space;
|
|
27
|
+
let dxn = this._space.properties.invocationTraceQueue?.dxn;
|
|
28
|
+
if (!dxn) {
|
|
29
|
+
dxn = DXN.fromQueue(QueueSubspaceTags.TRACE, this._space.id, Key.ObjectId.random());
|
|
30
|
+
this._space.properties.invocationTraceQueue = Ref.fromDXN(dxn);
|
|
31
|
+
}
|
|
32
|
+
this._invocationTraceQueue = this._space.queues.get(dxn);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
log(event: BlueprintEvent) {
|
|
36
|
+
switch (event.type) {
|
|
37
|
+
case 'begin':
|
|
38
|
+
void this._invocationTraceQueue.append([
|
|
39
|
+
Obj.make(InvocationTraceStartEvent, {
|
|
40
|
+
type: InvocationTraceEventType.START,
|
|
41
|
+
invocationId: event.invocationId,
|
|
42
|
+
timestampMs: Date.now(),
|
|
43
|
+
input: {},
|
|
44
|
+
invocationTraceQueue: Ref.fromDXN(this._getTraceQueueDxn(event.invocationId)),
|
|
45
|
+
invocationTarget: Ref.make(this.blueprint),
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
break;
|
|
49
|
+
case 'end':
|
|
50
|
+
void this._invocationTraceQueue.append([
|
|
51
|
+
Obj.make(InvocationTraceEndEvent, {
|
|
52
|
+
type: InvocationTraceEventType.END,
|
|
53
|
+
invocationId: event.invocationId,
|
|
54
|
+
timestampMs: Date.now(),
|
|
55
|
+
outcome: InvocationOutcome.SUCCESS,
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
break;
|
|
59
|
+
case 'step-start':
|
|
60
|
+
case 'step-complete':
|
|
61
|
+
void this._getTraceEventQueue(event.invocationId).append([
|
|
62
|
+
Obj.make(TraceEvent, {
|
|
63
|
+
outcome: event.type,
|
|
64
|
+
truncated: false,
|
|
65
|
+
ingestionTimestampMs: Date.now(),
|
|
66
|
+
logs: [
|
|
67
|
+
{
|
|
68
|
+
timestampMs: Date.now(),
|
|
69
|
+
level: 'info',
|
|
70
|
+
message: event.type,
|
|
71
|
+
context: { step: event.step },
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
exceptions: [],
|
|
75
|
+
}),
|
|
76
|
+
]);
|
|
77
|
+
break;
|
|
78
|
+
case 'message':
|
|
79
|
+
void this._getTraceEventQueue(event.invocationId).append([
|
|
80
|
+
Obj.make(TraceEvent, {
|
|
81
|
+
outcome: event.type,
|
|
82
|
+
truncated: false,
|
|
83
|
+
ingestionTimestampMs: Date.now(),
|
|
84
|
+
logs: [
|
|
85
|
+
{
|
|
86
|
+
timestampMs: Date.now(),
|
|
87
|
+
level: 'info',
|
|
88
|
+
message: event.type,
|
|
89
|
+
context: { message: event.message },
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
exceptions: [],
|
|
93
|
+
}),
|
|
94
|
+
]);
|
|
95
|
+
break;
|
|
96
|
+
case 'block':
|
|
97
|
+
void this._getTraceEventQueue(event.invocationId).append([
|
|
98
|
+
Obj.make(TraceEvent, {
|
|
99
|
+
outcome: event.type,
|
|
100
|
+
truncated: false,
|
|
101
|
+
ingestionTimestampMs: Date.now(),
|
|
102
|
+
logs: [
|
|
103
|
+
{
|
|
104
|
+
timestampMs: Date.now(),
|
|
105
|
+
level: 'info',
|
|
106
|
+
message: event.type,
|
|
107
|
+
context: { block: event.block },
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
exceptions: [],
|
|
111
|
+
}),
|
|
112
|
+
]);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private _getTraceQueueDxn(invocationId: string): DXN {
|
|
118
|
+
return DXN.fromQueue(QueueSubspaceTags.TRACE, this._space.id, invocationId);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private _getTraceEventQueue(invocationId: string): Queue<TraceEvent> {
|
|
122
|
+
const dxn = this._getTraceQueueDxn(invocationId);
|
|
123
|
+
return this._space.queues.get(dxn);
|
|
124
|
+
}
|
|
125
|
+
}
|