@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +232 -188
  3. package/dist/diagnostics.d.ts +6 -0
  4. package/dist/diagnostics.d.ts.map +1 -0
  5. package/dist/diagnostics.js +150 -0
  6. package/dist/diagnostics.js.map +1 -0
  7. package/dist/errors.d.ts +5 -2
  8. package/dist/errors.d.ts.map +1 -1
  9. package/dist/errors.js +7 -1
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +9 -7
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +8 -6
  14. package/dist/index.js.map +1 -1
  15. package/dist/package-resolution.d.ts +3 -0
  16. package/dist/package-resolution.d.ts.map +1 -0
  17. package/dist/package-resolution.js +44 -0
  18. package/dist/package-resolution.js.map +1 -0
  19. package/dist/plan.d.ts +3 -2
  20. package/dist/plan.d.ts.map +1 -1
  21. package/dist/plan.js +95 -86
  22. package/dist/plan.js.map +1 -1
  23. package/dist/preparation.d.ts +5 -0
  24. package/dist/preparation.d.ts.map +1 -0
  25. package/dist/preparation.js +175 -0
  26. package/dist/preparation.js.map +1 -0
  27. package/dist/profile.d.ts +5 -2
  28. package/dist/profile.d.ts.map +1 -1
  29. package/dist/profile.js +122 -1
  30. package/dist/profile.js.map +1 -1
  31. package/dist/proxy.d.ts +4 -2
  32. package/dist/proxy.d.ts.map +1 -1
  33. package/dist/proxy.js +62 -1
  34. package/dist/proxy.js.map +1 -1
  35. package/dist/resolve.d.ts.map +1 -1
  36. package/dist/resolve.js +44 -29
  37. package/dist/resolve.js.map +1 -1
  38. package/dist/session.d.ts +3 -3
  39. package/dist/session.d.ts.map +1 -1
  40. package/dist/session.js +427 -533
  41. package/dist/session.js.map +1 -1
  42. package/dist/spec.d.ts +3 -3
  43. package/dist/spec.d.ts.map +1 -1
  44. package/dist/spec.js +2 -33
  45. package/dist/spec.js.map +1 -1
  46. package/dist/systemd.d.ts +5 -2
  47. package/dist/systemd.d.ts.map +1 -1
  48. package/dist/systemd.js +57 -6
  49. package/dist/systemd.js.map +1 -1
  50. package/dist/types.d.ts +218 -68
  51. package/dist/types.d.ts.map +1 -1
  52. 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` session runtime for Node.js applications.
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 full `code-server` lifecycle on Linux-first hosts:
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
- - resolve the installed `code-server`
8
- - build launch plans and sandbox-friendly execution specs
9
- - restore and persist allowlisted profile data
10
- - launch directly or through transient systemd services
11
- - supervise readiness and startup failures
12
- - reuse, stop, restart, and inspect sessions with structured metadata
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, users, routes, or app-specific filesystem conventions.
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 code-server
23
+ npm install @trebired/code-server-kit
22
24
  ```
23
25
 
24
- ## What Host Apps Still Provide
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
- After the session runtime layer is in place, host applications mostly choose policy:
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
- - `sessionKey`
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 package owns the generic mechanics:
32
+ The preferred host integration flow is now:
38
33
 
39
- - installation resolution
40
- - entrypoint resolution
41
- - `node <entry.js>` vs direct executable launch
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
- ## Main Session APIs
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 high-level lifecycle object and wires logging through `@trebired/logger-adapter`.
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 that creates a manager and starts a session.
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
- - reuse defaults to exact normalized spec match
112
- - `dataRoot` defaults to `stateRoot/sessions/<sessionKey>/runtime`
113
- - systemd never defaults its scope
114
-
115
- ### `stopCodeServerSession(options)`
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
- Loads the package-owned session record and re-probes the live backing resource instead of trusting disk alone.
126
-
127
- ### `readCodeServerSessionDiagnostics(options)`
130
+ Returns a refreshed status object with:
128
131
 
129
- Reads the persisted diagnostics snapshot for a session.
132
+ - `state`
133
+ - `health`
134
+ - `ready`
135
+ - `preparation`
136
+ - `watchdogMode`
137
+ - `lastStartSummary`
138
+ - `sanitizedDiagnostics`
130
139
 
131
- ## Session Metadata
140
+ ### `readCodeServerSessionDiagnostics(options)`
132
141
 
133
- The package stores generic lifecycle metadata under:
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
- The session record tracks values such as:
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
- ## Reuse Model
149
+ ### `getCodeServerPreparationStatus(options?)`
155
150
 
156
- The package builds a normalized session spec from the effective launch plan plus lifecycle-relevant inputs such as:
151
+ Checks whether the installed package looks ready to run and reports:
157
152
 
158
- - launch strategy
159
- - workspace path
160
- - trusted origins
161
- - env overrides
162
- - profile restore and persist configuration
163
- - systemd scope and unit naming
153
+ - package root
154
+ - support root
155
+ - bootstrap script path
156
+ - preparation state
157
+ - issues
158
+ - watchdog mode
164
159
 
165
- That normalized spec is hashed and stored. Reuse only happens when:
160
+ ### `ensureCodeServerPrepared(options?)`
166
161
 
167
- - the same `sessionKey` is used
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
- If the hash changes, the package marks the old record stale, stops the old runtime when needed, and starts a fresh session.
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 launch planning APIs remain available for callers that want policy ownership while still avoiding `code-server` package-layout details.
168
+ The lower-level planning APIs still exist for hosts that want custom execution layers.
177
169
 
