@lifeaitools/clauth 1.5.40 → 1.5.41
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 +49 -1
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -5009,15 +5009,43 @@ function sendTerminalMessage(session_id, message) {
|
|
|
5009
5009
|
const turn = `\n\nUser: ${message}\nAssistant: ${response}`;
|
|
5010
5010
|
const combined = s.context + turn;
|
|
5011
5011
|
s.context = combined.length > 8000 ? combined.slice(combined.length - 8000) : combined;
|
|
5012
|
+
s.lastResponse = response;
|
|
5013
|
+
s.lastResponseAt = new Date().toISOString();
|
|
5014
|
+
s.turn = (s.turn || 0) + 1;
|
|
5012
5015
|
s.status = 'ready';
|
|
5013
5016
|
s.activeProc = null;
|
|
5014
|
-
console.log(`[terminal] session ${session_id} turn complete code=${code}`);
|
|
5017
|
+
console.log(`[terminal] session ${session_id} turn=${s.turn} complete code=${code}`);
|
|
5015
5018
|
}
|
|
5016
5019
|
});
|
|
5017
5020
|
|
|
5018
5021
|
return { queued: true, session_id };
|
|
5019
5022
|
}
|
|
5020
5023
|
|
|
5024
|
+
function recvTerminalResponse(session_id, timeout_ms = 30000) {
|
|
5025
|
+
const session = terminalSessions.get(session_id);
|
|
5026
|
+
if (!session) return { error: 'not_found', message: `Session ${session_id} not found` };
|
|
5027
|
+
|
|
5028
|
+
// If already ready with a response, return it immediately
|
|
5029
|
+
if (session.status === 'ready' && session.lastResponse !== undefined) {
|
|
5030
|
+
return {
|
|
5031
|
+
session_id,
|
|
5032
|
+
status: 'ready',
|
|
5033
|
+
turn: session.turn || 0,
|
|
5034
|
+
response: session.lastResponse,
|
|
5035
|
+
responded_at: session.lastResponseAt,
|
|
5036
|
+
};
|
|
5037
|
+
}
|
|
5038
|
+
|
|
5039
|
+
// Session is still busy — caller should poll again
|
|
5040
|
+
return {
|
|
5041
|
+
session_id,
|
|
5042
|
+
status: session.status,
|
|
5043
|
+
turn: session.turn || 0,
|
|
5044
|
+
response: null,
|
|
5045
|
+
message: session.status === 'busy' ? 'Still processing — poll again in a few seconds' : 'No response yet',
|
|
5046
|
+
};
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5021
5049
|
function listTerminalSessions() {
|
|
5022
5050
|
const sessions = [];
|
|
5023
5051
|
for (const [, s] of terminalSessions) {
|
|
@@ -5256,6 +5284,18 @@ const MCP_TOOLS = [
|
|
|
5256
5284
|
description: "List all active terminal sessions with their status (ready/busy/stopped), knowledge tier, and start time.",
|
|
5257
5285
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5258
5286
|
},
|
|
5287
|
+
{
|
|
5288
|
+
name: "terminal_recv",
|
|
5289
|
+
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'.",
|
|
5290
|
+
inputSchema: {
|
|
5291
|
+
type: "object",
|
|
5292
|
+
properties: {
|
|
5293
|
+
session_id: { type: "string", description: "Session ID returned by terminal_start" },
|
|
5294
|
+
},
|
|
5295
|
+
required: ["session_id"],
|
|
5296
|
+
additionalProperties: false,
|
|
5297
|
+
},
|
|
5298
|
+
},
|
|
5259
5299
|
{
|
|
5260
5300
|
name: "terminal_stop",
|
|
5261
5301
|
description: "Stop a terminal session and remove it from memory. Kills any active process.",
|
|
@@ -6005,6 +6045,14 @@ async function handleMcpTool(vault, name, args) {
|
|
|
6005
6045
|
return mcpResult(JSON.stringify(listTerminalSessions()));
|
|
6006
6046
|
}
|
|
6007
6047
|
|
|
6048
|
+
case "terminal_recv": {
|
|
6049
|
+
const { session_id } = args;
|
|
6050
|
+
if (!session_id) return mcpError("session_id required");
|
|
6051
|
+
const result = recvTerminalResponse(session_id);
|
|
6052
|
+
if (result.error) return mcpError(`${result.error}: ${result.message}`);
|
|
6053
|
+
return mcpResult(JSON.stringify(result));
|
|
6054
|
+
}
|
|
6055
|
+
|
|
6008
6056
|
case "terminal_stop": {
|
|
6009
6057
|
const { session_id } = args;
|
|
6010
6058
|
if (!session_id) return mcpError("session_id required");
|