@clawos-dev/clawd 0.2.681 → 0.2.682

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 +27 -12
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -48418,7 +48418,7 @@ function pushEventToBufferInPlace(next, event, deps) {
48418
48418
  next.stdinClosed = true;
48419
48419
  effects.push({ kind: "close-stdin" });
48420
48420
  } else if (isRpcAgentTool(tool) && !isCloudTool(tool)) {
48421
- if (tool === PI_TOOL_ID) next.stdinClosed = true;
48421
+ next.stdinClosed = true;
48422
48422
  effects.push({ kind: "kill", signal: "SIGTERM" });
48423
48423
  } else {
48424
48424
  const idleKillMs = idleKillDelayOf(next);
@@ -49170,6 +49170,7 @@ var SessionRunner = class {
49170
49170
  // JSON-RPC 类 agent(codex app-server) 的 per-session 驱动器;非 null 时 runner 不用 spawn()/ChildProcess,
49171
49171
  // effect 路由到 session 一等方法(startTurn/respondPermission/answerQuestion/interrupt/stop)。claude 恒 null。
49172
49172
  session = null;
49173
+ sessionGeneration = 0;
49173
49174
  stdoutBuf = "";
49174
49175
  // 未决 control_request 表;key = request_id
49175
49176
  pendingControlRequests = /* @__PURE__ */ new Map();
@@ -49216,6 +49217,7 @@ var SessionRunner = class {
49216
49217
  };
49217
49218
  const { state, effects } = reduceSession(this.state, inputMsg, deps);
49218
49219
  this.state = state;
49220
+ if (this.session && effects.some((effect) => effect.kind === "spawn")) this.sessionGeneration++;
49219
49221
  for (const e of effects) this.applyEffect(e, inputMsg);
49220
49222
  if (!this.state.procAlive && this.stopWaiters.length > 0) {
49221
49223
  const waiters = this.stopWaiters;
@@ -49581,25 +49583,35 @@ var SessionRunner = class {
49581
49583
  return;
49582
49584
  }
49583
49585
  if (this.hooks.adapter.createSession) {
49584
- this.session = this.hooks.adapter.createSession(ctx, {
49586
+ const generation = ++this.sessionGeneration;
49587
+ const isCurrent = () => this.sessionGeneration === generation;
49588
+ const session = this.hooks.adapter.createSession(ctx, {
49585
49589
  pushEvents: (events) => {
49586
- if (events.length === 0) return;
49590
+ if (!isCurrent() || events.length === 0) return;
49587
49591
  const uuid = (this.hooks.genUuid ?? import_node_crypto4.randomUUID)();
49588
49592
  this.input({ kind: "inject-events", events: events.map((e) => e.uuid ? e : { ...e, uuid }) });
49589
49593
  },
49590
49594
  onExit: (code) => {
49595
+ if (!isCurrent()) return;
49596
+ this.sessionGeneration++;
49591
49597
  this.session = null;
49592
49598
  this.clearIdleKillTimers();
49593
49599
  this.input({ kind: "proc-exit", code });
49594
49600
  },
49595
- onError: (message) => this.input({ kind: "proc-error", message }),
49596
- onHistoryGap: (synchronized) => this.hooks.broadcastFrame({
49597
- type: "session:control",
49598
- sessionId: this.state.file.sessionId,
49599
- kind: CLOUD_HISTORY_REFRESH_KIND,
49600
- synchronized
49601
- }, "broadcast"),
49601
+ onError: (message) => {
49602
+ if (isCurrent()) this.input({ kind: "proc-error", message });
49603
+ },
49604
+ onHistoryGap: (synchronized) => {
49605
+ if (!isCurrent()) return;
49606
+ this.hooks.broadcastFrame({
49607
+ type: "session:control",
49608
+ sessionId: this.state.file.sessionId,
49609
+ kind: CLOUD_HISTORY_REFRESH_KIND,
49610
+ synchronized
49611
+ }, "broadcast");
49612
+ },
49602
49613
  onCommandPrepared: (commandId, text, prepared) => {
49614
+ if (!isCurrent()) return false;
49603
49615
  const pending = this.state.file.cloudPendingTurns?.find((turn) => turn.id === commandId) ?? this.state.file.cloudPendingCommand;
49604
49616
  if (!pending || pending.id !== commandId) return false;
49605
49617
  if (!prepared && pending !== this.state.file.cloudPendingCommand) {
@@ -49607,8 +49619,11 @@ var SessionRunner = class {
49607
49619
  }
49608
49620
  return true;
49609
49621
  },
49610
- onCloudTurnTerminal: (turnId) => this.input({ kind: "cloud-turn-terminal", turnId })
49622
+ onCloudTurnTerminal: (turnId) => {
49623
+ if (isCurrent()) this.input({ kind: "cloud-turn-terminal", turnId });
49624
+ }
49611
49625
  });
49626
+ if (isCurrent()) this.session = session;
49612
49627
  return;
49613
49628
  }
49614
49629
  const proc = this.hooks.spawnOverride ? this.hooks.spawnOverride(ctx) : this.hooks.adapter.spawn(ctx);
@@ -75323,7 +75338,7 @@ function computeMethodAccess(args) {
75323
75338
  }
75324
75339
 
75325
75340
  // src/version.ts
75326
- var version = "0.2.681".length > 0 ? "0.2.681" : "dev";
75341
+ var version = "0.2.682".length > 0 ? "0.2.682" : "dev";
75327
75342
 
75328
75343
  // src/cli-probe/probe.ts
75329
75344
  var fs86 = __toESM(require("fs"), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.681",
3
+ "version": "0.2.682",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",