deepspace 0.5.0 → 0.5.2

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.
@@ -0,0 +1,115 @@
1
+ import * as _playwright_test from '@playwright/test';
2
+ import { BrowserContext, Page, Browser } from '@playwright/test';
3
+ export { expect } from '@playwright/test';
4
+
5
+ interface MultiplayerUser {
6
+ context: BrowserContext;
7
+ page: Page;
8
+ email: string;
9
+ name: string;
10
+ /** Test account user ID, if known from the accounts registry. */
11
+ userId?: string;
12
+ }
13
+ /**
14
+ * Fixture function signature. Pass either a count (`users(2)`) or an
15
+ * array of account names (`users(['Alice', 'Bob'])`). Returns one entry
16
+ * per requested user.
17
+ */
18
+ type UsersFixture = (selector: number | string[], options?: {
19
+ label?: string;
20
+ }) => Promise<MultiplayerUser[]>;
21
+ interface MultiplayerFixtures {
22
+ users: UsersFixture;
23
+ }
24
+ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & MultiplayerFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
25
+
26
+ /**
27
+ * Account-credential plumbing for the testing module.
28
+ *
29
+ * Reads test accounts from `~/.deepspace/test-accounts.json` (the same
30
+ * file `deepspace test-accounts create` writes). Each account has at
31
+ * minimum `{email, password}`; `name` and `label` are optional.
32
+ *
33
+ * Used by the multi-user Playwright fixture in `./fixtures.ts` and is
34
+ * also exported standalone in case suites want to do their own
35
+ * orchestration.
36
+ */
37
+ interface TestAccount {
38
+ email: string;
39
+ password: string;
40
+ name?: string;
41
+ label?: string | null;
42
+ id?: string;
43
+ userId?: string;
44
+ createdAt?: number;
45
+ }
46
+ /**
47
+ * Load all test accounts the developer has created. Returns an empty
48
+ * array if the file doesn't exist yet.
49
+ */
50
+ declare function loadAllTestAccounts(): TestAccount[];
51
+ /**
52
+ * Pick `count` test accounts from the local registry, optionally
53
+ * filtered by `label`. Order-stable: sorted by `createdAt` ascending so
54
+ * the first test account you created is always the first one returned.
55
+ *
56
+ * Throws with a helpful message if not enough accounts exist.
57
+ */
58
+ declare function pickTestAccounts(count: number, options?: {
59
+ label?: string;
60
+ }): TestAccount[];
61
+ /**
62
+ * Find a single account by name. Used by `users(['Alice', 'Bob'])`.
63
+ * Throws if not found.
64
+ */
65
+ declare function findTestAccountByName(name: string): TestAccount;
66
+
67
+ /**
68
+ * Per-account `storageState` cache for Playwright.
69
+ *
70
+ * Better Auth applies a per-IP rate limit on `/api/auth/sign-in/email`
71
+ * (~5 sign-ins / 60s / endpoint). A multiplayer suite that spins up
72
+ * 5+ users per spec would hit the limit and start failing in non-obvious
73
+ * ways. This module signs each account in *once*, persists the
74
+ * resulting browser cookies + storage to disk, and reuses the file on
75
+ * subsequent runs.
76
+ *
77
+ * Cache layout:
78
+ * ~/.deepspace/playwright-states/<sha256(email)>.json
79
+ *
80
+ * Validity: a cached file is reused if Playwright successfully loads it
81
+ * AND the resulting context produces a non-anonymous session on the
82
+ * target app. If validation fails, we fall back to a fresh sign-in and
83
+ * overwrite the cache.
84
+ */
85
+
86
+ interface EnsureStorageStateOptions {
87
+ /** Max age of a cached state file before we re-sign-in. Default 7 days. */
88
+ maxAgeMs?: number;
89
+ /** Force a fresh sign-in even if the cache is fresh. */
90
+ force?: boolean;
91
+ }
92
+ /**
93
+ * Ensure a Playwright `storageState` file exists for `account` and
94
+ * return its path. Signs in once if the cache is missing, stale, or
95
+ * `force: true`.
96
+ */
97
+ declare function ensureStorageState(browser: Browser, account: {
98
+ email: string;
99
+ password: string;
100
+ }, baseURL: string, options?: EnsureStorageStateOptions): Promise<string>;
101
+ /**
102
+ * Convenience: open a fresh `BrowserContext` for `account` using the
103
+ * cached storage state (signing in if needed). The caller is responsible
104
+ * for closing the context.
105
+ */
106
+ declare function newSignedInContext(browser: Browser, account: {
107
+ email: string;
108
+ password: string;
109
+ }, baseURL: string, options?: EnsureStorageStateOptions): Promise<BrowserContext>;
110
+ /** Read a cached storageState file (mostly for debugging). */
111
+ declare function readCachedState(email: string): unknown | null;
112
+ /** Where the cache for `email` lives. Useful for diagnostics. */
113
+ declare function getStatePathForEmail(email: string): string;
114
+
115
+ export { type EnsureStorageStateOptions, type MultiplayerUser, type TestAccount, type UsersFixture, ensureStorageState, findTestAccountByName, getStatePathForEmail, loadAllTestAccounts, newSignedInContext, pickTestAccounts, readCachedState, test };
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';
@@ -2989,11 +2991,11 @@ declare function composioTools(env: ApiWorkerEnv, options: ComposioToolsOptions)
2989
2991
  * `null` on any non-2xx — callers should treat as "no preview available"
