@copilotkit/runtime 1.10.5-next.1 → 1.10.5-next.2
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 +7 -0
- package/dist/{chunk-T4NLPBCY.mjs → chunk-AJIPGTPV.mjs} +2 -2
- package/dist/{chunk-C56AVUZI.mjs → chunk-AK5H4K5T.mjs} +2 -2
- package/dist/{chunk-FOXQPOXW.mjs → chunk-G3STE4EL.mjs} +21 -2
- package/dist/chunk-G3STE4EL.mjs.map +1 -0
- package/dist/{chunk-H6QUY5ZQ.mjs → chunk-H5ZYJ27F.mjs} +2 -2
- package/dist/{chunk-CX4GADTM.mjs → chunk-IONJJRU6.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -1
- 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 +20 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/{shared-35015e40.d.ts → shared-0a7346ce.d.ts} +10 -0
- package/package.json +2 -2
- package/src/lib/runtime/agui-action.ts +7 -0
- package/src/lib/runtime/copilot-runtime.ts +25 -0
- package/dist/chunk-FOXQPOXW.mjs.map +0 -1
- /package/dist/{chunk-T4NLPBCY.mjs.map → chunk-AJIPGTPV.mjs.map} +0 -0
- /package/dist/{chunk-C56AVUZI.mjs.map → chunk-AK5H4K5T.mjs.map} +0 -0
- /package/dist/{chunk-H6QUY5ZQ.mjs.map → chunk-H5ZYJ27F.mjs.map} +0 -0
- /package/dist/{chunk-CX4GADTM.mjs.map → chunk-IONJJRU6.mjs.map} +0 -0
|
@@ -246,6 +246,14 @@ interface OnAfterRequestOptions {
|
|
|
246
246
|
url?: string;
|
|
247
247
|
}
|
|
248
248
|
type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
|
|
249
|
+
interface OnStopGenerationOptions {
|
|
250
|
+
threadId: string;
|
|
251
|
+
runId?: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
agentName?: string;
|
|
254
|
+
lastMessage: MessageInput;
|
|
255
|
+
}
|
|
256
|
+
type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
|
|
249
257
|
interface Middleware {
|
|
250
258
|
/**
|
|
251
259
|
* A function that is called before the request is processed.
|
|
@@ -362,6 +370,7 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
|
362
370
|
* ```
|
|
363
371
|
*/
|
|
364
372
|
onError?: CopilotErrorHandler;
|
|
373
|
+
onStopGeneration?: OnStopGenerationHandler;
|
|
365
374
|
}
|
|
366
375
|
declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
367
376
|
actions: ActionsConfiguration<T>;
|
|
@@ -370,6 +379,7 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
370
379
|
private langserve;
|
|
371
380
|
private onBeforeRequest?;
|
|
372
381
|
private onAfterRequest?;
|
|
382
|
+
private onStopGeneration?;
|
|
373
383
|
private delegateAgentProcessingToServiceAdapter;
|
|
374
384
|
private observability?;
|
|
375
385
|
private availableAgents;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.10.5-next.
|
|
12
|
+
"version": "1.10.5-next.2",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"rxjs": "7.8.1",
|
|
68
68
|
"type-graphql": "2.0.0-rc.1",
|
|
69
69
|
"zod": "^3.23.3",
|
|
70
|
-
"@copilotkit/shared": "1.10.5-next.
|
|
70
|
+
"@copilotkit/shared": "1.10.5-next.2"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@ag-ui/client": ">=0.0.37",
|
|
@@ -48,6 +48,13 @@ export function constructAGUIRemoteAction({
|
|
|
48
48
|
actionInputsWithoutAgents,
|
|
49
49
|
threadId,
|
|
50
50
|
}: RemoteAgentHandlerParams): Promise<Observable<RuntimeEvent>> => {
|
|
51
|
+
graphqlContext.request.signal.addEventListener(
|
|
52
|
+
"abort",
|
|
53
|
+
() => {
|
|
54
|
+
agent.abortRun();
|
|
55
|
+
},
|
|
56
|
+
{ once: true }, // optional: fire only once
|
|
57
|
+
);
|
|
51
58
|
logger.debug({ actionName: agent.agentId }, "Executing remote agent");
|
|
52
59
|
|
|
53
60
|
const agentWireMessages = convertMessagesToAGUIMessage(messages);
|
|
@@ -144,6 +144,15 @@ interface OnAfterRequestOptions {
|
|
|
144
144
|
|
|
145
145
|
type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
|
|
146
146
|
|
|
147
|
+
interface OnStopGenerationOptions {
|
|
148
|
+
threadId: string;
|
|
149
|
+
runId?: string;
|
|
150
|
+
url?: string;
|
|
151
|
+
agentName?: string;
|
|
152
|
+
lastMessage: MessageInput;
|
|
153
|
+
}
|
|
154
|
+
type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
|
|
155
|
+
|
|
147
156
|
interface Middleware {
|
|
148
157
|
/**
|
|
149
158
|
* A function that is called before the request is processed.
|
|
@@ -301,6 +310,8 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
|
|
|
301
310
|
* ```
|
|
302
311
|
*/
|
|
303
312
|
onError?: CopilotErrorHandler;
|
|
313
|
+
|
|
314
|
+
onStopGeneration?: OnStopGenerationHandler;
|
|
304
315
|
}
|
|
305
316
|
|
|
306
317
|
export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
@@ -310,6 +321,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
310
321
|
private langserve: Promise<Action<any>>[] = [];
|
|
311
322
|
private onBeforeRequest?: OnBeforeRequestHandler;
|
|
312
323
|
private onAfterRequest?: OnAfterRequestHandler;
|
|
324
|
+
private onStopGeneration?: OnStopGenerationHandler;
|
|
313
325
|
private delegateAgentProcessingToServiceAdapter: boolean;
|
|
314
326
|
private observability?: CopilotObservabilityConfig;
|
|
315
327
|
private availableAgents: Pick<AgentWithEndpoint, "name" | "id">[];
|
|
@@ -359,6 +371,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
359
371
|
|
|
360
372
|
this.onBeforeRequest = params?.middleware?.onBeforeRequest;
|
|
361
373
|
this.onAfterRequest = params?.middleware?.onAfterRequest;
|
|
374
|
+
this.onStopGeneration = params?.onStopGeneration;
|
|
362
375
|
this.delegateAgentProcessingToServiceAdapter =
|
|
363
376
|
params?.delegateAgentProcessingToServiceAdapter || false;
|
|
364
377
|
this.observability = params?.observability_c;
|
|
@@ -488,6 +501,18 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
488
501
|
publicApiKey,
|
|
489
502
|
context,
|
|
490
503
|
} = request;
|
|
504
|
+
graphqlContext.request.signal.addEventListener(
|
|
505
|
+
"abort",
|
|
506
|
+
() =>
|
|
507
|
+
this.onStopGeneration?.({
|
|
508
|
+
threadId,
|
|
509
|
+
runId,
|
|
510
|
+
url,
|
|
511
|
+
agentName: agentSession?.agentName,
|
|
512
|
+
lastMessage: rawMessages[rawMessages.length - 1],
|
|
513
|
+
}),
|
|
514
|
+
{ once: true }, // optional: fire only once
|
|
515
|
+
);
|
|
491
516
|
|
|
492
517
|
const eventSource = new RuntimeEventSource({
|
|
493
518
|
errorHandler: async (error, context) => {
|