@github-tools/sdk 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +97 -30
  2. package/dist/approval-policy-CEMMPq92.mjs +17 -0
  3. package/dist/approval-policy-CEMMPq92.mjs.map +1 -0
  4. package/dist/connect/eve.d.mts +2 -2
  5. package/dist/connect/eve.d.mts.map +1 -1
  6. package/dist/connect/eve.mjs +1 -1
  7. package/dist/connect.d.mts +15 -24
  8. package/dist/connect.d.mts.map +1 -1
  9. package/dist/connect.mjs +2 -2
  10. package/dist/{cores-BeLZwcde.mjs → cores-meFAMt2D.mjs} +41 -2
  11. package/dist/cores-meFAMt2D.mjs.map +1 -0
  12. package/dist/{tool-types-CrC80SIL.d.mts → dry-run-DXckOam2.d.mts} +437 -54
  13. package/dist/dry-run-DXckOam2.d.mts.map +1 -0
  14. package/dist/evaluation-DJHINyAu.mjs +311 -0
  15. package/dist/evaluation-DJHINyAu.mjs.map +1 -0
  16. package/dist/{eve-runtime-DRh2QJI7.d.mts → eve-runtime-B_CJE9JV.d.mts} +21 -7
  17. package/dist/eve-runtime-B_CJE9JV.d.mts.map +1 -0
  18. package/dist/{eve-runtime-YTxfrWP-.mjs → eve-runtime-DPzMPCLt.mjs} +49 -15
  19. package/dist/eve-runtime-DPzMPCLt.mjs.map +1 -0
  20. package/dist/eve-runtime.d.mts +5 -5
  21. package/dist/eve-runtime.mjs +4 -4
  22. package/dist/eve.d.mts +95 -4
  23. package/dist/eve.d.mts.map +1 -1
  24. package/dist/eve.mjs +94 -3
  25. package/dist/eve.mjs.map +1 -1
  26. package/dist/{index-DkZvveZP.d.mts → index-CzzrtCVj.d.mts} +119 -348
  27. package/dist/index-CzzrtCVj.d.mts.map +1 -0
  28. package/dist/index.d.mts +3 -3
  29. package/dist/index.mjs +4 -3
  30. package/dist/{interrupts-C_lUXMdd.d.mts → interrupts-BSDPwdJ2.d.mts} +2 -2
  31. package/dist/interrupts-BSDPwdJ2.d.mts.map +1 -0
  32. package/dist/{src-Bx5p1Unc.mjs → src-BlhrSieS.mjs} +491 -23
  33. package/dist/src-BlhrSieS.mjs.map +1 -0
  34. package/dist/tanstack/interrupts.d.mts +1 -1
  35. package/dist/tanstack.d.mts +1705 -204
  36. package/dist/tanstack.d.mts.map +1 -1
  37. package/dist/tanstack.mjs +53 -19
  38. package/dist/tanstack.mjs.map +1 -1
  39. package/dist/{token-Bh8nPj66.mjs → token-BLps09gm.mjs} +36 -116
  40. package/dist/token-BLps09gm.mjs.map +1 -0
  41. package/dist/{types-BmwOpI5-.d.mts → types-Bln8U42J.d.mts} +3 -3
  42. package/dist/{types-BmwOpI5-.d.mts.map → types-Bln8U42J.d.mts.map} +1 -1
  43. package/dist/{types-CPAsEMzx.d.mts → types-C7O2lwwz.d.mts} +14 -2
  44. package/dist/{types-CPAsEMzx.d.mts.map → types-C7O2lwwz.d.mts.map} +1 -1
  45. package/dist/workflow.d.mts +41 -40
  46. package/dist/workflow.d.mts.map +1 -1
  47. package/dist/workflow.mjs +20 -47
  48. package/dist/workflow.mjs.map +1 -1
  49. package/dist/{write-tools-BaoTUCg7.mjs → write-tools-w-8tjnDQ.mjs} +1360 -124
  50. package/dist/write-tools-w-8tjnDQ.mjs.map +1 -0
  51. package/package.json +4 -6
  52. package/dist/cores-BeLZwcde.mjs.map +0 -1
  53. package/dist/evaluation-f-2QwBid.mjs +0 -210
  54. package/dist/evaluation-f-2QwBid.mjs.map +0 -1
  55. package/dist/eve-runtime-DRh2QJI7.d.mts.map +0 -1
  56. package/dist/eve-runtime-YTxfrWP-.mjs.map +0 -1
  57. package/dist/index-DkZvveZP.d.mts.map +0 -1
  58. package/dist/instructions-BuypoY0x.mjs +0 -148
  59. package/dist/instructions-BuypoY0x.mjs.map +0 -1
  60. package/dist/interrupts-C_lUXMdd.d.mts.map +0 -1
  61. package/dist/src-Bx5p1Unc.mjs.map +0 -1
  62. package/dist/token-Bh8nPj66.mjs.map +0 -1
  63. package/dist/tool-types-CrC80SIL.d.mts.map +0 -1
  64. package/dist/write-tools-BaoTUCg7.mjs.map +0 -1
