scoutline 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 (206) hide show
  1. package/README.md +170 -5
  2. package/bin/scoutline.js +36 -15
  3. package/dist/capabilities/diagnostics.d.ts +97 -0
  4. package/dist/capabilities/diagnostics.d.ts.map +1 -0
  5. package/dist/capabilities/diagnostics.js +88 -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/search.d.ts +110 -0
  12. package/dist/capabilities/search.d.ts.map +1 -0
  13. package/dist/capabilities/search.js +21 -0
  14. package/dist/capabilities/search.js.map +1 -0
  15. package/dist/capabilities/vision.d.ts +156 -0
  16. package/dist/capabilities/vision.d.ts.map +1 -0
  17. package/dist/capabilities/vision.js +111 -0
  18. package/dist/capabilities/vision.js.map +1 -0
  19. package/dist/command-invocation.d.ts +58 -0
  20. package/dist/command-invocation.d.ts.map +1 -0
  21. package/dist/command-invocation.js +95 -0
  22. package/dist/command-invocation.js.map +1 -0
  23. package/dist/commands/code.d.ts +11 -4
  24. package/dist/commands/code.d.ts.map +1 -1
  25. package/dist/commands/code.js +16 -42
  26. package/dist/commands/code.js.map +1 -1
  27. package/dist/commands/doctor.d.ts +58 -3
  28. package/dist/commands/doctor.d.ts.map +1 -1
  29. package/dist/commands/doctor.js +154 -52
  30. package/dist/commands/doctor.js.map +1 -1
  31. package/dist/commands/quota.d.ts +45 -3
  32. package/dist/commands/quota.d.ts.map +1 -1
  33. package/dist/commands/quota.js +116 -60
  34. package/dist/commands/quota.js.map +1 -1
  35. package/dist/commands/read.d.ts +15 -1
  36. package/dist/commands/read.d.ts.map +1 -1
  37. package/dist/commands/read.js +53 -54
  38. package/dist/commands/read.js.map +1 -1
  39. package/dist/commands/repo.d.ts +8 -3
  40. package/dist/commands/repo.d.ts.map +1 -1
  41. package/dist/commands/repo.js +40 -78
  42. package/dist/commands/repo.js.map +1 -1
  43. package/dist/commands/search.d.ts +27 -2
  44. package/dist/commands/search.d.ts.map +1 -1
  45. package/dist/commands/search.js +95 -103
  46. package/dist/commands/search.js.map +1 -1
  47. package/dist/commands/tools.d.ts +9 -3
  48. package/dist/commands/tools.d.ts.map +1 -1
  49. package/dist/commands/tools.js +29 -59
  50. package/dist/commands/tools.js.map +1 -1
  51. package/dist/commands/vision.d.ts +35 -9
  52. package/dist/commands/vision.d.ts.map +1 -1
  53. package/dist/commands/vision.js +184 -131
  54. package/dist/commands/vision.js.map +1 -1
  55. package/dist/index.d.ts +42 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +389 -207
  58. package/dist/index.js.map +1 -1
  59. package/dist/lib/cache.d.ts +61 -0
  60. package/dist/lib/cache.d.ts.map +1 -1
  61. package/dist/lib/cache.js +74 -11
  62. package/dist/lib/cache.js.map +1 -1
  63. package/dist/lib/code-mode.d.ts +13 -0
  64. package/dist/lib/code-mode.d.ts.map +1 -1
  65. package/dist/lib/code-mode.js +26 -6
  66. package/dist/lib/code-mode.js.map +1 -1
  67. package/dist/lib/config.d.ts.map +1 -1
  68. package/dist/lib/config.js +15 -18
  69. package/dist/lib/config.js.map +1 -1
  70. package/dist/lib/errors.d.ts +65 -10
  71. package/dist/lib/errors.d.ts.map +1 -1
  72. package/dist/lib/errors.js +135 -19
  73. package/dist/lib/errors.js.map +1 -1
  74. package/dist/lib/execution.d.ts +76 -0
  75. package/dist/lib/execution.d.ts.map +1 -0
  76. package/dist/lib/execution.js +177 -0
  77. package/dist/lib/execution.js.map +1 -0
  78. package/dist/lib/index.d.ts +10 -2
  79. package/dist/lib/index.d.ts.map +1 -1
  80. package/dist/lib/index.js +10 -2
  81. package/dist/lib/index.js.map +1 -1
  82. package/dist/lib/mcp-client.d.ts +46 -11
  83. package/dist/lib/mcp-client.d.ts.map +1 -1
  84. package/dist/lib/mcp-client.js +92 -27
  85. package/dist/lib/mcp-client.js.map +1 -1
  86. package/dist/lib/mcp-config.d.ts +17 -0
  87. package/dist/lib/mcp-config.d.ts.map +1 -1
  88. package/dist/lib/mcp-config.js +29 -0
  89. package/dist/lib/mcp-config.js.map +1 -1
  90. package/dist/lib/monitor-client.d.ts +17 -3
  91. package/dist/lib/monitor-client.d.ts.map +1 -1
  92. package/dist/lib/monitor-client.js +23 -69
  93. package/dist/lib/monitor-client.js.map +1 -1
  94. package/dist/lib/output.d.ts +53 -7
  95. package/dist/lib/output.d.ts.map +1 -1
  96. package/dist/lib/output.js +126 -39
  97. package/dist/lib/output.js.map +1 -1
  98. package/dist/lib/redact.d.ts +62 -3
  99. package/dist/lib/redact.d.ts.map +1 -1
  100. package/dist/lib/redact.js +165 -31
  101. package/dist/lib/redact.js.map +1 -1
  102. package/dist/lib/tty.d.ts +7 -20
  103. package/dist/lib/tty.d.ts.map +1 -1
  104. package/dist/lib/tty.js +51 -30
  105. package/dist/lib/tty.js.map +1 -1
  106. package/dist/node-command-invocation-adapter.d.ts +28 -0
  107. package/dist/node-command-invocation-adapter.d.ts.map +1 -0
  108. package/dist/node-command-invocation-adapter.js +88 -0
  109. package/dist/node-command-invocation-adapter.js.map +1 -0
  110. package/dist/providers/minimax/adapter.d.ts +47 -0
  111. package/dist/providers/minimax/adapter.d.ts.map +1 -0
  112. package/dist/providers/minimax/adapter.js +443 -0
  113. package/dist/providers/minimax/adapter.js.map +1 -0
  114. package/dist/providers/minimax/config.d.ts +32 -0
  115. package/dist/providers/minimax/config.d.ts.map +1 -0
  116. package/dist/providers/minimax/config.js +84 -0
  117. package/dist/providers/minimax/config.js.map +1 -0
  118. package/dist/providers/minimax/media.d.ts +34 -0
  119. package/dist/providers/minimax/media.d.ts.map +1 -0
  120. package/dist/providers/minimax/media.js +92 -0
  121. package/dist/providers/minimax/media.js.map +1 -0
  122. package/dist/providers/minimax/quota-client.d.ts +37 -0
  123. package/dist/providers/minimax/quota-client.d.ts.map +1 -0
  124. package/dist/providers/minimax/quota-client.js +78 -0
  125. package/dist/providers/minimax/quota-client.js.map +1 -0
  126. package/dist/providers/minimax/quota.d.ts +48 -0
  127. package/dist/providers/minimax/quota.d.ts.map +1 -0
  128. package/dist/providers/minimax/quota.js +120 -0
  129. package/dist/providers/minimax/quota.js.map +1 -0
  130. package/dist/providers/minimax/sdk-client.d.ts +29 -0
  131. package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
  132. package/dist/providers/minimax/sdk-client.js +50 -0
  133. package/dist/providers/minimax/sdk-client.js.map +1 -0
  134. package/dist/providers/minimax/vision-attestations.d.ts +29 -0
  135. package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
  136. package/dist/providers/minimax/vision-attestations.js +54 -0
  137. package/dist/providers/minimax/vision-attestations.js.map +1 -0
  138. package/dist/providers/minimax/vision-conformance.d.ts +184 -0
  139. package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
  140. package/dist/providers/minimax/vision-conformance.js +369 -0
  141. package/dist/providers/minimax/vision-conformance.js.map +1 -0
  142. package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
  143. package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
  144. package/dist/providers/minimax/vision-mappings/chart.js +55 -0
  145. package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
  146. package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
  147. package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
  148. package/dist/providers/minimax/vision-mappings/common.js +75 -0
  149. package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
  150. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
  151. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
  152. package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
  153. package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
  154. package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
  155. package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
  156. package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
  157. package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
  158. package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
  159. package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
  160. package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
  161. package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
  162. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
  163. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
  164. package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
  165. package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
  166. package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
  167. package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
  168. package/dist/providers/minimax/vision-mappings.generated.js +29 -0
  169. package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
  170. package/dist/providers/minimax/vision-revisions.d.ts +22 -0
  171. package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
  172. package/dist/providers/minimax/vision-revisions.js +27 -0
  173. package/dist/providers/minimax/vision-revisions.js.map +1 -0
  174. package/dist/providers/registry.d.ts +36 -0
  175. package/dist/providers/registry.d.ts.map +1 -0
  176. package/dist/providers/registry.js +45 -0
  177. package/dist/providers/registry.js.map +1 -0
  178. package/dist/providers/selection.d.ts +44 -0
  179. package/dist/providers/selection.d.ts.map +1 -0
  180. package/dist/providers/selection.js +85 -0
  181. package/dist/providers/selection.js.map +1 -0
  182. package/dist/providers/types.d.ts +247 -0
  183. package/dist/providers/types.d.ts.map +1 -0
  184. package/dist/providers/types.js +127 -0
  185. package/dist/providers/types.js.map +1 -0
  186. package/dist/providers/zai/adapter.d.ts +35 -0
  187. package/dist/providers/zai/adapter.d.ts.map +1 -0
  188. package/dist/providers/zai/adapter.js +619 -0
  189. package/dist/providers/zai/adapter.js.map +1 -0
  190. package/dist/providers/zai/credentials.d.ts +38 -0
  191. package/dist/providers/zai/credentials.d.ts.map +1 -0
  192. package/dist/providers/zai/credentials.js +60 -0
  193. package/dist/providers/zai/credentials.js.map +1 -0
  194. package/dist/providers/zai/media.d.ts +38 -0
  195. package/dist/providers/zai/media.d.ts.map +1 -0
  196. package/dist/providers/zai/media.js +107 -0
  197. package/dist/providers/zai/media.js.map +1 -0
  198. package/dist/providers/zai/monitor-client.d.ts +53 -0
  199. package/dist/providers/zai/monitor-client.d.ts.map +1 -0
  200. package/dist/providers/zai/monitor-client.js +117 -0
  201. package/dist/providers/zai/monitor-client.js.map +1 -0
  202. package/dist/providers/zai/quota.d.ts +47 -0
  203. package/dist/providers/zai/quota.d.ts.map +1 -0
  204. package/dist/providers/zai/quota.js +127 -0
  205. package/dist/providers/zai/quota.js.map +1 -0
  206. package/package.json +10 -5
