@github-tools/eve-extension 0.7.4 → 0.8.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
@@ -54,6 +54,8 @@ export default githubExtension({
54
54
  })
55
55
  ```
56
56
 
57
+ A GitHub App installed on several accounts needs no configuration: each token is minted for the installation that owns the call's target `owner/repo`, after `context` defaults. Tools without a repository target use the connector's default installation. Set `installationId`, `authorizationDetails` or `repositories` in `connect` to pin one installation. If the App is not installed on the target account, the tool returns `CONNECT_INSTALLATION_REQUIRED` naming that account.
58
+
57
59
  Tools are exposed to the model as `<namespace>__<toolName>`, where `<namespace>` comes from the mount file's name: `agent/extensions/github.ts` yields `github__listPullRequests`, `github__createIssue`, and so on.
58
60
 
59
61
  To hand-pick an exact set of tools instead of a preset, pass `include`:
@@ -90,12 +92,13 @@ extension/
90
92
  |---|---|---|
91
93
  | `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
94
  | `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. `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
- | `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
+ | `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); pass `{ type: 'user', id }` or a per-caller resolver `(ctx) => subject` to mint each caller's own connection token in multi-user apps. 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 |
96
+ | `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'` picks at most two presets per user message |
95
97
  | `include` | `string[]?` | Tool names to add on top of `preset` (union), or the full set standalone |
96
98
  | `exclude` | `string[]?` | Tool names to remove from the resolved `preset` + `include` set |
97
99
  | `context` | `{ owner?, repo?, pullNumber?, issueNumber?, ref? }?` | Default working context for tool inputs and schemas |
98
- | `requireApproval` | `boolean \| record` | Global or per-tool; per-tool values may be predicate functions |
100
+ | `requireApproval` | `boolean \| 'auto' \| record` | Global or per-tool; per-tool values may be `'auto'` or predicate functions. `'auto'` runs low-risk writes the user asked for without a prompt |
101
+ | `evaluation` | `record?` | Tunes the `'auto'` modes: `model`, `maxRisk`, `minIntent`, `minPresetProbability`, `maxPresets` |
99
102
  | `overrides` | `record` | Per-tool `description` / `approval` / `toModelOutput` / `outputSchema` |
100
103
  | `author` / `committer` / `coAuthors` | commit identity | Attribution for commit-creating tools |
101
104
 
@@ -1,7 +1,7 @@
1
- import type { GithubTokenInput } from '@github-tools/sdk';
1
+ import type { GithubTokenCall, GithubTokenInput } from '@github-tools/sdk';
2
2
  import type { ConnectTokenSubject, GithubConnectorInput, GithubConnectParams } from '@github-tools/sdk/connect';
3
3
  import type { ToolContext } from 'eve/tools';
4
- import { type CommitIdentity, type EveApprovalConfig, type EveToolOverrides, type GithubToolName, type GithubToolPreset } from '@github-tools/sdk/eve-runtime';
4
+ import { type CommitIdentity, type EveApprovalValue, type EveToolOverrides, type GithubEvaluationOptions, type GithubToolName, type GithubToolPreset, type GithubWriteToolName } from '@github-tools/sdk/eve-runtime';
5
5
  import { z } from 'zod';
6
6
  /**
7
7
  * Default owner / repo / PR / issue / ref for tool inputs.
@@ -33,6 +33,24 @@ export type GithubConnectSubjectInput = ConnectTokenSubject | ((ctx: ToolContext
33
33
  export type GithubExtensionConnectParams = Omit<GithubConnectParams, 'subject'> & {
34
34
  subject?: GithubConnectSubjectInput;
35
35
  };
36
+ /**
37
+ * Resolves Connect token params for each tool call. Receives the eve tool
38
+ * execution context and the call — `owner` / `repo` are the tool's resolved
39
+ * inputs after `context` defaults, undefined for tools without a repository
40
+ * target. Selecting the installation per target repository is the default and
41
+ * needs no resolver.
42
+ */
43
+ export type GithubExtensionConnectResolver = (ctx: ToolContext, call: GithubTokenCall) => GithubExtensionConnectParams | Promise<GithubExtensionConnectParams>;
44
+ /**
45
+ * Approval for one write tool: an eve approval value, or `'auto'` to let an
46
+ * evaluation model skip approval for low-risk calls the user asked for.
47
+ */
48
+ export type GithubExtensionApprovalValue = EveApprovalValue | 'auto';
49
+ /**
50
+ * Global approval mode or per-tool approval values. `'auto'` evaluates the
51
+ * low-risk write tools (`AUTO_APPROVAL_TOOLS`) and keeps approval on the rest.
52
+ */
53
+ export type GithubExtensionApprovalConfig = boolean | 'auto' | Partial<Record<GithubWriteToolName, GithubExtensionApprovalValue>>;
36
54
  /**
37
55
  * Config passed to `githubExtension({ ... })` at the agent mount site.
38
56
  * Declared as an interface (not only a Zod schema) so IDE hovers show JSDoc.
@@ -56,10 +74,19 @@ export interface GithubExtensionConfig {
56
74
  * is set. `subject` defaults to `{ type: 'app' }` (the project's GitHub App
57
75
  * installation, shared by every caller); pass a value or a per-caller
58
76
  * resolver to mint per-user tokens instead.
77
+ *
78
+ * App tokens target the GitHub App installation owning each call's
79
+ * repository, so an App installed on several accounts needs nothing here;
80
+ * `installationId`, `authorizationDetails` or `repositories` pins one. Pass
81
+ * a resolver for other per-call rules. Scopes still derive from `preset` /
82
+ * `include` / `exclude` unless the resolved params set `scopes`.
83
+ */
84
+ connect?: GithubExtensionConnectParams | GithubExtensionConnectResolver;
85
+ /**
86
+ * Restrict tools to a preset (or array of presets). Prefer a focused preset; omit or use `maintainer` for the full catalog.
87
+ * `'auto'` picks up to two presets per user message with an evaluation model, and never exposes the full catalog.
59
88
  */