2990
2992
  * and surface their own fallback UX.
2991
2993
  *
2992
- * Auth is the same HMAC-of-appName pattern `/internal/files` uses:
2993
- * x-app-identity-token = hmac(PLATFORM_IDENTITY_SECRET, APP_NAME)
2994
- * x-app-name = APP_NAME
2994
+ * Auth is the same HMAC-of-appId pattern `/internal/files` uses:
2995
+ * x-app-identity-token = hmac(PLATFORM_IDENTITY_SECRET, DEEPSPACE_APP_ID)
2996
+ * x-app-id = DEEPSPACE_APP_ID
2995
2997
  *
2996
- * Apps already have both as bindings (APP_IDENTITY_TOKEN + APP_NAME),
2998
+ * Apps already have both as bindings (APP_IDENTITY_TOKEN + DEEPSPACE_APP_ID),
2997
2999
  * so this helper is a thin wrapper — no extra secrets to manage.
2998
3000
  */
2999
3001
 
@@ -3008,8 +3010,10 @@ interface ScreenshotOptions {
3008
3010
  fullPage?: boolean;
3009
3011
  }
3010
3012
  interface ScreenshotEnv extends PlatformWorkerEnv {
3011
- APP_NAME: string;
3012
- APP_IDENTITY_TOKEN: string;
3013
+ /** Immutable app id — the identity the platform verifies (HMAC input). */
3014
+ DEEPSPACE_APP_ID: string;
3015
+ /** Absent until the app's first deploy registers it — see appendAppIdentity. */
3016
+ APP_IDENTITY_TOKEN?: string;
3013
3017
  }