@@ -1,26 +1,113 @@
1
1
  /**
2
- * Error types and handling for Scoutline
2
+ * Error types and handling for Scoutline.
3
+ *
4
+ * P1-01 introduces the normalised error contract from DESIGN.md §4:
5
+ * `ScoutlineErrorCode`, `ScoutlineError`, `ValidationError`,
6
+ * `UnsupportedCapabilityError`, `UnsupportedOptionError`,
7
+ * `ConfigurationError`, `isRetryableError`, `getErrorExitCode`.
8
+ *
9
+ * The legacy `ZaiError` compatibility name is retained with its existing
10
+ * 4-arg constructor signature so current imports keep working without
11
+ * modification. Legacy subclasses (`AuthError`, `ApiError`,
12
+ * `NetworkError`, `TimeoutError`, `FileError`) continue to extend
13
+ * `ZaiError` for backward compatibility. The legacy 1-arg
14
+ * `formatErrorOutput` helper is preserved so Phase 1 command handlers
15
+ * keep compiling; the pure invocation-local replacement lives in
16
+ * `./output.js` (DESIGN.md §3) and replaces it in P1-10.
17
+ *
18
+ * P4-01 routes both the legacy and the invocation-local error
19
+ * formatters through `lib/redact.js` so redaction is a single source of
20
+ * truth.
3
21
  */
