@clawos-dev/clawd 0.2.54-beta.87.f1cd100 → 0.2.55-beta.88.65f49df

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 +114 -2
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -8595,7 +8595,7 @@ var init_zod = __esm({
8595
8595
  });
8596
8596
 
8597
8597
  // ../protocol/src/persona-schemas.ts
8598
- var PersonaTokenEntrySchema, PersonaFileSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema, PersonaIssueTokenArgsSchema, PersonaRevokeTokenArgsSchema, PersonaAppendOwnerMessageArgsSchema;
8598
+ var PersonaTokenEntrySchema, PersonaFileSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema, PersonaIssueTokenArgsSchema, PersonaRevokeTokenArgsSchema, PersonaAppendOwnerMessageArgsSchema, ChatSummarySchema, ChatListRequestSchema, ChatListResponseSchema, ChatRenameRequestSchema, ChatRenameResponseSchema;
8599
8599
  var init_persona_schemas = __esm({
8600
8600
  "../protocol/src/persona-schemas.ts"() {
8601
8601
  "use strict";
@@ -8654,6 +8654,37 @@ var init_persona_schemas = __esm({
8654
8654
  subSessionId: external_exports.string().min(1),
8655
8655
  text: external_exports.string().min(1)
8656
8656
  });
8657
+ ChatSummarySchema = external_exports.object({
8658
+ sessionId: external_exports.string().min(1),
8659
+ /** 派生 sessionId 时使用的原始 chatId('default' 为 root chat 保留值) */
8660
+ chatId: external_exports.string().min(1),
8661
+ /** sub-session label,listener 视为 chat 名 */
8662
+ label: external_exports.string(),
8663
+ /** SessionFile.createdAt(ISO string) */
8664
+ createdAt: external_exports.string(),
8665
+ /** 是否为 default chat(sessionId 等于 ${personaId}-${tokenHash12} 时为 true) */
8666
+ isDefault: external_exports.boolean()
8667
+ });
8668
+ ChatListRequestSchema = external_exports.object({
8669
+ type: external_exports.literal("chat:list"),
8670
+ requestId: external_exports.string().min(1).optional()
8671
+ });
8672
+ ChatListResponseSchema = external_exports.object({
8673
+ type: external_exports.literal("chat:list"),
8674
+ requestId: external_exports.string().min(1).optional(),
8675
+ chats: external_exports.array(ChatSummarySchema)
8676
+ });
8677
+ ChatRenameRequestSchema = external_exports.object({
8678
+ type: external_exports.literal("chat:rename"),
8679
+ requestId: external_exports.string().min(1).optional(),
8680
+ sessionId: external_exports.string().min(1),
8681
+ label: external_exports.string().min(1)
8682
+ });
8683
+ ChatRenameResponseSchema = external_exports.object({
8684
+ type: external_exports.literal("chat:rename"),
8685
+ requestId: external_exports.string().min(1).optional(),
8686
+ ok: external_exports.literal(true)
8687
+ });
8657
8688
  }
8658
8689
  });
8659
8690
 
@@ -8757,6 +8788,10 @@ var init_schemas = __esm({
8757
8788
  // owner-mode persona session 身份标识;UI 用它在 SessionList 过滤 + jump,
8758
8789
  // daemon 用它做 idempotent dedupe + spawn 时派生 ctx.personaMode='owner'
8759
8790
  ownerPersonaId: external_exports.string().min(1).optional(),
8791
+ // listener-mode sub-session 的原始 chatId(owner-mode 不设;旧数据缺省)
8792
+ // alice 端 chat:list 拿到 chatId 后用它发 auth 帧重连同一 sub-session;
8793
+ // daemon 派生 sessionId 是单向 hash,必须保留原始 chatId 才能让 alice 重建连接
8794
+ chatId: external_exports.string().min(1).optional(),
8760
8795
  createdAt: external_exports.string().min(1),
8761
8796
  updatedAt: external_exports.string().min(1)
8762
8797
  });
@@ -17439,6 +17474,7 @@ var SessionManager = class {
17439
17474
  label: args.label,
17440
17475
  model: args.model,
17441
17476
  permissionMode: args.permissionMode,
17477
+ ...args.chatId ? { chatId: args.chatId } : {},
17442
17478
  createdAt: iso,
17443
17479
  updatedAt: iso
17444
17480
  };
@@ -17549,6 +17585,21 @@ var SessionManager = class {
17549
17585
  });
17550
17586
  return { response: { ok: true }, broadcast };
17551
17587
  }
