@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,372 @@
1
+ import { R as Rainfall } from './sdk-CN1ezZrI.js';
2
+
3
+ /**
4
+ * Rainfall Networked Executor - Distributed job execution via Rainfall API
5
+ *
6
+ * This service enables multi-computer networked executions without direct Redis access.
7
+ * All communication goes through the authenticated Rainfall API.
8
+ */
9
+
10
+ interface NodeCapabilities {
11
+ /** Can execute local commands/shell */
12
+ localExec?: boolean;
13
+ /** Can watch files for changes */
14
+ fileWatch?: boolean;
15
+ /** Can listen to passive events (webhooks, etc.) */
16
+ passiveListen?: boolean;
17
+ /** Can execute browser automation */
18
+ browser?: boolean;
19
+ /** Custom capability flags */
20
+ custom?: string[];
21
+ }
22
+ interface EdgeNodeRegistration {
23
+ edgeNodeId: string;
24
+ hostname: string;
25
+ capabilities: string[];
26
+ wsPort?: number;
27
+ httpPort?: number;
28
+ registeredAt: string;
29
+ }
30
+ interface QueuedJob {
31
+ jobId: string;
32
+ toolId: string;
33
+ params: Record<string, unknown>;
34
+ status: 'queued' | 'running' | 'completed' | 'failed';
35
+ executionMode: 'local-only' | 'distributed' | 'any';
36
+ requesterEdgeNodeId?: string;
37
+ executorEdgeNodeId?: string;
38
+ createdAt: string;
39
+ startedAt?: string;
40
+ completedAt?: string;
41
+ result?: unknown;
42
+ error?: string;
43
+ }
44
+ interface NetworkedExecutorOptions {
45
+ /** WebSocket port for receiving push jobs */
46
+ wsPort?: number;
47
+ /** HTTP port for health checks */
48
+ httpPort?: number;
49
+ /** Edge node capabilities */
50
+ capabilities?: NodeCapabilities;
51
+ /** Hostname identifier */
52
+ hostname?: string;
53
+ }
54
+ declare class RainfallNetworkedExecutor {
55
+ private rainfall;
56
+ private options;
57
+ private edgeNodeId?;
58
+ private jobCallbacks;
59
+ private resultPollingInterval?;
60
+ constructor(rainfall: Rainfall, options?: NetworkedExecutorOptions);
61
+ /**
62
+ * Register this edge node with the Rainfall backend
63
+ */
64
+ registerEdgeNode(): Promise<string>;
65
+ /**
66
+ * Unregister this edge node on shutdown
67
+ */
68
+ unregisterEdgeNode(): Promise<void>;
69
+ /**
70
+ * Queue a tool execution for distributed processing
71
+ * Non-blocking - returns immediately with a job ID
72
+ */
73
+ queueToolExecution(toolId: string, params: Record<string, unknown>, options?: {
74
+ executionMode?: 'local-only' | 'distributed' | 'any';
75
+ callback?: (result: unknown, error?: string) => void;
76
+ }): Promise<string>;
77
+ /**
78
+ * Get status of a queued job
79
+ */
80
+ getJobStatus(jobId: string): Promise<QueuedJob | null>;
81
+ /**
82
+ * Subscribe to job results via polling (WebSocket fallback)
83
+ * In the future, this will use WebSocket push from ApresMoi
84
+ */
85
+ subscribeToResults(callback: (jobId: string, result: unknown, error?: string) => void): Promise<void>;
86
+ private onResultReceived?;
87
+ /**
88
+ * Start polling for job results (fallback until WebSocket push is ready)
89
+ */
90
+ private startResultPolling;
91
+ /**
92
+ * Claim a job for execution on this edge node
93
+ */
94
+ claimJob(): Promise<QueuedJob | null>;
95
+ /**
96
+ * Submit job result after execution
97
+ */
98
+ submitJobResult(jobId: string, result: unknown, error?: string): Promise<void>;
99
+ /**
100
+ * Get this edge node's ID
101
+ */
102
+ getEdgeNodeId(): string | undefined;
103
+ /**
104
+ * Build capabilities list from options
105
+ */
106
+ private buildCapabilitiesList;
107
+ }
108
+
109
+ /**
110
+ * Rainfall Daemon Context - Persistent memory and session state
111
+ *
112
+ * Provides:
113
+ * - Persistent memory storage (local + cloud sync)
114
+ * - Session context for ongoing conversations/workflows
115
+ * - Tool execution history
116
+ * - Local state management
117
+ */
118
+
119
+ interface MemoryEntry {
120
+ id: string;
121
+ content: string;
122
+ keywords: string[];
123
+ timestamp: string;
124
+ source?: string;
125
+ metadata?: Record<string, unknown>;
126
+ }
127
+ interface SessionContext {
128
+ id: string;
129
+ startedAt: string;
130
+ lastActivity: string;
131
+ variables: Record<string, unknown>;
132
+ messageHistory: Array<{
133
+ role: 'user' | 'assistant' | 'system' | 'tool';
134
+ content: string;
135
+ timestamp: string;
136
+ }>;
137
+ }
138
+ interface ToolExecutionRecord {
139
+ id: string;
140
+ toolId: string;
141
+ params: Record<string, unknown>;
142
+ result: unknown;
143
+ error?: string;
144
+ timestamp: string;
145
+ duration: number;
146
+ edgeNodeId?: string;
147
+ }
148
+ interface ContextOptions {
149
+ /** Maximum number of memories to cache locally */
150
+ maxLocalMemories?: number;
151
+ /** Maximum message history per session */
152
+ maxMessageHistory?: number;
153
+ /** Maximum execution history to keep */
154
+ maxExecutionHistory?: number;
155
+ /** Session TTL in milliseconds */
156
+ sessionTtl?: number;
157
+ }
158
+ declare class RainfallDaemonContext {
159
+ private rainfall;
160
+ private options;
161
+ private localMemories;
162
+ private sessions;
163
+ private executionHistory;
164
+ private currentSessionId?;
165
+ constructor(rainfall: Rainfall, options?: ContextOptions);
166
+ /**
167
+ * Initialize the context - load recent memories from cloud
168
+ */
169
+ initialize(): Promise<void>;
170
+ /**
171
+ * Create or get a session
172
+ */
173
+ getSession(sessionId?: string): SessionContext;
174
+ /**
175
+ * Get the current active session
176
+ */
177
+ getCurrentSession(): SessionContext | undefined;
178
+ /**
179
+ * Set the current active session
180
+ */
181
+ setCurrentSession(sessionId: string): void;
182
+ /**
183
+ * Add a message to the current session history
184
+ */
185
+ addMessage(role: 'user' | 'assistant' | 'system' | 'tool', content: string): void;
186
+ /**
187
+ * Store a memory (local + cloud sync)
188
+ */
189
+ storeMemory(content: string, options?: {
190
+ keywords?: string[];
191
+ source?: string;
192
+ metadata?: Record<string, unknown>;
193
+ }): Promise<string>;
194
+ /**
195
+ * Recall memories by query
196
+ */
197
+ recallMemories(query: string, topK?: number): Promise<MemoryEntry[]>;
198
+ /**
199
+ * Set a session variable
200
+ */
201
+ setVariable(key: string, value: unknown): void;
202
+ /**
203
+ * Get a session variable
204
+ */
205
+ getVariable<T = unknown>(key: string): T | undefined;
206
+ /**
207
+ * Record a tool execution
208
+ */
209
+ recordExecution(toolId: string, params: Record<string, unknown>, result: unknown, options?: {
210
+ error?: string;
211
+ duration: number;
212
+ edgeNodeId?: string;
213
+ }): void;
214
+ /**
215
+ * Get recent execution history
216
+ */
217
+ getExecutionHistory(limit?: number): ToolExecutionRecord[];
218
+ /**
219
+ * Get execution statistics
220
+ */
221
+ getExecutionStats(): {
222
+ total: number;
223
+ successful: number;
224
+ failed: number;
225
+ averageDuration: number;
226
+ byTool: Record<string, number>;
227
+ };
228
+ /**
229
+ * Clear old sessions based on TTL
230
+ */
231
+ cleanupSessions(): void;
232
+ /**
233
+ * Get context summary for debugging
234
+ */
235
+ getStatus(): {
236
+ memoriesCached: number;
237
+ activeSessions: number;
238
+ currentSession?: string;
239
+ executionHistorySize: number;
240
+ };
241
+ private trimLocalMemories;
242
+ }
243
+
244
+ /**
245
+ * Rainfall Daemon Passive Listeners - File watchers, cron triggers, etc.
246
+ *
247
+ * Provides:
248
+ * - File system watchers for triggering workflows
249
+ * - Cron-style scheduled triggers
250
+ * - Webhook listeners (future)
251
+ * - Event bus for inter-node communication
252
+ */
253
+
254
+ interface FileWatcherConfig {
255
+ id: string;
256
+ name: string;
257
+ watchPath: string;
258
+ pattern?: string;
259
+ events: ('create' | 'modify' | 'delete')[];
260
+ workflow: {
261
+ toolId: string;
262
+ params: Record<string, unknown>;
263
+ }[];
264
+ options?: {
265
+ recursive?: boolean;
266
+ ignoreInitial?: boolean;
267
+ debounceMs?: number;
268
+ };
269
+ }
270
+ interface CronTriggerConfig {
271
+ id: string;
272
+ name: string;
273
+ cron: string;
274
+ timezone?: string;
275
+ workflow: {
276
+ toolId: string;
277
+ params: Record<string, unknown>;
278
+ }[];
279
+ }
280
+ interface ListenerEvent {
281
+ id: string;
282
+ type: 'file' | 'cron' | 'webhook' | 'manual';
283
+ source: string;
284
+ timestamp: string;
285
+ data: Record<string, unknown>;
286
+ }
287
+ interface ListenerRegistry {
288
+ fileWatchers: FileWatcherConfig[];
289
+ cronTriggers: CronTriggerConfig[];
290
+ }
291
+ declare class RainfallListenerRegistry {
292
+ private rainfall;
293
+ private context;
294
+ private executor;
295
+ private watchers;
296
+ private cronIntervals;
297
+ private eventHistory;
298
+ private maxEventHistory;
299
+ constructor(rainfall: Rainfall, context: RainfallDaemonContext, executor: RainfallNetworkedExecutor);
300
+ /**
301
+ * Register a file watcher
302
+ * Note: Actual file watching requires fs.watch or chokidar
303
+ * This is the registry - actual watching is done by the daemon
304
+ */
305
+ registerFileWatcher(config: FileWatcherConfig): Promise<void>;
306
+ /**
307
+ * Unregister a file watcher
308
+ */
309
+ unregisterFileWatcher(id: string): Promise<void>;
310
+ /**
311
+ * Register a cron trigger
312
+ */
313
+ registerCronTrigger(config: CronTriggerConfig): Promise<void>;
314
+ /**
315
+ * Unregister a cron trigger
316
+ */
317
+ unregisterCronTrigger(id: string): void;
318
+ /**
319
+ * Handle a file event
320
+ */
321
+ handleFileEvent(watcherId: string, eventType: 'create' | 'modify' | 'delete', filePath: string): Promise<void>;
322
+ /**
323
+ * Handle a cron tick
324
+ */
325
+ private handleCronTick;
326
+ /**
327
+ * Trigger a manual event (for testing or programmatic triggers)
328
+ */
329
+ triggerManual(name: string, data?: Record<string, unknown>): Promise<void>;
330
+ /**
331
+ * Get recent events
332
+ */
333
+ getRecentEvents(limit?: number): ListenerEvent[];
334
+ /**
335
+ * Get active listeners status
336
+ */
337
+ getStatus(): {
338
+ fileWatchers: number;
339
+ cronTriggers: number;
340
+ recentEvents: number;
341
+ };
342
+ /**
343
+ * Stop all listeners
344
+ */
345
+ stopAll(): Promise<void>;
346
+ private recordEvent;
347
+ /**
348
+ * Simple cron parser - converts basic cron expressions to milliseconds
349
+ * Supports: @hourly, @daily, @weekly, and simple intervals like every N minutes
350
+ */
351
+ private parseCronToMs;
352
+ }
353
+ /**
354
+ * Create a file watcher workflow helper
355
+ */
356
+ declare function createFileWatcherWorkflow(name: string, watchPath: string, options: {
357
+ pattern?: string;
358
+ events?: ('create' | 'modify' | 'delete')[];
359
+ workflow: {
360
+ toolId: string;
361
+ params: Record<string, unknown>;
362
+ }[];
363
+ }): FileWatcherConfig;
364
+ /**
365
+ * Create a cron trigger workflow helper
366
+ */
367
+ declare function createCronWorkflow(name: string, cron: string, workflow: {
368
+ toolId: string;
369
+ params: Record<string, unknown>;
370
+ }[]): CronTriggerConfig;
371
+
372
+ export { type ContextOptions as C, type EdgeNodeRegistration as E, type FileWatcherConfig as F, type ListenerEvent as L, type MemoryEntry as M, type NetworkedExecutorOptions as N, type QueuedJob as Q, RainfallDaemonContext as R, type SessionContext as S, type ToolExecutionRecord as T, type CronTriggerConfig as a, type ListenerRegistry as b, type NodeCapabilities as c, RainfallListenerRegistry as d, RainfallNetworkedExecutor as e, createCronWorkflow as f, createFileWatcherWorkflow as g };