@lifeaitools/clauth 1.5.40 → 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.
@@ -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") 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_"));
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") return "gws";
3128
- if (p === "/clauth") return "clauth";
3129
- if (p === "/fs") return "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
 
@@ -5009,15 +5011,43 @@ function sendTerminalMessage(session_id, message) {
5009
5011
  const turn = `\n\nUser: ${message}\nAssistant: ${response}`;
5010
5012
  const combined = s.context + turn;
5011
5013
  s.context = combined.length > 8000 ? combined.slice(combined.length - 8000) : combined;
5014
+ s.lastResponse = response;
5015
+ s.lastResponseAt = new Date().toISOString();
5016
+ s.turn = (s.turn || 0) + 1;
5012
5017
  s.status = 'ready';
5013
5018
  s.activeProc = null;
5014
- console.log(`[terminal] session ${session_id} turn complete code=${code}`);
5019
+ console.log(`[terminal] session ${session_id} turn=${s.turn} complete code=${code}`);
5015
5020
  }
5016
5021
  });
5017
5022
 
5018
5023
  return { queued: true, session_id };
5019
5024
  }
5020
5025
 
5026
+ function recvTerminalResponse(session_id, timeout_ms = 30000) {
5027
+ const session = terminalSessions.get(session_id);
5028
+ if (!session) return { error: 'not_found', message: `Session ${session_id} not found` };
5029
+
5030
+ // If already ready with a response, return it immediately
5031
+ if (session.status === 'ready' && session.lastResponse !== undefined) {
5032
+ return {
5033
+ session_id,
5034
+ status: 'ready',
5035
+ turn: session.turn || 0,
5036
+ response: session.lastResponse,
5037
+ responded_at: session.lastResponseAt,
5038
+ };
5039
+ }
5040
+
5041
+ // Session is still busy — caller should poll again
5042
+ return {
5043
+ session_id,
5044
+ status: session.status,
5045
+ turn: session.turn || 0,
5046
+ response: null,
5047
+ message: session.status === 'busy' ? 'Still processing — poll again in a few seconds' : 'No response yet',
5048
+ };
5049
+ }
5050
+
5021
5051
  function listTerminalSessions() {
5022
5052
  const sessions = [];
5023
5053
  for (const [, s] of terminalSessions) {
@@ -5043,6 +5073,100 @@ function stopTerminalSession(session_id) {
5043
5073
  return { stopped: true, session_id };
5044
5074
  }
5045
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
+
5046
5170
  const ENV_MAP = {
5047
5171
  "github": "GITHUB_TOKEN",
5048
5172
  "supabase-anon": "NEXT_PUBLIC_SUPABASE_ANON_KEY",
@@ -5256,6 +5380,18 @@ const MCP_TOOLS = [
5256
5380
  description: "List all active terminal sessions with their status (ready/busy/stopped), knowledge tier, and start time.",
5257
5381
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
5258
5382
  },
5383
+ {
5384
+ name: "terminal_recv",
5385
+ description: "Read the last response from a terminal session. Returns response if ready, or status='busy' if still processing. Poll every 3-5 seconds until status='ready'.",
5386
+ inputSchema: {
5387
+ type: "object",
5388
+ properties: {
5389
+ session_id: { type: "string", description: "Session ID returned by terminal_start" },
5390
+ },
5391
+ required: ["session_id"],
5392
+ additionalProperties: false,
5393
+ },
5394
+ },
5259
5395
  {
5260
5396
  name: "terminal_stop",
5261
5397
  description: "Stop a terminal session and remove it from memory. Kills any active process.",
@@ -5269,6 +5405,62 @@ const MCP_TOOLS = [
5269
5405
  },
5270
5406
  },
5271
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
+
5272
5464
  // ── Google Workspace (gws CLI) ──────────────────────────────────────────
5273
5465
  {
5274
5466
  name: "gws_run",
@@ -6005,6 +6197,14 @@ async function handleMcpTool(vault, name, args) {
6005
6197
  return mcpResult(JSON.stringify(listTerminalSessions()));
6006
6198
  }
6007
6199
 
6200
+ case "terminal_recv": {
6201
+ const { session_id } = args;
6202
+ if (!session_id) return mcpError("session_id required");
6203
+ const result = recvTerminalResponse(session_id);
6204
+ if (result.error) return mcpError(`${result.error}: ${result.message}`);
6205
+ return mcpResult(JSON.stringify(result));
6206
+ }
6207
+
6008
6208
  case "terminal_stop": {
6009
6209
  const { session_id } = args;
6010
6210
  if (!session_id) return mcpError("session_id required");
@@ -6013,6 +6213,42 @@ async function handleMcpTool(vault, name, args) {
6013
6213
  return mcpResult(JSON.stringify(result));
6014
6214
  }
6015
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
+
6016
6252
  default:
6017
6253
  return mcpError(`Unknown tool: ${name}`);
6018
6254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/clauth",
3
- "version": "1.5.40",
3
+ "version": "1.5.42",
4
4
  "description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
5
5
  "type": "module",
6
6
  "bin": {