dsh-agent-enhancer 0.3.10 → 0.3.11
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/README.en.md +19 -4
- package/README.md +19 -4
- package/lib/client/browser-agent/tab.d.ts.map +1 -1
- package/lib/client/dsh/settings-features.d.ts.map +1 -1
- package/lib/client/locales.d.ts +15 -13
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client.js +70 -20
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +15 -3
- package/lib/config.d.ts.map +1 -1
- package/lib/host/browser-agent/install.d.ts.map +1 -1
- package/lib/host/browser-agent/launch.d.ts +26 -6
- package/lib/host/browser-agent/launch.d.ts.map +1 -1
- package/lib/host/browser-agent/playwright-driver.d.ts +9 -0
- package/lib/host/browser-agent/playwright-driver.d.ts.map +1 -1
- package/lib/host/browser-agent/tools.d.ts +2 -2
- package/lib/host/index.d.ts +2 -2
- package/lib/host/index.d.ts.map +1 -1
- package/lib/host/rpc.d.ts +20 -0
- package/lib/host/rpc.d.ts.map +1 -1
- package/lib/host/update/cli.d.ts +28 -2
- package/lib/host/update/cli.d.ts.map +1 -1
- package/lib/identity.d.ts +1 -1
- package/lib/index.js +337 -161
- package/lib/index.js.map +3 -3
- package/package.json +1 -1
- package/lib/client/web-chat-bridge/export-markdown.test.d.ts +0 -2
- package/lib/client/web-chat-bridge/export-markdown.test.d.ts.map +0 -1
- package/lib/client/web-chat-bridge/guest-policy-clipboard.test.d.ts +0 -2
- package/lib/client/web-chat-bridge/guest-policy-clipboard.test.d.ts.map +0 -1
- package/lib/host/browser-agent/auto-nav.test.d.ts +0 -2
- package/lib/host/browser-agent/auto-nav.test.d.ts.map +0 -1
- package/lib/host/browser-agent/extract.test.d.ts +0 -2
- package/lib/host/browser-agent/extract.test.d.ts.map +0 -1
- package/lib/host/browser-agent/human-gate.test.d.ts +0 -2
- package/lib/host/browser-agent/human-gate.test.d.ts.map +0 -1
- package/lib/host/browser-agent/page-links.test.d.ts +0 -2
- package/lib/host/browser-agent/page-links.test.d.ts.map +0 -1
- package/lib/host/browser-agent/path-key.test.d.ts +0 -2
- package/lib/host/browser-agent/path-key.test.d.ts.map +0 -1
- package/lib/host/browser-agent/pick-auto-nav.test.d.ts +0 -2
- package/lib/host/browser-agent/pick-auto-nav.test.d.ts.map +0 -1
- package/lib/host/extra-folders/pick.test.d.ts +0 -2
- package/lib/host/extra-folders/pick.test.d.ts.map +0 -1
- package/lib/host/web-chat-bridge/parse-export.test.d.ts +0 -2
- package/lib/host/web-chat-bridge/parse-export.test.d.ts.map +0 -1
- package/lib/host/web-chat-bridge/share-link.test.d.ts +0 -2
- package/lib/host/web-chat-bridge/share-link.test.d.ts.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/host/index.ts
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { homedir as
|
|
4
|
-
import { join as
|
|
2
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync11, readdirSync as readdirSync7, renameSync as renameSync9, rmdirSync } from "node:fs";
|
|
3
|
+
import { homedir as homedir7 } from "node:os";
|
|
4
|
+
import { join as join33 } from "node:path";
|
|
5
5
|
import z5 from "@deepseek-ai/schemastery";
|
|
6
6
|
import { RemoteError as RemoteError2, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
7
7
|
|
|
@@ -25,11 +25,29 @@ function resolveBrowserAgentBrowser(value) {
|
|
|
25
25
|
case "auto":
|
|
26
26
|
case "chrome":
|
|
27
27
|
case "edge":
|
|
28
|
+
case "safari":
|
|
28
29
|
return value;
|
|
29
30
|
default:
|
|
30
31
|
return "auto";
|
|
31
32
|
}
|
|
32
33
|
}
|
|
34
|
+
function browserAgentBrowsersForPlatform(platform) {
|
|
35
|
+
switch (platform) {
|
|
36
|
+
case "darwin":
|
|
37
|
+
return ["auto", "chrome", "safari"];
|
|
38
|
+
case "win32":
|
|
39
|
+
return ["auto", "chrome", "edge"];
|
|
40
|
+
default:
|
|
41
|
+
return ["auto", "chrome"];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function coerceBrowserAgentBrowserForPlatform(value, platform) {
|
|
45
|
+
const allowed = browserAgentBrowsersForPlatform(platform);
|
|
46
|
+
if (allowed.includes(value)) return value;
|
|
47
|
+
if (value === "edge" && platform === "darwin") return "safari";
|
|
48
|
+
if (value === "safari" && platform === "win32") return "edge";
|
|
49
|
+
return "auto";
|
|
50
|
+
}
|
|
33
51
|
var DEFAULT_AUXILIARY_MODEL = {
|
|
34
52
|
provider: "",
|
|
35
53
|
model: "",
|
|
@@ -385,7 +403,16 @@ var BrowserHumanGate = class {
|
|
|
385
403
|
import { execFileSync } from "node:child_process";
|
|
386
404
|
import { existsSync } from "node:fs";
|
|
387
405
|
import { homedir } from "node:os";
|
|
388
|
-
import { join } from "node:path";
|
|
406
|
+
import { join, posix as pathPosix } from "node:path";
|
|
407
|
+
var BROWSER_AGENT_PROFILE_SLOTS = [
|
|
408
|
+
"auto",
|
|
409
|
+
"auto-chrome",
|
|
410
|
+
"auto-msedge",
|
|
411
|
+
"auto-webkit",
|
|
412
|
+
"chrome",
|
|
413
|
+
"edge",
|
|
414
|
+
"safari"
|
|
415
|
+
];
|
|
389
416
|
function windowsEnv(name2, env = process.env) {
|
|
390
417
|
const variants = [
|
|
391
418
|
name2,
|
|
@@ -404,8 +431,23 @@ function windowsEnv(name2, env = process.env) {
|
|
|
404
431
|
}
|
|
405
432
|
return void 0;
|
|
406
433
|
}
|
|
434
|
+
function uniquePaths(paths) {
|
|
435
|
+
const out = [];
|
|
436
|
+
for (const path of paths) {
|
|
437
|
+
if (path.trim() === "" || out.includes(path)) continue;
|
|
438
|
+
out.push(path);
|
|
439
|
+
}
|
|
440
|
+
return out;
|
|
441
|
+
}
|
|
442
|
+
function darwinAppExecutable(appName, binaryName, home) {
|
|
443
|
+
const relative4 = pathPosix.join(`${appName}.app`, "Contents", "MacOS", binaryName);
|
|
444
|
+
return [
|
|
445
|
+
pathPosix.join("/Applications", relative4),
|
|
446
|
+
pathPosix.join(home, "Applications", relative4)
|
|
447
|
+
];
|
|
448
|
+
}
|
|
407
449
|
function browserExecutableCandidates(kind, platform = process.platform, env = process.env) {
|
|
408
|
-
const home = homedir();
|
|
450
|
+
const home = env.HOME?.trim() || env.USERPROFILE?.trim() || homedir();
|
|
409
451
|
if (platform === "win32") {
|
|
410
452
|
const local = windowsEnv("LocalAppData", env);
|
|
411
453
|
const programFiles64 = windowsEnv("ProgramW6432", env) ?? "C:\\Program Files";
|
|
@@ -423,6 +465,7 @@ function browserExecutableCandidates(kind, platform = process.platform, env = pr
|
|
|
423
465
|
join(home, "AppData", "Local", "Google", "Chrome", "Application", "chrome.exe")
|
|
424
466
|
];
|
|
425
467
|
}
|
|
468
|
+
if (kind === "safari") return [];
|
|
426
469
|
return [
|
|
427
470
|
...roots.map((root) => join(root, "Microsoft", "Edge", "Application", "msedge.exe")),
|
|
428
471
|
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
@@ -432,17 +475,33 @@ function browserExecutableCandidates(kind, platform = process.platform, env = pr
|
|
|
432
475
|
}
|
|
433
476
|
if (platform === "darwin") {
|
|
434
477
|
if (kind === "chrome") {
|
|
435
|
-
return [
|
|
478
|
+
return uniquePaths([
|
|
479
|
+
...darwinAppExecutable("Google Chrome", "Google Chrome", home),
|
|
480
|
+
...darwinAppExecutable("Google Chrome Canary", "Google Chrome Canary", home),
|
|
481
|
+
...darwinAppExecutable("Chromium", "Chromium", home)
|
|
482
|
+
]);
|
|
436
483
|
}
|
|
437
|
-
|
|
484
|
+
if (kind === "safari") {
|
|
485
|
+
return uniquePaths([
|
|
486
|
+
...darwinAppExecutable("Safari", "Safari", home)
|
|
487
|
+
]);
|
|
488
|
+
}
|
|
489
|
+
return uniquePaths([
|
|
490
|
+
...darwinAppExecutable("Microsoft Edge", "Microsoft Edge", home),
|
|
491
|
+
...darwinAppExecutable("Microsoft Edge Beta", "Microsoft Edge Beta", home),
|
|
492
|
+
...darwinAppExecutable("Microsoft Edge Dev", "Microsoft Edge Dev", home)
|
|
493
|
+
]);
|
|
438
494
|
}
|
|
439
495
|
if (kind === "chrome") {
|
|
440
496
|
return ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser"];
|
|
441
497
|
}
|
|
498
|
+
if (kind === "safari") {
|
|
499
|
+
return [];
|
|
500
|
+
}
|
|
442
501
|
return ["/usr/bin/microsoft-edge", "/usr/bin/microsoft-edge-stable"];
|
|
443
502
|
}
|
|
444
503
|
function lookUpOnPath(kind, platform, where, exists) {
|
|
445
|
-
const names = platform === "win32" ? kind === "chrome" ? ["chrome.exe", "chrome"] : ["msedge.exe", "msedge"] : kind === "chrome" ? ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"] : ["microsoft-edge", "microsoft-edge-stable", "msedge"];
|
|
504
|
+
const names = platform === "win32" ? kind === "chrome" ? ["chrome.exe", "chrome"] : kind === "edge" ? ["msedge.exe", "msedge"] : [] : kind === "chrome" ? ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"] : kind === "edge" ? ["microsoft-edge", "microsoft-edge-stable", "msedge"] : [];
|
|
446
505
|
for (const name2 of names) {
|
|
447
506
|
const hit = where(name2);
|
|
448
507
|
if (hit !== null && exists(hit)) return hit;
|
|
@@ -471,7 +530,7 @@ function resolveBrowserExecutable(preference = "auto", options = {}) {
|
|
|
471
530
|
const exists = options.exists ?? existsSync;
|
|
472
531
|
const platform = options.platform ?? process.platform;
|
|
473
532
|
const env = options.env ?? process.env;
|
|
474
|
-
const order = preference === "auto" ? platform === "win32" ? ["edge", "chrome"] : ["
|
|
533
|
+
const order = preference === "auto" ? platform === "win32" ? ["edge", "chrome"] : platform === "darwin" ? ["safari", "chrome"] : ["chrome"] : [preference];
|
|
475
534
|
for (const kind of order) {
|
|
476
535
|
const seen = /* @__PURE__ */ new Set();
|
|
477
536
|
for (const executable of browserExecutableCandidates(kind, platform, env)) {
|
|
@@ -487,14 +546,29 @@ function resolveBrowserExecutable(preference = "auto", options = {}) {
|
|
|
487
546
|
function defaultBrowserAgentProfileDir(pluginDataPackageRoot) {
|
|
488
547
|
return browserAgentProfileDirFor(pluginDataPackageRoot, "auto");
|
|
489
548
|
}
|
|
490
|
-
function
|
|
491
|
-
const slot = preference === "chrome" || preference === "edge" ? preference : "auto";
|
|
549
|
+
function browserAgentProfileSlotDir(pluginDataPackageRoot, slot) {
|
|
492
550
|
return join(pluginDataPackageRoot, "browser-agent", `profile-${slot}`);
|
|
493
551
|
}
|
|
552
|
+
function browserAgentProfileDirFor(pluginDataPackageRoot, preference, channel) {
|
|
553
|
+
if (preference === "chrome" || preference === "edge" || preference === "safari") {
|
|
554
|
+
return browserAgentProfileSlotDir(pluginDataPackageRoot, preference);
|
|
555
|
+
}
|
|
556
|
+
if (channel === "chrome" || channel === "msedge" || channel === "webkit") {
|
|
557
|
+
return browserAgentProfileSlotDir(pluginDataPackageRoot, `auto-${channel}`);
|
|
558
|
+
}
|
|
559
|
+
return browserAgentProfileSlotDir(pluginDataPackageRoot, "auto");
|
|
560
|
+
}
|
|
494
561
|
function playwrightChannelOrder(preference, platform = process.platform) {
|
|
495
562
|
if (preference === "chrome") return ["chrome"];
|
|
496
563
|
if (preference === "edge") return ["msedge"];
|
|
497
|
-
|
|
564
|
+
if (preference === "safari") return ["webkit"];
|
|
565
|
+
if (platform === "win32") return ["msedge", "chrome"];
|
|
566
|
+
if (platform === "darwin") return ["webkit", "chrome"];
|
|
567
|
+
return ["chrome"];
|
|
568
|
+
}
|
|
569
|
+
function playwrightChannelSatisfiesPreference(channel, preference, platform = process.platform) {
|
|
570
|
+
if (channel === null || channel === void 0) return false;
|
|
571
|
+
return playwrightChannelOrder(preference, platform).includes(channel);
|
|
498
572
|
}
|
|
499
573
|
function stopAgentBrowserProcesses(profileDir) {
|
|
500
574
|
if (profileDir.trim() === "") return;
|
|
@@ -530,8 +604,8 @@ function stopAgentBrowserProcesses(profileDir) {
|
|
|
530
604
|
}
|
|
531
605
|
|
|
532
606
|
// src/host/browser-agent/playwright-driver.ts
|
|
533
|
-
import { mkdirSync } from "node:fs";
|
|
534
|
-
import { chromium } from "playwright-core";
|
|
607
|
+
import { existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
608
|
+
import { chromium, webkit } from "playwright-core";
|
|
535
609
|
|
|
536
610
|
// src/host/browser-agent/proximity.ts
|
|
537
611
|
function attachHrefByProximity(nodes, anchors) {
|
|
@@ -957,6 +1031,13 @@ var PlaywrightDriver = class {
|
|
|
957
1031
|
currentProfileDir() {
|
|
958
1032
|
return typeof this.profileDirOption === "function" ? this.profileDirOption() : this.profileDirOption;
|
|
959
1033
|
}
|
|
1034
|
+
/** Resolve the on-disk profile for a preference (+ auto channel isolation). */
|
|
1035
|
+
profileDirFor(preference, channel) {
|
|
1036
|
+
if (this.profileRoot !== void 0) {
|
|
1037
|
+
return browserAgentProfileDirFor(this.profileRoot, preference, channel);
|
|
1038
|
+
}
|
|
1039
|
+
return this.currentProfileDir();
|
|
1040
|
+
}
|
|
960
1041
|
/** Latest snapshot refs — used by the click/type path. */
|
|
961
1042
|
refOf(ref) {
|
|
962
1043
|
return this.lastRefs.get(ref);
|
|
@@ -974,9 +1055,8 @@ var PlaywrightDriver = class {
|
|
|
974
1055
|
}
|
|
975
1056
|
async ensureReady(startUrl) {
|
|
976
1057
|
const preference = this.currentPreference();
|
|
977
|
-
const
|
|
978
|
-
const
|
|
979
|
-
const runningOk = this.context !== null && this.page !== null && !this.page.isClosed() && this.channel === wantChannel && this.launchedProfileDir === profileDir;
|
|
1058
|
+
const order = [...playwrightChannelOrder(preference, process.platform)];
|
|
1059
|
+
const runningOk = this.context !== null && this.page !== null && !this.page.isClosed() && playwrightChannelSatisfiesPreference(this.channel, preference, process.platform) && this.launchedProfileDir !== null && this.channel !== null && this.launchedProfileDir === this.profileDirFor(preference, this.channel);
|
|
980
1060
|
if (runningOk) {
|
|
981
1061
|
if (typeof startUrl === "string" && /^https?:\/\//i.test(startUrl)) {
|
|
982
1062
|
const current = this.page.url();
|
|
@@ -989,34 +1069,18 @@ var PlaywrightDriver = class {
|
|
|
989
1069
|
if (this.context !== null) {
|
|
990
1070
|
await this.dispose().catch(() => void 0);
|
|
991
1071
|
}
|
|
992
|
-
this.stopPreferenceProfiles(
|
|
993
|
-
mkdirSync(profileDir, { recursive: true });
|
|
994
|
-
const order = [...playwrightChannelOrder(preference, process.platform)];
|
|
1072
|
+
this.stopPreferenceProfiles(this.profileDirFor(preference));
|
|
995
1073
|
let lastDetail = "";
|
|
996
1074
|
for (const channel of order) {
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1075
|
+
const profileDir = this.profileDirFor(preference, channel);
|
|
1076
|
+
mkdirSync(profileDir, { recursive: true });
|
|
1077
|
+
stopAgentBrowserProcesses(profileDir);
|
|
1078
|
+
try {
|
|
1079
|
+
const context = channel === "webkit" ? await this.launchWebkit(profileDir, preference) : await this.launchChromium(profileDir, preference, channel);
|
|
1080
|
+
if (context === null) {
|
|
1081
|
+
lastDetail = this.lastError ?? `${channel} is not available`;
|
|
1003
1082
|
continue;
|
|
1004
1083
|
}
|
|
1005
|
-
} else if (resolved === null) {
|
|
1006
|
-
lastDetail = `${kind} is not installed or not found on PATH`;
|
|
1007
|
-
this.lastError = lastDetail;
|
|
1008
|
-
continue;
|
|
1009
|
-
}
|
|
1010
|
-
try {
|
|
1011
|
-
const context = await chromium.launchPersistentContext(profileDir, {
|
|
1012
|
-
executablePath: resolved.executable,
|
|
1013
|
-
headless: this.headless,
|
|
1014
|
-
// Avoid Edge/Chrome infobar: "unsupported command-line flag: --no-sandbox".
|
|
1015
|
-
chromiumSandbox: true,
|
|
1016
|
-
ignoreDefaultArgs: ["--no-sandbox"],
|
|
1017
|
-
viewport: this.headless ? { width: 1280, height: 800 } : null,
|
|
1018
|
-
args: ["--no-first-run", "--no-default-browser-check", "--disable-default-apps"]
|
|
1019
|
-
});
|
|
1020
1084
|
this.context = context;
|
|
1021
1085
|
this.channel = channel;
|
|
1022
1086
|
this.launchedProfileDir = profileDir;
|
|
@@ -1037,19 +1101,72 @@ var PlaywrightDriver = class {
|
|
|
1037
1101
|
this.lastError = lastDetail;
|
|
1038
1102
|
}
|
|
1039
1103
|
}
|
|
1040
|
-
const hint = preference === "chrome" || preference === "edge" ? ` Preference is locked to ${preference} (no silent fallback).` : "";
|
|
1104
|
+
const hint = preference === "chrome" || preference === "edge" || preference === "safari" ? ` Preference is locked to ${preference} (no silent fallback).` : "";
|
|
1041
1105
|
throw new Error(
|
|
1042
1106
|
`Playwright could not launch a persistent browser (tried ${order.join(", ")}): ${lastDetail}.${hint}`
|
|
1043
1107
|
);
|
|
1044
1108
|
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Safari preference uses Playwright WebKit (Safari engine). Branded Safari.app
|
|
1111
|
+
* cannot be driven by Playwright; require system Safari to be present as a
|
|
1112
|
+
* platform gate, then launch the WebKit automation build.
|
|
1113
|
+
*/
|
|
1114
|
+
async launchWebkit(profileDir, preference) {
|
|
1115
|
+
if (preference === "safari") {
|
|
1116
|
+
const safari = resolveBrowserExecutable("safari", {
|
|
1117
|
+
platform: process.platform
|
|
1118
|
+
});
|
|
1119
|
+
if (safari === null) {
|
|
1120
|
+
this.lastError = "Safari is not installed";
|
|
1121
|
+
return null;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
let webkitExe;
|
|
1125
|
+
try {
|
|
1126
|
+
webkitExe = webkit.executablePath();
|
|
1127
|
+
} catch (error) {
|
|
1128
|
+
this.lastError = error instanceof Error ? error.message : "Playwright WebKit is unavailable";
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
if (!existsSync2(webkitExe)) {
|
|
1132
|
+
this.lastError = "Playwright WebKit is not installed. Run: npx playwright install webkit";
|
|
1133
|
+
return null;
|
|
1134
|
+
}
|
|
1135
|
+
return webkit.launchPersistentContext(profileDir, {
|
|
1136
|
+
headless: this.headless,
|
|
1137
|
+
viewport: this.headless ? { width: 1280, height: 800 } : null
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
async launchChromium(profileDir, preference, channel) {
|
|
1141
|
+
const kind = channel === "msedge" ? "edge" : "chrome";
|
|
1142
|
+
const resolved = resolveBrowserExecutable(kind);
|
|
1143
|
+
if (preference === "chrome" || preference === "edge") {
|
|
1144
|
+
if (resolved === null || resolved.kind !== preference) {
|
|
1145
|
+
this.lastError = `${preference} is not installed or not found on PATH`;
|
|
1146
|
+
return null;
|
|
1147
|
+
}
|
|
1148
|
+
} else if (resolved === null) {
|
|
1149
|
+
this.lastError = `${kind} is not installed or not found on PATH`;
|
|
1150
|
+
return null;
|
|
1151
|
+
}
|
|
1152
|
+
return chromium.launchPersistentContext(profileDir, {
|
|
1153
|
+
executablePath: resolved.executable,
|
|
1154
|
+
headless: this.headless,
|
|
1155
|
+
// Avoid Edge/Chrome infobar: "unsupported command-line flag: --no-sandbox".
|
|
1156
|
+
chromiumSandbox: true,
|
|
1157
|
+
ignoreDefaultArgs: ["--no-sandbox"],
|
|
1158
|
+
viewport: this.headless ? { width: 1280, height: 800 } : null,
|
|
1159
|
+
args: ["--no-first-run", "--no-default-browser-check", "--disable-default-apps"]
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1045
1162
|
stopPreferenceProfiles(activeProfileDir) {
|
|
1046
1163
|
stopAgentBrowserProcesses(activeProfileDir);
|
|
1047
1164
|
if (this.launchedProfileDir !== null && this.launchedProfileDir !== activeProfileDir) {
|
|
1048
1165
|
stopAgentBrowserProcesses(this.launchedProfileDir);
|
|
1049
1166
|
}
|
|
1050
1167
|
if (this.profileRoot !== void 0) {
|
|
1051
|
-
for (const slot of
|
|
1052
|
-
const dir =
|
|
1168
|
+
for (const slot of BROWSER_AGENT_PROFILE_SLOTS) {
|
|
1169
|
+
const dir = browserAgentProfileSlotDir(this.profileRoot, slot);
|
|
1053
1170
|
if (dir !== activeProfileDir) stopAgentBrowserProcesses(dir);
|
|
1054
1171
|
}
|
|
1055
1172
|
}
|
|
@@ -1382,7 +1499,7 @@ async function listHttpAnchors(page) {
|
|
|
1382
1499
|
// src/host/browser-agent/prompt.ts
|
|
1383
1500
|
var SECTION_NAME = "agent-enhancer:browser-agent";
|
|
1384
1501
|
var GUIDANCE = [
|
|
1385
|
-
"## Browser agent (Desktop dedicated Chrome/Edge)",
|
|
1502
|
+
"## Browser agent (Desktop dedicated browser: Safari/Chrome on Mac, Chrome/Edge on Windows)",
|
|
1386
1503
|
"When the user asks to open a website, browse the web, click pages, fill forms, read on-page content, log into a site, or verify UI in a real browser, you MUST use the browser_* tools \u2014 do not only describe steps or ask the user to open a browser manually.",
|
|
1387
1504
|
"Goal phases: (1) reach the target page once, (2) stay and observe/extract, (3) answer the user. Do not keep navigating without a new user goal.",
|
|
1388
1505
|
"Preferred loop: browser_navigate (or reuse a tab) \u2192 browser_wait if slow \u2192 browser_snapshot \u2192 click/type/scroll using listed refs \u2192 browser_snapshot or browser_extract again.",
|
|
@@ -1838,7 +1955,7 @@ function registerBrowserTools(ctx, options) {
|
|
|
1838
1955
|
};
|
|
1839
1956
|
disposers.push(ctx.tools.register(textTool(
|
|
1840
1957
|
"browser_status",
|
|
1841
|
-
"Check the Desktop dedicated-browser bridge (Chrome/Edge
|
|
1958
|
+
"Check the Desktop dedicated-browser bridge (Mac: Safari/Chrome; Windows: Chrome/Edge): connection, bound tab URL/title/tabId. Use this for any real-browser / webpage / on-page task. Auto-launches the dedicated browser when disconnected \u2014 do not ask the user to launch manually first.",
|
|
1842
1959
|
{},
|
|
1843
1960
|
async (_args, exec) => {
|
|
1844
1961
|
guardEnabled();
|
|
@@ -2493,8 +2610,8 @@ function installBrowserAgent(ctx, options) {
|
|
|
2493
2610
|
options.browserPreference()
|
|
2494
2611
|
);
|
|
2495
2612
|
const stopAllProfileSlots = () => {
|
|
2496
|
-
for (const slot of
|
|
2497
|
-
stopAgentBrowserProcesses(
|
|
2613
|
+
for (const slot of BROWSER_AGENT_PROFILE_SLOTS) {
|
|
2614
|
+
stopAgentBrowserProcesses(browserAgentProfileSlotDir(options.profileRoot, slot));
|
|
2498
2615
|
}
|
|
2499
2616
|
};
|
|
2500
2617
|
const enqueueSwitch = (work) => {
|
|
@@ -2537,8 +2654,10 @@ function installBrowserAgent(ctx, options) {
|
|
|
2537
2654
|
if (activeDriver === null || mountedPreference !== preference) return false;
|
|
2538
2655
|
const status = activeDriver.status();
|
|
2539
2656
|
if (!status.ready) return true;
|
|
2540
|
-
const
|
|
2541
|
-
|
|
2657
|
+
const endpoint = status.endpoint ?? "";
|
|
2658
|
+
if (!endpoint.startsWith("playwright:")) return false;
|
|
2659
|
+
const channel = endpoint.slice("playwright:".length);
|
|
2660
|
+
return playwrightChannelSatisfiesPreference(channel, preference, process.platform);
|
|
2542
2661
|
};
|
|
2543
2662
|
const createDriver = (_preference) => {
|
|
2544
2663
|
mountedPreference = options.browserPreference();
|
|
@@ -2797,7 +2916,7 @@ var AuxiliaryError = class extends Error {
|
|
|
2797
2916
|
// src/identity.ts
|
|
2798
2917
|
var PACKAGE_NAME = "dsh-agent-enhancer";
|
|
2799
2918
|
var PLUGIN_ID = "agent-enhancer";
|
|
2800
|
-
var PACKAGE_VERSION = "0.3.
|
|
2919
|
+
var PACKAGE_VERSION = "0.3.11";
|
|
2801
2920
|
var LEGACY_PACKAGE_NAME = "dsh-composer-enhancer";
|
|
2802
2921
|
var ROLLBACK_PREFIX = `${PACKAGE_NAME}:rollback:`;
|
|
2803
2922
|
var UNDO_PREFIX = `${PACKAGE_NAME}:undo:`;
|
|
@@ -5941,7 +6060,7 @@ var SessionCleanupRegistry = class {
|
|
|
5941
6060
|
|
|
5942
6061
|
// src/host/session-delete/plugin-purge.ts
|
|
5943
6062
|
import { createHash as createHash4 } from "node:crypto";
|
|
5944
|
-
import { existsSync as
|
|
6063
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
5945
6064
|
import { readdir as readdir3, readFile as readFile4, rm, unlink as unlink4 } from "node:fs/promises";
|
|
5946
6065
|
import { join as join7 } from "node:path";
|
|
5947
6066
|
function digest4(value) {
|
|
@@ -5951,7 +6070,7 @@ function shortDigest(value, length = 16) {
|
|
|
5951
6070
|
return digest4(value).slice(0, length);
|
|
5952
6071
|
}
|
|
5953
6072
|
async function removeIfPresent4(path) {
|
|
5954
|
-
if (!
|
|
6073
|
+
if (!existsSync3(path)) return false;
|
|
5955
6074
|
await rm(path, { recursive: true, force: true });
|
|
5956
6075
|
return true;
|
|
5957
6076
|
}
|
|
@@ -6016,7 +6135,7 @@ function createContextExcludeCleaner(pluginDataRoot) {
|
|
|
6016
6135
|
|
|
6017
6136
|
// src/host/session-delete/delete.ts
|
|
6018
6137
|
import { createHash as createHash5 } from "node:crypto";
|
|
6019
|
-
import { existsSync as
|
|
6138
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
6020
6139
|
import { appendFile, mkdir as mkdir4, readdir as readdir4, rm as rm2 } from "node:fs/promises";
|
|
6021
6140
|
import { homedir as homedir2, tmpdir } from "node:os";
|
|
6022
6141
|
import { join as join8 } from "node:path";
|
|
@@ -6241,7 +6360,7 @@ async function forgetInRegistry(ctx, sessionId, options) {
|
|
|
6241
6360
|
return removed;
|
|
6242
6361
|
}
|
|
6243
6362
|
async function removePathBestEffort(path) {
|
|
6244
|
-
if (!
|
|
6363
|
+
if (!existsSync4(path)) return false;
|
|
6245
6364
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
6246
6365
|
try {
|
|
6247
6366
|
await rm2(path, { recursive: true, force: true });
|
|
@@ -6256,10 +6375,10 @@ async function removePathBestEffort(path) {
|
|
|
6256
6375
|
async function eraseSessionLog(sessionId) {
|
|
6257
6376
|
const removed = [];
|
|
6258
6377
|
const root = sessionsRoot();
|
|
6259
|
-
if (!
|
|
6378
|
+
if (!existsSync4(root)) return removed;
|
|
6260
6379
|
for (const workspaceDir of await readdir4(root)) {
|
|
6261
6380
|
const target = join8(root, workspaceDir, sessionId);
|
|
6262
|
-
if (!
|
|
6381
|
+
if (!existsSync4(target)) continue;
|
|
6263
6382
|
const normalizedRoot = root.toLowerCase();
|
|
6264
6383
|
if (!target.toLowerCase().startsWith(normalizedRoot)) continue;
|
|
6265
6384
|
if (await removePathBestEffort(target)) removed.push(target);
|
|
@@ -6278,7 +6397,7 @@ async function eraseSpill(sessionId) {
|
|
|
6278
6397
|
for (const entry of entries) {
|
|
6279
6398
|
if (!SPILL_ROOT_RE.test(entry)) continue;
|
|
6280
6399
|
const target = join8(spillBase(), entry, name2);
|
|
6281
|
-
if (!
|
|
6400
|
+
if (!existsSync4(target)) continue;
|
|
6282
6401
|
if (await removePathBestEffort(target)) removed.push(target);
|
|
6283
6402
|
}
|
|
6284
6403
|
return removed;
|
|
@@ -6306,7 +6425,7 @@ async function eraseProjcache(ctx, sessionId) {
|
|
|
6306
6425
|
join8(projcacheSessionsDir(), `${sessionId}.json`),
|
|
6307
6426
|
join8(projcacheSessionsDir(), `${uuid}.json`)
|
|
6308
6427
|
]) {
|
|
6309
|
-
if (!
|
|
6428
|
+
if (!existsSync4(cacheFile)) continue;
|
|
6310
6429
|
if (await removePathBestEffort(cacheFile)) removed.push(cacheFile);
|
|
6311
6430
|
}
|
|
6312
6431
|
return removed;
|
|
@@ -6378,7 +6497,7 @@ async function deleteSessionNow(options) {
|
|
|
6378
6497
|
|
|
6379
6498
|
// src/host/web-chat-bridge/import-session.ts
|
|
6380
6499
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
6381
|
-
import { existsSync as
|
|
6500
|
+
import { existsSync as existsSync5, statSync } from "node:fs";
|
|
6382
6501
|
import { resolve as resolve2 } from "node:path";
|
|
6383
6502
|
import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
|
|
6384
6503
|
import {
|
|
@@ -6972,7 +7091,7 @@ async function createWebChatWorkspaceNow(ctx, signal) {
|
|
|
6972
7091
|
signal.throwIfAborted();
|
|
6973
7092
|
const absolute = resolve2(picked.path);
|
|
6974
7093
|
try {
|
|
6975
|
-
if (!
|
|
7094
|
+
if (!existsSync5(absolute) || !statSync(absolute).isDirectory()) {
|
|
6976
7095
|
throw new WebChatImportError(
|
|
6977
7096
|
"import-failed",
|
|
6978
7097
|
`Selected folder does not exist: ${absolute}`
|
|
@@ -7571,7 +7690,7 @@ async function fetchWebChatShareContent(shareId, signal) {
|
|
|
7571
7690
|
}
|
|
7572
7691
|
|
|
7573
7692
|
// src/host/web-chat-bridge/login-snapshot.ts
|
|
7574
|
-
import { existsSync as
|
|
7693
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7575
7694
|
import { dirname, join as join9 } from "node:path";
|
|
7576
7695
|
|
|
7577
7696
|
// src/host/web-chat-bridge/login-snapshot-types.ts
|
|
@@ -7638,7 +7757,7 @@ function parseSnapshot(raw) {
|
|
|
7638
7757
|
}
|
|
7639
7758
|
function loadWebChatLoginSnapshot(pluginDataPackageRoot) {
|
|
7640
7759
|
const path = webChatLoginSnapshotPath(pluginDataPackageRoot);
|
|
7641
|
-
if (!
|
|
7760
|
+
if (!existsSync6(path)) return null;
|
|
7642
7761
|
try {
|
|
7643
7762
|
return parseSnapshot(readFileSync(path, "utf8"));
|
|
7644
7763
|
} catch {
|
|
@@ -7674,7 +7793,7 @@ function saveWebChatLoginSnapshot(pluginDataPackageRoot, input, options) {
|
|
|
7674
7793
|
}
|
|
7675
7794
|
function clearWebChatLoginSnapshot(pluginDataPackageRoot) {
|
|
7676
7795
|
const path = webChatLoginSnapshotPath(pluginDataPackageRoot);
|
|
7677
|
-
if (!
|
|
7796
|
+
if (!existsSync6(path)) return false;
|
|
7678
7797
|
try {
|
|
7679
7798
|
unlinkSync(path);
|
|
7680
7799
|
return true;
|
|
@@ -8187,7 +8306,7 @@ async function writeWorkspaceFileNow(options) {
|
|
|
8187
8306
|
}
|
|
8188
8307
|
|
|
8189
8308
|
// src/host/file-edit/monaco.ts
|
|
8190
|
-
import { existsSync as
|
|
8309
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
8191
8310
|
import { promises as fsp2 } from "node:fs";
|
|
8192
8311
|
import { dirname as dirname3, extname, join as join12, resolve as resolve6, sep as sep5 } from "node:path";
|
|
8193
8312
|
import { fileURLToPath } from "node:url";
|
|
@@ -8207,7 +8326,7 @@ function packageRootCandidates() {
|
|
|
8207
8326
|
}
|
|
8208
8327
|
function resolveMonacoVsDir() {
|
|
8209
8328
|
for (const candidate of packageRootCandidates()) {
|
|
8210
|
-
if (
|
|
8329
|
+
if (existsSync7(join12(candidate, "loader.js"))) return candidate;
|
|
8211
8330
|
}
|
|
8212
8331
|
return packageRootCandidates()[0];
|
|
8213
8332
|
}
|
|
@@ -8344,15 +8463,15 @@ function installMonacoRoute(ctx) {
|
|
|
8344
8463
|
}
|
|
8345
8464
|
|
|
8346
8465
|
// src/host/instructions-skills/io.ts
|
|
8347
|
-
import { existsSync as
|
|
8466
|
+
import { existsSync as existsSync17, readFileSync as readFileSync7, statSync as statSync5 } from "node:fs";
|
|
8348
8467
|
import { basename as basename13, join as join26, resolve as resolve16, sep as sep7 } from "node:path";
|
|
8349
8468
|
|
|
8350
8469
|
// src/host/instructions-skills/create.ts
|
|
8351
|
-
import { existsSync as
|
|
8470
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8352
8471
|
import { dirname as dirname5, join as join14, resolve as resolve8 } from "node:path";
|
|
8353
8472
|
|
|
8354
8473
|
// src/host/instructions-skills/paths.ts
|
|
8355
|
-
import { existsSync as
|
|
8474
|
+
import { existsSync as existsSync8, statSync as statSync2 } from "node:fs";
|
|
8356
8475
|
import { basename as basename5, dirname as dirname4, join as join13, resolve as resolve7, sep as sep6 } from "node:path";
|
|
8357
8476
|
import { homedir as homedir3 } from "node:os";
|
|
8358
8477
|
var INSTRUCTION_CANDIDATES = [
|
|
@@ -8376,7 +8495,7 @@ function findProjectRoot(cwd, markers = PROJECT_ROOT_MARKERS) {
|
|
|
8376
8495
|
let current = resolve7(cwd);
|
|
8377
8496
|
for (; ; ) {
|
|
8378
8497
|
for (const marker of markers) {
|
|
8379
|
-
if (
|
|
8498
|
+
if (existsSync8(join13(current, marker))) return current;
|
|
8380
8499
|
}
|
|
8381
8500
|
const parent = dirname4(current);
|
|
8382
8501
|
if (parent === current) return resolve7(cwd);
|
|
@@ -8473,7 +8592,7 @@ Instructions for the agent go here.
|
|
|
8473
8592
|
}
|
|
8474
8593
|
function createWorkspaceAgentsFile(projectRoot) {
|
|
8475
8594
|
const path = resolve8(projectRoot, "AGENTS.md");
|
|
8476
|
-
if (
|
|
8595
|
+
if (existsSync9(path)) {
|
|
8477
8596
|
throw new AuxiliaryError("FILE_DENIED", "AGENTS.md already exists at the workspace root");
|
|
8478
8597
|
}
|
|
8479
8598
|
mkdirSync4(dirname5(path), { recursive: true });
|
|
@@ -8487,7 +8606,7 @@ function createWorkspaceSkill(projectRoot, rawName) {
|
|
|
8487
8606
|
}
|
|
8488
8607
|
const dir = join14(resolve8(projectRoot), ".agents", "skills", name2);
|
|
8489
8608
|
const path = join14(dir, "SKILL.md");
|
|
8490
|
-
if (
|
|
8609
|
+
if (existsSync9(path) || existsSync9(dir)) {
|
|
8491
8610
|
throw new AuxiliaryError("FILE_DENIED", "A skill with that name already exists");
|
|
8492
8611
|
}
|
|
8493
8612
|
mkdirSync4(dir, { recursive: true });
|
|
@@ -8496,7 +8615,7 @@ function createWorkspaceSkill(projectRoot, rawName) {
|
|
|
8496
8615
|
}
|
|
8497
8616
|
|
|
8498
8617
|
// src/host/instructions-skills/discover.ts
|
|
8499
|
-
import { existsSync as
|
|
8618
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
8500
8619
|
import { basename as basename9, dirname as dirname8, join as join19, resolve as resolve12 } from "node:path";
|
|
8501
8620
|
|
|
8502
8621
|
// src/host/instructions-skills/types.ts
|
|
@@ -8510,7 +8629,7 @@ function defaultSkillInstallMeta() {
|
|
|
8510
8629
|
}
|
|
8511
8630
|
|
|
8512
8631
|
// src/host/instructions-skills/transient-paths.ts
|
|
8513
|
-
import { existsSync as
|
|
8632
|
+
import { existsSync as existsSync10, lstatSync, readdirSync, renameSync as renameSync3, rmSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
8514
8633
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
8515
8634
|
import { basename as basename6, join as join15, resolve as resolve9 } from "node:path";
|
|
8516
8635
|
var TRANSIENT_MARK = /\.__ae_(?:removing|installing)_/;
|
|
@@ -8565,7 +8684,7 @@ function removeQuietly(path) {
|
|
|
8565
8684
|
} catch {
|
|
8566
8685
|
return;
|
|
8567
8686
|
}
|
|
8568
|
-
if (!
|
|
8687
|
+
if (!existsSync10(path)) return;
|
|
8569
8688
|
try {
|
|
8570
8689
|
rmSync(path, { recursive: true, force: true, maxRetries: 2, retryDelay: 20 });
|
|
8571
8690
|
} catch {
|
|
@@ -8577,7 +8696,7 @@ import { lstatSync as lstatSync3 } from "node:fs";
|
|
|
8577
8696
|
import { basename as basename8, dirname as dirname7, join as join18, resolve as resolve11 } from "node:path";
|
|
8578
8697
|
|
|
8579
8698
|
// src/host/instructions-skills/install-ledger.ts
|
|
8580
|
-
import { existsSync as
|
|
8699
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync3, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
8581
8700
|
import { dirname as dirname6, join as join16 } from "node:path";
|
|
8582
8701
|
function ledgerPath(dataRoot) {
|
|
8583
8702
|
return join16(dataRoot, "skills-install", "registry.json");
|
|
@@ -8592,7 +8711,7 @@ function writeLedger(dataRoot, ledger) {
|
|
|
8592
8711
|
}
|
|
8593
8712
|
function readInstallLedger(dataRoot) {
|
|
8594
8713
|
const path = ledgerPath(dataRoot);
|
|
8595
|
-
if (!
|
|
8714
|
+
if (!existsSync11(path)) return {};
|
|
8596
8715
|
try {
|
|
8597
8716
|
const raw = readFileSync3(path, "utf8").trim();
|
|
8598
8717
|
if (raw === "") return {};
|
|
@@ -8616,7 +8735,7 @@ function removeInstallRecord(dataRoot, name2) {
|
|
|
8616
8735
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8617
8736
|
import {
|
|
8618
8737
|
chmodSync,
|
|
8619
|
-
existsSync as
|
|
8738
|
+
existsSync as existsSync12,
|
|
8620
8739
|
lstatSync as lstatSync2,
|
|
8621
8740
|
readdirSync as readdirSync2,
|
|
8622
8741
|
readlinkSync,
|
|
@@ -8698,12 +8817,12 @@ function isReparseOrSymlink(path) {
|
|
|
8698
8817
|
}
|
|
8699
8818
|
}
|
|
8700
8819
|
function effectivelyGone(target) {
|
|
8701
|
-
if (!pathPresent(target) && !
|
|
8820
|
+
if (!pathPresent(target) && !existsSync12(target)) return true;
|
|
8702
8821
|
try {
|
|
8703
8822
|
const stat = lstatSync2(target);
|
|
8704
8823
|
if (stat.isSymbolicLink()) return false;
|
|
8705
8824
|
if (!stat.isDirectory()) return false;
|
|
8706
|
-
if (
|
|
8825
|
+
if (existsSync12(join17(target, "SKILL.md"))) return false;
|
|
8707
8826
|
let names;
|
|
8708
8827
|
try {
|
|
8709
8828
|
names = readdirSync2(target);
|
|
@@ -8733,7 +8852,7 @@ function unlinkMountOnly(absolute) {
|
|
|
8733
8852
|
return false;
|
|
8734
8853
|
}
|
|
8735
8854
|
}
|
|
8736
|
-
return !pathPresent(absolute) && !
|
|
8855
|
+
return !pathPresent(absolute) && !existsSync12(absolute);
|
|
8737
8856
|
}
|
|
8738
8857
|
function tryUnlinkReparseOrFile(absolute) {
|
|
8739
8858
|
let preferUnlink = false;
|
|
@@ -8753,7 +8872,7 @@ function removePathRobust(target) {
|
|
|
8753
8872
|
if (isProtectedExternalSkillPath(absolute)) {
|
|
8754
8873
|
return;
|
|
8755
8874
|
}
|
|
8756
|
-
if (!pathPresent(absolute) && !
|
|
8875
|
+
if (!pathPresent(absolute) && !existsSync12(absolute)) return;
|
|
8757
8876
|
if (isReparseOrSymlink(absolute)) {
|
|
8758
8877
|
if (unlinkMountOnly(absolute)) return;
|
|
8759
8878
|
if (effectivelyGone(absolute)) return;
|
|
@@ -8771,7 +8890,7 @@ function removePathRobust(target) {
|
|
|
8771
8890
|
} catch (error) {
|
|
8772
8891
|
if (!isWindowsPathBusyError(error) && effectivelyGone(absolute)) return;
|
|
8773
8892
|
}
|
|
8774
|
-
if (!pathPresent(absolute) && !
|
|
8893
|
+
if (!pathPresent(absolute) && !existsSync12(absolute)) return;
|
|
8775
8894
|
try {
|
|
8776
8895
|
const aside = renameAsideToTemp(absolute, "removing");
|
|
8777
8896
|
removeQuietly(aside);
|
|
@@ -8791,10 +8910,10 @@ function removePathRobust(target) {
|
|
|
8791
8910
|
} catch {
|
|
8792
8911
|
}
|
|
8793
8912
|
}
|
|
8794
|
-
if (!pathPresent(absolute) && !
|
|
8913
|
+
if (!pathPresent(absolute) && !existsSync12(absolute)) return;
|
|
8795
8914
|
if (effectivelyGone(absolute)) return;
|
|
8796
8915
|
}
|
|
8797
|
-
if (effectivelyGone(absolute) || !pathPresent(absolute) && !
|
|
8916
|
+
if (effectivelyGone(absolute) || !pathPresent(absolute) && !existsSync12(absolute)) return;
|
|
8798
8917
|
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename7(absolute)));
|
|
8799
8918
|
}
|
|
8800
8919
|
|
|
@@ -8920,7 +9039,7 @@ function discoverInstructionFiles(options) {
|
|
|
8920
9039
|
scope: "global",
|
|
8921
9040
|
name: "AGENTS.md",
|
|
8922
9041
|
path: globalPath,
|
|
8923
|
-
exists:
|
|
9042
|
+
exists: existsSync13(globalPath),
|
|
8924
9043
|
bytes: fileBytes(globalPath),
|
|
8925
9044
|
createable: false
|
|
8926
9045
|
});
|
|
@@ -8930,7 +9049,7 @@ function discoverInstructionFiles(options) {
|
|
|
8930
9049
|
scope: "shared",
|
|
8931
9050
|
name: "AGENTS.md",
|
|
8932
9051
|
path: sharedPath,
|
|
8933
|
-
exists:
|
|
9052
|
+
exists: existsSync13(sharedPath),
|
|
8934
9053
|
bytes: fileBytes(sharedPath),
|
|
8935
9054
|
createable: false
|
|
8936
9055
|
});
|
|
@@ -8940,14 +9059,14 @@ function discoverInstructionFiles(options) {
|
|
|
8940
9059
|
scope: "project",
|
|
8941
9060
|
name: "AGENTS.md",
|
|
8942
9061
|
path: rootAgents,
|
|
8943
|
-
exists:
|
|
9062
|
+
exists: existsSync13(rootAgents),
|
|
8944
9063
|
bytes: fileBytes(rootAgents),
|
|
8945
|
-
createable: !
|
|
9064
|
+
createable: !existsSync13(rootAgents)
|
|
8946
9065
|
});
|
|
8947
9066
|
for (const dir of projectChainDirs(projectRoot, cwd)) {
|
|
8948
9067
|
for (const name2 of INSTRUCTION_CANDIDATES) {
|
|
8949
9068
|
const path = join19(dir, name2);
|
|
8950
|
-
if (!
|
|
9069
|
+
if (!existsSync13(path)) continue;
|
|
8951
9070
|
if (samePath2(path, rootAgents)) continue;
|
|
8952
9071
|
pushUnique(instructions, seen, {
|
|
8953
9072
|
id: entryId("project", path),
|
|
@@ -8992,7 +9111,7 @@ function discoverFilesystemSkills(options) {
|
|
|
8992
9111
|
for (const name2 of names) {
|
|
8993
9112
|
if (isTransientSkillEntryName(name2)) continue;
|
|
8994
9113
|
const skillMd = join19(root, name2, "SKILL.md");
|
|
8995
|
-
if (!
|
|
9114
|
+
if (!existsSync13(skillMd)) continue;
|
|
8996
9115
|
if (byName.has(name2)) continue;
|
|
8997
9116
|
byName.set(name2, {
|
|
8998
9117
|
id: `fs:${resolve12(skillMd).toLowerCase()}`,
|
|
@@ -9052,23 +9171,23 @@ function normalizeRegistrySkills(raw) {
|
|
|
9052
9171
|
function coerceSkillDocumentPath(path, _name) {
|
|
9053
9172
|
if (path === null || path.trim() === "") return null;
|
|
9054
9173
|
const absolute = resolve12(path.trim());
|
|
9055
|
-
if (
|
|
9174
|
+
if (existsSync13(absolute)) {
|
|
9056
9175
|
try {
|
|
9057
9176
|
if (statSync3(absolute).isFile()) return absolute;
|
|
9058
9177
|
} catch {
|
|
9059
9178
|
}
|
|
9060
9179
|
const asFile = join19(absolute, "SKILL.md");
|
|
9061
|
-
if (
|
|
9180
|
+
if (existsSync13(asFile)) return asFile;
|
|
9062
9181
|
}
|
|
9063
9182
|
const lower = absolute.toLowerCase();
|
|
9064
9183
|
if (lower.endsWith("skill.md") || lower.endsWith(".md")) return absolute;
|
|
9065
9184
|
const nested = join19(absolute, "SKILL.md");
|
|
9066
|
-
return
|
|
9185
|
+
return existsSync13(nested) ? nested : absolute;
|
|
9067
9186
|
}
|
|
9068
9187
|
function resolveSkillPathFromRoots(name2, cwd, projectRoot, env) {
|
|
9069
9188
|
for (const root of previewSkillSearchRoots(cwd, projectRoot, env)) {
|
|
9070
9189
|
const skillMd = join19(root, name2, "SKILL.md");
|
|
9071
|
-
if (
|
|
9190
|
+
if (existsSync13(skillMd)) return resolve12(skillMd);
|
|
9072
9191
|
}
|
|
9073
9192
|
return null;
|
|
9074
9193
|
}
|
|
@@ -9229,7 +9348,7 @@ function parseGitSkillSource(raw) {
|
|
|
9229
9348
|
|
|
9230
9349
|
// src/host/instructions-skills/install.ts
|
|
9231
9350
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
9232
|
-
import { existsSync as
|
|
9351
|
+
import { existsSync as existsSync15, mkdtempSync, realpathSync, rmSync as rmSync4 } from "node:fs";
|
|
9233
9352
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
9234
9353
|
import { basename as basename11, dirname as dirname10, join as join23, resolve as resolve14 } from "node:path";
|
|
9235
9354
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -9403,7 +9522,7 @@ async function fetchGithubRepoArchive(options) {
|
|
|
9403
9522
|
// src/host/instructions-skills/install-fs.ts
|
|
9404
9523
|
import {
|
|
9405
9524
|
cpSync,
|
|
9406
|
-
existsSync as
|
|
9525
|
+
existsSync as existsSync14,
|
|
9407
9526
|
lstatSync as lstatSync4,
|
|
9408
9527
|
mkdirSync as mkdirSync7,
|
|
9409
9528
|
readdirSync as readdirSync5,
|
|
@@ -9435,9 +9554,9 @@ function directoryBundleName(dir, folderName) {
|
|
|
9435
9554
|
}
|
|
9436
9555
|
function findSkillBundles(root) {
|
|
9437
9556
|
const absolute = resolve13(root);
|
|
9438
|
-
if (!
|
|
9557
|
+
if (!existsSync14(absolute)) return [];
|
|
9439
9558
|
const rootSkill = join21(absolute, "SKILL.md");
|
|
9440
|
-
if (
|
|
9559
|
+
if (existsSync14(rootSkill)) {
|
|
9441
9560
|
const folderName = basename10(absolute);
|
|
9442
9561
|
const name2 = directoryBundleName(absolute, folderName);
|
|
9443
9562
|
if (isKebabCaseName(name2)) {
|
|
@@ -9454,7 +9573,7 @@ function findSkillBundles(root) {
|
|
|
9454
9573
|
for (const entry of entries) {
|
|
9455
9574
|
if (isTransientSkillEntryName(entry)) continue;
|
|
9456
9575
|
const full = join21(absolute, entry);
|
|
9457
|
-
if (
|
|
9576
|
+
if (existsSync14(join21(full, "SKILL.md"))) {
|
|
9458
9577
|
const name2 = directoryBundleName(full, entry);
|
|
9459
9578
|
if (!isKebabCaseName(name2)) continue;
|
|
9460
9579
|
out.push({ name: name2, sourcePath: full, kind: "directory" });
|
|
@@ -9476,10 +9595,10 @@ function findSkillBundles(root) {
|
|
|
9476
9595
|
}
|
|
9477
9596
|
function resolveBundlesFromClone(cloneRoot, subpath) {
|
|
9478
9597
|
const base = subpath === null || subpath === "" ? resolve13(cloneRoot) : resolve13(cloneRoot, subpath);
|
|
9479
|
-
if (!
|
|
9598
|
+
if (!existsSync14(base)) {
|
|
9480
9599
|
throw new AuxiliaryError("FILE_NOT_FOUND", `Path not found in repository: ${subpath ?? "."}`);
|
|
9481
9600
|
}
|
|
9482
|
-
if (base.toLowerCase().endsWith("skill.md") &&
|
|
9601
|
+
if (base.toLowerCase().endsWith("skill.md") && existsSync14(base)) {
|
|
9483
9602
|
const dir = dirname9(base);
|
|
9484
9603
|
const name2 = directoryBundleName(dir, basename10(dir));
|
|
9485
9604
|
if (!isKebabCaseName(name2)) {
|
|
@@ -9531,13 +9650,13 @@ function isStaleSkillDestination(dest, kind) {
|
|
|
9531
9650
|
if (kind === "file") {
|
|
9532
9651
|
try {
|
|
9533
9652
|
const stat = lstatSync4(dest);
|
|
9534
|
-
if (stat.isSymbolicLink()) return !
|
|
9653
|
+
if (stat.isSymbolicLink()) return !existsSync14(dest);
|
|
9535
9654
|
return !stat.isFile();
|
|
9536
9655
|
} catch {
|
|
9537
9656
|
return true;
|
|
9538
9657
|
}
|
|
9539
9658
|
}
|
|
9540
|
-
return !
|
|
9659
|
+
return !existsSync14(join21(dest, "SKILL.md"));
|
|
9541
9660
|
}
|
|
9542
9661
|
function copySkillTree(source, dest) {
|
|
9543
9662
|
try {
|
|
@@ -9590,7 +9709,7 @@ function linkOrCopy(source, dest, mode, kind) {
|
|
|
9590
9709
|
try {
|
|
9591
9710
|
if (process.platform === "win32") {
|
|
9592
9711
|
const stat = lstatSync4(source);
|
|
9593
|
-
if (stat.isDirectory() || stat.isSymbolicLink() &&
|
|
9712
|
+
if (stat.isDirectory() || stat.isSymbolicLink() && existsSync14(join21(source, "SKILL.md"))) {
|
|
9594
9713
|
symlinkSync(source, dest, "junction");
|
|
9595
9714
|
return "link";
|
|
9596
9715
|
}
|
|
@@ -10057,7 +10176,7 @@ async function checkGithubSkillUpdate(record2, options) {
|
|
|
10057
10176
|
|
|
10058
10177
|
// src/host/instructions-skills/zip-install.ts
|
|
10059
10178
|
import { execFile as execFile4 } from "node:child_process";
|
|
10060
|
-
import { existsSync as
|
|
10179
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync8, mkdtempSync as mkdtempSync3, realpathSync as realpathSync3, rmSync as rmSync6 } from "node:fs";
|
|
10061
10180
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
10062
10181
|
import { basename as basename12, join as join25, resolve as resolve15 } from "node:path";
|
|
10063
10182
|
import { promisify as promisify4 } from "node:util";
|
|
@@ -10086,7 +10205,7 @@ async function extractZipArchive(zipPath, destDir, signal) {
|
|
|
10086
10205
|
}
|
|
10087
10206
|
async function installSkillsFromZipFile(options) {
|
|
10088
10207
|
const zipPath = resolve15(options.zipPath);
|
|
10089
|
-
if (!
|
|
10208
|
+
if (!existsSync16(zipPath)) {
|
|
10090
10209
|
throw new AuxiliaryError("FILE_NOT_FOUND", `Zip not found: ${zipPath}`);
|
|
10091
10210
|
}
|
|
10092
10211
|
if (!zipPath.toLowerCase().endsWith(".zip")) {
|
|
@@ -10261,7 +10380,7 @@ function inferSkillInstallTarget(name2, cwd, projectRoot, env = process.env) {
|
|
|
10261
10380
|
const userAgents = join26(agentsHomeOf(env), "skills");
|
|
10262
10381
|
const userDsh = join26(dshHomeOf(env), "skills");
|
|
10263
10382
|
for (const root of roots) {
|
|
10264
|
-
const present =
|
|
10383
|
+
const present = existsSync17(join26(root, name2, "SKILL.md")) || existsSync17(join26(root, `${name2}.md`));
|
|
10265
10384
|
if (!present) continue;
|
|
10266
10385
|
if (samePath2(root, projectAgents)) return "project";
|
|
10267
10386
|
if (samePath2(root, projectDsh)) return "project-dsh";
|
|
@@ -10499,7 +10618,7 @@ async function readSkillDocumentNow(options) {
|
|
|
10499
10618
|
throw new AuxiliaryError("FILE_DENIED", "Only SKILL.md may be previewed");
|
|
10500
10619
|
}
|
|
10501
10620
|
options.signal.throwIfAborted();
|
|
10502
|
-
if (!
|
|
10621
|
+
if (!existsSync17(absolutePath2)) {
|
|
10503
10622
|
throw new AuxiliaryError("FILE_NOT_FOUND", "Skill document not found");
|
|
10504
10623
|
}
|
|
10505
10624
|
try {
|
|
@@ -10534,7 +10653,7 @@ async function readSkillDocumentNow(options) {
|
|
|
10534
10653
|
}
|
|
10535
10654
|
|
|
10536
10655
|
// src/host/mcp-connectors/io.ts
|
|
10537
|
-
import { existsSync as
|
|
10656
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
10538
10657
|
|
|
10539
10658
|
// src/host/mcp-connectors/validate.ts
|
|
10540
10659
|
var MCP_SERVER_NAME_PATTERN = /^[A-Za-z0-9_-]{1,32}$/;
|
|
@@ -10656,7 +10775,7 @@ function parseMcpJsonText(jsonText) {
|
|
|
10656
10775
|
}
|
|
10657
10776
|
|
|
10658
10777
|
// src/host/mcp-connectors/install-git.ts
|
|
10659
|
-
import { existsSync as
|
|
10778
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync9, readFileSync as readFileSync8, renameSync as renameSync7, rmSync as rmSync7 } from "node:fs";
|
|
10660
10779
|
import { join as join28 } from "node:path";
|
|
10661
10780
|
|
|
10662
10781
|
// src/host/mcp-connectors/paths.ts
|
|
@@ -10689,7 +10808,7 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
10689
10808
|
};
|
|
10690
10809
|
}
|
|
10691
10810
|
const pkgPath = join28(installDir, "package.json");
|
|
10692
|
-
if (!
|
|
10811
|
+
if (!existsSync18(pkgPath)) {
|
|
10693
10812
|
return {
|
|
10694
10813
|
transport: "stdio",
|
|
10695
10814
|
command: "npx",
|
|
@@ -10748,7 +10867,7 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
10748
10867
|
async function installMcpServerFromGit(options) {
|
|
10749
10868
|
const parsed = parseGitSkillSource(options.source);
|
|
10750
10869
|
const installDir = mcpServerInstallDir(options.rootDir, options.id);
|
|
10751
|
-
if (
|
|
10870
|
+
if (existsSync18(installDir)) {
|
|
10752
10871
|
if (!options.force) {
|
|
10753
10872
|
throw new AuxiliaryError("FILE_EDIT_FAILED", `MCP install dir already exists: ${installDir}`);
|
|
10754
10873
|
}
|
|
@@ -10757,7 +10876,7 @@ async function installMcpServerFromGit(options) {
|
|
|
10757
10876
|
mkdirSync9(join28(options.rootDir, "mcp-servers"), { recursive: true });
|
|
10758
10877
|
const staging = `${installDir}.staging.${process.pid}`;
|
|
10759
10878
|
try {
|
|
10760
|
-
if (
|
|
10879
|
+
if (existsSync18(staging)) removePathRobust(staging);
|
|
10761
10880
|
mkdirSync9(staging, { recursive: true });
|
|
10762
10881
|
if (parsed.github === null) {
|
|
10763
10882
|
throw new AuxiliaryError(
|
|
@@ -10775,7 +10894,7 @@ async function installMcpServerFromGit(options) {
|
|
|
10775
10894
|
let contentRoot = repoDir;
|
|
10776
10895
|
if (parsed.subpath !== null) {
|
|
10777
10896
|
const nested = join28(repoDir, parsed.subpath);
|
|
10778
|
-
if (!
|
|
10897
|
+
if (!existsSync18(nested)) {
|
|
10779
10898
|
throw new AuxiliaryError("FILE_EDIT_FAILED", `Subpath not found in repo: ${parsed.subpath}`);
|
|
10780
10899
|
}
|
|
10781
10900
|
contentRoot = nested;
|
|
@@ -10795,11 +10914,11 @@ async function installMcpServerFromGit(options) {
|
|
|
10795
10914
|
}
|
|
10796
10915
|
} catch (error) {
|
|
10797
10916
|
try {
|
|
10798
|
-
if (
|
|
10917
|
+
if (existsSync18(staging)) rmSync7(staging, { recursive: true, force: true });
|
|
10799
10918
|
} catch {
|
|
10800
10919
|
}
|
|
10801
10920
|
try {
|
|
10802
|
-
if (
|
|
10921
|
+
if (existsSync18(installDir)) removePathRobust(installDir);
|
|
10803
10922
|
} catch {
|
|
10804
10923
|
}
|
|
10805
10924
|
if (error instanceof AuxiliaryError) throw error;
|
|
@@ -10897,7 +11016,7 @@ async function uninstallMcpConnectorNow(host, request) {
|
|
|
10897
11016
|
}
|
|
10898
11017
|
const next = doc.connectors.filter((entry) => entry.id !== request.id);
|
|
10899
11018
|
const installDir = mcpServerInstallDir(host.store.rootDir, request.id);
|
|
10900
|
-
if (
|
|
11019
|
+
if (existsSync19(installDir)) {
|
|
10901
11020
|
try {
|
|
10902
11021
|
removePathRobust(installDir);
|
|
10903
11022
|
} catch (error) {
|
|
@@ -13804,10 +13923,10 @@ var browserAgentAuditEntrySchema = z4.strictObject({
|
|
|
13804
13923
|
});
|
|
13805
13924
|
var browserAgentSnapshotSchema = z4.strictObject({
|
|
13806
13925
|
enabled: z4.boolean(),
|
|
13807
|
-
/** Settings preference (auto / chrome / edge). */
|
|
13808
|
-
browser: z4.enum(["auto", "chrome", "edge"]),
|
|
13926
|
+
/** Settings preference (auto / chrome / edge / safari). */
|
|
13927
|
+
browser: z4.enum(["auto", "chrome", "edge", "safari"]),
|
|
13809
13928
|
/** Actually launched channel once ready; null when not running. */
|
|
13810
|
-
launchedBrowser: z4.enum(["chrome", "edge"]).nullable(),
|
|
13929
|
+
launchedBrowser: z4.enum(["chrome", "edge", "safari"]).nullable(),
|
|
13811
13930
|
/** Shipping driver (Playwright only after MV3 retirement). */
|
|
13812
13931
|
driver: z4.literal("playwright"),
|
|
13813
13932
|
allowedOrigins: z4.array(z4.string()),
|
|
@@ -13915,7 +14034,7 @@ var browserAgentQuotePageResultCodec = codec(
|
|
|
13915
14034
|
browserAgentQuotePageResultSchema
|
|
13916
14035
|
);
|
|
13917
14036
|
var browserAgentLaunchBrowserRequestSchema = z4.strictObject({
|
|
13918
|
-
browser: z4.enum(["auto", "chrome", "edge"]).optional()
|
|
14037
|
+
browser: z4.enum(["auto", "chrome", "edge", "safari"]).optional()
|
|
13919
14038
|
});
|
|
13920
14039
|
var browserAgentLaunchBrowserRequestCodec = codec(
|
|
13921
14040
|
"dsh-agent-enhancer#BrowserAgentLaunchBrowserRequest",
|
|
@@ -13923,7 +14042,7 @@ var browserAgentLaunchBrowserRequestCodec = codec(
|
|
|
13923
14042
|
);
|
|
13924
14043
|
var browserAgentLaunchBrowserResultSchema = z4.strictObject({
|
|
13925
14044
|
ok: z4.boolean(),
|
|
13926
|
-
browser: z4.enum(["chrome", "edge"]).optional(),
|
|
14045
|
+
browser: z4.enum(["chrome", "edge", "safari"]).optional(),
|
|
13927
14046
|
executable: z4.string().optional(),
|
|
13928
14047
|
profileDir: z4.string().min(1),
|
|
13929
14048
|
error: z4.string().optional(),
|
|
@@ -13934,7 +14053,7 @@ var browserAgentLaunchBrowserResultCodec = codec(
|
|
|
13934
14053
|
browserAgentLaunchBrowserResultSchema
|
|
13935
14054
|
);
|
|
13936
14055
|
var browserAgentSetBrowserRequestSchema = z4.strictObject({
|
|
13937
|
-
browser: z4.enum(["auto", "chrome", "edge"])
|
|
14056
|
+
browser: z4.enum(["auto", "chrome", "edge", "safari"])
|
|
13938
14057
|
});
|
|
13939
14058
|
var browserAgentSetBrowserRequestCodec = codec(
|
|
13940
14059
|
"dsh-agent-enhancer#BrowserAgentSetBrowserRequest",
|
|
@@ -13942,7 +14061,7 @@ var browserAgentSetBrowserRequestCodec = codec(
|
|
|
13942
14061
|
);
|
|
13943
14062
|
var browserAgentSetBrowserResultSchema = z4.strictObject({
|
|
13944
14063
|
ok: z4.boolean(),
|
|
13945
|
-
browser: z4.enum(["auto", "chrome", "edge"]),
|
|
14064
|
+
browser: z4.enum(["auto", "chrome", "edge", "safari"]),
|
|
13946
14065
|
snapshot: browserAgentSnapshotSchema
|
|
13947
14066
|
});
|
|
13948
14067
|
var browserAgentSetBrowserResultCodec = codec(
|
|
@@ -15240,11 +15359,14 @@ async function showOsNotificationNow(input) {
|
|
|
15240
15359
|
}
|
|
15241
15360
|
|
|
15242
15361
|
// src/host/update/check.ts
|
|
15243
|
-
import { homedir as
|
|
15244
|
-
import { join as
|
|
15362
|
+
import { homedir as homedir6 } from "node:os";
|
|
15363
|
+
import { join as join32 } from "node:path";
|
|
15245
15364
|
|
|
15246
15365
|
// src/host/update/cli.ts
|
|
15247
15366
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
15367
|
+
import { existsSync as existsSync20 } from "node:fs";
|
|
15368
|
+
import { homedir as homedir5 } from "node:os";
|
|
15369
|
+
import { posix as pathPosix2 } from "node:path";
|
|
15248
15370
|
function defaultSpawn(command, args, options) {
|
|
15249
15371
|
return nodeSpawn(command, [...args], options ?? {});
|
|
15250
15372
|
}
|
|
@@ -15254,6 +15376,40 @@ var STRICT_SEMVER = /^\d+\.\d+\.\d+$/;
|
|
|
15254
15376
|
function isStrictVersion(value) {
|
|
15255
15377
|
return STRICT_SEMVER.test(value);
|
|
15256
15378
|
}
|
|
15379
|
+
function dshFromElectronExecPath(execPath) {
|
|
15380
|
+
const normalized = execPath.replace(/\\/g, "/");
|
|
15381
|
+
const marker = "/Contents/MacOS/";
|
|
15382
|
+
const idx = normalized.lastIndexOf(marker);
|
|
15383
|
+
if (idx < 0) return null;
|
|
15384
|
+
const contentsRoot = normalized.slice(0, idx + "/Contents".length);
|
|
15385
|
+
return pathPosix2.join(contentsRoot, "Resources", "runtime", "cli", "bin", "dsh");
|
|
15386
|
+
}
|
|
15387
|
+
function dshExecutableCandidates(options = {}) {
|
|
15388
|
+
const platform = options.platform ?? process.platform;
|
|
15389
|
+
const env = options.env ?? process.env;
|
|
15390
|
+
const home = options.home ?? env.HOME?.trim() ?? homedir5();
|
|
15391
|
+
const execPath = options.execPath ?? process.execPath;
|
|
15392
|
+
const out = [];
|
|
15393
|
+
const push = (value) => {
|
|
15394
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
15395
|
+
if (trimmed === "" || out.includes(trimmed)) return;
|
|
15396
|
+
out.push(trimmed);
|
|
15397
|
+
};
|
|
15398
|
+
push(env.DSH_CLI);
|
|
15399
|
+
if (platform === "darwin") {
|
|
15400
|
+
push(dshFromElectronExecPath(execPath));
|
|
15401
|
+
push("/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh");
|
|
15402
|
+
push(pathPosix2.join(
|
|
15403
|
+
home,
|
|
15404
|
+
"Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"
|
|
15405
|
+
));
|
|
15406
|
+
}
|
|
15407
|
+
push("dsh");
|
|
15408
|
+
return out;
|
|
15409
|
+
}
|
|
15410
|
+
function isCommandMissingDetail(detail) {
|
|
15411
|
+
return /ENOENT|not found|spawn .*(ENOENT|not found)/i.test(detail);
|
|
15412
|
+
}
|
|
15257
15413
|
function dshSpawnOptions() {
|
|
15258
15414
|
const base = { stdio: ["ignore", "pipe", "pipe"] };
|
|
15259
15415
|
return process.platform === "win32" ? { ...base, shell: true, windowsHide: true } : base;
|
|
@@ -15292,29 +15448,42 @@ function waitForExit(child, timeoutMs) {
|
|
|
15292
15448
|
});
|
|
15293
15449
|
});
|
|
15294
15450
|
}
|
|
15295
|
-
async function
|
|
15451
|
+
async function runDshOnce(command, args, spawnFn, timeoutMs) {
|
|
15296
15452
|
let child;
|
|
15297
15453
|
try {
|
|
15298
|
-
child = spawnFn(
|
|
15454
|
+
child = spawnFn(command, args, dshSpawnOptions());
|
|
15299
15455
|
} catch (err) {
|
|
15300
15456
|
return { ok: false, detail: err instanceof Error ? err.message : String(err) };
|
|
15301
15457
|
}
|
|
15302
15458
|
return waitForExit(child, timeoutMs);
|
|
15303
15459
|
}
|
|
15304
|
-
async function
|
|
15305
|
-
const
|
|
15460
|
+
async function runDsh(args, spawnFn, timeoutMs, options = {}) {
|
|
15461
|
+
const candidates = options.candidates ?? dshExecutableCandidates();
|
|
15462
|
+
const exists = options.exists ?? existsSync20;
|
|
15463
|
+
let last = { ok: false, detail: "dsh not found" };
|
|
15464
|
+
for (const command of candidates) {
|
|
15465
|
+
if (command !== "dsh" && !exists(command)) continue;
|
|
15466
|
+
const result = await runDshOnce(command, args, spawnFn, timeoutMs);
|
|
15467
|
+
if (result.ok) return result;
|
|
15468
|
+
last = result;
|
|
15469
|
+
if (!isCommandMissingDetail(result.detail)) return result;
|
|
15470
|
+
}
|
|
15471
|
+
return last;
|
|
15472
|
+
}
|
|
15473
|
+
async function probeDsh(spawnFn = defaultSpawn, options = {}) {
|
|
15474
|
+
const result = await runDsh(["--version"], spawnFn, PROBE_TIMEOUT_MS, options);
|
|
15306
15475
|
return result.ok;
|
|
15307
15476
|
}
|
|
15308
|
-
async function runPluginAdd(latest, spawnFn = defaultSpawn) {
|
|
15477
|
+
async function runPluginAdd(latest, spawnFn = defaultSpawn, options = {}) {
|
|
15309
15478
|
if (!isStrictVersion(latest)) return { ok: false, detail: "invalid version" };
|
|
15310
|
-
return runDsh(pluginAddArgs(latest), spawnFn, RUN_ADD_TIMEOUT_MS);
|
|
15479
|
+
return runDsh(pluginAddArgs(latest), spawnFn, RUN_ADD_TIMEOUT_MS, options);
|
|
15311
15480
|
}
|
|
15312
15481
|
|
|
15313
15482
|
// src/host/update/install-kind.ts
|
|
15314
15483
|
import { lstatSync as lstatSync5 } from "node:fs";
|
|
15315
|
-
import { join as
|
|
15484
|
+
import { join as join31 } from "node:path";
|
|
15316
15485
|
function detectInstallKind(profileDir) {
|
|
15317
|
-
const pkgPath =
|
|
15486
|
+
const pkgPath = join31(profileDir, "node_modules", PACKAGE_NAME);
|
|
15318
15487
|
try {
|
|
15319
15488
|
const stat = lstatSync5(pkgPath);
|
|
15320
15489
|
if (stat.isSymbolicLink()) return "link";
|
|
@@ -15444,9 +15613,9 @@ function isNewerVersion(latest, current) {
|
|
|
15444
15613
|
}
|
|
15445
15614
|
|
|
15446
15615
|
// src/host/update/check.ts
|
|
15447
|
-
function resolveDesktopProfileDir(env = process.env, home =
|
|
15448
|
-
const dshHome2 = env.DSH_HOME ??
|
|
15449
|
-
return
|
|
15616
|
+
function resolveDesktopProfileDir(env = process.env, home = homedir6()) {
|
|
15617
|
+
const dshHome2 = env.DSH_HOME ?? join32(home, ".dsh");
|
|
15618
|
+
return join32(dshHome2, "profiles", "desktop");
|
|
15450
15619
|
}
|
|
15451
15620
|
async function checkPluginUpdate(deps) {
|
|
15452
15621
|
const latest = await deps.fetchLatest();
|
|
@@ -15503,6 +15672,12 @@ async function applyPluginUpdateForHost(messages, overrides) {
|
|
|
15503
15672
|
}
|
|
15504
15673
|
|
|
15505
15674
|
// src/host/index.ts
|
|
15675
|
+
function hostBrowserPreference(value) {
|
|
15676
|
+
return coerceBrowserAgentBrowserForPlatform(
|
|
15677
|
+
resolveBrowserAgentBrowser(value),
|
|
15678
|
+
process.platform
|
|
15679
|
+
);
|
|
15680
|
+
}
|
|
15506
15681
|
var name = PLUGIN_ID;
|
|
15507
15682
|
var inject = [
|
|
15508
15683
|
"llm",
|
|
@@ -15586,12 +15761,12 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
15586
15761
|
};
|
|
15587
15762
|
}
|
|
15588
15763
|
}, sessionCleanup = new SessionCleanupRegistry(), extraFolders = createExtraFoldersStore(
|
|
15589
|
-
|
|
15764
|
+
join33(homedir7(), ".dsh", "profiles", "desktop", "plugin-data", PACKAGE_NAME, "extra-folders")
|
|
15590
15765
|
), softPause = new SoftPauseGate(), softPauseEnabled = () => true, installLedgerRoot = void 0, mcpHost = null, browserAgent = null, browserAgentSettings = () => ({
|
|
15591
15766
|
enabled: false,
|
|
15592
15767
|
browser: "auto"
|
|
15593
15768
|
}), setBrowserAgentBrowser = () => void 0, browserAgentProfileDir = defaultBrowserAgentProfileDir(
|
|
15594
|
-
|
|
15769
|
+
join33(homedir7(), ".dsh", "profiles", "desktop", "plugin-data", PACKAGE_NAME)
|
|
15595
15770
|
)) {
|
|
15596
15771
|
super(ctx, "agentEnhancer");
|
|
15597
15772
|
this.models = models;
|
|
@@ -15634,7 +15809,7 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
15634
15809
|
const boundTabId = pending !== null ? this.browserAgent?.sessions.tabOf(pending.sessionId) ?? null : conflict !== null ? conflict.boundTabId : needsHuman !== null ? this.browserAgent?.sessions.tabOf(needsHuman.sessionId) ?? null : null;
|
|
15635
15810
|
const connected = driverStatus?.ready === true;
|
|
15636
15811
|
const endpoint = driverStatus?.endpoint ?? "playwright:unlaunched";
|
|
15637
|
-
const launched = endpoint === "playwright:msedge" ? "edge" : endpoint === "playwright:chrome" ? "chrome" : null;
|
|
15812
|
+
const launched = endpoint === "playwright:msedge" ? "edge" : endpoint === "playwright:chrome" ? "chrome" : endpoint === "playwright:webkit" ? "safari" : null;
|
|
15638
15813
|
return {
|
|
15639
15814
|
enabled: settings.enabled,
|
|
15640
15815
|
browser: settings.browser,
|
|
@@ -15836,7 +16011,7 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
15836
16011
|
}
|
|
15837
16012
|
}
|
|
15838
16013
|
webChatPluginDataRoot() {
|
|
15839
|
-
return this.installLedgerRoot ??
|
|
16014
|
+
return this.installLedgerRoot ?? join33(homedir7(), ".dsh", "profiles", "desktop", "plugin-data", PACKAGE_NAME);
|
|
15840
16015
|
}
|
|
15841
16016
|
/** User-level web chat guest login snapshot (non-HttpOnly storage only). */
|
|
15842
16017
|
async loadWebChatLoginSnapshot(_request, signal) {
|
|
@@ -16299,7 +16474,7 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
16299
16474
|
snapshot: this.browserSnapshotNow()
|
|
16300
16475
|
};
|
|
16301
16476
|
}
|
|
16302
|
-
const preference = request.browser ?? settings.browser;
|
|
16477
|
+
const preference = hostBrowserPreference(request.browser ?? settings.browser);
|
|
16303
16478
|
this.setBrowserAgentBrowser(preference);
|
|
16304
16479
|
const launched = await this.browserAgent?.launchDedicated(void 0, preference);
|
|
16305
16480
|
const snapshot = this.browserSnapshotNow();
|
|
@@ -16313,14 +16488,15 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
16313
16488
|
}
|
|
16314
16489
|
async browserAgentSetBrowser(request) {
|
|
16315
16490
|
this.assertOwner();
|
|
16316
|
-
|
|
16491
|
+
const preference = hostBrowserPreference(request.browser);
|
|
16492
|
+
this.setBrowserAgentBrowser(preference);
|
|
16317
16493
|
const settings = this.browserAgentSettings();
|
|
16318
16494
|
if (settings.enabled && this.browserAgent?.driverStatus()?.ready === true) {
|
|
16319
16495
|
await this.browserAgent.alignToPreference();
|
|
16320
16496
|
}
|
|
16321
16497
|
return {
|
|
16322
16498
|
ok: true,
|
|
16323
|
-
browser:
|
|
16499
|
+
browser: preference,
|
|
16324
16500
|
snapshot: this.browserSnapshotNow()
|
|
16325
16501
|
};
|
|
16326
16502
|
}
|
|
@@ -16336,16 +16512,16 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
16336
16512
|
}
|
|
16337
16513
|
};
|
|
16338
16514
|
function resolveCheckpointRoot(dshHome2) {
|
|
16339
|
-
const base =
|
|
16340
|
-
const nextPkg =
|
|
16341
|
-
const next =
|
|
16342
|
-
const prev =
|
|
16343
|
-
if (!
|
|
16515
|
+
const base = join33(dshHome2, "profiles", "desktop", "plugin-data");
|
|
16516
|
+
const nextPkg = join33(base, PACKAGE_NAME);
|
|
16517
|
+
const next = join33(nextPkg, "checkpoint");
|
|
16518
|
+
const prev = join33(base, LEGACY_PACKAGE_NAME, "checkpoint");
|
|
16519
|
+
if (!existsSync21(next) && existsSync21(prev)) {
|
|
16344
16520
|
mkdirSync11(nextPkg, { recursive: true });
|
|
16345
16521
|
renameSync9(prev, next);
|
|
16346
|
-
const prevPkg =
|
|
16522
|
+
const prevPkg = join33(base, LEGACY_PACKAGE_NAME);
|
|
16347
16523
|
try {
|
|
16348
|
-
if (
|
|
16524
|
+
if (existsSync21(prevPkg) && readdirSync7(prevPkg).length === 0) rmdirSync(prevPkg);
|
|
16349
16525
|
} catch {
|
|
16350
16526
|
}
|
|
16351
16527
|
}
|
|
@@ -16416,7 +16592,7 @@ function readSettings(config) {
|
|
|
16416
16592
|
runAlertsEnabled: config.runAlertsEnabled.get(),
|
|
16417
16593
|
runAlertsLevel: resolveRunAlertsLevel(config.runAlertsLevel.get()),
|
|
16418
16594
|
browserAgentEnabled: config.browserAgentEnabled.get(),
|
|
16419
|
-
browserAgentBrowser:
|
|
16595
|
+
browserAgentBrowser: hostBrowserPreference(config.browserAgentBrowser.get()),
|
|
16420
16596
|
webChatBridgeEnabled: config.webChatBridgeEnabled.get(),
|
|
16421
16597
|
instructionsSkillsEnabled: config.instructionsSkillsEnabled.get(),
|
|
16422
16598
|
mcpConnectorsEnabled: config.mcpConnectorsEnabled.get(),
|
|
@@ -16448,9 +16624,9 @@ function apply(ctx, config) {
|
|
|
16448
16624
|
const settings = () => readSettings(config);
|
|
16449
16625
|
const models = new AuxiliaryModels(ctx, settings);
|
|
16450
16626
|
installAutoSessionRoute(ctx, { settings });
|
|
16451
|
-
const storageRoot = resolveCheckpointRoot(process.env.DSH_HOME ??
|
|
16452
|
-
const pluginDataPackageRoot =
|
|
16453
|
-
const usage = new UsageLedger(
|
|
16627
|
+
const storageRoot = resolveCheckpointRoot(process.env.DSH_HOME ?? join33(homedir7(), ".dsh"));
|
|
16628
|
+
const pluginDataPackageRoot = join33(storageRoot, "..");
|
|
16629
|
+
const usage = new UsageLedger(join33(storageRoot, "..", "usage"), (message) => {
|
|
16454
16630
|
ctx.logger.warn(message);
|
|
16455
16631
|
});
|
|
16456
16632
|
const balancesFacade = (() => {
|
|
@@ -16480,12 +16656,12 @@ function apply(ctx, config) {
|
|
|
16480
16656
|
})();
|
|
16481
16657
|
installUsageObserver(ctx, usage);
|
|
16482
16658
|
const store = new CheckpointStore(storageRoot);
|
|
16483
|
-
const cutStore = new SessionCutStore(
|
|
16659
|
+
const cutStore = new SessionCutStore(join33(storageRoot, "cuts"));
|
|
16484
16660
|
const cutCache = /* @__PURE__ */ new Map();
|
|
16485
16661
|
const sessionCleanup = new SessionCleanupRegistry();
|
|
16486
16662
|
sessionCleanup.register(createCheckpointCleaner({ store, cutStore, storageRoot }));
|
|
16487
|
-
sessionCleanup.register(createContextExcludeCleaner(
|
|
16488
|
-
const extraFoldersStore = createExtraFoldersStore(
|
|
16663
|
+
sessionCleanup.register(createContextExcludeCleaner(join33(storageRoot, "..")));
|
|
16664
|
+
const extraFoldersStore = createExtraFoldersStore(join33(storageRoot, "..", "extra-folders"));
|
|
16489
16665
|
const softPauseGate = new SoftPauseGate();
|
|
16490
16666
|
const mcpStore = createMcpConnectorsStore(mcpConnectorsRoot(pluginDataPackageRoot));
|
|
16491
16667
|
const mcpRuntime = new McpConnectorRuntime(ctx, mcpStore);
|
|
@@ -16552,7 +16728,7 @@ function apply(ctx, config) {
|
|
|
16552
16728
|
browser: browserAgentLive.browser
|
|
16553
16729
|
}),
|
|
16554
16730
|
(browser) => {
|
|
16555
|
-
browserAgentLive.browser =
|
|
16731
|
+
browserAgentLive.browser = hostBrowserPreference(browser);
|
|
16556
16732
|
},
|
|
16557
16733
|
browserAgentProfileDir
|
|
16558
16734
|
);
|
|
@@ -16568,7 +16744,7 @@ function apply(ctx, config) {
|
|
|
16568
16744
|
const prevEnabled = browserAgentLive.enabled;
|
|
16569
16745
|
const prevBrowser = browserAgentLive.browser;
|
|
16570
16746
|
browserAgentLive.enabled = cfg.browserAgentEnabled.get();
|
|
16571
|
-
browserAgentLive.browser =
|
|
16747
|
+
browserAgentLive.browser = hostBrowserPreference(cfg.browserAgentBrowser.get());
|
|
16572
16748
|
if (prevEnabled !== browserAgentLive.enabled) {
|
|
16573
16749
|
browserAgent.refresh();
|
|
16574
16750
|
} else if (browserAgentLive.enabled && prevBrowser !== browserAgentLive.browser && browserAgent.driverStatus()?.ready === true) {
|