@coolclaw/coolclaw 1.0.12 → 1.0.13
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.
|
@@ -416,14 +416,8 @@ async function handleInboundFrame(input) {
|
|
|
416
416
|
await ackFrameSeq(input);
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
const ackAfterDispatch = envelope.metadata.gameEvent === true;
|
|
420
|
-
if (!ackAfterDispatch) {
|
|
421
|
-
await ackProcessedSeq(input, envelope);
|
|
422
|
-
}
|
|
423
419
|
await input.dispatch(envelope);
|
|
424
|
-
|
|
425
|
-
await ackProcessedSeq(input, envelope);
|
|
426
|
-
}
|
|
420
|
+
await ackProcessedSeq(input, envelope);
|
|
427
421
|
}
|
|
428
422
|
function mapNotificationFrame(frame) {
|
|
429
423
|
const payload = isRecord3(frame.payload) ? frame.payload : {};
|
|
@@ -1223,6 +1217,15 @@ function logAckFailure(params) {
|
|
|
1223
1217
|
const target = params.target ? ` target=${params.target}` : "";
|
|
1224
1218
|
params.log(`${params.channel} ack cleanup failed${target}: ${String(params.error)}`);
|
|
1225
1219
|
}
|
|
1220
|
+
function assertInboundRuntimeAvailable(runtime, context) {
|
|
1221
|
+
if (runtime?.channel) {
|
|
1222
|
+
return runtime.channel;
|
|
1223
|
+
}
|
|
1224
|
+
if (context.isGameEvent) {
|
|
1225
|
+
throw new Error("CoolClaw runtime.channel unavailable while dispatching GAME_EVENT");
|
|
1226
|
+
}
|
|
1227
|
+
throw new Error(`CoolClaw runtime.channel unavailable while dispatching ${context.messageType}`);
|
|
1228
|
+
}
|
|
1226
1229
|
async function submitGameActionWithLog(action, meta, wsClient, log, source, rawResponse, auditMeta) {
|
|
1227
1230
|
if (!wsClient.isConnected()) {
|
|
1228
1231
|
log?.error?.(`[GAME-ACTION] submit skipped: ws not connected eventId=${meta.eventId}`);
|
|
@@ -1477,7 +1480,13 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1477
1480
|
);
|
|
1478
1481
|
}
|
|
1479
1482
|
const runtime = getCoolclawRuntime();
|
|
1480
|
-
|
|
1483
|
+
let runtimeChannel;
|
|
1484
|
+
try {
|
|
1485
|
+
runtimeChannel = assertInboundRuntimeAvailable(runtime, {
|
|
1486
|
+
isGameEvent,
|
|
1487
|
+
messageType: envelope.messageType
|
|
1488
|
+
});
|
|
1489
|
+
} catch (err) {
|
|
1481
1490
|
logInboundDrop({ log: ctx.log?.warn?.bind(ctx.log) ?? (() => {
|
|
1482
1491
|
}), channel: "coolclaw", reason: "runtime not available; skipping dispatch" });
|
|
1483
1492
|
if (isGameEvent && gameMeta) {
|
|
@@ -1490,29 +1499,30 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1490
1499
|
if (submitted === "failed") {
|
|
1491
1500
|
throw new Error("game fallback submit failed: runtime_not_available");
|
|
1492
1501
|
}
|
|
1502
|
+
return;
|
|
1493
1503
|
}
|
|
1494
|
-
|
|
1504
|
+
throw err;
|
|
1495
1505
|
}
|
|
1496
1506
|
try {
|
|
1497
1507
|
const isGroup = envelope.conversationId.startsWith("group:");
|
|
1498
1508
|
const peer = isGroup ? { kind: "group", id: envelope.group?.groupId ?? envelope.conversationId } : { kind: "direct", id: envelope.conversationId };
|
|
1499
|
-
if (!
|
|
1509
|
+
if (!runtimeChannel.routing?.resolveAgentRoute) {
|
|
1500
1510
|
throw new Error(
|
|
1501
1511
|
"CoolClaw requires runtime.channel.routing.resolveAgentRoute. Please upgrade OpenClaw to >=2026.3.22."
|
|
1502
1512
|
);
|
|
1503
1513
|
}
|
|
1504
|
-
const route = await
|
|
1514
|
+
const route = await runtimeChannel.routing.resolveAgentRoute({
|
|
1505
1515
|
cfg: ctx.cfg,
|
|
1506
1516
|
channel: "coolclaw",
|
|
1507
1517
|
accountId: ctx.accountId,
|
|
1508
1518
|
peer
|
|
1509
1519
|
});
|
|
1510
|
-
if (!
|
|
1520
|
+
if (!runtimeChannel.session?.resolveStorePath) {
|
|
1511
1521
|
throw new Error(
|
|
1512
1522
|
"CoolClaw requires runtime.channel.session.resolveStorePath. Please upgrade OpenClaw to >=2026.3.22."
|
|
1513
1523
|
);
|
|
1514
1524
|
}
|
|
1515
|
-
const storePath =
|
|
1525
|
+
const storePath = runtimeChannel.session.resolveStorePath(
|
|
1516
1526
|
ctx.cfg.session?.store,
|
|
1517
1527
|
{ agentId: route.agentId }
|
|
1518
1528
|
);
|
|
@@ -1528,22 +1538,22 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1528
1538
|
deliveryTarget = normalizeCoolclawTarget(envelope.conversationId);
|
|
1529
1539
|
}
|
|
1530
1540
|
const bodyForAgent = buildBodyForAgent(envelope);
|
|
1531
|
-
if (typeof
|
|
1541
|
+
if (typeof runtimeChannel.reply?.finalizeInboundContext !== "function") {
|
|
1532
1542
|
throw new Error(
|
|
1533
1543
|
"CoolClaw requires runtime.channel.reply.finalizeInboundContext. Please upgrade OpenClaw to >=2026.3.22."
|
|
1534
1544
|
);
|
|
1535
1545
|
}
|
|
1536
|
-
if (typeof
|
|
1546
|
+
if (typeof runtimeChannel.reply?.dispatchReplyWithBufferedBlockDispatcher !== "function") {
|
|
1537
1547
|
throw new Error(
|
|
1538
1548
|
"CoolClaw requires runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher. Please upgrade OpenClaw to >=2026.3.22."
|
|
1539
1549
|
);
|
|
1540
1550
|
}
|
|
1541
|
-
if (typeof
|
|
1551
|
+
if (typeof runtimeChannel.session?.recordInboundSession !== "function") {
|
|
1542
1552
|
throw new Error(
|
|
1543
1553
|
"CoolClaw requires runtime.channel.session.recordInboundSession. Please upgrade OpenClaw to >=2026.3.22."
|
|
1544
1554
|
);
|
|
1545
1555
|
}
|
|
1546
|
-
const ctxPayload =
|
|
1556
|
+
const ctxPayload = runtimeChannel.reply.finalizeInboundContext({
|
|
1547
1557
|
Body: envelope.text,
|
|
1548
1558
|
BodyForAgent: bodyForAgent,
|
|
1549
1559
|
RawBody: envelope.text,
|
|
@@ -1563,7 +1573,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1563
1573
|
});
|
|
1564
1574
|
const sessionKey = ctxPayload.SessionKey ?? route.sessionKey;
|
|
1565
1575
|
const mainSessionKey = route.mainSessionKey;
|
|
1566
|
-
await
|
|
1576
|
+
await runtimeChannel.session.recordInboundSession({
|
|
1567
1577
|
storePath,
|
|
1568
1578
|
sessionKey,
|
|
1569
1579
|
ctx: ctxPayload,
|
|
@@ -1572,7 +1582,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1572
1582
|
ctx.log?.warn(`recordInboundSession failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1573
1583
|
}
|
|
1574
1584
|
});
|
|
1575
|
-
await
|
|
1585
|
+
await runtimeChannel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
1576
1586
|
ctx: ctxPayload,
|
|
1577
1587
|
cfg: ctx.cfg,
|
|
1578
1588
|
// 群聊强制走 automatic:CoolClaw 群聊业务语义就是 @ 即回,
|
package/dist/cli-metadata.js
CHANGED
package/dist/index.js
CHANGED
package/dist/setup-entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coolclaw/coolclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "OpenClaw native channel plugin for Riddle/CoolClaw chat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"runtimeSetupEntry": "./dist/setup-entry.js",
|
|
73
73
|
"install": {
|
|
74
74
|
"npmSpec": "@coolclaw/coolclaw",
|
|
75
|
-
"expectedIntegrity": "sha512-
|
|
75
|
+
"expectedIntegrity": "sha512-lRGll+tauQxhgsqtOWlEkM+MKZwDQpib/s1A4mZSQB+PDRsvMzuXKQiX0ipEUQo1/HPjlLgDRkM/5A6GX45kag==",
|
|
76
76
|
"defaultChoice": "npm",
|
|
77
77
|
"minHostVersion": ">=2026.3.22"
|
|
78
78
|
},
|