The best way to control Claude Code, Codex and more from any computer or phone
fix(server): `t3 service protect` can ask for your sudo password (#27465)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 30, 2026 at 02:17 UTC
32ecd71726fee16f335484c1f95cbce126d461f6
3 files changed
+21
-5
apps/server/src/cli/service.ts
+9
-1
@@ -314,6 +314,14 @@ const serviceProtectCommand = Command.make("protect", {
314
);
315
}
316
317
+ yield* Console.log(
318
+ [
319
+ "Keeps T3 Code running when agents fill this machine's memory:",
320
+ " - reserves memory for the T3 Code server, so the kernel takes memory from agents first",
321
+ " - makes the out-of-memory killer pick agents before the server",
322
+ "It adds systemd drop-in files and changes nothing else. Undo with `t3 service protect --undo`.",
323
+ ].join("\n"),
324
+ );
325
const names = remote.map((unit) => unit.replace(/\.service$/, "")).join(" and ");
326
const protectRemote =
327
remote.length > 0 &&
@@ -328,7 +336,7 @@ const serviceProtectCommand = Command.make("protect", {
336
});
337
yield* Console.log(
338
[
331
- "As root, through sudo:",
339
+ "Drop-ins it writes, as root through sudo:",
340
...formatDropIns(plan.system),
341
"As you:",
342
...formatDropIns([plan.managerDefaults, ...plan.user]),
apps/server/src/cloud/serviceProtection.test.ts
+9
-4
@@ -11,6 +11,7 @@ import * as Effect from "effect/Effect";
11
import * as FileSystem from "effect/FileSystem";
12
import * as Sink from "effect/Sink";
13
import * as Stream from "effect/Stream";
14
+import type * as ChildProcess from "effect/process/ChildProcess";
15
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
16
17
import * as ProcessRunner from "../processRunner.ts";
@@ -122,13 +123,13 @@ it.each([
123
expect(ServiceProtection.loadedRemoteAccessUnits(shown)).toEqual(expected);
124
});
125
125
-const fakeSudo = (exitCode: number, onRun: () => void) =>
126
+const fakeSudo = (exitCode: number, onRun: (command: ChildProcess.StandardCommand) => void) =>
127
ChildProcessSpawner.make((command) =>
128
Effect.gen(function* () {
129
if (command._tag !== "StandardCommand" || command.command !== "sudo") {
130
return yield* Effect.die("Unexpected command");
131
}
131
- onRun();
132
+ onRun(command);
133
return ChildProcessSpawner.makeHandle({
134
pid: ChildProcessSpawner.ProcessId(123),
135
stdout: Stream.empty,
@@ -180,11 +181,13 @@ it.effect("lowers no score before the manager default is in place, and undoes in
181
writesManagerDropIn = false,
182
) => {
183
let atSudo: ReturnType<typeof present> | undefined;
184
+ let sudoOptions: ChildProcess.CommandOptions | undefined;
185
return effect.pipe(
186
Effect.provideService(
187
ChildProcessSpawner.ChildProcessSpawner,
186
- fakeSudo(exitCode, () => {
188
+ fakeSudo(exitCode, (command) => {
189
atSudo = present();
190
+ sudoOptions = command.options;
191
if (writesManagerDropIn) {
192
NodeFS.mkdirSync(NodePath.dirname(managerDropIn), { recursive: true });
193
NodeFS.writeFileSync(managerDropIn, "[Service]\nOOMScoreAdjust=-900\n");
@@ -192,7 +195,7 @@ it.effect("lowers no score before the manager default is in place, and undoes in
195
}),
196
),
197
Effect.exit,
195
- Effect.map((exit) => ({ exit, atSudo })),
198
+ Effect.map((exit) => ({ exit, atSudo, sudoOptions })),
199
);
200
};
201
const refused = yield* withSudo(ServiceProtection.applyProtection(plan), 1);
@@ -209,6 +212,8 @@ it.effect("lowers no score before the manager default is in place, and undoes in
212
213
const applied = yield* withSudo(ServiceProtection.applyProtection(plan), 0);
214
expect(applied.atSudo).toEqual({ managerDefaults: true, user: 0 });
215
+ // sudo needs the controlling terminal to ask for a password.
216
+ expect(applied.sudoOptions).toMatchObject({ detached: false, stdin: "inherit" });
217
expect(present()).toEqual({ managerDefaults: true, user: plan.user.length });
218
219
const removed = yield* withSudo(ServiceProtection.removeProtection(plan), 0);
apps/server/src/cloud/serviceProtection.ts
+3
@@ -240,7 +240,10 @@ const runPrivileged = Effect.fn("ServiceProtection.runPrivileged")(function* (sc
240
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
241
const exitCode = yield* spawner
242
.exitCode(
243
+ // Effect detaches children on POSIX by default; sudo then has no controlling
244
+ // terminal and cannot ask for a password.
245
ChildProcess.make("sudo", ["/bin/sh", "-c", script], {
246
+ detached: false,
247
stdin: "inherit",
248
stdout: "inherit",
249
stderr: "inherit",