@clagentic/console 1.4.0-beta.1 → 1.4.0-beta.3
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/lib/daemon.js +70 -22
- package/lib/project-loop.js +17 -23
- package/lib/project-sessions.js +19 -1
- package/lib/project.js +8 -0
- package/lib/public/app.js +17 -3
- package/lib/public/css/input.css +5 -0
- package/lib/public/modules/app-header.js +7 -1
- package/lib/public/modules/app-messages.js +10 -5
- package/lib/public/modules/command-palette.js +3 -0
- package/lib/public/modules/input.js +18 -2
- package/lib/public/modules/overlay-history.js +62 -0
- package/lib/public/modules/project-settings.js +3 -0
- package/lib/public/modules/scheduler.js +3 -0
- package/lib/public/modules/server-settings.js +4 -1
- package/lib/public/modules/session-search.js +3 -0
- package/lib/public/modules/sticky-notes.js +3 -0
- package/lib/sdk-bridge.js +72 -13
- package/lib/sdk-message-processor.js +21 -10
- package/lib/sdk-skill-discovery.js +199 -1
- package/lib/sdk-slash-enrichment.js +64 -0
- package/lib/sdk-worker.js +17 -0
- package/lib/sdk-workflow-discovery.js +151 -0
- package/lib/server.js +9 -2
- package/lib/sessions.js +2 -0
- package/lib/updater.js +15 -6
- package/lib/yoke/adapters/claude-worker.js +17 -0
- package/lib/yoke/adapters/claude.js +13 -3
- package/lib/yoke/adapters/codex.js +53 -4
- package/package.json +2 -2
package/lib/server.js
CHANGED
|
@@ -180,6 +180,7 @@ function createServer(opts) {
|
|
|
180
180
|
var onSetPin = opts.onSetPin || null;
|
|
181
181
|
var onSetKeepAwake = opts.onSetKeepAwake || null;
|
|
182
182
|
var onSetImageRetention = opts.onSetImageRetention || null;
|
|
183
|
+
var onSetMemAvailableThreshold = opts.onSetMemAvailableThreshold || null;
|
|
183
184
|
var onShutdown = opts.onShutdown || null;
|
|
184
185
|
var onRestart = opts.onRestart || null;
|
|
185
186
|
var onSetUpdateChannel = opts.onSetUpdateChannel || null;
|
|
@@ -946,10 +947,15 @@ function createServer(opts) {
|
|
|
946
947
|
});
|
|
947
948
|
return list;
|
|
948
949
|
},
|
|
949
|
-
|
|
950
|
+
// includeSelf: when true, the calling project's own sessions are included
|
|
951
|
+
// in the uniform pass (so callers need not special-case self). The Hub
|
|
952
|
+
// recent-sessions list uses this to gather every project identically —
|
|
953
|
+
// matching the palette's behavior — so the global recency sort is honest
|
|
954
|
+
// and the currently-connected project doesn't dominate the result.
|
|
955
|
+
getAllProjectSessions: function (includeSelf) {
|
|
950
956
|
var allSessions = [];
|
|
951
957
|
projects.forEach(function (pCtx, pSlug) {
|
|
952
|
-
if (pSlug === slug) return; // skip self
|
|
958
|
+
if (!includeSelf && pSlug === slug) return; // skip self unless asked
|
|
953
959
|
var status = pCtx.getStatus();
|
|
954
960
|
if (status.isWorktree) return;
|
|
955
961
|
var pSm = pCtx.getSessionManager();
|
|
@@ -1070,6 +1076,7 @@ function createServer(opts) {
|
|
|
1070
1076
|
onSetPin: onSetPin,
|
|
1071
1077
|
onSetKeepAwake: onSetKeepAwake,
|
|
1072
1078
|
onSetImageRetention: onSetImageRetention,
|
|
1079
|
+
onSetMemAvailableThreshold: onSetMemAvailableThreshold,
|
|
1073
1080
|
onSetUpdateChannel: onSetUpdateChannel,
|
|
1074
1081
|
updateChannel: onGetDaemonConfig ? (onGetDaemonConfig().updateChannel || "stable") : "stable",
|
|
1075
1082
|
onShutdown: onShutdown,
|
package/lib/sessions.js
CHANGED
|
@@ -1060,6 +1060,8 @@ function createSessionManager(opts) {
|
|
|
1060
1060
|
return {
|
|
1061
1061
|
get activeSessionId() { return activeSessionId; },
|
|
1062
1062
|
get nextLocalId() { return nextLocalId; },
|
|
1063
|
+
// slashCommands and slashCommandsByVendor store {name, desc, type}[] (lr-1c7f).
|
|
1064
|
+
// Previously string[]; now enriched objects. Setters are generic pass-through.
|
|
1063
1065
|
get slashCommands() { return slashCommands; },
|
|
1064
1066
|
set slashCommands(v) { slashCommands = v; },
|
|
1065
1067
|
get slashCommandsByVendor() { return slashCommandsByVendor; },
|
package/lib/updater.js
CHANGED
|
@@ -81,10 +81,15 @@ function isNewer(latest, current) {
|
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
// Install an EXACT version, never a dist-tag. Installing a tag (@latest/@beta)
|
|
85
|
+
// is unsafe: the tag can resolve to a different — even older — version than the
|
|
86
|
+
// one isNewer() approved, which is how a beta machine got silently downgraded to
|
|
87
|
+
// whatever @latest happened to point at. Pinning the resolved version makes a
|
|
88
|
+
// downgrade structurally impossible.
|
|
89
|
+
function performUpdate(version) {
|
|
90
|
+
if (!version) return false;
|
|
86
91
|
try {
|
|
87
|
-
execFileSync("npm", ["install", "-g", "@clagentic/console@" +
|
|
92
|
+
execFileSync("npm", ["install", "-g", "@clagentic/console@" + version], { stdio: "pipe" });
|
|
88
93
|
return true;
|
|
89
94
|
} catch (e) {
|
|
90
95
|
return false;
|
|
@@ -116,13 +121,17 @@ async function checkAndUpdate(currentVersion, skipUpdate, channel) {
|
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
// Guard: only ever install something strictly newer than what is running.
|
|
125
|
+
// isNewer treats a same-base stable as newer than a pre-release, so this also
|
|
126
|
+
// never trades a beta down to an equal-or-older stable.
|
|
119
127
|
if (!latest || !isNewer(latest, currentVersion)) return false;
|
|
120
128
|
|
|
121
|
-
var tag = (isBeta && latest.includes("-")) ? "beta" : "latest";
|
|
122
129
|
log(sym.pointer + " " + a.bold + "Update available" + a.reset + " " + a.dim + currentVersion + " -> " + latest + a.reset);
|
|
123
130
|
log(sym.bar + " Installing...");
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
// Install the exact resolved version, not a dist-tag — the announced version
|
|
133
|
+
// and the installed version are then guaranteed identical.
|
|
134
|
+
if (performUpdate(latest)) {
|
|
126
135
|
log(sym.done + " Updated to " + a.green + latest + a.reset);
|
|
127
136
|
log("");
|
|
128
137
|
reExec();
|
|
@@ -130,7 +139,7 @@ async function checkAndUpdate(currentVersion, skipUpdate, channel) {
|
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
log(sym.warn + " " + a.yellow + "Update failed" + a.reset + a.dim + " (permission denied?)" + a.reset);
|
|
133
|
-
log(sym.bar + " " + a.dim + "Run manually: npm install -g @clagentic/console@" +
|
|
142
|
+
log(sym.bar + " " + a.dim + "Run manually: npm install -g @clagentic/console@" + latest + a.reset);
|
|
134
143
|
log("");
|
|
135
144
|
return false;
|
|
136
145
|
}
|
|
@@ -103,6 +103,9 @@ var pendingElicitations = {}; // requestId -> resolve
|
|
|
103
103
|
var pendingMcpToolCalls = {}; // requestId -> { resolve, reject }
|
|
104
104
|
var conn = null;
|
|
105
105
|
var buffer = "";
|
|
106
|
+
// Reference to the claude CLI child process spawned by spawnClaudeCodeProcess.
|
|
107
|
+
// Stored so cleanup() can send SIGTERM/SIGKILL to it on worker shutdown.
|
|
108
|
+
var _claudeChildProcess = null;
|
|
106
109
|
|
|
107
110
|
// --- Message queue (same implementation as sdk-bridge.js) ---
|
|
108
111
|
function createMessageQueue() {
|
|
@@ -458,6 +461,8 @@ async function handleQueryStart(msg) {
|
|
|
458
461
|
env: spawnOpts.env,
|
|
459
462
|
stdio: ["pipe", "pipe", "pipe"],
|
|
460
463
|
});
|
|
464
|
+
// Track the child so cleanup() can terminate it on worker shutdown.
|
|
465
|
+
_claudeChildProcess = cp;
|
|
461
466
|
// Capture ALL CLI stderr
|
|
462
467
|
if (cp.stderr) {
|
|
463
468
|
cp.stderr.on("data", function(chunk) {
|
|
@@ -730,6 +735,18 @@ function cleanup() {
|
|
|
730
735
|
if (conn && !conn.destroyed) {
|
|
731
736
|
try { conn.end(); } catch (e) {}
|
|
732
737
|
}
|
|
738
|
+
// Terminate the claude CLI child process. Without this, it outlives the worker
|
|
739
|
+
// and becomes orphaned when the daemon sends SIGTERM to the process group.
|
|
740
|
+
if (_claudeChildProcess && !_claudeChildProcess.killed) {
|
|
741
|
+
try { _claudeChildProcess.kill("SIGTERM"); } catch (e) {}
|
|
742
|
+
// SIGKILL fallback after brief grace period to allow the CLI to flush state.
|
|
743
|
+
var _cpSnapshot = _claudeChildProcess;
|
|
744
|
+
setTimeout(function() {
|
|
745
|
+
if (_cpSnapshot && !_cpSnapshot.killed) {
|
|
746
|
+
try { _cpSnapshot.kill("SIGKILL"); } catch (e) {}
|
|
747
|
+
}
|
|
748
|
+
}, 2000);
|
|
749
|
+
}
|
|
733
750
|
}
|
|
734
751
|
|
|
735
752
|
// Exit with a grace period so the SDK can flush session state to disk.
|
|
@@ -523,6 +523,11 @@ function spawnWorker(linuxUser, workerScriptPath, cwd) {
|
|
|
523
523
|
env: workerEnv,
|
|
524
524
|
cwd: cwd,
|
|
525
525
|
stdio: ["ignore", "pipe", "pipe"],
|
|
526
|
+
// detached: true gives the worker its own process group (pgid = worker.pid).
|
|
527
|
+
// This lets us send SIGTERM/SIGKILL to the whole group (kill(-pgid)) when
|
|
528
|
+
// the daemon shuts down, reaping grandchild claude CLI processes too.
|
|
529
|
+
// We do NOT call .unref() so the daemon still tracks the worker.
|
|
530
|
+
detached: true,
|
|
526
531
|
});
|
|
527
532
|
|
|
528
533
|
worker.process.stdout.on("data", function(data) {
|
|
@@ -613,10 +618,15 @@ function spawnWorker(linuxUser, workerScriptPath, cwd) {
|
|
|
613
618
|
worker.kill = function() {
|
|
614
619
|
console.log("[yoke/claude] worker.kill() called, pid=" + (worker.process ? worker.process.pid : "?") + " stack=" + new Error().stack.split("\n").slice(1, 4).join(" | "));
|
|
615
620
|
worker.send({ type: "shutdown" });
|
|
616
|
-
//
|
|
621
|
+
// Kill the entire process group (worker + any grandchild claude CLI processes).
|
|
622
|
+
// Negative pid targets the process group (pgid = worker.pid when detached: true).
|
|
623
|
+
if (worker.process && worker.process.pid) {
|
|
624
|
+
try { process.kill(-worker.process.pid, "SIGTERM"); } catch (e) {}
|
|
625
|
+
}
|
|
626
|
+
// Force kill the whole group after 5 seconds if still alive (gives SDK time to save session)
|
|
617
627
|
setTimeout(function() {
|
|
618
628
|
if (worker.process && !worker.process.killed) {
|
|
619
|
-
try { worker.process.
|
|
629
|
+
try { process.kill(-worker.process.pid, "SIGKILL"); } catch (e) {}
|
|
620
630
|
}
|
|
621
631
|
}, 5000);
|
|
622
632
|
// Don't call cleanupWorker here. Let the exit handler do it after
|
|
@@ -934,7 +944,7 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
934
944
|
worker._abortTimeout = setTimeout(function() {
|
|
935
945
|
if (worker.process && !worker.process.killed) {
|
|
936
946
|
console.log("[yoke/claude] Abort timeout: force-killing worker pid=" + (worker.process ? worker.process.pid : "?"));
|
|
937
|
-
try { worker.process.
|
|
947
|
+
try { process.kill(-worker.process.pid, "SIGKILL"); } catch (e) {}
|
|
938
948
|
}
|
|
939
949
|
}, 5000);
|
|
940
950
|
},
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
var path = require("path");
|
|
7
7
|
var fs = require("fs");
|
|
8
8
|
var { CodexAppServer } = require("../codex-app-server");
|
|
9
|
+
var { discoverWorkflows } = require("../../sdk-workflow-discovery");
|
|
10
|
+
var { discoverSkillsWithMeta } = require("../../sdk-skill-discovery");
|
|
9
11
|
|
|
10
12
|
// --- Claude skill discovery ---
|
|
11
13
|
// Finds Claude skills in ~/.claude/skills/ and <cwd>/.claude/skills/
|
|
@@ -1151,12 +1153,59 @@ function createCodexAdapter(opts) {
|
|
|
1151
1153
|
updateLastActiveAt();
|
|
1152
1154
|
}
|
|
1153
1155
|
|
|
1154
|
-
|
|
1156
|
+
// Build the enriched slash_commands array from skill names and workflow discovery.
|
|
1157
|
+
// Returns {name, desc, type}[] with skills first (type:'skill'), then workflows
|
|
1158
|
+
// (type:'workflow'), deduplicated by name. This mirrors the enrichment done in
|
|
1159
|
+
// sdk-message-processor for the Claude adapter path.
|
|
1160
|
+
function buildEnrichedSlashCommands(skillNames, cwd) {
|
|
1161
|
+
var effectiveCwd = cwd || _cwd;
|
|
1162
|
+
var seen = {};
|
|
1163
|
+
var combined = [];
|
|
1164
|
+
|
|
1165
|
+
// Skills: enrich with descriptions from SKILL.md where available
|
|
1166
|
+
var fsSkillsMeta;
|
|
1167
|
+
try {
|
|
1168
|
+
fsSkillsMeta = discoverSkillsWithMeta(effectiveCwd);
|
|
1169
|
+
} catch (e) {
|
|
1170
|
+
fsSkillsMeta = [];
|
|
1171
|
+
}
|
|
1172
|
+
var skillMetaMap = {};
|
|
1173
|
+
for (var si = 0; si < fsSkillsMeta.length; si++) {
|
|
1174
|
+
skillMetaMap[fsSkillsMeta[si].name] = fsSkillsMeta[si];
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
var names = skillNames || [];
|
|
1178
|
+
for (var ni = 0; ni < names.length; ni++) {
|
|
1179
|
+
var name = names[ni];
|
|
1180
|
+
if (seen[name]) continue;
|
|
1181
|
+
seen[name] = true;
|
|
1182
|
+
var meta = skillMetaMap[name];
|
|
1183
|
+
combined.push({ name: name, desc: (meta && meta.description) || "", type: "skill" });
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// Workflows: discovered from filesystem, deduplicated against skills by name
|
|
1187
|
+
var workflows;
|
|
1188
|
+
try {
|
|
1189
|
+
workflows = discoverWorkflows(effectiveCwd);
|
|
1190
|
+
} catch (e) {
|
|
1191
|
+
workflows = [];
|
|
1192
|
+
}
|
|
1193
|
+
for (var wi = 0; wi < workflows.length; wi++) {
|
|
1194
|
+
var wf = workflows[wi];
|
|
1195
|
+
if (seen[wf.name]) continue;
|
|
1196
|
+
seen[wf.name] = true;
|
|
1197
|
+
combined.push({ name: wf.name, desc: wf.description || "", type: "workflow" });
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
return combined;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function buildReadyResponse(skillNames, cwd) {
|
|
1155
1204
|
return {
|
|
1156
1205
|
models: _cachedModels,
|
|
1157
1206
|
defaultModel: _defaultModel,
|
|
1158
1207
|
skills: skillNames || [],
|
|
1159
|
-
slashCommands: skillNames
|
|
1208
|
+
slashCommands: buildEnrichedSlashCommands(skillNames, cwd),
|
|
1160
1209
|
fastModeState: null,
|
|
1161
1210
|
capabilities: {
|
|
1162
1211
|
thinking: true,
|
|
@@ -1278,7 +1327,7 @@ function createCodexAdapter(opts) {
|
|
|
1278
1327
|
|
|
1279
1328
|
// Already initialized - return cached result
|
|
1280
1329
|
if (_appServer && _appServer.started && _cachedModels.length > 0) {
|
|
1281
|
-
return Promise.resolve(buildReadyResponse([]));
|
|
1330
|
+
return Promise.resolve(buildReadyResponse([], _cwd));
|
|
1282
1331
|
}
|
|
1283
1332
|
|
|
1284
1333
|
// Deduplicate concurrent init calls
|
|
@@ -1455,7 +1504,7 @@ function createCodexAdapter(opts) {
|
|
|
1455
1504
|
_initPromise = null;
|
|
1456
1505
|
updateLastActiveAt();
|
|
1457
1506
|
|
|
1458
|
-
return buildReadyResponse(skillNames);
|
|
1507
|
+
return buildReadyResponse(skillNames, _cwd);
|
|
1459
1508
|
})();
|
|
1460
1509
|
|
|
1461
1510
|
return _initPromise;
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.4.0-beta.
|
|
6
|
+
"version": "1.4.0-beta.3",
|
|
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
|
-
"test": "node --test test/*.test.js",
|
|
13
|
+
"test": "node --test --test-force-exit test/*.test.js",
|
|
14
14
|
"semantic-release": "semantic-release"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|