@trebired/code-server-kit 0.2.0 → 1.0.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 +17 -0
  2. package/README.md +236 -218
  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 +23 -2
  8. package/dist/errors.d.ts.map +1 -1
  9. package/dist/errors.js +43 -1
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +11 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +10 -5
  14. package/dist/index.js.map +1 -1
  15. package/dist/logging.d.ts +5 -0
  16. package/dist/logging.d.ts.map +1 -0
  17. package/dist/logging.js +11 -0
  18. package/dist/logging.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 +68 -68
  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 +194 -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 +43 -1
  37. package/dist/resolve.js.map +1 -1
  38. package/dist/session.d.ts +11 -0
  39. package/dist/session.d.ts.map +1 -0
  40. package/dist/session.js +770 -0
  41. package/dist/session.js.map +1 -0
  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 +20 -0
  47. package/dist/systemd.d.ts.map +1 -0
  48. package/dist/systemd.js +305 -0
  49. package/dist/systemd.js.map +1 -0
  50. package/dist/types.d.ts +354 -7
  51. package/dist/types.d.ts.map +1 -1
  52. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  - nothing yet
6
6
 
7
+ ## 1.0.0
8
+
9
+ - expand the package from a session helper into a fuller generic `code-server` integration layer
10
+ - add package preparation status and auto-repair helpers for the installed `code-server` dependency
11
+ - add richer integration planning, diagnostics normalization, redaction, and proxy websocket helpers
12
+ - add profile snapshot and deduplicated persistence helpers
13
+ - strengthen session lifecycle ownership with inflight dedup, richer status metadata, and persisted diagnostics
14
+ - expand systemd helpers with restart, journal summarization, and structured failure extraction
15
+
16
+ ## 0.3.0
17
+
18
+ - expand the package from launch planning into a full generic `code-server` session runtime
19
+ - add session lifecycle APIs for start, stop, restart, status, diagnostics, and session-manager creation
20
+ - add Linux-first transient systemd helpers and launch-command builders
21
+ - add disk-backed session metadata, reuse checks, profile restore and persist hooks, and richer startup diagnostics
22
+ - add `@trebired/logger-adapter` support across the higher-level APIs
23
+
7
24
  ## 0.2.0
8
25
 
9
26
  - add `createCodeServerLaunchPlan()` as the main higher-level launch planning API
package/README.md CHANGED
@@ -1,186 +1,205 @@
1
1
  # @trebired/code-server-kit
2
2
 
3
- Framework-agnostic `code-server` integration helpers for Node.js applications.
3
+ Framework-agnostic `code-server` integration layer for Node.js applications.
4
4
 
5
- `@trebired/code-server-kit` gives host applications a typed, generic layer for resolving an installed `code-server`, building a complete launch plan, waiting for readiness, syncing selected profile data, and preparing the result for direct processes, systemd units, containers, or custom sandboxes.
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
- The package stays in one lane:
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
8
15
 
9
- - resolve the installed `code-server` package root and launch entrypoint
10
- - describe the final launch command, args, cwd, env, and path-access suggestions
11
- - expose structured errors that host apps can log and branch on
12
- - optionally spawn the process and wait for readiness
13
- - sync allowlisted profile data without copying a whole runtime tree
14
- - help reverse-proxy integrations with trusted-origin and forwarded-header helpers
15
-
16
- It does not try to be a `code-server` fork, a sandbox manager, a container runtime, or a product layer with app-specific routes and filesystem rules.
16
+ The package stays generic on purpose. It does not know about products, repositories, organizations, routes, or app-specific filesystem conventions.
17
17
 
18
18
  ## Install
19
19
 
20
20
  Runtime target: Node.js 22+ on Linux first.
21
21
 
22
22
  ```sh
23
- npm install @trebired/code-server-kit code-server
23
+ npm install @trebired/code-server-kit
24
24
  ```
25
25
 
26
- ## Quick Start
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.
27
+
28
+ ## Preferred Flow
29
+
30
+ The preferred host integration flow is now:
31
+
32
+ 1. Create a session manager.
33
+ 2. Start a session with `sessionKey`, `stateRoot`, `workspacePath`, and trusted origins.
34
+ 3. Let the package prepare `code-server`, restore profile data, choose launch mechanics, supervise readiness, and persist diagnostics.
27
35
 
