integrate-sdk 0.9.17-dev.0 → 0.9.18-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.
@@ -4584,6 +4584,8 @@ function generateCodeModeTypes(tools) {
4584
4584
  const methodMap = {};
4585
4585
  const integrationCounts = {};
4586
4586
  const sections = [];
4587
+ const compactLines = [];
4588
+ const perIntegration = {};
4587
4589
  const integrationIds = Object.keys(byIntegration).sort();
4588
4590
  sections.push("/**");
4589
4591
  sections.push(" * Integrate SDK — available APIs inside `execute_code`.");
@@ -4596,18 +4598,35 @@ function generateCodeModeTypes(tools) {
4596
4598
  const integrationTools = byIntegration[integrationId].slice().sort((a, b) => a.name.localeCompare(b.name));
4597
4599
  integrationCounts[integrationId] = integrationTools.length;
4598
4600
  const interfaceName = pascalCase(integrationId) + "Client";
4601
+ const fullSections = [];
4602
+ fullSections.push(`export interface ${interfaceName} {`);
4599
4603
  sections.push(`export interface ${interfaceName} {`);
4604
+ const compactMethods = [];
4600
4605
  for (const tool of integrationTools) {
4601
4606
  const methodName = toolNameToMethod(tool.name);
4602
4607
  methodMap[`${integrationId}.${methodName}`] = tool.name;
4603
- sections.push(formatDescription(tool.description, " "));
4608
+ const fullDesc = formatDescription(tool.description, " ");
4609
+ fullSections.push(fullDesc);
4610
+ sections.push(fullDesc);
4604
4611
  const argType = argsType(tool.inputSchema);
4605
4612
  const argIsOptional = !methodHasRequiredArgs(tool.inputSchema);
4606
4613
  const paramName = argIsOptional ? "args?" : "args";
4607
- sections.push(` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`);
4614
+ const fullLine = ` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`;
4615
+ fullSections.push(fullLine);
4616
+ sections.push(fullLine);
4617
+ const compactArgs = compactArgsSignature(tool.inputSchema);
4618
+ const compactParam = argIsOptional ? `args?: ${compactArgs}` : `args: ${compactArgs}`;
4619
+ compactMethods.push(` ${safeIdent(methodName)}(${compactParam}): Promise<ToolResult>`);
4608
4620
  }
4609
4621
  sections.push("}");
4610
4622
  sections.push("");
4623
+ fullSections.push("}");
4624
+ perIntegration[integrationId] = fullSections.join(`
4625
+ `);
4626
+ compactLines.push(`client.${integrationId}:`);
4627
+ for (const m of compactMethods) {
4628
+ compactLines.push(m);
4629
+ }
4611
4630
  }
4612
4631
  sections.push("export interface ToolResult {");
4613
4632
  sections.push(" content: Array<{ type: 'text' | 'image' | 'resource'; text?: string; data?: string; mimeType?: string; [key: string]: unknown }>;");
@@ -4625,11 +4644,22 @@ function generateCodeModeTypes(tools) {
4625
4644
  sections.push("export declare const client: Client;");
4626
4645
  return {
4627
4646
  source: sections.filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join(`
4647
+ `),
4648
+ compact: compactLines.join(`
4628
4649
  `),
4629
4650
  methodMap,
4630
- integrationCounts
4651
+ integrationCounts,
4652
+ perIntegration
4631
4653
  };
4632
4654
  }
4655
+ function compactArgsSignature(schema) {
4656
+ if (!schema || !schema.properties || Object.keys(schema.properties).length === 0) {
4657
+ return "{}";
4658
+ }
4659
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
4660
+ const params = Object.keys(schema.properties).map((key) => `${safeIdent(key)}${required.has(key) ? "" : "?"}`);
4661
+ return `{ ${params.join(", ")} }`;
4662
+ }
4633
4663
  function pascalCase(id) {
4634
4664
  return id.split(/[^A-Za-z0-9]/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("") || "Unknown";
4635
4665
  }
@@ -4903,25 +4933,16 @@ function getEnv(key) {
4903
4933
 
4904
4934
  // ../code-mode/tool-builder.ts
4905
4935
  var CODE_MODE_TOOL_NAME = "execute_code";
4936
+ var TYPES_TOOL_NAME = "get_integration_types";
4906
4937
  var DEFAULT_INSTRUCTIONS = [
4907
- "You are given a single tool: `execute_code`. Instead of calling individual MCP tools,",
4908
- "you write a short async TypeScript/JavaScript snippet that uses the typed `client`",
4909
- "object below, and the snippet runs in an isolated sandbox which dispatches the actual",
4910
- "tool calls. Chain multiple operations together in one snippet whenever possible —",
4911
- "that is the whole point of this tool.",
4938
+ "Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
4939
+ "Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
4940
+ "Each method returns `ToolResult { content: [{ type, text? }], isError? }` parse `result.content[0].text` as JSON.",
4941
+ "Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
4912
4942
  "",
4913
- "Rules:",
4914
- "- The snippet is the body of an `async` function. Use `await` freely.",
4915
- "- Use `return <value>` at the end to hand a structured result back to the caller;",
4916
- " the caller receives it as JSON.",
4917
- "- Use `console.log(...)` for intermediate observations you want to read later.",
4918
- "- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
4919
- "- Each method call returns an object of shape `ToolResult` (see types below).",
4920
- " The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
4921
- "- You cannot import npm packages. Only the pre-imported `client` and standard",
4922
- " globals (`fetch`, `console`, `JSON`, ...) are available.",
4943
+ "Call `get_integration_types` with an integration name to get full parameter types before writing code.",
4923
4944
  "",
4924
- "API surface:"
4945
+ "Available methods:"
4925
4946
  ].join(`
4926
4947
  `);
4927
4948
  function resolveCodeModeClientConfig(client) {
@@ -4963,10 +4984,7 @@ function buildCodeModeTool(client, options) {
4963
4984
  const serverCodeModeConfig = resolveCodeModeClientConfig(client);
4964
4985
  const sandboxOverrides = options.sandbox ?? {};
4965
4986
  const description = `${DEFAULT_INSTRUCTIONS}
4966
-
4967
- \`\`\`typescript
4968
- ${generated.source}
4969
- \`\`\``;
4987
+ ${generated.compact}`;
4970
4988
  const execute = async ({ code }) => {
4971
4989
  const publicUrl = resolveCodeModePublicUrl({
4972
4990
  publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
@@ -4996,7 +5014,8 @@ ${generated.source}
4996
5014
  networkPolicy: sandboxOverrides.networkPolicy ?? serverCodeModeConfig.networkPolicy
4997
5015
  });
4998
5016
  };
4999
- return {
5017
+ const availableIntegrations = Object.keys(generated.perIntegration);
5018
+ const codeTool = {
5000
5019
  name: CODE_MODE_TOOL_NAME,
5001
5020
  description,
5002
5021
  parameters: {
@@ -5012,6 +5031,29 @@ ${generated.source}
5012
5031
  },
5013
5032
  execute
5014
5033
  };
5034
+ const typesTool = {
5035
+ name: TYPES_TOOL_NAME,
5036
+ description: "Get full TypeScript type definitions (method signatures, parameter types, JSDoc) for a specific integration. " + `Available integrations: ${availableIntegrations.join(", ")}.`,
5037
+ parameters: {
5038
+ type: "object",
5039
+ properties: {
5040
+ integration: {
5041
+ type: "string",
5042
+ description: `Integration name to get types for (${availableIntegrations.join(", ")}).`
5043
+ }
5044
+ },
5045
+ required: ["integration"],
5046
+ additionalProperties: false
5047
+ },
5048
+ execute: ({ integration }) => {
5049
+ const types2 = generated.perIntegration[integration];
5050
+ if (!types2) {
5051
+ return { error: `Unknown integration "${integration}".`, available: availableIntegrations };
5052
+ }
5053
+ return { types: types2 };
5054
+ }
5055
+ };
5056
+ return { codeTool, typesTool };
5015
5057
  }
5016
5058
 
5017
5059
  // vercel-ai.ts
@@ -5051,7 +5093,7 @@ async function getVercelAITools(client, options) {
5051
5093
  }
5052
5094
  }
5053
5095
  if (effectiveMode === "code") {
5054
- const codeTool = buildCodeModeTool(client, {
5096
+ const { codeTool, typesTool } = buildCodeModeTool(client, {
5055
5097
  tools: mcpTools,
5056
5098
  providerTokens,
5057
5099
  context: options?.context,
@@ -5064,6 +5106,13 @@ async function getVercelAITools(client, options) {
5064
5106
  }),
5065
5107
  execute: async (args) => codeTool.execute(args)
5066
5108
  };
5109
+ vercelTools[TYPES_TOOL_NAME] = {
5110
+ description: typesTool.description,
5111
+ inputSchema: exports_external.object({
5112
+ integration: exports_external.string().describe(typesTool.parameters.properties.integration.description)
5113
+ }),
5114
+ execute: async (args) => typesTool.execute(args)
5115
+ };
5067
5116
  } else {
5068
5117
  for (const mcpTool of mcpTools) {
5069
5118
  vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
@@ -8,5 +8,5 @@
8
8
  export { generateCodeModeTypes, type GeneratedTypes, } from "./type-generator.js";
9
9
  export { executeSandboxCode, __setSandboxFactoryForTests, type ExecuteSandboxCodeOptions, type ExecuteSandboxCodeResult, } from "./executor.js";
10
10
  export { RUNTIME_STUB_SOURCE } from "./runtime-stub.js";
11
- export { buildCodeModeTool, canUseCodeMode, CODE_MODE_TOOL_NAME, type CodeModeToolOptions, type CodeModeToolDefinition, } from "./tool-builder.js";
11
+ export { buildCodeModeTool, canUseCodeMode, CODE_MODE_TOOL_NAME, TYPES_TOOL_NAME, type CodeModeToolOptions, type CodeModeToolDefinition, type TypesToolDefinition, type CodeModeTools, } from "./tool-builder.js";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-mode/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-mode/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC"}
@@ -182,6 +182,8 @@ function generateCodeModeTypes(tools) {
182
182
  const methodMap = {};
183
183
  const integrationCounts = {};
184
184
  const sections = [];
185
+ const compactLines = [];
186
+ const perIntegration = {};
185
187
  const integrationIds = Object.keys(byIntegration).sort();
186
188
  sections.push("/**");
187
189
  sections.push(" * Integrate SDK — available APIs inside `execute_code`.");
@@ -194,18 +196,35 @@ function generateCodeModeTypes(tools) {
194
196
  const integrationTools = byIntegration[integrationId].slice().sort((a, b) => a.name.localeCompare(b.name));
195
197
  integrationCounts[integrationId] = integrationTools.length;
196
198
  const interfaceName = pascalCase(integrationId) + "Client";
199
+ const fullSections = [];
200
+ fullSections.push(`export interface ${interfaceName} {`);
197
201
  sections.push(`export interface ${interfaceName} {`);
202
+ const compactMethods = [];
198
203
  for (const tool of integrationTools) {
199
204
  const methodName = toolNameToMethod(tool.name);
200
205
  methodMap[`${integrationId}.${methodName}`] = tool.name;
201
- sections.push(formatDescription(tool.description, " "));
206
+ const fullDesc = formatDescription(tool.description, " ");
207
+ fullSections.push(fullDesc);
208
+ sections.push(fullDesc);
202
209
  const argType = argsType(tool.inputSchema);
203
210
  const argIsOptional = !methodHasRequiredArgs(tool.inputSchema);
204
211
  const paramName = argIsOptional ? "args?" : "args";
205
- sections.push(` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`);
212
+ const fullLine = ` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`;
213
+ fullSections.push(fullLine);
214
+ sections.push(fullLine);
215
+ const compactArgs = compactArgsSignature(tool.inputSchema);
216
+ const compactParam = argIsOptional ? `args?: ${compactArgs}` : `args: ${compactArgs}`;
217
+ compactMethods.push(` ${safeIdent(methodName)}(${compactParam}): Promise<ToolResult>`);
206
218
  }
207
219
  sections.push("}");
208
220
  sections.push("");
221
+ fullSections.push("}");
222
+ perIntegration[integrationId] = fullSections.join(`
223
+ `);
224
+ compactLines.push(`client.${integrationId}:`);
225
+ for (const m of compactMethods) {
226
+ compactLines.push(m);
227
+ }
209
228
  }
210
229
  sections.push("export interface ToolResult {");
211
230
  sections.push(" content: Array<{ type: 'text' | 'image' | 'resource'; text?: string; data?: string; mimeType?: string; [key: string]: unknown }>;");
@@ -223,11 +242,22 @@ function generateCodeModeTypes(tools) {
223
242
  sections.push("export declare const client: Client;");
224
243
  return {
225
244
  source: sections.filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join(`
245
+ `),
246
+ compact: compactLines.join(`
226
247
  `),
227
248
  methodMap,
228
- integrationCounts
249
+ integrationCounts,
250
+ perIntegration
229
251
  };
230
252
  }
253
+ function compactArgsSignature(schema) {
254
+ if (!schema || !schema.properties || Object.keys(schema.properties).length === 0) {
255
+ return "{}";
256
+ }
257
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
258
+ const params = Object.keys(schema.properties).map((key) => `${safeIdent(key)}${required.has(key) ? "" : "?"}`);
259
+ return `{ ${params.join(", ")} }`;
260
+ }
231
261
  function pascalCase(id) {
232
262
  return id.split(/[^A-Za-z0-9]/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("") || "Unknown";
233
263
  }
@@ -512,25 +542,16 @@ function getEnv(key) {
512
542
 
513
543
  // tool-builder.ts
514
544
  var CODE_MODE_TOOL_NAME = "execute_code";
545
+ var TYPES_TOOL_NAME = "get_integration_types";
515
546
  var DEFAULT_INSTRUCTIONS = [
516
- "You are given a single tool: `execute_code`. Instead of calling individual MCP tools,",
517
- "you write a short async TypeScript/JavaScript snippet that uses the typed `client`",
518
- "object below, and the snippet runs in an isolated sandbox which dispatches the actual",
519
- "tool calls. Chain multiple operations together in one snippet whenever possible —",
520
- "that is the whole point of this tool.",
547
+ "Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
548
+ "Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
549
+ "Each method returns `ToolResult { content: [{ type, text? }], isError? }` parse `result.content[0].text` as JSON.",
550
+ "Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
521
551
  "",
522
- "Rules:",
523
- "- The snippet is the body of an `async` function. Use `await` freely.",
524
- "- Use `return <value>` at the end to hand a structured result back to the caller;",
525
- " the caller receives it as JSON.",
526
- "- Use `console.log(...)` for intermediate observations you want to read later.",
527
- "- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
528
- "- Each method call returns an object of shape `ToolResult` (see types below).",
529
- " The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
530
- "- You cannot import npm packages. Only the pre-imported `client` and standard",
531
- " globals (`fetch`, `console`, `JSON`, ...) are available.",
552
+ "Call `get_integration_types` with an integration name to get full parameter types before writing code.",
532
553
  "",
533
- "API surface:"
554
+ "Available methods:"
534
555
  ].join(`
535
556
  `);
536
557
  function resolveCodeModeClientConfig(client) {
@@ -578,10 +599,7 @@ function buildCodeModeTool(client, options) {
578
599
  const serverCodeModeConfig = resolveCodeModeClientConfig(client);
579
600
  const sandboxOverrides = options.sandbox ?? {};
580
601
  const description = `${DEFAULT_INSTRUCTIONS}
581
-
582
- \`\`\`typescript
583
- ${generated.source}
584
- \`\`\``;
602
+ ${generated.compact}`;
585
603
  const execute = async ({ code }) => {
586
604
  const publicUrl = resolveCodeModePublicUrl({
587
605
  publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
@@ -611,7 +629,8 @@ ${generated.source}
611
629
  networkPolicy: sandboxOverrides.networkPolicy ?? serverCodeModeConfig.networkPolicy
612
630
  });
613
631
  };
614
- return {
632
+ const availableIntegrations = Object.keys(generated.perIntegration);
633
+ const codeTool = {
615
634
  name: CODE_MODE_TOOL_NAME,
616
635
  description,
617
636
  parameters: {
@@ -627,6 +646,29 @@ ${generated.source}
627
646
  },
628
647
  execute
629
648
  };
649
+ const typesTool = {
650
+ name: TYPES_TOOL_NAME,
651
+ description: "Get full TypeScript type definitions (method signatures, parameter types, JSDoc) for a specific integration. " + `Available integrations: ${availableIntegrations.join(", ")}.`,
652
+ parameters: {
653
+ type: "object",
654
+ properties: {
655
+ integration: {
656
+ type: "string",
657
+ description: `Integration name to get types for (${availableIntegrations.join(", ")}).`
658
+ }
659
+ },
660
+ required: ["integration"],
661
+ additionalProperties: false
662
+ },
663
+ execute: ({ integration }) => {
664
+ const types = generated.perIntegration[integration];
665
+ if (!types) {
666
+ return { error: `Unknown integration "${integration}".`, available: availableIntegrations };
667
+ }
668
+ return { types };
669
+ }
670
+ };
671
+ return { codeTool, typesTool };
630
672
  }
631
673
  export {
632
674
  generateCodeModeTypes,
@@ -634,6 +676,7 @@ export {
634
676
  canUseCodeMode,
635
677
  buildCodeModeTool,
636
678
  __setSandboxFactoryForTests,
679
+ TYPES_TOOL_NAME,
637
680
  RUNTIME_STUB_SOURCE,
638
681
  CODE_MODE_TOOL_NAME
639
682
  };
@@ -12,6 +12,7 @@ import type { MCPContext } from "../config/types.js";
12
12
  import type { MCPTool } from "../protocol/messages.js";
13
13
  import { type ExecuteSandboxCodeResult } from "./executor.js";
14
14
  export declare const CODE_MODE_TOOL_NAME = "execute_code";
15
+ export declare const TYPES_TOOL_NAME = "get_integration_types";
15
16
  export interface CodeModeToolOptions {
16
17
  /** Enabled MCP tools (already fetched by the caller). */
17
18
  tools: MCPTool[];
@@ -61,6 +62,33 @@ export interface CodeModeToolDefinition {
61
62
  code: string;
62
63
  }) => Promise<ExecuteSandboxCodeResult>;
63
64
  }
65
+ export interface TypesToolDefinition {
66
+ name: string;
67
+ description: string;
68
+ parameters: {
69
+ type: "object";
70
+ properties: {
71
+ integration: {
72
+ type: "string";
73
+ description: string;
74
+ };
75
+ };
76
+ required: ["integration"];
77
+ additionalProperties: false;
78
+ };
79
+ execute: (input: {
80
+ integration: string;
81
+ }) => {
82
+ types: string;
83
+ } | {
84
+ error: string;
85
+ available: string[];
86
+ };
87
+ }
88
+ export interface CodeModeTools {
89
+ codeTool: CodeModeToolDefinition;
90
+ typesTool: TypesToolDefinition;
91
+ }
64
92
  export declare function resolveCodeModeClientConfig(client: MCPClient<any>): {
65
93
  publicUrl?: string;
66
94
  runtime?: "node24" | "node22";
@@ -100,9 +128,9 @@ export declare function __resetCodeModeFallbackWarnings(): void;
100
128
  */
101
129
  export declare function warnCodeModeFallback(reason: CodeModeUnavailableReason): void;
102
130
  /**
103
- * Build the `execute_code` tool definition. The returned `execute` function
104
- * is what the AI provider SDK ultimately invokes when the model picks the
105
- * tool.
131
+ * Build the `execute_code` and `get_integration_types` tool definitions.
132
+ * The compact method listing goes in execute_code's description; full
133
+ * TypeScript types are served on demand via get_integration_types.
106
134
  */
107
- export declare function buildCodeModeTool(client: MCPClient<any>, options: CodeModeToolOptions): CodeModeToolDefinition;
135
+ export declare function buildCodeModeTool(client: MCPClient<any>, options: CodeModeToolOptions): CodeModeTools;
108
136
  //# sourceMappingURL=tool-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-builder.d.ts","sourceRoot":"","sources":["../../../src/code-mode/tool-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,KAAK,EA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AO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;CAClH,CAGA;AAED,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE5E,MAAM,MAAM,iBAAiB,GACzB;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,GACnB;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,yBAAyB,CAAA;CAAE,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,MAAM,GAAG,SAAS,CAEpB;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUzF;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E;AAwBD,sEAAsE;AACtE,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAI5E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE,mBAAmB,GAC3B,aAAa,CA2Ff"}
@@ -182,6 +182,8 @@ function generateCodeModeTypes(tools) {
182
182
  const methodMap = {};
183
183
  const integrationCounts = {};
184
184
  const sections = [];
185
+ const compactLines = [];
186
+ const perIntegration = {};
185
187
  const integrationIds = Object.keys(byIntegration).sort();
186
188
  sections.push("/**");
187
189
  sections.push(" * Integrate SDK — available APIs inside `execute_code`.");
@@ -194,18 +196,35 @@ function generateCodeModeTypes(tools) {
194
196
  const integrationTools = byIntegration[integrationId].slice().sort((a, b) => a.name.localeCompare(b.name));
195
197
  integrationCounts[integrationId] = integrationTools.length;
196
198
  const interfaceName = pascalCase(integrationId) + "Client";
199
+ const fullSections = [];
200
+ fullSections.push(`export interface ${interfaceName} {`);
197
201
  sections.push(`export interface ${interfaceName} {`);
202
+ const compactMethods = [];
198
203
  for (const tool of integrationTools) {
199
204
  const methodName = toolNameToMethod(tool.name);
200
205
  methodMap[`${integrationId}.${methodName}`] = tool.name;
201
- sections.push(formatDescription(tool.description, " "));
206
+ const fullDesc = formatDescription(tool.description, " ");
207
+ fullSections.push(fullDesc);
208
+ sections.push(fullDesc);
202
209
  const argType = argsType(tool.inputSchema);
203
210
  const argIsOptional = !methodHasRequiredArgs(tool.inputSchema);
204
211
  const paramName = argIsOptional ? "args?" : "args";
205
- sections.push(` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`);
212
+ const fullLine = ` ${safeIdent(methodName)}(${paramName}: ${argType}): Promise<ToolResult>;`;
213
+ fullSections.push(fullLine);
214
+ sections.push(fullLine);
215
+ const compactArgs = compactArgsSignature(tool.inputSchema);
216
+ const compactParam = argIsOptional ? `args?: ${compactArgs}` : `args: ${compactArgs}`;
217
+ compactMethods.push(` ${safeIdent(methodName)}(${compactParam}): Promise<ToolResult>`);
206
218
  }
207
219
  sections.push("}");
208
220
  sections.push("");
221
+ fullSections.push("}");
222
+ perIntegration[integrationId] = fullSections.join(`
223
+ `);
224
+ compactLines.push(`client.${integrationId}:`);
225
+ for (const m of compactMethods) {
226
+ compactLines.push(m);
227
+ }
209
228
  }
210
229
  sections.push("export interface ToolResult {");
211
230
  sections.push(" content: Array<{ type: 'text' | 'image' | 'resource'; text?: string; data?: string; mimeType?: string; [key: string]: unknown }>;");
@@ -223,11 +242,22 @@ function generateCodeModeTypes(tools) {
223
242
  sections.push("export declare const client: Client;");
224
243
  return {
225
244
  source: sections.filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join(`
245
+ `),
246
+ compact: compactLines.join(`
226
247
  `),
227
248
  methodMap,
228
- integrationCounts
249
+ integrationCounts,
250
+ perIntegration
229
251
  };
230
252
  }
253
+ function compactArgsSignature(schema) {
254
+ if (!schema || !schema.properties || Object.keys(schema.properties).length === 0) {
255
+ return "{}";
256
+ }
257
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
258
+ const params = Object.keys(schema.properties).map((key) => `${safeIdent(key)}${required.has(key) ? "" : "?"}`);
259
+ return `{ ${params.join(", ")} }`;
260
+ }
231
261
  function pascalCase(id) {
232
262
  return id.split(/[^A-Za-z0-9]/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("") || "Unknown";
233
263
  }
@@ -512,25 +542,16 @@ function getEnv(key) {
512
542
 
513
543
  // tool-builder.ts
514
544
  var CODE_MODE_TOOL_NAME = "execute_code";
545
+ var TYPES_TOOL_NAME = "get_integration_types";
515
546
  var DEFAULT_INSTRUCTIONS = [
516
- "You are given a single tool: `execute_code`. Instead of calling individual MCP tools,",
517
- "you write a short async TypeScript/JavaScript snippet that uses the typed `client`",
518
- "object below, and the snippet runs in an isolated sandbox which dispatches the actual",
519
- "tool calls. Chain multiple operations together in one snippet whenever possible —",
520
- "that is the whole point of this tool.",
547
+ "Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
548
+ "Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
549
+ "Each method returns `ToolResult { content: [{ type, text? }], isError? }` parse `result.content[0].text` as JSON.",
550
+ "Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
521
551
  "",
522
- "Rules:",
523
- "- The snippet is the body of an `async` function. Use `await` freely.",
524
- "- Use `return <value>` at the end to hand a structured result back to the caller;",
525
- " the caller receives it as JSON.",
526
- "- Use `console.log(...)` for intermediate observations you want to read later.",
527
- "- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
528
- "- Each method call returns an object of shape `ToolResult` (see types below).",
529
- " The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
530
- "- You cannot import npm packages. Only the pre-imported `client` and standard",
531
- " globals (`fetch`, `console`, `JSON`, ...) are available.",
552
+ "Call `get_integration_types` with an integration name to get full parameter types before writing code.",
532
553
  "",
533
- "API surface:"
554
+ "Available methods:"
534
555
  ].join(`
535
556
  `);
536
557
  function resolveCodeModeClientConfig(client) {
@@ -578,10 +599,7 @@ function buildCodeModeTool(client, options) {
578
599
  const serverCodeModeConfig = resolveCodeModeClientConfig(client);
579
600
  const sandboxOverrides = options.sandbox ?? {};
580
601
  const description = `${DEFAULT_INSTRUCTIONS}
581
-
582
- \`\`\`typescript
583
- ${generated.source}
584
- \`\`\``;
602
+ ${generated.compact}`;
585
603
  const execute = async ({ code }) => {
586
604
  const publicUrl = resolveCodeModePublicUrl({
587
605
  publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
@@ -611,7 +629,8 @@ ${generated.source}
611
629
  networkPolicy: sandboxOverrides.networkPolicy ?? serverCodeModeConfig.networkPolicy
612
630
  });
613
631
  };
614
- return {
632
+ const availableIntegrations = Object.keys(generated.perIntegration);
633
+ const codeTool = {
615
634
  name: CODE_MODE_TOOL_NAME,
616
635
  description,
617
636
  parameters: {
@@ -627,6 +646,29 @@ ${generated.source}
627
646
  },
628
647
  execute
629
648
  };
649
+ const typesTool = {
650
+ name: TYPES_TOOL_NAME,
651
+ description: "Get full TypeScript type definitions (method signatures, parameter types, JSDoc) for a specific integration. " + `Available integrations: ${availableIntegrations.join(", ")}.`,
652
+ parameters: {
653
+ type: "object",
654
+ properties: {
655
+ integration: {
656
+ type: "string",
657
+ description: `Integration name to get types for (${availableIntegrations.join(", ")}).`
658
+ }
659
+ },
660
+ required: ["integration"],
661
+ additionalProperties: false
662
+ },
663
+ execute: ({ integration }) => {
664
+ const types = generated.perIntegration[integration];
665
+ if (!types) {
666
+ return { error: `Unknown integration "${integration}".`, available: availableIntegrations };
667
+ }
668
+ return { types };
669
+ }
670
+ };
671
+ return { codeTool, typesTool };
630
672
  }
631
673
  export {
632
674
  warnCodeModeFallback,
@@ -636,5 +678,6 @@ export {
636
678
  canUseCodeMode,
637
679
  buildCodeModeTool,
638
680
  __resetCodeModeFallbackWarnings,
681
+ TYPES_TOOL_NAME,
639
682
  CODE_MODE_TOOL_NAME
640
683
  };
@@ -10,10 +10,14 @@ import type { MCPTool } from "../protocol/messages.js";
10
10
  export interface GeneratedTypes {
11
11
  /** The full TypeScript source to embed in the LLM prompt. */
12
12
  source: string;
13
+ /** Compact method listing (no JSDoc, param names only) for the tool description. */
14
+ compact: string;
13
15
  /** Map from dotted method path (e.g. `github.createIssue`) to MCP tool name. */
14
16
  methodMap: Record<string, string>;
15
17
  /** Per-integration tool counts, useful for logging. */
16
18
  integrationCounts: Record<string, number>;
19
+ /** Per-integration full type source for on-demand lookup. */
20
+ perIntegration: Record<string, string>;
17
21
  }
18
22
  /**
19
23
  * Build the TypeScript API surface from a set of enabled MCP tools.
@@ -1 +1 @@
1
- {"version":3,"file":"type-generator.d.ts","sourceRoot":"","sources":["../../../src/code-mode/type-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,yBAAyB,CAAC;AAGxE,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAgHD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,CA6DtE"}
1
+ {"version":3,"file":"type-generator.d.ts","sourceRoot":"","sources":["../../../src/code-mode/type-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,yBAAyB,CAAC;AAGxE,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAgHD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,CA8FtE"}