deepspace 0.15.0 → 0.16.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/worker.d.ts CHANGED
@@ -3027,29 +3027,40 @@ declare const UPLOAD_PART_BYTES: number;
3027
3027
  */
3028
3028
  declare const MAX_UPLOAD_PARTS: number;
3029
3029
  /**
3030
- * Per-tier storage schedule, in bytes. Product semantics, not a deployment
3031
- * dial — the one table both storage allocations admit against:
3030
+ * The customer-visible storage schedule, in bytes, PER ACCOUNT — the total an
3031
+ * owner's uploaded files may occupy across every app they own, not a budget
3032
+ * each app gets separately. This is the number the billing page advertises.
3032
3033
  *
3033
- * - the repo store (Git packs + retained bundles + deploy assets), admitted
3034
- * by the app's Repo DO (`platform/deploy-worker/src/vc/storage-quota.ts`)
3035
- * - the app-files allocation, admitted by the shared files handler
3036
- * (`server/utils/scoped-r2-files.ts`)
3034
+ * Admitted by the shared files handler (`server/utils/scoped-r2-files.ts`),
3035
+ * which sums the owner's apps rather than the one being written to.
3037
3036
  *
3038
- * Each allocation gets the full amount independently; they are different
3039
- * buckets with different writers (docs/platform/r2-storage.md). The
3040
- * customer-visible "storage" number is the app-files allocation — the repo
3041
- * store is platform bookkeeping that degrades (drops rollback retention)
3042
- * rather than surfacing here.
3037
+ * It deliberately does NOT govern the repo store — see
3038
+ * `REPO_STORE_LIMIT_BYTES` below, and docs/platform/r2-storage.md.
3043
3039
  */
