From 8fa645410f8542a08643fa55365ee4174e1d4d19 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Sat, 5 Sep 2026 09:51:51 -0700 Subject: [PATCH 1/2] refactor(contracts): keep domain schema internals private --- .../src/checkpointing/CheckpointDiffQuery.ts | 4 +- packages/contracts/src/git.ts | 18 ++-- packages/contracts/src/model.ts | 24 ++--- packages/contracts/src/orchestration.ts | 49 +++++----- packages/contracts/src/project.ts | 4 +- packages/contracts/src/providerInstance.ts | 5 +- packages/contracts/src/pullRequest.ts | 12 +-- packages/contracts/src/relay.ts | 94 +++++++++---------- packages/contracts/src/relayClient.ts | 4 +- packages/contracts/src/resourceTelemetry.ts | 58 ++++++------ packages/contracts/src/settings.ts | 48 +++++----- packages/contracts/src/sourceControl.ts | 12 +-- packages/contracts/src/terminal.ts | 2 +- packages/contracts/src/usage.ts | 8 +- packages/contracts/src/vcs.ts | 16 ++-- 15 files changed, 172 insertions(+), 186 deletions(-) diff --git a/apps/server/src/checkpointing/CheckpointDiffQuery.ts b/apps/server/src/checkpointing/CheckpointDiffQuery.ts index 077506ff3a84..2647891c363b 100644 --- a/apps/server/src/checkpointing/CheckpointDiffQuery.ts +++ b/apps/server/src/checkpointing/CheckpointDiffQuery.ts @@ -8,7 +8,7 @@ */ import { type CheckpointRef, - OrchestrationGetTurnDiffResult, + ThreadTurnDiff, type OrchestrationGetFullThreadDiffInput, type OrchestrationGetFullThreadDiffResult, type OrchestrationGetTurnDiffInput, @@ -57,7 +57,7 @@ export class CheckpointDiffQuery extends Context.Service< } >()("t3/checkpointing/CheckpointDiffQuery") {} -const isTurnDiffResult = Schema.is(OrchestrationGetTurnDiffResult); +const isTurnDiffResult = Schema.is(ThreadTurnDiff); function buildTurnDiffResult( input: { diff --git a/packages/contracts/src/git.ts b/packages/contracts/src/git.ts index 4b63b877923f..0de86d554107 100644 --- a/packages/contracts/src/git.ts +++ b/packages/contracts/src/git.ts @@ -19,7 +19,7 @@ export const GitStackedAction = Schema.Literals([ export type GitStackedAction = typeof GitStackedAction.Type; export const GitActionProgressPhase = Schema.Literals(["branch", "commit", "push", "pr"]); export type GitActionProgressPhase = typeof GitActionProgressPhase.Type; -export const GitActionProgressKind = Schema.Literals([ +const GitActionProgressKind = Schema.Literals([ "action_started", "phase_started", "hook_started", @@ -28,9 +28,9 @@ export const GitActionProgressKind = Schema.Literals([ "action_finished", "action_failed", ]); -export type GitActionProgressKind = typeof GitActionProgressKind.Type; -export const GitActionProgressStream = Schema.Literals(["stdout", "stderr"]); -export type GitActionProgressStream = typeof GitActionProgressStream.Type; +type GitActionProgressKind = typeof GitActionProgressKind.Type; +const GitActionProgressStream = Schema.Literals(["stdout", "stderr"]); +type GitActionProgressStream = typeof GitActionProgressStream.Type; const GitCommitStepStatus = Schema.Literals([ "created", "skipped_no_changes", @@ -47,10 +47,10 @@ const VcsStatusChangeRequestState = Schema.Literals(["open", "closed", "merged"] const GitPullRequestReference = TrimmedNonEmptyStringSchema; const GitPullRequestState = Schema.Literals(["open", "closed", "merged"]); const GitPreparePullRequestThreadMode = Schema.Literals(["local", "worktree"]); -export const GitRunStackedActionToastRunAction = Schema.Struct({ +const GitRunStackedActionToastRunAction = Schema.Struct({ kind: GitStackedAction, }); -export type GitRunStackedActionToastRunAction = typeof GitRunStackedActionToastRunAction.Type; +type GitRunStackedActionToastRunAction = typeof GitRunStackedActionToastRunAction.Type; const GitRunStackedActionToastCta = Schema.Union([ Schema.Struct({ kind: Schema.Literal("none"), @@ -66,13 +66,13 @@ const GitRunStackedActionToastCta = Schema.Union([ action: GitRunStackedActionToastRunAction, }), ]); -export type GitRunStackedActionToastCta = typeof GitRunStackedActionToastCta.Type; +type GitRunStackedActionToastCta = typeof GitRunStackedActionToastCta.Type; const GitRunStackedActionToast = Schema.Struct({ title: TrimmedNonEmptyStringSchema, description: Schema.optional(TrimmedNonEmptyStringSchema), cta: GitRunStackedActionToastCta, }); -export type GitRunStackedActionToast = typeof GitRunStackedActionToast.Type; +type GitRunStackedActionToast = typeof GitRunStackedActionToast.Type; export const VcsRef = Schema.Struct({ name: TrimmedNonEmptyStringSchema, @@ -96,7 +96,7 @@ const GitResolvedPullRequest = Schema.Struct({ headBranch: TrimmedNonEmptyStringSchema, state: GitPullRequestState, }); -export type GitResolvedPullRequest = typeof GitResolvedPullRequest.Type; +type GitResolvedPullRequest = typeof GitResolvedPullRequest.Type; // RPC Inputs diff --git a/packages/contracts/src/model.ts b/packages/contracts/src/model.ts index bce1a766bc9b..47b904cd7603 100644 --- a/packages/contracts/src/model.ts +++ b/packages/contracts/src/model.ts @@ -4,16 +4,16 @@ import * as SchemaTransformation from "effect/SchemaTransformation"; import { TrimmedNonEmptyString } from "./baseSchemas.ts"; import { ProviderDriverKind } from "./providerInstance.ts"; -export const ProviderOptionDescriptorType = Schema.Literals(["select", "boolean"]); -export type ProviderOptionDescriptorType = typeof ProviderOptionDescriptorType.Type; +const ProviderOptionDescriptorType = Schema.Literals(["select", "boolean"]); +type ProviderOptionDescriptorType = typeof ProviderOptionDescriptorType.Type; -export const ProviderOptionChoice = Schema.Struct({ +const ProviderOptionChoice = Schema.Struct({ id: TrimmedNonEmptyString, label: TrimmedNonEmptyString, description: Schema.optional(TrimmedNonEmptyString), isDefault: Schema.optional(Schema.Boolean), }); -export type ProviderOptionChoice = typeof ProviderOptionChoice.Type; +type ProviderOptionChoice = typeof ProviderOptionChoice.Type; const ProviderOptionDescriptorBase = { id: TrimmedNonEmptyString, @@ -21,21 +21,21 @@ const ProviderOptionDescriptorBase = { description: Schema.optional(TrimmedNonEmptyString), } as const; -export const SelectProviderOptionDescriptor = Schema.Struct({ +const SelectProviderOptionDescriptor = Schema.Struct({ ...ProviderOptionDescriptorBase, type: Schema.Literal("select"), options: Schema.Array(ProviderOptionChoice), currentValue: Schema.optional(TrimmedNonEmptyString), promptInjectedValues: Schema.optional(Schema.Array(TrimmedNonEmptyString)), }); -export type SelectProviderOptionDescriptor = typeof SelectProviderOptionDescriptor.Type; +type SelectProviderOptionDescriptor = typeof SelectProviderOptionDescriptor.Type; -export const BooleanProviderOptionDescriptor = Schema.Struct({ +const BooleanProviderOptionDescriptor = Schema.Struct({ ...ProviderOptionDescriptorBase, type: Schema.Literal("boolean"), currentValue: Schema.optional(Schema.Boolean), }); -export type BooleanProviderOptionDescriptor = typeof BooleanProviderOptionDescriptor.Type; +type BooleanProviderOptionDescriptor = typeof BooleanProviderOptionDescriptor.Type; export const ProviderOptionDescriptor = Schema.Union([ SelectProviderOptionDescriptor, @@ -43,8 +43,8 @@ export const ProviderOptionDescriptor = Schema.Union([ ]); export type ProviderOptionDescriptor = typeof ProviderOptionDescriptor.Type; -export const ProviderOptionSelectionValue = Schema.Union([TrimmedNonEmptyString, Schema.Boolean]); -export type ProviderOptionSelectionValue = typeof ProviderOptionSelectionValue.Type; +const ProviderOptionSelectionValue = Schema.Union([TrimmedNonEmptyString, Schema.Boolean]); +type ProviderOptionSelectionValue = typeof ProviderOptionSelectionValue.Type; export const ProviderOptionSelection = Schema.Struct({ id: TrimmedNonEmptyString, @@ -132,12 +132,12 @@ export type ModelCapabilities = typeof ModelCapabilities.Type; * bare slug keeps its driver-default presentation; when `capabilities` is * set, its descriptors replace the driver default in the model picker. */ -export const CustomModelEntry = Schema.Struct({ +const CustomModelEntry = Schema.Struct({ slug: TrimmedNonEmptyString, name: Schema.optional(TrimmedNonEmptyString), capabilities: Schema.optional(ModelCapabilities), }); -export type CustomModelEntry = typeof CustomModelEntry.Type; +type CustomModelEntry = typeof CustomModelEntry.Type; /** On-disk custom model setting: the legacy bare slug, or a full entry. */ export const CustomModelSetting = Schema.Union([Schema.String, CustomModelEntry]); diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts index 92e9fe01dd42..2503f0768d7d 100644 --- a/packages/contracts/src/orchestration.ts +++ b/packages/contracts/src/orchestration.ts @@ -183,7 +183,7 @@ const ChatAttachmentId = TrimmedNonEmptyString.check( Schema.isMaxLength(CHAT_ATTACHMENT_ID_MAX_CHARS), Schema.isPattern(/^[a-z0-9_-]+$/i), ); -export type ChatAttachmentId = typeof ChatAttachmentId.Type; +type ChatAttachmentId = typeof ChatAttachmentId.Type; export const ChatImageAttachment = Schema.Struct({ type: Schema.Literal("image"), @@ -246,7 +246,7 @@ export const ChatAttachment = Schema.Union([ ]); export type ChatAttachment = typeof ChatAttachment.Type; const UploadChatAttachment = Schema.Union([UploadChatImageAttachment]); -export type UploadChatAttachment = typeof UploadChatAttachment.Type; +type UploadChatAttachment = typeof UploadChatAttachment.Type; export const ProjectScriptIcon = Schema.Literals([ "play", @@ -455,7 +455,7 @@ const OrchestrationLatestTurnState = Schema.Literals([ "completed", "error", ]); -export type OrchestrationLatestTurnState = typeof OrchestrationLatestTurnState.Type; +type OrchestrationLatestTurnState = typeof OrchestrationLatestTurnState.Type; export const OrchestrationLatestTurn = Schema.Struct({ turnId: TurnId, @@ -468,11 +468,11 @@ export const OrchestrationLatestTurn = Schema.Struct({ }); export type OrchestrationLatestTurn = typeof OrchestrationLatestTurn.Type; -export const ThreadTitleRegeneration = Schema.Struct({ +const ThreadTitleRegeneration = Schema.Struct({ requestId: CommandId, startedAt: IsoDateTime, }); -export type ThreadTitleRegeneration = typeof ThreadTitleRegeneration.Type; +type ThreadTitleRegeneration = typeof ThreadTitleRegeneration.Type; export const ThreadLinkedPullRequest = Schema.Struct({ projectId: ProjectId, @@ -659,7 +659,7 @@ export const OrchestrationShellStreamItem = Schema.Union([ ]); export type OrchestrationShellStreamItem = typeof OrchestrationShellStreamItem.Type; -export const OrchestrationSubscribeShellInput = Schema.Struct({ +const OrchestrationSubscribeShellInput = Schema.Struct({ /** * When provided, the server skips the initial full shell snapshot and instead * replays shell events after this sequence before streaming live events. @@ -675,9 +675,9 @@ export const OrchestrationSubscribeShellInput = Schema.Struct({ */ requestCompletionMarker: Schema.optionalKey(Schema.Boolean), }); -export type OrchestrationSubscribeShellInput = typeof OrchestrationSubscribeShellInput.Type; +type OrchestrationSubscribeShellInput = typeof OrchestrationSubscribeShellInput.Type; -export const OrchestrationSubscribeThreadInput = Schema.Struct({ +const OrchestrationSubscribeThreadInput = Schema.Struct({ threadId: ThreadId, /** * When provided, the server skips the initial snapshot frame and instead @@ -701,7 +701,7 @@ export const OrchestrationSubscribeThreadInput = Schema.Struct({ */ turnLimit: Schema.optionalKey(PositiveInt), }); -export type OrchestrationSubscribeThreadInput = typeof OrchestrationSubscribeThreadInput.Type; +type OrchestrationSubscribeThreadInput = typeof OrchestrationSubscribeThreadInput.Type; /** * Bounds a thread detail read to a window of recent turns. `turnLimit` counts @@ -952,7 +952,7 @@ const ThreadTurnStartBootstrap = Schema.Struct({ runSetupScript: Schema.optional(Schema.Boolean), }); -export type ThreadTurnStartBootstrap = typeof ThreadTurnStartBootstrap.Type; +type ThreadTurnStartBootstrap = typeof ThreadTurnStartBootstrap.Type; export const ThreadTurnStartCommand = Schema.Struct({ type: Schema.Literal("thread.turn.start"), @@ -1066,8 +1066,7 @@ const DispatchableClientOrchestrationCommand = Schema.Union([ ThreadCheckpointRevertCommand, ThreadSessionStopCommand, ]); -export type DispatchableClientOrchestrationCommand = - typeof DispatchableClientOrchestrationCommand.Type; +type DispatchableClientOrchestrationCommand = typeof DispatchableClientOrchestrationCommand.Type; export const ClientOrchestrationCommand = Schema.Union([ ProjectCreateCommand, @@ -1195,7 +1194,7 @@ const InternalOrchestrationCommand = Schema.Union([ ThreadRevertCompleteCommand, ThreadTitleRegenerationCompleteCommand, ]); -export type InternalOrchestrationCommand = typeof InternalOrchestrationCommand.Type; +type InternalOrchestrationCommand = typeof InternalOrchestrationCommand.Type; export const OrchestrationCommand = Schema.Union([ DispatchableClientOrchestrationCommand, @@ -1673,7 +1672,7 @@ export type OrchestrationThreadStreamItem = typeof OrchestrationThreadStreamItem export const OrchestrationCommandReceiptStatus = Schema.Literals(["accepted", "rejected"]); export type OrchestrationCommandReceiptStatus = typeof OrchestrationCommandReceiptStatus.Type; -export const TurnCountRange = Schema.Struct({ +const TurnCountRange = Schema.Struct({ fromTurnCount: NonNegativeInt, toTurnCount: NonNegativeInt, }).check( @@ -1709,7 +1708,7 @@ const ProjectionThreadTurnStatus = Schema.Literals([ "interrupted", "error", ]); -export type ProjectionThreadTurnStatus = typeof ProjectionThreadTurnStatus.Type; +type ProjectionThreadTurnStatus = typeof ProjectionThreadTurnStatus.Type; const ProjectionCheckpointRow = Schema.Struct({ threadId: ThreadId, @@ -1721,7 +1720,7 @@ const ProjectionCheckpointRow = Schema.Struct({ assistantMessageId: Schema.NullOr(MessageId), completedAt: IsoDateTime, }); -export type ProjectionCheckpointRow = typeof ProjectionCheckpointRow.Type; +type ProjectionCheckpointRow = typeof ProjectionCheckpointRow.Type; export const ProjectionPendingApprovalStatus = Schema.Literals(["pending", "resolved"]); export type ProjectionPendingApprovalStatus = typeof ProjectionPendingApprovalStatus.Type; @@ -1743,8 +1742,7 @@ export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields( ); export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type; -export const OrchestrationGetTurnDiffResult = ThreadTurnDiff; -export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResult.Type; +export type OrchestrationGetTurnDiffResult = typeof ThreadTurnDiff.Type; export const OrchestrationGetFullThreadDiffInput = Schema.Struct({ threadId: ThreadId, @@ -1753,8 +1751,7 @@ export const OrchestrationGetFullThreadDiffInput = Schema.Struct({ }); export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type; -export const OrchestrationGetFullThreadDiffResult = ThreadTurnDiff; -export type OrchestrationGetFullThreadDiffResult = typeof OrchestrationGetFullThreadDiffResult.Type; +export type OrchestrationGetFullThreadDiffResult = typeof ThreadTurnDiff.Type; export const OrchestrationThreadSearchSource = Schema.Literals(["user", "assistant"]); export type OrchestrationThreadSearchSource = typeof OrchestrationThreadSearchSource.Type; @@ -1781,20 +1778,20 @@ export const OrchestrationSearchThreadsResult = Schema.Struct({ }); export type OrchestrationSearchThreadsResult = typeof OrchestrationSearchThreadsResult.Type; -export const OrchestrationGetWorkflowScriptInput = Schema.Struct({ +const OrchestrationGetWorkflowScriptInput = Schema.Struct({ threadId: ThreadId, /** Absolute path from the workflow's runHandles.scriptPath. The server * re-derives containment; the client value is a hint, never trusted. */ scriptPath: TrimmedNonEmptyString, }); -export type OrchestrationGetWorkflowScriptInput = typeof OrchestrationGetWorkflowScriptInput.Type; +type OrchestrationGetWorkflowScriptInput = typeof OrchestrationGetWorkflowScriptInput.Type; -export const OrchestrationGetWorkflowScriptResult = Schema.Struct({ +const OrchestrationGetWorkflowScriptResult = Schema.Struct({ scriptPath: TrimmedNonEmptyString, contents: Schema.String, truncated: Schema.Boolean, }); -export type OrchestrationGetWorkflowScriptResult = typeof OrchestrationGetWorkflowScriptResult.Type; +type OrchestrationGetWorkflowScriptResult = typeof OrchestrationGetWorkflowScriptResult.Type; const WORKFLOW_SCRIPT_ERROR_MESSAGES = { "invalid-path": "Workflow scripts must be absolute .js paths.", @@ -1840,11 +1837,11 @@ export const OrchestrationRpcSchemas = { }, getTurnDiff: { input: OrchestrationGetTurnDiffInput, - output: OrchestrationGetTurnDiffResult, + output: ThreadTurnDiff, }, getFullThreadDiff: { input: OrchestrationGetFullThreadDiffInput, - output: OrchestrationGetFullThreadDiffResult, + output: ThreadTurnDiff, }, searchThreads: { input: OrchestrationSearchThreadsInput, diff --git a/packages/contracts/src/project.ts b/packages/contracts/src/project.ts index 12f29b5e4ab3..4a6b27ccf664 100644 --- a/packages/contracts/src/project.ts +++ b/packages/contracts/src/project.ts @@ -49,11 +49,11 @@ export const ProjectSearchContentsInput = Schema.Struct({ }); export type ProjectSearchContentsInput = typeof ProjectSearchContentsInput.Type; -export const ProjectContentMatchRange = Schema.Struct({ +const ProjectContentMatchRange = Schema.Struct({ start: NonNegativeInt, end: NonNegativeInt, }); -export type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type; +type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type; export const ProjectContentMatch = Schema.Struct({ path: TrimmedNonEmptyString, diff --git a/packages/contracts/src/providerInstance.ts b/packages/contracts/src/providerInstance.ts index 2a9fc9ed0d1b..4841311c8ba2 100644 --- a/packages/contracts/src/providerInstance.ts +++ b/packages/contracts/src/providerInstance.ts @@ -94,12 +94,11 @@ export const ProviderInstanceRef = Schema.Struct({ }); export type ProviderInstanceRef = typeof ProviderInstanceRef.Type; -export const ProviderInstanceEnvironmentVariableName = TrimmedNonEmptyString.check( +const ProviderInstanceEnvironmentVariableName = TrimmedNonEmptyString.check( Schema.isMaxLength(ENVIRONMENT_VARIABLE_NAME_MAX_CHARS), Schema.isPattern(ENVIRONMENT_VARIABLE_NAME_PATTERN), ); -export type ProviderInstanceEnvironmentVariableName = - typeof ProviderInstanceEnvironmentVariableName.Type; +type ProviderInstanceEnvironmentVariableName = typeof ProviderInstanceEnvironmentVariableName.Type; export const ProviderInstanceEnvironmentVariable = Schema.Struct({ name: ProviderInstanceEnvironmentVariableName, diff --git a/packages/contracts/src/pullRequest.ts b/packages/contracts/src/pullRequest.ts index f766578bb1a3..7e01751f0e6f 100644 --- a/packages/contracts/src/pullRequest.ts +++ b/packages/contracts/src/pullRequest.ts @@ -185,12 +185,8 @@ export const PullRequestReaction = Schema.Struct({ }); export type PullRequestReaction = typeof PullRequestReaction.Type; -export const PullRequestCommentKind = Schema.Literals([ - "issue-comment", - "review-comment", - "review", -]); -export type PullRequestCommentKind = typeof PullRequestCommentKind.Type; +const PullRequestCommentKind = Schema.Literals(["issue-comment", "review-comment", "review"]); +type PullRequestCommentKind = typeof PullRequestCommentKind.Type; export const PullRequestComment = Schema.Struct({ id: TrimmedNonEmptyString, @@ -344,13 +340,13 @@ export type PullRequestReviewCapabilities = typeof PullRequestReviewCapabilities * command that closes a pull request, and has no way to post a remark here at all — so nothing it * shows in a conversation can be rewritten either. */ -export const PullRequestEditCapabilities = Schema.Struct({ +const PullRequestEditCapabilities = Schema.Struct({ /** The change request's own title and description can be rewritten. */ changeRequest: Schema.Boolean, /** A remark can be rewritten by whoever wrote it. */ comment: Schema.Boolean, }); -export type PullRequestEditCapabilities = typeof PullRequestEditCapabilities.Type; +type PullRequestEditCapabilities = typeof PullRequestEditCapabilities.Type; /** * What a host can do about who reviews. The two are independent: a host can take a request without diff --git a/packages/contracts/src/relay.ts b/packages/contracts/src/relay.ts index 37221262ebad..5fb17aceea31 100644 --- a/packages/contracts/src/relay.ts +++ b/packages/contracts/src/relay.ts @@ -16,8 +16,8 @@ import { } from "./baseSchemas.ts"; import { ExecutionEnvironmentDescriptor } from "./environment.ts"; -export const RelayAgentAwarenessPlatform = Schema.Literal("ios"); -export type RelayAgentAwarenessPlatform = typeof RelayAgentAwarenessPlatform.Type; +const RelayAgentAwarenessPlatform = Schema.Literal("ios"); +type RelayAgentAwarenessPlatform = typeof RelayAgentAwarenessPlatform.Type; export const RelayAgentAwarenessPhase = Schema.Literals([ "starting", @@ -40,8 +40,8 @@ export const RelayAgentAwarenessPreferences = Schema.Struct({ }); export type RelayAgentAwarenessPreferences = typeof RelayAgentAwarenessPreferences.Type; -export const RelayApnsEnvironment = Schema.Literals(["sandbox", "production"]); -export type RelayApnsEnvironment = typeof RelayApnsEnvironment.Type; +const RelayApnsEnvironment = Schema.Literals(["sandbox", "production"]); +type RelayApnsEnvironment = typeof RelayApnsEnvironment.Type; export const RelayDeviceRegistrationRequest = Schema.Struct({ deviceId: TrimmedNonEmptyString, @@ -81,10 +81,10 @@ export const RelayClientDeviceRecord = Schema.Struct({ }); export type RelayClientDeviceRecord = typeof RelayClientDeviceRecord.Type; -export const RelayListDevicesResponse = Schema.Struct({ +const RelayListDevicesResponse = Schema.Struct({ devices: Schema.Array(RelayClientDeviceRecord), }); -export type RelayListDevicesResponse = typeof RelayListDevicesResponse.Type; +type RelayListDevicesResponse = typeof RelayListDevicesResponse.Type; export const RelayLiveActivityRegistrationRequest = Schema.Struct({ deviceId: TrimmedNonEmptyString, @@ -92,10 +92,10 @@ export const RelayLiveActivityRegistrationRequest = Schema.Struct({ }); export type RelayLiveActivityRegistrationRequest = typeof RelayLiveActivityRegistrationRequest.Type; -export const RelayDeviceUnregistrationParams = Schema.Struct({ +const RelayDeviceUnregistrationParams = Schema.Struct({ deviceId: TrimmedNonEmptyString, }); -export type RelayDeviceUnregistrationParams = typeof RelayDeviceUnregistrationParams.Type; +type RelayDeviceUnregistrationParams = typeof RelayDeviceUnregistrationParams.Type; export const RelayAgentActivityState = Schema.Struct({ environmentId: EnvironmentId, @@ -199,7 +199,6 @@ export const RelayAgentActivityPublishProofPayload = Schema.Struct({ }); export type RelayAgentActivityPublishProofPayload = typeof RelayAgentActivityPublishProofPayload.Type; -export type RelayAgentActivityPublishProof = string; export const RelayAgentActivityPublishRequest = Schema.Struct({ state: Schema.NullOr(RelayAgentActivityState).annotate({ @@ -211,11 +210,11 @@ export const RelayAgentActivityPublishRequest = Schema.Struct({ }).annotate({ description: "Publishes a signed agent-awareness update from an environment." }); export type RelayAgentActivityPublishRequest = typeof RelayAgentActivityPublishRequest.Type; -export const RelayEnvironmentLinkScope = Schema.Literals([ +const RelayEnvironmentLinkScope = Schema.Literals([ "agent_activity_notifications", "managed_tunnels", ]); -export type RelayEnvironmentLinkScope = typeof RelayEnvironmentLinkScope.Type; +type RelayEnvironmentLinkScope = typeof RelayEnvironmentLinkScope.Type; export const RelayEnvironmentLinkProofPayload = Schema.Struct({ ...RelaySignedJwtRegisteredClaims, @@ -290,26 +289,25 @@ export const RelayEnvironmentLinkProofInvalidReason = Schema.Literals([ export type RelayEnvironmentLinkProofInvalidReason = typeof RelayEnvironmentLinkProofInvalidReason.Type; -export const RelayEnvironmentLinkFailedReason = Schema.Literals([ +const RelayEnvironmentLinkFailedReason = Schema.Literals([ "link_persistence_failed", "credential_persistence_failed", "replay_persistence_failed", "internal_error", ]); -export type RelayEnvironmentLinkFailedReason = typeof RelayEnvironmentLinkFailedReason.Type; +type RelayEnvironmentLinkFailedReason = typeof RelayEnvironmentLinkFailedReason.Type; -export const RelayEnvironmentLinkUnavailableReason = Schema.Literals([ +const RelayEnvironmentLinkUnavailableReason = Schema.Literals([ "managed_endpoint_not_configured", "managed_endpoint_provisioning_failed", ]); -export type RelayEnvironmentLinkUnavailableReason = - typeof RelayEnvironmentLinkUnavailableReason.Type; +type RelayEnvironmentLinkUnavailableReason = typeof RelayEnvironmentLinkUnavailableReason.Type; -export const RelayEnvironmentEndpointUnavailableReason = Schema.Literals([ +const RelayEnvironmentEndpointUnavailableReason = Schema.Literals([ "endpoint_request_failed", "endpoint_response_invalid", ]); -export type RelayEnvironmentEndpointUnavailableReason = +type RelayEnvironmentEndpointUnavailableReason = typeof RelayEnvironmentEndpointUnavailableReason.Type; export const RelayAgentActivityPublishProofInvalidReason = Schema.Literals([ @@ -330,13 +328,13 @@ export type RelayAuthInvalidReason = typeof RelayAuthInvalidReason.Type; export const RelayDpopFailureReason = DpopFailureReason; export type RelayDpopFailureReason = typeof RelayDpopFailureReason.Type; -export const RelayInternalErrorReason = Schema.Literals([ +const RelayInternalErrorReason = Schema.Literals([ "database_unavailable", "persistence_failed", "upstream_unavailable", "internal_error", ]); -export type RelayInternalErrorReason = typeof RelayInternalErrorReason.Type; +type RelayInternalErrorReason = typeof RelayInternalErrorReason.Type; export class RelayAuthInvalidError extends Schema.TaggedErrorClass()( "RelayAuthInvalidError", @@ -636,10 +634,10 @@ export const RelayClientEnvironmentRecord = Schema.Struct({ }); export type RelayClientEnvironmentRecord = typeof RelayClientEnvironmentRecord.Type; -export const RelayListEnvironmentsResponse = Schema.Struct({ +const RelayListEnvironmentsResponse = Schema.Struct({ environments: Schema.Array(RelayClientEnvironmentRecord), }); -export type RelayListEnvironmentsResponse = typeof RelayListEnvironmentsResponse.Type; +type RelayListEnvironmentsResponse = typeof RelayListEnvironmentsResponse.Type; export const RelayEnvironmentConnectRequest = Schema.Struct({ deviceId: Schema.optional( @@ -679,7 +677,7 @@ export type RelayPublicClientId = typeof RelayPublicClientId.Type; export const RelayMobileClientId = "t3-mobile" as const; export const RelayWebClientId = "t3-web" as const; -export const RelayDpopAccessTokenRequest = Schema.Struct({ +const RelayDpopAccessTokenRequest = Schema.Struct({ grant_type: Schema.Literal(RelayDpopTokenExchangeGrantType), subject_token: TrimmedNonEmptyString.annotate({ description: "Clerk bearer token for the signed-in cloud user.", @@ -696,31 +694,31 @@ export const RelayDpopAccessTokenRequest = Schema.Struct({ }) .annotate({ description: "OAuth token exchange request for a DPoP-bound relay access token." }) .pipe(HttpApiSchema.asFormUrlEncoded()); -export type RelayDpopAccessTokenRequest = typeof RelayDpopAccessTokenRequest.Type; +type RelayDpopAccessTokenRequest = typeof RelayDpopAccessTokenRequest.Type; -export const RelayDpopAccessTokenResponse = Schema.Struct({ +const RelayDpopAccessTokenResponse = Schema.Struct({ access_token: TrimmedNonEmptyString, issued_token_type: Schema.Literal(RelayAccessTokenType), token_type: Schema.Literal("DPoP"), expires_in: Schema.Int.check(Schema.isGreaterThan(0)), scope: TrimmedNonEmptyString, }); -export type RelayDpopAccessTokenResponse = typeof RelayDpopAccessTokenResponse.Type; +type RelayDpopAccessTokenResponse = typeof RelayDpopAccessTokenResponse.Type; -export const RelayBearerRequestHeaders = Schema.Struct({ +const RelayBearerRequestHeaders = Schema.Struct({ authorization: TrimmedNonEmptyString, }); -export const RelayDpopProofRequestHeaders = Schema.Struct({ +const RelayDpopProofRequestHeaders = Schema.Struct({ dpop: TrimmedNonEmptyString, }); -export const RelayDpopRequestHeaders = Schema.Struct({ +const RelayDpopRequestHeaders = Schema.Struct({ authorization: TrimmedNonEmptyString, dpop: TrimmedNonEmptyString, }); -export const RelayAuthorizationServerMetadata = Schema.Struct({ +const RelayAuthorizationServerMetadata = Schema.Struct({ issuer: TrimmedNonEmptyString, token_endpoint: TrimmedNonEmptyString, grant_types_supported: Schema.Array(Schema.Literal(RelayDpopTokenExchangeGrantType)), @@ -729,7 +727,7 @@ export const RelayAuthorizationServerMetadata = Schema.Struct({ scopes_supported: Schema.Array(RelayDpopAccessTokenScope), }); -export const RelayProtectedResourceMetadata = Schema.Struct({ +const RelayProtectedResourceMetadata = Schema.Struct({ resource: TrimmedNonEmptyString, authorization_servers: Schema.Array(TrimmedNonEmptyString), scopes_supported: Schema.Array(RelayDpopAccessTokenScope), @@ -737,10 +735,10 @@ export const RelayProtectedResourceMetadata = Schema.Struct({ dpop_signing_alg_values_supported: Schema.Array(Schema.Literal("ES256")), }); -export const RelayEnvironmentUnlinkParams = Schema.Struct({ +const RelayEnvironmentUnlinkParams = Schema.Struct({ environmentId: EnvironmentId, }); -export type RelayEnvironmentUnlinkParams = typeof RelayEnvironmentUnlinkParams.Type; +type RelayEnvironmentUnlinkParams = typeof RelayEnvironmentUnlinkParams.Type; export const RelayEnvironmentConnectResponse = Schema.Struct({ environmentId: EnvironmentId, @@ -750,8 +748,8 @@ export const RelayEnvironmentConnectResponse = Schema.Struct({ }); export type RelayEnvironmentConnectResponse = typeof RelayEnvironmentConnectResponse.Type; -export const RelayEnvironmentStatusValue = Schema.Literals(["online", "offline"]); -export type RelayEnvironmentStatusValue = typeof RelayEnvironmentStatusValue.Type; +const RelayEnvironmentStatusValue = Schema.Literals(["online", "offline"]); +type RelayEnvironmentStatusValue = typeof RelayEnvironmentStatusValue.Type; export const RelayEnvironmentStatusResponse = Schema.Struct({ environmentId: EnvironmentId, @@ -777,8 +775,8 @@ export const RelayCloudMintCredentialProofPayload = Schema.Struct({ }); export type RelayCloudMintCredentialProofPayload = typeof RelayCloudMintCredentialProofPayload.Type; -export const RelayCloudMintCredentialProof = TrimmedNonEmptyString; -export type RelayCloudMintCredentialProof = typeof RelayCloudMintCredentialProof.Type; +const RelayCloudMintCredentialProof = TrimmedNonEmptyString; +type RelayCloudMintCredentialProof = typeof RelayCloudMintCredentialProof.Type; export const RelayCloudMintCredentialRequest = Schema.Struct({ proof: RelayCloudMintCredentialProof, @@ -794,8 +792,8 @@ export const RelayCloudEnvironmentHealthProofPayload = Schema.Struct({ export type RelayCloudEnvironmentHealthProofPayload = typeof RelayCloudEnvironmentHealthProofPayload.Type; -export const RelayCloudEnvironmentHealthProof = TrimmedNonEmptyString; -export type RelayCloudEnvironmentHealthProof = typeof RelayCloudEnvironmentHealthProof.Type; +const RelayCloudEnvironmentHealthProof = TrimmedNonEmptyString; +type RelayCloudEnvironmentHealthProof = typeof RelayCloudEnvironmentHealthProof.Type; export const RelayCloudEnvironmentHealthRequest = Schema.Struct({ proof: RelayCloudEnvironmentHealthProof, @@ -869,13 +867,13 @@ export const RelayPublishResponse = Schema.Struct({ }); export type RelayPublishResponse = typeof RelayPublishResponse.Type; -export const RelayHealthResponse = Schema.Struct({ +const RelayHealthResponse = Schema.Struct({ ok: Schema.Boolean, service: Schema.Literal("relay"), }); -export type RelayHealthResponse = typeof RelayHealthResponse.Type; +type RelayHealthResponse = typeof RelayHealthResponse.Type; -export const RelayHealthGroup = HttpApiGroup.make("health") +const RelayHealthGroup = HttpApiGroup.make("health") .add( HttpApiEndpoint.get("health", "/health", { success: RelayHealthResponse, @@ -884,7 +882,7 @@ export const RelayHealthGroup = HttpApiGroup.make("health") ) .annotate(OpenApi.Description, "Service health and readiness."); -export const RelayMetadataGroup = HttpApiGroup.make("metadata") +const RelayMetadataGroup = HttpApiGroup.make("metadata") .add( HttpApiEndpoint.get("authorizationServer", "/.well-known/oauth-authorization-server", { success: RelayAuthorizationServerMetadata, @@ -946,7 +944,7 @@ export const RelayUnregisterDeviceEndpoint = HttpApiEndpoint.delete( }, ).annotate(OpenApi.Summary, "Unregister a mobile device"); -export const RelayMobileGroup = HttpApiGroup.make("mobile") +const RelayMobileGroup = HttpApiGroup.make("mobile") .add( RelayRegisterDeviceEndpoint, RelayRegisterLiveActivityEndpoint, @@ -956,7 +954,7 @@ export const RelayMobileGroup = HttpApiGroup.make("mobile") .annotate(OpenApi.Description, "Mobile push-notification and Live Activity registration.") .middleware(RelayDpopClientAuth); -export const RelayClientGroup = HttpApiGroup.make("client") +const RelayClientGroup = HttpApiGroup.make("client") .add( HttpApiEndpoint.get("listEnvironments", "/v1/environments", { headers: RelayBearerRequestHeaders, @@ -1025,7 +1023,7 @@ export const RelayExchangeDpopAccessTokenEndpoint = HttpApiEndpoint.post( "Bootstrap endpoint. Send the DPoP proof JWT in the dpop header and the Clerk token in subject_token. The returned access token is bound to the proof key.", ); -export const RelayTokenGroup = HttpApiGroup.make("token") +const RelayTokenGroup = HttpApiGroup.make("token") .add(RelayExchangeDpopAccessTokenEndpoint) .annotate(OpenApi.Description, "OAuth token exchange for DPoP-bound client access."); @@ -1056,12 +1054,12 @@ export const RelayGetEnvironmentStatusEndpoint = HttpApiEndpoint.post( }, ).annotate(OpenApi.Summary, "Check environment status"); -export const RelayDpopClientGroup = HttpApiGroup.make("dpopClient") +const RelayDpopClientGroup = HttpApiGroup.make("dpopClient") .add(RelayConnectEnvironmentEndpoint, RelayGetEnvironmentStatusEndpoint) .annotate(OpenApi.Description, "DPoP-authenticated client access to linked environments.") .middleware(RelayDpopClientAuth); -export const RelayServerGroup = HttpApiGroup.make("server") +const RelayServerGroup = HttpApiGroup.make("server") .add( HttpApiEndpoint.post( "publishAgentActivity", diff --git a/packages/contracts/src/relayClient.ts b/packages/contracts/src/relayClient.ts index e78078d1eedb..f84ef9079a3a 100644 --- a/packages/contracts/src/relayClient.ts +++ b/packages/contracts/src/relayClient.ts @@ -18,7 +18,6 @@ export const RelayClientStatusSchema = Schema.Union([ version: Schema.String, }), ]); -export type RelayClientStatus = typeof RelayClientStatusSchema.Type; export const RelayClientInstallProgressStageSchema = Schema.Literals([ "checking", @@ -43,7 +42,7 @@ export const RelayClientInstallProgressEventSchema = Schema.Union([ ]); export type RelayClientInstallProgressEvent = typeof RelayClientInstallProgressEventSchema.Type; -export const RelayClientInstallFailureReasonSchema = Schema.Literals([ +const RelayClientInstallFailureReasonSchema = Schema.Literals([ "download_failed", "invalid_checksum", "install_locked", @@ -52,7 +51,6 @@ export const RelayClientInstallFailureReasonSchema = Schema.Literals([ "validation_failed", "write_failed", ]); -export type RelayClientInstallFailureReason = typeof RelayClientInstallFailureReasonSchema.Type; export class RelayClientInstallFailedError extends Schema.TaggedErrorClass()( "RelayClientInstallFailedError", diff --git a/packages/contracts/src/resourceTelemetry.ts b/packages/contracts/src/resourceTelemetry.ts index 3ec1e4de3ef4..86a25bfebe43 100644 --- a/packages/contracts/src/resourceTelemetry.ts +++ b/packages/contracts/src/resourceTelemetry.ts @@ -78,58 +78,57 @@ export const ResourceMonitorProcessSample = Schema.Struct({ }); export type ResourceMonitorProcessSample = typeof ResourceMonitorProcessSample.Type; -export const ResourceMonitorConfigureCommand = Schema.Struct({ +const ResourceMonitorConfigureCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("configure"), rootPid: PositiveInt, sampleIntervalMs: NonNegativeInt, externalProcesses: Schema.Array(ResourceMonitorExternalProcess), }); -export type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type; +type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type; -export const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({ +const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setExternalProcesses"), processes: Schema.Array(ResourceMonitorExternalProcess), }); -export type ResourceMonitorSetExternalProcessesCommand = +type ResourceMonitorSetExternalProcessesCommand = typeof ResourceMonitorSetExternalProcessesCommand.Type; -export const ResourceMonitorSampleNowCommand = Schema.Struct({ +const ResourceMonitorSampleNowCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("sampleNow"), requestId: TrimmedNonEmptyString, }); -export type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type; +type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type; -export const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({ +const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setSampleInterval"), sampleIntervalMs: NonNegativeInt, }); -export type ResourceMonitorSetSampleIntervalCommand = - typeof ResourceMonitorSetSampleIntervalCommand.Type; +type ResourceMonitorSetSampleIntervalCommand = typeof ResourceMonitorSetSampleIntervalCommand.Type; -export const ResourceMonitorSetStreamingCommand = Schema.Struct({ +const ResourceMonitorSetStreamingCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setStreaming"), enabled: Schema.Boolean, }); -export type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type; +type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type; -export const ResourceMonitorReadHistoryCommand = Schema.Struct({ +const ResourceMonitorReadHistoryCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("readHistory"), requestId: TrimmedNonEmptyString, windowMs: NonNegativeInt, }); -export type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type; +type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type; -export const ResourceMonitorShutdownCommand = Schema.Struct({ +const ResourceMonitorShutdownCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("shutdown"), }); -export type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type; +type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type; export const ResourceMonitorCommand = Schema.Union([ ResourceMonitorConfigureCommand, @@ -168,23 +167,23 @@ export const ResourceMonitorSnapshotEvent = Schema.Struct({ }); export type ResourceMonitorSnapshotEvent = typeof ResourceMonitorSnapshotEvent.Type; -export const ResourceMonitorHistoryChunkEvent = Schema.Struct({ +const ResourceMonitorHistoryChunkEvent = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("historyChunk"), requestId: TrimmedNonEmptyString, done: Schema.Boolean, snapshots: Schema.Array(ResourceMonitorSnapshotEvent), }); -export type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type; +type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type; -export const ResourceMonitorErrorEvent = Schema.Struct({ +const ResourceMonitorErrorEvent = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("error"), code: TrimmedNonEmptyString, message: TrimmedNonEmptyString, recoverable: Schema.Boolean, }); -export type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type; +type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type; export const ResourceMonitorEvent = Schema.Union([ ResourceMonitorHelloEvent, @@ -194,7 +193,7 @@ export const ResourceMonitorEvent = Schema.Union([ ]); export type ResourceMonitorEvent = typeof ResourceMonitorEvent.Type; -export const DesktopElectronProcessType = Schema.Literals([ +const DesktopElectronProcessType = Schema.Literals([ "Browser", "Tab", "Utility", @@ -205,7 +204,7 @@ export const DesktopElectronProcessType = Schema.Literals([ "Pepper Plugin Broker", "Unknown", ]); -export type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type; +type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type; export const DesktopElectronProcessMetric = Schema.Struct({ pid: PositiveInt, @@ -238,12 +237,12 @@ export const DesktopHostTelemetrySnapshot = Schema.Struct({ }); export type DesktopHostTelemetrySnapshot = typeof DesktopHostTelemetrySnapshot.Type; -export const DesktopHostTelemetryHello = Schema.Struct({ +const DesktopHostTelemetryHello = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("desktopTelemetryHello"), electronPid: PositiveInt, }); -export type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type; +type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type; /** Terminal marker for a server-triggered desktop update run. */ export const DesktopUpdateRemoteOutcome = Schema.Literals([ @@ -279,21 +278,20 @@ export const DesktopHostTelemetryMessage = Schema.Union([ ]); export type DesktopHostTelemetryMessage = typeof DesktopHostTelemetryMessage.Type; -export const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({ +const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("setDiagnosticsDemand"), enabled: Schema.Boolean, }); -export type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type; +type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type; -export const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({ +const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("setHostPowerIntervals"), activeIntervalMs: PositiveInt, idleIntervalMs: PositiveInt, }); -export type DesktopTelemetrySetHostPowerIntervals = - typeof DesktopTelemetrySetHostPowerIntervals.Type; +type DesktopTelemetrySetHostPowerIntervals = typeof DesktopTelemetrySetHostPowerIntervals.Type; /** * Server -> desktop main: run the app's own update flow now (check -> @@ -373,13 +371,13 @@ export const ResourceTelemetryAggregate = Schema.Struct({ }); export type ResourceTelemetryAggregate = typeof ResourceTelemetryAggregate.Type; -export const ResourceTelemetryGroups = Schema.Struct({ +const ResourceTelemetryGroups = Schema.Struct({ backend: ResourceTelemetryAggregate, electron: ResourceTelemetryAggregate, monitor: ResourceTelemetryAggregate, allT3: ResourceTelemetryAggregate, }); -export type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type; +type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type; export const ResourceTelemetrySourceHealth = Schema.Struct({ status: ResourceTelemetrySourceStatus, diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 623780c1fb8b..6d87074d4709 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -31,11 +31,11 @@ import { export const TimestampFormat = Schema.Literals(["locale", "12-hour", "24-hour"]); export type TimestampFormat = typeof TimestampFormat.Type; -export const DEFAULT_TIMESTAMP_FORMAT: TimestampFormat = "locale"; +const DEFAULT_TIMESTAMP_FORMAT: TimestampFormat = "locale"; export const DiffLayout = Schema.Literals(["stacked", "split"]); export type DiffLayout = typeof DiffLayout.Type; -export const DEFAULT_DIFF_LAYOUT: DiffLayout = "stacked"; +const DEFAULT_DIFF_LAYOUT: DiffLayout = "stacked"; export const SidebarProjectSortOrder = Schema.Literals(["updated_at", "created_at", "manual"]); export type SidebarProjectSortOrder = typeof SidebarProjectSortOrder.Type; @@ -51,7 +51,7 @@ export const SidebarProjectGroupingMode = Schema.Literals([ "separate", ]); export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type; -export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository"; +const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository"; export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1; export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15; export const SidebarThreadPreviewCount = Schema.Int.check( @@ -61,7 +61,7 @@ export const SidebarThreadPreviewCount = Schema.Int.check( }), ); export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type; -export const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6; +const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6; export const MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 1; export const MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 90; export const SidebarAutoSettleAfterDays = Schema.Number.check( @@ -71,7 +71,7 @@ export const SidebarAutoSettleAfterDays = Schema.Number.check( }), ); export type SidebarAutoSettleAfterDays = typeof SidebarAutoSettleAfterDays.Type; -export const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3; +const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3; export const MIN_GLASS_OPACITY = 40; export const MAX_GLASS_OPACITY = 100; export const GlassOpacity = Schema.Int.check( @@ -81,7 +81,7 @@ export const GlassOpacity = Schema.Int.check( }), ); export type GlassOpacity = typeof GlassOpacity.Type; -export const DEFAULT_GLASS_OPACITY: GlassOpacity = 80; +const DEFAULT_GLASS_OPACITY: GlassOpacity = 80; export const MIN_APPEARANCE_CONTRAST = 50; export const MAX_APPEARANCE_CONTRAST = 200; @@ -89,7 +89,7 @@ export const AppearanceContrast = Schema.Int.check( Schema.isBetween({ minimum: MIN_APPEARANCE_CONTRAST, maximum: MAX_APPEARANCE_CONTRAST }), ); export type AppearanceContrast = typeof AppearanceContrast.Type; -export const DEFAULT_APPEARANCE_CONTRAST: AppearanceContrast = 100; +const DEFAULT_APPEARANCE_CONTRAST: AppearanceContrast = 100; export const MIN_PANEL_ANIMATION_DURATION_MS = 0; export const MAX_PANEL_ANIMATION_DURATION_MS = 400; export const PanelAnimationDurationMs = Schema.Int.check( @@ -99,7 +99,7 @@ export const PanelAnimationDurationMs = Schema.Int.check( }), ); export type PanelAnimationDurationMs = typeof PanelAnimationDurationMs.Type; -export const DEFAULT_PANEL_ANIMATION_DURATION_MS: PanelAnimationDurationMs = 0; +const DEFAULT_PANEL_ANIMATION_DURATION_MS: PanelAnimationDurationMs = 0; /** * Font size preferences, in CSS pixels. The ranges are deliberately narrow: * the interface size scales every rem-based dimension in the app, so the @@ -135,7 +135,7 @@ export const TerminalFontSize = Schema.Int.check( Schema.isBetween({ minimum: MIN_TERMINAL_FONT_SIZE, maximum: MAX_TERMINAL_FONT_SIZE }), ); export type TerminalFontSize = typeof TerminalFontSize.Type; -export const DEFAULT_TERMINAL_FONT_SIZE: TerminalFontSize = 12; +const DEFAULT_TERMINAL_FONT_SIZE: TerminalFontSize = 12; export const EnvironmentIdentificationMode = Schema.Literals(["artwork", "pill", "none"]); export type EnvironmentIdentificationMode = typeof EnvironmentIdentificationMode.Type; @@ -143,7 +143,7 @@ export const DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE: EnvironmentIdentificationM export const QuitConfirmationMode = Schema.Literals(["direct", "hold", "double-click"]); export type QuitConfirmationMode = typeof QuitConfirmationMode.Type; -export const DEFAULT_QUIT_CONFIRMATION_MODE: QuitConfirmationMode = "hold"; +const DEFAULT_QUIT_CONFIRMATION_MODE: QuitConfirmationMode = "hold"; const LegacyConfirmQuit = Schema.Boolean.pipe( Schema.decodeTo( @@ -161,8 +161,8 @@ const QuitConfirmationModeSetting = Schema.Union([QuitConfirmationMode, LegacyCo * A user-chosen font family (a single name or a comma-separated list). Empty * means "use the app default"; clients compose their own fallback stacks. */ -export const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200)); -export type FontFamilyPreference = typeof FontFamilyPreference.Type; +const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200)); +type FontFamilyPreference = typeof FontFamilyPreference.Type; /** * The environment's theme, set with `t3 theme set `. Each client applies @@ -171,11 +171,11 @@ export type FontFamilyPreference = typeof FontFamilyPreference.Type; * afterwards sticks until the next set. Empty means "no environment theme", * which is also how it is cleared. */ -export const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64)); +const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64)); // Deliberately absent from ServerSettingsPatch: `t3 theme set` checks that an // id is syntactically valid and actually resolvable, and a generic RPC patch // would let a client write a theme no client can resolve, bypassing both. -export type DefaultThemePreference = typeof DefaultThemePreference.Type; +type DefaultThemePreference = typeof DefaultThemePreference.Type; /** * Defaults for the in-app preview browser, applied whenever a tab is opened @@ -418,12 +418,12 @@ declare module "effect/Schema" { } } -export type ProviderSettingsOrder = readonly Extract< +type ProviderSettingsOrder = readonly Extract< keyof Fields, string >[]; -export function makeProviderSettingsSchema( +function makeProviderSettingsSchema( fields: Fields, options?: { readonly order?: ProviderSettingsOrder | undefined; @@ -766,11 +766,11 @@ export const UsageLimitSourceConfig = Schema.Struct({ }); export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type; -export const ObservabilitySettings = Schema.Struct({ +const ObservabilitySettings = Schema.Struct({ otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))), otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))), }); -export type ObservabilitySettings = typeof ObservabilitySettings.Type; +type ObservabilitySettings = typeof ObservabilitySettings.Type; export const SourceControlWritingStyleMode = Schema.Literals([ "repo_conventions", @@ -801,15 +801,15 @@ export const BackgroundActivityProfile = Schema.Literals([ export type BackgroundActivityProfile = typeof BackgroundActivityProfile.Type; export const DEFAULT_BACKGROUND_ACTIVITY_PROFILE: BackgroundActivityProfile = "balanced"; -export const BackgroundActivityProfileSelection = Schema.Literals([ +const BackgroundActivityProfileSelection = Schema.Literals([ "balanced", "performance", "battery-saver", "custom", ]); -export type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type; +type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type; -export const BackgroundActivityOverrides = Schema.Struct({ +const BackgroundActivityOverrides = Schema.Struct({ automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis), providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis), hostPowerMonitorActiveInterval: Schema.optionalKey(Schema.DurationFromMillis), @@ -820,7 +820,7 @@ export const BackgroundActivityOverrides = Schema.Struct({ pauseWhenClientLowPower: Schema.optionalKey(Schema.Boolean), pauseWhenOnBattery: Schema.optionalKey(Schema.Boolean), }); -export type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type; +type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type; export const BackgroundActivitySettings = Schema.Struct({ schemaVersion: Schema.Literal(1).pipe(Schema.withDecodingDefault(Effect.succeed(1 as const))), @@ -1006,7 +1006,7 @@ export const resolveProviderInstanceEnabled = ( return instance.enabled ?? configEnabled ?? defaultEnabledForDriver(instance.driver); }; -export const ServerSettingsOperation = Schema.Literals([ +const ServerSettingsOperation = Schema.Literals([ "normalize", "check-exists", "read-file", @@ -1018,7 +1018,7 @@ export const ServerSettingsOperation = Schema.Literals([ "write-file", "prepare-directory", ]); -export type ServerSettingsOperation = typeof ServerSettingsOperation.Type; +type ServerSettingsOperation = typeof ServerSettingsOperation.Type; export class ServerSettingsError extends Schema.TaggedErrorClass()( "ServerSettingsError", diff --git a/packages/contracts/src/sourceControl.ts b/packages/contracts/src/sourceControl.ts index be3d70aefadd..4e91678174e0 100644 --- a/packages/contracts/src/sourceControl.ts +++ b/packages/contracts/src/sourceControl.ts @@ -92,8 +92,8 @@ export const SourceControlPublishRepositoryInput = Schema.Struct({ }); export type SourceControlPublishRepositoryInput = typeof SourceControlPublishRepositoryInput.Type; -export const SourceControlPublishStatus = Schema.Literals(["pushed", "remote_added"]); -export type SourceControlPublishStatus = typeof SourceControlPublishStatus.Type; +const SourceControlPublishStatus = Schema.Literals(["pushed", "remote_added"]); +type SourceControlPublishStatus = typeof SourceControlPublishStatus.Type; export const SourceControlPublishRepositoryResult = Schema.Struct({ repository: SourceControlRepositoryInfo, @@ -105,15 +105,15 @@ export const SourceControlPublishRepositoryResult = Schema.Struct({ }); export type SourceControlPublishRepositoryResult = typeof SourceControlPublishRepositoryResult.Type; -export const SourceControlDiscoveryStatus = Schema.Literals(["available", "missing"]); -export type SourceControlDiscoveryStatus = typeof SourceControlDiscoveryStatus.Type; +const SourceControlDiscoveryStatus = Schema.Literals(["available", "missing"]); +type SourceControlDiscoveryStatus = typeof SourceControlDiscoveryStatus.Type; -export const SourceControlProviderAuthStatus = Schema.Literals([ +const SourceControlProviderAuthStatus = Schema.Literals([ "authenticated", "unauthenticated", "unknown", ]); -export type SourceControlProviderAuthStatus = typeof SourceControlProviderAuthStatus.Type; +type SourceControlProviderAuthStatus = typeof SourceControlProviderAuthStatus.Type; export const SourceControlProviderAuth = Schema.Struct({ status: SourceControlProviderAuthStatus, diff --git a/packages/contracts/src/terminal.ts b/packages/contracts/src/terminal.ts index 36e3d339f521..fda8c330c3cf 100644 --- a/packages/contracts/src/terminal.ts +++ b/packages/contracts/src/terminal.ts @@ -35,7 +35,7 @@ const TerminalSessionInput = Schema.Struct({ ...TerminalThreadInput.fields, terminalId: TerminalIdSchema, }); -export type TerminalSessionInput = Schema.Codec.Encoded; +type TerminalSessionInput = Schema.Codec.Encoded; export const TerminalOpenInput = Schema.Struct({ ...TerminalSessionInput.fields, diff --git a/packages/contracts/src/usage.ts b/packages/contracts/src/usage.ts index c36a4557c294..f2da1efe1fd6 100644 --- a/packages/contracts/src/usage.ts +++ b/packages/contracts/src/usage.ts @@ -134,8 +134,8 @@ export const UsageSourceFingerprint = Schema.Struct({ }); export type UsageSourceFingerprint = typeof UsageSourceFingerprint.Type; -export const UsageSourceStatus = Schema.Literals(["ok", "missing", "partial", "failed"]); -export type UsageSourceStatus = typeof UsageSourceStatus.Type; +const UsageSourceStatus = Schema.Literals(["ok", "missing", "partial", "failed"]); +type UsageSourceStatus = typeof UsageSourceStatus.Type; export const UsageSource = Schema.Struct({ fingerprint: UsageSourceFingerprint, @@ -154,8 +154,8 @@ export const UsageSource = Schema.Struct({ }); export type UsageSource = typeof UsageSource.Type; -export const UsagePricingStatus = Schema.Literals(["fresh", "cached", "unavailable"]); -export type UsagePricingStatus = typeof UsagePricingStatus.Type; +const UsagePricingStatus = Schema.Literals(["fresh", "cached", "unavailable"]); +type UsagePricingStatus = typeof UsagePricingStatus.Type; /** * Provenance for the rate table, so the UI can be honest about how good the diff --git a/packages/contracts/src/vcs.ts b/packages/contracts/src/vcs.ts index a0956e83bd5b..650f762c77b6 100644 --- a/packages/contracts/src/vcs.ts +++ b/packages/contracts/src/vcs.ts @@ -4,20 +4,20 @@ import { NonNegativeInt, TrimmedNonEmptyString } from "./baseSchemas.ts"; export const VcsDriverKind = Schema.Literals(["git", "jj", "unknown"]); export type VcsDriverKind = typeof VcsDriverKind.Type; -export const VcsFreshnessSource = Schema.Literals([ +const VcsFreshnessSource = Schema.Literals([ "live-local", "cached-local", "cached-remote", "explicit-remote", ]); -export type VcsFreshnessSource = typeof VcsFreshnessSource.Type; +type VcsFreshnessSource = typeof VcsFreshnessSource.Type; -export const VcsFreshness = Schema.Struct({ +const VcsFreshness = Schema.Struct({ source: VcsFreshnessSource, observedAt: Schema.DateTimeUtc, expiresAt: Schema.Option(Schema.DateTimeUtc), }); -export type VcsFreshness = typeof VcsFreshness.Type; +type VcsFreshness = typeof VcsFreshness.Type; export const VcsDriverCapabilities = Schema.Struct({ kind: VcsDriverKind, @@ -44,13 +44,13 @@ export const VcsListWorkspaceFilesResult = Schema.Struct({ }); export type VcsListWorkspaceFilesResult = typeof VcsListWorkspaceFilesResult.Type; -export const VcsRemote = Schema.Struct({ +const VcsRemote = Schema.Struct({ name: TrimmedNonEmptyString, url: TrimmedNonEmptyString, pushUrl: Schema.Option(TrimmedNonEmptyString), isPrimary: Schema.Boolean, }); -export type VcsRemote = typeof VcsRemote.Type; +type VcsRemote = typeof VcsRemote.Type; export const VcsListRemotesResult = Schema.Struct({ remotes: Schema.Array(VcsRemote), @@ -234,13 +234,13 @@ export class VcsProcessMissingExitCodeError extends Schema.TaggedErrorClass()( "VcsRepositoryDetectionError", From b37eb8ea1cf53ab16ad0c9e0ba21fd3bdc319cb4 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Sat, 5 Sep 2026 11:20:52 -0700 Subject: [PATCH 2/2] refactor(contracts): retain domain schemas and types --- .../src/checkpointing/CheckpointDiffQuery.ts | 4 +- packages/contracts/src/git.ts | 18 ++--- packages/contracts/src/model.ts | 24 +++--- packages/contracts/src/orchestration.ts | 49 ++++++------ packages/contracts/src/project.ts | 4 +- packages/contracts/src/providerInstance.ts | 5 +- packages/contracts/src/pullRequest.ts | 12 ++- packages/contracts/src/relay.ts | 80 ++++++++++--------- packages/contracts/src/relayClient.ts | 4 +- packages/contracts/src/resourceTelemetry.ts | 58 +++++++------- packages/contracts/src/settings.ts | 26 +++--- packages/contracts/src/sourceControl.ts | 12 +-- packages/contracts/src/terminal.ts | 2 +- packages/contracts/src/usage.ts | 8 +- packages/contracts/src/vcs.ts | 16 ++-- 15 files changed, 168 insertions(+), 154 deletions(-) diff --git a/apps/server/src/checkpointing/CheckpointDiffQuery.ts b/apps/server/src/checkpointing/CheckpointDiffQuery.ts index 2647891c363b..077506ff3a84 100644 --- a/apps/server/src/checkpointing/CheckpointDiffQuery.ts +++ b/apps/server/src/checkpointing/CheckpointDiffQuery.ts @@ -8,7 +8,7 @@ */ import { type CheckpointRef, - ThreadTurnDiff, + OrchestrationGetTurnDiffResult, type OrchestrationGetFullThreadDiffInput, type OrchestrationGetFullThreadDiffResult, type OrchestrationGetTurnDiffInput, @@ -57,7 +57,7 @@ export class CheckpointDiffQuery extends Context.Service< } >()("t3/checkpointing/CheckpointDiffQuery") {} -const isTurnDiffResult = Schema.is(ThreadTurnDiff); +const isTurnDiffResult = Schema.is(OrchestrationGetTurnDiffResult); function buildTurnDiffResult( input: { diff --git a/packages/contracts/src/git.ts b/packages/contracts/src/git.ts index 0de86d554107..4b63b877923f 100644 --- a/packages/contracts/src/git.ts +++ b/packages/contracts/src/git.ts @@ -19,7 +19,7 @@ export const GitStackedAction = Schema.Literals([ export type GitStackedAction = typeof GitStackedAction.Type; export const GitActionProgressPhase = Schema.Literals(["branch", "commit", "push", "pr"]); export type GitActionProgressPhase = typeof GitActionProgressPhase.Type; -const GitActionProgressKind = Schema.Literals([ +export const GitActionProgressKind = Schema.Literals([ "action_started", "phase_started", "hook_started", @@ -28,9 +28,9 @@ const GitActionProgressKind = Schema.Literals([ "action_finished", "action_failed", ]); -type GitActionProgressKind = typeof GitActionProgressKind.Type; -const GitActionProgressStream = Schema.Literals(["stdout", "stderr"]); -type GitActionProgressStream = typeof GitActionProgressStream.Type; +export type GitActionProgressKind = typeof GitActionProgressKind.Type; +export const GitActionProgressStream = Schema.Literals(["stdout", "stderr"]); +export type GitActionProgressStream = typeof GitActionProgressStream.Type; const GitCommitStepStatus = Schema.Literals([ "created", "skipped_no_changes", @@ -47,10 +47,10 @@ const VcsStatusChangeRequestState = Schema.Literals(["open", "closed", "merged"] const GitPullRequestReference = TrimmedNonEmptyStringSchema; const GitPullRequestState = Schema.Literals(["open", "closed", "merged"]); const GitPreparePullRequestThreadMode = Schema.Literals(["local", "worktree"]); -const GitRunStackedActionToastRunAction = Schema.Struct({ +export const GitRunStackedActionToastRunAction = Schema.Struct({ kind: GitStackedAction, }); -type GitRunStackedActionToastRunAction = typeof GitRunStackedActionToastRunAction.Type; +export type GitRunStackedActionToastRunAction = typeof GitRunStackedActionToastRunAction.Type; const GitRunStackedActionToastCta = Schema.Union([ Schema.Struct({ kind: Schema.Literal("none"), @@ -66,13 +66,13 @@ const GitRunStackedActionToastCta = Schema.Union([ action: GitRunStackedActionToastRunAction, }), ]); -type GitRunStackedActionToastCta = typeof GitRunStackedActionToastCta.Type; +export type GitRunStackedActionToastCta = typeof GitRunStackedActionToastCta.Type; const GitRunStackedActionToast = Schema.Struct({ title: TrimmedNonEmptyStringSchema, description: Schema.optional(TrimmedNonEmptyStringSchema), cta: GitRunStackedActionToastCta, }); -type GitRunStackedActionToast = typeof GitRunStackedActionToast.Type; +export type GitRunStackedActionToast = typeof GitRunStackedActionToast.Type; export const VcsRef = Schema.Struct({ name: TrimmedNonEmptyStringSchema, @@ -96,7 +96,7 @@ const GitResolvedPullRequest = Schema.Struct({ headBranch: TrimmedNonEmptyStringSchema, state: GitPullRequestState, }); -type GitResolvedPullRequest = typeof GitResolvedPullRequest.Type; +export type GitResolvedPullRequest = typeof GitResolvedPullRequest.Type; // RPC Inputs diff --git a/packages/contracts/src/model.ts b/packages/contracts/src/model.ts index 47b904cd7603..bce1a766bc9b 100644 --- a/packages/contracts/src/model.ts +++ b/packages/contracts/src/model.ts @@ -4,16 +4,16 @@ import * as SchemaTransformation from "effect/SchemaTransformation"; import { TrimmedNonEmptyString } from "./baseSchemas.ts"; import { ProviderDriverKind } from "./providerInstance.ts"; -const ProviderOptionDescriptorType = Schema.Literals(["select", "boolean"]); -type ProviderOptionDescriptorType = typeof ProviderOptionDescriptorType.Type; +export const ProviderOptionDescriptorType = Schema.Literals(["select", "boolean"]); +export type ProviderOptionDescriptorType = typeof ProviderOptionDescriptorType.Type; -const ProviderOptionChoice = Schema.Struct({ +export const ProviderOptionChoice = Schema.Struct({ id: TrimmedNonEmptyString, label: TrimmedNonEmptyString, description: Schema.optional(TrimmedNonEmptyString), isDefault: Schema.optional(Schema.Boolean), }); -type ProviderOptionChoice = typeof ProviderOptionChoice.Type; +export type ProviderOptionChoice = typeof ProviderOptionChoice.Type; const ProviderOptionDescriptorBase = { id: TrimmedNonEmptyString, @@ -21,21 +21,21 @@ const ProviderOptionDescriptorBase = { description: Schema.optional(TrimmedNonEmptyString), } as const; -const SelectProviderOptionDescriptor = Schema.Struct({ +export const SelectProviderOptionDescriptor = Schema.Struct({ ...ProviderOptionDescriptorBase, type: Schema.Literal("select"), options: Schema.Array(ProviderOptionChoice), currentValue: Schema.optional(TrimmedNonEmptyString), promptInjectedValues: Schema.optional(Schema.Array(TrimmedNonEmptyString)), }); -type SelectProviderOptionDescriptor = typeof SelectProviderOptionDescriptor.Type; +export type SelectProviderOptionDescriptor = typeof SelectProviderOptionDescriptor.Type; -const BooleanProviderOptionDescriptor = Schema.Struct({ +export const BooleanProviderOptionDescriptor = Schema.Struct({ ...ProviderOptionDescriptorBase, type: Schema.Literal("boolean"), currentValue: Schema.optional(Schema.Boolean), }); -type BooleanProviderOptionDescriptor = typeof BooleanProviderOptionDescriptor.Type; +export type BooleanProviderOptionDescriptor = typeof BooleanProviderOptionDescriptor.Type; export const ProviderOptionDescriptor = Schema.Union([ SelectProviderOptionDescriptor, @@ -43,8 +43,8 @@ export const ProviderOptionDescriptor = Schema.Union([ ]); export type ProviderOptionDescriptor = typeof ProviderOptionDescriptor.Type; -const ProviderOptionSelectionValue = Schema.Union([TrimmedNonEmptyString, Schema.Boolean]); -type ProviderOptionSelectionValue = typeof ProviderOptionSelectionValue.Type; +export const ProviderOptionSelectionValue = Schema.Union([TrimmedNonEmptyString, Schema.Boolean]); +export type ProviderOptionSelectionValue = typeof ProviderOptionSelectionValue.Type; export const ProviderOptionSelection = Schema.Struct({ id: TrimmedNonEmptyString, @@ -132,12 +132,12 @@ export type ModelCapabilities = typeof ModelCapabilities.Type; * bare slug keeps its driver-default presentation; when `capabilities` is * set, its descriptors replace the driver default in the model picker. */ -const CustomModelEntry = Schema.Struct({ +export const CustomModelEntry = Schema.Struct({ slug: TrimmedNonEmptyString, name: Schema.optional(TrimmedNonEmptyString), capabilities: Schema.optional(ModelCapabilities), }); -type CustomModelEntry = typeof CustomModelEntry.Type; +export type CustomModelEntry = typeof CustomModelEntry.Type; /** On-disk custom model setting: the legacy bare slug, or a full entry. */ export const CustomModelSetting = Schema.Union([Schema.String, CustomModelEntry]); diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts index 2503f0768d7d..92e9fe01dd42 100644 --- a/packages/contracts/src/orchestration.ts +++ b/packages/contracts/src/orchestration.ts @@ -183,7 +183,7 @@ const ChatAttachmentId = TrimmedNonEmptyString.check( Schema.isMaxLength(CHAT_ATTACHMENT_ID_MAX_CHARS), Schema.isPattern(/^[a-z0-9_-]+$/i), ); -type ChatAttachmentId = typeof ChatAttachmentId.Type; +export type ChatAttachmentId = typeof ChatAttachmentId.Type; export const ChatImageAttachment = Schema.Struct({ type: Schema.Literal("image"), @@ -246,7 +246,7 @@ export const ChatAttachment = Schema.Union([ ]); export type ChatAttachment = typeof ChatAttachment.Type; const UploadChatAttachment = Schema.Union([UploadChatImageAttachment]); -type UploadChatAttachment = typeof UploadChatAttachment.Type; +export type UploadChatAttachment = typeof UploadChatAttachment.Type; export const ProjectScriptIcon = Schema.Literals([ "play", @@ -455,7 +455,7 @@ const OrchestrationLatestTurnState = Schema.Literals([ "completed", "error", ]); -type OrchestrationLatestTurnState = typeof OrchestrationLatestTurnState.Type; +export type OrchestrationLatestTurnState = typeof OrchestrationLatestTurnState.Type; export const OrchestrationLatestTurn = Schema.Struct({ turnId: TurnId, @@ -468,11 +468,11 @@ export const OrchestrationLatestTurn = Schema.Struct({ }); export type OrchestrationLatestTurn = typeof OrchestrationLatestTurn.Type; -const ThreadTitleRegeneration = Schema.Struct({ +export const ThreadTitleRegeneration = Schema.Struct({ requestId: CommandId, startedAt: IsoDateTime, }); -type ThreadTitleRegeneration = typeof ThreadTitleRegeneration.Type; +export type ThreadTitleRegeneration = typeof ThreadTitleRegeneration.Type; export const ThreadLinkedPullRequest = Schema.Struct({ projectId: ProjectId, @@ -659,7 +659,7 @@ export const OrchestrationShellStreamItem = Schema.Union([ ]); export type OrchestrationShellStreamItem = typeof OrchestrationShellStreamItem.Type; -const OrchestrationSubscribeShellInput = Schema.Struct({ +export const OrchestrationSubscribeShellInput = Schema.Struct({ /** * When provided, the server skips the initial full shell snapshot and instead * replays shell events after this sequence before streaming live events. @@ -675,9 +675,9 @@ const OrchestrationSubscribeShellInput = Schema.Struct({ */ requestCompletionMarker: Schema.optionalKey(Schema.Boolean), }); -type OrchestrationSubscribeShellInput = typeof OrchestrationSubscribeShellInput.Type; +export type OrchestrationSubscribeShellInput = typeof OrchestrationSubscribeShellInput.Type; -const OrchestrationSubscribeThreadInput = Schema.Struct({ +export const OrchestrationSubscribeThreadInput = Schema.Struct({ threadId: ThreadId, /** * When provided, the server skips the initial snapshot frame and instead @@ -701,7 +701,7 @@ const OrchestrationSubscribeThreadInput = Schema.Struct({ */ turnLimit: Schema.optionalKey(PositiveInt), }); -type OrchestrationSubscribeThreadInput = typeof OrchestrationSubscribeThreadInput.Type; +export type OrchestrationSubscribeThreadInput = typeof OrchestrationSubscribeThreadInput.Type; /** * Bounds a thread detail read to a window of recent turns. `turnLimit` counts @@ -952,7 +952,7 @@ const ThreadTurnStartBootstrap = Schema.Struct({ runSetupScript: Schema.optional(Schema.Boolean), }); -type ThreadTurnStartBootstrap = typeof ThreadTurnStartBootstrap.Type; +export type ThreadTurnStartBootstrap = typeof ThreadTurnStartBootstrap.Type; export const ThreadTurnStartCommand = Schema.Struct({ type: Schema.Literal("thread.turn.start"), @@ -1066,7 +1066,8 @@ const DispatchableClientOrchestrationCommand = Schema.Union([ ThreadCheckpointRevertCommand, ThreadSessionStopCommand, ]); -type DispatchableClientOrchestrationCommand = typeof DispatchableClientOrchestrationCommand.Type; +export type DispatchableClientOrchestrationCommand = + typeof DispatchableClientOrchestrationCommand.Type; export const ClientOrchestrationCommand = Schema.Union([ ProjectCreateCommand, @@ -1194,7 +1195,7 @@ const InternalOrchestrationCommand = Schema.Union([ ThreadRevertCompleteCommand, ThreadTitleRegenerationCompleteCommand, ]); -type InternalOrchestrationCommand = typeof InternalOrchestrationCommand.Type; +export type InternalOrchestrationCommand = typeof InternalOrchestrationCommand.Type; export const OrchestrationCommand = Schema.Union([ DispatchableClientOrchestrationCommand, @@ -1672,7 +1673,7 @@ export type OrchestrationThreadStreamItem = typeof OrchestrationThreadStreamItem export const OrchestrationCommandReceiptStatus = Schema.Literals(["accepted", "rejected"]); export type OrchestrationCommandReceiptStatus = typeof OrchestrationCommandReceiptStatus.Type; -const TurnCountRange = Schema.Struct({ +export const TurnCountRange = Schema.Struct({ fromTurnCount: NonNegativeInt, toTurnCount: NonNegativeInt, }).check( @@ -1708,7 +1709,7 @@ const ProjectionThreadTurnStatus = Schema.Literals([ "interrupted", "error", ]); -type ProjectionThreadTurnStatus = typeof ProjectionThreadTurnStatus.Type; +export type ProjectionThreadTurnStatus = typeof ProjectionThreadTurnStatus.Type; const ProjectionCheckpointRow = Schema.Struct({ threadId: ThreadId, @@ -1720,7 +1721,7 @@ const ProjectionCheckpointRow = Schema.Struct({ assistantMessageId: Schema.NullOr(MessageId), completedAt: IsoDateTime, }); -type ProjectionCheckpointRow = typeof ProjectionCheckpointRow.Type; +export type ProjectionCheckpointRow = typeof ProjectionCheckpointRow.Type; export const ProjectionPendingApprovalStatus = Schema.Literals(["pending", "resolved"]); export type ProjectionPendingApprovalStatus = typeof ProjectionPendingApprovalStatus.Type; @@ -1742,7 +1743,8 @@ export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields( ); export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type; -export type OrchestrationGetTurnDiffResult = typeof ThreadTurnDiff.Type; +export const OrchestrationGetTurnDiffResult = ThreadTurnDiff; +export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResult.Type; export const OrchestrationGetFullThreadDiffInput = Schema.Struct({ threadId: ThreadId, @@ -1751,7 +1753,8 @@ export const OrchestrationGetFullThreadDiffInput = Schema.Struct({ }); export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type; -export type OrchestrationGetFullThreadDiffResult = typeof ThreadTurnDiff.Type; +export const OrchestrationGetFullThreadDiffResult = ThreadTurnDiff; +export type OrchestrationGetFullThreadDiffResult = typeof OrchestrationGetFullThreadDiffResult.Type; export const OrchestrationThreadSearchSource = Schema.Literals(["user", "assistant"]); export type OrchestrationThreadSearchSource = typeof OrchestrationThreadSearchSource.Type; @@ -1778,20 +1781,20 @@ export const OrchestrationSearchThreadsResult = Schema.Struct({ }); export type OrchestrationSearchThreadsResult = typeof OrchestrationSearchThreadsResult.Type; -const OrchestrationGetWorkflowScriptInput = Schema.Struct({ +export const OrchestrationGetWorkflowScriptInput = Schema.Struct({ threadId: ThreadId, /** Absolute path from the workflow's runHandles.scriptPath. The server * re-derives containment; the client value is a hint, never trusted. */ scriptPath: TrimmedNonEmptyString, }); -type OrchestrationGetWorkflowScriptInput = typeof OrchestrationGetWorkflowScriptInput.Type; +export type OrchestrationGetWorkflowScriptInput = typeof OrchestrationGetWorkflowScriptInput.Type; -const OrchestrationGetWorkflowScriptResult = Schema.Struct({ +export const OrchestrationGetWorkflowScriptResult = Schema.Struct({ scriptPath: TrimmedNonEmptyString, contents: Schema.String, truncated: Schema.Boolean, }); -type OrchestrationGetWorkflowScriptResult = typeof OrchestrationGetWorkflowScriptResult.Type; +export type OrchestrationGetWorkflowScriptResult = typeof OrchestrationGetWorkflowScriptResult.Type; const WORKFLOW_SCRIPT_ERROR_MESSAGES = { "invalid-path": "Workflow scripts must be absolute .js paths.", @@ -1837,11 +1840,11 @@ export const OrchestrationRpcSchemas = { }, getTurnDiff: { input: OrchestrationGetTurnDiffInput, - output: ThreadTurnDiff, + output: OrchestrationGetTurnDiffResult, }, getFullThreadDiff: { input: OrchestrationGetFullThreadDiffInput, - output: ThreadTurnDiff, + output: OrchestrationGetFullThreadDiffResult, }, searchThreads: { input: OrchestrationSearchThreadsInput, diff --git a/packages/contracts/src/project.ts b/packages/contracts/src/project.ts index 4a6b27ccf664..12f29b5e4ab3 100644 --- a/packages/contracts/src/project.ts +++ b/packages/contracts/src/project.ts @@ -49,11 +49,11 @@ export const ProjectSearchContentsInput = Schema.Struct({ }); export type ProjectSearchContentsInput = typeof ProjectSearchContentsInput.Type; -const ProjectContentMatchRange = Schema.Struct({ +export const ProjectContentMatchRange = Schema.Struct({ start: NonNegativeInt, end: NonNegativeInt, }); -type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type; +export type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type; export const ProjectContentMatch = Schema.Struct({ path: TrimmedNonEmptyString, diff --git a/packages/contracts/src/providerInstance.ts b/packages/contracts/src/providerInstance.ts index 4841311c8ba2..2a9fc9ed0d1b 100644 --- a/packages/contracts/src/providerInstance.ts +++ b/packages/contracts/src/providerInstance.ts @@ -94,11 +94,12 @@ export const ProviderInstanceRef = Schema.Struct({ }); export type ProviderInstanceRef = typeof ProviderInstanceRef.Type; -const ProviderInstanceEnvironmentVariableName = TrimmedNonEmptyString.check( +export const ProviderInstanceEnvironmentVariableName = TrimmedNonEmptyString.check( Schema.isMaxLength(ENVIRONMENT_VARIABLE_NAME_MAX_CHARS), Schema.isPattern(ENVIRONMENT_VARIABLE_NAME_PATTERN), ); -type ProviderInstanceEnvironmentVariableName = typeof ProviderInstanceEnvironmentVariableName.Type; +export type ProviderInstanceEnvironmentVariableName = + typeof ProviderInstanceEnvironmentVariableName.Type; export const ProviderInstanceEnvironmentVariable = Schema.Struct({ name: ProviderInstanceEnvironmentVariableName, diff --git a/packages/contracts/src/pullRequest.ts b/packages/contracts/src/pullRequest.ts index 7e01751f0e6f..f766578bb1a3 100644 --- a/packages/contracts/src/pullRequest.ts +++ b/packages/contracts/src/pullRequest.ts @@ -185,8 +185,12 @@ export const PullRequestReaction = Schema.Struct({ }); export type PullRequestReaction = typeof PullRequestReaction.Type; -const PullRequestCommentKind = Schema.Literals(["issue-comment", "review-comment", "review"]); -type PullRequestCommentKind = typeof PullRequestCommentKind.Type; +export const PullRequestCommentKind = Schema.Literals([ + "issue-comment", + "review-comment", + "review", +]); +export type PullRequestCommentKind = typeof PullRequestCommentKind.Type; export const PullRequestComment = Schema.Struct({ id: TrimmedNonEmptyString, @@ -340,13 +344,13 @@ export type PullRequestReviewCapabilities = typeof PullRequestReviewCapabilities * command that closes a pull request, and has no way to post a remark here at all — so nothing it * shows in a conversation can be rewritten either. */ -const PullRequestEditCapabilities = Schema.Struct({ +export const PullRequestEditCapabilities = Schema.Struct({ /** The change request's own title and description can be rewritten. */ changeRequest: Schema.Boolean, /** A remark can be rewritten by whoever wrote it. */ comment: Schema.Boolean, }); -type PullRequestEditCapabilities = typeof PullRequestEditCapabilities.Type; +export type PullRequestEditCapabilities = typeof PullRequestEditCapabilities.Type; /** * What a host can do about who reviews. The two are independent: a host can take a request without diff --git a/packages/contracts/src/relay.ts b/packages/contracts/src/relay.ts index 5fb17aceea31..cac14af5c7c8 100644 --- a/packages/contracts/src/relay.ts +++ b/packages/contracts/src/relay.ts @@ -16,8 +16,8 @@ import { } from "./baseSchemas.ts"; import { ExecutionEnvironmentDescriptor } from "./environment.ts"; -const RelayAgentAwarenessPlatform = Schema.Literal("ios"); -type RelayAgentAwarenessPlatform = typeof RelayAgentAwarenessPlatform.Type; +export const RelayAgentAwarenessPlatform = Schema.Literal("ios"); +export type RelayAgentAwarenessPlatform = typeof RelayAgentAwarenessPlatform.Type; export const RelayAgentAwarenessPhase = Schema.Literals([ "starting", @@ -40,8 +40,8 @@ export const RelayAgentAwarenessPreferences = Schema.Struct({ }); export type RelayAgentAwarenessPreferences = typeof RelayAgentAwarenessPreferences.Type; -const RelayApnsEnvironment = Schema.Literals(["sandbox", "production"]); -type RelayApnsEnvironment = typeof RelayApnsEnvironment.Type; +export const RelayApnsEnvironment = Schema.Literals(["sandbox", "production"]); +export type RelayApnsEnvironment = typeof RelayApnsEnvironment.Type; export const RelayDeviceRegistrationRequest = Schema.Struct({ deviceId: TrimmedNonEmptyString, @@ -81,10 +81,10 @@ export const RelayClientDeviceRecord = Schema.Struct({ }); export type RelayClientDeviceRecord = typeof RelayClientDeviceRecord.Type; -const RelayListDevicesResponse = Schema.Struct({ +export const RelayListDevicesResponse = Schema.Struct({ devices: Schema.Array(RelayClientDeviceRecord), }); -type RelayListDevicesResponse = typeof RelayListDevicesResponse.Type; +export type RelayListDevicesResponse = typeof RelayListDevicesResponse.Type; export const RelayLiveActivityRegistrationRequest = Schema.Struct({ deviceId: TrimmedNonEmptyString, @@ -92,10 +92,10 @@ export const RelayLiveActivityRegistrationRequest = Schema.Struct({ }); export type RelayLiveActivityRegistrationRequest = typeof RelayLiveActivityRegistrationRequest.Type; -const RelayDeviceUnregistrationParams = Schema.Struct({ +export const RelayDeviceUnregistrationParams = Schema.Struct({ deviceId: TrimmedNonEmptyString, }); -type RelayDeviceUnregistrationParams = typeof RelayDeviceUnregistrationParams.Type; +export type RelayDeviceUnregistrationParams = typeof RelayDeviceUnregistrationParams.Type; export const RelayAgentActivityState = Schema.Struct({ environmentId: EnvironmentId, @@ -199,6 +199,7 @@ export const RelayAgentActivityPublishProofPayload = Schema.Struct({ }); export type RelayAgentActivityPublishProofPayload = typeof RelayAgentActivityPublishProofPayload.Type; +export type RelayAgentActivityPublishProof = string; export const RelayAgentActivityPublishRequest = Schema.Struct({ state: Schema.NullOr(RelayAgentActivityState).annotate({ @@ -210,11 +211,11 @@ export const RelayAgentActivityPublishRequest = Schema.Struct({ }).annotate({ description: "Publishes a signed agent-awareness update from an environment." }); export type RelayAgentActivityPublishRequest = typeof RelayAgentActivityPublishRequest.Type; -const RelayEnvironmentLinkScope = Schema.Literals([ +export const RelayEnvironmentLinkScope = Schema.Literals([ "agent_activity_notifications", "managed_tunnels", ]); -type RelayEnvironmentLinkScope = typeof RelayEnvironmentLinkScope.Type; +export type RelayEnvironmentLinkScope = typeof RelayEnvironmentLinkScope.Type; export const RelayEnvironmentLinkProofPayload = Schema.Struct({ ...RelaySignedJwtRegisteredClaims, @@ -289,25 +290,26 @@ export const RelayEnvironmentLinkProofInvalidReason = Schema.Literals([ export type RelayEnvironmentLinkProofInvalidReason = typeof RelayEnvironmentLinkProofInvalidReason.Type; -const RelayEnvironmentLinkFailedReason = Schema.Literals([ +export const RelayEnvironmentLinkFailedReason = Schema.Literals([ "link_persistence_failed", "credential_persistence_failed", "replay_persistence_failed", "internal_error", ]); -type RelayEnvironmentLinkFailedReason = typeof RelayEnvironmentLinkFailedReason.Type; +export type RelayEnvironmentLinkFailedReason = typeof RelayEnvironmentLinkFailedReason.Type; -const RelayEnvironmentLinkUnavailableReason = Schema.Literals([ +export const RelayEnvironmentLinkUnavailableReason = Schema.Literals([ "managed_endpoint_not_configured", "managed_endpoint_provisioning_failed", ]); -type RelayEnvironmentLinkUnavailableReason = typeof RelayEnvironmentLinkUnavailableReason.Type; +export type RelayEnvironmentLinkUnavailableReason = + typeof RelayEnvironmentLinkUnavailableReason.Type; -const RelayEnvironmentEndpointUnavailableReason = Schema.Literals([ +export const RelayEnvironmentEndpointUnavailableReason = Schema.Literals([ "endpoint_request_failed", "endpoint_response_invalid", ]); -type RelayEnvironmentEndpointUnavailableReason = +export type RelayEnvironmentEndpointUnavailableReason = typeof RelayEnvironmentEndpointUnavailableReason.Type; export const RelayAgentActivityPublishProofInvalidReason = Schema.Literals([ @@ -328,13 +330,13 @@ export type RelayAuthInvalidReason = typeof RelayAuthInvalidReason.Type; export const RelayDpopFailureReason = DpopFailureReason; export type RelayDpopFailureReason = typeof RelayDpopFailureReason.Type; -const RelayInternalErrorReason = Schema.Literals([ +export const RelayInternalErrorReason = Schema.Literals([ "database_unavailable", "persistence_failed", "upstream_unavailable", "internal_error", ]); -type RelayInternalErrorReason = typeof RelayInternalErrorReason.Type; +export type RelayInternalErrorReason = typeof RelayInternalErrorReason.Type; export class RelayAuthInvalidError extends Schema.TaggedErrorClass()( "RelayAuthInvalidError", @@ -634,10 +636,10 @@ export const RelayClientEnvironmentRecord = Schema.Struct({ }); export type RelayClientEnvironmentRecord = typeof RelayClientEnvironmentRecord.Type; -const RelayListEnvironmentsResponse = Schema.Struct({ +export const RelayListEnvironmentsResponse = Schema.Struct({ environments: Schema.Array(RelayClientEnvironmentRecord), }); -type RelayListEnvironmentsResponse = typeof RelayListEnvironmentsResponse.Type; +export type RelayListEnvironmentsResponse = typeof RelayListEnvironmentsResponse.Type; export const RelayEnvironmentConnectRequest = Schema.Struct({ deviceId: Schema.optional( @@ -677,7 +679,7 @@ export type RelayPublicClientId = typeof RelayPublicClientId.Type; export const RelayMobileClientId = "t3-mobile" as const; export const RelayWebClientId = "t3-web" as const; -const RelayDpopAccessTokenRequest = Schema.Struct({ +export const RelayDpopAccessTokenRequest = Schema.Struct({ grant_type: Schema.Literal(RelayDpopTokenExchangeGrantType), subject_token: TrimmedNonEmptyString.annotate({ description: "Clerk bearer token for the signed-in cloud user.", @@ -694,31 +696,31 @@ const RelayDpopAccessTokenRequest = Schema.Struct({ }) .annotate({ description: "OAuth token exchange request for a DPoP-bound relay access token." }) .pipe(HttpApiSchema.asFormUrlEncoded()); -type RelayDpopAccessTokenRequest = typeof RelayDpopAccessTokenRequest.Type; +export type RelayDpopAccessTokenRequest = typeof RelayDpopAccessTokenRequest.Type; -const RelayDpopAccessTokenResponse = Schema.Struct({ +export const RelayDpopAccessTokenResponse = Schema.Struct({ access_token: TrimmedNonEmptyString, issued_token_type: Schema.Literal(RelayAccessTokenType), token_type: Schema.Literal("DPoP"), expires_in: Schema.Int.check(Schema.isGreaterThan(0)), scope: TrimmedNonEmptyString, }); -type RelayDpopAccessTokenResponse = typeof RelayDpopAccessTokenResponse.Type; +export type RelayDpopAccessTokenResponse = typeof RelayDpopAccessTokenResponse.Type; -const RelayBearerRequestHeaders = Schema.Struct({ +export const RelayBearerRequestHeaders = Schema.Struct({ authorization: TrimmedNonEmptyString, }); -const RelayDpopProofRequestHeaders = Schema.Struct({ +export const RelayDpopProofRequestHeaders = Schema.Struct({ dpop: TrimmedNonEmptyString, }); -const RelayDpopRequestHeaders = Schema.Struct({ +export const RelayDpopRequestHeaders = Schema.Struct({ authorization: TrimmedNonEmptyString, dpop: TrimmedNonEmptyString, }); -const RelayAuthorizationServerMetadata = Schema.Struct({ +export const RelayAuthorizationServerMetadata = Schema.Struct({ issuer: TrimmedNonEmptyString, token_endpoint: TrimmedNonEmptyString, grant_types_supported: Schema.Array(Schema.Literal(RelayDpopTokenExchangeGrantType)), @@ -727,7 +729,7 @@ const RelayAuthorizationServerMetadata = Schema.Struct({ scopes_supported: Schema.Array(RelayDpopAccessTokenScope), }); -const RelayProtectedResourceMetadata = Schema.Struct({ +export const RelayProtectedResourceMetadata = Schema.Struct({ resource: TrimmedNonEmptyString, authorization_servers: Schema.Array(TrimmedNonEmptyString), scopes_supported: Schema.Array(RelayDpopAccessTokenScope), @@ -735,10 +737,10 @@ const RelayProtectedResourceMetadata = Schema.Struct({ dpop_signing_alg_values_supported: Schema.Array(Schema.Literal("ES256")), }); -const RelayEnvironmentUnlinkParams = Schema.Struct({ +export const RelayEnvironmentUnlinkParams = Schema.Struct({ environmentId: EnvironmentId, }); -type RelayEnvironmentUnlinkParams = typeof RelayEnvironmentUnlinkParams.Type; +export type RelayEnvironmentUnlinkParams = typeof RelayEnvironmentUnlinkParams.Type; export const RelayEnvironmentConnectResponse = Schema.Struct({ environmentId: EnvironmentId, @@ -748,8 +750,8 @@ export const RelayEnvironmentConnectResponse = Schema.Struct({ }); export type RelayEnvironmentConnectResponse = typeof RelayEnvironmentConnectResponse.Type; -const RelayEnvironmentStatusValue = Schema.Literals(["online", "offline"]); -type RelayEnvironmentStatusValue = typeof RelayEnvironmentStatusValue.Type; +export const RelayEnvironmentStatusValue = Schema.Literals(["online", "offline"]); +export type RelayEnvironmentStatusValue = typeof RelayEnvironmentStatusValue.Type; export const RelayEnvironmentStatusResponse = Schema.Struct({ environmentId: EnvironmentId, @@ -775,8 +777,8 @@ export const RelayCloudMintCredentialProofPayload = Schema.Struct({ }); export type RelayCloudMintCredentialProofPayload = typeof RelayCloudMintCredentialProofPayload.Type; -const RelayCloudMintCredentialProof = TrimmedNonEmptyString; -type RelayCloudMintCredentialProof = typeof RelayCloudMintCredentialProof.Type; +export const RelayCloudMintCredentialProof = TrimmedNonEmptyString; +export type RelayCloudMintCredentialProof = typeof RelayCloudMintCredentialProof.Type; export const RelayCloudMintCredentialRequest = Schema.Struct({ proof: RelayCloudMintCredentialProof, @@ -792,8 +794,8 @@ export const RelayCloudEnvironmentHealthProofPayload = Schema.Struct({ export type RelayCloudEnvironmentHealthProofPayload = typeof RelayCloudEnvironmentHealthProofPayload.Type; -const RelayCloudEnvironmentHealthProof = TrimmedNonEmptyString; -type RelayCloudEnvironmentHealthProof = typeof RelayCloudEnvironmentHealthProof.Type; +export const RelayCloudEnvironmentHealthProof = TrimmedNonEmptyString; +export type RelayCloudEnvironmentHealthProof = typeof RelayCloudEnvironmentHealthProof.Type; export const RelayCloudEnvironmentHealthRequest = Schema.Struct({ proof: RelayCloudEnvironmentHealthProof, @@ -867,11 +869,11 @@ export const RelayPublishResponse = Schema.Struct({ }); export type RelayPublishResponse = typeof RelayPublishResponse.Type; -const RelayHealthResponse = Schema.Struct({ +export const RelayHealthResponse = Schema.Struct({ ok: Schema.Boolean, service: Schema.Literal("relay"), }); -type RelayHealthResponse = typeof RelayHealthResponse.Type; +export type RelayHealthResponse = typeof RelayHealthResponse.Type; const RelayHealthGroup = HttpApiGroup.make("health") .add( diff --git a/packages/contracts/src/relayClient.ts b/packages/contracts/src/relayClient.ts index f84ef9079a3a..e78078d1eedb 100644 --- a/packages/contracts/src/relayClient.ts +++ b/packages/contracts/src/relayClient.ts @@ -18,6 +18,7 @@ export const RelayClientStatusSchema = Schema.Union([ version: Schema.String, }), ]); +export type RelayClientStatus = typeof RelayClientStatusSchema.Type; export const RelayClientInstallProgressStageSchema = Schema.Literals([ "checking", @@ -42,7 +43,7 @@ export const RelayClientInstallProgressEventSchema = Schema.Union([ ]); export type RelayClientInstallProgressEvent = typeof RelayClientInstallProgressEventSchema.Type; -const RelayClientInstallFailureReasonSchema = Schema.Literals([ +export const RelayClientInstallFailureReasonSchema = Schema.Literals([ "download_failed", "invalid_checksum", "install_locked", @@ -51,6 +52,7 @@ const RelayClientInstallFailureReasonSchema = Schema.Literals([ "validation_failed", "write_failed", ]); +export type RelayClientInstallFailureReason = typeof RelayClientInstallFailureReasonSchema.Type; export class RelayClientInstallFailedError extends Schema.TaggedErrorClass()( "RelayClientInstallFailedError", diff --git a/packages/contracts/src/resourceTelemetry.ts b/packages/contracts/src/resourceTelemetry.ts index 86a25bfebe43..3ec1e4de3ef4 100644 --- a/packages/contracts/src/resourceTelemetry.ts +++ b/packages/contracts/src/resourceTelemetry.ts @@ -78,57 +78,58 @@ export const ResourceMonitorProcessSample = Schema.Struct({ }); export type ResourceMonitorProcessSample = typeof ResourceMonitorProcessSample.Type; -const ResourceMonitorConfigureCommand = Schema.Struct({ +export const ResourceMonitorConfigureCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("configure"), rootPid: PositiveInt, sampleIntervalMs: NonNegativeInt, externalProcesses: Schema.Array(ResourceMonitorExternalProcess), }); -type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type; +export type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type; -const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({ +export const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setExternalProcesses"), processes: Schema.Array(ResourceMonitorExternalProcess), }); -type ResourceMonitorSetExternalProcessesCommand = +export type ResourceMonitorSetExternalProcessesCommand = typeof ResourceMonitorSetExternalProcessesCommand.Type; -const ResourceMonitorSampleNowCommand = Schema.Struct({ +export const ResourceMonitorSampleNowCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("sampleNow"), requestId: TrimmedNonEmptyString, }); -type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type; +export type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type; -const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({ +export const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setSampleInterval"), sampleIntervalMs: NonNegativeInt, }); -type ResourceMonitorSetSampleIntervalCommand = typeof ResourceMonitorSetSampleIntervalCommand.Type; +export type ResourceMonitorSetSampleIntervalCommand = + typeof ResourceMonitorSetSampleIntervalCommand.Type; -const ResourceMonitorSetStreamingCommand = Schema.Struct({ +export const ResourceMonitorSetStreamingCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("setStreaming"), enabled: Schema.Boolean, }); -type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type; +export type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type; -const ResourceMonitorReadHistoryCommand = Schema.Struct({ +export const ResourceMonitorReadHistoryCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("readHistory"), requestId: TrimmedNonEmptyString, windowMs: NonNegativeInt, }); -type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type; +export type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type; -const ResourceMonitorShutdownCommand = Schema.Struct({ +export const ResourceMonitorShutdownCommand = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("shutdown"), }); -type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type; +export type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type; export const ResourceMonitorCommand = Schema.Union([ ResourceMonitorConfigureCommand, @@ -167,23 +168,23 @@ export const ResourceMonitorSnapshotEvent = Schema.Struct({ }); export type ResourceMonitorSnapshotEvent = typeof ResourceMonitorSnapshotEvent.Type; -const ResourceMonitorHistoryChunkEvent = Schema.Struct({ +export const ResourceMonitorHistoryChunkEvent = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("historyChunk"), requestId: TrimmedNonEmptyString, done: Schema.Boolean, snapshots: Schema.Array(ResourceMonitorSnapshotEvent), }); -type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type; +export type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type; -const ResourceMonitorErrorEvent = Schema.Struct({ +export const ResourceMonitorErrorEvent = Schema.Struct({ version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), type: Schema.Literal("error"), code: TrimmedNonEmptyString, message: TrimmedNonEmptyString, recoverable: Schema.Boolean, }); -type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type; +export type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type; export const ResourceMonitorEvent = Schema.Union([ ResourceMonitorHelloEvent, @@ -193,7 +194,7 @@ export const ResourceMonitorEvent = Schema.Union([ ]); export type ResourceMonitorEvent = typeof ResourceMonitorEvent.Type; -const DesktopElectronProcessType = Schema.Literals([ +export const DesktopElectronProcessType = Schema.Literals([ "Browser", "Tab", "Utility", @@ -204,7 +205,7 @@ const DesktopElectronProcessType = Schema.Literals([ "Pepper Plugin Broker", "Unknown", ]); -type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type; +export type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type; export const DesktopElectronProcessMetric = Schema.Struct({ pid: PositiveInt, @@ -237,12 +238,12 @@ export const DesktopHostTelemetrySnapshot = Schema.Struct({ }); export type DesktopHostTelemetrySnapshot = typeof DesktopHostTelemetrySnapshot.Type; -const DesktopHostTelemetryHello = Schema.Struct({ +export const DesktopHostTelemetryHello = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("desktopTelemetryHello"), electronPid: PositiveInt, }); -type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type; +export type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type; /** Terminal marker for a server-triggered desktop update run. */ export const DesktopUpdateRemoteOutcome = Schema.Literals([ @@ -278,20 +279,21 @@ export const DesktopHostTelemetryMessage = Schema.Union([ ]); export type DesktopHostTelemetryMessage = typeof DesktopHostTelemetryMessage.Type; -const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({ +export const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("setDiagnosticsDemand"), enabled: Schema.Boolean, }); -type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type; +export type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type; -const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({ +export const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({ version: Schema.Literal(1), type: Schema.Literal("setHostPowerIntervals"), activeIntervalMs: PositiveInt, idleIntervalMs: PositiveInt, }); -type DesktopTelemetrySetHostPowerIntervals = typeof DesktopTelemetrySetHostPowerIntervals.Type; +export type DesktopTelemetrySetHostPowerIntervals = + typeof DesktopTelemetrySetHostPowerIntervals.Type; /** * Server -> desktop main: run the app's own update flow now (check -> @@ -371,13 +373,13 @@ export const ResourceTelemetryAggregate = Schema.Struct({ }); export type ResourceTelemetryAggregate = typeof ResourceTelemetryAggregate.Type; -const ResourceTelemetryGroups = Schema.Struct({ +export const ResourceTelemetryGroups = Schema.Struct({ backend: ResourceTelemetryAggregate, electron: ResourceTelemetryAggregate, monitor: ResourceTelemetryAggregate, allT3: ResourceTelemetryAggregate, }); -type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type; +export type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type; export const ResourceTelemetrySourceHealth = Schema.Struct({ status: ResourceTelemetrySourceStatus, diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 6d87074d4709..ce9082477372 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -161,8 +161,8 @@ const QuitConfirmationModeSetting = Schema.Union([QuitConfirmationMode, LegacyCo * A user-chosen font family (a single name or a comma-separated list). Empty * means "use the app default"; clients compose their own fallback stacks. */ -const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200)); -type FontFamilyPreference = typeof FontFamilyPreference.Type; +export const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200)); +export type FontFamilyPreference = typeof FontFamilyPreference.Type; /** * The environment's theme, set with `t3 theme set `. Each client applies @@ -171,11 +171,11 @@ type FontFamilyPreference = typeof FontFamilyPreference.Type; * afterwards sticks until the next set. Empty means "no environment theme", * which is also how it is cleared. */ -const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64)); +export const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64)); // Deliberately absent from ServerSettingsPatch: `t3 theme set` checks that an // id is syntactically valid and actually resolvable, and a generic RPC patch // would let a client write a theme no client can resolve, bypassing both. -type DefaultThemePreference = typeof DefaultThemePreference.Type; +export type DefaultThemePreference = typeof DefaultThemePreference.Type; /** * Defaults for the in-app preview browser, applied whenever a tab is opened @@ -418,7 +418,7 @@ declare module "effect/Schema" { } } -type ProviderSettingsOrder = readonly Extract< +export type ProviderSettingsOrder = readonly Extract< keyof Fields, string >[]; @@ -766,11 +766,11 @@ export const UsageLimitSourceConfig = Schema.Struct({ }); export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type; -const ObservabilitySettings = Schema.Struct({ +export const ObservabilitySettings = Schema.Struct({ otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))), otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))), }); -type ObservabilitySettings = typeof ObservabilitySettings.Type; +export type ObservabilitySettings = typeof ObservabilitySettings.Type; export const SourceControlWritingStyleMode = Schema.Literals([ "repo_conventions", @@ -801,15 +801,15 @@ export const BackgroundActivityProfile = Schema.Literals([ export type BackgroundActivityProfile = typeof BackgroundActivityProfile.Type; export const DEFAULT_BACKGROUND_ACTIVITY_PROFILE: BackgroundActivityProfile = "balanced"; -const BackgroundActivityProfileSelection = Schema.Literals([ +export const BackgroundActivityProfileSelection = Schema.Literals([ "balanced", "performance", "battery-saver", "custom", ]); -type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type; +export type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type; -const BackgroundActivityOverrides = Schema.Struct({ +export const BackgroundActivityOverrides = Schema.Struct({ automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis), providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis), hostPowerMonitorActiveInterval: Schema.optionalKey(Schema.DurationFromMillis), @@ -820,7 +820,7 @@ const BackgroundActivityOverrides = Schema.Struct({ pauseWhenClientLowPower: Schema.optionalKey(Schema.Boolean), pauseWhenOnBattery: Schema.optionalKey(Schema.Boolean), }); -type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type; +export type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type; export const BackgroundActivitySettings = Schema.Struct({ schemaVersion: Schema.Literal(1).pipe(Schema.withDecodingDefault(Effect.succeed(1 as const))), @@ -1006,7 +1006,7 @@ export const resolveProviderInstanceEnabled = ( return instance.enabled ?? configEnabled ?? defaultEnabledForDriver(instance.driver); }; -const ServerSettingsOperation = Schema.Literals([ +export const ServerSettingsOperation = Schema.Literals([ "normalize", "check-exists", "read-file", @@ -1018,7 +1018,7 @@ const ServerSettingsOperation = Schema.Literals([ "write-file", "prepare-directory", ]); -type ServerSettingsOperation = typeof ServerSettingsOperation.Type; +export type ServerSettingsOperation = typeof ServerSettingsOperation.Type; export class ServerSettingsError extends Schema.TaggedErrorClass()( "ServerSettingsError", diff --git a/packages/contracts/src/sourceControl.ts b/packages/contracts/src/sourceControl.ts index 4e91678174e0..be3d70aefadd 100644 --- a/packages/contracts/src/sourceControl.ts +++ b/packages/contracts/src/sourceControl.ts @@ -92,8 +92,8 @@ export const SourceControlPublishRepositoryInput = Schema.Struct({ }); export type SourceControlPublishRepositoryInput = typeof SourceControlPublishRepositoryInput.Type; -const SourceControlPublishStatus = Schema.Literals(["pushed", "remote_added"]); -type SourceControlPublishStatus = typeof SourceControlPublishStatus.Type; +export const SourceControlPublishStatus = Schema.Literals(["pushed", "remote_added"]); +export type SourceControlPublishStatus = typeof SourceControlPublishStatus.Type; export const SourceControlPublishRepositoryResult = Schema.Struct({ repository: SourceControlRepositoryInfo, @@ -105,15 +105,15 @@ export const SourceControlPublishRepositoryResult = Schema.Struct({ }); export type SourceControlPublishRepositoryResult = typeof SourceControlPublishRepositoryResult.Type; -const SourceControlDiscoveryStatus = Schema.Literals(["available", "missing"]); -type SourceControlDiscoveryStatus = typeof SourceControlDiscoveryStatus.Type; +export const SourceControlDiscoveryStatus = Schema.Literals(["available", "missing"]); +export type SourceControlDiscoveryStatus = typeof SourceControlDiscoveryStatus.Type; -const SourceControlProviderAuthStatus = Schema.Literals([ +export const SourceControlProviderAuthStatus = Schema.Literals([ "authenticated", "unauthenticated", "unknown", ]); -type SourceControlProviderAuthStatus = typeof SourceControlProviderAuthStatus.Type; +export type SourceControlProviderAuthStatus = typeof SourceControlProviderAuthStatus.Type; export const SourceControlProviderAuth = Schema.Struct({ status: SourceControlProviderAuthStatus, diff --git a/packages/contracts/src/terminal.ts b/packages/contracts/src/terminal.ts index fda8c330c3cf..36e3d339f521 100644 --- a/packages/contracts/src/terminal.ts +++ b/packages/contracts/src/terminal.ts @@ -35,7 +35,7 @@ const TerminalSessionInput = Schema.Struct({ ...TerminalThreadInput.fields, terminalId: TerminalIdSchema, }); -type TerminalSessionInput = Schema.Codec.Encoded; +export type TerminalSessionInput = Schema.Codec.Encoded; export const TerminalOpenInput = Schema.Struct({ ...TerminalSessionInput.fields, diff --git a/packages/contracts/src/usage.ts b/packages/contracts/src/usage.ts index f2da1efe1fd6..c36a4557c294 100644 --- a/packages/contracts/src/usage.ts +++ b/packages/contracts/src/usage.ts @@ -134,8 +134,8 @@ export const UsageSourceFingerprint = Schema.Struct({ }); export type UsageSourceFingerprint = typeof UsageSourceFingerprint.Type; -const UsageSourceStatus = Schema.Literals(["ok", "missing", "partial", "failed"]); -type UsageSourceStatus = typeof UsageSourceStatus.Type; +export const UsageSourceStatus = Schema.Literals(["ok", "missing", "partial", "failed"]); +export type UsageSourceStatus = typeof UsageSourceStatus.Type; export const UsageSource = Schema.Struct({ fingerprint: UsageSourceFingerprint, @@ -154,8 +154,8 @@ export const UsageSource = Schema.Struct({ }); export type UsageSource = typeof UsageSource.Type; -const UsagePricingStatus = Schema.Literals(["fresh", "cached", "unavailable"]); -type UsagePricingStatus = typeof UsagePricingStatus.Type; +export const UsagePricingStatus = Schema.Literals(["fresh", "cached", "unavailable"]); +export type UsagePricingStatus = typeof UsagePricingStatus.Type; /** * Provenance for the rate table, so the UI can be honest about how good the diff --git a/packages/contracts/src/vcs.ts b/packages/contracts/src/vcs.ts index 650f762c77b6..a0956e83bd5b 100644 --- a/packages/contracts/src/vcs.ts +++ b/packages/contracts/src/vcs.ts @@ -4,20 +4,20 @@ import { NonNegativeInt, TrimmedNonEmptyString } from "./baseSchemas.ts"; export const VcsDriverKind = Schema.Literals(["git", "jj", "unknown"]); export type VcsDriverKind = typeof VcsDriverKind.Type; -const VcsFreshnessSource = Schema.Literals([ +export const VcsFreshnessSource = Schema.Literals([ "live-local", "cached-local", "cached-remote", "explicit-remote", ]); -type VcsFreshnessSource = typeof VcsFreshnessSource.Type; +export type VcsFreshnessSource = typeof VcsFreshnessSource.Type; -const VcsFreshness = Schema.Struct({ +export const VcsFreshness = Schema.Struct({ source: VcsFreshnessSource, observedAt: Schema.DateTimeUtc, expiresAt: Schema.Option(Schema.DateTimeUtc), }); -type VcsFreshness = typeof VcsFreshness.Type; +export type VcsFreshness = typeof VcsFreshness.Type; export const VcsDriverCapabilities = Schema.Struct({ kind: VcsDriverKind, @@ -44,13 +44,13 @@ export const VcsListWorkspaceFilesResult = Schema.Struct({ }); export type VcsListWorkspaceFilesResult = typeof VcsListWorkspaceFilesResult.Type; -const VcsRemote = Schema.Struct({ +export const VcsRemote = Schema.Struct({ name: TrimmedNonEmptyString, url: TrimmedNonEmptyString, pushUrl: Schema.Option(TrimmedNonEmptyString), isPrimary: Schema.Boolean, }); -type VcsRemote = typeof VcsRemote.Type; +export type VcsRemote = typeof VcsRemote.Type; export const VcsListRemotesResult = Schema.Struct({ remotes: Schema.Array(VcsRemote), @@ -234,13 +234,13 @@ export class VcsProcessMissingExitCodeError extends Schema.TaggedErrorClass()( "VcsRepositoryDetectionError",