@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.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.
|
|
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
|
|
2432
|
-
if (typeof
|
|
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,43 +2437,90 @@ async function handleMessage(deps, event) {
|
|
|
2438
2437
|
conversationKind: event.conversationKind,
|
|
2439
2438
|
sender: event.sender
|
|
2440
2439
|
},
|
|
2441
|
-
"channelRuntime
|
|
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
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2461
|
+
if (event.conversationKind === "direct") {
|
|
2462
|
+
await directDm.dispatchInboundDirectDmWithRuntime({
|
|
2463
|
+
cfg: deps.gatewayCfg,
|
|
2464
|
+
runtime: { channel: channelRuntime },
|
|
2451
2465
|
channel: "agentchat",
|
|
2452
2466
|
channelLabel: "AgentChat",
|
|
2453
2467
|
accountId: deps.accountId,
|
|
2454
|
-
|
|
2455
|
-
conversationLabel,
|
|
2468
|
+
peer: { kind: "direct", id: senderHandle },
|
|
2456
2469
|
senderId: senderHandle,
|
|
2457
2470
|
senderAddress: `@${senderHandle}`,
|
|
2458
2471
|
recipientAddress: `@${recipientHandle}`,
|
|
2459
|
-
|
|
2472
|
+
conversationLabel,
|
|
2460
2473
|
rawBody: body,
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
deliver:
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
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
|
+
);
|
|
2475
2494
|
}
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
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
|
+
}
|
|
2478
2524
|
} catch (err3) {
|
|
2479
2525
|
deps.logger.error(
|
|
2480
2526
|
{
|