@@ -1,7 +1,8 @@
1
- import { $ as createGistDescription, $i as getRepositoryTreeDescription, $n as mergePullRequestDescription, $r as removeAssigneesDescription, $t as listWorkflowsDescription, A as searchRepositoriesInputSchema, Ai as listCheckRunsInputSchema, An as createPullRequestInputSchema, Ar as createIssueInputSchema, At as getIssueContextInputSchema, B as listIssueReactionsCore, Bi as deleteBranchCore, Bn as listPullRequestFilesCore, Br as getIssueCore, Bt as getWorkflowJobLogsCore, C as searchCodeDescription, Ci as listCommitsDescription, Cn as updateReleaseDescription, Cr as addLabelsDescription, Ct as listDiscussionsDescription, D as searchIssuesInputSchema, Di as getCombinedStatusInputSchema, Dn as addPullRequestCommentInputSchema, Dr as closeIssueInputSchema, Dt as getCiFailureContextInputSchema, E as searchIssuesDescription, Ei as getCombinedStatusDescription, En as addPullRequestCommentDescription, Er as closeIssueDescription, Et as getCiFailureContextDescription, F as addIssueReactionDescription, Fi as createOrUpdateFileDescription, Fn as deletePullRequestCommentDescription, Fr as deleteIssueCommentDescription, Ft as getReleaseContextDescription, G as listNotificationsInputSchema, Gi as forkRepositoryInputSchema, Gn as listPullRequestReviewThreadsInputSchema, Gr as listIssueCommentsInputSchema, Gt as getWorkflowRunInputSchema, H as listIssueReactionsInputSchema, Hi as deleteBranchInputSchema, Hn as listPullRequestFilesInputSchema, Hr as getIssueInputSchema, Ht as getWorkflowJobLogsInputSchema, I as addIssueReactionInputSchema, Ii as createOrUpdateFileInputSchema, In as deletePullRequestCommentInputSchema, Ir as deleteIssueCommentInputSchema, It as getReleaseContextInputSchema, J as markNotificationReadInputSchema, Ji as getFileContentInputSchema, Jn as listPullRequestReviewsInputSchema, Jr as listIssuesInputSchema, Jt as listWorkflowJobsInputSchema, K as markNotificationReadCore, Ki as getFileContentCore, Kn as listPullRequestReviewsCore, Kr as listIssuesCore, Kt as listWorkflowJobsCore, L as listCommentReactionsCore, Li as createRepositoryCore, Ln as getPullRequestCore, Lr as deleteLabelCore, Lt as cancelWorkflowRunCore, M as addCommentReactionDescription, Mi as createBranchDescription, Mn as createPullRequestReviewDescription, Mr as createLabelDescription, Mt as getPullRequestContextDescription, N as addCommentReactionInputSchema, Ni as createBranchInputSchema, Nn as createPullRequestReviewInputSchema, Nr as createLabelInputSchema, Nt as getPullRequestContextInputSchema, O as searchRepositoriesCore, Oi as listCheckRunsCore, On as createPullRequestCore, Or as createIssueCore, Ot as getIssueContextCore, P as addIssueReactionCore, Pi as createOrUpdateFileCore, Pn as deletePullRequestCommentCore, Pr as deleteIssueCommentCore, Pt as getReleaseContextCore, Q as createGistCore, Qi as getRepositoryTreeCore, Qn as mergePullRequestCore, Qr as removeAssigneesCore, Qt as listWorkflowsCore, R as listCommentReactionsDescription, Ri as createRepositoryDescription, Rn as getPullRequestDescription, Rr as deleteLabelDescription, Rt as cancelWorkflowRunDescription, S as searchCodeCore, Si as listCommitsCore, Sn as updateReleaseCore, Sr as addLabelsCore, St as listDiscussionsCore, T as searchIssuesCore, Ti as getCombinedStatusCore, Tn as addPullRequestCommentCore, Tr as closeIssueCore, Tt as getCiFailureContextCore, U as listNotificationsCore, Ui as forkRepositoryCore, Un as listPullRequestReviewThreadsCore, Ur as listIssueCommentsCore, Ut as getWorkflowRunCore, V as listIssueReactionsDescription, Vi as deleteBranchDescription, Vn as listPullRequestFilesDescription, Vr as getIssueDescription, Vt as getWorkflowJobLogsDescription, W as listNotificationsDescription, Wi as forkRepositoryDescription, Wn as listPullRequestReviewThreadsDescription, Wr as listIssueCommentsDescription, Wt as getWorkflowRunDescription, X as createGistCommentDescription, Xi as getRepositoryDescription, Xn as listPullRequestsDescription, Xr as listLabelsDescription, Xt as listWorkflowRunsDescription, Y as createGistCommentCore, Yi as getRepositoryCore, Yn as listPullRequestsCore, Yr as listLabelsCore, Yt as listWorkflowRunsCore, Z as createGistCommentInputSchema, Zi as getRepositoryInputSchema, Zn as listPullRequestsInputSchema, Zr as listLabelsInputSchema, Zt as listWorkflowRunsInputSchema, _ as githubTokenCall, _i as getBlameDescription, _n as getReleaseDescription, _r as addAssigneesDescription, _t as addDiscussionCommentDescription, ai as updateIssueCommentDescription, an as triggerWorkflowDescription, ar as requestReviewersDescription, at as getGistDescription, bi as getCommitDescription, bn as listReleasesDescription, br as addIssueCommentDescription, bt as getDiscussionDescription, ca as stripRateLimit, ci as updateIssueDescription, cn as createReleaseDescription, cr as resolveReviewThreadDescription, ct as listGistCommentsDescription, di as updateLabelDescription, dn as deleteReleaseDescription, dr as updatePullRequestCommentDescription, dt as listGistsDescription, ea as getRepositoryTreeInputSchema, ei as removeAssigneesInputSchema, en as listWorkflowsInputSchema, er as mergePullRequestInputSchema, et as createGistInputSchema, fi as updateLabelInputSchema, fn as deleteReleaseInputSchema, fr as updatePullRequestCommentInputSchema, ft as listGistsInputSchema, g as createGithubTokenResolver, gi as getBlameCore, gn as getReleaseCore, gr as addAssigneesCore, gt as addDiscussionCommentCore, h as resolvePresetTools, hi as compareCommitsInputSchema, hn as getLatestReleaseInputSchema, hr as updatePullRequestInputSchema, ht as updateGistInputSchema, ii as updateIssueCommentCore, in as triggerWorkflowCore, ir as requestReviewersCore, it as getGistCore, j as addCommentReactionCore, ji as createBranchCore, jn as createPullRequestReviewCore, jr as createLabelCore, jt as getPullRequestContextCore, k as searchRepositoriesDescription, ki as listCheckRunsDescription, kn as createPullRequestDescription, kr as createIssueDescription, kt as getIssueContextDescription, li as updateIssueInputSchema, ln as createReleaseInputSchema, lr as resolveReviewThreadInputSchema, lt as listGistCommentsInputSchema, mi as compareCommitsDescription, mn as getLatestReleaseDescription, mr as updatePullRequestDescription, mt as updateGistDescription, na as listBranchesDescription, ni as removeLabelDescription, nn as rerunWorkflowRunDescription, nr as replyToReviewCommentDescription, nt as deleteGistDescription, oi as updateIssueCommentInputSchema, on as triggerWorkflowInputSchema, or as requestReviewersInputSchema, ot as getGistInputSchema, pi as compareCommitsCore, pn as getLatestReleaseCore, pr as updatePullRequestCore, pt as updateGistCore, q as markNotificationReadDescription, qi as getFileContentDescription, qn as listPullRequestReviewsDescription, qr as listIssuesDescription, qt as listWorkflowJobsDescription, r as bindToolsContext, ra as listBranchesInputSchema, ri as removeLabelInputSchema, rn as rerunWorkflowRunInputSchema, rr as replyToReviewCommentInputSchema, rt as deleteGistInputSchema, si as updateIssueCore, sn as createReleaseCore, sr as resolveReviewThreadCore, st as listGistCommentsCore, ta as listBranchesCore, ti as removeLabelCore, tn as rerunWorkflowRunCore, tr as replyToReviewCommentCore, tt as deleteGistCore, ui as updateLabelCore, un as deleteReleaseCore, ur as updatePullRequestCommentCore, ut as listGistsCore, v as resolveGithubToken, vi as getBlameInputSchema, vn as getReleaseInputSchema, vr as addAssigneesInputSchema, vt as addDiscussionCommentInputSchema, w as searchCodeInputSchema, wi as listCommitsInputSchema, wn as updateReleaseInputSchema, wr as addLabelsInputSchema, wt as listDiscussionsInputSchema, xi as getCommitInputSchema, xn as listReleasesInputSchema, xr as addIssueCommentInputSchema, xt as getDiscussionInputSchema, yi as getCommitCore, yn as listReleasesCore, yr as addIssueCommentCore, yt as getDiscussionCore, z as listCommentReactionsInputSchema, zi as createRepositoryInputSchema, zn as getPullRequestInputSchema, zr as deleteLabelInputSchema, zt as cancelWorkflowRunInputSchema } from "./write-tools-BaoTUCg7.mjs";
2
- import { a as getCommitToModelOutput, c as getRepositoryTreeToModelOutput, i as compareCommitsToModelOutput, l as listPullRequestFilesToModelOutput, n as needsAutoApproval, o as getFileContentToModelOutput, r as selectPresets, s as getPullRequestContextToModelOutput } from "./evaluation-f-2QwBid.mjs";
3
- import { n as resolveApprovalMode, t as resolveInstructions } from "./instructions-BuypoY0x.mjs";
4
- import { ToolLoopAgent, tool } from "ai";
1
+ import { $ as listCommentReactionsInputSchema, $a as stripRateLimit, $i as getCommitDescription, $n as disablePullRequestAutoMergeInputSchema, $r as closeIssueDescription, $t as cancelWorkflowRunInputSchema, A as listDependabotAlertsCore, Aa as forkRepositoryInputSchema, Ai as listSubIssuesInputSchema, An as getReleaseCore, Ar as updatePullRequestBranchCore, At as addDiscussionCommentCore, B as searchIssuesDescription, Ba as getRepositoryCore, Bi as updateIssueCore, Bn as addPullRequestCommentDescription, Br as addAssigneesCore, Bt as getCiFailureContextDescription, C as withGithubGuardrails, Ca as deleteBranchDescription, Ci as listLabelsDescription, Cn as createReleaseInputSchema, Cr as replyToReviewCommentInputSchema, Ct as listGistCommentsInputSchema, D as listCodeScanningAlertsCore, Da as editFilesInputSchema, Di as listMilestonesInputSchema, Dn as getLatestReleaseCore, Dr as resolveReviewThreadCore, Dt as updateGistCore, E as isGithubWriteToolName, Ea as editFilesDescription, Ei as listMilestonesDescription, En as deleteReleaseInputSchema, Er as requestReviewersInputSchema, Et as listGistsInputSchema, F as listSecretScanningAlertsInputSchema, Fa as getCollaboratorPermissionDescription, Fi as removeLabelDescription, Fn as listReleasesInputSchema, Fr as updatePullRequestCommentInputSchema, Ft as getDiscussionInputSchema, G as addCommentReactionCore, Ga as getRepositoryTreeInputSchema, Gi as updateLabelInputSchema, Gn as createPullRequestReviewCore, Gr as addIssueCommentInputSchema, Gt as getPullRequestContextCore, H as searchRepositoriesCore, Ha as getRepositoryInputSchema, Hi as updateIssueInputSchema, Hn as createPullRequestCore, Hr as addAssigneesInputSchema, Ht as getIssueContextCore, I as searchCodeCore, Ia as getCollaboratorPermissionInputSchema, Ii as removeLabelInputSchema, In as updateReleaseCore, Ir as updatePullRequestCore, It as listDiscussionsCore, J as addIssueReactionCore, Ja as listBranchesInputSchema, Ji as compareCommitsInputSchema, Jn as deletePullRequestCommentCore, Jr as addLabelsInputSchema, Jt as getReleaseContextCore, K as addCommentReactionDescription, Ka as listBranchesCore, Ki as compareCommitsCore, Kn as createPullRequestReviewDescription, Kr as addLabelsCore, Kt as getPullRequestContextDescription, L as searchCodeDescription, La as getFileContentCore, Li as updateIssueCommentCore, Ln as updateReleaseDescription, Lr as updatePullRequestDescription, Lt as listDiscussionsDescription, M as listDependabotAlertsInputSchema, Ma as getBranchRulesDescription, Mi as removeAssigneesDescription, Mn as getReleaseInputSchema, Mr as updatePullRequestBranchInputSchema, Mt as addDiscussionCommentInputSchema, N as listSecretScanningAlertsCore, Na as getBranchRulesInputSchema, Ni as removeAssigneesInputSchema, Nn as listReleasesCore, Nr as updatePullRequestCommentCore, Nt as getDiscussionCore, O as listCodeScanningAlertsDescription, Oa as forkRepositoryCore, Oi as listSubIssuesCore, On as getLatestReleaseDescription, Or as resolveReviewThreadDescription, Ot as updateGistDescription, P as listSecretScanningAlertsDescription, Pa as getCollaboratorPermissionCore, Pi as removeLabelCore, Pn as listReleasesDescription, Pr as updatePullRequestCommentDescription, Pt as getDiscussionDescription, Q as listCommentReactionsDescription, Qi as getCommitCore, Qn as disablePullRequestAutoMergeDescription, Qr as closeIssueCore, Qt as cancelWorkflowRunDescription, R as searchCodeInputSchema, Ra as getFileContentDescription, Ri as updateIssueCommentDescription, Rn as updateReleaseInputSchema, Rr as updatePullRequestInputSchema, Rt as listDiscussionsInputSchema, S as resolveGithubToken, Sa as deleteBranchCore, Si as listLabelsCore, Sn as createReleaseDescription, Sr as replyToReviewCommentDescription, St as listGistCommentsDescription, T as GITHUB_TOOL_CATALOG, Ta as editFilesCore, Ti as listMilestonesCore, Tn as deleteReleaseDescription, Tr as requestReviewersDescription, Tt as listGistsDescription, U as searchRepositoriesDescription, Ua as getRepositoryTreeCore, Ui as updateLabelCore, Un as createPullRequestDescription, Ur as addIssueCommentCore, Ut as getIssueContextDescription, V as searchIssuesInputSchema, Va as getRepositoryDescription, Vi as updateIssueDescription, Vn as addPullRequestCommentInputSchema, Vr as addAssigneesDescription, Vt as getCiFailureContextInputSchema, W as searchRepositoriesInputSchema, Wa as getRepositoryTreeDescription, Wi as updateLabelDescription, Wn as createPullRequestInputSchema, Wr as addIssueCommentDescription, Wt as getIssueContextInputSchema, X as addIssueReactionInputSchema, Xi as getBlameDescription, Xn as deletePullRequestCommentInputSchema, Xr as addSubIssueDescription, Xt as getReleaseContextInputSchema, Y as addIssueReactionDescription, Yi as getBlameCore, Yn as deletePullRequestCommentDescription, Yr as addSubIssueCore, Yt as getReleaseContextDescription, Z as listCommentReactionsCore, Za as githubToolsErrors, Zi as getBlameInputSchema, Zn as disablePullRequestAutoMergeCore, Zr as addSubIssueInputSchema, Zt as cancelWorkflowRunCore, _a as createOrUpdateFileDescription, _i as listIssueCommentsDescription, _n as rerunWorkflowRunInputSchema, _r as listPullRequestsInputSchema, _t as deleteGistInputSchema, a as bindToolsContext, aa as createCommitStatusDescription, ai as createLabelDescription, an as getWorkflowRunInputSchema, ar as getPullRequestInputSchema, at as listNotificationsInputSchema, ba as createRepositoryDescription, bi as listIssuesDescription, bn as triggerWorkflowInputSchema, br as mergePullRequestInputSchema, bt as getGistInputSchema, ca as getCombinedStatusDescription, ci as deleteIssueCommentDescription, cn as listWorkflowJobsInputSchema, cr as listPullRequestFilesInputSchema, ct as markNotificationReadInputSchema, da as listCheckRunsDescription, di as deleteLabelDescription, dn as listWorkflowRunsInputSchema, dr as listPullRequestReviewThreadsInputSchema, dt as createGistCommentInputSchema, ea as getCommitInputSchema, ei as closeIssueInputSchema, en as getWorkflowJobLogsCore, er as enablePullRequestAutoMergeCore, et as listIssueReactionsCore, fa as listCheckRunsInputSchema, fi as deleteLabelInputSchema, fn as listWorkflowsCore, fr as listPullRequestReviewsCore, ft as createGistCore, ga as createOrUpdateFileCore, gi as listIssueCommentsCore, gn as rerunWorkflowRunDescription, gr as listPullRequestsDescription, gt as deleteGistDescription, ha as createBranchInputSchema, hi as getIssueInputSchema, hn as rerunWorkflowRunCore, hr as listPullRequestsCore, ht as deleteGistCore, i as dryRunWrite, ia as createCommitStatusCore, ii as createLabelCore, in as getWorkflowRunDescription, ir as getPullRequestDescription, it as listNotificationsDescription, j as listDependabotAlertsDescription, ja as getBranchRulesCore, ji as removeAssigneesCore, jn as getReleaseDescription, jr as updatePullRequestBranchDescription, jt as addDiscussionCommentDescription, k as listCodeScanningAlertsInputSchema, ka as forkRepositoryDescription, ki as listSubIssuesDescription, kn as getLatestReleaseInputSchema, kr as resolveReviewThreadInputSchema, kt as updateGistInputSchema, l as DEFAULT_EVALUATION_MODEL, la as getCombinedStatusInputSchema, li as deleteIssueCommentInputSchema, ln as listWorkflowRunsCore, lr as listPullRequestReviewThreadsCore, lt as createGistCommentCore, ma as createBranchDescription, mi as getIssueDescription, mn as listWorkflowsInputSchema, mr as listPullRequestReviewsInputSchema, mt as createGistInputSchema, n as resolveInstructions, na as listCommitsDescription, ni as createIssueDescription, nn as getWorkflowJobLogsInputSchema, nr as enablePullRequestAutoMergeInputSchema, nt as listIssueReactionsInputSchema, oa as createCommitStatusInputSchema, oi as createLabelInputSchema, on as listWorkflowJobsCore, or as listPullRequestFilesCore, ot as markNotificationReadCore, pa as createBranchCore, pi as getIssueCore, pn as listWorkflowsDescription, pr as listPullRequestReviewsDescription, pt as createGistDescription, q as addCommentReactionInputSchema, qa as listBranchesDescription, qi as compareCommitsDescription, qn as createPullRequestReviewInputSchema, qr as addLabelsDescription, qt as getPullRequestContextInputSchema, ra as listCommitsInputSchema, ri as createIssueInputSchema, rn as getWorkflowRunCore, rr as getPullRequestCore, rt as listNotificationsCore, sa as getCombinedStatusCore, si as deleteIssueCommentCore, sn as listWorkflowJobsDescription, sr as listPullRequestFilesDescription, st as markNotificationReadDescription, ta as listCommitsCore, ti as createIssueCore, tn as getWorkflowJobLogsDescription, tr as enablePullRequestAutoMergeDescription, tt as listIssueReactionsDescription, ua as listCheckRunsCore, ui as deleteLabelCore, un as listWorkflowRunsDescription, ur as listPullRequestReviewThreadsDescription, ut as createGistCommentDescription, va as createOrUpdateFileInputSchema, vi as listIssueCommentsInputSchema, vn as triggerWorkflowCore, vr as mergePullRequestCore, vt as getGistCore, w as ALL_GITHUB_TOOL_NAMES, wa as deleteBranchInputSchema, wi as listLabelsInputSchema, wn as deleteReleaseCore, wr as requestReviewersCore, wt as listGistsCore, x as githubTokenCall, xa as createRepositoryInputSchema, xi as listIssuesInputSchema, xn as createReleaseCore, xr as replyToReviewCommentCore, xt as listGistCommentsCore, y as resolvePresetTools, ya as createRepositoryCore, yi as listIssuesCore, yn as triggerWorkflowDescription, yr as mergePullRequestDescription, yt as getGistDescription, z as searchIssuesCore, za as getFileContentInputSchema, zi as updateIssueCommentInputSchema, zn as addPullRequestCommentCore, zr as guardrailViolation, zt as getCiFailureContextCore } from "./write-tools-w-8tjnDQ.mjs";
2
+ import { _ as listPullRequestFilesToModelOutput, a as evaluationRequest, f as compareCommitsToModelOutput, g as getRepositoryTreeToModelOutput, h as getPullRequestContextToModelOutput, i as evaluateTools, m as getFileContentToModelOutput, n as autoApprovalDecision, o as fallbackPresets, p as getCommitToModelOutput, r as evaluatePresets, s as fallbackTools, t as assertEvaluationAvailable } from "./evaluation-DJHINyAu.mjs";
3
+ import { t as resolveApprovalMode } from "./approval-policy-CEMMPq92.mjs";
4
+ import { ToolLoopAgent, asSchema, tool } from "ai";
5
+ import { z } from "zod";
5
6
  //#region src/tools/repository.ts
