@clagentic/console 1.4.1 → 1.5.0-beta.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 (52) hide show
  1. package/README.md +47 -21
  2. package/bin/cli.js +163 -60
  3. package/deploy/clagentic-console.service +2 -0
  4. package/lib/agents-favorites.js +3 -1
  5. package/lib/agents.js +75 -5
  6. package/lib/browser-mcp-server.js +5 -5
  7. package/lib/clone-validate.js +44 -0
  8. package/lib/config.js +75 -0
  9. package/lib/daemon.js +116 -8
  10. package/lib/dm.js +12 -1
  11. package/lib/ipc.js +12 -0
  12. package/lib/lite-detect.js +92 -0
  13. package/lib/os-users.js +8 -8
  14. package/lib/project-connection.js +7 -1
  15. package/lib/project-external-trigger.js +65 -6
  16. package/lib/project-loop.js +44 -3
  17. package/lib/project-sessions.js +95 -37
  18. package/lib/project.js +6 -1
  19. package/lib/public/app.js +6 -3
  20. package/lib/public/css/at-agents.css +68 -0
  21. package/lib/public/index.html +60 -0
  22. package/lib/public/modules/app-messages.js +38 -4
  23. package/lib/public/modules/at-agents.js +248 -0
  24. package/lib/public/modules/escape-html.js +19 -0
  25. package/lib/public/modules/filebrowser.js +12 -9
  26. package/lib/public/modules/input.js +26 -4
  27. package/lib/public/modules/pending-navigate.js +28 -0
  28. package/lib/public/modules/playbook.js +1 -1
  29. package/lib/public/modules/project-settings.js +75 -0
  30. package/lib/public/modules/project-switcher.js +1 -1
  31. package/lib/public/modules/server-settings.js +33 -0
  32. package/lib/public/modules/sticky-notes-fmt.js +52 -0
  33. package/lib/public/modules/sticky-notes.js +23 -5
  34. package/lib/public/modules/theme.js +1 -1
  35. package/lib/public/modules/tool-palette.js +1 -1
  36. package/lib/public/modules/utils.js +1 -3
  37. package/lib/public/style.css +1 -0
  38. package/lib/push.js +13 -2
  39. package/lib/scheduler.js +26 -2
  40. package/lib/sdk-bridge.js +7 -4
  41. package/lib/server-dm.js +16 -0
  42. package/lib/server-settings.js +42 -0
  43. package/lib/server-skills.js +10 -7
  44. package/lib/server.js +14 -3
  45. package/lib/sessions.js +4 -0
  46. package/lib/ws-schema.js +11 -1
  47. package/lib/yoke/adapters/claude-worker.js +2 -2
  48. package/lib/yoke/adapters/claude.js +47 -10
  49. package/lib/yoke/adapters/codex.js +14 -3
  50. package/lib/yoke/mcp-bridge-server.js +7 -7
  51. package/package.json +1 -1
  52. package/lib/relay-agent-claims.js +0 -480
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="media/logo/console-lockup-256.png" alt="clagentic:console" width="260" />
2
+ <img src="media/logo/console-lockup-256.png" alt="Clagentic: Console" width="260" />
3
3
  </p>
4
4
 
5
5
  <h4 align="center">AI tooling. Built for builders.</h4>
@@ -13,9 +13,7 @@
13
13
  <a href="https://ko-fi.com/clagentic"><img src="https://img.shields.io/badge/Ko--fi-FF5E5B?style=flat&logo=ko-fi&logoColor=white&label=support" alt="Support on Ko-fi" /></a>
14
14
  </p>
15
15
 
