@copilotkit/runtime 1.5.14 → 1.5.15-next.1

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 (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{chunk-EKESUZN7.mjs → chunk-2CH7MDMH.mjs} +2 -2
  3. package/dist/{chunk-CBI52XPL.mjs → chunk-3QMRQQKK.mjs} +9 -5
  4. package/dist/chunk-3QMRQQKK.mjs.map +1 -0
  5. package/dist/{chunk-NKTCGE5C.mjs → chunk-5KOKNRAO.mjs} +2 -2
  6. package/dist/{chunk-H3A6C24Z.mjs → chunk-DATHT2T2.mjs} +2 -2
  7. package/dist/{copilot-runtime-8c442d65.d.ts → copilot-runtime-628cc60c.d.ts} +3 -12
  8. package/dist/{groq-adapter-7a82cd22.d.ts → groq-adapter-acb6ed0b.d.ts} +1 -1
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +8 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +4 -4
  13. package/dist/{langserve-e308c437.d.ts → langserve-9614171f.d.ts} +14 -1
  14. package/dist/lib/index.d.ts +3 -3
  15. package/dist/lib/index.js +8 -4
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/index.mjs +4 -4
  18. package/dist/lib/integrations/index.d.ts +3 -3
  19. package/dist/lib/integrations/index.js +1 -1
  20. package/dist/lib/integrations/index.js.map +1 -1
  21. package/dist/lib/integrations/index.mjs +4 -4
  22. package/dist/lib/integrations/nest/index.d.ts +2 -2
  23. package/dist/lib/integrations/nest/index.js +1 -1
  24. package/dist/lib/integrations/nest/index.js.map +1 -1
  25. package/dist/lib/integrations/nest/index.mjs +2 -2
  26. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  27. package/dist/lib/integrations/node-express/index.js +1 -1
  28. package/dist/lib/integrations/node-express/index.js.map +1 -1
  29. package/dist/lib/integrations/node-express/index.mjs +2 -2
  30. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  31. package/dist/lib/integrations/node-http/index.js +1 -1
  32. package/dist/lib/integrations/node-http/index.js.map +1 -1
  33. package/dist/lib/integrations/node-http/index.mjs +1 -1
  34. package/dist/service-adapters/index.d.ts +3 -3
  35. package/package.json +2 -2
  36. package/src/lib/runtime/copilot-runtime.ts +16 -3
  37. package/src/service-adapters/service-adapter.ts +4 -0
  38. package/dist/chunk-CBI52XPL.mjs.map +0 -1
  39. /package/dist/{chunk-EKESUZN7.mjs.map → chunk-2CH7MDMH.mjs.map} +0 -0
  40. /package/dist/{chunk-NKTCGE5C.mjs.map → chunk-5KOKNRAO.mjs.map} +0 -0
  41. /package/dist/{chunk-H3A6C24Z.mjs.map → chunk-DATHT2T2.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-CBI52XPL.mjs";
3
+ } from "../../../chunk-3QMRQQKK.mjs";
4
4
  import "../../../chunk-S3KKBII4.mjs";
5
5
  import "../../../chunk-U3V2BCGI.mjs";
6
6
  import "../../../chunk-HNUNXFTW.mjs";
@@ -1,6 +1,6 @@
1
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-e308c437.js';
2
- export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-e308c437.js';
3
- export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-7a82cd22.js';
1
+ import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-9614171f.js';
2
+ export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-9614171f.js';
3
+ export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-acb6ed0b.js';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
5
  import '../index-a7f37670.js';
6
6
  import '../graphql/types/base/index.js';
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.5.14",
12
+ "version": "1.5.15-next.1",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -58,7 +58,7 @@
58
58
  "rxjs": "^7.8.1",
59
59
  "type-graphql": "2.0.0-rc.1",
60
60
  "zod": "^3.23.3",
61
- "@copilotkit/shared": "1.5.14"
61
+ "@copilotkit/shared": "1.5.15-next.1"
62
62
  },