6
7
  async function getRepositoryStep(args) {
7
8
  "use step";
@@ -130,6 +131,49 @@ const createOrUpdateFile = (token, { needsApproval = true, author, committer, co
130
131
  ...args
131
132
  })
132
133
  });
134
+ async function editFilesStep(args) {
135
+ "use step";
136
+ return editFilesCore(args);
137
+ }
138
+ /** Edit files in one commit, by exact text replacement or whole contents, on a new or existing branch, and optionally open a pull request. Requires approval by default. */
139
+ const editFiles = (token, { needsApproval = true, author, committer, coAuthors } = {}) => tool({
140
+ description: editFilesDescription,
141
+ needsApproval,
142
+ inputSchema: editFilesInputSchema,
143
+ execute: async (args) => editFilesStep({
144
+ token: await resolveGithubToken(token, githubTokenCall("editFiles", args)),
145
+ author,
146
+ committer,
147
+ coAuthors,
148
+ ...args
149
+ })
150
+ });
151
+ async function getBranchRulesStep(args) {
152
+ "use step";
153
+ return getBranchRulesCore(args);
154
+ }
155
+ /** List the required checks, required reviews and other rules that protect a branch. */
156
+ const getBranchRules = (token) => tool({
157
+ description: getBranchRulesDescription,
158
+ inputSchema: getBranchRulesInputSchema,
159
+ execute: async (args) => getBranchRulesStep({
160
+ token: await resolveGithubToken(token, githubTokenCall("getBranchRules", args)),
161
+ ...args
162
+ })
163
+ });
164
+ async function getCollaboratorPermissionStep(args) {
165
+ "use step";
166
+ return getCollaboratorPermissionCore(args);
167
+ }
168
+ /** Get a user's permission and role on a repository. */
169
+ const getCollaboratorPermission = (token) => tool({
170
+ description: getCollaboratorPermissionDescription,
171
+ inputSchema: getCollaboratorPermissionInputSchema,
172
+ execute: async (args) => getCollaboratorPermissionStep({
173
+ token: await resolveGithubToken(token, githubTokenCall("getCollaboratorPermission", args)),
174
+ ...args
175
+ })
176
+ });
133
177
  //#endregion
