@dxos/assistant 0.8.2-main.f11618f → 0.8.2-staging.7ac8446

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 (77) hide show
  1. package/dist/lib/browser/{chunk-DEIGOD4U.mjs → chunk-PND5VR6D.mjs} +84 -91
  2. package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +153 -275
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +25 -25
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-7VH7NMIM.cjs → chunk-IBOBRBDF.cjs} +98 -106
  9. package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +183 -302
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +33 -33
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/{chunk-7JI4MDGL.mjs → chunk-DCQJOLSR.mjs} +84 -91
  16. package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +153 -275
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +25 -25
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/ai-service/edge-client.d.ts +5 -4
  23. package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/message-collector.d.ts +6 -0
  25. package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
  26. package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
  27. package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
  28. package/dist/types/src/ai-service/parser.d.ts +3 -0
  29. package/dist/types/src/ai-service/parser.d.ts.map +1 -1
  30. package/dist/types/src/ai-service/service.d.ts +2 -18
  31. package/dist/types/src/ai-service/service.d.ts.map +1 -1
  32. package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
  33. package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
  34. package/dist/types/src/ai-service/types.d.ts +9 -52
  35. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  36. package/dist/types/src/conversation/conversation.d.ts +3 -0
  37. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  38. package/dist/types/src/conversation/types.d.ts +3 -2
  39. package/dist/types/src/conversation/types.d.ts.map +1 -1
  40. package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
  41. package/dist/types/src/session/index.d.ts +0 -1
  42. package/dist/types/src/session/index.d.ts.map +1 -1
  43. package/dist/types/src/session/session.d.ts +10 -29
  44. package/dist/types/src/session/session.d.ts.map +1 -1
  45. package/dist/types/src/testing/test-schema.d.ts +2 -2
  46. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  47. package/package.json +13 -13
  48. package/src/ai-service/client.test.ts +68 -50
  49. package/src/ai-service/edge-client.ts +20 -13
  50. package/src/ai-service/ollama-client.ts +2 -9
  51. package/src/ai-service/parser.ts +2 -13
  52. package/src/ai-service/service.ts +3 -19
  53. package/src/ai-service/testing/mock.ts +1 -9
  54. package/src/ai-service/types.ts +6 -15
  55. package/src/bin/chat.ts +3 -3
  56. package/src/conversation/conversation.ts +11 -5
  57. package/src/conversation/types.ts +4 -1
  58. package/src/cypher/combinators.test.ts +4 -4
  59. package/src/cypher/echo-data-source.ts +2 -1
  60. package/src/cypher/execution-plan.test.ts +1 -1
  61. package/src/cypher/query-executor.test.ts +1 -1
  62. package/src/cypher/schema.test.ts +3 -3
  63. package/src/session/index.ts +0 -1
  64. package/src/session/session.test.ts +7 -8
  65. package/src/session/session.ts +148 -284
  66. package/src/testing/query.test.ts +19 -17
  67. package/src/testing/test-data.ts +22 -22
  68. package/src/testing/test-schema.ts +3 -3
  69. package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +0 -7
  70. package/dist/lib/node/chunk-7VH7NMIM.cjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +0 -7
  72. package/dist/types/src/session/version-pin.d.ts +0 -17
  73. package/dist/types/src/session/version-pin.d.ts.map +0 -1
  74. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  75. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  76. package/src/session/version-pin.test.ts +0 -26
  77. package/src/session/version-pin.ts +0 -43
@@ -7,7 +7,6 @@ import {
7
7
  DEFAULT_OLLAMA_MODELS,
8
8
  EchoDataSource,
9
9
  GenerateRequest,
10
- GenerateResponse,
11
10
  GenerationStreamImpl,
12
11
  LLMModel,
13
12
  MessageCollector,
@@ -29,48 +28,15 @@ import {
29
28
  parseCypherQuery,
30
29
  runLLM,
31
30
  runTools
32
- } from "./chunk-DEIGOD4U.mjs";
31
+ } from "./chunk-PND5VR6D.mjs";
33
32
 
34
33
  // packages/experimental/assistant/src/session/session.ts