28
36
  ```ts
29
37
  import {
30
- createCodeServerLaunchPlan,
31
- launchCodeServerProcess,
32
- waitForCodeServerReady,
38
+ createCodeServerSessionManager,
33
39
  } from "@trebired/code-server-kit";
34
40
 
35
- const plan = await createCodeServerLaunchPlan({
36
- dataRoot: "/srv/code-server/session-42",
37
- host: "127.0.0.1",
38
- port: 8080,
41
+ const sessions = createCodeServerSessionManager({
42
+ logger: console,
43
+ });
44
+
45
+ const started = await sessions.start({
46
+ sessionKey: "workspace-42",
47
+ stateRoot: "/srv/code-server-state",
39
48
  trustedOrigins: [
40
49
  "https://app.example.com",
41
50
  ],
42
51
  workspacePath: "/srv/workspaces/demo",
43
52
  });
44
53
 
45
- const handle = await launchCodeServerProcess({
46
- plan,
47
- stdout(text) {
48
- process.stdout.write(text);
49
- },
50
- stderr(text) {
51
- process.stderr.write(text);
52
- },
54
+ console.log(started.status.state, started.status.port);
55
+
56
+ const status = await sessions.getStatus({
57
+ sessionKey: "workspace-42",
58
+ stateRoot: "/srv/code-server-state",
53
59
  });
54
60
 
55
- await waitForCodeServerReady({
56
- host: plan.host,
57
- port: plan.port,
58
- process: handle,
59
- timeoutMs: 30_000,
61
+ console.log(status?.ready);
62
+
63
+ await sessions.stop({
64
+ sessionKey: "workspace-42",
65
+ stateRoot: "/srv/code-server-state",
60
66
  });
61
67
  ```
62
68
 
63
- ## Why The Launch Plan Exists
69
+ ## What The Package Owns
64
70
 
65
- Most host apps do not want to know where `code-server` put its real entry file, when to call `node <entry.js>` versus a direct executable, which package directories should be mounted read-only, or which runtime paths must stay writable.
71
+ High-level APIs now own generic mechanics that host apps previously had to rebuild:
66
72
 
67
- `createCodeServerLaunchPlan()` moves that generic integration work into one reusable contract so host apps can focus on policy instead:
73
+ - checking whether the installed `code-server` package is fully prepared
74
+ - running the package-owned bootstrap script when preparation is repairable
75
+ - resolving the true entrypoint and support root
76
+ - deriving support-tree read-only bind suggestions
77
+ - deciding `node <entry.js>` vs direct execution
78
+ - preparing profile directories and syncing only allowlisted items
79
+ - handling missing optional native watchdog support with a non-fatal fallback mode
80
+ - deduplicating concurrent starts for the same `sessionKey`
81
+ - reusing healthy sessions when the effective spec still matches
82
+ - invalidating stale sessions and restarting cleanly when the spec changes
83
+ - collecting and sanitizing startup diagnostics
84
+ - translating launch plans into transient systemd unit arguments
68
85
 
69
- - what workspace should be opened
70
- - which paths should actually be writable in a sandbox
71
- - how processes are supervised
72
- - which users, tokens, or routes exist in the host product
86
+ Host applications mostly provide:
73
87
 
74
- ## Main Planning API
88
+ - `sessionKey`
89
+ - `stateRoot`
90
+ - `workspacePath`
91
+ - `trustedOrigins`
92
+ - `launchStrategy`
93
+ - systemd `scope` when using systemd
94
+ - optional profile and sanitization policy
95
+ - optional logging
75
96
 
76
- ### `createCodeServerLaunchPlan(options)`
97
+ ## Main High-Level APIs
77
98
 
78
- This is the main higher-level API. It returns a structured `CodeServerLaunchPlan` with:
99
+ ### `createCodeServerSessionManager(options?)`
79
100
 
80
- - `command`
81
- - `args`
82
- - `cwd`
83
- - `env`
84
- - `entryKind`
85
- - `launchMode`
86
- - `installation`
87
- - `userDataDir`
88
- - `extensionsDir`
89
- - `supportRoot`
90
- - `supportBindings`
91
- - `recommendedReadablePaths`
92
- - `recommendedWritablePaths`
93
- - `bindAddr`
94
- - `host`
95
- - `port`
96
- - `trustedOrigins`
97
- - `workspacePath`
101
+ Creates the main lifecycle object.
98
102
 
