@dxos/assistant 0.7.4 → 0.7.5-labs.071a3e2

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 (115) hide show
  1. package/dist/lib/browser/chunk-AXUUNA7O.mjs +565 -0
  2. package/dist/lib/browser/chunk-AXUUNA7O.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1212 -47
  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 +15 -9
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/chunk-QPHGQINW.cjs +577 -0
  9. package/dist/lib/node/chunk-QPHGQINW.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +1212 -54
  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 +21 -14
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs +567 -0
  16. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +1212 -47
  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 +15 -9
  21. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  22. package/dist/types/src/ai-service/client.d.ts +16 -32
  23. package/dist/types/src/ai-service/client.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/index.d.ts +4 -1
  25. package/dist/types/src/ai-service/index.d.ts.map +1 -1
  26. package/dist/types/src/ai-service/parser.d.ts +136 -0
  27. package/dist/types/src/ai-service/parser.d.ts.map +1 -0
  28. package/dist/types/src/ai-service/stream.d.ts +39 -0
  29. package/dist/types/src/ai-service/stream.d.ts.map +1 -0
  30. package/dist/types/src/ai-service/stream.test.d.ts +2 -0
  31. package/dist/types/src/ai-service/stream.test.d.ts.map +1 -0
  32. package/dist/types/src/ai-service/testing.d.ts +7 -0
  33. package/dist/types/src/ai-service/testing.d.ts.map +1 -0
  34. package/dist/types/src/ai-service/transform.d.ts +27 -0
  35. package/dist/types/src/ai-service/transform.d.ts.map +1 -0
  36. package/dist/types/src/ai-service/types.d.ts +150 -0
  37. package/dist/types/src/ai-service/types.d.ts.map +1 -0
  38. package/dist/types/src/ai-service/util/index.d.ts +2 -0
  39. package/dist/types/src/ai-service/util/index.d.ts.map +1 -0
  40. package/dist/types/src/ai-service/{sse.d.ts → util/sse.d.ts} +5 -0
  41. package/dist/types/src/ai-service/util/sse.d.ts.map +1 -0
  42. package/dist/types/src/conversation/conversation.d.ts +61 -6
  43. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  44. package/dist/types/src/conversation/index.d.ts +0 -1
  45. package/dist/types/src/conversation/index.d.ts.map +1 -1
  46. package/dist/types/src/conversation/types.d.ts +44 -13
  47. package/dist/types/src/conversation/types.d.ts.map +1 -1
  48. package/dist/types/src/cypher/combinators.d.ts.map +1 -1
  49. package/dist/types/src/cypher/parjs.d.ts +1 -1
  50. package/dist/types/src/cypher/parjs.d.ts.map +1 -1
  51. package/dist/types/src/cypher/schema.d.ts.map +1 -1
  52. package/dist/types/src/testing/artifacts.test.d.ts +1 -0
  53. package/dist/types/src/testing/artifacts.test.d.ts.map +1 -0
  54. package/dist/types/src/testing/data.d.ts +2 -0
  55. package/dist/types/src/testing/data.d.ts.map +1 -0
  56. package/dist/types/src/testing/defs.d.ts +5 -0
  57. package/dist/types/src/testing/defs.d.ts.map +1 -0
  58. package/dist/types/src/testing/index.d.ts +1 -0
  59. package/dist/types/src/testing/index.d.ts.map +1 -1
  60. package/dist/types/src/testing/logger.d.ts +1 -1
  61. package/dist/types/src/testing/logger.d.ts.map +1 -1
  62. package/dist/types/src/testing/query-promts.d.ts +1 -1
  63. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  64. package/dist/types/src/testing/test-data.d.ts +1 -1
  65. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  66. package/dist/types/src/testing/test-schema.d.ts +4 -4
  67. package/dist/types/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +22 -18
  69. package/src/ai-service/client.test.ts +69 -54
  70. package/src/ai-service/client.ts +29 -184
  71. package/src/ai-service/index.ts +4 -1
  72. package/src/ai-service/parser.ts +338 -0
  73. package/src/ai-service/stream.test.ts +101 -0
  74. package/src/ai-service/stream.ts +116 -0
  75. package/src/ai-service/testing.ts +93 -0
  76. package/src/ai-service/transform.ts +121 -0
  77. package/src/ai-service/types.ts +107 -0
  78. package/src/ai-service/util/index.ts +5 -0
  79. package/src/ai-service/{sse.ts → util/sse.ts} +5 -0
  80. package/src/bin/chat.ts +10 -11
  81. package/src/conversation/conversation.test.ts +16 -17
  82. package/src/conversation/conversation.ts +126 -20
  83. package/src/conversation/index.ts +0 -1
  84. package/src/conversation/types.ts +55 -16
  85. package/src/cypher/combinators.test.ts +4 -4
  86. package/src/cypher/combinators.ts +0 -1
  87. package/src/cypher/execution-plan.test.ts +5 -3
  88. package/src/cypher/parjs-shims.d.ts +4 -0
  89. package/src/cypher/parjs.ts +2 -2
  90. package/src/cypher/query-executor.test.ts +1 -1
  91. package/src/cypher/schema.ts +6 -2
  92. package/src/index.ts +1 -1
  93. package/src/testing/artifacts.test.ts +182 -0
  94. package/src/testing/data.ts +13 -0
  95. package/src/testing/defs.ts +8 -0
  96. package/src/testing/index.ts +1 -0
  97. package/src/testing/logger.ts +3 -2
  98. package/src/testing/query-promts.ts +3 -3
  99. package/src/testing/query.test.ts +11 -10
  100. package/src/testing/test-data.ts +8 -2
  101. package/vendor/parjs-browser.mjs +4 -0
  102. package/vendor/parjs-default.mjs +8 -0
  103. package/dist/lib/browser/chunk-AKP45LQH.mjs +0 -1394
  104. package/dist/lib/browser/chunk-AKP45LQH.mjs.map +0 -7
  105. package/dist/lib/node/chunk-G6CGWEMO.cjs +0 -1418
  106. package/dist/lib/node/chunk-G6CGWEMO.cjs.map +0 -7
  107. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs +0 -1396
  108. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs.map +0 -7
  109. package/dist/types/src/ai-service/schema.d.ts +0 -296
  110. package/dist/types/src/ai-service/schema.d.ts.map +0 -1
  111. package/dist/types/src/ai-service/sse.d.ts.map +0 -1
  112. package/dist/types/src/sanity.test.d.ts +0 -2
  113. package/dist/types/src/sanity.test.d.ts.map +0 -1
  114. package/src/ai-service/schema.ts +0 -260
  115. package/src/sanity.test.ts +0 -9
