@copilotkit/runtime 1.3.11 → 1.3.12-fix-tool-call-dynamic-parameters.0

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 (42) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-7MQDBRXJ.mjs → chunk-24WEOOFX.mjs} +2 -2
  3. package/dist/{chunk-AP2CCJ3J.mjs → chunk-AOYYOKTP.mjs} +13 -6
  4. package/dist/chunk-AOYYOKTP.mjs.map +1 -0
  5. package/dist/{chunk-REA4Z4VP.mjs → chunk-HKLL7TTP.mjs} +2 -2
  6. package/dist/{chunk-ZUQH5YKI.mjs → chunk-OSJXQNII.mjs} +3 -3
  7. package/dist/{chunk-ZSMR26MX.mjs → chunk-SIMJ6TZU.mjs} +2 -2
  8. package/dist/{chunk-BYL3ABWM.mjs → chunk-UYORVPCQ.mjs} +2 -2
  9. package/dist/{chunk-V7SK6QZN.mjs → chunk-ZEHCLFJ2.mjs} +9 -6
  10. package/dist/chunk-ZEHCLFJ2.mjs.map +1 -0
  11. package/dist/index.js +19 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +7 -7
  14. package/dist/lib/index.js +19 -9
  15. package/dist/lib/index.js.map +1 -1
  16. package/dist/lib/index.mjs +7 -7
  17. package/dist/lib/integrations/index.js +4 -3
  18. package/dist/lib/integrations/index.js.map +1 -1
  19. package/dist/lib/integrations/index.mjs +5 -5
  20. package/dist/lib/integrations/nest/index.js +4 -3
  21. package/dist/lib/integrations/nest/index.js.map +1 -1
  22. package/dist/lib/integrations/nest/index.mjs +3 -3
  23. package/dist/lib/integrations/node-express/index.js +4 -3
  24. package/dist/lib/integrations/node-express/index.js.map +1 -1
  25. package/dist/lib/integrations/node-express/index.mjs +3 -3
  26. package/dist/lib/integrations/node-http/index.js +4 -3
  27. package/dist/lib/integrations/node-http/index.js.map +1 -1
  28. package/dist/lib/integrations/node-http/index.mjs +2 -2
  29. package/dist/service-adapters/index.js +8 -5
  30. package/dist/service-adapters/index.js.map +1 -1
  31. package/dist/service-adapters/index.mjs +2 -2
  32. package/package.json +6 -5
  33. package/src/service-adapters/events.ts +5 -1
  34. package/src/service-adapters/langchain/utils.test.ts +169 -0
  35. package/src/service-adapters/langchain/utils.ts +10 -5
  36. package/dist/chunk-AP2CCJ3J.mjs.map +0 -1
  37. package/dist/chunk-V7SK6QZN.mjs.map +0 -1
  38. /package/dist/{chunk-7MQDBRXJ.mjs.map → chunk-24WEOOFX.mjs.map} +0 -0
  39. /package/dist/{chunk-REA4Z4VP.mjs.map → chunk-HKLL7TTP.mjs.map} +0 -0
  40. /package/dist/{chunk-ZUQH5YKI.mjs.map → chunk-OSJXQNII.mjs.map} +0 -0
  41. /package/dist/{chunk-ZSMR26MX.mjs.map → chunk-SIMJ6TZU.mjs.map} +0 -0
  42. /package/dist/{chunk-BYL3ABWM.mjs.map → chunk-UYORVPCQ.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CopilotRuntime,
3
3
  flattenToolCallsNoDuplicates
4
- } from "./chunk-ZUQH5YKI.mjs";
4
+ } from "./chunk-OSJXQNII.mjs";
5
5
  import {
6
6
  AnthropicAdapter,
7
7
  GoogleGenerativeAIAdapter,
@@ -11,25 +11,25 @@ import {
11
11
  OpenAIAssistantAdapter,
12
12
  RemoteChain,
13
13
  UnifyAdapter
14
- } from "./chunk-7MQDBRXJ.mjs";
14
+ } from "./chunk-24WEOOFX.mjs";
15
15
  import {
16
16
  config,
17
17
  copilotRuntimeNextJSAppRouterEndpoint,
18
18
  copilotRuntimeNextJSPagesRouterEndpoint
19
- } from "./chunk-BYL3ABWM.mjs";
19
+ } from "./chunk-UYORVPCQ.mjs";
20
20
  import {
21
21
  copilotRuntimeNestEndpoint
22
- } from "./chunk-ZSMR26MX.mjs";
22
+ } from "./chunk-SIMJ6TZU.mjs";
23
23
  import {
24
24
  copilotRuntimeNodeExpressEndpoint
25
- } from "./chunk-REA4Z4VP.mjs";
25
+ } from "./chunk-HKLL7TTP.mjs";
26
26
  import {
27
27
  buildSchema,
28
28
  copilotRuntimeNodeHttpEndpoint,
29
29
  createContext,
30
30
  getCommonConfig
31
- } from "./chunk-AP2CCJ3J.mjs";
32
- import "./chunk-V7SK6QZN.mjs";
31
+ } from "./chunk-AOYYOKTP.mjs";
32
+ import "./chunk-ZEHCLFJ2.mjs";
33
33
  import {
34
34
  GuardrailsValidationFailureResponse,
35
35
  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.3.11",
47
+ version: "1.3.12-fix-tool-call-dynamic-parameters.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -77,15 +77,16 @@ var require_package = __commonJS({
77
77
  "ts-node": "^10.9.2",
78
78
  tsconfig: "workspace:*",
79
79
  tsup: "^6.7.0",
80
- typescript: "^5.2.3"
80
+ typescript: "^5.2.3",
81
+ "zod-to-json-schema": "^3.23.5"
81
82
  },
