@github-tools/sdk 1.16.1 → 1.18.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.
Files changed (60) hide show
  1. package/README.md +51 -15
  2. package/dist/connect/eve.d.mts +2 -2
  3. package/dist/connect/eve.d.mts.map +1 -1
  4. package/dist/connect/eve.mjs +1 -1
  5. package/dist/connect.d.mts +12 -4
  6. package/dist/connect.d.mts.map +1 -1
  7. package/dist/connect.mjs +2 -2
  8. package/dist/cores-BeLZwcde.mjs +269 -0
  9. package/dist/cores-BeLZwcde.mjs.map +1 -0
  10. package/dist/evaluation-f-2QwBid.mjs +210 -0
  11. package/dist/evaluation-f-2QwBid.mjs.map +1 -0
  12. package/dist/{eve-runtime-BnWUzXdV.d.mts → eve-runtime-DNQrQZ36.d.mts} +5 -5
  13. package/dist/{eve-runtime-BnWUzXdV.d.mts.map → eve-runtime-DNQrQZ36.d.mts.map} +1 -1
  14. package/dist/{eve-runtime-Cfyy1tzp.mjs → eve-runtime-DnhM9Vog.mjs} +14 -11
  15. package/dist/eve-runtime-DnhM9Vog.mjs.map +1 -0
  16. package/dist/eve-runtime.d.mts +5 -5
  17. package/dist/eve-runtime.mjs +4 -3
  18. package/dist/eve.d.mts +4 -4
  19. package/dist/eve.d.mts.map +1 -1
  20. package/dist/eve.mjs +2 -2
  21. package/dist/{index-JH3DVh1R.d.mts → index-DkZvveZP.d.mts} +337 -11
  22. package/dist/index-DkZvveZP.d.mts.map +1 -0
  23. package/dist/index.d.mts +3 -3
  24. package/dist/index.mjs +3 -3
  25. package/dist/instructions-BuypoY0x.mjs +148 -0
  26. package/dist/instructions-BuypoY0x.mjs.map +1 -0
  27. package/dist/interrupts-BSDPwdJ2.d.mts +60 -0
  28. package/dist/interrupts-BSDPwdJ2.d.mts.map +1 -0
  29. package/dist/{src-C54blWpT.mjs → src-Bx5p1Unc.mjs} +130 -232
  30. package/dist/src-Bx5p1Unc.mjs.map +1 -0
  31. package/dist/tanstack/interrupts.d.mts +2 -0
  32. package/dist/tanstack/interrupts.mjs +17 -0
  33. package/dist/tanstack/interrupts.mjs.map +1 -0
  34. package/dist/tanstack.d.mts +4971 -0
  35. package/dist/tanstack.d.mts.map +1 -0
  36. package/dist/tanstack.mjs +465 -0
  37. package/dist/tanstack.mjs.map +1 -0
  38. package/dist/{token-Iop2lapd.mjs → token-BOLrrbTS.mjs} +65 -10
  39. package/dist/token-BOLrrbTS.mjs.map +1 -0
  40. package/dist/tool-types-CrC80SIL.d.mts +1573 -0
  41. package/dist/tool-types-CrC80SIL.d.mts.map +1 -0
  42. package/dist/{types-ve9shBaf.d.mts → types-BmwOpI5-.d.mts} +19 -8
  43. package/dist/types-BmwOpI5-.d.mts.map +1 -0
  44. package/dist/{types-BKXTeCqT.d.mts → types-CPAsEMzx.d.mts} +2 -2
  45. package/dist/{types-BKXTeCqT.d.mts.map → types-CPAsEMzx.d.mts.map} +1 -1
  46. package/dist/workflow.d.mts +7 -5
  47. package/dist/workflow.d.mts.map +1 -1
  48. package/dist/workflow.mjs +3 -2
  49. package/dist/workflow.mjs.map +1 -1
  50. package/dist/{write-tools-BvuWAzwo.mjs → write-tools-BaoTUCg7.mjs} +2293 -2558
  51. package/dist/write-tools-BaoTUCg7.mjs.map +1 -0
  52. package/package.json +32 -16
  53. package/dist/eve-runtime-Cfyy1tzp.mjs.map +0 -1
  54. package/dist/index-JH3DVh1R.d.mts.map +0 -1
  55. package/dist/src-C54blWpT.mjs.map +0 -1
  56. package/dist/token-Iop2lapd.mjs.map +0 -1
  57. package/dist/tool-types-BsfalcyC.d.mts +0 -4163
  58. package/dist/tool-types-BsfalcyC.d.mts.map +0 -1
  59. package/dist/types-ve9shBaf.d.mts.map +0 -1
  60. package/dist/write-tools-BvuWAzwo.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { i as GITHUB_TOOL_CATALOG, ia as githubToolsErrors, r as ALL_GITHUB_TOOL_NAMES, s as resolvePresetTools } from "./write-tools-BvuWAzwo.mjs";
