@searchfe/openclaw-baiduapp 0.1.0 → 0.1.2

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 CHANGED
@@ -53,12 +53,12 @@ openclaw plugins install @searchfe/openclaw-baiduapp
53
53
  ### 使用命令行配置
54
54
 
55
55
  ```bash
56
- openclaw config set channels.baidu-app.enabled true
57
- openclaw config set channels.baidu-app.webhookPath /baidu-app
58
- openclaw config set channels.baidu-app.token your-token
59
- openclaw config set channels.baidu-app.encodingAESKey your-43-char-encoding-aes-key
60
- openclaw config set channels.baidu-app.appKey your-app-key
61
- openclaw config set channels.baidu-app.appSecret your-app-secret
56
+ openclaw config set channels.openclaw-baiduapp.enabled true
57
+ openclaw config set channels.openclaw-baiduapp.webhookPath /openclaw-baiduapp
58
+ openclaw config set channels.openclaw-baiduapp.token your-token
59
+ openclaw config set channels.openclaw-baiduapp.encodingAESKey your-43-char-encoding-aes-key
60
+ openclaw config set channels.openclaw-baiduapp.appKey your-app-key
61
+ openclaw config set channels.openclaw-baiduapp.appSecret your-app-secret
62
62
  ```
63
63
 
64
64
  ### 或直接编辑配置文件
@@ -68,9 +68,9 @@ openclaw config set channels.baidu-app.appSecret your-app-secret
68
68
  ```json
69
69
  {
70
70
  "channels": {
71
- "baidu-app": {
71
+ "openclaw-baiduapp": {
72
72
  "enabled": true,
73
- "webhookPath": "/baidu-app",
73
+ "webhookPath": "/openclaw-baiduapp",
74
74
  "token": "your-token",
75
75
  "encodingAESKey": "your-43-char-encoding-aes-key",
76
76
  "appKey": "your-app-key",
@@ -130,7 +130,7 @@ openclaw gateway restart
130
130
  ```json
