integrate-sdk 0.9.3-dev.0 → 0.9.5-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 (65) hide show
  1. package/dist/adapters/auto-routes.js +720 -22
  2. package/dist/adapters/index.js +720 -22
  3. package/dist/adapters/nextjs.js +720 -22
  4. package/dist/adapters/node.js +720 -22
  5. package/dist/adapters/svelte-kit.js +720 -22
  6. package/dist/adapters/tanstack-start.js +720 -22
  7. package/dist/ai/anthropic.d.ts +11 -0
  8. package/dist/ai/anthropic.d.ts.map +1 -1
  9. package/dist/ai/anthropic.js +559 -9
  10. package/dist/ai/google.d.ts +11 -0
  11. package/dist/ai/google.d.ts.map +1 -1
  12. package/dist/ai/google.js +568 -9
  13. package/dist/ai/index.js +655 -15
  14. package/dist/ai/openai.d.ts +11 -0
  15. package/dist/ai/openai.d.ts.map +1 -1
  16. package/dist/ai/openai.js +557 -9
  17. package/dist/ai/trigger-tools.d.ts +7 -7
  18. package/dist/ai/trigger-tools.js +7 -7
  19. package/dist/ai/vercel-ai.d.ts +13 -0
  20. package/dist/ai/vercel-ai.d.ts.map +1 -1
  21. package/dist/ai/vercel-ai.js +543 -9
  22. package/dist/code-mode/executor.d.ts +99 -0
  23. package/dist/code-mode/executor.d.ts.map +1 -0
  24. package/dist/code-mode/executor.js +207 -0
  25. package/dist/code-mode/index.d.ts +12 -0
  26. package/dist/code-mode/index.d.ts.map +1 -0
  27. package/dist/code-mode/index.js +527 -0
  28. package/dist/code-mode/runtime-stub.d.ts +16 -0
  29. package/dist/code-mode/runtime-stub.d.ts.map +1 -0
  30. package/dist/code-mode/runtime-stub.js +72 -0
  31. package/dist/code-mode/tool-builder.d.ts +83 -0
  32. package/dist/code-mode/tool-builder.d.ts.map +1 -0
  33. package/dist/code-mode/tool-builder.js +524 -0
  34. package/dist/code-mode/type-generator.d.ts +22 -0
  35. package/dist/code-mode/type-generator.d.ts.map +1 -0
  36. package/dist/code-mode/type-generator.js +217 -0
  37. package/dist/index.js +720 -22
  38. package/dist/oauth.js +720 -22
  39. package/dist/server.d.ts +1 -0
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +731 -23
  42. package/dist/src/ai/anthropic.d.ts +11 -0
  43. package/dist/src/ai/anthropic.d.ts.map +1 -1
  44. package/dist/src/ai/google.d.ts +11 -0
  45. package/dist/src/ai/google.d.ts.map +1 -1
  46. package/dist/src/ai/openai.d.ts +11 -0
  47. package/dist/src/ai/openai.d.ts.map +1 -1
  48. package/dist/src/ai/trigger-tools.d.ts +7 -7
  49. package/dist/src/ai/vercel-ai.d.ts +13 -0
  50. package/dist/src/ai/vercel-ai.d.ts.map +1 -1
  51. package/dist/src/code-mode/executor.d.ts +99 -0
  52. package/dist/src/code-mode/executor.d.ts.map +1 -0
  53. package/dist/src/code-mode/index.d.ts +12 -0
  54. package/dist/src/code-mode/index.d.ts.map +1 -0
  55. package/dist/src/code-mode/runtime-stub.d.ts +16 -0
  56. package/dist/src/code-mode/runtime-stub.d.ts.map +1 -0
  57. package/dist/src/code-mode/tool-builder.d.ts +83 -0
  58. package/dist/src/code-mode/tool-builder.d.ts.map +1 -0
  59. package/dist/src/code-mode/type-generator.d.ts +22 -0
  60. package/dist/src/code-mode/type-generator.d.ts.map +1 -0
  61. package/dist/src/config/types.d.ts +55 -0
  62. package/dist/src/config/types.d.ts.map +1 -1
  63. package/dist/src/server.d.ts.map +1 -1
  64. package/package.json +15 -6
  65. package/server.ts +9 -0
