@deepseek-ai/dsh-plugin-manager 0.2.1-rc.3 → 0.2.2-alpha.2

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,20 +1,20 @@
1
1
  /**
2
- * Record the build scripts a failed run reported as ignored, then list every name awaiting a decision.
2
+ * Record the build scripts a failed run reported as blocked, then list every `allowBuilds` key awaiting a decision.
3
3
  *
4
4
  * pnpm writes those policy entries itself only when it can prompt, and the
5
5
  * manager always runs it non-interactively, so the run's own report is the
6
6
  * record that survives.
7
7
  * @param dir Current profile directory.
8
8
  * @param output Captured output of the failed run.
9
- * @returns Exact package names awaiting a build decision; wildcard rules are excluded.
9
+ * @returns Exact `allowBuilds` keys awaiting a build decision; wildcard rules are excluded.
10
10
  */
11
11
  export declare function recordPendingBuilds(dir: string, output: string): Promise<string[]>;
12
12
  /**
13
- * Read the package names a pnpm run reported as ignored build scripts.
13
+ * Read the `allowBuilds` keys a pnpm run reported as ignored build scripts or as a git-hosted package it refused to prepare.
14
14
  * @param output Captured output of the run.
15
- * @returns Exact names in report order; wildcard patterns are excluded.
15
+ * @returns Exact keys in report order; wildcard patterns and git keys carrying a credential are excluded.
16
16
  */
17
- export declare function ignoredBuildNames(output: string): string[];
17
+ export declare function blockedBuildNames(output: string): string[];
18
18
  /** Persist approval without running scripts; the caller holds the profile manifest lock.
19
19
  * @param dir Current profile directory.
20
20
  * @param names Explicit package names from the pending build list.
@@ -8,6 +8,19 @@ import { writeFileAtomic } from '@deepseek-ai/dsh-atomic-write';
8
8
  const UNDECIDED_BUILD = 'set this to true or false';
9
9
  /** Where a non-interactive run names the build scripts it skipped. */
10
10
  const IGNORED_BUILDS = /\bIgnored build scripts: (.+)/;
