@github-tools/eve-extension 0.3.1 → 0.4.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
@@ -43,7 +43,7 @@ export default githubExtension({
43
43
 
44
44
  > `code-review` pairs cleanly with a Connect `connector`. `maintainer` and `repo-explorer` include gist tools, and GitHub only grants gist access to user access tokens, never the installation tokens Connect mints, so gist calls 403 over Connect. Write tools already require approval via `always()` by default, so a plain `{ someTool: true }` is a no-op, use a predicate (as above) when you actually want to narrow or loosen the default.
45
45
 
46
- Tools are registered with **inline** `execute` handlers in the extension package so they survive multi-turn durable eve Workflow replay (see [#51](https://github.com/vercel-labs/github-tools/issues/51)). Do not use the deprecated `@github-tools/sdk/connect/eve` one-liner for durable Slack/multi-turn agents.
46
+ Tools are registered with **inline** `execute` and `toModelOutput` handlers in the extension package so they survive multi-turn durable eve Workflow replay (see [#51](https://github.com/vercel-labs/github-tools/issues/51), [#99](https://github.com/vercel-labs/github-tools/issues/99)). `toModelOutput` strips `rateLimit` from the model-facing payload; the execute result still carries it for hooks and channels. Do not use the deprecated `@github-tools/sdk/connect/eve` one-liner for durable Slack/multi-turn agents.
47
47
 
48
48
  `connector` also accepts a `() => string | Promise<string>` resolver, so the same config can pick a connector dynamically (e.g. by environment):
49
49
 
@@ -73,7 +73,7 @@ export default githubExtension({
73
73
  })
74
74
  ```
75
75
 
76
- See the runnable consumer at [`examples/eve-extension-agent`](../../examples/eve-extension-agent).
76
+ See the runnable consumer at [`examples/eve`](../../examples/eve).
77
77
 
78
78
  ## Structure
79
79
 
@@ -88,7 +88,7 @@ extension/
88
88
 
89
89
  | Field | Type | Notes |
90
90
  |---|---|---|
91
- | `token` | `string?` | Falls back to `GITHUB_TOKEN` when omitted and `connector` is not set |
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
93
  | `connect` | `record?` | Passed through to `getToken` when `connector` is set |
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` |
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "kind": "eve-extension",
3
- "formatVersion": 1,
4
- "builtWithEve": "0.30.6",
3
+ "formatVersion": 2,
4
+ "builtWithEve": "0.40.0",
5
5
  "requires": {
6
6
  "extension": 1,
7
- "tool": 5,
8
- "dynamicTool": 8,
7
+ "tool": 13,
8
+ "dynamicTool": 18,
9
9
  "config": 1
10
10
  }
11
11
  }
@@ -1,3 +1,4 @@
1
+ import type { GithubTokenInput } from '@github-tools/sdk';
1
2
  import type { GithubConnectorInput } from '@github-tools/sdk/connect';
2
3
  import { type CommitIdentity, type EveApprovalConfig, type EveToolOverrides, type GithubToolName, type GithubToolPreset } from '@github-tools/sdk/eve-runtime';
3
4
  import { z } from 'zod';
@@ -22,8 +23,13 @@ export interface GithubExtensionContext {
22
23
  * Declared as an interface (not only a Zod schema) so IDE hovers show JSDoc.
23
24
  */
24
25
  export interface GithubExtensionConfig {
25
- /** GitHub PAT. Falls back to `GITHUB_TOKEN` when omitted and `connector` is not set. */
26
- token?: string;
26
+ /**
27
+ * GitHub token: a PAT string, or a `() => Promise<string>` provider for
28
+ * tokens that rotate (a GitHub App installation token, a vault lease).
29
+ * Same input the SDK accepts. Falls back to `GITHUB_TOKEN` when omitted
30
+ * and `connector` is not set.
31
+ */
32
+ token?: GithubTokenInput;
27
33
  /**
28
34
  * Vercel Connect connector name (e.g. `github/my-connector`), or a
29
35
  * `() => string | Promise<string>` resolver for picking one dynamically
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["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AAA;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;;AA8CD,wBAEE"}
@@ -24,7 +24,7 @@ const commitIdentitySchema = z.object({
24
24
  email: z.string()
25
25
  });
26
26
  var extension_default = defineExtension({ config: z.object({
27
- token: z.string().optional(),
27
+ token: z.custom((value) => typeof value === "string" || typeof value === "function").optional(),
28
28
  connector: z.custom((value) => typeof value === "string" || typeof value === "function").optional(),
29
29
  connect: z.record(z.string(), z.unknown()).optional(),
30
30
  preset: z.union([presetNameSchema, z.array(presetNameSchema)]).optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"AAWA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AAa1E,wBAyEE"}
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../extension/tools/github.ts"],"names":[],"mappings":"AAeA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AAqE1E,wBAyCE"}
@@ -4,18 +4,14 @@ 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 { executeGithubEveTool, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval } from "@github-tools/sdk/eve-runtime";
7
+ import { executeGithubEveTool, formatGithubEveToolOutput, isEveApprovalDisabled, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval } from "@github-tools/sdk/eve-runtime";
8
8
  import { connectGithubToken } from "@github-tools/sdk/connect";
9
9
  import { defineDynamic, defineTool } from "eve/tools";
10
- let sessionOptions = {};
11
- async function runGithubEveTool(name, input) {
12
- return executeGithubEveTool(name, input, sessionOptions);
13
- }
14
- var github_default = defineDynamic({ events: { "session.started": async () => {
10
+ function buildSessionOptions() {
15
11
  const { token, connector, connect, preset, include, exclude, requireApproval, overrides, context, author, committer, coAuthors } = extension_default.config;
16
12
  const includeNames = include;
17
13
  const excludeNames = exclude;
18
- sessionOptions = {
14
+ return {
19
15
  token: connector ? connectGithubToken(connector, {
20
16
  preset,
21
17
  include: includeNames,
@@ -32,18 +28,32 @@ var github_default = defineDynamic({ events: { "session.started": async () => {
32
28
  committer,
33
29
  coAuthors
34
30
  };
31
+ }
32
+ function approvalDisabled(writeTool, requireApproval, override) {
33
+ if (override !== void 0) return isEveApprovalDisabled(override);
34
+ if (!writeTool) return true;
35
+ if (requireApproval === false) return true;
36
+ if (typeof requireApproval === "object" && requireApproval !== null) return isEveApprovalDisabled(requireApproval[writeTool]);
37
+ return false;
38
+ }
39
+ async function runGithubEveTool(name, input) {
40
+ return executeGithubEveTool(name, input, buildSessionOptions());
41
+ }
42
+ var github_default = defineDynamic({ events: { "step.started": async () => {
43
+ const sessionOptions = buildSessionOptions();
35
44
  const descriptors = listEveToolDescriptors(sessionOptions);
36
45
  const tools = {};
37
46
  const toolOverrides = sessionOptions.overrides;
38
47
  for (const entry of descriptors) {
39
48
  const name = entry.name;
40
49
  const override = toolOverrides?.[name];
50
+ const skipApproval = approvalDisabled(entry.writeTool, sessionOptions.requireApproval, override?.approval);
41
51
  tools[name] = defineTool({
42
52
  description: override?.description ?? entry.description,
43
53
  inputSchema: entry.inputSchema,
44
- ...entry.writeTool && { approval: resolveEveApproval(entry.writeTool, sessionOptions.requireApproval) },
45
- ...override?.approval !== void 0 && { approval: mapEveApprovalValue(override.approval) },
46
- ...override?.toModelOutput !== void 0 ? { toModelOutput: override.toModelOutput } : entry.toModelOutput ? { toModelOutput: entry.toModelOutput } : {},
54
+ ...entry.writeTool && !skipApproval && { approval: resolveEveApproval(entry.writeTool, sessionOptions.requireApproval) },
55
+ ...override?.approval !== void 0 && !skipApproval && { approval: mapEveApprovalValue(override.approval) },
56
+ ...override?.toModelOutput !== void 0 ? { toModelOutput: override.toModelOutput } : { toModelOutput: (output) => formatGithubEveToolOutput(name, output) },
47
57
  ...override?.outputSchema !== void 0 && { outputSchema: override.outputSchema },
48
58
  execute: async (input) => runGithubEveTool(name, input)
49
59
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@github-tools/eve-extension",
3
- "version": "0.3.1",
3
+ "version": "0.4.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.11.0"
49
+ "@github-tools/sdk": "1.12.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@vercel/connect": ">=0.3.2",
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^26.1.2",
62
62
  "@vercel/connect": "^0.6.1",
63
63
  "eslint": "^10.8.0",
64
- "eve": "^0.30.6",
64
+ "eve": "^0.40.0",
65
65
  "typescript": "^6.0.3",
66
66
  "typescript-eslint": "^8.65.0"
67
67
  },