11import type { Static } from "typebox" ;
22import { Type } from "typebox" ;
3- import { closedObject } from "./closed-object.js" ;
43import { NonEmptyString } from "./primitives.js" ;
54import { SESSION_PLACEMENT_STATES } from "./session-placement-state.js" ;
65
@@ -78,64 +77,85 @@ const TerminalSessionPlacementProperties = {
7877function createUnownedSessionPlacementSchema < const State extends "local" | "requested" > (
7978 state : State ,
8079) {
81- return closedObject ( { state : Type . Literal ( state ) , ...SessionPlacementTimingProperties } ) ;
80+ return Type . Object (
81+ { state : Type . Literal ( state ) , ...SessionPlacementTimingProperties } ,
82+ { additionalProperties : false } ,
83+ ) ;
8284}
8385
8486function createWorkerOwnedSessionPlacementSchema <
8587 const State extends "active" | "draining" | "reconciling" ,
8688> ( state : State ) {
87- return closedObject ( {
88- state : Type . Literal ( state ) ,
89- ...SessionPlacementTimingProperties ,
90- environmentId : NonEmptyString ,
91- activeOwnerEpoch : SessionPlacementOwnerEpochSchema ,
92- workerBundleHash : WorkerBundleHashSchema ,
93- ...SessionPlacementWorkspaceProperties ,
94- ...SessionPlacementAckProperties ,
95- } ) ;
89+ return Type . Object (
90+ {
91+ state : Type . Literal ( state ) ,
92+ ...SessionPlacementTimingProperties ,
93+ environmentId : NonEmptyString ,
94+ activeOwnerEpoch : SessionPlacementOwnerEpochSchema ,
95+ workerBundleHash : WorkerBundleHashSchema ,
96+ ...SessionPlacementWorkspaceProperties ,
97+ ...SessionPlacementAckProperties ,
98+ } ,
99+ { additionalProperties : false } ,
100+ ) ;
96101}
97102
98103export const LocalSessionPlacementSchema = createUnownedSessionPlacementSchema ( "local" ) ;
99104export const RequestedSessionPlacementSchema = createUnownedSessionPlacementSchema ( "requested" ) ;
100105
101- export const ProvisioningSessionPlacementSchema = closedObject ( {
102- state : Type . Literal ( "provisioning" ) ,
103- ...SessionPlacementTimingProperties ,
104- environmentId : Type . Optional ( NonEmptyString ) ,
105- } ) ;
106+ export const ProvisioningSessionPlacementSchema = Type . Object (
107+ {
108+ state : Type . Literal ( "provisioning" ) ,
109+ ...SessionPlacementTimingProperties ,
110+ environmentId : Type . Optional ( NonEmptyString ) ,
111+ } ,
112+ { additionalProperties : false } ,
113+ ) ;
106114
107- export const SyncingSessionPlacementSchema = closedObject ( {
108- state : Type . Literal ( "syncing" ) ,
109- ...SessionPlacementTimingProperties ,
110- environmentId : NonEmptyString ,
111- workerBundleHash : WorkerBundleHashSchema ,
112- } ) ;
115+ export const SyncingSessionPlacementSchema = Type . Object (
116+ {
117+ state : Type . Literal ( "syncing" ) ,
118+ ...SessionPlacementTimingProperties ,
119+ environmentId : NonEmptyString ,
120+ workerBundleHash : WorkerBundleHashSchema ,
121+ } ,
122+ { additionalProperties : false } ,
123+ ) ;
113124
114- export const StartingSessionPlacementSchema = closedObject ( {
115- state : Type . Literal ( "starting" ) ,
116- ...SessionPlacementTimingProperties ,
117- environmentId : NonEmptyString ,
118- workerBundleHash : WorkerBundleHashSchema ,
119- ...SessionPlacementWorkspaceProperties ,
120- } ) ;
125+ export const StartingSessionPlacementSchema = Type . Object (
126+ {
127+ state : Type . Literal ( "starting" ) ,
128+ ...SessionPlacementTimingProperties ,
129+ environmentId : NonEmptyString ,
130+ workerBundleHash : WorkerBundleHashSchema ,
131+ ...SessionPlacementWorkspaceProperties ,
132+ } ,
133+ { additionalProperties : false } ,
134+ ) ;
121135
122136export const ActiveWorkerSessionPlacementSchema = createWorkerOwnedSessionPlacementSchema ( "active" ) ;
123137export const DrainingSessionPlacementSchema = createWorkerOwnedSessionPlacementSchema ( "draining" ) ;
124138export const ReconcilingSessionPlacementSchema =
125139 createWorkerOwnedSessionPlacementSchema ( "reconciling" ) ;
126140
127- export const ReclaimedSessionPlacementSchema = closedObject ( {
128- state : Type . Literal ( "reclaimed" ) ,
129- ...SessionPlacementTimingProperties ,
130- ...TerminalSessionPlacementProperties ,
131- } ) ;
141+ export const ReclaimedSessionPlacementSchema = Type . Object (
142+ {
143+ state : Type . Literal ( "reclaimed" ) ,
144+ ...SessionPlacementTimingProperties ,
145+ ...TerminalSessionPlacementProperties ,
146+ } ,
147+ { additionalProperties : false } ,
148+ ) ;
132149
133- export const FailedSessionPlacementSchema = closedObject ( {
134- state : Type . Literal ( "failed" ) ,
135- ...SessionPlacementTimingProperties ,
136- ...TerminalSessionPlacementProperties ,
137- recoveryError : NonEmptyString ,
138- } ) ;
150+ export const FailedSessionPlacementSchema = Type . Object (
151+ {
152+ state : Type . Literal ( "failed" ) ,
153+ ...SessionPlacementTimingProperties ,
154+ ...TerminalSessionPlacementProperties ,
155+ recoveryError : NonEmptyString ,
156+ } ,
157+ { additionalProperties : false } ,
158+ ) ;
139159
140160/** Gateway-visible placement projection; `state` remains the closed discriminator. */
141161export const SessionPlacementSchema = Type . Union ( [
@@ -152,19 +172,25 @@ export const SessionPlacementSchema = Type.Union([
152172] ) ;
153173
154174/** Requests one-way dispatch of an existing local session to a configured worker profile. */
155- export const SessionsDispatchParamsSchema = closedObject ( {
156- key : NonEmptyString ,
157- agentId : Type . Optional ( NonEmptyString ) ,
158- profileId : NonEmptyString ,
159- } ) ;
175+ export const SessionsDispatchParamsSchema = Type . Object (
176+ {
177+ key : NonEmptyString ,
178+ agentId : Type . Optional ( NonEmptyString ) ,
179+ profileId : NonEmptyString ,
180+ } ,
181+ { additionalProperties : false } ,
182+ ) ;
160183
161184/** Result returned once session dispatch reaches durable worker ownership. */
162- export const SessionsDispatchResultSchema = closedObject ( {
163- ok : Type . Literal ( true ) ,
164- key : NonEmptyString ,
165- sessionId : NonEmptyString ,
166- placement : ActiveWorkerSessionPlacementSchema ,
167- } ) ;
185+ export const SessionsDispatchResultSchema = Type . Object (
186+ {
187+ ok : Type . Literal ( true ) ,
188+ key : NonEmptyString ,
189+ sessionId : NonEmptyString ,
190+ placement : ActiveWorkerSessionPlacementSchema ,
191+ } ,
192+ { additionalProperties : false } ,
193+ ) ;
168194
169195/** Requests safe workspace reconciliation and teardown of an active cloud worker. */
170196export const SessionsReclaimParamsSchema = Type . Object (
0 commit comments