@clawos-dev/clawd 0.2.707 → 0.2.708

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.
@@ -33417,6 +33417,8 @@ var SessionUpdateArgs = external_exports.object({
33417
33417
  sessionId: external_exports.string().min(1),
33418
33418
  patch: external_exports.object({
33419
33419
  label: external_exports.string().optional(),
33420
+ // Engine switch is only accepted before the first query (no toolSessionId yet) and never for cloud tools.
33421
+ tool: external_exports.string().min(1).optional(),
33420
33422
  model: external_exports.string().optional(),
33421
33423
  permissionMode: external_exports.string().optional(),
33422
33424
  effort: external_exports.string().optional(),
package/dist/cli.cjs CHANGED
@@ -8626,6 +8626,8 @@ var init_schemas = __esm({
8626
8626
  sessionId: external_exports.string().min(1),
8627
8627
  patch: external_exports.object({
8628
8628
  label: external_exports.string().optional(),
8629
+ // Engine switch is only accepted before the first query (no toolSessionId yet) and never for cloud tools.
8630
+ tool: external_exports.string().min(1).optional(),
8629
8631
  model: external_exports.string().optional(),
8630
8632
  permissionMode: external_exports.string().optional(),
8631
8633
  effort: external_exports.string().optional(),
@@ -50546,6 +50548,52 @@ var SessionManager = class {
50546
50548
  return existing;
50547
50549
  }
50548
50550
  update(args) {
50551
+ const { tool, ...rest } = args.patch;
50552
+ const current = this.getFile(args.sessionId);
50553
+ if (tool !== void 0 && tool !== (current.tool ?? "claude")) {
50554
+ return this.switchTool(current, tool, rest);
50555
+ }
50556
+ return this.applyUpdate({ sessionId: args.sessionId, patch: rest });
50557
+ }
50558
+ /**
50559
+ * 首条 query 发出前换引擎:还没有进程也没有历史,只需改 tool、清掉从属于旧引擎的
50560
+ * model / effort / serviceTier(同 patch 带了 model / effort 就用带的)。闲置 runner 绑着旧
50561
+ * adapter(newRunner 时取),直接丢掉,下次用到按新 tool 重建。
50562
+ */
50563
+ switchTool(existing, tool, rest) {
50564
+ const state = this.runners.get(existing.sessionId)?.getState();
50565
+ if (existing.toolSessionId || state?.procAlive || state?.turnOpen) {
50566
+ throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, "Engine can only be changed before the first message");
50567
+ }
50568
+ if (isCloudTool(existing.tool) || isCloudTool(tool)) {
50569
+ throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, "Cloud session engine cannot be changed");
50570
+ }
50571
+ this.deps.getAdapter(tool);
50572
+ this.titleGenPending.get(existing.sessionId)?.abort();
50573
+ this.titleGenPending.delete(existing.sessionId);
50574
+ this.runners.delete(existing.sessionId);
50575
+ const {
50576
+ model: _model,
50577
+ effort: _effort,
50578
+ serviceTier: _serviceTier,
50579
+ resolvedModel: _resolvedModel,
50580
+ resolvedEffort: _resolvedEffort,
50581
+ ...base
50582
+ } = existing;
50583
+ const updated = {
50584
+ ...base,
50585
+ ...rest,
50586
+ tool,
50587
+ ...isCodexFamily(tool) ? { serviceTier: CODEX_SERVICE_TIERS.standard } : {},
50588
+ updatedAt: nowIso2(this.deps)
50589
+ };
50590
+ this.writeOwned(updated);
50591
+ return {
50592
+ response: updated,
50593
+ broadcast: [{ frame: { type: "session:info", ...updated }, target: "all" }]
50594
+ };
50595
+ }
50596
+ applyUpdate(args) {
50549
50597
  const existing = this.getFile(args.sessionId);
50550
50598
  if (args.patch.model !== void 0 || args.patch.label) {
50551
50599
  this.titleGenPending.get(args.sessionId)?.abort();
@@ -75878,7 +75926,7 @@ function computeMethodAccess(args) {
75878
75926
  }
75879
75927
 
75880
75928
  // src/version.ts
75881
- var version = "0.2.707".length > 0 ? "0.2.707" : "dev";
75929
+ var version = "0.2.708".length > 0 ? "0.2.708" : "dev";
75882
75930
 
75883
75931
  // src/cli-probe/probe.ts
75884
75932
  var fs87 = __toESM(require("fs"), 1);