@adhdev/daemon-core 0.8.46 → 0.8.48
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 +51 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -18
- package/dist/index.mjs.map +1 -1
- package/dist/providers/contracts.d.ts +6 -0
- package/dist/shared-types.d.ts +6 -0
- 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/src/providers/cli-provider-instance.ts +35 -4
- package/src/providers/contracts.ts +6 -0
- package/src/shared-types.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -4417,6 +4417,8 @@ var DaemonCdpManager = class {
|
|
|
4417
4417
|
allTargets = result?.targetInfos || [];
|
|
4418
4418
|
}
|
|
4419
4419
|
const pageWebviewUrls = await this.getCurrentPageWebviewUrls();
|
|
4420
|
+
const pageWebviewOrder = /* @__PURE__ */ new Map();
|
|
4421
|
+
Array.from(pageWebviewUrls).forEach((url, index) => pageWebviewOrder.set(url, index));
|
|
4420
4422
|
const iframes = allTargets.filter((t) => t.type === "iframe");
|
|
4421
4423
|
const typeMap = /* @__PURE__ */ new Map();
|
|
4422
4424
|
for (const t of allTargets) {
|
|
@@ -4458,6 +4460,14 @@ var DaemonCdpManager = class {
|
|
|
4458
4460
|
}
|
|
4459
4461
|
}
|
|
4460
4462
|
}
|
|
4463
|
+
agents.sort((lhs, rhs) => {
|
|
4464
|
+
const leftOrder = pageWebviewOrder.get(lhs.url);
|
|
4465
|
+
const rightOrder = pageWebviewOrder.get(rhs.url);
|
|
4466
|
+
if (leftOrder != null && rightOrder != null) return leftOrder - rightOrder;
|
|
4467
|
+
if (leftOrder != null) return -1;
|
|
4468
|
+
if (rightOrder != null) return 1;
|
|
4469
|
+
return lhs.url.localeCompare(rhs.url);
|
|
4470
|
+
});
|
|
4461
4471
|
this._lastDiscoveredTargets = new Set(agents.map((a) => a.targetId));
|
|
4462
4472
|
return agents;
|
|
4463
4473
|
} catch (e) {
|
|
@@ -4596,6 +4606,26 @@ var DaemonCdpManager = class {
|
|
|
4596
4606
|
}
|
|
4597
4607
|
async getCurrentPageWebviewUrls() {
|
|
4598
4608
|
if (!this.isConnected) return /* @__PURE__ */ new Set();
|
|
4609
|
+
try {
|
|
4610
|
+
const raw = await this.evaluate(
|
|
4611
|
+
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
4612
|
+
.filter((el) => {
|
|
4613
|
+
const rect = el.getBoundingClientRect();
|
|
4614
|
+
if (rect.width <= 8 || rect.height <= 8) return false;
|
|
4615
|
+
const style = window.getComputedStyle(el);
|
|
4616
|
+
return style.display !== 'none' && style.visibility !== 'hidden';
|
|
4617
|
+
})
|
|
4618
|
+
.map((el) => el.src || el.getAttribute('src') || '')
|
|
4619
|
+
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
4620
|
+
5e3
|
|
4621
|
+
);
|
|
4622
|
+
const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
4623
|
+
if (Array.isArray(parsed)) {
|
|
4624
|
+
const urls = parsed.filter((src) => typeof src === "string" && src.length > 0);
|
|
4625
|
+
if (urls.length > 0) return new Set(urls);
|
|
4626
|
+
}
|
|
4627
|
+
} catch {
|
|
4628
|
+
}
|
|
4599
4629
|
try {
|
|
4600
4630
|
const urls = /* @__PURE__ */ new Set();
|
|
4601
4631
|
const { frameTree } = await this.sendInternal("Page.getFrameTree", {}, 5e3);
|
|
@@ -4607,19 +4637,7 @@ var DaemonCdpManager = class {
|
|
|
4607
4637
|
for (const child of node?.childFrames || []) visit(child);
|
|
4608
4638
|
};
|
|
4609
4639
|
if (frameTree) visit(frameTree);
|
|
4610
|
-
|
|
4611
|
-
} catch {
|
|
4612
|
-
}
|
|
4613
|
-
try {
|
|
4614
|
-
const raw = await this.evaluate(
|
|
4615
|
-
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
4616
|
-
.map((el) => el.src || el.getAttribute('src') || '')
|
|
4617
|
-
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
4618
|
-
5e3
|
|
4619
|
-
);
|
|
4620
|
-
const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
4621
|
-
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
4622
|
-
return new Set(parsed.filter((src) => typeof src === "string" && src.length > 0));
|
|
4640
|
+
return urls;
|
|
4623
4641
|
} catch {
|
|
4624
4642
|
return /* @__PURE__ */ new Set();
|
|
4625
4643
|
}
|
|
@@ -9043,7 +9061,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
9043
9061
|
}
|
|
9044
9062
|
const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
|
|
9045
9063
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
9046
|
-
const IDE_LEVEL_SCRIPTS = ["listModes", "setMode", "listModels", "setModel"];
|
|
9064
|
+
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
9047
9065
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
9048
9066
|
if (targetSessionId) {
|
|
9049
9067
|
try {
|
|
@@ -9970,14 +9988,18 @@ var CliProviderInstance = class {
|
|
|
9970
9988
|
}
|
|
9971
9989
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
9972
9990
|
this.maybeAppendRuntimeRecoveryMessage(runtime);
|
|
9973
|
-
|
|
9991
|
+
let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
|
|
9992
|
+
const historyMessageCount = Number.isFinite(parsedStatus?.historyMessageCount) ? Math.max(0, Number(parsedStatus.historyMessageCount)) : null;
|
|
9993
|
+
if (historyMessageCount !== null) {
|
|
9994
|
+
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
9995
|
+
}
|
|
9974
9996
|
const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
|
|
9975
9997
|
if (controlValues) {
|
|
9976
|
-
this.controlValues = controlValues;
|
|
9977
|
-
} else if (Object.keys(this.controlValues).length > 0) {
|
|
9978
|
-
this.controlValues = {};
|
|
9998
|
+
this.controlValues = { ...this.controlValues, ...controlValues };
|
|
9979
9999
|
}
|
|
9980
10000
|
const mergedMessages = this.mergeConversationMessages(parsedMessages);
|
|
10001
|
+
const currentModel = typeof parsedStatus?.model === "string" && parsedStatus.model.trim() ? parsedStatus.model.trim() : typeof this.controlValues.model === "string" && this.controlValues.model.trim() ? this.controlValues.model.trim() : void 0;
|
|
10002
|
+
const currentPlan = typeof parsedStatus?.mode === "string" && parsedStatus.mode.trim() ? parsedStatus.mode.trim() : typeof this.controlValues.mode === "string" && this.controlValues.mode.trim() ? this.controlValues.mode.trim() : void 0;
|
|
9981
10003
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
9982
10004
|
if (parsedMessages.length > 0) {
|
|
9983
10005
|
const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
|
|
@@ -10014,6 +10036,8 @@ var CliProviderInstance = class {
|
|
|
10014
10036
|
inputContent: ""
|
|
10015
10037
|
},
|
|
10016
10038
|
workspace: this.workingDir,
|
|
10039
|
+
currentModel,
|
|
10040
|
+
currentPlan,
|
|
10017
10041
|
instanceId: this.instanceId,
|
|
10018
10042
|
providerSessionId: this.providerSessionId,
|
|
10019
10043
|
lastUpdated: Date.now(),
|
|
@@ -10203,6 +10227,15 @@ var CliProviderInstance = class {
|
|
|
10203
10227
|
}
|
|
10204
10228
|
applyProviderResponse(data, options) {
|
|
10205
10229
|
if (!data || typeof data !== "object") return;
|
|
10230
|
+
const patchedProviderSessionId = typeof data.providerSessionId === "string" ? data.providerSessionId.trim() : "";
|
|
10231
|
+
if (patchedProviderSessionId) {
|
|
10232
|
+
this.promoteProviderSessionId(patchedProviderSessionId);
|
|
10233
|
+
}
|
|
10234
|
+
if (data.sessionEvent === "new_session") {
|
|
10235
|
+
this.runtimeMessages = [];
|
|
10236
|
+
this.suppressIdleHistoryReplay = false;
|
|
10237
|
+
this.adapter.clearHistory();
|
|
10238
|
+
}
|
|
10206
10239
|
const controlValues = extractProviderControlValues(this.provider.controls, data);
|
|
10207
10240
|
if (controlValues) {
|
|
10208
10241
|
this.controlValues = { ...this.controlValues, ...controlValues };
|