@clagentic/console 1.7.0 → 1.8.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 (58) hide show
  1. package/bin/cli.js +198 -2542
  2. package/lib/build-sha.json +4 -0
  3. package/lib/cli/daemon-launch.js +797 -0
  4. package/lib/cli/ipc-subcommands.js +186 -0
  5. package/lib/cli/menus.js +849 -0
  6. package/lib/cli/net-detect.js +209 -0
  7. package/lib/cli/tui.js +589 -0
  8. package/lib/daemon.js +15 -6
  9. package/lib/memory-shed.js +81 -2
  10. package/lib/pages.js +13 -17
  11. package/lib/project-connection.js +13 -0
  12. package/lib/project-loop.js +4 -0
  13. package/lib/project-sessions.js +9 -3
  14. package/lib/project.js +3 -2
  15. package/lib/public/css/diagnostics.css +29 -1
  16. package/lib/public/css/home-hub.css +10 -0
  17. package/lib/public/css/overlays.css +19 -0
  18. package/lib/public/index.html +12 -11
  19. package/lib/public/manifest.json +1 -1
  20. package/lib/public/modules/app-connection.js +150 -4
  21. package/lib/public/modules/app-history-replay.js +155 -0
  22. package/lib/public/modules/app-home-hub.js +24 -14
  23. package/lib/public/modules/app-messages.js +1246 -1469
  24. package/lib/public/modules/app-notifications.js +4 -4
  25. package/lib/public/modules/app-rate-limit.js +128 -27
  26. package/lib/public/modules/command-palette.js +11 -22
  27. package/lib/public/modules/context-sources.js +1 -6
  28. package/lib/public/modules/filebrowser.js +25 -13
  29. package/lib/public/modules/input.js +47 -12
  30. package/lib/public/modules/mcp-ui.js +2 -2
  31. package/lib/public/modules/notifications.js +22 -1
  32. package/lib/public/modules/playbook.js +6 -6
  33. package/lib/public/modules/project-settings.js +5 -13
  34. package/lib/public/modules/qrcode.js +2 -2
  35. package/lib/public/modules/rate-limit-state.js +133 -0
  36. package/lib/public/modules/relative-time.js +27 -0
  37. package/lib/public/modules/scheduler-history.js +1 -5
  38. package/lib/public/modules/server-settings.js +28 -15
  39. package/lib/public/modules/sidebar-mobile.js +8 -3
  40. package/lib/public/modules/sidebar-projects.js +1 -1
  41. package/lib/public/modules/sidebar-sessions.js +1 -15
  42. package/lib/public/modules/sidebar.js +3 -3
  43. package/lib/public/modules/utils.js +1 -0
  44. package/lib/public/sw.js +24 -4
  45. package/lib/sdk-bridge.js +22 -0
  46. package/lib/sdk-message-processor.js +27 -1
  47. package/lib/server-auth.js +48 -2
  48. package/lib/server-palette.js +17 -1
  49. package/lib/server-settings.js +70 -4
  50. package/lib/server.js +200 -4
  51. package/lib/session-search.js +20 -5
  52. package/lib/sessions.js +84 -3
  53. package/lib/smtp.js +6 -6
  54. package/lib/yoke/adapters/codex.js +1 -1
  55. package/package.json +4 -2
  56. package/scripts/install-local-test.js +97 -0
  57. package/scripts/verify-installed-build.js +80 -0
  58. package/scripts/write-build-sha.js +53 -0