134
178
  //#region src/tools/pull-requests.ts
135
179
  async function listPullRequestsStep(args) {
@@ -177,14 +221,15 @@ async function mergePullRequestStep(args) {
177
221
  return mergePullRequestCore(args);
178
222
  }
179
223
  /** Merge a pull request. Requires approval by default. */
180
- const mergePullRequest = (token, { needsApproval = true, coAuthors } = {}) => tool({
224
+ const mergePullRequest = (token, { needsApproval = true, coAuthors, branches } = {}) => tool({
181
225
  description: mergePullRequestDescription,
182
226
  needsApproval,
183
227
  inputSchema: mergePullRequestInputSchema,
184
228
  execute: async (args) => mergePullRequestStep({
185
229
  token: await resolveGithubToken(token, githubTokenCall("mergePullRequest", args)),
186
230
  coAuthors,
187
- ...args
231
+ ...args,
232
+ branches
188
233
  })
189
234
  });
190
235
  async function updatePullRequestStep(args) {
@@ -339,6 +384,51 @@ const requestReviewers = (token, { needsApproval = true } = {}) => tool({
339
384
  ...args
340
385
  })
341
386
  });
387
+ async function enablePullRequestAutoMergeStep(args) {
388
+ "use step";
389
+ return enablePullRequestAutoMergeCore(args);
390
+ }
391
+ /** Merge a pull request automatically once its required checks and reviews pass. Requires approval by default. */
392
+ const enablePullRequestAutoMerge = (token, { needsApproval = true, coAuthors, branches } = {}) => tool({
393
+ description: enablePullRequestAutoMergeDescription,
394
+ needsApproval,
395
+ inputSchema: enablePullRequestAutoMergeInputSchema,
396
+ execute: async (args) => enablePullRequestAutoMergeStep({
397
+ token: await resolveGithubToken(token, githubTokenCall("enablePullRequestAutoMerge", args)),
398
+ coAuthors,
399
+ ...args,
400
+ branches
401
+ })
402
+ });
403
+ async function disablePullRequestAutoMergeStep(args) {
404
+ "use step";
405
+ return disablePullRequestAutoMergeCore(args);
406
+ }
407
+ /** Cancel a pending auto-merge. Requires approval by default. */
408
+ const disablePullRequestAutoMerge = (token, { needsApproval = true } = {}) => tool({
409
+ description: disablePullRequestAutoMergeDescription,
410
+ needsApproval,
411
+ inputSchema: disablePullRequestAutoMergeInputSchema,
412
+ execute: async (args) => disablePullRequestAutoMergeStep({
413
+ token: await resolveGithubToken(token, githubTokenCall("disablePullRequestAutoMerge", args)),
414
+ ...args
415
+ })
416
+ });
417
+ async function updatePullRequestBranchStep(args) {
418
+ "use step";
419
+ return updatePullRequestBranchCore(args);
420
+ }
421
+ /** Merge a pull request's base branch into its head branch. Requires approval by default. */
422
+ const updatePullRequestBranch = (token, { needsApproval = true, guardrails } = {}) => tool({
423
+ description: updatePullRequestBranchDescription,
424
+ needsApproval,
425
+ inputSchema: updatePullRequestBranchInputSchema,
426
+ execute: async (args) => updatePullRequestBranchStep({
427
+ token: await resolveGithubToken(token, githubTokenCall("updatePullRequestBranch", args)),
428
+ ...args,
429
+ guardrails
430
+ })
431
+ });
342
432
  //#endregion
343
433
  //#region src/tools/issues.ts
344
434
  async function listIssuesStep(args) {
@@ -575,6 +665,46 @@ const removeAssignees = (token, { needsApproval = true } = {}) => tool({
575
665
  ...args
576
666
  })
577
667
  });
668
+ async function listMilestonesStep(args) {
669
+ "use step";
670
+ return listMilestonesCore(args);
671
+ }
672
+ /** List milestones in a GitHub repository with their due dates and issue counts. */
673
+ const listMilestones = (token) => tool({
674
+ description: listMilestonesDescription,
675
+ inputSchema: listMilestonesInputSchema,
676
+ execute: async (args) => listMilestonesStep({
677
+ token: await resolveGithubToken(token, githubTokenCall("listMilestones", args)),
678
+ ...args
679
+ })
680
+ });
681
+ async function listSubIssuesStep(args) {
682
+ "use step";
683
+ return listSubIssuesCore(args);
684
+ }
685
+ /** List the sub-issues of an issue. */
686
+ const listSubIssues = (token) => tool({
687
+ description: listSubIssuesDescription,
688
+ inputSchema: listSubIssuesInputSchema,
689
+ execute: async (args) => listSubIssuesStep({
690
+ token: await resolveGithubToken(token, githubTokenCall("listSubIssues", args)),
691
+ ...args
692
+ })
693
+ });
694
+ async function addSubIssueStep(args) {
695
+ "use step";
696
+ return addSubIssueCore(args);
697
+ }
698
+ /** Add an existing issue as a sub-issue of another issue. Requires approval by default. */
699
+ const addSubIssue = (token, { needsApproval = true } = {}) => tool({
700
+ description: addSubIssueDescription,
701
+ needsApproval,
702
+ inputSchema: addSubIssueInputSchema,
703
+ execute: async (args) => addSubIssueStep({
704
+ token: await resolveGithubToken(token, githubTokenCall("addSubIssue", args)),
705
+ ...args
706
+ })
707
+ });
578
708
  //#endregion
579
709
  //#region src/tools/reactions.ts
580
710
  async function listIssueReactionsStep(args) {
@@ -1033,6 +1163,61 @@ const getCombinedStatus = (token) => tool({
1033
1163
  ...args
1034
1164
  })
1035
1165
  });
