dsh-crate 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +288 -2
  3. package/README.zh.md +263 -0
  4. package/UPDATE-API-V1.md +207 -0
  5. package/assets/logo.svg +37 -0
  6. package/client/client.js +18964 -0
  7. package/cordis.patch.yml +4 -0
  8. package/lib/accelerate.js +194 -0
  9. package/lib/agents.js +67 -0
  10. package/lib/backup.js +688 -0
  11. package/lib/body-progress.js +173 -0
  12. package/lib/catalog-local-match.js +160 -0
  13. package/lib/catalog-npm.js +180 -0
  14. package/lib/changelog.js +462 -0
  15. package/lib/channels.js +64 -0
  16. package/lib/check.js +1557 -0
  17. package/lib/compatibility.js +243 -0
  18. package/lib/crate-catalog.js +179 -0
  19. package/lib/diagnostics.js +49 -0
  20. package/lib/discovery-compatibility.js +447 -0
  21. package/lib/drain-journal.js +164 -0
  22. package/lib/drain.js +1043 -0
  23. package/lib/dsh-cli.js +1373 -0
  24. package/lib/dsh-install.js +259 -0
  25. package/lib/entry-identity.js +85 -0
  26. package/lib/gist.js +369 -0
  27. package/lib/groups.js +108 -0
  28. package/lib/home-paths.js +29 -0
  29. package/lib/host-recovery.js +187 -0
  30. package/lib/hot.js +871 -0
  31. package/lib/http.js +252 -0
  32. package/lib/index.js +394 -0
  33. package/lib/install.js +1147 -0
  34. package/lib/lifecycle.js +37 -0
  35. package/lib/log-redaction.js +24 -0
  36. package/lib/log.js +204 -0
  37. package/lib/ndjson.js +154 -0
  38. package/lib/net.js +174 -0
  39. package/lib/official-desktop.js +619 -0
  40. package/lib/order.js +284 -0
  41. package/lib/patch.js +943 -0
  42. package/lib/pending-rows.js +142 -0
  43. package/lib/pending-updates.js +346 -0
  44. package/lib/pnpm-compat.js +972 -0
  45. package/lib/presets.js +282 -0
  46. package/lib/probe-context.js +20 -0
  47. package/lib/proc-text.js +69 -0
  48. package/lib/profile.js +1978 -0
  49. package/lib/recovery.js +1059 -0
  50. package/lib/region-probe.js +93 -0
  51. package/lib/regions.js +283 -0
  52. package/lib/registry.js +308 -0
  53. package/lib/release-candidates.js +115 -0
  54. package/lib/release-updates.js +70 -0
  55. package/lib/restart.js +688 -0
  56. package/lib/routes.js +7960 -0
  57. package/lib/settings.js +164 -0
  58. package/lib/shelfry-catalog.js +179 -0
  59. package/lib/snapshot.js +506 -0
  60. package/lib/source-migration.js +164 -0
  61. package/lib/sources.js +1005 -0
  62. package/lib/state.js +38 -0
  63. package/lib/store.js +163 -0
  64. package/lib/themes.js +350 -0
  65. package/lib/trial.js +125 -0
  66. package/lib/types/accelerate.d.ts +85 -0
  67. package/lib/types/agents.d.ts +52 -0
  68. package/lib/types/backup.d.ts +171 -0
  69. package/lib/types/body-progress.d.ts +94 -0
  70. package/lib/types/catalog-local-match.d.ts +39 -0
  71. package/lib/types/catalog-npm.d.ts +77 -0
  72. package/lib/types/changelog.d.ts +131 -0
  73. package/lib/types/channels.d.ts +56 -0
  74. package/lib/types/check.d.ts +353 -0
  75. package/lib/types/compatibility.d.ts +83 -0
  76. package/lib/types/crate-catalog.d.ts +48 -0
  77. package/lib/types/diagnostics.d.ts +29 -0
  78. package/lib/types/discovery-compatibility.d.ts +145 -0
  79. package/lib/types/drain-journal.d.ts +25 -0
  80. package/lib/types/drain.d.ts +306 -0
  81. package/lib/types/dsh-cli.d.ts +481 -0
  82. package/lib/types/dsh-install.d.ts +106 -0
  83. package/lib/types/entry-identity.d.ts +68 -0
  84. package/lib/types/gist.d.ts +79 -0
  85. package/lib/types/groups.d.ts +34 -0
  86. package/lib/types/home-paths.d.ts +13 -0
  87. package/lib/types/host-recovery.d.ts +95 -0
  88. package/lib/types/hot.d.ts +405 -0
  89. package/lib/types/http.d.ts +114 -0
  90. package/lib/types/index.d.ts +52 -0
  91. package/lib/types/install.d.ts +463 -0
  92. package/lib/types/lifecycle.d.ts +14 -0
  93. package/lib/types/log-redaction.d.ts +2 -0
  94. package/lib/types/log.d.ts +43 -0
  95. package/lib/types/ndjson.d.ts +52 -0
  96. package/lib/types/net.d.ts +94 -0
  97. package/lib/types/official-desktop.d.ts +59 -0
  98. package/lib/types/order.d.ts +100 -0
  99. package/lib/types/patch.d.ts +218 -0
  100. package/lib/types/pending-rows.d.ts +81 -0
  101. package/lib/types/pending-updates.d.ts +161 -0
  102. package/lib/types/pnpm-compat.d.ts +102 -0
  103. package/lib/types/presets.d.ts +94 -0
  104. package/lib/types/probe-context.d.ts +14 -0
  105. package/lib/types/proc-text.d.ts +29 -0
  106. package/lib/types/profile.d.ts +551 -0
  107. package/lib/types/recovery.d.ts +342 -0
  108. package/lib/types/region-probe.d.ts +50 -0
  109. package/lib/types/regions.d.ts +134 -0
  110. package/lib/types/registry.d.ts +160 -0
  111. package/lib/types/release-candidates.d.ts +42 -0
  112. package/lib/types/release-updates.d.ts +15 -0
  113. package/lib/types/restart.d.ts +279 -0
  114. package/lib/types/routes.d.ts +130 -0
  115. package/lib/types/settings.d.ts +112 -0
  116. package/lib/types/shelfry-catalog.d.ts +48 -0
  117. package/lib/types/snapshot.d.ts +93 -0
  118. package/lib/types/source-migration.d.ts +100 -0
  119. package/lib/types/sources.d.ts +391 -0
  120. package/lib/types/state.d.ts +20 -0
  121. package/lib/types/store.d.ts +47 -0
  122. package/lib/types/themes.d.ts +46 -0
  123. package/lib/types/trial.d.ts +61 -0
  124. package/lib/types/update-api-v1.d.ts +83 -0
  125. package/lib/types/updates.d.ts +273 -0
  126. package/lib/types/verify.d.ts +277 -0
  127. package/lib/update-api-v1.js +273 -0
  128. package/lib/updates.js +981 -0
  129. package/lib/verify.js +904 -0
  130. package/locale/en.json +5 -0
  131. package/locale/zh.json +6 -0
  132. package/package.json +113 -4