@@ -1,71 +1,1236 @@
1
1
  import {
2
- AIServiceClientImpl,
3
2
  EchoDataSource,
4
- GenerateRequest,
5
- GenerationStream,
6
- ImageSource,
7
- LLMModel,
8
- LLMTool,
9
- LLMToolDefinition,
10
- LLMToolResult,
11
- Message,
12
- MessageContentBlock,
13
- MessageFromDb,
14
- MessageImageContentBlock,
15
- MessageRole,
16
- MessageTextContentBlock,
17
- MessageToolResultContentBlock,
18
- MessageToolUseContentBlock,
19
- ObjectId,
20
- ObjectIdBrand,
21
- Space,
22
- SpaceIdSchema,
23
- Thread,
24
- ToolTypes,
25
- createUserMessage,
26
- defineTool,
27
3
  executeQuery,
28
4
  executeQueryPlan,
29
5
  formatInferredRelationshipLabel,
30
6
  formatJsonSchemaForLLM,
31
7
  formatNodeLabel,
32
8
  isReference,
33
- parseCypherQuery,
34
- runLLM
35
- } from "./chunk-AKP45LQH.mjs";
9
+ parseCypherQuery
10
+ } from "./chunk-AXUUNA7O.mjs";
11
+
12
+ // packages/experimental/assistant/src/ai-service/client.ts
13
+ import { Schema as S } from "@effect/schema";
14
+ import { Message } from "@dxos/artifact";
15
+ import { invariant } from "@dxos/invariant";
16
+
17
+ // packages/experimental/assistant/src/ai-service/stream.ts
18
+ import { Trigger } from "@dxos/async";
19
+ import { log } from "@dxos/log";
20
+
21
+ // packages/experimental/assistant/src/ai-service/util/sse.ts
22
+ async function* iterSSEMessages(response, controller) {
23
+ if (!response.body) {
24
+ controller.abort();
25
+ throw new Error("Attempted to iterate over a response with no body");
26
+ }
27
+ const sseDecoder = new SSEDecoder();
28
+ const lineDecoder = new LineDecoder();
29
+ const iter = readableStreamAsyncIterable(response.body);
30
+ for await (const sseChunk of iterSSEChunks(iter)) {
31
+ for (const line of lineDecoder.decode(sseChunk)) {
32
+ const sse = sseDecoder.decode(line);
33
+ if (sse) {
34
+ yield sse;
35
+ }
36
+ }
37
+ }
38
+ for (const line of lineDecoder.flush()) {
39
+ const sse = sseDecoder.decode(line);
40
+ if (sse) {
41
+ yield sse;
42
+ }
43
+ }
44
+ }
45
+ async function* iterSSEChunks(iterator) {
46
+ let data = new Uint8Array();
47
+ for await (const chunk of iterator) {
48
+ if (chunk == null) {
49
+ continue;
50
+ }
51
+ const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk) : typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
52
+ const newData = new Uint8Array(data.length + binaryChunk.length);
53
+ newData.set(data);
54
+ newData.set(binaryChunk, data.length);
55
+ data = newData;
56
+ let patternIndex;
57
+ while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
58
+ yield data.slice(0, patternIndex);
59
+ data = data.slice(patternIndex);
60
+ }
61
+ }
62
+ if (data.length > 0) {
63
+ yield data;
64
+ }
65
+ }
66
+ var findDoubleNewlineIndex = (buffer) => {
67
+ const newline = 10;
68
+ const carriage = 13;
69
+ for (let i = 0; i < buffer.length - 2; i++) {
70
+ if (buffer[i] === newline && buffer[i + 1] === newline) {
71
+ return i + 2;
72
+ }
73
+ if (buffer[i] === carriage && buffer[i + 1] === carriage) {
74
+ return i + 2;
75
+ }
76
+ if (buffer[i] === carriage && buffer[i + 1] === newline && i + 3 < buffer.length && buffer[i + 2] === carriage && buffer[i + 3] === newline) {
77
+ return i + 4;
78
+ }
79
+ }
80
+ return -1;
81
+ };
82
+ var SSEDecoder = class {
83
+ constructor() {
84
+ this.event = null;
85
+ this.data = [];
86
+ this.chunks = [];
87
+ }
88
+ decode(line) {
89
+ if (line.endsWith("\r")) {
90
+ line = line.substring(0, line.length - 1);
91
+ }
92
+ if (!line) {
93
+ if (!this.event && !this.data.length) {
94
+ return null;
95
+ }
96
+ const sse = {
97
+ event: this.event,
98
+ data: this.data.join("\n"),
99
+ raw: this.chunks
100
+ };
101
+ this.event = null;
102
+ this.data = [];
103
+ this.chunks = [];
104
+ return sse;
105
+ }
106
+ this.chunks.push(line);
107
+ if (line.startsWith(":")) {
108
+ return null;
109
+ }
110
+ let [fieldname, _, value] = partition(line, ":");
111
+ if (value.startsWith(" ")) {
112
+ value = value.substring(1);
113
+ }
114
+ if (fieldname === "event") {
115
+ this.event = value;
116
+ } else if (fieldname === "data") {
117
+ this.data.push(value);
118
+ }
119
+ return null;
120
+ }
121
+ };
122
+ var partition = (str, delimiter) => {
123
+ const index = str.indexOf(delimiter);
124
+ if (index !== -1) {
125
+ return [
126
+ str.substring(0, index),
127
+ delimiter,
128
+ str.substring(index + delimiter.length)
129
+ ];
130
+ }
131
+ return [
132
+ str,
133
+ "",
134
+ ""
135
+ ];
136
+ };
137
+ function readableStreamAsyncIterable(stream) {
138
+ if (stream[Symbol.asyncIterator]) {
139
+ return stream;
140
+ }
141
+ const reader = stream.getReader();
142
+ return {
143
+ next: async () => {
144
+ try {
145
+ const result = await reader.read();
146
+ if (result?.done) {
147
+ reader.releaseLock();
148
+ }
149
+ return result;
150
+ } catch (e) {
151
+ reader.releaseLock();
152
+ throw e;
153
+ }
154
+ },
155
+ return: async () => {
156
+ const cancelPromise = reader.cancel();
157
+ reader.releaseLock();
158
+ await cancelPromise;
159
+ return {
160
+ done: true,
161
+ value: void 0
162
+ };
163
+ },
164
+ [Symbol.asyncIterator]() {
165
+ return this;
166
+ }
167
+ };
168
+ }
169
+ var LineDecoder = class _LineDecoder {
170
+ static {
171
+ // prettier-ignore
172
+ this.NEWLINE_CHARS = /* @__PURE__ */ new Set([
173
+ "\n",
174
+ "\r"
175
+ ]);
176
+ }
177
+ static {
178
+ this.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
179
+ }
180
+ constructor() {
181
+ this.buffer = [];
182
+ this.trailingCR = false;
183
+ }
184
+ decode(chunk) {
185
+ let text = this.decodeText(chunk);
186
+ if (this.trailingCR) {
187
+ text = "\r" + text;
188
+ this.trailingCR = false;
189
+ }
190
+ if (text.endsWith("\r")) {
191
+ this.trailingCR = true;
192
+ text = text.slice(0, -1);
193
+ }
194
+ if (!text) {
195
+ return [];
196
+ }
197
+ const trailingNewline = _LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || "");
198
+ let lines = text.split(_LineDecoder.NEWLINE_REGEXP);
199
+ if (trailingNewline) {
200
+ lines.pop();
201
+ }
202
+ if (lines.length === 1 && !trailingNewline) {
203
+ this.buffer.push(lines[0]);
204
+ return [];
205
+ }
206
+ if (this.buffer.length > 0) {
207
+ lines = [
208
+ this.buffer.join("") + lines[0],
209
+ ...lines.slice(1)
210
+ ];
211
+ this.buffer = [];
212
+ }
213
+ if (!trailingNewline) {
214
+ this.buffer = [
215
+ lines.pop() || ""
216
+ ];
217
+ }
218
+ return lines;
219
+ }
220
+ decodeText(bytes) {
221
+ if (bytes == null) {
222
+ return "";
223
+ }
224
+ if (typeof bytes === "string") {
225
+ return bytes;
226
+ }
227
+ if (typeof Buffer !== "undefined") {
228
+ if (bytes instanceof Buffer) {
229
+ return bytes.toString();
230
+ }
231
+ if (bytes instanceof Uint8Array) {
232
+ return Buffer.from(bytes).toString();
233
+ }
234
+ throw new Error(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
235
+ }
236
+ if (typeof TextDecoder !== "undefined") {
237
+ if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
238
+ this.textDecoder ??= new TextDecoder("utf8");
239
+ return this.textDecoder.decode(bytes);
240
+ }
241
+ throw new Error(`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`);
242
+ }
243
+ throw new Error("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.");
244
+ }
245
+ flush() {
246
+ if (!this.buffer.length && !this.trailingCR) {
247
+ return [];
248
+ }
249
+ const lines = [
250
+ this.buffer.join("")
251
+ ];
252
+ this.buffer = [];
253
+ this.trailingCR = false;
254
+ return lines;
255
+ }
256
+ };
257
+
258
+ // packages/experimental/assistant/src/ai-service/stream.ts
259
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/ai-service/stream.ts";
260
+ var createGenerationStream = (response, controller = new AbortController()) => {
261
+ const iterator = async function* () {
262
+ for await (const sse of iterSSEMessages(response, controller)) {
263
+ if (sse.event === "completion") {
264
+ try {
265
+ yield JSON.parse(sse.data);
266
+ } catch (err) {
267
+ log.error("could not parse message into JSON:", {
268
+ data: sse.data,
269
+ raw: sse.raw
270
+ }, {
271
+ F: __dxlog_file,
272
+ L: 21,
273
+ S: this,
274
+ C: (f, a) => f(...a)
275
+ });
276
+ throw err;
277
+ }
278
+ }
279
+ if (sse.event === "message_start" || sse.event === "message_delta" || sse.event === "message_stop" || sse.event === "content_block_start" || sse.event === "content_block_delta" || sse.event === "content_block_stop") {
280
+ try {
281
+ yield JSON.parse(sse.data);
282
+ } catch (err) {
283
+ log.error("could not parse message into JSON:", {
284
+ data: sse.data,
285
+ raw: sse.raw
286
+ }, {
287
+ F: __dxlog_file,
288
+ L: 37,
289
+ S: this,
290
+ C: (f, a) => f(...a)
291
+ });
292
+ throw err;
293
+ }
294
+ }
295
+ if (sse.event === "ping") {
296
+ continue;
297
+ }
298
+ if (sse.event === "error") {
299
+ throw new Error(`Message generation error: ${sse.data}`);
300
+ }
301
+ }
302
+ };
303
+ return new GenerationStream(controller, iterator);
304
+ };
305
+ var GenerationStream = class {
306
+ constructor(_controller, _getIterator) {
307
+ this._controller = _controller;
308
+ this._getIterator = _getIterator;
309
+ this._done = new Trigger();
310
+ this._iterator = void 0;
311
+ }
312
+ /**
313
+ * Returns an iterator over the stream.
314
+ */
315
+ [Symbol.asyncIterator]() {
316
+ return this._createIterator();
317
+ }
318
+ /**
319
+ * Aborts the stream.
320
+ */
321
+ abort() {
322
+ this._controller.abort();
323
+ }
324
+ /**
325
+ * Returns the complete message list generated by the AI service.
326
+ */
327
+ async complete() {
328
+ await this._done.wait();
329
+ }
330
+ /**
331
+ * Creates an iterator over the stream.
332
+ */
333
+ _createIterator() {
334
+ const self = this;
335
+ return this._iterator ??= (() => {
336
+ const generator = async function* () {
337
+ try {
338
+ for await (const event of self._getIterator()) {
339
+ yield event;
340
+ }
341
+ this._done.wake();
342
+ } catch (err) {
343
+ this._done.throw(err);
344
+ }
345
+ };
346
+ return generator.call(this);
347
+ })();
348
+ }
349
+ };
350
+
351
+ // packages/experimental/assistant/src/ai-service/client.ts
352
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/ai-service/client.ts";
353
+ var AIServiceClientImpl = class {
354
+ constructor({ endpoint }) {
355
+ invariant(endpoint, "endpoint is required", {
356
+ F: __dxlog_file2,
357
+ L: 36,
358
+ S: this,
359
+ A: [
360
+ "endpoint",
361
+ "'endpoint is required'"
362
+ ]
363
+ });
364
+ this._endpoint = endpoint;
365
+ }
366
+ async getSpace(spaceId) {
367
+ throw new Error("Not implemented");
368
+ }
369
+ async getThread(spaceId, threadId) {
370
+ throw new Error("Not implemented");
371
+ }
372
+ async getMessages(spaceId, threadId) {
373
+ const res = await fetch(`${this._endpoint}/space/${spaceId}/thread/${threadId}/message`);
374
+ return S.decodePromise(S.Array(Message).pipe(S.mutable))((await res.json()).data.results);
375
+ }
376
+ async appendMessages(messages) {
377
+ const url = `${this._endpoint}/message`;
378
+ const res = await fetch(url, {
379
+ method: "POST",
380
+ headers: {
381
+ "Content-Type": "application/json"
382
+ },
383
+ body: JSON.stringify({
384
+ messages: await S.encodePromise(S.Array(Message))(messages)
385
+ })
386
+ });
387
+ if (!res.ok) {
388
+ throw new Error(`${await res.text()} [${url}]`);
389
+ }
390
+ }
391
+ // TODO(dmaretskyi): Accept partial message schema.
392
+ async updateMessage(spaceId, threadId, messageId, message) {
393
+ throw new Error("Not implemented");
394
+ }
395
+ /**
396
+ * Open message stream.
397
+ */
398
+ async generate(request) {
399
+ const controller = new AbortController();
400
+ const response = await fetch(`${this._endpoint}/generate`, {
401
+ signal: controller.signal,
402
+ method: "POST",
403
+ headers: {
404
+ "Content-Type": "application/json"
405
+ },
406
+ body: JSON.stringify(request)
407
+ });
408
+ invariant(response.body instanceof ReadableStream, void 0, {
409
+ F: __dxlog_file2,
410
+ L: 85,
411
+ S: this,
412
+ A: [
413
+ "response.body instanceof ReadableStream",
414
+ ""
415
+ ]
416
+ });
417
+ return createGenerationStream(response, controller);
418
+ }
419
+ };
420
+
421
+ // packages/experimental/assistant/src/ai-service/parser.ts
422
+ import { Message as Message2 } from "@dxos/artifact";
423
+ import { Event } from "@dxos/async";
424
+ import { createStatic } from "@dxos/echo-schema";
425
+ import { invariant as invariant2 } from "@dxos/invariant";
426
+ import { log as log2 } from "@dxos/log";
427
+ import { isNotFalsy, safeParseJson } from "@dxos/util";
428
+
429
+ // packages/experimental/assistant/src/ai-service/transform.ts
430
+ import * as P from "parsimmon";
431
+ var textChunk = P.regexp(/[^<]+/).map((content) => ({
432
+ type: "text",
433
+ content
434
+ }));
435
+ var attribute = P.seq(P.regexp(/[a-zA-Z_][a-zA-Z0-9_-]*/), P.string("=").trim(P.optWhitespace), P.alt(P.regexp(/"[^"]*"/).map((s) => s.slice(1, -1)), P.regexp(/'[^']*'/).map((s) => s.slice(1, -1)))).map(([name, _, value]) => [
436
+ name,
437
+ value
438
+ ]);
439
+ var tagName = P.regexp(/[a-zA-Z_][a-zA-Z0-9_-]*/);
440
+ var selfClosingTag = P.seqMap(
441
+ //
442
+ P.string("<"),
443
+ tagName,
444
+ P.optWhitespace.then(attribute).many(),
445
+ P.optWhitespace.then(P.string("/>")),
446
+ P.optWhitespace,
447
+ (_, tag, attributes, __) => ({
448
+ type: "tag",
449
+ tag,
450
+ attributes: Object.fromEntries(attributes),
451
+ content: [],
452
+ selfClosing: true
453
+ })
454
+ );
455
+ var openTag = P.seqMap(
456
+ //
457
+ P.string("<"),
458
+ tagName,
459
+ P.optWhitespace.then(attribute).many(),
460
+ P.string(">"),
461
+ P.regexp(/[^<]*/),
462
+ (_, tag, attributes, __, content) => ({
463
+ type: "tag",
464
+ tag,
465
+ attributes: Object.fromEntries(attributes),
466
+ content: content.length ? [
467
+ {
468
+ type: "text",
469
+ content
470
+ }
471
+ ] : []
472
+ })
473
+ );
474
+ var closeTag = P.seqMap(
475
+ //
476
+ P.string("</"),
477
+ tagName,
478
+ P.string(">"),
479
+ P.optWhitespace,
480
+ (_, tag) => ({
481
+ type: "tag",
482
+ tag,
483
+ content: [],
484
+ closing: true
485
+ })
486
+ );
487
+ var mixedChunk = P.alt(selfClosingTag, openTag, closeTag, textChunk);
488
+ var StreamTransform = class {
489
+ constructor() {
490
+ this._buffer = "";
491
+ }
492
+ transform(chunk) {
493
+ this._buffer += chunk;
494
+ const results = [];
495
+ const parser = mixedChunk.many().skip(P.optWhitespace);
496
+ const result = parser.parse(this._buffer);
497
+ if (result.status) {
498
+ for (const chunk2 of result.value) {
499
+ results.push(chunk2);
500
+ }
501
+ this._buffer = "";
502
+ }
503
+ return results;
504
+ }
505
+ // TODO(burdon): Process remaining buffer?
506
+ flush() {
507
+ const remaining = this._buffer;
508
+ this._buffer = "";
509
+ return remaining.length > 0 ? [
510
+ {
511
+ type: "text",
512
+ content: remaining
513
+ }
514
+ ] : [];
515
+ }
516
+ };
517
+
518
+ // packages/experimental/assistant/src/ai-service/parser.ts
519
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/ai-service/parser.ts";
520
+ var MixedStreamParser = class {
521
+ constructor() {
522
+ /**
523
+ * New message.
524
+ */
525
+ this.message = new Event();
526
+ /**
527
+ * Complete block added to Message.
528
+ */
529
+ this.block = new Event();
530
+ /**
531
+ * Update partial block (while streaming).
532
+ */
533
+ this.update = new Event();
534
+ }
535
+ _emitBlock(contentBlock, streamBlock) {
536
+ const messageBlock = streamBlock ? mergeMessageBlock(contentBlock, streamBlock) : contentBlock;
537
+ if (messageBlock) {
538
+ if (messageBlock.type === "text" && messageBlock.text.length === 0) {
539
+ return;
540
+ }
541
+ invariant2(this._message, void 0, {
542
+ F: __dxlog_file3,
543
+ L: 46,
544
+ S: this,
545
+ A: [
546
+ "this._message",
547
+ ""
548
+ ]
549
+ });
550
+ this._message.content.push(messageBlock);
551
+ this.block.emit(messageBlock);
552
+ }
553
+ }
554
+ _emitUpdate(contentBlock, streamBlock) {
555
+ const messageBlock = mergeMessageBlock(contentBlock, streamBlock);
556
+ if (messageBlock) {
557
+ messageBlock.pending = true;
558
+ this.update.emit(messageBlock);
559
+ }
560
+ }
561
+ /**
562
+ * Parse stream until end.
563
+ */
564
+ async parse(stream) {
565
+ const transformer = new StreamTransform();
566
+ let contentBlock;
567
+ let streamBlock;
568
+ const stack = [];
569
+ for await (const event of stream) {
570
+ switch (event.type) {
571
+ //
572
+ // Messages.
573
+ //
574
+ case "message_start": {
575
+ if (this._message) {
576
+ log2.warn("unexpected message_start", void 0, {
577
+ F: __dxlog_file3,
578
+ L: 86,
579
+ S: this,
580
+ C: (f, a) => f(...a)
581
+ });
582
+ }
583
+ this._message = createStatic(Message2, {
584
+ role: "assistant",
585
+ content: []
586
+ });
587
+ this.message.emit(this._message);
588
+ break;
589
+ }
590
+ case "message_delta": {
591
+ if (!this._message) {
592
+ log2.warn("unexpected message_delta", void 0, {
593
+ F: __dxlog_file3,
594
+ L: 96,
595
+ S: this,
596
+ C: (f, a) => f(...a)
597
+ });
598
+ }
599
+ break;
600
+ }
601
+ case "message_stop": {
602
+ if (!this._message) {
603
+ log2.warn("unexpected message_stop", void 0, {
604
+ F: __dxlog_file3,
605
+ L: 104,
606
+ S: this,
607
+ C: (f, a) => f(...a)
608
+ });
609
+ } else {
610
+ this._message = void 0;
611
+ }
612
+ break;
613
+ }
614
+ //
615
+ // Content blocks.
616
+ //
617
+ case "content_block_start": {
618
+ if (contentBlock) {
619
+ log2.warn("unexpected content_block_start", {
620
+ content: contentBlock
621
+ }, {
622
+ F: __dxlog_file3,
623
+ L: 117,
624
+ S: this,
625
+ C: (f, a) => f(...a)
626
+ });
627
+ }
628
+ contentBlock = event.content;
629
+ break;
630
+ }
631
+ case "content_block_delta": {
632
+ if (!contentBlock) {
633
+ log2.warn("unexpected content_block_delta", void 0, {
634
+ F: __dxlog_file3,
635
+ L: 127,
636
+ S: this,
637
+ C: (f, a) => f(...a)
638
+ });
639
+ break;
640
+ }
641
+ switch (event.delta.type) {
642
+ //
643
+ // Text
644
+ //
645
+ case "text_delta": {
646
+ const chunks = transformer.transform(event.delta.text);
647
+ for (const chunk of chunks) {
648
+ switch (streamBlock?.type) {
649
+ //
650
+ // XML Fragment.
651
+ //
652
+ case "tag": {
653
+ if (chunk.type === "tag") {
654
+ if (chunk.selfClosing) {
655
+ streamBlock.content.push(chunk);
656
+ } else if (chunk.closing) {
657
+ if (stack.length > 0) {
658
+ const top = stack.pop();
659
+ invariant2(top && top.type === "tag", void 0, {
660
+ F: __dxlog_file3,
661
+ L: 151,
662
+ S: this,
663
+ A: [
664
+ "top && top.type === 'tag'",
665
+ ""
666
+ ]
667
+ });
668
+ top.content.push(streamBlock);
669
+ streamBlock = top;
670
+ } else {
671
+ this._emitBlock(contentBlock, streamBlock);
672
+ streamBlock = void 0;
673
+ }
674
+ } else {
675
+ stack.push(streamBlock);
676
+ streamBlock = chunk;
677
+ }
678
+ } else {
679
+ if (streamBlock.content.length === 0) {
680
+ streamBlock.content.push(chunk);
681
+ } else {
682
+ const last = streamBlock.content.at(-1);
683
+ invariant2(last, void 0, {
684
+ F: __dxlog_file3,
685
+ L: 168,
686
+ S: this,
687
+ A: [
688
+ "last",
689
+ ""
690
+ ]
691
+ });
692
+ if (last.type === "text") {
693
+ last.content += chunk.content;
694
+ } else {
695
+ streamBlock.content.push(chunk);
696
+ }
697
+ }
698
+ }
699
+ break;
700
+ }
701
+ //
702
+ // Text Fragment.
703
+ //
704
+ case "text": {
705
+ if (chunk.type === "tag") {
706
+ this._emitBlock(contentBlock, streamBlock);
707
+ if (chunk.selfClosing) {
708
+ this._emitBlock(contentBlock, chunk);
709
+ streamBlock = void 0;
710
+ } else {
711
+ streamBlock = chunk;
712
+ }
713
+ } else {
714
+ streamBlock.content += chunk.content;
715
+ }
716
+ break;
717
+ }
718
+ //
719
+ // No current chunk.
720
+ //
721
+ default: {
722
+ if (chunk.type === "tag" && chunk.selfClosing) {
723
+ this._emitBlock(contentBlock, chunk);
724
+ } else {
725
+ streamBlock = chunk;
726
+ }
727
+ }
728
+ }
729
+ }
730
+ break;
731
+ }
732
+ //
733
+ // JSON
734
+ //
735
+ case "input_json_delta": {
736
+ if (!contentBlock) {
737
+ log2.warn("unexpected input_json_delta", {
738
+ contentBlock
739
+ }, {
740
+ F: __dxlog_file3,
741
+ L: 218,
742
+ S: this,
743
+ C: (f, a) => f(...a)
744
+ });
745
+ break;
746
+ }
747
+ if (streamBlock?.type === "json") {
748
+ streamBlock.content += event.delta.partial_json;
749
+ } else {
750
+ streamBlock = {
751
+ type: "json",
752
+ content: event.delta.partial_json
753
+ };
754
+ }
755
+ break;
756
+ }
757
+ }
758
+ break;
759
+ }
760
+ case "content_block_stop": {
761
+ if (!contentBlock) {
762
+ log2.warn("unexpected content_block_stop", void 0, {
763
+ F: __dxlog_file3,
764
+ L: 235,
765
+ S: this,
766
+ C: (f, a) => f(...a)
767
+ });
768
+ break;
769
+ }
770
+ this._emitBlock(contentBlock, streamBlock);
771
+ contentBlock = void 0;
772
+ streamBlock = void 0;
773
+ break;
774
+ }
775
+ }
776
+ if (contentBlock && streamBlock) {
777
+ this._emitUpdate(contentBlock, streamBlock);
778
+ }
779
+ }
780
+ }
781
+ };
782
+ var mergeMessageBlock = (contentBlock, streamBlock) => {
783
+ log2("mergeMessageBlock", {
784
+ contentBlock,
785
+ streamBlock
786
+ }, {
787
+ F: __dxlog_file3,
788
+ L: 260,
789
+ S: void 0,
790
+ C: (f, a) => f(...a)
791
+ });
792
+ switch (streamBlock.type) {
793
+ //
794
+ // Text
795
+ //
796
+ case "text": {
797
+ return {
798
+ ...contentBlock,
799
+ type: "text",
800
+ text: streamBlock.content
801
+ };
802
+ }
803
+ //
804
+ // XML
805
+ //
806
+ case "tag": {
807
+ switch (streamBlock.tag) {
808
+ case "cot": {
809
+ const content = streamBlock.content.map((block) => {
810
+ switch (block.type) {
811
+ case "text":
812
+ return block.content;
813
+ default:
814
+ return null;
815
+ }
816
+ }).filter(isNotFalsy).join("\n");
817
+ return {
818
+ ...contentBlock,
819
+ type: "text",
820
+ disposition: "cot",
821
+ text: content
822
+ };
823
+ }
824
+ case "artifact": {
825
+ const { attributes } = streamBlock;
826
+ return {
827
+ type: "json",
828
+ disposition: "artifact",
829
+ json: JSON.stringify(attributes)
830
+ };
831
+ }
832
+ case "suggest": {
833
+ if (streamBlock.content.length === 1 && streamBlock.content[0].type === "text") {
834
+ return {
835
+ type: "json",
836
+ disposition: "suggest",
837
+ json: JSON.stringify({
838
+ text: streamBlock.content[0].content
839
+ })
840
+ };
841
+ }
842
+ break;
843
+ }
844
+ case "select": {
845
+ return {
846
+ type: "json",
847
+ disposition: "select",
848
+ json: JSON.stringify({
849
+ options: streamBlock.content.flatMap((content) => content.type === "tag" && content.content.length === 1 && content.content[0].type === "text" ? [
850
+ content.content[0].content
851
+ ] : [])
852
+ })
853
+ };
854
+ }
855
+ }
856
+ break;
857
+ }
858
+ //
859
+ // JSON
860
+ //
861
+ case "json": {
862
+ switch (contentBlock.type) {
863
+ case "tool_use": {
864
+ return {
865
+ ...contentBlock,
866
+ input: safeParseJson(streamBlock.content) ?? {}
867
+ };
868
+ }
869
+ }
870
+ return {
871
+ ...contentBlock,
872
+ type: "json",
873
+ disposition: "artifact",
874
+ json: streamBlock.content
875
+ };
876
+ }
877
+ }
878
+ };
879
+
880
+ // packages/experimental/assistant/src/ai-service/types.ts
881
+ import { Schema as S2 } from "@effect/schema";
882
+ import { Tool, Message as Message3, SpaceIdSchema } from "@dxos/artifact";
883
+ import { ObjectId } from "@dxos/echo-schema";
884
+ var createArtifactElement = (id) => `<artifact id=${id} />`;
885
+ var LLMModel = S2.Literal("@anthropic/claude-3-5-haiku-20241022", "@anthropic/claude-3-5-sonnet-20241022", "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", "@hf/nousresearch/hermes-2-pro-mistral-7b", "@ollama/llama-3-2-3b", "@ollama/llama-3-1-nemotron-70b-instruct", "@ollama/llama-3-1-nemotron-mini-4b-instruct");
886
+ var ToolTypes = Object.freeze({
887
+ // TODO(dmaretskyi): Not implemented yet.
888
+ // DatabaseQuery: 'database_query',
889
+ TextToImage: "text_to_image"
890
+ });
891
+ var GenerateRequest = S2.Struct({
892
+ spaceId: S2.optional(SpaceIdSchema),
893
+ threadId: S2.optional(ObjectId),
894
+ // TODO(burdon): Make optional with default.
895
+ model: LLMModel,
896
+ /**
897
+ * Current request.
898
+ */
899
+ // TODO(burdon): Remove from history.
900
+ // prompt: Message,
901
+ /**
902
+ * System instructions to the LLM.
903
+ */
904
+ systemPrompt: S2.optional(S2.String),
905
+ /**
906
+ * History of messages to include in the context window.
907
+ */
908
+ history: S2.optional(S2.Array(Message3)),
909
+ /**
910
+ * Tools available for the LLM.
911
+ */
912
+ tools: S2.optional(S2.Array(Tool).pipe(S2.mutable))
913
+ });
914
+
915
+ // packages/experimental/assistant/src/conversation/conversation.ts
916
+ import { ToolResult, Message as Message4 } from "@dxos/artifact";
917
+ import { createStatic as createStatic2, ObjectId as ObjectId2 } from "@dxos/echo-schema";
918
+ import { invariant as invariant3 } from "@dxos/invariant";
919
+ import { log as log3 } from "@dxos/log";
920
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/conversation/conversation.ts";
921
+ var runLLM = async (params) => {
922
+ let conversationResult = null;
923
+ const history = params.history ?? [];
924
+ const generate = async () => {
925
+ log3("llm generate", {
926
+ tools: params.tools
927
+ }, {
928
+ F: __dxlog_file4,
929
+ L: 44,
930
+ S: void 0,
931
+ C: (f, a) => f(...a)
932
+ });
933
+ const beginTs = Date.now();
934
+ const stream = await params.client.generate({
935
+ model: params.model,
936
+ spaceId: params.spaceId,
937
+ threadId: params.threadId,
938
+ history,
939
+ systemPrompt: params.system,
940
+ tools: params.tools
941
+ });
942
+ for await (const event of stream) {
943
+ params.logger?.(event);
944
+ }
945
+ await stream.complete();
946
+ const messages = [];
947
+ const message = messages.at(-1);
948
+ invariant3(message, void 0, {
949
+ F: __dxlog_file4,
950
+ L: 63,
951
+ S: void 0,
952
+ A: [
953
+ "message",
954
+ ""
955
+ ]
956
+ });
957
+ log3("llm result", {
958
+ time: Date.now() - beginTs,
959
+ message
960
+ }, {
961
+ F: __dxlog_file4,
962
+ L: 65,
963
+ S: void 0,
964
+ C: (f, a) => f(...a)
965
+ });
966
+ invariant3(message, void 0, {
967
+ F: __dxlog_file4,
968
+ L: 66,
969
+ S: void 0,
970
+ A: [
971
+ "message",
972
+ ""
973
+ ]
974
+ });
975
+ params.logger?.({
976
+ type: "message",
977
+ message
978
+ });
979
+ history.push(...messages.map((message2) => ({
980
+ ...message2,
981
+ content: message2.content.filter((block) => block.type !== "image")
982
+ })));
983
+ const isToolUse2 = message.content.at(-1)?.type === "tool_use";
984
+ if (isToolUse2) {
985
+ const toolCalls = message.content.filter((block) => block.type === "tool_use");
986
+ invariant3(toolCalls.length === 1, void 0, {
987
+ F: __dxlog_file4,
988
+ L: 77,
989
+ S: void 0,
990
+ A: [
991
+ "toolCalls.length === 1",
992
+ ""
993
+ ]
994
+ });
995
+ const toolCall = toolCalls[0];
996
+ const tool = params.tools.find((tool2) => tool2.name === toolCall.name);
997
+ if (!tool) {
998
+ throw new Error(`Tool not found: ${toolCall.name}`);
999
+ }
1000
+ invariant3(tool.execute, void 0, {
1001
+ F: __dxlog_file4,
1002
+ L: 84,
1003
+ S: void 0,
1004
+ A: [
1005
+ "tool.execute",
1006
+ ""
1007
+ ]
1008
+ });
1009
+ const toolResult = await tool.execute(toolCall.input);
1010
+ switch (toolResult.kind) {
1011
+ case "error": {
1012
+ log3.warn("tool error", {
1013
+ message: toolResult.message
1014
+ }, {
1015
+ F: __dxlog_file4,
1016
+ L: 88,
1017
+ S: void 0,
1018
+ C: (f, a) => f(...a)
1019
+ });
1020
+ const resultMessage = {
1021
+ id: ObjectId2.random(),
1022
+ spaceId: params.spaceId,
1023
+ threadId: params.threadId,
1024
+ role: "user",
1025
+ content: [
1026
+ {
1027
+ type: "tool_result",
1028
+ toolUseId: toolCall.id,
1029
+ content: toolResult.message,
1030
+ isError: true
1031
+ }
1032
+ ]
1033
+ };
1034
+ params.logger?.({
1035
+ type: "message",
1036
+ message: resultMessage
1037
+ });
1038
+ history.push(resultMessage);
1039
+ return true;
1040
+ }
1041
+ case "success": {
1042
+ log3("tool success", {
1043
+ result: toolResult.result
1044
+ }, {
1045
+ F: __dxlog_file4,
1046
+ L: 110,
1047
+ S: void 0,
1048
+ C: (f, a) => f(...a)
1049
+ });
1050
+ const resultMessage = {
1051
+ id: ObjectId2.random(),
1052
+ spaceId: params.spaceId,
1053
+ threadId: params.threadId,
1054
+ role: "user",
1055
+ content: [
1056
+ {
1057
+ type: "tool_result",
1058
+ toolUseId: toolCall.id,
1059
+ content: JSON.stringify(toolResult.result)
1060
+ }
1061
+ ]
1062
+ };
1063
+ params.logger?.({
1064
+ type: "message",
1065
+ message: resultMessage
1066
+ });
1067
+ history.push(resultMessage);
1068
+ return true;
1069
+ }
1070
+ case "break": {
1071
+ log3("tool break", {
1072
+ result: toolResult.result
1073
+ }, {
1074
+ F: __dxlog_file4,
1075
+ L: 131,
1076
+ S: void 0,
1077
+ C: (f, a) => f(...a)
1078
+ });
1079
+ conversationResult = toolResult.result;
1080
+ return false;
1081
+ }
1082
+ }
1083
+ }
1084
+ return false;
1085
+ };
1086
+ while (await generate()) {
1087
+ }
1088
+ return {
1089
+ result: conversationResult,
1090
+ history
1091
+ };
1092
+ };
1093
+ var isToolUse = (message) => {
1094
+ const block = message.content.at(-1);
1095
+ invariant3(block, void 0, {
1096
+ F: __dxlog_file4,
1097
+ L: 152,
1098
+ S: void 0,
1099
+ A: [
1100
+ "block",
1101
+ ""
1102
+ ]
1103
+ });
1104
+ return block.type === "tool_use";
1105
+ };
1106
+ var runTools = async ({ message, tools, extensions }) => {
1107
+ const toolCalls = message.content.filter((block) => block.type === "tool_use");
1108
+ invariant3(toolCalls.length === 1, void 0, {
1109
+ F: __dxlog_file4,
1110
+ L: 174,
1111
+ S: void 0,
1112
+ A: [
1113
+ "toolCalls.length === 1",
1114
+ ""
1115
+ ]
1116
+ });
1117
+ const toolCall = toolCalls[0];
1118
+ const tool = tools.find((tool2) => tool2.name === toolCall.name);
1119
+ if (!tool) {
1120
+ throw new Error(`Tool not found: ${toolCall.name}`);
1121
+ }
1122
+ let toolResult;
1123
+ try {
1124
+ invariant3(tool.execute, void 0, {
1125
+ F: __dxlog_file4,
1126
+ L: 183,
1127
+ S: void 0,
1128
+ A: [
1129
+ "tool.execute",
1130
+ ""
1131
+ ]
1132
+ });
1133
+ toolResult = await tool.execute(toolCall.input, {
1134
+ extensions
1135
+ });
1136
+ } catch (error) {
1137
+ log3("tool error", {
1138
+ error
1139
+ }, {
1140
+ F: __dxlog_file4,
1141
+ L: 186,
1142
+ S: void 0,
1143
+ C: (f, a) => f(...a)
1144
+ });
1145
+ toolResult = ToolResult.Error(error.message);
1146
+ }
1147
+ switch (toolResult.kind) {
1148
+ case "error": {
1149
+ log3("tool error", {
1150
+ message: toolResult.message
1151
+ }, {
1152
+ F: __dxlog_file4,
1153
+ L: 192,
1154
+ S: void 0,
1155
+ C: (f, a) => f(...a)
1156
+ });
1157
+ const resultMessage = createStatic2(Message4, {
1158
+ role: "user",
1159
+ content: [
1160
+ {
1161
+ type: "tool_result",
1162
+ toolUseId: toolCall.id,
1163
+ content: toolResult.message,
1164
+ isError: true
1165
+ }
1166
+ ]
1167
+ });
1168
+ return {
1169
+ type: "continue",
1170
+ message: resultMessage
1171
+ };
1172
+ }
1173
+ case "success": {
1174
+ log3("tool success", {
1175
+ result: toolResult.result
1176
+ }, {
1177
+ F: __dxlog_file4,
1178
+ L: 213,
1179
+ S: void 0,
1180
+ C: (f, a) => f(...a)
1181
+ });
1182
+ const resultMessage = createStatic2(Message4, {
1183
+ role: "user",
1184
+ content: [
1185
+ {
1186
+ type: "tool_result",
1187
+ toolUseId: toolCall.id,
1188
+ content: typeof toolResult.result === "string" ? toolResult.result : JSON.stringify(toolResult.result) ?? ""
1189
+ }
1190
+ ]
1191
+ });
1192
+ return {
1193
+ type: "continue",
1194
+ message: resultMessage
1195
+ };
1196
+ }
1197
+ case "break": {
1198
+ log3("tool break", {
1199
+ result: toolResult.result
1200
+ }, {
1201
+ F: __dxlog_file4,
1202
+ L: 233,
1203
+ S: void 0,
1204
+ C: (f, a) => f(...a)
1205
+ });
1206
+ return {
1207
+ type: "break",
1208
+ result: toolResult.result
1209
+ };
1210
+ }
1211
+ }
1212
+ };
36
1213
  export {
37
1214
  AIServiceClientImpl,
38
1215
  EchoDataSource,
39
1216
  GenerateRequest,
40
1217
  GenerationStream,
41
- ImageSource,
42
1218
  LLMModel,
43
- LLMTool,
44
- LLMToolDefinition,
45
- LLMToolResult,
46
- Message,
47
- MessageContentBlock,
48
- MessageFromDb,
49
- MessageImageContentBlock,
50
- MessageRole,
51
- MessageTextContentBlock,
52
- MessageToolResultContentBlock,
53
- MessageToolUseContentBlock,
54
- ObjectId,
55
- ObjectIdBrand,
56
- Space,
57
- SpaceIdSchema,
58
- Thread,
1219
+ MixedStreamParser,
1220
+ StreamTransform,
59
1221
  ToolTypes,
60
- createUserMessage,
61
- defineTool,
1222
+ createArtifactElement,
1223
+ createGenerationStream,
62
1224
  executeQuery,
63
1225
  executeQueryPlan,
64
1226
  formatInferredRelationshipLabel,
65
1227
  formatJsonSchemaForLLM,
66
1228
  formatNodeLabel,
67
1229
  isReference,
1230
+ isToolUse,
1231
+ mergeMessageBlock,
68
1232
  parseCypherQuery,
69
- runLLM
1233
+ runLLM,
1234
+ runTools
70
1235
  };
71
1236
  //# sourceMappingURL=index.mjs.map