@zhin.js/adapter-onebot12 1.0.1 → 1.1.0
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 +855 -0
- package/README.md +59 -69
- package/adapters/onebot12.js +50 -0
- package/adapters/onebot12.ts +64 -0
- package/commands/endpoint/add/[id].js +3 -0
- package/commands/endpoint/add/[id].ts +3 -0
- package/commands/endpoint/list.js +3 -0
- package/commands/endpoint/list.ts +3 -0
- package/commands/endpoint/remove/[id].js +3 -0
- package/commands/endpoint/remove/[id].ts +3 -0
- package/lib/client.d.ts +20 -0
- package/lib/client.js +33 -0
- package/lib/content-port.d.ts +4 -0
- package/lib/content-port.js +45 -0
- package/lib/endpoint-management.d.ts +16 -0
- package/lib/endpoint-management.js +47 -0
- package/lib/index.d.ts +10 -19
- package/lib/index.js +7 -27
- package/lib/onebot12-endpoint-commands.d.ts +1 -0
- package/lib/onebot12-endpoint-commands.js +25 -0
- package/lib/onebot12-runtime-state.d.ts +1 -0
- package/lib/onebot12-runtime-state.js +6 -0
- package/lib/protocol.d.ts +173 -0
- package/lib/protocol.js +415 -0
- package/lib/side-event-dispatch.d.ts +7 -0
- package/lib/side-event-dispatch.js +36 -0
- package/lib/webhook.d.ts +23 -0
- package/lib/webhook.js +161 -0
- package/lib/ws-endpoint.d.ts +22 -0
- package/lib/ws-endpoint.js +255 -0
- package/lib/ws-types.d.ts +16 -0
- package/lib/ws-types.js +1 -0
- package/lib/wss-auth.d.ts +2 -0
- package/lib/wss-auth.js +16 -0
- package/lib/wss-endpoint.d.ts +25 -0
- package/lib/wss-endpoint.js +222 -0
- package/package.json +63 -17
- package/plugin.js +14 -0
- package/schema.json +102 -0
- package/src/client.ts +81 -0
- package/src/content-port.ts +49 -0
- package/src/endpoint-management.ts +73 -0
- package/src/index.ts +64 -37
- package/src/onebot12-endpoint-commands.ts +24 -0
- package/src/onebot12-runtime-state.ts +7 -0
- package/src/protocol.ts +574 -0
- package/src/side-event-dispatch.ts +48 -0
- package/src/webhook.ts +223 -0
- package/src/ws-endpoint.ts +321 -0
- package/src/ws-types.ts +19 -0
- package/src/wss-auth.ts +17 -0
- package/src/wss-endpoint.ts +278 -0
- package/lib/adapter.d.ts +0 -18
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -41
- package/lib/adapter.js.map +0 -1
- package/lib/api.d.ts +0 -14
- package/lib/api.d.ts.map +0 -1
- package/lib/api.js +0 -34
- package/lib/api.js.map +0 -1
- package/lib/endpoint-webhook.d.ts +0 -25
- package/lib/endpoint-webhook.d.ts.map +0 -1
- package/lib/endpoint-webhook.js +0 -118
- package/lib/endpoint-webhook.js.map +0 -1
- package/lib/endpoint-ws.d.ts +0 -26
- package/lib/endpoint-ws.d.ts.map +0 -1
- package/lib/endpoint-ws.js +0 -210
- package/lib/endpoint-ws.js.map +0 -1
- package/lib/endpoint-wss.d.ts +0 -26
- package/lib/endpoint-wss.d.ts.map +0 -1
- package/lib/endpoint-wss.js +0 -187
- package/lib/endpoint-wss.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types.d.ts +0 -77
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
- package/lib/utils.d.ts +0 -45
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -60
- package/lib/utils.js.map +0 -1
- package/src/adapter.ts +0 -54
- package/src/api.ts +0 -48
- package/src/endpoint-webhook.ts +0 -130
- package/src/endpoint-ws.ts +0 -222
- package/src/endpoint-wss.ts +0 -202
- package/src/types.ts +0 -86
- package/src/utils.ts +0 -87
- /package/{skills/onebot12/SKILL.md → agent/skills/onebot12.md} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,40 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export {
|
|
2
|
+
buildSendMessageParams,
|
|
3
|
+
buildWsConnectOptions,
|
|
4
|
+
callOneBot12Action,
|
|
5
|
+
formatInboundContent,
|
|
6
|
+
formatOutboundSegments,
|
|
7
|
+
getChannelId,
|
|
8
|
+
isBotMentioned,
|
|
9
|
+
isMessageEvent,
|
|
10
|
+
mediaRefToOneBot12Fields,
|
|
11
|
+
mediaRefToOneBot12UploadParams,
|
|
12
|
+
onebot12InboundConversation,
|
|
13
|
+
resolveOneBot12Config,
|
|
14
|
+
senderNickname,
|
|
15
|
+
senderUserId,
|
|
16
|
+
uploadOneBot12MediaSegments,
|
|
17
|
+
type OneBot12ActionRequest,
|
|
18
|
+
type OneBot12ActionResponse,
|
|
19
|
+
type OneBot12AdapterConfig,
|
|
20
|
+
type OneBot12CallAction,
|
|
21
|
+
type OneBot12ConfigBase,
|
|
22
|
+
type OneBot12EndpointConfig,
|
|
23
|
+
type OneBot12Event,
|
|
24
|
+
type OneBot12HttpOptions,
|
|
25
|
+
type OneBot12Segment,
|
|
26
|
+
type OneBot12Self,
|
|
27
|
+
type OneBot12WebhookConfig,
|
|
28
|
+
type OneBot12WireSegment,
|
|
29
|
+
type OneBot12WsConfig,
|
|
30
|
+
type OneBot12WssConfig,
|
|
31
|
+
type ResolvedOneBot12Config,
|
|
32
|
+
} from './protocol.js';
|
|
8
33
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export { OneBot12WebhookEndpoint } from './endpoint-webhook.js';
|
|
14
|
-
export { OneBot12WssServer } from './endpoint-wss.js';
|
|
15
|
-
export { OneBot12Adapter, type OneBot12Bot } from './adapter.js';
|
|
34
|
+
export {
|
|
35
|
+
OneBot12WebhookEndpoint,
|
|
36
|
+
type OneBot12WebhookEndpointOptions,
|
|
37
|
+
} from './webhook.js';
|
|
16
38
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
interface Adapters {
|
|
24
|
-
onebot12: OneBot12Adapter;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
39
|
+
export {
|
|
40
|
+
OneBot12WsEndpoint,
|
|
41
|
+
type OneBot12WsEndpointOptions,
|
|
42
|
+
} from './ws-endpoint.js';
|
|
27
43
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
44
|
+
export {
|
|
45
|
+
OneBot12WssEndpoint,
|
|
46
|
+
type OneBot12WssEndpointOptions,
|
|
47
|
+
} from './wss-endpoint.js';
|
|
48
|
+
|
|
49
|
+
export type { OneBot12WsSocket, OneBot12WsCreateOptions } from './ws-types.js';
|
|
50
|
+
|
|
51
|
+
export { verifyOneBotAccessToken } from './wss-auth.js';
|
|
52
|
+
export {
|
|
53
|
+
Onebot12Client,
|
|
54
|
+
onebot12Client,
|
|
55
|
+
type Onebot12ClientEventMap,
|
|
56
|
+
} from './client.js';
|
|
57
|
+
|
|
58
|
+
export type {
|
|
59
|
+
OneBotV12ActionUrlResolver,
|
|
60
|
+
OneBotV12AdapterConfig as ImHelperOneBotV12AdapterConfig,
|
|
61
|
+
OneBotV12Call,
|
|
62
|
+
OneBotV12ClientConfig,
|
|
63
|
+
OneBotV12Event as ImHelperOneBotV12Event,
|
|
64
|
+
OneBotV12Response,
|
|
65
|
+
} from '@imhelper/onebot-v12';
|
|
66
|
+
export { ProtocolError } from '@imhelper/onebot-v12';
|
|
67
|
+
export type { ProtocolErrorKind, ProtocolErrorOptions } from 'imhelper';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `onebot12.endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
|
|
3
|
+
* commands/endpoint/ 下的 list / add / remove 直接默认导出这三项。
|
|
4
|
+
*/
|
|
5
|
+
import { createEndpointCommands } from 'zhin.js/adapter';
|
|
6
|
+
import { defineCommand } from 'zhin.js/command';
|
|
7
|
+
import { onebot12RuntimeStateToken } from './onebot12-runtime-state.js';
|
|
8
|
+
|
|
9
|
+
export const onebot12EndpointCommands = createEndpointCommands({
|
|
10
|
+
adapterKey: 'onebot12',
|
|
11
|
+
adapterDisplayName: 'OneBot 12',
|
|
12
|
+
fields: [
|
|
13
|
+
{ key: 'url', description: 'OneBot 实现 WebSocket URL(connection: ws 必填)' },
|
|
14
|
+
{ key: 'path', description: 'HTTP/WS 路径(webhook / reverse-wss)' },
|
|
15
|
+
{ key: 'api_url', description: 'HTTP action 端点(connection: webhook 出站必填)' },
|
|
16
|
+
{ key: 'access_token', env: true, description: 'OneBot access token' },
|
|
17
|
+
],
|
|
18
|
+
running: (use) => use(onebot12RuntimeStateToken).endpoints.values(),
|
|
19
|
+
describeEntry: (entry) => {
|
|
20
|
+
if (entry.url) return `url: ${String(entry.url)}`;
|
|
21
|
+
if (entry.path) return `path: ${String(entry.path)}`;
|
|
22
|
+
return '';
|
|
23
|
+
},
|
|
24
|
+
}, defineCommand);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneBot12 插件实例的运行时状态:adapter create() 注册的 endpoint 列表。
|
|
3
|
+
* 由 plugin.ts setup() provide,adapter create 与 `onebot12.endpoint` 命令共享(同一 owner generation)。
|
|
4
|
+
*/
|
|
5
|
+
import { defineEndpointRuntimeStateToken } from 'zhin.js/adapter';
|
|
6
|
+
|
|
7
|
+
export const onebot12RuntimeStateToken = defineEndpointRuntimeStateToken('onebot12');
|