1
+ import { b as GITHUB_TOOL_CATALOG, h as resolvePresetTools, oa as githubToolsErrors, y as ALL_GITHUB_TOOL_NAMES } from "./write-tools-BaoTUCg7.mjs";
2
2
  import { ConnectError, ConnectorInstallationRequiredError, UserAuthorizationRequiredError, getToken } from "@vercel/connect";
3
3
  //#region src/connect/connector.ts
4
4
  /** Resolves a {@link GithubConnectorInput} to a connector name string. */
@@ -220,24 +220,75 @@ function buildConnectTokenParams(scopes, params) {
220
220
  * `connector` may be a static name or a resolver function — e.g. to pick a
221
221
  * different connector per environment (production vs. preview) or tenant.
222
222
  * It's re-resolved on every call, alongside the token itself.
223
+ *
224
+ * App-subject tokens are minted for the GitHub App installation that owns the
225
+ * call's target repository, so one App installed on several accounts works
226
+ * with no configuration; an explicit `installationId`, `authorizationDetails`
227
+ * or `repositories` in `params` pins the installation instead. `params` may
228
+ * also be a resolver called with the tool call on every token request.
229
+ * Connect caches tokens per `(connector, params)`, so repeated calls on the
230
+ * same repository reuse one token.
223
231
  */
224
232
  function connectGithubToken(connector, options = {}) {
225
233
  const { connectOptions } = options;
226
- const tokenParams = resolveGithubConnectTokenParams(options);
227
- return async () => {
234
+ const tokenParamsFor = createTokenParamsResolver(options);
235
+ return async (call) => {
236
+ const tokenParams = await tokenParamsFor(call);
228
237
  try {
229
238
  return await getToken(await resolveGithubConnector(connector), tokenParams, resolveConnectOptions(connectOptions));
230
239
  } catch (error) {
231
- throw toConnectCatalogError(error, tokenParams);
240
+ throw toConnectCatalogError(error, tokenParams, call);
232
241
  }
233
242
  };
234
243
  }
235
244
  /**
245
+ * Static and resolved params go through the same repository targeting and
246
+ * scope derivation, so per-call params keep the preset/include/exclude scope
247
+ * narrowing unless they set `scopes` explicitly.
248
+ */
249
+ function createTokenParamsResolver(options) {
250
+ const { params } = options;
251
+ return async (call) => {
252
+ const resolved = typeof params === "function" ? await params(call) : params;
253
+ return resolveGithubConnectTokenParams({
254
+ ...options,
255
+ params: withRepositoryTarget(resolved, call)
256
+ });
257
+ };
258
+ }
259
+ /**
260
+ * Target the installation that owns the call's repository. Only app subjects
261
+ * are installation-scoped, and an explicit installation choice in `params`
262
+ * always wins.
263
+ */
264
+ function withRepositoryTarget(params, call) {
265
+ if (!call?.owner || !call.repo) return params;
266
+ if (params?.subject !== void 0 && params.subject.type !== "app") return params;
267
+ if (params?.installationId !== void 0 || params?.authorizationDetails !== void 0 || params?.repositories !== void 0) return params;
268
+ return {
269
+ ...params,
270
+ authorizationDetails: [{
271
+ type: "github_app_installation",
272
+ org: call.owner,
273
+ repositories: [call.repo]
274
+ }]
275
+ };
276
+ }
277
+ /** Account Connect selects the installation for: the detail's `org`, else the owner of a qualified repository. */
278
+ function installationTarget(tokenParams) {
279
+ for (const detail of tokenParams.authorizationDetails ?? []) {
280
+ if (detail.type !== "github_app_installation") continue;
281
+ if (typeof detail.org === "string") return detail.org;
282
+ const qualified = [detail.repositories].flat().find((repository) => typeof repository === "string" && repository.includes("/"));
283
+ if (qualified) return qualified.split("/")[0];
284
+ }
285
+ }
286
+ /**
236
287
  * Map @vercel/connect failures to catalog errors so models get the actual
237
288
  * cause (process identity, missing user connection, missing installation)
238
289
  * instead of a bare "Not authorized" they misread as GitHub permissions.
239
290
  */
240
- function toConnectCatalogError(error, tokenParams) {
291
+ function toConnectCatalogError(error, tokenParams, call) {
241
292
  if (error instanceof UserAuthorizationRequiredError) {
242
293
  const subjectId = tokenParams.subject.type === "user" ? tokenParams.subject.id : tokenParams.subject.type;
243
294
  return githubToolsErrors.CONNECT_USER_NOT_CONNECTED({
@@ -245,10 +296,14 @@ function toConnectCatalogError(error, tokenParams) {
245
296
  cause: error
246
297
  });
247
298
  }
248
- if (error instanceof ConnectorInstallationRequiredError) return githubToolsErrors.CONNECT_INSTALLATION_REQUIRED({
249
- detail: error.message,
250
- cause: error
251
- });
299
+ if (error instanceof ConnectorInstallationRequiredError) {
300
+ const owner = installationTarget(tokenParams) ?? call?.owner;
301
+ return githubToolsErrors.CONNECT_INSTALLATION_REQUIRED({
302
+ detail: error.message,
303
+ ...owner && { owner },
304
+ cause: error
305
+ });
306
+ }
252
307
  if (error instanceof ConnectError && error.status === 403) return githubToolsErrors.CONNECT_NOT_AUTHORIZED({
253
308
  detail: error.message,
254
309
  cause: error
@@ -293,4 +348,4 @@ function resolveConnectOptions(connectOptions) {
293
348
  //#endregion
294
349
  export { connectGithubScopesForSelection as a, connectGithubScopesForPreset as i, PRESET_CONNECT_SCOPES as n, connectGithubScopesForTools as o, TOOL_CONNECT_SCOPES as r, resolveGithubConnector as s, connectGithubToken as t };
295
350
 
296
- //# sourceMappingURL=token-Iop2lapd.mjs.map
351
+ //# sourceMappingURL=token-BOLrrbTS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-BOLrrbTS.mjs","names":[],"sources":["../src/connect/connector.ts","../src/connect/scopes.ts","../src/connect/params.ts","../src/connect/token.ts"],"sourcesContent":["/**\n * A Vercel Connect connector name, or a resolver that returns one.\n *\n * Use a function to pick the connector dynamically — e.g. a different\n * connector per environment (`production` vs. `preview`) or per tenant.\n * It's resolved lazily, on every token request, alongside the token itself.\n */\nexport type GithubConnectorInput = string | (() => string | Promise<string>)\n\n/** Resolves a {@link GithubConnectorInput} to a connector name string. */\nexport async function resolveGithubConnector(connector: GithubConnectorInput): Promise<string> {\n return typeof connector === 'function' ? await connector() : connector\n}\n","import { resolvePresetTools, type GithubToolPreset } from '../core/presets'\nimport { GITHUB_TOOL_CATALOG } from '../core/catalog'\nimport { ALL_GITHUB_TOOL_NAMES, type GithubToolName } from '../core/tool-names'\n\n/**\n * Vercel Connect scope strings mapped to each {@link GithubToolPreset}.\n *\n * Scopes mirror GitHub App permissions (`contents`, `pull_requests`, `issues`,\n * `discussions`, `actions`, `checks`, `statuses`, `administration`, `metadata`)\n * and must cover every read/write family a preset's tools touch, not just its\n * primary domain. Release tools fall under the `contents` permission on GitHub\n * Apps, and reaction tools under `issues`, so neither needs a scope of its own.\n *\n * Gist tools in `repo-explorer` and `maintainer` are intentionally left\n * unscoped: the Gists API only accepts GitHub App *user* access tokens, never\n * installation tokens, and Connect mints `subject: { type: 'app' }`\n * installation tokens by default. Gist calls made with an app-subject token\n * 403 regardless of requested scopes — use a `{ type: 'user' }` subject or a\n * fine-grained PAT with the \"Gists\" account permission for those tools instead.\n *\n * Notification tools in `maintainer` and `notification-inbox` are unscoped for\n * the same reason: `notifications` is an account-level GitHub App permission\n * that only applies to user access tokens, so `listNotifications` /\n * `markNotificationRead` need a PAT with the \"Notifications\" account permission.\n */\nexport const PRESET_CONNECT_SCOPES = {\n 'repo-explorer': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'issues:read',\n 'discussions:read',\n 'actions:read',\n 'checks:read',\n 'statuses:read',\n ],\n 'code-review': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'pull_requests:write',\n 'checks:read',\n 'statuses:read',\n ],\n 'issue-triage': [\n 'contents:read',\n 'metadata:read',\n 'issues:read',\n 'issues:write',\n ],\n 'ci-ops': [\n 'contents:read',\n 'metadata:read',\n 'actions:read',\n 'actions:write',\n 'checks:read',\n 'statuses:read',\n ],\n 'security-audit': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'issues:read',\n 'issues:write',\n 'actions:read',\n 'checks:read',\n 'statuses:read',\n ],\n 'release-manager': [\n 'contents:read',\n 'contents:write',\n 'metadata:read',\n 'pull_requests:read',\n 'actions:read',\n 'actions:write',\n ],\n 'discussion-moderator': [\n 'contents:read',\n 'metadata:read',\n 'issues:read',\n 'issues:write',\n 'discussions:read',\n 'discussions:write',\n ],\n 'notification-inbox': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'issues:read',\n ],\n 'pr-author': [\n 'contents:read',\n 'contents:write',\n 'metadata:read',\n 'pull_requests:read',\n 'pull_requests:write',\n ],\n 'maintainer': [\n 'contents:read',\n 'contents:write',\n 'metadata:read',\n 'pull_requests:read',\n 'pull_requests:write',\n 'issues:read',\n 'issues:write',\n 'discussions:read',\n 'discussions:write',\n 'actions:read',\n 'actions:write',\n 'checks:read',\n 'statuses:read',\n 'administration:read',\n 'administration:write',\n ],\n} as const satisfies Record<GithubToolPreset, readonly string[]>\n\n/** Default scopes when no preset is specified — union of all preset scopes. */\nconst ALL_CONNECT_SCOPES = [\n ...new Set(Object.values(PRESET_CONNECT_SCOPES).flat()),\n] as string[]\n\n/** Stable scope order for tool-derived unions (tests + Connect payloads). */\nconst SCOPE_ORDER = [\n 'contents:read',\n 'contents:write',\n 'metadata:read',\n 'pull_requests:read',\n 'pull_requests:write',\n 'issues:read',\n 'issues:write',\n 'discussions:read',\n 'discussions:write',\n 'actions:read',\n 'actions:write',\n 'checks:read',\n 'statuses:read',\n 'administration:read',\n 'administration:write',\n] as const\n\n/**\n * Per-tool Connect scopes, derived from `GITHUB_TOOL_CATALOG`. Empty arrays are\n * intentional for gist and notification tools (installation tokens cannot\n * satisfy those APIs).\n */\nexport const TOOL_CONNECT_SCOPES = ALL_GITHUB_TOOL_NAMES.reduce(\n (map, name) => {\n map[name] = GITHUB_TOOL_CATALOG[name].connectScopes\n return map\n },\n {} as Record<GithubToolName, readonly string[]>,\n)\n\nfunction orderScopes(scopes: Set<string>): string[] {\n return SCOPE_ORDER.filter(scope => scopes.has(scope))\n}\n\n/**\n * Returns Vercel Connect scopes for a preset or combined presets.\n * Without a preset, returns the union of all preset scopes (full tool set).\n */\nexport function connectGithubScopesForPreset(\n preset?: GithubToolPreset | GithubToolPreset[],\n): string[] {\n if (!preset) return [...ALL_CONNECT_SCOPES]\n\n const presets = Array.isArray(preset) ? preset : [preset]\n return [\n ...new Set(presets.flatMap(p => PRESET_CONNECT_SCOPES[p])),\n ]\n}\n\n/**\n * Returns Connect scopes covering exactly the given tools.\n * Always includes `metadata:read`. Gist and notification tools contribute nothing.\n */\nexport function connectGithubScopesForTools(names: readonly GithubToolName[]): string[] {\n const scopes = new Set<string>(['metadata:read'])\n for (const name of names) {\n for (const scope of TOOL_CONNECT_SCOPES[name]) {\n scopes.add(scope)\n }\n }\n return orderScopes(scopes)\n}\n\nexport type ConnectScopeSelection = {\n preset?: GithubToolPreset | GithubToolPreset[]\n include?: readonly GithubToolName[]\n exclude?: readonly GithubToolName[]\n}\n\nfunction resolveSelectedToolNames({\n preset,\n include,\n exclude,\n}: ConnectScopeSelection): GithubToolName[] {\n const presetAllowed = preset ? resolvePresetTools(preset) : null\n const includeAllowed = include ? new Set(include) : null\n const excluded = exclude ? new Set(exclude) : null\n\n const allowed = presetAllowed && includeAllowed\n ? new Set([...presetAllowed, ...includeAllowed])\n : presetAllowed ?? includeAllowed\n\n return ALL_GITHUB_TOOL_NAMES.filter(\n name => (!allowed || allowed.has(name)) && !excluded?.has(name),\n )\n}\n\n/**\n * Resolves Connect scopes for the effective tool set.\n *\n * - No `include` / `exclude`: same as {@link connectGithubScopesForPreset}\n * (omitted preset → full union, including `administration:write`).\n * - With `include` and/or `exclude`: scopes are derived from the resolved tools\n * so a hand-picked `include` list does not mint the full admin surface.\n */\nexport function connectGithubScopesForSelection(selection: ConnectScopeSelection = {}): string[] {\n const { preset, include, exclude } = selection\n if (!include && !exclude) {\n return connectGithubScopesForPreset(preset)\n }\n return connectGithubScopesForTools(resolveSelectedToolNames(selection))\n}\n","import type { ConnectTokenParams } from '@vercel/connect'\nimport { connectGithubScopesForSelection } from './scopes'\nimport type { ConnectGithubTokenOptions, GithubConnectParams } from './types'\n\nexport function resolveGithubConnectTokenParams(\n options: Omit<ConnectGithubTokenOptions, 'params'> & { params?: GithubConnectParams } = {},\n): ConnectTokenParams {\n const { preset, include, exclude, params } = options\n const scopes = params?.scopes ?? connectGithubScopesForSelection({ preset, include, exclude })\n return buildConnectTokenParams(scopes, params)\n}\n\nfunction buildConnectTokenParams(\n scopes: string[],\n params?: GithubConnectParams,\n): ConnectTokenParams {\n const { repositories, subject, ...rest } = params ?? {}\n\n const authorizationDetails = rest.authorizationDetails\n ?? (repositories?.length\n ? [{ type: 'github_app_installation' as const, repositories }]\n : undefined)\n\n return {\n subject: subject ?? { type: 'app' },\n ...rest,\n scopes,\n ...(authorizationDetails && { authorizationDetails }),\n }\n}\n","import {\n ConnectError,\n ConnectorInstallationRequiredError,\n getToken,\n UserAuthorizationRequiredError,\n type ConnectOptions,\n type ConnectTokenParams,\n} from '@vercel/connect'\nimport { githubToolsErrors } from '../core/errors'\nimport type { GithubTokenCall, GithubTokenInput } from '../core/token'\nimport { resolveGithubConnector, type GithubConnectorInput } from './connector'\nimport { resolveGithubConnectTokenParams } from './params'\nimport type { ConnectGithubTokenOptions, GithubConnectParams } from './types'\n\n/**\n * Returns a lazy GitHub token provider backed by a Vercel Connect connector.\n * Scopes are derived from `preset`, or from the resolved `include`/`exclude`\n * tool set when those are set, unless overridden in `params.scopes`.\n *\n * `connector` may be a static name or a resolver function — e.g. to pick a\n * different connector per environment (production vs. preview) or tenant.\n * It's re-resolved on every call, alongside the token itself.\n *\n * App-subject tokens are minted for the GitHub App installation that owns the\n * call's target repository, so one App installed on several accounts works\n * with no configuration; an explicit `installationId`, `authorizationDetails`\n * or `repositories` in `params` pins the installation instead. `params` may\n * also be a resolver called with the tool call on every token request.\n * Connect caches tokens per `(connector, params)`, so repeated calls on the\n * same repository reuse one token.\n */\nexport function connectGithubToken(\n connector: GithubConnectorInput,\n options: ConnectGithubTokenOptions = {},\n): GithubTokenInput {\n const { connectOptions } = options\n const tokenParamsFor = createTokenParamsResolver(options)\n\n return async (call) => {\n const tokenParams = await tokenParamsFor(call)\n try {\n return await getToken(\n await resolveGithubConnector(connector),\n tokenParams,\n resolveConnectOptions(connectOptions),\n )\n }\n catch (error) {\n throw toConnectCatalogError(error, tokenParams, call)\n }\n }\n}\n\n/**\n * Static and resolved params go through the same repository targeting and\n * scope derivation, so per-call params keep the preset/include/exclude scope\n * narrowing unless they set `scopes` explicitly.\n */\nfunction createTokenParamsResolver(\n options: ConnectGithubTokenOptions,\n): (call?: GithubTokenCall) => Promise<ConnectTokenParams> {\n const { params } = options\n return async (call) => {\n const resolved = typeof params === 'function' ? await params(call) : params\n return resolveGithubConnectTokenParams({ ...options, params: withRepositoryTarget(resolved, call) })\n }\n}\n\n/**\n * Target the installation that owns the call's repository. Only app subjects\n * are installation-scoped, and an explicit installation choice in `params`\n * always wins.\n */\nexport function withRepositoryTarget(params: GithubConnectParams | undefined, call: GithubTokenCall | undefined): GithubConnectParams | undefined {\n if (!call?.owner || !call.repo) return params\n if (params?.subject !== undefined && params.subject.type !== 'app') return params\n if (params?.installationId !== undefined || params?.authorizationDetails !== undefined || params?.repositories !== undefined) return params\n return {\n ...params,\n authorizationDetails: [{ type: 'github_app_installation', org: call.owner, repositories: [call.repo] }],\n }\n}\n\n/** Account Connect selects the installation for: the detail's `org`, else the owner of a qualified repository. */\nfunction installationTarget(tokenParams: ConnectTokenParams): string | undefined {\n for (const detail of tokenParams.authorizationDetails ?? []) {\n if (detail.type !== 'github_app_installation') continue\n if (typeof detail.org === 'string') return detail.org\n const repositories = [detail.repositories].flat()\n const qualified = repositories.find((repository): repository is string => typeof repository === 'string' && repository.includes('/'))\n if (qualified) return qualified.split('/')[0]\n }\n return undefined\n}\n\n/**\n * Map @vercel/connect failures to catalog errors so models get the actual\n * cause (process identity, missing user connection, missing installation)\n * instead of a bare \"Not authorized\" they misread as GitHub permissions.\n */\nfunction toConnectCatalogError(error: unknown, tokenParams: ConnectTokenParams, call: GithubTokenCall | undefined): unknown {\n if (error instanceof UserAuthorizationRequiredError) {\n const subjectId = tokenParams.subject.type === 'user' ? tokenParams.subject.id : tokenParams.subject.type\n return githubToolsErrors.CONNECT_USER_NOT_CONNECTED({ subjectId, cause: error })\n }\n if (error instanceof ConnectorInstallationRequiredError) {\n const owner = installationTarget(tokenParams) ?? call?.owner\n return githubToolsErrors.CONNECT_INSTALLATION_REQUIRED({ detail: error.message, ...(owner && { owner }), cause: error })\n }\n if (error instanceof ConnectError && error.status === 403) {\n return githubToolsErrors.CONNECT_NOT_AUTHORIZED({ detail: error.message, cause: error })\n }\n return error\n}\n\n/**\n * Best-effort JWT `exp` claim, in epoch seconds. Returns undefined for\n * malformed tokens — Connect then rejects them with its own error.\n */\nfunction oidcTokenExpiry(token: string): number | undefined {\n const payload = token.split('.')[1]\n if (!payload) return undefined\n try {\n const claims: unknown = JSON.parse(Buffer.from(payload, 'base64url').toString())\n if (claims == null || typeof claims !== 'object' || !('exp' in claims)) return undefined\n return typeof claims.exp === 'number' ? claims.exp : undefined\n }\n catch {\n return undefined\n }\n}\n\n/**\n * Prefer an explicit `vercelToken`, then `VERCEL_OIDC_TOKEN` from the environment.\n * Passing the env token into `getToken` skips `@vercel/oidc`'s project-root walk,\n * which fails inside eve/workflow snapshots that have no `.vercel` directory.\n *\n * Pinning also disables refresh, so an expired token fails loudly here instead\n * of surfacing as an opaque Connect 403 the model misreads as GitHub permissions.\n */\nfunction resolveConnectOptions(connectOptions?: ConnectOptions): ConnectOptions | undefined {\n const vercelToken = connectOptions?.vercelToken ?? process.env.VERCEL_OIDC_TOKEN\n if (vercelToken) {\n const exp = oidcTokenExpiry(vercelToken)\n if (exp !== undefined && exp * 1000 <= Date.now()) {\n throw githubToolsErrors.OIDC_TOKEN_EXPIRED({ expiredAt: new Date(exp * 1000).toISOString() })\n }\n }\n if (!vercelToken && !connectOptions) return undefined\n return {\n ...vercelToken ? { vercelToken } : {},\n ...connectOptions,\n }\n}\n\nexport type { ConnectOptions }\n"],"mappings":";;;;AAUA,eAAsB,uBAAuB,WAAkD;CAC7F,OAAO,OAAO,cAAc,aAAa,MAAM,UAAU,IAAI;AAC/D;;;;;;;;;;;;;;;;;;;;;;;;ACaA,MAAa,wBAAwB;CACnC,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;CACF;CACA,gBAAgB;EACd;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;E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