@adhdev/daemon-core 0.6.19 → 0.6.21
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/dist/index.d.ts +3 -0
- package/dist/index.js +112 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/handler.ts +85 -0
- package/src/daemon/dev-server.ts +17 -5
package/package.json
CHANGED
package/src/commands/handler.ts
CHANGED
|
@@ -369,6 +369,12 @@ export class DaemonCommandHandler implements CommandHelpers {
|
|
|
369
369
|
case 'list_extension_modes': return Stream.handleExtensionScript(this, args, 'listModes');
|
|
370
370
|
case 'set_extension_mode': return Stream.handleExtensionScript(this, args, 'setMode');
|
|
371
371
|
|
|
372
|
+
// ─── Provider Auto-Fix / Clone (DevServer proxy) ──────────
|
|
373
|
+
case 'provider_auto_fix': return this.proxyDevServerPost(args, 'auto-implement');
|
|
374
|
+
case 'provider_auto_fix_cancel': return this.proxyDevServerPost(args, 'auto-implement/cancel');
|
|
375
|
+
case 'provider_auto_fix_status': return this.proxyDevServerGet(args, 'auto-implement/status');
|
|
376
|
+
case 'provider_clone': return this.proxyDevServerScaffold(args);
|
|
377
|
+
|
|
372
378
|
default:
|
|
373
379
|
return { success: false, error: `Unknown command: ${cmd}` };
|
|
374
380
|
}
|
|
@@ -398,4 +404,83 @@ export class DaemonCommandHandler implements CommandHelpers {
|
|
|
398
404
|
}
|
|
399
405
|
return { success: false, error: 'ProviderLoader not initialized' };
|
|
400
406
|
}
|
|
407
|
+
|
|
408
|
+
// ─── DevServer HTTP proxy helpers ─────────────────
|
|
409
|
+
// These bridge WS commands to the DevServer REST API (localhost:19280)
|
|
410
|
+
|
|
411
|
+
private async proxyDevServerPost(args: any, endpoint: string): Promise<CommandResult> {
|
|
412
|
+
const { providerType, ...body } = args || {};
|
|
413
|
+
if (!providerType) return { success: false, error: 'providerType required' };
|
|
414
|
+
try {
|
|
415
|
+
const http = await import('http');
|
|
416
|
+
const postData = JSON.stringify(body);
|
|
417
|
+
const result = await new Promise<any>((resolve, reject) => {
|
|
418
|
+
const req = http.request({
|
|
419
|
+
hostname: '127.0.0.1', port: 19280,
|
|
420
|
+
path: `/api/providers/${providerType}/${endpoint}`,
|
|
421
|
+
method: 'POST',
|
|
422
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
|
|
423
|
+
}, (res) => {
|
|
424
|
+
let data = '';
|
|
425
|
+
res.on('data', (chunk: Buffer) => data += chunk);
|
|
426
|
+
res.on('end', () => {
|
|
427
|
+
try { resolve(JSON.parse(data)); } catch { resolve({ raw: data }); }
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
req.on('error', reject);
|
|
431
|
+
req.write(postData);
|
|
432
|
+
req.end();
|
|
433
|
+
});
|
|
434
|
+
return { success: true, ...result };
|
|
435
|
+
} catch (e: any) {
|
|
436
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private async proxyDevServerGet(args: any, endpoint: string): Promise<CommandResult> {
|
|
441
|
+
const { providerType } = args || {};
|
|
442
|
+
if (!providerType) return { success: false, error: 'providerType required' };
|
|
443
|
+
try {
|
|
444
|
+
const http = await import('http');
|
|
445
|
+
const result = await new Promise<any>((resolve, reject) => {
|
|
446
|
+
http.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
447
|
+
let data = '';
|
|
448
|
+
res.on('data', (chunk: Buffer) => data += chunk);
|
|
449
|
+
res.on('end', () => {
|
|
450
|
+
try { resolve(JSON.parse(data)); } catch { resolve({ raw: data }); }
|
|
451
|
+
});
|
|
452
|
+
}).on('error', reject);
|
|
453
|
+
});
|
|
454
|
+
return { success: true, ...result };
|
|
455
|
+
} catch (e: any) {
|
|
456
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private async proxyDevServerScaffold(args: any): Promise<CommandResult> {
|
|
461
|
+
try {
|
|
462
|
+
const http = await import('http');
|
|
463
|
+
const postData = JSON.stringify(args || {});
|
|
464
|
+
const result = await new Promise<any>((resolve, reject) => {
|
|
465
|
+
const req = http.request({
|
|
466
|
+
hostname: '127.0.0.1', port: 19280,
|
|
467
|
+
path: '/api/scaffold',
|
|
468
|
+
method: 'POST',
|
|
469
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
|
|
470
|
+
}, (res) => {
|
|
471
|
+
let data = '';
|
|
472
|
+
res.on('data', (chunk: Buffer) => data += chunk);
|
|
473
|
+
res.on('end', () => {
|
|
474
|
+
try { resolve(JSON.parse(data)); } catch { resolve({ raw: data }); }
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
req.on('error', reject);
|
|
478
|
+
req.write(postData);
|
|
479
|
+
req.end();
|
|
480
|
+
});
|
|
481
|
+
return { success: true, ...result };
|
|
482
|
+
} catch (e: any) {
|
|
483
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
484
|
+
}
|
|
485
|
+
}
|
|
401
486
|
}
|
package/src/daemon/dev-server.ts
CHANGED
|
@@ -1824,7 +1824,7 @@ export class DevServer {
|
|
|
1824
1824
|
|
|
1825
1825
|
private async handleAutoImplement(type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
|
|
1826
1826
|
const body = await this.readBody(req);
|
|
1827
|
-
const { agent = 'claude-cli', functions, reference = 'antigravity', model } = body;
|
|
1827
|
+
const { agent = 'claude-cli', functions, reference = 'antigravity', model, comment } = body;
|
|
1828
1828
|
if (!functions || !Array.isArray(functions) || functions.length === 0) {
|
|
1829
1829
|
this.json(res, 400, { error: 'functions[] is required (e.g. ["readChat", "sendMessage"])' });
|
|
1830
1830
|
return;
|
|
@@ -1874,7 +1874,7 @@ export class DevServer {
|
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
1876
|
// 3. Build the prompt
|
|
1877
|
-
const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts);
|
|
1877
|
+
const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, comment);
|
|
1878
1878
|
|
|
1879
1879
|
// 4. Write prompt to temp file (avoids shell escaping issues with special chars)
|
|
1880
1880
|
const tmpDir = path.join(os.tmpdir(), 'adhdev-autoimpl');
|
|
@@ -2064,6 +2064,7 @@ export class DevServer {
|
|
|
2064
2064
|
this.sendAutoImplSSE({ event: 'progress', data: { function: '_init', status: 'spawning', message: `에이전트 실행 중: ${shellCmd.substring(0, 200)}... (prompt: ${prompt.length} chars)` } });
|
|
2065
2065
|
|
|
2066
2066
|
this.autoImplStatus = { running: true, type, progress: [] };
|
|
2067
|
+
const spawnedAt = Date.now();
|
|
2067
2068
|
|
|
2068
2069
|
let child: any;
|
|
2069
2070
|
let isPty = false;
|
|
@@ -2128,9 +2129,10 @@ export class DevServer {
|
|
|
2128
2129
|
|
|
2129
2130
|
approvalBuffer = (approvalBuffer + cleanData).slice(-1500);
|
|
2130
2131
|
|
|
2131
|
-
// Force exit on completion signal
|
|
2132
|
-
|
|
2133
|
-
|
|
2132
|
+
// Force exit on completion signal (ignore during first 15s — prompt echo contains the token)
|
|
2133
|
+
const elapsed = Date.now() - spawnedAt;
|
|
2134
|
+
if (elapsed > 15000 && approvalBuffer.includes('AUTO_IMPLEMENT_FINISHED')) {
|
|
2135
|
+
this.log(`Agent finished task after ${Math.round(elapsed/1000)}s. Terminating interactive CLI session to unblock pipeline.`);
|
|
2134
2136
|
this.sendAutoImplSSE({ event: 'output', data: { chunk: `\n[🤖 ADHDev Pipeline] Completion token detected. Proceeding...\n`, stream: 'stdout' } });
|
|
2135
2137
|
approvalBuffer = '';
|
|
2136
2138
|
|
|
@@ -2231,6 +2233,7 @@ export class DevServer {
|
|
|
2231
2233
|
functions: string[],
|
|
2232
2234
|
domContext: any,
|
|
2233
2235
|
referenceScripts: Record<string, string>,
|
|
2236
|
+
userComment?: string,
|
|
2234
2237
|
): string {
|
|
2235
2238
|
const lines: string[] = [];
|
|
2236
2239
|
|
|
@@ -2394,6 +2397,15 @@ export class DevServer {
|
|
|
2394
2397
|
lines.push('3. Use CDP evaluate to deeply inspect the DOM structure of the newly generated tables, code blocks, thought blocks, and tool calls.');
|
|
2395
2398
|
lines.push('4. Ensure `readChat` extracts `content` with precise markdown formatting (especially for tables/code) and assigns correct `kind` tags (`thought`, `tool`, `terminal`).');
|
|
2396
2399
|
lines.push('');
|
|
2400
|
+
// ── User-provided additional instructions ──
|
|
2401
|
+
if (userComment) {
|
|
2402
|
+
lines.push('## ⚠️ User Instructions (HIGH PRIORITY)');
|
|
2403
|
+
lines.push('The user has provided the following additional instructions. Follow them strictly:');
|
|
2404
|
+
lines.push('');
|
|
2405
|
+
lines.push(userComment);
|
|
2406
|
+
lines.push('');
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2397
2409
|
lines.push('Start NOW. Do not ask for permission. Explore the DOM -> Code -> Test.');
|
|
2398
2410
|
|
|
2399
2411
|
return lines.join('\n');
|