@clawos-dev/clawd 0.2.34 → 0.2.35-beta.51.70d804e

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +15 -3
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -17546,6 +17546,9 @@ var PersonaStore = class {
17546
17546
  const raw = JSON.parse(fs6.readFileSync(p, "utf8"));
17547
17547
  return PersonaFileSchema.parse(raw);
17548
17548
  }
17549
+ has(personaId) {
17550
+ return fs6.existsSync(this.metaPath(personaId));
17551
+ }
17549
17552
  readPersonality(personaId) {
17550
17553
  const p = this.claudeMdPath(personaId);
17551
17554
  if (!fs6.existsSync(p)) return null;
@@ -17735,11 +17738,20 @@ var PersonaManager = class {
17735
17738
  });
17736
17739
  }
17737
17740
  // ---------------- 内部 ----------------
17738
- /** label 转 4-16 char slug + 4 char base64url 后缀,避免冲突且文件名安全 */
17741
+ /**
17742
+ * label 转 4-16 char slug。优先用 `persona-<slug>`;若 slug 已被占用,追加 4 char
17743
+ * base64url 随机后缀直到不撞为止(最多 5 次,理论冲突 ≈ 2^-24,留个 panic 上限)。
17744
+ */
17739
17745
  generatePersonaId(label) {
17740
17746
  const slug = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 16) || "persona";
17741
- const rand = import_node_crypto3.default.randomBytes(3).toString("base64url").slice(0, 4);
17742
- return `persona-${slug}-${rand}`;
17747
+ const base = `persona-${slug}`;
17748
+ if (!this.deps.store.has(base)) return base;
17749
+ for (let i = 0; i < 5; i++) {
17750
+ const rand = import_node_crypto3.default.randomBytes(3).toString("base64url").slice(0, 4);
17751
+ const candidate = `${base}-${rand}`;
17752
+ if (!this.deps.store.has(candidate)) return candidate;
17753
+ }
17754
+ throw new Error(`failed to generate unique personaId for label=${label}`);
17743
17755
  }
17744
17756
  /** subSessionId = persona-<short>-<tokenHash12>;同 token 始终复用同一 sub-session */
17745
17757
  deriveSubSessionId(personaId, token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.34",
3
+ "version": "0.2.35-beta.51.70d804e",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",