131
131
  {
132
132
  "channels": {
133
- "baidu-app": {
133
+ "openclaw-baiduapp": {
134
134
  "enabled": true,
135
135
  "dmPolicy": "open",
136
136
  "allowFrom": []
@@ -149,18 +149,18 @@ openclaw gateway restart
149
149
  ```json
150
150
  {
151
151
  "channels": {
152
- "baidu-app": {
152
+ "openclaw-baiduapp": {
153
153
  "enabled": true,
154
154
  "accounts": {
155
155
  "bot1": {
156
- "webhookPath": "/baidu-app-1",
156
+ "webhookPath": "/openclaw-baiduapp-1",
157
157
  "token": "token-1",
158
158
  "encodingAESKey": "key-1",
159
159
  "appKey": "app-key-1",
160
160
  "appSecret": "secret-1"
161
161
  },
162
162
  "bot2": {
163
- "webhookPath": "/baidu-app-2",
163
+ "webhookPath": "/openclaw-baiduapp-2",
164
164
  "token": "token-2",
165
165
  "encodingAESKey": "key-2",
166
166
  "appKey": "app-key-2",
@@ -196,8 +196,8 @@ openclaw gateway restart
196
196
  # 使用 user: 前缀
197
197
  send user:userId123 你好
198
198
 
199
- # 使用 baidu-app: 完整前缀
200
- send baidu-app:user:userId123 你好
199
+ # 使用 openclaw-baiduapp: 完整前缀
200
+ send openclaw-baiduapp:user:userId123 你好
201
201
 
202
202
  # 指定账户
203
203
  send user:userId123@bot1 你好
package/dist/index.d.ts CHANGED
@@ -1,18 +1,15 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
2
 
3
- type BaiduAppDmPolicy = 'open' | 'pairing' | 'allowlist' | 'disabled';
4
3
  interface BaiduAppAccountConfig {
5
4
  name?: string;
6
5
  enabled?: boolean;
7
6
  webhookPath?: string;
8
7
  token?: string;
9
8
  encodingAESKey?: string;
10
- receiveId?: string;
11
9
  appKey?: string;
12
10
  appSecret?: string;
11
+ apiBase?: string;
13
12
  welcomeText?: string;
14
- dmPolicy?: BaiduAppDmPolicy;
15
- allowFrom?: string[];
16
13
  }
17
14
  type BaiduAppConfig = BaiduAppAccountConfig & {
18
15
  accounts?: Record<string, BaiduAppAccountConfig>;
@@ -25,29 +22,20 @@ interface ResolvedBaiduAppAccount {
25
22
  configured: boolean;
26
23
  token?: string;
27
24
  encodingAESKey?: string;
28
- receiveId: string;
29
25
  appKey?: string;
30
26
  appSecret?: string;
27
+ apiBase: string;
31
28
  canSendActive: boolean;
32
29
  config: BaiduAppAccountConfig;
33
30
  }
34
- interface BaiduAppSendTarget {
35
- userId: string;
36
- }
37
- interface AccessTokenCacheEntry {
38
- token: string;
39
- expiresAt: number;
40
- }
41
31
  interface BaiduAppInboundBase {
42
32
  MsgId?: string;
43
33
  msgid?: string;
44
34
  aibotid?: string;
45
35
  response_url?: string;
46
36
  from?: {
47
- userid?: string;
48
37
  appkey?: string;
49
38
  };
50
- FromUserName?: string;
51
39
  ToUserName?: string;
52
40
  CreateTime?: number;
53
41
  MsgType?: string;
@@ -82,18 +70,18 @@ interface PluginConfig {
82
70
  store?: unknown;
83
71
  };
84
72
  channels?: {
85
- 'baidu-app'?: BaiduAppConfig;
73
+ 'openclaw-baiduapp'?: BaiduAppConfig;
86
74
  };
87
75
  }
88
76
 
89
77
  declare const baiduAppPlugin: {
90
78
  id: string;
91
79
  meta: {
92
- id: "baidu-app";
80
+ id: "openclaw-baiduapp";
93
81
  label: "Baidu App";
94
82
  selectionLabel: "Baidu Search AI (百度搜索对话式AI)";
95
- docsPath: "/channels/baidu-app";
96
- docsLabel: "baidu-app";
83
+ docsPath: "/channels/openclaw-baiduapp";
84
+ docsLabel: "openclaw-baiduapp";
97
85
  blurb: "百度搜索对话式AI,支持主动发送消息";
98
86
  aliases: readonly ["baidu-ai", "百度搜索AI"];
99
87
  order: 85;
@@ -128,27 +116,17 @@ declare const baiduAppPlugin: {
128
116
  encodingAESKey: {
129
117
  type: string;
130
118
  };
131
- receiveId: {
132
- type: string;
133
- };
134
119
  appKey: {
135
120
  type: string;
136
121
  };
137
122
  appSecret: {
138
123
  type: string;
139
124
  };
140
- welcomeText: {
125
+ apiBase: {
141
126
  type: string;
142
127
  };
143
- dmPolicy: {
128
+ welcomeText: {
144
129
  type: string;
145
- enum: string[];
146
- };
147
- allowFrom: {
148
- type: string;
149
- items: {
150
- type: string;
151
- };
152
130
  };
153
131
  defaultAccount: {
154
132
  type: string;
@@ -174,27 +152,17 @@ declare const baiduAppPlugin: {
174
152
  encodingAESKey: {
175
153
  type: string;
176
154
  };
177
- receiveId: {
178
- type: string;
179
- };
180
155
  appKey: {
181
156
  type: string;
182
157
  };
183
158
  appSecret: {
184
159
  type: string;
185
160
  };
186
- welcomeText: {
187
- type: string;
188
- };
189
- dmPolicy: {
161
+ apiBase: {
190
162
  type: string;
191
- enum: string[];
192
163
  };
193
- allowFrom: {
164
+ welcomeText: {
194
165
  type: string;
195
- items: {
196
- type: string;
197
- };
198
166
  };
199
167
  };
200
168
  };
@@ -227,13 +195,6 @@ declare const baiduAppPlugin: {
227
195
  canSendActive: boolean;
228
196
  webhookPath: string;
229
197
  };
230
- resolveAllowFrom: (params: {
231
- cfg: PluginConfig;
232
- accountId?: string;
233
- }) => string[];
234
- formatAllowFrom: (params: {
235
- allowFrom: Array<string | number>;
236
- }) => string[];
237
198
  };
238
199
  directory: {
239
200
  canResolve: (params: {
@@ -273,6 +234,18 @@ declare const baiduAppPlugin: {
273
234
  messageId: string;
274
235
  error?: Error;
275
236
  }>;
237
+ sendMedia: (params: {
238
+ cfg: PluginConfig;
239
+ accountId?: string | null;
240
+ to: string;
241
+ text: string;
242
+ mediaUrl?: string;
243
+ }) => Promise<{
244
+ channel: string;
245
+ ok: boolean;
246
+ messageId: string;
247
+ error?: Error;
248
+ }>;
276
249
  };
277
250
  gateway: {
278
251
  startAccount: (ctx: {
@@ -385,9 +358,6 @@ interface PluginRuntime {
385
358
  declare function setBaiduAppRuntime(next: PluginRuntime): void;
386
359
  declare function getBaiduAppRuntime(): PluginRuntime;
387
360
 
388
- declare function getAccessToken(account: ResolvedBaiduAppAccount): Promise<string>;
389
- declare function clearAccessTokenCache(account: ResolvedBaiduAppAccount): void;
390
- declare function clearAllAccessTokenCache(): void;
391
361
  interface SendMessageResult {
392
362
  ok: boolean;
393
363
  errcode?: number;
@@ -395,7 +365,12 @@ interface SendMessageResult {
395
365
  invaliduser?: string;
396
366
  msgid?: string;
397
367
  }
398
- declare function sendBaiduAppMessage(account: ResolvedBaiduAppAccount, target: BaiduAppSendTarget, message: string): Promise<SendMessageResult>;
368
+ interface SendMessageOptions$1 {
369
+ msgid?: string;
370
+ streamId?: string;
371
+ chunkKey?: number;
372
+ }
373
+ declare function sendBaiduAppMessage(account: ResolvedBaiduAppAccount, message: string, options?: SendMessageOptions$1): Promise<SendMessageResult>;
399
374
 
400
375
  interface SendMessageOptions {
401
376
  text?: string;
@@ -405,10 +380,8 @@ interface SendResult {
405
380
  msgid?: string;
406
381
  error?: string;
407
382
  }
408
- declare function normalizeTarget(target: string, type: 'user'): string;
409
- declare function parseTarget(target: string): BaiduAppSendTarget;
410
- declare function sendBaiduDM(account: ResolvedBaiduAppAccount, userId: string, options: SendMessageOptions): Promise<SendResult>;
411
- declare function sendBaidu(account: ResolvedBaiduAppAccount, target: string, options: SendMessageOptions): Promise<SendResult>;
383
+ declare function sendBaiduDM(account: ResolvedBaiduAppAccount, options: SendMessageOptions): Promise<SendResult>;
384
+ declare function sendBaidu(account: ResolvedBaiduAppAccount, options: SendMessageOptions): Promise<SendResult>;
412
385
 
413
386
  interface MoltbotPluginApi {
414
387
  registerChannel: (opts: {
@@ -431,4 +404,4 @@ declare const plugin: {
431
404
  register(api: MoltbotPluginApi): void;
432
405
  };
433
406
 
434
- export { type AccessTokenCacheEntry, type BaiduAppConfig, type BaiduAppDmPolicy, type BaiduAppInboundMessage, type BaiduAppSendTarget, DEFAULT_ACCOUNT_ID, type MoltbotPluginApi, type ResolvedBaiduAppAccount, type SendMessageOptions, type SendResult, baiduAppPlugin, clearAccessTokenCache, clearAllAccessTokenCache, plugin as default, getAccessToken, getBaiduAppRuntime, normalizeTarget, parseTarget, sendBaidu, sendBaiduAppMessage, sendBaiduDM, setBaiduAppRuntime };
407
+ export { type BaiduAppConfig, type BaiduAppInboundMessage, DEFAULT_ACCOUNT_ID, type MoltbotPluginApi, type ResolvedBaiduAppAccount, type SendMessageOptions$1 as SendBaiduAppMessageOptions, type SendMessageOptions, type SendResult, baiduAppPlugin, plugin as default, getBaiduAppRuntime, sendBaidu, sendBaiduAppMessage, sendBaiduDM, setBaiduAppRuntime };