@53ai/53ai-openclaw 1.0.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 +26 -0
- package/README.md +424 -0
- package/dist/index.cjs.js +1607 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.esm.js +1583 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/src/access-policy.d.ts +23 -0
- package/dist/src/channel.d.ts +3 -0
- package/dist/src/const.d.ts +44 -0
- package/dist/src/interface.d.ts +209 -0
- package/dist/src/media-handler.d.ts +23 -0
- package/dist/src/message-parser.d.ts +9 -0
- package/dist/src/message-sender.d.ts +26 -0
- package/dist/src/monitor.d.ts +2 -0
- package/dist/src/onboarding.d.ts +2 -0
- package/dist/src/reqid-store.d.ts +9 -0
- package/dist/src/runtime.d.ts +3 -0
- package/dist/src/state-manager.d.ts +17 -0
- package/dist/src/timeout.d.ts +10 -0
- package/dist/src/utils.d.ts +48 -0
- package/openclaw.plugin.json +41 -0
- package/package.json +80 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RuntimeEnv } from "openclaw/plugin-sdk";
|
|
2
|
+
import type { WebSocket } from "ws";
|
|
3
|
+
import { ErrorCode } from "./interface.js";
|
|
4
|
+
interface SendReplyParams {
|
|
5
|
+
wsClient: WebSocket;
|
|
6
|
+
text: string;
|
|
7
|
+
toChatId: string;
|
|
8
|
+
replyToMsgId?: string;
|
|
9
|
+
runtime: RuntimeEnv;
|
|
10
|
+
finish: boolean;
|
|
11
|
+
streamId: string;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
errorCode?: ErrorCode | string;
|
|
14
|
+
errorDetails?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function sendReply(params: SendReplyParams): Promise<void>;
|
|
17
|
+
export declare function sendDirectMessage(wsClient: WebSocket, to: string, content: string, runtime?: RuntimeEnv): Promise<void>;
|
|
18
|
+
export declare function sendMediaMessage(wsClient: WebSocket, to: string, media: {
|
|
19
|
+
type: "image" | "file";
|
|
20
|
+
url?: string;
|
|
21
|
+
base64?: string;
|
|
22
|
+
mimeType?: string;
|
|
23
|
+
filename?: string;
|
|
24
|
+
}, text?: string, runtime?: RuntimeEnv): Promise<void>;
|
|
25
|
+
export declare function sendThinkingMessage(wsClient: WebSocket, text: string, msgId: string, streamId: string, runtime?: RuntimeEnv): Promise<void>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface PersistentReqIdStore {
|
|
2
|
+
set(chatId: string, reqId: string): void;
|
|
3
|
+
get(chatId: string): Promise<string | undefined>;
|
|
4
|
+
getSync(chatId: string): string | undefined;
|
|
5
|
+
delete(chatId: string): void;
|
|
6
|
+
warmup(onError?: (error: unknown) => void): Promise<number>;
|
|
7
|
+
flush(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createPersistentReqIdStore(accountId: string): PersistentReqIdStore;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WebSocket } from "ws";
|
|
2
|
+
import type { MessageState } from "./interface.js";
|
|
3
|
+
export declare function getWebSocket(accountId: string): WebSocket | null;
|
|
4
|
+
export declare function setWebSocket(accountId: string, client: WebSocket): void;
|
|
5
|
+
export declare function deleteWebSocket(accountId: string): void;
|
|
6
|
+
export declare function startMessageStateCleanup(): void;
|
|
7
|
+
export declare function stopMessageStateCleanup(): void;
|
|
8
|
+
export declare function setMessageState(messageId: string, state: MessageState): void;
|
|
9
|
+
export declare function getMessageState(messageId: string): MessageState | undefined;
|
|
10
|
+
export declare function deleteMessageState(messageId: string): void;
|
|
11
|
+
export declare function clearAllMessageStates(): void;
|
|
12
|
+
export declare function setLastMsgIdForChat(chatId: string, msgId: string, accountId?: string): void;
|
|
13
|
+
export declare function getLastMsgIdForChat(chatId: string, accountId?: string): string | undefined;
|
|
14
|
+
export declare function warmupReqIdStore(accountId?: string, log?: (msg: string) => void): Promise<number>;
|
|
15
|
+
export declare function flushReqIdStore(accountId?: string): Promise<void>;
|
|
16
|
+
export declare function cleanupAccount(accountId: string): Promise<void>;
|
|
17
|
+
export declare function cleanupAll(): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { OpenClawConfig } from "openclaw/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* 53AIHub 渠道配置
|
|
4
|
+
*/
|
|
5
|
+
export interface AIHubConfig {
|
|
6
|
+
/** 是否启用 */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** 账户名称 */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** 机器人 ID */
|
|
11
|
+
botId?: string;
|
|
12
|
+
/** 用户 ID */
|
|
13
|
+
userId?: string;
|
|
14
|
+
/** 密钥 */
|
|
15
|
+
secret?: string;
|
|
16
|
+
/** 访问令牌 */
|
|
17
|
+
token?: string;
|
|
18
|
+
/** WebSocket URL */
|
|
19
|
+
websocketUrl?: string;
|
|
20
|
+
/** 访问控制白名单 */
|
|
21
|
+
allowFrom?: Array<string | number>;
|
|
22
|
+
/** 访问策略: open=开放, allowlist=白名单, pairing=配对审批 */
|
|
23
|
+
accessPolicy?: "open" | "allowlist" | "pairing" | "disabled";
|
|
24
|
+
/** 是否发送"思考中"消息 */
|
|
25
|
+
sendThinkingMessage?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 解析后的账户配置
|
|
29
|
+
*/
|
|
30
|
+
export interface ResolvedAccount {
|
|
31
|
+
accountId: string;
|
|
32
|
+
name: string;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
websocketUrl: string;
|
|
35
|
+
botId: string;
|
|
36
|
+
secret: string;
|
|
37
|
+
token: string;
|
|
38
|
+
sendThinkingMessage: boolean;
|
|
39
|
+
config: AIHubConfig;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 解析账户配置
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveAccount(cfg: OpenClawConfig, accountId?: string): ResolvedAccount;
|
|
45
|
+
/**
|
|
46
|
+
* 设置账户配置
|
|
47
|
+
*/
|
|
48
|
+
export declare function setAccount(cfg: OpenClawConfig, account: Partial<AIHubConfig>): OpenClawConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "53ai-openclaw",
|
|
3
|
+
"channels": [
|
|
4
|
+
"53aihub"
|
|
5
|
+
],
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"botId": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "AgentHub 智能体 ID (HashID)"
|
|
13
|
+
},
|
|
14
|
+
"secret": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "AgentHub App Secret / Token"
|
|
17
|
+
},
|
|
18
|
+
"token": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "AgentHub App Secret / Token (Alias)"
|
|
21
|
+
},
|
|
22
|
+
"websocketUrl": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "AgentHub WebSocket 连接地址"
|
|
25
|
+
},
|
|
26
|
+
"accessPolicy": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["open", "allowlist", "pairing"],
|
|
29
|
+
"default": "open",
|
|
30
|
+
"description": "访问策略: open=开放所有用户, allowlist=仅白名单用户, pairing=首次使用需审批"
|
|
31
|
+
},
|
|
32
|
+
"allowFrom": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"items": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"description": "访问控制白名单,配合 accessPolicy=allowlist 或 pairing 使用"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@53ai/53ai-openclaw",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"openclaw.plugin.json",
|
|
11
|
+
"README.md",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rollup -c",
|
|
16
|
+
"dev": "rollup -c -w",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"prebuild": "npm run clean",
|
|
19
|
+
"test": "echo \"No tests configured\" && exit 0",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"release": "bash scripts/publish.sh",
|
|
22
|
+
"release:patch": "bash scripts/publish.sh patch",
|
|
23
|
+
"release:minor": "bash scripts/publish.sh minor",
|
|
24
|
+
"release:major": "bash scripts/publish.sh major"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"53ai",
|
|
28
|
+
"openclaw",
|
|
29
|
+
"53ai-openclaw",
|
|
30
|
+
"agent",
|
|
31
|
+
"chatbot",
|
|
32
|
+
"websocket"
|
|
33
|
+
],
|
|
34
|
+
"author": "53AI",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"description": "OpenClaw 53AI channel plugin",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/53AI/53ai-openclaw.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/53AI/53ai-openclaw/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/53AI/53ai-openclaw#readme",
|
|
45
|
+
"openclaw": {
|
|
46
|
+
"extensions": [
|
|
47
|
+
"./dist/index.esm.js"
|
|
48
|
+
],
|
|
49
|
+
"channel": {
|
|
50
|
+
"id": "53aihub",
|
|
51
|
+
"paclabel": "53AIHub",
|
|
52
|
+
"selectionLabel": "53AIHub (AgentHub)",
|
|
53
|
+
"docsPath": "/channels/53aihub",
|
|
54
|
+
"docsLabel": "53ai-openclaw",
|
|
55
|
+
"blurb": "53AIHub 智能机器人接入插件",
|
|
56
|
+
"order": 90,
|
|
57
|
+
"quickstartAllowFrom": true
|
|
58
|
+
},
|
|
59
|
+
"install": {
|
|
60
|
+
"npmSpec": "@53ai/53ai-openclaw",
|
|
61
|
+
"localPath": "extensions/53ai-openclaw",
|
|
62
|
+
"defaultChoice": "npm"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"ws": "^8.16.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
70
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
71
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
72
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
73
|
+
"@types/ws": "^8.5.10",
|
|
74
|
+
"openclaw": ">=2026.2.13",
|
|
75
|
+
"rollup": "^4.9.6",
|
|
76
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
77
|
+
"tslib": "^2.6.2",
|
|
78
|
+
"typescript": "^5.3.3"
|
|
79
|
+
}
|
|
80
|
+
}
|