60
- connect?: GithubExtensionConnectParams;
61
- /** Restrict tools to a preset (or array of presets). Prefer a focused preset; omit or use `maintainer` for the full catalog. */
62
- preset?: GithubToolPreset | GithubToolPreset[];
89
+ preset?: GithubToolPreset | GithubToolPreset[] | 'auto';
63
90
  /**
64
91
  * Hand-pick tool names to add on top of `preset` (or standalone, without `preset`).
65
92
  * When combined with `preset`, the effective set is the union of both.
@@ -73,10 +100,12 @@ export interface GithubExtensionConfig {
73
100
  */
74
101
  context?: GithubExtensionContext;
75
102
  /**
76
- * Global boolean or per-tool approval config.
77
- * Per-tool values may be `'once'`, `'always'`, `'never'`, or predicate functions.
103
+ * Global boolean, `'auto'`, or per-tool approval config.
104
+ * Per-tool values may be `'once'`, `'always'`, `'never'`, `'auto'`, or predicate functions.
78
105
  */
79
- requireApproval?: EveApprovalConfig;
106
+ requireApproval?: GithubExtensionApprovalConfig;
107
+ /** Tuning for `preset: 'auto'` and `'auto'` approval. The evaluation model defaults to TypeSafe Jev. */
108
+ evaluation?: GithubEvaluationOptions;
80
109
  /** Per-tool overrides (`description`, `approval`, `toModelOutput`, `outputSchema`). */
81
110
  overrides?: EveToolOverrides;
82
111
  /** Default author for commit-creating tools. */
@@ -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,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,CAA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29
  token: z.custom((value) => typeof value === "string" || typeof value === "function").optional(),
30
30
  connector: z.custom((value) => typeof value === "string" || typeof value === "function").optional(),
31
- connect: z.record(z.string(), z.unknown()).optional(),
32
- preset: z.union([presetNameSchema, z.array(presetNameSchema)]).optional(),
31
+ connect: z.union([z.record(z.string(), z.unknown()), z.custom((value) => typeof value === "function")]).optional(),
32
+ preset: z.union([
33
+ presetNameSchema,
34
+ z.array(presetNameSchema),
35
+ z.literal("auto")
36
+ ]).optional(),
33
37
  include: z.array(toolNameSchema).optional(),
34
38
  exclude: z.array(toolNameSchema).optional(),
