@copilotkit/runtime 1.9.2-next.23 → 1.9.2-next.25
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-ZQUGWRVU.mjs → chunk-3JXN25PL.mjs} +2 -2
- package/dist/{chunk-LYXJJDV3.mjs → chunk-BNLL5CH2.mjs} +2 -2
- package/dist/{chunk-C6PCDSTD.mjs → chunk-DOXGUQKL.mjs} +2 -2
- package/dist/{chunk-HZW6X63M.mjs → chunk-GJWXNXSA.mjs} +2 -2
- package/dist/{chunk-FIA5HRU2.mjs → chunk-YKYBGYYL.mjs} +81 -35
- package/dist/chunk-YKYBGYYL.mjs.map +1 -0
- 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 +80 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- 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 +80 -34
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +10 -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 -2
- package/dist/lib/integrations/nest/index.js +10 -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 -2
- package/dist/lib/integrations/node-express/index.js +10 -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 -2
- package/dist/lib/integrations/node-http/index.js +10 -10
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/{shared-6b6dbf8b.d.ts → shared-96b46379.d.ts} +1 -1
- package/package.json +11 -11
- package/src/lib/runtime/copilot-runtime.ts +32 -19
- package/src/service-adapters/events.ts +40 -1
- package/dist/chunk-FIA5HRU2.mjs.map +0 -1
- /package/dist/{chunk-ZQUGWRVU.mjs.map → chunk-3JXN25PL.mjs.map} +0 -0
- /package/dist/{chunk-LYXJJDV3.mjs.map → chunk-BNLL5CH2.mjs.map} +0 -0
- /package/dist/{chunk-C6PCDSTD.mjs.map → chunk-DOXGUQKL.mjs.map} +0 -0
- /package/dist/{chunk-HZW6X63M.mjs.map → chunk-GJWXNXSA.mjs.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-
|
|
2
|
-
export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-
|
|
1
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-3e8d0e06.js';
|
|
2
|
+
export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-3e8d0e06.js';
|
|
3
3
|
export { convertServiceAdapterError } from './shared/index.js';
|
|
4
|
-
import { L as LangChainAdapter } from '../groq-adapter-
|
|
5
|
-
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-
|
|
4
|
+
import { L as LangChainAdapter } from '../groq-adapter-742818f2.js';
|
|
5
|
+
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-742818f2.js';
|
|
6
6
|
import Anthropic from '@anthropic-ai/sdk';
|
|
7
7
|
import '../index-d4614f9b.js';
|
|
8
8
|
import '../graphql/types/base/index.js';
|
|
@@ -3,7 +3,7 @@ import * as createPinoLogger from 'pino';
|
|
|
3
3
|
import createPinoLogger__default from 'pino';
|
|
4
4
|
import { YogaInitialContext, createYoga } from 'graphql-yoga';
|
|
5
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-
|
|
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';
|
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.25",
|
|
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.34",
|
|
41
|
+
"@ag-ui/core": "0.0.34",
|
|
42
|
+
"@ag-ui/encoder": "0.0.34",
|
|
43
|
+
"@ag-ui/langgraph": "0.0.6",
|
|
44
|
+
"@ag-ui/proto": "0.0.34",
|
|
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.
|
|
69
|
+
"@copilotkit/shared": "1.9.2-next.25"
|
|
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",
|
|
@@ -486,16 +486,11 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
486
486
|
publicApiKey,
|
|
487
487
|
} = request;
|
|
488
488
|
|
|
489
|
-
const eventSource = new RuntimeEventSource(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
// Track request start
|
|
496
|
-
await this.error(
|
|
497
|
-
"request",
|
|
498
|
-
{
|
|
489
|
+
const eventSource = new RuntimeEventSource({
|
|
490
|
+
errorHandler: async (error, context) => {
|
|
491
|
+
await this.error("error", context, error, publicApiKey);
|
|
492
|
+
},
|
|
493
|
+
errorContext: {
|
|
499
494
|
threadId,
|
|
500
495
|
runId,
|
|
501
496
|
source: "runtime",
|
|
@@ -503,20 +498,18 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
503
498
|
operation: "processRuntimeRequest",
|
|
504
499
|
method: "POST",
|
|
505
500
|
url: url,
|
|
506
|
-
startTime:
|
|
501
|
+
startTime: Date.now(),
|
|
507
502
|
},
|
|
508
503
|
agent: agentSession ? { name: agentSession.agentName } : undefined,
|
|
509
|
-
messages: {
|
|
510
|
-
input: rawMessages,
|
|
511
|
-
messageCount: rawMessages.length,
|
|
512
|
-
},
|
|
513
504
|
technical: {
|
|
514
505
|
environment: process.env.NODE_ENV,
|
|
515
506
|
},
|
|
516
507
|
},
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
);
|
|
508
|
+
});
|
|
509
|
+
// Track request start time for logging
|
|
510
|
+
const requestStartTime = Date.now();
|
|
511
|
+
// For storing streamed chunks if progressive logging is enabled
|
|
512
|
+
const streamedChunks: any[] = [];
|
|
520
513
|
|
|
521
514
|
try {
|
|
522
515
|
if (
|
|
@@ -1129,7 +1122,27 @@ please use an LLM adapter instead.`,
|
|
|
1129
1122
|
});
|
|
1130
1123
|
|
|
1131
1124
|
try {
|
|
1132
|
-
const eventSource = new RuntimeEventSource(
|
|
1125
|
+
const eventSource = new RuntimeEventSource({
|
|
1126
|
+
errorHandler: async (error, context) => {
|
|
1127
|
+
await this.error("error", context, error, publicApiKey);
|
|
1128
|
+
},
|
|
1129
|
+
errorContext: {
|
|
1130
|
+
threadId,
|
|
1131
|
+
source: "agent",
|
|
1132
|
+
request: {
|
|
1133
|
+
operation: "processAgentRequest",
|
|
1134
|
+
method: "POST",
|
|
1135
|
+
startTime: requestStartTime,
|
|
1136
|
+
},
|
|
1137
|
+
agent: {
|
|
1138
|
+
name: agentName,
|
|
1139
|
+
nodeName: nodeName,
|
|
1140
|
+
},
|
|
1141
|
+
technical: {
|
|
1142
|
+
environment: process.env.NODE_ENV,
|
|
1143
|
+
},
|
|
1144
|
+
},
|
|
1145
|
+
});
|
|
1133
1146
|
const stream = await currentAgent.remoteAgentHandler({
|
|
1134
1147
|
name: agentName,
|
|
1135
1148
|
threadId,
|
|
@@ -240,6 +240,16 @@ export class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
|
|
|
240
240
|
export class RuntimeEventSource {
|
|
241
241
|
private eventStream$ = new RuntimeEventSubject();
|
|
242
242
|
private callback!: EventSourceCallback;
|
|
243
|
+
private errorHandler?: (error: any, context: any) => Promise<void>;
|
|
244
|
+
private errorContext?: any;
|
|
245
|
+
|
|
246
|
+
constructor(params?: {
|
|
247
|
+
errorHandler?: (error: any, context: any) => Promise<void>;
|
|
248
|
+
errorContext?: any;
|
|
249
|
+
}) {
|
|
250
|
+
this.errorHandler = params?.errorHandler;
|
|
251
|
+
this.errorContext = params?.errorContext;
|
|
252
|
+
}
|
|
243
253
|
|
|
244
254
|
async stream(callback: EventSourceCallback): Promise<void> {
|
|
245
255
|
this.callback = callback;
|
|
@@ -267,9 +277,19 @@ export class RuntimeEventSource {
|
|
|
267
277
|
actionInputsWithoutAgents: ActionInput[];
|
|
268
278
|
threadId: string;
|
|
269
279
|
}) {
|
|
270
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
280
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
271
281
|
// Convert streaming errors to structured errors, but preserve already structured ones
|
|
272
282
|
const structuredError = ensureStructuredError(error, convertStreamingErrorToStructured);
|
|
283
|
+
|
|
284
|
+
// Call the runtime error handler if provided
|
|
285
|
+
if (this.errorHandler && this.errorContext) {
|
|
286
|
+
try {
|
|
287
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
288
|
+
} catch (errorHandlerError) {
|
|
289
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
273
293
|
this.eventStream$.error(structuredError);
|
|
274
294
|
this.eventStream$.complete();
|
|
275
295
|
});
|
|
@@ -333,6 +353,25 @@ export class RuntimeEventSource {
|
|
|
333
353
|
error,
|
|
334
354
|
convertStreamingErrorToStructured,
|
|
335
355
|
);
|
|
356
|
+
|
|
357
|
+
// Call the runtime error handler if provided
|
|
358
|
+
if (this.errorHandler && this.errorContext) {
|
|
359
|
+
// Use from() to handle async error handler
|
|
360
|
+
from(
|
|
361
|
+
this.errorHandler(structuredError, {
|
|
362
|
+
...this.errorContext,
|
|
363
|
+
action: {
|
|
364
|
+
name: eventWithState.action!.name,
|
|
365
|
+
executionId: eventWithState.actionExecutionId,
|
|
366
|
+
},
|
|
367
|
+
}),
|
|
368
|
+
).subscribe({
|
|
369
|
+
error: (errorHandlerError) => {
|
|
370
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
336
375
|
toolCallEventStream$.sendActionExecutionResult({
|
|
337
376
|
actionExecutionId: eventWithState.actionExecutionId!,
|
|
338
377
|
actionName: eventWithState.action!.name,
|