@github-tools/sdk 1.21.0 → 1.22.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 (61) hide show
  1. package/README.md +9 -9
  2. package/dist/{approval-policy-CEMMPq92.mjs → approval-policy-C2rcAY77.mjs} +3 -4
  3. package/dist/{approval-policy-CEMMPq92.mjs.map → approval-policy-C2rcAY77.mjs.map} +1 -1
  4. package/dist/connect/eve.d.mts +2 -4
  5. package/dist/connect/eve.d.mts.map +1 -1
  6. package/dist/connect/eve.mjs +3 -4
  7. package/dist/connect/eve.mjs.map +1 -1
  8. package/dist/connect.d.mts +3 -9
  9. package/dist/connect.d.mts.map +1 -1
  10. package/dist/connect.mjs +3 -4
  11. package/dist/{cores-meFAMt2D.mjs → cores-CMUr_SEv.mjs} +3 -4
  12. package/dist/{cores-meFAMt2D.mjs.map → cores-CMUr_SEv.mjs.map} +1 -1
  13. package/dist/{dry-run-DXckOam2.d.mts → dry-run-BAbes7Mv.d.mts} +2 -28
  14. package/dist/dry-run-BAbes7Mv.d.mts.map +1 -0
  15. package/dist/{evaluation-DJHINyAu.mjs → evaluation-DskA4Lzk.mjs} +4 -6
  16. package/dist/{evaluation-DJHINyAu.mjs.map → evaluation-DskA4Lzk.mjs.map} +1 -1
  17. package/dist/{eve-runtime-B_CJE9JV.d.mts → eve-runtime-Bmdw1C-K.d.mts} +43 -15
  18. package/dist/eve-runtime-Bmdw1C-K.d.mts.map +1 -0
  19. package/dist/{eve-runtime-DPzMPCLt.mjs → eve-runtime-DM9yjOsG.mjs} +158 -15
  20. package/dist/eve-runtime-DM9yjOsG.mjs.map +1 -0
  21. package/dist/eve-runtime.d.mts +5 -5
  22. package/dist/eve-runtime.mjs +4 -4
  23. package/dist/eve.d.mts +67 -69
  24. package/dist/eve.d.mts.map +1 -1
  25. package/dist/eve.mjs +67 -68
  26. package/dist/eve.mjs.map +1 -1
  27. package/dist/{index-CzzrtCVj.d.mts → index-DgCZi9Ns.d.mts} +23 -54
  28. package/dist/index-DgCZi9Ns.d.mts.map +1 -0
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.mjs +3 -3
  31. package/dist/{interrupts-BSDPwdJ2.d.mts → interrupts-MwQ_v_PF.d.mts} +1 -3
  32. package/dist/interrupts-MwQ_v_PF.d.mts.map +1 -0
  33. package/dist/rolldown-runtime-D8jQpDG7.mjs +12 -0
  34. package/dist/{src-BlhrSieS.mjs → src-Djn_FFj1.mjs} +21 -38
  35. package/dist/{src-BlhrSieS.mjs.map → src-Djn_FFj1.mjs.map} +1 -1
  36. package/dist/tanstack/interrupts.d.mts +1 -1
  37. package/dist/tanstack/interrupts.mjs +1 -2
  38. package/dist/tanstack.d.mts +3 -20
  39. package/dist/tanstack.d.mts.map +1 -1
  40. package/dist/tanstack.mjs +8 -13
  41. package/dist/tanstack.mjs.map +1 -1
  42. package/dist/{token-BLps09gm.mjs → token-HpJhSRkl.mjs} +6 -10
  43. package/dist/{token-BLps09gm.mjs.map → token-HpJhSRkl.mjs.map} +1 -1
  44. package/dist/{types-Bln8U42J.d.mts → types-8KtcPTao.d.mts} +3 -7
  45. package/dist/types-8KtcPTao.d.mts.map +1 -0
  46. package/dist/{types-C7O2lwwz.d.mts → types-C-BIKmas.d.mts} +2 -4
  47. package/dist/types-C-BIKmas.d.mts.map +1 -0
  48. package/dist/workflow.d.mts +2 -4
  49. package/dist/workflow.d.mts.map +1 -1
  50. package/dist/workflow.mjs +3 -4
  51. package/dist/{write-tools-w-8tjnDQ.mjs → write-tools-BR29EOoM.mjs} +51 -88
  52. package/dist/write-tools-BR29EOoM.mjs.map +1 -0
  53. package/package.json +1 -1
  54. package/dist/dry-run-DXckOam2.d.mts.map +0 -1
  55. package/dist/eve-runtime-B_CJE9JV.d.mts.map +0 -1
  56. package/dist/eve-runtime-DPzMPCLt.mjs.map +0 -1
  57. package/dist/index-CzzrtCVj.d.mts.map +0 -1
  58. package/dist/interrupts-BSDPwdJ2.d.mts.map +0 -1
  59. package/dist/types-Bln8U42J.d.mts.map +0 -1
  60. package/dist/types-C7O2lwwz.d.mts.map +0 -1
  61. package/dist/write-tools-w-8tjnDQ.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"token-BLps09gm.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 { PRESET_TOOLS, 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/** 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 'statuses:write',\n 'administration:read',\n 'administration:write',\n 'security_events:read',\n 'vulnerability_alerts:read',\n 'secret_scanning_alerts:read',\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 * Vercel Connect scope strings mapped to each {@link GithubToolPreset}, derived\n * from the preset's tools so a tool added to a preset brings its scopes along.\n *\n * Scopes mirror GitHub App permissions (`contents`, `pull_requests`, `issues`,\n * `discussions`, `actions`, `checks`, `statuses`, `administration`, `metadata`,\n * and `security_events`, `vulnerability_alerts`, `secret_scanning_alerts` for the alert tools)\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 = (Object.keys(PRESET_TOOLS) as GithubToolPreset[]).reduce(\n (map, preset) => {\n map[preset] = connectGithubScopesForTools(PRESET_TOOLS[preset])\n return map\n },\n {} as Record<GithubToolPreset, readonly string[]>,\n)\n\n/** Default scopes when no preset is specified: every tool's scopes. */\nconst ALL_CONNECT_SCOPES = connectGithubScopesForTools(ALL_GITHUB_TOOL_NAMES)\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 { subject } = tokenParams\n const subjectId = subject.type === 'user' ? subject.id : subject.type ?? 'token'\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;;;;ACPA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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KACpD,OAAO,kBAAkB,uBAAuB;EAAE,QAAQ,MAAM;EAAS,OAAO;CAAM,CAAC;CAEzF,OAAO;AACT;;;;;AAMA,SAAS,gBAAgB,OAAmC;CAC1D,MAAM,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC;CACjC,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,CAAC;EAC/E,IAAI,UAAU,QAAQ,OAAO,WAAW,YAAY,EAAE,SAAS,SAAS,OAAO,KAAA;EAC/E,OAAO,OAAO,OAAO,QAAQ,WAAW,OAAO,MAAM,KAAA;CACvD,QACM;EACJ;CACF;AACF;;;;;;;;;AAUA,SAAS,sBAAsB,gBAA6D;CAC1F,MAAM,cAAc,gBAAgB,eAAe,QAAQ,IAAI;CAC/D,IAAI,aAAa;EACf,MAAM,MAAM,gBAAgB,WAAW;EACvC,IAAI,QAAQ,KAAA,KAAa,MAAM,OAAQ,KAAK,IAAI,GAC9C,MAAM,kBAAkB,mBAAmB,EAAE,4BAAW,IAAI,KAAK,MAAM,GAAI,EAAA,CAAE,YAAY,EAAE,CAAC;CAEhG;CACA,IAAI,CAAC,eAAe,CAAC,gBAAgB,OAAO,KAAA;CAC5C,OAAO;EACL,GAAG,cAAc,EAAE,YAAY,IAAI,CAAC;EACpC,GAAG;CACL;AACF"}
