@clawos-dev/clawd 0.2.20-beta.27.e8cd6cc → 0.2.20

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 +1 -94
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -13446,11 +13446,6 @@ var SessionRunner = class {
13446
13446
  this.stopWaiters = [];
13447
13447
  for (const w of waiters) w();
13448
13448
  }
13449
- try {
13450
- this.hooks.onAfterInput?.(this.state, inputMsg);
13451
- } catch (err) {
13452
- this.hooks.logger?.warn("onAfterInput hook threw", { err: err.message });
13453
- }
13454
13449
  }
13455
13450
  // 等子进程退出(procAlive=false)。manager.stop 在发完 SIGTERM 后调它确保
13456
13451
  // 真停下来再 ack 给前端,从而避免"删 worktree 时 CC 还活着持有文件锁"的 race。
@@ -13643,63 +13638,6 @@ var SessionRunner = class {
13643
13638
  }
13644
13639
  };
13645
13640
 
13646
- // src/session/phase.ts
13647
- var PHASE_DESCRIPTIONS = {
13648
- idle: "\u8FD8\u6CA1\u542F\u52A8",
13649
- spawning: "\u8FDB\u7A0B\u542F\u52A8\u4E2D",
13650
- "turn-idle": "\u8FDB\u7A0B\u6D3B\u7740\uFF0C\u7B49\u8F93\u5165",
13651
- "turn-running": "\u6B63\u5728 run \u4E2D",
13652
- stopping: "\u6B63\u5728\u6740\u8FDB\u7A0B",
13653
- exited: "\u8FDB\u7A0B\u5DF2\u9000\u51FA",
13654
- crashed: "\u542F\u52A8\u5931\u8D25 / \u5F02\u5E38\u9000\u51FA",
13655
- observing: "\u5916\u90E8 CC \u5728\u8DD1\uFF0Cdaemon \u65C1\u89C2"
13656
- };
13657
- function derivePhase(state) {
13658
- switch (state.status) {
13659
- case "idle":
13660
- return "idle";
13661
- case "spawning":
13662
- return "spawning";
13663
- case "running":
13664
- return state.turnOpen ? "turn-running" : "turn-idle";
13665
- case "stopping":
13666
- return "stopping";
13667
- case "stopped":
13668
- return "exited";
13669
- case "error":
13670
- return "crashed";
13671
- }
13672
- }
13673
- function deriveReason(input) {
13674
- switch (input.kind) {
13675
- case "command":
13676
- return `cmd:${input.command.kind}`;
13677
- case "proc-exit":
13678
- return "proc-exit";
13679
- case "proc-error":
13680
- return "proc-error";
13681
- case "inject-events":
13682
- return "observer-events";
13683
- case "stdout-line":
13684
- return "stdout";
13685
- case "permission-decision":
13686
- return "permission";
13687
- case "answer-question":
13688
- return "answer-question";
13689
- case "tick":
13690
- return "tick";
13691
- }
13692
- }
13693
- function buildPhaseLogFields(args) {
13694
- return {
13695
- sessionId: args.sessionId,
13696
- phase: args.phase,
13697
- prev: args.prev,
13698
- desc: PHASE_DESCRIPTIONS[args.phase],
13699
- ...args.reason ? { reason: args.reason } : {}
13700
- };
13701
- }
13702
-
13703
13641
  // src/session/manager.ts
