@rainfall-devkit/sdk 0.1.8 → 0.2.0

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 (39) 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-V5QWJVLC.mjs +662 -0
  5. package/dist/chunk-VDPKDC3R.mjs +869 -0
  6. package/dist/chunk-WOITG5TG.mjs +84 -0
  7. package/dist/cli/index.js +2799 -713
  8. package/dist/cli/index.mjs +354 -36
  9. package/dist/config-DDTQQBN7.mjs +14 -0
  10. package/dist/config-ZKNHII2A.mjs +8 -0
  11. package/dist/daemon/index.d.mts +136 -0
  12. package/dist/daemon/index.d.ts +136 -0
  13. package/dist/daemon/index.js +2473 -0
  14. package/dist/daemon/index.mjs +836 -0
  15. package/dist/errors-BMPseAnM.d.mts +47 -0
  16. package/dist/errors-BMPseAnM.d.ts +47 -0
  17. package/dist/errors-CZdRoYyw.d.ts +332 -0
  18. package/dist/errors-Chjq1Mev.d.mts +332 -0
  19. package/dist/index.d.mts +3 -1
  20. package/dist/index.d.ts +3 -1
  21. package/dist/index.js +759 -3
  22. package/dist/index.mjs +14 -2
  23. package/dist/listeners-BbYIaNCs.d.mts +372 -0
  24. package/dist/listeners-CP2A9J_2.d.ts +372 -0
  25. package/dist/listeners-CTRSofnm.d.mts +372 -0
  26. package/dist/listeners-CYI-YwIF.d.mts +372 -0
  27. package/dist/listeners-QJeEtLbV.d.ts +372 -0
  28. package/dist/listeners-hp0Ib2Ox.d.ts +372 -0
  29. package/dist/mcp.d.mts +3 -2
  30. package/dist/mcp.d.ts +3 -2
  31. package/dist/mcp.js +92 -1
  32. package/dist/mcp.mjs +1 -1
  33. package/dist/sdk-CJ9g5lFo.d.mts +772 -0
  34. package/dist/sdk-CJ9g5lFo.d.ts +772 -0
  35. package/dist/sdk-DD1OeGRJ.d.mts +871 -0
  36. package/dist/sdk-DD1OeGRJ.d.ts +871 -0
  37. package/dist/types-GnRAfH-h.d.mts +489 -0
  38. package/dist/types-GnRAfH-h.d.ts +489 -0
  39. package/package.json +14 -5
