@rainfall-devkit/sdk 0.1.8 → 0.2.1

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 (58) hide show
  1. package/README.md +51 -0
  2. package/dist/chunk-7MRE4ZVI.mjs +662 -0
  3. package/dist/chunk-AQFC7YAX.mjs +27 -0
  4. package/dist/chunk-EI7SJH5K.mjs +85 -0
  5. package/dist/chunk-NTTAVKRT.mjs +89 -0
  6. package/dist/chunk-RVKW5KBT.mjs +269 -0
  7. package/dist/chunk-V5QWJVLC.mjs +662 -0
  8. package/dist/chunk-VDPKDC3R.mjs +869 -0
  9. package/dist/chunk-WOITG5TG.mjs +84 -0
  10. package/dist/chunk-XAHJQRBJ.mjs +269 -0
  11. package/dist/chunk-XEQ6U3JQ.mjs +269 -0
  12. package/dist/cli/index.js +3797 -632
  13. package/dist/cli/index.mjs +453 -36
  14. package/dist/config-7UT7GYSN.mjs +16 -0
  15. package/dist/config-DDTQQBN7.mjs +14 -0
  16. package/dist/config-MD45VGWD.mjs +14 -0
  17. package/dist/config-ZKNHII2A.mjs +8 -0
  18. package/dist/daemon/index.d.mts +168 -0
  19. package/dist/daemon/index.d.ts +168 -0
  20. package/dist/daemon/index.js +3182 -0
  21. package/dist/daemon/index.mjs +1548 -0
  22. package/dist/errors-BMPseAnM.d.mts +47 -0
  23. package/dist/errors-BMPseAnM.d.ts +47 -0
  24. package/dist/errors-CZdRoYyw.d.ts +332 -0
  25. package/dist/errors-Chjq1Mev.d.mts +332 -0
  26. package/dist/index.d.mts +249 -2
  27. package/dist/index.d.ts +249 -2
  28. package/dist/index.js +1247 -3
  29. package/dist/index.mjs +227 -2
  30. package/dist/listeners-B5Vy9Ao5.d.ts +372 -0
  31. package/dist/listeners-BbYIaNCs.d.mts +372 -0
  32. package/dist/listeners-CP2A9J_2.d.ts +372 -0
  33. package/dist/listeners-CTRSofnm.d.mts +372 -0
  34. package/dist/listeners-CYI-YwIF.d.mts +372 -0
  35. package/dist/listeners-DRwITBW_.d.mts +372 -0
  36. package/dist/listeners-DrMrvFT5.d.ts +372 -0
  37. package/dist/listeners-MNAnpZj-.d.mts +372 -0
  38. package/dist/listeners-PZI7iT85.d.ts +372 -0
  39. package/dist/listeners-QJeEtLbV.d.ts +372 -0
  40. package/dist/listeners-hp0Ib2Ox.d.ts +372 -0
  41. package/dist/listeners-jLwetUnx.d.mts +372 -0
  42. package/dist/mcp.d.mts +7 -2
  43. package/dist/mcp.d.ts +7 -2
  44. package/dist/mcp.js +92 -1
  45. package/dist/mcp.mjs +1 -1
  46. package/dist/sdk-4OvXPr8E.d.mts +1054 -0
  47. package/dist/sdk-4OvXPr8E.d.ts +1054 -0
  48. package/dist/sdk-CJ9g5lFo.d.mts +772 -0
  49. package/dist/sdk-CJ9g5lFo.d.ts +772 -0
  50. package/dist/sdk-CN1ezZrI.d.mts +1054 -0
  51. package/dist/sdk-CN1ezZrI.d.ts +1054 -0
  52. package/dist/sdk-DD1OeGRJ.d.mts +871 -0
  53. package/dist/sdk-DD1OeGRJ.d.ts +871 -0
  54. package/dist/sdk-Xw0BjsLd.d.mts +1054 -0
  55. package/dist/sdk-Xw0BjsLd.d.ts +1054 -0
  56. package/dist/types-GnRAfH-h.d.mts +489 -0
  57. package/dist/types-GnRAfH-h.d.ts +489 -0
  58. package/package.json +17 -5
