@askalf/dario 4.8.144 → 4.8.145

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.
@@ -490,6 +490,17 @@ export declare const CC_CACHE_CONTROL: CacheControl;
490
490
  * Exported for unit testing.
491
491
  */
492
492
  export declare function applyCcPromptCaching(ccRequest: Record<string, unknown>, cacheControl: CacheControl): void;
493
+ /**
494
+ * Drop later tools whose exact name already appeared. Upstream rejects the
495
+ * whole request with 400 "tools: Tool names must be unique" on any repeat,
496
+ * so this is the last-line guard on the assembled advertise array — a
497
+ * polluted live template (see the mcp__ exclusion at the availableCC build)
498
+ * or a client double-declare degrades to first-wins instead of a hard
499
+ * request failure. Exported for tests.
500
+ */
501
+ export declare function dedupeToolsByName<T extends {
502
+ name?: unknown;
503
+ }>(tools: T[]): T[];
493
504
  export declare function buildCCRequest(clientBody: Record<string, unknown>, billingTag: string, cacheControl: CacheControl, identity: {
494
505
  deviceId: string;
495
506
  accountUuid: string;
@@ -1308,6 +1308,27 @@ export function applyCcPromptCaching(ccRequest, cacheControl) {
1308
1308
  }
1309
1309
  }
1310
1310
  }
1311
+ /**
1312
+ * Drop later tools whose exact name already appeared. Upstream rejects the
1313
+ * whole request with 400 "tools: Tool names must be unique" on any repeat,
1314
+ * so this is the last-line guard on the assembled advertise array — a
1315
+ * polluted live template (see the mcp__ exclusion at the availableCC build)
1316
+ * or a client double-declare degrades to first-wins instead of a hard
1317
+ * request failure. Exported for tests.
1318
+ */
1319
+ export function dedupeToolsByName(tools) {
1320
+ const seen = new Set();
1321
+ const out = [];
1322
+ for (const t of tools) {
1323
+ const name = typeof t.name === 'string' ? t.name : '';
1324
+ if (name && seen.has(name))
1325
+ continue;
1326
+ if (name)
1327
+ seen.add(name);
1328
+ out.push(t);
1329
+ }
1330
+ return out;
1331
+ }
1311
1332
  export function buildCCRequest(clientBody, billingTag, cacheControl, identity, opts = {}) {
1312
1333
  const model = clientBody.model || 'claude-sonnet-5';
1313
1334
  const isHaiku = model.toLowerCase().includes('haiku');
@@ -1648,10 +1669,20 @@ export function buildCCRequest(clientBody, billingTag, cacheControl, identity, o
1648
1669
  // declaration encodes the client's platform, so a win32 CC declaring
1649
1670
  // PowerShell/Glob/Grep gets their canonical defs even from a Linux-hosted
1650
1671
  // dario. The host filter only governs the no-declaration fallbacks.
1651
- const availableCC = CC_TOOL_DEFINITIONS_UNION.filter((t) => clientToolNames.has(t.name.toLowerCase()));
1672
+ //
1673
+ // mcp__* entries are EXCLUDED from the template side: a live capture on
1674
+ // a machine with MCP servers configured absorbs the capture session's
1675
+ // mcp__* tools into the template (the dario#678 reporter's doctor showed
1676
+ // 138 tool defs — ~111 of them MCP pollution), and any client-declared
1677
+ // MCP tool whose name also sat in the polluted union then went out
1678
+ // TWICE (template def + verbatim client schema) — upstream rejects the
1679
+ // whole request with 400 "tools: Tool names must be unique". MCP
1680
+ // schemas are operator-supplied; the client's declaration is the only
1681
+ // authoritative source, never the template.
1682
+ const availableCC = CC_TOOL_DEFINITIONS_UNION.filter((t) => !isMcpToolName(t.name) && clientToolNames.has(t.name.toLowerCase()));
1652
1683
  const mcpTools = clientTools.filter((t) => isMcpToolName(t.name));
1653
1684
  ccRequest.tools = availableCC.length > 0 || mcpTools.length > 0
1654
- ? [...availableCC, ...mcpTools]
1685
+ ? dedupeToolsByName([...availableCC, ...mcpTools])
1655
1686
  : CC_TOOL_DEFINITIONS;
1656
1687
  }
1657
1688
  }
