@lifeaitools/clauth 1.5.42 → 1.5.43
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 +36 -20
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -4919,7 +4919,7 @@ function findClaudeBinary() {
|
|
|
4919
4919
|
let activeCliWorkers = 0;
|
|
4920
4920
|
const MAX_CLI_WORKERS = 2;
|
|
4921
4921
|
|
|
4922
|
-
function spawnClaudeTask(prompt, jobId) {
|
|
4922
|
+
function spawnClaudeTask(prompt, jobId, cwd) {
|
|
4923
4923
|
if (activeCliWorkers >= MAX_CLI_WORKERS) {
|
|
4924
4924
|
return { error: 'concurrency_limit', message: `Max ${MAX_CLI_WORKERS} CLI workers active` };
|
|
4925
4925
|
}
|
|
@@ -4930,7 +4930,7 @@ function spawnClaudeTask(prompt, jobId) {
|
|
|
4930
4930
|
|
|
4931
4931
|
activeCliWorkers++;
|
|
4932
4932
|
const proc = spawnProc(binary, ['-p', prompt, '--dangerously-skip-permissions'], {
|
|
4933
|
-
cwd:
|
|
4933
|
+
cwd: cwd || CHITCHAT_FALLBACK_CWD,
|
|
4934
4934
|
env: process.env,
|
|
4935
4935
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4936
4936
|
shell: true,
|
|
@@ -4955,7 +4955,7 @@ function generateSessionId() {
|
|
|
4955
4955
|
return crypto.randomUUID();
|
|
4956
4956
|
}
|
|
4957
4957
|
|
|
4958
|
-
function startTerminalSession(name, knowledge_tier, context_md) {
|
|
4958
|
+
function startTerminalSession(name, knowledge_tier, context_md, cwd) {
|
|
4959
4959
|
const binary = findClaudeBinary();
|
|
4960
4960
|
if (!binary) {
|
|
4961
4961
|
return { error: 'binary_not_found', message: 'claude CLI not found in PATH or AppData/npm' };
|
|
@@ -4973,9 +4973,10 @@ function startTerminalSession(name, knowledge_tier, context_md) {
|
|
|
4973
4973
|
started_at: new Date().toISOString(),
|
|
4974
4974
|
context: initialContext,
|
|
4975
4975
|
activeProc: null,
|
|
4976
|
+
cwd: cwd || CHITCHAT_FALLBACK_CWD,
|
|
4976
4977
|
};
|
|
4977
4978
|
terminalSessions.set(session_id, session);
|
|
4978
|
-
console.log(`[terminal] started session ${session_id} name=${name}`);
|
|
4979
|
+
console.log(`[terminal] started session ${session_id} name=${name} cwd=${session.cwd}`);
|
|
4979
4980
|
return { session_id, status: 'ready' };
|
|
4980
4981
|
}
|
|
4981
4982
|
|
|
@@ -4992,7 +4993,7 @@ function sendTerminalMessage(session_id, message) {
|
|
|
4992
4993
|
const fullPrompt = `${session.context}\n\n---\nUser: ${message}`;
|
|
4993
4994
|
|
|
4994
4995
|
const proc = spawnProc(binary, ['-p', fullPrompt, '--dangerously-skip-permissions'], {
|
|
4995
|
-
cwd:
|
|
4996
|
+
cwd: session.cwd || CHITCHAT_FALLBACK_CWD,
|
|
4996
4997
|
env: process.env,
|
|
4997
4998
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4998
4999
|
shell: true,
|
|
@@ -5075,23 +5076,34 @@ function stopTerminalSession(session_id) {
|
|
|
5075
5076
|
|
|
5076
5077
|
// ── Chitchat helpers ──────────────────────────────────────────────────────
|
|
5077
5078
|
// Wrappers around terminal session logic, pre-configured for regen-root collab.
|
|
5078
|
-
//
|
|
5079
|
+
// cwd + bootstrap path are read from the vault's first fileserver mount at
|
|
5080
|
+
// call time — no hardcoded paths. Falls back to C:/Dev/regen-root if vault
|
|
5081
|
+
// is locked or no fileserver mount is configured.
|
|
5079
5082
|
|
|
5080
|
-
const
|
|
5081
|
-
const CHITCHAT_BOOTSTRAP_PATH = 'C:/Dev/regen-root/.rdc/guides/agent-bootstrap.md';
|
|
5083
|
+
const CHITCHAT_FALLBACK_CWD = 'C:/Dev/regen-root';
|
|
5082
5084
|
|
|
5083
|
-
function
|
|
5085
|
+
async function resolveChitchatRoot(vault) {
|
|
5084
5086
|
try {
|
|
5085
|
-
|
|
5087
|
+
const { mounts } = await getFileserverMounts(vault);
|
|
5088
|
+
if (mounts && mounts.length > 0) return mounts[0].path;
|
|
5089
|
+
} catch {}
|
|
5090
|
+
return CHITCHAT_FALLBACK_CWD;
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
async function readBootstrapContext(rootPath) {
|
|
5094
|
+
const bootstrapPath = path.join(rootPath, '.rdc', 'guides', 'agent-bootstrap.md');
|
|
5095
|
+
try {
|
|
5096
|
+
return fs.readFileSync(bootstrapPath, 'utf-8');
|
|
5086
5097
|
} catch {
|
|
5087
|
-
return
|
|
5098
|
+
return `# agent-bootstrap.md not found at ${bootstrapPath} — proceeding without corpus context\n`;
|
|
5088
5099
|
}
|
|
5089
5100
|
}
|
|
5090
5101
|
|
|
5091
|
-
function startChitchatSession(name) {
|
|
5092
|
-
const
|
|
5102
|
+
async function startChitchatSession(name, vault) {
|
|
5103
|
+
const rootPath = await resolveChitchatRoot(vault);
|
|
5104
|
+
const corpus = await readBootstrapContext(rootPath);
|
|
5093
5105
|
const session_id = generateSessionId();
|
|
5094
|
-
const preamble = `${corpus}\n\n---\nCollab session: ${name} | cwd: ${
|
|
5106
|
+
const preamble = `${corpus}\n\n---\nCollab session: ${name} | cwd: ${rootPath}\nRead the bootstrap above. Ready to receive tasks from claude.ai.`;
|
|
5095
5107
|
const session = {
|
|
5096
5108
|
session_id,
|
|
5097
5109
|
name,
|
|
@@ -5101,10 +5113,11 @@ function startChitchatSession(name) {
|
|
|
5101
5113
|
context: preamble,
|
|
5102
5114
|
activeProc: null,
|
|
5103
5115
|
is_chitchat: true,
|
|
5116
|
+
cwd: rootPath,
|
|
5104
5117
|
};
|
|
5105
5118
|
terminalSessions.set(session_id, session);
|
|
5106
|
-
console.log(`[chitchat] started session ${session_id} name=${name}`);
|
|
5107
|
-
return { session_id, status: 'ready', name };
|
|
5119
|
+
console.log(`[chitchat] started session ${session_id} name=${name} cwd=${rootPath}`);
|
|
5120
|
+
return { session_id, status: 'ready', name, cwd: rootPath };
|
|
5108
5121
|
}
|
|
5109
5122
|
|
|
5110
5123
|
function sendChitchatMessage(session_id, message) {
|
|
@@ -5121,7 +5134,7 @@ function sendChitchatMessage(session_id, message) {
|
|
|
5121
5134
|
const fullPrompt = `${session.context}\n\n---\nFrom claude.ai: ${message}`;
|
|
5122
5135
|
|
|
5123
5136
|
const proc = spawnProc(binary, ['-p', fullPrompt, '--dangerously-skip-permissions'], {
|
|
5124
|
-
cwd:
|
|
5137
|
+
cwd: session.cwd,
|
|
5125
5138
|
env: process.env,
|
|
5126
5139
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
5127
5140
|
shell: true,
|
|
@@ -5161,6 +5174,7 @@ function listChitchatSessions() {
|
|
|
5161
5174
|
status: s.status,
|
|
5162
5175
|
started_at: s.started_at,
|
|
5163
5176
|
turn: s.turn || 0,
|
|
5177
|
+
cwd: s.cwd,
|
|
5164
5178
|
});
|
|
5165
5179
|
}
|
|
5166
5180
|
}
|
|
@@ -6172,7 +6186,8 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6172
6186
|
case "monkey_dispatch": {
|
|
6173
6187
|
const { prompt, job_id } = args;
|
|
6174
6188
|
if (!prompt) return mcpError("prompt required");
|
|
6175
|
-
const
|
|
6189
|
+
const cwd = await resolveChitchatRoot(vault);
|
|
6190
|
+
const result = spawnClaudeTask(prompt, job_id || "untracked", cwd);
|
|
6176
6191
|
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6177
6192
|
return mcpResult(JSON.stringify(result));
|
|
6178
6193
|
}
|
|
@@ -6180,7 +6195,8 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6180
6195
|
case "terminal_start": {
|
|
6181
6196
|
const { name, knowledge_tier, context_md } = args;
|
|
6182
6197
|
if (!name) return mcpError("name required");
|
|
6183
|
-
const
|
|
6198
|
+
const cwd = await resolveChitchatRoot(vault);
|
|
6199
|
+
const result = startTerminalSession(name, knowledge_tier || 'db_only', context_md || null, cwd);
|
|
6184
6200
|
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6185
6201
|
return mcpResult(JSON.stringify(result));
|
|
6186
6202
|
}
|
|
@@ -6216,7 +6232,7 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6216
6232
|
case "chitchat_start": {
|
|
6217
6233
|
const { name } = args;
|
|
6218
6234
|
if (!name) return mcpError("name required");
|
|
6219
|
-
const result = startChitchatSession(name);
|
|
6235
|
+
const result = await startChitchatSession(name, vault);
|
|
6220
6236
|
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6221
6237
|
return mcpResult(JSON.stringify(result));
|
|
6222
6238
|
}
|