scoutline 0.1.0 → 0.6.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 (242) hide show
  1. package/README.md +394 -7
  2. package/bin/scoutline.js +36 -15
  3. package/dist/capabilities/diagnostics.d.ts +135 -0
  4. package/dist/capabilities/diagnostics.d.ts.map +1 -0
  5. package/dist/capabilities/diagnostics.js +139 -0
  6. package/dist/capabilities/diagnostics.js.map +1 -0
  7. package/dist/capabilities/quota.d.ts +99 -0
  8. package/dist/capabilities/quota.d.ts.map +1 -0
  9. package/dist/capabilities/quota.js +129 -0
  10. package/dist/capabilities/quota.js.map +1 -0
  11. package/dist/capabilities/reader.d.ts +227 -0
  12. package/dist/capabilities/reader.d.ts.map +1 -0
  13. package/dist/capabilities/reader.js +100 -0
  14. package/dist/capabilities/reader.js.map +1 -0
  15. package/dist/capabilities/repository.d.ts +221 -0
  16. package/dist/capabilities/repository.d.ts.map +1 -0
  17. package/dist/capabilities/repository.js +172 -0
  18. package/dist/capabilities/repository.js.map +1 -0
  19. package/dist/capabilities/search.d.ts +110 -0
  20. package/dist/capabilities/search.d.ts.map +1 -0
  21. package/dist/capabilities/search.js +21 -0
  22. package/dist/capabilities/search.js.map +1 -0
  23. package/dist/capabilities/vision.d.ts +156 -0
  24. package/dist/capabilities/vision.d.ts.map +1 -0
  25. package/dist/capabilities/vision.js +111 -0
  26. package/dist/capabilities/vision.js.map +1 -0
  27. package/dist/command-invocation.d.ts +58 -0
  28. package/dist/command-invocation.d.ts.map +1 -0
  29. package/dist/command-invocation.js +95 -0
  30. package/dist/command-invocation.js.map +1 -0
  31. package/dist/commands/cache.d.ts +106 -0
  32. package/dist/commands/cache.d.ts.map +1 -0
  33. package/dist/commands/cache.js +203 -0
  34. package/dist/commands/cache.js.map +1 -0
  35. package/dist/commands/code.d.ts +11 -4
  36. package/dist/commands/code.d.ts.map +1 -1
  37. package/dist/commands/code.js +16 -42
  38. package/dist/commands/code.js.map +1 -1
  39. package/dist/commands/doctor.d.ts +69 -3
  40. package/dist/commands/doctor.d.ts.map +1 -1
  41. package/dist/commands/doctor.js +179 -52
  42. package/dist/commands/doctor.js.map +1 -1
  43. package/dist/commands/quota.d.ts +45 -3
  44. package/dist/commands/quota.d.ts.map +1 -1
  45. package/dist/commands/quota.js +116 -60
  46. package/dist/commands/quota.js.map +1 -1
  47. package/dist/commands/read.d.ts +76 -2
  48. package/dist/commands/read.d.ts.map +1 -1
  49. package/dist/commands/read.js +260 -121
  50. package/dist/commands/read.js.map +1 -1
  51. package/dist/commands/repo.d.ts +55 -4
  52. package/dist/commands/repo.d.ts.map +1 -1
  53. package/dist/commands/repo.js +115 -172
  54. package/dist/commands/repo.js.map +1 -1
  55. package/dist/commands/repository-explorer.d.ts +147 -0
  56. package/dist/commands/repository-explorer.d.ts.map +1 -0
  57. package/dist/commands/repository-explorer.js +550 -0
  58. package/dist/commands/repository-explorer.js.map +1 -0
  59. package/dist/commands/search.d.ts +27 -2
  60. package/dist/commands/search.d.ts.map +1 -1
  61. package/dist/commands/search.js +95 -103
  62. package/dist/commands/search.js.map +1 -1
  63. package/dist/commands/tools.d.ts +9 -3
  64. package/dist/commands/tools.d.ts.map +1 -1
  65. package/dist/commands/tools.js +29 -59
  66. package/dist/commands/tools.js.map +1 -1
  67. package/dist/commands/vision.d.ts +35 -9
  68. package/dist/commands/vision.d.ts.map +1 -1
  69. package/dist/commands/vision.js +184 -131
  70. package/dist/commands/vision.js.map +1 -1
  71. package/dist/index.d.ts +62 -1
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +580 -223
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/cache.d.ts +178 -12
  76. package/dist/lib/cache.d.ts.map +1 -1
  77. package/dist/lib/cache.js +377 -39
  78. package/dist/lib/cache.js.map +1 -1
  79. package/dist/lib/code-mode.d.ts +13 -0
  80. package/dist/lib/code-mode.d.ts.map +1 -1
  81. package/dist/lib/code-mode.js +26 -6
  82. package/dist/lib/code-mode.js.map +1 -1
  83. package/dist/lib/config.d.ts.map +1 -1
  84. package/dist/lib/config.js +15 -18
  85. package/dist/lib/config.js.map +1 -1
  86. package/dist/lib/errors.d.ts +89 -11
  87. package/dist/lib/errors.d.ts.map +1 -1
  88. package/dist/lib/errors.js +168 -21
  89. package/dist/lib/errors.js.map +1 -1
  90. package/dist/lib/execution.d.ts +190 -0
  91. package/dist/lib/execution.d.ts.map +1 -0
  92. package/dist/lib/execution.js +383 -0
  93. package/dist/lib/execution.js.map +1 -0
  94. package/dist/lib/index.d.ts +10 -2
  95. package/dist/lib/index.d.ts.map +1 -1
  96. package/dist/lib/index.js +10 -2
  97. package/dist/lib/index.js.map +1 -1
  98. package/dist/lib/mcp-client.d.ts +75 -16
  99. package/dist/lib/mcp-client.d.ts.map +1 -1
  100. package/dist/lib/mcp-client.js +173 -108
  101. package/dist/lib/mcp-client.js.map +1 -1
  102. package/dist/lib/mcp-config.d.ts +17 -0
  103. package/dist/lib/mcp-config.d.ts.map +1 -1
  104. package/dist/lib/mcp-config.js +29 -0
  105. package/dist/lib/mcp-config.js.map +1 -1
  106. package/dist/lib/monitor-client.d.ts +17 -3
  107. package/dist/lib/monitor-client.d.ts.map +1 -1
  108. package/dist/lib/monitor-client.js +23 -69
  109. package/dist/lib/monitor-client.js.map +1 -1
  110. package/dist/lib/output.d.ts +53 -7
  111. package/dist/lib/output.d.ts.map +1 -1
  112. package/dist/lib/output.js +126 -39
  113. package/dist/lib/output.js.map +1 -1
  114. package/dist/lib/redact.d.ts +62 -3
  115. package/dist/lib/redact.d.ts.map +1 -1
  116. package/dist/lib/redact.js +165 -31
  117. package/dist/lib/redact.js.map +1 -1
  118. package/dist/lib/tool-cache.d.ts +86 -0
  119. package/dist/lib/tool-cache.d.ts.map +1 -0
  120. package/dist/lib/tool-cache.js +123 -0
  121. package/dist/lib/tool-cache.js.map +1 -0
  122. package/dist/lib/tty.d.ts +7 -20
  123. package/dist/lib/tty.d.ts.map +1 -1
  124. package/dist/lib/tty.js +51 -30
  125. package/dist/lib/tty.js.map +1 -1
  126. package/dist/node-command-invocation-adapter.d.ts +28 -0
  127. package/dist/node-command-invocation-adapter.d.ts.map +1 -0
  128. package/dist/node-command-invocation-adapter.js +88 -0
  129. package/dist/node-command-invocation-adapter.js.map +1 -0
  130. package/dist/providers/minimax/adapter.d.ts +49 -0
  131. package/dist/providers/minimax/adapter.d.ts.map +1 -0
  132. package/dist/providers/minimax/adapter.js +450 -0
  133. package/dist/providers/minimax/adapter.js.map +1 -0
  134. package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
  135. package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
  136. package/dist/providers/minimax/coding-plan-client.js +204 -0
  137. package/dist/providers/minimax/coding-plan-client.js.map +1 -0
  138. package/dist/providers/minimax/config.d.ts +32 -0
  139. package/dist/providers/minimax/config.d.ts.map +1 -0
  140. package/dist/providers/minimax/config.js +84 -0
  141. package/dist/providers/minimax/config.js.map +1 -0
  142. package/dist/providers/minimax/media.d.ts +88 -0
  143. package/dist/providers/minimax/media.d.ts.map +1 -0
  144. package/dist/providers/minimax/media.js +232 -0
  145. package/dist/providers/minimax/media.js.map +1 -0
  146. package/dist/providers/minimax/quota-client.d.ts +44 -0
  147. package/dist/providers/minimax/quota-client.d.ts.map +1 -0
  148. package/dist/providers/minimax/quota-client.js +83 -0
  149. package/dist/providers/minimax/quota-client.js.map +1 -0
  150. package/dist/providers/minimax/quota.d.ts +48 -0
  151. package/dist/providers/minimax/quota.d.ts.map +1 -0
  152. package/dist/providers/minimax/quota.js +120 -0
  153. package/dist/providers/minimax/quota.js.map +1 -0
  154. package/dist/providers/minimax/sdk-client.d.ts +29 -0
  155. package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
  156. package/dist/providers/minimax/sdk-client.js +50 -0
  157. package/dist/providers/minimax/sdk-client.js.map +1 -0
  158. package/dist/providers/minimax/vision-attestations.d.ts +52 -0
  159. package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
  160. package/dist/providers/minimax/vision-attestations.js +79 -0
  161. package/dist/providers/minimax/vision-attestations.js.map +1 -0
  162. package/dist/providers/minimax/vision-conformance.d.ts +186 -0
  163. package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
  164. package/dist/providers/minimax/vision-conformance.js +371 -0
  165. package/dist/providers/minimax/vision-conformance.js.map +1 -0
  166. package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
  167. package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
  168. package/dist/providers/minimax/vision-mappings/chart.js +55 -0
  169. package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
  170. package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
  171. package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
  172. package/dist/providers/minimax/vision-mappings/common.js +75 -0
  173. package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
  174. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
  175. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
  176. package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
  177. package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
  178. package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
  179. package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
  180. package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
  181. package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
  182. package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
  183. package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
  184. package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
  185. package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
  186. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
  187. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
  188. package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
  189. package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
  190. package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
  191. package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
  192. package/dist/providers/minimax/vision-mappings.generated.js +29 -0
  193. package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
  194. package/dist/providers/minimax/vision-revisions.d.ts +29 -0
  195. package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
  196. package/dist/providers/minimax/vision-revisions.js +34 -0
  197. package/dist/providers/minimax/vision-revisions.js.map +1 -0
  198. package/dist/providers/registry.d.ts +36 -0
  199. package/dist/providers/registry.d.ts.map +1 -0
  200. package/dist/providers/registry.js +45 -0
  201. package/dist/providers/registry.js.map +1 -0
  202. package/dist/providers/selection.d.ts +44 -0
  203. package/dist/providers/selection.d.ts.map +1 -0
  204. package/dist/providers/selection.js +85 -0
  205. package/dist/providers/selection.js.map +1 -0
  206. package/dist/providers/types.d.ts +281 -0
  207. package/dist/providers/types.d.ts.map +1 -0
  208. package/dist/providers/types.js +127 -0
  209. package/dist/providers/types.js.map +1 -0
  210. package/dist/providers/zai/adapter.d.ts +35 -0
  211. package/dist/providers/zai/adapter.d.ts.map +1 -0
  212. package/dist/providers/zai/adapter.js +685 -0
  213. package/dist/providers/zai/adapter.js.map +1 -0
  214. package/dist/providers/zai/credentials.d.ts +38 -0
  215. package/dist/providers/zai/credentials.d.ts.map +1 -0
  216. package/dist/providers/zai/credentials.js +60 -0
  217. package/dist/providers/zai/credentials.js.map +1 -0
  218. package/dist/providers/zai/encoded-error.d.ts +90 -0
  219. package/dist/providers/zai/encoded-error.d.ts.map +1 -0
  220. package/dist/providers/zai/encoded-error.js +169 -0
  221. package/dist/providers/zai/encoded-error.js.map +1 -0
  222. package/dist/providers/zai/media.d.ts +38 -0
  223. package/dist/providers/zai/media.d.ts.map +1 -0
  224. package/dist/providers/zai/media.js +107 -0
  225. package/dist/providers/zai/media.js.map +1 -0
  226. package/dist/providers/zai/monitor-client.d.ts +53 -0
  227. package/dist/providers/zai/monitor-client.d.ts.map +1 -0
  228. package/dist/providers/zai/monitor-client.js +117 -0
  229. package/dist/providers/zai/monitor-client.js.map +1 -0
  230. package/dist/providers/zai/quota.d.ts +47 -0
  231. package/dist/providers/zai/quota.d.ts.map +1 -0
  232. package/dist/providers/zai/quota.js +127 -0
  233. package/dist/providers/zai/quota.js.map +1 -0
  234. package/dist/providers/zai/reader.d.ts +82 -0
  235. package/dist/providers/zai/reader.d.ts.map +1 -0
  236. package/dist/providers/zai/reader.js +490 -0
  237. package/dist/providers/zai/reader.js.map +1 -0
  238. package/dist/providers/zai/repository.d.ts +76 -0
  239. package/dist/providers/zai/repository.d.ts.map +1 -0
  240. package/dist/providers/zai/repository.js +715 -0
  241. package/dist/providers/zai/repository.js.map +1 -0
  242. package/package.json +11 -6
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MiniMax Coding Plan direct transport (DESIGN.md §12, P4-02).
3
+ *
4
+ * The pinned `mmx-cli/sdk` 1.0.16 does not preserve an arbitrary
5
+ * configured host for the Coding Plan endpoints. This module performs
6
+ * direct POSTs against the two `/v1/coding_plan/*` endpoints with an
7
+ * `Authorization: Bearer <apiKey>` header so `MINIMAX_BASE_URL` is
8
+ * authoritative. There is NO internal retry — shared execution owns
9
+ * retry policy. Fetch and timer are injectable for tests.
10
+ *
11
+ * Mirrors `providers/minimax/quota-client.ts` line-for-line in
12
+ * structure; that module is the canon direct-transport pattern. The
13
+ * `MiniMaxTransportDeps` shape is the renamed `MiniMaxQuotaClientDeps`
14
+ * (same four fields — rename, not superset).
15
+ *
16
+ * Boundary rules (ARCHITECTURE.md §2):
17
+ * - May import Adapter-local config and normalized errors.
18
+ * - May import `ProviderQuotaFetch` from `providers/types.ts`.
19
+ * - Must NOT import `mmx-cli/sdk`, command presentation, or another
20
+ * Provider's Adapter.
21
+ * - Must NOT perform field normalization — the Adapter owns that.
22
+ */
23
+ import type { MiniMaxConfig } from "./config.js";
24
+ import type { ProviderQuotaFetch } from "../types.js";
25
+ /** Injectable transport dependencies (renamed from `MiniMaxQuotaClientDeps`). */
26
+ export interface MiniMaxTransportDeps {
27
+ readonly fetch?: ProviderQuotaFetch;
28
+ readonly setTimeout?: typeof setTimeout;
29
+ readonly clearTimeout?: typeof clearTimeout;
30
+ readonly env?: NodeJS.ProcessEnv;
31
+ }
32
+ /** Raw MiniMax search response shape (search endpoint). */
33
+ export interface MiniMaxRawSearchResponse {
34
+ organic?: unknown[];
35
+ related_searches?: unknown[];
36
+ base_resp?: unknown;
37
+ }
38
+ /** Raw MiniMax VLM response shape (vision-language endpoint). */
39
+ export interface MiniMaxRawVlmResponse {
40
+ content?: unknown;
41
+ base_resp?: unknown;
42
+ }
43
+ /**
44
+ * Perform ONE POST against the MiniMax Coding Plan search endpoint. No
45
+ * retry; no response body in public errors. Returns the parsed JSON
46
+ * body (raw; the Adapter post-processes into normalized search
47
+ * sources).
48
+ */
49
+ export declare function fetchMiniMaxSearch(config: MiniMaxConfig, query: string, deps?: MiniMaxTransportDeps): Promise<MiniMaxRawSearchResponse>;
50
+ /**
51
+ * Perform ONE POST against the MiniMax Coding Plan VLM endpoint. No
52
+ * retry; no response body in public errors. Returns the parsed JSON
53
+ * body (raw; the Adapter post-processes the content field).
54
+ *
55
+ * `image` is the pre-resolved data URI produced by the Adapter's
56
+ * `convertToDataUri` step. The transport does NOT perform any
57
+ * data-URI conversion.
58
+ */
59
+ export declare function fetchMiniMaxVlm(config: MiniMaxConfig, image: string, prompt: string, deps?: MiniMaxTransportDeps): Promise<MiniMaxRawVlmResponse>;
60
+ //# sourceMappingURL=coding-plan-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coding-plan-client.d.ts","sourceRoot":"","sources":["../../../src/providers/minimax/coding-plan-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAatD,iFAAiF;AACjF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,YAAY,CAAC;IAC5C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAED,2DAA2D;AAC3D,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoLD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CAQnC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAQhC"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * MiniMax Coding Plan direct transport (DESIGN.md §12, P4-02).
3
+ *
4
+ * The pinned `mmx-cli/sdk` 1.0.16 does not preserve an arbitrary
5
+ * configured host for the Coding Plan endpoints. This module performs
6
+ * direct POSTs against the two `/v1/coding_plan/*` endpoints with an
7
+ * `Authorization: Bearer <apiKey>` header so `MINIMAX_BASE_URL` is
8
+ * authoritative. There is NO internal retry — shared execution owns
9
+ * retry policy. Fetch and timer are injectable for tests.
10
+ *
11
+ * Mirrors `providers/minimax/quota-client.ts` line-for-line in
12
+ * structure; that module is the canon direct-transport pattern. The
13
+ * `MiniMaxTransportDeps` shape is the renamed `MiniMaxQuotaClientDeps`
14
+ * (same four fields — rename, not superset).
15
+ *
16
+ * Boundary rules (ARCHITECTURE.md §2):
17
+ * - May import Adapter-local config and normalized errors.
18
+ * - May import `ProviderQuotaFetch` from `providers/types.ts`.
19
+ * - Must NOT import `mmx-cli/sdk`, command presentation, or another
20
+ * Provider's Adapter.
21
+ * - Must NOT perform field normalization — the Adapter owns that.
22
+ */
23
+ import { createRequire } from "node:module";
24
+ import { ApiError, AuthError, NetworkError, QuotaError, TimeoutError, } from "../../lib/errors.js";
25
+ const require = createRequire(import.meta.url);
26
+ const { version: VERSION } = require("../../../package.json");
27
+ const SEARCH_PATH = "/v1/coding_plan/search";
28
+ const VLM_PATH = "/v1/coding_plan/vlm";
29
+ const DEFAULT_TIMEOUT_MS = 30000;
30
+ const MM_API_SOURCE = "Scoutline";
31
+ const USER_AGENT = `scoutline/${VERSION}`;
32
+ const TIMEOUT_HELP_TEXT = "Try again or increase timeout with MINIMAX_TIMEOUT env var";
33
+ function resolveTimeoutMs(env) {
34
+ const raw = parseInt(env.MINIMAX_TIMEOUT || String(DEFAULT_TIMEOUT_MS), 10);
35
+ return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_TIMEOUT_MS;
36
+ }
37
+ /**
38
+ * Layer 1 — HTTP-status mapping. Runs BEFORE the body is parsed; on a
39
+ * non-200 response we discard the body and throw a typed error.
40
+ *
41
+ * `timeoutMs` is forwarded so 408/504 can throw `TimeoutError`
42
+ * carrying the configured duration (and the `MINIMAX_TIMEOUT` help
43
+ * text). The transport never embeds credential material in any
44
+ * error message.
45
+ */
46
+ function mapStatusError(status, timeoutMs) {
47
+ if (status === 401 || status === 403) {
48
+ return new AuthError("MiniMax authentication failed", "MINIMAX_API_KEY");
49
+ }
50
+ if (status === 408 || status === 504) {
51
+ return new TimeoutError(timeoutMs, TIMEOUT_HELP_TEXT);
52
+ }
53
+ if (status === 429) {
54
+ return new ApiError("MiniMax rate limit exceeded", 429);
55
+ }
56
+ if (status === 400 || status === 404 || status === 410 || status === 422) {
57
+ return new ApiError("MiniMax request failed", status);
58
+ }
59
+ if (status >= 500) {
60
+ return new ApiError("MiniMax request failed", status);
61
+ }
62
+ return new ApiError("MiniMax request failed", status);
63
+ }
64
+ /**
65
+ * Layer 2 — `base_resp.status_code` mapping. Runs ONLY when HTTP 200
66
+ * AND body parses as JSON. If body is missing `base_resp`, the body
67
+ * is treated as malformed and a 500-status `ApiError` is thrown.
68
+ */
69
+ function mapBaseRespError(statusCode) {
70
+ if (statusCode === 0 || statusCode === undefined || statusCode === null) {
71
+ // status_code === 0 is success; undefined/null are also treated as
72
+ // "no business error" so a missing-but-present `base_resp` with no
73
+ // status_code field doesn't break the success path. The malformed
74
+ // branch handles the missing-`base_resp`-entirely case.
75
+ return null;
76
+ }
77
+ if (typeof statusCode !== "number" || !Number.isFinite(statusCode)) {
78
+ return new ApiError("MiniMax returned a malformed response", 500);
79
+ }
80
+ if (statusCode === 1002 || statusCode === 1039) {
81
+ return new ApiError("MiniMax content filter rejected the request", 400);
82
+ }
83
+ if (statusCode === 1004) {
84
+ return new AuthError("MiniMax authentication failed", "MINIMAX_API_KEY");
85
+ }
86
+ if (statusCode === 1028 || statusCode === 1030) {
87
+ return new QuotaError();
88
+ }
89
+ if (statusCode === 2038) {
90
+ return new ApiError("MiniMax account requires real-name verification. Visit https://platform.minimaxi.com/user-center/basic-information to resolve.", 403);
91
+ }
92
+ if (statusCode === 2061) {
93
+ return new ApiError("MiniMax model not available on current Token Plan", 403);
94
+ }
95
+ return new ApiError("MiniMax request failed", 500);
96
+ }
97
+ function isPlainObject(value) {
98
+ return typeof value === "object" && value !== null && !Array.isArray(value);
99
+ }
100
+ function getBaseRespStatusCode(body) {
101
+ if (!isPlainObject(body)) {
102
+ return { statusCode: undefined, malformed: true };
103
+ }
104
+ const baseResp = body.base_resp;
105
+ if (baseResp === undefined) {
106
+ return { statusCode: undefined, malformed: true };
107
+ }
108
+ if (!isPlainObject(baseResp)) {
109
+ return { statusCode: undefined, malformed: true };
110
+ }
111
+ return { statusCode: baseResp.status_code, malformed: false };
112
+ }
113
+ function normalizeTransportError(err, timeoutMs) {
114
+ if (err instanceof AuthError ||
115
+ err instanceof ApiError ||
116
+ err instanceof QuotaError ||
117
+ err instanceof TimeoutError) {
118
+ return err;
119
+ }
120
+ if (err instanceof Error) {
121
+ if (err.name === "AbortError") {
122
+ return new TimeoutError(timeoutMs, TIMEOUT_HELP_TEXT);
123
+ }
124
+ const lower = err.message.toLowerCase();
125
+ if (lower.includes("fetch") ||
126
+ lower.includes("econnrefused") ||
127
+ lower.includes("econnreset") ||
128
+ lower.includes("enotfound") ||
129
+ lower.includes("network")) {
130
+ return new NetworkError("MiniMax network error");
131
+ }
132
+ }
133
+ return new ApiError("MiniMax request failed", 500);
134
+ }
135
+ async function postCodingPlanJson(config, path, body, deps, endpointLabel) {
136
+ const f = deps.fetch ?? fetch;
137
+ const setT = deps.setTimeout ?? setTimeout;
138
+ const clearT = deps.clearTimeout ?? clearTimeout;
139
+ const env = deps.env ?? process.env;
140
+ const timeoutMs = resolveTimeoutMs(env);
141
+ const url = `${config.baseUrl}${path}`;
142
+ const controller = new AbortController();
143
+ const timeoutId = setT(() => controller.abort(), timeoutMs);
144
+ try {
145
+ const res = await f(url, {
146
+ method: "POST",
147
+ headers: {
148
+ Authorization: `Bearer ${config.apiKey}`,
149
+ "Content-Type": "application/json",
150
+ "MM-API-Source": MM_API_SOURCE,
151
+ "User-Agent": USER_AGENT,
152
+ },
153
+ body: JSON.stringify(body),
154
+ signal: controller.signal,
155
+ });
156
+ clearT(timeoutId);
157
+ if (!res.ok) {
158
+ await res.text().catch(() => { });
159
+ throw mapStatusError(res.status, timeoutMs);
160
+ }
161
+ let parsed;
162
+ try {
163
+ parsed = await res.json();
164
+ }
165
+ catch {
166
+ throw new ApiError(`MiniMax ${endpointLabel} returned a malformed response`, 500);
167
+ }
168
+ const { statusCode, malformed } = getBaseRespStatusCode(parsed);
169
+ if (malformed) {
170
+ throw new ApiError(`MiniMax ${endpointLabel} returned a malformed response`, 500);
171
+ }
172
+ const mapped = mapBaseRespError(statusCode);
173
+ if (mapped) {
174
+ throw mapped;
175
+ }
176
+ return parsed;
177
+ }
178
+ catch (err) {
179
+ clearT(timeoutId);
180
+ throw normalizeTransportError(err, timeoutMs);
181
+ }
182
+ }
183
+ /**
184
+ * Perform ONE POST against the MiniMax Coding Plan search endpoint. No
185
+ * retry; no response body in public errors. Returns the parsed JSON
186
+ * body (raw; the Adapter post-processes into normalized search
187
+ * sources).
188
+ */
189
+ export async function fetchMiniMaxSearch(config, query, deps = {}) {
190
+ return postCodingPlanJson(config, SEARCH_PATH, { q: query }, deps, "search");
191
+ }
192
+ /**
193
+ * Perform ONE POST against the MiniMax Coding Plan VLM endpoint. No
194
+ * retry; no response body in public errors. Returns the parsed JSON
195
+ * body (raw; the Adapter post-processes the content field).
196
+ *
197
+ * `image` is the pre-resolved data URI produced by the Adapter's
198
+ * `convertToDataUri` step. The transport does NOT perform any
199
+ * data-URI conversion.
200
+ */
201
+ export async function fetchMiniMaxVlm(config, image, prompt, deps = {}) {
202
+ return postCodingPlanJson(config, VLM_PATH, { prompt, image_url: image }, deps, "vlm");
203
+ }
204
+ //# sourceMappingURL=coding-plan-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coding-plan-client.js","sourceRoot":"","sources":["../../../src/providers/minimax/coding-plan-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,MAAM,OAAO,GAAG,aA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MAAqB,EACrB,KAAa,EACb,IAAI,GAAyB,EAAE;IAE/B,OAAO,kBAAkB,CACvB,MAAM,EACN,WAAW,EACX,EAAE,CAAC,EAAE,KAAK,EAAE,EACZ,IAAI,EACJ,QAAQ,CAC4B,CAAC;AACzC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAqB,EACrB,KAAa,EACb,MAAc,EACd,IAAI,GAAyB,EAAE;IAE/B,OAAO,kBAAkB,CACvB,MAAM,EACN,QAAQ,EACR,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAC5B,IAAI,EACJ,KAAK,CAC4B,CAAC;AACtC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MiniMax Adapter-local configuration (DESIGN.md §12 — P2-04).
3
+ *
4
+ * Reads MiniMax credentials and endpoints from the injected environment.
5
+ * This module is the Adapter-local companion to the SDK client; MiniMax
6
+ * environment names intentionally do NOT appear in shared `lib/config.ts`
7
+ * (that module remains Z.AI-only). No credential is persisted or read
8
+ * from shared configuration.
9
+ *
10
+ * Resolution rules:
11
+ * - `MINIMAX_API_KEY`: required, non-empty after trim. Whitespace-only
12
+ * is invalid, not absent.
13
+ * - `MINIMAX_REGION`: optional; undefined defaults to `global`. An
14
+ * empty value is invalid, not absent. Must be exactly `global` or
15
+ * `cn`.
16
+ * - Region URLs: `global` -> `https://api.minimax.io`,
17
+ * `cn` -> `https://api.minimaxi.com`.
18
+ * - `MINIMAX_BASE_URL`: optional override; must be an absolute HTTPS
19
+ * URL. An empty value is invalid. Exactly one trailing slash is
20
+ * removed. Overrides the region URL for every SDK operation.
21
+ */
22
+ export interface MiniMaxConfig {
23
+ readonly apiKey: string;
24
+ readonly region: "global" | "cn";
25
+ readonly baseUrl: string;
26
+ }
27
+ /**
28
+ * Load and validate MiniMax configuration from the injected environment.
29
+ * Throws a normalized {@link ConfigurationError} for any invalid value.
30
+ */
31
+ export declare function loadMiniMaxConfig(env: NodeJS.ProcessEnv): MiniMaxConfig;
32
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/providers/minimax/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAYD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,aAAa,CAyDvE"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * MiniMax Adapter-local configuration (DESIGN.md §12 — P2-04).
3
+ *
4
+ * Reads MiniMax credentials and endpoints from the injected environment.
5
+ * This module is the Adapter-local companion to the SDK client; MiniMax
6
+ * environment names intentionally do NOT appear in shared `lib/config.ts`
7
+ * (that module remains Z.AI-only). No credential is persisted or read
8
+ * from shared configuration.
9
+ *
10
+ * Resolution rules:
11
+ * - `MINIMAX_API_KEY`: required, non-empty after trim. Whitespace-only
12
+ * is invalid, not absent.
13
+ * - `MINIMAX_REGION`: optional; undefined defaults to `global`. An
14
+ * empty value is invalid, not absent. Must be exactly `global` or
15
+ * `cn`.
16
+ * - Region URLs: `global` -> `https://api.minimax.io`,
17
+ * `cn` -> `https://api.minimaxi.com`.
18
+ * - `MINIMAX_BASE_URL`: optional override; must be an absolute HTTPS
19
+ * URL. An empty value is invalid. Exactly one trailing slash is
20
+ * removed. Overrides the region URL for every SDK operation.
21
+ */
22
+ import { ConfigurationError } from "../../lib/errors.js";
23
+ const REGION_BASE_URLS = {
24
+ global: "https://api.minimax.io",
25
+ cn: "https://api.minimaxi.com",
26
+ };
27
+ const MISSING_KEY_HELP = 'export MINIMAX_API_KEY="your-api-key"';
28
+ const REGION_HELP = "Accepted MINIMAX_REGION values: global, cn";
29
+ const BASE_URL_HELP = "MINIMAX_BASE_URL must be an absolute HTTPS URL (e.g. https://api.minimax.io)";
30
+ /**
31
+ * Load and validate MiniMax configuration from the injected environment.
32
+ * Throws a normalized {@link ConfigurationError} for any invalid value.
33
+ */
34
+ export function loadMiniMaxConfig(env) {
35
+ const apiKey = env.MINIMAX_API_KEY;
36
+ if (typeof apiKey !== "string" || apiKey.trim().length === 0) {
37
+ throw new ConfigurationError("MINIMAX_API_KEY environment variable is required", MISSING_KEY_HELP);
38
+ }
39
+ const regionRaw = env.MINIMAX_REGION;
40
+ let region;
41
+ if (regionRaw === undefined) {
42
+ region = "global";
43
+ }
44
+ else if (regionRaw.trim() === "") {
45
+ throw new ConfigurationError('MINIMAX_REGION must be "global" or "cn"', REGION_HELP);
46
+ }
47
+ else if (regionRaw !== "global" && regionRaw !== "cn") {
48
+ throw new ConfigurationError(`Unknown MINIMAX_REGION "${regionRaw}"`, REGION_HELP);
49
+ }
50
+ else {
51
+ region = regionRaw;
52
+ }
53
+ const baseUrlRaw = env.MINIMAX_BASE_URL;
54
+ let baseUrl;
55
+ if (baseUrlRaw === undefined) {
56
+ baseUrl = REGION_BASE_URLS[region];
57
+ }
58
+ else if (baseUrlRaw.trim() === "") {
59
+ throw new ConfigurationError("MINIMAX_BASE_URL must not be empty", BASE_URL_HELP);
60
+ }
61
+ else if (!/^https:\/\//i.test(baseUrlRaw)) {
62
+ throw new ConfigurationError(`MINIMAX_BASE_URL must be an absolute HTTPS URL (got "${baseUrlRaw}")`, BASE_URL_HELP);
63
+ }
64
+ else {
65
+ // Fixup C — W1: reject scheme-only URLs (no host). The previous
66
+ // accept-and-normalize path turned `https://` into `https:/`, which
67
+ // is not a valid URL and breaks SDK construction. Parse the URL and
68
+ // require a non-empty host.
69
+ let parsed;
70
+ try {
71
+ parsed = new URL(baseUrlRaw);
72
+ }
73
+ catch {
74
+ throw new ConfigurationError(`MINIMAX_BASE_URL must be an absolute HTTPS URL with a host (got "${baseUrlRaw}")`, BASE_URL_HELP);
75
+ }
76
+ if (parsed.host.length === 0) {
77
+ throw new ConfigurationError(`MINIMAX_BASE_URL must include a host (got "${baseUrlRaw}")`, BASE_URL_HELP);
78
+ }
79
+ // Remove exactly one trailing slash so the SDK receives a clean base.
80
+ baseUrl = baseUrlRaw.replace(/\/$/, "");
81
+ }
82
+ return { apiKey, region, baseUrl };
83
+ }
84
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/providers/minimax/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzD,MAAM,gBAAgB,GAAG;IACvB,MAAM,EAAE,wBAAwB;IAChC,EAAE,EAAE,0BAA0B;CACtB,CAAC;AAEX,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AACjE,MAAM,WAAW,GAAG,4CAA4C,CAAC;AACjE,MAAM,aAAa,GACjB,8EAA8E,CAAC;AAEjF;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAsB;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC;IACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,kBAAkB,CAC1B,kDAAkD,EAClD,gBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,cAAc,CAAC;IACrC,IAAI,MAAuB,CAAC;IAC5B,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,GAAG,QAAQ,CAAC;IACpB,CAAC;SAAM,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,kBAAkB,CAAC,yCAAyC,EAAE,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CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * MiniMax Provider Media Module (DESIGN.md §9 — P3-02).
3
+ *
4
+ * Owns MiniMax-local image media facts: accepted extensions, size limit,
5
+ * existence check, and absolute-path resolution. Commands pass raw
6
+ * path-or-URL strings; this module is the single owner of every
7
+ * Provider-specific media decision for MiniMax images.
8
+ *
9
+ * Boundary rules (ARCHITECTURE.md §2):
10
+ * - May import normalized errors from `lib/errors.ts` and the shared
11
+ * `ProviderQuotaFetch` port from `providers/types.ts` (HTTP-source
12
+ * image fetch only).
13
+ * - Content reads happen here, in the Adapter-local media Module,
14
+ * since the SDK no longer performs data-URI conversion. The Module
15
+ * owns every MiniMax image fact: accepted extensions, size limit,
16
+ * existence check, absolute-path resolution, MIME detection, and
17
+ * base64 conversion.
18
+ *
19
+ * Media rules (DESIGN.md §9 MiniMax Transitional SDK):
20
+ * - Local image: JPG, JPEG, PNG, WebP (case-insensitive), at most 50 MiB.
21
+ * - HTTP(S) source is accepted.
22
+ * - Local source becomes an absolute path after validation.
23
+ * - `convertToDataUri` performs data-URI conversion for HTTP sources
24
+ * (fetched bytes) and local paths (read bytes); `data:` URIs pass
25
+ * through unchanged.
26
+ * - No MiniMax video media module exists in this scope.
27
+ * - Missing local file rejects with `FILE_ERROR`.
28
+ * - Non-HTTP URL-like strings and unsupported extensions reject with
29
+ * `VALIDATION_ERROR` and Provider-specific supported-format help.
30
+ */
31
+ import type { ProviderImageFetch } from "../types.js";
32
+ /**
33
+ * HTTP image-fetch timeout in milliseconds (DESIGN.md §9, critique G2).
34
+ * Matches the SDK's effective default (`config.timeout * 1000`,
35
+ * `config.timeout = 300` → 30 s). Local files are NOT bound by this
36
+ * timeout — already validated synchronously by `resolveImageSource`
37
+ * via `fs.statSync`, so a slow disk read is not a real risk here.
38
+ */
39
+ export declare const MINIMAX_IMAGE_FETCH_TIMEOUT_MS = 30000;
40
+ /**
41
+ * Local-file extension → MIME mapping for `convertToDataUri` (critique
42
+ * G1). Mirrors the SDK's `IMAGE_MIME_TYPES` table at
43
+ * `mmx-cli/dist/sdk.mjs:1581-1586` exactly. The extension has already
44
+ * been validated against `MINIMAX_IMAGE_EXTENSIONS` by
45
+ * `resolveImageSource`, so a missing entry is not expected at this
46
+ * layer (we still fall back to `image/jpeg` defensively, matching SDK).
47
+ */
48
+ export declare const MINIMAX_IMAGE_MIME_BY_EXTENSION: Readonly<Record<string, string>>;
49
+ /**
50
+ * Resolve a MiniMax image source into the value the MiniMax SDK consumes.
51
+ * For a local file, validates existence, size (≤ 50 MiB), and extension
52
+ * (JPG/JPEG/PNG/WebP) and returns the absolute path (the SDK performs
53
+ * data-URI conversion from this path). For an HTTP(S) URL, returns the URL
54
+ * unchanged without touching the local filesystem.
55
+ */
56
+ export declare function resolveImageSource(source: string): string;
57
+ /**
58
+ * Injectable dependencies for `convertToDataUri`. Fetch and timer
59
+ * injection mirror the `MiniMaxQuotaClientDeps` pattern in
60
+ * `quota-client.ts` so a unit test can drive the HTTP branch
61
+ * deterministically without real network I/O.
62
+ */
63
+ export interface ConvertToDataUriDeps {
64
+ readonly fetch?: ProviderImageFetch;
65
+ readonly setTimeout?: typeof setTimeout;
66
+ readonly clearTimeout?: typeof clearTimeout;
67
+ }
68
+ /**
69
+ * Convert a MiniMax image source into the `data:<mime>;base64,...` form
70
+ * the MiniMax VLM endpoint consumes. Three branches:
71
+ *
72
+ * 1. `data:` prefix → returned unchanged.
73
+ * 2. `http(s)://` → bytes fetched via injected `fetch` with an
74
+ * `AbortController` timed out by `MINIMAX_IMAGE_FETCH_TIMEOUT_MS`,
75
+ * MIME detected via `detectMimeFromContentType`, base64-encoded.
76
+ * The 50 MiB cap (`MINIMAX_MAX_IMAGE_BYTES`) is enforced on the
77
+ * fetched byte length.
78
+ * 3. Local path → bytes read via `node:fs/promises`, MIME from
79
+ * `MINIMAX_IMAGE_MIME_BY_EXTENSION`. The path has already been
80
+ * validated (existence, size, extension) by `resolveImageSource`,
81
+ * so this branch trusts the prior validation.
82
+ *
83
+ * The HTTP branch mirrors the abort/timeout + injected-fetch +
84
+ * injected-setTimeout pattern from `quota-client.ts` so the same test
85
+ * fixtures drive both transports.
86
+ */
87
+ export declare function convertToDataUri(source: string, deps?: ConvertToDataUriDeps): Promise<string>;
88
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/providers/minimax/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAaH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAatD;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK5E,CAAC;AAyDF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUzD;AA+BD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,YAAY,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAajB"}