dsh-dty 0.0.0-stage → 0.1.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 (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +224 -2
  3. package/assets/icon.png +0 -0
  4. package/cordis.patch.yml +9 -0
  5. package/lib/client.js +13201 -0
  6. package/lib/index.js +7275 -0
  7. package/lib/typert.host.d.ts +3 -0
  8. package/lib/typert.host.js +724 -0
  9. package/lib/typert.remote-client.d.ts +46 -0
  10. package/lib/typert.remote-client.js +512 -0
  11. package/lib/types/client/EntryIcon.d.ts +27 -0
  12. package/lib/types/client/FoldableRedBlock.d.ts +27 -0
  13. package/lib/types/client/ShopDetailAction.d.ts +46 -0
  14. package/lib/types/client/ShopGlyph.d.ts +12 -0
  15. package/lib/types/client/ShopPage.d.ts +27 -0
  16. package/lib/types/client/ShopTab.d.ts +110 -0
  17. package/lib/types/client/flow-registry.d.ts +91 -0
  18. package/lib/types/client/index.d.ts +89 -0
  19. package/lib/types/client/listeners.d.ts +27 -0
  20. package/lib/types/client/locales.d.ts +427 -0
  21. package/lib/types/client/module-table.d.ts +131 -0
  22. package/lib/types/client/page-store.d.ts +259 -0
  23. package/lib/types/client/present.d.ts +627 -0
  24. package/lib/types/client/restart-monitor.d.ts +156 -0
  25. package/lib/types/client/useFlows.d.ts +88 -0
  26. package/lib/types/client/useFoldableRedBlock.d.ts +36 -0
  27. package/lib/types/client/useUpdateSelf.d.ts +28 -0
  28. package/lib/types/host/activation.d.ts +58 -0
  29. package/lib/types/host/bundle-patch.d.ts +35 -0
  30. package/lib/types/host/catalog.d.ts +82 -0
  31. package/lib/types/host/child-env.d.ts +36 -0
  32. package/lib/types/host/client-half.d.ts +28 -0
  33. package/lib/types/host/compatibility.d.ts +244 -0
  34. package/lib/types/host/dsh-cli.d.ts +88 -0
  35. package/lib/types/host/executor.d.ts +288 -0
  36. package/lib/types/host/harness.d.ts +166 -0
  37. package/lib/types/host/hot.d.ts +134 -0
  38. package/lib/types/host/index.d.ts +965 -0
  39. package/lib/types/host/install.d.ts +69 -0
  40. package/lib/types/host/manager-runner.d.ts +81 -0
  41. package/lib/types/host/npm-origin.d.ts +28 -0
  42. package/lib/types/host/npmrc.d.ts +23 -0
  43. package/lib/types/host/origin.d.ts +46 -0
  44. package/lib/types/host/peers.d.ts +269 -0
  45. package/lib/types/host/plugin-manager.d.ts +144 -0
  46. package/lib/types/host/prefetch.d.ts +67 -0
  47. package/lib/types/host/profile.d.ts +173 -0
  48. package/lib/types/host/race.d.ts +41 -0
  49. package/lib/types/host/repo-pins.d.ts +22 -0
  50. package/lib/types/host/restart.d.ts +76 -0
  51. package/lib/types/host/self-update.d.ts +17 -0
  52. package/lib/types/host/state.d.ts +118 -0
  53. package/lib/types/host/supervisor.d.ts +15 -0
  54. package/lib/types/host/types.d.ts +166 -0
  55. package/lib/types/index.d.ts +3 -0
  56. package/lib/types/own-version.d.ts +45 -0
  57. package/lib/types/shared/identity.d.ts +97 -0
  58. package/lib/types/shared/install-state.d.ts +16 -0
  59. package/lib/types/shared/npm-name.d.ts +42 -0
  60. package/lib/types/shared/shop-like.d.ts +32 -0
  61. package/lib/types/shared/tar.d.ts +18 -0
  62. package/lib/types/shared/zh-intents.d.ts +89 -0
  63. package/package.json +136 -3
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The shop's own page in dsh's main column (design
3
+ * 2026-10-16-shop-sidebar-page §4.2), framed as dsh frames its Plugins page:
4
+ * the page is its own scroll container, its head carries the title and the
5
+ * one intro line and clears the desktop title bar, and the body below is
6
+ * `ShopTab`, unchanged.
7
+ *
8
+ * It keeps the reader's scroll position in the page store (design
9
+ * 2026-10-16-shop-sidebar-page §5.7). The position is written on every
10
+ * scroll event — a browser fires at most one a frame, and the store takes it
11
+ * without telling anyone — with the card at the page's top edge. The page
12
+ * goes back there once, when the shelf is on screen again and the installed
13
+ * list has answered, unless the reader moved first: the same card at the
14
+ * same height, held there for a moment while the cards around it render, or
15
+ * the position when that card is no longer on the shelf or the shelf was
16
+ * refiltered since.
17
+ */
18
+ import { type ReactNode } from 'react';
19
+ import { type ShopTabProps } from './ShopTab.tsx';
20
+ /** How long the page holds the reader's card at its height once it is put
21
+ * back, in ms. The cards near it render a frame or two later and take their
22
+ * real heights, each correction brings a few more above it into range, and
23
+ * the shelf's entry animation moves it for 220ms (ShopTab.module.css).
24
+ * Measured on dsh 0.2.0-rc.2 with the live catalog, the card stood still
25
+ * within 200ms of being put back. */
26
+ export declare const HOLD_MS = 500;
27
+ export declare function ShopPage(props: ShopTabProps): ReactNode;
@@ -0,0 +1,110 @@
1
+ /** The shop tab: browse the catalog, detail an entry, install on one click,
2
+ * poll the install to its terminal state (§7.2).
3
+ * Everything the tab renders is text — summaries, capabilities, log lines,
4
+ * details — never markup, so hostile npm descriptions cannot inject (spec
5
+ * §11.3.4): no render path here may ever use dangerouslySetInnerHTML. */
6
+ import { type ReactNode } from 'react';
7
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
8
+ import type { InstallArgs, ShopCatalogResult, ShopInstalledEntry, ShopInstallResult, ShopInstallStatusResult, ShopRestartResult, ShopSetEnabledResult, ShopStateResult, ShopUninstallResult, ShopUpdateResult, ShopVersionResult } from '../host/index.ts';
9
+ import { type ShopPageStore } from './page-store.ts';
10
+ /** The tab's Remote face: the Host result types, already unwrapped from the
11
+ * wire envelope by `index.ts`; `catalog` throws on a wire error so the tab's
12
+ * error state renders. */
13
+ export interface ShopTabInjected {
14
+ /** `reverdict: true` means "judge again against the installation as it
15
+ * stands now" — the host's own snapshot and freshness window, asked with
16
+ * the same plain call as a stash-expired open, never a network refresh. A
17
+ * plain open can still serve the stash; a reverdict always bypasses it (the
18
+ * install or uninstall that triggered it predates whatever the stash
19
+ * holds). It is a client-only instruction: `index.ts` never lets it reach
20
+ * the host RPC, which accepts only `{ refresh?: boolean }`. */
21
+ catalog: (args?: {
22
+ refresh?: boolean;
23
+ reverdict?: boolean;
24
+ }) => Promise<ShopCatalogResult>;
25
+ install: (args: InstallArgs) => Promise<ShopInstallResult>;
26
+ installStatus: (args: {
27
+ installId: string;
28
+ }) => Promise<ShopInstallStatusResult>;
29
+ setEnabled: (args: {
30
+ name: string;
31
+ enabled: boolean;
32
+ }) => Promise<ShopSetEnabledResult>;
33
+ installed: () => Promise<ShopInstalledEntry[]>;
34
+ /** The profile manifest's dependency specs — the install gate's own input,
35
+ * so the card's verdict and the host's are one rule. `null` is "cannot
36
+ * say", never "nothing is installed". */
37
+ installedSpecs: () => Promise<Record<string, string> | null>;
38
+ uninstall: (args: {
39
+ name: string;
40
+ }) => Promise<ShopUninstallResult>;
41
+ /** Tells the client half that this page uninstalled `name`, so the module
42
+ * table's refinement never vouches for it again (the page-removed set,
43
+ * design 2026-09-01-harness-compatibility section 9.1): a graph row or a
44
+ * `loadCache` record can outlive a restart-free uninstall, and would
45
+ * otherwise clear a badge the host is still right to show. Optional — a
46
+ * stub or an old host face may not offer it — and installs need no
47
+ * counterpart, since a reinstalled package resolves on the host again. */
48
+ noteUninstalled?: (name: string) => void;
49
+ restart: () => Promise<ShopRestartResult>;
50
+ version: () => Promise<ShopVersionResult>;
51
+ /** Be told when the version answers start coming from another dsh process
52
+ * — dsh restarted under the page, which nothing reloads — with the first
53
+ * answer from it; returns the unsubscribe. The receipts a restart settles
54
+ * are the page store's to clear (`noteRestarted`), which index.ts calls on
55
+ * every restart under the page, tab or no tab; the tab clears them itself
56
+ * only for the store it builds when none is handed over (design §8,
57
+ * 2026-10-06 amendment, and design 2026-10-16-shop-sidebar-page §5.5).
58
+ * Optional: a stub may not offer it. */
59
+ onRestarted?: (listener: (fresh: ShopVersionResult) => void) => () => void;
60
+ updateStart: (args: {
61
+ version: string;
62
+ }) => Promise<ShopUpdateResult>;
63
+ /** Favorites and rollback records (design 2026-11-02-market-borrowings
64
+ * §6–§7). Optional like `reload`: a stub written before these existed keeps
65
+ * working, and the tab then draws no stars and offers no rollback. */
66
+ state?: () => Promise<ShopStateResult>;
67
+ setFavorite?: (args: {
68
+ key: string;
69
+ favorite: boolean;
70
+ }) => Promise<{
71
+ ok: boolean;
72
+ detail?: string;
73
+ }>;
74
+ rollback?: (args: {
75
+ key: string;
76
+ }) => Promise<ShopInstallResult>;
77
+ /** Open the shop's own page inside dsh's plugin manager. There a
78
+ * self-update of the shop runs when the host reports `selfUpdate:
79
+ * 'dsh-page'` (the desktop profile): dsh's page has the remove → install →
80
+ * restore operation the shop cannot run on itself. Optional like the rest
81
+ * — a host or stub without the navigation service offers no move, and the
82
+ * button is disabled. */
83
+ openUpdatePage?: () => void;
84
+ /** The §4 reload trigger, defaulted once at the tab root to a real page
85
+ * reload. Injected so a test can observe it without touching jsdom's
86
+ * non-writable `location.reload`. */
87
+ reload?: () => void;
88
+ /** The page's store (page-store.ts): the reader's place on the shelf and
89
+ * every flow, kept across leaving and returning (design
90
+ * 2026-10-16-shop-sidebar-page §5). Optional: without it the tab builds a
91
+ * store of its own, which lives and dies with the tab — how the tab
92
+ * behaved before the store existed, and what a stub gets. */
93
+ page?: ShopPageStore;
94
+ }
95
+ /** What only the page frame hands the body (ShopPage.tsx). */
96
+ export interface ShopTabOwnProps {
97
+ /** Called once per mount, on the first commit with the shelf on screen
98
+ * and an answer from the installed list, rows or none or a failure: the
99
+ * frame restores its scroll position then (design
100
+ * 2026-10-16-shop-sidebar-page §5.7). */
101
+ onShelfReady?: () => void;
102
+ }
103
+ /** The page's props as the main-column renderer assembles them (no owner
104
+ * props), plus what only the page frame hands the body. */
105
+ export type ShopTabProps = PropsRuntime<'main'> & PropsLocale<'settings.shop'> & InjectFace<ShopTabInjected> & ShopTabOwnProps;
106
+ /** The shop body inside its own error boundary, as `ShopPage` renders it
107
+ * below the page's head (index.ts registers `ShopPage` in the main column).
108
+ * Exported under the name the body used to carry, so nothing can render the
109
+ * body without the boundary. */
110
+ export declare function ShopTab(props: ShopTabProps): ReactNode;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * One keyed registry of install-shaped flows: start, poll to terminal, reset.
3
+ *
4
+ * Framework-free, so a flow can belong to the page rather than to a component
5
+ * (design 2026-10-16-shop-sidebar-page §5). dsh mounts the shop only while it
6
+ * is on screen, and a flow held in a component's state — the poll loop an
7
+ * effect of that component — stopped the moment the reader looked elsewhere:
8
+ * the install ran on in the host, and nothing was left to fold its status or
9
+ * write its receipt. The page store (page-store.ts) owns three that outlive
10
+ * every component showing them, and `useRegistryFlows` (useFlows.ts) renders
11
+ * one for React.
12
+ *
13
+ * Install and uninstall are the same machine, and so is the shop's own
14
+ * update: they differ only in what the STARTING RPC's answer means, which is
15
+ * the three `begin*` mappings at the foot of this file.
16
+ */
17
+ import type { InstallArgs, ShopInstallResult, ShopInstallStatusResult, ShopUninstallResult, ShopUpdateResult } from '../host/index.ts';
18
+ import { type InstallView } from './present.ts';
19
+ /** The one idle view, so a key the registry holds no flow for and a key it
20
+ * reset to idle hand a memoized consumer the same object. */
21
+ export declare const IDLE_VIEW: InstallView;
22
+ /** `map` without every entry `drop` selects, or null when it selects none.
23
+ * The copy is made at the first match, so a prune that matches nothing
24
+ * copies nothing, and its caller, handed null, publishes nothing. The
25
+ * registry's `resetWhere` and the page store's owed notices share this
26
+ * contract, so a fourth prune cannot return an empty map instead. */
27
+ export declare function pruned<K, V>(map: ReadonlyMap<K, V>, drop: (value: V, key: K) => boolean): Map<K, V> | null;
28
+ /** What a registry holds at one moment. Replaced whole on every change, so a
29
+ * consumer can tell "changed" from "same" by identity. */
30
+ export interface FlowSnapshot {
31
+ readonly views: ReadonlyMap<string, InstallView>;
32
+ /** Identities whose start is in flight and unanswered. */
33
+ readonly starting: ReadonlySet<string>;
34
+ }
35
+ export interface FlowRegistryDeps<TArgs> {
36
+ /** The starting RPC with its answer mapped to the first view. Never
37
+ * rejects: the mapping folds a transport throw into a view. */
38
+ begin: (args: TArgs) => Promise<InstallView>;
39
+ installStatus: (args: {
40
+ installId: string;
41
+ }) => Promise<ShopInstallStatusResult>;
42
+ /** Once per identity that reaches a terminal state: which one, and the
43
+ * arguments its flow was started with. The outcome is load-bearing: a
44
+ * failed flow changed nothing on the server. */
45
+ onSettled?: (key: string, outcome: 'done' | 'failed', args: TArgs) => void;
46
+ }
47
+ export interface FlowRegistryOptions {
48
+ /** Keep polling while nothing subscribes. The page store's registries do,
49
+ * so an install the reader left finishes its receipt with no page showing
50
+ * it; a component's own registry does not, so its polling stops when the
51
+ * component unmounts and resumes if it mounts again. */
52
+ pollUnwatched: boolean;
53
+ }
54
+ export interface FlowRegistry<TArgs> {
55
+ getSnapshot: () => FlowSnapshot;
56
+ subscribe: (listener: () => void) => () => void;
57
+ /** Start `key`'s flow. A second start while the first is unanswered is
58
+ * ignored: the host does not dedupe, so a second RPC would download and
59
+ * install the same thing twice. */
60
+ start: (key: string, args: TArgs) => Promise<void>;
61
+ reset: (key: string) => void;
62
+ /** Reset every identity whose view `predicate` selects. It is handed the
63
+ * identity too, so a caller can select one identity's view by its kind. */
64
+ resetWhere: (predicate: (view: InstallView, key: string) => boolean) => void;
65
+ /** Stop for good: no more polling, starts, changes or listeners, a start
66
+ * still unanswered included. The snapshot stays readable. */
67
+ dispose: () => void;
68
+ }
69
+ /**
70
+ * @param deps read on every call, so an owner can hand over its latest
71
+ * functions without rebuilding the registry.
72
+ */
73
+ export declare function createFlowRegistry<TArgs>(deps: () => FlowRegistryDeps<TArgs>, options: FlowRegistryOptions): FlowRegistry<TArgs>;
74
+ /** An install's start: the host's business union mapped to the first view. */
75
+ export declare function beginInstall(install: (args: InstallArgs) => Promise<ShopInstallResult>): (args: InstallArgs) => Promise<InstallView>;
76
+ /** An uninstall's start. Its refusals: not in the catalog, not installed.
77
+ * The host reports no phase for an uninstall, which opens on `installing`. */
78
+ export declare function beginUninstall(uninstall: (args: {
79
+ name: string;
80
+ }) => Promise<ShopUninstallResult>): (args: {
81
+ name: string;
82
+ }) => Promise<InstallView>;
83
+ /** The shop's own update's start. Its refusals: a version that is not plain
84
+ * semver, and the desktop profile, whose update belongs to dsh's Plugins
85
+ * page. The flow shows the host's own detail for either and never needs
86
+ * `code`: the version row does not offer this start on that profile. */
87
+ export declare function beginUpdate(updateStart: (args: {
88
+ version: string;
89
+ }) => Promise<ShopUpdateResult>): (args: {
90
+ version: string;
91
+ }) => Promise<InstallView>;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Shop surface, browser half — the shop's own page in dsh's main column
3
+ * (`main`), which browses the catalog, installs on one click, toggles
4
+ * enablement, lists installed plugins, and restarts dsh after installs; its
5
+ * row in the left sidebar (`sidebar.panellist`); and the two buttons on dsh's
6
+ * Plugins page that lead into it (`plugins.detail.actions`) (design
7
+ * 2026-10-16-shop-sidebar-page).
8
+ * Mounts the shop Remote itself (the assembly does not know this package)
9
+ * and holds no privilege beyond the nine `shop/*` methods (the shop design's
10
+ * §5.3).
11
+ */
12
+ import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
13
+ import type { ShopLocaleKey } from './locales.ts';
14
+ import { type PluginsSubject } from './ShopDetailAction.tsx';
15
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
16
+ interface LocaleNamespaceMap {
17
+ /** The shop page's copy. */
18
+ 'settings.shop': ShopLocaleKey;
19
+ }
20
+ interface SlotMap {
21
+ /** dsh's left column of global panels (`dsh-client-ui-sidebar`, on
22
+ * 0.1.5-rc.3, 0.1.7-rc.2 and 0.2.0-rc.2): one row per entry, which owns
23
+ * the button, its label and its selection, and renders the entry's glyph
24
+ * at the size it asks. Declared here, in dsh's own terms, because the
25
+ * 0.1.1-rc.2 protocol this package builds against predates it — as
26
+ * `connection/reset` is below. */
27
+ 'sidebar.panellist': {
28
+ kind: 'list';
29
+ scope: 'root';
30
+ owner: {
31
+ size: number;
32
+ active: boolean;
33
+ };
34
+ };
35
+ /** The main column, keyed by panel id (`dsh-client-ui-layout`, the same
36
+ * harnesses): only the selected key is mounted, and the sidebar row with
37
+ * the same id selects it. Declared here for the same reason. */
38
+ 'main': {
39
+ kind: 'keyed';
40
+ scope: 'root';
41
+ };
42
+ /** Controls at the head of a detail page on dsh's Plugins page
43
+ * (`dsh-client-ui-plugin-manager`, 0.1.7-rc.2 and later), rendered with
44
+ * the page's subject; an entry renders null for a subject it has nothing
45
+ * for. On a harness without the Plugins page nothing declares it, and a
46
+ * registration into it waits without ever rendering. */
47
+ 'plugins.detail.actions': {
48
+ kind: 'list';
49
+ scope: 'root';
50
+ owner: {
51
+ subject: PluginsSubject;
52
+ };
53
+ };
54
+ }
55
+ }
56
+ declare module '@deepseek-ai/cordis' {
57
+ interface Events {
58
+ /** A connection generation was established: the first connect after
59
+ * plugin boot, and every reconnect. `@deepseek-ai/dsh-client-connection`
60
+ * declares it, in these words, from 0.1.5-rc.3 on, and dsh-api-gateway's
61
+ * client emits it there through 0.2.0-rc.2; the 0.1.1-rc.2 this package
62
+ * builds against predates the declaration. A harness that never emits
63
+ * it leaves the shop as it was before it listened. */
64
+ 'connection/reset'(): void;
65
+ }
66
+ }
67
+ /** Dictionary namespace owned by this plugin. */
68
+ export declare const NS = "settings.shop";
69
+ /** The id the shop's sidebar row and its main-column page share (design
70
+ * 2026-10-16-shop-sidebar-page §4.1). */
71
+ export declare const SHOP_PANEL = "shop";
72
+ /** How long a stashed catalog may satisfy a plain open. The host applies the
73
+ * same five-minute freshness window, so the client stash must not outlive it. */
74
+ export declare const WARM_TTL_MS: number;
75
+ /** Services required by the page, row and Plugins page button registrations
76
+ * and the Remote mount.
77
+ *
78
+ * `remote.shop` is deliberately ABSENT: this package both mounts its own
79
+ * Remote (the assembly does not know it, §7.3) and consumes it, and cordis
80
+ * will not let one package do both through the inject face. Declaring the
81
+ * face makes the boot's activation gate wait for the `remote.shop` service —
82
+ * which only this package's own apply can register — and the real web boot
83
+ * deadlocked on exactly that ("waiting for service: remote.shop"). The
84
+ * namespace is therefore read through the reflect shop instead (`ctx.get`,
85
+ * see apply), which has no inject requirement. */
86
+ export declare const inject: string[];
87
+ /** Mount the shop Remote and contribute the shop's page, its sidebar row and
88
+ * its buttons on dsh's Plugins page. */
89
+ export declare function apply(ctx: ClientContext): Promise<void>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The listener plumbing the client's external stores share: the page store
3
+ * and its owed notices (page-store.ts), the flow registries
4
+ * (flow-registry.ts) and the restart monitor (restart-monitor.ts). Each keeps
5
+ * its listeners in a plain `Set`. React subscribes through `listen`, as
6
+ * `useSyncExternalStore` asks, and a change reaches every listener through
7
+ * `notify`.
8
+ *
9
+ * Functions over that `Set`, never an object a store keeps in its place. The
10
+ * restart monitor's store lives on `globalThis`, and a 0.8.x shop hands it
11
+ * over (design 2026-10-16-shop-sidebar-page §6). Its `listeners` is a plain
12
+ * `Set` that the predecessor's own code adds to, deletes from and iterates,
13
+ * so the field's shape is a contract across versions, and these functions
14
+ * take that `Set` as it is.
15
+ */
16
+ /** Add `listener`, and hand back what removes it. A forgotten set takes
17
+ * none: its store tells nobody anything more, so a listener subscribing in
18
+ * a hot swap's window would only be held. */
19
+ export declare function listen(listeners: Set<() => void>, listener: () => void): () => void;
20
+ /** Call every listener as the set stands when the call begins. Over a copy,
21
+ * so a listener that subscribes or unsubscribes one while it runs (React
22
+ * re-subscribing in the render the change caused) changes the next notify,
23
+ * never this one. */
24
+ export declare function notify(listeners: ReadonlySet<() => void>): void;
25
+ /** Drop every listener, and take none again: a disposed store tells nobody
26
+ * anything more. */
27
+ export declare function forget(listeners: Set<() => void>): void;