@github-tools/sdk 1.22.0 → 1.23.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/README.md +1 -1
- package/dist/{approval-policy-C2rcAY77.mjs → approval-policy-DJlImo7H.mjs} +2 -2
- package/dist/{approval-policy-C2rcAY77.mjs.map → approval-policy-DJlImo7H.mjs.map} +1 -1
- package/dist/connect/eve.mjs +1 -1
- package/dist/connect.d.mts +1 -1
- package/dist/connect.mjs +2 -2
- package/dist/{cores-CMUr_SEv.mjs → cores-H6HKlwFZ.mjs} +2 -2
- package/dist/{cores-CMUr_SEv.mjs.map → cores-H6HKlwFZ.mjs.map} +1 -1
- package/dist/{evaluation-DskA4Lzk.mjs → evaluation-Dlf-571x.mjs} +2 -2
- package/dist/{evaluation-DskA4Lzk.mjs.map → evaluation-Dlf-571x.mjs.map} +1 -1
- package/dist/{eve-runtime-Bmdw1C-K.d.mts → eve-runtime-CoBSN8nF.d.mts} +26 -3
- package/dist/eve-runtime-CoBSN8nF.d.mts.map +1 -0
- package/dist/{eve-runtime-DM9yjOsG.mjs → eve-runtime-DEdQqbCs.mjs} +61 -17
- package/dist/eve-runtime-DEdQqbCs.mjs.map +1 -0
- package/dist/eve-runtime.d.mts +3 -3
- package/dist/eve-runtime.mjs +4 -4
- package/dist/eve.d.mts +1 -1
- package/dist/eve.mjs +2 -2
- package/dist/{index-DgCZi9Ns.d.mts → index-v5n5OLs7.d.mts} +7 -1
- package/dist/{index-DgCZi9Ns.d.mts.map → index-v5n5OLs7.d.mts.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{src-Djn_FFj1.mjs → src-BRZIY_PZ.mjs} +4 -4
- package/dist/{src-Djn_FFj1.mjs.map → src-BRZIY_PZ.mjs.map} +1 -1
- package/dist/tanstack.d.mts +1 -1
- package/dist/tanstack.mjs +3 -3
- package/dist/{token-HpJhSRkl.mjs → token-DZu9uttC.mjs} +2 -2
- package/dist/{token-HpJhSRkl.mjs.map → token-DZu9uttC.mjs.map} +1 -1
- package/dist/workflow.d.mts +1 -1
- package/dist/workflow.mjs +2 -2
- package/dist/{write-tools-BR29EOoM.mjs → write-tools-C-962T9O.mjs} +7 -1
- package/dist/write-tools-C-962T9O.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/eve-runtime-Bmdw1C-K.d.mts.map +0 -1
- package/dist/eve-runtime-DM9yjOsG.mjs.map +0 -1
- package/dist/write-tools-BR29EOoM.mjs.map +0 -1
package/dist/tanstack.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as DEFAULT_EVALUATION_MODEL, B as GithubToolPreset, G as GithubToolName, H as PresetToolName, K as GithubWriteToolName, L as GithubGuardrails, M as GithubTokenCall, N as GithubTokenInput, O as GITHUB_WRITE_TOOLS, U as GITHUB_TOOL_NAMES, V as PRESET_TOOLS, W as GITHUB_TOOL_CATALOG, c as CommitIdentity, d as Octokit, g as ToolApprovalMode, j as RoutablePreset, k as AUTO_APPROVAL_TOOLS, m as ApprovalConfig, n as GithubDryRunResult, s as GithubToolsContext } from "./dry-run-BAbes7Mv.mjs";
|
|
2
2
|
import { t as githubToolApproval } from "./interrupts-MwQ_v_PF.mjs";
|
|
3
|
-
import "./index-
|
|
3
|
+
import "./index-v5n5OLs7.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { AnyTextAdapter, ChatMiddleware, ChatStream, EvaluateAdapter, ModelMessage, ServerTool, Tool, chat } from "@tanstack/ai";
|
|
6
6
|
type DetailLevel = 'summary' | 'full';
|
package/dist/tanstack.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $a as stripRateLimit, C as withGithubGuardrails, E as isGithubWriteToolName, T as GITHUB_TOOL_CATALOG, Za as githubToolsErrors, c as AUTO_APPROVAL_TOOLS, d as PRESET_PURPOSES, f as RISK_QUESTION, g as GITHUB_TOOL_NAMES, h as requiresApproval, i as dryRunWrite, l as DEFAULT_EVALUATION_MODEL, m as rankPresets, n as resolveInstructions, o as mergeContextArgs, p as conversationState, s as softenContextSchema, t as GITHUB_WRITE_TOOLS, u as INTENT_QUESTION, v as PRESET_TOOLS, w as ALL_GITHUB_TOOL_NAMES, x as githubTokenCall, y as resolvePresetTools } from "./write-tools-
|
|
2
|
-
import { t as GITHUB_TOOL_CORES } from "./cores-
|
|
3
|
-
import { t as resolveApprovalMode } from "./approval-policy-
|
|
1
|
+
import { $a as stripRateLimit, C as withGithubGuardrails, E as isGithubWriteToolName, T as GITHUB_TOOL_CATALOG, Za as githubToolsErrors, c as AUTO_APPROVAL_TOOLS, d as PRESET_PURPOSES, f as RISK_QUESTION, g as GITHUB_TOOL_NAMES, h as requiresApproval, i as dryRunWrite, l as DEFAULT_EVALUATION_MODEL, m as rankPresets, n as resolveInstructions, o as mergeContextArgs, p as conversationState, s as softenContextSchema, t as GITHUB_WRITE_TOOLS, u as INTENT_QUESTION, v as PRESET_TOOLS, w as ALL_GITHUB_TOOL_NAMES, x as githubTokenCall, y as resolvePresetTools } from "./write-tools-C-962T9O.mjs";
|
|
2
|
+
import { t as GITHUB_TOOL_CORES } from "./cores-H6HKlwFZ.mjs";
|
|
3
|
+
import { t as resolveApprovalMode } from "./approval-policy-DJlImo7H.mjs";
|
|
4
4
|
import { githubToolApproval } from "./tanstack/interrupts.mjs";
|
|
5
5
|
import { boolean, chat, convertMessagesToModelMessages, decide, score, toolDefinition } from "@tanstack/ai";
|
|
6
6
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as GITHUB_TOOL_CATALOG, Za as githubToolsErrors, v as PRESET_TOOLS, w as ALL_GITHUB_TOOL_NAMES, y as resolvePresetTools } from "./write-tools-
|
|
1
|
+
import { T as GITHUB_TOOL_CATALOG, Za as githubToolsErrors, v as PRESET_TOOLS, w as ALL_GITHUB_TOOL_NAMES, y as resolvePresetTools } from "./write-tools-C-962T9O.mjs";
|
|
2
2
|
import { ConnectError, ConnectorInstallationRequiredError, UserAuthorizationRequiredError, getToken } from "@vercel/connect";
|
|
3
3
|
// src/connect/connector.ts
|
|
4
4
|
/** Resolves a {@link GithubConnectorInput} to a connector name string. */
|
|
@@ -265,4 +265,4 @@ function resolveConnectOptions(connectOptions) {
|
|
|
265
265
|
}
|
|
266
266
|
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 };
|
|
267
267
|
|
|
268
|
-
//# sourceMappingURL=token-
|
|
268
|
+
//# sourceMappingURL=token-DZu9uttC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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;CACV,IAAI,CAAC,QAAQ,OAAO,CAAC,GAAG,kBAAkB;CAG1C,OAAO,CACL,GAAG,IAAI,KAFO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM,EAAA,CAEnC,SAAQ,MAAK,sBAAsB,EAAE,CAAC,CAC3D;AACF;;;;;AAMA,SAAgB,4BAA4B,OAA4C;CACtF,MAAM,yBAAS,IAAI,IAAY,CAAC,eAAe,CAAC;CAChD,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,SAAS,oBAAoB,OACtC,OAAO,IAAI,KAAK;CAGpB,OAAO,YAAY,MAAM;AAC3B;AAQA,SAAS,yBAAyB,EAChC,QACA,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"file":"token-DZu9uttC.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,G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AM,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"}
|
package/dist/workflow.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { Qt as createGithubAgent, Zt as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-v5n5OLs7.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";
|
package/dist/workflow.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as createGithubAgent, t as createGithubTools } from "./src-
|
|
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-
|
|
1
|
+
import { r as createGithubAgent, t as createGithubTools } from "./src-BRZIY_PZ.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-C-962T9O.mjs";
|
|
3
3
|
import { WorkflowAgent } from "@ai-sdk/workflow";
|
|
4
4
|
// src/workflow.ts
|
|
5
5
|
/**
|
|
@@ -149,6 +149,12 @@ const githubToolsErrors = defineErrorCatalog("github_tools", {
|
|
|
149
149
|
fix: "Act on a repository and branch the guardrails allow, such as a branch matching the allowed patterns, or ask the user to change `guardrails`.",
|
|
150
150
|
link: "https://github-tools.com/approval#guardrails"
|
|
151
151
|
},
|
|
152
|
+
APP_BOT_UNKNOWN: {
|
|
153
|
+
status: 403,
|
|
154
|
+
message: "GitHub lists no installation of the App to this user token, so the App's bot account can't be credited.",
|
|
155
|
+
why: "Attribution reads the App that issued a user token from the installations GitHub lists to it. An empty list means the token is not a GitHub App user token, or the user can reach no installation of the App.",
|
|
156
|
+
fix: "Use a Vercel Connect connector backed by a GitHub App installed where the user works, or turn attribution off."
|
|
157
|
+
},
|
|
152
158
|
CALLER_FORBIDDEN: {
|
|
153
159
|
status: 403,
|
|
154
160
|
message: ({ reason }) => `Not allowed for the person who asked: ${reason}`,
|
|
@@ -5903,4 +5909,4 @@ function resolveToolGuidance(options) {
|
|
|
5903
5909
|
const GITHUB_WRITE_TOOLS = Object.fromEntries(GITHUB_WRITE_TOOL_NAMES.map((name) => [name, name]));
|
|
5904
5910
|
export { listCommentReactionsInputSchema as $, stripRateLimit as $a, getCommitDescription as $i, disablePullRequestAutoMergeInputSchema as $n, closeIssueDescription as $r, cancelWorkflowRunInputSchema as $t, listDependabotAlertsCore as A, forkRepositoryInputSchema as Aa, listSubIssuesInputSchema as Ai, getReleaseCore as An, updatePullRequestBranchCore as Ar, addDiscussionCommentCore as At, searchIssuesDescription as B, getRepositoryCore as Ba, updateIssueCore as Bi, addPullRequestCommentDescription as Bn, addAssigneesCore as Br, getCiFailureContextDescription as Bt, withGithubGuardrails as C, deleteBranchDescription as Ca, listLabelsDescription as Ci, createReleaseInputSchema as Cn, replyToReviewCommentInputSchema as Cr, listGistCommentsInputSchema as Ct, listCodeScanningAlertsCore as D, editFilesInputSchema as Da, listMilestonesInputSchema as Di, getLatestReleaseCore as Dn, resolveReviewThreadCore as Dr, updateGistCore as Dt, isGithubWriteToolName as E, editFilesDescription as Ea, listMilestonesDescription as Ei, deleteReleaseInputSchema as En, requestReviewersInputSchema as Er, listGistsInputSchema as Et, listSecretScanningAlertsInputSchema as F, getCollaboratorPermissionDescription as Fa, removeLabelDescription as Fi, listReleasesInputSchema as Fn, updatePullRequestCommentInputSchema as Fr, getDiscussionInputSchema as Ft, addCommentReactionCore as G, getRepositoryTreeInputSchema as Ga, updateLabelInputSchema as Gi, createPullRequestReviewCore as Gn, addIssueCommentInputSchema as Gr, getPullRequestContextCore as Gt, searchRepositoriesCore as H, getRepositoryInputSchema as Ha, updateIssueInputSchema as Hi, createPullRequestCore as Hn, addAssigneesInputSchema as Hr, getIssueContextCore as Ht, searchCodeCore as I, getCollaboratorPermissionInputSchema as Ia, removeLabelInputSchema as Ii, updateReleaseCore as In, updatePullRequestCore as Ir, listDiscussionsCore as It, addIssueReactionCore as J, listBranchesInputSchema as Ja, compareCommitsInputSchema as Ji, deletePullRequestCommentCore as Jn, addLabelsInputSchema as Jr, getReleaseContextCore as Jt, addCommentReactionDescription as K, listBranchesCore as Ka, compareCommitsCore as Ki, createPullRequestReviewDescription as Kn, addLabelsCore as Kr, getPullRequestContextDescription as Kt, searchCodeDescription as L, getFileContentCore as La, updateIssueCommentCore as Li, updateReleaseDescription as Ln, updatePullRequestDescription as Lr, listDiscussionsDescription as Lt, listDependabotAlertsInputSchema as M, getBranchRulesDescription as Ma, removeAssigneesDescription as Mi, getReleaseInputSchema as Mn, updatePullRequestBranchInputSchema as Mr, addDiscussionCommentInputSchema as Mt, listSecretScanningAlertsCore as N, getBranchRulesInputSchema as Na, removeAssigneesInputSchema as Ni, listReleasesCore as Nn, updatePullRequestCommentCore as Nr, getDiscussionCore as Nt, listCodeScanningAlertsDescription as O, forkRepositoryCore as Oa, listSubIssuesCore as Oi, getLatestReleaseDescription as On, resolveReviewThreadDescription as Or, updateGistDescription as Ot, listSecretScanningAlertsDescription as P, getCollaboratorPermissionCore as Pa, removeLabelCore as Pi, listReleasesDescription as Pn, updatePullRequestCommentDescription as Pr, getDiscussionDescription as Pt, listCommentReactionsDescription as Q, toModelErrorPayload as Qa, getCommitCore as Qi, disablePullRequestAutoMergeDescription as Qn, closeIssueCore as Qr, cancelWorkflowRunDescription as Qt, searchCodeInputSchema as R, getFileContentDescription as Ra, updateIssueCommentDescription as Ri, updateReleaseInputSchema as Rn, updatePullRequestInputSchema as Rr, listDiscussionsInputSchema as Rt, resolveGithubToken as S, deleteBranchCore as Sa, listLabelsCore as Si, createReleaseDescription as Sn, replyToReviewCommentDescription as Sr, listGistCommentsDescription as St, GITHUB_TOOL_CATALOG as T, editFilesCore as Ta, listMilestonesCore as Ti, deleteReleaseDescription as Tn, requestReviewersDescription as Tr, listGistsDescription as Tt, searchRepositoriesDescription as U, getRepositoryTreeCore as Ua, updateLabelCore as Ui, createPullRequestDescription as Un, addIssueCommentCore as Ur, getIssueContextDescription as Ut, searchIssuesInputSchema as V, getRepositoryDescription as Va, updateIssueDescription as Vi, addPullRequestCommentInputSchema as Vn, addAssigneesDescription as Vr, getCiFailureContextInputSchema as Vt, searchRepositoriesInputSchema as W, getRepositoryTreeDescription as Wa, updateLabelDescription as Wi, createPullRequestInputSchema as Wn, addIssueCommentDescription as Wr, getIssueContextInputSchema as Wt, addIssueReactionInputSchema as X, EvlogError as Xa, getBlameDescription as Xi, deletePullRequestCommentInputSchema as Xn, addSubIssueDescription as Xr, getReleaseContextInputSchema as Xt, addIssueReactionDescription as Y, createOctokit as Ya, getBlameCore as Yi, deletePullRequestCommentDescription as Yn, addSubIssueCore as Yr, getReleaseContextDescription as Yt, listCommentReactionsCore as Z, githubToolsErrors as Za, getBlameInputSchema as Zi, disablePullRequestAutoMergeCore as Zn, addSubIssueInputSchema as Zr, cancelWorkflowRunCore as Zt, CORE_READ_TOOLS as _, createOrUpdateFileDescription as _a, listIssueCommentsDescription as _i, rerunWorkflowRunInputSchema as _n, listPullRequestsInputSchema as _r, deleteGistInputSchema as _t, bindToolsContext as a, createCommitStatusDescription as aa, createLabelDescription as ai, getWorkflowRunInputSchema as an, getPullRequestInputSchema as ar, listNotificationsInputSchema as at, createGithubTokenResolver as b, createRepositoryDescription as ba, listIssuesDescription as bi, triggerWorkflowInputSchema as bn, mergePullRequestInputSchema as br, getGistInputSchema as bt, AUTO_APPROVAL_TOOLS as c, getCombinedStatusDescription as ca, deleteIssueCommentDescription as ci, listWorkflowJobsInputSchema as cn, listPullRequestFilesInputSchema as cr, markNotificationReadInputSchema as ct, PRESET_PURPOSES as d, listCheckRunsDescription as da, deleteLabelDescription as di, listWorkflowRunsInputSchema as dn, listPullRequestReviewThreadsInputSchema as dr, createGistCommentInputSchema as dt, getCommitInputSchema as ea, closeIssueInputSchema as ei, getWorkflowJobLogsCore as en, enablePullRequestAutoMergeCore as er, listIssueReactionsCore as et, RISK_QUESTION as f, listCheckRunsInputSchema as fa, deleteLabelInputSchema as fi, listWorkflowsCore as fn, listPullRequestReviewsCore as fr, createGistCore as ft, GITHUB_TOOL_NAMES as g, createOrUpdateFileCore as ga, listIssueCommentsCore as gi, rerunWorkflowRunDescription as gn, listPullRequestsDescription as gr, deleteGistDescription as gt, requiresApproval as h, createBranchInputSchema as ha, getIssueInputSchema as hi, rerunWorkflowRunCore as hn, listPullRequestsCore as hr, deleteGistCore as ht, dryRunWrite as i, createCommitStatusCore as ia, createLabelCore as ii, getWorkflowRunDescription as in, getPullRequestDescription as ir, listNotificationsDescription as it, listDependabotAlertsDescription as j, getBranchRulesCore as ja, removeAssigneesCore as ji, getReleaseDescription as jn, updatePullRequestBranchDescription as jr, addDiscussionCommentDescription as jt, listCodeScanningAlertsInputSchema as k, forkRepositoryDescription as ka, listSubIssuesDescription as ki, getLatestReleaseInputSchema as kn, resolveReviewThreadInputSchema as kr, updateGistInputSchema as kt, DEFAULT_EVALUATION_MODEL as l, getCombinedStatusInputSchema as la, deleteIssueCommentInputSchema as li, listWorkflowRunsCore as ln, listPullRequestReviewThreadsCore as lr, createGistCommentCore as lt, rankPresets as m, createBranchDescription as ma, getIssueDescription as mi, listWorkflowsInputSchema as mn, listPullRequestReviewsInputSchema as mr, createGistInputSchema as mt, resolveInstructions as n, listCommitsDescription as na, createIssueDescription as ni, getWorkflowJobLogsInputSchema as nn, enablePullRequestAutoMergeInputSchema as nr, listIssueReactionsInputSchema as nt, mergeContextArgs as o, createCommitStatusInputSchema as oa, createLabelInputSchema as oi, listWorkflowJobsCore as on, listPullRequestFilesCore as or, markNotificationReadCore as ot, conversationState as p, createBranchCore as pa, getIssueCore as pi, listWorkflowsDescription as pn, listPullRequestReviewsDescription as pr, createGistDescription as pt, addCommentReactionInputSchema as q, listBranchesDescription as qa, compareCommitsDescription as qi, createPullRequestReviewInputSchema as qn, addLabelsDescription as qr, getPullRequestContextInputSchema as qt, resolveToolGuidance as r, listCommitsInputSchema as ra, createIssueInputSchema as ri, getWorkflowRunCore as rn, getPullRequestCore as rr, listNotificationsCore as rt, softenContextSchema as s, getCombinedStatusCore as sa, deleteIssueCommentCore as si, listWorkflowJobsDescription as sn, listPullRequestFilesDescription as sr, markNotificationReadDescription as st, GITHUB_WRITE_TOOLS as t, listCommitsCore as ta, createIssueCore as ti, getWorkflowJobLogsDescription as tn, enablePullRequestAutoMergeDescription as tr, listIssueReactionsDescription as tt, INTENT_QUESTION as u, listCheckRunsCore as ua, deleteLabelCore as ui, listWorkflowRunsDescription as un, listPullRequestReviewThreadsDescription as ur, createGistCommentDescription as ut, PRESET_TOOLS as v, createOrUpdateFileInputSchema as va, listIssueCommentsInputSchema as vi, triggerWorkflowCore as vn, mergePullRequestCore as vr, getGistCore as vt, ALL_GITHUB_TOOL_NAMES as w, deleteBranchInputSchema as wa, listLabelsInputSchema as wi, deleteReleaseCore as wn, requestReviewersCore as wr, listGistsCore as wt, githubTokenCall as x, createRepositoryInputSchema as xa, listIssuesInputSchema as xi, createReleaseCore as xn, replyToReviewCommentCore as xr, listGistCommentsCore as xt, resolvePresetTools as y, createRepositoryCore as ya, listIssuesCore as yi, triggerWorkflowDescription as yn, mergePullRequestDescription as yr, getGistDescription as yt, searchIssuesCore as z, getFileContentInputSchema as za, updateIssueCommentInputSchema as zi, addPullRequestCommentCore as zn, guardrailViolation as zr, getCiFailureContextCore as zt };
|
|
5905
5911
|
|
|
5906
|
-
//# sourceMappingURL=write-tools-
|
|
5912
|
+
//# sourceMappingURL=write-tools-C-962T9O.mjs.map
|