froggo-mission-control 1.2.21 → 1.2.23
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.
|
@@ -2,7 +2,7 @@ import { ENV } from '@/lib/env';
|
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
3
|
import { getDb } from '@/lib/database';
|
|
4
4
|
import { calcCostUsd } from '@/lib/env';
|
|
5
|
-
import { existsSync, readFileSync, statSync } from 'fs';
|
|
5
|
+
import { existsSync, readFileSync, statSync, mkdirSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import { homedir } from 'os';
|
|
8
8
|
import { spawn } from 'child_process';
|
|
@@ -301,10 +301,12 @@ export async function POST(
|
|
|
301
301
|
const resumeId = (existing && existing.soulMtime === sm) ? existing.sessionId : null;
|
|
302
302
|
|
|
303
303
|
const dir = join(HOME, 'mission-control', 'agents', id);
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
|
|
304
|
+
// Always use the agent workspace dir as cwd so Claude finds ~/mission-control/.mcp.json
|
|
305
|
+
// and ~/.claude/settings.json via directory traversal. Creating it if it doesn't exist.
|
|
306
|
+
// (Using HOME directly would skip ~/mission-control/ in the search path, causing MCP
|
|
307
|
+
// servers to not be found and all tool calls to silently fail → 120s timeout.)
|
|
308
|
+
try { if (!existsSync(dir)) mkdirSync(dir, { recursive: true }); } catch {}
|
|
309
|
+
const cwd = existsSync(dir) ? dir : HOME;
|
|
308
310
|
|
|
309
311
|
const { allowed, disallowed } = resolveAgentTools(id);
|
|
310
312
|
const args = [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import
|
|
2
|
+
import { ENV } from '@/lib/env';
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
3
4
|
|
|
4
5
|
export const runtime = 'nodejs';
|
|
5
6
|
|
|
@@ -10,25 +11,37 @@ export async function POST(request: NextRequest) {
|
|
|
10
11
|
return NextResponse.json({ error: 'message is required' }, { status: 400 });
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
14
|
-
if (!apiKey) {
|
|
15
|
-
return NextResponse.json({ success: false, error: 'ANTHROPIC_API_KEY not configured' }, { status: 424 });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const client = new Anthropic({ apiKey });
|
|
19
14
|
const systemPrompt = `You are a helpful assistant generating a ${tone} reply to a message. Be concise and direct. Only output the reply text, nothing else.`;
|
|
20
15
|
const userPrompt = context
|
|
21
16
|
? `Context: ${context}\n\nMessage to reply to: ${message}`
|
|
22
17
|
: `Message to reply to: ${message}`;
|
|
23
18
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
const { CLAUDECODE, CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_SESSION_ID, ...cleanEnv } = process.env;
|
|
20
|
+
void CLAUDECODE; void CLAUDE_CODE_ENTRYPOINT; void CLAUDE_CODE_SESSION_ID;
|
|
21
|
+
|
|
22
|
+
const result = spawnSync(
|
|
23
|
+
process.execPath,
|
|
24
|
+
[
|
|
25
|
+
ENV.CLAUDE_SCRIPT,
|
|
26
|
+
'--print',
|
|
27
|
+
'--output-format', 'text',
|
|
28
|
+
'--model', ENV.MODEL_TRIVIAL,
|
|
29
|
+
'--system-prompt', systemPrompt,
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
input: userPrompt,
|
|
33
|
+
encoding: 'utf-8',
|
|
34
|
+
env: cleanEnv as NodeJS.ProcessEnv,
|
|
35
|
+
timeout: 30_000,
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (result.error || result.status !== 0) {
|
|
40
|
+
console.error('generate-reply claude error:', result.stderr);
|
|
41
|
+
return NextResponse.json({ success: false, error: 'Claude CLI failed' }, { status: 500 });
|
|
42
|
+
}
|
|
30
43
|
|
|
31
|
-
const reply =
|
|
44
|
+
const reply = (result.stdout || '').trim();
|
|
32
45
|
return NextResponse.json({ success: true, reply });
|
|
33
46
|
} catch (error) {
|
|
34
47
|
console.error('POST /api/chat/generate-reply error:', error);
|
package/package.json
CHANGED