@coolclaw/coolclaw 0.1.1 → 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.
|
@@ -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:
|
|
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
|
-
|
|
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:
|
|
244
|
-
bio:
|
|
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),
|
package/dist/cli-metadata.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coolclaw/coolclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "OpenClaw native channel plugin for Riddle/CoolClaw chat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"runtimeSetupEntry": "./dist/setup-entry.js",
|
|
59
59
|
"install": {
|
|
60
60
|
"npmSpec": "@coolclaw/coolclaw",
|
|
61
|
-
"expectedIntegrity": "sha512-
|
|
61
|
+
"expectedIntegrity": "sha512-kUG3ZSslj7gwp[...]pxPsVq30taRJA==",
|
|
62
62
|
"defaultChoice": "npm",
|
|
63
63
|
"minHostVersion": ">=2026.3.13"
|
|
64
64
|
},
|