@lifeaitools/clauth 1.17.0 → 1.18.0
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/cli/commands/serve.js +72 -2
- package/package.json +65 -65
package/cli/commands/serve.js
CHANGED
|
@@ -7907,10 +7907,26 @@ function startTerminalSession(name, knowledge_tier, context_md, cwd) {
|
|
|
7907
7907
|
started_at: new Date().toISOString(),
|
|
7908
7908
|
context: initialContext,
|
|
7909
7909
|
activeProc: null,
|
|
7910
|
+
warmWorker: null,
|
|
7910
7911
|
cwd: cwd || CHITCHAT_FALLBACK_CWD,
|
|
7911
7912
|
};
|
|
7913
|
+
|
|
7914
|
+
// Try to acquire a warm worker from the agent pool for low-latency turns
|
|
7915
|
+
try {
|
|
7916
|
+
const pool = getAgentPool();
|
|
7917
|
+
if (pool) {
|
|
7918
|
+
const worker = pool.acquireForSession(session_id);
|
|
7919
|
+
if (worker) {
|
|
7920
|
+
session.warmWorker = worker;
|
|
7921
|
+
console.log(`[terminal] session ${session_id} acquired warm worker`);
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
} catch (e) {
|
|
7925
|
+
console.log(`[terminal] session ${session_id} warm pool unavailable, will use cold path: ${e.message}`);
|
|
7926
|
+
}
|
|
7927
|
+
|
|
7912
7928
|
terminalSessions.set(session_id, session);
|
|
7913
|
-
console.log(`[terminal] started session ${session_id} name=${name} cwd=${session.cwd}`);
|
|
7929
|
+
console.log(`[terminal] started session ${session_id} name=${name} cwd=${session.cwd} warm=${!!session.warmWorker}`);
|
|
7914
7930
|
return { session_id, status: 'ready' };
|
|
7915
7931
|
}
|
|
7916
7932
|
|
|
@@ -7920,6 +7936,49 @@ function sendTerminalMessage(session_id, message) {
|
|
|
7920
7936
|
if (session.status === 'stopped') return { error: 'stopped', message: 'Session is stopped' };
|
|
7921
7937
|
if (session.status === 'busy') return { error: 'session_busy', message: 'Session is busy — try again shortly' };
|
|
7922
7938
|
|
|
7939
|
+
// ── Warm-pool path: dispatch to the pinned worker (maintains its own context) ──
|
|
7940
|
+
if (session.warmWorker && !session.warmWorker.isDead()) {
|
|
7941
|
+
session.status = 'busy';
|
|
7942
|
+
const pool = getAgentPool();
|
|
7943
|
+
pool.dispatchToSession(session_id, { prompt: message })
|
|
7944
|
+
.then((result) => {
|
|
7945
|
+
if (!terminalSessions.has(session_id)) return;
|
|
7946
|
+
const s = terminalSessions.get(session_id);
|
|
7947
|
+
const response = result.ok
|
|
7948
|
+
? (result.stdout || '').trim() || '(no output)'
|
|
7949
|
+
: `(warm dispatch error: ${result.error || 'unknown'})`;
|
|
7950
|
+
// Still update rolling context for terminal_recv compatibility
|
|
7951
|
+
const turn = `\n\nUser: ${message}\nAssistant: ${response}`;
|
|
7952
|
+
const combined = s.context + turn;
|
|
7953
|
+
s.context = combined.length > 8000 ? combined.slice(combined.length - 8000) : combined;
|
|
7954
|
+
s.lastResponse = response;
|
|
7955
|
+
s.lastResponseAt = new Date().toISOString();
|
|
7956
|
+
s.turn = (s.turn || 0) + 1;
|
|
7957
|
+
s.status = 'ready';
|
|
7958
|
+
s.activeProc = null;
|
|
7959
|
+
console.log(`[terminal] session ${session_id} turn=${s.turn} complete (warm) ok=${result.ok}`);
|
|
7960
|
+
|
|
7961
|
+
// If the warm worker died during dispatch, clear it so next turn falls back to cold
|
|
7962
|
+
if (!result.ok && result.error === 'pinned_worker_died') {
|
|
7963
|
+
s.warmWorker = null;
|
|
7964
|
+
console.log(`[terminal] session ${session_id} warm worker died, next turn will use cold path`);
|
|
7965
|
+
}
|
|
7966
|
+
})
|
|
7967
|
+
.catch((err) => {
|
|
7968
|
+
if (!terminalSessions.has(session_id)) return;
|
|
7969
|
+
const s = terminalSessions.get(session_id);
|
|
7970
|
+
s.lastResponse = `(warm dispatch failed: ${err.message})`;
|
|
7971
|
+
s.lastResponseAt = new Date().toISOString();
|
|
7972
|
+
s.turn = (s.turn || 0) + 1;
|
|
7973
|
+
s.status = 'ready';
|
|
7974
|
+
s.activeProc = null;
|
|
7975
|
+
s.warmWorker = null; // fall back to cold on next turn
|
|
7976
|
+
console.log(`[terminal] session ${session_id} warm dispatch threw, falling back to cold: ${err.message}`);
|
|
7977
|
+
});
|
|
7978
|
+
return { queued: true, session_id, warm: true };
|
|
7979
|
+
}
|
|
7980
|
+
|
|
7981
|
+
// ── Cold-spawn fallback: original path ──
|
|
7923
7982
|
const binary = findClaudeBinary();
|
|
7924
7983
|
if (!binary) return { error: 'binary_not_found', message: 'claude CLI not found in PATH or AppData/npm' };
|
|
7925
7984
|
|
|
@@ -7955,7 +8014,7 @@ function sendTerminalMessage(session_id, message) {
|
|
|
7955
8014
|
}
|
|
7956
8015
|
});
|
|
7957
8016
|
|
|
7958
|
-
return { queued: true, session_id };
|
|
8017
|
+
return { queued: true, session_id, warm: false };
|
|
7959
8018
|
}
|
|
7960
8019
|
|
|
7961
8020
|
function recvTerminalResponse(session_id, timeout_ms = 30000) {
|
|
@@ -8003,6 +8062,17 @@ function stopTerminalSession(session_id) {
|
|
|
8003
8062
|
if (session.activeProc) {
|
|
8004
8063
|
try { session.activeProc.kill(); } catch {}
|
|
8005
8064
|
}
|
|
8065
|
+
// Release the warm worker back to the pool
|
|
8066
|
+
if (session.warmWorker) {
|
|
8067
|
+
try {
|
|
8068
|
+
const pool = getAgentPool();
|
|
8069
|
+
pool.releaseSession(session_id);
|
|
8070
|
+
console.log(`[terminal] session ${session_id} released warm worker`);
|
|
8071
|
+
} catch (e) {
|
|
8072
|
+
console.log(`[terminal] session ${session_id} warm worker release failed: ${e.message}`);
|
|
8073
|
+
}
|
|
8074
|
+
session.warmWorker = null;
|
|
8075
|
+
}
|
|
8006
8076
|
terminalSessions.delete(session_id);
|
|
8007
8077
|
console.log(`[terminal] stopped session ${session_id}`);
|
|
8008
8078
|
return { stopped: true, session_id };
|
package/package.json
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lifeaitools/clauth",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"clauth": "./cli/index.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "bash scripts/build.sh",
|
|
11
|
-
"test": "node --test cli/commands/scrub.test.js cli/api.classify.test.js && node test-auth-verdict.mjs",
|
|
12
|
-
"test:agent-pool": "node test/agent-pool.test.mjs",
|
|
13
|
-
"test:call-agent-10": "node test/call-agent-10-skills.test.mjs",
|
|
14
|
-
"test:call-agent-guard": "node test/call-agent-guard.test.mjs",
|
|
15
|
-
"postinstall": "node scripts/postinstall.js",
|
|
16
|
-
"worker:start": "node cli/index.js serve",
|
|
17
|
-
"worker:stop": "curl -s http://127.0.0.1:52437/shutdown 2>nul || taskkill /F /IM cloudflared.exe 2>nul & exit 0",
|
|
18
|
-
"worker:restart": "npm run worker:stop && timeout /t 3 /nobreak >nul && npm run worker:start"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"chalk": "^5.3.0",
|
|
22
|
-
"commander": "^12.1.0",
|
|
23
|
-
"conf": "^13.0.0",
|
|
24
|
-
"inquirer": "^10.1.0",
|
|
25
|
-
"node-fetch": "^3.3.2",
|
|
26
|
-
"ora": "^8.1.0",
|
|
27
|
-
"@vscode/ripgrep": "^1.15.9",
|
|
28
|
-
"fast-glob": "^3.3.2"
|
|
29
|
-
},
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=18.0.0"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"lifeai",
|
|
35
|
-
"credentials",
|
|
36
|
-
"vault",
|
|
37
|
-
"cli",
|
|
38
|
-
"prt"
|
|
39
|
-
],
|
|
40
|
-
"author": "Dave Ladouceur <dave@life.ai>",
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "https://github.com/LIFEAI/clauth.git"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"javascript-obfuscator": "^5.3.0"
|
|
48
|
-
},
|
|
49
|
-
"files": [
|
|
50
|
-
"cli/",
|
|
51
|
-
"scripts/bin/",
|
|
52
|
-
"scripts/bootstrap.cjs",
|
|
53
|
-
"scripts/build.sh",
|
|
54
|
-
"scripts/postinstall.js",
|
|
55
|
-
"supabase/",
|
|
56
|
-
".clauth-skill/",
|
|
57
|
-
"install.sh",
|
|
58
|
-
"install.ps1",
|
|
59
|
-
"README.md"
|
|
60
|
-
],
|
|
61
|
-
"publishConfig": {
|
|
62
|
-
"access": "public"
|
|
63
|
-
},
|
|
64
|
-
"homepage": "https://github.com/LIFEAI/clauth"
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@lifeaitools/clauth",
|
|
3
|
+
"version": "1.18.0",
|
|
4
|
+
"description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"clauth": "./cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "bash scripts/build.sh",
|
|
11
|
+
"test": "node --test cli/commands/scrub.test.js cli/api.classify.test.js && node test-auth-verdict.mjs",
|
|
12
|
+
"test:agent-pool": "node test/agent-pool.test.mjs",
|
|
13
|
+
"test:call-agent-10": "node test/call-agent-10-skills.test.mjs",
|
|
14
|
+
"test:call-agent-guard": "node test/call-agent-guard.test.mjs",
|
|
15
|
+
"postinstall": "node scripts/postinstall.js",
|
|
16
|
+
"worker:start": "node cli/index.js serve",
|
|
17
|
+
"worker:stop": "curl -s http://127.0.0.1:52437/shutdown 2>nul || taskkill /F /IM cloudflared.exe 2>nul & exit 0",
|
|
18
|
+
"worker:restart": "npm run worker:stop && timeout /t 3 /nobreak >nul && npm run worker:start"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"chalk": "^5.3.0",
|
|
22
|
+
"commander": "^12.1.0",
|
|
23
|
+
"conf": "^13.0.0",
|
|
24
|
+
"inquirer": "^10.1.0",
|
|
25
|
+
"node-fetch": "^3.3.2",
|
|
26
|
+
"ora": "^8.1.0",
|
|
27
|
+
"@vscode/ripgrep": "^1.15.9",
|
|
28
|
+
"fast-glob": "^3.3.2"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.0.0"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"lifeai",
|
|
35
|
+
"credentials",
|
|
36
|
+
"vault",
|
|
37
|
+
"cli",
|
|
38
|
+
"prt"
|
|
39
|
+
],
|
|
40
|
+
"author": "Dave Ladouceur <dave@life.ai>",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/LIFEAI/clauth.git"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"javascript-obfuscator": "^5.3.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"cli/",
|
|
51
|
+
"scripts/bin/",
|
|
52
|
+
"scripts/bootstrap.cjs",
|
|
53
|
+
"scripts/build.sh",
|
|
54
|
+
"scripts/postinstall.js",
|
|
55
|
+
"supabase/",
|
|
56
|
+
".clauth-skill/",
|
|
57
|
+
"install.sh",
|
|
58
|
+
"install.ps1",
|
|
59
|
+
"README.md"
|
|
60
|
+
],
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/LIFEAI/clauth"
|
|
65
|
+
}
|