99
- If you pass `dataRoot`, the package derives:
103
+ Manager methods:
100
104
 
101
- - `${dataRoot}/user-data`
102
- - `${dataRoot}/extensions`
105
+ - `start(options)`
106
+ - `stop(options)`
107
+ - `restart(options)`
108
+ - `getStatus(options)`
109
+ - `readDiagnostics(options)`
103
110
 
104
- If you omit `port` or pass `0`, the package allocates a free TCP port first.
111
+ ### `startCodeServerSession(options)`
105
112
 
106
- Example:
113
+ One-shot helper around the session manager.
107
114
 
108
- ```ts
109
- import { createCodeServerLaunchPlan } from "@trebired/code-server-kit";
115
+ Defaults:
110
116
 
111
- const plan = await createCodeServerLaunchPlan({
112
- dataRoot: "/srv/code-server/session-42",
113
- host: "127.0.0.1",
114
- port: 0,
115
- trustedOrigins: [
116
- "https://app.example.com",
117
- "https://admin.example.com",
118
- ],
119
- workspacePath: "/srv/workspaces/demo",
120
- });
121
- ```
117
+ - `launchStrategy` defaults to `"direct"`
118
+ - preparation defaults to auto-ensure
119
+ - exact-spec inflight starts join each other
120
+ - conflicting inflight starts fail with a structured conflict error
121
+ - profile restore defaults to `"if-missing-or-empty"`
122
+ - profile persist defaults to `"if-changed"`
122
123
 
123
- ### `resolveCodeServerInstallation(options?)`
124
+ ### `getCodeServerSessionStatus(options)`
124
125
 
125
- Use this lower-level helper when you only need installation metadata:
126
+ Returns a refreshed status object with:
126
127
 
127
- - `packageRoot`
128
- - `packageJsonPath`
129
- - `entryPoint`
130
- - `entryRelativePath`
131
- - `entryKind`
132
- - `supportRoot`
133
- - `version`
128
+ - `state`
129
+ - `health`
130
+ - `ready`
131
+ - `preparation`
132
+ - `watchdogMode`
133
+ - `lastStartSummary`
134
+ - `sanitizedDiagnostics`
134
135
 
135
- ### `createCodeServerLaunch(options)`
136
+ ### `readCodeServerSessionDiagnostics(options)`
136
137
 
137
- This remains available as a compatibility-friendly alias for `createCodeServerLaunchPlan()`.
138
+ Reads the persisted diagnostics snapshot under:
138
139
 
139
- ## Launch Specs And Sandbox Helpers
140
+ - `<stateRoot>/sessions/<safe-session-key>/session.json`
141
+ - `<stateRoot>/sessions/<safe-session-key>/diagnostics.json`
140
142
 
141
- ### `createCodeServerLaunchSpec(plan)`
143
+ ## Preparation APIs
142
144
 
143
- Converts a launch plan into a smaller execution-oriented shape:
145
+ ### `getCodeServerPreparationStatus(options?)`
144
146
 
145
- - `command`
146
- - `args`
147
- - `cwd`
148
- - `env`
149
- - `readablePaths`
150
- - `writablePaths`
151
- - `bindings`
147
+ Checks whether the installed package looks ready to run and reports:
148
+
149
+ - package root
150
+ - support root
151
+ - bootstrap script path
152
+ - preparation state
153
+ - issues
154
+ - watchdog mode
155
+
156
+ ### `ensureCodeServerPrepared(options?)`
157
+
158
+ Runs the package-owned bootstrap script when the installation is repairable.
152
159
 
153
- This is useful when a caller wants to feed the launch plan into:
160
+ Use this explicitly when a host wants a preflight step. Otherwise the session manager runs it automatically.
154
161
 
155
- - a direct child-process launch
156
- - a systemd unit generator
157
- - a container wrapper
158
- - a custom sandbox layer
162
+ ## Launch Planning APIs
159
163
 
160
- ### `formatCodeServerCommand(planOrSpec)`
164
+ The lower-level planning APIs still exist for hosts that want custom execution layers.
161
165
 
162
- Formats the command and arg vector as one safely escaped string for logs, debug output, shell transcripts, or generated unit files.
166
+ ### `createCodeServerIntegrationPlan(options)`
163
167
 
