@github-tools/sdk 1.7.0 → 1.8.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 +76 -3
- package/dist/connect/eve.d.mts +17 -0
- package/dist/connect/eve.d.mts.map +1 -0
- package/dist/connect/eve.mjs +27 -0
- package/dist/connect/eve.mjs.map +1 -0
- package/dist/connect.d.mts +46 -0
- package/dist/connect.d.mts.map +1 -0
- package/dist/connect.mjs +22 -0
- package/dist/connect.mjs.map +1 -0
- package/dist/eve-B-LChKzS.mjs +526 -0
- package/dist/eve-B-LChKzS.mjs.map +1 -0
- package/dist/eve.d.mts +3 -45
- package/dist/eve.d.mts.map +1 -1
- package/dist/eve.mjs +2 -521
- package/dist/{index-BRUYe5q0.d.mts → index-SZCaP-y9.d.mts} +44 -44
- package/dist/index-SZCaP-y9.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{src-BgnkKMD7.mjs → src-CfzZfU82.mjs} +87 -87
- package/dist/src-CfzZfU82.mjs.map +1 -0
- package/dist/token-CW8lQBND.mjs +100 -0
- package/dist/token-CW8lQBND.mjs.map +1 -0
- package/dist/{tool-types-CuirBEc8.d.mts → tool-types-C0kszIwd.d.mts} +35 -30
- package/dist/tool-types-C0kszIwd.d.mts.map +1 -0
- package/dist/types-BTanS_dq.d.mts +49 -0
- package/dist/types-BTanS_dq.d.mts.map +1 -0
- package/dist/types-DOeq0Iia.d.mts +27 -0
- package/dist/types-DOeq0Iia.d.mts.map +1 -0
- package/dist/workflow.d.mts +5 -5
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +3 -3
- package/dist/workflow.mjs.map +1 -1
- package/dist/{write-tools-vzlewWo5.mjs → write-tools-Dx9LfYlU.mjs} +26 -9
- package/dist/write-tools-Dx9LfYlU.mjs.map +1 -0
- package/package.json +16 -3
- package/dist/eve.mjs.map +0 -1
- package/dist/index-BRUYe5q0.d.mts.map +0 -1
- package/dist/src-BgnkKMD7.mjs.map +0 -1
- package/dist/tool-types-CuirBEc8.d.mts.map +0 -1
- package/dist/write-tools-vzlewWo5.mjs.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { getToken } from "@vercel/connect";
|
|
2
|
+
//#region src/connect/scopes.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vercel Connect scope strings mapped to each {@link GithubToolPreset}.
|
|
5
|
+
*
|
|
6
|
+
* Scopes mirror GitHub App permissions (`contents`, `pull_requests`, `issues`,
|
|
7
|
+
* `actions`, `administration`, `metadata`) and must cover every read/write
|
|
8
|
+
* family a preset's tools touch, not just its primary domain.
|
|
9
|
+
*
|
|
10
|
+
* Gist tools in `repo-explorer` and `maintainer` are intentionally left
|
|
11
|
+
* unscoped: the Gists API only accepts GitHub App *user* access tokens, never
|
|
12
|
+
* installation tokens, and Connect always mints `subject: { type: 'app' }`
|
|
13
|
+
* installation tokens. Gist calls made with a Connect-derived token 403
|
|
14
|
+
* regardless of requested scopes — use a fine-grained PAT with the "Gists"
|
|
15
|
+
* account permission for those tools instead.
|
|
16
|
+
*/
|
|
17
|
+
const PRESET_CONNECT_SCOPES = {
|
|
18
|
+
"repo-explorer": [
|
|
19
|
+
"contents:read",
|
|
20
|
+
"metadata:read",
|
|
21
|
+
"pull_requests:read",
|
|
22
|
+
"issues:read",
|
|
23
|
+
"actions:read"
|
|
24
|
+
],
|
|
25
|
+
"code-review": [
|
|
26
|
+
"contents:read",
|
|
27
|
+
"metadata:read",
|
|
28
|
+
"pull_requests:read",
|
|
29
|
+
"pull_requests:write"
|
|
30
|
+
],
|
|
31
|
+
"issue-triage": [
|
|
32
|
+
"contents:read",
|
|
33
|
+
"metadata:read",
|
|
34
|
+
"issues:read",
|
|
35
|
+
"issues:write"
|
|
36
|
+
],
|
|
37
|
+
"ci-ops": [
|
|
38
|
+
"contents:read",
|
|
39
|
+
"metadata:read",
|
|
40
|
+
"actions:read",
|
|
41
|
+
"actions:write"
|
|
42
|
+
],
|
|
43
|
+
"maintainer": [
|
|
44
|
+
"contents:read",
|
|
45
|
+
"contents:write",
|
|
46
|
+
"metadata:read",
|
|
47
|
+
"pull_requests:read",
|
|
48
|
+
"pull_requests:write",
|
|
49
|
+
"issues:read",
|
|
50
|
+
"issues:write",
|
|
51
|
+
"actions:read",
|
|
52
|
+
"actions:write",
|
|
53
|
+
"administration:read",
|
|
54
|
+
"administration:write"
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
/** Default scopes when no preset is specified — union of all preset scopes. */
|
|
58
|
+
const ALL_CONNECT_SCOPES = [...new Set(Object.values(PRESET_CONNECT_SCOPES).flat())];
|
|
59
|
+
/**
|
|
60
|
+
* Returns Vercel Connect scopes for a preset or combined presets.
|
|
61
|
+
* Without a preset, returns the union of all preset scopes (full tool set).
|
|
62
|
+
*/
|
|
63
|
+
function connectGithubScopesForPreset(preset) {
|
|
64
|
+
if (!preset) return [...ALL_CONNECT_SCOPES];
|
|
65
|
+
return [...new Set((Array.isArray(preset) ? preset : [preset]).flatMap((p) => PRESET_CONNECT_SCOPES[p]))];
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/connect/params.ts
|
|
69
|
+
function resolveGithubConnectTokenParams(options = {}) {
|
|
70
|
+
const { preset, params } = options;
|
|
71
|
+
return buildConnectTokenParams(params?.scopes ?? connectGithubScopesForPreset(preset), params);
|
|
72
|
+
}
|
|
73
|
+
function buildConnectTokenParams(scopes, params) {
|
|
74
|
+
const { repositories, ...rest } = params ?? {};
|
|
75
|
+
const authorizationDetails = rest.authorizationDetails ?? (repositories?.length ? [{
|
|
76
|
+
type: "github_app_installation",
|
|
77
|
+
repositories
|
|
78
|
+
}] : void 0);
|
|
79
|
+
return {
|
|
80
|
+
subject: { type: "app" },
|
|
81
|
+
...rest,
|
|
82
|
+
scopes,
|
|
83
|
+
...authorizationDetails && { authorizationDetails }
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/connect/token.ts
|
|
88
|
+
/**
|
|
89
|
+
* Returns a lazy GitHub token provider backed by a Vercel Connect connector.
|
|
90
|
+
* Scopes are derived from `preset` unless overridden in `params.scopes`.
|
|
91
|
+
*/
|
|
92
|
+
function connectGithubToken(connector, options = {}) {
|
|
93
|
+
const { connectOptions } = options;
|
|
94
|
+
const tokenParams = resolveGithubConnectTokenParams(options);
|
|
95
|
+
return () => getToken(connector, tokenParams, connectOptions);
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { PRESET_CONNECT_SCOPES as n, connectGithubScopesForPreset as r, connectGithubToken as t };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=token-CW8lQBND.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-CW8lQBND.mjs","names":[],"sources":["../src/connect/scopes.ts","../src/connect/params.ts","../src/connect/token.ts"],"sourcesContent":["import type { GithubToolPreset } from '../core/presets'\n\n/**\n * Vercel Connect scope strings mapped to each {@link GithubToolPreset}.\n *\n * Scopes mirror GitHub App permissions (`contents`, `pull_requests`, `issues`,\n * `actions`, `administration`, `metadata`) and must cover every read/write\n * family a preset's tools touch, not just its primary domain.\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 always mints `subject: { type: 'app' }`\n * installation tokens. Gist calls made with a Connect-derived token 403\n * regardless of requested scopes — use a fine-grained PAT with the \"Gists\"\n * account permission for those tools instead.\n */\nexport const PRESET_CONNECT_SCOPES = {\n 'repo-explorer': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'issues:read',\n 'actions:read',\n ],\n 'code-review': [\n 'contents:read',\n 'metadata:read',\n 'pull_requests:read',\n 'pull_requests:write',\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 ],\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 'actions:read',\n 'actions:write',\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/**\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","import type { ConnectTokenParams } from '@vercel/connect'\nimport { connectGithubScopesForPreset } from './scopes'\nimport type { ConnectGithubTokenOptions, GithubConnectParams } from './types'\n\nexport function resolveGithubConnectTokenParams(\n options: ConnectGithubTokenOptions = {},\n): ConnectTokenParams {\n const { preset, params } = options\n const scopes = params?.scopes ?? connectGithubScopesForPreset(preset)\n return buildConnectTokenParams(scopes, params)\n}\n\nfunction buildConnectTokenParams(\n scopes: string[],\n params?: GithubConnectParams,\n): ConnectTokenParams {\n const { repositories, ...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: { type: 'app' },\n ...rest,\n scopes,\n ...(authorizationDetails && { authorizationDetails }),\n }\n}\n","import { getToken, type ConnectOptions } from '@vercel/connect'\nimport type { GithubTokenInput } from '../core/token'\nimport { resolveGithubConnectTokenParams } from './params'\nimport type { ConnectGithubTokenOptions } from './types'\n\n/**\n * Returns a lazy GitHub token provider backed by a Vercel Connect connector.\n * Scopes are derived from `preset` unless overridden in `params.scopes`.\n */\nexport function connectGithubToken(\n connector: string,\n options: ConnectGithubTokenOptions = {},\n): GithubTokenInput {\n const { connectOptions } = options\n const tokenParams = resolveGithubConnectTokenParams(options)\n\n return () => getToken(connector, tokenParams, connectOptions)\n}\n\nexport type { ConnectOptions }\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,wBAAwB;CACnC,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACD;CACD,eAAe;EACb;EACA;EACA;EACA;EACD;CACD,gBAAgB;EACd;EACA;EACA;EACA;EACD;CACD,UAAU;EACR;EACA;EACA;EACA;EACD;CACD,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACF;;AAGD,MAAM,qBAAqB,CACzB,GAAG,IAAI,IAAI,OAAO,OAAO,sBAAsB,CAAC,MAAM,CAAC,CACxD;;;;;AAMD,SAAgB,6BACd,QACU;AACV,KAAI,CAAC,OAAQ,QAAO,CAAC,GAAG,mBAAmB;AAG3C,QAAO,CACL,GAAG,IAAI,KAFO,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO,EAEpC,SAAQ,MAAK,sBAAsB,GAAG,CAAC,CAC3D;;;;ACtEH,SAAgB,gCACd,UAAqC,EAAE,EACnB;CACpB,MAAM,EAAE,QAAQ,WAAW;AAE3B,QAAO,wBADQ,QAAQ,UAAU,6BAA6B,OAAO,EAC9B,OAAO;;AAGhD,SAAS,wBACP,QACA,QACoB;CACpB,MAAM,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE;CAE9C,MAAM,uBAAuB,KAAK,yBAC5B,cAAc,SACd,CAAC;EAAE,MAAM;EAAoC;EAAc,CAAC,GAC5D,KAAA;AAEN,QAAO;EACL,SAAS,EAAE,MAAM,OAAO;EACxB,GAAG;EACH;EACA,GAAI,wBAAwB,EAAE,sBAAsB;EACrD;;;;;;;;ACnBH,SAAgB,mBACd,WACA,UAAqC,EAAE,EACrB;CAClB,MAAM,EAAE,mBAAmB;CAC3B,MAAM,cAAc,gCAAgC,QAAQ;AAE5D,cAAa,SAAS,WAAW,aAAa,eAAe"}
|
|
@@ -141,6 +141,38 @@ declare const GITHUB_WRITE_TOOLS: {
|
|
|
141
141
|
};
|
|
142
142
|
type GithubWriteToolName = typeof GITHUB_WRITE_TOOLS[keyof typeof GITHUB_WRITE_TOOLS];
|
|
143
143
|
//#endregion
|
|
144
|
+
//#region src/core/approval.d.ts
|
|
145
|
+
/**
|
|
146
|
+
* Whether write operations require user approval.
|
|
147
|
+
*
|
|
148
|
+
* - `true` — all write tools need approval (default)
|
|
149
|
+
* - `false` — no approval needed for any write tool
|
|
150
|
+
* - object — per-tool override via {@link GithubWriteToolName}; unspecified write tools default to `true`
|
|
151
|
+
*
|
|
152
|
+
* @example Global disable
|
|
153
|
+
* ```ts
|
|
154
|
+
* createGithubTools({ token, requireApproval: false })
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example Granular per write tool
|
|
158
|
+
* ```ts
|
|
159
|
+
* createGithubTools({
|
|
160
|
+
* token,
|
|
161
|
+
* requireApproval: {
|
|
162
|
+
* mergePullRequest: true,
|
|
163
|
+
* createOrUpdateFile: true,
|
|
164
|
+
* addPullRequestComment: false,
|
|
165
|
+
* },
|
|
166
|
+
* })
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
type ApprovalConfig = boolean | Partial<Record<GithubWriteToolName, boolean>>;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/core/token.d.ts
|
|
172
|
+
type GithubTokenInput = string | (() => Promise<string>);
|
|
173
|
+
/** Resolves a {@link GithubTokenInput} to a token string. */
|
|
174
|
+
declare function resolveGithubToken(token?: GithubTokenInput): Promise<string>;
|
|
175
|
+
//#endregion
|
|
144
176
|
//#region src/types.d.ts
|
|
145
177
|
type GithubTool = Tool<any, any>;
|
|
146
178
|
type ToolOptions = {
|
|
@@ -196,39 +228,12 @@ type CommitToolOptions = ToolOptions & {
|
|
|
196
228
|
*/
|
|
197
229
|
type ToolOverrides = Partial<Pick<Tool, 'description' | 'needsApproval' | 'onInputAvailable' | 'onInputDelta' | 'onInputStart' | 'providerOptions' | 'strict' | 'title' | 'toModelOutput'>>;
|
|
198
230
|
//#endregion
|
|
199
|
-
//#region src/core/approval.d.ts
|
|
200
|
-
/**
|
|
201
|
-
* Whether write operations require user approval.
|
|
202
|
-
*
|
|
203
|
-
* - `true` — all write tools need approval (default)
|
|
204
|
-
* - `false` — no approval needed for any write tool
|
|
205
|
-
* - object — per-tool override via {@link GithubWriteToolName}; unspecified write tools default to `true`
|
|
206
|
-
*
|
|
207
|
-
* @example Global disable
|
|
208
|
-
* ```ts
|
|
209
|
-
* createGithubTools({ token, requireApproval: false })
|
|
210
|
-
* ```
|
|
211
|
-
*
|
|
212
|
-
* @example Granular per write tool
|
|
213
|
-
* ```ts
|
|
214
|
-
* createGithubTools({
|
|
215
|
-
* token,
|
|
216
|
-
* requireApproval: {
|
|
217
|
-
* mergePullRequest: true,
|
|
218
|
-
* createOrUpdateFile: true,
|
|
219
|
-
* addPullRequestComment: false,
|
|
220
|
-
* },
|
|
221
|
-
* })
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
type ApprovalConfig = boolean | Partial<Record<GithubWriteToolName, boolean>>;
|
|
225
|
-
//#endregion
|
|
226
231
|
//#region src/core/tool-types.d.ts
|
|
227
232
|
/** Full tool set returned when no `preset` is specified. */
|
|
228
233
|
type AllGithubTools = Record<GithubToolName, GithubTool>;
|
|
229
234
|
/** Base options shared by all {@link createGithubTools} overloads. */
|
|
230
235
|
type GithubToolsBaseOptions = {
|
|
231
|
-
/** GitHub
|
|
236
|
+
/** GitHub token string or async provider. Falls back to `process.env.GITHUB_TOKEN` when omitted. */token?: GithubTokenInput; /** Control whether write operations require user approval. @see {@link ApprovalConfig} */
|
|
232
237
|
requireApproval?: ApprovalConfig; /** Per-tool overrides for description, title, needsApproval, and related AI SDK tool fields. */
|
|
233
238
|
overrides?: Partial<Record<GithubToolName, ToolOverrides>>; /** Default author for commit-creating tools. Falls back to the authenticated user when omitted. */
|
|
234
239
|
author?: CommitIdentity; /** Default committer for commit-creating tools. Falls back to the authenticated user when omitted. */
|
|
@@ -240,5 +245,5 @@ type GithubToolsForPreset<P extends GithubToolPreset | readonly GithubToolPreset
|
|
|
240
245
|
/** Pick a subset of GitHub tools by tool name. */
|
|
241
246
|
type PickGithubTools<T extends GithubToolName> = Pick<AllGithubTools, T>;
|
|
242
247
|
//#endregion
|
|
243
|
-
export {
|
|
244
|
-
//# sourceMappingURL=tool-types-
|
|
248
|
+
export { GithubToolPreset as _, CommitIdentity as a, GITHUB_TOOL_NAMES as b, Octokit$1 as c, GithubTokenInput as d, resolveGithubToken as f, CombinedPresetToolNames as g, GithubWriteToolName as h, PickGithubTools as i, ToolOptions as l, GITHUB_WRITE_TOOLS as m, GithubToolsBaseOptions as n, CommitToolOptions as o, ApprovalConfig as p, GithubToolsForPreset as r, GithubTool as s, AllGithubTools as t, ToolOverrides as u, PRESET_TOOLS as v, GithubToolName as x, PresetToolName as y };
|
|
249
|
+
//# sourceMappingURL=tool-types-C0kszIwd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-types-C0kszIwd.d.mts","names":[],"sources":["../src/core/tool-names.ts","../src/core/presets.ts","../src/core/write-tools.ts","../src/core/approval.ts","../src/core/token.ts","../src/types.ts","../src/core/tool-types.ts"],"mappings":";;;;;;;;cAIa,iBAAA;EAqFH,4JAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;qCAEgB;EAAA,mDAAU;EAAA;;iCCN1B;EAAA,iCAAA;EAAA;;;qCAEE;EAAA;mDAA4C;EAAA,yCAG9B;EAAA,+CAAW;EAAA,2CAAkD;EAAA,+CAA9B;EAAA,6CAAO;EAAA,iDAA3B;EAAA;;KDCzB,cAAA,UAAwB,iBAAA,cAA+B,iBAAA;;;;;;AAvFnE;;cCGa,YAAA;EDkFH;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCFE,gBAAA,gBAAgC,YAAA;;KAGhC,cAAA,WAAyB,gBAAA,IAAoB,OAAA,SAAgB,YAAA,EAAc,CAAA,WAAY,cAAA;;KAGvF,uBAAA,oBAA2C,gBAAA,MAAsB,cAAA,CAAe,CAAA;;;;;;;cCzF/E,kBAAA;EFqFH,6JAAA;EAAA;;;;;;;;;;;;;;;;;;;;KE1CE,mBAAA,UAA6B,kBAAA,cAAgC,kBAAA;;;;;;AF3CzE;;;;;;;;;;;;;;;;;;;;;KGsBY,cAAA,aAA2B,OAAA,CAAQ,MAAA,CAAO,mBAAA;;;KC1B1C,gBAAA,mBAAmC,OAAA;;iBA+B/B,kBAAA,CAAmB,KAAA,GAAQ,gBAAA,GAAmB,OAAA;;;KCzBlD,UAAA,GAAa,IAAA;AAAA,KAEb,WAAA;EAAgB,aAAA;AAAA;;;;;;;KAQhB,cAAA;EACV,IAAA;EACA,KAAA;AAAA;;;;KAMU,iBAAA,GAAoB,WAAA;;;;;EAK9B,MAAA,GAAS,cAAA;;;;;EAKT,SAAA,GAAY,cAAA;;;;;EAKZ,SAAA,GAAY,cAAA;AAAA;;;;;;;;;;;;;;;;;ALoDd;;KK/BY,aAAA,GAAgB,OAAA,CAC1B,IAAA,CACE,IAAA;;;;KCvDQ,cAAA,GAAiB,MAAA,CAAO,cAAA,EAAgB,UAAA;;KAGxC,sBAAA;sGAEV,KAAA,GAAQ,gBAAA;EAER,eAAA,GAAkB,cAAA;EAElB,SAAA,GAAY,OAAA,CAAQ,MAAA,CAAO,cAAA,EAAgB,aAAA;EAE3C,MAAA,GAAS,cAAA;EAET,SAAA,GAAY,cAAA;EAEZ,SAAA,GAAY,cAAA;AAAA;;KAIF,oBAAA,WAA+B,gBAAA,YAA4B,gBAAA,kBACrE,CAAA,SAAU,gBAAA,GACN,IAAA,CAAK,cAAA,EAAgB,cAAA,CAAe,CAAA,IAAK,cAAA,IACzC,CAAA,kBAAmB,gBAAA,KACjB,IAAA,CAAK,cAAA,EAAgB,uBAAA,CAAwB,CAAA,IAAK,cAAA,IAClD,cAAA;;KAGI,eAAA,WAA0B,cAAA,IAAkB,IAAA,CAAK,cAAA,EAAgB,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { _ as GithubToolPreset, a as CommitIdentity, d as GithubTokenInput, h as GithubWriteToolName, x as GithubToolName } from "./tool-types-C0kszIwd.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Approval, ToolModelOutput } from "eve/tools";
|
|
4
|
+
|
|
5
|
+
//#region src/eve/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Approval value for eve tools.
|
|
8
|
+
* - `true` / `'always'` → require approval on every call
|
|
9
|
+
* - `false` / `'never'` → skip approval
|
|
10
|
+
* - `'once'` → require approval only the first time per session
|
|
11
|
+
* - predicate → input-dependent gate (eve `Approval` shape)
|
|
12
|
+
* - eve helpers (`always()`, `once()`, `never()`) → passthrough
|
|
13
|
+
*/
|
|
14
|
+
type EveApprovalValue = boolean | 'always' | 'once' | 'never' | Approval;
|
|
15
|
+
type EveApprovalConfig = boolean | Partial<Record<GithubWriteToolName, EveApprovalValue>>;
|
|
16
|
+
type EveToolOverrides = Partial<Record<GithubToolName, {
|
|
17
|
+
description?: string;
|
|
18
|
+
approval?: EveApprovalValue;
|
|
19
|
+
toModelOutput?: (output: unknown) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
20
|
+
outputSchema?: z.ZodType | Record<string, unknown>;
|
|
21
|
+
}>>;
|
|
22
|
+
type EveGithubToolsOptions = {
|
|
23
|
+
/** GitHub token string or async provider. Defaults to `process.env.GITHUB_TOKEN`. */token?: GithubTokenInput;
|
|
24
|
+
/**
|
|
25
|
+
* Restrict tools to a predefined preset.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link GithubToolPreset} for available presets and included tools.
|
|
28
|
+
*/
|
|
29
|
+
preset?: GithubToolPreset | GithubToolPreset[];
|
|
30
|
+
/**
|
|
31
|
+
* Control whether write operations require user approval before execution.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link EveApprovalConfig} for global and per-tool options.
|
|
34
|
+
*/
|
|
35
|
+
requireApproval?: EveApprovalConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Per-tool overrides for description, approval, output shaping, and output schema.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link GithubToolName} for valid tool keys.
|
|
40
|
+
*/
|
|
41
|
+
overrides?: EveToolOverrides; /** Default author for commit-creating tools. Falls back to the authenticated user when omitted. */
|
|
42
|
+
author?: CommitIdentity; /** Default committer for commit-creating tools. Falls back to the authenticated user when omitted. */
|
|
43
|
+
committer?: CommitIdentity; /** Co-authors to attribute on all commits created by tools. */
|
|
44
|
+
coAuthors?: CommitIdentity[];
|
|
45
|
+
};
|
|
46
|
+
type EveToolFactoryOptions = Omit<EveGithubToolsOptions, 'preset'>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { EveToolOverrides as a, EveToolFactoryOptions as i, EveApprovalValue as n, EveGithubToolsOptions as r, EveApprovalConfig as t };
|
|
49
|
+
//# sourceMappingURL=types-BTanS_dq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BTanS_dq.d.mts","names":[],"sources":["../src/eve/types.ts"],"mappings":";;;;;;;;AAuBA;;;;;KAPY,gBAAA,2CAKR,QAAA;AAAA,KAEQ,iBAAA,aAER,OAAA,CAAQ,MAAA,CAAO,mBAAA,EAAqB,gBAAA;AAAA,KAE5B,gBAAA,GAAmB,OAAA,CAAQ,MAAA,CAAO,cAAA;EAC5C,WAAA;EACA,QAAA,GAAW,gBAAA;EACX,aAAA,IAAiB,MAAA,cAAoB,eAAA,GAAkB,OAAA,CAAQ,eAAA;EAC/D,YAAA,GAAe,CAAA,CAAE,OAAA,GAAU,MAAA;AAAA;AAAA,KAGjB,qBAAA;EAT4C,qFAWtD,KAAA,GAAQ,gBAAA;EATkB;;;;;EAe1B,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAZ2B;;;;;EAkBvD,eAAA,GAAkB,iBAAA;EArBkB;;;;;EA2BpC,SAAA,GAAY,gBAAA,EAzBD;EA2BX,MAAA,GAAS,cAAA,EA1BQ;EA4BjB,SAAA,GAAY,cAAA,EA5B2C;EA8BvD,SAAA,GAAY,cAAA;AAAA;AAAA,KAGF,qBAAA,GAAwB,IAAA,CAAK,qBAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { _ as GithubToolPreset, n as GithubToolsBaseOptions } from "./tool-types-C0kszIwd.mjs";
|
|
2
|
+
import { r as EveGithubToolsOptions } from "./types-BTanS_dq.mjs";
|
|
3
|
+
import { ConnectOptions, ConnectTokenParams } from "@vercel/connect";
|
|
4
|
+
|
|
5
|
+
//#region src/connect/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Token parameters for Vercel Connect GitHub connectors.
|
|
8
|
+
* `subject` is pinned to `{ type: 'app' }` by the SDK — same as `connectGitHubAdapter`.
|
|
9
|
+
*/
|
|
10
|
+
type GithubConnectParams = Omit<ConnectTokenParams, 'subject'> & {
|
|
11
|
+
/** Restrict the token to specific repositories via GitHub authorization details. */repositories?: string[];
|
|
12
|
+
};
|
|
13
|
+
type ConnectGithubToolsOptions = GithubToolsBaseOptions & {
|
|
14
|
+
preset?: GithubToolPreset | GithubToolPreset[];
|
|
15
|
+
connect?: GithubConnectParams;
|
|
16
|
+
};
|
|
17
|
+
type ConnectGithubEveToolsOptions = Omit<EveGithubToolsOptions, 'token'> & {
|
|
18
|
+
connect?: GithubConnectParams;
|
|
19
|
+
};
|
|
20
|
+
type ConnectGithubTokenOptions = {
|
|
21
|
+
preset?: GithubToolPreset | GithubToolPreset[];
|
|
22
|
+
params?: GithubConnectParams;
|
|
23
|
+
connectOptions?: ConnectOptions;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { GithubConnectParams as i, ConnectGithubTokenOptions as n, ConnectGithubToolsOptions as r, ConnectGithubEveToolsOptions as t };
|
|
27
|
+
//# sourceMappingURL=types-DOeq0Iia.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DOeq0Iia.d.mts","names":[],"sources":["../src/connect/types.ts"],"mappings":";;;;;;AASA;;;KAAY,mBAAA,GAAsB,IAAA,CAAK,kBAAA;EAAL,oFAEhC,YAAA;AAAA;AAAA,KAGU,yBAAA,GAA4B,sBAAA;EACtC,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAC5B,OAAA,GAAU,mBAAA;AAAA;AAAA,KAGA,4BAAA,GAA+B,IAAA,CAAK,qBAAA;EAC9C,OAAA,GAAU,mBAAA;AAAA;AAAA,KAGA,yBAAA;EACV,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAC5B,MAAA,GAAS,mBAAA;EACT,cAAA,GAAiB,cAAA;AAAA"}
|
package/dist/workflow.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { a as createGithubAgent, i as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-
|
|
1
|
+
import { _ as GithubToolPreset, a as CommitIdentity, b as GITHUB_TOOL_NAMES, d as GithubTokenInput, f as resolveGithubToken, g as CombinedPresetToolNames, h as GithubWriteToolName, i as PickGithubTools, m as GITHUB_WRITE_TOOLS, o as CommitToolOptions, p as ApprovalConfig, r as GithubToolsForPreset, t as AllGithubTools, u as ToolOverrides, v as PRESET_TOOLS, x as GithubToolName, y as PresetToolName } from "./tool-types-C0kszIwd.mjs";
|
|
2
|
+
import { a as createGithubAgent, i as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-SZCaP-y9.mjs";
|
|
3
3
|
import { FinishReason, LanguageModel, LanguageModelResponseMetadata, LanguageModelUsage, ModelMessage, StepResult, StopCondition, ToolSet } from "ai";
|
|
4
4
|
import { WorkflowAgentOptions, WorkflowAgentStreamOptions, WorkflowAgentStreamResult } from "@ai-sdk/workflow";
|
|
5
5
|
import { Context } from "@ai-sdk/provider-utils";
|
|
@@ -65,10 +65,10 @@ declare class DurableGithubAgent<TTools extends ToolSet = ToolSet> {
|
|
|
65
65
|
type CreateDurableGithubAgentOptions = Omit<WorkflowAgentOptions, 'model' | 'tools' | 'instructions'> & {
|
|
66
66
|
model: string | LanguageModel;
|
|
67
67
|
/**
|
|
68
|
-
* GitHub personal access token.
|
|
68
|
+
* GitHub personal access token or async token provider.
|
|
69
69
|
* Falls back to `process.env.GITHUB_TOKEN` when omitted.
|
|
70
70
|
*/
|
|
71
|
-
token?:
|
|
71
|
+
token?: GithubTokenInput;
|
|
72
72
|
/**
|
|
73
73
|
* Restrict tools and system prompt to a predefined preset.
|
|
74
74
|
*
|
|
@@ -150,5 +150,5 @@ declare function createDurableGithubAgent<P extends readonly GithubToolPreset[]>
|
|
|
150
150
|
preset: P;
|
|
151
151
|
}): DurableGithubAgent<Pick<AllGithubTools, CombinedPresetToolNames<P>>>;
|
|
152
152
|
//#endregion
|
|
153
|
-
export { type AllGithubTools, type ApprovalConfig, type CombinedPresetToolNames, type CommitIdentity, type CommitToolOptions, CreateDurableGithubAgentOptions, type CreateGithubAgentOptions, DurableGithubAgent, DurableGithubAgentGenerateResult, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, type GithubToolName, type GithubToolPreset, type GithubTools, type GithubToolsForPreset, type GithubToolsOptions, type GithubWriteToolName, PRESET_TOOLS, type PickGithubTools, type PresetToolName, type ToolOverrides, createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
153
|
+
export { type AllGithubTools, type ApprovalConfig, type CombinedPresetToolNames, type CommitIdentity, type CommitToolOptions, CreateDurableGithubAgentOptions, type CreateGithubAgentOptions, DurableGithubAgent, DurableGithubAgentGenerateResult, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, type GithubTokenInput, type GithubToolName, type GithubToolPreset, type GithubTools, type GithubToolsForPreset, type GithubToolsOptions, type GithubWriteToolName, PRESET_TOOLS, type PickGithubTools, type PresetToolName, type ToolOverrides, createDurableGithubAgent, createGithubAgent, createGithubTools, resolveGithubToken };
|
|
154
154
|
//# sourceMappingURL=workflow.d.mts.map
|
package/dist/workflow.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;;;;;UA8BiB,gCAAA,gBAAgD,OAAA,GAAU,OAAA;EACzE,IAAA;EACA,YAAA,EAAc,YAAA;EACd,KAAA,EAAO,kBAAA;EACP,KAAA,EAAO,UAAA,CAAW,MAAA;EAClB,QAAA,EAAU,6BAAA;IAAkC,QAAA,EAAU,YAAA;EAAA;AAAA;;;;;;;;;;;cAa3C,kBAAA,gBAAkC,OAAA,GAAU,OAAA;EAAA,QAC/C,KAAA;EAAA,QACA,MAAA;EAAA,QACA,aAAA;EAAA,QACA,UAAA;EAAA,QACA,MAAA;cAEI,OAAA,EAAS,oBAAA,CAAqB,MAAA;EAP/B;EAAA,IAgBP,KAAA,CAAA,GAAS,MAAA;EAhBgB;;;;EAwB7B,MAAA,sBAA4B,MAAA,GAAS,MAAA,yCAAA,CACnC,OAAA,EAAS,0BAAA,CAA2B,YAAA,EAAc,OAAA,EAAS,MAAA,EAAQ,cAAA,IAClE,OAAA,CAAQ,yBAAA,CAA0B,YAAA,EAAc,MAAA;EAVtC;;;;;;;EAqBP,QAAA,CAAA;IAAW,MAAA;IAAQ;EAAA;IAAc,MAAA;IAAgB,QAAA,GAAW,aAAA,CAAc,MAAA,IAAU,KAAA,CAAM,aAAA,CAAc,MAAA;EAAA,IAAa,OAAA,CAAQ,gCAAA,CAAiC,MAAA;AAAA;;;;;;;KA8B1J,+BAAA,GACV,IAAA,CAAK,oBAAA;EACH,KAAA,WAAgB,aAAA;EAhCiH;;;;EAqCjI,KAAA,GAAQ,gBAAA;EA1EmC;;;;;;;;EAmF3C,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EA5EY;;;;;EAkFxC,eAAA,GAAkB,cAAA;EAjEQ;;;;EAsE1B,YAAA;EArEoC;;;;EA0EpC,sBAAA;EAzEC;;;;EA8ED,MAAA,GAAS,cAAA;EAnEM;;;;EAwEf,SAAA,GAAY,cAAA;EAxEyC;;;;EA6ErD,SAAA,GAAY,cAAA;AAAA;;;;;;AA/ChB;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFgB,wBAAA,CACd,OAAA,EAAS,+BAAA;EAAoC,MAAA;AAAA,IAC5C,kBAAA,CAAmB,cAAA;AAAA,iBACN,wBAAA,WAAmC,gBAAA,CAAA,CACjD,OAAA,EAAS,+BAAA;EAAoC,MAAA,EAAQ,CAAA;AAAA,IACpD,kBAAA,CAAmB,IAAA,CAAK,cAAA,EAAgB,cAAA,CAAe,CAAA;AAAA,iBAC1C,wBAAA,oBAA4C,gBAAA,GAAA,CAC1D,OAAA,EAAS,+BAAA;EAAoC,MAAA,EAAQ,CAAA;AAAA,IACpD,kBAAA,CAAmB,IAAA,CAAK,cAAA,EAAgB,uBAAA,CAAwB,CAAA"}
|
package/dist/workflow.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createGithubAgent, r as resolveInstructions, t as createGithubTools } from "./src-
|
|
1
|
+
import { i as PRESET_TOOLS, in as resolveGithubToken, r as GITHUB_TOOL_NAMES, t as GITHUB_WRITE_TOOLS } from "./write-tools-Dx9LfYlU.mjs";
|
|
2
|
+
import { n as createGithubAgent, r as resolveInstructions, t as createGithubTools } from "./src-CfzZfU82.mjs";
|
|
3
3
|
import { WorkflowAgent } from "@ai-sdk/workflow";
|
|
4
4
|
//#region src/workflow.ts
|
|
5
5
|
/**
|
|
@@ -84,6 +84,6 @@ function createDurableGithubAgent({ model, token, preset, requireApproval, instr
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
|
-
export { DurableGithubAgent, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, PRESET_TOOLS, createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
87
|
+
export { DurableGithubAgent, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, PRESET_TOOLS, createDurableGithubAgent, createGithubAgent, createGithubTools, resolveGithubToken };
|
|
88
88
|
|
|
89
89
|
//# sourceMappingURL=workflow.mjs.map
|
package/dist/workflow.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { WorkflowAgent } from '@ai-sdk/workflow'\nimport type {\n WorkflowAgentOptions,\n WorkflowAgentStreamOptions,\n WorkflowAgentStreamResult,\n TelemetryOptions,\n} from '@ai-sdk/workflow'\nimport type {\n LanguageModel,\n ToolSet,\n StepResult,\n FinishReason,\n LanguageModelUsage,\n LanguageModelResponseMetadata,\n ModelMessage,\n StopCondition,\n} from 'ai'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport type { AllGithubTools } from './core/tool-types'\nimport type { CombinedPresetToolNames, GithubToolPreset, PresetToolName } from './core/presets'\nimport type { GithubToolName } from './core/tool-names'\nimport type { ApprovalConfig } from './index'\nimport type { CommitIdentity } from './types'\nimport type { Context } from '@ai-sdk/provider-utils'\n\n/**\n * Result of {@link DurableGithubAgent.generate}.\n */\nexport interface DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> {\n text: string\n finishReason: FinishReason\n usage: LanguageModelUsage\n steps: StepResult<TTools>[]\n response: LanguageModelResponseMetadata & { messages: ModelMessage[] }\n}\n\n/**\n * A wrapper around {@link WorkflowAgent} that adds a non-streaming\n * `.generate()` method alongside the existing `.stream()`.\n *\n * - `.stream()` — delegates to `WorkflowAgent.stream()`. Each tool call is\n * an individually retriable workflow step. Supports `needsApproval` on tools.\n * - `.generate()` — uses `generateText` from the AI SDK for non-streaming\n * execution. Must be called from within a `\"use step\"` function in\n * workflow context (the Workflow runtime blocks raw I/O in workflow scope).\n */\nexport class DurableGithubAgent<TTools extends ToolSet = ToolSet> {\n private agent: WorkflowAgent<TTools>\n private _model: LanguageModel\n private _instructions?: string\n private _telemetry?: TelemetryOptions\n private _tools: TTools\n\n constructor(options: WorkflowAgentOptions<TTools>) {\n this.agent = new WorkflowAgent(options)\n this._model = options.model\n this._instructions = typeof options.instructions === 'string' ? options.instructions : undefined\n this._telemetry = options.telemetry\n this._tools = options.tools ?? {} as TTools\n }\n\n /** The tool set configured for this agent. */\n get tools(): TTools {\n return this.agent.tools\n }\n\n /**\n * Stream the agent's response. Delegates directly to `WorkflowAgent.stream()`.\n * Works in workflow context — each tool call is a durable step.\n */\n stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(\n options: WorkflowAgentStreamOptions<TStreamTools, Context, OUTPUT, PARTIAL_OUTPUT>,\n ): Promise<WorkflowAgentStreamResult<TStreamTools, OUTPUT>> {\n return this.agent.stream(options)\n }\n\n /**\n * Generate a non-streaming response using `generateText` from the AI SDK.\n *\n * In workflow context this **must** be called from within a `\"use step\"`\n * function, because the Workflow runtime blocks direct I/O (HTTP calls)\n * at the workflow scope level.\n */\n async generate({ prompt, stopWhen }: { prompt: string, stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>> }): Promise<DurableGithubAgentGenerateResult<TTools>> {\n const { generateText } = await import('ai')\n\n const system = this._instructions\n\n const result = await generateText({\n model: this._model,\n tools: this._tools,\n system,\n prompt,\n stopWhen,\n experimental_telemetry: this._telemetry as Parameters<typeof generateText>[0]['experimental_telemetry'],\n })\n\n return {\n text: result.text,\n finishReason: result.finishReason,\n usage: result.usage,\n steps: result.steps as StepResult<TTools>[],\n response: result.response,\n }\n }\n}\n\n/**\n * Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.\n *\n * Extends all `WorkflowAgentOptions` (temperature, telemetry, callbacks, etc.)\n * and adds GitHub-specific fields (token, preset, approval config).\n */\nexport type CreateDurableGithubAgentOptions =\n Omit<WorkflowAgentOptions, 'model' | 'tools' | 'instructions'> & {\n model: string | LanguageModel\n /**\n * GitHub personal access token.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?:
|
|
1
|
+
{"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { WorkflowAgent } from '@ai-sdk/workflow'\nimport type {\n WorkflowAgentOptions,\n WorkflowAgentStreamOptions,\n WorkflowAgentStreamResult,\n TelemetryOptions,\n} from '@ai-sdk/workflow'\nimport type {\n LanguageModel,\n ToolSet,\n StepResult,\n FinishReason,\n LanguageModelUsage,\n LanguageModelResponseMetadata,\n ModelMessage,\n StopCondition,\n} from 'ai'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport type { AllGithubTools } from './core/tool-types'\nimport type { CombinedPresetToolNames, GithubToolPreset, PresetToolName } from './core/presets'\nimport type { GithubToolName } from './core/tool-names'\nimport type { ApprovalConfig } from './index'\nimport type { CommitIdentity } from './types'\nimport type { GithubTokenInput } from './core/token'\nimport type { Context } from '@ai-sdk/provider-utils'\n\n/**\n * Result of {@link DurableGithubAgent.generate}.\n */\nexport interface DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> {\n text: string\n finishReason: FinishReason\n usage: LanguageModelUsage\n steps: StepResult<TTools>[]\n response: LanguageModelResponseMetadata & { messages: ModelMessage[] }\n}\n\n/**\n * A wrapper around {@link WorkflowAgent} that adds a non-streaming\n * `.generate()` method alongside the existing `.stream()`.\n *\n * - `.stream()` — delegates to `WorkflowAgent.stream()`. Each tool call is\n * an individually retriable workflow step. Supports `needsApproval` on tools.\n * - `.generate()` — uses `generateText` from the AI SDK for non-streaming\n * execution. Must be called from within a `\"use step\"` function in\n * workflow context (the Workflow runtime blocks raw I/O in workflow scope).\n */\nexport class DurableGithubAgent<TTools extends ToolSet = ToolSet> {\n private agent: WorkflowAgent<TTools>\n private _model: LanguageModel\n private _instructions?: string\n private _telemetry?: TelemetryOptions\n private _tools: TTools\n\n constructor(options: WorkflowAgentOptions<TTools>) {\n this.agent = new WorkflowAgent(options)\n this._model = options.model\n this._instructions = typeof options.instructions === 'string' ? options.instructions : undefined\n this._telemetry = options.telemetry\n this._tools = options.tools ?? {} as TTools\n }\n\n /** The tool set configured for this agent. */\n get tools(): TTools {\n return this.agent.tools\n }\n\n /**\n * Stream the agent's response. Delegates directly to `WorkflowAgent.stream()`.\n * Works in workflow context — each tool call is a durable step.\n */\n stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(\n options: WorkflowAgentStreamOptions<TStreamTools, Context, OUTPUT, PARTIAL_OUTPUT>,\n ): Promise<WorkflowAgentStreamResult<TStreamTools, OUTPUT>> {\n return this.agent.stream(options)\n }\n\n /**\n * Generate a non-streaming response using `generateText` from the AI SDK.\n *\n * In workflow context this **must** be called from within a `\"use step\"`\n * function, because the Workflow runtime blocks direct I/O (HTTP calls)\n * at the workflow scope level.\n */\n async generate({ prompt, stopWhen }: { prompt: string, stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>> }): Promise<DurableGithubAgentGenerateResult<TTools>> {\n const { generateText } = await import('ai')\n\n const system = this._instructions\n\n const result = await generateText({\n model: this._model,\n tools: this._tools,\n system,\n prompt,\n stopWhen,\n experimental_telemetry: this._telemetry as Parameters<typeof generateText>[0]['experimental_telemetry'],\n })\n\n return {\n text: result.text,\n finishReason: result.finishReason,\n usage: result.usage,\n steps: result.steps as StepResult<TTools>[],\n response: result.response,\n }\n }\n}\n\n/**\n * Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.\n *\n * Extends all `WorkflowAgentOptions` (temperature, telemetry, callbacks, etc.)\n * and adds GitHub-specific fields (token, preset, approval config).\n */\nexport type CreateDurableGithubAgentOptions =\n Omit<WorkflowAgentOptions, 'model' | 'tools' | 'instructions'> & {\n model: string | LanguageModel\n /**\n * GitHub personal access token or async token provider.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?: GithubTokenInput\n /**\n * Restrict tools and system prompt to a predefined preset.\n *\n * Selects a subset of tools and, when a single preset is passed,\n * sets a matching system prompt. Combine presets with an array to merge tool sets.\n *\n * @see {@link GithubToolPreset} for available presets and included tools.\n */\n preset?: GithubToolPreset | GithubToolPreset[]\n /**\n * Control whether write operations require user approval before execution.\n *\n * @see {@link ApprovalConfig} for global and per-tool options.\n */\n requireApproval?: ApprovalConfig\n /**\n * Fully replace the default system prompt.\n * When set, `preset` system prompts and `additionalInstructions` are ignored.\n */\n instructions?: string\n /**\n * Append text to the preset-specific (or default) system prompt.\n * Ignored when `instructions` is set.\n */\n additionalInstructions?: string\n /**\n * Default author for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n author?: CommitIdentity\n /**\n * Default committer for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n committer?: CommitIdentity\n /**\n * Co-authors to attribute on all commits.\n * Added as \"Co-authored-by\" trailers to commit messages.\n */\n coAuthors?: CommitIdentity[]\n }\n\n/**\n * Create a pre-configured durable GitHub agent powered by `WorkflowAgent`\n * from `@ai-sdk/workflow`.\n *\n * Returns a {@link DurableGithubAgent} with two interaction modes:\n *\n * - `.stream()` — works directly in workflow scope; each tool call is a durable step.\n * Write tools honor `requireApproval` via `needsApproval` and pause the workflow\n * until the user approves or denies.\n * - `.generate()` — uses `generateText` from the AI SDK; must be called from\n * within a `\"use step\"` function when running inside a workflow.\n *\n * @example Streaming (chat UI — works in workflow scope)\n * ```ts\n * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'\n * import { getWritable } from 'workflow'\n * import type { ModelMessage, ModelCallStreamPart } from 'ai'\n *\n * async function chatWorkflow(messages: ModelMessage[], token: string) {\n * \"use workflow\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-sonnet-4.6',\n * token,\n * preset: 'code-review',\n * })\n * const writable = getWritable<ModelCallStreamPart>()\n * await agent.stream({ messages, writable })\n * }\n * ```\n */\nexport function createDurableGithubAgent(\n options: CreateDurableGithubAgentOptions & { preset?: undefined },\n): DurableGithubAgent<AllGithubTools>\nexport function createDurableGithubAgent<P extends GithubToolPreset>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, PresetToolName<P>>>\nexport function createDurableGithubAgent<P extends readonly GithubToolPreset[]>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, CombinedPresetToolNames<P>>>\nexport function createDurableGithubAgent({\n model,\n token,\n preset,\n requireApproval,\n instructions,\n additionalInstructions,\n author,\n committer,\n coAuthors,\n ...agentOptions\n}: CreateDurableGithubAgentOptions): DurableGithubAgent<AllGithubTools | Pick<AllGithubTools, GithubToolName>> {\n const tools = createGithubTools({ token, requireApproval, preset, author, committer, coAuthors })\n\n return new DurableGithubAgent({\n ...agentOptions,\n model,\n tools,\n instructions: resolveInstructions({ preset, instructions, additionalInstructions }),\n }) as DurableGithubAgent<typeof tools>\n}\n\nexport { createGithubTools, createGithubAgent } from './index'\nexport type { CommitIdentity, CommitToolOptions, GithubTools, GithubToolsOptions, GithubToolPreset, GithubToolName, GithubWriteToolName, ApprovalConfig, ToolOverrides, AllGithubTools, PresetToolName, CombinedPresetToolNames, GithubToolsForPreset, PickGithubTools, GithubTokenInput } from './index'\nexport { PRESET_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, resolveGithubToken } from './index'\nexport type { CreateGithubAgentOptions } from './agents'\n"],"mappings":";;;;;;;;;;;;;;AAgDA,IAAa,qBAAb,MAAkE;CAChE;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAuC;AACjD,OAAK,QAAQ,IAAI,cAAc,QAAQ;AACvC,OAAK,SAAS,QAAQ;AACtB,OAAK,gBAAgB,OAAO,QAAQ,iBAAiB,WAAW,QAAQ,eAAe,KAAA;AACvF,OAAK,aAAa,QAAQ;AAC1B,OAAK,SAAS,QAAQ,SAAS,EAAE;;;CAInC,IAAI,QAAgB;AAClB,SAAO,KAAK,MAAM;;;;;;CAOpB,OACE,SAC0D;AAC1D,SAAO,KAAK,MAAM,OAAO,QAAQ;;;;;;;;;CAUnC,MAAM,SAAS,EAAE,QAAQ,YAAoJ;EAC3K,MAAM,EAAE,iBAAiB,MAAM,OAAO;EAEtC,MAAM,SAAS,KAAK;EAEpB,MAAM,SAAS,MAAM,aAAa;GAChC,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ;GACA;GACA;GACA,wBAAwB,KAAK;GAC9B,CAAC;AAEF,SAAO;GACL,MAAM,OAAO;GACb,cAAc,OAAO;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,UAAU,OAAO;GAClB;;;AAmGL,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,cACA,wBACA,QACA,WACA,WACA,GAAG,gBAC0G;CAC7G,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ;EAAQ;EAAW;EAAW,CAAC;AAEjG,QAAO,IAAI,mBAAmB;EAC5B,GAAG;EACH;EACA;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB,CAAC;EACpF,CAAC"}
|
|
@@ -462,6 +462,30 @@ function getFileContentToModelOutput({ output }) {
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
//#endregion
|
|
465
|
+
//#region src/core/token.ts
|
|
466
|
+
const TOKEN_REQUIRED_ERROR = "GitHub token is required. Pass it as `token` or set the GITHUB_TOKEN environment variable.";
|
|
467
|
+
/**
|
|
468
|
+
* Normalizes a token string, async token provider, or `process.env.GITHUB_TOKEN`
|
|
469
|
+
* into a `() => Promise<string>` resolver.
|
|
470
|
+
*
|
|
471
|
+
* Throws immediately for static inputs when no token is available. Provider
|
|
472
|
+
* functions are validated lazily, each time the resolver is invoked.
|
|
473
|
+
*/
|
|
474
|
+
function createGithubTokenResolver(token) {
|
|
475
|
+
if (typeof token === "function") return async () => {
|
|
476
|
+
const resolvedToken = await token();
|
|
477
|
+
if (!resolvedToken) throw new Error(TOKEN_REQUIRED_ERROR);
|
|
478
|
+
return resolvedToken;
|
|
479
|
+
};
|
|
480
|
+
const resolvedToken = token || process.env.GITHUB_TOKEN;
|
|
481
|
+
if (!resolvedToken) throw new Error(TOKEN_REQUIRED_ERROR);
|
|
482
|
+
return async () => resolvedToken;
|
|
483
|
+
}
|
|
484
|
+
/** Resolves a {@link GithubTokenInput} to a token string. */
|
|
485
|
+
function resolveGithubToken(token) {
|
|
486
|
+
return createGithubTokenResolver(token)();
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
465
489
|
//#region src/core/pull-requests.ts
|
|
466
490
|
const listPullRequestsInputSchema = z.object({
|
|
467
491
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1762,13 +1786,6 @@ const GITHUB_TOOL_NAMES = {
|
|
|
1762
1786
|
};
|
|
1763
1787
|
const ALL_GITHUB_TOOL_NAMES = Object.values(GITHUB_TOOL_NAMES);
|
|
1764
1788
|
//#endregion
|
|
1765
|
-
//#region src/core/token.ts
|
|
1766
|
-
function resolveGithubToken(token) {
|
|
1767
|
-
const resolvedToken = token || process.env.GITHUB_TOKEN;
|
|
1768
|
-
if (!resolvedToken) throw new Error("GitHub token is required. Pass it as `token` or set the GITHUB_TOKEN environment variable.");
|
|
1769
|
-
return resolvedToken;
|
|
1770
|
-
}
|
|
1771
|
-
//#endregion
|
|
1772
1789
|
//#region src/core/write-tools.ts
|
|
1773
1790
|
/**
|
|
1774
1791
|
* Write tools that mutate GitHub state. All require user approval by default
|
|
@@ -1818,6 +1835,6 @@ const GITHUB_WRITE_TOOLS = {
|
|
|
1818
1835
|
};
|
|
1819
1836
|
Object.values(GITHUB_WRITE_TOOLS);
|
|
1820
1837
|
//#endregion
|
|
1821
|
-
export {
|
|
1838
|
+
export { getCommitInputSchema as $, listPullRequestsInputSchema as $t, createGistCore as A, removeLabelCore as At, listGistCommentsDescription as B, createPullRequestReviewDescription as Bt, rerunWorkflowRunInputSchema as C, getRepositoryCore as Cn, getIssueInputSchema as Ct, createGistCommentCore as D, listBranchesDescription as Dn, listLabelsCore as Dt, triggerWorkflowInputSchema as E, listBranchesCore as En, listIssuesInputSchema as Et, deleteGistInputSchema as F, addPullRequestCommentInputSchema as Ft, updateGistCore as G, listPullRequestFilesCore as Gt, listGistsCore as H, getPullRequestCore as Ht, getGistCore as I, createPullRequestCore as It, getBlameCore as J, listPullRequestReviewsCore as Jt, updateGistDescription as K, listPullRequestFilesDescription as Kt, getGistDescription as L, createPullRequestDescription as Lt, createGistInputSchema as M, removeLabelInputSchema as Mt, deleteGistCore as N, addPullRequestCommentCore as Nt, createGistCommentDescription as O, listBranchesInputSchema as On, listLabelsDescription as Ot, deleteGistDescription as P, addPullRequestCommentDescription as Pt, getCommitDescription as Q, listPullRequestsDescription as Qt, getGistInputSchema as R, createPullRequestInputSchema as Rt, rerunWorkflowRunDescription as S, getFileContentInputSchema as Sn, getIssueDescription as St, triggerWorkflowDescription as T, getRepositoryInputSchema as Tn, listIssuesDescription as Tt, listGistsDescription as U, getPullRequestDescription as Ut, listGistCommentsInputSchema as V, createPullRequestReviewInputSchema as Vt, listGistsInputSchema as W, getPullRequestInputSchema as Wt, getBlameInputSchema as X, listPullRequestReviewsInputSchema as Xt, getBlameDescription as Y, listPullRequestReviewsDescription as Yt, getCommitCore as Z, listPullRequestsCore as Zt, listWorkflowRunsInputSchema as _, forkRepositoryCore as _n, closeIssueInputSchema as _t, resolvePresetTools as a, getCommitToModelOutput as an, searchCodeInputSchema as at, listWorkflowsInputSchema as b, getFileContentCore as bn, createIssueInputSchema as bt, cancelWorkflowRunInputSchema as c, createBranchCore as cn, searchRepositoriesInputSchema as ct, getWorkflowRunInputSchema as d, createOrUpdateFileCore as dn, addIssueCommentInputSchema as dt, mergePullRequestCore as en, listCommitsCore as et, listWorkflowJobsCore as f, createOrUpdateFileDescription as fn, addLabelsCore as ft, listWorkflowRunsDescription as g, createRepositoryInputSchema as gn, closeIssueDescription as gt, listWorkflowRunsCore as h, createRepositoryDescription as hn, closeIssueCore as ht, PRESET_TOOLS as i, resolveGithubToken as in, searchCodeDescription as it, createGistDescription as j, removeLabelDescription as jt, createGistCommentInputSchema as k, createOctokit as kn, listLabelsInputSchema as kt, getWorkflowRunCore as l, createBranchDescription as ln, addIssueCommentCore as lt, listWorkflowJobsInputSchema as m, createRepositoryCore as mn, addLabelsInputSchema as mt, ALL_GITHUB_TOOL_NAMES as n, mergePullRequestInputSchema as nn, listCommitsInputSchema as nt, cancelWorkflowRunCore as o, getFileContentToModelOutput as on, searchRepositoriesCore as ot, listWorkflowJobsDescription as p, createOrUpdateFileInputSchema as pn, addLabelsDescription as pt, updateGistInputSchema as q, listPullRequestFilesInputSchema as qt, GITHUB_TOOL_NAMES as r, createGithubTokenResolver as rn, searchCodeCore as rt, cancelWorkflowRunDescription as s, listPullRequestFilesToModelOutput as sn, searchRepositoriesDescription as st, GITHUB_WRITE_TOOLS as t, mergePullRequestDescription as tn, listCommitsDescription as tt, getWorkflowRunDescription as u, createBranchInputSchema as un, addIssueCommentDescription as ut, listWorkflowsCore as v, forkRepositoryDescription as vn, createIssueCore as vt, triggerWorkflowCore as w, getRepositoryDescription as wn, listIssuesCore as wt, rerunWorkflowRunCore as x, getFileContentDescription as xn, getIssueCore as xt, listWorkflowsDescription as y, forkRepositoryInputSchema as yn, createIssueDescription as yt, listGistCommentsCore as z, createPullRequestReviewCore as zt };
|
|
1822
1839
|
|
|
1823
|
-
//# sourceMappingURL=write-tools-
|
|
1840
|
+
//# sourceMappingURL=write-tools-Dx9LfYlU.mjs.map
|