@zhin.js/adapter-github 1.1.17 → 1.1.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @zhin.js/adapter-github
2
2
 
3
+ ## 1.1.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 6345a38: feat(adapters): add per-adapter Console pages
8
+
9
+ Every platform adapter now ships a `pages/index` Console page backed by a shared
10
+ `createAdapterConsolePage` component and `createAdapterConsoleRpc` server helper:
11
+
12
+ - See running endpoints, test connectivity, and manage
13
+ `plugins.<adapter>.endpoints` (add/remove writes `.env` references) from the
14
+ Console instead of chat commands.
15
+ - Surface LoginAssist pending tasks (QR / slider / SMS / device) so ICQQ login no
16
+ longer requires the terminal.
17
+ - QQ moves its QR binding flow (`qq endpoint add`) into Console actions with
18
+ public/private selection.
19
+ - Pages are permission-gated by `<adapter>:read`; writes need `<adapter>:write`.
20
+
21
+ - Updated dependencies [6345a38]
22
+ - Updated dependencies [ff3efe7]
23
+ - Updated dependencies [c58c589]
24
+ - @zhin.js/adapter@1.1.25
25
+ - @zhin.js/client@1.1.21
26
+ - @zhin.js/core@1.1.53
27
+ - @zhin.js/im-contract@1.1.9
28
+ - @zhin.js/tool@1.1.12
29
+
3
30
  ## 1.1.17
4
31
 
5
32
  ### Patch Changes
package/README.md CHANGED
@@ -97,6 +97,16 @@ github:
97
97
  - 入站:`httpHostToken` POST → `Endpoint.emit(...)`
98
98
  - 出站:`send({ conversation, payload })`
99
99
 
100
+ ## Console 页面
101
+
102
+ 启动后打开 Console 的「GitHub」页(地址 `/github`),可以:
103
+
104
+ - 查看运行中的连接、点「测试连接」做连通性诊断;
105
+ - 增删 `plugins.github.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
106
+ - 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
107
+
108
+ 读取需要 `github:read`,写操作需要 `github:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `github endpoint add`。
109
+
100
110
  ## 故障排查
101
111
 
102
112
  | 现象 | 排查 |