3044
- declare const APP_STORAGE_LIMIT_BYTES: {
3040
+ declare const ACCOUNT_STORAGE_LIMIT_BYTES: {
3045
3041
  readonly test: 0;
3046
3042
  readonly free: number;
3047
3043
  readonly starter: number;
3048
3044
  readonly premium: number;
3049
3045
  readonly admin: number;
3050
3046
  };
3051
- /** The storage limit for a billing tier; unknown or missing tiers get free. */
3047
+ /** The account storage limit for a billing tier; unknown or missing tiers get free. */
3052
3048
  declare function storageLimitForTier(tier: string | null | undefined): number;
3049
+ /**
3050
+ * The repo store's budget, per app, flat across every tier.
3051
+ *
3052
+ * Git packs, retained rollback bundles, and stored deploy assets are platform
3053
+ * bookkeeping, not something a customer buys — so this is a working ceiling,
3054
+ * not an entitlement, and it is deliberately small. An app that cannot fit its
3055
+ * SOURCE plus a few rollback bundles in this has something in the wrong place:
3056
+ * user uploads belong in the app-files allocation above, which is what the
3057
+ * account schedule sizes.
3058
+ *
3059
+ * Being flat is the point. Tying it to the tier table meant every raise to the
3060
+ * customer-facing number silently multiplied platform-side storage per app,
3061
+ * and made a push depend on a billing lookup that could refuse it.
3062
+ */
3063
+ declare const REPO_STORE_LIMIT_BYTES: number;
3053
3064
  /** The one storage-quota refusal sentence. `usedBytes` is net of any object
3054
3065
  * the upload replaces, so an upsert is charged only for its growth. */
3055
3066
  declare function storageQuotaMessage(incomingBytes: number, usedBytes: number, limitBytes: number): string;
@@ -3131,15 +3142,26 @@ interface ScopedR2Config {
3131
3142
  * applies.
3132
3143
  */
3133
3144
  interface StorageAdmission {
3134
- /** The WHOLE allocation the quota governs — the app prefix, not the
3135
- * (possibly deeper) scope prefix a request resolved to. */
3145
+ /** This app's own prefix — the one the incoming write lands under. */
3136
3146
  prefix: string;
3137
3147
  /**
3138
3148
  * Resolve the owner's limit in bytes. `null` means the lookup failed;
3139
- * writes then fail closed (503) rather than admitting unmetered storage,
3140
- * mirroring the repo store's `StorageBillingUnavailableError`.
3149
+ * writes then fail closed (503) rather than admitting unmetered storage.
3141
3150
  */
3142
3151
  limitBytes: () => Promise<number | null>;
3152
+ /**
3153
+ * The OTHER app prefixes this owner's storage spans, if any.
3154
+ *
3155
+ * The limit is per ACCOUNT, not per app: an owner's allocation is the total
3156
+ * across everything they own, so admission has to see the siblings too. `[]`
3157
+ * for an owner with one app, which is the common case and costs exactly what
3158
+ * it did when this was a per-app limit.
3159
+ *
3160
+ * Returning `null` means the owner's apps could not be enumerated. Like a
3161
+ * failed limit lookup that fails the write closed rather than admitting a
3162
+ * write against an allocation we cannot measure.
3163
+ */
3164
+ siblingPrefixes?: () => Promise<string[] | null>;
3143
3165
  }
3144
3166
  interface ScopedR2Auth {
3145
3167
  userId: string | null;
@@ -5361,4 +5383,4 @@ interface AppLogsResponse {
5361
5383
  declare const APP_LOG_EVENT_KEYS: readonly ["id", "timestamp", "level", "eventType", "message", "source", "outcome", "request", "exception"];
5362
5384
  type AppLogEventKey = (typeof APP_LOG_EVENT_KEYS)[number];
5363
5385
 
5364
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_LOG_EVENT_KEYS, APP_NAME_RULES, APP_STORAGE_LIMIT_BYTES, ASSET_NOT_FOUND_HANDLING_VALUES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AppNameResolution, type AppNameValidation, type AssetNotFoundHandling, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BROWSER_PROXY_ROUTES, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CANONICAL_APP_IDENTITY_MIGRATION_ID, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CLIENT_LOG_MARKER, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientErrorKind, type ClientErrorReport, 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, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIOptions, type DeepSpaceAIProvider, type DeepSpaceAgentDiagnosticContext, DeepSpaceAgentModelError, type DeepSpaceAgentProfile, DeepSpaceAgentProfileError, type DeepSpaceAgentProfileId, type DeepSpaceAgentStream, type DeepSpaceAgentStreamOptions, type DeepSpaceAgentSupport, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DeepSpaceDocumentationRouteEnv, type DeepSpaceDocumentationRouteOptions, 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, LOG_LEVELS, type LogLevel, MAX_APP_FILE_BYTES, MAX_DEPLOY_ASSET_FILE_BYTES, MAX_UPLOAD_PARTS, MAX_UPLOAD_REQUEST_BYTES, 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 ProxyRoute, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RELEASE_STAMP_PATH, REQUIRED_COMPATIBILITY_FLAGS, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESERVED_RUN_WORKER_FIRST, RESOURCE_ID_RE, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, RegistryClientError, type ResolvedColumn, type ResolvedDeepSpaceAgentModel, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SDK_RUN_WORKER_FIRST, STRICT_APP_ID_RE, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type ServerMessage, type SharedConnection, type StorageAdmission, type StoredRecord, type Summarizer, type SyncResult, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, UNDECLARED_ASSET_NOT_FOUND_HANDLING, UPLOAD_PART_BYTES, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, formatBytes, getChat, getDeepSpaceAIModel, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleClientErrorReport, handleSyncMessage, hasContent, isAssetNotFoundHandling, isAutoProvision, isFilesVerbPath, isOwner, isPlatformReservedPath, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, listDeepSpaceAgentModels, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, registerClientErrorRoute, registerDeepSpaceDocumentation, registryErrorJson, registryStub, resolveAppName, resolveColumn, resolveCompatibilityFlags, resolveDeepSpaceAgentModel, rowToData, runMigrations, serverBuild, storageLimitForTier, storageQuotaMessage, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppMigrationIds, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
5386
+ export { ACCOUNT_STORAGE_LIMIT_BYTES, AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_LOG_EVENT_KEYS, APP_NAME_RULES, ASSET_NOT_FOUND_HANDLING_VALUES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AppNameResolution, type AppNameValidation, type AssetNotFoundHandling, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BROWSER_PROXY_ROUTES, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CANONICAL_APP_IDENTITY_MIGRATION_ID, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CLIENT_LOG_MARKER, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientErrorKind, type ClientErrorReport, 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, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIOptions, type DeepSpaceAIProvider, type DeepSpaceAgentDiagnosticContext, DeepSpaceAgentModelError, type DeepSpaceAgentProfile, DeepSpaceAgentProfileError, type DeepSpaceAgentProfileId, type DeepSpaceAgentStream, type DeepSpaceAgentStreamOptions, type DeepSpaceAgentSupport, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DeepSpaceDocumentationRouteEnv, type DeepSpaceDocumentationRouteOptions, 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, LOG_LEVELS, type LogLevel, MAX_APP_FILE_BYTES, MAX_DEPLOY_ASSET_FILE_BYTES, MAX_UPLOAD_PARTS, MAX_UPLOAD_REQUEST_BYTES, 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 ProxyRoute, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RELEASE_STAMP_PATH, REPO_STORE_LIMIT_BYTES, REQUIRED_COMPATIBILITY_FLAGS, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESERVED_RUN_WORKER_FIRST, RESOURCE_ID_RE, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, RegistryClientError, type ResolvedColumn, type ResolvedDeepSpaceAgentModel, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SDK_RUN_WORKER_FIRST, STRICT_APP_ID_RE, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type ServerMessage, type SharedConnection, type StorageAdmission, type StoredRecord, type Summarizer, type SyncResult, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, UNDECLARED_ASSET_NOT_FOUND_HANDLING, UPLOAD_PART_BYTES, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, formatBytes, getChat, getDeepSpaceAIModel, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleClientErrorReport, handleSyncMessage, hasContent, isAssetNotFoundHandling, isAutoProvision, isFilesVerbPath, isOwner, isPlatformReservedPath, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, listDeepSpaceAgentModels, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, registerClientErrorRoute, registerDeepSpaceDocumentation, registryErrorJson, registryStub, resolveAppName, resolveColumn, resolveCompatibilityFlags, resolveDeepSpaceAgentModel, rowToData, runMigrations, serverBuild, storageLimitForTier, storageQuotaMessage, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppMigrationIds, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
package/dist/worker.js CHANGED
@@ -6317,19 +6317,21 @@ var MAX_UPLOAD_REQUEST_BYTES = 25 * 1024 * 1024;
6317
6317
  var UPLOAD_PART_BYTES = 20 * 1024 * 1024;
6318
6318
  var MAX_UPLOAD_PARTS = Math.ceil(MAX_APP_FILE_BYTES / UPLOAD_PART_BYTES);
6319
6319
  var MAX_BASE64_UPLOAD_BYTES = Math.floor(MAX_UPLOAD_REQUEST_BYTES * 3 / 4);
6320
- var APP_STORAGE_LIMIT_BYTES = {
6320
+ var GIB = 1024 * 1024 * 1024;
6321
+ var ACCOUNT_STORAGE_LIMIT_BYTES = {
6321
6322
  test: 0,
6322
- free: 128 * 1024 * 1024,
6323
- starter: 512 * 1024 * 1024,
6324
- premium: 2 * 1024 * 1024 * 1024,
6325
- admin: 10 * 1024 * 1024 * 1024
6323
+ free: 1 * GIB,
6324
+ starter: 10 * GIB,
6325
+ premium: 30 * GIB,
6326
+ admin: 100 * GIB
6326
6327
  };
6327
6328
  function storageLimitForTier(tier) {
6328
- if (tier && Object.hasOwn(APP_STORAGE_LIMIT_BYTES, tier)) {
6329
- return APP_STORAGE_LIMIT_BYTES[tier];
6329
+ if (tier && Object.hasOwn(ACCOUNT_STORAGE_LIMIT_BYTES, tier)) {
6330
+ return ACCOUNT_STORAGE_LIMIT_BYTES[tier];
6330
6331
  }
6331
- return APP_STORAGE_LIMIT_BYTES.free;
6332
+ return ACCOUNT_STORAGE_LIMIT_BYTES.free;
6332
6333
  }
6334
+ var REPO_STORE_LIMIT_BYTES = 256 * 1024 * 1024;
6333
6335
  function storageQuotaMessage(incomingBytes, usedBytes, limitBytes) {
6334
6336
  const free = Math.max(0, limitBytes - usedBytes);
6335
6337
  return `This upload needs ${formatBytes(incomingBytes)} but the app's file storage has ${formatBytes(free)} free (${formatBytes(usedBytes)} of ${formatBytes(limitBytes)} used). Delete files with \`deepspace app files rm <key>\`, or upgrade the owner's plan.`;
@@ -6420,7 +6422,7 @@ function declaredLength(request, what) {
6420
6422
  function isKeyWithinPrefix(key, prefix) {
6421
6423
  return key.startsWith(prefix);
6422
6424
  }
6423
- async function allocationUsage(bucket, prefix) {
6425
+ async function prefixUsage(bucket, prefix) {
6424
6426
  let total = 0;
6425
6427
  let cursor;
6426
6428
  do {
@@ -6430,6 +6432,13 @@ async function allocationUsage(bucket, prefix) {
6430
6432
  } while (cursor !== void 0);
6431
6433
  return total;
6432
6434
  }
6435
+ async function allocationUsage(bucket, storage) {
6436
+ const siblings = storage.siblingPrefixes ? await storage.siblingPrefixes() : [];
6437
+ if (siblings === null) return null;
6438
+ const prefixes = [storage.prefix, ...siblings.filter((p) => p !== storage.prefix)];
6439
+ const totals = await Promise.all(prefixes.map((prefix) => prefixUsage(bucket, prefix)));
6440
+ return totals.reduce((sum, bytes) => sum + bytes, 0);
6441
+ }
6433
6442
  async function admitStorage(bucket, storage, incomingBytes, replacesKey) {
6434
6443
  if (!storage) return null;
6435
6444
  const limit = await storage.limitBytes();
@@ -6440,7 +6449,14 @@ async function admitStorage(bucket, storage, incomingBytes, replacesKey) {
6440
6449
  "storage_limit_unavailable"
6441
6450
  );
6442
6451
  }
6443
- const stored = await allocationUsage(bucket, storage.prefix);
6452
+ const stored = await allocationUsage(bucket, storage);
6453
+ if (stored === null) {
6454
+ return fail(
6455
+ 503,
6456
+ "The storage already used by this account could not be measured; nothing was uploaded. Retry shortly.",
6457
+ "storage_limit_unavailable"
6458
+ );
6459
+ }
6444
6460
  const replaced = replacesKey === null ? 0 : (await bucket.head(replacesKey))?.size ?? 0;
6445
6461
  const used = stored - replaced;
6446
6462
  if (used + incomingBytes <= limit) return null;
@@ -6456,7 +6472,11 @@ async function admitAssembledObject(bucket, storage, key, objectBytes) {
6456
6472
  console.error("[files:quota] limit unavailable at complete; keeping", key);
6457
6473
  return null;
6458
6474
  }
6459
- const stored = await allocationUsage(bucket, storage.prefix);
6475
+ const stored = await allocationUsage(bucket, storage);
6476
+ if (stored === null) {
6477
+ console.error("[files:quota] account usage unmeasurable at complete; keeping", key);
6478
+ return null;
6479
+ }
6460
6480
  if (stored <= limit) return null;
6461
6481
  await bucket.delete(key).catch(() => void 0);
6462
6482
  return fail(
@@ -6853,9 +6873,10 @@ async function handleList(bucket, prefix, url, scope, auth) {
6853
6873
  });
6854
6874
  let storage;
6855
6875
  if (auth.storage) {
6856
- storage = { usedBytes: await allocationUsage(bucket, auth.storage.prefix) };
6876
+ const usedBytes = await allocationUsage(bucket, auth.storage);
6877
+ if (usedBytes !== null) storage = { usedBytes };
6857
6878
  const limitBytes = await auth.storage.limitBytes();
6858
- if (limitBytes !== null) storage.limitBytes = limitBytes;
6879
+ if (storage && limitBytes !== null) storage.limitBytes = limitBytes;
6859
6880
  }
6860
6881
  return Response.json(
6861
6882
  { files, truncated: listed.truncated, ...storage ? { storage } : {} },
@@ -9462,13 +9483,13 @@ var APP_LOG_EVENT_KEYS = [
9462
9483
  "exception"
9463
9484
  ];
9464
9485
  export {
9486
+ ACCOUNT_STORAGE_LIMIT_BYTES,
9465
9487
  AI_CHATS_SCHEMA,
9466
9488
  AI_MESSAGES_SCHEMA,
9467
9489
  ALLOWED_BINDING_TYPES,
9468
9490
  APP_ID_RE,
9469
9491
  APP_LOG_EVENT_KEYS,
9470
9492
  APP_NAME_RULES,
9471
- APP_STORAGE_LIMIT_BYTES,
9472
9493
  ASSET_NOT_FOUND_HANDLING_VALUES,
9473
9494
  AUTO_PROVISIONABLE_TYPES,
9474
9495
  AUTO_PROVISION_SENTINEL,
@@ -9520,6 +9541,7 @@ export {
9520
9541
  READ_RECEIPTS_SCHEMA,
9521
9542
  REGISTRY_INSTANCE,
9522
9543
  RELEASE_STAMP_PATH,
9544
+ REPO_STORE_LIMIT_BYTES,
9523
9545
  REQUIRED_COMPATIBILITY_FLAGS,
9524
9546
  RESERVED_BINDING_NAMES,
9525
9547
  RESERVED_COLLECTION_NAMES,