integrate-sdk 0.9.9-dev.0 → 0.9.13-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 +32750 -281
- package/dist/adapters/context-cookie.js +18 -0
- package/dist/adapters/index.js +32752 -283
- package/dist/adapters/nextjs-oauth-redirect.js +18 -0
- package/dist/adapters/nextjs.js +32750 -281
- package/dist/adapters/node.js +32750 -281
- package/dist/adapters/session-detector.js +18 -0
- package/dist/adapters/solid-start.js +18 -0
- package/dist/adapters/svelte-kit.js +32750 -281
- package/dist/adapters/tanstack-start.js +32752 -283
- package/dist/ai/anthropic.js +47 -15
- package/dist/ai/google.js +47 -15
- package/dist/ai/index.js +47 -15
- package/dist/ai/openai.js +47 -15
- package/dist/ai/trigger-tools.js +17 -0
- package/dist/ai/utils.js +17 -0
- package/dist/ai/vercel-ai.js +47 -15
- package/dist/code-mode/executor.d.ts +8 -0
- package/dist/code-mode/executor.d.ts.map +1 -1
- package/dist/code-mode/executor.js +35 -7
- package/dist/code-mode/index.js +51 -15
- package/dist/code-mode/runtime-stub.js +19 -0
- package/dist/code-mode/tool-builder.d.ts +9 -1
- package/dist/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/code-mode/tool-builder.js +52 -15
- package/dist/code-mode/type-generator.js +19 -0
- package/dist/index.js +76 -19
- package/dist/oauth.js +71 -19
- package/dist/react.js +22 -0
- package/dist/server.js +71 -19
- package/dist/src/code-mode/executor.d.ts +8 -0
- package/dist/src/code-mode/executor.d.ts.map +1 -1
- package/dist/src/code-mode/tool-builder.d.ts +9 -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 +2 -2
package/dist/ai/anthropic.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|
|
@@ -4692,7 +4709,11 @@ export { callTool };
|
|
|
4692
4709
|
// ../code-mode/executor.ts
|
|
4693
4710
|
var sandboxFactoryOverride = null;
|
|
4694
4711
|
var _sandboxAvailableCache = null;
|
|
4712
|
+
var _sandboxImportError = null;
|
|
4695
4713
|
var _sandboxForcedUnavailableForTests = false;
|
|
4714
|
+
function getSandboxImportError() {
|
|
4715
|
+
return _sandboxImportError;
|
|
4716
|
+
}
|
|
4696
4717
|
async function isSandboxAvailable() {
|
|
4697
4718
|
if (_sandboxAvailableCache !== null)
|
|
4698
4719
|
return _sandboxAvailableCache;
|
|
@@ -4702,15 +4723,17 @@ async function isSandboxAvailable() {
|
|
|
4702
4723
|
}
|
|
4703
4724
|
if (sandboxFactoryOverride) {
|
|
4704
4725
|
_sandboxAvailableCache = true;
|
|
4726
|
+
_sandboxImportError = null;
|
|
4705
4727
|
return true;
|
|
4706
4728
|
}
|
|
4707
4729
|
try {
|
|
4708
|
-
|
|
4709
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
4730
|
+
await import("@vercel/sandbox");
|
|
4710
4731
|
_sandboxAvailableCache = true;
|
|
4732
|
+
_sandboxImportError = null;
|
|
4711
4733
|
return true;
|
|
4712
|
-
} catch {
|
|
4734
|
+
} catch (err) {
|
|
4713
4735
|
_sandboxAvailableCache = false;
|
|
4736
|
+
_sandboxImportError = err;
|
|
4714
4737
|
return false;
|
|
4715
4738
|
}
|
|
4716
4739
|
}
|
|
@@ -4718,12 +4741,12 @@ async function loadSandboxFactory() {
|
|
|
4718
4741
|
if (sandboxFactoryOverride)
|
|
4719
4742
|
return sandboxFactoryOverride;
|
|
4720
4743
|
try {
|
|
4721
|
-
const
|
|
4722
|
-
const pkg = "@" + "vercel/sandbox";
|
|
4723
|
-
const mod = await dynamicImport(pkg);
|
|
4744
|
+
const mod = await import("@vercel/sandbox");
|
|
4724
4745
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
4725
4746
|
} catch (err) {
|
|
4726
|
-
|
|
4747
|
+
_sandboxImportError = err;
|
|
4748
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
4749
|
+
throw new Error("Code Mode failed to load `@vercel/sandbox`" + detail + ". Ensure the package is installed and reachable at runtime. On Next.js/Vercel, confirm it is listed in `dependencies` (not only `devDependencies`) and that the route using Code Mode runs in the Node.js runtime (not Edge).");
|
|
4727
4750
|
}
|
|
4728
4751
|
}
|
|
4729
4752
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -4893,27 +4916,34 @@ function resolveCodeModeClientConfig(client) {
|
|
|
4893
4916
|
const oauthConfig = client.__oauthConfig;
|
|
4894
4917
|
return oauthConfig?.codeMode ?? {};
|
|
4895
4918
|
}
|
|
4919
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
4920
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
4921
|
+
}
|
|
4896
4922
|
async function diagnoseCodeMode(client) {
|
|
4897
4923
|
if (!await isSandboxAvailable()) {
|
|
4898
4924
|
return { available: false, reason: "sandbox-missing" };
|
|
4899
4925
|
}
|
|
4900
4926
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
4901
|
-
const publicUrl = serverConfig
|
|
4927
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
4902
4928
|
if (!publicUrl) {
|
|
4903
4929
|
return { available: false, reason: "no-public-url" };
|
|
4904
4930
|
}
|
|
4905
4931
|
return { available: true };
|
|
4906
4932
|
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
}
|
|
4933
|
+
function buildFallbackMessage(reason) {
|
|
4934
|
+
if (reason === "no-public-url") {
|
|
4935
|
+
return "[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.";
|
|
4936
|
+
}
|
|
4937
|
+
const importError = getSandboxImportError();
|
|
4938
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
4939
|
+
return "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Ensure `@vercel/sandbox` is in `dependencies` and the route runs in the Node.js runtime (not Edge)." + detail;
|
|
4940
|
+
}
|
|
4911
4941
|
var warnedCodeModeReasons = new Set;
|
|
4912
4942
|
function warnCodeModeFallback(reason) {
|
|
4913
4943
|
if (warnedCodeModeReasons.has(reason))
|
|
4914
4944
|
return;
|
|
4915
4945
|
warnedCodeModeReasons.add(reason);
|
|
4916
|
-
console.warn(
|
|
4946
|
+
console.warn(buildFallbackMessage(reason));
|
|
4917
4947
|
}
|
|
4918
4948
|
function buildCodeModeTool(client, options) {
|
|
4919
4949
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -4926,7 +4956,9 @@ function buildCodeModeTool(client, options) {
|
|
|
4926
4956
|
${generated.source}
|
|
4927
4957
|
\`\`\``;
|
|
4928
4958
|
const execute = async ({ code }) => {
|
|
4929
|
-
const publicUrl =
|
|
4959
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
4960
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
4961
|
+
});
|
|
4930
4962
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
4931
4963
|
if (!publicUrl) {
|
|
4932
4964
|
return {
|
|
@@ -4935,7 +4967,7 @@ ${generated.source}
|
|
|
4935
4967
|
stdout: "",
|
|
4936
4968
|
stderr: "",
|
|
4937
4969
|
durationMs: 0,
|
|
4938
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
4970
|
+
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."
|
|
4939
4971
|
};
|
|
4940
4972
|
}
|
|
4941
4973
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
package/dist/ai/google.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|
|
@@ -4692,7 +4709,11 @@ export { callTool };
|
|
|
4692
4709
|
// ../code-mode/executor.ts
|
|
4693
4710
|
var sandboxFactoryOverride = null;
|
|
4694
4711
|
var _sandboxAvailableCache = null;
|
|
4712
|
+
var _sandboxImportError = null;
|
|
4695
4713
|
var _sandboxForcedUnavailableForTests = false;
|
|
4714
|
+
function getSandboxImportError() {
|
|
4715
|
+
return _sandboxImportError;
|
|
4716
|
+
}
|
|
4696
4717
|
async function isSandboxAvailable() {
|
|
4697
4718
|
if (_sandboxAvailableCache !== null)
|
|
4698
4719
|
return _sandboxAvailableCache;
|
|
@@ -4702,15 +4723,17 @@ async function isSandboxAvailable() {
|
|
|
4702
4723
|
}
|
|
4703
4724
|
if (sandboxFactoryOverride) {
|
|
4704
4725
|
_sandboxAvailableCache = true;
|
|
4726
|
+
_sandboxImportError = null;
|
|
4705
4727
|
return true;
|
|
4706
4728
|
}
|
|
4707
4729
|
try {
|
|
4708
|
-
|
|
4709
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
4730
|
+
await import("@vercel/sandbox");
|
|
4710
4731
|
_sandboxAvailableCache = true;
|
|
4732
|
+
_sandboxImportError = null;
|
|
4711
4733
|
return true;
|
|
4712
|
-
} catch {
|
|
4734
|
+
} catch (err) {
|
|
4713
4735
|
_sandboxAvailableCache = false;
|
|
4736
|
+
_sandboxImportError = err;
|
|
4714
4737
|
return false;
|
|
4715
4738
|
}
|
|
4716
4739
|
}
|
|
@@ -4718,12 +4741,12 @@ async function loadSandboxFactory() {
|
|
|
4718
4741
|
if (sandboxFactoryOverride)
|
|
4719
4742
|
return sandboxFactoryOverride;
|
|
4720
4743
|
try {
|
|
4721
|
-
const
|
|
4722
|
-
const pkg = "@" + "vercel/sandbox";
|
|
4723
|
-
const mod = await dynamicImport(pkg);
|
|
4744
|
+
const mod = await import("@vercel/sandbox");
|
|
4724
4745
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
4725
4746
|
} catch (err) {
|
|
4726
|
-
|
|
4747
|
+
_sandboxImportError = err;
|
|
4748
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
4749
|
+
throw new Error("Code Mode failed to load `@vercel/sandbox`" + detail + ". Ensure the package is installed and reachable at runtime. On Next.js/Vercel, confirm it is listed in `dependencies` (not only `devDependencies`) and that the route using Code Mode runs in the Node.js runtime (not Edge).");
|
|
4727
4750
|
}
|
|
4728
4751
|
}
|
|
4729
4752
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -4893,27 +4916,34 @@ function resolveCodeModeClientConfig(client) {
|
|
|
4893
4916
|
const oauthConfig = client.__oauthConfig;
|
|
4894
4917
|
return oauthConfig?.codeMode ?? {};
|
|
4895
4918
|
}
|
|
4919
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
4920
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
4921
|
+
}
|
|
4896
4922
|
async function diagnoseCodeMode(client) {
|
|
4897
4923
|
if (!await isSandboxAvailable()) {
|
|
4898
4924
|
return { available: false, reason: "sandbox-missing" };
|
|
4899
4925
|
}
|
|
4900
4926
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
4901
|
-
const publicUrl = serverConfig
|
|
4927
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
4902
4928
|
if (!publicUrl) {
|
|
4903
4929
|
return { available: false, reason: "no-public-url" };
|
|
4904
4930
|
}
|
|
4905
4931
|
return { available: true };
|
|
4906
4932
|
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
}
|
|
4933
|
+
function buildFallbackMessage(reason) {
|
|
4934
|
+
if (reason === "no-public-url") {
|
|
4935
|
+
return "[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.";
|
|
4936
|
+
}
|
|
4937
|
+
const importError = getSandboxImportError();
|
|
4938
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
4939
|
+
return "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Ensure `@vercel/sandbox` is in `dependencies` and the route runs in the Node.js runtime (not Edge)." + detail;
|
|
4940
|
+
}
|
|
4911
4941
|
var warnedCodeModeReasons = new Set;
|
|
4912
4942
|
function warnCodeModeFallback(reason) {
|
|
4913
4943
|
if (warnedCodeModeReasons.has(reason))
|
|
4914
4944
|
return;
|
|
4915
4945
|
warnedCodeModeReasons.add(reason);
|
|
4916
|
-
console.warn(
|
|
4946
|
+
console.warn(buildFallbackMessage(reason));
|
|
4917
4947
|
}
|
|
4918
4948
|
function buildCodeModeTool(client, options) {
|
|
4919
4949
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -4926,7 +4956,9 @@ function buildCodeModeTool(client, options) {
|
|
|
4926
4956
|
${generated.source}
|
|
4927
4957
|
\`\`\``;
|
|
4928
4958
|
const execute = async ({ code }) => {
|
|
4929
|
-
const publicUrl =
|
|
4959
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
4960
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
4961
|
+
});
|
|
4930
4962
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
4931
4963
|
if (!publicUrl) {
|
|
4932
4964
|
return {
|
|
@@ -4935,7 +4967,7 @@ ${generated.source}
|
|
|
4935
4967
|
stdout: "",
|
|
4936
4968
|
stderr: "",
|
|
4937
4969
|
durationMs: 0,
|
|
4938
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
4970
|
+
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."
|
|
4939
4971
|
};
|
|
4940
4972
|
}
|
|
4941
4973
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
package/dist/ai/index.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|
|
@@ -4692,7 +4709,11 @@ export { callTool };
|
|
|
4692
4709
|
// ../code-mode/executor.ts
|
|
4693
4710
|
var sandboxFactoryOverride = null;
|
|
4694
4711
|
var _sandboxAvailableCache = null;
|
|
4712
|
+
var _sandboxImportError = null;
|
|
4695
4713
|
var _sandboxForcedUnavailableForTests = false;
|
|
4714
|
+
function getSandboxImportError() {
|
|
4715
|
+
return _sandboxImportError;
|
|
4716
|
+
}
|
|
4696
4717
|
async function isSandboxAvailable() {
|
|
4697
4718
|
if (_sandboxAvailableCache !== null)
|
|
4698
4719
|
return _sandboxAvailableCache;
|
|
@@ -4702,15 +4723,17 @@ async function isSandboxAvailable() {
|
|
|
4702
4723
|
}
|
|
4703
4724
|
if (sandboxFactoryOverride) {
|
|
4704
4725
|
_sandboxAvailableCache = true;
|
|
4726
|
+
_sandboxImportError = null;
|
|
4705
4727
|
return true;
|
|
4706
4728
|
}
|
|
4707
4729
|
try {
|
|
4708
|
-
|
|
4709
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
4730
|
+
await import("@vercel/sandbox");
|
|
4710
4731
|
_sandboxAvailableCache = true;
|
|
4732
|
+
_sandboxImportError = null;
|
|
4711
4733
|
return true;
|
|
4712
|
-
} catch {
|
|
4734
|
+
} catch (err) {
|
|
4713
4735
|
_sandboxAvailableCache = false;
|
|
4736
|
+
_sandboxImportError = err;
|
|
4714
4737
|
return false;
|
|
4715
4738
|
}
|
|
4716
4739
|
}
|
|
@@ -4718,12 +4741,12 @@ async function loadSandboxFactory() {
|
|
|
4718
4741
|
if (sandboxFactoryOverride)
|
|
4719
4742
|
return sandboxFactoryOverride;
|
|
4720
4743
|
try {
|
|
4721
|
-
const
|
|
4722
|
-
const pkg = "@" + "vercel/sandbox";
|
|
4723
|
-
const mod = await dynamicImport(pkg);
|
|
4744
|
+
const mod = await import("@vercel/sandbox");
|
|
4724
4745
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
4725
4746
|
} catch (err) {
|
|
4726
|
-
|
|
4747
|
+
_sandboxImportError = err;
|
|
4748
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
4749
|
+
throw new Error("Code Mode failed to load `@vercel/sandbox`" + detail + ". Ensure the package is installed and reachable at runtime. On Next.js/Vercel, confirm it is listed in `dependencies` (not only `devDependencies`) and that the route using Code Mode runs in the Node.js runtime (not Edge).");
|
|
4727
4750
|
}
|
|
4728
4751
|
}
|
|
4729
4752
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -4893,27 +4916,34 @@ function resolveCodeModeClientConfig(client) {
|
|
|
4893
4916
|
const oauthConfig = client.__oauthConfig;
|
|
4894
4917
|
return oauthConfig?.codeMode ?? {};
|
|
4895
4918
|
}
|
|
4919
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
4920
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
4921
|
+
}
|
|
4896
4922
|
async function diagnoseCodeMode(client) {
|
|
4897
4923
|
if (!await isSandboxAvailable()) {
|
|
4898
4924
|
return { available: false, reason: "sandbox-missing" };
|
|
4899
4925
|
}
|
|
4900
4926
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
4901
|
-
const publicUrl = serverConfig
|
|
4927
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
4902
4928
|
if (!publicUrl) {
|
|
4903
4929
|
return { available: false, reason: "no-public-url" };
|
|
4904
4930
|
}
|
|
4905
4931
|
return { available: true };
|
|
4906
4932
|
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
}
|
|
4933
|
+
function buildFallbackMessage(reason) {
|
|
4934
|
+
if (reason === "no-public-url") {
|
|
4935
|
+
return "[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.";
|
|
4936
|
+
}
|
|
4937
|
+
const importError = getSandboxImportError();
|
|
4938
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
4939
|
+
return "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Ensure `@vercel/sandbox` is in `dependencies` and the route runs in the Node.js runtime (not Edge)." + detail;
|
|
4940
|
+
}
|
|
4911
4941
|
var warnedCodeModeReasons = new Set;
|
|
4912
4942
|
function warnCodeModeFallback(reason) {
|
|
4913
4943
|
if (warnedCodeModeReasons.has(reason))
|
|
4914
4944
|
return;
|
|
4915
4945
|
warnedCodeModeReasons.add(reason);
|
|
4916
|
-
console.warn(
|
|
4946
|
+
console.warn(buildFallbackMessage(reason));
|
|
4917
4947
|
}
|
|
4918
4948
|
function buildCodeModeTool(client, options) {
|
|
4919
4949
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -4926,7 +4956,9 @@ function buildCodeModeTool(client, options) {
|
|
|
4926
4956
|
${generated.source}
|
|
4927
4957
|
\`\`\``;
|
|
4928
4958
|
const execute = async ({ code }) => {
|
|
4929
|
-
const publicUrl =
|
|
4959
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
4960
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
4961
|
+
});
|
|
4930
4962
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
4931
4963
|
if (!publicUrl) {
|
|
4932
4964
|
return {
|
|
@@ -4935,7 +4967,7 @@ ${generated.source}
|
|
|
4935
4967
|
stdout: "",
|
|
4936
4968
|
stderr: "",
|
|
4937
4969
|
durationMs: 0,
|
|
4938
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
4970
|
+
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."
|
|
4939
4971
|
};
|
|
4940
4972
|
}
|
|
4941
4973
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
package/dist/ai/openai.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|
|
@@ -4692,7 +4709,11 @@ export { callTool };
|
|
|
4692
4709
|
// ../code-mode/executor.ts
|
|
4693
4710
|
var sandboxFactoryOverride = null;
|
|
4694
4711
|
var _sandboxAvailableCache = null;
|
|
4712
|
+
var _sandboxImportError = null;
|
|
4695
4713
|
var _sandboxForcedUnavailableForTests = false;
|
|
4714
|
+
function getSandboxImportError() {
|
|
4715
|
+
return _sandboxImportError;
|
|
4716
|
+
}
|
|
4696
4717
|
async function isSandboxAvailable() {
|
|
4697
4718
|
if (_sandboxAvailableCache !== null)
|
|
4698
4719
|
return _sandboxAvailableCache;
|
|
@@ -4702,15 +4723,17 @@ async function isSandboxAvailable() {
|
|
|
4702
4723
|
}
|
|
4703
4724
|
if (sandboxFactoryOverride) {
|
|
4704
4725
|
_sandboxAvailableCache = true;
|
|
4726
|
+
_sandboxImportError = null;
|
|
4705
4727
|
return true;
|
|
4706
4728
|
}
|
|
4707
4729
|
try {
|
|
4708
|
-
|
|
4709
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
4730
|
+
await import("@vercel/sandbox");
|
|
4710
4731
|
_sandboxAvailableCache = true;
|
|
4732
|
+
_sandboxImportError = null;
|
|
4711
4733
|
return true;
|
|
4712
|
-
} catch {
|
|
4734
|
+
} catch (err) {
|
|
4713
4735
|
_sandboxAvailableCache = false;
|
|
4736
|
+
_sandboxImportError = err;
|
|
4714
4737
|
return false;
|
|
4715
4738
|
}
|
|
4716
4739
|
}
|
|
@@ -4718,12 +4741,12 @@ async function loadSandboxFactory() {
|
|
|
4718
4741
|
if (sandboxFactoryOverride)
|
|
4719
4742
|
return sandboxFactoryOverride;
|
|
4720
4743
|
try {
|
|
4721
|
-
const
|
|
4722
|
-
const pkg = "@" + "vercel/sandbox";
|
|
4723
|
-
const mod = await dynamicImport(pkg);
|
|
4744
|
+
const mod = await import("@vercel/sandbox");
|
|
4724
4745
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
4725
4746
|
} catch (err) {
|
|
4726
|
-
|
|
4747
|
+
_sandboxImportError = err;
|
|
4748
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
4749
|
+
throw new Error("Code Mode failed to load `@vercel/sandbox`" + detail + ". Ensure the package is installed and reachable at runtime. On Next.js/Vercel, confirm it is listed in `dependencies` (not only `devDependencies`) and that the route using Code Mode runs in the Node.js runtime (not Edge).");
|
|
4727
4750
|
}
|
|
4728
4751
|
}
|
|
4729
4752
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -4893,27 +4916,34 @@ function resolveCodeModeClientConfig(client) {
|
|
|
4893
4916
|
const oauthConfig = client.__oauthConfig;
|
|
4894
4917
|
return oauthConfig?.codeMode ?? {};
|
|
4895
4918
|
}
|
|
4919
|
+
function resolveCodeModePublicUrl(serverConfig = {}) {
|
|
4920
|
+
return serverConfig.publicUrl ?? getEnv("INTEGRATE_URL");
|
|
4921
|
+
}
|
|
4896
4922
|
async function diagnoseCodeMode(client) {
|
|
4897
4923
|
if (!await isSandboxAvailable()) {
|
|
4898
4924
|
return { available: false, reason: "sandbox-missing" };
|
|
4899
4925
|
}
|
|
4900
4926
|
const serverConfig = resolveCodeModeClientConfig(client);
|
|
4901
|
-
const publicUrl = serverConfig
|
|
4927
|
+
const publicUrl = resolveCodeModePublicUrl(serverConfig);
|
|
4902
4928
|
if (!publicUrl) {
|
|
4903
4929
|
return { available: false, reason: "no-public-url" };
|
|
4904
4930
|
}
|
|
4905
4931
|
return { available: true };
|
|
4906
4932
|
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
}
|
|
4933
|
+
function buildFallbackMessage(reason) {
|
|
4934
|
+
if (reason === "no-public-url") {
|
|
4935
|
+
return "[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.";
|
|
4936
|
+
}
|
|
4937
|
+
const importError = getSandboxImportError();
|
|
4938
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
4939
|
+
return "[integrate-sdk] Code Mode unavailable (reason: sandbox-missing) — falling back to tool mode. " + "Ensure `@vercel/sandbox` is in `dependencies` and the route runs in the Node.js runtime (not Edge)." + detail;
|
|
4940
|
+
}
|
|
4911
4941
|
var warnedCodeModeReasons = new Set;
|
|
4912
4942
|
function warnCodeModeFallback(reason) {
|
|
4913
4943
|
if (warnedCodeModeReasons.has(reason))
|
|
4914
4944
|
return;
|
|
4915
4945
|
warnedCodeModeReasons.add(reason);
|
|
4916
|
-
console.warn(
|
|
4946
|
+
console.warn(buildFallbackMessage(reason));
|
|
4917
4947
|
}
|
|
4918
4948
|
function buildCodeModeTool(client, options) {
|
|
4919
4949
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -4926,7 +4956,9 @@ function buildCodeModeTool(client, options) {
|
|
|
4926
4956
|
${generated.source}
|
|
4927
4957
|
\`\`\``;
|
|
4928
4958
|
const execute = async ({ code }) => {
|
|
4929
|
-
const publicUrl =
|
|
4959
|
+
const publicUrl = resolveCodeModePublicUrl({
|
|
4960
|
+
publicUrl: sandboxOverrides.publicUrl ?? serverCodeModeConfig.publicUrl
|
|
4961
|
+
});
|
|
4930
4962
|
const apiKey = client.__oauthConfig?.apiKey;
|
|
4931
4963
|
if (!publicUrl) {
|
|
4932
4964
|
return {
|
|
@@ -4935,7 +4967,7 @@ ${generated.source}
|
|
|
4935
4967
|
stdout: "",
|
|
4936
4968
|
stderr: "",
|
|
4937
4969
|
durationMs: 0,
|
|
4938
|
-
error: "Code Mode requires `codeMode.publicUrl` in createMCPServer config (or the
|
|
4970
|
+
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."
|
|
4939
4971
|
};
|
|
4940
4972
|
}
|
|
4941
4973
|
const mcpUrl = publicUrl.replace(/\/$/, "") + "/api/integrate/mcp";
|
package/dist/ai/trigger-tools.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|
package/dist/ai/utils.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -8,6 +24,7 @@ var __export = (target, all) => {
|
|
|
8
24
|
set: (newValue) => all[name] = () => newValue
|
|
9
25
|
});
|
|
10
26
|
};
|
|
27
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
28
|
|
|
12
29
|
// ../../node_modules/zod/v3/external.js
|
|
13
30
|
var exports_external = {};
|