@adhdev/daemon-core 0.6.18 → 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 +122 -9
- 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 +28 -10
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
|
|
@@ -10411,7 +10509,7 @@ var DevServer = class _DevServer {
|
|
|
10411
10509
|
this.json(res, 400, { error: `Script '${scriptName}' not found in provider '${type}'`, available: provider.scripts ? Object.keys(provider.scripts) : [] });
|
|
10412
10510
|
return;
|
|
10413
10511
|
}
|
|
10414
|
-
const cdp = this.getCdp(scriptIdeType);
|
|
10512
|
+
const cdp = this.getCdp(scriptIdeType || type);
|
|
10415
10513
|
if (!cdp) {
|
|
10416
10514
|
this.json(res, 503, { error: "No CDP connection available" });
|
|
10417
10515
|
return;
|
|
@@ -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`);
|
|
@@ -12130,9 +12228,11 @@ var DevServer = class _DevServer {
|
|
|
12130
12228
|
const baseArgs = [...spawn3.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
12131
12229
|
let shellCmd;
|
|
12132
12230
|
if (command === "claude") {
|
|
12133
|
-
const args = [...baseArgs, "--
|
|
12231
|
+
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
12232
|
+
if (model) args.push("--model", model);
|
|
12134
12233
|
const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
|
|
12135
|
-
|
|
12234
|
+
const metaPrompt = `Read the file at ${promptFile} and follow ALL the instructions. Implement the specific function requested, then test it via CDP curl targeting 127.0.0.1:19280, wait for confirmation of success, and then close. DO NOT start working on other features not listed in the prompt constraint.`;
|
|
12235
|
+
shellCmd = `${command} ${escapedArgs} -p "${metaPrompt}"`;
|
|
12136
12236
|
} else if (command === "gemini") {
|
|
12137
12237
|
const args = [...baseArgs, "-y", "-s", "false"];
|
|
12138
12238
|
if (model) args.push("-m", model);
|
|
@@ -12148,7 +12248,7 @@ var DevServer = class _DevServer {
|
|
|
12148
12248
|
}
|
|
12149
12249
|
if (model) args.push("--model", model);
|
|
12150
12250
|
const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
|
|
12151
|
-
const metaPrompt = `Read the file at ${promptFile} and follow ALL
|
|
12251
|
+
const metaPrompt = `Read the file at ${promptFile} and follow ALL instructions recursively. You have full authority to implement ALL required script files, update provider.json configurations based on the reference patterns, and independently test them against 127.0.0.1:19280 via CDP CURL. Upon complete validation of ALL assigned files, print exactly "AUTO_IMPLEMENT_FINISHED" to gracefully close the pipeline. DO NOT WAIT FOR APPROVAL, execute completely autonomously.`;
|
|
12152
12252
|
shellCmd = `${command} ${escapedArgs} "${metaPrompt}"`;
|
|
12153
12253
|
} else {
|
|
12154
12254
|
const escapedArgs = baseArgs.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
|
|
@@ -12156,6 +12256,7 @@ var DevServer = class _DevServer {
|
|
|
12156
12256
|
}
|
|
12157
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)` } });
|
|
12158
12258
|
this.autoImplStatus = { running: true, type, progress: [] };
|
|
12259
|
+
const spawnedAt = Date.now();
|
|
12159
12260
|
let child;
|
|
12160
12261
|
let isPty = false;
|
|
12161
12262
|
const { spawn: spawnFn } = await import("child_process");
|
|
@@ -12208,8 +12309,9 @@ var DevServer = class _DevServer {
|
|
|
12208
12309
|
const checkAutoApproval = (chunk, writeFn) => {
|
|
12209
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, " ");
|
|
12210
12311
|
approvalBuffer = (approvalBuffer + cleanData).slice(-1500);
|
|
12211
|
-
|
|
12212
|
-
|
|
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.`);
|
|
12213
12315
|
this.sendAutoImplSSE({ event: "output", data: { chunk: `
|
|
12214
12316
|
[\u{1F916} ADHDev Pipeline] Completion token detected. Proceeding...
|
|
12215
12317
|
`, stream: "stdout" } });
|
|
@@ -12311,7 +12413,7 @@ var DevServer = class _DevServer {
|
|
|
12311
12413
|
this.json(res, 500, { error: `Auto-implement failed: ${e.message}` });
|
|
12312
12414
|
}
|
|
12313
12415
|
}
|
|
12314
|
-
buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts) {
|
|
12416
|
+
buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, userComment) {
|
|
12315
12417
|
const lines = [];
|
|
12316
12418
|
lines.push("You are implementing browser automation scripts for an IDE provider.");
|
|
12317
12419
|
lines.push("Be concise. Do NOT explain your reasoning. Just edit files directly.");
|
|
@@ -12427,6 +12529,10 @@ var DevServer = class _DevServer {
|
|
|
12427
12529
|
lines.push("1. Edit the script files to implement working code");
|
|
12428
12530
|
lines.push("2. After editing, TEST each function using the DevConsole API (see below)");
|
|
12429
12531
|
lines.push("3. If a test fails, fix the implementation and re-test");
|
|
12532
|
+
lines.push("4. **IMPORTANT VERIFICATION LOGIC**: When verifying your implementation, beware of state contamination! You MUST perform strict Integration Testing:");
|
|
12533
|
+
lines.push(" - `openPanel`: Toggle buttons are usually located in the top header, sidebar, or activity bar. Prefer finding and clicking these native UI buttons over extreme CSS injection hacks if possible.");
|
|
12534
|
+
lines.push(" - `listSessions`: If sessions are unmounted when the panel is closed, try to explicitly interact with the UI to open the history/sessions view (e.g., clicking a history icon usually found near the chat header) BEFORE scraping.");
|
|
12535
|
+
lines.push(" - `switchSession`: Prove your switch was successful by subsequently calling `readChat` and explicitly checking that the chat context has actually changed.");
|
|
12430
12536
|
lines.push("");
|
|
12431
12537
|
lines.push("## YOU MUST EXPLORE THE DOM YOURSELF!");
|
|
12432
12538
|
lines.push("I have NOT provided you with the DOM snapshot. You MUST use your command-line tools to discover the IDE structure dynamically!");
|
|
@@ -12461,6 +12567,13 @@ var DevServer = class _DevServer {
|
|
|
12461
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.");
|
|
12462
12568
|
lines.push("4. Ensure `readChat` extracts `content` with precise markdown formatting (especially for tables/code) and assigns correct `kind` tags (`thought`, `tool`, `terminal`).");
|
|
12463
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
|
+
}
|
|
12464
12577
|
lines.push("Start NOW. Do not ask for permission. Explore the DOM -> Code -> Test.");
|
|
12465
12578
|
return lines.join("\n");
|
|
12466
12579
|
}
|