The best way to control Claude Code, Codex and more from any computer or phone
fix(server): t3 auth --json and --token-only print only the result (#27817)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MarcoDotIO committed
Oct 30, 2026 at 17:26 UTC
714f849ec13b93e75624d9a9d42c60b15eb81d49
5 files changed
+53
-5
apps/server/src/cli/auth.ts
+1
-1
@@ -32,7 +32,7 @@ const runWithEnvironmentAuth = Effect.fn("auth.runWithEnvironmentAuth")(function
32
},
33
) {
34
const logLevel = yield* GlobalFlag.LogLevel;
35
- const config = yield* resolveCliAuthConfig(flags, logLevel);
35
+ const config = yield* resolveCliAuthConfig(flags, logLevel, options);
36
const minimumLogLevel = options?.quietLogs ? "Error" : config.logLevel;
37
return yield* Effect.gen(function* () {
38
const environmentAuth = yield* EnvironmentAuth.EnvironmentAuth;
apps/server/src/cli/config.ts
+10
-2
@@ -15,6 +15,7 @@ import * as LogLevel from "effect/LogLevel";
15
import * as Option from "effect/Option";
16
import * as Path from "effect/Path";
17
import * as Redacted from "effect/Redacted";
18
+import * as References from "effect/References";
19
import * as Schema from "effect/Schema";
20
import * as SchemaIssue from "effect/SchemaIssue";
21
import * as SchemaTransformation from "effect/SchemaTransformation";
@@ -513,8 +514,9 @@ export const resolveServerConfig = Effect.fn("config.resolveServerConfig")(funct
514
export const resolveCliAuthConfig = (
515
flags: CliAuthLocationFlags,
516
cliLogLevel: Option.Option<LogLevel.LogLevel>,
516
-) =>
517
- resolveServerConfig(
517
+ options?: { readonly quietLogs?: boolean },
518
+) => {
519
+ const resolved = resolveServerConfig(
520
{
521
mode: Option.none(),
522
port: Option.none(),
@@ -531,6 +533,12 @@ export const resolveCliAuthConfig = (
533
},
534
cliLogLevel,
535
);
536
+ // Logs go to stdout, where --json and --token-only print, and resolving can
537
+ // log, for example when it sweeps abandoned attachment uploads.
538
+ return options?.quietLogs === true
539
+ ? resolved.pipe(Effect.provideService(References.MinimumLogLevel, "Error"))
540
+ : resolved;
541
+};
542
543
const DurationShorthandPattern = /^(?<value>\d+)(?<unit>ms|s|m|h|d|w)$/i;
544
apps/server/src/cli/connect.ts
+1
-1
@@ -529,7 +529,7 @@ const runCloudCommand = Effect.fn("cloud.cli.run_cloud_command")(function* <A, E
529
},
530
) {
531
const logLevel = yield* GlobalFlag.LogLevel;
532
- const config = yield* resolveCliAuthConfig(flags, logLevel);
532
+ const config = yield* resolveCliAuthConfig(flags, logLevel, options);
533
const minimumLogLevel = options?.quietLogs ? "Error" : config.logLevel;
534
const layerRuntime = Layer.mergeAll(
535
ServerSecretStore.layer,
apps/server/src/cli/environment.ts
+1
-1
@@ -29,7 +29,7 @@ const runWithPeerLinks = Effect.fn("environment.runWithPeerLinks")(function* <A,
29
options?: { readonly quietLogs?: boolean },
30
) {
31
const logLevel = yield* GlobalFlag.LogLevel;
32
- const config = yield* resolveCliAuthConfig(flags, logLevel);
32
+ const config = yield* resolveCliAuthConfig(flags, logLevel, options);
33
return yield* PeerLinks.PeerLinks.pipe(
34
Effect.flatMap(run),
35
Effect.provide(
apps/server/src/cli/pair.test.ts
+40
@@ -18,6 +18,7 @@ import * as Sink from "effect/Sink";
18
import * as Stream from "effect/Stream";
19
import { FetchHttpClient } from "effect/http";
20
import { ChildProcess, ChildProcessSpawner } from "effect/process";
21
+import * as TestClock from "effect/testing/TestClock";
22
import * as TestConsole from "effect/testing/TestConsole";
23
import { Command, CliError } from "effect/cli";
24
@@ -548,3 +549,42 @@ describe("auth pairing create --base-url", () => {
549
}),
550
);
551
});
552
+
553
+describe("scripted auth output", () => {
554
+ it.effect.each(
555
+ [
556
+ ["auth", "session", "issue", "--token-only"],
557
+ ["auth", "session", "list", "--json"],
558
+ ["auth", "pairing", "list", "--json"],
559
+ ].map((command) => ({ command, label: command.join(" ") })),
560
+ )("prints only the result for $label after removing an abandoned upload", ({ command }) =>
561
+ Effect.gen(function* () {
562
+ const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-cli-quiet-test-"));
563
+ const attachmentsDir = NodePath.join(baseDir, "userdata", "attachments");
564
+ NodeFS.mkdirSync(attachmentsDir, { recursive: true });
565
+ // An abandoned upload makes config resolution log that it removed it.
566
+ const abandoned = NodePath.join(attachmentsDir, "abandoned.part");
567
+ NodeFS.writeFileSync(abandoned, "");
568
+ const jan2020Seconds = 1_577_836_800;
569
+ NodeFS.utimesSync(abandoned, jan2020Seconds, jan2020Seconds);
570
+ // The sweep reads Clock, so a week past the upload's mtime makes it expired.
571
+ yield* TestClock.setTime((jan2020Seconds + 7 * 24 * 60 * 60) * 1000);
572
+
573
+ const lines = yield* provideCliTestLayers(
574
+ Effect.gen(function* () {
575
+ yield* runCli([...command, "--base-dir", baseDir]);
576
+ return yield* TestConsole.logLines;
577
+ }),
578
+ );
579
+
580
+ assert.isFalse(NodeFS.existsSync(abandoned));
581
+ assert.lengthOf(lines, 1);
582
+ const output = String(lines[0]);
583
+ if (command.includes("--json")) {
584
+ assert.deepEqual(JSON.parse(output), []);
585
+ } else {
586
+ assert.match(output.trim(), /^[\w-]+\.[\w-]+/);
587
+ }
588
+ }),
589
+ );
590
+});