recker 1.0.2-0 → 1.0.4

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 (287) hide show
  1. package/LICENSE +0 -2
  2. package/README.md +121 -72
  3. package/dist/cache/memory-storage.d.ts.map +1 -1
  4. package/dist/cache/memory-storage.js +7 -1
  5. package/dist/constants/http-status.d.ts +74 -0
  6. package/dist/constants/http-status.d.ts.map +1 -0
  7. package/dist/constants/http-status.js +156 -0
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +6 -6
  10. package/dist/cookies/memory-cookie-jar.d.ts +31 -0
  11. package/dist/cookies/memory-cookie-jar.d.ts.map +1 -0
  12. package/dist/cookies/memory-cookie-jar.js +210 -0
  13. package/dist/core/client.d.ts +9 -0
  14. package/dist/core/client.d.ts.map +1 -1
  15. package/dist/core/client.js +252 -53
  16. package/dist/core/errors.d.ts +18 -2
  17. package/dist/core/errors.d.ts.map +1 -1
  18. package/dist/core/errors.js +66 -5
  19. package/dist/core/index.d.ts +6 -0
  20. package/dist/core/index.d.ts.map +1 -0
  21. package/dist/core/index.js +5 -0
  22. package/dist/core/request-promise.d.ts.map +1 -1
  23. package/dist/core/request-promise.js +8 -2
  24. package/dist/core/request.d.ts +7 -1
  25. package/dist/core/request.d.ts.map +1 -1
  26. package/dist/core/request.js +32 -0
  27. package/dist/core/response.d.ts +2 -0
  28. package/dist/core/response.d.ts.map +1 -1
  29. package/dist/core/response.js +44 -19
  30. package/dist/events/request-events.d.ts +48 -0
  31. package/dist/events/request-events.d.ts.map +1 -0
  32. package/dist/events/request-events.js +85 -0
  33. package/dist/index.d.ts +28 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +28 -2
  36. package/dist/mcp/client.d.ts.map +1 -1
  37. package/dist/mcp/client.js +16 -5
  38. package/dist/mcp/contract.d.ts +77 -0
  39. package/dist/mcp/contract.d.ts.map +1 -0
  40. package/dist/mcp/contract.js +278 -0
  41. package/dist/mcp/types.d.ts +1 -0
  42. package/dist/mcp/types.d.ts.map +1 -1
  43. package/dist/plugins/auth.d.ts +45 -0
  44. package/dist/plugins/auth.d.ts.map +1 -0
  45. package/dist/plugins/auth.js +268 -0
  46. package/dist/plugins/cache.d.ts +7 -1
  47. package/dist/plugins/cache.d.ts.map +1 -1
  48. package/dist/plugins/cache.js +470 -49
  49. package/dist/plugins/circuit-breaker.js +1 -1
  50. package/dist/plugins/compression.d.ts.map +1 -1
  51. package/dist/plugins/compression.js +3 -3
  52. package/dist/plugins/dedup.d.ts.map +1 -1
  53. package/dist/plugins/dedup.js +2 -1
  54. package/dist/plugins/graphql.d.ts +4 -3
  55. package/dist/plugins/graphql.d.ts.map +1 -1
  56. package/dist/plugins/graphql.js +24 -5
  57. package/dist/plugins/grpc-web.d.ts +80 -0
  58. package/dist/plugins/grpc-web.d.ts.map +1 -0
  59. package/dist/plugins/grpc-web.js +261 -0
  60. package/dist/plugins/har-player.d.ts.map +1 -1
  61. package/dist/plugins/har-player.js +11 -2
  62. package/dist/plugins/hls.d.ts +33 -0
  63. package/dist/plugins/hls.d.ts.map +1 -0
  64. package/dist/plugins/hls.js +225 -0
  65. package/dist/plugins/http2-push.d.ts +64 -0
  66. package/dist/plugins/http2-push.d.ts.map +1 -0
  67. package/dist/plugins/http2-push.js +274 -0
  68. package/dist/plugins/http3.d.ts +76 -0
  69. package/dist/plugins/http3.d.ts.map +1 -0
  70. package/dist/plugins/http3.js +231 -0
  71. package/dist/plugins/interface-rotator.d.ts +10 -0
  72. package/dist/plugins/interface-rotator.d.ts.map +1 -0
  73. package/dist/plugins/interface-rotator.js +57 -0
  74. package/dist/plugins/jsonrpc.d.ts +76 -0
  75. package/dist/plugins/jsonrpc.d.ts.map +1 -0
  76. package/dist/plugins/jsonrpc.js +143 -0
  77. package/dist/plugins/logger.d.ts +8 -5
  78. package/dist/plugins/logger.d.ts.map +1 -1
  79. package/dist/plugins/logger.js +66 -30
  80. package/dist/plugins/odata.d.ts +182 -0
  81. package/dist/plugins/odata.d.ts.map +1 -0
  82. package/dist/plugins/odata.js +561 -0
  83. package/dist/plugins/retry.d.ts +1 -0
  84. package/dist/plugins/retry.d.ts.map +1 -1
  85. package/dist/plugins/retry.js +26 -2
  86. package/dist/plugins/scrape.d.ts +22 -0
  87. package/dist/plugins/scrape.d.ts.map +1 -0
  88. package/dist/plugins/scrape.js +87 -0
  89. package/dist/plugins/soap.d.ts +73 -0
  90. package/dist/plugins/soap.d.ts.map +1 -0
  91. package/dist/plugins/soap.js +347 -0
  92. package/dist/plugins/user-agent.d.ts +8 -0
  93. package/dist/plugins/user-agent.d.ts.map +1 -0
  94. package/dist/plugins/user-agent.js +46 -0
  95. package/dist/plugins/xml.d.ts +10 -0
  96. package/dist/plugins/xml.d.ts.map +1 -0
  97. package/dist/plugins/xml.js +194 -0
  98. package/dist/presets/anthropic.d.ts +7 -0
  99. package/dist/presets/anthropic.d.ts.map +1 -0
  100. package/dist/presets/anthropic.js +17 -0
  101. package/dist/presets/azure-openai.d.ts +9 -0
  102. package/dist/presets/azure-openai.d.ts.map +1 -0
  103. package/dist/presets/azure-openai.js +25 -0
  104. package/dist/presets/cloudflare.d.ts +13 -0
  105. package/dist/presets/cloudflare.d.ts.map +1 -0
  106. package/dist/presets/cloudflare.js +39 -0
  107. package/dist/presets/cohere.d.ts +6 -0
  108. package/dist/presets/cohere.d.ts.map +1 -0
  109. package/dist/presets/cohere.js +16 -0
  110. package/dist/presets/deepseek.d.ts +6 -0
  111. package/dist/presets/deepseek.d.ts.map +1 -0
  112. package/dist/presets/deepseek.js +16 -0
  113. package/dist/presets/digitalocean.d.ts +6 -0
  114. package/dist/presets/digitalocean.d.ts.map +1 -0
  115. package/dist/presets/digitalocean.js +16 -0
  116. package/dist/presets/discord.d.ts +7 -0
  117. package/dist/presets/discord.d.ts.map +1 -0
  118. package/dist/presets/discord.js +17 -0
  119. package/dist/presets/fireworks.d.ts +6 -0
  120. package/dist/presets/fireworks.d.ts.map +1 -0
  121. package/dist/presets/fireworks.js +16 -0
  122. package/dist/presets/gemini.d.ts +6 -0
  123. package/dist/presets/gemini.d.ts.map +1 -0
  124. package/dist/presets/gemini.js +16 -0
  125. package/dist/presets/github.d.ts +7 -0
  126. package/dist/presets/github.d.ts.map +1 -0
  127. package/dist/presets/github.js +17 -0
  128. package/dist/presets/gitlab.d.ts +7 -0
  129. package/dist/presets/gitlab.d.ts.map +1 -0
  130. package/dist/presets/gitlab.js +16 -0
  131. package/dist/presets/groq.d.ts +6 -0
  132. package/dist/presets/groq.d.ts.map +1 -0
  133. package/dist/presets/groq.js +16 -0
  134. package/dist/presets/huggingface.d.ts +6 -0
  135. package/dist/presets/huggingface.d.ts.map +1 -0
  136. package/dist/presets/huggingface.js +16 -0
  137. package/dist/presets/index.d.ts +28 -0
  138. package/dist/presets/index.d.ts.map +1 -0
  139. package/dist/presets/index.js +27 -0
  140. package/dist/presets/linear.d.ts +6 -0
  141. package/dist/presets/linear.d.ts.map +1 -0
  142. package/dist/presets/linear.js +16 -0
  143. package/dist/presets/mistral.d.ts +6 -0
  144. package/dist/presets/mistral.d.ts.map +1 -0
  145. package/dist/presets/mistral.js +16 -0
  146. package/dist/presets/notion.d.ts +7 -0
  147. package/dist/presets/notion.d.ts.map +1 -0
  148. package/dist/presets/notion.js +17 -0
  149. package/dist/presets/openai.d.ts +8 -0
  150. package/dist/presets/openai.d.ts.map +1 -0
  151. package/dist/presets/openai.js +23 -0
  152. package/dist/presets/perplexity.d.ts +6 -0
  153. package/dist/presets/perplexity.d.ts.map +1 -0
  154. package/dist/presets/perplexity.js +16 -0
  155. package/dist/presets/registry.d.ts +20 -0
  156. package/dist/presets/registry.d.ts.map +1 -0
  157. package/dist/presets/registry.js +311 -0
  158. package/dist/presets/replicate.d.ts +6 -0
  159. package/dist/presets/replicate.d.ts.map +1 -0
  160. package/dist/presets/replicate.js +16 -0
  161. package/dist/presets/slack.d.ts +6 -0
  162. package/dist/presets/slack.d.ts.map +1 -0
  163. package/dist/presets/slack.js +16 -0
  164. package/dist/presets/stripe.d.ts +8 -0
  165. package/dist/presets/stripe.d.ts.map +1 -0
  166. package/dist/presets/stripe.js +23 -0
  167. package/dist/presets/supabase.d.ts +7 -0
  168. package/dist/presets/supabase.d.ts.map +1 -0
  169. package/dist/presets/supabase.js +18 -0
  170. package/dist/presets/together.d.ts +6 -0
  171. package/dist/presets/together.d.ts.map +1 -0
  172. package/dist/presets/together.js +16 -0
  173. package/dist/presets/twilio.d.ts +7 -0
  174. package/dist/presets/twilio.d.ts.map +1 -0
  175. package/dist/presets/twilio.js +17 -0
  176. package/dist/presets/vercel.d.ts +7 -0
  177. package/dist/presets/vercel.d.ts.map +1 -0
  178. package/dist/presets/vercel.js +23 -0
  179. package/dist/presets/xai.d.ts +7 -0
  180. package/dist/presets/xai.d.ts.map +1 -0
  181. package/dist/presets/xai.js +17 -0
  182. package/dist/protocols/ftp.d.ts +63 -0
  183. package/dist/protocols/ftp.d.ts.map +1 -0
  184. package/dist/protocols/ftp.js +388 -0
  185. package/dist/protocols/index.d.ts +4 -0
  186. package/dist/protocols/index.d.ts.map +1 -0
  187. package/dist/protocols/index.js +3 -0
  188. package/dist/protocols/sftp.d.ts +65 -0
  189. package/dist/protocols/sftp.d.ts.map +1 -0
  190. package/dist/protocols/sftp.js +346 -0
  191. package/dist/protocols/telnet.d.ts +50 -0
  192. package/dist/protocols/telnet.d.ts.map +1 -0
  193. package/dist/protocols/telnet.js +139 -0
  194. package/dist/runner/request-runner.d.ts.map +1 -1
  195. package/dist/runner/request-runner.js +1 -0
  196. package/dist/scrape/document.d.ts +44 -0
  197. package/dist/scrape/document.d.ts.map +1 -0
  198. package/dist/scrape/document.js +198 -0
  199. package/dist/scrape/element.d.ts +50 -0
  200. package/dist/scrape/element.d.ts.map +1 -0
  201. package/dist/scrape/element.js +176 -0
  202. package/dist/scrape/extractors.d.ts +17 -0
  203. package/dist/scrape/extractors.d.ts.map +1 -0
  204. package/dist/scrape/extractors.js +356 -0
  205. package/dist/scrape/index.d.ts +5 -0
  206. package/dist/scrape/index.d.ts.map +1 -0
  207. package/dist/scrape/index.js +3 -0
  208. package/dist/scrape/types.d.ts +108 -0
  209. package/dist/scrape/types.d.ts.map +1 -0
  210. package/dist/scrape/types.js +1 -0
  211. package/dist/testing/index.d.ts +3 -0
  212. package/dist/testing/index.d.ts.map +1 -0
  213. package/dist/testing/index.js +1 -0
  214. package/dist/testing/mock.d.ts +58 -0
  215. package/dist/testing/mock.d.ts.map +1 -0
  216. package/dist/testing/mock.js +252 -0
  217. package/dist/transport/fetch.d.ts.map +1 -1
  218. package/dist/transport/fetch.js +12 -4
  219. package/dist/transport/undici.d.ts +17 -1
  220. package/dist/transport/undici.d.ts.map +1 -1
  221. package/dist/transport/undici.js +708 -47
  222. package/dist/types/index.d.ts +111 -10
  223. package/dist/types/index.d.ts.map +1 -1
  224. package/dist/types/index.js +1 -1
  225. package/dist/types/logger.d.ts +17 -0
  226. package/dist/types/logger.d.ts.map +1 -0
  227. package/dist/types/logger.js +66 -0
  228. package/dist/utils/agent-manager.d.ts.map +1 -1
  229. package/dist/utils/agent-manager.js +20 -4
  230. package/dist/utils/body.d.ts.map +1 -1
  231. package/dist/utils/body.js +14 -2
  232. package/dist/utils/charset.d.ts +16 -0
  233. package/dist/utils/charset.d.ts.map +1 -0
  234. package/dist/utils/charset.js +169 -0
  235. package/dist/utils/client-pool.d.ts +21 -0
  236. package/dist/utils/client-pool.d.ts.map +1 -0
  237. package/dist/utils/client-pool.js +49 -0
  238. package/dist/utils/concurrency.d.ts.map +1 -1
  239. package/dist/utils/concurrency.js +8 -4
  240. package/dist/utils/dns-toolkit.d.ts +13 -0
  241. package/dist/utils/dns-toolkit.d.ts.map +1 -0
  242. package/dist/utils/dns-toolkit.js +48 -0
  243. package/dist/utils/doh.d.ts.map +1 -1
  244. package/dist/utils/doh.js +16 -3
  245. package/dist/utils/download.d.ts +15 -0
  246. package/dist/utils/download.d.ts.map +1 -0
  247. package/dist/utils/download.js +44 -0
  248. package/dist/utils/env-proxy.d.ts +13 -0
  249. package/dist/utils/env-proxy.d.ts.map +1 -0
  250. package/dist/utils/env-proxy.js +105 -0
  251. package/dist/utils/header-parser.d.ts +15 -1
  252. package/dist/utils/header-parser.d.ts.map +1 -1
  253. package/dist/utils/header-parser.js +161 -1
  254. package/dist/utils/link-header.d.ts +70 -0
  255. package/dist/utils/link-header.d.ts.map +1 -0
  256. package/dist/utils/link-header.js +190 -0
  257. package/dist/utils/progress.d.ts +7 -2
  258. package/dist/utils/progress.d.ts.map +1 -1
  259. package/dist/utils/progress.js +48 -15
  260. package/dist/utils/rdap.d.ts +17 -0
  261. package/dist/utils/rdap.d.ts.map +1 -0
  262. package/dist/utils/rdap.js +32 -0
  263. package/dist/utils/request-pool.d.ts.map +1 -1
  264. package/dist/utils/request-pool.js +4 -3
  265. package/dist/utils/sse.d.ts.map +1 -1
  266. package/dist/utils/sse.js +8 -2
  267. package/dist/utils/status-codes.d.ts +84 -0
  268. package/dist/utils/status-codes.d.ts.map +1 -0
  269. package/dist/utils/status-codes.js +204 -0
  270. package/dist/utils/streaming.d.ts.map +1 -1
  271. package/dist/utils/streaming.js +1 -0
  272. package/dist/utils/tls-inspector.d.ts +21 -0
  273. package/dist/utils/tls-inspector.d.ts.map +1 -0
  274. package/dist/utils/tls-inspector.js +39 -0
  275. package/dist/utils/try-fn.d.ts.map +1 -1
  276. package/dist/utils/try-fn.js +11 -5
  277. package/dist/utils/upload.d.ts +1 -0
  278. package/dist/utils/upload.d.ts.map +1 -1
  279. package/dist/utils/upload.js +20 -3
  280. package/dist/utils/user-agent.d.ts +9 -9
  281. package/dist/utils/user-agent.js +9 -9
  282. package/dist/utils/whois.d.ts.map +1 -1
  283. package/dist/utils/whois.js +11 -2
  284. package/dist/websocket/client.d.ts +29 -1
  285. package/dist/websocket/client.d.ts.map +1 -1
  286. package/dist/websocket/client.js +145 -13
  287. package/package.json +45 -8
