commanderclaw 1.1.5 → 1.1.6
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/dist/cli/index.js +1 -1
- package/dist/plugin/client.d.ts.map +1 -1
- package/dist/plugin/index.cjs +29 -10
- package/dist/plugin/index.cjs.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.mjs +29 -10
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugin/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgWH,QAAA,MAAM,MAAM;;;;;kBAKI,GAAG;CAQlB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin/index.mjs
CHANGED
|
@@ -215,14 +215,25 @@ class CommanderClawClient {
|
|
|
215
215
|
console.error(`[CommanderClawClient] send: WebSocket not connected, cannot send ${type}`);
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
+
let to;
|
|
219
|
+
let actualPayload = payload;
|
|
220
|
+
if (payload && typeof payload === "object" && "to" in payload) {
|
|
221
|
+
const { to: toField, ...rest } = payload;
|
|
222
|
+
to = toField;
|
|
223
|
+
actualPayload = rest;
|
|
224
|
+
}
|
|
218
225
|
const msg = {
|
|
219
226
|
type,
|
|
220
227
|
id: crypto.randomUUID(),
|
|
221
228
|
from: this.nodeId || "unknown",
|
|
222
|
-
|
|
229
|
+
to,
|
|
230
|
+
payload: actualPayload,
|
|
223
231
|
timestamp: Date.now(),
|
|
224
232
|
};
|
|
225
|
-
|
|
233
|
+
if (to) {
|
|
234
|
+
msg.msgType = "private";
|
|
235
|
+
}
|
|
236
|
+
console.log(`[CommanderClawClient] send: type=${type}, from=${msg.from}, to=${to || "broadcast"}`, actualPayload);
|
|
226
237
|
this.ws.send(JSON.stringify(msg));
|
|
227
238
|
}
|
|
228
239
|
on(event, handler) {
|
|
@@ -4288,15 +4299,20 @@ async function handleChatMessage(msg) {
|
|
|
4288
4299
|
to: msg.to,
|
|
4289
4300
|
msgType: msg.msgType,
|
|
4290
4301
|
});
|
|
4302
|
+
if (!client) {
|
|
4303
|
+
log.error("handleChatMessage: client not initialized");
|
|
4304
|
+
return;
|
|
4305
|
+
}
|
|
4306
|
+
const nodeId = client.getNodeId();
|
|
4307
|
+
if (msg.from === nodeId) {
|
|
4308
|
+
log.debug("handleChatMessage: ignoring own message", { from: msg.from });
|
|
4309
|
+
return;
|
|
4310
|
+
}
|
|
4291
4311
|
const rt = getRuntime();
|
|
4292
4312
|
if (!rt || !rt.channel) {
|
|
4293
4313
|
log.error("handleChatMessage: runtime or channel not initialized");
|
|
4294
4314
|
return;
|
|
4295
4315
|
}
|
|
4296
|
-
if (!client) {
|
|
4297
|
-
log.error("handleChatMessage: client not initialized");
|
|
4298
|
-
return;
|
|
4299
|
-
}
|
|
4300
4316
|
if (!pluginConfig) {
|
|
4301
4317
|
log.error("handleChatMessage: pluginConfig not initialized");
|
|
4302
4318
|
return;
|
|
@@ -4310,6 +4326,7 @@ async function handleChatMessage(msg) {
|
|
|
4310
4326
|
from: msg.from,
|
|
4311
4327
|
contentLength: content.length,
|
|
4312
4328
|
});
|
|
4329
|
+
const senderId = msg.from;
|
|
4313
4330
|
try {
|
|
4314
4331
|
const nodeId = client.getNodeId() || "unknown";
|
|
4315
4332
|
const route = rt.channel.routing.resolveAgentRoute({
|
|
@@ -4318,7 +4335,7 @@ async function handleChatMessage(msg) {
|
|
|
4318
4335
|
accountId: "default",
|
|
4319
4336
|
peer: {
|
|
4320
4337
|
kind: "direct",
|
|
4321
|
-
id:
|
|
4338
|
+
id: senderId,
|
|
4322
4339
|
},
|
|
4323
4340
|
});
|
|
4324
4341
|
const ctxPayload = rt.channel.reply.finalizeInboundContext({
|
|
@@ -4326,13 +4343,13 @@ async function handleChatMessage(msg) {
|
|
|
4326
4343
|
RawBody: content,
|
|
4327
4344
|
CommandBody: content,
|
|
4328
4345
|
MessageSid: `cc-${Date.now()}`,
|
|
4329
|
-
From: `${CHANNEL_ID}:${
|
|
4346
|
+
From: `${CHANNEL_ID}:${senderId}`,
|
|
4330
4347
|
To: `${CHANNEL_ID}:${nodeId}`,
|
|
4331
|
-
SenderId:
|
|
4348
|
+
SenderId: senderId,
|
|
4332
4349
|
SessionKey: route.sessionKey,
|
|
4333
4350
|
AccountId: "default",
|
|
4334
4351
|
ChatType: "direct",
|
|
4335
|
-
ConversationLabel: `user:${
|
|
4352
|
+
ConversationLabel: `user:${senderId}`,
|
|
4336
4353
|
Timestamp: Date.now(),
|
|
4337
4354
|
Provider: CHANNEL_ID,
|
|
4338
4355
|
Surface: CHANNEL_ID,
|
|
@@ -4350,10 +4367,12 @@ async function handleChatMessage(msg) {
|
|
|
4350
4367
|
accumulatedText = payload.text;
|
|
4351
4368
|
if (info.kind === "final") {
|
|
4352
4369
|
log.info("handleChatMessage: sending response", {
|
|
4370
|
+
to: senderId,
|
|
4353
4371
|
textLength: accumulatedText.length,
|
|
4354
4372
|
});
|
|
4355
4373
|
client?.send("CHAT", {
|
|
4356
4374
|
content: accumulatedText,
|
|
4375
|
+
to: senderId,
|
|
4357
4376
|
});
|
|
4358
4377
|
}
|
|
4359
4378
|
},
|