@copilotkit/runtime 1.9.2-next.16 → 1.9.2-next.18
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 +18 -0
- package/dist/{chunk-7F4BIRQF.mjs → chunk-FW5UOGQ2.mjs} +38 -33
- package/dist/chunk-FW5UOGQ2.mjs.map +1 -0
- package/dist/{chunk-4ODT32DV.mjs → chunk-JIE2UKYM.mjs} +2 -2
- package/dist/{chunk-BCDAWNNK.mjs → chunk-QSSQAW7A.mjs} +2 -2
- package/dist/{chunk-R22NGLLV.mjs → chunk-RXWWTMSG.mjs} +2 -2
- package/dist/{chunk-RBG2A675.mjs → chunk-Y6GPK3Y7.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +37 -32
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +2 -2
- package/dist/lib/integrations/index.js +2 -2
- 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 +1 -1
- package/dist/lib/integrations/nest/index.js +2 -2
- 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 +1 -1
- package/dist/lib/integrations/node-express/index.js +2 -2
- 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 +1 -1
- package/dist/lib/integrations/node-http/index.js +2 -2
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/{shared-4164c674.d.ts → shared-41d4988d.d.ts} +13 -13
- package/package.json +2 -2
- package/src/graphql/resolvers/copilot.resolver.ts +1 -2
- package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts} +27 -27
- package/src/lib/runtime/agui-action.ts +3 -0
- package/src/lib/runtime/copilot-runtime.ts +42 -42
- package/src/lib/runtime/remote-actions.ts +3 -0
- package/dist/chunk-7F4BIRQF.mjs.map +0 -1
- /package/dist/{chunk-4ODT32DV.mjs.map → chunk-JIE2UKYM.mjs.map} +0 -0
- /package/dist/{chunk-BCDAWNNK.mjs.map → chunk-QSSQAW7A.mjs.map} +0 -0
- /package/dist/{chunk-R22NGLLV.mjs.map → chunk-RXWWTMSG.mjs.map} +0 -0
- /package/dist/{chunk-RBG2A675.mjs.map → chunk-Y6GPK3Y7.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import * as graphql from 'graphql';
|
|
|
2
2
|
import * as createPinoLogger from 'pino';
|
|
3
3
|
import createPinoLogger__default from 'pino';
|
|
4
4
|
import { YogaInitialContext, createYoga } from 'graphql-yoga';
|
|
5
|
-
import { Parameter, Action,
|
|
5
|
+
import { Parameter, Action, CopilotErrorHandler } from '@copilotkit/shared';
|
|
6
6
|
import { b as CopilotServiceAdapter, A as ActionInput, d as AgentSessionInput, e as AgentStateInput, F as ForwardedParametersInput, E as ExtensionsInput, R as RemoteChainParameters, f as RuntimeEventSource, g as ExtensionsResponse } from './langserve-fc5cac89.js';
|
|
7
7
|
import { M as MessageInput, a as Message } from './index-d4614f9b.js';
|
|
8
8
|
import { CopilotCloudOptions } from './lib/cloud/index.js';
|
|
@@ -340,23 +340,23 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
|
340
340
|
*/
|
|
341
341
|
createMCPClient?: CreateMCPClientFunction;
|
|
342
342
|
/**
|
|
343
|
-
* Optional
|
|
343
|
+
* Optional error handler for comprehensive debugging and observability.
|
|
344
344
|
*
|
|
345
|
-
* **Requires publicApiKey**:
|
|
345
|
+
* **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
|
|
346
346
|
* This is a premium CopilotKit Cloud feature.
|
|
347
347
|
*
|
|
348
|
-
* @param
|
|
348
|
+
* @param errorEvent - Structured error event with rich debugging context
|
|
349
349
|
*
|
|
350
350
|
* @example
|
|
351
351
|
* ```typescript
|
|
352
352
|
* const runtime = new CopilotRuntime({
|
|
353
|
-
*
|
|
354
|
-
* debugDashboard.capture(
|
|
353
|
+
* onError: (errorEvent) => {
|
|
354
|
+
* debugDashboard.capture(errorEvent);
|
|
355
355
|
* }
|
|
356
356
|
* });
|
|
357
357
|
* ```
|
|
358
358
|
*/
|
|
359
|
-
|
|
359
|
+
onError?: CopilotErrorHandler;
|
|
360
360
|
}
|
|
361
361
|
declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
362
362
|
actions: ActionsConfiguration<T>;
|
|
@@ -368,8 +368,8 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
368
368
|
private delegateAgentProcessingToServiceAdapter;
|
|
369
369
|
private observability?;
|
|
370
370
|
private availableAgents;
|
|
371
|
-
private
|
|
372
|
-
private
|
|
371
|
+
private onError?;
|
|
372
|
+
private hasWarnedAboutError;
|
|
373
373
|
private readonly mcpServersConfig?;
|
|
374
374
|
private mcpActionCache;
|
|
375
375
|
private readonly createMCPClientImpl?;
|
|
@@ -384,12 +384,12 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
384
384
|
private getServerSideActions;
|
|
385
385
|
private detectProvider;
|
|
386
386
|
private convertStreamingErrorToStructured;
|
|
387
|
-
private
|
|
387
|
+
private error;
|
|
388
388
|
/**
|
|
389
|
-
* Public method to
|
|
390
|
-
* This allows the GraphQL resolver to send validation errors through the
|
|
389
|
+
* Public method to handle GraphQL validation errors
|
|
390
|
+
* This allows the GraphQL resolver to send validation errors through the error system
|
|
391
391
|
*/
|
|
392
|
-
|
|
392
|
+
errorGraphQLError(error: {
|
|
393
393
|
message: string;
|
|
394
394
|
code: string;
|
|
395
395
|
type: string;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.9.2-next.
|
|
12
|
+
"version": "1.9.2-next.18",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rxjs": "7.8.1",
|
|
67
67
|
"type-graphql": "2.0.0-rc.1",
|
|
68
68
|
"zod": "^3.23.3",
|
|
69
|
-
"@copilotkit/shared": "1.9.2-next.
|
|
69
|
+
"@copilotkit/shared": "1.9.2-next.18"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@ag-ui/client": ">=0.0.28",
|
|
@@ -192,8 +192,7 @@ export class CopilotResolver {
|
|
|
192
192
|
if (!copilotCloudPublicApiKey) {
|
|
193
193
|
logger.error("Public API key not found in headers");
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
await copilotRuntime.traceGraphQLError(
|
|
195
|
+
await copilotRuntime.errorGraphQLError(
|
|
197
196
|
{
|
|
198
197
|
message: "X-CopilotCloud-Public-API-Key header is required",
|
|
199
198
|
code: "MISSING_PUBLIC_API_KEY",
|
package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopilotErrorEvent, CopilotRequestContext, CopilotErrorHandler } from "@copilotkit/shared";
|
|
2
2
|
|
|
3
|
-
describe("CopilotRuntime
|
|
3
|
+
describe("CopilotRuntime onError types", () => {
|
|
4
4
|
it("should have correct CopilotTraceEvent type structure", () => {
|
|
5
|
-
const
|
|
5
|
+
const errorEvent: CopilotErrorEvent = {
|
|
6
6
|
type: "error",
|
|
7
7
|
timestamp: Date.now(),
|
|
8
8
|
context: {
|
|
@@ -18,10 +18,10 @@ describe("CopilotRuntime onTrace types", () => {
|
|
|
18
18
|
error: new Error("Test error"),
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
21
|
+
expect(errorEvent.type).toBe("error");
|
|
22
|
+
expect(errorEvent.timestamp).toBeGreaterThan(0);
|
|
23
|
+
expect(errorEvent.context.threadId).toBe("test-123");
|
|
24
|
+
expect(errorEvent.error).toBeInstanceOf(Error);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it("should have correct CopilotRequestContext type structure", () => {
|
|
@@ -76,8 +76,8 @@ describe("CopilotRuntime onTrace types", () => {
|
|
|
76
76
|
expect(context.metadata?.testFlag).toBe(true);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it("should support all
|
|
80
|
-
const eventTypes:
|
|
79
|
+
it("should support all error event types", () => {
|
|
80
|
+
const eventTypes: CopilotErrorEvent["type"][] = [
|
|
81
81
|
"error",
|
|
82
82
|
"request",
|
|
83
83
|
"response",
|
|
@@ -88,7 +88,7 @@ describe("CopilotRuntime onTrace types", () => {
|
|
|
88
88
|
];
|
|
89
89
|
|
|
90
90
|
eventTypes.forEach((type) => {
|
|
91
|
-
const event:
|
|
91
|
+
const event: CopilotErrorEvent = {
|
|
92
92
|
type,
|
|
93
93
|
timestamp: Date.now(),
|
|
94
94
|
context: {
|
|
@@ -108,37 +108,37 @@ describe("CopilotRuntime onTrace types", () => {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
describe("publicApiKey gating logic", () => {
|
|
111
|
-
type
|
|
111
|
+
type ShouldHandleError = (onError?: CopilotErrorHandler, publicApiKey?: string) => boolean;
|
|
112
112
|
|
|
113
|
-
const
|
|
114
|
-
return Boolean(
|
|
113
|
+
const shouldHandleError: ShouldHandleError = (onError, publicApiKey) => {
|
|
114
|
+
return Boolean(onError && publicApiKey);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
it("should return true when both
|
|
118
|
-
const
|
|
119
|
-
const result =
|
|
117
|
+
it("should return true when both onError and publicApiKey are provided", () => {
|
|
118
|
+
const onError = jest.fn();
|
|
119
|
+
const result = shouldHandleError(onError, "valid-api-key");
|
|
120
120
|
expect(result).toBe(true);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
it("should return false when
|
|
124
|
-
const result =
|
|
123
|
+
it("should return false when onError is missing", () => {
|
|
124
|
+
const result = shouldHandleError(undefined, "valid-api-key");
|
|
125
125
|
expect(result).toBe(false);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
it("should return false when publicApiKey is missing", () => {
|
|
129
|
-
const
|
|
130
|
-
const result =
|
|
129
|
+
const onError = jest.fn();
|
|
130
|
+
const result = shouldHandleError(onError, undefined);
|
|
131
131
|
expect(result).toBe(false);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
it("should return false when publicApiKey is empty string", () => {
|
|
135
|
-
const
|
|
136
|
-
const result =
|
|
135
|
+
const onError = jest.fn();
|
|
136
|
+
const result = shouldHandleError(onError, "");
|
|
137
137
|
expect(result).toBe(false);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
it("should return false when both are missing", () => {
|
|
141
|
-
const result =
|
|
141
|
+
const result = shouldHandleError(undefined, undefined);
|
|
142
142
|
expect(result).toBe(false);
|
|
143
143
|
});
|
|
144
144
|
|
|
@@ -160,10 +160,10 @@ describe("CopilotRuntime onTrace types", () => {
|
|
|
160
160
|
const nonCloudKey = extractPublicApiKey(mockHeaders, false);
|
|
161
161
|
expect(nonCloudKey).toBe("test-key-123");
|
|
162
162
|
|
|
163
|
-
// Both should enable
|
|
164
|
-
const
|
|
165
|
-
expect(
|
|
166
|
-
expect(
|
|
163
|
+
// Both should enable error handling when onError is present
|
|
164
|
+
const onError = jest.fn();
|
|
165
|
+
expect(shouldHandleError(onError, cloudKey)).toBe(true);
|
|
166
|
+
expect(shouldHandleError(onError, nonCloudKey)).toBe(true);
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
});
|
|
@@ -23,6 +23,7 @@ export function constructAGUIRemoteAction({
|
|
|
23
23
|
agent,
|
|
24
24
|
metaEvents,
|
|
25
25
|
threadMetadata,
|
|
26
|
+
nodeName,
|
|
26
27
|
}: {
|
|
27
28
|
logger: Logger;
|
|
28
29
|
messages: Message[];
|
|
@@ -30,6 +31,7 @@ export function constructAGUIRemoteAction({
|
|
|
30
31
|
agent: AbstractAgent;
|
|
31
32
|
metaEvents?: MetaEventInput[];
|
|
32
33
|
threadMetadata?: Record<string, any>;
|
|
34
|
+
nodeName?: string;
|
|
33
35
|
}) {
|
|
34
36
|
const action = {
|
|
35
37
|
name: agent.agentId,
|
|
@@ -72,6 +74,7 @@ export function constructAGUIRemoteAction({
|
|
|
72
74
|
const forwardedProps = {
|
|
73
75
|
...(metaEvents?.length ? { command: { resume: metaEvents[0]?.response } } : {}),
|
|
74
76
|
...(threadMetadata ? { threadMetadata } : {}),
|
|
77
|
+
...(nodeName ? { nodeName } : {}),
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
return agent.legacy_to_be_removed_runAgentBridged({
|
|
@@ -20,13 +20,12 @@ import {
|
|
|
20
20
|
CopilotKitApiDiscoveryError,
|
|
21
21
|
randomId,
|
|
22
22
|
CopilotKitError,
|
|
23
|
-
CopilotKitRemoteEndpointDiscoveryError,
|
|
24
23
|
CopilotKitAgentDiscoveryError,
|
|
25
24
|
CopilotKitMisuseError,
|
|
26
25
|
CopilotKitErrorCode,
|
|
27
26
|
CopilotKitLowLevelError,
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
CopilotErrorHandler,
|
|
28
|
+
CopilotErrorEvent,
|
|
30
29
|
CopilotRequestContext,
|
|
31
30
|
ensureStructuredError,
|
|
32
31
|
} from "@copilotkit/shared";
|
|
@@ -66,7 +65,7 @@ import { ExtensionsInput } from "../../graphql/inputs/extensions.input";
|
|
|
66
65
|
import { ExtensionsResponse } from "../../graphql/types/extensions-response.type";
|
|
67
66
|
import { LoadAgentStateResponse } from "../../graphql/types/load-agent-state-response.type";
|
|
68
67
|
import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
|
|
69
|
-
import { langchainMessagesToCopilotKit
|
|
68
|
+
import { langchainMessagesToCopilotKit } from "./remote-lg-action";
|
|
70
69
|
import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
|
|
71
70
|
import {
|
|
72
71
|
CopilotObservabilityConfig,
|
|
@@ -283,23 +282,23 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
|
|
|
283
282
|
createMCPClient?: CreateMCPClientFunction;
|
|
284
283
|
|
|
285
284
|
/**
|
|
286
|
-
* Optional
|
|
285
|
+
* Optional error handler for comprehensive debugging and observability.
|
|
287
286
|
*
|
|
288
|
-
* **Requires publicApiKey**:
|
|
287
|
+
* **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
|
|
289
288
|
* This is a premium CopilotKit Cloud feature.
|
|
290
289
|
*
|
|
291
|
-
* @param
|
|
290
|
+
* @param errorEvent - Structured error event with rich debugging context
|
|
292
291
|
*
|
|
293
292
|
* @example
|
|
294
293
|
* ```typescript
|
|
295
294
|
* const runtime = new CopilotRuntime({
|
|
296
|
-
*
|
|
297
|
-
* debugDashboard.capture(
|
|
295
|
+
* onError: (errorEvent) => {
|
|
296
|
+
* debugDashboard.capture(errorEvent);
|
|
298
297
|
* }
|
|
299
298
|
* });
|
|
300
299
|
* ```
|
|
301
300
|
*/
|
|
302
|
-
|
|
301
|
+
onError?: CopilotErrorHandler;
|
|
303
302
|
}
|
|
304
303
|
|
|
305
304
|
export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
@@ -312,8 +311,8 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
312
311
|
private delegateAgentProcessingToServiceAdapter: boolean;
|
|
313
312
|
private observability?: CopilotObservabilityConfig;
|
|
314
313
|
private availableAgents: Pick<AgentWithEndpoint, "name" | "id">[];
|
|
315
|
-
private
|
|
316
|
-
private
|
|
314
|
+
private onError?: CopilotErrorHandler;
|
|
315
|
+
private hasWarnedAboutError = false;
|
|
317
316
|
|
|
318
317
|
// +++ MCP Properties +++
|
|
319
318
|
private readonly mcpServersConfig?: MCPEndpointConfig[];
|
|
@@ -362,7 +361,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
362
361
|
params?.delegateAgentProcessingToServiceAdapter || false;
|
|
363
362
|
this.observability = params?.observability_c;
|
|
364
363
|
this.agents = params?.agents ?? {};
|
|
365
|
-
this.
|
|
364
|
+
this.onError = params?.onError;
|
|
366
365
|
// +++ MCP Initialization +++
|
|
367
366
|
this.mcpServersConfig = params?.mcpServers;
|
|
368
367
|
this.createMCPClientImpl = params?.createMCPClient;
|
|
@@ -495,8 +494,8 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
495
494
|
// For storing streamed chunks if progressive logging is enabled
|
|
496
495
|
const streamedChunks: any[] = [];
|
|
497
496
|
|
|
498
|
-
//
|
|
499
|
-
await this.
|
|
497
|
+
// Track request start
|
|
498
|
+
await this.error(
|
|
500
499
|
"request",
|
|
501
500
|
{
|
|
502
501
|
threadId,
|
|
@@ -755,8 +754,8 @@ please use an LLM adapter instead.`,
|
|
|
755
754
|
);
|
|
756
755
|
}
|
|
757
756
|
|
|
758
|
-
//
|
|
759
|
-
await this.
|
|
757
|
+
// Track the error
|
|
758
|
+
await this.error(
|
|
760
759
|
"error",
|
|
761
760
|
{
|
|
762
761
|
threadId,
|
|
@@ -1041,8 +1040,8 @@ please use an LLM adapter instead.`,
|
|
|
1041
1040
|
// for backwards compatibility, deal with the case when no threadId is provided
|
|
1042
1041
|
const threadId = threadIdFromRequest ?? agentSession.threadId;
|
|
1043
1042
|
|
|
1044
|
-
//
|
|
1045
|
-
await this.
|
|
1043
|
+
// Track agent request start
|
|
1044
|
+
await this.error(
|
|
1046
1045
|
"agent_state",
|
|
1047
1046
|
{
|
|
1048
1047
|
threadId,
|
|
@@ -1222,8 +1221,8 @@ please use an LLM adapter instead.`,
|
|
|
1222
1221
|
this.convertStreamingErrorToStructured(error),
|
|
1223
1222
|
);
|
|
1224
1223
|
|
|
1225
|
-
//
|
|
1226
|
-
await this.
|
|
1224
|
+
// Track streaming errors
|
|
1225
|
+
await this.error(
|
|
1227
1226
|
"error",
|
|
1228
1227
|
{
|
|
1229
1228
|
threadId,
|
|
@@ -1332,8 +1331,8 @@ please use an LLM adapter instead.`,
|
|
|
1332
1331
|
this.convertStreamingErrorToStructured(err),
|
|
1333
1332
|
);
|
|
1334
1333
|
|
|
1335
|
-
//
|
|
1336
|
-
await this.
|
|
1334
|
+
// Track the agent error
|
|
1335
|
+
await this.error(
|
|
1337
1336
|
"error",
|
|
1338
1337
|
{
|
|
1339
1338
|
threadId,
|
|
@@ -1392,6 +1391,7 @@ please use an LLM adapter instead.`,
|
|
|
1392
1391
|
frontendUrl: url,
|
|
1393
1392
|
agents: this.agents,
|
|
1394
1393
|
metaEvents: request.metaEvents,
|
|
1394
|
+
nodeName: request.agentSession?.nodeName,
|
|
1395
1395
|
});
|
|
1396
1396
|
|
|
1397
1397
|
const configuredActions =
|
|
@@ -1505,45 +1505,45 @@ please use an LLM adapter instead.`,
|
|
|
1505
1505
|
});
|
|
1506
1506
|
}
|
|
1507
1507
|
|
|
1508
|
-
private async
|
|
1509
|
-
type:
|
|
1508
|
+
private async error(
|
|
1509
|
+
type: CopilotErrorEvent["type"],
|
|
1510
1510
|
context: CopilotRequestContext,
|
|
1511
1511
|
error?: any,
|
|
1512
1512
|
publicApiKey?: string,
|
|
1513
1513
|
): Promise<void> {
|
|
1514
|
-
if (!this.
|
|
1514
|
+
if (!this.onError) return;
|
|
1515
1515
|
|
|
1516
1516
|
// Just check if publicApiKey is defined (regardless of validity)
|
|
1517
1517
|
if (!publicApiKey) {
|
|
1518
|
-
if (!this.
|
|
1518
|
+
if (!this.hasWarnedAboutError) {
|
|
1519
1519
|
console.warn(
|
|
1520
|
-
"CopilotKit:
|
|
1520
|
+
"CopilotKit: onError handler provided but requires publicApiKey to be defined for error handling to work.",
|
|
1521
1521
|
);
|
|
1522
|
-
this.
|
|
1522
|
+
this.hasWarnedAboutError = true;
|
|
1523
1523
|
}
|
|
1524
1524
|
return;
|
|
1525
1525
|
}
|
|
1526
1526
|
|
|
1527
1527
|
try {
|
|
1528
|
-
const
|
|
1528
|
+
const errorEvent: CopilotErrorEvent = {
|
|
1529
1529
|
type,
|
|
1530
1530
|
timestamp: Date.now(),
|
|
1531
1531
|
context,
|
|
1532
1532
|
...(error && { error }),
|
|
1533
1533
|
};
|
|
1534
1534
|
|
|
1535
|
-
await this.
|
|
1536
|
-
} catch (
|
|
1537
|
-
// Don't let
|
|
1538
|
-
console.error("Error in
|
|
1535
|
+
await this.onError(errorEvent);
|
|
1536
|
+
} catch (errorHandlerError) {
|
|
1537
|
+
// Don't let error handler errors break the main flow
|
|
1538
|
+
console.error("Error in onError handler:", errorHandlerError);
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
|
|
1542
1542
|
/**
|
|
1543
|
-
* Public method to
|
|
1544
|
-
* This allows the GraphQL resolver to send validation errors through the
|
|
1543
|
+
* Public method to handle GraphQL validation errors
|
|
1544
|
+
* This allows the GraphQL resolver to send validation errors through the error system
|
|
1545
1545
|
*/
|
|
1546
|
-
public async
|
|
1546
|
+
public async errorGraphQLError(
|
|
1547
1547
|
error: { message: string; code: string; type: string },
|
|
1548
1548
|
context: {
|
|
1549
1549
|
operation: string;
|
|
@@ -1551,10 +1551,10 @@ please use an LLM adapter instead.`,
|
|
|
1551
1551
|
guardrailsEnabled: boolean;
|
|
1552
1552
|
},
|
|
1553
1553
|
): Promise<void> {
|
|
1554
|
-
if (!this.
|
|
1554
|
+
if (!this.onError) return;
|
|
1555
1555
|
|
|
1556
1556
|
try {
|
|
1557
|
-
await this.
|
|
1557
|
+
await this.onError({
|
|
1558
1558
|
type: "error",
|
|
1559
1559
|
timestamp: Date.now(),
|
|
1560
1560
|
context: {
|
|
@@ -1574,9 +1574,9 @@ please use an LLM adapter instead.`,
|
|
|
1574
1574
|
},
|
|
1575
1575
|
error,
|
|
1576
1576
|
});
|
|
1577
|
-
} catch (
|
|
1578
|
-
// Don't let
|
|
1579
|
-
console.error("Error in
|
|
1577
|
+
} catch (errorHandlerError) {
|
|
1578
|
+
// Don't let error handler errors break the main flow
|
|
1579
|
+
console.error("Error in onError handler:", errorHandlerError);
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
@@ -131,6 +131,7 @@ export async function setupRemoteActions({
|
|
|
131
131
|
frontendUrl,
|
|
132
132
|
agents,
|
|
133
133
|
metaEvents,
|
|
134
|
+
nodeName,
|
|
134
135
|
}: {
|
|
135
136
|
remoteEndpointDefinitions: EndpointDefinition[];
|
|
136
137
|
graphqlContext: GraphQLContext;
|
|
@@ -139,6 +140,7 @@ export async function setupRemoteActions({
|
|
|
139
140
|
frontendUrl?: string;
|
|
140
141
|
agents: Record<string, AbstractAgent>;
|
|
141
142
|
metaEvents?: MetaEventInput[];
|
|
143
|
+
nodeName?: string;
|
|
142
144
|
}): Promise<Action[]> {
|
|
143
145
|
const logger = graphqlContext.logger.child({ component: "remote-actions.fetchRemoteActions" });
|
|
144
146
|
logger.debug({ remoteEndpointDefinitions }, "Fetching from remote endpoints");
|
|
@@ -207,6 +209,7 @@ export async function setupRemoteActions({
|
|
|
207
209
|
agent: agent,
|
|
208
210
|
metaEvents,
|
|
209
211
|
threadMetadata,
|
|
212
|
+
nodeName,
|
|
210
213
|
}),
|
|
211
214
|
);
|
|
212
215
|
}
|