@copilotkit/runtime 1.9.2-next.24 → 1.9.2-next.26
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-S2YGYQDH.mjs → chunk-3RL34U4Q.mjs} +2 -2
- package/dist/{chunk-FR4C3TPU.mjs → chunk-D7OAY4CQ.mjs} +2 -2
- package/dist/{chunk-GAUZHH2X.mjs → chunk-GRU5EPNU.mjs} +91 -39
- package/dist/chunk-GRU5EPNU.mjs.map +1 -0
- package/dist/{chunk-ECQRTXJX.mjs → chunk-PQG7ZI72.mjs} +2 -2
- package/dist/{chunk-TBVA4IGX.mjs → chunk-SE7TPKR2.mjs} +2 -2
- package/dist/{groq-adapter-098f97f6.d.ts → groq-adapter-742818f2.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +83 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +83 -31
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +3 -3
- 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.d.ts +2 -2
- 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.d.ts +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 +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +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 +2 -2
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/{shared-6b6dbf8b.d.ts → shared-96b46379.d.ts} +1 -1
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +46 -28
- package/src/service-adapters/events.ts +40 -1
- package/dist/chunk-GAUZHH2X.mjs.map +0 -1
- /package/dist/{chunk-S2YGYQDH.mjs.map → chunk-3RL34U4Q.mjs.map} +0 -0
- /package/dist/{chunk-FR4C3TPU.mjs.map → chunk-D7OAY4CQ.mjs.map} +0 -0
- /package/dist/{chunk-ECQRTXJX.mjs.map → chunk-PQG7ZI72.mjs.map} +0 -0
- /package/dist/{chunk-TBVA4IGX.mjs.map → chunk-SE7TPKR2.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CustomEventNames,
|
|
3
3
|
LangGraphAgent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3RL34U4Q.mjs";
|
|
5
5
|
import {
|
|
6
6
|
config,
|
|
7
7
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
8
8
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SE7TPKR2.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNestEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PQG7ZI72.mjs";
|
|
13
13
|
import {
|
|
14
14
|
copilotRuntimeNodeExpressEndpoint
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-D7OAY4CQ.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotRuntime,
|
|
18
18
|
addCustomHeaderPlugin,
|
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
getCommonConfig,
|
|
29
29
|
langGraphPlatformEndpoint,
|
|
30
30
|
resolveEndpointType
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-GRU5EPNU.mjs";
|
|
32
|
+
import "./chunk-SHBDMA63.mjs";
|
|
32
33
|
import {
|
|
33
34
|
AnthropicAdapter,
|
|
34
35
|
BedrockAdapter,
|
|
@@ -51,7 +52,6 @@ import {
|
|
|
51
52
|
import {
|
|
52
53
|
convertServiceAdapterError
|
|
53
54
|
} from "./chunk-AMUJQ6IR.mjs";
|
|
54
|
-
import "./chunk-SHBDMA63.mjs";
|
|
55
55
|
import "./chunk-2OZAGFV3.mjs";
|
|
56
56
|
import "./chunk-FHD4JECV.mjs";
|
|
57
57
|
|
|
@@ -146,6 +146,12 @@ declare class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
|
|
|
146
146
|
declare class RuntimeEventSource {
|
|
147
147
|
private eventStream$;
|
|
148
148
|
private callback;
|
|
149
|
+
private errorHandler?;
|
|
150
|
+
private errorContext?;
|
|
151
|
+
constructor(params?: {
|
|
152
|
+
errorHandler?: (error: any, context: any) => Promise<void>;
|
|
153
|
+
errorContext?: any;
|
|
154
|
+
});
|
|
149
155
|
stream(callback: EventSourceCallback): Promise<void>;
|
|
150
156
|
sendErrorMessageToChat(message?: string): void;
|
|
151
157
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId, }: {
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-
|
|
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-742818f2.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, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-96b46379.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';
|
|
@@ -9,7 +9,7 @@ import { TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, To
|
|
|
9
9
|
import { LangGraphAgent as LangGraphAgent$1, LangGraphAgentConfig, ProcessedEvents, SchemaKeys } from '@ag-ui/langgraph';
|
|
10
10
|
import { Message } from '@langchain/langgraph-sdk/dist/types.messages';
|
|
11
11
|
import 'openai';
|
|
12
|
-
import '../langserve-
|
|
12
|
+
import '../langserve-3e8d0e06.js';
|
|
13
13
|
import '../index-d4614f9b.js';
|
|
14
14
|
import '../graphql/types/base/index.js';
|
|
15
15
|
import '@copilotkit/shared';
|
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.9.2-next.
|
|
47
|
+
version: "1.9.2-next.26",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -4394,30 +4394,30 @@ var CopilotRuntime = class {
|
|
|
4394
4394
|
async processRuntimeRequest(request) {
|
|
4395
4395
|
var _a, _b, _c, _d, _e;
|
|
4396
4396
|
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, url, extensions, agentSession, agentStates, publicApiKey } = request;
|
|
4397
|
-
const eventSource = new RuntimeEventSource(
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
await this.error("request", {
|
|
4401
|
-
threadId,
|
|
4402
|
-
runId,
|
|
4403
|
-
source: "runtime",
|
|
4404
|
-
request: {
|
|
4405
|
-
operation: "processRuntimeRequest",
|
|
4406
|
-
method: "POST",
|
|
4407
|
-
url,
|
|
4408
|
-
startTime: requestStartTime
|
|
4397
|
+
const eventSource = new RuntimeEventSource({
|
|
4398
|
+
errorHandler: async (error, context) => {
|
|
4399
|
+
await this.error("error", context, error, publicApiKey);
|
|
4409
4400
|
},
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4401
|
+
errorContext: {
|
|
4402
|
+
threadId,
|
|
4403
|
+
runId,
|
|
4404
|
+
source: "runtime",
|
|
4405
|
+
request: {
|
|
4406
|
+
operation: "processRuntimeRequest",
|
|
4407
|
+
method: "POST",
|
|
4408
|
+
url,
|
|
4409
|
+
startTime: Date.now()
|
|
4410
|
+
},
|
|
4411
|
+
agent: agentSession ? {
|
|
4412
|
+
name: agentSession.agentName
|
|
4413
|
+
} : void 0,
|
|
4414
|
+
technical: {
|
|
4415
|
+
environment: process.env.NODE_ENV
|
|
4416
|
+
}
|
|
4419
4417
|
}
|
|
4420
|
-
}
|
|
4418
|
+
});
|
|
4419
|
+
const requestStartTime = Date.now();
|
|
4420
|
+
const streamedChunks = [];
|
|
4421
4421
|
try {
|
|
4422
4422
|
if (Object.keys(this.agents).length && (agentSession == null ? void 0 : agentSession.agentName) && !this.delegateAgentProcessingToServiceAdapter) {
|
|
4423
4423
|
this.agents = {
|
|
@@ -4728,6 +4728,7 @@ please use an LLM adapter instead.`
|
|
|
4728
4728
|
}));
|
|
4729
4729
|
}
|
|
4730
4730
|
async loadAgentState(graphqlContext, threadId, agentName) {
|
|
4731
|
+
var _a;
|
|
4731
4732
|
const agents = await this.getAllAgents(graphqlContext);
|
|
4732
4733
|
const agent = agents.find((agent2) => agent2.name === agentName);
|
|
4733
4734
|
if (!agent) {
|
|
@@ -4808,12 +4809,17 @@ please use an LLM adapter instead.`
|
|
|
4808
4809
|
state = client ? (await client.threads.getState(threadId)).values : {};
|
|
4809
4810
|
} catch (error) {
|
|
4810
4811
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4812
|
+
const errorStatus = ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) || (error == null ? void 0 : error.status);
|
|
4813
|
+
if (errorStatus === 404) {
|
|
4814
|
+
state = {};
|
|
4815
|
+
} else {
|
|
4816
|
+
console.debug(`Agent '${agentName}' configuration issue: ${errorMessage}`);
|
|
4817
|
+
throw new import_shared15.ResolvedCopilotKitError({
|
|
4818
|
+
status: 400,
|
|
4819
|
+
message: `Agent '${agentName}' failed to execute: ${errorMessage}`,
|
|
4820
|
+
code: import_shared15.CopilotKitErrorCode.CONFIGURATION_ERROR
|
|
4821
|
+
});
|
|
4822
|
+
}
|
|
4817
4823
|
}
|
|
4818
4824
|
if (Object.keys(state).length === 0) {
|
|
4819
4825
|
return {
|
|
@@ -4909,7 +4915,27 @@ please use an LLM adapter instead.`
|
|
|
4909
4915
|
properties: graphqlContext.properties
|
|
4910
4916
|
}));
|
|
4911
4917
|
try {
|
|
4912
|
-
const eventSource = new RuntimeEventSource(
|
|
4918
|
+
const eventSource = new RuntimeEventSource({
|
|
4919
|
+
errorHandler: async (error, context) => {
|
|
4920
|
+
await this.error("error", context, error, publicApiKey);
|
|
4921
|
+
},
|
|
4922
|
+
errorContext: {
|
|
4923
|
+
threadId,
|
|
4924
|
+
source: "agent",
|
|
4925
|
+
request: {
|
|
4926
|
+
operation: "processAgentRequest",
|
|
4927
|
+
method: "POST",
|
|
4928
|
+
startTime: requestStartTime
|
|
4929
|
+
},
|
|
4930
|
+
agent: {
|
|
4931
|
+
name: agentName,
|
|
4932
|
+
nodeName
|
|
4933
|
+
},
|
|
4934
|
+
technical: {
|
|
4935
|
+
environment: process.env.NODE_ENV
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
});
|
|
4913
4939
|
const stream = await currentAgent.remoteAgentHandler({
|
|
4914
4940
|
name: agentName,
|
|
4915
4941
|
threadId,
|
|
@@ -6210,6 +6236,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
|
6210
6236
|
var RuntimeEventSource = class {
|
|
6211
6237
|
eventStream$ = new RuntimeEventSubject();
|
|
6212
6238
|
callback;
|
|
6239
|
+
errorHandler;
|
|
6240
|
+
errorContext;
|
|
6241
|
+
constructor(params) {
|
|
6242
|
+
this.errorHandler = params == null ? void 0 : params.errorHandler;
|
|
6243
|
+
this.errorContext = params == null ? void 0 : params.errorContext;
|
|
6244
|
+
}
|
|
6213
6245
|
async stream(callback) {
|
|
6214
6246
|
this.callback = callback;
|
|
6215
6247
|
}
|
|
@@ -6224,8 +6256,15 @@ var RuntimeEventSource = class {
|
|
|
6224
6256
|
}
|
|
6225
6257
|
}
|
|
6226
6258
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
6227
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
6259
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
6228
6260
|
const structuredError = (0, import_shared24.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6261
|
+
if (this.errorHandler && this.errorContext) {
|
|
6262
|
+
try {
|
|
6263
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
6264
|
+
} catch (errorHandlerError) {
|
|
6265
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6229
6268
|
this.eventStream$.error(structuredError);
|
|
6230
6269
|
this.eventStream$.complete();
|
|
6231
6270
|
});
|
|
@@ -6264,6 +6303,19 @@ var RuntimeEventSource = class {
|
|
|
6264
6303
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
6265
6304
|
return (0, import_rxjs3.concat)((0, import_rxjs3.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs3.catchError)((error) => {
|
|
6266
6305
|
const structuredError = (0, import_shared24.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6306
|
+
if (this.errorHandler && this.errorContext) {
|
|
6307
|
+
(0, import_rxjs3.from)(this.errorHandler(structuredError, {
|
|
6308
|
+
...this.errorContext,
|
|
6309
|
+
action: {
|
|
6310
|
+
name: eventWithState.action.name,
|
|
6311
|
+
executionId: eventWithState.actionExecutionId
|
|
6312
|
+
}
|
|
6313
|
+
})).subscribe({
|
|
6314
|
+
error: (errorHandlerError) => {
|
|
6315
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
6316
|
+
}
|
|
6317
|
+
});
|
|
6318
|
+
}
|
|
6267
6319
|
toolCallEventStream$.sendActionExecutionResult({
|
|
6268
6320
|
actionExecutionId: eventWithState.actionExecutionId,
|
|
6269
6321
|
actionName: eventWithState.action.name,
|