@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.mjs
CHANGED
|
@@ -4330,6 +4330,8 @@ var DaemonCdpManager = class {
|
|
|
4330
4330
|
allTargets = result?.targetInfos || [];
|
|
4331
4331
|
}
|
|
4332
4332
|
const pageWebviewUrls = await this.getCurrentPageWebviewUrls();
|
|
4333
|
+
const pageWebviewOrder = /* @__PURE__ */ new Map();
|
|
4334
|
+
Array.from(pageWebviewUrls).forEach((url, index) => pageWebviewOrder.set(url, index));
|
|
4333
4335
|
const iframes = allTargets.filter((t) => t.type === "iframe");
|
|
4334
4336
|
const typeMap = /* @__PURE__ */ new Map();
|
|
4335
4337
|
for (const t of allTargets) {
|
|
@@ -4371,6 +4373,14 @@ var DaemonCdpManager = class {
|
|
|
4371
4373
|
}
|
|
4372
4374
|
}
|
|
4373
4375
|
}
|
|
4376
|
+
agents.sort((lhs, rhs) => {
|
|
4377
|
+
const leftOrder = pageWebviewOrder.get(lhs.url);
|
|
4378
|
+
const rightOrder = pageWebviewOrder.get(rhs.url);
|
|
4379
|
+
if (leftOrder != null && rightOrder != null) return leftOrder - rightOrder;
|
|
4380
|
+
if (leftOrder != null) return -1;
|
|
4381
|
+
if (rightOrder != null) return 1;
|
|
4382
|
+
return lhs.url.localeCompare(rhs.url);
|
|
4383
|
+
});
|
|
4374
4384
|
this._lastDiscoveredTargets = new Set(agents.map((a) => a.targetId));
|
|
4375
4385
|
return agents;
|
|
4376
4386
|
} catch (e) {
|
|
@@ -4509,6 +4519,26 @@ var DaemonCdpManager = class {
|
|
|
4509
4519
|
}
|
|
4510
4520
|
async getCurrentPageWebviewUrls() {
|
|
4511
4521
|
if (!this.isConnected) return /* @__PURE__ */ new Set();
|
|
4522
|
+
try {
|
|
4523
|
+
const raw = await this.evaluate(
|
|
4524
|
+
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
4525
|
+
.filter((el) => {
|
|
4526
|
+
const rect = el.getBoundingClientRect();
|
|
4527
|
+
if (rect.width <= 8 || rect.height <= 8) return false;
|
|
4528
|
+
const style = window.getComputedStyle(el);
|
|
4529
|
+
return style.display !== 'none' && style.visibility !== 'hidden';
|
|
4530
|
+
})
|
|
4531
|
+
.map((el) => el.src || el.getAttribute('src') || '')
|
|
4532
|
+
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
4533
|
+
5e3
|
|
4534
|
+
);
|
|
4535
|
+
const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
4536
|
+
if (Array.isArray(parsed)) {
|
|
4537
|
+
const urls = parsed.filter((src) => typeof src === "string" && src.length > 0);
|
|
4538
|
+
if (urls.length > 0) return new Set(urls);
|
|
4539
|
+
}
|
|
4540
|
+
} catch {
|
|
4541
|
+
}
|
|
4512
4542
|
try {
|
|
4513
4543
|
const urls = /* @__PURE__ */ new Set();
|
|
4514
4544
|
const { frameTree } = await this.sendInternal("Page.getFrameTree", {}, 5e3);
|
|
@@ -4520,19 +4550,7 @@ var DaemonCdpManager = class {
|
|
|
4520
4550
|
for (const child of node?.childFrames || []) visit(child);
|
|
4521
4551
|
};
|
|
4522
4552
|
if (frameTree) visit(frameTree);
|
|
4523
|
-
|
|
4524
|
-
} catch {
|
|
4525
|
-
}
|
|
4526
|
-
try {
|
|
4527
|
-
const raw = await this.evaluate(
|
|
4528
|
-
`JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
|
|
4529
|
-
.map((el) => el.src || el.getAttribute('src') || '')
|
|
4530
|
-
.filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
|
|
4531
|
-
5e3
|
|
4532
|
-
);
|
|
4533
|
-
const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
4534
|
-
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
4535
|
-
return new Set(parsed.filter((src) => typeof src === "string" && src.length > 0));
|
|
4553
|
+
return urls;
|
|
4536
4554
|
} catch {
|
|
4537
4555
|
return /* @__PURE__ */ new Set();
|
|
4538
4556
|
}
|
|
@@ -8956,7 +8974,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
8956
8974
|
}
|
|
8957
8975
|
const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
|
|
8958
8976
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
8959
|
-
const IDE_LEVEL_SCRIPTS = ["listModes", "setMode", "listModels", "setModel"];
|
|
8977
|
+
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
8960
8978
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
8961
8979
|
if (targetSessionId) {
|
|
8962
8980
|
try {
|
|
@@ -9883,14 +9901,18 @@ var CliProviderInstance = class {
|
|
|
9883
9901
|
}
|
|
9884
9902
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
9885
9903
|
this.maybeAppendRuntimeRecoveryMessage(runtime);
|
|
9886
|
-
|
|
9904
|
+
let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
|
|
9905
|
+
const historyMessageCount = Number.isFinite(parsedStatus?.historyMessageCount) ? Math.max(0, Number(parsedStatus.historyMessageCount)) : null;
|
|
9906
|
+
if (historyMessageCount !== null) {
|
|
9907
|
+
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
9908
|
+
}
|
|
9887
9909
|
const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
|
|
9888
9910
|
if (controlValues) {
|
|
9889
|
-
this.controlValues = controlValues;
|
|
9890
|
-
} else if (Object.keys(this.controlValues).length > 0) {
|
|
9891
|
-
this.controlValues = {};
|
|
9911
|
+
this.controlValues = { ...this.controlValues, ...controlValues };
|
|
9892
9912
|
}
|
|
9893
9913
|
const mergedMessages = this.mergeConversationMessages(parsedMessages);
|
|
9914
|
+
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;
|
|
9915
|
+
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;
|
|
9894
9916
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
9895
9917
|
if (parsedMessages.length > 0) {
|
|
9896
9918
|
const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
|
|
@@ -9927,6 +9949,8 @@ var CliProviderInstance = class {
|
|
|
9927
9949
|
inputContent: ""
|
|
9928
9950
|
},
|
|
9929
9951
|
workspace: this.workingDir,
|
|
9952
|
+
currentModel,
|
|
9953
|
+
currentPlan,
|
|
9930
9954
|
instanceId: this.instanceId,
|
|
9931
9955
|
providerSessionId: this.providerSessionId,
|
|
9932
9956
|
lastUpdated: Date.now(),
|
|
@@ -10116,6 +10140,15 @@ var CliProviderInstance = class {
|
|
|
10116
10140
|
}
|
|
10117
10141
|
applyProviderResponse(data, options) {
|
|
10118
10142
|
if (!data || typeof data !== "object") return;
|
|
10143
|
+
const patchedProviderSessionId = typeof data.providerSessionId === "string" ? data.providerSessionId.trim() : "";
|
|
10144
|
+
if (patchedProviderSessionId) {
|
|
10145
|
+
this.promoteProviderSessionId(patchedProviderSessionId);
|
|
10146
|
+
}
|
|
10147
|
+
if (data.sessionEvent === "new_session") {
|
|
10148
|
+
this.runtimeMessages = [];
|
|
10149
|
+
this.suppressIdleHistoryReplay = false;
|
|
10150
|
+
this.adapter.clearHistory();
|
|
10151
|
+
}
|
|
10119
10152
|
const controlValues = extractProviderControlValues(this.provider.controls, data);
|
|
10120
10153
|
if (controlValues) {
|
|
10121
10154
|
this.controlValues = { ...this.controlValues, ...controlValues };
|