82
83
  dependencies: {
83
84
  "@anthropic-ai/sdk": "^0.27.3",
84
85
  "@copilotkit/shared": "workspace:*",
85
- "@langchain/google-gauth": "^0.1.0",
86
86
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
87
87
  "@langchain/community": "^0.0.53",
88
88
  "@langchain/core": "^0.3.13",
89
+ "@langchain/google-gauth": "^0.1.0",
89
90
  "@langchain/openai": "^0.0.28",
90
91
  "class-transformer": "^0.5.1",
91
92
  express: "^4.19.2",
@@ -493,24 +494,27 @@ __name(convertMessageToLangChainMessage, "convertMessageToLangChainMessage");
493
494
  function convertJsonSchemaToZodSchema(jsonSchema, required) {
494
495
  if (jsonSchema.type === "object") {
495
496
  const spec = {};
497
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
498
+ return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
499
+ }
496
500
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
497
501
  spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
498
502
  }
499
503
  let schema = import_zod.z.object(spec);
500
- return !required ? schema.optional() : schema;
504
+ return required ? schema : schema.optional();
501
505
  } else if (jsonSchema.type === "string") {
502
506
  let schema = import_zod.z.string().describe(jsonSchema.description);
503
- return !required ? schema.optional() : schema;
507
+ return required ? schema : schema.optional();
504
508
  } else if (jsonSchema.type === "number") {
505
509
  let schema = import_zod.z.number().describe(jsonSchema.description);
506
- return !required ? schema.optional() : schema;
510
+ return required ? schema : schema.optional();
507
511
  } else if (jsonSchema.type === "boolean") {
508
512
  let schema = import_zod.z.boolean().describe(jsonSchema.description);
509
- return !required ? schema.optional() : schema;
513
+ return required ? schema : schema.optional();
510
514
  } else if (jsonSchema.type === "array") {
511
515
  let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
512
516
  let schema = import_zod.z.array(itemSchema);
513
- return !required ? schema.optional() : schema;
517
+ return required ? schema : schema.optional();
514
518
  }
515
519
  }
516
520
  __name(convertJsonSchemaToZodSchema, "convertJsonSchemaToZodSchema");
@@ -1658,7 +1662,13 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
1658
1662
  }
1659
1663
  let args = [];
1660
1664
  if (actionArguments) {
1661
- args = JSON.parse(actionArguments);
1665
+ try {
1666
+ args = JSON.parse(actionArguments);
1667
+ } catch (e) {
1668
+ console.warn("Action argument unparsable", {
1669
+ actionArguments
1670
+ });
1671
+ }
1662
1672
  }
1663
1673
  if (isLangGraphAgentAction(action)) {
1664
1674
  eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);