@zhin.js/adapter-github 3.0.2 → 3.0.3

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +624 -0
  2. package/README.md +38 -201
  3. package/adapters/github.ts +51 -0
  4. package/agent/skills/github.md +2 -2
  5. package/agent/tools/bind.ts +2 -2
  6. package/agent/tools/create_pr.ts +2 -2
  7. package/agent/tools/install.ts +2 -2
  8. package/agent/tools/patch_file.ts +2 -2
  9. package/agent/tools/prepare_workspace.ts +2 -2
  10. package/agent/tools/push_branch.ts +2 -2
  11. package/agent/tools/star.ts +2 -2
  12. package/agent/tools/subscribe.ts +2 -2
  13. package/agent/tools/subscriptions.ts +2 -2
  14. package/agent/tools/unbind.ts +2 -2
  15. package/agent/tools/unsubscribe.ts +2 -2
  16. package/agent/tools/whoami.ts +2 -2
  17. package/lib/agent-prompt.d.ts +2 -0
  18. package/lib/{src/agent-prompt.js → agent-prompt.js} +0 -1
  19. package/lib/endpoint.d.ts +48 -0
  20. package/lib/endpoint.js +165 -0
  21. package/lib/gh-client.d.ts +300 -0
  22. package/lib/{src/gh-client.js → gh-client.js} +1 -2
  23. package/lib/github-agent-deps.d.ts +47 -0
  24. package/lib/github-agent-deps.js +43 -0
  25. package/lib/github-bot-handlers.d.ts +26 -0
  26. package/lib/{src/github-bot-handlers.js → github-bot-handlers.js} +0 -1
  27. package/lib/github-channel-context.d.ts +16 -0
  28. package/lib/{src/github-channel-context.js → github-channel-context.js} +0 -1
  29. package/lib/github-tool-handlers.d.ts +17 -0
  30. package/lib/{src/github-tool-handlers.js → github-tool-handlers.js} +14 -8
  31. package/lib/index.d.ts +9 -0
  32. package/lib/index.js +9 -0
  33. package/lib/oauth-users.d.ts +33 -0
  34. package/lib/oauth-users.js +38 -0
  35. package/lib/protocol.d.ts +87 -0
  36. package/lib/protocol.js +241 -0
  37. package/lib/types.d.ts +149 -0
  38. package/lib/{src/types.js → types.js} +0 -1
  39. package/lib/webhook.d.ts +13 -0
  40. package/lib/webhook.js +87 -0
  41. package/lib/workspace-manager.d.ts +21 -0
  42. package/lib/{src/workspace-manager.js → workspace-manager.js} +37 -1
  43. package/package.json +53 -26
  44. package/plugin.ts +52 -0
  45. package/schema.json +65 -0
  46. package/src/endpoint.ts +166 -175
  47. package/src/gh-client.ts +1 -1
  48. package/src/github-agent-deps.ts +66 -11
  49. package/src/github-tool-handlers.ts +20 -7
  50. package/src/index.ts +55 -137
  51. package/src/oauth-users.ts +47 -0
  52. package/src/protocol.ts +367 -0
  53. package/src/webhook.ts +125 -0
  54. package/src/workspace-manager.ts +44 -0
  55. package/lib/agent/tools/bind.js +0 -12
  56. package/lib/agent/tools/bind.js.map +0 -1
  57. package/lib/agent/tools/create_pr.js +0 -19
  58. package/lib/agent/tools/create_pr.js.map +0 -1
  59. package/lib/agent/tools/install.js +0 -12
  60. package/lib/agent/tools/install.js.map +0 -1
  61. package/lib/agent/tools/patch_file.js +0 -18
  62. package/lib/agent/tools/patch_file.js.map +0 -1
  63. package/lib/agent/tools/prepare_workspace.js +0 -14
  64. package/lib/agent/tools/prepare_workspace.js.map +0 -1
  65. package/lib/agent/tools/push_branch.js +0 -17
  66. package/lib/agent/tools/push_branch.js.map +0 -1
  67. package/lib/agent/tools/star.js +0 -15
  68. package/lib/agent/tools/star.js.map +0 -1
  69. package/lib/agent/tools/subscribe.js +0 -16
  70. package/lib/agent/tools/subscribe.js.map +0 -1
  71. package/lib/agent/tools/subscriptions.js +0 -13
  72. package/lib/agent/tools/subscriptions.js.map +0 -1
  73. package/lib/agent/tools/unbind.js +0 -12
  74. package/lib/agent/tools/unbind.js.map +0 -1
  75. package/lib/agent/tools/unsubscribe.js +0 -15
  76. package/lib/agent/tools/unsubscribe.js.map +0 -1
  77. package/lib/agent/tools/whoami.js +0 -12
  78. package/lib/agent/tools/whoami.js.map +0 -1
  79. package/lib/src/adapter.js +0 -423
  80. package/lib/src/adapter.js.map +0 -1
  81. package/lib/src/agent-prompt.js.map +0 -1
  82. package/lib/src/endpoint.js +0 -189
  83. package/lib/src/endpoint.js.map +0 -1
  84. package/lib/src/gh-client.js.map +0 -1
  85. package/lib/src/github-agent-deps.js +0 -13
  86. package/lib/src/github-agent-deps.js.map +0 -1
  87. package/lib/src/github-bot-handlers.js.map +0 -1
  88. package/lib/src/github-channel-context.js.map +0 -1
  89. package/lib/src/github-tool-handlers.js.map +0 -1
  90. package/lib/src/index.js +0 -104
  91. package/lib/src/index.js.map +0 -1
  92. package/lib/src/register-github-mcp.js +0 -41
  93. package/lib/src/register-github-mcp.js.map +0 -1
  94. package/lib/src/segment-mapper.js +0 -2
  95. package/lib/src/segment-mapper.js.map +0 -1
  96. package/lib/src/types.js.map +0 -1
  97. package/lib/src/workspace-manager.js.map +0 -1
  98. package/plugin.yml +0 -3
  99. package/src/adapter.ts +0 -454
  100. package/src/register-github-mcp.ts +0 -67
  101. package/src/segment-mapper.ts +0 -1