35
- import { Option, Schema as S } from "effect";
34
+ import { Schema as S } from "effect";
36
35
  import { defineTool, Message, ToolResult } from "@dxos/artifact";
37
36
  import { Event, synchronized } from "@dxos/async";
38
- import { ObjectVersion } from "@dxos/echo-db";
39
- import { create } from "@dxos/echo-schema";
37
+ import { createStatic } from "@dxos/echo-schema";
40
38
  import { invariant } from "@dxos/invariant";
41
39
  import { log } from "@dxos/log";
42
-
43
- // packages/experimental/assistant/src/session/version-pin.ts
44
- import { Schema } from "effect";
45
- import { getVersion } from "@dxos/echo-db";
46
- import { ObjectId } from "@dxos/echo-schema";
47
- var ObjectVersionSchema = Schema.Unknown;
48
- var VersionPinSchema = Schema.Struct({
49
- // TODO(dmaretskyi): Use Ref when those support encoding.
50
- objectId: ObjectId,
51
- // TODO(dmaretskyi): Could be opaque
52
- version: ObjectVersionSchema
53
- });
54
- var VersionPin = class extends VersionPinSchema {
55
- static {
56
- this.DISPOSITION = "version-pin";
57
- }
58
- static fromObject(object) {
59
- return VersionPin.make({
60
- objectId: object.id,
61
- version: getVersion(object)
62
- });
63
- }
64
- static createBlock(pin) {
65
- return {
66
- type: "json",
67
- disposition: VersionPin.DISPOSITION,
68
- json: JSON.stringify(pin)
69
- };
70
- }
71
- };
72
-
73
- // packages/experimental/assistant/src/session/session.ts
74
40
  function _ts_decorate(decorators, target, key, desc) {
75
41
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
76
42
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -94,28 +60,152 @@ var AISession = class _AISession {
94
60
  });
95
61
  }
