@clawos-dev/clawd 0.2.37 → 0.2.38-beta.55.d2c72b2
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 +44 -11
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -8738,9 +8738,10 @@ var init_schemas = __esm({
|
|
|
8738
8738
|
// NewSessionDialog 勾选 worktree 创建的 session 才会持久化这两个字段
|
|
8739
8739
|
worktreeRoot: external_exports.string().min(1).optional(),
|
|
8740
8740
|
worktreeBranch: external_exports.string().min(1).optional(),
|
|
8741
|
-
// 由 session:fork 派生的 session 在 create 时记录源
|
|
8742
|
-
// sidebar 据此挂 fork 图标。非 fork session
|
|
8743
|
-
forkedFromToolSessionId
|
|
8741
|
+
// 由 session:fork 派生的 session 在 create 时记录源 session 的 sessionId(稳定 key,
|
|
8742
|
+
// 不受 parent clear / re-spawn 影响);sidebar 据此挂 fork 图标。非 fork session 该字段缺省。
|
|
8743
|
+
// 旧字段 forkedFromToolSessionId 已弃用,daemon 启动时一次性迁移老数据
|
|
8744
|
+
forkedFromSessionId: external_exports.string().min(1).optional(),
|
|
8744
8745
|
// owner-mode persona session 身份标识;UI 用它在 SessionList 过滤 + jump,
|
|
8745
8746
|
// daemon 用它做 idempotent dedupe + spawn 时派生 ctx.personaMode='owner'
|
|
8746
8747
|
ownerPersonaId: external_exports.string().min(1).optional(),
|
|
@@ -8955,8 +8956,8 @@ var init_schemas = __esm({
|
|
|
8955
8956
|
// NewSessionDialog 勾选 worktree 时由 UI 传入,daemon 原样持久化,不做额外副作用
|
|
8956
8957
|
worktreeRoot: external_exports.string().min(1).optional(),
|
|
8957
8958
|
worktreeBranch: external_exports.string().min(1).optional(),
|
|
8958
|
-
// session:fork 派生 session 时由 UI
|
|
8959
|
-
|
|
8959
|
+
// session:fork 派生 session 时由 UI 传入源 sessionId,daemon 写到 SessionFile.forkedFromSessionId
|
|
8960
|
+
forkedFromSessionId: external_exports.string().min(1).optional(),
|
|
8960
8961
|
// owner-mode persona session:传此字段时 daemon 自行派生 cwd 和启动参数,
|
|
8961
8962
|
// 且按 ownerPersonaId 做 idempotent dedupe(每 persona 永远只有一个 owner session)
|
|
8962
8963
|
ownerPersonaId: external_exports.string().min(1).optional()
|
|
@@ -15522,19 +15523,51 @@ var SessionStore = class {
|
|
|
15522
15523
|
if (code === "ENOENT") return [];
|
|
15523
15524
|
throw err;
|
|
15524
15525
|
}
|
|
15525
|
-
const
|
|
15526
|
+
const raws = [];
|
|
15526
15527
|
for (const name of entries) {
|
|
15527
15528
|
if (!name.endsWith(".json")) continue;
|
|
15528
15529
|
if (name.includes(".tmp-")) continue;
|
|
15529
15530
|
const full = import_node_path3.default.join(this.root, name);
|
|
15530
15531
|
try {
|
|
15531
|
-
const
|
|
15532
|
-
const parsed = JSON.parse(
|
|
15533
|
-
|
|
15534
|
-
|
|
15532
|
+
const text = import_node_fs3.default.readFileSync(full, "utf8");
|
|
15533
|
+
const parsed = JSON.parse(text);
|
|
15534
|
+
raws.push({ raw: parsed, path: full });
|
|
15535
|
+
} catch {
|
|
15536
|
+
continue;
|
|
15537
|
+
}
|
|
15538
|
+
}
|
|
15539
|
+
const byToolId = /* @__PURE__ */ new Map();
|
|
15540
|
+
for (const { raw } of raws) {
|
|
15541
|
+
const sid = raw["sessionId"];
|
|
15542
|
+
const tsid = raw["toolSessionId"];
|
|
15543
|
+
if (typeof sid === "string" && typeof tsid === "string") byToolId.set(tsid, sid);
|
|
15544
|
+
}
|
|
15545
|
+
const out = [];
|
|
15546
|
+
for (const { raw, path: full } of raws) {
|
|
15547
|
+
const legacy = raw["forkedFromToolSessionId"];
|
|
15548
|
+
const dirty = typeof legacy === "string";
|
|
15549
|
+
if (dirty) {
|
|
15550
|
+
if (raw["forkedFromSessionId"] === void 0) {
|
|
15551
|
+
const parentSid = byToolId.get(legacy);
|
|
15552
|
+
if (typeof parentSid === "string") raw["forkedFromSessionId"] = parentSid;
|
|
15553
|
+
}
|
|
15554
|
+
delete raw["forkedFromToolSessionId"];
|
|
15555
|
+
}
|
|
15556
|
+
let validated;
|
|
15557
|
+
try {
|
|
15558
|
+
validated = SessionFileSchema.parse(raw);
|
|
15535
15559
|
} catch {
|
|
15536
15560
|
continue;
|
|
15537
15561
|
}
|
|
15562
|
+
if (dirty) {
|
|
15563
|
+
try {
|
|
15564
|
+
const tmp = `${full}.tmp-${process.pid}-${Date.now()}`;
|
|
15565
|
+
import_node_fs3.default.writeFileSync(tmp, JSON.stringify(validated, null, 2), { encoding: "utf8", mode: 384 });
|
|
15566
|
+
import_node_fs3.default.renameSync(tmp, full);
|
|
15567
|
+
} catch {
|
|
15568
|
+
}
|
|
15569
|
+
}
|
|
15570
|
+
out.push(validated);
|
|
15538
15571
|
}
|
|
15539
15572
|
return out.sort((a, b) => a.updatedAt > b.updatedAt ? -1 : a.updatedAt < b.updatedAt ? 1 : 0);
|
|
15540
15573
|
}
|
|
@@ -16789,7 +16822,7 @@ var SessionManager = class {
|
|
|
16789
16822
|
iconKey: args.iconKey,
|
|
16790
16823
|
worktreeRoot: args.worktreeRoot,
|
|
16791
16824
|
worktreeBranch: args.worktreeBranch,
|
|
16792
|
-
|
|
16825
|
+
forkedFromSessionId: args.forkedFromSessionId,
|
|
16793
16826
|
ownerPersonaId: args.ownerPersonaId,
|
|
16794
16827
|
createdAt: iso,
|
|
16795
16828
|
updatedAt: iso
|
package/package.json
CHANGED