@dxos/assistant 0.8.1 → 0.8.2-main.12df754
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/{chunk-PND5VR6D.mjs → chunk-DEIGOD4U.mjs} +91 -84
- package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -4
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +20 -20
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-IBOBRBDF.cjs → chunk-7VH7NMIM.cjs} +106 -98
- package/dist/lib/node/chunk-7VH7NMIM.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -35
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +27 -27
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-DCQJOLSR.mjs → chunk-7JI4MDGL.mjs} +91 -84
- package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +6 -4
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +20 -20
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/ai-service/edge-client.d.ts +4 -5
- package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/message-collector.d.ts +0 -6
- package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +6 -2
- package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/parser.d.ts +0 -3
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/service.d.ts +18 -2
- package/dist/types/src/ai-service/service.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +6 -2
- package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
- package/dist/types/src/ai-service/types.d.ts +52 -9
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.d.ts +0 -3
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/types.d.ts +2 -3
- package/dist/types/src/conversation/types.d.ts.map +1 -1
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +0 -6
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/ai-service/client.test.ts +50 -68
- package/src/ai-service/edge-client.ts +13 -20
- package/src/ai-service/ollama-client.ts +9 -2
- package/src/ai-service/parser.ts +13 -2
- package/src/ai-service/service.ts +19 -3
- package/src/ai-service/testing/mock.ts +9 -1
- package/src/ai-service/types.ts +15 -6
- package/src/bin/chat.ts +1 -1
- package/src/conversation/conversation.ts +5 -11
- package/src/conversation/types.ts +1 -4
- package/src/cypher/echo-data-source.ts +1 -2
- package/src/session/session.test.ts +6 -6
- package/src/session/session.ts +3 -3
- package/src/testing/query.test.ts +14 -16
- package/src/testing/test-data.ts +19 -19
- package/dist/lib/browser/chunk-PND5VR6D.mjs.map +0 -7
- package/dist/lib/node/chunk-IBOBRBDF.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +0 -7
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { type GenerationStream, type AIServiceClient, type GenerateRequest } from '@dxos/assistant';
|
|
1
|
+
import { type GenerationStream, type AIServiceClient, type GenerateRequest, type GenerateResponse } from '@dxos/assistant';
|
|
2
2
|
export declare class MockAIService implements AIServiceClient {
|
|
3
3
|
private readonly _responses;
|
|
4
4
|
constructor(_responses: string[]);
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Generate non-streaming response.
|
|
7
|
+
*/
|
|
8
|
+
exec(request: GenerateRequest): Promise<GenerateResponse>;
|
|
9
|
+
execStream(request: GenerateRequest): Promise<GenerationStream>;
|
|
6
10
|
}
|
|
7
11
|
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/testing/mock.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/testing/mock.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,aAAc,YAAW,eAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,MAAM,EAAE;IAEjD;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMzD,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAGtE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
2
|
import { Message, type MessageContentBlock } from '@dxos/artifact';
|
|
3
|
-
import { ObjectId } from '@dxos/echo-schema';
|
|
3
|
+
import { type ObjectId } from '@dxos/echo-schema';
|
|
4
4
|
export declare const createArtifactElement: (id: ObjectId) => string;
|
|
5
5
|
export declare const LLMModel: S.Literal<["@anthropic/claude-3-5-haiku-20241022", "@anthropic/claude-3-5-sonnet-20241022", "@anthropic/claude-3-7-sonnet-20250219", "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", "@hf/nousresearch/hermes-2-pro-mistral-7b", "@ollama/llama-3-1-nemotron-70b-instruct", "@ollama/llama-3-1-nemotron-mini-4b-instruct", "@ollama/llama-3-2-3b", "llama3.2:1b", "llama3:70b", "deepseek-r1:latest"]>;
|
|
6
6
|
export type LLMModel = S.Schema.Type<typeof LLMModel>;
|
|
@@ -11,8 +11,6 @@ export declare const ToolTypes: Readonly<{
|
|
|
11
11
|
* Client GPT request.
|
|
12
12
|
*/
|
|
13
13
|
export declare const GenerateRequest: S.Struct<{
|
|
14
|
-
spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
|
|
15
|
-
threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
|
|
16
14
|
/**
|
|
17
15
|
* Preferred model or system default.
|
|
18
16
|
*/
|
|
@@ -39,9 +37,6 @@ export declare const GenerateRequest: S.Struct<{
|
|
|
39
37
|
*/
|
|
40
38
|
history: S.optional<S.Array$<import("@dxos/echo-schema").EchoObjectSchema<S.Struct<{
|
|
41
39
|
id: import("@dxos/echo-schema").ObjectIdClass;
|
|
42
|
-
spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
|
|
43
|
-
threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
|
|
44
|
-
foreignId: S.optional<typeof S.String>;
|
|
45
40
|
role: S.refine<"user" | "assistant", S.Schema<string, string, never>>;
|
|
46
41
|
content: S.mutable<S.Array$<S.Union<[S.mutable<S.extend<S.Struct<{
|
|
47
42
|
pending: S.optional<typeof S.Boolean>;
|
|
@@ -86,9 +81,6 @@ export declare const GenerateRequest: S.Struct<{
|
|
|
86
81
|
*/
|
|
87
82
|
prompt: S.optional<import("@dxos/echo-schema").EchoObjectSchema<S.Struct<{
|
|
88
83
|
id: import("@dxos/echo-schema").ObjectIdClass;
|
|
89
|
-
spaceId: S.optional<S.Schema<import("@dxos/keys").SpaceId, string, never>>;
|
|
90
|
-
threadId: S.optional<import("@dxos/echo-schema").ObjectIdClass>;
|
|
91
|
-
foreignId: S.optional<typeof S.String>;
|
|
92
84
|
role: S.refine<"user" | "assistant", S.Schema<string, string, never>>;
|
|
93
85
|
content: S.mutable<S.Array$<S.Union<[S.mutable<S.extend<S.Struct<{
|
|
94
86
|
pending: S.optional<typeof S.Boolean>;
|
|
@@ -130,6 +122,57 @@ export declare const GenerateRequest: S.Struct<{
|
|
|
130
122
|
}>>>;
|
|
131
123
|
}>;
|
|
132
124
|
export type GenerateRequest = S.Schema.Type<typeof GenerateRequest>;
|
|
125
|
+
/**
|
|
126
|
+
* Non-streaming response.
|
|
127
|
+
*/
|
|
128
|
+
export declare const GenerateResponse: S.Struct<{
|
|
129
|
+
messages: S.Array$<import("@dxos/echo-schema").EchoObjectSchema<S.Struct<{
|
|
130
|
+
id: import("@dxos/echo-schema").ObjectIdClass;
|
|
131
|
+
role: S.refine<"user" | "assistant", S.Schema<string, string, never>>;
|
|
132
|
+
content: S.mutable<S.Array$<S.Union<[S.mutable<S.extend<S.Struct<{
|
|
133
|
+
pending: S.optional<typeof S.Boolean>;
|
|
134
|
+
}>, S.Struct<{
|
|
135
|
+
type: S.Literal<["text"]>;
|
|
136
|
+
disposition: S.optional<typeof S.String>;
|
|
137
|
+
text: typeof S.String;
|
|
138
|
+
}>>>, S.mutable<S.extend<S.Struct<{
|
|
139
|
+
pending: S.optional<typeof S.Boolean>;
|
|
140
|
+
}>, S.Struct<{
|
|
141
|
+
type: S.Literal<["json"]>;
|
|
142
|
+
disposition: S.optional<typeof S.String>;
|
|
143
|
+
json: typeof S.String;
|
|
144
|
+
}>>>, S.mutable<S.extend<S.Struct<{
|
|
145
|
+
pending: S.optional<typeof S.Boolean>;
|
|
146
|
+
}>, S.Struct<{
|
|
147
|
+
type: S.Literal<["image"]>;
|
|
148
|
+
id: S.optional<typeof S.String>;
|
|
149
|
+
source: S.optional<S.mutable<S.Struct<{
|
|
150
|
+
type: S.Literal<["base64"]>;
|
|
151
|
+
mediaType: typeof S.String;
|
|
152
|
+
data: typeof S.String;
|
|
153
|
+
}>>>;
|
|
154
|
+
}>>>, S.mutable<S.extend<S.Struct<{
|
|
155
|
+
pending: S.optional<typeof S.Boolean>;
|
|
156
|
+
}>, S.Struct<{
|
|
157
|
+
type: S.Literal<["tool_use"]>;
|
|
158
|
+
id: typeof S.String;
|
|
159
|
+
name: typeof S.String;
|
|
160
|
+
input: typeof S.Unknown;
|
|
161
|
+
}>>>, S.mutable<S.extend<S.Struct<{
|
|
162
|
+
pending: S.optional<typeof S.Boolean>;
|
|
163
|
+
}>, S.Struct<{
|
|
164
|
+
type: S.Literal<["tool_result"]>;
|
|
165
|
+
toolUseId: typeof S.String;
|
|
166
|
+
content: typeof S.String;
|
|
167
|
+
isError: S.optional<typeof S.Boolean>;
|
|
168
|
+
}>>>]>>>;
|
|
169
|
+
}>>>;
|
|
170
|
+
/**
|
|
171
|
+
* Number of tokens used in the response.
|
|
172
|
+
*/
|
|
173
|
+
tokenCount: S.optional<typeof S.Number>;
|
|
174
|
+
}>;
|
|
175
|
+
export type GenerateResponse = S.Schema.Type<typeof GenerateResponse>;
|
|
133
176
|
/**
|
|
134
177
|
* Server-Sent Events (SSE) stream from the AI service.
|
|
135
178
|
* https://docs.anthropic.com/en/api/streaming
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAQ,OAAO,EAAE,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAQ,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,eAAO,MAAM,qBAAqB,OAAQ,QAAQ,WAA4B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M,CAAC;IACd,KAAK,EACD;QACE,IAAI,EAAE,YAAY,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACd,GACD;QACE,IAAI,EAAE,kBAAkB,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACP,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -23,9 +23,6 @@ export declare const runLLM: (params: CreateLLMConversationParams) => Promise<{
|
|
|
23
23
|
result: any;
|
|
24
24
|
history: {
|
|
25
25
|
readonly id: string;
|
|
26
|
-
spaceId?: SpaceId | undefined;
|
|
27
|
-
threadId?: string | undefined;
|
|
28
|
-
foreignId?: string | undefined;
|
|
29
26
|
role: "user" | "assistant";
|
|
30
27
|
content: ({
|
|
31
28
|
pending?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../src/conversation/conversation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,IAAI,EAAc,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../src/conversation/conversation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,IAAI,EAAc,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAU,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhG,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,QAAQ,CAAC;IAEhB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,GACD,qBAAqB,CAAC;AAG1B,eAAO,MAAM,MAAM,WAAkB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuG/D,CAAC;AAEF,eAAO,MAAM,SAAS,YAAa,OAAO,sBAAqB;IAAE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,YAI1F,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEN,eAAO,MAAM,QAAQ,mCAA0C,eAAe,KAAG,OAAO,CAAC,cAAc,CAqFtG,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
2
|
import { type Message, type MessageContentBlock } from '@dxos/artifact';
|
|
3
|
-
import { JsonSchemaType
|
|
4
|
-
|
|
5
|
-
export declare const createUserMessage: (spaceId: SpaceId, threadId: ObjectId, text: string) => Message;
|
|
3
|
+
import { JsonSchemaType } from '@dxos/echo-schema';
|
|
4
|
+
export declare const createUserMessage: (text: string) => Message;
|
|
6
5
|
/**
|
|
7
6
|
* @deprecated Use {@link LLMTool} instead.
|
|
8
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/conversation/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/conversation/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAgB,cAAc,EAAY,MAAM,mBAAmB,CAAC;AAG3E,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,OAI/C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;EAKzB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAClF,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,qBAAqB;KAAG;CACnC;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAA;CAAE,GAClF;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvC,eAAO,MAAM,UAAU;IACrB;;;OAGG;sBACe,OAAO,yBAAyB,mBAAmB,EAAE,KAAG,UAAU;qBAMnE,MAAM,KAAG,UAAU;IACpC;;OAEG;oBACa,OAAO,KAAG,UAAU;EACpC,CAAC;AAEH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAChG,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,2CAK5D,gBAAgB,CAAC,MAAM,CAAC,KAAG,cAU7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo-data-source.d.ts","sourceRoot":"","sources":["../../../../src/cypher/echo-data-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAmC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"echo-data-source.d.ts","sourceRoot":"","sources":["../../../../src/cypher/echo-data-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAmC,MAAM,eAAe,CAAC;AAInF,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGvE,qBAAa,cAAe,YAAW,UAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAGxC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBxD,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YA+BhE,aAAa;IAQ3B,OAAO,CAAC,aAAa;YAUP,uBAAuB;CAqBtC"}
|
|
@@ -53,9 +53,6 @@ export declare class AISession {
|
|
|
53
53
|
*/
|
|
54
54
|
readonly message: Event<{
|
|
55
55
|
readonly id: string;
|
|
56
|
-
spaceId?: import("@dxos/keys").SpaceId | undefined;
|
|
57
|
-
threadId?: string | undefined;
|
|
58
|
-
foreignId?: string | undefined;
|
|
59
56
|
role: "user" | "assistant";
|
|
60
57
|
content: ({
|
|
61
58
|
pending?: boolean | undefined;
|
|
@@ -166,9 +163,6 @@ export declare class AISession {
|
|
|
166
163
|
*/
|
|
167
164
|
readonly userMessage: Event<{
|
|
168
165
|
readonly id: string;
|
|
169
|
-
spaceId?: import("@dxos/keys").SpaceId | undefined;
|
|
170
|
-
threadId?: string | undefined;
|
|
171
|
-
foreignId?: string | undefined;
|
|
172
166
|
role: "user" | "assistant";
|
|
173
167
|
content: ({
|
|
174
168
|
pending?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAc,OAAO,EAAc,KAAK,kBAAkB,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAK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AW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAwB;gBAEtB,QAAQ,EAAE,gBAAgB;IAQjD,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAkOzD,KAAK;CAGN;;;;AAqCD,qBAAa,wBAAyB,SAAQ,6BAG7C;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/assistant",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-main.12df754",
|
|
4
4
|
"description": "Natural language interface to DXOS",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"parjs": "^1.3.9",
|
|
41
41
|
"parsimmon": "^1.18.1",
|
|
42
42
|
"ulidx": "^2.3.0",
|
|
43
|
-
"@dxos/artifact": "0.8.
|
|
44
|
-
"@dxos/async": "0.8.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/echo-
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/invariant": "0.8.
|
|
50
|
-
"@dxos/keys": "0.8.
|
|
51
|
-
"@dxos/live-object": "0.8.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
43
|
+
"@dxos/artifact": "0.8.2-main.12df754",
|
|
44
|
+
"@dxos/async": "0.8.2-main.12df754",
|
|
45
|
+
"@dxos/debug": "0.8.2-main.12df754",
|
|
46
|
+
"@dxos/context": "0.8.2-main.12df754",
|
|
47
|
+
"@dxos/echo-db": "0.8.2-main.12df754",
|
|
48
|
+
"@dxos/echo-schema": "0.8.2-main.12df754",
|
|
49
|
+
"@dxos/invariant": "0.8.2-main.12df754",
|
|
50
|
+
"@dxos/keys": "0.8.2-main.12df754",
|
|
51
|
+
"@dxos/live-object": "0.8.2-main.12df754",
|
|
52
|
+
"@dxos/log": "0.8.2-main.12df754",
|
|
53
|
+
"@dxos/node-std": "0.8.2-main.12df754",
|
|
54
|
+
"@dxos/util": "0.8.2-main.12df754"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/parsimmon": "^1.10.9",
|
|
@@ -6,9 +6,8 @@ import { Schema as S } from 'effect';
|
|
|
6
6
|
import { test, describe } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { defineTool, Message, ToolResult, type Tool } from '@dxos/artifact';
|
|
9
|
-
import { toJsonSchema,
|
|
9
|
+
import { toJsonSchema, create } from '@dxos/echo-schema';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { SpaceId } from '@dxos/keys';
|
|
12
11
|
import { log } from '@dxos/log';
|
|
13
12
|
|
|
14
13
|
import { DEFAULT_EDGE_MODEL } from './defs';
|
|
@@ -26,23 +25,18 @@ describe.skip('AI Service Client', () => {
|
|
|
26
25
|
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
const stream = await client.exec({
|
|
28
|
+
// await client.appendMessages([
|
|
29
|
+
// {
|
|
30
|
+
// id: ObjectId.random(),
|
|
31
|
+
// spaceId,
|
|
32
|
+
// threadId,
|
|
33
|
+
// role: 'user',
|
|
34
|
+
// content: [{ type: 'text', text: 'Hello' }],
|
|
35
|
+
// },
|
|
36
|
+
// ]);
|
|
37
|
+
|
|
38
|
+
const stream = await client.execStream({
|
|
43
39
|
model: DEFAULT_EDGE_MODEL,
|
|
44
|
-
spaceId,
|
|
45
|
-
threadId,
|
|
46
40
|
systemPrompt: 'You are a poet',
|
|
47
41
|
tools: [],
|
|
48
42
|
});
|
|
@@ -70,24 +64,19 @@ describe.skip('AI Service Client', () => {
|
|
|
70
64
|
),
|
|
71
65
|
};
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
content: [{ type: 'text', text: 'What is the password? Ask the custodian' }],
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
67
|
+
// await client.appendMessages([
|
|
68
|
+
// {
|
|
69
|
+
// id: ObjectId.random(),
|
|
70
|
+
// spaceId,
|
|
71
|
+
// threadId,
|
|
72
|
+
// role: 'user',
|
|
73
|
+
// content: [{ type: 'text', text: 'What is the password? Ask the custodian' }],
|
|
74
|
+
// },
|
|
75
|
+
// ]);
|
|
85
76
|
|
|
86
77
|
{
|
|
87
|
-
const stream1 = await client.
|
|
78
|
+
const stream1 = await client.execStream({
|
|
88
79
|
model: DEFAULT_EDGE_MODEL,
|
|
89
|
-
spaceId,
|
|
90
|
-
threadId,
|
|
91
80
|
systemPrompt: 'You are a helpful assistant.',
|
|
92
81
|
tools: [custodian],
|
|
93
82
|
});
|
|
@@ -102,26 +91,24 @@ describe.skip('AI Service Client', () => {
|
|
|
102
91
|
|
|
103
92
|
const [message1] = messages;
|
|
104
93
|
log('full message', { message: message1 });
|
|
105
|
-
await client.appendMessages([message1]);
|
|
94
|
+
// await client.appendMessages([message1]);
|
|
106
95
|
|
|
107
96
|
const toolUse = message1.content.find(({ type }) => type === 'tool_use')!;
|
|
108
97
|
invariant(toolUse.type === 'tool_use');
|
|
109
|
-
await client.appendMessages([
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
]);
|
|
98
|
+
// await client.appendMessages([
|
|
99
|
+
// {
|
|
100
|
+
// id: ObjectId.random(),
|
|
101
|
+
// spaceId,
|
|
102
|
+
// threadId,
|
|
103
|
+
// role: 'user',
|
|
104
|
+
// content: [{ type: 'tool_result', toolUseId: toolUse.id, content: 'password="The sky is blue"' }],
|
|
105
|
+
// },
|
|
106
|
+
// ]);
|
|
118
107
|
}
|
|
119
108
|
|
|
120
109
|
{
|
|
121
|
-
const stream2 = await client.
|
|
110
|
+
const stream2 = await client.execStream({
|
|
122
111
|
model: DEFAULT_EDGE_MODEL,
|
|
123
|
-
spaceId,
|
|
124
|
-
threadId,
|
|
125
112
|
systemPrompt: 'You are a helpful assistant.',
|
|
126
113
|
tools: [custodian],
|
|
127
114
|
});
|
|
@@ -143,23 +130,18 @@ describe.skip('AI Service Client', () => {
|
|
|
143
130
|
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
144
131
|
});
|
|
145
132
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
]);
|
|
158
|
-
|
|
159
|
-
const stream = await client.exec({
|
|
133
|
+
// await client.appendMessages([
|
|
134
|
+
// {
|
|
135
|
+
// id: ObjectId.random(),
|
|
136
|
+
// spaceId,
|
|
137
|
+
// threadId,
|
|
138
|
+
// role: 'user',
|
|
139
|
+
// content: [{ type: 'text', text: 'Generate an image of a cat' }],
|
|
140
|
+
// },
|
|
141
|
+
// ]);
|
|
142
|
+
|
|
143
|
+
const stream = await client.execStream({
|
|
160
144
|
model: DEFAULT_EDGE_MODEL,
|
|
161
|
-
spaceId,
|
|
162
|
-
threadId,
|
|
163
145
|
tools: [
|
|
164
146
|
{
|
|
165
147
|
name: 'text-to-image',
|
|
@@ -190,8 +172,8 @@ describe.skip('Ollama Client', () => {
|
|
|
190
172
|
const parser = new MixedStreamParser();
|
|
191
173
|
|
|
192
174
|
const messages = await parser.parse(
|
|
193
|
-
await client.
|
|
194
|
-
prompt:
|
|
175
|
+
await client.execStream({
|
|
176
|
+
prompt: create(Message, {
|
|
195
177
|
role: 'user',
|
|
196
178
|
content: [{ type: 'text', text: 'Hello, world!' }],
|
|
197
179
|
}),
|
|
@@ -225,8 +207,8 @@ describe.skip('Ollama Client', () => {
|
|
|
225
207
|
});
|
|
226
208
|
|
|
227
209
|
const messages = await parser.parse(
|
|
228
|
-
await client.
|
|
229
|
-
prompt:
|
|
210
|
+
await client.execStream({
|
|
211
|
+
prompt: create(Message, {
|
|
230
212
|
role: 'user',
|
|
231
213
|
content: [{ type: 'text', text: 'What is the encrypted message for "Hello, world!"' }],
|
|
232
214
|
}),
|
|
@@ -246,8 +228,8 @@ describe.skip('Ollama Client', () => {
|
|
|
246
228
|
const parser = new MixedStreamParser();
|
|
247
229
|
|
|
248
230
|
const messages = await parser.parse(
|
|
249
|
-
await client.
|
|
250
|
-
prompt:
|
|
231
|
+
await client.execStream({
|
|
232
|
+
prompt: create(Message, {
|
|
251
233
|
role: 'user',
|
|
252
234
|
content: [{ type: 'text', text: 'Generate an image of a cat' }],
|
|
253
235
|
}),
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema as S } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { Message } from '@dxos/artifact';
|
|
8
5
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
9
6
|
import { log } from '@dxos/log';
|
|
10
7
|
|
|
11
8
|
import type { AIServiceClient, GenerationStream } from './service';
|
|
12
9
|
import { createGenerationStream } from './stream';
|
|
13
|
-
import { type GenerateRequest } from './types';
|
|
10
|
+
import { type GenerateRequest, type GenerateResponse } from './types';
|
|
14
11
|
|
|
15
12
|
export type AIServiceEdgeClientOptions = {
|
|
16
13
|
endpoint: string;
|
|
@@ -25,28 +22,16 @@ export class AIServiceEdgeClient implements AIServiceClient {
|
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
|
-
*
|
|
25
|
+
* Generate non-streaming response.
|
|
29
26
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const url = `${this._endpoint}/message`;
|
|
33
|
-
const res = await fetch(url, {
|
|
34
|
-
method: 'POST',
|
|
35
|
-
headers: { 'Content-Type': 'application/json' },
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
messages: await S.encodePromise(S.Array(Message))(messages),
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (!res.ok) {
|
|
42
|
-
throw new Error(`${await res.text()} [${url}]`);
|
|
43
|
-
}
|
|
27
|
+
async exec(request: GenerateRequest): Promise<GenerateResponse> {
|
|
28
|
+
throw new Error('Not implemented');
|
|
44
29
|
}
|
|
45
30
|
|
|
46
31
|
/**
|
|
47
32
|
* Process request and open message stream.
|
|
48
33
|
*/
|
|
49
|
-
async
|
|
34
|
+
async execStream(request: GenerateRequest): Promise<GenerationStream> {
|
|
50
35
|
assertArgument(typeof request.model === 'string', 'model is required');
|
|
51
36
|
log('requesting', { endpoint: this._endpoint });
|
|
52
37
|
const controller = new AbortController();
|
|
@@ -61,7 +46,15 @@ export class AIServiceEdgeClient implements AIServiceClient {
|
|
|
61
46
|
}),
|
|
62
47
|
});
|
|
63
48
|
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw await parseErrorResponse(response);
|
|
51
|
+
}
|
|
52
|
+
|
|
64
53
|
invariant(response.body instanceof ReadableStream);
|
|
65
54
|
return createGenerationStream(response, controller);
|
|
66
55
|
}
|
|
67
56
|
}
|
|
57
|
+
|
|
58
|
+
const parseErrorResponse = async (response: Response): Promise<Error> => {
|
|
59
|
+
throw new Error(`AI Service error: ${response.status} ${response.statusText} ${await response.text()}`);
|
|
60
|
+
};
|
|
@@ -13,7 +13,7 @@ import { DEFAULT_OLLAMA_ENDPOINT } from './defs';
|
|
|
13
13
|
import { MessageCollector, emitMessageAsEvents } from './message-collector';
|
|
14
14
|
import { type AIServiceClient, type GenerationStream } from './service';
|
|
15
15
|
import { GenerationStreamImpl } from './stream';
|
|
16
|
-
import { ToolTypes, type GenerateRequest, type GenerationStreamEvent } from './types';
|
|
16
|
+
import { ToolTypes, type GenerateRequest, type GenerateResponse, type GenerationStreamEvent } from './types';
|
|
17
17
|
import { isToolUse, runTools } from '../conversation';
|
|
18
18
|
|
|
19
19
|
export type OllamaClientParams = {
|
|
@@ -300,7 +300,14 @@ export class OllamaClient implements AIServiceClient {
|
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Generate non-streaming response.
|
|
305
|
+
*/
|
|
306
|
+
async exec(request: GenerateRequest): Promise<GenerateResponse> {
|
|
307
|
+
throw new Error('Not implemented');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
async execStream(request: GenerateRequest): Promise<GenerationStream> {
|
|
304
311
|
const controller = new AbortController();
|
|
305
312
|
|
|
306
313
|
try {
|
package/src/ai-service/parser.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Message, type MessageContentBlock } from '@dxos/artifact';
|
|
6
6
|
import { Event } from '@dxos/async';
|
|
7
|
-
import {
|
|
7
|
+
import { create } from '@dxos/echo-schema';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { isNotFalsy, safeParseJson } from '@dxos/util';
|
|
@@ -94,7 +94,7 @@ export class MixedStreamParser {
|
|
|
94
94
|
log.warn('unexpected message_start');
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
this._message =
|
|
97
|
+
this._message = create(Message, { role: event.message.role, content: [...event.message.content] });
|
|
98
98
|
this.message.emit(this._message);
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
@@ -316,6 +316,17 @@ export const mergeMessageBlock = (
|
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
case 'proposal': {
|
|
320
|
+
if (streamBlock.content.length === 1 && streamBlock.content[0].type === 'text') {
|
|
321
|
+
return {
|
|
322
|
+
type: 'json',
|
|
323
|
+
disposition: 'proposal',
|
|
324
|
+
json: JSON.stringify({ text: streamBlock.content[0].content }),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
|
|
319
330
|
case 'select': {
|
|
320
331
|
return {
|
|
321
332
|
type: 'json',
|
|
@@ -2,13 +2,29 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type GenerateRequest, type GenerationStreamEvent } from './types';
|
|
5
|
+
import { type GenerateRequest, type GenerationStreamEvent, type GenerateResponse } from './types';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Interface for AI service.
|
|
9
|
+
* Generates chat completions, supports, history and tools.
|
|
10
|
+
*/
|
|
8
11
|
export interface AIServiceClient {
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Generate chat completions, supports, history and tools.
|
|
14
|
+
* Generate non-streaming response.
|
|
15
|
+
*/
|
|
16
|
+
exec(request: GenerateRequest): Promise<GenerateResponse>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generate chat completions, supports, history and tools.
|
|
20
|
+
* Process request and open message stream.
|
|
21
|
+
*/
|
|
22
|
+
execStream(request: GenerateRequest): Promise<GenerationStream>;
|
|
10
23
|
}
|
|
11
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Streaming chat completion stream.
|
|
27
|
+
*/
|
|
12
28
|
export interface GenerationStream extends AsyncIterable<GenerationStreamEvent> {
|
|
13
29
|
abort(): void;
|
|
14
30
|
complete(): Promise<void>;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type AIServiceClient,
|
|
8
8
|
type GenerateRequest,
|
|
9
9
|
createGenerationStream,
|
|
10
|
+
type GenerateResponse,
|
|
10
11
|
} from '@dxos/assistant';
|
|
11
12
|
|
|
12
13
|
import { createTestSSEStream } from './test-stream';
|
|
@@ -14,9 +15,16 @@ import { createTestSSEStream } from './test-stream';
|
|
|
14
15
|
export class MockAIService implements AIServiceClient {
|
|
15
16
|
constructor(private readonly _responses: string[]) {}
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Generate non-streaming response.
|
|
20
|
+
*/
|
|
21
|
+
async exec(request: GenerateRequest): Promise<GenerateResponse> {
|
|
22
|
+
throw new Error('Not implemented');
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
// TODO(burdon): Match response to request.
|
|
18
26
|
// TODO(burdon): See MockGpt (from conductor).
|
|
19
|
-
async
|
|
27
|
+
async execStream(request: GenerateRequest): Promise<GenerationStream> {
|
|
20
28
|
return createGenerationStream(new Response(createTestSSEStream(this._responses)));
|
|
21
29
|
}
|
|
22
30
|
}
|