claude-overnight 1.50.3 → 1.50.6

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.
@@ -1 +1 @@
1
- export declare const VERSION = "1.50.3";
1
+ export declare const VERSION = "1.50.6";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by build — do not edit manually.
2
- export const VERSION = "1.50.3";
2
+ export const VERSION = "1.50.6";
@@ -310,6 +310,10 @@ export interface RunState extends RunConfigBase {
310
310
  coachedObjective?: string;
311
311
  /** Unix timestamp (ms) when the coach produced the accepted rewrite. */
312
312
  coachedAt?: number;
313
+ /** Run-branch created when mergeStrategy="branch" — must survive resume so subsequent waves accumulate into it instead of orphan branches. */
314
+ runBranch?: string;
315
+ /** Branch (or detached HEAD sha) the user was on before the run-branch was created — restored on run completion. */
316
+ originalRef?: string;
313
317
  }
314
318
  /** Function that returns a rate-limit snapshot with optional context token info. */
315
319
  export type RLGetter = () => {
@@ -21,10 +21,16 @@ let _envResolver;
21
21
  export function setPlannerEnvResolver(fn) {
22
22
  _envResolver = fn;
23
23
  }
24
- // ── Cursor proxy: direct HTTP bypass ──
25
- // SDK spawns 4+ subprocesses (~15s each) for the proxy; one direct POST is 4-10x faster.
26
- function isCursorProxyEnv(env) {
27
- return !!env?.CURSOR_API_KEY && !env?.ANTHROPIC_API_KEY;
24
+ // ── Direct HTTP bypass for non-Anthropic endpoints ──
25
+ // The Claude Code CLI subprocess spawned by @anthropic-ai/claude-agent-sdk validates
26
+ // model names against its built-in Anthropic list and rejects custom ids (qwen3.6-plus,
27
+ // composer-2, etc.) pre-flight, even when ANTHROPIC_BASE_URL points at an Anthropic-
28
+ // compatible proxy. Bypass the SDK with a direct POST for any non-anthropic.com base.
29
+ function shouldUseDirectFetch(env) {
30
+ const base = env?.ANTHROPIC_BASE_URL;
31
+ if (!base)
32
+ return false;
33
+ return !/^https?:\/\/(api\.)?anthropic\.com/i.test(base);
28
34
  }
29
35
  async function runViaDirectFetch(prompt, opts, onLog) {
30
36
  const env = opts.env ?? _envResolver?.(opts.model);
@@ -39,30 +45,34 @@ async function runViaDirectFetch(prompt, opts, onLog) {
39
45
  await apiEndpointLimiter.waitIfNeeded();
40
46
  const waited = await rl.waitIfNeeded();
41
47
  if (waited > 0)
42
- onLog(`Cursor proxy rate gate — waited ${Math.round(waited / 1000)}s`, "event");
48
+ onLog(`Planner proxy rate gate — waited ${Math.round(waited / 1000)}s`, "event");
43
49
  const res = await fetch(`${baseUrl}/v1/messages`, {
44
50
  method: "POST",
45
- headers: { "Content-Type": "application/json", "Authorization": `Bearer ${authToken}` },
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ "Authorization": `Bearer ${authToken}`,
54
+ "anthropic-version": "2023-06-01",
55
+ },
46
56
  body: JSON.stringify({ model: opts.model, max_tokens: 8192, messages: [{ role: "user", content: prompt }] }),
47
57
  });
48
58
  if (res.status === 429 && attempt < MAX_RETRIES) {
49
59
  const waitMs = BACKOFF[attempt];
50
- onLog(`Cursor proxy rate limited — waiting ${Math.round(waitMs / 1000)}s`, "event");
60
+ onLog(`Planner proxy rate limited — waiting ${Math.round(waitMs / 1000)}s`, "event");
51
61
  await sleep(waitMs);
52
62
  continue;
53
63
  }
54
64
  if (!res.ok)
55
- throw new Error(`Cursor proxy ${res.status}: ${(await res.text().catch(() => ""))}`);
65
+ throw new Error(`Planner proxy ${res.status}: ${(await res.text().catch(() => ""))}`);
56
66
  rl.record();
57
67
  apiEndpointLimiter.record();
58
68
  const data = await res.json();
59
69
  return data.content?.[0]?.text ?? "";
60
70
  }
61
- throw new Error("Cursor proxy direct fetch failed after retries");
71
+ throw new Error("Planner proxy direct fetch failed after retries");
62
72
  }
63
73
  export async function runPlannerQuery(prompt, opts, onLog) {
64
74
  const env = opts.env ?? _envResolver?.(opts.model);
65
- if (isCursorProxyEnv(env))
75
+ if (shouldUseDirectFetch(env))
66
76
  return runViaDirectFetch(prompt, opts, onLog);
67
77
  const MAX_RETRIES = 3;
68
78
  const BACKOFF = [30_000, 60_000, 120_000];
@@ -27,7 +27,11 @@ export const STEER_SCHEMA = {
27
27
  required: ["done", "tasks", "reasoning", "statusUpdate", "estimatedSessionsRemaining"],
28
28
  },
29
29
  };
30
- const PROMPT_BUDGET = 6000;
30
+ // The base 30-1_steer template alone is ~7 KB, so any budget below that is
31
+ // unreachable no matter how aggressively we trim variables. 20 KB leaves room
32
+ // for the template + moderate run memory while still being a tiny fraction of
33
+ // any planner's context window.
34
+ const PROMPT_BUDGET = 20_000;
31
35
  const DEFAULT_CAPS = {
32
36
  milestones: 2000, designs: 1500, reflections: 1000,
33
37
  verifications: 1000, previousRuns: 800, userGuidance: 4000,
@@ -109,9 +109,6 @@ export function envFor(p) {
109
109
  base.ANTHROPIC_AUTH_TOKEN = key;
110
110
  }
111
111
  delete base.ANTHROPIC_API_KEY;
112
- // Prevent CURSOR_API_KEY from leaking into non-proxy envs — would trip
113
- // isCursorProxyEnv false-positive, silently rerouting through direct fetch
114
- // which ignores outputFormat (no JSON schema enforcement).
115
112
  delete base.CURSOR_API_KEY;
116
113
  delete base.CURSOR_AUTH_TOKEN;
117
114
  return base;
package/dist/run/run.js CHANGED
@@ -207,10 +207,25 @@ export async function executeRun(cfg) {
207
207
  .then(text => { display.setDebrief(text.trim().slice(0, 210), label); })
208
208
  .catch(() => { display.setDebrief(undefined); });
209
209
  };
210
- // For flex + branch strategy: create one target branch
210
+ // For flex + branch strategy: create one target branch (or restore on resume).
211
+ // The run-branch + originalRef are persisted in run.json so resumes accumulate
212
+ // into the original branch instead of spawning orphan swarm/run-* branches.
211
213
  let runBranch;
212
214
  let originalRef;
213
- if (flex && mergeStrategy === "branch" && useWorktrees && !cfg.resuming) {
215
+ if (cfg.resuming && cfg.resumeState) {
216
+ runBranch = cfg.resumeState.runBranch;
217
+ originalRef = cfg.resumeState.originalRef;
218
+ if (runBranch) {
219
+ try {
220
+ execSync(`git checkout "${runBranch}"`, { cwd, encoding: "utf-8", stdio: "pipe" });
221
+ console.log(chalk.dim(` Resumed on branch: ${runBranch}\n`));
222
+ }
223
+ catch {
224
+ console.log(chalk.yellow(` ⚠ Could not check out run branch ${runBranch} — wave merges may diverge\n`));
225
+ }
226
+ }
227
+ }
228
+ if (flex && mergeStrategy === "branch" && useWorktrees && !runBranch) {
214
229
  try {
215
230
  originalRef = execSync("git rev-parse --abbrev-ref HEAD", { cwd, encoding: "utf-8", stdio: "pipe" }).trim();
216
231
  if (originalRef === "HEAD")
@@ -253,6 +268,8 @@ export async function executeRun(cfg) {
253
268
  repoFingerprint,
254
269
  coachedObjective: cfg.coachedObjective,
255
270
  coachedAt: cfg.coachedAt,
271
+ runBranch,
272
+ originalRef,
256
273
  };
257
274
  const buildRunState = (varying) => composeRunState({ ...runStateBase, workerModel, plannerModel, fastModel, concurrency, usageCap }, { remaining: varying.remaining, waveNum, accCost, accCompleted, accFailed, accIn, accOut, accTools, branches }, { phase: varying.phase, currentTasks: varying.currentTasks });
258
275
  const gracefulStop = () => {
@@ -22,6 +22,8 @@ export interface RunStateBase {
22
22
  repoFingerprint: string;
23
23
  coachedObjective?: string;
24
24
  coachedAt?: number;
25
+ runBranch?: string;
26
+ originalRef?: string;
25
27
  }
26
28
  /** Live counters captured at snapshot time. */
27
29
  export interface RunStateLive {
@@ -26,5 +26,7 @@ export function composeRunState(base, live, varying) {
26
26
  repoFingerprint: base.repoFingerprint,
27
27
  coachedObjective: base.coachedObjective,
28
28
  coachedAt: base.coachedAt,
29
+ runBranch: base.runBranch,
30
+ originalRef: base.originalRef,
29
31
  };
30
32
  }
@@ -199,7 +199,12 @@ export function saveRunState(runDir, state) {
199
199
  }
200
200
  export function loadRunState(runDir) {
201
201
  try {
202
- return JSON.parse(readFileSync(join(runDir, "run.json"), "utf-8"));
202
+ const state = JSON.parse(readFileSync(join(runDir, "run.json"), "utf-8"));
203
+ if (state && !Array.isArray(state.branches))
204
+ state.branches = [];
205
+ if (state && !Array.isArray(state.currentTasks))
206
+ state.currentTasks = [];
207
+ return state;
203
208
  }
204
209
  catch {
205
210
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-overnight",
3
- "version": "1.50.3",
3
+ "version": "1.50.6",
4
4
  "description": "Parallel Claude agents in git worktrees with a usage cap that reserves headroom for your interactive Claude Code. Crash-safe resume. Provider-agnostic model catalog (Anthropic, Cursor, OpenAI, Gemini, DeepSeek, Llama, Qwen) with capability-based task scoping.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-overnight",
3
- "version": "1.50.3",
3
+ "version": "1.50.6",
4
4
  "description": "Claude Code skill for understanding, installing, and inspecting claude-overnight runs -- parallel Claude agents in git worktrees with thinking waves, multi-wave steering, and crash-safe resume. Supports Cursor API Proxy, Qwen, OpenRouter.",
5
5
  "author": {
6
6
  "name": "Francesco Fornace"