164
- ### `normalizeCodeServerStartupFailure(error)`
168
+ This is the preferred lower-level planning API. It returns:
165
169
 
166
- Converts package-specific and generic thrown values into one consistent startup-failure shape with:
170
+ - final `command` and `args`
171
+ - `cwd` and `env`
172
+ - preparation status
173
+ - support-root bind suggestions
174
+ - readable and writable path suggestions
175
+ - host-visible and sandbox-visible path lists
176
+ - translated path pairs
167
177
 
168
- - `name`
169
- - `message`
170
- - `code`
171
- - `details`
172
- - `isCodeServerKitError`
178
+ ### `createCodeServerLaunchPlan(options)`
179
+
180
+ Compatibility-friendly alias for callers that still want the previous naming. It now routes through the richer integration-plan path.
181
+
182
+ ### `createCodeServerLaunchSpec(plan)`
183
+
184
+ Converts the plan into a smaller execution-oriented shape:
173
185
 
174
- ## Launching Strategies
186
+ - `command`
187
+ - `args`
188
+ - `cwd`
189
+ - `env`
190
+ - `bindings`
191
+ - `readablePaths`
192
+ - `writablePaths`
175
193
 
176
- ### Direct Child Process
194
+ ## Direct And Systemd Launching
177
195
 
178
- Use the built-in launcher when you want a plain host-owned child process:
196
+ ### Direct
179
197
 
180
198
  ```ts
181
199
  import {
182
200
  createCodeServerLaunchPlan,
183
201
  launchCodeServerProcess,
202
+ waitForCodeServerReady,
184
203
  } from "@trebired/code-server-kit";
185
204
 
186
205
  const plan = await createCodeServerLaunchPlan({
@@ -189,66 +208,77 @@ const plan = await createCodeServerLaunchPlan({
189
208
  });
190
209
 
191
210
  const handle = await launchCodeServerProcess({ plan });
211
+
212
+ await waitForCodeServerReady({
213
+ host: plan.host,
214
+ port: plan.port,
215
+ process: handle,
216
+ });
192
217
  ```
193
218
 
194
219
  ### Systemd
195
220
 
196
- Use `createCodeServerLaunchPlan()` or `createCodeServerLaunchSpec()` to generate:
221
+ Linux-first transient systemd support is built into the same package and stays explicit.
197
222
 
198
- - `ExecStart` from `command` plus `args`
199
- - `WorkingDirectory` from `cwd`
200
- - `Environment` lines from `env`
201
- - read and write path policy from `bindings`, `readablePaths`, and `writablePaths`
223
+ Relevant APIs:
202
224
 
203
- ### Containers
225
+ - `launchCodeServerWithSystemd(options)`
226
+ - `restartCodeServerSystemdUnit(options)`
227
+ - `stopCodeServerSystemdUnit(options)`
228
+ - `readCodeServerSystemdStatus(options)`
229
+ - `readCodeServerSystemdJournal(options)`
230
+ - `summarizeCodeServerSystemdJournal(options)`
231
+ - `extractCodeServerSystemdFailure(options)`
232
+ - `createCodeServerSystemdLaunchCommand(options)`
204
233
 
205
- Use the launch plan to decide:
234
+ `systemd` launches require an explicit scope:
206
235
 
207
- - which package and support paths should be mounted read-only
208
- - which runtime paths should be mounted writable
209
- - the final command and arg vector inside the container
236
+ - `scope: "user"`
237
+ - `scope: "system"`
210
238
 
211
- The package does not impose a container layout. It only returns generic path suggestions.
239
+ There is no package default.
212
240
 
213
- ### Custom Sandboxes
241
+ ## Diagnostics And Redaction
214
242
 
215
- Use `supportBindings`, `recommendedReadablePaths`, and `recommendedWritablePaths` as generic inputs to your own sandbox policy. Host apps can tighten or expand those lists without re-deriving them from package internals.
243
+ ### `collectCodeServerStartupDiagnostics(options)`
216
244
 
217
- ## Readiness Helpers
245
+ Builds a structured diagnostic object with:
218
246
 
