@cldmv/llm-translator 0.0.0-stage → 0.2.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 (153) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +185 -2
  3. package/dist/api/convert/anthropic/messages/to/openai/chat/request.mjs +17 -0
  4. package/dist/api/convert/anthropic/messages/to/openai/chat/response.mjs +2 -0
  5. package/dist/api/convert/anthropic/messages/to/openai/chat/stream.mjs +2 -0
  6. package/dist/api/convert/openai/chat/to/anthropic/messages/request.mjs +6 -0
  7. package/dist/api/convert/openai/chat/to/anthropic/messages/response.mjs +2 -0
  8. package/dist/api/convert/openai/chat/to/anthropic/messages/stream.mjs +2 -0
  9. package/dist/api/detect.mjs +2 -0
  10. package/dist/api/driver/anthropic/detect.mjs +2 -0
  11. package/dist/api/driver/anthropic/info.mjs +2 -0
  12. package/dist/api/driver/anthropic/model/list.mjs +2 -0
  13. package/dist/api/driver/anthropic/settings.mjs +2 -0
  14. package/dist/api/driver/anthropic/token/count.mjs +2 -0
  15. package/dist/api/driver/compatible/detect.mjs +2 -0
  16. package/dist/api/driver/compatible/info.mjs +2 -0
  17. package/dist/api/driver/compatible/model/list.mjs +2 -0
  18. package/dist/api/driver/compatible/request.mjs +2 -0
  19. package/dist/api/driver/compatible/settings.mjs +2 -0
  20. package/dist/api/driver/openai/detect.mjs +2 -0
  21. package/dist/api/driver/openai/info.mjs +2 -0
  22. package/dist/api/driver/openai/model/list.mjs +2 -0
  23. package/dist/api/driver/openai/request.mjs +2 -0
  24. package/dist/api/driver/openai/settings.mjs +2 -0
  25. package/dist/api/driver/vllm/detect.mjs +2 -0
  26. package/dist/api/driver/vllm/error.mjs +2 -0
  27. package/dist/api/driver/vllm/info.mjs +2 -0
  28. package/dist/api/driver/vllm/model/list.mjs +2 -0
  29. package/dist/api/driver/vllm/probe.mjs +2 -0
  30. package/dist/api/driver/vllm/request.mjs +2 -0
  31. package/dist/api/driver/vllm/settings.mjs +2 -0
  32. package/dist/api/driver/vllm/token/count.mjs +2 -0
  33. package/dist/api/error/build.mjs +2 -0
  34. package/dist/api/error/error.mjs +2 -0
  35. package/dist/api/model/list.mjs +2 -0
  36. package/dist/api/request.mjs +3 -0
  37. package/dist/api/response.mjs +2 -0
  38. package/dist/api/send.mjs +2 -0
  39. package/dist/api/server/plugin.mjs +2 -0
  40. package/dist/api/server/start.mjs +2 -0
  41. package/dist/api/server/stop.mjs +2 -0
  42. package/dist/api/sse/encode.mjs +4 -0
  43. package/dist/api/sse/parse.mjs +2 -0
  44. package/dist/api/sse/ping.mjs +2 -0
  45. package/dist/api/sse/write.mjs +2 -0
  46. package/dist/api/status.mjs +2 -0
  47. package/dist/api/stream.mjs +2 -0
  48. package/dist/api/token/count.mjs +2 -0
  49. package/dist/bin/llm-translator.mjs +3 -0
  50. package/dist/index.cjs +44 -0
  51. package/dist/index.mjs +2 -0
  52. package/dist/lib/arguments.mjs +2 -0
  53. package/dist/lib/capture.mjs +2 -0
  54. package/dist/lib/cli.mjs +29 -0
  55. package/dist/lib/config.mjs +2 -0
  56. package/dist/lib/documents.mjs +12 -0
  57. package/dist/lib/errors.mjs +2 -0
  58. package/dist/lib/estimate.mjs +2 -0
  59. package/dist/lib/finish.mjs +2 -0
  60. package/dist/lib/http.mjs +2 -0
  61. package/dist/lib/ids.mjs +2 -0
  62. package/dist/lib/images.mjs +2 -0
  63. package/dist/lib/models.mjs +2 -0
  64. package/dist/lib/normalize.mjs +2 -0
  65. package/dist/lib/passthrough.mjs +2 -0
  66. package/dist/lib/pdf.mjs +2 -0
  67. package/dist/lib/ping.mjs +2 -0
  68. package/dist/lib/route.mjs +2 -0
  69. package/dist/lib/routes.mjs +2 -0
  70. package/dist/lib/runtime.mjs +2 -0
  71. package/dist/lib/schema.mjs +2 -0
  72. package/dist/lib/settings.mjs +2 -0
  73. package/dist/lib/source.mjs +2 -0
  74. package/dist/lib/sse.mjs +10 -0
  75. package/dist/lib/thinking.mjs +2 -0
  76. package/dist/lib/transport.mjs +2 -0
  77. package/dist/lib/upstream-error.mjs +2 -0
  78. package/dist/lib/warn.mjs +2 -0
  79. package/package.json +127 -5
  80. package/types/src/api/convert/anthropic/messages/to/openai/chat/request.d.mts +28 -0
  81. package/types/src/api/convert/anthropic/messages/to/openai/chat/response.d.mts +24 -0
  82. package/types/src/api/convert/anthropic/messages/to/openai/chat/stream.d.mts +29 -0
  83. package/types/src/api/convert/openai/chat/to/anthropic/messages/request.d.mts +30 -0
  84. package/types/src/api/convert/openai/chat/to/anthropic/messages/response.d.mts +28 -0
  85. package/types/src/api/convert/openai/chat/to/anthropic/messages/stream.d.mts +38 -0
  86. package/types/src/api/detect.d.mts +21 -0
  87. package/types/src/api/driver/anthropic/detect.d.mts +26 -0
  88. package/types/src/api/driver/anthropic/info.d.mts +30 -0
  89. package/types/src/api/driver/anthropic/model/list.d.mts +20 -0
  90. package/types/src/api/driver/anthropic/settings.d.mts +23 -0
  91. package/types/src/api/driver/anthropic/token/count.d.mts +20 -0
  92. package/types/src/api/driver/compatible/detect.d.mts +23 -0
  93. package/types/src/api/driver/compatible/info.d.mts +29 -0
  94. package/types/src/api/driver/compatible/model/list.d.mts +20 -0
  95. package/types/src/api/driver/compatible/request.d.mts +20 -0
  96. package/types/src/api/driver/compatible/settings.d.mts +23 -0
  97. package/types/src/api/driver/openai/detect.d.mts +26 -0
  98. package/types/src/api/driver/openai/info.d.mts +29 -0
  99. package/types/src/api/driver/openai/model/list.d.mts +20 -0
  100. package/types/src/api/driver/openai/request.d.mts +20 -0
  101. package/types/src/api/driver/openai/settings.d.mts +23 -0
  102. package/types/src/api/driver/vllm/detect.d.mts +20 -0
  103. package/types/src/api/driver/vllm/error.d.mts +28 -0
  104. package/types/src/api/driver/vllm/info.d.mts +29 -0
  105. package/types/src/api/driver/vllm/model/list.d.mts +20 -0
  106. package/types/src/api/driver/vllm/probe.d.mts +39 -0
  107. package/types/src/api/driver/vllm/request.d.mts +22 -0
  108. package/types/src/api/driver/vllm/settings.d.mts +22 -0
  109. package/types/src/api/driver/vllm/token/count.d.mts +20 -0
  110. package/types/src/api/error/build.d.mts +26 -0
  111. package/types/src/api/error/error.d.mts +29 -0
  112. package/types/src/api/model/list.d.mts +21 -0
  113. package/types/src/api/request.d.mts +35 -0
  114. package/types/src/api/response.d.mts +22 -0
  115. package/types/src/api/send.d.mts +32 -0
  116. package/types/src/api/server/plugin.d.mts +24 -0
  117. package/types/src/api/server/start.d.mts +26 -0
  118. package/types/src/api/server/stop.d.mts +19 -0
  119. package/types/src/api/sse/encode.d.mts +26 -0
  120. package/types/src/api/sse/parse.d.mts +24 -0
  121. package/types/src/api/sse/ping.d.mts +30 -0
  122. package/types/src/api/sse/write.d.mts +26 -0
  123. package/types/src/api/status.d.mts +22 -0
  124. package/types/src/api/stream.d.mts +25 -0
  125. package/types/src/api/token/count.d.mts +24 -0
  126. package/types/src/index.d.mts +76 -0
  127. package/types/src/lib/arguments.d.mts +30 -0
  128. package/types/src/lib/capture.d.mts +28 -0
  129. package/types/src/lib/cli.d.mts +49 -0
  130. package/types/src/lib/config.d.mts +65 -0
  131. package/types/src/lib/documents.d.mts +43 -0
  132. package/types/src/lib/errors.d.mts +144 -0
  133. package/types/src/lib/estimate.d.mts +24 -0
  134. package/types/src/lib/finish.d.mts +73 -0
  135. package/types/src/lib/http.d.mts +58 -0
  136. package/types/src/lib/ids.d.mts +55 -0
  137. package/types/src/lib/images.d.mts +39 -0
  138. package/types/src/lib/models.d.mts +25 -0
  139. package/types/src/lib/normalize.d.mts +37 -0
  140. package/types/src/lib/passthrough.d.mts +22 -0
  141. package/types/src/lib/pdf.d.mts +67 -0
  142. package/types/src/lib/ping.d.mts +24 -0
  143. package/types/src/lib/route.d.mts +38 -0
  144. package/types/src/lib/routes.d.mts +22 -0
  145. package/types/src/lib/runtime.d.mts +24 -0
  146. package/types/src/lib/schema.d.mts +22 -0
  147. package/types/src/lib/settings.d.mts +175 -0
  148. package/types/src/lib/source.d.mts +32 -0
  149. package/types/src/lib/sse.d.mts +72 -0
  150. package/types/src/lib/thinking.d.mts +60 -0
  151. package/types/src/lib/transport.d.mts +31 -0
  152. package/types/src/lib/upstream-error.d.mts +57 -0
  153. package/types/src/lib/warn.d.mts +26 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/convert/openai/chat/to/anthropic/messages/request.mjs