@@ -1,4 +1,4 @@
1
- import { Method, ReckerRequest, RequestOptions, ProgressCallback } from '../types/index.js';
1
+ import { Method, ReckerRequest, RequestOptions, ProgressCallback, TimeoutOptions, RedirectInfo } from '../types/index.js';
2
2
  export declare class HttpRequest implements ReckerRequest {
3
3
  readonly url: string;
4
4
  readonly method: Method;
@@ -6,8 +6,14 @@ export declare class HttpRequest implements ReckerRequest {
6
6
  readonly body: BodyInit | null;
7
7
  readonly signal?: AbortSignal;
8
8
  readonly throwHttpErrors?: boolean;
9
+ readonly timeout?: TimeoutOptions;
9
10
  readonly onUploadProgress?: ProgressCallback;
10
11
  readonly onDownloadProgress?: ProgressCallback;
12
+ readonly maxResponseSize?: number;
13
+ readonly beforeRedirect?: (info: RedirectInfo) => void | false | string | Promise<void | false | string>;
14
+ readonly maxRedirects?: number;
15
+ readonly followRedirects?: boolean;
16
+ readonly http2?: boolean;
11
17
  constructor(url: string, options?: RequestOptions);
12
18
  withHeader(name: string, value: string): ReckerRequest;
13
19
  withBody(body: BodyInit): ReckerRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,qBAAa,WAAY,YAAW,aAAa;IAC/C,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtC,SAAgB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrC,SAAgB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1C,SAAgB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpD,SAAgB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;gBAE1C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAWrD,UAAU,C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AiBxC"}
@@ -1,3 +1,11 @@
1
+ function normalizeTimeout(timeout) {
2
+ if (timeout === undefined)
3
+ return undefined;
4
+ if (typeof timeout === 'number') {
5
+ return { request: timeout };
6
+ }
7
+ return timeout;
8
+ }
1
9
  export class HttpRequest {
2
10
  url;
3
11
  method;
@@ -5,8 +13,14 @@ export class HttpRequest {
5
13
  body;
6
14
  signal;
7
15
  throwHttpErrors;
16
+ timeout;
8
17
  onUploadProgress;
9
18
  onDownloadProgress;
19
+ maxResponseSize;
20
+ beforeRedirect;
21
+ maxRedirects;
22
+ followRedirects;
23
+ http2;
10
24
  constructor(url, options = {}) {
11
25
  this.url = url;
12
26
  this.method = options.method || 'GET';
@@ -14,8 +28,14 @@ export class HttpRequest {
14
28
  this.body = options.body || null;
15
29
  this.signal = options.signal;
16
30
  this.throwHttpErrors = options.throwHttpErrors !== undefined ? options.throwHttpErrors : true;
31
+ this.timeout = normalizeTimeout(options.timeout);
17
32
  this.onUploadProgress = options.onUploadProgress;
18
33
  this.onDownloadProgress = options.onDownloadProgress;
34
+ this.maxResponseSize = options.maxResponseSize;
35
+ this.beforeRedirect = options.beforeRedirect;
36
+ this.maxRedirects = options.maxRedirects;
37
+ this.followRedirects = options.followRedirects;
38
+ this.http2 = options.http2;
19
39
  }
20
40
  withHeader(name, value) {
21
41
  const newHeaders = new Headers(this.headers);
@@ -26,8 +46,14 @@ export class HttpRequest {
26
46
  body: this.body,
27
47
  signal: this.signal,
28
48
  throwHttpErrors: this.throwHttpErrors,
49
+ timeout: this.timeout,
29
50
  onUploadProgress: this.onUploadProgress,
30
51
  onDownloadProgress: this.onDownloadProgress,
52
+ maxResponseSize: this.maxResponseSize,
53
+ beforeRedirect: this.beforeRedirect,
54
+ maxRedirects: this.maxRedirects,
55
+ followRedirects: this.followRedirects,
56
+ http2: this.http2,
31
57
  });
32
58
  }
33
59
  withBody(body) {
@@ -37,8 +63,14 @@ export class HttpRequest {
37
63
  body: body,
38
64
  signal: this.signal,
39
65
  throwHttpErrors: this.throwHttpErrors,
66
+ timeout: this.timeout,
40
67
  onUploadProgress: this.onUploadProgress,
41
68
  onDownloadProgress: this.onDownloadProgress,
69
+ maxResponseSize: this.maxResponseSize,
70
+ beforeRedirect: this.beforeRedirect,
71
+ maxRedirects: this.maxRedirects,
72
+ followRedirects: this.followRedirects,
73
+ http2: this.http2,
42
74
  });
43
75
  }
44
76
  }
@@ -1,6 +1,7 @@
1
1
  import { ConnectionInfo, ReckerResponse, Timings, SSEEvent, ProgressEvent } from '../types/index.js';
2
2
  import { Dispatcher } from 'undici';
3
3
  import { type HeaderInfo, type CacheInfo, type RateLimitInfo } from '../utils/header-parser.js';
4
+ import { type LinkHeaderParser } from '../utils/link-header.js';
4
5
  import type { Readable } from 'node:stream';
5
6
  export declare class HttpResponse<T = unknown> implements ReckerResponse<T> {
6
7
  readonly timings?: Timings;
@@ -17,6 +18,7 @@ export declare class HttpResponse<T = unknown> implements ReckerResponse<T> {
17
18
  get url(): string;
18
19
  get cache(): CacheInfo;
19
20
  get rateLimit(): RateLimitInfo;
21
+ links(): LinkHeaderParser | null;
20
22
  get headerInfo(): HeaderInfo;
21
23
  json<R = T>(): Promise<R>;
22
24
  text(): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,cAAc,CAAC,CAAC,CAAC;IACjE,SAAgB,OAAO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,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB7D,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC;IAO1B,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC;IAgBxB,QAAQ,IAAI,cAAc,CAAC,aAAa,CAAC;IA2EzC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC;CAe5D"}
@@ -2,6 +2,8 @@ import { parseSSE } from '../utils/sse.js';
2
2
  import { cleanHtml } from '../utils/html-cleaner.js';
3
3
  import { webToNodeStream } from '../utils/streaming.js';
4
4
  import { parseHeaders } from '../utils/header-parser.js';
5
+ import { parseLinkHeader } from '../utils/link-header.js';
6
+ import { ReckerError } from './errors.js';
5
7
  export class HttpResponse {
6
8
  timings;
7
9
  connection;
@@ -41,6 +43,9 @@ export class HttpResponse {
41
43
  get rateLimit() {
42
44
  return parseHeaders(this.headers, this.status).rateLimit;
43
45
  }
46
+ links() {
47
+ return parseLinkHeader(this.headers);
48
+ }
44
49
  get headerInfo() {
45
50
  return parseHeaders(this.headers, this.status);
46
51
  }
@@ -69,7 +74,11 @@ export class HttpResponse {
69
74
  async pipe(destination) {
70
75
  const nodeStream = this.toNodeStream();
71
76
  if (!nodeStream) {
72
- throw new Error('Response has no body to pipe');
77
+ throw new ReckerError('Response has no body to pipe', undefined, this, [
78
+ 'Ensure the request method returns a body (e.g., not HEAD).',
79
+ 'Check the upstream response status and headers.',
80
+ 'Verify the request was not aborted before receiving a body.'
81
+ ]);
73
82
  }
74
83
  return new Promise((resolve, reject) => {
75
84
  nodeStream.pipe(destination);
@@ -95,35 +104,51 @@ export class HttpResponse {
95
104
  const total = contentLength ? parseInt(contentLength, 10) : undefined;
96
105
  let loaded = 0;
97
106
  const startTime = Date.now();
98
- let lastUpdate = startTime;
107
+ let lastUpdate = 0;
108
+ let lastLoaded = 0;
109
+ let lastRateUpdate = startTime;
110
+ let smoothedRate = 0;
111
+ const rateSmoothingFactor = 0.3;
112
+ const createProgress = (isFinal) => {
113
+ const now = Date.now();
114
+ const intervalMs = now - lastRateUpdate;
115
+ const bytesInInterval = loaded - lastLoaded;
116
+ if (intervalMs > 0) {
117
+ const instantRate = (bytesInInterval / intervalMs) * 1000;
118
+ smoothedRate = smoothedRate === 0
119
+ ? instantRate
120
+ : smoothedRate * (1 - rateSmoothingFactor) + instantRate * rateSmoothingFactor;
121
+ }
122
+ lastLoaded = loaded;
123
+ lastRateUpdate = now;
124
+ let percent;
125
+ if (total) {
126
+ percent = isFinal ? 100 : Math.min((loaded / total) * 100, 99.9);
127
+ }
128
+ return {
129
+ loaded,
130
+ transferred: loaded,
131
+ total,
132
+ percent,
133
+ rate: smoothedRate,
134
+ estimated: total && smoothedRate > 0 ? ((total - loaded) / smoothedRate) * 1000 : undefined,
135
+ direction: 'download',
136
+ };
137
+ };
99
138
  const reader = this.raw.body.getReader();
100
139
  try {
140
+ yield createProgress(false);
101
141
  while (true) {
102
142
  const { done, value } = await reader.read();
103
143
  if (done) {
104
- const elapsed = (Date.now() - startTime) / 1000;
105
- const rate = elapsed > 0 ? loaded / elapsed : 0;
106
- yield {
107
- loaded,
108
- total,
109
- percent: total ? 100 : undefined,
110
- rate,
111
- };
144
+ yield createProgress(true);
112
145
  break;
113
146
  }
114
147
  if (value) {
115
148
  loaded += value.byteLength;
116
149
  const now = Date.now();
117
- const elapsed = (now - startTime) / 1000;
118
- const rate = elapsed > 0 ? loaded / elapsed : 0;
119
150
  if (now - lastUpdate > 100) {
120
- yield {
121
- loaded,
122
- total,
123
- percent: total ? (loaded / total) * 100 : undefined,
124
- rate,
125
- estimated: total && rate > 0 ? ((total - loaded) / rate) * 1000 : undefined,
126
- };
151
+ yield createProgress(false);
127
152
  lastUpdate = now;
128
153
  }
129
154
  }
@@ -0,0 +1,48 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { ProgressEvent, ReckerResponse, ReckerRequest } from '../types/index.js';
3
+ export interface RequestEvents {
4
+ request: (request: ReckerRequest) => void;
5
+ response: (response: ResponseInfo) => void;
6
+ downloadProgress: (progress: ProgressEvent) => void;
7
+ uploadProgress: (progress: ProgressEvent) => void;
8
+ retry: (info: RetryInfo) => void;
9
+ redirect: (info: EventRedirectInfo) => void;
10
+ complete: (response: ReckerResponse) => void;
11
+ error: (error: Error) => void;
12
+ }
13
+ export interface ResponseInfo {
14
+ status: number;
15
+ statusText: string;
16
+ headers: Headers;
17
+ url: string;
18
+ }
19
+ export interface RetryInfo {
20
+ attempt: number;
21
+ maxAttempts: number;
22
+ error: Error;
23
+ delay: number;
24
+ }
25
+ export interface EventRedirectInfo {
26
+ from: string;
27
+ to: string;
28
+ status: number;
29
+ }
30
+ export declare class RequestEventEmitter extends EventEmitter {
31
+ on<E extends keyof RequestEvents>(event: E, listener: RequestEvents[E]): this;
32
+ once<E extends keyof RequestEvents>(event: E, listener: RequestEvents[E]): this;
33
+ emit<E extends keyof RequestEvents>(event: E, ...args: Parameters<RequestEvents[E]>): boolean;
34
+ off<E extends keyof RequestEvents>(event: E, listener: RequestEvents[E]): this;
35
+ removeListener<E extends keyof RequestEvents>(event: E, listener: RequestEvents[E]): this;
36
+ }
37
+ export declare function createRequestEvents(): RequestEventEmitter;
38
+ export declare function createEventStream(stream: ReadableStream<Uint8Array>, events: RequestEventEmitter, options: {
39
+ total?: number;
40
+ direction: 'upload' | 'download';
41
+ throttleMs?: number;
42
+ }): ReadableStream<Uint8Array>;
43
+ export interface StreamEventsConfig {
44
+ events: RequestEventEmitter;
45
+ total?: number;
46
+ throttleMs?: number;
47
+ }
48
+ //# sourceMappingURL=request-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-events.d.ts","sourceRoot":"","sources":["../../src/events/request-events.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKtF,MAAM,WAAW,aAAa;IAE5B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AM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO;IAI7F,GAAG,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI;IAI9E,cAAc,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI;CAG1F;AAoBD,wBAAgB,mBAAmB,IAAI,mBAAmB,CAEzD;AAMD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,cAAc,CAAC,UAAU,CAAC,CA6E5B;AAKD,MAAM,WAAW,kBAAkB;IAEjC,MAAM,EAAE,mBAAmB,CAAC;IAG5B,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,85 @@
1
+ import { EventEmitter } from 'events';
2
+ export class RequestEventEmitter extends EventEmitter {
3
+ on(event, listener) {
4
+ return super.on(event, listener);
5
+ }
6
+ once(event, listener) {
7
+ return super.once(event, listener);
8
+ }
9
+ emit(event, ...args) {
10
+ return super.emit(event, ...args);
11
+ }
12
+ off(event, listener) {
13
+ return super.off(event, listener);
14
+ }
15
+ removeListener(event, listener) {
16
+ return super.removeListener(event, listener);
17
+ }
18
+ }
19
+ export function createRequestEvents() {
20
+ return new RequestEventEmitter();
21
+ }
22
+ export function createEventStream(stream, events, options) {
23
+ const { total, direction, throttleMs = 100 } = options;
24
+ let loaded = 0;
25
+ let startTime = Date.now();
26
+ let lastUpdate = 0;
27
+ let lastLoaded = 0;
28
+ let lastRateUpdate = startTime;
29
+ let smoothedRate = 0;
30
+ const rateSmoothingFactor = 0.3;
31
+ const emitProgress = (now, isFinal) => {
32
+ const intervalMs = now - lastRateUpdate;
33
+ const bytesInInterval = loaded - lastLoaded;
34
+ if (intervalMs > 0) {
35
+ const instantRate = (bytesInInterval / intervalMs) * 1000;
36
+ smoothedRate = smoothedRate === 0
37
+ ? instantRate
38
+ : smoothedRate * (1 - rateSmoothingFactor) + instantRate * rateSmoothingFactor;
39
+ }
40
+ lastLoaded = loaded;
41
+ lastRateUpdate = now;
42
+ let percent;
43
+ if (total) {
44
+ percent = isFinal ? 100 : Math.min((loaded / total) * 100, 99.9);
45
+ }
46
+ const progress = {
47
+ loaded,
48
+ transferred: loaded,
49
+ total,
50
+ percent,
51
+ rate: smoothedRate,
52
+ estimated: total && smoothedRate > 0 ? ((total - loaded) / smoothedRate) * 1000 : undefined,
53
+ direction,
54
+ };
55
+ const event = direction === 'download' ? 'downloadProgress' : 'uploadProgress';
56
+ events.emit(event, progress);
57
+ lastUpdate = now;
58
+ };
59
+ return new ReadableStream({
60
+ async start(controller) {
61
+ const reader = stream.getReader();
62
+ try {
63
+ emitProgress(Date.now(), false);
64
+ while (true) {
65
+ const { done, value } = await reader.read();
66
+ if (done) {
67
+ emitProgress(Date.now(), true);
68
+ controller.close();
69
+ break;
70
+ }
71
+ loaded += value.byteLength;
72
+ const now = Date.now();
73
+ if (now - lastUpdate >= throttleMs || (total && loaded === total)) {
74
+ emitProgress(now, false);
75
+ }
76
+ controller.enqueue(value);
77
+ }
78
+ }
79
+ catch (error) {
80
+ controller.error(error);
81
+ throw error;
82
+ }
83
+ },
84
+ });
85
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export * from './core/request-promise.js';
2
2
  export * from './transport/undici.js';
3
+ export * from './utils/tls-inspector.js';
4
+ export * from './utils/rdap.js';
5
+ export * from './utils/dns-toolkit.js';
3
6
  export * from './transport/fetch.js';
4
- export * from './types/index.js';
5
7
  export * from './core/errors.js';
6
8
  export * from './core/client.js';
7
9
  export * from './core/request.js';
@@ -12,6 +14,7 @@ export * from './plugins/dedup.js';
12
14
  export * from './plugins/logger.js';
13
15
  export * from './plugins/circuit-breaker.js';
14
16
  export * from './plugins/cookie-jar.js';
17
+ export * from './cookies/memory-cookie-jar.js';
15
18
  export * from './runner/request-runner.js';
16
19
  export * from './contract/index.js';
17
20
  export * from './cache/memory-storage.js';
@@ -22,19 +25,42 @@ export * from './plugins/compression.js';
22
25
  export * from './utils/streaming.js';
23
26
  export * from './utils/request-pool.js';
24
27
  export * from './utils/header-parser.js';
28
+ export * from './utils/link-header.js';
25
29
  export * from './websocket/client.js';
26
30
  export * from './utils/whois.js';
27
31
  export * from './utils/dns.js';
28
32
  export * from './utils/cert.js';
29
33
  export * from './utils/doh.js';
30
34
  export * from './utils/upload.js';
35
+ export * from './utils/download.js';
31
36
  export * from './utils/user-agent.js';
32
37
  export * from './plugins/har-recorder.js';
33
38
  export * from './plugins/har-player.js';
34
39
  export * from './plugins/graphql.js';
40
+ export * from './plugins/xml.js';
41
+ export * from './plugins/scrape.js';
42
+ export * from './scrape/index.js';
35
43
  export * from './plugins/server-timing.js';
44
+ export * from './plugins/auth.js';
36
45
  export * from './plugins/proxy-rotator.js';
46
+ export * from './plugins/interface-rotator.js';
47
+ export * from './plugins/hls.js';
48
+ export * from './plugins/jsonrpc.js';
49
+ export * from './plugins/grpc-web.js';
50
+ export * from './plugins/soap.js';
51
+ export * from './plugins/odata.js';
52
+ export * from './plugins/http2-push.js';
53
+ export * from './plugins/http3.js';
37
54
  export * from './cache/redis-storage.js';
38
- export * from './mcp/index.js';
55
+ export * from './events/request-events.js';
56
+ export * from './constants/http-status.js';
57
+ export * from './utils/env-proxy.js';
58
+ export * from './utils/charset.js';
59
+ export * from './utils/client-pool.js';
60
+ export * as presets from './presets/index.js';
61
+ export * as testing from './testing/index.js';
62
+ export * as protocols from './protocols/index.js';
63
+ export * from './mcp/client.js';
64
+ export * from './mcp/contract.js';
39
65
  export { Client as Recker } from './core/client.js';
40
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC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,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAGlD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export * from './core/request-promise.js';
2
2
  export * from './transport/undici.js';
3
+ export * from './utils/tls-inspector.js';
4
+ export * from './utils/rdap.js';
5
+ export * from './utils/dns-toolkit.js';
3
6
  export * from './transport/fetch.js';
4
- export * from './types/index.js';
5
7
  export * from './core/errors.js';
6
8
  export * from './core/client.js';
7
9
  export * from './core/request.js';
@@ -12,6 +14,7 @@ export * from './plugins/dedup.js';
12
14
  export * from './plugins/logger.js';
13
15
  export * from './plugins/circuit-breaker.js';
14
16
  export * from './plugins/cookie-jar.js';
17
+ export * from './cookies/memory-cookie-jar.js';
15
18
  export * from './runner/request-runner.js';
16
19
  export * from './contract/index.js';
17
20
  export * from './cache/memory-storage.js';
@@ -22,18 +25,41 @@ export * from './plugins/compression.js';
22
25
  export * from './utils/streaming.js';
23
26
  export * from './utils/request-pool.js';
24
27
  export * from './utils/header-parser.js';
28
+ export * from './utils/link-header.js';
25
29
  export * from './websocket/client.js';
26
30
  export * from './utils/whois.js';
27
31
  export * from './utils/dns.js';
28
32
  export * from './utils/cert.js';
29
33
  export * from './utils/doh.js';
30
34
  export * from './utils/upload.js';
35
+ export * from './utils/download.js';
31
36
  export * from './utils/user-agent.js';
32
37
  export * from './plugins/har-recorder.js';
33
38
  export * from './plugins/har-player.js';
34
39
  export * from './plugins/graphql.js';
40
+ export * from './plugins/xml.js';
41
+ export * from './plugins/scrape.js';
42
+ export * from './scrape/index.js';
35
43
  export * from './plugins/server-timing.js';
44
+ export * from './plugins/auth.js';
36
45
  export * from './plugins/proxy-rotator.js';
46
+ export * from './plugins/interface-rotator.js';
47
+ export * from './plugins/hls.js';
48
+ export * from './plugins/jsonrpc.js';
49
+ export * from './plugins/grpc-web.js';
50
+ export * from './plugins/soap.js';
51
+ export * from './plugins/odata.js';
52
+ export * from './plugins/http2-push.js';
53
+ export * from './plugins/http3.js';
37
54
  export * from './cache/redis-storage.js';
38
- export * from './mcp/index.js';
55
+ export * from './events/request-events.js';
56
+ export * from './constants/http-status.js';
57
+ export * from './utils/env-proxy.js';
58
+ export * from './utils/charset.js';
59
+ export * from './utils/client-pool.js';
60
+ export * as presets from './presets/index.js';
61
+ export * as testing from './testing/index.js';
62
+ export * as protocols from './protocols/index.js';
63
+ export * from './mcp/client.js';
64
+ export * from './mcp/contract.js';
39
65
  export { Client as Recker } from './core/client.js';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAGV,aAAa,EACb,OAAO,EAEP,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAYjB,MAAM,YAAY,CAA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AM,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;MAOtF;IAEI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,IAAI,aAAa,GAAG,SAAS;IAI1C,WAAW,IAAI,OAAO;YAIR,OAAO;YAgDP,UAAU;IAkBxB,OAAO,CAAC,cAAc;CAgCvB;AAYD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAEpE"}
@@ -1,5 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { createClient } from '../core/client.js';
3
+ import { ReckerError } from '../core/errors.js';
4
+ import { consoleLogger } from '../types/logger.js';
3
5
  export class MCPClient extends EventEmitter {
4
6
  client;
5
7
  endpoint;
@@ -34,9 +36,10 @@ export class MCPClient extends EventEmitter {
34
36
  transport: options.transport,
35
37
  });
36
38
  if (this.options.debug) {
37
- this.on('request', (req) => console.log('[MCP Request]', req));
38
- this.on('response', (res) => console.log('[MCP Response]', res));
39
- this.on('notification', (notif) => console.log('[MCP Notification]', notif));
39
+ const logger = consoleLogger;
40
+ this.on('request', (req) => logger.debug({ type: 'mcp-request', data: req }, `[MCP Request] ${JSON.stringify(req)}`));
41
+ this.on('response', (res) => logger.debug({ type: 'mcp-response', data: res }, `[MCP Response] ${JSON.stringify(res)}`));
42
+ this.on('notification', (notif) => logger.debug({ type: 'mcp-notification', data: notif }, `[MCP Notification] ${JSON.stringify(notif)}`));
40
43
  }
41
44
  }
42
45
  async connect() {
@@ -125,7 +128,11 @@ export class MCPClient extends EventEmitter {
125
128
  }
126
129
  async request(method, params) {
127
130
  if (!this.initialized && method !== 'initialize') {
128
- throw new Error('MCP client not initialized. Call connect() first.');
131
+ throw new ReckerError('MCP client not initialized. Call connect() first.', undefined, undefined, [
132
+ 'Call connect() before invoking MCP methods.',
133
+ 'Check for initialization errors in serverInfo.',
134
+ 'Ensure the MCP server URL and credentials are correct.'
135
+ ]);
129
136
  }
130
137
  const request = {
131
138
  jsonrpc: '2.0',
@@ -139,7 +146,11 @@ export class MCPClient extends EventEmitter {
139
146
  .json();
140
147
  this.emit('response', response);
141
148
  if (response.error) {
142
- const error = new Error(response.error.message);
149
+ const error = new ReckerError(response.error.message, undefined, undefined, [
150
+ 'Inspect MCP server logs for the reported error.',
151
+ 'Validate request params against the tool schema.',
152
+ 'Retry if the error is transient.'
153
+ ]);
143
154
  error.code = response.error.code;
144
155
  error.data = response.error.data;
145
156
  throw error;
@@ -0,0 +1,77 @@
1
+ import { z, ZodSchema } from 'zod';
2
+ import type { MCPClient } from './client.js';
3
+ import type { MCPToolResult } from './types.js';
4
+ import type { Client } from '../core/client.js';
5
+ import type { SSEEvent } from '../utils/sse.js';
6
+ export interface MCPToolContract {
7
+ inputSchema?: ZodSchema;
8
+ outputSchema?: ZodSchema;
9
+ stream?: boolean;
10
+ description?: string;
11
+ }
12
+ export type MCPContractDefinition = Record<string, MCPToolContract>;
13
+ type ToolFunction<T extends MCPToolContract> = (args: T['inputSchema'] extends ZodSchema ? z.infer<T['inputSchema']> : Record<string, unknown>) => Promise<T['outputSchema'] extends ZodSchema ? z.infer<T['outputSchema']> : MCPToolResult>;
14
+ type StreamingToolFunction<T extends MCPToolContract> = (args: T['inputSchema'] extends ZodSchema ? z.infer<T['inputSchema']> : Record<string, unknown>) => AsyncGenerator<string, void, unknown>;
15
+ type MCPToolFunction<T extends MCPToolContract> = T['stream'] extends true ? StreamingToolFunction<T> : ToolFunction<T>;
16
+ export type MCPContractClient<T extends MCPContractDefinition> = {
17
+ [K in keyof T]: MCPToolFunction<T[K]>;
18
+ } & {
19
+ raw: <K extends keyof T>(name: K, args: T[K]['inputSchema'] extends ZodSchema ? z.infer<T[K]['inputSchema']> : Record<string, unknown>) => Promise<MCPToolResult>;
20
+ list: () => Array<{
21
+ name: string;
22
+ description?: string;
23
+ inputSchema?: ZodSchema;
24
+ }>;
25
+ has: (name: string) => boolean;
26
+ };
27
+ export declare class MCPContractError extends Error {
28
+ toolName: string;
29
+ validationType: 'input' | 'output';
30
+ originalError: Error;
31
+ constructor(toolName: string, validationType: 'input' | 'output', originalError: Error);
32
+ }
33
+ export declare function createMCPContract<T extends MCPContractDefinition>(mcp: MCPClient, contract: T): MCPContractClient<T>;
34
+ export declare function createMCPStream(mcp: MCPClient, toolName: string, options?: {
35
+ inputParam?: string;
36
+ extraParams?: Record<string, unknown>;
37
+ }): MCPStreamFunction;
38
+ export interface MCPStreamFunction {
39
+ (input: string): AsyncGenerator<string>;
40
+ text(input: string): Promise<string>;
41
+ json<T = unknown>(input: string): Promise<T>;
42
+ }
43
+ export declare function createMCPBatch<T extends MCPContractDefinition>(mcp: MCPClient, contract: T): <K extends keyof T>(calls: Array<{
44
+ tool: K;
45
+ args?: T[K]["inputSchema"] extends ZodSchema ? z.infer<T[K]["inputSchema"]> : Record<string, unknown>;
46
+ }>) => Promise<Array<{
47
+ success: boolean;
48
+ result?: any;
49
+ error?: Error;
50
+ }>>;
51
+ export interface SSEStreamOptions {
52
+ inputParam?: string;
53
+ extraParams?: Record<string, unknown>;
54
+ eventType?: string | string[];
55
+ extractData?: (event: SSEEvent) => string | null;
56
+ signal?: AbortSignal;
57
+ timeout?: number;
58
+ }
59
+ export interface SSEStreamFunction {
60
+ (input: string, options?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): AsyncGenerator<string>;
61
+ text(input: string, options?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): Promise<string>;
62
+ json<T = unknown>(input: string, options?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): Promise<T>;
63
+ events(input: string, options?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): AsyncGenerator<SSEEvent>;
64
+ }
65
+ export declare function createMCPSSEStream(client: Client, endpoint: string, options?: SSEStreamOptions): SSEStreamFunction;
66
+ export declare function createValidatedSSEStream<T extends ZodSchema>(client: Client, endpoint: string, options: SSEStreamOptions & {
67
+ inputSchema: T;
68
+ }): {
69
+ (args: z.infer<T>, callOptions?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): AsyncGenerator<string>;
70
+ text(args: z.infer<T>, callOptions?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): Promise<string>;
71
+ json<R = unknown>(args: z.infer<T>, callOptions?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): Promise<R>;
72
+ events(args: z.infer<T>, callOptions?: Pick<SSEStreamOptions, 'signal' | 'timeout'>): AsyncGenerator<SSEEvent>;
73
+ };
74
+ export declare function openAIExtractor(event: SSEEvent): string | null;
75
+ export declare function anthropicExtractor(event: SSEEvent): string | null;
76
+ export {};
77
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/mcp/contract.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,eAAe;IAE9B,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAMpE,KAAK,YAAY,CAAC,CAAC,SAAS,eAAe,IAAI,CAC7C,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,SAAS,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3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