@linxin666/dsh-client-ui-plugin-manager 0.4.12 → 0.4.13

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/lib/index.js CHANGED
@@ -1279,6 +1279,39 @@ function unsafeSpecReason(spec) {
1279
1279
  return UNSAFE_SPEC_CHARS.test(spec) ? "plugin-manager: spec 含有危险的 shell 元字符或控制字符,已拒绝" : void 0;
1280
1280
  }
1281
1281
  /**
1282
+ * The pnpm diagnostic for a dependency whose build script it skipped, as it
1283
+ * appears in the CLI's captured output:
1284
+ *
1285
+ * [ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: cpu-features@0.0.10
1286
+ *
1287
+ * The code is bracketed and the package list is comma separated, so the bracket
1288
+ * is part of the match, and it stops at the end of that line, so the \r a
1289
+ * Windows console writes before the newline neither hides nor extends it.
1290
+ */
1291
+ const IGNORED_BUILDS_PATTERN = /\[ERR_PNPM_IGNORED_BUILDS\][ \t]*Ignored build scripts:[^\n\r]*/;
1292
+ /**
1293
+ * Whether one CLI run's captured output carries the skipped-build-script
1294
+ * condition.
1295
+ *
1296
+ * `dsh plugin` forwards to pnpm, so a non-zero exit is pnpm's own verdict —
1297
+ * except this one, which pnpm prints *after* it has written the profile: a
1298
+ * dependency that declares a build script is not built until it is approved, and
1299
+ * the unapproved one fails the command while the package is already on disk and
1300
+ * the profile already carries it. Measured 2026-10-31 against the CLI's bundled
1301
+ * pnpm 11.9.0 and against pnpm 11.24.0: `dsh plugin --profile web add
1302
+ * cpu-features` exits 1 with its dependency landed, and the family aggregate
1303
+ * exits the same way naming cloudflared, cpu-features and ssh2.
1304
+ *
1305
+ * The condition is necessary and not sufficient: only the profile can say
1306
+ * whether the change the caller asked for really landed. The job runner reads it
1307
+ * and keeps the exit a failure when it did not.
1308
+ * @param output - the captured stdout and stderr of one CLI run.
1309
+ * @returns true when pnpm named the build scripts it skipped.
1310
+ */
1311
+ function reportsIgnoredBuilds(output) {
1312
+ return IGNORED_BUILDS_PATTERN.test(output);
1313
+ }
1314
+ /**
1282
1315
  * The Electron resource roots a packaged Desktop install may carry, as
1283
1316
  * absolute directories. Two independent launcher facts name them, and either
1284
1317
  * alone is enough:
@@ -1917,7 +1950,9 @@ var CliGateway = class {
1917
1950
  return;
1918
1951
  }
1919
1952
  const targetIsLocal = /^(?:link:|file:)/.test(targetSpec);
1920
- if (targetPreviouslyInstalled ? !targetIsLocal : !after.dependencies.includes(targetId)) {
1953
+ const shouldAddTarget = targetPreviouslyInstalled ? !targetIsLocal : !after.dependencies.includes(targetId);
1954
+ let tolerated;
1955
+ if (shouldAddTarget) {
1921
1956
  const add = await this.runCli(binary, [
1922
1957
  "plugin",
1923
1958
  "--profile",
@@ -1925,7 +1960,11 @@ var CliGateway = class {
1925
1960
  "add",
1926
1961
  targetSpec
1927
1962
  ], ADD_TIMEOUT_MS);
1928
- if (add.code !== 0) {
1963
+ if (add.code !== 0 && reportsIgnoredBuilds(add.output)) tolerated = {
1964
+ code: add.code,
1965
+ output: add.output
1966
+ };
1967
+ if (add.code !== 0 && tolerated === void 0) {
1929
1968
  await this.rollbackMigration(job, sourceId, targetId, oldSpec, oldIndex, targetPreviouslyInstalled);
1930
1969
  job.error = `plugin-manager: 迁移安装 ${targetSpec} 失败${add.output === "" ? "" : `:\n${add.output}`}`;
1931
1970
  return;
@@ -1934,7 +1973,7 @@ var CliGateway = class {
1934
1973
  }
1935
1974
  if (!after.dependencies.includes(targetId)) {
1936
1975
  await this.rollbackMigration(job, sourceId, targetId, oldSpec, oldIndex, targetPreviouslyInstalled);
1937
- job.error = `plugin-manager: dsh plugin add 报告成功,但 ${targetId} 未出现在 profile 中`;
1976
+ job.error = tolerated === void 0 ? `plugin-manager: dsh plugin add 报告成功,但 ${targetId} 未出现在 profile 中` : `plugin-manager: 迁移安装 ${targetSpec} 失败${tolerated.output === "" ? "" : `:\n${tolerated.output}`}`;
1938
1977
  return;
1939
1978
  }
1940
1979
  const stripped = await this.stripDuplicateMounts(job, before, after);
@@ -1978,6 +2017,7 @@ var CliGateway = class {
1978
2017
  from: change.from,
1979
2018
  to: change.to
1980
2019
  }));
2020
+ if (tolerated !== void 0) this.recordToleratedExit(job, tolerated);
1981
2021
  job.phase = "done";
1982
2022
  }
1983
2023
  /** Restore the original legacy package after a failed migration. */
