@github-tools/sdk 1.5.0 → 1.7.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.
@@ -0,0 +1,812 @@
1
+ import { $ as getCommitDescription, $t as listPullRequestsDescription, A as createGistCommentInputSchema, At as listLabelsInputSchema, B as listGistCommentsCore, Bt as createPullRequestReviewCore, C as rerunWorkflowRunDescription, Cn as getRepositoryDescription, Ct as getIssueDescription, D as triggerWorkflowInputSchema, Dn as listBranchesInputSchema, Dt as listIssuesInputSchema, E as triggerWorkflowDescription, En as listBranchesDescription, Et as listIssuesDescription, F as deleteGistDescription, Ft as addPullRequestCommentDescription, G as listGistsInputSchema, Gt as getPullRequestInputSchema, H as listGistCommentsInputSchema, Ht as createPullRequestReviewInputSchema, I as deleteGistInputSchema, It as addPullRequestCommentInputSchema, J as updateGistInputSchema, Jt as listPullRequestFilesInputSchema, K as updateGistCore, Kt as listPullRequestFilesCore, L as getGistCore, Lt as createPullRequestCore, M as createGistDescription, Mt as removeLabelDescription, N as createGistInputSchema, Nt as removeLabelInputSchema, O as createGistCommentCore, Ot as listLabelsCore, P as deleteGistCore, Pt as addPullRequestCommentCore, Q as getCommitCore, Qt as listPullRequestsCore, R as getGistDescription, Rt as createPullRequestDescription, S as rerunWorkflowRunCore, Sn as getRepositoryCore, St as getIssueCore, T as triggerWorkflowCore, Tn as listBranchesCore, Tt as listIssuesCore, U as listGistsCore, Ut as getPullRequestCore, V as listGistCommentsDescription, Vt as createPullRequestReviewDescription, W as listGistsDescription, Wt as getPullRequestDescription, X as getBlameDescription, Xt as listPullRequestReviewsDescription, Y as getBlameCore, Yt as listPullRequestReviewsCore, Z as getBlameInputSchema, Zt as listPullRequestReviewsInputSchema, _ as listWorkflowRunsDescription, _n as forkRepositoryDescription, _t as closeIssueDescription, an as getFileContentToModelOutput, at as searchCodeDescription, b as listWorkflowsDescription, bn as getFileContentDescription, bt as createIssueDescription, c as cancelWorkflowRunDescription, cn as createBranchDescription, ct as searchRepositoriesDescription, d as getWorkflowRunDescription, dn as createOrUpdateFileDescription, dt as addIssueCommentDescription, en as listPullRequestsInputSchema, et as getCommitInputSchema, f as getWorkflowRunInputSchema, fn as createOrUpdateFileInputSchema, ft as addIssueCommentInputSchema, g as listWorkflowRunsCore, gn as forkRepositoryCore, gt as closeIssueCore, h as listWorkflowJobsInputSchema, hn as createRepositoryInputSchema, ht as addLabelsInputSchema, in as getCommitToModelOutput, it as searchCodeCore, j as createGistCore, jt as removeLabelCore, k as createGistCommentDescription, kt as listLabelsDescription, l as cancelWorkflowRunInputSchema, ln as createBranchInputSchema, lt as searchRepositoriesInputSchema, m as listWorkflowJobsDescription, mn as createRepositoryDescription, mt as addLabelsDescription, n as resolveGithubToken, nn as mergePullRequestDescription, nt as listCommitsDescription, o as resolvePresetTools, on as listPullRequestFilesToModelOutput, ot as searchCodeInputSchema, p as listWorkflowJobsCore, pn as createRepositoryCore, pt as addLabelsCore, q as updateGistDescription, qt as listPullRequestFilesDescription, rn as mergePullRequestInputSchema, rt as listCommitsInputSchema, s as cancelWorkflowRunCore, sn as createBranchCore, st as searchRepositoriesCore, tn as mergePullRequestCore, tt as listCommitsCore, u as getWorkflowRunCore, un as createOrUpdateFileCore, ut as addIssueCommentCore, v as listWorkflowRunsInputSchema, vn as forkRepositoryInputSchema, vt as closeIssueInputSchema, w as rerunWorkflowRunInputSchema, wn as getRepositoryInputSchema, wt as getIssueInputSchema, x as listWorkflowsInputSchema, xn as getFileContentInputSchema, xt as createIssueInputSchema, y as listWorkflowsCore, yn as getFileContentCore, yt as createIssueCore, z as getGistInputSchema, zt as createPullRequestInputSchema } from "./write-tools-vzlewWo5.mjs";
2
+ import { ToolLoopAgent, tool } from "ai";
3
+ //#region src/tools/repository.ts
4
+ async function getRepositoryStep(args) {
5
+ "use step";
6
+ return getRepositoryCore(args);
7
+ }
8
+ /** Get information about a GitHub repository including description, stars, forks, language, and default branch. */
9
+ const getRepository = (token) => tool({
10
+ description: getRepositoryDescription,
11
+ inputSchema: getRepositoryInputSchema,
12
+ execute: async (args) => getRepositoryStep({
13
+ token,
14
+ ...args
15
+ })
16
+ });
17
+ async function listBranchesStep(args) {
18
+ "use step";
19
+ return listBranchesCore(args);
20
+ }
21
+ /** List branches in a GitHub repository. */
22
+ const listBranches = (token) => tool({
23
+ description: listBranchesDescription,
24
+ inputSchema: listBranchesInputSchema,
25
+ execute: async (args) => listBranchesStep({
26
+ token,
27
+ ...args
28
+ })
29
+ });
30
+ async function getFileContentStep(args) {
31
+ "use step";
32
+ return getFileContentCore(args);
33
+ }
34
+ /** Get the content of a file from a GitHub repository. */
35
+ const getFileContent = (token) => tool({
36
+ description: getFileContentDescription,
37
+ inputSchema: getFileContentInputSchema,
38
+ toModelOutput: getFileContentToModelOutput,
39
+ execute: async (args) => getFileContentStep({
40
+ token,
41
+ ...args
42
+ })
43
+ });
44
+ async function createBranchStep(args) {
45
+ "use step";
46
+ return createBranchCore(args);
47
+ }
48
+ /** Create a new branch in a GitHub repository from an existing branch or commit SHA. Requires approval by default. */
49
+ const createBranch = (token, { needsApproval = true } = {}) => tool({
50
+ description: createBranchDescription,
51
+ needsApproval,
52
+ inputSchema: createBranchInputSchema,
53
+ execute: async (args) => createBranchStep({
54
+ token,
55
+ ...args
56
+ })
57
+ });
58
+ async function forkRepositoryStep(args) {
59
+ "use step";
60
+ return forkRepositoryCore(args);
61
+ }
62
+ /** Fork a GitHub repository to the authenticated user account or a specified organization. Requires approval by default. */
63
+ const forkRepository = (token, { needsApproval = true } = {}) => tool({
64
+ description: forkRepositoryDescription,
65
+ needsApproval,
66
+ inputSchema: forkRepositoryInputSchema,
67
+ execute: async (args) => forkRepositoryStep({
68
+ token,
69
+ ...args
70
+ })
71
+ });
72
+ async function createRepositoryStep(args) {
73
+ "use step";
74
+ return createRepositoryCore(args);
75
+ }
76
+ /** Create a new GitHub repository for the authenticated user or a specified organization. Requires approval by default. */
77
+ const createRepository = (token, { needsApproval = true } = {}) => tool({
78
+ description: createRepositoryDescription,
79
+ needsApproval,
80
+ inputSchema: createRepositoryInputSchema,
81
+ execute: async (args) => createRepositoryStep({
82
+ token,
83
+ ...args
84
+ })
85
+ });
86
+ async function createOrUpdateFileStep(args) {
87
+ "use step";
88
+ return createOrUpdateFileCore(args);
89
+ }
90
+ /** Create or update a file in a GitHub repository. Provide the SHA when updating an existing file. Requires approval by default. */
91
+ const createOrUpdateFile = (token, { needsApproval = true, author, committer, coAuthors } = {}) => tool({
92
+ description: createOrUpdateFileDescription,
93
+ needsApproval,
94
+ inputSchema: createOrUpdateFileInputSchema,
95
+ execute: async (args) => createOrUpdateFileStep({
96
+ token,
97
+ author,
98
+ committer,
99
+ coAuthors,
100
+ ...args
101
+ })
102
+ });
103
+ //#endregion
104
+ //#region src/tools/pull-requests.ts
105
+ async function listPullRequestsStep(args) {
106
+ "use step";
107
+ return listPullRequestsCore(args);
108
+ }
109
+ /** List pull requests for a GitHub repository. */
110
+ const listPullRequests = (token) => tool({
111
+ description: listPullRequestsDescription,
112
+ inputSchema: listPullRequestsInputSchema,
113
+ execute: async (args) => listPullRequestsStep({
114
+ token,
115
+ ...args
116
+ })
117
+ });
118
+ async function getPullRequestStep(args) {
119
+ "use step";
120
+ return getPullRequestCore(args);
121
+ }
122
+ /** Get detailed information about a specific pull request. */
123
+ const getPullRequest = (token) => tool({
124
+ description: getPullRequestDescription,
125
+ inputSchema: getPullRequestInputSchema,
126
+ execute: async (args) => getPullRequestStep({
127
+ token,
128
+ ...args
129
+ })
130
+ });
131
+ async function createPullRequestStep(args) {
132
+ "use step";
133
+ return createPullRequestCore(args);
134
+ }
135
+ /** Create a new pull request in a GitHub repository. Requires approval by default. */
136
+ const createPullRequest = (token, { needsApproval = true } = {}) => tool({
137
+ description: createPullRequestDescription,
138
+ needsApproval,
139
+ inputSchema: createPullRequestInputSchema,
140
+ execute: async (args) => createPullRequestStep({
141
+ token,
142
+ ...args
143
+ })
144
+ });
145
+ async function mergePullRequestStep(args) {
146
+ "use step";
147
+ return mergePullRequestCore(args);
148
+ }
149
+ /** Merge a pull request. Requires approval by default. */
150
+ const mergePullRequest = (token, { needsApproval = true, coAuthors } = {}) => tool({
151
+ description: mergePullRequestDescription,
152
+ needsApproval,
153
+ inputSchema: mergePullRequestInputSchema,
154
+ execute: async (args) => mergePullRequestStep({
155
+ token,
156
+ coAuthors,
157
+ ...args
158
+ })
159
+ });
160
+ async function addPullRequestCommentStep(args) {
161
+ "use step";
162
+ return addPullRequestCommentCore(args);
163
+ }
164
+ /** Add a comment to a pull request. Requires approval by default. */
165
+ const addPullRequestComment = (token, { needsApproval = true } = {}) => tool({
166
+ description: addPullRequestCommentDescription,
167
+ needsApproval,
168
+ inputSchema: addPullRequestCommentInputSchema,
169
+ execute: async (args) => addPullRequestCommentStep({
170
+ token,
171
+ ...args
172
+ })
173
+ });
174
+ async function listPullRequestFilesStep(args) {
175
+ "use step";
176
+ return listPullRequestFilesCore(args);
177
+ }
178
+ /** List files changed in a pull request, including diff status and patch content. */
179
+ const listPullRequestFiles = (token) => tool({
180
+ description: listPullRequestFilesDescription,
181
+ inputSchema: listPullRequestFilesInputSchema,
182
+ toModelOutput: listPullRequestFilesToModelOutput,
183
+ execute: async (args) => listPullRequestFilesStep({
184
+ token,
185
+ ...args
186
+ })
187
+ });
188
+ async function listPullRequestReviewsStep(args) {
189
+ "use step";
190
+ return listPullRequestReviewsCore(args);
191
+ }
192
+ /** List reviews on a pull request (approvals, change requests, and comments). */
193
+ const listPullRequestReviews = (token) => tool({
194
+ description: listPullRequestReviewsDescription,
195
+ inputSchema: listPullRequestReviewsInputSchema,
196
+ execute: async (args) => listPullRequestReviewsStep({
197
+ token,
198
+ ...args
199
+ })
200
+ });
201
+ async function createPullRequestReviewStep(args) {
202
+ "use step";
203
+ return createPullRequestReviewCore(args);
204
+ }
205
+ /** Submit a pull request review with optional inline comments. Requires approval by default. */
206
+ const createPullRequestReview = (token, { needsApproval = true } = {}) => tool({
207
+ description: createPullRequestReviewDescription,
208
+ needsApproval,
209
+ inputSchema: createPullRequestReviewInputSchema,
210
+ execute: async (args) => createPullRequestReviewStep({
211
+ token,
212
+ ...args
213
+ })
214
+ });
215
+ //#endregion
216
+ //#region src/tools/issues.ts
217
+ async function listIssuesStep(args) {
218
+ "use step";
219
+ return listIssuesCore(args);
220
+ }
221
+ /** List issues for a GitHub repository (excludes pull requests). */
222
+ const listIssues = (token) => tool({
223
+ description: listIssuesDescription,
224
+ inputSchema: listIssuesInputSchema,
225
+ execute: async (args) => listIssuesStep({
226
+ token,
227
+ ...args
228
+ })
229
+ });
230
+ async function getIssueStep(args) {
231
+ "use step";
232
+ return getIssueCore(args);
233
+ }
234
+ /** Get detailed information about a specific issue. */
235
+ const getIssue = (token) => tool({
236
+ description: getIssueDescription,
237
+ inputSchema: getIssueInputSchema,
238
+ execute: async (args) => getIssueStep({
239
+ token,
240
+ ...args
241
+ })
242
+ });
243
+ async function createIssueStep(args) {
244
+ "use step";
245
+ return createIssueCore(args);
246
+ }
247
+ /** Create a new issue in a GitHub repository. Requires approval by default. */
248
+ const createIssue = (token, { needsApproval = true } = {}) => tool({
249
+ description: createIssueDescription,
250
+ needsApproval,
251
+ inputSchema: createIssueInputSchema,
252
+ execute: async (args) => createIssueStep({
253
+ token,
254
+ ...args
255
+ })
256
+ });
257
+ async function addIssueCommentStep(args) {
258
+ "use step";
259
+ return addIssueCommentCore(args);
260
+ }
261
+ /** Add a comment to a GitHub issue. Requires approval by default. */
262
+ const addIssueComment = (token, { needsApproval = true } = {}) => tool({
263
+ description: addIssueCommentDescription,
264
+ needsApproval,
265
+ inputSchema: addIssueCommentInputSchema,
266
+ execute: async (args) => addIssueCommentStep({
267
+ token,
268
+ ...args
269
+ })
270
+ });
271
+ async function closeIssueStep(args) {
272
+ "use step";
273
+ return closeIssueCore(args);
274
+ }
275
+ /** Close an open GitHub issue. Requires approval by default. */
276
+ const closeIssue = (token, { needsApproval = true } = {}) => tool({
277
+ description: closeIssueDescription,
278
+ needsApproval,
279
+ inputSchema: closeIssueInputSchema,
280
+ execute: async (args) => closeIssueStep({
281
+ token,
282
+ ...args
283
+ })
284
+ });
285
+ async function listLabelsStep(args) {
286
+ "use step";
287
+ return listLabelsCore(args);
288
+ }
289
+ /** List labels available in a GitHub repository. */
290
+ const listLabels = (token) => tool({
291
+ description: listLabelsDescription,
292
+ inputSchema: listLabelsInputSchema,
293
+ execute: async (args) => listLabelsStep({
294
+ token,
295
+ ...args
296
+ })
297
+ });
298
+ async function addLabelsStep(args) {
299
+ "use step";
300
+ return addLabelsCore(args);
301
+ }
302
+ /** Add labels to an issue or pull request. Requires approval by default. */
303
+ const addLabels = (token, { needsApproval = true } = {}) => tool({
304
+ description: addLabelsDescription,
305
+ needsApproval,
306
+ inputSchema: addLabelsInputSchema,
307
+ execute: async (args) => addLabelsStep({
308
+ token,
309
+ ...args
310
+ })
311
+ });
312
+ async function removeLabelStep(args) {
313
+ "use step";
314
+ return removeLabelCore(args);
315
+ }
316
+ /** Remove a label from an issue or pull request. Requires approval by default. */
317
+ const removeLabel = (token, { needsApproval = true } = {}) => tool({
318
+ description: removeLabelDescription,
319
+ needsApproval,
320
+ inputSchema: removeLabelInputSchema,
321
+ execute: async (args) => removeLabelStep({
322
+ token,
323
+ ...args
324
+ })
325
+ });
326
+ //#endregion
327
+ //#region src/tools/search.ts
328
+ async function searchCodeStep(args) {
329
+ "use step";
330
+ return searchCodeCore(args);
331
+ }
332
+ /** Search for code in GitHub repositories. Use qualifiers like "repo:owner/name" to scope the search. */
333
+ const searchCode = (token) => tool({
334
+ description: searchCodeDescription,
335
+ inputSchema: searchCodeInputSchema,
336
+ execute: async (args) => searchCodeStep({
337
+ token,
338
+ ...args
339
+ })
340
+ });
341
+ async function searchRepositoriesStep(args) {
342
+ "use step";
343
+ return searchRepositoriesCore(args);
344
+ }
345
+ /** Search for GitHub repositories by keyword, topic, language, or other qualifiers. */
346
+ const searchRepositories = (token) => tool({
347
+ description: searchRepositoriesDescription,
348
+ inputSchema: searchRepositoriesInputSchema,
349
+ execute: async (args) => searchRepositoriesStep({
350
+ token,
351
+ ...args
352
+ })
353
+ });
354
+ //#endregion
355
+ //#region src/tools/commits.ts
356
+ async function listCommitsStep(args) {
357
+ "use step";
358
+ return listCommitsCore(args);
359
+ }
360
+ /** List commits for a GitHub repository. Filter by file path to see commits that touched a file. */
361
+ const listCommits = (token) => tool({
362
+ description: listCommitsDescription,
363
+ inputSchema: listCommitsInputSchema,
364
+ execute: async (args) => listCommitsStep({
365
+ token,
366
+ ...args
367
+ })
368
+ });
369
+ async function getCommitStep(args) {
370
+ "use step";
371
+ return getCommitCore(args);
372
+ }
373
+ /** Get detailed information about a specific commit, including files changed with additions and deletions. */
374
+ const getCommit = (token) => tool({
375
+ description: getCommitDescription,
376
+ inputSchema: getCommitInputSchema,
377
+ toModelOutput: getCommitToModelOutput,
378
+ execute: async (args) => getCommitStep({
379
+ token,
380
+ ...args
381
+ })
382
+ });
383
+ async function getBlameStep(args) {
384
+ "use step";
385
+ return getBlameCore(args);
386
+ }
387
+ /** Line-level git blame for a file at a commit-like ref (branch, tag, or SHA). */
388
+ const getBlame = (token) => tool({
389
+ description: getBlameDescription,
390
+ inputSchema: getBlameInputSchema,
391
+ execute: async (args) => getBlameStep({
392
+ token,
393
+ ...args
394
+ })
395
+ });
396
+ //#endregion
397
+ //#region src/tools/gists.ts
398
+ async function listGistsStep(args) {
399
+ "use step";
400
+ return listGistsCore(args);
401
+ }
402
+ /** List gists for the authenticated user or a specific user. */
403
+ const listGists = (token) => tool({
404
+ description: listGistsDescription,
405
+ inputSchema: listGistsInputSchema,
406
+ execute: async (args) => listGistsStep({
407
+ token,
408
+ ...args
409
+ })
410
+ });
411
+ async function getGistStep(args) {
412
+ "use step";
413
+ return getGistCore(args);
414
+ }
415
+ /** Get a gist by ID, including file contents. */
416
+ const getGist = (token) => tool({
417
+ description: getGistDescription,
418
+ inputSchema: getGistInputSchema,
419
+ execute: async (args) => getGistStep({
420
+ token,
421
+ ...args
422
+ })
423
+ });
424
+ async function listGistCommentsStep(args) {
425
+ "use step";
426
+ return listGistCommentsCore(args);
427
+ }
428
+ /** List comments on a gist. */
429
+ const listGistComments = (token) => tool({
430
+ description: listGistCommentsDescription,
431
+ inputSchema: listGistCommentsInputSchema,
432
+ execute: async (args) => listGistCommentsStep({
433
+ token,
434
+ ...args
435
+ })
436
+ });
437
+ async function createGistStep(args) {
438
+ "use step";
439
+ return createGistCore(args);
440
+ }
441
+ /** Create a new gist with one or more files. Requires approval by default. */
442
+ const createGist = (token, { needsApproval = true } = {}) => tool({
443
+ description: createGistDescription,
444
+ needsApproval,
445
+ inputSchema: createGistInputSchema,
446
+ execute: async (args) => createGistStep({
447
+ token,
448
+ ...args
449
+ })
450
+ });
451
+ async function updateGistStep(args) {
452
+ "use step";
453
+ return updateGistCore(args);
454
+ }
455
+ /** Update an existing gist. Requires approval by default. */
456
+ const updateGist = (token, { needsApproval = true } = {}) => tool({
457
+ description: updateGistDescription,
458
+ needsApproval,
459
+ inputSchema: updateGistInputSchema,
460
+ execute: async (args) => updateGistStep({
461
+ token,
462
+ ...args
463
+ })
464
+ });
465
+ async function deleteGistStep(args) {
466
+ "use step";
467
+ return deleteGistCore(args);
468
+ }
469
+ /** Delete a gist permanently. Requires approval by default. */
470
+ const deleteGist = (token, { needsApproval = true } = {}) => tool({
471
+ description: deleteGistDescription,
472
+ needsApproval,
473
+ inputSchema: deleteGistInputSchema,
474
+ execute: async (args) => deleteGistStep({
475
+ token,
476
+ ...args
477
+ })
478
+ });
479
+ async function createGistCommentStep(args) {
480
+ "use step";
481
+ return createGistCommentCore(args);
482
+ }
483
+ /** Add a comment to a gist. Requires approval by default. */
484
+ const createGistComment = (token, { needsApproval = true } = {}) => tool({
485
+ description: createGistCommentDescription,
486
+ needsApproval,
487
+ inputSchema: createGistCommentInputSchema,
488
+ execute: async (args) => createGistCommentStep({
489
+ token,
490
+ ...args
491
+ })
492
+ });
493
+ //#endregion
494
+ //#region src/tools/workflows.ts
495
+ async function listWorkflowsStep(args) {
496
+ "use step";
497
+ return listWorkflowsCore(args);
498
+ }
499
+ /** List GitHub Actions workflows in a repository. */
500
+ const listWorkflows = (token) => tool({
501
+ description: listWorkflowsDescription,
502
+ inputSchema: listWorkflowsInputSchema,
503
+ execute: async (args) => listWorkflowsStep({
504
+ token,
505
+ ...args
506
+ })
507
+ });
508
+ async function listWorkflowRunsStep(args) {
509
+ "use step";
510
+ return listWorkflowRunsCore(args);
511
+ }
512
+ /** List workflow runs for a repository, optionally filtered by workflow, branch, status, or event. */
513
+ const listWorkflowRuns = (token) => tool({
514
+ description: listWorkflowRunsDescription,
515
+ inputSchema: listWorkflowRunsInputSchema,
516
+ execute: async (args) => listWorkflowRunsStep({
517
+ token,
518
+ ...args
519
+ })
520
+ });
521
+ async function getWorkflowRunStep(args) {
522
+ "use step";
523
+ return getWorkflowRunCore(args);
524
+ }
525
+ /** Get details of a specific workflow run including status, timing, and trigger info. */
526
+ const getWorkflowRun = (token) => tool({
527
+ description: getWorkflowRunDescription,
528
+ inputSchema: getWorkflowRunInputSchema,
529
+ execute: async (args) => getWorkflowRunStep({
530
+ token,
531
+ ...args
532
+ })
533
+ });
534
+ async function listWorkflowJobsStep(args) {
535
+ "use step";
536
+ return listWorkflowJobsCore(args);
537
+ }
538
+ /** List jobs for a workflow run, including step-level status and timing. */
539
+ const listWorkflowJobs = (token) => tool({
540
+ description: listWorkflowJobsDescription,
541
+ inputSchema: listWorkflowJobsInputSchema,
542
+ execute: async (args) => listWorkflowJobsStep({
543
+ token,
544
+ ...args
545
+ })
546
+ });
547
+ async function triggerWorkflowStep(args) {
548
+ "use step";
549
+ return triggerWorkflowCore(args);
550
+ }
551
+ /** Trigger a workflow via workflow_dispatch event. Requires approval by default. */
552
+ const triggerWorkflow = (token, { needsApproval = true } = {}) => tool({
553
+ description: triggerWorkflowDescription,
554
+ needsApproval,
555
+ inputSchema: triggerWorkflowInputSchema,
556
+ execute: async (args) => triggerWorkflowStep({
557
+ token,
558
+ ...args
559
+ })
560
+ });
561
+ async function cancelWorkflowRunStep(args) {
562
+ "use step";
563
+ return cancelWorkflowRunCore(args);
564
+ }
565
+ /** Cancel an in-progress workflow run. Requires approval by default. */
566
+ const cancelWorkflowRun = (token, { needsApproval = true } = {}) => tool({
567
+ description: cancelWorkflowRunDescription,
568
+ needsApproval,
569
+ inputSchema: cancelWorkflowRunInputSchema,
570
+ execute: async (args) => cancelWorkflowRunStep({
571
+ token,
572
+ ...args
573
+ })
574
+ });
575
+ async function rerunWorkflowRunStep(args) {
576
+ "use step";
577
+ return rerunWorkflowRunCore(args);
578
+ }
579
+ /** Re-run a workflow run, optionally only the failed jobs. Requires approval by default. */
580
+ const rerunWorkflowRun = (token, { needsApproval = true } = {}) => tool({
581
+ description: rerunWorkflowRunDescription,
582
+ needsApproval,
583
+ inputSchema: rerunWorkflowRunInputSchema,
584
+ execute: async (args) => rerunWorkflowRunStep({
585
+ token,
586
+ ...args
587
+ })
588
+ });
589
+ //#endregion
590
+ //#region src/core/approval.ts
591
+ /**
592
+ * Resolve whether a write tool requires approval for the AI SDK.
593
+ *
594
+ * @param toolName - The write tool to check.
595
+ * @param config - Global or per-tool approval config.
596
+ * @returns `true` when approval is required; defaults to `true` for unspecified write tools in object mode.
597
+ */
598
+ function resolveAiSdkApproval(toolName, config) {
599
+ if (typeof config === "boolean") return config;
600
+ return config[toolName] ?? true;
601
+ }
602
+ //#endregion
603
+ //#region src/agents.ts
604
+ const SHARED_RULES = `When a tool execution is denied by the user, do not retry it. Briefly acknowledge the decision and move on.`;
605
+ const DEFAULT_INSTRUCTIONS = `You are a helpful GitHub assistant. You can read and explore repositories, issues, pull requests, commits, code, gists, and workflows. You can also create issues, pull requests, comments, gists, trigger workflows, and update files when asked.
606
+
607
+ ${SHARED_RULES}`;
608
+ const PRESET_INSTRUCTIONS = {
609
+ "code-review": `You are a code review assistant. Your job is to review pull requests thoroughly and provide constructive feedback.
610
+
611
+ When reviewing a PR:
612
+ - Read the PR description and changed files carefully
613
+ - To trace why a specific line exists or who last touched it, use getBlame on the file path and ref (branch or merge commit), then follow up with getCommit if you need the full patch
614
+ - Check for bugs, logic errors, and edge cases
615
+ - Suggest improvements when you spot issues
616
+ - Be constructive — explain why something is a problem and how to fix it
617
+ - Use listPullRequestFiles to see exactly which files changed before diving into details
618
+ - Use createPullRequestReview to submit a formal review with inline comments on specific lines
619
+ - Post your review as PR comments when asked
620
+
621
+ ${SHARED_RULES}`,
622
+ "issue-triage": `You are an issue triage assistant. Your job is to help manage and organize GitHub issues.
623
+
624
+ When triaging issues:
625
+ - Read issue descriptions carefully to understand the problem
626
+ - Identify duplicates when possible
627
+ - Help categorize and prioritize issues
628
+ - Respond to users with clear, helpful information
629
+ - Use listLabels to see available labels, then addLabels and removeLabel to categorize issues
630
+ - Create new issues when asked, with clear titles and descriptions
631
+
632
+ ${SHARED_RULES}`,
633
+ "ci-ops": `You are a CI/CD operations assistant. Your job is to help monitor and manage GitHub Actions workflows.
634
+
635
+ When working with workflows:
636
+ - Check workflow run status and report failures clearly
637
+ - Inspect job steps to identify exactly where a run failed
638
+ - Re-run failed workflows when asked
639
+ - Trigger workflow dispatches with the correct inputs and branch
640
+ - Be careful with cancel and re-run operations — confirm the target run
641
+ - Summarize run history and trends when asked
642
+
643
+ ${SHARED_RULES}`,
644
+ "repo-explorer": `You are a repository explorer. Your job is to help users understand codebases and find information across GitHub repositories.
645
+
646
+ When exploring repos:
647
+ - Answer questions about code structure and organization
648
+ - Use getBlame when the user asks about history or ownership of specific lines in a file
649
+ - Summarize recent activity (commits, PRs, issues)
650
+ - Find specific files, functions, or patterns in code
651
+ - Explain how different parts of the codebase work together
652
+ - You have read-only access — you cannot make changes
653
+
654
+ ${SHARED_RULES}`,
655
+ "maintainer": `You are a repository maintainer assistant. You have full access to manage repositories, issues, pull requests, gists, and workflows.
656
+
657
+ When maintaining repos:
658
+ - Be careful with write operations — review before acting
659
+ - Create well-structured issues and PRs with clear descriptions
660
+ - Use merge strategies appropriate for the repository
661
+ - Keep commit messages clean and descriptive
662
+ - When closing issues, provide a clear reason
663
+
664
+ ${SHARED_RULES}`
665
+ };
666
+ function resolveInstructions(options) {
667
+ const defaultPrompt = options.preset && !Array.isArray(options.preset) ? PRESET_INSTRUCTIONS[options.preset] : DEFAULT_INSTRUCTIONS;
668
+ if (options.instructions) return options.instructions;
669
+ if (options.additionalInstructions) return `${defaultPrompt}\n\n${options.additionalInstructions}`;
670
+ return defaultPrompt;
671
+ }
672
+ /**
673
+ * Create a pre-configured GitHub agent powered by the AI SDK's `ToolLoopAgent`.
674
+ *
675
+ * Returns a `ToolLoopAgent` instance with `.generate()` and `.stream()` methods.
676
+ *
677
+ * @example
678
+ * ```ts
679
+ * import { createGithubAgent } from '@github-tools/sdk'
680
+ *
681
+ * const agent = createGithubAgent({
682
+ * model: 'anthropic/claude-sonnet-4.6',
683
+ * token: process.env.GITHUB_TOKEN!,
684
+ * preset: 'code-review',
685
+ * })
686
+ *
687
+ * const result = await agent.generate({ prompt: 'Review PR #42 on vercel/ai' })
688
+ * ```
689
+ */
690
+ function createGithubAgent({ token, preset, requireApproval, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
691
+ const tools = createGithubTools({
692
+ token,
693
+ requireApproval,
694
+ preset,
695
+ author,
696
+ committer,
697
+ coAuthors
698
+ });
699
+ return new ToolLoopAgent({
700
+ ...agentOptions,
701
+ tools,
702
+ instructions: resolveInstructions({
703
+ preset,
704
+ instructions,
705
+ additionalInstructions
706
+ })
707
+ });
708
+ }
709
+ //#endregion
710
+ //#region src/index.ts
711
+ /**
712
+ * Create a set of GitHub tools for the Vercel AI SDK.
713
+ *
714
+ * Write operations require user approval by default.
715
+ * Control this globally or per-tool via `requireApproval`.
716
+ * Use `preset` to get only the tools you need.
717
+ *
718
+ * @example
719
+ * ```ts
720
+ * // All tools (default)
721
+ * createGithubTools({ token })
722
+ *
723
+ * // Code-review agent — only PR & commit tools
724
+ * createGithubTools({ token, preset: 'code-review' })
725
+ *
726
+ * // Combine presets
727
+ * createGithubTools({ token, preset: ['code-review', 'issue-triage'] })
728
+ *
729
+ * // Granular approval
730
+ * createGithubTools({
731
+ * token,
732
+ * preset: 'maintainer',
733
+ * requireApproval: {
734
+ * mergePullRequest: true,
735
+ * createOrUpdateFile: true,
736
+ * addPullRequestComment: false,
737
+ * }
738
+ * })
739
+ * ```
740
+ */
741
+ function createGithubTools({ token, requireApproval = true, preset, overrides, author, committer, coAuthors } = {}) {
742
+ const resolvedToken = resolveGithubToken(token);
743
+ const approval = (name) => ({ needsApproval: resolveAiSdkApproval(name, requireApproval) });
744
+ const allowed = preset ? resolvePresetTools(preset) : null;
745
+ const allTools = {
746
+ getRepository: getRepository(resolvedToken),
747
+ listBranches: listBranches(resolvedToken),
748
+ getFileContent: getFileContent(resolvedToken),
749
+ listPullRequests: listPullRequests(resolvedToken),
750
+ getPullRequest: getPullRequest(resolvedToken),
751
+ listIssues: listIssues(resolvedToken),
752
+ getIssue: getIssue(resolvedToken),
753
+ searchCode: searchCode(resolvedToken),
754
+ searchRepositories: searchRepositories(resolvedToken),
755
+ listCommits: listCommits(resolvedToken),
756
+ getCommit: getCommit(resolvedToken),
757
+ getBlame: getBlame(resolvedToken),
758
+ createBranch: createBranch(resolvedToken, approval("createBranch")),
759
+ forkRepository: forkRepository(resolvedToken, approval("forkRepository")),
760
+ createRepository: createRepository(resolvedToken, approval("createRepository")),
761
+ createOrUpdateFile: createOrUpdateFile(resolvedToken, {
762
+ ...approval("createOrUpdateFile"),
763
+ author,
764
+ committer,
765
+ coAuthors
766
+ }),
767
+ createPullRequest: createPullRequest(resolvedToken, approval("createPullRequest")),
768
+ mergePullRequest: mergePullRequest(resolvedToken, {
769
+ ...approval("mergePullRequest"),
770
+ coAuthors
771
+ }),
772
+ addPullRequestComment: addPullRequestComment(resolvedToken, approval("addPullRequestComment")),
773
+ listPullRequestFiles: listPullRequestFiles(resolvedToken),
774
+ listPullRequestReviews: listPullRequestReviews(resolvedToken),
775
+ createPullRequestReview: createPullRequestReview(resolvedToken, approval("createPullRequestReview")),
776
+ createIssue: createIssue(resolvedToken, approval("createIssue")),
777
+ addIssueComment: addIssueComment(resolvedToken, approval("addIssueComment")),
778
+ closeIssue: closeIssue(resolvedToken, approval("closeIssue")),
779
+ listLabels: listLabels(resolvedToken),
780
+ addLabels: addLabels(resolvedToken, approval("addLabels")),
781
+ removeLabel: removeLabel(resolvedToken, approval("removeLabel")),
782
+ listGists: listGists(resolvedToken),
783
+ getGist: getGist(resolvedToken),
784
+ listGistComments: listGistComments(resolvedToken),
785
+ createGist: createGist(resolvedToken, approval("createGist")),
786
+ updateGist: updateGist(resolvedToken, approval("updateGist")),
787
+ deleteGist: deleteGist(resolvedToken, approval("deleteGist")),
788
+ createGistComment: createGistComment(resolvedToken, approval("createGistComment")),
789
+ listWorkflows: listWorkflows(resolvedToken),
790
+ listWorkflowRuns: listWorkflowRuns(resolvedToken),
791
+ getWorkflowRun: getWorkflowRun(resolvedToken),
792
+ listWorkflowJobs: listWorkflowJobs(resolvedToken),
793
+ triggerWorkflow: triggerWorkflow(resolvedToken, approval("triggerWorkflow")),
794
+ cancelWorkflowRun: cancelWorkflowRun(resolvedToken, approval("cancelWorkflowRun")),
795
+ rerunWorkflowRun: rerunWorkflowRun(resolvedToken, approval("rerunWorkflowRun"))
796
+ };
797
+ if (overrides) {
798
+ for (const [name, toolOverrides] of Object.entries(overrides)) if (name in allTools && toolOverrides) {
799
+ const key = name;
800
+ Object.assign(allTools, { [key]: {
801
+ ...allTools[key],
802
+ ...toolOverrides
803
+ } });
804
+ }
805
+ }
806
+ if (!allowed) return allTools;
807
+ return Object.fromEntries(Object.entries(allTools).filter(([name]) => allowed.has(name)));
808
+ }
809
+ //#endregion
810
+ export { removeLabel as A, createOrUpdateFile as B, addIssueComment as C, getIssue as D, createIssue as E, listPullRequestFiles as F, listBranches as G, forkRepository as H, listPullRequestReviews as I, listPullRequests as L, createPullRequest as M, createPullRequestReview as N, listIssues as O, getPullRequest as P, mergePullRequest as R, searchRepositories as S, closeIssue as T, getFileContent as U, createRepository as V, getRepository as W, updateGist as _, getWorkflowRun as a, listCommits as b, listWorkflows as c, createGist as d, createGistComment as f, listGists as g, listGistComments as h, cancelWorkflowRun as i, addPullRequestComment as j, listLabels as k, rerunWorkflowRun as l, getGist as m, createGithubAgent as n, listWorkflowJobs as o, deleteGist as p, resolveInstructions as r, listWorkflowRuns as s, createGithubTools as t, triggerWorkflow as u, getBlame as v, addLabels as w, searchCode as x, getCommit as y, createBranch as z };
811
+
812
+ //# sourceMappingURL=src-BgnkKMD7.mjs.map