@iasiv5/dsh-skip-browser-auth 0.3.8 → 0.3.9

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.md CHANGED
@@ -38,7 +38,7 @@ sudo systemctl restart deepseek-harness.service # 按你的部署方式重启
38
38
  - DSH 0.1.5-rc.1 / 0.1.5-rc.2:carrier-neutral-v2
39
39
  - DSH 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2:carrier-neutral-v3
40
40
  其它版本或 runtime/connection 混合版本会自动休眠,不要强行处理。
41
- desktop 宿主一律自动休眠(宿主进程判别,0.3.8 起生效),这是设计行为,不要强行处理或改代码绕过;desktop 用户请直接使用 0.3.8+(0.3.6/0.3.7 在 desktop 有已知缺陷)。
41
+ desktop 宿主一律自动休眠(多进程树判别:安装槽位/启动器 argv/宿主二进制,0.3.9 起生效),这是设计行为,不要强行处理或改代码绕过;desktop 用户请直接使用 0.3.9+(0.3.6-0.3.8 在 desktop 有已知缺陷,见 docs/COMPATIBILITY.md §7.4)。
42
42
 
43
43
  1. 先执行 dsh --version 告诉我当前 DSH 版本,然后照常安装:
44
44
  dsh plugin --profile web add @iasiv5/dsh-skip-browser-auth
package/cordis.patch.yml CHANGED
@@ -14,11 +14,11 @@
14
14
  - id: connection
15
15
  name: '@deepseek-ai/dsh-client-connection'
16
16
  disabled: !!js >-
17
- (() => { try { const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); const execPath = hostProcess !== null && typeof hostProcess ===
18
- 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule =
19
- processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return
20
- null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles = [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); return profile !== null &&
21
- ["legacy-web-v1","carrier-neutral-v2","carrier-neutral-v3"].includes(profile); } catch (gateError) { return false; } })()
17
+ (() => { try { const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); let slot = ''; try { const decodedBase = decodeURIComponent(typeof
18
+ ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; const slotIndex = trimmedBase.lastIndexOf('/'); slot = trimmedBase.slice(slotIndex + 1).toLowerCase(); } catch (slotError) { slot = ''; } const desktopBySlot = slot === "desktop"; const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || desktopBySlot || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented =
19
+ decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) {
20
+ const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
21
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); return profile !== null && ["legacy-web-v1","carrier-neutral-v2","carrier-neutral-v3"].includes(profile); } catch (gateError) { return false; } })()
22
22
  - insert:
23
23
  - id: trusted-connection
24
24
  name: '@iasiv5/dsh-skip-browser-auth'
@@ -27,14 +27,15 @@
27
27
  config:
28
28
  trustedHosts: !!js ctx.webRuntime.trustedHosts
29
29
  compatibilityProfile: !!js >-
30
- (() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof
31
- hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if
32
- (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null)
33
- return null; versions.push(anchorVersion); } const profiles = [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()
30
+ (() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); let slot = ''; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ?
31
+ ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; const slotIndex = trimmedBase.lastIndexOf('/'); slot = trimmedBase.slice(slotIndex + 1).toLowerCase(); } catch (slotError) { slot = ''; } const desktopBySlot = slot === "desktop"; const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || desktopBySlot || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new
32
+ RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const
33
+ specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
34
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()
34
35
  disabled: !!js >-
35
36
  !((() => { try { const self = ctx[Symbol.for('cordis.entry')]; if (!self || !self.parent || !self.parent.tree) return false; const official = self.parent.tree.resolve('connection'); if (!official || official.parent !== self.parent) return false; if (official.options.id !== 'connection' || official.options.name !== '@deepseek-ai/dsh-client-connection') return false; const probeAllowed = ((() => { try { const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const
36
- desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const
37
- segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource]
38
- of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
37
+ desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); let slot = ''; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; const slotIndex = trimmedBase.lastIndexOf('/'); slot = trimmedBase.slice(slotIndex + 1).toLowerCase(); } catch (slotError) { slot = ''; } const desktopBySlot = slot === "desktop"; const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\')) + 1).toLowerCase(); const
38
+ webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || desktopBySlot || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest =
39
+ JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
39
40
  [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); return profile !== null && ["legacy-web-v1","carrier-neutral-v2","carrier-neutral-v3"].includes(profile); } catch (gateError) { return false; } })()); if (probeAllowed !== true) return false;
40
41
  return official.disabled === true; } catch (gateError) { return false; } })())
package/lib/gate.js CHANGED
@@ -45,6 +45,10 @@
45
45
  * (Electron under ELECTRON_RUN_AS_NODE),与 DSH 官方 dsh-plugin-manager
46
46
  * 的 isPackagedDesktopArgv 同款判别:launcher 事实独立于 profile 布局,
47
47
  * 不可被依赖抬升污染;
48
+ * ②′ desktop 槽位判别:ctx.baseUrl 目录基名 === 'desktop'——desktop 客户端
49
+ * 恒以 profiles/desktop 槽位启动 loader(官方 desktopProfileDirFromArgv 按
50
+ * profiles 树定位),构造性事实、与进程树形状无关。0.3.8 的事态(宿主以
51
+ * 纯 node 子进程跑 loader,argv/execPath 双双落空)由本信号兜底;
48
52
  * ③ web 正向证明:宿主二进制 process.execPath 基名(大小写归一)∈
49
53
  * {node, node.exe, nodejs, nodejs.exe}——Windows/macOS/Linux 的 web 全形态
