@coolclaw/coolclaw 0.5.0 → 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.
@@ -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,
@@ -1530,7 +1530,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
1530
1530
  async login({ cfg, accountId, verbose }) {
1531
1531
  const resolvedAccountId = accountId?.trim() || "default";
1532
1532
  const account = coolclawChannelPlugin.config.resolveAccount(cfg, resolvedAccountId);
1533
- const { validateAgentToken, runCoolclawSetup } = await import("./setup-HS3PWYJK.js");
1533
+ const { validateAgentToken, runCoolclawSetup } = await import("./setup-OG74IIBU.js");
1534
1534
  const existingToken = account.tokenSecretRef ? await resolveAccountToken(account) : void 0;
1535
1535
  if (existingToken) {
1536
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-I6SQ5S34.js";
4
- import "./chunk-P2I7XHZL.js";
5
- import "./chunk-DHGATALZ.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-I6SQ5S34.js";
4
- import "./chunk-P2I7XHZL.js";
5
- import "./chunk-DHGATALZ.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-DHGATALZ.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-P2I7XHZL.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.5.0",
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-HI/uadGwTrDPoM8FJ47+0F5bix6X49i7TUPQ/3x+e12BzyyCgE5gHrQsv2qic5VjHmbPoQ/IAfnejecmxl7Lsw==",
74
+ "expectedIntegrity": "sha512-h2PsCHLcS4wJPyqAiW2jIrEh22PnbrjNAgZMK3H4Kt+hqSnDXqCTo19AOiY07xbZc9owZPUP/GDca1D1cTG96w==",
63
75
  "defaultChoice": "npm",
64
76
  "minHostVersion": ">=2026.3.22"
65
77
  },
@@ -1,137 +0,0 @@
1
- import {
2
- coolclawChannelPlugin,
3
- setCoolclawRuntime
4
- } from "./chunk-P2I7XHZL.js";
5
- import {
6
- runCoolclawSetup
7
- } from "./chunk-DHGATALZ.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("--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
- 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
- const explicitInviteCode = stringOption(raw.inviteCode) ?? stringOption(process.env.RIDDLE_INVITE_CODE);
37
- return {
38
- gatewayUrl: stringOption(raw.gatewayUrl),
39
- bindingFile: stringOption(raw.bindingFile),
40
- openclawConfigPath: stringOption(raw.openclawConfig),
41
- workspaceDir: stringOption(raw.workspaceDir),
42
- registration: explicitName || explicitBio || explicitInviteCode ? {
43
- name: explicitName ?? "CoolClaw Agent",
44
- bio: explicitBio ?? "OpenClaw agent connected through CoolClaw channel.",
45
- tags: stringOption(raw.tags) ?? JSON.stringify(["assistant", "openclaw", "coolclaw"]),
46
- inviteCode: explicitInviteCode
47
- } : void 0,
48
- allowFrom: splitCsv(stringOption(raw.allowFrom)),
49
- dmPolicy: raw.dmPolicy === "pairing" ? "pairing" : "open",
50
- forceRegister: Boolean(raw.forceRegister),
51
- dryRun: Boolean(raw.dryRun),
52
- autoRestart: raw.restart !== false,
53
- // --no-restart 时为 false,默认 true
54
- yes: Boolean(raw.yes)
55
- };
56
- }
57
- function stringOption(value) {
58
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
59
- }
60
- function splitCsv(value) {
61
- if (!value) return void 0;
62
- const items = value.split(",").map((item) => item.trim()).filter(Boolean);
63
- return items.length > 0 ? items : void 0;
64
- }
65
-
66
- // src/compat.ts
67
- var SUPPORTED_HOST_MIN = "2026.3.22";
68
- var MAX_TESTED_VERSION = "2026.5.7";
69
- function parseVersion(v) {
70
- const clean = v.split("-")[0].replace(/\s*\(.*\)/, "").trim();
71
- const [y, m, d] = clean.split(".").map(Number);
72
- return [y || 0, m || 0, d || 0];
73
- }
74
- function cmp(a, b) {
75
- const [ay, am, ad] = parseVersion(a);
76
- const [by, bm, bd] = parseVersion(b);
77
- if (ay !== by) return ay > by ? 1 : -1;
78
- if (am !== bm) return am > bm ? 1 : -1;
79
- if (ad !== bd) return ad > bd ? 1 : -1;
80
- return 0;
81
- }
82
- function assertHostCompatibility(hostVersion) {
83
- if (!hostVersion || hostVersion === "unknown") return;
84
- if (cmp(hostVersion, SUPPORTED_HOST_MIN) >= 0) return;
85
- throw new Error(
86
- `This version of @coolclaw/coolclaw requires OpenClaw >=${SUPPORTED_HOST_MIN}, but found ${hostVersion}. Please upgrade OpenClaw:
87
- npm install -g openclaw@latest
88
- Then reinstall the plugin:
89
- openclaw plugins install @coolclaw/coolclaw
90
-
91
- Or use the one-command installer:
92
- npx -y @coolclaw/coolclaw-cli@latest install`
93
- );
94
- }
95
- function advisoryHostCompatibility(hostVersion) {
96
- if (!hostVersion || hostVersion === "unknown") return;
97
- if (cmp(hostVersion, MAX_TESTED_VERSION) > 0) {
98
- console.warn(
99
- `[coolclaw] Host version ${hostVersion} is newer than the latest tested version (${MAX_TESTED_VERSION}). Proceeding without version gate; please report incompatibilities.`
100
- );
101
- }
102
- }
103
-
104
- // index.ts
105
- var entry = defineChannelPluginEntry({
106
- id: "coolclaw",
107
- name: "CoolClaw",
108
- description: "CoolClaw/Riddle messaging channel for OpenClaw",
109
- configSchema: buildChannelConfigSchema(CoolclawConfigSchema),
110
- plugin: coolclawChannelPlugin,
111
- registerCliMetadata(api) {
112
- api.registerCli(
113
- ({ program }) => {
114
- registerCoolclawCli({ program });
115
- },
116
- {
117
- descriptors: [
118
- {
119
- name: "coolclaw",
120
- description: "Manage the CoolClaw/Riddle channel",
121
- hasSubcommands: true
122
- }
123
- ]
124
- }
125
- );
126
- },
127
- registerFull(api) {
128
- assertHostCompatibility(api.runtime?.version);
129
- advisoryHostCompatibility(api.runtime?.version);
130
- setCoolclawRuntime(api.runtime);
131
- }
132
- });
133
- var index_default = entry;
134
-
135
- export {
136
- index_default
137
- };