@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/dist/{chunk-Z5GYTKMD.mjs → chunk-EK5RTZVJ.mjs} +225 -149
  3. package/dist/chunk-EK5RTZVJ.mjs.map +1 -0
  4. package/dist/{chunk-SMDVD4VG.mjs → chunk-KCYFFRJY.mjs} +2 -2
  5. package/dist/{chunk-4JBKY7XT.mjs → chunk-QLLV2QVK.mjs} +48 -28
  6. package/dist/chunk-QLLV2QVK.mjs.map +1 -0
  7. package/dist/{chunk-5YGKE5SN.mjs → chunk-R5D7D7YN.mjs} +2 -2
  8. package/dist/{chunk-UUXRYAB4.mjs → chunk-RCCT2GOF.mjs} +2 -2
  9. package/dist/{chunk-ALZ5H3VD.mjs → chunk-YGS5B7PN.mjs} +2 -2
  10. package/dist/{groq-adapter-172a2ca4.d.ts → groq-adapter-742818f2.d.ts} +5 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +267 -171
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +9 -9
  15. package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
  16. package/dist/lib/index.d.ts +155 -5
  17. package/dist/lib/index.js +221 -168
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/index.mjs +9 -9
  20. package/dist/lib/integrations/index.d.ts +3 -3
  21. package/dist/lib/integrations/index.js +11 -11
  22. package/dist/lib/integrations/index.js.map +1 -1
  23. package/dist/lib/integrations/index.mjs +8 -8
  24. package/dist/lib/integrations/nest/index.d.ts +2 -2
  25. package/dist/lib/integrations/nest/index.js +11 -11
  26. package/dist/lib/integrations/nest/index.js.map +1 -1
  27. package/dist/lib/integrations/nest/index.mjs +4 -4
  28. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  29. package/dist/lib/integrations/node-express/index.js +11 -11
  30. package/dist/lib/integrations/node-express/index.js.map +1 -1
  31. package/dist/lib/integrations/node-express/index.mjs +4 -4
  32. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  33. package/dist/lib/integrations/node-http/index.js +11 -11
  34. package/dist/lib/integrations/node-http/index.js.map +1 -1
  35. package/dist/lib/integrations/node-http/index.mjs +3 -3
  36. package/dist/service-adapters/index.d.ts +5 -4
  37. package/dist/service-adapters/index.js +47 -27
  38. package/dist/service-adapters/index.js.map +1 -1
  39. package/dist/service-adapters/index.mjs +1 -1
  40. package/dist/{shared-bd953ebf.d.ts → shared-96b46379.d.ts} +16 -18
  41. package/package.json +11 -11
  42. package/src/graphql/resolvers/copilot.resolver.ts +1 -2
  43. package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts} +27 -27
  44. package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +464 -0
  45. package/src/lib/runtime/agui-action.ts +9 -3
  46. package/src/lib/runtime/copilot-runtime.ts +112 -124
  47. package/src/lib/runtime/mcp-tools-utils.ts +84 -18
  48. package/src/lib/runtime/remote-actions.ts +6 -0
  49. package/src/service-adapters/anthropic/anthropic-adapter.ts +64 -4
  50. package/src/service-adapters/anthropic/utils.ts +3 -8
  51. package/src/service-adapters/events.ts +40 -1
  52. package/src/service-adapters/google/google-genai-adapter.ts +5 -0
  53. package/src/service-adapters/openai/openai-adapter.ts +0 -14
  54. package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +172 -387
  55. package/dist/chunk-4JBKY7XT.mjs.map +0 -1
  56. package/dist/chunk-Z5GYTKMD.mjs.map +0 -1
  57. /package/dist/{chunk-SMDVD4VG.mjs.map → chunk-KCYFFRJY.mjs.map} +0 -0
  58. /package/dist/{chunk-5YGKE5SN.mjs.map → chunk-R5D7D7YN.mjs.map} +0 -0
  59. /package/dist/{chunk-UUXRYAB4.mjs.map → chunk-RCCT2GOF.mjs.map} +0 -0
  60. /package/dist/{chunk-ALZ5H3VD.mjs.map → chunk-YGS5B7PN.mjs.map} +0 -0
