@clawos-dev/clawd 0.2.543 → 0.2.545

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.
@@ -24201,6 +24201,11 @@ var METHOD_DOCS = {
24201
24201
  summary: "\u586B\u5199\u578B\u8FDE\u63A5\u5668\uFF1A\u628A\u4F7F\u7528\u8005\u672C\u4EBA\u7684\u51ED\u636E\u503C\u4EA4\u7ED9\u4E2D\u5FC3\u52A0\u5BC6\u5165\u5E93\uFF08\u4E00\u6B21\u586B\u5199\u5168\u5C40\u5171\u7528\uFF09\u3002**\u8FD9\u662F\u503C\u552F\u4E00\u7684\u5165\u53E3**\uFF1A\u5165\u53C2\u4E0D\u8FDB\u65E5\u5FD7\u3001\u54CD\u5E94\u4E0D\u56DE\u663E\u3001\u672C\u673A\u4E0D\u843D\u76D8\uFF1B\u683C\u540D\u5FC5\u987B\u662F\u8BE5\u8FDE\u63A5\u5668\u58F0\u660E\u8FC7\u7684\uFF1Bowner-only",
24202
24202
  args: CloudConnectorFillArgsSchema
24203
24203
  },
24204
+ // ---- cloud:volume:get(云上会话聊天页顶栏的云盘角标;design 2026-09-19-cloud-volume-usage §3.3)----
24205
+ "cloud:volume:get": {
24206
+ summary: "\u8C03\u7528\u65B9\u81EA\u5DF1\u90A3\u5757\u4E91\u76D8\u4E0A\u4E00\u8F6E\u672B\u7684\u7528\u91CF\uFF08usedBytes / sizeBytes / measuredAt\uFF09\u3002\u6309\u4EBA\u4E0D\u6309 persona\uFF1A\u4E91\u4E0A\u6240\u6709 persona \u5171\u7528\u4E00\u5757\u76D8\u3002daemon \u62FF\u672C\u673A api key \u95EE gateway /me/volume\uFF1B\u6CA1\u767B\u5F55 / \u6CA1 key / gateway \u4E0D\u901A / \u6CA1\u8DD1\u8FC7\u4EFB\u52A1\u4E00\u5F8B\u56DE volume:null\uFF08\u89D2\u6807\u4E0D\u6E32\uFF09\uFF0C\u4E0D\u629B\uFF1Bowner-only\u3002\u65E0\u53C2\u6570\uFF08\u67E5\u7684\u662F\u8C03\u7528\u65B9\u81EA\u5DF1\u7684\u76D8\uFF09",
24207
+ args: NO_ARGS
24208
+ },
24204
24209
  "shift:list": {
24205
24210
  summary: "\u5217\u51FA owner \u7684\u5168\u90E8 shift\uFF08\u6392\u73ED\uFF09\uFF0C\u7ED9 UI \u65E5\u5386\u6E32\u67D3\u7528\uFF1Bowner-only",
24206
24211
  args: NO_ARGS
@@ -24645,6 +24650,19 @@ var MetaMethodsResultSchema = external_exports.object({
24645
24650
  methods: external_exports.array(RpcMethodInfoSchema)
24646
24651
  });
24647
24652
 
24653
+ // ../protocol/src/cloud-volume-schemas.ts
24654
+ var CloudVolumeUsageSchema = external_exports.object({
24655
+ /** 已用字节(df 的 Used 列) */
24656
+ usedBytes: external_exports.number().int().nonnegative(),
24657
+ /** 盘的总字节(df 的 1B-blocks 列;ext4 预留之后比 PVC 的 5Gi 略小) */
24658
+ sizeBytes: external_exports.number().int().positive(),
24659
+ /** 量的时刻(ms)= 上一轮结束时 */
24660
+ measuredAt: external_exports.number().int().nonnegative()
24661
+ }).strict();
24662
+ var CloudVolumeGetResultSchema = external_exports.object({
24663
+ volume: CloudVolumeUsageSchema.nullable()
24664
+ }).strict();
24665
+
24648
24666
  // ../protocol/src/log.ts
24649
24667
  var LOG_SOURCES = ["daemon", "main", "renderer"];
24650
24668
  var LogSourceSchema = external_exports.enum(LOG_SOURCES);
package/dist/cli.cjs CHANGED
@@ -9028,6 +9028,11 @@ var init_methods = __esm({
9028
9028
  summary: "\u586B\u5199\u578B\u8FDE\u63A5\u5668\uFF1A\u628A\u4F7F\u7528\u8005\u672C\u4EBA\u7684\u51ED\u636E\u503C\u4EA4\u7ED9\u4E2D\u5FC3\u52A0\u5BC6\u5165\u5E93\uFF08\u4E00\u6B21\u586B\u5199\u5168\u5C40\u5171\u7528\uFF09\u3002**\u8FD9\u662F\u503C\u552F\u4E00\u7684\u5165\u53E3**\uFF1A\u5165\u53C2\u4E0D\u8FDB\u65E5\u5FD7\u3001\u54CD\u5E94\u4E0D\u56DE\u663E\u3001\u672C\u673A\u4E0D\u843D\u76D8\uFF1B\u683C\u540D\u5FC5\u987B\u662F\u8BE5\u8FDE\u63A5\u5668\u58F0\u660E\u8FC7\u7684\uFF1Bowner-only",
9029
9029
  args: CloudConnectorFillArgsSchema
9030
9030
  },
9031
+ // ---- cloud:volume:get(云上会话聊天页顶栏的云盘角标;design 2026-09-19-cloud-volume-usage §3.3)----
9032
+ "cloud:volume:get": {
9033
+ summary: "\u8C03\u7528\u65B9\u81EA\u5DF1\u90A3\u5757\u4E91\u76D8\u4E0A\u4E00\u8F6E\u672B\u7684\u7528\u91CF\uFF08usedBytes / sizeBytes / measuredAt\uFF09\u3002\u6309\u4EBA\u4E0D\u6309 persona\uFF1A\u4E91\u4E0A\u6240\u6709 persona \u5171\u7528\u4E00\u5757\u76D8\u3002daemon \u62FF\u672C\u673A api key \u95EE gateway /me/volume\uFF1B\u6CA1\u767B\u5F55 / \u6CA1 key / gateway \u4E0D\u901A / \u6CA1\u8DD1\u8FC7\u4EFB\u52A1\u4E00\u5F8B\u56DE volume:null\uFF08\u89D2\u6807\u4E0D\u6E32\uFF09\uFF0C\u4E0D\u629B\uFF1Bowner-only\u3002\u65E0\u53C2\u6570\uFF08\u67E5\u7684\u662F\u8C03\u7528\u65B9\u81EA\u5DF1\u7684\u76D8\uFF09",
9034
+ args: NO_ARGS
9035
+ },
9031
9036
  "shift:list": {
9032
9037
  summary: "\u5217\u51FA owner \u7684\u5168\u90E8 shift\uFF08\u6392\u73ED\uFF09\uFF0C\u7ED9 UI \u65E5\u5386\u6E32\u67D3\u7528\uFF1Bowner-only",
9033
9038
  args: NO_ARGS
@@ -9534,6 +9539,26 @@ var init_frames = __esm({
9534
9539
  }
9535
9540
  });
9536
9541
 
9542
+ // ../protocol/src/cloud-volume-schemas.ts
9543
+ var CloudVolumeUsageSchema, CloudVolumeGetResultSchema;
9544
+ var init_cloud_volume_schemas = __esm({
9545
+ "../protocol/src/cloud-volume-schemas.ts"() {
9546
+ "use strict";
9547
+ init_zod();
9548
+ CloudVolumeUsageSchema = external_exports.object({
9549
+ /** 已用字节(df 的 Used 列) */
9550
+ usedBytes: external_exports.number().int().nonnegative(),
9551
+ /** 盘的总字节(df 的 1B-blocks 列;ext4 预留之后比 PVC 的 5Gi 略小) */
9552
+ sizeBytes: external_exports.number().int().positive(),
9553
+ /** 量的时刻(ms)= 上一轮结束时 */
9554
+ measuredAt: external_exports.number().int().nonnegative()
9555
+ }).strict();
9556
+ CloudVolumeGetResultSchema = external_exports.object({
9557
+ volume: CloudVolumeUsageSchema.nullable()
9558
+ }).strict();
9559
+ }
9560
+ });
9561
+
9537
9562
  // ../protocol/src/persona-mode.ts
9538
9563
  var init_persona_mode = __esm({
9539
9564
  "../protocol/src/persona-mode.ts"() {
@@ -9705,6 +9730,7 @@ var init_runtime = __esm({
9705
9730
  init_frames();
9706
9731
  init_environment_schemas();
9707
9732
  init_cloud_connector_schemas();
9733
+ init_cloud_volume_schemas();
9708
9734
  init_deploy_schemas();
9709
9735
  init_github_auth_schemas();
9710
9736
  init_persona_schemas();
@@ -62471,7 +62497,9 @@ var GATEWAY_ROUTES = {
62471
62497
  session: (personaId2) => `/p/${encodeURIComponent(personaId2)}/session`,
62472
62498
  sessionSend: (personaId2, sessionId) => `/p/${encodeURIComponent(personaId2)}/session/${encodeURIComponent(sessionId)}`,
62473
62499
  // 历史文件不挂在 persona 下:使用者卷跨 persona 共用(design 2026-09-14-codex-native-memories §3.2f)
62474
- thread: (threadId) => `/threads/${encodeURIComponent(threadId)}`
62500
+ thread: (threadId) => `/threads/${encodeURIComponent(threadId)}`,
62501
+ // 调用方自己那块盘的用量(design 2026-09-19-cloud-volume-usage §3.3):同样按人、不挂 persona
62502
+ volume: () => "/me/volume"
62475
62503
  };
62476
62504
  var trimSlash = (u2) => u2.replace(/\/+$/, "");
62477
62505
  var CloudApiKeyRequiredError = class extends Error {
@@ -62522,6 +62550,10 @@ var CloudGatewayClient = class {
62522
62550
  }
62523
62551
  async listPersonas() {
62524
62552
  const { gatewayUrl } = await this.locate();
62553
+ return this.fetchDeployments(gatewayUrl);
62554
+ }
62555
+ /** /healthz 的登记表 → official 行。gatewayUrl 由调用方定:listPersonas 从中心拿,personaConnectors 用 persona 文件里的 */
62556
+ async fetchDeployments(gatewayUrl) {
62525
62557
  const res = await this.fetchImpl(gatewayUrl + GATEWAY_ROUTES.healthz());
62526
62558
  if (!res.ok) throw new Error(`gateway /healthz \u56DE ${res.status}`);
62527
62559
  const body = await res.json();
@@ -62543,9 +62575,13 @@ var CloudGatewayClient = class {
62543
62575
  }
62544
62576
  return out;
62545
62577
  }
62546
- /** gateway 登记行上这个 persona(gateway 名)装了哪些连接器;没这行 = 空 */
62547
- async personaConnectors(gatewayPersonaId) {
62548
- const list = await this.listPersonas();
62578
+ /**
62579
+ * gateway 登记行上这个 persona(gateway 名)装了哪些连接器;没这行 = 空。
62580
+ * gatewayUrl 从 persona 文件的 cloud.gatewayUrl 来,**不经 locate()**:那一跳只为拿同一个地址,
62581
+ * 远端网络下白等 ~1s(design 2026-09-19-cloud-connectors-skip-locate)。/healthz 不看票,这里也不要求登录。
62582
+ */
62583
+ async personaConnectors(gatewayPersonaId, gatewayUrl) {
62584
+ const list = await this.fetchDeployments(trimSlash(gatewayUrl));
62549
62585
  return list.find((p3) => p3.personaId === gatewayPersonaId)?.connectors ?? [];
62550
62586
  }
62551
62587
  /**
@@ -62562,6 +62598,20 @@ var CloudGatewayClient = class {
62562
62598
  logger: this.deps.logger
62563
62599
  });
62564
62600
  }
62601
+ /**
62602
+ * 这个人云盘上一轮末的用量(design 2026-09-19-cloud-volume-usage §3.3)。gateway 回 `volume: null` = 还没跑过任务(没有盘)。
62603
+ * 没登录 / 没 key 走 credentials() 的抛法,调用方(cloud:volume:get 的 handler)把它们和网络错一并折成 null——角标不该弹错。
62604
+ */
62605
+ async fetchVolume() {
62606
+ const { apiKey, gatewayUrl } = await this.credentials();
62607
+ const res = await this.fetchImpl(gatewayUrl + GATEWAY_ROUTES.volume(), {
62608
+ headers: { authorization: `Bearer ${apiKey}` }
62609
+ });
62610
+ if (!res.ok) throw new Error(`gateway /me/volume \u56DE ${res.status}`);
62611
+ const body = await res.json();
62612
+ if (body.volume == null) return null;
62613
+ return CloudVolumeUsageSchema.parse(body.volume);
62614
+ }
62565
62615
  /** rollout 原文;404 = 没这条 thread(还没开过第一轮 / 卷被清)→ null */
62566
62616
  async fetchRollout(threadId) {
62567
62617
  const { apiKey, gatewayUrl } = await this.credentials();
@@ -70582,7 +70632,7 @@ function buildCloudConnectorsHandlers(deps) {
70582
70632
  const persona = deps.getPersona(personaId2);
70583
70633
  if (!persona) throw new ClawdError(ERROR_CODES.PERSONA_NOT_FOUND, `PERSONA_NOT_FOUND: \u6CA1\u6709\u8FD9\u4E2A persona\uFF08${personaId2}\uFF09`);
70584
70634
  if (!persona.cloud) throw invalid2(`${personaId2} \u4E0D\u662F\u4E91\u4E0A persona\uFF0C\u6CA1\u6709\u8FDE\u63A5\u5668\u533A`);
70585
- const all = await deps.gatewayConnectors(persona.cloud.personaId);
70635
+ const all = await deps.gatewayConnectors(persona.cloud.personaId, persona.cloud.gatewayUrl);
70586
70636
  return { gatewayPersonaId: persona.cloud.personaId, connectors: all.filter((c2) => c2.credentialSource === "personal") };
70587
70637
  }
70588
70638
  const list = async (frame, _client, ctx) => {
@@ -70612,6 +70662,30 @@ function buildCloudConnectorsHandlers(deps) {
70612
70662
  };
70613
70663
  }
70614
70664
 
70665
+ // src/handlers/cloud-volume.ts
70666
+ init_protocol();
70667
+ function ensureOwner7(ctx) {
70668
+ if (!ctx || ctx.principal.kind !== "owner") {
70669
+ throw new ClawdError(ERROR_CODES.UNAUTHORIZED, "UNAUTHORIZED: cloud:volume:get requires owner ctx");
70670
+ }
70671
+ }
70672
+ function buildCloudVolumeHandlers(deps) {
70673
+ const get = async (_frame, _client, ctx) => {
70674
+ ensureOwner7(ctx);
70675
+ let volume = null;
70676
+ if (deps.getLoginPass()) {
70677
+ try {
70678
+ volume = await deps.fetchVolume();
70679
+ } catch (err) {
70680
+ deps.logger?.debug("cloud:volume:get skipped", { reason: err.message });
70681
+ volume = null;
70682
+ }
70683
+ }
70684
+ return { response: { type: "cloud:volume:get:ok", volume } };
70685
+ };
70686
+ return { "cloud:volume:get": get };
70687
+ }
70688
+
70615
70689
  // src/handlers/meta.ts
70616
70690
  var import_node_os23 = __toESM(require("os"), 1);
70617
70691
  init_protocol();
@@ -70671,6 +70745,8 @@ var METHOD_GRANT_MAP = {
70671
70745
  // 拿本机登录凭证向中心代查 / 代填使用者本人的凭据,guest 一律够不着
70672
70746
  "cloud:connectors:list": ADMIN_ANY,
70673
70747
  "cloud:connectors:fill": ADMIN_ANY,
70748
+ // cloud:volume:get(云上会话顶栏的云盘角标;design 2026-09-19-cloud-volume-usage):本机 api key 问 gateway,guest 够不着
70749
+ "cloud:volume:get": ADMIN_ANY,
70674
70750
  // ---- session:* / chat:* 业务方法(v2 Phase 8 两层模型)----
70675
70751
  // dispatcher 不验资源,handler 内按 ctx + frame.args 反查 ownerPersonaId 调 assertGrant。
70676
70752
  // owner 自动通过(ctx 自带 '*':'admin' grant 一切 match);guest 在被授权 persona 内可调。
@@ -70919,7 +70995,7 @@ function computeMethodAccess(args) {
70919
70995
  }
70920
70996
 
70921
70997
  // src/version.ts
70922
- var version = "0.2.543".length > 0 ? "0.2.543" : "dev";
70998
+ var version = "0.2.545".length > 0 ? "0.2.545" : "dev";
70923
70999
 
70924
71000
  // src/cli-probe/probe.ts
70925
71001
  var fs78 = __toESM(require("fs"), 1);
@@ -72578,7 +72654,7 @@ function buildGithubHandlers(deps) {
72578
72654
 
72579
72655
  // src/handlers/visitor.ts
72580
72656
  init_protocol();
72581
- function ensureOwner7(ctx) {
72657
+ function ensureOwner8(ctx) {
72582
72658
  if (!ctx || ctx.principal.kind !== "owner") {
72583
72659
  throw new ClawdError(
72584
72660
  ERROR_CODES.UNAUTHORIZED,
@@ -72588,7 +72664,7 @@ function ensureOwner7(ctx) {
72588
72664
  }
72589
72665
  function buildVisitorHandlers(deps) {
72590
72666
  const list = async (_frame, _client, ctx) => {
72591
- ensureOwner7(ctx);
72667
+ ensureOwner8(ctx);
72592
72668
  return {
72593
72669
  response: {
72594
72670
  type: "visitor:list",
@@ -72874,6 +72950,7 @@ function buildMethodHandlers(deps) {
72874
72950
  ...buildFeishuAuthHandlers(deps.feishuAuth),
72875
72951
  ...buildDeviceHandlers(deps.feishuDevice),
72876
72952
  ...buildCloudConnectorsHandlers(deps.cloudConnectors),
72953
+ ...buildCloudVolumeHandlers(deps.cloudVolume),
72877
72954
  ...deps.attachment ? buildAttachmentHandlers(deps.attachment) : {},
72878
72955
  ...buildExtensionHandlers({
72879
72956
  loadAll,
@@ -74508,13 +74585,19 @@ async function startDaemon(config) {
74508
74585
  // 连没连上问中心。登录票只在 daemon 内部传给中心,与 apiKeyClient 同一条纪律。
74509
74586
  cloudConnectors: {
74510
74587
  getPersona: (personaId2) => personaRegistry.get(personaId2),
74511
- gatewayConnectors: (gatewayPersonaId) => cloudGateway.personaConnectors(gatewayPersonaId),
74588
+ gatewayConnectors: (gatewayPersonaId, gatewayUrl) => cloudGateway.personaConnectors(gatewayPersonaId, gatewayUrl),
74512
74589
  getLoginPass: () => ownerIdentityStore.read()?.loginPass ?? null,
74513
74590
  central: {
74514
74591
  mine: (args) => centralConnectorsMine({ api: config.clawosApi ?? DEFAULT_CLAWOS_API, ...args }),
74515
74592
  fill: (args) => centralConnectorFill({ api: config.clawosApi ?? DEFAULT_CLAWOS_API, ...args })
74516
74593
  }
74517
74594
  },
74595
+ // 云盘角标(design 2026-09-19-cloud-volume-usage):拿不到一律 null,handler 自己折
74596
+ cloudVolume: {
74597
+ getLoginPass: () => ownerIdentityStore.read()?.loginPass ?? null,
74598
+ fetchVolume: () => cloudGateway.fetchVolume(),
74599
+ logger
74600
+ },
74518
74601
  // 设备目录 + 连接(决策 #15:daemon 代理中心 server)。
74519
74602
  // exchange/listDevices 包掉本机登录票(每次现读 store——热切换后立即用新身份);
74520
74603
  // dispatcher 的 FEISHU_GATED_METHODS gate 已保证未登录时这些 RPC 到不了 handler,
@@ -24016,6 +24016,11 @@ var METHOD_DOCS = {
24016
24016
  summary: "\u586B\u5199\u578B\u8FDE\u63A5\u5668\uFF1A\u628A\u4F7F\u7528\u8005\u672C\u4EBA\u7684\u51ED\u636E\u503C\u4EA4\u7ED9\u4E2D\u5FC3\u52A0\u5BC6\u5165\u5E93\uFF08\u4E00\u6B21\u586B\u5199\u5168\u5C40\u5171\u7528\uFF09\u3002**\u8FD9\u662F\u503C\u552F\u4E00\u7684\u5165\u53E3**\uFF1A\u5165\u53C2\u4E0D\u8FDB\u65E5\u5FD7\u3001\u54CD\u5E94\u4E0D\u56DE\u663E\u3001\u672C\u673A\u4E0D\u843D\u76D8\uFF1B\u683C\u540D\u5FC5\u987B\u662F\u8BE5\u8FDE\u63A5\u5668\u58F0\u660E\u8FC7\u7684\uFF1Bowner-only",
24017
24017
  args: CloudConnectorFillArgsSchema
24018
24018
  },
24019
+ // ---- cloud:volume:get(云上会话聊天页顶栏的云盘角标;design 2026-09-19-cloud-volume-usage §3.3)----
24020
+ "cloud:volume:get": {
24021
+ summary: "\u8C03\u7528\u65B9\u81EA\u5DF1\u90A3\u5757\u4E91\u76D8\u4E0A\u4E00\u8F6E\u672B\u7684\u7528\u91CF\uFF08usedBytes / sizeBytes / measuredAt\uFF09\u3002\u6309\u4EBA\u4E0D\u6309 persona\uFF1A\u4E91\u4E0A\u6240\u6709 persona \u5171\u7528\u4E00\u5757\u76D8\u3002daemon \u62FF\u672C\u673A api key \u95EE gateway /me/volume\uFF1B\u6CA1\u767B\u5F55 / \u6CA1 key / gateway \u4E0D\u901A / \u6CA1\u8DD1\u8FC7\u4EFB\u52A1\u4E00\u5F8B\u56DE volume:null\uFF08\u89D2\u6807\u4E0D\u6E32\uFF09\uFF0C\u4E0D\u629B\uFF1Bowner-only\u3002\u65E0\u53C2\u6570\uFF08\u67E5\u7684\u662F\u8C03\u7528\u65B9\u81EA\u5DF1\u7684\u76D8\uFF09",
24022
+ args: NO_ARGS
24023
+ },
24019
24024
  "shift:list": {
24020
24025
  summary: "\u5217\u51FA owner \u7684\u5168\u90E8 shift\uFF08\u6392\u73ED\uFF09\uFF0C\u7ED9 UI \u65E5\u5386\u6E32\u67D3\u7528\uFF1Bowner-only",
24021
24026
  args: NO_ARGS
@@ -24460,6 +24465,19 @@ var MetaMethodsResultSchema = external_exports.object({
24460
24465
  methods: external_exports.array(RpcMethodInfoSchema)
24461
24466
  });
24462
24467
 
24468
+ // ../protocol/src/cloud-volume-schemas.ts
24469
+ var CloudVolumeUsageSchema = external_exports.object({
24470
+ /** 已用字节(df 的 Used 列) */
24471
+ usedBytes: external_exports.number().int().nonnegative(),
24472
+ /** 盘的总字节(df 的 1B-blocks 列;ext4 预留之后比 PVC 的 5Gi 略小) */
24473
+ sizeBytes: external_exports.number().int().positive(),
24474
+ /** 量的时刻(ms)= 上一轮结束时 */
24475
+ measuredAt: external_exports.number().int().nonnegative()
24476
+ }).strict();
24477
+ var CloudVolumeGetResultSchema = external_exports.object({
24478
+ volume: CloudVolumeUsageSchema.nullable()
24479
+ }).strict();
24480
+
24463
24481
  // ../protocol/src/log.ts
24464
24482
  var LOG_SOURCES = ["daemon", "main", "renderer"];
24465
24483
  var LogSourceSchema = external_exports.enum(LOG_SOURCES);