@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.
- package/README.md +51 -0
- package/dist/chunk-7MRE4ZVI.mjs +662 -0
- package/dist/chunk-AQFC7YAX.mjs +27 -0
- package/dist/chunk-EI7SJH5K.mjs +85 -0
- package/dist/chunk-NTTAVKRT.mjs +89 -0
- package/dist/chunk-RVKW5KBT.mjs +269 -0
- package/dist/chunk-V5QWJVLC.mjs +662 -0
- package/dist/chunk-VDPKDC3R.mjs +869 -0
- package/dist/chunk-WOITG5TG.mjs +84 -0
- package/dist/chunk-XAHJQRBJ.mjs +269 -0
- package/dist/chunk-XEQ6U3JQ.mjs +269 -0
- package/dist/cli/index.js +3797 -632
- package/dist/cli/index.mjs +453 -36
- package/dist/config-7UT7GYSN.mjs +16 -0
- package/dist/config-DDTQQBN7.mjs +14 -0
- package/dist/config-MD45VGWD.mjs +14 -0
- package/dist/config-ZKNHII2A.mjs +8 -0
- package/dist/daemon/index.d.mts +168 -0
- package/dist/daemon/index.d.ts +168 -0
- package/dist/daemon/index.js +3182 -0
- package/dist/daemon/index.mjs +1548 -0
- package/dist/errors-BMPseAnM.d.mts +47 -0
- package/dist/errors-BMPseAnM.d.ts +47 -0
- package/dist/errors-CZdRoYyw.d.ts +332 -0
- package/dist/errors-Chjq1Mev.d.mts +332 -0
- package/dist/index.d.mts +249 -2
- package/dist/index.d.ts +249 -2
- package/dist/index.js +1247 -3
- package/dist/index.mjs +227 -2
- package/dist/listeners-B5Vy9Ao5.d.ts +372 -0
- package/dist/listeners-BbYIaNCs.d.mts +372 -0
- package/dist/listeners-CP2A9J_2.d.ts +372 -0
- package/dist/listeners-CTRSofnm.d.mts +372 -0
- package/dist/listeners-CYI-YwIF.d.mts +372 -0
- package/dist/listeners-DRwITBW_.d.mts +372 -0
- package/dist/listeners-DrMrvFT5.d.ts +372 -0
- package/dist/listeners-MNAnpZj-.d.mts +372 -0
- package/dist/listeners-PZI7iT85.d.ts +372 -0
- package/dist/listeners-QJeEtLbV.d.ts +372 -0
- package/dist/listeners-hp0Ib2Ox.d.ts +372 -0
- package/dist/listeners-jLwetUnx.d.mts +372 -0
- package/dist/mcp.d.mts +7 -2
- package/dist/mcp.d.ts +7 -2
- package/dist/mcp.js +92 -1
- package/dist/mcp.mjs +1 -1
- package/dist/sdk-4OvXPr8E.d.mts +1054 -0
- package/dist/sdk-4OvXPr8E.d.ts +1054 -0
- package/dist/sdk-CJ9g5lFo.d.mts +772 -0
- package/dist/sdk-CJ9g5lFo.d.ts +772 -0
- package/dist/sdk-CN1ezZrI.d.mts +1054 -0
- package/dist/sdk-CN1ezZrI.d.ts +1054 -0
- package/dist/sdk-DD1OeGRJ.d.mts +871 -0
- package/dist/sdk-DD1OeGRJ.d.ts +871 -0
- package/dist/sdk-Xw0BjsLd.d.mts +1054 -0
- package/dist/sdk-Xw0BjsLd.d.ts +1054 -0
- package/dist/types-GnRAfH-h.d.mts +489 -0
- package/dist/types-GnRAfH-h.d.ts +489 -0
- package/package.json +17 -5
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { R as RainfallConfig, g as MCPClientConfig, h as MCPProxyHub } from '../sdk-4OvXPr8E.mjs';
|
|
2
|
+
export { i as MCPClientInfo, j as MCPToolInfo, k as MCPTransportType } from '../sdk-4OvXPr8E.mjs';
|
|
3
|
+
import { N as NetworkedExecutorOptions, C as ContextOptions, R as RainfallNetworkedExecutor, a as RainfallDaemonContext, b as RainfallListenerRegistry } from '../listeners-MNAnpZj-.mjs';
|
|
4
|
+
import 'ws';
|
|
5
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
7
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rainfall Daemon - Local websocket server + OpenAI-compatible proxy
|
|
11
|
+
*
|
|
12
|
+
* Provides:
|
|
13
|
+
* - WebSocket server for MCP clients (Claude, Cursor, etc.)
|
|
14
|
+
* - OpenAI-compatible /v1/chat/completions endpoint
|
|
15
|
+
* - Hot-loaded tools from Rainfall SDK
|
|
16
|
+
* - Networked execution for distributed workflows
|
|
17
|
+
* - Persistent context and memory
|
|
18
|
+
* - Passive listeners (file watchers, cron triggers)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface DaemonConfig {
|
|
22
|
+
port?: number;
|
|
23
|
+
openaiPort?: number;
|
|
24
|
+
rainfallConfig?: RainfallConfig;
|
|
25
|
+
/** Enable debug logging */
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
/** Networked executor options */
|
|
28
|
+
networkedOptions?: NetworkedExecutorOptions;
|
|
29
|
+
/** Context/memory options */
|
|
30
|
+
contextOptions?: ContextOptions;
|
|
31
|
+
/** Enable MCP proxy hub (default: true) */
|
|
32
|
+
enableMcpProxy?: boolean;
|
|
33
|
+
/** Namespace prefix for MCP tools (default: true) */
|
|
34
|
+
mcpNamespacePrefix?: boolean;
|
|
35
|
+
/** Pre-configured MCP clients to connect on startup */
|
|
36
|
+
mcpClients?: MCPClientConfig[];
|
|
37
|
+
}
|
|
38
|
+
interface DaemonStatus {
|
|
39
|
+
running: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
openaiPort?: number;
|
|
42
|
+
toolsLoaded: number;
|
|
43
|
+
mcpClients?: number;
|
|
44
|
+
mcpTools?: number;
|
|
45
|
+
clientsConnected: number;
|
|
46
|
+
edgeNodeId?: string;
|
|
47
|
+
context: {
|
|
48
|
+
memoriesCached: number;
|
|
49
|
+
activeSessions: number;
|
|
50
|
+
currentSession?: string;
|
|
51
|
+
executionHistorySize: number;
|
|
52
|
+
};
|
|
53
|
+
listeners: {
|
|
54
|
+
fileWatchers: number;
|
|
55
|
+
cronTriggers: number;
|
|
56
|
+
recentEvents: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
declare class RainfallDaemon {
|
|
60
|
+
private wss?;
|
|
61
|
+
private openaiApp;
|
|
62
|
+
private rainfall?;
|
|
63
|
+
private port;
|
|
64
|
+
private openaiPort;
|
|
65
|
+
private rainfallConfig?;
|
|
66
|
+
private tools;
|
|
67
|
+
private toolSchemas;
|
|
68
|
+
private clients;
|
|
69
|
+
private debug;
|
|
70
|
+
private networkedExecutor?;
|
|
71
|
+
private context?;
|
|
72
|
+
private listeners?;
|
|
73
|
+
private mcpProxy?;
|
|
74
|
+
private enableMcpProxy;
|
|
75
|
+
private mcpNamespacePrefix;
|
|
76
|
+
constructor(config?: DaemonConfig);
|
|
77
|
+
start(): Promise<void>;
|
|
78
|
+
stop(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the networked executor for distributed job management
|
|
81
|
+
*/
|
|
82
|
+
getNetworkedExecutor(): RainfallNetworkedExecutor | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get the context for memory/session management
|
|
85
|
+
*/
|
|
86
|
+
getContext(): RainfallDaemonContext | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Get the listener registry for passive triggers
|
|
89
|
+
*/
|
|
90
|
+
getListenerRegistry(): RainfallListenerRegistry | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Get the MCP Proxy Hub for managing external MCP clients
|
|
93
|
+
*/
|
|
94
|
+
getMCPProxy(): MCPProxyHub | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Connect an MCP client dynamically
|
|
97
|
+
*/
|
|
98
|
+
connectMCPClient(config: MCPClientConfig): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Disconnect an MCP client
|
|
101
|
+
*/
|
|
102
|
+
disconnectMCPClient(name: string): Promise<void>;
|
|
103
|
+
private initializeRainfall;
|
|
104
|
+
private loadTools;
|
|
105
|
+
private getToolSchema;
|
|
106
|
+
private startWebSocketServer;
|
|
107
|
+
private handleMCPMessage;
|
|
108
|
+
private getMCPTools;
|
|
109
|
+
private executeTool;
|
|
110
|
+
/**
|
|
111
|
+
* Execute a tool, trying MCP proxy first, then falling back to Rainfall tools
|
|
112
|
+
*/
|
|
113
|
+
private executeToolWithMCP;
|
|
114
|
+
private startOpenAIProxy;
|
|
115
|
+
/**
|
|
116
|
+
* Build a map of local Rainfall tools for quick lookup
|
|
117
|
+
* Maps OpenAI-style underscore names to Rainfall tool IDs
|
|
118
|
+
*/
|
|
119
|
+
private buildLocalToolMap;
|
|
120
|
+
/**
|
|
121
|
+
* Find a local Rainfall tool by name (OpenAI underscore format or original)
|
|
122
|
+
*/
|
|
123
|
+
private findLocalTool;
|
|
124
|
+
/**
|
|
125
|
+
* Execute a local Rainfall tool
|
|
126
|
+
*/
|
|
127
|
+
private executeLocalTool;
|
|
128
|
+
/**
|
|
129
|
+
* Parse XML-style tool calls from model output
|
|
130
|
+
* Handles formats like: <function=name><parameter=key>value</parameter></function>
|
|
131
|
+
*/
|
|
132
|
+
private parseXMLToolCalls;
|
|
133
|
+
/**
|
|
134
|
+
* Call the LLM via Rainfall backend, LM Studio, RunPod, or other providers
|
|
135
|
+
*
|
|
136
|
+
* Provider priority:
|
|
137
|
+
* 1. Config file (llm.provider, llm.baseUrl)
|
|
138
|
+
* 2. Environment variables (OPENAI_API_KEY, OLLAMA_HOST, etc.)
|
|
139
|
+
* 3. Default to Rainfall (credits-based)
|
|
140
|
+
*/
|
|
141
|
+
private callLLM;
|
|
142
|
+
/**
|
|
143
|
+
* Call external LLM provider (OpenAI, Anthropic) via their OpenAI-compatible APIs
|
|
144
|
+
*/
|
|
145
|
+
private callExternalLLM;
|
|
146
|
+
/**
|
|
147
|
+
* Call a local LLM (LM Studio, Ollama, etc.)
|
|
148
|
+
*/
|
|
149
|
+
private callLocalLLM;
|
|
150
|
+
/**
|
|
151
|
+
* Stream a response to the client (converts non-streaming to SSE format)
|
|
152
|
+
*/
|
|
153
|
+
private streamResponse;
|
|
154
|
+
/**
|
|
155
|
+
* Update context with conversation history
|
|
156
|
+
*/
|
|
157
|
+
private updateContext;
|
|
158
|
+
private getOpenAITools;
|
|
159
|
+
private buildResponseContent;
|
|
160
|
+
getStatus(): DaemonStatus;
|
|
161
|
+
private log;
|
|
162
|
+
}
|
|
163
|
+
declare function startDaemon(config?: DaemonConfig): Promise<RainfallDaemon>;
|
|
164
|
+
declare function stopDaemon(): Promise<void>;
|
|
165
|
+
declare function getDaemonStatus(): DaemonStatus | null;
|
|
166
|
+
declare function getDaemonInstance(): RainfallDaemon | null;
|
|
167
|
+
|
|
168
|
+
export { type DaemonConfig, type DaemonStatus, MCPClientConfig, MCPProxyHub, RainfallDaemon, getDaemonInstance, getDaemonStatus, startDaemon, stopDaemon };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { R as RainfallConfig, g as MCPClientConfig, h as MCPProxyHub } from '../sdk-4OvXPr8E.js';
|
|
2
|
+
export { i as MCPClientInfo, j as MCPToolInfo, k as MCPTransportType } from '../sdk-4OvXPr8E.js';
|
|
3
|
+
import { N as NetworkedExecutorOptions, C as ContextOptions, R as RainfallNetworkedExecutor, a as RainfallDaemonContext, b as RainfallListenerRegistry } from '../listeners-B5Vy9Ao5.js';
|
|
4
|
+
import 'ws';
|
|
5
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
7
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rainfall Daemon - Local websocket server + OpenAI-compatible proxy
|
|
11
|
+
*
|
|
12
|
+
* Provides:
|
|
13
|
+
* - WebSocket server for MCP clients (Claude, Cursor, etc.)
|
|
14
|
+
* - OpenAI-compatible /v1/chat/completions endpoint
|
|
15
|
+
* - Hot-loaded tools from Rainfall SDK
|
|
16
|
+
* - Networked execution for distributed workflows
|
|
17
|
+
* - Persistent context and memory
|
|
18
|
+
* - Passive listeners (file watchers, cron triggers)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface DaemonConfig {
|
|
22
|
+
port?: number;
|
|
23
|
+
openaiPort?: number;
|
|
24
|
+
rainfallConfig?: RainfallConfig;
|
|
25
|
+
/** Enable debug logging */
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
/** Networked executor options */
|
|
28
|
+
networkedOptions?: NetworkedExecutorOptions;
|
|
29
|
+
/** Context/memory options */
|
|
30
|
+
contextOptions?: ContextOptions;
|
|
31
|
+
/** Enable MCP proxy hub (default: true) */
|
|
32
|
+
enableMcpProxy?: boolean;
|
|
33
|
+
/** Namespace prefix for MCP tools (default: true) */
|
|
34
|
+
mcpNamespacePrefix?: boolean;
|
|
35
|
+
/** Pre-configured MCP clients to connect on startup */
|
|
36
|
+
mcpClients?: MCPClientConfig[];
|
|
37
|
+
}
|
|
38
|
+
interface DaemonStatus {
|
|
39
|
+
running: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
openaiPort?: number;
|
|
42
|
+
toolsLoaded: number;
|
|
43
|
+
mcpClients?: number;
|
|
44
|
+
mcpTools?: number;
|
|
45
|
+
clientsConnected: number;
|
|
46
|
+
edgeNodeId?: string;
|
|
47
|
+
context: {
|
|
48
|
+
memoriesCached: number;
|
|
49
|
+
activeSessions: number;
|
|
50
|
+
currentSession?: string;
|
|
51
|
+
executionHistorySize: number;
|
|
52
|
+
};
|
|
53
|
+
listeners: {
|
|
54
|
+
fileWatchers: number;
|
|
55
|
+
cronTriggers: number;
|
|
56
|
+
recentEvents: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
declare class RainfallDaemon {
|
|
60
|
+
private wss?;
|
|
61
|
+
private openaiApp;
|
|
62
|
+
private rainfall?;
|
|
63
|
+
private port;
|
|
64
|
+
private openaiPort;
|
|
65
|
+
private rainfallConfig?;
|
|
66
|
+
private tools;
|
|
67
|
+
private toolSchemas;
|
|
68
|
+
private clients;
|
|
69
|
+
private debug;
|
|
70
|
+
private networkedExecutor?;
|
|
71
|
+
private context?;
|
|
72
|
+
private listeners?;
|
|
73
|
+
private mcpProxy?;
|
|
74
|
+
private enableMcpProxy;
|
|
75
|
+
private mcpNamespacePrefix;
|
|
76
|
+
constructor(config?: DaemonConfig);
|
|
77
|
+
start(): Promise<void>;
|
|
78
|
+
stop(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the networked executor for distributed job management
|
|
81
|
+
*/
|
|
82
|
+
getNetworkedExecutor(): RainfallNetworkedExecutor | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get the context for memory/session management
|
|
85
|
+
*/
|
|
86
|
+
getContext(): RainfallDaemonContext | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Get the listener registry for passive triggers
|
|
89
|
+
*/
|
|
90
|
+
getListenerRegistry(): RainfallListenerRegistry | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Get the MCP Proxy Hub for managing external MCP clients
|
|
93
|
+
*/
|
|
94
|
+
getMCPProxy(): MCPProxyHub | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Connect an MCP client dynamically
|
|
97
|
+
*/
|
|
98
|
+
connectMCPClient(config: MCPClientConfig): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Disconnect an MCP client
|
|
101
|
+
*/
|
|
102
|
+
disconnectMCPClient(name: string): Promise<void>;
|
|
103
|
+
private initializeRainfall;
|
|
104
|
+
private loadTools;
|
|
105
|
+
private getToolSchema;
|
|
106
|
+
private startWebSocketServer;
|
|
107
|
+
private handleMCPMessage;
|
|
108
|
+
private getMCPTools;
|
|
109
|
+
private executeTool;
|
|
110
|
+
/**
|
|
111
|
+
* Execute a tool, trying MCP proxy first, then falling back to Rainfall tools
|
|
112
|
+
*/
|
|
113
|
+
private executeToolWithMCP;
|
|
114
|
+
private startOpenAIProxy;
|
|
115
|
+
/**
|
|
116
|
+
* Build a map of local Rainfall tools for quick lookup
|
|
117
|
+
* Maps OpenAI-style underscore names to Rainfall tool IDs
|
|
118
|
+
*/
|
|
119
|
+
private buildLocalToolMap;
|
|
120
|
+
/**
|
|
121
|
+
* Find a local Rainfall tool by name (OpenAI underscore format or original)
|
|
122
|
+
*/
|
|
123
|
+
private findLocalTool;
|
|
124
|
+
/**
|
|
125
|
+
* Execute a local Rainfall tool
|
|
126
|
+
*/
|
|
127
|
+
private executeLocalTool;
|
|
128
|
+
/**
|
|
129
|
+
* Parse XML-style tool calls from model output
|
|
130
|
+
* Handles formats like: <function=name><parameter=key>value</parameter></function>
|
|
131
|
+
*/
|
|
132
|
+
private parseXMLToolCalls;
|
|
133
|
+
/**
|
|
134
|
+
* Call the LLM via Rainfall backend, LM Studio, RunPod, or other providers
|
|
135
|
+
*
|
|
136
|
+
* Provider priority:
|
|
137
|
+
* 1. Config file (llm.provider, llm.baseUrl)
|
|
138
|
+
* 2. Environment variables (OPENAI_API_KEY, OLLAMA_HOST, etc.)
|
|
139
|
+
* 3. Default to Rainfall (credits-based)
|
|
140
|
+
*/
|
|
141
|
+
private callLLM;
|
|
142
|
+
/**
|
|
143
|
+
* Call external LLM provider (OpenAI, Anthropic) via their OpenAI-compatible APIs
|
|
144
|
+
*/
|
|
145
|
+
private callExternalLLM;
|
|
146
|
+
/**
|
|
147
|
+
* Call a local LLM (LM Studio, Ollama, etc.)
|
|
148
|
+
*/
|
|
149
|
+
private callLocalLLM;
|
|
150
|
+
/**
|
|
151
|
+
* Stream a response to the client (converts non-streaming to SSE format)
|
|
152
|
+
*/
|
|
153
|
+
private streamResponse;
|
|
154
|
+
/**
|
|
155
|
+
* Update context with conversation history
|
|
156
|
+
*/
|
|
157
|
+
private updateContext;
|
|
158
|
+
private getOpenAITools;
|
|
159
|
+
private buildResponseContent;
|
|
160
|
+
getStatus(): DaemonStatus;
|
|
161
|
+
private log;
|
|
162
|
+
}
|
|
163
|
+
declare function startDaemon(config?: DaemonConfig): Promise<RainfallDaemon>;
|
|
164
|
+
declare function stopDaemon(): Promise<void>;
|
|
165
|
+
declare function getDaemonStatus(): DaemonStatus | null;
|
|
166
|
+
declare function getDaemonInstance(): RainfallDaemon | null;
|
|
167
|
+
|
|
168
|
+
export { type DaemonConfig, type DaemonStatus, MCPClientConfig, MCPProxyHub, RainfallDaemon, getDaemonInstance, getDaemonStatus, startDaemon, stopDaemon };
|