@copilotkit/runtime 1.5.18-next.1 → 1.5.18-next.2
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 +8 -0
- package/dist/{chunk-2NWLEHMA.mjs → chunk-6LFPAZDL.mjs} +70 -24
- package/dist/chunk-6LFPAZDL.mjs.map +1 -0
- package/dist/{chunk-CJZ7QUXU.mjs → chunk-BMKRXGMW.mjs} +2 -2
- package/dist/{chunk-OS4N57XE.mjs → chunk-BNJW4KHS.mjs} +2 -2
- package/dist/{chunk-326WWZNE.mjs → chunk-KZ3RUNSQ.mjs} +2 -2
- package/dist/index.js +89 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.js +89 -43
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.js +1 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- 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 +2 -2
- 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 +2 -2
- 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 +1 -1
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +33 -13
- package/src/lib/runtime/remote-action-constructors.ts +17 -2
- package/src/lib/runtime/remote-actions.ts +5 -1
- package/dist/chunk-2NWLEHMA.mjs.map +0 -1
- /package/dist/{chunk-CJZ7QUXU.mjs.map → chunk-BMKRXGMW.mjs.map} +0 -0
- /package/dist/{chunk-OS4N57XE.mjs.map → chunk-BNJW4KHS.mjs.map} +0 -0
- /package/dist/{chunk-326WWZNE.mjs.map → chunk-KZ3RUNSQ.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
config,
|
|
4
4
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
5
5
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KZ3RUNSQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
copilotRuntimeNestEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BMKRXGMW.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNodeExpressEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BNJW4KHS.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotRuntime,
|
|
15
15
|
addCustomHeaderPlugin,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
getCommonConfig,
|
|
22
22
|
langGraphPlatformEndpoint,
|
|
23
23
|
resolveEndpointType
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6LFPAZDL.mjs";
|
|
25
25
|
import {
|
|
26
26
|
AnthropicAdapter,
|
|
27
27
|
EmptyAdapter,
|
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.5.18-next.
|
|
47
|
+
version: "1.5.18-next.2",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -149,7 +149,7 @@ __export(lib_exports, {
|
|
|
149
149
|
module.exports = __toCommonJS(lib_exports);
|
|
150
150
|
|
|
151
151
|
// src/lib/runtime/copilot-runtime.ts
|
|
152
|
-
var
|
|
152
|
+
var import_shared14 = require("@copilotkit/shared");
|
|
153
153
|
|
|
154
154
|
// src/service-adapters/langchain/langserve.ts
|
|
155
155
|
var import_remote = require("langchain/runnables/remote");
|
|
@@ -1228,11 +1228,11 @@ var EmptyAdapter = class {
|
|
|
1228
1228
|
__name(EmptyAdapter, "EmptyAdapter");
|
|
1229
1229
|
|
|
1230
1230
|
// src/service-adapters/events.ts
|
|
1231
|
-
var
|
|
1231
|
+
var import_shared13 = require("@copilotkit/shared");
|
|
1232
1232
|
var import_rxjs2 = require("rxjs");
|
|
1233
1233
|
|
|
1234
1234
|
// src/lib/telemetry-client.ts
|
|
1235
|
-
var
|
|
1235
|
+
var import_shared12 = require("@copilotkit/shared");
|
|
1236
1236
|
|
|
1237
1237
|
// src/lib/runtime/remote-action-constructors.ts
|
|
1238
1238
|
var import_node_crypto2 = require("crypto");
|
|
@@ -2651,6 +2651,7 @@ __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
|
|
|
2651
2651
|
|
|
2652
2652
|
// src/lib/runtime/remote-action-constructors.ts
|
|
2653
2653
|
var import_shared9 = require("@copilotkit/shared");
|
|
2654
|
+
var import_shared10 = require("@copilotkit/shared");
|
|
2654
2655
|
function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
2655
2656
|
const agents = endpoint.agents.map((agent) => ({
|
|
2656
2657
|
name: agent.name,
|
|
@@ -2751,7 +2752,16 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2751
2752
|
status: response.status,
|
|
2752
2753
|
body: await response.text()
|
|
2753
2754
|
}, "Failed to execute remote action");
|
|
2754
|
-
|
|
2755
|
+
if (response.status === 404) {
|
|
2756
|
+
throw new import_shared10.CopilotKitApiDiscoveryError({
|
|
2757
|
+
url: fetchUrl
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
throw new import_shared10.ResolvedCopilotKitError({
|
|
2761
|
+
status: response.status,
|
|
2762
|
+
url: fetchUrl,
|
|
2763
|
+
isRemoteEndpoint: true
|
|
2764
|
+
});
|
|
2755
2765
|
}
|
|
2756
2766
|
const requestResult = await response.json();
|
|
2757
2767
|
const result = requestResult["result"];
|
|
@@ -2824,7 +2834,16 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2824
2834
|
status: response.status,
|
|
2825
2835
|
body: await response.text()
|
|
2826
2836
|
}, "Failed to execute remote agent");
|
|
2827
|
-
|
|
2837
|
+
if (response.status === 404) {
|
|
2838
|
+
throw new import_shared10.CopilotKitApiDiscoveryError({
|
|
2839
|
+
url: fetchUrl
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
throw new import_shared10.ResolvedCopilotKitError({
|
|
2843
|
+
status: response.status,
|
|
2844
|
+
url: fetchUrl,
|
|
2845
|
+
isRemoteEndpoint: true
|
|
2846
|
+
});
|
|
2828
2847
|
}
|
|
2829
2848
|
const eventSource = new RemoteLangGraphEventSource();
|
|
2830
2849
|
streamResponse(response.body, eventSource.eventStream$);
|
|
@@ -2907,7 +2926,7 @@ function createHeaders(onBeforeRequest, graphqlContext) {
|
|
|
2907
2926
|
__name(createHeaders, "createHeaders");
|
|
2908
2927
|
|
|
2909
2928
|
// src/lib/runtime/remote-actions.ts
|
|
2910
|
-
var
|
|
2929
|
+
var import_shared11 = require("@copilotkit/shared");
|
|
2911
2930
|
var EndpointType;
|
|
2912
2931
|
(function(EndpointType2) {
|
|
2913
2932
|
EndpointType2["CopilotKit"] = "copilotKit";
|
|
@@ -2941,8 +2960,9 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
2941
2960
|
status: response.status,
|
|
2942
2961
|
body: await response.text()
|
|
2943
2962
|
}, "Failed to fetch actions from url");
|
|
2944
|
-
throw new
|
|
2963
|
+
throw new import_shared11.ResolvedCopilotKitError({
|
|
2945
2964
|
status: response.status,
|
|
2965
|
+
url: fetchUrl,
|
|
2946
2966
|
isRemoteEndpoint: true
|
|
2947
2967
|
});
|
|
2948
2968
|
}
|
|
@@ -2952,10 +2972,10 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
2952
2972
|
}, "Fetched actions from url");
|
|
2953
2973
|
return json;
|
|
2954
2974
|
} catch (error) {
|
|
2955
|
-
if (error instanceof
|
|
2975
|
+
if (error instanceof import_shared11.CopilotKitError) {
|
|
2956
2976
|
throw error;
|
|
2957
2977
|
}
|
|
2958
|
-
throw new
|
|
2978
|
+
throw new import_shared11.CopilotKitLowLevelError({
|
|
2959
2979
|
error,
|
|
2960
2980
|
url: fetchUrl
|
|
2961
2981
|
});
|
|
@@ -3018,7 +3038,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
3018
3038
|
// src/lib/telemetry-client.ts
|
|
3019
3039
|
var import_node_crypto3 = require("crypto");
|
|
3020
3040
|
var packageJson = require_package();
|
|
3021
|
-
var telemetryClient = new
|
|
3041
|
+
var telemetryClient = new import_shared12.TelemetryClient({
|
|
3022
3042
|
packageName: packageJson.name,
|
|
3023
3043
|
packageVersion: packageJson.version
|
|
3024
3044
|
});
|
|
@@ -3335,10 +3355,10 @@ var RuntimeEventSource = class {
|
|
|
3335
3355
|
const errorMessage = `\u274C ${message}`;
|
|
3336
3356
|
if (!this.callback) {
|
|
3337
3357
|
this.stream(async (eventStream$) => {
|
|
3338
|
-
eventStream$.sendTextMessage((0,
|
|
3358
|
+
eventStream$.sendTextMessage((0, import_shared13.randomId)(), errorMessage);
|
|
3339
3359
|
});
|
|
3340
3360
|
} else {
|
|
3341
|
-
this.eventStream$.sendTextMessage((0,
|
|
3361
|
+
this.eventStream$.sendTextMessage((0, import_shared13.randomId)(), errorMessage);
|
|
3342
3362
|
}
|
|
3343
3363
|
}
|
|
3344
3364
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
@@ -3574,7 +3594,7 @@ var CopilotRuntime = class {
|
|
|
3574
3594
|
return await this.processAgentRequest(request);
|
|
3575
3595
|
}
|
|
3576
3596
|
if (serviceAdapter instanceof EmptyAdapter) {
|
|
3577
|
-
throw new
|
|
3597
|
+
throw new import_shared14.CopilotKitMisuseError({
|
|
3578
3598
|
message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
|
|
3579
3599
|
For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
|
|
3580
3600
|
please use an LLM adapter instead.`
|
|
@@ -3586,7 +3606,7 @@ please use an LLM adapter instead.`
|
|
|
3586
3606
|
const serverSideActionsInput = serverSideActions.map((action) => ({
|
|
3587
3607
|
name: action.name,
|
|
3588
3608
|
description: action.description,
|
|
3589
|
-
jsonSchema: JSON.stringify((0,
|
|
3609
|
+
jsonSchema: JSON.stringify((0, import_shared14.actionParametersToJsonSchema)(action.parameters))
|
|
3590
3610
|
}));
|
|
3591
3611
|
const actionInputs = flattenToolCallsNoDuplicates([
|
|
3592
3612
|
...serverSideActionsInput,
|
|
@@ -3638,7 +3658,7 @@ please use an LLM adapter instead.`
|
|
|
3638
3658
|
extensions: result.extensions
|
|
3639
3659
|
};
|
|
3640
3660
|
} catch (error) {
|
|
3641
|
-
if (error instanceof
|
|
3661
|
+
if (error instanceof import_shared14.CopilotKitError) {
|
|
3642
3662
|
throw error;
|
|
3643
3663
|
}
|
|
3644
3664
|
console.error("Error getting response:", error);
|
|
@@ -3684,10 +3704,13 @@ please use an LLM adapter instead.`
|
|
|
3684
3704
|
});
|
|
3685
3705
|
if (!response.ok) {
|
|
3686
3706
|
if (response.status === 404) {
|
|
3687
|
-
throw new
|
|
3707
|
+
throw new import_shared14.CopilotKitApiDiscoveryError({
|
|
3708
|
+
url: fetchUrl
|
|
3709
|
+
});
|
|
3688
3710
|
}
|
|
3689
|
-
throw new
|
|
3711
|
+
throw new import_shared14.ResolvedCopilotKitError({
|
|
3690
3712
|
status: response.status,
|
|
3713
|
+
url: fetchUrl,
|
|
3691
3714
|
isRemoteEndpoint: true
|
|
3692
3715
|
});
|
|
3693
3716
|
}
|
|
@@ -3695,7 +3718,7 @@ please use an LLM adapter instead.`
|
|
|
3695
3718
|
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
3696
3719
|
name: agent.name,
|
|
3697
3720
|
description: agent.description ?? "" ?? "",
|
|
3698
|
-
id: (0,
|
|
3721
|
+
id: (0, import_shared14.randomId)(),
|
|
3699
3722
|
endpoint
|
|
3700
3723
|
}));
|
|
3701
3724
|
return [
|
|
@@ -3703,10 +3726,10 @@ please use an LLM adapter instead.`
|
|
|
3703
3726
|
...endpointAgents
|
|
3704
3727
|
];
|
|
3705
3728
|
} catch (error) {
|
|
3706
|
-
if (error instanceof
|
|
3729
|
+
if (error instanceof import_shared14.CopilotKitError) {
|
|
3707
3730
|
throw error;
|
|
3708
3731
|
}
|
|
3709
|
-
throw new
|
|
3732
|
+
throw new import_shared14.CopilotKitLowLevelError({
|
|
3710
3733
|
error,
|
|
3711
3734
|
url: fetchUrl
|
|
3712
3735
|
});
|
|
@@ -3755,21 +3778,44 @@ please use an LLM adapter instead.`
|
|
|
3755
3778
|
};
|
|
3756
3779
|
}
|
|
3757
3780
|
} else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
|
|
3758
|
-
const
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3781
|
+
const fetchUrl = `${agentWithEndpoint.endpoint.url}/agents/state`;
|
|
3782
|
+
try {
|
|
3783
|
+
const response = await fetch(fetchUrl, {
|
|
3784
|
+
method: "POST",
|
|
3785
|
+
headers,
|
|
3786
|
+
body: JSON.stringify({
|
|
3787
|
+
properties: graphqlContext.properties,
|
|
3788
|
+
threadId,
|
|
3789
|
+
name: agentName
|
|
3790
|
+
})
|
|
3791
|
+
});
|
|
3792
|
+
if (!response.ok) {
|
|
3793
|
+
if (response.status === 404) {
|
|
3794
|
+
throw new import_shared14.CopilotKitApiDiscoveryError({
|
|
3795
|
+
url: fetchUrl
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
throw new import_shared14.ResolvedCopilotKitError({
|
|
3799
|
+
status: response.status,
|
|
3800
|
+
url: fetchUrl,
|
|
3801
|
+
isRemoteEndpoint: true
|
|
3802
|
+
});
|
|
3803
|
+
}
|
|
3804
|
+
const data = await response.json();
|
|
3805
|
+
return {
|
|
3806
|
+
...data,
|
|
3807
|
+
state: JSON.stringify(data.state),
|
|
3808
|
+
messages: JSON.stringify(data.messages)
|
|
3809
|
+
};
|
|
3810
|
+
} catch (error) {
|
|
3811
|
+
if (error instanceof import_shared14.CopilotKitError) {
|
|
3812
|
+
throw error;
|
|
3813
|
+
}
|
|
3814
|
+
throw new import_shared14.CopilotKitLowLevelError({
|
|
3815
|
+
error,
|
|
3816
|
+
url: fetchUrl
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3773
3819
|
} else {
|
|
3774
3820
|
throw new Error(`Unknown endpoint type: ${agentWithEndpoint.endpoint.type}`);
|
|
3775
3821
|
}
|
|
@@ -3783,7 +3829,7 @@ please use an LLM adapter instead.`
|
|
|
3783
3829
|
const messages = convertGqlInputToMessages(rawMessages);
|
|
3784
3830
|
const currentAgent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
|
|
3785
3831
|
if (!currentAgent) {
|
|
3786
|
-
throw new
|
|
3832
|
+
throw new import_shared14.CopilotKitAgentDiscoveryError({
|
|
3787
3833
|
agentName
|
|
3788
3834
|
});
|
|
3789
3835
|
}
|
|
@@ -3794,7 +3840,7 @@ please use an LLM adapter instead.`
|
|
|
3794
3840
|
)).map((action) => ({
|
|
3795
3841
|
name: action.name,
|
|
3796
3842
|
description: action.description,
|
|
3797
|
-
jsonSchema: JSON.stringify((0,
|
|
3843
|
+
jsonSchema: JSON.stringify((0, import_shared14.actionParametersToJsonSchema)(action.parameters))
|
|
3798
3844
|
}));
|
|
3799
3845
|
const allAvailableActions = flattenToolCallsNoDuplicates([
|
|
3800
3846
|
...availableActionsForCurrentAgent,
|
|
@@ -4712,7 +4758,7 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
4712
4758
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
4713
4759
|
|
|
4714
4760
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
4715
|
-
var
|
|
4761
|
+
var import_shared15 = require("@copilotkit/shared");
|
|
4716
4762
|
|
|
4717
4763
|
// src/graphql/types/agents-response.type.ts
|
|
4718
4764
|
var import_type_graphql19 = require("type-graphql");
|
|
@@ -4895,7 +4941,7 @@ var CopilotResolver = class {
|
|
|
4895
4941
|
rejectOutputMessagesPromise = reject;
|
|
4896
4942
|
});
|
|
4897
4943
|
logger2.debug("Processing");
|
|
4898
|
-
const { eventSource, threadId = (0,
|
|
4944
|
+
const { eventSource, threadId = (0, import_shared15.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
|
|
4899
4945
|
serviceAdapter,
|
|
4900
4946
|
messages: data.messages,
|
|
4901
4947
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -5028,7 +5074,7 @@ var CopilotResolver = class {
|
|
|
5028
5074
|
});
|
|
5029
5075
|
outputMessages = [
|
|
5030
5076
|
(0, import_class_transformer3.plainToInstance)(TextMessage, {
|
|
5031
|
-
id: (0,
|
|
5077
|
+
id: (0, import_shared15.randomId)(),
|
|
5032
5078
|
createdAt: /* @__PURE__ */ new Date(),
|
|
5033
5079
|
content: result.reason,
|
|
5034
5080
|
role: MessageRole.assistant
|
|
@@ -5206,7 +5252,7 @@ var CopilotResolver = class {
|
|
|
5206
5252
|
event
|
|
5207
5253
|
}, "Agent message event received");
|
|
5208
5254
|
pushMessage({
|
|
5209
|
-
id: (0,
|
|
5255
|
+
id: (0, import_shared15.randomId)(),
|
|
5210
5256
|
status: new SuccessMessageStatus(),
|
|
5211
5257
|
threadId: event.threadId,
|
|
5212
5258
|
agentName: event.agentName,
|
|
@@ -5219,7 +5265,7 @@ var CopilotResolver = class {
|
|
|
5219
5265
|
createdAt: /* @__PURE__ */ new Date()
|
|
5220
5266
|
});
|
|
5221
5267
|
outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
|
|
5222
|
-
id: (0,
|
|
5268
|
+
id: (0, import_shared15.randomId)(),
|
|
5223
5269
|
threadId: event.threadId,
|
|
5224
5270
|
agentName: event.agentName,
|
|
5225
5271
|
nodeName: event.nodeName,
|