@@ -0,0 +1,186 @@
1
+ // lib/cli/ipc-subcommands.js
2
+ //
3
+ // One-shot IPC subcommand handlers for bin/cli.js: --shutdown, --restart,
4
+ // --add <path>, --remove <path>, --list. Each of these talks to the running
5
+ // daemon over the Unix socket and exits the process directly (they never
6
+ // return control to the caller) — extracted verbatim from bin/cli.js
7
+ // (lr-4e49 Part 1), no behavior change.
8
+
9
+ var fs = require("fs");
10
+ var path = require("path");
11
+
12
+ var { loadConfig, socketPath, isDaemonAliveAsync, checkOldDaemon, clearStaleConfig } = require("../config");
13
+ var { sendIPCCommand } = require("../ipc");
14
+
15
+ function handleShutdown() {
16
+ var shutdownConfig = loadConfig();
17
+ isDaemonAliveAsync(shutdownConfig).then(function (alive) {
18
+ if (alive) {
19
+ return sendIPCCommand(socketPath(), { cmd: "shutdown" }).then(function (resp) {
20
+ if (resp && resp.ok) {
21
+ console.log("Server stopped.");
22
+ clearStaleConfig();
23
+ process.exit(0);
24
+ } else {
25
+ var pid = shutdownConfig && shutdownConfig.pid;
26
+ console.error("Shutdown failed: daemon did not acknowledge the command.");
27
+ if (pid) console.error(" Daemon PID: " + pid + " (try: kill " + pid + ")");
28
+ console.error(" Or: systemctl restart clagentic-console");
29
+ process.exit(1);
30
+ }
31
+ });
32
+ }
33
+ // New socket not alive — check whether a pre-1.5 daemon is on the old path
34
+ return checkOldDaemon().then(function (old) {
35
+ if (old && old.alive) {
36
+ console.log("[migration] Sending shutdown to pre-1.5 daemon at " + old.sockPath);
37
+ return sendIPCCommand(old.sockPath, { cmd: "shutdown" }).then(function (resp) {
38
+ if (resp && resp.ok) {
39
+ console.log("Server stopped.");
40
+ process.exit(0);
41
+ } else {
42
+ var oldPid = shutdownConfig && shutdownConfig.pid;
43
+ console.error("Shutdown of pre-1.5 daemon failed: no acknowledgement from " + old.sockPath);
44
+ if (oldPid) console.error(" Daemon PID: " + oldPid + " (try: kill " + oldPid + ")");
45
+ console.error(" Or: systemctl restart clagentic-console");
46
+ process.exit(1);
47
+ }
48
+ });
49
+ }
50
+ console.error("No running daemon found.");
51
+ process.exit(1);
52
+ });
53
+ });
54
+ }
55
+
56
+ function handleRestart() {
57
+ var restartConfig = loadConfig();
58
+ isDaemonAliveAsync(restartConfig).then(function (alive) {
59
+ if (alive) {
60
+ return sendIPCCommand(socketPath(), { cmd: "restart" }).then(function (resp) {
61
+ if (resp && resp.ok) {
62
+ console.log("Server restarted.");
63
+ process.exit(0);
64
+ } else {
65
+ var pid = restartConfig && restartConfig.pid;
66
+ console.error("Restart failed: daemon did not acknowledge the command.");
67
+ if (pid) console.error(" Daemon PID: " + pid + " (try: kill " + pid + " && clagentic-console)");
68
+ console.error(" Or: systemctl restart clagentic-console");
69
+ process.exit(1);
70
+ }
71
+ });
72
+ }
73
+ // New socket not alive — check whether a pre-1.5 daemon is on the old path
74
+ return checkOldDaemon().then(function (old) {
75
+ if (old && old.alive) {
76
+ // Pre-1.5 daemon does not understand {cmd:"restart"} for the CLI restart
77
+ // flow (it would restart on the old socket path). Shut it down instead so
78
+ // the caller can re-run without a port conflict.
79
+ console.log("[migration] Pre-1.5 daemon found at " + old.sockPath + " — shutting it down so a fresh start can proceed.");
80
+ return sendIPCCommand(old.sockPath, { cmd: "shutdown" }).then(function (resp) {
81
+ if (resp && resp.ok) {
82
+ console.log("Pre-1.5 daemon stopped. Run clagentic-console to start the updated daemon.");
83
+ process.exit(0);
84
+ } else {
85
+ var oldPid = restartConfig && restartConfig.pid;
86
+ console.error("Shutdown of pre-1.5 daemon failed: no acknowledgement from " + old.sockPath);
87
+ if (oldPid) console.error(" Daemon PID: " + oldPid + " (try: kill " + oldPid + ")");
88
+ console.error(" Or: systemctl restart clagentic-console");
89
+ process.exit(1);
90
+ }
91
+ });
92
+ }
93
+ console.error("No running daemon found.");
94
+ process.exit(1);
95
+ });
96
+ });
97
+ }
98
+
99
+ function handleAdd(addPath) {
100
+ var absAdd = path.resolve(addPath);
101
+ try {
102
+ var stat = fs.statSync(absAdd);
103
+ if (!stat.isDirectory()) {
104
+ console.error("Not a directory: " + absAdd);
105
+ process.exit(1);
106
+ }
107
+ } catch (e) {
108
+ console.error("Directory not found: " + absAdd);
109
+ process.exit(1);
110
+ }
111
+ var addConfig = loadConfig();
112
+ isDaemonAliveAsync(addConfig).then(function (alive) {
113
+ if (!alive) {
114
+ console.error("No running daemon. Start with: npx @clagentic/console");
115
+ process.exit(1);
116
+ }
117
+ sendIPCCommand(socketPath(), { cmd: "add_project", path: absAdd }).then(function (res) {
118
+ if (res.ok) {
119
+ if (res.existing) {
120
+ console.log("Already registered: " + res.slug);
121
+ } else {
122
+ console.log("Added: " + res.slug + " → " + absAdd);
123
+ }
124
+ process.exit(0);
125
+ } else {
126
+ console.error("Failed: " + (res.error || "unknown error"));
127
+ process.exit(1);
128
+ }
129
+ });
130
+ });
131
+ }
132
+
133
+ function handleRemove(removePath) {
134
+ var absRemove = path.resolve(removePath);
135
+ var removeConfig = loadConfig();
136
+ isDaemonAliveAsync(removeConfig).then(function (alive) {
137
+ if (!alive) {
138
+ console.error("No running daemon. Start with: npx @clagentic/console");
139
+ process.exit(1);
140
+ }
141
+ sendIPCCommand(socketPath(), { cmd: "remove_project", path: absRemove }).then(function (res) {
142
+ if (res.ok) {
143
+ console.log("Removed: " + path.basename(absRemove));
144
+ process.exit(0);
145
+ } else {
146
+ console.error("Failed: " + (res.error || "project not found"));
147
+ process.exit(1);
148
+ }
149
+ });
150
+ });
151
+ }
152
+
153
+ function handleList() {
154
+ var listConfig = loadConfig();
155
+ isDaemonAliveAsync(listConfig).then(function (alive) {
156
+ if (!alive) {
157
+ console.error("No running daemon. Start with: npx @clagentic/console");
158
+ process.exit(1);
159
+ }
160
+ sendIPCCommand(socketPath(), { cmd: "get_status" }).then(function (res) {
161
+ if (!res.ok || !res.projects || res.projects.length === 0) {
162
+ console.log("No projects registered.");
163
+ process.exit(0);
164
+ return;
165
+ }
166
+ console.log("Projects (" + res.projects.length + "):\n");
167
+ for (var p = 0; p < res.projects.length; p++) {
168
+ var proj = res.projects[p];
169
+ var label = " " + proj.slug;
170
+ if (proj.title) label += " (" + proj.title + ")";
171
+ label += "\n " + proj.path;
172
+ console.log(label);
173
+ }
174
+ console.log("");
175
+ process.exit(0);
176
+ });
177
+ });
178
+ }
179
+
180
+ module.exports = {
181
+ handleShutdown: handleShutdown,
182
+ handleRestart: handleRestart,
183
+ handleAdd: handleAdd,
184
+ handleRemove: handleRemove,
185
+ handleList: handleList,
186
+ };