@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
|
@@ -8,18 +8,16 @@ import { type Meta, type StoryObj } from '@storybook/react';
|
|
|
8
8
|
import { Match, Schema } from 'effect';
|
|
9
9
|
import React, { useCallback, useEffect, useMemo, useRef, useState, type FC } from 'react';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { EdgeAiServiceClient, type AiServiceEdgeClientOptions } from '@dxos/ai';
|
|
12
|
+
import { SpyAiService } from '@dxos/ai/testing';
|
|
13
13
|
import { Events } from '@dxos/app-framework';
|
|
14
14
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
15
15
|
import { localServiceEndpoints, remoteServiceEndpoints } from '@dxos/artifact-testing';
|
|
16
|
-
import { BlueprintMachine, BlueprintParser,
|
|
16
|
+
import { BlueprintMachine, BlueprintParser, BufferedLogger, setConsolePrinter, setLogger } from '@dxos/assistant';
|
|
17
17
|
import { combine } from '@dxos/async';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { Ref, create, getLabelForObject, getTypename, type AnyEchoObject } from '@dxos/echo-schema';
|
|
18
|
+
import { Queue, type Space } from '@dxos/client/echo';
|
|
19
|
+
import { DXN, Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
21
20
|
import { SelectionModel } from '@dxos/graph';
|
|
22
|
-
import { DXN } from '@dxos/keys';
|
|
23
21
|
import { log } from '@dxos/log';
|
|
24
22
|
import { D3ForceGraph, type D3ForceGraphProps } from '@dxos/plugin-explorer';
|
|
25
23
|
import { faker } from '@dxos/random';
|
|
@@ -28,8 +26,8 @@ import { useQueue } from '@dxos/react-client/echo';
|
|
|
28
26
|
import { Dialog, IconButton, Toolbar, useAsyncState, useTranslation } from '@dxos/react-ui';
|
|
29
27
|
import {
|
|
30
28
|
matchCompletion,
|
|
31
|
-
staticCompletion,
|
|
32
29
|
typeahead,
|
|
30
|
+
staticCompletion,
|
|
33
31
|
type TypeaheadContext,
|
|
34
32
|
type TypeaheadOptions,
|
|
35
33
|
} from '@dxos/react-ui-editor';
|
|
@@ -45,7 +43,7 @@ import { testPlugins } from './testing';
|
|
|
45
43
|
import { AmbientDialog, PromptBar, type PromptBarProps, type PromptController } from '../components';
|
|
46
44
|
import { ASSISTANT_PLUGIN } from '../meta';
|
|
47
45
|
import { QueryParser, createFilter, type Expression } from '../parser';
|
|
48
|
-
import {
|
|
46
|
+
import { createToolRegistry, RESEARCH_BLUEPRINT } from '../testing';
|
|
49
47
|
import translations from '../translations';
|
|
50
48
|
|
|
51
49
|
faker.seed(1);
|
|
@@ -57,7 +55,7 @@ const LOCAL = false;
|
|
|
57
55
|
const endpoints = LOCAL ? localServiceEndpoints : remoteServiceEndpoints;
|
|
58
56
|
|
|
59
57
|
// TODO(burdon) Move to story args.
|
|
60
|
-
const aiConfig:
|
|
58
|
+
const aiConfig: AiServiceEdgeClientOptions = {
|
|
61
59
|
endpoint: endpoints.ai,
|
|
62
60
|
defaultGenerationOptions: {
|
|
63
61
|
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
@@ -69,7 +67,7 @@ const aiConfig: AIServiceEdgeClientOptions = {
|
|
|
69
67
|
* Container for a set of ephemeral research results.
|
|
70
68
|
*/
|
|
71
69
|
const ResearchGraph = Schema.Struct({
|
|
72
|
-
queue: Ref(Queue),
|
|
70
|
+
queue: Type.Ref(Queue),
|
|
73
71
|
}).pipe(
|
|
74
72
|
Type.Obj({
|
|
75
73
|
typename: 'dxos.org/type/ResearchGraph',
|
|
@@ -130,8 +128,7 @@ const DefaultStory = ({ mode, spec, ...props }: StoryProps) => {
|
|
|
130
128
|
} else {
|
|
131
129
|
const queue = space.queues.create();
|
|
132
130
|
return space.db.add(
|
|
133
|
-
|
|
134
|
-
// TODO(dmaretskyi): Ref.make(queue)
|
|
131
|
+
Obj.make(ResearchGraph, {
|
|
135
132
|
queue: Ref.fromDXN(queue.dxn),
|
|
136
133
|
}),
|
|
137
134
|
);
|
|
@@ -159,21 +156,21 @@ const DefaultStory = ({ mode, spec, ...props }: StoryProps) => {
|
|
|
159
156
|
model?.nodes
|
|
160
157
|
.filter((node) => {
|
|
161
158
|
try {
|
|
162
|
-
getTypename(node.data.object as
|
|
159
|
+
Obj.getTypename(node.data.object as Obj.Any);
|
|
163
160
|
return true;
|
|
164
161
|
} catch {
|
|
165
162
|
return false;
|
|
166
163
|
}
|
|
167
164
|
})
|
|
168
|
-
.map((node) => node.data.object as
|
|
165
|
+
.map((node) => node.data.object as Obj.Any) ?? [];
|
|
169
166
|
|
|
170
167
|
//
|
|
171
168
|
// AI
|
|
172
169
|
//
|
|
173
170
|
|
|
174
|
-
const aiClient = useMemo(() => new
|
|
175
|
-
const
|
|
176
|
-
() => space && researchGraph &&
|
|
171
|
+
const aiClient = useMemo(() => new SpyAiService(new EdgeAiServiceClient(aiConfig)), []);
|
|
172
|
+
const tools = useMemo(
|
|
173
|
+
() => space && researchGraph && createToolRegistry(space, researchGraph.queue.dxn),
|
|
177
174
|
[space, researchGraph?.queue.dxn],
|
|
178
175
|
);
|
|
179
176
|
|
|
@@ -181,7 +178,7 @@ const DefaultStory = ({ mode, spec, ...props }: StoryProps) => {
|
|
|
181
178
|
|
|
182
179
|
const researchBlueprint = useMemo(() => BlueprintParser.create().parse(RESEARCH_BLUEPRINT), []);
|
|
183
180
|
|
|
184
|
-
const logger = useMemo(() => new
|
|
181
|
+
const logger = useMemo(() => new BufferedLogger(), []);
|
|
185
182
|
|
|
186
183
|
//
|
|
187
184
|
// Handlers
|
|
@@ -192,27 +189,27 @@ const DefaultStory = ({ mode, spec, ...props }: StoryProps) => {
|
|
|
192
189
|
}, [model]);
|
|
193
190
|
|
|
194
191
|
const handleResearch = useCallback(async () => {
|
|
195
|
-
if (!space || !
|
|
192
|
+
if (!space || !tools || !researchBlueprint) {
|
|
196
193
|
return;
|
|
197
194
|
}
|
|
198
195
|
|
|
199
|
-
const selected = selection.selected.value;
|
|
200
|
-
log.info('starting research...', { selected });
|
|
201
196
|
const resolver = space.db.graph.createRefResolver({
|
|
202
197
|
context: {
|
|
203
198
|
space: space.db.spaceId,
|
|
204
199
|
queue: researchGraph?.queue.dxn,
|
|
205
200
|
},
|
|
206
201
|
});
|
|
202
|
+
|
|
203
|
+
const selected = selection.selected.value;
|
|
207
204
|
const objects = await Promise.all(selected.map((id) => resolver.resolve(DXN.fromLocalObjectId(id))));
|
|
208
|
-
const machine = new BlueprintMachine(
|
|
205
|
+
const machine = new BlueprintMachine(tools, researchBlueprint);
|
|
209
206
|
const cleanup = combine(setConsolePrinter(machine, true), setLogger(machine, logger));
|
|
210
207
|
|
|
211
208
|
log.info('starting research...', { selected });
|
|
212
|
-
await machine.runToCompletion({
|
|
209
|
+
await machine.runToCompletion({ aiClient, input: objects });
|
|
213
210
|
|
|
214
211
|
cleanup();
|
|
215
|
-
}, [space, aiClient,
|
|
212
|
+
}, [space, aiClient, tools, researchBlueprint, selection]);
|
|
216
213
|
|
|
217
214
|
const handleGenerate = useCallback(async () => {
|
|
218
215
|
if (!space) {
|
|
@@ -392,10 +389,12 @@ const ItemList = <T extends Obj.Any>({ items = [] }: { items?: T[] }) => {
|
|
|
392
389
|
classNames='grid grid-cols-[4rem_16rem_1fr] min-h-[32px] items-center'
|
|
393
390
|
>
|
|
394
391
|
<div className='text-xs font-mono font-thin px-1 text-subdued'>{item.id.slice(-6)}</div>
|
|
395
|
-
<div
|
|
396
|
-
{getTypename(item)}
|
|
392
|
+
<div
|
|
393
|
+
className={mx('text-xs font-mono font-thin truncate px-1', getHashColor(Obj.getTypename(item))?.text)}
|
|
394
|
+
>
|
|
395
|
+
{Obj.getTypename(item)}
|
|
397
396
|
</div>
|
|
398
|
-
<List.ItemTitle>{
|
|
397
|
+
<List.ItemTitle>{Obj.getLabel(item)}</List.ItemTitle>
|
|
399
398
|
</List.Item>
|
|
400
399
|
))}
|
|
401
400
|
</div>
|
|
@@ -432,7 +431,7 @@ const useFlush = (space?: Space) => {
|
|
|
432
431
|
return { state, handleFlush };
|
|
433
432
|
};
|
|
434
433
|
|
|
435
|
-
const Log: FC<{ logger:
|
|
434
|
+
const Log: FC<{ logger: BufferedLogger }> = ({ logger }) => {
|
|
436
435
|
return (
|
|
437
436
|
<div className='grow flex flex-col p-1 overflow-y-auto text-sm'>
|
|
438
437
|
{logger.messages.value.map((message, index) => (
|
|
@@ -9,45 +9,31 @@ import { type Meta, type StoryObj } from '@storybook/react';
|
|
|
9
9
|
import { Option, SchemaAST } from 'effect';
|
|
10
10
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
11
11
|
|
|
12
|
-
import { AgentStatusReport,
|
|
13
|
-
import { EXA_API_KEY,
|
|
12
|
+
import { AgentStatusReport, EdgeAiServiceClient, createTool, type ExecutableTool, Message, ToolResult } from '@dxos/ai';
|
|
13
|
+
import { EXA_API_KEY, SpyAiService } from '@dxos/ai/testing';
|
|
14
14
|
import { Capabilities, contributes, createSurface, Events, Surface, useIntentDispatcher } from '@dxos/app-framework';
|
|
15
15
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
16
16
|
import { localServiceEndpoints, remoteServiceEndpoints } from '@dxos/artifact-testing';
|
|
17
17
|
import { findRelatedSchema, researchFn, type RelatedSchema } from '@dxos/assistant';
|
|
18
18
|
import { raise } from '@dxos/debug';
|
|
19
|
-
import { Type,
|
|
20
|
-
import {
|
|
21
|
-
ATTR_RELATION_SOURCE,
|
|
22
|
-
ATTR_RELATION_TARGET,
|
|
23
|
-
create,
|
|
24
|
-
createQueueDxn,
|
|
25
|
-
getSchema,
|
|
26
|
-
getSchemaDXN,
|
|
27
|
-
getTypename,
|
|
28
|
-
isInstanceOf,
|
|
29
|
-
toJsonSchema,
|
|
30
|
-
type BaseObject,
|
|
31
|
-
Filter,
|
|
32
|
-
RelationSourceId,
|
|
33
|
-
RelationTargetId,
|
|
34
|
-
} from '@dxos/echo-schema';
|
|
19
|
+
import { Type, Filter, Obj, Relation } from '@dxos/echo';
|
|
20
|
+
import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET } from '@dxos/echo-schema';
|
|
35
21
|
import { ConfiguredCredentialsService, FunctionExecutor, ServiceContainer, TracingService } from '@dxos/functions';
|
|
36
22
|
import { invariant } from '@dxos/invariant';
|
|
37
23
|
import { log } from '@dxos/log';
|
|
38
24
|
import { ForceGraph, useGraphModel } from '@dxos/plugin-explorer';
|
|
39
25
|
import { useClient } from '@dxos/react-client';
|
|
40
|
-
import { getSpace,
|
|
26
|
+
import { getSpace, useQuery, useQueue, type EchoDatabase, type Live } from '@dxos/react-client/echo';
|
|
41
27
|
import { IconButton, Input, Toolbar, useAsyncState } from '@dxos/react-ui';
|
|
42
28
|
import {
|
|
43
29
|
createMenuAction,
|
|
44
30
|
createMenuItemGroup,
|
|
45
|
-
|
|
46
|
-
ToolbarMenu,
|
|
31
|
+
rxFromSignal,
|
|
47
32
|
useMenuActions,
|
|
48
33
|
type ActionGraphProps,
|
|
34
|
+
MenuProvider,
|
|
35
|
+
ToolbarMenu,
|
|
49
36
|
type ToolbarMenuActionGroupProperties,
|
|
50
|
-
rxFromSignal,
|
|
51
37
|
} from '@dxos/react-ui-menu';
|
|
52
38
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
53
39
|
import { mx } from '@dxos/react-ui-theme';
|
|
@@ -73,11 +59,10 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
73
59
|
const [, forceUpdate] = useState({});
|
|
74
60
|
|
|
75
61
|
const client = useClient();
|
|
76
|
-
|
|
77
|
-
const [aiClient] = useState(
|
|
62
|
+
const aiClient = useMemo(
|
|
78
63
|
() =>
|
|
79
|
-
new
|
|
80
|
-
new
|
|
64
|
+
new SpyAiService(
|
|
65
|
+
new EdgeAiServiceClient({
|
|
81
66
|
endpoint: endpoints.ai,
|
|
82
67
|
defaultGenerationOptions: {
|
|
83
68
|
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
@@ -85,6 +70,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
85
70
|
},
|
|
86
71
|
}),
|
|
87
72
|
),
|
|
73
|
+
[],
|
|
88
74
|
);
|
|
89
75
|
|
|
90
76
|
const space = client.spaces.default;
|
|
@@ -94,7 +80,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
94
80
|
const menuProps = useMenuActions(actionCreator);
|
|
95
81
|
|
|
96
82
|
// Queue.
|
|
97
|
-
const [queueDxn, setQueueDxn] = useState<string>(() =>
|
|
83
|
+
const [queueDxn, setQueueDxn] = useState<string>(() => space.queues.create().dxn.toString());
|
|
98
84
|
const queue = useQueue<Message>(Type.DXN.tryParse(queueDxn));
|
|
99
85
|
|
|
100
86
|
// Function executor.
|
|
@@ -147,8 +133,8 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
147
133
|
|
|
148
134
|
useEffect(() => {
|
|
149
135
|
if (queue?.objects.length === 0 && !queue.isLoading && prompts.length > 0) {
|
|
150
|
-
queue.append([
|
|
151
|
-
|
|
136
|
+
void queue.append([
|
|
137
|
+
Obj.make(Message, {
|
|
152
138
|
role: 'assistant',
|
|
153
139
|
content: prompts.map(
|
|
154
140
|
(prompt) =>
|
|
@@ -166,7 +152,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
166
152
|
// State.
|
|
167
153
|
const objects = useQuery(space, Filter.or(...DataTypes.map((type) => Filter.type(type))));
|
|
168
154
|
const messages = [
|
|
169
|
-
...(queue?.objects.filter((item) =>
|
|
155
|
+
...(queue?.objects.filter((item) => Obj.instanceOf(Message, item)) ?? []),
|
|
170
156
|
...(processor?.messages.value ?? []),
|
|
171
157
|
];
|
|
172
158
|
|
|
@@ -185,7 +171,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
185
171
|
await processor.request(message, {
|
|
186
172
|
history: queue.objects,
|
|
187
173
|
onComplete: (messages) => {
|
|
188
|
-
queue.append(messages);
|
|
174
|
+
void queue.append(messages);
|
|
189
175
|
},
|
|
190
176
|
});
|
|
191
177
|
});
|
|
@@ -210,20 +196,20 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
210
196
|
);
|
|
211
197
|
|
|
212
198
|
// TODO(dmaretskyi): Pull in relations automatically.
|
|
213
|
-
const handleAddToGraph = useCallback(async (object:
|
|
199
|
+
const handleAddToGraph = useCallback(async (object: Obj.Any) => {
|
|
214
200
|
space.db.add(instantiate(space.db, object));
|
|
215
201
|
await space.db.flush({ indexes: true });
|
|
216
202
|
forceUpdate({});
|
|
217
203
|
}, []);
|
|
218
204
|
|
|
219
|
-
const handleResearchMore = useCallback((object:
|
|
205
|
+
const handleResearchMore = useCallback((object: Obj.Any | Relation.Any, relatedSchema: RelatedSchema) => {
|
|
220
206
|
const prompt = `
|
|
221
207
|
Research more about objects related to the object in terms of the by the specific relation schema:
|
|
222
208
|
<object>${JSON.stringify(object, null, 2)}</object>
|
|
223
209
|
<schema>
|
|
224
210
|
<description>${SchemaAST.getDescriptionAnnotation(relatedSchema.schema.ast).pipe(Option.getOrElse(() => ''))}</description>
|
|
225
211
|
<json>
|
|
226
|
-
${JSON.stringify(toJsonSchema(relatedSchema.schema), null, 2)}
|
|
212
|
+
${JSON.stringify(Type.toJsonSchema(relatedSchema.schema), null, 2)}
|
|
227
213
|
</json>
|
|
228
214
|
</schema>
|
|
229
215
|
`;
|
|
@@ -254,7 +240,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
254
240
|
iconOnly
|
|
255
241
|
label='Clear history'
|
|
256
242
|
icon='ph--trash--regular'
|
|
257
|
-
onClick={() => setQueueDxn(
|
|
243
|
+
onClick={() => setQueueDxn(space.queues.create().dxn.toString())}
|
|
258
244
|
/>
|
|
259
245
|
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
260
246
|
</Input.Root>
|
|
@@ -308,20 +294,20 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
308
294
|
};
|
|
309
295
|
|
|
310
296
|
type ResearchPromptsProps = {
|
|
311
|
-
object:
|
|
312
|
-
onResearch: (object:
|
|
297
|
+
object: Obj.Any | Relation.Any;
|
|
298
|
+
onResearch: (object: Obj.Any | Relation.Any, relatedSchema: RelatedSchema) => void;
|
|
313
299
|
};
|
|
314
300
|
|
|
315
301
|
const ResearchPrompts = ({ object, onResearch }: ResearchPromptsProps) => {
|
|
316
302
|
const [relatedSchemas = []] = useAsyncState(
|
|
317
|
-
async () => findRelatedSchema(getSpace(object)!.db, getSchema(object)!),
|
|
303
|
+
async () => findRelatedSchema(getSpace(object)!.db, Obj.getSchema(object)!),
|
|
318
304
|
[object],
|
|
319
305
|
);
|
|
320
306
|
return (
|
|
321
307
|
<div>
|
|
322
308
|
{relatedSchemas.map((schema) => (
|
|
323
309
|
<button
|
|
324
|
-
key={
|
|
310
|
+
key={Type.getDXN(schema.schema)?.toString()}
|
|
325
311
|
onClick={() => onResearch(object, schema)}
|
|
326
312
|
className='border border-separator rounded px-2 py-1 m-1'
|
|
327
313
|
>
|
|
@@ -342,7 +328,7 @@ const createResearchTool = (serviceContainer: ServiceContainer, name: string, fn
|
|
|
342
328
|
serviceContainer.clone().setServices({
|
|
343
329
|
tracing: {
|
|
344
330
|
write: (event) => {
|
|
345
|
-
if (
|
|
331
|
+
if (Obj.instanceOf(AgentStatusReport, event)) {
|
|
346
332
|
log.info('[too] report status', { status: event });
|
|
347
333
|
reportStatus?.(event);
|
|
348
334
|
}
|
|
@@ -352,7 +338,7 @@ const createResearchTool = (serviceContainer: ServiceContainer, name: string, fn
|
|
|
352
338
|
);
|
|
353
339
|
|
|
354
340
|
reportStatus?.(
|
|
355
|
-
|
|
341
|
+
Obj.make(AgentStatusReport, {
|
|
356
342
|
message: 'Researching...',
|
|
357
343
|
}),
|
|
358
344
|
);
|
|
@@ -382,7 +368,7 @@ const createResearchTool = (serviceContainer: ServiceContainer, name: string, fn
|
|
|
382
368
|
// TODO(dmaretskyi): Move into core.
|
|
383
369
|
const instantiate = (db: EchoDatabase, object: unknown): Live<any> => {
|
|
384
370
|
const schema =
|
|
385
|
-
db.graph.schemaRegistry.getSchemaByDXN(Type.DXN.parse(getTypename(object as any)!)) ??
|
|
371
|
+
db.graph.schemaRegistry.getSchemaByDXN(Type.DXN.parse(Obj.getTypename(object as any)!)) ??
|
|
386
372
|
raise(new Error('Schema not found'));
|
|
387
373
|
|
|
388
374
|
let { id, [ATTR_RELATION_SOURCE]: source, [ATTR_RELATION_TARGET]: target, ...props } = object as any;
|
|
@@ -393,15 +379,15 @@ const instantiate = (db: EchoDatabase, object: unknown): Live<any> => {
|
|
|
393
379
|
target = db.getObjectById(Type.DXN.parse(target).asEchoDXN()!.echoId) ?? raise(new Error('Target not found'));
|
|
394
380
|
}
|
|
395
381
|
|
|
396
|
-
return
|
|
382
|
+
return Relation.make(schema, {
|
|
397
383
|
id,
|
|
384
|
+
[Relation.Source]: source,
|
|
385
|
+
[Relation.Target]: target,
|
|
398
386
|
...props,
|
|
399
|
-
[RelationSourceId]: source,
|
|
400
|
-
[RelationTargetId]: target,
|
|
401
387
|
});
|
|
402
388
|
};
|
|
403
389
|
|
|
404
|
-
const createToolbar = (aiClient:
|
|
390
|
+
const createToolbar = (aiClient: SpyAiService) =>
|
|
405
391
|
Rx.make((get) => {
|
|
406
392
|
const result: ActionGraphProps = { nodes: [], edges: [] };
|
|
407
393
|
const save = createMenuAction('save', () => aiClient.saveEvents(), {
|
package/src/stories/test-data.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Live, type Space } from '@dxos/client/echo';
|
|
6
|
-
import {
|
|
6
|
+
import { Obj, Type, Relation } from '@dxos/echo';
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { DataType } from '@dxos/schema';
|
|
9
9
|
|
|
10
|
-
const organizations: DataType.Organization[] = [
|
|
10
|
+
const organizations: (Type.Properties<DataType.Organization> & { id: string })[] = [
|
|
11
11
|
{ id: 'dxos', name: 'DXOS', website: 'https://dxos.org' },
|
|
12
12
|
{ id: 'socket_supply', name: 'Socket Supply', website: 'https://socketsupply.com' },
|
|
13
13
|
{ id: 'ink_and_switch', name: 'Ink & Switch', website: 'https://inkandswitch.com' },
|
|
@@ -24,7 +24,7 @@ const organizations: DataType.Organization[] = [
|
|
|
24
24
|
{ id: 'deshaw', name: 'D. E. Shaw & Co.', website: 'https://deshaw.com' },
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
-
const people: DataType.Person[] = [
|
|
27
|
+
const people: (Type.Properties<DataType.Person> & { id: string })[] = [
|
|
28
28
|
{ id: 'rich_burdon', fullName: 'Rich Burdon' },
|
|
29
29
|
{ id: 'josiah_witt', fullName: 'Josiah Witt' },
|
|
30
30
|
{ id: 'dima_dmaretskyi', fullName: 'Dima Maretskyi' },
|
|
@@ -41,8 +41,8 @@ const people: DataType.Person[] = [
|
|
|
41
41
|
];
|
|
42
42
|
|
|
43
43
|
const testObjects: Record<string, any[]> = {
|
|
44
|
-
[
|
|
45
|
-
[
|
|
44
|
+
[Type.getTypename(DataType.Organization)!]: organizations,
|
|
45
|
+
[Type.getTypename(DataType.Person)!]: people,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const testRelationships: Record<
|
|
@@ -52,7 +52,7 @@ const testRelationships: Record<
|
|
|
52
52
|
target: string;
|
|
53
53
|
} & Record<string, any>)[]
|
|
54
54
|
> = {
|
|
55
|
-
[
|
|
55
|
+
[Type.getTypename(DataType.Employer)!]: [
|
|
56
56
|
// @eslint-disable-next-line
|
|
57
57
|
{ source: 'rich_burdon', target: 'dxos' },
|
|
58
58
|
{ source: 'rich_burdon', target: 'google', active: false }, // TODO(burdon): Should not contribute to force.
|
|
@@ -75,7 +75,7 @@ const testRelationships: Record<
|
|
|
75
75
|
],
|
|
76
76
|
|
|
77
77
|
// TODO(burdon): Limit graph view to selected relationship types.
|
|
78
|
-
[
|
|
78
|
+
[Type.getTypename(DataType.HasConnection)!]: [
|
|
79
79
|
//
|
|
80
80
|
{ kind: 'partner', source: 'dxos', target: 'ink_and_switch' },
|
|
81
81
|
{ kind: 'partner', source: 'dxos', target: 'effectful' },
|
|
@@ -100,7 +100,7 @@ export const addTestData = async (space: Space): Promise<void> => {
|
|
|
100
100
|
const schema = space.db.graph.schemaRegistry.getSchema(typename);
|
|
101
101
|
invariant(schema, `Schema not found: ${typename}`);
|
|
102
102
|
for (const { id, ...data } of objects) {
|
|
103
|
-
const object = space.db.add(
|
|
103
|
+
const object = space.db.add(Obj.make(schema, data));
|
|
104
104
|
objectMap.set(id, object);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -116,11 +116,11 @@ export const addTestData = async (space: Space): Promise<void> => {
|
|
|
116
116
|
invariant(targetObject, `Target object not found: ${target}`);
|
|
117
117
|
|
|
118
118
|
space.db.add(
|
|
119
|
-
|
|
120
|
-
...data,
|
|
119
|
+
Relation.make(schema, {
|
|
121
120
|
// TODO(burdon): Test source/target types match.
|
|
122
|
-
[
|
|
123
|
-
[
|
|
121
|
+
[Relation.Source]: sourceObject,
|
|
122
|
+
[Relation.Target]: targetObject,
|
|
123
|
+
...data,
|
|
124
124
|
}),
|
|
125
125
|
);
|
|
126
126
|
}
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { ToolRegistry } from '@dxos/ai';
|
|
6
6
|
import { EXA_API_KEY } from '@dxos/ai/testing';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
type BlueprintDefinition,
|
|
9
|
+
BlueprintParser,
|
|
10
|
+
createExaTool,
|
|
11
|
+
createGraphWriterTool,
|
|
12
|
+
createLocalSearchTool,
|
|
13
|
+
} from '@dxos/assistant';
|
|
8
14
|
import { type Space } from '@dxos/client/echo';
|
|
9
15
|
import { type DXN } from '@dxos/keys';
|
|
10
16
|
import { DataTypes } from '@dxos/schema';
|
|
@@ -12,7 +18,7 @@ import { isNonNullable } from '@dxos/util';
|
|
|
12
18
|
|
|
13
19
|
// TODO(dmaretskyi): make db available through services (same as function executor).
|
|
14
20
|
// TODO(burdon): Can tools implement "aspects" so that variants can be used rather than an explicit reference?
|
|
15
|
-
export const
|
|
21
|
+
export const createToolRegistry = (space: Space, queueDxn?: DXN): ToolRegistry => {
|
|
16
22
|
return new ToolRegistry(
|
|
17
23
|
[
|
|
18
24
|
createExaTool({ apiKey: EXA_API_KEY }),
|
|
@@ -21,17 +27,17 @@ export const createRegistry = (space: Space, queueDxn?: DXN): ToolRegistry => {
|
|
|
21
27
|
createGraphWriterTool({
|
|
22
28
|
db: space.db,
|
|
23
29
|
queue: space.queues.get(queueDxn),
|
|
24
|
-
|
|
30
|
+
schema: DataTypes,
|
|
25
31
|
onDone: async (objects) => {
|
|
26
32
|
const queue = space.queues.get(queueDxn);
|
|
27
|
-
queue.append(objects);
|
|
33
|
+
await queue.append(objects);
|
|
28
34
|
},
|
|
29
35
|
}),
|
|
30
36
|
].filter(isNonNullable),
|
|
31
37
|
);
|
|
32
38
|
};
|
|
33
39
|
|
|
34
|
-
export const
|
|
40
|
+
export const RESEARCH_BLUEPRINT_DEFINITION: BlueprintDefinition = {
|
|
35
41
|
steps: [
|
|
36
42
|
{
|
|
37
43
|
instructions: 'Research information and entities related to the selected objects.',
|
|
@@ -47,4 +53,6 @@ export const RESEARCH_BLUEPRINT = BlueprintParser.create().parse({
|
|
|
47
53
|
tools: ['search/local_search', 'graph/writer'],
|
|
48
54
|
},
|
|
49
55
|
],
|
|
50
|
-
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const RESEARCH_BLUEPRINT = BlueprintParser.create().parse(RESEARCH_BLUEPRINT_DEFINITION);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Obj } from '@dxos/echo';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
type ApiAuthorization,
|
|
@@ -54,7 +54,7 @@ const VISUAL_CROSSING_CREDENTIALS: ApiAuthorization = {
|
|
|
54
54
|
// - e.g., https://github.com/konfig-sdks/openapi-examples/blob/main/xkcd/openapi.yaml
|
|
55
55
|
|
|
56
56
|
const TEST_SERVICES: ServiceType[] = [
|
|
57
|
-
|
|
57
|
+
Obj.make(ServiceType, {
|
|
58
58
|
serviceId: 'amadeus.com/service/FlightSearch',
|
|
59
59
|
name: 'Amadeus Flight Search',
|
|
60
60
|
description: 'Search for local and international flights.',
|
|
@@ -68,7 +68,7 @@ const TEST_SERVICES: ServiceType[] = [
|
|
|
68
68
|
],
|
|
69
69
|
}),
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Obj.make(ServiceType, {
|
|
72
72
|
serviceId: 'amadeus.com/service/HotelSearch',
|
|
73
73
|
name: 'Amadeus Hotel Search',
|
|
74
74
|
description: 'Search for local and international hotels.',
|
|
@@ -82,7 +82,7 @@ const TEST_SERVICES: ServiceType[] = [
|
|
|
82
82
|
],
|
|
83
83
|
}),
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
Obj.make(ServiceType, {
|
|
86
86
|
serviceId: 'visualcrossing.com/service/Weather',
|
|
87
87
|
name: 'Visual Crossing Weather',
|
|
88
88
|
description: 'Search for global weather forecasts.',
|
|
@@ -97,7 +97,7 @@ const TEST_SERVICES: ServiceType[] = [
|
|
|
97
97
|
}),
|
|
98
98
|
|
|
99
99
|
// TODO(burdon): Needs auth.
|
|
100
|
-
|
|
100
|
+
Obj.make(ServiceType, {
|
|
101
101
|
serviceId: 'abstractapi.com/service/GeoLocation',
|
|
102
102
|
name: 'Abstract GeoLocation',
|
|
103
103
|
description: 'Get the location of any IP address.',
|
|
@@ -115,7 +115,7 @@ const TEST_SERVICES: ServiceType[] = [
|
|
|
115
115
|
//
|
|
116
116
|
|
|
117
117
|
...Array.from({ length: 20 }, (_, i) =>
|
|
118
|
-
|
|
118
|
+
Obj.make(ServiceType, {
|
|
119
119
|
serviceId: `example.com/service/test-${i}`,
|
|
120
120
|
name: `Test ${i}`,
|
|
121
121
|
description: `Test ${i}`,
|
package/src/tools/function.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createTool, type ExecutableTool, ToolResult } from '@dxos/ai';
|
|
6
|
-
import {
|
|
6
|
+
import { Type } from '@dxos/echo';
|
|
7
7
|
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
8
8
|
import { type FunctionType } from '@dxos/functions';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
@@ -29,7 +29,7 @@ export const convertFunctionToTool = (
|
|
|
29
29
|
return createTool('user-function', {
|
|
30
30
|
name: fn.name,
|
|
31
31
|
description: fn.description,
|
|
32
|
-
schema: toEffectSchema(fn.inputSchema),
|
|
32
|
+
schema: Type.toEffectSchema(fn.inputSchema),
|
|
33
33
|
execute: async (input) => {
|
|
34
34
|
log.info('execute function tool', { name: fn.name, url, input });
|
|
35
35
|
const response = await fetch(url, {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { EdgeAiServiceClient } from '@dxos/ai';
|
|
8
8
|
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
|
|
@@ -73,10 +73,8 @@ describe.skip('openapi', () => {
|
|
|
73
73
|
describe.skip('AI uses tools', () => {
|
|
74
74
|
test('amadeus flight availabilities', { timeout: 60_000 }, async () => {
|
|
75
75
|
const tools = await createToolsFromApi(FLIGHT_SEARCH_API, { authorization: AMADEUS_AUTH });
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
const processor = new ChatProcessor(client, tools);
|
|
76
|
+
const aiClient = new EdgeAiServiceClient({ endpoint: AI_SERVICE_ENDPOINT.LOCAL });
|
|
77
|
+
const processor = new ChatProcessor(aiClient, tools);
|
|
80
78
|
const reply = await processor.request(
|
|
81
79
|
`What is the cheapest flight from New York to Paris? going on ${new Date().toISOString()} and returning after a week. 1 adult traveler`,
|
|
82
80
|
);
|
|
@@ -87,10 +85,8 @@ describe.skip('openapi', () => {
|
|
|
87
85
|
// TODO(dmaretskyi): Doesn't work.
|
|
88
86
|
test('amadeus hotel name autocomplete', { timeout: 60_000 }, async () => {
|
|
89
87
|
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
const processor = new ChatProcessor(client, tools);
|
|
88
|
+
const aiClient = new EdgeAiServiceClient({ endpoint: AI_SERVICE_ENDPOINT.LOCAL });
|
|
89
|
+
const processor = new ChatProcessor(aiClient, tools);
|
|
94
90
|
const reply = await processor.request('Find me the William Wale in Brooklyn New York');
|
|
95
91
|
|
|
96
92
|
log.info('reply', { reply });
|
|
@@ -101,10 +97,8 @@ describe.skip('openapi', () => {
|
|
|
101
97
|
authorization: VISUAL_CROSSING_CREDENTIALS,
|
|
102
98
|
instructions: WEATHER_INSTRUCTIONS,
|
|
103
99
|
});
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
const processor = new ChatProcessor(client, tools);
|
|
100
|
+
const aiClient = new EdgeAiServiceClient({ endpoint: AI_SERVICE_ENDPOINT.LOCAL });
|
|
101
|
+
const processor = new ChatProcessor(aiClient, tools);
|
|
108
102
|
const reply = await processor.request(
|
|
109
103
|
`Today's date is ${new Date().toISOString().split('T')[0]}. Give me weather forecast for Warsaw for next 5 days.`,
|
|
110
104
|
);
|
package/src/tools/openapi.ts
CHANGED
|
@@ -7,7 +7,8 @@ import jsonpointer from 'jsonpointer';
|
|
|
7
7
|
import { type OpenAPIV2, type OpenAPIV3_1 } from 'openapi-types';
|
|
8
8
|
|
|
9
9
|
import { type ExecutableTool, ToolResult, createRawTool } from '@dxos/ai';
|
|
10
|
-
import {
|
|
10
|
+
import { Type } from '@dxos/echo';
|
|
11
|
+
import { normalizeSchema } from '@dxos/echo-schema';
|
|
11
12
|
import { invariant } from '@dxos/invariant';
|
|
12
13
|
import { log } from '@dxos/log';
|
|
13
14
|
import { deepMapValues } from '@dxos/util';
|
|
@@ -52,8 +53,7 @@ export const createToolsFromApi = async (
|
|
|
52
53
|
return resolved;
|
|
53
54
|
}) ?? [];
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
const inputSchema: JsonSchemaType = {
|
|
56
|
+
const inputSchema: Type.JsonSchema = {
|
|
57
57
|
type: 'object',
|
|
58
58
|
properties: {},
|
|
59
59
|
};
|
|
@@ -86,7 +86,7 @@ export const createToolsFromApi = async (
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
log('inputSchema', { inputSchema });
|
|
89
|
-
Schema.validateSync(
|
|
89
|
+
Schema.validateSync(Type.JsonSchema)(inputSchema);
|
|
90
90
|
|
|
91
91
|
const description = methodItem.description ?? methodItem.summary;
|
|
92
92
|
if (!description) {
|
|
@@ -206,7 +206,7 @@ const callApiEndpoint = async (endpoint: EndpointDescriptor, input: any) => {
|
|
|
206
206
|
const value = input[parameter.name];
|
|
207
207
|
|
|
208
208
|
// Client-side validation
|
|
209
|
-
const effectSchema = toEffectSchema(parameter.schema);
|
|
209
|
+
const effectSchema = Type.toEffectSchema(parameter.schema);
|
|
210
210
|
Schema.validateSync(effectSchema)(value);
|
|
211
211
|
|
|
212
212
|
if (body) {
|