@coolclaw/coolclaw 0.4.1 → 0.5.1

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 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 执行:下载并安装此Skill https://agits-xa.baidu.com/riddle/skills/coolclaw-skill.tar.gz
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.
@@ -170,17 +170,17 @@ async function runCoolclawSetup(options = {}) {
170
170
  const openclawConfigPath = options.openclawConfigPath ?? defaultOpenClawConfigFile();
171
171
  const existingBinding = await loadBinding(bindingFile);
172
172
  const existingToken = await readTokenRef(existingBinding.tokenRef);
173
+ const canReuse = !options.forceRegister && existingBinding.agentId.length > 0 && Boolean(existingToken) && await validateAgentToken(gatewayUrl, existingToken);
173
174
  if (options.dryRun) {
174
175
  return {
175
- mode: "dry-run",
176
+ mode: canReuse ? "reuse" : "dry-run",
176
177
  gatewayUrl,
177
- agentId: existingBinding.agentId,
178
+ agentId: canReuse ? existingBinding.agentId : "",
178
179
  bindingFile,
179
180
  openclawConfigPath,
180
181
  tokenSavedTo: tokenFileFromBinding(existingBinding, bindingFile)
181
182
  };
182
183
  }
183
- const canReuse = !options.forceRegister && existingBinding.agentId.length > 0 && Boolean(existingToken) && await validateAgentToken(gatewayUrl, existingToken);
184
184
  const binding = canReuse ? existingBinding : await registerAndPersistBinding({
185
185
  gatewayUrl,
186
186
  bindingFile,
@@ -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
 
@@ -444,7 +444,7 @@ function mapInboundFrame(frame) {
444
444
  }
445
445
  };
446
446
  }
447
- 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") {
448
448
  return mapNotificationFrame(frame);
449
449
  }
450
450
  throw new Error(`Unsupported inbound CoolClaw frame type: ${frame.type}`);
@@ -488,6 +488,20 @@ function mapNotificationFrame(frame) {
488
488
  metadata: { sourceFrameId: frame.id, payload: frame.payload }
489
489
  };
490
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
+ }
491
505
  return null;
492
506
  }
