@dxos/assistant 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef

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.
Files changed (147) hide show
  1. package/README.md +1 -0
  2. package/dist/lib/neutral/extraction/index.mjs +202 -0
  3. package/dist/lib/neutral/extraction/index.mjs.map +7 -0
  4. package/dist/lib/neutral/index.mjs +1731 -0
  5. package/dist/lib/neutral/index.mjs.map +7 -0
  6. package/dist/lib/neutral/meta.json +1 -0
  7. package/dist/types/src/conversation/context.d.ts +120 -64
  8. package/dist/types/src/conversation/context.d.ts.map +1 -1
  9. package/dist/types/src/conversation/context.test.d.ts +2 -0
  10. package/dist/types/src/conversation/context.test.d.ts.map +1 -0
  11. package/dist/types/src/conversation/index.d.ts +1 -1
  12. package/dist/types/src/conversation/index.d.ts.map +1 -1
  13. package/dist/types/src/conversation/session.d.ts +78 -0
  14. package/dist/types/src/conversation/session.d.ts.map +1 -0
  15. package/dist/types/src/diff.d.ts +3 -1
  16. package/dist/types/src/diff.d.ts.map +1 -1
  17. package/dist/types/src/errors.d.ts +32 -40
  18. package/dist/types/src/errors.d.ts.map +1 -1
  19. package/dist/types/src/execution-graph.d.ts +5 -2
  20. package/dist/types/src/execution-graph.d.ts.map +1 -1
  21. package/dist/types/src/extraction/extraction-ner-function/index.d.ts +0 -1
  22. package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -1
  23. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  24. package/dist/types/src/extraction/extraction.d.ts +1066 -307
  25. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  26. package/dist/types/src/extraction/index.d.ts +0 -1
  27. package/dist/types/src/extraction/index.d.ts.map +1 -1
  28. package/dist/types/src/extraction/quotes.d.ts +3 -3
  29. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  30. package/dist/types/src/functions/services.d.ts +15 -16
  31. package/dist/types/src/functions/services.d.ts.map +1 -1
  32. package/dist/types/src/index.d.ts +1 -0
  33. package/dist/types/src/index.d.ts.map +1 -1
  34. package/dist/types/src/session/artifact-diff.d.ts +2 -2
  35. package/dist/types/src/session/artifact-diff.d.ts.map +1 -1
  36. package/dist/types/src/session/error-handling.d.ts +2 -2
  37. package/dist/types/src/session/error-handling.d.ts.map +1 -1
  38. package/dist/types/src/session/format.d.ts +8 -177
  39. package/dist/types/src/session/format.d.ts.map +1 -1
  40. package/dist/types/src/session/index.d.ts +2 -1
  41. package/dist/types/src/session/index.d.ts.map +1 -1
  42. package/dist/types/src/session/observer.d.ts +7 -6
  43. package/dist/types/src/session/observer.d.ts.map +1 -1
  44. package/dist/types/src/session/request.d.ts +104 -0
  45. package/dist/types/src/session/request.d.ts.map +1 -0
  46. package/dist/types/src/session/toolkit.d.ts +11 -9
  47. package/dist/types/src/session/toolkit.d.ts.map +1 -1
  48. package/dist/types/src/session/version-pin.d.ts +4 -4
  49. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  50. package/dist/types/src/templates/system.d.ts +1 -2
  51. package/dist/types/src/templates/system.d.ts.map +1 -1
  52. package/dist/types/src/tracing.d.ts +233 -0
  53. package/dist/types/src/tracing.d.ts.map +1 -0
  54. package/dist/types/src/types/artifact.d.ts +28 -0
  55. package/dist/types/src/types/artifact.d.ts.map +1 -0
  56. package/dist/types/src/types/index.d.ts +2 -0
  57. package/dist/types/src/types/index.d.ts.map +1 -0
  58. package/dist/types/tsconfig.tsbuildinfo +1 -1
  59. package/package.json +35 -47
  60. package/src/conversation/context.test.ts +52 -0
  61. package/src/conversation/context.ts +324 -75
  62. package/src/conversation/index.ts +1 -1
  63. package/src/conversation/session.ts +334 -0
  64. package/src/diff.test.ts +37 -6
  65. package/src/diff.ts +18 -4
  66. package/src/errors.ts +2 -2
  67. package/src/execution-graph.test.ts +47 -45
  68. package/src/execution-graph.ts +41 -22
  69. package/src/extraction/extraction-ner-function/index.ts +0 -1
  70. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +10 -5
  71. package/src/extraction/extraction.ts +44 -15
  72. package/src/extraction/index.ts +0 -1
  73. package/src/extraction/quotes.ts +5 -6
  74. package/src/functions/services.ts +126 -65
  75. package/src/functions.conversations.json +1 -0
  76. package/src/index.ts +1 -0
  77. package/src/session/artifact-diff.ts +2 -2
  78. package/src/session/error-handling.ts +4 -3
  79. package/src/session/format.ts +34 -26
  80. package/src/session/index.ts +2 -1
  81. package/src/session/observer.ts +8 -4
  82. package/src/session/request.conversations.json +1 -0
  83. package/src/session/request.ts +342 -0
  84. package/src/session/toolkit.ts +29 -28
  85. package/src/session/version-pin.ts +7 -7
  86. package/src/templates/{format.tpl → instructions/format.tpl} +1 -4
  87. package/src/templates/{system.tpl → instructions/system.tpl} +50 -2
  88. package/src/templates/system.ts +9 -8
  89. package/src/tracing.ts +57 -0
  90. package/src/{types.ts → types/artifact.ts} +44 -7
  91. package/src/types/index.ts +5 -0
  92. package/dist/lib/browser/chunk-ILL2CN3G.mjs +0 -374
  93. package/dist/lib/browser/chunk-ILL2CN3G.mjs.map +0 -7
  94. package/dist/lib/browser/chunk-UB26N5UF.mjs +0 -89
  95. package/dist/lib/browser/chunk-UB26N5UF.mjs.map +0 -7
  96. package/dist/lib/browser/extraction/index.mjs +0 -272
  97. package/dist/lib/browser/extraction/index.mjs.map +0 -7
  98. package/dist/lib/browser/index.mjs +0 -861
  99. package/dist/lib/browser/index.mjs.map +0 -7
  100. package/dist/lib/browser/meta.json +0 -1
  101. package/dist/lib/browser/named-entity-recognition-QPYHML66.mjs +0 -13
  102. package/dist/lib/browser/named-entity-recognition-QPYHML66.mjs.map +0 -7
  103. package/dist/lib/node-esm/chunk-BCFXTNSK.mjs +0 -91
  104. package/dist/lib/node-esm/chunk-BCFXTNSK.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-GVKA7VL3.mjs +0 -376
  106. package/dist/lib/node-esm/chunk-GVKA7VL3.mjs.map +0 -7
  107. package/dist/lib/node-esm/extraction/index.mjs +0 -273
  108. package/dist/lib/node-esm/extraction/index.mjs.map +0 -7
  109. package/dist/lib/node-esm/index.mjs +0 -862
  110. package/dist/lib/node-esm/index.mjs.map +0 -7
  111. package/dist/lib/node-esm/meta.json +0 -1
  112. package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs +0 -14
  113. package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs.map +0 -7
  114. package/dist/types/src/conversation/conversation.d.ts +0 -41
  115. package/dist/types/src/conversation/conversation.d.ts.map +0 -1
  116. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +0 -4
  117. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +0 -1
  118. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +0 -2
  119. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +0 -1
  120. package/dist/types/src/extraction/extraction-llm-function/index.d.ts +0 -2
  121. package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +0 -1
  122. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +0 -341
  123. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +0 -1
  124. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +0 -2
  125. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +0 -1
  126. package/dist/types/src/session/format.test.d.ts +0 -2
  127. package/dist/types/src/session/format.test.d.ts.map +0 -1
  128. package/dist/types/src/session/session.d.ts +0 -47
  129. package/dist/types/src/session/session.d.ts.map +0 -1
  130. package/dist/types/src/session/session.test.d.ts +0 -2
  131. package/dist/types/src/session/session.test.d.ts.map +0 -1
  132. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  133. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  134. package/dist/types/src/types.d.ts +0 -16
  135. package/dist/types/src/types.d.ts.map +0 -1
  136. package/src/conversation/conversation.ts +0 -119
  137. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +0 -84
  138. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +0 -72
  139. package/src/extraction/extraction-llm-function/index.ts +0 -5
  140. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +0 -115
  141. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +0 -64
  142. package/src/session/format.test.ts +0 -60
  143. package/src/session/session.conversations.json +0 -1
  144. package/src/session/session.test.ts +0 -146
  145. package/src/session/session.ts +0 -206
  146. package/src/summarization/summarization.test.ts +0 -201
  147. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -1,341 +0,0 @@