1166
+ async function createCommitStatusStep(args) {
1167
+ "use step";
1168
+ return createCommitStatusCore(args);
1169
+ }
1170
+ /** Report a result on a commit as a commit status. Requires approval by default. */
1171
+ const createCommitStatus = (token, { needsApproval = true } = {}) => tool({
1172
+ description: createCommitStatusDescription,
1173
+ needsApproval,
1174
+ inputSchema: createCommitStatusInputSchema,
1175
+ execute: async (args) => createCommitStatusStep({
1176
+ token: await resolveGithubToken(token, githubTokenCall("createCommitStatus", args)),
1177
+ ...args
1178
+ })
1179
+ });
1180
+ //#endregion
1181
+ //#region src/tools/security.ts
1182
+ async function listCodeScanningAlertsStep(args) {
1183
+ "use step";
1184
+ return listCodeScanningAlertsCore(args);
1185
+ }
1186
+ /** List code scanning alerts for a repository, with the rule, severity and location. */
1187
+ const listCodeScanningAlerts = (token) => tool({
1188
+ description: listCodeScanningAlertsDescription,
1189
+ inputSchema: listCodeScanningAlertsInputSchema,
1190
+ execute: async (args) => listCodeScanningAlertsStep({
1191
+ token: await resolveGithubToken(token, githubTokenCall("listCodeScanningAlerts", args)),
1192
+ ...args
1193
+ })
1194
+ });
1195
+ async function listDependabotAlertsStep(args) {
1196
+ "use step";
1197
+ return listDependabotAlertsCore(args);
1198
+ }
1199
+ /** List Dependabot alerts for vulnerable dependencies, with the advisory and the first patched version. */
1200
+ const listDependabotAlerts = (token) => tool({
1201
+ description: listDependabotAlertsDescription,
1202
+ inputSchema: listDependabotAlertsInputSchema,
1203
+ execute: async (args) => listDependabotAlertsStep({
1204
+ token: await resolveGithubToken(token, githubTokenCall("listDependabotAlerts", args)),
1205
+ ...args
1206
+ })
1207
+ });
1208
+ async function listSecretScanningAlertsStep(args) {
1209
+ "use step";
1210
+ return listSecretScanningAlertsCore(args);
1211
+ }
1212
+ /** List secret scanning alerts for a repository. The secret itself is never returned. */
1213
+ const listSecretScanningAlerts = (token) => tool({
1214
+ description: listSecretScanningAlertsDescription,
1215
+ inputSchema: listSecretScanningAlertsInputSchema,
1216
+ execute: async (args) => listSecretScanningAlertsStep({
1217
+ token: await resolveGithubToken(token, githubTokenCall("listSecretScanningAlerts", args)),
1218
+ ...args
1219
+ })
1220
+ });
1036
1221
  //#endregion
1037
1222
  //#region src/tools/releases.ts
