@lifeaitools/clauth 1.5.41 → 1.5.42
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 +196 -8
- 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
|
|
|
@@ -5071,6 +5073,100 @@ function stopTerminalSession(session_id) {
|
|
|
5071
5073
|
return { stopped: true, session_id };
|
|
5072
5074
|
}
|
|
5073
5075
|
|
|
5076
|
+
// ── Chitchat helpers ──────────────────────────────────────────────────────
|
|
5077
|
+
// Wrappers around terminal session logic, pre-configured for regen-root collab.
|
|
5078
|
+
// Auto-injects agent-bootstrap.md as corpus context on every new session.
|
|
5079
|
+
|
|
5080
|
+
const CHITCHAT_CWD = 'C:/Dev/regen-root';
|
|
5081
|
+
const CHITCHAT_BOOTSTRAP_PATH = 'C:/Dev/regen-root/.rdc/guides/agent-bootstrap.md';
|
|
5082
|
+
|
|
5083
|
+
function readBootstrapContext() {
|
|
5084
|
+
try {
|
|
5085
|
+
return fs.readFileSync(CHITCHAT_BOOTSTRAP_PATH, 'utf-8');
|
|
5086
|
+
} catch {
|
|
5087
|
+
return '# agent-bootstrap.md not found — proceeding without corpus context\n';
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
function startChitchatSession(name) {
|
|
5092
|
+
const corpus = readBootstrapContext();
|
|
5093
|
+
const session_id = generateSessionId();
|
|
5094
|
+
const preamble = `${corpus}\n\n---\nCollab session: ${name} | cwd: ${CHITCHAT_CWD}\nRead the bootstrap above. Ready to receive tasks from claude.ai.`;
|
|
5095
|
+
const session = {
|
|
5096
|
+
session_id,
|
|
5097
|
+
name,
|
|
5098
|
+
knowledge_tier: 'corpus',
|
|
5099
|
+
status: 'ready',
|
|
5100
|
+
started_at: new Date().toISOString(),
|
|
5101
|
+
context: preamble,
|
|
5102
|
+
activeProc: null,
|
|
5103
|
+
is_chitchat: true,
|
|
5104
|
+
};
|
|
5105
|
+
terminalSessions.set(session_id, session);
|
|
5106
|
+
console.log(`[chitchat] started session ${session_id} name=${name}`);
|
|
5107
|
+
return { session_id, status: 'ready', name };
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
function sendChitchatMessage(session_id, message) {
|
|
5111
|
+
const session = terminalSessions.get(session_id);
|
|
5112
|
+
if (!session) return { error: 'not_found', message: `Chitchat session ${session_id} not found` };
|
|
5113
|
+
if (!session.is_chitchat) return { error: 'wrong_type', message: 'Use terminal_send for non-chitchat sessions' };
|
|
5114
|
+
if (session.status === 'stopped') return { error: 'stopped', message: 'Session is stopped' };
|
|
5115
|
+
if (session.status === 'busy') return { error: 'session_busy', message: 'Session is busy — try again shortly' };
|
|
5116
|
+
|
|
5117
|
+
const binary = findClaudeBinary();
|
|
5118
|
+
if (!binary) return { error: 'binary_not_found', message: 'claude CLI not found in PATH or AppData/npm' };
|
|
5119
|
+
|
|
5120
|
+
session.status = 'busy';
|
|
5121
|
+
const fullPrompt = `${session.context}\n\n---\nFrom claude.ai: ${message}`;
|
|
5122
|
+
|
|
5123
|
+
const proc = spawnProc(binary, ['-p', fullPrompt, '--dangerously-skip-permissions'], {
|
|
5124
|
+
cwd: CHITCHAT_CWD,
|
|
5125
|
+
env: process.env,
|
|
5126
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
5127
|
+
shell: true,
|
|
5128
|
+
});
|
|
5129
|
+
session.activeProc = proc;
|
|
5130
|
+
|
|
5131
|
+
let stdout = '';
|
|
5132
|
+
let stderr = '';
|
|
5133
|
+
proc.stdout.on('data', d => { stdout += d; });
|
|
5134
|
+
proc.stderr.on('data', d => { stderr += d; });
|
|
5135
|
+
proc.on('close', (code) => {
|
|
5136
|
+
if (terminalSessions.has(session_id)) {
|
|
5137
|
+
const s = terminalSessions.get(session_id);
|
|
5138
|
+
const response = stdout.trim() || stderr.trim() || '(no output)';
|
|
5139
|
+
const turn = `\n\nFrom claude.ai: ${message}\nClaude Code: ${response}`;
|
|
5140
|
+
const combined = s.context + turn;
|
|
5141
|
+
s.context = combined.length > 8000 ? combined.slice(combined.length - 8000) : combined;
|
|
5142
|
+
s.lastResponse = response;
|
|
5143
|
+
s.lastResponseAt = new Date().toISOString();
|
|
5144
|
+
s.turn = (s.turn || 0) + 1;
|
|
5145
|
+
s.status = 'ready';
|
|
5146
|
+
s.activeProc = null;
|
|
5147
|
+
console.log(`[chitchat] session ${session_id} turn=${s.turn} complete code=${code}`);
|
|
5148
|
+
}
|
|
5149
|
+
});
|
|
5150
|
+
|
|
5151
|
+
return { queued: true, session_id };
|
|
5152
|
+
}
|
|
5153
|
+
|
|
5154
|
+
function listChitchatSessions() {
|
|
5155
|
+
const sessions = [];
|
|
5156
|
+
for (const [, s] of terminalSessions) {
|
|
5157
|
+
if (s.is_chitchat) {
|
|
5158
|
+
sessions.push({
|
|
5159
|
+
session_id: s.session_id,
|
|
5160
|
+
name: s.name,
|
|
5161
|
+
status: s.status,
|
|
5162
|
+
started_at: s.started_at,
|
|
5163
|
+
turn: s.turn || 0,
|
|
5164
|
+
});
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
return sessions;
|
|
5168
|
+
}
|
|
5169
|
+
|
|
5074
5170
|
const ENV_MAP = {
|
|
5075
5171
|
"github": "GITHUB_TOKEN",
|
|
5076
5172
|
"supabase-anon": "NEXT_PUBLIC_SUPABASE_ANON_KEY",
|
|
@@ -5309,6 +5405,62 @@ const MCP_TOOLS = [
|
|
|
5309
5405
|
},
|
|
5310
5406
|
},
|
|
5311
5407
|
|
|
5408
|
+
// ── Chitchat — regen-root collab sessions (claude.ai ↔ Claude Code) ────
|
|
5409
|
+
{
|
|
5410
|
+
name: "chitchat_start",
|
|
5411
|
+
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.",
|
|
5412
|
+
inputSchema: {
|
|
5413
|
+
type: "object",
|
|
5414
|
+
properties: {
|
|
5415
|
+
name: { type: "string", description: "Session name slug, e.g. 'collab-sidebar-tabs'" },
|
|
5416
|
+
},
|
|
5417
|
+
required: ["name"],
|
|
5418
|
+
additionalProperties: false,
|
|
5419
|
+
},
|
|
5420
|
+
},
|
|
5421
|
+
{
|
|
5422
|
+
name: "chitchat_send",
|
|
5423
|
+
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 }.",
|
|
5424
|
+
inputSchema: {
|
|
5425
|
+
type: "object",
|
|
5426
|
+
properties: {
|
|
5427
|
+
session_id: { type: "string", description: "Session ID from chitchat_start" },
|
|
5428
|
+
message: { type: "string", description: "Message or task to send to Claude Code" },
|
|
5429
|
+
},
|
|
5430
|
+
required: ["session_id", "message"],
|
|
5431
|
+
additionalProperties: false,
|
|
5432
|
+
},
|
|
5433
|
+
},
|
|
5434
|
+
{
|
|
5435
|
+
name: "chitchat_recv",
|
|
5436
|
+
description: "Poll for Claude Code's response. Returns { status: 'busy' } while processing, { status: 'ready', response: '...' } when done. Poll every 5 seconds.",
|
|
5437
|
+
inputSchema: {
|
|
5438
|
+
type: "object",
|
|
5439
|
+
properties: {
|
|
5440
|
+
session_id: { type: "string", description: "Session ID from chitchat_start" },
|
|
5441
|
+
},
|
|
5442
|
+
required: ["session_id"],
|
|
5443
|
+
additionalProperties: false,
|
|
5444
|
+
},
|
|
5445
|
+
},
|
|
5446
|
+
{
|
|
5447
|
+
name: "chitchat_list",
|
|
5448
|
+
description: "List all active chitchat sessions with their status and start time.",
|
|
5449
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5450
|
+
},
|
|
5451
|
+
{
|
|
5452
|
+
name: "chitchat_stop",
|
|
5453
|
+
description: "End a chitchat session and free its memory. Always call this when the collab task is done.",
|
|
5454
|
+
inputSchema: {
|
|
5455
|
+
type: "object",
|
|
5456
|
+
properties: {
|
|
5457
|
+
session_id: { type: "string", description: "Session ID to stop" },
|
|
5458
|
+
},
|
|
5459
|
+
required: ["session_id"],
|
|
5460
|
+
additionalProperties: false,
|
|
5461
|
+
},
|
|
5462
|
+
},
|
|
5463
|
+
|
|
5312
5464
|
// ── Google Workspace (gws CLI) ──────────────────────────────────────────
|
|
5313
5465
|
{
|
|
5314
5466
|
name: "gws_run",
|
|
@@ -6061,6 +6213,42 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6061
6213
|
return mcpResult(JSON.stringify(result));
|
|
6062
6214
|
}
|
|
6063
6215
|
|
|
6216
|
+
case "chitchat_start": {
|
|
6217
|
+
const { name } = args;
|
|
6218
|
+
if (!name) return mcpError("name required");
|
|
6219
|
+
const result = startChitchatSession(name);
|
|
6220
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6221
|
+
return mcpResult(JSON.stringify(result));
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
case "chitchat_send": {
|
|
6225
|
+
const { session_id, message } = args;
|
|
6226
|
+
if (!session_id || !message) return mcpError("session_id and message required");
|
|
6227
|
+
const result = sendChitchatMessage(session_id, message);
|
|
6228
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6229
|
+
return mcpResult(JSON.stringify(result));
|
|
6230
|
+
}
|
|
6231
|
+
|
|
6232
|
+
case "chitchat_recv": {
|
|
6233
|
+
const { session_id } = args;
|
|
6234
|
+
if (!session_id) return mcpError("session_id required");
|
|
6235
|
+
const result = recvTerminalResponse(session_id);
|
|
6236
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6237
|
+
return mcpResult(JSON.stringify(result));
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6240
|
+
case "chitchat_list": {
|
|
6241
|
+
return mcpResult(JSON.stringify(listChitchatSessions()));
|
|
6242
|
+
}
|
|
6243
|
+
|
|
6244
|
+
case "chitchat_stop": {
|
|
6245
|
+
const { session_id } = args;
|
|
6246
|
+
if (!session_id) return mcpError("session_id required");
|
|
6247
|
+
const result = stopTerminalSession(session_id);
|
|
6248
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6249
|
+
return mcpResult(JSON.stringify(result));
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6064
6252
|
default:
|
|
6065
6253
|
return mcpError(`Unknown tool: ${name}`);
|
|
6066
6254
|
}
|