@agentchatme/openclaw 0.6.12 → 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 +74 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +74 -28
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +74 -28
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +74 -28
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +17 -14
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { writeAgentsAnchor, removeAgentsAnchor } from './binding/agents-anchor.j
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import pino from 'pino';
|
|
7
7
|
import { WebSocket } from 'ws';
|
|
8
|
+
import { dispatchInboundDirectDmWithRuntime } from 'openclaw/plugin-sdk/direct-dm';
|
|
8
9
|
import { AgentChatClient } from '@agentchatme/agentchat';
|
|
9
10
|
import { Type } from '@sinclair/typebox';
|
|
10
11
|
|
|
@@ -1853,7 +1854,7 @@ var CircuitBreaker = class {
|
|
|
1853
1854
|
};
|
|
1854
1855
|
|
|
1855
1856
|
// src/version.ts
|
|
1856
|
-
var PACKAGE_VERSION = "0.6.
|
|
1857
|
+
var PACKAGE_VERSION = "0.6.14";
|
|
1857
1858
|
|
|
1858
1859
|
// src/outbound.ts
|
|
1859
1860
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2382,8 +2383,6 @@ function unregisterRuntime(accountId, deadlineMs = Date.now() + 5e3) {
|
|
|
2382
2383
|
function getRuntime(accountId) {
|
|
2383
2384
|
return registry.get(accountId)?.runtime;
|
|
2384
2385
|
}
|
|
2385
|
-
|
|
2386
|
-
// src/binding/inbound-bridge.ts
|
|
2387
2386
|
function createInboundBridge(deps) {
|
|
2388
2387
|
return async function onInbound(event) {
|
|
2389
2388
|
switch (event.kind) {
|
|
@@ -2420,8 +2419,8 @@ async function handleMessage(deps, event) {
|
|
|
2420
2419
|
if (!body && !event.content.attachmentId && !event.content.data) {
|
|
2421
2420
|
return;
|
|
2422
2421
|
}
|
|
2423
|
-
const
|
|
2424
|
-
if (typeof
|
|
2422
|
+
const channelRuntime = deps.channelRuntime;
|
|
2423
|
+
if (!channelRuntime || typeof channelRuntime.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
|
|
2425
2424
|
deps.logger.error(
|
|
2426
2425
|
{
|
|
2427
2426
|
event: "inbound_dispatch_unavailable",
|
|
@@ -2430,43 +2429,90 @@ async function handleMessage(deps, event) {
|
|
|
2430
2429
|
conversationKind: event.conversationKind,
|
|
2431
2430
|
sender: event.sender
|
|
2432
2431
|
},
|
|
2433
|
-
"channelRuntime
|
|
2432
|
+
"channelRuntime unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
|
|
2434
2433
|
);
|
|
2435
2434
|
return;
|
|
2436
2435
|
}
|
|
2437
2436
|
const recipientHandle = selfHandle ?? "me";
|
|
2438
2437
|
const conversationLabel = event.conversationKind === "group" ? `group ${event.conversationId}` : `dm with @${senderHandle}`;
|
|
2438
|
+
const sendReply = async (replyText) => {
|
|
2439
|
+
if (!replyText) return;
|
|
2440
|
+
const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
|
|
2441
|
+
await deps.runtime.sendMessage({
|
|
2442
|
+
...target,
|
|
2443
|
+
type: "text",
|
|
2444
|
+
content: { text: replyText },
|
|
2445
|
+
metadata: { reply_to: event.messageId }
|
|
2446
|
+
});
|
|
2447
|
+
};
|
|
2448
|
+
const deliver2 = async (payload) => {
|
|
2449
|
+
const replyText = payload.text ?? extractText(payload.blocks);
|
|
2450
|
+
await sendReply(replyText);
|
|
2451
|
+
};
|
|
2439
2452
|
try {
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2453
|
+
if (event.conversationKind === "direct") {
|
|
2454
|
+
await dispatchInboundDirectDmWithRuntime({
|
|
2455
|
+
cfg: deps.gatewayCfg,
|
|
2456
|
+
runtime: { channel: channelRuntime },
|
|
2443
2457
|
channel: "agentchat",
|
|
2444
2458
|
channelLabel: "AgentChat",
|
|
2445
2459
|
accountId: deps.accountId,
|
|
2446
|
-
|
|
2447
|
-
conversationLabel,
|
|
2460
|
+
peer: { kind: "direct", id: senderHandle },
|
|
2448
2461
|
senderId: senderHandle,
|
|
2449
2462
|
senderAddress: `@${senderHandle}`,
|
|
2450
2463
|
recipientAddress: `@${recipientHandle}`,
|
|
2451
|
-
|
|
2464
|
+
conversationLabel,
|
|
2452
2465
|
rawBody: body,
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
deliver:
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2466
|
+
messageId: event.messageId,
|
|
2467
|
+
timestamp: typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt),
|
|
2468
|
+
provider: "agentchat",
|
|
2469
|
+
surface: "agentchat",
|
|
2470
|
+
deliver: deliver2,
|
|
2471
|
+
onRecordError: (err3) => {
|
|
2472
|
+
deps.logger.error(
|
|
2473
|
+
{ err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
|
|
2474
|
+
"recordInboundSession failed"
|
|
2475
|
+
);
|
|
2476
|
+
},
|
|
2477
|
+
onDispatchError: (err3, info) => {
|
|
2478
|
+
deps.logger.error(
|
|
2479
|
+
{
|
|
2480
|
+
err: err3 instanceof Error ? err3.message : String(err3),
|
|
2481
|
+
messageId: event.messageId,
|
|
2482
|
+
kind: info.kind
|
|
2483
|
+
},
|
|
2484
|
+
"inbound dispatch failed"
|
|
2485
|
+
);
|
|
2467
2486
|
}
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2487
|
+
});
|
|
2488
|
+
} else {
|
|
2489
|
+
const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
|
|
2490
|
+
const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
|
|
2491
|
+
await dispatcher({
|
|
2492
|
+
cfg: deps.gatewayCfg,
|
|
2493
|
+
ctx: {
|
|
2494
|
+
Body: body,
|
|
2495
|
+
BodyForAgent: body,
|
|
2496
|
+
RawBody: body,
|
|
2497
|
+
CommandBody: body,
|
|
2498
|
+
From: `@${senderHandle}`,
|
|
2499
|
+
To: `@${recipientHandle}`,
|
|
2500
|
+
SessionKey: sessionKey,
|
|
2501
|
+
AccountId: deps.accountId,
|
|
2502
|
+
ChatType: "group",
|
|
2503
|
+
ConversationLabel: conversationLabel,
|
|
2504
|
+
SenderId: senderHandle,
|
|
2505
|
+
Provider: "agentchat",
|
|
2506
|
+
Surface: "agentchat",
|
|
2507
|
+
MessageSid: event.messageId,
|
|
2508
|
+
MessageSidFull: event.messageId,
|
|
2509
|
+
Timestamp: event.createdAt,
|
|
2510
|
+
OriginatingChannel: "agentchat",
|
|
2511
|
+
OriginatingTo: `@${recipientHandle}`
|
|
2512
|
+
},
|
|
2513
|
+
dispatcherOptions: { deliver: deliver2 }
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2470
2516
|
} catch (err3) {
|
|
2471
2517
|
deps.logger.error(
|
|
2472
2518
|
{
|