1038
1223
  async function listReleasesStep(args) {
@@ -1173,17 +1358,200 @@ const getCiFailureContext = (token) => tool({
1173
1358
  });
1174
1359
  //#endregion
1175
1360
  //#region src/core/approval.ts
1361
+ const MAX_CACHED_DECISIONS = 100;
1176
1362
  /**
1177
1363
  * Resolve the AI SDK `needsApproval` value for a write tool.
1178
1364
  * `'auto'` becomes a function that evaluates each call with {@link needsAutoApproval}.
1365
+ * The AI SDK asks again once a person approves, so each decision is reused for the same
1366
+ * call, input and request (with the message it replies to) instead of calling the evaluation model twice.
1179
1367
  */
1180
1368
  function resolveAiSdkApproval(toolName, config, evaluation) {
1181
1369
  const mode = resolveApprovalMode(toolName, config);
1182
1370
  if (mode !== "auto") return mode;
1183
- return (input, { messages }) => needsAutoApproval(toolName, input, messages, evaluation);
1371
+ assertEvaluationAvailable();
1372
+ const decisions = /* @__PURE__ */ new Map();
1373
+ return (input, { toolCallId, messages }) => {
1374
+ const key = JSON.stringify([
1375
+ toolCallId,
1376
+ input,
1377
+ evaluationRequest(messages)
1378
+ ]);
1379
+ const cached = decisions.get(key);
1380
+ if (cached) return cached;
1381
+ const decision = autoApprovalDecision(toolName, input, messages, evaluation).then(({ ask }) => ask);
1382
+ decisions.set(key, decision);
1383
+ if (decisions.size > MAX_CACHED_DECISIONS) decisions.delete(decisions.keys().next().value);
1384
+ return decision;
1385
+ };
1386
+ }
1387
+ function resolveAiSdkToolApproval(toolName, config, evaluation) {
1388
+ const mode = resolveApprovalMode(toolName, config);
1389
+ if (mode !== "auto") return async () => mode ? "user-approval" : void 0;
1390
+ assertEvaluationAvailable();
1391
+ const decisions = /* @__PURE__ */ new Map();
1392
+ return async (input, { toolCallId, messages }) => {
1393
+ const key = JSON.stringify([
1394
+ toolCallId,
1395
+ input,
1396
+ evaluationRequest(messages)
1397
+ ]);
1398
+ let decision = decisions.get(key);
1399
+ if (!decision) {
1400
+ decision = autoApprovalDecision(toolName, input, messages, evaluation);
1401
+ decisions.set(key, decision);
1402
+ if (decisions.size > MAX_CACHED_DECISIONS) decisions.delete(decisions.keys().next().value);
1403
+ }
1404
+ const { ask, reason } = await decision;
1405
+ return {
1406
+ type: ask ? "user-approval" : "approved",
1407
+ reason
1408
+ };
1409
+ };
1184
1410
  }
1185
1411
  //#endregion
1186
1412
  //#region src/agents.ts
1413
+ const MAX_CACHED_ROUTES = 100;
1414
+ /** Name of the tool `preset: 'auto'` adds so the model can call GitHub tools that were not picked. */
1415
+ const CALL_GITHUB_TOOL = "callGithubTool";
1416
+ const callGithubToolInput = z.object({
1417
+ name: z.enum(ALL_GITHUB_TOOL_NAMES).describe("GitHub tool to call"),
1418
+ input: z.record(z.string(), z.unknown()).optional().describe("The tool's arguments. Omit to get its description and input schema without calling it.")
1419
+ });
1420
+ async function validateInput(tools, name, input) {
1421
+ return await asSchema(tools[name].inputSchema).validate?.(input) ?? {
1422
+ success: true,
1423
+ value: input
1424
+ };
1425
+ }
1426
+ function callGithubTool(tools) {
1427
+ const validate = (name, input) => validateInput(tools, name, input);
1428
+ return tool({
1429
+ description: "Call a GitHub tool that is not in your tool list. Every GitHub tool is in the `name` enum. Pass its arguments as `input`; if you do not know them, omit `input` to get the tool's description and input schema first.",
1430
+ inputSchema: callGithubToolInput,
1431
+ needsApproval: async ({ name, input }, options) => {
1432
+ if (input === void 0) return false;
1433
+ const parsed = await validate(name, input);
1434
+ const needsApproval = tools[name].needsApproval;
1435
+ if (!parsed.success || needsApproval === void 0) return false;
1436
+ return typeof needsApproval === "function" ? needsApproval(parsed.value, options) : needsApproval;
1437
+ },
1438
+ execute: async ({ name, input }, options) => {
1439
+ if (input === void 0) return {
1440
+ name,
1441
+ description: tools[name].description,
1442
+ inputSchema: await asSchema(tools[name].inputSchema).jsonSchema
1443
+ };
1444
+ const parsed = await validate(name, input);
1445
+ if (!parsed.success) throw new Error(`Invalid input for ${name}: ${parsed.error.message}\nInput schema: ${JSON.stringify(await asSchema(tools[name].inputSchema).jsonSchema)}`);
1446
+ return tools[name].execute(parsed.value, options);
1447
+ },
1448
+ toModelOutput: async ({ toolCallId, input: { name, input }, output }) => {
1449
+ const toModelOutput = tools[name].toModelOutput;
1450
+ if (input === void 0 || !toModelOutput) return {
1451
+ type: "json",
1452
+ value: output
1453
+ };
1454
+ const parsed = await validate(name, input);
1455
+ return toModelOutput({
1456
+ toolCallId,
1457
+ input: parsed.success ? parsed.value : input,
1458
+ output
1459
+ });
1460
+ }
1461
+ });
1462
+ }
1463
+ /**
1464
+ * Call-level approval for every GitHub tool, the AI SDK 7 replacement for tool-level `needsApproval`.
1465
+ * `requireApproval: 'auto'` puts the decision model's verdict on approval requests and records the
1466
+ * calls it lets through as automatic approvals. Calls through `callGithubTool` follow the named tool.
1467
+ */
1468
+ function githubToolApproval({ tools, requireApproval, evaluation, overrides, guardrails, dryRun }) {
1469
+ const policies = /* @__PURE__ */ new Map();
1470
+ const policyFor = (name) => {
1471
+ let policy = policies.get(name);
1472
+ if (!policy) {
1473
+ const override = overrides?.[name]?.needsApproval;
1474
+ policy = override !== void 0 ? async (input, options) => (typeof override === "function" ? await override(input, {
1475
+ ...options,
1476
+ context: void 0
1477
+ }) : override) ? "user-approval" : void 0 : isGithubWriteToolName(name) ? resolveAiSdkToolApproval(name, requireApproval ?? true, evaluation) : async () => void 0;
1478
+ policies.set(name, policy);
1479
+ }
1480
+ return policy;
1481
+ };
1482
+ const decide = (name, input, options) => {
1483
+ const reason = guardrailViolation(githubTokenCall(name, input), guardrails);
1484
+ if (reason) return {
1485
+ type: "denied",
1486
+ reason
1487
+ };
1488
+ return dryRun && isGithubWriteToolName(name) ? void 0 : policyFor(name)(input, options);
1489
+ };
1490
+ return async ({ toolCall, messages, tools: available, toolsContext }) => {
1491
+ if (toolCall.toolName !== "callGithubTool" && !Object.hasOwn(GITHUB_TOOL_CATALOG, toolCall.toolName)) {
1492
+ const needsApproval = available?.[toolCall.toolName]?.needsApproval;
1493
+ return (typeof needsApproval === "function" ? await needsApproval(toolCall.input, {
1494
+ toolCallId: toolCall.toolCallId,
1495
+ messages,
1496
+ context: toolsContext?.[toolCall.toolName]
1497
+ }) : needsApproval) ? "user-approval" : void 0;
1498
+ }
1499
+ if (toolCall.toolName !== "callGithubTool") return decide(toolCall.toolName, toolCall.input, {
1500
+ toolCallId: toolCall.toolCallId,
1501
+ messages
1502
+ });
1503
+ const { name, input } = toolCall.input;
1504
+ if (input === void 0) return void 0;
1505
+ const parsed = await validateInput(tools, name, input);
1506
+ return parsed.success ? decide(name, parsed.value, {
1507
+ toolCallId: toolCall.toolCallId,
1508
+ messages
1509
+ }) : void 0;
1510
+ };
1511
+ }
1512
+ function firstRequest(messages) {
1513
+ const index = messages.findIndex((message) => message.role === "user");
1514
+ return index === -1 ? messages : messages.slice(0, index + 1);
1515
+ }
1516
+ function callMessages(call) {
1517
+ if (typeof call.prompt === "string") return [{
1518
+ role: "user",
1519
+ content: call.prompt
1520
+ }];
1521
+ return call.prompt ?? call.messages ?? [];
1522
+ }
1523
+ function decisionModelId({ model = DEFAULT_EVALUATION_MODEL } = {}) {
1524
+ return typeof model === "string" ? model : `${model.provider}/${model.modelId}`;
1525
+ }
1526
+ async function storeKey(kind, settings, key) {
1527
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify([settings, key])));
1528
+ return `github-tools:${kind}:${[...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
1529
+ }
1530
+ /**
1531
+ * Routing for a request, cached per request so an approval continuation keeps its tools, and in
1532
+ * `evaluation.store` when set. Only successful decisions are kept, so a request routed while the
1533
+ * evaluator was down is routed again.
1534
+ */
1535
+ function cachedRouting(kind, settings, route, fallback, store) {
1536
+ const routing = /* @__PURE__ */ new Map();
1537
+ return async (messages) => {
1538
+ const key = JSON.stringify(evaluationRequest(messages));
1539
+ let routed = routing.get(key);
1540
+ if (!routed) {
1541
+ routed = store ? storeKey(kind, settings, key).then(async (stored) => {
1542
+ const saved = await store.get(stored);
1543
+ if (saved) return saved;
1544
+ const decided = await route(messages);
1545
+ await store.set(stored, decided);
1546
+ return decided;
1547
+ }) : route(messages);
1548
+ routing.set(key, routed);
1549
+ routed.catch(() => routing.delete(key));
1550
+ if (routing.size > MAX_CACHED_ROUTES) routing.delete(routing.keys().next().value);
1551
+ }
1552
+ return routed.catch(fallback);
1553
+ };
1554
+ }
1187
1555
  /**
1188
1556
  * Create a pre-configured GitHub agent powered by the AI SDK's `ToolLoopAgent`.
1189
1557
  *
@@ -1203,21 +1571,37 @@ function resolveAiSdkApproval(toolName, config, evaluation) {
1203
1571
  * const result = await agent.generate({ prompt: 'Review this PR' })
1204
1572
  * ```
1205
1573
  */
