chore: updated Claude Code to v2.1.39 with improved reliability and OAuth enhancements

- Updated Claude Code version header to 2.1.39 and runtime version to v24.13.1.
- Increased request timeout from 60s to 600s for improved reliability on slower connections.
- Reordered Accept-Encoding header values to prioritize Brotli compression.
- Updated OAuth endpoints to use platform.claude.com and expanded scopes to include user:sessions:claude_code and user:mcp_servers.
- Removed deprecated beta features claude-code-20250219 and fine-grained-tool-streaming-2025-05-14.
- Improved Bun binary detection and update process with version verification and environment variable checking.
This commit is contained in:
can1357
2026-02-12 08:35:15 +01:00
parent 857abcc321
commit 531f8e7f4a
6 changed files with 67 additions and 18 deletions
+17
View File
@@ -1,6 +1,23 @@
# Changelog
## [Unreleased]
### Added
- Added prompt-caching-scope-2026-01-05 beta feature support
### Changed
- Updated Claude Code version header to 2.1.39
- Updated runtime version header to v24.13.1 and package version to 0.73.0
- Increased request timeout from 60s to 600s
- Reordered Accept-Encoding header values for compression preference
- Updated OAuth authorization and token endpoints to use platform.claude.com
- Expanded OAuth scopes to include user:sessions:claude_code and user:mcp_servers
### Removed
- Removed claude-code-20250219 beta feature from default models
- Removed fine-grained-tool-streaming-2025-05-14 beta feature
## [11.13.1] - 2026-02-12
### Added
+6 -7
View File
@@ -59,19 +59,19 @@ function getCacheControl(
}
// Stealth mode: Mimic Claude Code headers and tool prefixing.
export const claudeCodeVersion = "1.0.83";
export const claudeCodeVersion = "2.1.39";
export const claudeToolPrefix = "proxy_";
export const claudeCodeSystemInstruction = "You are Claude Code, Anthropic's official CLI for Claude.";
export const claudeCodeHeaders = {
"X-Stainless-Helper-Method": "stream",
"X-Stainless-Retry-Count": "0",
"X-Stainless-Runtime-Version": "v24.3.0",
"X-Stainless-Package-Version": "0.55.1",
"X-Stainless-Runtime-Version": "v24.13.1",
"X-Stainless-Package-Version": "0.73.0",
"X-Stainless-Runtime": "node",
"X-Stainless-Lang": "js",
"X-Stainless-Arch": "arm64",
"X-Stainless-Os": "MacOS",
"X-Stainless-Timeout": "60",
"X-Stainless-Timeout": "600",
} as const;
export const applyClaudeToolPrefix = (name: string) => {
@@ -89,10 +89,9 @@ export const stripClaudeToolPrefix = (name: string) => {
};
const claudeCodeBetaDefaults = [
"claude-code-20250219",
"oauth-2025-04-20",
"interleaved-thinking-2025-05-14",
"fine-grained-tool-streaming-2025-05-14",
"prompt-caching-scope-2026-01-05",
];
// Prefix tool names for OAuth traffic.
@@ -465,7 +464,7 @@ export function buildAnthropicHeaders(options: AnthropicHeaderOptions): Record<s
...modelHeaders,
...claudeCodeHeaders,
Accept: acceptHeader,
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Encoding": "br, gzip, deflate",
Connection: "keep-alive",
"Content-Type": "application/json",
"Anthropic-Version": "2023-06-01",
+3 -3
View File
@@ -7,11 +7,11 @@ import type { OAuthController, OAuthCredentials } from "./types";
const decode = (s: string) => atob(s);
const CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
const TOKEN_URL = "https://console.anthropic.com/v1/oauth/token";
const AUTHORIZE_URL = "https://platform.claude.com/oauth/authorize";
const TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
const CALLBACK_PORT = 54545;
const CALLBACK_PATH = "/callback";
const SCOPES = "org:create_api_key user:profile user:inference";
const SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers";
class AnthropicOAuthFlow extends OAuthCallbackFlow {
#verifier: string = "";
+9
View File
@@ -1,6 +1,15 @@
# Changelog
## [Unreleased]
### Changed
- Improved Bun binary detection to check `Bun.env.PI_COMPILED` environment variable
- Enhanced Bun package manager update to install specific version instead of latest
- Added post-update verification for Bun installations to warn if expected version was not installed
### Fixed
- Fixed Bun update process to properly handle version pinning and report installation mismatches
## [11.14.0] - 2026-02-12
### Added
+28 -7
View File
@@ -17,7 +17,10 @@ import { theme } from "../modes/theme/theme";
* Detect if we're running as a Bun compiled binary.
*/
const isBunBinary =
import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
Bun.env.PI_COMPILED ||
import.meta.url.includes("$bunfs") ||
import.meta.url.includes("~BUN") ||
import.meta.url.includes("%7EBUN");
const REPO = "can1357/oh-my-pi";
const PACKAGE = "@oh-my-pi/pi-coding-agent";
@@ -155,15 +158,33 @@ function getNativeAddonName(): string {
/**
* Update via bun package manager.
*/
async function updateViaBun(): Promise<void> {
async function updateViaBun(expectedVersion: string): Promise<void> {
console.log(chalk.dim("Updating via bun..."));
try {
execSync(`bun update --latest -g ${PACKAGE}`, { stdio: "inherit" });
console.log(chalk.green(`\n${theme.status.success} Update complete`));
execSync(`bun install -g ${PACKAGE}@${expectedVersion}`, { stdio: "inherit" });
} catch (error) {
throw new Error("bun update failed", { cause: error });
throw new Error("bun install failed", { cause: error });
}
// Verify the update actually took effect
try {
const result = spawnSync("bun", ["pm", "ls", "-g"], { encoding: "utf-8", stdio: "pipe" });
const output = result.stdout || "";
const match = output.match(new RegExp(`${PACKAGE.replace("/", "\\/")}@(\\S+)`));
if (match) {
const installedVersion = match[1];
if (compareVersions(installedVersion, expectedVersion) < 0) {
console.log(
chalk.yellow(`\nWarning: bun reports ${installedVersion} installed, expected ${expectedVersion}`),
);
console.log(chalk.yellow(`Try: bun install -g ${PACKAGE}@latest`));
return;
}
}
} catch {
// Verification is best-effort, don't fail the update
}
console.log(chalk.green(`\n${theme.status.success} Update complete`));
}
/**
@@ -280,7 +301,7 @@ export async function runUpdateCommand(opts: { force: boolean; check: boolean })
// Choose update method
try {
if (!isBunBinary && hasBun()) {
await updateViaBun();
await updateViaBun(release.version);
} else {
await updateViaBinary(release);
}
+4 -1
View File
@@ -45,7 +45,10 @@ const legacyUserDataDir =
: path.join(os.homedir(), ".local", "bin");
const downloadUrl = `https://github.com/can1357/oh-my-pi/releases/latest/download/${addonFilename}`;
const isCompiledBinary =
import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
Bun.env.PI_COMPILED ||
import.meta.url.includes("$bunfs") ||
import.meta.url.includes("~BUN") ||
import.meta.url.includes("%7EBUN");
const SUPPORTED_PLATFORMS = ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64", "win32-x64"];