@yeaft/webchat-agent 1.0.437 → 1.0.439
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/container-cli.js +110 -2
- package/container-manager.js +185 -5
- package/local-runtime/agent/container-manager.js +185 -5
- package/local-runtime/server/config.js +5 -1
- package/local-runtime/server/container-agent-service.js +27 -0
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +3 -2
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,9 @@ import { userDb } from './database.js';
|
|
|
5
5
|
import {
|
|
6
6
|
checkContainerAgentRuntime,
|
|
7
7
|
createContainerAgent,
|
|
8
|
+
ensureAgentSlice,
|
|
8
9
|
inspectContainerAgent,
|
|
10
|
+
isAgentSliceReady,
|
|
9
11
|
removeContainerAgent,
|
|
10
12
|
startContainerAgent,
|
|
11
13
|
stopContainerAgent,
|
|
@@ -15,7 +17,9 @@ import {
|
|
|
15
17
|
const DEFAULT_RUNTIME = Object.freeze({
|
|
16
18
|
check: checkContainerAgentRuntime,
|
|
17
19
|
create: createContainerAgent,
|
|
20
|
+
ensureSlice: ensureAgentSlice,
|
|
18
21
|
inspect: inspectContainerAgent,
|
|
22
|
+
isSliceReady: isAgentSliceReady,
|
|
19
23
|
remove: removeContainerAgent,
|
|
20
24
|
start: startContainerAgent,
|
|
21
25
|
stop: stopContainerAgent,
|
|
@@ -100,11 +104,15 @@ export class ContainerAgentService {
|
|
|
100
104
|
const name = this.nameForUser(user.id);
|
|
101
105
|
const secretFile = join(this.config.stateDir, name, 'agent-secret');
|
|
102
106
|
await this.runtime.writeSecret(secretFile, user.agent_secret);
|
|
107
|
+
if (this.config.cgroupParent) {
|
|
108
|
+
await this.ensureManagedSlice();
|
|
109
|
+
}
|
|
103
110
|
await this.runtime.create({
|
|
104
111
|
name,
|
|
105
112
|
serverUrl: this.config.serverUrl,
|
|
106
113
|
secretFile,
|
|
107
114
|
image: this.config.image,
|
|
115
|
+
...(this.config.cgroupParent ? { cgroupParent: this.config.cgroupParent } : {}),
|
|
108
116
|
});
|
|
109
117
|
return { snapshot: await this.snapshot(user.id), replayed: false };
|
|
110
118
|
});
|
|
@@ -121,6 +129,25 @@ export class ContainerAgentService {
|
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Make sure the shared cgroup slice exists before the first managed
|
|
134
|
+
* container is created. The Server process must have root access to
|
|
135
|
+
* /sys/fs/cgroup (typical for a systemd service); a containerized Server
|
|
136
|
+
* without cgroup access fails here with an explicit code instead of
|
|
137
|
+
* silently creating an unprotected container.
|
|
138
|
+
*/
|
|
139
|
+
async ensureManagedSlice() {
|
|
140
|
+
if (await this.runtime.isSliceReady()) return;
|
|
141
|
+
try {
|
|
142
|
+
await this.runtime.ensureSlice();
|
|
143
|
+
} catch (error) {
|
|
144
|
+
throw Object.assign(
|
|
145
|
+
new Error('SANDBOX_CGROUP_SLICE_UNAVAILABLE'),
|
|
146
|
+
{ code: 'SANDBOX_CGROUP_SLICE_UNAVAILABLE', cause: error },
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
124
151
|
// User-visible lifecycle operations are admitted on every request. The
|
|
125
152
|
// feature flag and Docker reachability can change while a browser is open.
|
|
126
153
|
async action(userId, action) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.439"}
|