integrate-sdk 0.9.10-dev.0 → 0.9.14-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 +166 -12360
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/base-handler.js +838 -0
- package/dist/adapters/index.js +3370 -12617
- package/dist/adapters/nextjs-oauth-redirect.js +0 -3
- package/dist/adapters/nextjs.js +266 -12132
- package/dist/adapters/node.js +31 -13004
- package/dist/adapters/session-detector.js +137 -38
- package/dist/adapters/solid-start.js +3633 -0
- package/dist/adapters/svelte-kit.js +3382 -12611
- package/dist/adapters/tanstack-start.js +7 -13027
- package/dist/ai/anthropic.js +44 -12
- package/dist/ai/google.js +44 -12
- package/dist/ai/index.js +44 -12
- package/dist/ai/openai.js +44 -12
- package/dist/ai/trigger-tools.js +17 -0
- package/dist/ai/utils.js +17 -0
- package/dist/ai/vercel-ai.js +44 -12
- 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 +40 -7
- package/dist/code-mode/index.js +48 -12
- package/dist/code-mode/runtime-stub.js +19 -0
- package/dist/code-mode/tool-builder.d.ts.map +1 -1
- package/dist/code-mode/tool-builder.js +48 -12
- package/dist/code-mode/type-generator.js +19 -0
- package/dist/index.js +4199 -12562
- package/dist/oauth.js +140 -12309
- package/dist/react.js +14 -16
- package/dist/server.js +9147 -9503
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
1
20
|
// runtime-stub.ts
|
|
2
21
|
var RUNTIME_STUB_SOURCE = `// runtime.mjs — generated by integrate-sdk code mode
|
|
3
22
|
const MCP_URL = process.env.INTEGRATE_MCP_URL;
|
|
@@ -73,15 +92,21 @@ export { callTool };
|
|
|
73
92
|
// executor.ts
|
|
74
93
|
var sandboxFactoryOverride = null;
|
|
75
94
|
var _sandboxAvailableCache = null;
|
|
95
|
+
var _sandboxImportError = null;
|
|
76
96
|
var _sandboxForcedUnavailableForTests = false;
|
|
77
97
|
function __setSandboxFactoryForTests(factory) {
|
|
78
98
|
sandboxFactoryOverride = factory;
|
|
79
99
|
_sandboxForcedUnavailableForTests = false;
|
|
80
100
|
_sandboxAvailableCache = null;
|
|
101
|
+
_sandboxImportError = null;
|
|
81
102
|
}
|
|
82
103
|
function __setSandboxUnavailableForTests(force) {
|
|
83
104
|
_sandboxForcedUnavailableForTests = force;
|
|
84
105
|
_sandboxAvailableCache = null;
|
|
106
|
+
_sandboxImportError = force ? new Error("Sandbox forced unavailable by test seam.") : null;
|
|
107
|
+
}
|
|
108
|
+
function getSandboxImportError() {
|
|
109
|
+
return _sandboxImportError;
|
|
85
110
|
}
|
|
86
111
|
async function isSandboxAvailable() {
|
|
87
112
|
if (_sandboxAvailableCache !== null)
|
|
@@ -92,15 +117,22 @@ async function isSandboxAvailable() {
|
|
|
92
117
|
}
|
|
93
118
|
if (sandboxFactoryOverride) {
|
|
94
119
|
_sandboxAvailableCache = true;
|
|
120
|
+
_sandboxImportError = null;
|
|
95
121
|
return true;
|
|
96
122
|
}
|
|
123
|
+
if (typeof window !== "undefined") {
|
|
124
|
+
_sandboxAvailableCache = false;
|
|
125
|
+
_sandboxImportError = new Error("Sandbox is not available in browser environments.");
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
97
128
|
try {
|
|
98
|
-
|
|
99
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
129
|
+
await import("@vercel/sandbox");
|
|
100
130
|
_sandboxAvailableCache = true;
|
|
131
|
+
_sandboxImportError = null;
|
|
101
132
|
return true;
|
|
102
|
-
} catch {
|
|
133
|
+
} catch (err) {
|
|
103
134
|
_sandboxAvailableCache = false;
|
|
135
|
+
_sandboxImportError = err;
|
|
104
136
|
return false;
|
|
105
137
|
}
|
|
106
138
|
}
|
|
@@ -108,12 +140,12 @@ async function loadSandboxFactory() {
|
|
|
108
140
|
if (sandboxFactoryOverride)
|
|
109
141
|
return sandboxFactoryOverride;
|
|
110
142
|
try {
|
|
111
|
-
const
|
|
112
|
-
const pkg = "@" + "vercel/sandbox";
|
|
113
|
-
const mod = await dynamicImport(pkg);
|
|
143
|
+
const mod = await import("@vercel/sandbox");
|
|
114
144
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
115
145
|
} catch (err) {
|
|
116
|
-
|
|
146
|
+
_sandboxImportError = err;
|
|
147
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
148
|
+
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).");
|
|
117
149
|
}
|
|
118
150
|
}
|
|
119
151
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -236,6 +268,7 @@ async function executeSandboxCode(options) {
|
|
|
236
268
|
}
|
|
237
269
|
export {
|
|
238
270
|
isSandboxAvailable,
|
|
271
|
+
getSandboxImportError,
|
|
239
272
|
executeSandboxCode,
|
|
240
273
|
__setSandboxUnavailableForTests,
|
|
241
274
|
__setSandboxFactoryForTests
|
package/dist/code-mode/index.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
1
20
|
// ../utils/naming.ts
|
|
2
21
|
function snakeToCamel(str) {
|
|
3
22
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -288,15 +307,21 @@ export { callTool };
|
|
|
288
307
|
// executor.ts
|
|
289
308
|
var sandboxFactoryOverride = null;
|
|
290
309
|
var _sandboxAvailableCache = null;
|
|
310
|
+
var _sandboxImportError = null;
|
|
291
311
|
var _sandboxForcedUnavailableForTests = false;
|
|
292
312
|
function __setSandboxFactoryForTests(factory) {
|
|
293
313
|
sandboxFactoryOverride = factory;
|
|
294
314
|
_sandboxForcedUnavailableForTests = false;
|
|
295
315
|
_sandboxAvailableCache = null;
|
|
316
|
+
_sandboxImportError = null;
|
|
296
317
|
}
|
|
297
318
|
function __setSandboxUnavailableForTests(force) {
|
|
298
319
|
_sandboxForcedUnavailableForTests = force;
|
|
299
320
|
_sandboxAvailableCache = null;
|
|
321
|
+
_sandboxImportError = force ? new Error("Sandbox forced unavailable by test seam.") : null;
|
|
322
|
+
}
|
|
323
|
+
function getSandboxImportError() {
|
|
324
|
+
return _sandboxImportError;
|
|
300
325
|
}
|
|
301
326
|
async function isSandboxAvailable() {
|
|
302
327
|
if (_sandboxAvailableCache !== null)
|
|
@@ -307,15 +332,22 @@ async function isSandboxAvailable() {
|
|
|
307
332
|
}
|
|
308
333
|
if (sandboxFactoryOverride) {
|
|
309
334
|
_sandboxAvailableCache = true;
|
|
335
|
+
_sandboxImportError = null;
|
|
310
336
|
return true;
|
|
311
337
|
}
|
|
338
|
+
if (typeof window !== "undefined") {
|
|
339
|
+
_sandboxAvailableCache = false;
|
|
340
|
+
_sandboxImportError = new Error("Sandbox is not available in browser environments.");
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
312
343
|
try {
|
|
313
|
-
|
|
314
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
344
|
+
await import("@vercel/sandbox");
|
|
315
345
|
_sandboxAvailableCache = true;
|
|
346
|
+
_sandboxImportError = null;
|
|
316
347
|
return true;
|
|
317
|
-
} catch {
|
|
348
|
+
} catch (err) {
|
|
318
349
|
_sandboxAvailableCache = false;
|
|
350
|
+
_sandboxImportError = err;
|
|
319
351
|
return false;
|
|
320
352
|
}
|
|
321
353
|
}
|
|
@@ -323,12 +355,12 @@ async function loadSandboxFactory() {
|
|
|
323
355
|
if (sandboxFactoryOverride)
|
|
324
356
|
return sandboxFactoryOverride;
|
|
325
357
|
try {
|
|
326
|
-
const
|
|
327
|
-
const pkg = "@" + "vercel/sandbox";
|
|
328
|
-
const mod = await dynamicImport(pkg);
|
|
358
|
+
const mod = await import("@vercel/sandbox");
|
|
329
359
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
330
360
|
} catch (err) {
|
|
331
|
-
|
|
361
|
+
_sandboxImportError = err;
|
|
362
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
363
|
+
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).");
|
|
332
364
|
}
|
|
333
365
|
}
|
|
334
366
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -515,10 +547,14 @@ async function diagnoseCodeMode(client) {
|
|
|
515
547
|
async function canUseCodeMode(client) {
|
|
516
548
|
return (await diagnoseCodeMode(client)).available;
|
|
517
549
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
550
|
+
function buildFallbackMessage(reason) {
|
|
551
|
+
if (reason === "no-public-url") {
|
|
552
|
+
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.";
|
|
553
|
+
}
|
|
554
|
+
const importError = getSandboxImportError();
|
|
555
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
556
|
+
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;
|
|
557
|
+
}
|
|
522
558
|
var warnedCodeModeReasons = new Set;
|
|
523
559
|
function __resetCodeModeFallbackWarnings() {
|
|
524
560
|
warnedCodeModeReasons.clear();
|
|
@@ -527,7 +563,7 @@ function warnCodeModeFallback(reason) {
|
|
|
527
563
|
if (warnedCodeModeReasons.has(reason))
|
|
528
564
|
return;
|
|
529
565
|
warnedCodeModeReasons.add(reason);
|
|
530
|
-
console.warn(
|
|
566
|
+
console.warn(buildFallbackMessage(reason));
|
|
531
567
|
}
|
|
532
568
|
function buildCodeModeTool(client, options) {
|
|
533
569
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
1
20
|
// runtime-stub.ts
|
|
2
21
|
var RUNTIME_STUB_SOURCE = `// runtime.mjs — generated by integrate-sdk code mode
|
|
3
22
|
const MCP_URL = process.env.INTEGRATE_MCP_URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-builder.d.ts","sourceRoot":"","sources":["../../../src/code-mode/tool-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,K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wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUzF;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E;AAwBD,sEAAsE;AACtE,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAI5E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE,mBAAmB,GAC3B,sBAAsB,CA8DxB"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
1
20
|
// ../utils/naming.ts
|
|
2
21
|
function snakeToCamel(str) {
|
|
3
22
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -288,15 +307,21 @@ export { callTool };
|
|
|
288
307
|
// executor.ts
|
|
289
308
|
var sandboxFactoryOverride = null;
|
|
290
309
|
var _sandboxAvailableCache = null;
|
|
310
|
+
var _sandboxImportError = null;
|
|
291
311
|
var _sandboxForcedUnavailableForTests = false;
|
|
292
312
|
function __setSandboxFactoryForTests(factory) {
|
|
293
313
|
sandboxFactoryOverride = factory;
|
|
294
314
|
_sandboxForcedUnavailableForTests = false;
|
|
295
315
|
_sandboxAvailableCache = null;
|
|
316
|
+
_sandboxImportError = null;
|
|
296
317
|
}
|
|
297
318
|
function __setSandboxUnavailableForTests(force) {
|
|
298
319
|
_sandboxForcedUnavailableForTests = force;
|
|
299
320
|
_sandboxAvailableCache = null;
|
|
321
|
+
_sandboxImportError = force ? new Error("Sandbox forced unavailable by test seam.") : null;
|
|
322
|
+
}
|
|
323
|
+
function getSandboxImportError() {
|
|
324
|
+
return _sandboxImportError;
|
|
300
325
|
}
|
|
301
326
|
async function isSandboxAvailable() {
|
|
302
327
|
if (_sandboxAvailableCache !== null)
|
|
@@ -307,15 +332,22 @@ async function isSandboxAvailable() {
|
|
|
307
332
|
}
|
|
308
333
|
if (sandboxFactoryOverride) {
|
|
309
334
|
_sandboxAvailableCache = true;
|
|
335
|
+
_sandboxImportError = null;
|
|
310
336
|
return true;
|
|
311
337
|
}
|
|
338
|
+
if (typeof window !== "undefined") {
|
|
339
|
+
_sandboxAvailableCache = false;
|
|
340
|
+
_sandboxImportError = new Error("Sandbox is not available in browser environments.");
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
312
343
|
try {
|
|
313
|
-
|
|
314
|
-
await dynamicImport("@" + "vercel/sandbox");
|
|
344
|
+
await import("@vercel/sandbox");
|
|
315
345
|
_sandboxAvailableCache = true;
|
|
346
|
+
_sandboxImportError = null;
|
|
316
347
|
return true;
|
|
317
|
-
} catch {
|
|
348
|
+
} catch (err) {
|
|
318
349
|
_sandboxAvailableCache = false;
|
|
350
|
+
_sandboxImportError = err;
|
|
319
351
|
return false;
|
|
320
352
|
}
|
|
321
353
|
}
|
|
@@ -323,12 +355,12 @@ async function loadSandboxFactory() {
|
|
|
323
355
|
if (sandboxFactoryOverride)
|
|
324
356
|
return sandboxFactoryOverride;
|
|
325
357
|
try {
|
|
326
|
-
const
|
|
327
|
-
const pkg = "@" + "vercel/sandbox";
|
|
328
|
-
const mod = await dynamicImport(pkg);
|
|
358
|
+
const mod = await import("@vercel/sandbox");
|
|
329
359
|
return mod.Sandbox ?? mod.default?.Sandbox ?? mod;
|
|
330
360
|
} catch (err) {
|
|
331
|
-
|
|
361
|
+
_sandboxImportError = err;
|
|
362
|
+
const detail = err instanceof Error ? `: ${err.message}` : "";
|
|
363
|
+
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).");
|
|
332
364
|
}
|
|
333
365
|
}
|
|
334
366
|
var RESULT_SENTINEL = "__INTEGRATE_RESULT__";
|
|
@@ -515,10 +547,14 @@ async function diagnoseCodeMode(client) {
|
|
|
515
547
|
async function canUseCodeMode(client) {
|
|
516
548
|
return (await diagnoseCodeMode(client)).available;
|
|
517
549
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
550
|
+
function buildFallbackMessage(reason) {
|
|
551
|
+
if (reason === "no-public-url") {
|
|
552
|
+
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.";
|
|
553
|
+
}
|
|
554
|
+
const importError = getSandboxImportError();
|
|
555
|
+
const detail = importError instanceof Error ? ` Underlying import error: ${importError.message}` : importError ? ` Underlying import error: ${String(importError)}` : "";
|
|
556
|
+
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;
|
|
557
|
+
}
|
|
522
558
|
var warnedCodeModeReasons = new Set;
|
|
523
559
|
function __resetCodeModeFallbackWarnings() {
|
|
524
560
|
warnedCodeModeReasons.clear();
|
|
@@ -527,7 +563,7 @@ function warnCodeModeFallback(reason) {
|
|
|
527
563
|
if (warnedCodeModeReasons.has(reason))
|
|
528
564
|
return;
|
|
529
565
|
warnedCodeModeReasons.add(reason);
|
|
530
|
-
console.warn(
|
|
566
|
+
console.warn(buildFallbackMessage(reason));
|
|
531
567
|
}
|
|
532
568
|
function buildCodeModeTool(client, options) {
|
|
533
569
|
const { tools, providerTokens, context, integrationIds } = options;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
1
20
|
// ../utils/naming.ts
|
|
2
21
|
function snakeToCamel(str) {
|
|
3
22
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|