dsh-builtin-browser 1.0.4 → 1.1.0

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.
@@ -47,6 +47,14 @@ export interface DesktopLayout {
47
47
  interface IdentityRule {
48
48
  readonly packageNames: readonly string[]
49
49
  readonly mainEntry: string
50
+ /** Further accepted entries; each states the dependency that must be present to qualify. */
51
+ readonly mainEntryCandidates?: readonly {
52
+ readonly entry: string
53
+ readonly packageName?: string
54
+ /** Dependency that must appear in the app's own manifest for this entry to be accepted. */
55
+ readonly requiresDependency?: string
56
+ readonly note?: string
57
+ }[]
50
58
  /** Main entries of look-alike Desktops that are recognized only to be refused, with the reason. */
51
59
  readonly unsupportedMainEntries?: Readonly<Record<string, string>>
52
60
  readonly layouts: readonly DesktopLayout[]
@@ -61,8 +69,16 @@ interface IdentityRule {
61
69
  export const FALLBACK_RULE: IdentityRule = {
62
70
  packageNames: ['@deepseek-ai/dsh-desktop', 'dsh-desktop'],
63
71
  mainEntry: 'lib/main.js',
72
+ mainEntryCandidates: [
73
+ {
74
+ entry: 'out/main/index.js',
75
+ packageName: 'dsh-desktop',
76
+ requiresDependency: '@deepseek-ai/dsh',
77
+ note: 'electron-vite layout. The official DSH Desktop 0.14.0 ships this entry with `main: ./out/main/index.js` and no `lib` directory at all (issue #112), while the third-party electron-vite shell (dataelement/dsh-desktop, issue #62) shares the same shape. The `@deepseek-ai/dsh` dependency is what separates them: the official bundle carries it, the third-party shell does not.',
78
+ },
79
+ ],
64
80
  unsupportedMainEntries: {
65
- 'out/main/index.js': 'the electron-vite layout of a third-party DSH Desktop (dataelement/dsh-desktop, issue #62), which shares the package name but not the DeepSeek Harness Desktop shell the bridge patches',
81
+ 'out/main/index.js': 'an electron-vite DSH Desktop without the @deepseek-ai/dsh dependency — the third-party shell from issue #62, which shares the package name but not the DeepSeek Harness Desktop bundle the bridge patches',
66
82
  },
67
83
  layouts: [
68
84
  { name: 'macos-bundle', marker: 'Contents/Info.plist', resources: 'Contents/Resources', executable: 'Contents/MacOS/DeepSeek Harness', cliLauncher: 'runtime/cli/bin/dsh' },
@@ -73,6 +89,8 @@ export const FALLBACK_RULE: IdentityRule = {
73
89
  /** A verified install. */
74
90
  export interface DesktopIdentity {
75
91
  readonly ok: true
92
+ /** The entry this install actually uses: `mainEntry`, or an accepted candidate. */
93
+ readonly mainEntry: string
76
94
  /** The install root that was verified. */
77
95
  readonly root: string
78
96
  /** Which shape was verified — the archive when it exists, the extraction only without one. */
@@ -129,14 +147,24 @@ export function readIdentityRule(): IdentityRule | { readonly error: string } {
129
147
  || layouts[layouts.length - 1]?.marker !== undefined) {
130
148
  return { error: 'desktop-identity.json: layouts must be a non-empty array whose last entry has no marker' }
131
149
  }
150
+ const candidates = raw.mainEntryCandidates
151
+ if (candidates !== undefined && (!Array.isArray(candidates) || candidates.some(c => c === null || typeof c !== 'object'
152
+ || !field(c.entry) || (c.requiresDependency !== undefined && !field(c.requiresDependency))))) {
153
+ return { error: 'desktop-identity.json: mainEntryCandidates must list entries with an optional requiresDependency' }
154
+ }
132
155
  const unsupported = raw.unsupportedMainEntries
133
156
  if (unsupported !== undefined && (unsupported === null || typeof unsupported !== 'object' || Array.isArray(unsupported)
134
157
  || Object.entries(unsupported).some(([entry, reason]) => entry === '' || !field(reason)))) {
135
158
  return { error: 'desktop-identity.json: unsupportedMainEntries must map entry paths to reasons' }
136
159
  }
160
+ // The candidates are part of the rule; dropping them here is what made a valid candidate entry
161
+ // indistinguishable from an unsupported one.
162
+ const base = candidates === undefined
163
+ ? { packageNames: names, mainEntry: main }
164
+ : { packageNames: names, mainEntry: main, mainEntryCandidates: candidates }
137
165
  return unsupported === undefined
138
- ? { packageNames: names, mainEntry: main, layouts }
139
- : { packageNames: names, mainEntry: main, unsupportedMainEntries: unsupported, layouts }
166
+ ? { ...base, layouts }
167
+ : { ...base, unsupportedMainEntries: unsupported, layouts }
140
168
  } catch (error) {
141
169
  if (error instanceof Error && 'code' in error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
142
170
  return FALLBACK_RULE
@@ -286,7 +314,6 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
286
314
 
287
315
  const layout: 'packed' | 'unpacked' = archivePresent ? 'packed' : 'unpacked'
288
316
  let manifestText: string | undefined
289
- let mainPresent: boolean
290
317
  let hasEntry: (entry: string) => boolean
291
318
  if (archivePresent) {
292
319
  const parsed = readAsarHeader(archive)
@@ -302,7 +329,6 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
302
329
  return { ok: false, reason: `${archive}: package.json is listed but its bytes cannot be read` }
303
330
  }
304
331
  hasEntry = entry => entryAt(parsed.header.files, entry) !== undefined
305
- mainPresent = hasEntry(rule.mainEntry)
306
332
  } else {
307
333
  const manifestPath = join(appDir, 'package.json')
308
334
  try {
@@ -315,7 +341,6 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
315
341
  return { ok: false, reason: `${manifestPath} is missing; a directory without a package manifest is not a DSH Desktop install` }
316
342
  }
317
343
  hasEntry = entry => existsSync(join(appDir, ...entry.split('/')))
318
- mainPresent = hasEntry(rule.mainEntry)
319
344
  }
320
345
 
321
346
  let manifest: { name?: unknown; version?: unknown }
@@ -333,13 +358,34 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
333
358
  }
334
359
  }
335
360
 
336
- // The main entry is the file the installer patches and the shell runs; if it is not there, this
337
- // is not an install this plugin can reason about even though the manifest looks right.
361
+ // The main entry is the file the installer patches and the shell runs. The default name comes
362
+ // first; the candidates cover layouts that later official builds adopted (0.14.0 ships
363
+ // "out/main/index.js" and no "lib" at all), and each candidate is gated on a dependency that the
364
+ // official bundle carries and the look-alike third-party shell does not.
365
+ let mainEntry: string = rule.mainEntry
366
+ let mainPresent = hasEntry(mainEntry)
367
+ if (!mainPresent) {
368
+ const dependencies = (manifest as { dependencies?: Record<string, unknown> }).dependencies
369
+ for (const candidate of rule.mainEntryCandidates ?? []) {
370
+ if (!hasEntry(candidate.entry)) continue
371
+ if (candidate.requiresDependency !== undefined && dependencies?.[candidate.requiresDependency] === undefined) continue
372
+ mainEntry = candidate.entry
373
+ mainPresent = true
374
+ break
375
+ }
376
+ }
338
377
  if (!mainPresent) {
339
378
  const foreign = Object.entries(rule.unsupportedMainEntries ?? {}).find(([entry]) => hasEntry(entry))
340
379
  if (foreign !== undefined) {
341
380
  return { ok: false, shell: 'third-party-shell', ...versionOf(manifest), reason: `${foreign[0]} instead of ${rule.mainEntry}: ${foreign[1]}; use DSH Web or DeepSeek Harness Desktop` }
342
381
  }
382
+ // A candidate entry is present but its gate was not satisfied: the package name was borrowed by a
383
+ // look-alike shell. Naming that is more useful than reporting the missing default entry.
384
+ const lookAlike = (rule.mainEntryCandidates ?? []).find(candidate => hasEntry(candidate.entry))
385
+ if (lookAlike !== undefined) {
386
+ const gate = lookAlike.requiresDependency === undefined ? 'its identity gate' : `${lookAlike.requiresDependency}`
387
+ return { ok: false, shell: 'third-party-shell', ...versionOf(manifest), reason: `${lookAlike.entry} instead of ${rule.mainEntry}, but ${gate} is absent, so this is not the DSH Desktop bundle (issue #62); use DSH Web or DeepSeek Harness Desktop` }
388
+ }
343
389
  return { ok: false, shell: 'official-unsupported', ...versionOf(manifest), reason: `${rule.mainEntry} is not present under ${archivePresent ? archive : appDir}` }
344
390
  }
345
391
 
@@ -347,6 +393,7 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
347
393
  ok: true,
348
394
  root: installRoot,
349
395
  layout,
396
+ mainEntry,
350
397
  packageName: name,
351
398
  ...typeof manifest.version === 'string' ? { version: manifest.version } : {},
352
399
  }
@@ -1,36 +1,36 @@
1
- /** Static Browser tab type and guide declaration. */
2
- import type { ShortcutCommandId } from '@deepseek-ai/dsh-client-shortcuts/client'
3
- import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client'
4
- import { GuideArtworkBrowser } from '@deepseek-ai/dsh-client-ui-primitives'
5
- import type { SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
6
- import type { SIDEBAR_BROWSER_LOCALE_NS } from './locales.ts'
7
-
8
- /** Browser tab kind. */
9
- export const BROWSER_KIND = 'browser'
10
-
11
- /**
12
- * Plugin-owned Browser implementation identity and keyed Slot dispatch key.
13
- * Distinct from DSH's built-in `@deepseek-ai/dsh-client-ui-sidebar-browser` so both
14
- * can coexist when a user profile re-enables the built-in row (issue #107).
15
- */
16
- export const BROWSER_ID = 'dsh-builtin-browser'
17
-
18
- /** Build the Browser type with locale-live copy. */
19
- export function browserDefinition(t: TranslateNS<typeof SIDEBAR_BROWSER_LOCALE_NS>): SidebarRightTabDefinition {
20
- return {
21
- id: BROWSER_ID,
22
- kind: BROWSER_KIND,
23
- // 每次显式打开都新建一个标签:侧栏"浏览器"按钮/向导入口在已有页面时应当开新标签,而不是
24
- // 把用户跳回旧页面(用户实测报的就是这个)。页内导航(地址栏、搜索结果、当前标签内跳转)
25
- // 走 `loadUrl` 原地替换,不会额外开标签。
26
- multiple: true,
27
- // Extension band natively takes over DSH's `builtin` `browser` kind without throwing,
28
- // and cleanly yields back to the built-in implementation if this plugin is removed.
29
- priority: 'extension',
30
- title: () => t('type.label'),
31
- guide: [{
32
- id: 'new', commandId: 'browser.new' as ShortcutCommandId, order: 30, title: () => t('guide.title'),
33
- description: () => t('guide.description'), icon: GuideArtworkBrowser,
34
- }],
35
- }
36
- }
1
+ /** Static Browser tab type and guide declaration. */
2
+ import type { ShortcutCommandId } from '@deepseek-ai/dsh-client-shortcuts/client'
3
+ import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client'
4
+ import { GuideArtworkBrowser } from '@deepseek-ai/dsh-client-ui-primitives'
5
+ import type { SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
6
+ import type { SIDEBAR_BROWSER_LOCALE_NS } from './locales.ts'
7
+
8
+ /** Browser tab kind. */
9
+ export const BROWSER_KIND = 'browser'
10
+
11
+ /**
12
+ * Plugin-owned Browser implementation identity and keyed Slot dispatch key.
13
+ * Distinct from DSH's built-in `@deepseek-ai/dsh-client-ui-sidebar-browser` so both
14
+ * can coexist when a user profile re-enables the built-in row (issue #107).
15
+ */
16
+ export const BROWSER_ID = 'dsh-builtin-browser'
17
+
18
+ /** Build the Browser type with locale-live copy. */
19
+ export function browserDefinition(t: TranslateNS<typeof SIDEBAR_BROWSER_LOCALE_NS>): SidebarRightTabDefinition {
20
+ return {
21
+ id: BROWSER_ID,
22
+ kind: BROWSER_KIND,
23
+ // 每次显式打开都新建一个标签:侧栏"浏览器"按钮/向导入口在已有页面时应当开新标签,而不是
24
+ // 把用户跳回旧页面(用户实测报的就是这个)。页内导航(地址栏、搜索结果、当前标签内跳转)
25
+ // 走 `loadUrl` 原地替换,不会额外开标签。
26
+ multiple: true,
27
+ // Extension band natively takes over DSH's `builtin` `browser` kind without throwing,
28
+ // and cleanly yields back to the built-in implementation if this plugin is removed.
29
+ priority: 'extension',
30
+ title: () => t('type.label'),
31
+ guide: [{
32
+ id: 'new', commandId: 'browser.new' as ShortcutCommandId, order: 30, title: () => t('guide.title'),
33
+ description: () => t('guide.description'), icon: GuideArtworkBrowser,
34
+ }],
35
+ }
36
+ }