@agentchatme/openclaw 0.6.13 → 0.6.15
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 +91 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +91 -53
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +91 -53
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +91 -53
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/setup-entry.cjs
CHANGED
|
@@ -7,8 +7,10 @@ var setup = require('openclaw/plugin-sdk/setup');
|
|
|
7
7
|
var readEnv_js = require('./credentials/read-env.cjs');
|
|
8
8
|
var agentsAnchor_js = require('./binding/agents-anchor.cjs');
|
|
9
9
|
var zod = require('zod');
|
|
10
|
+
var channelLifecycle = require('openclaw/plugin-sdk/channel-lifecycle');
|
|
10
11
|
var pino = require('pino');
|
|
11
12
|
var ws = require('ws');
|
|
13
|
+
var directDm = require('openclaw/plugin-sdk/direct-dm');
|
|
12
14
|
var agentchat = require('@agentchatme/agentchat');
|
|
13
15
|
var typebox = require('@sinclair/typebox');
|
|
14
16
|
|
|
@@ -1853,7 +1855,7 @@ var CircuitBreaker = class {
|
|
|
1853
1855
|
};
|
|
1854
1856
|
|
|
1855
1857
|
// src/version.ts
|
|
1856
|
-
var PACKAGE_VERSION = "0.6.
|
|
1858
|
+
var PACKAGE_VERSION = "0.6.15";
|
|
1857
1859
|
|
|
1858
1860
|
// src/outbound.ts
|
|
1859
1861
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2382,8 +2384,6 @@ function unregisterRuntime(accountId, deadlineMs = Date.now() + 5e3) {
|
|
|
2382
2384
|
function getRuntime(accountId) {
|
|
2383
2385
|
return registry.get(accountId)?.runtime;
|
|
2384
2386
|
}
|
|
2385
|
-
|
|
2386
|
-
// src/binding/inbound-bridge.ts
|
|
2387
2387
|
function createInboundBridge(deps) {
|
|
2388
2388
|
return async function onInbound(event) {
|
|
2389
2389
|
switch (event.kind) {
|
|
@@ -2420,8 +2420,8 @@ async function handleMessage(deps, event) {
|
|
|
2420
2420
|
if (!body && !event.content.attachmentId && !event.content.data) {
|
|
2421
2421
|
return;
|
|
2422
2422
|
}
|
|
2423
|
-
const
|
|
2424
|
-
if (typeof
|
|
2423
|
+
const channelRuntime = deps.channelRuntime;
|
|
2424
|
+
if (!channelRuntime || typeof channelRuntime.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
|
|
2425
2425
|
deps.logger.error(
|
|
2426
2426
|
{
|
|
2427
2427
|
event: "inbound_dispatch_unavailable",
|
|
@@ -2430,50 +2430,90 @@ async function handleMessage(deps, event) {
|
|
|
2430
2430
|
conversationKind: event.conversationKind,
|
|
2431
2431
|
sender: event.sender
|
|
2432
2432
|
},
|
|
2433
|
-
"channelRuntime
|
|
2433
|
+
"channelRuntime unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
|
|
2434
2434
|
);
|
|
2435
2435
|
return;
|
|
2436
2436
|
}
|
|
2437
2437
|
const recipientHandle = selfHandle ?? "me";
|
|
2438
2438
|
const conversationLabel = event.conversationKind === "group" ? `group ${event.conversationId}` : `dm with @${senderHandle}`;
|
|
2439
|
+
const sendReply = async (replyText) => {
|
|
2440
|
+
if (!replyText) return;
|
|
2441
|
+
const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
|
|
2442
|
+
await deps.runtime.sendMessage({
|
|
2443
|
+
...target,
|
|
2444
|
+
type: "text",
|
|
2445
|
+
content: { text: replyText },
|
|
2446
|
+
metadata: { reply_to: event.messageId }
|
|
2447
|
+
});
|
|
2448
|
+
};
|
|
2449
|
+
const deliver2 = async (payload) => {
|
|
2450
|
+
const replyText = payload.text ?? extractText(payload.blocks);
|
|
2451
|
+
await sendReply(replyText);
|
|
2452
|
+
};
|
|
2439
2453
|
try {
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
});
|
|
2454
|
+
if (event.conversationKind === "direct") {
|
|
2455
|
+
await directDm.dispatchInboundDirectDmWithRuntime({
|
|
2456
|
+
cfg: deps.gatewayCfg,
|
|
2457
|
+
runtime: { channel: channelRuntime },
|
|
2458
|
+
channel: "agentchat",
|
|
2459
|
+
channelLabel: "AgentChat",
|
|
2460
|
+
accountId: deps.accountId,
|
|
2461
|
+
peer: { kind: "direct", id: senderHandle },
|
|
2462
|
+
senderId: senderHandle,
|
|
2463
|
+
senderAddress: `@${senderHandle}`,
|
|
2464
|
+
recipientAddress: `@${recipientHandle}`,
|
|
2465
|
+
conversationLabel,
|
|
2466
|
+
rawBody: body,
|
|
2467
|
+
messageId: event.messageId,
|
|
2468
|
+
timestamp: typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt),
|
|
2469
|
+
provider: "agentchat",
|
|
2470
|
+
surface: "agentchat",
|
|
2471
|
+
deliver: deliver2,
|
|
2472
|
+
onRecordError: (err3) => {
|
|
2473
|
+
deps.logger.error(
|
|
2474
|
+
{ err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
|
|
2475
|
+
"recordInboundSession failed"
|
|
2476
|
+
);
|
|
2477
|
+
},
|
|
2478
|
+
onDispatchError: (err3, info) => {
|
|
2479
|
+
deps.logger.error(
|
|
2480
|
+
{
|
|
2481
|
+
err: err3 instanceof Error ? err3.message : String(err3),
|
|
2482
|
+
messageId: event.messageId,
|
|
2483
|
+
kind: info.kind
|
|
2484
|
+
},
|
|
2485
|
+
"inbound dispatch failed"
|
|
2486
|
+
);
|
|
2474
2487
|
}
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2488
|
+
});
|
|
2489
|
+
} else {
|
|
2490
|
+
const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
|
|
2491
|
+
const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
|
|
2492
|
+
await dispatcher({
|
|
2493
|
+
cfg: deps.gatewayCfg,
|
|
2494
|
+
ctx: {
|
|
2495
|
+
Body: body,
|
|
2496
|
+
BodyForAgent: body,
|
|
2497
|
+
RawBody: body,
|
|
2498
|
+
CommandBody: body,
|
|
2499
|
+
From: `@${senderHandle}`,
|
|
2500
|
+
To: `@${recipientHandle}`,
|
|
2501
|
+
SessionKey: sessionKey,
|
|
2502
|
+
AccountId: deps.accountId,
|
|
2503
|
+
ChatType: "group",
|
|
2504
|
+
ConversationLabel: conversationLabel,
|
|
2505
|
+
SenderId: senderHandle,
|
|
2506
|
+
Provider: "agentchat",
|
|
2507
|
+
Surface: "agentchat",
|
|
2508
|
+
MessageSid: event.messageId,
|
|
2509
|
+
MessageSidFull: event.messageId,
|
|
2510
|
+
Timestamp: event.createdAt,
|
|
2511
|
+
OriginatingChannel: "agentchat",
|
|
2512
|
+
OriginatingTo: `@${recipientHandle}`
|
|
2513
|
+
},
|
|
2514
|
+
dispatcherOptions: { deliver: deliver2 }
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2477
2517
|
} catch (err3) {
|
|
2478
2518
|
deps.logger.error(
|
|
2479
2519
|
{
|
|
@@ -2612,17 +2652,15 @@ var agentchatGatewayAdapter = {
|
|
|
2612
2652
|
gatewayCfg: ctx.cfg,
|
|
2613
2653
|
selfHandle: account.config.agentHandle
|
|
2614
2654
|
});
|
|
2615
|
-
ctx.abortSignal
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
{ once: true }
|
|
2625
|
-
);
|
|
2655
|
+
await channelLifecycle.waitUntilAbort(ctx.abortSignal, async () => {
|
|
2656
|
+
try {
|
|
2657
|
+
await unregisterRuntime(ctx.accountId, Date.now() + 5e3);
|
|
2658
|
+
} catch (err3) {
|
|
2659
|
+
ctx.log?.error?.(
|
|
2660
|
+
`[agentchat:${ctx.accountId}] unregisterRuntime failed on abort: ${err3 instanceof Error ? err3.message : String(err3)}`
|
|
2661
|
+
);
|
|
2662
|
+
}
|
|
2663
|
+
});
|
|
2626
2664
|
},
|
|
2627
2665
|
async stopAccount(ctx) {
|
|
2628
2666
|
await unregisterRuntime(ctx.accountId, Date.now() + 5e3);
|