recker 1.0.84 → 1.0.85

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.
@@ -133,8 +133,8 @@ export const tlsHandler = withHandler({ loading: true }, async (ctx, out, extCtx
133
133
  valid: socket.authorized,
134
134
  protocol,
135
135
  cipher: cipher?.name,
136
- subject: cert.subject?.CN,
137
- issuer: cert.issuer?.O,
136
+ subject: Array.isArray(cert.subject?.CN) ? cert.subject.CN[0] : cert.subject?.CN,
137
+ issuer: Array.isArray(cert.issuer?.O) ? cert.issuer.O[0] : cert.issuer?.O,
138
138
  validFrom: cert.valid_from,
139
139
  validTo: cert.valid_to,
140
140
  fingerprint: cert.fingerprint,
@@ -45,6 +45,7 @@ export declare function createSmartInput(options: {
45
45
  }) => void;
46
46
  setValue: (v: string) => void;
47
47
  clear: () => void;
48
+ updateOptions: (nextOptions?: import("tuiuiu.js").TextInputOptions) => void;
48
49
  focus: () => void;
49
50
  };
50
51
  getSuggestions: () => Suggestion[];
@@ -16,8 +16,13 @@ export declare class RaffelClient extends SimpleEmitter {
16
16
  private idCounter;
17
17
  private defaultTimeout;
18
18
  private onEvent?;
19
+ private _onMessage?;
19
20
  private url;
20
21
  private options;
22
+ private _mode;
23
+ private _waiters;
24
+ private _messageBuffer;
25
+ private static readonly MAX_BUFFER_SIZE;
21
26
  constructor(url: string, options?: RaffelClientOptions);
22
27
  private ensureTransport;
23
28
  _setTransport(transport: RaffelTransport): void;
@@ -33,6 +38,9 @@ export declare class RaffelClient extends SimpleEmitter {
33
38
  subscribe(channel: string, handler?: ChannelEventHandler): void;
34
39
  unsubscribe(channel: string): void;
35
40
  publish(channel: string, event: string, data?: unknown): void;
41
+ sendRaw(data: unknown): void;
42
+ waitFor<T = any>(predicate: (msg: any) => boolean, timeoutMs?: number): Promise<T>;
43
+ get mode(): 'raw' | 'full';
36
44
  cancel(id: string): void;
37
45
  private executeWithTimeout;
38
46
  private handleIncoming;
@@ -44,14 +44,21 @@ export class RaffelClient extends SimpleEmitter {
44
44
  idCounter = 0;
45
45
  defaultTimeout;
46
46
  onEvent;
47
+ _onMessage;
47
48
  url;
48
49
  options;
50
+ _mode;
51
+ _waiters = [];
52
+ _messageBuffer = [];
53
+ static MAX_BUFFER_SIZE = 100;
49
54
  constructor(url, options = {}) {
50
55
  super();
51
56
  this.url = url;
52
57
  this.options = options;
58
+ this._mode = options.mode ?? 'full';
53
59
  this.defaultTimeout = options.defaultTimeout ?? 30_000;
54
60
  this.onEvent = options.onEvent;
61
+ this._onMessage = options.onMessage;
55
62
  if (options.channels) {
56
63
  for (const ch of options.channels) {
57
64
  this.subscribedChannels.set(ch, options.channelHandlers?.[ch] ?? null);
@@ -79,8 +86,10 @@ export class RaffelClient extends SimpleEmitter {
79
86
  this.transport.on('message', (data) => this.handleIncoming(data));
80
87
  this.transport.on('connected', () => {
81
88
  this.emit('raffel:connected');
82
- for (const [channel] of this.subscribedChannels) {
83
- this.sendChannelSubscribe(channel);
89
+ if (this._mode === 'full') {
90
+ for (const [channel] of this.subscribedChannels) {
91
+ this.sendChannelSubscribe(channel);
92
+ }
84
93
  }
85
94
  });
86
95
  this.transport.on('disconnected', () => {
@@ -110,6 +119,11 @@ export class RaffelClient extends SimpleEmitter {
110
119
  pending.reject(new Error(`Connection closed while waiting for response to ${id}`));
111
120
  }
112
121
  this.pendingCalls.clear();
122
+ for (const waiter of this._waiters) {
123
+ clearTimeout(waiter.timer);
124
+ waiter.reject(new Error('Connection closed'));
125
+ }
126
+ this._waiters = [];
113
127
  if (this.transport) {
114
128
  this.transport.close(code, reason);
115
129
  }
@@ -288,6 +302,25 @@ export class RaffelClient extends SimpleEmitter {
288
302
  };
289
303
  this.transport.send(msg);
290
304
  }
305
+ sendRaw(data) {
306
+ this.transport.send(data);
307
+ }
308
+ waitFor(predicate, timeoutMs) {
309
+ const existing = this._messageBuffer.find(predicate);
310
+ if (existing)
311
+ return Promise.resolve(existing);
312
+ const timeout = timeoutMs ?? this.defaultTimeout;
313
+ return new Promise((resolve, reject) => {
314
+ const timer = setTimeout(() => {
315
+ this._waiters = this._waiters.filter(w => w.timer !== timer);
316
+ reject(new Error('waitFor() timed out'));
317
+ }, timeout);
318
+ this._waiters.push({ predicate, resolve, reject, timer });
319
+ });
320
+ }
321
+ get mode() {
322
+ return this._mode;
323
+ }
291
324
  cancel(id) {
292
325
  if (!hasCapability(this.transport, TransportCapability.CANCEL)) {
293
326
  throw new UnsupportedError(`cancel() not supported over ${detectTransportType(this.url, this.options)}. Use WebSocket or TCP.`);
@@ -321,10 +354,27 @@ export class RaffelClient extends SimpleEmitter {
321
354
  return Promise.race(promises);
322
355
  }
323
356
  handleIncoming(data) {
357
+ this._messageBuffer.push(data);
358
+ if (this._messageBuffer.length > RaffelClient.MAX_BUFFER_SIZE) {
359
+ this._messageBuffer.shift();
360
+ }
361
+ for (let i = this._waiters.length - 1; i >= 0; i--) {
362
+ const waiter = this._waiters[i];
363
+ if (waiter.predicate(data)) {
364
+ clearTimeout(waiter.timer);
365
+ this._waiters.splice(i, 1);
366
+ waiter.resolve(data);
367
+ }
368
+ }
369
+ if (this._mode === 'raw') {
370
+ this._onMessage?.(data);
371
+ this.emit('message', data);
372
+ return;
373
+ }
324
374
  if (data.channel) {
325
375
  this.handleChannelMessage(data);
326
376
  }
327
- else if (data.procedure || data.type === 'cancel') {
377
+ else if (data.procedure || data.type === 'cancel' || data.type === 'response' || data.type === 'error') {
328
378
  this.handleEnvelope(data);
329
379
  }
330
380
  else {
@@ -45,10 +45,12 @@ export interface RaffelJsonRpcOptions {
45
45
  export type ChannelEventHandler = (event: string, data: unknown) => void;
46
46
  export interface RaffelClientOptions {
47
47
  transport?: RaffelTransportType;
48
+ mode?: 'raw' | 'full';
48
49
  defaultTimeout?: number;
49
50
  channels?: string[];
50
51
  channelHandlers?: Record<string, ChannelEventHandler>;
51
52
  onEvent?: (procedure: string, payload: unknown) => void;
53
+ onMessage?: (data: unknown) => void;
52
54
  ws?: WebSocketOptions;
53
55
  http?: RaffelHttpOptions;
54
56
  tcp?: RaffelTcpOptions;
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION = '1.0.84';
1
+ const VERSION = '1.0.85';
2
2
  let _version = null;
3
3
  export async function getVersion() {
4
4
  if (_version)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recker",
3
- "version": "1.0.84",
3
+ "version": "1.0.85",
4
4
  "description": "Multi-Protocol SDK for the AI Era - HTTP, WebSocket, DNS, FTP, SFTP, Telnet, HLS unified with AI providers and MCP tools",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -236,8 +236,8 @@
236
236
  "cli-args-parser": "^1.0.6",
237
237
  "css-select": "^6.0.0",
238
238
  "he": "^1.2.0",
239
- "tuiuiu.js": "^1.0.53",
240
- "undici": "^7.19.0",
239
+ "tuiuiu.js": "^1.0.57",
240
+ "undici": "^7.24.3",
241
241
  "zod": "^4.3.6"
242
242
  },
243
243
  "peerDependencies": {
@@ -265,39 +265,39 @@
265
265
  }
266
266
  },
267
267
  "devDependencies": {
268
- "raffel": "^1.0.3",
268
+ "raffel": "^1.0.14",
269
269
  "@hapi/wreck": "^18.1.0",
270
270
  "@types/he": "^1.2.3",
271
271
  "@types/needle": "^3.3.0",
272
- "@types/node": "^25.0.10",
272
+ "@types/node": "^25.5.0",
273
273
  "@types/ssh2-sftp-client": "^9.0.6",
274
274
  "@types/superagent": "^8.1.9",
275
275
  "@types/ws": "^8.18.1",
276
- "@vitest/coverage-v8": "^4.0.18",
277
- "axios": "^1.13.2",
276
+ "@vitest/coverage-v8": "^4.1.0",
277
+ "axios": "^1.13.6",
278
278
  "cardinal": "^2.1.1",
279
279
  "cross-fetch": "^4.1.0",
280
280
  "domhandler": "^5.0.3",
281
- "esbuild": "^0.27.2",
281
+ "esbuild": "^0.27.4",
282
282
  "got": "^14.6.6",
283
- "happy-dom": "^20.3.4",
283
+ "happy-dom": "^20.8.4",
284
284
  "husky": "^9.1.7",
285
- "ky": "^1.14.2",
286
- "make-fetch-happen": "^15.0.3",
287
- "minipass-fetch": "^5.0.0",
285
+ "ky": "^1.14.3",
286
+ "make-fetch-happen": "^15.0.4",
287
+ "minipass-fetch": "^5.0.2",
288
288
  "mitata": "^1.0.34",
289
- "needle": "^3.3.1",
289
+ "needle": "^3.5.0",
290
290
  "node-fetch": "^3.3.2",
291
291
  "picocolors": "^1.1.1",
292
292
  "popsicle": "^12.1.2",
293
- "serve": "^14.2.5",
294
- "socks": "^2.8.3",
295
- "ssh2-sftp-client": "^12.0.1",
293
+ "serve": "^14.2.6",
294
+ "socks": "^2.8.7",
295
+ "ssh2-sftp-client": "^12.1.0",
296
296
  "superagent": "^10.3.0",
297
297
  "tsx": "^4.21.0",
298
298
  "typescript": "^5.9.3",
299
- "vitest": "^4.0.18",
300
- "wretch": "^3.0.6",
299
+ "vitest": "^4.1.0",
300
+ "wretch": "^3.0.7",
301
301
  "ws": "^8.19.0",
302
302
  "zod": "^4.3.6"
303
303
  },