96
62
  async run(options) {
97
- const systemTools = [];
63
+ const systemTools = [
64
+ defineTool("system", {
65
+ name: "query_artifact_definitions",
66
+ description: "Query the available artifact definitions",
67
+ schema: S.Struct({}),
68
+ execute: async () => {
69
+ return ToolResult.Success({
70
+ artifactDefinitions: options.artifacts.map((artifact) => ({
71
+ id: artifact.id,
72
+ name: artifact.name,
73
+ description: artifact.description
74
+ }))
75
+ });
76
+ }
77
+ })
78
+ ];
98
79
  switch (this._options.operationModel) {
99
80
  case "planning":
100
- systemTools.push(this._createQueryArtifactsTool(options.artifacts), this._createPlanningTool(options));
101
- break;
102
- case "importing":
103
- systemTools.push(this._createQueryArtifactsTool(options.artifacts), this._createRequireTool(options.artifacts, (artifactDefinitionIds) => {
104
- for (const artifactDefinitionId of artifactDefinitionIds) {
105
- requiredArtifactIds.add(artifactDefinitionId);
81
+ systemTools.push(defineTool("system", {
82
+ name: "create_plan",
83
+ description: "Create a plan. Make sure that each step is independent and can be executed solely on the data returned by the previous step. The steps only share the data that is specified in the plan.",
84
+ schema: S.Struct({
85
+ goal: S.String.annotations({
86
+ description: "The goal that the plan will achieve."
87
+ }),
88
+ steps: S.Array(S.Struct({
89
+ action: S.String.annotations({
90
+ description: "Complete, detailed action to perform."
91
+ }),
92
+ input: S.String.annotations({
93
+ description: "The required input data for this step. First step must not require any data."
94
+ }),
95
+ output: S.String.annotations({
96
+ description: "The output data from this step. This is passed to the next step as input."
97
+ }),
98
+ requiredArtifactIds: S.Array(S.String).annotations({
99
+ description: "The ids of the artifacts required to perform this step.",
100
+ examples: [
101
+ [
102
+ "artifact:dxos.org/example/Test"
103
+ ]
104
+ ]
105
+ })
106
+ })).annotations({
107
+ description: "Steps"
108
+ })
109
+ }),
110
+ execute: async ({ goal, steps }) => {
111
+ const missingArtifactIds = steps.flatMap((step) => step.requiredArtifactIds).filter((artifactId) => !options.artifacts.some((artifact) => artifact.id === artifactId));
112
+ if (missingArtifactIds.length > 0) {
113
+ return ToolResult.Error(`One or more artifact ids are invalid: ${missingArtifactIds.join(", ")}`);
114
+ }
115
+ const stepResults = [];
116
+ for (const step of steps) {
117
+ log("executing step", {
118
+ action: step.action
119
+ }, {
120
+ F: __dxlog_file,
121
+ L: 160,
122
+ S: this,
123
+ C: (f, a) => f(...a)
124
+ });
125
+ const session = new _AISession({
126
+ operationModel: "immediate"
127
+ });
128
+ session.message.on((ev) => this.message.emit(ev));
129
+ session.block.on((ev) => this.block.emit(ev));
130
+ session.update.on((ev) => this.update.emit(ev));
131
+ session.streamEvent.on((ev) => this.streamEvent.emit(ev));
132
+ session.userMessage.on((ev) => this.userMessage.emit(ev));
133
+ const messages = await session.run({
134
+ client: options.client,
135
+ artifacts: options.artifacts,
136
+ tools: options.tools,
137
+ history: options.history,
138
+ extensions: options.extensions,
139
+ generationOptions: options.generationOptions,
140
+ requiredArtifactIds: step.requiredArtifactIds.slice(),
141
+ prompt: `
142
+ You are an agent that executes the subtask in a plan.
143
+
144
+ While you know the plan's goal only focus on your subtask
145
+ Use the data from the previous step to complete your task.
146
+ Return all of the data from "output" in your last message.
147
+
148
+ Current step (that you need to complete):
149
+ ${JSON.stringify({
150
+ goal,
151
+ input: step.input,
152
+ output: step.output,
153
+ yourTask: step.action
154
+ }, null, 2)}
155
+
156
+ Previous step results:
157
+ ${JSON.stringify(stepResults.at(-1))}.
158
+ `
159
+ });
160
+ const result = messages.at(-1);
161
+ stepResults.push(result);
162
+ }
163
+ return ToolResult.Success({
164
+ stepResults
165
+ });
106
166
  }
107
167
  }));
108
168
  break;
109
- case "configured":
169
+ case "immediate":
170
+ systemTools.push(defineTool("system", {
171
+ name: "require_artifact_definitions",
172
+ description: "Require the use of specific artifact definitions. This will allow the model to interact with artifact definitions and use their tools.",
173
+ schema: S.Struct({
174
+ artifactDefinitionIds: S.Array(S.String).annotations({
175
+ description: "The ids of the artifact definitions to require",
176
+ examples: [
177
+ [
178
+ "artifact:dxos.org/example/Test"
179
+ ]
180
+ ]
181
+ })
182
+ }),
183
+ execute: async ({ artifactDefinitionIds }) => {
184
+ const missingArtifactDefinitionIds = artifactDefinitionIds.filter((artifactId) => !options.artifacts.some((artifact) => artifact.id === artifactId));
185
+ if (missingArtifactDefinitionIds.length > 0) {
186
+ return ToolResult.Error(`One or more artifact definition ids are invalid: ${missingArtifactDefinitionIds.join(", ")}`);
187
+ }
188
+ for (const artifactDefinitionId of artifactDefinitionIds) {
189
+ requiredArtifactIds.add(artifactDefinitionId);
190
+ }
191
+ return ToolResult.Success({});
192
+ }
193
+ }));
110
194
  break;
111
- default:
112
- throw new TypeError(`Invalid operation model: ${this._options.operationModel}`);
113
195
  }
114
196
  this._history = [
115
197
  ...options.history
116
198
  ];
117
199
  this._pending = [
118
- await this._formatUserPrompt(options.artifactDiffResolver, options.prompt, options.history)
200
+ createStatic(Message, {
201
+ role: "user",
202
+ content: [
203
+ {
204
+ type: "text",
205
+ text: options.prompt
206
+ }
207
+ ]
208
+ })
119
209
  ];
120
210
  this.userMessage.emit(this._pending.at(-1));
121
211
  this._stream = void 0;
@@ -135,11 +225,11 @@ var AISession = class _AISession {
135
225
  tools: tools.map((tool) => tool.name)
136
226
  }, {
137
227
  F: __dxlog_file,
138
- L: 180,
228
+ L: 264,
139
229
  S: this,
140
230
  C: (f, a) => f(...a)
141
231
  });
142
- this._stream = await options.client.execStream({
232
+ this._stream = await options.client.exec({
143
233
  ...options.generationOptions ?? {},
144
234
  // TODO(burdon): Rename messages or separate history/message.
145
235
  history: [
@@ -158,7 +248,7 @@ var AISession = class _AISession {
158
248
  pending: this._pending
159
249
  }, {
160
250
  F: __dxlog_file,
161
- L: 205,
251
+ L: 289,
162
252
  S: this,
163
253
  C: (f, a) => f(...a)
164
254
  });
@@ -166,7 +256,7 @@ var AISession = class _AISession {
166
256
  const message = this._pending.at(-1);
167
257
  invariant(message, void 0, {
168
258
  F: __dxlog_file,
169
- L: 210,
259
+ L: 294,
170
260
  S: this,
171
261
  A: [
172
262
  "message",
@@ -176,7 +266,7 @@ var AISession = class _AISession {
176
266
  if (isToolUse(message)) {
177
267
  log("tool request...", void 0, {
178
268
  F: __dxlog_file,
179
- L: 212,
269
+ L: 296,
180
270
  S: this,
181
271
  C: (f, a) => f(...a)
182
272
  });
@@ -189,7 +279,7 @@ var AISession = class _AISession {
189
279
  response
190
280
  }, {
191
281
  F: __dxlog_file,
192
- L: 219,
282
+ L: 303,
193
283
  S: this,
194
284
  C: (f, a) => f(...a)
195
285
  });
@@ -209,7 +299,7 @@ var AISession = class _AISession {
209
299
  } catch (err) {
210
300
  log.catch(err, void 0, {
211
301
  F: __dxlog_file,
212
- L: 231,
302
+ L: 315,
213
303
  S: this,
214
304
  C: (f, a) => f(...a)
215
305
  });
@@ -230,180 +320,6 @@ var AISession = class _AISession {
230
320
  }
231
321
  return this._pending;
232
322
  }
233
- async _formatUserPrompt(artifactDiffResolver, prompt, history) {
234
- const prelude = [];
235
- if (artifactDiffResolver) {
236
- const versions = gatherObjectVersions(history);
237
- const artifactDiff = await artifactDiffResolver(Array.from(versions.entries()).map(([id, version]) => ({
238
- id,
239
- lastVersion: version
240
- })));
241
- log.info("vision", {
242
- artifactDiff,
243
- versions
244
- }, {
245
- F: __dxlog_file,
246
- L: 262,
247
- S: this,
248
- C: (f, a) => f(...a)
249
- });
250
- for (const [id, { version }] of [
251
- ...artifactDiff.entries()
252
- ]) {
253
- if (ObjectVersion.equals(version, versions.get(id))) {
254
- artifactDiff.delete(id);
255
- continue;
256
- }
257
- prelude.push(VersionPin.createBlock(VersionPin.make({
258
- objectId: id,
259
- version
260
- })));
261
- }
262
- if (artifactDiff.size > 0) {
263
- prelude.push(createArtifactUpdateBlock(artifactDiff));
264
- }
265
- }
266
- return create(Message, {
267
- role: "user",
268
- content: [
269
- ...prelude,
270
- {
271
- type: "text",
272
- text: prompt
273
- }
274
- ]
275
- });
276
- }
277
- _createQueryArtifactsTool(artifacts) {
278
- return defineTool("system", {
279
- name: "query_artifact_definitions",
280
- description: "Query the available artifact definitions",
281
- schema: S.Struct({}),
282
- execute: async () => {
283
- return ToolResult.Success({
284
- artifactDefinitions: artifacts.map((artifact) => ({
285
- id: artifact.id,
286
- name: artifact.name,
287
- description: artifact.description
288
- }))
289
- });
290
- }
291
- });
292
- }
293
- _createRequireTool(artifacts, onRequire) {
294
- return defineTool("system", {
295
- name: "require_artifact_definitions",
296
- description: "Require the use of specific artifact definitions. This will allow the model to interact with artifact definitions and use their tools.",
297
- schema: S.Struct({
298
- artifactDefinitionIds: S.Array(S.String).annotations({
299
- description: "The ids of the artifact definitions to require",
300
- examples: [
301
- [
302
- "artifact:dxos.org/example/Test"
303
- ]
304
- ]
305
- })
306
- }),
307
- execute: async ({ artifactDefinitionIds }) => {
308
- const missingArtifactDefinitionIds = artifactDefinitionIds.filter((artifactId) => !artifacts.some((artifact) => artifact.id === artifactId));
309
- if (missingArtifactDefinitionIds.length > 0) {
310
- return ToolResult.Error(`One or more artifact definition ids are invalid: ${missingArtifactDefinitionIds.join(", ")}`);
311
- }
312
- onRequire(artifactDefinitionIds);
313
- return ToolResult.Success({});
314
- }
315
- });
316
- }
317
- _createPlanningTool(options) {
318
- return defineTool("system", {
319
- name: "create_plan",
320
- description: "Create a plan. Make sure that each step is independent and can be executed solely on the data returned by the previous step. The steps only share the data that is specified in the plan.",
321
- schema: S.Struct({
322
- goal: S.String.annotations({
323
- description: "The goal that the plan will achieve."
324
- }),
325
- steps: S.Array(S.Struct({
326
- action: S.String.annotations({
327
- description: "Complete, detailed action to perform."
328
- }),
329
- input: S.String.annotations({
330
- description: "The required input data for this step. First step must not require any data."
331
- }),
332
- output: S.String.annotations({
333
- description: "The output data from this step. This is passed to the next step as input."
334
- }),
335
- requiredArtifactIds: S.Array(S.String).annotations({
336
- description: "The ids of the artifacts required to perform this step.",
337
- examples: [
338
- [
339
- "artifact:dxos.org/example/Test"
340
- ]
341
- ]
342
- })
343
- })).annotations({
344
- description: "Steps"
345
- })
346
- }),
347
- execute: async ({ goal, steps }) => {
348
- const missingArtifactIds = steps.flatMap((step) => step.requiredArtifactIds).filter((artifactId) => !options.artifacts.some((artifact) => artifact.id === artifactId));
349
- if (missingArtifactIds.length > 0) {
350
- return ToolResult.Error(`One or more artifact ids are invalid: ${missingArtifactIds.join(", ")}`);
351
- }
352
- const stepResults = [];
353
- for (const step of steps) {
354
- log("executing step", {
355
- action: step.action
356
- }, {
357
- F: __dxlog_file,
358
- L: 369,
359
- S: this,
360
- C: (f, a) => f(...a)
361
- });
362
- const session = new _AISession({
363
- operationModel: "importing"
364
- });
365
- session.message.on((ev) => this.message.emit(ev));
366
- session.block.on((ev) => this.block.emit(ev));
367
- session.update.on((ev) => this.update.emit(ev));
368
- session.streamEvent.on((ev) => this.streamEvent.emit(ev));
369
- session.userMessage.on((ev) => this.userMessage.emit(ev));
370
- const messages = await session.run({
371
- client: options.client,
372
- artifacts: options.artifacts,
373
- tools: options.tools,
374
- history: options.history,
375
- extensions: options.extensions,
376
- generationOptions: options.generationOptions,
377
- requiredArtifactIds: step.requiredArtifactIds.slice(),
378
- artifactDiffResolver: options.artifactDiffResolver,
379
- prompt: `
380
- You are an agent that executes the subtask in a plan.
381
-
382
- While you know the plan's goal only focus on your subtask
383
- Use the data from the previous step to complete your task.
384
- Return all of the data from "output" in your last message.
385
-
386
- Current step (that you need to complete):
387
- ${JSON.stringify({
388
- goal,
389
- input: step.input,
390
- output: step.output,
391
- yourTask: step.action
392
- }, null, 2)}
393
-
394
- Previous step results:
395
- ${JSON.stringify(stepResults.at(-1))}.
396
- `
397
- });
398
- const result = messages.at(-1);
399
- stepResults.push(result);
400
- }
401
- return ToolResult.Success({
402
- stepResults
403
- });
404
- }
405
- });
406
- }
407
323
  abort() {
408
324
  this._stream?.abort();
409
325
  }
@@ -421,57 +337,21 @@ var createBaseInstructions = ({ availableArtifacts, operationModel }) => `
421
337
  Decision-making:
422
338
 
423
339
  - Analyze the structure and type of the content in the user's message.
424
-
425
-
340
+ - Can you complete the task using the available artifacts?
341
+ - If you can't complete the task using the available artifacts, query the list of available artifacts using the appropriate tool.
342
+ - Identify which artifacts are relevant to the user's request.
426
343
  ${operationModel === "planning" ? `
427
- - Can you complete the task using the available artifacts?
428
- - If you can't complete the task using the available artifacts, query the list of available artifacts using the appropriate tool.
429
- - Identify which artifacts are relevant to the user's request.
430
344
  - Break down the user's request into a step-by-step plan that you will use to execute the user's request, the plan items should include artifacts which will be used to perform the actions.
431
- ` : ""}
432
- ${operationModel === "importing" ? `
433
- - Can you complete the task using the available artifacts?
434
- - If you can't complete the task using the available artifacts, query the list of available artifacts using the appropriate tool.
435
- - Identify which artifacts are relevant to the user's request.
436
- - Are the required artifacts already available?
437
- - If not, select which artifact(s) will be the most relevant and require them using the require_artifacts tool.
438
- - The require'd artifact tools will be available for use after require.
439
- ` : ""}
440
- ${operationModel === "configured" ? `
441
- - Select the most relevant artifact(s) to complete the task.
442
- - Call the appropriate tool to use the artifact(s).
443
- ` : ""}
345
+ ` : `
346
+ - Are the required artifacts already available?
347
+ - If not, select which artifact(s) will be the most relevant and require them using the require_artifacts tool.
348
+ - The require'd artifact tools will be available for use after require.
349
+ `}
444
350
 
445
351
  ${availableArtifacts.length > 0 ? `Artifacts already in context: ${availableArtifacts.join("\n")}` : ""}
446
352
  `;
447
353
  var AIServiecOverloadedError = class extends S.TaggedError()("AIServiecOverloadedError", {}) {
448
354
  };
449
- var gatherObjectVersions = (messages) => {
450
- const artifactIds = /* @__PURE__ */ new Map();
451
- for (const message of messages) {
452
- for (const block of message.content) {
453
- if (block.type === "json" && block.disposition === VersionPin.DISPOSITION) {
454
- const pin = VersionPin.pipe(S.decodeOption)(JSON.parse(block.json)).pipe(Option.getOrUndefined);
455
- if (!pin) {
456
- continue;
457
- }
458
- artifactIds.set(pin.objectId, pin.version);
459
- }
460
- }
461
- }
462
- return artifactIds;
463
- };
464
- var createArtifactUpdateBlock = (artifactDiff) => {
465
- return {
466
- type: "text",
467
- disposition: "artifact-update",
468
- text: `
469
- The following artifacts have been updated since the last message:
470
- ${Array.from(artifactDiff.entries()).map(([id, { diff }]) => `<changed-artifact id="${id}">${diff ? `
471
- ${diff}` : ""}</changed-artifact>`).join("\n")}
472
- `
473
- };
474
- };
475
355
  export {
476
356
  AIServiceEdgeClient,
477
357
  AIServiecOverloadedError,
@@ -483,7 +363,6 @@ export {
483
363
  DEFAULT_OLLAMA_MODELS,
484
364
  EchoDataSource,
485
365
  GenerateRequest,
486
- GenerateResponse,
487
366
  GenerationStreamImpl,
488
367
  LLMModel,
489
368
  MessageCollector,
@@ -491,7 +370,6 @@ export {
491
370
  OllamaClient,
492
371
  StreamTransform,
493
372
  ToolTypes,
494
- VersionPin,
495
373
  createArtifactElement,
496
374
  createGenerationStream,
497
375
  emitMessageAsEvents,