@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.
- package/README.md +101 -9
- package/dist/eve.d.mts +167 -0
- package/dist/eve.d.mts.map +1 -0
- package/dist/eve.mjs +522 -0
- package/dist/eve.mjs.map +1 -0
- package/dist/index-BRUYe5q0.d.mts +220 -0
- package/dist/index-BRUYe5q0.d.mts.map +1 -0
- package/dist/index.d.mts +3 -777
- package/dist/index.mjs +3 -220
- package/dist/src-BgnkKMD7.mjs +812 -0
- package/dist/src-BgnkKMD7.mjs.map +1 -0
- package/dist/tool-types-CuirBEc8.d.mts +244 -0
- package/dist/tool-types-CuirBEc8.d.mts.map +1 -0
- package/dist/workflow.d.mts +66 -726
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +20 -79
- package/dist/workflow.mjs.map +1 -1
- package/dist/write-tools-vzlewWo5.mjs +1823 -0
- package/dist/write-tools-vzlewWo5.mjs.map +1 -0
- package/package.json +30 -11
- package/dist/agents-C6nqZiYp.d.mts +0 -781
- package/dist/agents-C6nqZiYp.d.mts.map +0 -1
- package/dist/agents-D9aKsd_7.mjs +0 -1649
- package/dist/agents-D9aKsd_7.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,220 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const PRESET_TOOLS = {
|
|
5
|
-
"code-review": [
|
|
6
|
-
"getPullRequest",
|
|
7
|
-
"listPullRequests",
|
|
8
|
-
"listPullRequestFiles",
|
|
9
|
-
"listPullRequestReviews",
|
|
10
|
-
"getFileContent",
|
|
11
|
-
"listCommits",
|
|
12
|
-
"getCommit",
|
|
13
|
-
"getBlame",
|
|
14
|
-
"getRepository",
|
|
15
|
-
"listBranches",
|
|
16
|
-
"searchCode",
|
|
17
|
-
"addPullRequestComment",
|
|
18
|
-
"createPullRequestReview"
|
|
19
|
-
],
|
|
20
|
-
"issue-triage": [
|
|
21
|
-
"listIssues",
|
|
22
|
-
"getIssue",
|
|
23
|
-
"createIssue",
|
|
24
|
-
"addIssueComment",
|
|
25
|
-
"closeIssue",
|
|
26
|
-
"listLabels",
|
|
27
|
-
"addLabels",
|
|
28
|
-
"removeLabel",
|
|
29
|
-
"getRepository",
|
|
30
|
-
"searchRepositories",
|
|
31
|
-
"searchCode"
|
|
32
|
-
],
|
|
33
|
-
"ci-ops": [
|
|
34
|
-
"getRepository",
|
|
35
|
-
"listBranches",
|
|
36
|
-
"listCommits",
|
|
37
|
-
"getCommit",
|
|
38
|
-
"listWorkflows",
|
|
39
|
-
"listWorkflowRuns",
|
|
40
|
-
"getWorkflowRun",
|
|
41
|
-
"listWorkflowJobs",
|
|
42
|
-
"triggerWorkflow",
|
|
43
|
-
"cancelWorkflowRun",
|
|
44
|
-
"rerunWorkflowRun"
|
|
45
|
-
],
|
|
46
|
-
"repo-explorer": [
|
|
47
|
-
"getRepository",
|
|
48
|
-
"listBranches",
|
|
49
|
-
"getFileContent",
|
|
50
|
-
"listPullRequests",
|
|
51
|
-
"getPullRequest",
|
|
52
|
-
"listPullRequestFiles",
|
|
53
|
-
"listPullRequestReviews",
|
|
54
|
-
"listIssues",
|
|
55
|
-
"getIssue",
|
|
56
|
-
"listLabels",
|
|
57
|
-
"listCommits",
|
|
58
|
-
"getCommit",
|
|
59
|
-
"getBlame",
|
|
60
|
-
"searchCode",
|
|
61
|
-
"searchRepositories",
|
|
62
|
-
"listGists",
|
|
63
|
-
"getGist",
|
|
64
|
-
"listGistComments",
|
|
65
|
-
"listWorkflows",
|
|
66
|
-
"listWorkflowRuns",
|
|
67
|
-
"getWorkflowRun",
|
|
68
|
-
"listWorkflowJobs"
|
|
69
|
-
],
|
|
70
|
-
"maintainer": [
|
|
71
|
-
"getRepository",
|
|
72
|
-
"listBranches",
|
|
73
|
-
"getFileContent",
|
|
74
|
-
"createBranch",
|
|
75
|
-
"forkRepository",
|
|
76
|
-
"createRepository",
|
|
77
|
-
"createOrUpdateFile",
|
|
78
|
-
"listPullRequests",
|
|
79
|
-
"getPullRequest",
|
|
80
|
-
"listPullRequestFiles",
|
|
81
|
-
"listPullRequestReviews",
|
|
82
|
-
"createPullRequest",
|
|
83
|
-
"mergePullRequest",
|
|
84
|
-
"addPullRequestComment",
|
|
85
|
-
"createPullRequestReview",
|
|
86
|
-
"listIssues",
|
|
87
|
-
"getIssue",
|
|
88
|
-
"createIssue",
|
|
89
|
-
"addIssueComment",
|
|
90
|
-
"closeIssue",
|
|
91
|
-
"listLabels",
|
|
92
|
-
"addLabels",
|
|
93
|
-
"removeLabel",
|
|
94
|
-
"listCommits",
|
|
95
|
-
"getCommit",
|
|
96
|
-
"getBlame",
|
|
97
|
-
"searchCode",
|
|
98
|
-
"searchRepositories",
|
|
99
|
-
"listGists",
|
|
100
|
-
"getGist",
|
|
101
|
-
"listGistComments",
|
|
102
|
-
"createGist",
|
|
103
|
-
"updateGist",
|
|
104
|
-
"deleteGist",
|
|
105
|
-
"createGistComment",
|
|
106
|
-
"listWorkflows",
|
|
107
|
-
"listWorkflowRuns",
|
|
108
|
-
"getWorkflowRun",
|
|
109
|
-
"listWorkflowJobs",
|
|
110
|
-
"triggerWorkflow",
|
|
111
|
-
"cancelWorkflowRun",
|
|
112
|
-
"rerunWorkflowRun"
|
|
113
|
-
]
|
|
114
|
-
};
|
|
115
|
-
function resolveApproval(toolName, config) {
|
|
116
|
-
if (typeof config === "boolean") return config;
|
|
117
|
-
return config[toolName] ?? true;
|
|
118
|
-
}
|
|
119
|
-
function resolvePresetTools(preset) {
|
|
120
|
-
if (!preset) return null;
|
|
121
|
-
const presets = Array.isArray(preset) ? preset : [preset];
|
|
122
|
-
const tools = /* @__PURE__ */ new Set();
|
|
123
|
-
for (const p of presets) for (const t of PRESET_TOOLS[p]) tools.add(t);
|
|
124
|
-
return tools;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Create a set of GitHub tools for the Vercel AI SDK.
|
|
128
|
-
*
|
|
129
|
-
* Write operations require user approval by default.
|
|
130
|
-
* Control this globally or per-tool via `requireApproval`.
|
|
131
|
-
* Use `preset` to get only the tools you need.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```ts
|
|
135
|
-
* // All tools (default)
|
|
136
|
-
* createGithubTools({ token })
|
|
137
|
-
*
|
|
138
|
-
* // Code-review agent — only PR & commit tools
|
|
139
|
-
* createGithubTools({ token, preset: 'code-review' })
|
|
140
|
-
*
|
|
141
|
-
* // Combine presets
|
|
142
|
-
* createGithubTools({ token, preset: ['code-review', 'issue-triage'] })
|
|
143
|
-
*
|
|
144
|
-
* // Granular approval
|
|
145
|
-
* createGithubTools({
|
|
146
|
-
* token,
|
|
147
|
-
* preset: 'maintainer',
|
|
148
|
-
* requireApproval: {
|
|
149
|
-
* mergePullRequest: true,
|
|
150
|
-
* createOrUpdateFile: true,
|
|
151
|
-
* addPullRequestComment: false,
|
|
152
|
-
* }
|
|
153
|
-
* })
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
function createGithubTools({ token, requireApproval = true, preset, overrides } = {}) {
|
|
157
|
-
const resolvedToken = token || process.env.GITHUB_TOKEN;
|
|
158
|
-
if (!resolvedToken) throw new Error("GitHub token is required. Pass it as `token` or set the GITHUB_TOKEN environment variable.");
|
|
159
|
-
const approval = (name) => ({ needsApproval: resolveApproval(name, requireApproval) });
|
|
160
|
-
const allowed = preset ? resolvePresetTools(preset) : null;
|
|
161
|
-
const allTools = {
|
|
162
|
-
getRepository: getRepository(resolvedToken),
|
|
163
|
-
listBranches: listBranches(resolvedToken),
|
|
164
|
-
getFileContent: getFileContent(resolvedToken),
|
|
165
|
-
listPullRequests: listPullRequests(resolvedToken),
|
|
166
|
-
getPullRequest: getPullRequest(resolvedToken),
|
|
167
|
-
listIssues: listIssues(resolvedToken),
|
|
168
|
-
getIssue: getIssue(resolvedToken),
|
|
169
|
-
searchCode: searchCode(resolvedToken),
|
|
170
|
-
searchRepositories: searchRepositories(resolvedToken),
|
|
171
|
-
listCommits: listCommits(resolvedToken),
|
|
172
|
-
getCommit: getCommit(resolvedToken),
|
|
173
|
-
getBlame: getBlame(resolvedToken),
|
|
174
|
-
createBranch: createBranch(resolvedToken, approval("createBranch")),
|
|
175
|
-
forkRepository: forkRepository(resolvedToken, approval("forkRepository")),
|
|
176
|
-
createRepository: createRepository(resolvedToken, approval("createRepository")),
|
|
177
|
-
createOrUpdateFile: createOrUpdateFile(resolvedToken, approval("createOrUpdateFile")),
|
|
178
|
-
createPullRequest: createPullRequest(resolvedToken, approval("createPullRequest")),
|
|
179
|
-
mergePullRequest: mergePullRequest(resolvedToken, approval("mergePullRequest")),
|
|
180
|
-
addPullRequestComment: addPullRequestComment(resolvedToken, approval("addPullRequestComment")),
|
|
181
|
-
listPullRequestFiles: listPullRequestFiles(resolvedToken),
|
|
182
|
-
listPullRequestReviews: listPullRequestReviews(resolvedToken),
|
|
183
|
-
createPullRequestReview: createPullRequestReview(resolvedToken, approval("createPullRequestReview")),
|
|
184
|
-
createIssue: createIssue(resolvedToken, approval("createIssue")),
|
|
185
|
-
addIssueComment: addIssueComment(resolvedToken, approval("addIssueComment")),
|
|
186
|
-
closeIssue: closeIssue(resolvedToken, approval("closeIssue")),
|
|
187
|
-
listLabels: listLabels(resolvedToken),
|
|
188
|
-
addLabels: addLabels(resolvedToken, approval("addLabels")),
|
|
189
|
-
removeLabel: removeLabel(resolvedToken, approval("removeLabel")),
|
|
190
|
-
listGists: listGists(resolvedToken),
|
|
191
|
-
getGist: getGist(resolvedToken),
|
|
192
|
-
listGistComments: listGistComments(resolvedToken),
|
|
193
|
-
createGist: createGist(resolvedToken, approval("createGist")),
|
|
194
|
-
updateGist: updateGist(resolvedToken, approval("updateGist")),
|
|
195
|
-
deleteGist: deleteGist(resolvedToken, approval("deleteGist")),
|
|
196
|
-
createGistComment: createGistComment(resolvedToken, approval("createGistComment")),
|
|
197
|
-
listWorkflows: listWorkflows(resolvedToken),
|
|
198
|
-
listWorkflowRuns: listWorkflowRuns(resolvedToken),
|
|
199
|
-
getWorkflowRun: getWorkflowRun(resolvedToken),
|
|
200
|
-
listWorkflowJobs: listWorkflowJobs(resolvedToken),
|
|
201
|
-
triggerWorkflow: triggerWorkflow(resolvedToken, approval("triggerWorkflow")),
|
|
202
|
-
cancelWorkflowRun: cancelWorkflowRun(resolvedToken, approval("cancelWorkflowRun")),
|
|
203
|
-
rerunWorkflowRun: rerunWorkflowRun(resolvedToken, approval("rerunWorkflowRun"))
|
|
204
|
-
};
|
|
205
|
-
if (overrides) {
|
|
206
|
-
for (const [name, toolOverrides] of Object.entries(overrides)) if (name in allTools && toolOverrides) {
|
|
207
|
-
const key = name;
|
|
208
|
-
Object.assign(allTools, { [key]: {
|
|
209
|
-
...allTools[key],
|
|
210
|
-
...toolOverrides
|
|
211
|
-
} });
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (!allowed) return allTools;
|
|
215
|
-
return Object.fromEntries(Object.entries(allTools).filter(([name]) => allowed.has(name)));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
//#endregion
|
|
219
|
-
export { addIssueComment, addLabels, addPullRequestComment, cancelWorkflowRun, closeIssue, createBranch, createGist, createGistComment, createGithubAgent, createGithubTools, createIssue, createOctokit, createOrUpdateFile, createPullRequest, createPullRequestReview, createRepository, deleteGist, forkRepository, getBlame, getCommit, getFileContent, getGist, getIssue, getPullRequest, getRepository, getWorkflowRun, listBranches, listCommits, listGistComments, listGists, listIssues, listLabels, listPullRequestFiles, listPullRequestReviews, listPullRequests, listWorkflowJobs, listWorkflowRuns, listWorkflows, mergePullRequest, removeLabel, rerunWorkflowRun, searchCode, searchRepositories, triggerWorkflow, updateGist };
|
|
220
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { On as createOctokit, a as PRESET_TOOLS, i as GITHUB_TOOL_NAMES, t as GITHUB_WRITE_TOOLS } from "./write-tools-vzlewWo5.mjs";
|
|
2
|
+
import { A as removeLabel, B as createOrUpdateFile, C as addIssueComment, D as getIssue, E as createIssue, F as listPullRequestFiles, G as listBranches, H as forkRepository, I as listPullRequestReviews, L as listPullRequests, M as createPullRequest, N as createPullRequestReview, O as listIssues, P as getPullRequest, R as mergePullRequest, S as searchRepositories, T as closeIssue, U as getFileContent, V as createRepository, W as getRepository, _ as updateGist, a as getWorkflowRun, b as listCommits, c as listWorkflows, d as createGist, f as createGistComment, g as listGists, h as listGistComments, i as cancelWorkflowRun, j as addPullRequestComment, k as listLabels, l as rerunWorkflowRun, m as getGist, n as createGithubAgent, o as listWorkflowJobs, p as deleteGist, s as listWorkflowRuns, t as createGithubTools, u as triggerWorkflow, v as getBlame, w as addLabels, x as searchCode, y as getCommit, z as createBranch } from "./src-BgnkKMD7.mjs";
|
|
3
|
+
export { GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, PRESET_TOOLS, addIssueComment, addLabels, addPullRequestComment, cancelWorkflowRun, closeIssue, createBranch, createGist, createGistComment, createGithubAgent, createGithubTools, createIssue, createOctokit, createOrUpdateFile, createPullRequest, createPullRequestReview, createRepository, deleteGist, forkRepository, getBlame, getCommit, getFileContent, getGist, getIssue, getPullRequest, getRepository, getWorkflowRun, listBranches, listCommits, listGistComments, listGists, listIssues, listLabels, listPullRequestFiles, listPullRequestReviews, listPullRequests, listWorkflowJobs, listWorkflowRuns, listWorkflows, mergePullRequest, removeLabel, rerunWorkflowRun, searchCode, searchRepositories, triggerWorkflow, updateGist };
|