deepspace 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -579,14 +579,12 @@ declare function getMessageType(data: Uint8Array): number;
579
579
  * Wire protocol constants.
580
580
  *
581
581
  * The JSON WebSocket protocol uses dotted string identifiers (e.g.
582
- * `"game.input"`) as the `type` discriminator. All message types are
582
+ * `"records.query"`) as the `type` discriminator. All message types are
583
583
  * grouped under a single `MSG` object so imports stay tidy:
584
584
  *
585
585
  * import { MSG, dispatch, clientBuild } from 'deepspace'
586
586
  *
587
587
  * dispatch<ServerMessage>(raw, {
588
- * [MSG.GAME_STATE]: (p) => { ... },
589
- * [MSG.GAME_TICK]: (p) => { ... },
590
588
  * })
591
589
  *
592
590
  * Each key's value is the on-wire string — grep-friendly, self-
@@ -615,14 +613,6 @@ declare const MSG: {
615
613
  readonly ACK: "records.ack";
616
614
  readonly LIST_SCHEMAS: "records.list_schemas";
617
615
  readonly RESUBSCRIBE: "records.resubscribe";
618
- readonly GAME_STATE: "game.state";
619
- readonly GAME_INPUT: "game.input";
620
- readonly GAME_PLAYER_JOIN: "game.player_join";
621
- readonly GAME_PLAYER_LEAVE: "game.player_leave";
622
- readonly GAME_PLAYER_READY: "game.player_ready";
623
- readonly GAME_START: "game.start";
624
- readonly GAME_END: "game.end";
625
- readonly GAME_TICK: "game.tick";
626
616
  readonly CANVAS_SHAPES: "canvas.shapes";
627
617
  readonly CANVAS_ADD: "canvas.add";
628
618
  readonly CANVAS_MOVE: "canvas.move";
@@ -711,7 +701,7 @@ declare const ROLE_ADMIN = "admin";
711
701
  * ---------------
712
702
  *
713
703
  * Some message types carry different payloads depending on who's sending.
714
- * `MSG.GAME_START`, for example, is `{}` when the client requests a start
704
+ * `MSG.RECORDS_RESUBSCRIBE`, for example, is `{}` when the client asks to
715
705
  * but `{ state, tick }` when the server broadcasts the start event.
716
706
  * `MSG.CANVAS_ADD` is a flat shape dict on the way in and a `{ shape }`
717
707
  * wrapper on the way out. Modelling these with one union would force
@@ -784,10 +774,7 @@ type ClientMessage = BaseMessage<typeof MSG.SUBSCRIBE, {
784
774
  collection: string;
785
775
  recordId: string;
786
776
  fieldName: string;
787
- }> | BaseMessage<typeof MSG.GAME_INPUT, {
788
- action: string;
789
- data: Record<string, unknown>;
790
- }> | BaseMessage<typeof MSG.GAME_PLAYER_READY, EmptyPayload> | BaseMessage<typeof MSG.GAME_START, EmptyPayload> | BaseMessage<typeof MSG.GAME_END, EmptyPayload> | BaseMessage<typeof MSG.CANVAS_ADD, unknown> | BaseMessage<typeof MSG.CANVAS_MOVE, {
777
+ }> | BaseMessage<typeof MSG.CANVAS_ADD, unknown> | BaseMessage<typeof MSG.CANVAS_MOVE, {
791
778
  shapeId: string;
792
779
  x: number;
793
780
  y: number;
@@ -862,26 +849,6 @@ type ServerMessage = BaseMessage<typeof MSG.QUERY_RESULT, {
862
849
  recordId: string;
863
850
  fieldName: string;
864
851
  canWrite: boolean;
865
- }> | BaseMessage<typeof MSG.GAME_STATE, {
866
- state: unknown;
867
- tick: number;
868
- players: unknown[];
869
- running: boolean;
870
- }> | BaseMessage<typeof MSG.GAME_TICK, {
871
- state: unknown;
872
- tick: number;
873
- }> | BaseMessage<typeof MSG.GAME_START, {
874
- state: unknown;
875
- tick: number;
876
- }> | BaseMessage<typeof MSG.GAME_END, {
877
- state: unknown;
878
- tick: number;
879
- }> | BaseMessage<typeof MSG.GAME_PLAYER_JOIN, {
880
- player: unknown;
881
- }> | BaseMessage<typeof MSG.GAME_PLAYER_LEAVE, {
882
- userId: string;
883
- }> | BaseMessage<typeof MSG.GAME_PLAYER_READY, {
884
- userId: string;
885
852
  }> | BaseMessage<typeof MSG.CANVAS_SHAPES, {
886
853
  shapes: unknown[];
887
854
  viewports: unknown[];
@@ -1007,25 +974,6 @@ declare const clientBuild: {
1007
974
  readonly fieldName: string;
1008
975
  };
1009
976
  };
1010
- gameInput: (action: string, data?: Record<string, unknown>) => {
1011
- readonly type: "game.input";
1012
- readonly payload: {
1013
- readonly action: string;
1014
- readonly data: Record<string, unknown>;
1015
- };
1016
- };
1017
- gamePlayerReady: () => {
1018
- readonly type: "game.player_ready";
1019
- readonly payload: EmptyPayload;
1020
- };
1021
- gameStart: () => {
1022
- readonly type: "game.start";
1023
- readonly payload: EmptyPayload;
1024
- };
1025
- gameEnd: () => {
1026
- readonly type: "game.end";
1027
- readonly payload: EmptyPayload;
1028
- };
1029
977
  canvasAdd: (shape: Record<string, unknown>) => {
1030
978
  readonly type: "canvas.add";
1031
979
  readonly payload: Record<string, unknown>;
@@ -1210,54 +1158,6 @@ declare const serverBuild: {
1210
1158
  readonly canWrite: boolean;
1211
1159
  };
1212
1160
  };
1213
- gameState: (state: unknown, tick: number, players: unknown[], running: boolean) => {
1214
- readonly type: "game.state";
1215
- readonly payload: {
1216
- readonly state: unknown;
1217
- readonly tick: number;
1218
- readonly players: unknown[];
1219
- readonly running: boolean;
1220
- };
1221
- };
1222
- gameTick: (state: unknown, tick: number) => {
1223
- readonly type: "game.tick";
1224
- readonly payload: {
1225
- readonly state: unknown;
1226
- readonly tick: number;
1227
- };
1228
- };
1229
- gameStart: (state: unknown, tick: number) => {
1230
- readonly type: "game.start";
1231
- readonly payload: {
1232
- readonly state: unknown;
1233
- readonly tick: number;
1234
- };
1235
- };
1236
- gameEnd: (state: unknown, tick: number) => {
1237
- readonly type: "game.end";
1238
- readonly payload: {
1239
- readonly state: unknown;
1240
- readonly tick: number;
1241
- };
1242
- };
1243
- gamePlayerJoin: (player: unknown) => {
1244
- readonly type: "game.player_join";
1245
- readonly payload: {
1246
- readonly player: unknown;
1247
- };
1248
- };
1249
- gamePlayerLeave: (userId: string) => {
1250
- readonly type: "game.player_leave";
1251
- readonly payload: {
1252
- readonly userId: string;
1253
- };
1254
- };
1255
- gamePlayerReady: (userId: string) => {
1256
- readonly type: "game.player_ready";
1257
- readonly payload: {
1258
- readonly userId: string;
1259
- };
1260
- };
1261
1161
  canvasShapes: (shapes: unknown[], viewports: unknown[]) => {
1262
1162
  readonly type: "canvas.shapes";
1263
1163
  readonly payload: {
@@ -1515,8 +1415,6 @@ interface HandlerContext {
1515
1415
  sendBinary(ws: WebSocket, data: Uint8Array): void;
1516
1416
  }
1517
1417
 
1518
- /** First source migration required by the canonical app identity cutover. */
1519
- declare const CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
1520
1418
  /** Asset-layer misses became real 404s, and the worker owns the fallback. The
1521
1419
  * config and the worker's fallback path have to move together. */
1522
1420
  declare const WORKER_OWNED_NOT_FOUND_MIGRATION_ID = "2026-08-worker-owned-not-found";
@@ -3349,57 +3247,6 @@ interface UseYjsRoomResult {
3349
3247
  */
3350
3248
  declare function useYjsRoom(docId: string, fieldName: string): UseYjsRoomResult;
3351
3249
 
3352
- /**
3353
- * useGameRoom — Connect to a GameRoom Durable Object.
3354
- *
3355
- * Opens a WebSocket to /ws/game/:roomId for real-time game state.
3356
- *
3357
- * @example
3358
- * const { state, sendInput, players, connected } = useGameRoom('my-game')
3359
- *
3360
- * Implementation note: this hook uses the typed wire protocol helpers
3361
- * (`clientBuild` for sends, `dispatch` for receives) from
3362
- * `shared/protocol/messages`. Hand-rolled `switch (msg.type)` blocks and
3363
- * raw `JSON.stringify({ type: MSG.X, payload: ... })` sends are a fast
3364
- * route to the "silent drop" bug class when a payload shape drifts —
3365
- * prefer the typed helpers instead.
3366
- */
3367
- interface GamePlayer {
3368
- userId: string;
3369
- userName: string;
3370
- ready: boolean;
3371
- connectedAt: string;
3372
- data: Record<string, unknown>;
3373
- }
3374
- interface UseGameRoomResult {
3375
- /** Current game state */
3376
- state: Record<string, unknown>;
3377
- /** Current tick number */
3378
- tick: number;
3379
- /** Connected players */
3380
- players: GamePlayer[];
3381
- /** Whether the game is currently running */
3382
- running: boolean;
3383
- /** Whether WebSocket is connected */
3384
- connected: boolean;
3385
- /**
3386
- * Whether this connection has write access. False for viewers /
3387
- * unauthenticated spectators — they receive state broadcasts but the
3388
- * send callbacks below no-op. UIs should disable input controls when
3389
- * false so spectators see why their actions don't take effect.
3390
- */
3391
- canWrite: boolean;
3392
- /** Send a game input (no-op for spectators) */
3393
- sendInput: (action: string, data?: Record<string, unknown>) => void;
3394
- /** Mark self as ready (no-op for spectators) */
3395
- setReady: () => void;
3396
- /** Request game start (no-op for spectators) */
3397
- startGame: () => void;
3398
- /** Request game end (no-op for spectators) */
3399
- endGame: () => void;
3400
- }
3401
- declare function useGameRoom(roomId: string): UseGameRoomResult;
3402
-
3403
3250
  /**
3404
3251
  * useCanvas — Connect to a CanvasRoom Durable Object.
3405
3252
  *
@@ -4992,4 +4839,4 @@ declare const ACCOUNT_STORAGE_LIMIT_BYTES: {
4992
4839
  declare function storageLimitForTier(tier: string | null | undefined): number;
4993
4840
  declare function formatBytes(bytes: number): string;
4994
4841
 
4995
- export { ACCOUNT_STORAGE_LIMIT_BYTES, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, type BaseMessage, CANONICAL_APP_IDENTITY_MIGRATION_ID, type CanvasShapeClient, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientErrorKind, type ClientErrorReport, type ClientErrorReporterOptions, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, type FileAttachment, type GamePlayer, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LinkPreviewData, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, type MsgType, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseGameRoomResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, installClientErrorReporter, integration, isAsyncResourceSlow, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, listDeepSpaceAgentModels, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, reportClientError, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, shouldGroupMessages, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useGameRoom, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };
4842
+ export { ACCOUNT_STORAGE_LIMIT_BYTES, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, type BaseMessage, type CanvasShapeClient, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientErrorKind, type ClientErrorReport, type ClientErrorReporterOptions, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, type FileAttachment, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LinkPreviewData, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, type MsgType, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, installClientErrorReporter, integration, isAsyncResourceSlow, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, listDeepSpaceAgentModels, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, reportClientError, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, shouldGroupMessages, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };