@cldmv/llm-translator 0.1.0 → 0.3.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 (208) hide show
  1. package/README.md +182 -7
  2. package/dist/api/convert/anthropic/messages/to/openai/chat/request.mjs +17 -0
  3. package/dist/api/convert/anthropic/messages/to/openai/chat/response.mjs +2 -0
  4. package/dist/api/convert/anthropic/messages/to/openai/chat/stream.mjs +2 -0
  5. package/dist/api/convert/openai/chat/to/anthropic/messages/request.mjs +6 -0
  6. package/dist/api/convert/openai/chat/to/anthropic/messages/response.mjs +2 -0
  7. package/dist/api/convert/openai/chat/to/anthropic/messages/stream.mjs +2 -0
  8. package/dist/api/detect.mjs +2 -0
  9. package/dist/api/driver/anthropic/detect.mjs +2 -0
  10. package/dist/api/driver/anthropic/info.mjs +2 -0
  11. package/dist/api/driver/anthropic/model/list.mjs +2 -0
  12. package/dist/api/driver/anthropic/settings.mjs +2 -0
  13. package/dist/api/driver/anthropic/token/count.mjs +2 -0
  14. package/dist/api/driver/compatible/detect.mjs +2 -0
  15. package/dist/api/driver/compatible/info.mjs +2 -0
  16. package/dist/api/driver/compatible/model/list.mjs +2 -0
  17. package/dist/api/driver/compatible/request.mjs +2 -0
  18. package/dist/api/driver/compatible/settings.mjs +2 -0
  19. package/dist/api/driver/deepseek/detect.mjs +2 -0
  20. package/dist/api/driver/deepseek/error.mjs +2 -0
  21. package/dist/api/driver/deepseek/info.mjs +2 -0
  22. package/dist/api/driver/deepseek/request.mjs +2 -0
  23. package/dist/api/driver/deepseek/settings.mjs +2 -0
  24. package/dist/api/driver/llamacpp/chunk.mjs +2 -0
  25. package/dist/api/driver/llamacpp/detect.mjs +2 -0
  26. package/dist/api/driver/llamacpp/flush.mjs +2 -0
  27. package/dist/api/driver/llamacpp/info.mjs +2 -0
  28. package/dist/api/driver/llamacpp/request.mjs +2 -0
  29. package/dist/api/driver/llamacpp/response.mjs +2 -0
  30. package/dist/api/driver/llamacpp/settings.mjs +2 -0
  31. package/dist/api/driver/ollama/detect.mjs +2 -0
  32. package/dist/api/driver/ollama/info.mjs +2 -0
  33. package/dist/api/driver/ollama/request.mjs +2 -0
  34. package/dist/api/driver/ollama/settings.mjs +2 -0
  35. package/dist/api/driver/openai/detect.mjs +2 -0
  36. package/dist/api/driver/openai/info.mjs +2 -0
  37. package/dist/api/driver/openai/model/list.mjs +2 -0
  38. package/dist/api/driver/openai/request.mjs +2 -0
  39. package/dist/api/driver/openai/settings.mjs +2 -0
  40. package/dist/api/driver/sglang/detect.mjs +2 -0
  41. package/dist/api/driver/sglang/info.mjs +2 -0
  42. package/dist/api/driver/sglang/request.mjs +2 -0
  43. package/dist/api/driver/sglang/settings.mjs +2 -0
  44. package/dist/api/driver/vllm/detect.mjs +2 -0
  45. package/dist/api/driver/vllm/error.mjs +2 -0
  46. package/dist/api/driver/vllm/info.mjs +2 -0
  47. package/dist/api/driver/vllm/model/list.mjs +2 -0
  48. package/dist/api/driver/vllm/probe.mjs +2 -0
  49. package/dist/api/driver/vllm/request.mjs +2 -0
  50. package/dist/api/driver/vllm/settings.mjs +2 -0
  51. package/dist/api/driver/vllm/token/count.mjs +2 -0
  52. package/dist/api/endpoint/status.mjs +2 -0
  53. package/dist/api/error/build.mjs +2 -0
  54. package/dist/api/error/error.mjs +2 -0
  55. package/dist/api/model/get.mjs +2 -0
  56. package/dist/api/model/list.mjs +2 -0
  57. package/dist/api/request.mjs +3 -0
  58. package/dist/api/response.mjs +2 -0
  59. package/dist/api/route.mjs +2 -0
  60. package/dist/api/send.mjs +2 -0
  61. package/dist/api/server/plugin.mjs +2 -0
  62. package/dist/api/server/start.mjs +2 -0
  63. package/dist/api/server/stop.mjs +2 -0
  64. package/dist/api/sse/encode.mjs +4 -0
  65. package/dist/api/sse/parse.mjs +2 -0
  66. package/dist/api/sse/ping.mjs +2 -0
  67. package/dist/api/sse/write.mjs +2 -0
  68. package/dist/api/status.mjs +2 -0
  69. package/dist/api/stream.mjs +2 -0
  70. package/dist/api/token/count.mjs +2 -0
  71. package/dist/bin/llm-translator.mjs +3 -0
  72. package/dist/index.cjs +3 -3
  73. package/dist/index.mjs +1 -1
  74. package/dist/lib/arguments.mjs +2 -0
  75. package/dist/lib/backends.mjs +2 -0
  76. package/dist/lib/capture.mjs +2 -0
  77. package/dist/lib/cli.mjs +29 -0
  78. package/dist/lib/config.mjs +2 -0
  79. package/dist/lib/documents.mjs +12 -0
  80. package/dist/lib/errors.mjs +2 -0
  81. package/dist/lib/estimate.mjs +2 -0
  82. package/dist/lib/finish.mjs +2 -0
  83. package/dist/lib/http.mjs +2 -0
  84. package/dist/lib/ids.mjs +2 -0
  85. package/dist/lib/images.mjs +2 -0
  86. package/dist/lib/models.mjs +2 -0
  87. package/dist/lib/normalize.mjs +2 -0
  88. package/dist/lib/passthrough.mjs +2 -0
  89. package/dist/lib/pdf.mjs +2 -0
  90. package/dist/lib/ping.mjs +2 -0
  91. package/dist/lib/pool.mjs +2 -0
  92. package/dist/lib/route.mjs +2 -0
  93. package/dist/lib/routes.mjs +2 -0
  94. package/dist/lib/runtime.mjs +2 -0
  95. package/dist/lib/schema.mjs +2 -0
  96. package/dist/lib/settings.mjs +2 -0
  97. package/dist/lib/source.mjs +2 -0
  98. package/dist/lib/sse.mjs +10 -0
  99. package/dist/lib/thinking.mjs +3 -0
  100. package/dist/lib/tools.mjs +2 -0
  101. package/dist/lib/toolsearch.mjs +3 -0
  102. package/dist/lib/transport.mjs +2 -0
  103. package/dist/lib/upstream-error.mjs +2 -0
  104. package/dist/lib/usage.mjs +2 -0
  105. package/dist/lib/warn.mjs +2 -0
  106. package/package.json +40 -9
  107. package/types/src/api/convert/anthropic/messages/to/openai/chat/request.d.mts +19 -0
  108. package/types/src/api/convert/anthropic/messages/to/openai/chat/response.d.mts +11 -0
  109. package/types/src/api/convert/anthropic/messages/to/openai/chat/stream.d.mts +15 -0
  110. package/types/src/api/convert/openai/chat/to/anthropic/messages/request.d.mts +16 -0
  111. package/types/src/api/convert/openai/chat/to/anthropic/messages/response.d.mts +14 -0
  112. package/types/src/api/convert/openai/chat/to/anthropic/messages/stream.d.mts +24 -0
  113. package/types/src/api/detect.d.mts +7 -0
  114. package/types/src/api/driver/anthropic/detect.d.mts +26 -0
  115. package/types/src/api/driver/anthropic/info.d.mts +30 -0
  116. package/types/src/api/driver/anthropic/model/list.d.mts +6 -0
  117. package/types/src/api/driver/anthropic/settings.d.mts +23 -0
  118. package/types/src/api/driver/anthropic/token/count.d.mts +6 -0
  119. package/types/src/api/driver/compatible/detect.d.mts +9 -0
  120. package/types/src/api/driver/compatible/info.d.mts +12 -0
  121. package/types/src/api/driver/compatible/model/list.d.mts +6 -0
  122. package/types/src/api/driver/compatible/request.d.mts +6 -0
  123. package/types/src/api/driver/compatible/settings.d.mts +23 -0
  124. package/types/src/api/driver/deepseek/detect.d.mts +26 -0
  125. package/types/src/api/driver/deepseek/error.d.mts +14 -0
  126. package/types/src/api/driver/deepseek/info.d.mts +29 -0
  127. package/types/src/api/driver/deepseek/request.d.mts +8 -0
  128. package/types/src/api/driver/deepseek/settings.d.mts +25 -0
  129. package/types/src/api/driver/llamacpp/chunk.d.mts +7 -0
  130. package/types/src/api/driver/llamacpp/detect.d.mts +6 -0
  131. package/types/src/api/driver/llamacpp/flush.d.mts +26 -0
  132. package/types/src/api/driver/llamacpp/info.d.mts +31 -0
  133. package/types/src/api/driver/llamacpp/request.d.mts +8 -0
  134. package/types/src/api/driver/llamacpp/response.d.mts +8 -0
  135. package/types/src/api/driver/llamacpp/settings.d.mts +27 -0
  136. package/types/src/api/driver/ollama/detect.d.mts +6 -0
  137. package/types/src/api/driver/ollama/info.d.mts +30 -0
  138. package/types/src/api/driver/ollama/request.d.mts +8 -0
  139. package/types/src/api/driver/ollama/settings.d.mts +7 -0
  140. package/types/src/api/driver/openai/detect.d.mts +26 -0
  141. package/types/src/api/driver/openai/info.d.mts +29 -0
  142. package/types/src/api/driver/openai/model/list.d.mts +6 -0
  143. package/types/src/api/driver/openai/request.d.mts +6 -0
  144. package/types/src/api/driver/openai/settings.d.mts +23 -0
  145. package/types/src/api/driver/sglang/detect.d.mts +6 -0
  146. package/types/src/api/driver/sglang/info.d.mts +31 -0
  147. package/types/src/api/driver/sglang/request.d.mts +8 -0
  148. package/types/src/api/driver/sglang/settings.d.mts +24 -0
  149. package/types/src/api/driver/vllm/detect.d.mts +6 -0
  150. package/types/src/api/driver/vllm/error.d.mts +14 -0
  151. package/types/src/api/driver/vllm/info.d.mts +12 -0
  152. package/types/src/api/driver/vllm/model/list.d.mts +6 -0
  153. package/types/src/api/driver/vllm/probe.d.mts +25 -0
  154. package/types/src/api/driver/vllm/request.d.mts +8 -0
  155. package/types/src/api/driver/vllm/settings.d.mts +8 -0
  156. package/types/src/api/driver/vllm/token/count.d.mts +6 -0
  157. package/types/src/api/endpoint/status.d.mts +27 -0
  158. package/types/src/api/error/build.d.mts +12 -0
  159. package/types/src/api/error/error.d.mts +15 -0
  160. package/types/src/api/model/get.d.mts +9 -0
  161. package/types/src/api/model/list.d.mts +7 -0
  162. package/types/src/api/request.d.mts +26 -0
  163. package/types/src/api/response.d.mts +8 -0
  164. package/types/src/api/route.d.mts +18 -0
  165. package/types/src/api/send.d.mts +37 -0
  166. package/types/src/api/server/plugin.d.mts +11 -0
  167. package/types/src/api/server/start.d.mts +12 -0
  168. package/types/src/api/server/stop.d.mts +5 -0
  169. package/types/src/api/sse/encode.d.mts +12 -0
  170. package/types/src/api/sse/parse.d.mts +10 -0
  171. package/types/src/api/sse/ping.d.mts +16 -0
  172. package/types/src/api/sse/write.d.mts +12 -0
  173. package/types/src/api/status.d.mts +8 -0
  174. package/types/src/api/stream.d.mts +11 -0
  175. package/types/src/api/token/count.d.mts +10 -0
  176. package/types/src/index.d.mts +62 -15
  177. package/types/src/lib/arguments.d.mts +16 -0
  178. package/types/src/lib/backends.d.mts +21 -0
  179. package/types/src/lib/capture.d.mts +14 -0
  180. package/types/src/lib/cli.d.mts +35 -0
  181. package/types/src/lib/config.d.mts +51 -0
  182. package/types/src/lib/documents.d.mts +32 -0
  183. package/types/src/lib/errors.d.mts +144 -0
  184. package/types/src/lib/estimate.d.mts +75 -0
  185. package/types/src/lib/finish.d.mts +73 -0
  186. package/types/src/lib/http.d.mts +72 -0
  187. package/types/src/lib/ids.d.mts +46 -0
  188. package/types/src/lib/images.d.mts +39 -0
  189. package/types/src/lib/models.d.mts +25 -0
  190. package/types/src/lib/normalize.d.mts +37 -0
  191. package/types/src/lib/passthrough.d.mts +16 -0
  192. package/types/src/lib/pdf.d.mts +53 -0
  193. package/types/src/lib/ping.d.mts +10 -0
  194. package/types/src/lib/pool.d.mts +124 -0
  195. package/types/src/lib/route.d.mts +45 -0
  196. package/types/src/lib/routes.d.mts +17 -0
  197. package/types/src/lib/runtime.d.mts +10 -0
  198. package/types/src/lib/schema.d.mts +8 -0
  199. package/types/src/lib/settings.d.mts +189 -0
  200. package/types/src/lib/source.d.mts +32 -0
  201. package/types/src/lib/sse.d.mts +61 -0
  202. package/types/src/lib/thinking.d.mts +155 -0
  203. package/types/src/lib/tools.d.mts +28 -0
  204. package/types/src/lib/toolsearch.d.mts +91 -0
  205. package/types/src/lib/transport.d.mts +18 -0
  206. package/types/src/lib/upstream-error.d.mts +43 -0
  207. package/types/src/lib/usage.d.mts +91 -0
  208. package/types/src/lib/warn.d.mts +26 -0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Convert an Anthropic Messages event stream into OpenAI `chat.completion.chunk` messages followed by `[DONE]`.
