feat(adapter): claude local chrome flag and max-turns session handling

Add --chrome flag support for Claude adapter. Detect max-turns
exhaustion (via subtype, stop_reason, or result text) and clear
the session to prevent stale session re-use. Add unit tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-26 16:33:10 -06:00
parent b0f3f04ac6
commit 9e89ca4a9e
9 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import { isClaudeMaxTurnsResult } from "@paperclip/adapter-claude-local/server";
describe("claude_local max-turn detection", () => {
it("detects max-turn exhaustion by subtype", () => {
expect(
isClaudeMaxTurnsResult({
subtype: "error_max_turns",
result: "Reached max turns",
}),
).toBe(true);
});
it("detects max-turn exhaustion by stop_reason", () => {
expect(
isClaudeMaxTurnsResult({
stop_reason: "max_turns",
}),
).toBe(true);
});
it("returns false for non-max-turn results", () => {
expect(
isClaudeMaxTurnsResult({
subtype: "success",
stop_reason: "end_turn",
}),
).toBe(false);
});
});