@copilotkit/runtime 1.8.5-next.3 → 1.8.5-next.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 +48 -0
- package/dist/{chunk-TDPCQIMB.mjs → chunk-AIQJ5N22.mjs} +2 -2
- package/dist/{chunk-UOCZJTXN.mjs → chunk-FP7EJSMU.mjs} +2 -2
- package/dist/{chunk-2PVUPC44.mjs → chunk-GQEDXH53.mjs} +2 -2
- package/dist/{chunk-UTUGZIQI.mjs → chunk-Q4KJZACA.mjs} +146 -9
- package/dist/chunk-Q4KJZACA.mjs.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +183 -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 +176 -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/src/lib/runtime/remote-lg-action.ts +24 -2
- package/dist/chunk-UTUGZIQI.mjs.map +0 -1
- /package/dist/{chunk-TDPCQIMB.mjs.map → chunk-AIQJ5N22.mjs.map} +0 -0
- /package/dist/{chunk-UOCZJTXN.mjs.map → chunk-FP7EJSMU.mjs.map} +0 -0
- /package/dist/{chunk-2PVUPC44.mjs.map → chunk-GQEDXH53.mjs.map} +0 -0
package/dist/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 './lib/integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
|
|
@@ -19,5 +19,6 @@ import '@copilotkit/shared';
|
|
|
19
19
|
import './index-5bec5424.js';
|
|
20
20
|
import './graphql/types/base/index.js';
|
|
21
21
|
import './lib/cloud/index.js';
|
|
22
|
+
import '@agentwire/client';
|
|
22
23
|
import 'rxjs';
|
|
23
24
|
import '@anthropic-ai/sdk';
|
package/dist/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-next.
|
|
47
|
+
version: "1.8.5-next.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",
|
|
@@ -2607,11 +2611,14 @@ GenerateCopilotResponseInput = _ts_decorate17([
|
|
|
2607
2611
|
var import_graphql_yoga = require("graphql-yoga");
|
|
2608
2612
|
|
|
2609
2613
|
// src/service-adapters/events.ts
|
|
2610
|
-
var
|
|
2614
|
+
var import_shared22 = require("@copilotkit/shared");
|
|
2611
2615
|
var import_rxjs3 = require("rxjs");
|
|
2612
2616
|
|
|
2613
2617
|
// src/lib/telemetry-client.ts
|
|
2614
|
-
var
|
|
2618
|
+
var import_shared21 = require("@copilotkit/shared");
|
|
2619
|
+
|
|
2620
|
+
// src/lib/runtime/remote-actions.ts
|
|
2621
|
+
var import_shared14 = require("@copilotkit/shared");
|
|
2615
2622
|
|
|
2616
2623
|
// src/lib/runtime/remote-action-constructors.ts
|
|
2617
2624
|
var import_node_crypto2 = require("crypto");
|
|
@@ -2900,6 +2907,23 @@ async function execute(args) {
|
|
|
2900
2907
|
await streamEvents(controller, args);
|
|
2901
2908
|
controller.close();
|
|
2902
2909
|
} catch (err) {
|
|
2910
|
+
const cause = err == null ? void 0 : err.cause;
|
|
2911
|
+
const errorCode = (cause == null ? void 0 : cause.code) || (err == null ? void 0 : err.code);
|
|
2912
|
+
if (errorCode === "ECONNREFUSED") {
|
|
2913
|
+
throw new import_shared9.CopilotKitMisuseError({
|
|
2914
|
+
message: `
|
|
2915
|
+
The LangGraph client could not connect to the graph. Please further check previous logs, which includes further details.
|
|
2916
|
+
|
|
2917
|
+
See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
|
|
2918
|
+
});
|
|
2919
|
+
} else {
|
|
2920
|
+
throw new import_shared9.CopilotKitMisuseError({
|
|
2921
|
+
message: `
|
|
2922
|
+
The LangGraph client threw unhandled error ${err}.
|
|
2923
|
+
|
|
2924
|
+
See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2903
2927
|
}
|
|
2904
2928
|
}
|
|
2905
2929
|
});
|
|
@@ -3764,7 +3788,101 @@ function createHeaders(onBeforeRequest, graphqlContext) {
|
|
|
3764
3788
|
__name(createHeaders, "createHeaders");
|
|
3765
3789
|
|
|
3766
3790
|
// src/lib/runtime/remote-actions.ts
|
|
3791
|
+
var import_shared15 = require("@copilotkit/shared");
|
|
3792
|
+
|
|
3793
|
+
// src/lib/runtime/agentwire-action.ts
|
|
3767
3794
|
var import_shared13 = require("@copilotkit/shared");
|
|
3795
|
+
function constructAgentWireRemoteAction({ logger: logger2, messages, agentStates, agent }) {
|
|
3796
|
+
const action = {
|
|
3797
|
+
name: agent.agentId,
|
|
3798
|
+
description: agent.description,
|
|
3799
|
+
parameters: [],
|
|
3800
|
+
handler: async (_args) => {
|
|
3801
|
+
},
|
|
3802
|
+
remoteAgentHandler: async ({ actionInputsWithoutAgents, threadId }) => {
|
|
3803
|
+
logger2.debug({
|
|
3804
|
+
actionName: agent.agentId
|
|
3805
|
+
}, "Executing remote agent");
|
|
3806
|
+
const agentWireMessages = convertMessagesToAgentWire(messages);
|
|
3807
|
+
agent.messages = agentWireMessages;
|
|
3808
|
+
agent.threadId = threadId;
|
|
3809
|
+
telemetry_client_default.capture("oss.runtime.remote_action_executed", {
|
|
3810
|
+
agentExecution: true,
|
|
3811
|
+
type: "self-hosted",
|
|
3812
|
+
agentsAmount: 1
|
|
3813
|
+
});
|
|
3814
|
+
let state = {};
|
|
3815
|
+
if (agentStates) {
|
|
3816
|
+
const jsonState = agentStates.find((state2) => state2.agentName === agent.agentId);
|
|
3817
|
+
if (jsonState) {
|
|
3818
|
+
state = (0, import_shared13.parseJson)(jsonState.state, {});
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
agent.state = state;
|
|
3822
|
+
const tools = actionInputsWithoutAgents.map((input) => {
|
|
3823
|
+
return {
|
|
3824
|
+
name: input.name,
|
|
3825
|
+
description: input.description,
|
|
3826
|
+
parameters: JSON.parse(input.jsonSchema)
|
|
3827
|
+
};
|
|
3828
|
+
});
|
|
3829
|
+
return agent.legacy_to_be_removed_runAgentBridged({
|
|
3830
|
+
tools
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
};
|
|
3834
|
+
return [
|
|
3835
|
+
action
|
|
3836
|
+
];
|
|
3837
|
+
}
|
|
3838
|
+
__name(constructAgentWireRemoteAction, "constructAgentWireRemoteAction");
|
|
3839
|
+
function convertMessagesToAgentWire(messages) {
|
|
3840
|
+
const result = [];
|
|
3841
|
+
for (const message of messages) {
|
|
3842
|
+
if (message.isTextMessage()) {
|
|
3843
|
+
result.push({
|
|
3844
|
+
id: message.id,
|
|
3845
|
+
role: message.role,
|
|
3846
|
+
content: message.content
|
|
3847
|
+
});
|
|
3848
|
+
} else if (message.isActionExecutionMessage()) {
|
|
3849
|
+
const toolCall = {
|
|
3850
|
+
id: message.id,
|
|
3851
|
+
type: "function",
|
|
3852
|
+
function: {
|
|
3853
|
+
name: message.name,
|
|
3854
|
+
arguments: JSON.stringify(message.arguments)
|
|
3855
|
+
}
|
|
3856
|
+
};
|
|
3857
|
+
if (message.parentMessageId && result.some((m) => m.id === message.parentMessageId)) {
|
|
3858
|
+
const parentMessage = result.find((m) => m.id === message.parentMessageId);
|
|
3859
|
+
if (parentMessage.toolCalls === void 0) {
|
|
3860
|
+
parentMessage.toolCalls = [];
|
|
3861
|
+
}
|
|
3862
|
+
parentMessage.toolCalls.push(toolCall);
|
|
3863
|
+
} else {
|
|
3864
|
+
result.push({
|
|
3865
|
+
id: message.parentMessageId ?? message.id,
|
|
3866
|
+
role: "assistant",
|
|
3867
|
+
toolCalls: [
|
|
3868
|
+
toolCall
|
|
3869
|
+
]
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
} else if (message.isResultMessage()) {
|
|
3873
|
+
result.push({
|
|
3874
|
+
id: message.id,
|
|
3875
|
+
role: "tool",
|
|
3876
|
+
content: message.result,
|
|
3877
|
+
toolCallId: message.actionExecutionId
|
|
3878
|
+
});
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
return result;
|
|
3882
|
+
}
|
|
3883
|
+
__name(convertMessagesToAgentWire, "convertMessagesToAgentWire");
|
|
3884
|
+
|
|
3885
|
+
// src/lib/runtime/remote-actions.ts
|
|
3768
3886
|
var EndpointType;
|
|
3769
3887
|
(function(EndpointType2) {
|
|
3770
3888
|
EndpointType2["CopilotKit"] = "copilotKit";
|
|
@@ -3798,7 +3916,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
3798
3916
|
status: response.status,
|
|
3799
3917
|
body: await response.text()
|
|
3800
3918
|
}, "Failed to fetch actions from url");
|
|
3801
|
-
throw new
|
|
3919
|
+
throw new import_shared15.ResolvedCopilotKitError({
|
|
3802
3920
|
status: response.status,
|
|
3803
3921
|
url: fetchUrl,
|
|
3804
3922
|
isRemoteEndpoint: true
|
|
@@ -3810,17 +3928,17 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
3810
3928
|
}, "Fetched actions from url");
|
|
3811
3929
|
return json;
|
|
3812
3930
|
} catch (error) {
|
|
3813
|
-
if (error instanceof
|
|
3931
|
+
if (error instanceof import_shared15.CopilotKitError) {
|
|
3814
3932
|
throw error;
|
|
3815
3933
|
}
|
|
3816
|
-
throw new
|
|
3934
|
+
throw new import_shared15.CopilotKitLowLevelError({
|
|
3817
3935
|
error,
|
|
3818
3936
|
url: fetchUrl
|
|
3819
3937
|
});
|
|
3820
3938
|
}
|
|
3821
3939
|
}
|
|
3822
3940
|
__name(fetchRemoteInfo, "fetchRemoteInfo");
|
|
3823
|
-
async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
|
|
3941
|
+
async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents }) {
|
|
3824
3942
|
const logger2 = graphqlContext.logger.child({
|
|
3825
3943
|
component: "remote-actions.fetchRemoteActions"
|
|
3826
3944
|
});
|
|
@@ -3869,6 +3987,22 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
|
|
|
3869
3987
|
agentStates
|
|
3870
3988
|
});
|
|
3871
3989
|
}));
|
|
3990
|
+
for (const [key, agent] of Object.entries(agents)) {
|
|
3991
|
+
if (agent.agentId !== void 0 && agent.agentId !== key) {
|
|
3992
|
+
throw new import_shared15.CopilotKitError({
|
|
3993
|
+
message: `Agent ${key} has agentId ${agent.agentId} which does not match the key ${key}`,
|
|
3994
|
+
code: import_shared14.CopilotKitErrorCode.UNKNOWN
|
|
3995
|
+
});
|
|
3996
|
+
} else if (agent.agentId === void 0) {
|
|
3997
|
+
agent.agentId = key;
|
|
3998
|
+
}
|
|
3999
|
+
result.push(constructAgentWireRemoteAction({
|
|
4000
|
+
logger: logger2,
|
|
4001
|
+
messages,
|
|
4002
|
+
agentStates,
|
|
4003
|
+
agent
|
|
4004
|
+
}));
|
|
4005
|
+
}
|
|
3872
4006
|
return result.flat();
|
|
3873
4007
|
}
|
|
3874
4008
|
__name(setupRemoteActions, "setupRemoteActions");
|
|
@@ -3877,7 +4011,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
3877
4011
|
var import_node_crypto3 = require("crypto");
|
|
3878
4012
|
|
|
3879
4013
|
// src/lib/runtime/copilot-runtime.ts
|
|
3880
|
-
var
|
|
4014
|
+
var import_shared20 = require("@copilotkit/shared");
|
|
3881
4015
|
|
|
3882
4016
|
// src/service-adapters/langchain/langserve.ts
|
|
3883
4017
|
var import_remote = require("langchain/runnables/remote");
|
|
@@ -4093,7 +4227,7 @@ function groupAnthropicMessagesByRole(messageParams) {
|
|
|
4093
4227
|
__name(groupAnthropicMessagesByRole, "groupAnthropicMessagesByRole");
|
|
4094
4228
|
|
|
4095
4229
|
// src/service-adapters/anthropic/anthropic-adapter.ts
|
|
4096
|
-
var
|
|
4230
|
+
var import_shared16 = require("@copilotkit/shared");
|
|
4097
4231
|
var DEFAULT_MODEL3 = "claude-3-sonnet-20240229";
|
|
4098
4232
|
var AnthropicAdapter = class {
|
|
4099
4233
|
model = DEFAULT_MODEL3;
|
|
@@ -4144,8 +4278,8 @@ var AnthropicAdapter = class {
|
|
|
4144
4278
|
eventSource.stream(async (eventStream$) => {
|
|
4145
4279
|
let mode = null;
|
|
4146
4280
|
let didOutputText = false;
|
|
4147
|
-
let currentMessageId = (0,
|
|
4148
|
-
let currentToolCallId = (0,
|
|
4281
|
+
let currentMessageId = (0, import_shared16.randomId)();
|
|
4282
|
+
let currentToolCallId = (0, import_shared16.randomId)();
|
|
4149
4283
|
let filterThinkingTextBuffer = new FilterThinkingTextBuffer();
|
|
4150
4284
|
for await (const chunk of await stream) {
|
|
4151
4285
|
if (chunk.type === "message_start") {
|
|
@@ -4202,7 +4336,7 @@ var AnthropicAdapter = class {
|
|
|
4202
4336
|
eventStream$.complete();
|
|
4203
4337
|
});
|
|
4204
4338
|
return {
|
|
4205
|
-
threadId: threadId || (0,
|
|
4339
|
+
threadId: threadId || (0, import_shared16.randomUUID)()
|
|
4206
4340
|
};
|
|
4207
4341
|
}
|
|
4208
4342
|
};
|
|
@@ -4242,7 +4376,7 @@ var FilterThinkingTextBuffer = /* @__PURE__ */ __name(class FilterThinkingTextBu
|
|
|
4242
4376
|
|
|
4243
4377
|
// src/service-adapters/experimental/ollama/ollama-adapter.ts
|
|
4244
4378
|
var import_ollama = require("@langchain/community/llms/ollama");
|
|
4245
|
-
var
|
|
4379
|
+
var import_shared17 = require("@copilotkit/shared");
|
|
4246
4380
|
var DEFAULT_MODEL4 = "llama3:latest";
|
|
4247
4381
|
var ExperimentalOllamaAdapter = class {
|
|
4248
4382
|
model;
|
|
@@ -4261,7 +4395,7 @@ var ExperimentalOllamaAdapter = class {
|
|
|
4261
4395
|
const contents = messages.filter((m) => m.isTextMessage()).map((m) => m.content);
|
|
4262
4396
|
const _stream = await ollama.stream(contents);
|
|
4263
4397
|
eventSource.stream(async (eventStream$) => {
|
|
4264
|
-
const currentMessageId = (0,
|
|
4398
|
+
const currentMessageId = (0, import_shared17.randomId)();
|
|
4265
4399
|
eventStream$.sendTextMessageStart({
|
|
4266
4400
|
messageId: currentMessageId
|
|
4267
4401
|
});
|
|
@@ -4277,18 +4411,18 @@ var ExperimentalOllamaAdapter = class {
|
|
|
4277
4411
|
eventStream$.complete();
|
|
4278
4412
|
});
|
|
4279
4413
|
return {
|
|
4280
|
-
threadId: request.threadId || (0,
|
|
4414
|
+
threadId: request.threadId || (0, import_shared17.randomUUID)()
|
|
4281
4415
|
};
|
|
4282
4416
|
}
|
|
4283
4417
|
};
|
|
4284
4418
|
__name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
|
|
4285
4419
|
|
|
4286
4420
|
// src/service-adapters/empty/empty-adapter.ts
|
|
4287
|
-
var
|
|
4421
|
+
var import_shared18 = require("@copilotkit/shared");
|
|
4288
4422
|
var EmptyAdapter = class {
|
|
4289
4423
|
async process(request) {
|
|
4290
4424
|
return {
|
|
4291
|
-
threadId: request.threadId || (0,
|
|
4425
|
+
threadId: request.threadId || (0, import_shared18.randomUUID)()
|
|
4292
4426
|
};
|
|
4293
4427
|
}
|
|
4294
4428
|
};
|
|
@@ -4411,9 +4545,9 @@ __name(AgentStateMessage, "AgentStateMessage");
|
|
|
4411
4545
|
|
|
4412
4546
|
// src/service-adapters/conversion.ts
|
|
4413
4547
|
var import_class_transformer = require("class-transformer");
|
|
4414
|
-
var
|
|
4548
|
+
var import_shared19 = require("@copilotkit/shared");
|
|
4415
4549
|
function convertGqlInputToMessages(inputMessages) {
|
|
4416
|
-
const messages = (0,
|
|
4550
|
+
const messages = (0, import_shared19.tryMap)(inputMessages, (message) => {
|
|
4417
4551
|
if (message.textMessage) {
|
|
4418
4552
|
return (0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
4419
4553
|
id: message.id,
|
|
@@ -4520,6 +4654,7 @@ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
|
|
|
4520
4654
|
// src/lib/runtime/copilot-runtime.ts
|
|
4521
4655
|
var CopilotRuntime = class {
|
|
4522
4656
|
actions;
|
|
4657
|
+
agents;
|
|
4523
4658
|
remoteEndpointDefinitions;
|
|
4524
4659
|
langserve = [];
|
|
4525
4660
|
onBeforeRequest;
|
|
@@ -4550,10 +4685,11 @@ var CopilotRuntime = class {
|
|
|
4550
4685
|
this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
|
|
4551
4686
|
this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
|
|
4552
4687
|
this.observability = params == null ? void 0 : params.observability_c;
|
|
4688
|
+
this.agents = (params == null ? void 0 : params.agents) ?? {};
|
|
4553
4689
|
this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
|
|
4554
4690
|
this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
|
|
4555
4691
|
if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
|
|
4556
|
-
throw new
|
|
4692
|
+
throw new import_shared20.CopilotKitMisuseError({
|
|
4557
4693
|
message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
|
|
4558
4694
|
});
|
|
4559
4695
|
}
|
|
@@ -4589,7 +4725,7 @@ var CopilotRuntime = class {
|
|
|
4589
4725
|
}
|
|
4590
4726
|
} else {
|
|
4591
4727
|
newMessages.unshift({
|
|
4592
|
-
id: (0,
|
|
4728
|
+
id: (0, import_shared20.randomId)(),
|
|
4593
4729
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4594
4730
|
textMessage: {
|
|
4595
4731
|
role: MessageRole.system,
|
|
@@ -4614,7 +4750,7 @@ var CopilotRuntime = class {
|
|
|
4614
4750
|
return await this.processAgentRequest(request);
|
|
4615
4751
|
}
|
|
4616
4752
|
if (serviceAdapter instanceof EmptyAdapter) {
|
|
4617
|
-
throw new
|
|
4753
|
+
throw new import_shared20.CopilotKitMisuseError({
|
|
4618
4754
|
message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
|
|
4619
4755
|
For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
|
|
4620
4756
|
please use an LLM adapter instead.`
|
|
@@ -4644,7 +4780,7 @@ please use an LLM adapter instead.`
|
|
|
4644
4780
|
const serverSideActionsInput = serverSideActions.map((action) => ({
|
|
4645
4781
|
name: action.name,
|
|
4646
4782
|
description: action.description,
|
|
4647
|
-
jsonSchema: JSON.stringify((0,
|
|
4783
|
+
jsonSchema: JSON.stringify((0, import_shared20.actionParametersToJsonSchema)(action.parameters))
|
|
4648
4784
|
}));
|
|
4649
4785
|
const actionInputs = flattenToolCallsNoDuplicates([
|
|
4650
4786
|
...serverSideActionsInput,
|
|
@@ -4773,7 +4909,7 @@ please use an LLM adapter instead.`
|
|
|
4773
4909
|
console.error("Error logging LLM error:", logError);
|
|
4774
4910
|
}
|
|
4775
4911
|
}
|
|
4776
|
-
if (error instanceof
|
|
4912
|
+
if (error instanceof import_shared20.CopilotKitError) {
|
|
4777
4913
|
throw error;
|
|
4778
4914
|
}
|
|
4779
4915
|
console.error("Error getting response:", error);
|
|
@@ -4799,12 +4935,12 @@ please use an LLM adapter instead.`
|
|
|
4799
4935
|
try {
|
|
4800
4936
|
data = await client.assistants.search();
|
|
4801
4937
|
if (data && "detail" in data && data.detail.toLowerCase() === "not found") {
|
|
4802
|
-
throw new
|
|
4938
|
+
throw new import_shared20.CopilotKitAgentDiscoveryError({
|
|
4803
4939
|
availableAgents: this.availableAgents
|
|
4804
4940
|
});
|
|
4805
4941
|
}
|
|
4806
4942
|
} catch (e) {
|
|
4807
|
-
throw new
|
|
4943
|
+
throw new import_shared20.CopilotKitMisuseError({
|
|
4808
4944
|
message: `
|
|
4809
4945
|
Failed to find or contact remote endpoint at url ${endpoint.deploymentUrl}.
|
|
4810
4946
|
Make sure the API is running and that it's indeed a LangGraph platform url.
|
|
@@ -4835,11 +4971,11 @@ please use an LLM adapter instead.`
|
|
|
4835
4971
|
});
|
|
4836
4972
|
if (!response.ok) {
|
|
4837
4973
|
if (response.status === 404) {
|
|
4838
|
-
throw new
|
|
4974
|
+
throw new import_shared20.CopilotKitApiDiscoveryError({
|
|
4839
4975
|
url: fetchUrl
|
|
4840
4976
|
});
|
|
4841
4977
|
}
|
|
4842
|
-
throw new
|
|
4978
|
+
throw new import_shared20.ResolvedCopilotKitError({
|
|
4843
4979
|
status: response.status,
|
|
4844
4980
|
url: fetchUrl,
|
|
4845
4981
|
isRemoteEndpoint: true
|
|
@@ -4849,7 +4985,7 @@ please use an LLM adapter instead.`
|
|
|
4849
4985
|
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
4850
4986
|
name: agent.name,
|
|
4851
4987
|
description: agent.description ?? "" ?? "",
|
|
4852
|
-
id: (0,
|
|
4988
|
+
id: (0, import_shared20.randomId)(),
|
|
4853
4989
|
endpoint
|
|
4854
4990
|
}));
|
|
4855
4991
|
return [
|
|
@@ -4857,10 +4993,10 @@ please use an LLM adapter instead.`
|
|
|
4857
4993
|
...endpointAgents
|
|
4858
4994
|
];
|
|
4859
4995
|
} catch (error) {
|
|
4860
|
-
if (error instanceof
|
|
4996
|
+
if (error instanceof import_shared20.CopilotKitError) {
|
|
4861
4997
|
throw error;
|
|
4862
4998
|
}
|
|
4863
|
-
throw new
|
|
4999
|
+
throw new import_shared20.CopilotKitLowLevelError({
|
|
4864
5000
|
error,
|
|
4865
5001
|
url: fetchUrl
|
|
4866
5002
|
});
|
|
@@ -4926,11 +5062,11 @@ please use an LLM adapter instead.`
|
|
|
4926
5062
|
});
|
|
4927
5063
|
if (!response.ok) {
|
|
4928
5064
|
if (response.status === 404) {
|
|
4929
|
-
throw new
|
|
5065
|
+
throw new import_shared20.CopilotKitApiDiscoveryError({
|
|
4930
5066
|
url: fetchUrl
|
|
4931
5067
|
});
|
|
4932
5068
|
}
|
|
4933
|
-
throw new
|
|
5069
|
+
throw new import_shared20.ResolvedCopilotKitError({
|
|
4934
5070
|
status: response.status,
|
|
4935
5071
|
url: fetchUrl,
|
|
4936
5072
|
isRemoteEndpoint: true
|
|
@@ -4943,10 +5079,10 @@ please use an LLM adapter instead.`
|
|
|
4943
5079
|
messages: JSON.stringify(data.messages)
|
|
4944
5080
|
};
|
|
4945
5081
|
} catch (error) {
|
|
4946
|
-
if (error instanceof
|
|
5082
|
+
if (error instanceof import_shared20.CopilotKitError) {
|
|
4947
5083
|
throw error;
|
|
4948
5084
|
}
|
|
4949
|
-
throw new
|
|
5085
|
+
throw new import_shared20.CopilotKitLowLevelError({
|
|
4950
5086
|
error,
|
|
4951
5087
|
url: fetchUrl
|
|
4952
5088
|
});
|
|
@@ -4966,7 +5102,7 @@ please use an LLM adapter instead.`
|
|
|
4966
5102
|
const messages = convertGqlInputToMessages(rawMessages);
|
|
4967
5103
|
const currentAgent = serverSideActions.find((action) => action.name === agentName && isRemoteAgentAction(action));
|
|
4968
5104
|
if (!currentAgent) {
|
|
4969
|
-
throw new
|
|
5105
|
+
throw new import_shared20.CopilotKitAgentDiscoveryError({
|
|
4970
5106
|
agentName,
|
|
4971
5107
|
availableAgents: this.availableAgents
|
|
4972
5108
|
});
|
|
@@ -4978,7 +5114,7 @@ please use an LLM adapter instead.`
|
|
|
4978
5114
|
)).map((action) => ({
|
|
4979
5115
|
name: action.name,
|
|
4980
5116
|
description: action.description,
|
|
4981
|
-
jsonSchema: JSON.stringify((0,
|
|
5117
|
+
jsonSchema: JSON.stringify((0, import_shared20.actionParametersToJsonSchema)(action.parameters))
|
|
4982
5118
|
}));
|
|
4983
5119
|
const allAvailableActions = flattenToolCallsNoDuplicates([
|
|
4984
5120
|
...availableActionsForCurrentAgent,
|
|
@@ -5171,7 +5307,8 @@ please use an LLM adapter instead.`
|
|
|
5171
5307
|
graphqlContext,
|
|
5172
5308
|
messages: inputMessages,
|
|
5173
5309
|
agentStates,
|
|
5174
|
-
frontendUrl: url
|
|
5310
|
+
frontendUrl: url,
|
|
5311
|
+
agents: this.agents
|
|
5175
5312
|
});
|
|
5176
5313
|
const configuredActions = typeof this.actions === "function" ? this.actions({
|
|
5177
5314
|
properties: graphqlContext.properties,
|
|
@@ -5276,7 +5413,7 @@ __name(resolveEndpointType, "resolveEndpointType");
|
|
|
5276
5413
|
|
|
5277
5414
|
// src/lib/telemetry-client.ts
|
|
5278
5415
|
var packageJson = require_package();
|
|
5279
|
-
var telemetryClient = new
|
|
5416
|
+
var telemetryClient = new import_shared21.TelemetryClient({
|
|
5280
5417
|
packageName: packageJson.name,
|
|
5281
5418
|
packageVersion: packageJson.version
|
|
5282
5419
|
});
|
|
@@ -5444,10 +5581,10 @@ var RuntimeEventSource = class {
|
|
|
5444
5581
|
const errorMessage = `\u274C ${message}`;
|
|
5445
5582
|
if (!this.callback) {
|
|
5446
5583
|
this.stream(async (eventStream$) => {
|
|
5447
|
-
eventStream$.sendTextMessage((0,
|
|
5584
|
+
eventStream$.sendTextMessage((0, import_shared22.randomId)(), errorMessage);
|
|
5448
5585
|
});
|
|
5449
5586
|
} else {
|
|
5450
|
-
this.eventStream$.sendTextMessage((0,
|
|
5587
|
+
this.eventStream$.sendTextMessage((0, import_shared22.randomId)(), errorMessage);
|
|
5451
5588
|
}
|
|
5452
5589
|
}
|
|
5453
5590
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
@@ -5643,7 +5780,7 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
5643
5780
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
5644
5781
|
|
|
5645
5782
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
5646
|
-
var
|
|
5783
|
+
var import_shared23 = require("@copilotkit/shared");
|
|
5647
5784
|
|
|
5648
5785
|
// src/graphql/types/agents-response.type.ts
|
|
5649
5786
|
var import_type_graphql19 = require("type-graphql");
|
|
@@ -5829,7 +5966,7 @@ var CopilotResolver = class {
|
|
|
5829
5966
|
ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
|
|
5830
5967
|
}
|
|
5831
5968
|
logger2.debug("Processing");
|
|
5832
|
-
const { eventSource, threadId = (0,
|
|
5969
|
+
const { eventSource, threadId = (0, import_shared23.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
|
|
5833
5970
|
serviceAdapter,
|
|
5834
5971
|
messages: data.messages,
|
|
5835
5972
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -5962,7 +6099,7 @@ var CopilotResolver = class {
|
|
|
5962
6099
|
});
|
|
5963
6100
|
outputMessages = [
|
|
5964
6101
|
(0, import_class_transformer3.plainToInstance)(TextMessage, {
|
|
5965
|
-
id: (0,
|
|
6102
|
+
id: (0, import_shared23.randomId)(),
|
|
5966
6103
|
createdAt: /* @__PURE__ */ new Date(),
|
|
5967
6104
|
content: result.reason,
|
|
5968
6105
|
role: MessageRole.assistant
|
|
@@ -6140,7 +6277,7 @@ var CopilotResolver = class {
|
|
|
6140
6277
|
event
|
|
6141
6278
|
}, "Agent message event received");
|
|
6142
6279
|
pushMessage({
|
|
6143
|
-
id: (0,
|
|
6280
|
+
id: (0, import_shared23.randomId)(),
|
|
6144
6281
|
status: new SuccessMessageStatus(),
|
|
6145
6282
|
threadId: event.threadId,
|
|
6146
6283
|
agentName: event.agentName,
|
|
@@ -6153,7 +6290,7 @@ var CopilotResolver = class {
|
|
|
6153
6290
|
createdAt: /* @__PURE__ */ new Date()
|
|
6154
6291
|
});
|
|
6155
6292
|
outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
|
|
6156
|
-
id: (0,
|
|
6293
|
+
id: (0, import_shared23.randomId)(),
|
|
6157
6294
|
threadId: event.threadId,
|
|
6158
6295
|
agentName: event.agentName,
|
|
6159
6296
|
nodeName: event.nodeName,
|