@zhin.js/adapter-github 6.0.0 → 6.0.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +18 -2
  3. package/adapters/github.js +0 -7
  4. package/adapters/github.ts +0 -7
  5. package/agent/prompt-sections/platform.ts +16 -0
  6. package/agent/tools/bind.ts +4 -3
  7. package/agent/tools/create_pr.ts +3 -2
  8. package/agent/tools/install.ts +4 -3
  9. package/agent/tools/patch_file.ts +3 -2
  10. package/agent/tools/prepare_workspace.ts +3 -2
  11. package/agent/tools/push_branch.ts +3 -2
  12. package/agent/tools/star.ts +3 -2
  13. package/agent/tools/subscribe.ts +3 -3
  14. package/agent/tools/subscriptions.ts +4 -4
  15. package/agent/tools/unbind.ts +4 -3
  16. package/agent/tools/unsubscribe.ts +3 -3
  17. package/agent/tools/whoami.ts +4 -3
  18. package/lib/client.d.ts +36 -0
  19. package/lib/client.js +47 -0
  20. package/lib/endpoint.d.ts +10 -24
  21. package/lib/endpoint.js +35 -65
  22. package/lib/github-bot-handlers.d.ts +5 -4
  23. package/lib/github-bot-handlers.js +12 -13
  24. package/lib/github-endpoint-commands.d.ts +1 -1
  25. package/lib/github-tool-handlers.d.ts +9 -8
  26. package/lib/github-tool-handlers.js +26 -33
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.js +1 -1
  29. package/lib/protocol.d.ts +1 -1
  30. package/lib/protocol.js +1 -1
  31. package/lib/webhook.d.ts +1 -0
  32. package/lib/webhook.js +1 -0
  33. package/package.json +19 -13
  34. package/plugin.js +0 -17
  35. package/src/client.ts +65 -0
  36. package/src/endpoint.ts +36 -75
  37. package/src/github-bot-handlers.ts +13 -9
  38. package/src/github-tool-handlers.ts +27 -32
  39. package/src/index.ts +1 -9
  40. package/src/protocol.ts +1 -1
  41. package/src/webhook.ts +5 -0
  42. package/lib/agent-prompt.d.ts +0 -2
  43. package/lib/agent-prompt.js +0 -84
  44. package/lib/github-agent-deps.d.ts +0 -47
  45. package/lib/github-agent-deps.js +0 -43
  46. package/src/agent-prompt.ts +0 -101
  47. package/src/github-agent-deps.ts +0 -82
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @zhin.js/adapter-github
2
2
 
3
+ ## 6.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 54bfd6b: Introduce Prompt Sections as a generation-owned Plugin Runtime Feature. Projects can declare typed context under `agent/prompt-sections/`, select interactive or scheduled profiles and IM platforms, and govern presentation order separately from required/preferred/opportunistic budget retention. In-flight turns remain pinned to their original generation across hot reloads, required policy fails explicitly when it cannot fit, duplicate identities are rejected, and the previous mutable Agent-local discovery and platform contributor APIs are removed. ICQQ and GitHub platform guidance now use the same Feature instead of a module-global registry.
8
+
9
+ Expose a content-free Prompt Section catalog through Console introspection, including owner, source, generation, profiles, and budget policy without disclosing prompt text. New AI projects mount the Feature automatically, and the full-bot example plus Chinese and English product documentation demonstrate the supported configuration.
10
+
11
+ - 1fc78bc: Unify native platform Client access behind the literal `adapter` discriminant. Handlers infer both native events and Clients, while command, inbound/outbound middleware, and both Agent tool authoring surfaces expose the exact operation-scoped Client through a lazy `$client` getter. Definitions without `adapter` keep `$client` typed as `unknown`, and runtime dispatch rejects adapter mismatches before resolving the Client. Bundled platform tools now use this single path instead of model-provided endpoint ids and adapter-specific dependency wrappers. Every adapter registers one Client/EventMap contract, and protocol adapters including NapCat, Milky, OneBot and Satori now produce transport-independent Client objects rather than letting Endpoint instances impersonate Clients.
12
+ - Updated dependencies [e9c6a73]
13
+ - Updated dependencies [4e8117c]
14
+ - Updated dependencies [902fa35]
15
+ - Updated dependencies [54bfd6b]
16
+ - Updated dependencies [12025ee]
17
+ - Updated dependencies [09b14d6]
18
+ - Updated dependencies [1fc78bc]
19
+ - @zhin.js/agent@1.1.16
20
+ - @zhin.js/adapter@1.2.1
21
+ - @zhin.js/prompt-section@0.0.1
22
+ - @zhin.js/core@1.5.14
23
+ - @zhin.js/host-http@1.0.13
24
+ - @zhin.js/command@1.0.16
25
+ - @zhin.js/logger@1.0.77
26
+ - zhin.js@6.0.14
27
+ - @zhin.js/feature-kit@1.0.13
28
+
3
29
  ## 6.0.0
