@zhin.js/adapter-napcat 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 +14 -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 +19 -0
- package/src/console.ts +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @zhin.js/adapter-napcat
|
|
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
|
@@ -87,6 +87,16 @@ endpoint 配置,不会从环境变量推断 endpoint id。
|
|
|
87
87
|
- [NapCatQQ](https://github.com/NapNeko/NapCatQQ)
|
|
88
88
|
- [适配器概览](https://zhin.js.org/essentials/adapters)
|
|
89
89
|
|
|
90
|
+
## Console 页面
|
|
91
|
+
|
|
92
|
+
启动后打开 Console 的「NapCat」页(地址 `/napcat`),可以:
|
|
93
|
+
|
|
94
|
+
- 查看运行中的连接、点「测试连接」做连通性诊断;
|
|
95
|
+
- 增删 `plugins.napcat.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
|
|
96
|
+
- 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
|
|
97
|
+
|
|
98
|
+
读取需要 `napcat:read`,写操作需要 `napcat:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `napcat endpoint add`。
|
|
99
|
+
|
|
90
100
|
## 故障排查
|
|
91
101
|
|
|
92
102
|
| 现象 | 排查 |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NapCat Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
|
|
3
|
+
*/
|
|
4
|
+
import type { AdapterConsoleField } from 'zhin.js/adapter';
|
|
5
|
+
export declare const napcatConsoleSpec: {
|
|
6
|
+
readonly adapterKey: "napcat";
|
|
7
|
+
readonly adapterDisplayName: "NapCat";
|
|
8
|
+
readonly fields: readonly AdapterConsoleField[];
|
|
9
|
+
readonly docsUrl: "https://zhin.js.org/adapters/napcat";
|
|
10
|
+
readonly readPermission: "napcat:read";
|
|
11
|
+
readonly writePermission: "napcat:write";
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const napcatConsoleSpec = {
|
|
2
|
+
adapterKey: 'napcat',
|
|
3
|
+
adapterDisplayName: 'NapCat',
|
|
4
|
+
fields: [
|
|
5
|
+
{ key: 'url', description: 'NapCat WebSocket URL(connection: ws 必填)', descriptionI18n: { en: 'NapCat WebSocket URL (required for connection: ws)' } },
|
|
6
|
+
{ key: 'path', description: 'reverse-wss 路径(connection: wss)', descriptionI18n: { en: 'Reverse WebSocket path (connection: wss)' } },
|
|
7
|
+
{ key: 'http_url', description: 'HTTP API base URL(connection: http 出站)', descriptionI18n: { en: 'HTTP API base URL (outbound connection: http)' } },
|
|
8
|
+
{ key: 'post_path', description: 'HTTP POST 事件路径(connection: http 入站)', descriptionI18n: { en: 'HTTP POST event path (inbound connection: http)' } },
|
|
9
|
+
{ key: 'access_token', env: true, description: 'NapCat access token' },
|
|
10
|
+
],
|
|
11
|
+
docsUrl: 'https://zhin.js.org/adapters/napcat',
|
|
12
|
+
readPermission: 'napcat:read',
|
|
13
|
+
writePermission: 'napcat:write',
|
|
14
|
+
};
|
package/lib/console.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NapCat Console RPC:运行状态 + endpoint 增删(原 `napcat 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 createNapcatConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
|
package/lib/console.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NapCat Console RPC:运行状态 + endpoint 增删(原 `napcat endpoint` 聊天命令)。
|
|
3
|
+
*
|
|
4
|
+
* 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
|
|
5
|
+
*/
|
|
6
|
+
import { createAdapterConsoleRpc } from 'zhin.js/adapter';
|
|
7
|
+
import { napcatRuntimeStateToken } from './napcat-runtime-state.js';
|
|
8
|
+
import { napcatConsoleSpec } from './console-spec.js';
|
|
9
|
+
export function createNapcatConsoleRpc(resources, getConfig) {
|
|
10
|
+
const state = resources.use(napcatRuntimeStateToken);
|
|
11
|
+
return createAdapterConsoleRpc({
|
|
12
|
+
...napcatConsoleSpec,
|
|
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-napcat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Zhin.js NapCat adapter for Plugin Runtime (WebSocket client, OneBot11 + NapCat extensions)",
|
|
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
|
},
|
|
45
46
|
"dependencies": {
|
|
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: 'NapCat',
|
|
6
|
+
titleI18n: { en: 'NapCat' },
|
|
7
|
+
icon: 'Cat',
|
|
8
|
+
order: 69,
|
|
9
|
+
requiredPermissions: ['napcat:read'],
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Convention page: `pages/index/index.ts` → `/napcat`(插件路径)。
|
|
13
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
14
|
+
*/
|
|
15
|
+
export default createAdapterConsolePage('napcat');
|
|
@@ -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: 'NapCat',
|
|
6
|
+
titleI18n: { en: 'NapCat' },
|
|
7
|
+
icon: 'Cat',
|
|
8
|
+
order: 69,
|
|
9
|
+
requiredPermissions: ['napcat:read'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convention page: `pages/index/index.ts` → `/napcat`(插件路径)。
|
|
14
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
15
|
+
*/
|
|
16
|
+
export default createAdapterConsolePage('napcat');
|
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 { napcatRuntimeStateToken } from "./lib/napcat-runtime-state.js";
|
|
6
|
+
import { createNapcatConsoleRpc } from "./lib/console.js";
|
|
6
7
|
export default definePlugin({
|
|
7
8
|
name: 'napcat',
|
|
8
9
|
metadata: {
|
|
@@ -10,6 +11,7 @@ export default definePlugin({
|
|
|
10
11
|
},
|
|
11
12
|
setup(context) {
|
|
12
13
|
context.resources.provide(napcatRuntimeStateToken, createEndpointRuntimeState());
|
|
14
|
+
context.resources.provide(pluginConsoleRpcToken, createNapcatConsoleRpc(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('napcat', createSceneRolePlatformChecker());
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NapCat Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
|
|
3
|
+
*/
|
|
4
|
+
import type { AdapterConsoleField } from 'zhin.js/adapter';
|
|
5
|
+
|
|
6
|
+
export const napcatConsoleSpec = {
|
|
7
|
+
adapterKey: 'napcat',
|
|
8
|
+
adapterDisplayName: 'NapCat',
|
|
9
|
+
fields: [
|
|
10
|
+
{ key: 'url', description: 'NapCat WebSocket URL(connection: ws 必填)', descriptionI18n: { en: 'NapCat WebSocket URL (required for connection: ws)' } },
|
|
11
|
+
{ key: 'path', description: 'reverse-wss 路径(connection: wss)', descriptionI18n: { en: 'Reverse WebSocket path (connection: wss)' } },
|
|
12
|
+
{ key: 'http_url', description: 'HTTP API base URL(connection: http 出站)', descriptionI18n: { en: 'HTTP API base URL (outbound connection: http)' } },
|
|
13
|
+
{ key: 'post_path', description: 'HTTP POST 事件路径(connection: http 入站)', descriptionI18n: { en: 'HTTP POST event path (inbound connection: http)' } },
|
|
14
|
+
{ key: 'access_token', env: true, description: 'NapCat access token' },
|
|
15
|
+
] as readonly AdapterConsoleField[],
|
|
16
|
+
docsUrl: 'https://zhin.js.org/adapters/napcat',
|
|
17
|
+
readPermission: 'napcat:read',
|
|
18
|
+
writePermission: 'napcat:write',
|
|
19
|
+
} as const;
|
package/src/console.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NapCat Console RPC:运行状态 + endpoint 增删(原 `napcat 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 { napcatRuntimeStateToken } from './napcat-runtime-state.js';
|
|
9
|
+
import { napcatConsoleSpec } from './console-spec.js';
|
|
10
|
+
|
|
11
|
+
export function createNapcatConsoleRpc(
|
|
12
|
+
resources: AdapterConsoleResources,
|
|
13
|
+
getConfig: () => unknown,
|
|
14
|
+
): PluginConsoleRpc {
|
|
15
|
+
const state = resources.use(napcatRuntimeStateToken);
|
|
16
|
+
return createAdapterConsoleRpc({
|
|
17
|
+
...napcatConsoleSpec,
|
|
18
|
+
running: () => state.endpoints.values(),
|
|
19
|
+
getConfig,
|
|
20
|
+
}, resources);
|
|
21
|
+
}
|