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.
- package/dist/adapters/index.js +6 -16
- package/dist/adapters/solid-start.js +6 -16
- package/dist/adapters/svelte-kit.js +6 -16
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +79 -26
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +84 -26
- package/dist/ai/index.js +116 -31
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +77 -26
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +74 -25
- package/dist/code-mode/index.d.ts +1 -1
- package/dist/code-mode/index.d.ts.map +1 -1
- package/dist/code-mode/index.js +67 -24
- package/dist/code-mode/tool-builder.d.ts +32 -4
- package/dist/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/code-mode/tool-builder.js +67 -24
- package/dist/code-mode/type-generator.d.ts +4 -0
- package/dist/code-mode/type-generator.d.ts.map +1 -1
- package/dist/code-mode/type-generator.js +33 -3
- package/dist/server.js +118 -32
- package/dist/src/ai/anthropic.d.ts.map +1 -1
- package/dist/src/ai/google.d.ts.map +1 -1
- package/dist/src/ai/openai.d.ts.map +1 -1
- package/dist/src/ai/vercel-ai.d.ts.map +1 -1
- package/dist/src/code-mode/index.d.ts +1 -1
- package/dist/src/code-mode/index.d.ts.map +1 -1
- package/dist/src/code-mode/tool-builder.d.ts +32 -4
- package/dist/src/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/src/code-mode/type-generator.d.ts +4 -0
- package/dist/src/code-mode/type-generator.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -1164,24 +1164,14 @@ var init_tool_builder = __esm(() => {
|
|
|
1164
1164
|
init_type_generator();
|
|
1165
1165
|
init_executor();
|
|
1166
1166
|
DEFAULT_INSTRUCTIONS = [
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"
|
|
1171
|
-
"that is the whole point of this tool.",
|
|
1167
|
+
"Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
|
|
1168
|
+
"Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
|
|
1169
|
+
"Each method returns `ToolResult { content: [{ type, text? }], isError? }` — parse `result.content[0].text` as JSON.",
|
|
1170
|
+
"Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
|
|
1172
1171
|
"",
|
|
1173
|
-
"
|
|
1174
|
-
"- The snippet is the body of an `async` function. Use `await` freely.",
|
|
1175
|
-
"- Use `return <value>` at the end to hand a structured result back to the caller;",
|
|
1176
|
-
" the caller receives it as JSON.",
|
|
1177
|
-
"- Use `console.log(...)` for intermediate observations you want to read later.",
|
|
1178
|
-
"- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
|
|
1179
|
-
"- Each method call returns an object of shape `ToolResult` (see types below).",
|
|
1180
|
-
" The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
|
|
1181
|
-
"- You cannot import npm packages. Only the pre-imported `client` and standard",
|
|
1182
|
-
" globals (`fetch`, `console`, `JSON`, ...) are available.",
|
|
1172
|
+
"Call `get_integration_types` with an integration name to get full parameter types before writing code.",
|
|
1183
1173
|
"",
|
|
1184
|
-
"
|
|
1174
|
+
"Available methods:"
|
|
1185
1175
|
].join(`
|
|
1186
1176
|
`);
|
|
1187
1177
|
warnedCodeModeReasons = new Set;
|
|
@@ -1164,24 +1164,14 @@ var init_tool_builder = __esm(() => {
|
|
|
1164
1164
|
init_type_generator();
|
|
1165
1165
|
init_executor();
|
|
1166
1166
|
DEFAULT_INSTRUCTIONS = [
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"
|
|
1171
|
-
"that is the whole point of this tool.",
|
|
1167
|
+
"Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
|
|
1168
|
+
"Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
|
|
1169
|
+
"Each method returns `ToolResult { content: [{ type, text? }], isError? }` — parse `result.content[0].text` as JSON.",
|
|
1170
|
+
"Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
|
|
1172
1171
|
"",
|
|
1173
|
-
"
|
|
1174
|
-
"- The snippet is the body of an `async` function. Use `await` freely.",
|
|
1175
|
-
"- Use `return <value>` at the end to hand a structured result back to the caller;",
|
|
1176
|
-
" the caller receives it as JSON.",
|
|
1177
|
-
"- Use `console.log(...)` for intermediate observations you want to read later.",
|
|
1178
|
-
"- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
|
|
1179
|
-
"- Each method call returns an object of shape `ToolResult` (see types below).",
|
|
1180
|
-
" The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
|
|
1181
|
-
"- You cannot import npm packages. Only the pre-imported `client` and standard",
|
|
1182
|
-
" globals (`fetch`, `console`, `JSON`, ...) are available.",
|
|
1172
|
+
"Call `get_integration_types` with an integration name to get full parameter types before writing code.",
|
|
1183
1173
|
"",
|
|
1184
|
-
"
|
|
1174
|
+
"Available methods:"
|
|
1185
1175
|
].join(`
|
|
1186
1176
|
`);
|
|
1187
1177
|
warnedCodeModeReasons = new Set;
|
|
@@ -1164,24 +1164,14 @@ var init_tool_builder = __esm(() => {
|
|
|
1164
1164
|
init_type_generator();
|
|
1165
1165
|
init_executor();
|
|
1166
1166
|
DEFAULT_INSTRUCTIONS = [
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"
|
|
1171
|
-
"that is the whole point of this tool.",
|
|
1167
|
+
"Write an async JS/TS snippet that runs in an isolated sandbox using `client.<integration>.<method>(args)`.",
|
|
1168
|
+
"Chain multiple operations in one snippet. Use `await`, `return <value>` for JSON output, `console.log()` for debug.",
|
|
1169
|
+
"Each method returns `ToolResult { content: [{ type, text? }], isError? }` — parse `result.content[0].text` as JSON.",
|
|
1170
|
+
"Only `client`, `callTool`, `fetch`, `console`, `JSON` are available (no npm imports).",
|
|
1172
1171
|
"",
|
|
1173
|
-
"
|
|
1174
|
-
"- The snippet is the body of an `async` function. Use `await` freely.",
|
|
1175
|
-
"- Use `return <value>` at the end to hand a structured result back to the caller;",
|
|
1176
|
-
" the caller receives it as JSON.",
|
|
1177
|
-
"- Use `console.log(...)` for intermediate observations you want to read later.",
|
|
1178
|
-
"- Throw / let errors propagate; the runtime will surface them with a non-zero exit.",
|
|
1179
|
-
"- Each method call returns an object of shape `ToolResult` (see types below).",
|
|
1180
|
-
" The payload usually lives in `result.content[0].text` as JSON — parse it if needed.",
|
|
1181
|
-
"- You cannot import npm packages. Only the pre-imported `client` and standard",
|
|
1182
|
-
" globals (`fetch`, `console`, `JSON`, ...) are available.",
|
|
1172
|
+
"Call `get_integration_types` with an integration name to get full parameter types before writing code.",
|
|
1183
1173
|
"",
|
|
1184
|
-
"
|
|
1174
|
+
"Available methods:"
|
|
1185
1175
|
].join(`
|
|
1186
1176
|
`);
|
|
1187
1177
|
warnedCodeModeReasons = new Set;
|
|
@@ -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;
|
|
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;AAUjH,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;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AA+ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAmF1B;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"}
|
package/dist/ai/anthropic.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
4908
|
-
"
|
|
4909
|
-
"
|
|
4910
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
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
|
// anthropic.ts
|
|
@@ -5049,8 +5091,11 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
5049
5091
|
try {
|
|
5050
5092
|
let result;
|
|
5051
5093
|
if (toolUse.name === CODE_MODE_TOOL_NAME) {
|
|
5052
|
-
const codeTool = await getCodeModeTool();
|
|
5094
|
+
const { codeTool } = await getCodeModeTool();
|
|
5053
5095
|
result = await codeTool.execute(toolUse.input);
|
|
5096
|
+
} else if (toolUse.name === TYPES_TOOL_NAME) {
|
|
5097
|
+
const { typesTool } = await getCodeModeTool();
|
|
5098
|
+
result = typesTool.execute(toolUse.input);
|
|
5054
5099
|
} else if (triggerTools && triggerTools[toolUse.name]) {
|
|
5055
5100
|
result = await triggerTools[toolUse.name].execute(toolUse.input);
|
|
5056
5101
|
} else {
|
|
@@ -5097,7 +5142,7 @@ async function getAnthropicTools(client, options) {
|
|
|
5097
5142
|
}
|
|
5098
5143
|
}
|
|
5099
5144
|
const anthropicTools = effectiveMode === "code" ? (() => {
|
|
5100
|
-
const codeTool = buildCodeModeTool(client, {
|
|
5145
|
+
const { codeTool, typesTool } = buildCodeModeTool(client, {
|
|
5101
5146
|
tools: mcpTools,
|
|
5102
5147
|
providerTokens,
|
|
5103
5148
|
context: options?.context,
|
|
@@ -5111,6 +5156,14 @@ async function getAnthropicTools(client, options) {
|
|
|
5111
5156
|
properties: codeTool.parameters.properties,
|
|
5112
5157
|
required: [...codeTool.parameters.required]
|
|
5113
5158
|
}
|
|
5159
|
+
}, {
|
|
5160
|
+
name: TYPES_TOOL_NAME,
|
|
5161
|
+
description: typesTool.description,
|
|
5162
|
+
input_schema: {
|
|
5163
|
+
type: "object",
|
|
5164
|
+
properties: typesTool.parameters.properties,
|
|
5165
|
+
required: [...typesTool.parameters.required]
|
|
5166
|
+
}
|
|
5114
5167
|
}];
|
|
5115
5168
|
})() : mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
5116
5169
|
const triggerConfig = client.__triggerConfig;
|
package/dist/ai/google.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAajH,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;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAsGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CA+DnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAqGvB"}
|
package/dist/ai/google.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
4908
|
-
"
|
|
4909
|
-
"
|
|
4910
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
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
|
// google.ts
|
|
@@ -5117,8 +5159,11 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
5117
5159
|
const args = call.args || {};
|
|
5118
5160
|
let result;
|
|
5119
5161
|
if (call.name === CODE_MODE_TOOL_NAME) {
|
|
5120
|
-
const codeTool = await getCodeModeTool();
|
|
5162
|
+
const { codeTool } = await getCodeModeTool();
|
|
5121
5163
|
result = await codeTool.execute(args);
|
|
5164
|
+
} else if (call.name === TYPES_TOOL_NAME) {
|
|
5165
|
+
const { typesTool } = await getCodeModeTool();
|
|
5166
|
+
result = typesTool.execute(args);
|
|
5122
5167
|
} else if (triggerTools && triggerTools[call.name]) {
|
|
5123
5168
|
result = await triggerTools[call.name].execute(args);
|
|
5124
5169
|
} else {
|
|
@@ -5153,7 +5198,7 @@ async function getGoogleTools(client, options) {
|
|
|
5153
5198
|
let googleTools;
|
|
5154
5199
|
if (effectiveMode === "code") {
|
|
5155
5200
|
const TypeEnum = await getGoogleType();
|
|
5156
|
-
const codeTool = buildCodeModeTool(client, {
|
|
5201
|
+
const { codeTool, typesTool } = buildCodeModeTool(client, {
|
|
5157
5202
|
tools: mcpTools,
|
|
5158
5203
|
providerTokens,
|
|
5159
5204
|
context: options?.context,
|
|
@@ -5172,6 +5217,19 @@ async function getGoogleTools(client, options) {
|
|
|
5172
5217
|
},
|
|
5173
5218
|
required: ["code"]
|
|
5174
5219
|
}
|
|
5220
|
+
}, {
|
|
5221
|
+
name: TYPES_TOOL_NAME,
|
|
5222
|
+
description: typesTool.description,
|
|
5223
|
+
parameters: {
|
|
5224
|
+
type: TypeEnum.OBJECT,
|
|
5225
|
+
properties: {
|
|
5226
|
+
integration: {
|
|
5227
|
+
type: TypeEnum.STRING,
|
|
5228
|
+
description: typesTool.parameters.properties.integration.description
|
|
5229
|
+
}
|
|
5230
|
+
},
|
|
5231
|
+
required: ["integration"]
|
|
5232
|
+
}
|
|
5175
5233
|
}];
|
|
5176
5234
|
} else {
|
|
5177
5235
|
googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|