@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/setup-entry.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
|
|
|
@@ -1845,7 +1846,7 @@ var CircuitBreaker = class {
|
|
|
1845
1846
|
};
|
|
1846
1847
|
|
|
1847
1848
|
// src/version.ts
|
|
1848
|
-
var PACKAGE_VERSION = "0.6.
|
|
1849
|
+
var PACKAGE_VERSION = "0.6.14";
|
|
1849
1850
|
|
|
1850
1851
|
// src/outbound.ts
|
|
1851
1852
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2374,8 +2375,6 @@ function unregisterRuntime(accountId, deadlineMs = Date.now() + 5e3) {
|
|
|
2374
2375
|
function getRuntime(accountId) {
|
|
2375
2376
|
return registry.get(accountId)?.runtime;
|
|
2376
2377
|
}
|
|
2377
|
-
|
|
2378
|
-
// src/binding/inbound-bridge.ts
|
|
2379
2378
|
function createInboundBridge(deps) {
|
|
2380
2379
|
return async function onInbound(event) {
|
|
2381
2380
|
switch (event.kind) {
|
|
@@ -2412,8 +2411,8 @@ async function handleMessage(deps, event) {
|
|
|
2412
2411
|
if (!body && !event.content.attachmentId && !event.content.data) {
|
|
2413
2412
|
return;
|
|
2414
2413
|
}
|
|
2415
|
-
const
|
|
2416
|
-
if (typeof
|
|
2414
|
+
const channelRuntime = deps.channelRuntime;
|
|
2415
|
+
if (!channelRuntime || typeof channelRuntime.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
|
|
2417
2416
|
deps.logger.error(
|
|
2418
2417
|
{
|
|
2419
2418
|
event: "inbound_dispatch_unavailable",
|
|
@@ -2422,43 +2421,90 @@ async function handleMessage(deps, event) {
|
|
|
2422
2421
|
conversationKind: event.conversationKind,
|
|
2423
2422
|
sender: event.sender
|
|
2424
2423
|
},
|
|
2425
|
-
"channelRuntime
|
|
2424
|
+
"channelRuntime unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
|
|
2426
2425
|
);
|
|
2427
2426
|
return;
|
|
2428
2427
|
}
|
|
2429
2428
|
const recipientHandle = selfHandle ?? "me";
|
|
2430
2429
|
const conversationLabel = event.conversationKind === "group" ? `group ${event.conversationId}` : `dm with @${senderHandle}`;
|
|
2430
|
+
const sendReply = async (replyText) => {
|
|
2431
|
+
if (!replyText) return;
|
|
2432
|
+
const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
|
|
2433
|
+
await deps.runtime.sendMessage({
|
|
2434
|
+
...target,
|
|
2435
|
+
type: "text",
|
|
2436
|
+
content: { text: replyText },
|
|
2437
|
+
metadata: { reply_to: event.messageId }
|
|
2438
|
+
});
|
|
2439
|
+
};
|
|
2440
|
+
const deliver2 = async (payload) => {
|
|
2441
|
+
const replyText = payload.text ?? extractText(payload.blocks);
|
|
2442
|
+
await sendReply(replyText);
|
|
2443
|
+
};
|
|
2431
2444
|
try {
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2445
|
+
if (event.conversationKind === "direct") {
|
|
2446
|
+
await dispatchInboundDirectDmWithRuntime({
|
|
2447
|
+
cfg: deps.gatewayCfg,
|
|
2448
|
+
runtime: { channel: channelRuntime },
|
|
2435
2449
|
channel: "agentchat",
|
|
2436
2450
|
channelLabel: "AgentChat",
|
|
2437
2451
|
accountId: deps.accountId,
|
|
2438
|
-
|
|
2439
|
-
conversationLabel,
|
|
2452
|
+
peer: { kind: "direct", id: senderHandle },
|
|
2440
2453
|
senderId: senderHandle,
|
|
2441
2454
|
senderAddress: `@${senderHandle}`,
|
|
2442
2455
|
recipientAddress: `@${recipientHandle}`,
|
|
2443
|
-
|
|
2456
|
+
conversationLabel,
|
|
2444
2457
|
rawBody: body,
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
deliver:
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2458
|
+
messageId: event.messageId,
|
|
2459
|
+
timestamp: typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt),
|
|
2460
|
+
provider: "agentchat",
|
|
2461
|
+
surface: "agentchat",
|
|
2462
|
+
deliver: deliver2,
|
|
2463
|
+
onRecordError: (err3) => {
|
|
2464
|
+
deps.logger.error(
|
|
2465
|
+
{ err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
|
|
2466
|
+
"recordInboundSession failed"
|
|
2467
|
+
);
|
|
2468
|
+
},
|
|
2469
|
+
onDispatchError: (err3, info) => {
|
|
2470
|
+
deps.logger.error(
|
|
2471
|
+
{
|
|
2472
|
+
err: err3 instanceof Error ? err3.message : String(err3),
|
|
2473
|
+
messageId: event.messageId,
|
|
2474
|
+
kind: info.kind
|
|
2475
|
+
},
|
|
2476
|
+
"inbound dispatch failed"
|
|
2477
|
+
);
|
|
2459
2478
|
}
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2479
|
+
});
|
|
2480
|
+
} else {
|
|
2481
|
+
const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
|
|
2482
|
+
const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
|
|
2483
|
+
await dispatcher({
|
|
2484
|
+
cfg: deps.gatewayCfg,
|
|
2485
|
+
ctx: {
|
|
2486
|
+
Body: body,
|
|
2487
|
+
BodyForAgent: body,
|
|
2488
|
+
RawBody: body,
|
|
2489
|
+
CommandBody: body,
|
|
2490
|
+
From: `@${senderHandle}`,
|
|
2491
|
+
To: `@${recipientHandle}`,
|
|
2492
|
+
SessionKey: sessionKey,
|
|
2493
|
+
AccountId: deps.accountId,
|
|
2494
|
+
ChatType: "group",
|
|
2495
|
+
ConversationLabel: conversationLabel,
|
|
2496
|
+
SenderId: senderHandle,
|
|
2497
|
+
Provider: "agentchat",
|
|
2498
|
+
Surface: "agentchat",
|
|
2499
|
+
MessageSid: event.messageId,
|
|
2500
|
+
MessageSidFull: event.messageId,
|
|
2501
|
+
Timestamp: event.createdAt,
|
|
2502
|
+
OriginatingChannel: "agentchat",
|
|
2503
|
+
OriginatingTo: `@${recipientHandle}`
|
|
2504
|
+
},
|
|
2505
|
+
dispatcherOptions: { deliver: deliver2 }
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2462
2508
|
} catch (err3) {
|
|
2463
2509
|
deps.logger.error(
|
|
2464
2510
|
{
|