integrate-sdk 0.9.8-dev.0 → 0.9.10-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 +96 -14
- package/dist/adapters/index.js +96 -14
- package/dist/adapters/nextjs.js +96 -14
- package/dist/adapters/node.js +96 -14
- package/dist/adapters/svelte-kit.js +96 -14
- package/dist/adapters/tanstack-start.js +96 -14
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +39 -8
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +39 -8
- package/dist/ai/index.js +75 -11
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +39 -8
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +39 -8
- package/dist/code-mode/index.js +33 -7
- package/dist/code-mode/tool-builder.d.ts +25 -1
- package/dist/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/code-mode/tool-builder.js +37 -7
- package/dist/index.js +96 -14
- package/dist/oauth.js +96 -14
- package/dist/server.js +96 -14
- 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/tool-builder.d.ts +25 -1
- package/dist/src/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +2 -2
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9182,16 +9182,46 @@ var sandboxFactoryOverride = null, _sandboxAvailableCache = null, _sandboxForced
|
|
|
9182
9182
|
var init_executor = () => {};
|
|
9183
9183
|
|
|
9184
9184
|
// src/code-mode/tool-builder.ts
|
|
9185
|
+
var exports_tool_builder = {};
|
|
9186
|
+
__export(exports_tool_builder, {
|
|
9187
|
+
warnCodeModeFallback: () => warnCodeModeFallback,
|
|
9188
|
+
resolveCodeModePublicUrl: () => resolveCodeModePublicUrl,
|
|
9189
|
+
resolveCodeModeClientConfig: () => resolveCodeModeClientConfig,
|
|
9190
|
+
diagnoseCodeMode: () => diagnoseCodeMode,
|
|
9191
|
+
canUseCodeMode: () => canUseCodeMode,
|
|
9192
|
+
buildCodeModeTool: () => buildCodeModeTool,
|
|
9193
|
+
__resetCodeModeFallbackWarnings: () => __resetCodeModeFallbackWarnings,
|
|
9194
|
+
CODE_MODE_TOOL_NAME: () => CODE_MODE_TOOL_NAME
|
|
9195
|
+
});
|
|
9185
9196
|
function resolveCodeModeClientConfig(client) {
|
|
9186
9197
|
const oauthConfig = client.__oauthConfig;
|
|
9187
9198
|
return oauthConfig?.codeMode ?? {};
|
|
9188
9199
|
}
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9200
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
9201
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
9202
|
+
}
|
|
9203
|
+
async function diagnoseCodeMode(client) {
|
|
9204
|
+
if (!await isSandboxAvailable()) {
|
|
9205
|
+
return { available: false, reason: "sandbox-missing" };
|
|
9206
|
+
}
|
|
9192
9207
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
9193
|
-
const publicUrl = serverConfig
|
|
9194
|
-
|
|
9208
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
9209
|
+
if (!publicUrl) {
|
|
9210
|
+
return { available: false, reason: "no-public-url" };
|
|
9211
|
+
}
|
|
9212
|
+
return { available: true };
|
|
9213
|
+
}
|
|
9214
|
+
async function canUseCodeMode(client) {
|
|
9215
|
+
return (await diagnoseCodeMode(client)).available;
|
|
9216
|
+
}
|
|
9217
|
+
function __resetCodeModeFallbackWarnings() {
|
|
9218
|
+
warnedCodeModeReasons.clear();
|
|
9219
|
+
}
|
|
9220
|
+
function warnCodeModeFallback(reason) {
|
|
9221
|
+
if (warnedCodeModeReasons.has(reason))
|
|
9222
|
+
return;
|
|
9223
|
+
warnedCodeModeReasons.add(reason);
|
|
9224
|
+
console.warn(CODE_MODE_UNAVAILABLE_MESSAGES[reason]);
|
|
9195
9225
|
}
|
|
9196
9226
|
function buildCodeModeTool(client, options) {
|
|
9197
9227
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -9204,7 +9234,9 @@ function buildCodeModeTool(client, options) {
|
|
|
9204
9234
|
${generated.source}
|
|
9205
9235
|
\`\`\``;
|
|
9206
9236
|
const execute = async ({ code }) => {
|
|
9207
|
-
const publicUrl =
|
|
9237
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
9238
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
9239
|
+
});
|
|
9208
9240
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
9209
9241
|
if (!publicUrl) {
|
|
9210
9242
|
return {
|
|
@@ -9213,7 +9245,7 @@ ${generated.source}
|
|
|
9213
9245
|
stdout: "",
|
|
9214
9246
|
stderr: "",
|
|
9215
9247
|
durationMs: 0,
|
|
9216
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
9248
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). " + "The sandbox uses it to call back into /api/integrate/mcp."
|
|
9217
9249
|
};
|
|
9218
9250
|
}
|
|
9219
9251
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
@@ -9247,7 +9279,7 @@ ${generated.source}
|
|
|
9247
9279
|
execute
|
|
9248
9280
|
};
|
|
9249
9281
|
}
|
|
9250
|
-
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS;
|
|
9282
|
+
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS, CODE_MODE_UNAVAILABLE_MESSAGES, warnedCodeModeReasons;
|
|
9251
9283
|
var init_tool_builder = __esm(() => {
|
|
9252
9284
|
init_type_generator();
|
|
9253
9285
|
init_executor();
|
|
@@ -9272,6 +9304,11 @@ var init_tool_builder = __esm(() => {
|
|
|
9272
9304
|
"API surface:"
|
|
9273
9305
|
].join(`
|
|
9274
9306
|
`);
|
|
9307
|
+
CODE_MODE_UNAVAILABLE_MESSAGES = {
|
|
9308
|
+
"sandbox-missing": "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Install `@vercel/sandbox` (e.g. `bun add @vercel/sandbox`) to enable Code Mode.",
|
|
9309
|
+
"no-public-url": "[integrate-sdk] Code Mode unavailable (reason: no-public-url) — falling back to tool mode. " + "Set `codeMode.publicUrl` on your server config or the `INTEGRATE_URL` env var."
|
|
9310
|
+
};
|
|
9311
|
+
warnedCodeModeReasons = new Set;
|
|
9275
9312
|
});
|
|
9276
9313
|
|
|
9277
9314
|
// src/ai/vercel-ai.ts
|
|
@@ -9298,7 +9335,18 @@ async function getVercelAITools(client, options) {
|
|
|
9298
9335
|
await ensureClientConnected(client);
|
|
9299
9336
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
9300
9337
|
const vercelTools = {};
|
|
9301
|
-
|
|
9338
|
+
let effectiveMode;
|
|
9339
|
+
if (options?.mode !== undefined) {
|
|
9340
|
+
effectiveMode = options.mode;
|
|
9341
|
+
} else {
|
|
9342
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
9343
|
+
if (diagnosis.available) {
|
|
9344
|
+
effectiveMode = "code";
|
|
9345
|
+
} else {
|
|
9346
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
9347
|
+
effectiveMode = "tools";
|
|
9348
|
+
}
|
|
9349
|
+
}
|
|
9302
9350
|
if (effectiveMode === "code") {
|
|
9303
9351
|
const codeTool = buildCodeModeTool(client, {
|
|
9304
9352
|
tools: mcpTools,
|
|
@@ -10757,7 +10805,18 @@ async function getOpenAITools(client, options) {
|
|
|
10757
10805
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
10758
10806
|
await ensureClientConnected(client);
|
|
10759
10807
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
10760
|
-
|
|
10808
|
+
let effectiveMode;
|
|
10809
|
+
if (options?.mode !== undefined) {
|
|
10810
|
+
effectiveMode = options.mode;
|
|
10811
|
+
} else {
|
|
10812
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
10813
|
+
if (diagnosis.available) {
|
|
10814
|
+
effectiveMode = "code";
|
|
10815
|
+
} else {
|
|
10816
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
10817
|
+
effectiveMode = "tools";
|
|
10818
|
+
}
|
|
10819
|
+
}
|
|
10761
10820
|
const openaiTools = effectiveMode === "code" ? (() => {
|
|
10762
10821
|
const codeTool = buildCodeModeTool(client, {
|
|
10763
10822
|
tools: mcpTools,
|
|
@@ -10937,7 +10996,18 @@ async function getAnthropicTools(client, options) {
|
|
|
10937
10996
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
10938
10997
|
await ensureClientConnected(client);
|
|
10939
10998
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
10940
|
-
|
|
10999
|
+
let effectiveMode;
|
|
11000
|
+
if (options?.mode !== undefined) {
|
|
11001
|
+
effectiveMode = options.mode;
|
|
11002
|
+
} else {
|
|
11003
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11004
|
+
if (diagnosis.available) {
|
|
11005
|
+
effectiveMode = "code";
|
|
11006
|
+
} else {
|
|
11007
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11008
|
+
effectiveMode = "tools";
|
|
11009
|
+
}
|
|
11010
|
+
}
|
|
10941
11011
|
const anthropicTools = effectiveMode === "code" ? (() => {
|
|
10942
11012
|
const codeTool = buildCodeModeTool(client, {
|
|
10943
11013
|
tools: mcpTools,
|
|
@@ -11126,7 +11196,18 @@ async function getGoogleTools(client, options) {
|
|
|
11126
11196
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
11127
11197
|
await ensureClientConnected(client);
|
|
11128
11198
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
11129
|
-
|
|
11199
|
+
let effectiveMode;
|
|
11200
|
+
if (options?.mode !== undefined) {
|
|
11201
|
+
effectiveMode = options.mode;
|
|
11202
|
+
} else {
|
|
11203
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11204
|
+
if (diagnosis.available) {
|
|
11205
|
+
effectiveMode = "code";
|
|
11206
|
+
} else {
|
|
11207
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11208
|
+
effectiveMode = "tools";
|
|
11209
|
+
}
|
|
11210
|
+
}
|
|
11130
11211
|
let googleTools;
|
|
11131
11212
|
if (effectiveMode === "code") {
|
|
11132
11213
|
const TypeEnum = await getGoogleType();
|
|
@@ -11720,11 +11801,12 @@ function createMCPServer(config) {
|
|
|
11720
11801
|
return Response.json({ error: "`code` is required and must be a non-empty string." }, { status: 400 });
|
|
11721
11802
|
}
|
|
11722
11803
|
const { executeSandboxCode: executeSandboxCode2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
|
|
11804
|
+
const { resolveCodeModePublicUrl: resolveCodeModePublicUrl2 } = await Promise.resolve().then(() => (init_tool_builder(), exports_tool_builder));
|
|
11723
11805
|
const codeModeConfig = config.codeMode ?? {};
|
|
11724
|
-
const publicUrl = codeModeConfig
|
|
11806
|
+
const publicUrl = resolveCodeModePublicUrl2(codeModeConfig);
|
|
11725
11807
|
if (!publicUrl) {
|
|
11726
11808
|
return Response.json({
|
|
11727
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
11809
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). Set it to the public origin where /api/integrate/mcp is reachable."
|
|
11728
11810
|
}, { status: 500 });
|
|
11729
11811
|
}
|
|
11730
11812
|
let contextOverride = body.context;
|
package/dist/oauth.js
CHANGED
|
@@ -9016,16 +9016,46 @@ var sandboxFactoryOverride = null, _sandboxAvailableCache = null, _sandboxForced
|
|
|
9016
9016
|
var init_executor = () => {};
|
|
9017
9017
|
|
|
9018
9018
|
// src/code-mode/tool-builder.ts
|
|
9019
|
+
var exports_tool_builder = {};
|
|
9020
|
+
__export(exports_tool_builder, {
|
|
9021
|
+
warnCodeModeFallback: () => warnCodeModeFallback,
|
|
9022
|
+
resolveCodeModePublicUrl: () => resolveCodeModePublicUrl,
|
|
9023
|
+
resolveCodeModeClientConfig: () => resolveCodeModeClientConfig,
|
|
9024
|
+
diagnoseCodeMode: () => diagnoseCodeMode,
|
|
9025
|
+
canUseCodeMode: () => canUseCodeMode,
|
|
9026
|
+
buildCodeModeTool: () => buildCodeModeTool,
|
|
9027
|
+
__resetCodeModeFallbackWarnings: () => __resetCodeModeFallbackWarnings,
|
|
9028
|
+
CODE_MODE_TOOL_NAME: () => CODE_MODE_TOOL_NAME
|
|
9029
|
+
});
|
|
9019
9030
|
function resolveCodeModeClientConfig(client) {
|
|
9020
9031
|
const oauthConfig = client.__oauthConfig;
|
|
9021
9032
|
return oauthConfig?.codeMode ?? {};
|
|
9022
9033
|
}
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9034
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
9035
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
9036
|
+
}
|
|
9037
|
+
async function diagnoseCodeMode(client) {
|
|
9038
|
+
if (!await isSandboxAvailable()) {
|
|
9039
|
+
return { available: false, reason: "sandbox-missing" };
|
|
9040
|
+
}
|
|
9026
9041
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
9027
|
-
const publicUrl = serverConfig
|
|
9028
|
-
|
|
9042
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
9043
|
+
if (!publicUrl) {
|
|
9044
|
+
return { available: false, reason: "no-public-url" };
|
|
9045
|
+
}
|
|
9046
|
+
return { available: true };
|
|
9047
|
+
}
|
|
9048
|
+
async function canUseCodeMode(client) {
|
|
9049
|
+
return (await diagnoseCodeMode(client)).available;
|
|
9050
|
+
}
|
|
9051
|
+
function __resetCodeModeFallbackWarnings() {
|
|
9052
|
+
warnedCodeModeReasons.clear();
|
|
9053
|
+
}
|
|
9054
|
+
function warnCodeModeFallback(reason) {
|
|
9055
|
+
if (warnedCodeModeReasons.has(reason))
|
|
9056
|
+
return;
|
|
9057
|
+
warnedCodeModeReasons.add(reason);
|
|
9058
|
+
console.warn(CODE_MODE_UNAVAILABLE_MESSAGES[reason]);
|
|
9029
9059
|
}
|
|
9030
9060
|
function buildCodeModeTool(client, options) {
|
|
9031
9061
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -9038,7 +9068,9 @@ function buildCodeModeTool(client, options) {
|
|
|
9038
9068
|
${generated.source}
|
|
9039
9069
|
\`\`\``;
|
|
9040
9070
|
const execute = async ({ code }) => {
|
|
9041
|
-
const publicUrl =
|
|
9071
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
9072
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
9073
|
+
});
|
|
9042
9074
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
9043
9075
|
if (!publicUrl) {
|
|
9044
9076
|
return {
|
|
@@ -9047,7 +9079,7 @@ ${generated.source}
|
|
|
9047
9079
|
stdout: "",
|
|
9048
9080
|
stderr: "",
|
|
9049
9081
|
durationMs: 0,
|
|
9050
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
9082
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). " + "The sandbox uses it to call back into /api/integrate/mcp."
|
|
9051
9083
|
};
|
|
9052
9084
|
}
|
|
9053
9085
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
@@ -9081,7 +9113,7 @@ ${generated.source}
|
|
|
9081
9113
|
execute
|
|
9082
9114
|
};
|
|
9083
9115
|
}
|
|
9084
|
-
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS;
|
|
9116
|
+
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS, CODE_MODE_UNAVAILABLE_MESSAGES, warnedCodeModeReasons;
|
|
9085
9117
|
var init_tool_builder = __esm(() => {
|
|
9086
9118
|
init_type_generator();
|
|
9087
9119
|
init_executor();
|
|
@@ -9106,6 +9138,11 @@ var init_tool_builder = __esm(() => {
|
|
|
9106
9138
|
"API surface:"
|
|
9107
9139
|
].join(`
|
|
9108
9140
|
`);
|
|
9141
|
+
CODE_MODE_UNAVAILABLE_MESSAGES = {
|
|
9142
|
+
"sandbox-missing": "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Install `@vercel/sandbox` (e.g. `bun add @vercel/sandbox`) to enable Code Mode.",
|
|
9143
|
+
"no-public-url": "[integrate-sdk] Code Mode unavailable (reason: no-public-url) — falling back to tool mode. " + "Set `codeMode.publicUrl` on your server config or the `INTEGRATE_URL` env var."
|
|
9144
|
+
};
|
|
9145
|
+
warnedCodeModeReasons = new Set;
|
|
9109
9146
|
});
|
|
9110
9147
|
|
|
9111
9148
|
// src/ai/vercel-ai.ts
|
|
@@ -9132,7 +9169,18 @@ async function getVercelAITools(client, options) {
|
|
|
9132
9169
|
await ensureClientConnected(client);
|
|
9133
9170
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
9134
9171
|
const vercelTools = {};
|
|
9135
|
-
|
|
9172
|
+
let effectiveMode;
|
|
9173
|
+
if (options?.mode !== undefined) {
|
|
9174
|
+
effectiveMode = options.mode;
|
|
9175
|
+
} else {
|
|
9176
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
9177
|
+
if (diagnosis.available) {
|
|
9178
|
+
effectiveMode = "code";
|
|
9179
|
+
} else {
|
|
9180
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
9181
|
+
effectiveMode = "tools";
|
|
9182
|
+
}
|
|
9183
|
+
}
|
|
9136
9184
|
if (effectiveMode === "code") {
|
|
9137
9185
|
const codeTool = buildCodeModeTool(client, {
|
|
9138
9186
|
tools: mcpTools,
|
|
@@ -10591,7 +10639,18 @@ async function getOpenAITools(client, options) {
|
|
|
10591
10639
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
10592
10640
|
await ensureClientConnected(client);
|
|
10593
10641
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
10594
|
-
|
|
10642
|
+
let effectiveMode;
|
|
10643
|
+
if (options?.mode !== undefined) {
|
|
10644
|
+
effectiveMode = options.mode;
|
|
10645
|
+
} else {
|
|
10646
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
10647
|
+
if (diagnosis.available) {
|
|
10648
|
+
effectiveMode = "code";
|
|
10649
|
+
} else {
|
|
10650
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
10651
|
+
effectiveMode = "tools";
|
|
10652
|
+
}
|
|
10653
|
+
}
|
|
10595
10654
|
const openaiTools = effectiveMode === "code" ? (() => {
|
|
10596
10655
|
const codeTool = buildCodeModeTool(client, {
|
|
10597
10656
|
tools: mcpTools,
|
|
@@ -10771,7 +10830,18 @@ async function getAnthropicTools(client, options) {
|
|
|
10771
10830
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
10772
10831
|
await ensureClientConnected(client);
|
|
10773
10832
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
10774
|
-
|
|
10833
|
+
let effectiveMode;
|
|
10834
|
+
if (options?.mode !== undefined) {
|
|
10835
|
+
effectiveMode = options.mode;
|
|
10836
|
+
} else {
|
|
10837
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
10838
|
+
if (diagnosis.available) {
|
|
10839
|
+
effectiveMode = "code";
|
|
10840
|
+
} else {
|
|
10841
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
10842
|
+
effectiveMode = "tools";
|
|
10843
|
+
}
|
|
10844
|
+
}
|
|
10775
10845
|
const anthropicTools = effectiveMode === "code" ? (() => {
|
|
10776
10846
|
const codeTool = buildCodeModeTool(client, {
|
|
10777
10847
|
tools: mcpTools,
|
|
@@ -10960,7 +11030,18 @@ async function getGoogleTools(client, options) {
|
|
|
10960
11030
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
10961
11031
|
await ensureClientConnected(client);
|
|
10962
11032
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
10963
|
-
|
|
11033
|
+
let effectiveMode;
|
|
11034
|
+
if (options?.mode !== undefined) {
|
|
11035
|
+
effectiveMode = options.mode;
|
|
11036
|
+
} else {
|
|
11037
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11038
|
+
if (diagnosis.available) {
|
|
11039
|
+
effectiveMode = "code";
|
|
11040
|
+
} else {
|
|
11041
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11042
|
+
effectiveMode = "tools";
|
|
11043
|
+
}
|
|
11044
|
+
}
|
|
10964
11045
|
let googleTools;
|
|
10965
11046
|
if (effectiveMode === "code") {
|
|
10966
11047
|
const TypeEnum = await getGoogleType();
|
|
@@ -11554,11 +11635,12 @@ function createMCPServer(config) {
|
|
|
11554
11635
|
return Response.json({ error: "`code` is required and must be a non-empty string." }, { status: 400 });
|
|
11555
11636
|
}
|
|
11556
11637
|
const { executeSandboxCode: executeSandboxCode2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
|
|
11638
|
+
const { resolveCodeModePublicUrl: resolveCodeModePublicUrl2 } = await Promise.resolve().then(() => (init_tool_builder(), exports_tool_builder));
|
|
11557
11639
|
const codeModeConfig = config.codeMode ?? {};
|
|
11558
|
-
const publicUrl = codeModeConfig
|
|
11640
|
+
const publicUrl = resolveCodeModePublicUrl2(codeModeConfig);
|
|
11559
11641
|
if (!publicUrl) {
|
|
11560
11642
|
return Response.json({
|
|
11561
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
11643
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). Set it to the public origin where /api/integrate/mcp is reachable."
|
|
11562
11644
|
}, { status: 500 });
|
|
11563
11645
|
}
|
|
11564
11646
|
let contextOverride = body.context;
|
package/dist/server.js
CHANGED
|
@@ -9696,16 +9696,46 @@ var sandboxFactoryOverride = null, _sandboxAvailableCache = null, _sandboxForced
|
|
|
9696
9696
|
var init_executor = () => {};
|
|
9697
9697
|
|
|
9698
9698
|
// src/code-mode/tool-builder.ts
|
|
9699
|
+
var exports_tool_builder = {};
|
|
9700
|
+
__export(exports_tool_builder, {
|
|
9701
|
+
warnCodeModeFallback: () => warnCodeModeFallback,
|
|
9702
|
+
resolveCodeModePublicUrl: () => resolveCodeModePublicUrl,
|
|
9703
|
+
resolveCodeModeClientConfig: () => resolveCodeModeClientConfig,
|
|
9704
|
+
diagnoseCodeMode: () => diagnoseCodeMode,
|
|
9705
|
+
canUseCodeMode: () => canUseCodeMode,
|
|
9706
|
+
buildCodeModeTool: () => buildCodeModeTool,
|
|
9707
|
+
__resetCodeModeFallbackWarnings: () => __resetCodeModeFallbackWarnings,
|
|
9708
|
+
CODE_MODE_TOOL_NAME: () => CODE_MODE_TOOL_NAME
|
|
9709
|
+
});
|
|
9699
9710
|
function resolveCodeModeClientConfig(client) {
|
|
9700
9711
|
const oauthConfig = client.__oauthConfig;
|
|
9701
9712
|
return oauthConfig?.codeMode ?? {};
|
|
9702
9713
|
}
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9714
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
9715
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
9716
|
+
}
|
|
9717
|
+
async function diagnoseCodeMode(client) {
|
|
9718
|
+
if (!await isSandboxAvailable()) {
|
|
9719
|
+
return { available: false, reason: "sandbox-missing" };
|
|
9720
|
+
}
|
|
9706
9721
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
9707
|
-
const publicUrl = serverConfig
|
|
9708
|
-
|
|
9722
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
9723
|
+
if (!publicUrl) {
|
|
9724
|
+
return { available: false, reason: "no-public-url" };
|
|
9725
|
+
}
|
|
9726
|
+
return { available: true };
|
|
9727
|
+
}
|
|
9728
|
+
async function canUseCodeMode(client) {
|
|
9729
|
+
return (await diagnoseCodeMode(client)).available;
|
|
9730
|
+
}
|
|
9731
|
+
function __resetCodeModeFallbackWarnings() {
|
|
9732
|
+
warnedCodeModeReasons.clear();
|
|
9733
|
+
}
|
|
9734
|
+
function warnCodeModeFallback(reason) {
|
|
9735
|
+
if (warnedCodeModeReasons.has(reason))
|
|
9736
|
+
return;
|
|
9737
|
+
warnedCodeModeReasons.add(reason);
|
|
9738
|
+
console.warn(CODE_MODE_UNAVAILABLE_MESSAGES[reason]);
|
|
9709
9739
|
}
|
|
9710
9740
|
function buildCodeModeTool(client, options) {
|
|
9711
9741
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -9718,7 +9748,9 @@ function buildCodeModeTool(client, options) {
|
|
|
9718
9748
|
${generated.source}
|
|
9719
9749
|
\`\`\``;
|
|
9720
9750
|
const execute = async ({ code }) => {
|
|
9721
|
-
const publicUrl =
|
|
9751
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
9752
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
9753
|
+
});
|
|
9722
9754
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
9723
9755
|
if (!publicUrl) {
|
|
9724
9756
|
return {
|
|
@@ -9727,7 +9759,7 @@ ${generated.source}
|
|
|
9727
9759
|
stdout: "",
|
|
9728
9760
|
stderr: "",
|
|
9729
9761
|
durationMs: 0,
|
|
9730
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
9762
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). " + "The sandbox uses it to call back into /api/integrate/mcp."
|
|
9731
9763
|
};
|
|
9732
9764
|
}
|
|
9733
9765
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
|
@@ -9761,7 +9793,7 @@ ${generated.source}
|
|
|
9761
9793
|
execute
|
|
9762
9794
|
};
|
|
9763
9795
|
}
|
|
9764
|
-
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS;
|
|
9796
|
+
var CODE_MODE_TOOL_NAME = "execute_code", DEFAULT_INSTRUCTIONS, CODE_MODE_UNAVAILABLE_MESSAGES, warnedCodeModeReasons;
|
|
9765
9797
|
var init_tool_builder = __esm(() => {
|
|
9766
9798
|
init_type_generator();
|
|
9767
9799
|
init_executor();
|
|
@@ -9786,6 +9818,11 @@ var init_tool_builder = __esm(() => {
|
|
|
9786
9818
|
"API surface:"
|
|
9787
9819
|
].join(`
|
|
9788
9820
|
`);
|
|
9821
|
+
CODE_MODE_UNAVAILABLE_MESSAGES = {
|
|
9822
|
+
"sandbox-missing": "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Install `@vercel/sandbox` (e.g. `bun add @vercel/sandbox`) to enable Code Mode.",
|
|
9823
|
+
"no-public-url": "[integrate-sdk] Code Mode unavailable (reason: no-public-url) — falling back to tool mode. " + "Set `codeMode.publicUrl` on your server config or the `INTEGRATE_URL` env var."
|
|
9824
|
+
};
|
|
9825
|
+
warnedCodeModeReasons = new Set;
|
|
9789
9826
|
});
|
|
9790
9827
|
|
|
9791
9828
|
// src/ai/vercel-ai.ts
|
|
@@ -9812,7 +9849,18 @@ async function getVercelAITools(client, options) {
|
|
|
9812
9849
|
await ensureClientConnected(client);
|
|
9813
9850
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
9814
9851
|
const vercelTools = {};
|
|
9815
|
-
|
|
9852
|
+
let effectiveMode;
|
|
9853
|
+
if (options?.mode !== undefined) {
|
|
9854
|
+
effectiveMode = options.mode;
|
|
9855
|
+
} else {
|
|
9856
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
9857
|
+
if (diagnosis.available) {
|
|
9858
|
+
effectiveMode = "code";
|
|
9859
|
+
} else {
|
|
9860
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
9861
|
+
effectiveMode = "tools";
|
|
9862
|
+
}
|
|
9863
|
+
}
|
|
9816
9864
|
if (effectiveMode === "code") {
|
|
9817
9865
|
const codeTool = buildCodeModeTool(client, {
|
|
9818
9866
|
tools: mcpTools,
|
|
@@ -11271,7 +11319,18 @@ async function getOpenAITools(client, options) {
|
|
|
11271
11319
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
11272
11320
|
await ensureClientConnected(client);
|
|
11273
11321
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
11274
|
-
|
|
11322
|
+
let effectiveMode;
|
|
11323
|
+
if (options?.mode !== undefined) {
|
|
11324
|
+
effectiveMode = options.mode;
|
|
11325
|
+
} else {
|
|
11326
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11327
|
+
if (diagnosis.available) {
|
|
11328
|
+
effectiveMode = "code";
|
|
11329
|
+
} else {
|
|
11330
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11331
|
+
effectiveMode = "tools";
|
|
11332
|
+
}
|
|
11333
|
+
}
|
|
11275
11334
|
const openaiTools = effectiveMode === "code" ? (() => {
|
|
11276
11335
|
const codeTool = buildCodeModeTool(client, {
|
|
11277
11336
|
tools: mcpTools,
|
|
@@ -11451,7 +11510,18 @@ async function getAnthropicTools(client, options) {
|
|
|
11451
11510
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
11452
11511
|
await ensureClientConnected(client);
|
|
11453
11512
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
11454
|
-
|
|
11513
|
+
let effectiveMode;
|
|
11514
|
+
if (options?.mode !== undefined) {
|
|
11515
|
+
effectiveMode = options.mode;
|
|
11516
|
+
} else {
|
|
11517
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11518
|
+
if (diagnosis.available) {
|
|
11519
|
+
effectiveMode = "code";
|
|
11520
|
+
} else {
|
|
11521
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11522
|
+
effectiveMode = "tools";
|
|
11523
|
+
}
|
|
11524
|
+
}
|
|
11455
11525
|
const anthropicTools = effectiveMode === "code" ? (() => {
|
|
11456
11526
|
const codeTool = buildCodeModeTool(client, {
|
|
11457
11527
|
tools: mcpTools,
|
|
@@ -11640,7 +11710,18 @@ async function getGoogleTools(client, options) {
|
|
|
11640
11710
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
11641
11711
|
await ensureClientConnected(client);
|
|
11642
11712
|
const mcpTools = await client.getEnabledToolsAsync();
|
|
11643
|
-
|
|
11713
|
+
let effectiveMode;
|
|
11714
|
+
if (options?.mode !== undefined) {
|
|
11715
|
+
effectiveMode = options.mode;
|
|
11716
|
+
} else {
|
|
11717
|
+
const diagnosis = await diagnoseCodeMode(client);
|
|
11718
|
+
if (diagnosis.available) {
|
|
11719
|
+
effectiveMode = "code";
|
|
11720
|
+
} else {
|
|
11721
|
+
warnCodeModeFallback(diagnosis.reason);
|
|
11722
|
+
effectiveMode = "tools";
|
|
11723
|
+
}
|
|
11724
|
+
}
|
|
11644
11725
|
let googleTools;
|
|
11645
11726
|
if (effectiveMode === "code") {
|
|
11646
11727
|
const TypeEnum = await getGoogleType();
|
|
@@ -12234,11 +12315,12 @@ function createMCPServer(config) {
|
|
|
12234
12315
|
return Response.json({ error: "`code` is required and must be a non-empty string." }, { status: 400 });
|
|
12235
12316
|
}
|
|
12236
12317
|
const { executeSandboxCode: executeSandboxCode2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
|
|
12318
|
+
const { resolveCodeModePublicUrl: resolveCodeModePublicUrl2 } = await Promise.resolve().then(() => (init_tool_builder(), exports_tool_builder));
|
|
12237
12319
|
const codeModeConfig = config.codeMode ?? {};
|
|
12238
|
-
const publicUrl = codeModeConfig
|
|
12320
|
+
const publicUrl = resolveCodeModePublicUrl2(codeModeConfig);
|
|
12239
12321
|
if (!publicUrl) {
|
|
12240
12322
|
return Response.json({
|
|
12241
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
12323
|
+
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the INTEGRATE_URL env var). Set it to the public origin where /api/integrate/mcp is reachable."
|
|
12242
12324
|
}, { status: 500 });
|
|
12243
12325
|
}
|
|
12244
12326
|
let contextOverride = body.context;
|
|
@@ -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;AASjH,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,kDAA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AA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAkC5I"}
|
|
@@ -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;AAYjH,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,CA4DnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAwFvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/openai.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":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/openai.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;AASjH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAA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oB,CAAC;AACrD,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/ai/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AASpB;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,gCAkE/B"}
|
|
@@ -27,7 +27,7 @@ export interface CodeModeToolOptions {
|
|
|
27
27
|
/**
|
|
28
28
|
* Sandbox + callback overrides. Everything is optional — defaults come
|
|
29
29
|
* from the server client's `__oauthConfig.codeMode` block (set by
|
|
30
|
-
* `createMCPServer`) or from `
|
|
30
|
+
* `createMCPServer`) or from `INTEGRATE_URL`.
|
|
31
31
|
*/
|
|
32
32
|
sandbox?: {
|
|
33
33
|
publicUrl?: string;
|
|
@@ -74,7 +74,31 @@ export declare function resolveCodeModeClientConfig(client: MCPClient<any>): {
|
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
+
export type CodeModeUnavailableReason = "sandbox-missing" | "no-public-url";
|
|
78
|
+
export type CodeModeDiagnosis = {
|
|
79
|
+
available: true;
|
|
80
|
+
} | {
|
|
81
|
+
available: false;
|
|
82
|
+
reason: CodeModeUnavailableReason;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Resolve the public URL the sandbox should call back into. Precedence:
|
|
86
|
+
* 1. Explicit `codeMode.publicUrl` on the server config
|
|
87
|
+
* 2. `INTEGRATE_URL` env var (same variable used for OAuth redirect auto-detect)
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveCodeModePublicUrl(serverConfig?: {
|
|
90
|
+
publicUrl?: string;
|
|
91
|
+
}): string | undefined;
|
|
92
|
+
export declare function diagnoseCodeMode(client: MCPClient<any>): Promise<CodeModeDiagnosis>;
|
|
77
93
|
export declare function canUseCodeMode(client: MCPClient<any>): Promise<boolean>;
|
|
94
|
+
/** @internal — used by unit tests to reset the warn-once throttle. */
|
|
95
|
+
export declare function __resetCodeModeFallbackWarnings(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Called by AI helpers when auto-detection picks `tools` mode. Emits a
|
|
98
|
+
* throttled `console.warn` so operators can tell *why* Code Mode was
|
|
99
|
+
* silently downgraded. Each reason warns at most once per process.
|
|
100
|
+
*/
|
|
101
|
+
export declare function warnCodeModeFallback(reason: CodeModeUnavailableReason): void;
|
|
78
102
|
/**
|
|
79
103
|
* Build the `execute_code` tool definition. The returned `execute` function
|
|
80
104
|
* is what the AI provider SDK ultimately invokes when the model picks the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-builder.d.ts","sourceRoot":"","sources":["../../../src/code-mode/tool-builder.ts"],"names":[],"mappings":"AAAA;;;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