@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.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",
@@ -499,24 +500,27 @@ __name(convertMessageToLangChainMessage, "convertMessageToLangChainMessage");
499
500
  function convertJsonSchemaToZodSchema(jsonSchema, required) {
500
501
  if (jsonSchema.type === "object") {
501
502
  const spec = {};
503
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
504
+ return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
505
+ }
502
506
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
503
507
  spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
504
508
  }
505
509
  let schema = import_zod.z.object(spec);
506
- return !required ? schema.optional() : schema;
510
+ return required ? schema : schema.optional();
507
511
  } else if (jsonSchema.type === "string") {
508
512
  let schema = import_zod.z.string().describe(jsonSchema.description);
509
- return !required ? schema.optional() : schema;
513
+ return required ? schema : schema.optional();
510
514
  } else if (jsonSchema.type === "number") {
511
515
  let schema = import_zod.z.number().describe(jsonSchema.description);
512
- return !required ? schema.optional() : schema;
516
+ return required ? schema : schema.optional();
513
517
  } else if (jsonSchema.type === "boolean") {
514
518
  let schema = import_zod.z.boolean().describe(jsonSchema.description);
515
- return !required ? schema.optional() : schema;
519
+ return required ? schema : schema.optional();
516
520
  } else if (jsonSchema.type === "array") {
517
521
  let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
518
522
  let schema = import_zod.z.array(itemSchema);
519
- return !required ? schema.optional() : schema;
523
+ return required ? schema : schema.optional();
520
524
  }
521
525
  }
522
526
  __name(convertJsonSchemaToZodSchema, "convertJsonSchemaToZodSchema");
@@ -1928,7 +1932,13 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
1928
1932
  }
1929
1933
  let args = [];
1930
1934
  if (actionArguments) {
1931
- args = JSON.parse(actionArguments);
1935
+ try {
1936
+ args = JSON.parse(actionArguments);
1937
+ } catch (e) {
1938
+ console.warn("Action argument unparsable", {
1939
+ actionArguments
1940
+ });
1941
+ }
1932
1942
  }
1933
1943
  if (isLangGraphAgentAction(action)) {
1934
1944
  eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);