@clawos-dev/clawd 0.2.186 → 0.2.187-beta.373.fba4299

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/dist/cli.cjs CHANGED
@@ -157,7 +157,8 @@ var init_methods = __esm({
157
157
  // 写入路径:device:connect 落 store + 自动反向(决策 #11);list / remove 作联系人列表读删。
158
158
  "contact:list",
159
159
  "contact:remove",
160
- // ---- visitor:* (web 访客 · persona web 分享,spec 2026-06-24-persona-web-share-design) ----
160
+ "contact:set-note",
161
+ // ---- visitor:*(web 访客 · persona web 分享,spec 2026-06-24-persona-web-share-design) ----
161
162
  // owner-only:列出登录访问过本机 public persona 的 web 访客(零安装、飞书登录、daemon 自签
162
163
  // visitor token)。存储 ~/.clawd/visitors.json(VisitorStore),登录(exchange)即 upsert;
163
164
  // 访客身份用 TTC unique_id,会话按 creatorPrincipalId='visitor-<id>' 进现有会话用户分组。
@@ -5630,7 +5631,7 @@ var init_inbox = __esm({
5630
5631
  });
5631
5632
 
5632
5633
  // ../protocol/src/contact.ts
5633
- var ContactSchema, ContactWireSchema, ContactRemoveArgsSchema, ContactRemoveOkSchema, ContactListOkSchema, ContactAddedFrameSchema, ContactRemovedFrameSchema;
5634
+ var ContactSchema, ContactWireSchema, ContactRemoveArgsSchema, ContactRemoveOkSchema, ContactListOkSchema, ContactAddedFrameSchema, ContactRemovedFrameSchema, ContactSetNoteArgsSchema, ContactSetNoteOkSchema;
5634
5635
  var init_contact = __esm({
5635
5636
  "../protocol/src/contact.ts"() {
5636
5637
  "use strict";
@@ -5659,7 +5660,12 @@ var init_contact = __esm({
5659
5660
  // 不用 .min(1):自动反向路径合法地存空串,禁止填假 token 占位(不造假数据)。
5660
5661
  connectToken: external_exports.string(),
5661
5662
  grants: external_exports.array(GrantSchema),
5662
- addedAt: external_exports.number().int().nonnegative()
5663
+ addedAt: external_exports.number().int().nonnegative(),
5664
+ /**
5665
+ * 本机私有备注(≤20 字):owner 给该联系人加的标注,只存本机、不分享给对方。
5666
+ * optional——老 contacts.json 记录无此字段,禁止必填(否则 strict parse 失败 orphan 全部联系人)。
5667
+ */
5668
+ note: external_exports.string().max(20).optional()
5663
5669
  }).strict();
5664
5670
  ContactWireSchema = ContactSchema;
5665
5671
  ContactRemoveArgsSchema = external_exports.object({
@@ -5681,6 +5687,15 @@ var init_contact = __esm({
5681
5687
  type: external_exports.literal("contact:removed"),
5682
5688
  deviceId: external_exports.string().min(1)
5683
5689
  }).strict();
5690
+ ContactSetNoteArgsSchema = external_exports.object({
5691
+ deviceId: external_exports.string().min(1),
5692
+ note: external_exports.string().max(20)
5693
+ }).strict();
5694
+ ContactSetNoteOkSchema = external_exports.object({
5695
+ type: external_exports.literal("contact:set-note:ok"),
5696
+ deviceId: external_exports.string().min(1),
5697
+ note: external_exports.string().max(20)
5698
+ }).strict();
5684
5699
  }
5685
5700
  });
5686
5701
 
@@ -50174,6 +50189,21 @@ var ContactStore = class {
50174
50189
  this.contacts.set(contact.deviceId, contact);
50175
50190
  this.flush();
50176
50191
  }
50192
+ /**
50193
+ * 设/改/清空单台设备的本机私有备注(决策:本机私有标注,只存本机不分享)。
50194
+ * 命中返回更新后的 contact 并 flush;note 空串则删除 note 字段(保持 contacts.json 干净);
50195
+ * 未命中返回 null(不写盘)。
50196
+ */
50197
+ setNote(deviceId, note) {
50198
+ const existing = this.contacts.get(deviceId);
50199
+ if (!existing) return null;
50200
+ const next = { ...existing };
50201
+ if (note) next.note = note;
50202
+ else delete next.note;
50203
+ this.contacts.set(deviceId, next);
50204
+ this.flush();
50205
+ return next;
50206
+ }
50177
50207
  /** 删单台设备(contact:remove 语义,决策 #16):删该 deviceId 一条,返回是否删到 */
50178
50208
  removeByDeviceId(deviceId) {
50179
50209
  const existed = this.contacts.delete(deviceId);
@@ -53760,9 +53790,30 @@ function buildContactHandlers(deps) {
53760
53790
  }
53761
53791
  };
53762
53792
  };
53793
+ const setNote = async (frame, _client, ctx) => {
53794
+ ensureOwner(ctx);
53795
+ const { type: _t, requestId: _r, ...rest } = frame;
53796
+ const args = ContactSetNoteArgsSchema.parse(rest);
53797
+ const updated = deps.store.setNote(args.deviceId, args.note);
53798
+ if (!updated) {
53799
+ throw new ClawdError(
53800
+ ERROR_CODES.INVALID_PARAM,
53801
+ `INVALID_PARAM: contact ${args.deviceId} \u4E0D\u5B58\u5728`
53802
+ );
53803
+ }
53804
+ deps.broadcast({ type: "contact:added", contact: updated });
53805
+ return {
53806
+ response: {
53807
+ type: "contact:set-note:ok",
53808
+ deviceId: args.deviceId,
53809
+ note: args.note
53810
+ }
53811
+ };
53812
+ };
53763
53813
  return {
53764
53814
  "contact:list": list,
53765
- "contact:remove": remove
53815
+ "contact:remove": remove,
53816
+ "contact:set-note": setNote
53766
53817
  };
53767
53818
  }
53768
53819
 
@@ -56553,6 +56604,7 @@ var METHOD_GRANT_MAP = {
56553
56604
  // 写入路径在 device:connect / 自动反向;list / remove 作联系人读 / 删,owner-only。
56554
56605
  "contact:list": ADMIN_ANY,
56555
56606
  "contact:remove": ADMIN_ANY,
56607
+ "contact:set-note": ADMIN_ANY,
56556
56608
  // ---- visitor:* (访客名单,owner-only) ----
56557
56609
  // owner 看完整访客名单(含没开会话的);guest 不可调(handler 内再 assertOwner 兜底)。
56558
56610
  "visitor:list": ADMIN_ANY,