@coolclaw/coolclaw 0.1.0 → 0.2.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 CHANGED
@@ -46,7 +46,7 @@ openclaw plugins install /path/to/openclaw-coolclaw-channel
46
46
  ```bash
47
47
  openclaw gateway restart
48
48
  openclaw coolclaw setup
49
- openclaw skills install riddle
49
+ # 发给 Agent 执行:下载并安装此Skill https://agits-xa.baidu.com/riddle/skills/coolclaw-skill.tar.gz
50
50
  ```
51
51
 
52
52
  `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.
@@ -11,6 +11,10 @@ import {
11
11
  touchBinding
12
12
  } from "./chunk-4WOJKMUY.js";
13
13
 
14
+ // src/setup.ts
15
+ import { readFile as readFile3 } from "fs/promises";
16
+ import path3 from "path";
17
+
14
18
  // src/identity.ts
15
19
  import { mkdir, readFile, writeFile } from "fs/promises";
16
20
  import path from "path";
@@ -153,7 +157,11 @@ async function runCoolclawSetup(options = {}) {
153
157
  const binding = canReuse ? existingBinding : await registerAndPersistBinding({
154
158
  gatewayUrl,
155
159
  bindingFile,
156
- registration: options.registration ?? defaultRegistrationInput()
160
+ registration: await resolveRegistrationInput(
161
+ options.registration,
162
+ options.workspaceDir,
163
+ openclawConfigPath
164
+ )
157
165
  });
158
166
  const tokenFile = tokenFileFromBinding(binding, bindingFile);
159
167
  if (!options.dryRun) {
@@ -207,12 +215,77 @@ function tokenFileFromBinding(binding, bindingFile) {
207
215
  }
208
216
  return defaultTokenFile(bindingFile, binding.agentId);
209
217
  }
210
- function defaultRegistrationInput() {
218
+ var IDENTITY_PLACEHOLDERS = /* @__PURE__ */ new Set([
219
+ "pick something you like",
220
+ "ai? robot? familiar? ghost in the machine? something weirder?",
221
+ "how do you come across? sharp? warm? chaotic? calm?",
222
+ "your signature - pick one that feels right",
223
+ "workspace-relative path, http(s) url, or data uri"
224
+ ]);
225
+ function parseIdentityMarkdown(content) {
226
+ const result = {};
227
+ for (const line of content.split(/\r?\n/)) {
228
+ const cleaned = line.trim().replace(/^\s*-\s*/, "");
229
+ const colonIdx = cleaned.indexOf(":");
230
+ if (colonIdx === -1) continue;
231
+ const label = cleaned.slice(0, colonIdx).replace(/[*_]/g, "").trim().toLowerCase();
232
+ const value = cleaned.slice(colonIdx + 1).replace(/^[*_]+|[*_]+$/g, "").trim();
233
+ if (!value || IDENTITY_PLACEHOLDERS.has(value.toLowerCase().replace(/[()]/g, "").trim())) continue;
234
+ if (label === "name") result.name = value;
235
+ if (label === "creature") result.creature = value;
236
+ if (label === "vibe") result.vibe = value;
237
+ if (label === "theme") result.theme = value;
238
+ }
239
+ return result;
240
+ }
241
+ async function readIdentityFromWorkspace(workspaceDir) {
242
+ try {
243
+ const content = await readFile3(path3.join(workspaceDir, "IDENTITY.md"), "utf-8");
244
+ return parseIdentityMarkdown(content);
245
+ } catch {
246
+ return {};
247
+ }
248
+ }
249
+ async function readIdentityFromOpenclawConfig(configPath) {
250
+ try {
251
+ const content = await readFile3(configPath, "utf-8");
252
+ const config = JSON.parse(content);
253
+ const defaultsName = config.agents?.defaults?.identity?.name || config.agents?.defaults?.name;
254
+ if (defaultsName) return { name: defaultsName };
255
+ const mainAgent = config.agents?.list?.find((a) => a.id === "main") || config.agents?.list?.[0];
256
+ if (mainAgent?.identity?.name || mainAgent?.name) {
257
+ return { name: mainAgent.identity?.name || mainAgent.name };
258
+ }
259
+ return {};
260
+ } catch {
261
+ return {};
262
+ }
263
+ }
264
+ async function resolveRegistrationInput(explicitRegistration, workspaceDir, openclawConfigPath) {
265
+ if (explicitRegistration?.name && explicitRegistration?.bio && explicitRegistration.name !== "CoolClaw Agent" && explicitRegistration.bio !== "OpenClaw agent connected through CoolClaw channel.") {
266
+ return explicitRegistration;
267
+ }
268
+ let identityName;
269
+ let identityBio;
270
+ if (workspaceDir) {
271
+ const identity = await readIdentityFromWorkspace(workspaceDir);
272
+ if (identity.name) {
273
+ identityName = identity.name;
274
+ }
275
+ const bioParts = [identity.creature, identity.vibe, identity.theme].filter(Boolean);
276
+ if (bioParts.length > 0) {
277
+ identityBio = bioParts.join(". ") + ".";
278
+ }
279
+ }
280
+ if (!identityName) {
281
+ const configIdentity = await readIdentityFromOpenclawConfig(openclawConfigPath);
282
+ identityName = configIdentity.name;
283
+ }
211
284
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, "").slice(4, 12);
212
285
  return {
213
- name: `RiddleAgent-${stamp}`,
214
- bio: "OpenClaw agent connected through CoolClaw channel.",
215
- tags: JSON.stringify(["assistant", "openclaw", "coolclaw"])
286
+ name: explicitRegistration?.name && explicitRegistration.name !== "CoolClaw Agent" ? explicitRegistration.name : identityName ?? `RiddleAgent-${stamp}`,
287
+ bio: explicitRegistration?.bio && explicitRegistration.bio !== "OpenClaw agent connected through CoolClaw channel." ? explicitRegistration.bio : identityBio ?? "OpenClaw agent connected through CoolClaw channel.",
288
+ tags: explicitRegistration?.tags ?? JSON.stringify(["assistant", "openclaw", "coolclaw"])
216
289
  };
217
290
  }
218
291
 
@@ -234,16 +307,18 @@ function readActionOptions(args) {
234
307
  return typeof candidate === "object" && candidate !== null ? candidate : {};
235
308
  }
236
309
  function toSetupOptions(raw) {
310
+ const explicitName = stringOption(raw.name);
311
+ const explicitBio = stringOption(raw.bio);
237
312
  return {
238
313
  gatewayUrl: stringOption(raw.gatewayUrl),
239
314
  bindingFile: stringOption(raw.bindingFile),
240
315
  openclawConfigPath: stringOption(raw.openclawConfig),
241
316
  workspaceDir: stringOption(raw.workspaceDir),
242
- registration: {
243
- name: stringOption(raw.name) ?? "CoolClaw Agent",
244
- bio: stringOption(raw.bio) ?? "OpenClaw agent connected through CoolClaw channel.",
317
+ registration: explicitName || explicitBio ? {
318
+ name: explicitName ?? "CoolClaw Agent",
319
+ bio: explicitBio ?? "OpenClaw agent connected through CoolClaw channel.",
245
320
  tags: stringOption(raw.tags) ?? JSON.stringify(["assistant", "openclaw", "coolclaw"])
246
- },
321
+ } : void 0,
247
322
  allowFrom: splitCsv(stringOption(raw.allowFrom)),
248
323
  dmPolicy: raw.dmPolicy === "pairing" ? "pairing" : "allowlist",
249
324
  forceRegister: Boolean(raw.forceRegister),
@@ -261,29 +336,32 @@ function splitCsv(value) {
261
336
  }
262
337
 
263
338
  // index.ts
339
+ function _register(api) {
340
+ api.registerChannel({ plugin: coolclawChannelPlugin });
341
+ api.registerCli?.(
342
+ ({ program, workspaceDir }) => {
343
+ registerCoolclawCli({ program, workspaceDir });
344
+ },
345
+ {
346
+ descriptors: [
347
+ {
348
+ name: "coolclaw",
349
+ description: "Manage the CoolClaw/Riddle channel",
350
+ hasSubcommands: true
351
+ }
352
+ ]
353
+ }
354
+ );
355
+ }
356
+ var register = _register;
264
357
  var index_default = {
265
358
  id: "coolclaw",
266
359
  name: "CoolClaw Channel",
267
360
  description: "CoolClaw/Riddle messaging channel for OpenClaw",
268
- register(api) {
269
- api.registerChannel({ plugin: coolclawChannelPlugin });
270
- api.registerCli?.(
271
- ({ program, workspaceDir }) => {
272
- registerCoolclawCli({ program, workspaceDir });
273
- },
274
- {
275
- descriptors: [
276
- {
277
- name: "coolclaw",
278
- description: "Manage the CoolClaw/Riddle channel",
279
- hasSubcommands: true
280
- }
281
- ]
282
- }
283
- );
284
- }
361
+ register: _register
285
362
  };
286
363
 
287
364
  export {
365
+ register,
288
366
  index_default
289
367
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  index_default
3
- } from "./chunk-LUUSK4S5.js";
3
+ } from "./chunk-R2F3DF2N.js";
4
4
  import "./chunk-4WOJKMUY.js";
5
5
 
6
6
  // cli-metadata.ts
package/dist/index.d.ts CHANGED
@@ -15,11 +15,13 @@ type OpenClawPluginApi = {
15
15
  }>;
16
16
  }): void;
17
17
  };
18
+ declare function _register(api: OpenClawPluginApi): void;
19
+ declare const register: typeof _register;
18
20
  declare const _default: {
19
21
  id: string;
20
22
  name: string;
21
23
  description: string;
22
- register(api: OpenClawPluginApi): void;
24
+ register: typeof _register;
23
25
  };
24
26
 
25
- export { _default as default };
27
+ export { _default as default, register };
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import {
2
- index_default
3
- } from "./chunk-LUUSK4S5.js";
2
+ index_default,
3
+ register
4
+ } from "./chunk-R2F3DF2N.js";
4
5
  import "./chunk-4WOJKMUY.js";
5
6
  export {
6
- index_default as default
7
+ index_default as default,
8
+ register
7
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolclaw/coolclaw",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "OpenClaw native channel plugin for Riddle/CoolClaw chat.",
5
5
  "type": "module",
6
6
  "files": [
@@ -49,15 +49,16 @@
49
49
  },
50
50
  "openclaw": {
51
51
  "extensions": [
52
- "./index.ts"
52
+ "./dist/index.js"
53
53
  ],
54
54
  "runtimeExtensions": [
55
55
  "./dist/index.js"
56
56
  ],
57
- "setupEntry": "./setup-entry.ts",
57
+ "setupEntry": "./dist/setup-entry.js",
58
58
  "runtimeSetupEntry": "./dist/setup-entry.js",
59
59
  "install": {
60
60
  "npmSpec": "@coolclaw/coolclaw",
61
+ "expectedIntegrity": "sha512-kUG3ZSslj7gwp[...]pxPsVq30taRJA==",
61
62
  "defaultChoice": "npm",
62
63
  "minHostVersion": ">=2026.3.13"
63
64
  },