@askalf/dario 1.0.8 → 1.0.9

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/cli.js CHANGED
@@ -132,7 +132,9 @@ async function proxy() {
132
132
  process.exit(1);
133
133
  }
134
134
  const verbose = args.includes('--verbose') || args.includes('-v');
135
- await startProxy({ port, verbose });
135
+ const modelArg = args.find(a => a.startsWith('--model='));
136
+ const model = modelArg ? modelArg.split('=')[1] : undefined;
137
+ await startProxy({ port, verbose, model });
136
138
  }
137
139
  async function help() {
138
140
  console.log(`
@@ -146,6 +148,9 @@ async function help() {
146
148
  dario logout Remove saved credentials
147
149
 
148
150
  Proxy options:
151
+ --model=MODEL Force a model for all requests
152
+ Shortcuts: opus, sonnet, haiku
153
+ Default: passthrough (client decides)
149
154
  --port=PORT Port to listen on (default: 3456)
150
155
  --verbose, -v Log all requests
151
156
 
package/dist/proxy.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  interface ProxyOptions {
11
11
  port?: number;
12
12
  verbose?: boolean;
13
+ model?: string;
13
14
  }
14
15
  export declare function startProxy(opts?: ProxyOptions): Promise<void>;
15
16
  export {};
package/dist/proxy.js CHANGED
@@ -49,6 +49,12 @@ function detectSdkVersion() {
49
49
  return '0.81.0';
50
50
  }
51
51
  }
52
+ // Model shortcuts — users can pass short names
53
+ const MODEL_ALIASES = {
54
+ 'opus': 'claude-opus-4-6',
55
+ 'sonnet': 'claude-sonnet-4-6',
56
+ 'haiku': 'claude-haiku-4-5',
57
+ };
52
58
  function sanitizeError(err) {
53
59
  const msg = err instanceof Error ? err.message : String(err);
54
60
  // Never leak tokens in error messages
@@ -65,6 +71,7 @@ export async function startProxy(opts = {}) {
65
71
  }
66
72
  const cliVersion = detectClaudeVersion();
67
73
  const sdkVersion = detectSdkVersion();
74
+ const modelOverride = opts.model ? (MODEL_ALIASES[opts.model] ?? opts.model) : null;
68
75
  let requestCount = 0;
69
76
  let tokenCostEstimate = 0;
70
77
  const server = createServer(async (req, res) => {
@@ -134,8 +141,19 @@ export async function startProxy(opts = {}) {
134
141
  chunks.push(buf);
135
142
  }
136
143
  const body = Buffer.concat(chunks);
144
+ // Override model in request body if --model flag was set
145
+ let finalBody = body.length > 0 ? body : undefined;
146
+ if (modelOverride && body.length > 0) {
147
+ try {
148
+ const parsed = JSON.parse(body.toString());
149
+ parsed.model = modelOverride;
150
+ finalBody = Buffer.from(JSON.stringify(parsed));
151
+ }
152
+ catch { /* not JSON, send as-is */ }
153
+ }
137
154
  if (verbose) {
138
- console.log(`[dario] #${requestCount} ${req.method} ${req.url}`);
155
+ const modelInfo = modelOverride ? ` (model: ${modelOverride})` : '';
156
+ console.log(`[dario] #${requestCount} ${req.method} ${req.url}${modelInfo}`);
139
157
  }
140
158
  // Build target URL from allowlist (no user input in URL construction)
141
159
  const targetUrl = targetBase;
@@ -177,10 +195,8 @@ export async function startProxy(opts = {}) {
177
195
  const upstream = await fetch(targetUrl, {
178
196
  method: req.method ?? 'POST',
179
197
  headers,
180
- body: body.length > 0 ? body : undefined,
198
+ body: finalBody ? new Uint8Array(finalBody) : undefined,
181
199
  signal: AbortSignal.timeout(UPSTREAM_TIMEOUT_MS),
182
- // @ts-expect-error — duplex needed for streaming
183
- duplex: 'half',
184
200
  });
185
201
  // Detect streaming from content-type (reliable) or body (fallback)
186
202
  const contentType = upstream.headers.get('content-type') ?? '';
@@ -251,6 +267,7 @@ export async function startProxy(opts = {}) {
251
267
  });
252
268
  server.listen(port, LOCALHOST, () => {
253
269
  const oauthLine = `OAuth: ${status.status} (expires in ${status.expiresIn})`;
270
+ const modelLine = modelOverride ? `Model: ${modelOverride} (all requests)` : 'Model: passthrough (client decides)';
254
271
  console.log('');
255
272
  console.log(` dario — http://localhost:${port}`);
256
273
  console.log('');
@@ -261,6 +278,7 @@ export async function startProxy(opts = {}) {
261
278
  console.log(' ANTHROPIC_API_KEY=dario');
262
279
  console.log('');
263
280
  console.log(` ${oauthLine}`);
281
+ console.log(` ${modelLine}`);
264
282
  console.log('');
265
283
  });
266
284
  // Periodic token refresh (every 15 minutes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Use your Claude subscription as an API. Two commands, no API key. OAuth bridge for Claude Max/Pro.",
5
5
  "type": "module",
6
6
  "bin": {