@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/dist/index.d.ts
CHANGED
|
@@ -1720,6 +1720,9 @@ declare class DaemonCommandHandler implements CommandHelpers {
|
|
|
1720
1720
|
private dispatch;
|
|
1721
1721
|
private handleGetRecentWorkspaces;
|
|
1722
1722
|
private handleRefreshScripts;
|
|
1723
|
+
private proxyDevServerPost;
|
|
1724
|
+
private proxyDevServerGet;
|
|
1725
|
+
private proxyDevServerScaffold;
|
|
1723
1726
|
}
|
|
1724
1727
|
|
|
1725
1728
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5573,6 +5573,15 @@ var DaemonCommandHandler = class {
|
|
|
5573
5573
|
return handleExtensionScript(this, args, "listModes");
|
|
5574
5574
|
case "set_extension_mode":
|
|
5575
5575
|
return handleExtensionScript(this, args, "setMode");
|
|
5576
|
+
// ─── Provider Auto-Fix / Clone (DevServer proxy) ──────────
|
|
5577
|
+
case "provider_auto_fix":
|
|
5578
|
+
return this.proxyDevServerPost(args, "auto-implement");
|
|
5579
|
+
case "provider_auto_fix_cancel":
|
|
5580
|
+
return this.proxyDevServerPost(args, "auto-implement/cancel");
|
|
5581
|
+
case "provider_auto_fix_status":
|
|
5582
|
+
return this.proxyDevServerGet(args, "auto-implement/status");
|
|
5583
|
+
case "provider_clone":
|
|
5584
|
+
return this.proxyDevServerScaffold(args);
|
|
5576
5585
|
default:
|
|
5577
5586
|
return { success: false, error: `Unknown command: ${cmd}` };
|
|
5578
5587
|
}
|
|
@@ -5600,6 +5609,95 @@ var DaemonCommandHandler = class {
|
|
|
5600
5609
|
}
|
|
5601
5610
|
return { success: false, error: "ProviderLoader not initialized" };
|
|
5602
5611
|
}
|
|
5612
|
+
// ─── DevServer HTTP proxy helpers ─────────────────
|
|
5613
|
+
// These bridge WS commands to the DevServer REST API (localhost:19280)
|
|
5614
|
+
async proxyDevServerPost(args, endpoint) {
|
|
5615
|
+
const { providerType, ...body } = args || {};
|
|
5616
|
+
if (!providerType) return { success: false, error: "providerType required" };
|
|
5617
|
+
try {
|
|
5618
|
+
const http3 = await import("http");
|
|
5619
|
+
const postData = JSON.stringify(body);
|
|
5620
|
+
const result = await new Promise((resolve8, reject) => {
|
|
5621
|
+
const req = http3.request({
|
|
5622
|
+
hostname: "127.0.0.1",
|
|
5623
|
+
port: 19280,
|
|
5624
|
+
path: `/api/providers/${providerType}/${endpoint}`,
|
|
5625
|
+
method: "POST",
|
|
5626
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
5627
|
+
}, (res) => {
|
|
5628
|
+
let data = "";
|
|
5629
|
+
res.on("data", (chunk) => data += chunk);
|
|
5630
|
+
res.on("end", () => {
|
|
5631
|
+
try {
|
|
5632
|
+
resolve8(JSON.parse(data));
|
|
5633
|
+
} catch {
|
|
5634
|
+
resolve8({ raw: data });
|
|
5635
|
+
}
|
|
5636
|
+
});
|
|
5637
|
+
});
|
|
5638
|
+
req.on("error", reject);
|
|
5639
|
+
req.write(postData);
|
|
5640
|
+
req.end();
|
|
5641
|
+
});
|
|
5642
|
+
return { success: true, ...result };
|
|
5643
|
+
} catch (e) {
|
|
5644
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
async proxyDevServerGet(args, endpoint) {
|
|
5648
|
+
const { providerType } = args || {};
|
|
5649
|
+
if (!providerType) return { success: false, error: "providerType required" };
|
|
5650
|
+
try {
|
|
5651
|
+
const http3 = await import("http");
|
|
5652
|
+
const result = await new Promise((resolve8, reject) => {
|
|
5653
|
+
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5654
|
+
let data = "";
|
|
5655
|
+
res.on("data", (chunk) => data += chunk);
|
|
5656
|
+
res.on("end", () => {
|
|
5657
|
+
try {
|
|
5658
|
+
resolve8(JSON.parse(data));
|
|
5659
|
+
} catch {
|
|
5660
|
+
resolve8({ raw: data });
|
|
5661
|
+
}
|
|
5662
|
+
});
|
|
5663
|
+
}).on("error", reject);
|
|
5664
|
+
});
|
|
5665
|
+
return { success: true, ...result };
|
|
5666
|
+
} catch (e) {
|
|
5667
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
async proxyDevServerScaffold(args) {
|
|
5671
|
+
try {
|
|
5672
|
+
const http3 = await import("http");
|
|
5673
|
+
const postData = JSON.stringify(args || {});
|
|
5674
|
+
const result = await new Promise((resolve8, reject) => {
|
|
5675
|
+
const req = http3.request({
|
|
5676
|
+
hostname: "127.0.0.1",
|
|
5677
|
+
port: 19280,
|
|
5678
|
+
path: "/api/scaffold",
|
|
5679
|
+
method: "POST",
|
|
5680
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
5681
|
+
}, (res) => {
|
|
5682
|
+
let data = "";
|
|
5683
|
+
res.on("data", (chunk) => data += chunk);
|
|
5684
|
+
res.on("end", () => {
|
|
5685
|
+
try {
|
|
5686
|
+
resolve8(JSON.parse(data));
|
|
5687
|
+
} catch {
|
|
5688
|
+
resolve8({ raw: data });
|
|
5689
|
+
}
|
|
5690
|
+
});
|
|
5691
|
+
});
|
|
5692
|
+
req.on("error", reject);
|
|
5693
|
+
req.write(postData);
|
|
5694
|
+
req.end();
|
|
5695
|
+
});
|
|
5696
|
+
return { success: true, ...result };
|
|
5697
|
+
} catch (e) {
|
|
5698
|
+
return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5603
5701
|
};
|
|
5604
5702
|
|
|
5605
5703
|
// src/launch.ts
|
|
@@ -11926,7 +12024,7 @@ var DevServer = class _DevServer {
|
|
|
11926
12024
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
11927
12025
|
async handleAutoImplement(type, req, res) {
|
|
11928
12026
|
const body = await this.readBody(req);
|
|
11929
|
-
const { agent = "claude-cli", functions, reference = "antigravity", model } = body;
|
|
12027
|
+
const { agent = "claude-cli", functions, reference = "antigravity", model, comment } = body;
|
|
11930
12028
|
if (!functions || !Array.isArray(functions) || functions.length === 0) {
|
|
11931
12029
|
this.json(res, 400, { error: 'functions[] is required (e.g. ["readChat", "sendMessage"])' });
|
|
11932
12030
|
return;
|
|
@@ -11975,7 +12073,7 @@ var DevServer = class _DevServer {
|
|
|
11975
12073
|
}
|
|
11976
12074
|
}
|
|
11977
12075
|
}
|
|
11978
|
-
const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts);
|
|
12076
|
+
const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, comment);
|
|
11979
12077
|
const tmpDir = path12.join(os14.tmpdir(), "adhdev-autoimpl");
|
|
11980
12078
|
if (!fs9.existsSync(tmpDir)) fs9.mkdirSync(tmpDir, { recursive: true });
|
|
11981
12079
|
const promptFile = path12.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
@@ -12158,6 +12256,7 @@ var DevServer = class _DevServer {
|
|
|
12158
12256
|
}
|
|
12159
12257
|
this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "spawning", message: `\uC5D0\uC774\uC804\uD2B8 \uC2E4\uD589 \uC911: ${shellCmd.substring(0, 200)}... (prompt: ${prompt.length} chars)` } });
|
|
12160
12258
|
this.autoImplStatus = { running: true, type, progress: [] };
|
|
12259
|
+
const spawnedAt = Date.now();
|
|
12161
12260
|
let child;
|
|
12162
12261
|
let isPty = false;
|
|
12163
12262
|
const { spawn: spawnFn } = await import("child_process");
|
|
@@ -12210,8 +12309,9 @@ var DevServer = class _DevServer {
|
|
|
12210
12309
|
const checkAutoApproval = (chunk, writeFn) => {
|
|
12211
12310
|
const cleanData = chunk.replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][^\x1B]*\x1B\\/g, "").replace(/ +/g, " ");
|
|
12212
12311
|
approvalBuffer = (approvalBuffer + cleanData).slice(-1500);
|
|
12213
|
-
|
|
12214
|
-
|
|
12312
|
+
const elapsed = Date.now() - spawnedAt;
|
|
12313
|
+
if (elapsed > 15e3 && approvalBuffer.includes("AUTO_IMPLEMENT_FINISHED")) {
|
|
12314
|
+
this.log(`Agent finished task after ${Math.round(elapsed / 1e3)}s. Terminating interactive CLI session to unblock pipeline.`);
|
|
12215
12315
|
this.sendAutoImplSSE({ event: "output", data: { chunk: `
|
|
12216
12316
|
[\u{1F916} ADHDev Pipeline] Completion token detected. Proceeding...
|
|
12217
12317
|
`, stream: "stdout" } });
|
|
@@ -12313,7 +12413,7 @@ var DevServer = class _DevServer {
|
|
|
12313
12413
|
this.json(res, 500, { error: `Auto-implement failed: ${e.message}` });
|
|
12314
12414
|
}
|
|
12315
12415
|
}
|
|
12316
|
-
buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts) {
|
|
12416
|
+
buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, userComment) {
|
|
12317
12417
|
const lines = [];
|
|
12318
12418
|
lines.push("You are implementing browser automation scripts for an IDE provider.");
|
|
12319
12419
|
lines.push("Be concise. Do NOT explain your reasoning. Just edit files directly.");
|
|
@@ -12467,6 +12567,13 @@ var DevServer = class _DevServer {
|
|
|
12467
12567
|
lines.push("3. Use CDP evaluate to deeply inspect the DOM structure of the newly generated tables, code blocks, thought blocks, and tool calls.");
|
|
12468
12568
|
lines.push("4. Ensure `readChat` extracts `content` with precise markdown formatting (especially for tables/code) and assigns correct `kind` tags (`thought`, `tool`, `terminal`).");
|
|
12469
12569
|
lines.push("");
|
|
12570
|
+
if (userComment) {
|
|
12571
|
+
lines.push("## \u26A0\uFE0F User Instructions (HIGH PRIORITY)");
|
|
12572
|
+
lines.push("The user has provided the following additional instructions. Follow them strictly:");
|
|
12573
|
+
lines.push("");
|
|
12574
|
+
lines.push(userComment);
|
|
12575
|
+
lines.push("");
|
|
12576
|
+
}
|
|
12470
12577
|
lines.push("Start NOW. Do not ask for permission. Explore the DOM -> Code -> Test.");
|
|
12471
12578
|
return lines.join("\n");
|
|
12472
12579
|
}
|