@copilotkit/runtime 1.8.5-next.4 → 1.8.5
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 +86 -0
- package/dist/{chunk-574FKWP5.mjs → chunk-AYW55OHA.mjs} +2 -2
- package/dist/{chunk-PKO7BUPS.mjs → chunk-CTOM2OZ3.mjs} +124 -4
- package/dist/chunk-CTOM2OZ3.mjs.map +1 -0
- package/dist/{chunk-WQZQTGHT.mjs → chunk-IUD7KKAU.mjs} +2 -2
- package/dist/{chunk-GGXHVDCG.mjs → chunk-NPWAEKGB.mjs} +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +166 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +159 -39
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.d.ts +3 -2
- package/dist/lib/integrations/index.js +15 -10
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.d.ts +2 -1
- package/dist/lib/integrations/nest/index.js +15 -10
- 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.d.ts +2 -1
- package/dist/lib/integrations/node-express/index.js +15 -10
- 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.d.ts +2 -1
- package/dist/lib/integrations/node-http/index.js +15 -10
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/{shared-86ec42e7.d.ts → shared-93687488.d.ts} +3 -0
- package/package.json +6 -2
- package/src/lib/runtime/agentwire-action.ts +123 -0
- package/src/lib/runtime/copilot-runtime.ts +9 -1
- package/src/lib/runtime/remote-action-constructors.ts +2 -7
- package/src/lib/runtime/remote-actions.ts +25 -1
- package/dist/chunk-PKO7BUPS.mjs.map +0 -1
- /package/dist/{chunk-574FKWP5.mjs.map → chunk-AYW55OHA.mjs.map} +0 -0
- /package/dist/{chunk-WQZQTGHT.mjs.map → chunk-IUD7KKAU.mjs.map} +0 -0
- /package/dist/{chunk-GGXHVDCG.mjs.map → chunk-NPWAEKGB.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-NPWAEKGB.mjs";
|
|
7
7
|
import {
|
|
8
8
|
copilotRuntimeNestEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IUD7KKAU.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNodeExpressEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-AYW55OHA.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotRuntime,
|
|
15
15
|
addCustomHeaderPlugin,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getCommonConfig,
|
|
25
25
|
langGraphPlatformEndpoint,
|
|
26
26
|
resolveEndpointType
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-CTOM2OZ3.mjs";
|
|
28
28
|
import {
|
|
29
29
|
AnthropicAdapter,
|
|
30
30
|
EmptyAdapter,
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-fb9aa3ab.js';
|
|
2
|
-
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-
|
|
2
|
+
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-93687488.js';
|
|
3
3
|
export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
|
|
@@ -18,3 +18,4 @@ import 'graphql';
|
|
|
18
18
|
import 'pino';
|
|
19
19
|
import 'graphql-yoga';
|
|
20
20
|
import './cloud/index.js';
|
|
21
|
+
import '@agentwire/client';
|
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.8.5
|
|
47
|
+
version: "1.8.5",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -81,6 +81,10 @@ var require_package = __commonJS({
|
|
|
81
81
|
"zod-to-json-schema": "^3.23.5"
|
|
82
82
|
},
|
|
83
83
|
dependencies: {
|
|
84
|
+
"@agentwire/client": "0.0.26",
|
|
85
|
+
"@agentwire/proto": "0.0.26",
|
|
86
|
+
"@agentwire/core": "0.0.26",
|
|
87
|
+
"@agentwire/encoder": "0.0.26",
|
|
84
88
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
85
89
|
"@copilotkit/shared": "workspace:*",
|
|
86
90
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
@@ -2598,11 +2602,14 @@ GenerateCopilotResponseInput = _ts_decorate17([
|
|
|
2598
2602
|
var import_graphql_yoga = require("graphql-yoga");
|
|
2599
2603
|
|
|
2600
2604
|
// src/service-adapters/events.ts
|
|
2601
|
-
var
|
|
2605
|
+
var import_shared20 = require("@copilotkit/shared");
|
|
2602
2606
|
var import_rxjs3 = require("rxjs");
|
|
2603
2607
|
|
|
2604
2608
|
// src/lib/telemetry-client.ts
|
|
2605
|
-
var
|
|
2609
|
+
var import_shared19 = require("@copilotkit/shared");
|
|
2610
|
+
|
|
2611
|
+
// src/lib/runtime/remote-actions.ts
|
|
2612
|
+
var import_shared14 = require("@copilotkit/shared");
|
|
2606
2613
|
|
|
2607
2614
|
// src/lib/runtime/remote-action-constructors.ts
|
|
2608
2615
|
var import_node_crypto2 = require("crypto");
|
|
@@ -3772,7 +3779,101 @@ function createHeaders(onBeforeRequest, graphqlContext) {
|
|
|
3772
3779
|
__name(createHeaders, "createHeaders");
|
|
3773
3780
|
|
|
3774
3781
|
// src/lib/runtime/remote-actions.ts
|
|
3782
|
+
var import_shared15 = require("@copilotkit/shared");
|
|
3783
|
+
|
|
3784
|
+
// src/lib/runtime/agentwire-action.ts
|
|
3775
3785
|
var import_shared13 = require("@copilotkit/shared");
|
|
3786
|
+
function constructAgentWireRemoteAction({ logger: logger2, messages, agentStates, agent }) {
|
|
3787
|
+
const action = {
|
|
3788
|
+
name: agent.agentId,
|
|
3789
|
+
description: agent.description,
|
|
3790
|
+
parameters: [],
|
|
3791
|
+
handler: async (_args) => {
|
|
3792
|
+
},
|
|
3793
|
+
remoteAgentHandler: async ({ actionInputsWithoutAgents, threadId }) => {
|
|
3794
|
+
logger2.debug({
|
|
3795
|
+
actionName: agent.agentId
|
|
3796
|
+
}, "Executing remote agent");
|
|
3797
|
+
const agentWireMessages = convertMessagesToAgentWire(messages);
|
|
3798
|
+
agent.messages = agentWireMessages;
|
|
3799
|
+
agent.threadId = threadId;
|
|
3800
|
+
telemetry_client_default.capture("oss.runtime.remote_action_executed", {
|
|
3801
|
+
agentExecution: true,
|
|
3802
|
+
type: "self-hosted",
|
|
3803
|
+
agentsAmount: 1
|
|
3804
|
+
});
|
|
3805
|
+
let state = {};
|
|
3806
|
+
if (agentStates) {
|
|
3807
|
+
const jsonState = agentStates.find((state2) => state2.agentName === agent.agentId);
|
|
3808
|
+
if (jsonState) {
|
|
3809
|
+
state = (0, import_shared13.parseJson)(jsonState.state, {});
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
agent.state = state;
|
|
3813
|
+
const tools = actionInputsWithoutAgents.map((input) => {
|
|
3814
|
+
return {
|
|
3815
|
+
name: input.name,
|
|
3816
|
+
description: input.description,
|
|
3817
|
+
parameters: JSON.parse(input.jsonSchema)
|
|
3818
|
+
};
|
|
3819
|
+
});
|
|
3820
|
+
return agent.legacy_to_be_removed_runAgentBridged({
|
|
3821
|
+
tools
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
};
|
|
3825
|
+
return [
|
|
3826
|
+
action
|
|
3827
|
+
];
|
|
3828
|
+
}
|
|
3829
|
+
__name(constructAgentWireRemoteAction, "constructAgentWireRemoteAction");
|
|
3830
|
+
function convertMessagesToAgentWire(messages) {
|
|
3831
|
+
const result = [];
|
|
3832
|
+
for (const message of messages) {
|
|
3833
|
+
if (message.isTextMessage()) {
|
|
3834
|
+
result.push({
|
|
3835
|
+
id: message.id,
|
|
3836
|
+
role: message.role,
|
|
3837
|
+
content: message.content
|
|
3838
|
+
});
|
|
3839
|
+
} else if (message.isActionExecutionMessage()) {
|
|
3840
|
+
const toolCall = {
|
|
3841
|
+
id: message.id,
|
|
3842
|
+
type: "function",
|
|
3843
|
+
function: {
|
|
3844
|
+
name: message.name,
|
|
3845
|
+
arguments: JSON.stringify(message.arguments)
|
|
3846
|
+
}
|
|
3847
|
+
};
|
|
3848
|
+
if (message.parentMessageId && result.some((m) => m.id === message.parentMessageId)) {
|
|
3849
|
+
const parentMessage = result.find((m) => m.id === message.parentMessageId);
|
|
3850
|
+
if (parentMessage.toolCalls === void 0) {
|
|
3851
|
+
parentMessage.toolCalls = [];
|
|
3852
|
+
}
|
|
3853
|
+
parentMessage.toolCalls.push(toolCall);
|
|
3854
|
+
} else {
|
|
3855
|
+
result.push({
|
|
3856
|
+
id: message.parentMessageId ?? message.id,
|
|
3857
|
+
role: "assistant",
|
|
3858
|
+
toolCalls: [
|
|
3859
|
+
toolCall
|
|
3860
|
+
]
|
|
3861
|
+
});
|
|
3862
|
+
}
|
|
3863
|
+
} else if (message.isResultMessage()) {
|
|
3864
|
+
result.push({
|
|
3865
|
+
id: message.id,
|
|
3866
|
+
role: "tool",
|
|
3867
|
+
content: message.result,
|
|
3868
|
+
toolCallId: message.actionExecutionId
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
return result;
|
|
3873
|
+
}
|
|
3874
|
+
__name(convertMessagesToAgentWire, "convertMessagesToAgentWire");
|
|
3875
|
+
|
|
3876
|
+
// src/lib/runtime/remote-actions.ts
|
|
3776
3877
|
var EndpointType;
|
|
3777
3878
|
(function(EndpointType2) {
|
|
3778
3879
|
EndpointType2["CopilotKit"] = "copilotKit";
|
|
@@ -3806,7 +3907,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
3806
3907
|
status: response.status,
|
|
3807
3908
|
body: await response.text()
|
|
3808
3909
|
}, "Failed to fetch actions from url");
|
|
3809
|
-
throw new
|
|
3910
|
+
throw new import_shared15.ResolvedCopilotKitError({
|
|
3810
3911
|
status: response.status,
|
|
3811
3912
|
url: fetchUrl,
|
|
3812
3913
|
isRemoteEndpoint: true
|
|
@@ -3818,17 +3919,17 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
3818
3919
|
}, "Fetched actions from url");
|
|
3819
3920
|
return json;
|
|
3820
3921
|
} catch (error) {
|
|
3821
|
-
if (error instanceof
|
|
3922
|
+
if (error instanceof import_shared15.CopilotKitError) {
|
|
3822
3923
|
throw error;
|
|
3823
3924
|
}
|
|
3824
|
-
throw new
|
|
3925
|
+
throw new import_shared15.CopilotKitLowLevelError({
|
|
3825
3926
|
error,
|
|
3826
3927
|
url: fetchUrl
|
|
3827
3928
|
});
|
|
3828
3929
|
}
|
|
3829
3930
|
}
|
|
3830
3931
|
__name(fetchRemoteInfo, "fetchRemoteInfo");
|
|
3831
|
-
async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
|
|
3932
|
+
async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents }) {
|
|
3832
3933
|
const logger2 = graphqlContext.logger.child({
|
|
3833
3934
|
component: "remote-actions.fetchRemoteActions"
|
|
3834
3935
|
});
|
|
@@ -3877,6 +3978,22 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
|
|
|
3877
3978
|
agentStates
|
|
3878
3979
|
});
|
|
3879
3980
|
}));
|
|
3981
|
+
for (const [key, agent] of Object.entries(agents)) {
|
|
3982
|
+
if (agent.agentId !== void 0 && agent.agentId !== key) {
|
|
3983
|
+
throw new import_shared15.CopilotKitError({
|
|
3984
|
+
message: `Agent ${key} has agentId ${agent.agentId} which does not match the key ${key}`,
|
|
3985
|
+
code: import_shared14.CopilotKitErrorCode.UNKNOWN
|
|
3986
|
+
});
|
|
3987
|
+
} else if (agent.agentId === void 0) {
|
|
3988
|
+
agent.agentId = key;
|
|
3989
|
+
}
|
|
3990
|
+
result.push(constructAgentWireRemoteAction({
|
|
3991
|
+
logger: logger2,
|
|
3992
|
+
messages,
|
|
3993
|
+
agentStates,
|
|
3994
|
+
agent
|
|
3995
|
+
}));
|
|
3996
|
+
}
|
|
3880
3997
|
return result.flat();
|
|
3881
3998
|
}
|
|
3882
3999
|
__name(setupRemoteActions, "setupRemoteActions");
|
|
@@ -3885,7 +4002,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
3885
4002
|
var import_node_crypto3 = require("crypto");
|
|
3886
4003
|
|
|
3887
4004
|
// src/lib/runtime/copilot-runtime.ts
|
|
3888
|
-
var
|
|
4005
|
+
var import_shared18 = require("@copilotkit/shared");
|
|
3889
4006
|
|
|
3890
4007
|
// src/service-adapters/langchain/langserve.ts
|
|
3891
4008
|
var import_remote = require("langchain/runnables/remote");
|
|
@@ -3966,11 +4083,11 @@ var RemoteChain = class {
|
|
|
3966
4083
|
__name(RemoteChain, "RemoteChain");
|
|
3967
4084
|
|
|
3968
4085
|
// src/service-adapters/empty/empty-adapter.ts
|
|
3969
|
-
var
|
|
4086
|
+
var import_shared16 = require("@copilotkit/shared");
|
|
3970
4087
|
var EmptyAdapter = class {
|
|
3971
4088
|
async process(request) {
|
|
3972
4089
|
return {
|
|
3973
|
-
threadId: request.threadId || (0,
|
|
4090
|
+
threadId: request.threadId || (0, import_shared16.randomUUID)()
|
|
3974
4091
|
};
|
|
3975
4092
|
}
|
|
3976
4093
|
};
|
|
@@ -4092,9 +4209,9 @@ __name(AgentStateMessage, "AgentStateMessage");
|
|
|
4092
4209
|
|
|
4093
4210
|
// src/service-adapters/conversion.ts
|
|
4094
4211
|
var import_class_transformer = require("class-transformer");
|
|
4095
|
-
var
|
|
4212
|
+
var import_shared17 = require("@copilotkit/shared");
|
|
4096
4213
|
function convertGqlInputToMessages(inputMessages) {
|
|
4097
|
-
const messages = (0,
|
|
4214
|
+
const messages = (0, import_shared17.tryMap)(inputMessages, (message) => {
|
|
4098
4215
|
if (message.textMessage) {
|
|
4099
4216
|
return (0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
4100
4217
|
id: message.id,
|
|
@@ -4201,6 +4318,7 @@ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
|
|
|
4201
4318
|
// src/lib/runtime/copilot-runtime.ts
|
|
4202
4319
|
var CopilotRuntime = class {
|
|
4203
4320
|
actions;
|
|
4321
|
+
agents;
|
|
4204
4322
|
remoteEndpointDefinitions;
|
|
4205
4323
|
langserve = [];
|
|
4206
4324
|
onBeforeRequest;
|
|
@@ -4231,10 +4349,11 @@ var CopilotRuntime = class {
|
|
|
4231
4349
|
this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
|
|
4232
4350
|
this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
|
|
4233
4351
|
this.observability = params == null ? void 0 : params.observability_c;
|
|
4352
|
+
this.agents = (params == null ? void 0 : params.agents) ?? {};
|
|
4234
4353
|
this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
|
|
4235
4354
|
this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
|
|
4236
4355
|
if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
|
|
4237
|
-
throw new
|
|
4356
|
+
throw new import_shared18.CopilotKitMisuseError({
|
|
4238
4357
|
message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
|
|
4239
4358
|
});
|
|
4240
4359
|
}
|
|
@@ -4270,7 +4389,7 @@ var CopilotRuntime = class {
|
|
|
4270
4389
|
}
|
|
4271
4390
|
} else {
|
|
4272
4391
|
newMessages.unshift({
|
|
4273
|
-
id: (0,
|
|
4392
|
+
id: (0, import_shared18.randomId)(),
|
|
4274
4393
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4275
4394
|
textMessage: {
|
|
4276
4395
|
role: MessageRole.system,
|
|
@@ -4295,7 +4414,7 @@ var CopilotRuntime = class {
|
|
|
4295
4414
|
return await this.processAgentRequest(request);
|
|
4296
4415
|
}
|
|
4297
4416
|
if (serviceAdapter instanceof EmptyAdapter) {
|
|
4298
|
-
throw new
|
|
4417
|
+
throw new import_shared18.CopilotKitMisuseError({
|
|
4299
4418
|
message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
|
|
4300
4419
|
For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
|
|
4301
4420
|
please use an LLM adapter instead.`
|
|
@@ -4325,7 +4444,7 @@ please use an LLM adapter instead.`
|
|
|
4325
4444
|
const serverSideActionsInput = serverSideActions.map((action) => ({
|
|
4326
4445
|
name: action.name,
|
|
4327
4446
|
description: action.description,
|
|
4328
|
-
jsonSchema: JSON.stringify((0,
|
|
4447
|
+
jsonSchema: JSON.stringify((0, import_shared18.actionParametersToJsonSchema)(action.parameters))
|
|
4329
4448
|
}));
|
|
4330
4449
|
const actionInputs = flattenToolCallsNoDuplicates([
|
|
4331
4450
|
...serverSideActionsInput,
|
|
@@ -4454,7 +4573,7 @@ please use an LLM adapter instead.`
|
|
|
4454
4573
|
console.error("Error logging LLM error:", logError);
|
|
4455
4574
|
}
|
|
4456
4575
|
}
|
|
4457
|
-
if (error instanceof
|
|
4576
|
+
if (error instanceof import_shared18.CopilotKitError) {
|
|
4458
4577
|
throw error;
|
|
4459
4578
|
}
|
|
4460
4579
|
console.error("Error getting response:", error);
|
|
@@ -4480,12 +4599,12 @@ please use an LLM adapter instead.`
|
|
|
4480
4599
|
try {
|
|
4481
4600
|
data = await client.assistants.search();
|
|
4482
4601
|
if (data && "detail" in data && data.detail.toLowerCase() === "not found") {
|
|
4483
|
-
throw new
|
|
4602
|
+
throw new import_shared18.CopilotKitAgentDiscoveryError({
|
|
4484
4603
|
availableAgents: this.availableAgents
|
|
4485
4604
|
});
|
|
4486
4605
|
}
|
|
4487
4606
|
} catch (e) {
|
|
4488
|
-
throw new
|
|
4607
|
+
throw new import_shared18.CopilotKitMisuseError({
|
|
4489
4608
|
message: `
|
|
4490
4609
|
Failed to find or contact remote endpoint at url ${endpoint.deploymentUrl}.
|
|
4491
4610
|
Make sure the API is running and that it's indeed a LangGraph platform url.
|
|
@@ -4516,11 +4635,11 @@ please use an LLM adapter instead.`
|
|
|
4516
4635
|
});
|
|
4517
4636
|
if (!response.ok) {
|
|
4518
4637
|
if (response.status === 404) {
|
|
4519
|
-
throw new
|
|
4638
|
+
throw new import_shared18.CopilotKitApiDiscoveryError({
|
|
4520
4639
|
url: fetchUrl
|
|
4521
4640
|
});
|
|
4522
4641
|
}
|
|
4523
|
-
throw new
|
|
4642
|
+
throw new import_shared18.ResolvedCopilotKitError({
|
|
4524
4643
|
status: response.status,
|
|
4525
4644
|
url: fetchUrl,
|
|
4526
4645
|
isRemoteEndpoint: true
|
|
@@ -4530,7 +4649,7 @@ please use an LLM adapter instead.`
|
|
|
4530
4649
|
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
4531
4650
|
name: agent.name,
|
|
4532
4651
|
description: agent.description ?? "" ?? "",
|
|
4533
|
-
id: (0,
|
|
4652
|
+
id: (0, import_shared18.randomId)(),
|
|
4534
4653
|
endpoint
|
|
4535
4654
|
}));
|
|
4536
4655
|
return [
|
|
@@ -4538,10 +4657,10 @@ please use an LLM adapter instead.`
|
|
|
4538
4657
|
...endpointAgents
|
|
4539
4658
|
];
|
|
4540
4659
|
} catch (error) {
|
|
4541
|
-
if (error instanceof
|
|
4660
|
+
if (error instanceof import_shared18.CopilotKitError) {
|
|
4542
4661
|
throw error;
|
|
4543
4662
|
}
|
|
4544
|
-
throw new
|
|
4663
|
+
throw new import_shared18.CopilotKitLowLevelError({
|
|
4545
4664
|
error,
|
|
4546
4665
|
url: fetchUrl
|
|
4547
4666
|
});
|
|
@@ -4607,11 +4726,11 @@ please use an LLM adapter instead.`
|
|
|
4607
4726
|
});
|
|
4608
4727
|
if (!response.ok) {
|
|
4609
4728
|
if (response.status === 404) {
|
|
4610
|
-
throw new
|
|
4729
|
+
throw new import_shared18.CopilotKitApiDiscoveryError({
|
|
4611
4730
|
url: fetchUrl
|
|
4612
4731
|
});
|
|
4613
4732
|
}
|
|
4614
|
-
throw new
|
|
4733
|
+
throw new import_shared18.ResolvedCopilotKitError({
|
|
4615
4734
|
status: response.status,
|
|
4616
4735
|
url: fetchUrl,
|
|
4617
4736
|
isRemoteEndpoint: true
|
|
@@ -4624,10 +4743,10 @@ please use an LLM adapter instead.`
|
|
|
4624
4743
|
messages: JSON.stringify(data.messages)
|
|
4625
4744
|
};
|
|
4626
4745
|
} catch (error) {
|
|
4627
|
-
if (error instanceof
|
|
4746
|
+
if (error instanceof import_shared18.CopilotKitError) {
|
|
4628
4747
|
throw error;
|
|
4629
4748
|
}
|
|
4630
|
-
throw new
|
|
4749
|
+
throw new import_shared18.CopilotKitLowLevelError({
|
|
4631
4750
|
error,
|
|
4632
4751
|
url: fetchUrl
|
|
4633
4752
|
});
|
|
@@ -4647,7 +4766,7 @@ please use an LLM adapter instead.`
|
|
|
4647
4766
|
const messages = convertGqlInputToMessages(rawMessages);
|
|
4648
4767
|
const currentAgent = serverSideActions.find((action) => action.name === agentName && isRemoteAgentAction(action));
|
|
4649
4768
|
if (!currentAgent) {
|
|
4650
|
-
throw new
|
|
4769
|
+
throw new import_shared18.CopilotKitAgentDiscoveryError({
|
|
4651
4770
|
agentName,
|
|
4652
4771
|
availableAgents: this.availableAgents
|
|
4653
4772
|
});
|
|
@@ -4659,7 +4778,7 @@ please use an LLM adapter instead.`
|
|
|
4659
4778
|
)).map((action) => ({
|
|
4660
4779
|
name: action.name,
|
|
4661
4780
|
description: action.description,
|
|
4662
|
-
jsonSchema: JSON.stringify((0,
|
|
4781
|
+
jsonSchema: JSON.stringify((0, import_shared18.actionParametersToJsonSchema)(action.parameters))
|
|
4663
4782
|
}));
|
|
4664
4783
|
const allAvailableActions = flattenToolCallsNoDuplicates([
|
|
4665
4784
|
...availableActionsForCurrentAgent,
|
|
@@ -4852,7 +4971,8 @@ please use an LLM adapter instead.`
|
|
|
4852
4971
|
graphqlContext,
|
|
4853
4972
|
messages: inputMessages,
|
|
4854
4973
|
agentStates,
|
|
4855
|
-
frontendUrl: url
|
|
4974
|
+
frontendUrl: url,
|
|
4975
|
+
agents: this.agents
|
|
4856
4976
|
});
|
|
4857
4977
|
const configuredActions = typeof this.actions === "function" ? this.actions({
|
|
4858
4978
|
properties: graphqlContext.properties,
|
|
@@ -4957,7 +5077,7 @@ __name(resolveEndpointType, "resolveEndpointType");
|
|
|
4957
5077
|
|
|
4958
5078
|
// src/lib/telemetry-client.ts
|
|
4959
5079
|
var packageJson = require_package();
|
|
4960
|
-
var telemetryClient = new
|
|
5080
|
+
var telemetryClient = new import_shared19.TelemetryClient({
|
|
4961
5081
|
packageName: packageJson.name,
|
|
4962
5082
|
packageVersion: packageJson.version
|
|
4963
5083
|
});
|
|
@@ -5125,10 +5245,10 @@ var RuntimeEventSource = class {
|
|
|
5125
5245
|
const errorMessage = `\u274C ${message}`;
|
|
5126
5246
|
if (!this.callback) {
|
|
5127
5247
|
this.stream(async (eventStream$) => {
|
|
5128
|
-
eventStream$.sendTextMessage((0,
|
|
5248
|
+
eventStream$.sendTextMessage((0, import_shared20.randomId)(), errorMessage);
|
|
5129
5249
|
});
|
|
5130
5250
|
} else {
|
|
5131
|
-
this.eventStream$.sendTextMessage((0,
|
|
5251
|
+
this.eventStream$.sendTextMessage((0, import_shared20.randomId)(), errorMessage);
|
|
5132
5252
|
}
|
|
5133
5253
|
}
|
|
5134
5254
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
@@ -5324,7 +5444,7 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
5324
5444
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
5325
5445
|
|
|
5326
5446
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
5327
|
-
var
|
|
5447
|
+
var import_shared21 = require("@copilotkit/shared");
|
|
5328
5448
|
|
|
5329
5449
|
// src/graphql/types/agents-response.type.ts
|
|
5330
5450
|
var import_type_graphql19 = require("type-graphql");
|
|
@@ -5510,7 +5630,7 @@ var CopilotResolver = class {
|
|
|
5510
5630
|
ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
|
|
5511
5631
|
}
|
|
5512
5632
|
logger2.debug("Processing");
|
|
5513
|
-
const { eventSource, threadId = (0,
|
|
5633
|
+
const { eventSource, threadId = (0, import_shared21.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
|
|
5514
5634
|
serviceAdapter,
|
|
5515
5635
|
messages: data.messages,
|
|
5516
5636
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -5643,7 +5763,7 @@ var CopilotResolver = class {
|
|
|
5643
5763
|
});
|
|
5644
5764
|
outputMessages = [
|
|
5645
5765
|
(0, import_class_transformer3.plainToInstance)(TextMessage, {
|
|
5646
|
-
id: (0,
|
|
5766
|
+
id: (0, import_shared21.randomId)(),
|
|
5647
5767
|
createdAt: /* @__PURE__ */ new Date(),
|
|
5648
5768
|
content: result.reason,
|
|
5649
5769
|
role: MessageRole.assistant
|
|
@@ -5821,7 +5941,7 @@ var CopilotResolver = class {
|
|
|
5821
5941
|
event
|
|
5822
5942
|
}, "Agent message event received");
|
|
5823
5943
|
pushMessage({
|
|
5824
|
-
id: (0,
|
|
5944
|
+
id: (0, import_shared21.randomId)(),
|
|
5825
5945
|
status: new SuccessMessageStatus(),
|
|
5826
5946
|
threadId: event.threadId,
|
|
5827
5947
|
agentName: event.agentName,
|
|
@@ -5834,7 +5954,7 @@ var CopilotResolver = class {
|
|
|
5834
5954
|
createdAt: /* @__PURE__ */ new Date()
|
|
5835
5955
|
});
|
|
5836
5956
|
outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
|
|
5837
|
-
id: (0,
|
|
5957
|
+
id: (0, import_shared21.randomId)(),
|
|
5838
5958
|
threadId: event.threadId,
|
|
5839
5959
|
agentName: event.agentName,
|
|
5840
5960
|
nodeName: event.nodeName,
|