@github-tools/eve-extension 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ extension/
|
|
|
90
90
|
|---|---|---|
|
|
91
91
|
| `token` | `string \| (() => Promise<string>)` (optional) | PAT string, or an async provider for rotating tokens (e.g. a GitHub App installation token) — the same `GithubTokenInput` the SDK accepts; falls back to `GITHUB_TOKEN` when omitted and `connector` is not set |
|
|
92
92
|
| `connector` | `string \| (() => string \| Promise<string>)` (optional) | Vercel Connect connector name, or a resolver to pick one dynamically (e.g. per environment/tenant); takes priority over `token` |
|
|
93
|
-
| `connect` | `record?` | Passed through to `getToken` when `connector` is set |
|
|
93
|
+
| `connect` | `record?` | Passed through to `getToken` when `connector` is set. `connect.subject` defaults to `{ type: 'app' }` (the project's GitHub App installation); pass `{ type: 'user', id }` or a per-caller resolver `(ctx) => subject` to mint each caller's own connection token in multi-user apps |
|
|
94
94
|
| `preset` | preset name or array | `code-review`, `issue-triage`, `ci-ops`, `repo-explorer`, `security-audit`, `release-manager`, `discussion-moderator`, `notification-inbox`, `pr-author`, `maintainer` |
|
|
95
95
|
| `include` | `string[]?` | Tool names to add on top of `preset` (union), or the full set standalone |
|
|
96
96
|
| `exclude` | `string[]?` | Tool names to remove from the resolved `preset` + `include` set |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GithubTokenInput } from '@github-tools/sdk';
|
|
2
|
-
import type { GithubConnectorInput } from '@github-tools/sdk/connect';
|
|
2
|
+
import type { ConnectTokenSubject, GithubConnectorInput, GithubConnectParams } from '@github-tools/sdk/connect';
|
|
3
|
+
import type { ToolContext } from 'eve/tools';
|
|
3
4
|
import { type CommitIdentity, type EveApprovalConfig, type EveToolOverrides, type GithubToolName, type GithubToolPreset } from '@github-tools/sdk/eve-runtime';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
/**
|
|
@@ -18,6 +19,20 @@ export interface GithubExtensionContext {
|
|
|
18
19
|
/** Default git ref (branch, tag, or SHA). */
|
|
19
20
|
ref?: string;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Connect token subject for the extension: a static value, or a resolver
|
|
24
|
+
* called with the eve tool execution context on every tool call — e.g.
|
|
25
|
+
* `(ctx) => ({ type: 'user', id: ctx.session.auth.current!.principalId })`
|
|
26
|
+
* to mint each caller's own GitHub connection token in multi-user apps.
|
|
27
|
+
*/
|
|
28
|
+
export type GithubConnectSubjectInput = ConnectTokenSubject | ((ctx: ToolContext) => ConnectTokenSubject | Promise<ConnectTokenSubject>);
|
|
29
|
+
/**
|
|
30
|
+
* Connect token params for the extension. Same as the SDK's
|
|
31
|
+
* `GithubConnectParams`, except `subject` may also be a per-caller resolver.
|
|
32
|
+
*/
|
|
33
|
+
export type GithubExtensionConnectParams = Omit<GithubConnectParams, 'subject'> & {
|
|
34
|
+
subject?: GithubConnectSubjectInput;
|
|
35
|
+
};
|
|
21
36
|
/**
|
|
22
37
|
* Config passed to `githubExtension({ ... })` at the agent mount site.
|
|
23
38
|
* Declared as an interface (not only a Zod schema) so IDE hovers show JSDoc.
|
|
@@ -36,8 +51,13 @@ export interface GithubExtensionConfig {
|
|
|
36
51
|
* (e.g. per environment or tenant). Takes priority over `token`.
|
|
37
52
|
*/
|
|
38
53
|
connector?: GithubConnectorInput;
|
|
39
|
-
/**
|
|
40
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Vercel Connect token params passed through to `getToken` when `connector`
|
|
56
|
+
* is set. `subject` defaults to `{ type: 'app' }` (the project's GitHub App
|
|
57
|
+
* installation, shared by every caller); pass a value or a per-caller
|
|
58
|
+
* resolver to mint per-user tokens instead.
|
|
59
|
+
*/
|
|
60
|
+
connect?: GithubExtensionConnectParams;
|
|
41
61
|
/** Restrict tools to a preset (or array of presets). Prefer a focused preset; omit or use `maintainer` for the full catalog. */
|
|
42
62
|
preset?: GithubToolPreset | GithubToolPreset[];
|
|
43
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../extension/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../extension/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAEtB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GACjC,mBAAmB,GACnB,CAAC,CAAC,GAAG,EAAE,WAAW,KAAK,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAA;AAE9E;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,GAAG;IAChF,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAAA;IAChC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,4BAA4B,CAAA;IACtC,gIAAgI;IAChI,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAA;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,EAAE,CAAA;IAC1B,4FAA4F;IAC5F,OAAO,CAAC,EAAE,cAAc,EAAE,CAAA;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,uFAAuF;IACvF,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,gDAAgD;IAChD,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,mDAAmD;IACnD,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,cAAc,EAAE,CAAA;CAC7B;;AAiDD,wBAEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"AAmBA,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AA+G5F,wBA6BE"}
|
|
@@ -4,20 +4,27 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
__eveDirname(__eveFileURLToPath(import.meta.url));
|
|
5
5
|
__eveCreateRequire(import.meta.url);
|
|
6
6
|
import extension_default from "../extension.mjs";
|
|
7
|
-
import { GITHUB_WRITE_TOOLS, executeGithubEveTool, formatGithubEveToolOutput, isEveApprovalDisabled, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval } from "@github-tools/sdk/eve-runtime";
|
|
7
|
+
import { GITHUB_WRITE_TOOLS, executeGithubEveTool, formatGithubEveToolOutput, githubToolsErrors, isEveApprovalDisabled, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval, resolveGithubToken } from "@github-tools/sdk/eve-runtime";
|
|
8
8
|
import { connectGithubToken } from "@github-tools/sdk/connect";
|
|
9
9
|
import { defineDynamic, defineTool } from "eve/tools";
|
|
10
|
-
function buildSessionOptions() {
|
|
10
|
+
function buildSessionOptions(ctx) {
|
|
11
11
|
const { token, connector, connect, preset, include, exclude, requireApproval, overrides, context, author, committer, coAuthors } = extension_default.config;
|
|
12
12
|
const includeNames = include;
|
|
13
13
|
const excludeNames = exclude;
|
|
14
14
|
return {
|
|
15
|
-
token: connector ?
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
token: connector ? async () => {
|
|
16
|
+
const { subject, ...params } = connect ?? {};
|
|
17
|
+
const resolvedSubject = typeof subject === "function" ? await subject(requireToolContext(ctx)) : subject;
|
|
18
|
+
return resolveGithubToken(connectGithubToken(connector, {
|
|
19
|
+
preset,
|
|
20
|
+
include: includeNames,
|
|
21
|
+
exclude: excludeNames,
|
|
22
|
+
params: {
|
|
23
|
+
...params,
|
|
24
|
+
...resolvedSubject && { subject: resolvedSubject }
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
} : token,
|
|
21
28
|
preset,
|
|
22
29
|
include: includeNames,
|
|
23
30
|
exclude: excludeNames,
|
|
@@ -40,8 +47,12 @@ function writeToolName(name) {
|
|
|
40
47
|
if (!Object.hasOwn(GITHUB_WRITE_TOOLS, name)) return void 0;
|
|
41
48
|
return GITHUB_WRITE_TOOLS[name];
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
function requireToolContext(ctx) {
|
|
51
|
+
if (!ctx) throw githubToolsErrors.SUBJECT_CONTEXT_REQUIRED();
|
|
52
|
+
return ctx;
|
|
53
|
+
}
|
|
54
|
+
async function runGithubEveTool(name, input, ctx) {
|
|
55
|
+
return executeGithubEveTool(name, input, buildSessionOptions(ctx));
|
|
45
56
|
}
|
|
46
57
|
function runGithubEveToModelOutput(name, output) {
|
|
47
58
|
const custom = buildSessionOptions().overrides?.[name]?.toModelOutput;
|
|
@@ -68,7 +79,7 @@ var github_default = defineDynamic({ events: { "step.started": async () => {
|
|
|
68
79
|
approval: (ctx) => runGithubEveApproval(name, ctx),
|
|
69
80
|
toModelOutput: (output) => runGithubEveToModelOutput(name, output),
|
|
70
81
|
...override?.outputSchema !== void 0 && { outputSchema: override.outputSchema },
|
|
71
|
-
execute: async (input) => runGithubEveTool(name, input)
|
|
82
|
+
execute: async (input, ctx) => runGithubEveTool(name, input, ctx)
|
|
72
83
|
});
|
|
73
84
|
}
|
|
74
85
|
return tools;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-tools/eve-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "GitHub tools for eve, distributed as a mountable eve extension (https://eve.dev/docs/extensions)",
|
|
5
5
|
"author": "HugoRCD <hugo.richard@vercel.com>",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"zod": "^4.3.6",
|
|
49
|
-
"@github-tools/sdk": "1.
|
|
49
|
+
"@github-tools/sdk": "1.16.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@vercel/connect": ">=0.3.2",
|