@github-tools/eve-extension 0.13.0 → 0.14.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
@@ -118,6 +118,7 @@ channels/
118
118
  | `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 |
119
119
  | `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` |
120
120
  | `actAs` | `'app' \| 'user' \| 'caller' \| { read, write }` (optional) | Whose GitHub access the tools use when `connector` is set. `'app'` (default) uses the GitHub App installation. `'user'` runs each call with the signed-in eve user's own GitHub token, so the agent can do what that user can do on GitHub and nothing more; sessions without a signed-in user fail. `'caller'` uses the user when one drives the turn and the App otherwise (schedules, bots). Users who have not authorized the App get a sign-in prompt and never fall back to the App. Someone who comments on eve's GitHub channel can't sign in, so their call runs as the App once their own role on the target repository allows it (Read for a read, Write for a write), and fails with `CALLER_FORBIDDEN` otherwise. `{ read, write }` picks per tool kind, `overrides.<tool>.actAs` per tool. The default may change to `'caller'` in a future major version |
121
+ | `attribution` | `boolean \| { footer?, coAuthor? }` (optional) | Credit the GitHub App when a call runs with a person's token, since GitHub then records the person as the author. `createPullRequest` ends the body with `Generated by [<app>](https://github.com/apps/<app>).`, and the commit tools add the App's bot account to `coAuthors`. The App is read from the person's token, once per process. Calls that run as the App add nothing. Default `true`; `false` turns both off |
121
122
  | `approvers` | `'requester' \| 'anyone'` (optional) | Who may answer an approval. `'requester'` (default) is only the person who asked, so a colleague cannot approve your request. `'anyone'` is an opt-in that lets any signed-in user approve and anyone deny; for `'user'` and `'caller'` tools the approved call runs with the approver's GitHub token, after they sign in |
122
123
  | `connect` | `record \| ((ctx, call) => record)` (optional) | Passed through to `getToken` when `connector` is set. `connect.subject` defaults to `{ type: 'app' }` (the project's GitHub App installation); for per-user tokens, use `actAs`. App tokens target the installation owning each call's repository unless `installationId`, `authorizationDetails` or `repositories` pins one; pass a `(ctx, call) => record` resolver for other per-call rules |
123
124
  | `preset` | preset name, array, or `'auto'` | `code-review`, `issue-triage`, `ci-ops`, `repo-explorer`, `security-audit`, `release-manager`, `discussion-moderator`, `notification-inbox`, `pr-author`, `maintainer`; `'auto'` lists the tools the session's first request needs and defers the rest |
@@ -64,6 +64,13 @@ export type GithubExtensionActAs = GithubActAs | {
64
64
  };
65
65
  /** Who may answer an approval: only the requester, or any signed-in user. */
66
66
  export type GithubExtensionApprovers = 'requester' | 'anyone';
67
+ /** Which credits `attribution` adds. Each defaults to `true`. */
68
+ export interface GithubExtensionAttribution {
69
+ /** End the body of a pull request with a line saying the App generated it. */
70
+ footer?: boolean;
71
+ /** Add the App's bot account as `Co-authored-by` on commits. */
72
+ coAuthor?: boolean;
73
+ }
67
74
  /** Per-tool overrides, including the tool's own `actAs`. */
68
75
  export type GithubExtensionToolOverrides = {
69
76
  [K in GithubToolName]?: NonNullable<EveToolOverrides[K]> & {
@@ -115,6 +122,21 @@ export interface GithubExtensionConfig {
115
122
  * `'caller'` in a future major version.
116
123
  */
117
124
  actAs?: GithubExtensionActAs;
125
+ /**
126
+ * Credit the GitHub App on what a person writes through it. When a call runs with a person's
127
+ * GitHub token (`actAs: 'user'`, or `'caller'` with a signed-in user), GitHub records that person
128
+ * as the author, so by default:
129
+ *
130
+ * - `createPullRequest` ends the body with `Generated by [<app>](https://github.com/apps/<app>).`
131
+ * - `createOrUpdateFile`, `editFiles`, `mergePullRequest` and `enablePullRequestAutoMerge` add the
132
+ * App's bot account to `coAuthors`, so the commit message carries
133
+ * `Co-authored-by: <app>[bot] <id+<app>[bot]@users.noreply.github.com>`.
134
+ *
135
+ * The App is read from the person's token, so the connector must be backed by a GitHub App.
136
+ * Calls that run as the App add nothing: the App is already their author. Pass `false` to turn
137
+ * both off, or `{ footer, coAuthor }` to pick.
138
+ */
139
+ attribution?: boolean | GithubExtensionAttribution;
118
140
  /**
119
141
  * Who may answer an approval.
120
142
  *
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../extension/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,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;;;;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D,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,mDAAmD;IACnD,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,cAAc,EAAE,CAAA;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;;AA8ED,wBAEE"}
@@ -27,6 +27,10 @@ const configSchema = z.object({
27
27
  write: actAsSchema.optional()
28
28
  })]).optional(),
29
29
  approvers: z.enum(["requester", "anyone"]).optional(),
30
+ attribution: z.union([z.boolean(), z.object({
31
+ footer: z.boolean().optional(),
32
+ coAuthor: z.boolean().optional()
33
+ })]).optional(),
30
34
  connect: z.union([z.record(z.string(), z.unknown()), z.custom((value) => typeof value === "function")]).optional(),
31
35
  preset: z.union([
32
36
  presetNameSchema,
@@ -0,0 +1,10 @@
1
+ import { type EveGithubToolsOptions, type GithubToolName } from '@github-tools/sdk/eve-runtime';
2
+ /**
3
+ * The input and options of a call that runs with a person's `token`, with the App credited as
4
+ * `attribution` asks: a footer on a new pull request, a co-author on a commit.
5
+ */
6
+ export declare function withAttribution(name: GithubToolName, args: Record<string, unknown>, options: EveGithubToolsOptions, token: string): Promise<{
7
+ args: Record<string, unknown>;
8
+ options: EveGithubToolsOptions;
9
+ }>;
10
+ //# sourceMappingURL=attribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../../../extension/lib/attribution.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAA;AAsBtC;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,CAAC,CAc5E"}
@@ -0,0 +1,55 @@
1
+ import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
+ import { dirname as __eveDirname } from "node:path";
3
+ import { createRequire as __eveCreateRequire } from "node:module";
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
6
+ __eveCreateRequire(import.meta.url);
7
+ import extension_default from "../extension.mjs";
8
+ import { GITHUB_COMMIT_TOOLS, githubAppBot, githubAppBotIdentity, withGithubAppFooter } from "@github-tools/sdk/eve-runtime";
9
+ import { resolveGithubConnector } from "@github-tools/sdk/connect";
10
+ const bots = new Map();
11
+ async function appBot(token) {
12
+ const connector = await resolveGithubConnector(extension_default.config.connector);
13
+ const cached = bots.get(connector);
14
+ if (cached) return cached;
15
+ const bot = githubAppBot(token);
16
+ bots.set(connector, bot);
17
+ bot.catch(() => bots.delete(connector));
18
+ return bot;
19
+ }
20
+ function credits() {
21
+ const { attribution = true } = extension_default.config;
22
+ if (typeof attribution === "boolean") return {
23
+ footer: attribution,
24
+ coAuthor: attribution
25
+ };
26
+ return {
27
+ footer: attribution.footer ?? true,
28
+ coAuthor: attribution.coAuthor ?? true
29
+ };
30
+ }
31
+ async function withAttribution(name, args, options, token) {
32
+ const { footer, coAuthor } = credits();
33
+ const addFooter = footer && name === "createPullRequest";
34
+ const addCoAuthor = coAuthor && GITHUB_COMMIT_TOOLS.has(name);
35
+ if (!addFooter && !addCoAuthor) return {
36
+ args,
37
+ options: {
38
+ ...options,
39
+ token
40
+ }
41
+ };
42
+ const bot = await appBot(token);
43
+ return {
44
+ args: addFooter ? {
45
+ ...args,
46
+ body: withGithubAppFooter(args.body, bot)
47
+ } : args,
48
+ options: {
49
+ ...options,
50
+ token,
51
+ ...addCoAuthor && { coAuthors: [...options.coAuthors ?? [], githubAppBotIdentity(bot)] }
52
+ }
53
+ };
54
+ }
55
+ export { withAttribution };
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":";AAmYA,wBAsDE"}
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":";AAkYA,wBAsDE"}
@@ -4,6 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
+ import { withAttribution } from "../lib/attribution.mjs";
7
8
  import { githubCommenter } from "../lib/commenter.mjs";
8
9
  import { sessionContext } from "../lib/context.mjs";
9
10
  import extension_default from "../extension.mjs";
@@ -11,7 +12,7 @@ import { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, autoApprova
11
12
  import { z } from "zod";
12
13
  import { connectGithubScopesForTools, connectGithubToken, resolveGithubConnector } from "@github-tools/sdk/connect";
13
14
  import { connect } from "@vercel/connect/eve";
14
- import { defineDynamic, defineTool, toolOutput } from "eve/tools";
15
+ import { defineDynamic, defineTool } from "eve/tools";
15
16
  function buildSessionOptions(ctx, auth = ctx?.session.auth.current) {
16
17
  const { token, connector, connect, preset, include, exclude, overrides, author, committer, coAuthors, guardrails, dryRun } = extension_default.config;
17
18
  const context = sessionContext(auth);
@@ -86,6 +87,10 @@ function samePrincipal(a, b) {
86
87
  async function githubUserAuth() {
87
88
  return connect(await resolveGithubConnector(extension_default.config.connector));
88
89
  }
90
+ async function runAsUser(name, input, ctx, token) {
91
+ const { args, options } = await withAttribution(name, input, buildSessionOptions(ctx), token);
92
+ return executeGithubEveTool(name, args, options);
93
+ }
89
94
  async function runGithubEveTool(name, input, ctx) {
90
95
  const args = input;
91
96
  if (extension_default.config.dryRun && writeToolName(name)) {
@@ -113,19 +118,16 @@ async function runGithubEveTool(name, input, ctx) {
113
118
  const auth = await githubUserAuth();
114
119
  if (approvedByOther) {
115
120
  const { token } = await approver.getToken(auth);
116
- return executeGithubEveTool(name, args, {
117
- ...buildSessionOptions(ctx),
118
- token
119
- });
121
+ return runAsUser(name, args, ctx, token);
120
122
  }
121
123
  if (actAs === "caller" && !isUser(requester)) return executeGithubEveTool(name, args, buildSessionOptions(ctx));
122
124
  const { token } = await ctx.getToken(auth);
123
- const result = await executeGithubEveTool(name, args, {
124
- ...buildSessionOptions(ctx),
125
- token
126
- });
127
- if (isUnauthorized(result)) ctx.requireAuth(auth);
128
- return result;
125
+ try {
126
+ return await runAsUser(name, args, ctx, token);
127
+ } catch (error) {
128
+ if (isUnauthorized(error)) ctx.requireAuth(auth);
129
+ throw error;
130
+ }
129
131
  }
130
132
  async function runGithubEveApprovalResponse(name, { request, response, auth }) {
131
133
  if (response.decision === "deny") return { status: "allowed" };
@@ -148,20 +150,15 @@ function configuredApprovalResponse(name) {
148
150
  const value = configuredApprovalValue(name);
149
151
  return typeof value === "object" ? value.response : void 0;
150
152
  }
151
- function isUnauthorized(result) {
152
- if (!isErrorResult(result)) return false;
153
- const { error } = result;
154
- return typeof error === "object" && error !== null && "code" in error && error.code === githubToolsErrors.UNAUTHORIZED.code;
153
+ function isUnauthorized(error) {
154
+ const cause = error instanceof Error ? error.cause : void 0;
155
+ return typeof cause === "object" && cause !== null && "code" in cause && cause.code === githubToolsErrors.UNAUTHORIZED.code;
155
156
  }
156
157
  function runGithubEveToModelOutput(name, output) {
157
158
  const custom = buildSessionOptions().overrides?.[name]?.toModelOutput;
158
159
  if (custom) return custom(output);
159
- if (isErrorResult(output)) return toolOutput.errorText(JSON.stringify({ error: output.error }));
160
160
  return formatGithubEveToolOutput(name, output);
161
161
  }
162
- function isErrorResult(output) {
163
- return output != null && typeof output === "object" && !Array.isArray(output) && "error" in output && output.error != null;
164
- }
165
162
  function isPersonRequest(ctx) {
166
163
  return ctx.session.parent === void 0 && ctx.session.auth.current?.principalType !== "service";
167
164
  }
@@ -265,10 +262,6 @@ const PAST_TENSE = {
265
262
  update: "Updated"
266
263
  };
267
264
  function describeGithubResult(name, inputSchema, input, output, context) {
268
- if (output !== null && typeof output === "object" && "error" in output) {
269
- const label = describeGithubCall(name, inputSchema, input, context);
270
- return `Couldn't ${label[0].toLowerCase()}${label.slice(1)}`;
271
- }
272
265
  if (!writeToolName(name)) return "";
273
266
  if (output !== null && typeof output === "object" && "dryRun" in output) {
274
267
  const label = describeGithubCall(name, inputSchema, input, context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@github-tools/eve-extension",
3
- "version": "0.13.0",
3
+ "version": "0.14.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": {
@@ -51,7 +51,7 @@
51
51
  "license": "MIT",
52
52
  "dependencies": {
53
53
  "zod": "^4.6.7",
54
- "@github-tools/sdk": "1.22.0"
54
+ "@github-tools/sdk": "1.23.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@vercel/connect": ">=2.7.0",