@velum-labs/routekit-gateway 0.18.6 → 1.0.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 (236) hide show
  1. package/README.md +6 -5
  2. package/dist/{acp-registry.d.ts → acp/registry.d.ts} +6 -6
  3. package/dist/acp/registry.js +99 -0
  4. package/dist/adapters/anthropic-codec.d.ts +45 -0
  5. package/dist/adapters/anthropic-codec.js +538 -0
  6. package/dist/adapters/anthropic-models.d.ts +62 -0
  7. package/dist/adapters/anthropic-models.js +145 -0
  8. package/dist/adapters/anthropic-stream.d.ts +5 -0
  9. package/dist/adapters/anthropic-stream.js +444 -0
  10. package/dist/adapters/anthropic-wire.d.ts +73 -0
  11. package/dist/adapters/anthropic-wire.js +6 -0
  12. package/dist/adapters/anthropic.d.ts +17 -159
  13. package/dist/adapters/anthropic.js +100 -1294
  14. package/dist/adapters/cursor.d.ts +2 -13
  15. package/dist/adapters/cursor.js +13 -35
  16. package/dist/adapters/openai-chat-wire.d.ts +20 -36
  17. package/dist/adapters/openai-chat-wire.js +232 -63
  18. package/dist/adapters/openai-responses-wire.d.ts +16 -21
  19. package/dist/adapters/openai-responses-wire.js +95 -265
  20. package/dist/adapters/responses-codec.d.ts +65 -0
  21. package/dist/adapters/responses-codec.js +756 -0
  22. package/dist/adapters/responses-stream.d.ts +1 -6
  23. package/dist/adapters/responses-stream.js +120 -107
  24. package/dist/adapters/responses-usage.d.ts +2 -9
  25. package/dist/adapters/responses-usage.js +7 -5
  26. package/dist/adapters/responses-wire.d.ts +111 -0
  27. package/dist/adapters/responses-wire.js +6 -0
  28. package/dist/adapters/responses.d.ts +14 -165
  29. package/dist/adapters/responses.js +182 -919
  30. package/dist/adapters/server-tool-loop.d.ts +12 -7
  31. package/dist/adapters/server-tool-loop.js +260 -281
  32. package/dist/adapters/server-tool-transcript.d.ts +32 -0
  33. package/dist/adapters/server-tool-transcript.js +86 -0
  34. package/dist/adapters/validate.d.ts +4 -0
  35. package/dist/adapters/validate.js +18 -1
  36. package/dist/adapters/web-search.d.ts +4 -16
  37. package/dist/adapters/web-search.js +67 -81
  38. package/dist/capacity-pool.d.ts +2 -31
  39. package/dist/capacity-pool.js +1 -99
  40. package/dist/catalog-service.d.ts +12 -0
  41. package/dist/catalog-service.js +157 -0
  42. package/dist/effect/gateway.d.ts +6 -0
  43. package/dist/effect/gateway.js +16 -0
  44. package/dist/effect/scoped-gateway.d.ts +9 -0
  45. package/dist/effect/scoped-gateway.js +11 -0
  46. package/dist/effect-api.d.ts +3 -0
  47. package/dist/effect-api.js +3 -0
  48. package/dist/{endpoint-health.d.ts → endpoint-health-service.d.ts} +3 -4
  49. package/dist/{endpoint-health.js → endpoint-health-service.js} +14 -19
  50. package/dist/endpoint-pipeline.d.ts +16 -0
  51. package/dist/endpoint-pipeline.js +17 -0
  52. package/dist/endpoints/anthropic-messages-endpoint.d.ts +29 -0
  53. package/dist/endpoints/anthropic-messages-endpoint.js +218 -0
  54. package/dist/endpoints/chat-endpoint.d.ts +17 -0
  55. package/dist/endpoints/chat-endpoint.js +181 -0
  56. package/dist/endpoints/endpoint-module.d.ts +49 -0
  57. package/dist/endpoints/endpoint-module.js +40 -0
  58. package/dist/endpoints/models-endpoint.d.ts +43 -0
  59. package/dist/endpoints/models-endpoint.js +111 -0
  60. package/dist/endpoints/responses-endpoint.d.ts +26 -0
  61. package/dist/endpoints/responses-endpoint.js +214 -0
  62. package/dist/endpoints/usage-endpoint.d.ts +10 -0
  63. package/dist/endpoints/usage-endpoint.js +21 -0
  64. package/dist/gateway-service.d.ts +93 -0
  65. package/dist/gateway-service.js +236 -0
  66. package/dist/http/app.d.ts +10 -0
  67. package/dist/http/app.js +140 -0
  68. package/dist/http/auth.d.ts +70 -0
  69. package/dist/http/auth.js +211 -0
  70. package/dist/http/errors.d.ts +19 -0
  71. package/dist/http/errors.js +151 -0
  72. package/dist/http/request.d.ts +12 -0
  73. package/dist/http/request.js +69 -0
  74. package/dist/http/response.d.ts +5 -0
  75. package/dist/http/response.js +32 -0
  76. package/dist/index.d.ts +55 -40
  77. package/dist/index.js +29 -20
  78. package/dist/model-call-service.d.ts +33 -0
  79. package/dist/model-call-service.js +211 -0
  80. package/dist/{cost.js → observability/cost.js} +3 -4
  81. package/dist/{provenance.js → observability/provenance.js} +135 -7
  82. package/dist/protocol-api.d.ts +2 -0
  83. package/dist/protocol-api.js +1 -0
  84. package/dist/providers/anthropic-backend.d.ts +11 -0
  85. package/dist/providers/anthropic-backend.js +52 -0
  86. package/dist/providers/anthropic-codec.d.ts +15 -0
  87. package/dist/providers/anthropic-codec.js +533 -0
  88. package/dist/providers/auth.d.ts +6 -0
  89. package/dist/providers/auth.js +51 -0
  90. package/dist/providers/backend-core.d.ts +71 -0
  91. package/dist/providers/backend-core.js +135 -0
  92. package/dist/providers/backend-factory.d.ts +8 -0
  93. package/dist/providers/backend-factory.js +19 -0
  94. package/dist/providers/backend.d.ts +139 -0
  95. package/dist/providers/backend.js +129 -0
  96. package/dist/providers/backends.d.ts +5 -0
  97. package/dist/providers/backends.js +4 -0
  98. package/dist/providers/bedrock-codec.d.ts +11 -0
  99. package/dist/providers/bedrock-codec.js +484 -0
  100. package/dist/providers/bedrock-source.d.ts +26 -0
  101. package/dist/providers/bedrock-source.js +203 -0
  102. package/dist/{codex-model-selection.d.ts → providers/codex-model-selection.d.ts} +4 -3
  103. package/dist/providers/codex-model-selection.js +277 -0
  104. package/dist/providers/codex-responses-backend.d.ts +15 -0
  105. package/dist/providers/codex-responses-backend.js +107 -0
  106. package/dist/providers/codex-responses-codec.d.ts +38 -0
  107. package/dist/providers/codex-responses-codec.js +402 -0
  108. package/dist/providers/google-backend.d.ts +11 -0
  109. package/dist/providers/google-backend.js +48 -0
  110. package/dist/providers/google-codec.d.ts +28 -0
  111. package/dist/providers/google-codec.js +312 -0
  112. package/dist/providers/openai-backend.d.ts +41 -0
  113. package/dist/{backend.js → providers/openai-backend.js} +29 -98
  114. package/dist/providers/openai-reasoning.d.ts +7 -0
  115. package/dist/providers/openai-reasoning.js +25 -0
  116. package/dist/providers/protocol.d.ts +56 -0
  117. package/dist/providers/protocol.js +368 -0
  118. package/dist/providers/source.d.ts +19 -0
  119. package/dist/providers/source.js +81 -0
  120. package/dist/providers/types.d.ts +44 -0
  121. package/dist/providers/types.js +2 -0
  122. package/dist/routing/classifier.d.ts +32 -0
  123. package/dist/routing/classifier.js +322 -0
  124. package/dist/routing/compositional.d.ts +106 -0
  125. package/dist/routing/compositional.js +92 -0
  126. package/dist/routing/core.d.ts +79 -0
  127. package/dist/routing/core.js +168 -0
  128. package/dist/routing/eval-policy.d.ts +88 -0
  129. package/dist/routing/eval-policy.js +268 -0
  130. package/dist/routing/requirements.d.ts +6 -0
  131. package/dist/routing/requirements.js +95 -0
  132. package/dist/routing/router.d.ts +80 -0
  133. package/dist/routing/router.js +568 -0
  134. package/dist/routing-api.d.ts +6 -0
  135. package/dist/routing-api.js +3 -0
  136. package/dist/server-api.d.ts +5 -0
  137. package/dist/server-api.js +3 -0
  138. package/dist/sse/chat-assembler.d.ts +6 -13
  139. package/dist/sse/chat-assembler.js +70 -41
  140. package/dist/sse/parse.d.ts +2 -50
  141. package/dist/sse/parse.js +1 -149
  142. package/dist/switching-proxy.d.ts +21 -7
  143. package/dist/switching-proxy.js +270 -156
  144. package/dist/test/acp-agent.test.js +1 -1
  145. package/dist/test/acp-registry.test.js +22 -14
  146. package/dist/test/anthropic-stop-reason.test.js +27 -0
  147. package/dist/test/anthropic.test.js +109 -129
  148. package/dist/test/auth.test.js +78 -10
  149. package/dist/test/bedrock-source.test.js +282 -353
  150. package/dist/test/boundary.test.js +1 -1
  151. package/dist/test/chat.test.js +112 -47
  152. package/dist/test/codex-model-selection.test.js +216 -185
  153. package/dist/test/compositional-routing.test.js +346 -0
  154. package/dist/test/cost.test.js +2 -3
  155. package/dist/test/cursor.test.js +67 -58
  156. package/dist/test/drain.test.js +69 -10
  157. package/dist/test/dropped.test.js +1 -3
  158. package/dist/test/effect-gateway.test.d.ts +1 -0
  159. package/dist/test/effect-gateway.test.js +40 -0
  160. package/dist/test/endpoint-health.test.js +37 -24
  161. package/dist/test/endpoint-modules.test.d.ts +1 -0
  162. package/dist/test/endpoint-modules.test.js +175 -0
  163. package/dist/test/endpoint-pipeline.test.d.ts +1 -0
  164. package/dist/test/endpoint-pipeline.test.js +35 -0
  165. package/dist/test/eval-policy.test.d.ts +1 -0
  166. package/dist/test/eval-policy.test.js +54 -0
  167. package/dist/test/eval-session-proxy.test.d.ts +1 -0
  168. package/dist/test/eval-session-proxy.test.js +127 -0
  169. package/dist/test/openai-reasoning.test.d.ts +1 -0
  170. package/dist/test/openai-reasoning.test.js +27 -0
  171. package/dist/test/openai-responses-wire.test.js +21 -248
  172. package/dist/test/provenance.test.js +75 -3
  173. package/dist/test/provider-backends-fixtures.d.ts +7 -0
  174. package/dist/test/provider-backends-fixtures.js +17 -0
  175. package/dist/test/provider-google-codex.test.d.ts +1 -0
  176. package/dist/test/provider-google-codex.test.js +869 -0
  177. package/dist/test/provider-protocol.test.d.ts +1 -0
  178. package/dist/test/provider-protocol.test.js +155 -0
  179. package/dist/test/provider-source-fixture.d.ts +18 -0
  180. package/dist/test/provider-source-fixture.js +35 -0
  181. package/dist/test/provider-source.test.js +16 -16
  182. package/dist/test/provider-streaming.test.d.ts +1 -0
  183. package/dist/test/provider-streaming.test.js +549 -0
  184. package/dist/test/provider-validation-anthropic.test.d.ts +1 -0
  185. package/dist/test/provider-validation-anthropic.test.js +891 -0
  186. package/dist/test/request-classifier.test.d.ts +1 -0
  187. package/dist/test/request-classifier.test.js +213 -0
  188. package/dist/test/responses-conversion.test.d.ts +1 -0
  189. package/dist/test/responses-conversion.test.js +267 -0
  190. package/dist/test/responses-fixtures.d.ts +46 -0
  191. package/dist/test/responses-fixtures.js +145 -0
  192. package/dist/test/responses-reasoning.test.d.ts +1 -0
  193. package/dist/test/responses-reasoning.test.js +1085 -0
  194. package/dist/test/responses-streaming-catalog.test.d.ts +1 -0
  195. package/dist/test/responses-streaming-catalog.test.js +484 -0
  196. package/dist/test/responses-tools.test.d.ts +1 -0
  197. package/dist/test/responses-tools.test.js +536 -0
  198. package/dist/test/routed-backend.test.js +25 -14
  199. package/dist/test/router.test.js +289 -154
  200. package/dist/test/routing-core.test.d.ts +1 -0
  201. package/dist/test/routing-core.test.js +55 -0
  202. package/dist/test/routing-requirements.test.d.ts +1 -0
  203. package/dist/test/routing-requirements.test.js +53 -0
  204. package/dist/test/server-resilience.test.js +39 -29
  205. package/dist/test/sse-codec.test.js +38 -14
  206. package/dist/test/switching-proxy-retire.test.js +5 -4
  207. package/dist/test/web-search-loop.test.js +278 -160
  208. package/dist/test/wire-validation.test.js +51 -18
  209. package/package.json +24 -6
  210. package/dist/acp-registry.js +0 -85
  211. package/dist/auth.d.ts +0 -32
  212. package/dist/auth.js +0 -80
  213. package/dist/backend.d.ts +0 -172
  214. package/dist/bedrock-source.d.ts +0 -39
  215. package/dist/bedrock-source.js +0 -739
  216. package/dist/codex-model-selection.js +0 -246
  217. package/dist/http-response.d.ts +0 -6
  218. package/dist/http-response.js +0 -19
  219. package/dist/provider-backends.d.ts +0 -41
  220. package/dist/provider-backends.js +0 -1436
  221. package/dist/provider-source.d.ts +0 -45
  222. package/dist/provider-source.js +0 -459
  223. package/dist/router.d.ts +0 -221
  224. package/dist/router.js +0 -768
  225. package/dist/server.d.ts +0 -67
  226. package/dist/server.js +0 -1129
  227. package/dist/test/provider-backends.test.js +0 -1999
  228. package/dist/test/responses.test.js +0 -2307
  229. /package/dist/{acp-agent.d.ts → acp/agent.d.ts} +0 -0
  230. /package/dist/{acp-agent.js → acp/agent.js} +0 -0
  231. /package/dist/{cost.d.ts → observability/cost.d.ts} +0 -0
  232. /package/dist/{provenance.d.ts → observability/provenance.d.ts} +0 -0
  233. /package/dist/{sse-wire.d.ts → sse/wire.d.ts} +0 -0
  234. /package/dist/{sse-wire.js → sse/wire.js} +0 -0
  235. /package/dist/test/{provider-backends.test.d.ts → anthropic-stop-reason.test.d.ts} +0 -0
  236. /package/dist/test/{responses.test.d.ts → compositional-routing.test.d.ts} +0 -0
