@zyclaw/webot 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyclaw/webot",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenClaw WeBot plugin — bot social platform for cross-network communication",
5
5
  "type": "module",
6
6
  "peerDependencies": {
@@ -224,35 +224,37 @@ export function createMessageHandler(
224
224
  msg.content.length > 80
225
225
  ? `${msg.content.slice(0, 80)}...`
226
226
  : msg.content;
227
+
228
+ const { type: msgType, body } = parseMessageType(msg.content);
229
+ const fromDeviceId = msg.fromDeviceId;
230
+ const fromUsername = msg.fromUsername || msg.fromBotName || fromDeviceId.slice(0, 8);
231
+ const sessionKey = `agent:main:webot:dm:${fromDeviceId}`;
232
+ const sessionLabel = `WeBot: ${fromUsername}`;
233
+
227
234
  logger.info(
228
- `WeBot: message from ${msg.fromUsername} (${msg.fromBotName}): ${preview}`,
235
+ `WeBot: message from ${fromUsername} (${msg.fromBotName}): ${preview}`,
229
236
  );
230
237
 
231
238
  // Acknowledge delivery (best-effort)
232
239
  relay.ackMessage(msg.messageId, "delivered").catch(() => {});
233
240
 
234
- const { type: msgType, body } = parseMessageType(msg.content);
235
- const fromDeviceId = msg.fromDeviceId;
236
- const sessionKey = `agent:main:webot:dm:${fromDeviceId}`;
237
- const sessionLabel = `WeBot: ${msg.fromUsername}`;
238
-
239
241
  try {
240
242
  switch (msgType) {
241
243
  // ── RESPONSE: result of a task we previously sent ──
242
244
  // Do NOT reply back (break the loop). Notify owner via agent + message tool.
243
245
  case "response": {
244
- logger.info(`WeBot: received task response from ${msg.fromUsername}`);
246
+ logger.info(`WeBot: received task response from ${fromUsername}`);
245
247
  // Use a brief trigger as the visible "user" message in session history;
246
248
  // put the full content in extraSystemPrompt so the agent can process it
247
249
  // without the full bot message appearing as a user message in Web UI.
248
250
  const responsePreview = body.length > 60 ? `${body.slice(0, 60)}…` : body;
249
251
  await callGatewayRpc("agent", {
250
- message: `[WeBot response from @${msg.fromUsername}]: ${responsePreview}`,
252
+ message: `[WeBot response from @${fromUsername}]: ${responsePreview}`,
251
253
  sessionKey,
252
254
  label: sessionLabel,
253
255
  idempotencyKey: crypto.randomUUID(),
254
256
  extraSystemPrompt: [
255
- `This is a RESPONSE from @${msg.fromUsername}'s bot to a task you previously sent.`,
257
+ `This is a RESPONSE from @${fromUsername}'s bot to a task you previously sent.`,
256
258
  `Full message content:\n---\n${body}\n---`,
257
259
  `DO NOT reply back to this bot via WeBot — the conversation is complete.`,
258
260
  `Review the result and notify your owner using the "message" tool about the outcome.`,
@@ -267,7 +269,7 @@ export function createMessageHandler(
267
269
  // Process via agent and send tagged response back.
268
270
  case "task":
269
271
  default: {
270
- logger.info(`WeBot: task request from ${msg.fromUsername}`);
272
+ logger.info(`WeBot: task request from ${fromUsername}`);
271
273
  // Use a brief trigger as the visible "user" message in session history;
272
274
  // put the full content in extraSystemPrompt so the agent can process it
273
275
  // without the full bot message appearing as a user message in Web UI.
@@ -275,12 +277,12 @@ export function createMessageHandler(
275
277
  await callGatewayRpc(
276
278
  "agent",
277
279
  {
278
- message: `[WeBot message from @${msg.fromUsername}]: ${taskPreview}`,
280
+ message: `[WeBot message from @${fromUsername}]: ${taskPreview}`,
279
281
  sessionKey,
280
282
  label: sessionLabel,
281
283
  idempotencyKey: crypto.randomUUID(),
282
284
  extraSystemPrompt: [
283
- `You are receiving a task message via WeBot from @${msg.fromUsername} (bot: "${msg.fromBotName}").`,
285
+ `You are receiving a task message via WeBot from @${fromUsername} (bot: "${msg.fromBotName}").`,
284
286
  `Full message content:\n---\n${body}\n---`,
285
287
  `Your reply will be automatically sent back to the sender's bot.`,
286
288
  ``,