@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.
- package/CHANGELOG.md +17 -0
- package/README.md +236 -218
- 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 +23 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +43 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +5 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +11 -0
- package/dist/logging.js.map +1 -0
- package/dist/plan.d.ts +3 -2
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +68 -68
- 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 +194 -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 +43 -1
- package/dist/resolve.js.map +1 -1
- package/dist/session.d.ts +11 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +770 -0
- package/dist/session.js.map +1 -0
- 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 +20 -0
- package/dist/systemd.d.ts.map +1 -0
- package/dist/systemd.js +305 -0
- package/dist/systemd.js.map +1 -0
- package/dist/types.d.ts +354 -7
- package/dist/types.d.ts.map +1 -1
- 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
|
|
3
|
+
Framework-agnostic `code-server` integration layer for Node.js applications.
|
|
4
4
|
|
|
5
|
-
`@trebired/code-server-kit`
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
23
|
+
npm install @trebired/code-server-kit
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
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
|
-
|
|
31
|
-
launchCodeServerProcess,
|
|
32
|
-
waitForCodeServerReady,
|
|
38
|
+
createCodeServerSessionManager,
|
|
33
39
|
} from "@trebired/code-server-kit";
|
|
34
40
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
##
|
|
69
|
+
## What The Package Owns
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
High-level APIs now own generic mechanics that host apps previously had to rebuild:
|
|
66
72
|
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
## Main High-Level APIs
|
|
77
98
|
|
|
78
|
-
|
|
99
|
+
### `createCodeServerSessionManager(options?)`
|
|
79
100
|
|
|
80
|
-
|
|
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
|
-
|
|
103
|
+
Manager methods:
|
|
100
104
|
|
|
101
|
-
-
|
|
102
|
-
-
|
|
105
|
+
- `start(options)`
|
|
106
|
+
- `stop(options)`
|
|
107
|
+
- `restart(options)`
|
|
108
|
+
- `getStatus(options)`
|
|
109
|
+
- `readDiagnostics(options)`
|
|
103
110
|
|
|
104
|
-
|
|
111
|
+
### `startCodeServerSession(options)`
|
|
105
112
|
|
|
106
|
-
|
|
113
|
+
One-shot helper around the session manager.
|
|
107
114
|
|
|
108
|
-
|
|
109
|
-
import { createCodeServerLaunchPlan } from "@trebired/code-server-kit";
|
|
115
|
+
Defaults:
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
### `
|
|
124
|
+
### `getCodeServerSessionStatus(options)`
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
Returns a refreshed status object with:
|
|
126
127
|
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
129
|
-
- `
|
|
130
|
-
- `
|
|
131
|
-
- `
|
|
132
|
-
- `
|
|
133
|
-
- `
|
|
128
|
+
- `state`
|
|
129
|
+
- `health`
|
|
130
|
+
- `ready`
|
|
131
|
+
- `preparation`
|
|
132
|
+
- `watchdogMode`
|
|
133
|
+
- `lastStartSummary`
|
|
134
|
+
- `sanitizedDiagnostics`
|
|
134
135
|
|
|
135
|
-
### `
|
|
136
|
+
### `readCodeServerSessionDiagnostics(options)`
|
|
136
137
|
|
|
137
|
-
|
|
138
|
+
Reads the persisted diagnostics snapshot under:
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
- `<stateRoot>/sessions/<safe-session-key>/session.json`
|
|
141
|
+
- `<stateRoot>/sessions/<safe-session-key>/diagnostics.json`
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
## Preparation APIs
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
### `getCodeServerPreparationStatus(options?)`
|
|
144
146
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
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
|
-
|
|
160
|
+
Use this explicitly when a host wants a preflight step. Otherwise the session manager runs it automatically.
|
|
154
161
|
|
|
155
|
-
|
|
156
|
-
- a systemd unit generator
|
|
157
|
-
- a container wrapper
|
|
158
|
-
- a custom sandbox layer
|
|
162
|
+
## Launch Planning APIs
|
|
159
163
|
|
|
160
|
-
|
|
164
|
+
The lower-level planning APIs still exist for hosts that want custom execution layers.
|
|
161
165
|
|
|
162
|
-
|
|
166
|
+
### `createCodeServerIntegrationPlan(options)`
|
|
163
167
|
|
|
164
|
-
|
|
168
|
+
This is the preferred lower-level planning API. It returns:
|
|
165
169
|
|
|
166
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
186
|
+
- `command`
|
|
187
|
+
- `args`
|
|
188
|
+
- `cwd`
|
|
189
|
+
- `env`
|
|
190
|
+
- `bindings`
|
|
191
|
+
- `readablePaths`
|
|
192
|
+
- `writablePaths`
|
|
175
193
|
|
|
176
|
-
|
|
194
|
+
## Direct And Systemd Launching
|
|
177
195
|
|
|
178
|
-
|
|
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
|
-
|
|
221
|
+
Linux-first transient systemd support is built into the same package and stays explicit.
|
|
197
222
|
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
234
|
+
`systemd` launches require an explicit scope:
|
|
206
235
|
|
|
207
|
-
-
|
|
208
|
-
-
|
|
209
|
-
- the final command and arg vector inside the container
|
|
236
|
+
- `scope: "user"`
|
|
237
|
+
- `scope: "system"`
|
|
210
238
|
|
|
211
|
-
|
|
239
|
+
There is no package default.
|
|
212
240
|
|
|
213
|
-
|
|
241
|
+
## Diagnostics And Redaction
|
|
214
242
|
|
|
215
|
-
|
|
243
|
+
### `collectCodeServerStartupDiagnostics(options)`
|
|
216
244
|
|
|
217
|
-
|
|
245
|
+
Builds a structured diagnostic object with:
|
|
218
246
|
|
|
219
|
-
|
|
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
|
-
|
|
256
|
+
Supported normalized categories include:
|
|
222
257
|
|
|
223
|
-
-
|
|
224
|
-
-
|
|
225
|
-
-
|
|
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
|
-
|
|
267
|
+
### `sanitizeCodeServerDiagnostics(diagnostics, options)`
|
|
228
268
|
|
|
229
|
-
|
|
269
|
+
Supports:
|
|
230
270
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
275
|
+
The package only sanitizes when a host asks for it.
|
|
248
276
|
|
|
249
|
-
|
|
277
|
+
## Profile Lifecycle
|
|
250
278
|
|
|
251
|
-
|
|
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
|
-
|
|
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
|
-
|
|
291
|
+
- `createCodeServerProfileSyncPlan(options)`
|
|
292
|
+
- `syncCodeServerProfile(options)`
|
|
293
|
+
- `readCodeServerProfileSnapshot(options)`
|
|
294
|
+
- `readCodeServerProfileSignature(options)`
|
|
295
|
+
- `persistCodeServerProfileIfChanged(options)`
|
|
266
296
|
|
|
267
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
303
|
+
## Proxy Helpers
|
|
284
304
|
|
|
285
|
-
|
|
305
|
+
Generic proxy-facing helpers now include:
|
|
286
306
|
|
|
287
|
-
|
|
307
|
+
- `buildForwardedHeaders(options)`
|
|
308
|
+
- `buildCodeServerWebSocketHeaders(options)`
|
|
309
|
+
- `isCodeServerHtmlResponse(options)`
|
|
310
|
+
- `classifyCodeServerProxyFailure(options)`
|
|
288
311
|
|
|
289
|
-
|
|
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
|
-
|
|
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
|
-
|
|
335
|
+
## Migration Note
|
|
317
336
|
|
|
318
|
-
|
|
319
|
-
- `CodeServerBinaryNotFoundError`
|
|
337
|
+
Existing host apps should delete generic glue for:
|
|
320
338
|
|
|
321
|
-
|
|
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
|
-
|
|
349
|
+
Prefer:
|
|
324
350
|
|
|
325
|
-
- `
|
|
326
|
-
- `
|
|
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
|
-
|
|
354
|
+
Keep low-level APIs only when you truly need a custom execution layer.
|
|
341
355
|
|
|
342
|
-
|
|
356
|
+
## Intentionally Deferred
|
|
343
357
|
|
|
344
|
-
|
|
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"}
|