1206
- function createGithubAgent({ token, preset, requireApproval, evaluation, context, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
1574
+ function createGithubAgent({ token, preset, requireApproval, evaluation, overrides, context, instructions, additionalInstructions, author, committer, coAuthors, guardrails, dryRun, ...agentOptions }) {
1207
1575
  const staticPreset = preset === "auto" ? void 0 : preset;
1208
1576
  const tools = createGithubTools({
1209
1577
  token,
1210
1578
  requireApproval,
1211
1579
  evaluation,
1212
1580
  preset: staticPreset,
1581
+ overrides,
1213
1582
  context,
1214
1583
  author,
1215
1584
  committer,
1216
- coAuthors
1585
+ coAuthors,
1586
+ guardrails,
1587
+ dryRun
1217
1588
  });
1589
+ const byTool = preset === "auto" && evaluation?.selection !== "presets";
1590
+ const agentTools = byTool ? {
1591
+ ...tools,
1592
+ [CALL_GITHUB_TOOL]: callGithubTool(tools)
1593
+ } : tools;
1218
1594
  const settings = {
1595
+ toolApproval: githubToolApproval({
1596
+ tools,
1597
+ requireApproval,
1598
+ evaluation,
1599
+ overrides,
1600
+ guardrails,
1601
+ dryRun
1602
+ }),
1219
1603
  ...agentOptions,
1220
- tools,
1604
+ tools: agentTools,
1221
1605
  instructions: resolveInstructions({
1222
1606
  preset: staticPreset,
1223
1607
  instructions,
@@ -1225,14 +1609,34 @@ function createGithubAgent({ token, preset, requireApproval, evaluation, context
1225
1609
  context
1226
1610
  })
1227
1611
  };
1228
- if (preset === "auto") {
1612
+ if (preset === "auto" && evaluation?.scope === "session" && !byTool) throw githubToolsErrors.SESSION_SCOPE_NEEDS_TOOL_SELECTION();
1613
+ if (byTool) {
1614
+ assertEvaluationAvailable();
1229
1615
  const prepareCall = agentOptions.prepareCall;
1616
+ const picks = cachedRouting("tools", [
1617
+ decisionModelId(evaluation),
1618
+ evaluation?.minToolProbability,
1619
+ evaluation?.maxTools
1620
+ ], (messages) => evaluateTools(messages, evaluation), (error) => fallbackTools(error, evaluation), evaluation?.store);
1230
1621
  settings.prepareCall = async (call) => {
1231
- const messages = typeof call.prompt === "string" ? [{
1232
- role: "user",
1233
- content: call.prompt
1234
- }] : call.prompt ?? call.messages ?? [];
1235
- const selected = await selectPresets(messages, evaluation);
1622
+ const messages = callMessages(call);
1623
+ const picked = await picks(evaluation?.scope === "turn" ? messages : firstRequest(messages));
1624
+ const next = {
1625
+ ...call,
1626
+ activeTools: [...picked, CALL_GITHUB_TOOL]
1627
+ };
1628
+ return prepareCall ? prepareCall(next) : next;
1629
+ };
1630
+ } else if (preset === "auto") {
1631
+ assertEvaluationAvailable();
1632
+ const prepareCall = agentOptions.prepareCall;
1633
+ const routes = cachedRouting("presets", [
1634
+ decisionModelId(evaluation),
1635
+ evaluation?.minPresetProbability,
1636
+ evaluation?.maxPresets
1637
+ ], (messages) => evaluatePresets(messages, evaluation), (error) => fallbackPresets(error, evaluation), evaluation?.store);
1638
+ settings.prepareCall = async (call) => {
1639
+ const selected = await routes(callMessages(call));
1236
1640
  const next = {
1237
1641
  ...call,
1238
1642
  activeTools: [...resolvePresetTools(selected)],
@@ -1289,11 +1693,21 @@ function createGithubAgent({ token, preset, requireApproval, evaluation, context
1289
1693
  * addPullRequestComment: false,
1290
1694
  * }
1291
1695
  * })
1696
+ *
1697
+ * // Try an agent on real repositories without changing them
1698
+ * createGithubTools({ token, dryRun: true })
1699
+ *
1700
+ * // Only act on one org, and only write to agent branches
1701
+ * createGithubTools({
1702
+ * token,
1703
+ * guardrails: { repositories: ['vercel-labs/*'], branches: ['agent/*'] },
1704
+ * })
1292
1705
  * ```
1293
1706
  */
1294
- function createGithubTools({ token, requireApproval = true, evaluation, preset, context, overrides, author, committer, coAuthors } = {}) {
1295
- const resolveToken = createGithubTokenResolver(token);
1296
- const approval = (name) => ({ needsApproval: resolveAiSdkApproval(name, requireApproval, evaluation) });
1707
+ function createGithubTools({ token, requireApproval = true, evaluation, preset, context, overrides, author, committer, coAuthors, guardrails, dryRun } = {}) {
1708
+ const resolveToken = withGithubGuardrails(token, guardrails);
1709
+ const approval = (name) => ({ needsApproval: guardedApproval(name, resolveAiSdkApproval(name, requireApproval, evaluation), guardrails) });
1710
+ const branches = guardrails?.branches;
1297
1711
  const allowed = preset ? resolvePresetTools(preset) : null;
1298
1712
  const allTools = {
1299
1713
  getRepository: getRepository(resolveToken),
@@ -1321,12 +1735,34 @@ function createGithubTools({ token, requireApproval = true, evaluation, preset,
1321
1735
  committer,
1322
1736
  coAuthors
1323
1737
  }),
1738
+ editFiles: editFiles(resolveToken, {
1739
+ ...approval("editFiles"),
1740
+ author,
1741
+ committer,
1742
+ coAuthors
1743
+ }),
1744
+ getBranchRules: getBranchRules(resolveToken),
1745
+ getCollaboratorPermission: getCollaboratorPermission(resolveToken),
1746
+ listCodeScanningAlerts: listCodeScanningAlerts(resolveToken),
1747
+ listDependabotAlerts: listDependabotAlerts(resolveToken),
1748
+ listSecretScanningAlerts: listSecretScanningAlerts(resolveToken),
1324
1749
  createPullRequest: createPullRequest(resolveToken, approval("createPullRequest")),
1325
1750
  mergePullRequest: mergePullRequest(resolveToken, {
1326
1751
  ...approval("mergePullRequest"),
1327
- coAuthors
1752
+ coAuthors,
1753
+ branches
1754
+ }),
1755
+ enablePullRequestAutoMerge: enablePullRequestAutoMerge(resolveToken, {
1756
+ ...approval("enablePullRequestAutoMerge"),
1757
+ coAuthors,
1758
+ branches
1328
1759
  }),
1760
+ disablePullRequestAutoMerge: disablePullRequestAutoMerge(resolveToken, approval("disablePullRequestAutoMerge")),
1329
1761
  updatePullRequest: updatePullRequest(resolveToken, approval("updatePullRequest")),
1762
+ updatePullRequestBranch: updatePullRequestBranch(resolveToken, {
1763
+ ...approval("updatePullRequestBranch"),
1764
+ guardrails
1765
+ }),
1330
1766
  addPullRequestComment: addPullRequestComment(resolveToken, approval("addPullRequestComment")),
1331
1767
  updatePullRequestComment: updatePullRequestComment(resolveToken, approval("updatePullRequestComment")),
1332
1768
  deletePullRequestComment: deletePullRequestComment(resolveToken, approval("deletePullRequestComment")),
@@ -1354,6 +1790,9 @@ function createGithubTools({ token, requireApproval = true, evaluation, preset,
1354
1790
  deleteLabel: deleteLabel(resolveToken, approval("deleteLabel")),
1355
1791
  addAssignees: addAssignees(resolveToken, approval("addAssignees")),
1356
1792
  removeAssignees: removeAssignees(resolveToken, approval("removeAssignees")),
1793
+ listMilestones: listMilestones(resolveToken),
1794
+ listSubIssues: listSubIssues(resolveToken),
1795
+ addSubIssue: addSubIssue(resolveToken, approval("addSubIssue")),
1357
1796
  listIssueReactions: listIssueReactions(resolveToken),
1358
1797
  addIssueReaction: addIssueReaction(resolveToken, approval("addIssueReaction")),
1359
1798
  listCommentReactions: listCommentReactions(resolveToken),
@@ -1380,6 +1819,7 @@ function createGithubTools({ token, requireApproval = true, evaluation, preset,
1380
1819
  rerunWorkflowRun: rerunWorkflowRun(resolveToken, approval("rerunWorkflowRun")),
1381
1820
  listCheckRuns: listCheckRuns(resolveToken),
1382
1821
  getCombinedStatus: getCombinedStatus(resolveToken),
1822
+ createCommitStatus: createCommitStatus(resolveToken, approval("createCommitStatus")),
1383
1823
  getCiFailureContext: getCiFailureContext(resolveToken),
1384
1824
  listReleases: listReleases(resolveToken),
1385
1825
  getLatestRelease: getLatestRelease(resolveToken),
@@ -1398,10 +1838,38 @@ function createGithubTools({ token, requireApproval = true, evaluation, preset,
1398
1838
  } });
1399
1839
  }
1400
1840
  }
1401
- const scoped = bindToolsContext(Object.fromEntries(Object.entries(allTools).map(([name, tool]) => [name, withStrippedRateLimit(tool)])), context);
1841
+ const wouldApprove = async (name, input, options) => {
1842
+ const override = overrides?.[name]?.needsApproval;
1843
+ if (override !== void 0) return { required: (typeof override === "function" ? await override(input, {
1844
+ ...options,
1845
+ context: void 0
1846
+ }) : override) === true };
1847
+ const status = await resolveAiSdkToolApproval(name, requireApproval, evaluation)(input, options);
1848
+ if (status === void 0 || status === "user-approval") return { required: status === "user-approval" };
1849
+ return {
1850
+ required: status.type === "user-approval",
1851
+ reason: status.reason
1852
+ };
1853
+ };
1854
+ const withDryRun = (name, tool) => dryRun && isGithubWriteToolName(name) ? {
1855
+ ...tool,
1856
+ needsApproval: false,
1857
+ execute: async (args, { toolCallId, messages }) => dryRunWrite(name, args, guardrails, () => wouldApprove(name, args, {
1858
+ toolCallId,
1859
+ messages
1860
+ }))
1861
+ } : tool;
1862
+ const scoped = bindToolsContext(Object.fromEntries(Object.entries(allTools).map(([name, tool]) => [name, withStrippedRateLimit(withDryRun(name, tool))])), context);
1402
1863
  if (!allowed) return scoped;
1403
1864
  return Object.fromEntries(Object.entries(scoped).filter(([name]) => allowed.has(name)));
1404
1865
  }
1866
+ function guardedApproval(name, needsApproval, guardrails) {
1867
+ if (!guardrails) return needsApproval;
1868
+ return async (input, options) => {
1869
+ if (guardrailViolation(githubTokenCall(name, input), guardrails)) return false;
1870
+ return typeof needsApproval === "function" ? needsApproval(input, options) : needsApproval === true;
1871
+ };
1872
+ }
1405
1873
  function withStrippedRateLimit(tool) {
1406
1874
  const inner = tool.toModelOutput;
1407
1875
  return {
@@ -1420,6 +1888,6 @@ function withStrippedRateLimit(tool) {
1420
1888
  };
1421
1889
  }
1422
1890
  //#endregion
1423
- export { deleteLabel as $, compareCommits as A, getRepository as At, getDiscussion as B, createGist as C, updatePullRequestComment as Ct, listGistComments as D, deleteBranch as Dt, getGist as E, createRepository as Et, searchIssues as F, listIssueReactions as G, addCommentReaction as H, searchRepositories as I, addLabels as J, addAssignees as K, listNotifications as L, getCommit as M, listBranches as Mt, listCommits as N, listGists as O, forkRepository as Ot, searchCode as P, deleteIssueComment as Q, markNotificationRead as R, triggerWorkflow as S, updatePullRequest as St, deleteGist as T, createOrUpdateFile as Tt, addIssueReaction as U, listDiscussions as V, listCommentReactions as W, createIssue as X, closeIssue as Y, createLabel as Z, getWorkflowRun as _, listPullRequests as _t, getPullRequestContext as a, removeLabel as at, listWorkflows as b, requestReviewers as bt, deleteRelease as c, updateLabel as ct, listReleases as d, createPullRequestReview as dt, getIssue as et, updateRelease as f, deletePullRequestComment as ft, getWorkflowJobLogs as g, listPullRequestReviews as gt, cancelWorkflowRun as h, listPullRequestReviewThreads as ht, getIssueContext as i, removeAssignees as it, getBlame as j, getRepositoryTree as jt, updateGist as k, getFileContent as kt, getLatestRelease as l, addPullRequestComment as lt, listCheckRuns as m, listPullRequestFiles as mt, createGithubAgent as n, listIssues as nt, getReleaseContext as o, updateIssue as ot, getCombinedStatus as p, getPullRequest as pt, addIssueComment as q, getCiFailureContext as r, listLabels as rt, createRelease as s, updateIssueComment as st, createGithubTools as t, listIssueComments as tt, getRelease as u, createPullRequest as ut, listWorkflowJobs as v, mergePullRequest as vt, createGistComment as w, createBranch as wt, rerunWorkflowRun as x, resolveReviewThread as xt, listWorkflowRuns as y, replyToReviewComment as yt, addDiscussionComment as z };
1891
+ export { addLabels as $, deleteGist as A, requestReviewers as At, searchIssues as B, forkRepository as Bt, listWorkflowJobs as C, getPullRequest as Ct, triggerWorkflow as D, listPullRequests as Dt, rerunWorkflowRun as E, listPullRequestReviews as Et, compareCommits as F, createBranch as Ft, getDiscussion as G, getRepositoryTree as Gt, listNotifications as H, getCollaboratorPermission as Ht, getBlame as I, createOrUpdateFile as It, addIssueReaction as J, listDiscussions as K, listBranches as Kt, getCommit as L, createRepository as Lt, listGistComments as M, updatePullRequest as Mt, listGists as N, updatePullRequestBranch as Nt, createGist as O, mergePullRequest as Ot, updateGist as P, updatePullRequestComment as Pt, addIssueComment as Q, listCommits as R, deleteBranch as Rt, getWorkflowRun as S, enablePullRequestAutoMerge as St, listWorkflows as T, listPullRequestReviewThreads as Tt, markNotificationRead as U, getFileContent as Ut, searchRepositories as V, getBranchRules as Vt, addDiscussionComment as W, getRepository as Wt, listIssueReactions as X, listCommentReactions as Y, addAssignees as Z, createCommitStatus as _, addPullRequestComment as _t, getIssueContext as a, deleteLabel as at, cancelWorkflowRun as b, deletePullRequestComment as bt, createRelease as c, listIssues as ct, getRelease as d, listSubIssues as dt, addSubIssue as et, listReleases as f, removeAssignees as ft, listSecretScanningAlerts as g, updateLabel as gt, listDependabotAlerts as h, updateIssueComment as ht, getCiFailureContext as i, deleteIssueComment as it, getGist as j, resolveReviewThread as jt, createGistComment as k, replyToReviewComment as kt, deleteRelease as l, listLabels as lt, listCodeScanningAlerts as m, updateIssue as mt, CALL_GITHUB_TOOL as n, createIssue as nt, getPullRequestContext as o, getIssue as ot, updateRelease as p, removeLabel as pt, addCommentReaction as q, createGithubAgent as r, createLabel as rt, getReleaseContext as s, listIssueComments as st, createGithubTools as t, closeIssue as tt, getLatestRelease as u, listMilestones as ut, getCombinedStatus as v, createPullRequest as vt, listWorkflowRuns as w, listPullRequestFiles as wt, getWorkflowJobLogs as x, disablePullRequestAutoMerge as xt, listCheckRuns as y, createPullRequestReview as yt, searchCode as z, editFiles as zt };
1424
1892
 
1425
- //# sourceMappingURL=src-Bx5p1Unc.mjs.map
1893
+ //# sourceMappingURL=src-BlhrSieS.mjs.map