@askalf/dario 3.0.2 → 3.0.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.
@@ -309,6 +309,8 @@ export function buildCCRequest(clientBody, billingTag, agentIdentity, cache1h, i
309
309
  systemText = systemText.replace(pattern, '');
310
310
  }
311
311
  // ── Build the CC request from template ──
312
+ // Key order matches CC v2.1.104 MITM capture exactly:
313
+ // model, messages, system, tools, metadata, max_tokens, thinking, context_management, output_config, stream
312
314
  const ccRequest = {
313
315
  model,
314
316
  messages,
@@ -317,17 +319,12 @@ export function buildCCRequest(clientBody, billingTag, agentIdentity, cache1h, i
317
319
  { type: 'text', text: agentIdentity, cache_control: cache1h },
318
320
  { type: 'text', text: systemText || 'You are a helpful assistant.', cache_control: cache1h },
319
321
  ],
320
- max_tokens: 64000,
321
322
  };
322
- // Model-specific fields (matches CC v2.1.104 exactly)
323
- if (!isHaiku) {
324
- ccRequest.thinking = { type: 'adaptive' };
325
- ccRequest.output_config = { effort: 'medium' };
326
- ccRequest.context_management = { edits: [{ type: 'clear_thinking_20251015', keep: 'all' }] };
327
- // CC sends temperature:1 explicitly when not in thinking-only mode
328
- ccRequest.temperature = 1;
323
+ // Tools come before metadata in CC's key order
324
+ if (clientTools && clientTools.length > 0) {
325
+ ccRequest.tools = CC_TOOL_DEFINITIONS;
329
326
  }
330
- // Always include metadata
327
+ // Metadata
331
328
  ccRequest.metadata = {
332
329
  user_id: JSON.stringify({
333
330
  device_id: identity.deviceId,
@@ -335,11 +332,14 @@ export function buildCCRequest(clientBody, billingTag, agentIdentity, cache1h, i
335
332
  session_id: identity.sessionId,
336
333
  }),
337
334
  };
338
- ccRequest.stream = stream;
339
- // Use CC's exact tool definitions not the client's
340
- if (clientTools && clientTools.length > 0) {
341
- ccRequest.tools = CC_TOOL_DEFINITIONS;
335
+ ccRequest.max_tokens = 64000;
336
+ // Model-specific fields order: thinking, context_management, output_config
337
+ if (!isHaiku) {
338
+ ccRequest.thinking = { type: 'adaptive' };
339
+ ccRequest.context_management = { edits: [{ type: 'clear_thinking_20251015', keep: 'all' }] };
340
+ ccRequest.output_config = { effort: 'medium' };
342
341
  }
342
+ ccRequest.stream = stream;
343
343
  return { body: ccRequest, toolMap: activeToolMap, unmappedTools };
344
344
  }
345
345
  /**
package/dist/proxy.js CHANGED
@@ -725,8 +725,10 @@ export async function startProxy(opts = {}) {
725
725
  }
726
726
  else {
727
727
  // Claude-optimized: full beta set matching real Claude Code (exact order from MITM capture)
728
- // Beta set from CC v2.1.104 binary RE some are CC-internal/gated, only include publicly accepted ones
729
- beta = 'claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advisor-tool-2026-03-01,effort-2025-11-24,fast-mode-2026-02-01,redact-thinking-2026-02-12,context-1m-2025-08-07,web-search-2025-03-05,advanced-tool-use-2025-11-20,tool-search-tool-2025-10-19';
728
+ // Exact beta set from CC v2.1.104 MITM capture (exact order)
729
+ // Only 8 betas — CC sends more conditionally (fast-mode, web-search, etc.)
730
+ // but the base set for a standard request is exactly this
731
+ beta = 'claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advisor-tool-2026-03-01,effort-2025-11-24';
730
732
  if (clientBeta) {
731
733
  const baseSet = new Set(beta.split(','));
732
734
  const filtered = filterBillableBetas(clientBeta)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Use your Claude subscription as an API. No API key needed. Local proxy for Claude Max/Pro subscriptions.",
5
5
  "type": "module",
6
6
  "bin": {