35
39
  context: z.object({
@@ -39,7 +43,18 @@ const configSchema = z.object({
39
43
  issueNumber: z.number().optional(),
40
44
  ref: z.string().optional()
41
45
  }).optional(),
42
- requireApproval: z.union([z.boolean(), z.partialRecord(writeToolNameSchema, z.unknown())]).optional(),
46
+ requireApproval: z.union([
47
+ z.boolean(),
48
+ z.literal("auto"),
49
+ z.partialRecord(writeToolNameSchema, z.unknown())
50
+ ]).optional(),
51
+ evaluation: z.object({
52
+ model: z.custom((value) => typeof value === "string" || typeof value === "object" && value !== null).optional(),
53
+ maxRisk: z.number().optional(),
54
+ minIntent: z.number().optional(),
55
+ minPresetProbability: z.number().optional(),
56
+ maxPresets: z.number().optional()
57
+ }).optional(),
43
58
  overrides: z.partialRecord(toolNameSchema, z.unknown()).optional(),
44
59
  author: commitIdentitySchema.optional(),
45
60
  committer: commitIdentitySchema.optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAoE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AAmIjH,wBAmCE"}
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAoE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AA0KjH,wBA4CE"}
@@ -5,31 +5,30 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import extension_default from "../extension.mjs";
8
- import { GITHUB_WRITE_TOOLS, executeGithubEveTool, formatGithubEveToolOutput, githubToolsErrors, isEveApprovalDisabled, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval, resolveGithubToken } from "@github-tools/sdk/eve-runtime";
8
+ import { AUTO_APPROVAL_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, executeGithubEveTool, formatGithubEveToolOutput, githubToolsErrors, isEveApprovalDisabled, latestUserText, listEveToolDescriptors, mapEveApprovalValue, needsAutoApproval, selectPresets } from "@github-tools/sdk/eve-runtime";
9
9
  import { connectGithubToken } from "@github-tools/sdk/connect";
10
10
  import { defineDurableSchema, defineDynamic, defineTool } from "eve/tools";
11
11
  function buildSessionOptions(ctx) {
12
- const { token, connector, connect, preset, include, exclude, requireApproval, overrides, context, author, committer, coAuthors } = extension_default.config;
12
+ const { token, connector, connect, preset, include, exclude, overrides, context, author, committer, coAuthors } = extension_default.config;
13
13
  const includeNames = include;
14
14
  const excludeNames = exclude;
15
15
  return {
16
- token: connector ? async () => {
17
- const { subject, ...params } = connect ?? {};
18
- const resolvedSubject = typeof subject === "function" ? await subject(requireToolContext(ctx)) : subject;
19
- return resolveGithubToken(connectGithubToken(connector, {
20
- preset,
21
- include: includeNames,
22
- exclude: excludeNames,
23
- params: {
16
+ token: connector ? connectGithubToken(connector, {
17
+ preset: preset === "auto" ? void 0 : preset,
18
+ include: includeNames,
19
+ exclude: excludeNames,
20
+ params: async (call) => {
21
+ const { subject, ...params } = typeof connect === "function" ? await connect(requireToolContext(ctx), requireToolCall(call)) : connect ?? {};
22
+ const resolvedSubject = typeof subject === "function" ? await subject(requireToolContext(ctx)) : subject;
23
+ return {
24
24
  ...params,
25
25
  ...resolvedSubject && { subject: resolvedSubject }
26
- }
27
- }));
28
- } : token,
29
- preset,
26
+ };
27
+ }
28
+ }) : token,
29
+ preset: preset === "auto" ? void 0 : preset,
30
30
  include: includeNames,
31
31
  exclude: excludeNames,
32
- requireApproval,
33
32
  overrides,
34
33
  context,
35
34
  author,
@@ -37,12 +36,35 @@ function buildSessionOptions(ctx) {
37
36
  coAuthors
38
37
  };
39
38
  }
40
- function approvalDisabled(writeTool, requireApproval, override) {
41
- if (override !== void 0) return isEveApprovalDisabled(override);
42
- if (!writeTool) return true;
43
- if (requireApproval === false) return true;
44
- if (typeof requireApproval === "object" && requireApproval !== null) return isEveApprovalDisabled(requireApproval[writeTool]);
45
- return false;
39
+ const autoApprovalTools = new Set(AUTO_APPROVAL_TOOLS);
40
+ function approvalValue(writeTool, requireApproval, override) {
41
+ if (override !== void 0) return override;
42
+ if (requireApproval === "auto") return autoApprovalTools.has(writeTool) ? "auto" : true;
43
+ if (typeof requireApproval === "object") return requireApproval[writeTool] ?? true;
44
+ return requireApproval ?? true;
45
+ }
46
+ const PENDING_APPROVALS_LABEL = "[Pending approvals]";
47
+ function withoutPendingApprovals(messages) {
48
+ return messages.filter((m) => m.role !== "user" || !latestUserText([m]).startsWith(PENDING_APPROVALS_LABEL));
49
+ }
50
+ const routedPresets = new Map();
51
+ function routePresets(sessionId, messages, evaluation) {
52
+ const key = `${sessionId}:${messages.filter((m) => m.role === "user").length}`;
53
+ let presets = routedPresets.get(key);
54
+ if (!presets) {
55
+ presets = selectPresets(messages, evaluation);
56
+ presets.catch(() => routedPresets.delete(key));
57
+ routedPresets.set(key, presets);
58
+ if (routedPresets.size > 1e3) routedPresets.delete(routedPresets.keys().next().value);
59
+ }
60
+ return presets;
61
+ }
62
+ function calledGithubTools(messages) {
63
+ return messages.flatMap((message) => message.role === "assistant" && Array.isArray(message.content) ? message.content.flatMap((part) => {
64
+ if (part.type !== "tool-call") return [];
65
+ const name = part.toolName.split("__").at(-1);
66
+ return Object.hasOwn(GITHUB_TOOL_NAMES, name) ? [name] : [];
67
+ }) : []);
46
68
  }
47
69
  function writeToolName(name) {
48
70
  if (!Object.hasOwn(GITHUB_WRITE_TOOLS, name)) return void 0;
@@ -52,6 +74,10 @@ function requireToolContext(ctx) {
52
74
  if (!ctx) throw githubToolsErrors.SUBJECT_CONTEXT_REQUIRED();
53
75
  return ctx;
54
76
  }
77
+ function requireToolCall(call) {
78
+ if (!call) throw githubToolsErrors.SUBJECT_CONTEXT_REQUIRED();
79
+ return call;
80
+ }
55
81
  async function runGithubEveTool(name, input, ctx) {
56
82
  return executeGithubEveTool(name, input, buildSessionOptions(ctx));
57
83
  }
@@ -59,12 +85,20 @@ function runGithubEveToModelOutput(name, output) {
59
85
  const custom = buildSessionOptions().overrides?.[name]?.toModelOutput;
60
86
  return custom ? custom(output) : formatGithubEveToolOutput(name, output);
61
87
  }
62
- function runGithubEveApproval(name, ctx) {
63
- const sessionOptions = buildSessionOptions();
64
- const override = sessionOptions.overrides?.[name]?.approval;
88
+ async function runGithubEveApproval(name, request, ctx) {
65
89
  const writeTool = writeToolName(name);
66
- if (!writeTool || approvalDisabled(writeTool, sessionOptions.requireApproval, override)) return "not-applicable";
67
- return (override !== void 0 ? mapEveApprovalValue(override) : resolveEveApproval(writeTool, sessionOptions.requireApproval))(ctx);
90
+ if (!writeTool) return "not-applicable";
91
+ const { requireApproval, overrides, evaluation } = extension_default.config;
92
+ const value = approvalValue(writeTool, requireApproval, overrides?.[name]?.approval);
93
+ if (value === "auto") {
94
+ const messages = [{
95
+ role: "user",
96
+ content: request
97
+ }];
98
+ return await needsAutoApproval(writeTool, ctx.toolInput, messages, evaluation) ? "user-approval" : "not-applicable";
99
+ }
100
+ if (isEveApprovalDisabled(value)) return "not-applicable";
101
+ return mapEveApprovalValue(value)(ctx);
68
102
  }
69
103
  function buildGithubEveInputSchema({ name }) {
70
104
  const descriptor = listEveToolDescriptors({
@@ -81,9 +115,16 @@ function buildGithubEveOutputSchema({ name }) {
81
115
  if (!outputSchema) throw new Error(`GitHub tool output schema override "${name}" is not available`);
82
116
  return outputSchema;
83
117
  }
84
- var github_default = defineDynamic({ events: { "step.started": async () => {
118
+ var github_default = defineDynamic({ events: { "step.started": async (_event, ctx) => {
85
119
  const sessionOptions = buildSessionOptions();
86
- const descriptors = listEveToolDescriptors(sessionOptions);
120
+ const { preset, evaluation } = extension_default.config;
121
+ const messages = withoutPendingApprovals(ctx.messages);
122
+ const request = latestUserText(messages);
123
+ const descriptors = listEveToolDescriptors(preset === "auto" ? {
124
+ ...sessionOptions,
125
+ preset: await routePresets(ctx.session.id, messages, evaluation),
126
+ include: [...sessionOptions.include ?? [], ...calledGithubTools(ctx.messages)]
127
+ } : sessionOptions);
87
128
  const tools = {};
88
129
  const toolOverrides = sessionOptions.overrides;
89
130
  for (const entry of descriptors) {
@@ -95,7 +136,7 @@ var github_default = defineDynamic({ events: { "step.started": async () => {
95
136
  closure: { name },
96
137
  schema: buildGithubEveInputSchema
97
138
  }),
98
- approval: (ctx) => runGithubEveApproval(name, ctx),
139
+ approval: (approvalCtx) => runGithubEveApproval(name, request, approvalCtx),
99
140
  toModelOutput: (output) => runGithubEveToModelOutput(name, output),
100
141
  ...override?.outputSchema !== void 0 && { outputSchema: defineDurableSchema({
101
142
  closure: { name },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@github-tools/eve-extension",
3
- "version": "0.7.4",
3
+ "version": "0.8.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.5.4",
49
- "@github-tools/sdk": "1.16.1"
49
+ "@github-tools/sdk": "1.17.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@vercel/connect": ">=0.3.2",