@agentchatme/openclaw 0.6.13 → 0.6.14

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/index.cjs CHANGED
@@ -9,6 +9,7 @@ var agentsAnchor_js = require('./binding/agents-anchor.cjs');
9
9
  var zod = require('zod');
10
10
  var pino = require('pino');
11
11
  var ws = require('ws');
12
+ var directDm = require('openclaw/plugin-sdk/direct-dm');
12
13
  var agentchat = require('@agentchatme/agentchat');
13
14
  var typebox = require('@sinclair/typebox');
14
15
 
@@ -1861,7 +1862,7 @@ var CircuitBreaker = class {
1861
1862
  };
1862
1863
 
1863
1864
  // src/version.ts
1864
- var PACKAGE_VERSION = "0.6.13";
1865
+ var PACKAGE_VERSION = "0.6.14";
1865
1866
 
1866
1867
  // src/outbound.ts
1867
1868
  var DEFAULT_RETRY_POLICY = {
@@ -2390,8 +2391,6 @@ function unregisterRuntime(accountId, deadlineMs = Date.now() + 5e3) {
2390
2391
  function getRuntime(accountId) {
2391
2392
  return registry.get(accountId)?.runtime;
2392
2393
  }
2393
-
2394
- // src/binding/inbound-bridge.ts
2395
2394
  function createInboundBridge(deps) {
2396
2395
  return async function onInbound(event) {
2397
2396
  switch (event.kind) {
@@ -2428,8 +2427,8 @@ async function handleMessage(deps, event) {
2428
2427
  if (!body && !event.content.attachmentId && !event.content.data) {
2429
2428
  return;
2430
2429
  }
2431
- const dispatcher = deps.channelRuntime?.reply?.dispatchReplyWithBufferedBlockDispatcher;
2432
- if (typeof dispatcher !== "function") {
2430
+ const channelRuntime = deps.channelRuntime;
2431
+ if (!channelRuntime || typeof channelRuntime.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
2433
2432
  deps.logger.error(
2434
2433
  {
2435
2434
  event: "inbound_dispatch_unavailable",
@@ -2438,50 +2437,90 @@ async function handleMessage(deps, event) {
2438
2437
  conversationKind: event.conversationKind,
2439
2438
  sender: event.sender
2440
2439
  },
2441
- "channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
2440
+ "channelRuntime unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
2442
2441
  );
2443
2442
  return;
2444
2443
  }
2445
2444
  const recipientHandle = selfHandle ?? "me";
2446
2445
  const conversationLabel = event.conversationKind === "group" ? `group ${event.conversationId}` : `dm with @${senderHandle}`;
2446
+ const sendReply = async (replyText) => {
2447
+ if (!replyText) return;
2448
+ const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
2449
+ await deps.runtime.sendMessage({
2450
+ ...target,
2451
+ type: "text",
2452
+ content: { text: replyText },
2453
+ metadata: { reply_to: event.messageId }
2454
+ });
2455
+ };
2456
+ const deliver2 = async (payload) => {
2457
+ const replyText = payload.text ?? extractText(payload.blocks);
2458
+ await sendReply(replyText);
2459
+ };
2447
2460
  try {
2448
- const sessionKey = event.conversationKind === "group" ? `agentchat:${deps.accountId}:group:${event.conversationId}` : `agentchat:${deps.accountId}:dm:${senderHandle}`;
2449
- await dispatcher({
2450
- cfg: deps.gatewayCfg,
2451
- ctx: {
2452
- Body: body,
2453
- BodyForAgent: body,
2454
- RawBody: body,
2455
- CommandBody: body,
2456
- From: `@${senderHandle}`,
2457
- To: `@${recipientHandle}`,
2458
- SessionKey: sessionKey,
2459
- AccountId: deps.accountId,
2460
- ChatType: event.conversationKind === "group" ? "group" : "direct",
2461
- ConversationLabel: conversationLabel,
2462
- SenderId: senderHandle,
2463
- Provider: "agentchat",
2464
- Surface: "agentchat",
2465
- MessageSid: event.messageId,
2466
- MessageSidFull: event.messageId,
2467
- Timestamp: event.createdAt,
2468
- OriginatingChannel: "agentchat",
2469
- OriginatingTo: `@${recipientHandle}`
2470
- },
2471
- dispatcherOptions: {
2472
- deliver: async (payload) => {
2473
- const replyText = payload.text ?? extractText(payload.blocks);
2474
- if (!replyText) return;
2475
- const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
2476
- await deps.runtime.sendMessage({
2477
- ...target,
2478
- type: "text",
2479
- content: { text: replyText },
2480
- metadata: { reply_to: event.messageId }
2481
- });
2461
+ if (event.conversationKind === "direct") {
2462
+ await directDm.dispatchInboundDirectDmWithRuntime({
2463
+ cfg: deps.gatewayCfg,
2464
+ runtime: { channel: channelRuntime },
2465
+ channel: "agentchat",
2466
+ channelLabel: "AgentChat",
2467
+ accountId: deps.accountId,
2468
+ peer: { kind: "direct", id: senderHandle },
2469
+ senderId: senderHandle,
2470
+ senderAddress: `@${senderHandle}`,
2471
+ recipientAddress: `@${recipientHandle}`,
2472
+ conversationLabel,
2473
+ rawBody: body,
2474
+ messageId: event.messageId,
2475
+ timestamp: typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt),
2476
+ provider: "agentchat",
2477
+ surface: "agentchat",
2478
+ deliver: deliver2,
2479
+ onRecordError: (err3) => {
2480
+ deps.logger.error(
2481
+ { err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
2482
+ "recordInboundSession failed"
2483
+ );
2484
+ },
2485
+ onDispatchError: (err3, info) => {
2486
+ deps.logger.error(
2487
+ {
2488
+ err: err3 instanceof Error ? err3.message : String(err3),
2489
+ messageId: event.messageId,
2490
+ kind: info.kind
2491
+ },
2492
+ "inbound dispatch failed"
2493
+ );
2482
2494
  }
2483
- }
2484
- });
2495
+ });
2496
+ } else {
2497
+ const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
2498
+ const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
2499
+ await dispatcher({
2500
+ cfg: deps.gatewayCfg,
2501
+ ctx: {
2502
+ Body: body,
2503
+ BodyForAgent: body,
2504
+ RawBody: body,
2505
+ CommandBody: body,
2506
+ From: `@${senderHandle}`,
2507
+ To: `@${recipientHandle}`,
2508
+ SessionKey: sessionKey,
2509
+ AccountId: deps.accountId,
2510
+ ChatType: "group",
2511
+ ConversationLabel: conversationLabel,
2512
+ SenderId: senderHandle,
2513
+ Provider: "agentchat",
2514
+ Surface: "agentchat",
2515
+ MessageSid: event.messageId,
2516
+ MessageSidFull: event.messageId,
2517
+ Timestamp: event.createdAt,
2518
+ OriginatingChannel: "agentchat",
2519
+ OriginatingTo: `@${recipientHandle}`
2520
+ },
2521
+ dispatcherOptions: { deliver: deliver2 }
2522
+ });
2523
+ }
2485
2524
  } catch (err3) {
2486
2525
  deps.logger.error(
2487
2526
  {