@blockrun/cc 0.7.0 → 0.7.2
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/commands/start.d.ts +1 -0
- package/dist/commands/start.js +2 -2
- package/dist/index.js +1 -0
- package/dist/proxy/server.d.ts +1 -0
- package/dist/proxy/server.js +13 -9
- package/package.json +1 -1
package/dist/commands/start.d.ts
CHANGED
package/dist/commands/start.js
CHANGED
|
@@ -25,7 +25,7 @@ export async function startCommand(options) {
|
|
|
25
25
|
console.log(`Model: ${chalk.green(model)}`);
|
|
26
26
|
console.log(`Proxy: ${chalk.cyan(`http://localhost:${port}`)}`);
|
|
27
27
|
console.log(`Backend: ${chalk.dim(apiUrl)}\n`);
|
|
28
|
-
const server = createProxy({ port, apiUrl, chain: 'solana', modelOverride: model });
|
|
28
|
+
const server = createProxy({ port, apiUrl, chain: 'solana', modelOverride: model, debug: options.debug });
|
|
29
29
|
launchServer(server, port, shouldLaunch, model);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
@@ -46,7 +46,7 @@ export async function startCommand(options) {
|
|
|
46
46
|
console.log(`Model: ${chalk.green(model)}`);
|
|
47
47
|
console.log(`Proxy: ${chalk.cyan(`http://localhost:${port}`)}`);
|
|
48
48
|
console.log(`Backend: ${chalk.dim(apiUrl)}\n`);
|
|
49
|
-
const server = createProxy({ port, apiUrl, chain: 'base', modelOverride: model });
|
|
49
|
+
const server = createProxy({ port, apiUrl, chain: 'base', modelOverride: model, debug: options.debug });
|
|
50
50
|
launchServer(server, port, shouldLaunch, model);
|
|
51
51
|
}
|
|
52
52
|
}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ program
|
|
|
21
21
|
.option('-p, --port <port>', 'Proxy port', '8402')
|
|
22
22
|
.option('-m, --model <model>', 'Default model (e.g. openai/gpt-5.4, anthropic/claude-sonnet-4.6)')
|
|
23
23
|
.option('--no-launch', 'Start proxy only, do not launch Claude Code')
|
|
24
|
+
.option('--debug', 'Enable debug logging')
|
|
24
25
|
.action(startCommand);
|
|
25
26
|
program
|
|
26
27
|
.command('models')
|
package/dist/proxy/server.d.ts
CHANGED
package/dist/proxy/server.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
3
|
+
function debug(options, ...args) {
|
|
4
|
+
if (options.debug)
|
|
5
|
+
console.error('[brcc]', ...args);
|
|
6
|
+
}
|
|
3
7
|
const DEFAULT_MAX_TOKENS = 4096;
|
|
4
8
|
let lastOutputTokens = 0;
|
|
5
9
|
export function createProxy(options) {
|
|
@@ -41,14 +45,14 @@ export function createProxy(options) {
|
|
|
41
45
|
const original = parsed.max_tokens;
|
|
42
46
|
const model = (parsed.model || '').toLowerCase();
|
|
43
47
|
const modelCap = (model.includes('deepseek') || model.includes('haiku') || model.includes('gpt-oss')) ? 8192 : 16384;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Use max of (last output × 2, default 4096) capped by model limit
|
|
49
|
+
// This ensures short replies don't starve the next request
|
|
50
|
+
const adaptive = lastOutputTokens > 0
|
|
51
|
+
? Math.max(lastOutputTokens * 2, DEFAULT_MAX_TOKENS)
|
|
52
|
+
: DEFAULT_MAX_TOKENS;
|
|
53
|
+
parsed.max_tokens = Math.min(adaptive, modelCap);
|
|
50
54
|
if (original !== parsed.max_tokens) {
|
|
51
|
-
|
|
55
|
+
debug(options, `max_tokens: ${original} → ${parsed.max_tokens} (last output: ${lastOutputTokens || 'none'})`);
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
body = JSON.stringify(parsed);
|
|
@@ -96,7 +100,7 @@ export function createProxy(options) {
|
|
|
96
100
|
const match = lastChunkText.match(/"output_tokens"\s*:\s*(\d+)/);
|
|
97
101
|
if (match) {
|
|
98
102
|
lastOutputTokens = parseInt(match[1], 10);
|
|
99
|
-
|
|
103
|
+
debug(options, `recorded output_tokens: ${lastOutputTokens} (stream)`);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
res.end();
|
|
@@ -116,7 +120,7 @@ export function createProxy(options) {
|
|
|
116
120
|
const parsed = JSON.parse(text);
|
|
117
121
|
if (parsed.usage?.output_tokens) {
|
|
118
122
|
lastOutputTokens = parsed.usage.output_tokens;
|
|
119
|
-
|
|
123
|
+
debug(options, `recorded output_tokens: ${lastOutputTokens}`);
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
catch { /* not JSON */ }
|