@xiaozhi-pro/openclaw-plugin 1.0.1 → 1.0.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 CHANGED
@@ -23,6 +23,14 @@ openclaw plugins install @xiaozhi-pro/openclaw-plugin
23
23
  > openclaw plugins install ./openclaw-plugin-1.0.0.tgz
24
24
  > ```
25
25
 
26
+ ### 更新
27
+
28
+ 如果已经安装过,需更新到最新版本:
29
+
30
+ ```bash
31
+ openclaw plugins install @xiaozhi-pro/openclaw-plugin --force
32
+ ```
33
+
26
34
  ### 配置
27
35
 
28
36
  编辑 `openclaw.json`:
@@ -69,6 +77,10 @@ pnpm run build
69
77
  ## 发布
70
78
 
71
79
  ```bash
80
+ # 发布前需要先提交commit
81
+ git add .
82
+ git commit -m 'xx'
83
+ # 然后更新版本号,本质上打了tag
72
84
  npm version patch # 1.0.0 → 1.0.1(修bug,最后一位+1)
73
85
  npm version minor # 1.0.0 → 1.1.0(新功能,中间位+1)
74
86
  npm version major # 1.0.0 → 2.0.0(破坏性变更,首位+1)
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const entry: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk/core").ChannelPlugin>;
1
+ declare const entry: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk/channel-core").ChannelPlugin>;
2
2
  export default entry;
@@ -1,2 +1,2 @@
1
- declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk/core").ChannelPlugin>;
1
+ declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk/channel-core").ChannelPlugin>;
2
2
  export default _default;