219
- ### `waitForCodeServerReady(options)`
247
+ - category
248
+ - code
249
+ - summary
250
+ - machine-readable details
251
+ - launch strategy
252
+ - watchdog mode
253
+ - stderr and stdout tails
254
+ - systemd journal summary
220
255
 
221
- Waits for the target TCP port to accept connections and can also:
256
+ Supported normalized categories include:
222
257
 
223
- - fail on startup timeout
224
- - fail early if a child process exits first
225
- - run a caller-provided `failureProbe`
258
+ - `startup_timeout`
259
+ - `process_exited_before_ready`
260
+ - `systemd_launch_failed`
261
+ - `systemd_unit_failed`
262
+ - `entrypoint_resolution_failed`
263
+ - `missing_runtime_dependency`
264
+ - `preparation_failed`
265
+ - `invalid_configuration`
226
266
 
227
- The readiness helper throws structured errors instead of returning vague booleans.
267
+ ### `sanitizeCodeServerDiagnostics(diagnostics, options)`
228
268
 
229
- Example:
269
+ Supports:
230
270
 
231
- ```ts
232
- await waitForCodeServerReady({
233
- host: plan.host,
234
- port: plan.port,
235
- process: handle,
236
- failureProbe({ elapsedMs }) {
237
- if (elapsedMs > 10_000) {
238
- return {
239
- message: "startup looked stalled",
240
- };
241
- }
242
- return null;
243
- },
244
- });
245
- ```
271
+ - path-prefix redaction
272
+ - exact-value redaction
273
+ - a custom replacer hook
246
274
 
247
- ## Profile Sync Helpers
275
+ The package only sanitizes when a host asks for it.
248
276
 
249
- The package now includes generic profile sync helpers built around an allowlist model.
277
+ ## Profile Lifecycle
250
278
 
251
- Supported profile items:
279
+ Profile sync stays allowlist-based instead of copying the whole runtime tree.
280
+
281
+ Supported items:
252
282
 
253
283
  - `settings.json`
254
284
  - `extensions.json`
@@ -256,89 +286,77 @@ Supported profile items:
256
286
  - `snippets`
257
287
  - `extensions`
258
288
 
259
- ### `createCodeServerProfileSyncPlan(options)`
260
-
261
- Builds a sync plan between two profile roots without copying anything yet.
262
-
263
- ### `syncCodeServerProfile(options)`
289
+ Lower-level APIs:
264
290
 
265
- Copies only the allowlisted profile items. By default it skips missing or unreadable sources cleanly instead of assuming full access to every runtime-owned path.
291
+ - `createCodeServerProfileSyncPlan(options)`
292
+ - `syncCodeServerProfile(options)`
293
+ - `readCodeServerProfileSnapshot(options)`
294
+ - `readCodeServerProfileSignature(options)`
295
+ - `persistCodeServerProfileIfChanged(options)`
266
296
 
267
- Example:
268
-
269
- ```ts
270
- import { syncCodeServerProfile } from "@trebired/code-server-kit";
271
-
272
- const result = await syncCodeServerProfile({
273
- sourceDir: "/srv/persisted-profile",
274
- targetDir: "/srv/runtime-profile",
275
- items: ["settings.json", "snippets", "extensions"],
276
- });
277
-
278
- console.log(result.copied.length, result.skipped.length);
279
- ```
297
+ Session-manager integration now handles:
280
298
 
281
- Default relative paths are also exported through `DEFAULT_CODE_SERVER_PROFILE_PATHS`, and callers can override them when needed through `pathMap`.
299
+ - restore only when runtime profile data is missing or empty by default
300
+ - persistence only when the allowlisted signature changed by default
301
+ - optional extension snapshotting in the signature
282
302
 
283
- ## Reverse Proxy Helpers
303
+ ## Proxy Helpers
284
304
 
285
- ### `normalizeTrustedOrigins(origins)`
305
+ Generic proxy-facing helpers now include:
286
306
 
287
- Normalizes absolute origins for launch planning and rejects invalid values clearly.
307
+ - `buildForwardedHeaders(options)`
308
+ - `buildCodeServerWebSocketHeaders(options)`
309
+ - `isCodeServerHtmlResponse(options)`
310
+ - `classifyCodeServerProxyFailure(options)`
288
311
 
