@clawos-dev/clawd 0.2.681 → 0.2.683
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
|
@@ -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
|
-
|
|
48421
|
+
next.stdinClosed = true;
|
|
48422
48422
|
effects.push({ kind: "kill", signal: "SIGTERM" });
|
|
48423
48423
|
} else {
|
|
48424
48424
|
const idleKillMs = idleKillDelayOf(next);
|
|
@@ -49158,6 +49158,14 @@ function encodeAllowWithInputControlResponse(requestId, updatedInput) {
|
|
|
49158
49158
|
}
|
|
49159
49159
|
var DEFAULT_WAIT_STOP_TIMEOUT_MS = 3e3;
|
|
49160
49160
|
var SUBAGENT_ACTIVE_WINDOW_MS = 3e5;
|
|
49161
|
+
function latestTurnId(state) {
|
|
49162
|
+
for (let index = state.buffer.length - 1; index >= 0; index--) {
|
|
49163
|
+
const event = state.buffer[index].event;
|
|
49164
|
+
if (event.turnId) return event.turnId;
|
|
49165
|
+
if (event.kind === "user_text") return void 0;
|
|
49166
|
+
}
|
|
49167
|
+
return void 0;
|
|
49168
|
+
}
|
|
49161
49169
|
var SessionRunner = class {
|
|
49162
49170
|
constructor(initial, hooks) {
|
|
49163
49171
|
this.hooks = hooks;
|
|
@@ -49170,6 +49178,7 @@ var SessionRunner = class {
|
|
|
49170
49178
|
// JSON-RPC 类 agent(codex app-server) 的 per-session 驱动器;非 null 时 runner 不用 spawn()/ChildProcess,
|
|
49171
49179
|
// effect 路由到 session 一等方法(startTurn/respondPermission/answerQuestion/interrupt/stop)。claude 恒 null。
|
|
49172
49180
|
session = null;
|
|
49181
|
+
sessionGeneration = 0;
|
|
49173
49182
|
stdoutBuf = "";
|
|
49174
49183
|
// 未决 control_request 表;key = request_id
|
|
49175
49184
|
pendingControlRequests = /* @__PURE__ */ new Map();
|
|
@@ -49216,6 +49225,7 @@ var SessionRunner = class {
|
|
|
49216
49225
|
};
|
|
49217
49226
|
const { state, effects } = reduceSession(this.state, inputMsg, deps);
|
|
49218
49227
|
this.state = state;
|
|
49228
|
+
if (this.session && effects.some((effect) => effect.kind === "spawn")) this.sessionGeneration++;
|
|
49219
49229
|
for (const e of effects) this.applyEffect(e, inputMsg);
|
|
49220
49230
|
if (!this.state.procAlive && this.stopWaiters.length > 0) {
|
|
49221
49231
|
const waiters = this.stopWaiters;
|
|
@@ -49408,20 +49418,11 @@ var SessionRunner = class {
|
|
|
49408
49418
|
}
|
|
49409
49419
|
lifecycleMetadata() {
|
|
49410
49420
|
const state = this.state;
|
|
49411
|
-
let turnId;
|
|
49412
|
-
for (let index = state.buffer.length - 1; index >= 0; index--) {
|
|
49413
|
-
const event = state.buffer[index].event;
|
|
49414
|
-
if (event.turnId) {
|
|
49415
|
-
turnId = event.turnId;
|
|
49416
|
-
break;
|
|
49417
|
-
}
|
|
49418
|
-
if (event.kind === "user_text") break;
|
|
49419
|
-
}
|
|
49420
49421
|
return {
|
|
49421
49422
|
sessionId: state.file.sessionId,
|
|
49422
49423
|
tool: state.file.tool,
|
|
49423
49424
|
toolSessionId: state.file.toolSessionId,
|
|
49424
|
-
turnId,
|
|
49425
|
+
turnId: latestTurnId(state),
|
|
49425
49426
|
status: state.status,
|
|
49426
49427
|
turnOpen: state.turnOpen,
|
|
49427
49428
|
procAlive: state.procAlive
|
|
@@ -49581,25 +49582,35 @@ var SessionRunner = class {
|
|
|
49581
49582
|
return;
|
|
49582
49583
|
}
|
|
49583
49584
|
if (this.hooks.adapter.createSession) {
|
|
49584
|
-
|
|
49585
|
+
const generation = ++this.sessionGeneration;
|
|
49586
|
+
const isCurrent = () => this.sessionGeneration === generation;
|
|
49587
|
+
const session = this.hooks.adapter.createSession(ctx, {
|
|
49585
49588
|
pushEvents: (events) => {
|
|
49586
|
-
if (events.length === 0) return;
|
|
49589
|
+
if (!isCurrent() || events.length === 0) return;
|
|
49587
49590
|
const uuid = (this.hooks.genUuid ?? import_node_crypto4.randomUUID)();
|
|
49588
49591
|
this.input({ kind: "inject-events", events: events.map((e) => e.uuid ? e : { ...e, uuid }) });
|
|
49589
49592
|
},
|
|
49590
49593
|
onExit: (code) => {
|
|
49594
|
+
if (!isCurrent()) return;
|
|
49595
|
+
this.sessionGeneration++;
|
|
49591
49596
|
this.session = null;
|
|
49592
49597
|
this.clearIdleKillTimers();
|
|
49593
49598
|
this.input({ kind: "proc-exit", code });
|
|
49594
49599
|
},
|
|
49595
|
-
onError: (message) =>
|
|
49596
|
-
|
|
49597
|
-
|
|
49598
|
-
|
|
49599
|
-
|
|
49600
|
-
|
|
49601
|
-
|
|
49600
|
+
onError: (message) => {
|
|
49601
|
+
if (isCurrent()) this.input({ kind: "proc-error", message });
|
|
49602
|
+
},
|
|
49603
|
+
onHistoryGap: (synchronized) => {
|
|
49604
|
+
if (!isCurrent()) return;
|
|
49605
|
+
this.hooks.broadcastFrame({
|
|
49606
|
+
type: "session:control",
|
|
49607
|
+
sessionId: this.state.file.sessionId,
|
|
49608
|
+
kind: CLOUD_HISTORY_REFRESH_KIND,
|
|
49609
|
+
synchronized
|
|
49610
|
+
}, "broadcast");
|
|
49611
|
+
},
|
|
49602
49612
|
onCommandPrepared: (commandId, text, prepared) => {
|
|
49613
|
+
if (!isCurrent()) return false;
|
|
49603
49614
|
const pending = this.state.file.cloudPendingTurns?.find((turn) => turn.id === commandId) ?? this.state.file.cloudPendingCommand;
|
|
49604
49615
|
if (!pending || pending.id !== commandId) return false;
|
|
49605
49616
|
if (!prepared && pending !== this.state.file.cloudPendingCommand) {
|
|
@@ -49607,8 +49618,11 @@ var SessionRunner = class {
|
|
|
49607
49618
|
}
|
|
49608
49619
|
return true;
|
|
49609
49620
|
},
|
|
49610
|
-
onCloudTurnTerminal: (turnId) =>
|
|
49621
|
+
onCloudTurnTerminal: (turnId) => {
|
|
49622
|
+
if (isCurrent()) this.input({ kind: "cloud-turn-terminal", turnId });
|
|
49623
|
+
}
|
|
49611
49624
|
});
|
|
49625
|
+
if (isCurrent()) this.session = session;
|
|
49612
49626
|
return;
|
|
49613
49627
|
}
|
|
49614
49628
|
const proc = this.hooks.spawnOverride ? this.hooks.spawnOverride(ctx) : this.hooks.adapter.spawn(ctx);
|
|
@@ -50745,6 +50759,11 @@ var SessionManager = class {
|
|
|
50745
50759
|
const runner = this.runners.get(sessionId);
|
|
50746
50760
|
return runner?.getState() ?? null;
|
|
50747
50761
|
}
|
|
50762
|
+
/** Native id of the turn this daemon is running right now; null when no foreground turn is open. */
|
|
50763
|
+
openTurnId(sessionId) {
|
|
50764
|
+
const state = this.runners.get(sessionId)?.getState();
|
|
50765
|
+
return state?.turnOpen ? latestTurnId(state) ?? null : null;
|
|
50766
|
+
}
|
|
50748
50767
|
// 等真实 proc-exit 再 ack,避免调用方开始删除 worktree 时进程仍持文件锁;超时向上报错。
|
|
50749
50768
|
async stop(args) {
|
|
50750
50769
|
const file = this.findOwnedSession(args.sessionId);
|
|
@@ -73480,6 +73499,13 @@ function slimHistoryMessages(messages) {
|
|
|
73480
73499
|
return out;
|
|
73481
73500
|
});
|
|
73482
73501
|
}
|
|
73502
|
+
function markOpenTurnInProgress(page, openTurnId) {
|
|
73503
|
+
if (page.view !== "turns" || !openTurnId) return page;
|
|
73504
|
+
return {
|
|
73505
|
+
...page,
|
|
73506
|
+
data: page.data.map((turn) => turn.id === openTurnId && turn.status === "interrupted" ? { ...turn, status: "inProgress" } : turn)
|
|
73507
|
+
};
|
|
73508
|
+
}
|
|
73483
73509
|
function assertGuestPath(ctx, absPath, personaRoot, method, usersRoot) {
|
|
73484
73510
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
73485
73511
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
@@ -73548,6 +73574,7 @@ function buildHistoryHandlers(deps) {
|
|
|
73548
73574
|
if (args.view) {
|
|
73549
73575
|
const reader = getHistoryReader(f2.tool ?? "claude", f2.cloudEnvironment);
|
|
73550
73576
|
if (!reader.readPage) throw new Error("This engine does not support turn history paging");
|
|
73577
|
+
const openTurnId = manager.openTurnId(args.sessionId);
|
|
73551
73578
|
const page = await reader.readPage({
|
|
73552
73579
|
cwd: f2.cwd,
|
|
73553
73580
|
toolSessionId: f2.toolSessionId,
|
|
@@ -73557,7 +73584,7 @@ function buildHistoryHandlers(deps) {
|
|
|
73557
73584
|
turnId: args.turnId,
|
|
73558
73585
|
snapshotId: args.snapshotId
|
|
73559
73586
|
});
|
|
73560
|
-
return { response: { type: "history:read", ...page } };
|
|
73587
|
+
return { response: { type: "history:read", ...markOpenTurnInProgress(page, openTurnId) } };
|
|
73561
73588
|
}
|
|
73562
73589
|
let res;
|
|
73563
73590
|
try {
|
|
@@ -75323,7 +75350,7 @@ function computeMethodAccess(args) {
|
|
|
75323
75350
|
}
|
|
75324
75351
|
|
|
75325
75352
|
// src/version.ts
|
|
75326
|
-
var version = "0.2.
|
|
75353
|
+
var version = "0.2.683".length > 0 ? "0.2.683" : "dev";
|
|
75327
75354
|
|
|
75328
75355
|
// src/cli-probe/probe.ts
|
|
75329
75356
|
var fs86 = __toESM(require("fs"), 1);
|