@@ -1,4 +1,3 @@
1
- import { type ChannelPlugin, defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
1
+ import { type ChannelPlugin } from "openclaw/plugin-sdk/channel-core";
2
2
  import { type ResolvedXiaozhiProAccount } from "./accounts.js";
3
3
  export declare const xiaozhiProPlugin: ChannelPlugin<ResolvedXiaozhiProAccount>;
4
- export { defineChannelPluginEntry };
@@ -4,9 +4,8 @@
4
4
  // 1. gateway.startAccount → 建立 WS 连接到小智Pro 服务端
5
5
  // 2. 收到 WS 消息 → 通过 rt.channel.inbound.run() 分发给 agent
6
6
  // 3. agent 回复 → 通过 WS 发回小智Pro
7
- import { createChatChannelPlugin, defineChannelPluginEntry, } from "openclaw/plugin-sdk/core";
8
- import { waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
9
- import { defineChannelMessageAdapter, createMessageReceiptFromOutboundResults, } from "openclaw/plugin-sdk/channel-outbound";
7
+ import { createChatChannelPlugin, } from "openclaw/plugin-sdk/channel-core";
8
+ import { waitUntilAbort } from "openclaw/plugin-sdk/channel-runtime";
10
9
  import { createEmptyChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
11
10
  import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver, } from "openclaw/plugin-sdk/channel-config-helpers";
12
11
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
@@ -17,34 +16,7 @@ import { connectXiaozhiProWs, sendXiaozhiProWsMessage, } from "./ws-client.js";
17
16
  import { isDuplicateMessage } from "./dedup.js";
18
17
  const CHANNEL_ID = "xiaozhi-pro";
19
18
  // ============================================================================
20
- // 1. 出站:agent 回复 → 通过 WS 发给小智Pro
21
- // ============================================================================
22
- const xiaozhiProMessageAdapter = defineChannelMessageAdapter({
23
- id: CHANNEL_ID,
24
- durableFinal: {
25
- capabilities: { text: true, media: false, messageSendingHooks: false },
26
- },
27
- send: {
28
- text: async (ctx) => {
29
- const account = resolveAccount(ctx.cfg, ctx.accountId ?? DEFAULT_ACCOUNT_ID);
30
- const sent = await sendXiaozhiProWsMessage(account, ctx.to, ctx.text);
31
- return {
32
- channel: CHANNEL_ID,
33
- messageId: sent.messageId,
34
- chatId: ctx.to,
35
- receipt: createMessageReceiptFromOutboundResults({
36
- results: [
37
- { channel: CHANNEL_ID, messageId: sent.messageId, chatId: ctx.to, conversationId: ctx.to },
38
- ],
39
- threadId: ctx.to,
40
- kind: "text",
41
- }),
42
- };
43
- },
44
- },
45
- });
46
- // ============================================================================
47
- // 2. 插件定义
19
+ // 1. 插件定义
48
20
  // ============================================================================
49
21
  export const xiaozhiProPlugin = createChatChannelPlugin({
50
22
  base: {
@@ -91,7 +63,7 @@ export const xiaozhiProPlugin = createChatChannelPlugin({
91
63
  },
92
64
  directory: createEmptyChannelDirectoryAdapter(),
93
65
  // ============================================================================
94
- // 3. gateway.startAccount:建立 WS 连接,收消息分发给 agent
66
+ // 2. gateway.startAccount:建立 WS 连接,收消息分发给 agent
95
67
  // ============================================================================
96
68
  gateway: {
97
69
  startAccount: async (ctx) => {
@@ -123,7 +95,6 @@ export const xiaozhiProPlugin = createChatChannelPlugin({
123
95
  });
124
96
  },
125
97
  },
126
- message: xiaozhiProMessageAdapter,
127
98
  agentPrompt: {
128
99
  messageToolHints: () => [
129
100
  "",
@@ -157,9 +128,6 @@ export const xiaozhiProPlugin = createChatChannelPlugin({
157
128
  outbound: {
158
129
  deliveryMode: "gateway",
159
130
  textChunkLimit: 2000,
160
- // TODO: 流式回复占位 — WS 天然支持增量推送,未来可接入
161
- // OpenClaw 的流式管道(live preview → finalize),届时需实现
162
- // sendStreamStart / sendStreamChunk / sendStreamFinalize
163
131
  sendText: async (ctx) => {
164
132
  const account = resolveAccount(ctx.cfg ?? {}, ctx.accountId ?? null);
165
133
  const sent = await sendXiaozhiProWsMessage(account, ctx.to, ctx.text);
@@ -167,13 +135,6 @@ export const xiaozhiProPlugin = createChatChannelPlugin({
167
135
  channel: CHANNEL_ID,
168
136
  messageId: sent.messageId,
169
137
  chatId: ctx.to,
170
- receipt: createMessageReceiptFromOutboundResults({
171
- results: [
172
- { channel: CHANNEL_ID, messageId: sent.messageId, chatId: ctx.to, conversationId: ctx.to },
173
- ],
174
- threadId: ctx.to,
175
- kind: "text",
176
- }),
177
138
  };
178
139
  },
179
140
  },
@@ -182,7 +143,7 @@ export const xiaozhiProPlugin = createChatChannelPlugin({
182
143
  // 入站分发:小智Pro WS 消息 → OpenClaw agent
183
144
  // ============================================================================
184
145
  async function dispatchXiaozhiProInboundEvent(params) {
185
- // 去重:跳过已处理过的消息(参考飞书 dedup 机制)
146
+ // 去重:跳过已处理过的消息
186
147
  if (isDuplicateMessage(params.msg.messageId)) {
187
148
  return;
188
149
  }
@@ -255,18 +216,12 @@ async function dispatchXiaozhiProInboundEvent(params) {
255
216
  if (text) {
256
217
  await sendXiaozhiProWsMessage(params.account, params.msg.senderId, text);
257
218
  }
258
- return createMessageReceiptFromOutboundResults({
259
- results: [
260
- {
261
- channel: CHANNEL_ID,
262
- messageId: `reply-${Date.now()}`,
263
- chatId: params.msg.senderId,
264
- conversationId: params.msg.senderId,
265
- },
266
- ],
267
- threadId: params.msg.senderId,
268
- kind: "text",
269
- });
219
+ return {
220
+ channel: CHANNEL_ID,
221
+ messageId: `reply-${Date.now()}`,
222
+ chatId: params.msg.senderId,
223
+ conversationId: params.msg.senderId,
224
+ };
270
225
  },
271
226
  },
272
227
  };
@@ -274,5 +229,3 @@ async function dispatchXiaozhiProInboundEvent(params) {
274
229
  },
275
230
  });
276
231
  }
277
- // 入口定义(外部插件用 defineChannelPluginEntry)
278
- export { defineChannelPluginEntry };
@@ -7,6 +7,17 @@
7
7
  "channelEnvVars": {
8
8
  "xiaozhi-pro": ["XIAOZHI_PRO_TOKEN"]
9
9
  },
10
+ "configSchema": {
11
+ "$schema": "http://json-schema.org/draft-07/schema#",
12
+ "type": "object",
13
+ "properties": {
14
+ "token": {
15
+ "type": "string",
16
+ "description": "小智Pro平台 API Token"
17
+ }
18
+ },
19
+ "additionalProperties": false
20
+ },
10
21
  "channelConfigs": {
11
22
  "xiaozhi-pro": {
12
23
  "schema": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaozhi-pro/openclaw-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "小智Pro (XiaoZhi Pro) channel plugin for OpenClaw via WebSocket",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",