@16pxh/cli-bridge 1.0.3 → 1.0.4
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/lib/claude.mjs +2 -1
- package/lib/server.mjs +3 -3
- package/package.json +1 -1
package/lib/claude.mjs
CHANGED
|
@@ -25,9 +25,10 @@ export async function checkClaudeInstalled() {
|
|
|
25
25
|
* @param {{ timeoutMs?: number }} [options]
|
|
26
26
|
* @returns {Promise<{ result: string, session_id: string, duration_ms: number }>}
|
|
27
27
|
*/
|
|
28
|
-
export function runPrompt(prompt, { timeoutMs = 60000 } = {}) {
|
|
28
|
+
export function runPrompt(prompt, { timeoutMs = 60000, sessionId } = {}) {
|
|
29
29
|
return new Promise((resolve, reject) => {
|
|
30
30
|
const args = ['-p', prompt, '--output-format', 'json'];
|
|
31
|
+
if (sessionId) args.push('--resume', sessionId);
|
|
31
32
|
const child = spawn('claude', args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
32
33
|
|
|
33
34
|
activeProcess = child;
|
package/lib/server.mjs
CHANGED
|
@@ -143,7 +143,7 @@ export function startServer() {
|
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
const { prompt, images } = body;
|
|
146
|
+
const { prompt, images, session_id } = body;
|
|
147
147
|
if (!prompt || typeof prompt !== 'string') {
|
|
148
148
|
logRequest('POST', '/prompt', 400, `${c.red}missing prompt${c.reset}`);
|
|
149
149
|
json(res, 400, { error: 'Missing or invalid "prompt" field' });
|
|
@@ -161,11 +161,11 @@ export function startServer() {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
try {
|
|
164
|
-
const { result, session_id, duration_ms } = await runPrompt(fullPrompt);
|
|
164
|
+
const { result, session_id: responseSessionId, duration_ms } = await runPrompt(fullPrompt, { sessionId: session_id });
|
|
165
165
|
const resultPreview = truncateChars(result, 64);
|
|
166
166
|
logRequest('POST', '/prompt', 200, `${c.dim}${duration_ms}ms${c.reset}`);
|
|
167
167
|
console.log(`${c.dim}${timestamp()}${c.reset} ${c.green}←${c.reset} ${c.dim}${resultPreview}${c.reset}`);
|
|
168
|
-
json(res, 200, { success: true, result, session_id, duration_ms });
|
|
168
|
+
json(res, 200, { success: true, result, session_id: responseSessionId, duration_ms });
|
|
169
169
|
} catch (err) {
|
|
170
170
|
logRequest('POST', '/prompt', 500, `${c.red}${err.message}${c.reset}`);
|
|
171
171
|
json(res, 500, { error: err.message });
|