@agentchatme/openclaw 0.6.16 → 0.6.17

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.
@@ -7,6 +7,8 @@ import { waitUntilAbort } from 'openclaw/plugin-sdk/channel-lifecycle';
7
7
  import pino from 'pino';
8
8
  import { WebSocket } from 'ws';
9
9
  import { dispatchInboundDirectDmWithRuntime } from 'openclaw/plugin-sdk/direct-dm';
10
+ import { resolveInboundRouteEnvelopeBuilderWithRuntime } from 'openclaw/plugin-sdk/inbound-envelope';
11
+ import { recordInboundSessionAndDispatchReply } from 'openclaw/plugin-sdk/inbound-reply-dispatch';
10
12
  import { AgentChatClient } from '@agentchatme/agentchat';
11
13
  import { Type } from '@sinclair/typebox';
12
14
 
@@ -1847,7 +1849,7 @@ var CircuitBreaker = class {
1847
1849
  };
1848
1850
 
1849
1851
  // src/version.ts
1850
- var PACKAGE_VERSION = "0.6.16";
1852
+ var PACKAGE_VERSION = "0.6.17";
1851
1853
 
1852
1854
  // src/outbound.ts
1853
1855
  var DEFAULT_RETRY_POLICY = {
@@ -2479,31 +2481,70 @@ async function handleMessage(deps, event) {
2479
2481
  }
2480
2482
  });
2481
2483
  } else {
2482
- const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
2483
- const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
2484
- await dispatcher({
2484
+ const ts = typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt);
2485
+ const runtime = channelRuntime;
2486
+ const { route, buildEnvelope } = resolveInboundRouteEnvelopeBuilderWithRuntime({
2485
2487
  cfg: deps.gatewayCfg,
2486
- ctx: {
2487
- Body: body,
2488
- BodyForAgent: body,
2489
- RawBody: body,
2490
- CommandBody: body,
2491
- From: `@${senderHandle}`,
2492
- To: `@${recipientHandle}`,
2493
- SessionKey: sessionKey,
2494
- AccountId: deps.accountId,
2495
- ChatType: "group",
2496
- ConversationLabel: conversationLabel,
2497
- SenderId: senderHandle,
2498
- Provider: "agentchat",
2499
- Surface: "agentchat",
2500
- MessageSid: event.messageId,
2501
- MessageSidFull: event.messageId,
2502
- Timestamp: event.createdAt,
2503
- OriginatingChannel: "agentchat",
2504
- OriginatingTo: `@${recipientHandle}`
2488
+ channel: "agentchat",
2489
+ accountId: deps.accountId,
2490
+ peer: { kind: "group", id: event.conversationId },
2491
+ runtime
2492
+ });
2493
+ const { storePath, body: envelopeBody } = buildEnvelope({
2494
+ channel: "AgentChat",
2495
+ from: conversationLabel,
2496
+ body,
2497
+ timestamp: ts
2498
+ });
2499
+ const finalize = channelRuntime.reply.finalizeInboundContext;
2500
+ const ctxPayload = finalize({
2501
+ Body: envelopeBody,
2502
+ BodyForAgent: body,
2503
+ RawBody: body,
2504
+ CommandBody: body,
2505
+ From: `@${senderHandle}`,
2506
+ To: `@${recipientHandle}`,
2507
+ SessionKey: route.sessionKey,
2508
+ AccountId: deps.accountId,
2509
+ ChatType: "group",
2510
+ ConversationLabel: conversationLabel,
2511
+ SenderId: senderHandle,
2512
+ Provider: "agentchat",
2513
+ Surface: "agentchat",
2514
+ MessageSid: event.messageId,
2515
+ MessageSidFull: event.messageId,
2516
+ Timestamp: ts,
2517
+ OriginatingChannel: "agentchat",
2518
+ OriginatingTo: `@${recipientHandle}`
2519
+ });
2520
+ const session = channelRuntime.session;
2521
+ await recordInboundSessionAndDispatchReply({
2522
+ cfg: deps.gatewayCfg,
2523
+ channel: "agentchat",
2524
+ accountId: deps.accountId,
2525
+ agentId: route.agentId,
2526
+ routeSessionKey: route.sessionKey,
2527
+ storePath,
2528
+ ctxPayload,
2529
+ recordInboundSession: session.recordInboundSession,
2530
+ dispatchReplyWithBufferedBlockDispatcher: channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher,
2531
+ deliver: deliver2,
2532
+ onRecordError: (err3) => {
2533
+ deps.logger.error(
2534
+ { err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
2535
+ "recordInboundSession failed (group)"
2536
+ );
2505
2537
  },
2506
- dispatcherOptions: { deliver: deliver2 }
2538
+ onDispatchError: (err3, info) => {
2539
+ deps.logger.error(
2540
+ {
2541
+ err: err3 instanceof Error ? err3.message : String(err3),
2542
+ messageId: event.messageId,
2543
+ kind: info.kind
2544
+ },
2545
+ "inbound dispatch failed (group)"
2546
+ );
2547
+ }
2507
2548
  });
2508
2549
  }
2509
2550
  } catch (err3) {