63
63
  "keywords": [
64
64
  "copilotkit",
@@ -169,6 +169,14 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
169
169
  * An array of LangServer URLs.
170
170
  */
171
171
  langserve?: RemoteChainParameters[];
172
+
173
+ /*
174
+ * Delegates agent state processing to the service adapter.
175
+ *
176
+ * When enabled, individual agent state requests will not be processed by the agent itself.
177
+ * Instead, all processing will be handled by the service adapter.
178
+ */
179
+ delegateAgentProcessingToServiceAdapter?: boolean;
172
180
  }
173
181
 
174
182
  export class CopilotRuntime<const T extends Parameter[] | [] = []> {
@@ -177,6 +185,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
177
185
  private langserve: Promise<Action<any>>[] = [];
178
186
  private onBeforeRequest?: OnBeforeRequestHandler;
179
187
  private onAfterRequest?: OnAfterRequestHandler;
188
+ private delegateAgentProcessingToServiceAdapter: boolean;
180
189
 
181
190
  constructor(params?: CopilotRuntimeConstructorParams<T>) {
182
191
  this.actions = params?.actions || [];
@@ -190,6 +199,8 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
190
199
 
191
200
  this.onBeforeRequest = params?.middleware?.onBeforeRequest;
192
201
  this.onAfterRequest = params?.middleware?.onAfterRequest;
202
+ this.delegateAgentProcessingToServiceAdapter =
203
+ params?.delegateAgentProcessingToServiceAdapter || false;
193
204
  }
194
205
 
195
206
  async processRuntimeRequest(request: CopilotRuntimeRequest): Promise<CopilotRuntimeResponse> {
@@ -202,15 +213,16 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
202
213
  outputMessagesPromise,
203
214
  graphqlContext,
204
215
  forwardedParameters,
205
- agentSession,
206
216
  url,
207
217
  extensions,
218
+ agentSession,
219
+ agentStates,
208
220
  } = request;
209
221
 
210
222
  const eventSource = new RuntimeEventSource();
211
223
 
212
224
  try {
213
- if (agentSession) {
225
+ if (agentSession && !this.delegateAgentProcessingToServiceAdapter) {
214
226
  return await this.processAgentRequest(request);
215
227
  }
216
228
  if (serviceAdapter instanceof EmptyAdapter) {
@@ -222,7 +234,6 @@ please use an LLM adapter instead.`,
222
234
  }
223
235
 
224
236
  const messages = rawMessages.filter((message) => !message.agentStateMessage);
225
-
226
237
  const inputMessages = convertGqlInputToMessages(messages);
227
238
  const serverSideActions = await this.getServerSideActions(request);
228
239
 
@@ -256,6 +267,8 @@ please use an LLM adapter instead.`,
256
267
  eventSource,
257
268
  forwardedParameters,
258
269
  extensions,
270
+ agentSession,
271
+ agentStates,
259
272
  });
260
273
 
261
274
  // for backwards compatibility, we deal with the case that no threadId is provided
@@ -4,6 +4,8 @@ import { ActionInput } from "../graphql/inputs/action.input";
4
4
  import { ForwardedParametersInput } from "../graphql/inputs/forwarded-parameters.input";
5
5
  import { ExtensionsInput } from "../graphql/inputs/extensions.input";
6
6
  import { ExtensionsResponse } from "../graphql/types/extensions-response.type";
7
+ import { AgentSessionInput } from "../graphql/inputs/agent-session.input";
8
+ import { AgentStateInput } from "../graphql/inputs/agent-state.input";
7
9
 
8
10
  export interface CopilotKitResponse {
9
11
  stream: ReadableStream;
@@ -19,6 +21,8 @@ export interface CopilotRuntimeChatCompletionRequest {
19
21
  runId?: string;
20
22
  forwardedParameters?: ForwardedParametersInput;
21
23
  extensions?: ExtensionsInput;
24
+ agentSession?: AgentSessionInput;
25
+ agentStates?: AgentStateInput[];
22
26
  }
23
27
 
24
28
  export interface CopilotRuntimeChatCompletionResponse {