@copilotkit/runtime 1.5.12-next.5 → 1.5.12-next.7

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/__snapshots__/schema/schema.graphql +33 -0
  3. package/dist/{chunk-MFDRA3BJ.mjs → chunk-34276UUU.mjs} +652 -285
  4. package/dist/chunk-34276UUU.mjs.map +1 -0
  5. package/dist/{chunk-XRW7ZSWJ.mjs → chunk-DLESGNLO.mjs} +2 -2
  6. package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
  7. package/dist/chunk-S3KKBII4.mjs.map +1 -0
  8. package/dist/{chunk-QDMAQO2C.mjs → chunk-UBYSQI43.mjs} +2 -2
  9. package/dist/{chunk-NORCONUM.mjs → chunk-WTUPF3W3.mjs} +2 -2
  10. package/dist/{copilot-runtime-1a224a0f.d.ts → copilot-runtime-8c442d65.d.ts} +16 -3
  11. package/dist/graphql/types/converted/index.d.ts +1 -1
  12. package/dist/{groq-adapter-c35c5374.d.ts → groq-adapter-7a82cd22.d.ts} +21 -1
  13. package/dist/{index-24315d90.d.ts → index-a7f37670.d.ts} +1 -1
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +727 -348
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -5
  18. package/dist/{langserve-a16ef8f4.d.ts → langserve-e308c437.d.ts} +32 -3
  19. package/dist/lib/index.d.ts +4 -4
  20. package/dist/lib/index.js +725 -346
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/index.mjs +5 -5
  23. package/dist/lib/integrations/index.d.ts +4 -4
  24. package/dist/lib/integrations/index.js +504 -244
  25. package/dist/lib/integrations/index.js.map +1 -1
  26. package/dist/lib/integrations/index.mjs +5 -5
  27. package/dist/lib/integrations/nest/index.d.ts +3 -3
  28. package/dist/lib/integrations/nest/index.js +504 -244
  29. package/dist/lib/integrations/nest/index.js.map +1 -1
  30. package/dist/lib/integrations/nest/index.mjs +3 -3
  31. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  32. package/dist/lib/integrations/node-express/index.js +504 -244
  33. package/dist/lib/integrations/node-express/index.js.map +1 -1
  34. package/dist/lib/integrations/node-express/index.mjs +3 -3
  35. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  36. package/dist/lib/integrations/node-http/index.js +504 -244
  37. package/dist/lib/integrations/node-http/index.js.map +1 -1
  38. package/dist/lib/integrations/node-http/index.mjs +2 -2
  39. package/dist/service-adapters/index.d.ts +4 -4
  40. package/dist/service-adapters/index.js +23 -11
  41. package/dist/service-adapters/index.js.map +1 -1
  42. package/dist/service-adapters/index.mjs +1 -1
  43. package/package.json +2 -2
  44. package/src/graphql/inputs/extensions.input.ts +21 -0
  45. package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
  46. package/src/graphql/inputs/load-agent-state.input.ts +10 -0
  47. package/src/graphql/resolvers/copilot.resolver.ts +8 -3
  48. package/src/graphql/resolvers/state.resolver.ts +23 -0
  49. package/src/graphql/types/agents-response.type.ts +1 -4
  50. package/src/graphql/types/copilot-response.type.ts +5 -1
  51. package/src/graphql/types/extensions-response.type.ts +23 -0
  52. package/src/graphql/types/load-agent-state-response.type.ts +17 -0
  53. package/src/lib/integrations/shared.ts +2 -1
  54. package/src/lib/runtime/copilot-runtime.ts +155 -31
  55. package/src/lib/runtime/remote-action-constructors.ts +42 -33
  56. package/src/lib/runtime/remote-actions.ts +12 -7
  57. package/src/lib/runtime/remote-lg-action.ts +24 -12
  58. package/src/service-adapters/anthropic/anthropic-adapter.ts +2 -3
  59. package/src/service-adapters/empty/empty-adapter.ts +2 -2
  60. package/src/service-adapters/events.ts +5 -0
  61. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -2
  62. package/src/service-adapters/groq/groq-adapter.ts +2 -2
  63. package/src/service-adapters/langchain/langchain-adapter.ts +10 -3
  64. package/src/service-adapters/openai/openai-adapter.ts +4 -3
  65. package/src/service-adapters/openai/openai-assistant-adapter.ts +15 -4
  66. package/src/service-adapters/service-adapter.ts +4 -0
  67. package/src/service-adapters/unify/unify-adapter.ts +2 -3
  68. package/dist/chunk-MFDRA3BJ.mjs.map +0 -1
  69. package/dist/chunk-TPTCSIAR.mjs.map +0 -1
  70. /package/dist/{chunk-XRW7ZSWJ.mjs.map → chunk-DLESGNLO.mjs.map} +0 -0
  71. /package/dist/{chunk-QDMAQO2C.mjs.map → chunk-UBYSQI43.mjs.map} +0 -0
  72. /package/dist/{chunk-NORCONUM.mjs.map → chunk-WTUPF3W3.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-MFDRA3BJ.mjs";
4
- import "../../../chunk-TPTCSIAR.mjs";
3
+ } from "../../../chunk-34276UUU.mjs";
4
+ import "../../../chunk-S3KKBII4.mjs";
5
5
  import "../../../chunk-U3V2BCGI.mjs";
