@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/index.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
|
|
|
@@ -1861,7 +1863,7 @@ var CircuitBreaker = class {
|
|
|
1861
1863
|
};
|
|
1862
1864
|
|
|
1863
1865
|
// src/version.ts
|
|
1864
|
-
var PACKAGE_VERSION = "0.6.
|
|
1866
|
+
var PACKAGE_VERSION = "0.6.15";
|
|
1865
1867
|
|
|
1866
1868
|
// src/outbound.ts
|
|
1867
1869
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2390,8 +2392,6 @@ function unregisterRuntime(accountId, deadlineMs = Date.now() + 5e3) {
|
|
|
2390
2392
|
function getRuntime(accountId) {
|
|
2391
2393
|
return registry.get(accountId)?.runtime;
|
|
2392
2394
|
}
|
|
2393
|
-
|
|
2394
|
-
// src/binding/inbound-bridge.ts
|
|
2395
2395
|
function createInboundBridge(deps) {
|
|
2396
2396
|
return async function onInbound(event) {
|
|
2397
2397
|
switch (event.kind) {
|
|
@@ -2428,8 +2428,8 @@ async function handleMessage(deps, event) {
|
|
|
2428
2428
|
if (!body && !event.content.attachmentId && !event.content.data) {
|
|
2429
2429
|
return;
|
|
2430
2430
|
}
|
|
2431
|
-
const
|
|
2432
|
-
if (typeof
|
|
2431
|
+
const channelRuntime = deps.channelRuntime;
|
|
2432
|
+
if (!channelRuntime || typeof channelRuntime.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
|
|
2433
2433
|
deps.logger.error(
|
|
2434
2434
|
{
|
|
2435
2435
|
event: "inbound_dispatch_unavailable",
|
|
@@ -2438,50 +2438,90 @@ async function handleMessage(deps, event) {
|
|
|
2438
2438
|
conversationKind: event.conversationKind,
|
|
2439
2439
|
sender: event.sender
|
|
2440
2440
|
},
|
|
2441
|
-
"channelRuntime
|
|
2441
|
+
"channelRuntime unavailable \u2014 message NOT dispatched to agent (will be redelivered on next sync)"
|
|
2442
2442
|
);
|
|
2443
2443
|
return;
|
|
2444
2444
|
}
|
|
2445
2445
|
const recipientHandle = selfHandle ?? "me";
|
|
2446
2446
|
const conversationLabel = event.conversationKind === "group" ? `group ${event.conversationId}` : `dm with @${senderHandle}`;
|
|
2447
|
+
const sendReply = async (replyText) => {
|
|
2448
|
+
if (!replyText) return;
|
|
2449
|
+
const target = event.conversationKind === "group" ? { kind: "group", conversationId: event.conversationId } : { kind: "direct", to: senderHandle };
|
|
2450
|
+
await deps.runtime.sendMessage({
|
|
2451
|
+
...target,
|
|
2452
|
+
type: "text",
|
|
2453
|
+
content: { text: replyText },
|
|
2454
|
+
metadata: { reply_to: event.messageId }
|
|
2455
|
+
});
|
|
2456
|
+
};
|
|
2457
|
+
const deliver2 = async (payload) => {
|
|
2458
|
+
const replyText = payload.text ?? extractText(payload.blocks);
|
|
2459
|
+
await sendReply(replyText);
|
|
2460
|
+
};
|
|
2447
2461
|
try {
|
|
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
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
});
|
|
2462
|
+
if (event.conversationKind === "direct") {
|
|
2463
|
+
await directDm.dispatchInboundDirectDmWithRuntime({
|
|
2464
|
+
cfg: deps.gatewayCfg,
|
|
2465
|
+
runtime: { channel: channelRuntime },
|
|
2466
|
+
channel: "agentchat",
|
|
2467
|
+
channelLabel: "AgentChat",
|
|
2468
|
+
accountId: deps.accountId,
|
|
2469
|
+
peer: { kind: "direct", id: senderHandle },
|
|
2470
|
+
senderId: senderHandle,
|
|
2471
|
+
senderAddress: `@${senderHandle}`,
|
|
2472
|
+
recipientAddress: `@${recipientHandle}`,
|
|
2473
|
+
conversationLabel,
|
|
2474
|
+
rawBody: body,
|
|
2475
|
+
messageId: event.messageId,
|
|
2476
|
+
timestamp: typeof event.createdAt === "number" ? event.createdAt : Date.parse(event.createdAt),
|
|
2477
|
+
provider: "agentchat",
|
|
2478
|
+
surface: "agentchat",
|
|
2479
|
+
deliver: deliver2,
|
|
2480
|
+
onRecordError: (err3) => {
|
|
2481
|
+
deps.logger.error(
|
|
2482
|
+
{ err: err3 instanceof Error ? err3.message : String(err3), messageId: event.messageId },
|
|
2483
|
+
"recordInboundSession failed"
|
|
2484
|
+
);
|
|
2485
|
+
},
|
|
2486
|
+
onDispatchError: (err3, info) => {
|
|
2487
|
+
deps.logger.error(
|
|
2488
|
+
{
|
|
2489
|
+
err: err3 instanceof Error ? err3.message : String(err3),
|
|
2490
|
+
messageId: event.messageId,
|
|
2491
|
+
kind: info.kind
|
|
2492
|
+
},
|
|
2493
|
+
"inbound dispatch failed"
|
|
2494
|
+
);
|
|
2482
2495
|
}
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2496
|
+
});
|
|
2497
|
+
} else {
|
|
2498
|
+
const dispatcher = channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher;
|
|
2499
|
+
const sessionKey = `agentchat:${deps.accountId}:group:${event.conversationId}`;
|
|
2500
|
+
await dispatcher({
|
|
2501
|
+
cfg: deps.gatewayCfg,
|
|
2502
|
+
ctx: {
|
|
2503
|
+
Body: body,
|
|
2504
|
+
BodyForAgent: body,
|
|
2505
|
+
RawBody: body,
|
|
2506
|
+
CommandBody: body,
|
|
2507
|
+
From: `@${senderHandle}`,
|
|
2508
|
+
To: `@${recipientHandle}`,
|
|
2509
|
+
SessionKey: sessionKey,
|
|
2510
|
+
AccountId: deps.accountId,
|
|
2511
|
+
ChatType: "group",
|
|
2512
|
+
ConversationLabel: conversationLabel,
|
|
2513
|
+
SenderId: senderHandle,
|
|
2514
|
+
Provider: "agentchat",
|
|
2515
|
+
Surface: "agentchat",
|
|
2516
|
+
MessageSid: event.messageId,
|
|
2517
|
+
MessageSidFull: event.messageId,
|
|
2518
|
+
Timestamp: event.createdAt,
|
|
2519
|
+
OriginatingChannel: "agentchat",
|
|
2520
|
+
OriginatingTo: `@${recipientHandle}`
|
|
2521
|
+
},
|
|
2522
|
+
dispatcherOptions: { deliver: deliver2 }
|
|
2523
|
+
});
|
|
2524
|
+
}
|
|
2485
2525
|
} catch (err3) {
|
|
2486
2526
|
deps.logger.error(
|
|
2487
2527
|
{
|
|
@@ -2620,17 +2660,15 @@ var agentchatGatewayAdapter = {
|
|
|
2620
2660
|
gatewayCfg: ctx.cfg,
|
|
2621
2661
|
selfHandle: account.config.agentHandle
|
|
2622
2662
|
});
|
|
2623
|
-
ctx.abortSignal
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
{ once: true }
|
|
2633
|
-
);
|
|
2663
|
+
await channelLifecycle.waitUntilAbort(ctx.abortSignal, async () => {
|
|
2664
|
+
try {
|
|
2665
|
+
await unregisterRuntime(ctx.accountId, Date.now() + 5e3);
|
|
2666
|
+
} catch (err3) {
|
|
2667
|
+
ctx.log?.error?.(
|
|
2668
|
+
`[agentchat:${ctx.accountId}] unregisterRuntime failed on abort: ${err3 instanceof Error ? err3.message : String(err3)}`
|
|
2669
|
+
);
|
|
2670
|
+
}
|
|
2671
|
+
});
|
|
2634
2672
|
},
|
|
2635
2673
|
async stopAccount(ctx) {
|
|
2636
2674
|
await unregisterRuntime(ctx.accountId, Date.now() + 5e3);
|