@dcrays/dcgchat-test 0.2.26 → 0.2.27
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/openclaw.plugin.json +4 -2
- package/package.json +4 -7
- package/src/channel.ts +10 -10
- package/src/request.ts +1 -1
- package/src/skill.ts +4 -4
- package/README.md +0 -83
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcrays/dcgchat-test",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -36,18 +36,15 @@
|
|
|
36
36
|
"id": "dcgchat-test",
|
|
37
37
|
"label": "书灵墨宝",
|
|
38
38
|
"selectionLabel": "书灵墨宝",
|
|
39
|
-
"docsPath": "/channels/dcgchat",
|
|
39
|
+
"docsPath": "/channels/dcgchat-test",
|
|
40
40
|
"docsLabel": "dcgchat-test",
|
|
41
41
|
"blurb": "连接 OpenClaw 与 书灵墨宝 产品",
|
|
42
42
|
"order": 80
|
|
43
43
|
},
|
|
44
44
|
"install": {
|
|
45
45
|
"npmSpec": "@dcrays/dcgchat-test",
|
|
46
|
-
"localPath": "extensions/dcgchat",
|
|
46
|
+
"localPath": "extensions/dcgchat-test",
|
|
47
47
|
"defaultChoice": "npm"
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"openclaw": "^2026.3.13"
|
|
52
49
|
}
|
|
53
|
-
}
|
|
50
|
+
}
|
package/src/channel.ts
CHANGED
|
@@ -95,7 +95,7 @@ export async function sendDcgchatMedia(ctx: DcgchatMediaSendContext): Promise<vo
|
|
|
95
95
|
|
|
96
96
|
export function resolveAccount(cfg: OpenClawConfig, accountId?: string | null): ResolvedDcgchatAccount {
|
|
97
97
|
const id = accountId ?? DEFAULT_ACCOUNT_ID;
|
|
98
|
-
const raw = (cfg.channels?.["dcgchat"] as DcgchatConfig | undefined) ?? {};
|
|
98
|
+
const raw = (cfg.channels?.["dcgchat-test"] as DcgchatConfig | undefined) ?? {};
|
|
99
99
|
return {
|
|
100
100
|
accountId: id,
|
|
101
101
|
enabled: raw.enabled !== false,
|
|
@@ -109,13 +109,13 @@ export function resolveAccount(cfg: OpenClawConfig, accountId?: string | null):
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
112
|
-
id: "dcgchat",
|
|
112
|
+
id: "dcgchat-test",
|
|
113
113
|
meta: {
|
|
114
|
-
id: "dcgchat",
|
|
114
|
+
id: "dcgchat-test",
|
|
115
115
|
label: "书灵墨宝",
|
|
116
116
|
selectionLabel: "书灵墨宝",
|
|
117
|
-
docsPath: "/channels/dcgchat",
|
|
118
|
-
docsLabel: "dcgchat",
|
|
117
|
+
docsPath: "/channels/dcgchat-test",
|
|
118
|
+
docsLabel: "dcgchat-test",
|
|
119
119
|
blurb: "连接 OpenClaw 与 书灵墨宝 产品",
|
|
120
120
|
order: 80,
|
|
121
121
|
},
|
|
@@ -131,7 +131,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
131
131
|
effects: true,
|
|
132
132
|
// blockStreaming: true,
|
|
133
133
|
},
|
|
134
|
-
reload: { configPrefixes: ["channels.dcgchat"] },
|
|
134
|
+
reload: { configPrefixes: ["channels.dcgchat-test"] },
|
|
135
135
|
configSchema: {
|
|
136
136
|
schema: {
|
|
137
137
|
type: "object",
|
|
@@ -155,8 +155,8 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
155
155
|
...cfg,
|
|
156
156
|
channels: {
|
|
157
157
|
...cfg.channels,
|
|
158
|
-
"dcgchat": {
|
|
159
|
-
...(cfg.channels?.["dcgchat"] as Record<string, unknown> | undefined),
|
|
158
|
+
"dcgchat-test": {
|
|
159
|
+
...(cfg.channels?.["dcgchat-test"] as Record<string, unknown> | undefined),
|
|
160
160
|
enabled,
|
|
161
161
|
},
|
|
162
162
|
},
|
|
@@ -227,7 +227,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
227
227
|
log(`[dcgchat][${ctx.accountId ?? DEFAULT_ACCOUNT_ID}] outbound -> : ${ctx.text}`);
|
|
228
228
|
}
|
|
229
229
|
return {
|
|
230
|
-
channel: "dcgchat",
|
|
230
|
+
channel: "dcgchat-test",
|
|
231
231
|
messageId: `dcg-${Date.now()}`,
|
|
232
232
|
chatId: params.userId.toString(),
|
|
233
233
|
};
|
|
@@ -236,7 +236,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
236
236
|
const params = getMsgParams();
|
|
237
237
|
await sendDcgchatMedia(ctx);
|
|
238
238
|
return {
|
|
239
|
-
channel: "dcgchat",
|
|
239
|
+
channel: "dcgchat-test",
|
|
240
240
|
messageId: `dcg-${Date.now()}`,
|
|
241
241
|
chatId: params.userId.toString(),
|
|
242
242
|
};
|
package/src/request.ts
CHANGED
package/src/skill.ts
CHANGED
|
@@ -46,7 +46,7 @@ function sendEvent(msgContent: Record<string, any>) {
|
|
|
46
46
|
|
|
47
47
|
// const route = core.channel.routing.resolveAgentRoute({
|
|
48
48
|
// cfg: ctx.cfg,
|
|
49
|
-
// channel: "dcgchat",
|
|
49
|
+
// channel: "dcgchat-test",
|
|
50
50
|
// accountId: account.accountId,
|
|
51
51
|
// peer: { kind: "direct", id: userId },
|
|
52
52
|
// });
|
|
@@ -71,13 +71,13 @@ function sendEvent(msgContent: Record<string, any>) {
|
|
|
71
71
|
// ChatType: "direct",
|
|
72
72
|
// SenderName: userId,
|
|
73
73
|
// SenderId: userId,
|
|
74
|
-
// Provider: "dcgchat" as const,
|
|
75
|
-
// Surface: "dcgchat" as const,
|
|
74
|
+
// Provider: "dcgchat-test" as const,
|
|
75
|
+
// Surface: "dcgchat-test" as const,
|
|
76
76
|
// MessageSid: Date.now().toString(),
|
|
77
77
|
// Timestamp: Date.now(),
|
|
78
78
|
// WasMentioned: true,
|
|
79
79
|
// CommandAuthorized: true,
|
|
80
|
-
// OriginatingChannel: "dcgchat" as const,
|
|
80
|
+
// OriginatingChannel: "dcgchat-test" as const,
|
|
81
81
|
// OriginatingTo: `user:${userId}`,
|
|
82
82
|
// });
|
|
83
83
|
|
package/README.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# OpenClaw 书灵墨宝 插件
|
|
2
|
-
|
|
3
|
-
连接 OpenClaw 与 书灵墨宝 产品的通道插件。
|
|
4
|
-
|
|
5
|
-
## 架构
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
┌──────────┐ WebSocket ┌──────────────┐ WebSocket ┌─────────────────────┐
|
|
9
|
-
│ Web 前端 │ ←───────────────→ │ 公司后端服务 │ ←───────────────→ │ OpenClaw(工作电脑) │
|
|
10
|
-
└──────────┘ └──────────────┘ (OpenClaw 主动连) └─────────────────────┘
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
- OpenClaw 插件**主动连接**后端的 WebSocket 服务(不需要公网 IP)
|
|
14
|
-
- 后端收到用户消息后转发给 OpenClaw,OpenClaw 回复后发回后端
|
|
15
|
-
|
|
16
|
-
## 快速开始
|
|
17
|
-
|
|
18
|
-
### 1. 安装插件
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pnpm openclaw plugins install -l /path/to/openclaw-dcgchat
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### 2. 配置
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
openclaw config set channels.dcgchat.enabled true
|
|
28
|
-
openclaw config set channels.dcgchat.wsUrl "ws://your-backend:8080/openclaw/ws"
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### 3. 启动
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
pnpm openclaw gateway
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 消息协议(MVP)
|
|
38
|
-
|
|
39
|
-
### 下行:后端 → OpenClaw(用户消息)
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{ "type": "message", "userId": "user_001", "text": "你好" }
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 上行:OpenClaw → 后端(Agent 回复)
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{ "type": "reply", "userId": "user_001", "text": "你好!有什么可以帮你的?" }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## 配置项
|
|
52
|
-
|
|
53
|
-
| 配置键 | 类型 | 说明 |
|
|
54
|
-
|--------|------|------|
|
|
55
|
-
| `channels.dcgchat.enabled` | boolean | 是否启用 |
|
|
56
|
-
| `channels.dcgchat.wsUrl` | string | 后端 WebSocket 地址 |
|
|
57
|
-
|
|
58
|
-
## 开发
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# 安装依赖
|
|
62
|
-
pnpm install
|
|
63
|
-
|
|
64
|
-
# 类型检查
|
|
65
|
-
pnpm typecheck
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## 文件结构
|
|
69
|
-
|
|
70
|
-
- `index.ts` - 插件入口
|
|
71
|
-
- `src/channel.ts` - ChannelPlugin 定义
|
|
72
|
-
- `src/runtime.ts` - 插件 runtime
|
|
73
|
-
- `src/types.ts` - 类型定义
|
|
74
|
-
- `src/monitor.ts` - WebSocket 连接与断线重连
|
|
75
|
-
- `src/bot.ts` - 消息处理与 Agent 调用
|
|
76
|
-
|
|
77
|
-
## 后续迭代
|
|
78
|
-
|
|
79
|
-
- [ ] Token 认证
|
|
80
|
-
- [ ] 流式输出
|
|
81
|
-
- [ ] Typing 指示
|
|
82
|
-
- [ ] messageId 去重
|
|
83
|
-
- [ ] 错误消息类型
|