@dxos/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/index.mjs +149 -60
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +155 -65
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +149 -60
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/ai.test.d.ts +2 -0
- package/dist/types/src/blueprint/ai.test.d.ts.map +1 -0
- package/dist/types/src/blueprint/blueprint.d.ts +16 -12
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/logger.d.ts +16 -3
- package/dist/types/src/blueprint/logger.d.ts.map +1 -1
- package/dist/types/src/blueprint/machine.d.ts +37 -16
- package/dist/types/src/blueprint/machine.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +31 -33
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +104 -100
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/research/graph.d.ts +5 -4
- package/dist/types/src/research/graph.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +6 -6
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/package.json +29 -20
- package/src/blueprint/ai.test.ts +156 -0
- package/src/blueprint/blueprint.test.ts +22 -20
- package/src/blueprint/blueprint.ts +18 -14
- package/src/blueprint/logger.ts +49 -3
- package/src/blueprint/machine.ts +69 -32
- package/src/blueprint/test-data.ts +4 -4
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +2 -2
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +2 -1
- package/src/extraction/quotes.ts +2 -1
- package/src/research/graph.ts +7 -9
- package/src/research/research.test.ts +9 -8
- package/src/research/research.ts +2 -2
- package/src/session/session.test.ts +10 -10
- package/src/session/session.ts +4 -3
- package/src/summarization/summarization.test.ts +17 -12
|
@@ -2,62 +2,61 @@ import { Schema } from 'effect';
|
|
|
2
2
|
import { Expando } from '@dxos/echo-schema';
|
|
3
3
|
import { type FunctionDefinition, type FunctionExecutor } from '@dxos/functions';
|
|
4
4
|
export declare const ExtractionInput: Schema.Struct<{
|
|
5
|
-
message: import("@dxos/echo
|
|
5
|
+
message: import("@dxos/echo/Type").obj<Schema.Struct<{
|
|
6
6
|
id: import("@dxos/keys").ObjectIdClass;
|
|
7
7
|
created: import("effect/Schema").SchemaClass<string, string, never>;
|
|
8
8
|
sender: import("effect/Schema").mutable<import("effect/Schema").Struct<{
|
|
9
|
-
contact: import("effect/Schema").optional<import("@dxos/echo
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}[] | undefined;
|
|
16
|
-
organization?: import("@dxos/echo-schema").Ref<{
|
|
17
|
-
readonly id: string;
|
|
9
|
+
contact: import("effect/Schema").optional<import("@dxos/echo/Type").ref<import("@dxos/echo/Type").obj<import("effect/Schema").Struct<{
|
|
10
|
+
fullName: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
11
|
+
preferredName: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
12
|
+
nickname: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
13
|
+
image: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
14
|
+
organization: import("effect/Schema").optional<import("effect/Schema").Schema<import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
18
15
|
description?: string | undefined;
|
|
16
|
+
id: string;
|
|
19
17
|
name?: string | undefined;
|
|
20
18
|
status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
|
|
21
19
|
image?: string | undefined;
|
|
22
20
|
website?: string | undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
21
|
+
}>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
22
|
+
jobTitle: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
23
|
+
department: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
24
|
+
notes: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
25
|
+
emails: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
26
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
27
|
+
value: import("effect/Schema").refine<string, typeof import("effect/Schema").String>;
|
|
28
|
+
}>>>>;
|
|
29
|
+
identities: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
30
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
31
|
+
value: typeof import("effect/Schema").String;
|
|
32
|
+
}>>>>;
|
|
33
|
+
phoneNumbers: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
34
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
35
|
+
value: typeof import("effect/Schema").String;
|
|
36
|
+
}>>>>;
|
|
37
|
+
addresses: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
38
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
39
|
+
value: import("effect/Schema").Struct<{
|
|
40
|
+
street: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
41
|
+
extended: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
42
|
+
locality: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
43
|
+
region: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
44
|
+
postalCode: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
45
|
+
postOfficeBoxNumber: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
46
|
+
country: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
47
|
+
}>;
|
|
48
|
+
}>>>>;
|
|
49
|
+
urls: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
50
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
51
|
+
value: import("effect/Schema").refine<string, typeof import("effect/Schema").String>;
|
|
52
|
+
}>>>>;
|
|
53
|
+
birthday: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").SchemaClass<string, string, never>>>;
|
|
54
|
+
fields: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
55
|
+
category: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
56
|
+
label: typeof import("effect/Schema").String;
|
|
57
|
+
value: typeof import("effect/Schema").String;
|
|
58
|
+
}>>>>;
|
|
59
|
+
}>>>>;
|
|
61
60
|
identityDid: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
62
61
|
identityKey: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
63
62
|
email: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
@@ -93,7 +92,10 @@ export declare const ExtractionInput: Schema.Struct<{
|
|
|
93
92
|
pending: import("effect/Schema").optional<typeof import("effect/Schema").Boolean>;
|
|
94
93
|
}>, import("effect/Schema").Struct<{
|
|
95
94
|
type: import("effect/Schema").Literal<["reference"]>;
|
|
96
|
-
reference: import("@dxos/echo
|
|
95
|
+
reference: import("@dxos/echo/Type").ref<import("effect/Schema").Schema<import("@dxos/echo/Type").Expando, {
|
|
96
|
+
[x: string]: any;
|
|
97
|
+
id: string;
|
|
98
|
+
}, never>>;
|
|
97
99
|
}>>>, import("effect/Schema").mutable<import("effect/Schema").extend<import("effect/Schema").Struct<{
|
|
98
100
|
pending: import("effect/Schema").optional<typeof import("effect/Schema").Boolean>;
|
|
99
101
|
}>, import("effect/Schema").Struct<{
|
|
@@ -102,7 +104,7 @@ export declare const ExtractionInput: Schema.Struct<{
|
|
|
102
104
|
text: typeof import("effect/Schema").String;
|
|
103
105
|
}>>>]>>>;
|
|
104
106
|
properties: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Record$<typeof import("effect/Schema").String, typeof import("effect/Schema").Any>>>;
|
|
105
|
-
}
|
|
107
|
+
}>>;
|
|
106
108
|
objects: Schema.optional<Schema.Array$<Schema.Schema<Expando, Expando, never>>>;
|
|
107
109
|
options: Schema.optional<Schema.Struct<{
|
|
108
110
|
timeout: Schema.optional<typeof Schema.Number>;
|
|
@@ -112,62 +114,61 @@ export declare const ExtractionInput: Schema.Struct<{
|
|
|
112
114
|
export interface ExtractionInput extends Schema.Schema.Type<typeof ExtractionInput> {
|
|
113
115
|
}
|
|
114
116
|
export declare const ExtractionOutput: Schema.Struct<{
|
|
115
|
-
message: import("@dxos/echo
|
|
117
|
+
message: import("@dxos/echo/Type").obj<Schema.Struct<{
|
|
116
118
|
id: import("@dxos/keys").ObjectIdClass;
|
|
117
119
|
created: import("effect/Schema").SchemaClass<string, string, never>;
|
|
118
120
|
sender: import("effect/Schema").mutable<import("effect/Schema").Struct<{
|
|
119
|
-
contact: import("effect/Schema").optional<import("@dxos/echo
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}[] | undefined;
|
|
126
|
-
organization?: import("@dxos/echo-schema").Ref<{
|
|
127
|
-
readonly id: string;
|
|
121
|
+
contact: import("effect/Schema").optional<import("@dxos/echo/Type").ref<import("@dxos/echo/Type").obj<import("effect/Schema").Struct<{
|
|
122
|
+
fullName: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
123
|
+
preferredName: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
124
|
+
nickname: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
125
|
+
image: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
126
|
+
organization: import("effect/Schema").optional<import("effect/Schema").Schema<import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
128
127
|
description?: string | undefined;
|
|
128
|
+
id: string;
|
|
129
129
|
name?: string | undefined;
|
|
130
130
|
status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
|
|
131
131
|
image?: string | undefined;
|
|
132
132
|
website?: string | undefined;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
}>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
134
|
+
jobTitle: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
135
|
+
department: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
136
|
+
notes: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
137
|
+
emails: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
138
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
139
|
+
value: import("effect/Schema").refine<string, typeof import("effect/Schema").String>;
|
|
140
|
+
}>>>>;
|
|
141
|
+
identities: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
142
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
143
|
+
value: typeof import("effect/Schema").String;
|
|
144
|
+
}>>>>;
|
|
145
|
+
phoneNumbers: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
146
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
147
|
+
value: typeof import("effect/Schema").String;
|
|
148
|
+
}>>>>;
|
|
149
|
+
addresses: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
150
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
151
|
+
value: import("effect/Schema").Struct<{
|
|
152
|
+
street: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
153
|
+
extended: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
154
|
+
locality: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
155
|
+
region: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
156
|
+
postalCode: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
157
|
+
postOfficeBoxNumber: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
158
|
+
country: import("effect/Schema").optional<import("effect/Schema").SchemaClass<string, string, never>>;
|
|
159
|
+
}>;
|
|
160
|
+
}>>>>;
|
|
161
|
+
urls: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
162
|
+
label: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
163
|
+
value: import("effect/Schema").refine<string, typeof import("effect/Schema").String>;
|
|
164
|
+
}>>>>;
|
|
165
|
+
birthday: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").SchemaClass<string, string, never>>>;
|
|
166
|
+
fields: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Array$<import("effect/Schema").Struct<{
|
|
167
|
+
category: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
168
|
+
label: typeof import("effect/Schema").String;
|
|
169
|
+
value: typeof import("effect/Schema").String;
|
|
170
|
+
}>>>>;
|
|
171
|
+
}>>>>;
|
|
171
172
|
identityDid: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
172
173
|
identityKey: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
173
174
|
email: import("effect/Schema").optional<typeof import("effect/Schema").String>;
|
|
@@ -203,7 +204,10 @@ export declare const ExtractionOutput: Schema.Struct<{
|
|
|
203
204
|
pending: import("effect/Schema").optional<typeof import("effect/Schema").Boolean>;
|
|
204
205
|
}>, import("effect/Schema").Struct<{
|
|
205
206
|
type: import("effect/Schema").Literal<["reference"]>;
|
|
206
|
-
reference: import("@dxos/echo
|
|
207
|
+
reference: import("@dxos/echo/Type").ref<import("effect/Schema").Schema<import("@dxos/echo/Type").Expando, {
|
|
208
|
+
[x: string]: any;
|
|
209
|
+
id: string;
|
|
210
|
+
}, never>>;
|
|
207
211
|
}>>>, import("effect/Schema").mutable<import("effect/Schema").extend<import("effect/Schema").Struct<{
|
|
208
212
|
pending: import("effect/Schema").optional<typeof import("effect/Schema").Boolean>;
|
|
209
213
|
}>, import("effect/Schema").Struct<{
|
|
@@ -212,7 +216,7 @@ export declare const ExtractionOutput: Schema.Struct<{
|
|
|
212
216
|
text: typeof import("effect/Schema").String;
|
|
213
217
|
}>>>]>>>;
|
|
214
218
|
properties: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Record$<typeof import("effect/Schema").String, typeof import("effect/Schema").Any>>>;
|
|
215
|
-
}
|
|
219
|
+
}>>;
|
|
216
220
|
timeElapsed: typeof Schema.Number;
|
|
217
221
|
}>;
|
|
218
222
|
export interface ExtractionOutput extends Schema.Schema.Type<typeof ExtractionOutput> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../../src/extraction/extraction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIjF,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../../src/extraction/extraction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QA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M,wBAAwB,GAAU,QAAQ,8BAA8B,KAAG,OAAO,CAAC,gBAAgB,CAkB/G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../../../src/extraction/quotes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../../../src/extraction/quotes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,eAAO,MAAM,gBAAgB;;;;;EAe3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,eAAO,MAAM,UAAU,GAAU,QAAQ,MAAM,EAAE,EAAE,IAAI,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAS7F,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,QAAQ,gBAAgB,WAYtE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import type { Obj } from '@dxos/echo';
|
|
2
3
|
import { type EchoDatabase, type Queue } from '@dxos/echo-db';
|
|
3
|
-
import { type
|
|
4
|
+
import { type BaseObject } from '@dxos/echo-schema';
|
|
4
5
|
export declare const Subgraph: Schema.Struct<{
|
|
5
6
|
/** Objects and relations. */
|
|
6
7
|
objects: Schema.Array$<typeof Schema.Any>;
|
|
@@ -31,10 +32,10 @@ export declare const createExtractionSchema: (types: Schema.Schema.AnyNoContext[
|
|
|
31
32
|
}>;
|
|
32
33
|
export declare const getSanitizedSchemaName: (schema: Schema.Schema.AnyNoContext) => string;
|
|
33
34
|
export declare const sanitizeObjects: (types: Schema.Schema.AnyNoContext[], data: Record<string, readonly unknown[]>, db: EchoDatabase, queue?: Queue) => Promise<BaseObject[]>;
|
|
34
|
-
export declare const createGraphWriterTool: ({ db, queue,
|
|
35
|
+
export declare const createGraphWriterTool: ({ db, queue, schema, onDone, }: {
|
|
35
36
|
db: EchoDatabase;
|
|
36
37
|
queue?: Queue;
|
|
37
|
-
|
|
38
|
-
onDone?: (data:
|
|
38
|
+
schema: Schema.Schema.AnyNoContext[];
|
|
39
|
+
onDone?: (data: Obj.Any[]) => Promise<any>;
|
|
39
40
|
}) => import("@dxos/ai").ExecutableTool;
|
|
40
41
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../src/research/graph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAA+B,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../src/research/graph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAA+B,MAAM,QAAQ,CAAC;AAG7D,OAAO,KAAK,EAAE,GAAG,EAAY,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAUL,KAAK,UAAU,EAKhB,MAAM,mBAAmB,CAAC;AAO3B,eAAO,MAAM,QAAQ;IACnB,6BAA6B;;EAE7B,CAAC;AACH,MAAM,WAAW,QAAS,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC;CAAG;AAExE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACnC,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,IAAI,YAAY,EAChB,QAAQ,MAAM,CAAC,MAAM,CAAC,YAAY,KACjC,OAAO,CAAC,aAAa,EAAE,CAsBzB,CAAC;AAmBF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,sCAyBpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;;EAWzE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,YAAY,WAIxE,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EACnC,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,EACxC,IAAI,YAAY,EAChB,QAAQ,KAAK,KACZ,OAAO,CAAC,UAAU,EAAE,CAyHtB,CAAC;AA2CF,eAAO,MAAM,qBAAqB,GAAI,gCAKnC;IACD,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC5C,sCAUA,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
import { type AgentStatus, type
|
|
2
|
+
import { type AgentStatus, type AiServiceClient, type GenerateRequest, Message, type ExecutableTool } from '@dxos/ai';
|
|
3
3
|
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
4
4
|
import { Event } from '@dxos/async';
|
|
5
5
|
import { ObjectVersion } from '@dxos/echo-db';
|
|
@@ -28,7 +28,7 @@ export type ArtifactDiffResolver = (artifacts: {
|
|
|
28
28
|
diff?: string;
|
|
29
29
|
}>>;
|
|
30
30
|
export type SessionRunOptions = {
|
|
31
|
-
client:
|
|
31
|
+
client: AiServiceClient;
|
|
32
32
|
artifacts: ArtifactDefinition[];
|
|
33
33
|
/**
|
|
34
34
|
* Non-artifact specific tools.
|
|
@@ -72,8 +72,8 @@ export declare class AISession {
|
|
|
72
72
|
/**
|
|
73
73
|
* New message.
|
|
74
74
|
*/
|
|
75
|
-
readonly message: Event<{
|
|
76
|
-
|
|
75
|
+
readonly message: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
76
|
+
id: string;
|
|
77
77
|
content: ({
|
|
78
78
|
pending?: boolean | undefined;
|
|
79
79
|
type: "text";
|
|
@@ -194,8 +194,8 @@ export declare class AISession {
|
|
|
194
194
|
/**
|
|
195
195
|
* User prompt or tool result.
|
|
196
196
|
*/
|
|
197
|
-
readonly userMessage: Event<{
|
|
198
|
-
|
|
197
|
+
readonly userMessage: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
198
|
+
id: string;
|
|
199
199
|
role: "user" | "assistant";
|
|
200
200
|
content: ({
|
|
201
201
|
pending?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,eAAe,EAEpB,KAAK,eAAe,EACpB,OAAO,EAKP,KAAK,cAAc,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;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AiBjC,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,mBAAmB;IAoF3B,OAAO,CAAC,mBAAmB;IAI3B,KAAK,IAAI,IAAI;CAGd;;;;AAuDD,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-
|
|
3
|
+
"version": "0.8.3-staging.0fa589b",
|
|
4
4
|
"description": "Natural language interface to DXOS",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,27 +25,36 @@
|
|
|
25
25
|
"@xenova/transformers": "^2.17.2",
|
|
26
26
|
"chalk": "^4.1.0",
|
|
27
27
|
"exa-js": "^1.5.12",
|
|
28
|
-
"@dxos/ai": "0.8.3-
|
|
29
|
-
"@dxos/artifact": "0.8.3-
|
|
30
|
-
"@dxos/async": "0.8.3-
|
|
31
|
-
"@dxos/context": "0.8.3-
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/echo-db": "0.8.3-
|
|
35
|
-
"@dxos/echo-protocol": "0.8.3-
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/node-std": "0.8.3-
|
|
45
|
-
"@dxos/schema": "0.8.3-
|
|
46
|
-
"@dxos/util": "0.8.3-
|
|
28
|
+
"@dxos/ai": "0.8.3-staging.0fa589b",
|
|
29
|
+
"@dxos/artifact": "0.8.3-staging.0fa589b",
|
|
30
|
+
"@dxos/async": "0.8.3-staging.0fa589b",
|
|
31
|
+
"@dxos/context": "0.8.3-staging.0fa589b",
|
|
32
|
+
"@dxos/echo": "0.8.3-staging.0fa589b",
|
|
33
|
+
"@dxos/debug": "0.8.3-staging.0fa589b",
|
|
34
|
+
"@dxos/echo-db": "0.8.3-staging.0fa589b",
|
|
35
|
+
"@dxos/echo-protocol": "0.8.3-staging.0fa589b",
|
|
36
|
+
"@dxos/effect": "0.8.3-staging.0fa589b",
|
|
37
|
+
"@dxos/graph": "0.8.3-staging.0fa589b",
|
|
38
|
+
"@dxos/invariant": "0.8.3-staging.0fa589b",
|
|
39
|
+
"@dxos/echo-schema": "0.8.3-staging.0fa589b",
|
|
40
|
+
"@dxos/functions": "0.8.3-staging.0fa589b",
|
|
41
|
+
"@dxos/keys": "0.8.3-staging.0fa589b",
|
|
42
|
+
"@dxos/log": "0.8.3-staging.0fa589b",
|
|
43
|
+
"@dxos/live-object": "0.8.3-staging.0fa589b",
|
|
44
|
+
"@dxos/node-std": "0.8.3-staging.0fa589b",
|
|
45
|
+
"@dxos/schema": "0.8.3-staging.0fa589b",
|
|
46
|
+
"@dxos/util": "0.8.3-staging.0fa589b"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@effect/ai": "^0.19.4",
|
|
50
|
+
"@effect/ai-anthropic": "^0.9.5",
|
|
51
|
+
"@effect/ai-openai": "^0.22.4",
|
|
52
|
+
"@effect/cluster": "^0.39.4",
|
|
53
|
+
"@effect/experimental": "^0.49.2",
|
|
54
|
+
"@effect/platform": "^0.85.2",
|
|
55
|
+
"@effect/platform-node": "^0.86.4",
|
|
56
|
+
"@effect/rpc": "^0.62.4",
|
|
57
|
+
"@effect/sql": "^0.38.2",
|
|
49
58
|
"effect": "3.14.21",
|
|
50
59
|
"inquirer": "^12.0.0"
|
|
51
60
|
},
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AiChat, AiInput, AiLanguageModel, AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { AnthropicClient, AnthropicLanguageModel } from '@effect/ai-anthropic';
|
|
7
|
+
import { OpenAiClient, OpenAiLanguageModel } from '@effect/ai-openai';
|
|
8
|
+
import { NodeHttpClient } from '@effect/platform-node';
|
|
9
|
+
import { Config, Console, Effect, Layer, pipe, Schedule, Schema } from 'effect';
|
|
10
|
+
import { describe, it } from 'vitest';
|
|
11
|
+
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
|
|
14
|
+
// https://effect.website/docs/ai/tool-use/#5-bring-it-all-together
|
|
15
|
+
// https://github.com/Effect-TS/effect/blob/main/packages/ai/ai/CHANGELOG.md
|
|
16
|
+
// https://discord.com/channels/795981131316985866/1338871274398679130
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Rationale:
|
|
20
|
+
* - Separation of concerns: config, execution pipline, error handling/retry, tool dispatch, async.
|
|
21
|
+
* - Uncouple tool definitions from tool implementation (late binding, composition).
|
|
22
|
+
* - Affinity with effect schema.
|
|
23
|
+
* - Leverage existing effect based conductor pipline.
|
|
24
|
+
* - Simple API for plugins/artifacts.
|
|
25
|
+
* - Ecosystem and design partner.
|
|
26
|
+
*/
|
|
27
|
+
describe.runIf(!process.env.CI)('AiLanguageModel', () => {
|
|
28
|
+
it.runIf(process.env.OPENAI_API_KEY)('Debug: Verify API configuration', async ({ expect }) => {
|
|
29
|
+
const program = Effect.gen(function* () {
|
|
30
|
+
yield* Console.log('Testing API connectivity...');
|
|
31
|
+
const response = yield* AiLanguageModel.generateText({ prompt: 'Hello, respond with "API is working"' });
|
|
32
|
+
yield* Console.log('API Response received:', response.text);
|
|
33
|
+
return response.text;
|
|
34
|
+
}).pipe(
|
|
35
|
+
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
36
|
+
Effect.timeout('10 seconds'),
|
|
37
|
+
Effect.retry({ times: 1 }),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const result = await program.pipe(
|
|
41
|
+
Effect.provide([
|
|
42
|
+
OpenAiClient.layerConfig({
|
|
43
|
+
apiKey: Config.redacted('OPENAI_API_KEY'),
|
|
44
|
+
}).pipe(Layer.provide(NodeHttpClient.layerUndici)),
|
|
45
|
+
]),
|
|
46
|
+
Effect.runPromise,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(result).to.contain('working');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Tool definitions.
|
|
53
|
+
class Toolkit extends AiToolkit.make(
|
|
54
|
+
AiTool.make('Calculator', {
|
|
55
|
+
description: 'Test tool',
|
|
56
|
+
parameters: {
|
|
57
|
+
input: Schema.String.annotations({
|
|
58
|
+
description: 'The calculation to perform.',
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
success: Schema.Struct({
|
|
62
|
+
result: Schema.Number,
|
|
63
|
+
}),
|
|
64
|
+
failure: Schema.Never,
|
|
65
|
+
}),
|
|
66
|
+
) {}
|
|
67
|
+
|
|
68
|
+
// Tool handlers.
|
|
69
|
+
const ToolkitLayer = Toolkit.toLayer({
|
|
70
|
+
Calculator: ({ input }) =>
|
|
71
|
+
Effect.gen(function* () {
|
|
72
|
+
const result = (() => {
|
|
73
|
+
// Only allow basic arithmetic operations for safety.
|
|
74
|
+
const sanitizedInput = input.replace(/[^0-9+\-*/().\s]/g, '');
|
|
75
|
+
// eslint-disable-next-line no-new-func
|
|
76
|
+
return Function(`"use strict"; return (${sanitizedInput})`)();
|
|
77
|
+
})();
|
|
78
|
+
|
|
79
|
+
yield* Console.log(`Executing calculation: ${input} = ${result}`);
|
|
80
|
+
return { result };
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Providers.
|
|
85
|
+
const OpenAiLayer = OpenAiClient.layerConfig({
|
|
86
|
+
apiKey: Config.redacted('OPENAI_API_KEY'),
|
|
87
|
+
}).pipe(Layer.provide(NodeHttpClient.layerUndici));
|
|
88
|
+
|
|
89
|
+
const AnthropicLayer = AnthropicClient.layerConfig({
|
|
90
|
+
apiKey: Config.redacted('ANTHROPIC_API_KEY'),
|
|
91
|
+
}).pipe(Layer.provide(NodeHttpClient.layerUndici));
|
|
92
|
+
|
|
93
|
+
it.runIf(process.env.OPENAI_API_KEY)('should make a tool call', async ({ expect }) => {
|
|
94
|
+
const createProgram = (prompt: string) =>
|
|
95
|
+
AiLanguageModel.generateText({
|
|
96
|
+
toolkit: Toolkit,
|
|
97
|
+
prompt,
|
|
98
|
+
}).pipe(
|
|
99
|
+
Effect.tap((response) => Console.log(response)),
|
|
100
|
+
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
101
|
+
Effect.retry(pipe(Schedule.exponential('1 second'), Schedule.intersect(Schedule.recurs(2)))),
|
|
102
|
+
Effect.timeout('30 seconds'),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const program = createProgram('What is six times seven? Use appropriate tools and just answer with the number.');
|
|
106
|
+
const result = await program.pipe(Effect.provide([ToolkitLayer, OpenAiLayer]), Effect.runPromise);
|
|
107
|
+
expect(result).toBeDefined();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// TODO(burdon): Is this the effectful way to do this?
|
|
111
|
+
const createChat = (prompt: string) =>
|
|
112
|
+
Effect.gen(function* () {
|
|
113
|
+
const chat = yield* AiChat.empty;
|
|
114
|
+
const toolkit = yield* Toolkit;
|
|
115
|
+
|
|
116
|
+
// Initial request.
|
|
117
|
+
let response = yield* chat.generateText({ toolkit, prompt });
|
|
118
|
+
|
|
119
|
+
// Agentic loop.
|
|
120
|
+
while (response.results.size > 0) {
|
|
121
|
+
response = yield* chat.generateText({ toolkit, prompt: AiInput.empty });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Done.
|
|
125
|
+
return response.text;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it.runIf(process.env.OPENAI_API_KEY)('should process an agentic loop using OpenAI', async ({ expect }) => {
|
|
129
|
+
const chat = createChat('What is six times seven?');
|
|
130
|
+
const result = await chat.pipe(
|
|
131
|
+
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
132
|
+
Effect.provide(OpenAiLayer),
|
|
133
|
+
Effect.provide(ToolkitLayer),
|
|
134
|
+
Effect.runPromise,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
log.info('result', { result });
|
|
138
|
+
expect(result).toContain('42');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// TODO(burdon): Fix Anthropic.
|
|
142
|
+
it.runIf(process.env.ANTHROPIC_API_KEY).skip('should process an agentic loop using Anthropic', async ({ expect }) => {
|
|
143
|
+
const chat = createChat('What is six times seven?');
|
|
144
|
+
const result = await chat.pipe(
|
|
145
|
+
Effect.provide(AnthropicLanguageModel.model('claude-3-5-sonnet-latest')),
|
|
146
|
+
Effect.provide(AnthropicLayer),
|
|
147
|
+
Effect.provide(ToolkitLayer),
|
|
148
|
+
Effect.runPromise,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
log.info('result', { result });
|
|
152
|
+
expect(result).toContain('42');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// TODO(burdon): Implement MCP server for ECHO on CF.
|
|
156
|
+
});
|