@yanzc/claude-pro 0.4.2 → 0.4.3

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.
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@yanzc/claude-pro",
3
- "version": "0.4.2",
4
- "description": "claude-pro: a self-implemented coding agent for Anthropic-compatible APIs or local Claude Code subscription login. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
5
- "type": "module",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/yanzaocheng/copy-claude-code.git"
9
- },
10
- "homepage": "https://github.com/yanzaocheng/copy-claude-code#readme",
11
- "keywords": ["claude", "coding-agent", "cli", "anthropic", "ai"],
12
- "bin": {
13
- "claude-pro": "bin/claude-pro.js"
14
- },
15
- "files": [
16
- "bin/",
17
- "src/",
18
- ".env.example",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "scripts": {
23
- "start": "node bin/claude-pro.js",
24
- "check": "node bin/claude-pro.js --self-check",
25
- "test": "node --test --test-force-exit --test-timeout=60000 --test-reporter=dot \"test/**/*.test.js\""
26
- },
27
- "engines": {
28
- "node": ">=22"
29
- },
30
- "license": "MIT",
31
- "publishConfig": {
32
- "access": "public"
33
- },
34
- "dependencies": {
35
- "@anthropic-ai/sdk": "^0.128.0"
36
- },
37
- "devDependencies": {
38
- "@xterm/headless": "^6.0.0"
39
- }
40
- }
1
+ {
2
+ "name": "@yanzc/claude-pro",
3
+ "version": "0.4.3",
4
+ "description": "claude-pro: a self-implemented coding agent for Anthropic-compatible APIs or local Claude Code subscription login. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/yanzaocheng/copy-claude-code.git"
9
+ },
10
+ "homepage": "https://github.com/yanzaocheng/copy-claude-code#readme",
11
+ "keywords": ["claude", "coding-agent", "cli", "anthropic", "ai"],
12
+ "bin": {
13
+ "claude-pro": "bin/claude-pro.js"
14
+ },
15
+ "files": [
16
+ "bin/",
17
+ "src/",
18
+ ".env.example",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "start": "node bin/claude-pro.js",
24
+ "check": "node bin/claude-pro.js --self-check",
25
+ "test": "node --test --test-force-exit --test-timeout=60000 --test-reporter=dot \"test/**/*.test.js\""
26
+ },
27
+ "engines": {
28
+ "node": ">=22"
29
+ },
30
+ "license": "MIT",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "dependencies": {
35
+ "@anthropic-ai/sdk": "^0.128.0"
36
+ },
37
+ "devDependencies": {
38
+ "@xterm/headless": "^6.0.0"
39
+ }
40
+ }
package/src/api.js CHANGED
@@ -7,7 +7,7 @@ import { refreshClaudeCodeLogin, canRenewLogin } from './oauth.js';
7
7
  import { humanDuration, parseRateLimit, parseRetryAfter, planRetry, sleepUntil, timing } from './ratelimit.js';
8
8
  import { cacheControl, cachePlanOf, fingerprint } from './cache.js';
9
9
  import { readGatewayLogin, fetchGatewayModels, cachedGatewayModel, gatewayEffort, gatewayDefaultEffort } from './gateway.js';
10
- import { createCodexFetch, codexModels, codexEffort } from './codex/client.js';
10
+ import { createCodexFetch, codexModels, codexEffort, nearestEffort } from './codex/client.js';
11
11
  import { SIGNATURE_PREFIX } from './codex/translate-request.js';
12
12
 
13
13
  let cached = null;
@@ -212,11 +212,15 @@ export function defaultEffort(modelId, config = null) {
212
212
  return null;
213
213
  }
214
214
 
215
+ // The effort levels Claude takes, as Claude Code's /effort offers them. OpenAI's none and minimal and the ultra of
216
+ // some GPT models are not among them; a level chosen on a GPT model stays chosen after a switch to Claude.
217
+ export const CLAUDE_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
218
+
215
219
  // The level a request for this model carries when `effort` is chosen: the nearest one the model takes. A GPT model
216
- // lists its own (the gateway's /v1/models, else the local Codex models cache). Claude has no "ultra", the level
217
- // above max that some GPT models take, which stays chosen when the user switches from such a model to Claude.
220
+ // lists its own (the gateway's /v1/models, else the local Codex models cache); Claude takes CLAUDE_EFFORTS.
218
221
  export function effortToSend(config, modelId, effort) {
219
222
  if (!effort) return effort;
223
+ if (/^claude-/i.test(modelId)) return nearestEffort(effort, CLAUDE_EFFORTS);
220
224
  if (!/^gpt-/i.test(modelId)) return effort === 'ultra' ? 'max' : effort;
221
225
  const info = gatewayModelInfo(config, modelId);
222
226
  return info ? gatewayEffort(info, effort) : codexEffort(modelId, effort, codexEnv(config));
@@ -174,6 +174,9 @@ function clampEffort(effort, supported) {
174
174
  return supported.reduce((best, s) => (Math.abs(EFFORTS.indexOf(s) - want) < Math.abs(EFFORTS.indexOf(best) - want) ? s : best), supported[0]);
175
175
  }
176
176
 
177
+ // The level of `supported` nearest to `effort` (on the scale none … ultra); `effort` itself when it is supported.
178
+ export const nearestEffort = (effort, supported) => clampEffort(effort, supported);
179
+
177
180
  // The effort levels a GPT model takes, from the local Codex models cache ([] when it is not listed there):
178
181
  // gpt-6.1-sol takes low … ultra, but not none or minimal.
179
182
  export const codexEfforts = (modelId, env = process.env) => codexModels(env).models.find((m) => m.slug === modelId)?.efforts || [];
package/src/commands.js CHANGED
@@ -15,7 +15,7 @@ import { INIT_PROMPT } from './prompts.js';
15
15
  import { loadCustomCommands, renderSkill, expandCommandBody, expandShellEmbeds } from './agents.js';
16
16
  import { listBackgroundShells } from './tools/bash.js';
17
17
  import { estimateTokens } from './agent.js';
18
- import { quickQuery, cacheRefusals, defaultEffort, effortToSend } from './api.js';
18
+ import { quickQuery, cacheRefusals, defaultEffort, effortToSend, CLAUDE_EFFORTS } from './api.js';
19
19
  import { hasRipgrep } from './utils/shell.js';
20
20
  import { displayPath } from './utils/paths.js';
21
21
  import { rewind } from './checkpoints.js';
@@ -23,8 +23,10 @@ import { canRestart, runSelfCheck } from './restart.js';
23
23
 
24
24
  const EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
25
25
  const isGpt = (modelId) => /^gpt-/i.test(modelId);
26
- // The levels /effort offers for a model: gateway metadata first, then the local Codex cache, else EFFORTS.
26
+ // The levels /effort offers for a model: Claude's own (as in Claude Code); for a GPT model the gateway's metadata,
27
+ // else the local Codex cache; EFFORTS for other models (an Anthropic-compatible API may take any of them).
27
28
  const effortLevels = (modelId, modelInfo = null) => {
29
+ if (/^claude-/i.test(modelId)) return CLAUDE_EFFORTS;
28
30
  const remote = gatewayEfforts(modelInfo);
29
31
  if (remote.length) return remote;
30
32
  return isGpt(modelId) && codexEfforts(modelId).length ? codexEfforts(modelId) : EFFORTS;