@@ -0,0 +1,12 @@
1
+ /**
2
+ * GitHub Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+ export declare const githubConsoleSpec: {
6
+ readonly adapterKey: "github";
7
+ readonly adapterDisplayName: "GitHub";
8
+ readonly fields: readonly AdapterConsoleField[];
9
+ readonly docsUrl: "https://zhin.js.org/adapters/github";
10
+ readonly readPermission: "github:read";
11
+ readonly writePermission: "github:write";
12
+ };
@@ -0,0 +1,12 @@
1
+ export const githubConsoleSpec = {
2
+ adapterKey: 'github',
3
+ adapterDisplayName: 'GitHub',
4
+ fields: [
5
+ { key: 'app_id', required: true, env: true, description: 'GitHub App ID' },
6
+ { key: 'private_key', required: true, secret: true, description: 'PEM 文件路径(推荐,如 ./data/xxx.pem)或 PEM 内容', descriptionI18n: { en: 'PEM file path (recommended) or PEM content' } },
7
+ { key: 'webhook_secret', env: true, description: 'webhook 签名密钥(不配则 API-only)', descriptionI18n: { en: 'Webhook signing secret (API-only when omitted)' } },
8
+ ],
9
+ docsUrl: 'https://zhin.js.org/adapters/github',
10
+ readPermission: 'github:read',
11
+ writePermission: 'github:write',
12
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GitHub Console RPC:运行状态 + endpoint 增删(原 `github endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { type AdapterConsoleResources } from 'zhin.js/adapter';
7
+ import type { PluginConsoleRpc } from 'zhin.js';
8
+ export declare function createGithubConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
package/lib/console.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * GitHub Console RPC:运行状态 + endpoint 增删(原 `github endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { createAdapterConsoleRpc } from 'zhin.js/adapter';
7
+ import { githubRuntimeStateToken } from './github-runtime-state.js';
8
+ import { githubConsoleSpec } from './console-spec.js';
9
+ export function createGithubConsoleRpc(resources, getConfig) {
10
+ const state = resources.use(githubRuntimeStateToken);
11
+ return createAdapterConsoleRpc({
12
+ ...githubConsoleSpec,
13
+ running: () => state.endpoints.values(),
14
+ getConfig,
15
+ }, resources);
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-github",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "Zhin.js GitHub adapter for Plugin Runtime (App auth + webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -39,25 +39,28 @@
39
39
  "directory": "plugins/adapters/github"
40
40
  },
41
41
  "dependencies": {
42
- "@zhin.js/adapter": "1.1.24",
42
+ "@zhin.js/adapter": "1.1.25",
43
43
  "@zhin.js/agent-feature": "1.1.10",
44
- "@zhin.js/core": "1.1.52",
44
+ "@zhin.js/client": "1.1.21",
45
+ "@zhin.js/console-contract": "1.1.3",
46
+ "@zhin.js/core": "1.1.53",
45
47
  "@zhin.js/feature-kit": "1.1.9",
46
48
  "@zhin.js/host-http": "1.1.11",
47
- "@zhin.js/im-contract": "1.1.8",
49
+ "@zhin.js/im-contract": "1.1.9",
48
50
  "@zhin.js/logger": "1.1.2",
51
+ "@zhin.js/page": "1.1.10",
49
52
  "@zhin.js/skill": "1.1.10",
50
- "@zhin.js/tool": "1.1.11"
53
+ "@zhin.js/tool": "1.1.12"
51
54
  },
52
55
  "peerDependencies": {
53
56
  "zod": "^4.0.0",
54
- "@zhin.js/adapter": "^1.1.24",
55
- "@zhin.js/agent": "^1.1.43",
57
+ "@zhin.js/adapter": "^1.1.25",
58
+ "@zhin.js/agent": "^1.1.44",
56
59
  "@zhin.js/command": "^1.1.11",
57
- "@zhin.js/core": "^1.1.52",
60
+ "@zhin.js/core": "^1.1.53",
58
61
  "@zhin.js/host-http": "^1.1.11",
59
62
  "@zhin.js/prompt-section": "^1.1.9",
60
- "zhin.js": "^1.1.17"
63
+ "zhin.js": "^1.1.18"
61
64
  },
62
65
  "peerDependenciesMeta": {
63
66
  "@zhin.js/agent": {
@@ -81,13 +84,14 @@
81
84
  "typescript": "^6.0.3",
82
85
  "vitest": "^4.1.10",
83
86
  "zod": "^4.4.3",
84
- "@zhin.js/agent": "1.1.43",
87
+ "@zhin.js/agent": "1.1.44",
85
88
  "@zhin.js/prompt-section": "1.1.9",
86
- "zhin.js": "1.1.17"
89
+ "zhin.js": "1.1.18"
87
90
  },
88
91
  "files": [
89
92
  "adapters",
90
93
  "commands",
94
+ "pages",
91
95
  "plugin.js",
92
96
  "schema.json",
93
97
  "src",
@@ -130,6 +134,10 @@
130
134
  {
131
135
  "package": "@zhin.js/agent-feature",
132
136
  "api": "^1.0.0"
137
+ },
138
+ {
139
+ "package": "@zhin.js/page",
140
+ "api": "^1.0.0"
133
141
  }
134
142
  ],
135
143
  "plugins": []
@@ -0,0 +1,15 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { definePage } from '@zhin.js/console-contract';
3
+ import { createAdapterConsolePage } from '@zhin.js/client';
4
+ export const meta = definePage({
5
+ title: 'GitHub',
6
+ titleI18n: { en: 'GitHub' },
7
+ icon: 'Github',
8
+ order: 63,
9
+ requiredPermissions: ['github:read'],
10
+ });
11
+ /**
12
+ * Convention page: `pages/index/index.ts` → `/github`(插件路径)。
13
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
14
+ */
15
+ export default createAdapterConsolePage('github');
@@ -0,0 +1,16 @@
1
+ import { definePage } from '@zhin.js/console-contract';
2
+ import { createAdapterConsolePage } from '@zhin.js/client';
3
+
4
+ export const meta = definePage({
5
+ title: 'GitHub',
6
+ titleI18n: { en: 'GitHub' },
7
+ icon: 'Github',
8
+ order: 63,
9
+ requiredPermissions: ['github:read'],
10
+ });
11
+
12
+ /**
13
+ * Convention page: `pages/index/index.ts` → `/github`(插件路径)。
14
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
15
+ */
16
+ export default createAdapterConsolePage('github');
package/plugin.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { createEndpointRuntimeState } from 'zhin.js/adapter';
3
- import { definePlugin, databaseHostToken } from 'zhin.js';
3
+ import { definePlugin, databaseHostToken, pluginConsoleRpcToken } from 'zhin.js';
4
4
  import { githubRuntimeStateToken } from "./lib/github-runtime-state.js";
