recker 1.0.14 → 1.0.15-next.0e216c0

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 (79) hide show
  1. package/README.md +78 -100
  2. package/dist/ai/client.d.ts +2 -3
  3. package/dist/ai/client.d.ts.map +1 -1
  4. package/dist/ai/client.js +5 -6
  5. package/dist/ai/index.d.ts +1 -1
  6. package/dist/ai/index.d.ts.map +1 -1
  7. package/dist/ai/index.js +1 -1
  8. package/dist/bench/generator.d.ts.map +1 -1
  9. package/dist/bench/generator.js +2 -1
  10. package/dist/bench/stats.d.ts +15 -1
  11. package/dist/bench/stats.d.ts.map +1 -1
  12. package/dist/bench/stats.js +84 -5
  13. package/dist/cli/index.js +21 -0
  14. package/dist/cli/tui/ai-chat.js +2 -2
  15. package/dist/cli/tui/load-dashboard.d.ts.map +1 -1
  16. package/dist/cli/tui/load-dashboard.js +62 -8
  17. package/dist/cli/tui/scroll-buffer.d.ts +43 -0
  18. package/dist/cli/tui/scroll-buffer.d.ts.map +1 -0
  19. package/dist/cli/tui/scroll-buffer.js +162 -0
  20. package/dist/cli/tui/search-panel.d.ts +41 -0
  21. package/dist/cli/tui/search-panel.d.ts.map +1 -0
  22. package/dist/cli/tui/search-panel.js +419 -0
  23. package/dist/cli/tui/shell.d.ts +11 -0
  24. package/dist/cli/tui/shell.d.ts.map +1 -1
  25. package/dist/cli/tui/shell.js +236 -46
  26. package/dist/contract/index.js +3 -2
  27. package/dist/dns/index.d.ts +36 -0
  28. package/dist/dns/index.d.ts.map +1 -0
  29. package/dist/dns/index.js +125 -0
  30. package/dist/dns/propagation.d.ts +19 -0
  31. package/dist/dns/propagation.d.ts.map +1 -0
  32. package/dist/dns/propagation.js +129 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/mcp/embeddings-loader.d.ts +18 -0
  37. package/dist/mcp/embeddings-loader.d.ts.map +1 -0
  38. package/dist/mcp/embeddings-loader.js +152 -0
  39. package/dist/mcp/index.d.ts +1 -0
  40. package/dist/mcp/index.d.ts.map +1 -1
  41. package/dist/mcp/index.js +1 -0
  42. package/dist/mcp/search/hybrid-search.d.ts.map +1 -1
  43. package/dist/mcp/search/hybrid-search.js +7 -21
  44. package/dist/mcp/server.d.ts +2 -0
  45. package/dist/mcp/server.d.ts.map +1 -1
  46. package/dist/mcp/server.js +8 -1
  47. package/dist/recker.d.ts +47 -0
  48. package/dist/recker.d.ts.map +1 -0
  49. package/dist/recker.js +99 -0
  50. package/dist/transport/base-udp.d.ts.map +1 -1
  51. package/dist/transport/base-udp.js +1 -0
  52. package/dist/transport/udp-response.d.ts +2 -2
  53. package/dist/transport/udp-response.d.ts.map +1 -1
  54. package/dist/transport/udp-response.js +2 -2
  55. package/dist/transport/udp.d.ts +4 -3
  56. package/dist/transport/udp.d.ts.map +1 -1
  57. package/dist/transport/udp.js +16 -7
  58. package/dist/types/udp.d.ts +1 -0
  59. package/dist/types/udp.d.ts.map +1 -1
  60. package/dist/udp/index.d.ts +2 -2
  61. package/dist/udp/index.d.ts.map +1 -1
  62. package/dist/udp/index.js +2 -2
  63. package/dist/utils/colors.d.ts +16 -0
  64. package/dist/utils/colors.d.ts.map +1 -1
  65. package/dist/utils/colors.js +16 -0
  66. package/dist/utils/tls-inspector.d.ts +6 -0
  67. package/dist/utils/tls-inspector.d.ts.map +1 -1
  68. package/dist/utils/tls-inspector.js +35 -1
  69. package/dist/utils/whois.d.ts +18 -0
  70. package/dist/utils/whois.d.ts.map +1 -1
  71. package/dist/utils/whois.js +63 -0
  72. package/dist/webrtc/index.d.ts +80 -0
  73. package/dist/webrtc/index.d.ts.map +1 -0
  74. package/dist/webrtc/index.js +311 -0
  75. package/dist/websocket/client.d.ts +1 -1
  76. package/dist/websocket/client.d.ts.map +1 -1
  77. package/dist/websocket/client.js +1 -1
  78. package/package.json +2 -2
  79. package/dist/mcp/data/embeddings.json +0 -1
