@copilotkit/runtime 1.9.2-next.5 → 1.9.2-next.6
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 +7 -0
- package/dist/{chunk-T4U5EWYD.mjs → chunk-6AD7VT26.mjs} +2 -2
- package/dist/{chunk-BLBS3CQH.mjs → chunk-6FLO2QTT.mjs} +2 -2
- package/dist/{chunk-5WRXYU4R.mjs → chunk-JZWHLURE.mjs} +2 -2
- package/dist/{chunk-RK7WRNH6.mjs → chunk-K4JQLKXK.mjs} +2 -2
- package/dist/{chunk-ZVJSUAD7.mjs → chunk-RCIYK6YJ.mjs} +107 -53
- package/dist/chunk-RCIYK6YJ.mjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +101 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +101 -47
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +2 -2
- package/dist/lib/integrations/index.js +4 -4
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +1 -1
- package/dist/lib/integrations/nest/index.js +4 -4
- 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.d.ts +1 -1
- package/dist/lib/integrations/node-express/index.js +4 -4
- 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.d.ts +1 -1
- package/dist/lib/integrations/node-http/index.js +4 -4
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/{shared-ba062831.d.ts → shared-941d59dc.d.ts} +2 -0
- package/package.json +2 -2
- package/src/graphql/resolvers/state.resolver.ts +3 -3
- package/src/lib/runtime/copilot-runtime.ts +114 -41
- package/dist/chunk-ZVJSUAD7.mjs.map +0 -1
- /package/dist/{chunk-T4U5EWYD.mjs.map → chunk-6AD7VT26.mjs.map} +0 -0
- /package/dist/{chunk-BLBS3CQH.mjs.map → chunk-6FLO2QTT.mjs.map} +0 -0
- /package/dist/{chunk-5WRXYU4R.mjs.map → chunk-JZWHLURE.mjs.map} +0 -0
- /package/dist/{chunk-RK7WRNH6.mjs.map → chunk-K4JQLKXK.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getCommonConfig,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RCIYK6YJ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
config,
|
|
78
78
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-6AD7VT26.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LangGraphEventTypes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RCIYK6YJ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
CustomEventNames,
|
|
139
139
|
LangGraphAgent
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-6FLO2QTT.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RCIYK6YJ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNodeExpressEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-JZWHLURE.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RCIYK6YJ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNestEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-K4JQLKXK.mjs.map
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EmptyAdapter,
|
|
3
|
-
RemoteChain,
|
|
4
|
-
streamLangChainResponse
|
|
5
|
-
} from "./chunk-IIXJVVTV.mjs";
|
|
6
1
|
import {
|
|
7
2
|
GuardrailsValidationFailureResponse,
|
|
8
3
|
MessageStreamInterruptedResponse,
|
|
@@ -10,6 +5,11 @@ import {
|
|
|
10
5
|
SuccessResponseStatus,
|
|
11
6
|
UnknownErrorResponse
|
|
12
7
|
} from "./chunk-5BIEM2UU.mjs";
|
|
8
|
+
import {
|
|
9
|
+
EmptyAdapter,
|
|
10
|
+
RemoteChain,
|
|
11
|
+
streamLangChainResponse
|
|
12
|
+
} from "./chunk-IIXJVVTV.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ActionExecutionMessage,
|
|
15
15
|
AgentStateMessage,
|
|
@@ -40,7 +40,7 @@ var require_package = __commonJS({
|
|
|
40
40
|
publishConfig: {
|
|
41
41
|
access: "public"
|
|
42
42
|
},
|
|
43
|
-
version: "1.9.2-next.
|
|
43
|
+
version: "1.9.2-next.6",
|
|
44
44
|
sideEffects: false,
|
|
45
45
|
main: "./dist/index.js",
|
|
46
46
|
module: "./dist/index.mjs",
|
|
@@ -3232,6 +3232,7 @@ var CopilotRuntime = class {
|
|
|
3232
3232
|
var _a, _b, _c, _d;
|
|
3233
3233
|
if ((params == null ? void 0 : params.actions) && (params == null ? void 0 : params.remoteEndpoints) && (params == null ? void 0 : params.remoteEndpoints.some((e) => e.type === EndpointType.LangGraphPlatform))) {
|
|
3234
3234
|
console.warn("Actions set in runtime instance will not be available for the agent");
|
|
3235
|
+
console.warn(`LangGraph Platform remote endpoints are deprecated in favor of the "agents" property`);
|
|
3235
3236
|
}
|
|
3236
3237
|
this.actions = (params == null ? void 0 : params.actions) || [];
|
|
3237
3238
|
this.availableAgents = [];
|
|
@@ -3546,6 +3547,23 @@ please use an LLM adapter instead.`
|
|
|
3546
3547
|
throw structuredError;
|
|
3547
3548
|
}
|
|
3548
3549
|
}
|
|
3550
|
+
async getAllAgents(graphqlContext) {
|
|
3551
|
+
const [agentsWithEndpoints, aguiAgents] = await Promise.all([
|
|
3552
|
+
this.discoverAgentsFromEndpoints(graphqlContext),
|
|
3553
|
+
this.discoverAgentsFromAgui()
|
|
3554
|
+
]);
|
|
3555
|
+
this.availableAgents = [
|
|
3556
|
+
...agentsWithEndpoints,
|
|
3557
|
+
...aguiAgents
|
|
3558
|
+
].map((a) => ({
|
|
3559
|
+
name: a.name,
|
|
3560
|
+
id: a.id
|
|
3561
|
+
}));
|
|
3562
|
+
return [
|
|
3563
|
+
...agentsWithEndpoints,
|
|
3564
|
+
...aguiAgents
|
|
3565
|
+
];
|
|
3566
|
+
}
|
|
3549
3567
|
async discoverAgentsFromEndpoints(graphqlContext) {
|
|
3550
3568
|
const agents = this.remoteEndpointDefinitions.reduce(async (acc, endpoint) => {
|
|
3551
3569
|
const agents2 = await acc;
|
|
@@ -3631,53 +3649,49 @@ please use an LLM adapter instead.`
|
|
|
3631
3649
|
});
|
|
3632
3650
|
}
|
|
3633
3651
|
}, Promise.resolve([]));
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3652
|
+
return agents;
|
|
3653
|
+
}
|
|
3654
|
+
async discoverAgentsFromAgui() {
|
|
3655
|
+
const agents = Object.values(this.agents ?? []).reduce(async (acc, agent) => {
|
|
3656
|
+
const agents2 = await acc;
|
|
3657
|
+
const client = agent.client;
|
|
3658
|
+
let data = [];
|
|
3659
|
+
try {
|
|
3660
|
+
data = await client.assistants.search();
|
|
3661
|
+
if (data && "detail" in data && data.detail.toLowerCase() === "not found") {
|
|
3662
|
+
throw new CopilotKitAgentDiscoveryError({
|
|
3663
|
+
availableAgents: this.availableAgents
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
} catch (e) {
|
|
3667
|
+
throw new CopilotKitMisuseError2({
|
|
3668
|
+
message: `
|
|
3669
|
+
Failed to find or contact agent ${agent.graphId}.
|
|
3670
|
+
Make sure the LangGraph API is running and the agent is defined in langgraph.json
|
|
3671
|
+
|
|
3672
|
+
See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
const endpointAgents = data.map((entry) => ({
|
|
3676
|
+
name: entry.graph_id,
|
|
3677
|
+
id: entry.assistant_id,
|
|
3678
|
+
description: ""
|
|
3679
|
+
}));
|
|
3680
|
+
return [
|
|
3681
|
+
...agents2,
|
|
3682
|
+
...endpointAgents
|
|
3683
|
+
];
|
|
3684
|
+
}, Promise.resolve([]));
|
|
3638
3685
|
return agents;
|
|
3639
3686
|
}
|
|
3640
3687
|
async loadAgentState(graphqlContext, threadId, agentName) {
|
|
3641
|
-
const
|
|
3642
|
-
const
|
|
3643
|
-
if (!
|
|
3688
|
+
const agents = await this.getAllAgents(graphqlContext);
|
|
3689
|
+
const agent = agents.find((agent2) => agent2.name === agentName);
|
|
3690
|
+
if (!agent) {
|
|
3644
3691
|
throw new Error("Agent not found");
|
|
3645
3692
|
}
|
|
3646
|
-
if (
|
|
3647
|
-
const
|
|
3648
|
-
authorization: `Bearer ${graphqlContext.properties.authorization}`
|
|
3649
|
-
} : null;
|
|
3650
|
-
const client = new LangGraphClient2({
|
|
3651
|
-
apiUrl: agentWithEndpoint.endpoint.deploymentUrl,
|
|
3652
|
-
apiKey: agentWithEndpoint.endpoint.langsmithApiKey,
|
|
3653
|
-
defaultHeaders: {
|
|
3654
|
-
...propertyHeaders
|
|
3655
|
-
}
|
|
3656
|
-
});
|
|
3657
|
-
let state = {};
|
|
3658
|
-
try {
|
|
3659
|
-
state = (await client.threads.getState(threadId)).values;
|
|
3660
|
-
} catch (error) {
|
|
3661
|
-
}
|
|
3662
|
-
if (Object.keys(state).length === 0) {
|
|
3663
|
-
return {
|
|
3664
|
-
threadId: threadId || "",
|
|
3665
|
-
threadExists: false,
|
|
3666
|
-
state: JSON.stringify({}),
|
|
3667
|
-
messages: JSON.stringify([])
|
|
3668
|
-
};
|
|
3669
|
-
} else {
|
|
3670
|
-
const { messages, ...stateWithoutMessages } = state;
|
|
3671
|
-
const copilotkitMessages = langchainMessagesToCopilotKit(messages);
|
|
3672
|
-
return {
|
|
3673
|
-
threadId: threadId || "",
|
|
3674
|
-
threadExists: true,
|
|
3675
|
-
state: JSON.stringify(stateWithoutMessages),
|
|
3676
|
-
messages: JSON.stringify(copilotkitMessages)
|
|
3677
|
-
};
|
|
3678
|
-
}
|
|
3679
|
-
} else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
|
|
3680
|
-
const cpkEndpoint = agentWithEndpoint.endpoint;
|
|
3693
|
+
if ("endpoint" in agent && (agent.endpoint.type === EndpointType.CopilotKit || !("type" in agent.endpoint))) {
|
|
3694
|
+
const cpkEndpoint = agent.endpoint;
|
|
3681
3695
|
const fetchUrl = `${cpkEndpoint.url}/agents/state`;
|
|
3682
3696
|
try {
|
|
3683
3697
|
const response = await fetchWithRetry(fetchUrl, {
|
|
@@ -3716,9 +3730,49 @@ please use an LLM adapter instead.`
|
|
|
3716
3730
|
url: fetchUrl
|
|
3717
3731
|
});
|
|
3718
3732
|
}
|
|
3733
|
+
}
|
|
3734
|
+
const propertyHeaders = graphqlContext.properties.authorization ? {
|
|
3735
|
+
authorization: `Bearer ${graphqlContext.properties.authorization}`
|
|
3736
|
+
} : null;
|
|
3737
|
+
let client;
|
|
3738
|
+
if ("endpoint" in agent && agent.endpoint.type === EndpointType.LangGraphPlatform) {
|
|
3739
|
+
client = new LangGraphClient2({
|
|
3740
|
+
apiUrl: agent.endpoint.deploymentUrl,
|
|
3741
|
+
apiKey: agent.endpoint.langsmithApiKey,
|
|
3742
|
+
defaultHeaders: {
|
|
3743
|
+
...propertyHeaders
|
|
3744
|
+
}
|
|
3745
|
+
});
|
|
3746
|
+
} else {
|
|
3747
|
+
const aguiAgent = graphqlContext._copilotkit.runtime.agents[agent.name];
|
|
3748
|
+
if (!aguiAgent) {
|
|
3749
|
+
throw new Error(`Agent: ${agent.name} could not be resolved`);
|
|
3750
|
+
}
|
|
3751
|
+
client = aguiAgent.client;
|
|
3752
|
+
}
|
|
3753
|
+
let state = {};
|
|
3754
|
+
try {
|
|
3755
|
+
state = (await client.threads.getState(threadId)).values;
|
|
3756
|
+
} catch (error) {
|
|
3757
|
+
}
|
|
3758
|
+
if (Object.keys(state).length === 0) {
|
|
3759
|
+
return {
|
|
3760
|
+
threadId: threadId || "",
|
|
3761
|
+
threadExists: false,
|
|
3762
|
+
state: JSON.stringify({}),
|
|
3763
|
+
messages: JSON.stringify([])
|
|
3764
|
+
};
|
|
3719
3765
|
} else {
|
|
3720
|
-
|
|
3766
|
+
const { messages, ...stateWithoutMessages } = state;
|
|
3767
|
+
const copilotkitMessages = langchainMessagesToCopilotKit(messages);
|
|
3768
|
+
return {
|
|
3769
|
+
threadId: threadId || "",
|
|
3770
|
+
threadExists: true,
|
|
3771
|
+
state: JSON.stringify(stateWithoutMessages),
|
|
3772
|
+
messages: JSON.stringify(copilotkitMessages)
|
|
3773
|
+
};
|
|
3721
3774
|
}
|
|
3775
|
+
throw new Error(`Agent: ${agent.name} could not be resolved`);
|
|
3722
3776
|
}
|
|
3723
3777
|
async processAgentRequest(request) {
|
|
3724
3778
|
var _a, _b, _c, _d, _e;
|
|
@@ -5350,9 +5404,9 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
5350
5404
|
__name(_ts_param2, "_ts_param");
|
|
5351
5405
|
var StateResolver = class {
|
|
5352
5406
|
async loadAgentState(ctx, data) {
|
|
5353
|
-
const agents = await ctx._copilotkit.runtime.
|
|
5354
|
-
const
|
|
5355
|
-
if (!
|
|
5407
|
+
const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
|
|
5408
|
+
const hasAgent = agents.some((agent) => agent.name === data.agentName);
|
|
5409
|
+
if (!hasAgent) {
|
|
5356
5410
|
throw new CopilotKitAgentDiscoveryError2({
|
|
5357
5411
|
agentName: data.agentName,
|
|
5358
5412
|
availableAgents: agents.map((a) => ({
|
|
@@ -5506,4 +5560,4 @@ export {
|
|
|
5506
5560
|
getCommonConfig,
|
|
5507
5561
|
copilotRuntimeNodeHttpEndpoint
|
|
5508
5562
|
};
|
|
5509
|
-
//# sourceMappingURL=chunk-
|
|
5563
|
+
//# sourceMappingURL=chunk-RCIYK6YJ.mjs.map
|