@github-tools/sdk 1.18.0 → 1.20.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 +60 -26
- package/dist/approval-policy--kByBqhT.mjs +17 -0
- package/dist/approval-policy--kByBqhT.mjs.map +1 -0
- package/dist/connect/eve.d.mts +2 -2
- package/dist/connect/eve.d.mts.map +1 -1
- package/dist/connect/eve.mjs +1 -1
- package/dist/connect.d.mts +15 -24
- package/dist/connect.d.mts.map +1 -1
- package/dist/connect.mjs +2 -2
- package/dist/{cores-BeLZwcde.mjs → cores-FLzAv2tu.mjs} +23 -2
- package/dist/cores-FLzAv2tu.mjs.map +1 -0
- package/dist/evaluation-BtoHbxuQ.mjs +311 -0
- package/dist/evaluation-BtoHbxuQ.mjs.map +1 -0
- package/dist/{eve-runtime-DnhM9Vog.mjs → eve-runtime-C-0doyHq.mjs} +14 -8
- package/dist/eve-runtime-C-0doyHq.mjs.map +1 -0
- package/dist/{eve-runtime-DNQrQZ36.d.mts → eve-runtime-CflZNuXD.d.mts} +6 -6
- package/dist/eve-runtime-CflZNuXD.d.mts.map +1 -0
- package/dist/eve-runtime.d.mts +5 -5
- package/dist/eve-runtime.mjs +4 -4
- package/dist/eve.d.mts +53 -4
- package/dist/eve.d.mts.map +1 -1
- package/dist/eve.mjs +52 -3
- package/dist/eve.mjs.map +1 -1
- package/dist/{index-DkZvveZP.d.mts → index-C3wlz660.d.mts} +91 -347
- package/dist/index-C3wlz660.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -3
- package/dist/{src-Bx5p1Unc.mjs → src-DyiAVHKl.mjs} +338 -15
- package/dist/src-DyiAVHKl.mjs.map +1 -0
- package/dist/tanstack.d.mts +1213 -55
- package/dist/tanstack.d.mts.map +1 -1
- package/dist/tanstack.mjs +26 -13
- package/dist/tanstack.mjs.map +1 -1
- package/dist/{token-BOLrrbTS.mjs → token-DIwB-wtp.mjs} +37 -117
- package/dist/token-DIwB-wtp.mjs.map +1 -0
- package/dist/{tool-types-CrC80SIL.d.mts → tool-types-OFyE3z0C.d.mts} +283 -54
- package/dist/tool-types-OFyE3z0C.d.mts.map +1 -0
- package/dist/{types-BmwOpI5-.d.mts → types-CJqhvQwi.d.mts} +3 -3
- package/dist/{types-BmwOpI5-.d.mts.map → types-CJqhvQwi.d.mts.map} +1 -1
- package/dist/{types-CPAsEMzx.d.mts → types-ITYfXMtY.d.mts} +2 -2
- package/dist/{types-CPAsEMzx.d.mts.map → types-ITYfXMtY.d.mts.map} +1 -1
- package/dist/workflow.d.mts +34 -40
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +17 -46
- package/dist/workflow.mjs.map +1 -1
- package/dist/{write-tools-BaoTUCg7.mjs → write-tools-DnGZw-RD.mjs} +941 -112
- package/dist/write-tools-DnGZw-RD.mjs.map +1 -0
- package/package.json +10 -12
- package/dist/cores-BeLZwcde.mjs.map +0 -1
- package/dist/evaluation-f-2QwBid.mjs +0 -210
- package/dist/evaluation-f-2QwBid.mjs.map +0 -1
- package/dist/eve-runtime-DNQrQZ36.d.mts.map +0 -1
- package/dist/eve-runtime-DnhM9Vog.mjs.map +0 -1
- package/dist/index-DkZvveZP.d.mts.map +0 -1
- package/dist/instructions-BuypoY0x.mjs +0 -148
- package/dist/instructions-BuypoY0x.mjs.map +0 -1
- package/dist/src-Bx5p1Unc.mjs.map +0 -1
- package/dist/token-BOLrrbTS.mjs.map +0 -1
- package/dist/tool-types-CrC80SIL.d.mts.map +0 -1
- package/dist/write-tools-BaoTUCg7.mjs.map +0 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { Aa as githubToolsErrors, C as GITHUB_TOOL_CATALOG, S as ALL_GITHUB_TOOL_NAMES, _ as PRESET_TOOLS, c as DEFAULT_EVALUATION_MODEL, d as RISK_QUESTION, f as conversationState, g as CORE_READ_TOOLS, l as INTENT_QUESTION, m as requiresApproval, p as rankPresets, u as PRESET_PURPOSES } from "./write-tools-DnGZw-RD.mjs";
|
|
2
|
+
import * as ai from "ai";
|
|
3
|
+
//#region src/core/model-output.ts
|
|
4
|
+
const MAX_PATCH_LENGTH = 4e3;
|
|
5
|
+
const MAX_CONTENT_LENGTH = 2e4;
|
|
6
|
+
const MAX_MODEL_TREE_ENTRIES = 200;
|
|
7
|
+
const MAX_MODEL_DIFF_FILES = 80;
|
|
8
|
+
function truncateText(text, maxLength) {
|
|
9
|
+
if (text.length <= maxLength) return text;
|
|
10
|
+
return `${text.slice(0, maxLength)}\n\n[truncated: ${text.length - maxLength} more characters]`;
|
|
11
|
+
}
|
|
12
|
+
function truncatePatchFields(files) {
|
|
13
|
+
return files.map((file) => ({
|
|
14
|
+
...file,
|
|
15
|
+
patch: file.patch ? truncateText(file.patch, MAX_PATCH_LENGTH) : file.patch
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function capDiffFiles(files) {
|
|
19
|
+
if (!files) return {
|
|
20
|
+
files,
|
|
21
|
+
filesOmitted: 0
|
|
22
|
+
};
|
|
23
|
+
const truncated = truncatePatchFields(files);
|
|
24
|
+
if (truncated.length <= MAX_MODEL_DIFF_FILES) return {
|
|
25
|
+
files: truncated,
|
|
26
|
+
filesOmitted: 0
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
files: truncated.slice(0, MAX_MODEL_DIFF_FILES),
|
|
30
|
+
filesOmitted: truncated.length - MAX_MODEL_DIFF_FILES
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function listPullRequestFilesToModelOutput({ output }) {
|
|
34
|
+
const result = output;
|
|
35
|
+
return {
|
|
36
|
+
type: "json",
|
|
37
|
+
value: {
|
|
38
|
+
...result,
|
|
39
|
+
items: truncatePatchFields(result.items)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function getCommitToModelOutput({ output }) {
|
|
44
|
+
const commit = output;
|
|
45
|
+
const { files, filesOmitted } = capDiffFiles(commit.files);
|
|
46
|
+
return {
|
|
47
|
+
type: "json",
|
|
48
|
+
value: {
|
|
49
|
+
...commit,
|
|
50
|
+
files,
|
|
51
|
+
...filesOmitted > 0 ? { filesOmitted } : {}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function compareCommitsToModelOutput({ output }) {
|
|
56
|
+
const comparison = output;
|
|
57
|
+
const { files, filesOmitted } = capDiffFiles(comparison.files);
|
|
58
|
+
return {
|
|
59
|
+
type: "json",
|
|
60
|
+
value: {
|
|
61
|
+
...comparison,
|
|
62
|
+
files,
|
|
63
|
+
...filesOmitted > 0 ? { filesOmitted } : {}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getFileContentToModelOutput({ output }) {
|
|
68
|
+
const result = output;
|
|
69
|
+
if (result.type === "directory" && "entries" in result && result.entries.length > MAX_MODEL_TREE_ENTRIES) return {
|
|
70
|
+
type: "json",
|
|
71
|
+
value: {
|
|
72
|
+
...result,
|
|
73
|
+
truncated: true,
|
|
74
|
+
entries: result.entries.slice(0, MAX_MODEL_TREE_ENTRIES),
|
|
75
|
+
entriesOmitted: result.entries.length - MAX_MODEL_TREE_ENTRIES
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if ("content" in result && result.content.length > MAX_CONTENT_LENGTH) return {
|
|
79
|
+
type: "json",
|
|
80
|
+
value: {
|
|
81
|
+
...result,
|
|
82
|
+
content: truncateText(result.content, MAX_CONTENT_LENGTH)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
type: "json",
|
|
87
|
+
value: result
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function getRepositoryTreeToModelOutput({ output }) {
|
|
91
|
+
const result = output;
|
|
92
|
+
if (result.entries.length <= MAX_MODEL_TREE_ENTRIES) return {
|
|
93
|
+
type: "json",
|
|
94
|
+
value: result
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
type: "json",
|
|
98
|
+
value: {
|
|
99
|
+
...result,
|
|
100
|
+
truncated: true,
|
|
101
|
+
entries: result.entries.slice(0, MAX_MODEL_TREE_ENTRIES),
|
|
102
|
+
entriesOmitted: result.entries.length - MAX_MODEL_TREE_ENTRIES
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getPullRequestContextToModelOutput({ output }) {
|
|
107
|
+
const result = output;
|
|
108
|
+
const { files, filesOmitted } = capDiffFiles(result.files);
|
|
109
|
+
return {
|
|
110
|
+
type: "json",
|
|
111
|
+
value: {
|
|
112
|
+
...result,
|
|
113
|
+
files,
|
|
114
|
+
...filesOmitted > 0 ? { filesOmitted } : {}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/core/evaluation.ts
|
|
120
|
+
/**
|
|
121
|
+
* Throws `EVALUATION_UNAVAILABLE` when the installed `ai` has neither `experimental_decide`
|
|
122
|
+
* nor `experimental_evaluate`. Call it where `'auto'` is configured, so a too-old `ai` fails
|
|
123
|
+
* at setup instead of mid-conversation.
|
|
124
|
+
*/
|
|
125
|
+
function assertEvaluationAvailable() {
|
|
126
|
+
loadDecide();
|
|
127
|
+
}
|
|
128
|
+
function loadDecide() {
|
|
129
|
+
const exports = ai;
|
|
130
|
+
const decide = exports.experimental_decide ?? exports.experimental_evaluate;
|
|
131
|
+
if (!decide) throw githubToolsErrors.EVALUATION_UNAVAILABLE();
|
|
132
|
+
return decide;
|
|
133
|
+
}
|
|
134
|
+
function refusedQuestions(error) {
|
|
135
|
+
return ai.Experimental_DecisionRefusalError?.isInstance(error) ? error.questionIds : void 0;
|
|
136
|
+
}
|
|
137
|
+
function warnEvaluationFailed(model, fallback, error, abortSignal) {
|
|
138
|
+
abortSignal?.throwIfAborted();
|
|
139
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
140
|
+
console.warn("[github-tools]", githubToolsErrors.EVALUATION_FAILED({
|
|
141
|
+
model: typeof model === "string" ? model : model.modelId,
|
|
142
|
+
fallback,
|
|
143
|
+
detail: cause.message,
|
|
144
|
+
cause
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
const RISK_LABELS = RISK_QUESTION.criteria.map((criterion) => criterion.slice(0, criterion.indexOf(":")));
|
|
148
|
+
/**
|
|
149
|
+
* Asks the decision model how risky a GitHub write is and whether the user asked for it, and
|
|
150
|
+
* explains the outcome: `ask` is true when a person should approve the call. A failed or refused
|
|
151
|
+
* decision asks, since it gives no evidence that the call is safe.
|
|
152
|
+
*/
|
|
153
|
+
async function autoApprovalDecision(toolName, input, messages, { model = DEFAULT_EVALUATION_MODEL, maxRisk = 1, minIntent = .6, providerOptions } = {}, abortSignal) {
|
|
154
|
+
const decide = loadDecide();
|
|
155
|
+
let refused = false;
|
|
156
|
+
const result = await decide({
|
|
157
|
+
model,
|
|
158
|
+
providerOptions,
|
|
159
|
+
state: {
|
|
160
|
+
...conversationState(messages, messageText),
|
|
161
|
+
toolCall: {
|
|
162
|
+
tool: toolName,
|
|
163
|
+
description: GITHUB_TOOL_CATALOG[toolName].description,
|
|
164
|
+
input
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
questions: {
|
|
168
|
+
risk: {
|
|
169
|
+
type: "score",
|
|
170
|
+
...RISK_QUESTION
|
|
171
|
+
},
|
|
172
|
+
intent: {
|
|
173
|
+
type: "boolean",
|
|
174
|
+
...INTENT_QUESTION
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
abortSignal
|
|
178
|
+
}).catch((error) => {
|
|
179
|
+
refused = Boolean(refusedQuestions(error));
|
|
180
|
+
if (!refused) warnEvaluationFailed(model, `asking approval for ${toolName}`, error, abortSignal);
|
|
181
|
+
});
|
|
182
|
+
if (!result) return {
|
|
183
|
+
ask: true,
|
|
184
|
+
reason: refused ? "The decision model declined to rate this call." : "The decision model was unavailable."
|
|
185
|
+
};
|
|
186
|
+
const risk = result.answers.risk.score;
|
|
187
|
+
const intent = result.answers.intent.probability;
|
|
188
|
+
const verdict = `${RISK_LABELS[Math.round(risk)]} (risk ${Number(risk.toFixed(1))} of 2), ${Math.round(intent * 100)}% likely you asked for it`;
|
|
189
|
+
return requiresApproval(risk, intent, {
|
|
190
|
+
maxRisk,
|
|
191
|
+
minIntent
|
|
192
|
+
}) ? {
|
|
193
|
+
ask: true,
|
|
194
|
+
reason: `${verdict}.`
|
|
195
|
+
} : {
|
|
196
|
+
ask: false,
|
|
197
|
+
reason: `Approved automatically: ${verdict.charAt(0).toLowerCase()}${verdict.slice(1)}.`
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/** Whether a GitHub write needs a person's approval; see {@link autoApprovalDecision}. */
|
|
201
|
+
async function needsAutoApproval(toolName, input, messages, options = {}, abortSignal) {
|
|
202
|
+
return (await autoApprovalDecision(toolName, input, messages, options, abortSignal)).ask;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Presets the latest user message needs, from one evaluation call with an independent
|
|
206
|
+
* yes/no question per preset. Returns up to `maxPresets` presets at or above
|
|
207
|
+
* `minPresetProbability`, most likely first, and read-only `repo-explorer` when none qualifies.
|
|
208
|
+
* `repo-explorer` is only combined with no other preset. Rejects when the evaluation call fails;
|
|
209
|
+
* {@link selectPresets} falls back instead. Never returns `maintainer`, so the full catalog is never exposed.
|
|
210
|
+
*/
|
|
211
|
+
async function evaluatePresets(messages, options = {}, abortSignal) {
|
|
212
|
+
const { minPresetProbability = .7, maxPresets = 2 } = options;
|
|
213
|
+
const probabilities = await decideEach(messages, Object.keys(PRESET_PURPOSES), (preset) => ({
|
|
214
|
+
instructions: "Does handling this GitHub request need the tools of this preset?",
|
|
215
|
+
criteria: { true: {
|
|
216
|
+
purpose: PRESET_PURPOSES[preset],
|
|
217
|
+
tools: [...PRESET_TOOLS[preset]]
|
|
218
|
+
} }
|
|
219
|
+
}), options, abortSignal);
|
|
220
|
+
return rankPresets(probabilities, {
|
|
221
|
+
minPresetProbability,
|
|
222
|
+
maxPresets
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Tools the latest user message needs, from one decision call with a yes/no question per tool:
|
|
227
|
+
* the core read tools, plus up to `maxTools` others at or above `minToolProbability`, most likely
|
|
228
|
+
* first. Rejects when the decision call fails; {@link selectTools} falls back instead.
|
|
229
|
+
*/
|
|
230
|
+
async function evaluateTools(messages, options = {}, abortSignal) {
|
|
231
|
+
const { minToolProbability = .5, maxTools = 8 } = options;
|
|
232
|
+
const core = CORE_READ_TOOLS;
|
|
233
|
+
const candidates = ALL_GITHUB_TOOL_NAMES.filter((name) => !core.includes(name));
|
|
234
|
+
const probabilities = await decideEach(messages, candidates, (name) => ({
|
|
235
|
+
instructions: "Does handling this GitHub request need this tool?",
|
|
236
|
+
criteria: { true: {
|
|
237
|
+
tool: name,
|
|
238
|
+
description: GITHUB_TOOL_CATALOG[name].description
|
|
239
|
+
} }
|
|
240
|
+
}), options, abortSignal);
|
|
241
|
+
const likely = candidates.filter((name) => probabilities[name] >= minToolProbability).toSorted((a, b) => probabilities[b] - probabilities[a]).slice(0, maxTools);
|
|
242
|
+
return [...core, ...likely];
|
|
243
|
+
}
|
|
244
|
+
async function decideEach(messages, keys, question, { model = DEFAULT_EVALUATION_MODEL, providerOptions }, abortSignal) {
|
|
245
|
+
const decide = loadDecide();
|
|
246
|
+
const state = conversationState(messages, messageText);
|
|
247
|
+
const ask = (asked) => decide({
|
|
248
|
+
model,
|
|
249
|
+
providerOptions,
|
|
250
|
+
state,
|
|
251
|
+
questions: Object.fromEntries(asked.map((key) => [key, {
|
|
252
|
+
type: "boolean",
|
|
253
|
+
...question(key)
|
|
254
|
+
}])),
|
|
255
|
+
abortSignal
|
|
256
|
+
});
|
|
257
|
+
const probabilities = Object.fromEntries(keys.map((key) => [key, 0]));
|
|
258
|
+
const { answers } = await ask(keys).catch((error) => {
|
|
259
|
+
const refused = refusedQuestions(error);
|
|
260
|
+
const remaining = keys.filter((key) => !refused?.includes(key));
|
|
261
|
+
if (!refused || remaining.length === 0) throw error;
|
|
262
|
+
return ask(remaining);
|
|
263
|
+
});
|
|
264
|
+
for (const [key, answer] of Object.entries(answers)) probabilities[key] = answer.probability;
|
|
265
|
+
return probabilities;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Logs `EVALUATION_FAILED` for a failed {@link evaluatePresets} call and returns the read-only
|
|
269
|
+
* `repo-explorer` fallback. Rethrows when `abortSignal` is aborted.
|
|
270
|
+
*/
|
|
271
|
+
function fallbackPresets(error, { model = DEFAULT_EVALUATION_MODEL } = {}, abortSignal) {
|
|
272
|
+
warnEvaluationFailed(model, "using the repo-explorer preset", error, abortSignal);
|
|
273
|
+
return ["repo-explorer"];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Logs `EVALUATION_FAILED` for a failed {@link evaluateTools} call and returns the read-only
|
|
277
|
+
* `repo-explorer` tools. Rethrows when `abortSignal` is aborted.
|
|
278
|
+
*/
|
|
279
|
+
function fallbackTools(error, { model = DEFAULT_EVALUATION_MODEL } = {}, abortSignal) {
|
|
280
|
+
warnEvaluationFailed(model, "using the repo-explorer tools", error, abortSignal);
|
|
281
|
+
return [...PRESET_TOOLS["repo-explorer"]];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* {@link evaluateTools}, falling back to the read-only `repo-explorer` tools (and logging
|
|
285
|
+
* `EVALUATION_FAILED`) when the decision call fails.
|
|
286
|
+
*/
|
|
287
|
+
async function selectTools(messages, options = {}, abortSignal) {
|
|
288
|
+
return evaluateTools(messages, options, abortSignal).catch((error) => fallbackTools(error, options, abortSignal));
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* {@link evaluatePresets}, falling back to read-only `repo-explorer` (and logging
|
|
292
|
+
* `EVALUATION_FAILED`) when the evaluation call fails.
|
|
293
|
+
*/
|
|
294
|
+
async function selectPresets(messages, options = {}, abortSignal) {
|
|
295
|
+
return evaluatePresets(messages, options, abortSignal).catch((error) => fallbackPresets(error, options, abortSignal));
|
|
296
|
+
}
|
|
297
|
+
function latestUserText(messages) {
|
|
298
|
+
return conversationState(messages, messageText).request;
|
|
299
|
+
}
|
|
300
|
+
/** The `request` and `repliedTo` the evaluation model sees for these messages. */
|
|
301
|
+
function evaluationRequest(messages) {
|
|
302
|
+
return conversationState(messages, messageText);
|
|
303
|
+
}
|
|
304
|
+
function messageText(message) {
|
|
305
|
+
if (typeof message.content === "string") return message.content;
|
|
306
|
+
return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
export { listPullRequestFilesToModelOutput as _, evaluationRequest as a, latestUserText as c, selectTools as d, compareCommitsToModelOutput as f, getRepositoryTreeToModelOutput as g, getPullRequestContextToModelOutput as h, evaluateTools as i, needsAutoApproval as l, getFileContentToModelOutput as m, autoApprovalDecision as n, fallbackPresets as o, getCommitToModelOutput as p, evaluatePresets as r, fallbackTools as s, assertEvaluationAvailable as t, selectPresets as u };
|
|
310
|
+
|
|
311
|
+
//# sourceMappingURL=evaluation-BtoHbxuQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation-BtoHbxuQ.mjs","names":["exports"],"sources":["../src/core/model-output.ts","../src/core/evaluation.ts"],"sourcesContent":["const MAX_PATCH_LENGTH = 4000\nconst MAX_CONTENT_LENGTH = 20000\nconst MAX_MODEL_TREE_ENTRIES = 200\nconst MAX_MODEL_DIFF_FILES = 80\n\nfunction truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text\n return `${text.slice(0, maxLength)}\\n\\n[truncated: ${text.length - maxLength} more characters]`\n}\n\nfunction truncatePatchFields<T extends { patch?: string }>(files: T[]): T[] {\n return files.map(file => ({\n ...file,\n patch: file.patch ? truncateText(file.patch, MAX_PATCH_LENGTH) : file.patch,\n }))\n}\n\nfunction capDiffFiles<T extends { patch?: string }>(files: T[] | undefined) {\n if (!files) return { files, filesOmitted: 0 }\n const truncated = truncatePatchFields(files)\n if (truncated.length <= MAX_MODEL_DIFF_FILES) return { files: truncated, filesOmitted: 0 }\n return {\n files: truncated.slice(0, MAX_MODEL_DIFF_FILES),\n filesOmitted: truncated.length - MAX_MODEL_DIFF_FILES,\n }\n}\n\ntype ToModelOutputOptions = {\n toolCallId: string\n input: unknown\n output: unknown\n}\n\ntype ListPullRequestFile = {\n filename: string\n status: string\n additions: number\n deletions: number\n changes: number\n patch?: string\n}\n\ntype ListPullRequestFilesOutput = {\n items: ListPullRequestFile[]\n hasMore: boolean\n page: number\n perPage: number\n nextPage?: number\n}\n\ntype GetCommitOutput = {\n sha: string\n message: string\n author?: string\n authorLogin?: string\n date?: string\n url: string\n stats: { additions: number, deletions: number, total: number } | null\n files?: Array<{\n filename: string\n status: string\n additions: number\n deletions: number\n patch?: string\n }>\n}\n\ntype GetFileContentOutput =\n | { type: 'directory', entries: Array<{ name: string, type: string, path: string }> }\n | { type: string, path: string }\n | {\n type: 'file'\n path: string\n sha: string\n size: number\n content: string\n totalLines?: number\n startLine?: number\n endLine?: number\n truncated?: boolean\n }\n\nexport function listPullRequestFilesToModelOutput({ output }: ToModelOutputOptions) {\n const result = output as ListPullRequestFilesOutput\n return {\n type: 'json' as const,\n value: {\n ...result,\n items: truncatePatchFields(result.items),\n },\n }\n}\n\nexport function getCommitToModelOutput({ output }: ToModelOutputOptions) {\n const commit = output as GetCommitOutput\n const { files, filesOmitted } = capDiffFiles(commit.files)\n return {\n type: 'json' as const,\n value: {\n ...commit,\n files,\n ...filesOmitted > 0 ? { filesOmitted } : {},\n },\n }\n}\n\ntype CompareCommitsOutput = {\n status: string\n aheadBy: number\n behindBy: number\n totalCommits: number\n url: string\n commits: Array<{ sha: string, message: string, author?: string, authorLogin?: string }>\n files?: Array<{\n filename: string\n status: string\n additions: number\n deletions: number\n patch?: string\n }>\n}\n\nexport function compareCommitsToModelOutput({ output }: ToModelOutputOptions) {\n const comparison = output as CompareCommitsOutput\n const { files, filesOmitted } = capDiffFiles(comparison.files)\n return {\n type: 'json' as const,\n value: {\n ...comparison,\n files,\n ...filesOmitted > 0 ? { filesOmitted } : {},\n },\n }\n}\n\nexport function getFileContentToModelOutput({ output }: ToModelOutputOptions) {\n const result = output as GetFileContentOutput\n if (result.type === 'directory' && 'entries' in result && result.entries.length > MAX_MODEL_TREE_ENTRIES) {\n return {\n type: 'json' as const,\n value: {\n ...result,\n truncated: true,\n entries: result.entries.slice(0, MAX_MODEL_TREE_ENTRIES),\n entriesOmitted: result.entries.length - MAX_MODEL_TREE_ENTRIES,\n },\n }\n }\n if ('content' in result && result.content.length > MAX_CONTENT_LENGTH) {\n return {\n type: 'json' as const,\n value: {\n ...result,\n content: truncateText(result.content, MAX_CONTENT_LENGTH),\n },\n }\n }\n return { type: 'json' as const, value: result }\n}\n\ntype GetRepositoryTreeOutput = {\n sha: string\n truncated: boolean\n path?: string\n entries: Array<{ path?: string, type?: string, size?: number, sha?: string }>\n}\n\nexport function getRepositoryTreeToModelOutput({ output }: ToModelOutputOptions) {\n const result = output as GetRepositoryTreeOutput\n if (result.entries.length <= MAX_MODEL_TREE_ENTRIES) {\n return { type: 'json' as const, value: result }\n }\n return {\n type: 'json' as const,\n value: {\n ...result,\n truncated: true,\n entries: result.entries.slice(0, MAX_MODEL_TREE_ENTRIES),\n entriesOmitted: result.entries.length - MAX_MODEL_TREE_ENTRIES,\n },\n }\n}\n\ntype GetPullRequestContextOutput = {\n pullRequest: {\n number: number\n title: string\n body: string | null\n state: string\n url: string\n author?: string\n branch: string\n headSha: string\n base: string\n draft?: boolean\n merged: boolean\n mergeable: boolean | null\n additions: number\n deletions: number\n changedFiles: number\n createdAt: string\n updatedAt: string\n mergedAt: string | null\n }\n files?: ListPullRequestFile[]\n filesHasMore?: boolean\n reviews?: Array<{\n id: number\n state: string\n body: string\n author?: string\n url: string\n submittedAt?: string | null\n }>\n checks?: {\n checkRuns: {\n totalCount: number\n checkRuns: Array<{\n id: number\n name: string\n status: string\n conclusion: string | null\n url: string | null\n startedAt: string | null\n completedAt: string | null\n }>\n }\n combinedStatus: {\n state: string\n totalCount: number\n statuses: Array<{\n context: string\n state: string\n description: string | null\n url: string | null\n }>\n }\n }\n}\n\nexport function getPullRequestContextToModelOutput({ output }: ToModelOutputOptions) {\n const result = output as GetPullRequestContextOutput\n const { files, filesOmitted } = capDiffFiles(result.files)\n return {\n type: 'json' as const,\n value: {\n ...result,\n files,\n ...filesOmitted > 0 ? { filesOmitted } : {},\n },\n }\n}\n","import * as ai from 'ai'\nimport type { Experimental_EvaluationModel, JSONValue, ModelMessage } from 'ai'\nimport { GITHUB_TOOL_CATALOG } from './catalog'\nimport { githubToolsErrors } from './errors'\nimport { CORE_READ_TOOLS, PRESET_TOOLS } from './presets'\nimport { ALL_GITHUB_TOOL_NAMES, type GithubToolName } from './tool-names'\nimport { DEFAULT_EVALUATION_MODEL, RISK_QUESTION, INTENT_QUESTION, PRESET_PURPOSES, conversationState, rankPresets, requiresApproval, type RoutablePreset } from './evaluation-policy'\nexport { DEFAULT_EVALUATION_MODEL, AUTO_APPROVAL_TOOLS } from './evaluation-policy'\nimport type { GithubWriteToolName } from './write-tools'\n\n/**\n * Tuning for `requireApproval: 'auto'` and `preset: 'auto'`. Every field is optional.\n */\nexport type GithubEvaluationOptions = {\n /**\n * Decision model for AI SDK `experimental_decide`: an AI Gateway ID or a model instance.\n * @default 'typesafe-ai/jev-1.14.0'\n */\n model?: Experimental_EvaluationModel\n /**\n * Provider options passed to every decision call, for example AI Gateway settings such as\n * `{ gateway: { zeroDataRetention: true } }`.\n */\n providerOptions?: Record<string, Record<string, JSONValue>>\n /**\n * Highest risk an `'auto'` tool call can have and still run without approval, on a 0–2 scale\n * (0 negligible, 1 visible but reversible, 2 hard to undo).\n * @default 1\n */\n maxRisk?: number\n /**\n * Lowest probability that the latest user message asked for the call, for it to run without approval.\n * @default 0.6\n */\n minIntent?: number\n /**\n * Lowest probability for `preset: 'auto'` to select a preset. When no preset reaches it,\n * read-only `repo-explorer` is used.\n * @default 0.7\n */\n minPresetProbability?: number\n /**\n * Most presets `preset: 'auto'` combines in one call, keeping the most likely ones.\n * @default 2\n */\n maxPresets?: number\n /**\n * What `preset: 'auto'` picks. `'tools'` asks the decision model about each tool and lists only\n * the likely ones plus the core read tools (`CORE_READ_TOOLS`), so the model sees far fewer tool\n * definitions. The rest stays reachable: eve defers it, and `createGithubAgent` adds a\n * `callGithubTool` tool. `'presets'` lists the tools of up to `maxPresets` presets and, on\n * `createGithubAgent`, uses their system prompts.\n * @default 'tools'\n */\n selection?: 'presets' | 'tools'\n /**\n * How long a `preset: 'auto'` decision lasts. `'session'` decides once, on the conversation's\n * first request, so the listed tools, and the provider's cached prompt prefix they start, stay\n * the same for the rest of the conversation; later needs go through deferred tools (eve) or\n * `callGithubTool` (`createGithubAgent`, which doesn't support it with `selection: 'presets'`).\n * `'turn'` decides again for each new request, which changes the tool list and makes the\n * provider write the whole conversation to its prompt cache again.\n * @default 'session', except `'turn'` for presets on `createGithubAgent`\n */\n scope?: 'turn' | 'session'\n /**\n * Keeps `createGithubAgent`'s `preset: 'auto'` decisions across processes, such as serverless\n * instances, under keys derived from the request and the routing settings (decision model,\n * thresholds and caps), so agents configured differently don't share decisions. Without it, a decision\n * lives in this process's memory, and another process decides again: that costs a decision\n * call, and a different pick changes the tool list and invalidates the provider's prompt cache.\n * The eve extension keeps decisions in the session and ignores this option.\n */\n store?: {\n get: (key: string) => Promise<readonly string[] | undefined>\n set: (key: string, value: readonly string[]) => Promise<void>\n }\n /**\n * Lowest probability for `selection: 'tools'` to list a tool beyond the core read tools.\n * @default 0.5\n */\n minToolProbability?: number\n /**\n * Most tools `selection: 'tools'` lists beyond the core read tools, keeping the most likely ones.\n * @default 8\n */\n maxTools?: number\n}\n\n/**\n * Throws `EVALUATION_UNAVAILABLE` when the installed `ai` has neither `experimental_decide`\n * nor `experimental_evaluate`. Call it where `'auto'` is configured, so a too-old `ai` fails\n * at setup instead of mid-conversation.\n */\nexport function assertEvaluationAvailable() {\n loadDecide()\n}\n\n// `experimental_decide` replaced `experimental_evaluate` in ai 7.0.128; the old name stays an alias.\nfunction loadDecide(): typeof ai.experimental_decide {\n const exports: Partial<Pick<typeof ai, 'experimental_decide' | 'experimental_evaluate'>> = ai\n const decide = exports.experimental_decide ?? exports.experimental_evaluate\n if (!decide) throw githubToolsErrors.EVALUATION_UNAVAILABLE()\n return decide\n}\n\n// `decide` throws when the model refuses any question; the error names the refused questions.\nfunction refusedQuestions(error: unknown): readonly string[] | undefined {\n const exports: Partial<Pick<typeof ai, 'Experimental_DecisionRefusalError'>> = ai\n return exports.Experimental_DecisionRefusalError?.isInstance(error) ? error.questionIds : undefined\n}\n\nfunction warnEvaluationFailed(model: Experimental_EvaluationModel, fallback: string, error: unknown, abortSignal?: AbortSignal) {\n abortSignal?.throwIfAborted()\n const cause = error instanceof Error ? error : new Error(String(error))\n console.warn('[github-tools]', githubToolsErrors.EVALUATION_FAILED({\n model: typeof model === 'string' ? model : model.modelId,\n fallback,\n detail: cause.message,\n cause,\n }))\n}\n\n/** Whether a person should approve a GitHub write, and why, as a short sentence for the approval request. */\nexport type AutoApprovalDecision = { ask: boolean, reason: string }\n\nconst RISK_LABELS = RISK_QUESTION.criteria.map(criterion => criterion.slice(0, criterion.indexOf(':')))\n\n/**\n * Asks the decision model how risky a GitHub write is and whether the user asked for it, and\n * explains the outcome: `ask` is true when a person should approve the call. A failed or refused\n * decision asks, since it gives no evidence that the call is safe.\n */\nexport async function autoApprovalDecision(\n toolName: GithubWriteToolName,\n input: unknown,\n messages: readonly ModelMessage[],\n { model = DEFAULT_EVALUATION_MODEL, maxRisk = 1, minIntent = 0.6, providerOptions }: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<AutoApprovalDecision> {\n const decide = loadDecide()\n let refused = false\n const result = await decide({\n model,\n providerOptions,\n state: {\n ...conversationState(messages, messageText),\n toolCall: {\n tool: toolName,\n description: GITHUB_TOOL_CATALOG[toolName].description,\n input: input as JSONValue,\n },\n },\n questions: {\n risk: { type: 'score', ...RISK_QUESTION },\n intent: { type: 'boolean', ...INTENT_QUESTION },\n },\n abortSignal,\n }).catch((error: unknown) => {\n // A refusal is an answer, not an outage: it gives no evidence the call is safe, so a person decides.\n refused = Boolean(refusedQuestions(error))\n if (!refused) warnEvaluationFailed(model, `asking approval for ${toolName}`, error, abortSignal)\n return undefined\n })\n if (!result) return { ask: true, reason: refused ? 'The decision model declined to rate this call.' : 'The decision model was unavailable.' }\n const risk = result.answers.risk.score\n const intent = result.answers.intent.probability\n // Jev scores risk on a continuous 0–2 scale, so the label is the nearest rubric level.\n const verdict = `${RISK_LABELS[Math.round(risk)]} (risk ${Number(risk.toFixed(1))} of 2), ${Math.round(intent * 100)}% likely you asked for it`\n return requiresApproval(risk, intent, { maxRisk, minIntent })\n ? { ask: true, reason: `${verdict}.` }\n : { ask: false, reason: `Approved automatically: ${verdict.charAt(0).toLowerCase()}${verdict.slice(1)}.` }\n}\n\n/** Whether a GitHub write needs a person's approval; see {@link autoApprovalDecision}. */\nexport async function needsAutoApproval(\n toolName: GithubWriteToolName,\n input: unknown,\n messages: readonly ModelMessage[],\n options: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<boolean> {\n return (await autoApprovalDecision(toolName, input, messages, options, abortSignal)).ask\n}\n\n/**\n * Presets the latest user message needs, from one evaluation call with an independent\n * yes/no question per preset. Returns up to `maxPresets` presets at or above\n * `minPresetProbability`, most likely first, and read-only `repo-explorer` when none qualifies.\n * `repo-explorer` is only combined with no other preset. Rejects when the evaluation call fails;\n * {@link selectPresets} falls back instead. Never returns `maintainer`, so the full catalog is never exposed.\n */\nexport async function evaluatePresets(\n messages: readonly ModelMessage[],\n options: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<RoutablePreset[]> {\n const { minPresetProbability = 0.7, maxPresets = 2 } = options\n const presets = Object.keys(PRESET_PURPOSES) as RoutablePreset[]\n const probabilities = await decideEach(messages, presets, preset => ({\n instructions: 'Does handling this GitHub request need the tools of this preset?',\n criteria: { true: { purpose: PRESET_PURPOSES[preset], tools: [...PRESET_TOOLS[preset]] } },\n }), options, abortSignal)\n return rankPresets(probabilities, { minPresetProbability, maxPresets })\n}\n\n/**\n * Tools the latest user message needs, from one decision call with a yes/no question per tool:\n * the core read tools, plus up to `maxTools` others at or above `minToolProbability`, most likely\n * first. Rejects when the decision call fails; {@link selectTools} falls back instead.\n */\nexport async function evaluateTools(\n messages: readonly ModelMessage[],\n options: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<GithubToolName[]> {\n const { minToolProbability = 0.5, maxTools = 8 } = options\n const core: readonly GithubToolName[] = CORE_READ_TOOLS\n const candidates = ALL_GITHUB_TOOL_NAMES.filter(name => !core.includes(name))\n const probabilities = await decideEach(messages, candidates, name => ({\n instructions: 'Does handling this GitHub request need this tool?',\n criteria: { true: { tool: name, description: GITHUB_TOOL_CATALOG[name].description } },\n }), options, abortSignal)\n const likely = candidates\n .filter(name => probabilities[name] >= minToolProbability)\n .toSorted((a, b) => probabilities[b] - probabilities[a])\n .slice(0, maxTools)\n return [...core, ...likely]\n}\n\ntype BooleanQuestion = { instructions: string, criteria: { true: Record<string, JSONValue> } }\n\n// One boolean question per key against the conversation. A refused question counts as a no:\n// ask once more without it instead of losing every answer.\nasync function decideEach<K extends string>(\n messages: readonly ModelMessage[],\n keys: readonly K[],\n question: (key: K) => BooleanQuestion,\n { model = DEFAULT_EVALUATION_MODEL, providerOptions }: GithubEvaluationOptions,\n abortSignal?: AbortSignal,\n): Promise<Record<K, number>> {\n const decide = loadDecide()\n const state = conversationState(messages, messageText)\n const ask = (asked: readonly K[]) => decide({\n model,\n providerOptions,\n state,\n questions: Object.fromEntries(asked.map(key => [key, { type: 'boolean' as const, ...question(key) }])),\n abortSignal,\n })\n const probabilities = Object.fromEntries(keys.map(key => [key, 0])) as Record<K, number>\n const { answers } = await ask(keys).catch((error: unknown) => {\n const refused = refusedQuestions(error)\n const remaining = keys.filter(key => !refused?.includes(key))\n if (!refused || remaining.length === 0) throw error\n return ask(remaining)\n })\n for (const [key, answer] of Object.entries(answers)) probabilities[key as K] = answer.probability\n return probabilities\n}\n\n/**\n * Logs `EVALUATION_FAILED` for a failed {@link evaluatePresets} call and returns the read-only\n * `repo-explorer` fallback. Rethrows when `abortSignal` is aborted.\n */\nexport function fallbackPresets(error: unknown, { model = DEFAULT_EVALUATION_MODEL }: GithubEvaluationOptions = {}, abortSignal?: AbortSignal): RoutablePreset[] {\n warnEvaluationFailed(model, 'using the repo-explorer preset', error, abortSignal)\n return ['repo-explorer']\n}\n\n/**\n * Logs `EVALUATION_FAILED` for a failed {@link evaluateTools} call and returns the read-only\n * `repo-explorer` tools. Rethrows when `abortSignal` is aborted.\n */\nexport function fallbackTools(error: unknown, { model = DEFAULT_EVALUATION_MODEL }: GithubEvaluationOptions = {}, abortSignal?: AbortSignal): GithubToolName[] {\n warnEvaluationFailed(model, 'using the repo-explorer tools', error, abortSignal)\n return [...PRESET_TOOLS['repo-explorer']]\n}\n\n/**\n * {@link evaluateTools}, falling back to the read-only `repo-explorer` tools (and logging\n * `EVALUATION_FAILED`) when the decision call fails.\n */\nexport async function selectTools(\n messages: readonly ModelMessage[],\n options: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<GithubToolName[]> {\n return evaluateTools(messages, options, abortSignal).catch(error => fallbackTools(error, options, abortSignal))\n}\n\n/**\n * {@link evaluatePresets}, falling back to read-only `repo-explorer` (and logging\n * `EVALUATION_FAILED`) when the evaluation call fails.\n */\nexport async function selectPresets(\n messages: readonly ModelMessage[],\n options: GithubEvaluationOptions = {},\n abortSignal?: AbortSignal,\n): Promise<RoutablePreset[]> {\n return evaluatePresets(messages, options, abortSignal).catch(error => fallbackPresets(error, options, abortSignal))\n}\n\nexport function latestUserText(messages: readonly ModelMessage[]): string {\n return conversationState(messages, messageText).request\n}\n\n/** The `request` and `repliedTo` the evaluation model sees for these messages. */\nexport function evaluationRequest(messages: readonly ModelMessage[]) {\n return conversationState(messages, messageText)\n}\n\nfunction messageText(message: ModelMessage): string {\n if (typeof message.content === 'string') return message.content\n return message.content.flatMap(part => part.type === 'text' ? [part.text] : []).join('\\n')\n}\n"],"mappings":";;;AAAA,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAE7B,SAAS,aAAa,MAAc,WAA2B;CAC7D,IAAI,KAAK,UAAU,WAAW,OAAO;CACrC,OAAO,GAAG,KAAK,MAAM,GAAG,SAAS,EAAE,kBAAkB,KAAK,SAAS,UAAU;AAC/E;AAEA,SAAS,oBAAkD,OAAiB;CAC1E,OAAO,MAAM,KAAI,UAAS;EACxB,GAAG;EACH,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,gBAAgB,IAAI,KAAK;CACxE,EAAE;AACJ;AAEA,SAAS,aAA2C,OAAwB;CAC1E,IAAI,CAAC,OAAO,OAAO;EAAE;EAAO,cAAc;CAAE;CAC5C,MAAM,YAAY,oBAAoB,KAAK;CAC3C,IAAI,UAAU,UAAU,sBAAsB,OAAO;EAAE,OAAO;EAAW,cAAc;CAAE;CACzF,OAAO;EACL,OAAO,UAAU,MAAM,GAAG,oBAAoB;EAC9C,cAAc,UAAU,SAAS;CACnC;AACF;AAyDA,SAAgB,kCAAkC,EAAE,UAAgC;CAClF,MAAM,SAAS;CACf,OAAO;EACL,MAAM;EACN,OAAO;GACL,GAAG;GACH,OAAO,oBAAoB,OAAO,KAAK;EACzC;CACF;AACF;AAEA,SAAgB,uBAAuB,EAAE,UAAgC;CACvE,MAAM,SAAS;CACf,MAAM,EAAE,OAAO,iBAAiB,aAAa,OAAO,KAAK;CACzD,OAAO;EACL,MAAM;EACN,OAAO;GACL,GAAG;GACH;GACA,GAAG,eAAe,IAAI,EAAE,aAAa,IAAI,CAAC;EAC5C;CACF;AACF;AAkBA,SAAgB,4BAA4B,EAAE,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,iCAAiC,OAAO,WAAW;CAC/E,OAAO,CAAC,GAAG,aAAa,gBAAgB;AAC1C;;;;;AAMA,eAAsB,YACpB,UACA,UAAmC,CAAC,GACpC,aAC2B;CAC3B,OAAO,cAAc,UAAU,SAAS,WAAW,CAAC,CAAC,OAAM,UAAS,cAAc,OAAO,SAAS,WAAW,CAAC;AAChH;;;;;AAMA,eAAsB,cACpB,UACA,UAAmC,CAAC,GACpC,aAC2B;CAC3B,OAAO,gBAAgB,UAAU,SAAS,WAAW,CAAC,CAAC,OAAM,UAAS,gBAAgB,OAAO,SAAS,WAAW,CAAC;AACpH;AAEA,SAAgB,eAAe,UAA2C;CACxE,OAAO,kBAAkB,UAAU,WAAW,CAAC,CAAC;AAClD;;AAGA,SAAgB,kBAAkB,UAAmC;CACnE,OAAO,kBAAkB,UAAU,WAAW;AAChD;AAEA,SAAS,YAAY,SAA+B;CAClD,IAAI,OAAO,QAAQ,YAAY,UAAU,OAAO,QAAQ;CACxD,OAAO,QAAQ,QAAQ,SAAQ,SAAQ,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;AAC3F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as GITHUB_TOOL_CORES } from "./cores-
|
|
1
|
+
import { C as GITHUB_TOOL_CATALOG, Ma as stripRateLimit, S as ALL_GITHUB_TOOL_NAMES, a as mergeContextArgs, b as githubTokenCall, ja as toModelErrorPayload, ka as EvlogError, o as softenContextSchema, v as resolvePresetTools, w as isGithubWriteToolName, x as resolveGithubToken, y as createGithubTokenResolver } from "./write-tools-DnGZw-RD.mjs";
|
|
2
|
+
import { _ as listPullRequestFilesToModelOutput, f as compareCommitsToModelOutput, g as getRepositoryTreeToModelOutput, h as getPullRequestContextToModelOutput, m as getFileContentToModelOutput, p as getCommitToModelOutput } from "./evaluation-BtoHbxuQ.mjs";
|
|
3
|
+
import { t as GITHUB_TOOL_CORES } from "./cores-FLzAv2tu.mjs";
|
|
4
4
|
import * as eveTools from "eve/tools";
|
|
5
5
|
import * as eveApproval from "eve/tools/approval";
|
|
6
6
|
//#region src/eve/load-eve.ts
|
|
@@ -115,7 +115,13 @@ function createToolRegistry(ctx, names = ALL_GITHUB_TOOL_NAMES) {
|
|
|
115
115
|
committer: ctx.committer,
|
|
116
116
|
coAuthors: ctx.coAuthors
|
|
117
117
|
},
|
|
118
|
-
|
|
118
|
+
editFiles: {
|
|
119
|
+
author: ctx.author,
|
|
120
|
+
committer: ctx.committer,
|
|
121
|
+
coAuthors: ctx.coAuthors
|
|
122
|
+
},
|
|
123
|
+
mergePullRequest: { coAuthors: ctx.coAuthors },
|
|
124
|
+
enablePullRequestAutoMerge: { coAuthors: ctx.coAuthors }
|
|
119
125
|
};
|
|
120
126
|
const entries = names.map((name) => {
|
|
121
127
|
const descriptor = GITHUB_TOOL_CATALOG[name];
|
|
@@ -140,7 +146,7 @@ function createToolRegistry(ctx, names = ALL_GITHUB_TOOL_NAMES) {
|
|
|
140
146
|
//#region src/eve/steps.ts
|
|
141
147
|
async function executeGithubToolStep(name, input, ctx) {
|
|
142
148
|
"use step";
|
|
143
|
-
const entry = createToolRegistry(ctx
|
|
149
|
+
const [entry] = createToolRegistry(ctx, ALL_GITHUB_TOOL_NAMES.filter((tool) => tool === name));
|
|
144
150
|
if (!entry) throw new Error(`Unknown GitHub tool: ${name}`);
|
|
145
151
|
return entry.execute(input);
|
|
146
152
|
}
|
|
@@ -196,7 +202,7 @@ function buildEveToolDefinition(name, options = {}) {
|
|
|
196
202
|
committer: options.committer,
|
|
197
203
|
coAuthors: options.coAuthors
|
|
198
204
|
};
|
|
199
|
-
const entry = createToolRegistry(ctx
|
|
205
|
+
const [entry] = createToolRegistry(ctx, ALL_GITHUB_TOOL_NAMES.filter((tool) => tool === name));
|
|
200
206
|
if (!entry) throw new Error(`Unknown GitHub tool: ${name}`);
|
|
201
207
|
const approval = entry.writeTool ? resolveEveToolApproval(entry.writeTool, options.requireApproval) : void 0;
|
|
202
208
|
return applyOverrides(defineTool({
|
|
@@ -235,7 +241,7 @@ function buildEveToolMap(options = {}) {
|
|
|
235
241
|
}
|
|
236
242
|
function createEveGithubToolsDynamic(options = {}) {
|
|
237
243
|
const { defineDynamic } = getEveTools();
|
|
238
|
-
return defineDynamic(
|
|
244
|
+
return defineDynamic(() => buildEveToolMap(options));
|
|
239
245
|
}
|
|
240
246
|
function listResolvedEveToolNames(options = {}) {
|
|
241
247
|
const isAllowed = resolveAllowedToolNames(options);
|
|
@@ -276,4 +282,4 @@ async function executeGithubEveTool(name, input, options = {}) {
|
|
|
276
282
|
//#endregion
|
|
277
283
|
export { listEveToolDescriptors as a, hasGithubEveToolModelOutput as c, resolveEveApproval as d, resolveEveToolApproval as f, executeGithubEveTool as i, isEveApprovalDisabled as l, buildEveToolMap as n, listResolvedEveToolNames as o, MISSING_EVE_MESSAGE as p, createEveGithubToolsDynamic as r, formatGithubEveToolOutput as s, buildEveToolDefinition as t, mapEveApprovalValue as u };
|
|
278
284
|
|
|
279
|
-
//# sourceMappingURL=eve-runtime-
|
|
285
|
+
//# sourceMappingURL=eve-runtime-C-0doyHq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eve-runtime-C-0doyHq.mjs","names":[],"sources":["../src/eve/load-eve.ts","../src/eve/approval.ts","../src/eve/registry.ts","../src/eve/steps.ts","../src/eve/build.ts"],"sourcesContent":["import * as eveTools from 'eve/tools'\nimport * as eveApproval from 'eve/tools/approval'\n\n/**\n * Static ESM imports so bundlers (eve/Nitro/Vercel) can resolve `eve` when it is\n * compiled into the output rather than left as `node_modules/eve` at runtime.\n * Runtime `createRequire(\"eve/tools\")` fails in those targets.\n */\nexport type EveToolsModule = typeof import('eve/tools')\nexport type EveApprovalModule = typeof import('eve/tools/approval')\n\n/**\n * @deprecated Never thrown since eve moved to static ESM imports — a missing\n * `eve` package now fails at module resolution with the bundler/runtime's own\n * error. Kept only for backward compatibility of the public export; do not\n * match on it. Will be removed in the next major.\n */\nexport const MISSING_EVE_MESSAGE =\n 'The \"eve\" package is required to use @github-tools/sdk/eve. Install it with: pnpm add eve'\n\nexport function getEveTools(): EveToolsModule {\n return eveTools\n}\n\nexport function getEveApprovalHelpers(): EveApprovalModule {\n return eveApproval\n}\n","import type { Approval, ApprovalPolicy } from 'eve/tools/approval'\nimport type { GithubWriteToolName } from '../core/write-tools'\nimport { getEveApprovalHelpers } from './load-eve'\nimport type { EveApprovalConfig, EveApprovalValue } from './types'\n\n/**\n * `false` / `'never'` should omit the tool `approval` field entirely.\n * eve treats a missing `approval` like `never()`; attaching `never()` is\n * redundant and has caused approval UI noise on some channels.\n */\nexport function isEveApprovalDisabled(value: EveApprovalValue | undefined): boolean {\n return value === false || value === 'never'\n}\n\nexport function mapEveApprovalValue(value: EveApprovalValue): ApprovalPolicy {\n if (typeof value === 'function') return value\n // Object-shaped eve `ApprovalConfiguration` — the request-time policy lives on `request`.\n if (typeof value === 'object') return value.request\n\n const { always, never, once } = getEveApprovalHelpers()\n\n if (value === true || value === 'always') return always()\n if (value === false || value === 'never') return never()\n return once()\n}\n\nexport function resolveEveApproval(\n toolName: GithubWriteToolName,\n config: EveApprovalConfig | undefined,\n): ApprovalPolicy {\n if (config === undefined) return getEveApprovalHelpers().always()\n if (config === true) return getEveApprovalHelpers().always()\n if (config === false) return getEveApprovalHelpers().never()\n\n const value = config[toolName]\n if (value === undefined) return getEveApprovalHelpers().always()\n\n return mapEveApprovalValue(value)\n}\n\n/**\n * Approval to attach on a write tool, or `undefined` to omit the field.\n * Prefer this when building `defineTool` values so `false` / `'never'` do not\n * attach a redundant `never()` handler.\n */\nexport function resolveEveToolApproval(\n toolName: GithubWriteToolName,\n config: EveApprovalConfig | undefined,\n override?: EveApprovalValue,\n): Approval | undefined {\n const value = override !== undefined\n ? override\n : typeof config === 'object' && config !== null\n ? config[toolName]\n : config\n\n if (value === undefined) return getEveApprovalHelpers().always()\n if (isEveApprovalDisabled(value)) return undefined\n // Pass policies and `ApprovalConfiguration` objects through unchanged so a\n // response-time authorizer (`response`) survives onto `defineTool`.\n if (typeof value === 'function' || typeof value === 'object') return value\n return mapEveApprovalValue(value)\n}\n","import type { ToolModelOutput } from 'eve/tools'\nimport type { z } from 'zod'\nimport type { CommitIdentity } from '../types'\nimport { GITHUB_TOOL_CATALOG, isGithubWriteToolName } from '../core/catalog'\nimport { GITHUB_TOOL_CORES } from '../core/cores'\nimport { mergeContextArgs, softenContextSchema, type GithubToolsContext } from '../core/context'\nimport {\n compareCommitsToModelOutput,\n getCommitToModelOutput,\n getFileContentToModelOutput,\n getPullRequestContextToModelOutput,\n getRepositoryTreeToModelOutput,\n listPullRequestFilesToModelOutput,\n} from '../core/model-output'\nimport { stripRateLimit } from '../core/rate-limit'\nimport { resolveGithubToken, type GithubTokenInput } from '../core/token'\nimport type { GithubWriteToolName } from '../core/write-tools'\nimport { ALL_GITHUB_TOOL_NAMES, type GithubToolName } from '../core/tool-names'\nexport type { GithubToolName } from '../core/tool-names'\nexport { ALL_GITHUB_TOOL_NAMES } from '../core/tool-names'\n\nexport type ToolBuildContext = {\n token: GithubTokenInput\n context?: GithubToolsContext\n author?: CommitIdentity\n committer?: CommitIdentity\n coAuthors?: CommitIdentity[]\n}\n\ntype ToolRegistryEntry = {\n name: GithubToolName\n writeTool?: GithubWriteToolName\n description: string\n inputSchema: z.ZodType\n execute: (args: Record<string, unknown>) => Promise<unknown>\n toModelOutput?: (output: unknown) => ToolModelOutput\n}\n\nfunction withToken<T extends Record<string, unknown>>(\n core: (args: T & { token: string }) => Promise<unknown>,\n ctx: ToolBuildContext,\n extra?: Record<string, unknown>,\n) {\n return async (input: Record<string, unknown>) =>\n core({\n token: await resolveGithubToken(ctx.token),\n ...extra,\n ...mergeContextArgs(input, ctx.context ?? {}),\n } as T & { token: string })\n}\n\nfunction modelOutputAdapter(\n fn: (options: { toolCallId: string, input: unknown, output: unknown }) => { type: 'json' | 'text', value: unknown },\n) {\n return (output: unknown) => fn({ toolCallId: '', input: {}, output }) as ToolModelOutput\n}\n\nconst GITHUB_EVE_TOOL_MODEL_OUTPUT = {\n getFileContent: modelOutputAdapter(getFileContentToModelOutput),\n getRepositoryTree: modelOutputAdapter(getRepositoryTreeToModelOutput),\n listPullRequestFiles: modelOutputAdapter(listPullRequestFilesToModelOutput),\n getPullRequestContext: modelOutputAdapter(getPullRequestContextToModelOutput),\n getCommit: modelOutputAdapter(getCommitToModelOutput),\n compareCommits: modelOutputAdapter(compareCommitsToModelOutput),\n} satisfies Partial<Record<GithubToolName, (output: unknown) => ToolModelOutput>>\n\nconst EVE_TOOL_MODEL_OUTPUTS: Partial<Record<GithubToolName, (output: unknown) => ToolModelOutput>> = GITHUB_EVE_TOOL_MODEL_OUTPUT\n\n/** Whether a GitHub tool has a built-in eve `toModelOutput` projection. */\nexport function hasGithubEveToolModelOutput(name: GithubToolName): boolean {\n return Object.hasOwn(GITHUB_EVE_TOOL_MODEL_OUTPUT, name)\n}\n\n/**\n * Apply the built-in eve `toModelOutput` projection for a tool.\n * Strips `rateLimit` so it never reaches the model. Tools without a dedicated\n * formatter get `{ type: 'json', value }` of the remaining payload.\n * Used by `@github-tools/eve-extension` so the callback only closes over a serializable tool name.\n */\nexport function formatGithubEveToolOutput(name: GithubToolName, output: unknown): ToolModelOutput {\n const stripped = stripRateLimit(output)\n // `runGithubToolStep` returns `{ error }` when execute throws. The per-tool\n // formatters assume the success shape (e.g. `listPullRequestFilesToModelOutput`\n // calls `.map` on the payload), so dispatching an error payload would throw a\n // second time inside model-output formatting and re-break the tool loop.\n if (isErrorPayload(stripped)) {\n return { type: 'json', value: stripped }\n }\n const format = GITHUB_EVE_TOOL_MODEL_OUTPUT[name as keyof typeof GITHUB_EVE_TOOL_MODEL_OUTPUT]\n if (!format) {\n return { type: 'json', value: stripped }\n }\n return format(stripped)\n}\n\nfunction isErrorPayload(output: unknown): output is { error: string | Record<string, string> } {\n if (output == null || typeof output !== 'object' || Array.isArray(output)) return false\n const { error } = output as { error?: unknown }\n return typeof error === 'string' || (error != null && typeof error === 'object')\n}\n\nexport function createToolRegistry(\n ctx: ToolBuildContext,\n names: readonly GithubToolName[] = ALL_GITHUB_TOOL_NAMES,\n): ToolRegistryEntry[] {\n // Commit-identity options are session-level, not model inputs, so they ride\n // alongside the token instead of living in the tool's input schema.\n const commitExtras: Partial<Record<GithubToolName, Record<string, unknown>>> = {\n createOrUpdateFile: { author: ctx.author, committer: ctx.committer, coAuthors: ctx.coAuthors },\n editFiles: { author: ctx.author, committer: ctx.committer, coAuthors: ctx.coAuthors },\n mergePullRequest: { coAuthors: ctx.coAuthors },\n enablePullRequestAutoMerge: { coAuthors: ctx.coAuthors },\n }\n\n const entries = names.map((name): ToolRegistryEntry => {\n const descriptor = GITHUB_TOOL_CATALOG[name]\n // Argument types vary per tool; `withToken` re-narrows at the dispatch boundary.\n const core = GITHUB_TOOL_CORES[name] as (args: Record<string, unknown> & { token: string }) => Promise<unknown>\n const toModelOutput = EVE_TOOL_MODEL_OUTPUTS[name]\n return {\n name,\n ...(isGithubWriteToolName(name) && { writeTool: name }),\n description: descriptor.description,\n inputSchema: descriptor.inputSchema,\n execute: withToken(core, ctx, commitExtras[name]),\n ...(toModelOutput && { toModelOutput }),\n }\n })\n\n if (!ctx.context) return entries\n\n return entries.map(entry => ({\n ...entry,\n inputSchema: softenContextSchema(entry.inputSchema, ctx.context!),\n }))\n}\n","import { mergeContextArgs } from '../core/context'\nimport { EvlogError, toModelErrorPayload } from '../core/errors'\nimport { githubTokenCall, resolveGithubToken } from '../core/token'\nimport { ALL_GITHUB_TOOL_NAMES, createToolRegistry, type GithubToolName, type ToolBuildContext } from './registry'\n\nasync function executeGithubToolStep(\n name: GithubToolName,\n input: Record<string, unknown>,\n ctx: ToolBuildContext,\n) {\n 'use step'\n const [entry] = createToolRegistry(ctx, ALL_GITHUB_TOOL_NAMES.filter(tool => tool === name))\n if (!entry) {\n throw new Error(`Unknown GitHub tool: ${name}`)\n }\n return entry.execute(input)\n}\n\nexport async function runGithubToolStep(\n name: GithubToolName,\n input: Record<string, unknown>,\n ctx: ToolBuildContext,\n) {\n try {\n // Resolve the token before entering the step so only a serializable string crosses the boundary.\n const call = githubTokenCall(name, mergeContextArgs(input, ctx.context ?? {}))\n const token = await resolveGithubToken(ctx.token, call)\n return await executeGithubToolStep(name, input, { ...ctx, token })\n } catch (error) {\n // Eve's tool-loop logs thrown execute errors but does not always append a\n // tool_result. Returning a payload keeps the Anthropic tool_use/tool_result pairing intact.\n // Catalog errors keep their { code, why, fix, link } structure so the model can recover.\n if (EvlogError.isEvlogError(error)) {\n return { error: toModelErrorPayload(error) }\n }\n return { error: error instanceof Error ? error.message : String(error) }\n }\n}\n","import type { ToolDefinition } from 'eve/tools'\nimport { resolvePresetTools, type CombinedPresetToolNames, type GithubToolPreset, type PresetToolName } from '../core/presets'\nimport { createGithubTokenResolver } from '../core/token'\nimport { isEveApprovalDisabled, mapEveApprovalValue, resolveEveToolApproval } from './approval'\nimport { getEveTools } from './load-eve'\nimport { ALL_GITHUB_TOOL_NAMES, createToolRegistry, formatGithubEveToolOutput, hasGithubEveToolModelOutput, type GithubToolName, type ToolBuildContext } from './registry'\nimport { runGithubToolStep } from './steps'\nimport type { EveGithubToolsOptions, EveToolFactoryOptions, EveToolOverrides } from './types'\n\ntype BuildOptions = EveGithubToolsOptions | (EveToolFactoryOptions & { preset?: EveGithubToolsOptions['preset'] })\ntype EveToolMap = Partial<Record<GithubToolName, ToolDefinition>>\n\nfunction resolveAllowedToolNames(\n options: Pick<EveGithubToolsOptions, 'preset' | 'include' | 'exclude'>,\n): (name: GithubToolName) => boolean {\n const presetAllowed = options.preset ? resolvePresetTools(options.preset) : null\n const includeAllowed = options.include ? new Set(options.include) : null\n const excluded = options.exclude ? new Set(options.exclude) : null\n\n // `preset` and `include` compose as a union (add tools a preset is missing);\n // `exclude` always subtracts from that combined set afterward.\n const allowed = presetAllowed && includeAllowed\n ? new Set([...presetAllowed, ...includeAllowed])\n : presetAllowed ?? includeAllowed\n\n return name => (!allowed || allowed.has(name)) && !excluded?.has(name)\n}\n\nfunction applyOverrides<T extends ToolDefinition>(\n tool: T,\n name: GithubToolName,\n overrides?: EveToolOverrides,\n): T {\n const override = overrides?.[name]\n if (!override) return tool\n\n const next: T = {\n ...tool,\n ...override.description !== undefined && { description: override.description },\n ...override.toModelOutput !== undefined && { toModelOutput: override.toModelOutput },\n ...override.outputSchema !== undefined && { outputSchema: override.outputSchema },\n }\n\n if (override.approval === undefined) return next\n if (isEveApprovalDisabled(override.approval)) {\n const rest = { ...next }\n delete (rest as { approval?: unknown }).approval\n return rest\n }\n // Preserve policies and `ApprovalConfiguration` objects as-is; only literals need mapping.\n const approval = typeof override.approval === 'function' || typeof override.approval === 'object'\n ? override.approval\n : mapEveApprovalValue(override.approval)\n return { ...next, approval }\n}\n\nexport function buildEveToolDefinition(\n name: GithubToolName,\n options: BuildOptions = {},\n): ToolDefinition {\n const { defineTool } = getEveTools()\n const ctx: ToolBuildContext = {\n token: createGithubTokenResolver(options.token),\n context: options.context,\n author: options.author,\n committer: options.committer,\n coAuthors: options.coAuthors,\n }\n\n const [entry] = createToolRegistry(ctx, ALL_GITHUB_TOOL_NAMES.filter(tool => tool === name))\n if (!entry) {\n throw new Error(`Unknown GitHub tool: ${name}`)\n }\n\n const approval = entry.writeTool\n ? resolveEveToolApproval(entry.writeTool, options.requireApproval)\n : undefined\n\n // Annotated so defineTool resolves to its ToolDefinition overload — inference\n // from the bare literal picks the background-tool overload on eve 0.45+.\n const definition: ToolDefinition = {\n description: entry.description,\n inputSchema: entry.inputSchema,\n ...(approval && { approval }),\n toModelOutput: (output: unknown) => formatGithubEveToolOutput(name, output),\n execute: async (input) => runGithubToolStep(name, input as Record<string, unknown>, ctx),\n }\n\n return applyOverrides(defineTool(definition), name, options.overrides)\n}\n\nexport function buildEveToolMap(options: EveGithubToolsOptions = {}): EveToolMap {\n const { defineTool } = getEveTools()\n const ctx: ToolBuildContext = {\n token: createGithubTokenResolver(options.token),\n context: options.context,\n author: options.author,\n committer: options.committer,\n coAuthors: options.coAuthors,\n }\n\n const isAllowed = resolveAllowedToolNames(options)\n const registry = createToolRegistry(ctx)\n const tools = {} as EveToolMap\n\n for (const entry of registry) {\n if (!isAllowed(entry.name)) continue\n\n const approval = entry.writeTool\n ? resolveEveToolApproval(entry.writeTool, options.requireApproval)\n : undefined\n\n const definition: ToolDefinition = {\n description: entry.description,\n inputSchema: entry.inputSchema,\n ...(approval && { approval }),\n toModelOutput: (output: unknown) => formatGithubEveToolOutput(entry.name, output),\n execute: async (input) => runGithubToolStep(entry.name, input as Record<string, unknown>, ctx),\n }\n\n tools[entry.name] = applyOverrides(defineTool(definition), entry.name, options.overrides)\n }\n\n return tools\n}\n\nexport function createEveGithubToolsDynamic(options: EveGithubToolsOptions = {}) {\n const { defineDynamic } = getEveTools()\n\n // TODO(eve-auth): resolve token from ctx.getToken('github') when eve-managed auth lands.\n // Deferred — eve does not yet expose managed GitHub tokens on the session context.\n return defineDynamic(() => buildEveToolMap(options))\n}\n\nexport function listResolvedEveToolNames(options?: { preset?: undefined, include?: undefined, exclude?: undefined }): GithubToolName[]\nexport function listResolvedEveToolNames<P extends GithubToolPreset>(options: { preset: P, include?: undefined, exclude?: undefined }): PresetToolName<P>[]\nexport function listResolvedEveToolNames<P extends readonly GithubToolPreset[]>(options: { preset: P, include?: undefined, exclude?: undefined }): CombinedPresetToolNames<P>[]\nexport function listResolvedEveToolNames(options: Pick<EveGithubToolsOptions, 'preset' | 'include' | 'exclude'>): GithubToolName[]\nexport function listResolvedEveToolNames(options: Pick<EveGithubToolsOptions, 'preset' | 'include' | 'exclude'> = {}): GithubToolName[] {\n const isAllowed = resolveAllowedToolNames(options)\n return ALL_GITHUB_TOOL_NAMES.filter(isAllowed)\n}\n\n/**\n * Tool descriptors (no `execute`) for authored eve `defineTool` loops.\n * Prefer this when registering tools outside the SDK package so durable transforms can hoist inline execute.\n */\nexport function listEveToolDescriptors(options: EveGithubToolsOptions = {}) {\n const ctx: ToolBuildContext = {\n token: createGithubTokenResolver(options.token),\n context: options.context,\n author: options.author,\n committer: options.committer,\n coAuthors: options.coAuthors,\n }\n\n const names = listResolvedEveToolNames(options)\n return createToolRegistry(ctx, names)\n .map(entry => ({\n name: entry.name,\n description: entry.description,\n inputSchema: entry.inputSchema,\n writeTool: entry.writeTool,\n toModelOutput: entry.toModelOutput,\n }))\n}\n\nexport { formatGithubEveToolOutput, hasGithubEveToolModelOutput }\n\n/**\n * Execute a GitHub tool by name with the given eve options (token/context/attribution).\n * Used by `@github-tools/eve-extension` so `execute` only closes over a serializable tool name.\n */\nexport async function executeGithubEveTool(\n name: GithubToolName,\n input: Record<string, unknown>,\n options: EveGithubToolsOptions = {},\n) {\n const ctx: ToolBuildContext = {\n token: createGithubTokenResolver(options.token),\n context: options.context,\n author: options.author,\n committer: options.committer,\n coAuthors: options.coAuthors,\n }\n return runGithubToolStep(name, input, ctx)\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,sBACX;AAEF,SAAgB,cAA8B;CAC5C,OAAO;AACT;AAEA,SAAgB,wBAA2C;CACzD,OAAO;AACT;;;;;;;;AChBA,SAAgB,sBAAsB,OAA8C;CAClF,OAAO,UAAU,SAAS,UAAU;AACtC;AAEA,SAAgB,oBAAoB,OAAyC;CAC3E,IAAI,OAAO,UAAU,YAAY,OAAO;CAExC,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM;CAE5C,MAAM,EAAE,QAAQ,OAAO,SAAS,sBAAsB;CAEtD,IAAI,UAAU,QAAQ,UAAU,UAAU,OAAO,OAAO;CACxD,IAAI,UAAU,SAAS,UAAU,SAAS,OAAO,MAAM;CACvD,OAAO,KAAK;AACd;AAEA,SAAgB,mBACd,UACA,QACgB;CAChB,IAAI,WAAW,KAAA,GAAW,OAAO,sBAAsB,CAAC,CAAC,OAAO;CAChE,IAAI,WAAW,MAAM,OAAO,sBAAsB,CA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CAAG;AAC3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { B as GithubToolName, F as GithubToolPreset, L as PresetToolName, P as CombinedPresetToolNames, V as GithubWriteToolName } from "./tool-types-OFyE3z0C.mjs";
|
|
2
|
+
import { i as EveToolFactoryOptions, n as EveApprovalValue, r as EveGithubToolsOptions, t as EveApprovalConfig } from "./types-ITYfXMtY.mjs";
|
|
3
|
+
import "./index-C3wlz660.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { ToolDefinition, ToolModelOutput } from "eve/tools";
|
|
6
6
|
import { Approval, ApprovalPolicy } from "eve/tools/approval";
|
|
@@ -22,7 +22,7 @@ type BuildOptions = EveGithubToolsOptions | (EveToolFactoryOptions & {
|
|
|
22
22
|
type EveToolMap = Partial<Record<GithubToolName, ToolDefinition>>;
|
|
23
23
|
declare function buildEveToolDefinition(name: GithubToolName, options?: BuildOptions): ToolDefinition;
|
|
24
24
|
declare function buildEveToolMap(options?: EveGithubToolsOptions): EveToolMap;
|
|
25
|
-
declare function createEveGithubToolsDynamic(options?: EveGithubToolsOptions): import("eve").DynamicSentinel<
|
|
25
|
+
declare function createEveGithubToolsDynamic(options?: EveGithubToolsOptions): import("eve/tools").DynamicSentinel<import("eve/tools").DynamicToolResult, import("eve/tools").DynamicContext>;
|
|
26
26
|
declare function listResolvedEveToolNames(options?: {
|
|
27
27
|
preset?: undefined;
|
|
28
28
|
include?: undefined;
|
|
@@ -44,7 +44,7 @@ declare function listResolvedEveToolNames(options: Pick<EveGithubToolsOptions, '
|
|
|
44
44
|
* Prefer this when registering tools outside the SDK package so durable transforms can hoist inline execute.
|
|
45
45
|
*/
|
|
46
46
|
declare function listEveToolDescriptors(options?: EveGithubToolsOptions): {
|
|
47
|
-
name: "
|
|
47
|
+
name: "getRepository" | "listBranches" | "getFileContent" | "getRepositoryTree" | "createBranch" | "deleteBranch" | "forkRepository" | "createRepository" | "createOrUpdateFile" | "getBranchRules" | "editFiles" | "listPullRequests" | "getPullRequest" | "createPullRequest" | "mergePullRequest" | "enablePullRequestAutoMerge" | "disablePullRequestAutoMerge" | "updatePullRequest" | "addPullRequestComment" | "updatePullRequestComment" | "deletePullRequestComment" | "listPullRequestFiles" | "listPullRequestReviews" | "createPullRequestReview" | "listPullRequestReviewThreads" | "replyToReviewComment" | "resolveReviewThread" | "requestReviewers" | "getPullRequestContext" | "getIssueContext" | "listIssues" | "getIssue" | "listIssueComments" | "createIssue" | "addIssueComment" | "updateIssueComment" | "deleteIssueComment" | "closeIssue" | "updateIssue" | "listLabels" | "addLabels" | "removeLabel" | "createLabel" | "updateLabel" | "deleteLabel" | "addAssignees" | "removeAssignees" | "listIssueReactions" | "addIssueReaction" | "listCommentReactions" | "addCommentReaction" | "listDiscussions" | "getDiscussion" | "addDiscussionComment" | "listNotifications" | "markNotificationRead" | "searchCode" | "searchRepositories" | "searchIssues" | "listCommits" | "getCommit" | "getBlame" | "compareCommits" | "listGists" | "getGist" | "listGistComments" | "createGist" | "updateGist" | "deleteGist" | "createGistComment" | "listWorkflows" | "listWorkflowRuns" | "getWorkflowRun" | "listWorkflowJobs" | "getWorkflowJobLogs" | "triggerWorkflow" | "cancelWorkflowRun" | "rerunWorkflowRun" | "listCheckRuns" | "getCombinedStatus" | "getCiFailureContext" | "listReleases" | "getLatestRelease" | "getRelease" | "getReleaseContext" | "createRelease" | "updateRelease" | "deleteRelease" | "listCodeScanningAlerts" | "listDependabotAlerts" | "listSecretScanningAlerts";
|
|
48
48
|
description: string;
|
|
49
49
|
inputSchema: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
|
|
50
50
|
writeTool: GithubWriteToolName | undefined;
|
|
@@ -82,4 +82,4 @@ declare function resolveEveToolApproval(toolName: GithubWriteToolName, config: E
|
|
|
82
82
|
declare const MISSING_EVE_MESSAGE = "The \"eve\" package is required to use @github-tools/sdk/eve. Install it with: pnpm add eve";
|
|
83
83
|
//#endregion
|
|
84
84
|
export { resolveEveToolApproval as a, createEveGithubToolsDynamic as c, listResolvedEveToolNames as d, formatGithubEveToolOutput as f, resolveEveApproval as i, executeGithubEveTool as l, isEveApprovalDisabled as n, buildEveToolDefinition as o, hasGithubEveToolModelOutput as p, mapEveApprovalValue as r, buildEveToolMap as s, MISSING_EVE_MESSAGE as t, listEveToolDescriptors as u };
|
|
85
|
-
//# sourceMappingURL=eve-runtime-
|
|
85
|
+
//# sourceMappingURL=eve-runtime-CflZNuXD.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eve-runtime-CflZNuXD.d.mts","names":[],"sources":["../src/eve/registry.ts","../src/eve/build.ts","../src/eve/approval.ts","../src/eve/load-eve.ts"],"mappings":";;;;;;;;iBAqEgB,4BAA4B,MAAM;;;;;;;iBAUlC,0BAA0B,MAAM,gBAAgB,kBAAkB;;;KCtE7E,eAAe,yBAAyB;EAA0B,SAAS;;KAC3E,aAAa,QAAQ,OAAO,gBAAgB;iBA8CjC,uBACd,MAAM,gBACN,UAAS,eACR;iBAgCa,gBAAgB,UAAS,wBAA6B;iBAmCtD,4BAA4B,UAAS,4CAA0B,oCAAA,uCAAA;iBAQ/D,yBAAyB;EAAY;EAAoB;EAAqB;IAAwB;iBACtG,yBAAyB,UAAU,kBAAkB;EAAW,QAAQ;EAAG;EAAqB;IAAwB,eAAe;iBACvI,yBAAyB,mBAAmB,oBAAoB;EAAW,QAAQ;EAAG;EAAqB;IAAwB,wBAAwB;iBAC3J,yBAAyB,SAAS,KAAK,2DAA2D;;;;;iBAUlG,uBAAuB,UAAS;;;;aAAA;;;;;;;iBA0B1B,qBACpB,MAAM,gBACN,OAAO,yBACP,UAAS,wBAA0B;;;;;;;;iBCtKrB,sBAAsB,OAAO;iBAI7B,oBAAoB,OAAO,mBAAmB;iBAY9C,mBACd,UAAU,qBACV,QAAQ,gCACP;;;;;;iBAgBa,uBACd,UAAU,qBACV,QAAQ,+BACR,WAAW,mBACV;;;;;;;;;cChCU"}
|
package/dist/eve-runtime.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as resolveEveToolApproval, c as createEveGithubToolsDynamic, d as listResolvedEveToolNames, f as formatGithubEveToolOutput, i as resolveEveApproval, l as executeGithubEveTool, n as isEveApprovalDisabled, o as buildEveToolDefinition, p as hasGithubEveToolModelOutput, r as mapEveApprovalValue, s as buildEveToolMap, t as MISSING_EVE_MESSAGE, u as listEveToolDescriptors } from "./eve-runtime-
|
|
5
|
-
export { AUTO_APPROVAL_TOOLS, type AllGithubTools, type CombinedPresetToolNames, type CommitIdentity, type EveApprovalConfig, type EveApprovalValue, type EveGithubToolsOptions, type EveToolFactoryOptions, type EveToolOverrides, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, type GithubEvaluationOptions, type GithubRateLimit, type GithubTokenCall, type GithubToolName, type GithubToolPreset, type GithubToolsForPreset, type GithubWriteToolName, MISSING_EVE_MESSAGE, PRESET_TOOLS, type PickGithubTools, type PresetToolName, buildEveToolDefinition, buildEveToolMap, createEveGithubToolsDynamic, executeGithubEveTool, formatGithubEveToolOutput, githubToolsErrors, hasGithubEveToolModelOutput, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, listResolvedEveToolNames, mapEveApprovalValue, needsAutoApproval, resolveEveApproval, resolveEveToolApproval, resolveGithubToken, selectPresets };
|
|
1
|
+
import { A as GithubTokenCall, B as GithubToolName, C as needsAutoApproval, D as AUTO_APPROVAL_TOOLS, E as GITHUB_WRITE_TOOLS, F as GithubToolPreset, I as PRESET_TOOLS, L as PresetToolName, M as resolveGithubToken, P as CombinedPresetToolNames, R as GITHUB_TOOL_NAMES, S as latestUserText, T as selectTools, V as GithubWriteToolName, _ as autoApprovalDecision, b as fallbackPresets, g as GithubEvaluationOptions, h as AutoApprovalDecision, i as PickGithubTools, o as CommitIdentity, r as GithubToolsForPreset, t as AllGithubTools, v as evaluatePresets, w as selectPresets, x as fallbackTools, y as evaluateTools } from "./tool-types-OFyE3z0C.mjs";
|
|
2
|
+
import { a as EveToolOverrides, i as EveToolFactoryOptions, n as EveApprovalValue, r as EveGithubToolsOptions, t as EveApprovalConfig } from "./types-ITYfXMtY.mjs";
|
|
3
|
+
import { a as GithubRateLimit, i as githubToolsErrors, qt as resolveToolGuidance } from "./index-C3wlz660.mjs";
|
|
4
|
+
import { a as resolveEveToolApproval, c as createEveGithubToolsDynamic, d as listResolvedEveToolNames, f as formatGithubEveToolOutput, i as resolveEveApproval, l as executeGithubEveTool, n as isEveApprovalDisabled, o as buildEveToolDefinition, p as hasGithubEveToolModelOutput, r as mapEveApprovalValue, s as buildEveToolMap, t as MISSING_EVE_MESSAGE, u as listEveToolDescriptors } from "./eve-runtime-CflZNuXD.mjs";
|
|
5
|
+
export { AUTO_APPROVAL_TOOLS, type AllGithubTools, type AutoApprovalDecision, type CombinedPresetToolNames, type CommitIdentity, type EveApprovalConfig, type EveApprovalValue, type EveGithubToolsOptions, type EveToolFactoryOptions, type EveToolOverrides, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, type GithubEvaluationOptions, type GithubRateLimit, type GithubTokenCall, type GithubToolName, type GithubToolPreset, type GithubToolsForPreset, type GithubWriteToolName, MISSING_EVE_MESSAGE, PRESET_TOOLS, type PickGithubTools, type PresetToolName, autoApprovalDecision, buildEveToolDefinition, buildEveToolMap, createEveGithubToolsDynamic, evaluatePresets, evaluateTools, executeGithubEveTool, fallbackPresets, fallbackTools, formatGithubEveToolOutput, githubToolsErrors, hasGithubEveToolModelOutput, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, listResolvedEveToolNames, mapEveApprovalValue, needsAutoApproval, resolveEveApproval, resolveEveToolApproval, resolveGithubToken, resolveToolGuidance, selectPresets, selectTools };
|
package/dist/eve-runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as listEveToolDescriptors, c as hasGithubEveToolModelOutput, d as resolveEveApproval, f as resolveEveToolApproval, i as executeGithubEveTool, l as isEveApprovalDisabled, n as buildEveToolMap, o as listResolvedEveToolNames, p as MISSING_EVE_MESSAGE, r as createEveGithubToolsDynamic, s as formatGithubEveToolOutput, t as buildEveToolDefinition, u as mapEveApprovalValue } from "./eve-runtime-
|
|
4
|
-
export { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, MISSING_EVE_MESSAGE, PRESET_TOOLS, buildEveToolDefinition, buildEveToolMap, createEveGithubToolsDynamic, executeGithubEveTool, formatGithubEveToolOutput, githubToolsErrors, hasGithubEveToolModelOutput, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, listResolvedEveToolNames, mapEveApprovalValue, needsAutoApproval, resolveEveApproval, resolveEveToolApproval, resolveGithubToken, selectPresets };
|
|
1
|
+
import { Aa as githubToolsErrors, _ as PRESET_TOOLS, h as GITHUB_TOOL_NAMES, r as resolveToolGuidance, s as AUTO_APPROVAL_TOOLS, t as GITHUB_WRITE_TOOLS, x as resolveGithubToken } from "./write-tools-DnGZw-RD.mjs";
|
|
2
|
+
import { c as latestUserText, d as selectTools, i as evaluateTools, l as needsAutoApproval, n as autoApprovalDecision, o as fallbackPresets, r as evaluatePresets, s as fallbackTools, u as selectPresets } from "./evaluation-BtoHbxuQ.mjs";
|
|
3
|
+
import { a as listEveToolDescriptors, c as hasGithubEveToolModelOutput, d as resolveEveApproval, f as resolveEveToolApproval, i as executeGithubEveTool, l as isEveApprovalDisabled, n as buildEveToolMap, o as listResolvedEveToolNames, p as MISSING_EVE_MESSAGE, r as createEveGithubToolsDynamic, s as formatGithubEveToolOutput, t as buildEveToolDefinition, u as mapEveApprovalValue } from "./eve-runtime-C-0doyHq.mjs";
|
|
4
|
+
export { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, MISSING_EVE_MESSAGE, PRESET_TOOLS, autoApprovalDecision, buildEveToolDefinition, buildEveToolMap, createEveGithubToolsDynamic, evaluatePresets, evaluateTools, executeGithubEveTool, fallbackPresets, fallbackTools, formatGithubEveToolOutput, githubToolsErrors, hasGithubEveToolModelOutput, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, listResolvedEveToolNames, mapEveApprovalValue, needsAutoApproval, resolveEveApproval, resolveEveToolApproval, resolveGithubToken, resolveToolGuidance, selectPresets, selectTools };
|