palz-connector 1.1.8 → 1.2.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "palz-connector",
3
3
  "name": "Palz Connector Channel",
4
- "version": "1.1.8",
4
+ "version": "1.2.0",
5
5
  "description": "Palz IM 接入 OpenClaw",
6
6
  "channels": [
7
7
  "palz-connector"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palz-connector",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "Palz IM 接入 OpenClaw — 模块化架构,基于 OpenClaw Runtime 消息管道",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "enabled": true,
3
- "streamUrl": "ws://14.103.148.99:9090/ws/bot",
4
- "apiBaseUrl": "http://14.103.148.99:9090/api",
3
+ "streamUrl": "wss://claw-server.csaiagent.com/ws/bot",
4
+ "apiBaseUrl": "https://claw-server.csaiagent.com/api",
5
5
  "sessionTimeout": 1800000
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "enabled": true,
3
- "streamUrl": "ws://172.23.39.43:8787/ws/bot",
4
- "apiBaseUrl": "http://172.23.39.43:8787/api",
3
+ "streamUrl": "wss://claw-server.csaiagent.com/ws/bot",
4
+ "apiBaseUrl": "https://claw-server.csaiagent.com/api",
5
5
  "sessionTimeout": 1800000
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "enabled": true,
3
- "streamUrl": "ws://172.23.39.43:8787/ws/bot",
4
- "apiBaseUrl": "http://172.23.39.43:8787/api",
3
+ "streamUrl": "wss://claw-server.csaiagent.com/ws/bot",
4
+ "apiBaseUrl": "https://claw-server.csaiagent.com/api",
5
5
  "sessionTimeout": 1800000
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "enabled": true,
3
- "streamUrl": "ws://172.23.39.43:8787/ws/bot",
4
- "apiBaseUrl": "http://172.23.39.43:8787/api",
3
+ "streamUrl": "wss://claw-server.csaiagent.com/ws/bot",
4
+ "apiBaseUrl": "https://claw-server.csaiagent.com/api",
5
5
  "sessionTimeout": 1800000
6
6
  }
package/src/bot.ts CHANGED
@@ -142,13 +142,23 @@ async function dispatchPalzMessage(params: HandlePalzMessageParams): Promise<voi
142
142
 
143
143
  // STEP 5: 解析路由
144
144
  const routeInput = { cfg: "(cfg)", channel: "palz-connector", accountId, peer: { kind: "direct", id: peerId } };
145
- log(`${tag}: [STEP 5/6 路由解析] 输入: ${JSON.stringify(routeInput)}`);
145
+ log(`${tag}: [STEP 5/6 路由解析] 输入: ${JSON.stringify(routeInput)} agent_id=${msg.agent_id ?? "(auto)"}`);
146
146
  const route = core.channel.routing.resolveAgentRoute({
147
147
  cfg,
148
148
  channel: "palz-connector",
149
149
  accountId,
150
150
  peer: { kind: "direct", id: peerId },
151
151
  });
152
+
153
+ // IM 指定 agent_id 时走指定 agent,否则强制走 main
154
+ const effectiveAgentId = msg.agent_id || "main";
155
+ if (route.agentId !== effectiveAgentId) {
156
+ const oldAgentId = route.agentId;
157
+ route.agentId = effectiveAgentId;
158
+ route.sessionKey = route.sessionKey.replace(`agent:${oldAgentId}:`, `agent:${effectiveAgentId}:`);
159
+ log(`${tag}: [STEP 5 覆盖] agentId: ${oldAgentId} -> ${effectiveAgentId}, sessionKey=${route.sessionKey} (${msg.agent_id ? "IM指定" : "默认main"})`);
160
+ }
161
+
152
162
  log(`${tag}: [STEP 5 输出] agentId=${route.agentId} sessionKey=${route.sessionKey} accountId=${route.accountId} matchedBy=${route.matchedBy}`);
153
163
 
154
164
  // STEP 6a: 构建 envelope body
package/src/monitor.ts CHANGED
@@ -38,7 +38,7 @@ export async function monitorPalzProvider(params: MonitorPalzParams): Promise<vo
38
38
  let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
39
39
  let currentWs: WebSocket | null = null;
40
40
  let consecutive4002 = 0;
41
- const MAX_CONSECUTIVE_4002 = 6;
41
+ const MAX_CONSECUTIVE_4002 = 10;
42
42
 
43
43
  const cleanup = () => {
44
44
  closed = true;
package/src/types.ts CHANGED
@@ -24,6 +24,8 @@ export interface PalzMessageEvent {
24
24
  stream?: boolean;
25
25
  msg_id: string;
26
26
  timestamp: number;
27
+ /** 可选,指定 OpenClaw agent ID,覆盖默认路由 */
28
+ agent_id?: string;
27
29
  }
28
30
 
29
31
  // ============ 配置 ============