@dsh-workbench/adapter-probe 1.5.5-rc.0 → 1.5.6
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { basename, join } from 'node:path';
|
|
3
|
-
import { OPENCLI_PIN, PREFLIGHT_INSTALL_TIMEOUT_MS, PREFLIGHT_VERSION_TIMEOUT_MS, VERIFIED_DSH, dshHome, dshHostGapOf, dshTierOf, dshVersionFrom, hostOsOf, preflightHandler, quoteShellArgFor, workbenchRoot } from '@dsh-workbench/shared/host';
|
|
3
|
+
import { OPENCLI_PIN, PREFLIGHT_INSTALL_TIMEOUT_MS, PREFLIGHT_VERSION_TIMEOUT_MS, VERIFIED_DSH, dshHome, dshHostGapOf, dshTierOf, dshVersionFrom, hostOsOf, param, preflightHandler, quoteShellArgFor, workbenchRoot } from '@dsh-workbench/shared/host';
|
|
4
4
|
import { isOpencliAtPin, isOpencliAtPinAt, isOpencliReady, opencliBuiltAt, opencliPackageDir, opencliReadinessAt, storeDirFor, toolchainDir } from '@dsh-workbench/adapter-runtime';
|
|
5
5
|
import { WAKE_BROWSER_ROUTE } from '@dsh-workbench/shared/contract/protocol/preflight-wake';
|
|
6
6
|
import { runBootstrapCommand } from '../runtime/bootstrap-run.js';
|
|
@@ -177,8 +177,11 @@ export function registerPreflight(input) {
|
|
|
177
177
|
});
|
|
178
178
|
input.routes.preflight = preflightHandler(preflight);
|
|
179
179
|
if (desktopBrowser !== undefined) {
|
|
180
|
-
input.routes[WAKE_BROWSER_ROUTE] = async () => {
|
|
181
|
-
const
|
|
180
|
+
input.routes[WAKE_BROWSER_ROUTE] = async (search) => {
|
|
181
|
+
const pending = param(search, 'target') === 'extensions'
|
|
182
|
+
? desktopBrowser.openExtensions()
|
|
183
|
+
: desktopBrowser.wake();
|
|
184
|
+
const result = await pending.catch(() => ({ status: 'unknown' }));
|
|
182
185
|
return { ok: true, ...result };
|
|
183
186
|
};
|
|
184
187
|
}
|
|
@@ -3,6 +3,7 @@ import type { WakeBrowserReply } from '@dsh-workbench/shared/contract/protocol/p
|
|
|
3
3
|
export interface DesktopBrowser {
|
|
4
4
|
observe(): Promise<void>;
|
|
5
5
|
wake(): Promise<WakeBrowserReply>;
|
|
6
|
+
openExtensions(): Promise<WakeBrowserReply>;
|
|
6
7
|
}
|
|
7
8
|
export declare function createDesktopBrowser(options: {
|
|
8
9
|
seam: Seam;
|
|
@@ -11,6 +11,7 @@ function isBrowserId(value) {
|
|
|
11
11
|
function specOf(id) {
|
|
12
12
|
return BROWSER_SPECS.find((item) => item.id === id) ?? BROWSER_SPECS[0];
|
|
13
13
|
}
|
|
14
|
+
const EXTENSIONS_URL = 'chrome://extensions';
|
|
14
15
|
const WAKE_WAIT_MS = 12_000;
|
|
15
16
|
const SHORT_WAIT_MS = 3_000;
|
|
16
17
|
const POLL_MS = 500;
|
|
@@ -104,11 +105,12 @@ export function createDesktopBrowser(options) {
|
|
|
104
105
|
const local = `/Applications/${label}.app`;
|
|
105
106
|
return exists(local) ? local : join(home, 'Applications', `${label}.app`);
|
|
106
107
|
}
|
|
107
|
-
async function launch(id) {
|
|
108
|
+
async function launch(id, url) {
|
|
108
109
|
const spec = browserLaunchOf(id, hostOsOf(platform), {
|
|
109
110
|
appPath: appPath(id),
|
|
110
111
|
executable: executableOf(id),
|
|
111
112
|
linuxBinary: specOf(id).linuxBinary,
|
|
113
|
+
...(url === undefined ? {} : { url }),
|
|
112
114
|
});
|
|
113
115
|
if (spec === undefined)
|
|
114
116
|
return false;
|
|
@@ -159,7 +161,18 @@ export function createDesktopBrowser(options) {
|
|
|
159
161
|
}
|
|
160
162
|
return { status: 'not-connected', browser: target };
|
|
161
163
|
}
|
|
162
|
-
|
|
164
|
+
async function openExtensions() {
|
|
165
|
+
if (!browserWakeSupportedOf(platform))
|
|
166
|
+
return { status: 'unsupported' };
|
|
167
|
+
const target = pickTarget(await running());
|
|
168
|
+
if (target === undefined)
|
|
169
|
+
return { status: 'no-browser' };
|
|
170
|
+
if (!(await launch(target, EXTENSIONS_URL)))
|
|
171
|
+
return { status: 'launch-failed', browser: target };
|
|
172
|
+
save(target);
|
|
173
|
+
return { status: 'browser-open', browser: target };
|
|
174
|
+
}
|
|
175
|
+
return { observe, wake, openExtensions };
|
|
163
176
|
}
|
|
164
177
|
export function bridgeFixCommand(command, issues, platform) {
|
|
165
178
|
return bridgeFixOf(command, issues, hostOsOf(platform));
|
|
@@ -2,6 +2,7 @@ export interface ToolchainLockOptions {
|
|
|
2
2
|
readonly waitMs?: number | undefined;
|
|
3
3
|
readonly staleMs?: number | undefined;
|
|
4
4
|
readonly pollMs?: number | undefined;
|
|
5
|
+
readonly absentGraceMs?: number | undefined;
|
|
5
6
|
}
|
|
6
7
|
export declare function isLockContention(error: unknown, locked: boolean): boolean;
|
|
7
8
|
export declare function holdToolchainLock<T>(dir: string, run: () => Promise<T>, options?: ToolchainLockOptions): Promise<T>;
|
|
@@ -4,6 +4,7 @@ import { now } from '@dsh-workbench/shared/host';
|
|
|
4
4
|
import lockfile from 'proper-lockfile';
|
|
5
5
|
const DEFAULT_WAIT_MS = 90_000;
|
|
6
6
|
const DEFAULT_POLL_MS = 500;
|
|
7
|
+
const DEFAULT_ABSENT_GRACE_MS = 2_000;
|
|
7
8
|
function codeOf(error) {
|
|
8
9
|
const code = typeof error === 'object' && error !== null ? error.code : undefined;
|
|
9
10
|
return typeof code === 'string' ? code : '';
|
|
@@ -17,6 +18,10 @@ export function isLockContention(error, locked) {
|
|
|
17
18
|
return true;
|
|
18
19
|
return (code === 'EPERM' || code === 'EEXIST') && locked;
|
|
19
20
|
}
|
|
21
|
+
function isTransientLockError(error) {
|
|
22
|
+
const code = codeOf(error);
|
|
23
|
+
return code === 'EPERM' || code === 'EEXIST';
|
|
24
|
+
}
|
|
20
25
|
function lockedNow(dir) {
|
|
21
26
|
try {
|
|
22
27
|
statSync(lockedPathOf(dir));
|
|
@@ -26,8 +31,9 @@ function lockedNow(dir) {
|
|
|
26
31
|
return false;
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
|
-
async function acquire(dir, stale, waitMs, pollMs) {
|
|
34
|
+
async function acquire(dir, stale, waitMs, pollMs, absentGraceMs) {
|
|
30
35
|
const deadline = now() + waitMs;
|
|
36
|
+
let absentSince;
|
|
31
37
|
for (;;) {
|
|
32
38
|
try {
|
|
33
39
|
return await lockfile.lock(dir, {
|
|
@@ -38,7 +44,18 @@ async function acquire(dir, stale, waitMs, pollMs) {
|
|
|
38
44
|
});
|
|
39
45
|
}
|
|
40
46
|
catch (error) {
|
|
41
|
-
if (
|
|
47
|
+
if (isLockContention(error, lockedNow(dir))) {
|
|
48
|
+
absentSince = undefined;
|
|
49
|
+
}
|
|
50
|
+
else if (isTransientLockError(error)) {
|
|
51
|
+
absentSince ??= now();
|
|
52
|
+
if (now() - absentSince > absentGraceMs)
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
if (now() >= deadline)
|
|
42
59
|
throw error;
|
|
43
60
|
await delay(pollMs);
|
|
44
61
|
}
|
|
@@ -46,7 +63,7 @@ async function acquire(dir, stale, waitMs, pollMs) {
|
|
|
46
63
|
}
|
|
47
64
|
export async function holdToolchainLock(dir, run, options = {}) {
|
|
48
65
|
mkdirSync(dir, { recursive: true });
|
|
49
|
-
const release = await acquire(dir, options.staleMs ?? 120_000, options.waitMs ?? DEFAULT_WAIT_MS, options.pollMs ?? DEFAULT_POLL_MS);
|
|
66
|
+
const release = await acquire(dir, options.staleMs ?? 120_000, options.waitMs ?? DEFAULT_WAIT_MS, options.pollMs ?? DEFAULT_POLL_MS, options.absentGraceMs ?? DEFAULT_ABSENT_GRACE_MS);
|
|
50
67
|
try {
|
|
51
68
|
return await run();
|
|
52
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/adapter-probe",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "Workbench adapter-probe adapter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"proper-lockfile": "^4.1.2",
|
|
17
|
-
"@dsh-workbench/adapter-profile": "1.5.
|
|
18
|
-
"@dsh-workbench/adapter-
|
|
19
|
-
"@dsh-workbench/shared": "1.5.
|
|
20
|
-
"@dsh-workbench/adapter-
|
|
17
|
+
"@dsh-workbench/adapter-profile": "1.5.6",
|
|
18
|
+
"@dsh-workbench/adapter-runtime": "1.5.6",
|
|
19
|
+
"@dsh-workbench/shared": "1.5.6",
|
|
20
|
+
"@dsh-workbench/adapter-supply": "1.5.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^24.19.0",
|