@github-tools/eve-extension 0.11.0 → 0.12.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/extension/extension.d.ts +18 -1
- package/dist/extension/extension.d.ts.map +1 -1
- package/dist/extension/extension.mjs +7 -1
- package/dist/extension/instructions.d.ts.map +1 -1
- package/dist/extension/instructions.mjs +4 -3
- package/dist/extension/lib/context.d.ts +12 -0
- package/dist/extension/lib/context.d.ts.map +1 -0
- package/dist/extension/lib/context.mjs +24 -0
- package/dist/extension/tools/github.d.ts.map +1 -1
- package/dist/extension/tools/github.mjs +52 -13
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GithubTokenCall, GithubTokenInput } from '@github-tools/sdk';
|
|
2
2
|
import type { ConnectTokenSubject, GithubConnectorInput, GithubConnectParams } from '@github-tools/sdk/connect';
|
|
3
3
|
import type { ToolContext } from 'eve/tools';
|
|
4
|
-
import { type CommitIdentity, type EveApprovalValue, type EveToolOverrides, type GithubEvaluationOptions, type GithubToolName, type GithubToolPreset, type GithubWriteToolName } from '@github-tools/sdk/eve-runtime';
|
|
4
|
+
import { type CommitIdentity, type EveApprovalValue, type EveToolOverrides, type GithubEvaluationOptions, type GithubGuardrails, type GithubToolName, type GithubToolPreset, type GithubWriteToolName } from '@github-tools/sdk/eve-runtime';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
/**
|
|
7
7
|
* Default owner / repo / PR / issue / ref for tool inputs.
|
|
@@ -175,6 +175,23 @@ export interface GithubExtensionConfig {
|
|
|
175
175
|
committer?: CommitIdentity;
|
|
176
176
|
/** Co-authors to attribute on commits created by tools. */
|
|
177
177
|
coAuthors?: CommitIdentity[];
|
|
178
|
+
/**
|
|
179
|
+
* Repositories and branches the tools may act on, checked before each call reaches GitHub.
|
|
180
|
+
* `repositories` takes `owner/repo` or `owner/*`; `branches` takes names or patterns such as
|
|
181
|
+
* `agent/*` and covers commits, branch creation and deletion, merges into a pull request's base,
|
|
182
|
+
* and updates of a pull request's branch. A call whose input contains what looks like a
|
|
183
|
+
* credential is blocked too, unless `secrets: 'allow'`. A blocked write is denied with the reason
|
|
184
|
+
* instead of asking anyone to approve it.
|
|
185
|
+
*/
|
|
186
|
+
guardrails?: GithubGuardrails;
|
|
187
|
+
/**
|
|
188
|
+
* Shadow mode: run reads as usual but send no write to GitHub, and ask nobody to approve one.
|
|
189
|
+
* Each write still goes through `guardrails`, then returns a dry-run result that says whether
|
|
190
|
+
* approval would have asked a person (with the evaluation model's verdict under `'auto'`), and
|
|
191
|
+
* its label reads "Would create issue on owner/repo". Use it to try the agent on real
|
|
192
|
+
* repositories, for example a scheduled bot, before letting it write.
|
|
193
|
+
*/
|
|
194
|
+
dryRun?: boolean;
|
|
178
195
|
}
|
|
179
196
|
declare const _default: import("eve/extension").ExtensionHandle<z.ZodType<GithubExtensionConfig, GithubExtensionConfig, z.core.$ZodTypeInternals<GithubExtensionConfig, GithubExtensionConfig>>>;
|
|
180
197
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../extension/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;I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,EAAE,sBAAsB,CAAA;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,6BAA6B,CAAA;IAC/C,wGAAwG;IACxG,UAAU,CAAC,EAAE,uBAAuB,CAAA;IACpC,gGAAgG;IAChG,SAAS,CAAC,EAAE,4BAA4B,CAAA;IACxC,gDAAgD;IAChD,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,mDAAmD;IACnD,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,cAAc,EAAE,CAAA;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;;AA6ED,wBAEE"}
|
|
@@ -62,7 +62,13 @@ const configSchema = z.object({
|
|
|
62
62
|
overrides: z.partialRecord(toolNameSchema, z.looseObject({ actAs: actAsSchema.optional() })).optional(),
|
|
63
63
|
author: commitIdentitySchema.optional(),
|
|
64
64
|
committer: commitIdentitySchema.optional(),
|
|
65
|
-
coAuthors: z.array(commitIdentitySchema).optional()
|
|
65
|
+
coAuthors: z.array(commitIdentitySchema).optional(),
|
|
66
|
+
guardrails: z.object({
|
|
67
|
+
repositories: z.array(z.string()).optional(),
|
|
68
|
+
branches: z.array(z.string()).optional(),
|
|
69
|
+
secrets: z.enum(["block", "allow"]).optional()
|
|
70
|
+
}).optional(),
|
|
71
|
+
dryRun: z.boolean().optional()
|
|
66
72
|
}).superRefine((config, ctx) => {
|
|
67
73
|
const { actAs } = config;
|
|
68
74
|
const identities = [...typeof actAs === "object" ? [actAs.read, actAs.write] : [actAs], ...Object.values(config.overrides ?? {}).map((override) => override?.actAs)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../extension/instructions.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../extension/instructions.ts"],"names":[],"mappings":";AAOA,wBAQE"}
|
|
@@ -5,13 +5,14 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import extension_default from "./extension.mjs";
|
|
8
|
+
import { sessionContext } from "./lib/context.mjs";
|
|
8
9
|
import { resolveToolGuidance } from "@github-tools/sdk/eve-runtime";
|
|
9
10
|
import { defineDynamic, defineInstructions } from "eve/instructions";
|
|
10
|
-
var instructions_default = defineDynamic(() => {
|
|
11
|
-
const { preset
|
|
11
|
+
var instructions_default = defineDynamic((ctx) => {
|
|
12
|
+
const { preset } = extension_default.config;
|
|
12
13
|
const guidance = resolveToolGuidance({
|
|
13
14
|
preset: preset === "auto" ? void 0 : preset,
|
|
14
|
-
context
|
|
15
|
+
context: sessionContext(ctx.session.auth.current)
|
|
15
16
|
});
|
|
16
17
|
return defineInstructions({ content: `GitHub tools: the tool names below leave out this extension's prefix, such as \`github__\`.${preset === "auto" ? " A GitHub tool that is not in your tool list can be found with `eve__search`." : ""}\n\n${guidance}` });
|
|
17
18
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GithubExtensionContext } from '../extension';
|
|
2
|
+
type SessionAuth = {
|
|
3
|
+
readonly authenticator?: string;
|
|
4
|
+
readonly attributes?: Readonly<Record<string, string | readonly string[]>>;
|
|
5
|
+
} | null | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The extension's `context`, with the fields it leaves out filled from the GitHub channel's thread:
|
|
8
|
+
* the repository, and the issue or pull request number. Other channels add nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sessionContext(auth: SessionAuth): GithubExtensionContext | undefined;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../extension/lib/context.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAErE,KAAK,WAAW,GAAG;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAA;AAErJ;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,sBAAsB,GAAG,SAAS,CAUpF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __eveDirname } from "node:path";
|
|
3
|
+
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
+
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
+
__eveDirname(__filename);
|
|
6
|
+
__eveCreateRequire(import.meta.url);
|
|
7
|
+
import extension_default from "../extension.mjs";
|
|
8
|
+
function sessionContext(auth) {
|
|
9
|
+
const configured = extension_default.config.context;
|
|
10
|
+
if (auth?.authenticator !== "github-webhook") return configured;
|
|
11
|
+
const { repository, issue_number: issue, pull_request_number: pull } = auth.attributes ?? {};
|
|
12
|
+
const [owner, repo] = typeof repository === "string" ? repository.split("/") : [];
|
|
13
|
+
if (!owner || !repo) return configured;
|
|
14
|
+
const pullNumber = Number(pull) || void 0;
|
|
15
|
+
const issueNumber = Number(issue) || pullNumber;
|
|
16
|
+
return {
|
|
17
|
+
owner,
|
|
18
|
+
repo,
|
|
19
|
+
...pullNumber && { pullNumber },
|
|
20
|
+
...issueNumber && { issueNumber },
|
|
21
|
+
...configured
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { sessionContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":";AAuXA,wBAsDE"}
|
|
@@ -4,14 +4,16 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
+
import { sessionContext } from "../lib/context.mjs";
|
|
7
8
|
import extension_default from "../extension.mjs";
|
|
8
|
-
import { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, autoApprovalDecision, evaluatePresets, evaluateTools, executeGithubEveTool, fallbackPresets, fallbackTools, formatGithubEveToolOutput, githubToolsErrors, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, mapEveApprovalValue } from "@github-tools/sdk/eve-runtime";
|
|
9
|
+
import { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, autoApprovalDecision, evaluatePresets, evaluateTools, executeGithubEveTool, fallbackPresets, fallbackTools, formatGithubEveToolOutput, githubGuardrailViolation, githubToolsErrors, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, mapEveApprovalValue } from "@github-tools/sdk/eve-runtime";
|
|
9
10
|
import { z } from "zod";
|
|
10
11
|
import { connectGithubScopesForTools, connectGithubToken, resolveGithubConnector } from "@github-tools/sdk/connect";
|
|
11
12
|
import { connect } from "@vercel/connect/eve";
|
|
12
13
|
import { defineDynamic, defineTool, toolOutput } from "eve/tools";
|
|
13
|
-
function buildSessionOptions(ctx) {
|
|
14
|
-
const { token, connector, connect, preset, include, exclude, overrides,
|
|
14
|
+
function buildSessionOptions(ctx, auth = ctx?.session.auth.current) {
|
|
15
|
+
const { token, connector, connect, preset, include, exclude, overrides, author, committer, coAuthors, guardrails, dryRun } = extension_default.config;
|
|
16
|
+
const context = sessionContext(auth);
|
|
15
17
|
const includeNames = include;
|
|
16
18
|
const excludeNames = exclude;
|
|
17
19
|
return {
|
|
@@ -36,7 +38,9 @@ function buildSessionOptions(ctx) {
|
|
|
36
38
|
context,
|
|
37
39
|
author,
|
|
38
40
|
committer,
|
|
39
|
-
coAuthors
|
|
41
|
+
coAuthors,
|
|
42
|
+
guardrails,
|
|
43
|
+
dryRun
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
const autoApprovalTools = new Set(AUTO_APPROVAL_TOOLS);
|
|
@@ -83,6 +87,15 @@ async function githubUserAuth() {
|
|
|
83
87
|
}
|
|
84
88
|
async function runGithubEveTool(name, input, ctx) {
|
|
85
89
|
const args = input;
|
|
90
|
+
if (extension_default.config.dryRun && writeToolName(name)) {
|
|
91
|
+
const key = decisionKey(ctx.session.id, ctx.callId);
|
|
92
|
+
const dryRunApproval = dryRunApprovals.get(key);
|
|
93
|
+
dryRunApprovals.delete(key);
|
|
94
|
+
return executeGithubEveTool(name, args, {
|
|
95
|
+
...buildSessionOptions(ctx),
|
|
96
|
+
dryRunApproval
|
|
97
|
+
});
|
|
98
|
+
}
|
|
86
99
|
const actAs = actAsFor(name);
|
|
87
100
|
if (actAs === "app") return executeGithubEveTool(name, args, buildSessionOptions(ctx));
|
|
88
101
|
const requester = ctx.session.auth.current;
|
|
@@ -172,9 +185,30 @@ function configuredApprovalValue(name) {
|
|
|
172
185
|
const { requireApproval, overrides } = extension_default.config;
|
|
173
186
|
return approvalValue(writeTool, requireApproval, overrides?.[name]?.approval);
|
|
174
187
|
}
|
|
188
|
+
const dryRunApprovals = new Map();
|
|
175
189
|
async function runGithubEveApproval(name, request, ctx) {
|
|
176
190
|
const writeTool = writeToolName(name);
|
|
177
191
|
if (!writeTool) return "not-applicable";
|
|
192
|
+
const reason = githubGuardrailViolation(name, ctx.toolInput, {
|
|
193
|
+
context: sessionContext(ctx.session.auth.current),
|
|
194
|
+
guardrails: extension_default.config.guardrails
|
|
195
|
+
});
|
|
196
|
+
if (reason) return {
|
|
197
|
+
type: "denied",
|
|
198
|
+
reason
|
|
199
|
+
};
|
|
200
|
+
if (!extension_default.config.dryRun) return githubApprovalStatus(name, writeTool, request, ctx);
|
|
201
|
+
const auto = configuredApprovalValue(name) === "auto" && isPersonRequest(ctx) && await cachedAutoApproval(writeTool, request, ctx);
|
|
202
|
+
const status = auto ? void 0 : await githubApprovalStatus(name, writeTool, request, ctx);
|
|
203
|
+
if (status === "denied" || typeof status === "object" && status?.type === "denied") return status;
|
|
204
|
+
dryRunApprovals.set(decisionKey(ctx.session.id, ctx.callId), auto ? {
|
|
205
|
+
required: auto.ask,
|
|
206
|
+
reason: auto.reason
|
|
207
|
+
} : { required: status === true || status === "user-approval" || typeof status === "object" && status?.type === "user-approval" });
|
|
208
|
+
if (dryRunApprovals.size > MAX_CACHED_DECISIONS) dryRunApprovals.delete(dryRunApprovals.keys().next().value);
|
|
209
|
+
return "not-applicable";
|
|
210
|
+
}
|
|
211
|
+
async function githubApprovalStatus(name, writeTool, request, ctx) {
|
|
178
212
|
const value = configuredApprovalValue(name);
|
|
179
213
|
if (value === "auto") {
|
|
180
214
|
if (!isPersonRequest(ctx)) return "user-approval";
|
|
@@ -187,10 +221,10 @@ async function runGithubEveApproval(name, request, ctx) {
|
|
|
187
221
|
if (isEveApprovalDisabled(value)) return "not-applicable";
|
|
188
222
|
return mapEveApprovalValue(value)(ctx);
|
|
189
223
|
}
|
|
190
|
-
function describeGithubCall(name, inputSchema, input) {
|
|
224
|
+
function describeGithubCall(name, inputSchema, input, sessionContext) {
|
|
191
225
|
const fields = inputSchema instanceof z.ZodObject ? inputSchema.shape : {};
|
|
192
226
|
const { owner, repo, pullNumber, issueNumber, discussionNumber } = {
|
|
193
|
-
...Object.fromEntries(Object.entries(
|
|
227
|
+
...Object.fromEntries(Object.entries(sessionContext ?? {}).filter(([key]) => key in fields)),
|
|
194
228
|
...input
|
|
195
229
|
};
|
|
196
230
|
const action = name.replace(/[A-Z]/g, (letter) => ` ${letter.toLowerCase()}`);
|
|
@@ -218,22 +252,27 @@ const PAST_TENSE = {
|
|
|
218
252
|
trigger: "Triggered",
|
|
219
253
|
update: "Updated"
|
|
220
254
|
};
|
|
221
|
-
function describeGithubResult(name, inputSchema, input, output) {
|
|
255
|
+
function describeGithubResult(name, inputSchema, input, output, context) {
|
|
222
256
|
if (output !== null && typeof output === "object" && "error" in output) {
|
|
223
|
-
const label = describeGithubCall(name, inputSchema, input);
|
|
257
|
+
const label = describeGithubCall(name, inputSchema, input, context);
|
|
224
258
|
return `Couldn't ${label[0].toLowerCase()}${label.slice(1)}`;
|
|
225
259
|
}
|
|
226
260
|
if (!writeToolName(name)) return "";
|
|
261
|
+
if (output !== null && typeof output === "object" && "dryRun" in output) {
|
|
262
|
+
const label = describeGithubCall(name, inputSchema, input, context);
|
|
263
|
+
return `Would ${label[0].toLowerCase()}${label.slice(1)}`;
|
|
264
|
+
}
|
|
227
265
|
const created = output !== null && typeof output === "object" && "number" in output && typeof output.number === "number" ? output.number : void 0;
|
|
228
266
|
const [verb, ...rest] = describeGithubCall(name, inputSchema, created !== void 0 && input.pullNumber === void 0 && input.issueNumber === void 0 && input.discussionNumber === void 0 ? {
|
|
229
267
|
...input,
|
|
230
268
|
issueNumber: created
|
|
231
|
-
} : input).split(" ");
|
|
269
|
+
} : input, context).split(" ");
|
|
232
270
|
const past = PAST_TENSE[verb.toLowerCase()];
|
|
233
271
|
return past ? [past, ...rest].join(" ") : "";
|
|
234
272
|
}
|
|
235
273
|
var github_default = defineDynamic(async (ctx) => {
|
|
236
|
-
const sessionOptions = buildSessionOptions();
|
|
274
|
+
const sessionOptions = buildSessionOptions(void 0, ctx.session.auth.current);
|
|
275
|
+
const { context } = sessionOptions;
|
|
237
276
|
const { preset, evaluation } = extension_default.config;
|
|
238
277
|
const messages = await ctx.messages();
|
|
239
278
|
const request = latestUserText(messages);
|
|
@@ -265,12 +304,12 @@ var github_default = defineDynamic(async (ctx) => {
|
|
|
265
304
|
inputSchema: entry.inputSchema,
|
|
266
305
|
approval: {
|
|
267
306
|
request: (approvalCtx) => runGithubEveApproval(name, request, approvalCtx),
|
|
268
|
-
prompt: ({ callId, input }) => approvalPrompt(describeGithubCall(name, entry.inputSchema, input), ctx.session.id, callId),
|
|
307
|
+
prompt: ({ callId, input }) => approvalPrompt(describeGithubCall(name, entry.inputSchema, input, context), ctx.session.id, callId),
|
|
269
308
|
...configuredResponse ? { response: (responseCtx) => runConfiguredApprovalResponse(name, configuredResponse, responseCtx) } : extension_default.config.approvers === "anyone" && { response: (responseCtx) => runGithubEveApprovalResponse(name, responseCtx) }
|
|
270
309
|
},
|
|
271
310
|
label: {
|
|
272
|
-
start: (input) => describeGithubCall(name, entry.inputSchema, input),
|
|
273
|
-
complete: (input, output) => describeGithubResult(name, entry.inputSchema, input, output)
|
|
311
|
+
start: (input) => describeGithubCall(name, entry.inputSchema, input, context),
|
|
312
|
+
complete: (input, output) => describeGithubResult(name, entry.inputSchema, input, output, context)
|
|
274
313
|
},
|
|
275
314
|
toModelOutput: (output) => runGithubEveToModelOutput(name, output),
|
|
276
315
|
...override?.outputSchema !== void 0 && { outputSchema: override.outputSchema },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-tools/eve-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "GitHub tools for eve, distributed as a mountable eve extension (https://eve.dev/docs/extensions)",
|
|
5
5
|
"author": "HugoRCD <hugo.richard@vercel.com>",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"zod": "^4.5.4",
|
|
49
|
-
"@github-tools/sdk": "1.
|
|
49
|
+
"@github-tools/sdk": "1.21.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@vercel/connect": ">=2.7.0",
|