16
- A self-hosted browser console for Claude Code and ChatGPT Codex. Part of the [clagentic](https://clagentic.ai) suite. Run AI sessions from any browser or phone — tool approvals, model selection, context management, session history — without leaving your own machine.
17
-
18
- No extras bolted on. No opinionated workflows. The floor is solid; you build what you need on top.
16
+ A self-hosted control plane for your AI runtimes. Clagentic: Console runs as a daemon on your machine and serves a full browser and mobile interface to Claude Code and ChatGPT Codex. Every project, every session, every tool approval — reachable from any device, all data staying on disk.
19
17
 
20
18
  ## Install
21
19
 
@@ -23,13 +21,13 @@ No extras bolted on. No opinionated workflows. The floor is solid; you build wha
23
21
  npm install -g @clagentic/console
24
22
  ```
25
23
 
26
- Then run from anywhere:
24
+ Then start the daemon:
27
25
 
28
26
  ```bash
29
27
  clagentic-console
30
28
  ```
31
29
 
32
- Or try it without installing:
30
+ Or try without installing:
33
31
 
34
32
  ```bash
35
33
  npx @clagentic/console
@@ -39,17 +37,33 @@ npx @clagentic/console
39
37
 
40
38
  ## What it does
41
39
 
42
- - **Browser access to your AI runtimes.** The goal is full parity with the CLI for both Claude Code and Codex — tool approvals, model selection, context management, session history. Most things work; see the FAQ for current gaps.
43
- - **Named agent sessions (Claude Code).** Talk directly to any agent defined in your Claude Code config. Agents get their own sessions, context, and history. This feature is currently Claude Code only — see FAQ for details and what's planned for Codex.
44
- - **Multi-project dashboard.** Every repo on your machine in one sidebar. Jump between projects, run sessions in parallel, see live status at a glance.
45
- - **Mobile PWA + push notifications.** Installable on iOS and Android. Your phone buzzes when Claude needs approval or finishes a long task — tap to respond from anywhere.
46
- - **Loop automation.** Write a `PROMPT.md`, hit go. Clagentic:Console iterates: run, evaluate, retry until done or capped. Schedule with standard cron.
47
- - **Vendor flexibility.** Supports Claude Code (Claude Agent SDK) and ChatGPT Codex (codex app-server protocol). Switch per session.
40
+ - **Named agent sessions.** Type `@` in the session input to launch any agent defined in `.claude/agents/` or `~/.claude/agents/` into its own session — with its own conversation history, context window, and state. Pick agents by name, switch mid-conversation.
41
+
42
+ - **Context injection.** Pin running terminals, live browser tabs, and sticky notes as active context sources. Their content flows into every message automatically: terminal output as a delta since your last message, browser tabs as full snapshots. No manual copy-paste. No extra prompting.
43
+
44
+ - **Loop automation.** Write a `PROMPT.md`, start a loop. Clagentic: Console runs the prompt, evaluates the result, and retries until done or capped. Schedule loops with standard cron syntax to run unattended.
45
+
46
+ - **External triggers.** Drop a JSON file into `~/.clagentic/external-triggers/` to spawn a new AI session or inject a message into an existing one. Use this to wire Claude into scripts, CI pipelines, or other AI processes — no API, no polling, just a file drop.
47
+
48
+ - **Cross-vendor instruction injection.** YOKE (the vendor adapter layer) scans `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `COPILOT.md`, and `.github/copilot-instructions.md` and cross-injects whichever ones the active vendor doesn't read natively. Switch from Claude to Codex in a session — your project instructions still reach the model.
49
+
50
+ - **Multi-project dashboard.** Every repo registered with the daemon in one sidebar. Jump between projects, run sessions in parallel, see live status at a glance.
51
+
52
+ - **Mobile PWA + push notifications.** Installable on iOS and Android. Approve tool calls from your phone. Push fires on approval requests, errors, and task completion.
53
+
54
+ - **Multi-user with OS isolation.** On Linux, opt in: each user maps to a real system account, file ACLs via `setfacl`, processes spawn under the correct UID/GID.
55
+
56
+ - **Vendor flexibility.** Claude Code (Claude Agent SDK) and ChatGPT Codex (codex app-server protocol). Switch per session. Sessions remember their vendor.
57
+
58
+ - **MCP servers.** Built-in ask-user and browser servers. User-configured MCPs via `~/.clagentic/mcp.json`. Works in both Claude and Codex sessions.
59
+
48
60
  - **Your data, your machine.** Sessions are JSONL, settings are JSON, knowledge is Markdown. No cloud relay, no proprietary database.
49
61
 
62
+ - **Clagentic: Lite (optional).** If [Clagentic: Lite](https://clagentic.ai/tools) is installed, project settings surface per-project enrollment controls and system settings add a global auto-enroll toggle. Console detects it passively — nothing changes if it isn't present.
63
+
50
64
  ## Getting Started
51
65
 
52
- On first run you'll be asked for a port and whether you're running solo or multi-user. Open the URL from any device on your network.
66
+ On first run you'll be asked for a port and prompted to create your admin account. Open the URL from any device on your network.
53
67
 
54
68
  For remote access, use a tunnel — Tailscale, Cloudflare Tunnel, or your existing VPN.
55
69
 
@@ -71,7 +85,7 @@ Also available as `clagentic-console` if installed globally.
71
85
 
72
86
  ## Architecture
73
87
 
74
- Clagentic:Console is a self-hosted daemon. It drives Claude Code via the Claude Agent SDK and Codex via the `codex app-server` JSON-RPC protocol through a vendor-agnostic adapter layer (YOKE), and serves a multi-user web workspace over HTTP/WS. Sessions and settings live as plain JSONL/JSON/Markdown on disk.
88
+ Clagentic: Console is a self-hosted daemon. It drives Claude Code via the Claude Agent SDK and Codex via the `codex app-server` JSON-RPC protocol through a vendor-agnostic adapter layer (YOKE), and serves a multi-user web workspace over HTTP/WS. Sessions and settings live as plain JSONL/JSON/Markdown on disk.
75
89
 
76
90
  ```mermaid
77
91
  graph LR
@@ -81,7 +95,7 @@ graph LR
81
95
  Phone["Phone PWA + Push"]
82
96
  end
83
97
 
84
- subgraph Daemon["Clagentic:Console Daemon (your machine)"]
98
+ subgraph Daemon["Clagentic: Console Daemon (your machine)"]
85
99
  Auth["Auth + RBAC"]
86
100
  Server["HTTP / WS Server"]
87
101
  Project["Project Context"]
@@ -113,15 +127,24 @@ For architecture details, sequence diagrams, and key design decisions, see [docs
113
127
  ## FAQ
114
128
 
115
129
  **"Is this a Claude Code wrapper?"**
116
- No. Clagentic:Console drives Claude Code through the Claude Agent SDK and Codex through the Codex app-server protocol. It adds multi-session orchestration, named agent sessions, scheduled agents, multi-user support, built-in MCP servers, and a full browser UI on top.
130
+ No. Clagentic: Console drives Claude Code through the Claude Agent SDK and Codex through the Codex app-server protocol. It adds multi-session orchestration, named agent sessions, scheduled agents, multi-user support, built-in MCP servers, context injection, external triggers, and a full browser UI on top.
117
131
 
118
132
  **"What are named agents?"**
119
- Agents defined in your Claude Code config (`.claude/agents/`) become first-class sessions. You talk to them directly — their own conversation history, context window, and session state.
133
+ Agents defined in your Claude Code config (`.claude/agents/` or `~/.claude/agents/`) become first-class sessions. Type `@` in the session input to see every installed agent and launch one directly — its own conversation history, context window, and session state.
120
134
 
121
- Named agents are **currently Claude Code only.** The Codex adapter has no equivalent API for per-session agent identity injection — the Claude Agent SDK exposes this directly, Codex does not. When you're in a Codex session, the Agent Chat entry point is hidden automatically. Partial Codex parity (system-prompt prepend) is planned; until then, agents only apply when the session vendor is Claude Code.
135
+ Named agents are **currently Claude Code only.** The Codex adapter has no equivalent API for per-session agent identity injection. When you're in a Codex session, the agent entry point is hidden. Partial Codex parity (system-prompt prepend) is planned.
136
+
137
+ **"How does context injection work?"**
138
+ Open the Context panel in the session input area. Pin a running terminal, a browser tab (requires the Clagentic: Console Chrome extension), or a sticky note. From that point on, every message you send automatically includes the latest content from those sources — terminal output as a delta since the last message, browser tabs as a full page snapshot. The injection happens before your message reaches the model; you don't need to mention the sources in your prompt.
139
+
140
+ **"What's the external trigger system?"**
141
+ Drop a JSON file into `~/.clagentic/external-triggers/`. The daemon picks it up within seconds. A v1 trigger spawns a new session with an `initialPrompt`. A v2 trigger can either spawn a session or inject a message into an existing session by `sessionId`. The file is archived to `processed/` on success. Unprocessed files survive daemon restarts. Use this to wire Claude into scripts, CI pipelines, cron jobs, or other AI processes.
142
+
143
+ **"What instruction files does it read?"**
144
+ YOKE scans the project directory for `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `COPILOT.md`, and `.github/copilot-instructions.md`. Each vendor reads some of these natively — Claude reads `CLAUDE.md`, Codex reads `AGENTS.md`. Files the active vendor doesn't read natively are merged and injected as additional context, so your project instructions reach the model regardless of which vendor is running.
122
145
 
123
146
  **"Is feature parity between Claude Code and Codex complete?"**
124
- Not yet. The goal is full parity, but there are gaps. Named agents (above) are the main one. Claude Code has been the primary development target; Codex support covers sessions, tool approvals, model selection, MCP servers, loop, and most UI surfaces. Features that depend on Claude Agent SDK internals (agent identity, extended thinking, some beta flags) have no Codex equivalent today.
147
+ Not yet. Named agents are the main gap — the Claude Agent SDK exposes agent identity injection directly; Codex does not. Claude Code has been the primary development target. Codex support covers sessions, tool approvals, model selection, MCP servers, loop, and most UI surfaces. Features that depend on Claude Agent SDK internals have no Codex equivalent today.
125
148
 
126
149
  **"Can I run Claude Code and Codex in the same workspace?"**
127
150
  Yes. Pick a vendor when you open a session. Switch per session — sessions remember their vendor.
@@ -130,7 +153,7 @@ Yes. Pick a vendor when you open a session. Switch per session — sessions reme
130
153
  Only as model API calls — the same as using the CLI directly. Sessions, settings, and knowledge all stay on disk.
131
154
 
132
155
  **"Does my existing CLAUDE.md / AGENTS.md work?"**
133
- Yes. Native instruction files are loaded per vendor and merged automatically.
156
+ Yes. Native instruction files are loaded per vendor and merged automatically. Non-native files are cross-injected by YOKE.
134
157
 
135
158
  **"Can I continue a CLI session in the browser?"**
136
159
  Yes. CLI sessions appear in the sidebar and can be picked up in the CLI.
@@ -144,9 +167,12 @@ Yes. User-configured MCPs from `~/.clagentic/mcp.json` plus built-in ask-user an
144
167
  **"Multi-user support?"**
145
168
  Yes. On Linux, opt in to OS-level isolation: each user maps to a real Linux account, file ACLs via `setfacl`, processes spawn under the correct UID/GID.
146
169
 
170
+ **"Does it integrate with Clagentic: Lite?"**
171
+ Yes, optionally. [Clagentic: Lite](https://clagentic.ai/tools) adds agentic gates, session memory, and audit trails to any repo. If Lite is installed (`~/.clagentic/lite/`), Console detects it automatically and shows an enrollment panel in each project's settings. Enable auto-enroll in system settings to wire up every project on add. Lite is never required — Console works normally without it.
172
+
147
173
  ## Support
148
174
 
149
- If clagentic:console is useful to you: [ko-fi.com/clagentic](https://ko-fi.com/clagentic)
175
+ If Clagentic: Console is useful to you: [ko-fi.com/clagentic](https://ko-fi.com/clagentic)
150
176
 
151
177
  ## Credits
152
178
 
package/bin/cli.js CHANGED
@@ -4,8 +4,8 @@
4
4
  var _nodeMajor = parseInt(process.versions.node.split(".")[0], 10);
5
5
  if (_nodeMajor < 20) {
6
6
  console.error("");
7
- console.error("\x1b[31m[clay] Node.js 20+ is required (current: " + process.version + ")\x1b[0m");
8
- console.error("[clay] The Claude Agent SDK 0.2.40+ requires Node 20 for Symbol.dispose support.");
7
+ console.error("\x1b[31m[clagentic-console] Node.js 20+ is required (current: " + process.version + ")\x1b[0m");
8
+ console.error("[clagentic-console] The Claude Agent SDK 0.2.40+ requires Node 20 for Symbol.dispose support.");
9
9
  console.error("");
10
10
  console.error(" Upgrade Node: nvm install 22 && nvm use 22");
11
11
  console.error("");
@@ -20,7 +20,7 @@ var qrcode = require("qrcode-terminal");
20
20
  var net = require("net");
21
21
 
22
22
  // Detect dev mode — dev and prod use separate daemon files so they can run simultaneously
23
- var _isDev = (process.argv[1] && (path.basename(process.argv[1]) === "clay-dev" || path.basename(process.argv[1]) === "clagentic-dev")) || process.argv.includes("--dev");
23
+ var _isDev = (process.argv[1] && path.basename(process.argv[1]) === "clagentic-dev") || process.argv.includes("--dev");
24
24
  if (_isDev) {
25
25
  process.env.CLAGENTIC_DEV = "1";
26
26
  }
@@ -31,7 +31,7 @@ if (_isDev || process.argv.includes("--debug")) {
31
31
  }
32
32
 
33
33
  var crypto = require("crypto");
34
- var { loadConfig, saveConfig, configPath, socketPath, logPath, ensureConfigDir, isDaemonAlive, isDaemonAliveAsync, generateSlug, clearStaleConfig, loadClayrc, saveClayrc, readCrashInfo, REAL_HOME } = require("../lib/config");
34
+ var { loadConfig, saveConfig, configPath, socketPath, oldSocketPath, logPath, ensureConfigDir, isDaemonAlive, isDaemonAliveAsync, checkOldDaemon, generateSlug, clearStaleConfig, loadClayrc, saveClayrc, readCrashInfo, REAL_HOME } = require("../lib/config");
35
35
  var { sendIPCCommand } = require("../lib/ipc");
36
36
  var { generateAuthToken } = require("../lib/server");
37
37
  var { enableMultiUser, disableMultiUser, hasAdmin, isMultiUser, getSetupCode } = require("../lib/users");
@@ -58,6 +58,7 @@ var autoYes = false;
58
58
  var cliPin = null;
59
59
  var shutdownMode = false;
60
60
  var restartMode = false;
61
+ var noRestart = false;
61
62
  var addPath = null;
62
63
  var removePath = null;
63
64
  var listMode = false;
@@ -102,6 +103,8 @@ for (var i = 0; i < args.length; i++) {
102
103
  shutdownMode = true;
103
104
  } else if (args[i] === "--restart") {
104
105
  restartMode = true;
106
+ } else if (args[i] === "--no-restart") {
107
+ noRestart = true;
105
108
  } else if (args[i] === "--add") {
106
109
  addPath = args[i + 1] || ".";
107
110
  i++;
@@ -120,10 +123,10 @@ for (var i = 0; i < args.length; i++) {
120
123
  } else if (args[i] === "--os-users") {
121
124
  osUsersMode = true;
122
125
  } else if (args[i] === "-h" || args[i] === "--help") {
123
- console.log("Usage: clagentic [-p|--port <port>] [--host <address>] [--no-https] [--no-update] [--debug] [-y|--yes] [--pin <pin>] [--shutdown] [--restart]");
124
- console.log(" clagentic --add <path> Add a project to the running daemon");
125
- console.log(" clagentic --remove <path> Remove a project from the running daemon");
126
- console.log(" clagentic --list List registered projects");
126
+ console.log("Usage: clagentic-console [-p|--port <port>] [--host <address>] [--no-https] [--no-update] [--debug] [-y|--yes] [--pin <pin>] [--shutdown] [--restart] [--no-restart]");
127
+ console.log(" clagentic-console --add <path> Add a project to the running daemon");
128
+ console.log(" clagentic-console --remove <path> Remove a project from the running daemon");
129
+ console.log(" clagentic-console --list List registered projects");
127
130
  console.log("");
128
131
  console.log("Options:");
129
132
  console.log(" -p, --port <port> Port to listen on (default: 2633)");
@@ -137,6 +140,7 @@ for (var i = 0; i < args.length; i++) {
137
140
  console.log(" --pin <pin> Set 6-digit PIN (use with --yes)");
138
141
  console.log(" --shutdown Shut down the running relay daemon");
139
142
  console.log(" --restart Restart the running relay daemon");
143
+ console.log(" --no-restart Do not auto-restart on crash (useful for debugging crash state)");
140
144
  console.log(" --add <path> Add a project directory (use '.' for current)");
141
145
  console.log(" --remove <path> Remove a project directory");
142
146
  console.log(" --list List all registered projects");
@@ -159,16 +163,39 @@ if (_isDev) {
159
163
  if (shutdownMode) {
160
164
  var shutdownConfig = loadConfig();
161
165
  isDaemonAliveAsync(shutdownConfig).then(function (alive) {
162
- if (!alive) {
163
- console.error("No running daemon found.");
164
- process.exit(1);
166
+ if (alive) {
167
+ return sendIPCCommand(socketPath(), { cmd: "shutdown" }).then(function (resp) {
168
+ if (resp && resp.ok) {
169
+ console.log("Server stopped.");
170
+ clearStaleConfig();
171
+ process.exit(0);
172
+ } else {
173
+ var pid = shutdownConfig && shutdownConfig.pid;
174
+ console.error("Shutdown failed: daemon did not acknowledge the command.");
175
+ if (pid) console.error(" Daemon PID: " + pid + " (try: kill " + pid + ")");
176
+ console.error(" Or: systemctl restart clagentic-console");
177
+ process.exit(1);
178
+ }
179
+ });
165
180
  }
166
- sendIPCCommand(socketPath(), { cmd: "shutdown" }).then(function () {
167
- console.log("Server stopped.");
168
- clearStaleConfig();
169
- process.exit(0);
170
- }).catch(function (err) {
171
- console.error("Shutdown failed:", err.message);
181
+ // New socket not alive — check whether a pre-1.5 daemon is on the old path
182
+ return checkOldDaemon().then(function (old) {
183
+ if (old && old.alive) {
184
+ console.log("[migration] Sending shutdown to pre-1.5 daemon at " + old.sockPath);
185
+ return sendIPCCommand(old.sockPath, { cmd: "shutdown" }).then(function (resp) {
186
+ if (resp && resp.ok) {
187
+ console.log("Server stopped.");
188
+ process.exit(0);
189
+ } else {
190
+ var oldPid = shutdownConfig && shutdownConfig.pid;
191
+ console.error("Shutdown of pre-1.5 daemon failed: no acknowledgement from " + old.sockPath);
192
+ if (oldPid) console.error(" Daemon PID: " + oldPid + " (try: kill " + oldPid + ")");
193
+ console.error(" Or: systemctl restart clagentic-console");
194
+ process.exit(1);
195
+ }
196
+ });
197
+ }
198
+ console.error("No running daemon found.");
172
199
  process.exit(1);
173
200
  });
174
201
  });
@@ -179,15 +206,41 @@ if (shutdownMode) {
179
206
  if (restartMode) {
180
207
  var restartConfig = loadConfig();
181
208
  isDaemonAliveAsync(restartConfig).then(function (alive) {
182
- if (!alive) {
183
- console.error("No running daemon found.");
184
- process.exit(1);
209
+ if (alive) {
210
+ return sendIPCCommand(socketPath(), { cmd: "restart" }).then(function (resp) {
211
+ if (resp && resp.ok) {
212
+ console.log("Server restarted.");
213
+ process.exit(0);
214
+ } else {
215
+ var pid = restartConfig && restartConfig.pid;
216
+ console.error("Restart failed: daemon did not acknowledge the command.");
217
+ if (pid) console.error(" Daemon PID: " + pid + " (try: kill " + pid + " && clagentic-console)");
218
+ console.error(" Or: systemctl restart clagentic-console");
219
+ process.exit(1);
220
+ }
221
+ });
185
222
  }
186
- sendIPCCommand(socketPath(), { cmd: "restart" }).then(function () {
187
- console.log("Server restarted.");
188
- process.exit(0);
189
- }).catch(function (err) {
190
- console.error("Restart failed:", err.message);
223
+ // New socket not alive — check whether a pre-1.5 daemon is on the old path
224
+ return checkOldDaemon().then(function (old) {
225
+ if (old && old.alive) {
226
+ // Pre-1.5 daemon does not understand {cmd:"restart"} for the CLI restart
227
+ // flow (it would restart on the old socket path). Shut it down instead so
228
+ // the caller can re-run without a port conflict.
229
+ console.log("[migration] Pre-1.5 daemon found at " + old.sockPath + " — shutting it down so a fresh start can proceed.");
230
+ return sendIPCCommand(old.sockPath, { cmd: "shutdown" }).then(function (resp) {
231
+ if (resp && resp.ok) {
232
+ console.log("Pre-1.5 daemon stopped. Run clagentic-console to start the updated daemon.");
233
+ process.exit(0);
234
+ } else {
235
+ var oldPid = restartConfig && restartConfig.pid;
236
+ console.error("Shutdown of pre-1.5 daemon failed: no acknowledgement from " + old.sockPath);
237
+ if (oldPid) console.error(" Daemon PID: " + oldPid + " (try: kill " + oldPid + ")");
238
+ console.error(" Or: systemctl restart clagentic-console");
239
+ process.exit(1);
240
+ }
241
+ });
242
+ }
243
+ console.error("No running daemon found.");
191
244
  process.exit(1);
192
245
  });
193
246
  });
@@ -292,7 +345,7 @@ var a = {
292
345
  reset: "\x1b[0m",
293
346
  bold: "\x1b[1m",
294
347
  dim: "\x1b[2m",
295
- clay: isBasicTerm ? "\x1b[34m" : "\x1b[38;2;88;87;252m", // #5857FC Indigo — active interaction
348
+ indigo: isBasicTerm ? "\x1b[34m" : "\x1b[38;2;88;87;252m", // #5857FC Indigo — active interaction
296
349
  green: "\x1b[32m",
297
350
  yellow: "\x1b[33m",
298
351
  red: "\x1b[31m",
@@ -302,7 +355,7 @@ function gradient(text) {
302
355
  if (isBasicTerm) {
303
356
  return a.yellow + text + a.reset;
304
357
  }
305
- // Terracotta (#FE7150) → Warm brown (#D09558) — Clay earthy warmth
358
+ // Terracotta (#FE7150) → Warm brown (#D09558) gradient
306
359
  var r0 = 254, g0 = 113, b0 = 80;
307
360
  var r1 = 208, g1 = 149, b1 = 88;
308
361
  var out = "";
@@ -318,7 +371,7 @@ function gradient(text) {
318
371
  }
319
372
 
320
373
  var sym = {
321
- pointer: a.clay + "◆" + a.reset,
374
+ pointer: a.indigo + "◆" + a.reset,
322
375
  done: a.green + "◇" + a.reset,
323
376
  bar: a.dim + "│" + a.reset,
324
377
  end: a.dim + "└" + a.reset,
@@ -389,6 +442,19 @@ function onDaemonDied() {
389
442
  return;
390
443
  }
391
444
 
445
+ // --no-restart: leave the daemon dead so the developer can inspect crash state
446
+ if (noRestart) {
447
+ log("");
448
+ log(sym.warn + " " + a.yellow + "Server crashed. --no-restart is set — not restarting." + a.reset);
449
+ if (crashInfo.reason) {
450
+ log(a.dim + " " + crashInfo.reason.split("\n")[0] + a.reset);
451
+ }
452
+ log(a.dim + " Check logs: " + a.reset + logPath());
453
+ log("");
454
+ process.exit(1);
455
+ return;
456
+ }
457
+
392
458
  // Reset backoff counter if enough time has passed since last restart burst
393
459
  var now = Date.now();
394
460
  if (_restartBackoffStart && now - _restartBackoffStart > 60000) {
@@ -818,7 +884,7 @@ function promptPin(callback) {
818
884
  }
819
885
  } else if (/\d/.test(ch) && pin.length < 6) {
820
886
  pin += ch;
821
- process.stdout.write(a.clay + "●" + a.reset);
887
+ process.stdout.write(a.indigo + "●" + a.reset);
822
888
  }
823
889
  });
824
890
  }
@@ -1121,7 +1187,7 @@ function promptMultiSelect(title, items, callback) {
1121
1187
  function render() {
1122
1188
  var out = "";
1123
1189
  for (var i = 0; i < items.length; i++) {
1124
- var cursor = i === idx ? a.clay + ">" + a.reset : " ";
1190
+ var cursor = i === idx ? a.indigo + ">" + a.reset : " ";
1125
1191
  var check = selected[i]
1126
1192
  ? a.green + a.bold + "■" + a.reset
1127
1193
  : a.dim + "□" + a.reset;
@@ -1288,14 +1354,14 @@ function setup(callback) {
1288
1354
  console.clear();
1289
1355
  printLogo();
1290
1356
  log("");
1291
- log(sym.pointer + " " + a.bold + "Clay" + a.reset + a.dim + " · Unofficial, open-source project" + a.reset);
1357
+ log(sym.pointer + " " + a.bold + "Clagentic: Console" + a.reset + a.dim + " · Unofficial, open-source project" + a.reset);
1292
1358
  log(sym.bar);
1293
1359
  log(sym.bar + " " + a.yellow + sym.warn + " Disclaimer" + a.reset);
1294
1360
  log(sym.bar);
1295
1361
  log(sym.bar + " " + a.dim + "This is an independent project and is not affiliated with Anthropic." + a.reset);
1296
1362
  log(sym.bar + " " + a.dim + "Claude is a trademark of Anthropic." + a.reset);
1297
1363
  log(sym.bar);
1298
- log(sym.bar + " " + a.dim + "Clay is provided \"as is\" without warranty of any kind. Users are" + a.reset);
1364
+ log(sym.bar + " " + a.dim + "Clagentic: Console is provided \"as is\" without warranty of any kind. Users are" + a.reset);
1299
1365
  log(sym.bar + " " + a.dim + "responsible for complying with the terms of service of underlying AI" + a.reset);
1300
1366
  log(sym.bar + " " + a.dim + "providers (e.g., Anthropic, OpenAI) and all applicable terms of any" + a.reset);
1301
1367
  log(sym.bar + " " + a.dim + "third-party services." + a.reset);
@@ -1342,24 +1408,14 @@ function setup(callback) {
1342
1408
  }
1343
1409
  port = p;
1344
1410
  log(sym.bar);
1345
- askMode();
1411
+ // Single-user mode removed (lr-bd9f). All new installs are multi-user.
1412
+ // Existing single-user installs continue to work until the full removal
1413
+ // lands — see task lr-bd9f-redux.
1414
+ askOsUsers("multi");
1346
1415
  });
1347
1416
  });
1348
1417
  }
1349
1418
 
1350
- function askMode() {
1351
- promptSelect("How will you use Clay?", [
1352
- { label: "Just me (single user)", value: "single" },
1353
- { label: "Multiple users", value: "multi" },
1354
- ], function (mode) {
1355
- if (mode === "single") {
1356
- finishSetup(mode, false);
1357
- } else {
1358
- askOsUsers(mode);
1359
- }
1360
- });
1361
- }
1362
-
1363
1419
  function askOsUsers(mode) {
1364
1420
  // Only offer OS user isolation on Linux
1365
1421
  if (process.platform !== "linux") {
@@ -1378,7 +1434,7 @@ function setup(callback) {
1378
1434
  log(sym.bar);
1379
1435
  log(sym.bar + " " + a.yellow + sym.warn + " OS-Level User Isolation" + a.reset);
1380
1436
  log(sym.bar);
1381
- log(sym.bar + " " + a.dim + "This feature maps each Clay user to a Linux OS user account." + a.reset);
1437
+ log(sym.bar + " " + a.dim + "This feature maps each Clagentic: Console user to a Linux OS user account." + a.reset);
1382
1438
  log(sym.bar + " " + a.dim + "The daemon must run as root and will spawn processes (SDK workers," + a.reset);
1383
1439
  log(sym.bar + " " + a.dim + "terminals, file operations) as the mapped Linux user." + a.reset);
1384
1440
  log(sym.bar);
@@ -1387,7 +1443,7 @@ function setup(callback) {
1387
1443
  log(sym.bar + " " + a.dim + "- Terminals and file access follow Linux permissions" + a.reset);
1388
1444
  log(sym.bar + " " + a.dim + "- Linux user accounts are created automatically (clay-username)" + a.reset);
1389
1445
  log(sym.bar);
1390
- log(sym.bar + " " + a.dim + "Recommended: Run on a dedicated Clay server or cloud instance," + a.reset);
1446
+ log(sym.bar + " " + a.dim + "Recommended: Run on a dedicated Clagentic: Console server or cloud instance," + a.reset);
1391
1447
  log(sym.bar + " " + a.dim + "not on a personal computer or general-purpose server." + a.reset);
1392
1448
  log(sym.bar);
1393
1449
  promptSelect("Confirm", [
@@ -1458,11 +1514,34 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers) {
1458
1514
  }
1459
1515
  }
1460
1516
 
1517
+ // Migration shim: detect and shut down a pre-1.5 daemon holding the old socket
1518
+ // path. This prevents the port-in-use dead-end on upgrade. (lr-6ed3)
1519
+ if (process.platform !== "win32") {
1520
+ var oldCheck = await checkOldDaemon();
1521
+ if (oldCheck && oldCheck.alive) {
1522
+ log(sym.warn + " " + a.yellow + "Pre-1.5 daemon detected at " + oldCheck.sockPath + " — shutting it down..." + a.reset);
1523
+ await sendIPCCommand(oldCheck.sockPath, { cmd: "shutdown" });
1524
+ // Wait up to 5 s for the port to be released
1525
+ var migWaited = 0;
1526
+ while (migWaited < 5000) {
1527
+ await new Promise(function (resolve) { setTimeout(resolve, 300); });
1528
+ migWaited += 300;
1529
+ if (await isPortFree(port)) break;
1530
+ }
1531
+ log(sym.done + " " + a.green + "Pre-1.5 daemon stopped. Continuing startup..." + a.reset);
1532
+ } else if (oldCheck && !oldCheck.alive && fs.existsSync(oldCheck.sockPath)) {
1533
+ // Stale socket not yet cleaned up by ensureConfigDir (e.g. ensureConfigDir not
1534
+ // called yet on this path). Remove it now so nothing trips on it later.
1535
+ try { fs.unlinkSync(oldCheck.sockPath); } catch (e) {}
1536
+ }
1537
+ }
1538
+
1461
1539
  // Check port availability
1462
1540
  var portFree = await isPortFree(port);
1463
1541
  if (!portFree) {
1464
1542
  log(a.red + "Port " + port + " is already in use." + a.reset);
1465
- log(a.dim + "Is another Clay daemon running?" + a.reset);
1543
+ log(a.dim + "Another process is holding this port." + a.reset);
1544
+ log(a.dim + "If a pre-1.5 daemon is running, clagentic-console --shutdown will stop it." + a.reset);
1466
1545
  process.exit(1);
1467
1546
  return;
1468
1547
  }
@@ -1603,12 +1682,12 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers) {
1603
1682
  : protocol + "://" + ip + ":" + config.port;
1604
1683
  console.log(" " + sym.done + " Daemon started (PID " + config.pid + ")");
1605
1684
  console.log(" " + sym.done + " " + url);
1606
- if (config.mkcertDetected) console.log(" " + sym.warn + " Clay now ships with a builtin HTTPS certificate. To use it, pass --builtin-cert or uninstall mkcert.");
1685
+ if (config.mkcertDetected) console.log(" " + sym.warn + " Clagentic: Console now ships with a builtin HTTPS certificate. To use it, pass --builtin-cert or uninstall mkcert.");
1607
1686
  if (_pendingSetupCode) {
1608
1687
  console.log("");
1609
1688
  console.log(" " + sym.done + " " + a.green + "Multi-user mode enabled." + a.reset);
1610
1689
  console.log(" " + sym.bar + " Setup code: " + a.bold + _pendingSetupCode + a.reset);
1611
- console.log(" " + sym.bar + " Open Clay in your browser and enter this code to create the admin account.");
1690
+ console.log(" " + sym.bar + " Open Clagentic: Console in your browser and enter this code to create the admin account.");
1612
1691
  }
1613
1692
  console.log(" " + sym.done + " Headless mode — exiting CLI");
1614
1693
  process.exit(0);
@@ -1637,6 +1716,25 @@ async function devMode(mode, keepAwake, existingPinHash, wantOsUsers) {
1637
1716
  }
1638
1717
  }
1639
1718
 
1719
+ // Migration shim: detect and shut down a pre-1.5 daemon on the old (dev) socket
1720
+ // path before checking port availability — mirrors what forkDaemon() does. (lr-6ed3)
1721
+ if (process.platform !== "win32") {
1722
+ var devOldCheck = await checkOldDaemon();
1723
+ if (devOldCheck && devOldCheck.alive) {
1724
+ log(sym.warn + " " + a.yellow + "Pre-1.5 daemon detected at " + devOldCheck.sockPath + " — shutting it down..." + a.reset);
1725
+ await sendIPCCommand(devOldCheck.sockPath, { cmd: "shutdown" });
1726
+ var devMigWaited = 0;
1727
+ while (devMigWaited < 5000) {
1728
+ await new Promise(function (resolve) { setTimeout(resolve, 300); });
1729
+ devMigWaited += 300;
1730
+ if (await isPortFree(port)) break;
1731
+ }
1732
+ log(sym.done + " " + a.green + "Pre-1.5 daemon stopped. Continuing startup..." + a.reset);
1733
+ } else if (devOldCheck && !devOldCheck.alive && fs.existsSync(devOldCheck.sockPath)) {
1734
+ try { fs.unlinkSync(devOldCheck.sockPath); } catch (e) {}
1735
+ }
1736
+ }
1737
+
1640
1738
  var portFree = await isPortFree(port);
1641
1739
  if (!portFree) {
1642
1740
  console.log("\x1b[31m[dev] Port " + port + " is already in use.\x1b[0m");
@@ -1751,7 +1849,12 @@ async function devMode(mode, keepAwake, existingPinHash, wantOsUsers) {
1751
1849
  process.exit(78);
1752
1850
  return;
1753
1851
  }
1754
- // Unexpected exit — auto restart
1852
+ // Unexpected exit — auto restart (suppressed when --no-restart is set)
1853
+ if (noRestart) {
1854
+ console.log("\x1b[33m[dev] Daemon exited (code " + code + "). --no-restart is set — not restarting.\x1b[0m");
1855
+ process.exit(code || 1);
1856
+ return;
1857
+ }
1755
1858
  console.log("\x1b[33m[dev] Daemon exited (code " + code + "), restarting...\x1b[0m");
1756
1859
  setTimeout(spawnDaemon, 500);
1757
1860
  });
@@ -1963,7 +2066,7 @@ function showMainMenu(config, ip, setupCode) {
1963
2066
 
1964
2067
  function afterQr() {
1965
2068
  // Status line
1966
- log(" " + a.dim + "clagentic" + a.reset + " " + a.dim + "v" + currentVersion + a.reset + a.dim + " — " + url + a.reset);
2069
+ log(" " + a.dim + "Clagentic: Console" + a.reset + " " + a.dim + "v" + currentVersion + a.reset + a.dim + " — " + url + a.reset);
1967
2070
  var parts = [];
1968
2071
  parts.push(a.bold + projs.length + a.reset + a.dim + (projs.length === 1 ? " project" : " projects"));
1969
2072
  parts.push(a.reset + a.bold + totalSessions + a.reset + a.dim + (totalSessions === 1 ? " session" : " sessions"));
@@ -1976,7 +2079,7 @@ function showMainMenu(config, ip, setupCode) {
1976
2079
  log("");
1977
2080
 
1978
2081
  if (config.mkcertDetected) {
1979
- log(" " + sym.warn + " " + a.yellow + "Clay now ships with a builtin HTTPS certificate." + a.reset);
2082
+ log(" " + sym.warn + " " + a.yellow + "Clagentic: Console now ships with a builtin HTTPS certificate." + a.reset);
1980
2083
  log(" " + a.dim + "No more CA setup on each device." + a.reset);
1981
2084
  log(" " + a.dim + "To use it, pass --builtin-cert or uninstall mkcert." + a.reset);
1982
2085
  log("");
@@ -2095,7 +2198,7 @@ function showSettingsMenu(config, ip) {
2095
2198
 
2096
2199
  var modeLabel = config.mode === "multi" ? "Multi-user" : "Single user";
2097
2200
  var modeStatus = config.mode === "multi"
2098
- ? a.clay + modeLabel + a.reset
2201
+ ? a.indigo + modeLabel + a.reset
2099
2202
  : a.dim + modeLabel + a.reset;
2100
2203
  log(sym.bar + " Mode " + modeStatus);
2101
2204
  log(sym.bar + " PIN " + pinStatus);
@@ -2188,7 +2291,7 @@ function showSettingsMenu(config, ip) {
2188
2291
  log(sym.bar);
2189
2292
  log(sym.bar + " Setup code: " + a.bold + muResult.setupCode + a.reset);
2190
2293
  log(sym.bar);
2191
- log(sym.bar + " " + a.dim + "Open Clay in your browser and enter this code to create the admin account." + a.reset);
2294
+ log(sym.bar + " " + a.dim + "Open Clagentic: Console in your browser and enter this code to create the admin account." + a.reset);
2192
2295
  log(sym.bar + " " + a.dim + "The code is single-use and will be cleared once the admin is set up." + a.reset);
2193
2296
  } else {
2194
2297
  log(sym.bar + " " + a.dim + "Multi-user mode is already enabled." + a.reset);
@@ -2246,7 +2349,7 @@ function showSettingsMenu(config, ip) {
2246
2349
  log(sym.bar);
2247
2350
  log(sym.bar + " " + a.red + sym.warn + " OS-level user isolation requires Linux." + a.reset);
2248
2351
  log(sym.bar + " " + a.dim + "This feature depends on setfacl, getent, and uid/gid process spawning." + a.reset);
2249
- log(sym.bar + " " + a.dim + "Use Docker or a Linux VM to run Clay with OS user isolation." + a.reset);
2352
+ log(sym.bar + " " + a.dim + "Use Docker or a Linux VM to run Clagentic: Console with OS user isolation." + a.reset);
2250
2353
  log(sym.bar);
2251
2354
  showSettingsMenu(config, ip);
2252
2355
  return;
@@ -2254,7 +2357,7 @@ function showSettingsMenu(config, ip) {
2254
2357
  log(sym.bar);
2255
2358
  log(sym.bar + " " + a.yellow + sym.warn + " OS-Level User Isolation" + a.reset);
2256
2359
  log(sym.bar);
2257
- log(sym.bar + " " + a.dim + "This feature maps each Clay user to a Linux OS user account." + a.reset);
2360
+ log(sym.bar + " " + a.dim + "This feature maps each Clagentic: Console user to a Linux OS user account." + a.reset);
2258
2361
  log(sym.bar + " " + a.dim + "The daemon must run as root and will spawn processes (SDK workers," + a.reset);
2259
2362
  log(sym.bar + " " + a.dim + "terminals, file operations) as the mapped Linux user." + a.reset);
2260
2363
  log(sym.bar);
@@ -2263,7 +2366,7 @@ function showSettingsMenu(config, ip) {
2263
2366
  log(sym.bar + " " + a.dim + "- Terminals and file access follow Linux permissions" + a.reset);
2264
2367
  log(sym.bar + " " + a.dim + "- Linux user accounts are created automatically (clay-username)" + a.reset);
2265
2368
  log(sym.bar);
2266
- log(sym.bar + " " + a.dim + "Recommended: Run on a dedicated Clay server or cloud instance," + a.reset);
2369
+ log(sym.bar + " " + a.dim + "Recommended: Run on a dedicated Clagentic: Console server or cloud instance," + a.reset);
2267
2370
  log(sym.bar + " " + a.dim + "not on a personal computer or general-purpose server." + a.reset);
2268
2371
  log(sym.bar);
2269
2372
  promptSelect("Select", [
@@ -2755,7 +2858,7 @@ var currentVersion = require("../package.json").version;
2755
2858
  console.error("");
2756
2859
  console.error("Install it: " + a.bold + aclCheck.installCmd + a.reset);
2757
2860
  console.error("");
2758
- console.error("Then restart Clay.");
2861
+ console.error("Then restart Clagentic: Console.");
2759
2862
  process.exit(1);
2760
2863
  return;
2761
2864
  }
@@ -7,6 +7,8 @@ Type=simple
7
7
  ExecStart=/usr/local/bin/clagentic-daemon.sh
8
8
  Restart=always
9
9
  RestartSec=5
10
+ # EX_CONFIG (78) is a fatal configuration error (mis-set CLAGENTIC_HOME, unsupported Node) — do not restart-loop
11
+ RestartPreventExitStatus=78
10
12
  KillMode=mixed
11
13
  TimeoutStopSec=20
12
14
  SendSIGKILL=yes
@@ -150,8 +150,10 @@ function addFavorite(agent) {
150
150
  }
151
151
 
152
152
  // Remove an agent from favorites. Returns true if removed, false if not present.
153
+ // Note: schema v2 entries have only {name, addedAt} — no kind field — so we
154
+ // guard on name only (matching addFavorite and sameAgent).
153
155
  function removeFavorite(agent) {
154
- if (!agent || !agent.name || !agent.kind) return false;
156
+ if (!agent || !agent.name) return false;
155
157
  var store = readStore();
156
158
  var before = store.favorites.length;
157
159
  store.favorites = store.favorites.filter(function (f) { return !sameAgent(f, agent); });