package/README.md CHANGED
@@ -4,10 +4,11 @@ Product-neutral model routing and provider egress for RouteKit.
4
4
 
5
5
  The package owns the `Backend` interface, HTTP gateway, OpenAI Chat,
6
6
  Responses, Anthropic Messages and Cursor adapters, SSE handling, ACP support,
7
- normalized call provenance, runtime-validated router configuration, model
8
- catalogs, provider sources, and provider-native egress.
7
+ normalized call provenance, model catalogs, provider sources, and
8
+ provider-native egress. Canonical router configuration belongs to
9
+ `@velum-labs/routekit-config-core`.
9
10
 
10
- At startup `CatalogBackend` authenticates every explicitly configured provider,
11
+ At startup `RoutingBackend` authenticates every explicitly configured provider,
11
12
  performs live model discovery, and publishes source-qualified
12
13
  `provider/model` IDs. Dispatch removes the source prefix before provider-native
13
14
  egress. An unavailable provider fails startup rather than silently shrinking
@@ -15,10 +16,10 @@ the catalog.
15
16
 
16
17
  ```ts
17
18
  import {
18
- CatalogBackend,
19
- parseRouterConfig,
19
+ RoutingBackend,
20
20
  startGateway
21
21
  } from "@velum-labs/routekit-gateway";
22
+ import { parseRouterConfig } from "@velum-labs/routekit-config-core";
22
23
  ```
