@dsh-workbench/shared 1.5.2-alpha.5 → 1.5.2-rc.1

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.
Files changed (39) hide show
  1. package/dist/contract/needs.d.ts +3 -1
  2. package/dist/contract/needs.js +4 -2
  3. package/dist/contract/protocol/bundle-install.d.ts +1 -1
  4. package/dist/contract/unit.js +2 -1
  5. package/dist/host/runtime/dsh-compat.d.ts +4 -0
  6. package/dist/host/runtime/dsh-compat.js +32 -16
  7. package/dist/host/runtime/verified-dsh.d.ts +5 -0
  8. package/dist/host/runtime/verified-dsh.js +20 -0
  9. package/dist/host/supply/builtin-catalog.d.ts +3 -0
  10. package/dist/host/supply/builtin-catalog.js +38 -0
  11. package/dist/host/supply/preflight.d.ts +14 -1
  12. package/dist/host/supply/supply-index.js +6 -0
  13. package/dist/host.d.ts +2 -0
  14. package/dist/host.js +2 -0
  15. package/dist/i18n/en.js +14 -3
  16. package/dist/i18n/index.d.ts +15 -4
  17. package/dist/i18n/zh.d.ts +14 -3
  18. package/dist/i18n/zh.js +14 -3
  19. package/dist/lib/bundle-requirements.d.ts +1 -0
  20. package/dist/lib/bundle-requirements.js +9 -0
  21. package/dist/lib/dsh-client.d.ts +1 -1
  22. package/package.json +47 -51
  23. package/src/contract/__tests__/unit.test.ts +7 -0
  24. package/src/contract/needs.ts +5 -3
  25. package/src/contract/protocol/bundle-install.ts +1 -0
  26. package/src/contract/unit.ts +2 -1
  27. package/src/host/runtime/__tests__/dsh-compat.test.ts +19 -1
  28. package/src/host/runtime/__tests__/verified-dsh.test.ts +55 -0
  29. package/src/host/runtime/dsh-compat.ts +36 -12
  30. package/src/host/runtime/verified-dsh.ts +22 -0
  31. package/src/host/supply/__tests__/builtin-catalog.test.ts +44 -0
  32. package/src/host/supply/builtin-catalog.ts +38 -0
  33. package/src/host/supply/preflight.ts +16 -1
  34. package/src/host/supply/supply-index.ts +3 -0
  35. package/src/host.ts +2 -0
  36. package/src/i18n/en.ts +17 -3
  37. package/src/i18n/zh.ts +16 -3
  38. package/src/lib/bundle-requirements.ts +11 -0
  39. package/src/lib/dsh-client.ts +1 -2
@@ -22,11 +22,13 @@ export type SupplySource = {
22
22
  readonly kind: 'local';
23
23
  readonly path?: string;
24
24
  readonly env?: string;
25
+ } | {
26
+ readonly kind: 'builtin';
25
27
  };
26
28
  /**
27
29
  * 协议认得的外部来源种类。
28
30
  */
29
- export declare const SUPPLY_SOURCE_KINDS: readonly ["npm", "git", "local"];
31
+ export declare const SUPPLY_SOURCE_KINDS: readonly ["npm", "git", "local", "builtin"];
30
32
  /**
31
33
  * 外部来源的类别。
32
34
  */
@@ -6,7 +6,7 @@ export const NEED_KINDS = ['bin', 'extension', 'lib', 'env'];
6
6
  /**
7
7
  * 协议认得的外部来源种类。
8
8
  */
9
- export const SUPPLY_SOURCE_KINDS = ['npm', 'git', 'local'];
9
+ export const SUPPLY_SOURCE_KINDS = ['npm', 'git', 'local', 'builtin'];
10
10
  /**
11
11
  * 协议认得的 need 字段;`x-` 前缀的字段留给第三方扩展,直接忽略。
12
12
  */
@@ -72,6 +72,8 @@ function sourceProblemsOf(raw, at) {
72
72
  errors.push(`${at}.url 没写`);
73
73
  return errors;
74
74
  }
75
+ if (kind === 'builtin')
76
+ return errors;
75
77
  if (text(raw['path']) === '' && text(raw['env']) === '') {
76
78
  errors.push(`${at} 是 local,但 path 与 env 都没写`);
77
79
  }
