@zhin.js/adapter-wecom 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-wecom
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
@@ -102,6 +102,16 @@ wecom:
102
102
 
103
103
  Access Token 在过期前 5 分钟自动刷新。
104
104
 
105
+ ## Console 页面
106
+
107
+ 启动后打开 Console 的「企业微信」页(地址 `/wecom`),可以:
108
+
109
+ - 查看运行中的连接、点「测试连接」做连通性诊断;
110
+ - 增删 `plugins.wecom.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
111
+ - 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
112
+
113
+ 读取需要 `wecom:read`,写操作需要 `wecom:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `wecom endpoint add`。
114
+
105
115
  ## 故障排查
106
116
 
107
117
  | 现象 | 排查 |
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 企业微信 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+ export declare const wecomConsoleSpec: {
6
+ readonly adapterKey: "wecom";
7
+ readonly adapterDisplayName: "企业微信";
8
+ readonly fields: readonly AdapterConsoleField[];
9
+ readonly docsUrl: "https://zhin.js.org/adapters/wecom";
10
+ readonly readPermission: "wecom:read";
11
+ readonly writePermission: "wecom:write";
12
+ };
@@ -0,0 +1,13 @@
1
+ export const wecomConsoleSpec = {
2
+ adapterKey: 'wecom',
3
+ adapterDisplayName: '企业微信',
4
+ fields: [
5
+ { key: 'corpId', required: true, env: true, description: '企业 corpId', descriptionI18n: { en: 'WeCom corporation ID' } },
6
+ { key: 'agentSecret', required: true, env: true, description: '应用 secret', descriptionI18n: { en: 'Application secret' } },
7
+ { key: 'token', required: true, env: true, description: '回调 token', descriptionI18n: { en: 'Callback token' } },
8
+ { key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key', descriptionI18n: { en: 'Callback encryption key' } },
9
+ ],
10
+ docsUrl: 'https://zhin.js.org/adapters/wecom',
11
+ readPermission: 'wecom:read',
12
+ writePermission: 'wecom:write',
13
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 企业微信 Console RPC:运行状态 + endpoint 增删(原 `wecom 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 createWecomConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
package/lib/console.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 企业微信 Console RPC:运行状态 + endpoint 增删(原 `wecom endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { createAdapterConsoleRpc } from 'zhin.js/adapter';
7
+ import { wecomRuntimeStateToken } from './wecom-runtime-state.js';
8
+ import { wecomConsoleSpec } from './console-spec.js';
9
+ export function createWecomConsoleRpc(resources, getConfig) {
10
+ const state = resources.use(wecomRuntimeStateToken);
11
+ return createAdapterConsoleRpc({
12
+ ...wecomConsoleSpec,
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-wecom",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "Zhin.js WeCom (企业微信) adapter for Plugin Runtime (HTTP webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -33,24 +33,27 @@
33
33
  "directory": "plugins/adapters/wecom"
34
34
  },
35
35
  "dependencies": {
36
- "@zhin.js/adapter": "1.1.24",
36
+ "@zhin.js/adapter": "1.1.25",
37
37
  "@zhin.js/agent-feature": "1.1.10",
38
- "@zhin.js/core": "1.1.52",
38
+ "@zhin.js/client": "1.1.21",
39
+ "@zhin.js/console-contract": "1.1.3",
40
+ "@zhin.js/core": "1.1.53",
39
41
  "@zhin.js/feature-kit": "1.1.9",
40
42
  "@zhin.js/host-http": "1.1.11",
41
- "@zhin.js/im-contract": "1.1.8",
43
+ "@zhin.js/im-contract": "1.1.9",
42
44
  "@zhin.js/logger": "1.1.2",
45
+ "@zhin.js/page": "1.1.10",
43
46
  "@zhin.js/skill": "1.1.10",
44
- "@zhin.js/tool": "1.1.11"
47
+ "@zhin.js/tool": "1.1.12"
45
48
  },
46
49
  "peerDependencies": {
47
50
  "zod": "^4.0.0",
48
- "@zhin.js/adapter": "^1.1.24",
51
+ "@zhin.js/adapter": "^1.1.25",
49
52
  "@zhin.js/command": "^1.1.11",
50
- "@zhin.js/core": "^1.1.52",
53
+ "@zhin.js/core": "^1.1.53",
51
54
  "@zhin.js/host-http": "^1.1.11",
52
55
  "@zhin.js/permission": "^1.1.9",
53
- "zhin.js": "^1.1.17"
56
+ "zhin.js": "^1.1.18"
54
57
  },
55
58
  "peerDependenciesMeta": {
56
59
  "@zhin.js/command": {
@@ -68,11 +71,12 @@
68
71
  "typescript": "^6.0.3",
69
72
  "vitest": "^4.1.10",
70
73
  "zod": "^4.4.3",
71
- "zhin.js": "1.1.17"
74
+ "zhin.js": "1.1.18"
72
75
  },
73
76
  "files": [
74
77
  "adapters",
75
78
  "commands",
79
+ "pages",
76
80
  "plugin.js",
77
81
  "schema.json",
78
82
  "src",
@@ -116,6 +120,10 @@
116
120
  {
117
121
  "package": "@zhin.js/agent-feature",
118
122
  "api": "^1.0.0"
123
+ },
124
+ {
125
+ "package": "@zhin.js/page",
126
+ "api": "^1.0.0"
119
127
  }
120
128
  ],
121
129
  "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: '企业微信',
6
+ titleI18n: { en: 'WeCom' },
7
+ icon: 'Building',
8
+ order: 76,
9
+ requiredPermissions: ['wecom:read'],
10
+ });
11
+ /**
12
+ * Convention page: `pages/index/index.ts` → `/wecom`(插件路径)。
13
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
14
+ */
15
+ export default createAdapterConsolePage('wecom');
@@ -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: '企业微信',
6
+ titleI18n: { en: 'WeCom' },
7
+ icon: 'Building',
8
+ order: 76,
9
+ requiredPermissions: ['wecom:read'],
10
+ });
11
+
12
+ /**
13
+ * Convention page: `pages/index/index.ts` → `/wecom`(插件路径)。
14
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
15
+ */
16
+ export default createAdapterConsolePage('wecom');
package/plugin.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { createEndpointRuntimeState } from 'zhin.js/adapter';
3
- import { definePlugin } from 'zhin.js';
3
+ import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
4
4
  import { permissionHostToken } from '@zhin.js/permission';
5
5
  import { checkWecomPlatformPermit } from "./lib/platform-permit.js";
6
6
  import { wecomRuntimeStateToken } from "./lib/wecom-runtime-state.js";
7
+ import { createWecomConsoleRpc } from "./lib/console.js";
7
8
  export default definePlugin({
8
9
  name: 'wecom',
9
10
  metadata: {
@@ -11,6 +12,7 @@ export default definePlugin({
11
12
  },
12
13
  setup(context) {
13
14
  context.resources.provide(wecomRuntimeStateToken, createEndpointRuntimeState());
15
+ context.resources.provide(pluginConsoleRpcToken, createWecomConsoleRpc(context.resources, () => context.config.get()));
14
16
  if (context.resources.has(permissionHostToken)) {
15
17
  const host = context.resources.use(permissionHostToken);
16
18
  return host.registerPlatform('wecom', checkWecomPlatformPermit);
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 企业微信 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+
6
+ export const wecomConsoleSpec = {
7
+ adapterKey: 'wecom',
8
+ adapterDisplayName: '企业微信',
9
+ fields: [
10
+ { key: 'corpId', required: true, env: true, description: '企业 corpId', descriptionI18n: { en: 'WeCom corporation ID' } },
11
+ { key: 'agentSecret', required: true, env: true, description: '应用 secret', descriptionI18n: { en: 'Application secret' } },
12
+ { key: 'token', required: true, env: true, description: '回调 token', descriptionI18n: { en: 'Callback token' } },
13
+ { key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key', descriptionI18n: { en: 'Callback encryption key' } },
14
+ ] as readonly AdapterConsoleField[],
15
+ docsUrl: 'https://zhin.js.org/adapters/wecom',
16
+ readPermission: 'wecom:read',
17
+ writePermission: 'wecom:write',
18
+ } as const;
package/src/console.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 企业微信 Console RPC:运行状态 + endpoint 增删(原 `wecom 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 { wecomRuntimeStateToken } from './wecom-runtime-state.js';
9
+ import { wecomConsoleSpec } from './console-spec.js';
10
+
11
+ export function createWecomConsoleRpc(
12
+ resources: AdapterConsoleResources,
13
+ getConfig: () => unknown,
14
+ ): PluginConsoleRpc {
15
+ const state = resources.use(wecomRuntimeStateToken);
16
+ return createAdapterConsoleRpc({
17
+ ...wecomConsoleSpec,
18
+ running: () => state.endpoints.values(),
19
+ getConfig,
20
+ }, resources);
21
+ }