5
+ * @Date: 2026-10-25T12:28:19-07:00 (1792956499)
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
+ * Convert an OpenAI Chat Completions request body into an Anthropic Messages request body (for an OpenAI-protocol
17
+ * client talking to an Anthropic-protocol upstream).
18
+ *
19
+ * `system` and `developer` messages are hoisted into the top-level `system`; assistant reasoning is not forwarded
20
+ * (real Anthropic rejects thinking blocks without its own signatures); consecutive same-role turns are merged and
21
+ * tool results are grouped into one user turn with the results first, as Anthropic requires.
22
+ * @param {any} chatBody - OpenAI `POST /v1/chat/completions` body.
23
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
24
+ * @returns {Promise<{ body: any, state: any }>} Anthropic request body and conversion state.
25
+ * @throws {TranslatorError} For malformed requests, `n` above 1, unknown roles, or unknown fields when configured to error.
26
+ */
27
+ export declare function request(chatBody: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): Promise<{
28
+ body: any;
29
+ state: any;
30
+ }>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/convert/openai/chat/to/anthropic/messages/response.mjs
5
+ * @Date: 2026-10-25T12:28:19-07:00 (1792956499)
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
+ * Convert a (non-streaming) OpenAI chat completion into an Anthropic message.
17
+ *
18
+ * Reasoning (`reasoning`, `reasoning_content`, or a leading `<think>` block when `thinkTags` is on) becomes a
19
+ * `thinking` block with a translator-marked signature. Tool calls become `tool_use` blocks; arguments that are not
20
+ * a JSON object are passed through under `_raw_arguments` so the client reports a tool error the model can recover
21
+ * from.
22
+ * @param {any} completion - OpenAI `chat.completion` object.
23
+ * @param {any} [state] - State from the request converter (original model, tool-name map).
24
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
25
+ * @returns {any} Anthropic message.
26
+ * @throws {TranslatorError} When the completion has no choices.
27
+ */
28
+ export declare function response(completion: any, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): any;
@@ -0,0 +1,38 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/convert/openai/chat/to/anthropic/messages/stream.mjs
5
+ * @Date: 2026-10-25T12:28:19-07:00 (1792956499)
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-25T13:31:27-07:00 (1792960287)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Convert an OpenAI chat-completion stream into Anthropic Messages stream events.
17
+ *
18
+ * `source` is SSE text/bytes (string, `Uint8Array`, `ReadableStream`, async or sync iterable of either) or an
19
+ * iterable of already-parsed chunk objects. Handles reasoning (`reasoning`, `reasoning_content`, leading
20
+ * `<think>`), the three vLLM tool-call delta shapes (id+name first then argument fragments, name and arguments
21
+ * together, whole call at once), usage-only final chunks, `[DONE]`, mid-stream `{"error":...}` objects (answered
22
+ * with an Anthropic `error` event) and closing the iterator early (the upstream source is closed too). Pings are
23
+ * the SSE writer's job, not this converter's.
24
+ *
25
+ * Tool calls follow `settings.toolStreaming`. `buffer` (default) holds every call until the stream finishes and then emits
26
+ * each one, in index order, as a single complete `tool_use` block (start, one `input_json_delta`, stop); text and
27
+ * thinking stream immediately, so they appear before the tool blocks and no argument fragment can arrive too late.
28
+ * `stream` forwards argument fragments incrementally; calls that start while a tool block is streaming are buffered and
29
+ * emitted whole when it closes, and text that arrives meanwhile is held until the tool blocks are done.
30
+ * @param {ReadableStream|AsyncIterable<unknown>|Iterable<unknown>|string|Uint8Array} source - OpenAI stream.
31
+ * @param {any} [state] - State from the request converter (original model, tool-name map).
32
+ * @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
33
+ * @returns {AsyncGenerator<{ event: string, data: any }, void, undefined>} Anthropic events.
34
+ */
35
+ export declare function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): AsyncGenerator<{
36
+ event: string;
37
+ data: any;
38
+ }, void, undefined>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/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
+ * Bind every endpoint to a driver. `backend: "auto"` endpoints are probed (drivers tried in `info().order`, the generic
17
+ * driver matches last); endpoints with an explicit `backend` skip detection. Call it again to re-probe.
18
+ * @param {any} [options] - `{ network, signal }`. `network: false` skips all probing (auto endpoints fall back to the generic driver).
19
+ * @returns {Promise<any>} The `status()` result.
20
+ */
21
+ export declare 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 declare 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 declare 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,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/anthropic/model/list.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
+ * List the models the Anthropic API reports.
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
19
+ */
20
+ export declare 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 declare function settings(): any;
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/anthropic/token/count.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
+ * Count tokens with the Anthropic API.
17
+ * @param {any} context - `{ endpoint, request, transport, signal, timeout }`.
18
+ * @returns {Promise<number | null>} Token count, or null when the API did not answer.
19
+ */
20
+ export declare function count({ endpoint, request, transport, signal, timeout }: any): Promise<number | null>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/compatible/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
+ * Probe `/v1/models` for reachability and the served model ids. Never returns null: this driver is the fallback.
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<{reachable: boolean, models: string[]}>} Facts.
19
+ */
20
+ export declare function detect(context: any): Promise<{
21
+ reachable: boolean;
22
+ models: string[];
23
+ }>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/compatible/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 Generic OpenAI-compatible driver: static facts about the backend.
17
+ * @module @cldmv/llm-translator/driver/compatible
18
+ */
19
+ /**
20
+ * Describe the generic OpenAI-compatible driver (matches last, after every specific driver).
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export declare function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ paths: Record<string, string>;
29
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/compatible/model/list.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
+ * List the models the server reports.
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
19
+ */
20
+ export declare function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/compatible/request.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
+ * Drop tool fields servers reject when no tools are present.
17
+ * @param {any} body - Chat Completions request body.
18
+ * @returns {any} Normalized body.
19
+ */
20
+ export declare 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 declare 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 declare 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 declare function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ paths: Record<string, string>;
29
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/openai/model/list.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
+ * List the models the OpenAI API reports.
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
19
+ */
20
+ export declare function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/openai/request.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
+ * Drop tool fields OpenAI rejects when no tools are present.
17
+ * @param {any} body - Chat Completions request body.
18
+ * @returns {any} Normalized body.
19
+ */
20
+ export declare 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 declare function settings(): any;
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/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:59:00-07:00 (1792958340)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Probe an endpoint for vLLM.
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<any | null>} Facts `{ version, models, maxModelLen }`, or null when the endpoint is not vLLM.
19
+ */
20
+ export declare function detect({ endpoint, transport, signal, timeout }: any): Promise<any | null>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/error.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
+ * Normalize old flat (`{message,type,code}`) and nested vLLM error bodies to the nested OpenAI shape.
17
+ * @param {number} status - HTTP status.
18
+ * @param {*} body - Parsed upstream error body.
19
+ * @returns {{error: {message: string, type: string | undefined, param: *, code: *}}} Nested error body.
20
+ */
21
+ export declare function error(status: number, body: any): {
22
+ error: {
23
+ message: string;
24
+ type: string | undefined;
25
+ param: any;
26
+ code: any;
27
+ };
28
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/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:59:00-07:00 (1792958340)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * @fileoverview vLLM driver: static facts about the backend.
17
+ * @module @cldmv/llm-translator/driver/vllm
18
+ */
19
+ /**
20
+ * Describe the vLLM driver.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, paths: Record<string,string>}} Driver facts.
22
+ */
23
+ export declare function info(): {
24
+ name: string;
25
+ protocol: string;
26
+ order: number;
27
+ auth: string;
28
+ paths: Record<string, string>;
29
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/model/list.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
+ * List the models the vLLM server serves (including `max_model_len`).
17
+ * @param {any} context - `{ endpoint, transport, signal, timeout }`.
18
+ * @returns {Promise<any[] | null>} Models, or null when unreachable.
19
+ */
20
+ export declare function list(context: any): Promise<any[] | null>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/probe.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
+ * Probe a vLLM server for facts that need a request.
17
+ *
18
+ * - `inlineSystem`: `POST /tokenize` with `[system, user, system, user]`. Success means the chat template tolerates system
19
+ * messages in the middle of a conversation (`keep`), failure means they must be folded into user turns (`user`).
20
+ * - `images`: a one-token chat completion with a 1x1 image. `false` when the server answers 400 that the model is not
21
+ * multimodal (so images and PDF page images are replaced by notes instead of failing every request), `true` when it
22
+ * accepts the request, and absent when the answer is inconclusive (timeouts, other errors).
23
+ * @param {{ endpoint: any, transport: Function, signal?: AbortSignal, timeout?: number, facts?: any, want?: { inlineSystem?: boolean, images?: boolean } }} context - Probe context. `want` selects the checks (`inlineSystem` defaults to on, `images` to off).
24
+ * @returns {Promise<{ inlineSystem?: "keep"|"user", images?: boolean }>} Probed settings.
25
+ */
26
+ export declare function probe({ endpoint, transport, signal, timeout, facts, want }: {
27
+ endpoint: any;
28
+ transport: Function;
29
+ signal?: AbortSignal;
30
+ timeout?: number;
31
+ facts?: any;
32
+ want?: {
33
+ inlineSystem?: boolean;
34
+ images?: boolean;
35
+ };
36
+ }): Promise<{
37
+ inlineSystem?: "keep" | "user";
38
+ images?: boolean;
39
+ }>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/request.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
+ * Drop tool fields vLLM rejects when no tools are present, and clamp `reasoning_effort` to what vLLM accepts
17
+ * (`xhigh` and `max` become `high`) unless the `effortPassthrough` setting is on.
18
+ * @param {any} body - Chat Completions request body.
19
+ * @param {any} [ctx] - `{ settings }`.
20
+ * @returns {any} Normalized body.
21
+ */
22
+ export declare function request(body: any, ctx?: any): any;