@rainfall-devkit/sdk 0.2.2 → 0.2.3

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.
@@ -0,0 +1,1165 @@
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
+ /** Disable parameter validation before tool execution (default: false) */
192
+ disableValidation?: boolean;
193
+ /** Pre-configured MCP clients to connect on daemon startup */
194
+ mcpClients?: MCPClientConfig[];
195
+ }
196
+ interface RequestOptions {
197
+ timeout?: number;
198
+ retries?: number;
199
+ retryDelay?: number;
200
+ }
201
+ interface ApiResponse<T = unknown> {
202
+ success: boolean;
203
+ data?: T;
204
+ error?: ApiError;
205
+ }
206
+ interface ApiError {
207
+ code: string;
208
+ message: string;
209
+ details?: Record<string, unknown>;
210
+ }
211
+ interface RateLimitInfo {
212
+ limit: number;
213
+ remaining: number;
214
+ resetAt: Date;
215
+ }
216
+ interface ToolSchema {
217
+ name: string;
218
+ description: string;
219
+ category: string;
220
+ parameters: unknown;
221
+ output: unknown;
222
+ metadata: Record<string, unknown>;
223
+ }
224
+ declare namespace Integrations {
225
+ interface GitHub {
226
+ issues: {
227
+ create(params: {
228
+ owner: string;
229
+ repo: string;
230
+ title: string;
231
+ body?: string;
232
+ }): Promise<unknown>;
233
+ list(params: {
234
+ owner: string;
235
+ repo: string;
236
+ state?: 'open' | 'closed' | 'all';
237
+ }): Promise<unknown>;
238
+ get(params: {
239
+ owner: string;
240
+ repo: string;
241
+ issue_number: number;
242
+ }): Promise<unknown>;
243
+ update(params: {
244
+ owner: string;
245
+ repo: string;
246
+ issue_number: number;
247
+ title?: string;
248
+ body?: string;
249
+ state?: 'open' | 'closed';
250
+ }): Promise<unknown>;
251
+ addComment(params: {
252
+ owner: string;
253
+ repo: string;
254
+ issue_number: number;
255
+ body: string;
256
+ }): Promise<unknown>;
257
+ };
258
+ repos: {
259
+ get(params: {
260
+ owner: string;
261
+ repo: string;
262
+ }): Promise<unknown>;
263
+ listBranches(params: {
264
+ owner: string;
265
+ repo: string;
266
+ }): Promise<unknown>;
267
+ };
268
+ pullRequests: {
269
+ list(params: {
270
+ owner: string;
271
+ repo: string;
272
+ state?: 'open' | 'closed' | 'all';
273
+ }): Promise<unknown>;
274
+ get(params: {
275
+ owner: string;
276
+ repo: string;
277
+ pullNumber: number;
278
+ }): Promise<unknown>;
279
+ };
280
+ }
281
+ interface Notion {
282
+ pages: {
283
+ create(params: {
284
+ parent: unknown;
285
+ properties: unknown;
286
+ children?: unknown[];
287
+ }): Promise<unknown>;
288
+ retrieve(params: {
289
+ pageId: string;
290
+ }): Promise<unknown>;
291
+ update(params: {
292
+ pageId: string;
293
+ properties: unknown;
294
+ }): Promise<unknown>;
295
+ };
296
+ databases: {
297
+ query(params: {
298
+ databaseId: string;
299
+ filter?: unknown;
300
+ sorts?: unknown[];
301
+ }): Promise<unknown>;
302
+ retrieve(params: {
303
+ databaseId: string;
304
+ }): Promise<unknown>;
305
+ };
306
+ blocks: {
307
+ appendChildren(params: {
308
+ blockId: string;
309
+ children: unknown[];
310
+ }): Promise<unknown>;
311
+ retrieveChildren(params: {
312
+ blockId: string;
313
+ }): Promise<unknown>;
314
+ };
315
+ }
316
+ interface Linear {
317
+ issues: {
318
+ create(params: {
319
+ title: string;
320
+ description?: string;
321
+ teamId?: string;
322
+ assigneeId?: string;
323
+ priority?: number;
324
+ labels?: string[];
325
+ }): Promise<unknown>;
326
+ list(params?: {
327
+ filter?: unknown;
328
+ orderBy?: string;
329
+ }): Promise<unknown>;
330
+ get(params: {
331
+ issueId: string;
332
+ }): Promise<unknown>;
333
+ update(params: {
334
+ issueId: string;
335
+ title?: string;
336
+ description?: string;
337
+ state?: string;
338
+ }): Promise<unknown>;
339
+ archive(params: {
340
+ issueId: string;
341
+ }): Promise<unknown>;
342
+ };
343
+ teams: {
344
+ list(): Promise<unknown>;
345
+ };
346
+ }
347
+ interface Slack {
348
+ messages: {
349
+ send(params: {
350
+ channelId: string;
351
+ text: string;
352
+ blocks?: unknown[];
353
+ }): Promise<unknown>;
354
+ list(params: {
355
+ channelId: string;
356
+ limit?: number;
357
+ }): Promise<unknown>;
358
+ };
359
+ channels: {
360
+ list(): Promise<unknown>;
361
+ };
362
+ users: {
363
+ list(): Promise<unknown>;
364
+ };
365
+ reactions: {
366
+ add(params: {
367
+ channelId: string;
368
+ timestamp: string;
369
+ reaction: string;
370
+ }): Promise<unknown>;
371
+ };
372
+ }
373
+ interface Figma {
374
+ files: {
375
+ get(params: {
376
+ fileKey: string;
377
+ }): Promise<unknown>;
378
+ getNodes(params: {
379
+ fileKey: string;
380
+ nodeIds: string[];
381
+ }): Promise<unknown>;
382
+ getImages(params: {
383
+ fileKey: string;
384
+ nodeIds: string[];
385
+ format?: 'png' | 'svg' | 'pdf';
386
+ }): Promise<unknown>;
387
+ getComments(params: {
388
+ fileKey: string;
389
+ }): Promise<unknown>;
390
+ postComment(params: {
391
+ fileKey: string;
392
+ message: string;
393
+ nodeId?: string;
394
+ }): Promise<unknown>;
395
+ };
396
+ projects: {
397
+ list(params: {
398
+ teamId: string;
399
+ }): Promise<unknown>;
400
+ getFiles(params: {
401
+ projectId: string;
402
+ }): Promise<unknown>;
403
+ };
404
+ }
405
+ interface Stripe {
406
+ customers: {
407
+ create(params: {
408
+ email: string;
409
+ name?: string;
410
+ metadata?: Record<string, string>;
411
+ }): Promise<unknown>;
412
+ retrieve(params: {
413
+ customerId: string;
414
+ }): Promise<unknown>;
415
+ update(params: {
416
+ customerId: string;
417
+ metadata?: Record<string, string>;
418
+ }): Promise<unknown>;
419
+ listPaymentMethods(params: {
420
+ customerId: string;
421
+ }): Promise<unknown>;
422
+ };
423
+ paymentIntents: {
424
+ create(params: {
425
+ amount: number;
426
+ currency: string;
427
+ customer?: string;
428
+ }): Promise<unknown>;
429
+ retrieve(params: {
430
+ paymentIntentId: string;
431
+ }): Promise<unknown>;
432
+ confirm(params: {
433
+ paymentIntentId: string;
434
+ }): Promise<unknown>;
435
+ };
436
+ subscriptions: {
437
+ create(params: {
438
+ customer: string;
439
+ items: unknown[];
440
+ }): Promise<unknown>;
441
+ retrieve(params: {
442
+ subscriptionId: string;
443
+ }): Promise<unknown>;
444
+ cancel(params: {
445
+ subscriptionId: string;
446
+ }): Promise<unknown>;
447
+ };
448
+ }
449
+ }
450
+ declare namespace Memory {
451
+ interface MemoryClient {
452
+ create(params: {
453
+ content: string;
454
+ keywords?: string[];
455
+ metadata?: Record<string, unknown>;
456
+ }): Promise<unknown>;
457
+ get(params: {
458
+ memoryId: string;
459
+ }): Promise<unknown>;
460
+ recall(params: {
461
+ query: string;
462
+ topK?: number;
463
+ threshold?: number;
464
+ }): Promise<unknown>;
465
+ list(params?: {
466
+ limit?: number;
467
+ offset?: number;
468
+ }): Promise<unknown>;
469
+ update(params: {
470
+ memoryId: string;
471
+ content?: string;
472
+ metadata?: Record<string, unknown>;
473
+ }): Promise<unknown>;
474
+ delete(params: {
475
+ memoryId: string;
476
+ }): Promise<unknown>;
477
+ }
478
+ }
479
+ declare namespace Articles {
480
+ interface ArticlesClient {
481
+ search(params: {
482
+ query: string;
483
+ limit?: number;
484
+ }): Promise<unknown>;
485
+ create(params: {
486
+ title: string;
487
+ content: string;
488
+ topics?: string[];
489
+ metadata?: Record<string, unknown>;
490
+ }): Promise<unknown>;
491
+ createFromUrl(params: {
492
+ url: string;
493
+ }): Promise<unknown>;
494
+ fetch(params: {
495
+ articleId: string;
496
+ }): Promise<unknown>;
497
+ recent(params?: {
498
+ limit?: number;
499
+ }): Promise<unknown>;
500
+ relevant(params: {
501
+ query: string;
502
+ limit?: number;
503
+ }): Promise<unknown>;
504
+ summarize(params: {
505
+ articleId?: string;
506
+ text?: string;
507
+ length?: 'short' | 'medium' | 'long';
508
+ }): Promise<unknown>;
509
+ extractTopics(params: {
510
+ text: string;
511
+ }): Promise<unknown>;
512
+ }
513
+ }
514
+ declare namespace Web {
515
+ interface WebClient {
516
+ search: {
517
+ exa(params: {
518
+ query: string;
519
+ numResults?: number;
520
+ includeDomains?: string[];
521
+ excludeDomains?: string[];
522
+ }): Promise<unknown>;
523
+ perplexity(params: {
524
+ query: string;
525
+ }): Promise<unknown>;
526
+ };
527
+ fetch(params: {
528
+ url: string;
529
+ headers?: Record<string, string>;
530
+ }): Promise<unknown>;
531
+ htmlToMarkdown(params: {
532
+ html: string;
533
+ baseUrl?: string;
534
+ }): Promise<unknown>;
535
+ extractHtml(params: {
536
+ html: string;
537
+ selector: string;
538
+ }): Promise<unknown>;
539
+ }
540
+ }
541
+ declare namespace AI {
542
+ interface AIClient {
543
+ embeddings: {
544
+ document(params: {
545
+ text: string;
546
+ }): Promise<unknown>;
547
+ query(params: {
548
+ text: string;
549
+ }): Promise<unknown>;
550
+ image(params: {
551
+ imageBase64: string;
552
+ }): Promise<unknown>;
553
+ };
554
+ image: {
555
+ generate(params: {
556
+ prompt: string;
557
+ size?: '256x256' | '512x512' | '1024x1024';
558
+ }): Promise<unknown>;
559
+ };
560
+ ocr(params: {
561
+ imageBase64: string;
562
+ }): Promise<unknown>;
563
+ vision(params: {
564
+ imageBase64: string;
565
+ prompt?: string;
566
+ }): Promise<unknown>;
567
+ chat(params: {
568
+ messages: Array<{
569
+ role: 'user' | 'assistant' | 'system';
570
+ content: string;
571
+ }>;
572
+ model?: string;
573
+ }): Promise<unknown>;
574
+ complete(params: {
575
+ prompt: string;
576
+ suffix?: string;
577
+ }): Promise<unknown>;
578
+ classify(params: {
579
+ text: string;
580
+ labels: string[];
581
+ }): Promise<unknown>;
582
+ segment(params: {
583
+ text: string;
584
+ maxLength?: number;
585
+ }): Promise<unknown[]>;
586
+ }
587
+ }
588
+ declare namespace Data {
589
+ interface DataClient {
590
+ csv: {
591
+ query(params: {
592
+ sql: string;
593
+ csvData?: string;
594
+ fileId?: string;
595
+ }): Promise<unknown>;
596
+ convert(params: {
597
+ data: string;
598
+ fromFormat: string;
599
+ toFormat: string;
600
+ }): Promise<unknown>;
601
+ };
602
+ scripts: {
603
+ create(params: {
604
+ name: string;
605
+ code: string;
606
+ language?: string;
607
+ }): Promise<unknown>;
608
+ execute(params: {
609
+ name: string;
610
+ params?: Record<string, unknown>;
611
+ }): Promise<unknown>;
612
+ list(): Promise<unknown>;
613
+ update(params: {
614
+ name: string;
615
+ code: string;
616
+ }): Promise<unknown>;
617
+ delete(params: {
618
+ name: string;
619
+ }): Promise<unknown>;
620
+ };
621
+ similarity: {
622
+ search(params: {
623
+ query: number[];
624
+ embeddings: number[][];
625
+ topK?: number;
626
+ }): Promise<unknown>;
627
+ duckDbSearch(params: {
628
+ query: number[];
629
+ tableName: string;
630
+ }): Promise<unknown>;
631
+ };
632
+ }
633
+ }
634
+ declare namespace Utils {
635
+ interface UtilsClient {
636
+ mermaid(params: {
637
+ diagram: string;
638
+ }): Promise<unknown>;
639
+ documentConvert(params: {
640
+ document: string;
641
+ mimeType: string;
642
+ format: string;
643
+ }): Promise<unknown>;
644
+ regex: {
645
+ match(params: {
646
+ text: string;
647
+ pattern: string;
648
+ flags?: string;
649
+ }): Promise<unknown>;
650
+ replace(params: {
651
+ text: string;
652
+ pattern: string;
653
+ replacement: string;
654
+ flags?: string;
655
+ }): Promise<unknown>;
656
+ };
657
+ jsonExtract(params: {
658
+ text: string;
659
+ }): Promise<unknown>;
660
+ digest(params: {
661
+ data: string;
662
+ }): Promise<string>;
663
+ monteCarlo(params: {
664
+ iterations?: number;
665
+ formula: string;
666
+ variables?: Record<string, {
667
+ mean: number;
668
+ stdDev: number;
669
+ }>;
670
+ }): Promise<unknown>;
671
+ }
672
+ }
673
+
674
+ /**
675
+ * Parameter validation for Rainfall SDK
676
+ * Fetches node schemas and validates params before execution
677
+ */
678
+
679
+ interface ParamSchema {
680
+ type: string;
681
+ description?: string;
682
+ optional?: boolean;
683
+ items?: ParamSchema;
684
+ properties?: Record<string, ParamSchema>;
685
+ [key: string]: unknown;
686
+ }
687
+ interface ToolParamsSchema {
688
+ name: string;
689
+ description: string;
690
+ category: string;
691
+ parameters: Record<string, ParamSchema>;
692
+ output?: unknown;
693
+ metadata?: Record<string, unknown>;
694
+ }
695
+ interface ValidationResult {
696
+ valid: boolean;
697
+ errors: ValidationIssue[];
698
+ }
699
+ interface ValidationIssue {
700
+ path: string;
701
+ message: string;
702
+ received?: unknown;
703
+ expected?: string;
704
+ }
705
+ /**
706
+ * Fetch and cache tool schema from the API
707
+ */
708
+ declare function fetchToolSchema(client: RainfallClient, toolId: string): Promise<ToolParamsSchema>;
709
+ /**
710
+ * Clear the schema cache (useful for testing or when schemas may have changed)
711
+ */
712
+ declare function clearSchemaCache(): void;
713
+ /**
714
+ * Validate params against a tool's schema
715
+ */
716
+ declare function validateParams(schema: ToolParamsSchema, params: Record<string, unknown> | undefined, toolId: string): ValidationResult;
717
+ /**
718
+ * Format validation errors into a readable message
719
+ */
720
+ declare function formatValidationErrors(result: ValidationResult): string;
721
+
722
+ /**
723
+ * Core HTTP client for Rainfall SDK
724
+ */
725
+
726
+ declare class RainfallClient {
727
+ private readonly apiKey;
728
+ private readonly baseUrl;
729
+ private readonly defaultTimeout;
730
+ private readonly defaultRetries;
731
+ private readonly defaultRetryDelay;
732
+ private readonly disableValidation;
733
+ private lastRateLimitInfo?;
734
+ private subscriberId?;
735
+ constructor(config: RainfallConfig);
736
+ /**
737
+ * Get the last rate limit info from the API
738
+ */
739
+ getRateLimitInfo(): RateLimitInfo | undefined;
740
+ /**
741
+ * Make an authenticated request to the Rainfall API
742
+ */
743
+ request<T = unknown>(path: string, options?: {
744
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
745
+ body?: unknown;
746
+ headers?: Record<string, string>;
747
+ }, requestOptions?: RequestOptions): Promise<T>;
748
+ /**
749
+ * Execute a tool/node by ID
750
+ *
751
+ * @param toolId - The ID of the tool/node to execute
752
+ * @param params - Parameters to pass to the tool
753
+ * @param options - Request options including skipValidation to bypass param validation
754
+ */
755
+ executeTool<T = unknown>(toolId: string, params?: Record<string, unknown>, options?: RequestOptions & {
756
+ skipValidation?: boolean;
757
+ }): Promise<T>;
758
+ /**
759
+ * Validate parameters for a tool without executing it
760
+ * Fetches the tool schema and validates the provided params
761
+ *
762
+ * @param toolId - The ID of the tool to validate params for
763
+ * @param params - Parameters to validate
764
+ * @returns Validation result with detailed error information
765
+ *
766
+ * @example
767
+ * ```typescript
768
+ * const result = await client.validateToolParams('finviz-quotes', { tickers: ['AAPL'] });
769
+ * if (!result.valid) {
770
+ * console.log('Validation errors:', result.errors);
771
+ * }
772
+ * ```
773
+ */
774
+ validateToolParams(toolId: string, params?: Record<string, unknown>): Promise<ValidationResult>;
775
+ /**
776
+ * List all available tools
777
+ */
778
+ listTools(): Promise<Array<{
779
+ id: string;
780
+ name: string;
781
+ description: string;
782
+ category: string;
783
+ }>>;
784
+ /**
785
+ * Get tool schema/parameters
786
+ *
787
+ * @param toolId - The ID of the tool to get schema for
788
+ * @returns Tool schema including parameters and output definitions
789
+ */
790
+ getToolSchema(toolId: string): Promise<ToolSchema>;
791
+ /**
792
+ * Get subscriber info
793
+ */
794
+ getMe(): Promise<{
795
+ id: string;
796
+ name: string;
797
+ email?: string;
798
+ plan?: string;
799
+ billingStatus?: string;
800
+ usage: {
801
+ callsThisMonth: number;
802
+ callsLimit: number;
803
+ };
804
+ }>;
805
+ /**
806
+ * Ensure we have a subscriber ID, fetching it if necessary
807
+ */
808
+ private ensureSubscriberId;
809
+ private sleep;
810
+ /**
811
+ * OpenAI-compatible chat completions with tool support
812
+ */
813
+ chatCompletions(params: {
814
+ subscriber_id: string;
815
+ messages: Array<{
816
+ role: string;
817
+ content: string;
818
+ name?: string;
819
+ }>;
820
+ model?: string;
821
+ stream?: boolean;
822
+ temperature?: number;
823
+ max_tokens?: number;
824
+ tools?: unknown[];
825
+ tool_choice?: string | {
826
+ type: string;
827
+ function?: {
828
+ name: string;
829
+ };
830
+ };
831
+ conversation_id?: string;
832
+ agent_name?: string;
833
+ incognito?: boolean;
834
+ tool_priority?: 'local' | 'rainfall' | 'serverside' | 'stacked';
835
+ enable_stacked?: boolean;
836
+ }): Promise<unknown>;
837
+ /**
838
+ * List available models (OpenAI-compatible format)
839
+ */
840
+ listModels(subscriberId?: string): Promise<Array<{
841
+ id: string;
842
+ [key: string]: unknown;
843
+ }>>;
844
+ }
845
+
846
+ /**
847
+ * Integrations namespace for Rainfall SDK
848
+ * GitHub, Notion, Linear, Slack, Figma, Stripe
849
+ */
850
+
851
+ declare class IntegrationsNamespace {
852
+ private client;
853
+ constructor(client: RainfallClient);
854
+ get github(): Integrations.GitHub;
855
+ get notion(): Integrations.Notion;
856
+ get linear(): Integrations.Linear;
857
+ get slack(): Integrations.Slack;
858
+ get figma(): Integrations.Figma;
859
+ get stripe(): Integrations.Stripe;
860
+ }
861
+
862
+ declare class Rainfall {
863
+ private readonly client;
864
+ private _integrations?;
865
+ private _memory?;
866
+ private _articles?;
867
+ private _web?;
868
+ private _ai?;
869
+ private _data?;
870
+ private _utils?;
871
+ constructor(config: RainfallConfig);
872
+ /**
873
+ * Integrations namespace - GitHub, Notion, Linear, Slack, Figma, Stripe
874
+ *
875
+ * @example
876
+ * ```typescript
877
+ * // GitHub
878
+ * await rainfall.integrations.github.issues.create({
879
+ * owner: 'facebook',
880
+ * repo: 'react',
881
+ * title: 'Bug report'
882
+ * });
883
+ *
884
+ * // Slack
885
+ * await rainfall.integrations.slack.messages.send({
886
+ * channelId: 'C123456',
887
+ * text: 'Hello team!'
888
+ * });
889
+ *
890
+ * // Linear
891
+ * const issues = await rainfall.integrations.linear.issues.list();
892
+ * ```
893
+ */
894
+ get integrations(): IntegrationsNamespace;
895
+ /**
896
+ * Memory namespace - Semantic memory storage and retrieval
897
+ *
898
+ * @example
899
+ * ```typescript
900
+ * // Store a memory
901
+ * await rainfall.memory.create({
902
+ * content: 'User prefers dark mode',
903
+ * keywords: ['preference', 'ui']
904
+ * });
905
+ *
906
+ * // Recall similar memories
907
+ * const memories = await rainfall.memory.recall({
908
+ * query: 'user preferences',
909
+ * topK: 5
910
+ * });
911
+ * ```
912
+ */
913
+ get memory(): Memory.MemoryClient;
914
+ /**
915
+ * Articles namespace - News aggregation and article management
916
+ *
917
+ * @example
918
+ * ```typescript
919
+ * // Search news
920
+ * const articles = await rainfall.articles.search({
921
+ * query: 'artificial intelligence'
922
+ * });
923
+ *
924
+ * // Create from URL
925
+ * const article = await rainfall.articles.createFromUrl({
926
+ * url: 'https://example.com/article'
927
+ * });
928
+ *
929
+ * // Summarize
930
+ * const summary = await rainfall.articles.summarize({
931
+ * text: article.content
932
+ * });
933
+ * ```
934
+ */
935
+ get articles(): Articles.ArticlesClient;
936
+ /**
937
+ * Web namespace - Web search, scraping, and content extraction
938
+ *
939
+ * @example
940
+ * ```typescript
941
+ * // Search with Exa
942
+ * const results = await rainfall.web.search.exa({
943
+ * query: 'latest AI research'
944
+ * });
945
+ *
946
+ * // Fetch and convert
947
+ * const html = await rainfall.web.fetch({ url: 'https://example.com' });
948
+ * const markdown = await rainfall.web.htmlToMarkdown({ html });
949
+ *
950
+ * // Extract specific elements
951
+ * const links = await rainfall.web.extractHtml({
952
+ * html,
953
+ * selector: 'a[href]'
954
+ * });
955
+ * ```
956
+ */
957
+ get web(): Web.WebClient;
958
+ /**
959
+ * AI namespace - Embeddings, image generation, OCR, vision, chat
960
+ *
961
+ * @example
962
+ * ```typescript
963
+ * // Generate embeddings
964
+ * const embedding = await rainfall.ai.embeddings.document({
965
+ * text: 'Hello world'
966
+ * });
967
+ *
968
+ * // Generate image
969
+ * const image = await rainfall.ai.image.generate({
970
+ * prompt: 'A serene mountain landscape'
971
+ * });
972
+ *
973
+ * // OCR
974
+ * const text = await rainfall.ai.ocr({ imageBase64: '...' });
975
+ *
976
+ * // Chat
977
+ * const response = await rainfall.ai.chat({
978
+ * messages: [{ role: 'user', content: 'Hello!' }]
979
+ * });
980
+ * ```
981
+ */
982
+ get ai(): AI.AIClient;
983
+ /**
984
+ * Data namespace - CSV processing, scripts, similarity search
985
+ *
986
+ * @example
987
+ * ```typescript
988
+ * // Query CSV with SQL
989
+ * const results = await rainfall.data.csv.query({
990
+ * sql: 'SELECT * FROM data WHERE value > 100'
991
+ * });
992
+ *
993
+ * // Execute saved script
994
+ * const result = await rainfall.data.scripts.execute({
995
+ * name: 'my-script',
996
+ * params: { input: 'data' }
997
+ * });
998
+ * ```
999
+ */
1000
+ get data(): Data.DataClient;
1001
+ /**
1002
+ * Utils namespace - Mermaid diagrams, document conversion, regex, JSON extraction
1003
+ *
1004
+ * @example
1005
+ * ```typescript
1006
+ * // Generate diagram
1007
+ * const diagram = await rainfall.utils.mermaid({
1008
+ * diagram: 'graph TD; A-->B;'
1009
+ * });
1010
+ *
1011
+ * // Convert document
1012
+ * const pdf = await rainfall.utils.documentConvert({
1013
+ * document: markdownContent,
1014
+ * mimeType: 'text/markdown',
1015
+ * format: 'pdf'
1016
+ * });
1017
+ *
1018
+ * // Extract JSON from text
1019
+ * const json = await rainfall.utils.jsonExtract({
1020
+ * text: 'Here is some data: {"key": "value"}'
1021
+ * });
1022
+ * ```
1023
+ */
1024
+ get utils(): Utils.UtilsClient;
1025
+ /**
1026
+ * Get the underlying HTTP client for advanced usage
1027
+ */
1028
+ getClient(): RainfallClient;
1029
+ /**
1030
+ * List all available tools
1031
+ */
1032
+ listTools(): Promise<{
1033
+ id: string;
1034
+ name: string;
1035
+ description: string;
1036
+ category: string;
1037
+ }[]>;
1038
+ /**
1039
+ * Get schema for a specific tool
1040
+ */
1041
+ getToolSchema(toolId: string): Promise<ToolSchema>;
1042
+ /**
1043
+ * Execute any tool by ID (low-level access)
1044
+ *
1045
+ * @param toolId - The ID of the tool to execute
1046
+ * @param params - Parameters to pass to the tool
1047
+ * @param options - Execution options including skipValidation to bypass param validation
1048
+ *
1049
+ * @example
1050
+ * ```typescript
1051
+ * // Execute with validation (default)
1052
+ * const result = await rainfall.executeTool('finviz-quotes', { tickers: ['AAPL'] });
1053
+ *
1054
+ * // Execute without validation
1055
+ * const result = await rainfall.executeTool('finviz-quotes', { tickers: ['AAPL'] }, { skipValidation: true });
1056
+ * ```
1057
+ */
1058
+ executeTool<T = unknown>(toolId: string, params?: Record<string, unknown>, options?: {
1059
+ skipValidation?: boolean;
1060
+ timeout?: number;
1061
+ retries?: number;
1062
+ retryDelay?: number;
1063
+ }): Promise<T>;
1064
+ /**
1065
+ * Validate parameters for a tool without executing it
1066
+ *
1067
+ * @param toolId - The ID of the tool to validate params for
1068
+ * @param params - Parameters to validate
1069
+ * @returns Validation result with detailed error information
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * const result = await rainfall.validateToolParams('finviz-quotes', { tickers: ['AAPL'] });
1074
+ * if (!result.valid) {
1075
+ * console.log('Validation errors:', result.errors);
1076
+ * }
1077
+ * ```
1078
+ */
1079
+ validateToolParams(toolId: string, params?: Record<string, unknown>): Promise<ValidationResult>;
1080
+ /**
1081
+ * Get current subscriber info and usage
1082
+ */
1083
+ getMe(): Promise<{
1084
+ id: string;
1085
+ name: string;
1086
+ email?: string;
1087
+ plan?: string;
1088
+ billingStatus?: string;
1089
+ usage: {
1090
+ callsThisMonth: number;
1091
+ callsLimit: number;
1092
+ };
1093
+ }>;
1094
+ /**
1095
+ * Get current rate limit info
1096
+ */
1097
+ getRateLimitInfo(): RateLimitInfo | undefined;
1098
+ /**
1099
+ * OpenAI-compatible chat completions with tool support
1100
+ *
1101
+ * @example
1102
+ * ```typescript
1103
+ * // Simple chat
1104
+ * const response = await rainfall.chatCompletions({
1105
+ * subscriber_id: 'my-subscriber',
1106
+ * messages: [{ role: 'user', content: 'Hello!' }],
1107
+ * model: 'llama-3.3-70b-versatile'
1108
+ * });
1109
+ *
1110
+ * // With tools
1111
+ * const response = await rainfall.chatCompletions({
1112
+ * subscriber_id: 'my-subscriber',
1113
+ * messages: [{ role: 'user', content: 'Search for AI news' }],
1114
+ * tools: [{ type: 'function', function: { name: 'web-search' } }],
1115
+ * enable_stacked: true
1116
+ * });
1117
+ *
1118
+ * // Streaming
1119
+ * const stream = await rainfall.chatCompletions({
1120
+ * subscriber_id: 'my-subscriber',
1121
+ * messages: [{ role: 'user', content: 'Tell me a story' }],
1122
+ * stream: true
1123
+ * });
1124
+ * ```
1125
+ */
1126
+ chatCompletions(params: {
1127
+ subscriber_id: string;
1128
+ messages: Array<{
1129
+ role: string;
1130
+ content: string;
1131
+ name?: string;
1132
+ }>;
1133
+ model?: string;
1134
+ stream?: boolean;
1135
+ temperature?: number;
1136
+ max_tokens?: number;
1137
+ tools?: unknown[];
1138
+ tool_choice?: string | {
1139
+ type: string;
1140
+ function?: {
1141
+ name: string;
1142
+ };
1143
+ };
1144
+ conversation_id?: string;
1145
+ agent_name?: string;
1146
+ incognito?: boolean;
1147
+ tool_priority?: 'local' | 'rainfall' | 'serverside' | 'stacked';
1148
+ enable_stacked?: boolean;
1149
+ }): Promise<unknown>;
1150
+ /**
1151
+ * List available models (OpenAI-compatible format)
1152
+ *
1153
+ * @example
1154
+ * ```typescript
1155
+ * const models = await rainfall.listModels();
1156
+ * console.log(models); // [{ id: 'llama-3.3-70b-versatile', ... }]
1157
+ * ```
1158
+ */
1159
+ listModels(subscriberId?: string): Promise<Array<{
1160
+ id: string;
1161
+ [key: string]: unknown;
1162
+ }>>;
1163
+ }
1164
+
1165
+ export { AI as A, Data as D, Integrations as I, Memory as M, type ParamSchema as P, type RainfallConfig as R, type ToolSchema as T, Utils as U, type ValidationIssue as V, 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, type ToolParamsSchema as m, type ValidationResult as n, clearSchemaCache as o, fetchToolSchema as p, formatValidationErrors as q, validateParams as v };