integrate-sdk 0.8.39 → 0.8.42-dev.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 (57) hide show
  1. package/dist/adapters/auto-routes.js +1471 -60
  2. package/dist/adapters/index.js +1471 -60
  3. package/dist/adapters/nextjs.js +1471 -60
  4. package/dist/adapters/node.js +1471 -60
  5. package/dist/adapters/svelte-kit.js +1471 -60
  6. package/dist/adapters/tanstack-start.js +1471 -60
  7. package/dist/ai/anthropic.d.ts.map +1 -1
  8. package/dist/ai/anthropic.js +5 -21
  9. package/dist/ai/google.d.ts.map +1 -1
  10. package/dist/ai/google.js +57 -18
  11. package/dist/ai/index.js +67 -60
  12. package/dist/ai/openai.d.ts.map +1 -1
  13. package/dist/ai/openai.js +5 -21
  14. package/dist/index.js +1471 -60
  15. package/dist/oauth.js +1471 -60
  16. package/dist/server.js +1471 -60
  17. package/dist/src/ai/anthropic.d.ts.map +1 -1
  18. package/dist/src/ai/google.d.ts.map +1 -1
  19. package/dist/src/ai/openai.d.ts.map +1 -1
  20. package/package.json +6 -5
  21. package/dist/adapters/base-handler.js +0 -561
  22. package/dist/ai/cloudflare.d.ts +0 -158
  23. package/dist/ai/cloudflare.d.ts.map +0 -1
  24. package/dist/ai/cloudflare.js +0 -4249
  25. package/dist/ai/langchain.d.ts +0 -139
  26. package/dist/ai/langchain.d.ts.map +0 -1
  27. package/dist/ai/langchain.js +0 -4237
  28. package/dist/ai/llamaindex.d.ts +0 -125
  29. package/dist/ai/llamaindex.d.ts.map +0 -1
  30. package/dist/ai/llamaindex.js +0 -4236
  31. package/dist/ai/mastra.d.ts +0 -138
  32. package/dist/ai/mastra.d.ts.map +0 -1
  33. package/dist/ai/mastra.js +0 -4240
  34. package/dist/src/ai/cloudflare.d.ts +0 -158
  35. package/dist/src/ai/cloudflare.d.ts.map +0 -1
  36. package/dist/src/ai/langchain.d.ts +0 -139
  37. package/dist/src/ai/langchain.d.ts.map +0 -1
  38. package/dist/src/ai/llamaindex.d.ts +0 -125
  39. package/dist/src/ai/llamaindex.d.ts.map +0 -1
  40. package/dist/src/ai/mastra.d.ts +0 -138
  41. package/dist/src/ai/mastra.d.ts.map +0 -1
  42. package/dist/src/integrations/vercel-ai.d.ts +0 -127
  43. package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
  44. package/dist/src/plugins/generic.d.ts +0 -99
  45. package/dist/src/plugins/generic.d.ts.map +0 -1
  46. package/dist/src/plugins/github-client.d.ts +0 -320
  47. package/dist/src/plugins/github-client.d.ts.map +0 -1
  48. package/dist/src/plugins/github.d.ts +0 -89
  49. package/dist/src/plugins/github.d.ts.map +0 -1
  50. package/dist/src/plugins/gmail-client.d.ts +0 -106
  51. package/dist/src/plugins/gmail-client.d.ts.map +0 -1
  52. package/dist/src/plugins/gmail.d.ts +0 -87
  53. package/dist/src/plugins/gmail.d.ts.map +0 -1
  54. package/dist/src/plugins/server-client.d.ts +0 -18
  55. package/dist/src/plugins/server-client.d.ts.map +0 -1
  56. package/dist/src/plugins/types.d.ts +0 -70
  57. package/dist/src/plugins/types.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjH,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC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AAO,EAAE,MAAM,CAAC;CACjB;AA2HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAwC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpG,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAkC5I"}
@@ -4402,6 +4402,7 @@ function createTriggerTools(config, context) {
4402
4402
  }
4403
4403
 
4404
4404
  // anthropic.ts
