@clagentic/console 1.4.0 → 1.4.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/README.md +12 -10
- package/deploy/clagentic-console.service +28 -0
- package/lib/daemon.js +3 -0
- package/package.json +5 -2
- package/scripts/check-client-imports.js +94 -0
- package/scripts/postinstall.js +150 -0
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="media/logo/console-lockup-256.png" alt="
|
|
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>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<a href="https://
|
|
9
|
-
<a href="
|
|
10
|
-
<
|
|
11
|
-
<a href="https://
|
|
8
|
+
<a href="https://clagentic.ai"><img src="https://img.shields.io/badge/-clagentic.ai-00CFFF?style=flat&logoColor=white" alt="clagentic.ai" /></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow?style=flat" alt="License: MIT" /></a>
|
|
10
|
+
<img src="https://img.shields.io/badge/Node.js-20+-339933?style=flat&logo=node.js&logoColor=white" alt="Node.js 20+" />
|
|
11
|
+
<a href="https://www.npmjs.com/package/@clagentic/console"><img src="https://img.shields.io/npm/v/@clagentic/console?style=flat&label=npm" alt="npm version" /></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@clagentic/console"><img src="https://img.shields.io/npm/dw/@clagentic/console?style=flat&label=downloads" alt="npm downloads" /></a>
|
|
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>
|
|
12
14
|
</p>
|
|
13
15
|
|
|
14
|
-
A self-hosted browser console for Claude Code and ChatGPT Codex. Run AI sessions from any browser or phone — tool approvals, model selection, context management, session history — without leaving your own machine.
|
|
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.
|
|
15
17
|
|
|
16
18
|
No extras bolted on. No opinionated workflows. The floor is solid; you build what you need on top.
|
|
17
19
|
|
|
@@ -24,7 +26,7 @@ npm install -g @clagentic/console
|
|
|
24
26
|
Then run from anywhere:
|
|
25
27
|
|
|
26
28
|
```bash
|
|
27
|
-
clagentic
|
|
29
|
+
clagentic-console
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
Or try it without installing:
|
|
@@ -65,7 +67,7 @@ npx @clagentic/console --shutdown # Stop daemon
|
|
|
65
67
|
npx @clagentic/console --dangerously-skip-permissions
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Also available as `clagentic
|
|
70
|
+
Also available as `clagentic-console` if installed globally.
|
|
69
71
|
|
|
70
72
|
## Architecture
|
|
71
73
|
|
|
@@ -144,7 +146,7 @@ Yes. On Linux, opt in to OS-level isolation: each user maps to a real Linux acco
|
|
|
144
146
|
|
|
145
147
|
## Support
|
|
146
148
|
|
|
147
|
-
If
|
|
149
|
+
If clagentic:console is useful to you: [ko-fi.com/clagentic](https://ko-fi.com/clagentic)
|
|
148
150
|
|
|
149
151
|
## Credits
|
|
150
152
|
|
|
@@ -156,4 +158,4 @@ Not affiliated with Anthropic or OpenAI. Claude is a trademark of Anthropic. Cod
|
|
|
156
158
|
|
|
157
159
|
## License
|
|
158
160
|
|
|
159
|
-
MIT
|
|
161
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=Clagentic Console daemon
|
|
3
|
+
After=network.target
|
|
4
|
+
|
|
5
|
+
[Service]
|
|
6
|
+
Type=simple
|
|
7
|
+
ExecStart=/usr/local/bin/clagentic-daemon.sh
|
|
8
|
+
Restart=always
|
|
9
|
+
RestartSec=5
|
|
10
|
+
KillMode=mixed
|
|
11
|
+
TimeoutStopSec=20
|
|
12
|
+
SendSIGKILL=yes
|
|
13
|
+
# Soft ceiling — kernel begins reclaiming memory early (requires systemd 240+; host runs systemd 255)
|
|
14
|
+
MemoryHigh=70%
|
|
15
|
+
# Hard ceiling — triggers per-service OOM so OOMPolicy fires instead of host-level OOM killer
|
|
16
|
+
MemoryMax=85%
|
|
17
|
+
# On OOM, kill all remaining cgroup members so no orphaned child processes survive
|
|
18
|
+
OOMPolicy=kill
|
|
19
|
+
StandardOutput=journal
|
|
20
|
+
StandardError=journal
|
|
21
|
+
SyslogIdentifier=clagentic-console
|
|
22
|
+
Environment=SHELL=/bin/bash
|
|
23
|
+
Environment=PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
24
|
+
# TODO(lr-9452): rename to CLAGENTIC_CONSOLE_MAX_CONCURRENT_SESSIONS once sdk-bridge.js is updated
|
|
25
|
+
Environment=CLAGENTIC_MAX_CONCURRENT_SESSIONS=50
|
|
26
|
+
|
|
27
|
+
[Install]
|
|
28
|
+
WantedBy=multi-user.target
|
package/lib/daemon.js
CHANGED
|
@@ -1381,6 +1381,9 @@ var ipc = createIPCServer(socketPath(), function (msg) {
|
|
|
1381
1381
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1382
1382
|
timeout: 120000,
|
|
1383
1383
|
encoding: "utf8",
|
|
1384
|
+
// CLAGENTIC_SELF_UPDATE=1 tells postinstall.js not to restart the
|
|
1385
|
+
// service — gracefulShutdown() below hands off to systemd Restart=always.
|
|
1386
|
+
env: Object.assign({}, process.env, { CLAGENTIC_SELF_UPDATE: "1" }),
|
|
1384
1387
|
});
|
|
1385
1388
|
console.log("[daemon] Global install complete. Shutting down for supervised restart.");
|
|
1386
1389
|
updOk = true;
|
package/package.json
CHANGED
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.4.
|
|
6
|
+
"version": "1.4.1",
|
|
7
7
|
"description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
|
|
8
8
|
"bin": {
|
|
9
9
|
"clagentic-console": "./bin/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "node bin/cli.js --dev",
|
|
13
|
+
"postinstall": "node scripts/postinstall.js",
|
|
13
14
|
"test": "node --test --test-force-exit test/*.test.js",
|
|
14
15
|
"semantic-release": "semantic-release"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"bin/",
|
|
18
19
|
"lib/",
|
|
20
|
+
"scripts/",
|
|
21
|
+
"deploy/",
|
|
19
22
|
"CREDITS.md"
|
|
20
23
|
],
|
|
21
24
|
"keywords": [
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"bugs": {
|
|
46
49
|
"url": "https://github.com/clagentic/clagentic-console/issues"
|
|
47
50
|
},
|
|
48
|
-
"homepage": "https://
|
|
51
|
+
"homepage": "https://clagentic.ai/tools",
|
|
49
52
|
"author": "Andy Kuehner",
|
|
50
53
|
"contributors": [
|
|
51
54
|
"Chad (original Clay author)"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Verify that every relative ES module import under lib/public/ resolves to
|
|
3
|
+
// an existing file. Catches accidentally-included imports that point at
|
|
4
|
+
// files which don't exist in this branch (e.g. PR #342 imported
|
|
5
|
+
// './agent-picker.js', which would have broken the client at runtime).
|
|
6
|
+
//
|
|
7
|
+
// Scope: only checks relative imports (./ or ../). Bare specifiers and
|
|
8
|
+
// absolute URLs are ignored — those are not what this guard is about.
|
|
9
|
+
//
|
|
10
|
+
// Exit code 0 on success, 1 on any unresolved import.
|
|
11
|
+
|
|
12
|
+
var fs = require('fs');
|
|
13
|
+
var path = require('path');
|
|
14
|
+
|
|
15
|
+
var ROOT = path.resolve(__dirname, '..', 'lib', 'public');
|
|
16
|
+
|
|
17
|
+
function walk(dir, out) {
|
|
18
|
+
var entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
19
|
+
for (var i = 0; i < entries.length; i++) {
|
|
20
|
+
var e = entries[i];
|
|
21
|
+
var full = path.join(dir, e.name);
|
|
22
|
+
if (e.isDirectory()) walk(full, out);
|
|
23
|
+
else if (e.isFile() && e.name.endsWith('.js')) out.push(full);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Match `import ... from '...'`, `import '...'`, and `export ... from '...'`.
|
|
29
|
+
// Skips dynamic import() — those can take runtime expressions and aren't
|
|
30
|
+
// reliably resolvable statically.
|
|
31
|
+
var IMPORT_RE = /(?:^|\s)(?:import|export)(?:[\s\S]*?from\s*)?['"]([^'"]+)['"]/g;
|
|
32
|
+
|
|
33
|
+
function extractSpecifiers(src) {
|
|
34
|
+
var specs = [];
|
|
35
|
+
var m;
|
|
36
|
+
IMPORT_RE.lastIndex = 0;
|
|
37
|
+
while ((m = IMPORT_RE.exec(src)) !== null) specs.push(m[1]);
|
|
38
|
+
return specs;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isRelative(spec) {
|
|
42
|
+
return spec.startsWith('./') || spec.startsWith('../');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resolveTarget(fromFile, spec) {
|
|
46
|
+
var base = path.resolve(path.dirname(fromFile), spec);
|
|
47
|
+
// Exact path as written.
|
|
48
|
+
if (fs.existsSync(base) && fs.statSync(base).isFile()) return base;
|
|
49
|
+
// Try with .js appended (some imports may omit the extension).
|
|
50
|
+
if (fs.existsSync(base + '.js')) return base + '.js';
|
|
51
|
+
// Directory with index.js.
|
|
52
|
+
var idx = path.join(base, 'index.js');
|
|
53
|
+
if (fs.existsSync(idx)) return idx;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var files = walk(ROOT, []);
|
|
58
|
+
var errors = [];
|
|
59
|
+
|
|
60
|
+
for (var i = 0; i < files.length; i++) {
|
|
61
|
+
var file = files[i];
|
|
62
|
+
var src;
|
|
63
|
+
try {
|
|
64
|
+
src = fs.readFileSync(file, 'utf8');
|
|
65
|
+
} catch (e) {
|
|
66
|
+
errors.push({ file: file, spec: '<read error>', detail: e.message });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
var specs = extractSpecifiers(src);
|
|
70
|
+
for (var j = 0; j < specs.length; j++) {
|
|
71
|
+
var spec = specs[j];
|
|
72
|
+
if (!isRelative(spec)) continue;
|
|
73
|
+
var target = resolveTarget(file, spec);
|
|
74
|
+
if (!target) {
|
|
75
|
+
errors.push({
|
|
76
|
+
file: path.relative(process.cwd(), file),
|
|
77
|
+
spec: spec,
|
|
78
|
+
detail: 'unresolved relative import',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (errors.length) {
|
|
85
|
+
console.error('Unresolved client imports:');
|
|
86
|
+
for (var k = 0; k < errors.length; k++) {
|
|
87
|
+
var err = errors[k];
|
|
88
|
+
console.error(' ' + err.file + ' -> ' + err.spec + ' (' + err.detail + ')');
|
|
89
|
+
}
|
|
90
|
+
console.error('\nTotal: ' + errors.length + ' unresolved import(s).');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log('OK: all ' + files.length + ' client modules have resolvable relative imports.');
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// postinstall.js — installs/updates the systemd service unit on Linux global npm installs.
|
|
5
|
+
// Runs automatically after `npm install -g @clagentic/console`.
|
|
6
|
+
// Silently exits on non-Linux platforms and non-root invocations.
|
|
7
|
+
|
|
8
|
+
const { execFileSync } = require('child_process');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const PREFIX = '[clagentic-console postinstall]';
|
|
13
|
+
|
|
14
|
+
function log(msg) {
|
|
15
|
+
console.log(`${PREFIX} ${msg}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function runCmd(cmd, args) {
|
|
19
|
+
// Returns stdout string on success, throws on failure.
|
|
20
|
+
// stderr is captured in err.stderr on failure.
|
|
21
|
+
return execFileSync(cmd, args, { stdio: 'pipe' }).toString().trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function errMsg(err) {
|
|
25
|
+
// execFileSync puts detail in err.stderr; fall back to err.message.
|
|
26
|
+
const stderr = err.stderr && err.stderr.toString().trim();
|
|
27
|
+
return stderr || err.message;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Skip silently on non-Linux platforms.
|
|
31
|
+
if (process.platform !== 'linux') {
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Skip silently when not running as root — cannot write to /etc/systemd/system/.
|
|
36
|
+
if (process.getuid() !== 0) {
|
|
37
|
+
log('skipping (not root)');
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// When the daemon triggers its own in-app update it passes CLAGENTIC_SELF_UPDATE=1.
|
|
42
|
+
// In that case, skip restarting the service — the daemon calls gracefulShutdown()
|
|
43
|
+
// immediately after npm install completes, and systemd Restart=always handles the
|
|
44
|
+
// supervised restart. Issuing systemctl restart here would race with gracefulShutdown
|
|
45
|
+
// and tear down sessions before state is flushed.
|
|
46
|
+
const selfUpdate = process.env.CLAGENTIC_SELF_UPDATE === '1';
|
|
47
|
+
if (selfUpdate) {
|
|
48
|
+
log('self-update detected (CLAGENTIC_SELF_UPDATE=1) — skipping service restart');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const SYSTEMD_DIR = '/etc/systemd/system';
|
|
52
|
+
const NEW_UNIT = 'clagentic-console.service';
|
|
53
|
+
const OLD_UNIT = 'clagentic.service';
|
|
54
|
+
const NEW_UNIT_DEST = path.join(SYSTEMD_DIR, NEW_UNIT);
|
|
55
|
+
const OLD_UNIT_PATH = path.join(SYSTEMD_DIR, OLD_UNIT);
|
|
56
|
+
const UNIT_SRC = path.join(__dirname, '..', 'deploy', 'clagentic-console.service');
|
|
57
|
+
|
|
58
|
+
// Step 1: Copy the new unit file.
|
|
59
|
+
log(`installing unit file -> ${NEW_UNIT_DEST}`);
|
|
60
|
+
try {
|
|
61
|
+
fs.copyFileSync(UNIT_SRC, NEW_UNIT_DEST);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
log(`ERROR copying unit file: ${errMsg(err)}`);
|
|
64
|
+
// Cannot continue without the unit file in place.
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Step 2: daemon-reload to pick up the new unit file.
|
|
69
|
+
log('running systemctl daemon-reload');
|
|
70
|
+
try {
|
|
71
|
+
runCmd('systemctl', ['daemon-reload']);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
log(`WARNING: daemon-reload failed: ${errMsg(err)}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Step 3: Enable the new unit if not already enabled.
|
|
77
|
+
log(`enabling ${NEW_UNIT}`);
|
|
78
|
+
try {
|
|
79
|
+
runCmd('systemctl', ['enable', NEW_UNIT]);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
log(`WARNING: enable ${NEW_UNIT} failed: ${errMsg(err)}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Step 4: Handle rename — migrate from old clagentic.service if present.
|
|
85
|
+
let wasRunningUnderOldUnit = false;
|
|
86
|
+
if (fs.existsSync(OLD_UNIT_PATH)) {
|
|
87
|
+
log(`old unit file detected: ${OLD_UNIT_PATH} — performing rename cutover`);
|
|
88
|
+
|
|
89
|
+
// Detect whether the old unit is currently active before stopping it.
|
|
90
|
+
try {
|
|
91
|
+
const activeState = runCmd('systemctl', ['is-active', OLD_UNIT]);
|
|
92
|
+
if (activeState === 'active') {
|
|
93
|
+
wasRunningUnderOldUnit = true;
|
|
94
|
+
}
|
|
95
|
+
} catch (_) {
|
|
96
|
+
// is-active exits non-zero when not active — not an error.
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Disable the old unit.
|
|
100
|
+
log(`disabling ${OLD_UNIT}`);
|
|
101
|
+
try {
|
|
102
|
+
runCmd('systemctl', ['disable', OLD_UNIT]);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
log(`WARNING: disable ${OLD_UNIT} failed (ignored): ${errMsg(err)}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Stop the old unit.
|
|
108
|
+
log(`stopping ${OLD_UNIT}`);
|
|
109
|
+
try {
|
|
110
|
+
runCmd('systemctl', ['stop', OLD_UNIT]);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
log(`WARNING: stop ${OLD_UNIT} failed (ignored): ${errMsg(err)}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Remove the old unit file.
|
|
116
|
+
log(`removing ${OLD_UNIT_PATH}`);
|
|
117
|
+
try {
|
|
118
|
+
fs.unlinkSync(OLD_UNIT_PATH);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
log(`WARNING: remove ${OLD_UNIT_PATH} failed: ${errMsg(err)}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// daemon-reload again to clear the old unit from systemd's view.
|
|
124
|
+
log('running systemctl daemon-reload (post-rename)');
|
|
125
|
+
try {
|
|
126
|
+
runCmd('systemctl', ['daemon-reload']);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
log(`WARNING: daemon-reload (post-rename) failed: ${errMsg(err)}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Step 5: Start clagentic-console.service only if it was running under the old unit
|
|
133
|
+
// and needs to be moved to the new one. Never restart a running service — that kills
|
|
134
|
+
// live sessions. Never auto-start on a fresh install — the daemon needs configuration.
|
|
135
|
+
// Self-updates use gracefulShutdown() + Restart=always; postinstall must not interfere.
|
|
136
|
+
if (selfUpdate) {
|
|
137
|
+
log('skipping start (self-update — gracefulShutdown will hand off to systemd)');
|
|
138
|
+
} else if (wasRunningUnderOldUnit) {
|
|
139
|
+
// Stopped the old unit during rename cutover — start under the new one now.
|
|
140
|
+
log(`starting ${NEW_UNIT} (was running under ${OLD_UNIT})`);
|
|
141
|
+
try {
|
|
142
|
+
runCmd('systemctl', ['start', NEW_UNIT]);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
log(`WARNING: start ${NEW_UNIT} failed: ${errMsg(err)}`);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
log(`skipping start (daemon was not running or is already running — operator controls restarts)`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
log('done');
|