vercel-cli 48.1.0__py3-none-any.whl → 48.1.4__py3-none-any.whl
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.
Potentially problematic release.
This version of vercel-cli might be problematic. Click here for more details.
- vercel_cli/vendor/dist/index.js +96 -32
- vercel_cli/vendor/node_modules/.package-lock.json +7 -4
- vercel_cli/vendor/node_modules/@vercel/detect-agent/CHANGELOG.md +19 -0
- vercel_cli/vendor/node_modules/@vercel/detect-agent/README.md +123 -0
- vercel_cli/vendor/node_modules/@vercel/detect-agent/dist/index.d.ts +29 -1
- vercel_cli/vendor/node_modules/@vercel/detect-agent/dist/index.js +28 -11
- vercel_cli/vendor/node_modules/@vercel/detect-agent/package.json +33 -5
- vercel_cli/vendor/package.json +2 -2
- {vercel_cli-48.1.0.dist-info → vercel_cli-48.1.4.dist-info}/METADATA +1 -1
- {vercel_cli-48.1.0.dist-info → vercel_cli-48.1.4.dist-info}/RECORD +12 -10
- {vercel_cli-48.1.0.dist-info → vercel_cli-48.1.4.dist-info}/WHEEL +0 -0
- {vercel_cli-48.1.0.dist-info → vercel_cli-48.1.4.dist-info}/entry_points.txt +0 -0
vercel_cli/vendor/dist/index.js
CHANGED
|
@@ -31624,6 +31624,15 @@ var init_command3 = __esm({
|
|
|
31624
31624
|
...yesOption,
|
|
31625
31625
|
description: "Skip the confirmation prompt about pulling environment variables and project settings when not found locally"
|
|
31626
31626
|
}
|
|
31627
|
+
// FIXME: standalone:replace env var with flag
|
|
31628
|
+
// {
|
|
31629
|
+
// name: 'experimentalStandalone',
|
|
31630
|
+
// description:
|
|
31631
|
+
// 'Create a standalone build with all dependencies inlined into function output folders',
|
|
31632
|
+
// shorthand: null,
|
|
31633
|
+
// type: Boolean,
|
|
31634
|
+
// deprecated: false,
|
|
31635
|
+
// },
|
|
31627
31636
|
],
|
|
31628
31637
|
examples: [
|
|
31629
31638
|
{
|
|
@@ -116930,7 +116939,7 @@ var require_frameworks = __commonJS2({
|
|
|
116930
116939
|
getOutputDirName: async () => "public"
|
|
116931
116940
|
},
|
|
116932
116941
|
{
|
|
116933
|
-
name: "
|
|
116942
|
+
name: "H3",
|
|
116934
116943
|
slug: "h3",
|
|
116935
116944
|
logo: "https://api-frameworks.vercel.sh/framework-logos/h3.svg",
|
|
116936
116945
|
tagline: "Universal, Tiny, and Fast Servers",
|
|
@@ -119368,7 +119377,7 @@ var require_detect_builders = __commonJS2({
|
|
|
119368
119377
|
builders.push(...apiBuilders);
|
|
119369
119378
|
}
|
|
119370
119379
|
if (frontendBuilder) {
|
|
119371
|
-
if (frontendBuilder?.use === "@vercel/express") {
|
|
119380
|
+
if (frontendBuilder?.use === "@vercel/express" || frontendBuilder?.use === "@vercel/hono") {
|
|
119372
119381
|
builders.push({
|
|
119373
119382
|
src: "public/**/*",
|
|
119374
119383
|
use: "@vercel/static",
|
|
@@ -144699,15 +144708,19 @@ var init_unzip = __esm({
|
|
|
144699
144708
|
});
|
|
144700
144709
|
|
|
144701
144710
|
// src/util/build/write-build-result.ts
|
|
144702
|
-
async function writeBuildResult(repoRootPath, outputDir, buildResult, build2, builder, builderPkg, vercelConfig) {
|
|
144703
|
-
|
|
144711
|
+
async function writeBuildResult(repoRootPath, outputDir, buildResult, build2, builder, builderPkg, vercelConfig, standalone = false) {
|
|
144712
|
+
let version2 = builder.version;
|
|
144713
|
+
if ("experimentalVersion" in builder && process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" && "name" in builder && builder.name === "express") {
|
|
144714
|
+
version2 = builder.experimentalVersion;
|
|
144715
|
+
}
|
|
144704
144716
|
if (typeof version2 !== "number" || version2 === 2) {
|
|
144705
144717
|
return writeBuildResultV2(
|
|
144706
144718
|
repoRootPath,
|
|
144707
144719
|
outputDir,
|
|
144708
144720
|
buildResult,
|
|
144709
144721
|
build2,
|
|
144710
|
-
vercelConfig
|
|
144722
|
+
vercelConfig,
|
|
144723
|
+
standalone
|
|
144711
144724
|
);
|
|
144712
144725
|
} else if (version2 === 3) {
|
|
144713
144726
|
return writeBuildResultV3(
|
|
@@ -144715,7 +144728,8 @@ async function writeBuildResult(repoRootPath, outputDir, buildResult, build2, bu
|
|
|
144715
144728
|
outputDir,
|
|
144716
144729
|
buildResult,
|
|
144717
144730
|
build2,
|
|
144718
|
-
vercelConfig
|
|
144731
|
+
vercelConfig,
|
|
144732
|
+
standalone
|
|
144719
144733
|
);
|
|
144720
144734
|
}
|
|
144721
144735
|
throw new Error(
|
|
@@ -144738,7 +144752,7 @@ function isFile(v) {
|
|
|
144738
144752
|
function stripDuplicateSlashes(path11) {
|
|
144739
144753
|
return normalize2(path11).replace(/(^\/|\/$)/g, "");
|
|
144740
144754
|
}
|
|
144741
|
-
async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2, vercelConfig) {
|
|
144755
|
+
async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2, vercelConfig, standalone = false) {
|
|
144742
144756
|
if ("buildOutputPath" in buildResult) {
|
|
144743
144757
|
await mergeBuilderOutput(outputDir, buildResult);
|
|
144744
144758
|
return;
|
|
@@ -144761,7 +144775,8 @@ async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2,
|
|
|
144761
144775
|
output2,
|
|
144762
144776
|
normalizedPath,
|
|
144763
144777
|
void 0,
|
|
144764
|
-
existingFunctions
|
|
144778
|
+
existingFunctions,
|
|
144779
|
+
standalone
|
|
144765
144780
|
);
|
|
144766
144781
|
} else if (isPrerender(output2)) {
|
|
144767
144782
|
if (!output2.lambda) {
|
|
@@ -144775,7 +144790,8 @@ async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2,
|
|
|
144775
144790
|
output2.lambda,
|
|
144776
144791
|
normalizedPath,
|
|
144777
144792
|
void 0,
|
|
144778
|
-
existingFunctions
|
|
144793
|
+
existingFunctions,
|
|
144794
|
+
standalone
|
|
144779
144795
|
);
|
|
144780
144796
|
let fallback = output2.fallback;
|
|
144781
144797
|
if (fallback) {
|
|
@@ -144827,7 +144843,8 @@ async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2,
|
|
|
144827
144843
|
outputDir,
|
|
144828
144844
|
output2,
|
|
144829
144845
|
normalizedPath,
|
|
144830
|
-
existingFunctions
|
|
144846
|
+
existingFunctions,
|
|
144847
|
+
standalone
|
|
144831
144848
|
);
|
|
144832
144849
|
} else {
|
|
144833
144850
|
throw new Error(
|
|
@@ -144837,7 +144854,7 @@ async function writeBuildResultV2(repoRootPath, outputDir, buildResult, build2,
|
|
|
144837
144854
|
}
|
|
144838
144855
|
return Object.keys(overrides).length > 0 ? overrides : void 0;
|
|
144839
144856
|
}
|
|
144840
|
-
async function writeBuildResultV3(repoRootPath, outputDir, buildResult, build2, vercelConfig) {
|
|
144857
|
+
async function writeBuildResultV3(repoRootPath, outputDir, buildResult, build2, vercelConfig, standalone = false) {
|
|
144841
144858
|
const { output: output2 } = buildResult;
|
|
144842
144859
|
const src = build2.src;
|
|
144843
144860
|
if (typeof src !== "string") {
|
|
@@ -144857,10 +144874,19 @@ async function writeBuildResultV3(repoRootPath, outputDir, buildResult, build2,
|
|
|
144857
144874
|
outputDir,
|
|
144858
144875
|
output2,
|
|
144859
144876
|
path11,
|
|
144860
|
-
functionConfiguration
|
|
144877
|
+
functionConfiguration,
|
|
144878
|
+
void 0,
|
|
144879
|
+
standalone
|
|
144861
144880
|
);
|
|
144862
144881
|
} else if (isEdgeFunction(output2)) {
|
|
144863
|
-
await writeEdgeFunction(
|
|
144882
|
+
await writeEdgeFunction(
|
|
144883
|
+
repoRootPath,
|
|
144884
|
+
outputDir,
|
|
144885
|
+
output2,
|
|
144886
|
+
path11,
|
|
144887
|
+
void 0,
|
|
144888
|
+
standalone
|
|
144889
|
+
);
|
|
144864
144890
|
} else {
|
|
144865
144891
|
throw new Error(
|
|
144866
144892
|
`Unsupported output type: "${output2.type}" for ${build2.src}`
|
|
@@ -144911,7 +144937,7 @@ async function writeFunctionSymlink(outputDir, dest, fn2, existingFunctions) {
|
|
|
144911
144937
|
await import_fs_extra12.default.symlink(target, dest);
|
|
144912
144938
|
return true;
|
|
144913
144939
|
}
|
|
144914
|
-
async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11, existingFunctions) {
|
|
144940
|
+
async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11, existingFunctions, standalone = false) {
|
|
144915
144941
|
const dest = (0, import_path21.join)(outputDir, "functions", `${path11}.func`);
|
|
144916
144942
|
if (existingFunctions) {
|
|
144917
144943
|
if (await writeFunctionSymlink(
|
|
@@ -144926,11 +144952,17 @@ async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11,
|
|
|
144926
144952
|
}
|
|
144927
144953
|
await import_fs_extra12.default.mkdirp(dest);
|
|
144928
144954
|
const ops = [];
|
|
144929
|
-
const
|
|
144955
|
+
const sharedDest = (0, import_path21.join)(outputDir, "shared");
|
|
144956
|
+
const { files, filePathMap, shared } = filesWithoutFsRefs(
|
|
144930
144957
|
edgeFunction.files,
|
|
144931
|
-
repoRootPath
|
|
144958
|
+
repoRootPath,
|
|
144959
|
+
sharedDest,
|
|
144960
|
+
standalone
|
|
144932
144961
|
);
|
|
144933
144962
|
ops.push((0, import_build_utils11.download)(files, dest));
|
|
144963
|
+
if (shared) {
|
|
144964
|
+
ops.push((0, import_build_utils11.download)(shared, sharedDest));
|
|
144965
|
+
}
|
|
144934
144966
|
const config2 = {
|
|
144935
144967
|
runtime: "edge",
|
|
144936
144968
|
...edgeFunction,
|
|
@@ -144947,7 +144979,7 @@ async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11,
|
|
|
144947
144979
|
);
|
|
144948
144980
|
await Promise.all(ops);
|
|
144949
144981
|
}
|
|
144950
|
-
async function writeLambda(repoRootPath, outputDir, lambda, path11, functionConfiguration, existingFunctions) {
|
|
144982
|
+
async function writeLambda(repoRootPath, outputDir, lambda, path11, functionConfiguration, existingFunctions, standalone = false) {
|
|
144951
144983
|
const dest = (0, import_path21.join)(outputDir, "functions", `${path11}.func`);
|
|
144952
144984
|
if (existingFunctions) {
|
|
144953
144985
|
if (await writeFunctionSymlink(outputDir, dest, lambda, existingFunctions)) {
|
|
@@ -144959,9 +144991,18 @@ async function writeLambda(repoRootPath, outputDir, lambda, path11, functionConf
|
|
|
144959
144991
|
const ops = [];
|
|
144960
144992
|
let filePathMap;
|
|
144961
144993
|
if (lambda.files) {
|
|
144962
|
-
const
|
|
144994
|
+
const sharedDest = (0, import_path21.join)(outputDir, "shared");
|
|
144995
|
+
const f = filesWithoutFsRefs(
|
|
144996
|
+
lambda.files,
|
|
144997
|
+
repoRootPath,
|
|
144998
|
+
sharedDest,
|
|
144999
|
+
standalone
|
|
145000
|
+
);
|
|
144963
145001
|
filePathMap = f.filePathMap;
|
|
144964
145002
|
ops.push((0, import_build_utils11.download)(f.files, dest));
|
|
145003
|
+
if (f.shared) {
|
|
145004
|
+
ops.push((0, import_build_utils11.download)(f.shared, sharedDest));
|
|
145005
|
+
}
|
|
144965
145006
|
} else if (lambda.zipBuffer) {
|
|
144966
145007
|
ops.push(unzip(lambda.zipBuffer, dest));
|
|
144967
145008
|
} else {
|
|
@@ -145053,21 +145094,29 @@ async function* findDirs(name, dir, root = dir) {
|
|
|
145053
145094
|
}
|
|
145054
145095
|
}
|
|
145055
145096
|
}
|
|
145056
|
-
function filesWithoutFsRefs(files, repoRootPath) {
|
|
145097
|
+
function filesWithoutFsRefs(files, repoRootPath, sharedDest, standalone) {
|
|
145057
145098
|
let filePathMap;
|
|
145058
145099
|
const out = {};
|
|
145100
|
+
const shared = {};
|
|
145059
145101
|
for (const [path11, file] of Object.entries(files)) {
|
|
145060
145102
|
if (file.type === "FileFsRef") {
|
|
145061
145103
|
if (!filePathMap)
|
|
145062
145104
|
filePathMap = {};
|
|
145063
|
-
|
|
145064
|
-
|
|
145065
|
-
|
|
145105
|
+
if (standalone && sharedDest) {
|
|
145106
|
+
shared[path11] = file;
|
|
145107
|
+
filePathMap[(0, import_build_utils11.normalizePath)(path11)] = (0, import_build_utils11.normalizePath)(
|
|
145108
|
+
(0, import_path21.relative)(repoRootPath, (0, import_path21.join)(sharedDest, path11))
|
|
145109
|
+
);
|
|
145110
|
+
} else {
|
|
145111
|
+
filePathMap[(0, import_build_utils11.normalizePath)(path11)] = (0, import_build_utils11.normalizePath)(
|
|
145112
|
+
(0, import_path21.relative)(repoRootPath, file.fsPath)
|
|
145113
|
+
);
|
|
145114
|
+
}
|
|
145066
145115
|
} else {
|
|
145067
145116
|
out[path11] = file;
|
|
145068
145117
|
}
|
|
145069
145118
|
}
|
|
145070
|
-
return { files: out, filePathMap };
|
|
145119
|
+
return { files: out, filePathMap, shared };
|
|
145071
145120
|
}
|
|
145072
145121
|
var import_fs_extra12, import_mime_types, import_path21, import_build_utils11, import_promisepipe2, import_client3, normalize2, OUTPUT_DIR;
|
|
145073
145122
|
var init_write_build_result = __esm({
|
|
@@ -145335,6 +145384,11 @@ var init_build = __esm({
|
|
|
145335
145384
|
this.trackCliFlag("yes");
|
|
145336
145385
|
}
|
|
145337
145386
|
}
|
|
145387
|
+
trackCliFlagStandalone(flag) {
|
|
145388
|
+
if (flag) {
|
|
145389
|
+
this.trackCliFlag("standalone");
|
|
145390
|
+
}
|
|
145391
|
+
}
|
|
145338
145392
|
};
|
|
145339
145393
|
}
|
|
145340
145394
|
});
|
|
@@ -146710,6 +146764,7 @@ async function main3(client2) {
|
|
|
146710
146764
|
flags: parsedArgs.flags
|
|
146711
146765
|
}) || "preview";
|
|
146712
146766
|
const yes = Boolean(parsedArgs.flags["--yes"]);
|
|
146767
|
+
const standalone = process.env.VERCEL_EXPERIMENTAL_STANDALONE_BUILD === "1";
|
|
146713
146768
|
try {
|
|
146714
146769
|
await (0, import_build_utils13.validateNpmrc)(cwd);
|
|
146715
146770
|
} catch (err) {
|
|
@@ -146816,7 +146871,7 @@ async function main3(client2) {
|
|
|
146816
146871
|
process.env.NOW_BUILDER = "1";
|
|
146817
146872
|
try {
|
|
146818
146873
|
await rootSpan.child("vc.doBuild").trace(
|
|
146819
|
-
(span) => doBuild(client2, project, buildsJson, cwd, outputDir, span)
|
|
146874
|
+
(span) => doBuild(client2, project, buildsJson, cwd, outputDir, span, standalone)
|
|
146820
146875
|
);
|
|
146821
146876
|
} finally {
|
|
146822
146877
|
await rootSpan.stop();
|
|
@@ -146849,7 +146904,7 @@ async function main3(client2) {
|
|
|
146849
146904
|
}
|
|
146850
146905
|
}
|
|
146851
146906
|
}
|
|
146852
|
-
async function doBuild(client2, project, buildsJson, cwd, outputDir, span) {
|
|
146907
|
+
async function doBuild(client2, project, buildsJson, cwd, outputDir, span, standalone = false) {
|
|
146853
146908
|
const { localConfigPath } = client2;
|
|
146854
146909
|
const workPath = (0, import_path27.join)(cwd, project.settings.rootDirectory || ".");
|
|
146855
146910
|
const [pkg, vercelConfig, nowConfig, hasInstrumentation] = await Promise.all([
|
|
@@ -147037,7 +147092,12 @@ async function doBuild(client2, project, buildsJson, cwd, outputDir, span) {
|
|
|
147037
147092
|
let buildResult;
|
|
147038
147093
|
try {
|
|
147039
147094
|
buildResult = await builderSpan.trace(
|
|
147040
|
-
() =>
|
|
147095
|
+
() => {
|
|
147096
|
+
if (process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" && "name" in builder && builder.name === "express" && "experimentalBuild" in builder && typeof builder.experimentalBuild === "function") {
|
|
147097
|
+
return builder.experimentalBuild(buildOptions);
|
|
147098
|
+
}
|
|
147099
|
+
return builder.build(buildOptions);
|
|
147100
|
+
}
|
|
147041
147101
|
);
|
|
147042
147102
|
if (buildConfig.zeroConfig && isFrontendBuilder && "output" in buildResult && !buildResult.routes) {
|
|
147043
147103
|
const framework2 = import_frameworks5.frameworkList.find(
|
|
@@ -147085,7 +147145,8 @@ async function doBuild(client2, project, buildsJson, cwd, outputDir, span) {
|
|
|
147085
147145
|
build2,
|
|
147086
147146
|
builder,
|
|
147087
147147
|
builderPkg,
|
|
147088
|
-
localConfig
|
|
147148
|
+
localConfig,
|
|
147149
|
+
standalone
|
|
147089
147150
|
)
|
|
147090
147151
|
).then(
|
|
147091
147152
|
(override) => {
|
|
@@ -151041,7 +151102,8 @@ ${err.stack}`);
|
|
|
151041
151102
|
printError(err);
|
|
151042
151103
|
return 1;
|
|
151043
151104
|
}
|
|
151044
|
-
const
|
|
151105
|
+
const { isAgent } = await (0, import_detect_agent.determineAgent)();
|
|
151106
|
+
const guidanceMode = parsedArguments.flags["--guidance"] ?? isAgent;
|
|
151045
151107
|
return printDeploymentStatus(deployment, deployStamp, noWait, guidanceMode);
|
|
151046
151108
|
};
|
|
151047
151109
|
addProcessEnv = async (log2, env) => {
|
|
@@ -174373,7 +174435,8 @@ async function add4(client2, argv) {
|
|
|
174373
174435
|
)}
|
|
174374
174436
|
`
|
|
174375
174437
|
);
|
|
174376
|
-
const
|
|
174438
|
+
const { isAgent } = await (0, import_detect_agent2.determineAgent)();
|
|
174439
|
+
const guidanceMode = parsedArgs.flags["--guidance"] ?? isAgent;
|
|
174377
174440
|
if (guidanceMode) {
|
|
174378
174441
|
suggestNextCommands([getCommandName(`env ls`), getCommandName(`env pull`)]);
|
|
174379
174442
|
}
|
|
@@ -174558,7 +174621,8 @@ async function ls5(client2, argv) {
|
|
|
174558
174621
|
client2.stdout.write(`${getTable(link4, envs, customEnvs)}
|
|
174559
174622
|
`);
|
|
174560
174623
|
}
|
|
174561
|
-
const
|
|
174624
|
+
const { isAgent } = await (0, import_detect_agent3.determineAgent)();
|
|
174625
|
+
const guidanceMode = parsedArgs.flags["--guidance"] ?? isAgent;
|
|
174562
174626
|
if (guidanceMode) {
|
|
174563
174627
|
suggestNextCommands([
|
|
174564
174628
|
getCommandName(`env add`),
|
|
@@ -186027,8 +186091,8 @@ var main17 = async () => {
|
|
|
186027
186091
|
store: telemetryEventStore
|
|
186028
186092
|
}
|
|
186029
186093
|
});
|
|
186030
|
-
const agent = await (0, import_detect_agent4.determineAgent)();
|
|
186031
|
-
telemetry2.trackAgenticUse(agent);
|
|
186094
|
+
const { agent } = await (0, import_detect_agent4.determineAgent)();
|
|
186095
|
+
telemetry2.trackAgenticUse(agent?.name);
|
|
186032
186096
|
telemetry2.trackCPUs();
|
|
186033
186097
|
telemetry2.trackPlatform();
|
|
186034
186098
|
telemetry2.trackArch();
|
|
@@ -9,10 +9,13 @@
|
|
|
9
9
|
"license": "Apache-2.0"
|
|
10
10
|
},
|
|
11
11
|
"node_modules/@vercel/detect-agent": {
|
|
12
|
-
"version": "0.
|
|
13
|
-
"resolved": "https://registry.npmjs.org/@vercel/detect-agent/-/detect-agent-0.
|
|
14
|
-
"integrity": "sha512-
|
|
15
|
-
"license": "Apache-2.0"
|
|
12
|
+
"version": "1.0.0",
|
|
13
|
+
"resolved": "https://registry.npmjs.org/@vercel/detect-agent/-/detect-agent-1.0.0.tgz",
|
|
14
|
+
"integrity": "sha512-AIPgNkmtFcDgPCl+xvTT1ga90OL7OTX2RKM4zu0PMpwBthPfN2DpdHy10n3bh8K+CA22GDU0/ncjzprZsrk0sw==",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=14"
|
|
18
|
+
}
|
|
16
19
|
},
|
|
17
20
|
"node_modules/@vercel/python": {
|
|
18
21
|
"version": "5.0.5",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @vercel/detect-agent
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Change return format to be an object to future proof ([#13965](https://github.com/vercel/vercel/pull/13965))
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Improve agent detection ([#13762](https://github.com/vercel/vercel/pull/13762))
|
|
14
|
+
|
|
15
|
+
## 0.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Initial release ([#13745](https://github.com/vercel/vercel/pull/13745))
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# @vercel/detect-agent
|
|
2
|
+
|
|
3
|
+
A lightweight utility for detecting if code is being executed by an AI agent or automated development environment.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vercel/detect-agent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { determineAgent } from '@vercel/detect-agent';
|
|
15
|
+
|
|
16
|
+
const { isAgent, agent } = await determineAgent();
|
|
17
|
+
|
|
18
|
+
if (isAgent) {
|
|
19
|
+
console.log(`Running in ${agent.name} environment`);
|
|
20
|
+
// Adapt behavior for AI agent context
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Supported Agents
|
|
25
|
+
|
|
26
|
+
This package can detect the following AI agents and development environments:
|
|
27
|
+
|
|
28
|
+
- **Custom agents** via `AI_AGENT` environment variable
|
|
29
|
+
- **Cursor** (cursor editor and cursor-cli)
|
|
30
|
+
- **Claude Code** (Anthropic's Claude)
|
|
31
|
+
- **Devin** (Cognition Labs)
|
|
32
|
+
- **Gemini CLI** (Google)
|
|
33
|
+
- **Codex** (OpenAI)
|
|
34
|
+
- **Replit** (online IDE)
|
|
35
|
+
|
|
36
|
+
## The AI_AGENT Standard
|
|
37
|
+
|
|
38
|
+
We're promoting `AI_AGENT` as a universal environment variable standard for AI development tools. This allows any tool or library to easily detect when it's running in an AI-driven environment.
|
|
39
|
+
|
|
40
|
+
### For AI Tool Developers
|
|
41
|
+
|
|
42
|
+
Set the `AI_AGENT` environment variable to identify your tool:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
export AI_AGENT="your-tool-name"
|
|
46
|
+
# or
|
|
47
|
+
AI_AGENT="your-tool-name" your-command
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Recommended Naming Convention
|
|
51
|
+
|
|
52
|
+
- Use lowercase with hyphens for multi-word names
|
|
53
|
+
- Include version information if needed, separated by an `@` symbol
|
|
54
|
+
- Examples: `claude-code`, `cursor-cli`, `devin@1`, `custom-agent@2.0`
|
|
55
|
+
|
|
56
|
+
## Use Cases
|
|
57
|
+
|
|
58
|
+
### Adaptive Behavior
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { determineAgent } from '@vercel/detect-agent';
|
|
62
|
+
|
|
63
|
+
async function setupEnvironment() {
|
|
64
|
+
const { isAgent, agent } = await determineAgent();
|
|
65
|
+
|
|
66
|
+
if (isAgent) {
|
|
67
|
+
// Running in AI environment - adjust behavior
|
|
68
|
+
process.env.LOG_LEVEL = 'verbose';
|
|
69
|
+
console.log(`🤖 Detected AI agent: ${agent.name}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Telemetry and Analytics
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { determineAgent } from '@vercel/detect-agent';
|
|
78
|
+
|
|
79
|
+
async function trackUsage(event: string) {
|
|
80
|
+
const result = await determineAgent();
|
|
81
|
+
|
|
82
|
+
analytics.track(event, {
|
|
83
|
+
agent: result.isAgent ? result.agent.name : 'human',
|
|
84
|
+
timestamp: Date.now(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Feature Toggles
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { determineAgent } from '@vercel/detect-agent';
|
|
93
|
+
|
|
94
|
+
async function shouldEnableFeature(feature: string) {
|
|
95
|
+
const result = await determineAgent();
|
|
96
|
+
|
|
97
|
+
// Enable experimental features for AI agents
|
|
98
|
+
if (result.isAgent && feature === 'experimental-ai-mode') {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
We welcome contributions! Please see our [contributing guidelines](../../CONTRIBUTING.md).
|
|
109
|
+
|
|
110
|
+
### Adding New Agent Support
|
|
111
|
+
|
|
112
|
+
To add support for a new AI agent:
|
|
113
|
+
|
|
114
|
+
1. Add detection logic to `src/index.ts`
|
|
115
|
+
2. Add comprehensive test cases in `test/unit/determine-agent.test.ts`
|
|
116
|
+
3. Update this README with the new agent information
|
|
117
|
+
4. Follow the existing priority order pattern
|
|
118
|
+
|
|
119
|
+
## Links
|
|
120
|
+
|
|
121
|
+
- [GitHub Repository](https://github.com/vercel/vercel/tree/main/packages/detect-agent)
|
|
122
|
+
- [npm Package](https://www.npmjs.com/package/@vercel/detect-agent)
|
|
123
|
+
- [Vercel Documentation](https://vercel.com/docs)
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
declare const CURSOR: "cursor";
|
|
2
|
+
declare const CURSOR_CLI: "cursor-cli";
|
|
3
|
+
declare const CLAUDE: "claude";
|
|
4
|
+
declare const DEVIN: "devin";
|
|
5
|
+
declare const REPLIT: "replit";
|
|
6
|
+
declare const GEMINI: "gemini";
|
|
7
|
+
declare const CODEX: "codex";
|
|
8
|
+
export type KnownAgentNames = typeof CURSOR | typeof CURSOR_CLI | typeof CLAUDE | typeof DEVIN | typeof REPLIT | typeof GEMINI | typeof CODEX;
|
|
9
|
+
export interface KnownAgentDetails {
|
|
10
|
+
name: KnownAgentNames;
|
|
11
|
+
}
|
|
12
|
+
export type AgentResult = {
|
|
13
|
+
isAgent: true;
|
|
14
|
+
agent: KnownAgentDetails;
|
|
15
|
+
} | {
|
|
16
|
+
isAgent: false;
|
|
17
|
+
agent: undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const KNOWN_AGENTS: {
|
|
20
|
+
readonly CURSOR: "cursor";
|
|
21
|
+
readonly CURSOR_CLI: "cursor-cli";
|
|
22
|
+
readonly CLAUDE: "claude";
|
|
23
|
+
readonly DEVIN: "devin";
|
|
24
|
+
readonly REPLIT: "replit";
|
|
25
|
+
readonly GEMINI: "gemini";
|
|
26
|
+
readonly CODEX: "codex";
|
|
27
|
+
};
|
|
28
|
+
export declare function determineAgent(): Promise<AgentResult>;
|
|
29
|
+
export {};
|
|
@@ -18,12 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
|
+
KNOWN_AGENTS: () => KNOWN_AGENTS,
|
|
21
22
|
determineAgent: () => determineAgent
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(src_exports);
|
|
24
25
|
var import_promises = require("node:fs/promises");
|
|
25
26
|
var import_node_fs = require("node:fs");
|
|
26
|
-
const
|
|
27
|
+
const DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
27
28
|
const CURSOR = "cursor";
|
|
28
29
|
const CURSOR_CLI = "cursor-cli";
|
|
29
30
|
const CLAUDE = "claude";
|
|
@@ -31,36 +32,52 @@ const DEVIN = "devin";
|
|
|
31
32
|
const REPLIT = "replit";
|
|
32
33
|
const GEMINI = "gemini";
|
|
33
34
|
const CODEX = "codex";
|
|
35
|
+
const KNOWN_AGENTS = {
|
|
36
|
+
CURSOR,
|
|
37
|
+
CURSOR_CLI,
|
|
38
|
+
CLAUDE,
|
|
39
|
+
DEVIN,
|
|
40
|
+
REPLIT,
|
|
41
|
+
GEMINI,
|
|
42
|
+
CODEX
|
|
43
|
+
};
|
|
34
44
|
async function determineAgent() {
|
|
35
45
|
if (process.env.AI_AGENT) {
|
|
36
|
-
|
|
46
|
+
const name = process.env.AI_AGENT.trim();
|
|
47
|
+
if (name) {
|
|
48
|
+
return {
|
|
49
|
+
isAgent: true,
|
|
50
|
+
agent: { name }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
37
53
|
}
|
|
38
54
|
if (process.env.CURSOR_TRACE_ID) {
|
|
39
|
-
return CURSOR;
|
|
55
|
+
return { isAgent: true, agent: { name: CURSOR } };
|
|
40
56
|
}
|
|
41
57
|
if (process.env.CURSOR_AGENT) {
|
|
42
|
-
return CURSOR_CLI;
|
|
58
|
+
return { isAgent: true, agent: { name: CURSOR_CLI } };
|
|
43
59
|
}
|
|
44
60
|
if (process.env.GEMINI_CLI) {
|
|
45
|
-
return GEMINI;
|
|
61
|
+
return { isAgent: true, agent: { name: GEMINI } };
|
|
46
62
|
}
|
|
47
63
|
if (process.env.CODEX_SANDBOX) {
|
|
48
|
-
return CODEX;
|
|
64
|
+
return { isAgent: true, agent: { name: CODEX } };
|
|
49
65
|
}
|
|
50
66
|
if (process.env.CLAUDECODE || process.env.CLAUDE_CODE) {
|
|
51
|
-
return CLAUDE;
|
|
67
|
+
return { isAgent: true, agent: { name: CLAUDE } };
|
|
52
68
|
}
|
|
53
69
|
if (process.env.REPL_ID) {
|
|
54
|
-
return REPLIT;
|
|
70
|
+
return { isAgent: true, agent: { name: REPLIT } };
|
|
55
71
|
}
|
|
56
72
|
try {
|
|
57
|
-
await (0, import_promises.access)(
|
|
58
|
-
return DEVIN;
|
|
73
|
+
await (0, import_promises.access)(DEVIN_LOCAL_PATH, import_node_fs.constants.F_OK);
|
|
74
|
+
return { isAgent: true, agent: { name: DEVIN } };
|
|
59
75
|
} catch (error) {
|
|
60
|
-
return false;
|
|
61
76
|
}
|
|
77
|
+
return { isAgent: false, agent: void 0 };
|
|
62
78
|
}
|
|
63
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
80
|
0 && (module.exports = {
|
|
81
|
+
KNOWN_AGENTS,
|
|
65
82
|
determineAgent
|
|
66
83
|
});
|
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/detect-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Detect if code is running in an AI agent or automated development environment",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"agent",
|
|
8
|
+
"detection",
|
|
9
|
+
"environment",
|
|
10
|
+
"cursor",
|
|
11
|
+
"claude",
|
|
12
|
+
"devin",
|
|
13
|
+
"automation",
|
|
14
|
+
"ai-agent"
|
|
15
|
+
],
|
|
4
16
|
"license": "Apache-2.0",
|
|
17
|
+
"author": "Vercel",
|
|
5
18
|
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
6
27
|
"publishConfig": {
|
|
7
28
|
"access": "public"
|
|
8
29
|
},
|
|
9
|
-
"homepage": "https://
|
|
30
|
+
"homepage": "https://github.com/vercel/vercel/tree/main/packages/detect-agent#readme",
|
|
10
31
|
"repository": {
|
|
11
32
|
"type": "git",
|
|
12
33
|
"url": "https://github.com/vercel/vercel.git",
|
|
13
34
|
"directory": "packages/detect-agent"
|
|
14
35
|
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/vercel/vercel/issues"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=14"
|
|
41
|
+
},
|
|
15
42
|
"files": [
|
|
16
|
-
"dist"
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"CHANGELOG.md"
|
|
17
46
|
],
|
|
18
47
|
"dependencies": {},
|
|
19
48
|
"devDependencies": {
|
|
@@ -24,8 +53,7 @@
|
|
|
24
53
|
},
|
|
25
54
|
"scripts": {
|
|
26
55
|
"build": "node ../../utils/build.mjs",
|
|
27
|
-
"
|
|
28
|
-
"vitest-unit": "glob --absolute 'test/unit/**/*.test.ts' 'test/unit/**/*.test.mts'",
|
|
56
|
+
"test": "vitest -c ../../vitest.config.mts",
|
|
29
57
|
"type-check": "tsc --noEmit"
|
|
30
58
|
}
|
|
31
59
|
}
|
vercel_cli/vendor/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@vercel/build-utils": "12.1.0",
|
|
8
|
-
"@vercel/detect-agent": "0.
|
|
8
|
+
"@vercel/detect-agent": "1.0.0",
|
|
9
9
|
"@vercel/python": "5.0.5"
|
|
10
10
|
},
|
|
11
11
|
"description": "The command-line interface for Vercel",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"vitest-run": "vitest --config ./vitest.config.mts",
|
|
38
38
|
"vitest-unit": "jest test/unit/ --listTests"
|
|
39
39
|
},
|
|
40
|
-
"version": "48.1.
|
|
40
|
+
"version": "48.1.4"
|
|
41
41
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vercel-cli
|
|
3
|
-
Version: 48.1.
|
|
3
|
+
Version: 48.1.4
|
|
4
4
|
Summary: Vercel CLI packaged for Python (bundled Node.js, vendored npm)
|
|
5
5
|
Project-URL: Homepage, https://github.com/nuage-studio/vercel-cli-python
|
|
6
6
|
Project-URL: Repository, https://github.com/nuage-studio/vercel-cli-python
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
vercel_cli/vendor/LICENSE,sha256=sHDXe_ssUqHdaZbeDOX2TEmgylXIibFjqWPd9csAHuI,11343
|
|
2
2
|
vercel_cli/vendor/README.md,sha256=2ZrJzd7x21xlpsOZ9QKG6478zbXb8-3YN8cPyzPxZNk,1799
|
|
3
|
-
vercel_cli/vendor/package.json,sha256=
|
|
3
|
+
vercel_cli/vendor/package.json,sha256=d3JYfKfeAgrCe8mwi1zhDUpCau_ChaFPMOXuObr3jjU,1261
|
|
4
4
|
vercel_cli/vendor/dist/VERCEL_DIR_README.txt,sha256=9dHtD1AyrhKJMfRkWbX6oa9jGfwt-z56X-VKhL-T29Y,520
|
|
5
5
|
vercel_cli/vendor/dist/builder-worker.js,sha256=RgutTXJcurRisV2NtlruuPDtCBOi8eHSGCo3n4GcCIM,1969
|
|
6
6
|
vercel_cli/vendor/dist/get-latest-worker.js,sha256=w7nK8nQtlYad_SKuFQGw_sg7_bb-p0uHOf1MYiwrUNs,7964
|
|
7
|
-
vercel_cli/vendor/dist/index.js,sha256=
|
|
7
|
+
vercel_cli/vendor/dist/index.js,sha256=wv1JJrdNJEQV2QozYLwfzPEAhFrcpeMd44xfL2J1nwM,8880842
|
|
8
8
|
vercel_cli/vendor/dist/vc.js,sha256=AAC4u6uwjpO0KfFVuLRs5YWXjW4aMCkgSj_45hR3W8k,340
|
|
9
|
-
vercel_cli/vendor/node_modules/.package-lock.json,sha256=
|
|
9
|
+
vercel_cli/vendor/node_modules/.package-lock.json,sha256=rEp5PAxk6jbsOEZZ_HOWnFpAIv94UIaPJ7TiNHgbY80,1053
|
|
10
10
|
vercel_cli/vendor/node_modules/@vercel/build-utils/CHANGELOG.md,sha256=ji-V7NgIUH1Fj-lmUh0LmIxhS6bq_0TW7xFH0e9yiF8,18051
|
|
11
11
|
vercel_cli/vendor/node_modules/@vercel/build-utils/LICENSE,sha256=sHDXe_ssUqHdaZbeDOX2TEmgylXIibFjqWPd9csAHuI,11343
|
|
12
12
|
vercel_cli/vendor/node_modules/@vercel/build-utils/build.mjs,sha256=UCAJgPaur_bxtLTnQxSkBwoq246SSCBvI-0w_PvbAVU,132
|
|
@@ -89,15 +89,17 @@ vercel_cli/vendor/node_modules/@vercel/build-utils/fs/glob.js,sha256=6BDU1Yu2e9t
|
|
|
89
89
|
vercel_cli/vendor/node_modules/@vercel/build-utils/fs/rename.js,sha256=tDfT7mkZu9EqBJx3r5o6N6irGvkjMFMLE9dPow8W5f4,50
|
|
90
90
|
vercel_cli/vendor/node_modules/@vercel/build-utils/fs/run-user-scripts.js,sha256=wZPDCPVjfxX_CrnJDJ0mJYrItsHNlkzBqMdnEPujLmc,43
|
|
91
91
|
vercel_cli/vendor/node_modules/@vercel/build-utils/fs/stream-to-buffer.js,sha256=Q4ZkMugOkxvIkIbq6YlMXBbkuHj2BBjNJvRtsXeGwww,58
|
|
92
|
+
vercel_cli/vendor/node_modules/@vercel/detect-agent/CHANGELOG.md,sha256=U04hZw38hixzMsaCFsRhprk6hDztjbVFOrHfGdFQCUI,380
|
|
92
93
|
vercel_cli/vendor/node_modules/@vercel/detect-agent/LICENSE,sha256=sHDXe_ssUqHdaZbeDOX2TEmgylXIibFjqWPd9csAHuI,11343
|
|
93
|
-
vercel_cli/vendor/node_modules/@vercel/detect-agent/
|
|
94
|
-
vercel_cli/vendor/node_modules/@vercel/detect-agent/
|
|
95
|
-
vercel_cli/vendor/node_modules/@vercel/detect-agent/dist/index.
|
|
94
|
+
vercel_cli/vendor/node_modules/@vercel/detect-agent/README.md,sha256=rFNRJMjrMU2EkYx4qnNg4ulXIhhAHDnO6sOIIIVKP5c,3049
|
|
95
|
+
vercel_cli/vendor/node_modules/@vercel/detect-agent/package.json,sha256=skFFT-UpaRezXJjk47svjfoqsFRGj76Xr8VpMxF6o0k,1306
|
|
96
|
+
vercel_cli/vendor/node_modules/@vercel/detect-agent/dist/index.d.ts,sha256=3HzKZBBpy_L_9ZFprqKrWHCTmazGlzGoqvx6MRABkjg,901
|
|
97
|
+
vercel_cli/vendor/node_modules/@vercel/detect-agent/dist/index.js,sha256=likIDfr0UHioDUkMLymGQoCfoOhDvj0c3mP2VyP9StA,2510
|
|
96
98
|
vercel_cli/vendor/node_modules/@vercel/python/LICENSE,sha256=sHDXe_ssUqHdaZbeDOX2TEmgylXIibFjqWPd9csAHuI,11343
|
|
97
99
|
vercel_cli/vendor/node_modules/@vercel/python/package.json,sha256=rLcVtrCKoYOp00gwMR7LmyfI_H-8M01PnBZsGICTLfs,1044
|
|
98
100
|
vercel_cli/vendor/node_modules/@vercel/python/vc_init.py,sha256=A7949hQi18B9yqPkTr1bepToi7nKRh_yRP7GwmsI-Ww,28201
|
|
99
101
|
vercel_cli/vendor/node_modules/@vercel/python/dist/index.js,sha256=8ta98iZTEyUQPkd-t7hzMQ4PAaL9OfRMuo6yde25Ld4,111220
|
|
100
|
-
vercel_cli-48.1.
|
|
101
|
-
vercel_cli-48.1.
|
|
102
|
-
vercel_cli-48.1.
|
|
103
|
-
vercel_cli-48.1.
|
|
102
|
+
vercel_cli-48.1.4.dist-info/METADATA,sha256=GDzavBLXiBAJHB3_nlkrEsX_ncBVB9qtpfPlfTIbpSg,7085
|
|
103
|
+
vercel_cli-48.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
104
|
+
vercel_cli-48.1.4.dist-info/entry_points.txt,sha256=3iHkg20gi2BZorK1g5UlyZY3tN5E1vJX6PX5-ibn9fI,83
|
|
105
|
+
vercel_cli-48.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|