@zhin.js/adapter-onebot11 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 +27 -0
- package/README.md +10 -0
- package/lib/console-spec.d.ts +12 -0
- package/lib/console-spec.js +12 -0
- package/lib/console.d.ts +8 -0
- package/lib/console.js +16 -0
- package/package.json +17 -9
- package/pages/index/index.js +15 -0
- package/pages/index/index.ts +16 -0
- package/plugin.js +3 -1
- package/src/console-spec.ts +17 -0
- package/src/console.ts +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @zhin.js/adapter-onebot11
|
|
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
|
@@ -93,6 +93,16 @@ onebot11:
|
|
|
93
93
|
- [OneBot 11 标准](https://github.com/botuniverse/onebot-11)
|
|
94
94
|
- [适配器概览](https://zhin.js.org/essentials/adapters)
|
|
95
95
|
|
|
96
|
+
## Console 页面
|
|
97
|
+
|
|
98
|
+
启动后打开 Console 的「OneBot 11」页(地址 `/onebot11`),可以:
|
|
99
|
+
|
|
100
|
+
- 查看运行中的连接、点「测试连接」做连通性诊断;
|
|
101
|
+
- 增删 `plugins.onebot11.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
|
|
102
|
+
- 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
|
|
103
|
+
|
|
104
|
+
读取需要 `onebot11:read`,写操作需要 `onebot11:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `onebot11 endpoint add`。
|
|
105
|
+
|
|
96
106
|
## 故障排查
|
|
97
107
|
|
|
98
108
|
| 现象 | 排查 |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot 11 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
|
|
3
|
+
*/
|
|
4
|
+
import type { AdapterConsoleField } from 'zhin.js/adapter';
|
|
5
|
+
export declare const onebot11ConsoleSpec: {
|
|
6
|
+
readonly adapterKey: "onebot11";
|
|
7
|
+
readonly adapterDisplayName: "OneBot 11";
|
|
8
|
+
readonly fields: readonly AdapterConsoleField[];
|
|
9
|
+
readonly docsUrl: "https://zhin.js.org/adapters/onebot11";
|
|
10
|
+
readonly readPermission: "onebot11:read";
|
|
11
|
+
readonly writePermission: "onebot11:write";
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const onebot11ConsoleSpec = {
|
|
2
|
+
adapterKey: 'onebot11',
|
|
3
|
+
adapterDisplayName: 'OneBot 11',
|
|
4
|
+
fields: [
|
|
5
|
+
{ key: 'url', description: 'OneBot 实现 WebSocket URL(connection: ws 必填)', descriptionI18n: { en: 'OneBot WebSocket URL (required for connection: ws)' } },
|
|
6
|
+
{ key: 'path', description: 'reverse-wss 路径(connection: wss)', descriptionI18n: { en: 'Reverse WebSocket path (connection: wss)' } },
|
|
7
|
+
{ key: 'access_token', env: true, description: 'OneBot access token' },
|
|
8
|
+
],
|
|
9
|
+
docsUrl: 'https://zhin.js.org/adapters/onebot11',
|
|
10
|
+
readPermission: 'onebot11:read',
|
|
11
|
+
writePermission: 'onebot11:write',
|
|
12
|
+
};
|
package/lib/console.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot 11 Console RPC:运行状态 + endpoint 增删(原 `onebot11 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 createOnebot11ConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
|
package/lib/console.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot 11 Console RPC:运行状态 + endpoint 增删(原 `onebot11 endpoint` 聊天命令)。
|
|
3
|
+
*
|
|
4
|
+
* 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
|
|
5
|
+
*/
|
|
6
|
+
import { createAdapterConsoleRpc } from 'zhin.js/adapter';
|
|
7
|
+
import { onebot11RuntimeStateToken } from './onebot11-runtime-state.js';
|
|
8
|
+
import { onebot11ConsoleSpec } from './console-spec.js';
|
|
9
|
+
export function createOnebot11ConsoleRpc(resources, getConfig) {
|
|
10
|
+
const state = resources.use(onebot11RuntimeStateToken);
|
|
11
|
+
return createAdapterConsoleRpc({
|
|
12
|
+
...onebot11ConsoleSpec,
|
|
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-onebot11",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Zhin.js OneBot 11 adapter for Plugin Runtime (WebSocket client)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"adapters",
|
|
16
16
|
"commands",
|
|
17
|
+
"pages",
|
|
17
18
|
"plugin.js",
|
|
18
19
|
"schema.json",
|
|
19
20
|
"src",
|
|
@@ -44,16 +45,19 @@
|
|
|
44
45
|
"@imhelper/onebot-v11": "1.0.7",
|
|
45
46
|
"imhelper": "1.0.7",
|
|
46
47
|
"ws": "^8.21.1",
|
|
47
|
-
"@zhin.js/adapter": "1.1.
|
|
48
|
+
"@zhin.js/adapter": "1.1.25",
|
|
48
49
|
"@zhin.js/agent-feature": "1.1.10",
|
|
49
|
-
"@zhin.js/
|
|
50
|
+
"@zhin.js/client": "1.1.21",
|
|
51
|
+
"@zhin.js/console-contract": "1.1.3",
|
|
52
|
+
"@zhin.js/core": "1.1.53",
|
|
50
53
|
"@zhin.js/feature-kit": "1.1.9",
|
|
51
54
|
"@zhin.js/host-http": "1.1.11",
|
|
52
|
-
"@zhin.js/im-contract": "1.1.
|
|
55
|
+
"@zhin.js/im-contract": "1.1.9",
|
|
53
56
|
"@zhin.js/logger": "1.1.2",
|
|
57
|
+
"@zhin.js/page": "1.1.10",
|
|
54
58
|
"@zhin.js/permission": "1.1.9",
|
|
55
59
|
"@zhin.js/skill": "1.1.10",
|
|
56
|
-
"@zhin.js/tool": "1.1.
|
|
60
|
+
"@zhin.js/tool": "1.1.12"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
63
|
"@types/node": "^26.1.2",
|
|
@@ -62,14 +66,14 @@
|
|
|
62
66
|
"vitest": "^4.1.10",
|
|
63
67
|
"zod": "^4.4.3",
|
|
64
68
|
"@zhin.js/host-http": "1.1.11",
|
|
65
|
-
"zhin.js": "1.1.
|
|
69
|
+
"zhin.js": "1.1.18"
|
|
66
70
|
},
|
|
67
71
|
"peerDependencies": {
|
|
68
72
|
"zod": "^4.0.0",
|
|
69
|
-
"@zhin.js/adapter": "^1.1.
|
|
73
|
+
"@zhin.js/adapter": "^1.1.25",
|
|
70
74
|
"@zhin.js/command": "^1.1.11",
|
|
71
|
-
"@zhin.js/core": "^1.1.
|
|
72
|
-
"zhin.js": "^1.1.
|
|
75
|
+
"@zhin.js/core": "^1.1.53",
|
|
76
|
+
"zhin.js": "^1.1.18"
|
|
73
77
|
},
|
|
74
78
|
"peerDependenciesMeta": {
|
|
75
79
|
"@zhin.js/command": {
|
|
@@ -120,6 +124,10 @@
|
|
|
120
124
|
{
|
|
121
125
|
"package": "@zhin.js/agent-feature",
|
|
122
126
|
"api": "^1.0.0"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"package": "@zhin.js/page",
|
|
130
|
+
"api": "^1.0.0"
|
|
123
131
|
}
|
|
124
132
|
],
|
|
125
133
|
"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: 'OneBot 11',
|
|
6
|
+
titleI18n: { en: 'OneBot 11' },
|
|
7
|
+
icon: 'Bot',
|
|
8
|
+
order: 70,
|
|
9
|
+
requiredPermissions: ['onebot11:read'],
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Convention page: `pages/index/index.ts` → `/onebot11`(插件路径)。
|
|
13
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
14
|
+
*/
|
|
15
|
+
export default createAdapterConsolePage('onebot11');
|
|
@@ -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: 'OneBot 11',
|
|
6
|
+
titleI18n: { en: 'OneBot 11' },
|
|
7
|
+
icon: 'Bot',
|
|
8
|
+
order: 70,
|
|
9
|
+
requiredPermissions: ['onebot11:read'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convention page: `pages/index/index.ts` → `/onebot11`(插件路径)。
|
|
14
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
15
|
+
*/
|
|
16
|
+
export default createAdapterConsolePage('onebot11');
|
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 } from 'zhin.js';
|
|
3
|
+
import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
|
|
4
4
|
import { permissionHostToken, createSceneRolePlatformChecker } from '@zhin.js/permission';
|
|
5
5
|
import { onebot11RuntimeStateToken } from "./lib/onebot11-runtime-state.js";
|
|
6
|
+
import { createOnebot11ConsoleRpc } from "./lib/console.js";
|
|
6
7
|
export default definePlugin({
|
|
7
8
|
name: 'onebot11',
|
|
8
9
|
metadata: {
|
|
@@ -10,6 +11,7 @@ export default definePlugin({
|
|
|
10
11
|
},
|
|
11
12
|
setup(context) {
|
|
12
13
|
context.resources.provide(onebot11RuntimeStateToken, createEndpointRuntimeState());
|
|
14
|
+
context.resources.provide(pluginConsoleRpcToken, createOnebot11ConsoleRpc(context.resources, () => context.config.get()));
|
|
13
15
|
if (context.resources.has(permissionHostToken)) {
|
|
14
16
|
const host = context.resources.use(permissionHostToken);
|
|
15
17
|
return host.registerPlatform('onebot11', createSceneRolePlatformChecker());
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot 11 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
|
|
3
|
+
*/
|
|
4
|
+
import type { AdapterConsoleField } from 'zhin.js/adapter';
|
|
5
|
+
|
|
6
|
+
export const onebot11ConsoleSpec = {
|
|
7
|
+
adapterKey: 'onebot11',
|
|
8
|
+
adapterDisplayName: 'OneBot 11',
|
|
9
|
+
fields: [
|
|
10
|
+
{ key: 'url', description: 'OneBot 实现 WebSocket URL(connection: ws 必填)', descriptionI18n: { en: 'OneBot WebSocket URL (required for connection: ws)' } },
|
|
11
|
+
{ key: 'path', description: 'reverse-wss 路径(connection: wss)', descriptionI18n: { en: 'Reverse WebSocket path (connection: wss)' } },
|
|
12
|
+
{ key: 'access_token', env: true, description: 'OneBot access token' },
|
|
13
|
+
] as readonly AdapterConsoleField[],
|
|
14
|
+
docsUrl: 'https://zhin.js.org/adapters/onebot11',
|
|
15
|
+
readPermission: 'onebot11:read',
|
|
16
|
+
writePermission: 'onebot11:write',
|
|
17
|
+
} as const;
|
package/src/console.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot 11 Console RPC:运行状态 + endpoint 增删(原 `onebot11 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 { onebot11RuntimeStateToken } from './onebot11-runtime-state.js';
|
|
9
|
+
import { onebot11ConsoleSpec } from './console-spec.js';
|
|
10
|
+
|
|
11
|
+
export function createOnebot11ConsoleRpc(
|
|
12
|
+
resources: AdapterConsoleResources,
|
|
13
|
+
getConfig: () => unknown,
|
|
14
|
+
): PluginConsoleRpc {
|
|
15
|
+
const state = resources.use(onebot11RuntimeStateToken);
|
|
16
|
+
return createAdapterConsoleRpc({
|
|
17
|
+
...onebot11ConsoleSpec,
|
|
18
|
+
running: () => state.endpoints.values(),
|
|
19
|
+
getConfig,
|
|
20
|
+
}, resources);
|
|
21
|
+
}
|