@adhdev/daemon-core 0.5.27 → 0.5.29
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 +8 -4
- package/dist/index.js +115 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/providers/_builtin/ide/cursor/provider.json +70 -1
- package/providers/_builtin/registry.json +11 -0
- package/src/boot/daemon-lifecycle.ts +11 -0
- package/src/commands/cdp-commands.ts +60 -12
- package/src/providers/provider-loader.ts +20 -22
- package/providers/_builtin/extension/codex/scripts/list_modes.js +0 -138
- package/providers/_builtin/extension/codex/scripts/set_mode.js +0 -165
- package/providers/_builtin/ide/cursor/provider.json.bak +0 -70
package/dist/index.d.ts
CHANGED
|
@@ -966,12 +966,16 @@ declare class ProviderLoader {
|
|
|
966
966
|
private log;
|
|
967
967
|
/**
|
|
968
968
|
* Load all providers (3-tier priority)
|
|
969
|
-
* 1.
|
|
970
|
-
* 2.
|
|
971
|
-
*
|
|
972
|
-
*
|
|
969
|
+
* 1. .upstream/ (GitHub auto-download — primary source)
|
|
970
|
+
* 2. User custom (~/.adhdev/providers/ excluding .upstream)
|
|
971
|
+
* User custom always wins (highest priority).
|
|
972
|
+
* If .upstream/ is empty, call fetchLatest() before loadAll().
|
|
973
973
|
*/
|
|
974
974
|
loadAll(): void;
|
|
975
|
+
/**
|
|
976
|
+
* Check if upstream directory exists and has providers.
|
|
977
|
+
*/
|
|
978
|
+
hasUpstream(): boolean;
|
|
975
979
|
/**
|
|
976
980
|
* Get raw provider metadata by type (NO scripts loaded).
|
|
977
981
|
* Use resolve() when you need scripts (readChat, listModels, etc).
|
package/dist/index.js
CHANGED
|
@@ -3861,6 +3861,41 @@ async function handleResolveAction(h, args) {
|
|
|
3861
3861
|
var fs4 = __toESM(require("fs"));
|
|
3862
3862
|
var path5 = __toESM(require("path"));
|
|
3863
3863
|
var os6 = __toESM(require("os"));
|
|
3864
|
+
var KEY_TO_VK = {
|
|
3865
|
+
Backspace: 8,
|
|
3866
|
+
Tab: 9,
|
|
3867
|
+
Enter: 13,
|
|
3868
|
+
Escape: 27,
|
|
3869
|
+
Space: 32,
|
|
3870
|
+
ArrowLeft: 37,
|
|
3871
|
+
ArrowUp: 38,
|
|
3872
|
+
ArrowRight: 39,
|
|
3873
|
+
ArrowDown: 40,
|
|
3874
|
+
Delete: 46,
|
|
3875
|
+
Home: 36,
|
|
3876
|
+
End: 35,
|
|
3877
|
+
PageUp: 33,
|
|
3878
|
+
PageDown: 34,
|
|
3879
|
+
Insert: 45,
|
|
3880
|
+
F1: 112,
|
|
3881
|
+
F2: 113,
|
|
3882
|
+
F3: 114,
|
|
3883
|
+
F4: 115,
|
|
3884
|
+
F5: 116,
|
|
3885
|
+
F6: 117,
|
|
3886
|
+
F7: 118,
|
|
3887
|
+
F8: 119,
|
|
3888
|
+
F9: 120,
|
|
3889
|
+
F10: 121,
|
|
3890
|
+
F11: 122,
|
|
3891
|
+
F12: 123,
|
|
3892
|
+
Control: 17,
|
|
3893
|
+
Shift: 16,
|
|
3894
|
+
Alt: 18,
|
|
3895
|
+
Meta: 91,
|
|
3896
|
+
CapsLock: 20,
|
|
3897
|
+
" ": 32
|
|
3898
|
+
};
|
|
3864
3899
|
async function handleCdpEval(h, args) {
|
|
3865
3900
|
if (!h.getCdp()?.isConnected) return { success: false, error: "CDP not connected" };
|
|
3866
3901
|
const expression = args?.expression || args?.script;
|
|
@@ -3921,18 +3956,40 @@ async function handleCdpRemoteAction(h, args) {
|
|
|
3921
3956
|
try {
|
|
3922
3957
|
switch (action) {
|
|
3923
3958
|
case "input_key": {
|
|
3924
|
-
const { key, modifiers } = params;
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3959
|
+
const { type: evType, key, code, text, unmodifiedText, modifiers } = params;
|
|
3960
|
+
const mod = typeof modifiers === "number" ? modifiers : 0;
|
|
3961
|
+
const vk = KEY_TO_VK[key] || (key.length === 1 ? key.charCodeAt(0) : 0);
|
|
3962
|
+
if (evType === "char") {
|
|
3963
|
+
await h.getCdp().send("Input.dispatchKeyEvent", {
|
|
3964
|
+
type: "char",
|
|
3965
|
+
key,
|
|
3966
|
+
code,
|
|
3967
|
+
text: text || key,
|
|
3968
|
+
unmodifiedText: unmodifiedText || text || key,
|
|
3969
|
+
...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
|
|
3970
|
+
...mod ? { modifiers: mod } : {}
|
|
3971
|
+
});
|
|
3972
|
+
} else {
|
|
3973
|
+
await h.getCdp().send("Input.dispatchKeyEvent", {
|
|
3974
|
+
type: "rawKeyDown",
|
|
3975
|
+
key,
|
|
3976
|
+
code,
|
|
3977
|
+
...text ? { text } : {},
|
|
3978
|
+
...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
|
|
3979
|
+
...mod ? { modifiers: mod } : {}
|
|
3980
|
+
});
|
|
3981
|
+
await h.getCdp().send("Input.dispatchKeyEvent", {
|
|
3982
|
+
type: "keyUp",
|
|
3983
|
+
key,
|
|
3984
|
+
code,
|
|
3985
|
+
...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
|
|
3986
|
+
...mod ? { modifiers: mod } : {}
|
|
3987
|
+
});
|
|
3988
|
+
}
|
|
3932
3989
|
return { success: true };
|
|
3933
3990
|
}
|
|
3934
3991
|
case "input_click": {
|
|
3935
|
-
let { x, y, nx, ny, button: btn } = params;
|
|
3992
|
+
let { x, y, nx, ny, button: btn, clickCount } = params;
|
|
3936
3993
|
if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
|
|
3937
3994
|
const viewport = await h.getCdp().evaluate(
|
|
3938
3995
|
"JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
|
|
@@ -3944,19 +4001,20 @@ async function handleCdpRemoteAction(h, args) {
|
|
|
3944
4001
|
if (x === void 0 || y === void 0) {
|
|
3945
4002
|
return { success: false, error: "No coordinates provided (x,y or nx,ny required)" };
|
|
3946
4003
|
}
|
|
4004
|
+
const cc = clickCount || 1;
|
|
3947
4005
|
await h.getCdp().send("Input.dispatchMouseEvent", {
|
|
3948
4006
|
type: "mousePressed",
|
|
3949
4007
|
x,
|
|
3950
4008
|
y,
|
|
3951
4009
|
button: btn || "left",
|
|
3952
|
-
clickCount:
|
|
4010
|
+
clickCount: cc
|
|
3953
4011
|
});
|
|
3954
4012
|
await h.getCdp().send("Input.dispatchMouseEvent", {
|
|
3955
4013
|
type: "mouseReleased",
|
|
3956
4014
|
x,
|
|
3957
4015
|
y,
|
|
3958
4016
|
button: btn || "left",
|
|
3959
|
-
clickCount:
|
|
4017
|
+
clickCount: cc
|
|
3960
4018
|
});
|
|
3961
4019
|
return { success: true, x, y };
|
|
3962
4020
|
}
|
|
@@ -3964,11 +4022,11 @@ async function handleCdpRemoteAction(h, args) {
|
|
|
3964
4022
|
const { text } = params;
|
|
3965
4023
|
for (const char of text || "") {
|
|
3966
4024
|
await h.getCdp().send("Input.dispatchKeyEvent", {
|
|
3967
|
-
type: "
|
|
4025
|
+
type: "char",
|
|
3968
4026
|
text: char,
|
|
3969
|
-
key: char
|
|
4027
|
+
key: char,
|
|
4028
|
+
unmodifiedText: char
|
|
3970
4029
|
});
|
|
3971
|
-
await h.getCdp().send("Input.dispatchKeyEvent", { type: "keyUp", key: char });
|
|
3972
4030
|
}
|
|
3973
4031
|
return { success: true };
|
|
3974
4032
|
}
|
|
@@ -3999,6 +4057,23 @@ async function handleCdpRemoteAction(h, args) {
|
|
|
3999
4057
|
});
|
|
4000
4058
|
return { success: true };
|
|
4001
4059
|
}
|
|
4060
|
+
case "input_mouseMoved": {
|
|
4061
|
+
let { x, y, nx, ny } = params;
|
|
4062
|
+
if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
|
|
4063
|
+
const viewport = await h.getCdp().evaluate(
|
|
4064
|
+
"JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
|
|
4065
|
+
);
|
|
4066
|
+
const { w, h: vh } = JSON.parse(viewport);
|
|
4067
|
+
x = Math.round(nx * w);
|
|
4068
|
+
y = Math.round(ny * vh);
|
|
4069
|
+
}
|
|
4070
|
+
await h.getCdp().send("Input.dispatchMouseEvent", {
|
|
4071
|
+
type: "mouseMoved",
|
|
4072
|
+
x: x || 0,
|
|
4073
|
+
y: y || 0
|
|
4074
|
+
});
|
|
4075
|
+
return { success: true };
|
|
4076
|
+
}
|
|
4002
4077
|
default:
|
|
4003
4078
|
return { success: false, error: `Unknown remote action: ${action}` };
|
|
4004
4079
|
}
|
|
@@ -4798,20 +4873,13 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
4798
4873
|
// ─── Public API ────────────────────────────────
|
|
4799
4874
|
/**
|
|
4800
4875
|
* Load all providers (3-tier priority)
|
|
4801
|
-
* 1.
|
|
4802
|
-
* 2.
|
|
4803
|
-
*
|
|
4804
|
-
*
|
|
4876
|
+
* 1. .upstream/ (GitHub auto-download — primary source)
|
|
4877
|
+
* 2. User custom (~/.adhdev/providers/ excluding .upstream)
|
|
4878
|
+
* User custom always wins (highest priority).
|
|
4879
|
+
* If .upstream/ is empty, call fetchLatest() before loadAll().
|
|
4805
4880
|
*/
|
|
4806
4881
|
loadAll() {
|
|
4807
4882
|
this.providers.clear();
|
|
4808
|
-
let builtinCount = 0;
|
|
4809
|
-
for (const dir of this.builtinDirs) {
|
|
4810
|
-
if (fs5.existsSync(dir)) {
|
|
4811
|
-
builtinCount += this.loadDir(dir);
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
this.log(`Loaded ${builtinCount} builtin providers`);
|
|
4815
4883
|
let upstreamCount = 0;
|
|
4816
4884
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
4817
4885
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
@@ -4826,11 +4894,21 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
4826
4894
|
}
|
|
4827
4895
|
}
|
|
4828
4896
|
this.log(`Total: ${this.providers.size} providers [${[...this.providers.keys()].join(", ")}]`);
|
|
4829
|
-
if (upstreamCount === 0 && builtinCount > 0) {
|
|
4830
|
-
this.log(`\u26A0 Using bundled providers only (upstream not available). Run 'adhdev daemon' with internet to auto-update.`);
|
|
4831
|
-
}
|
|
4832
4897
|
if (this.providers.size === 0) {
|
|
4833
|
-
this.log(`\u274C No providers loaded!
|
|
4898
|
+
this.log(`\u274C No providers loaded! Run 'adhdev daemon' with internet to download providers.`);
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
/**
|
|
4902
|
+
* Check if upstream directory exists and has providers.
|
|
4903
|
+
*/
|
|
4904
|
+
hasUpstream() {
|
|
4905
|
+
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
4906
|
+
try {
|
|
4907
|
+
return fs5.readdirSync(this.upstreamDir).some(
|
|
4908
|
+
(d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
|
|
4909
|
+
);
|
|
4910
|
+
} catch {
|
|
4911
|
+
return false;
|
|
4834
4912
|
}
|
|
4835
4913
|
}
|
|
4836
4914
|
/**
|
|
@@ -12567,6 +12645,14 @@ async function initDaemonComponents(config) {
|
|
|
12567
12645
|
const providerLoader = new ProviderLoader({
|
|
12568
12646
|
logFn: config.providerLogFn
|
|
12569
12647
|
});
|
|
12648
|
+
if (!providerLoader.hasUpstream()) {
|
|
12649
|
+
LOG.info("Provider", "No upstream providers found \u2014 downloading from GitHub...");
|
|
12650
|
+
try {
|
|
12651
|
+
await providerLoader.fetchLatest();
|
|
12652
|
+
} catch (e) {
|
|
12653
|
+
LOG.warn("Provider", `\u26A0 Failed to fetch providers: ${e?.message}`);
|
|
12654
|
+
}
|
|
12655
|
+
}
|
|
12570
12656
|
providerLoader.loadAll();
|
|
12571
12657
|
providerLoader.registerToDetector();
|
|
12572
12658
|
const instanceManager = new ProviderInstanceManager();
|