package/src/webhook.ts ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * GitHub webhook HTTP: verify → parse → admit inbound comments.
3
+ */
4
+ import type { IncomingMessage, ServerResponse } from 'node:http';
5
+ import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
6
+ import { formatCompact, getLogger } from '@zhin.js/logger';
7
+ import {
8
+ headerValue,
9
+ parseIssueCommentInbound,
10
+ parsePrReviewCommentInbound,
11
+ parsePrReviewInbound,
12
+ readTextBody,
13
+ verifyWebhookSignature,
14
+ type GithubInboundComment,
15
+ type IssueCommentPayload,
16
+ type PRReviewCommentPayload,
17
+ type PRReviewPayload,
18
+ type ResolvedGithubConfig,
19
+ } from './protocol.js';
20
+
21
+ const logger = getLogger('github');
22
+
23
+ export interface GithubWebhookHandler {
24
+ readonly config: ResolvedGithubConfig;
25
+ admit(comment: GithubInboundComment): void;
26
+ }
27
+
28
+ export function registerGithubWebhookRoutes(
29
+ http: HttpHost,
30
+ handler: GithubWebhookHandler,
31
+ ): HttpRouteRegistration[] {
32
+ const routePath = handler.config.webhookPath;
33
+ return [
34
+ http.route('POST', routePath, async (request, response) => {
35
+ await handleGithubWebhookRequest(request, response, handler);
36
+ }, { summary: 'GitHub webhook', tags: ['github'] }),
37
+ ];
38
+ }
39
+
40
+ export async function handleGithubWebhookRequest(
41
+ request: IncomingMessage,
42
+ response: ServerResponse,
43
+ handler: GithubWebhookHandler,
44
+ ): Promise<void> {
45
+ const secret = handler.config.webhookSecret;
46
+ if (!secret) {
47
+ response.writeHead(503, { 'Content-Type': 'application/json' });
48
+ response.end(JSON.stringify({ error: 'Webhook not configured' }));
49
+ return;
50
+ }
51
+
52
+ const signature = headerValue(request.headers, 'x-hub-signature-256');
53
+ const event = headerValue(request.headers, 'x-github-event');
54
+ const deliveryId = headerValue(request.headers, 'x-github-delivery');
55
+
56
+ if (!signature || !event) {
57
+ response.writeHead(400, { 'Content-Type': 'application/json' });
58
+ response.end(JSON.stringify({ error: 'Missing signature or event header' }));
59
+ return;
60
+ }
61
+
62
+ try {
63
+ const rawBody = await readTextBody(request);
64
+ if (!verifyWebhookSignature(secret, rawBody, signature)) {
65
+ logger.warn(formatCompact({
66
+ op: 'webhook',
67
+ ok: false,
68
+ error: 'invalid signature',
69
+ delivery: deliveryId,
70
+ }));
71
+ response.writeHead(401, { 'Content-Type': 'application/json' });
72
+ response.end(JSON.stringify({ error: 'Invalid signature' }));
73
+ return;
74
+ }
75
+
76
+ let payload: unknown;
77
+ try {
78
+ payload = rawBody ? JSON.parse(rawBody) : {};
79
+ } catch {
80
+ response.writeHead(400, { 'Content-Type': 'application/json' });
81
+ response.end(JSON.stringify({ error: 'Invalid JSON' }));
82
+ return;
83
+ }
84
+
85
+ response.writeHead(200, { 'Content-Type': 'application/json' });
86
+ response.end(JSON.stringify({ ok: true }));
87
+
88
+ void dispatchGithubWebhookPayload(event, payload, handler).catch((e) => {
89
+ logger.error(`Webhook 事件处理失败 (${event}):`, e);
90
+ });
91
+ } catch (error) {
92
+ logger.error('Webhook error:', error);
93
+ if (!response.headersSent) {
94
+ response.writeHead(500, { 'Content-Type': 'application/json' });
95
+ response.end(JSON.stringify({ error: 'Internal Server Error' }));
96
+ }
97
+ }
98
+ }
99
+
100
+ export async function dispatchGithubWebhookPayload(
101
+ event: string,
102
+ payload: unknown,
103
+ handler: GithubWebhookHandler,
104
+ ): Promise<void> {
105
+ if (!payload || typeof payload !== 'object') return;
106
+ const body = payload as Record<string, unknown>;
107
+ const repo = (body.repository as { full_name?: string } | undefined)?.full_name;
108
+ logger.debug(`Webhook: ${event}${(body.action as string) ? `.${body.action}` : ''} ${repo || ''}`);
109
+
110
+ if (event === 'issue_comment') {
111
+ const inbound = parseIssueCommentInbound(payload as IssueCommentPayload);
112
+ if (inbound) handler.admit(inbound);
113
+ return;
114
+ }
115
+ if (event === 'pull_request_review_comment') {
116
+ const inbound = parsePrReviewCommentInbound(payload as PRReviewCommentPayload);
117
+ if (inbound) handler.admit(inbound);
118
+ return;
119
+ }
120
+ if (event === 'pull_request_review') {
121
+ const inbound = parsePrReviewInbound(payload as PRReviewPayload);
122
+ if (inbound) handler.admit(inbound);
123
+ }
124
+ // Cross-adapter subscription fan-out deferred (needs multi-adapter send in Runtime).
125
+ }
@@ -6,6 +6,43 @@ import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import type { GhClient, GitHubBotIdentity } from './gh-client.js';
8
8
 