11
+ /** The `allowBuilds` key pnpm suggests when it refuses to prepare a git-hosted package; a subdirectory key can contain spaces. */
12
+ const GIT_DEP_PREPARE = /ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED[\s\S]*?^allowBuilds:\r?\n[ \t]+(.+?): true$/m;
13
+ /**
14
+ * Whether an `allowBuilds` key names a git URL that carries a credential: a password, or any user name over HTTP(S).
15
+ * Such a key is not recorded, so the credential stays out of the profile settings and the pending list.
16
+ */
17
+ function carriesCredential(key) {
18
+ const at = key.indexOf('@git+');
19
+ if (at === -1)
20
+ return false;
21
+ const url = URL.parse(key.slice(at + '@git+'.length).replace(/#.*$/s, ''));
22
+ return url !== null && (url.password !== '' || (url.username !== '' && /^https?:$/.test(url.protocol)));
23
+ }
11
24
  async function readPolicy(dir) {
12
25
  let text;
13
26
  try {
@@ -37,19 +50,19 @@ async function readPolicy(dir) {
37
50
  return { document, pending, keys };
38
51
  }
39
52
  /**
40
- * Record the build scripts a failed run reported as ignored, then list every name awaiting a decision.
53
+ * Record the build scripts a failed run reported as blocked, then list every `allowBuilds` key awaiting a decision.
41
54
  *
42
55
  * pnpm writes those policy entries itself only when it can prompt, and the
43
56
  * manager always runs it non-interactively, so the run's own report is the
44
57
  * record that survives.
45
58
  * @param dir Current profile directory.
46
59
  * @param output Captured output of the failed run.
47
- * @returns Exact package names awaiting a build decision; wildcard rules are excluded.
60
+ * @returns Exact `allowBuilds` keys awaiting a build decision; wildcard rules are excluded.
48
61
  */
49
62
  export async function recordPendingBuilds(dir, output) {
50
63
  const { document, pending, keys } = await readPolicy(dir);
51
64
  const known = new Set(keys);
52
- const added = ignoredBuildNames(output).filter(name => !known.has(name));
65
+ const added = blockedBuildNames(output).filter(name => !known.has(name));
53
66
  if (added.length === 0)
54
67
  return pending;
55
68
  for (const name of added)
@@ -58,15 +71,15 @@ export async function recordPendingBuilds(dir, output) {
58
71
  return [...pending, ...added];
59
72
  }
60
73
  /**
61
- * Read the package names a pnpm run reported as ignored build scripts.
74
+ * Read the `allowBuilds` keys a pnpm run reported as ignored build scripts or as a git-hosted package it refused to prepare.
62
75
  * @param output Captured output of the run.
63
- * @returns Exact names in report order; wildcard patterns are excluded.
76
+ * @returns Exact keys in report order; wildcard patterns and git keys carrying a credential are excluded.
64
77
  */
65
- export function ignoredBuildNames(output) {
66
- const reported = IGNORED_BUILDS.exec(output)?.[1];
67
- if (reported === undefined)
68
- return [];
69
- return reported.split(',').map(name => name.trim()).filter(name => name !== '' && !/[*?]/.test(name));
78
+ export function blockedBuildNames(output) {
79
+ const ignored = IGNORED_BUILDS.exec(output)?.[1]?.split(',') ?? [];
80
+ const git = GIT_DEP_PREPARE.exec(output)?.[1];
81
+ return [...ignored, ...git === undefined ? [] : [git]]
82
+ .map(name => name.trim()).filter(name => name !== '' && !/[*?]/.test(name) && !carriesCredential(name));
70
83
  }
71
84
  /** Persist approval without running scripts; the caller holds the profile manifest lock.
72
85
  * @param dir Current profile directory.
@@ -0,0 +1,40 @@
1
+ import type { ProfileContext } from '@deepseek-ai/dsh-app-boot';
2
+ import { type NpmFileSource } from '@deepseek-ai/dsh-plugin-detail';
3
+ import type { BundleDetail, BundleInfo } from './types.ts';
4
+ /** Limits and sources of bundle detail reads. */
5
+ export interface BundleDetailOptions {
6
+ readonly profile: ProfileContext;
7
+ readonly maxDocumentBytes: number;
8
+ readonly maxImageBytes: number;
9
+ readonly npmFileSources: readonly NpmFileSource[];
10
+ /** Deadline of one CDN request. */
11
+ readonly timeoutMs: number;
12
+ /** The plugin manager's disposal. */
13
+ readonly lifetime: AbortSignal;
14
+ }
15
+ /**
16
+ * Read a bundle's detail document in a display language.
17
+ * @param bundle - the bundle as `listBundles()` reports it.
18
+ * @param language - a BCP 47 language id.
19
+ * @param preferred - npm file CDNs to ask first for an offered version; see `npmFileSourceOrder`.
20
+ * @param options - profile, sources, and limits.
21
+ * @returns the document, or `none` when the bundle has neither a `meta.detail` file nor a README.
22
+ * @throws {RemoteError} `plugin-manager/invalid-language`, `plugin-manager/unknown-bundle`, or
23
+ * `plugin-manager/detail-unavailable`.
24
+ */
25
+ export declare function readBundleDocument(bundle: BundleInfo, language: string, preferred: readonly string[], options: BundleDetailOptions): Promise<BundleDetail>;
26
+ /**
27
+ * Read an image beside a bundle's detail document.
28
+ * @param bundle - the bundle as `listBundles()` reports it.
29
+ * @param document - the document's path inside the bundle, as {@link readBundleDocument} returned it.
30
+ * @param destination - the image destination as the document writes it.
31
+ * @param preferred - npm file CDNs to ask first for an offered version; see `npmFileSourceOrder`.
32
+ * @param options - profile, sources, and limits.
33
+ * @returns the bytes and media type, or undefined for a path outside the bundle, an unsupported type, or a missing file.
34
+ * @throws {RemoteError} `plugin-manager/unknown-bundle` or `plugin-manager/detail-unavailable`.
35
+ */
36
+ export declare function readBundleImage(bundle: BundleInfo, document: string, destination: string, preferred: readonly string[], options: BundleDetailOptions): Promise<{
37
+ bytes: Uint8Array;
38
+ mediaType: string;
39
+ } | undefined>;
40
+ //# sourceMappingURL=bundle-detail.d.ts.map
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Detail documents of profile bundles: an installed bundle's `meta.detail` file or README from its directory, and an
3
+ * official bundle the installation offers, before it is installed, from the npm file CDNs at its offered version. Reads
4
+ * keep no state; an image request resolves its bundle and document again.
5
+ */
6
+ import semver from 'semver';
7
+ import { resolveBundleDir } from '@deepseek-ai/dsh-app-boot';
8
+ import { DetailFailure, detailImage, languageChain, localFiles, npmFileSourceOrder, npmFiles, readPackageDocument, } from '@deepseek-ai/dsh-plugin-detail';
9
+ import { RemoteError } from '@deepseek-ai/dsh-typert-protocol';
10
+ /**
11
+ * The files of a listed bundle: its directory when its files can be read, otherwise its offered npm version.
12
+ * @param bundle - the bundle as `listBundles()` reports it.
13
+ * @param preferred - npm file CDNs to ask first for an offered version; see `npmFileSourceOrder`.
14
+ * @param options - profile, sources, and limits.
15
+ * @returns the files, or undefined for a bundle offered at no published version.
16
+ * @throws {RemoteError} `plugin-manager/unknown-bundle` when the bundle's directory cannot be resolved.
17
+ */
18
+ function filesOf(bundle, preferred, options) {
19
+ if (bundle.availability !== 'missing') {
20
+ let dir;
21
+ try {
22
+ dir = resolveBundleDir('dsh', bundle.name, options.profile.installAnchor, options.profile.dir);
23
+ }
24
+ catch (error) {
25
+ throw new RemoteError('plugin-manager/unknown-bundle', error.message, { name: bundle.name }, { cause: error });
26
+ }
27
+ // `listBundles()` reports the version of every bundle whose manifest it read; one without is read as unversioned.
28
+ return localFiles(dir, String(bundle.version));
29
+ }
30
+ const version = bundle.installTarget?.version;
31
+ if (version === undefined || semver.valid(version) !== version)
32
+ return undefined;
33
+ const sources = npmFileSourceOrder(options.npmFileSources, preferred);
34
+ return npmFiles(bundle.name, version, sources, { timeoutMs: options.timeoutMs, lifetime: options.lifetime });
35
+ }
36
+ /** Rethrow a detail failure as the Remote error clients read. */
37
+ function remoteFailure(error) {
38
+ if (error instanceof DetailFailure) {
39
+ throw new RemoteError('plugin-manager/detail-unavailable', error.message, { reason: error.reason }, { cause: error });
40
+ }
41
+ throw error;
42
+ }
43
+ /**
44
+ * Read a bundle's detail document in a display language.
45
+ * @param bundle - the bundle as `listBundles()` reports it.
46
+ * @param language - a BCP 47 language id.
47
+ * @param preferred - npm file CDNs to ask first for an offered version; see `npmFileSourceOrder`.
48
+ * @param options - profile, sources, and limits.
49
+ * @returns the document, or `none` when the bundle has neither a `meta.detail` file nor a README.
50
+ * @throws {RemoteError} `plugin-manager/invalid-language`, `plugin-manager/unknown-bundle`, or
51
+ * `plugin-manager/detail-unavailable`.
52
+ */
53
+ export async function readBundleDocument(bundle, language, preferred, options) {
54
+ let languages;
55
+ try {
56
+ languages = languageChain(language);
57
+ }
58
+ catch (error) {
59
+ throw new RemoteError('plugin-manager/invalid-language', error.message, { language }, { cause: error });
60
+ }
61
+ const files = filesOf(bundle, preferred, options);
62
+ if (files === undefined)
63
+ return { status: 'none' };
64
+ const document = await readPackageDocument(files, '', languages, options.maxDocumentBytes, options.lifetime).catch(remoteFailure);
65
+ return document === undefined ? { status: 'none' } : { status: 'found', ...document };
66
+ }
67
+ /**
68
+ * Read an image beside a bundle's detail document.
69
+ * @param bundle - the bundle as `listBundles()` reports it.
70
+ * @param document - the document's path inside the bundle, as {@link readBundleDocument} returned it.
71
+ * @param destination - the image destination as the document writes it.
72
+ * @param preferred - npm file CDNs to ask first for an offered version; see `npmFileSourceOrder`.
73
+ * @param options - profile, sources, and limits.
74
+ * @returns the bytes and media type, or undefined for a path outside the bundle, an unsupported type, or a missing file.
75
+ * @throws {RemoteError} `plugin-manager/unknown-bundle` or `plugin-manager/detail-unavailable`.
76
+ */
77
+ export async function readBundleImage(bundle, document, destination, preferred, options) {
78
+ const image = detailImage(document, destination);
79
+ const files = image === undefined ? undefined : filesOf(bundle, preferred, options);
80
+ if (image === undefined || files === undefined)
81
+ return undefined;
82
+ const bytes = await files.read(image.path, options.maxImageBytes, options.lifetime).catch(remoteFailure);
83
+ return bytes === undefined ? undefined : { bytes, mediaType: image.mediaType };
84
+ }
85
+ //# sourceMappingURL=bundle-detail.js.map
@@ -0,0 +1,17 @@
1
+ import type { Branded } from '@deepseek-ai/dsh-brand';
2
+ import type { PluginOperation } from './types.ts';
3
+ /** Identifies the process lifetime which observed management operations. */
4
+ export type PluginOperationRunId = Branded<'PluginOperationRunId'>;
5
+ /** One diagnostic event; omissions and unknown outcomes must not be interpreted as successful operations. */
6
+ export interface PluginOperationRecord {
7
+ readonly runId: PluginOperationRunId;
8
+ readonly operation: PluginOperation;
9
+ readonly transportDropped: number;
10
+ }
11
+ /**
12
+ * Validate transport/file data and discard fields outside the diagnostic whitelist.
13
+ * @param value - Untrusted decoded JSON.
14
+ * @returns A bounded record, or undefined for malformed, oversized or unsupported records.
15
+ */
16
+ export declare function parsePluginOperationRecord(value: unknown): PluginOperationRecord | undefined;
17
+ //# sourceMappingURL=diagnostic.d.ts.map
@@ -0,0 +1,72 @@
1
+ /** Whitelisted operation records shared by diagnostic transport and durable readers. */
2
+ import { z } from 'zod';
3
+ const fields = {
4
+ id: z.uuid().transform(value => value),
5
+ time: z.iso.datetime(),
6
+ reason: z.enum({
7
+ 'plugin': 'plugin',
8
+ 'bundle': 'bundle',
9
+ 'install': 'install',
10
+ 'remove': 'remove',
11
+ }),
12
+ target: z.string().max(256).nullable(),
13
+ stage: z.enum({
14
+ 'install': 'install',
15
+ 'enable': 'enable',
16
+ 'remove': 'remove',
17
+ }),
18
+ enabled: z.boolean().optional(),
19
+ version: z.string().max(128).optional(),
20
+ };
21
+ const operation = z.discriminatedUnion('phase', [
22
+ z.object({ ...fields, phase: z.literal('started') }),
23
+ z.object({ ...fields, phase: z.literal('unknown') }),
24
+ z.object({ ...fields, phase: z.literal('settled'),
25
+ application: z.enum({
26
+ 'applied': 'applied',
27
+ 'restart-required': 'restart-required',
28
+ 'overridden': 'overridden',
29
+ 'failed': 'failed',
30
+ 'cancelled': 'cancelled',
31
+ }),
32
+ changed: z.boolean(),
33
+ errorCode: z.enum({
34
+ 'management-required': 'management-required',
35
+ 'unaddressable': 'unaddressable',
36
+ 'unknown-plugin': 'unknown-plugin',
37
+ 'invalid-spec': 'invalid-spec',
38
+ 'already-installed': 'already-installed',
39
+ 'ambiguous-install': 'ambiguous-install',
40
+ 'not-bundle': 'not-bundle',
41
+ 'not-removable': 'not-removable',
42
+ 'stop-profile': 'stop-profile',
43
+ 'bundle-in-use': 'bundle-in-use',
44
+ 'stale-approval': 'stale-approval',
45
+ 'incompatible-version': 'incompatible-version',
46
+ 'unsupported-platform': 'unsupported-platform',
47
+ 'operation-error': 'operation-error',
48
+ }).optional(),
49
+ restartReason: z.enum({
50
+ 'no-hmr': 'no-hmr',
51
+ 'package-moved': 'package-moved',
52
+ 'host-module': 'host-module',
53
+ 'unmanaged-plugin': 'unmanaged-plugin',
54
+ 'module-comparison': 'module-comparison',
55
+ }).optional(),
56
+ }),
57
+ ]);
58
+ const record = z.object({
59
+ runId: z.uuid().transform(value => value),
60
+ operation,
61
+ transportDropped: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
62
+ });
63
+ /**
64
+ * Validate transport/file data and discard fields outside the diagnostic whitelist.
65
+ * @param value - Untrusted decoded JSON.
66
+ * @returns A bounded record, or undefined for malformed, oversized or unsupported records.
67
+ */
68
+ export function parsePluginOperationRecord(value) {
69
+ const parsed = record.safeParse(value);
70
+ return parsed.success ? parsed.data : undefined;
71
+ }
72
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1,27 @@
1
+ import type { ParsedInstallSpec } from './install-spec.ts';
2
+ /** Deadline and cancellation for each read-only access probe. */
3
+ export interface GitTransportOptions {
4
+ timeoutMs: number;
5
+ signal: AbortSignal;
6
+ /** The application-owned package manager's environment, also used by its Git children. */
7
+ env?: Readonly<Record<string, string>>;
8
+ }
9
+ /**
10
+ * The SSH form of an HTTP(S) Git spec on a host pnpm has no transport fallback for. pnpm tries HTTPS and SSH itself
11
+ * for the hosts `hosted-git-info` knows, such as GitHub and GitLab.com, and clones any other URL over the transport
12
+ * it names.
13
+ * @param spec The parsed installation address.
14
+ * @returns `git+ssh://git@<host>/<path>` on SSH's default port with the spec's fragment, or `undefined` for a spec that
15
+ * is not an HTTP(S) Git URL on such a host, or whose URL carries credentials or a query.
16
+ */
17
+ export declare function sshGitSpec(spec: ParsedInstallSpec): string | undefined;
18
+ /**
19
+ * Choose how pnpm clones an HTTP(S) Git repository that {@link sshGitSpec} has an SSH form for: probe the spec's URL,
20
+ * and when HTTP(S) cannot read it, probe the SSH form.
21
+ * @param spec The parsed installation address.
22
+ * @param dir The profile directory where installation runs.
23
+ * @param options The deadline of each probe, cancellation and the installer's environment.
24
+ * @returns The SSH form when only SSH can read the repository; otherwise the spec unchanged.
25
+ */
26
+ export declare function chooseGitTransport(spec: ParsedInstallSpec, dir: string, options: GitTransportOptions): Promise<string>;
27
+ //# sourceMappingURL=git-transport.d.ts.map
@@ -0,0 +1,65 @@
1
+ /** The Git transport an installation of a self-hosted repository uses, chosen by probing access before pnpm starts. */
2
+ import { execa } from 'execa';
3
+ import hostedGitInfo from 'hosted-git-info';
4
+ import { scrubbedParentEnv } from '@deepseek-ai/dsh-subprocess';
5
+ /** An HTTP(S) Git URL with an optional `git+` prefix, which pnpm clones over that transport as written. */
6
+ const HTTP_GIT_URL = /^(?:git\+)?https?:\/\//i;
7
+ /**
8
+ * The SSH form of an HTTP(S) Git spec on a host pnpm has no transport fallback for. pnpm tries HTTPS and SSH itself
9
+ * for the hosts `hosted-git-info` knows, such as GitHub and GitLab.com, and clones any other URL over the transport
10
+ * it names.
11
+ * @param spec The parsed installation address.
12
+ * @returns `git+ssh://git@<host>/<path>` on SSH's default port with the spec's fragment, or `undefined` for a spec that
13
+ * is not an HTTP(S) Git URL on such a host, or whose URL carries credentials or a query.
14
+ */
15
+ export function sshGitSpec(spec) {
16
+ if (spec.kind !== 'git' || !HTTP_GIT_URL.test(spec.spec) || hostedGitInfo.fromUrl(spec.spec) !== undefined)
17
+ return undefined;
18
+ const url = new URL(spec.spec.replace(/^git\+/i, ''));
19
+ if (url.username !== '' || url.password !== '' || url.search !== '')
20
+ return undefined;
21
+ // The fragment is copied as written: WHATWG serialization would percent-encode some of its characters.
22
+ const hash = /#.*$/s.exec(spec.spec)?.[0] ?? '';
23
+ return `git+ssh://git@${url.hostname}${url.pathname}${hash}`;
24
+ }
25
+ /**
26
+ * Probe whether Git can read a repository with the installer's Git configuration and credential helpers. Git's
27
+ * terminal and askpass prompts are disabled, `core.askPass` included because Windows drops the empty `GIT_ASKPASS`,
28
+ * and on POSIX the probe has no controlling terminal, so SSH cannot ask about host keys or passphrases either.
29
+ * @param repository The repository URL Git reads.
30
+ * @param dir The profile directory where installation runs.
31
+ * @param options The probe deadline, cancellation and environment.
32
+ * @returns Whether `git ls-remote` listed the repository's HEAD.
33
+ */
34
+ async function readable(repository, dir, options) {
35
+ const result = await execa('git', ['-c', 'core.askPass=', 'ls-remote', '--exit-code', '--', repository, 'HEAD'], {
36
+ cwd: dir,
37
+ env: {
38
+ ...scrubbedParentEnv(), ...options.env, LC_ALL: 'C', GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'never',
39
+ GIT_ASKPASS: '', SSH_ASKPASS: '', SSH_ASKPASS_REQUIRE: 'never',
40
+ },
41
+ extendEnv: false, stdin: 'ignore', stdout: 'ignore', stderr: 'ignore', reject: false,
42
+ timeout: options.timeoutMs, cancelSignal: options.signal, killDescendants: true, killSignal: 'SIGKILL',
43
+ });
44
+ return !result.failed;
45
+ }
46
+ /**
47
+ * Choose how pnpm clones an HTTP(S) Git repository that {@link sshGitSpec} has an SSH form for: probe the spec's URL,
48
+ * and when HTTP(S) cannot read it, probe the SSH form.
49
+ * @param spec The parsed installation address.
50
+ * @param dir The profile directory where installation runs.
51
+ * @param options The deadline of each probe, cancellation and the installer's environment.
52
+ * @returns The SSH form when only SSH can read the repository; otherwise the spec unchanged.
53
+ */
54
+ export async function chooseGitTransport(spec, dir, options) {
55
+ const ssh = sshGitSpec(spec);
56
+ if (ssh === undefined)
57
+ return spec.spec;
58
+ const strip = (value) => value.replace(/^git\+/i, '').replace(/#.*$/s, '');
59
+ if (await readable(strip(spec.spec), dir, options))
60
+ return spec.spec;
61
+ if (options.signal.aborted || !await readable(strip(ssh), dir, options))
62
+ return spec.spec;
63
+ return ssh;
64
+ }
65
+ //# sourceMappingURL=git-transport.js.map
@@ -1,7 +1,8 @@
1
1
  import { Context } from '@deepseek-ai/cordis';
2
2
  import z from '@deepseek-ai/schemastery';
3
3
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
4
- import type { BundleInfo, ChangeResult, InspectOptions, InstallBundleOptions, PluginEntryId, PluginInfo, PluginInstallCancellation, PluginInstallRequestId, PluginRegistries, PluginSpecInspection } from './types.ts';
4
+ import type { NpmFileSource } from '@deepseek-ai/dsh-plugin-detail/types';
5
+ import type { BundleDetail, BundleInfo, ChangeResult, InspectOptions, InstallBundleOptions, ListVersionsOptions, PluginEntryId, PluginInfo, PluginInstallCancellation, PluginInstallRequestId, PluginRegistries, PluginSpecInspection, PluginUpdateResult, PluginVersionList, UpdateBundleOptions } from './types.ts';
5
6
  export type * from './types.ts';
6
7
  export { classifyInstallFailure, type InstallFailureFacts } from './install-failure.ts';
7
8
  export { InvalidInstallSpecError, parseInstallSpec, type ParsedInstallSpec } from './install-spec.ts';
@@ -17,6 +18,8 @@ export interface Config {
17
18
  inspectTimeoutMs?: number;
18
19
  /** Maximum duration of the GitHub repository connection check before installation, in milliseconds. */
19
20
  githubConnectionTimeoutMs?: number;
21
+ /** Maximum duration of each HTTP(S) and SSH access probe of a self-hosted Git repository before installation, in milliseconds. */
22
+ gitTransportTimeoutMs?: number;
20
23
  /** Maximum time one captured package run may print nothing before the manager terminates it, in milliseconds. */
21
24
  idleTimeoutMs?: number;
22
25
  /** The registry lookups and installations ask first, as an http(s) URL; absent, the one pnpm's own configuration names. */
@@ -27,6 +30,18 @@ export interface Config {
27
30
  * unless that is npm's own registry or one of these.
28
31
  */
29
32
  fallbackRegistries?: string[];
33
+ /** How many of the newest versions above the installed one a version listing reads and returns. */
34
+ versionListLimit?: number;
35
+ /** How many single-version registry lookups a version listing runs at once. */
36
+ versionLookupConcurrency?: number;
37
+ /** Largest bundle detail document, and largest locale file read for one, in bytes. */
38
+ detailMaxBytes?: number;
39
+ /** Largest image served beside a bundle detail document, in bytes. */
40
+ detailImageMaxBytes?: number;
41
+ /** Deadline of one npm file CDN request for an offered bundle's detail document. */
42
+ detailFetchTimeoutMs?: number;
43
+ /** npm file CDNs that offered bundles are read from, in order; a read's `npmFileSources` moves the CDNs it names first. */
44
+ detailNpmFileSources?: NpmFileSource[];
30
45
  }
31
46
  declare module '@deepseek-ai/cordis' {
32
47
  interface Context {
@@ -52,14 +67,39 @@ export declare class PluginManager extends TypertRemoteService {
52
67
  private readonly lockWaitMs;
53
68
  private readonly inspectTimeoutMs;
54
69
  private readonly githubConnectionTimeoutMs;
70
+ private readonly gitTransportTimeoutMs;
55
71
  private readonly idleTimeoutMs;
56
72
  private readonly pnpmCommand;
73
+ private readonly versionListLimit;
74
+ private readonly versionLookupConcurrency;
57
75
  private readonly configuredRegistries;
58
76
  private readonly ownerContext;
59
77
  private readonly abort;
60
78
  /** Installations by request id, from their call until it settles. */
61
79
  private readonly installs;
80
+ private readonly detail;
62
81
  constructor(ctx: Context, config: Config);
82
+ /**
83
+ * Read a bundle's long description: the Markdown file its locale `meta.detail` names in `language`, otherwise its
84
+ * README. An installed bundle is read from its directory without network access; an official bundle the installation
85
+ * offers before it is installed is read from the npm file CDNs at its offered version. Nothing is cached.
86
+ * @param name - the bundle's package name, as `listBundles()` lists it.
87
+ * @param language - the display language, such as `zh-CN`; documents fall back through its prefixes to English.
88
+ * @param options - `npmFileSources` names npm file CDNs to ask first for an offered bundle, in order, such as the one
89
+ * a Client measured as fastest; configured CDNs it omits follow, and CDNs that are not configured are not asked.
90
+ * @returns the document with its origin and path, or `none`.
91
+ * @throws {RemoteError} `plugin-manager/unknown-bundle`, `plugin-manager/invalid-language`, or
92
+ * `plugin-manager/detail-unavailable`.
93
+ */
94
+ readBundleDetail(name: string, language: string, options?: {
95
+ npmFileSources?: NpmFileSource[];
96
+ }): Promise<BundleDetail>;
97
+ private listedBundle;
98
+ /**
99
+ * Answer `GET ${DETAIL_FILE_PATH}?bundle=<name>&document=<path>&path=<destination>[&sources=<cdn>,...]` with one image
100
+ * beside a bundle document; `sources` names npm file CDNs to ask first for an offered bundle, as `readBundleDetail` does.
101
+ */
102
+ private serveDetailFile;
63
103
  /** Read exact plugin-version exemptions saved in this profile.
64
104
  * @returns Accepted package-name@version keys with the runtime versions they may run on, and any
65
105
  * record or file problem the reader rejected, which the caller reports instead of failing.
@@ -86,6 +126,8 @@ export declare class PluginManager extends TypertRemoteService {
86
126
  * display metadata, activation selections, whether the installation offers the bundle, and removal availability.
87
127
  */
88
128
  listBundles(): Promise<BundleInfo[]>;
129
+ /** The bundle inventory before update eligibility, which is derived from each listed bundle. */
130
+ private readBundles;
89
131
  /** Read the registries this manager asks: the configured first one, its fallbacks in order, and what pnpm's own configuration names.
90
132
  * @returns The registries in pnpm's comparison form; null is the one pnpm's own configuration names, `resolved` as pnpm reads it now.
91
133
  */
@@ -97,6 +139,46 @@ export declare class PluginManager extends TypertRemoteService {
97
139
  * @returns The package the spec names, or why it is refused.
98
140
  */
99
141
  inspect(spec: string, options?: InspectOptions, signal?: AbortSignal): Promise<PluginSpecInspection>;
142
+ /** Read the published versions newer than an installed registry package's version, from the first registry that answers.
143
+ * Official bundles follow the DSH version and are not listed.
144
+ * @param name Installed profile dependency name.
145
+ * @param options The registry asked first; absent, the one the package was installed from in this process, else the configured one.
146
+ * @param signal Ends the lookups early.
147
+ * @returns At most `versionListLimit` newer versions, newest first, with their tags, deprecation, bundle declaration,
148
+ * and DSH compatibility, and the registry that answered; or why no list could be read, with every registry asked.
149
+ */
150
+ listVersions(name: string, options?: ListVersionsOptions, signal?: AbortSignal): Promise<PluginVersionList>;
151
+ /**
152
+ * Replace an installed registry bundle with a newer published version. The target is checked on the registry first:
153
+ * it must exist, declare a bundle, and accept the running DSH version, or nothing changes. With HMR the installed
154
+ * version is removed, so its plugins stop, and the target is installed with the same selection; when that
155
+ * installation fails or is cancelled, the removed version is installed again from the registry it came from.
156
+ * Without HMR the target is installed over the running version and the result reports the restart.
157
+ * @param name Installed profile dependency name.
158
+ * @param version Exact published version newer than the installed one.
159
+ * @param options The registry asked first, as for `listVersions`, and the request id naming the progress and the
160
+ * target installation's logs and cancellation.
161
+ * @returns The versions, the last step that ran with its result, and the reinstallation when one ran.
162
+ */
163
+ updateBundle(name: string, version: string, options?: UpdateBundleOptions): Promise<PluginUpdateResult>;
164
+ /**
165
+ * The registry a version listing or an update asks first.
166
+ * @param name The package name.
167
+ * @param requested The caller's registry, when it named one.
168
+ * @returns The requested registry, else the one this process last installed the package from, else undefined for the configured one.
169
+ */
170
+ private registryFor;
171
+ /**
172
+ * Ask registries in turn through `pnpm view`, moving to the next one while a failure is the registry's: unreachable,
173
+ * timed out, or without the package or version, which a mirror not yet synced reports.
174
+ * @param spec The registry spec viewed.
175
+ * @param fields The manifest fields printed.
176
+ * @param plan The registries, in order; never empty.
177
+ * @param parsed The spec's form, which decides whether a failure was the registry's.
178
+ * @param signal Ends the lookup; a dropped lookup is not carried to the next registry.
179
+ * @returns The parsed answer and the registry that gave it, or the last refusal, with every registry asked.
180
+ */
181
+ private askRegistries;
100
182
  /** Persist a plugin entry's desired enablement and apply it on live profiles.
101
183
  * @param id Loader entry identity returned by listPlugins.
102
184
  * @param enabled Whether the plugin should run.
@@ -112,7 +194,9 @@ export declare class PluginManager extends TypertRemoteService {
112
194
  /**
113
195
  * Install a package using the same pnpm implementation as dsh plugin. GitHub
114
196
  * repositories get a connection check bounded by githubConnectionTimeoutMs before pnpm starts;
115
- * only network failures or timeouts stop installation, while pnpm owns authentication and transport fallback. A run
197
+ * only network failures or timeouts stop installation, while pnpm owns authentication and transport fallback. An
198
+ * HTTP(S) Git URL on another host is installed over SSH instead when access probes bounded by gitTransportTimeoutMs
199
+ * find that only SSH can read it. A run
116
200
  * that fails, is cancelled, or adds a package without a bundle patch restores
117
201
  * `package.json` and `pnpm-lock.yaml` as they were; downloaded files can stay.
118
202
  * @param spec One package spec, including local paths relative to the invocation directory.
@@ -169,6 +253,10 @@ export declare class PluginManager extends TypertRemoteService {
169
253
  */
170
254
  private reload;
171
255
  private change;
256
+ private reportOperation;
257
+ private operationTarget;
258
+ /** Read the request-time package version without preventing recovery from damaged metadata. */
259
+ private operationVersion;
172
260
  private diskState;
173
261
  }
174
262
  export default PluginManager;