deepspace 0.5.0 → 0.5.1

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/worker.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as Y from 'yjs';
2
2
  import { LanguageModel, ToolSet, ModelMessage } from 'ai';
3
+ import * as zod_v4_core from 'zod/v4/core';
4
+ import * as zod from 'zod';
3
5
  import * as better_auth from 'better-auth';
4
6
  import { betterAuth } from 'better-auth';
5
7
  import * as better_auth_plugins from 'better-auth/plugins';
@@ -3009,7 +3011,8 @@ interface ScreenshotOptions {
3009
3011
  }
3010
3012
  interface ScreenshotEnv extends PlatformWorkerEnv {
3011
3013
  APP_NAME: string;
3012
- APP_IDENTITY_TOKEN: string;
3014
+ /** Absent until the app's first deploy registers it — see appendAppIdentity. */
3015
+ APP_IDENTITY_TOKEN?: string;
3013
3016
  }
3014
3017
  interface ScreenshotResult {
3015
3018
  /** PNG bytes. */
@@ -3503,6 +3506,33 @@ declare function timingSafeEqualHex(a: string, b: string): Promise<boolean>;
3503
3506
 
3504
3507
  declare function decodeJwtPayload(token: string | null | undefined): TokenDebugInfo | undefined;
3505
3508
 
3509
+ /**
3510
+ * Test-account identification, shared by every platform worker.
3511
+ *
3512
+ * Test accounts (created via `deepspace test-accounts`) are real Better Auth
3513
+ * users demarcated three ways, and a caller may present as any of them
3514
+ * depending on where the check runs:
3515
+ * - their email always ends with @deepspace.test (enforced at creation)
3516
+ * - their JWTs carry `isTestAccount: true` (minted by the auth-worker,
3517
+ * the source of truth)
3518
+ * - their billing profile's subscription tier is 'test' (mirrored by the
3519
+ * api-worker on every authenticated request)
3520
+ *
3521
+ * Gate anything a test account must not do with these helpers rather than
3522
+ * hand-rolled string comparisons, so the policy stays in one place. Prefer
3523
+ * checking the claim when a verified JWT is at hand, and the tier as the
3524
+ * fallback for persisted state that may outlive a claim (e.g. rows written
3525
+ * before a guard existed).
3526
+ */
3527
+
3528
+ declare const TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
3529
+ /** True when the email belongs to a test account (case-insensitive). */
3530
+ declare function isTestAccountEmail(email: string | null | undefined): boolean;
3531
+ /** True when verified JWT claims identify the caller as a test account. */
3532
+ declare function isTestAccountClaims(claims: JwtClaims | Record<string, unknown> | null | undefined): boolean;
3533
+ /** True when a billing subscription tier marks a test account. */
3534
+ declare function isTestAccountTier(tier: string | null | undefined): boolean;
3535
+
3506
3536
  interface DeepSpaceAuthConfig {
3507
3537
  /** D1 database binding */
3508
3538
  database: D1Database;
@@ -3544,6 +3574,7 @@ interface DeepSpaceAuthConfig {
3544
3574
  declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.Auth<{
3545
3575
  plugins: [{
3546
3576
  id: "organization";
3577
+ version: string;
3547
3578
  endpoints: better_auth_plugins.OrganizationEndpoints<better_auth_plugins.OrganizationOptions & {
3548
3579
  teams: {
3549
3580
  enabled: true;
@@ -3680,6 +3711,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3680
3711
  INVITATION_NOT_FOUND: better_auth.RawError<"INVITATION_NOT_FOUND">;
3681
3712
  YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION: better_auth.RawError<"YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION">;
3682
3713
  EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION: better_auth.RawError<"EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION">;
3714
+ EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION: better_auth.RawError<"EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION">;
3683
3715
  YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION">;
3684
3716
  INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION: better_auth.RawError<"INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION">;
3685
3717
  YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE">;
@@ -3714,6 +3746,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3714
3746
  ROLE_NAME_IS_ALREADY_TAKEN: better_auth.RawError<"ROLE_NAME_IS_ALREADY_TAKEN">;
3715
3747
  CANNOT_DELETE_A_PRE_DEFINED_ROLE: better_auth.RawError<"CANNOT_DELETE_A_PRE_DEFINED_ROLE">;
3716
3748
  ROLE_IS_ASSIGNED_TO_MEMBERS: better_auth.RawError<"ROLE_IS_ASSIGNED_TO_MEMBERS">;
3749
+ INVALID_TEAM_ID: better_auth.RawError<"INVALID_TEAM_ID">;
3717
3750
  };
3718
3751
  options: NoInfer<better_auth_plugins.OrganizationOptions & {
3719
3752
  teams: {
@@ -3725,13 +3758,17 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3725
3758
  }>;
3726
3759
  }, {
3727
3760
  id: "two-factor";
3761
+ version: string;
3728
3762
  endpoints: {
3729
3763
  enableTwoFactor: better_auth.StrictEndpoint<"/two-factor/enable", {
3730
3764
  method: "POST";
3731
- body: better_auth.ZodObject<{
3732
- password: better_auth.ZodString;
3733
- issuer: better_auth.ZodOptional<better_auth.ZodString>;
3734
- }, better_auth.$strip>;
3765
+ body: zod.ZodObject<{
3766
+ password: zod.ZodOptional<zod.ZodString>;
3767
+ issuer: zod.ZodOptional<zod.ZodString>;
3768
+ }, zod_v4_core.$strip> | zod.ZodObject<{
3769
+ password: zod.ZodString;
3770
+ issuer: zod.ZodOptional<zod.ZodString>;
3771
+ }, zod_v4_core.$strip>;
3735
3772
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3736
3773
  session: {
3737
3774
  session: Record<string, any> & {
@@ -3792,9 +3829,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3792
3829
  }>;
3793
3830
  disableTwoFactor: better_auth.StrictEndpoint<"/two-factor/disable", {
3794
3831
  method: "POST";
3795
- body: better_auth.ZodObject<{
3796
- password: better_auth.ZodString;
3797
- }, better_auth.$strip>;
3832
+ body: zod.ZodObject<{
3833
+ password: zod.ZodOptional<zod.ZodString>;
3834
+ }, zod_v4_core.$strip> | zod.ZodObject<{
3835
+ password: zod.ZodString;
3836
+ }, zod_v4_core.$strip>;
3798
3837
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3799
3838
  session: {
3800
3839
  session: Record<string, any> & {
@@ -3846,11 +3885,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3846
3885
  }>;
3847
3886
  verifyBackupCode: better_auth.StrictEndpoint<"/two-factor/verify-backup-code", {
3848
3887
  method: "POST";
3849
- body: better_auth.ZodObject<{
3850
- code: better_auth.ZodString;
3851
- disableSession: better_auth.ZodOptional<better_auth.ZodBoolean>;
3852
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
3853
- }, better_auth.$strip>;
3888
+ body: zod.ZodObject<{
3889
+ code: zod.ZodString;
3890
+ disableSession: zod.ZodOptional<zod.ZodBoolean>;
3891
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
3892
+ }, zod_v4_core.$strip>;
3854
3893
  metadata: {
3855
3894
  openapi: {
3856
3895
  description: string;
@@ -3957,9 +3996,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3957
3996
  }>;
3958
3997
  generateBackupCodes: better_auth.StrictEndpoint<"/two-factor/generate-backup-codes", {
3959
3998
  method: "POST";
3960
- body: better_auth.ZodObject<{
3961
- password: better_auth.ZodString;
3962
- }, better_auth.$strip>;
3999
+ body: zod.ZodObject<{
4000
+ password: zod.ZodOptional<zod.ZodString>;
4001
+ }, zod_v4_core.$strip> | zod.ZodObject<{
4002
+ password: zod.ZodString;
4003
+ }, zod_v4_core.$strip>;
3963
4004
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3964
4005
  session: {
3965
4006
  session: Record<string, any> & {
@@ -4021,18 +4062,18 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4021
4062
  }>;
4022
4063
  viewBackupCodes: better_auth.StrictEndpoint<string, {
4023
4064
  method: "POST";
4024
- body: better_auth.ZodObject<{
4025
- userId: better_auth.ZodCoercedString<unknown>;
4026
- }, better_auth.$strip>;
4065
+ body: zod.ZodObject<{
4066
+ userId: zod.ZodCoercedString<unknown>;
4067
+ }, zod_v4_core.$strip>;
4027
4068
  }, {
4028
4069
  status: boolean;
4029
4070
  backupCodes: string[];
4030
4071
  }>;
4031
4072
  sendTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/send-otp", {
4032
4073
  method: "POST";
4033
- body: better_auth.ZodOptional<better_auth.ZodObject<{
4034
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4035
- }, better_auth.$strip>>;
4074
+ body: zod.ZodOptional<zod.ZodObject<{
4075
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4076
+ }, zod_v4_core.$strip>>;
4036
4077
  metadata: {
4037
4078
  openapi: {
4038
4079
  summary: string;
@@ -4061,10 +4102,10 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4061
4102
  }>;
4062
4103
  verifyTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/verify-otp", {
4063
4104
  method: "POST";
4064
- body: better_auth.ZodObject<{
4065
- code: better_auth.ZodString;
4066
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4067
- }, better_auth.$strip>;
4105
+ body: zod.ZodObject<{
4106
+ code: zod.ZodString;
4107
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4108
+ }, zod_v4_core.$strip>;
4068
4109
  metadata: {
4069
4110
  openapi: {
4070
4111
  summary: string;
@@ -4150,9 +4191,9 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4150
4191
  }>;
4151
4192
  generateTOTP: better_auth.StrictEndpoint<string, {
4152
4193
  method: "POST";
4153
- body: better_auth.ZodObject<{
4154
- secret: better_auth.ZodString;
4155
- }, better_auth.$strip>;
4194
+ body: zod.ZodObject<{
4195
+ secret: zod.ZodString;
4196
+ }, zod_v4_core.$strip>;
4156
4197
  metadata: {
4157
4198
  openapi: {
4158
4199
  summary: string;
@@ -4204,9 +4245,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4204
4245
  };
4205
4246
  };
4206
4247
  }>)[];
4207
- body: better_auth.ZodObject<{
4208
- password: better_auth.ZodString;
4209
- }, better_auth.$strip>;
4248
+ body: zod.ZodObject<{
4249
+ password: zod.ZodOptional<zod.ZodString>;
4250
+ }, zod_v4_core.$strip> | zod.ZodObject<{
4251
+ password: zod.ZodString;
4252
+ }, zod_v4_core.$strip>;
4210
4253
  metadata: {
4211
4254
  openapi: {
4212
4255
  summary: string;
@@ -4235,10 +4278,10 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4235
4278
  }>;
4236
4279
  verifyTOTP: better_auth.StrictEndpoint<"/two-factor/verify-totp", {
4237
4280
  method: "POST";
4238
- body: better_auth.ZodObject<{
4239
- code: better_auth.ZodString;
4240
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4241
- }, better_auth.$strip>;
4281
+ body: zod.ZodObject<{
4282
+ code: zod.ZodString;
4283
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4284
+ }, zod_v4_core.$strip>;
4242
4285
  metadata: {
4243
4286
  openapi: {
4244
4287
  summary: string;
@@ -4284,6 +4327,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4284
4327
  matcher(context: better_auth.HookEndpointContext): boolean;
4285
4328
  handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
4286
4329
  twoFactorRedirect: boolean;
4330
+ twoFactorMethods: string[];
4287
4331
  } | undefined>;
4288
4332
  }[];
4289
4333
  };
@@ -4321,6 +4365,25 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4321
4365
  };
4322
4366
  index: true;
4323
4367
  };
4368
+ verified: {
4369
+ type: "boolean";
4370
+ required: false;
4371
+ defaultValue: true;
4372
+ input: false;
4373
+ };
4374
+ failedVerificationCount: {
4375
+ type: "number";
4376
+ required: false;
4377
+ defaultValue: number;
4378
+ input: false;
4379
+ returned: false;
4380
+ };
4381
+ lockedUntil: {
4382
+ type: "date";
4383
+ required: false;
4384
+ input: false;
4385
+ returned: false;
4386
+ };
4324
4387
  };
4325
4388
  };
4326
4389
  };
@@ -4338,6 +4401,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4338
4401
  INVALID_BACKUP_CODE: better_auth.RawError<"INVALID_BACKUP_CODE">;
4339
4402
  INVALID_CODE: better_auth.RawError<"INVALID_CODE">;
4340
4403
  TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: better_auth.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
4404
+ ACCOUNT_TEMPORARILY_LOCKED: better_auth.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
4341
4405
  INVALID_TWO_FACTOR_COOKIE: better_auth.RawError<"INVALID_TWO_FACTOR_COOKIE">;
4342
4406
  };
4343
4407
  }];
@@ -4375,4 +4439,4 @@ type DeepSpaceAuth = ReturnType<typeof createDeepSpaceAuth>;
4375
4439
  /** Collections that bypass schema checks (permissive access) */
4376
4440
  declare const SYSTEM_COLLECTIONS: Set<string>;
4377
4441
 
4378
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientMessage, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConnectionAttachment, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type HandlerContext, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MessageHandlers, type MsgType, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type ProtocolMessage, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotOptions, type ScreenshotResult, type ServerMessage, type SharedConnection, type StoredRecord, type Summarizer, type SyncResult, type TokenDebugInfo, type ToolResult, type ToolSchema, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, getChat, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleSyncMessage, hasContent, isAutoProvision, isOwner, lintSchema, loadMessages, makeDefaultSummarizer, meterAi, meterUsage, meterVectorize, noopPermissionContext, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, resolveAppName, resolveColumn, rowToData, runMigrations, serverBuild, timingSafeEqualHex, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
4442
+ export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientMessage, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConnectionAttachment, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type HandlerContext, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MessageHandlers, type MsgType, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type ProtocolMessage, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotOptions, type ScreenshotResult, type ServerMessage, type SharedConnection, type StoredRecord, type Summarizer, type SyncResult, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, getChat, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleSyncMessage, hasContent, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, meterAi, meterUsage, meterVectorize, noopPermissionContext, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, resolveAppName, resolveColumn, rowToData, runMigrations, serverBuild, timingSafeEqualHex, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
package/dist/worker.js CHANGED
@@ -6354,13 +6354,19 @@ async function composioTools(env, options) {
6354
6354
  return tools;
6355
6355
  }
6356
6356
 
6357
+ // src/server/utils/app-identity.ts
6358
+ function appendAppIdentity(headers, env) {
6359
+ headers.delete("x-app-identity-token");
6360
+ headers.delete("x-app-name");
6361
+ if (!env.APP_IDENTITY_TOKEN) return;
6362
+ headers.set("x-app-identity-token", env.APP_IDENTITY_TOKEN);
6363
+ headers.set("x-app-name", env.APP_NAME);
6364
+ }
6365
+
6357
6366
  // src/server/utils/screenshot.ts
6358
6367
  async function captureScreenshot(env, opts) {
6359
- const headers = new Headers({
6360
- "content-type": "application/json",
6361
- "x-app-identity-token": env.APP_IDENTITY_TOKEN,
6362
- "x-app-name": env.APP_NAME
6363
- });
6368
+ const headers = new Headers({ "content-type": "application/json" });
6369
+ appendAppIdentity(headers, env);
6364
6370
  const res = await platformWorkerFetch(
6365
6371
  env,
6366
6372
  new Request("https://platform-internal/internal/screenshot", {
@@ -7128,6 +7134,18 @@ async function timingSafeEqualHex(a, b) {
7128
7134
  return diff === 0;
7129
7135
  }
7130
7136
 
7137
+ // src/server/auth/testAccounts.ts
7138
+ var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
7139
+ function isTestAccountEmail(email) {
7140
+ return !!email && email.trim().toLowerCase().endsWith(TEST_ACCOUNT_EMAIL_SUFFIX);
7141
+ }
7142
+ function isTestAccountClaims(claims) {
7143
+ return claims?.isTestAccount === true;
7144
+ }
7145
+ function isTestAccountTier(tier) {
7146
+ return tier === "test";
7147
+ }
7148
+
7131
7149
  // src/server/auth/betterAuth.ts
7132
7150
  import { betterAuth } from "better-auth";
7133
7151
  import { organization, twoFactor } from "better-auth/plugins";
@@ -7249,6 +7267,7 @@ export {
7249
7267
  SYSTEM_COLLECTIONS,
7250
7268
  SYSTEM_MANAGED_COLUMNS,
7251
7269
  SchemaRegistry,
7270
+ TEST_ACCOUNT_EMAIL_SUFFIX,
7252
7271
  USERS_COLUMNS,
7253
7272
  VOTING_SCHEMAS,
7254
7273
  WORKSPACE_SCHEMAS,
@@ -7303,6 +7322,9 @@ export {
7303
7322
  hasContent,
7304
7323
  isAutoProvision,
7305
7324
  isOwner,
7325
+ isTestAccountClaims,
7326
+ isTestAccountEmail,
7327
+ isTestAccountTier,
7306
7328
  lintSchema,
7307
7329
  loadMessages,
7308
7330
  makeDefaultSummarizer,