1
+ {"version":3,"file":"token-HpJhSRkl.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 { PRESET_TOOLS, 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/** 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 'statuses:write',\n 'administration:read',\n 'administration:write',\n 'security_events:read',\n 'vulnerability_alerts:read',\n 'secret_scanning_alerts:read',\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 * Vercel Connect scope strings mapped to each {@link GithubToolPreset}, derived\n * from the preset's tools so a tool added to a preset brings its scopes along.\n *\n * Scopes mirror GitHub App permissions (`contents`, `pull_requests`, `issues`,\n * `discussions`, `actions`, `checks`, `statuses`, `administration`, `metadata`,\n * and `security_events`, `vulnerability_alerts`, `secret_scanning_alerts` for the alert tools)\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 = (Object.keys(PRESET_TOOLS) as GithubToolPreset[]).reduce(\n (map, preset) => {\n map[preset] = connectGithubScopesForTools(PRESET_TOOLS[preset])\n return map\n },\n {} as Record<GithubToolPreset, readonly string[]>,\n)\n\n/** Default scopes when no preset is specified: every tool's scopes. */\nconst ALL_CONNECT_SCOPES = connectGithubScopesForTools(ALL_GITHUB_TOOL_NAMES)\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 { subject } = tokenParams\n const subjectId = subject.type === 'user' ? subject.id : subject.type ?? 'token'\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;;;ACPA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAa,sBAAsB,sBAAsB,QACtD,KAAK,SAAS;CACb,IAAI,QAAQ,oBAAoB,KAAK,CAAC;CACtC,OAAO;AACT,GACA,CAAC,CACH;AAEA,SAAS,YAAY,QAA+B;CAClD,OAAO,YAAY,QAAO,UAAS,OAAO,IAAI,KAAK,CAAC;AACtD;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,wBAAyB,OAAO,KAAK,YAAY,CAAC,CAAwB,QACpF,KAAK,WAAW;CACf,IAAI,UAAU,4BAA4B,aAAa,OAAO;CAC9D,OAAO;AACT,GACA,CAAC,CACH;;AAGA,MAAM,qBAAqB,4BAA4B,qBAAqB;;;;;AAM5E,SAAgB,6BACd,QACU;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sB,gBAA6D;CAC1F,MAAM,cAAc,gBAAgB,eAAe,QAAQ,IAAI;CAC/D,IAAI,aAAa;EACf,MAAM,MAAM,gBAAgB,WAAW;EACvC,IAAI,QAAQ,KAAA,KAAa,MAAM,OAAQ,KAAK,IAAI,GAC9C,MAAM,kBAAkB,mBAAmB,EAAE,4BAAW,IAAI,KAAK,MAAM,GAAI,EAAA,CAAE,YAAY,EAAE,CAAC;CAEhG;CACA,IAAI,CAAC,eAAe,CAAC,gBAAgB,OAAO,KAAA;CAC5C,OAAO;EACL,GAAG,cAAc,EAAE,YAAY,IAAI,CAAC;EACpC,GAAG;CACL;AACF"}
@@ -1,7 +1,6 @@
1
- import { M as GithubTokenCall, W as GithubToolName, i as GithubToolsBaseOptions, z as GithubToolPreset } from "./dry-run-DXckOam2.mjs";
2
- import { r as EveGithubToolsOptions } from "./types-C7O2lwwz.mjs";
1
+ import { B as GithubToolPreset, G as GithubToolName, M as GithubTokenCall, i as GithubToolsBaseOptions } from "./dry-run-BAbes7Mv.mjs";
2
+ import { r as EveGithubToolsOptions } from "./types-C-BIKmas.mjs";
3
3
  import { ConnectOptions, ConnectTokenParams } from "@vercel/connect";
