@cldmv/llm-translator 0.1.0 → 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 (151) hide show
  1. package/README.md +176 -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/openai/detect.mjs +2 -0
  20. package/dist/api/driver/openai/info.mjs +2 -0
  21. package/dist/api/driver/openai/model/list.mjs +2 -0
  22. package/dist/api/driver/openai/request.mjs +2 -0
  23. package/dist/api/driver/openai/settings.mjs +2 -0
  24. package/dist/api/driver/vllm/detect.mjs +2 -0
  25. package/dist/api/driver/vllm/error.mjs +2 -0
  26. package/dist/api/driver/vllm/info.mjs +2 -0
  27. package/dist/api/driver/vllm/model/list.mjs +2 -0
  28. package/dist/api/driver/vllm/probe.mjs +2 -0
  29. package/dist/api/driver/vllm/request.mjs +2 -0
  30. package/dist/api/driver/vllm/settings.mjs +2 -0
  31. package/dist/api/driver/vllm/token/count.mjs +2 -0
  32. package/dist/api/error/build.mjs +2 -0
  33. package/dist/api/error/error.mjs +2 -0
  34. package/dist/api/model/list.mjs +2 -0
  35. package/dist/api/request.mjs +3 -0
  36. package/dist/api/response.mjs +2 -0
  37. package/dist/api/send.mjs +2 -0
  38. package/dist/api/server/plugin.mjs +2 -0
  39. package/dist/api/server/start.mjs +2 -0
  40. package/dist/api/server/stop.mjs +2 -0
  41. package/dist/api/sse/encode.mjs +4 -0
  42. package/dist/api/sse/parse.mjs +2 -0
  43. package/dist/api/sse/ping.mjs +2 -0
  44. package/dist/api/sse/write.mjs +2 -0
  45. package/dist/api/status.mjs +2 -0
  46. package/dist/api/stream.mjs +2 -0
  47. package/dist/api/token/count.mjs +2 -0
  48. package/dist/bin/llm-translator.mjs +3 -0
  49. package/dist/index.mjs +1 -1
  50. package/dist/lib/arguments.mjs +2 -0
  51. package/dist/lib/capture.mjs +2 -0
  52. package/dist/lib/cli.mjs +29 -0
  53. package/dist/lib/config.mjs +2 -0
  54. package/dist/lib/documents.mjs +12 -0
  55. package/dist/lib/errors.mjs +2 -0
  56. package/dist/lib/estimate.mjs +2 -0
  57. package/dist/lib/finish.mjs +2 -0
  58. package/dist/lib/http.mjs +2 -0
  59. package/dist/lib/ids.mjs +2 -0
  60. package/dist/lib/images.mjs +2 -0
  61. package/dist/lib/models.mjs +2 -0
  62. package/dist/lib/normalize.mjs +2 -0
  63. package/dist/lib/passthrough.mjs +2 -0
  64. package/dist/lib/pdf.mjs +2 -0
  65. package/dist/lib/ping.mjs +2 -0
  66. package/dist/lib/route.mjs +2 -0
  67. package/dist/lib/routes.mjs +2 -0
  68. package/dist/lib/runtime.mjs +2 -0
  69. package/dist/lib/schema.mjs +2 -0
  70. package/dist/lib/settings.mjs +2 -0
  71. package/dist/lib/source.mjs +2 -0
  72. package/dist/lib/sse.mjs +10 -0
  73. package/dist/lib/thinking.mjs +2 -0
  74. package/dist/lib/transport.mjs +2 -0
  75. package/dist/lib/upstream-error.mjs +2 -0
  76. package/dist/lib/warn.mjs +2 -0
  77. package/package.json +30 -5
  78. package/types/src/api/convert/anthropic/messages/to/openai/chat/request.d.mts +28 -0
  79. package/types/src/api/convert/anthropic/messages/to/openai/chat/response.d.mts +24 -0
  80. package/types/src/api/convert/anthropic/messages/to/openai/chat/stream.d.mts +29 -0
  81. package/types/src/api/convert/openai/chat/to/anthropic/messages/request.d.mts +30 -0
  82. package/types/src/api/convert/openai/chat/to/anthropic/messages/response.d.mts +28 -0
  83. package/types/src/api/convert/openai/chat/to/anthropic/messages/stream.d.mts +38 -0
  84. package/types/src/api/detect.d.mts +21 -0
  85. package/types/src/api/driver/anthropic/detect.d.mts +26 -0
  86. package/types/src/api/driver/anthropic/info.d.mts +30 -0
  87. package/types/src/api/driver/anthropic/model/list.d.mts +20 -0
  88. package/types/src/api/driver/anthropic/settings.d.mts +23 -0
  89. package/types/src/api/driver/anthropic/token/count.d.mts +20 -0
  90. package/types/src/api/driver/compatible/detect.d.mts +23 -0
  91. package/types/src/api/driver/compatible/info.d.mts +29 -0
  92. package/types/src/api/driver/compatible/model/list.d.mts +20 -0
  93. package/types/src/api/driver/compatible/request.d.mts +20 -0
  94. package/types/src/api/driver/compatible/settings.d.mts +23 -0
  95. package/types/src/api/driver/openai/detect.d.mts +26 -0
  96. package/types/src/api/driver/openai/info.d.mts +29 -0
  97. package/types/src/api/driver/openai/model/list.d.mts +20 -0
  98. package/types/src/api/driver/openai/request.d.mts +20 -0
  99. package/types/src/api/driver/openai/settings.d.mts +23 -0
  100. package/types/src/api/driver/vllm/detect.d.mts +20 -0
  101. package/types/src/api/driver/vllm/error.d.mts +28 -0
  102. package/types/src/api/driver/vllm/info.d.mts +29 -0
  103. package/types/src/api/driver/vllm/model/list.d.mts +20 -0
  104. package/types/src/api/driver/vllm/probe.d.mts +39 -0
  105. package/types/src/api/driver/vllm/request.d.mts +22 -0
  106. package/types/src/api/driver/vllm/settings.d.mts +22 -0
  107. package/types/src/api/driver/vllm/token/count.d.mts +20 -0
  108. package/types/src/api/error/build.d.mts +26 -0
  109. package/types/src/api/error/error.d.mts +29 -0
  110. package/types/src/api/model/list.d.mts +21 -0
  111. package/types/src/api/request.d.mts +35 -0
  112. package/types/src/api/response.d.mts +22 -0
  113. package/types/src/api/send.d.mts +32 -0
  114. package/types/src/api/server/plugin.d.mts +24 -0
  115. package/types/src/api/server/start.d.mts +26 -0
  116. package/types/src/api/server/stop.d.mts +19 -0
  117. package/types/src/api/sse/encode.d.mts +26 -0
  118. package/types/src/api/sse/parse.d.mts +24 -0
  119. package/types/src/api/sse/ping.d.mts +30 -0
  120. package/types/src/api/sse/write.d.mts +26 -0
  121. package/types/src/api/status.d.mts +22 -0
  122. package/types/src/api/stream.d.mts +25 -0
  123. package/types/src/api/token/count.d.mts +24 -0
  124. package/types/src/index.d.mts +61 -4
  125. package/types/src/lib/arguments.d.mts +30 -0
  126. package/types/src/lib/capture.d.mts +28 -0
  127. package/types/src/lib/cli.d.mts +49 -0
  128. package/types/src/lib/config.d.mts +65 -0
  129. package/types/src/lib/documents.d.mts +43 -0
  130. package/types/src/lib/errors.d.mts +144 -0
  131. package/types/src/lib/estimate.d.mts +24 -0
  132. package/types/src/lib/finish.d.mts +73 -0
  133. package/types/src/lib/http.d.mts +58 -0
  134. package/types/src/lib/ids.d.mts +55 -0
  135. package/types/src/lib/images.d.mts +39 -0
  136. package/types/src/lib/models.d.mts +25 -0
  137. package/types/src/lib/normalize.d.mts +37 -0
  138. package/types/src/lib/passthrough.d.mts +22 -0
  139. package/types/src/lib/pdf.d.mts +67 -0
  140. package/types/src/lib/ping.d.mts +24 -0
  141. package/types/src/lib/route.d.mts +38 -0
  142. package/types/src/lib/routes.d.mts +22 -0
  143. package/types/src/lib/runtime.d.mts +24 -0
  144. package/types/src/lib/schema.d.mts +22 -0
  145. package/types/src/lib/settings.d.mts +175 -0
  146. package/types/src/lib/source.d.mts +32 -0
  147. package/types/src/lib/sse.d.mts +72 -0
  148. package/types/src/lib/thinking.d.mts +60 -0
  149. package/types/src/lib/transport.d.mts +31 -0
  150. package/types/src/lib/upstream-error.d.mts +57 -0
  151. package/types/src/lib/warn.d.mts +26 -0
