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,117 @@
1
+ /**
2
+ * Z.AI Monitor API client — Provider-local transport (DESIGN.md §13, P4-02).
3
+ *
4
+ * This Module owns the Z.AI monitor endpoint fetch mechanics moved here
5
+ * from `lib/monitor-client.ts`. It performs direct HTTP against
6
+ * `https://api.z.ai` (overridable via `ZAI_MONITOR_BASE_URL`) with an
7
+ * auth quirk: try the raw key first, and on 401 retry the same request
8
+ * with a `Bearer` prefix. Every transport dependency (fetch, timer,
9
+ * environment) is injectable so tests drive auth fallback and timeout
10
+ * deterministically without touching globals.
11
+ *
12
+ * Boundary rules (ARCHITECTURE.md §2):
13
+ * - May import Provider identity types, normalized errors.
14
+ * - Must NOT import command presentation or another Provider's Adapter.
15
+ *
16
+ * Raw response text NEVER enters public errors. A non-2xx response is
17
+ * mapped to a stable normalized error (`AuthError` for 401/403, `ApiError`
18
+ * otherwise) whose message carries no response body. Transport failures
19
+ * map to `TimeoutError`/`NetworkError`.
20
+ *
21
+ * This transport performs ONE logical attempt (including the auth-scheme
22
+ * fallback). Shared execution owns retry policy.
23
+ */
24
+ import { ApiError, AuthError, NetworkError, TimeoutError } from "../../lib/errors.js";
25
+ const DEFAULT_MONITOR_BASE = "https://api.z.ai";
26
+ const DEFAULT_TIMEOUT_MS = 30000;
27
+ function resolveBase(env) {
28
+ return env.ZAI_MONITOR_BASE_URL || DEFAULT_MONITOR_BASE;
29
+ }
30
+ function resolveTimeoutMs(env) {
31
+ const raw = parseInt(env.Z_AI_TIMEOUT || String(DEFAULT_TIMEOUT_MS), 10);
32
+ return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_TIMEOUT_MS;
33
+ }
34
+ function mapStatusError(status) {
35
+ if (status === 401 || status === 403) {
36
+ return new AuthError("Z.AI monitor API authentication failed");
37
+ }
38
+ return new ApiError("Z.AI monitor API request failed", status);
39
+ }
40
+ function normalizeTransportError(err, timeoutMs) {
41
+ if (err instanceof AuthError || err instanceof ApiError)
42
+ return err;
43
+ if (err instanceof Error) {
44
+ if (err.name === "AbortError") {
45
+ return new TimeoutError(timeoutMs);
46
+ }
47
+ const lower = err.message.toLowerCase();
48
+ if (lower.includes("fetch") ||
49
+ lower.includes("econnrefused") ||
50
+ lower.includes("econnreset") ||
51
+ lower.includes("enotfound") ||
52
+ lower.includes("network")) {
53
+ return new NetworkError("Z.AI monitor network error");
54
+ }
55
+ }
56
+ return new ApiError("Z.AI monitor request failed", 500);
57
+ }
58
+ /**
59
+ * Perform one authenticated GET against the monitor API with the raw-key
60
+ * then Bearer auth fallback. Returns the unwrapped `data` payload (or the
61
+ * whole body when no `data` envelope is present).
62
+ *
63
+ * `path` is appended to the monitor base; `params` become query params.
64
+ */
65
+ export async function fetchZaiMonitorPath(apiKey, path, params, deps = {}) {
66
+ const f = deps.fetch ?? fetch;
67
+ const setT = deps.setTimeout ?? setTimeout;
68
+ const clearT = deps.clearTimeout ?? clearTimeout;
69
+ const env = deps.env ?? process.env;
70
+ const base = resolveBase(env);
71
+ const timeoutMs = resolveTimeoutMs(env);
72
+ const url = new URL(base + path);
73
+ if (params) {
74
+ for (const [k, v] of Object.entries(params))
75
+ url.searchParams.set(k, v);
76
+ }
77
+ for (const authValue of [apiKey, `Bearer ${apiKey}`]) {
78
+ const controller = new AbortController();
79
+ const timeoutId = setT(() => controller.abort(), timeoutMs);
80
+ try {
81
+ const res = await f(url, {
82
+ method: "GET",
83
+ headers: {
84
+ Authorization: authValue,
85
+ "Accept-Language": "en-US,en",
86
+ "Content-Type": "application/json",
87
+ },
88
+ signal: controller.signal,
89
+ });
90
+ clearT(timeoutId);
91
+ if (res.status === 401 && authValue === apiKey) {
92
+ // Auth-scheme fallback: retry the same request with Bearer.
93
+ continue;
94
+ }
95
+ if (!res.ok) {
96
+ // Drain the body so the connection can be reused, but NEVER let
97
+ // the raw text reach a public error message.
98
+ await res.text().catch(() => { });
99
+ throw mapStatusError(res.status);
100
+ }
101
+ const body = (await res.json());
102
+ return body.data ?? body;
103
+ }
104
+ catch (err) {
105
+ clearT(timeoutId);
106
+ throw normalizeTransportError(err, timeoutMs);
107
+ }
108
+ }
109
+ throw new AuthError("Z.AI monitor API rejected both auth schemes");
110
+ }
111
+ /**
112
+ * Fetch the Z.AI quota-limit payload (one attempt, auth-scheme fallback).
113
+ */
114
+ export async function fetchZaiQuotaLimit(apiKey, deps = {}) {
115
+ return (await fetchZaiMonitorPath(apiKey, "/api/monitor/usage/quota/limit", undefined, deps));
116
+ }
117
+ //# sourceMappingURL=monitor-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor-client.js","sourceRoot":"","sources":["../../../src/providers/zai/monitor-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGtF,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAsBjC,SAAS,WAAW,CAAC,GAAsB;IACzC,OAAO,GAAG,CAAC,oBAAoB,IAAI,oBAAoB,CAAC;AAC1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D,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YACH,MAAM,CAAC,SAAS,CAAC,CAAC;YAElB,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;gBAC/C,4DAA4D;gBAC5D,SAAS;YACX,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,gEAAgE;gBAChE,6CAA6C;gBAC7C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBACjC,MAAM,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAuB,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAC3B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,SAAS,CAAC,CAAC;YAClB,MAAM,uBAAuB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,IAAI,GAAmB,EAAE;IAEzB,OAAO,CAAC,MAAM,mBAAmB,CAC/B,MAAM,EACN,gCAAgC,EAChC,SAAS,EACT,IAAI,CACL,CAAqB,CAAC;AACzB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Z.AI Quota Capability (DESIGN.md §13, P4-02).
3
+ *
4
+ * Maps the Z.AI monitor quota-limit response into the normalized
5
+ * Provider-quota Interface. The normalizer is pure; the capability
6
+ * factory owns credential resolution, the single monitor transport
7
+ * attempt, and failure normalization. Shared execution owns retry.
8
+ *
9
+ * Z.AI mapping (DESIGN.md §13):
10
+ * - `level` -> `plan`.
11
+ * - Rolling `TIME_LIMIT` -> `requests` category with current counts,
12
+ * duration in seconds, derived remaining percent, and ISO reset.
13
+ * - `TOKENS_LIMIT` -> `tokens` category; convert the Provider's used
14
+ * percentage to a remaining percentage.
15
+ * - Categories are named `requests` then `tokens` when present.
16
+ * - Per-tool breakdown (`usageDetails`) is omitted — no field in
17
+ * ADR-0001.
18
+ *
19
+ * Boundary rules (ARCHITECTURE.md §2):
20
+ * - May import the quota capability contract, Provider-local monitor
21
+ * transport, and normalized errors.
22
+ * - Must NOT import command presentation or another Provider's Adapter.
23
+ */
24
+ import type { ProviderQuotaSuccess, QuotaCapability } from "../../capabilities/quota.js";
25
+ import { type ZaiMonitorDeps } from "./monitor-client.js";
26
+ /**
27
+ * Normalize a raw Z.AI quota-limit payload into the shared Interface.
28
+ * Throws `QUOTA_ERROR` (via {@link buildQuotaWindow}) when a present
29
+ * limit entry has neither a valid percentage nor valid counts.
30
+ */
31
+ export declare function normalizeZaiQuota(raw: unknown): ProviderQuotaSuccess;
32
+ /**
33
+ * Options for the Z.AI QuotaCapability. `env` resolves the API key and
34
+ * monitor base/timeout. The transport dependencies (`fetch`, timer) are
35
+ * injectable for deterministic tests.
36
+ */
37
+ export interface ZaiQuotaCapabilityOptions extends ZaiMonitorDeps {
38
+ readonly env: NodeJS.ProcessEnv;
39
+ }
40
+ /**
41
+ * Build the Z.AI QuotaCapability. `invoke` resolves the credential,
42
+ * performs one monitor transport attempt (auth-scheme fallback inside),
43
+ * and normalizes the response. Shared execution wraps this in the retry
44
+ * policy; quota never uses the response cache.
45
+ */
46
+ export declare function createZaiQuotaCapability(options: ZaiQuotaCapabilityOptions): QuotaCapability;
47
+ //# sourceMappingURL=quota.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../../src/providers/zai/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAEhB,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,qBAAqB,CAAC;AAsD7B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAiDpE;AAmBD;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,eAAe,CAgB5F"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Z.AI Quota Capability (DESIGN.md §13, P4-02).
3
+ *
4
+ * Maps the Z.AI monitor quota-limit response into the normalized
5
+ * Provider-quota Interface. The normalizer is pure; the capability
6
+ * factory owns credential resolution, the single monitor transport
7
+ * attempt, and failure normalization. Shared execution owns retry.
8
+ *
9
+ * Z.AI mapping (DESIGN.md §13):
10
+ * - `level` -> `plan`.
11
+ * - Rolling `TIME_LIMIT` -> `requests` category with current counts,
12
+ * duration in seconds, derived remaining percent, and ISO reset.
13
+ * - `TOKENS_LIMIT` -> `tokens` category; convert the Provider's used
14
+ * percentage to a remaining percentage.
15
+ * - Categories are named `requests` then `tokens` when present.
16
+ * - Per-tool breakdown (`usageDetails`) is omitted — no field in
17
+ * ADR-0001.
18
+ *
19
+ * Boundary rules (ARCHITECTURE.md §2):
20
+ * - May import the quota capability contract, Provider-local monitor
21
+ * transport, and normalized errors.
22
+ * - Must NOT import command presentation or another Provider's Adapter.
23
+ */
24
+ import { buildQuotaWindow } from "../../capabilities/quota.js";
25
+ import { ApiError, AuthError, ConfigurationError, NetworkError, TimeoutError, } from "../../lib/errors.js";
26
+ import { fetchZaiQuotaLimit, } from "./monitor-client.js";
27
+ import { requireZaiApiKey } from "./credentials.js";
28
+ function isTimeLimit(value) {
29
+ return (!!value && typeof value === "object" && value.type === "TIME_LIMIT");
30
+ }
31
+ function isTokensLimit(value) {
32
+ return (!!value && typeof value === "object" && value.type === "TOKENS_LIMIT");
33
+ }
34
+ function readNumber(value) {
35
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
36
+ }
37
+ // ---------------------------------------------------------------------------
38
+ // Normalizer
39
+ // ---------------------------------------------------------------------------
40
+ /**
41
+ * Normalize a raw Z.AI quota-limit payload into the shared Interface.
42
+ * Throws `QUOTA_ERROR` (via {@link buildQuotaWindow}) when a present
43
+ * limit entry has neither a valid percentage nor valid counts.
44
+ */
45
+ export function normalizeZaiQuota(raw) {
46
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
47
+ throw new ApiError("Z.AI quota returned a malformed response", 500);
48
+ }
49
+ const data = raw;
50
+ const categories = [];
51
+ const limits = Array.isArray(data.limits) ? data.limits : [];
52
+ const timeLimit = limits.find(isTimeLimit);
53
+ if (timeLimit) {
54
+ const durationSeconds = typeof timeLimit.unit === "number" && Number.isFinite(timeLimit.unit)
55
+ ? timeLimit.unit * 3600
56
+ : undefined;
57
+ categories.push({
58
+ name: "requests",
59
+ unit: "requests",
60
+ current: buildQuotaWindow({
61
+ used: readNumber(timeLimit.currentValue),
62
+ limit: readNumber(timeLimit.usage),
63
+ durationSeconds,
64
+ resetsAtEpochMs: readNumber(timeLimit.nextResetTime),
65
+ // Z.AI `percentage` is a USED percentage — do NOT treat it as an
66
+ // explicit remaining percentage. Derive from counts instead.
67
+ }),
68
+ });
69
+ }
70
+ const tokensLimit = limits.find(isTokensLimit);
71
+ if (tokensLimit) {
72
+ const usedPercent = readNumber(tokensLimit.percentage);
73
+ const remainingPercent = usedPercent !== undefined ? 100 - usedPercent : undefined;
74
+ categories.push({
75
+ name: "tokens",
76
+ unit: "tokens",
77
+ current: buildQuotaWindow({
78
+ explicitRemainingPercent: remainingPercent,
79
+ resetsAtEpochMs: readNumber(tokensLimit.nextResetTime),
80
+ }),
81
+ });
82
+ }
83
+ return {
84
+ provider: "zai",
85
+ status: "ok",
86
+ plan: typeof data.level === "string" && data.level.length > 0 ? data.level : undefined,
87
+ categories,
88
+ };
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Capability factory
92
+ // ---------------------------------------------------------------------------
93
+ function normalizeZaiQuotaError(error) {
94
+ if (error instanceof AuthError ||
95
+ error instanceof ApiError ||
96
+ error instanceof NetworkError ||
97
+ error instanceof TimeoutError ||
98
+ error instanceof ConfigurationError) {
99
+ return error;
100
+ }
101
+ return new ApiError("Z.AI quota request failed", 500);
102
+ }
103
+ /**
104
+ * Build the Z.AI QuotaCapability. `invoke` resolves the credential,
105
+ * performs one monitor transport attempt (auth-scheme fallback inside),
106
+ * and normalizes the response. Shared execution wraps this in the retry
107
+ * policy; quota never uses the response cache.
108
+ */
109
+ export function createZaiQuotaCapability(options) {
110
+ const { env, ...transportDeps } = options;
111
+ return {
112
+ async invoke() {
113
+ // Shared credential resolver (Fixup A — B4/B7): honours the
114
+ // ZAI_API_KEY alias and treats a missing key as a configuration
115
+ // failure (ConfigurationError, exit 3).
116
+ const apiKey = requireZaiApiKey(env);
117
+ try {
118
+ const raw = await fetchZaiQuotaLimit(apiKey, transportDeps);
119
+ return normalizeZaiQuota(raw);
120
+ }
121
+ catch (error) {
122
+ throw normalizeZaiQuotaError(error);
123
+ }
124
+ },
125
+ };
126
+ }
127
+ //# sourceMappingURL=quota.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quota.js","sourceRoot":"","sources":["../../../src/providers/zai/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,GAGnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,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AAE9E,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IACE,KAAK,YAAY,SAAS;QAC1B,KAAK,YAAY,QAAQ;QACzB,KAAK,YAAY,YAAY;QAC7B,KAAK,YAAY,YAAY;QAC7B,KAAK,YAAY,kBAAkB,EACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAWD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACzE,MAAM,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAC1C,OAAO;QACL,KAAK,CAAC,MAAM;YACV,4DAA4D;YAC5D,gEAAgE;YAChE,wCAAwC;YACxC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;gBAC5D,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,sBAAsB,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Z.AI Reader Adapter (DESIGN.md §18; reader-migration-tech-plan D4;
3
+ * PRD FR-??? — reader migration Ticket 03).
4
+ *
5
+ * Owns the Provider-facing half of the provider-neutral Reader
6
+ * Capability defined in `src/capabilities/reader.ts`:
7
+ *
8
+ * - URL rewrite (gist.github.com/<user>/<id> -> /raw) applied BEFORE
9
+ * invocation; the rewritten URL surfaces as `finalUrl` in the
10
+ * result. The rewrite is Z.AI-specific because Z.AI's WebReader
11
+ * MCP recognizes the rewritten URL.
12
+ * - a total parser for the characterized Z.AI WebReader response
13
+ * (`ReaderRawResponse`: object on success, bare string for MCP-
14
+ * level error envelopes);
15
+ * - encoded MCP error classification BEFORE success parsing
16
+ * (`quota` is terminal `QUOTA_ERROR`; the rest of the taxonomy
17
+ * uses the shared retry/terminal classification); the parsing
18
+ * helpers live in `./encoded-error.ts` and are shared with
19
+ * `./repository.ts`;
20
+ * - a single resolved-credential fingerprint per cache identity and
21
+ * exact per-operation legacy cache candidate using Ticket 01's
22
+ * `buildLegacyReaderCacheKey` helper;
23
+ * - `decodeCached` delegates to Ticket 01's total decoder
24
+ * (`decodeReaderFetchResult`);
25
+ * - a fresh transport per invocation attempt and exactly one
26
+ * best-effort close in `finally`; close failure never replaces
27
+ * success nor masks the primary failure;
28
+ * - no leakage of raw WebReader response types outside this module.
29
+ *
30
+ * Boundary rules (ARCHITECTURE.md §2):
31
+ * - May import capability types, normalized errors, the Z.AI MCP
32
+ * tool-name helpers, the legacy cache-key helper, the shared
33
+ * `ZaiAdapterClientPort` typed client port, and the shared
34
+ * encoded-error helpers.
35
+ * - Must NOT import another Provider's Adapter, command
36
+ * presentation, or extract/maxChars projection logic.
37
+ *
38
+ * Scope:
39
+ * - implements the single `reader-fetch` operation only. URL scheme
40
+ * validation, `--extract`, `--max-chars`, and `--full-envelope`
41
+ * belong to the command layer (Ticket 04 cuts the handler over).
42
+ * - descriptor metadata sequencing: Ticket 03 introduces this Adapter
43
+ * handle and wires it through `ProviderAdapter.reader` WITHOUT
44
+ * advertising `reader` on `createZaiDescriptor.capabilities()`;
45
+ * Ticket 04 then flips the descriptor to advertise `reader` so
46
+ * Provider selection and Doctor inventory derive from a single
47
+ * source of truth, AND cuts `commands/read.ts` over to dispatch
48
+ * through `adapter.reader.fetch`. This module owns no registry,
49
+ * selection, or command cutover.
50
+ */
51
+ import type { ZaiAdapterClientPort, ZaiMcpClientOptions } from "../types.js";
52
+ import { type ReaderCapability } from "../../capabilities/reader.js";
53
+ /**
54
+ * Production close bound (ms). Matches the existing
55
+ * `ZaiMcpClient.close(timeoutMs = 2000)` semantic; the Adapter races
56
+ * the close against a 2 second timer that resolves silently so a stuck
57
+ * close cannot stall the attempt. Tests may inject a shorter bound via
58
+ * {@link ZaiReaderCapabilityOptions.closeTimeoutMs}.
59
+ */
60
+ export declare const ZAI_READER_CLOSE_BOUND_MS = 2000;
61
+ /**
62
+ * Options accepted by {@link createZaiReaderCapability}.
63
+ *
64
+ * `closeTimeoutMs` defaults to {@link ZAI_READER_CLOSE_BOUND_MS}
65
+ * (2000 ms) — the existing `ZaiMcpClient.close(timeoutMs = 2000)`
66
+ * semantic. Tests may inject a shorter bound to bound a never-
67
+ * resolving `close()` without waiting for the production default.
68
+ */
69
+ export interface ZaiReaderCapabilityOptions {
70
+ readonly env: NodeJS.ProcessEnv;
71
+ readonly clientFactory: (options: ZaiMcpClientOptions) => ZaiAdapterClientPort;
72
+ readonly closeTimeoutMs?: number;
73
+ }
74
+ /**
75
+ * Build the Z.AI Reader Capability. The capability is composed of a
76
+ * single typed `ReaderOperation` descriptor (`fetch`); the Adapter
77
+ * owns credentials, transport lifecycle, raw request/response mapping,
78
+ * URL rewrite, and error normalization. No transport, credential
79
+ * resolution, or I/O happens during construction.
80
+ */
81
+ export declare function createZaiReaderCapability(options: ZaiReaderCapabilityOptions): ReaderCapability;
82
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/providers/zai/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAM7E,OAAO,EAGL,KAAK,gBAAgB,EAItB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAie9C;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,oBAAoB,CAAC;IAC/E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,gBAAgB,CAS/F"}