9
+ const REPO_FULL_NAME_RE = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
10
+ const GIT_REF_ILLEGAL_RE = /[\s\x00-\x1f\x7f~^:?*[\\`;]/;
11
+
12
+ /**
13
+ * 校验 GitHub "owner/name" 全名,防止路径穿越与 git 选项注入。
14
+ * 返回通过校验的原值,便于调用方直接使用「已消毒」的变量。
15
+ */
16
+ export function assertRepoFullName(repo: string): string {
17
+ if (
18
+ typeof repo !== 'string' ||
19
+ !REPO_FULL_NAME_RE.test(repo) ||
20
+ repo.split('/').some((seg) => seg === '' || seg.startsWith('-') || /^\.+$/.test(seg))
21
+ ) {
22
+ throw new TypeError(`非法的仓库全名: ${JSON.stringify(repo)}`);
23
+ }
24
+ return repo;
25
+ }
26
+
27
+ /**
28
+ * 校验 git ref 名称,拒绝选项注入(`-` 前缀)与 git 非法字符。
29
+ */
30
+ export function assertGitRefName(ref: string): string {
31
+ if (typeof ref !== 'string' || ref.length === 0) {
32
+ throw new TypeError(`非法的 git ref: ${JSON.stringify(ref)}`);
33
+ }
34
+ if (
35
+ ref.startsWith('-') ||
36
+ ref.includes('..') ||
37
+ GIT_REF_ILLEGAL_RE.test(ref) ||
38
+ ref.endsWith('/') ||
39
+ ref.endsWith('.')
40
+ ) {
41
+ throw new TypeError(`非法的 git ref: ${JSON.stringify(ref)}`);
42
+ }
43
+ return ref;
44
+ }
45
+
9
46
  export class WorkspaceManager {
10
47
  constructor(
11
48
  private readonly gh: GhClient,
@@ -13,6 +50,7 @@ export class WorkspaceManager {
13
50
  ) {}
14
51
 
15
52
  getRepoPath(repo: string): string {
53
+ repo = assertRepoFullName(repo);
16
54
  const [owner, name] = repo.split('/');
17
55
  return path.join(this.rootDir, owner, name);
18
56
  }
@@ -47,6 +85,7 @@ export class WorkspaceManager {
47
85
  }
48
86
 
49
87
  async ensureRepo(repo: string): Promise<string> {
88
+ repo = assertRepoFullName(repo);
50
89
  if (!this.gh.isAppAuth) {
51
90
  throw new Error('GitHub App 认证未配置,无法托管工作区');
52
91
  }
@@ -72,6 +111,9 @@ export class WorkspaceManager {
72
111
  }
73
112
 
74
113
  async checkoutBranch(repo: string, branch: string, baseRef: string): Promise<string> {
114
+ repo = assertRepoFullName(repo);
115
+ branch = assertGitRefName(branch);
116
+ baseRef = assertGitRefName(baseRef);
75
117
  const repoPath = await this.ensureRepo(repo);
76
118
  const localBranches = await this.runGit(repoPath, ['branch', '--list', branch]);
77
119
  if (localBranches.trim()) {
@@ -94,6 +136,8 @@ export class WorkspaceManager {
94
136
  }
95
137
 
96
138
  async commitAndPush(repo: string, branch: string, message: string): Promise<string> {
139
+ repo = assertRepoFullName(repo);
140
+ branch = assertGitRefName(branch);
97
141
  const repoPath = this.getRepoPath(repo);
98
142
  if (!fs.existsSync(repoPath)) {
99
143
  throw new Error(`工作区不存在: ${repoPath},请先 github_prepare_workspace`);
@@ -1,12 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubBind } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '绑定你的 GitHub 账号 — 使用 Device Flow 授权,无需输入密码',
6
- inputSchema: z.object({}),
7
- tags: ['github'],
8
- async execute() {
9
- return executeGithubBind({});
10
- },
11
- });
12
- //# sourceMappingURL=bind.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bind.js","sourceRoot":"","sources":["../../../agent/tools/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,2CAA2C;IACxD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC"}
@@ -1,19 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubCreatePr } from '../../src/github-bot-handlers.js';
4
- export default defineTool({
5
- description: '以 GitHub App Bot 身份创建 Pull Request(需 HITL 确认;Issue 场景常用)',
6
- inputSchema: z.object({
7
- repo: z.string().optional().describe('owner/repo'),
8
- title: z.string().describe('PR 标题'),
9
- body: z.string().optional().describe('PR 正文'),
10
- head: z.string().optional().describe('head 分支,缺省为工作区分支'),
11
- base: z.string().optional().describe('base 分支,缺省为仓库默认分支'),
12
- }),
13
- tags: ['github'],
14
- approval: 'always',
15
- async execute(input) {
16
- return executeGithubCreatePr(input);
17
- },
18
- });
19
- //# sourceMappingURL=create_pr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_pr.js","sourceRoot":"","sources":["../../../agent/tools/create_pr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,eAAe,UAAU,CAAgF;IACvG,WAAW,EAAE,0DAA0D;IACvE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACxD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;KAC1D,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubInstall } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '获取安装 GitHub App 的链接 — 安装后 Endpoint 可以访问你的仓库,你也可以使用更多功能',
6
- inputSchema: z.object({}),
7
- tags: ['github'],
8
- async execute() {
9
- return executeGithubInstall();
10
- },
11
- });
12
- //# sourceMappingURL=install.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../agent/tools/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,wDAAwD;IACrE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,oBAAoB,EAAE,CAAC;IAChC,CAAC;CACF,CAAC,CAAC"}
@@ -1,18 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubPatchFile } from '../../src/github-bot-handlers.js';
4
- export default defineTool({
5
- description: '通过 Contents API 单文件更新(小改;Bot Installation Token 身份)',
6
- inputSchema: z.object({
7
- repo: z.string().optional().describe('owner/repo'),
8
- path: z.string().describe('仓库内文件路径'),
9
- content: z.string().describe('新文件内容'),
10
- message: z.string().describe('commit message'),
11
- branch: z.string().optional().describe('目标分支,缺省从 Issue/PR 上下文推断'),
12
- }),
13
- tags: ['github'],
14
- async execute(input) {
15
- return executeGithubPatchFile(input);
16
- },
17
- });
18
- //# sourceMappingURL=patch_file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patch_file.js","sourceRoot":"","sources":["../../../agent/tools/patch_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,eAAe,UAAU,CAAqF;IAC5G,WAAW,EAAE,qDAAqD;IAClE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC9C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;KAClE,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubPrepareWorkspace } from '../../src/github-bot-handlers.js';
4
- export default defineTool({
5
- description: 'Clone/fetch 托管工作区并 checkout 到 Issue/PR 对应分支(GitHub App Bot 身份)',
6
- inputSchema: z.object({
7
- repo: z.string().optional().describe('owner/repo,缺省从当前 Issue/PR 频道推断'),
8
- }),
9
- tags: ['github'],
10
- async execute(input) {
11
- return executeGithubPrepareWorkspace(input);
12
- },
13
- });
14
- //# sourceMappingURL=prepare_workspace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prepare_workspace.js","sourceRoot":"","sources":["../../../agent/tools/prepare_workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEjF,eAAe,UAAU,CAAoB;IAC3C,WAAW,EAAE,gEAAgE;IAC7E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;KACvE,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,6BAA6B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubPushBranch } from '../../src/github-bot-handlers.js';
4
- export default defineTool({
5
- description: '在托管工作区 git commit 并 push 到远程分支(需 HITL 确认;Bot 身份)',
6
- inputSchema: z.object({
7
- repo: z.string().optional().describe('owner/repo'),
8
- branch: z.string().optional().describe('分支名,缺省从上下文推断'),
9
- message: z.string().describe('commit message'),
10
- }),
11
- tags: ['github'],
12
- approval: 'always',
13
- async execute(input) {
14
- return executeGithubPushBranch(input);
15
- },
16
- });
17
- //# sourceMappingURL=push_branch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"push_branch.js","sourceRoot":"","sources":["../../../agent/tools/push_branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,eAAe,UAAU,CAAsD;IAC7E,WAAW,EAAE,kDAAkD;IAC/D,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;QACtD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KAC/C,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
@@ -1,15 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubStar } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: 'Star 或取消 Star 一个 GitHub 仓库(使用你绑定的 GitHub 账号,未绑定则用 Endpoint 默认账号)',
6
- inputSchema: z.object({
7
- action: z.enum(['star', 'unstar', 'check']),
8
- repo: z.string().min(1),
9
- }),
10
- tags: ['github'],
11
- async execute(input) {
12
- return executeGithubStar(input);
13
- },
14
- });
15
- //# sourceMappingURL=star.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"star.js","sourceRoot":"","sources":["../../../agent/tools/star.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,eAAe,UAAU,CAAwD;IAC/E,WAAW,EAAE,kEAAkE;IAC/E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACxB,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubSubscribe } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '订阅 GitHub 仓库的 Webhook 事件,事件将推送到当前聊天通道',
6
- inputSchema: z.object({
7
- repo: z.string().min(1),
8
- events: z.string().optional(),
9
- }),
10
- platforms: ['github'],
11
- tags: ['github'],
12
- async execute(input) {
13
- return executeGithubSubscribe(input);
14
- },
15
- });
16
- //# sourceMappingURL=subscribe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../../agent/tools/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,eAAe,UAAU,CAAoC;IAC3D,WAAW,EAAE,uCAAuC;IACpD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC9B,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubSubscriptions } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '查看当前聊天通道的 GitHub 仓库订阅列表',
6
- inputSchema: z.object({}),
7
- platforms: ['github'],
8
- tags: ['github'],
9
- async execute() {
10
- return executeGithubSubscriptions({});
11
- },
12
- });
13
- //# sourceMappingURL=subscriptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../../agent/tools/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAE/E,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,0BAA0B,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubUnbind } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '解除你绑定的 GitHub 账号',
6
- inputSchema: z.object({}),
7
- tags: ['github'],
8
- async execute() {
9
- return executeGithubUnbind({});
10
- },
11
- });
12
- //# sourceMappingURL=unbind.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unbind.js","sourceRoot":"","sources":["../../../agent/tools/unbind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
@@ -1,15 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubUnsubscribe } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '取消订阅 GitHub 仓库的 Webhook 事件',
6
- inputSchema: z.object({
7
- repo: z.string().min(1),
8
- }),
9
- platforms: ['github'],
10
- tags: ['github'],
11
- async execute(input) {
12
- return executeGithubUnsubscribe(input);
13
- },
14
- });
15
- //# sourceMappingURL=unsubscribe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsubscribe.js","sourceRoot":"","sources":["../../../agent/tools/unsubscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,eAAe,UAAU,CAAmB;IAC1C,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACxB,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { executeGithubWhoami } from '../../src/github-tool-handlers.js';
4
- export default defineTool({
5
- description: '查看你绑定的 GitHub 账号信息',
6
- inputSchema: z.object({}),
7
- tags: ['github'],
8
- async execute() {
9
- return executeGithubWhoami({});
10
- },
11
- });
12
- //# sourceMappingURL=whoami.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../agent/tools/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}