178
- ### `resolveCodeServerInstallation(options?)`
170
+ ### `createCodeServerIntegrationPlan(options)`
179
171
 
180
- Returns installation metadata:
172
+ This is the preferred lower-level planning API. It returns:
181
173
 
182
- - `packageRoot`
183
- - `packageJsonPath`
184
- - `entryPoint`
185
- - `entryRelativePath`
186
- - `entryKind`
187
- - `supportRoot`
188
- - `version`
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
- Returns a structured launch plan with:
185
+ Compatibility-friendly alias for callers that still want the previous naming. It now routes through the richer integration-plan path.
193
186
 
194
- - `command`
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 launch plan into an execution-oriented shape:
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
- This is useful when a host wants to feed the same plan into a container, custom sandbox, or generated unit file.
225
-
226
- ## Direct Launch
201
+ ## Direct And Systemd Launching
227
202
 
228
- Use the built-in child-process helper when you want a plain process owned by the current Node.js runtime.
203
+ ### Direct
229
204
 
230
205
  ```ts
231
206
  import {
@@ -248,42 +223,111 @@ await waitForCodeServerReady({
248
223
  });
249
224
  ```
250
225
 
251
- The lifecycle manager uses this same lower-level path internally for `launchStrategy: "direct"`.
226
+ ### Session Diagnostics
252
227
 
253
- ## Systemd Launch
228
+ ```ts
229
+ const sessions = createCodeServerSessionManager();
254
230
 
255
- Linux systemd support is built into the same package and stays explicit.
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
- Use `launchStrategy: "systemd"` only when you also provide:
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
- - `systemd.scope: "user"` or `"system"`
253
+ ### Systemd
260
254
 
261
- The package uses transient services through `systemd-run`, not scopes.
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
- The systemd translation layer derives:
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
- - `--unit`
275
- - `--working-directory`
276
- - `--setenv`
277
- - `BindPaths`
278
- - `BindReadOnlyPaths`
279
- - `ReadOnlyPaths`
280
- - `ReadWritePaths`
322
+ - path-prefix redaction
323
+ - exact-value redaction
324
+ - a custom replacer hook
281
325
 
282
- That means host applications do not need to rebuild transient unit arguments from raw launch-plan data themselves.
326
+ The package only sanitizes when a host asks for it.
283
327
 
284
- ## Profile Restore And Persist
328
+ ## Profile Lifecycle
285
329
 
286
- Profile sync stays allowlist-based rather than copying the entire runtime tree.
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 helpers:
340
+ Lower-level APIs:
297
341
 
298
342
  - `createCodeServerProfileSyncPlan(options)`
299
343
  - `syncCodeServerProfile(options)`
300
- - `resolveCodeServerProfilePathMap(overrides?)`
344
+ - `readCodeServerProfileSnapshot(options)`
345
+ - `readCodeServerProfileSignature(options)`
346
+ - `persistCodeServerProfileIfChanged(options)`
301
347
 
302
- Lifecycle integration:
348
+ Session-manager integration now handles:
303
349
 
304
- - restore before launch with `profile.restoreFrom`
305
- - persist after stop with `profile.persistTo`
306
- - skip missing or unreadable sources cleanly by default
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
- items: ["settings.json", "keybindings.json", "extensions"],
314
- persistTo: "/srv/profiles/demo",
315
- restoreFrom: "/srv/profiles/demo",
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
- ## Readiness And Failure Handling
324
-
325
- ### `waitForCodeServerReady(options)`
370
+ ## Proxy Helpers
326
371
 
327
- Waits for the TCP port to accept connections and can also:
372
+ Generic proxy-facing helpers now include:
328
373
 
329
- - fail on startup timeout
330
- - fail on direct-process early exit
331
- - fail on a caller-provided failure probe
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
- - direct-process stdout and stderr tails
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 tagged object shape for logs or API responses.
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
- - `buildForwardedHeaders(options)`
367
- - `normalizeTrustedOrigin(value)`
368
- - `isCodeServerHtmlResponse(options)`
402
+ ## Migration Note
369
403
 
370
- These helpers stay intentionally small. They do not add product-specific route rewriting.
404
+ Existing host apps should delete generic glue for:
371
405
 
372
- ## Logging
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
- High-level APIs accept:
416
+ Prefer:
375
417
 
376
- - `logger`
377
- - `loggerAdapter`
418
+ - `createCodeServerSessionManager()`
419
+ - `startCodeServerSession()`
378
420
 
379
- The package resolves those through `@trebired/logger-adapter`, matching the style used by other `@trebired/*` packages. `createCodeServerSessionManager()` also emits `logPackageInitialized()` on creation.
421
+ Keep low-level APIs only when you truly need a custom execution layer.
380
422
 
381
- ## `code-server`: Dependency vs Peer Dependency
423
+ ## Direct `code-server` Dependency
382
424
 
383
- Use `code-server` as a normal `dependency` when:
425
+ None by default.
384
426
 
385
- - this package is part of an application deployment
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
- Use `code-server` as a `peerDependency` in your own higher-level package when:
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
- - your package wraps `@trebired/code-server-kit`
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
- `@trebired/code-server-kit` itself depends on `code-server` because the generic runtime layer needs a predictable package to resolve.
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"}