@askalf/dario 2.10.0 → 2.11.0

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.
Files changed (2) hide show
  1. package/dist/proxy.js +40 -1
  2. package/package.json +1 -1
package/dist/proxy.js CHANGED
@@ -329,6 +329,34 @@ function rewriteToolNames(body) {
329
329
  tool.name = mcpName;
330
330
  }
331
331
  }
332
+ // Cap tool count — CC sends max ~22 tools. Excess tools get consolidated
333
+ // into a single MCPCallTool dispatch with routing table.
334
+ const MAX_TOOLS = 22;
335
+ if (tools.length > MAX_TOOLS) {
336
+ const keep = tools.slice(0, MAX_TOOLS - 1); // keep first N-1
337
+ const overflow = tools.slice(MAX_TOOLS - 1);
338
+ // Build dispatch tool that wraps all overflow tools
339
+ const dispatchDesc = overflow.map((t) => `${t.name}: ${(t.description || '').slice(0, 50)}`).join('\n');
340
+ const dispatchTool = {
341
+ name: 'mcp_dispatch',
342
+ description: `Route to one of these tools:\n${dispatchDesc}`,
343
+ input_schema: {
344
+ type: 'object',
345
+ properties: {
346
+ tool_name: { type: 'string', description: 'Which tool to call', enum: overflow.map((t) => t.name) },
347
+ input: { type: 'object', description: 'Arguments to pass to the tool' },
348
+ },
349
+ required: ['tool_name', 'input'],
350
+ },
351
+ };
352
+ // Track overflow mappings for reverse
353
+ for (const t of overflow) {
354
+ mappings.push({ original: t.name, mapped: 'mcp_dispatch' });
355
+ }
356
+ // Replace tools array
357
+ keep.push(dispatchTool);
358
+ body.tools = keep;
359
+ }
332
360
  return mappings;
333
361
  }
334
362
  /**
@@ -845,7 +873,18 @@ export async function startProxy(opts = {}) {
845
873
  // context_management: clear_thinking does NOT reduce input token billing.
846
874
  // Real Claude Code strips thinking before building the next request.
847
875
  stripThinkingFromHistory(r);
848
- // 2. Rewrite tool names to CC equivalents (Anthropic fingerprints on tool names)
876
+ // 2. Strip client cache_control from messages (prevents overflow max 4 breakpoints)
877
+ const msgs = r.messages;
878
+ if (msgs) {
879
+ for (const msg of msgs) {
880
+ if (Array.isArray(msg.content)) {
881
+ for (const block of msg.content) {
882
+ delete block.cache_control;
883
+ }
884
+ }
885
+ }
886
+ }
887
+ // 3. Rewrite tool names to CC equivalents (Anthropic fingerprints on tool names)
849
888
  toolMappings = rewriteToolNames(r);
850
889
  // 3. Scrub non-CC fields and normalize field ordering
851
890
  const reordered = scrubAndReorderFields(r);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
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": {