@rainfall-devkit/sdk 0.1.7 → 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 (40) 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-RA3HDYF4.mjs +778 -0
  5. package/dist/chunk-V5QWJVLC.mjs +662 -0
  6. package/dist/chunk-VDPKDC3R.mjs +869 -0
  7. package/dist/chunk-WOITG5TG.mjs +84 -0
  8. package/dist/cli/index.js +2756 -607
  9. package/dist/cli/index.mjs +404 -46
  10. package/dist/config-DDTQQBN7.mjs +14 -0
  11. package/dist/config-ZKNHII2A.mjs +8 -0
  12. package/dist/daemon/index.d.mts +136 -0
  13. package/dist/daemon/index.d.ts +136 -0
  14. package/dist/daemon/index.js +2473 -0
  15. package/dist/daemon/index.mjs +836 -0
  16. package/dist/errors-BMPseAnM.d.mts +47 -0
  17. package/dist/errors-BMPseAnM.d.ts +47 -0
  18. package/dist/errors-CZdRoYyw.d.ts +332 -0
  19. package/dist/errors-Chjq1Mev.d.mts +332 -0
  20. package/dist/index.d.mts +3 -1
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.js +762 -5
  23. package/dist/index.mjs +14 -2
  24. package/dist/listeners-BbYIaNCs.d.mts +372 -0
  25. package/dist/listeners-CP2A9J_2.d.ts +372 -0
  26. package/dist/listeners-CTRSofnm.d.mts +372 -0
  27. package/dist/listeners-CYI-YwIF.d.mts +372 -0
  28. package/dist/listeners-QJeEtLbV.d.ts +372 -0
  29. package/dist/listeners-hp0Ib2Ox.d.ts +372 -0
  30. package/dist/mcp.d.mts +3 -2
  31. package/dist/mcp.d.ts +3 -2
  32. package/dist/mcp.js +95 -3
  33. package/dist/mcp.mjs +1 -1
  34. package/dist/sdk-CJ9g5lFo.d.mts +772 -0
  35. package/dist/sdk-CJ9g5lFo.d.ts +772 -0
  36. package/dist/sdk-DD1OeGRJ.d.mts +871 -0
  37. package/dist/sdk-DD1OeGRJ.d.ts +871 -0
  38. package/dist/types-GnRAfH-h.d.mts +489 -0
  39. package/dist/types-GnRAfH-h.d.ts +489 -0
  40. package/package.json +14 -5
@@ -0,0 +1,84 @@
1
+ // src/cli/config.ts
2
+ import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
3
+ import { join } from "path";
4
+ import { homedir } from "os";
5
+ var CONFIG_DIR = join(homedir(), ".rainfall");
6
+ var CONFIG_FILE = join(CONFIG_DIR, "config.json");
7
+ function loadConfig() {
8
+ let config = {};
9
+ if (existsSync(CONFIG_FILE)) {
10
+ try {
11
+ config = JSON.parse(readFileSync(CONFIG_FILE, "utf8"));
12
+ } catch {
13
+ config = {};
14
+ }
15
+ }
16
+ if (process.env.RAINFALL_API_KEY) {
17
+ config.apiKey = process.env.RAINFALL_API_KEY;
18
+ }
19
+ if (process.env.RAINFALL_BASE_URL) {
20
+ config.baseUrl = process.env.RAINFALL_BASE_URL;
21
+ }
22
+ if (!config.llm) {
23
+ config.llm = { provider: "rainfall" };
24
+ }
25
+ if (process.env.OPENAI_API_KEY) {
26
+ config.llm.provider = config.llm.provider || "openai";
27
+ config.llm.apiKey = process.env.OPENAI_API_KEY;
28
+ }
29
+ if (process.env.ANTHROPIC_API_KEY) {
30
+ config.llm.provider = "anthropic";
31
+ config.llm.apiKey = process.env.ANTHROPIC_API_KEY;
32
+ }
33
+ if (process.env.OLLAMA_HOST || process.env.OLLAMA_URL) {
34
+ config.llm.provider = "ollama";
35
+ config.llm.baseUrl = process.env.OLLAMA_HOST || process.env.OLLAMA_URL;
36
+ }
37
+ if (process.env.LLM_MODEL) {
38
+ config.llm.model = process.env.LLM_MODEL;
39
+ }
40
+ return config;
41
+ }
42
+ function saveConfig(config) {
43
+ if (!existsSync(CONFIG_DIR)) {
44
+ mkdirSync(CONFIG_DIR, { recursive: true });
45
+ }
46
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
47
+ }
48
+ function getLLMConfig(config) {
49
+ const defaults = {
50
+ provider: "rainfall",
51
+ apiKey: config.apiKey || "",
52
+ baseUrl: config.baseUrl || "https://api.rainfall.com",
53
+ model: "llama-3.3-70b-versatile",
54
+ options: {}
55
+ };
56
+ return { ...defaults, ...config.llm };
57
+ }
58
+ function isLocalProvider(config) {
59
+ return config.llm?.provider === "ollama" || config.llm?.provider === "local";
60
+ }
61
+ function getProviderBaseUrl(config) {
62
+ const provider = config.llm?.provider || "rainfall";
63
+ switch (provider) {
64
+ case "openai":
65
+ return config.llm?.baseUrl || "https://api.openai.com/v1";
66
+ case "anthropic":
67
+ return config.llm?.baseUrl || "https://api.anthropic.com/v1";
68
+ case "ollama":
69
+ return config.llm?.baseUrl || "http://localhost:11434/v1";
70
+ case "local":
71
+ return config.llm?.baseUrl || "http://localhost:1234/v1";
72
+ case "rainfall":
73
+ default:
74
+ return config.baseUrl || "https://api.rainfall.com";
75
+ }
76
+ }
77
+
78
+ export {
79
+ loadConfig,
80
+ saveConfig,
81
+ getLLMConfig,
82
+ isLocalProvider,
83
+ getProviderBaseUrl
84
+ };