@lifeaitools/clauth 1.5.41 → 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 +219 -15
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -2921,7 +2921,7 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
2921
2921
|
}
|
|
2922
2922
|
|
|
2923
2923
|
// ── Hosts that bypass OAuth (fresh domains for claude.ai compatibility) ──
|
|
2924
|
-
const NOAUTH_HOSTS = ["fs.regendevcorp.com", "clauth.regendevcorp.com"];
|
|
2924
|
+
const NOAUTH_HOSTS = ["fs.regendevcorp.com", "clauth.regendevcorp.com", "chitchat.regendevcorp.com"];
|
|
2925
2925
|
const requestHost = (req.headers.host || "").split(":")[0].toLowerCase();
|
|
2926
2926
|
const noAuthHost = NOAUTH_HOSTS.includes(requestHost);
|
|
2927
2927
|
|
|
@@ -3115,18 +3115,20 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
3115
3115
|
}
|
|
3116
3116
|
|
|
3117
3117
|
// ── MCP path helpers ──
|
|
3118
|
-
const MCP_PATHS = ["/mcp", "/gws", "/clauth", "/fs"];
|
|
3118
|
+
const MCP_PATHS = ["/mcp", "/gws", "/clauth", "/fs", "/chitchat"];
|
|
3119
3119
|
const isMcpPath = MCP_PATHS.includes(reqPath);
|
|
3120
3120
|
function toolsForPath(p) {
|
|
3121
|
-
if (p === "/gws")
|
|
3122
|
-
if (p === "/clauth")
|
|
3123
|
-
if (p === "/fs")
|
|
3121
|
+
if (p === "/gws") return MCP_TOOLS.filter(t => t.name.startsWith("gws_"));
|
|
3122
|
+
if (p === "/clauth") return MCP_TOOLS.filter(t => t.name.startsWith("clauth_") || t.name === "monkey_dispatch" || t.name.startsWith("terminal_"));
|
|
3123
|
+
if (p === "/fs") return MCP_TOOLS.filter(t => t.name.startsWith("fs_"));
|
|
3124
|
+
if (p === "/chitchat") return MCP_TOOLS.filter(t => t.name.startsWith("chitchat_"));
|
|
3124
3125
|
return MCP_TOOLS; // /mcp — all tools
|
|
3125
3126
|
}
|
|
3126
3127
|
function serverNameForPath(p) {
|
|
3127
|
-
if (p === "/gws")
|
|
3128
|
-
if (p === "/clauth")
|
|
3129
|
-
if (p === "/fs")
|
|
3128
|
+
if (p === "/gws") return "gws";
|
|
3129
|
+
if (p === "/clauth") return "clauth";
|
|
3130
|
+
if (p === "/fs") return "fs";
|
|
3131
|
+
if (p === "/chitchat") return "chitchat";
|
|
3130
3132
|
return "clauth";
|
|
3131
3133
|
}
|
|
3132
3134
|
|
|
@@ -4917,7 +4919,7 @@ function findClaudeBinary() {
|
|
|
4917
4919
|
let activeCliWorkers = 0;
|
|
4918
4920
|
const MAX_CLI_WORKERS = 2;
|
|
4919
4921
|
|
|
4920
|
-
function spawnClaudeTask(prompt, jobId) {
|
|
4922
|
+
function spawnClaudeTask(prompt, jobId, cwd) {
|
|
4921
4923
|
if (activeCliWorkers >= MAX_CLI_WORKERS) {
|
|
4922
4924
|
return { error: 'concurrency_limit', message: `Max ${MAX_CLI_WORKERS} CLI workers active` };
|
|
4923
4925
|
}
|
|
@@ -4928,7 +4930,7 @@ function spawnClaudeTask(prompt, jobId) {
|
|
|
4928
4930
|
|
|
4929
4931
|
activeCliWorkers++;
|
|
4930
4932
|
const proc = spawnProc(binary, ['-p', prompt, '--dangerously-skip-permissions'], {
|
|
4931
|
-
cwd:
|
|
4933
|
+
cwd: cwd || CHITCHAT_FALLBACK_CWD,
|
|
4932
4934
|
env: process.env,
|
|
4933
4935
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4934
4936
|
shell: true,
|
|
@@ -4953,7 +4955,7 @@ function generateSessionId() {
|
|
|
4953
4955
|
return crypto.randomUUID();
|
|
4954
4956
|
}
|
|
4955
4957
|
|
|
4956
|
-
function startTerminalSession(name, knowledge_tier, context_md) {
|
|
4958
|
+
function startTerminalSession(name, knowledge_tier, context_md, cwd) {
|
|
4957
4959
|
const binary = findClaudeBinary();
|
|
4958
4960
|
if (!binary) {
|
|
4959
4961
|
return { error: 'binary_not_found', message: 'claude CLI not found in PATH or AppData/npm' };
|
|
@@ -4971,9 +4973,10 @@ function startTerminalSession(name, knowledge_tier, context_md) {
|
|
|
4971
4973
|
started_at: new Date().toISOString(),
|
|
4972
4974
|
context: initialContext,
|
|
4973
4975
|
activeProc: null,
|
|
4976
|
+
cwd: cwd || CHITCHAT_FALLBACK_CWD,
|
|
4974
4977
|
};
|
|
4975
4978
|
terminalSessions.set(session_id, session);
|
|
4976
|
-
console.log(`[terminal] started session ${session_id} name=${name}`);
|
|
4979
|
+
console.log(`[terminal] started session ${session_id} name=${name} cwd=${session.cwd}`);
|
|
4977
4980
|
return { session_id, status: 'ready' };
|
|
4978
4981
|
}
|
|
4979
4982
|
|
|
@@ -4990,7 +4993,7 @@ function sendTerminalMessage(session_id, message) {
|
|
|
4990
4993
|
const fullPrompt = `${session.context}\n\n---\nUser: ${message}`;
|
|
4991
4994
|
|
|
4992
4995
|
const proc = spawnProc(binary, ['-p', fullPrompt, '--dangerously-skip-permissions'], {
|
|
4993
|
-
cwd:
|
|
4996
|
+
cwd: session.cwd || CHITCHAT_FALLBACK_CWD,
|
|
4994
4997
|
env: process.env,
|
|
4995
4998
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4996
4999
|
shell: true,
|
|
@@ -5071,6 +5074,113 @@ function stopTerminalSession(session_id) {
|
|
|
5071
5074
|
return { stopped: true, session_id };
|
|
5072
5075
|
}
|
|
5073
5076
|
|
|
5077
|
+
// ── Chitchat helpers ──────────────────────────────────────────────────────
|
|
5078
|
+
// Wrappers around terminal session logic, pre-configured for regen-root collab.
|
|
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.
|
|
5082
|
+
|
|
5083
|
+
const CHITCHAT_FALLBACK_CWD = 'C:/Dev/regen-root';
|
|
5084
|
+
|
|
5085
|
+
async function resolveChitchatRoot(vault) {
|
|
5086
|
+
try {
|
|
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');
|
|
5097
|
+
} catch {
|
|
5098
|
+
return `# agent-bootstrap.md not found at ${bootstrapPath} — proceeding without corpus context\n`;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
|
|
5102
|
+
async function startChitchatSession(name, vault) {
|
|
5103
|
+
const rootPath = await resolveChitchatRoot(vault);
|
|
5104
|
+
const corpus = await readBootstrapContext(rootPath);
|
|
5105
|
+
const session_id = generateSessionId();
|
|
5106
|
+
const preamble = `${corpus}\n\n---\nCollab session: ${name} | cwd: ${rootPath}\nRead the bootstrap above. Ready to receive tasks from claude.ai.`;
|
|
5107
|
+
const session = {
|
|
5108
|
+
session_id,
|
|
5109
|
+
name,
|
|
5110
|
+
knowledge_tier: 'corpus',
|
|
5111
|
+
status: 'ready',
|
|
5112
|
+
started_at: new Date().toISOString(),
|
|
5113
|
+
context: preamble,
|
|
5114
|
+
activeProc: null,
|
|
5115
|
+
is_chitchat: true,
|
|
5116
|
+
cwd: rootPath,
|
|
5117
|
+
};
|
|
5118
|
+
terminalSessions.set(session_id, session);
|
|
5119
|
+
console.log(`[chitchat] started session ${session_id} name=${name} cwd=${rootPath}`);
|
|
5120
|
+
return { session_id, status: 'ready', name, cwd: rootPath };
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5123
|
+
function sendChitchatMessage(session_id, message) {
|
|
5124
|
+
const session = terminalSessions.get(session_id);
|
|
5125
|
+
if (!session) return { error: 'not_found', message: `Chitchat session ${session_id} not found` };
|
|
5126
|
+
if (!session.is_chitchat) return { error: 'wrong_type', message: 'Use terminal_send for non-chitchat sessions' };
|
|
5127
|
+
if (session.status === 'stopped') return { error: 'stopped', message: 'Session is stopped' };
|
|
5128
|
+
if (session.status === 'busy') return { error: 'session_busy', message: 'Session is busy — try again shortly' };
|
|
5129
|
+
|
|
5130
|
+
const binary = findClaudeBinary();
|
|
5131
|
+
if (!binary) return { error: 'binary_not_found', message: 'claude CLI not found in PATH or AppData/npm' };
|
|
5132
|
+
|
|
5133
|
+
session.status = 'busy';
|
|
5134
|
+
const fullPrompt = `${session.context}\n\n---\nFrom claude.ai: ${message}`;
|
|
5135
|
+
|
|
5136
|
+
const proc = spawnProc(binary, ['-p', fullPrompt, '--dangerously-skip-permissions'], {
|
|
5137
|
+
cwd: session.cwd,
|
|
5138
|
+
env: process.env,
|
|
5139
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
5140
|
+
shell: true,
|
|
5141
|
+
});
|
|
5142
|
+
session.activeProc = proc;
|
|
5143
|
+
|
|
5144
|
+
let stdout = '';
|
|
5145
|
+
let stderr = '';
|
|
5146
|
+
proc.stdout.on('data', d => { stdout += d; });
|
|
5147
|
+
proc.stderr.on('data', d => { stderr += d; });
|
|
5148
|
+
proc.on('close', (code) => {
|
|
5149
|
+
if (terminalSessions.has(session_id)) {
|
|
5150
|
+
const s = terminalSessions.get(session_id);
|
|
5151
|
+
const response = stdout.trim() || stderr.trim() || '(no output)';
|
|
5152
|
+
const turn = `\n\nFrom claude.ai: ${message}\nClaude Code: ${response}`;
|
|
5153
|
+
const combined = s.context + turn;
|
|
5154
|
+
s.context = combined.length > 8000 ? combined.slice(combined.length - 8000) : combined;
|
|
5155
|
+
s.lastResponse = response;
|
|
5156
|
+
s.lastResponseAt = new Date().toISOString();
|
|
5157
|
+
s.turn = (s.turn || 0) + 1;
|
|
5158
|
+
s.status = 'ready';
|
|
5159
|
+
s.activeProc = null;
|
|
5160
|
+
console.log(`[chitchat] session ${session_id} turn=${s.turn} complete code=${code}`);
|
|
5161
|
+
}
|
|
5162
|
+
});
|
|
5163
|
+
|
|
5164
|
+
return { queued: true, session_id };
|
|
5165
|
+
}
|
|
5166
|
+
|
|
5167
|
+
function listChitchatSessions() {
|
|
5168
|
+
const sessions = [];
|
|
5169
|
+
for (const [, s] of terminalSessions) {
|
|
5170
|
+
if (s.is_chitchat) {
|
|
5171
|
+
sessions.push({
|
|
5172
|
+
session_id: s.session_id,
|
|
5173
|
+
name: s.name,
|
|
5174
|
+
status: s.status,
|
|
5175
|
+
started_at: s.started_at,
|
|
5176
|
+
turn: s.turn || 0,
|
|
5177
|
+
cwd: s.cwd,
|
|
5178
|
+
});
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
return sessions;
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5074
5184
|
const ENV_MAP = {
|
|
5075
5185
|
"github": "GITHUB_TOKEN",
|
|
5076
5186
|
"supabase-anon": "NEXT_PUBLIC_SUPABASE_ANON_KEY",
|
|
@@ -5309,6 +5419,62 @@ const MCP_TOOLS = [
|
|
|
5309
5419
|
},
|
|
5310
5420
|
},
|
|
5311
5421
|
|
|
5422
|
+
// ── Chitchat — regen-root collab sessions (claude.ai ↔ Claude Code) ────
|
|
5423
|
+
{
|
|
5424
|
+
name: "chitchat_start",
|
|
5425
|
+
description: "Start a collab session with Claude Code at C:/Dev/regen-root. Auto-injects agent-bootstrap.md as corpus context. Returns session_id for subsequent calls.",
|
|
5426
|
+
inputSchema: {
|
|
5427
|
+
type: "object",
|
|
5428
|
+
properties: {
|
|
5429
|
+
name: { type: "string", description: "Session name slug, e.g. 'collab-sidebar-tabs'" },
|
|
5430
|
+
},
|
|
5431
|
+
required: ["name"],
|
|
5432
|
+
additionalProperties: false,
|
|
5433
|
+
},
|
|
5434
|
+
},
|
|
5435
|
+
{
|
|
5436
|
+
name: "chitchat_send",
|
|
5437
|
+
description: "Send a message to an active chitchat session. Claude Code runs async — call chitchat_recv to get the response. Returns immediately with { queued: true }.",
|
|
5438
|
+
inputSchema: {
|
|
5439
|
+
type: "object",
|
|
5440
|
+
properties: {
|
|
5441
|
+
session_id: { type: "string", description: "Session ID from chitchat_start" },
|
|
5442
|
+
message: { type: "string", description: "Message or task to send to Claude Code" },
|
|
5443
|
+
},
|
|
5444
|
+
required: ["session_id", "message"],
|
|
5445
|
+
additionalProperties: false,
|
|
5446
|
+
},
|
|
5447
|
+
},
|
|
5448
|
+
{
|
|
5449
|
+
name: "chitchat_recv",
|
|
5450
|
+
description: "Poll for Claude Code's response. Returns { status: 'busy' } while processing, { status: 'ready', response: '...' } when done. Poll every 5 seconds.",
|
|
5451
|
+
inputSchema: {
|
|
5452
|
+
type: "object",
|
|
5453
|
+
properties: {
|
|
5454
|
+
session_id: { type: "string", description: "Session ID from chitchat_start" },
|
|
5455
|
+
},
|
|
5456
|
+
required: ["session_id"],
|
|
5457
|
+
additionalProperties: false,
|
|
5458
|
+
},
|
|
5459
|
+
},
|
|
5460
|
+
{
|
|
5461
|
+
name: "chitchat_list",
|
|
5462
|
+
description: "List all active chitchat sessions with their status and start time.",
|
|
5463
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5464
|
+
},
|
|
5465
|
+
{
|
|
5466
|
+
name: "chitchat_stop",
|
|
5467
|
+
description: "End a chitchat session and free its memory. Always call this when the collab task is done.",
|
|
5468
|
+
inputSchema: {
|
|
5469
|
+
type: "object",
|
|
5470
|
+
properties: {
|
|
5471
|
+
session_id: { type: "string", description: "Session ID to stop" },
|
|
5472
|
+
},
|
|
5473
|
+
required: ["session_id"],
|
|
5474
|
+
additionalProperties: false,
|
|
5475
|
+
},
|
|
5476
|
+
},
|
|
5477
|
+
|
|
5312
5478
|
// ── Google Workspace (gws CLI) ──────────────────────────────────────────
|
|
5313
5479
|
{
|
|
5314
5480
|
name: "gws_run",
|
|
@@ -6020,7 +6186,8 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6020
6186
|
case "monkey_dispatch": {
|
|
6021
6187
|
const { prompt, job_id } = args;
|
|
6022
6188
|
if (!prompt) return mcpError("prompt required");
|
|
6023
|
-
const
|
|
6189
|
+
const cwd = await resolveChitchatRoot(vault);
|
|
6190
|
+
const result = spawnClaudeTask(prompt, job_id || "untracked", cwd);
|
|
6024
6191
|
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6025
6192
|
return mcpResult(JSON.stringify(result));
|
|
6026
6193
|
}
|
|
@@ -6028,7 +6195,8 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6028
6195
|
case "terminal_start": {
|
|
6029
6196
|
const { name, knowledge_tier, context_md } = args;
|
|
6030
6197
|
if (!name) return mcpError("name required");
|
|
6031
|
-
const
|
|
6198
|
+
const cwd = await resolveChitchatRoot(vault);
|
|
6199
|
+
const result = startTerminalSession(name, knowledge_tier || 'db_only', context_md || null, cwd);
|
|
6032
6200
|
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6033
6201
|
return mcpResult(JSON.stringify(result));
|
|
6034
6202
|
}
|
|
@@ -6061,6 +6229,42 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6061
6229
|
return mcpResult(JSON.stringify(result));
|
|
6062
6230
|
}
|
|
6063
6231
|
|
|
6232
|
+
case "chitchat_start": {
|
|
6233
|
+
const { name } = args;
|
|
6234
|
+
if (!name) return mcpError("name required");
|
|
6235
|
+
const result = await startChitchatSession(name, vault);
|
|
6236
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6237
|
+
return mcpResult(JSON.stringify(result));
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6240
|
+
case "chitchat_send": {
|
|
6241
|
+
const { session_id, message } = args;
|
|
6242
|
+
if (!session_id || !message) return mcpError("session_id and message required");
|
|
6243
|
+
const result = sendChitchatMessage(session_id, message);
|
|
6244
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6245
|
+
return mcpResult(JSON.stringify(result));
|
|
6246
|
+
}
|
|
6247
|
+
|
|
6248
|
+
case "chitchat_recv": {
|
|
6249
|
+
const { session_id } = args;
|
|
6250
|
+
if (!session_id) return mcpError("session_id required");
|
|
6251
|
+
const result = recvTerminalResponse(session_id);
|
|
6252
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6253
|
+
return mcpResult(JSON.stringify(result));
|
|
6254
|
+
}
|
|
6255
|
+
|
|
6256
|
+
case "chitchat_list": {
|
|
6257
|
+
return mcpResult(JSON.stringify(listChitchatSessions()));
|
|
6258
|
+
}
|
|
6259
|
+
|
|
6260
|
+
case "chitchat_stop": {
|
|
6261
|
+
const { session_id } = args;
|
|
6262
|
+
if (!session_id) return mcpError("session_id required");
|
|
6263
|
+
const result = stopTerminalSession(session_id);
|
|
6264
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6265
|
+
return mcpResult(JSON.stringify(result));
|
|
6266
|
+
}
|
|
6267
|
+
|
|
6064
6268
|
default:
|
|
6065
6269
|
return mcpError(`Unknown tool: ${name}`);
|
|
6066
6270
|
}
|