@adhdev/daemon-core 0.5.20 → 0.5.23
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 -0
- package/dist/index.js +66 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/providers/_builtin/extension/codex/provider.json +36 -0
- package/providers/_builtin/extension/codex/scripts/click_conversation_webview.js +24 -0
- package/providers/_builtin/extension/codex/scripts/explore_chat_webview.js +110 -0
- package/providers/_builtin/extension/codex/scripts/explore_controls_webview.js +75 -0
- package/providers/_builtin/extension/codex/scripts/explore_dom.js +88 -0
- package/providers/_builtin/extension/codex/scripts/explore_dropdown_webview.js +64 -0
- package/providers/_builtin/extension/codex/scripts/inspect_code_webview.js +55 -0
- package/providers/_builtin/extension/codex/scripts/list_models.js +62 -0
- package/providers/_builtin/extension/codex/scripts/message_structure_webview.js +79 -0
- package/providers/_builtin/extension/codex/scripts/new_session.js +26 -0
- package/providers/_builtin/extension/codex/scripts/read_chat.js +342 -0
- package/providers/_builtin/extension/codex/scripts/resolve_action.js +42 -0
- package/providers/_builtin/extension/codex/scripts/send_message.js +62 -0
- package/providers/_builtin/extension/codex/scripts/set_model.js +86 -0
- package/providers/_builtin/extension/codex/scripts.js +94 -0
- package/providers/_builtin/registry.json +6 -1
- package/src/agent-stream/manager.ts +7 -7
- package/src/cdp/devtools.ts +3 -3
- package/src/cdp/manager.ts +66 -0
- package/src/commands/handler.ts +1 -1
- package/src/commands/stream-commands.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1331,6 +1331,14 @@ declare class DaemonCdpManager {
|
|
|
1331
1331
|
discoverAgentWebviews(): Promise<AgentWebviewTarget[]>;
|
|
1332
1332
|
attachToAgent(target: AgentWebviewTarget): Promise<string | null>;
|
|
1333
1333
|
evaluateInSession(sessionId: string, expression: string, timeoutMs?: number): Promise<unknown>;
|
|
1334
|
+
/**
|
|
1335
|
+
* Evaluate inside the child frame of an attached session.
|
|
1336
|
+
* Extension webviews have a nested iframe structure:
|
|
1337
|
+
* outer (vscode-webview://) → inner (extension React app)
|
|
1338
|
+
* This method navigates into the inner frame using CDP Page.getFrameTree.
|
|
1339
|
+
* Falls back to evaluateInSession if no child frame is found.
|
|
1340
|
+
*/
|
|
1341
|
+
evaluateInSessionFrame(sessionId: string, expression: string, timeoutMs?: number): Promise<unknown>;
|
|
1334
1342
|
detachAgent(sessionId: string): Promise<void>;
|
|
1335
1343
|
detachAllAgents(): Promise<void>;
|
|
1336
1344
|
getAgentSessions(): Map<string, AgentWebviewTarget>;
|
package/dist/index.js
CHANGED
|
@@ -1631,6 +1631,60 @@ var DaemonCdpManager = class {
|
|
|
1631
1631
|
}, timeoutMs);
|
|
1632
1632
|
});
|
|
1633
1633
|
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Evaluate inside the child frame of an attached session.
|
|
1636
|
+
* Extension webviews have a nested iframe structure:
|
|
1637
|
+
* outer (vscode-webview://) → inner (extension React app)
|
|
1638
|
+
* This method navigates into the inner frame using CDP Page.getFrameTree.
|
|
1639
|
+
* Falls back to evaluateInSession if no child frame is found.
|
|
1640
|
+
*/
|
|
1641
|
+
async evaluateInSessionFrame(sessionId, expression, timeoutMs = 15e3) {
|
|
1642
|
+
const ws = this._browserConnected ? this.browserWs : this.ws;
|
|
1643
|
+
if (!ws || ws.readyState !== import_ws.default.OPEN) {
|
|
1644
|
+
throw new Error("CDP not connected");
|
|
1645
|
+
}
|
|
1646
|
+
const sendViaSession = (method, params = {}) => {
|
|
1647
|
+
return new Promise((resolve7, reject) => {
|
|
1648
|
+
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1649
|
+
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1650
|
+
pendingMap.set(id, { resolve: resolve7, reject });
|
|
1651
|
+
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1652
|
+
setTimeout(() => {
|
|
1653
|
+
if (pendingMap.has(id)) {
|
|
1654
|
+
pendingMap.delete(id);
|
|
1655
|
+
reject(new Error(`CDP session timeout: ${method}`));
|
|
1656
|
+
}
|
|
1657
|
+
}, timeoutMs);
|
|
1658
|
+
});
|
|
1659
|
+
};
|
|
1660
|
+
try {
|
|
1661
|
+
const { frameTree } = await sendViaSession("Page.getFrameTree");
|
|
1662
|
+
const childFrame = frameTree?.childFrames?.[0]?.frame;
|
|
1663
|
+
if (!childFrame) {
|
|
1664
|
+
return this.evaluateInSession(sessionId, expression, timeoutMs);
|
|
1665
|
+
}
|
|
1666
|
+
const { executionContextId } = await sendViaSession("Page.createIsolatedWorld", {
|
|
1667
|
+
frameId: childFrame.id,
|
|
1668
|
+
worldName: "adhdev-agent-eval",
|
|
1669
|
+
grantUniveralAccess: true
|
|
1670
|
+
});
|
|
1671
|
+
const result = await sendViaSession("Runtime.evaluate", {
|
|
1672
|
+
expression,
|
|
1673
|
+
returnByValue: true,
|
|
1674
|
+
awaitPromise: true,
|
|
1675
|
+
contextId: executionContextId
|
|
1676
|
+
});
|
|
1677
|
+
if (result?.result?.subtype === "error") {
|
|
1678
|
+
throw new Error(result.result.description);
|
|
1679
|
+
}
|
|
1680
|
+
return result?.result?.value;
|
|
1681
|
+
} catch (e) {
|
|
1682
|
+
if (e.message?.includes("getFrameTree")) {
|
|
1683
|
+
return this.evaluateInSession(sessionId, expression, timeoutMs);
|
|
1684
|
+
}
|
|
1685
|
+
throw e;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1634
1688
|
async detachAgent(sessionId) {
|
|
1635
1689
|
try {
|
|
1636
1690
|
const sendFn = this._browserConnected ? this.sendBrowser.bind(this) : this.sendInternal.bind(this);
|
|
@@ -1777,7 +1831,7 @@ var CdpDomHandlers = class {
|
|
|
1777
1831
|
}
|
|
1778
1832
|
let result;
|
|
1779
1833
|
if (sessionId) {
|
|
1780
|
-
result = await this.getCdp().
|
|
1834
|
+
result = await this.getCdp().evaluateInSessionFrame(sessionId, expression);
|
|
1781
1835
|
} else {
|
|
1782
1836
|
result = await this.getCdp().evaluate(expression, 3e4);
|
|
1783
1837
|
}
|
|
@@ -1838,7 +1892,7 @@ var CdpDomHandlers = class {
|
|
|
1838
1892
|
try {
|
|
1839
1893
|
let raw;
|
|
1840
1894
|
if (sessionId) {
|
|
1841
|
-
raw = await this.getCdp().
|
|
1895
|
+
raw = await this.getCdp().evaluateInSessionFrame(sessionId, expression);
|
|
1842
1896
|
} else {
|
|
1843
1897
|
raw = await this.getCdp().evaluate(expression, 15e3);
|
|
1844
1898
|
}
|
|
@@ -1973,7 +2027,7 @@ var CdpDomHandlers = class {
|
|
|
1973
2027
|
try {
|
|
1974
2028
|
let raw;
|
|
1975
2029
|
if (sessionId) {
|
|
1976
|
-
raw = await this.getCdp().
|
|
2030
|
+
raw = await this.getCdp().evaluateInSessionFrame(sessionId, expression);
|
|
1977
2031
|
} else {
|
|
1978
2032
|
raw = await this.getCdp().evaluate(expression, 3e4);
|
|
1979
2033
|
}
|
|
@@ -4221,7 +4275,7 @@ async function handleExtensionScript(h, args, scriptName) {
|
|
|
4221
4275
|
if (!targetSessionId) {
|
|
4222
4276
|
return { success: false, error: `No active session found for ${agentType}` };
|
|
4223
4277
|
}
|
|
4224
|
-
result = await cdp.
|
|
4278
|
+
result = await cdp.evaluateInSessionFrame(targetSessionId, scriptCode);
|
|
4225
4279
|
} else if (hasWebviewScript && cdp.evaluateInWebviewFrame) {
|
|
4226
4280
|
const matchText = provider.webviewMatchText;
|
|
4227
4281
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
@@ -4459,7 +4513,7 @@ var DaemonCommandHandler = class {
|
|
|
4459
4513
|
sessionId = this.getExtensionSessionId(provider);
|
|
4460
4514
|
}
|
|
4461
4515
|
if (!sessionId) return null;
|
|
4462
|
-
const result2 = await cdp.
|
|
4516
|
+
const result2 = await cdp.evaluateInSessionFrame(sessionId, script, timeout);
|
|
4463
4517
|
return { result: result2, category: "extension" };
|
|
4464
4518
|
}
|
|
4465
4519
|
const result = await cdp.evaluate(script, timeout);
|
|
@@ -8839,7 +8893,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8839
8893
|
results.push(agent.lastState);
|
|
8840
8894
|
} else {
|
|
8841
8895
|
try {
|
|
8842
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8896
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8843
8897
|
const state = await agent.adapter.readChat(evaluate);
|
|
8844
8898
|
agent.lastState = state;
|
|
8845
8899
|
agent.lastError = null;
|
|
@@ -8877,7 +8931,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8877
8931
|
const agent = this.managed.get(agentType);
|
|
8878
8932
|
if (!agent) return false;
|
|
8879
8933
|
try {
|
|
8880
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8934
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8881
8935
|
await agent.adapter.sendMessage(evaluate, text);
|
|
8882
8936
|
return true;
|
|
8883
8937
|
} catch (e) {
|
|
@@ -8890,7 +8944,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8890
8944
|
const agent = this.managed.get(agentType);
|
|
8891
8945
|
if (!agent) return false;
|
|
8892
8946
|
try {
|
|
8893
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8947
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8894
8948
|
return await agent.adapter.resolveAction(evaluate, action);
|
|
8895
8949
|
} catch (e) {
|
|
8896
8950
|
this.logFn(`[AgentStream] resolveAction(${agentType}) error: ${e.message}`);
|
|
@@ -8902,7 +8956,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8902
8956
|
const agent = this.managed.get(agentType);
|
|
8903
8957
|
if (!agent) return false;
|
|
8904
8958
|
try {
|
|
8905
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8959
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8906
8960
|
await agent.adapter.newSession(evaluate);
|
|
8907
8961
|
return true;
|
|
8908
8962
|
} catch (e) {
|
|
@@ -8920,7 +8974,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8920
8974
|
}
|
|
8921
8975
|
if (!agent || typeof agent.adapter.listChats !== "function") return [];
|
|
8922
8976
|
try {
|
|
8923
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8977
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8924
8978
|
return await agent.adapter.listChats(evaluate);
|
|
8925
8979
|
} catch (e) {
|
|
8926
8980
|
this.logFn(`[AgentStream] listChats(${agentType}) error: ${e.message}`);
|
|
@@ -8937,7 +8991,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8937
8991
|
}
|
|
8938
8992
|
if (!agent || typeof agent.adapter.switchSession !== "function") return false;
|
|
8939
8993
|
try {
|
|
8940
|
-
const evaluate = (expr, timeout) => cdp.
|
|
8994
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8941
8995
|
return await agent.adapter.switchSession(evaluate, sessionId);
|
|
8942
8996
|
} catch (e) {
|
|
8943
8997
|
this.logFn(`[AgentStream] switchSession(${agentType}) error: ${e.message}`);
|
|
@@ -8948,7 +9002,7 @@ var DaemonAgentStreamManager = class {
|
|
|
8948
9002
|
const agent = this.managed.get(agentType);
|
|
8949
9003
|
if (!agent || typeof agent.adapter.focusEditor !== "function") return false;
|
|
8950
9004
|
try {
|
|
8951
|
-
const evaluate = (expr, timeout) => cdp.
|
|
9005
|
+
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
|
|
8952
9006
|
await agent.adapter.focusEditor(evaluate);
|
|
8953
9007
|
return true;
|
|
8954
9008
|
} catch (e) {
|