493
507
  function mapGameEventFrame(frame, payload) {
@@ -1516,7 +1530,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
1516
1530
  async login({ cfg, accountId, verbose }) {
1517
1531
  const resolvedAccountId = accountId?.trim() || "default";
1518
1532
  const account = coolclawChannelPlugin.config.resolveAccount(cfg, resolvedAccountId);
1519
- const { validateAgentToken, runCoolclawSetup } = await import("./setup-T2A3RRG7.js");
1533
+ const { validateAgentToken, runCoolclawSetup } = await import("./setup-OG74IIBU.js");
1520
1534
  const existingToken = account.tokenSecretRef ? await resolveAccountToken(account) : void 0;
1521
1535
  if (existingToken) {
1522
1536
  const gatewayUrl = account.gatewayUrl ?? "https://agits-xa.baidu.com/riddle";
@@ -0,0 +1,92 @@
1
+ import {
2
+ coolclawChannelPlugin,
3
+ setCoolclawRuntime
4
+ } from "./chunk-FFEQQ4B4.js";
5
+ import {
6
+ CoolclawConfigSchema,
7
+ defaultBindingFile
8
+ } from "./chunk-Q3NF4NWE.js";
9
+
10
+ // index.ts
11
+ import { defineChannelPluginEntry, buildChannelConfigSchema } from "openclaw/plugin-sdk/core";
12
+
13
+ // src/cli.ts
14
+ function registerCoolclawCli(options) {
15
+ const coolclaw = options.program.command("coolclaw").description("Manage the CoolClaw/Riddle channel");
16
+ coolclaw.command("status").description("Show the shared Riddle binding location used by CoolClaw").action(() => {
17
+ console.log(JSON.stringify({ bindingFile: defaultBindingFile() }, null, 2));
18
+ });
19
+ }
20
+
21
+ // src/compat.ts
22
+ var SUPPORTED_HOST_MIN = "2026.3.22";
23
+ var MAX_TESTED_VERSION = "2026.5.7";
24
+ function parseVersion(v) {
25
+ const clean = v.split("-")[0].replace(/\s*\(.*\)/, "").trim();
26
+ const [y, m, d] = clean.split(".").map(Number);
27
+ return [y || 0, m || 0, d || 0];
28
+ }
29
+ function cmp(a, b) {
30
+ const [ay, am, ad] = parseVersion(a);
31
+ const [by, bm, bd] = parseVersion(b);
32
+ if (ay !== by) return ay > by ? 1 : -1;
33
+ if (am !== bm) return am > bm ? 1 : -1;
34
+ if (ad !== bd) return ad > bd ? 1 : -1;
35
+ return 0;
36
+ }
37
+ function assertHostCompatibility(hostVersion) {
38
+ if (!hostVersion || hostVersion === "unknown") return;
39
+ if (cmp(hostVersion, SUPPORTED_HOST_MIN) >= 0) return;
40
+ throw new Error(
41
+ `This version of @coolclaw/coolclaw requires OpenClaw >=${SUPPORTED_HOST_MIN}, but found ${hostVersion}. Please upgrade OpenClaw:
42
+ npm install -g openclaw@latest
43
+ Then reinstall the plugin:
44
+ openclaw plugins install @coolclaw/coolclaw
45
+
46
+ Or use the one-command installer:
47
+ npx -y @coolclaw/coolclaw-cli@latest install`
48
+ );
49
+ }
50
+ function advisoryHostCompatibility(hostVersion) {
51
+ if (!hostVersion || hostVersion === "unknown") return;
52
+ if (cmp(hostVersion, MAX_TESTED_VERSION) > 0) {
53
+ console.warn(
54
+ `[coolclaw] Host version ${hostVersion} is newer than the latest tested version (${MAX_TESTED_VERSION}). Proceeding without version gate; please report incompatibilities.`
55
+ );
56
+ }
57
+ }
58
+
59
+ // index.ts
60
+ var entry = defineChannelPluginEntry({
61
+ id: "coolclaw",
62
+ name: "CoolClaw",
63
+ description: "CoolClaw/Riddle messaging channel for OpenClaw",
64
+ configSchema: buildChannelConfigSchema(CoolclawConfigSchema),
65
+ plugin: coolclawChannelPlugin,
66
+ registerCliMetadata(api) {
67
+ api.registerCli(
68
+ ({ program }) => {
69
+ registerCoolclawCli({ program });
70
+ },
71
+ {
72
+ descriptors: [
73
+ {
74
+ name: "coolclaw",
75
+ description: "Manage the CoolClaw/Riddle channel",
76
+ hasSubcommands: true
77
+ }
78
+ ]
79
+ }
80
+ );
81
+ },
82
+ registerFull(api) {
83
+ assertHostCompatibility(api.runtime?.version);
84
+ advisoryHostCompatibility(api.runtime?.version);
85
+ setCoolclawRuntime(api.runtime);
86
+ }
87
+ });
88
+ var index_default = entry;
89
+
90
+ export {
91
+ index_default
92
+ };
@@ -1,6 +1,6 @@
1
1
  import entry from './index.js';
2
2
  import 'openclaw/plugin-sdk/core';
3
- import './types-y7-Cr6xf.js';
3
+ import './types-DYTarCqf.js';
4
4
 
5
5
 
6
6
 
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  index_default
3
- } from "./chunk-QZL3FKVL.js";
4
- import "./chunk-XVB6UKBR.js";
5
- import "./chunk-A54AF634.js";
3
+ } from "./chunk-KLWIUZCZ.js";
4
+ import "./chunk-FFEQQ4B4.js";
5
+ import "./chunk-FBTRQUNW.js";
6
6
  import "./chunk-Q3NF4NWE.js";
7
7
 
8
8
  // cli-metadata.ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,37 @@
1
1
  import { OpenClawPluginApi, ChannelPlugin, PluginRuntime } from 'openclaw/plugin-sdk/core';
2
- import { C as CoolclawAccount } from './types-y7-Cr6xf.js';
2
+ import { C as CoolclawDmPolicy, a as CoolclawAccount } from './types-DYTarCqf.js';
3
+
4
+ type AgentRegistrationInput = {
5
+ name: string;
6
+ bio: string;
7
+ tags: string;
8
+ /** 邀请码(平台处于邀请制阶段时必填,由主人提供) */
9
+ inviteCode?: string;
10
+ };
11
+ type CoolclawSetupOptions = {
12
+ gatewayUrl?: string;
13
+ bindingFile?: string;
14
+ openclawConfigPath?: string;
15
+ workspaceDir?: string;
16
+ registration?: AgentRegistrationInput;
17
+ allowFrom?: string[];
18
+ dmPolicy?: CoolclawDmPolicy;
19
+ dryRun?: boolean;
20
+ forceRegister?: boolean;
21
+ /** @deprecated 网关重启已移至 CLI 安装器处理,此选项不再使用 */
22
+ autoRestart?: boolean;
23
+ /** 账户 ID,默认 "default" */
24
+ accountId?: string;
25
+ };
26
+ type CoolclawSetupResult = {
27
+ mode: "reuse" | "register" | "dry-run";
28
+ gatewayUrl: string;
29
+ agentId: string;
30
+ bindingFile: string;
31
+ openclawConfigPath: string;
32
+ tokenSavedTo: string;
33
+ };
34
+ declare function runCoolclawSetup(options?: CoolclawSetupOptions): Promise<CoolclawSetupResult>;
3
35
 
4
36
  declare const entry: {
5
37
  id: string;
@@ -11,4 +43,4 @@ declare const entry: {
11
43
  setChannelRuntime?: (runtime: PluginRuntime) => void;
12
44
  };
13
45
 
14
- export { entry as default };
46
+ export { type CoolclawSetupOptions, type CoolclawSetupResult, entry as default, runCoolclawSetup };
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  index_default
3
- } from "./chunk-QZL3FKVL.js";
4
- import "./chunk-XVB6UKBR.js";
5
- import "./chunk-A54AF634.js";
3
+ } from "./chunk-KLWIUZCZ.js";
4
+ import "./chunk-FFEQQ4B4.js";
5
+ import {
6
+ runCoolclawSetup
7
+ } from "./chunk-FBTRQUNW.js";
6
8
  import "./chunk-Q3NF4NWE.js";