@@ -204,7 +206,7 @@ export const NEED_KIND_SPECS = Object.freeze({
204
206
  extension: Object.freeze({
205
207
  kind: 'extension',
206
208
  probe: 'extension',
207
- sources: Object.freeze(['npm', 'git', 'local']),
209
+ sources: Object.freeze(['npm', 'git', 'local', 'builtin']),
208
210
  validate: validateKind('extension'),
209
211
  }),
210
212
  lib: Object.freeze({
@@ -10,7 +10,7 @@ export interface BundleRegistries {
10
10
  readonly fallbackRegistries: readonly BundleRegistry[];
11
11
  readonly resolved: string | null;
12
12
  }
13
- export type BundleInspectProblem = 'invalid-spec' | 'already-installed' | 'not-found' | 'not-a-package' | 'not-a-bundle' | 'not-a-workbench-module' | 'not-a-module-or-plugin' | 'network' | 'unknown';
13
+ export type BundleInspectProblem = 'invalid-spec' | 'already-installed' | 'not-found' | 'not-a-package' | 'not-a-bundle' | 'not-a-workbench-module' | 'not-a-module-or-plugin' | 'module-builtin-missing' | 'network' | 'unknown';
14
14
  export type BundleSpecKind = 'registry' | 'path' | 'git' | 'tarball';
15
15
  export interface BundleInspectionAccepted {
16
16
  readonly status: 'accepted';
@@ -20,7 +20,8 @@ export function needsOf(manifest) {
20
20
  * @returns 可代装的 need 列表。
21
21
  */
22
22
  export function provisionableNeedsOf(manifest) {
23
- return needsOf(manifest).filter((need) => (need.kind === 'extension' || need.kind === 'lib') && (need.sources ?? []).length > 0);
23
+ return needsOf(manifest).filter((need) => (need.kind === 'extension' || need.kind === 'lib') &&
24
+ (need.sources ?? []).some((source) => source.kind !== 'builtin'));
24
25
  }
25
26
  /**
26
27
  * 市场门槛要看的那些需要:声明了 extension / lib 就算(不要求写了来源)。
@@ -25,3 +25,7 @@ export declare function dshCompatibilityOf(input: {
25
25
  readonly dshVersion?: string | undefined;
26
26
  }): DshCompatibility;
27
27
  export declare function dshVersionIn(profileDir: string): string | undefined;
28
+ export declare function dshVersionFrom(profileDir: string): {
29
+ readonly version: string;
30
+ readonly from: string;
31
+ } | undefined;
@@ -48,22 +48,38 @@ export function dshCompatibilityOf(input) {
48
48
  return { verdict: 'compatible' };
49
49
  }
50
50
  export function dshVersionIn(profileDir) {
51
- const fromClient = process.env['DSH_CLIENT_VERSION'];
52
- if (typeof fromClient === 'string' && semver.valid(fromClient.trim()) !== null)
53
- return fromClient.trim();
54
- for (const dir of searchDirsOf(profileDir)) {
55
- const own = readManifest(join(dir, 'node_modules', '@deepseek-ai', 'dsh', 'package.json'))?.['version'];
56
- if (typeof own === 'string' && semver.valid(own) !== null)
57
- return own;
58
- }
59
- const fromEnv = process.env['DSH_VERSION'];
60
- if (typeof fromEnv === 'string' && semver.valid(fromEnv.trim()) !== null)
61
- return fromEnv.trim();
62
- for (const dir of searchDirsOf(profileDir)) {
63
- const anchor = readManifest(join(dir, 'node_modules', '@deepseek-ai', 'dsh-app-boot', 'package.json'));
64
- const version = dependencyVersionOf(anchor, '@deepseek-ai/dsh');
65
- if (version !== undefined)
66
- return version;
51
+ return dshVersionFrom(profileDir)?.version;
52
+ }
53
+ export function dshVersionFrom(profileDir) {
54
+ const fromClient = envVersionOf('DSH_CLIENT_VERSION');
55
+ if (fromClient !== undefined)
56
+ return { version: fromClient, from: 'DSH_CLIENT_VERSION' };
57
+ const dirs = searchDirsOf(profileDir);
58
+ const installed = firstOver(dirs, (dir) => {
59
+ const file = join(dir, 'node_modules', '@deepseek-ai', 'dsh', 'package.json');
60
+ const own = readManifest(file)?.['version'];
61
+ return typeof own === 'string' && semver.valid(own) !== null ? { version: own, from: file } : undefined;
62
+ });
63
+ if (installed !== undefined)
64
+ return installed;
65
+ const fromEnv = envVersionOf('DSH_VERSION');
66
+ if (fromEnv !== undefined)
67
+ return { version: fromEnv, from: 'DSH_VERSION' };
68
+ return firstOver(dirs, (dir) => {
69
+ const file = join(dir, 'node_modules', '@deepseek-ai', 'dsh-app-boot', 'package.json');
70
+ const version = dependencyVersionOf(readManifest(file), '@deepseek-ai/dsh');
71
+ return version === undefined ? undefined : { version, from: `${file} → @deepseek-ai/dsh` };
72
+ });
73
+ }
74
+ function envVersionOf(name) {
75
+ const raw = process.env[name];
76
+ return typeof raw === 'string' && semver.valid(raw.trim()) !== null ? raw.trim() : undefined;
77
+ }
78
+ function firstOver(dirs, read) {
79
+ for (const dir of dirs) {
80
+ const got = read(dir);
81
+ if (got !== undefined)
82
+ return got;
67
83
  }
68
84
  return undefined;
69
85
  }
@@ -0,0 +1,5 @@
1
+ import type { PreflightHostGap } from '../supply/preflight.js';
2
+ export declare const VERIFIED_DSH = "0.2.2-rc.2";
3
+ export type DshTier = 'ok' | 'newer' | 'older' | 'unknown';
4
+ export declare function dshTierOf(runtime: string | undefined, verified?: string): DshTier;
5
+ export declare function dshHostGapOf(runtime: string | undefined, verified?: string): PreflightHostGap | undefined;
@@ -0,0 +1,20 @@
1
+ import semver from 'semver';
2
+ export const VERIFIED_DSH = '0.2.2-rc.2';
3
+ export function dshTierOf(runtime, verified = VERIFIED_DSH) {
4
+ const got = runtime?.trim() ?? '';
5
+ if (semver.valid(got) === null || semver.valid(verified) === null)
6
+ return 'unknown';
7
+ if (semver.lt(got, verified))
8
+ return 'older';
9
+ const have = semver.parse(got);
10
+ const want = semver.parse(verified);
11
+ if (have === null || want === null)
12
+ return 'unknown';
13
+ return have.major === want.major && have.minor === want.minor ? 'ok' : 'newer';
14
+ }
15
+ export function dshHostGapOf(runtime, verified = VERIFIED_DSH) {
16
+ const tier = dshTierOf(runtime, verified);
17
+ if (tier !== 'newer' && tier !== 'older')
18
+ return undefined;
19
+ return { tier, runtime: (runtime ?? '').trim(), verified };
20
+ }
@@ -0,0 +1,3 @@
1
+ import type { Need } from '../../contract/needs.js';
2
+ export declare function builtinCommandsOf(file: string): ReadonlyMap<string, readonly string[]>;
3
+ export declare function builtinMissingOf(needs: readonly Need[] | undefined, catalog: ReadonlyMap<string, readonly string[]>): readonly string[];
@@ -0,0 +1,38 @@
1
+ import { readJsonObject } from '../runtime/read-json.js';
2
+ export function builtinCommandsOf(file) {
3
+ const parsed = readJsonObject(file);
4
+ if (!Array.isArray(parsed))
5
+ return new Map();
6
+ const bySite = new Map();
7
+ for (const one of parsed) {
8
+ if (typeof one !== 'object' || one === null)
9
+ continue;
10
+ const row = one;
11
+ const site = typeof row['site'] === 'string' ? row['site'] : '';
12
+ const name = typeof row['name'] === 'string' ? row['name'] : '';
13
+ if (site === '' || name === '')
14
+ continue;
15
+ const list = bySite.get(site) ?? [];
16
+ list.push(name);
17
+ for (const alias of Array.isArray(row['aliases']) ? row['aliases'] : []) {
18
+ if (typeof alias === 'string' && alias !== '')
19
+ list.push(alias);
20
+ }
21
+ bySite.set(site, list);
22
+ }
23
+ return bySite;
24
+ }
25
+ export function builtinMissingOf(needs, catalog) {
26
+ return (needs ?? [])
27
+ .filter((need) => need.kind === 'extension' || need.kind === 'lib')
28
+ .filter((need) => (need.sources ?? []).some((source) => source.kind === 'builtin'))
29
+ .filter((need) => {
30
+ const commands = catalog.get(need.name);
31
+ if (commands === undefined)
32
+ return true;
33
+ if (need.kind !== 'extension')
34
+ return false;
35
+ return (need.commands ?? []).some((name) => !commands.includes(name));
36
+ })
37
+ .map((need) => need.name);
38
+ }
@@ -1,4 +1,4 @@
1
- export type PreflightStepId = 'toolchain' | 'cli' | 'bridge' | 'runtime' | 'diy' | 'warm';
1
+ export type PreflightStepId = 'toolchain' | 'cli' | 'bridge' | 'runtime' | 'host' | 'diy' | 'warm';
2
2
  export type PreflightStepStatus = 'pending' | 'running' | 'ok' | 'warn' | 'failed';
3
3
  export type PreflightFailure = 'permission' | 'network' | 'missing' | 'host' | 'unknown';
4
4
  export type PreflightGuidance = 'install' | 'path' | 'shell' | 'host';
@@ -17,6 +17,18 @@ export interface PreflightDiyGap {
17
17
  readonly detail: string;
18
18
  readonly command: string;
19
19
  }
20
+ export type PreflightHostTier = 'newer' | 'older';
21
+ export type PreflightHostStanding = {
22
+ readonly tier: 'ok';
23
+ readonly log?: readonly string[];
24
+ } | PreflightHostGap;
25
+ export interface PreflightHostGap {
26
+ readonly tier: PreflightHostTier;
27
+ readonly runtime: string;
28
+ readonly verified: string;
29
+ readonly command?: string;
30
+ readonly log?: readonly string[];
31
+ }
20
32
  export interface PreflightSnapshot {
21
33
  readonly phase: 'idle' | 'checking' | 'installing' | 'ready' | 'failed';
22
34
  readonly steps: readonly PreflightStep[];
@@ -25,6 +37,7 @@ export interface PreflightSnapshot {
25
37
  readonly failure?: PreflightFailure;
26
38
  readonly guidance?: PreflightGuidance;
27
39
  readonly bridgeIssues?: readonly PreflightBridgeIssue[];
40
+ readonly hostGap?: PreflightHostGap;
28
41
  readonly diyGap?: PreflightDiyGap;
29
42
  readonly canWakeBrowser?: boolean;
30
43
  readonly extensionDir?: string;
@@ -13,6 +13,8 @@ function nativeSourcePackage(source) {
13
13
  return text(source.package);
14
14
  if (source.kind === 'git')
15
15
  return `git:${text(source.url)}`;
16
+ if (source.kind === 'builtin')
17
+ return 'builtin';
16
18
  return `local:${text(source.env) || text(source.path)}`;
17
19
  }
18
20
  function packageOf(need, prefix) {
@@ -52,6 +54,8 @@ function sourceCompatible(left, right, env) {
52
54
  if (left.kind === 'local' && right.kind === 'local') {
53
55
  return text(left.env) === text(right.env) && text(left.path) === text(right.path);
54
56
  }
57
+ if (left.kind === 'builtin' && right.kind === 'builtin')
58
+ return true;
55
59
  return false;
56
60
  }
57
61
  function sourcesCompatible(left, right, env) {
@@ -96,6 +100,8 @@ function sourceText(source) {
96
100
  }
97
101
  if (source.kind === 'git')
98
102
  return `git:${source.url}`;
103
+ if (source.kind === 'builtin')
104
+ return '运行时自带';
99
105
  return `local:${source.env ?? source.path ?? ''}`;
100
106
  }
101
107
  function addDeclarer(entry, unit, commands) {
package/dist/host.d.ts CHANGED
@@ -112,6 +112,7 @@ export * from './host/runtime/process-alive.js';
112
112
  export * from './host/runtime/read-json.js';
113
113
  export * from './host/runtime/time.js';
114
114
  export * from './host/runtime/version-range.js';
115
+ export * from './host/runtime/verified-dsh.js';
115
116
  export * from './host/runtime/version.js';
116
117
  export * from './host/runtime/workspace-store.js';
117
118
  export * from './host/runtime/write-result.js';
@@ -136,6 +137,7 @@ export * from './host/supply/installed-sources.js';
136
137
  export * from './host/supply/lib-capabilities.js';
137
138
  export * from './host/supply/lib-install.js';
138
139
  export * from './host/supply/lib-runners.js';
140
+ export * from './host/supply/builtin-catalog.js';
139
141
  export * from './host/supply/market-index-claim.js';
140
142
  export * from './host/supply/market-index-doc.js';
141
143
  export * from './host/supply/market-index-parse.js';
package/dist/host.js CHANGED
@@ -112,6 +112,7 @@ export * from './host/runtime/process-alive.js';
112
112
  export * from './host/runtime/read-json.js';
113
113
  export * from './host/runtime/time.js';
114
114
  export * from './host/runtime/version-range.js';
115
+ export * from './host/runtime/verified-dsh.js';
115
116
  export * from './host/runtime/version.js';
116
117
  export * from './host/runtime/workspace-store.js';
117
118
  export * from './host/runtime/write-result.js';
@@ -136,6 +137,7 @@ export * from './host/supply/installed-sources.js';
136
137
  export * from './host/supply/lib-capabilities.js';
137
138
  export * from './host/supply/lib-install.js';
138
139
  export * from './host/supply/lib-runners.js';
140
+ export * from './host/supply/builtin-catalog.js';
139
141
  export * from './host/supply/market-index-claim.js';
140
142
  export * from './host/supply/market-index-doc.js';
141
143
  export * from './host/supply/market-index-parse.js';
package/dist/i18n/en.js CHANGED
@@ -195,7 +195,7 @@ export const en = {
195
195
  'panels.market.selfUpdateMigration': 'This update needs Desktop to be closed once: quit Desktop and it finishes automatically, with no further action.',
196
196
  'panels.market.selfUpdatePendingRestart': 'The new version is ready — restart to pick it up.',
197
197
  'panels.market.selfUpdateRetry': 'Update failed. Click Update to try again.',
198
- 'panels.market.selfUpdateNeedsDsh': 'Update failed: this version needs {dsh}. Upgrade dsh first.',
198
+ 'panels.market.selfUpdateNeedsHost': 'Update failed: this version needs {host} {version} or newer; you have {runtime}.',
199
199
  'panels.market.selfUpdateBusy': 'The previous update has not finished. Wait for it to end, then update again.',
200
200
  'panels.market.selfUpdateReinstallFailed': 'Reinstalling dependencies failed. Restart the workbench and try again; if it still fails, install manually with the command shown in the terminal.',
201
201
  'panels.market.selfUpdateReinstallStopped': 'Automatic dependency installation kept failing. Install manually with the command shown in the terminal.',
@@ -261,6 +261,7 @@ export const en = {
261
261
  'panels.market.needLib': 'Install the library {name} first.',
262
262
  'panels.market.localMark': 'local',
263
263
  'panels.market.noSource': 'This module does not declare an install method; handle it manually.',
264
+ 'panels.market.needBuiltinMissing': 'This module declares a broken dependency: the module author needs to fix it (or wait for a module update).',
264
265
  'panels.market.badSource': 'The install method is incomplete; handle it manually.',
265
266
  'panels.market.empty': 'No modules available to install yet. Add a module source or refresh and try again.',
266
267
  'panels.market.updateAllPlugins': 'Update all',
@@ -320,7 +321,9 @@ export const en = {
320
321
  'panels.market.configDriftedNote': 'The workbench config records {declared}, but {installed} is installed. Click Update to reinstall the recorded version.',
321
322
  'panels.market.olderOnDiskNote': 'Installed {installed} while {running} is running. Update before restarting; a restart now runs {installed}.',
322
323
  'panels.market.updateNeedsWorkbench': 'This version needs a newer workbench first.',
323
- 'panels.market.updateNeedsDsh': 'This version needs {dsh}; the running dsh is {runtime}.',
324
+ 'panels.market.needsHostVersion': 'This version needs {host} {version} or newer; you have {runtime}.',
325
+ 'panels.market.needsHostAction.desktop': 'Update DeepSeek Harness, then try again.',
326
+ 'panels.market.needsHostAction.dsh': 'Upgrade dsh, restart it, then try again.',
324
327
  'panels.market.updateIncompatible': 'The new version does not match this workbench, so it cannot be updated now.',
325
328
  'panels.market.updateUnverified': 'Compatibility is unverified; the update may fail.',
326
329
  'panels.market.moduleRefused': 'This module does not match this workbench, so it cannot be used for now.',
@@ -435,7 +438,6 @@ export const en = {
435
438
  'panels.market.add.failureModuleRow': 'The module is installed in this workbench, but the module list in its configuration was not updated, so it will not load. Fix that list, then restart the workbench.',
436
439
  'panels.market.add.failureModuleRowRemove': 'The module was removed from this workbench, but the module list in its configuration was not updated. Fix that list, then restart the workbench.',
437
440
  'panels.market.add.failureNoProfileDir': 'The directory for this workbench configuration cannot be found, so the module cannot be installed. Check the configuration directory in workbench settings, or install the workbench again.',
438
- 'panels.market.add.failureIncompatible': 'This version needs {dsh}; the running dsh is {runtime}. Upgrade dsh first.',
439
441
  'panels.market.add.failureCredentials': 'This repository needs credentials, and this machine has none for it. Run a clone once in a terminal and set up a credential helper, or switch to the SSH address and try again.',
440
442
  'panels.market.approve.title': 'Install scripts need approval',
441
443
  'panels.market.approve.caution': 'Approve only packages you trust. Install scripts run on this machine with your permissions.',
@@ -644,6 +646,7 @@ export const en = {
644
646
  'panels.market.add.removed': 'Removed.',
645
647
  'panels.market.add.supplyPending': 'The plugins this module needs will be installed after a restart.',
646
648
  'panels.market.add.supplyFailed': 'The plugins this module needs are not installed: {reason}',
649
+ 'panels.market.add.problemBuiltinMissing': 'This module declares a broken dependency: the module author needs to fix it (or wait for a module update).',
647
650
  'panels.market.add.notModule': "This is not a workbench module (no dsh.workbench declaration), so it will not show up on the board.",
648
651
  'panels.market.add.removedRestart': 'Uninstalled; restart to finish.',
649
652
  'panels.market.add.remove': 'Remove it',
@@ -749,6 +752,14 @@ export const en = {
749
752
  'env.diy.noRow': 'The startup check did not find “Workbench DIY mode” in dsh’s mode list. This workbench install most likely does not include the matching mode patch.',
750
753
  'env.diy.step': 'Upgrade dsh, then restart the workbench:',
751
754
  'env.diy.continue': 'Enter the workbench anyway',
755
+ 'env.step.hostVersion': 'Check {host} version',
756
+ 'env.hostVersion.newer': 'Unverified',
757
+ 'env.hostVersion.older': 'Too old',
758
+ 'env.hostVersion.newer.why': 'This machine has {host} {runtime}. The workbench is verified on {verified}. You can continue. Upgrade the workbench if a module or panel does not work as expected.',
759
+ 'env.hostVersion.older.why': 'The workbench needs {host} {verified} or later. This machine has {runtime}. Upgrade {host}, then restart.',
760
+ 'env.hostVersion.older.step': 'Upgrade {host}, then restart:',
761
+ 'env.hostVersion.recover': 'If the workbench keeps failing to open, remove it from this workbench configuration, then restart {host}.',
762
+ 'env.hostVersion.recover.detail': 'Remove @dsh-workbench/core from dsh.profile.bundles in package.json.',
752
763
  'env.copyCommand': 'Copy command',
753
764
  'env.copied': 'Copied',
754
765
  'env.step.toolchain': 'Check the environment',