6
6
  import "../../../chunk-HNUNXFTW.mjs";
7
7
  import "../../../chunk-D2WLFQS6.mjs";
@@ -1,8 +1,8 @@
1
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-a16ef8f4.js';
2
- export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-a16ef8f4.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-c35c5374.js';
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';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
- import '../index-24315d90.js';
5
+ import '../index-a7f37670.js';
6
6
  import '../graphql/types/base/index.js';
7
7
  import 'rxjs';
8
8
  import '@copilotkit/shared';
@@ -282,8 +282,9 @@ var OpenAIAdapter = class {
282
282
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
283
283
  }
284
284
  async process(request) {
285
- const { threadId, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
285
+ const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
286
286
  const tools = actions.map(convertActionInputToOpenAITool);
287
+ const threadId = threadIdFromRequest ?? (0, import_shared.randomUUID)();
287
288
  let openaiMessages = messages.map(convertMessageToOpenAIMessage);
288
289
  openaiMessages = limitMessagesToTokenCount(openaiMessages, tools, model);
289
290
  let toolChoice = forwardedParameters == null ? void 0 : forwardedParameters.toolChoice;
@@ -381,7 +382,7 @@ var OpenAIAdapter = class {
381
382
  eventStream$.complete();
382
383
  });
383
384
  return {
384
- threadId: threadId || (0, import_shared.randomId)()
385
+ threadId
385
386
  };
386
387
  }
387
388
  };
@@ -627,8 +628,8 @@ var LangChainAdapter = class {
627
628
  }
628
629
  async process(request) {
629
630
  try {
630
- const { eventSource, model, actions, messages, runId } = request;
631
- const threadId = request.threadId ?? (0, import_shared3.randomId)();
631
+ const { eventSource, model, actions, messages, runId, threadId: threadIdFromRequest } = request;
632
+ const threadId = threadIdFromRequest ?? (0, import_shared3.randomUUID)();
632
633
  const result = await this.options.chainFn({
633
634
  messages: messages.map(convertMessageToLangChainMessage),
634
635
  tools: actions.map(convertActionInputToLangChainTool),
@@ -689,8 +690,12 @@ var OpenAIAssistantAdapter = class {
689
690
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
690
691
  }
691
692
  async process(request) {
693
+ var _a, _b;
692
694
  const { messages, actions, eventSource, runId, forwardedParameters } = request;
693
- let threadId = request.threadId || (await this.openai.beta.threads.create()).id;
695
+ let threadId = (_b = (_a = request.extensions) == null ? void 0 : _a.openaiAssistantAPI) == null ? void 0 : _b.threadId;
696
+ if (!threadId) {
697
+ threadId = (await this.openai.beta.threads.create()).id;
698
+ }
694
699
  const lastMessage = messages.at(-1);
695
700
  let nextRunId = void 0;
696
701
  if (lastMessage.isResultMessage() && runId) {
@@ -701,8 +706,15 @@ var OpenAIAssistantAdapter = class {
701
706
  throw new Error("No actionable message found in the messages");
702
707
  }
703
708
  return {
709
+ runId: nextRunId,
704
710
  threadId,
705
- runId: nextRunId
711
+ extensions: {
712
+ ...request.extensions,
713
+ openaiAssistantAPI: {
714
+ threadId,
715
+ runId: nextRunId
716
+ }
717
+ }
706
718
  };
707
719
  }
708
720
  async submitToolOutputs(threadId, runId, messages, eventSource) {
@@ -970,7 +982,7 @@ var UnifyAdapter = class {
970
982
  eventStream$.complete();
971
983
  });
972
984
  return {
973
- threadId: request.threadId || (0, import_shared4.randomId)()
985
+ threadId: request.threadId || (0, import_shared4.randomUUID)()
974
986
  };
975
987
  }
976
988
  };
@@ -1091,7 +1103,7 @@ var GroqAdapter = class {
1091
1103
  eventStream$.complete();
1092
1104
  });
1093
1105
  return {
1094
- threadId: threadId || (0, import_shared5.randomId)()
1106
+ threadId: request.threadId || (0, import_shared5.randomUUID)()
1095
1107
  };
1096
1108
  }
1097
1109
  };
@@ -1342,7 +1354,7 @@ var AnthropicAdapter = class {
1342
1354
  eventStream$.complete();
1343
1355
  });
1344
1356
  return {
1345
- threadId: threadId || (0, import_shared6.randomId)()
1357
+ threadId: threadId || (0, import_shared6.randomUUID)()
1346
1358
  };
1347
1359
  }
1348
1360
  };
@@ -1417,7 +1429,7 @@ var ExperimentalOllamaAdapter = class {
1417
1429
  eventStream$.complete();
1418
1430
  });
1419
1431
  return {
1420
- threadId: request.threadId || (0, import_shared7.randomId)()
1432
+ threadId: request.threadId || (0, import_shared7.randomUUID)()
1421
1433
  };
1422
1434
  }
1423
1435
  };
@@ -1428,7 +1440,7 @@ var import_shared8 = require("@copilotkit/shared");
1428
1440
  var EmptyAdapter = class {
1429
1441
  async process(request) {
1430
1442
  return {
1431
- threadId: request.threadId || (0, import_shared8.randomId)()
1443
+ threadId: request.threadId || (0, import_shared8.randomUUID)()
1432
1444
  };
1433
1445
  }
1434
1446
  };