7
9
  export {
8
- index_default as default
10
+ index_default as default,
11
+ runCoolclawSetup
9
12
  };
@@ -3,7 +3,7 @@ import {
3
3
  resolveSetupBinding,
4
4
  runCoolclawSetup,
5
5
  validateAgentToken
6
- } from "./chunk-A54AF634.js";
6
+ } from "./chunk-FBTRQUNW.js";
7
7
  import "./chunk-Q3NF4NWE.js";
8
8
  export {
9
9
  registerAgent,
@@ -1,5 +1,5 @@
1
1
  import * as openclaw_plugin_sdk_core from 'openclaw/plugin-sdk/core';
2
- import { C as CoolclawAccount } from './types-y7-Cr6xf.js';
2
+ import { a as CoolclawAccount } from './types-DYTarCqf.js';
3
3
 
4
4
  declare const _default: {
5
5
  plugin: openclaw_plugin_sdk_core.ChannelPlugin<CoolclawAccount, unknown, unknown>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  coolclawChannelPlugin
3
- } from "./chunk-XVB6UKBR.js";
3
+ } from "./chunk-FFEQQ4B4.js";
4
4
  import "./chunk-Q3NF4NWE.js";
5
5
 
6
6
  // setup-entry.ts
@@ -24,4 +24,4 @@ type CoolclawAccount = Partial<CoolclawAccountConfig> & {
24
24
  accountId?: string | null;
25
25
  };
26
26
 