3
+ *
4
+ * `source` is SSE text/bytes, an iterable of `{ event, data }` pairs, or an iterable of bare event payloads. The
5
+ * result yields `{ data }` messages (chunk objects, then the string `"[DONE]"`); encode them with `lib/sse.mjs`.
6
+ * Usage is emitted as a final `choices: []` chunk when `state.includeUsage` is not false. An Anthropic `error`
7
+ * event, or a stream that ends before `message_stop`, becomes a `{ error }` chunk followed by `[DONE]`.
8
+ * @param {ReadableStream|AsyncIterable<unknown>|Iterable<unknown>|string|Uint8Array} source - Anthropic stream.
9
+ * @param {any} [state] - State from the request converter (model, `includeUsage`, tool-name map).
10
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
11
+ * @returns {AsyncGenerator<{ data: any|string }, void, undefined>} OpenAI chunks.
12
+ */
13
+ export function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): AsyncGenerator<{
14
+ data: any | string;
15
+ }, void, undefined>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Convert an OpenAI Chat Completions request body into an Anthropic Messages request body (for an OpenAI-protocol
3
+ * client talking to an Anthropic-protocol upstream).
4
+ *
5
+ * `system` and `developer` messages are hoisted into the top-level `system`; assistant reasoning is not forwarded
6
+ * (real Anthropic rejects thinking blocks without its own signatures); consecutive same-role turns are merged and
7
+ * tool results are grouped into one user turn with the results first, as Anthropic requires.
8
+ * @param {any} chatBody - OpenAI `POST /v1/chat/completions` body.
9
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
10
+ * @returns {Promise<{ body: any, state: any }>} Anthropic request body and conversion state.
11
+ * @throws {TranslatorError} For malformed requests, `n` above 1, unknown roles, or unknown fields when configured to error.
12
+ */
13
+ export function request(chatBody: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): Promise<{
14
+ body: any;
15
+ state: any;
16
+ }>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Convert a (non-streaming) OpenAI chat completion into an Anthropic message.
3
+ *
4
+ * Reasoning (`reasoning`, `reasoning_content`, or a leading `<think>` block when `thinkTags` is on, or a block closed by `</think>` when `thinkOpen` is also on) becomes a
5
+ * `thinking` block with a translator-marked signature (which carries the provider's reasoning fields when `reasoningRoundTrip` is on). Tool calls become `tool_use` blocks; arguments that are not
6
+ * a JSON object are passed through under `_raw_arguments` so the client reports a tool error the model can recover
7
+ * from.
8
+ * @param {any} completion - OpenAI `chat.completion` object.
9
+ * @param {any} [state] - State from the request converter (original model, tool-name map).
10
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
11
+ * @returns {any} Anthropic message.
12
+ * @throws {TranslatorError} When the completion has no choices.
13
+ */
14
+ export function response(completion: any, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Convert an OpenAI chat-completion stream into Anthropic Messages stream events.
3
+ *
4
+ * `source` is SSE text/bytes (string, `Uint8Array`, `ReadableStream`, async or sync iterable of either) or an
5
+ * iterable of already-parsed chunk objects. Handles reasoning (`reasoning`, `reasoning_content`, leading
6
+ * `<think>`), the three vLLM tool-call delta shapes (id+name first then argument fragments, name and arguments
7
+ * together, whole call at once), usage-only final chunks, `[DONE]`, mid-stream `{"error":...}` objects (answered
8
+ * with an Anthropic `error` event) and closing the iterator early (the upstream source is closed too). Pings are
9
+ * the SSE writer's job, not this converter's.
10
+ *
11
+ * Tool calls follow `settings.toolStreaming`. `buffer` (default) holds every call until the stream finishes and then emits
12
+ * each one, in index order, as a single complete `tool_use` block (start, one `input_json_delta`, stop); text and
13
+ * thinking stream immediately, so they appear before the tool blocks and no argument fragment can arrive too late.
14
+ * `stream` forwards argument fragments incrementally; calls that start while a tool block is streaming are buffered and
15
+ * emitted whole when it closes, and text that arrives meanwhile is held until the tool blocks are done.
16
+ * @param {ReadableStream|AsyncIterable<unknown>|Iterable<unknown>|string|Uint8Array} source - OpenAI stream.
17
+ * @param {any} [state] - State from the request converter (original model, tool-name map).
18
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
19
+ * @returns {AsyncGenerator<{ event: string, data: any }, void, undefined>} Anthropic events.
20
+ */
21
+ export function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): AsyncGenerator<{
22
+ event: string;
23
+ data: any;
24
+ }, void, undefined>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Bind every endpoint to a driver. `backend: "auto"` endpoints are probed (drivers tried in `info().order`, the generic
3
+ * driver matches last); endpoints with an explicit `backend` skip detection. Call it again to re-probe.
4
+ * @param {any} [options] - `{ network, signal }`. `network: false` skips all probing (auto endpoints fall back to the generic driver).
5
+ * @returns {Promise<any>} The `status()` result.
6
+ */
7
+ export function detect(options?: any): Promise<any>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/anthropic/detect.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview Anthropic driver: matches the api.anthropic.com host.
17
+ * @module @cldmv/llm-translator/driver/anthropic
18
+ */
19
+ /**
20
+ * Match by host name, no network access. Other Anthropic-compatible servers are selected with `backend: "anthropic"`.
21
+ * @param {any} context - `{ endpoint }`.
22
+ * @returns {{host: string} | null} Facts, or null when the endpoint is not api.anthropic.com.
23
+ */
24
+ export function detect({ endpoint }: any): {
25
+ host: string;
26
+ } | null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/anthropic/info.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview Anthropic driver: static facts about the backend.
17
+ * @module @cldmv/llm-translator/driver/anthropic
18
+ */
19
+ /**
20
+ * Describe the Anthropic driver (native Messages API upstream).
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, headers: Record<string,string>, paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ headers: Record<string, string>;
29
+ paths: Record<string, string>;
30
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * List the models the Anthropic API reports.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
4
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
5
+ */
6
+ export function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/anthropic/settings.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview Anthropic driver: translator settings.
17
+ * @module @cldmv/llm-translator/driver/anthropic
18
+ */
19
+ /**
20
+ * The Messages API needs no special settings; the converters use the library defaults.
21
+ * @returns {any} Partial settings (empty).
22
+ */
23
+ export function settings(): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Count tokens with the Anthropic API.
3
+ * @param {any} context - `{ endpoint, request, transport, signal, timeout }`.
4
+ * @returns {Promise<number | null>} Token count, or null when the API did not answer.
5
+ */
6
+ export function count({ endpoint, request, transport, signal, timeout }: any): Promise<number | null>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Probe `/v1/models` for reachability and the served model ids. Never returns null: this driver is the fallback.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout, probes }`.
4
+ * @returns {Promise<{reachable: boolean, models: string[]}>} Facts.
5
+ */
6
+ export function detect(context: any): Promise<{
7
+ reachable: boolean;
8
+ models: string[];
9
+ }>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Describe the generic OpenAI-compatible driver (matches last, after every specific driver).
3
+ * @returns {{name: string, protocol: string, order: number, auth: string, fields: string[], paths: Record<string,string>}} Driver facts.
4
+ */
5
+ export function info(): {
6
+ name: string;
7
+ protocol: string;
8
+ order: number;
9
+ auth: string;
10
+ fields: string[];
11
+ paths: Record<string, string>;
12
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * List the models the server reports.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
4
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
5
+ */
6
+ export function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Drop tool fields servers reject when no tools are present.
3
+ * @param {any} body - Chat Completions request body.
4
+ * @returns {any} Normalized body.
5
+ */
6
+ export function request(body: any): any;
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/compatible/settings.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview Generic OpenAI-compatible driver: conservative translator settings.
17
+ * @module @cldmv/llm-translator/driver/compatible
18
+ */
19
+ /**
20
+ * Settings that avoid fields unknown servers may reject. Override per upstream with `settings`.
21
+ * @returns {any} Partial settings.
22
+ */
23
+ export function settings(): any;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/deepseek/detect.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview DeepSeek driver: matches the api.deepseek.com host.
17
+ * @module @cldmv/llm-translator/driver/deepseek
18
+ */
19
+ /**
20
+ * Match by host name, no network access.
21
+ * @param {any} context - `{ endpoint }`.
22
+ * @returns {{host: string} | null} Facts, or null when the endpoint is not api.deepseek.com.
23
+ */
24
+ export function detect({ endpoint }: any): {
25
+ host: string;
26
+ } | null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Normalize to the nested OpenAI shape and explain DeepSeek's `reasoning_content` refusal.
3
+ * @param {number} status - HTTP status.
4
+ * @param {*} body - Parsed upstream error body.
5
+ * @returns {{error: {message: string, type: string | undefined, param: *, code: *}}} Nested error body.
6
+ */
7
+ export function error(status: number, body: any): {
8
+ error: {
9
+ message: string;
10
+ type: string | undefined;
11
+ param: any;
12
+ code: any;
13
+ };
14
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/deepseek/info.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview DeepSeek driver: static facts about the hosted DeepSeek API.
17
+ * @module @cldmv/llm-translator/driver/deepseek
18
+ */
19
+ /**
20
+ * Describe the DeepSeek driver.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ paths: Record<string, string>;
29
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Drop tool fields when there are no tools. In thinking mode also remove what DeepSeek rejects there: `tool_choice` of `required` or a named
3
+ * function (`auto` and `none` stay) and `logprobs`/`top_logprobs`; each removal is recorded in `state.dropped`.
4
+ * @param {any} body - Chat Completions request body.
5
+ * @param {any} [ctx] - `{ state }`.
6
+ * @returns {any} Normalized body.
7
+ */
8
+ export function request(body: any, ctx?: any): any;
@@ -0,0 +1,25 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/deepseek/settings.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview DeepSeek driver: translator settings for the hosted DeepSeek API.
17
+ * @module @cldmv/llm-translator/driver/deepseek
18
+ */
19
+ /**
20
+ * Settings for api.deepseek.com: reasoning in `reasoning_content`, no `top_k`, no prefill continuation, `json_object` response format only
21
+ * (no `json_schema`), text-only models, and usage on the last content chunk (read as for any server). Thinking is chosen by the model name, so no
22
+ * thinking switch is sent.
23
+ * @returns {any} Partial settings.
24
+ */
25
+ export function settings(): any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Normalize a streamed chunk: drop the duplicate reasoning block of `deepseek-legacy` and give tool calls without an id one.
3
+ * @param {any} chunk - Parsed `chat.completion.chunk`.
4
+ * @param {any} [ctx] - `{ state }`.
5
+ * @returns {any} Normalized chunk.
6
+ */
7
+ export function chunk(chunk: any, ctx?: any): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Probe an endpoint for `llama-server`.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout, probes }`.
4
+ * @returns {Promise<any | null>} Facts `{ models, build, vision }`, or null when the endpoint is not llama-server.
5
+ */
6
+ export function detect(context: any): Promise<any | null>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/llamacpp/flush.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview llama.cpp driver: end-of-stream flush for the chunk normalizer.
17
+ * @module @cldmv/llm-translator/driver/llamacpp
18
+ */
19
+ /**
20
+ * Release the content the chunk normalizer was still holding when the stream ended. While it waits to see whether the content opens with
21
+ * `<think>` it holds a partial prefix (`<`, `<thi`) or whitespace; if the stream ends there, that text is the answer and goes out as one
22
+ * more content chunk. Text held inside a repeated think block (`deepseek-legacy`) is the duplicate and is not released.
23
+ * @param {any} ctx - `{ state }`.
24
+ * @returns {any[]} Chunks to emit (empty when nothing is held).
25
+ */
26
+ export function flush(ctx: any): any[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/llamacpp/info.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview llama.cpp driver: static facts about `llama-server`.
17
+ * @module @cldmv/llm-translator/driver/llamacpp
18
+ */
19
+ /**
20
+ * Describe the llama.cpp driver.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ probes: string[];
29
+ fields: string[];
30
+ paths: Record<string, string>;
31
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Drop tool fields when there are no tools; send `parallel_tool_calls: true` with tools (llama-server leaves parallel calls off unless
3
+ * asked, and the converter only ever sends `false`); and rename vLLM's `repetition_penalty` to llama.cpp's `repeat_penalty`.
4
+ * @param {any} body - Chat Completions request body.
5
+ * @param {any} [ctx] - `{ settings }`.
6
+ * @returns {any} Normalized body.
7
+ */
8
+ export function request(body: any, ctx?: any): any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Give tool calls without an id one, and remove the duplicate reasoning that `--reasoning-format deepseek-legacy` leaves in `content`.
3
+ * `deepseek` puts reasoning in `reasoning_content` only; `none` leaves `<think>` tags in `content` only (read by `thinkTags`); `deepseek-legacy`
4
+ * does both, so a leading `<think>...</think>` is cut from `content` when `reasoning_content` already carries the reasoning.
5
+ * @param {any} body - Chat Completions response body.
6
+ * @returns {any} Normalized body.
7
+ */
8
+ export function response(body: any): any;
@@ -0,0 +1,27 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/llamacpp/settings.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview llama.cpp driver: translator settings for `llama-server`.
17
+ * @module @cldmv/llm-translator/driver/llamacpp
18
+ */
19
+ /**
20
+ * Settings for `llama-server`: reasoning comes back as `reasoning_content`, `top_k` is a native sampler, `max_tokens` is the output cap,
21
+ * thinking is toggled through `chat_template_kwargs` (needs `--jinja`) and `images` follows what `/props` says the model accepts.
22
+ * @param {{vision?: boolean}} [facts] - Detection facts.
23
+ * @returns {any} Partial settings.
24
+ */
25
+ export function settings(facts?: {
26
+ vision?: boolean;
27
+ }): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Probe an endpoint for Ollama.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout, probes }`.
4
+ * @returns {Promise<any | null>} Facts `{ version, models }`, or null when the endpoint is not Ollama.
5
+ */
6
+ export function detect(context: any): Promise<any | null>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/ollama/info.mjs
5
+ * @Date: 2026-10-31T14:00:00-07:00 (1793480400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-31T14:00:00-07:00 (1793480400)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview Ollama driver: static facts about Ollama's OpenAI-compatible `/v1` endpoint.
17
+ * @module @cldmv/llm-translator/driver/ollama
18
+ */
19
+ /**
20
+ * Describe the Ollama driver.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, probes: string[], paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ probes: string[];
29
+ paths: Record<string, string>;
30
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Remove `tool_choice`, `n` and `logit_bias` (recorded in `state.dropped`; with `tool_choice: "none"` the tools are removed too, so a forbidden tool call cannot happen), replace images given by URL with a note, and warn once per
3
+ * upstream when the prompt is estimated to exceed `contextWindow` (Ollama truncates silently).
4
+ * @param {any} body - Chat Completions request body.
5
+ * @param {any} [ctx] - `{ endpoint, settings, state, warn }`.
6
+ * @returns {any} Normalized body.
7
+ */
8
+ export function request(body: any, ctx?: any): any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Settings for Ollama: no `top_k` (not accepted on `/v1`), `max_tokens` as the output cap, no `parallel_tool_calls`, and a
3
+ * `contextWindow` of Ollama's default so a prompt that will be truncated is warned about. Raise `contextWindow` to the value the
4
+ * server really runs with (`OLLAMA_CONTEXT_LENGTH` or a Modelfile `num_ctx`).
5
+ * @returns {any} Partial settings.
6
+ */
7
+ export function settings(): any;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/openai/detect.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview OpenAI driver: matches the api.openai.com host.
17
+ * @module @cldmv/llm-translator/driver/openai
18
+ */
19
+ /**
20
+ * Match by host name, no network access.
21
+ * @param {any} context - `{ endpoint }`.
22
+ * @returns {{host: string} | null} Facts, or null when the endpoint is not api.openai.com.
23
+ */
24
+ export function detect({ endpoint }: any): {
25
+ host: string;
26
+ } | null;
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/openai/info.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:58:59-07:00 (1792958339)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview OpenAI driver: static facts about the backend.
17
+ * @module @cldmv/llm-translator/driver/openai
18
+ */
19
+ /**
20
+ * Describe the OpenAI driver.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ paths: Record<string, string>;
29
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * List the models the OpenAI API reports.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
4
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
5
+ */
6
+ export function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Drop tool fields OpenAI rejects when no tools are present.
3
+ * @param {any} body - Chat Completions request body.
4
+ * @returns {any} Normalized body.
5
+ */
6
+ export function request(body: any): any;
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/openai/settings.mjs
5
+ * @Date: 2026-10-25T12:29:36-07:00 (1792956576)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-25T12:59:00-07:00 (1792958340)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview OpenAI driver: translator settings for the hosted OpenAI API.
17
+ * @module @cldmv/llm-translator/driver/openai
18
+ */
19
+ /**
20
+ * Settings for api.openai.com: no `top_k`, `reasoning_effort` for thinking, no prefill continuation.
21
+ * @returns {any} Partial settings.
22
+ */
23
+ export function settings(): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Probe an endpoint for SGLang.
3
+ * @param {any} context - `{ endpoint, transport, signal, timeout, probes }`.
4
+ * @returns {Promise<any | null>} Facts `{ version, models, modelPath, reasoningParser, toolCallParser }`, or null when the endpoint is not SGLang.
5
+ */
6
+ export function detect(context: any): Promise<any | null>;