4
- //#region src/connect/connector.d.ts
5
4
  /**
6
5
  * A Vercel Connect connector name, or a resolver that returns one.
7
6
  *
@@ -12,8 +11,6 @@ import { ConnectOptions, ConnectTokenParams } from "@vercel/connect";
12
11
  type GithubConnectorInput = string | (() => string | Promise<string>);
13
12
  /** Resolves a {@link GithubConnectorInput} to a connector name string. */
14
13
  declare function resolveGithubConnector(connector: GithubConnectorInput): Promise<string>;
15
- //#endregion
16
- //#region src/connect/types.d.ts
17
14
  /**
18
15
  * Token parameters for Vercel Connect GitHub connectors.
19
16
  * `subject` defaults to `{ type: 'app' }` — the project's GitHub App
@@ -58,6 +55,5 @@ type ConnectGithubTokenOptions = {
58
55
  params?: GithubConnectParamsInput;
59
56
  connectOptions?: ConnectOptions;
60
57
  };
61
- //#endregion
62
58
  export { GithubConnectParamsInput as a, resolveGithubConnector as c, GithubConnectParams as i, ConnectGithubTokenOptions as n, GithubConnectParamsResolver as o, ConnectGithubToolsOptions as r, GithubConnectorInput as s, ConnectGithubEveToolsOptions as t };
63
- //# sourceMappingURL=types-Bln8U42J.d.mts.map
59
+ //# sourceMappingURL=types-8KtcPTao.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-8KtcPTao.d.mts","names":[],"sources":["../src/connect/connector.ts","../src/connect/types.ts"],"mappings":";;;;;;;;;;KAOY,gDAAgD;;iBAGtC,uBAAuB,WAAW,uBAAuB;;;;;;;;KCInE,sBAAsB,KAAK;;;;;;;;EAQrC,UAAU;;EAEV;;;;;;;;KASU,+BACV,OAAO,oBACJ,sBAAsB,QAAQ;;KAGvB,2BAA2B,sBAAsB;KAEjD,4BAA4B;EACtC,SAAS,mBAAmB;EAC5B,UAAU;;KAGA,+BAA+B,KAAK;EAC9C,UAAU;;KAGA;EACV,SAAS,mBAAmB;;EAE5B,mBAAmB;;EAEnB,mBAAmB;EACnB,SAAS;EACT,iBAAiB"}
@@ -1,8 +1,7 @@
1
- import { G as GithubWriteToolName, I as GithubGuardrails, N as GithubTokenInput, W as GithubToolName, c as CommitIdentity, s as GithubToolsContext, t as GithubDryRunApproval, z as GithubToolPreset } from "./dry-run-DXckOam2.mjs";
1
+ import { B as GithubToolPreset, G as GithubToolName, K as GithubWriteToolName, L as GithubGuardrails, N as GithubTokenInput, c as CommitIdentity, s as GithubToolsContext, t as GithubDryRunApproval } from "./dry-run-BAbes7Mv.mjs";
2
2
  import { z } from "zod";
3
3
  import { ToolModelOutput } from "eve/tools";
4
4
  import { Approval } from "eve/tools/approval";
5
- //#region src/eve/types.d.ts
6
5
  /**
7
6
  * Approval value for eve tools.
8
7
  * - `true` / `'always'` → require approval on every call
@@ -78,6 +77,5 @@ type EveGithubToolsOptions = {
78
77
  context?: GithubToolsContext;
79
78
  };
80
79
  type EveToolFactoryOptions = Omit<EveGithubToolsOptions, 'preset' | 'include' | 'exclude'>;
81
- //#endregion
82
80
  export { EveToolOverrides as a, EveToolFactoryOptions as i, EveApprovalValue as n, EveGithubToolsOptions as r, EveApprovalConfig as t };
83
- //# sourceMappingURL=types-C7O2lwwz.d.mts.map
81
+ //# sourceMappingURL=types-C-BIKmas.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-C-BIKmas.d.mts","names":[],"sources":["../src/eve/types.ts"],"mappings":";;;;;;;;;;;;KAoBY,2DAKR;KAEQ,8BAER,QAAQ,OAAO,qBAAqB;KAE5B,mBAAmB,QAAQ,OAAO;EAC5C;EACA,WAAW;EACX,iBAAiB,oBAAoB,kBAAkB,QAAQ;;EAE/D,eAAe,EAAE;;KAGP;;EAEV,QAAQ;;;;;;EAMR,SAAS,mBAAmB;;;;;;EAM5B,UAAU;;;;;;EAMV,UAAU;;;;;;EAMV,kBAAkB;;;;;;EAMlB,YAAY;;EAEZ,SAAS;;EAET,YAAY;;EAEZ,YAAY;;;;;EAKZ,aAAa;;;;;EAKb;;EAEA,iBAAiB;;;;;EAKjB,UAAU;;KAGA,wBAAwB,KAAK"}
@@ -1,9 +1,8 @@
1
- import { B as PRESET_TOOLS, G as GithubWriteToolName, H as GITHUB_TOOL_NAMES, N as GithubTokenInput, O as GITHUB_WRITE_TOOLS, P as resolveGithubToken, R as CombinedPresetToolNames, V as PresetToolName, W as GithubToolName, a as GithubToolsForPreset, c as CommitIdentity, h as StaticApprovalConfig, i as GithubToolsBaseOptions, l as CommitToolOptions, m as ApprovalConfig, o as PickGithubTools, p as ToolOverrides, r as AllGithubTools, s as GithubToolsContext, z as GithubToolPreset } from "./dry-run-DXckOam2.mjs";
2
- import { Qt as createGithubAgent, Zt as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-CzzrtCVj.mjs";
1
+ import { B as GithubToolPreset, F as resolveGithubToken, G as GithubToolName, H as PresetToolName, K as GithubWriteToolName, N as GithubTokenInput, O as GITHUB_WRITE_TOOLS, U as GITHUB_TOOL_NAMES, V as PRESET_TOOLS, a as GithubToolsForPreset, c as CommitIdentity, h as StaticApprovalConfig, i as GithubToolsBaseOptions, l as CommitToolOptions, m as ApprovalConfig, o as PickGithubTools, p as ToolOverrides, r as AllGithubTools, s as GithubToolsContext, z as CombinedPresetToolNames } from "./dry-run-BAbes7Mv.mjs";
2
+ import { Qt as createGithubAgent, Zt as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-DgCZi9Ns.mjs";
3
3
  import { LanguageModel, Output, ToolSet } from "ai";
4
4
  import { WorkflowAgent, WorkflowAgentOptions, WorkflowAgentStreamOptions, WorkflowAgentStreamResult } from "@ai-sdk/workflow";
5
5
  import { Context } from "@ai-sdk/provider-utils";
6
- //#region src/workflow.d.ts
7
6
  type WorkflowGenerate<TTools extends ToolSet> = WorkflowAgent<TTools> extends {
8
7
  generate: infer Generate;
9
8
  } ? Generate : never;
@@ -152,6 +151,5 @@ export declare function createDurableGithubAgent<P extends GithubToolPreset>(opt
152
151
  export declare function createDurableGithubAgent<P extends readonly GithubToolPreset[]>(options: CreateDurableGithubAgentOptions & {
153
152
  preset: P;
154
153
  }): DurableGithubAgent<Pick<AllGithubTools, CombinedPresetToolNames<P>>>;
155
- //#endregion
156
154
  export { type AllGithubTools, type ApprovalConfig, type CombinedPresetToolNames, type CommitIdentity, type CommitToolOptions, type CreateGithubAgentOptions, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, type GithubTokenInput, type GithubToolName, type GithubToolPreset, type GithubTools, type GithubToolsContext, type GithubToolsForPreset, type GithubToolsOptions, type GithubWriteToolName, PRESET_TOOLS, type PickGithubTools, type PresetToolName, type ToolOverrides, createGithubAgent, createGithubTools, resolveGithubToken };
157
155
  //# sourceMappingURL=workflow.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;KAuBK,iBAAiB,eAAe,WAAW,cAAc;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c,WAAU;;;;;;;;;qBAUjJ,mBAAmB,eAAe,UAAU;UAC/C;EAEI,YAAA,SAAS,qBAAqB;;MAKtC,SAAS;;EAKb,OAAO,qBAAqB,SAAS,QAAQ,gBAAgB,wBAC3D,SAAS,2BAA2B,cAAc,SAAS,QAAQ,kBAClE,QAAQ,0BAA0B,cAAc;;;;;;;EAUnD,SAAS,iBACP,SAAS,kCAAkC;IAAY,SAAS,OAAO,OAAO;MAC7E,QAAQ,KAAK,iCAAiC;aAAgC,QAAQ;;;;;;;;;YAY/E,kCACV,KAAK;EACH,gBAAgB;;;;;EAKhB,QAAQ;;;;;;;;;EASR,SAAS,mBAAmB;;;;;;;;EAQ5B,kBAAkB;;;;;EAKlB,YAAY;;;;;EAKZ,aAAa;;EAEb;;;;;EAKA;;;;;EAKA;;;;EAIA,UAAU;;;;;EAKV,SAAS;;;;;EAKT,YAAY;;;;;EAKZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiCA,yBACd,SAAS;EAAoC;IAC5C,mBAAmB;wBACN,yBAAyB,UAAU,kBACjD,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,eAAe;wBAC1C,yBAAyB,mBAAmB,oBAC1D,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,wBAAwB"}
package/dist/workflow.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { S as resolveGithubToken, Za as githubToolsErrors, g as GITHUB_TOOL_NAMES, n as resolveInstructions, t as GITHUB_WRITE_TOOLS, v as PRESET_TOOLS } from "./write-tools-w-8tjnDQ.mjs";
2
- import { r as createGithubAgent, t as createGithubTools } from "./src-BlhrSieS.mjs";
1
+ import { r as createGithubAgent, t as createGithubTools } from "./src-Djn_FFj1.mjs";
2
+ import { S as resolveGithubToken, Za as githubToolsErrors, g as GITHUB_TOOL_NAMES, n as resolveInstructions, t as GITHUB_WRITE_TOOLS, v as PRESET_TOOLS } from "./write-tools-BR29EOoM.mjs";
3
3
  import { WorkflowAgent } from "@ai-sdk/workflow";
4
- //#region src/workflow.ts
4
+ // src/workflow.ts
5
5
  /**
6
6
  * A GitHub agent built on {@link WorkflowAgent}. Call both methods from a `"use workflow"`
7
7
  * function: each model call and each tool call runs as its own retriable workflow step, and
@@ -59,7 +59,6 @@ function createDurableGithubAgent({ model, token, preset, requireApproval, overr
59
59
  })
60
60
  });
61
61
  }
62
- //#endregion
63
62
  export { DurableGithubAgent, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, PRESET_TOOLS, createDurableGithubAgent, createGithubAgent, createGithubTools, resolveGithubToken };
64
63
 
65
64
  //# sourceMappingURL=workflow.mjs.map