@trebired/code-server-kit 0.3.0 → 1.1.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.
- package/CHANGELOG.md +15 -0
- package/README.md +232 -188
- package/dist/diagnostics.d.ts +6 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +150 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/package-resolution.d.ts +3 -0
- package/dist/package-resolution.d.ts.map +1 -0
- package/dist/package-resolution.js +44 -0
- package/dist/package-resolution.js.map +1 -0
- package/dist/plan.d.ts +3 -2
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +95 -86
- package/dist/plan.js.map +1 -1
- package/dist/preparation.d.ts +5 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +175 -0
- package/dist/preparation.js.map +1 -0
- package/dist/profile.d.ts +5 -2
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +122 -1
- package/dist/profile.js.map +1 -1
- package/dist/proxy.d.ts +4 -2
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +62 -1
- package/dist/proxy.js.map +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +44 -29
- package/dist/resolve.js.map +1 -1
- package/dist/session.d.ts +3 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +427 -533
- package/dist/session.js.map +1 -1
- package/dist/spec.d.ts +3 -3
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js +2 -33
- package/dist/spec.js.map +1 -1
- package/dist/systemd.d.ts +5 -2
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +57 -6
- package/dist/systemd.js.map +1 -1
- package/dist/types.d.ts +218 -68
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
- nothing yet
|
|
6
6
|
|
|
7
|
+
## 1.1.0
|
|
8
|
+
|
|
9
|
+
- make the bundled `code-server` dependency the default resolution target
|
|
10
|
+
- centralize package-resolution logic so preparation and installation discovery stay consistent
|
|
11
|
+
- add coverage and documentation for single-package host integration without a direct `code-server` dependency
|
|
12
|
+
|
|
13
|
+
## 1.0.0
|
|
14
|
+
|
|
15
|
+
- expand the package from a session helper into a fuller generic `code-server` integration layer
|
|
16
|
+
- add package preparation status and auto-repair helpers for the installed `code-server` dependency
|
|
17
|
+
- add richer integration planning, diagnostics normalization, redaction, and proxy websocket helpers
|
|
18
|
+
- add profile snapshot and deduplicated persistence helpers
|
|
19
|
+
- strengthen session lifecycle ownership with inflight dedup, richer status metadata, and persisted diagnostics
|
|
20
|
+
- expand systemd helpers with restart, journal summarization, and structured failure extraction
|
|
21
|
+
|
|
7
22
|
## 0.3.0
|
|
8
23
|
|
|
9
24
|
- expand the package from launch planning into a full generic `code-server` session runtime
|
package/README.md
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
1
|
# @trebired/code-server-kit
|
|
2
2
|
|
|
3
|
-
Framework-agnostic `code-server`
|
|
3
|
+
Framework-agnostic `code-server` integration layer for Node.js applications.
|
|
4
4
|
|
|
5
|
-
`@trebired/code-server-kit` is the generic Trebired package for owning the
|
|
5
|
+
`@trebired/code-server-kit` is the generic Trebired package for owning the real `code-server` integration lifecycle on Linux-first hosts:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- package preparation and bootstrap repair
|
|
8
|
+
- installation and support-root resolution
|
|
9
|
+
- launch and sandbox path planning
|
|
10
|
+
- direct and transient systemd launching
|
|
11
|
+
- session reuse, restart, stop, and status refresh
|
|
12
|
+
- startup diagnostics and redaction
|
|
13
|
+
- allowlisted profile restore and persistence
|
|
14
|
+
- proxy-facing helpers for forwarded and websocket headers
|
|
13
15
|
|
|
14
|
-
The package stays generic on purpose. It does not know about products, repositories, organizations,
|
|
16
|
+
The package stays generic on purpose. It does not know about products, repositories, organizations, routes, or app-specific filesystem conventions.
|
|
15
17
|
|
|
16
18
|
## Install
|
|
17
19
|
|
|
18
20
|
Runtime target: Node.js 22+ on Linux first.
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
|
-
npm install @trebired/code-server-kit
|
|
23
|
+
npm install @trebired/code-server-kit
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
`code-server` is installed as a normal dependency of this package. A host application only needs a separate direct `code-server` dependency when it intentionally wants to override how resolution happens.
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
By default, the package resolves and prepares its own bundled `code-server`. A host does not need to pass `resolveFrom` just to make normal session startup work.
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
- `stateRoot`
|
|
30
|
-
- `workspacePath`
|
|
31
|
-
- `trustedOrigins`
|
|
32
|
-
- `launchStrategy`
|
|
33
|
-
- systemd `scope` when using systemd
|
|
34
|
-
- optional profile roots
|
|
35
|
-
- optional logging and policy hooks
|
|
30
|
+
## Preferred Flow
|
|
36
31
|
|
|
37
|
-
The
|
|
32
|
+
The preferred host integration flow is now:
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- runtime profile directory defaults
|
|
43
|
-
- direct launch vs systemd launch translation
|
|
44
|
-
- readiness probing
|
|
45
|
-
- session reuse checks
|
|
46
|
-
- session metadata persistence
|
|
47
|
-
- startup diagnostics normalization
|
|
48
|
-
|
|
49
|
-
## Quick Start
|
|
34
|
+
1. Create a session manager.
|
|
35
|
+
2. Start a session with `sessionKey`, `stateRoot`, `workspacePath`, and trusted origins.
|
|
36
|
+
3. Let the package prepare `code-server`, restore profile data, choose launch mechanics, supervise readiness, and persist diagnostics.
|
|
50
37
|
|
|
51
38
|
```ts
|
|
52
39
|
import {
|
|
@@ -58,7 +45,6 @@ const sessions = createCodeServerSessionManager({
|
|
|
58
45
|
});
|
|
59
46
|
|
|
60
47
|
const started = await sessions.start({
|
|
61
|
-
launchStrategy: "direct",
|
|
62
48
|
sessionKey: "workspace-42",
|
|
63
49
|
stateRoot: "/srv/code-server-state",
|
|
64
50
|
trustedOrigins: [
|
|
@@ -82,11 +68,41 @@ await sessions.stop({
|
|
|
82
68
|
});
|
|
83
69
|
```
|
|
84
70
|
|
|
85
|
-
|
|
71
|
+
The host application only needs a separate direct `code-server` dependency for explicit override scenarios, such as testing against a different installation root or intentionally pinning resolution outside `@trebired/code-server-kit`.
|
|
72
|
+
|
|
73
|
+
## What The Package Owns
|
|
74
|
+
|
|
75
|
+
High-level APIs now own generic mechanics that host apps previously had to rebuild:
|
|
76
|
+
|
|
77
|
+
- checking whether the installed `code-server` package is fully prepared
|
|
78
|
+
- running the package-owned bootstrap script when preparation is repairable
|
|
79
|
+
- resolving the true entrypoint and support root
|
|
80
|
+
- deriving support-tree read-only bind suggestions
|
|
81
|
+
- deciding `node <entry.js>` vs direct execution
|
|
82
|
+
- preparing profile directories and syncing only allowlisted items
|
|
83
|
+
- handling missing optional native watchdog support with a non-fatal fallback mode
|
|
84
|
+
- deduplicating concurrent starts for the same `sessionKey`
|
|
85
|
+
- reusing healthy sessions when the effective spec still matches
|
|
86
|
+
- invalidating stale sessions and restarting cleanly when the spec changes
|
|
87
|
+
- collecting and sanitizing startup diagnostics
|
|
88
|
+
- translating launch plans into transient systemd unit arguments
|
|
89
|
+
|
|
90
|
+
Host applications mostly provide:
|
|
91
|
+
|
|
92
|
+
- `sessionKey`
|
|
93
|
+
- `stateRoot`
|
|
94
|
+
- `workspacePath`
|
|
95
|
+
- `trustedOrigins`
|
|
96
|
+
- `launchStrategy`
|
|
97
|
+
- systemd `scope` when using systemd
|
|
98
|
+
- optional profile and sanitization policy
|
|
99
|
+
- optional logging
|
|
100
|
+
|
|
101
|
+
## Main High-Level APIs
|
|
86
102
|
|
|
87
103
|
### `createCodeServerSessionManager(options?)`
|
|
88
104
|
|
|
89
|
-
Creates the main
|
|
105
|
+
Creates the main lifecycle object.
|
|
90
106
|
|
|
91
107
|
Manager methods:
|
|
92
108
|
|
|
@@ -98,120 +114,81 @@ Manager methods:
|
|
|
98
114
|
|
|
99
115
|
### `startCodeServerSession(options)`
|
|
100
116
|
|
|
101
|
-
One-shot helper
|
|
102
|
-
|
|
103
|
-
Lifecycle-managed session APIs require:
|
|
104
|
-
|
|
105
|
-
- `sessionKey`
|
|
106
|
-
- `stateRoot`
|
|
117
|
+
One-shot helper around the session manager.
|
|
107
118
|
|
|
108
119
|
Defaults:
|
|
109
120
|
|
|
110
121
|
- `launchStrategy` defaults to `"direct"`
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Stops a direct child process or a systemd transient unit using the stored session metadata. If profile persistence is configured, the package persists allowlisted profile items after stop.
|
|
118
|
-
|
|
119
|
-
### `restartCodeServerSession(options)`
|
|
120
|
-
|
|
121
|
-
Runs stop then start with the same session request shape.
|
|
122
|
+
- preparation defaults to auto-ensure
|
|
123
|
+
- exact-spec inflight starts join each other
|
|
124
|
+
- conflicting inflight starts fail with a structured conflict error
|
|
125
|
+
- profile restore defaults to `"if-missing-or-empty"`
|
|
126
|
+
- profile persist defaults to `"if-changed"`
|
|
122
127
|
|
|
123
128
|
### `getCodeServerSessionStatus(options)`
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### `readCodeServerSessionDiagnostics(options)`
|
|
130
|
+
Returns a refreshed status object with:
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
- `state`
|
|
133
|
+
- `health`
|
|
134
|
+
- `ready`
|
|
135
|
+
- `preparation`
|
|
136
|
+
- `watchdogMode`
|
|
137
|
+
- `lastStartSummary`
|
|
138
|
+
- `sanitizedDiagnostics`
|
|
130
139
|
|
|
131
|
-
|
|
140
|
+
### `readCodeServerSessionDiagnostics(options)`
|
|
132
141
|
|
|
133
|
-
|
|
142
|
+
Reads the persisted diagnostics snapshot under:
|
|
134
143
|
|
|
135
144
|
- `<stateRoot>/sessions/<safe-session-key>/session.json`
|
|
136
145
|
- `<stateRoot>/sessions/<safe-session-key>/diagnostics.json`
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- `state`
|
|
141
|
-
- `launchStrategy`
|
|
142
|
-
- `specHash`
|
|
143
|
-
- `bindAddr`
|
|
144
|
-
- `port`
|
|
145
|
-
- `userDataDir`
|
|
146
|
-
- `extensionsDir`
|
|
147
|
-
- `workspacePath`
|
|
148
|
-
- `pid` for direct launches
|
|
149
|
-
- `unitName` and `systemdScope` for systemd launches
|
|
150
|
-
- timestamps and normalized failure details
|
|
151
|
-
|
|
152
|
-
This disk-backed record is what allows the package to reuse, stop, restart, and inspect sessions across calls.
|
|
147
|
+
## Preparation APIs
|
|
153
148
|
|
|
154
|
-
|
|
149
|
+
### `getCodeServerPreparationStatus(options?)`
|
|
155
150
|
|
|
156
|
-
|
|
151
|
+
Checks whether the installed package looks ready to run and reports:
|
|
157
152
|
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
153
|
+
- package root
|
|
154
|
+
- support root
|
|
155
|
+
- bootstrap script path
|
|
156
|
+
- preparation state
|
|
157
|
+
- issues
|
|
158
|
+
- watchdog mode
|
|
164
159
|
|
|
165
|
-
|
|
160
|
+
### `ensureCodeServerPrepared(options?)`
|
|
166
161
|
|
|
167
|
-
- the
|
|
168
|
-
- the spec hash matches exactly
|
|
169
|
-
- the backing process or unit still exists
|
|
170
|
-
- the target port becomes ready again
|
|
162
|
+
Runs the package-owned bootstrap script when the installation is repairable.
|
|
171
163
|
|
|
172
|
-
|
|
164
|
+
Use this explicitly when a host wants a preflight step. Otherwise the session manager runs it automatically.
|
|
173
165
|
|
|
174
166
|
## Launch Planning APIs
|
|
175
167
|
|
|
176
|
-
The lower-level
|
|
168
|
+
The lower-level planning APIs still exist for hosts that want custom execution layers.
|
|
177
169
|
|
|
178
|
-
### `
|
|
170
|
+
### `createCodeServerIntegrationPlan(options)`
|
|
179
171
|
|
|
180
|
-
|
|
172
|
+
This is the preferred lower-level planning API. It returns:
|
|
181
173
|
|
|
182
|
-
- `
|
|
183
|
-
- `
|
|
184
|
-
- `
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
174
|
+
- final `command` and `args`
|
|
175
|
+
- final `bindings`
|
|
176
|
+
- `cwd` and `env`
|
|
177
|
+
- preparation status
|
|
178
|
+
- support-root bind suggestions
|
|
179
|
+
- readable and writable path suggestions
|
|
180
|
+
- host-visible and sandbox-visible path lists
|
|
181
|
+
- translated path pairs
|
|
189
182
|
|
|
190
183
|
### `createCodeServerLaunchPlan(options)`
|
|
191
184
|
|
|
192
|
-
|
|
185
|
+
Compatibility-friendly alias for callers that still want the previous naming. It now routes through the richer integration-plan path.
|
|
193
186
|
|
|
194
|
-
|
|
195
|
-
- `args`
|
|
196
|
-
- `cwd`
|
|
197
|
-
- `env`
|
|
198
|
-
- `entryKind`
|
|
199
|
-
- `launchMode`
|
|
200
|
-
- `installation`
|
|
201
|
-
- `bindAddr`
|
|
202
|
-
- `host`
|
|
203
|
-
- `port`
|
|
204
|
-
- `supportRoot`
|
|
205
|
-
- `supportBindings`
|
|
206
|
-
- `recommendedReadablePaths`
|
|
207
|
-
- `recommendedWritablePaths`
|
|
208
|
-
- `userDataDir`
|
|
209
|
-
- `extensionsDir`
|
|
210
|
-
- `workspacePath`
|
|
187
|
+
The returned plan already includes final `bindings`, `recommendedReadablePaths`, `recommendedWritablePaths`, and `translatedPaths`, so a host does not need to rebuild support-tree mount decisions itself.
|
|
211
188
|
|
|
212
189
|
### `createCodeServerLaunchSpec(plan)`
|
|
213
190
|
|
|
214
|
-
Converts the
|
|
191
|
+
Converts the plan into a smaller execution-oriented shape:
|
|
215
192
|
|
|
216
193
|
- `command`
|
|
217
194
|
- `args`
|
|
@@ -221,11 +198,9 @@ Converts the launch plan into an execution-oriented shape:
|
|
|
221
198
|
- `readablePaths`
|
|
222
199
|
- `writablePaths`
|
|
223
200
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
## Direct Launch
|
|
201
|
+
## Direct And Systemd Launching
|
|
227
202
|
|
|
228
|
-
|
|
203
|
+
### Direct
|
|
229
204
|
|
|
230
205
|
```ts
|
|
231
206
|
import {
|
|
@@ -248,42 +223,111 @@ await waitForCodeServerReady({
|
|
|
248
223
|
});
|
|
249
224
|
```
|
|
250
225
|
|
|
251
|
-
|
|
226
|
+
### Session Diagnostics
|
|
252
227
|
|
|
253
|
-
|
|
228
|
+
```ts
|
|
229
|
+
const sessions = createCodeServerSessionManager();
|
|
254
230
|
|
|
255
|
-
|
|
231
|
+
const started = await sessions.start({
|
|
232
|
+
sanitizer: {
|
|
233
|
+
pathPrefixes: ["/srv"],
|
|
234
|
+
},
|
|
235
|
+
sessionKey: "workspace-42",
|
|
236
|
+
stateRoot: "/srv/code-server-state",
|
|
237
|
+
trustedOrigins: ["https://app.example.com"],
|
|
238
|
+
workspacePath: "/srv/workspaces/demo",
|
|
239
|
+
});
|
|
256
240
|
|
|
257
|
-
|
|
241
|
+
const diagnostics = await sessions.readDiagnostics({
|
|
242
|
+
sanitizer: {
|
|
243
|
+
pathPrefixes: ["/srv"],
|
|
244
|
+
},
|
|
245
|
+
sessionKey: "workspace-42",
|
|
246
|
+
stateRoot: "/srv/code-server-state",
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
console.log(started.status.lastStartSummary);
|
|
250
|
+
console.log(diagnostics?.sanitized?.summary);
|
|
251
|
+
```
|
|
258
252
|
|
|
259
|
-
|
|
253
|
+
### Systemd
|
|
260
254
|
|
|
261
|
-
|
|
255
|
+
Linux-first transient systemd support is built into the same package and stays explicit.
|
|
262
256
|
|
|
263
257
|
Relevant APIs:
|
|
264
258
|
|
|
265
259
|
- `launchCodeServerWithSystemd(options)`
|
|
260
|
+
- `restartCodeServerSystemdUnit(options)`
|
|
266
261
|
- `stopCodeServerSystemdUnit(options)`
|
|
267
262
|
- `readCodeServerSystemdStatus(options)`
|
|
268
263
|
- `readCodeServerSystemdJournal(options)`
|
|
264
|
+
- `summarizeCodeServerSystemdJournal(options)`
|
|
265
|
+
- `extractCodeServerSystemdFailure(options)`
|
|
269
266
|
- `createCodeServerSystemdLaunchCommand(options)`
|
|
270
|
-
- `buildSystemdPathProperties(spec)`
|
|
271
267
|
|
|
272
|
-
|
|
268
|
+
`systemd` launches require an explicit scope:
|
|
269
|
+
|
|
270
|
+
- `scope: "user"`
|
|
271
|
+
- `scope: "system"`
|
|
272
|
+
|
|
273
|
+
There is no package default.
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
const sessions = createCodeServerSessionManager();
|
|
277
|
+
|
|
278
|
+
const started = await sessions.start({
|
|
279
|
+
launchStrategy: "systemd",
|
|
280
|
+
sessionKey: "workspace-42",
|
|
281
|
+
stateRoot: "/srv/code-server-state",
|
|
282
|
+
systemd: {
|
|
283
|
+
scope: "user",
|
|
284
|
+
},
|
|
285
|
+
trustedOrigins: ["https://app.example.com"],
|
|
286
|
+
workspacePath: "/srv/workspaces/demo",
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
console.log(started.status.unitName);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Diagnostics And Redaction
|
|
293
|
+
|
|
294
|
+
### `collectCodeServerStartupDiagnostics(options)`
|
|
295
|
+
|
|
296
|
+
Builds a structured diagnostic object with:
|
|
297
|
+
|
|
298
|
+
- category
|
|
299
|
+
- code
|
|
300
|
+
- summary
|
|
301
|
+
- machine-readable details
|
|
302
|
+
- launch strategy
|
|
303
|
+
- watchdog mode
|
|
304
|
+
- stderr and stdout tails
|
|
305
|
+
- systemd journal summary
|
|
306
|
+
|
|
307
|
+
Supported normalized categories include:
|
|
308
|
+
|
|
309
|
+
- `startup_timeout`
|
|
310
|
+
- `process_exited_before_ready`
|
|
311
|
+
- `systemd_launch_failed`
|
|
312
|
+
- `systemd_unit_failed`
|
|
313
|
+
- `entrypoint_resolution_failed`
|
|
314
|
+
- `missing_runtime_dependency`
|
|
315
|
+
- `preparation_failed`
|
|
316
|
+
- `invalid_configuration`
|
|
317
|
+
|
|
318
|
+
### `sanitizeCodeServerDiagnostics(diagnostics, options)`
|
|
319
|
+
|
|
320
|
+
Supports:
|
|
273
321
|
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
277
|
-
- `BindPaths`
|
|
278
|
-
- `BindReadOnlyPaths`
|
|
279
|
-
- `ReadOnlyPaths`
|
|
280
|
-
- `ReadWritePaths`
|
|
322
|
+
- path-prefix redaction
|
|
323
|
+
- exact-value redaction
|
|
324
|
+
- a custom replacer hook
|
|
281
325
|
|
|
282
|
-
|
|
326
|
+
The package only sanitizes when a host asks for it.
|
|
283
327
|
|
|
284
|
-
## Profile
|
|
328
|
+
## Profile Lifecycle
|
|
285
329
|
|
|
286
|
-
Profile sync stays allowlist-based
|
|
330
|
+
Profile sync stays allowlist-based instead of copying the whole runtime tree.
|
|
287
331
|
|
|
288
332
|
Supported items:
|
|
289
333
|
|
|
@@ -293,56 +337,52 @@ Supported items:
|
|
|
293
337
|
- `snippets`
|
|
294
338
|
- `extensions`
|
|
295
339
|
|
|
296
|
-
Lower-level
|
|
340
|
+
Lower-level APIs:
|
|
297
341
|
|
|
298
342
|
- `createCodeServerProfileSyncPlan(options)`
|
|
299
343
|
- `syncCodeServerProfile(options)`
|
|
300
|
-
- `
|
|
344
|
+
- `readCodeServerProfileSnapshot(options)`
|
|
345
|
+
- `readCodeServerProfileSignature(options)`
|
|
346
|
+
- `persistCodeServerProfileIfChanged(options)`
|
|
301
347
|
|
|
302
|
-
|
|
348
|
+
Session-manager integration now handles:
|
|
303
349
|
|
|
304
|
-
- restore
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
|
|
308
|
-
Example:
|
|
350
|
+
- restore only when runtime profile data is missing or empty by default
|
|
351
|
+
- persistence only when the allowlisted signature changed by default
|
|
352
|
+
- optional extension snapshotting in the signature
|
|
309
353
|
|
|
310
354
|
```ts
|
|
355
|
+
const sessions = createCodeServerSessionManager();
|
|
356
|
+
|
|
311
357
|
await sessions.start({
|
|
312
358
|
profile: {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
359
|
+
persistTo: "/srv/code-server-profiles/workspace-42",
|
|
360
|
+
restoreFrom: "/srv/code-server-profiles/workspace-42",
|
|
361
|
+
snapshotExtensions: true,
|
|
316
362
|
},
|
|
317
363
|
sessionKey: "workspace-42",
|
|
318
364
|
stateRoot: "/srv/code-server-state",
|
|
365
|
+
trustedOrigins: ["https://app.example.com"],
|
|
319
366
|
workspacePath: "/srv/workspaces/demo",
|
|
320
367
|
});
|
|
321
368
|
```
|
|
322
369
|
|
|
323
|
-
##
|
|
324
|
-
|
|
325
|
-
### `waitForCodeServerReady(options)`
|
|
370
|
+
## Proxy Helpers
|
|
326
371
|
|
|
327
|
-
|
|
372
|
+
Generic proxy-facing helpers now include:
|
|
328
373
|
|
|
329
|
-
-
|
|
330
|
-
-
|
|
331
|
-
-
|
|
332
|
-
|
|
333
|
-
The lifecycle manager builds on this and adds strategy-aware supervision:
|
|
374
|
+
- `buildForwardedHeaders(options)`
|
|
375
|
+
- `buildCodeServerWebSocketHeaders(options)`
|
|
376
|
+
- `isCodeServerHtmlResponse(options)`
|
|
377
|
+
- `classifyCodeServerProxyFailure(options)`
|
|
334
378
|
|
|
335
|
-
|
|
336
|
-
- systemd state probing
|
|
337
|
-
- systemd journal collection
|
|
338
|
-
- normalized startup failure metadata
|
|
379
|
+
These helpers stay framework-agnostic and do not add product-specific route rewriting.
|
|
339
380
|
|
|
340
381
|
## Structured Errors
|
|
341
382
|
|
|
342
|
-
The package throws structured error classes so callers can log and branch on them reliably.
|
|
343
|
-
|
|
344
383
|
Examples:
|
|
345
384
|
|
|
385
|
+
- `CodeServerPreparationError`
|
|
346
386
|
- `CodeServerInvalidConfigurationError`
|
|
347
387
|
- `CodeServerInstallationResolutionError`
|
|
348
388
|
- `CodeServerEntrypointResolutionError`
|
|
@@ -357,39 +397,43 @@ Examples:
|
|
|
357
397
|
- `CodeServerSystemdStatusError`
|
|
358
398
|
- `CodeServerSystemdJournalError`
|
|
359
399
|
|
|
360
|
-
Use `normalizeCodeServerStartupFailure(error)` when you want one
|
|
361
|
-
|
|
362
|
-
## Reverse Proxy Helpers
|
|
363
|
-
|
|
364
|
-
The package also includes a few small generic embedding helpers:
|
|
400
|
+
Use `normalizeCodeServerStartupFailure(error)` when you want one consistent structured startup-failure payload.
|
|
365
401
|
|
|
366
|
-
|
|
367
|
-
- `normalizeTrustedOrigin(value)`
|
|
368
|
-
- `isCodeServerHtmlResponse(options)`
|
|
402
|
+
## Migration Note
|
|
369
403
|
|
|
370
|
-
|
|
404
|
+
Existing host apps should delete generic glue for:
|
|
371
405
|
|
|
372
|
-
|
|
406
|
+
- reading from `node_modules/code-server/...` directly
|
|
407
|
+
- running `code-server` postinstall repair themselves
|
|
408
|
+
- discovering support roots or remapping entrypoints manually
|
|
409
|
+
- building support-tree read-only bind lists manually
|
|
410
|
+
- translating host paths into sandbox-visible `code-server` paths
|
|
411
|
+
- deduplicating concurrent starts for the same session key
|
|
412
|
+
- comparing profile state before persisting
|
|
413
|
+
- parsing raw startup output into user-facing summaries
|
|
414
|
+
- building websocket proxy headers and classifying common upstream failures
|
|
373
415
|
|
|
374
|
-
|
|
416
|
+
Prefer:
|
|
375
417
|
|
|
376
|
-
- `
|
|
377
|
-
- `
|
|
418
|
+
- `createCodeServerSessionManager()`
|
|
419
|
+
- `startCodeServerSession()`
|
|
378
420
|
|
|
379
|
-
|
|
421
|
+
Keep low-level APIs only when you truly need a custom execution layer.
|
|
380
422
|
|
|
381
|
-
## `code-server
|
|
423
|
+
## Direct `code-server` Dependency
|
|
382
424
|
|
|
383
|
-
|
|
425
|
+
None by default.
|
|
384
426
|
|
|
385
|
-
-
|
|
386
|
-
- you want the runtime to own the exact installed `code-server`
|
|
387
|
-
- you want installation resolution to succeed without extra host setup
|
|
427
|
+
Host applications only need a separate direct `code-server` dependency when they intentionally override resolution behavior, such as:
|
|
388
428
|
|
|
389
|
-
|
|
429
|
+
- testing against a different installation root
|
|
430
|
+
- pinning a different package copy outside `@trebired/code-server-kit`
|
|
431
|
+
- using custom resolution during advanced development workflows
|
|
390
432
|
|
|
391
|
-
|
|
392
|
-
- the final host application should choose the `code-server` version
|
|
393
|
-
- you want to avoid forcing duplicate `code-server` installs across wrappers
|
|
433
|
+
## Intentionally Deferred
|
|
394
434
|
|
|
395
|
-
|
|
435
|
+
- non-Linux lifecycle orchestration
|
|
436
|
+
- container runtime wrappers
|
|
437
|
+
- host-specific sandbox policy
|
|
438
|
+
- Windows and macOS service-management behavior
|
|
439
|
+
- a stronger watchdog strategy than preparation plus disabled-fallback classification, unless future `code-server` versions expose a cleaner supported switch
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CodeServerSanitizedDiagnostics, CodeServerSanitizerOptions, CodeServerStartupDiagnostics, CollectCodeServerStartupDiagnosticsOptions, NormalizedCodeServerStartupFailure } from "./types.js";
|
|
2
|
+
declare function collectCodeServerStartupDiagnostics(options?: CollectCodeServerStartupDiagnosticsOptions): CodeServerStartupDiagnostics;
|
|
3
|
+
declare function sanitizeCodeServerDiagnostics(diagnostics: Pick<CodeServerStartupDiagnostics, "details" | "summary">, options: CodeServerSanitizerOptions): CodeServerSanitizedDiagnostics;
|
|
4
|
+
declare function normalizeCodeServerStartupFailure(error: unknown, options?: Omit<CollectCodeServerStartupDiagnosticsOptions, "error">): NormalizedCodeServerStartupFailure;
|
|
5
|
+
export { collectCodeServerStartupDiagnostics, normalizeCodeServerStartupFailure, sanitizeCodeServerDiagnostics, };
|
|
6
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,EAE5B,0CAA0C,EAC1C,kCAAkC,EACnC,MAAM,YAAY,CAAC;AAEpB,iBAAS,mCAAmC,CAAC,OAAO,GAAE,0CAA+C,GAAG,4BAA4B,CAgCnI;AAED,iBAAS,6BAA6B,CACpC,WAAW,EAAE,IAAI,CAAC,4BAA4B,EAAE,SAAS,GAAG,SAAS,CAAC,EACtE,OAAO,EAAE,0BAA0B,GAClC,8BAA8B,CAOhC;AAED,iBAAS,iCAAiC,CACxC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,0CAA0C,EAAE,OAAO,CAAM,GACtE,kCAAkC,CAYpC;AAoHD,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,6BAA6B,GAC9B,CAAC"}
|