@@ -0,0 +1,1054 @@
1
+ import { WebSocket } from 'ws';
2
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
4
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
5
+
6
+ /**
7
+ * MCP Proxy Hub - Manages external MCP clients (Chrome DevTools, etc.)
8
+ *
9
+ * This service allows the Rainfall daemon to act as a central MCP hub:
10
+ * - External MCP servers (like Chrome DevTools) connect via WebSocket or stdio
11
+ * - Their tools are exposed as native Rainfall tools with optional namespacing
12
+ * - Tool calls are proxied back to the appropriate MCP client
13
+ * - Multiple clients can connect simultaneously with unique namespaces
14
+ */
15
+
16
+ type MCPTransportType = 'stdio' | 'websocket' | 'http';
17
+ interface MCPClientConfig {
18
+ name: string;
19
+ transport: MCPTransportType;
20
+ command?: string;
21
+ args?: string[];
22
+ env?: Record<string, string>;
23
+ url?: string;
24
+ headers?: Record<string, string>;
25
+ autoConnect?: boolean;
26
+ }
27
+ interface MCPClientInfo {
28
+ name: string;
29
+ client: Client;
30
+ transport: StdioClientTransport | StreamableHTTPClientTransport | WebSocket;
31
+ transportType: MCPTransportType;
32
+ tools: MCPToolInfo[];
33
+ connectedAt: string;
34
+ lastUsed: string;
35
+ config: MCPClientConfig;
36
+ status: 'connected' | 'disconnected' | 'error';
37
+ error?: string;
38
+ }
39
+ interface MCPToolInfo {
40
+ name: string;
41
+ description: string;
42
+ inputSchema: unknown;
43
+ serverName: string;
44
+ }
45
+ interface MCPProxyOptions {
46
+ /** Enable debug logging */
47
+ debug?: boolean;
48
+ /** Auto-reconnect disconnected clients */
49
+ autoReconnect?: boolean;
50
+ /** Reconnect delay in ms */
51
+ reconnectDelay?: number;
52
+ /** Tool call timeout in ms */
53
+ toolTimeout?: number;
54
+ /** Refresh interval for tool lists in ms */
55
+ refreshInterval?: number;
56
+ }
57
+ declare class MCPProxyHub {
58
+ private clients;
59
+ private options;
60
+ private refreshTimer?;
61
+ private reconnectTimeouts;
62
+ private requestId;
63
+ constructor(options?: MCPProxyOptions);
64
+ /**
65
+ * Initialize the MCP proxy hub
66
+ */
67
+ initialize(): Promise<void>;
68
+ /**
69
+ * Shutdown the MCP proxy hub and disconnect all clients
70
+ */
71
+ shutdown(): Promise<void>;
72
+ /**
73
+ * Connect to an MCP server
74
+ */
75
+ connectClient(config: MCPClientConfig): Promise<string>;
76
+ /**
77
+ * Disconnect a specific MCP client
78
+ */
79
+ disconnectClient(name: string): Promise<void>;
80
+ /**
81
+ * Schedule a reconnection attempt
82
+ */
83
+ private scheduleReconnect;
84
+ /**
85
+ * Call a tool on the appropriate MCP client
86
+ */
87
+ callTool(toolName: string, args: Record<string, unknown>, options?: {
88
+ timeout?: number;
89
+ namespace?: string;
90
+ }): Promise<unknown>;
91
+ /**
92
+ * Format MCP tool result for consistent output
93
+ */
94
+ private formatToolResult;
95
+ /**
96
+ * Get all tools from all connected MCP clients
97
+ * Optionally with namespace prefix
98
+ */
99
+ getAllTools(options?: {
100
+ namespacePrefix?: boolean;
101
+ }): MCPToolInfo[];
102
+ /**
103
+ * Get tools from a specific client
104
+ */
105
+ getClientTools(clientName: string): MCPToolInfo[];
106
+ /**
107
+ * Get list of connected MCP clients
108
+ */
109
+ listClients(): Array<{
110
+ name: string;
111
+ status: string;
112
+ toolCount: number;
113
+ connectedAt: string;
114
+ lastUsed: string;
115
+ transportType: MCPTransportType;
116
+ }>;
117
+ /**
118
+ * Get client info by name
119
+ */
120
+ getClient(name: string): MCPClientInfo | undefined;
121
+ /**
122
+ * Refresh tool lists from all connected clients
123
+ */
124
+ refreshTools(): Promise<void>;
125
+ /**
126
+ * List resources from a specific client or all clients
127
+ */
128
+ listResources(clientName?: string): Promise<Array<{
129
+ clientName: string;
130
+ resources: unknown[];
131
+ }>>;
132
+ /**
133
+ * Read a resource from a specific client
134
+ */
135
+ readResource(uri: string, clientName?: string): Promise<unknown>;
136
+ /**
137
+ * List prompts from a specific client or all clients
138
+ */
139
+ listPrompts(clientName?: string): Promise<Array<{
140
+ clientName: string;
141
+ prompts: unknown[];
142
+ }>>;
143
+ /**
144
+ * Get a prompt from a specific client
145
+ */
146
+ getPrompt(name: string, args: Record<string, unknown>, clientName?: string): Promise<unknown>;
147
+ /**
148
+ * Health check for all connected clients
149
+ */
150
+ healthCheck(): Promise<Map<string, {
151
+ status: string;
152
+ responseTime: number;
153
+ error?: string;
154
+ }>>;
155
+ /**
156
+ * Start the automatic refresh timer
157
+ */
158
+ private startRefreshTimer;
159
+ /**
160
+ * Print available tools for a client
161
+ */
162
+ private printAvailableTools;
163
+ /**
164
+ * Debug logging
165
+ */
166
+ private log;
167
+ /**
168
+ * Get statistics about the MCP proxy hub
169
+ */
170
+ getStats(): {
171
+ totalClients: number;
172
+ totalTools: number;
173
+ clients: Array<{
174
+ name: string;
175
+ toolCount: number;
176
+ status: string;
177
+ transportType: MCPTransportType;
178
+ }>;
179
+ };
180
+ }
181
+
182
+ /**
183
+ * Core types for the Rainfall SDK
184
+ */
185
+ interface RainfallConfig {
186
+ apiKey: string;
187
+ baseUrl?: string;
188
+ timeout?: number;
189
+ retries?: number;
190
+ retryDelay?: number;
191
+ /** Pre-configured MCP clients to connect on daemon startup */
192
+ mcpClients?: MCPClientConfig[];
193
+ }
194
+ interface RequestOptions {
195
+ timeout?: number;
196
+ retries?: number;
197
+ retryDelay?: number;
198
+ }
199
+ interface ApiResponse<T = unknown> {
200
+ success: boolean;
201
+ data?: T;
202
+ error?: ApiError;
203
+ }
204
+ interface ApiError {
205
+ code: string;
206
+ message: string;
207
+ details?: Record<string, unknown>;
208
+ }
209
+ interface RateLimitInfo {
210
+ limit: number;
211
+ remaining: number;
212
+ resetAt: Date;
213
+ }
214
+ interface ToolSchema {
215
+ name: string;
216
+ description: string;
217
+ category: string;
218
+ parameters: unknown;
219
+ output: unknown;
220
+ metadata: Record<string, unknown>;
221
+ }
222
+ declare namespace Integrations {
223
+ interface GitHub {
224
+ issues: {
225
+ create(params: {
226
+ owner: string;
227
+ repo: string;
228
+ title: string;
229
+ body?: string;
230
+ }): Promise<unknown>;
231
+ list(params: {
232
+ owner: string;
233
+ repo: string;
234
+ state?: 'open' | 'closed' | 'all';
235
+ }): Promise<unknown>;
236
+ get(params: {
237
+ owner: string;
238
+ repo: string;
239
+ issue_number: number;
240
+ }): Promise<unknown>;
241
+ update(params: {
242
+ owner: string;
243
+ repo: string;
244
+ issue_number: number;
245
+ title?: string;
246
+ body?: string;
247
+ state?: 'open' | 'closed';
248
+ }): Promise<unknown>;
249
+ addComment(params: {
250
+ owner: string;
251
+ repo: string;
252
+ issue_number: number;
253
+ body: string;
254
+ }): Promise<unknown>;
255
+ };
256
+ repos: {
257
+ get(params: {
258
+ owner: string;
259
+ repo: string;
260
+ }): Promise<unknown>;
261
+ listBranches(params: {
262
+ owner: string;
263
+ repo: string;
264
+ }): Promise<unknown>;
265
+ };
266
+ pullRequests: {
267
+ list(params: {
268
+ owner: string;
269
+ repo: string;
270
+ state?: 'open' | 'closed' | 'all';
271
+ }): Promise<unknown>;
272
+ get(params: {
273
+ owner: string;
274
+ repo: string;
275
+ pullNumber: number;
276
+ }): Promise<unknown>;
277
+ };
278
+ }
279
+ interface Notion {
280
+ pages: {
281
+ create(params: {
282
+ parent: unknown;
283
+ properties: unknown;
284
+ children?: unknown[];
285
+ }): Promise<unknown>;
286
+ retrieve(params: {
287
+ pageId: string;
288
+ }): Promise<unknown>;
289
+ update(params: {
290
+ pageId: string;
291
+ properties: unknown;
292
+ }): Promise<unknown>;
293
+ };
294
+ databases: {
295
+ query(params: {
296
+ databaseId: string;
297
+ filter?: unknown;
298
+ sorts?: unknown[];
299
+ }): Promise<unknown>;
300
+ retrieve(params: {
301
+ databaseId: string;
302
+ }): Promise<unknown>;
303
+ };
304
+ blocks: {
305
+ appendChildren(params: {
306
+ blockId: string;
307
+ children: unknown[];
308
+ }): Promise<unknown>;
309
+ retrieveChildren(params: {
310
+ blockId: string;
311
+ }): Promise<unknown>;
312
+ };
313
+ }
314
+ interface Linear {
315
+ issues: {
316
+ create(params: {
317
+ title: string;
318
+ description?: string;
319
+ teamId?: string;
320
+ assigneeId?: string;
321
+ priority?: number;
322
+ labels?: string[];
323
+ }): Promise<unknown>;
324
+ list(params?: {
325
+ filter?: unknown;
326
+ orderBy?: string;
327
+ }): Promise<unknown>;
328
+ get(params: {
329
+ issueId: string;
330
+ }): Promise<unknown>;
331
+ update(params: {
332
+ issueId: string;
333
+ title?: string;
334
+ description?: string;
335
+ state?: string;
336
+ }): Promise<unknown>;
337
+ archive(params: {
338
+ issueId: string;
339
+ }): Promise<unknown>;
340
+ };
341
+ teams: {
342
+ list(): Promise<unknown>;
343
+ };
344
+ }
345
+ interface Slack {
346
+ messages: {
347
+ send(params: {
348
+ channelId: string;
349
+ text: string;
350
+ blocks?: unknown[];
351
+ }): Promise<unknown>;
352
+ list(params: {
353
+ channelId: string;
354
+ limit?: number;
355
+ }): Promise<unknown>;
356
+ };
357
+ channels: {
358
+ list(): Promise<unknown>;
359
+ };
360
+ users: {
361
+ list(): Promise<unknown>;
362
+ };
363
+ reactions: {
364
+ add(params: {
365
+ channelId: string;
366
+ timestamp: string;
367
+ reaction: string;
368
+ }): Promise<unknown>;
369
+ };
370
+ }
371
+ interface Figma {
372
+ files: {
373
+ get(params: {
374
+ fileKey: string;
375
+ }): Promise<unknown>;
376
+ getNodes(params: {
377
+ fileKey: string;
378
+ nodeIds: string[];
379
+ }): Promise<unknown>;
380
+ getImages(params: {
381
+ fileKey: string;
382
+ nodeIds: string[];
383
+ format?: 'png' | 'svg' | 'pdf';
384
+ }): Promise<unknown>;
385
+ getComments(params: {
386
+ fileKey: string;
387
+ }): Promise<unknown>;
388
+ postComment(params: {
389
+ fileKey: string;
390
+ message: string;
391
+ nodeId?: string;
392
+ }): Promise<unknown>;
393
+ };
394
+ projects: {
395
+ list(params: {
396
+ teamId: string;
397
+ }): Promise<unknown>;
398
+ getFiles(params: {
399
+ projectId: string;
400
+ }): Promise<unknown>;
401
+ };
402
+ }
403
+ interface Stripe {
404
+ customers: {
405
+ create(params: {
406
+ email: string;
407
+ name?: string;
408
+ metadata?: Record<string, string>;
409
+ }): Promise<unknown>;
410
+ retrieve(params: {
411
+ customerId: string;
412
+ }): Promise<unknown>;
413
+ update(params: {
414
+ customerId: string;
415
+ metadata?: Record<string, string>;
416
+ }): Promise<unknown>;
417
+ listPaymentMethods(params: {
418
+ customerId: string;
419
+ }): Promise<unknown>;
420
+ };
421
+ paymentIntents: {
422
+ create(params: {
423
+ amount: number;
424
+ currency: string;
425
+ customer?: string;
426
+ }): Promise<unknown>;
427
+ retrieve(params: {
428
+ paymentIntentId: string;
429
+ }): Promise<unknown>;
430
+ confirm(params: {
431
+ paymentIntentId: string;
432
+ }): Promise<unknown>;
433
+ };
434
+ subscriptions: {
435
+ create(params: {
436
+ customer: string;
437
+ items: unknown[];
438
+ }): Promise<unknown>;
439
+ retrieve(params: {
440
+ subscriptionId: string;
441
+ }): Promise<unknown>;
442
+ cancel(params: {
443
+ subscriptionId: string;
444
+ }): Promise<unknown>;
445
+ };
446
+ }
447
+ }
448
+ declare namespace Memory {
449
+ interface MemoryClient {
450
+ create(params: {
451
+ content: string;
452
+ keywords?: string[];
453
+ metadata?: Record<string, unknown>;
454
+ }): Promise<unknown>;
455
+ get(params: {
456
+ memoryId: string;
457
+ }): Promise<unknown>;
458
+ recall(params: {
459
+ query: string;
460
+ topK?: number;
461
+ threshold?: number;
462
+ }): Promise<unknown>;
463
+ list(params?: {
464
+ limit?: number;
465
+ offset?: number;
466
+ }): Promise<unknown>;
467
+ update(params: {
468
+ memoryId: string;
469
+ content?: string;
470
+ metadata?: Record<string, unknown>;
471
+ }): Promise<unknown>;
472
+ delete(params: {
473
+ memoryId: string;
474
+ }): Promise<unknown>;
475
+ }
476
+ }
477
+ declare namespace Articles {
478
+ interface ArticlesClient {
479
+ search(params: {
480
+ query: string;
481
+ limit?: number;
482
+ }): Promise<unknown>;
483
+ create(params: {
484
+ title: string;
485
+ content: string;
486
+ topics?: string[];
487
+ metadata?: Record<string, unknown>;
488
+ }): Promise<unknown>;
489
+ createFromUrl(params: {
490
+ url: string;
491
+ }): Promise<unknown>;
492
+ fetch(params: {
493
+ articleId: string;
494
+ }): Promise<unknown>;
495
+ recent(params?: {
496
+ limit?: number;
497
+ }): Promise<unknown>;
498
+ relevant(params: {
499
+ query: string;
500
+ limit?: number;
501
+ }): Promise<unknown>;
502
+ summarize(params: {
503
+ articleId?: string;
504
+ text?: string;
505
+ length?: 'short' | 'medium' | 'long';
506
+ }): Promise<unknown>;
507
+ extractTopics(params: {
508
+ text: string;
509
+ }): Promise<unknown>;
510
+ }
511
+ }
512
+ declare namespace Web {
513
+ interface WebClient {
514
+ search: {
515
+ exa(params: {
516
+ query: string;
517
+ numResults?: number;
518
+ includeDomains?: string[];
519
+ excludeDomains?: string[];
520
+ }): Promise<unknown>;
521
+ perplexity(params: {
522
+ query: string;
523
+ }): Promise<unknown>;
524
+ };
525
+ fetch(params: {
526
+ url: string;
527
+ headers?: Record<string, string>;
528
+ }): Promise<unknown>;
529
+ htmlToMarkdown(params: {
530
+ html: string;
531
+ baseUrl?: string;
532
+ }): Promise<unknown>;
533
+ extractHtml(params: {
534
+ html: string;
535
+ selector: string;
536
+ }): Promise<unknown>;
537
+ }
538
+ }
539
+ declare namespace AI {
540
+ interface AIClient {
541
+ embeddings: {
542
+ document(params: {
543
+ text: string;
544
+ }): Promise<unknown>;
545
+ query(params: {
546
+ text: string;
547
+ }): Promise<unknown>;
548
+ image(params: {
549
+ imageBase64: string;
550
+ }): Promise<unknown>;
551
+ };
552
+ image: {
553
+ generate(params: {
554
+ prompt: string;
555
+ size?: '256x256' | '512x512' | '1024x1024';
556
+ }): Promise<unknown>;
557
+ };
558
+ ocr(params: {
559
+ imageBase64: string;
560
+ }): Promise<unknown>;
561
+ vision(params: {
562
+ imageBase64: string;
563
+ prompt?: string;
564
+ }): Promise<unknown>;
565
+ chat(params: {
566
+ messages: Array<{
567
+ role: 'user' | 'assistant' | 'system';
568
+ content: string;
569
+ }>;
570
+ model?: string;
571
+ }): Promise<unknown>;
572
+ complete(params: {
573
+ prompt: string;
574
+ suffix?: string;
575
+ }): Promise<unknown>;
576
+ classify(params: {
577
+ text: string;
578
+ labels: string[];
579
+ }): Promise<unknown>;
580
+ segment(params: {
581
+ text: string;
582
+ maxLength?: number;
583
+ }): Promise<unknown[]>;
584
+ }
585
+ }
586
+ declare namespace Data {
587
+ interface DataClient {
588
+ csv: {
589
+ query(params: {
590
+ sql: string;
591
+ csvData?: string;
592
+ fileId?: string;
593
+ }): Promise<unknown>;
594
+ convert(params: {
595
+ data: string;
596
+ fromFormat: string;
597
+ toFormat: string;
598
+ }): Promise<unknown>;
599
+ };
600
+ scripts: {
601
+ create(params: {
602
+ name: string;
603
+ code: string;
604
+ language?: string;
605
+ }): Promise<unknown>;
606
+ execute(params: {
607
+ name: string;
608
+ params?: Record<string, unknown>;
609
+ }): Promise<unknown>;
610
+ list(): Promise<unknown>;
611
+ update(params: {
612
+ name: string;
613
+ code: string;
614
+ }): Promise<unknown>;
615
+ delete(params: {
616
+ name: string;
617
+ }): Promise<unknown>;
618
+ };
619
+ similarity: {
620
+ search(params: {
621
+ query: number[];
622
+ embeddings: number[][];
623
+ topK?: number;
624
+ }): Promise<unknown>;
625
+ duckDbSearch(params: {
626
+ query: number[];
627
+ tableName: string;
628
+ }): Promise<unknown>;
629
+ };
630
+ }
631
+ }
632
+ declare namespace Utils {
633
+ interface UtilsClient {
634
+ mermaid(params: {
635
+ diagram: string;
636
+ }): Promise<unknown>;
637
+ documentConvert(params: {
638
+ document: string;
639
+ mimeType: string;
640
+ format: string;
641
+ }): Promise<unknown>;
642
+ regex: {
643
+ match(params: {
644
+ text: string;
645
+ pattern: string;
646
+ flags?: string;
647
+ }): Promise<unknown>;
648
+ replace(params: {
649
+ text: string;
650
+ pattern: string;
651
+ replacement: string;
652
+ flags?: string;
653
+ }): Promise<unknown>;
654
+ };
655
+ jsonExtract(params: {
656
+ text: string;
657
+ }): Promise<unknown>;
658
+ digest(params: {
659
+ data: string;
660
+ }): Promise<string>;
661
+ monteCarlo(params: {
662
+ iterations?: number;
663
+ formula: string;
664
+ variables?: Record<string, {
665
+ mean: number;
666
+ stdDev: number;
667
+ }>;
668
+ }): Promise<unknown>;
669
+ }
670
+ }
671
+
672
+ /**
673
+ * Core HTTP client for Rainfall SDK
674
+ */
675
+
676
+ declare class RainfallClient {
677
+ private readonly apiKey;
678
+ private readonly baseUrl;
679
+ private readonly defaultTimeout;
680
+ private readonly defaultRetries;
681
+ private readonly defaultRetryDelay;
682
+ private lastRateLimitInfo?;
683
+ private subscriberId?;
684
+ constructor(config: RainfallConfig);
685
+ /**
686
+ * Get the last rate limit info from the API
687
+ */
688
+ getRateLimitInfo(): RateLimitInfo | undefined;
689
+ /**
690
+ * Make an authenticated request to the Rainfall API
691
+ */
692
+ request<T = unknown>(path: string, options?: {
693
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
694
+ body?: unknown;
695
+ headers?: Record<string, string>;
696
+ }, requestOptions?: RequestOptions): Promise<T>;
697
+ /**
698
+ * Execute a tool/node by ID
699
+ */
700
+ executeTool<T = unknown>(toolId: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<T>;
701
+ /**
702
+ * List all available tools
703
+ */
704
+ listTools(): Promise<Array<{
705
+ id: string;
706
+ name: string;
707
+ description: string;
708
+ category: string;
709
+ }>>;
710
+ /**
711
+ * Get tool schema/parameters
712
+ */
713
+ getToolSchema(toolId: string): Promise<ToolSchema>;
714
+ /**
715
+ * Get subscriber info
716
+ */
717
+ getMe(): Promise<{
718
+ id: string;
719
+ name: string;
720
+ email?: string;
721
+ plan?: string;
722
+ billingStatus?: string;
723
+ usage: {
724
+ callsThisMonth: number;
725
+ callsLimit: number;
726
+ };
727
+ }>;
728
+ /**
729
+ * Ensure we have a subscriber ID, fetching it if necessary
730
+ */
731
+ private ensureSubscriberId;
732
+ private sleep;
733
+ /**
734
+ * OpenAI-compatible chat completions with tool support
735
+ */
736
+ chatCompletions(params: {
737
+ subscriber_id: string;
738
+ messages: Array<{
739
+ role: string;
740
+ content: string;
741
+ name?: string;
742
+ }>;
743
+ model?: string;
744
+ stream?: boolean;
745
+ temperature?: number;
746
+ max_tokens?: number;
747
+ tools?: unknown[];
748
+ tool_choice?: string | {
749
+ type: string;
750
+ function?: {
751
+ name: string;
752
+ };
753
+ };
754
+ conversation_id?: string;
755
+ agent_name?: string;
756
+ incognito?: boolean;
757
+ tool_priority?: 'local' | 'rainfall' | 'serverside' | 'stacked';
758
+ enable_stacked?: boolean;
759
+ }): Promise<unknown>;
760
+ /**
761
+ * List available models (OpenAI-compatible format)
762
+ */
763
+ listModels(subscriberId?: string): Promise<Array<{
764
+ id: string;
765
+ [key: string]: unknown;
766
+ }>>;
767
+ }
768
+
769
+ /**
770
+ * Integrations namespace for Rainfall SDK
771
+ * GitHub, Notion, Linear, Slack, Figma, Stripe
772
+ */
773
+
774
+ declare class IntegrationsNamespace {
775
+ private client;
776
+ constructor(client: RainfallClient);
777
+ get github(): Integrations.GitHub;
778
+ get notion(): Integrations.Notion;
779
+ get linear(): Integrations.Linear;
780
+ get slack(): Integrations.Slack;
781
+ get figma(): Integrations.Figma;
782
+ get stripe(): Integrations.Stripe;
783
+ }
784
+
785
+ declare class Rainfall {
786
+ private readonly client;
787
+ private _integrations?;
788
+ private _memory?;
789
+ private _articles?;
790
+ private _web?;
791
+ private _ai?;
792
+ private _data?;
793
+ private _utils?;
794
+ constructor(config: RainfallConfig);
795
+ /**
796
+ * Integrations namespace - GitHub, Notion, Linear, Slack, Figma, Stripe
797
+ *
798
+ * @example
799
+ * ```typescript
800
+ * // GitHub
801
+ * await rainfall.integrations.github.issues.create({
802
+ * owner: 'facebook',
803
+ * repo: 'react',
804
+ * title: 'Bug report'
805
+ * });
806
+ *
807
+ * // Slack
808
+ * await rainfall.integrations.slack.messages.send({
809
+ * channelId: 'C123456',
810
+ * text: 'Hello team!'
811
+ * });
812
+ *
813
+ * // Linear
814
+ * const issues = await rainfall.integrations.linear.issues.list();
815
+ * ```
816
+ */
817
+ get integrations(): IntegrationsNamespace;
818
+ /**
819
+ * Memory namespace - Semantic memory storage and retrieval
820
+ *
821
+ * @example
822
+ * ```typescript
823
+ * // Store a memory
824
+ * await rainfall.memory.create({
825
+ * content: 'User prefers dark mode',
826
+ * keywords: ['preference', 'ui']
827
+ * });
828
+ *
829
+ * // Recall similar memories
830
+ * const memories = await rainfall.memory.recall({
831
+ * query: 'user preferences',
832
+ * topK: 5
833
+ * });
834
+ * ```
835
+ */
836
+ get memory(): Memory.MemoryClient;
837
+ /**
838
+ * Articles namespace - News aggregation and article management
839
+ *
840
+ * @example
841
+ * ```typescript
842
+ * // Search news
843
+ * const articles = await rainfall.articles.search({
844
+ * query: 'artificial intelligence'
845
+ * });
846
+ *
847
+ * // Create from URL
848
+ * const article = await rainfall.articles.createFromUrl({
849
+ * url: 'https://example.com/article'
850
+ * });
851
+ *
852
+ * // Summarize
853
+ * const summary = await rainfall.articles.summarize({
854
+ * text: article.content
855
+ * });
856
+ * ```
857
+ */
858
+ get articles(): Articles.ArticlesClient;
859
+ /**
860
+ * Web namespace - Web search, scraping, and content extraction
861
+ *
862
+ * @example
863
+ * ```typescript
864
+ * // Search with Exa
865
+ * const results = await rainfall.web.search.exa({
866
+ * query: 'latest AI research'
867
+ * });
868
+ *
869
+ * // Fetch and convert
870
+ * const html = await rainfall.web.fetch({ url: 'https://example.com' });
871
+ * const markdown = await rainfall.web.htmlToMarkdown({ html });
872
+ *
873
+ * // Extract specific elements
874
+ * const links = await rainfall.web.extractHtml({
875
+ * html,
876
+ * selector: 'a[href]'
877
+ * });
878
+ * ```
879
+ */
880
+ get web(): Web.WebClient;
881
+ /**
882
+ * AI namespace - Embeddings, image generation, OCR, vision, chat
883
+ *
884
+ * @example
885
+ * ```typescript
886
+ * // Generate embeddings
887
+ * const embedding = await rainfall.ai.embeddings.document({
888
+ * text: 'Hello world'
889
+ * });
890
+ *
891
+ * // Generate image
892
+ * const image = await rainfall.ai.image.generate({
893
+ * prompt: 'A serene mountain landscape'
894
+ * });
895
+ *
896
+ * // OCR
897
+ * const text = await rainfall.ai.ocr({ imageBase64: '...' });
898
+ *
899
+ * // Chat
900
+ * const response = await rainfall.ai.chat({
901
+ * messages: [{ role: 'user', content: 'Hello!' }]
902
+ * });
903
+ * ```
904
+ */
905
+ get ai(): AI.AIClient;
906
+ /**
907
+ * Data namespace - CSV processing, scripts, similarity search
908
+ *
909
+ * @example
910
+ * ```typescript
911
+ * // Query CSV with SQL
912
+ * const results = await rainfall.data.csv.query({
913
+ * sql: 'SELECT * FROM data WHERE value > 100'
914
+ * });
915
+ *
916
+ * // Execute saved script
917
+ * const result = await rainfall.data.scripts.execute({
918
+ * name: 'my-script',
919
+ * params: { input: 'data' }
920
+ * });
921
+ * ```
922
+ */
923
+ get data(): Data.DataClient;
924
+ /**
925
+ * Utils namespace - Mermaid diagrams, document conversion, regex, JSON extraction
926
+ *
927
+ * @example
928
+ * ```typescript
929
+ * // Generate diagram
930
+ * const diagram = await rainfall.utils.mermaid({
931
+ * diagram: 'graph TD; A-->B;'
932
+ * });
933
+ *
934
+ * // Convert document
935
+ * const pdf = await rainfall.utils.documentConvert({
936
+ * document: markdownContent,
937
+ * mimeType: 'text/markdown',
938
+ * format: 'pdf'
939
+ * });
940
+ *
941
+ * // Extract JSON from text
942
+ * const json = await rainfall.utils.jsonExtract({
943
+ * text: 'Here is some data: {"key": "value"}'
944
+ * });
945
+ * ```
946
+ */
947
+ get utils(): Utils.UtilsClient;
948
+ /**
949
+ * Get the underlying HTTP client for advanced usage
950
+ */
951
+ getClient(): RainfallClient;
952
+ /**
953
+ * List all available tools
954
+ */
955
+ listTools(): Promise<{
956
+ id: string;
957
+ name: string;
958
+ description: string;
959
+ category: string;
960
+ }[]>;
961
+ /**
962
+ * Get schema for a specific tool
963
+ */
964
+ getToolSchema(toolId: string): Promise<ToolSchema>;
965
+ /**
966
+ * Execute any tool by ID (low-level access)
967
+ */
968
+ executeTool<T = unknown>(toolId: string, params?: Record<string, unknown>): Promise<T>;
969
+ /**
970
+ * Get current subscriber info and usage
971
+ */
972
+ getMe(): Promise<{
973
+ id: string;
974
+ name: string;
975
+ email?: string;
976
+ plan?: string;
977
+ billingStatus?: string;
978
+ usage: {
979
+ callsThisMonth: number;
980
+ callsLimit: number;
981
+ };
982
+ }>;
983
+ /**
984
+ * Get current rate limit info
985
+ */
986
+ getRateLimitInfo(): RateLimitInfo | undefined;
987
+ /**
988
+ * OpenAI-compatible chat completions with tool support
989
+ *
990
+ * @example
991
+ * ```typescript
992
+ * // Simple chat
993
+ * const response = await rainfall.chatCompletions({
994
+ * subscriber_id: 'my-subscriber',
995
+ * messages: [{ role: 'user', content: 'Hello!' }],
996
+ * model: 'llama-3.3-70b-versatile'
997
+ * });
998
+ *
999
+ * // With tools
1000
+ * const response = await rainfall.chatCompletions({
1001
+ * subscriber_id: 'my-subscriber',
1002
+ * messages: [{ role: 'user', content: 'Search for AI news' }],
1003
+ * tools: [{ type: 'function', function: { name: 'web-search' } }],
1004
+ * enable_stacked: true
1005
+ * });
1006
+ *
1007
+ * // Streaming
1008
+ * const stream = await rainfall.chatCompletions({
1009
+ * subscriber_id: 'my-subscriber',
1010
+ * messages: [{ role: 'user', content: 'Tell me a story' }],
1011
+ * stream: true
1012
+ * });
1013
+ * ```
1014
+ */
1015
+ chatCompletions(params: {
1016
+ subscriber_id: string;
1017
+ messages: Array<{
1018
+ role: string;
1019
+ content: string;
1020
+ name?: string;
1021
+ }>;
1022
+ model?: string;
1023
+ stream?: boolean;
1024
+ temperature?: number;
1025
+ max_tokens?: number;
1026
+ tools?: unknown[];
1027
+ tool_choice?: string | {
1028
+ type: string;
1029
+ function?: {
1030
+ name: string;
1031
+ };
1032
+ };
1033
+ conversation_id?: string;
1034
+ agent_name?: string;
1035
+ incognito?: boolean;
1036
+ tool_priority?: 'local' | 'rainfall' | 'serverside' | 'stacked';
1037
+ enable_stacked?: boolean;
1038
+ }): Promise<unknown>;
1039
+ /**
1040
+ * List available models (OpenAI-compatible format)
1041
+ *
1042
+ * @example
1043
+ * ```typescript
1044
+ * const models = await rainfall.listModels();
1045
+ * console.log(models); // [{ id: 'llama-3.3-70b-versatile', ... }]
1046
+ * ```
1047
+ */
1048
+ listModels(subscriberId?: string): Promise<Array<{
1049
+ id: string;
1050
+ [key: string]: unknown;
1051
+ }>>;
1052
+ }
1053
+
1054
+ export { AI as A, Data as D, Integrations as I, Memory as M, type RainfallConfig as R, type ToolSchema as T, Utils as U, Web as W, Rainfall as a, type ApiError as b, type ApiResponse as c, Articles as d, type RateLimitInfo as e, type RequestOptions as f, type MCPClientConfig as g, MCPProxyHub as h, type MCPClientInfo as i, type MCPToolInfo as j, type MCPTransportType as k, RainfallClient as l };