@@ -2539,7 +2579,8 @@ var CliGateway = class {
2539
2579
  ...job,
2540
2580
  conflicts: job.conflicts === void 0 ? void 0 : [...job.conflicts],
2541
2581
  notices: job.notices === void 0 ? void 0 : [...job.notices],
2542
- restartRequired: job.restartRequired === void 0 ? void 0 : [...job.restartRequired]
2582
+ restartRequired: job.restartRequired === void 0 ? void 0 : [...job.restartRequired],
2583
+ warnings: job.warnings === void 0 ? void 0 : [...job.warnings]
2543
2584
  };
2544
2585
  }
2545
2586
  /** Capture the layer snapshot and the dependency names (tolerant parse). */
@@ -2615,9 +2656,13 @@ var CliGateway = class {
2615
2656
  capture(chunk, output);
2616
2657
  });
2617
2658
  const code = await awaitCliExit(child, output, timeoutMs);
2618
- if (code !== 0) {
2659
+ const tail = output.read().trim();
2660
+ const tolerated = code !== 0 && reportsIgnoredBuilds(tail) ? {
2661
+ code,
2662
+ output: tail
2663
+ } : void 0;
2664
+ if (code !== 0 && tolerated === void 0) {
2619
2665
  job.phase = "error";
2620
- const tail = output.read().trim();
2621
2666
  job.error = tail === "" ? `plugin-manager: dsh plugin ${job.action} exited with code ${String(code)}` : tail;
2622
2667
  return;
2623
2668
  }
@@ -2638,7 +2683,7 @@ var CliGateway = class {
2638
2683
  const name = this.newDependency(before, after);
2639
2684
  if (name === void 0) {
2640
2685
  job.phase = "error";
2641
- job.error = "plugin-manager: dsh plugin add 报告成功,但 profile 未新增任何依赖(安装未生效)";
2686
+ job.error = tolerated?.output ?? "plugin-manager: dsh plugin add 报告成功,但 profile 未新增任何依赖(安装未生效)";
2642
2687
  return;
2643
2688
  }
2644
2689
  const duplicate = await this.detectDuplicateClaims(before, after);
@@ -2658,14 +2703,14 @@ var CliGateway = class {
2658
2703
  const targetVersion = job.targetVersion;
2659
2704
  if (targetId === void 0 || targetVersion === void 0 || !after.dependencies.includes(targetId)) {
2660
2705
  job.phase = "error";
2661
- job.error = "plugin-manager: dsh plugin add 报告成功,但目标插件未保留在 profile 中(更新未生效)";
2706
+ job.error = tolerated?.output ?? "plugin-manager: dsh plugin add 报告成功,但目标插件未保留在 profile 中(更新未生效)";
2662
2707
  return;
2663
2708
  }
2664
2709
  const manifest = await readProfileManifest(this.facts.packageJsonPath);
2665
2710
  const updated = await buildPluginRow(this.facts, targetId, manifest.dependencies[targetId] ?? job.spec, after.layer.rows);
2666
2711
  if (updated.version !== targetVersion) {
2667
2712
  job.phase = "error";
2668
- job.error = `plugin-manager: dsh plugin add 报告成功,但 ${targetId} 仍为 ${updated.version},预期 ${targetVersion}(更新未生效)`;
2713
+ job.error = tolerated?.output ?? `plugin-manager: dsh plugin add 报告成功,但 ${targetId} 仍为 ${updated.version},预期 ${targetVersion}(更新未生效)`;
2669
2714
  return;
2670
2715
  }
2671
2716
  job.plugin = updated;
@@ -2674,7 +2719,7 @@ var CliGateway = class {
2674
2719
  if (await this.pruneOrphanOverrides(job, dump) === void 0) return;
2675
2720
  } else if (before.dependencies.find((candidate) => !after.dependencies.includes(candidate)) === void 0) {
2676
2721
  job.phase = "error";
2677
- job.error = "plugin-manager: dsh plugin remove 报告成功,但依赖仍在 profile 中(卸载未生效)";
2722
+ job.error = tolerated?.output ?? "plugin-manager: dsh plugin remove 报告成功,但依赖仍在 profile 中(卸载未生效)";
2678
2723
  return;
2679
2724
  }
2680
2725
  job.conflicts = conflicts.map((change) => ({
@@ -2684,9 +2729,24 @@ var CliGateway = class {
2684
2729
  to: change.to
2685
2730
  }));
2686
2731
  if (job.action === "install" || job.action === "remove") job.plugin = await this.rowFor(job.action, job.spec, before, after);
2732
+ if (tolerated !== void 0) this.recordToleratedExit(job, tolerated);
2687
2733
  job.phase = "done";
2688
2734
  }
2689
2735
  /**
2736
+ * Carry an accepted non-zero exit to the caller and to the host log.
2737
+ *
2738
+ * Every post-check passed, so the change landed and the job settles `done`;
2739
+ * the pnpm output is kept anyway, because it is the only record that a
2740
+ * dependency was installed without its build script — a fact the next boot
2741
+ * reports as a missing native module, with nothing left to attribute it to.
2742
+ * @param job - the job the run settles.
2743
+ * @param tolerated - the exit the profile overruled.
2744
+ */
2745
+ recordToleratedExit(job, tolerated) {
2746
+ job.warnings = [...job.warnings ?? [], tolerated.output];
2747
+ console.warn(`[plugin-manager] 退出码 ${String(tolerated.code)} 已按完成处理:profile 变更已落地,pnpm 只是跳过了构建脚本(可用 pnpm approve-builds 复核):\n${tolerated.output}`);
2748
+ }
2749
+ /**
2690
2750
  * Post-mutation duplicate-mount safeguard (B9): remove the bundles entries
2691
2751
  * the CLI's reconciliation newly added for packages the before-state
2692
2752
  * composition already mounted through a patch row. The write goes through
@@ -3274,8 +3334,8 @@ function evaluateDshCompatibility(host, range) {
3274
3334
  *
3275
3335
  * The runtime identifiers (web-ui-* rows, settings section, API paths,
3276
3336
  * storage keys) stay frozen; only the npm aggregate package name changes.
3277
- * This module is the single migration map shared by the plugin-manager
3278
- * update job and the Doctor preflight launcher so they never drift.
3337
+ * This module is the single migration map for the plugin-manager update job,
3338
+ * the one official writer that rewrites a user profile.
3279
3339
  */
3280
3340
  /** The previously published aggregate package name. */
3281
3341
  const LEGACY_AGGREGATE = "@linxin666/dsh-web-ui-all";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The "Built-in plugins" group at the bottom of the official Plugins page.
3
+ *
4
+ * By default it lists every global Loader entry no installed bundle contributes —
5
+ * the rows a profile patch inserts itself (the Computer Use pair among them) and
6
+ * the rows the host ships globally — each with the official manager's own switch,
7
+ * so a row is enabled or disabled by exactly the call the official page makes.
8
+ * One control widens that list to every Loader entry and names, on each row a
9
+ * bundle adds, the bundle that adds it: those rows are the ones a reader also
10
+ * meets on that bundle's own page, and the answer to "why is this here twice" is
11
+ * that sentence. Below it, the agent preset compositions the same inventory
12
+ * reports are rendered read-only: a preset's rows are composed per session and
13
+ * only a Loader context can decide a `!!js` condition, so nothing here offers
14
+ * them a switch.
15
+ *
16
+ * Every state shown is the Loader's own: after an accepted write the group
17
+ * re-reads instead of trusting the answer, a refusal is named by the code the
18
+ * manager returned, and a locked row says which lock it is.
19
+ * @module @linxin666/dsh-client-ui-plugin-manager/client
20
+ */
21
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
22
+ import { type DisplayText } from '../core/builtin.ts';
23
+ import type { RemoteSnapshot } from './native-faces.ts';
24
+ /** The operations the group drives, all of them the official manager's own. */
25
+ export interface BuiltinPluginsInjected {
26
+ /** The official faces, sampled on every render; its `version` moves on change. */
27
+ remote: RemoteSnapshot;
28
+ /**
29
+ * Resolve package metadata text through the language the GUI is showing. The
30
+ * inventory hands back translations, not strings, and the mount owns no
31
+ * language of its own.
32
+ */
33
+ resolveText: (text: DisplayText) => string;
34
+ }
35
+ /** Full component props. */
36
+ export type BuiltinPluginsProps = PropsLocale<'settings.pluginManager'> & BuiltinPluginsInjected;
37
+ /**
38
+ * The group itself. All state is local: the page around it owns the plugin list,
39
+ * and the Loader is the only truth this component reports.
40
+ */
41
+ export declare function BuiltinPlugins(props: BuiltinPluginsProps): import("react").JSX.Element;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Mounting the built-in plugin group at the bottom of the official Plugins page.
3
+ *
4
+ * The page declares no seat at the list's end: its extension points are
5
+ * `plugins.detail.*` (per page), `plugins.bundle.config` / `plugins.row.config` /
6
+ * `plugins.item` (configuration entries) and `plugins.bundle.activation`. Its
7
+ * list view is `<section data-plugin-panel> <header/> <div class="…_installedPanel">
8
+ * <section data-plugin-group="basic|extensions|bundles"/> … </div> … </section>`,
9
+ * and the class names are CSS-module hashes, so the seat is found through the
10
+ * page's own data attributes plus DOM position: the section after the installed
11
+ * panel, which is a flex column of 32px gaps whose direct children are exactly
12
+ * the width of the groups above.
13
+ *
14
+ * The container is a plain element carrying its own React root, so it can never
15
+ * disturb the page's reconciliation, and it re-seats itself through the
16
+ * page-wide body-mutation hub: a re-render that moves or drops the panel is
17
+ * followed on the next frame, a panel switch that unmounts the list detaches
18
+ * the container until the list returns, and the detail / "all plugins" views
19
+ * (which render no bundles group) leave it off the page entirely.
20
+ * @module @linxin666/dsh-client-ui-plugin-manager/client
21
+ */
22
+ import { type BuiltinPluginsProps } from './BuiltinPlugins.tsx';
23
+ /** Stable attribute identifying the injected container (mount idempotency). */
24
+ export declare const BUILTIN_GROUP_MOUNT_SELECTOR = "[data-dsh-plugin-manager-builtin]";
25
+ /** The mount's inputs. */
26
+ export interface BuiltinGroupMountOptions {
27
+ /** Build the group's props; called on mount and on every locale change. */
28
+ props: () => BuiltinPluginsProps;
29
+ /** Locale change subscription (ctx.locale.subscribe); re-renders the group. */
30
+ subscribe?: (listener: () => void) => () => void;
31
+ }
32
+ /**
33
+ * The official page's installed panel, when the list view is mounted.
34
+ * @returns the element the group belongs after, or undefined off the list view.
35
+ */
36
+ export declare function builtinGroupSeat(): HTMLElement | undefined;
37
+ /**
38
+ * Mount the built-in plugin group after the installed panel.
39
+ * @param options - props factory and the optional locale subscription.
40
+ * @returns disposer removing the container, its observers and its React root.
41
+ */
42
+ export declare function mountBuiltinPluginGroup(options: BuiltinGroupMountOptions): () => void;
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Plugin-manager browser half: contributes the package's one remaining
3
- * surface — the check-for-updates block on the official Plugins page — and
4
- * provides the dual-channel face as the `'pluginManager'` cordis service for
5
- * sibling client plugins.
2
+ * Plugin-manager browser half: contributes this package's surfaces on the
3
+ * official Plugins page — the check-for-updates block, the list-level update
4
+ * toolbar, and the built-in plugin group at the list's bottom — and provides the
5
+ * dual-channel face as the `'pluginManager'` cordis service for sibling client
6
+ * plugins.
6
7
  *
7
8
  * It is dual-channel: on runtimes with the official installer services
8
9
  * (DSHCode, the 1.0.4 checkout web) every operation rides the official
@@ -47,6 +47,36 @@ declare const STATIC_ZH: {
47
47
  downloadingPercent: string;
48
48
  extracting: string;
49
49
  writing: string;
50
+ builtinGroup: string;
51
+ builtinReading: string;
52
+ builtinEmpty: string;
53
+ builtinUnavailable: string;
54
+ builtinFailed: string;
55
+ builtinUnconfirmed: string;
56
+ builtinScopeExpand: string;
57
+ builtinScopeCollapse: string;
58
+ builtinOwnedBy: string;
59
+ builtinToggle: string;
60
+ builtinFailedEnable: string;
61
+ builtinFailedDisable: string;
62
+ builtinReasonManagementRequired: string;
63
+ builtinReasonUnaddressable: string;
64
+ builtinReasonUnknown: string;
65
+ builtinRestartRequired: string;
66
+ builtinOverridden: string;
67
+ builtinRestartUnnamed: string;
68
+ builtinRestartNoHmr: string;
69
+ builtinRestartPackageMoved: string;
70
+ builtinRestartHostModule: string;
71
+ builtinRestartUnmanagedPlugin: string;
72
+ builtinRestartModuleComparison: string;
73
+ presetGroup: string;
74
+ presetDefault: string;
75
+ presetBroken: string;
76
+ presetRowOn: string;
77
+ presetRowOff: string;
78
+ presetRowConditional: string;
79
+ presetRowConditionalUnnamed: string;
50
80
  localOnlyTitle: string;
51
81
  localOnlyBody: string;
52
82
  };
@@ -87,6 +117,36 @@ export declare const zh: {
87
117
  downloadingPercent: string;
88
118
  extracting: string;
89
119
  writing: string;
120
+ builtinGroup: string;
121
+ builtinReading: string;
122
+ builtinEmpty: string;
123
+ builtinUnavailable: string;
124
+ builtinFailed: string;
125
+ builtinUnconfirmed: string;
126
+ builtinScopeExpand: string;
127
+ builtinScopeCollapse: string;
128
+ builtinOwnedBy: string;
129
+ builtinToggle: string;
130
+ builtinFailedEnable: string;
131
+ builtinFailedDisable: string;
132
+ builtinReasonManagementRequired: string;
133
+ builtinReasonUnaddressable: string;
134
+ builtinReasonUnknown: string;
135
+ builtinRestartRequired: string;
136
+ builtinOverridden: string;
137
+ builtinRestartUnnamed: string;
138
+ builtinRestartNoHmr: string;
139
+ builtinRestartPackageMoved: string;
140
+ builtinRestartHostModule: string;
141
+ builtinRestartUnmanagedPlugin: string;
142
+ builtinRestartModuleComparison: string;
143
+ presetGroup: string;
144
+ presetDefault: string;
145
+ presetBroken: string;
146
+ presetRowOn: string;
147
+ presetRowOff: string;
148
+ presetRowConditional: string;
149
+ presetRowConditionalUnnamed: string;
90
150
  localOnlyTitle: string;
91
151
  localOnlyBody: string;
92
152
  };
@@ -127,6 +187,36 @@ export declare const en: {
127
187
  downloadingPercent: string;
128
188
  extracting: string;
129
189
  writing: string;
190
+ builtinGroup: string;
191
+ builtinReading: string;
192
+ builtinEmpty: string;
193
+ builtinUnavailable: string;
194
+ builtinFailed: string;
195
+ builtinUnconfirmed: string;
196
+ builtinScopeExpand: string;
197
+ builtinScopeCollapse: string;
198
+ builtinOwnedBy: string;
199
+ builtinToggle: string;
200
+ builtinFailedEnable: string;
201
+ builtinFailedDisable: string;
202
+ builtinReasonManagementRequired: string;
203
+ builtinReasonUnaddressable: string;
204
+ builtinReasonUnknown: string;
205
+ builtinRestartRequired: string;
206
+ builtinOverridden: string;
207
+ builtinRestartUnnamed: string;
208
+ builtinRestartNoHmr: string;
209
+ builtinRestartPackageMoved: string;
210
+ builtinRestartHostModule: string;
211
+ builtinRestartUnmanagedPlugin: string;
212
+ builtinRestartModuleComparison: string;
213
+ presetGroup: string;
214
+ presetDefault: string;
215
+ presetBroken: string;
216
+ presetRowOn: string;
217
+ presetRowOff: string;
218
+ presetRowConditional: string;
219
+ presetRowConditionalUnnamed: string;
130
220
  localOnlyTitle: string;
131
221
  localOnlyBody: string;
132
222
  };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Bridge to the official remote namespaces the built-in plugin group reads
3
+ * through, and to the event that says the host rewrote the profile.
4
+ *
5
+ * - `remote.pluginInventory` — the Loader snapshot (entries and, when a roster is
6
+ * composed, each agent preset's rows).
7
+ * - `remote.pluginManager` — the very manager the official Plugins page drives:
8
+ * per-row writability, the installed bundle roster, and enable/disable.
9
+ * - `plugin-manager/changed` — forwarded on the `remote` root after a write, so a
10
+ * second page (or the official page's own switch) re-reads instead of showing
11
+ * a stale toggle.
12
+ *
13
+ * Every face is OPTIONAL: `ctx.inject` runs the effect when the namespace is
14
+ * published and disposes it when it goes away, which clears the snapshot. An
15
+ * absent face leaves the group's read-only "unavailable" state, never a write.
16
+ *
17
+ * CONTRACT OBSERVATION: cross-package value imports are forbidden and this
18
+ * package does not depend on the api-remotes assembly types, so the members
19
+ * called here are re-declared. Their shapes are the official manager's own
20
+ * schemas, not ones this package invented.
21
+ * @module @linxin666/dsh-client-ui-plugin-manager/client
22
+ */
23
+ import type { Context } from '@deepseek-ai/cordis';
24
+ /** The inventory namespace's one method. */
25
+ export interface InventoryFace {
26
+ /** Read the Loader, and every composed preset's rows, on each call. */
27
+ list(): Promise<unknown>;
28
+ }
29
+ /** The manager namespace's methods this package calls. */
30
+ export interface ManagerFace {
31
+ /** Every Loader entry with its `patchId` or the reason it cannot be written. */
32
+ listPlugins(): Promise<unknown>;
33
+ /** Every installed bundle, with the rows its patch inserts. */
34
+ listBundles(): Promise<unknown>;
35
+ /** Enable or disable one Loader entry through the official manager. */
36
+ setPluginEnabled(entryId: string, enabled: boolean): Promise<unknown>;
37
+ }
38
+ /** The `remote` root's forwarded-event subscription. */
39
+ export interface RemoteEventFace {
40
+ $on?(event: string, listener: (payload: unknown) => void): () => void;
41
+ }
42
+ /** What the group reads, sampled per render; `version` moves on every change. */
43
+ export interface RemoteSnapshot {
44
+ readonly version: number;
45
+ readonly inventory: InventoryFace | null;
46
+ readonly manager: ManagerFace | null;
47
+ }
48
+ /** The current snapshot (stable reference between changes). */
49
+ export declare function getRemoteSnapshot(): RemoteSnapshot;
50
+ /**
51
+ * Subscribe to snapshot changes.
52
+ * @param listener - called after every face swap or forwarded change event.
53
+ * @returns the unsubscribe function.
54
+ */
55
+ export declare function subscribeRemote(listener: () => void): () => void;
56
+ /**
57
+ * Bridge the official faces into the snapshot. Uses `ctx.inject` (not the
58
+ * plugin's module-level inject array) so each face stays optional.
59
+ * @param ctx - the client context the plugin runs in.
60
+ */
61
+ export declare function bridgeRemoteNamespaces(ctx: Context): void;
@@ -0,0 +1,178 @@
1
+ /**
2
+ * The built-in plugin group's pure logic: which global Loader entries no
3
+ * installed bundle contributes, how each one may be written, and the two answer
4
+ * shapes the official remote namespaces return.
5
+ *
6
+ * "Built-in" is a subtraction, not a roster of ours: the inventory's Loader
7
+ * entries minus every entry an installed bundle's patch inserts. That covers the
8
+ * rows a profile patch inserts itself — the Computer Use pair among them — and
9
+ * the rows the host ships globally, without this package keeping a list that
10
+ * would drift. The modules the official manager protects are refused by the
11
+ * manager itself and reported per row as `readOnlyReason`, so no second
12
+ * whitelist lives here.
13
+ * @module @linxin666/dsh-client-ui-plugin-manager/client
14
+ */
15
+ /** Literal text or translations indexed by language id, as package metadata carries it. */
16
+ export type DisplayText = string | {
17
+ readonly en: string;
18
+ readonly [locale: string]: string;
19
+ };
20
+ /** Display metadata the inventory attaches to a Loader entry. */
21
+ export interface EntryMeta {
22
+ readonly title?: DisplayText;
23
+ readonly description?: DisplayText;
24
+ readonly icon?: string;
25
+ readonly error?: string;
26
+ }
27
+ /** A Loader entry's fiber phase, or null when the entry has no live root. */
28
+ export type FiberPhase = null | 'failed' | 'pending' | 'active' | 'loading' | 'unloading';
29
+ /** One Loader entry as `pluginInventory.list()` reports it. */
30
+ export interface LoaderEntry {
31
+ readonly entryId: string;
32
+ readonly moduleName: string;
33
+ readonly meta?: EntryMeta;
34
+ readonly enabled: boolean;
35
+ readonly fiberPhase: FiberPhase;
36
+ }
37
+ /** One composition row of an agent preset. */
38
+ export interface AgentPresetRow {
39
+ readonly entryId: string | null;
40
+ readonly moduleName: string;
41
+ readonly meta?: EntryMeta;
42
+ readonly enabled: boolean | 'conditional';
43
+ /** The row's own `!!js` disabled expression, when it carries one. */
44
+ readonly condition?: string;
45
+ readonly fiberPhase: FiberPhase;
46
+ }
47
+ /** One composed agent preset. */
48
+ export interface AgentPreset {
49
+ readonly id: string;
50
+ readonly name?: string;
51
+ readonly isDefault: boolean;
52
+ /** Why this preset's composition cannot be read; absent when rows answer. */
53
+ readonly broken?: string;
54
+ readonly rows: readonly AgentPresetRow[];
55
+ }
56
+ /** The `pluginInventory.list()` snapshot this group consumes. */
57
+ export interface PluginInventory {
58
+ readonly managementAvailable?: boolean;
59
+ readonly entries: readonly LoaderEntry[];
60
+ readonly agentPresets?: readonly AgentPreset[];
61
+ }
62
+ /** The slice of `pluginManager.listBundles()` this group subtracts. */
63
+ export interface BundleFacts {
64
+ /** The installed bundle's package name; the row's owner reads as this. */
65
+ readonly name?: string;
66
+ /**
67
+ * Whether the profile actually declares this bundle. The roster also reports
68
+ * bundles that are only available, and their declared rows are no mounted
69
+ * Loader entries — counting them would take a live row out of the default scope
70
+ * over a package that is not even installed, so `false` is skipped. Absent
71
+ * keeps the bundle in play, which is how the manager always answers.
72
+ */
73
+ readonly installed?: boolean;
74
+ readonly rows?: readonly {
75
+ readonly entryId?: string;
76
+ }[];
77
+ }
78
+ /** The slice of `pluginManager.listPlugins()` that decides a row's writability. */
79
+ export interface PluginFacts {
80
+ readonly entryId: string;
81
+ readonly readOnlyReason?: 'management-required' | 'unaddressable';
82
+ }
83
+ /** Why a row's switch is locked, or that the manager will take a write. */
84
+ export type WriteState = 'writable' | 'management-required' | 'unaddressable' | 'unknown';
85
+ /** One row of the built-in group, in whichever scope it is shown. */
86
+ export interface BuiltinRow {
87
+ readonly entryId: string;
88
+ readonly moduleName: string;
89
+ readonly meta?: EntryMeta;
90
+ readonly enabled: boolean;
91
+ readonly write: WriteState;
92
+ /**
93
+ * The installed bundle whose patch inserts this entry, by package name. Absent
94
+ * on a row no bundle contributes — the rows the group lists by default.
95
+ */
96
+ readonly ownedBy?: string;
97
+ }
98
+ /** The group's two scopes, the ownership behind them, and the roster state. */
99
+ export interface BuiltinSelection {
100
+ /** The default scope: the entries no installed bundle contributes. */
101
+ readonly rows: readonly BuiltinRow[];
102
+ /**
103
+ * Every Loader entry in Loader order, with `ownedBy` on the ones a bundle
104
+ * contributes. Same row shape as {@link BuiltinSelection.rows}, so the two
105
+ * scopes render through one path.
106
+ */
107
+ readonly allRows: readonly BuiltinRow[];
108
+ /** Loader entry id to the package name of the bundle that inserts it. */
109
+ readonly owners: ReadonlyMap<string, string>;
110
+ /**
111
+ * `confirmed` when every installed bundle was read and its rows subtracted;
112
+ * `unconfirmed` when that read failed and every entry is listed instead.
113
+ */
114
+ readonly bundles: 'confirmed' | 'unconfirmed';
115
+ }
116
+ /**
117
+ * Select the built-in group's two scopes in one pass: every Loader entry, the
118
+ * ones no installed bundle contributes, and which bundle contributes the rest.
119
+ *
120
+ * The default scope is the subtraction the group shipped with; the wider scope is
121
+ * the same rows plus the ones a bundle's patch inserts, each named after that
122
+ * bundle — the reason a reader meets them again on the bundle's own page.
123
+ * @param inventory - the Loader snapshot.
124
+ * @param bundles - every installed bundle, or undefined when `listBundles()`
125
+ * failed; both scopes then list every entry and the group says so.
126
+ * @param plugins - the manager's plugin rows, or undefined when that read
127
+ * failed; an unread row is reported as `unknown` rather than guessed writable.
128
+ * @returns both scopes, the ownership map behind them, and the roster state.
129
+ */
130
+ export declare function selectBuiltinEntries(inventory: PluginInventory, bundles: readonly BundleFacts[] | undefined, plugins: readonly PluginFacts[] | undefined): BuiltinSelection;
131
+ /** One official remote answer: the gateway's envelope, or a bare value. */
132
+ export type RemoteAnswer<T> = {
133
+ readonly ok: true;
134
+ readonly value: T;
135
+ } | {
136
+ readonly ok: false;
137
+ readonly code?: string;
138
+ };
139
+ /**
140
+ * Read one `remote.<namespace>` answer.
141
+ *
142
+ * The API gateway wraps every namespace result as `{ ok, value | error }`, and a
143
+ * carrier that hands the bare value back must not be mistaken for a failure —
144
+ * so an object is treated as an envelope only when its `ok` really is a boolean,
145
+ * and anything else passes through as the value itself.
146
+ * @param raw - the resolved answer, exactly as the namespace returned it.
147
+ * @returns the unwrapped value, or the envelope's error code.
148
+ */
149
+ export declare function readRemoteAnswer<T>(raw: unknown): RemoteAnswer<T>;
150
+ /** The applications one write can end in. */
151
+ export type ChangeApplication = 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
152
+ /**
153
+ * What a write achieved: the application the host settled on, or the code it
154
+ * failed with. `overridden` is a resolved write a higher profile layer wins
155
+ * over — the official page reports it as its own notice rather than a failure,
156
+ * because the manager did accept the call.
157
+ */
158
+ export type ChangeOutcome = {
159
+ readonly ok: true;
160
+ readonly application: 'applied' | 'overridden' | 'restart-required';
161
+ /** Why `restart-required`, as the host named it. */
162
+ readonly restartReason?: string;
163
+ } | {
164
+ readonly ok: false;
165
+ readonly code: string;
166
+ };
167
+ /**
168
+ * Read one `setPluginEnabled` answer.
169
+ *
170
+ * The official manager folds a refusal into the resolved result
171
+ * (`application: 'failed'` with an `error.code`) instead of rejecting, so a
172
+ * resolved promise is not a success. Both answer shapes are accepted because
173
+ * the gateway's envelope and the bare `ChangeResult` are the same call seen
174
+ * through two carriers.
175
+ * @param raw - the resolved answer.
176
+ * @returns the outcome the switch should show.
177
+ */
178
+ export declare function readChangeResult(raw: unknown): ChangeOutcome;