authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-08 01:11:08-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-08 01:11:08-07:00
log6f4cd07b900299629b9f2f9a9336f5c090556a51
tree2481fd6b1962b83c27cf209f7a74e1059aa18426
parent11601da846e7d82db63a6f4773e3a02421619b60
signature Signed by PGP key B5690EEEBB952194

refactor(server): classify runtime exports (#10274)


32 files changed, 40 insertions(+), 28 deletions(-)

apps/server/scripts/t3-sqlite-state.ts+1-1
......@@ -245,7 +245,7 @@ export const runSqliteState = Effect.fn("runSqliteState")(function* (
245245 );
246246});
247247
248export const t3SqliteStateCommand = Command.make(
248const t3SqliteStateCommand = Command.make(
249249 "t3-sqlite-state",
250250 {
251251 operation: Argument.choice("operation", SqliteStateOperation.literals).pipe(
apps/server/src/attachmentStore.ts+1-1
......@@ -22,7 +22,7 @@ const ATTACHMENT_ID_PATTERN = new RegExp(
2222);
2323
2424export const PENDING_ATTACHMENT_THREAD_SEGMENT = "pending";
25export const PENDING_ATTACHMENT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
25const PENDING_ATTACHMENT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
2626const PARTIAL_UPLOAD_MAX_AGE_MS = 60 * 60 * 1000;
2727
2828export function toSafeThreadAttachmentSegment(threadId: string): string | null {
apps/server/src/auth/EnvironmentAuth.ts+3-2
......@@ -38,7 +38,7 @@ import * as SessionStore from "./SessionStore.ts";
3838import { verifyRequestDpopProof } from "./dpop.ts";
3939import { layerConfig as SqlitePersistenceLayer } from "../persistence/Layers/Sqlite.ts";
4040
41export const DEFAULT_SESSION_SUBJECT = "cli-issued-session";
41const DEFAULT_SESSION_SUBJECT = "cli-issued-session";
4242export const INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT = "administrative-bootstrap";
4343
4444export interface IssuedPairingLink {
......@@ -591,6 +591,7 @@ export function selectRequestCredential(
591591 return undefined;
592592}
593593
594/** @public Service construction is part of the canonical Effect module API. */
594595export const make = Effect.gen(function* () {
595596 const policy = yield* EnvironmentAuthPolicy.EnvironmentAuthPolicy;
596597 const bootstrapCredentials = yield* PairingGrantStore.PairingGrantStore;
......@@ -1033,7 +1034,7 @@ export const layer = Layer.effect(EnvironmentAuth, make).pipe(
10331034 Layer.provideMerge(EnvironmentAuthPolicy.layer),
10341035);
10351036
1036export const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistenceLayer);
1037const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistenceLayer);
10371038
10381039export const runtimeLayer = layer.pipe(
10391040 Layer.provideMerge(storageLayer),
apps/server/src/auth/EnvironmentAuthPolicy.ts+1
......@@ -14,6 +14,7 @@ export class EnvironmentAuthPolicy extends Context.Service<
1414 }
1515>()("t3/auth/EnvironmentAuthPolicy") {}
1616
17/** @public Service construction is part of the canonical Effect module API. */
1718export const make = Effect.gen(function* () {
1819 const config = yield* ServerConfig.ServerConfig;
1920 const serverEnvironment = yield* ServerEnvironment.ServerEnvironmentIdentity;
apps/server/src/auth/PairingGrantStore.ts-2
......@@ -72,7 +72,6 @@ export const BootstrapCredentialInvalidError = Schema.Union([
7272 UnavailableBootstrapCredentialError,
7373]);
7474export type BootstrapCredentialInvalidError = typeof BootstrapCredentialInvalidError.Type;
75export const isBootstrapCredentialInvalidError = Schema.is(BootstrapCredentialInvalidError);
7675
7776export class ActivePairingLinksLoadError extends Schema.TaggedError<ActivePairingLinksLoadError>()(
7877 "ActivePairingLinksLoadError",
......@@ -173,7 +172,6 @@ export const BootstrapCredentialError = Schema.Union([
173172 BootstrapCredentialInternalError,
174173]);
175174export type BootstrapCredentialError = typeof BootstrapCredentialError.Type;
176export const isBootstrapCredentialError = Schema.is(BootstrapCredentialError);
177175
178176export interface IssuedBootstrapCredential {
179177 readonly id: string;
apps/server/src/auth/ServerSecretStore.ts+1
......@@ -149,6 +149,7 @@ export class ServerSecretStore extends Context.Service<
149149 }
150150>()("t3/auth/ServerSecretStore") {}
151151
152/** @public Service construction is part of the canonical Effect module API. */
152153export const make = Effect.gen(function* () {
153154 const crypto = yield* Crypto.Crypto;
154155 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/auth/SessionStore.ts-2
......@@ -349,14 +349,12 @@ export const SessionCredentialInternalError = Schema.Union([
349349 OtherSessionsRevocationError,
350350]);
351351export type SessionCredentialInternalError = typeof SessionCredentialInternalError.Type;
352export const isSessionCredentialInternalError = Schema.is(SessionCredentialInternalError);
353352
354353export const SessionCredentialError = Schema.Union([
355354 SessionCredentialInvalidError,
356355 SessionCredentialInternalError,
357356]);
358357export type SessionCredentialError = typeof SessionCredentialError.Type;
359export const isSessionCredentialError = Schema.is(SessionCredentialError);
360358
361359export class SessionStore extends Context.Service<
362360 SessionStore,
apps/server/src/auth/http.ts+1-1
......@@ -65,7 +65,7 @@ const appendDpopChallengeOnUnauthorized = (error: EnvironmentAuthInvalidError) =
6565 return yield* error;
6666 });
6767
68export const currentEnvironmentTraceId = Effect.currentParentSpan.pipe(
68const currentEnvironmentTraceId = Effect.currentParentSpan.pipe(
6969 Effect.map((span) => span.traceId),
7070 Effect.orElseSucceed(() => "unavailable"),
7171);
apps/server/src/background/BackgroundPolicy.ts+2-1
......@@ -82,7 +82,7 @@ function leaseKey(lease: Pick<ClientActivityLease, "sessionId" | "rpcClientId" |
8282 return JSON.stringify([lease.sessionId, lease.rpcClientId, lease.clientId]);
8383}
8484
85export function upsertClientActivityLease(
85function upsertClientActivityLease(
8686 leases: ReadonlyMap<string, ClientActivityLease>,
8787 lease: ClientActivityLease,
8888 now: DateTime.Utc,
......@@ -208,6 +208,7 @@ function computeSnapshot(input: {
208208 };
209209}
210210
211/** @public Service construction is part of the canonical Effect module API. */
211212export const make = Effect.fn("background.policy.make")(function* () {
212213 const hostPowerMonitor = yield* HostPowerMonitor.HostPowerMonitor;
213214 const serverSettings = yield* ServerSettingsService;
apps/server/src/background/HostPowerMonitor.ts+1-1
......@@ -19,7 +19,7 @@ export class HostPowerMonitor extends Context.Service<
1919 }
2020>()("t3/background/HostPowerMonitor") {}
2121
22export const makeUnknownSnapshot = (
22const makeUnknownSnapshot = (
2323 source: HostPowerSnapshot["source"],
2424 updatedAt: HostPowerSnapshot["updatedAt"],
2525): HostPowerSnapshot => ({
apps/server/src/checkpointing/CheckpointDiffQuery.ts+1
......@@ -75,6 +75,7 @@ function buildTurnDiffResult(
7575 };
7676}
7777
78/** @public Service construction is part of the canonical Effect module API. */
7879export const make = Effect.gen(function* () {
7980 const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
8081 const checkpointStore = yield* CheckpointStore.CheckpointStore;
apps/server/src/checkpointing/CheckpointStore.ts+1
......@@ -98,6 +98,7 @@ export class CheckpointStore extends Context.Service<
9898 }
9999>()("t3/checkpointing/CheckpointStore") {}
100100
101/** @public Service construction is part of the canonical Effect module API. */
101102export const make = Effect.gen(function* () {
102103 const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry;
103104
apps/server/src/checkpointing/Utils.ts+1-1
......@@ -1,7 +1,7 @@
11import * as Encoding from "effect/Encoding";
22import { CheckpointRef, ProjectId, type ThreadId } from "@t3tools/contracts";
33
4export const CHECKPOINT_REFS_PREFIX = "refs/t3/checkpoints";
4const CHECKPOINT_REFS_PREFIX = "refs/t3/checkpoints";
55
66export function checkpointRefForThreadTurn(threadId: ThreadId, turnCount: number): CheckpointRef {
77 return CheckpointRef.make(
apps/server/src/cli/app.ts+1-1
......@@ -81,7 +81,7 @@ function isDesktopPlatform(platform: NodeJS.Platform): platform is DesktopAppAct
8181 return platform === "darwin" || platform === "linux" || platform === "win32";
8282}
8383
84export function sendDesktopAppActivationRequest(input: {
84function sendDesktopAppActivationRequest(input: {
8585 readonly address: string;
8686 readonly fallbackAddress?: string;
8787 readonly request: DesktopAppActivationRequest;
apps/server/src/cli/config.ts+2-2
......@@ -17,7 +17,7 @@ import { readBootstrapEnvelope } from "../bootstrap.ts";
1717import * as ServerConfig from "../config.ts";
1818import { expandHomePath, resolveBaseDir } from "../os-jank.ts";
1919
20export const modeFlag = Flag.choice("mode", ServerConfig.RuntimeMode.literals).pipe(
20const modeFlag = Flag.choice("mode", ServerConfig.RuntimeMode.literals).pipe(
2121 Flag.withDescription("Runtime mode. `desktop` keeps loopback defaults unless overridden."),
2222 Flag.optional,
2323);
......@@ -69,7 +69,7 @@ const tailscaleServeFlag = Flag.boolean("tailscale-serve").pipe(
6969 ),
7070 Flag.optional,
7171);
72export const tailscaleServePortFlag = Flag.integer("tailscale-serve-port").pipe(
72const tailscaleServePortFlag = Flag.integer("tailscale-serve-port").pipe(
7373 Flag.withSchema(PortSchema),
7474 Flag.withDescription("HTTPS port for Tailscale Serve when --tailscale-serve is enabled."),
7575 Flag.optional,
apps/server/src/cli/pair.ts+1-1
......@@ -173,7 +173,7 @@ export const resolveTailscaleLocalTarget = (
173173 return { localPort: state.port };
174174};
175175
176export const formatPairOutput = (input: {
176const formatPairOutput = (input: {
177177 readonly serverLabel: string;
178178 readonly origin: string;
179179 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_
324324 });
325325});
326326
327/** @public Service construction is part of the canonical Effect module API. */
327328export const make = Effect.gen(function* () {
328329 // Capture exactly the services the login/refresh flows need at build time
329330 // (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) =>
111111 )
112112 : Effect.void;
113113
114/** @public Service construction is part of the canonical Effect module API. */
114115export const make = Effect.gen(function* () {
115116 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
116117 const relayClient = yield* RelayClient.RelayClient;
apps/server/src/cloud/publicConfig.ts+4-4
......@@ -49,21 +49,21 @@ function normalizeSecureUrl(value: string): string | null {
4949 }
5050}
5151
52export const buildTimeRelayUrl =
52const buildTimeRelayUrl =
5353 typeof __T3CODE_BUILD_RELAY_URL__ === "undefined"
5454 ? ""
5555 : (normalizeSecureRelayUrl(__T3CODE_BUILD_RELAY_URL__) ?? "");
56export const buildTimeClerkPublishableKey = readBuildTimeValue(
56const buildTimeClerkPublishableKey = readBuildTimeValue(
5757 typeof __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__ === "undefined"
5858 ? undefined
5959 : __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__,
6060);
61export const buildTimeClerkCliOAuthClientId = readBuildTimeValue(
61const buildTimeClerkCliOAuthClientId = readBuildTimeValue(
6262 typeof __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__ === "undefined"
6363 ? undefined
6464 : __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__,
6565);
66export const buildTimeRelayClientTracing = {
66const buildTimeRelayClientTracing = {
6767 tracesUrl: readBuildTimeValue(
6868 typeof __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_URL__ === "undefined"
6969 ? undefined
apps/server/src/cloud/serviceProtocol.ts+1-1
......@@ -71,7 +71,7 @@ export const isExactServiceVersion = (version: string): boolean =>
7171const isRecord = (value: unknown): value is Record<string, unknown> =>
7272 typeof value === "object" && value !== null && !Array.isArray(value);
7373
74export function decodeServiceUpdate(value: unknown): ServiceUpdateRecord | undefined {
74function decodeServiceUpdate(value: unknown): ServiceUpdateRecord | undefined {
7575 if (!isRecord(value)) return undefined;
7676 const { id, fromVersion, targetVersion, status } = value;
7777 if (
apps/server/src/environment/RemoteOpenTargets.ts+1
......@@ -26,6 +26,7 @@ export class RemoteOpenTargets extends Context.Service<
2626 }
2727>()("t3/environment/RemoteOpenTargets") {}
2828
29/** @public Service construction is part of the canonical Effect module API. */
2930export const make = Effect.gen(function* () {
3031 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3132 const net = yield* NetService.NetService;
apps/server/src/environment/ServerEnvironment.ts+1
......@@ -179,6 +179,7 @@ const makeIdentity = Effect.gen(function* () {
179179 });
180180});
181181
182/** @public Service construction is part of the canonical Effect module API. */
182183export const make = Effect.gen(function* () {
183184 const path = yield* Path.Path;
184185 const serverConfig = yield* ServerConfig.ServerConfig;
apps/server/src/imageMime.ts+1-1
......@@ -1,6 +1,6 @@
11import Mime from "@effect/platform-node/Mime";
22
3export const IMAGE_EXTENSION_BY_MIME_TYPE: Record<string, string> = {
3const IMAGE_EXTENSION_BY_MIME_TYPE: Record<string, string> = {
44 "image/avif": ".avif",
55 "image/bmp": ".bmp",
66 "image/gif": ".gif",
apps/server/src/persistence/AuthPairingLinks.ts+1
......@@ -119,6 +119,7 @@ function toPersistenceSqlOrDecodeError(
119119 });
120120}
121121
122/** @public Service construction is part of the canonical Effect module API. */
122123export const make = Effect.gen(function* () {
123124 const sql = yield* SqlClient.SqlClient;
124125
apps/server/src/persistence/AuthSessions.ts+1
......@@ -200,6 +200,7 @@ function toPersistenceSqlOrDecodeError(
200200 });
201201}
202202
203/** @public Service construction is part of the canonical Effect module API. */
203204export const make = Effect.gen(function* () {
204205 const sql = yield* SqlClient.SqlClient;
205206
apps/server/src/persistence/Migrations.ts+2-2
......@@ -72,7 +72,7 @@ import Migration0049 from "./Migrations/049_ProjectionThreadsActiveOrderKey.ts";
7272 * Uses Migrator.fromRecord which parses the key format and
7373 * returns migrations sorted by ID.
7474 */
75export const migrationEntries = [
75const migrationEntries = [
7676 [1, "OrchestrationEvents", Migration0001],
7777 [2, "OrchestrationCommandReceipts", Migration0002],
7878 [3, "CheckpointDiffBlobs", Migration0003],
......@@ -126,7 +126,7 @@ export const migrationEntries = [
126126
127127export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
128128
129export const makeMigrationLoader = (throughId?: number) =>
129const makeMigrationLoader = (throughId?: number) =>
130130 Migrator.fromRecord(
131131 Object.fromEntries(
132132 migrationEntries
apps/server/src/persistence/ProviderSessionRuntime.ts+1
......@@ -166,6 +166,7 @@ function toPersistenceSqlOrDecodeError(
166166 });
167167}
168168
169/** @public Service construction is part of the canonical Effect module API. */
169170export const make = Effect.gen(function* () {
170171 const sql = yield* SqlClient.SqlClient;
171172
apps/server/src/process/externalLauncher.ts+1
......@@ -752,6 +752,7 @@ const launchEditorProcess = Effect.fn("externalLauncher.launchEditorProcess")(fu
752752 );
753753});
754754
755/** @public Service construction is part of the canonical Effect module API. */
755756export const make = Effect.gen(function* () {
756757 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
757758 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/processRunner.ts+1
......@@ -399,6 +399,7 @@ const runProcessCore = Effect.fn("processRunner.runProcessCore")(function* (
399399 } satisfies ProcessRunOutput;
400400});
401401
402/** @public Service construction is part of the canonical Effect module API. */
402403export const make = Effect.fn("ProcessRunner.make")(function* () {
403404 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
404405
apps/server/src/server.ts+1-1
......@@ -564,7 +564,7 @@ export const makeRoutesLayer = Layer.mergeAll(
564564 Layer.provide(httpCompressionLayer),
565565);
566566
567export const makeServerLayer = Layer.unwrap(
567const makeServerLayer = Layer.unwrap(
568568 Effect.gen(function* () {
569569 const config = yield* ServerConfig.ServerConfig;
570570 const activation = yield* Deferred.make<void>();
apps/server/src/serverRuntimeStartup.ts+3-2
......@@ -147,7 +147,7 @@ export const makeCommandGate = Effect.gen(function* () {
147147 } satisfies CommandGate;
148148});
149149
150export const recordStartupHeartbeat = Effect.gen(function* () {
150const recordStartupHeartbeat = Effect.gen(function* () {
151151 const analytics = yield* AnalyticsService.AnalyticsService;
152152 const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
153153
......@@ -466,7 +466,7 @@ const clearContinuationMarkers = (
466466 { concurrency: "unbounded", discard: true },
467467 );
468468
469export const clearProviderSessionContinuationMarkers = (threadIds: ReadonlyArray<ThreadId>) =>
469const clearProviderSessionContinuationMarkers = (threadIds: ReadonlyArray<ThreadId>) =>
470470 Effect.gen(function* () {
471471 const directory = yield* ProviderSessionDirectory.ProviderSessionDirectory;
472472 yield* clearContinuationMarkers(directory, threadIds);
......@@ -803,6 +803,7 @@ export const autoPullProjects = Effect.fn("autoPullProjects")(function* (
803803 );
804804});
805805
806/** @public Service construction is part of the canonical Effect module API. */
806807export const make = (options?: StartupOptions) =>
807808 Effect.gen(function* () {
808809 const serverConfig = yield* ServerConfig.ServerConfig;
apps/server/src/serverSettings.ts+1-1
......@@ -142,7 +142,7 @@ function providerEnvironmentSecretName(input: {
142142 */
143143const USAGE_LIMIT_SOURCE_KEY_REDACTED = "\u2022\u2022\u2022\u2022\u2022\u2022";
144144
145export function usageLimitSourceSecretName(sourceId: string): string {
145function usageLimitSourceSecretName(sourceId: string): string {
146146 return `usage-limit-source-${Buffer.from(sourceId, "utf8").toString("base64url")}`;
147147}
148148