4405
+ import { zodToJsonSchema } from "zod-to-json-schema";
4405
4406
  function convertMCPToolToAnthropic(mcpTool, _client, _options) {
4406
4407
  return {
4407
4408
  name: mcpTool.name,
@@ -4460,7 +4461,10 @@ async function getAnthropicTools(client, options) {
4460
4461
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
4461
4462
  for (const [name, tool] of Object.entries(triggerTools)) {
4462
4463
  const zodSchema = tool.inputSchema;
4463
- const jsonSchema = zodToAnthropicSchema(zodSchema);
4464
+ const jsonSchema = zodToJsonSchema(zodSchema, {
4465
+ target: "openApi3",
4466
+ $refStrategy: "none"
4467
+ });
4464
4468
  anthropicTools.push({
4465
4469
  name,
4466
4470
  description: tool.description || `Execute ${name}`,
@@ -4470,26 +4474,6 @@ async function getAnthropicTools(client, options) {
4470
4474
  }
4471
4475
  return anthropicTools;
4472
4476
  }
4473
- function zodToAnthropicSchema(schema) {
4474
- if (schema._def?.typeName === "ZodObject") {
4475
- const shape = schema._def.shape();
4476
- const properties = {};
4477
- const required = [];
4478
- for (const [key, value] of Object.entries(shape)) {
4479
- const fieldSchema = value;
4480
- properties[key] = { type: "string" };
4481
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4482
- required.push(key);
4483
- }
4484
- }
4485
- return {
4486
- type: "object",
4487
- properties,
4488
- ...required.length > 0 ? { required } : {}
4489
- };
4490
- }
4491
- return { type: "object", properties: {}, required: [] };
4492
- }
4493
4477
  async function handleAnthropicMessage(client, message, options) {
4494
4478
  let providerTokens = options?.providerTokens;
4495
4479
  if (!providerTokens) {
@@ -1 +1 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjH,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACL,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAC7C,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAuB7B;;GAEG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;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,aAAa,EAAE,kBAAkB,EAAE,GAAG,SAAS,GAAG,IAAI,EACtD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CA2CnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CA8CvB"}
package/dist/ai/google.js CHANGED
@@ -4402,6 +4402,7 @@ function createTriggerTools(config, context) {
4402
4402
  }
4403
4403
 
4404
4404
  // google.ts
4405
+ import { zodToJsonSchema } from "zod-to-json-schema";
4405
4406
  async function getGoogleType() {
4406
4407
  try {
4407
4408
  const dynamicImport = new Function("specifier", "return import(specifier)");
@@ -4515,35 +4516,73 @@ async function getGoogleTools(client, options) {
4515
4516
  const TypeEnum = await getGoogleType();
4516
4517
  for (const [name, tool] of Object.entries(triggerTools)) {
4517
4518
  const zodSchema = tool.inputSchema;
4518
- const jsonSchema = zodToGoogleSchema(zodSchema, TypeEnum);
4519
+ const jsonSchema = zodToJsonSchema(zodSchema, {
4520
+ target: "openApi3",
4521
+ $refStrategy: "none"
4522
+ });
4523
+ const googleSchema = convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum);
4519
4524
  googleTools.push({
4520
4525
  name,
4521
4526
  description: tool.description || `Execute ${name}`,
4522
- parameters: jsonSchema
4527
+ parameters: googleSchema
4523
4528
  });
4524
4529
  }
4525
4530
  }
4526
4531
  return googleTools;
4527
4532
  }
4528
- function zodToGoogleSchema(schema, TypeEnum) {
4529
- if (schema._def?.typeName === "ZodObject") {
4530
- const shape = schema._def.shape();
4531
- const properties = {};
4532
- const required = [];
4533
- for (const [key, value] of Object.entries(shape)) {
4534
- const fieldSchema = value;
4535
- properties[key] = { type: TypeEnum.STRING };
4536
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4537
- required.push(key);
4533
+ function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
4534
+ const result = {
4535
+ type: TypeEnum.OBJECT
4536
+ };
4537
+ if (jsonSchema.properties) {
4538
+ const googleProperties = {};
4539
+ for (const [key, prop] of Object.entries(jsonSchema.properties)) {
4540
+ const googleProp = {};
4541
+ if (prop.type) {
4542
+ switch (prop.type) {
4543
+ case "string":
4544
+ googleProp.type = TypeEnum.STRING;
4545
+ break;
4546
+ case "number":
4547
+ googleProp.type = TypeEnum.NUMBER;
4548
+ break;
4549
+ case "integer":
4550
+ googleProp.type = TypeEnum.INTEGER;
4551
+ break;
4552
+ case "boolean":
4553
+ googleProp.type = TypeEnum.BOOLEAN;
4554
+ break;
4555
+ case "array":
4556
+ googleProp.type = TypeEnum.ARRAY;
4557
+ if (prop.items) {
4558
+ googleProp.items = convertJsonSchemaToGoogleSchema(prop.items, TypeEnum);
4559
+ }
4560
+ break;
4561
+ case "object":
4562
+ googleProp.type = TypeEnum.OBJECT;
4563
+ if (prop.properties) {
4564
+ googleProp.properties = Object.fromEntries(Object.entries(prop.properties).map(([k, v]) => [
4565
+ k,
4566
+ convertJsonSchemaToGoogleSchema(v, TypeEnum)
4567
+ ]));
4568
+ }
4569
+ break;
4570
+ default:
4571
+ googleProp.type = TypeEnum.STRING;
4572
+ }
4538
4573
  }
4574
+ if (prop.description)
4575
+ googleProp.description = prop.description;
4576
+ if (prop.enum)
4577
+ googleProp.enum = prop.enum;
4578
+ googleProperties[key] = googleProp;
4539
4579
  }
4540
- return {
4541
- type: TypeEnum.OBJECT,
4542
- properties,
4543
- ...required.length > 0 ? { required } : {}
4544
- };
4580
+ result.properties = googleProperties;
4545
4581
  }
4546
- return { type: TypeEnum.OBJECT, properties: {} };
4582
+ if (jsonSchema.required && Array.isArray(jsonSchema.required)) {
4583
+ result.required = jsonSchema.required;
4584
+ }
4585
+ return result;
4547
4586
  }
4548
4587
  export {
4549
4588
  getGoogleTools,
package/dist/ai/index.js CHANGED
@@ -4402,6 +4402,7 @@ function createTriggerTools(config, context) {
4402
4402
  }
4403
4403
 
4404
4404
  // anthropic.ts
4405
+ import { zodToJsonSchema } from "zod-to-json-schema";
4405
4406
  function convertMCPToolToAnthropic(mcpTool, _client, _options) {
4406
4407
  return {
4407
4408
  name: mcpTool.name,
@@ -4460,7 +4461,10 @@ async function getAnthropicTools(client, options) {
4460
4461
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
4461
4462
  for (const [name, tool] of Object.entries(triggerTools)) {
4462
4463
  const zodSchema = tool.inputSchema;
4463
- const jsonSchema = zodToAnthropicSchema(zodSchema);
4464
+ const jsonSchema = zodToJsonSchema(zodSchema, {
4465
+ target: "openApi3",
4466
+ $refStrategy: "none"
4467
+ });
4464
4468
  anthropicTools.push({
4465
4469
  name,
4466
4470
  description: tool.description || `Execute ${name}`,
@@ -4470,26 +4474,6 @@ async function getAnthropicTools(client, options) {
4470
4474
  }
4471
4475
  return anthropicTools;
4472
4476
  }
4473
- function zodToAnthropicSchema(schema) {
4474
- if (schema._def?.typeName === "ZodObject") {
4475
- const shape = schema._def.shape();
4476
- const properties = {};
4477
- const required = [];
4478
- for (const [key, value] of Object.entries(shape)) {
4479
- const fieldSchema = value;
4480
- properties[key] = { type: "string" };
4481
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4482
- required.push(key);
4483
- }
4484
- }
4485
- return {
4486
- type: "object",
4487
- properties,
4488
- ...required.length > 0 ? { required } : {}
4489
- };
4490
- }
4491
- return { type: "object", properties: {}, required: [] };
4492
- }
4493
4477
  async function handleAnthropicMessage(client, message, options) {
4494
4478
  let providerTokens = options?.providerTokens;
4495
4479
  if (!providerTokens) {
@@ -4515,6 +4499,7 @@ async function handleAnthropicMessage(client, message, options) {
4515
4499
  }
4516
4500
 
4517
4501
  // google.ts
4502
+ import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
4518
4503
  async function getGoogleType() {
4519
4504
  try {
4520
4505
  const dynamicImport = new Function("specifier", "return import(specifier)");
@@ -4628,35 +4613,73 @@ async function getGoogleTools(client, options) {
4628
4613
  const TypeEnum = await getGoogleType();
4629
4614
  for (const [name, tool] of Object.entries(triggerTools)) {
4630
4615
  const zodSchema = tool.inputSchema;
4631
- const jsonSchema = zodToGoogleSchema(zodSchema, TypeEnum);
4616
+ const jsonSchema = zodToJsonSchema2(zodSchema, {
4617
+ target: "openApi3",
4618
+ $refStrategy: "none"
4619
+ });
4620
+ const googleSchema = convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum);
4632
4621
  googleTools.push({
4633
4622
  name,
4634
4623
  description: tool.description || `Execute ${name}`,
4635
- parameters: jsonSchema
4624
+ parameters: googleSchema
4636
4625
  });
4637
4626
  }
4638
4627
  }
4639
4628
  return googleTools;
4640
4629
  }
4641
- function zodToGoogleSchema(schema, TypeEnum) {
4642
- if (schema._def?.typeName === "ZodObject") {
4643
- const shape = schema._def.shape();
4644
- const properties = {};
4645
- const required = [];
4646
- for (const [key, value] of Object.entries(shape)) {
4647
- const fieldSchema = value;
4648
- properties[key] = { type: TypeEnum.STRING };
4649
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4650
- required.push(key);
4630
+ function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
4631
+ const result = {
4632
+ type: TypeEnum.OBJECT
4633
+ };
4634
+ if (jsonSchema.properties) {
4635
+ const googleProperties = {};
4636
+ for (const [key, prop] of Object.entries(jsonSchema.properties)) {
4637
+ const googleProp = {};
4638
+ if (prop.type) {
4639
+ switch (prop.type) {
4640
+ case "string":
4641
+ googleProp.type = TypeEnum.STRING;
4642
+ break;
4643
+ case "number":
4644
+ googleProp.type = TypeEnum.NUMBER;
4645
+ break;
4646
+ case "integer":
4647
+ googleProp.type = TypeEnum.INTEGER;
4648
+ break;
4649
+ case "boolean":
4650
+ googleProp.type = TypeEnum.BOOLEAN;
4651
+ break;
4652
+ case "array":
4653
+ googleProp.type = TypeEnum.ARRAY;
4654
+ if (prop.items) {
4655
+ googleProp.items = convertJsonSchemaToGoogleSchema(prop.items, TypeEnum);
4656
+ }
4657
+ break;
4658
+ case "object":
4659
+ googleProp.type = TypeEnum.OBJECT;
4660
+ if (prop.properties) {
4661
+ googleProp.properties = Object.fromEntries(Object.entries(prop.properties).map(([k, v]) => [
4662
+ k,
4663
+ convertJsonSchemaToGoogleSchema(v, TypeEnum)
4664
+ ]));
4665
+ }
4666
+ break;
4667
+ default:
4668
+ googleProp.type = TypeEnum.STRING;
4669
+ }
4651
4670
  }
4671
+ if (prop.description)
4672
+ googleProp.description = prop.description;
4673
+ if (prop.enum)
4674
+ googleProp.enum = prop.enum;
4675
+ googleProperties[key] = googleProp;
4652
4676
  }
4653
- return {
4654
- type: TypeEnum.OBJECT,
4655
- properties,
4656
- ...required.length > 0 ? { required } : {}
4657
- };
4677
+ result.properties = googleProperties;
4678
+ }
4679
+ if (jsonSchema.required && Array.isArray(jsonSchema.required)) {
4680
+ result.required = jsonSchema.required;
4658
4681
  }
4659
- return { type: TypeEnum.OBJECT, properties: {} };
4682
+ return result;
4660
4683
  }
4661
4684
 
4662
4685
  // vercel-ai.ts
@@ -4695,6 +4718,7 @@ async function getVercelAITools(client, options) {
4695
4718
  }
4696
4719
 
4697
4720
  // openai.ts
4721
+ import { zodToJsonSchema as zodToJsonSchema3 } from "zod-to-json-schema";
4698
4722
  function convertMCPToolToOpenAI(mcpTool, _client, options) {
4699
4723
  const inputParams = mcpTool.inputSchema;
4700
4724
  return {
@@ -4721,7 +4745,10 @@ async function getOpenAITools(client, options) {
4721
4745
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
4722
4746
  for (const [name, tool] of Object.entries(triggerTools)) {
4723
4747
  const zodSchema = tool.inputSchema;
4724
- const jsonSchema = zodToJsonSchema(zodSchema);
4748
+ const jsonSchema = zodToJsonSchema3(zodSchema, {
4749
+ target: "openApi3",
4750
+ $refStrategy: "none"
4751
+ });
4725
4752
  openaiTools.push({
4726
4753
  type: "function",
4727
4754
  name,
@@ -4733,26 +4760,6 @@ async function getOpenAITools(client, options) {
4733
4760
  }
4734
4761
  return openaiTools;
4735
4762
  }
4736
- function zodToJsonSchema(schema) {
4737
- if (schema._def?.typeName === "ZodObject") {
4738
- const shape = schema._def.shape();
4739
- const properties = {};
4740
- const required = [];
4741
- for (const [key, value] of Object.entries(shape)) {
4742
- const fieldSchema = value;
4743
- properties[key] = { type: "string" };
4744
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4745
- required.push(key);
4746
- }
4747
- }
4748
- return {
4749
- type: "object",
4750
- properties,
4751
- ...required.length > 0 ? { required } : {}
4752
- };
4753
- }
4754
- return { type: "object" };
4755
- }
4756
4763
  async function handleOpenAIToolCalls(client, toolCalls, options) {
4757
4764
  const toolOutputs = [];
4758
4765
  const triggerConfig = client.__triggerConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IA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4402,6 +4402,7 @@ function createTriggerTools(config, context) {
4402
4402
  }
4403
4403
 
4404
4404
  // openai.ts
4405
+ import { zodToJsonSchema } from "zod-to-json-schema";
4405
4406
  function convertMCPToolToOpenAI(mcpTool, _client, options) {
4406
4407
  const inputParams = mcpTool.inputSchema;
4407
4408
  return {
@@ -4428,7 +4429,10 @@ async function getOpenAITools(client, options) {
4428
4429
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
4429
4430
  for (const [name, tool] of Object.entries(triggerTools)) {
4430
4431
  const zodSchema = tool.inputSchema;
4431
- const jsonSchema = zodToJsonSchema(zodSchema);
4432
+ const jsonSchema = zodToJsonSchema(zodSchema, {
4433
+ target: "openApi3",
4434
+ $refStrategy: "none"
4435
+ });
4432
4436
  openaiTools.push({
4433
4437
  type: "function",
4434
4438
  name,
@@ -4440,26 +4444,6 @@ async function getOpenAITools(client, options) {
4440
4444
  }
4441
4445
  return openaiTools;
4442
4446
  }
4443
- function zodToJsonSchema(schema) {
4444
- if (schema._def?.typeName === "ZodObject") {
4445
- const shape = schema._def.shape();
4446
- const properties = {};
4447
- const required = [];
4448
- for (const [key, value] of Object.entries(shape)) {
4449
- const fieldSchema = value;
4450
- properties[key] = { type: "string" };
4451
- if (fieldSchema._def?.typeName !== "ZodOptional") {
4452
- required.push(key);
4453
- }
4454
- }
4455
- return {
4456
- type: "object",
4457
- properties,
4458
- ...required.length > 0 ? { required } : {}
4459
- };
4460
- }
4461
- return { type: "object" };
4462
- }
4463
4447
  async function handleOpenAIToolCalls(client, toolCalls, options) {
4464
4448
  const toolOutputs = [];
4465
4449
  const triggerConfig = client.__triggerConfig;