@trebired/code-server-kit 0.2.0 → 0.3.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 +8 -0
- package/README.md +254 -203
- package/dist/errors.d.ts +20 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +37 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- 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/session.d.ts +11 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +888 -0
- package/dist/session.js.map +1 -0
- package/dist/systemd.d.ts +17 -0
- package/dist/systemd.d.ts.map +1 -0
- package/dist/systemd.js +254 -0
- package/dist/systemd.js.map +1 -0
- package/dist/types.d.ts +200 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
- nothing yet
|
|
6
6
|
|
|
7
|
+
## 0.3.0
|
|
8
|
+
|
|
9
|
+
- expand the package from launch planning into a full generic `code-server` session runtime
|
|
10
|
+
- add session lifecycle APIs for start, stop, restart, status, diagnostics, and session-manager creation
|
|
11
|
+
- add Linux-first transient systemd helpers and launch-command builders
|
|
12
|
+
- add disk-backed session metadata, reuse checks, profile restore and persist hooks, and richer startup diagnostics
|
|
13
|
+
- add `@trebired/logger-adapter` support across the higher-level APIs
|
|
14
|
+
|
|
7
15
|
## 0.2.0
|
|
8
16
|
|
|
9
17
|
- add `createCodeServerLaunchPlan()` as the main higher-level launch planning API
|
package/README.md
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
# @trebired/code-server-kit
|
|
2
2
|
|
|
3
|
-
Framework-agnostic `code-server`
|
|
3
|
+
Framework-agnostic `code-server` session runtime for Node.js applications.
|
|
4
4
|
|
|
5
|
-
`@trebired/code-server-kit`
|
|
5
|
+
`@trebired/code-server-kit` is the generic Trebired package for owning the full `code-server` lifecycle on Linux-first hosts:
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
8
13
|
|
|
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.
|
|
14
|
+
The package stays generic on purpose. It does not know about products, repositories, organizations, users, routes, or app-specific filesystem conventions.
|
|
17
15
|
|
|
18
16
|
## Install
|
|
19
17
|
|
|
@@ -23,106 +21,163 @@ Runtime target: Node.js 22+ on Linux first.
|
|
|
23
21
|
npm install @trebired/code-server-kit code-server
|
|
24
22
|
```
|
|
25
23
|
|
|
24
|
+
## What Host Apps Still Provide
|
|
25
|
+
|
|
26
|
+
After the session runtime layer is in place, host applications mostly choose policy:
|
|
27
|
+
|
|
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
|
|
36
|
+
|
|
37
|
+
The package owns the generic mechanics:
|
|
38
|
+
|
|
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
|
+
|
|
26
49
|
## Quick Start
|
|
27
50
|
|
|
28
51
|
```ts
|
|
29
52
|
import {
|
|
30
|
-
|
|
31
|
-
launchCodeServerProcess,
|
|
32
|
-
waitForCodeServerReady,
|
|
53
|
+
createCodeServerSessionManager,
|
|
33
54
|
} from "@trebired/code-server-kit";
|
|
34
55
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
const sessions = createCodeServerSessionManager({
|
|
57
|
+
logger: console,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const started = await sessions.start({
|
|
61
|
+
launchStrategy: "direct",
|
|
62
|
+
sessionKey: "workspace-42",
|
|
63
|
+
stateRoot: "/srv/code-server-state",
|
|
39
64
|
trustedOrigins: [
|
|
40
65
|
"https://app.example.com",
|
|
41
66
|
],
|
|
42
67
|
workspacePath: "/srv/workspaces/demo",
|
|
43
68
|
});
|
|
44
69
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
stderr(text) {
|
|
51
|
-
process.stderr.write(text);
|
|
52
|
-
},
|
|
70
|
+
console.log(started.status.state, started.status.port);
|
|
71
|
+
|
|
72
|
+
const status = await sessions.getStatus({
|
|
73
|
+
sessionKey: "workspace-42",
|
|
74
|
+
stateRoot: "/srv/code-server-state",
|
|
53
75
|
});
|
|
54
76
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
console.log(status?.ready);
|
|
78
|
+
|
|
79
|
+
await sessions.stop({
|
|
80
|
+
sessionKey: "workspace-42",
|
|
81
|
+
stateRoot: "/srv/code-server-state",
|
|
60
82
|
});
|
|
61
83
|
```
|
|
62
84
|
|
|
63
|
-
##
|
|
85
|
+
## Main Session APIs
|
|
64
86
|
|
|
65
|
-
|
|
87
|
+
### `createCodeServerSessionManager(options?)`
|
|
66
88
|
|
|
67
|
-
|
|
89
|
+
Creates the main high-level lifecycle object and wires logging through `@trebired/logger-adapter`.
|
|
68
90
|
|
|
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
|
|
91
|
+
Manager methods:
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
- `start(options)`
|
|
94
|
+
- `stop(options)`
|
|
95
|
+
- `restart(options)`
|
|
96
|
+
- `getStatus(options)`
|
|
97
|
+
- `readDiagnostics(options)`
|
|
75
98
|
|
|
76
|
-
### `
|
|
99
|
+
### `startCodeServerSession(options)`
|
|
77
100
|
|
|
78
|
-
|
|
101
|
+
One-shot helper that creates a manager and starts a session.
|
|
79
102
|
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
- `
|
|
83
|
-
- `
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- `
|
|
88
|
-
-
|
|
89
|
-
- `
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
Lifecycle-managed session APIs require:
|
|
104
|
+
|
|
105
|
+
- `sessionKey`
|
|
106
|
+
- `stateRoot`
|
|
107
|
+
|
|
108
|
+
Defaults:
|
|
109
|
+
|
|
110
|
+
- `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
|
+
|
|
123
|
+
### `getCodeServerSessionStatus(options)`
|
|
124
|
+
|
|
125
|
+
Loads the package-owned session record and re-probes the live backing resource instead of trusting disk alone.
|
|
126
|
+
|
|
127
|
+
### `readCodeServerSessionDiagnostics(options)`
|
|
128
|
+
|
|
129
|
+
Reads the persisted diagnostics snapshot for a session.
|
|
130
|
+
|
|
131
|
+
## Session Metadata
|
|
132
|
+
|
|
133
|
+
The package stores generic lifecycle metadata under:
|
|
134
|
+
|
|
135
|
+
- `<stateRoot>/sessions/<safe-session-key>/session.json`
|
|
136
|
+
- `<stateRoot>/sessions/<safe-session-key>/diagnostics.json`
|
|
137
|
+
|
|
138
|
+
The session record tracks values such as:
|
|
139
|
+
|
|
140
|
+
- `state`
|
|
141
|
+
- `launchStrategy`
|
|
142
|
+
- `specHash`
|
|
93
143
|
- `bindAddr`
|
|
94
|
-
- `host`
|
|
95
144
|
- `port`
|
|
96
|
-
- `
|
|
145
|
+
- `userDataDir`
|
|
146
|
+
- `extensionsDir`
|
|
97
147
|
- `workspacePath`
|
|
148
|
+
- `pid` for direct launches
|
|
149
|
+
- `unitName` and `systemdScope` for systemd launches
|
|
150
|
+
- timestamps and normalized failure details
|
|
98
151
|
|
|
99
|
-
|
|
152
|
+
This disk-backed record is what allows the package to reuse, stop, restart, and inspect sessions across calls.
|
|
100
153
|
|
|
101
|
-
|
|
102
|
-
- `${dataRoot}/extensions`
|
|
154
|
+
## Reuse Model
|
|
103
155
|
|
|
104
|
-
|
|
156
|
+
The package builds a normalized session spec from the effective launch plan plus lifecycle-relevant inputs such as:
|
|
105
157
|
|
|
106
|
-
|
|
158
|
+
- launch strategy
|
|
159
|
+
- workspace path
|
|
160
|
+
- trusted origins
|
|
161
|
+
- env overrides
|
|
162
|
+
- profile restore and persist configuration
|
|
163
|
+
- systemd scope and unit naming
|
|
107
164
|
|
|
108
|
-
|
|
109
|
-
import { createCodeServerLaunchPlan } from "@trebired/code-server-kit";
|
|
165
|
+
That normalized spec is hashed and stored. Reuse only happens when:
|
|
110
166
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```
|
|
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
|
|
171
|
+
|
|
172
|
+
If the hash changes, the package marks the old record stale, stops the old runtime when needed, and starts a fresh session.
|
|
173
|
+
|
|
174
|
+
## Launch Planning APIs
|
|
175
|
+
|
|
176
|
+
The lower-level launch planning APIs remain available for callers that want policy ownership while still avoiding `code-server` package-layout details.
|
|
122
177
|
|
|
123
178
|
### `resolveCodeServerInstallation(options?)`
|
|
124
179
|
|
|
125
|
-
|
|
180
|
+
Returns installation metadata:
|
|
126
181
|
|
|
127
182
|
- `packageRoot`
|
|
128
183
|
- `packageJsonPath`
|
|
@@ -132,55 +187,51 @@ Use this lower-level helper when you only need installation metadata:
|
|
|
132
187
|
- `supportRoot`
|
|
133
188
|
- `version`
|
|
134
189
|
|
|
135
|
-
### `
|
|
190
|
+
### `createCodeServerLaunchPlan(options)`
|
|
136
191
|
|
|
137
|
-
|
|
192
|
+
Returns a structured launch plan with:
|
|
138
193
|
|
|
139
|
-
|
|
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`
|
|
140
211
|
|
|
141
212
|
### `createCodeServerLaunchSpec(plan)`
|
|
142
213
|
|
|
143
|
-
Converts
|
|
214
|
+
Converts the launch plan into an execution-oriented shape:
|
|
144
215
|
|
|
145
216
|
- `command`
|
|
146
217
|
- `args`
|
|
147
218
|
- `cwd`
|
|
148
219
|
- `env`
|
|
220
|
+
- `bindings`
|
|
149
221
|
- `readablePaths`
|
|
150
222
|
- `writablePaths`
|
|
151
|
-
- `bindings`
|
|
152
|
-
|
|
153
|
-
This is useful when a caller wants to feed the launch plan into:
|
|
154
|
-
|
|
155
|
-
- a direct child-process launch
|
|
156
|
-
- a systemd unit generator
|
|
157
|
-
- a container wrapper
|
|
158
|
-
- a custom sandbox layer
|
|
159
223
|
|
|
160
|
-
|
|
224
|
+
This is useful when a host wants to feed the same plan into a container, custom sandbox, or generated unit file.
|
|
161
225
|
|
|
162
|
-
|
|
226
|
+
## Direct Launch
|
|
163
227
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Converts package-specific and generic thrown values into one consistent startup-failure shape with:
|
|
167
|
-
|
|
168
|
-
- `name`
|
|
169
|
-
- `message`
|
|
170
|
-
- `code`
|
|
171
|
-
- `details`
|
|
172
|
-
- `isCodeServerKitError`
|
|
173
|
-
|
|
174
|
-
## Launching Strategies
|
|
175
|
-
|
|
176
|
-
### Direct Child Process
|
|
177
|
-
|
|
178
|
-
Use the built-in launcher when you want a plain host-owned child process:
|
|
228
|
+
Use the built-in child-process helper when you want a plain process owned by the current Node.js runtime.
|
|
179
229
|
|
|
180
230
|
```ts
|
|
181
231
|
import {
|
|
182
232
|
createCodeServerLaunchPlan,
|
|
183
233
|
launchCodeServerProcess,
|
|
234
|
+
waitForCodeServerReady,
|
|
184
235
|
} from "@trebired/code-server-kit";
|
|
185
236
|
|
|
186
237
|
const plan = await createCodeServerLaunchPlan({
|
|
@@ -189,66 +240,52 @@ const plan = await createCodeServerLaunchPlan({
|
|
|
189
240
|
});
|
|
190
241
|
|
|
191
242
|
const handle = await launchCodeServerProcess({ plan });
|
|
192
|
-
```
|
|
193
243
|
|
|
194
|
-
|
|
244
|
+
await waitForCodeServerReady({
|
|
245
|
+
host: plan.host,
|
|
246
|
+
port: plan.port,
|
|
247
|
+
process: handle,
|
|
248
|
+
});
|
|
249
|
+
```
|
|
195
250
|
|
|
196
|
-
|
|
251
|
+
The lifecycle manager uses this same lower-level path internally for `launchStrategy: "direct"`.
|
|
197
252
|
|
|
198
|
-
|
|
199
|
-
- `WorkingDirectory` from `cwd`
|
|
200
|
-
- `Environment` lines from `env`
|
|
201
|
-
- read and write path policy from `bindings`, `readablePaths`, and `writablePaths`
|
|
253
|
+
## Systemd Launch
|
|
202
254
|
|
|
203
|
-
|
|
255
|
+
Linux systemd support is built into the same package and stays explicit.
|
|
204
256
|
|
|
205
|
-
Use
|
|
257
|
+
Use `launchStrategy: "systemd"` only when you also provide:
|
|
206
258
|
|
|
207
|
-
-
|
|
208
|
-
- which runtime paths should be mounted writable
|
|
209
|
-
- the final command and arg vector inside the container
|
|
259
|
+
- `systemd.scope: "user"` or `"system"`
|
|
210
260
|
|
|
211
|
-
The package
|
|
261
|
+
The package uses transient services through `systemd-run`, not scopes.
|
|
212
262
|
|
|
213
|
-
|
|
263
|
+
Relevant APIs:
|
|
214
264
|
|
|
215
|
-
|
|
265
|
+
- `launchCodeServerWithSystemd(options)`
|
|
266
|
+
- `stopCodeServerSystemdUnit(options)`
|
|
267
|
+
- `readCodeServerSystemdStatus(options)`
|
|
268
|
+
- `readCodeServerSystemdJournal(options)`
|
|
269
|
+
- `createCodeServerSystemdLaunchCommand(options)`
|
|
270
|
+
- `buildSystemdPathProperties(spec)`
|
|
216
271
|
|
|
217
|
-
|
|
272
|
+
The systemd translation layer derives:
|
|
218
273
|
|
|
219
|
-
|
|
274
|
+
- `--unit`
|
|
275
|
+
- `--working-directory`
|
|
276
|
+
- `--setenv`
|
|
277
|
+
- `BindPaths`
|
|
278
|
+
- `BindReadOnlyPaths`
|
|
279
|
+
- `ReadOnlyPaths`
|
|
280
|
+
- `ReadWritePaths`
|
|
220
281
|
|
|
221
|
-
|
|
282
|
+
That means host applications do not need to rebuild transient unit arguments from raw launch-plan data themselves.
|
|
222
283
|
|
|
223
|
-
|
|
224
|
-
- fail early if a child process exits first
|
|
225
|
-
- run a caller-provided `failureProbe`
|
|
284
|
+
## Profile Restore And Persist
|
|
226
285
|
|
|
227
|
-
|
|
286
|
+
Profile sync stays allowlist-based rather than copying the entire runtime tree.
|
|
228
287
|
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
```
|
|
246
|
-
|
|
247
|
-
## Profile Sync Helpers
|
|
248
|
-
|
|
249
|
-
The package now includes generic profile sync helpers built around an allowlist model.
|
|
250
|
-
|
|
251
|
-
Supported profile items:
|
|
288
|
+
Supported items:
|
|
252
289
|
|
|
253
290
|
- `settings.json`
|
|
254
291
|
- `extensions.json`
|
|
@@ -256,89 +293,103 @@ Supported profile items:
|
|
|
256
293
|
- `snippets`
|
|
257
294
|
- `extensions`
|
|
258
295
|
|
|
259
|
-
|
|
296
|
+
Lower-level helpers:
|
|
260
297
|
|
|
261
|
-
|
|
298
|
+
- `createCodeServerProfileSyncPlan(options)`
|
|
299
|
+
- `syncCodeServerProfile(options)`
|
|
300
|
+
- `resolveCodeServerProfilePathMap(overrides?)`
|
|
262
301
|
|
|
263
|
-
|
|
302
|
+
Lifecycle integration:
|
|
264
303
|
|
|
265
|
-
|
|
304
|
+
- restore before launch with `profile.restoreFrom`
|
|
305
|
+
- persist after stop with `profile.persistTo`
|
|
306
|
+
- skip missing or unreadable sources cleanly by default
|
|
266
307
|
|
|
267
308
|
Example:
|
|
268
309
|
|
|
269
310
|
```ts
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
311
|
+
await sessions.start({
|
|
312
|
+
profile: {
|
|
313
|
+
items: ["settings.json", "keybindings.json", "extensions"],
|
|
314
|
+
persistTo: "/srv/profiles/demo",
|
|
315
|
+
restoreFrom: "/srv/profiles/demo",
|
|
316
|
+
},
|
|
317
|
+
sessionKey: "workspace-42",
|
|
318
|
+
stateRoot: "/srv/code-server-state",
|
|
319
|
+
workspacePath: "/srv/workspaces/demo",
|
|
276
320
|
});
|
|
277
|
-
|
|
278
|
-
console.log(result.copied.length, result.skipped.length);
|
|
279
321
|
```
|
|
280
322
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
## Reverse Proxy Helpers
|
|
284
|
-
|
|
285
|
-
### `normalizeTrustedOrigins(origins)`
|
|
286
|
-
|
|
287
|
-
Normalizes absolute origins for launch planning and rejects invalid values clearly.
|
|
323
|
+
## Readiness And Failure Handling
|
|
288
324
|
|
|
289
|
-
### `
|
|
290
|
-
|
|
291
|
-
Normalizes one origin value.
|
|
292
|
-
|
|
293
|
-
### `buildForwardedHeaders(options)`
|
|
325
|
+
### `waitForCodeServerReady(options)`
|
|
294
326
|
|
|
295
|
-
|
|
327
|
+
Waits for the TCP port to accept connections and can also:
|
|
296
328
|
|
|
297
|
-
|
|
329
|
+
- fail on startup timeout
|
|
330
|
+
- fail on direct-process early exit
|
|
331
|
+
- fail on a caller-provided failure probe
|
|
298
332
|
|
|
299
|
-
|
|
333
|
+
The lifecycle manager builds on this and adds strategy-aware supervision:
|
|
300
334
|
|
|
301
|
-
|
|
335
|
+
- direct-process stdout and stderr tails
|
|
336
|
+
- systemd state probing
|
|
337
|
+
- systemd journal collection
|
|
338
|
+
- normalized startup failure metadata
|
|
302
339
|
|
|
303
340
|
## Structured Errors
|
|
304
341
|
|
|
305
|
-
The package
|
|
342
|
+
The package throws structured error classes so callers can log and branch on them reliably.
|
|
343
|
+
|
|
344
|
+
Examples:
|
|
306
345
|
|
|
346
|
+
- `CodeServerInvalidConfigurationError`
|
|
307
347
|
- `CodeServerInstallationResolutionError`
|
|
308
348
|
- `CodeServerEntrypointResolutionError`
|
|
309
349
|
- `CodeServerLaunchPlanningError`
|
|
310
|
-
- `CodeServerInvalidConfigurationError`
|
|
311
350
|
- `CodeServerPortAllocationError`
|
|
312
|
-
- `CodeServerProcessExitedBeforeReadyError`
|
|
313
|
-
- `CodeServerStartupProbeError`
|
|
314
351
|
- `CodeServerStartupTimeoutError`
|
|
352
|
+
- `CodeServerProcessExitedBeforeReadyError`
|
|
353
|
+
- `CodeServerSessionLifecycleError`
|
|
354
|
+
- `CodeServerSessionReuseConflictError`
|
|
355
|
+
- `CodeServerSystemdLaunchError`
|
|
356
|
+
- `CodeServerSystemdCollisionError`
|
|
357
|
+
- `CodeServerSystemdStatusError`
|
|
358
|
+
- `CodeServerSystemdJournalError`
|
|
359
|
+
|
|
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:
|
|
365
|
+
|
|
366
|
+
- `buildForwardedHeaders(options)`
|
|
367
|
+
- `normalizeTrustedOrigin(value)`
|
|
368
|
+
- `isCodeServerHtmlResponse(options)`
|
|
369
|
+
|
|
370
|
+
These helpers stay intentionally small. They do not add product-specific route rewriting.
|
|
371
|
+
|
|
372
|
+
## Logging
|
|
373
|
+
|
|
374
|
+
High-level APIs accept:
|
|
315
375
|
|
|
316
|
-
|
|
376
|
+
- `logger`
|
|
377
|
+
- `loggerAdapter`
|
|
317
378
|
|
|
318
|
-
- `
|
|
319
|
-
- `CodeServerBinaryNotFoundError`
|
|
379
|
+
The package resolves those through `@trebired/logger-adapter`, matching the style used by other `@trebired/*` packages. `createCodeServerSessionManager()` also emits `logPackageInitialized()` on creation.
|
|
320
380
|
|
|
321
|
-
##
|
|
381
|
+
## `code-server`: Dependency vs Peer Dependency
|
|
322
382
|
|
|
323
|
-
|
|
383
|
+
Use `code-server` as a normal `dependency` when:
|
|
324
384
|
|
|
325
|
-
-
|
|
326
|
-
- `
|
|
327
|
-
-
|
|
328
|
-
- `createCodeServerLaunchSpec()`
|
|
329
|
-
- `launchCodeServerProcess()`
|
|
330
|
-
- `waitForCodeServerReady()`
|
|
331
|
-
- `createCodeServerProfileSyncPlan()`
|
|
332
|
-
- `syncCodeServerProfile()`
|
|
333
|
-
- `buildForwardedHeaders()`
|
|
334
|
-
- `normalizeTrustedOrigins()`
|
|
335
|
-
- `normalizeTrustedOrigin()`
|
|
336
|
-
- `isCodeServerHtmlResponse()`
|
|
337
|
-
- `formatCodeServerCommand()`
|
|
338
|
-
- `normalizeCodeServerStartupFailure()`
|
|
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
|
|
339
388
|
|
|
340
|
-
|
|
389
|
+
Use `code-server` as a `peerDependency` in your own higher-level package when:
|
|
341
390
|
|
|
342
|
-
|
|
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
|
|
343
394
|
|
|
344
|
-
|
|
395
|
+
`@trebired/code-server-kit` itself depends on `code-server` because the generic runtime layer needs a predictable package to resolve.
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type CodeServerKitErrorCode = "entrypoint_resolution_failed" | "installation_resolution_failed" | "invalid_configuration" | "launch_planning_failed" | "port_allocation_failed" | "process_exited_before_ready" | "startup_probe_failed" | "startup_timeout";
|
|
1
|
+
type CodeServerKitErrorCode = "entrypoint_resolution_failed" | "installation_resolution_failed" | "invalid_configuration" | "launch_planning_failed" | "port_allocation_failed" | "process_exited_before_ready" | "session_lifecycle_failed" | "session_reuse_conflict" | "startup_probe_failed" | "startup_timeout" | "systemd_collision" | "systemd_journal_failed" | "systemd_launch_failed" | "systemd_status_failed";
|
|
2
2
|
declare class CodeServerKitError extends Error {
|
|
3
3
|
code: CodeServerKitErrorCode | string;
|
|
4
4
|
details: Record<string, unknown>;
|
|
@@ -28,6 +28,24 @@ declare class CodeServerStartupTimeoutError extends CodeServerKitError {
|
|
|
28
28
|
declare class CodeServerStartupProbeError extends CodeServerKitError {
|
|
29
29
|
constructor(message: string, details?: Record<string, unknown>);
|
|
30
30
|
}
|
|
31
|
+
declare class CodeServerSessionLifecycleError extends CodeServerKitError {
|
|
32
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
33
|
+
}
|
|
34
|
+
declare class CodeServerSessionReuseConflictError extends CodeServerKitError {
|
|
35
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
36
|
+
}
|
|
37
|
+
declare class CodeServerSystemdLaunchError extends CodeServerKitError {
|
|
38
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
39
|
+
}
|
|
40
|
+
declare class CodeServerSystemdCollisionError extends CodeServerKitError {
|
|
41
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
42
|
+
}
|
|
43
|
+
declare class CodeServerSystemdStatusError extends CodeServerKitError {
|
|
44
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
45
|
+
}
|
|
46
|
+
declare class CodeServerSystemdJournalError extends CodeServerKitError {
|
|
47
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
48
|
+
}
|
|
31
49
|
declare class CodeServerPackageResolutionError extends CodeServerInstallationResolutionError {
|
|
32
50
|
constructor(message: string, details?: Record<string, unknown>);
|
|
33
51
|
}
|
|
@@ -35,6 +53,6 @@ declare class CodeServerBinaryNotFoundError extends CodeServerEntrypointResoluti
|
|
|
35
53
|
constructor(message: string, details?: Record<string, unknown>);
|
|
36
54
|
}
|
|
37
55
|
declare function isCodeServerKitError(value: unknown): value is CodeServerKitError;
|
|
38
|
-
export { CodeServerBinaryNotFoundError, CodeServerEntrypointResolutionError, CodeServerInstallationResolutionError, CodeServerInvalidConfigurationError, CodeServerKitError, CodeServerLaunchPlanningError, CodeServerPackageResolutionError, CodeServerPortAllocationError, CodeServerProcessExitedBeforeReadyError, CodeServerStartupProbeError, CodeServerStartupTimeoutError, isCodeServerKitError, };
|
|
56
|
+
export { CodeServerBinaryNotFoundError, CodeServerEntrypointResolutionError, CodeServerInstallationResolutionError, CodeServerInvalidConfigurationError, CodeServerKitError, CodeServerLaunchPlanningError, CodeServerPackageResolutionError, CodeServerPortAllocationError, CodeServerProcessExitedBeforeReadyError, CodeServerSessionLifecycleError, CodeServerSessionReuseConflictError, CodeServerStartupProbeError, CodeServerStartupTimeoutError, CodeServerSystemdCollisionError, CodeServerSystemdJournalError, CodeServerSystemdLaunchError, CodeServerSystemdStatusError, isCodeServerKitError, };
|
|
39
57
|
export type { CodeServerKitErrorCode };
|
|
40
58
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GACvB,8BAA8B,GAC9B,gCAAgC,GAChC,uBAAuB,GACvB,wBAAwB,GACxB,wBAAwB,GACxB,6BAA6B,GAC7B,sBAAsB,GACtB,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GACvB,8BAA8B,GAC9B,gCAAgC,GAChC,uBAAuB,GACvB,wBAAwB,GACxB,wBAAwB,GACxB,6BAA6B,GAC7B,0B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