@@ -507,10 +507,17 @@ var init_errors = __esm(() => {
507
507
  function camelToSnake(str) {
508
508
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
509
509
  }
510
+ function snakeToCamel(str) {
511
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
512
+ }
510
513
  function methodToToolName(methodName, integrationId) {
511
514
  const snakeCaseMethod = camelToSnake(methodName);
512
515
  return `${integrationId}_${snakeCaseMethod}`;
513
516
  }
517
+ function toolNameToMethod(toolName) {
518
+ const withoutPrefix = toolName.replace(/^[^_]+_/, "");
519
+ return snakeToCamel(withoutPrefix);
520
+ }
514
521
 
515
522
  // ../triggers/client.ts
516
523
  class TriggerClient {
@@ -8166,7 +8173,7 @@ var init_utils2 = __esm(() => {
8166
8173
  function createTriggerTools(config, context) {
8167
8174
  const { callbacks } = config;
8168
8175
  return {
8169
- create_trigger: {
8176
+ trigger_create: {
8170
8177
  description: "Schedule a tool to run at a specific time or on a recurring schedule. Use this when the user wants to do something later.",
8171
8178
  inputSchema: exports_external.object({
8172
8179
  name: exports_external.string().optional().describe("Human-readable trigger name"),
@@ -8200,7 +8207,7 @@ function createTriggerTools(config, context) {
8200
8207
  return callbacks.create(trigger, context);
8201
8208
  }
8202
8209
  },
8203
- list_triggers: {
8210
+ trigger_list: {
8204
8211
  description: "List all scheduled triggers with optional filtering by status or tool name",
8205
8212
  inputSchema: exports_external.object({
8206
8213
  status: exports_external.enum(["active", "paused", "completed", "failed"]).optional().describe("Filter by trigger status"),
@@ -8224,7 +8231,7 @@ function createTriggerTools(config, context) {
8224
8231
  };
8225
8232
  }
8226
8233
  },
8227
- get_trigger: {
8234
+ trigger_get: {
8228
8235
  description: "Get details of a specific trigger by its ID",
8229
8236
  inputSchema: exports_external.object({
8230
8237
  triggerId: exports_external.string().describe("The trigger ID to retrieve")
@@ -8237,7 +8244,7 @@ function createTriggerTools(config, context) {
8237
8244
  return trigger;
8238
8245
  }
8239
8246
  },
8240
- update_trigger: {
8247
+ trigger_update: {
8241
8248
  description: "Update a trigger's properties like name, description, arguments, or schedule",
8242
8249
  inputSchema: exports_external.object({
8243
8250
  triggerId: exports_external.string().describe("The trigger ID to update"),
@@ -8264,7 +8271,7 @@ function createTriggerTools(config, context) {
8264
8271
  return callbacks.update(triggerId, updatesWithTimestamp, context);
8265
8272
  }
8266
8273
  },
8267
- delete_trigger: {
8274
+ trigger_delete: {
8268
8275
  description: "Delete a trigger permanently. This cannot be undone.",
8269
8276
  inputSchema: exports_external.object({
8270
8277
  triggerId: exports_external.string().describe("The trigger ID to delete")
@@ -8274,7 +8281,7 @@ function createTriggerTools(config, context) {
8274
8281
  return { success: true, message: `Trigger ${args.triggerId} deleted` };
8275
8282
  }
8276
8283
  },
8277
- pause_trigger: {
8284
+ trigger_pause: {
8278
8285
  description: "Pause a trigger to temporarily stop it from executing. Can be resumed later.",
8279
8286
  inputSchema: exports_external.object({
8280
8287
  triggerId: exports_external.string().describe("The trigger ID to pause")
@@ -8294,7 +8301,7 @@ function createTriggerTools(config, context) {
8294
8301
  }, context);
8295
8302
  }
8296
8303
  },
8297
- resume_trigger: {
8304
+ trigger_resume: {
8298
8305
  description: "Resume a paused trigger to start executing it again on schedule",
8299
8306
  inputSchema: exports_external.object({
8300
8307
  triggerId: exports_external.string().describe("The trigger ID to resume")
@@ -8321,6 +8328,508 @@ var init_trigger_tools = __esm(() => {
8321
8328
  init_utils2();
8322
8329
  });
8323
8330
 
8331
+ // ../code-mode/type-generator.ts
8332
+ function safeIdent(name) {
8333
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) || RESERVED_TS.has(name)) {
8334
+ return JSON.stringify(name);
8335
+ }
8336
+ return name;
8337
+ }
8338
+ function integrationFromToolName(toolName) {
8339
+ const idx = toolName.indexOf("_");
8340
+ return idx === -1 ? toolName : toolName.slice(0, idx);
8341
+ }
8342
+ function jsonSchemaToTs(schema, indent) {
8343
+ if (!schema || typeof schema !== "object")
8344
+ return "unknown";
8345
+ const s = schema;
8346
+ if (Array.isArray(s.enum) && s.enum.length > 0) {
8347
+ return s.enum.map((v) => typeof v === "string" ? JSON.stringify(v) : typeof v === "number" || typeof v === "boolean" ? String(v) : "unknown").join(" | ");
8348
+ }
8349
+ if (Array.isArray(s.type)) {
8350
+ return s.type.map((t2) => jsonSchemaToTs({ ...s, type: t2 }, indent)).join(" | ");
8351
+ }
8352
+ const t = s.type;
8353
+ switch (t) {
8354
+ case "string":
8355
+ return "string";
8356
+ case "number":
8357
+ case "integer":
8358
+ return "number";
8359
+ case "boolean":
8360
+ return "boolean";
8361
+ case "null":
8362
+ return "null";
8363
+ case "array": {
8364
+ const items = s.items;
8365
+ if (Array.isArray(items))
8366
+ return "unknown[]";
8367
+ const inner = jsonSchemaToTs(items, indent);
8368
+ return /[|&]/.test(inner) ? `Array<${inner}>` : `${inner}[]`;
8369
+ }
8370
+ case "object":
8371
+ return objectShape(s, indent);
8372
+ default:
8373
+ if (s.properties && typeof s.properties === "object")
8374
+ return objectShape(s, indent);
8375
+ return "unknown";
8376
+ }
8377
+ }
8378
+ function objectShape(schema, indent) {
8379
+ const props = schema.properties && typeof schema.properties === "object" ? schema.properties : {};
8380
+ const keys = Object.keys(props);
8381
+ if (keys.length === 0) {
8382
+ return schema.additionalProperties === false ? "Record<string, never>" : "Record<string, unknown>";
8383
+ }
8384
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
8385
+ const inner = indent + " ";
8386
+ const lines = ["{"];
8387
+ for (const key of keys) {
8388
+ const prop = props[key];
8389
+ const desc = prop && typeof prop.description === "string" ? prop.description : undefined;
8390
+ if (desc)
8391
+ lines.push(`${inner}/** ${desc.replace(/\*\//g, "*\\/")} */`);
8392
+ const optional = required.has(key) ? "" : "?";
8393
+ const type = jsonSchemaToTs(prop, inner);
8394
+ lines.push(`${inner}${safeIdent(key)}${optional}: ${type};`);
8395
+ }
8396
+ lines.push(`${indent}}`);
8397
+ return lines.join(`
8398
+ `);
8399
+ }
8400
+ function argsType(schema) {
8401
+ if (!schema)
8402
+ return "Record<string, unknown>";
8403
+ const hasProps = schema.properties && Object.keys(schema.properties).length > 0;
8404
+ if (!hasProps)
8405
+ return "Record<string, unknown>";
8406
+ return objectShape(schema, " ");
8407
+ }
8408
+ function methodHasRequiredArgs(schema) {
8409
+ if (!schema || !schema.properties)
8410
+ return false;
8411
+ const req = Array.isArray(schema.required) ? schema.required : [];
8412
+ return req.length > 0;
8413
+ }
8414
+ function formatDescription(desc, indent) {
8415
+ if (!desc)
8416
+ return "";
8417
+ const cleaned = desc.replace(/\*\//g, "*\\/").trim();
8418
+ if (!cleaned.includes(`
8419
+ `))
8420
+ return `${indent}/** ${cleaned} */
8421
+ `;
8422
+ const lines = cleaned.split(`
8423
+ `).map((l) => `${indent} * ${l}`).join(`
8424
+ `);
8425
+ return `${indent}/**
8426
+ ${lines}
8427
+ ${indent} */
8428
+ `;
8429
+ }
8430
+ function generateCodeModeTypes(tools) {
8431
+ const byIntegration = {};
8432
+ for (const tool of tools) {
8433
+ const integration = integrationFromToolName(tool.name);
8434
+ (byIntegration[integration] ??= []).push(tool);
8435
+ }
8436
+ const methodMap = {};
8437
+ const integrationCounts = {};
8438
+ const sections = [];
8439
+ const integrationIds = Object.keys(byIntegration).sort();
8440
+ sections.push("/**");
8441
+ sections.push(" * Integrate SDK — available APIs inside `execute_code`.");
8442
+ sections.push(" * Every method is async and returns the MCP tool-call response.");
8443
+ sections.push(" * Call them via the exported `client` object, e.g.");
8444
+ sections.push(" * const repos = await client.github.listRepos();");
8445
+ sections.push(" */");
8446
+ sections.push("");
8447
+ for (const integrationId of integrationIds) {
8448
+ const integrationTools = byIntegration[integrationId].slice().sort((a, b) => a.name.localeCompare(b.name));
8449
+ integrationCounts[integrationId] = integrationTools.length;
8450
+ const interfaceName = pascalCase(integrationId) + "Client";
8451
+ sections.push(`export interface ${interfaceName} {`);
8452
+ for (const tool of integrationTools) {
8453
+ const methodName = toolNameToMethod(tool.name);
8454
+ methodMap[`${integrationId}.${methodName}`] = tool.name;
8455
+ sections.push(formatDescription(tool.description, " "));
8456
+ const argType = argsType(tool.inputSchema);
8457
+ const argIsOptional = !methodHasRequiredArgs(tool.inputSchema);
8458
+ const paramName = argIsOptional ? "args?" : "args";
8459
+ sections.push(` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`);
8460
+ }
8461
+ sections.push("}");
8462
+ sections.push("");
8463
+ }
8464
+ sections.push("export interface ToolResult {");
8465
+ sections.push(" content: Array<{ type: 'text' | 'image' | 'resource'; text?: string; data?: string; mimeType?: string; [key: string]: unknown }>;");
8466
+ sections.push(" isError?: boolean;");
8467
+ sections.push(" structuredContent?: Record<string, unknown>;");
8468
+ sections.push("}");
8469
+ sections.push("");
8470
+ sections.push("export interface Client {");
8471
+ for (const integrationId of integrationIds) {
8472
+ const interfaceName = pascalCase(integrationId) + "Client";
8473
+ sections.push(` ${safeIdent(integrationId)}: ${interfaceName};`);
8474
+ }
8475
+ sections.push("}");
8476
+ sections.push("");
8477
+ sections.push("export declare const client: Client;");
8478
+ return {
8479
+ source: sections.filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join(`
8480
+ `),
8481
+ methodMap,
8482
+ integrationCounts
8483
+ };
8484
+ }
8485
+ function pascalCase(id) {
8486
+ return id.split(/[^A-Za-z0-9]/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("") || "Unknown";
8487
+ }
8488
+ var RESERVED_TS;
8489
+ var init_type_generator = __esm(() => {
8490
+ RESERVED_TS = new Set([
8491
+ "break",
8492
+ "case",
8493
+ "catch",
8494
+ "class",
8495
+ "const",
8496
+ "continue",
8497
+ "debugger",
8498
+ "default",
8499
+ "delete",
8500
+ "do",
8501
+ "else",
8502
+ "enum",
8503
+ "export",
8504
+ "extends",
8505
+ "false",
8506
+ "finally",
8507
+ "for",
8508
+ "function",
8509
+ "if",
8510
+ "import",
8511
+ "in",
8512
+ "instanceof",
8513
+ "new",
8514
+ "null",
8515
+ "return",
8516
+ "super",
8517
+ "switch",
8518
+ "this",
8519
+ "throw",
8520
+ "true",
8521
+ "try",
8522
+ "typeof",
8523
+ "var",
8524
+ "void",
8525
+ "while",
8526
+ "with",
8527
+ "as",
8528
+ "implements",
8529
+ "interface",
8530
+ "let",
8531
+ "package",
8532
+ "private",
8533
+ "protected",
8534
+ "public",
8535
+ "static",
8536
+ "yield"
8537
+ ]);
8538
+ });
8539
+
8540
+ // ../code-mode/runtime-stub.ts
8541
+ var RUNTIME_STUB_SOURCE = `// runtime.mjs — generated by integrate-sdk code mode
8542
+ const MCP_URL = process.env.INTEGRATE_MCP_URL;
8543
+ const SESSION_TOKEN = process.env.INTEGRATE_SESSION_TOKEN;
8544
+ const PROVIDER_TOKENS = process.env.INTEGRATE_PROVIDER_TOKENS || '';
8545
+ const INTEGRATIONS_HEADER = process.env.INTEGRATE_INTEGRATIONS || '';
8546
+ const CONTEXT_JSON = process.env.INTEGRATE_CONTEXT || '';
8547
+
8548
+ if (!MCP_URL) {
8549
+ throw new Error('INTEGRATE_MCP_URL is not set — the sandbox cannot reach the MCP route.');
8550
+ }
8551
+
8552
+ function camelToSnake(str) {
8553
+ return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
8554
+ }
8555
+
8556
+ async function callTool(toolName, args) {
8557
+ const headers = {
8558
+ 'Content-Type': 'application/json',
8559
+ 'x-integrate-code-mode': '1',
8560
+ };
8561
+ if (SESSION_TOKEN) headers['Authorization'] = 'Bearer ' + SESSION_TOKEN;
8562
+ if (PROVIDER_TOKENS) headers['x-integrate-tokens'] = PROVIDER_TOKENS;
8563
+ if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;
8564
+ if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;
8565
+
8566
+ const res = await fetch(MCP_URL, {
8567
+ method: 'POST',
8568
+ headers,
8569
+ body: JSON.stringify({ name: toolName, arguments: args || {} }),
8570
+ });
8571
+
8572
+ const text = await res.text();
8573
+ let payload;
8574
+ try {
8575
+ payload = text ? JSON.parse(text) : null;
8576
+ } catch {
8577
+ payload = { content: [{ type: 'text', text }] };
8578
+ }
8579
+
8580
+ if (!res.ok) {
8581
+ const message = (payload && (payload.error || payload.message)) || 'Tool call failed: HTTP ' + res.status;
8582
+ const err = new Error(message);
8583
+ err.status = res.status;
8584
+ err.toolName = toolName;
8585
+ throw err;
8586
+ }
8587
+
8588
+ return payload;
8589
+ }
8590
+
8591
+ function createIntegrationProxy(integrationId) {
8592
+ return new Proxy({}, {
8593
+ get(_target, methodName) {
8594
+ if (typeof methodName !== 'string') return undefined;
8595
+ return (args) => callTool(integrationId + '_' + camelToSnake(methodName), args);
8596
+ },
8597
+ });
8598
+ }
8599
+
8600
+ export const client = new Proxy({}, {
8601
+ get(_target, integrationId) {
8602
+ if (typeof integrationId !== 'string') return undefined;
8603
+ return createIntegrationProxy(integrationId);
8604
+ },
8605
+ });
8606
+
8607
+ export { callTool };
8608
+ `;
8609
+
8610
+ // ../code-mode/executor.ts
8611
+ var exports_executor = {};
8612
+ __export(exports_executor, {
8613
+ executeSandboxCode: () => executeSandboxCode,
8614
+ __setSandboxFactoryForTests: () => __setSandboxFactoryForTests
8615
+ });
8616
+ function __setSandboxFactoryForTests(factory) {
8617
+ sandboxFactoryOverride = factory;
8618
+ }
8619
+ async function loadSandboxFactory() {
8620
+ if (sandboxFactoryOverride)
8621
+ return sandboxFactoryOverride;
8622
+ try {
8623
+ const dynamicImport = new Function("specifier", "return import(specifier)");
8624
+ const pkg = "@" + "vercel/sandbox";
8625
+ const mod = await dynamicImport(pkg);
8626
+ return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
8627
+ } catch (err) {
8628
+ throw new Error("Code Mode requires the optional peer dependency `@vercel/sandbox`. " + "Install it with `npm install @vercel/sandbox` (or `bun add @vercel/sandbox`).");
8629
+ }
8630
+ }
8631
+ function wrapUserCode(code) {
8632
+ return `// user.mjs — wrapped by integrate-sdk code mode
8633
+ import { client, callTool } from './runtime.mjs';
8634
+
8635
+ (async () => {
8636
+ try {
8637
+ const __result = await (async () => {
8638
+ ${code}
8639
+ })();
8640
+ if (typeof __result !== 'undefined') {
8641
+ process.stdout.write('\\n' + ${JSON.stringify(RESULT_SENTINEL)} + JSON.stringify(__result) + '\\n');
8642
+ }
8643
+ } catch (err) {
8644
+ const payload = {
8645
+ message: err && err.message ? err.message : String(err),
8646
+ name: err && err.name,
8647
+ stack: err && err.stack,
8648
+ toolName: err && err.toolName,
8649
+ status: err && err.status,
8650
+ };
8651
+ process.stderr.write('\\n' + ${JSON.stringify(RESULT_SENTINEL)} + JSON.stringify({ error: payload }) + '\\n');
8652
+ process.exit(1);
8653
+ }
8654
+ })();
8655
+ `;
8656
+ }
8657
+ function defaultNetworkPolicy(mcpUrl) {
8658
+ try {
8659
+ const host = new URL(mcpUrl).hostname;
8660
+ return { allow: [host] };
8661
+ } catch {
8662
+ return { allow: [] };
8663
+ }
8664
+ }
8665
+ function extractResult(stream) {
8666
+ const idx = stream.lastIndexOf(RESULT_SENTINEL);
8667
+ if (idx === -1)
8668
+ return { cleaned: stream };
8669
+ const before = stream.slice(0, idx).replace(/\n$/, "");
8670
+ const rest = stream.slice(idx + RESULT_SENTINEL.length);
8671
+ const newlineIdx = rest.indexOf(`
8672
+ `);
8673
+ const payload = newlineIdx === -1 ? rest : rest.slice(0, newlineIdx);
8674
+ const after = newlineIdx === -1 ? "" : rest.slice(newlineIdx + 1);
8675
+ try {
8676
+ return { cleaned: (before + after).trimEnd(), result: JSON.parse(payload) };
8677
+ } catch {
8678
+ return { cleaned: stream };
8679
+ }
8680
+ }
8681
+ async function executeSandboxCode(options) {
8682
+ const startedAt = Date.now();
8683
+ const runtime = options.runtime ?? "node22";
8684
+ const timeoutMs = options.timeoutMs ?? 60000;
8685
+ const networkPolicy = options.networkPolicy ?? defaultNetworkPolicy(options.mcpUrl);
8686
+ let sandbox = null;
8687
+ try {
8688
+ const Sandbox = await loadSandboxFactory();
8689
+ sandbox = await Sandbox.create({
8690
+ runtime,
8691
+ timeout: timeoutMs,
8692
+ resources: options.vcpus ? { vcpus: options.vcpus } : undefined,
8693
+ networkPolicy
8694
+ });
8695
+ const runtimeContent = Buffer.from(RUNTIME_STUB_SOURCE, "utf-8");
8696
+ const userContent = Buffer.from(wrapUserCode(options.code), "utf-8");
8697
+ await sandbox.writeFiles([
8698
+ { path: "runtime.mjs", content: runtimeContent },
8699
+ { path: "user.mjs", content: userContent }
8700
+ ]);
8701
+ const env = {
8702
+ INTEGRATE_MCP_URL: options.mcpUrl
8703
+ };
8704
+ if (options.sessionToken)
8705
+ env.INTEGRATE_SESSION_TOKEN = options.sessionToken;
8706
+ if (options.providerTokens && Object.keys(options.providerTokens).length > 0) {
8707
+ env.INTEGRATE_PROVIDER_TOKENS = JSON.stringify(options.providerTokens);
8708
+ }
8709
+ if (options.integrationsHeader)
8710
+ env.INTEGRATE_INTEGRATIONS = options.integrationsHeader;
8711
+ if (options.context)
8712
+ env.INTEGRATE_CONTEXT = JSON.stringify(options.context);
8713
+ const cmd = await sandbox.runCommand({
8714
+ cmd: "node",
8715
+ args: ["user.mjs"],
8716
+ env
8717
+ });
8718
+ const [stdoutRaw, stderrRaw] = await Promise.all([cmd.stdout(), cmd.stderr()]);
8719
+ const stdoutExtract = extractResult(stdoutRaw);
8720
+ const stderrExtract = extractResult(stderrRaw);
8721
+ return {
8722
+ success: cmd.exitCode === 0,
8723
+ exitCode: cmd.exitCode,
8724
+ result: stdoutExtract.result ?? stderrExtract.result,
8725
+ stdout: stdoutExtract.cleaned,
8726
+ stderr: stderrExtract.cleaned,
8727
+ durationMs: Date.now() - startedAt
8728
+ };
8729
+ } catch (err) {
8730
+ return {
8731
+ success: false,
8732
+ exitCode: -1,
8733
+ stdout: "",
8734
+ stderr: "",
8735
+ durationMs: Date.now() - startedAt,
8736
+ error: err instanceof Error ? err.message : String(err)
8737
+ };
8738
+ } finally {
8739
+ if (sandbox) {
8740
+ try {
8741
+ await sandbox.stop();
8742
+ } catch {}
8743
+ }
8744
+ }
8745
+ }
8746
+ var sandboxFactoryOverride = null, RESULT_SENTINEL = "__INTEGRATE_RESULT__";
8747
+ var init_executor = () => {};
8748
+
8749
+ // ../code-mode/tool-builder.ts
8750
+ function resolveCodeModeClientConfig(client) {
8751
+ const oauthConfig = client.__oauthConfig;
8752
+ return oauthConfig?.codeMode ?? {};
8753
+ }
8754
+ function buildCodeModeTool(client, options) {
8755
+ const { tools, providerTokens, context, integrationIds } = options;
8756
+ const generated = generateCodeModeTypes(tools);
8757
+ const serverCodeModeConfig = resolveCodeModeClientConfig(client);
8758
+ const sandboxOverrides = options.sandbox ?? {};
8759
+ const description = `${DEFAULT_INSTRUCTIONS}
8760
+
8761
+ \`\`\`typescript
8762
+ ${generated.source}
8763
+ \`\`\``;
8764
+ const execute = async ({ code }) => {
8765
+ const publicUrl = sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl ?? getEnv("INTEGRATE_PUBLIC_URL");
8766
+ if (!publicUrl) {
8767
+ return {
8768
+ success: false,
8769
+ exitCode: -1,
8770
+ stdout: "",
8771
+ stderr: "",
8772
+ durationMs: 0,
8773
+ error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_PUBLIC_URL env var). " + "The sandbox uses it to call back into /api/integrate/mcp."
8774
+ };
8775
+ }
8776
+ const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
8777
+ return executeSandboxCode({
8778
+ code,
8779
+ mcpUrl,
8780
+ providerTokens,
8781
+ context,
8782
+ integrationsHeader: integrationIds && integrationIds.length > 0 ? integrationIds.join(",") : undefined,
8783
+ runtime: sandboxOverrides.runtime ?? serverCodeModeConfig.runtime,
8784
+ timeoutMs: sandboxOverrides.timeoutMs ?? serverCodeModeConfig.timeoutMs,
8785
+ vcpus: sandboxOverrides.vcpus ?? serverCodeModeConfig.vcpus,
8786
+ networkPolicy: sandboxOverrides.networkPolicy ?? serverCodeModeConfig.networkPolicy
8787
+ });
8788
+ };
8789
+ return {
8790
+ name: CODE_MODE_TOOL_NAME,
8791
+ description,
8792
+ parameters: {
8793
+ type: "object",
8794
+ properties: {
8795
+ code: {
8796
+ type: "string",
8797
+ description: "The TypeScript/JavaScript snippet to execute. It is wrapped in an async IIFE, so you may use top-level await and return a final value."
8798
+ }
8799
+ },
8800
+ required: ["code"],
8801
+ additionalProperties: false
8802
+ },
8803
+ execute
8804
+ };
8805
+ }
8806
+ var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS;
8807
+ var init_tool_builder = __esm(() => {
8808
+ init_type_generator();
8809
+ init_executor();
8810
+ DEFAULT_INSTRUCTIONS = [
8811
+ "You are given a single tool: `execute_code`. Instead of calling individual MCP tools,",
8812
+ "you write a short async TypeScript/JavaScript snippet that uses the typed `client`",
8813
+ "object below, and the snippet runs in an isolated sandbox which dispatches the actual",
8814
+ "tool calls. Chain multiple operations together in one snippet whenever possible —",
8815
+ "that is the whole point of this tool.",
8816
+ "",
8817
+ "Rules:",
8818
+ "- The snippet is the body of an `async` function. Use `await` freely.",
8819
+ "- Use `return <value>` at the end to hand a structured result back to the caller;",
8820
+ " the caller receives it as JSON.",
8821
+ "- Use `console.log(...)` for intermediate observations you want to read later.",
8822
+ "- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
8823
+ "- Each method call returns an object of shape `ToolResult` (see types below).",
8824
+ " The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
8825
+ "- You cannot import npm packages. Only the pre-imported `client` and standard",
8826
+ " globals (`fetch`, `console`, `JSON`, ...) are available.",
8827
+ "",
8828
+ "API surface:"
8829
+ ].join(`
8830
+ `);
8831
+ });
8832
+
8324
8833
  // ../ai/vercel-ai.ts
8325
8834
  function convertMCPToolToVercelAI(mcpTool, client, options) {
8326
8835
  return {
@@ -8345,8 +8854,25 @@ async function getVercelAITools(client, options) {
8345
8854
  await ensureClientConnected(client);
8346
8855
  const mcpTools = await client.getEnabledToolsAsync();
8347
8856
  const vercelTools = {};
8348
- for (const mcpTool of mcpTools) {
8349
- vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
8857
+ const mode = options?.mode ?? "code";
8858
+ if (mode === "code") {
8859
+ const codeTool = buildCodeModeTool(client, {
8860
+ tools: mcpTools,
8861
+ providerTokens,
8862
+ context: options?.context,
8863
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id) ?? client.integrations?.map?.((i) => i.id)
8864
+ });
8865
+ vercelTools[CODE_MODE_TOOL_NAME] = {
8866
+ description: codeTool.description,
8867
+ inputSchema: exports_external.object({
8868
+ code: exports_external.string().describe(codeTool.parameters.properties.code.description)
8869
+ }),
8870
+ execute: async (args) => codeTool.execute(args)
8871
+ };
8872
+ } else {
8873
+ for (const mcpTool of mcpTools) {
8874
+ vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
8875
+ }
8350
8876
  }
8351
8877
  const triggerConfig = client.__triggerConfig;
8352
8878
  if (triggerConfig) {
@@ -8356,8 +8882,10 @@ async function getVercelAITools(client, options) {
8356
8882
  return vercelTools;
8357
8883
  }
8358
8884
  var init_vercel_ai = __esm(() => {
8885
+ init_zod();
8359
8886
  init_utils();
8360
8887
  init_trigger_tools();
8888
+ init_tool_builder();
8361
8889
  });
8362
8890
 
8363
8891
  // ../../node_modules/zod-to-json-schema/dist/esm/Options.js
@@ -9785,7 +10313,22 @@ async function getOpenAITools(client, options) {
9785
10313
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
9786
10314
  await ensureClientConnected(client);
9787
10315
  const mcpTools = await client.getEnabledToolsAsync();
9788
- const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
10316
+ const mode = options?.mode ?? "code";
10317
+ const openaiTools = mode === "code" ? (() => {
10318
+ const codeTool = buildCodeModeTool(client, {
10319
+ tools: mcpTools,
10320
+ providerTokens,
10321
+ context: options?.context,
10322
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10323
+ });
10324
+ return [{
10325
+ type: "function",
10326
+ name: CODE_MODE_TOOL_NAME,
10327
+ description: codeTool.description,
10328
+ parameters: codeTool.parameters,
10329
+ strict: options?.strict ?? null
10330
+ }];
10331
+ })() : mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
9789
10332
  const triggerConfig = client.__triggerConfig;
9790
10333
  if (triggerConfig) {
9791
10334
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
@@ -9810,6 +10353,19 @@ async function handleOpenAIToolCalls(client, toolCalls, options) {
9810
10353
  const toolOutputs = [];
9811
10354
  const triggerConfig = client.__triggerConfig;
9812
10355
  const triggerTools = triggerConfig ? createTriggerTools(triggerConfig, options?.context) : null;
10356
+ let cachedCodeModeTool = null;
10357
+ const getCodeModeTool = async () => {
10358
+ if (cachedCodeModeTool)
10359
+ return cachedCodeModeTool;
10360
+ const mcpTools = await client.getEnabledToolsAsync();
10361
+ cachedCodeModeTool = buildCodeModeTool(client, {
10362
+ tools: mcpTools,
10363
+ providerTokens: options?.providerTokens,
10364
+ context: options?.context,
10365
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10366
+ });
10367
+ return cachedCodeModeTool;
10368
+ };
9813
10369
  for (const output of toolCalls) {
9814
10370
  if (output.type === "function_call") {
9815
10371
  const toolCall = {
@@ -9820,7 +10376,10 @@ async function handleOpenAIToolCalls(client, toolCalls, options) {
9820
10376
  try {
9821
10377
  const args = JSON.parse(toolCall.arguments);
9822
10378
  let result;
9823
- if (triggerTools && triggerTools[toolCall.name]) {
10379
+ if (toolCall.name === CODE_MODE_TOOL_NAME) {
10380
+ const codeTool = await getCodeModeTool();
10381
+ result = await codeTool.execute(args);
10382
+ } else if (triggerTools && triggerTools[toolCall.name]) {
9824
10383
  result = await triggerTools[toolCall.name].execute(args);
9825
10384
  } else {
9826
10385
  result = await executeToolWithToken(client, toolCall.name, args, options);
@@ -9861,6 +10420,7 @@ async function handleOpenAIResponse(client, response, options) {
9861
10420
  var init_openai = __esm(() => {
9862
10421
  init_utils();
9863
10422
  init_trigger_tools();
10423
+ init_tool_builder();
9864
10424
  init_esm();
9865
10425
  });
9866
10426
 
@@ -9880,11 +10440,27 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
9880
10440
  const toolResults = [];
9881
10441
  const triggerConfig = client.__triggerConfig;
9882
10442
  const triggerTools = triggerConfig ? createTriggerTools(triggerConfig, options?.context) : null;
10443
+ let cachedCodeModeTool = null;
10444
+ const getCodeModeTool = async () => {
10445
+ if (cachedCodeModeTool)
10446
+ return cachedCodeModeTool;
10447
+ const mcpTools = await client.getEnabledToolsAsync();
10448
+ cachedCodeModeTool = buildCodeModeTool(client, {
10449
+ tools: mcpTools,
10450
+ providerTokens: options?.providerTokens,
10451
+ context: options?.context,
10452
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10453
+ });
10454
+ return cachedCodeModeTool;
10455
+ };
9883
10456
  const toolUseBlocks = messageContent.filter((block) => block.type === "tool_use" && ("id" in block) && ("name" in block) && ("input" in block));
9884
10457
  for (const toolUse of toolUseBlocks) {
9885
10458
  try {
9886
10459
  let result;
9887
- if (triggerTools && triggerTools[toolUse.name]) {
10460
+ if (toolUse.name === CODE_MODE_TOOL_NAME) {
10461
+ const codeTool = await getCodeModeTool();
10462
+ result = await codeTool.execute(toolUse.input);
10463
+ } else if (triggerTools && triggerTools[toolUse.name]) {
9888
10464
  result = await triggerTools[toolUse.name].execute(toolUse.input);
9889
10465
  } else {
9890
10466
  result = await executeToolWithToken(client, toolUse.name, toolUse.input, options);
@@ -9917,7 +10493,24 @@ async function getAnthropicTools(client, options) {
9917
10493
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
9918
10494
  await ensureClientConnected(client);
9919
10495
  const mcpTools = await client.getEnabledToolsAsync();
9920
- const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
10496
+ const mode = options?.mode ?? "code";
10497
+ const anthropicTools = mode === "code" ? (() => {
10498
+ const codeTool = buildCodeModeTool(client, {
10499
+ tools: mcpTools,
10500
+ providerTokens,
10501
+ context: options?.context,
10502
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10503
+ });
10504
+ return [{
10505
+ name: CODE_MODE_TOOL_NAME,
10506
+ description: codeTool.description,
10507
+ input_schema: {
10508
+ type: "object",
10509
+ properties: codeTool.parameters.properties,
10510
+ required: [...codeTool.parameters.required]
10511
+ }
10512
+ }];
10513
+ })() : mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
9921
10514
  const triggerConfig = client.__triggerConfig;
9922
10515
  if (triggerConfig) {
9923
10516
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
@@ -9962,6 +10555,7 @@ async function handleAnthropicMessage(client, message, options) {
9962
10555
  var init_anthropic = __esm(() => {
9963
10556
  init_utils();
9964
10557
  init_trigger_tools();
10558
+ init_tool_builder();
9965
10559
  init_esm();
9966
10560
  });
9967
10561
 
@@ -10047,13 +10641,29 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
10047
10641
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
10048
10642
  const triggerConfig = client.__triggerConfig;
10049
10643
  const triggerTools = triggerConfig ? createTriggerTools(triggerConfig, options?.context) : null;
10644
+ let cachedCodeModeTool = null;
10645
+ const getCodeModeTool = async () => {
10646
+ if (cachedCodeModeTool)
10647
+ return cachedCodeModeTool;
10648
+ const mcpTools = await client.getEnabledToolsAsync();
10649
+ cachedCodeModeTool = buildCodeModeTool(client, {
10650
+ tools: mcpTools,
10651
+ providerTokens: finalOptions?.providerTokens,
10652
+ context: options?.context,
10653
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10654
+ });
10655
+ return cachedCodeModeTool;
10656
+ };
10050
10657
  const results = await Promise.all(functionCalls.map(async (call) => {
10051
10658
  if (!call?.name) {
10052
10659
  throw new Error("Function call must have a name");
10053
10660
  }
10054
10661
  const args = call.args || {};
10055
10662
  let result;
10056
- if (triggerTools && triggerTools[call.name]) {
10663
+ if (call.name === CODE_MODE_TOOL_NAME) {
10664
+ const codeTool = await getCodeModeTool();
10665
+ result = await codeTool.execute(args);
10666
+ } else if (triggerTools && triggerTools[call.name]) {
10057
10667
  result = await triggerTools[call.name].execute(args);
10058
10668
  } else {
10059
10669
  result = await executeToolWithToken(client, call.name, args, finalOptions);
@@ -10072,7 +10682,33 @@ async function getGoogleTools(client, options) {
10072
10682
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
10073
10683
  await ensureClientConnected(client);
10074
10684
  const mcpTools = await client.getEnabledToolsAsync();
10075
- const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
10685
+ const mode = options?.mode ?? "code";
10686
+ let googleTools;
10687
+ if (mode === "code") {
10688
+ const TypeEnum = await getGoogleType();
10689
+ const codeTool = buildCodeModeTool(client, {
10690
+ tools: mcpTools,
10691
+ providerTokens,
10692
+ context: options?.context,
10693
+ integrationIds: client.__oauthConfig?.integrations?.map((i) => i.id)
10694
+ });
10695
+ googleTools = [{
10696
+ name: CODE_MODE_TOOL_NAME,
10697
+ description: codeTool.description,
10698
+ parameters: {
10699
+ type: TypeEnum.OBJECT,
10700
+ properties: {
10701
+ code: {
10702
+ type: TypeEnum.STRING,
10703
+ description: codeTool.parameters.properties.code.description
10704
+ }
10705
+ },
10706
+ required: ["code"]
10707
+ }
10708
+ }];
10709
+ } else {
10710
+ googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
10711
+ }
10076
10712
  const triggerConfig = client.__triggerConfig;
10077
10713
  if (triggerConfig) {
10078
10714
  const triggerTools = createTriggerTools(triggerConfig, options?.context);
@@ -10150,6 +10786,7 @@ function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
10150
10786
  var init_google = __esm(() => {
10151
10787
  init_utils();
10152
10788
  init_trigger_tools();
10789
+ init_tool_builder();
10153
10790
  init_esm();
10154
10791
  });
10155
10792
 
@@ -10215,8 +10852,8 @@ var init_webhooks = __esm(() => {
10215
10852
  var MAX_TRIGGER_STEPS = 20, WEBHOOK_DELIVERY_TIMEOUT_MS = 1e4;
10216
10853
 
10217
10854
  // ../triggers/executor.ts
10218
- var exports_executor = {};
10219
- __export(exports_executor, {
10855
+ var exports_executor2 = {};
10856
+ __export(exports_executor2, {
10220
10857
  executeTrigger: () => executeTrigger
10221
10858
  });
10222
10859
  async function executeTrigger(trigger, config, context) {
@@ -10363,7 +11000,7 @@ async function executeTrigger(trigger, config, context) {
10363
11000
  return { success: false, steps, error: limitError };
10364
11001
  }
10365
11002
  var logger30;
10366
- var init_executor = __esm(() => {
11003
+ var init_executor2 = __esm(() => {
10367
11004
  init_logger();
10368
11005
  init_utils2();
10369
11006
  init_webhooks();
@@ -10508,7 +11145,8 @@ function createMCPServer(config) {
10508
11145
  integrations: updatedIntegrations,
10509
11146
  getSessionContext: config.getSessionContext,
10510
11147
  setProviderToken: config.setProviderToken,
10511
- removeProviderToken: config.removeProviderToken
11148
+ removeProviderToken: config.removeProviderToken,
11149
+ codeMode: config.codeMode
10512
11150
  };
10513
11151
  client.__triggerConfig = config.triggers ? {
10514
11152
  callbacks: config.triggers,
@@ -10578,8 +11216,21 @@ function createMCPServer(config) {
10578
11216
  if (action === "mcp" && method === "POST") {
10579
11217
  try {
10580
11218
  const body = await webRequest.json();
10581
- const authHeader = webRequest.headers.get("authorization");
11219
+ let authHeader = webRequest.headers.get("authorization");
10582
11220
  const integrationsHeader = webRequest.headers.get("x-integrations");
11221
+ if (!authHeader) {
11222
+ const tokensHeader = webRequest.headers.get("x-integrate-tokens");
11223
+ const toolName = typeof body?.name === "string" ? body.name : "";
11224
+ if (tokensHeader && toolName) {
11225
+ try {
11226
+ const tokens = JSON.parse(tokensHeader);
11227
+ const provider = toolName.split("_")[0];
11228
+ if (provider && tokens[provider]) {
11229
+ authHeader = `Bearer ${tokens[provider]}`;
11230
+ }
11231
+ } catch {}
11232
+ }
11233
+ }
10583
11234
  const { OAuthHandler } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
10584
11235
  const oauthHandler = new OAuthHandler({
10585
11236
  providers,
@@ -10600,6 +11251,53 @@ function createMCPServer(config) {
10600
11251
  return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
10601
11252
  }
10602
11253
  }
11254
+ if (action === "code" && method === "POST") {
11255
+ try {
11256
+ const body = await webRequest.json();
11257
+ if (typeof body?.code !== "string" || body.code.length === 0) {
11258
+ return Response.json({ error: "`code` is required and must be a non-empty string." }, { status: 400 });
11259
+ }
11260
+ const { executeSandboxCode: executeSandboxCode2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
11261
+ const codeModeConfig = config.codeMode ?? {};
11262
+ const publicUrl = codeModeConfig.publicUrl ?? getEnv("INTEGRATE_PUBLIC_URL");
11263
+ if (!publicUrl) {
11264
+ return Response.json({
11265
+ error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_PUBLIC_URL env var). Set it to the public origin where /api/integrate/mcp is reachable."
11266
+ }, { status: 500 });
11267
+ }
11268
+ let contextOverride = body.context;
11269
+ if (!contextOverride && config.getSessionContext) {
11270
+ try {
11271
+ contextOverride = await config.getSessionContext(webRequest);
11272
+ } catch {}
11273
+ }
11274
+ let providerTokens = body.providerTokens;
11275
+ if (!providerTokens) {
11276
+ const headerTokens = webRequest.headers.get("x-integrate-tokens");
11277
+ if (headerTokens) {
11278
+ try {
11279
+ providerTokens = JSON.parse(headerTokens);
11280
+ } catch {}
11281
+ }
11282
+ }
11283
+ const integrationIds = updatedIntegrations.map((i) => i.id);
11284
+ const result = await executeSandboxCode2({
11285
+ code: body.code,
11286
+ mcpUrl: publicUrl.replace(/\/$/, "") + "/api/integrate/mcp",
11287
+ providerTokens,
11288
+ context: contextOverride,
11289
+ integrationsHeader: integrationIds.join(","),
11290
+ runtime: codeModeConfig.runtime,
11291
+ timeoutMs: codeModeConfig.timeoutMs,
11292
+ vcpus: codeModeConfig.vcpus,
11293
+ networkPolicy: codeModeConfig.networkPolicy
11294
+ });
11295
+ return Response.json(result, { status: result.success ? 200 : 500 });
11296
+ } catch (error) {
11297
+ logger31.error("[Code Mode] Error:", error);
11298
+ return Response.json({ error: error?.message || "Failed to execute code" }, { status: 500 });
11299
+ }
11300
+ }
10603
11301
  if (action === "integrations" && method === "GET") {
10604
11302
  const integrations = updatedIntegrations.map((integration) => ({
10605
11303
  id: integration.id,
@@ -10635,7 +11333,7 @@ function createMCPServer(config) {
10635
11333
  return Response.json({ error: "Trigger has no provider configured" }, { status: 400 });
10636
11334
  }
10637
11335
  const triggerContext = trigger.userId ? { userId: trigger.userId } : undefined;
10638
- const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
11336
+ const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor2(), exports_executor2));
10639
11337
  const { OAuthHandler } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
10640
11338
  const oauthHandler = new OAuthHandler({
10641
11339
  providers,
@@ -10798,7 +11496,7 @@ function createMCPServer(config) {
10798
11496
  if (!trigger.provider) {
10799
11497
  return Response.json({ error: "Trigger has no provider configured" }, { status: 400 });
10800
11498
  }
10801
- const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
11499
+ const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor2(), exports_executor2));
10802
11500
  const { OAuthHandler } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
10803
11501
  const oauthHandler = new OAuthHandler({
10804
11502
  providers,