@clawos-dev/clawd 0.2.65-beta.107.ac81439 → 0.2.65-beta.108.410b956

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 +53 -8
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -22121,6 +22121,16 @@ function nowIso2(deps) {
22121
22121
  function newSessionId() {
22122
22122
  return v4_default().replace(/-/g, "").slice(0, 16);
22123
22123
  }
22124
+ function derivePersonaSpawnCwd(file, personaRoot) {
22125
+ const personaId = file.ownerPersonaId;
22126
+ if (!personaId) return file.cwd;
22127
+ if (!personaRoot) {
22128
+ throw new Error(
22129
+ `derivePersonaSpawnCwd: personaRoot missing for owner session ${file.sessionId} (ownerPersonaId=${personaId})`
22130
+ );
22131
+ }
22132
+ return import_node_path6.default.join(personaRoot, safeFileName(personaId));
22133
+ }
22124
22134
  function makeInitialState(file, subSessionMeta) {
22125
22135
  return {
22126
22136
  file,
@@ -22279,6 +22289,24 @@ var SessionManager = class {
22279
22289
  const adapter = this.deps.getAdapter(file.tool ?? "claude");
22280
22290
  const store = this.storeFor(scope);
22281
22291
  const subSessionMeta = metaFromScope(scope, this.deps.personaRoot ?? "");
22292
+ const correctedCwd = derivePersonaSpawnCwd(file, this.deps.personaRoot);
22293
+ if (correctedCwd !== file.cwd) {
22294
+ this.deps.logger?.warn("owner session cwd drifted from persona dir; auto-correcting", {
22295
+ sessionId: file.sessionId,
22296
+ ownerPersonaId: file.ownerPersonaId,
22297
+ stale: file.cwd,
22298
+ corrected: correctedCwd
22299
+ });
22300
+ file = { ...file, cwd: correctedCwd, updatedAt: nowIso2(this.deps) };
22301
+ try {
22302
+ store.write(file);
22303
+ } catch (err) {
22304
+ this.deps.logger?.warn("failed to persist auto-corrected owner cwd", {
22305
+ sessionId: file.sessionId,
22306
+ error: err.message
22307
+ });
22308
+ }
22309
+ }
22282
22310
  const attachmentGroup = this.deps.attachmentGroup;
22283
22311
  const runner = new SessionRunner(makeInitialState(file, subSessionMeta), {
22284
22312
  broadcastFrame: (frame, target) => this.routeFromRunner(frame, target),
@@ -22388,14 +22416,31 @@ var SessionManager = class {
22388
22416
  }
22389
22417
  // ---- 命令方法:均返回 { response, broadcast[] },由 dispatcher 聚合 ----
22390
22418
  create(args) {
22391
- let cwd = args.cwd;
22392
- if (args.ownerPersonaId && !cwd) {
22393
- if (!this.deps.personaRoot) {
22394
- throw new Error("personaRoot required to derive cwd from ownerPersonaId");
22395
- }
22396
- cwd = import_node_path6.default.join(this.deps.personaRoot, safeFileName(args.ownerPersonaId));
22397
- }
22398
- if (!cwd) {
22419
+ this.deps.logger?.warn("[spawn-cwd-debug] manager.create entry", {
22420
+ argsOwnerPersonaId: args.ownerPersonaId,
22421
+ argsCwd: args.cwd,
22422
+ personaRoot: this.deps.personaRoot
22423
+ });
22424
+ let cwd;
22425
+ if (args.ownerPersonaId) {
22426
+ cwd = derivePersonaSpawnCwd(
22427
+ {
22428
+ sessionId: "",
22429
+ cwd: args.cwd ?? "",
22430
+ tool: "claude",
22431
+ ownerPersonaId: args.ownerPersonaId,
22432
+ createdAt: "",
22433
+ updatedAt: ""
22434
+ },
22435
+ this.deps.personaRoot
22436
+ );
22437
+ this.deps.logger?.warn("[spawn-cwd-debug] derived persona cwd", { derivedCwd: cwd });
22438
+ } else if (args.cwd) {
22439
+ cwd = args.cwd;
22440
+ this.deps.logger?.warn("[spawn-cwd-debug] using args.cwd (no ownerPersonaId)", {
22441
+ cwd
22442
+ });
22443
+ } else {
22399
22444
  throw new ClawdError(ERROR_CODES.INVALID_CWD, "cwd required when ownerPersonaId is absent");
22400
22445
  }
22401
22446
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.65-beta.107.ac81439",
3
+ "version": "0.2.65-beta.108.410b956",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",