integrate-sdk 0.9.27-dev.0 → 0.9.27-dev.2
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/README.md +82 -0
- package/dist/adapters/index.js +84 -34
- package/dist/adapters/solid-start.js +84 -34
- package/dist/adapters/svelte-kit.js +84 -34
- package/dist/ai/anthropic.js +27 -1
- package/dist/ai/google.js +27 -1
- package/dist/ai/index.js +27 -1
- package/dist/ai/openai.js +27 -1
- package/dist/ai/vercel-ai.js +27 -1
- package/dist/code-mode/executor.js +27 -1
- package/dist/code-mode/index.js +27 -1
- package/dist/code-mode/runtime-stub.d.ts +1 -1
- package/dist/code-mode/runtime-stub.d.ts.map +1 -1
- package/dist/code-mode/runtime-stub.js +27 -1
- package/dist/code-mode/tool-builder.js +27 -1
- package/dist/index.js +263 -62
- package/dist/server.js +312 -84
- package/dist/src/client.d.ts +8 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/code-mode/runtime-stub.d.ts +1 -1
- package/dist/src/code-mode/runtime-stub.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/dropbox.d.ts +22 -0
- package/dist/src/integrations/dropbox.d.ts.map +1 -0
- package/dist/src/integrations/granola.d.ts +14 -0
- package/dist/src/integrations/granola.d.ts.map +1 -0
- package/dist/src/integrations/mercury.d.ts +14 -0
- package/dist/src/integrations/mercury.d.ts.map +1 -0
- package/dist/src/integrations/types.d.ts +4 -0
- package/dist/src/integrations/types.d.ts.map +1 -1
- package/dist/src/server.d.ts +3 -0
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2737,6 +2737,34 @@ class OAuthManager {
|
|
|
2737
2737
|
|
|
2738
2738
|
// ../client.ts
|
|
2739
2739
|
var CLIENT_LOG_CONTEXT = "client";
|
|
2740
|
+
var NON_TOOL_PROXY_PROPERTIES = new Set([
|
|
2741
|
+
"then",
|
|
2742
|
+
"catch",
|
|
2743
|
+
"finally",
|
|
2744
|
+
"constructor",
|
|
2745
|
+
"prototype",
|
|
2746
|
+
"toString",
|
|
2747
|
+
"valueOf",
|
|
2748
|
+
"toJSON",
|
|
2749
|
+
"inspect",
|
|
2750
|
+
"hasOwnProperty",
|
|
2751
|
+
"isPrototypeOf",
|
|
2752
|
+
"propertyIsEnumerable",
|
|
2753
|
+
"__proto__",
|
|
2754
|
+
"__defineGetter__",
|
|
2755
|
+
"__defineSetter__",
|
|
2756
|
+
"__lookupGetter__",
|
|
2757
|
+
"__lookupSetter__",
|
|
2758
|
+
"__esModule",
|
|
2759
|
+
Symbol.toStringTag,
|
|
2760
|
+
Symbol.toPrimitive,
|
|
2761
|
+
Symbol.iterator,
|
|
2762
|
+
Symbol.asyncIterator,
|
|
2763
|
+
Symbol.for("nodejs.util.inspect.custom")
|
|
2764
|
+
]);
|
|
2765
|
+
function isToolProxyProperty(property) {
|
|
2766
|
+
return typeof property === "string" && !NON_TOOL_PROXY_PROPERTIES.has(property);
|
|
2767
|
+
}
|
|
2740
2768
|
|
|
2741
2769
|
class SimpleEventEmitter {
|
|
2742
2770
|
handlers = new Map;
|
|
@@ -2959,6 +2987,8 @@ class MCPClientBase {
|
|
|
2959
2987
|
}
|
|
2960
2988
|
return new Proxy({}, {
|
|
2961
2989
|
get: (_target, methodName) => {
|
|
2990
|
+
if (!isToolProxyProperty(methodName))
|
|
2991
|
+
return;
|
|
2962
2992
|
return async (args, options) => {
|
|
2963
2993
|
const toolName = methodToToolName(methodName, integrationId);
|
|
2964
2994
|
return await this.callToolWithRetry(toolName, args, 0, options);
|
|
@@ -2972,6 +3002,8 @@ class MCPClientBase {
|
|
|
2972
3002
|
createServerProxy() {
|
|
2973
3003
|
return new Proxy({}, {
|
|
2974
3004
|
get: (_target, methodName) => {
|
|
3005
|
+
if (!isToolProxyProperty(methodName))
|
|
3006
|
+
return;
|
|
2975
3007
|
if (methodName === "listConfiguredIntegrations") {
|
|
2976
3008
|
return async (options) => {
|
|
2977
3009
|
const transportHeaders = this.transport.headers || {};
|
|
@@ -3192,6 +3224,9 @@ class MCPClientBase {
|
|
|
3192
3224
|
async _callToolByName(name, args, options) {
|
|
3193
3225
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
3194
3226
|
}
|
|
3227
|
+
async callTool(name, args, options) {
|
|
3228
|
+
return await this.callToolWithRetry(name, args, 0, options);
|
|
3229
|
+
}
|
|
3195
3230
|
async callServerTool(name, args) {
|
|
3196
3231
|
try {
|
|
3197
3232
|
const response = await this.callToolThroughHandler(name, args);
|
|
@@ -3202,35 +3237,38 @@ class MCPClientBase {
|
|
|
3202
3237
|
}
|
|
3203
3238
|
}
|
|
3204
3239
|
async callToolThroughHandler(name, args, provider, options) {
|
|
3240
|
+
const integrationHeaders = this.getHeadersForTool(name);
|
|
3205
3241
|
const transportHeaders = this.transport.headers || {};
|
|
3206
3242
|
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
3207
3243
|
if (hasApiKey) {
|
|
3208
3244
|
await this.ensureConnected();
|
|
3245
|
+
const temporaryHeaders = { ...integrationHeaders };
|
|
3209
3246
|
if (provider) {
|
|
3210
3247
|
const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
|
|
3211
|
-
if (tokenData
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3248
|
+
if (tokenData) {
|
|
3249
|
+
temporaryHeaders["Authorization"] = `Bearer ${tokenData.accessToken}`;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
const previousHeaders = new Map;
|
|
3253
|
+
for (const [key, value] of Object.entries(temporaryHeaders)) {
|
|
3254
|
+
previousHeaders.set(key, transportHeaders[key]);
|
|
3255
|
+
this.transport.setHeader(key, value);
|
|
3256
|
+
}
|
|
3257
|
+
try {
|
|
3258
|
+
const result2 = await this.transport.sendRequest("tools/call", {
|
|
3259
|
+
name,
|
|
3260
|
+
arguments: args || {}
|
|
3261
|
+
});
|
|
3262
|
+
return result2;
|
|
3263
|
+
} finally {
|
|
3264
|
+
for (const [key, previousValue] of previousHeaders.entries()) {
|
|
3265
|
+
if (previousValue !== undefined) {
|
|
3266
|
+
this.transport.setHeader(key, previousValue);
|
|
3267
|
+
} else {
|
|
3268
|
+
this.transport.removeHeader(key);
|
|
3226
3269
|
}
|
|
3227
3270
|
}
|
|
3228
3271
|
}
|
|
3229
|
-
const result2 = await this.transport.sendRequest("tools/call", {
|
|
3230
|
-
name,
|
|
3231
|
-
arguments: args || {}
|
|
3232
|
-
});
|
|
3233
|
-
return result2;
|
|
3234
3272
|
}
|
|
3235
3273
|
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
3236
3274
|
const headers = {
|
|
@@ -3240,6 +3278,7 @@ class MCPClientBase {
|
|
|
3240
3278
|
if (integrationsHeader) {
|
|
3241
3279
|
headers["X-Integrations"] = integrationsHeader;
|
|
3242
3280
|
}
|
|
3281
|
+
Object.assign(headers, integrationHeaders);
|
|
3243
3282
|
if (provider) {
|
|
3244
3283
|
const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
|
|
3245
3284
|
if (tokenData) {
|
|
@@ -3329,6 +3368,14 @@ class MCPClientBase {
|
|
|
3329
3368
|
}
|
|
3330
3369
|
return;
|
|
3331
3370
|
}
|
|
3371
|
+
getHeadersForTool(toolName) {
|
|
3372
|
+
for (const integration of this.integrations) {
|
|
3373
|
+
if (integration.tools.includes(toolName) && integration.getHeaders) {
|
|
3374
|
+
return integration.getHeaders();
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
return {};
|
|
3378
|
+
}
|
|
3332
3379
|
getTool(name) {
|
|
3333
3380
|
return this.availableTools.get(name);
|
|
3334
3381
|
}
|
|
@@ -3709,45 +3756,48 @@ var logger22 = createLogger("Ramp");
|
|
|
3709
3756
|
// ../integrations/onedrive.ts
|
|
3710
3757
|
init_logger();
|
|
3711
3758
|
var logger23 = createLogger("OneDrive");
|
|
3759
|
+
// ../integrations/dropbox.ts
|
|
3760
|
+
init_logger();
|
|
3761
|
+
var logger24 = createLogger("Dropbox");
|
|
3712
3762
|
// ../integrations/word.ts
|
|
3713
3763
|
init_logger();
|
|
3714
|
-
var
|
|
3764
|
+
var logger25 = createLogger("Word");
|
|
3715
3765
|
// ../integrations/excel.ts
|
|
3716
3766
|
init_logger();
|
|
3717
|
-
var
|
|
3767
|
+
var logger26 = createLogger("Excel");
|
|
3718
3768
|
// ../integrations/powerpoint.ts
|
|
3719
3769
|
init_logger();
|
|
3720
|
-
var
|
|
3770
|
+
var logger27 = createLogger("PowerPoint");
|
|
3721
3771
|
// ../integrations/gdocs.ts
|
|
3722
3772
|
init_logger();
|
|
3723
|
-
var
|
|
3773
|
+
var logger28 = createLogger("Google Docs");
|
|
3724
3774
|
// ../integrations/gdrive.ts
|
|
3725
3775
|
init_logger();
|
|
3726
|
-
var
|
|
3776
|
+
var logger29 = createLogger("Google Drive");
|
|
3727
3777
|
// ../integrations/gsheets.ts
|
|
3728
3778
|
init_logger();
|
|
3729
|
-
var
|
|
3779
|
+
var logger30 = createLogger("Google Sheets");
|
|
3730
3780
|
// ../integrations/gslides.ts
|
|
3731
3781
|
init_logger();
|
|
3732
|
-
var
|
|
3782
|
+
var logger31 = createLogger("Google Slides");
|
|
3733
3783
|
// ../integrations/polar.ts
|
|
3734
3784
|
init_logger();
|
|
3735
|
-
var
|
|
3785
|
+
var logger32 = createLogger("Polar");
|
|
3736
3786
|
// ../integrations/figma.ts
|
|
3737
3787
|
init_logger();
|
|
3738
|
-
var
|
|
3788
|
+
var logger33 = createLogger("Figma");
|
|
3739
3789
|
// ../integrations/intercom.ts
|
|
3740
3790
|
init_logger();
|
|
3741
|
-
var
|
|
3791
|
+
var logger34 = createLogger("Intercom");
|
|
3742
3792
|
// ../integrations/hubspot.ts
|
|
3743
3793
|
init_logger();
|
|
3744
|
-
var
|
|
3794
|
+
var logger35 = createLogger("HubSpot");
|
|
3745
3795
|
// ../integrations/youtube.ts
|
|
3746
3796
|
init_logger();
|
|
3747
|
-
var
|
|
3797
|
+
var logger36 = createLogger("YouTube");
|
|
3748
3798
|
// ../integrations/cursor.ts
|
|
3749
3799
|
init_logger();
|
|
3750
|
-
var
|
|
3800
|
+
var logger37 = createLogger("Cursor");
|
|
3751
3801
|
// ../ai/trigger-tools.ts
|
|
3752
3802
|
init_utils();
|
|
3753
3803
|
|
|
@@ -3766,7 +3816,7 @@ init_tool_builder();
|
|
|
3766
3816
|
init_tool_builder();
|
|
3767
3817
|
// ../server.ts
|
|
3768
3818
|
var SERVER_LOG_CONTEXT3 = "server";
|
|
3769
|
-
var
|
|
3819
|
+
var logger38 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
|
|
3770
3820
|
var codeVerifierStorage = new Map;
|
|
3771
3821
|
var unauthenticatedCodeModeWarnings = new Set;
|
|
3772
3822
|
function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {
|
package/dist/ai/anthropic.js
CHANGED
|
@@ -4681,6 +4681,32 @@ function camelToSnake(str) {
|
|
|
4681
4681
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4682
|
}
|
|
4683
4683
|
|
|
4684
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
4685
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
4686
|
+
'then',
|
|
4687
|
+
'catch',
|
|
4688
|
+
'finally',
|
|
4689
|
+
'constructor',
|
|
4690
|
+
'prototype',
|
|
4691
|
+
'toString',
|
|
4692
|
+
'valueOf',
|
|
4693
|
+
'toJSON',
|
|
4694
|
+
'inspect',
|
|
4695
|
+
'hasOwnProperty',
|
|
4696
|
+
'isPrototypeOf',
|
|
4697
|
+
'propertyIsEnumerable',
|
|
4698
|
+
'__proto__',
|
|
4699
|
+
'__defineGetter__',
|
|
4700
|
+
'__defineSetter__',
|
|
4701
|
+
'__lookupGetter__',
|
|
4702
|
+
'__lookupSetter__',
|
|
4703
|
+
'__esModule',
|
|
4704
|
+
]);
|
|
4705
|
+
|
|
4706
|
+
function isToolProperty(property) {
|
|
4707
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4684
4710
|
async function callTool(toolName, args) {
|
|
4685
4711
|
const headers = {
|
|
4686
4712
|
'Content-Type': 'application/json',
|
|
@@ -4728,7 +4754,7 @@ async function callTool(toolName, args) {
|
|
|
4728
4754
|
function createIntegrationProxy(integrationId) {
|
|
4729
4755
|
return new Proxy({}, {
|
|
4730
4756
|
get(_target, methodName) {
|
|
4731
|
-
if (
|
|
4757
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
4732
4758
|
return (args) => {
|
|
4733
4759
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
4734
4760
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
package/dist/ai/google.js
CHANGED
|
@@ -4681,6 +4681,32 @@ function camelToSnake(str) {
|
|
|
4681
4681
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4682
|
}
|
|
4683
4683
|
|
|
4684
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
4685
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
4686
|
+
'then',
|
|
4687
|
+
'catch',
|
|
4688
|
+
'finally',
|
|
4689
|
+
'constructor',
|
|
4690
|
+
'prototype',
|
|
4691
|
+
'toString',
|
|
4692
|
+
'valueOf',
|
|
4693
|
+
'toJSON',
|
|
4694
|
+
'inspect',
|
|
4695
|
+
'hasOwnProperty',
|
|
4696
|
+
'isPrototypeOf',
|
|
4697
|
+
'propertyIsEnumerable',
|
|
4698
|
+
'__proto__',
|
|
4699
|
+
'__defineGetter__',
|
|
4700
|
+
'__defineSetter__',
|
|
4701
|
+
'__lookupGetter__',
|
|
4702
|
+
'__lookupSetter__',
|
|
4703
|
+
'__esModule',
|
|
4704
|
+
]);
|
|
4705
|
+
|
|
4706
|
+
function isToolProperty(property) {
|
|
4707
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4684
4710
|
async function callTool(toolName, args) {
|
|
4685
4711
|
const headers = {
|
|
4686
4712
|
'Content-Type': 'application/json',
|
|
@@ -4728,7 +4754,7 @@ async function callTool(toolName, args) {
|
|
|
4728
4754
|
function createIntegrationProxy(integrationId) {
|
|
4729
4755
|
return new Proxy({}, {
|
|
4730
4756
|
get(_target, methodName) {
|
|
4731
|
-
if (
|
|
4757
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
4732
4758
|
return (args) => {
|
|
4733
4759
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
4734
4760
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
package/dist/ai/index.js
CHANGED
|
@@ -4681,6 +4681,32 @@ function camelToSnake(str) {
|
|
|
4681
4681
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4682
|
}
|
|
4683
4683
|
|
|
4684
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
4685
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
4686
|
+
'then',
|
|
4687
|
+
'catch',
|
|
4688
|
+
'finally',
|
|
4689
|
+
'constructor',
|
|
4690
|
+
'prototype',
|
|
4691
|
+
'toString',
|
|
4692
|
+
'valueOf',
|
|
4693
|
+
'toJSON',
|
|
4694
|
+
'inspect',
|
|
4695
|
+
'hasOwnProperty',
|
|
4696
|
+
'isPrototypeOf',
|
|
4697
|
+
'propertyIsEnumerable',
|
|
4698
|
+
'__proto__',
|
|
4699
|
+
'__defineGetter__',
|
|
4700
|
+
'__defineSetter__',
|
|
4701
|
+
'__lookupGetter__',
|
|
4702
|
+
'__lookupSetter__',
|
|
4703
|
+
'__esModule',
|
|
4704
|
+
]);
|
|
4705
|
+
|
|
4706
|
+
function isToolProperty(property) {
|
|
4707
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4684
4710
|
async function callTool(toolName, args) {
|
|
4685
4711
|
const headers = {
|
|
4686
4712
|
'Content-Type': 'application/json',
|
|
@@ -4728,7 +4754,7 @@ async function callTool(toolName, args) {
|
|
|
4728
4754
|
function createIntegrationProxy(integrationId) {
|
|
4729
4755
|
return new Proxy({}, {
|
|
4730
4756
|
get(_target, methodName) {
|
|
4731
|
-
if (
|
|
4757
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
4732
4758
|
return (args) => {
|
|
4733
4759
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
4734
4760
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
package/dist/ai/openai.js
CHANGED
|
@@ -4681,6 +4681,32 @@ function camelToSnake(str) {
|
|
|
4681
4681
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4682
|
}
|
|
4683
4683
|
|
|
4684
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
4685
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
4686
|
+
'then',
|
|
4687
|
+
'catch',
|
|
4688
|
+
'finally',
|
|
4689
|
+
'constructor',
|
|
4690
|
+
'prototype',
|
|
4691
|
+
'toString',
|
|
4692
|
+
'valueOf',
|
|
4693
|
+
'toJSON',
|
|
4694
|
+
'inspect',
|
|
4695
|
+
'hasOwnProperty',
|
|
4696
|
+
'isPrototypeOf',
|
|
4697
|
+
'propertyIsEnumerable',
|
|
4698
|
+
'__proto__',
|
|
4699
|
+
'__defineGetter__',
|
|
4700
|
+
'__defineSetter__',
|
|
4701
|
+
'__lookupGetter__',
|
|
4702
|
+
'__lookupSetter__',
|
|
4703
|
+
'__esModule',
|
|
4704
|
+
]);
|
|
4705
|
+
|
|
4706
|
+
function isToolProperty(property) {
|
|
4707
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4684
4710
|
async function callTool(toolName, args) {
|
|
4685
4711
|
const headers = {
|
|
4686
4712
|
'Content-Type': 'application/json',
|
|
@@ -4728,7 +4754,7 @@ async function callTool(toolName, args) {
|
|
|
4728
4754
|
function createIntegrationProxy(integrationId) {
|
|
4729
4755
|
return new Proxy({}, {
|
|
4730
4756
|
get(_target, methodName) {
|
|
4731
|
-
if (
|
|
4757
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
4732
4758
|
return (args) => {
|
|
4733
4759
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
4734
4760
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
package/dist/ai/vercel-ai.js
CHANGED
|
@@ -4681,6 +4681,32 @@ function camelToSnake(str) {
|
|
|
4681
4681
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4682
|
}
|
|
4683
4683
|
|
|
4684
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
4685
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
4686
|
+
'then',
|
|
4687
|
+
'catch',
|
|
4688
|
+
'finally',
|
|
4689
|
+
'constructor',
|
|
4690
|
+
'prototype',
|
|
4691
|
+
'toString',
|
|
4692
|
+
'valueOf',
|
|
4693
|
+
'toJSON',
|
|
4694
|
+
'inspect',
|
|
4695
|
+
'hasOwnProperty',
|
|
4696
|
+
'isPrototypeOf',
|
|
4697
|
+
'propertyIsEnumerable',
|
|
4698
|
+
'__proto__',
|
|
4699
|
+
'__defineGetter__',
|
|
4700
|
+
'__defineSetter__',
|
|
4701
|
+
'__lookupGetter__',
|
|
4702
|
+
'__lookupSetter__',
|
|
4703
|
+
'__esModule',
|
|
4704
|
+
]);
|
|
4705
|
+
|
|
4706
|
+
function isToolProperty(property) {
|
|
4707
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4684
4710
|
async function callTool(toolName, args) {
|
|
4685
4711
|
const headers = {
|
|
4686
4712
|
'Content-Type': 'application/json',
|
|
@@ -4728,7 +4754,7 @@ async function callTool(toolName, args) {
|
|
|
4728
4754
|
function createIntegrationProxy(integrationId) {
|
|
4729
4755
|
return new Proxy({}, {
|
|
4730
4756
|
get(_target, methodName) {
|
|
4731
|
-
if (
|
|
4757
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
4732
4758
|
return (args) => {
|
|
4733
4759
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
4734
4760
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
|
@@ -34,6 +34,32 @@ function camelToSnake(str) {
|
|
|
34
34
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
38
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
39
|
+
'then',
|
|
40
|
+
'catch',
|
|
41
|
+
'finally',
|
|
42
|
+
'constructor',
|
|
43
|
+
'prototype',
|
|
44
|
+
'toString',
|
|
45
|
+
'valueOf',
|
|
46
|
+
'toJSON',
|
|
47
|
+
'inspect',
|
|
48
|
+
'hasOwnProperty',
|
|
49
|
+
'isPrototypeOf',
|
|
50
|
+
'propertyIsEnumerable',
|
|
51
|
+
'__proto__',
|
|
52
|
+
'__defineGetter__',
|
|
53
|
+
'__defineSetter__',
|
|
54
|
+
'__lookupGetter__',
|
|
55
|
+
'__lookupSetter__',
|
|
56
|
+
'__esModule',
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
function isToolProperty(property) {
|
|
60
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
61
|
+
}
|
|
62
|
+
|
|
37
63
|
async function callTool(toolName, args) {
|
|
38
64
|
const headers = {
|
|
39
65
|
'Content-Type': 'application/json',
|
|
@@ -81,7 +107,7 @@ async function callTool(toolName, args) {
|
|
|
81
107
|
function createIntegrationProxy(integrationId) {
|
|
82
108
|
return new Proxy({}, {
|
|
83
109
|
get(_target, methodName) {
|
|
84
|
-
if (
|
|
110
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
85
111
|
return (args) => {
|
|
86
112
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
87
113
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
package/dist/code-mode/index.js
CHANGED
|
@@ -279,6 +279,32 @@ function camelToSnake(str) {
|
|
|
279
279
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
283
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
284
|
+
'then',
|
|
285
|
+
'catch',
|
|
286
|
+
'finally',
|
|
287
|
+
'constructor',
|
|
288
|
+
'prototype',
|
|
289
|
+
'toString',
|
|
290
|
+
'valueOf',
|
|
291
|
+
'toJSON',
|
|
292
|
+
'inspect',
|
|
293
|
+
'hasOwnProperty',
|
|
294
|
+
'isPrototypeOf',
|
|
295
|
+
'propertyIsEnumerable',
|
|
296
|
+
'__proto__',
|
|
297
|
+
'__defineGetter__',
|
|
298
|
+
'__defineSetter__',
|
|
299
|
+
'__lookupGetter__',
|
|
300
|
+
'__lookupSetter__',
|
|
301
|
+
'__esModule',
|
|
302
|
+
]);
|
|
303
|
+
|
|
304
|
+
function isToolProperty(property) {
|
|
305
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
306
|
+
}
|
|
307
|
+
|
|
282
308
|
async function callTool(toolName, args) {
|
|
283
309
|
const headers = {
|
|
284
310
|
'Content-Type': 'application/json',
|
|
@@ -326,7 +352,7 @@ async function callTool(toolName, args) {
|
|
|
326
352
|
function createIntegrationProxy(integrationId) {
|
|
327
353
|
return new Proxy({}, {
|
|
328
354
|
get(_target, methodName) {
|
|
329
|
-
if (
|
|
355
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
330
356
|
return (args) => {
|
|
331
357
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
332
358
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* dependencies. It is NOT imported by the host SDK — it only ships as a
|
|
13
13
|
* literal payload to the sandbox.
|
|
14
14
|
*/
|
|
15
|
-
export declare const RUNTIME_STUB_SOURCE = "// runtime.mjs \u2014 generated by integrate-sdk code mode\nconst MCP_URL = process.env.INTEGRATE_MCP_URL;\nconst SESSION_TOKEN = process.env.INTEGRATE_SESSION_TOKEN;\nconst API_KEY = process.env.INTEGRATE_API_KEY || '';\nconst PROVIDER_TOKENS = process.env.INTEGRATE_PROVIDER_TOKENS || '';\nconst INTEGRATIONS_HEADER = process.env.INTEGRATE_INTEGRATIONS || '';\nconst CONTEXT_JSON = process.env.INTEGRATE_CONTEXT || '';\n\nif (!MCP_URL) {\n throw new Error('INTEGRATE_MCP_URL is not set \u2014 the sandbox cannot reach the MCP route.');\n}\n\nfunction camelToSnake(str) {\n return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());\n}\n\nasync function callTool(toolName, args) {\n const headers = {\n 'Content-Type': 'application/json',\n 'x-integrate-code-mode': '1',\n };\n if (SESSION_TOKEN) headers['Authorization'] = 'Bearer ' + SESSION_TOKEN;\n if (API_KEY) headers['x-integrate-api-key'] = API_KEY;\n if (PROVIDER_TOKENS) headers['x-integrate-tokens'] = PROVIDER_TOKENS;\n if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;\n if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;\n\n const res = await fetch(MCP_URL, {\n method: 'POST',\n headers,\n body: JSON.stringify({ name: toolName, arguments: args || {} }),\n });\n\n const text = await res.text();\n\n let payload;\n try {\n payload = text ? JSON.parse(text) : null;\n } catch {\n payload = { content: [{ type: 'text', text }] };\n }\n\n if (!res.ok) {\n let message = (payload && (payload.error || payload.message)) || 'Tool call failed: HTTP ' + res.status;\n if ((res.status === 401 || res.status === 403) && typeof text === 'string' && text.indexOf('Authorization header') !== -1) {\n message =\n 'Code Mode callback was rejected by the MCP server (HTTP ' + res.status + '). ' +\n 'The SDK route could not synthesize an Authorization header. Check the host-side ' +\n 'createMCPServer config (apiKey, getProviderToken) or pass providerTokens to the ' +\n 'AI helper. Original upstream message: ' + text;\n }\n const err = new Error(message);\n err.status = res.status;\n err.toolName = toolName;\n throw err;\n }\n\n return payload;\n}\n\nfunction createIntegrationProxy(integrationId) {\n return new Proxy({}, {\n get(_target, methodName) {\n if (
|
|
15
|
+
export declare const RUNTIME_STUB_SOURCE = "// runtime.mjs \u2014 generated by integrate-sdk code mode\nconst MCP_URL = process.env.INTEGRATE_MCP_URL;\nconst SESSION_TOKEN = process.env.INTEGRATE_SESSION_TOKEN;\nconst API_KEY = process.env.INTEGRATE_API_KEY || '';\nconst PROVIDER_TOKENS = process.env.INTEGRATE_PROVIDER_TOKENS || '';\nconst INTEGRATIONS_HEADER = process.env.INTEGRATE_INTEGRATIONS || '';\nconst CONTEXT_JSON = process.env.INTEGRATE_CONTEXT || '';\n\nif (!MCP_URL) {\n throw new Error('INTEGRATE_MCP_URL is not set \u2014 the sandbox cannot reach the MCP route.');\n}\n\nfunction camelToSnake(str) {\n return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());\n}\n\nconst NON_TOOL_PROPERTIES = new Set([\n // Promise assimilation and object inspection should not become MCP calls.\n 'then',\n 'catch',\n 'finally',\n 'constructor',\n 'prototype',\n 'toString',\n 'valueOf',\n 'toJSON',\n 'inspect',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n '__proto__',\n '__defineGetter__',\n '__defineSetter__',\n '__lookupGetter__',\n '__lookupSetter__',\n '__esModule',\n]);\n\nfunction isToolProperty(property) {\n return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);\n}\n\nasync function callTool(toolName, args) {\n const headers = {\n 'Content-Type': 'application/json',\n 'x-integrate-code-mode': '1',\n };\n if (SESSION_TOKEN) headers['Authorization'] = 'Bearer ' + SESSION_TOKEN;\n if (API_KEY) headers['x-integrate-api-key'] = API_KEY;\n if (PROVIDER_TOKENS) headers['x-integrate-tokens'] = PROVIDER_TOKENS;\n if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;\n if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;\n\n const res = await fetch(MCP_URL, {\n method: 'POST',\n headers,\n body: JSON.stringify({ name: toolName, arguments: args || {} }),\n });\n\n const text = await res.text();\n\n let payload;\n try {\n payload = text ? JSON.parse(text) : null;\n } catch {\n payload = { content: [{ type: 'text', text }] };\n }\n\n if (!res.ok) {\n let message = (payload && (payload.error || payload.message)) || 'Tool call failed: HTTP ' + res.status;\n if ((res.status === 401 || res.status === 403) && typeof text === 'string' && text.indexOf('Authorization header') !== -1) {\n message =\n 'Code Mode callback was rejected by the MCP server (HTTP ' + res.status + '). ' +\n 'The SDK route could not synthesize an Authorization header. Check the host-side ' +\n 'createMCPServer config (apiKey, getProviderToken) or pass providerTokens to the ' +\n 'AI helper. Original upstream message: ' + text;\n }\n const err = new Error(message);\n err.status = res.status;\n err.toolName = toolName;\n throw err;\n }\n\n return payload;\n}\n\nfunction createIntegrationProxy(integrationId) {\n return new Proxy({}, {\n get(_target, methodName) {\n if (!isToolProperty(methodName)) return undefined;\n return (args) => {\n const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');\n const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);\n return callTool(toolName, args);\n };\n },\n });\n}\n\nexport const client = new Proxy({}, {\n get(_target, integrationId) {\n if (typeof integrationId !== 'string') return undefined;\n return createIntegrationProxy(integrationId);\n },\n});\n\nexport { callTool };\n";
|
|
16
16
|
//# sourceMappingURL=runtime-stub.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-stub.d.ts","sourceRoot":"","sources":["../../../src/code-mode/runtime-stub.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"runtime-stub.d.ts","sourceRoot":"","sources":["../../../src/code-mode/runtime-stub.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,mBAAmB,q7GA2G/B,CAAC"}
|
|
@@ -34,6 +34,32 @@ function camelToSnake(str) {
|
|
|
34
34
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
38
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
39
|
+
'then',
|
|
40
|
+
'catch',
|
|
41
|
+
'finally',
|
|
42
|
+
'constructor',
|
|
43
|
+
'prototype',
|
|
44
|
+
'toString',
|
|
45
|
+
'valueOf',
|
|
46
|
+
'toJSON',
|
|
47
|
+
'inspect',
|
|
48
|
+
'hasOwnProperty',
|
|
49
|
+
'isPrototypeOf',
|
|
50
|
+
'propertyIsEnumerable',
|
|
51
|
+
'__proto__',
|
|
52
|
+
'__defineGetter__',
|
|
53
|
+
'__defineSetter__',
|
|
54
|
+
'__lookupGetter__',
|
|
55
|
+
'__lookupSetter__',
|
|
56
|
+
'__esModule',
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
function isToolProperty(property) {
|
|
60
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
61
|
+
}
|
|
62
|
+
|
|
37
63
|
async function callTool(toolName, args) {
|
|
38
64
|
const headers = {
|
|
39
65
|
'Content-Type': 'application/json',
|
|
@@ -81,7 +107,7 @@ async function callTool(toolName, args) {
|
|
|
81
107
|
function createIntegrationProxy(integrationId) {
|
|
82
108
|
return new Proxy({}, {
|
|
83
109
|
get(_target, methodName) {
|
|
84
|
-
if (
|
|
110
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
85
111
|
return (args) => {
|
|
86
112
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
87
113
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|
|
@@ -279,6 +279,32 @@ function camelToSnake(str) {
|
|
|
279
279
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
const NON_TOOL_PROPERTIES = new Set([
|
|
283
|
+
// Promise assimilation and object inspection should not become MCP calls.
|
|
284
|
+
'then',
|
|
285
|
+
'catch',
|
|
286
|
+
'finally',
|
|
287
|
+
'constructor',
|
|
288
|
+
'prototype',
|
|
289
|
+
'toString',
|
|
290
|
+
'valueOf',
|
|
291
|
+
'toJSON',
|
|
292
|
+
'inspect',
|
|
293
|
+
'hasOwnProperty',
|
|
294
|
+
'isPrototypeOf',
|
|
295
|
+
'propertyIsEnumerable',
|
|
296
|
+
'__proto__',
|
|
297
|
+
'__defineGetter__',
|
|
298
|
+
'__defineSetter__',
|
|
299
|
+
'__lookupGetter__',
|
|
300
|
+
'__lookupSetter__',
|
|
301
|
+
'__esModule',
|
|
302
|
+
]);
|
|
303
|
+
|
|
304
|
+
function isToolProperty(property) {
|
|
305
|
+
return typeof property === 'string' && !NON_TOOL_PROPERTIES.has(property);
|
|
306
|
+
}
|
|
307
|
+
|
|
282
308
|
async function callTool(toolName, args) {
|
|
283
309
|
const headers = {
|
|
284
310
|
'Content-Type': 'application/json',
|
|
@@ -326,7 +352,7 @@ async function callTool(toolName, args) {
|
|
|
326
352
|
function createIntegrationProxy(integrationId) {
|
|
327
353
|
return new Proxy({}, {
|
|
328
354
|
get(_target, methodName) {
|
|
329
|
-
if (
|
|
355
|
+
if (!isToolProperty(methodName)) return undefined;
|
|
330
356
|
return (args) => {
|
|
331
357
|
const alreadyFull = methodName.startsWith(integrationId + '_') || methodName.startsWith('___');
|
|
332
358
|
const toolName = alreadyFull ? methodName : integrationId + '_' + camelToSnake(methodName);
|