The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 07:45 UTC
refactor(server): classify runtime exports (#10274)
Julius Marminge committed
Sep 8, 2026 at 01:11 UTC
6f4cd07b900299629b9f2f9a9336f5c090556a51
32 files changed
+40
-28
apps/server/scripts/t3-sqlite-state.ts
+1
-1
@@ -245,7 +245,7 @@ export const runSqliteState = Effect.fn("runSqliteState")(function* (
245
);
246
});
247
248
-export const t3SqliteStateCommand = Command.make(
248
+const t3SqliteStateCommand = Command.make(
249
"t3-sqlite-state",
250
{
251
operation: Argument.choice("operation", SqliteStateOperation.literals).pipe(
apps/server/src/attachmentStore.ts
+1
-1
@@ -22,7 +22,7 @@ const ATTACHMENT_ID_PATTERN = new RegExp(
22
);
23
24
export const PENDING_ATTACHMENT_THREAD_SEGMENT = "pending";
25
-export const PENDING_ATTACHMENT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
25
+const PENDING_ATTACHMENT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
26
const PARTIAL_UPLOAD_MAX_AGE_MS = 60 * 60 * 1000;
27
28
export function toSafeThreadAttachmentSegment(threadId: string): string | null {
apps/server/src/auth/EnvironmentAuth.ts
+3
-2
@@ -38,7 +38,7 @@ import * as SessionStore from "./SessionStore.ts";
38
import { verifyRequestDpopProof } from "./dpop.ts";
39
import { layerConfig as SqlitePersistenceLayer } from "../persistence/Layers/Sqlite.ts";
40
41
-export const DEFAULT_SESSION_SUBJECT = "cli-issued-session";
41
+const DEFAULT_SESSION_SUBJECT = "cli-issued-session";
42
export const INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT = "administrative-bootstrap";
43
44
export interface IssuedPairingLink {
@@ -591,6 +591,7 @@ export function selectRequestCredential(
591
return undefined;
592
}
593
594
+/** @public Service construction is part of the canonical Effect module API. */
595
export const make = Effect.gen(function* () {
596
const policy = yield* EnvironmentAuthPolicy.EnvironmentAuthPolicy;
597
const bootstrapCredentials = yield* PairingGrantStore.PairingGrantStore;
@@ -1033,7 +1034,7 @@ export const layer = Layer.effect(EnvironmentAuth, make).pipe(
1034
Layer.provideMerge(EnvironmentAuthPolicy.layer),
1035
);
1036
1036
-export const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistenceLayer);
1037
+const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistenceLayer);
1038
1039
export const runtimeLayer = layer.pipe(
1040
Layer.provideMerge(storageLayer),
apps/server/src/auth/EnvironmentAuthPolicy.ts
+1
@@ -14,6 +14,7 @@ export class EnvironmentAuthPolicy extends Context.Service<
14
}
15
>()("t3/auth/EnvironmentAuthPolicy") {}
16
17
+/** @public Service construction is part of the canonical Effect module API. */
18
export const make = Effect.gen(function* () {
19
const config = yield* ServerConfig.ServerConfig;
20
const serverEnvironment = yield* ServerEnvironment.ServerEnvironmentIdentity;
apps/server/src/auth/PairingGrantStore.ts
-2
@@ -72,7 +72,6 @@ export const BootstrapCredentialInvalidError = Schema.Union([
72
UnavailableBootstrapCredentialError,
73
]);
74
export type BootstrapCredentialInvalidError = typeof BootstrapCredentialInvalidError.Type;
75
-export const isBootstrapCredentialInvalidError = Schema.is(BootstrapCredentialInvalidError);
75
76
export class ActivePairingLinksLoadError extends Schema.TaggedError<ActivePairingLinksLoadError>()(
77
"ActivePairingLinksLoadError",
@@ -173,7 +172,6 @@ export const BootstrapCredentialError = Schema.Union([
172
BootstrapCredentialInternalError,
173
]);
174
export type BootstrapCredentialError = typeof BootstrapCredentialError.Type;
176
-export const isBootstrapCredentialError = Schema.is(BootstrapCredentialError);
175
176
export interface IssuedBootstrapCredential {
177
readonly id: string;
apps/server/src/auth/ServerSecretStore.ts
+1
@@ -149,6 +149,7 @@ export class ServerSecretStore extends Context.Service<
149
}
150
>()("t3/auth/ServerSecretStore") {}
151
152
+/** @public Service construction is part of the canonical Effect module API. */
153
export const make = Effect.gen(function* () {
154
const crypto = yield* Crypto.Crypto;
155
const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/auth/SessionStore.ts
-2
@@ -349,14 +349,12 @@ export const SessionCredentialInternalError = Schema.Union([
349
OtherSessionsRevocationError,
350
]);
351
export type SessionCredentialInternalError = typeof SessionCredentialInternalError.Type;
352
-export const isSessionCredentialInternalError = Schema.is(SessionCredentialInternalError);
352
353
export const SessionCredentialError = Schema.Union([
354
SessionCredentialInvalidError,
355
SessionCredentialInternalError,
356
]);
357
export type SessionCredentialError = typeof SessionCredentialError.Type;
359
-export const isSessionCredentialError = Schema.is(SessionCredentialError);
358
359
export class SessionStore extends Context.Service<
360
SessionStore,
apps/server/src/auth/http.ts
+1
-1
@@ -65,7 +65,7 @@ const appendDpopChallengeOnUnauthorized = (error: EnvironmentAuthInvalidError) =
65
return yield* error;
66
});
67
68
-export const currentEnvironmentTraceId = Effect.currentParentSpan.pipe(
68
+const currentEnvironmentTraceId = Effect.currentParentSpan.pipe(
69
Effect.map((span) => span.traceId),
70
Effect.orElseSucceed(() => "unavailable"),
71
);
apps/server/src/background/BackgroundPolicy.ts
+2
-1
@@ -82,7 +82,7 @@ function leaseKey(lease: Pick<ClientActivityLease, "sessionId" | "rpcClientId" |
82
return JSON.stringify([lease.sessionId, lease.rpcClientId, lease.clientId]);
83
}
84
85
-export function upsertClientActivityLease(
85
+function upsertClientActivityLease(
86
leases: ReadonlyMap<string, ClientActivityLease>,
87
lease: ClientActivityLease,
88
now: DateTime.Utc,
@@ -208,6 +208,7 @@ function computeSnapshot(input: {
208
};
209
}
210
211
+/** @public Service construction is part of the canonical Effect module API. */
212
export const make = Effect.fn("background.policy.make")(function* () {
213
const hostPowerMonitor = yield* HostPowerMonitor.HostPowerMonitor;
214
const serverSettings = yield* ServerSettingsService;
apps/server/src/background/HostPowerMonitor.ts
+1
-1
@@ -19,7 +19,7 @@ export class HostPowerMonitor extends Context.Service<
19
}
20
>()("t3/background/HostPowerMonitor") {}
21
22
-export const makeUnknownSnapshot = (
22
+const makeUnknownSnapshot = (
23
source: HostPowerSnapshot["source"],
24
updatedAt: HostPowerSnapshot["updatedAt"],
25
): HostPowerSnapshot => ({
apps/server/src/checkpointing/CheckpointDiffQuery.ts
+1
@@ -75,6 +75,7 @@ function buildTurnDiffResult(
75
};
76
}
77
78
+/** @public Service construction is part of the canonical Effect module API. */
79
export const make = Effect.gen(function* () {
80
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
81
const checkpointStore = yield* CheckpointStore.CheckpointStore;
apps/server/src/checkpointing/CheckpointStore.ts
+1
@@ -98,6 +98,7 @@ export class CheckpointStore extends Context.Service<
98
}
99
>()("t3/checkpointing/CheckpointStore") {}
100
101
+/** @public Service construction is part of the canonical Effect module API. */
102
export const make = Effect.gen(function* () {
103
const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry;
104
apps/server/src/checkpointing/Utils.ts
+1
-1
@@ -1,7 +1,7 @@
1
import * as Encoding from "effect/Encoding";
2
import { CheckpointRef, ProjectId, type ThreadId } from "@t3tools/contracts";
3
4
-export const CHECKPOINT_REFS_PREFIX = "refs/t3/checkpoints";
4
+const CHECKPOINT_REFS_PREFIX = "refs/t3/checkpoints";
5
6
export function checkpointRefForThreadTurn(threadId: ThreadId, turnCount: number): CheckpointRef {
7
return CheckpointRef.make(
apps/server/src/cli/app.ts
+1
-1
@@ -81,7 +81,7 @@ function isDesktopPlatform(platform: NodeJS.Platform): platform is DesktopAppAct
81
return platform === "darwin" || platform === "linux" || platform === "win32";
82
}
83
84
-export function sendDesktopAppActivationRequest(input: {
84
+function sendDesktopAppActivationRequest(input: {
85
readonly address: string;
86
readonly fallbackAddress?: string;
87
readonly request: DesktopAppActivationRequest;
apps/server/src/cli/config.ts
+2
-2
@@ -17,7 +17,7 @@ import { readBootstrapEnvelope } from "../bootstrap.ts";
17
import * as ServerConfig from "../config.ts";
18
import { expandHomePath, resolveBaseDir } from "../os-jank.ts";
19
20
-export const modeFlag = Flag.choice("mode", ServerConfig.RuntimeMode.literals).pipe(
20
+const modeFlag = Flag.choice("mode", ServerConfig.RuntimeMode.literals).pipe(
21
Flag.withDescription("Runtime mode. `desktop` keeps loopback defaults unless overridden."),
22
Flag.optional,
23
);
@@ -69,7 +69,7 @@ const tailscaleServeFlag = Flag.boolean("tailscale-serve").pipe(
69
),
70
Flag.optional,
71
);
72
-export const tailscaleServePortFlag = Flag.integer("tailscale-serve-port").pipe(
72
+const tailscaleServePortFlag = Flag.integer("tailscale-serve-port").pipe(
73
Flag.withSchema(PortSchema),
74
Flag.withDescription("HTTPS port for Tailscale Serve when --tailscale-serve is enabled."),
75
Flag.optional,
apps/server/src/cli/pair.ts
+1
-1
@@ -173,7 +173,7 @@ export const resolveTailscaleLocalTarget = (
173
return { localPort: state.port };
174
};
175
176
-export const formatPairOutput = (input: {
176
+const formatPairOutput = (input: {
177
readonly serverLabel: string;
178
readonly origin: string;
179
readonly pairingUrl: string;
apps/server/src/cloud/CliTokenManager.ts
+1
@@ -324,6 +324,7 @@ export const outOfBandOAuthLogin = Effect.fn("cloud.cli_token.out_of_band_oauth_
324
});
325
});
326
327
+/** @public Service construction is part of the canonical Effect module API. */
328
export const make = Effect.gen(function* () {
329
// Capture exactly the services the login/refresh flows need at build time
330
// (matching the behavior before the out-of-band flow captured the instances), not
apps/server/src/cloud/ManagedEndpointRuntime.ts
+1
@@ -111,6 +111,7 @@ const stopConnector = (connector: ActiveConnector | null) =>
111
)
112
: Effect.void;
113
114
+/** @public Service construction is part of the canonical Effect module API. */
115
export const make = Effect.gen(function* () {
116
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
117
const relayClient = yield* RelayClient.RelayClient;
apps/server/src/cloud/publicConfig.ts
+4
-4
@@ -49,21 +49,21 @@ function normalizeSecureUrl(value: string): string | null {
49
}
50
}
51
52
-export const buildTimeRelayUrl =
52
+const buildTimeRelayUrl =
53
typeof __T3CODE_BUILD_RELAY_URL__ === "undefined"
54
? ""
55
: (normalizeSecureRelayUrl(__T3CODE_BUILD_RELAY_URL__) ?? "");
56
-export const buildTimeClerkPublishableKey = readBuildTimeValue(
56
+const buildTimeClerkPublishableKey = readBuildTimeValue(
57
typeof __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__ === "undefined"
58
? undefined
59
: __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__,
60
);
61
-export const buildTimeClerkCliOAuthClientId = readBuildTimeValue(
61
+const buildTimeClerkCliOAuthClientId = readBuildTimeValue(
62
typeof __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__ === "undefined"
63
? undefined
64
: __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__,
65
);
66
-export const buildTimeRelayClientTracing = {
66
+const buildTimeRelayClientTracing = {
67
tracesUrl: readBuildTimeValue(
68
typeof __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_URL__ === "undefined"
69
? undefined
apps/server/src/cloud/serviceProtocol.ts
+1
-1
@@ -71,7 +71,7 @@ export const isExactServiceVersion = (version: string): boolean =>
71
const isRecord = (value: unknown): value is Record<string, unknown> =>
72
typeof value === "object" && value !== null && !Array.isArray(value);
73
74
-export function decodeServiceUpdate(value: unknown): ServiceUpdateRecord | undefined {
74
+function decodeServiceUpdate(value: unknown): ServiceUpdateRecord | undefined {
75
if (!isRecord(value)) return undefined;
76
const { id, fromVersion, targetVersion, status } = value;
77
if (
apps/server/src/environment/RemoteOpenTargets.ts
+1
@@ -26,6 +26,7 @@ export class RemoteOpenTargets extends Context.Service<
26
}
27
>()("t3/environment/RemoteOpenTargets") {}
28
29
+/** @public Service construction is part of the canonical Effect module API. */
30
export const make = Effect.gen(function* () {
31
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
32
const net = yield* NetService.NetService;
apps/server/src/environment/ServerEnvironment.ts
+1
@@ -179,6 +179,7 @@ const makeIdentity = Effect.gen(function* () {
179
});
180
});
181
182
+/** @public Service construction is part of the canonical Effect module API. */
183
export const make = Effect.gen(function* () {
184
const path = yield* Path.Path;
185
const serverConfig = yield* ServerConfig.ServerConfig;
apps/server/src/imageMime.ts
+1
-1
@@ -1,6 +1,6 @@
1
import Mime from "@effect/platform-node/Mime";
2
3
-export const IMAGE_EXTENSION_BY_MIME_TYPE: Record<string, string> = {
3
+const IMAGE_EXTENSION_BY_MIME_TYPE: Record<string, string> = {
4
"image/avif": ".avif",
5
"image/bmp": ".bmp",
6
"image/gif": ".gif",
apps/server/src/persistence/AuthPairingLinks.ts
+1
@@ -119,6 +119,7 @@ function toPersistenceSqlOrDecodeError(
119
});
120
}
121
122
+/** @public Service construction is part of the canonical Effect module API. */
123
export const make = Effect.gen(function* () {
124
const sql = yield* SqlClient.SqlClient;
125
apps/server/src/persistence/AuthSessions.ts
+1
@@ -200,6 +200,7 @@ function toPersistenceSqlOrDecodeError(
200
});
201
}
202
203
+/** @public Service construction is part of the canonical Effect module API. */
204
export const make = Effect.gen(function* () {
205
const sql = yield* SqlClient.SqlClient;
206
apps/server/src/persistence/Migrations.ts
+2
-2
@@ -72,7 +72,7 @@ import Migration0049 from "./Migrations/049_ProjectionThreadsActiveOrderKey.ts";
72
* Uses Migrator.fromRecord which parses the key format and
73
* returns migrations sorted by ID.
74
*/
75
-export const migrationEntries = [
75
+const migrationEntries = [
76
[1, "OrchestrationEvents", Migration0001],
77
[2, "OrchestrationCommandReceipts", Migration0002],
78
[3, "CheckpointDiffBlobs", Migration0003],
@@ -126,7 +126,7 @@ export const migrationEntries = [
126
127
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
128
129
-export const makeMigrationLoader = (throughId?: number) =>
129
+const makeMigrationLoader = (throughId?: number) =>
130
Migrator.fromRecord(
131
Object.fromEntries(
132
migrationEntries
apps/server/src/persistence/ProviderSessionRuntime.ts
+1
@@ -166,6 +166,7 @@ function toPersistenceSqlOrDecodeError(
166
});
167
}
168
169
+/** @public Service construction is part of the canonical Effect module API. */
170
export const make = Effect.gen(function* () {
171
const sql = yield* SqlClient.SqlClient;
172
apps/server/src/process/externalLauncher.ts
+1
@@ -752,6 +752,7 @@ const launchEditorProcess = Effect.fn("externalLauncher.launchEditorProcess")(fu
752
);
753
});
754
755
+/** @public Service construction is part of the canonical Effect module API. */
756
export const make = Effect.gen(function* () {
757
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
758
const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/processRunner.ts
+1
@@ -399,6 +399,7 @@ const runProcessCore = Effect.fn("processRunner.runProcessCore")(function* (
399
} satisfies ProcessRunOutput;
400
});
401
402
+/** @public Service construction is part of the canonical Effect module API. */
403
export const make = Effect.fn("ProcessRunner.make")(function* () {
404
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
405
apps/server/src/server.ts
+1
-1
@@ -564,7 +564,7 @@ export const makeRoutesLayer = Layer.mergeAll(
564
Layer.provide(httpCompressionLayer),
565
);
566
567
-export const makeServerLayer = Layer.unwrap(
567
+const makeServerLayer = Layer.unwrap(
568
Effect.gen(function* () {
569
const config = yield* ServerConfig.ServerConfig;
570
const activation = yield* Deferred.make<void>();
apps/server/src/serverRuntimeStartup.ts
+3
-2
@@ -147,7 +147,7 @@ export const makeCommandGate = Effect.gen(function* () {
147
} satisfies CommandGate;
148
});
149
150
-export const recordStartupHeartbeat = Effect.gen(function* () {
150
+const recordStartupHeartbeat = Effect.gen(function* () {
151
const analytics = yield* AnalyticsService.AnalyticsService;
152
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
153
@@ -466,7 +466,7 @@ const clearContinuationMarkers = (
466
{ concurrency: "unbounded", discard: true },
467
);
468
469
-export const clearProviderSessionContinuationMarkers = (threadIds: ReadonlyArray<ThreadId>) =>
469
+const clearProviderSessionContinuationMarkers = (threadIds: ReadonlyArray<ThreadId>) =>
470
Effect.gen(function* () {
471
const directory = yield* ProviderSessionDirectory.ProviderSessionDirectory;
472
yield* clearContinuationMarkers(directory, threadIds);
@@ -803,6 +803,7 @@ export const autoPullProjects = Effect.fn("autoPullProjects")(function* (
803
);
804
});
805
806
+/** @public Service construction is part of the canonical Effect module API. */
807
export const make = (options?: StartupOptions) =>
808
Effect.gen(function* () {
809
const serverConfig = yield* ServerConfig.ServerConfig;
apps/server/src/serverSettings.ts
+1
-1
@@ -142,7 +142,7 @@ function providerEnvironmentSecretName(input: {
142
*/
143
const USAGE_LIMIT_SOURCE_KEY_REDACTED = "\u2022\u2022\u2022\u2022\u2022\u2022";
144
145
-export function usageLimitSourceSecretName(sourceId: string): string {
145
+function usageLimitSourceSecretName(sourceId: string): string {
146
return `usage-limit-source-${Buffer.from(sourceId, "utf8").toString("base64url")}`;
147
}
148