@inetafrica/open-claudia 1.6.0 → 1.7.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/Dockerfile CHANGED
@@ -29,5 +29,10 @@ VOLUME /data
29
29
 
30
30
  EXPOSE 8080
31
31
 
32
+ # Entrypoint auto-configures from env vars on first run
33
+ COPY docker-entrypoint.sh /usr/local/bin/
34
+ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
35
+ ENTRYPOINT ["docker-entrypoint.sh"]
36
+
32
37
  # Start with web UI enabled
33
38
  CMD ["node", "bin/cli.js", "web"]
package/bin/cli.js CHANGED
@@ -8,6 +8,16 @@ const args = process.argv.slice(2);
8
8
  const command = args[0] || "help";
9
9
 
10
10
  const botDir = path.join(__dirname, "..");
11
+ const configDir = require(path.join(botDir, "config-dir"));
12
+
13
+ function getBotFile() {
14
+ const modeFile = path.join(configDir, ".bot-mode");
15
+ try {
16
+ const mode = fs.readFileSync(modeFile, "utf-8").trim();
17
+ if (mode === "agent") return "bot-agent.js";
18
+ } catch (e) {}
19
+ return "bot.js";
20
+ }
11
21
 
12
22
  function findBotProcesses() {
13
23
  try {
@@ -25,7 +35,7 @@ function findBotProcesses() {
25
35
  }
26
36
  return pids;
27
37
  } else {
28
- const out = execSync('ps -eo pid,command | grep "bot.js" | grep "open-claudia" | grep -v grep', { encoding: "utf-8" });
38
+ const out = execSync('ps -eo pid,command | grep "bot\\(-agent\\)\\?\\.js" | grep "open-claudia" | grep -v grep', { encoding: "utf-8" });
29
39
  return out.trim().split("\n").map((l) => l.trim().split(/\s+/)[0]).filter(Boolean);
30
40
  }
31
41
  } catch (e) {
@@ -38,27 +48,31 @@ switch (command) {
38
48
  require(path.join(botDir, "setup.js"));
39
49
  break;
40
50
 
41
- case "start":
42
- console.log("Starting Open Claudia...");
51
+ case "start": {
52
+ const botFile = getBotFile();
53
+ console.log(`Starting Open Claudia (${botFile === "bot-agent.js" ? "agent" : "direct"} mode)...`);
43
54
  // Start web UI alongside bot if WEB_UI=true or --web flag
44
55
  if (process.env.WEB_UI === "true" || args.includes("--web")) {
45
56
  const { startWebServer } = require(path.join(botDir, "web.js"));
46
57
  startWebServer();
47
58
  }
48
- require(path.join(botDir, "bot.js"));
59
+ require(path.join(botDir, botFile));
49
60
  break;
61
+ }
50
62
 
51
- case "web":
63
+ case "web": {
52
64
  // Web UI only (for initial setup or config management)
53
65
  const { startWebServer: startWeb, isConfigured } = require(path.join(botDir, "web.js"));
54
66
  startWeb();
55
67
  if (isConfigured()) {
56
- console.log("Bot config found. Starting bot too...");
57
- require(path.join(botDir, "bot.js"));
68
+ const botFile = getBotFile();
69
+ console.log(`Bot config found. Starting bot (${botFile === "bot-agent.js" ? "agent" : "direct"} mode)...`);
70
+ require(path.join(botDir, botFile));
58
71
  } else {
59
72
  console.log("No config found. Complete setup in the web UI.");
60
73
  }
61
74
  break;
75
+ }
62
76
 
63
77
  case "auth":
64
78
  // Pass through to setup.js auth mode