5
5
  import { defineGithubOauthUsersTable } from "./lib/oauth-users.js";
6
+ import { createGithubConsoleRpc } from "./lib/console.js";
6
7
  /**
7
8
  * github_subscriptions — repo event subscriptions per chat channel
8
9
  * (used by github_subscriptions agent tool; schema is registered through DatabaseHost).
@@ -29,6 +30,7 @@ export default definePlugin({
29
30
  setup(context) {
30
31
  // 运行中 endpoint 注册表(github endpoint list 的"运行中"数据源)
31
32
  context.resources.provide(githubRuntimeStateToken, createEndpointRuntimeState());
33
+ context.resources.provide(pluginConsoleRpcToken, createGithubConsoleRpc(context.resources, () => context.config.get()));
32
34
  if (context.resources.has(databaseHostToken)) {
33
35
  const host = context.resources.use(databaseHostToken);
34
36
  defineGithubOauthUsersTable(host);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * GitHub Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+
6
+ export const githubConsoleSpec = {
7
+ adapterKey: 'github',
8
+ adapterDisplayName: 'GitHub',
9
+ fields: [
10
+ { key: 'app_id', required: true, env: true, description: 'GitHub App ID' },
11
+ { key: 'private_key', required: true, secret: true, description: 'PEM 文件路径(推荐,如 ./data/xxx.pem)或 PEM 内容', descriptionI18n: { en: 'PEM file path (recommended) or PEM content' } },
12
+ { key: 'webhook_secret', env: true, description: 'webhook 签名密钥(不配则 API-only)', descriptionI18n: { en: 'Webhook signing secret (API-only when omitted)' } },
13
+ ] as readonly AdapterConsoleField[],
14
+ docsUrl: 'https://zhin.js.org/adapters/github',
15
+ readPermission: 'github:read',
16
+ writePermission: 'github:write',
17
+ } as const;
package/src/console.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * GitHub Console RPC:运行状态 + endpoint 增删(原 `github endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { createAdapterConsoleRpc, type AdapterConsoleResources } from 'zhin.js/adapter';
7
+ import type { PluginConsoleRpc } from 'zhin.js';
8
+ import { githubRuntimeStateToken } from './github-runtime-state.js';
9
+ import { githubConsoleSpec } from './console-spec.js';
10
+
11
+ export function createGithubConsoleRpc(
12
+ resources: AdapterConsoleResources,
13
+ getConfig: () => unknown,
14
+ ): PluginConsoleRpc {
15
+ const state = resources.use(githubRuntimeStateToken);
16
+ return createAdapterConsoleRpc({
17
+ ...githubConsoleSpec,
18
+ running: () => state.endpoints.values(),
19
+ getConfig,
20
+ }, resources);
21
+ }