23
24
 
24
25
  API-key providers use registry-defined credentials and URLs. Multi-account
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * ACP Registry integration. Resolves curated ACP-compatible agents (for
3
3
  * example the registry-backed `Codex CLI` and `Claude Agent` adapters) from the
4
- * ACP Registry so they can drive the generic ACP front door. The fetcher and
5
- * install directory are injectable for deterministic testing.
4
+ * ACP Registry so they can drive the generic ACP front door. The install
5
+ * directory is injectable for deterministic testing.
6
6
  *
7
7
  * Registry source: https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json
8
8
  */
9
+ import { Effect } from "effect";
10
+ import { HttpClient } from "effect/unstable/http";
9
11
  export declare const ACP_REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
10
12
  export type AcpRegistryAgent = {
11
13
  id: string;
@@ -17,7 +19,6 @@ export type AcpRegistryAgent = {
17
19
  export type AcpRegistry = {
18
20
  agents: AcpRegistryAgent[];
19
21
  };
20
- export type AcpRegistryFetcher = (url: string) => Promise<unknown>;
21
22
  export type InstalledAcpAdapter = {
22
23
  id: string;
23
24
  name: string;
@@ -26,11 +27,10 @@ export type InstalledAcpAdapter = {
26
27
  installedAt: string;
27
28
  metadataPath: string;
28
29
  };
29
- export declare function fetchAcpRegistry(fetcher?: AcpRegistryFetcher, url?: string): Promise<AcpRegistry>;
30
+ export declare function fetchAcpRegistry(url?: string): Effect.Effect<AcpRegistry, Error, HttpClient.HttpClient>;
30
31
  export type InstallAcpAdaptersOptions = {
31
32
  agentIds: string[];
32
33
  installDir: string;
33
- fetcher?: AcpRegistryFetcher;
34
34
  url?: string;
35
35
  };
36
- export declare function installAcpAdapters(options: InstallAcpAdaptersOptions): Promise<InstalledAcpAdapter[]>;
36
+ export declare function installAcpAdapters(options: InstallAcpAdaptersOptions): Effect.Effect<InstalledAcpAdapter[], Error, HttpClient.HttpClient>;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * ACP Registry integration. Resolves curated ACP-compatible agents (for
3
+ * example the registry-backed `Codex CLI` and `Claude Agent` adapters) from the
4
+ * ACP Registry so they can drive the generic ACP front door. The install
5
+ * directory is injectable for deterministic testing.
6
+ *
7
+ * Registry source: https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json
8
+ */
9
+ import { mkdirSync, writeFileSync } from "node:fs";
10
+ import { join, resolve } from "node:path";
11
+ import { executeWebRequest, RouteKitFailure, routeKitError, toRouteKitFailure } from "@velum-labs/routekit-runtime/effect";
12
+ import { Effect } from "effect";
13
+ import { gatewayTry } from "../effect/gateway.js";
14
+ export const ACP_REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
15
+ function normalizeRegistry(raw) {
16
+ if (typeof raw !== "object" || raw === null) {
17
+ throw new Error("ACP registry payload must be an object");
18
+ }
19
+ const agentsValue = raw.agents;
20
+ if (!Array.isArray(agentsValue)) {
21
+ throw new Error("ACP registry payload is missing an agents array");
22
+ }
23
+ const agents = [];
24
+ for (const entry of agentsValue) {
25
+ if (typeof entry !== "object" || entry === null)
26
+ continue;
27
+ const id = entry.id;
28
+ if (typeof id !== "string" || id.length === 0)
29
+ continue;
30
+ const agent = { id };
31
+ const name = entry.name;
32
+ if (typeof name === "string")
33
+ agent.name = name;
34
+ const version = entry.version;
35
+ if (typeof version === "string")
36
+ agent.version = version;
37
+ const description = entry.description;
38
+ if (typeof description === "string")
39
+ agent.description = description;
40
+ const distribution = entry.distribution;
41
+ if (typeof distribution === "object" && distribution !== null) {
42
+ agent.distribution = distribution;
43
+ }
44
+ agents.push(agent);
45
+ }
46
+ return { agents };
47
+ }
48
+ export function fetchAcpRegistry(url = ACP_REGISTRY_URL) {
49
+ return Effect.gen(function* () {
50
+ const response = yield* executeWebRequest(url).pipe(Effect.mapError((error) => routeKitError(error)));
51
+ if (!response.ok) {
52
+ return yield* new RouteKitFailure({
53
+ message: `ACP registry fetch failed: ${response.status}`
54
+ });
55
+ }
56
+ const payload = yield* Effect.tryPromise({
57
+ try: () => response.json(),
58
+ catch: (cause) => toRouteKitFailure(cause)
59
+ });
60
+ return normalizeRegistry(payload);
61
+ });
62
+ }
63
+ export function installAcpAdapters(options) {
64
+ return Effect.gen(function* () {
65
+ if (options.agentIds.length === 0) {
66
+ return yield* new RouteKitFailure({ message: "at least one ACP agent id is required" });
67
+ }
68
+ const registry = yield* fetchAcpRegistry(options.url ?? ACP_REGISTRY_URL);
69
+ const byId = new Map(registry.agents.map((agent) => [agent.id, agent]));
70
+ const dir = resolve(options.installDir);
71
+ yield* gatewayTry(() => mkdirSync(dir, { recursive: true }));
72
+ const installed = [];
73
+ for (const agentId of options.agentIds) {
74
+ const agent = byId.get(agentId);
75
+ if (agent === undefined) {
76
+ return yield* new RouteKitFailure({
77
+ message: `ACP registry has no agent with id "${agentId}"`
78
+ });
79
+ }
80
+ if (agent.distribution === undefined) {
81
+ return yield* new RouteKitFailure({
82
+ message: `ACP agent "${agentId}" has no distribution metadata`
83
+ });
84
+ }
85
+ const metadataPath = join(dir, `${agentId}.json`);
86
+ const record = {
87
+ id: agent.id,
88
+ name: agent.name ?? agent.id,
89
+ version: agent.version ?? "unknown",
90
+ distribution: agent.distribution,
91
+ installedAt: new Date().toISOString(),
92
+ metadataPath
93
+ };
94
+ yield* gatewayTry(() => writeFileSync(metadataPath, JSON.stringify(record, null, 2) + "\n"));
95
+ installed.push(record);
96
+ }
97
+ return installed;
98
+ });
99
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Anthropic Messages codec. Pure request/response translation between the
3
+ * Anthropic Messages wire and the gateway's OpenAI Chat Completions core.
4
+ * Streaming translation lives in `anthropic-stream.ts`; HTTP handling lives
5
+ * in `anthropic.ts`.
6
+ */
7
+ import type { OpenAiChatResponse } from "../providers/protocol.js";
8
+ import type { AnthropicRequest } from "./anthropic-wire.js";
9
+ import type { ExecutedSearch, ServerToolLoopEvent } from "./server-tool-loop.js";
10
+ export type { AnthropicRequest } from "./anthropic-wire.js";
11
+ /**
12
+ * Whether an Anthropic tool is *server-executed* (run by Anthropic's backend,
13
+ * e.g. `web_search_20250305` / `code_execution_*`). Nothing behind this gateway
14
+ * can execute those, so advertising them to the upstream model would only produce
15
+ * calls nobody answers. Everything else — plain client tools (no `type` /
16
+ * `custom`) and Anthropic-defined client tools (`bash_*`, `text_editor_*`,
17
+ * `computer_*`), all of which the caller executes via ordinary `tool_use`
18
+ * blocks — is projected through.
19
+ */
20
+ export declare function isAnthropicServerTool(tool: {
21
+ type?: string;
22
+ }): boolean;
23
+ /** A server web search tool declaration (`web_search_20250305` et al.) — the
24
+ * one server tool the gateway can honor via its own web-search executor. */
25
+ export declare function isAnthropicWebSearchTool(tool: {
26
+ type?: string;
27
+ }): boolean;
28
+ /** The name the gateway-executed web search tool is projected under chat-side. */
29
+ export declare const WEB_SEARCH_TOOL_NAME = "web_search";
30
+ /** Options gating server-executed tool projection (on iff an executor exists). */
31
+ export type AnthropicTranslationOptions = {
32
+ serverTools?: boolean;
33
+ };
34
+ type OpenAiResponse = OpenAiChatResponse;
35
+ export declare function thinkingValidationError(body: AnthropicRequest): string | undefined;
36
+ /**
37
+ * Translate an Anthropic Messages request to an OpenAI Chat Completions body.
38
+ * The upstream model is always the backend's own model (Claude Code sends a
39
+ * `claude-*` id the local server would not recognise); the requested id is
40
+ * only echoed back in the response.
41
+ */
42
+ export declare function anthropicToChat(body: AnthropicRequest, backendModel: string | undefined, options?: AnthropicTranslationOptions): Record<string, unknown>;
43
+ export declare function mapStopReason(finishReason: string | null | undefined): string;
44
+ export declare function chatToAnthropicMessage(openai: OpenAiResponse, model: string, searches?: readonly ExecutedSearch[], events?: readonly ServerToolLoopEvent[]): Record<string, unknown>;
45
+ export declare function countTokensEstimate(body: AnthropicRequest): number;