@clawos-dev/clawd 0.2.218 → 0.2.219
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 +59 -24
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -41651,6 +41651,47 @@ function escapeAttr(v2) {
|
|
|
41651
41651
|
return v2.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
41652
41652
|
}
|
|
41653
41653
|
|
|
41654
|
+
// src/shift/end-frame-handler.ts
|
|
41655
|
+
function makeEndFrameHandler(sessionId, onEnd) {
|
|
41656
|
+
return (frame) => {
|
|
41657
|
+
if (!frame || typeof frame !== "object") return;
|
|
41658
|
+
const f = frame;
|
|
41659
|
+
if (f.type !== "session:status") return;
|
|
41660
|
+
if (f.sessionId !== sessionId) return;
|
|
41661
|
+
if (f.status === "running-idle") {
|
|
41662
|
+
onEnd({ kind: "idle" });
|
|
41663
|
+
return;
|
|
41664
|
+
}
|
|
41665
|
+
if (f.status === "stopped") {
|
|
41666
|
+
onEnd({ kind: "stopped" });
|
|
41667
|
+
return;
|
|
41668
|
+
}
|
|
41669
|
+
if (f.status === "error") {
|
|
41670
|
+
onEnd({ kind: "error", message: f.message ?? "cc proc error" });
|
|
41671
|
+
return;
|
|
41672
|
+
}
|
|
41673
|
+
};
|
|
41674
|
+
}
|
|
41675
|
+
|
|
41676
|
+
// src/shift/end-dispatcher.ts
|
|
41677
|
+
function dispatchShiftEnd(info, settle, killImpl) {
|
|
41678
|
+
if (info.kind === "idle") {
|
|
41679
|
+
settle({ ok: true });
|
|
41680
|
+
killImpl();
|
|
41681
|
+
return;
|
|
41682
|
+
}
|
|
41683
|
+
if (info.kind === "stopped") {
|
|
41684
|
+
settle({ error: "cc exited before turn completed" });
|
|
41685
|
+
return;
|
|
41686
|
+
}
|
|
41687
|
+
if (info.kind === "error") {
|
|
41688
|
+
settle({ error: info.message });
|
|
41689
|
+
return;
|
|
41690
|
+
}
|
|
41691
|
+
const _exhaustive = info;
|
|
41692
|
+
throw new Error(`dispatchShiftEnd: unhandled kind ${JSON.stringify(_exhaustive)}`);
|
|
41693
|
+
}
|
|
41694
|
+
|
|
41654
41695
|
// src/session/runner.ts
|
|
41655
41696
|
var import_node_os4 = __toESM(require("os"), 1);
|
|
41656
41697
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
@@ -44469,8 +44510,9 @@ var SessionManager = class {
|
|
|
44469
44510
|
* 跟 createDispatchedSession 的差异:
|
|
44470
44511
|
* - 不带 dispatchId / source / task pack;prompt 直接当第一条 user message
|
|
44471
44512
|
* - 不调 personaDispatchManager.registerBSession
|
|
44472
|
-
* - 多返一个 ended Promise,监听 session:status
|
|
44473
|
-
*
|
|
44513
|
+
* - 多返一个 ended Promise,监听 session:status 帧翻译成 shift 业务终态 union
|
|
44514
|
+
* (ShiftSessionEnded:{ok:true} | {error:string}),不经 exit code 中转
|
|
44515
|
+
* - turn-idle 到达即视为业务完成 → settle {ok:true} + fire-and-forget kill cc
|
|
44474
44516
|
* - kill 通过 runner.input({command:{kind:'stop'}}) 触发 SIGKILL → proc-exit
|
|
44475
44517
|
*/
|
|
44476
44518
|
createShiftSession(args) {
|
|
@@ -44514,16 +44556,18 @@ var SessionManager = class {
|
|
|
44514
44556
|
unsubscribe();
|
|
44515
44557
|
resolveEnded(info);
|
|
44516
44558
|
};
|
|
44517
|
-
|
|
44518
|
-
|
|
44519
|
-
|
|
44520
|
-
|
|
44521
|
-
|
|
44522
|
-
|
|
44523
|
-
|
|
44524
|
-
|
|
44525
|
-
|
|
44526
|
-
|
|
44559
|
+
const killImpl = () => {
|
|
44560
|
+
const r = this.runners.get(sessionId);
|
|
44561
|
+
if (!r) return;
|
|
44562
|
+
r.input({ kind: "command", command: { kind: "stop" } });
|
|
44563
|
+
};
|
|
44564
|
+
unsubscribe = this.subscribe(
|
|
44565
|
+
sessionId,
|
|
44566
|
+
scope,
|
|
44567
|
+
makeEndFrameHandler(sessionId, (info) => {
|
|
44568
|
+
dispatchShiftEnd(info, settle, killImpl);
|
|
44569
|
+
})
|
|
44570
|
+
);
|
|
44527
44571
|
const runner = this.ensureRunnerForScope(file, scope);
|
|
44528
44572
|
this.deps.logger?.info("shift.createShiftSession.runner-ready", { sessionId });
|
|
44529
44573
|
runner.input({
|
|
@@ -44536,12 +44580,7 @@ var SessionManager = class {
|
|
|
44536
44580
|
})
|
|
44537
44581
|
}
|
|
44538
44582
|
});
|
|
44539
|
-
|
|
44540
|
-
const r = this.runners.get(sessionId);
|
|
44541
|
-
if (!r) return;
|
|
44542
|
-
r.input({ kind: "command", command: { kind: "stop" } });
|
|
44543
|
-
};
|
|
44544
|
-
return { sessionId, ended, kill };
|
|
44583
|
+
return { sessionId, ended, kill: killImpl };
|
|
44545
44584
|
}
|
|
44546
44585
|
/**
|
|
44547
44586
|
* 老板插话:把 'inject-owner-text' input 喂给对应 runner,
|
|
@@ -48446,15 +48485,11 @@ function createShiftSpawnFn(deps) {
|
|
|
48446
48485
|
void created.ended.then((info) => {
|
|
48447
48486
|
clearTimeout(timer);
|
|
48448
48487
|
if (settled) return;
|
|
48449
|
-
if (info
|
|
48450
|
-
settle({ kind: "error", error: info.error });
|
|
48451
|
-
return;
|
|
48452
|
-
}
|
|
48453
|
-
if (info.exitCode === 0) {
|
|
48488
|
+
if ("ok" in info) {
|
|
48454
48489
|
settle({ kind: "ok" });
|
|
48455
48490
|
return;
|
|
48456
48491
|
}
|
|
48457
|
-
settle({ kind: "error", error:
|
|
48492
|
+
settle({ kind: "error", error: info.error });
|
|
48458
48493
|
});
|
|
48459
48494
|
return { sessionId: created.sessionId, ended };
|
|
48460
48495
|
};
|