3014
3018
  interface ScreenshotResult {
3015
3019
  /** PNG bytes. */
@@ -3500,9 +3504,42 @@ declare function verifyJwt(config: JwtVerifierConfig, token: string | null | und
3500
3504
  */
3501
3505
  declare function computeHmacHex(secret: string, payload: string): Promise<string>;
3502
3506
  declare function timingSafeEqualHex(a: string, b: string): Promise<boolean>;
3507
+ /**
3508
+ * Constant-time equality for arbitrary strings (hash-then-compare: SHA-256
3509
+ * normalizes lengths so neither length nor content short-circuits). The one
3510
+ * implementation every worker's bearer/secret checks share.
3511
+ */
3512
+ declare function timingSafeEqualStrings(a: string, b: string): Promise<boolean>;
3503
3513
 
3504
3514
  declare function decodeJwtPayload(token: string | null | undefined): TokenDebugInfo | undefined;
3505
3515
 
3516
+ /**
3517
+ * Test-account identification, shared by every platform worker.
3518
+ *
3519
+ * Test accounts (created via `deepspace test-accounts`) are real Better Auth
3520
+ * users demarcated three ways, and a caller may present as any of them
3521
+ * depending on where the check runs:
3522
+ * - their email always ends with @deepspace.test (enforced at creation)
3523
+ * - their JWTs carry `isTestAccount: true` (minted by the auth-worker,
3524
+ * the source of truth)
3525
+ * - their billing profile's subscription tier is 'test' (mirrored by the
3526
+ * api-worker on every authenticated request)
3527
+ *
3528
+ * Gate anything a test account must not do with these helpers rather than
3529
+ * hand-rolled string comparisons, so the policy stays in one place. Prefer
3530
+ * checking the claim when a verified JWT is at hand, and the tier as the
3531
+ * fallback for persisted state that may outlive a claim (e.g. rows written
3532
+ * before a guard existed).
3533
+ */
3534
+
3535
+ declare const TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
3536
+ /** True when the email belongs to a test account (case-insensitive). */
3537
+ declare function isTestAccountEmail(email: string | null | undefined): boolean;
3538
+ /** True when verified JWT claims identify the caller as a test account. */
3539
+ declare function isTestAccountClaims(claims: JwtClaims | Record<string, unknown> | null | undefined): boolean;
3540
+ /** True when a billing subscription tier marks a test account. */
3541
+ declare function isTestAccountTier(tier: string | null | undefined): boolean;
3542
+
3506
3543
  interface DeepSpaceAuthConfig {
3507
3544
  /** D1 database binding */
3508
3545
  database: D1Database;
@@ -3544,6 +3581,7 @@ interface DeepSpaceAuthConfig {
3544
3581
  declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.Auth<{
3545
3582
  plugins: [{
3546
3583
  id: "organization";
3584
+ version: string;
3547
3585
  endpoints: better_auth_plugins.OrganizationEndpoints<better_auth_plugins.OrganizationOptions & {
3548
3586
  teams: {
3549
3587
  enabled: true;
@@ -3680,6 +3718,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3680
3718
  INVITATION_NOT_FOUND: better_auth.RawError<"INVITATION_NOT_FOUND">;
3681
3719
  YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION: better_auth.RawError<"YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION">;
3682
3720
  EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION: better_auth.RawError<"EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION">;
3721
+ EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION: better_auth.RawError<"EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION">;
3683
3722
  YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION">;
3684
3723
  INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION: better_auth.RawError<"INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION">;
3685
3724
  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 +3753,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3714
3753
  ROLE_NAME_IS_ALREADY_TAKEN: better_auth.RawError<"ROLE_NAME_IS_ALREADY_TAKEN">;
3715
3754
  CANNOT_DELETE_A_PRE_DEFINED_ROLE: better_auth.RawError<"CANNOT_DELETE_A_PRE_DEFINED_ROLE">;
3716
3755
  ROLE_IS_ASSIGNED_TO_MEMBERS: better_auth.RawError<"ROLE_IS_ASSIGNED_TO_MEMBERS">;
3756
+ INVALID_TEAM_ID: better_auth.RawError<"INVALID_TEAM_ID">;
3717
3757
  };
3718
3758
  options: NoInfer<better_auth_plugins.OrganizationOptions & {
3719
3759
  teams: {
@@ -3725,13 +3765,17 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3725
3765
  }>;
3726
3766
  }, {
3727
3767
  id: "two-factor";
3768
+ version: string;
3728
3769
  endpoints: {
3729
3770
  enableTwoFactor: better_auth.StrictEndpoint<"/two-factor/enable", {
3730
3771
  method: "POST";
3731
- body: better_auth.ZodObject<{
3732
- password: better_auth.ZodString;
3733
- issuer: better_auth.ZodOptional<better_auth.ZodString>;
3734
- }, better_auth.$strip>;
3772
+ body: zod.ZodObject<{
3773
+ password: zod.ZodOptional<zod.ZodString>;
3774
+ issuer: zod.ZodOptional<zod.ZodString>;
3775
+ }, zod_v4_core.$strip> | zod.ZodObject<{
3776
+ password: zod.ZodString;
3777
+ issuer: zod.ZodOptional<zod.ZodString>;
3778
+ }, zod_v4_core.$strip>;
3735
3779
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3736
3780
  session: {
3737
3781
  session: Record<string, any> & {
@@ -3792,9 +3836,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3792
3836
  }>;
3793
3837
  disableTwoFactor: better_auth.StrictEndpoint<"/two-factor/disable", {
3794
3838
  method: "POST";
3795
- body: better_auth.ZodObject<{
3796
- password: better_auth.ZodString;
3797
- }, better_auth.$strip>;
3839
+ body: zod.ZodObject<{
3840
+ password: zod.ZodOptional<zod.ZodString>;
3841
+ }, zod_v4_core.$strip> | zod.ZodObject<{
3842
+ password: zod.ZodString;
3843
+ }, zod_v4_core.$strip>;
3798
3844
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3799
3845
  session: {
3800
3846
  session: Record<string, any> & {
@@ -3846,11 +3892,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3846
3892
  }>;
3847
3893
  verifyBackupCode: better_auth.StrictEndpoint<"/two-factor/verify-backup-code", {
3848
3894
  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>;
3895
+ body: zod.ZodObject<{
3896
+ code: zod.ZodString;
3897
+ disableSession: zod.ZodOptional<zod.ZodBoolean>;
3898
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
3899
+ }, zod_v4_core.$strip>;
3854
3900
  metadata: {
3855
3901
  openapi: {
3856
3902
  description: string;
@@ -3957,9 +4003,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
3957
4003
  }>;
3958
4004
  generateBackupCodes: better_auth.StrictEndpoint<"/two-factor/generate-backup-codes", {
3959
4005
  method: "POST";
3960
- body: better_auth.ZodObject<{
3961
- password: better_auth.ZodString;
3962
- }, better_auth.$strip>;
4006
+ body: zod.ZodObject<{
4007
+ password: zod.ZodOptional<zod.ZodString>;
4008
+ }, zod_v4_core.$strip> | zod.ZodObject<{
4009
+ password: zod.ZodString;
4010
+ }, zod_v4_core.$strip>;
3963
4011
  use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3964
4012
  session: {
3965
4013
  session: Record<string, any> & {
@@ -4021,18 +4069,18 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4021
4069
  }>;
4022
4070
  viewBackupCodes: better_auth.StrictEndpoint<string, {
4023
4071
  method: "POST";
4024
- body: better_auth.ZodObject<{
4025
- userId: better_auth.ZodCoercedString<unknown>;
4026
- }, better_auth.$strip>;
4072
+ body: zod.ZodObject<{
4073
+ userId: zod.ZodCoercedString<unknown>;
4074
+ }, zod_v4_core.$strip>;
4027
4075
  }, {
4028
4076
  status: boolean;
4029
4077
  backupCodes: string[];
4030
4078
  }>;
4031
4079
  sendTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/send-otp", {
4032
4080
  method: "POST";
4033
- body: better_auth.ZodOptional<better_auth.ZodObject<{
4034
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4035
- }, better_auth.$strip>>;
4081
+ body: zod.ZodOptional<zod.ZodObject<{
4082
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4083
+ }, zod_v4_core.$strip>>;
4036
4084
  metadata: {
4037
4085
  openapi: {
4038
4086
  summary: string;
@@ -4061,10 +4109,10 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4061
4109
  }>;
4062
4110
  verifyTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/verify-otp", {
4063
4111
  method: "POST";
4064
- body: better_auth.ZodObject<{
4065
- code: better_auth.ZodString;
4066
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4067
- }, better_auth.$strip>;
4112
+ body: zod.ZodObject<{
4113
+ code: zod.ZodString;
4114
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4115
+ }, zod_v4_core.$strip>;
4068
4116
  metadata: {
4069
4117
  openapi: {
4070
4118
  summary: string;
@@ -4150,9 +4198,9 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4150
4198
  }>;
4151
4199
  generateTOTP: better_auth.StrictEndpoint<string, {
4152
4200
  method: "POST";
4153
- body: better_auth.ZodObject<{
4154
- secret: better_auth.ZodString;
4155
- }, better_auth.$strip>;
4201
+ body: zod.ZodObject<{
4202
+ secret: zod.ZodString;
4203
+ }, zod_v4_core.$strip>;
4156
4204
  metadata: {
4157
4205
  openapi: {
4158
4206
  summary: string;
@@ -4204,9 +4252,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4204
4252
  };
4205
4253
  };
4206
4254
  }>)[];
4207
- body: better_auth.ZodObject<{
4208
- password: better_auth.ZodString;
4209
- }, better_auth.$strip>;
4255
+ body: zod.ZodObject<{
4256
+ password: zod.ZodOptional<zod.ZodString>;
4257
+ }, zod_v4_core.$strip> | zod.ZodObject<{
4258
+ password: zod.ZodString;
4259
+ }, zod_v4_core.$strip>;
4210
4260
  metadata: {
4211
4261
  openapi: {
4212
4262
  summary: string;
@@ -4235,10 +4285,10 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4235
4285
  }>;
4236
4286
  verifyTOTP: better_auth.StrictEndpoint<"/two-factor/verify-totp", {
4237
4287
  method: "POST";
4238
- body: better_auth.ZodObject<{
4239
- code: better_auth.ZodString;
4240
- trustDevice: better_auth.ZodOptional<better_auth.ZodBoolean>;
4241
- }, better_auth.$strip>;
4288
+ body: zod.ZodObject<{
4289
+ code: zod.ZodString;
4290
+ trustDevice: zod.ZodOptional<zod.ZodBoolean>;
4291
+ }, zod_v4_core.$strip>;
4242
4292
  metadata: {
4243
4293
  openapi: {
4244
4294
  summary: string;
@@ -4284,6 +4334,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4284
4334
  matcher(context: better_auth.HookEndpointContext): boolean;
4285
4335
  handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
4286
4336
  twoFactorRedirect: boolean;
4337
+ twoFactorMethods: string[];
4287
4338
  } | undefined>;
4288
4339
  }[];
4289
4340
  };
@@ -4321,6 +4372,25 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4321
4372
  };
4322
4373
  index: true;
4323
4374
  };
4375
+ verified: {
4376
+ type: "boolean";
4377
+ required: false;
4378
+ defaultValue: true;
4379
+ input: false;
4380
+ };
4381
+ failedVerificationCount: {
4382
+ type: "number";
4383
+ required: false;
4384
+ defaultValue: number;
4385
+ input: false;
4386
+ returned: false;
4387
+ };
4388
+ lockedUntil: {
4389
+ type: "date";
4390
+ required: false;
4391
+ input: false;
4392
+ returned: false;
4393
+ };
4324
4394
  };
4325
4395
  };
4326
4396
  };
@@ -4338,6 +4408,7 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
4338
4408
  INVALID_BACKUP_CODE: better_auth.RawError<"INVALID_BACKUP_CODE">;
4339
4409
  INVALID_CODE: better_auth.RawError<"INVALID_CODE">;
4340
4410
  TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: better_auth.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
4411
+ ACCOUNT_TEMPORARILY_LOCKED: better_auth.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
4341
4412
  INVALID_TWO_FACTOR_COOKIE: better_auth.RawError<"INVALID_TWO_FACTOR_COOKIE">;
4342
4413
  };
4343
4414
  }];
@@ -4375,4 +4446,4 @@ type DeepSpaceAuth = ReturnType<typeof createDeepSpaceAuth>;
4375
4446
  /** Collections that bypass schema checks (permissive access) */
4376
4447
  declare const SYSTEM_COLLECTIONS: Set<string>;
4377
4448
 
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 };
4449
+ 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, timingSafeEqualStrings, 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-id");
6361
+ if (!env.APP_IDENTITY_TOKEN) return;
6362
+ headers.set("x-app-identity-token", env.APP_IDENTITY_TOKEN);
6363
+ headers.set("x-app-id", env.DEEPSPACE_APP_ID);
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", {
@@ -7127,6 +7133,30 @@ async function timingSafeEqualHex(a, b) {
7127
7133
  }
7128
7134
  return diff === 0;
7129
7135
  }
7136
+ async function timingSafeEqualStrings(a, b) {
7137
+ const encoder = new TextEncoder();
7138
+ const [aHash, bHash] = await Promise.all([
7139
+ crypto.subtle.digest("SHA-256", encoder.encode(a)),
7140
+ crypto.subtle.digest("SHA-256", encoder.encode(b))
7141
+ ]);
7142
+ const aBytes = new Uint8Array(aHash);
7143
+ const bBytes = new Uint8Array(bHash);
7144
+ let diff = 0;
7145
+ for (let i = 0; i < aBytes.length; i++) diff |= aBytes[i] ^ bBytes[i];
7146
+ return diff === 0;
7147
+ }
7148
+
7149
+ // src/server/auth/testAccounts.ts
7150
+ var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
7151
+ function isTestAccountEmail(email) {
7152
+ return !!email && email.trim().toLowerCase().endsWith(TEST_ACCOUNT_EMAIL_SUFFIX);
7153
+ }
7154
+ function isTestAccountClaims(claims) {
7155
+ return claims?.isTestAccount === true;
7156
+ }
7157
+ function isTestAccountTier(tier) {
7158
+ return tier === "test";
7159
+ }
7130
7160
 
7131
7161
  // src/server/auth/betterAuth.ts
7132
7162
  import { betterAuth } from "better-auth";
@@ -7249,6 +7279,7 @@ export {
7249
7279
  SYSTEM_COLLECTIONS,
7250
7280
  SYSTEM_MANAGED_COLUMNS,
7251
7281
  SchemaRegistry,
7282
+ TEST_ACCOUNT_EMAIL_SUFFIX,
7252
7283
  USERS_COLUMNS,
7253
7284
  VOTING_SCHEMAS,
7254
7285
  WORKSPACE_SCHEMAS,
@@ -7303,6 +7334,9 @@ export {
7303
7334
  hasContent,
7304
7335
  isAutoProvision,
7305
7336
  isOwner,
7337
+ isTestAccountClaims,
7338
+ isTestAccountEmail,
7339
+ isTestAccountTier,
7306
7340
  lintSchema,
7307
7341
  loadMessages,
7308
7342
  makeDefaultSummarizer,
@@ -7321,6 +7355,7 @@ export {
7321
7355
  runMigrations,
7322
7356
  serverBuild,
7323
7357
  timingSafeEqualHex,
7358
+ timingSafeEqualStrings,
7324
7359
  toUint8Array,
7325
7360
  totalChars,
7326
7361
  truncateOldToolResults,