@copilotkit/runtime 1.9.2-next.9 → 1.9.3-next.0
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 +176 -0
- package/dist/{chunk-Z5GYTKMD.mjs → chunk-EK5RTZVJ.mjs} +225 -149
- package/dist/chunk-EK5RTZVJ.mjs.map +1 -0
- package/dist/{chunk-SMDVD4VG.mjs → chunk-KCYFFRJY.mjs} +2 -2
- package/dist/{chunk-4JBKY7XT.mjs → chunk-QLLV2QVK.mjs} +48 -28
- package/dist/chunk-QLLV2QVK.mjs.map +1 -0
- package/dist/{chunk-5YGKE5SN.mjs → chunk-R5D7D7YN.mjs} +2 -2
- package/dist/{chunk-UUXRYAB4.mjs → chunk-RCCT2GOF.mjs} +2 -2
- package/dist/{chunk-ALZ5H3VD.mjs → chunk-YGS5B7PN.mjs} +2 -2
- package/dist/{groq-adapter-172a2ca4.d.ts → groq-adapter-742818f2.d.ts} +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +267 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
- package/dist/lib/index.d.ts +155 -5
- package/dist/lib/index.js +221 -168
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -9
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +11 -11
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +8 -8
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +11 -11
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +4 -4
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +11 -11
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +4 -4
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +11 -11
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +3 -3
- package/dist/service-adapters/index.d.ts +5 -4
- package/dist/service-adapters/index.js +47 -27
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/dist/{shared-bd953ebf.d.ts → shared-96b46379.d.ts} +16 -18
- package/package.json +11 -11
- 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/__tests__/mcp-tools-utils.test.ts +464 -0
- package/src/lib/runtime/agui-action.ts +9 -3
- package/src/lib/runtime/copilot-runtime.ts +112 -124
- package/src/lib/runtime/mcp-tools-utils.ts +84 -18
- package/src/lib/runtime/remote-actions.ts +6 -0
- package/src/service-adapters/anthropic/anthropic-adapter.ts +64 -4
- package/src/service-adapters/anthropic/utils.ts +3 -8
- package/src/service-adapters/events.ts +40 -1
- package/src/service-adapters/google/google-genai-adapter.ts +5 -0
- package/src/service-adapters/openai/openai-adapter.ts +0 -14
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +172 -387
- package/dist/chunk-4JBKY7XT.mjs.map +0 -1
- package/dist/chunk-Z5GYTKMD.mjs.map +0 -1
- /package/dist/{chunk-SMDVD4VG.mjs.map → chunk-KCYFFRJY.mjs.map} +0 -0
- /package/dist/{chunk-5YGKE5SN.mjs.map → chunk-R5D7D7YN.mjs.map} +0 -0
- /package/dist/{chunk-UUXRYAB4.mjs.map → chunk-RCCT2GOF.mjs.map} +0 -0
- /package/dist/{chunk-ALZ5H3VD.mjs.map → chunk-YGS5B7PN.mjs.map} +0 -0
|
@@ -2,8 +2,8 @@ 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,
|
|
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-
|
|
5
|
+
import { Parameter, Action, CopilotErrorHandler } from '@copilotkit/shared';
|
|
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-3e8d0e06.js';
|
|
7
7
|
import { M as MessageInput, a as Message } from './index-d4614f9b.js';
|
|
8
8
|
import { CopilotCloudOptions } from './lib/cloud/index.js';
|
|
9
9
|
import { AbstractAgent } from '@ag-ui/client';
|
|
@@ -142,9 +142,7 @@ interface MCPTool {
|
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
144
|
/** The function to call to execute the tool on the MCP server. */
|
|
145
|
-
execute(
|
|
146
|
-
params: any;
|
|
147
|
-
}): Promise<any>;
|
|
145
|
+
execute(params: any): Promise<any>;
|
|
148
146
|
}
|
|
149
147
|
/**
|
|
150
148
|
* Defines the contract for *any* MCP client implementation the user might provide.
|
|
@@ -340,23 +338,23 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
|
340
338
|
*/
|
|
341
339
|
createMCPClient?: CreateMCPClientFunction;
|
|
342
340
|
/**
|
|
343
|
-
* Optional
|
|
341
|
+
* Optional error handler for comprehensive debugging and observability.
|
|
344
342
|
*
|
|
345
|
-
* **Requires publicApiKey**:
|
|
343
|
+
* **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
|
|
346
344
|
* This is a premium CopilotKit Cloud feature.
|
|
347
345
|
*
|
|
348
|
-
* @param
|
|
346
|
+
* @param errorEvent - Structured error event with rich debugging context
|
|
349
347
|
*
|
|
350
348
|
* @example
|
|
351
349
|
* ```typescript
|
|
352
350
|
* const runtime = new CopilotRuntime({
|
|
353
|
-
*
|
|
354
|
-
* debugDashboard.capture(
|
|
351
|
+
* onError: (errorEvent) => {
|
|
352
|
+
* debugDashboard.capture(errorEvent);
|
|
355
353
|
* }
|
|
356
354
|
* });
|
|
357
355
|
* ```
|
|
358
356
|
*/
|
|
359
|
-
|
|
357
|
+
onError?: CopilotErrorHandler;
|
|
360
358
|
}
|
|
361
359
|
declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
362
360
|
actions: ActionsConfiguration<T>;
|
|
@@ -368,8 +366,8 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
368
366
|
private delegateAgentProcessingToServiceAdapter;
|
|
369
367
|
private observability?;
|
|
370
368
|
private availableAgents;
|
|
371
|
-
private
|
|
372
|
-
private
|
|
369
|
+
private onError?;
|
|
370
|
+
private hasWarnedAboutError;
|
|
373
371
|
private readonly mcpServersConfig?;
|
|
374
372
|
private mcpActionCache;
|
|
375
373
|
private readonly createMCPClientImpl?;
|
|
@@ -378,18 +376,18 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
378
376
|
processRuntimeRequest(request: CopilotRuntimeRequest): Promise<CopilotRuntimeResponse>;
|
|
379
377
|
getAllAgents(graphqlContext: GraphQLContext): Promise<(AgentWithEndpoint | Agent)[]>;
|
|
380
378
|
discoverAgentsFromEndpoints(graphqlContext: GraphQLContext): Promise<AgentWithEndpoint[]>;
|
|
381
|
-
discoverAgentsFromAgui():
|
|
379
|
+
discoverAgentsFromAgui(): Agent[];
|
|
382
380
|
loadAgentState(graphqlContext: GraphQLContext, threadId: string, agentName: string): Promise<LoadAgentStateResponse>;
|
|
383
381
|
private processAgentRequest;
|
|
384
382
|
private getServerSideActions;
|
|
385
383
|
private detectProvider;
|
|
386
384
|
private convertStreamingErrorToStructured;
|
|
387
|
-
private
|
|
385
|
+
private error;
|
|
388
386
|
/**
|
|
389
|
-
* Public method to
|
|
390
|
-
* This allows the GraphQL resolver to send validation errors through the
|
|
387
|
+
* Public method to handle GraphQL validation errors
|
|
388
|
+
* This allows the GraphQL resolver to send validation errors through the error system
|
|
391
389
|
*/
|
|
392
|
-
|
|
390
|
+
errorGraphQLError(error: {
|
|
393
391
|
message: string;
|
|
394
392
|
code: string;
|
|
395
393
|
type: string;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.9.
|
|
12
|
+
"version": "1.9.3-next.0",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"tsconfig": "1.4.6"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ag-ui/client": "0.0.
|
|
41
|
-
"@ag-ui/core": "0.0.
|
|
42
|
-
"@ag-ui/encoder": "0.0.
|
|
43
|
-
"@ag-ui/langgraph": "0.0.
|
|
44
|
-
"@ag-ui/proto": "0.0.
|
|
40
|
+
"@ag-ui/client": "0.0.35",
|
|
41
|
+
"@ag-ui/core": "0.0.35",
|
|
42
|
+
"@ag-ui/encoder": "0.0.35",
|
|
43
|
+
"@ag-ui/langgraph": "0.0.7",
|
|
44
|
+
"@ag-ui/proto": "0.0.35",
|
|
45
45
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
46
46
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
47
47
|
"@langchain/aws": "^0.1.9",
|
|
@@ -66,13 +66,13 @@
|
|
|
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.
|
|
69
|
+
"@copilotkit/shared": "1.9.3-next.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@ag-ui/client": ">=0.0.
|
|
73
|
-
"@ag-ui/core": ">=0.0.
|
|
74
|
-
"@ag-ui/encoder": ">=0.0.
|
|
75
|
-
"@ag-ui/proto": ">=0.0.
|
|
72
|
+
"@ag-ui/client": ">=0.0.34",
|
|
73
|
+
"@ag-ui/core": ">=0.0.34",
|
|
74
|
+
"@ag-ui/encoder": ">=0.0.34",
|
|
75
|
+
"@ag-ui/proto": ">=0.0.34"
|
|
76
76
|
},
|
|
77
77
|
"keywords": [
|
|
78
78
|
"copilotkit",
|
|
@@ -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
|
});
|