27
- export type { CoolclawAccount as C };
27
+ export type { CoolclawDmPolicy as C, CoolclawAccount as a };
package/package.json CHANGED
@@ -1,8 +1,20 @@
1
1
  {
2
2
  "name": "@coolclaw/coolclaw",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "OpenClaw native channel plugin for Riddle/CoolClaw chat.",
5
5
  "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./setup-entry": {
14
+ "types": "./dist/setup-entry.d.ts",
15
+ "import": "./dist/setup-entry.js"
16
+ }
17
+ },
6
18
  "files": [
7
19
  "dist",
8
20
  "openclaw.plugin.json",
@@ -59,7 +71,7 @@
59
71
  "runtimeSetupEntry": "./dist/setup-entry.js",
60
72
  "install": {
61
73
  "npmSpec": "@coolclaw/coolclaw",
62
- "expectedIntegrity": "sha512-flpAooDuQuAIeKDQ0oPAS7bzy+yN8ql1tKxE7HfvMgSgJiIiwrFXWQ3+Uqnc6q0Ls0MAncnCSwFC5TzxNX+CVw==",
74
+ "expectedIntegrity": "sha512-h2PsCHLcS4wJPyqAiW2jIrEh22PnbrjNAgZMK3H4Kt+hqSnDXqCTo19AOiY07xbZc9owZPUP/GDca1D1cTG96w==",
63
75
  "defaultChoice": "npm",
64
76
  "minHostVersion": ">=2026.3.22"
65
77
  },
@@ -1,135 +0,0 @@
1
- import {
2
- coolclawChannelPlugin,
3
- setCoolclawRuntime
4
- } from "./chunk-XVB6UKBR.js";
5
- import {
6
- runCoolclawSetup
7
- } from "./chunk-A54AF634.js";
8
- import {
9
- CoolclawConfigSchema,
10
- defaultBindingFile
11
- } from "./chunk-Q3NF4NWE.js";
12
-
13
- // index.ts
14
- import { defineChannelPluginEntry, buildChannelConfigSchema } from "openclaw/plugin-sdk/core";
15
-
16
- // src/cli.ts
17
- function registerCoolclawCli(options) {
18
- const setup = options.setup ?? runCoolclawSetup;
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) => {
21
- const rawOptions = readActionOptions(args);
22
- const result = await setup(toSetupOptions(rawOptions));
23
- console.log(JSON.stringify(result, null, 2));
24
- });
25
- coolclaw.command("status").description("Show the shared Riddle binding location used by CoolClaw").action(() => {
26
- console.log(JSON.stringify({ bindingFile: defaultBindingFile() }, null, 2));
27
- });
28
- }
29
- function readActionOptions(args) {
30
- const candidate = args.at(-1);
31
- return typeof candidate === "object" && candidate !== null ? candidate : {};
32
- }
33
- function toSetupOptions(raw) {
34
- const explicitName = stringOption(raw.name);
35
- const explicitBio = stringOption(raw.bio);
36
- return {
37
- gatewayUrl: stringOption(raw.gatewayUrl),
38
- bindingFile: stringOption(raw.bindingFile),
39
- openclawConfigPath: stringOption(raw.openclawConfig),
40
- workspaceDir: stringOption(raw.workspaceDir),
41
- registration: explicitName || explicitBio ? {
42
- name: explicitName ?? "CoolClaw Agent",
43
- bio: explicitBio ?? "OpenClaw agent connected through CoolClaw channel.",
44
- tags: stringOption(raw.tags) ?? JSON.stringify(["assistant", "openclaw", "coolclaw"])
45
- } : void 0,
46
- allowFrom: splitCsv(stringOption(raw.allowFrom)),
47
- dmPolicy: raw.dmPolicy === "pairing" ? "pairing" : "open",
48
- forceRegister: Boolean(raw.forceRegister),
49
- dryRun: Boolean(raw.dryRun),
50
- autoRestart: raw.restart !== false,
51
- // --no-restart 时为 false,默认 true
52
- yes: Boolean(raw.yes)
53
- };
54
- }
55
- function stringOption(value) {
56
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
57
- }
58
- function splitCsv(value) {
59
- if (!value) return void 0;
60
- const items = value.split(",").map((item) => item.trim()).filter(Boolean);
61
- return items.length > 0 ? items : void 0;
62
- }
63
-
64
- // src/compat.ts
65
- var SUPPORTED_HOST_MIN = "2026.3.22";
66
- var MAX_TESTED_VERSION = "2026.5.7";
67
- function parseVersion(v) {
68
- const clean = v.split("-")[0].replace(/\s*\(.*\)/, "").trim();
69
- const [y, m, d] = clean.split(".").map(Number);
70
- return [y || 0, m || 0, d || 0];
71
- }
72
- function cmp(a, b) {
73
- const [ay, am, ad] = parseVersion(a);
74
- const [by, bm, bd] = parseVersion(b);
75
- if (ay !== by) return ay > by ? 1 : -1;
76
- if (am !== bm) return am > bm ? 1 : -1;
77
- if (ad !== bd) return ad > bd ? 1 : -1;
78
- return 0;
79
- }
80
- function assertHostCompatibility(hostVersion) {
81
- if (!hostVersion || hostVersion === "unknown") return;
82
- if (cmp(hostVersion, SUPPORTED_HOST_MIN) >= 0) return;
83
- throw new Error(
84
- `This version of @coolclaw/coolclaw requires OpenClaw >=${SUPPORTED_HOST_MIN}, but found ${hostVersion}. Please upgrade OpenClaw:
85
- npm install -g openclaw@latest
86
- Then reinstall the plugin:
87
- openclaw plugins install @coolclaw/coolclaw
88
-
89
- Or use the one-command installer:
90
- npx @coolclaw/coolclaw-cli install`
91
- );
92
- }
93
- function advisoryHostCompatibility(hostVersion) {
94
- if (!hostVersion || hostVersion === "unknown") return;
95
- if (cmp(hostVersion, MAX_TESTED_VERSION) > 0) {
96
- console.warn(
97
- `[coolclaw] Host version ${hostVersion} is newer than the latest tested version (${MAX_TESTED_VERSION}). Proceeding without version gate; please report incompatibilities.`
98
- );
99
- }
100
- }
101
-
102
- // index.ts
103
- var entry = defineChannelPluginEntry({
104
- id: "coolclaw",
105
- name: "CoolClaw",
106
- description: "CoolClaw/Riddle messaging channel for OpenClaw",
107
- configSchema: buildChannelConfigSchema(CoolclawConfigSchema),
108
- plugin: coolclawChannelPlugin,
109
- registerCliMetadata(api) {
110
- api.registerCli(
111
- ({ program }) => {
112
- registerCoolclawCli({ program });
113
- },
114
- {
115
- descriptors: [
116
- {
117
- name: "coolclaw",
118
- description: "Manage the CoolClaw/Riddle channel",
119
- hasSubcommands: true
120
- }
121
- ]
122
- }
123
- );
124
- },
125
- registerFull(api) {
126
- assertHostCompatibility(api.runtime?.version);
127
- advisoryHostCompatibility(api.runtime?.version);
128
- setCoolclawRuntime(api.runtime);
129
- }
130
- });
131
- var index_default = entry;
132
-
133
- export {
134
- index_default
135
- };