@clawos-dev/clawd 0.2.709 → 0.2.710

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 +29 -4
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -48263,7 +48263,7 @@ function shallowEqMeta(a2, b3) {
48263
48263
  function applyMetaUpdate(state, patch, deps) {
48264
48264
  const next = cloneState(state);
48265
48265
  const merged = { ...next.file, ...patch };
48266
- if (patch.resolvedModel !== void 0) {
48266
+ if (patch.resolvedModel !== void 0 && patch.contextWindowSize === void 0 && (patch.resolvedModel !== next.file.resolvedModel || merged.contextWindowSize === void 0)) {
48267
48267
  const w3 = deps.resolveContextWindow?.(next.file.tool, patch.resolvedModel);
48268
48268
  if (w3 !== void 0) merged.contextWindowSize = w3;
48269
48269
  }
@@ -49230,6 +49230,7 @@ var SessionRunner = class {
49230
49230
  // effect 路由到 session 一等方法(startTurn/respondPermission/answerQuestion/interrupt/stop)。claude 恒 null。
49231
49231
  session = null;
49232
49232
  sessionGeneration = 0;
49233
+ contextRefresh = null;
49233
49234
  stdoutBuf = "";
49234
49235
  // 未决 control_request 表;key = request_id
49235
49236
  pendingControlRequests = /* @__PURE__ */ new Map();
@@ -49398,6 +49399,26 @@ var SessionRunner = class {
49398
49399
  }
49399
49400
  }
49400
49401
  }
49402
+ /** Ask CC for its /context summary, including its own compaction-policy window. */
49403
+ refreshClaudeContext() {
49404
+ const proc = this.proc;
49405
+ if (!proc || !this.state.procAlive || this.state.turnOpen || this.hooks.adapter.id !== "claude" || this.hooks.mode === "tui") return;
49406
+ const refresh = this.sendControlRequest("get_context_usage", { detail: "summary" }).then((raw) => {
49407
+ if (this.proc !== proc || this.contextRefresh !== refresh || this.state.turnOpen || !raw || typeof raw !== "object") return;
49408
+ const usage = raw;
49409
+ const total = usage.totalTokens;
49410
+ const window2 = usage.rawMaxTokens;
49411
+ if (typeof total !== "number" || !Number.isSafeInteger(total) || total < 0 || typeof window2 !== "number" || !Number.isSafeInteger(window2) || window2 <= 0) return;
49412
+ this.feedObserverEvents([{ kind: "meta_update", patch: {
49413
+ ...typeof usage.model === "string" && usage.model ? { resolvedModel: usage.model } : {},
49414
+ contextUsage: { inputTokens: total, outputTokens: 0 },
49415
+ contextWindowSize: window2
49416
+ } }]);
49417
+ }).catch((err) => {
49418
+ this.hooks.logger?.debug("claude context summary unavailable", { message: String(err) });
49419
+ });
49420
+ this.contextRefresh = refresh;
49421
+ }
49401
49422
  // CC control_request 按 request_id 匹配异步 control_response;退出或超时拒绝等待者。
49402
49423
  sendControlRequest(subtype, extraRequestFields = {}, opts = {}) {
49403
49424
  const proc = this.proc;
@@ -49500,9 +49521,12 @@ var SessionRunner = class {
49500
49521
  }
49501
49522
  this.doKill(effect.signal);
49502
49523
  break;
49503
- case "close-stdin":
49504
- this.proc?.stdin?.end();
49524
+ case "close-stdin": {
49525
+ const proc = this.proc;
49526
+ if (this.contextRefresh) void this.contextRefresh.then(() => proc?.stdin?.end());
49527
+ else proc?.stdin?.end();
49505
49528
  break;
49529
+ }
49506
49530
  case "write-stdin":
49507
49531
  if (this.session) {
49508
49532
  this.session.startTurn(effect.payload, this.state.file.cloudPendingTurns?.at(-1)?.id ?? this.state.file.cloudPendingCommand?.id);
@@ -49570,6 +49594,7 @@ var SessionRunner = class {
49570
49594
  ...input.kind === "command" ? { commandKind: input.command.kind } : {}
49571
49595
  });
49572
49596
  }
49597
+ if (event?.kind === "turn_end") this.refreshClaudeContext();
49573
49598
  this.hooks.broadcastFrame(effect.frame, effect.target ?? "broadcast");
49574
49599
  break;
49575
49600
  }
@@ -75937,7 +75962,7 @@ function computeMethodAccess(args) {
75937
75962
  }
75938
75963
 
75939
75964
  // src/version.ts
75940
- var version = "0.2.709".length > 0 ? "0.2.709" : "dev";
75965
+ var version = "0.2.710".length > 0 ? "0.2.710" : "dev";
75941
75966
 
75942
75967
  // src/cli-probe/probe.ts
75943
75968
  var fs87 = __toESM(require("fs"), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.709",
3
+ "version": "0.2.710",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",