50
54
  * (systemd/docker/nvm/fnm/volta/mise/直接 node)经解释器 exec 后 execPath
@@ -73,6 +77,8 @@ export const GATE_ANCHOR_PACKAGES = [GATE_RUNTIME_PACKAGE, CONNECTION_PACKAGE];
73
77
  export const DESKTOP_HOST_PACKAGE = '@deepseek-ai/dsh-desktop-host';
74
78
  /** desktop 宿主 argv 判别子串:desktop 宿主入口脚本为 `dsh-desktop-host/lib/index.js`(官方 isPackagedDesktopArgv 同款)。 */
75
79
  export const DESKTOP_HOST_ARGV_MARKER = 'dsh-desktop-host';
80
+ /** desktop 安装槽位名:desktop 客户端恒以 profiles/desktop 槽位启动 loader(官方 desktopProfileDirFromArgv 契约)。 */
81
+ export const DESKTOP_HOST_SLOT_NAME = 'desktop';
76
82
  /**
77
83
  * 从已解析 URL 提取 pnpm store 版本段的正则源(`+name@VER_` / `+name@VER/`)。
78
84
  * 探针表达式内嵌的正则由此单一实现生成;仅匹配 pnpm 布局,非 pnpm 布局
@@ -88,7 +94,7 @@ const GATE_ANCHOR_TABLE = GATE_ANCHOR_PACKAGES.map((pkg) => [pkg, versionSegment
88
94
  // 逐锚点解析 `锚点包/package.json`,返回完整 runtime/connection pair 对应的
89
95
  // profile id;candidate profile 也可被识别,是否允许激活由下方 boolean probe
90
96
  // 根据 profile status 决定。解析失败、未知 pair 或混合 pair 一律返回 null。
91
- export const GATE_PROFILE_EXPRESSION = `(() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = ${JSON.stringify(DESKTOP_HOST_PACKAGE)} + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf(${JSON.stringify(DESKTOP_HOST_ARGV_MARKER)}) !== -1); const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = ${JSON.stringify(GATE_ANCHOR_TABLE)}; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles = ${JSON.stringify(GATE_PROFILE_TABLE)}; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()`;
97
+ export const GATE_PROFILE_EXPRESSION = `(() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = ${JSON.stringify(DESKTOP_HOST_PACKAGE)} + '/package.json'; let hostProfile; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; const desktopByPackage = typeof desktopUrl === 'string'; const hostProcess = typeof process !== 'undefined' ? process : null; const desktopByArgv = hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv) && hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf(${JSON.stringify(DESKTOP_HOST_ARGV_MARKER)}) !== -1); let slot = ''; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; const slotIndex = trimmedBase.lastIndexOf('/'); slot = trimmedBase.slice(slotIndex + 1).toLowerCase(); } catch (slotError) { slot = ''; } const desktopBySlot = slot === ${JSON.stringify(DESKTOP_HOST_SLOT_NAME)}; const execPath = hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string' ? hostProcess.execPath : ''; const execBase = execPath.slice(Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\\\')) + 1).toLowerCase(); const webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; hostProfile = desktopByPackage || desktopByArgv || desktopBySlot || !webByBinary ? 'desktop' : 'web'; } catch (hostError) { hostProfile = 'web'; } const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = ${JSON.stringify(GATE_ANCHOR_TABLE)}; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles = ${JSON.stringify(GATE_PROFILE_TABLE)}; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) && profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()`;
92
98
  // Boolean activation probe: only active profiles disable the official row.
93
99
  // A known candidate profile remains dormant until its host/client adapter is
94
100
  // promoted, while the profile expression still exposes its exact pair id.
@@ -127,6 +133,17 @@ export function detectHostProfile(internal, baseUrl) {
127
133
  catch {
128
134
  // 信号包不可达/解析异常 ⇒ 落到宿主进程 argv 判别
129
135
  }
136
+ let slot = '';
137
+ try {
138
+ const trimmedBase = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
139
+ const slotIndex = Math.max(trimmedBase.lastIndexOf('/'), trimmedBase.lastIndexOf('\\'));
140
+ slot = trimmedBase.slice(slotIndex + 1).toLowerCase();
141
+ }
142
+ catch {
143
+ slot = '';
144
+ }
145
+ if (slot === 'desktop')
146
+ return 'desktop';
130
147
  const hostProcess = globalThis.process;
131
148
  if (hostProcess !== undefined && hostProcess !== null && Array.isArray(hostProcess.argv)) {
132
149
  const desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' && arg.includes(DESKTOP_HOST_ARGV_MARKER));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iasiv5/dsh-skip-browser-auth",
3
- "version": "0.3.8",
4
- "description": "替换官方 Connection 提供方跳过 BrowserAuth,免输 Token;已适配 0.1.2-rc.1、0.1.5-rc.1/rc.2、0.1.7-rc.1/rc.2 与 0.2.0-rc.1/rc.2,详见仓库。仅支持 web(宿主二进制须为 node);desktop 宿主一律自动休眠(宿主进程判别),属设计行为。",
3
+ "version": "0.3.9",
4
+ "description": "替换官方 Connection 提供方跳过 BrowserAuth,免输 Token;已适配 0.1.2-rc.1、0.1.5-rc.1/rc.2、0.1.7-rc.1/rc.2 与 0.2.0-rc.1/rc.2,详见仓库。仅支持 web(宿主二进制须为 node);desktop 宿主一律自动休眠(多进程树判别:安装槽位/启动器 argv/宿主二进制),属设计行为。",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "deepseek-harness",