@@ -11,7 +11,7 @@ import {
11
11
  OpenAIAssistantAdapter,
12
12
  RemoteChain,
13
13
  UnifyAdapter
14
- } from "../chunk-4JBKY7XT.mjs";
14
+ } from "../chunk-QLLV2QVK.mjs";
15
15
  import {
16
16
  convertServiceAdapterError
17
17
  } from "../chunk-AMUJQ6IR.mjs";
@@ -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, CopilotTraceHandler } 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-fc5cac89.js';
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(options: {
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 trace handler for comprehensive debugging and observability.
341
+ * Optional error handler for comprehensive debugging and observability.
344
342
  *
345
- * **Requires publicApiKey**: Tracing only works when requests include a valid 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 traceEvent - Structured trace event with rich debugging context
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
- * onTrace: (traceEvent) => {
354
- * debugDashboard.capture(traceEvent);
351
+ * onError: (errorEvent) => {
352
+ * debugDashboard.capture(errorEvent);
355
353
  * }
356
354
  * });
357
355
  * ```
358
356
  */
359
- onTrace?: CopilotTraceHandler;
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 onTrace?;
372
- private hasWarnedAboutTracing;
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(): Promise<AgentWithEndpoint[]>;
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 trace;
385
+ private error;
388
386
  /**
389
- * Public method to trace GraphQL validation errors
390
- * This allows the GraphQL resolver to send validation errors through the trace system
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
- traceGraphQLError(error: {
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.2-next.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.28",
41
- "@ag-ui/core": "0.0.28",
42
- "@ag-ui/encoder": "0.0.28",
43
- "@ag-ui/langgraph": "0.0.4",
44
- "@ag-ui/proto": "0.0.28",
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.2-next.9"
69
+ "@copilotkit/shared": "1.9.3-next.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@ag-ui/client": ">=0.0.28",
73
- "@ag-ui/core": ">=0.0.28",
74
- "@ag-ui/encoder": ">=0.0.28",
75
- "@ag-ui/proto": ">=0.0.28"
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
- // Trace the validation error for debugging visibility
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",
@@ -1,8 +1,8 @@
1
- import { CopilotTraceEvent, CopilotRequestContext, CopilotTraceHandler } from "@copilotkit/shared";
1
+ import { CopilotErrorEvent, CopilotRequestContext, CopilotErrorHandler } from "@copilotkit/shared";
2
2
 
3
- describe("CopilotRuntime onTrace types", () => {
3
+ describe("CopilotRuntime onError types", () => {
4
4
  it("should have correct CopilotTraceEvent type structure", () => {
5
- const traceEvent: CopilotTraceEvent = {
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(traceEvent.type).toBe("error");
22
- expect(traceEvent.timestamp).toBeGreaterThan(0);
23
- expect(traceEvent.context.threadId).toBe("test-123");
24
- expect(traceEvent.error).toBeInstanceOf(Error);
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 trace event types", () => {
80
- const eventTypes: CopilotTraceEvent["type"][] = [
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: CopilotTraceEvent = {
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 ShouldTrace = (onTrace?: CopilotTraceHandler, publicApiKey?: string) => boolean;
111
+ type ShouldHandleError = (onError?: CopilotErrorHandler, publicApiKey?: string) => boolean;
112
112
 
113
- const shouldTrace: ShouldTrace = (onTrace, publicApiKey) => {
114
- return Boolean(onTrace && publicApiKey);
113
+ const shouldHandleError: ShouldHandleError = (onError, publicApiKey) => {
114
+ return Boolean(onError && publicApiKey);
115
115
  };
116
116
 
117
- it("should return true when both onTrace and publicApiKey are provided", () => {
118
- const onTrace = jest.fn();
119
- const result = shouldTrace(onTrace, "valid-api-key");
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 onTrace is missing", () => {
124
- const result = shouldTrace(undefined, "valid-api-key");
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 onTrace = jest.fn();
130
- const result = shouldTrace(onTrace, undefined);
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 onTrace = jest.fn();
136
- const result = shouldTrace(onTrace, "");
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 = shouldTrace(undefined, undefined);
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 tracing when onTrace is present
164
- const onTrace = jest.fn();
165
- expect(shouldTrace(onTrace, cloudKey)).toBe(true);
166
- expect(shouldTrace(onTrace, nonCloudKey)).toBe(true);
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
  });