@copilotkit/runtime 1.0.3 → 1.0.4

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 (49) hide show
  1. package/.turbo/turbo-build.log +28 -28
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +1 -1
  4. package/dist/{chunk-FPVMUZ5S.mjs → chunk-67DNPQCA.mjs} +10 -10
  5. package/dist/chunk-67DNPQCA.mjs.map +1 -0
  6. package/dist/{chunk-TTT54UED.mjs → chunk-F7DCXPQ7.mjs} +2 -2
  7. package/dist/{chunk-GTYL57UF.mjs → chunk-FNDYTEEL.mjs} +2 -2
  8. package/dist/{chunk-3SJCLGQE.mjs → chunk-JWUHY4RB.mjs} +2 -2
  9. package/dist/{chunk-L2HCON4L.mjs → chunk-UFAHXJX7.mjs} +3 -3
  10. package/dist/{chunk-DVDKD6F5.mjs → chunk-URMISMK2.mjs} +8 -8
  11. package/dist/chunk-URMISMK2.mjs.map +1 -0
  12. package/dist/{chunk-VIQZS4W6.mjs → chunk-VQM4RIMQ.mjs} +9 -10
  13. package/dist/chunk-VQM4RIMQ.mjs.map +1 -0
  14. package/dist/index.js +26 -27
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +7 -7
  17. package/dist/lib/index.js +26 -27
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/index.mjs +7 -7
  20. package/dist/lib/integrations/index.js +7 -8
  21. package/dist/lib/integrations/index.js.map +1 -1
  22. package/dist/lib/integrations/index.mjs +5 -5
  23. package/dist/lib/integrations/nest/index.js +7 -8
  24. package/dist/lib/integrations/nest/index.js.map +1 -1
  25. package/dist/lib/integrations/nest/index.mjs +3 -3
  26. package/dist/lib/integrations/node-express/index.js +7 -8
  27. package/dist/lib/integrations/node-express/index.js.map +1 -1
  28. package/dist/lib/integrations/node-express/index.mjs +3 -3
  29. package/dist/lib/integrations/node-http/index.js +7 -8
  30. package/dist/lib/integrations/node-http/index.js.map +1 -1
  31. package/dist/lib/integrations/node-http/index.mjs +2 -2
  32. package/dist/service-adapters/index.js +15 -15
  33. package/dist/service-adapters/index.js.map +1 -1
  34. package/dist/service-adapters/index.mjs +2 -2
  35. package/package.json +4 -5
  36. package/src/graphql/resolvers/copilot.resolver.ts +6 -6
  37. package/src/service-adapters/experimental/groq/groq-adapter.ts +3 -3
  38. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -5
  39. package/src/service-adapters/google/google-genai-adapter.ts +4 -4
  40. package/src/service-adapters/langchain/langchain-adapter.ts +2 -2
  41. package/src/service-adapters/langchain/utils.ts +7 -7
  42. package/src/service-adapters/openai/openai-adapter.ts +2 -2
  43. package/dist/chunk-DVDKD6F5.mjs.map +0 -1
  44. package/dist/chunk-FPVMUZ5S.mjs.map +0 -1
  45. package/dist/chunk-VIQZS4W6.mjs.map +0 -1
  46. /package/dist/{chunk-TTT54UED.mjs.map → chunk-F7DCXPQ7.mjs.map} +0 -0
  47. /package/dist/{chunk-GTYL57UF.mjs.map → chunk-FNDYTEEL.mjs.map} +0 -0
  48. /package/dist/{chunk-3SJCLGQE.mjs.map → chunk-JWUHY4RB.mjs.map} +0 -0
  49. /package/dist/{chunk-L2HCON4L.mjs.map → chunk-UFAHXJX7.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,31 +1,31 @@
1
1
  import {
2
2
  CopilotRuntime,
3
3
  flattenToolCallsNoDuplicates
4
- } from "./chunk-L2HCON4L.mjs";
4
+ } from "./chunk-UFAHXJX7.mjs";
5
5
  import {
6
6
  GoogleGenerativeAIAdapter,
7
7
  LangChainAdapter,
8
8
  OpenAIAdapter,
9
9
  OpenAIAssistantAdapter
10
- } from "./chunk-FPVMUZ5S.mjs";
10
+ } from "./chunk-67DNPQCA.mjs";
11
11
  import {
12
12
  config,
13
13
  copilotRuntimeNextJSAppRouterEndpoint,
14
14
  copilotRuntimeNextJSPagesRouterEndpoint
15
- } from "./chunk-3SJCLGQE.mjs";
15
+ } from "./chunk-JWUHY4RB.mjs";
16
16
  import {
17
17
  copilotRuntimeNestEndpoint
18
- } from "./chunk-GTYL57UF.mjs";
18
+ } from "./chunk-FNDYTEEL.mjs";
19
19
  import {
20
20
  copilotRuntimeNodeExpressEndpoint
21
- } from "./chunk-TTT54UED.mjs";
21
+ } from "./chunk-F7DCXPQ7.mjs";
22
22
  import {
23
23
  buildSchema,
24
24
  copilotRuntimeNodeHttpEndpoint,
25
25
  createContext,
26
26
  getCommonConfig
27
- } from "./chunk-VIQZS4W6.mjs";
28
- import "./chunk-DVDKD6F5.mjs";
27
+ } from "./chunk-VQM4RIMQ.mjs";
28
+ import "./chunk-URMISMK2.mjs";
29
29
  import {
30
30
  GuardrailsValidationFailureResponse,
31
31
  MessageStreamInterruptedResponse,
package/dist/lib/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.0.3",
47
+ version: "1.0.4",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -92,7 +92,6 @@ var require_package = __commonJS({
92
92
  "groq-sdk": "^0.5.0",
93
93
  "js-tiktoken": "^1.0.8",
94
94
  langchain: "^0.1.36",
95
- nanoid: "3.3.4",
96
95
  openai: "^4.50.0",
97
96
  pino: "^9.2.0",
98
97
  "pino-pretty": "^11.2.1",
@@ -140,7 +139,7 @@ __export(lib_exports, {
140
139
  module.exports = __toCommonJS(lib_exports);
141
140
 
142
141
  // src/lib/copilot-runtime.ts
143
- var import_shared = require("@copilotkit/shared");
142
+ var import_shared5 = require("@copilotkit/shared");
144
143
 
145
144
  // src/service-adapters/openai/openai-adapter.ts
146
145
  var import_openai = __toESM(require("openai"));
@@ -346,7 +345,7 @@ function convertSystemMessageToAssistantAPI(message) {
346
345
  __name(convertSystemMessageToAssistantAPI, "convertSystemMessageToAssistantAPI");
347
346
 
348
347
  // src/service-adapters/openai/openai-adapter.ts
349
- var import_nanoid = require("nanoid");
348
+ var import_shared = require("@copilotkit/shared");
350
349
  var DEFAULT_MODEL = "gpt-4o";
351
350
  var OpenAIAdapter = class {
352
351
  model = DEFAULT_MODEL;
@@ -409,7 +408,7 @@ var OpenAIAdapter = class {
409
408
  eventStream$.complete();
410
409
  });
411
410
  return {
412
- threadId: threadId || (0, import_nanoid.nanoid)()
411
+ threadId: threadId || (0, import_shared.randomId)()
413
412
  };
414
413
  }
415
414
  };
@@ -655,7 +654,7 @@ function tryParseJson(str) {
655
654
  __name(tryParseJson, "tryParseJson");
656
655
 
657
656
  // src/service-adapters/google/google-genai-adapter.ts
658
- var import_nanoid2 = require("nanoid");
657
+ var import_shared2 = require("@copilotkit/shared");
659
658
  var GoogleGenerativeAIAdapter = class {
660
659
  model;
661
660
  constructor(options) {
@@ -722,7 +721,7 @@ var GoogleGenerativeAIAdapter = class {
722
721
  }
723
722
  if (!isTextMessage) {
724
723
  isTextMessage = true;
725
- eventStream$.sendTextMessageStart((0, import_nanoid2.nanoid)());
724
+ eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
726
725
  }
727
726
  eventStream$.sendTextMessageContent(chunkText);
728
727
  }
@@ -732,13 +731,13 @@ var GoogleGenerativeAIAdapter = class {
732
731
  let calls = (await result.response).functionCalls();
733
732
  if (calls) {
734
733
  for (let call of calls) {
735
- eventStream$.sendActionExecution((0, import_nanoid2.nanoid)(), call.name, JSON.stringify(replaceNewlinesInObject(call.args)));
734
+ eventStream$.sendActionExecution((0, import_shared2.randomId)(), call.name, JSON.stringify(replaceNewlinesInObject(call.args)));
736
735
  }
737
736
  }
738
737
  eventStream$.complete();
739
738
  });
740
739
  return {
741
- threadId: request.threadId || (0, import_nanoid2.nanoid)()
740
+ threadId: request.threadId || (0, import_shared2.randomId)()
742
741
  };
743
742
  }
744
743
  };
@@ -765,7 +764,7 @@ __name(replaceNewlinesInObject, "replaceNewlinesInObject");
765
764
  var import_messages = require("@langchain/core/messages");
766
765
  var import_tools = require("@langchain/core/tools");
767
766
  var import_zod = require("zod");
768
- var import_nanoid3 = require("nanoid");
767
+ var import_shared3 = require("@copilotkit/shared");
769
768
  function convertMessageToLangChainMessage(message) {
770
769
  if (message instanceof TextMessage) {
771
770
  if (message.role == "user") {
@@ -858,26 +857,26 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
858
857
  var _a, _b, _c, _d, _e, _f, _g, _h;
859
858
  if (typeof result === "string") {
860
859
  if (!actionExecution) {
861
- eventStream$.sendTextMessage((0, import_nanoid3.nanoid)(), result);
860
+ eventStream$.sendTextMessage((0, import_shared3.randomId)(), result);
862
861
  } else {
863
862
  eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
864
863
  }
865
864
  } else if (isAIMessage(result)) {
866
865
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
867
866
  if (result.content) {
868
- eventStream$.sendTextMessage((0, import_nanoid3.nanoid)(), result.content);
867
+ eventStream$.sendTextMessage((0, import_shared3.randomId)(), result.content);
869
868
  }
870
869
  for (const toolCall of result.tool_calls) {
871
- eventStream$.sendActionExecution(toolCall.id || (0, import_nanoid3.nanoid)(), toolCall.name, JSON.stringify(toolCall.args));
870
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared3.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
872
871
  }
873
872
  } else if (isBaseMessageChunk(result)) {
874
873
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
875
874
  if ((_a = result.lc_kwargs) == null ? void 0 : _a.content) {
876
- eventStream$.sendTextMessage((0, import_nanoid3.nanoid)(), result.content);
875
+ eventStream$.sendTextMessage((0, import_shared3.randomId)(), result.content);
877
876
  }
878
877
  if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
879
878
  for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
880
- eventStream$.sendActionExecution(toolCall.id || (0, import_nanoid3.nanoid)(), toolCall.name, JSON.stringify(toolCall.args));
879
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared3.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
881
880
  }
882
881
  }
883
882
  } else if (result && "getReader" in result) {
@@ -921,7 +920,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
921
920
  eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
922
921
  } else if (content) {
923
922
  mode = "message";
924
- eventStream$.sendTextMessageStart((0, import_nanoid3.nanoid)());
923
+ eventStream$.sendTextMessageStart((0, import_shared3.randomId)());
925
924
  }
926
925
  }
927
926
  if (mode === "message" && content) {
@@ -954,7 +953,7 @@ function encodeResult(result) {
954
953
  __name(encodeResult, "encodeResult");
955
954
 
956
955
  // src/service-adapters/langchain/langchain-adapter.ts
957
- var import_nanoid4 = require("nanoid");
956
+ var import_shared4 = require("@copilotkit/shared");
958
957
  var LangChainAdapter = class {
959
958
  options;
960
959
  /**
@@ -979,7 +978,7 @@ var LangChainAdapter = class {
979
978
  });
980
979
  });
981
980
  return {
982
- threadId: threadId || (0, import_nanoid4.nanoid)()
981
+ threadId: threadId || (0, import_shared4.randomId)()
983
982
  };
984
983
  }
985
984
  };
@@ -1284,7 +1283,7 @@ var CopilotRuntime = class {
1284
1283
  const serverSideActionsInput = actions.map((action) => ({
1285
1284
  name: action.name,
1286
1285
  description: action.description,
1287
- jsonSchema: JSON.stringify((0, import_shared.actionParametersToJsonSchema)(action.parameters))
1286
+ jsonSchema: JSON.stringify((0, import_shared5.actionParametersToJsonSchema)(action.parameters))
1288
1287
  }));
1289
1288
  const actionInputs = flattenToolCallsNoDuplicates([
1290
1289
  ...serverSideActionsInput,
@@ -2072,7 +2071,6 @@ CopilotResponse = _ts_decorate10([
2072
2071
 
2073
2072
  // src/graphql/resolvers/copilot.resolver.ts
2074
2073
  var import_graphql_yoga = require("graphql-yoga");
2075
- var import_nanoid5 = require("nanoid");
2076
2074
  var import_graphql_scalars2 = require("graphql-scalars");
2077
2075
  var import_class_transformer2 = require("class-transformer");
2078
2076
  var import_graphql = require("graphql");
@@ -2111,15 +2109,16 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
2111
2109
  __name(UnknownErrorResponse, "UnknownErrorResponse");
2112
2110
 
2113
2111
  // src/lib/telemetry-client.ts
2114
- var import_shared2 = require("@copilotkit/shared");
2112
+ var import_shared6 = require("@copilotkit/shared");
2115
2113
  var packageJson = require_package();
2116
- var telemetryClient = new import_shared2.TelemetryClient({
2114
+ var telemetryClient = new import_shared6.TelemetryClient({
2117
2115
  packageName: packageJson.name,
2118
2116
  packageVersion: packageJson.version
2119
2117
  });
2120
2118
  var telemetry_client_default = telemetryClient;
2121
2119
 
2122
2120
  // src/graphql/resolvers/copilot.resolver.ts
2121
+ var import_shared7 = require("@copilotkit/shared");
2123
2122
  function _ts_decorate11(decorators, target, key, desc) {
2124
2123
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2125
2124
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2237,7 +2236,7 @@ var CopilotResolver = class {
2237
2236
  rejectOutputMessagesPromise = reject;
2238
2237
  });
2239
2238
  logger2.debug("Processing");
2240
- const { eventSource, threadId = (0, import_nanoid5.nanoid)(), runId, actions } = await copilotRuntime.process({
2239
+ const { eventSource, threadId = (0, import_shared7.randomId)(), runId, actions } = await copilotRuntime.process({
2241
2240
  serviceAdapter,
2242
2241
  messages: data.messages,
2243
2242
  actions: data.frontend.actions,
@@ -2278,7 +2277,7 @@ var CopilotResolver = class {
2278
2277
  });
2279
2278
  outputMessages = [
2280
2279
  (0, import_class_transformer2.plainToInstance)(TextMessage, {
2281
- id: (0, import_nanoid5.nanoid)(),
2280
+ id: (0, import_shared7.randomId)(),
2282
2281
  createdAt: /* @__PURE__ */ new Date(),
2283
2282
  content: result.reason,
2284
2283
  role: MessageRole.assistant
@@ -2325,7 +2324,7 @@ var CopilotResolver = class {
2325
2324
  (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
2326
2325
  );
2327
2326
  const streamingTextStatus = new import_rxjs2.Subject();
2328
- const messageId = (0, import_nanoid5.nanoid)();
2327
+ const messageId = (0, import_shared7.randomId)();
2329
2328
  pushMessage({
2330
2329
  id: messageId,
2331
2330
  status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
@@ -2437,7 +2436,7 @@ var CopilotResolver = class {
2437
2436
  result: event.result
2438
2437
  }, "Action execution result event received");
2439
2438
  pushMessage({
2440
- id: (0, import_nanoid5.nanoid)(),
2439
+ id: (0, import_shared7.randomId)(),
2441
2440
  status: new SuccessMessageStatus(),
2442
2441
  createdAt: /* @__PURE__ */ new Date(),
2443
2442
  actionExecutionId: event.actionExecutionId,
@@ -2445,7 +2444,7 @@ var CopilotResolver = class {
2445
2444
  result: event.result
2446
2445
  });
2447
2446
  outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
2448
- id: (0, import_nanoid5.nanoid)(),
2447
+ id: (0, import_shared7.randomId)(),
2449
2448
  createdAt: /* @__PURE__ */ new Date(),
2450
2449
  actionExecutionId: event.actionExecutionId,
2451
2450
  actionName: event.actionName,