@@ -550,9 +550,18 @@ export function extractTemplate(captured) {
550
550
  const systemPrompt = pickTextBlock(systemBlocks[2]);
551
551
  if (!agentIdentity || !systemPrompt)
552
552
  return null;
553
+ // mcp__* tools are EXCLUDED from the template: the capture spawns the
554
+ // operator's own CC, and on a machine with MCP servers configured the
555
+ // captured request declares their mcp__<server>__<tool> schemas — session
556
+ // config, not CC wire shape. Baking them poisoned CC_TOOL_DEFINITIONS_UNION
557
+ // and duplicated any client-declared MCP tool on the advertise path
558
+ // (template def + verbatim client schema), which upstream rejects with
559
+ // 400 "tools: Tool names must be unique" (dario#678 follow-up). Local
560
+ // startsWith mirror of cc-template's isMcpToolName — importing it here
561
+ // would cycle (cc-template imports loadTemplate from this module).
553
562
  const tools = Array.isArray(body.tools)
554
563
  ? body.tools
555
- .filter((t) => typeof t.name === 'string')
564
+ .filter((t) => typeof t.name === 'string' && !t.name.startsWith('mcp__'))
556
565
  .map((t) => ({
557
566
  name: t.name,
558
567
  description: t.description ?? '',
package/dist/proxy.d.ts CHANGED
@@ -64,8 +64,10 @@ export declare const CLAUDE_CODE_BETA = "claude-code-20250219";
64
64
  * it, ORDER included:
65
65
  *
66
66
  * opus-4-8 = base (unchanged)
67
- * sonnet-5 = base − {mid-conversation-system} (CC 2.1.201 dropped it
68
- * from sonnet; 2.1.199 sonnet == opus and still kept it — #667)
67
+ * sonnet-5 = base (== opus wire-drift
68
+ * live capture, CC 2.1.204: mid-conversation-system included)
69
+ * sonnet-4-x = base − {mid-conversation-system} (CC 2.1.201 dropped it
70
+ * from sonnet 4.6; 2.1.199 sonnet == opus and still kept it — #667)
69
71
  * haiku-4-5 = base − {mid-conversation-system, effort, afk-mode}, and
70
72
  * claude-code-20250219 MOVED to position 5 (before advisor-tool)
71
73
  * fable-5 = base + fallback-credit-2026-06-01 inserted BEFORE afk-mode
package/dist/proxy.js CHANGED
@@ -323,8 +323,10 @@ function moveBetaBefore(flags, flag, anchor) {
323
323
  * it, ORDER included:
324
324
  *
325
325
  * opus-4-8 = base (unchanged)
326
- * sonnet-5 = base − {mid-conversation-system} (CC 2.1.201 dropped it
327
- * from sonnet; 2.1.199 sonnet == opus and still kept it — #667)
326
+ * sonnet-5 = base (== opus wire-drift
327
+ * live capture, CC 2.1.204: mid-conversation-system included)
328
+ * sonnet-4-x = base − {mid-conversation-system} (CC 2.1.201 dropped it
329
+ * from sonnet 4.6; 2.1.199 sonnet == opus and still kept it — #667)
328
330
  * haiku-4-5 = base − {mid-conversation-system, effort, afk-mode}, and
329
331
  * claude-code-20250219 MOVED to position 5 (before advisor-tool)
330
332
  * fable-5 = base + fallback-credit-2026-06-01 inserted BEFORE afk-mode
@@ -353,9 +355,11 @@ export function betaForModel(base, model, skipContext1m = false) {
353
355
  flags = flags.filter((f) => !drop.has(f));
354
356
  flags = moveBetaBefore(flags, CLAUDE_CODE_BETA, ADVISOR_TOOL_BETA);
355
357
  }
356
- else if (m.includes('sonnet')) {
357
- // CC 2.1.201 dropped mid-conversation-system from sonnet's beta set (2.1.199
358
- // sonnet == opus and still carried it — live capture #667). opus + fable keep it.
358
+ else if (/sonnet-4/.test(m)) {
359
+ // CC 2.1.201 dropped mid-conversation-system from SONNET 4.6's beta set
360
+ // (2.1.199 sonnet == opus and still carried it — live capture #667).
361
+ // Scoped to the sonnet-4 line: Sonnet 5 carries it again — the wire-drift
362
+ // runner's live capture on CC 2.1.204 shows sonnet-5's set equal to opus's.
359
363
  flags = flags.filter((f) => f !== MID_CONVERSATION_SYSTEM_BETA);
360
364
  }
361
365
  else if (m.includes('fable')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "4.8.144",
3
+ "version": "4.8.145",
4
4
  "description": "Use your Claude Pro/Max subscription in any tool — Cursor, Cline, Aider, the Agent SDK, your scripts — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint.",
5
5
  "type": "module",
6
6
  "bin": {