17588
+ /**
17589
+ * 改 SessionFile.label(用于 listener-bound chat:rename RPC)。
17590
+ * 不存在抛 SESSION_NOT_FOUND。
17591
+ */
17592
+ renameForScope(args) {
17593
+ const file = this.storeFor(args.scope).read(args.sessionId);
17594
+ if (!file) {
17595
+ throw new ClawdError(
17596
+ ERROR_CODES.SESSION_NOT_FOUND,
17597
+ `sub-session not found: ${scopeKey(args.scope)}/${args.sessionId}`
17598
+ );
17599
+ }
17600
+ const store = this.storeFor(args.scope);
17601
+ store.write({ ...file, label: args.label });
17602
+ }
17552
17603
  /** ensureSession 的 scope-aware 版本:复用现有 runner 或按 scope 创建(含 metaFromScope 派生 meta) */
17553
17604
  ensureRunnerForScope(file, scope) {
17554
17605
  const existing = this.runners.get(file.sessionId);
@@ -17925,7 +17976,8 @@ var PersonaManager = class {
17925
17976
  cwd: this.deps.store.personaDirPath(personaId),
17926
17977
  tool: "claude",
17927
17978
  label: subLabel,
17928
- model: persona.model
17979
+ model: persona.model,
17980
+ chatId: normalizedChatId
17929
17981
  });
17930
17982
  return { sessionFile, isNew: true };
17931
17983
  }
@@ -19274,6 +19326,66 @@ var PersonaBoundHandler = class {
19274
19326
  }
19275
19327
  return;
19276
19328
  }
19329
+ case "chat:list": {
19330
+ const tokenPart = scope.subSessionId.slice(
19331
+ scope.personaId.length + 1,
19332
+ scope.personaId.length + 1 + 12
19333
+ );
19334
+ const tokenPrefix = `${scope.personaId}-${tokenPart}`;
19335
+ try {
19336
+ const all = this.deps.sessionManager.listPersonaSessions(scope.personaId, "listener");
19337
+ const sameTuple = all.filter(
19338
+ (s) => s.sessionId === tokenPrefix || s.sessionId.startsWith(`${tokenPrefix}-`)
19339
+ );
19340
+ const chats = sameTuple.map((s) => ({
19341
+ sessionId: s.sessionId,
19342
+ chatId: s.chatId ?? (s.sessionId === tokenPrefix ? "default" : "unknown"),
19343
+ label: s.label ?? "",
19344
+ createdAt: s.createdAt,
19345
+ isDefault: s.sessionId === tokenPrefix
19346
+ }));
19347
+ if (requestId) send({ type: "chat:list", requestId, chats });
19348
+ else send({ type: "chat:list", chats });
19349
+ } catch (err) {
19350
+ const e = err;
19351
+ sendError(requestId, e.code ?? "INTERNAL", e.message ?? String(err));
19352
+ }
19353
+ return;
19354
+ }
19355
+ case "chat:rename": {
19356
+ const targetId = frame.sessionId;
19357
+ const newLabel = frame.label;
19358
+ if (typeof targetId !== "string" || targetId.length === 0) {
19359
+ sendError(requestId, "VALIDATION_ERROR", "sessionId must be non-empty string");
19360
+ return;
19361
+ }
19362
+ if (typeof newLabel !== "string" || newLabel.length === 0) {
19363
+ sendError(requestId, "VALIDATION_ERROR", "label must be non-empty string");
19364
+ return;
19365
+ }
19366
+ const tokenPart = scope.subSessionId.slice(
19367
+ scope.personaId.length + 1,
19368
+ scope.personaId.length + 1 + 12
19369
+ );
19370
+ const tokenPrefix = `${scope.personaId}-${tokenPart}`;
19371
+ const sameTuple = targetId === tokenPrefix || targetId.startsWith(`${tokenPrefix}-`);
19372
+ if (!sameTuple) {
19373
+ sendError(requestId, "FORBIDDEN", "sessionId out of (persona, token) scope");
19374
+ return;
19375
+ }
19376
+ try {
19377
+ this.deps.sessionManager.renameForScope({
19378
+ sessionId: targetId,
19379
+ scope: listenerScope(),
19380
+ label: newLabel
19381
+ });
19382
+ if (requestId) send({ type: "chat:rename", requestId, ok: true });
19383
+ } catch (err) {
19384
+ const e = err;
19385
+ sendError(requestId, e.code ?? "INTERNAL", e.message ?? String(err));
19386
+ }
19387
+ return;
19388
+ }
19277
19389
  default:
19278
19390
  sendError(
19279
19391
  requestId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.54-beta.87.f1cd100",
3
+ "version": "0.2.55-beta.88.65f49df",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",