@adhdev/daemon-core 0.8.46 → 0.8.47
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.js +32 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -14
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cdp/manager.ts +33 -14
- package/src/commands/stream-commands.ts +3 -1
package/package.json
CHANGED
package/src/cdp/manager.ts
CHANGED
|
@@ -775,6 +775,8 @@ export class DaemonCdpManager {
|
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
const pageWebviewUrls = await this.getCurrentPageWebviewUrls();
|
|
778
|
+
const pageWebviewOrder = new Map<string, number>();
|
|
779
|
+
Array.from(pageWebviewUrls).forEach((url, index) => pageWebviewOrder.set(url, index));
|
|
778
780
|
|
|
779
781
|
const iframes = allTargets.filter((t: any) => t.type === 'iframe');
|
|
780
782
|
const typeMap = new Map<string, number>();
|
|
@@ -821,7 +823,16 @@ export class DaemonCdpManager {
|
|
|
821
823
|
}
|
|
822
824
|
}
|
|
823
825
|
}
|
|
824
|
-
|
|
826
|
+
|
|
827
|
+
agents.sort((lhs, rhs) => {
|
|
828
|
+
const leftOrder = pageWebviewOrder.get(lhs.url);
|
|
829
|
+
const rightOrder = pageWebviewOrder.get(rhs.url);
|
|
830
|
+
if (leftOrder != null && rightOrder != null) return leftOrder - rightOrder;
|
|
831
|
+
if (leftOrder != null) return -1;
|
|
832
|
+
if (rightOrder != null) return 1;
|
|
833
|
+
return lhs.url.localeCompare(rhs.url);
|
|
834
|
+
});
|
|
835
|
+
|
|
825
836
|
this._lastDiscoveredTargets = new Set(agents.map(a => a.targetId));
|
|
826
837
|
return agents;
|
|
827
838
|
} catch (e) {
|
|
@@ -980,6 +991,26 @@ export class DaemonCdpManager {
|
|
|
980
991
|
private async getCurrentPageWebviewUrls(): Promise<Set<string>> {
|
|
981
992
|
if (!this.isConnected) return new Set();
|
|
982
993
|
|
|
994
|
+
try {
|
|
995
|
+
const raw = await this.evaluate(
|
|
996
|
+
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
997
|
+
.filter((el) => {
|
|
998
|
+
const rect = el.getBoundingClientRect();
|
|
999
|
+
if (rect.width <= 8 || rect.height <= 8) return false;
|
|
1000
|
+
const style = window.getComputedStyle(el);
|
|
1001
|
+
return style.display !== 'none' && style.visibility !== 'hidden';
|
|
1002
|
+
})
|
|
1003
|
+
.map((el) => el.src || el.getAttribute('src') || '')
|
|
1004
|
+
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
1005
|
+
5000,
|
|
1006
|
+
);
|
|
1007
|
+
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1008
|
+
if (Array.isArray(parsed)) {
|
|
1009
|
+
const urls = parsed.filter((src: unknown): src is string => typeof src === 'string' && src.length > 0);
|
|
1010
|
+
if (urls.length > 0) return new Set(urls);
|
|
1011
|
+
}
|
|
1012
|
+
} catch { /* fall through to frame tree */ }
|
|
1013
|
+
|
|
983
1014
|
try {
|
|
984
1015
|
const urls = new Set<string>();
|
|
985
1016
|
const { frameTree } = await this.sendInternal('Page.getFrameTree', {}, 5000);
|
|
@@ -991,19 +1022,7 @@ export class DaemonCdpManager {
|
|
|
991
1022
|
for (const child of node?.childFrames || []) visit(child);
|
|
992
1023
|
};
|
|
993
1024
|
if (frameTree) visit(frameTree);
|
|
994
|
-
|
|
995
|
-
} catch { /* fall through to DOM scan */ }
|
|
996
|
-
|
|
997
|
-
try {
|
|
998
|
-
const raw = await this.evaluate(
|
|
999
|
-
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
1000
|
-
.map((el) => el.src || el.getAttribute('src') || '')
|
|
1001
|
-
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
1002
|
-
5000,
|
|
1003
|
-
);
|
|
1004
|
-
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1005
|
-
if (!Array.isArray(parsed)) return new Set();
|
|
1006
|
-
return new Set(parsed.filter((src: unknown): src is string => typeof src === 'string' && src.length > 0));
|
|
1025
|
+
return urls;
|
|
1007
1026
|
} catch {
|
|
1008
1027
|
return new Set();
|
|
1009
1028
|
}
|
|
@@ -238,7 +238,9 @@ async function executeProviderScript(h: CommandHelpers, args: any, scriptName: s
|
|
|
238
238
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
239
239
|
|
|
240
240
|
// IDE-level scripts (model/mode) — try session frame first, fallback to main page
|
|
241
|
-
const IDE_LEVEL_SCRIPTS =
|
|
241
|
+
const IDE_LEVEL_SCRIPTS = provider.type === 'claude-code-vscode'
|
|
242
|
+
? ['listModes', 'setMode']
|
|
243
|
+
: ['listModes', 'setMode', 'listModels', 'setModel'];
|
|
242
244
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
243
245
|
// Try session frame first (some extensions embed mode selector in their webview)
|
|
244
246
|
if (targetSessionId) {
|