ddchat 0.4.1 → 0.4.3
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/README.md +22 -0
- package/index.js +11 -11
- package/openclaw.plugin.json +148 -148
- package/package.json +36 -36
- package/setup-entry.js +8 -8
- package/src/channel.js +99 -99
- package/src/constants.js +4 -4
- package/src/dedupe.js +44 -44
- package/src/gateway.js +211 -211
- package/src/inbound.js +363 -363
- package/src/outbound.js +150 -150
- package/src/pairing.js +8 -8
- package/src/runtime.js +20 -20
- package/src/session.js +13 -13
- package/src/types.js +73 -73
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 本地安装ddchat插件
|
|
2
|
+
```shell
|
|
3
|
+
openclaw plugins install "安装包路径"
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
# 仓库管理ddchat插件
|
|
7
|
+
```shell
|
|
8
|
+
openclaw plugins install ddchat # 安装插件
|
|
9
|
+
openclaw plugins update ddchat # 更新插件
|
|
10
|
+
openclaw plugins uninstall ddchat # 卸载插件
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 默认default账号
|
|
15
|
+
```shell
|
|
16
|
+
openclaw channels add --channel ddchat --token "appId:appSecret"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
# 多个账号时指定账户名 避免覆盖
|
|
20
|
+
```shell
|
|
21
|
+
openclaw channels add --channel ddchat --account xxx --token "appId:appSecret"
|
|
22
|
+
```
|
package/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
-
import { ddchatPlugin } from "./src/channel.js";
|
|
3
|
-
import { registerDdchatWebhook } from "./src/inbound.js";
|
|
4
|
-
export { ddchatPlugin } from "./src/channel.js";
|
|
5
|
-
export default defineChannelPluginEntry({
|
|
6
|
-
id: "ddchat",
|
|
7
|
-
name: "DDChat",
|
|
8
|
-
description: "DDChat channel plugin",
|
|
9
|
-
plugin: ddchatPlugin,
|
|
10
|
-
registerFull: registerDdchatWebhook,
|
|
11
|
-
});
|
|
1
|
+
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import { ddchatPlugin } from "./src/channel.js";
|
|
3
|
+
import { registerDdchatWebhook } from "./src/inbound.js";
|
|
4
|
+
export { ddchatPlugin } from "./src/channel.js";
|
|
5
|
+
export default defineChannelPluginEntry({
|
|
6
|
+
id: "ddchat",
|
|
7
|
+
name: "DDChat",
|
|
8
|
+
description: "DDChat channel plugin",
|
|
9
|
+
plugin: ddchatPlugin,
|
|
10
|
+
registerFull: registerDdchatWebhook,
|
|
11
|
+
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "ddchat",
|
|
3
|
-
"kind": "channel",
|
|
4
|
-
"channels": ["ddchat"],
|
|
5
|
-
"configSchema": {
|
|
6
|
-
"type": "object",
|
|
7
|
-
"additionalProperties": false,
|
|
8
|
-
"properties": {}
|
|
9
|
-
},
|
|
10
|
-
"channelConfigs": {
|
|
11
|
-
"ddchat": {
|
|
12
|
-
"label": "DDChat",
|
|
13
|
-
"description": "DDChat internal IM integration.",
|
|
14
|
-
"schema": {
|
|
15
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"additionalProperties": false,
|
|
18
|
-
"properties": {
|
|
19
|
-
"name": { "type": "string" },
|
|
20
|
-
"enabled": { "type": "boolean" },
|
|
21
|
-
"token": { "type": "string" },
|
|
22
|
-
"wsUrl": { "type": "string" },
|
|
23
|
-
"webhookPath": { "type": "string" },
|
|
24
|
-
"webhookPort": {
|
|
25
|
-
"type": "integer",
|
|
26
|
-
"minimum": 0,
|
|
27
|
-
"maximum": 9007199254740991
|
|
28
|
-
},
|
|
29
|
-
"connectionMode": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"enum": ["websocket", "webhook"]
|
|
32
|
-
},
|
|
33
|
-
"dmPolicy": {
|
|
34
|
-
"type": "string",
|
|
35
|
-
"enum": ["open", "pairing", "allowlist"]
|
|
36
|
-
},
|
|
37
|
-
"groupPolicy": {
|
|
38
|
-
"type": "string",
|
|
39
|
-
"enum": ["open", "allowlist", "disabled"]
|
|
40
|
-
},
|
|
41
|
-
"requireMention": { "type": "boolean" },
|
|
42
|
-
"streaming": { "type": "boolean" },
|
|
43
|
-
"streamingMode": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"enum": ["chunk", "token"]
|
|
46
|
-
},
|
|
47
|
-
"allowFrom": {
|
|
48
|
-
"type": "array",
|
|
49
|
-
"items": {
|
|
50
|
-
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"groupAllowFrom": {
|
|
54
|
-
"type": "array",
|
|
55
|
-
"items": {
|
|
56
|
-
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"heartbeatSec": {
|
|
60
|
-
"type": "number",
|
|
61
|
-
"minimum": 15
|
|
62
|
-
},
|
|
63
|
-
"defaultAccount": { "type": "string" },
|
|
64
|
-
"accounts": {
|
|
65
|
-
"type": "object",
|
|
66
|
-
"propertyNames": { "type": "string" },
|
|
67
|
-
"additionalProperties": {
|
|
68
|
-
"type": "object",
|
|
69
|
-
"additionalProperties": false,
|
|
70
|
-
"properties": {
|
|
71
|
-
"name": { "type": "string" },
|
|
72
|
-
"enabled": { "type": "boolean" },
|
|
73
|
-
"token": { "type": "string" },
|
|
74
|
-
"wsUrl": { "type": "string" },
|
|
75
|
-
"webhookPath": { "type": "string" },
|
|
76
|
-
"webhookPort": {
|
|
77
|
-
"type": "integer",
|
|
78
|
-
"minimum": 0,
|
|
79
|
-
"maximum": 9007199254740991
|
|
80
|
-
},
|
|
81
|
-
"connectionMode": {
|
|
82
|
-
"type": "string",
|
|
83
|
-
"enum": ["websocket", "webhook"]
|
|
84
|
-
},
|
|
85
|
-
"dmPolicy": {
|
|
86
|
-
"type": "string",
|
|
87
|
-
"enum": ["open", "pairing", "allowlist"]
|
|
88
|
-
},
|
|
89
|
-
"groupPolicy": {
|
|
90
|
-
"type": "string",
|
|
91
|
-
"enum": ["open", "allowlist", "disabled"]
|
|
92
|
-
},
|
|
93
|
-
"requireMention": { "type": "boolean" },
|
|
94
|
-
"streaming": { "type": "boolean" },
|
|
95
|
-
"streamingMode": {
|
|
96
|
-
"type": "string",
|
|
97
|
-
"enum": ["chunk", "token"]
|
|
98
|
-
},
|
|
99
|
-
"allowFrom": {
|
|
100
|
-
"type": "array",
|
|
101
|
-
"items": {
|
|
102
|
-
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
"groupAllowFrom": {
|
|
106
|
-
"type": "array",
|
|
107
|
-
"items": {
|
|
108
|
-
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"heartbeatSec": {
|
|
112
|
-
"type": "number",
|
|
113
|
-
"minimum": 15
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
"uiHints": {
|
|
121
|
-
"": {
|
|
122
|
-
"label": "DDChat",
|
|
123
|
-
"help": "DDChat channel provider configuration for WebSocket/Webhook transport, account credentials, and access policies."
|
|
124
|
-
},
|
|
125
|
-
"token": {
|
|
126
|
-
"label": "DDChat Token",
|
|
127
|
-
"sensitive": true
|
|
128
|
-
},
|
|
129
|
-
"accounts.*.token": {
|
|
130
|
-
"label": "DDChat Token",
|
|
131
|
-
"sensitive": true
|
|
132
|
-
},
|
|
133
|
-
"connectionMode": {
|
|
134
|
-
"label": "DDChat Connection Mode"
|
|
135
|
-
},
|
|
136
|
-
"dmPolicy": {
|
|
137
|
-
"label": "DDChat DM Policy"
|
|
138
|
-
},
|
|
139
|
-
"groupPolicy": {
|
|
140
|
-
"label": "DDChat Group Policy"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"commands": {
|
|
144
|
-
"nativeCommandsAutoEnabled": false,
|
|
145
|
-
"nativeSkillsAutoEnabled": false
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
2
|
+
"id": "ddchat",
|
|
3
|
+
"kind": "channel",
|
|
4
|
+
"channels": ["ddchat"],
|
|
5
|
+
"configSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {}
|
|
9
|
+
},
|
|
10
|
+
"channelConfigs": {
|
|
11
|
+
"ddchat": {
|
|
12
|
+
"label": "DDChat",
|
|
13
|
+
"description": "DDChat internal IM integration.",
|
|
14
|
+
"schema": {
|
|
15
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"properties": {
|
|
19
|
+
"name": { "type": "string" },
|
|
20
|
+
"enabled": { "type": "boolean" },
|
|
21
|
+
"token": { "type": "string" },
|
|
22
|
+
"wsUrl": { "type": "string" },
|
|
23
|
+
"webhookPath": { "type": "string" },
|
|
24
|
+
"webhookPort": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"minimum": 0,
|
|
27
|
+
"maximum": 9007199254740991
|
|
28
|
+
},
|
|
29
|
+
"connectionMode": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["websocket", "webhook"]
|
|
32
|
+
},
|
|
33
|
+
"dmPolicy": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["open", "pairing", "allowlist"]
|
|
36
|
+
},
|
|
37
|
+
"groupPolicy": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
40
|
+
},
|
|
41
|
+
"requireMention": { "type": "boolean" },
|
|
42
|
+
"streaming": { "type": "boolean" },
|
|
43
|
+
"streamingMode": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["chunk", "token"]
|
|
46
|
+
},
|
|
47
|
+
"allowFrom": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {
|
|
50
|
+
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"groupAllowFrom": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": {
|
|
56
|
+
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"heartbeatSec": {
|
|
60
|
+
"type": "number",
|
|
61
|
+
"minimum": 15
|
|
62
|
+
},
|
|
63
|
+
"defaultAccount": { "type": "string" },
|
|
64
|
+
"accounts": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"propertyNames": { "type": "string" },
|
|
67
|
+
"additionalProperties": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"properties": {
|
|
71
|
+
"name": { "type": "string" },
|
|
72
|
+
"enabled": { "type": "boolean" },
|
|
73
|
+
"token": { "type": "string" },
|
|
74
|
+
"wsUrl": { "type": "string" },
|
|
75
|
+
"webhookPath": { "type": "string" },
|
|
76
|
+
"webhookPort": {
|
|
77
|
+
"type": "integer",
|
|
78
|
+
"minimum": 0,
|
|
79
|
+
"maximum": 9007199254740991
|
|
80
|
+
},
|
|
81
|
+
"connectionMode": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"enum": ["websocket", "webhook"]
|
|
84
|
+
},
|
|
85
|
+
"dmPolicy": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": ["open", "pairing", "allowlist"]
|
|
88
|
+
},
|
|
89
|
+
"groupPolicy": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
92
|
+
},
|
|
93
|
+
"requireMention": { "type": "boolean" },
|
|
94
|
+
"streaming": { "type": "boolean" },
|
|
95
|
+
"streamingMode": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"enum": ["chunk", "token"]
|
|
98
|
+
},
|
|
99
|
+
"allowFrom": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"groupAllowFrom": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"items": {
|
|
108
|
+
"anyOf": [{ "type": "string" }, { "type": "number" }]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"heartbeatSec": {
|
|
112
|
+
"type": "number",
|
|
113
|
+
"minimum": 15
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"uiHints": {
|
|
121
|
+
"": {
|
|
122
|
+
"label": "DDChat",
|
|
123
|
+
"help": "DDChat channel provider configuration for WebSocket/Webhook transport, account credentials, and access policies."
|
|
124
|
+
},
|
|
125
|
+
"token": {
|
|
126
|
+
"label": "DDChat Token",
|
|
127
|
+
"sensitive": true
|
|
128
|
+
},
|
|
129
|
+
"accounts.*.token": {
|
|
130
|
+
"label": "DDChat Token",
|
|
131
|
+
"sensitive": true
|
|
132
|
+
},
|
|
133
|
+
"connectionMode": {
|
|
134
|
+
"label": "DDChat Connection Mode"
|
|
135
|
+
},
|
|
136
|
+
"dmPolicy": {
|
|
137
|
+
"label": "DDChat DM Policy"
|
|
138
|
+
},
|
|
139
|
+
"groupPolicy": {
|
|
140
|
+
"label": "DDChat Group Policy"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"commands": {
|
|
144
|
+
"nativeCommandsAutoEnabled": false,
|
|
145
|
+
"nativeSkillsAutoEnabled": false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ddchat",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "DDChat channel plugin for OpenClaw",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./index.js",
|
|
7
|
-
"peerDependencies": {
|
|
8
|
-
"openclaw": ">=2026.2.0"
|
|
9
|
-
},
|
|
10
|
-
"peerDependenciesMeta": {
|
|
11
|
-
"openclaw": {
|
|
12
|
-
"optional": true
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"openclaw": {
|
|
16
|
-
"extensions": [
|
|
17
|
-
"./index.js"
|
|
18
|
-
],
|
|
19
|
-
"setupEntry": "./setup-entry.js",
|
|
20
|
-
"channel": {
|
|
21
|
-
"id": "ddchat",
|
|
22
|
-
"label": "DDChat",
|
|
23
|
-
"selectionLabel": "DDChat (IM)",
|
|
24
|
-
"detailLabel": "DDChat IM",
|
|
25
|
-
"docsPath": "/channels/ddchat",
|
|
26
|
-
"docsLabel": "ddchat",
|
|
27
|
-
"blurb": "DDChat internal IM integration.",
|
|
28
|
-
"order": 90
|
|
29
|
-
},
|
|
30
|
-
"install": {
|
|
31
|
-
"npmSpec": "ddchat",
|
|
32
|
-
"localPath": "ddchat",
|
|
33
|
-
"defaultChoice": "local"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ddchat",
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"description": "DDChat channel plugin for OpenClaw",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"openclaw": ">=2026.2.0"
|
|
9
|
+
},
|
|
10
|
+
"peerDependenciesMeta": {
|
|
11
|
+
"openclaw": {
|
|
12
|
+
"optional": true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"openclaw": {
|
|
16
|
+
"extensions": [
|
|
17
|
+
"./index.js"
|
|
18
|
+
],
|
|
19
|
+
"setupEntry": "./setup-entry.js",
|
|
20
|
+
"channel": {
|
|
21
|
+
"id": "ddchat",
|
|
22
|
+
"label": "DDChat",
|
|
23
|
+
"selectionLabel": "DDChat (IM)",
|
|
24
|
+
"detailLabel": "DDChat IM",
|
|
25
|
+
"docsPath": "/channels/ddchat",
|
|
26
|
+
"docsLabel": "ddchat",
|
|
27
|
+
"blurb": "DDChat internal IM integration.",
|
|
28
|
+
"order": 90
|
|
29
|
+
},
|
|
30
|
+
"install": {
|
|
31
|
+
"npmSpec": "ddchat",
|
|
32
|
+
"localPath": "ddchat",
|
|
33
|
+
"defaultChoice": "local"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/setup-entry.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
-
import { ddchatPlugin } from "./src/channel.js";
|
|
3
|
-
export default defineChannelPluginEntry({
|
|
4
|
-
id: "ddchat",
|
|
5
|
-
name: "DDChat",
|
|
6
|
-
description: "DDChat channel setup plugin",
|
|
7
|
-
plugin: ddchatPlugin,
|
|
8
|
-
});
|
|
1
|
+
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import { ddchatPlugin } from "./src/channel.js";
|
|
3
|
+
export default defineChannelPluginEntry({
|
|
4
|
+
id: "ddchat",
|
|
5
|
+
name: "DDChat",
|
|
6
|
+
description: "DDChat channel setup plugin",
|
|
7
|
+
plugin: ddchatPlugin,
|
|
8
|
+
});
|
package/src/channel.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
2
|
-
import { patchScopedAccountConfig, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
|
|
3
|
-
import { DDCHAT_CHANNEL_ID } from "./constants.js";
|
|
4
|
-
import { ddchatGateway } from "./gateway.js";
|
|
5
|
-
import { ddchatOutbound } from "./outbound.js";
|
|
6
|
-
import { ddchatPairing } from "./pairing.js";
|
|
7
|
-
import { listDdchatAccountIds, resolveDdchatAccount } from "./types.js";
|
|
8
|
-
function inspectDdchatAccount(cfg, accountId) {
|
|
9
|
-
const account = resolveDdchatAccount(cfg, accountId);
|
|
10
|
-
return {
|
|
11
|
-
enabled: account.enabled,
|
|
12
|
-
configured: account.configured,
|
|
13
|
-
tokenStatus: account.token ? "available" : "missing",
|
|
14
|
-
connectionMode: account.connectionMode,
|
|
15
|
-
dmPolicy: account.dmPolicy,
|
|
16
|
-
groupPolicy: account.groupPolicy,
|
|
17
|
-
streaming: account.streaming,
|
|
18
|
-
streamingMode: account.streamingMode,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export const ddchatPlugin = createChatChannelPlugin({
|
|
22
|
-
base: {
|
|
23
|
-
id: DDCHAT_CHANNEL_ID,
|
|
24
|
-
meta: {
|
|
25
|
-
id: DDCHAT_CHANNEL_ID,
|
|
26
|
-
label: "DDChat",
|
|
27
|
-
selectionLabel: "DDChat (IM)",
|
|
28
|
-
docsPath: "/channels/ddchat",
|
|
29
|
-
blurb: "DDChat internal IM integration.",
|
|
30
|
-
order: 90,
|
|
31
|
-
},
|
|
32
|
-
capabilities: {
|
|
33
|
-
chatTypes: ["direct", "channel"],
|
|
34
|
-
media: true,
|
|
35
|
-
threads: false,
|
|
36
|
-
polls: false,
|
|
37
|
-
},
|
|
38
|
-
config: {
|
|
39
|
-
listAccountIds: (cfg) => listDdchatAccountIds(cfg),
|
|
40
|
-
resolveAccount: (cfg, accountId) => resolveDdchatAccount(cfg, accountId),
|
|
41
|
-
inspectAccount: inspectDdchatAccount,
|
|
42
|
-
isEnabled: (account) => account.enabled,
|
|
43
|
-
isConfigured: (account) => account.configured,
|
|
44
|
-
},
|
|
45
|
-
setup: {
|
|
46
|
-
resolveAccountId: ({ accountId }) => accountId ?? "default",
|
|
47
|
-
applyAccountName: ({ cfg, accountId, name }) => prepareScopedSetupConfig({
|
|
48
|
-
cfg,
|
|
49
|
-
channelKey: DDCHAT_CHANNEL_ID,
|
|
50
|
-
accountId,
|
|
51
|
-
name,
|
|
52
|
-
alwaysUseAccounts: true,
|
|
53
|
-
}),
|
|
54
|
-
validateInput: ({ input }) => {
|
|
55
|
-
const token = typeof input.token === "string" ? input.token.trim() : "";
|
|
56
|
-
return token ? null : "ddchat requires --token";
|
|
57
|
-
},
|
|
58
|
-
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
59
|
-
const token = typeof input.token === "string" ? input.token.trim() : "";
|
|
60
|
-
const next = prepareScopedSetupConfig({
|
|
61
|
-
cfg,
|
|
62
|
-
channelKey: DDCHAT_CHANNEL_ID,
|
|
63
|
-
accountId,
|
|
64
|
-
name: input.name,
|
|
65
|
-
alwaysUseAccounts: true,
|
|
66
|
-
});
|
|
67
|
-
const patch = {};
|
|
68
|
-
if (token) {
|
|
69
|
-
patch.token = token;
|
|
70
|
-
}
|
|
71
|
-
return patchScopedAccountConfig({
|
|
72
|
-
cfg: next,
|
|
73
|
-
channelKey: DDCHAT_CHANNEL_ID,
|
|
74
|
-
accountId,
|
|
75
|
-
patch,
|
|
76
|
-
accountPatch: patch,
|
|
77
|
-
ensureChannelEnabled: true,
|
|
78
|
-
ensureAccountEnabled: true,
|
|
79
|
-
scopeDefaultToAccounts: true,
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
gateway: ddchatGateway,
|
|
84
|
-
},
|
|
85
|
-
pairing: ddchatPairing,
|
|
86
|
-
security: {
|
|
87
|
-
dm: {
|
|
88
|
-
channelKey: DDCHAT_CHANNEL_ID,
|
|
89
|
-
resolvePolicy: (account) => account.dmPolicy,
|
|
90
|
-
resolveAllowFrom: (account) => account.allowFrom,
|
|
91
|
-
defaultPolicy: "pairing",
|
|
92
|
-
normalizeEntry: (raw) => raw.replace(/^ddchat:/i, "").trim(),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
outbound: ddchatOutbound,
|
|
96
|
-
threading: {
|
|
97
|
-
topLevelReplyToMode: "off",
|
|
98
|
-
},
|
|
99
|
-
});
|
|
1
|
+
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import { patchScopedAccountConfig, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
|
|
3
|
+
import { DDCHAT_CHANNEL_ID } from "./constants.js";
|
|
4
|
+
import { ddchatGateway } from "./gateway.js";
|
|
5
|
+
import { ddchatOutbound } from "./outbound.js";
|
|
6
|
+
import { ddchatPairing } from "./pairing.js";
|
|
7
|
+
import { listDdchatAccountIds, resolveDdchatAccount } from "./types.js";
|
|
8
|
+
function inspectDdchatAccount(cfg, accountId) {
|
|
9
|
+
const account = resolveDdchatAccount(cfg, accountId);
|
|
10
|
+
return {
|
|
11
|
+
enabled: account.enabled,
|
|
12
|
+
configured: account.configured,
|
|
13
|
+
tokenStatus: account.token ? "available" : "missing",
|
|
14
|
+
connectionMode: account.connectionMode,
|
|
15
|
+
dmPolicy: account.dmPolicy,
|
|
16
|
+
groupPolicy: account.groupPolicy,
|
|
17
|
+
streaming: account.streaming,
|
|
18
|
+
streamingMode: account.streamingMode,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const ddchatPlugin = createChatChannelPlugin({
|
|
22
|
+
base: {
|
|
23
|
+
id: DDCHAT_CHANNEL_ID,
|
|
24
|
+
meta: {
|
|
25
|
+
id: DDCHAT_CHANNEL_ID,
|
|
26
|
+
label: "DDChat",
|
|
27
|
+
selectionLabel: "DDChat (IM)",
|
|
28
|
+
docsPath: "/channels/ddchat",
|
|
29
|
+
blurb: "DDChat internal IM integration.",
|
|
30
|
+
order: 90,
|
|
31
|
+
},
|
|
32
|
+
capabilities: {
|
|
33
|
+
chatTypes: ["direct", "channel"],
|
|
34
|
+
media: true,
|
|
35
|
+
threads: false,
|
|
36
|
+
polls: false,
|
|
37
|
+
},
|
|
38
|
+
config: {
|
|
39
|
+
listAccountIds: (cfg) => listDdchatAccountIds(cfg),
|
|
40
|
+
resolveAccount: (cfg, accountId) => resolveDdchatAccount(cfg, accountId),
|
|
41
|
+
inspectAccount: inspectDdchatAccount,
|
|
42
|
+
isEnabled: (account) => account.enabled,
|
|
43
|
+
isConfigured: (account) => account.configured,
|
|
44
|
+
},
|
|
45
|
+
setup: {
|
|
46
|
+
resolveAccountId: ({ accountId }) => accountId ?? "default",
|
|
47
|
+
applyAccountName: ({ cfg, accountId, name }) => prepareScopedSetupConfig({
|
|
48
|
+
cfg,
|
|
49
|
+
channelKey: DDCHAT_CHANNEL_ID,
|
|
50
|
+
accountId,
|
|
51
|
+
name,
|
|
52
|
+
alwaysUseAccounts: true,
|
|
53
|
+
}),
|
|
54
|
+
validateInput: ({ input }) => {
|
|
55
|
+
const token = typeof input.token === "string" ? input.token.trim() : "";
|
|
56
|
+
return token ? null : "ddchat requires --token";
|
|
57
|
+
},
|
|
58
|
+
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
59
|
+
const token = typeof input.token === "string" ? input.token.trim() : "";
|
|
60
|
+
const next = prepareScopedSetupConfig({
|
|
61
|
+
cfg,
|
|
62
|
+
channelKey: DDCHAT_CHANNEL_ID,
|
|
63
|
+
accountId,
|
|
64
|
+
name: input.name,
|
|
65
|
+
alwaysUseAccounts: true,
|
|
66
|
+
});
|
|
67
|
+
const patch = {};
|
|
68
|
+
if (token) {
|
|
69
|
+
patch.token = token;
|
|
70
|
+
}
|
|
71
|
+
return patchScopedAccountConfig({
|
|
72
|
+
cfg: next,
|
|
73
|
+
channelKey: DDCHAT_CHANNEL_ID,
|
|
74
|
+
accountId,
|
|
75
|
+
patch,
|
|
76
|
+
accountPatch: patch,
|
|
77
|
+
ensureChannelEnabled: true,
|
|
78
|
+
ensureAccountEnabled: true,
|
|
79
|
+
scopeDefaultToAccounts: true,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
gateway: ddchatGateway,
|
|
84
|
+
},
|
|
85
|
+
pairing: ddchatPairing,
|
|
86
|
+
security: {
|
|
87
|
+
dm: {
|
|
88
|
+
channelKey: DDCHAT_CHANNEL_ID,
|
|
89
|
+
resolvePolicy: (account) => account.dmPolicy,
|
|
90
|
+
resolveAllowFrom: (account) => account.allowFrom,
|
|
91
|
+
defaultPolicy: "pairing",
|
|
92
|
+
normalizeEntry: (raw) => raw.replace(/^ddchat:/i, "").trim(),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
outbound: ddchatOutbound,
|
|
96
|
+
threading: {
|
|
97
|
+
topLevelReplyToMode: "off",
|
|
98
|
+
},
|
|
99
|
+
});
|
package/src/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const DDCHAT_CHANNEL_ID = "ddchat";
|
|
2
|
-
export const DDCHAT_DEFAULT_ACCOUNT_ID = "default";
|
|
3
|
-
/** Default WebSocket endpoint when `channels.ddchat.wsUrl` / per-account `wsUrl` is unset (`token` query appended at connect). */
|
|
4
|
-
export const DDCHAT_PLUGIN_WS_BASE_URL = "wss://chat.ddjf.info/socket/ai/claw";
|
|
1
|
+
export const DDCHAT_CHANNEL_ID = "ddchat";
|
|
2
|
+
export const DDCHAT_DEFAULT_ACCOUNT_ID = "default";
|
|
3
|
+
/** Default WebSocket endpoint when `channels.ddchat.wsUrl` / per-account `wsUrl` is unset (`token` query appended at connect). */
|
|
4
|
+
export const DDCHAT_PLUGIN_WS_BASE_URL = "wss://chat.ddjf.info/socket/ai/claw";
|