@moxxy/plugin-provider-claude-code 0.41.3 → 0.42.1
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/dist/login.d.ts +12 -2
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +31 -4
- package/dist/login.js.map +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +3 -3
- package/dist/provider.js.map +1 -1
- package/package.json +8 -8
- package/src/login-desktop.test.ts +93 -0
- package/src/login.ts +49 -6
- package/src/process.test.ts +1 -1
- package/src/provider.test.ts +37 -35
- package/src/provider.ts +3 -3
package/dist/login.d.ts
CHANGED
|
@@ -12,9 +12,19 @@ export interface ClaudeCommandResult {
|
|
|
12
12
|
readonly stderr: string;
|
|
13
13
|
readonly error?: NodeJS.ErrnoException;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* A GUI host's side of the CLI's interactive login: it shows the CLI's output
|
|
17
|
+
* and answers the CLI's paste prompt, since the CLI has no terminal of its own.
|
|
18
|
+
*/
|
|
19
|
+
export interface ClaudeLoginRelay {
|
|
20
|
+
readonly write: (chunk: string) => void;
|
|
21
|
+
readonly askCode: () => Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
interface CommandOptions {
|
|
16
24
|
readonly inherit?: boolean;
|
|
17
|
-
|
|
25
|
+
readonly relay?: ClaudeLoginRelay;
|
|
26
|
+
}
|
|
27
|
+
type CommandRunner = (executable: string, args: readonly string[], options?: CommandOptions) => Promise<ClaudeCommandResult>;
|
|
18
28
|
/** Test seam. */
|
|
19
29
|
export declare function __setClaudeCommandRunner(runner: CommandRunner): void;
|
|
20
30
|
/** Resolve the executable without involving a shell (paths containing spaces are safe). */
|
package/dist/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAEA,OAA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
import { CLAUDE_AUTH_LOGIN_ARGS, CLAUDE_AUTH_LOGOUT_ARGS, CLAUDE_AUTH_STATUS_ARGS, CLAUDE_CODE_EXECUTABLE_ENV, CLAUDE_CODE_PROVIDER_ID, } from './constants.js';
|
|
4
|
+
/** The CLI's non-TTY login asks for a code only when the browser's automatic return fails. */
|
|
5
|
+
const PASTE_PROMPT = /paste code/i;
|
|
6
|
+
const PASTE_QUESTION = 'If your browser shows a sign-in code instead of finishing on its own, paste it here.';
|
|
4
7
|
let runCommandImpl = runCommand;
|
|
5
8
|
/** Test seam. */
|
|
6
9
|
export function __setClaudeCommandRunner(runner) {
|
|
@@ -64,7 +67,12 @@ export async function claudeLogin(ctx) {
|
|
|
64
67
|
return status.accountId ? { accountId: status.accountId } : {};
|
|
65
68
|
if (status.state !== 'signed-out')
|
|
66
69
|
throw authError(status);
|
|
67
|
-
|
|
70
|
+
// A GUI host (the desktop) has no terminal to hand the CLI, so relay its
|
|
71
|
+
// dialogue through the host instead.
|
|
72
|
+
const prompt = ctx.prompt;
|
|
73
|
+
const login = await runCommandImpl(executable, CLAUDE_AUTH_LOGIN_ARGS, ctx.noOpen && prompt
|
|
74
|
+
? { relay: { write: ctx.write, askCode: () => prompt(PASTE_QUESTION) } }
|
|
75
|
+
: { inherit: true });
|
|
68
76
|
if (login.error)
|
|
69
77
|
throw authError({ state: login.error.code === 'ENOENT' ? 'missing' : 'error', executable, message: login.error.message });
|
|
70
78
|
if (login.code !== 0) {
|
|
@@ -132,17 +140,36 @@ function authError(status) {
|
|
|
132
140
|
});
|
|
133
141
|
}
|
|
134
142
|
async function runCommand(executable, args, options = {}) {
|
|
143
|
+
const { relay } = options;
|
|
135
144
|
return await new Promise((resolve) => {
|
|
136
145
|
const spawnOptions = options.inherit
|
|
137
146
|
? { stdio: 'inherit' }
|
|
138
|
-
: { stdio: ['ignore', 'pipe', 'pipe'] };
|
|
147
|
+
: { stdio: [relay ? 'pipe' : 'ignore', 'pipe', 'pipe'] };
|
|
139
148
|
const child = spawn(executable, [...args], spawnOptions);
|
|
140
149
|
let stdout = '';
|
|
141
150
|
let stderr = '';
|
|
151
|
+
let askedForCode = false;
|
|
152
|
+
// The CLI may exit (browser callback) before the pasted code arrives.
|
|
153
|
+
child.stdin?.on('error', () => { });
|
|
142
154
|
child.stdout?.setEncoding('utf8');
|
|
143
155
|
child.stderr?.setEncoding('utf8');
|
|
144
|
-
child.stdout?.on('data', (chunk) => {
|
|
145
|
-
|
|
156
|
+
child.stdout?.on('data', (chunk) => {
|
|
157
|
+
stdout += chunk;
|
|
158
|
+
if (!relay)
|
|
159
|
+
return;
|
|
160
|
+
relay.write(chunk);
|
|
161
|
+
if (askedForCode || !PASTE_PROMPT.test(stdout))
|
|
162
|
+
return;
|
|
163
|
+
askedForCode = true;
|
|
164
|
+
void relay.askCode().then((code) => {
|
|
165
|
+
if (code.trim() && child.stdin?.writable)
|
|
166
|
+
child.stdin.write(`${code.trim()}\n`);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
child.stderr?.on('data', (chunk) => {
|
|
170
|
+
stderr += chunk;
|
|
171
|
+
relay?.write(chunk);
|
|
172
|
+
});
|
|
146
173
|
child.once('error', (error) => resolve({ code: 1, stdout, stderr, error }));
|
|
147
174
|
child.once('close', (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
148
175
|
});
|
package/dist/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMxC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAA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AE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACnG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LLMProvider, ModelDescriptor, ProviderEvent, ProviderRequest } from '@moxxy/sdk';
|
|
2
2
|
import { type ClaudeSpawn } from './process.js';
|
|
3
|
-
export declare const CLAUDE_CODE_DEFAULT_MODEL = "claude-sonnet-5";
|
|
3
|
+
export declare const CLAUDE_CODE_DEFAULT_MODEL = "claude-sonnet-5-5";
|
|
4
4
|
export declare const claudeCodeModels: ReadonlyArray<ModelDescriptor>;
|
|
5
5
|
export interface ClaudeCodeProviderConfig {
|
|
6
6
|
/** Installed Claude Code executable. Defaults to the command resolved from PATH. */
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG/F,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtF,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG/F,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtF,eAAO,M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,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;gBAE7B,MAAM,GAAE,wBAA6B;IAoB1C,MAAM,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa,CAAC,aAAa,CAAC;IAkF3D,WAAW,CACf,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC,GACpE,OAAO,CAAC,MAAM,CAAC;CAYnB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,wBAA6B,GAAG,WAAW,CAEzF"}
|
package/dist/provider.js
CHANGED
|
@@ -2,7 +2,7 @@ import { estimateTextTokens } from '@moxxy/sdk';
|
|
|
2
2
|
import { CLAUDE_CODE_PROVIDER_ID } from './constants.js';
|
|
3
3
|
import { ClaudeProcessError, runClaudeProcess } from './process.js';
|
|
4
4
|
import { createProtocolState, parseClaudeRecord, serializeClaudePrompt } from './protocol.js';
|
|
5
|
-
export const CLAUDE_CODE_DEFAULT_MODEL = 'claude-sonnet-5';
|
|
5
|
+
export const CLAUDE_CODE_DEFAULT_MODEL = 'claude-sonnet-5-5';
|
|
6
6
|
const NON_TEXT_BLOCK_TOKENS = 256;
|
|
7
7
|
/**
|
|
8
8
|
* Models offered by Claude Code subscriptions through the installed CLI.
|
|
@@ -23,8 +23,8 @@ const textOnlyCapabilities = {
|
|
|
23
23
|
hostedTools: ['web_search'],
|
|
24
24
|
};
|
|
25
25
|
export const claudeCodeModels = [
|
|
26
|
-
{ id: 'claude-fable-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
27
|
-
{ id: 'claude-opus-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
26
|
+
{ id: 'claude-fable-5-1', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
27
|
+
{ id: 'claude-opus-5-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
28
28
|
{ id: CLAUDE_CODE_DEFAULT_MODEL, contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
29
29
|
{ id: 'claude-haiku-4-5', contextWindow: 200_000, maxOutputTokens: 64_000, ...textOnlyCapabilities },
|
|
30
30
|
];
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAoB,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE9F,MAAM,CAAC,MAAM,yBAAyB,GAAG,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE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AAE,CAAC;AACtF,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc,EAAE,UAAkB;IAC9D,MAAM,SAAS,GAAG,KAA8B,CAAC;IACjD,IAAI,SAAS,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,oCAAoC,UAAU,mIAAmI;YAC1L,SAAS,EAAE,KAAK;SACjB,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/plugin-provider-claude-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "Claude Pro/Max subscription provider for moxxy. Streams through the user's authenticated installed Claude CLI, with opt-in native-tool tasks and no Anthropic API key.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
],
|
|
55
55
|
"provider": {
|
|
56
56
|
"auth": "oauth",
|
|
57
|
-
"defaultModel": "claude-sonnet-5"
|
|
57
|
+
"defaultModel": "claude-sonnet-5-5"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@moxxy/plugin-browser": "0.
|
|
63
|
-
"@moxxy/plugin-oauth": "0.
|
|
64
|
-
"@moxxy/plugin-provider-anthropic": "0.
|
|
65
|
-
"@moxxy/sdk": "0.
|
|
62
|
+
"@moxxy/plugin-browser": "0.42.1",
|
|
63
|
+
"@moxxy/plugin-oauth": "0.42.1",
|
|
64
|
+
"@moxxy/plugin-provider-anthropic": "0.42.1",
|
|
65
|
+
"@moxxy/sdk": "0.42.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/node": "^22.
|
|
68
|
+
"@types/node": "^22.20.5",
|
|
69
69
|
"typescript": "^6.0.3",
|
|
70
|
-
"vitest": "^
|
|
70
|
+
"vitest": "^5.0.3",
|
|
71
71
|
"zod": "^3.25.76",
|
|
72
72
|
"@moxxy/tsconfig": "0.0.0",
|
|
73
73
|
"@moxxy/vitest-preset": "0.0.0"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { chmod, mkdtemp, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { posixShell } from '@moxxy/vitest-preset/platform';
|
|
6
|
+
import type { ProviderAuthContext } from '@moxxy/sdk';
|
|
7
|
+
import { claudeLogin } from './login.js';
|
|
8
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
9
|
+
|
|
10
|
+
// A stand-in for the installed `claude` binary, speaking the same non-TTY login
|
|
11
|
+
// dialogue: it prints the sign-in URL and a paste prompt, then either finishes
|
|
12
|
+
// on its own (the browser's localhost callback) or waits for a pasted code.
|
|
13
|
+
const FAKE_CLAUDE = `#!/usr/bin/env node
|
|
14
|
+
const fs = require('node:fs');
|
|
15
|
+
const path = require('node:path');
|
|
16
|
+
const marker = path.join(__dirname, 'signed-in');
|
|
17
|
+
const [, , group, command] = process.argv;
|
|
18
|
+
if (group === 'auth' && command === 'status') {
|
|
19
|
+
console.log(JSON.stringify({ loggedIn: fs.existsSync(marker), email: 'me@example.com' }));
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
if (group === 'auth' && command === 'login') {
|
|
23
|
+
process.stdout.write('Opening browser to sign in…\\n');
|
|
24
|
+
process.stdout.write("If the browser didn't open, visit: https://claude.com/cai/oauth/authorize?code=true\\n");
|
|
25
|
+
process.stdout.write('Paste code here if prompted > ');
|
|
26
|
+
if (process.env.FAKE_CLAUDE_CALLBACK === '1') {
|
|
27
|
+
fs.writeFileSync(marker, '');
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
let input = '';
|
|
31
|
+
process.stdin.on('data', (chunk) => {
|
|
32
|
+
input += chunk;
|
|
33
|
+
if (!input.includes('\\n')) return;
|
|
34
|
+
if (input.trim() !== 'code#state') process.exit(3);
|
|
35
|
+
fs.writeFileSync(marker, '');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const dirs: string[] = [];
|
|
42
|
+
|
|
43
|
+
afterEach(async () => {
|
|
44
|
+
delete process.env.FAKE_CLAUDE_CALLBACK;
|
|
45
|
+
await Promise.all(dirs.splice(0).map((dir) => removeDir(dir)));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
async function fakeClaude(): Promise<string> {
|
|
49
|
+
const dir = await mkdtemp(join(tmpdir(), 'moxxy-claude-login-'));
|
|
50
|
+
dirs.push(dir);
|
|
51
|
+
const executable = join(dir, 'claude');
|
|
52
|
+
await writeFile(executable, FAKE_CLAUDE, 'utf8');
|
|
53
|
+
await chmod(executable, 0o755);
|
|
54
|
+
return executable;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The context `moxxy login --stdin-prompts` hands a provider when the desktop drives it. */
|
|
58
|
+
function desktopContext(executable: string, answer: () => Promise<string>) {
|
|
59
|
+
const output: string[] = [];
|
|
60
|
+
const questions: string[] = [];
|
|
61
|
+
const ctx: ProviderAuthContext = {
|
|
62
|
+
headless: false,
|
|
63
|
+
noOpen: true,
|
|
64
|
+
providerConfig: { executable },
|
|
65
|
+
write: (chunk) => { output.push(chunk); },
|
|
66
|
+
onAuthUrl: () => {},
|
|
67
|
+
prompt: async (question) => {
|
|
68
|
+
questions.push(question);
|
|
69
|
+
return await answer();
|
|
70
|
+
},
|
|
71
|
+
vault: { get: async () => null, set: async () => {}, delete: async () => false },
|
|
72
|
+
};
|
|
73
|
+
return { ctx, output, questions };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('Claude sign-in driven from the desktop', () => {
|
|
77
|
+
it.skipIf(!posixShell)('shows the CLI progress and hands the code pasted in the desktop to the CLI', async () => {
|
|
78
|
+
const { ctx, output, questions } = desktopContext(await fakeClaude(), async () => 'code#state');
|
|
79
|
+
|
|
80
|
+
await expect(claudeLogin(ctx)).resolves.toEqual({ accountId: 'me@example.com' });
|
|
81
|
+
|
|
82
|
+
expect(output.join('')).toContain("If the browser didn't open, visit: https://claude.com/cai/oauth/authorize?code=true");
|
|
83
|
+
expect(questions).toHaveLength(1);
|
|
84
|
+
expect(questions[0]).toMatch(/paste/i);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it.skipIf(!posixShell)('finishes when the browser completes the sign-in, without waiting for a pasted code', async () => {
|
|
88
|
+
process.env.FAKE_CLAUDE_CALLBACK = '1';
|
|
89
|
+
const { ctx } = desktopContext(await fakeClaude(), () => new Promise<string>(() => {}));
|
|
90
|
+
|
|
91
|
+
await expect(claudeLogin(ctx)).resolves.toEqual({ accountId: 'me@example.com' });
|
|
92
|
+
});
|
|
93
|
+
});
|
package/src/login.ts
CHANGED
|
@@ -29,12 +29,30 @@ export interface ClaudeCommandResult {
|
|
|
29
29
|
readonly error?: NodeJS.ErrnoException;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* A GUI host's side of the CLI's interactive login: it shows the CLI's output
|
|
34
|
+
* and answers the CLI's paste prompt, since the CLI has no terminal of its own.
|
|
35
|
+
*/
|
|
36
|
+
export interface ClaudeLoginRelay {
|
|
37
|
+
readonly write: (chunk: string) => void;
|
|
38
|
+
readonly askCode: () => Promise<string>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface CommandOptions {
|
|
42
|
+
readonly inherit?: boolean;
|
|
43
|
+
readonly relay?: ClaudeLoginRelay;
|
|
44
|
+
}
|
|
45
|
+
|
|
32
46
|
type CommandRunner = (
|
|
33
47
|
executable: string,
|
|
34
48
|
args: readonly string[],
|
|
35
|
-
options?:
|
|
49
|
+
options?: CommandOptions,
|
|
36
50
|
) => Promise<ClaudeCommandResult>;
|
|
37
51
|
|
|
52
|
+
/** The CLI's non-TTY login asks for a code only when the browser's automatic return fails. */
|
|
53
|
+
const PASTE_PROMPT = /paste code/i;
|
|
54
|
+
const PASTE_QUESTION = 'If your browser shows a sign-in code instead of finishing on its own, paste it here.';
|
|
55
|
+
|
|
38
56
|
let runCommandImpl: CommandRunner = runCommand;
|
|
39
57
|
/** Test seam. */
|
|
40
58
|
export function __setClaudeCommandRunner(runner: CommandRunner): void {
|
|
@@ -101,7 +119,16 @@ export async function claudeLogin(ctx: ProviderAuthContext): Promise<ProviderOAu
|
|
|
101
119
|
if (status.state === 'signed-in') return status.accountId ? { accountId: status.accountId } : {};
|
|
102
120
|
if (status.state !== 'signed-out') throw authError(status);
|
|
103
121
|
|
|
104
|
-
|
|
122
|
+
// A GUI host (the desktop) has no terminal to hand the CLI, so relay its
|
|
123
|
+
// dialogue through the host instead.
|
|
124
|
+
const prompt = ctx.prompt;
|
|
125
|
+
const login = await runCommandImpl(
|
|
126
|
+
executable,
|
|
127
|
+
CLAUDE_AUTH_LOGIN_ARGS,
|
|
128
|
+
ctx.noOpen && prompt
|
|
129
|
+
? { relay: { write: ctx.write, askCode: () => prompt(PASTE_QUESTION) } }
|
|
130
|
+
: { inherit: true },
|
|
131
|
+
);
|
|
105
132
|
if (login.error) throw authError({ state: login.error.code === 'ENOENT' ? 'missing' : 'error', executable, message: login.error.message });
|
|
106
133
|
if (login.code !== 0) {
|
|
107
134
|
throw new MoxxyError({
|
|
@@ -171,19 +198,35 @@ function authError(status: ClaudeCliAuthStatus): MoxxyError {
|
|
|
171
198
|
async function runCommand(
|
|
172
199
|
executable: string,
|
|
173
200
|
args: readonly string[],
|
|
174
|
-
options:
|
|
201
|
+
options: CommandOptions = {},
|
|
175
202
|
): Promise<ClaudeCommandResult> {
|
|
203
|
+
const { relay } = options;
|
|
176
204
|
return await new Promise((resolve) => {
|
|
177
205
|
const spawnOptions: SpawnOptions = options.inherit
|
|
178
206
|
? { stdio: 'inherit' }
|
|
179
|
-
: { stdio: ['ignore', 'pipe', 'pipe'] };
|
|
207
|
+
: { stdio: [relay ? 'pipe' : 'ignore', 'pipe', 'pipe'] };
|
|
180
208
|
const child = spawn(executable, [...args], spawnOptions);
|
|
181
209
|
let stdout = '';
|
|
182
210
|
let stderr = '';
|
|
211
|
+
let askedForCode = false;
|
|
212
|
+
// The CLI may exit (browser callback) before the pasted code arrives.
|
|
213
|
+
child.stdin?.on('error', () => {});
|
|
183
214
|
child.stdout?.setEncoding('utf8');
|
|
184
215
|
child.stderr?.setEncoding('utf8');
|
|
185
|
-
child.stdout?.on('data', (chunk: string) => {
|
|
186
|
-
|
|
216
|
+
child.stdout?.on('data', (chunk: string) => {
|
|
217
|
+
stdout += chunk;
|
|
218
|
+
if (!relay) return;
|
|
219
|
+
relay.write(chunk);
|
|
220
|
+
if (askedForCode || !PASTE_PROMPT.test(stdout)) return;
|
|
221
|
+
askedForCode = true;
|
|
222
|
+
void relay.askCode().then((code) => {
|
|
223
|
+
if (code.trim() && child.stdin?.writable) child.stdin.write(`${code.trim()}\n`);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
child.stderr?.on('data', (chunk: string) => {
|
|
227
|
+
stderr += chunk;
|
|
228
|
+
relay?.write(chunk);
|
|
229
|
+
});
|
|
187
230
|
child.once('error', (error: NodeJS.ErrnoException) => resolve({ code: 1, stdout, stderr, error }));
|
|
188
231
|
child.once('close', (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
189
232
|
});
|
package/src/process.test.ts
CHANGED
package/src/provider.test.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { PassThrough } from 'node:stream';
|
|
4
|
-
import { chmod, mkdtemp, readFile, realpath,
|
|
4
|
+
import { chmod, mkdtemp, readFile, realpath, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { tmpdir } from 'node:os';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { afterEach, describe, expect, it } from 'vitest';
|
|
8
|
+
import { posixShell } from '@moxxy/vitest-preset/platform';
|
|
8
9
|
import { z } from 'zod';
|
|
9
10
|
import type { ProviderEvent, ProviderRequest } from '@moxxy/sdk';
|
|
10
11
|
import {
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
createClaudeCodeClient,
|
|
15
16
|
__setClaudeCommandRunner,
|
|
16
17
|
} from './index.js';
|
|
18
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
17
19
|
|
|
18
20
|
class ControlledProviderChild extends EventEmitter {
|
|
19
21
|
readonly stdin = new PassThrough();
|
|
@@ -37,7 +39,7 @@ class ControlledProviderChild extends EventEmitter {
|
|
|
37
39
|
|
|
38
40
|
const tempDirs: string[] = [];
|
|
39
41
|
afterEach(async () => {
|
|
40
|
-
await Promise.all(tempDirs.splice(0).map((dir) =>
|
|
42
|
+
await Promise.all(tempDirs.splice(0).map((dir) => removeDir(dir)));
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
describe('claude-code provider definition', () => {
|
|
@@ -54,13 +56,13 @@ describe('claude-code provider definition', () => {
|
|
|
54
56
|
it('registers the exact Claude Code catalog and its native web-search capability', () => {
|
|
55
57
|
expect(claudeCodeProviderDef.name).toBe('claude-code');
|
|
56
58
|
expect(claudeCodeProviderDef.auth?.kind).toBe('oauth');
|
|
57
|
-
expect(CLAUDE_CODE_DEFAULT_MODEL).toBe('claude-sonnet-5');
|
|
59
|
+
expect(CLAUDE_CODE_DEFAULT_MODEL).toBe('claude-sonnet-5-5');
|
|
58
60
|
expect(claudeCodeProviderDef.models).toBe(claudeCodeModels);
|
|
59
|
-
expect(claudeCodeProviderDef.models.map((model) => model.id)).toEqual([
|
|
60
|
-
'claude-fable-5',
|
|
61
|
-
'claude-opus-5',
|
|
62
|
-
'claude-sonnet-5',
|
|
63
|
-
'claude-haiku-4-5',
|
|
61
|
+
expect(claudeCodeProviderDef.models.map((model) => [model.id, model.contextWindow, model.maxOutputTokens])).toEqual([
|
|
62
|
+
['claude-fable-5-1', 1_000_000, 128_000],
|
|
63
|
+
['claude-opus-5-5', 1_000_000, 128_000],
|
|
64
|
+
['claude-sonnet-5-5', 1_000_000, 128_000],
|
|
65
|
+
['claude-haiku-4-5', 200_000, 64_000],
|
|
64
66
|
]);
|
|
65
67
|
for (const model of claudeCodeProviderDef.models) {
|
|
66
68
|
expect(model).toMatchObject({
|
|
@@ -75,7 +77,7 @@ describe('claude-code provider definition', () => {
|
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
79
|
|
|
78
|
-
it('streams text through a fake Claude executable with structured non-interactive arguments', async () => {
|
|
80
|
+
it.skipIf(!posixShell)('streams text through a fake Claude executable with structured non-interactive arguments', async () => {
|
|
79
81
|
const dir = await makeFakeClaude([
|
|
80
82
|
{ type: 'system', subtype: 'init' },
|
|
81
83
|
{ type: 'rate_limit_event', rate_limit_info: { status: 'allowed' } },
|
|
@@ -92,7 +94,7 @@ describe('claude-code provider definition', () => {
|
|
|
92
94
|
const events = await collect(client.stream(textRequest()));
|
|
93
95
|
|
|
94
96
|
expect(events).toEqual([
|
|
95
|
-
{ type: 'message_start', model: 'claude-sonnet-5' },
|
|
97
|
+
{ type: 'message_start', model: 'claude-sonnet-5-5' },
|
|
96
98
|
{ type: 'text_delta', delta: 'Hello ' },
|
|
97
99
|
{ type: 'text_delta', delta: 'world' },
|
|
98
100
|
{ type: 'message_end', stopReason: 'end_turn', usage: { inputTokens: 8, outputTokens: 2 } },
|
|
@@ -110,7 +112,7 @@ describe('claude-code provider definition', () => {
|
|
|
110
112
|
expect(input).not.toContain('oauth-secret');
|
|
111
113
|
});
|
|
112
114
|
|
|
113
|
-
it('can disable native WebSearch without enabling any other Claude tools', async () => {
|
|
115
|
+
it.skipIf(!posixShell)('can disable native WebSearch without enabling any other Claude tools', async () => {
|
|
114
116
|
const dir = await makeFakeClaude([
|
|
115
117
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
116
118
|
]);
|
|
@@ -125,7 +127,7 @@ describe('claude-code provider definition', () => {
|
|
|
125
127
|
expect(args).not.toContain('--allowedTools');
|
|
126
128
|
});
|
|
127
129
|
|
|
128
|
-
it('consumes streamed thinking blocks without exposing their deltas', async () => {
|
|
130
|
+
it.skipIf(!posixShell)('consumes streamed thinking blocks without exposing their deltas', async () => {
|
|
129
131
|
const dir = await makeFakeClaude([
|
|
130
132
|
{ type: 'stream_event', event: { type: 'message_start', message: {} } },
|
|
131
133
|
{ type: 'stream_event', event: { type: 'content_block_start', content_block: { type: 'thinking', thinking: '' } } },
|
|
@@ -140,7 +142,7 @@ describe('claude-code provider definition', () => {
|
|
|
140
142
|
const events = await collect(createClaudeCodeClient({ executable: join(dir, 'claude') }).stream(textRequest()));
|
|
141
143
|
|
|
142
144
|
expect(events).toEqual([
|
|
143
|
-
{ type: 'message_start', model: 'claude-sonnet-5' },
|
|
145
|
+
{ type: 'message_start', model: 'claude-sonnet-5-5' },
|
|
144
146
|
{ type: 'text_delta', delta: 'Visible answer' },
|
|
145
147
|
{ type: 'message_end', stopReason: 'end_turn', usage: { inputTokens: 3, outputTokens: 2 } },
|
|
146
148
|
]);
|
|
@@ -148,7 +150,7 @@ describe('claude-code provider definition', () => {
|
|
|
148
150
|
expect(JSON.stringify(events)).not.toContain('private-signature');
|
|
149
151
|
});
|
|
150
152
|
|
|
151
|
-
it('accepts complete assistant records containing thinking blocks without exposing them', async () => {
|
|
153
|
+
it.skipIf(!posixShell)('accepts complete assistant records containing thinking blocks without exposing them', async () => {
|
|
152
154
|
const dir = await makeFakeClaude([
|
|
153
155
|
{ type: 'assistant', message: { content: [
|
|
154
156
|
{ type: 'thinking', thinking: 'private chain of thought', signature: 'private-signature' },
|
|
@@ -159,14 +161,14 @@ describe('claude-code provider definition', () => {
|
|
|
159
161
|
const events = await collect(createClaudeCodeClient({ executable: join(dir, 'claude') }).stream(textRequest()));
|
|
160
162
|
|
|
161
163
|
expect(events).toEqual([
|
|
162
|
-
{ type: 'message_start', model: 'claude-sonnet-5' },
|
|
164
|
+
{ type: 'message_start', model: 'claude-sonnet-5-5' },
|
|
163
165
|
{ type: 'message_end', stopReason: 'end_turn', usage: { inputTokens: 3, outputTokens: 2 } },
|
|
164
166
|
]);
|
|
165
167
|
expect(JSON.stringify(events)).not.toContain('private chain of thought');
|
|
166
168
|
expect(JSON.stringify(events)).not.toContain('private-signature');
|
|
167
169
|
});
|
|
168
170
|
|
|
169
|
-
it('reconstructs two turns for each stateless CLI invocation without a session id', async () => {
|
|
171
|
+
it.skipIf(!posixShell)('reconstructs two turns for each stateless CLI invocation without a session id', async () => {
|
|
170
172
|
const dir = await makeFakeClaude([
|
|
171
173
|
{ type: 'stream_event', event: { type: 'content_block_start', content_block: { type: 'text', text: '' } } },
|
|
172
174
|
{ type: 'stream_event', event: { type: 'content_block_delta', delta: { type: 'text_delta', text: 'first answer' } } },
|
|
@@ -196,7 +198,7 @@ describe('claude-code provider definition', () => {
|
|
|
196
198
|
expect(args.some((arg) => /session|resume/i.test(arg))).toBe(false);
|
|
197
199
|
});
|
|
198
200
|
|
|
199
|
-
it('projects prior moxxy tools and unsafe content deterministically as inert text', async () => {
|
|
201
|
+
it.skipIf(!posixShell)('projects prior moxxy tools and unsafe content deterministically as inert text', async () => {
|
|
200
202
|
const dir = await makeFakeClaude([
|
|
201
203
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
202
204
|
]);
|
|
@@ -236,7 +238,7 @@ describe('claude-code provider definition', () => {
|
|
|
236
238
|
expect(first).not.toContain(rawBase64);
|
|
237
239
|
});
|
|
238
240
|
|
|
239
|
-
it('runs native tools in the configured workspace without emitting dispatcher tool events', async () => {
|
|
241
|
+
it.skipIf(!posixShell)('runs native tools in the configured workspace without emitting dispatcher tool events', async () => {
|
|
240
242
|
const workspace = await mkdtemp(join(tmpdir(), 'moxxy-claude-workspace-'));
|
|
241
243
|
tempDirs.push(workspace);
|
|
242
244
|
const dir = await makeFakeClaude([
|
|
@@ -271,7 +273,7 @@ describe('claude-code provider definition', () => {
|
|
|
271
273
|
expect(args).not.toEqual(expect.arrayContaining(['--tools', '']));
|
|
272
274
|
});
|
|
273
275
|
|
|
274
|
-
it('leaves the safe permission default to Claude and uses a valid no-tools invocation for an empty native allow-list', async () => {
|
|
276
|
+
it.skipIf(!posixShell)('leaves the safe permission default to Claude and uses a valid no-tools invocation for an empty native allow-list', async () => {
|
|
275
277
|
const dir = await makeFakeClaude([
|
|
276
278
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
277
279
|
]);
|
|
@@ -288,7 +290,7 @@ describe('claude-code provider definition', () => {
|
|
|
288
290
|
expect(args).not.toContain('bypassPermissions');
|
|
289
291
|
});
|
|
290
292
|
|
|
291
|
-
it.each(['claude-fable-5', 'claude-opus-5'])('passes the selected %s model as an exact structured argument', async (model) => {
|
|
293
|
+
it.skipIf(!posixShell).each(['claude-fable-5-1', 'claude-opus-5-5'])('passes the selected %s model as an exact structured argument', async (model) => {
|
|
292
294
|
const dir = await makeFakeClaude([
|
|
293
295
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
294
296
|
]);
|
|
@@ -300,18 +302,18 @@ describe('claude-code provider definition', () => {
|
|
|
300
302
|
expect(args.filter((arg) => arg === '--model')).toHaveLength(1);
|
|
301
303
|
});
|
|
302
304
|
|
|
303
|
-
it('uses the persisted provider-item model as its default selection', async () => {
|
|
305
|
+
it.skipIf(!posixShell)('uses the persisted provider-item model as its default selection', async () => {
|
|
304
306
|
const dir = await makeFakeClaude([
|
|
305
307
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
306
308
|
]);
|
|
307
|
-
const client = claudeCodeProviderDef.createClient({ model: 'claude-fable-5', executable: join(dir, 'claude') });
|
|
309
|
+
const client = claudeCodeProviderDef.createClient({ model: 'claude-fable-5-1', executable: join(dir, 'claude') });
|
|
308
310
|
await collect(client.stream({ ...textRequest(), model: '' }));
|
|
309
311
|
|
|
310
312
|
const args = JSON.parse(await readFile(join(dir, 'args.json'), 'utf8')) as string[];
|
|
311
|
-
expect(args.slice(-2)).toEqual(['--model', 'claude-fable-5']);
|
|
313
|
+
expect(args.slice(-2)).toEqual(['--model', 'claude-fable-5-1']);
|
|
312
314
|
});
|
|
313
315
|
|
|
314
|
-
it('returns actionable errors for locally unsupported and CLI-rejected models', async () => {
|
|
316
|
+
it.skipIf(!posixShell)('returns actionable errors for locally unsupported and CLI-rejected models', async () => {
|
|
315
317
|
const supported = claudeCodeModels.map((model) => model.id);
|
|
316
318
|
const unsupported = await collect(createClaudeCodeClient({
|
|
317
319
|
spawn: () => { throw new Error('should not spawn'); },
|
|
@@ -328,17 +330,17 @@ describe('claude-code provider definition', () => {
|
|
|
328
330
|
]);
|
|
329
331
|
const rejected = await collect(createClaudeCodeClient({ executable: join(dir, 'claude') }).stream({
|
|
330
332
|
...textRequest(),
|
|
331
|
-
model: 'claude-fable-5',
|
|
333
|
+
model: 'claude-fable-5-1',
|
|
332
334
|
}));
|
|
333
335
|
expect(rejected[1]).toMatchObject({
|
|
334
336
|
type: 'error',
|
|
335
|
-
message: expect.stringMatching(/Claude Code rejected model "claude-fable-5".*Model is unavailable/),
|
|
337
|
+
message: expect.stringMatching(/Claude Code rejected model "claude-fable-5-1".*Model is unavailable/),
|
|
336
338
|
retryable: false,
|
|
337
339
|
});
|
|
338
340
|
for (const model of supported) expect((rejected[1] as { message: string }).message).toContain(model);
|
|
339
341
|
});
|
|
340
342
|
|
|
341
|
-
it.each([
|
|
343
|
+
it.skipIf(!posixShell).each([
|
|
342
344
|
['Not logged in. Authentication required', /signed out|authentication/i, false],
|
|
343
345
|
['Rate limit exceeded (429)', /service failure.*rate limit/i, true],
|
|
344
346
|
['Service temporarily unavailable', /service failure.*unavailable/i, true],
|
|
@@ -368,7 +370,7 @@ describe('claude-code provider definition', () => {
|
|
|
368
370
|
expect(child.kills).toEqual(['SIGTERM']);
|
|
369
371
|
});
|
|
370
372
|
|
|
371
|
-
it('reports a missing executable and an unexpected exit as actionable non-retryable errors', async () => {
|
|
373
|
+
it.skipIf(!posixShell)('reports a missing executable and an unexpected exit as actionable non-retryable errors', async () => {
|
|
372
374
|
const missing = Object.assign(new Error('spawn claude ENOENT'), { code: 'ENOENT' });
|
|
373
375
|
const missingEvents = await collect(createClaudeCodeClient({
|
|
374
376
|
executable: '/missing/claude',
|
|
@@ -390,7 +392,7 @@ describe('claude-code provider definition', () => {
|
|
|
390
392
|
expect(exitEvents.filter((event) => event.type === 'error')).toHaveLength(1);
|
|
391
393
|
});
|
|
392
394
|
|
|
393
|
-
it('surfaces a permission denial as a clear non-retryable error', async () => {
|
|
395
|
+
it.skipIf(!posixShell)('surfaces a permission denial as a clear non-retryable error', async () => {
|
|
394
396
|
const dir = await makeFakeClaude([
|
|
395
397
|
{ type: 'result', subtype: 'error_during_execution', is_error: true, result: 'Permission denied for Edit' },
|
|
396
398
|
]);
|
|
@@ -430,7 +432,7 @@ describe('claude-code provider definition', () => {
|
|
|
430
432
|
}
|
|
431
433
|
});
|
|
432
434
|
|
|
433
|
-
it('orders the identity, message-derived system text, and extra system text', async () => {
|
|
435
|
+
it.skipIf(!posixShell)('orders the identity, message-derived system text, and extra system text', async () => {
|
|
434
436
|
const dir = await makeFakeClaude([
|
|
435
437
|
{ type: 'result', subtype: 'success', is_error: false, usage: { input_tokens: 1, output_tokens: 1 } },
|
|
436
438
|
]);
|
|
@@ -449,7 +451,7 @@ describe('claude-code provider definition', () => {
|
|
|
449
451
|
expect(input.indexOf('message system')).toBeLessThan(input.indexOf('system instructions'));
|
|
450
452
|
});
|
|
451
453
|
|
|
452
|
-
it('turns a streamed moxxy tool-call block into tool_use events and stops at it', async () => {
|
|
454
|
+
it.skipIf(!posixShell)('turns a streamed moxxy tool-call block into tool_use events and stops at it', async () => {
|
|
453
455
|
const delta = (text: string) => ({
|
|
454
456
|
type: 'stream_event',
|
|
455
457
|
event: { type: 'content_block_delta', delta: { type: 'text_delta', text } },
|
|
@@ -483,7 +485,7 @@ describe('claude-code provider definition', () => {
|
|
|
483
485
|
expect(ids).toHaveLength(2);
|
|
484
486
|
expect(new Set(ids).size).toBe(2);
|
|
485
487
|
expect(events).toEqual([
|
|
486
|
-
{ type: 'message_start', model: 'claude-sonnet-5' },
|
|
488
|
+
{ type: 'message_start', model: 'claude-sonnet-5-5' },
|
|
487
489
|
{ type: 'text_delta', delta: "I'll read it.\n" },
|
|
488
490
|
{ type: 'tool_use_start', id: ids[0], name: 'Read' },
|
|
489
491
|
{ type: 'tool_use_end', id: ids[0], input: { file_path: 'x.yaml' } },
|
|
@@ -503,7 +505,7 @@ describe('claude-code provider definition', () => {
|
|
|
503
505
|
expect(args).not.toContain('Read');
|
|
504
506
|
});
|
|
505
507
|
|
|
506
|
-
it('continues past an internal CLI tool round trip to the moxxy tool-call block', async () => {
|
|
508
|
+
it.skipIf(!posixShell)('continues past an internal CLI tool round trip to the moxxy tool-call block', async () => {
|
|
507
509
|
// Shape captured from the live CLI: the model first tries a native Read,
|
|
508
510
|
// the CLI rejects it, then the model uses the moxxy protocol.
|
|
509
511
|
const dir = await makeFakeClaude([
|
|
@@ -527,7 +529,7 @@ describe('claude-code provider definition', () => {
|
|
|
527
529
|
expect(events.at(-1)).toEqual({ type: 'message_end', stopReason: 'tool_use' });
|
|
528
530
|
});
|
|
529
531
|
|
|
530
|
-
it('keeps call-shaped text as plain output when no tools were offered or the block never closes', async () => {
|
|
532
|
+
it.skipIf(!posixShell)('keeps call-shaped text as plain output when no tools were offered or the block never closes', async () => {
|
|
531
533
|
const records = [
|
|
532
534
|
{ type: 'stream_event', event: { type: 'content_block_start', content_block: { type: 'text', text: '' } } },
|
|
533
535
|
{ type: 'stream_event', event: { type: 'content_block_delta', delta: { type: 'text_delta', text: 'a <moxxy_tool_calls><call name="Read">{}' } } },
|
|
@@ -602,7 +604,7 @@ describe('claude-code provider definition', () => {
|
|
|
602
604
|
|
|
603
605
|
function textRequest(): ProviderRequest {
|
|
604
606
|
return {
|
|
605
|
-
model: 'claude-sonnet-5',
|
|
607
|
+
model: 'claude-sonnet-5-5',
|
|
606
608
|
system: 'system instructions',
|
|
607
609
|
messages: [
|
|
608
610
|
{ role: 'user', content: [{ type: 'text', text: 'prior user' }] },
|
package/src/provider.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CLAUDE_CODE_PROVIDER_ID } from './constants.js';
|
|
|
4
4
|
import { ClaudeProcessError, runClaudeProcess, type ClaudeSpawn } from './process.js';
|
|
5
5
|
import { createProtocolState, parseClaudeRecord, serializeClaudePrompt } from './protocol.js';
|
|
6
6
|
|
|
7
|
-
export const CLAUDE_CODE_DEFAULT_MODEL = 'claude-sonnet-5';
|
|
7
|
+
export const CLAUDE_CODE_DEFAULT_MODEL = 'claude-sonnet-5-5';
|
|
8
8
|
const NON_TEXT_BLOCK_TOKENS = 256;
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -27,8 +27,8 @@ const textOnlyCapabilities = {
|
|
|
27
27
|
} as const;
|
|
28
28
|
|
|
29
29
|
export const claudeCodeModels: ReadonlyArray<ModelDescriptor> = [
|
|
30
|
-
{ id: 'claude-fable-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
31
|
-
{ id: 'claude-opus-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
30
|
+
{ id: 'claude-fable-5-1', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
31
|
+
{ id: 'claude-opus-5-5', contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
32
32
|
{ id: CLAUDE_CODE_DEFAULT_MODEL, contextWindow: 1_000_000, maxOutputTokens: 128_000, ...textOnlyCapabilities },
|
|
33
33
|
{ id: 'claude-haiku-4-5', contextWindow: 200_000, maxOutputTokens: 64_000, ...textOnlyCapabilities },
|
|
34
34
|
];
|