@@ -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;
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/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
+ * Settings for a vLLM server. An unknown version is treated as the latest release, except `thinkingBudget`, which needs a known version of 0.19.0 or later.
17
+ * @param {{version?: string}} [facts] - Detection facts (or the configured version).
18
+ * @returns {any} Partial settings.
19
+ */
20
+ export declare function settings(facts?: {
21
+ version?: string;
22
+ }): any;
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/driver/vllm/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:59:00-07:00 (1792958340)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Count the prompt tokens of a converted Chat Completions request with the server's own tokenizer and chat template.
17
+ * @param {any} context - `{ endpoint, request, transport, signal, timeout }`.
18
+ * @returns {Promise<number | null>} Token count, or null when the server did not answer (caller falls back to an estimate).
19
+ */
20
+ export declare function count({ endpoint, request, transport, signal, timeout }: any): Promise<number | null>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/error/build.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
+ * Build `{ status, headers, body }` in the client protocol.
17
+ * @param {number} status - HTTP status.
18
+ * @param {string} message - Error message.
19
+ * @param {any} [options] - `{ type, code, param, front }` overrides; `type` is an Anthropic error type (mapped for the OpenAI front) and `front` defaults to the configured front.
20
+ * @returns {{status: number, headers: Record<string,string>, body: any}} Client-shaped error reply.
21
+ */
22
+ export declare function build(status: number, message: string, options?: any): {
23
+ status: number;
24
+ headers: Record<string, string>;
25
+ body: any;
26
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/error/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
+ * Convert an upstream error reply into `{ status, headers, body }` in the client protocol. Context-window overflows
17
+ * become Anthropic's "prompt is too long: N tokens > MAX maximum" (which triggers Claude Code's compaction); status codes
18
+ * map 1:1; `retry-after` is kept.
19
+ * @param {number} status - Upstream HTTP status.
20
+ * @param {*} upstreamBody - Parsed upstream error body (object or text).
21
+ * @param {Record<string,string>} [headers] - Lowercase upstream response headers.
22
+ * @param {any} [state] - The `state` returned by `request` (selects the driver normalizer and native handling).
23
+ * @returns {Promise<{status: number, headers: Record<string,string>, body: any}>} Client-shaped error reply.
24
+ */
25
+ export default function error(status: number, upstreamBody: any, headers?: Record<string, string>, state?: any): Promise<{
26
+ status: number;
27
+ headers: Record<string, string>;
28
+ body: any;
29
+ }>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/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 upstreams serve (live when the driver can, else detection/config data), plus the configured aliases,
17
+ * in the client protocol's list shape (Anthropic `{data:[{type:"model",...}]}` or OpenAI `{object:"list",data:[...]}`).
18
+ * @param {any} [options] - `{ signal, front }`.
19
+ * @returns {Promise<any>} Model list.
20
+ */
21
+ export declare function list(options?: any): Promise<any>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/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
+ * Route a client request body (in the configured `front` protocol) to an upstream and convert it to that upstream's
17
+ * protocol. Does no I/O.
18
+ * @param {any} body - Client request body (Anthropic Messages or OpenAI Chat Completions, per `front`).
19
+ * @param {any} [options] - `{ front, headers, clientHeaders, filter, images }`. `front` overrides the configured front for this call, `headers` are extra upstream headers, `clientHeaders` are client headers forwarded only to a native Anthropic upstream, `filter` restricts a forwarded OpenAI body to known fields (default: the `passthroughFilter` setting, off), `images: false` sends the request without images (used by the image fallback).
20
+ * @returns {Promise<{upstream: string, method: string, url: string, path: string, headers: Record<string,string>, body: any, state: any, images: {sent: boolean, retry: boolean, key: string}}>} The upstream request and the state `response`/`stream`/`error` need. `images` tells `send` whether the body carries images, whether a refusal may be retried without them and the key under which a refusal is remembered.
21
+ */
22
+ export declare function request(body: any, options?: any): Promise<{
23
+ upstream: string;
24
+ method: string;
25
+ url: string;
26
+ path: string;
27
+ headers: Record<string, string>;
28
+ body: any;
29
+ state: any;
30
+ images: {
31
+ sent: boolean;
32
+ retry: boolean;
33
+ key: string;
34
+ };
35
+ }>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/response.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:01-07:00 (1792958341)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Convert an upstream response body to the client protocol (a no-op apart from driver normalization and restoring the
17
+ * client's model name when front and upstream speak the same protocol).
18
+ * @param {any} upstreamBody - Parsed upstream JSON body.
19
+ * @param {any} state - The `state` returned by `request`.
20
+ * @returns {Promise<any>} Response body in the client protocol.
21
+ */
22
+ export declare function response(upstreamBody: any, state: any): Promise<any>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/send.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:01-07:00 (1792958341)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Send a client request to the routed upstream and return the client-protocol reply.
17
+ * @param {any} body - Client request body (per `front`).
18
+ * @param {any} [options] - `{ signal, front, headers, clientHeaders, filter }`: abort signal for the upstream call, per-call front, extra upstream headers, client headers forwarded to a native Anthropic upstream, and the pass-through body filter (see `request`).
19
+ * @returns {Promise<{status: number, headers: Record<string,string>, body: any} | {status: number, headers: Record<string,string>, stream: AsyncIterable<{event?: string, data: *}>}>} A JSON reply, or a stream reply when the client asked for streaming and the upstream accepted.
20
+ */
21
+ export declare function send(body: any, options?: any): Promise<{
22
+ status: number;
23
+ headers: Record<string, string>;
24
+ body: any;
25
+ } | {
26
+ status: number;
27
+ headers: Record<string, string>;
28
+ stream: AsyncIterable<{
29
+ event?: string;
30
+ data: any;
31
+ }>;
32
+ }>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/server/plugin.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:01-07:00 (1792958341)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Fastify plugin. Anthropic front: `POST /v1/messages`, `POST /v1/messages/count_tokens`, `GET /v1/models`, `GET|HEAD /`
17
+ * and `/api/hello`. OpenAI front: `POST /v1/chat/completions`, `GET /v1/models`, `GET|HEAD /`. Responses stream as
18
+ * `text/event-stream` with keep-alive pings; a client disconnect aborts the upstream request. Register it with
19
+ * `app.register(api.server.plugin, { apiKey })`.
20
+ * @param {any} fastify - Fastify instance.
21
+ * @param {any} [options] - `{ front, apiKey, bodyLimit }`. `front` sets the protocol this plugin instance serves (default: the translator's front, other plugin instances and `api.send` are unaffected); `apiKey` (string or array) is required from clients. Forwarded OpenAI bodies are restricted to known fields unless the `passthroughFilter` setting is `false`.
22
+ * @returns {Promise<void>} Resolves once the routes are registered.
23
+ */
24
+ export declare function plugin(fastify: any, options?: any): Promise<void>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/llm-translator
4
+ * @Filename: /src/api/server/start.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-25T14:00:49-07:00 (1792962049)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+ /**
16
+ * Start an HTTP server in front of the translator. Fastify is an optional peer dependency and is imported here.
17
+ * @param {any} [options] - `{ host = "127.0.0.1", port = 8787, front, apiKey, bodyLimit, logger, allowUnauthenticated }`. Listening on a non-loopback address without an `apiKey` is refused unless `allowUnauthenticated` is true.
18
+ * @returns {Promise<{url: string, host: string, port: number, app: any, close: () => Promise<void>}>} Running server handle.
19
+ */
20
+ export declare function start(options?: any): Promise<{
21
+ url: string;
22
+ host: string;
23
+ port: number;
24
+ app: any;
25
+ close: () => Promise<void>;
26
+ }>;