13704
13642
  function compressFrameForWire(frame) {
13705
13643
  if (frame.type !== "session:status") return frame;
@@ -13785,9 +13723,6 @@ var SessionManager = class {
13785
13723
  // 由 observer 监听 jsonl user 行后调 recordRealUserUuid 建立映射;rewind 系列 RPC 在
13786
13724
  // 入参 / 出参做转译,保证 UI 看到的 uuid 始终是 events 流里的 synth uuid
13787
13725
  realUuidBySynth = /* @__PURE__ */ new Map();
13788
- // sessionId → 最近一次打过 log 的 phase;diff 命中才再打,避免每次 input 刷一行。
13789
- // observer 路径的 'observing' 也写到这张表,跟 reducer 派生 phase 共享 last 值
13790
- lastPhase = /* @__PURE__ */ new Map();
13791
13726
  async getCapabilities(tool) {
13792
13727
  const cached = this.capabilitiesCache.get(tool);
13793
13728
  if (cached) return cached;
@@ -13809,35 +13744,10 @@ var SessionManager = class {
13809
13744
  now: this.deps.now,
13810
13745
  bufferCap: this.deps.bufferCap,
13811
13746
  // adapter 自己持有模型表 + 兜底逻辑(contains / opus-1M / [1m] 等),manager 不再 cache 转发
13812
- resolveContextWindow: (tool, modelId) => this.deps.getAdapter(tool).resolveContextWindow(modelId),
13813
- // phase 派生:每次 input 应用完后比对,变化才打一行 log。observer 路径的
13814
- // 'observing' 由 onObserverPhase 单独写入 lastPhase 表,此处不会回退
13815
- onAfterInput: (state, input) => this.recordPhaseFromState(file.sessionId, state, deriveReason(input))
13747
+ resolveContextWindow: (tool, modelId) => this.deps.getAdapter(tool).resolveContextWindow(modelId)
13816
13748
  });
13817
13749
  return runner;
13818
13750
  }
13819
- // 给 reducer state 派生当前 phase,跟上次 diff,变化时打一行带中文说明的 log
13820
- recordPhaseFromState(sessionId, state, reason) {
13821
- const next = derivePhase(state);
13822
- const prev = this.lastPhase.get(sessionId) ?? null;
13823
- if (prev === next) return;
13824
- this.lastPhase.set(sessionId, next);
13825
- this.deps.logger?.info(
13826
- "session-phase",
13827
- buildPhaseLogFields({ sessionId, phase: next, prev, reason })
13828
- );
13829
- }
13830
- // observer 路径:外部 CC 在跑、daemon 只 tail JSONL;走单独的 'observing' phase
13831
- recordObserverPhase(sessionId, status) {
13832
- const next = status === "observing" ? "observing" : "exited";
13833
- const prev = this.lastPhase.get(sessionId) ?? null;
13834
- if (prev === next) return;
13835
- this.lastPhase.set(sessionId, next);
13836
- this.deps.logger?.info(
13837
- "session-phase",
13838
- buildPhaseLogFields({ sessionId, phase: next, prev, reason: "observer" })
13839
- );
13840
- }
13841
13751
  // 统一 runner 出口:先压 wire,然后按当前上下文路由
13842
13752
  // 同步命令路径(currentCollector 非空) → push 进 collector,命令方法返回给 dispatcher
13843
13753
  // 异步路径(stdout/exit/observer 主动调用) → 走 deps.broadcastFrame
@@ -13990,11 +13900,9 @@ var SessionManager = class {
13990
13900
  });
13991
13901
  this.runners.delete(args.sessionId);
13992
13902
  this.realUuidBySynth.delete(args.sessionId);
13993
- this.lastPhase.delete(args.sessionId);
13994
13903
  return { response: { sessionId: args.sessionId }, broadcast };
13995
13904
  }
13996
13905
  this.deps.store.delete(args.sessionId);
13997
- this.lastPhase.delete(args.sessionId);
13998
13906
  return {
13999
13907
  response: { sessionId: args.sessionId },
14000
13908
  broadcast: [
@@ -18399,7 +18307,6 @@ async function startDaemon(config) {
18399
18307
  hasRunner: !!r,
18400
18308
  runnerProcAlive: r ? r.getState().procAlive : null
18401
18309
  });
18402
- manager.recordObserverPhase(sessionId, status);
18403
18310
  transport?.broadcastToSession(sessionId, { type: "session:status", sessionId, status });
18404
18311
  },
18405
18312
  // jsonl user 行的 real uuid 映射到 buffer 里 synth user_text,rewind 系列 RPC 在
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.20-beta.27.e8cd6cc",
3
+ "version": "0.2.20",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",