4
30
 
5
31
  ### Patch Changes
package/README.md CHANGED
@@ -5,7 +5,7 @@ GitHub Plugin Runtime 适配器 — Issue/PR 评论区即聊天通道,GitHub A
5
5
  ## 功能特性
6
6
 
7
7
  - **聊天通道**:Issue/PR 评论区映射为群聊,支持收发消息
8
- - **Webhook 入站**:HMAC-SHA256 验签 → `messageGatewayToken`
8
+ - **Webhook 入站**:HMAC-SHA256 验签 → `Endpoint.emit(...)`
9
9
  - **出站**:`send({ conversation, payload })` → Issue/PR comment(`conversation.id` 为 channel ID)
10
10
  - **GitHub App 认证**:JWT → Installation Token
11
11
  - **Agent 工具**:`agent/` 下 star/bind/subscribe/workspace 等保留
@@ -18,6 +18,13 @@ pnpm add @zhin.js/adapter-github
18
18
 
19
19
  Webhook 需要 Root 提供 `@zhin.js/host-http`(`zhin runtime start` 默认装配)。
20
20
 
21
+ ## 前置条件
22
+
23
+ 1. 创建 GitHub App,记录 App ID、私钥与 Webhook Secret。
24
+ 2. 授予目标仓库所需的 Issues、Pull requests 与 Contents 权限。
25
+ 3. 将 Webhook 指向公网 HTTPS 的 `/github/webhook`,并订阅 Issue、PR 与评论事件。
26
+ 4. 把 App 安装到目标仓库;仓库 Workroom 使用稳定的 `owner/repo` 地址匹配。
27
+
21
28
  ## 配置(Plugin Runtime)
22
29
 
