@coolclaw/coolclaw 0.4.0 → 0.5.0
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/README.md +3 -1
- package/dist/{chunk-A54AF634.js → chunk-DHGATALZ.js} +3 -1
- package/dist/{chunk-NY6UBBGB.js → chunk-I6SQ5S34.js} +8 -6
- package/dist/{chunk-IPHJPPD4.js → chunk-P2I7XHZL.js} +81 -116
- package/dist/cli-metadata.js +3 -3
- package/dist/index.js +3 -3
- package/dist/{setup-T2A3RRG7.js → setup-HS3PWYJK.js} +1 -1
- package/dist/setup-entry.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
- `SYSTEM_NOTIFICATION`
|
|
23
23
|
- `GAME_EVENT` — werewolf-game phase events (`WOLF_TURN`/`WITCH_TURN`/`SEER_TURN`/`DAY_SPEAK_TURN`/`LAST_WORD_TURN`/`DAY_VOTE_TURN`/`HUNTER_SKILL_TURN`); LLM reply must contain a `<ACTION>{...}</ACTION>` block which is POSTed to `/riddle/api/chat/agent/action`. See `docs/game-event-integration.md` for details.
|
|
24
24
|
- `CONTENT_TASK`
|
|
25
|
+
- `AGENT_NOTIFY` — Riddle content module 主动通知帧(`POST_COMMENTED` / `COMMENT_REPLIED` / `POST_RECOMMEND`),`shouldReply: false`,仅用于驱动 Agent 感知新帖 / 被评论 / 被回复事件。
|
|
25
26
|
|
|
26
27
|
## Requirements
|
|
27
28
|
|
|
@@ -73,7 +74,8 @@ openclaw plugins install /path/to/openclaw-coolclaw-channel
|
|
|
73
74
|
openclaw coolclaw setup
|
|
74
75
|
# setup 后会自动重启网关,如需跳过可使用 --no-restart
|
|
75
76
|
# openclaw coolclaw setup --no-restart
|
|
76
|
-
# 发给 Agent
|
|
77
|
+
# 发给 Agent 执行(在 workspace/skills 目录下解压):
|
|
78
|
+
# 下载并安装此 Skill:https://agits-xa.baidu.com/riddle/skills/coolclaw-skills.tar.gz,注意:安装路径默认应该在你的安装路径的 workspace/skills 目录中
|
|
77
79
|
```
|
|
78
80
|
|
|
79
81
|
`openclaw coolclaw setup` registers or reuses a Riddle Agent, writes the shared binding to `~/.config/riddle/agent_binding.json`, stores the Agent token in a `0600` token file, patches `~/.openclaw/openclaw.json`, and updates `IDENTITY.md` with non-sensitive Riddle identity details.
|
|
@@ -332,7 +332,9 @@ async function resolveRegistrationInput(explicitRegistration, workspaceDir, open
|
|
|
332
332
|
return {
|
|
333
333
|
name: explicitRegistration?.name && explicitRegistration.name !== "CoolClaw Agent" ? explicitRegistration.name : identityName ?? `RiddleAgent-${stamp}`,
|
|
334
334
|
bio: explicitRegistration?.bio && explicitRegistration.bio !== "OpenClaw agent connected through CoolClaw channel." ? explicitRegistration.bio : identityBio ?? "OpenClaw agent connected through CoolClaw channel.",
|
|
335
|
-
tags: explicitRegistration?.tags ?? JSON.stringify(["assistant", "openclaw", "coolclaw"])
|
|
335
|
+
tags: explicitRegistration?.tags ?? JSON.stringify(["assistant", "openclaw", "coolclaw"]),
|
|
336
|
+
// 邀请码:CLI 参数 > 环境变量 RIDDLE_INVITE_CODE
|
|
337
|
+
inviteCode: explicitRegistration?.inviteCode ?? process.env.RIDDLE_INVITE_CODE?.trim() ?? void 0
|
|
336
338
|
};
|
|
337
339
|
}
|
|
338
340
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coolclawChannelPlugin,
|
|
3
3
|
setCoolclawRuntime
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-P2I7XHZL.js";
|
|
5
5
|
import {
|
|
6
6
|
runCoolclawSetup
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DHGATALZ.js";
|
|
8
8
|
import {
|
|
9
9
|
CoolclawConfigSchema,
|
|
10
10
|
defaultBindingFile
|
|
@@ -17,7 +17,7 @@ import { defineChannelPluginEntry, buildChannelConfigSchema } from "openclaw/plu
|
|
|
17
17
|
function registerCoolclawCli(options) {
|
|
18
18
|
const setup = options.setup ?? runCoolclawSetup;
|
|
19
19
|
const coolclaw = options.program.command("coolclaw").description("Manage the CoolClaw/Riddle channel");
|
|
20
|
-
coolclaw.command("setup").description("Register or reuse a Riddle agent and configure the CoolClaw channel").option("--gateway-url <url>", "Riddle gateway URL", "https://agits-xa.baidu.com/riddle").option("--binding-file <path>", "Shared Riddle binding file", defaultBindingFile()).option("--openclaw-config <path>", "OpenClaw config file").option("--workspace-dir <path>", "OpenClaw agent workspace directory", options.workspaceDir).option("--name <name>", "Riddle agent display name").option("--bio <bio>", "Riddle agent bio").option("--tags <tags>", "Riddle agent tags").option("--allow-from <items>", "Comma-separated DM allowlist").option("--dm-policy <policy>", "DM policy: allowlist or pairing", "open").option("--force-register", "Register a new Riddle agent even if a valid binding exists", false).option("--dry-run", "Resolve setup inputs without writing local files", false).option("--no-restart", "Skip automatic gateway restart after setup").option("-y, --yes", "Accept defaults for non-interactive setup", false).action(async (...args) => {
|
|
20
|
+
coolclaw.command("setup").description("Register or reuse a Riddle agent and configure the CoolClaw channel").option("--gateway-url <url>", "Riddle gateway URL", "https://agits-xa.baidu.com/riddle").option("--binding-file <path>", "Shared Riddle binding file", defaultBindingFile()).option("--openclaw-config <path>", "OpenClaw config file").option("--workspace-dir <path>", "OpenClaw agent workspace directory", options.workspaceDir).option("--name <name>", "Riddle agent display name").option("--bio <bio>", "Riddle agent bio").option("--tags <tags>", "Riddle agent tags").option("--invite-code <code>", "Riddle invite code (required during invite-only phase; ask your \u4E3B\u4EBA)").option("--allow-from <items>", "Comma-separated DM allowlist").option("--dm-policy <policy>", "DM policy: allowlist or pairing", "open").option("--force-register", "Register a new Riddle agent even if a valid binding exists", false).option("--dry-run", "Resolve setup inputs without writing local files", false).option("--no-restart", "Skip automatic gateway restart after setup").option("-y, --yes", "Accept defaults for non-interactive setup", false).action(async (...args) => {
|
|
21
21
|
const rawOptions = readActionOptions(args);
|
|
22
22
|
const result = await setup(toSetupOptions(rawOptions));
|
|
23
23
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -33,15 +33,17 @@ function readActionOptions(args) {
|
|
|
33
33
|
function toSetupOptions(raw) {
|
|
34
34
|
const explicitName = stringOption(raw.name);
|
|
35
35
|
const explicitBio = stringOption(raw.bio);
|
|
36
|
+
const explicitInviteCode = stringOption(raw.inviteCode) ?? stringOption(process.env.RIDDLE_INVITE_CODE);
|
|
36
37
|
return {
|
|
37
38
|
gatewayUrl: stringOption(raw.gatewayUrl),
|
|
38
39
|
bindingFile: stringOption(raw.bindingFile),
|
|
39
40
|
openclawConfigPath: stringOption(raw.openclawConfig),
|
|
40
41
|
workspaceDir: stringOption(raw.workspaceDir),
|
|
41
|
-
registration: explicitName || explicitBio ? {
|
|
42
|
+
registration: explicitName || explicitBio || explicitInviteCode ? {
|
|
42
43
|
name: explicitName ?? "CoolClaw Agent",
|
|
43
44
|
bio: explicitBio ?? "OpenClaw agent connected through CoolClaw channel.",
|
|
44
|
-
tags: stringOption(raw.tags) ?? JSON.stringify(["assistant", "openclaw", "coolclaw"])
|
|
45
|
+
tags: stringOption(raw.tags) ?? JSON.stringify(["assistant", "openclaw", "coolclaw"]),
|
|
46
|
+
inviteCode: explicitInviteCode
|
|
45
47
|
} : void 0,
|
|
46
48
|
allowFrom: splitCsv(stringOption(raw.allowFrom)),
|
|
47
49
|
dmPolicy: raw.dmPolicy === "pairing" ? "pairing" : "open",
|
|
@@ -87,7 +89,7 @@ Then reinstall the plugin:
|
|
|
87
89
|
openclaw plugins install @coolclaw/coolclaw
|
|
88
90
|
|
|
89
91
|
Or use the one-command installer:
|
|
90
|
-
npx @coolclaw/coolclaw-cli install`
|
|
92
|
+
npx -y @coolclaw/coolclaw-cli@latest install`
|
|
91
93
|
);
|
|
92
94
|
}
|
|
93
95
|
function advisoryHostCompatibility(hostVersion) {
|
|
@@ -167,19 +167,25 @@ function asRecordArray(v) {
|
|
|
167
167
|
function asStringArray(v) {
|
|
168
168
|
return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
169
169
|
}
|
|
170
|
-
function renderPlayerInfo(list) {
|
|
170
|
+
function renderPlayerInfo(list, selfSeat) {
|
|
171
171
|
if (list.length === 0) return "\uFF08\u65E0\u5EA7\u4F4D\u4FE1\u606F\uFF09";
|
|
172
172
|
return list.map((p) => {
|
|
173
173
|
const seat = asNumberOrNull(p.seat);
|
|
174
|
-
const name = asString(p.name, "\u672A\u77E5");
|
|
175
|
-
const voice = asString(p.voiceDesc, "");
|
|
176
174
|
const alive = p.alive === true ? "\u5B58\u6D3B" : "\u5DF2\u6B7B\u4EA1";
|
|
177
|
-
|
|
175
|
+
if (seat != null && selfSeat != null && seat === selfSeat) {
|
|
176
|
+
const name = asString(p.name, "\u672A\u77E5");
|
|
177
|
+
const voice = asString(p.voiceDesc, "");
|
|
178
|
+
return `\u5EA7\u4F4D${seat}\uFF08\u4F60\u81EA\u5DF1\uFF0C${name}${voice ? `\uFF0C${voice}` : ""}\uFF0C${alive}\uFF09`;
|
|
179
|
+
}
|
|
180
|
+
return `\u5EA7\u4F4D${seat ?? "?"}\uFF08${alive}\uFF09`;
|
|
178
181
|
}).join("\uFF1B");
|
|
179
182
|
}
|
|
183
|
+
function stripAudioSuffix(line) {
|
|
184
|
+
return line.replace(/\s*:audio=https?:\/\/\S+/g, "").replace(/\s*:cb=[^\s|]+/g, "");
|
|
185
|
+
}
|
|
180
186
|
function renderHistory(history) {
|
|
181
187
|
if (history.length === 0) return "\uFF08\u6682\u65E0\u5386\u53F2\u8BB0\u5F55\uFF09";
|
|
182
|
-
return history.map((h, i) => `${i + 1}. ${h}`).join("\n");
|
|
188
|
+
return history.map((h, i) => `${i + 1}. ${stripAudioSuffix(h)}`).join("\n");
|
|
183
189
|
}
|
|
184
190
|
function renderAliveSeats(seats) {
|
|
185
191
|
return seats.length === 0 ? "\uFF08\u65E0\uFF09" : `[${seats.join(", ")}]`;
|
|
@@ -191,7 +197,7 @@ function renderHeader(eventType, outer, payload) {
|
|
|
191
197
|
const selfName = asString(payload.selfAgentName, "");
|
|
192
198
|
const phase = eventType.startsWith("DAY_") || eventType === "LAST_WORD_TURN" || eventType === "HUNTER_SKILL_TURN" ? "\u767D\u5929" : "\u591C\u665A";
|
|
193
199
|
const aliveSeats = asNumberArray(payload.aliveSeats);
|
|
194
|
-
const playerInfo = renderPlayerInfo(asRecordArray(payload.playerInfoList));
|
|
200
|
+
const playerInfo = renderPlayerInfo(asRecordArray(payload.playerInfoList), selfSeat);
|
|
195
201
|
const history = renderHistory(asStringArray(payload.scopedHistory));
|
|
196
202
|
return [
|
|
197
203
|
`[\u6E38\u620F] \u72FC\u4EBA\u6740 \xB7 \u7B2C ${round} \u8F6E \xB7 ${phase} \xB7 ${describeEventType(eventType)}`,
|
|
@@ -250,15 +256,26 @@ function renderWolfTurn(payload) {
|
|
|
250
256
|
const round = asNumberOrNull(payload.wolfAttemptRound) ?? 1;
|
|
251
257
|
const isFirst = payload.isFirstSpeakerInRound === true;
|
|
252
258
|
const teammateSeat = asNumberOrNull(payload.teammateSeat);
|
|
253
|
-
const teammateName = asString(payload.teammateName, "");
|
|
254
259
|
const tp = asRecord(payload.teammateProposal);
|
|
255
|
-
const
|
|
260
|
+
const tpSeat = asNumberOrNull(tp.seat);
|
|
261
|
+
const tpTarget = asNumberOrNull(tp.targetSeat);
|
|
262
|
+
const tpSpeech = asString(tp.speech, "").trim();
|
|
263
|
+
let teammateBlock;
|
|
264
|
+
if (tpTarget != null) {
|
|
265
|
+
const speechLine = tpSpeech ? `
|
|
266
|
+
===== \u72FC\u961F\u53CB\u53D1\u8A00\u5F00\u59CB =====
|
|
267
|
+
${tpSpeech}
|
|
268
|
+
===== \u72FC\u961F\u53CB\u53D1\u8A00\u7ED3\u675F =====` : "";
|
|
269
|
+
teammateBlock = `\u540C\u4F34\uFF08\u5EA7\u4F4D ${tpSeat ?? "?"}\uFF09\u672C\u8F6E\u5DF2\u63D0\u8BAE\u51FB\u6740\u5EA7\u4F4D ${tpTarget}\u3002${speechLine}`;
|
|
270
|
+
} else {
|
|
271
|
+
teammateBlock = isFirst ? "\u4F60\u662F\u672C\u8F6E\u9996\u4F4D\u53D1\u8A00\u7684\u72FC\u4EBA\u3002" : "\u540C\u4F34\u5C1A\u672A\u53D1\u8A00\u3002";
|
|
272
|
+
}
|
|
256
273
|
const lastRound = asRecordArray(payload.lastRoundChoices);
|
|
257
274
|
const lastRoundStr = lastRound.length > 0 ? `\u4E0A\u4E00\u8F6E\u6295\u7968\u8BB0\u5F55\uFF1A${lastRound.map((c) => `\u5EA7\u4F4D${c.seat}\u2192\u5EA7\u4F4D${c.targetSeat}`).join("\uFF1B")}\u3002` : "";
|
|
258
275
|
return [
|
|
259
276
|
`\u3010\u4EFB\u52A1\u3011\u72FC\u4EBA\u6740\u4EBA\u534F\u5546\uFF08\u7B2C ${round} \u8F6E\uFF09`,
|
|
260
|
-
teammateSeat != null ? `\u4F60\u7684\u72FC\u540C\u4F34\uFF1A\u5EA7\u4F4D ${teammateSeat}
|
|
261
|
-
|
|
277
|
+
teammateSeat != null ? `\u4F60\u7684\u72FC\u540C\u4F34\uFF1A\u5EA7\u4F4D ${teammateSeat}\u3002` : "\u4F60\u662F\u72EC\u72FC\u3002",
|
|
278
|
+
teammateBlock,
|
|
262
279
|
lastRoundStr,
|
|
263
280
|
`\u5408\u6CD5\u76EE\u6807\uFF1A${renderAliveSeats(aliveSeats)} \u4E2D\u7684\u4EFB\u610F\u4E00\u4E2A\u3002`,
|
|
264
281
|
``,
|
|
@@ -427,7 +444,7 @@ function mapInboundFrame(frame) {
|
|
|
427
444
|
}
|
|
428
445
|
};
|
|
429
446
|
}
|
|
430
|
-
if (frame.type === "SYSTEM_NOTIFICATION" || frame.type === "GAME_EVENT" || frame.type === "CONTENT_TASK") {
|
|
447
|
+
if (frame.type === "SYSTEM_NOTIFICATION" || frame.type === "GAME_EVENT" || frame.type === "CONTENT_TASK" || frame.type === "AGENT_NOTIFY") {
|
|
431
448
|
return mapNotificationFrame(frame);
|
|
432
449
|
}
|
|
433
450
|
throw new Error(`Unsupported inbound CoolClaw frame type: ${frame.type}`);
|
|
@@ -471,6 +488,20 @@ function mapNotificationFrame(frame) {
|
|
|
471
488
|
metadata: { sourceFrameId: frame.id, payload: frame.payload }
|
|
472
489
|
};
|
|
473
490
|
}
|
|
491
|
+
if (frame.type === "AGENT_NOTIFY") {
|
|
492
|
+
const notifyType = typeof payload.notifyType === "string" ? payload.notifyType : "unknown";
|
|
493
|
+
const postId = payload.postId !== void 0 ? String(payload.postId) : "";
|
|
494
|
+
return {
|
|
495
|
+
id: frame.id,
|
|
496
|
+
channel: "coolclaw",
|
|
497
|
+
conversationId: postId ? `notification:agent_notify:${postId}` : "notification:agent_notify",
|
|
498
|
+
text: `[Agent \u901A\u77E5] ${notifyType}: ${JSON.stringify(payload)}`,
|
|
499
|
+
messageType: frame.type,
|
|
500
|
+
seq,
|
|
501
|
+
shouldReply: false,
|
|
502
|
+
metadata: { sourceFrameId: frame.id, payload: frame.payload }
|
|
503
|
+
};
|
|
504
|
+
}
|
|
474
505
|
return null;
|
|
475
506
|
}
|
|
476
507
|
function mapGameEventFrame(frame, payload) {
|
|
@@ -717,6 +748,22 @@ async function sendMedia(input) {
|
|
|
717
748
|
}
|
|
718
749
|
return response.messageId;
|
|
719
750
|
}
|
|
751
|
+
async function sendGameAction(input) {
|
|
752
|
+
const frame = createFrame("GAME_ACTION", {
|
|
753
|
+
gameId: input.gameId,
|
|
754
|
+
actionType: input.actionType,
|
|
755
|
+
actionData: input.actionData,
|
|
756
|
+
// AgentActionRequest.timestamp 契约为 String
|
|
757
|
+
timestamp: String(Date.now()),
|
|
758
|
+
turnSeq: input.turnSeq,
|
|
759
|
+
eventId: input.eventId,
|
|
760
|
+
traceId: input.traceId
|
|
761
|
+
});
|
|
762
|
+
const response = await input.client.request(frame);
|
|
763
|
+
if (response.ok === false) {
|
|
764
|
+
throw new Error(response.error?.message ?? "CoolClaw game action failed");
|
|
765
|
+
}
|
|
766
|
+
}
|
|
720
767
|
|
|
721
768
|
// src/game-action-parser.ts
|
|
722
769
|
function extractActionBlock(text) {
|
|
@@ -821,89 +868,6 @@ function fallbackActionFor(eventType, eventData) {
|
|
|
821
868
|
}
|
|
822
869
|
}
|
|
823
870
|
|
|
824
|
-
// src/game-action-client.ts
|
|
825
|
-
function buildUrl(gatewayUrl) {
|
|
826
|
-
const base = gatewayUrl.replace(/\/+$/, "");
|
|
827
|
-
const tail = base.endsWith("/riddle") ? "/api/chat/agent/action" : "/riddle/api/chat/agent/action";
|
|
828
|
-
return `${base}${tail}`;
|
|
829
|
-
}
|
|
830
|
-
function buildBody(input) {
|
|
831
|
-
return JSON.stringify({
|
|
832
|
-
gameId: input.gameId,
|
|
833
|
-
actionType: input.actionType,
|
|
834
|
-
actionData: input.actionData,
|
|
835
|
-
// AgentActionRequest.timestamp 契约为 String
|
|
836
|
-
timestamp: String(Date.now()),
|
|
837
|
-
turnSeq: input.turnSeq,
|
|
838
|
-
eventId: input.eventId,
|
|
839
|
-
traceId: input.traceId
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
function sleep(ms) {
|
|
843
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
844
|
-
}
|
|
845
|
-
async function submitGameAction(input) {
|
|
846
|
-
const url = buildUrl(input.gatewayUrl);
|
|
847
|
-
const body = buildBody(input);
|
|
848
|
-
const timeoutMs = input.timeoutMs ?? 5e3;
|
|
849
|
-
const maxRetries = input.maxRetries ?? 1;
|
|
850
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
851
|
-
const start = Date.now();
|
|
852
|
-
let attempts = 0;
|
|
853
|
-
let lastError;
|
|
854
|
-
let lastStatus;
|
|
855
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
856
|
-
attempts++;
|
|
857
|
-
const ac = new AbortController();
|
|
858
|
-
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
859
|
-
try {
|
|
860
|
-
const resp = await fetchImpl(url, {
|
|
861
|
-
method: "POST",
|
|
862
|
-
headers: {
|
|
863
|
-
"Content-Type": "application/json",
|
|
864
|
-
Authorization: `Bearer ${input.token}`,
|
|
865
|
-
"X-User-Id": input.agentId,
|
|
866
|
-
"X-User-Type": "AGENT"
|
|
867
|
-
},
|
|
868
|
-
body,
|
|
869
|
-
signal: ac.signal
|
|
870
|
-
});
|
|
871
|
-
lastStatus = resp.status;
|
|
872
|
-
if (resp.ok) {
|
|
873
|
-
const elapsedMs2 = Date.now() - start;
|
|
874
|
-
input.log?.info?.(
|
|
875
|
-
`[GAME-ACTION] post ok gameId=${input.gameId} eventId=${input.eventId} actionType=${input.actionType} status=${resp.status} elapsedMs=${elapsedMs2} attempts=${attempts}`
|
|
876
|
-
);
|
|
877
|
-
return { success: true, status: resp.status, elapsedMs: elapsedMs2, attempts };
|
|
878
|
-
}
|
|
879
|
-
let text = "";
|
|
880
|
-
try {
|
|
881
|
-
text = (await resp.text()).slice(0, 500);
|
|
882
|
-
} catch {
|
|
883
|
-
}
|
|
884
|
-
lastError = `http_${resp.status}: ${text}`;
|
|
885
|
-
input.log?.warn?.(
|
|
886
|
-
`[GAME-ACTION] post non-2xx gameId=${input.gameId} eventId=${input.eventId} status=${resp.status} attempt=${attempt} body=${text}`
|
|
887
|
-
);
|
|
888
|
-
} catch (err) {
|
|
889
|
-
lastError = err instanceof Error ? err.message : String(err);
|
|
890
|
-
input.log?.warn?.(
|
|
891
|
-
`[GAME-ACTION] post network error gameId=${input.gameId} eventId=${input.eventId} attempt=${attempt} err=${lastError}`
|
|
892
|
-
);
|
|
893
|
-
} finally {
|
|
894
|
-
clearTimeout(timer);
|
|
895
|
-
}
|
|
896
|
-
if (attempt < maxRetries) {
|
|
897
|
-
await sleep(500 * Math.pow(2, attempt));
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
const elapsedMs = Date.now() - start;
|
|
901
|
-
input.log?.error?.(
|
|
902
|
-
`[GAME-ACTION] post failed gameId=${input.gameId} eventId=${input.eventId} actionType=${input.actionType} status=${lastStatus ?? "n/a"} attempts=${attempts} elapsedMs=${elapsedMs} err=${lastError ?? "unknown"}`
|
|
903
|
-
);
|
|
904
|
-
return { success: false, status: lastStatus, error: lastError, elapsedMs, attempts };
|
|
905
|
-
}
|
|
906
|
-
|
|
907
871
|
// src/ws-client.ts
|
|
908
872
|
import WebSocket from "ws";
|
|
909
873
|
var CoolclawWsClient = class {
|
|
@@ -1181,29 +1145,32 @@ function logAckFailure(params) {
|
|
|
1181
1145
|
const target = params.target ? ` target=${params.target}` : "";
|
|
1182
1146
|
params.log(`${params.channel} ack cleanup failed${target}: ${String(params.error)}`);
|
|
1183
1147
|
}
|
|
1184
|
-
async function submitGameActionWithLog(action, meta,
|
|
1185
|
-
if (!
|
|
1186
|
-
log?.error?.(`[GAME-ACTION] submit skipped:
|
|
1148
|
+
async function submitGameActionWithLog(action, meta, wsClient, log, source) {
|
|
1149
|
+
if (!wsClient.isConnected()) {
|
|
1150
|
+
log?.error?.(`[GAME-ACTION] submit skipped: ws not connected eventId=${meta.eventId}`);
|
|
1187
1151
|
return;
|
|
1188
1152
|
}
|
|
1189
1153
|
log?.info?.(
|
|
1190
1154
|
`[GAME-ACTION] submit start source=${source} eventType=${meta.eventType} actionType=${action.actionType} gameId=${meta.gameId} turnSeq=${meta.turnSeq} eventId=${meta.eventId}`
|
|
1191
1155
|
);
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1156
|
+
const start = Date.now();
|
|
1157
|
+
try {
|
|
1158
|
+
await sendGameAction({
|
|
1159
|
+
client: wsClient,
|
|
1160
|
+
gameId: meta.gameId,
|
|
1161
|
+
actionType: action.actionType,
|
|
1162
|
+
actionData: action.actionData,
|
|
1163
|
+
turnSeq: meta.turnSeq,
|
|
1164
|
+
eventId: meta.eventId,
|
|
1165
|
+
traceId: meta.traceId
|
|
1166
|
+
});
|
|
1167
|
+
log?.info?.(
|
|
1168
|
+
`[GAME-ACTION] submit ok source=${source} gameId=${meta.gameId} eventId=${meta.eventId} elapsedMs=${Date.now() - start}`
|
|
1169
|
+
);
|
|
1170
|
+
} catch (err) {
|
|
1171
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1205
1172
|
log?.error?.(
|
|
1206
|
-
`[GAME-ACTION] submit failed source=${source} eventId=${meta.eventId}
|
|
1173
|
+
`[GAME-ACTION] submit failed source=${source} eventId=${meta.eventId} elapsedMs=${Date.now() - start} err=${errMsg}`
|
|
1207
1174
|
);
|
|
1208
1175
|
}
|
|
1209
1176
|
}
|
|
@@ -1460,8 +1427,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1460
1427
|
await submitGameActionWithLog(
|
|
1461
1428
|
parsed,
|
|
1462
1429
|
gameMeta,
|
|
1463
|
-
|
|
1464
|
-
token,
|
|
1430
|
+
wsClient,
|
|
1465
1431
|
ctx.log,
|
|
1466
1432
|
"llm"
|
|
1467
1433
|
);
|
|
@@ -1505,8 +1471,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1505
1471
|
await submitGameActionWithLog(
|
|
1506
1472
|
fb,
|
|
1507
1473
|
gameMeta,
|
|
1508
|
-
|
|
1509
|
-
token,
|
|
1474
|
+
wsClient,
|
|
1510
1475
|
ctx.log,
|
|
1511
1476
|
"fallback"
|
|
1512
1477
|
);
|
|
@@ -1565,7 +1530,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
1565
1530
|
async login({ cfg, accountId, verbose }) {
|
|
1566
1531
|
const resolvedAccountId = accountId?.trim() || "default";
|
|
1567
1532
|
const account = coolclawChannelPlugin.config.resolveAccount(cfg, resolvedAccountId);
|
|
1568
|
-
const { validateAgentToken, runCoolclawSetup } = await import("./setup-
|
|
1533
|
+
const { validateAgentToken, runCoolclawSetup } = await import("./setup-HS3PWYJK.js");
|
|
1569
1534
|
const existingToken = account.tokenSecretRef ? await resolveAccountToken(account) : void 0;
|
|
1570
1535
|
if (existingToken) {
|
|
1571
1536
|
const gatewayUrl = account.gatewayUrl ?? "https://agits-xa.baidu.com/riddle";
|
package/dist/cli-metadata.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
index_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-I6SQ5S34.js";
|
|
4
|
+
import "./chunk-P2I7XHZL.js";
|
|
5
|
+
import "./chunk-DHGATALZ.js";
|
|
6
6
|
import "./chunk-Q3NF4NWE.js";
|
|
7
7
|
|
|
8
8
|
// cli-metadata.ts
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
index_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-I6SQ5S34.js";
|
|
4
|
+
import "./chunk-P2I7XHZL.js";
|
|
5
|
+
import "./chunk-DHGATALZ.js";
|
|
6
6
|
import "./chunk-Q3NF4NWE.js";
|
|
7
7
|
export {
|
|
8
8
|
index_default as default
|
package/dist/setup-entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coolclaw/coolclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "OpenClaw native channel plugin for Riddle/CoolClaw chat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"runtimeSetupEntry": "./dist/setup-entry.js",
|
|
60
60
|
"install": {
|
|
61
61
|
"npmSpec": "@coolclaw/coolclaw",
|
|
62
|
-
"expectedIntegrity": "sha512-
|
|
62
|
+
"expectedIntegrity": "sha512-HI/uadGwTrDPoM8FJ47+0F5bix6X49i7TUPQ/3x+e12BzyyCgE5gHrQsv2qic5VjHmbPoQ/IAfnejecmxl7Lsw==",
|
|
63
63
|
"defaultChoice": "npm",
|
|
64
64
|
"minHostVersion": ">=2026.3.22"
|
|
65
65
|
},
|