@@ -0,0 +1,136 @@
1
+ import { e as RainfallConfig } from '../sdk-DD1OeGRJ.js';
2
+ import { N as NetworkedExecutorOptions, C as ContextOptions, e as RainfallNetworkedExecutor, R as RainfallDaemonContext, d as RainfallListenerRegistry } from '../listeners-QJeEtLbV.js';
3
+
4
+ /**
5
+ * Rainfall Daemon - Local websocket server + OpenAI-compatible proxy
6
+ *
7
+ * Provides:
8
+ * - WebSocket server for MCP clients (Claude, Cursor, etc.)
9
+ * - OpenAI-compatible /v1/chat/completions endpoint
10
+ * - Hot-loaded tools from Rainfall SDK
11
+ * - Networked execution for distributed workflows
12
+ * - Persistent context and memory
13
+ * - Passive listeners (file watchers, cron triggers)
14
+ */
15
+
16
+ interface DaemonConfig {
17
+ port?: number;
18
+ openaiPort?: number;
19
+ rainfallConfig?: RainfallConfig;
20
+ /** Enable debug logging */
21
+ debug?: boolean;
22
+ /** Networked executor options */
23
+ networkedOptions?: NetworkedExecutorOptions;
24
+ /** Context/memory options */
25
+ contextOptions?: ContextOptions;
26
+ }
27
+ interface DaemonStatus {
28
+ running: boolean;
29
+ port?: number;
30
+ openaiPort?: number;
31
+ toolsLoaded: number;
32
+ clientsConnected: number;
33
+ edgeNodeId?: string;
34
+ context: {
35
+ memoriesCached: number;
36
+ activeSessions: number;
37
+ currentSession?: string;
38
+ executionHistorySize: number;
39
+ };
40
+ listeners: {
41
+ fileWatchers: number;
42
+ cronTriggers: number;
43
+ recentEvents: number;
44
+ };
45
+ }
46
+ declare class RainfallDaemon {
47
+ private wss?;
48
+ private openaiApp;
49
+ private rainfall?;
50
+ private port;
51
+ private openaiPort;
52
+ private rainfallConfig?;
53
+ private tools;
54
+ private toolSchemas;
55
+ private clients;
56
+ private debug;
57
+ private networkedExecutor?;
58
+ private context?;
59
+ private listeners?;
60
+ constructor(config?: DaemonConfig);
61
+ start(): Promise<void>;
62
+ stop(): Promise<void>;
63
+ /**
64
+ * Get the networked executor for distributed job management
65
+ */
66
+ getNetworkedExecutor(): RainfallNetworkedExecutor | undefined;
67
+ /**
68
+ * Get the context for memory/session management
69
+ */
70
+ getContext(): RainfallDaemonContext | undefined;
71
+ /**
72
+ * Get the listener registry for passive triggers
73
+ */
74
+ getListenerRegistry(): RainfallListenerRegistry | undefined;
75
+ private initializeRainfall;
76
+ private loadTools;
77
+ private getToolSchema;
78
+ private startWebSocketServer;
79
+ private handleMCPMessage;
80
+ private getMCPTools;
81
+ private executeTool;
82
+ private startOpenAIProxy;
83
+ /**
84
+ * Build a map of local Rainfall tools for quick lookup
85
+ * Maps OpenAI-style underscore names to Rainfall tool IDs
86
+ */
87
+ private buildLocalToolMap;
88
+ /**
89
+ * Find a local Rainfall tool by name (OpenAI underscore format or original)
90
+ */
91
+ private findLocalTool;
92
+ /**
93
+ * Execute a local Rainfall tool
94
+ */
95
+ private executeLocalTool;
96
+ /**
97
+ * Parse XML-style tool calls from model output
98
+ * Handles formats like: <function=name><parameter=key>value</parameter></function>
99
+ */
100
+ private parseXMLToolCalls;
101
+ /**
102
+ * Call the LLM via Rainfall backend, LM Studio, RunPod, or other providers
103
+ *
104
+ * Provider priority:
105
+ * 1. Config file (llm.provider, llm.baseUrl)
106
+ * 2. Environment variables (OPENAI_API_KEY, OLLAMA_HOST, etc.)
107
+ * 3. Default to Rainfall (credits-based)
108
+ */
109
+ private callLLM;
110
+ /**
111
+ * Call external LLM provider (OpenAI, Anthropic) via their OpenAI-compatible APIs
112
+ */
113
+ private callExternalLLM;
114
+ /**
115
+ * Call a local LLM (LM Studio, Ollama, etc.)
116
+ */
117
+ private callLocalLLM;
118
+ /**
119
+ * Stream a response to the client (converts non-streaming to SSE format)
120
+ */
121
+ private streamResponse;
122
+ /**
123
+ * Update context with conversation history
124
+ */
125
+ private updateContext;
126
+ private getOpenAITools;
127
+ private buildResponseContent;
128
+ getStatus(): DaemonStatus;
129
+ private log;
130
+ }
131
+ declare function startDaemon(config?: DaemonConfig): Promise<RainfallDaemon>;
132
+ declare function stopDaemon(): Promise<void>;
133
+ declare function getDaemonStatus(): DaemonStatus | null;
134
+ declare function getDaemonInstance(): RainfallDaemon | null;
135
+
136
+ export { type DaemonConfig, type DaemonStatus, RainfallDaemon, getDaemonInstance, getDaemonStatus, startDaemon, stopDaemon };