@github-tools/sdk 1.17.0 → 1.19.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 +33 -6
- 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 +3 -3
- package/dist/connect.mjs +2 -2
- package/dist/cores-BeLZwcde.mjs +269 -0
- package/dist/cores-BeLZwcde.mjs.map +1 -0
- package/dist/evaluation-f-2QwBid.mjs +210 -0
- package/dist/evaluation-f-2QwBid.mjs.map +1 -0
- package/dist/{eve-runtime-DwPFaBlj.d.mts → eve-runtime-DRh2QJI7.d.mts} +5 -5
- package/dist/eve-runtime-DRh2QJI7.d.mts.map +1 -0
- package/dist/{eve-runtime-NBFRz1SB.mjs → eve-runtime-YTxfrWP-.mjs} +6 -4
- package/dist/eve-runtime-YTxfrWP-.mjs.map +1 -0
- package/dist/eve-runtime.d.mts +4 -4
- package/dist/eve-runtime.mjs +3 -2
- package/dist/eve.d.mts +4 -4
- package/dist/eve.d.mts.map +1 -1
- package/dist/eve.mjs +2 -2
- package/dist/{index-DglfkoWk.d.mts → index-DkZvveZP.d.mts} +304 -3
- package/dist/index-DkZvveZP.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/instructions-BuypoY0x.mjs +148 -0
- package/dist/instructions-BuypoY0x.mjs.map +1 -0
- package/dist/interrupts-C_lUXMdd.d.mts +60 -0
- package/dist/interrupts-C_lUXMdd.d.mts.map +1 -0
- package/dist/{src-SH7fl4eI.mjs → src-Bx5p1Unc.mjs} +5 -143
- package/dist/{src-SH7fl4eI.mjs.map → src-Bx5p1Unc.mjs.map} +1 -1
- package/dist/tanstack/interrupts.d.mts +2 -0
- package/dist/tanstack/interrupts.mjs +17 -0
- package/dist/tanstack/interrupts.mjs.map +1 -0
- package/dist/tanstack.d.mts +4971 -0
- package/dist/tanstack.d.mts.map +1 -0
- package/dist/tanstack.mjs +465 -0
- package/dist/tanstack.mjs.map +1 -0
- package/dist/{token-C4lAap1Y.mjs → token-Bh8nPj66.mjs} +4 -3
- package/dist/{token-C4lAap1Y.mjs.map → token-Bh8nPj66.mjs.map} +1 -1
- package/dist/tool-types-CrC80SIL.d.mts +1573 -0
- package/dist/tool-types-CrC80SIL.d.mts.map +1 -0
- package/dist/{types-6nsCJ0Pu.d.mts → types-BmwOpI5-.d.mts} +3 -3
- package/dist/{types-6nsCJ0Pu.d.mts.map → types-BmwOpI5-.d.mts.map} +1 -1
- package/dist/{types-vuvgvlL-.d.mts → types-CPAsEMzx.d.mts} +2 -2
- package/dist/{types-vuvgvlL-.d.mts.map → types-CPAsEMzx.d.mts.map} +1 -1
- package/dist/workflow.d.mts +2 -2
- package/dist/workflow.mjs +3 -2
- package/dist/workflow.mjs.map +1 -1
- package/dist/{write-tools-BidBkLtv.mjs → write-tools-BaoTUCg7.mjs} +27 -464
- package/dist/write-tools-BaoTUCg7.mjs.map +1 -0
- package/package.json +34 -18
- package/dist/eve-runtime-DwPFaBlj.d.mts.map +0 -1
- package/dist/eve-runtime-NBFRz1SB.mjs.map +0 -1
- package/dist/index-DglfkoWk.d.mts.map +0 -1
- package/dist/tool-types-DcfQIOAY.d.mts +0 -4261
- package/dist/tool-types-DcfQIOAY.d.mts.map +0 -1
- package/dist/write-tools-BidBkLtv.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://github.com/vercel-labs/github-tools/blob/main/LICENSE)
|
|
9
9
|
|
|
10
|
-
**Give any agent GitHub access.** A typed tool layer for GitHub AI agents, with presets, human approval, and durable execution. Works with [eve](https://eve.dev), the [AI SDK](https://ai-sdk.dev), Vercel Workflow, and [Chat SDK](https://chat-sdk.dev).
|
|
10
|
+
**Give any agent GitHub access.** A typed tool layer for GitHub AI agents, with presets, human approval, and durable execution. Works with [eve](https://eve.dev), the [AI SDK](https://ai-sdk.dev), [TanStack AI](https://tanstack.com/ai), Vercel Workflow, and [Chat SDK](https://chat-sdk.dev).
|
|
11
11
|
|
|
12
12
|
Docs: **[github-tools.com](https://github-tools.com)**
|
|
13
13
|
|
|
@@ -17,10 +17,10 @@ They all reach the GitHub API, but none of them were built as an agent's tool la
|
|
|
17
17
|
|
|
18
18
|
| | `@github-tools/sdk` | GitHub MCP server | `gh` CLI | Raw Octokit |
|
|
19
19
|
|---|---|---|---|---|
|
|
20
|
-
| Integration | Native AI SDK
|
|
20
|
+
| Integration | Native AI SDK and TanStack AI tools | MCP wire protocol via a separate process | Shell-out from the agent | Hand-written per call |
|
|
21
21
|
| Human approval | Built in, on by default | Host-dependent, inconsistent | None | You build it |
|
|
22
|
-
| Durable / retryable |
|
|
23
|
-
| Scoped by task | Presets (
|
|
22
|
+
| Durable / retryable | Workflow entry point uses `"use step"` | No | No | No |
|
|
23
|
+
| Scoped by task | Presets (10 built-in) | Full server surface, or manual filtering | Full CLI surface | You build it |
|
|
24
24
|
| Token-efficient output | Shaped and truncated by design | Raw API responses | Raw text, needs parsing | Raw API responses |
|
|
25
25
|
| Native eve / Workflow / Chat SDK | Yes | No | No | No |
|
|
26
26
|
|
|
@@ -30,6 +30,7 @@ They all reach the GitHub API, but none of them were built as an agent's tool la
|
|
|
30
30
|
|---|---|
|
|
31
31
|
| A standalone GitHub agent, fast: 3 files, durable approval | [eve extension](#eve-extension-recommended) |
|
|
32
32
|
| Scripts, chat backends, or an existing AI SDK app | Quick Start below |
|
|
33
|
+
| A TanStack AI app | [TanStack AI](#tanstack-ai) |
|
|
33
34
|
| Production agents that must survive restarts and timeouts | [Durable Agents](#durable-agents-vercel-workflow-sdk) |
|
|
34
35
|
| A GitHub, Slack, or Discord bot | [Chat SDK docs](https://github-tools.com/frameworks/chat-sdk) |
|
|
35
36
|
|
|
@@ -354,6 +355,32 @@ connectGithubTools(
|
|
|
354
355
|
)
|
|
355
356
|
```
|
|
356
357
|
|
|
358
|
+
## TanStack AI
|
|
359
|
+
|
|
360
|
+
Import native tool arrays and the prebuilt agent from `@github-tools/sdk/tanstack`:
|
|
361
|
+
|
|
362
|
+
```sh
|
|
363
|
+
pnpm add @github-tools/sdk @tanstack/ai@0.64 @tanstack/ai-vercel-gateway@0.3 ai zod
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
import { createGithubAgent } from '@github-tools/sdk/tanstack'
|
|
368
|
+
import { vercelGatewayText } from '@tanstack/ai-vercel-gateway'
|
|
369
|
+
|
|
370
|
+
const agent = createGithubAgent({
|
|
371
|
+
adapter: vercelGatewayText('anthropic/claude-opus-5'),
|
|
372
|
+
context: { owner: 'vercel', repo: 'ai' },
|
|
373
|
+
preset: 'auto',
|
|
374
|
+
requireApproval: 'auto',
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
const text = await agent.generate({ prompt: 'Summarize the open pull requests.' })
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Set `GITHUB_TOKEN` and Gateway authentication on the server. `generate()` returns a string and throws on approval interrupts; `stream()` returns TanStack's native event stream. Auto modes use TanStack `decide()` with Gateway Jev and the same approval and routing thresholds as the AI SDK integration. Supply `evaluation.adapter` to use another evaluator. Auto-preset continuations skip routing and expose `repo-explorer` plus pending GitHub tools.
|
|
381
|
+
|
|
382
|
+
`createGithubTools()` returns an array for TanStack `chat({ tools })`. Direct tools with auto approval also need `createGithubApprovalMiddleware({ tools })` and the shared `githubToolApproval` interrupt from `@github-tools/sdk/tanstack/interrupts`. Register that definition on the client to handle human review. See the [TanStack AI guide](https://github-tools.com/frameworks/tanstack-ai) for tools, streaming, and approval continuation.
|
|
383
|
+
|
|
357
384
|
## eve
|
|
358
385
|
|
|
359
386
|
[eve](https://eve.dev) is Vercel's filesystem-first agent framework. `@github-tools/eve-extension` is the **recommended** way to add GitHub tools to an eve agent: a mountable [eve extension](https://eve.dev/docs/extensions), no CLI setup, no direct SDK import in `agent/tools/`. The legacy `createGithubTools` / per-tool factories on `@github-tools/sdk/eve` are **deprecated** for that registration pattern; they keep working and are documented below for existing agents. Shared runtime helpers for the extension live on `@github-tools/sdk/eve-runtime` (not deprecated).
|
|
@@ -752,10 +779,10 @@ Returns a `DurableGithubAgent` instance for use inside Vercel Workflow SDK funct
|
|
|
752
779
|
|
|
753
780
|
Supports both `.stream()` (real-time output to a writable) and `.generate()` (non-streaming, returns the full text response).
|
|
754
781
|
|
|
755
|
-
Requires the optional peer dependencies `workflow` and `@workflow
|
|
782
|
+
Requires the optional peer dependencies `workflow` and `@ai-sdk/workflow`:
|
|
756
783
|
|
|
757
784
|
```sh
|
|
758
|
-
pnpm add workflow @workflow
|
|
785
|
+
pnpm add workflow @ai-sdk/workflow
|
|
759
786
|
```
|
|
760
787
|
|
|
761
788
|
#### Streaming (chat UI)
|
package/dist/connect/eve.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as GithubConnectorInput, t as ConnectGithubEveToolsOptions } from "../types-
|
|
1
|
+
import { s as GithubConnectorInput, t as ConnectGithubEveToolsOptions } from "../types-BmwOpI5-.mjs";
|
|
2
2
|
//#region src/connect/eve.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Register eve GitHub tools backed by a Vercel Connect connector.
|
|
@@ -23,6 +23,6 @@ import { s as GithubConnectorInput, t as ConnectGithubEveToolsOptions } from "..
|
|
|
23
23
|
* `build.externalDependencies: ['@vercel/connect']` in `agent.ts`. Prefer the
|
|
24
24
|
* eve extension (pre-built) so that workaround is unnecessary.
|
|
25
25
|
*/
|
|
26
|
-
export declare function connectGithubTools(connector: GithubConnectorInput, options?: ConnectGithubEveToolsOptions): import("eve").DynamicSentinel<
|
|
26
|
+
export declare function connectGithubTools(connector: GithubConnectorInput, options?: ConnectGithubEveToolsOptions): import("eve").DynamicSentinel<import("eve/tools").DynamicToolResult, import("eve").DynamicContext>;
|
|
27
27
|
//#endregion
|
|
28
28
|
//# sourceMappingURL=eve.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eve.d.mts","names":[],"sources":["../../src/connect/eve.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;wBA4BgB,mBACd,WAAW,sBACX,UAAS,6CAAiC,
|
|
1
|
+
{"version":3,"file":"eve.d.mts","names":[],"sources":["../../src/connect/eve.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;wBA4BgB,mBACd,WAAW,sBACX,UAAS,6CAAiC,oCAAA,iCAAA"}
|
package/dist/connect/eve.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createGithubTools } from "../eve.mjs";
|
|
2
|
-
import { t as connectGithubToken } from "../token-
|
|
2
|
+
import { t as connectGithubToken } from "../token-Bh8nPj66.mjs";
|
|
3
3
|
//#region src/connect/eve.ts
|
|
4
4
|
/**
|
|
5
5
|
* Register eve GitHub tools backed by a Vercel Connect connector.
|
package/dist/connect.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { a as GithubConnectParamsInput, c as resolveGithubConnector, i as GithubConnectParams, n as ConnectGithubTokenOptions, o as GithubConnectParamsResolver, r as ConnectGithubToolsOptions, s as GithubConnectorInput, t as ConnectGithubEveToolsOptions } from "./types-
|
|
3
|
-
import "./
|
|
1
|
+
import "./index-DkZvveZP.mjs";
|
|
2
|
+
import { a as GithubConnectParamsInput, c as resolveGithubConnector, i as GithubConnectParams, n as ConnectGithubTokenOptions, o as GithubConnectParamsResolver, r as ConnectGithubToolsOptions, s as GithubConnectorInput, t as ConnectGithubEveToolsOptions } from "./types-BmwOpI5-.mjs";
|
|
3
|
+
import { C as GithubTokenInput, E as GithubToolPreset, S as GithubTokenCall, j as GithubToolName, t as AllGithubTools } from "./tool-types-CrC80SIL.mjs";
|
|
4
4
|
import { ConnectTokenSubject } from "@vercel/connect";
|
|
5
5
|
//#region src/connect/scopes.d.ts
|
|
6
6
|
/**
|
package/dist/connect.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createGithubTools } from "./src-
|
|
2
|
-
import { a as connectGithubScopesForSelection, i as connectGithubScopesForPreset, n as PRESET_CONNECT_SCOPES, o as connectGithubScopesForTools, r as TOOL_CONNECT_SCOPES, s as resolveGithubConnector, t as connectGithubToken } from "./token-
|
|
1
|
+
import { t as createGithubTools } from "./src-Bx5p1Unc.mjs";
|
|
2
|
+
import { a as connectGithubScopesForSelection, i as connectGithubScopesForPreset, n as PRESET_CONNECT_SCOPES, o as connectGithubScopesForTools, r as TOOL_CONNECT_SCOPES, s as resolveGithubConnector, t as connectGithubToken } from "./token-Bh8nPj66.mjs";
|
|
3
3
|
//#region src/connect/tools.ts
|
|
4
4
|
/**
|
|
5
5
|
* Create GitHub tools backed by a Vercel Connect connector.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { B as listIssueReactionsCore, Bi as deleteBranchCore, Bn as listPullRequestFilesCore, Br as getIssueCore, Bt as getWorkflowJobLogsCore, 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, 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, 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, Y as createGistCommentCore, Yi as getRepositoryCore, Yn as listPullRequestsCore, Yr as listLabelsCore, Yt as listWorkflowRunsCore, gi as getBlameCore, gn as getReleaseCore, gr as addAssigneesCore, gt as addDiscussionCommentCore, 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, pi as compareCommitsCore, pn as getLatestReleaseCore, pr as updatePullRequestCore, pt as updateGistCore, 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, yi as getCommitCore, yn as listReleasesCore, yr as addIssueCommentCore, yt as getDiscussionCore } from "./write-tools-BaoTUCg7.mjs";
|
|
2
|
+
//#region src/core/cores.ts
|
|
3
|
+
/**
|
|
4
|
+
* The `*Core` implementation of every tool, keyed by tool name.
|
|
5
|
+
*
|
|
6
|
+
* Kept apart from `GITHUB_TOOL_CATALOG` so that importing tool metadata does
|
|
7
|
+
* not pull Octokit into a Vercel Workflow flow bundle, which cannot load
|
|
8
|
+
* Node.js built-ins. Argument types vary per tool, so callers cast at the
|
|
9
|
+
* dispatch boundary. Entries are getters so the ESM binding stays live
|
|
10
|
+
* (module spies in tests).
|
|
11
|
+
*/
|
|
12
|
+
const GITHUB_TOOL_CORES = {
|
|
13
|
+
get getRepository() {
|
|
14
|
+
return getRepositoryCore;
|
|
15
|
+
},
|
|
16
|
+
get listBranches() {
|
|
17
|
+
return listBranchesCore;
|
|
18
|
+
},
|
|
19
|
+
get getFileContent() {
|
|
20
|
+
return getFileContentCore;
|
|
21
|
+
},
|
|
22
|
+
get getRepositoryTree() {
|
|
23
|
+
return getRepositoryTreeCore;
|
|
24
|
+
},
|
|
25
|
+
get createBranch() {
|
|
26
|
+
return createBranchCore;
|
|
27
|
+
},
|
|
28
|
+
get deleteBranch() {
|
|
29
|
+
return deleteBranchCore;
|
|
30
|
+
},
|
|
31
|
+
get forkRepository() {
|
|
32
|
+
return forkRepositoryCore;
|
|
33
|
+
},
|
|
34
|
+
get createRepository() {
|
|
35
|
+
return createRepositoryCore;
|
|
36
|
+
},
|
|
37
|
+
get createOrUpdateFile() {
|
|
38
|
+
return createOrUpdateFileCore;
|
|
39
|
+
},
|
|
40
|
+
get listPullRequests() {
|
|
41
|
+
return listPullRequestsCore;
|
|
42
|
+
},
|
|
43
|
+
get getPullRequest() {
|
|
44
|
+
return getPullRequestCore;
|
|
45
|
+
},
|
|
46
|
+
get createPullRequest() {
|
|
47
|
+
return createPullRequestCore;
|
|
48
|
+
},
|
|
49
|
+
get mergePullRequest() {
|
|
50
|
+
return mergePullRequestCore;
|
|
51
|
+
},
|
|
52
|
+
get updatePullRequest() {
|
|
53
|
+
return updatePullRequestCore;
|
|
54
|
+
},
|
|
55
|
+
get addPullRequestComment() {
|
|
56
|
+
return addPullRequestCommentCore;
|
|
57
|
+
},
|
|
58
|
+
get updatePullRequestComment() {
|
|
59
|
+
return updatePullRequestCommentCore;
|
|
60
|
+
},
|
|
61
|
+
get deletePullRequestComment() {
|
|
62
|
+
return deletePullRequestCommentCore;
|
|
63
|
+
},
|
|
64
|
+
get listPullRequestFiles() {
|
|
65
|
+
return listPullRequestFilesCore;
|
|
66
|
+
},
|
|
67
|
+
get listPullRequestReviews() {
|
|
68
|
+
return listPullRequestReviewsCore;
|
|
69
|
+
},
|
|
70
|
+
get createPullRequestReview() {
|
|
71
|
+
return createPullRequestReviewCore;
|
|
72
|
+
},
|
|
73
|
+
get listPullRequestReviewThreads() {
|
|
74
|
+
return listPullRequestReviewThreadsCore;
|
|
75
|
+
},
|
|
76
|
+
get replyToReviewComment() {
|
|
77
|
+
return replyToReviewCommentCore;
|
|
78
|
+
},
|
|
79
|
+
get resolveReviewThread() {
|
|
80
|
+
return resolveReviewThreadCore;
|
|
81
|
+
},
|
|
82
|
+
get requestReviewers() {
|
|
83
|
+
return requestReviewersCore;
|
|
84
|
+
},
|
|
85
|
+
get getPullRequestContext() {
|
|
86
|
+
return getPullRequestContextCore;
|
|
87
|
+
},
|
|
88
|
+
get getIssueContext() {
|
|
89
|
+
return getIssueContextCore;
|
|
90
|
+
},
|
|
91
|
+
get listIssues() {
|
|
92
|
+
return listIssuesCore;
|
|
93
|
+
},
|
|
94
|
+
get getIssue() {
|
|
95
|
+
return getIssueCore;
|
|
96
|
+
},
|
|
97
|
+
get listIssueComments() {
|
|
98
|
+
return listIssueCommentsCore;
|
|
99
|
+
},
|
|
100
|
+
get createIssue() {
|
|
101
|
+
return createIssueCore;
|
|
102
|
+
},
|
|
103
|
+
get addIssueComment() {
|
|
104
|
+
return addIssueCommentCore;
|
|
105
|
+
},
|
|
106
|
+
get updateIssueComment() {
|
|
107
|
+
return updateIssueCommentCore;
|
|
108
|
+
},
|
|
109
|
+
get deleteIssueComment() {
|
|
110
|
+
return deleteIssueCommentCore;
|
|
111
|
+
},
|
|
112
|
+
get closeIssue() {
|
|
113
|
+
return closeIssueCore;
|
|
114
|
+
},
|
|
115
|
+
get updateIssue() {
|
|
116
|
+
return updateIssueCore;
|
|
117
|
+
},
|
|
118
|
+
get listLabels() {
|
|
119
|
+
return listLabelsCore;
|
|
120
|
+
},
|
|
121
|
+
get addLabels() {
|
|
122
|
+
return addLabelsCore;
|
|
123
|
+
},
|
|
124
|
+
get removeLabel() {
|
|
125
|
+
return removeLabelCore;
|
|
126
|
+
},
|
|
127
|
+
get createLabel() {
|
|
128
|
+
return createLabelCore;
|
|
129
|
+
},
|
|
130
|
+
get updateLabel() {
|
|
131
|
+
return updateLabelCore;
|
|
132
|
+
},
|
|
133
|
+
get deleteLabel() {
|
|
134
|
+
return deleteLabelCore;
|
|
135
|
+
},
|
|
136
|
+
get addAssignees() {
|
|
137
|
+
return addAssigneesCore;
|
|
138
|
+
},
|
|
139
|
+
get removeAssignees() {
|
|
140
|
+
return removeAssigneesCore;
|
|
141
|
+
},
|
|
142
|
+
get listIssueReactions() {
|
|
143
|
+
return listIssueReactionsCore;
|
|
144
|
+
},
|
|
145
|
+
get addIssueReaction() {
|
|
146
|
+
return addIssueReactionCore;
|
|
147
|
+
},
|
|
148
|
+
get listCommentReactions() {
|
|
149
|
+
return listCommentReactionsCore;
|
|
150
|
+
},
|
|
151
|
+
get addCommentReaction() {
|
|
152
|
+
return addCommentReactionCore;
|
|
153
|
+
},
|
|
154
|
+
get listDiscussions() {
|
|
155
|
+
return listDiscussionsCore;
|
|
156
|
+
},
|
|
157
|
+
get getDiscussion() {
|
|
158
|
+
return getDiscussionCore;
|
|
159
|
+
},
|
|
160
|
+
get addDiscussionComment() {
|
|
161
|
+
return addDiscussionCommentCore;
|
|
162
|
+
},
|
|
163
|
+
get listNotifications() {
|
|
164
|
+
return listNotificationsCore;
|
|
165
|
+
},
|
|
166
|
+
get markNotificationRead() {
|
|
167
|
+
return markNotificationReadCore;
|
|
168
|
+
},
|
|
169
|
+
get searchCode() {
|
|
170
|
+
return searchCodeCore;
|
|
171
|
+
},
|
|
172
|
+
get searchRepositories() {
|
|
173
|
+
return searchRepositoriesCore;
|
|
174
|
+
},
|
|
175
|
+
get searchIssues() {
|
|
176
|
+
return searchIssuesCore;
|
|
177
|
+
},
|
|
178
|
+
get listCommits() {
|
|
179
|
+
return listCommitsCore;
|
|
180
|
+
},
|
|
181
|
+
get getCommit() {
|
|
182
|
+
return getCommitCore;
|
|
183
|
+
},
|
|
184
|
+
get getBlame() {
|
|
185
|
+
return getBlameCore;
|
|
186
|
+
},
|
|
187
|
+
get compareCommits() {
|
|
188
|
+
return compareCommitsCore;
|
|
189
|
+
},
|
|
190
|
+
get listGists() {
|
|
191
|
+
return listGistsCore;
|
|
192
|
+
},
|
|
193
|
+
get getGist() {
|
|
194
|
+
return getGistCore;
|
|
195
|
+
},
|
|
196
|
+
get listGistComments() {
|
|
197
|
+
return listGistCommentsCore;
|
|
198
|
+
},
|
|
199
|
+
get createGist() {
|
|
200
|
+
return createGistCore;
|
|
201
|
+
},
|
|
202
|
+
get updateGist() {
|
|
203
|
+
return updateGistCore;
|
|
204
|
+
},
|
|
205
|
+
get deleteGist() {
|
|
206
|
+
return deleteGistCore;
|
|
207
|
+
},
|
|
208
|
+
get createGistComment() {
|
|
209
|
+
return createGistCommentCore;
|
|
210
|
+
},
|
|
211
|
+
get listWorkflows() {
|
|
212
|
+
return listWorkflowsCore;
|
|
213
|
+
},
|
|
214
|
+
get listWorkflowRuns() {
|
|
215
|
+
return listWorkflowRunsCore;
|
|
216
|
+
},
|
|
217
|
+
get getWorkflowRun() {
|
|
218
|
+
return getWorkflowRunCore;
|
|
219
|
+
},
|
|
220
|
+
get listWorkflowJobs() {
|
|
221
|
+
return listWorkflowJobsCore;
|
|
222
|
+
},
|
|
223
|
+
get getWorkflowJobLogs() {
|
|
224
|
+
return getWorkflowJobLogsCore;
|
|
225
|
+
},
|
|
226
|
+
get triggerWorkflow() {
|
|
227
|
+
return triggerWorkflowCore;
|
|
228
|
+
},
|
|
229
|
+
get cancelWorkflowRun() {
|
|
230
|
+
return cancelWorkflowRunCore;
|
|
231
|
+
},
|
|
232
|
+
get rerunWorkflowRun() {
|
|
233
|
+
return rerunWorkflowRunCore;
|
|
234
|
+
},
|
|
235
|
+
get listCheckRuns() {
|
|
236
|
+
return listCheckRunsCore;
|
|
237
|
+
},
|
|
238
|
+
get getCombinedStatus() {
|
|
239
|
+
return getCombinedStatusCore;
|
|
240
|
+
},
|
|
241
|
+
get getCiFailureContext() {
|
|
242
|
+
return getCiFailureContextCore;
|
|
243
|
+
},
|
|
244
|
+
get listReleases() {
|
|
245
|
+
return listReleasesCore;
|
|
246
|
+
},
|
|
247
|
+
get getLatestRelease() {
|
|
248
|
+
return getLatestReleaseCore;
|
|
249
|
+
},
|
|
250
|
+
get getRelease() {
|
|
251
|
+
return getReleaseCore;
|
|
252
|
+
},
|
|
253
|
+
get getReleaseContext() {
|
|
254
|
+
return getReleaseContextCore;
|
|
255
|
+
},
|
|
256
|
+
get createRelease() {
|
|
257
|
+
return createReleaseCore;
|
|
258
|
+
},
|
|
259
|
+
get updateRelease() {
|
|
260
|
+
return updateReleaseCore;
|
|
261
|
+
},
|
|
262
|
+
get deleteRelease() {
|
|
263
|
+
return deleteReleaseCore;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
export { GITHUB_TOOL_CORES as t };
|
|
268
|
+
|
|
269
|
+
//# sourceMappingURL=cores-BeLZwcde.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cores-BeLZwcde.mjs","names":["repository.getRepositoryCore","repository.listBranchesCore","repository.getFileContentCore","repository.getRepositoryTreeCore","repository.createBranchCore","repository.deleteBranchCore","repository.forkRepositoryCore","repository.createRepositoryCore","repository.createOrUpdateFileCore","pullRequests.listPullRequestsCore","pullRequests.getPullRequestCore","pullRequests.createPullRequestCore","pullRequests.mergePullRequestCore","pullRequests.updatePullRequestCore","pullRequests.addPullRequestCommentCore","pullRequests.updatePullRequestCommentCore","pullRequests.deletePullRequestCommentCore","pullRequests.listPullRequestFilesCore","pullRequests.listPullRequestReviewsCore","pullRequests.createPullRequestReviewCore","pullRequests.listPullRequestReviewThreadsCore","pullRequests.replyToReviewCommentCore","pullRequests.resolveReviewThreadCore","pullRequests.requestReviewersCore","bundles.getPullRequestContextCore","bundles.getIssueContextCore","issues.listIssuesCore","issues.getIssueCore","issues.listIssueCommentsCore","issues.createIssueCore","issues.addIssueCommentCore","issues.updateIssueCommentCore","issues.deleteIssueCommentCore","issues.closeIssueCore","issues.updateIssueCore","issues.listLabelsCore","issues.addLabelsCore","issues.removeLabelCore","issues.createLabelCore","issues.updateLabelCore","issues.deleteLabelCore","issues.addAssigneesCore","issues.removeAssigneesCore","reactions.listIssueReactionsCore","reactions.addIssueReactionCore","reactions.listCommentReactionsCore","reactions.addCommentReactionCore","discussions.listDiscussionsCore","discussions.getDiscussionCore","discussions.addDiscussionCommentCore","notifications.listNotificationsCore","notifications.markNotificationReadCore","search.searchCodeCore","search.searchRepositoriesCore","search.searchIssuesCore","commits.listCommitsCore","commits.getCommitCore","commits.getBlameCore","commits.compareCommitsCore","gists.listGistsCore","gists.getGistCore","gists.listGistCommentsCore","gists.createGistCore","gists.updateGistCore","gists.deleteGistCore","gists.createGistCommentCore","workflows.listWorkflowsCore","workflows.listWorkflowRunsCore","workflows.getWorkflowRunCore","workflows.listWorkflowJobsCore","workflows.getWorkflowJobLogsCore","workflows.triggerWorkflowCore","workflows.cancelWorkflowRunCore","workflows.rerunWorkflowRunCore","checks.listCheckRunsCore","checks.getCombinedStatusCore","bundles.getCiFailureContextCore","releases.listReleasesCore","releases.getLatestReleaseCore","releases.getReleaseCore","bundles.getReleaseContextCore","releases.createReleaseCore","releases.updateReleaseCore","releases.deleteReleaseCore"],"sources":["../src/core/cores.ts"],"sourcesContent":["import * as bundles from './bundles'\nimport * as checks from './checks'\nimport * as commits from './commits'\nimport * as discussions from './discussions'\nimport * as gists from './gists'\nimport * as issues from './issues'\nimport * as notifications from './notifications'\nimport * as pullRequests from './pull-requests'\nimport * as reactions from './reactions'\nimport * as releases from './releases'\nimport * as repository from './repository'\nimport * as search from './search'\nimport * as workflows from './workflows'\nimport type { GithubToolName } from './catalog'\n\n/**\n * The `*Core` implementation of every tool, keyed by tool name.\n *\n * Kept apart from `GITHUB_TOOL_CATALOG` so that importing tool metadata does\n * not pull Octokit into a Vercel Workflow flow bundle, which cannot load\n * Node.js built-ins. Argument types vary per tool, so callers cast at the\n * dispatch boundary. Entries are getters so the ESM binding stays live\n * (module spies in tests).\n */\nexport const GITHUB_TOOL_CORES = {\n get getRepository() { return repository.getRepositoryCore },\n get listBranches() { return repository.listBranchesCore },\n get getFileContent() { return repository.getFileContentCore },\n get getRepositoryTree() { return repository.getRepositoryTreeCore },\n get createBranch() { return repository.createBranchCore },\n get deleteBranch() { return repository.deleteBranchCore },\n get forkRepository() { return repository.forkRepositoryCore },\n get createRepository() { return repository.createRepositoryCore },\n get createOrUpdateFile() { return repository.createOrUpdateFileCore },\n get listPullRequests() { return pullRequests.listPullRequestsCore },\n get getPullRequest() { return pullRequests.getPullRequestCore },\n get createPullRequest() { return pullRequests.createPullRequestCore },\n get mergePullRequest() { return pullRequests.mergePullRequestCore },\n get updatePullRequest() { return pullRequests.updatePullRequestCore },\n get addPullRequestComment() { return pullRequests.addPullRequestCommentCore },\n get updatePullRequestComment() { return pullRequests.updatePullRequestCommentCore },\n get deletePullRequestComment() { return pullRequests.deletePullRequestCommentCore },\n get listPullRequestFiles() { return pullRequests.listPullRequestFilesCore },\n get listPullRequestReviews() { return pullRequests.listPullRequestReviewsCore },\n get createPullRequestReview() { return pullRequests.createPullRequestReviewCore },\n get listPullRequestReviewThreads() { return pullRequests.listPullRequestReviewThreadsCore },\n get replyToReviewComment() { return pullRequests.replyToReviewCommentCore },\n get resolveReviewThread() { return pullRequests.resolveReviewThreadCore },\n get requestReviewers() { return pullRequests.requestReviewersCore },\n get getPullRequestContext() { return bundles.getPullRequestContextCore },\n get getIssueContext() { return bundles.getIssueContextCore },\n get listIssues() { return issues.listIssuesCore },\n get getIssue() { return issues.getIssueCore },\n get listIssueComments() { return issues.listIssueCommentsCore },\n get createIssue() { return issues.createIssueCore },\n get addIssueComment() { return issues.addIssueCommentCore },\n get updateIssueComment() { return issues.updateIssueCommentCore },\n get deleteIssueComment() { return issues.deleteIssueCommentCore },\n get closeIssue() { return issues.closeIssueCore },\n get updateIssue() { return issues.updateIssueCore },\n get listLabels() { return issues.listLabelsCore },\n get addLabels() { return issues.addLabelsCore },\n get removeLabel() { return issues.removeLabelCore },\n get createLabel() { return issues.createLabelCore },\n get updateLabel() { return issues.updateLabelCore },\n get deleteLabel() { return issues.deleteLabelCore },\n get addAssignees() { return issues.addAssigneesCore },\n get removeAssignees() { return issues.removeAssigneesCore },\n get listIssueReactions() { return reactions.listIssueReactionsCore },\n get addIssueReaction() { return reactions.addIssueReactionCore },\n get listCommentReactions() { return reactions.listCommentReactionsCore },\n get addCommentReaction() { return reactions.addCommentReactionCore },\n get listDiscussions() { return discussions.listDiscussionsCore },\n get getDiscussion() { return discussions.getDiscussionCore },\n get addDiscussionComment() { return discussions.addDiscussionCommentCore },\n get listNotifications() { return notifications.listNotificationsCore },\n get markNotificationRead() { return notifications.markNotificationReadCore },\n get searchCode() { return search.searchCodeCore },\n get searchRepositories() { return search.searchRepositoriesCore },\n get searchIssues() { return search.searchIssuesCore },\n get listCommits() { return commits.listCommitsCore },\n get getCommit() { return commits.getCommitCore },\n get getBlame() { return commits.getBlameCore },\n get compareCommits() { return commits.compareCommitsCore },\n get listGists() { return gists.listGistsCore },\n get getGist() { return gists.getGistCore },\n get listGistComments() { return gists.listGistCommentsCore },\n get createGist() { return gists.createGistCore },\n get updateGist() { return gists.updateGistCore },\n get deleteGist() { return gists.deleteGistCore },\n get createGistComment() { return gists.createGistCommentCore },\n get listWorkflows() { return workflows.listWorkflowsCore },\n get listWorkflowRuns() { return workflows.listWorkflowRunsCore },\n get getWorkflowRun() { return workflows.getWorkflowRunCore },\n get listWorkflowJobs() { return workflows.listWorkflowJobsCore },\n get getWorkflowJobLogs() { return workflows.getWorkflowJobLogsCore },\n get triggerWorkflow() { return workflows.triggerWorkflowCore },\n get cancelWorkflowRun() { return workflows.cancelWorkflowRunCore },\n get rerunWorkflowRun() { return workflows.rerunWorkflowRunCore },\n get listCheckRuns() { return checks.listCheckRunsCore },\n get getCombinedStatus() { return checks.getCombinedStatusCore },\n get getCiFailureContext() { return bundles.getCiFailureContextCore },\n get listReleases() { return releases.listReleasesCore },\n get getLatestRelease() { return releases.getLatestReleaseCore },\n get getRelease() { return releases.getReleaseCore },\n get getReleaseContext() { return bundles.getReleaseContextCore },\n get createRelease() { return releases.createReleaseCore },\n get updateRelease() { return releases.updateReleaseCore },\n get deleteRelease() { return releases.deleteReleaseCore },\n} satisfies Record<GithubToolName, (args: never) => Promise<unknown>>\n"],"mappings":"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"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { b as GITHUB_TOOL_CATALOG, c as DEFAULT_EVALUATION_MODEL, d as RISK_QUESTION, f as rankPresets, l as INTENT_QUESTION, m as PRESET_TOOLS, oa as githubToolsErrors, p as requiresApproval, u as PRESET_PURPOSES } from "./write-tools-BaoTUCg7.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
|
+
function loadEvaluate() {
|
|
121
|
+
if (!("experimental_evaluate" in ai)) throw githubToolsErrors.EVALUATION_UNAVAILABLE();
|
|
122
|
+
return ai.experimental_evaluate;
|
|
123
|
+
}
|
|
124
|
+
function warnEvaluationFailed(model, fallback, error) {
|
|
125
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
126
|
+
console.warn("[github-tools]", githubToolsErrors.EVALUATION_FAILED({
|
|
127
|
+
model: typeof model === "string" ? model : model.modelId,
|
|
128
|
+
fallback,
|
|
129
|
+
detail: cause.message,
|
|
130
|
+
cause
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Whether an `'auto'` write tool call needs human approval: `false` only when the model
|
|
135
|
+
* rates it low-risk and asked for by the latest user message. When the evaluation call
|
|
136
|
+
* fails, logs `EVALUATION_FAILED` and asks for approval.
|
|
137
|
+
*/
|
|
138
|
+
async function needsAutoApproval(toolName, input, messages, { model = DEFAULT_EVALUATION_MODEL, maxRisk = 1, minIntent = .6 } = {}) {
|
|
139
|
+
const result = await loadEvaluate()({
|
|
140
|
+
model,
|
|
141
|
+
state: {
|
|
142
|
+
request: latestUserText(messages),
|
|
143
|
+
toolCall: {
|
|
144
|
+
tool: toolName,
|
|
145
|
+
description: GITHUB_TOOL_CATALOG[toolName].description,
|
|
146
|
+
input
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
questions: {
|
|
150
|
+
risk: {
|
|
151
|
+
type: "score",
|
|
152
|
+
...RISK_QUESTION
|
|
153
|
+
},
|
|
154
|
+
intent: {
|
|
155
|
+
type: "boolean",
|
|
156
|
+
...INTENT_QUESTION
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}).catch((error) => {
|
|
160
|
+
warnEvaluationFailed(model, `asking approval for ${toolName}`, error);
|
|
161
|
+
});
|
|
162
|
+
if (!result) return true;
|
|
163
|
+
const { answers } = result;
|
|
164
|
+
return requiresApproval(answers.risk.score, answers.intent.probability, {
|
|
165
|
+
maxRisk,
|
|
166
|
+
minIntent
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Presets the latest user message needs, from one evaluation call with an independent
|
|
171
|
+
* yes/no question per preset. Returns up to `maxPresets` presets at or above
|
|
172
|
+
* `minPresetProbability`, most likely first; when none qualifies, the single most likely preset.
|
|
173
|
+
* `repo-explorer` is only returned when no other preset qualifies.
|
|
174
|
+
* When the evaluation call fails, logs `EVALUATION_FAILED` and returns read-only `repo-explorer`.
|
|
175
|
+
* Never returns `maintainer`, so the full catalog is never exposed.
|
|
176
|
+
*/
|
|
177
|
+
async function selectPresets(messages, { model = DEFAULT_EVALUATION_MODEL, minPresetProbability = .7, maxPresets = 2 } = {}) {
|
|
178
|
+
const evaluate = loadEvaluate();
|
|
179
|
+
const presets = Object.keys(PRESET_PURPOSES);
|
|
180
|
+
const result = await evaluate({
|
|
181
|
+
model,
|
|
182
|
+
state: { request: latestUserText(messages) },
|
|
183
|
+
questions: Object.fromEntries(presets.map((preset) => [preset, {
|
|
184
|
+
type: "boolean",
|
|
185
|
+
instructions: "Does handling this GitHub request need the tools of this preset?",
|
|
186
|
+
criteria: { true: {
|
|
187
|
+
purpose: PRESET_PURPOSES[preset],
|
|
188
|
+
tools: [...PRESET_TOOLS[preset]]
|
|
189
|
+
} }
|
|
190
|
+
}]))
|
|
191
|
+
}).catch((error) => {
|
|
192
|
+
warnEvaluationFailed(model, "using the repo-explorer preset", error);
|
|
193
|
+
});
|
|
194
|
+
if (!result) return ["repo-explorer"];
|
|
195
|
+
const { answers } = result;
|
|
196
|
+
return rankPresets(Object.fromEntries(presets.map((preset) => [preset, answers[preset].probability])), {
|
|
197
|
+
minPresetProbability,
|
|
198
|
+
maxPresets
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function latestUserText(messages) {
|
|
202
|
+
const message = messages.findLast((m) => m.role === "user");
|
|
203
|
+
if (!message) return "";
|
|
204
|
+
if (typeof message.content === "string") return message.content;
|
|
205
|
+
return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { getCommitToModelOutput as a, getRepositoryTreeToModelOutput as c, compareCommitsToModelOutput as i, listPullRequestFilesToModelOutput as l, needsAutoApproval as n, getFileContentToModelOutput as o, selectPresets as r, getPullRequestContextToModelOutput as s, latestUserText as t };
|
|
209
|
+
|
|
210
|
+
//# sourceMappingURL=evaluation-f-2QwBid.mjs.map
|