@copilotkit/runtime 1.3.12 → 1.3.14-fix-handle-execute-agent-error.0
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 +16 -0
- package/dist/{chunk-ZEHCLFJ2.mjs → chunk-CPAHDRLS.mjs} +28 -4
- package/dist/chunk-CPAHDRLS.mjs.map +1 -0
- package/dist/{chunk-F2KJWMGD.mjs → chunk-GVAUIADR.mjs} +35 -28
- package/dist/chunk-GVAUIADR.mjs.map +1 -0
- package/dist/{chunk-IXVCESAR.mjs → chunk-LB3EPUOQ.mjs} +3 -3
- package/dist/{chunk-PRG6VWHR.mjs → chunk-LOMWWP44.mjs} +2 -2
- package/dist/{chunk-IZP72K7I.mjs → chunk-QXHQKRLT.mjs} +2 -2
- package/dist/{chunk-WBLYFYMZ.mjs → chunk-VN26GZV4.mjs} +2 -2
- package/dist/{chunk-24WEOOFX.mjs → chunk-Y6RQG5HF.mjs} +2 -2
- package/dist/index.js +60 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/lib/index.js +60 -29
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -7
- package/dist/lib/integrations/index.js +1 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.js +1 -1
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.js +1 -1
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.js +1 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.js +27 -3
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +2 -2
- package/package.json +4 -4
- package/src/lib/runtime/remote-actions.ts +33 -24
- package/src/service-adapters/langchain/utils.ts +31 -3
- package/dist/chunk-F2KJWMGD.mjs.map +0 -1
- package/dist/chunk-ZEHCLFJ2.mjs.map +0 -1
- /package/dist/{chunk-IXVCESAR.mjs.map → chunk-LB3EPUOQ.mjs.map} +0 -0
- /package/dist/{chunk-PRG6VWHR.mjs.map → chunk-LOMWWP44.mjs.map} +0 -0
- /package/dist/{chunk-IZP72K7I.mjs.map → chunk-QXHQKRLT.mjs.map} +0 -0
- /package/dist/{chunk-WBLYFYMZ.mjs.map → chunk-VN26GZV4.mjs.map} +0 -0
- /package/dist/{chunk-24WEOOFX.mjs.map → chunk-Y6RQG5HF.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotRuntime,
|
|
3
3
|
flattenToolCallsNoDuplicates
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LB3EPUOQ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
AnthropicAdapter,
|
|
7
7
|
GoogleGenerativeAIAdapter,
|
|
@@ -11,25 +11,25 @@ import {
|
|
|
11
11
|
OpenAIAssistantAdapter,
|
|
12
12
|
RemoteChain,
|
|
13
13
|
UnifyAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Y6RQG5HF.mjs";
|
|
15
15
|
import {
|
|
16
16
|
config,
|
|
17
17
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
18
18
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QXHQKRLT.mjs";
|
|
20
20
|
import {
|
|
21
21
|
copilotRuntimeNestEndpoint
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LOMWWP44.mjs";
|
|
23
23
|
import {
|
|
24
24
|
copilotRuntimeNodeExpressEndpoint
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-VN26GZV4.mjs";
|
|
26
26
|
import {
|
|
27
27
|
buildSchema,
|
|
28
28
|
copilotRuntimeNodeHttpEndpoint,
|
|
29
29
|
createContext,
|
|
30
30
|
getCommonConfig
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-GVAUIADR.mjs";
|
|
32
|
+
import "./chunk-CPAHDRLS.mjs";
|
|
33
33
|
import {
|
|
34
34
|
GuardrailsValidationFailureResponse,
|
|
35
35
|
MessageStreamInterruptedResponse,
|
package/dist/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.3.
|
|
47
|
+
version: "1.3.14-fix-handle-execute-agent-error.0",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -577,20 +577,39 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
577
577
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
578
578
|
let reader = result.getReader();
|
|
579
579
|
let mode = null;
|
|
580
|
+
const toolCallDetails = {
|
|
581
|
+
name: null,
|
|
582
|
+
id: null,
|
|
583
|
+
index: null,
|
|
584
|
+
prevIndex: null
|
|
585
|
+
};
|
|
580
586
|
while (true) {
|
|
581
587
|
try {
|
|
582
588
|
const { done, value } = await reader.read();
|
|
583
589
|
let toolCallName = void 0;
|
|
584
590
|
let toolCallId = void 0;
|
|
585
591
|
let toolCallArgs = void 0;
|
|
592
|
+
let toolCallIndex = void 0;
|
|
593
|
+
let toolCallPrevIndex = void 0;
|
|
586
594
|
let hasToolCall = false;
|
|
587
595
|
let content = value == null ? void 0 : value.content;
|
|
588
596
|
if (isAIMessageChunk(value)) {
|
|
589
597
|
let chunk = (_d = value.tool_call_chunks) == null ? void 0 : _d[0];
|
|
590
|
-
toolCallName = chunk == null ? void 0 : chunk.name;
|
|
591
|
-
toolCallId = chunk == null ? void 0 : chunk.id;
|
|
592
598
|
toolCallArgs = chunk == null ? void 0 : chunk.args;
|
|
593
599
|
hasToolCall = chunk != void 0;
|
|
600
|
+
if (chunk == null ? void 0 : chunk.name)
|
|
601
|
+
toolCallDetails.name = chunk.name;
|
|
602
|
+
if ((chunk == null ? void 0 : chunk.index) != null) {
|
|
603
|
+
toolCallDetails.index = chunk.index;
|
|
604
|
+
if (toolCallDetails.prevIndex == null)
|
|
605
|
+
toolCallDetails.prevIndex = chunk.index;
|
|
606
|
+
}
|
|
607
|
+
if (chunk == null ? void 0 : chunk.id)
|
|
608
|
+
toolCallDetails.id = chunk.index != null ? `${chunk.id}-idx-${chunk.index}` : chunk.id;
|
|
609
|
+
toolCallName = toolCallDetails.name;
|
|
610
|
+
toolCallId = toolCallDetails.id;
|
|
611
|
+
toolCallIndex = toolCallDetails.index;
|
|
612
|
+
toolCallPrevIndex = toolCallDetails.prevIndex;
|
|
594
613
|
} else if (isBaseMessageChunk(value)) {
|
|
595
614
|
let chunk = (_f = (_e = value.additional_kwargs) == null ? void 0 : _e.tool_calls) == null ? void 0 : _f[0];
|
|
596
615
|
toolCallName = (_g = chunk == null ? void 0 : chunk.function) == null ? void 0 : _g.name;
|
|
@@ -609,7 +628,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
609
628
|
break;
|
|
610
629
|
}
|
|
611
630
|
if (mode === null) {
|
|
612
|
-
if (hasToolCall) {
|
|
631
|
+
if (hasToolCall && toolCallId && toolCallName) {
|
|
613
632
|
mode = "function";
|
|
614
633
|
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
615
634
|
} else if (content) {
|
|
@@ -620,6 +639,11 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
620
639
|
if (mode === "message" && content) {
|
|
621
640
|
eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
|
|
622
641
|
} else if (mode === "function" && toolCallArgs) {
|
|
642
|
+
if (toolCallIndex !== toolCallPrevIndex) {
|
|
643
|
+
eventStream$.sendActionExecutionEnd();
|
|
644
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
645
|
+
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
646
|
+
}
|
|
623
647
|
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
624
648
|
}
|
|
625
649
|
} catch (error) {
|
|
@@ -1435,34 +1459,41 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1435
1459
|
state = JSON.parse(jsonState);
|
|
1436
1460
|
}
|
|
1437
1461
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1462
|
+
try {
|
|
1463
|
+
const response = await fetch(`${url}/agents/execute`, {
|
|
1464
|
+
method: "POST",
|
|
1465
|
+
headers,
|
|
1466
|
+
body: JSON.stringify({
|
|
1467
|
+
name,
|
|
1468
|
+
threadId,
|
|
1469
|
+
nodeName,
|
|
1470
|
+
messages,
|
|
1471
|
+
state,
|
|
1472
|
+
properties: graphqlContext.properties,
|
|
1473
|
+
actions: actionInputsWithoutAgents.map((action) => ({
|
|
1474
|
+
name: action.name,
|
|
1475
|
+
description: action.description,
|
|
1476
|
+
parameters: JSON.parse(action.jsonSchema)
|
|
1477
|
+
}))
|
|
1478
|
+
})
|
|
1479
|
+
});
|
|
1480
|
+
if (!response.ok) {
|
|
1481
|
+
logger2.error({
|
|
1482
|
+
url,
|
|
1483
|
+
status: response.status,
|
|
1484
|
+
body: await response.text()
|
|
1485
|
+
}, "Failed to execute remote agent");
|
|
1486
|
+
throw "Failed to execute remote agent";
|
|
1487
|
+
}
|
|
1488
|
+
const eventSource = new RemoteLangGraphEventSource();
|
|
1489
|
+
eventSource.streamResponse(response);
|
|
1490
|
+
return eventSource.processLangGraphEvents();
|
|
1491
|
+
} catch (error) {
|
|
1456
1492
|
logger2.error({
|
|
1457
|
-
|
|
1458
|
-
status: response.status,
|
|
1459
|
-
body: await response.text()
|
|
1493
|
+
error: error.message ? error.message : error + ""
|
|
1460
1494
|
}, "Failed to execute remote agent");
|
|
1461
|
-
throw
|
|
1495
|
+
throw "Failed to execute remote agent";
|
|
1462
1496
|
}
|
|
1463
|
-
const eventSource = new RemoteLangGraphEventSource();
|
|
1464
|
-
eventSource.streamResponse(response);
|
|
1465
|
-
return eventSource.processLangGraphEvents();
|
|
1466
1497
|
}
|
|
1467
1498
|
}));
|
|
1468
1499
|
return [
|