@github-tools/eve-extension 0.4.1 → 0.5.1
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` and `
|
|
46
|
+
Tools are registered with **inline** `execute`, `toModelOutput`, and `approval` as direct `defineTool` properties 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)). A spread or call-expression callback has no durable descriptor: on eve 0.44+ the resolver discards every GitHub tool. `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
|
|
|
@@ -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;AACrE,OAAO,
|
|
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,2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;CAC7B;;AAiDD,wBAEE"}
|
|
@@ -3,7 +3,7 @@ import { dirname as __eveDirname } from "node:path";
|
|
|
3
3
|
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
4
|
__eveDirname(__eveFileURLToPath(import.meta.url));
|
|
5
5
|
__eveCreateRequire(import.meta.url);
|
|
6
|
-
import { GITHUB_TOOL_NAMES } from "@github-tools/sdk/eve-runtime";
|
|
6
|
+
import { GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS } from "@github-tools/sdk/eve-runtime";
|
|
7
7
|
import { defineExtension } from "eve/extension";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
const presetNameSchema = z.enum([
|
|
@@ -19,6 +19,7 @@ const presetNameSchema = z.enum([
|
|
|
19
19
|
"maintainer"
|
|
20
20
|
]);
|
|
21
21
|
const toolNameSchema = z.enum(Object.values(GITHUB_TOOL_NAMES));
|
|
22
|
+
const writeToolNameSchema = z.enum(Object.values(GITHUB_WRITE_TOOLS));
|
|
22
23
|
const commitIdentitySchema = z.object({
|
|
23
24
|
name: z.string(),
|
|
24
25
|
email: z.string()
|
|
@@ -37,8 +38,8 @@ var extension_default = defineExtension({ config: z.object({
|
|
|
37
38
|
issueNumber: z.number().optional(),
|
|
38
39
|
ref: z.string().optional()
|
|
39
40
|
}).optional(),
|
|
40
|
-
requireApproval: z.union([z.boolean(), z.
|
|
41
|
-
overrides: z.
|
|
41
|
+
requireApproval: z.union([z.boolean(), z.partialRecord(writeToolNameSchema, z.unknown())]).optional(),
|
|
42
|
+
overrides: z.partialRecord(toolNameSchema, z.unknown()).optional(),
|
|
42
43
|
author: commitIdentitySchema.optional(),
|
|
43
44
|
committer: commitIdentitySchema.optional(),
|
|
44
45
|
coAuthors: z.array(commitIdentitySchema).optional()
|
|
@@ -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":"AAiBA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;;AAgG1E,wBA6BE"}
|
|
@@ -4,7 +4,7 @@ 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, formatGithubEveToolOutput, isEveApprovalDisabled, listEveToolDescriptors, mapEveApprovalValue, resolveEveApproval } from "@github-tools/sdk/eve-runtime";
|
|
7
|
+
import { GITHUB_WRITE_TOOLS, 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
10
|
function buildSessionOptions() {
|
|
@@ -36,9 +36,24 @@ function approvalDisabled(writeTool, requireApproval, override) {
|
|
|
36
36
|
if (typeof requireApproval === "object" && requireApproval !== null) return isEveApprovalDisabled(requireApproval[writeTool]);
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
+
function writeToolName(name) {
|
|
40
|
+
if (!Object.hasOwn(GITHUB_WRITE_TOOLS, name)) return void 0;
|
|
41
|
+
return GITHUB_WRITE_TOOLS[name];
|
|
42
|
+
}
|
|
39
43
|
async function runGithubEveTool(name, input) {
|
|
40
44
|
return executeGithubEveTool(name, input, buildSessionOptions());
|
|
41
45
|
}
|
|
46
|
+
function runGithubEveToModelOutput(name, output) {
|
|
47
|
+
const custom = buildSessionOptions().overrides?.[name]?.toModelOutput;
|
|
48
|
+
return custom ? custom(output) : formatGithubEveToolOutput(name, output);
|
|
49
|
+
}
|
|
50
|
+
function runGithubEveApproval(name, ctx) {
|
|
51
|
+
const sessionOptions = buildSessionOptions();
|
|
52
|
+
const override = sessionOptions.overrides?.[name]?.approval;
|
|
53
|
+
const writeTool = writeToolName(name);
|
|
54
|
+
if (!writeTool || approvalDisabled(writeTool, sessionOptions.requireApproval, override)) return "not-applicable";
|
|
55
|
+
return (override !== void 0 ? mapEveApprovalValue(override) : resolveEveApproval(writeTool, sessionOptions.requireApproval))(ctx);
|
|
56
|
+
}
|
|
42
57
|
var github_default = defineDynamic({ events: { "step.started": async () => {
|
|
43
58
|
const sessionOptions = buildSessionOptions();
|
|
44
59
|
const descriptors = listEveToolDescriptors(sessionOptions);
|
|
@@ -47,16 +62,11 @@ var github_default = defineDynamic({ events: { "step.started": async () => {
|
|
|
47
62
|
for (const entry of descriptors) {
|
|
48
63
|
const name = entry.name;
|
|
49
64
|
const override = toolOverrides?.[name];
|
|
50
|
-
const skipApproval = approvalDisabled(entry.writeTool, sessionOptions.requireApproval, override?.approval);
|
|
51
65
|
tools[name] = defineTool({
|
|
52
66
|
description: override?.description ?? entry.description,
|
|
53
67
|
inputSchema: entry.inputSchema,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
toModelOutput: (output) => {
|
|
57
|
-
const custom = buildSessionOptions().overrides?.[name]?.toModelOutput;
|
|
58
|
-
return custom ? custom(output) : formatGithubEveToolOutput(name, output);
|
|
59
|
-
},
|
|
68
|
+
approval: (ctx) => runGithubEveApproval(name, ctx),
|
|
69
|
+
toModelOutput: (output) => runGithubEveToModelOutput(name, output),
|
|
60
70
|
...override?.outputSchema !== void 0 && { outputSchema: override.outputSchema },
|
|
61
71
|
execute: async (input) => runGithubEveTool(name, input)
|
|
62
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-tools/eve-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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,11 +46,11 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"zod": "^4.3.6",
|
|
49
|
-
"@github-tools/sdk": "1.
|
|
49
|
+
"@github-tools/sdk": "1.14.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@vercel/connect": ">=0.3.2",
|
|
53
|
-
"eve": ">=0.44.0"
|
|
53
|
+
"eve": ">=0.44.0 <0.48.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@vercel/connect": {
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"build": "eve extension build",
|
|
73
73
|
"lint": "eslint .",
|
|
74
74
|
"lint:fix": "eslint . --fix",
|
|
75
|
-
"typecheck": "tsc --noEmit"
|
|
75
|
+
"typecheck": "tsc --noEmit",
|
|
76
|
+
"test": "node --test --experimental-strip-types ./test/durable-define-tool.test.ts"
|
|
76
77
|
}
|
|
77
78
|
}
|