4
- export class ZaiError extends Error {
22
+ import { redactCredentialString, configuredSecrets } from "./redact.js";
23
+ export class ScoutlineError extends Error {
5
24
  code;
6
25
  statusCode;
7
26
  help;
8
- constructor(message, code, statusCode, help) {
27
+ retryable;
28
+ exitCode;
29
+ constructor(message, code, options = {}) {
9
30
  super(message);
31
+ this.name = "ScoutlineError";
10
32
  this.code = code;
11
- this.statusCode = statusCode;
12
- this.help = help;
33
+ this.statusCode = options.statusCode;
34
+ this.help = options.help;
35
+ this.retryable = options.retryable ?? false;
36
+ this.exitCode = options.exitCode ?? 1;
37
+ }
38
+ }
39
+ /**
40
+ * Compatibility name for existing imports. The 4-arg constructor
41
+ * signature matches the legacy `ZaiError` so current call sites keep
42
+ * working without modification. Status codes passed here become
43
+ * `statusCode`; `help` becomes `help`; `retryable` and `exitCode` keep
44
+ * their defaults (`false` / `1`).
45
+ */
46
+ export class ZaiError extends ScoutlineError {
47
+ constructor(message, code, statusCode, help) {
48
+ super(message, code, { statusCode, help });
13
49
  this.name = "ZaiError";
14
50
  }
15
51
  }
16
- export class AuthError extends ZaiError {
17
- constructor(message) {
18
- super(message, "AUTH_ERROR", 401, "Check your Z_AI_API_KEY is valid and has sufficient quota");
52
+ export class ValidationError extends ScoutlineError {
53
+ constructor(message, help) {
54
+ super(message, "VALIDATION_ERROR", {
55
+ statusCode: 400,
56
+ help,
57
+ exitCode: 1,
58
+ });
59
+ this.name = "ValidationError";
19
60
  }
20
61
  }
21
- export class ValidationError extends ZaiError {
22
- constructor(message) {
23
- super(message, "VALIDATION_ERROR", 400);
62
+ export class UnsupportedCapabilityError extends ScoutlineError {
63
+ constructor(provider, capability) {
64
+ super(`Provider "${provider}" does not support capability "${capability}"`, "UNSUPPORTED_CAPABILITY", { exitCode: 1 });
65
+ this.name = "UnsupportedCapabilityError";
66
+ }
67
+ }
68
+ export class UnsupportedOptionError extends ScoutlineError {
69
+ constructor(provider, capability, option) {
70
+ super(`Provider "${provider}" does not support option "${option}" for capability "${capability}"`, "UNSUPPORTED_OPTION", { exitCode: 1 });
71
+ this.name = "UnsupportedOptionError";
72
+ }
73
+ }
74
+ export class ConfigurationError extends ScoutlineError {
75
+ constructor(message, help) {
76
+ // Configuration failures use exit 3 to distinguish them from
77
+ // ordinary command failures (DESIGN.md §4, GATE-1). The public code is
78
+ // CONFIGURATION_ERROR; the previous "FILE_ERROR" code was semantically
79
+ // wrong (FILE_ERROR is reserved for file/media failures in Phase 3).
80
+ super(message, "CONFIGURATION_ERROR", { help, exitCode: 3 });
81
+ this.name = "ConfigurationError";
82
+ }
83
+ }
84
+ export function isRetryableError(error) {
85
+ if (error instanceof ScoutlineError) {
86
+ return error.retryable;
87
+ }
88
+ return false;
89
+ }
90
+ export function getErrorExitCode(error) {
91
+ if (error instanceof ScoutlineError) {
92
+ return error.exitCode;
93
+ }
94
+ return 1;
95
+ }
96
+ // ---------------------------------------------------------------------------
97
+ // Legacy subclasses (compat). Kept for Phase 1 command handlers; the ones
98
+ // that survive into Phase 2 are validated during that phase's migration.
99
+ // ---------------------------------------------------------------------------
100
+ export class AuthError extends ZaiError {
101
+ // Fixup C — W2: AuthError help text is Provider-neutral. The default
102
+ // message points at "your Provider credentials" instead of naming a
103
+ // specific env var, since the same AuthError surfaces for any Provider
104
+ // transport failure (including MiniMax). Callers that DO know which
105
+ // Provider failed can pass `keyName` to tighten the guidance.
106
+ constructor(message, keyName) {
107
+ const help = keyName
108
+ ? `Check that ${keyName} is valid and has sufficient quota for the active Provider`
109
+ : "Check that your Provider credentials are valid and have sufficient quota";
110
+ super(message, "AUTH_ERROR", 401, help);
24
111
  }
25
112
  }
26
113
  export class ApiError extends ZaiError {
@@ -34,8 +121,16 @@ export class NetworkError extends ZaiError {
34
121
  }
35
122
  }
36
123
  export class TimeoutError extends ZaiError {
124
+ /**
125
+ * The configured timeout duration that elapsed, in milliseconds. Kept as
126
+ * a first-class field (Fixup D) so an Adapter rewrapping a typed
127
+ * `TimeoutError` can preserve the original duration instead of re-reading
128
+ * an ambient `process.env` value that may differ from the injected env.
129
+ */
130
+ durationMs;
37
131
  constructor(timeoutMs) {
38
132
  super(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", undefined, "Try again or increase timeout with Z_AI_TIMEOUT env var");
133
+ this.durationMs = timeoutMs;
39
134
  }
40
135
  }
41
136
  export class FileError extends ZaiError {
@@ -43,26 +138,47 @@ export class FileError extends ZaiError {
43
138
  super(message, "FILE_ERROR", undefined, help);
44
139
  }
45
140
  }
141
+ // ---------------------------------------------------------------------------
142
+ // Legacy 1-arg `formatErrorOutput` (compat). Phase 1 command handlers
143
+ // still call this with an unknown error value and rely on the legacy
144
+ // `ZAI_OUTPUT_MODE` env var for pretty-print decisions. The pure,
145
+ // invocation-local replacement lives in `./output.js` (DESIGN.md §3) and
146
+ // replaces this helper in P1-10.
147
+ //
148
+ // P4-01: every field that reaches the public envelope is run through the
149
+ // shared `redactCredentialString` from `./redact.js` so credential
150
+ // material embedded in `message` or `help` is replaced with
151
+ // `[REDACTED]` before the value reaches stdout/stderr. The configured
152
+ // Provider credentials from the process environment are passed in as
153
+ // extra replacement targets.
154
+ // ---------------------------------------------------------------------------
46
155
  export function formatErrorOutput(error) {
47
- const pretty = (process.env.ZAI_OUTPUT_MODE || "") === "pretty";
48
- if (error instanceof ZaiError) {
49
- return JSON.stringify({
156
+ const pretty = typeof process !== "undefined" && process.env && process.env.ZAI_OUTPUT_MODE === "pretty";
157
+ const secrets = configuredSecrets();
158
+ if (error instanceof ScoutlineError) {
159
+ const payload = {
50
160
  success: false,
51
- error: error.message,
161
+ error: redactCredentialString(error.message, secrets),
52
162
  code: error.code,
53
- ...(error.help && { help: error.help }),
54
- }, null, pretty ? 2 : 0);
163
+ };
164
+ if (error.help) {
165
+ payload.help = redactCredentialString(error.help, secrets);
166
+ }
167
+ if (typeof error.statusCode === "number") {
168
+ payload.statusCode = error.statusCode;
169
+ }
170
+ return JSON.stringify(payload, null, pretty ? 2 : 0);
55
171
  }
56
172
  if (error instanceof Error) {
57
173
  return JSON.stringify({
58
174
  success: false,
59
- error: error.message,
175
+ error: redactCredentialString(error.message, secrets),
60
176
  code: "UNKNOWN_ERROR",
61
177
  }, null, pretty ? 2 : 0);
62
178
  }
63
179
  return JSON.stringify({
64
180
  success: false,
65
- error: String(error),
181
+ error: redactCredentialString(String(error), secrets),
66
182
  code: "UNKNOWN_ERROR",
67
183
  }, null, pretty ? 2 : 0);
68
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGxB,IAAI;IACJ,UAAU;IACV,IAAI;IAJb,YACE,OAAe,EACR,IAAY,EACZ,UAAmB,EACnB,IAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;oBAJR,IAAI;0BACJ,UAAU;oBACV,IAAI;QAGX,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,QAAQ;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,2DAA2D,CAAC,CAAC;IACjG,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,YAAY,OAAe,EAAE,UAAkB;QAC7C,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,gCAAgC,CAAC,CAAC;IAC/E,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SA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AM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QACrD,IAAI,EAAE,eAAe;KACtB,EACD,IAAI,EACJ,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Shared Execution Contract (DESIGN.md §10).
3
+ *
4
+ * Owns cache lookup, legacy read-through, retry policy, and local count
5
+ * truncation for every Provider Capability. Capability Modules define
6
+ * shared meaning; Adapters perform a single transport attempt; this
7
+ * module is the single retry and cache-policy owner.
8
+ *
9
+ * Boundary rules (ARCHITECTURE.md §2):
10
+ * - May import capability types, Provider identity types, cache, and
11
+ * normalized errors.
12
+ * - Must NOT import a concrete Provider Adapter, UTCP, or `mmx-cli`.
13
+ * - Must NOT import command presentation or output mode modules.
14
+ *
15
+ * Order of operations for `executeSearch`:
16
+ * 1. `capability.validate(request)`
17
+ * 2. `capability.cacheIdentity(request, { legacyCount: options.count })`
18
+ * 3. Read the provider-partitioned cache key
19
+ * 4. Try and decode Adapter-supplied legacy candidates when applicable
20
+ * 5. Invoke through `executeProviderOperation`
21
+ * 6. Retry only normalized retryable failures
22
+ * 7. Cache the full normalized result
23
+ * 8. Apply local count truncation
24
+ */
25
+ import type { SearchCapability, SearchRequest, SearchSource } from "../capabilities/search.js";
26
+ import { type ResponseCache } from "./cache.js";
27
+ /**
28
+ * Retry policy for a single Provider operation. Defaults are applied
29
+ * per-operation from {@link defaultRetryPolicy}.
30
+ */
31
+ export interface RetryPolicy {
32
+ maxRetries: number;
33
+ baseDelayMs: number;
34
+ maxDelayMs: number;
35
+ jitterMs: number;
36
+ }
37
+ /**
38
+ * Dependencies shared execution requires. `sleep` and `random` are
39
+ * injected so retry backoff is deterministic under test.
40
+ */
41
+ export interface ExecutionDependencies {
42
+ cache: ResponseCache;
43
+ sleep(ms: number): Promise<void>;
44
+ random(): number;
45
+ }
46
+ /** Provider operations that share a single retry policy table. */
47
+ export type ProviderOperation = "search" | "vision" | "quota" | "diagnostics";
48
+ /**
49
+ * Default retry policy per operation. Search, quota, and diagnostics
50
+ * allow one retry; Vision allows two to preserve shipped Z.AI
51
+ * behaviour. Base delay 500 ms, max delay 8000 ms, jitter up to 250 ms.
52
+ */
53
+ export declare function defaultRetryPolicy(operation: ProviderOperation): RetryPolicy;
54
+ /**
55
+ * Generic uncached retry wrapper. Performs no I/O of its own; the
56
+ * caller supplies the invoke thunk and the cache strategy. Each
57
+ * outward Provider operation has exactly one retry wrapper; Adapter
58
+ * transport methods perform one attempt and never retry internally.
59
+ */
60
+ export declare function executeProviderOperation<T>(operation: ProviderOperation, invoke: () => Promise<T>, dependencies: Pick<ExecutionDependencies, "sleep" | "random">, retryPolicy?: RetryPolicy): Promise<T>;
61
+ /**
62
+ * Execute a normalized Search through the shared pipeline:
63
+ * validate → cache identity → new-key read → optional legacy
64
+ * read-through → invoke with retry → cache the full result → apply
65
+ * count truncation.
66
+ *
67
+ * Count never enters the cache identity request or the Provider
68
+ * request; it is supplied only as `legacyCount` so the Z.AI Adapter
69
+ * can reconstruct old keys.
70
+ */
71
+ export declare function executeSearch(capability: SearchCapability, request: SearchRequest, options: {
72
+ count?: number;
73
+ noCache?: boolean;
74
+ retryPolicy?: RetryPolicy;
75
+ }, dependencies: ExecutionDependencies): Promise<readonly SearchSource[]>;
76
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/lib/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE/F,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAMvE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,IAAI,MAAM,CAAC;CAClB;AAED,kEAAkE;AAClE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;AAM9E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,GAAG,WAAW,CAe5E;AAkCD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,YAAY,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,QAAQ,CAAC,EAC7D,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,CAAC,CAAC,CAeZ;AAoBD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,gBAAgB,EAC5B,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,EACzE,YAAY,EAAE,qBAAqB,GAClC,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAuDlC"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Shared Execution Contract (DESIGN.md §10).
3
+ *
4
+ * Owns cache lookup, legacy read-through, retry policy, and local count
5
+ * truncation for every Provider Capability. Capability Modules define
6
+ * shared meaning; Adapters perform a single transport attempt; this
7
+ * module is the single retry and cache-policy owner.
8
+ *
9
+ * Boundary rules (ARCHITECTURE.md §2):
10
+ * - May import capability types, Provider identity types, cache, and
11
+ * normalized errors.
12
+ * - Must NOT import a concrete Provider Adapter, UTCP, or `mmx-cli`.
13
+ * - Must NOT import command presentation or output mode modules.
14
+ *
15
+ * Order of operations for `executeSearch`:
16
+ * 1. `capability.validate(request)`
17
+ * 2. `capability.cacheIdentity(request, { legacyCount: options.count })`
18
+ * 3. Read the provider-partitioned cache key
19
+ * 4. Try and decode Adapter-supplied legacy candidates when applicable
20
+ * 5. Invoke through `executeProviderOperation`
21
+ * 6. Retry only normalized retryable failures
22
+ * 7. Cache the full normalized result
23
+ * 8. Apply local count truncation
24
+ */
25
+ import { ScoutlineError } from "./errors.js";
26
+ import { buildProviderCacheKey } from "./cache.js";
27
+ const DEFAULT_BASE_DELAY_MS = 500;
28
+ const DEFAULT_MAX_DELAY_MS = 8000;
29
+ const DEFAULT_JITTER_MS = 250;
30
+ /**
31
+ * Default retry policy per operation. Search, quota, and diagnostics
32
+ * allow one retry; Vision allows two to preserve shipped Z.AI
33
+ * behaviour. Base delay 500 ms, max delay 8000 ms, jitter up to 250 ms.
34
+ */
35
+ export function defaultRetryPolicy(operation) {
36
+ const base = {
37
+ baseDelayMs: DEFAULT_BASE_DELAY_MS,
38
+ maxDelayMs: DEFAULT_MAX_DELAY_MS,
39
+ jitterMs: DEFAULT_JITTER_MS,
40
+ };
41
+ switch (operation) {
42
+ case "vision":
43
+ return { ...base, maxRetries: 2 };
44
+ case "search":
45
+ case "quota":
46
+ case "diagnostics":
47
+ default:
48
+ return { ...base, maxRetries: 1 };
49
+ }
50
+ }
51
+ /**
52
+ * Classify whether a normalized error is retryable for a Provider
53
+ * operation. Authentication, validation, unsupported, content-policy,
54
+ * and exhausted-quota failures are terminal. Normalized timeout,
55
+ * network, HTTP 429, 500, 502, 503, and 504 equivalents are retryable.
56
+ *
57
+ * An explicit `retryable: true` on a `ScoutlineError` wins; an explicit
58
+ * `retryable: false` overrides a code-based default. Non-Scoutline
59
+ * errors never retry — Adapters must normalize failures before they
60
+ * leave the Adapter boundary.
61
+ */
62
+ function isOperationRetryableError(error) {
63
+ if (!(error instanceof ScoutlineError))
64
+ return false;
65
+ // Explicit retryable flag wins over code-based defaults.
66
+ if (error.retryable)
67
+ return true;
68
+ switch (error.code) {
69
+ case "TIMEOUT_ERROR":
70
+ case "NETWORK_ERROR":
71
+ return true;
72
+ case "API_ERROR":
73
+ return (error.statusCode === 429 ||
74
+ error.statusCode === 500 ||
75
+ error.statusCode === 502 ||
76
+ error.statusCode === 503 ||
77
+ error.statusCode === 504);
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ /**
83
+ * Generic uncached retry wrapper. Performs no I/O of its own; the
84
+ * caller supplies the invoke thunk and the cache strategy. Each
85
+ * outward Provider operation has exactly one retry wrapper; Adapter
86
+ * transport methods perform one attempt and never retry internally.
87
+ */
88
+ export async function executeProviderOperation(operation, invoke, dependencies, retryPolicy) {
89
+ const policy = retryPolicy ?? defaultRetryPolicy(operation);
90
+ let attempt = 0;
91
+ for (;;) {
92
+ try {
93
+ return await invoke();
94
+ }
95
+ catch (error) {
96
+ if (attempt >= policy.maxRetries)
97
+ throw error;
98
+ if (!isOperationRetryableError(error))
99
+ throw error;
100
+ const backoff = Math.min(policy.maxDelayMs, policy.baseDelayMs * Math.pow(2, attempt));
101
+ const jitter = Math.floor(dependencies.random() * policy.jitterMs);
102
+ await dependencies.sleep(backoff + jitter);
103
+ attempt += 1;
104
+ }
105
+ }
106
+ }
107
+ // ---------------------------------------------------------------------------
108
+ // Search execution
109
+ // ---------------------------------------------------------------------------
110
+ /**
111
+ * Apply command-level count truncation to a normalized result. Count
112
+ * is meaning local to the command Module: zero returns an empty list,
113
+ * a positive count slices, and an absent count returns everything.
114
+ */
115
+ function applyCount(result, count) {
116
+ if (count === undefined)
117
+ return result;
118
+ if (count <= 0)
119
+ return [];
120
+ return result.slice(0, count);
121
+ }
122
+ /**
123
+ * Execute a normalized Search through the shared pipeline:
124
+ * validate → cache identity → new-key read → optional legacy
125
+ * read-through → invoke with retry → cache the full result → apply
126
+ * count truncation.
127
+ *
128
+ * Count never enters the cache identity request or the Provider
129
+ * request; it is supplied only as `legacyCount` so the Z.AI Adapter
130
+ * can reconstruct old keys.
131
+ */
132
+ export async function executeSearch(capability, request, options, dependencies) {
133
+ // 1. Validate Capability request.
134
+ capability.validate(request);
135
+ // 2. Adapter-owned cache identity (after validation).
136
+ const identity = capability.cacheIdentity(request, {
137
+ legacyCount: options.count,
138
+ });
139
+ // 3. Read the provider-partitioned cache key.
140
+ const newKey = buildProviderCacheKey({
141
+ provider: identity.provider,
142
+ capability: identity.capability,
143
+ credentialFingerprint: identity.credentialFingerprint,
144
+ request: identity.request,
145
+ });
146
+ if (!options.noCache) {
147
+ const cached = await dependencies.cache.get(newKey);
148
+ if (cached !== null) {
149
+ return applyCount(cached, options.count);
150
+ }
151
+ // 4. Adapter-owned legacy candidates (Z.AI only). Invalid raw data
152
+ // is a miss; a valid hit populates the new key but the legacy
153
+ // file is never changed or deleted.
154
+ if (identity.legacyCandidates) {
155
+ for (const candidate of identity.legacyCandidates) {
156
+ const raw = await dependencies.cache.get(candidate.key);
157
+ if (raw === null)
158
+ continue;
159
+ const decoded = candidate.decode(raw);
160
+ if (decoded !== null) {
161
+ await dependencies.cache.set(newKey, decoded);
162
+ return applyCount(decoded, options.count);
163
+ }
164
+ }
165
+ }
166
+ }
167
+ // 5 + 6. Invoke through executeProviderOperation; retryable failures
168
+ // are retried with backoff driven by the injected sleep+random.
169
+ const result = await executeProviderOperation("search", () => capability.invoke(request), dependencies, options.retryPolicy);
170
+ // 7. Cache the full normalized result before count is applied.
171
+ if (!options.noCache) {
172
+ await dependencies.cache.set(newKey, result);
173
+ }
174
+ // 8. Local count truncation.
175
+ return applyCount(result, options.count);
176
+ }
177
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/lib/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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oBAC9C,OAAO,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAC3C,QAAQ,EACR,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAChC,YAAY,EACZ,OAAO,CAAC,WAAW,CACpB,CAAC;IAEF,+DAA+D;IAC/D,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,6BAA6B;IAC7B,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
@@ -1,8 +1,16 @@
1
1
  /**
2
- * Library exports for programmatic usage
2
+ * Library exports for programmatic usage.
3
+ *
4
+ * `formatErrorOutput` lives in `./output.js` (DESIGN.md §3, canonical
5
+ * invocation-local 2-arg form). `./errors.js` keeps a legacy 1-arg
6
+ * compat version that Phase 1 command handlers import directly until
7
+ * P1-10 migrates them. To avoid a duplicate-export error in this
8
+ * aggregator, the errors-module re-export below is explicit and omits
9
+ * `formatErrorOutput`; the canonical 2-arg version from `./output.js`
10
+ * wins through `export *` below.
3
11
  */
4
12
  export * from "./config.js";
5
- export * from "./errors.js";
13
+ export { type ScoutlineErrorCode, type ScoutlineErrorOptions, ScoutlineError, ZaiError, ValidationError, ConfigurationError, UnsupportedCapabilityError, UnsupportedOptionError, AuthError, ApiError, NetworkError, TimeoutError, FileError, isRetryableError, getErrorExitCode, } from "./errors.js";
6
14
  export * from "./output.js";
7
15
  export * from "./image.js";
8
16
  export * from "./api-client.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,cAAc,EACd,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
package/dist/lib/index.js CHANGED
@@ -1,8 +1,16 @@
1
1
  /**
2
- * Library exports for programmatic usage
2
+ * Library exports for programmatic usage.
3
+ *
4
+ * `formatErrorOutput` lives in `./output.js` (DESIGN.md §3, canonical
5
+ * invocation-local 2-arg form). `./errors.js` keeps a legacy 1-arg
6
+ * compat version that Phase 1 command handlers import directly until
7
+ * P1-10 migrates them. To avoid a duplicate-export error in this
8
+ * aggregator, the errors-module re-export below is explicit and omits
9
+ * `formatErrorOutput`; the canonical 2-arg version from `./output.js`
10
+ * wins through `export *` below.
3
11
  */
4
12
  export * from "./config.js";
5
- export * from "./errors.js";
13
+ export { ScoutlineError, ZaiError, ValidationError, ConfigurationError, UnsupportedCapabilityError, UnsupportedOptionError, AuthError, ApiError, NetworkError, TimeoutError, FileError, isRetryableError, getErrorExitCode, } from "./errors.js";
6
14
  export * from "./output.js";
7
15
  export * from "./image.js";
8
16
  export * from "./api-client.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,aAAa,CAAC;AAC5B,OAAO,EAGL,cAAc,EACd,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * - Web Search: Real-time web search
8
8
  * - Web Reader: Web page content extraction
9
9
  */
10
- import { type Tool } from "@utcp/sdk";
10
+ import { UtcpClient, type Tool } from "@utcp/sdk";
11
11
  import "@utcp/mcp";
12
12
  export interface ZReadSearchResult {
13
13
  title: string;
@@ -24,6 +24,23 @@ export interface WebSearchResult {
24
24
  icon: string;
25
25
  publish_date?: string;
26
26
  }
27
+ /**
28
+ * Constructor options for {@link ZaiMcpClient}.
29
+ *
30
+ * `utcpFactory` is a behaviour-preserving injection seam: when omitted the
31
+ * production path uses `UtcpClient.create()`. Tests inject a fake to avoid
32
+ * touching process globals.
33
+ *
34
+ * `disableRetry` (P2-03) lets the Z.AI Search Adapter hand retry policy
35
+ * to shared execution. When omitted, the client retains its existing
36
+ * direct-client retry behaviour.
37
+ */
38
+ export interface ZaiMcpClientOptions {
39
+ enableVision?: boolean;
40
+ noCache?: boolean;
41
+ disableRetry?: boolean;
42
+ utcpFactory?: () => Promise<UtcpClient>;
43
+ }
27
44
  /**
28
45
  * Unified MCP client for all Z.AI MCP services
29
46
  */
@@ -32,10 +49,7 @@ export declare class ZaiMcpClient {
32
49
  private initPromise;
33
50
  private isInitialized;
34
51
  private options;
35
- constructor(options?: {
36
- enableVision?: boolean;
37
- noCache?: boolean;
38
- });
52
+ constructor(options?: ZaiMcpClientOptions);
39
53
  /**
40
54
  * Initialize the UTCP client and register all MCP servers
41
55
  */
@@ -54,13 +68,37 @@ export declare class ZaiMcpClient {
54
68
  private readToolsCache;
55
69
  private writeToolsCache;
56
70
  /**
57
- * List all discovered tools from registered MCP servers
71
+ * List all discovered tools from registered MCP servers.
72
+ *
73
+ * Returns the PUBLIC projected view: internal UTCP names (e.g.
74
+ * `scoutline_zai.search.web_search_prime`) are rewritten to the
75
+ * stable dotted form (e.g. `scoutline.zai.search.web_search_prime`).
76
+ * The private unprojected discovery list is retained for invocation
77
+ * through {@link getTool} / {@link resolveToolName}.
58
78
  */
59
79
  listTools(refresh?: boolean): Promise<Tool[]>;
60
80
  /**
61
- * Find a tool by exact name or by suffix match
81
+ * Private unprojected discovery list. Tools keep their exact UTCP
82
+ * names so {@link getTool} can resolve public aliases back to the
83
+ * internal invocation identity.
84
+ */
85
+ private discoverTools;
86
+ /**
87
+ * Find a tool by exact internal name, public dotted name, or leaf
88
+ * suffix. Resolution order:
89
+ * 1. Exact discovered name (e.g. `scoutline_zai.search.web_search_prime`).
90
+ * 2. Public dotted name (e.g. `scoutline.zai.search.web_search_prime`):
91
+ * derive the provider-relative suffix after the public prefix and
92
+ * match exactly one discovered name ending in `.<suffix>`. Zero or
93
+ * multiple matches fail.
94
+ * 3. Legacy short-suffix fallback: a single discovered name ending in
95
+ * `.<name>` (e.g. for callers that pass only `web_search_prime`).
96
+ *
97
+ * Public names never replace the private discovered-name record — the
98
+ * returned {@link Tool} always carries its internal UTCP name.
62
99
  */
63
100
  getTool(toolName: string): Promise<Tool | undefined>;
101
+ private findToolByResolvedName;
64
102
  /**
65
103
  * Resolve a tool name, accepting full names or suffixes
66
104
  */
@@ -150,10 +188,7 @@ export declare class ZaiMcpClient {
150
188
  close(timeoutMs?: number): Promise<void>;
151
189
  }
152
190
  export declare class ZReadMcpClient extends ZaiMcpClient {
153
- constructor(options?: {
154
- enableVision?: boolean;
155
- noCache?: boolean;
156
- });
191
+ constructor(options?: ZaiMcpClientOptions);
157
192
  searchDoc(repo: string, query: string, language?: "zh" | "en"): Promise<string>;
158
193
  getRepoStructure(repo: string, dirPath?: string): Promise<string>;
159
194
  readFile(repo: string, path: string): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,WAAW,CAAC;AAyCnB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAgD;IAE/D,YAAY,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,O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