289
- ### `normalizeTrustedOrigin(origin)`
290
-
291
- Normalizes one origin value.
292
-
293
- ### `buildForwardedHeaders(options)`
294
-
295
- Builds a small forwarded-header record for reverse-proxy embedding.
296
-
297
- ### `isCodeServerHtmlResponse(options)`
298
-
299
- Returns `true` when a response looks like HTML that a host app may want to transform before returning it to a browser.
300
-
301
- This helper is intentionally narrow. It does not rewrite routes or inject product-specific markup.
312
+ These helpers stay framework-agnostic and do not add product-specific route rewriting.
302
313
 
303
314
  ## Structured Errors
304
315
 
305
- The package exposes structured error classes so host apps can log clearly and branch reliably:
316
+ Examples:
306
317
 
318
+ - `CodeServerPreparationError`
319
+ - `CodeServerInvalidConfigurationError`
307
320
  - `CodeServerInstallationResolutionError`
308
321
  - `CodeServerEntrypointResolutionError`
309
322
  - `CodeServerLaunchPlanningError`
310
- - `CodeServerInvalidConfigurationError`
311
323
  - `CodeServerPortAllocationError`
312
- - `CodeServerProcessExitedBeforeReadyError`
313
- - `CodeServerStartupProbeError`
314
324
  - `CodeServerStartupTimeoutError`
325
+ - `CodeServerProcessExitedBeforeReadyError`
326
+ - `CodeServerSessionLifecycleError`
327
+ - `CodeServerSessionReuseConflictError`
328
+ - `CodeServerSystemdLaunchError`
329
+ - `CodeServerSystemdCollisionError`
330
+ - `CodeServerSystemdStatusError`
331
+ - `CodeServerSystemdJournalError`
332
+
333
+ Use `normalizeCodeServerStartupFailure(error)` when you want one consistent structured startup-failure payload.
315
334
 
316
- The earlier compatibility exports are still available:
335
+ ## Migration Note
317
336
 
318
- - `CodeServerPackageResolutionError`
319
- - `CodeServerBinaryNotFoundError`
337
+ Existing host apps should delete generic glue for:
320
338
 
321
- ## Public Surface
339
+ - reading from `node_modules/code-server/...` directly
340
+ - running `code-server` postinstall repair themselves
341
+ - discovering support roots or remapping entrypoints manually
342
+ - building support-tree read-only bind lists manually
343
+ - translating host paths into sandbox-visible `code-server` paths
344
+ - deduplicating concurrent starts for the same session key
345
+ - comparing profile state before persisting
346
+ - parsing raw startup output into user-facing summaries
347
+ - building websocket proxy headers and classifying common upstream failures
322
348
 
323
- The current API is centered around these exports:
349
+ Prefer:
324
350
 
325
- - `resolveCodeServerInstallation()`
326
- - `createCodeServerLaunchPlan()`
327
- - `createCodeServerLaunch()`
328
- - `createCodeServerLaunchSpec()`
329
- - `launchCodeServerProcess()`
330
- - `waitForCodeServerReady()`
331
- - `createCodeServerProfileSyncPlan()`
332
- - `syncCodeServerProfile()`
333
- - `buildForwardedHeaders()`
334
- - `normalizeTrustedOrigins()`
335
- - `normalizeTrustedOrigin()`
336
- - `isCodeServerHtmlResponse()`
337
- - `formatCodeServerCommand()`
338
- - `normalizeCodeServerStartupFailure()`
351
+ - `createCodeServerSessionManager()`
352
+ - `startCodeServerSession()`
339
353
 
340
- ## Dependency vs Peer Dependency for `code-server`
354
+ Keep low-level APIs only when you truly need a custom execution layer.
341
355
 
342
- For an application, prefer a regular `dependency` on `code-server` when you want one installed runtime and want `@trebired/code-server-kit` to resolve the same package reliably every time.
356
+ ## Intentionally Deferred
343
357
 
344
- For a wrapper library on top of this package, prefer a `peerDependency` on `code-server` when the host application must choose the exact `code-server` version and install location itself. In that setup, document that `code-server` must still be resolvable from the host application's dependency tree, and pass `resolveFrom` when you need to anchor resolution to the host side explicitly.
358
+ - non-Linux lifecycle orchestration
359
+ - container runtime wrappers
360
+ - host-specific sandbox policy
361
+ - Windows and macOS service-management behavior
362
+ - 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"}