benignswarm 0.12.48 → 0.12.49

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.
@@ -6,7 +6,7 @@ import { bool, str } from "../args.js";
6
6
  import { agentRef, loadAgent } from "../config.js";
7
7
  import { CliError } from "../errors.js";
8
8
  import { requireInstall } from "../install.js";
9
- import { bindSession, codexRollout } from "../sessions.js";
9
+ import { bindSession, codexArchivedRollout, codexRollout } from "../sessions.js";
10
10
  import { codexHooksPath } from "./codex.js";
11
11
  import { join } from "./join.js";
12
12
  import { installLaunchd } from "./watch.js";
@@ -66,9 +66,12 @@ export async function codexStart(p, out) {
66
66
  let firstTurnLog = null;
67
67
  if (adopt) {
68
68
  thread = adopt.toLowerCase();
69
- if (!codexRollout(thread))
69
+ if (!codexRollout(thread)) {
70
+ if (codexArchivedRollout(thread))
71
+ throw new CliError("archived", `Codex thread ${thread} is archived (its session file is in ~/.codex/archived_sessions)`, "Unarchive it in the Codex app, then leave it unopened there and run this again");
70
72
  throw new CliError("not_found", `no Codex session file for thread ${thread} under ~/.codex/sessions on this machine`);
71
- lines.push(`Adopted Codex thread ${thread}. Close it in the Codex app: from now on the watcher runs its turns, and two clients on one thread conflict.`);
73
+ }
74
+ lines.push(`Adopted Codex thread ${thread}. Leave it unopened in the Codex app (do not archive it: that moves its session file away): from now on the watcher runs its turns, and two clients on one thread conflict.`);
72
75
  }
73
76
  else {
74
77
  const logDir = joinPath(homedir(), ".bschat", "logs");
@@ -1,5 +1,5 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { bindSession, codexRollout, sessionOfExec, threadOfExec } from "../sessions.js";
2
+ import { bindSession, codexArchivedRollout, codexRollout, sessionOfExec, threadOfExec } from "../sessions.js";
3
3
  import { readTurnPhase, startTurn, stopTurn } from "../turn.js";
4
4
  import { applyAck } from "./wake.js";
5
5
  import { reloadLaunchAgent, requireInstall } from "../install.js";
@@ -373,7 +373,9 @@ async function turnStep(ctl, thread, timeoutMin, log, wake, name) {
373
373
  }
374
374
  }
375
375
  else {
376
- log(`no session file for thread ${thread} under ~/.codex/sessions; cannot tell whether a turn is running, so starting none`);
376
+ log(codexArchivedRollout(thread)
377
+ ? `thread ${thread} is archived in the Codex app (its session file is in ~/.codex/archived_sessions); starting no turn until it is unarchived`
378
+ : `no session file for thread ${thread} under ~/.codex/sessions; cannot tell whether a turn is running, so starting none`);
377
379
  return;
378
380
  }
379
381
  const st = readState(name);
package/dist/sessions.js CHANGED
@@ -74,6 +74,14 @@ export function sessionsOf(kind, ref) {
74
74
  return Object.entries(read(kind).conversations).filter(([, r]) => r === ref).map(([id]) => id);
75
75
  }
76
76
  /** A Codex thread's rollout file (~/.codex/sessions/YYYY/MM/DD/rollout-*-<thread>.jsonl), newest first, or null. */
77
+ /** The thread's session file in Codex's archive (the app moves it there when a thread is archived), if it is there. */
78
+ export function codexArchivedRollout(thread) {
79
+ const dir = join(process.env.CODEX_HOME ?? join(homedir(), ".codex"), "archived_sessions");
80
+ if (!existsSync(dir))
81
+ return null;
82
+ const f = readdirSync(dir).find((n) => n.includes(thread) && n.endsWith(".jsonl"));
83
+ return f ? join(dir, f) : null;
84
+ }
77
85
  export function codexRollout(thread) {
78
86
  const root = join(process.env.CODEX_HOME ?? join(homedir(), ".codex"), "sessions");
79
87
  if (!existsSync(root))
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.48";
1
+ export const CLI_VERSION = "0.12.49";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.48",
3
+ "version": "0.12.49",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {