integrate-sdk 0.9.19-dev.0 → 0.9.21-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/auto-routes.js +22 -2
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/base-handler.js +22 -2
- package/dist/adapters/index.js +22 -2
- package/dist/adapters/nextjs.js +22 -2
- package/dist/adapters/solid-start.js +22 -2
- package/dist/adapters/svelte-kit.js +22 -2
- package/dist/ai/anthropic.js +52 -0
- package/dist/ai/google.js +52 -0
- package/dist/ai/index.js +52 -0
- package/dist/ai/openai.js +52 -0
- package/dist/ai/vercel-ai.js +52 -0
- package/dist/code-mode/executor.d.ts.map +1 -1
- package/dist/code-mode/executor.js +35 -0
- package/dist/code-mode/index.js +105 -0
- 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 +25 -0
- package/dist/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/code-mode/tool-builder.js +105 -0
- package/dist/index.js +22 -2
- package/dist/oauth.js +22 -2
- package/dist/server.js +171 -57
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/code-mode/executor.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/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAe3D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,iDAAiD;QACjD,QAAQ,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,qCAAqC;QACrC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8CAA8C;QAC9C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,6DAA6D;QAC7D,cAAc,CAAC,EAAE,MAA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EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BlF;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4D1H;;;;;;;;;OASG;IACG,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;IAuGhF;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAClB,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,OAAO,CAAC,gBAAgB,CAAC;CA8F7B"}
|
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
package/dist/adapters/index.js
CHANGED
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
|
@@ -806,11 +806,31 @@ class OAuthHandler {
|
|
|
806
806
|
arguments: request.arguments || {}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
console.warn("[integrate-sdk] handleToolCall →", url, JSON.stringify({
|
|
810
|
+
tool: request.name,
|
|
811
|
+
hasAuth: !!headers["Authorization"],
|
|
812
|
+
hasApiKey: !!headers["X-API-KEY"],
|
|
813
|
+
headerKeys: Object.keys(headers)
|
|
814
|
+
}));
|
|
815
|
+
let response = await fetch(url, {
|
|
810
816
|
method: "POST",
|
|
811
817
|
headers,
|
|
812
|
-
body: JSON.stringify(jsonRpcRequest)
|
|
818
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
819
|
+
redirect: "manual"
|
|
813
820
|
});
|
|
821
|
+
if (response.status >= 300 && response.status < 400) {
|
|
822
|
+
const location = response.headers.get("location");
|
|
823
|
+
if (location) {
|
|
824
|
+
const redirectUrl = new URL(location, url).href;
|
|
825
|
+
console.warn(`[integrate-sdk] handleToolCall: following redirect ${response.status} → ${redirectUrl} (preserving Authorization header)`);
|
|
826
|
+
response = await fetch(redirectUrl, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers,
|
|
829
|
+
body: JSON.stringify(jsonRpcRequest),
|
|
830
|
+
redirect: "manual"
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
814
834
|
if (!response.ok) {
|
|
815
835
|
const error = await response.text();
|
|
816
836
|
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
package/dist/ai/anthropic.js
CHANGED
|
@@ -4677,6 +4677,21 @@ if (!MCP_URL) {
|
|
|
4677
4677
|
throw new Error('INTEGRATE_MCP_URL is not set — the sandbox cannot reach the MCP route.');
|
|
4678
4678
|
}
|
|
4679
4679
|
|
|
4680
|
+
// Diagnostic: log sandbox env summary to stderr so it shows up in the
|
|
4681
|
+
// execute_code result's stderr field for debugging auth issues.
|
|
4682
|
+
console.error('[sandbox-diag] MCP_URL=' + MCP_URL);
|
|
4683
|
+
console.error('[sandbox-diag] HAS_API_KEY=' + !!API_KEY);
|
|
4684
|
+
console.error('[sandbox-diag] HAS_SESSION_TOKEN=' + !!SESSION_TOKEN);
|
|
4685
|
+
console.error('[sandbox-diag] HAS_PROVIDER_TOKENS=' + !!PROVIDER_TOKENS);
|
|
4686
|
+
if (PROVIDER_TOKENS) {
|
|
4687
|
+
try {
|
|
4688
|
+
const _parsed = JSON.parse(PROVIDER_TOKENS);
|
|
4689
|
+
const _keys = Object.keys(_parsed);
|
|
4690
|
+
console.error('[sandbox-diag] PROVIDER_TOKEN_KEYS=' + _keys.join(','));
|
|
4691
|
+
console.error('[sandbox-diag] TOKEN_LENGTHS=' + _keys.map(k => k + ':' + (typeof _parsed[k] === 'string' ? _parsed[k].length : typeof _parsed[k])).join(','));
|
|
4692
|
+
} catch { console.error('[sandbox-diag] PROVIDER_TOKENS is not valid JSON'); }
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4680
4695
|
function camelToSnake(str) {
|
|
4681
4696
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4697
|
}
|
|
@@ -4692,6 +4707,14 @@ async function callTool(toolName, args) {
|
|
|
4692
4707
|
if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;
|
|
4693
4708
|
if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;
|
|
4694
4709
|
|
|
4710
|
+
console.error('[sandbox-diag] callTool: ' + toolName + ' → ' + MCP_URL);
|
|
4711
|
+
console.error('[sandbox-diag] headers: ' + JSON.stringify({
|
|
4712
|
+
hasAuth: !!headers['Authorization'],
|
|
4713
|
+
hasApiKey: !!headers['x-integrate-api-key'],
|
|
4714
|
+
hasTokens: !!headers['x-integrate-tokens'],
|
|
4715
|
+
hasCodeMode: !!headers['x-integrate-code-mode'],
|
|
4716
|
+
}));
|
|
4717
|
+
|
|
4695
4718
|
const res = await fetch(MCP_URL, {
|
|
4696
4719
|
method: 'POST',
|
|
4697
4720
|
headers,
|
|
@@ -4699,6 +4722,8 @@ async function callTool(toolName, args) {
|
|
|
4699
4722
|
});
|
|
4700
4723
|
|
|
4701
4724
|
const text = await res.text();
|
|
4725
|
+
console.error('[sandbox-diag] response: HTTP ' + res.status + ' len=' + text.length);
|
|
4726
|
+
|
|
4702
4727
|
let payload;
|
|
4703
4728
|
try {
|
|
4704
4729
|
payload = text ? JSON.parse(text) : null;
|
|
@@ -4876,6 +4901,16 @@ async function executeSandboxCode(options) {
|
|
|
4876
4901
|
env.INTEGRATE_INTEGRATIONS = options.integrationsHeader;
|
|
4877
4902
|
if (options.context)
|
|
4878
4903
|
env.INTEGRATE_CONTEXT = JSON.stringify(options.context);
|
|
4904
|
+
console.debug("[integrate-sdk] Sandbox env:", JSON.stringify({
|
|
4905
|
+
mcpUrl: options.mcpUrl,
|
|
4906
|
+
hasApiKey: !!options.apiKey,
|
|
4907
|
+
hasSessionToken: !!options.sessionToken,
|
|
4908
|
+
providerTokenKeys: options.providerTokens ? Object.keys(options.providerTokens) : [],
|
|
4909
|
+
hasIntegrations: !!options.integrationsHeader,
|
|
4910
|
+
hasContext: !!options.context,
|
|
4911
|
+
runtime,
|
|
4912
|
+
timeoutMs
|
|
4913
|
+
}));
|
|
4879
4914
|
const cmd = await sandbox.runCommand({
|
|
4880
4915
|
cmd: "node",
|
|
4881
4916
|
args: ["user.mjs"],
|
|
@@ -5002,6 +5037,15 @@ ${generated.compact}`;
|
|
|
5002
5037
|
}
|
|
5003
5038
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
5004
5039
|
let resolvedTokens = providerTokens;
|
|
5040
|
+
let tokenSource = resolvedTokens && Object.keys(resolvedTokens).length > 0 ? "build-time" : "none";
|
|
5041
|
+
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5042
|
+
try {
|
|
5043
|
+
resolvedTokens = await getProviderTokens();
|
|
5044
|
+
if (resolvedTokens && Object.keys(resolvedTokens).length > 0) {
|
|
5045
|
+
tokenSource = "request-header";
|
|
5046
|
+
}
|
|
5047
|
+
} catch {}
|
|
5048
|
+
}
|
|
5005
5049
|
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5006
5050
|
const oauthManager = client.oauthManager;
|
|
5007
5051
|
if (oauthManager) {
|
|
@@ -5020,9 +5064,17 @@ ${generated.compact}`;
|
|
|
5020
5064
|
}
|
|
5021
5065
|
if (Object.keys(resolvedTokens).length === 0) {
|
|
5022
5066
|
resolvedTokens = undefined;
|
|
5067
|
+
} else {
|
|
5068
|
+
tokenSource = "oauthManager";
|
|
5023
5069
|
}
|
|
5024
5070
|
}
|
|
5025
5071
|
}
|
|
5072
|
+
console.debug("[integrate-sdk] execute_code token resolution:", JSON.stringify({
|
|
5073
|
+
source: tokenSource,
|
|
5074
|
+
keys: resolvedTokens ? Object.keys(resolvedTokens) : [],
|
|
5075
|
+
hasApiKey: !!apiKey,
|
|
5076
|
+
mcpUrl
|
|
5077
|
+
}));
|
|
5026
5078
|
return executeSandboxCode({
|
|
5027
5079
|
code,
|
|
5028
5080
|
mcpUrl,
|
package/dist/ai/google.js
CHANGED
|
@@ -4677,6 +4677,21 @@ if (!MCP_URL) {
|
|
|
4677
4677
|
throw new Error('INTEGRATE_MCP_URL is not set — the sandbox cannot reach the MCP route.');
|
|
4678
4678
|
}
|
|
4679
4679
|
|
|
4680
|
+
// Diagnostic: log sandbox env summary to stderr so it shows up in the
|
|
4681
|
+
// execute_code result's stderr field for debugging auth issues.
|
|
4682
|
+
console.error('[sandbox-diag] MCP_URL=' + MCP_URL);
|
|
4683
|
+
console.error('[sandbox-diag] HAS_API_KEY=' + !!API_KEY);
|
|
4684
|
+
console.error('[sandbox-diag] HAS_SESSION_TOKEN=' + !!SESSION_TOKEN);
|
|
4685
|
+
console.error('[sandbox-diag] HAS_PROVIDER_TOKENS=' + !!PROVIDER_TOKENS);
|
|
4686
|
+
if (PROVIDER_TOKENS) {
|
|
4687
|
+
try {
|
|
4688
|
+
const _parsed = JSON.parse(PROVIDER_TOKENS);
|
|
4689
|
+
const _keys = Object.keys(_parsed);
|
|
4690
|
+
console.error('[sandbox-diag] PROVIDER_TOKEN_KEYS=' + _keys.join(','));
|
|
4691
|
+
console.error('[sandbox-diag] TOKEN_LENGTHS=' + _keys.map(k => k + ':' + (typeof _parsed[k] === 'string' ? _parsed[k].length : typeof _parsed[k])).join(','));
|
|
4692
|
+
} catch { console.error('[sandbox-diag] PROVIDER_TOKENS is not valid JSON'); }
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4680
4695
|
function camelToSnake(str) {
|
|
4681
4696
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4697
|
}
|
|
@@ -4692,6 +4707,14 @@ async function callTool(toolName, args) {
|
|
|
4692
4707
|
if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;
|
|
4693
4708
|
if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;
|
|
4694
4709
|
|
|
4710
|
+
console.error('[sandbox-diag] callTool: ' + toolName + ' → ' + MCP_URL);
|
|
4711
|
+
console.error('[sandbox-diag] headers: ' + JSON.stringify({
|
|
4712
|
+
hasAuth: !!headers['Authorization'],
|
|
4713
|
+
hasApiKey: !!headers['x-integrate-api-key'],
|
|
4714
|
+
hasTokens: !!headers['x-integrate-tokens'],
|
|
4715
|
+
hasCodeMode: !!headers['x-integrate-code-mode'],
|
|
4716
|
+
}));
|
|
4717
|
+
|
|
4695
4718
|
const res = await fetch(MCP_URL, {
|
|
4696
4719
|
method: 'POST',
|
|
4697
4720
|
headers,
|
|
@@ -4699,6 +4722,8 @@ async function callTool(toolName, args) {
|
|
|
4699
4722
|
});
|
|
4700
4723
|
|
|
4701
4724
|
const text = await res.text();
|
|
4725
|
+
console.error('[sandbox-diag] response: HTTP ' + res.status + ' len=' + text.length);
|
|
4726
|
+
|
|
4702
4727
|
let payload;
|
|
4703
4728
|
try {
|
|
4704
4729
|
payload = text ? JSON.parse(text) : null;
|
|
@@ -4876,6 +4901,16 @@ async function executeSandboxCode(options) {
|
|
|
4876
4901
|
env.INTEGRATE_INTEGRATIONS = options.integrationsHeader;
|
|
4877
4902
|
if (options.context)
|
|
4878
4903
|
env.INTEGRATE_CONTEXT = JSON.stringify(options.context);
|
|
4904
|
+
console.debug("[integrate-sdk] Sandbox env:", JSON.stringify({
|
|
4905
|
+
mcpUrl: options.mcpUrl,
|
|
4906
|
+
hasApiKey: !!options.apiKey,
|
|
4907
|
+
hasSessionToken: !!options.sessionToken,
|
|
4908
|
+
providerTokenKeys: options.providerTokens ? Object.keys(options.providerTokens) : [],
|
|
4909
|
+
hasIntegrations: !!options.integrationsHeader,
|
|
4910
|
+
hasContext: !!options.context,
|
|
4911
|
+
runtime,
|
|
4912
|
+
timeoutMs
|
|
4913
|
+
}));
|
|
4879
4914
|
const cmd = await sandbox.runCommand({
|
|
4880
4915
|
cmd: "node",
|
|
4881
4916
|
args: ["user.mjs"],
|
|
@@ -5002,6 +5037,15 @@ ${generated.compact}`;
|
|
|
5002
5037
|
}
|
|
5003
5038
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
5004
5039
|
let resolvedTokens = providerTokens;
|
|
5040
|
+
let tokenSource = resolvedTokens && Object.keys(resolvedTokens).length > 0 ? "build-time" : "none";
|
|
5041
|
+
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5042
|
+
try {
|
|
5043
|
+
resolvedTokens = await getProviderTokens();
|
|
5044
|
+
if (resolvedTokens && Object.keys(resolvedTokens).length > 0) {
|
|
5045
|
+
tokenSource = "request-header";
|
|
5046
|
+
}
|
|
5047
|
+
} catch {}
|
|
5048
|
+
}
|
|
5005
5049
|
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5006
5050
|
const oauthManager = client.oauthManager;
|
|
5007
5051
|
if (oauthManager) {
|
|
@@ -5020,9 +5064,17 @@ ${generated.compact}`;
|
|
|
5020
5064
|
}
|
|
5021
5065
|
if (Object.keys(resolvedTokens).length === 0) {
|
|
5022
5066
|
resolvedTokens = undefined;
|
|
5067
|
+
} else {
|
|
5068
|
+
tokenSource = "oauthManager";
|
|
5023
5069
|
}
|
|
5024
5070
|
}
|
|
5025
5071
|
}
|
|
5072
|
+
console.debug("[integrate-sdk] execute_code token resolution:", JSON.stringify({
|
|
5073
|
+
source: tokenSource,
|
|
5074
|
+
keys: resolvedTokens ? Object.keys(resolvedTokens) : [],
|
|
5075
|
+
hasApiKey: !!apiKey,
|
|
5076
|
+
mcpUrl
|
|
5077
|
+
}));
|
|
5026
5078
|
return executeSandboxCode({
|
|
5027
5079
|
code,
|
|
5028
5080
|
mcpUrl,
|
package/dist/ai/index.js
CHANGED
|
@@ -4677,6 +4677,21 @@ if (!MCP_URL) {
|
|
|
4677
4677
|
throw new Error('INTEGRATE_MCP_URL is not set — the sandbox cannot reach the MCP route.');
|
|
4678
4678
|
}
|
|
4679
4679
|
|
|
4680
|
+
// Diagnostic: log sandbox env summary to stderr so it shows up in the
|
|
4681
|
+
// execute_code result's stderr field for debugging auth issues.
|
|
4682
|
+
console.error('[sandbox-diag] MCP_URL=' + MCP_URL);
|
|
4683
|
+
console.error('[sandbox-diag] HAS_API_KEY=' + !!API_KEY);
|
|
4684
|
+
console.error('[sandbox-diag] HAS_SESSION_TOKEN=' + !!SESSION_TOKEN);
|
|
4685
|
+
console.error('[sandbox-diag] HAS_PROVIDER_TOKENS=' + !!PROVIDER_TOKENS);
|
|
4686
|
+
if (PROVIDER_TOKENS) {
|
|
4687
|
+
try {
|
|
4688
|
+
const _parsed = JSON.parse(PROVIDER_TOKENS);
|
|
4689
|
+
const _keys = Object.keys(_parsed);
|
|
4690
|
+
console.error('[sandbox-diag] PROVIDER_TOKEN_KEYS=' + _keys.join(','));
|
|
4691
|
+
console.error('[sandbox-diag] TOKEN_LENGTHS=' + _keys.map(k => k + ':' + (typeof _parsed[k] === 'string' ? _parsed[k].length : typeof _parsed[k])).join(','));
|
|
4692
|
+
} catch { console.error('[sandbox-diag] PROVIDER_TOKENS is not valid JSON'); }
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4680
4695
|
function camelToSnake(str) {
|
|
4681
4696
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4697
|
}
|
|
@@ -4692,6 +4707,14 @@ async function callTool(toolName, args) {
|
|
|
4692
4707
|
if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;
|
|
4693
4708
|
if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;
|
|
4694
4709
|
|
|
4710
|
+
console.error('[sandbox-diag] callTool: ' + toolName + ' → ' + MCP_URL);
|
|
4711
|
+
console.error('[sandbox-diag] headers: ' + JSON.stringify({
|
|
4712
|
+
hasAuth: !!headers['Authorization'],
|
|
4713
|
+
hasApiKey: !!headers['x-integrate-api-key'],
|
|
4714
|
+
hasTokens: !!headers['x-integrate-tokens'],
|
|
4715
|
+
hasCodeMode: !!headers['x-integrate-code-mode'],
|
|
4716
|
+
}));
|
|
4717
|
+
|
|
4695
4718
|
const res = await fetch(MCP_URL, {
|
|
4696
4719
|
method: 'POST',
|
|
4697
4720
|
headers,
|
|
@@ -4699,6 +4722,8 @@ async function callTool(toolName, args) {
|
|
|
4699
4722
|
});
|
|
4700
4723
|
|
|
4701
4724
|
const text = await res.text();
|
|
4725
|
+
console.error('[sandbox-diag] response: HTTP ' + res.status + ' len=' + text.length);
|
|
4726
|
+
|
|
4702
4727
|
let payload;
|
|
4703
4728
|
try {
|
|
4704
4729
|
payload = text ? JSON.parse(text) : null;
|
|
@@ -4876,6 +4901,16 @@ async function executeSandboxCode(options) {
|
|
|
4876
4901
|
env.INTEGRATE_INTEGRATIONS = options.integrationsHeader;
|
|
4877
4902
|
if (options.context)
|
|
4878
4903
|
env.INTEGRATE_CONTEXT = JSON.stringify(options.context);
|
|
4904
|
+
console.debug("[integrate-sdk] Sandbox env:", JSON.stringify({
|
|
4905
|
+
mcpUrl: options.mcpUrl,
|
|
4906
|
+
hasApiKey: !!options.apiKey,
|
|
4907
|
+
hasSessionToken: !!options.sessionToken,
|
|
4908
|
+
providerTokenKeys: options.providerTokens ? Object.keys(options.providerTokens) : [],
|
|
4909
|
+
hasIntegrations: !!options.integrationsHeader,
|
|
4910
|
+
hasContext: !!options.context,
|
|
4911
|
+
runtime,
|
|
4912
|
+
timeoutMs
|
|
4913
|
+
}));
|
|
4879
4914
|
const cmd = await sandbox.runCommand({
|
|
4880
4915
|
cmd: "node",
|
|
4881
4916
|
args: ["user.mjs"],
|
|
@@ -5002,6 +5037,15 @@ ${generated.compact}`;
|
|
|
5002
5037
|
}
|
|
5003
5038
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
5004
5039
|
let resolvedTokens = providerTokens;
|
|
5040
|
+
let tokenSource = resolvedTokens && Object.keys(resolvedTokens).length > 0 ? "build-time" : "none";
|
|
5041
|
+
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5042
|
+
try {
|
|
5043
|
+
resolvedTokens = await getProviderTokens();
|
|
5044
|
+
if (resolvedTokens && Object.keys(resolvedTokens).length > 0) {
|
|
5045
|
+
tokenSource = "request-header";
|
|
5046
|
+
}
|
|
5047
|
+
} catch {}
|
|
5048
|
+
}
|
|
5005
5049
|
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5006
5050
|
const oauthManager = client.oauthManager;
|
|
5007
5051
|
if (oauthManager) {
|
|
@@ -5020,9 +5064,17 @@ ${generated.compact}`;
|
|
|
5020
5064
|
}
|
|
5021
5065
|
if (Object.keys(resolvedTokens).length === 0) {
|
|
5022
5066
|
resolvedTokens = undefined;
|
|
5067
|
+
} else {
|
|
5068
|
+
tokenSource = "oauthManager";
|
|
5023
5069
|
}
|
|
5024
5070
|
}
|
|
5025
5071
|
}
|
|
5072
|
+
console.debug("[integrate-sdk] execute_code token resolution:", JSON.stringify({
|
|
5073
|
+
source: tokenSource,
|
|
5074
|
+
keys: resolvedTokens ? Object.keys(resolvedTokens) : [],
|
|
5075
|
+
hasApiKey: !!apiKey,
|
|
5076
|
+
mcpUrl
|
|
5077
|
+
}));
|
|
5026
5078
|
return executeSandboxCode({
|
|
5027
5079
|
code,
|
|
5028
5080
|
mcpUrl,
|
package/dist/ai/openai.js
CHANGED
|
@@ -4677,6 +4677,21 @@ if (!MCP_URL) {
|
|
|
4677
4677
|
throw new Error('INTEGRATE_MCP_URL is not set — the sandbox cannot reach the MCP route.');
|
|
4678
4678
|
}
|
|
4679
4679
|
|
|
4680
|
+
// Diagnostic: log sandbox env summary to stderr so it shows up in the
|
|
4681
|
+
// execute_code result's stderr field for debugging auth issues.
|
|
4682
|
+
console.error('[sandbox-diag] MCP_URL=' + MCP_URL);
|
|
4683
|
+
console.error('[sandbox-diag] HAS_API_KEY=' + !!API_KEY);
|
|
4684
|
+
console.error('[sandbox-diag] HAS_SESSION_TOKEN=' + !!SESSION_TOKEN);
|
|
4685
|
+
console.error('[sandbox-diag] HAS_PROVIDER_TOKENS=' + !!PROVIDER_TOKENS);
|
|
4686
|
+
if (PROVIDER_TOKENS) {
|
|
4687
|
+
try {
|
|
4688
|
+
const _parsed = JSON.parse(PROVIDER_TOKENS);
|
|
4689
|
+
const _keys = Object.keys(_parsed);
|
|
4690
|
+
console.error('[sandbox-diag] PROVIDER_TOKEN_KEYS=' + _keys.join(','));
|
|
4691
|
+
console.error('[sandbox-diag] TOKEN_LENGTHS=' + _keys.map(k => k + ':' + (typeof _parsed[k] === 'string' ? _parsed[k].length : typeof _parsed[k])).join(','));
|
|
4692
|
+
} catch { console.error('[sandbox-diag] PROVIDER_TOKENS is not valid JSON'); }
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4680
4695
|
function camelToSnake(str) {
|
|
4681
4696
|
return str.replace(/[A-Z]/g, (letter) => '_' + letter.toLowerCase());
|
|
4682
4697
|
}
|
|
@@ -4692,6 +4707,14 @@ async function callTool(toolName, args) {
|
|
|
4692
4707
|
if (INTEGRATIONS_HEADER) headers['x-integrations'] = INTEGRATIONS_HEADER;
|
|
4693
4708
|
if (CONTEXT_JSON) headers['x-integrate-context'] = CONTEXT_JSON;
|
|
4694
4709
|
|
|
4710
|
+
console.error('[sandbox-diag] callTool: ' + toolName + ' → ' + MCP_URL);
|
|
4711
|
+
console.error('[sandbox-diag] headers: ' + JSON.stringify({
|
|
4712
|
+
hasAuth: !!headers['Authorization'],
|
|
4713
|
+
hasApiKey: !!headers['x-integrate-api-key'],
|
|
4714
|
+
hasTokens: !!headers['x-integrate-tokens'],
|
|
4715
|
+
hasCodeMode: !!headers['x-integrate-code-mode'],
|
|
4716
|
+
}));
|
|
4717
|
+
|
|
4695
4718
|
const res = await fetch(MCP_URL, {
|
|
4696
4719
|
method: 'POST',
|
|
4697
4720
|
headers,
|
|
@@ -4699,6 +4722,8 @@ async function callTool(toolName, args) {
|
|
|
4699
4722
|
});
|
|
4700
4723
|
|
|
4701
4724
|
const text = await res.text();
|
|
4725
|
+
console.error('[sandbox-diag] response: HTTP ' + res.status + ' len=' + text.length);
|
|
4726
|
+
|
|
4702
4727
|
let payload;
|
|
4703
4728
|
try {
|
|
4704
4729
|
payload = text ? JSON.parse(text) : null;
|
|
@@ -4876,6 +4901,16 @@ async function executeSandboxCode(options) {
|
|
|
4876
4901
|
env.INTEGRATE_INTEGRATIONS = options.integrationsHeader;
|
|
4877
4902
|
if (options.context)
|
|
4878
4903
|
env.INTEGRATE_CONTEXT = JSON.stringify(options.context);
|
|
4904
|
+
console.debug("[integrate-sdk] Sandbox env:", JSON.stringify({
|
|
4905
|
+
mcpUrl: options.mcpUrl,
|
|
4906
|
+
hasApiKey: !!options.apiKey,
|
|
4907
|
+
hasSessionToken: !!options.sessionToken,
|
|
4908
|
+
providerTokenKeys: options.providerTokens ? Object.keys(options.providerTokens) : [],
|
|
4909
|
+
hasIntegrations: !!options.integrationsHeader,
|
|
4910
|
+
hasContext: !!options.context,
|
|
4911
|
+
runtime,
|
|
4912
|
+
timeoutMs
|
|
4913
|
+
}));
|
|
4879
4914
|
const cmd = await sandbox.runCommand({
|
|
4880
4915
|
cmd: "node",
|
|
4881
4916
|
args: ["user.mjs"],
|
|
@@ -5002,6 +5037,15 @@ ${generated.compact}`;
|
|
|
5002
5037
|
}
|
|
5003
5038
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
5004
5039
|
let resolvedTokens = providerTokens;
|
|
5040
|
+
let tokenSource = resolvedTokens && Object.keys(resolvedTokens).length > 0 ? "build-time" : "none";
|
|
5041
|
+
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5042
|
+
try {
|
|
5043
|
+
resolvedTokens = await getProviderTokens();
|
|
5044
|
+
if (resolvedTokens && Object.keys(resolvedTokens).length > 0) {
|
|
5045
|
+
tokenSource = "request-header";
|
|
5046
|
+
}
|
|
5047
|
+
} catch {}
|
|
5048
|
+
}
|
|
5005
5049
|
if (!resolvedTokens || Object.keys(resolvedTokens).length === 0) {
|
|
5006
5050
|
const oauthManager = client.oauthManager;
|
|
5007
5051
|
if (oauthManager) {
|
|
@@ -5020,9 +5064,17 @@ ${generated.compact}`;
|
|
|
5020
5064
|
}
|
|
5021
5065
|
if (Object.keys(resolvedTokens).length === 0) {
|
|
5022
5066
|
resolvedTokens = undefined;
|
|
5067
|
+
} else {
|
|
5068
|
+
tokenSource = "oauthManager";
|
|
5023
5069
|
}
|
|
5024
5070
|
}
|
|
5025
5071
|
}
|
|
5072
|
+
console.debug("[integrate-sdk] execute_code token resolution:", JSON.stringify({
|
|
5073
|
+
source: tokenSource,
|
|
5074
|
+
keys: resolvedTokens ? Object.keys(resolvedTokens) : [],
|
|
5075
|
+
hasApiKey: !!apiKey,
|
|
5076
|
+
mcpUrl
|
|
5077
|
+
}));
|
|
5026
5078
|
return executeSandboxCode({
|
|
5027
5079
|
code,
|
|
5028
5080
|
mcpUrl,
|