23
30
  ```yaml
@@ -84,9 +91,18 @@ plugins:
84
91
  | `src/protocol.ts` | 协议纯函数(channel / payload) |
85
92
  | `src/gh-client.ts` | GitHub API 客户端 |
86
93
 
87
- - 入站:`httpHostToken` POST → `messageGatewayToken.receive`
94
+ - 入站:`httpHostToken` POST → `Endpoint.emit(...)`
88
95
  - 出站:`send({ conversation, payload })`
89
96
 
97
+ ## 故障排查
98
+
99
+ | 现象 | 排查 |
100
+ | --- | --- |
101
+ | Webhook 401 | 检查 Secret、`X-Hub-Signature-256` 与原始请求体 |
102
+ | App 鉴权失败 | 检查 App ID、私钥 PEM/文件路径与服务器时钟 |
103
+ | 评论没有进入 Workroom | 先查 Endpoint 收件箱,再核对 Catalog 的 Endpoint 与 `owner/repo` |
104
+ | 能收事件但不能回复 | 检查 installation 与仓库权限;PAT MCP 不替代 App 出站 |
105
+
90
106
  ## License
91
107
 
92
108
  MIT
@@ -4,7 +4,6 @@
4
4
  * Implementation lives under `src/` (endpoint / webhook / oauth / protocol).
5
5
  */
6
6
  import { defineAdapter } from 'zhin.js/adapter';
7
- import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
8
7
  import { httpHostToken } from '@zhin.js/host-http';
9
8
  import { databaseHostToken, } from 'zhin.js';
10
9
  import { GithubEndpoint } from "../lib/endpoint.js";
@@ -28,8 +27,6 @@ export default defineAdapter({
28
27
  },
29
28
  create(context) {
30
29
  const config = resolveGithubConfig(context.config);
31
- const gateway = context.use(messageGatewayToken);
32
- const sideEvents = context.use(sideEventGatewayToken);
33
30
  const database = optionalDatabase(context);
34
31
  // 注册到插件运行时状态(github.endpoint list 的"运行中"数据源)
35
32
  context.use(githubRuntimeStateToken).endpoints.set(config.id, {
@@ -39,8 +36,6 @@ export default defineAdapter({
39
36
  if (config.webhookSecret) {
40
37
  return new GithubEndpoint({
41
38
  id: context.id,
42
- gateway,
43
- sideEvents,
44
39
  http: context.use(httpHostToken),
45
40
  database,
46
41
  config,
@@ -49,8 +44,6 @@ export default defineAdapter({
49
44
  // API-only: Issue/PR send + agent tools without webhook.
50
45
  return new GithubEndpoint({
51
46
  id: context.id,
52
- gateway,
53
- sideEvents,
54
47
  database,
55
48
  config,
56
49
  });
@@ -3,7 +3,6 @@
3
3
  * Implementation lives under `src/` (endpoint / webhook / oauth / protocol).
4
4
  */
5
5
  import { defineAdapter, type AdapterContext } from 'zhin.js/adapter';
6
- import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
7
6
  import { httpHostToken } from '@zhin.js/host-http';
8
7
  import {
9
8
  databaseHostToken,
@@ -36,8 +35,6 @@ export default defineAdapter<GithubAdapterConfig>({
36
35
  },
37
36
  create(context) {
38
37
  const config = resolveGithubConfig(context.config);
39
- const gateway = context.use(messageGatewayToken);
40
- const sideEvents = context.use(sideEventGatewayToken);
41
38
  const database = optionalDatabase(context);
42
39
  // 注册到插件运行时状态(github.endpoint list 的"运行中"数据源)
43
40
  context.use(githubRuntimeStateToken).endpoints.set(config.id, {
@@ -47,8 +44,6 @@ export default defineAdapter<GithubAdapterConfig>({
47
44
  if (config.webhookSecret) {
48
45
  return new GithubEndpoint({
49
46
  id: context.id,
50
- gateway,
51
- sideEvents,
52
47
  http: context.use(httpHostToken),
53
48
  database,
54
49
  config,
@@ -57,8 +52,6 @@ export default defineAdapter<GithubAdapterConfig>({
57
52
  // API-only: Issue/PR send + agent tools without webhook.
58
53
  return new GithubEndpoint({
59
54
  id: context.id,
60
- gateway,
61
- sideEvents,
62
55
  database,
63
56
  config,
64
57
  });
@@ -0,0 +1,16 @@
1
+ import { defineAgentPromptSection } from '@zhin.js/prompt-section';
2
+
3
+ export default defineAgentPromptSection({
4
+ title: 'GitHub',
5
+ content: [
6
+ 'On GitHub, discuss Issues and Pull Requests in their current conversation context.',
7
+ 'Use github_* tools for Bot write operations; do not use mcp_github_* writes that act as a human PAT.',
8
+ 'Use a workspace and branch for multi-file changes, then report the resulting Pull Request or branch.',
9
+ ].join('\n'),
10
+ layer: 'tools',
11
+ order: 70,
12
+ retention: 'preferred',
13
+ maxChars: 1200,
14
+ profiles: ['interactive'],
15
+ platforms: ['github'],
16
+ });
@@ -2,11 +2,12 @@ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { executeGithubBind } from '../../src/github-tool-handlers.js';
4
4
 
5
- export default defineAgentTool({
5
+ export default defineAgentTool<{}>({
6
6
  description: '绑定你的 GitHub 账号 — 使用 Device Flow 授权,无需输入密码',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({}),
8
9
  tags: ['github'],
9
- async execute() {
10
- return executeGithubBind({});
10
+ async execute(input, context) {
11
+ return executeGithubBind({}, context.$client, context.message);
11
12
  },
12
13
  });
@@ -4,6 +4,7 @@ import { executeGithubCreatePr } from '../../src/github-bot-handlers.js';
4
4
 
5
5
  export default defineAgentTool<{ repo?: string; title: string; body?: string; head?: string; base?: string }>({
6
6
  description: '以 GitHub App Bot 身份创建 Pull Request(需 HITL 确认;Issue 场景常用)',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({
8
9
  repo: z.string().optional().describe('owner/repo'),
9
10
  title: z.string().describe('PR 标题'),
@@ -13,7 +14,7 @@ export default defineAgentTool<{ repo?: string; title: string; body?: string; he
13
14
  }),
14
15
  tags: ['github'],
15
16
  approval: 'always',
16
- async execute(input) {
17
- return executeGithubCreatePr(input);
17
+ async execute(input, context) {
18
+ return executeGithubCreatePr(input, context.$client, context.message);
18
19
  },
19
20
  });
@@ -2,11 +2,12 @@ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { executeGithubInstall } from '../../src/github-tool-handlers.js';
4
4
 
5
- export default defineAgentTool({
5
+ export default defineAgentTool<{}>({
6
6
  description: '获取安装 GitHub App 的链接 — 安装后 Endpoint 可以访问你的仓库,你也可以使用更多功能',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({}),
8
9
  tags: ['github'],
9
- async execute() {
10
- return executeGithubInstall();
10
+ async execute(input, context) {
11
+ return executeGithubInstall(context.$client);
11
12
  },
12
13
  });
@@ -4,6 +4,7 @@ import { executeGithubPatchFile } from '../../src/github-bot-handlers.js';
4
4
 
5
5
  export default defineAgentTool<{ repo?: string; path: string; content: string; message: string; branch?: string }>({
6
6
  description: '通过 Contents API 单文件更新(小改;Bot Installation Token 身份)',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({
8
9
  repo: z.string().optional().describe('owner/repo'),
9
10
  path: z.string().describe('仓库内文件路径'),
@@ -12,7 +13,7 @@ export default defineAgentTool<{ repo?: string; path: string; content: string; m
12
13
  branch: z.string().optional().describe('目标分支,缺省从 Issue/PR 上下文推断'),
13
14
  }),
14
15
  tags: ['github'],
15
- async execute(input) {
16
- return executeGithubPatchFile(input);
16
+ async execute(input, context) {
17
+ return executeGithubPatchFile(input, context.$client, context.message);
17
18
  },
18
19
  });
@@ -4,11 +4,12 @@ import { executeGithubPrepareWorkspace } from '../../src/github-bot-handlers.js'
4
4
 
5
5
  export default defineAgentTool<{ repo?: string }>({
6
6
  description: 'Clone/fetch 托管工作区并 checkout 到 Issue/PR 对应分支(GitHub App Bot 身份)',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({
8
9
  repo: z.string().optional().describe('owner/repo,缺省从当前 Issue/PR 频道推断'),
9
10
  }),
10
11
  tags: ['github'],
11
- async execute(input) {
12
- return executeGithubPrepareWorkspace(input);
12
+ async execute(input, context) {
13
+ return executeGithubPrepareWorkspace(input, context.$client, context.message);
13
14
  },
14
15
  });
@@ -4,6 +4,7 @@ import { executeGithubPushBranch } from '../../src/github-bot-handlers.js';
4
4
 
5
5
  export default defineAgentTool<{ repo?: string; branch?: string; message: string }>({
6
6
  description: '在托管工作区 git commit 并 push 到远程分支(需 HITL 确认;Bot 身份)',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({
8
9
  repo: z.string().optional().describe('owner/repo'),
9
10
  branch: z.string().optional().describe('分支名,缺省从上下文推断'),
@@ -11,7 +12,7 @@ export default defineAgentTool<{ repo?: string; branch?: string; message: string
11
12
  }),
12
13
  tags: ['github'],
13
14
  approval: 'always',
14
- async execute(input) {
15
- return executeGithubPushBranch(input);
15
+ async execute(input, context) {
16
+ return executeGithubPushBranch(input, context.$client, context.message);
16
17
  },
17
18
  });
@@ -4,12 +4,13 @@ import { executeGithubStar } from '../../src/github-tool-handlers.js';
4
4
 
5
5
  export default defineAgentTool<{ action: 'star' | 'unstar' | 'check'; repo: string }>({
6
6
  description: 'Star 或取消 Star 一个 GitHub 仓库(使用你绑定的 GitHub 账号,未绑定则用 Endpoint 默认账号)',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({
8
9
  action: z.enum(['star', 'unstar', 'check']),
9
10
  repo: z.string().min(1),
10
11
  }),
11
12
  tags: ['github'],
12
- async execute(input) {
13
- return executeGithubStar(input);
13
+ async execute(input, context) {
14
+ return executeGithubStar(input, context.$client, context.message);
14
15
  },
15
16
  });
@@ -8,9 +8,9 @@ export default defineAgentTool<{ repo: string; events?: string }>({
8
8
  repo: z.string().min(1),
9
9
  events: z.string().optional(),
10
10
  }),
11
- platforms: ['github'],
11
+ adapter: 'github',
12
12
  tags: ['github'],
13
- async execute(input) {
14
- return executeGithubSubscribe(input);
13
+ async execute(input, context) {
14
+ return executeGithubSubscribe(input, context.$client, context.message);
15
15
  },
16
16
  });
@@ -2,12 +2,12 @@ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { executeGithubSubscriptions } from '../../src/github-tool-handlers.js';
4
4
 
5
- export default defineAgentTool({
5
+ export default defineAgentTool<{}>({
6
6
  description: '查看当前聊天通道的 GitHub 仓库订阅列表',
7
7
  inputSchema: z.object({}),
8
- platforms: ['github'],
8
+ adapter: 'github',
9
9
  tags: ['github'],
10
- async execute() {
11
- return executeGithubSubscriptions({});
10
+ async execute(input, context) {
11
+ return executeGithubSubscriptions({}, context.$client, context.message);
12
12
  },
13
13
  });
@@ -2,11 +2,12 @@ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { executeGithubUnbind } from '../../src/github-tool-handlers.js';
4
4
 
5
- export default defineAgentTool({
5
+ export default defineAgentTool<{}>({
6
6
  description: '解除你绑定的 GitHub 账号',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({}),
8
9
  tags: ['github'],
9
- async execute() {
10
- return executeGithubUnbind({});
10
+ async execute(input, context) {
11
+ return executeGithubUnbind({}, context.$client, context.message);
11
12
  },
12
13
  });
@@ -7,9 +7,9 @@ export default defineAgentTool<{ repo: string }>({
7
7
  inputSchema: z.object({
8
8
  repo: z.string().min(1),
9
9
  }),
10
- platforms: ['github'],
10
+ adapter: 'github',
11
11
  tags: ['github'],
12
- async execute(input) {
13
- return executeGithubUnsubscribe(input);
12
+ async execute(input, context) {
13
+ return executeGithubUnsubscribe(input, context.$client, context.message);
14
14
  },
15
15
  });
@@ -2,11 +2,12 @@ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { executeGithubWhoami } from '../../src/github-tool-handlers.js';
4
4
 
5
- export default defineAgentTool({
5
+ export default defineAgentTool<{}>({
6
6
  description: '查看你绑定的 GitHub 账号信息',
7
+ adapter: 'github',
7
8
  inputSchema: z.object({}),
8
9
  tags: ['github'],
9
- async execute() {
10
- return executeGithubWhoami({});
10
+ async execute(input, context) {
11
+ return executeGithubWhoami({}, context.$client, context.message);
11
12
  },
12
13
  });
@@ -0,0 +1,36 @@
1
+ import type { PluginDatabaseHost } from 'zhin.js';
2
+ import { GhClient } from './gh-client.js';
3
+ import type { ResolvedGithubConfig } from './protocol.js';
4
+ import { WorkspaceManager } from './workspace-manager.js';
5
+ /** GitHub SDK surface exposed to plugin handlers and Agent tools. */
6
+ export declare class GithubClient {
7
+ #private;
8
+ readonly name: string;
9
+ readonly api: GhClient;
10
+ readonly config: ResolvedGithubConfig;
11
+ readonly database?: PluginDatabaseHost | undefined;
12
+ constructor(name: string, api: GhClient, config: ResolvedGithubConfig, database?: PluginDatabaseHost | undefined);
13
+ getUserOrDefaultApi(platform?: string, platformUid?: string): Promise<GhClient>;
14
+ get clientId(): string | null;
15
+ get host(): string | undefined;
16
+ get appSlug(): string | null;
17
+ get installations(): {
18
+ id: number;
19
+ account: {
20
+ login: string;
21
+ type: string;
22
+ };
23
+ target_type: string;
24
+ }[];
25
+ get workspaceManager(): WorkspaceManager;
26
+ }
27
+ export type GithubClientEventMap = Record<string, unknown>;
28
+ declare module '@zhin.js/feature-kit' {
29
+ interface AdapterClientRegistry {
30
+ readonly github: {
31
+ readonly client: GithubClient;
32
+ readonly events: GithubClientEventMap;
33
+ };
34
+ }
35
+ }
36
+ export declare const githubClient: import("@zhin.js/adapter").EndpointClientToken<GithubClient, GithubClientEventMap>;
package/lib/client.js ADDED
@@ -0,0 +1,47 @@
1
+ import path from 'node:path';
2
+ import { defineEndpointClient } from 'zhin.js/adapter';
3
+ import { lookupGithubOauthAccessToken } from './oauth-users.js';
4
+ import { WorkspaceManager } from './workspace-manager.js';
5
+ /** GitHub SDK surface exposed to plugin handlers and Agent tools. */
6
+ export class GithubClient {
7
+ name;
8
+ api;
9
+ config;
10
+ database;
11
+ #workspaceManager;
12
+ constructor(name, api, config, database) {
13
+ this.name = name;
14
+ this.api = api;
15
+ this.config = config;
16
+ this.database = database;
17
+ }
18
+ async getUserOrDefaultApi(platform, platformUid) {
19
+ if (platform && platformUid) {
20
+ const token = await lookupGithubOauthAccessToken(this.database, platform, platformUid);
21
+ if (token)
22
+ return this.api.withToken(token);
23
+ }
24
+ return this.api;
25
+ }
26
+ get clientId() {
27
+ return this.api.clientId || null;
28
+ }
29
+ get host() {
30
+ return this.config.host;
31
+ }
32
+ get appSlug() {
33
+ return this.api.appSlug || null;
34
+ }
35
+ get installations() {
36
+ return this.api.installations || [];
37
+ }
38
+ get workspaceManager() {
39
+ if (!this.#workspaceManager) {
40
+ const root = this.config.workspaceRoot
41
+ ?? path.join(process.cwd(), 'data', 'github-workspaces');
42
+ this.#workspaceManager = new WorkspaceManager(this.api, root);
43
+ }
44
+ return this.#workspaceManager;
45
+ }
46
+ }
47
+ export const githubClient = defineEndpointClient('github');
package/lib/endpoint.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import type { EndpointInstance, EndpointSendRequest } from 'zhin.js/adapter';
2
- import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
1
+ import { Endpoint } from 'zhin.js/adapter';
2
+ /**
3
+ * GithubEndpoint — lifecycle, outbound send, inbound admit.
4
+ */
5
+ import { type EndpointSendRequest } from 'zhin.js/adapter';
3
6
  import type { HttpHost } from '@zhin.js/host-http';
4
7
  import type { CapabilityId, PluginDatabaseHost } from 'zhin.js';
5
8
  import { GhClient } from './gh-client.js';
6
9
  import { type GithubInboundComment, type ResolvedGithubConfig } from './protocol.js';
7
- import { WorkspaceManager } from './workspace-manager.js';
10
+ import { GithubClient } from './client.js';
8
11
  export interface GithubEndpointOptions {
9
12
  readonly id: CapabilityId;
10
- readonly gateway: MessageGateway;
11
- readonly sideEvents?: SideEventGateway;
12
13
  readonly http?: HttpHost;
13
14
  readonly database?: PluginDatabaseHost;
14
15
  readonly config: ResolvedGithubConfig;
@@ -18,27 +19,11 @@ export interface GithubEndpointOptions {
18
19
  * GitHub 是代码协作面(issue/PR),无好友/群/频道等 IM 社交概念,
19
20
  * 不适用 EndpointManagement 语义端口;本 endpoint 不暴露该端口。
20
21
  */
21
- export declare class GithubEndpoint implements EndpointInstance {
22
+ export declare class GithubEndpoint extends Endpoint<GithubClient> {
22
23
  #private;
23
- readonly gh: GhClient;
24
- readonly config: ResolvedGithubConfig;
25
- readonly name: string;
24
+ readonly client: GithubClient;
26
25
  constructor(options: GithubEndpointOptions);
27
- getAPI(): GhClient;
28
- getUserOrDefaultAPI(platform?: string, platformUid?: string): Promise<GhClient | null>;
29
- getClientId(): string | null;
30
- getHost(): string | undefined;
31
- getAppSlug(): string | null;
32
- getInstallations(): {
33
- id: number;
34
- account: {
35
- login: string;
36
- type: string;
37
- };
38
- target_type: string;
39
- }[];
40
- getWorkspaceManager(): WorkspaceManager;
41
- getDatabase(): PluginDatabaseHost | undefined;
26
+ get config(): ResolvedGithubConfig;
42
27
  start(): Promise<void>;
43
28
  open(): void;
44
29
  close(): void;
@@ -46,5 +31,6 @@ export declare class GithubEndpoint implements EndpointInstance {
46
31
  send({ conversation, payload }: EndpointSendRequest): Promise<string>;
47
32
  /** Test / internal: admit a parsed comment when open. */
48
33
  admit(comment: GithubInboundComment): void;
34
+ admitPlatform(name: string, event: unknown): void;
49
35
  }
50
36
  export declare function defaultCreateClient(config: ResolvedGithubConfig): GhClient;