@copilotkit/runtime 1.4.6 → 1.4.8-coagents-v0-3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -5
- package/__snapshots__/schema/schema.graphql +7 -9
- package/dist/{chunk-OKQVDDJ2.mjs → chunk-2PK2SFRB.mjs} +220 -57
- package/dist/chunk-2PK2SFRB.mjs.map +1 -0
- package/dist/{chunk-37LZS4PV.mjs → chunk-BACNNHHI.mjs} +2 -2
- package/dist/{chunk-55FONM7Y.mjs → chunk-FVYNRYIB.mjs} +420 -296
- package/dist/chunk-FVYNRYIB.mjs.map +1 -0
- package/dist/{chunk-6KZNQI7Z.mjs → chunk-MQJNZYAH.mjs} +2 -2
- package/dist/{chunk-B74M7FXG.mjs → chunk-RFF5IIZJ.mjs} +3 -2
- package/dist/chunk-RFF5IIZJ.mjs.map +1 -0
- package/dist/{chunk-XA3KCJ6P.mjs → chunk-YFG3Q3YH.mjs} +2 -2
- package/dist/{copilot-runtime-12e7ac40.d.ts → copilot-runtime-b15b683d.d.ts} +2 -2
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +2 -1
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +1 -1
- package/dist/{groq-adapter-24abe931.d.ts → groq-adapter-50aa9621.d.ts} +1 -1
- package/dist/{index-10b1c870.d.ts → index-ff3fbc33.d.ts} +7 -8
- package/dist/index.d.ts +4 -4
- package/dist/index.js +725 -437
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/{langserve-f021ab9c.d.ts → langserve-8ec29cba.d.ts} +51 -12
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +703 -431
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +71 -30
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +6 -6
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +71 -30
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +4 -4
- package/dist/lib/integrations/node-express/index.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +71 -30
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +4 -4
- package/dist/lib/integrations/node-http/index.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +71 -30
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +3 -3
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/service-adapters/index.js +219 -56
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +2 -2
- package/src/agents/langgraph/event-source.ts +140 -148
- package/src/agents/langgraph/events.ts +1 -1
- package/src/graphql/inputs/message.input.ts +15 -3
- package/src/graphql/resolvers/copilot.resolver.ts +32 -6
- package/src/graphql/types/converted/index.ts +4 -3
- package/src/graphql/types/copilot-response.type.ts +12 -3
- package/src/graphql/types/enums.ts +0 -11
- package/src/lib/runtime/remote-action-constructors.ts +4 -2
- package/src/lib/runtime/remote-actions.ts +1 -0
- package/src/lib/runtime/remote-lg-action.ts +161 -140
- package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -6
- package/src/service-adapters/conversion.ts +2 -1
- package/src/service-adapters/events.ts +111 -52
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +7 -3
- package/src/service-adapters/groq/groq-adapter.ts +23 -8
- package/src/service-adapters/langchain/utils.ts +49 -31
- package/src/service-adapters/openai/openai-adapter.ts +22 -9
- package/src/service-adapters/openai/openai-assistant-adapter.ts +22 -8
- package/src/service-adapters/unify/unify-adapter.ts +28 -11
- package/dist/chunk-55FONM7Y.mjs.map +0 -1
- package/dist/chunk-B74M7FXG.mjs.map +0 -1
- package/dist/chunk-OKQVDDJ2.mjs.map +0 -1
- /package/dist/{chunk-37LZS4PV.mjs.map → chunk-BACNNHHI.mjs.map} +0 -0
- /package/dist/{chunk-6KZNQI7Z.mjs.map → chunk-MQJNZYAH.mjs.map} +0 -0
- /package/dist/{chunk-XA3KCJ6P.mjs.map → chunk-YFG3Q3YH.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,93 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.4.8-coagents-v0-3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- CoAgents v0.3 prerelease
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @copilotkit/shared@1.4.8-coagents-v0-3.1
|
|
10
|
+
|
|
11
|
+
## 1.4.8-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @copilotkit/shared@1.4.8-next.0
|
|
16
|
+
|
|
17
|
+
## 1.4.7
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Fix broken build script before release
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @copilotkit/shared@1.4.7
|
|
24
|
+
|
|
3
25
|
## 1.4.6
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
6
28
|
|
|
7
29
|
- .
|
|
8
|
-
- Updated dependencies
|
|
9
|
-
- @copilotkit/shared@1.4.6
|
|
10
30
|
|
|
11
31
|
## 1.4.5
|
|
12
32
|
|
|
13
33
|
### Patch Changes
|
|
14
34
|
|
|
15
|
-
-
|
|
35
|
+
- testing release workflow
|
|
16
36
|
- Updated dependencies
|
|
17
37
|
- @copilotkit/shared@1.4.5
|
|
18
38
|
|
|
19
|
-
## 1.4.
|
|
39
|
+
## 1.4.5-next.0
|
|
20
40
|
|
|
21
41
|
### Patch Changes
|
|
22
42
|
|
|
23
|
-
-
|
|
43
|
+
- testing release workflow
|
|
24
44
|
- Updated dependencies
|
|
45
|
+
- @copilotkit/shared@1.4.5-next.0
|
|
46
|
+
|
|
47
|
+
## 1.4.4
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 665deab: test prerelease
|
|
52
|
+
- 57a6012: test next prerelease automation
|
|
53
|
+
- 7cfc2e7: test prerelease stuff
|
|
54
|
+
- af36f1a: - feat(runtime): readme update
|
|
25
55
|
- @copilotkit/shared@1.4.4
|
|
26
56
|
|
|
57
|
+
## 1.4.4-next.4
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- 57a6012: test next prerelease automation
|
|
62
|
+
- @copilotkit/shared@1.4.4-next.4
|
|
63
|
+
|
|
64
|
+
## 1.4.4-next.3
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 7cfc2e7: test prerelease stuff
|
|
69
|
+
- @copilotkit/shared@1.4.4-next.3
|
|
70
|
+
|
|
71
|
+
## 1.4.4-next.2
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- 665deab: test prerelease
|
|
76
|
+
- @copilotkit/shared@1.4.4-next.2
|
|
77
|
+
|
|
78
|
+
## 1.4.4-next.1
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- af36f1a: - feat(runtime): readme update
|
|
83
|
+
- @copilotkit/shared@1.4.4-next.1
|
|
84
|
+
|
|
85
|
+
## 1.4.4-next.0
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- @copilotkit/shared@1.4.4-next.0
|
|
90
|
+
|
|
27
91
|
## 1.4.3
|
|
28
92
|
|
|
29
93
|
### Patch Changes
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
input ActionExecutionMessageInput {
|
|
7
7
|
arguments: String!
|
|
8
8
|
name: String!
|
|
9
|
-
|
|
9
|
+
parentMessageId: String
|
|
10
|
+
scope: String @deprecated(reason: "This field will be removed in a future version")
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
type ActionExecutionMessageOutput implements BaseMessageOutput {
|
|
@@ -14,17 +15,11 @@ type ActionExecutionMessageOutput implements BaseMessageOutput {
|
|
|
14
15
|
createdAt: DateTimeISO!
|
|
15
16
|
id: String!
|
|
16
17
|
name: String!
|
|
17
|
-
|
|
18
|
+
parentMessageId: String
|
|
19
|
+
scope: String @deprecated(reason: "This field will be removed in a future version")
|
|
18
20
|
status: MessageStatus!
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
"""The scope of the action"""
|
|
22
|
-
enum ActionExecutionScope {
|
|
23
|
-
client
|
|
24
|
-
passThrough
|
|
25
|
-
server
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
input ActionInput {
|
|
29
24
|
available: ActionInputAvailability
|
|
30
25
|
description: String!
|
|
@@ -229,6 +224,7 @@ enum ResponseStatusCode {
|
|
|
229
224
|
input ResultMessageInput {
|
|
230
225
|
actionExecutionId: String!
|
|
231
226
|
actionName: String!
|
|
227
|
+
parentMessageId: String
|
|
232
228
|
result: String!
|
|
233
229
|
}
|
|
234
230
|
|
|
@@ -251,6 +247,7 @@ type SuccessResponseStatus implements BaseResponseStatus {
|
|
|
251
247
|
|
|
252
248
|
input TextMessageInput {
|
|
253
249
|
content: String!
|
|
250
|
+
parentMessageId: String
|
|
254
251
|
role: MessageRole!
|
|
255
252
|
}
|
|
256
253
|
|
|
@@ -258,6 +255,7 @@ type TextMessageOutput implements BaseMessageOutput {
|
|
|
258
255
|
content: [String!]!
|
|
259
256
|
createdAt: DateTimeISO!
|
|
260
257
|
id: String!
|
|
258
|
+
parentMessageId: String
|
|
261
259
|
role: MessageRole!
|
|
262
260
|
status: MessageStatus!
|
|
263
261
|
}
|
|
@@ -276,6 +276,8 @@ var OpenAIAdapter = class {
|
|
|
276
276
|
eventSource.stream(async (eventStream$) => {
|
|
277
277
|
var _a, _b;
|
|
278
278
|
let mode = null;
|
|
279
|
+
let currentMessageId;
|
|
280
|
+
let currentToolCallId;
|
|
279
281
|
for await (const chunk of stream) {
|
|
280
282
|
if (chunk.choices.length === 0) {
|
|
281
283
|
continue;
|
|
@@ -284,30 +286,52 @@ var OpenAIAdapter = class {
|
|
|
284
286
|
const content = chunk.choices[0].delta.content;
|
|
285
287
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
286
288
|
mode = null;
|
|
287
|
-
eventStream$.sendTextMessageEnd(
|
|
289
|
+
eventStream$.sendTextMessageEnd({
|
|
290
|
+
messageId: currentMessageId
|
|
291
|
+
});
|
|
288
292
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
289
293
|
mode = null;
|
|
290
|
-
eventStream$.sendActionExecutionEnd(
|
|
294
|
+
eventStream$.sendActionExecutionEnd({
|
|
295
|
+
actionExecutionId: currentToolCallId
|
|
296
|
+
});
|
|
291
297
|
}
|
|
292
298
|
if (mode === null) {
|
|
293
299
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
294
300
|
mode = "function";
|
|
295
|
-
|
|
301
|
+
currentToolCallId = toolCall.id;
|
|
302
|
+
eventStream$.sendActionExecutionStart({
|
|
303
|
+
actionExecutionId: currentToolCallId,
|
|
304
|
+
parentMessageId: chunk.id,
|
|
305
|
+
actionName: toolCall.function.name
|
|
306
|
+
});
|
|
296
307
|
} else if (content) {
|
|
297
308
|
mode = "message";
|
|
298
|
-
|
|
309
|
+
currentMessageId = chunk.id;
|
|
310
|
+
eventStream$.sendTextMessageStart({
|
|
311
|
+
messageId: currentMessageId
|
|
312
|
+
});
|
|
299
313
|
}
|
|
300
314
|
}
|
|
301
315
|
if (mode === "message" && content) {
|
|
302
|
-
eventStream$.sendTextMessageContent(
|
|
316
|
+
eventStream$.sendTextMessageContent({
|
|
317
|
+
messageId: currentMessageId,
|
|
318
|
+
content
|
|
319
|
+
});
|
|
303
320
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
304
|
-
eventStream$.sendActionExecutionArgs(
|
|
321
|
+
eventStream$.sendActionExecutionArgs({
|
|
322
|
+
actionExecutionId: currentToolCallId,
|
|
323
|
+
args: toolCall.function.arguments
|
|
324
|
+
});
|
|
305
325
|
}
|
|
306
326
|
}
|
|
307
327
|
if (mode === "message") {
|
|
308
|
-
eventStream$.sendTextMessageEnd(
|
|
328
|
+
eventStream$.sendTextMessageEnd({
|
|
329
|
+
messageId: currentMessageId
|
|
330
|
+
});
|
|
309
331
|
} else if (mode === "function") {
|
|
310
|
-
eventStream$.sendActionExecutionEnd(
|
|
332
|
+
eventStream$.sendActionExecutionEnd({
|
|
333
|
+
actionExecutionId: currentToolCallId
|
|
334
|
+
});
|
|
311
335
|
}
|
|
312
336
|
eventStream$.complete();
|
|
313
337
|
});
|
|
@@ -375,17 +399,25 @@ function isBaseMessageChunk(message) {
|
|
|
375
399
|
__name(isBaseMessageChunk, "isBaseMessageChunk");
|
|
376
400
|
function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
|
|
377
401
|
if (actionExecution) {
|
|
378
|
-
eventStream$.sendActionExecutionResult(
|
|
402
|
+
eventStream$.sendActionExecutionResult({
|
|
403
|
+
actionExecutionId: actionExecution.id,
|
|
404
|
+
actionName: actionExecution.name,
|
|
405
|
+
result: "Sending a message"
|
|
406
|
+
});
|
|
379
407
|
}
|
|
380
408
|
}
|
|
381
409
|
__name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
|
|
382
410
|
async function streamLangChainResponse({ result, eventStream$, actionExecution }) {
|
|
383
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
411
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
384
412
|
if (typeof result === "string") {
|
|
385
413
|
if (!actionExecution) {
|
|
386
414
|
eventStream$.sendTextMessage(randomId2(), result);
|
|
387
415
|
} else {
|
|
388
|
-
eventStream$.sendActionExecutionResult(
|
|
416
|
+
eventStream$.sendActionExecutionResult({
|
|
417
|
+
actionExecutionId: actionExecution.id,
|
|
418
|
+
actionName: actionExecution.name,
|
|
419
|
+
result
|
|
420
|
+
});
|
|
389
421
|
}
|
|
390
422
|
} else if (isAIMessage(result)) {
|
|
391
423
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -393,7 +425,11 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
393
425
|
eventStream$.sendTextMessage(randomId2(), result.content);
|
|
394
426
|
}
|
|
395
427
|
for (const toolCall of result.tool_calls) {
|
|
396
|
-
eventStream$.sendActionExecution(
|
|
428
|
+
eventStream$.sendActionExecution({
|
|
429
|
+
actionExecutionId: toolCall.id || randomId2(),
|
|
430
|
+
actionName: toolCall.name,
|
|
431
|
+
args: JSON.stringify(toolCall.args)
|
|
432
|
+
});
|
|
397
433
|
}
|
|
398
434
|
} else if (isBaseMessageChunk(result)) {
|
|
399
435
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -402,13 +438,18 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
402
438
|
}
|
|
403
439
|
if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
|
|
404
440
|
for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
|
|
405
|
-
eventStream$.sendActionExecution(
|
|
441
|
+
eventStream$.sendActionExecution({
|
|
442
|
+
actionExecutionId: toolCall.id || randomId2(),
|
|
443
|
+
actionName: toolCall.name,
|
|
444
|
+
args: JSON.stringify(toolCall.args)
|
|
445
|
+
});
|
|
406
446
|
}
|
|
407
447
|
}
|
|
408
448
|
} else if (result && "getReader" in result) {
|
|
409
449
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
410
450
|
let reader = result.getReader();
|
|
411
451
|
let mode = null;
|
|
452
|
+
let currentMessageId;
|
|
412
453
|
const toolCallDetails = {
|
|
413
454
|
name: null,
|
|
414
455
|
id: null,
|
|
@@ -447,10 +488,14 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
447
488
|
}
|
|
448
489
|
if (mode === "message" && (toolCallId || done)) {
|
|
449
490
|
mode = null;
|
|
450
|
-
eventStream$.sendTextMessageEnd(
|
|
491
|
+
eventStream$.sendTextMessageEnd({
|
|
492
|
+
messageId: currentMessageId
|
|
493
|
+
});
|
|
451
494
|
} else if (mode === "function" && (!hasToolCall || done)) {
|
|
452
495
|
mode = null;
|
|
453
|
-
eventStream$.sendActionExecutionEnd(
|
|
496
|
+
eventStream$.sendActionExecutionEnd({
|
|
497
|
+
actionExecutionId: toolCallId
|
|
498
|
+
});
|
|
454
499
|
}
|
|
455
500
|
if (done) {
|
|
456
501
|
break;
|
|
@@ -458,21 +503,40 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
458
503
|
if (mode === null) {
|
|
459
504
|
if (hasToolCall && toolCallId && toolCallName) {
|
|
460
505
|
mode = "function";
|
|
461
|
-
eventStream$.sendActionExecutionStart(
|
|
506
|
+
eventStream$.sendActionExecutionStart({
|
|
507
|
+
actionExecutionId: toolCallId,
|
|
508
|
+
actionName: toolCallName,
|
|
509
|
+
parentMessageId: (_i = value.lc_kwargs) == null ? void 0 : _i.id
|
|
510
|
+
});
|
|
462
511
|
} else if (content) {
|
|
463
512
|
mode = "message";
|
|
464
|
-
|
|
513
|
+
currentMessageId = ((_j = value.lc_kwargs) == null ? void 0 : _j.id) || randomId2();
|
|
514
|
+
eventStream$.sendTextMessageStart({
|
|
515
|
+
messageId: currentMessageId
|
|
516
|
+
});
|
|
465
517
|
}
|
|
466
518
|
}
|
|
467
519
|
if (mode === "message" && content) {
|
|
468
|
-
eventStream$.sendTextMessageContent(
|
|
520
|
+
eventStream$.sendTextMessageContent({
|
|
521
|
+
messageId: currentMessageId,
|
|
522
|
+
content: Array.isArray(content) ? ((_k = content[0]) == null ? void 0 : _k.text) ?? "" : content
|
|
523
|
+
});
|
|
469
524
|
} else if (mode === "function" && toolCallArgs) {
|
|
470
525
|
if (toolCallDetails.index !== toolCallDetails.prevIndex) {
|
|
471
|
-
eventStream$.sendActionExecutionEnd(
|
|
472
|
-
|
|
526
|
+
eventStream$.sendActionExecutionEnd({
|
|
527
|
+
actionExecutionId: toolCallId
|
|
528
|
+
});
|
|
529
|
+
eventStream$.sendActionExecutionStart({
|
|
530
|
+
actionExecutionId: toolCallId,
|
|
531
|
+
actionName: toolCallName,
|
|
532
|
+
parentMessageId: (_l = value.lc_kwargs) == null ? void 0 : _l.id
|
|
533
|
+
});
|
|
473
534
|
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
474
535
|
}
|
|
475
|
-
eventStream$.sendActionExecutionArgs(
|
|
536
|
+
eventStream$.sendActionExecutionArgs({
|
|
537
|
+
actionExecutionId: toolCallId,
|
|
538
|
+
args: toolCallArgs
|
|
539
|
+
});
|
|
476
540
|
}
|
|
477
541
|
} catch (error) {
|
|
478
542
|
console.error("Error reading from stream", error);
|
|
@@ -480,7 +544,11 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
480
544
|
}
|
|
481
545
|
}
|
|
482
546
|
} else if (actionExecution) {
|
|
483
|
-
eventStream$.sendActionExecutionResult(
|
|
547
|
+
eventStream$.sendActionExecutionResult({
|
|
548
|
+
actionExecutionId: actionExecution.id,
|
|
549
|
+
actionName: actionExecution.name,
|
|
550
|
+
result: encodeResult(result)
|
|
551
|
+
});
|
|
484
552
|
} else {
|
|
485
553
|
throw new Error("Invalid return type from LangChain function.");
|
|
486
554
|
}
|
|
@@ -660,21 +728,33 @@ var OpenAIAssistantAdapter = class {
|
|
|
660
728
|
eventSource.stream(async (eventStream$) => {
|
|
661
729
|
var _a, _b, _c, _d, _e, _f;
|
|
662
730
|
let inFunctionCall = false;
|
|
731
|
+
let currentMessageId;
|
|
732
|
+
let currentToolCallId;
|
|
663
733
|
for await (const chunk of stream) {
|
|
664
734
|
switch (chunk.event) {
|
|
665
735
|
case "thread.message.created":
|
|
666
736
|
if (inFunctionCall) {
|
|
667
|
-
eventStream$.sendActionExecutionEnd(
|
|
737
|
+
eventStream$.sendActionExecutionEnd({
|
|
738
|
+
actionExecutionId: currentToolCallId
|
|
739
|
+
});
|
|
668
740
|
}
|
|
669
|
-
|
|
741
|
+
currentMessageId = chunk.data.id;
|
|
742
|
+
eventStream$.sendTextMessageStart({
|
|
743
|
+
messageId: currentMessageId
|
|
744
|
+
});
|
|
670
745
|
break;
|
|
671
746
|
case "thread.message.delta":
|
|
672
747
|
if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
|
|
673
|
-
eventStream$.sendTextMessageContent(
|
|
748
|
+
eventStream$.sendTextMessageContent({
|
|
749
|
+
messageId: currentMessageId,
|
|
750
|
+
content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
|
|
751
|
+
});
|
|
674
752
|
}
|
|
675
753
|
break;
|
|
676
754
|
case "thread.message.completed":
|
|
677
|
-
eventStream$.sendTextMessageEnd(
|
|
755
|
+
eventStream$.sendTextMessageEnd({
|
|
756
|
+
messageId: currentMessageId
|
|
757
|
+
});
|
|
678
758
|
break;
|
|
679
759
|
case "thread.run.step.delta":
|
|
680
760
|
let toolCallId;
|
|
@@ -687,18 +767,30 @@ var OpenAIAssistantAdapter = class {
|
|
|
687
767
|
}
|
|
688
768
|
if (toolCallName && toolCallId) {
|
|
689
769
|
if (inFunctionCall) {
|
|
690
|
-
eventStream$.sendActionExecutionEnd(
|
|
770
|
+
eventStream$.sendActionExecutionEnd({
|
|
771
|
+
actionExecutionId: currentToolCallId
|
|
772
|
+
});
|
|
691
773
|
}
|
|
692
774
|
inFunctionCall = true;
|
|
693
|
-
|
|
775
|
+
currentToolCallId = toolCallId;
|
|
776
|
+
eventStream$.sendActionExecutionStart({
|
|
777
|
+
actionExecutionId: currentToolCallId,
|
|
778
|
+
parentMessageId: chunk.data.id,
|
|
779
|
+
actionName: toolCallName
|
|
780
|
+
});
|
|
694
781
|
} else if (toolCallArgs) {
|
|
695
|
-
eventStream$.sendActionExecutionArgs(
|
|
782
|
+
eventStream$.sendActionExecutionArgs({
|
|
783
|
+
actionExecutionId: currentToolCallId,
|
|
784
|
+
args: toolCallArgs
|
|
785
|
+
});
|
|
696
786
|
}
|
|
697
787
|
break;
|
|
698
788
|
}
|
|
699
789
|
}
|
|
700
790
|
if (inFunctionCall) {
|
|
701
|
-
eventStream$.sendActionExecutionEnd(
|
|
791
|
+
eventStream$.sendActionExecutionEnd({
|
|
792
|
+
actionExecutionId: currentToolCallId
|
|
793
|
+
});
|
|
702
794
|
}
|
|
703
795
|
eventStream$.complete();
|
|
704
796
|
});
|
|
@@ -751,46 +843,77 @@ var UnifyAdapter = class {
|
|
|
751
843
|
}
|
|
752
844
|
});
|
|
753
845
|
let model = null;
|
|
846
|
+
let currentMessageId;
|
|
847
|
+
let currentToolCallId;
|
|
754
848
|
request.eventSource.stream(async (eventStream$) => {
|
|
755
849
|
var _a, _b;
|
|
756
850
|
let mode = null;
|
|
757
851
|
for await (const chunk of stream) {
|
|
758
852
|
if (this.start) {
|
|
759
853
|
model = chunk.model;
|
|
760
|
-
|
|
761
|
-
eventStream$.
|
|
762
|
-
|
|
763
|
-
|
|
854
|
+
currentMessageId = randomId4();
|
|
855
|
+
eventStream$.sendTextMessageStart({
|
|
856
|
+
messageId: currentMessageId
|
|
857
|
+
});
|
|
858
|
+
eventStream$.sendTextMessageContent({
|
|
859
|
+
messageId: currentMessageId,
|
|
860
|
+
content: `Model used: ${model}
|
|
861
|
+
`
|
|
862
|
+
});
|
|
863
|
+
eventStream$.sendTextMessageEnd({
|
|
864
|
+
messageId: currentMessageId
|
|
865
|
+
});
|
|
764
866
|
this.start = false;
|
|
765
867
|
}
|
|
766
868
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
767
869
|
const content = chunk.choices[0].delta.content;
|
|
768
870
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
769
871
|
mode = null;
|
|
770
|
-
eventStream$.sendTextMessageEnd(
|
|
872
|
+
eventStream$.sendTextMessageEnd({
|
|
873
|
+
messageId: currentMessageId
|
|
874
|
+
});
|
|
771
875
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
772
876
|
mode = null;
|
|
773
|
-
eventStream$.sendActionExecutionEnd(
|
|
877
|
+
eventStream$.sendActionExecutionEnd({
|
|
878
|
+
actionExecutionId: currentToolCallId
|
|
879
|
+
});
|
|
774
880
|
}
|
|
775
881
|
if (mode === null) {
|
|
776
882
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
777
883
|
mode = "function";
|
|
778
|
-
|
|
884
|
+
currentToolCallId = toolCall.id;
|
|
885
|
+
eventStream$.sendActionExecutionStart({
|
|
886
|
+
actionExecutionId: currentToolCallId,
|
|
887
|
+
actionName: toolCall.function.name
|
|
888
|
+
});
|
|
779
889
|
} else if (content) {
|
|
780
890
|
mode = "message";
|
|
781
|
-
|
|
891
|
+
currentMessageId = chunk.id;
|
|
892
|
+
eventStream$.sendTextMessageStart({
|
|
893
|
+
messageId: currentMessageId
|
|
894
|
+
});
|
|
782
895
|
}
|
|
783
896
|
}
|
|
784
897
|
if (mode === "message" && content) {
|
|
785
|
-
eventStream$.sendTextMessageContent(
|
|
898
|
+
eventStream$.sendTextMessageContent({
|
|
899
|
+
messageId: currentMessageId,
|
|
900
|
+
content
|
|
901
|
+
});
|
|
786
902
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
787
|
-
eventStream$.sendActionExecutionArgs(
|
|
903
|
+
eventStream$.sendActionExecutionArgs({
|
|
904
|
+
actionExecutionId: currentToolCallId,
|
|
905
|
+
args: toolCall.function.arguments
|
|
906
|
+
});
|
|
788
907
|
}
|
|
789
908
|
}
|
|
790
909
|
if (mode === "message") {
|
|
791
|
-
eventStream$.sendTextMessageEnd(
|
|
910
|
+
eventStream$.sendTextMessageEnd({
|
|
911
|
+
messageId: currentMessageId
|
|
912
|
+
});
|
|
792
913
|
} else if (mode === "function") {
|
|
793
|
-
eventStream$.sendActionExecutionEnd(
|
|
914
|
+
eventStream$.sendActionExecutionEnd({
|
|
915
|
+
actionExecutionId: currentToolCallId
|
|
916
|
+
});
|
|
794
917
|
}
|
|
795
918
|
eventStream$.complete();
|
|
796
919
|
});
|
|
@@ -856,35 +979,59 @@ var GroqAdapter = class {
|
|
|
856
979
|
eventSource.stream(async (eventStream$) => {
|
|
857
980
|
var _a, _b;
|
|
858
981
|
let mode = null;
|
|
982
|
+
let currentMessageId;
|
|
983
|
+
let currentToolCallId;
|
|
859
984
|
for await (const chunk of stream) {
|
|
860
985
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
861
986
|
const content = chunk.choices[0].delta.content;
|
|
862
987
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
863
988
|
mode = null;
|
|
864
|
-
eventStream$.sendTextMessageEnd(
|
|
989
|
+
eventStream$.sendTextMessageEnd({
|
|
990
|
+
messageId: currentMessageId
|
|
991
|
+
});
|
|
865
992
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
866
993
|
mode = null;
|
|
867
|
-
eventStream$.sendActionExecutionEnd(
|
|
994
|
+
eventStream$.sendActionExecutionEnd({
|
|
995
|
+
actionExecutionId: currentToolCallId
|
|
996
|
+
});
|
|
868
997
|
}
|
|
869
998
|
if (mode === null) {
|
|
870
999
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
871
1000
|
mode = "function";
|
|
872
|
-
|
|
1001
|
+
currentToolCallId = toolCall.id;
|
|
1002
|
+
eventStream$.sendActionExecutionStart({
|
|
1003
|
+
actionExecutionId: currentToolCallId,
|
|
1004
|
+
actionName: toolCall.function.name,
|
|
1005
|
+
parentMessageId: chunk.id
|
|
1006
|
+
});
|
|
873
1007
|
} else if (content) {
|
|
874
1008
|
mode = "message";
|
|
875
|
-
|
|
1009
|
+
currentMessageId = chunk.id;
|
|
1010
|
+
eventStream$.sendTextMessageStart({
|
|
1011
|
+
messageId: currentMessageId
|
|
1012
|
+
});
|
|
876
1013
|
}
|
|
877
1014
|
}
|
|
878
1015
|
if (mode === "message" && content) {
|
|
879
|
-
eventStream$.sendTextMessageContent(
|
|
1016
|
+
eventStream$.sendTextMessageContent({
|
|
1017
|
+
messageId: currentMessageId,
|
|
1018
|
+
content
|
|
1019
|
+
});
|
|
880
1020
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
881
|
-
eventStream$.sendActionExecutionArgs(
|
|
1021
|
+
eventStream$.sendActionExecutionArgs({
|
|
1022
|
+
actionExecutionId: currentToolCallId,
|
|
1023
|
+
args: toolCall.function.arguments
|
|
1024
|
+
});
|
|
882
1025
|
}
|
|
883
1026
|
}
|
|
884
1027
|
if (mode === "message") {
|
|
885
|
-
eventStream$.sendTextMessageEnd(
|
|
1028
|
+
eventStream$.sendTextMessageEnd({
|
|
1029
|
+
messageId: currentMessageId
|
|
1030
|
+
});
|
|
886
1031
|
} else if (mode === "function") {
|
|
887
|
-
eventStream$.sendActionExecutionEnd(
|
|
1032
|
+
eventStream$.sendActionExecutionEnd({
|
|
1033
|
+
actionExecutionId: currentToolCallId
|
|
1034
|
+
});
|
|
888
1035
|
}
|
|
889
1036
|
eventStream$.complete();
|
|
890
1037
|
});
|
|
@@ -1092,7 +1239,11 @@ var AnthropicAdapter = class {
|
|
|
1092
1239
|
mode = "message";
|
|
1093
1240
|
} else if (chunk.content_block.type === "tool_use") {
|
|
1094
1241
|
currentToolCallId = chunk.content_block.id;
|
|
1095
|
-
eventStream$.sendActionExecutionStart(
|
|
1242
|
+
eventStream$.sendActionExecutionStart({
|
|
1243
|
+
actionExecutionId: currentToolCallId,
|
|
1244
|
+
actionName: chunk.content_block.name,
|
|
1245
|
+
parentMessageId: currentMessageId
|
|
1246
|
+
});
|
|
1096
1247
|
mode = "function";
|
|
1097
1248
|
}
|
|
1098
1249
|
} else if (chunk.type === "content_block_delta") {
|
|
@@ -1100,21 +1251,33 @@ var AnthropicAdapter = class {
|
|
|
1100
1251
|
const text = filterThinkingTextBuffer.onTextChunk(chunk.delta.text);
|
|
1101
1252
|
if (text.length > 0) {
|
|
1102
1253
|
if (!didOutputText) {
|
|
1103
|
-
eventStream$.sendTextMessageStart(
|
|
1254
|
+
eventStream$.sendTextMessageStart({
|
|
1255
|
+
messageId: currentMessageId
|
|
1256
|
+
});
|
|
1104
1257
|
didOutputText = true;
|
|
1105
1258
|
}
|
|
1106
|
-
eventStream$.sendTextMessageContent(
|
|
1259
|
+
eventStream$.sendTextMessageContent({
|
|
1260
|
+
messageId: currentMessageId,
|
|
1261
|
+
content: text
|
|
1262
|
+
});
|
|
1107
1263
|
}
|
|
1108
1264
|
} else if (chunk.delta.type === "input_json_delta") {
|
|
1109
|
-
eventStream$.sendActionExecutionArgs(
|
|
1265
|
+
eventStream$.sendActionExecutionArgs({
|
|
1266
|
+
actionExecutionId: currentToolCallId,
|
|
1267
|
+
args: chunk.delta.partial_json
|
|
1268
|
+
});
|
|
1110
1269
|
}
|
|
1111
1270
|
} else if (chunk.type === "content_block_stop") {
|
|
1112
1271
|
if (mode === "message") {
|
|
1113
1272
|
if (didOutputText) {
|
|
1114
|
-
eventStream$.sendTextMessageEnd(
|
|
1273
|
+
eventStream$.sendTextMessageEnd({
|
|
1274
|
+
messageId: currentMessageId
|
|
1275
|
+
});
|
|
1115
1276
|
}
|
|
1116
1277
|
} else if (mode === "function") {
|
|
1117
|
-
eventStream$.sendActionExecutionEnd(
|
|
1278
|
+
eventStream$.sendActionExecutionEnd({
|
|
1279
|
+
actionExecutionId: currentToolCallId
|
|
1280
|
+
});
|
|
1118
1281
|
}
|
|
1119
1282
|
}
|
|
1120
1283
|
}
|
|
@@ -1170,4 +1333,4 @@ export {
|
|
|
1170
1333
|
GroqAdapter,
|
|
1171
1334
|
AnthropicAdapter
|
|
1172
1335
|
};
|
|
1173
|
-
//# sourceMappingURL=chunk-
|
|
1336
|
+
//# sourceMappingURL=chunk-2PK2SFRB.mjs.map
|