package/README.md CHANGED
@@ -1,158 +1,136 @@
1
- # Recker
2
-
3
1
  <div align="center">
4
2
 
5
- <img src="docs/assets/logo.svg" alt="Recker Logo" width="200" />
3
+ # Recker
6
4
 
7
- ### The HTTP SDK for the AI Era
5
+ ### The Network SDK for the AI Era
8
6
 
9
- **Fast as infrastructure demands. AI-ready from the first byte. Observable down to the millisecond. Resilient when everything else fails.**
7
+ **Zero-config HTTP. Multi-protocol support. AI-native streaming. Observable to the millisecond.**
10
8
 
11
9
  [![npm version](https://img.shields.io/npm/v/recker.svg?style=flat-square&color=F5A623)](https://www.npmjs.com/package/recker)
12
10
  [![npm downloads](https://img.shields.io/npm/dm/recker.svg?style=flat-square&color=34C759)](https://www.npmjs.com/package/recker)
13
11
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
14
12
  [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/)
15
- [![Coverage](https://img.shields.io/badge/coverage-85%25-F5A623?style=flat-square)](https://github.com/forattini-dev/recker)
13
+ [![Coverage](https://img.shields.io/badge/coverage-90%25-34C759?style=flat-square)](https://github.com/forattini-dev/recker)
16
14
  [![License](https://img.shields.io/npm/l/recker.svg?style=flat-square&color=007AFF)](https://github.com/forattini-dev/recker/blob/main/LICENSE)
17
15
 
18
- [Documentation](https://forattini-dev.github.io/recker) · [Examples](./docs/examples/README.md) · [Migration](./docs/migration.md)
16
+ [Documentation](https://forattini-dev.github.io/recker) · [API Reference](./docs/reference/01-api.md) · [Examples](./docs/examples/README.md)
19
17
 
20
18
  </div>
21
19
 
22
20
  ---
23
21
 
24
- ## 📦 Install
22
+ ## Install
25
23
 
26
24
  ```bash
27
25
  npm install recker
28
26
  ```
29
27
 
30
- ## 🚀 Quick Start
28
+ ## Quick Start
31
29
 
32
30
  ```typescript
33
- import { createClient } from 'recker';
31
+ import { get, post, whois, dns } from 'recker';
32
+
33
+ // HTTP - zero config
34
+ const users = await get('https://api.example.com/users').json();
35
+ await post('https://api.example.com/users', { json: { name: 'John' } });
34
36
 
35
- const client = createClient({ baseUrl: 'https://api.example.com' });
37
+ // WHOIS
38
+ const info = await whois('github.com');
36
39
 
37
- // GET with JSON
38
- const users = await client.get('/users').json();
40
+ // DNS
41
+ const ips = await dns('google.com');
42
+ ```
43
+
44
+ ### Unified Namespace
39
45
 
40
- // POST with body
41
- await client.post('/users', { json: { name: 'John' } });
46
+ ```typescript
47
+ import { recker } from 'recker';
42
48
 
43
- // Path params + query
44
- await client.get('/users/:id', { params: { id: '123', expand: 'profile' } });
49
+ // Everything in one place
50
+ await recker.get('https://api.example.com/users').json();
51
+ await recker.whois('github.com');
52
+ await recker.dns('google.com');
53
+ await recker.ai.chat('Hello!');
54
+
55
+ const socket = recker.ws('wss://api.example.com/ws');
45
56
  ```
46
57
 
47
- ## Why Recker?
58
+ ### With Configuration
59
+
60
+ ```typescript
61
+ import { createClient } from 'recker';
62
+
63
+ const api = createClient({
64
+ baseUrl: 'https://api.example.com',
65
+ headers: { 'Authorization': 'Bearer token' },
66
+ timeout: 10000,
67
+ retry: { maxAttempts: 3 }
68
+ });
69
+
70
+ const user = await api.get('/users/:id', { params: { id: '123' } }).json();
71
+ ```
48
72
 
49
- Recker isn't just another HTTP client. It's a **complete orchestration layer** designed for modern, data-intensive applications.
73
+ ## Features
50
74
 
51
75
  | Feature | Description |
52
76
  |:---|:---|
53
- | 🔮 **19 HTTP Methods** | Beyond CRUD: WebDAV, CDN Purging, and specialized verbs. |
54
- | 🤖 **AI-First** | Native Server-Sent Events (SSE) parsing optimized for LLMs. |
55
- | 🕷️ **Scraping Ready** | jQuery-like HTML parsing, HLS downloading, and proxy rotation. |
56
- | 🛡️ **Security Suite** | Built-in SSL inspection, WHOIS/RDAP, and DNS analysis. |
57
- | **Performance** | Connection pooling, deduplication, and deep network metrics. |
58
- | 🛡️ **Resilience** | Circuit breakers, smart retries, and rate limit awareness. |
77
+ | **Zero Config** | Direct functions work out of the box. No setup required. |
78
+ | **Multi-Protocol** | HTTP, WebSocket, DNS, WHOIS, FTP, SFTP, Telnet in one SDK. |
79
+ | **AI-Native** | SSE streaming, token counting, provider abstraction. |
80
+ | **Type-Safe** | Full TypeScript with Zod schema validation. |
81
+ | **Observable** | DNS/TCP/TLS/TTFB timing breakdown per request. |
82
+ | **Resilient** | Retry, circuit breaker, rate limiting, deduplication. |
59
83
 
60
- ## 💡 Feature Highlights
84
+ ## Highlights
61
85
 
62
- ### Stream AI Responses
63
- Handle LLM streams effortlessly with the `.sse()` iterator.
86
+ ### AI Streaming
64
87
 
65
88
  ```typescript
66
- for await (const event of client.post('/v1/chat/completions', {
67
- json: { model: 'gpt-5', messages, stream: true }
68
- }).sse()) {
69
- process.stdout.write(event.data);
89
+ for await (const event of recker.ai.stream({
90
+ model: 'gpt-4',
91
+ messages: [{ role: 'user', content: 'Hello!' }]
92
+ })) {
93
+ process.stdout.write(event.choices[0]?.delta?.content || '');
70
94
  }
71
95
  ```
72
96
 
73
- ### Scrape & Extract
74
- Turn any webpage into structured data with the `.scrape()` method.
97
+ ### Request Timing
98
+
99
+ ```typescript
100
+ const response = await get('https://api.example.com/data');
101
+ console.log(response.timings);
102
+ // { dns: 12, tcp: 8, tls: 45, firstByte: 23, total: 156 }
103
+ ```
104
+
105
+ ### Scraping
75
106
 
76
107
  ```typescript
77
108
  const doc = await client.scrape('https://example.com');
78
109
  const titles = doc.selectAll('h1').map(el => el.text());
79
110
  ```
80
111
 
81
- ### Reliability Built-in
82
- Configure advanced retry policies in declarative style.
112
+ ### Circuit Breaker
83
113
 
84
114
  ```typescript
115
+ import { createClient, circuitBreaker } from 'recker';
116
+
85
117
  const client = createClient({
118
+ baseUrl: 'https://api.example.com',
86
119
  plugins: [
87
- retry({ maxAttempts: 3, backoff: 'exponential', jitter: true })
120
+ circuitBreaker({ threshold: 5, resetTimeout: 30000 })
88
121
  ]
89
122
  });
90
123
  ```
91
124
 
92
- ### Deep Observability
93
- Know exactly where your latency comes from.
94
-
95
- ```typescript
96
- const { timings } = await client.get('/api/data');
97
- console.log(timings);
98
- // { dns: 12ms, tcp: 8ms, tls: 45ms, firstByte: 23ms, total: 156ms }
99
- ```
125
+ ## Documentation
100
126
 
101
- ## 📚 Documentation
127
+ - **[Quick Start](./docs/http/01-quickstart.md)** - Get running in 2 minutes
128
+ - **[API Reference](./docs/reference/01-api.md)** - Complete API documentation
129
+ - **[Configuration](./docs/http/05-configuration.md)** - Client options
130
+ - **[Plugins](./docs/http/10-plugins.md)** - Extend functionality
131
+ - **[AI Integration](./docs/ai/01-overview.md)** - OpenAI, Anthropic, and more
132
+ - **[Protocols](./docs/protocols/01-websocket.md)** - WebSocket, DNS, WHOIS
102
133
 
103
- **Getting Started**
104
- - [Installation](./docs/getting-started/installation.md)
105
- - [Quick Start](./docs/http/01-quickstart.md)
106
- - [Client Configuration](./docs/http/05-configuration.md)
107
-
108
- **Core Features**
109
- - [HTTP Fundamentals](./docs/http/02-fundamentals.md)
110
- - [Streaming & SSE](./docs/ai/02-streaming.md)
111
- - [Retry & Resilience](./docs/http/07-resilience.md)
112
- - [Caching](./docs/http/09-cache.md)
113
- - [Concurrency](./docs/http/08-concurrency.md)
114
-
115
- **Integrations**
116
- - [GraphQL](./docs/http/13-graphql.md)
117
- - [Scraping](./docs/http/14-scraping.md)
118
- - [Plugins](./docs/http/10-plugins.md)
119
-
120
- **Reference**
121
- - [API Reference](./docs/reference/01-api.md)
122
- - [Troubleshooting](./docs/reference/05-troubleshooting.md)
123
- - [Examples](./docs/examples/README.md)
124
-
125
- ## ❤️ Acknowledgements
126
-
127
- At Recker, we are passionate about these incredible open-source technologies. We are here to celebrate the past achievements that shaped the internet as we know it today, and to prepare ourselves for the future of web development.
128
-
129
- Recker stands on the shoulders of giants. We extend our deepest gratitude to these projects:
130
-
131
- <div align="center">
132
-
133
- | | | |
134
- |:---|:---|:---|
135
- | **[Apollo Client](https://github.com/apollographql/apollo-client)** | **[Axios](https://github.com/axios/axios)** | **[Cheerio](https://github.com/cheeriojs/cheerio)** |
136
- | **[Cookie](https://github.com/jshttp/cookie)** | **[Got](https://github.com/sindresorhus/got)** | **[GraphQL.js](https://github.com/graphql/graphql-js)** |
137
- | **[Ky](https://github.com/sindresorhus/ky)** | **[Needle](https://github.com/tomas/needle)** | **[Node-libcurl](https://github.com/JCMais/node-libcurl)** |
138
- | **[SuperAgent](https://github.com/ladjs/superagent)** | **[Undici](https://github.com/nodejs/undici)** | **[WS](https://github.com/websockets/ws)** |
139
-
140
- </div>
141
-
142
- ## 🤝 Contributing
143
-
144
- We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
145
-
146
- ## 📄 License
134
+ ## License
147
135
 
148
136
  MIT © [Forattini](https://github.com/forattini-dev)
149
-
150
- ---
151
-
152
- <div align="center">
153
-
154
- **Built for the AI era.**
155
-
156
- [Documentation](https://forattini-dev.github.io/recker) · [GitHub](https://github.com/forattini-dev/recker) · [npm](https://www.npmjs.com/package/recker)
157
-
158
- </div>
@@ -1,5 +1,5 @@
1
1
  import type { AIClient, AIClientConfig, ChatOptions, AIResponse, AIStream, EmbedOptions, EmbedResponse, AIMetrics } from '../types/ai.js';
2
- export declare class AIClientImpl implements AIClient {
2
+ export declare class UnifiedAIClient implements AIClient {
3
3
  private config;
4
4
  private providers;
5
5
  private _metrics;
@@ -19,6 +19,5 @@ export declare class AIClientImpl implements AIClient {
19
19
  private logResponse;
20
20
  private sleep;
21
21
  }
22
- export declare function createAIClient(config?: AIClientConfig): AIClient;
23
- export declare const ai: AIClient;
22
+ export declare function createAI(config?: AIClientConfig): AIClient;
24
23
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ai/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,YAAY,EAC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AM,GAAE,cAAmB;IAevC,IAAI,OAAO,IAAI,SAAS,CAEvB;IAKK,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8BhE,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ/C,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ1D,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,QAAQ;IAwBhD,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,gBAAgB;YAYV,gBAAgB;IAwE9B,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,gBAAgB;IAgCxB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,KAAK;CAGd;AAiBD,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,QAAQ,CAE1D"}
package/dist/ai/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AIError, RateLimitError, ContextLengthError, OverloadedError } from './providers/base.js';
2
2
  import { OpenAIProvider } from './providers/openai.js';
3
3
  import { AnthropicProvider } from './providers/anthropic.js';
4
- class AIMetricsImpl {
4
+ class AIMetricsTracker {
5
5
  data = {
6
6
  totalRequests: 0,
7
7
  totalTokens: 0,
@@ -87,10 +87,10 @@ class AIMetricsImpl {
87
87
  };
88
88
  }
89
89
  }
90
- export class AIClientImpl {
90
+ export class UnifiedAIClient {
91
91
  config;
92
92
  providers = new Map();
93
- _metrics = new AIMetricsImpl();
93
+ _metrics = new AIMetricsTracker();
94
94
  constructor(config = {}) {
95
95
  this.config = {
96
96
  defaultProvider: 'openai',
@@ -283,7 +283,6 @@ export class AIClientImpl {
283
283
  return new Promise((resolve) => setTimeout(resolve, ms));
284
284
  }
285
285
  }
286
- export function createAIClient(config) {
287
- return new AIClientImpl(config);
286
+ export function createAI(config) {
287
+ return new UnifiedAIClient(config);
288
288
  }
289
- export const ai = createAIClient();
@@ -1,4 +1,4 @@
1
- export { AIClientImpl, createAIClient, ai } from './client.js';
1
+ export { UnifiedAIClient, createAI } from './client.js';
2
2
  export { BaseAIProvider, AIError, RateLimitError, ContextLengthError, OverloadedError, AuthenticationError } from './providers/base.js';
3
3
  export { OpenAIProvider } from './providers/openai.js';
4
4
  export { AnthropicProvider } from './providers/anthropic.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AA2DA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxI,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG1G,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAEV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,QAAQ,EAGR,UAAU,EACV,QAAQ,EACR,SAAS,EAGT,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EAGZ,UAAU,EACV,aAAa,EAGb,eAAe,EACf,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EAGR,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,mBAA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AAc,EACd,gBAAgB,EAChB,KAAK,GACN,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/ai/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { AIClientImpl, createAIClient, ai } from './client.js';
1
+ export { UnifiedAIClient, createAI } from './client.js';
2
2
  export { BaseAIProvider, AIError, RateLimitError, ContextLengthError, OverloadedError, AuthenticationError } from './providers/base.js';
3
3
  export { OpenAIProvider } from './providers/openai.js';
4
4
  export { AnthropicProvider } from './providers/anthropic.js';
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/bench/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAa;IACpB,KAAK,EAAE,SAAS,CAAC;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,UAAU;IAKxB,KAAK;IA4FX,IAAI;CAGL"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/bench/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAa;IACpB,KAAK,EAAE,SAAS,CAAC;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,UAAU;IAKxB,KAAK;IAgGX,IAAI;CAGL"}
@@ -22,7 +22,7 @@ export class LoadGenerator {
22
22
  agent: {
23
23
  connections: this.config.users,
24
24
  pipelining: this.config.mode === 'throughput' ? 2 : 1,
25
- keepAlive: false
25
+ keepAlive: true
26
26
  }
27
27
  },
28
28
  retry: {
@@ -41,6 +41,7 @@ export class LoadGenerator {
41
41
  await new Promise(r => setTimeout(r, 50 + Math.random() * 450));
42
42
  }
43
43
  const res = await client.get(path, { signal: controller.signal });
44
+ await res.text();
44
45
  const duration = performance.now() - start;
45
46
  const bytes = Number(res.headers.get('content-length') || 0);
46
47
  this.stats.addResult(duration, res.status, bytes);
@@ -1,15 +1,29 @@
1
+ export interface ErrorEntry {
2
+ status: number;
3
+ message: string;
4
+ count: number;
5
+ lastSeen: number;
6
+ }
1
7
  export declare class LoadStats {
2
8
  totalRequests: number;
3
9
  successful: number;
4
10
  failed: number;
5
11
  bytesTransferred: number;
6
12
  statusCodes: Record<number, number>;
7
- errors: Record<string, number>;
13
+ private errorMap;
14
+ private recentErrors;
15
+ private readonly maxRecentErrors;
8
16
  latencies: number[];
9
17
  private lastSnapshotTime;
10
18
  private lastSnapshotRequests;
11
19
  activeUsers: number;
12
20
  addResult(durationMs: number, status: number, bytes: number, error?: Error): void;
21
+ private trackError;
22
+ private formatErrorMessage;
23
+ private getStatusText;
24
+ getErrors(): ErrorEntry[];
25
+ getRecentErrors(): ErrorEntry[];
26
+ get errors(): Record<string, number>;
13
27
  getSnapshot(): {
14
28
  rps: number;
15
29
  p95: number;
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/bench/stats.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IACpB,aAAa,SAAK;IAClB,UAAU,SAAK;IACf,MAAM,SAAK;IACX,gBAAgB,SAAK;IAErB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAGpC,SAAS,EAAE,MAAM,EAAE,CAAM;IAGzB,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,oBAAoB,CAAK;IAGjC,WAAW,SAAK;IAEhB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAoB1E,WAAW;;;;;IAmBX,UAAU;;;;;;;;;;;;;;;;CAmBX"}
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/bench/stats.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,SAAS;IACpB,aAAa,SAAK;IAClB,UAAU,SAAK;IACf,MAAM,SAAK;IACX,gBAAgB,SAAK;IAErB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAKzC,OAAO,CAAC,QAAQ,CAAiC;IAKjD,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAM;IAGtC,SAAS,EAAE,MAAM,EAAE,CAAM;IAGzB,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,oBAAoB,CAAK;IAGjC,WAAW,SAAK;IAEhB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAoB1E,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,kBAAkB;IAkC1B,OAAO,CAAC,aAAa;IAoBrB,SAAS,IAAI,UAAU,EAAE;IAQzB,eAAe,IAAI,UAAU,EAAE;IAO/B,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOnC;IAED,WAAW;;;;;IAmBX,UAAU;;;;;;;;;;;;;;;;CAmBX"}
@@ -4,7 +4,9 @@ export class LoadStats {
4
4
  failed = 0;
5
5
  bytesTransferred = 0;
6
6
  statusCodes = {};
7
- errors = {};
7
+ errorMap = new Map();
8
+ recentErrors = [];
9
+ maxRecentErrors = 10;
8
10
  latencies = [];
9
11
  lastSnapshotTime = Date.now();
10
12
  lastSnapshotRequests = 0;
@@ -15,10 +17,7 @@ export class LoadStats {
15
17
  this.latencies.push(durationMs);
16
18
  if (error || status >= 400) {
17
19
  this.failed++;
18
- if (error) {
19
- const msg = error.message || 'Unknown Error';
20
- this.errors[msg] = (this.errors[msg] || 0) + 1;
21
- }
20
+ this.trackError(status, error);
22
21
  }
23
22
  else {
24
23
  this.successful++;
@@ -27,6 +26,86 @@ export class LoadStats {
27
26
  this.statusCodes[status] = (this.statusCodes[status] || 0) + 1;
28
27
  }
29
28
  }
29
+ trackError(status, error) {
30
+ const message = this.formatErrorMessage(status, error);
31
+ const key = `${status}:${message}`;
32
+ const now = Date.now();
33
+ const existing = this.errorMap.get(key);
34
+ if (existing) {
35
+ existing.count++;
36
+ existing.lastSeen = now;
37
+ }
38
+ else {
39
+ const entry = { status, message, count: 1, lastSeen: now };
40
+ this.errorMap.set(key, entry);
41
+ this.recentErrors.push(entry);
42
+ if (this.recentErrors.length > this.maxRecentErrors) {
43
+ this.recentErrors.shift();
44
+ }
45
+ }
46
+ }
47
+ formatErrorMessage(status, error) {
48
+ if (error) {
49
+ let msg = error.message || 'Unknown Error';
50
+ if (msg.includes('ECONNREFUSED'))
51
+ return 'Connection refused';
52
+ if (msg.includes('ECONNRESET'))
53
+ return 'Connection reset';
54
+ if (msg.includes('ETIMEDOUT'))
55
+ return 'Connection timeout';
56
+ if (msg.includes('ENOTFOUND'))
57
+ return 'DNS lookup failed';
58
+ if (msg.includes('UND_ERR_SOCKET'))
59
+ return 'Socket error';
60
+ if (msg.includes('UND_ERR_HEADERS_TIMEOUT'))
61
+ return 'Headers timeout';
62
+ if (msg.includes('UND_ERR_BODY_TIMEOUT'))
63
+ return 'Body timeout';
64
+ if (msg.includes('UND_ERR_CONNECT_TIMEOUT'))
65
+ return 'Connect timeout';
66
+ if (msg.includes('AbortError') || msg.includes('aborted'))
67
+ return 'Request aborted';
68
+ if (msg.length > 50) {
69
+ msg = msg.substring(0, 47) + '...';
70
+ }
71
+ return msg;
72
+ }
73
+ if (status >= 400) {
74
+ return this.getStatusText(status);
75
+ }
76
+ return 'Unknown Error';
77
+ }
78
+ getStatusText(status) {
79
+ const texts = {
80
+ 400: 'Bad Request',
81
+ 401: 'Unauthorized',
82
+ 403: 'Forbidden',
83
+ 404: 'Not Found',
84
+ 405: 'Method Not Allowed',
85
+ 408: 'Request Timeout',
86
+ 429: 'Too Many Requests',
87
+ 500: 'Internal Server Error',
88
+ 502: 'Bad Gateway',
89
+ 503: 'Service Unavailable',
90
+ 504: 'Gateway Timeout',
91
+ };
92
+ return texts[status] || `HTTP ${status}`;
93
+ }
94
+ getErrors() {
95
+ return Array.from(this.errorMap.values())
96
+ .sort((a, b) => b.count - a.count);
97
+ }
98
+ getRecentErrors() {
99
+ return [...this.recentErrors];
100
+ }
101
+ get errors() {
102
+ const result = {};
103
+ for (const entry of this.errorMap.values()) {
104
+ const key = entry.status > 0 ? `[${entry.status}] ${entry.message}` : entry.message;
105
+ result[key] = entry.count;
106
+ }
107
+ return result;
108
+ }
30
109
  getSnapshot() {
31
110
  const now = Date.now();
32
111
  const timeDiff = (now - this.lastSnapshotTime) / 1000;
package/dist/cli/index.js CHANGED
@@ -270,6 +270,27 @@ complete -F _rek_completions rek
270
270
  const shell = new RekShell();
271
271
  shell.start();
272
272
  });
273
+ program
274
+ .command('docs [query...]')
275
+ .alias('?')
276
+ .description('Search Recker documentation (opens fullscreen panel)')
277
+ .action(async (queryParts) => {
278
+ const query = queryParts.join(' ').trim();
279
+ const { openSearchPanel } = await import('./tui/search-panel.js');
280
+ await openSearchPanel(query || undefined);
281
+ });
282
+ const dns = program.command('dns').description('DNS tools and diagnostics');
283
+ dns
284
+ .command('propagate')
285
+ .description('Check global DNS propagation across multiple providers')
286
+ .argument('<domain>', 'Domain name to check')
287
+ .argument('[type]', 'Record type (A, AAAA, CNAME, MX, NS, TXT)', 'A')
288
+ .action(async (domain, type) => {
289
+ const { checkPropagation, formatPropagationReport } = await import('../dns/propagation.js');
290
+ console.log(pc.gray(`Checking propagation for ${domain} (${type})...`));
291
+ const results = await checkPropagation(domain, type);
292
+ console.log(formatPropagationReport(results, domain, type));
293
+ });
273
294
  const bench = program.command('bench').description('Performance benchmarking tools');
274
295
  bench
275
296
  .command('load')
@@ -1,6 +1,6 @@
1
1
  import readline from 'node:readline';
2
2
  import pc from '../../utils/colors.js';
3
- import { createAIClient } from '../../ai/client.js';
3
+ import { createAI } from '../../ai/client.js';
4
4
  export async function startAIChat(rl, provider = 'openai', apiKey, model) {
5
5
  console.clear();
6
6
  console.log(pc.bold(pc.magenta(`🤖 Rek AI Chat (${provider})`)));
@@ -14,7 +14,7 @@ Warning: No API Key found for ${provider}.`));
14
14
  console.log(`Example: set ${envKey}=sk-... inside the shell.`);
15
15
  return;
16
16
  }
17
- const client = createAIClient({
17
+ const client = createAI({
18
18
  defaultProvider: provider,
19
19
  providers: {
20
20
  [provider]: { apiKey: key }
@@ -1 +1 @@
1
- {"version":3,"file":"load-dashboard.d.ts","sourceRoot":"","sources":["../../../src/cli/tui/load-dashboard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKrE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,UAAU,iBA4E1D"}
1
+ {"version":3,"file":"load-dashboard.d.ts","sourceRoot":"","sources":["../../../src/cli/tui/load-dashboard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMrE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,UAAU,iBA4E1D"}
@@ -72,11 +72,11 @@ function render(config, elapsed, remaining, snapshot, rpsHistory, latencyHistory
72
72
  console.log(`${pc.white('Time:')} ${pc.green(elapsed + 's')} ` +
73
73
  `${pc.gray('/')} ${config.duration}s ` +
74
74
  `${pc.gray('(')}${pc.yellow(remaining + 's left')}${pc.gray(')')} ` +
75
- `${pc.white('Reqs:')} ${pc.bold(stats.totalRequests)}`);
76
- console.log(`${pc.blue('Users:')} ${pc.bold(snapshot.activeUsers)} ` +
75
+ `${pc.white('Reqs:')} ${pc.bold(String(stats.totalRequests))}`);
76
+ console.log(`${pc.blue('Users:')} ${pc.bold(String(snapshot.activeUsers))} ` +
77
77
  `${pc.green('RPS:')} ${pc.bold(snapshot.rps.toFixed(0))} ` +
78
78
  `${pc.magenta('Latency (P95):')} ${pc.bold(snapshot.p95.toFixed(0) + 'ms')} ` +
79
- `${pc.white('Errors:')} ${stats.failed > 0 ? pc.red(stats.failed) : pc.green('0')}`);
79
+ `${pc.white('Errors:')} ${stats.failed > 0 ? pc.red(String(stats.failed)) : pc.green('0')}`);
80
80
  console.log(pc.gray('──────────────────────────────────────────────────'));
81
81
  console.log(pc.bold(pc.blue('👥 Active Users')));
82
82
  console.log(pc.blue(plot(usersHistory, { height: 4 })));
@@ -86,6 +86,39 @@ function render(config, elapsed, remaining, snapshot, rpsHistory, latencyHistory
86
86
  console.log('');
87
87
  console.log(pc.bold(pc.magenta('⏱️ Latency P95 (ms)')));
88
88
  console.log(pc.magenta(plot(latencyHistory, { height: 4 })));
89
+ const recentErrors = stats.getRecentErrors();
90
+ if (recentErrors.length > 0) {
91
+ console.log('');
92
+ console.log(pc.bold(pc.red('⚠️ Recent Errors')));
93
+ renderErrorList(recentErrors, 5);
94
+ }
95
+ }
96
+ function formatErrorEntry(entry) {
97
+ const count = pc.gray(`${entry.count}x`);
98
+ if (entry.status === 0) {
99
+ return ` ${count} ${pc.red('NET')} ${entry.message}`;
100
+ }
101
+ const statusBadge = formatStatusBadge(entry.status);
102
+ return ` ${count} ${statusBadge} ${entry.message}`;
103
+ }
104
+ function formatStatusBadge(status) {
105
+ const code = String(status);
106
+ if (status >= 500)
107
+ return pc.bgRed(pc.white(` ${code} `));
108
+ if (status >= 400)
109
+ return pc.bgYellow(pc.black(` ${code} `));
110
+ if (status >= 300)
111
+ return pc.bgCyan(pc.black(` ${code} `));
112
+ return pc.bgGreen(pc.black(` ${code} `));
113
+ }
114
+ function renderErrorList(errors, maxItems = 10) {
115
+ const toShow = errors.slice(-maxItems);
116
+ for (const entry of toShow) {
117
+ console.log(formatErrorEntry(entry));
118
+ }
119
+ if (errors.length > maxItems) {
120
+ console.log(pc.gray(` ... and ${errors.length - maxItems} more`));
121
+ }
89
122
  }
90
123
  function renderFinalReport(stats, config) {
91
124
  const summary = stats.getSummary();
@@ -97,8 +130,8 @@ function renderFinalReport(stats, config) {
97
130
  console.log(` Duration: ${config.duration}s`);
98
131
  console.log('\n' + pc.bold('Traffic:'));
99
132
  console.log(` Total Requests: ${summary.total}`);
100
- console.log(` Successful: ${pc.green(summary.success)}`);
101
- console.log(` Failed: ${summary.failed > 0 ? pc.red(summary.failed) : pc.gray(0)}`);
133
+ console.log(` Successful: ${pc.green(String(summary.success))}`);
134
+ console.log(` Failed: ${summary.failed > 0 ? pc.red(String(summary.failed)) : pc.gray('0')}`);
102
135
  console.log(` Total Bytes: ${(summary.bytes / 1024 / 1024).toFixed(2)} MB`);
103
136
  console.log('\n' + pc.bold('Latency (ms):'));
104
137
  console.log(` Avg: ${summary.latency.avg.toFixed(2)}`);
@@ -108,10 +141,31 @@ function renderFinalReport(stats, config) {
108
141
  console.log(` Max: ${summary.latency.max.toFixed(0)}`);
109
142
  if (Object.keys(summary.codes).length > 0) {
110
143
  console.log('\n' + pc.bold('Status Codes:'));
111
- Object.entries(summary.codes).forEach(([code, count]) => {
112
- const color = code.startsWith('2') ? pc.green : code.startsWith('5') ? pc.red : pc.yellow;
113
- console.log(` ${color(code)}: ${count}`);
144
+ Object.entries(summary.codes)
145
+ .sort(([a], [b]) => Number(a) - Number(b))
146
+ .forEach(([code, count]) => {
147
+ const badge = formatStatusBadge(Number(code));
148
+ console.log(` ${badge} ${count}`);
114
149
  });
115
150
  }
151
+ const allErrors = stats.getErrors();
152
+ if (allErrors.length > 0) {
153
+ console.log('\n' + pc.bold(pc.red('Errors:')));
154
+ renderErrorList(allErrors, 15);
155
+ const networkErrors = allErrors.filter(e => e.status === 0);
156
+ const httpErrors = allErrors.filter(e => e.status > 0);
157
+ if (networkErrors.length > 0 || httpErrors.length > 0) {
158
+ console.log('');
159
+ console.log(pc.gray(' Summary:'));
160
+ if (networkErrors.length > 0) {
161
+ const total = networkErrors.reduce((sum, e) => sum + e.count, 0);
162
+ console.log(pc.gray(` Network errors: ${total} (${networkErrors.length} types)`));
163
+ }
164
+ if (httpErrors.length > 0) {
165
+ const total = httpErrors.reduce((sum, e) => sum + e.count, 0);
166
+ console.log(pc.gray(` HTTP errors: ${total} (${httpErrors.length} types)`));
167
+ }
168
+ }
169
+ }
116
170
  console.log('');
117
171
  }