@@ -0,0 +1,207 @@
1
+ # Public plugin update API v1
2
+
3
+ > **Status: beta.** The shape described here may still change between
4
+ > releases. `GET /dsh-crate/api/v1/capabilities` reports
5
+ > `"stability": "beta"` while that is true, and `"stable"` once it stops
6
+ > moving — read that field rather than assuming from the `v1` in the path.
7
+ >
8
+ > Nothing here is going away; what is not yet promised is that field names
9
+ > and response shapes will survive untouched. If you ship against it now,
10
+ > say so in an issue: a shape somebody depends on is a much stronger reason
11
+ > not to move it, and it is how this reaches `stable`.
12
+
13
+
14
+ `dshmarket` exposes a small, versioned, same-origin JSON API for plugin-owned
15
+ update surfaces. It lets a plugin show its own update button without spawning a
16
+ package manager, copying the Market installation algorithm, or binding to the
17
+ Market UI's private response fields.
18
+
19
+ All responses carry:
20
+
21
+ ```json
22
+ { "schema": "dsh-crate/update-api/v1" }
23
+ ```
24
+
25
+ Clients must discover the API before enabling mutation controls:
26
+
27
+ ```http
28
+ GET /dsh-crate/api/v1/capabilities
29
+ ```
30
+
31
+ The response names the Market version, profile, runtime (`web` or `desktop`),
32
+ supported features, restart owner and endpoint paths. A client must hide its
33
+ restart button when `restart.supported` is false. Desktop and supervised hosts
34
+ normally delegate restart to their owning shell or operator.
35
+
36
+ ## Count what can be updated
37
+
38
+ ```http
39
+ GET /dsh-crate/api/v1/updates/summary
40
+ ```
41
+
42
+ ```json
43
+ {
44
+ "schema": "dsh-crate/update-api/v1",
45
+ "checked": 12,
46
+ "updatable": 3,
47
+ "packages": [
48
+ { "name": "dsh-mcp-connector", "source": "npm", "installedVersion": "1.1.0", "latestVersion": "1.2.0" }
49
+ ]
50
+ }
51
+ ```
52
+
53
+ `checked` is the denominator — how many installed plugins the answer looked
54
+ at. Read it, or a badge cannot tell "nothing to update" from "nothing was
55
+ looked at". The two are different answers and only one of them means the
56
+ profile is up to date.
57
+
58
+ `packages` carries the same objects the single-package endpoint below
59
+ returns, and lists only plugins that can be updated. A badge needs
60
+ `updatable`; a panel needs the rows; neither should have to filter the whole
61
+ profile itself.
62
+
63
+ `GET /dsh-crate/api/v1/capabilities` reports this endpoint at
64
+ `endpoints.updatesSummary` and sets `features.updatesSummary`. Check that
65
+ rather than probing for the path.
66
+
67
+ ## Check one installed package
68
+
69
+ ```http
70
+ GET /dsh-crate/api/v1/updates?name=dsh-mcp-connector&force=1
71
+ ```
72
+
73
+ The response includes the installed version, target version, source kind and
74
+ whether the target is a forward update. Omitting `force=1` allows the Market's
75
+ short update-check cache.
76
+
77
+ ## Start and observe an update
78
+
79
+ Mutation requests require the same-origin protection used by the Market UI.
80
+
81
+ Every endpoint here — reads included — also sits behind DSH's own browser
82
+ login, on any host that has one (`dsh web` from 0.1.2-alpha.2 on): a request
83
+ without the host's session cookie is answered `401`, and one from an untrusted
84
+ origin `403`, exactly as DSH answers for its own API (#603). A plugin UI running
85
+ in the DSH page sends that cookie with every same-origin `fetch`, so it needs no
86
+ change. A script or tool calling these endpoints from outside the browser is the
87
+ anonymous client this refuses; there is no separate token for it.
88
+
89
+ ```http
90
+ POST /dsh-crate/api/v1/updates
91
+ Content-Type: application/json
92
+
93
+ { "packageName": "dsh-mcp-connector" }
94
+ ```
95
+
96
+ An accepted request returns HTTP `202` immediately with an `operationId`.
97
+ Passing `"force": true` opts this one operation out of the registry release-age
98
+ wait; clients should offer it only after the normal operation reports
99
+ `RELEASE_TOO_FRESH` or `VERSION_UNCHANGED`.
100
+
101
+ Poll the operation by id:
102
+
103
+ ```http
104
+ GET /dsh-crate/api/v1/operations?operationId=<id>
105
+ ```
106
+
107
+ States are `queued`, `running`, `succeeded`, `failed`, `cancelled` and
108
+ `rolled-back`. Running operations include structured package progress when
109
+ pnpm provides it. Terminal operations include:
110
+
111
+ - the before and actually installed versions;
112
+ - `refreshRequired` and `restartRequired` outcomes;
113
+ - a stable failure code, bounded user-facing message and retryability;
114
+ - whether a compatibility rollback is currently available.
115
+
116
+ For npm updates, Market verifies the package version that pnpm actually placed
117
+ on disk before reporting success. This prevents pnpm's release-age policy or a
118
+ lagging registry mirror from silently turning `@latest` into an older or
119
+ unexpected build. A mismatch is restored from the pre-update recovery point
120
+ and reported as one of these stable failures:
121
+
122
+ - `DOWNGRADE_DETECTED`: the resolved version is older than the version present
123
+ before the operation; not retryable without a new target.
124
+ - `RESOLVED_VERSION_MISMATCH`: the resolved version is BELOW the registry
125
+ target checked immediately before installation; retryable after registry or
126
+ mirror convergence. A version above that target is accepted — `latest` can
127
+ move forward while the install is still running.
128
+
129
+ Provider clients should still compare `beforeVersion`, the target they showed
130
+ to the user, and `installedVersion` before offering restart. That independent
131
+ check protects clients connected to another compatible provider implementation.
132
+
133
+ Up to 50 operation records live in the current Host process. A boot id is
134
+ embedded in every operation id, so a client never mistakes a stale browser
135
+ record for a task belonging to the replacement process.
136
+
137
+ ## Roll back
138
+
139
+ ```http
140
+ POST /dsh-crate/api/v1/rollback
141
+ Content-Type: application/json
142
+
143
+ { "operationId": "<id>" }
144
+ ```
145
+
146
+ Rollback is intentionally capability- and operation-scoped. It is available
147
+ only when the Market's compatibility verification retained a recovery point;
148
+ a later mutation may supersede it. The normalized result is written back to
149
+ the same operation record.
150
+
151
+ ## Restart
152
+
153
+ ```http
154
+ POST /dsh-crate/api/v1/restart
155
+ Content-Type: application/json
156
+
157
+ {}
158
+ ```
159
+
160
+ This preserves the Market's stricter restart guard: direct loopback,
161
+ same-origin, no forwarding headers, no package mutation in progress, and a Host
162
+ whose lifecycle is not owned by Desktop or a supervisor. Clients must feature
163
+ detect it; they must not invent an alternative process-control path.
164
+
165
+ ## Rendering the market's panel elsewhere (client-side)
166
+
167
+ A host shell that wants the market inside its own container — rather than in
168
+ the settings page — reads the client service this package publishes:
169
+
170
+ ```ts
171
+ const market = ctx.reflect.get('market')
172
+ const element = market.render({ preferredSubsectionId: 'installed' })
173
+ ```
174
+
175
+ `render()` returns the market's own panel wrapped in its error boundary, as a
176
+ React element. Same page, same React instance: this package's client bundle
177
+ resolves react through the host's module table, so the element mounts
178
+ anywhere in that tree.
179
+
180
+ | member | |
181
+ |---|---|
182
+ | `version` | `1` |
183
+ | `render(props?)` | the panel element; `preferredSubsectionId` is optional |
184
+ | `setSettingsVisible(visible)` | register or retract the market's own `settings.section` entry |
185
+ | `settingsVisible()` | whether that entry is registered right now |
186
+
187
+ The user's own entry switches (#1015) are ANDed with this control: a host's
188
+ `setSettingsVisible(true)` cannot override an entry the user turned off, and
189
+ the user cannot turn on an entry the host hides. `settingsVisible()` reports
190
+ the resulting registration, not the host's last request.
191
+
192
+ `ctx.provide(name, value)` and `ctx.reflect.provide(name, value)` are the
193
+ same call — cordis's `Service.provide` delegates to the reflect layer — so
194
+ either idiom reaches this service.
195
+
196
+ What `render()` is **not**: a way to rearrange the market. It hands over the
197
+ whole panel, chrome included. Cutting the market into host-fillable regions
198
+ is a different design, and one host asking is not yet evidence that it fits
199
+ anyone else.
200
+
201
+ ## Compatibility policy
202
+
203
+ - New optional response fields may be added within v1.
204
+ - Existing v1 fields and meanings are not repurposed.
205
+ - A breaking change uses a new path and schema version.
206
+ - When discovery is unavailable, plugin UIs should fall back to opening the
207
+ Market rather than calling legacy `/dsh-crate/*` mutation routes directly.
@@ -0,0 +1,37 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-labelledby="t">
2
+ <title id="t">crate</title>
3
+ <!-- 品牌标记:四个方块,右上那一块会从外侧飞进来落位。
4
+ 波浪按对角线依次变暗,飞块同时参与波浪,节奏与上游 dsh-market 一致。 -->
5
+ <style>
6
+ .cell{ animation: dshmWave 2.8s cubic-bezier(.4,0,.2,1) infinite; animation-delay: calc(var(--w) * 200ms); }
7
+ .plug{
8
+ transform-box: fill-box;
9
+ transform-origin: 50% 50%;
10
+ animation:
11
+ dshmWave 2.8s cubic-bezier(.4,0,.2,1) 200ms infinite,
12
+ dshmPlug 2.8s cubic-bezier(.4,0,.2,1) infinite;
13
+ }
14
+ @keyframes dshmWave{
15
+ 0%,100%{ opacity: 1; }
16
+ 6%{ opacity: .5; }
17
+ 16%{ opacity: 1; }
18
+ }
19
+ @keyframes dshmPlug{
20
+ 0%,8%{ transform: translate(12px,-12px) rotate(9deg); }
21
+ 22%{ transform: translate(-1px,1px) rotate(0deg); }
22
+ 30%,62%{ transform: translate(0,0) rotate(0deg); }
23
+ 76%,100%{ transform: translate(12px,-12px) rotate(9deg); }
24
+ }
25
+ @media (prefers-reduced-motion: reduce){
26
+ .cell,.plug{ animation: none; }
27
+ }
28
+ </style>
29
+ <rect width="128" height="128" rx="28" fill="#f6f2ea"/>
30
+ <!-- 四格整体缩到 90%:飞块位移 12px 时外角仍留在圆角底板内。 -->
31
+ <g fill="#2b2620" transform="translate(6.4 6.4) scale(0.9)">
32
+ <rect class="cell" style="--w:0" x="16" y="16" width="44" height="44" rx="7"/>
33
+ <rect class="cell" style="--w:1" x="16" y="68" width="44" height="44" rx="7"/>
34
+ <rect class="cell" style="--w:2" x="68" y="68" width="44" height="44" rx="7"/>
35
+ <rect class="plug" x="68" y="16" width="44" height="44" rx="7"/>
36
+ </g>
37
+ </svg>