@askalf/dario 6.22.1 → 6.22.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.
@@ -46,6 +46,14 @@ export function isAdvertisableToolDefinition(def) {
46
46
  const schema = def.input_schema;
47
47
  return !!schema && typeof schema === 'object' && typeof schema.type === 'string';
48
48
  }
49
+ /**
50
+ * A client entry for a tool Anthropic defines (`advisor_20260301`): it carries a
51
+ * `type` other than `custom` and no `input_schema`, because the definition lives
52
+ * on the server. Nothing can be remapped onto it and nothing can stand in for it.
53
+ */
54
+ function isAnthropicDefinedTool(def) {
55
+ return typeof def.type === 'string' && def.type !== 'custom';
56
+ }
49
57
  /** Names in the bundle whose definition is not advertisable (see above). Empty on a clean bake. */
50
58
  export const CC_TOOL_DEFINITIONS_UNADVERTISABLE = new Set(TEMPLATE.tools.filter((t) => !isAdvertisableToolDefinition(t)).map((t) => String(t.name)));
51
59
  /** CC's exact tool definitions for the current platform — filtered from the bundled union. */
@@ -765,6 +773,18 @@ export function detectNonCCByTools(clientTools) {
765
773
  // Union set, not the host-filtered one: a win32 client's PowerShell is
766
774
  // native regardless of the platform dario itself runs on (v4.8.136).
767
775
  if (CC_NATIVE_NAMES_UNION.has(rawName)) {
776
+ // A union name whose bundled definition is not advertisable is a server
777
+ // tool: CC never carries a client-callable schema for it (dario#1376).
778
+ // A client entry of that name that DOES declare an advertisable schema
779
+ // is the client's own tool wearing a CC name — count it unmapped and
780
+ // withhold native evidence, or one such entry suppresses every preserve
781
+ // route (`unmapped > 0 && !native`, and the skipped entry keeps the
782
+ // ratio below 0.8) and the whole surface goes to remap (#1812).
783
+ const foreignWearingCCName = CC_TOOL_DEFINITIONS_UNADVERTISABLE.has(rawName) && isAdvertisableToolDefinition(tool);
784
+ if (foreignWearingCCName) {
785
+ unmapped++;
786
+ continue;
787
+ }
768
788
  native = true;
769
789
  continue;
770
790
  }
@@ -1996,7 +2016,11 @@ export function buildCCRequest(clientBody, billingTag, cacheControl, identity, o
1996
2016
  // name, arguments untouched, renamed back on the response. A tool that
1997
2017
  // cannot be carried that way fails the request with its name.
1998
2018
  const CC_FALLBACK_TOOLS = ['Bash', 'Read', 'Grep', 'Glob', 'WebSearch', 'WebFetch'];
1999
- const namesCCTool = clientTools.some((t) => typeof t.name === 'string' && !isMcpToolName(t.name) && CC_TOOL_NAMES_LOWER.has(t.name.toLowerCase()));
2019
+ // An Anthropic-defined entry for a bundled name counts: it goes out on its
2020
+ // own, so the advertise step never reaches the template and a tool beside it
2021
+ // needs the MCP shape to be seen at all (#1812).
2022
+ const namesCCTool = clientTools.some((t) => typeof t.name === 'string' && !isMcpToolName(t.name) && (CC_TOOL_NAMES_LOWER.has(t.name.toLowerCase())
2023
+ || (CC_TOOL_DEFINITIONS_UNADVERTISABLE.has(t.name) && isAnthropicDefinedTool(t))));
2000
2024
  const declaredNames = new Set(clientTools.map((t) => t.name));
2001
2025
  const uncarried = [];
2002
2026
  for (const tool of clientTools) {
@@ -2246,12 +2270,19 @@ export function buildCCRequest(clientBody, billingTag, cacheControl, identity, o
2246
2270
  // `advisor` captured with an empty schema) is still identity-mapped
2247
2271
  // above; the only usable definition is the client's own, so it goes out
2248
2272
  // verbatim, as MCP tools do. The client's schema is what its parser
2249
- // expects back in any case.
2250
- const clientOwnNative = clientTools.filter((t) => typeof t.name === 'string' && CC_TOOL_DEFINITIONS_UNADVERTISABLE.has(t.name) && isAdvertisableToolDefinition(t));
2273
+ // expects back in any case. An Anthropic-defined entry has no schema, so
2274
+ // it is forwarded as declared; dropping it loses the declaration with no
2275
+ // error the client can see (#1812).
2276
+ const clientOwnNative = clientTools.filter((t) => typeof t.name === 'string' && CC_TOOL_DEFINITIONS_UNADVERTISABLE.has(t.name)
2277
+ && (isAdvertisableToolDefinition(t) || isAnthropicDefinedTool(t)));
2278
+ // CC sends its own tools in name order, so a client's definition of one
2279
+ // takes its place among them: `advisor` goes first, not after `Read`.
2280
+ const natives = [...availableCC, ...clientOwnNative]
2281
+ .sort((a, b) => String(a.name).localeCompare(String(b.name)));
2251
2282
  // Client tools outside CC's set follow the MCP tools, under the
2252
2283
  // MCP-shaped names the tool map gave them.
2253
- ccRequest.tools = availableCC.length > 0 || mcpTools.length > 0 || clientOwnNative.length > 0 || mcpShapedTools.length > 0
2254
- ? dedupeToolsByName([...availableCC, ...clientOwnNative, ...mcpTools, ...mcpShapedTools])
2284
+ ccRequest.tools = natives.length > 0 || mcpTools.length > 0 || mcpShapedTools.length > 0
2285
+ ? dedupeToolsByName([...natives, ...mcpTools, ...mcpShapedTools])
2255
2286
  : CC_TOOL_DEFINITIONS;
2256
2287
  }
2257
2288
  }
@@ -27,6 +27,8 @@ MCP tools take a third path: anything named `mcp__<server>__<tool>` is neither r
27
27
 
28
28
  A request that names Claude Code tools and also declares a tool outside `TOOL_MAP` (`Grep`, `Read`, `submit_review`) stays in remap, and the extra tool gets the MCP treatment: it goes out as `mcp__client__<name>` with the client's own schema, after the CC tools, and the model's calls come back under the client's name. Remap advertises only the CC tools such a request declares, so the fallback slot it used to ride was never on the wire. A tool that cannot be carried that way (an Anthropic-defined tool such as `computer_20251124`, a tool with no `input_schema`, or a name longer than 51 characters) fails the request with a 400 that names it. `--preserve-tools` forwards all of them verbatim instead.
29
29
 
30
+ Anthropic's `advisor` tool (`advisor_20260301`) is the exception. Its name is in Claude Code's own tool list and the bundle holds only a stub for it, so dario forwards the client's entry as declared and leaves any `server_tool_use` and `advisor_tool_result` blocks in the response untouched. This has not been verified against the live API. An Anthropic-defined entry whose name is in `TOOL_MAP` takes the mapped tool instead: `bash_20250124` becomes `Bash`, and `web_search_20250305` becomes Claude Code's client-side `WebSearch`, so that call comes back for the client to run (#1812).
31
+
30
32
  If your agent's tool names aren't pre-mapped and its tools carry fields CC's schema doesn't have, there are two escape hatches: **`--preserve-tools`** (forward your schema verbatim, lose the CC wire shape) or **`--hybrid-tools`** (keep the CC wire shape, fill request-context fields from headers). See [Custom tool schemas](#custom-tool-schemas).
31
33
 
32
34
  The OpenAI-compat backend forwards tool definitions byte-for-byte and doesn't need any of this.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "6.22.1",
3
+ "version": "6.22.2",
4
4
  "description": "Use your Claude and ChatGPT subscriptions in Cursor, Cline, Aider, Claude Code and the Agent SDK at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint: either plan answers either wire shape, opt-in failover when one hits its limit, and a ledger of what each plan absorbed.",
5
5
  "type": "module",
6
6
  "bin": {