1
- /**
2
- * Named Entity Recognition model
3
- */
4
- export declare const extractionNerFunction: import("@dxos/functions").FunctionDefinition<{
5
- readonly options?: {
6
- readonly timeout?: number | undefined;
7
- readonly fallbackToRaw?: boolean | undefined;
8
- } | undefined;
9
- readonly message: import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
10
- id: string;
11
- parentMessage?: string | undefined;
12
- created: string;
13
- sender: {
14
- contact?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
15
- fullName?: string | undefined;
16
- preferredName?: string | undefined;
17
- nickname?: string | undefined;
18
- image?: string | undefined;
19
- organization?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
20
- id: string;
21
- description?: string | undefined;
22
- name?: string | undefined;
23
- status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
24
- image?: string | undefined;
25
- website?: string | undefined;
26
- }> | undefined;
27
- jobTitle?: string | undefined;
28
- department?: string | undefined;
29
- notes?: string | undefined;
30
- emails?: {
31
- readonly label?: string | undefined;
32
- readonly value: string;
33
- }[] | undefined;
34
- identities?: {
35
- readonly label?: string | undefined;
36
- readonly value: string;
37
- }[] | undefined;
38
- phoneNumbers?: {
39
- readonly label?: string | undefined;
40
- readonly value: string;
41
- }[] | undefined;
42
- addresses?: {
43
- readonly label?: string | undefined;
44
- readonly value: {
45
- readonly street?: string | undefined;
46
- readonly extended?: string | undefined;
47
- readonly locality?: string | undefined;
48
- readonly region?: string | undefined;
49
- readonly postalCode?: string | undefined;
50
- readonly postOfficeBoxNumber?: string | undefined;
51
- readonly country?: string | undefined;
52
- };
53
- }[] | undefined;
54
- urls?: {
55
- readonly label?: string | undefined;
56
- readonly value: string;
57
- }[] | undefined;
58
- birthday?: string | undefined;
59
- fields?: {
60
- readonly label: string;
61
- readonly value: string;
62
- readonly category?: string | undefined;
63
- }[] | undefined;
64
- }> | undefined;
65
- identityDid?: string | undefined;
66
- identityKey?: string | undefined;
67
- email?: string | undefined;
68
- name?: string | undefined;
69
- role?: "user" | "assistant" | "tool" | undefined;
70
- };
71
- blocks: ({
72
- version: unknown;
73
- _tag: "anchor";
74
- pending?: boolean | undefined;
75
- objectId: string;
76
- } | {
77
- name?: string | undefined;
78
- _tag: "file";
79
- pending?: boolean | undefined;
80
- url: string;
81
- mediaType?: string | undefined;
82
- } | {
83
- id?: string | undefined;
84
- _tag: "image";
85
- pending?: boolean | undefined;
86
- source?: {
87
- mediaType: string;
88
- type: "base64";
89
- data: string;
90
- } | {
91
- url: string;
92
- type: "http";
93
- } | undefined;
94
- } | {
95
- _tag: "json";
96
- pending?: boolean | undefined;
97
- data: string;
98
- disposition?: string | undefined;
99
- } | {
100
- text: string;
101
- _tag: "proposal";
102
- pending?: boolean | undefined;
103
- } | {
104
- _tag: "reasoning";
105
- pending?: boolean | undefined;
106
- reasoningText?: string | undefined;
107
- redactedText?: string | undefined;
108
- signature?: string | undefined;
109
- } | {
110
- reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
111
- _tag: "reference";
112
- pending?: boolean | undefined;
113
- } | {
114
- _tag: "select";
115
- pending?: boolean | undefined;
116
- options: readonly string[];
117
- } | {
118
- _tag: "status";
119
- pending?: boolean | undefined;
120
- statusText: string;
121
- } | {
122
- text: string;
123
- _tag: "suggestion";
124
- pending?: boolean | undefined;
125
- } | {
126
- _tag: "summary";
127
- pending?: boolean | undefined;
128
- mimeType?: string | undefined;
129
- message?: string | undefined;
130
- model?: string | undefined;
131
- usage?: {
132
- readonly inputTokens?: number | undefined;
133
- readonly outputTokens?: number | undefined;
134
- readonly totalTokens?: number | undefined;
135
- } | undefined;
136
- toolCalls?: number | undefined;
137
- errors?: number | undefined;
138
- duration?: number | undefined;
139
- } | {
140
- text: string;
141
- _tag: "text";
142
- pending?: boolean | undefined;
143
- disposition?: string | undefined;
144
- mimeType?: string | undefined;
145
- } | {
146
- _tag: "toolkit";
147
- pending?: boolean | undefined;
148
- } | {
149
- name: string;
150
- _tag: "toolCall";
151
- pending?: boolean | undefined;
152
- toolCallId: string;
153
- input: string;
154
- providerExecuted: boolean;
155
- } | {
156
- name: string;
157
- _tag: "toolResult";
158
- pending?: boolean | undefined;
159
- toolCallId: string;
160
- providerExecuted: boolean;
161
- result?: string | undefined;
162
- error?: string | undefined;
163
- } | {
164
- text: string;
165
- _tag: "transcript";
166
- pending?: boolean | undefined;
167
- started: string;
168
- })[];
169
- properties?: {
170
- [x: string]: any;
171
- } | undefined;
172
- };
173
- readonly objects?: readonly import("@dxos/echo-schema").Expando[] | undefined;
174
- }, {
175
- readonly message: import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
176
- id: string;
177
- parentMessage?: string | undefined;
178
- created: string;
179
- sender: {
180
- contact?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
181
- fullName?: string | undefined;
182
- preferredName?: string | undefined;
183
- nickname?: string | undefined;
184
- image?: string | undefined;
185
- organization?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
186
- id: string;
187
- description?: string | undefined;
188
- name?: string | undefined;
189
- status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
190
- image?: string | undefined;
191
- website?: string | undefined;
192
- }> | undefined;
193
- jobTitle?: string | undefined;
194
- department?: string | undefined;
195
- notes?: string | undefined;
196
- emails?: {
197
- readonly label?: string | undefined;
198
- readonly value: string;
199
- }[] | undefined;
200
- identities?: {
201
- readonly label?: string | undefined;
202
- readonly value: string;
203
- }[] | undefined;
204
- phoneNumbers?: {
205
- readonly label?: string | undefined;
206
- readonly value: string;
207
- }[] | undefined;
208
- addresses?: {
209
- readonly label?: string | undefined;
210
- readonly value: {
211
- readonly street?: string | undefined;
212
- readonly extended?: string | undefined;
213
- readonly locality?: string | undefined;
214
- readonly region?: string | undefined;
215
- readonly postalCode?: string | undefined;
216
- readonly postOfficeBoxNumber?: string | undefined;
217
- readonly country?: string | undefined;
218
- };
219
- }[] | undefined;
220
- urls?: {
221
- readonly label?: string | undefined;
222
- readonly value: string;
223
- }[] | undefined;
224
- birthday?: string | undefined;
225
- fields?: {
226
- readonly label: string;
227
- readonly value: string;
228
- readonly category?: string | undefined;
229
- }[] | undefined;
230
- }> | undefined;
231
- identityDid?: string | undefined;
232
- identityKey?: string | undefined;
233
- email?: string | undefined;
234
- name?: string | undefined;
235
- role?: "user" | "assistant" | "tool" | undefined;
236
- };
237
- blocks: ({
238
- version: unknown;
239
- _tag: "anchor";
240
- pending?: boolean | undefined;
241
- objectId: string;
242
- } | {
243
- name?: string | undefined;
244
- _tag: "file";
245
- pending?: boolean | undefined;
246
- url: string;
247
- mediaType?: string | undefined;
248
- } | {
249
- id?: string | undefined;
250
- _tag: "image";
251
- pending?: boolean | undefined;
252
- source?: {
253
- mediaType: string;
254
- type: "base64";
255
- data: string;
256
- } | {
257
- url: string;
258
- type: "http";
259
- } | undefined;
260
- } | {
261
- _tag: "json";
262
- pending?: boolean | undefined;
263
- data: string;
264
- disposition?: string | undefined;
265
- } | {
266
- text: string;
267
- _tag: "proposal";
268
- pending?: boolean | undefined;
269
- } | {
270
- _tag: "reasoning";
271
- pending?: boolean | undefined;
272
- reasoningText?: string | undefined;
273
- redactedText?: string | undefined;
274
- signature?: string | undefined;
275
- } | {
276
- reference: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").Expando>;
277
- _tag: "reference";
278
- pending?: boolean | undefined;
279
- } | {
280
- _tag: "select";
281
- pending?: boolean | undefined;
282
- options: readonly string[];
283
- } | {
284
- _tag: "status";
285
- pending?: boolean | undefined;
286
- statusText: string;
287
- } | {
288
- text: string;
289
- _tag: "suggestion";
290
- pending?: boolean | undefined;
291
- } | {
292
- _tag: "summary";
293
- pending?: boolean | undefined;
294
- mimeType?: string | undefined;
295
- message?: string | undefined;
296
- model?: string | undefined;
297
- usage?: {
298
- readonly inputTokens?: number | undefined;
299
- readonly outputTokens?: number | undefined;
300
- readonly totalTokens?: number | undefined;
301
- } | undefined;
302
- toolCalls?: number | undefined;
303
- errors?: number | undefined;
304
- duration?: number | undefined;
305
- } | {
306
- text: string;
307
- _tag: "text";
308
- pending?: boolean | undefined;
309
- disposition?: string | undefined;
310
- mimeType?: string | undefined;
311
- } | {
312
- _tag: "toolkit";
313
- pending?: boolean | undefined;
314
- } | {
315
- name: string;
316
- _tag: "toolCall";
317
- pending?: boolean | undefined;
318
- toolCallId: string;
319
- input: string;
320
- providerExecuted: boolean;
321
- } | {
322
- name: string;
323
- _tag: "toolResult";
324
- pending?: boolean | undefined;
325
- toolCallId: string;
326
- providerExecuted: boolean;
327
- result?: string | undefined;
328
- error?: string | undefined;
329
- } | {
330
- text: string;
331
- _tag: "transcript";
332
- pending?: boolean | undefined;
333
- started: string;
334
- })[];
335
- properties?: {
336
- [x: string]: any;
337
- } | undefined;
338
- };
339
- readonly timeElapsed: number;
340
- }>;
341
- //# sourceMappingURL=extraction-ner-function.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extraction-ner-function.d.ts","sourceRoot":"","sources":["../../../../../src/extraction/extraction-ner-function/extraction-ner-function.ts"],"names":[],"mappings":"AAiBA;;GAEG;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0ChC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=extraction-ner-function.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extraction-ner-function.test.d.ts","sourceRoot":"","sources":["../../../../../src/extraction/extraction-ner-function/extraction-ner-function.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=format.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.test.d.ts","sourceRoot":"","sources":["../../../../src/session/format.test.ts"],"names":[],"mappings":""}
@@ -1,47 +0,0 @@
1
- import { type AiError, LanguageModel, type Tool, type Toolkit } from '@effect/ai';
2
- import { Effect, type Schema } from 'effect';
3
- import { type AiToolNotFoundError, type PromptPreprocessingError, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
4
- import { type Blueprint } from '@dxos/blueprints';
5
- import { Obj } from '@dxos/echo';
6
- import { TracingService } from '@dxos/functions';
7
- import { DataType } from '@dxos/schema';
8
- import { type AiAssistantError } from '../errors';
9
- import { GenerationObserver } from './observer';
10
- export type AiSessionRunError = AiError.AiError | PromptPreprocessingError | AiToolNotFoundError | AiAssistantError;
11
- export type AiSessionRunRequirements = LanguageModel.LanguageModel | ToolExecutionService | ToolResolverService | TracingService;
12
- export type AiSessionRunParams<Tools extends Record<string, Tool.Any>> = {
13
- prompt: string;
14
- system?: string;
15
- history?: DataType.Message[];
16
- objects?: Obj.Any[];
17
- blueprints?: Blueprint.Blueprint[];
18
- toolkit?: Toolkit.WithHandler<Tools>;
19
- observer?: GenerationObserver;
20
- };
21
- export type AiSessionOptions = {};
22
- /**
23
- * Contains message history, tools, current context.
24
- * Current context means the state of the app, time of day, and other contextual information.
25
- * It makes requests to the model, its a state machine.
26
- * It keeps track of the current goal.
27
- * It manages the context window.
28
- * Tracks the success criteria of reaching the goal, exposing metrics (stretch).
29
- * Could be run locally in the app or remotely.
30
- * Could be personal or shared.
31
- */
32
- export declare class AiSession {
33
- private readonly _options;
34
- /** Prevents concurrent execution of session. */
35
- private readonly _semaphore;
36
- /** Message history from queue. */
37
- private _history;
38
- /** Pending messages for this session (incl. the current prompt). */
39
- private _pending;
40
- constructor(_options?: AiSessionOptions);
41
- run: <Tools extends Record<string, Tool.Any>>({ prompt, system: systemTemplate, history, objects, blueprints, toolkit, observer, }: AiSessionRunParams<Tools>) => Effect.Effect<DataType.Message[], AiSessionRunError, AiSessionRunRequirements>;
42
- /**
43
- * @deprecated
44
- */
45
- runStructured<S extends Schema.Schema.AnyNoContext>(_schema: S, _options: AiSessionRunParams<any>): Promise<Schema.Schema.Type<S>>;
46
- }
47
- //# sourceMappingURL=session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAS,MAAM,EAAE,KAAK,MAAM,EAAU,MAAM,QAAQ,CAAC;AAE5D,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAGzB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,wBAAwB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAEpH,MAAM,MAAM,wBAAwB,GAChC,aAAa,CAAC,aAAa,GAC3B,oBAAoB,GACpB,mBAAmB,GACnB,cAAc,CAAC;AAEnB,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC;;;;;;;;;GASG;AACH,qBAAa,SAAS;IAWR,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAVrC,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA2C;IAEtE,kCAAkC;IAElC,OAAO,CAAC,QAAQ,CAA0B;IAE1C,oEAAoE;IACpE,OAAO,CAAC,QAAQ,CAA0B;gBAEb,QAAQ,GAAE,gBAAqB;IAE5D,GAAG,GAAI,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,sFAQ5C,kBAAkB,CAAC,KAAK,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,wBAAwB,CAAC,CA+FjC;IAE5E;;OAEG;IAEG,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,EACtD,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CASlC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=session.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.test.d.ts","sourceRoot":"","sources":["../../../../src/session/session.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=summarization.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"summarization.test.d.ts","sourceRoot":"","sources":["../../../../src/summarization/summarization.test.ts"],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { type ObjectId } from '@dxos/echo-schema';
3
- import { DXN, type SpaceId } from '@dxos/keys';
4
- /**
5
- * @deprecated
6
- */
7
- export declare const createArtifactElement: (id: ObjectId) => string;
8
- /**
9
- * A model-friendly way to reference an object.
10
- * Supports vairous formats that will be normalized to a DXN.
11
- */
12
- export declare const ArtifactId: Schema.Schema<string> & {
13
- toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;
14
- };
15
- export type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;
16
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAmB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,IAAI,QAAQ,WAA4B,CAAC;AAE/E;;;GAGG;AAEH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;IAC/C,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC;CA4BhE,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,119 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Toolkit } from '@effect/ai';
6
- import { Array, Effect, Option } from 'effect';
7
-
8
- import { Obj } from '@dxos/echo';
9
- import { type Queue } from '@dxos/echo-db';
10
- import { DatabaseService } from '@dxos/functions';
11
- import { log } from '@dxos/log';
12
- import { DataType } from '@dxos/schema';
13
-
14
- import {
15
- AiSession,
16
- type AiSessionRunError,
17
- type AiSessionRunRequirements,
18
- type GenerationObserver,
19
- createToolkit,
20
- } from '../session';
21
-
22
- import { AiContextBinder, AiContextService, type ContextBinding } from './context';
23
-
24
- export interface AiConversationRunParams {
25
- prompt: string;
26
- system?: string;
27
- observer?: GenerationObserver;
28
- }
29
-
30
- export type AiConversationOptions = {
31
- queue: Queue<DataType.Message | ContextBinding>;
32
- };
33
-
34
- /**
35
- * Durable conversation state (initiated by users and agents) backed by a Queue.
36
- * Executes tools based on AI responses and supports cancellation of in-progress requests.
37
- */
38
- export class AiConversation {
39
- /**
40
- * Message and binding queue.
41
- */
42
- private readonly _queue: Queue<DataType.Message | ContextBinding>;
43
-
44
- /**
45
- * Blueprints bound to the conversation.
46
- */
47
- private readonly _context: AiContextBinder;
48
-
49
- /**
50
- * Toolkit from the current session request.
51
- */
52
- private _toolkit: Toolkit.WithHandler<any> | undefined;
53
-
54
- public constructor(options: AiConversationOptions) {
55
- this._queue = options.queue;
56
- this._context = new AiContextBinder(this._queue);
57
- }
58
-
59
- public get context() {
60
- return this._context;
61
- }
62
-
63
- public get toolkit() {
64
- return this._toolkit;
65
- }
66
-
67
- public async getHistory(): Promise<DataType.Message[]> {
68
- const queueItems = await this._queue.queryObjects();
69
- return queueItems.filter(Obj.instanceOf(DataType.Message));
70
- }
71
-
72
- /**
73
- * Creates a new cancelable request effect.
74
- */
75
- createRequest(
76
- params: AiConversationRunParams,
77
- ): Effect.Effect<DataType.Message[], AiSessionRunError, AiSessionRunRequirements> {
78
- return Effect.gen(this, function* () {
79
- const session = new AiSession();
80
- const history = yield* Effect.promise(() => this.getHistory());
81
-
82
- // Get context objects.
83
- const context = yield* Effect.promise(() => this.context.query());
84
- const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.loadOption).pipe(
85
- Effect.map(Array.filter(Option.isSome)),
86
- Effect.map(Array.map((option) => option.value)),
87
- );
88
- const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.loadOption).pipe(
89
- Effect.map(Array.filter(Option.isSome)),
90
- Effect.map(Array.map((option) => option.value)),
91
- );
92
-
93
- // Create toolkit.
94
- const toolkit = yield* createToolkit({ blueprints });
95
- this._toolkit = toolkit;
96
-
97
- const start = Date.now();
98
- log('run', {
99
- history: history.length,
100
- blueprints: blueprints.length,
101
- objects: objects.length,
102
- tools: this._toolkit?.tools.length ?? 0,
103
- });
104
-
105
- // Process request.
106
- const messages = yield* session.run({ history, blueprints, objects, toolkit, ...params }).pipe(
107
- Effect.provideService(AiContextService, {
108
- binder: this.context,
109
- }),
110
- );
111
-
112
- log('result', { messages: messages.length, duration: Date.now() - start });
113
-
114
- // Append to queue.
115
- yield* Effect.promise(() => this._queue.append(messages));
116
- return messages;
117
- }).pipe(Effect.withSpan('AiConversation.request'));
118
- }
119
- }
@@ -1,84 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { beforeAll, describe, test } from 'vitest';
6
-
7
- import { todo } from '@dxos/debug';
8
- import { FunctionExecutor } from '@dxos/functions';
9
- import { log } from '@dxos/log';
10
- import { createTestData } from '@dxos/schema/testing';
11
- import { range } from '@dxos/util';
12
-
13
- import { processTranscriptMessage } from '../extraction';
14
-
15
- import { extractionAnthropicFunction } from './extraction-llm-function';
16
-
17
- // TODO(burdon): Rewrite test.
18
- describe.skip('LLM EntityExtraction', () => {
19
- let executor: FunctionExecutor;
20
-
21
- beforeAll(async () => {
22
- executor = new FunctionExecutor(todo());
23
- });
24
-
25
- test('should process a transcript block', async () => {
26
- const { transcriptMessages, documents, contacts } = createTestData();
27
- log.info('context', { documents, contacts });
28
-
29
- for (const message of transcriptMessages.slice(0, 1)) {
30
- log.info('input', message);
31
- const { message: enhancedMessage } = await processTranscriptMessage({
32
- input: {
33
- message,
34
- objects: [...documents, ...Object.values(contacts)],
35
- },
36
- function: extractionAnthropicFunction,
37
- executor,
38
- });
39
- log.info('output', enhancedMessage);
40
- }
41
- });
42
-
43
- test('computational irreducibility', async () => {
44
- const { transcriptWoflram, documents, contacts } = createTestData();
45
- log.info('context', { documents, contacts });
46
-
47
- const message = transcriptWoflram[0];
48
- log.info('input', message);
49
-
50
- await Promise.all(
51
- range(10).map(async () => {
52
- const { message: enhancedMessage, timeElapsed } = await processTranscriptMessage({
53
- input: {
54
- message,
55
- objects: [...documents, ...Object.values(contacts)],
56
- },
57
- function: extractionAnthropicFunction,
58
- executor,
59
- });
60
-
61
- log.info('output', { message: enhancedMessage.blocks[0], timeElapsed });
62
- }),
63
- );
64
- });
65
-
66
- test('org and document linking', async () => {
67
- const { transcriptJosiah, documents, contacts, organizations } = createTestData();
68
- log.info('context', { contacts, organizations, documents });
69
-
70
- for (const message of transcriptJosiah) {
71
- log.info('input', message);
72
- const { message: enhancedMessage } = await processTranscriptMessage({
73
- input: {
74
- message,
75
- objects: [...documents, ...Object.values(contacts), ...Object.values(organizations)],
76
- },
77
- function: extractionAnthropicFunction,
78
- executor,
79
- });
80
-
81
- log.info('output', enhancedMessage);
82
- }
83
- });
84
- });