deepspace 0.14.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
@@ -2550,6 +2550,9 @@ declare function getMessageType(data: Uint8Array): number;
2550
2550
 
2551
2551
  /** First source migration required by the canonical app identity cutover. */
2552
2552
  declare const CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
2553
+ /** Asset-layer misses became real 404s, and the worker owns the fallback. The
2554
+ * config and the worker's fallback path have to move together. */
2555
+ declare const WORKER_OWNED_NOT_FOUND_MIGRATION_ID = "2026-08-worker-owned-not-found";
2553
2556
  type AppMigrationIdsValidation = {
2554
2557
  valid: true;
2555
2558
  ids: string[];
@@ -2736,6 +2739,82 @@ interface ResolvedDeepSpaceAgentModel {
2736
2739
  }
2737
2740
  declare function resolveDeepSpaceAgentModel(modelId: unknown, profileId?: DeepSpaceAgentProfileId): ResolvedDeepSpaceAgentModel | null;
2738
2741
 
2742
+ /**
2743
+ * Routing decisions the deploy worker, the CLI, and the scaffold all depend
2744
+ * on. One home so they cannot drift — see docs/platform/app-platform-contract.md
2745
+ * for why this boundary needs one.
2746
+ */
2747
+ /** Where every release serves its own identity. The deploy worker injects this
2748
+ * asset; the CLI polls it to learn which release an edge is serving. */
2749
+ declare const RELEASE_STAMP_PATH = "/.well-known/deepspace/release.json";
2750
+ /**
2751
+ * What the asset layer does with a path it has no file for — Cloudflare's own
2752
+ * `not_found_handling`, restated here because both ends of a deploy have to
2753
+ * agree on the legal values.
2754
+ *
2755
+ * The app declares this and the platform honors it. It is the app's to declare
2756
+ * because it is half of a decision whose other half lives in the app's worker:
2757
+ * `none` sends misses to the worker, which is the only place that can tell a
2758
+ * client route from a missing file, and a worker written for one setting
2759
+ * misbehaves under the other. Overriding it from here would silently rewrite
2760
+ * the behavior of code the platform did not write — see
2761
+ * docs/platform/app-platform-contract.md.
2762
+ */
2763
+ declare const ASSET_NOT_FOUND_HANDLING_VALUES: readonly ["none", "single-page-application", "404-page"];
2764
+ type AssetNotFoundHandling = (typeof ASSET_NOT_FOUND_HANDLING_VALUES)[number];
2765
+ /**
2766
+ * Applied when a deploy declares nothing.
2767
+ *
2768
+ * This is NOT Cloudflare's default (`none`) and not the value new apps ship.
2769
+ * It is what the platform hardcoded for every app before it started honoring
2770
+ * the declaration, and a deploy carrying no declaration is a CLI too old to
2771
+ * send one — necessarily paired with an app written for the old behavior.
2772
+ * Anything else here breaks every app whose CLI has not been upgraded, which
2773
+ * is the failure Rule 1 exists to prevent.
2774
+ */
2775
+ declare const UNDECLARED_ASSET_NOT_FOUND_HANDLING: AssetNotFoundHandling;
2776
+ declare function isAssetNotFoundHandling(value: unknown): value is AssetNotFoundHandling;
2777
+ /** Stated, not inherited from the compatibility date: from 2025-04-01 the
2778
+ * default sends navigations to the asset layer, which under
2779
+ * `not_found_handling: "none"` would 404 every client route before the
2780
+ * worker sees it. Required for every app, whatever it declares above. */
2781
+ declare const REQUIRED_COMPATIBILITY_FLAGS: readonly ["nodejs_compat", "assets_navigation_has_no_effect"];
2782
+ /** Required flags plus whatever the app added that does not contradict them. */
2783
+ declare function resolveCompatibilityFlags(declared: readonly string[] | undefined): string[];
2784
+ /** Routes Cloudflare hands to the worker before the asset layer answers. The
2785
+ * agent paths are here so an app publishing nothing there 404s instead of
2786
+ * returning its homepage. */
2787
+ declare const SDK_RUN_WORKER_FIRST: readonly ["/api/*", "/ws/*", "/internal/*", "/v1/*", "/_deepspace/*", "/llms.txt", "/llms-full.txt", "/.well-known/mcp", "/.well-known/mcp.json", "/.well-known/mcp/*"];
2788
+ /** Deny-list for an app's own `run_worker_first`. Strictly wider than what the
2789
+ * platform routes worker-first; expressing it as a superset keeps the
2790
+ * difference deliberate. */
2791
+ declare const RESERVED_RUN_WORKER_FIRST: readonly string[];
2792
+ /**
2793
+ * Whether the platform owns this path — so an app's worker must answer 404
2794
+ * rather than its shell when nothing is published there. Exported as a
2795
+ * predicate, not a list, because the patterns carry globs and every caller
2796
+ * matching them by hand is another copy that can drift.
2797
+ */
2798
+ declare function isPlatformReservedPath(pathname: string): boolean;
2799
+
2800
+ /**
2801
+ * The platform endpoints this SDK's client hooks call through an app's proxy.
2802
+ *
2803
+ * The app's worker forwards these with its own identity, so the proxy is an
2804
+ * allow-list rather than a passthrough. That list has to match what the hooks
2805
+ * actually call — and only this package knows that, which is why it is stated
2806
+ * here instead of copied into each scaffold. A frozen copy in a customer's
2807
+ * repo would 404 the next hook we ship, in their browser, silently.
2808
+ *
2809
+ * The scaffold still registers the proxy itself, visibly and editably; it just
2810
+ * reads the routes from here.
2811
+ */
2812
+ interface ProxyRoute {
2813
+ method: string;
2814
+ path: string;
2815
+ }
2816
+ declare const BROWSER_PROXY_ROUTES: ReadonlyArray<ProxyRoute>;
2817
+
2739
2818
  /**
2740
2819
  * Wildcard-aware CORS origin matching for the platform workers.
2741
2820
  *
@@ -2948,29 +3027,40 @@ declare const UPLOAD_PART_BYTES: number;
2948
3027
  */
2949
3028
  declare const MAX_UPLOAD_PARTS: number;
2950
3029
  /**
2951
- * Per-tier storage schedule, in bytes. Product semantics, not a deployment
2952
- * 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.
2953
3033
  *
2954
- * - the repo store (Git packs + retained bundles + deploy assets), admitted
2955
- * by the app's Repo DO (`platform/deploy-worker/src/vc/storage-quota.ts`)
2956
- * - the app-files allocation, admitted by the shared files handler
2957
- * (`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.
2958
3036
  *
2959
- * Each allocation gets the full amount independently; they are different
2960
- * buckets with different writers (docs/platform/r2-storage.md). The
2961
- * customer-visible "storage" number is the app-files allocation — the repo
2962
- * store is platform bookkeeping that degrades (drops rollback retention)
2963
- * 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.
2964
3039
  */
2965
- declare const APP_STORAGE_LIMIT_BYTES: {
3040
+ declare const ACCOUNT_STORAGE_LIMIT_BYTES: {
2966
3041
  readonly test: 0;
2967
3042
  readonly free: number;
2968
3043
  readonly starter: number;
2969
3044
  readonly premium: number;
2970
3045
  readonly admin: number;
2971
3046
  };
2972
- /** 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. */
2973
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;
2974
3064
  /** The one storage-quota refusal sentence. `usedBytes` is net of any object
2975
3065
  * the upload replaces, so an upsert is charged only for its growth. */
2976
3066
  declare function storageQuotaMessage(incomingBytes: number, usedBytes: number, limitBytes: number): string;
@@ -3052,15 +3142,26 @@ interface ScopedR2Config {
3052
3142
  * applies.
3053
3143
  */
3054
3144
  interface StorageAdmission {
3055
- /** The WHOLE allocation the quota governs — the app prefix, not the
3056
- * (possibly deeper) scope prefix a request resolved to. */
3145
+ /** This app's own prefix — the one the incoming write lands under. */
3057
3146
  prefix: string;
3058
3147
  /**
3059
3148
  * Resolve the owner's limit in bytes. `null` means the lookup failed;
3060
- * writes then fail closed (503) rather than admitting unmetered storage,
3061
- * mirroring the repo store's `StorageBillingUnavailableError`.
3149
+ * writes then fail closed (503) rather than admitting unmetered storage.
3062
3150
  */
3063
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>;
3064
3165
  }
3065
3166
  interface ScopedR2Auth {
3066
3167
  userId: string | null;
@@ -5282,4 +5383,4 @@ interface AppLogsResponse {
5282
5383
  declare const APP_LOG_EVENT_KEYS: readonly ["id", "timestamp", "level", "eventType", "message", "source", "outcome", "request", "exception"];
5283
5384
  type AppLogEventKey = (typeof APP_LOG_EVENT_KEYS)[number];
5284
5385
 
5285
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_LOG_EVENT_KEYS, APP_NAME_RULES, APP_STORAGE_LIMIT_BYTES, 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 AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, 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 QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESOURCE_ID_RE, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, RegistryClientError, type ResolvedColumn, type ResolvedDeepSpaceAgentModel, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, 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, UPLOAD_PART_BYTES, 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, 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, isAutoProvision, isFilesVerbPath, isOwner, 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, 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
@@ -6019,6 +6019,7 @@ var RESERVED_COLLECTION_NAMES = new Set(
6019
6019
  var APP_MIGRATION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/;
6020
6020
  var MAX_APP_MIGRATION_IDS = 256;
6021
6021
  var CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
6022
+ var WORKER_OWNED_NOT_FOUND_MIGRATION_ID = "2026-08-worker-owned-not-found";
6022
6023
  function validateAppMigrationIds(value) {
6023
6024
  if (!Array.isArray(value)) {
6024
6025
  return { valid: false, reason: "app migrations must be a JSON string array" };
@@ -6170,6 +6171,76 @@ function resolveDeepSpaceAgentModel(modelId, profileId = "application") {
6170
6171
  return { modelId: model.id, provider: model.provider, model, profile };
6171
6172
  }
6172
6173
 
6174
+ // src/shared/app-routing.ts
6175
+ var RELEASE_STAMP_PATH = "/.well-known/deepspace/release.json";
6176
+ var ASSET_NOT_FOUND_HANDLING_VALUES = [
6177
+ "none",
6178
+ "single-page-application",
6179
+ "404-page"
6180
+ ];
6181
+ var UNDECLARED_ASSET_NOT_FOUND_HANDLING = "single-page-application";
6182
+ function isAssetNotFoundHandling(value) {
6183
+ return ASSET_NOT_FOUND_HANDLING_VALUES.includes(value);
6184
+ }
6185
+ var REQUIRED_COMPATIBILITY_FLAGS = [
6186
+ "nodejs_compat",
6187
+ "assets_navigation_has_no_effect"
6188
+ ];
6189
+ var CONTRADICTORY_COMPATIBILITY_FLAGS = /* @__PURE__ */ new Set([
6190
+ "no_nodejs_compat",
6191
+ "assets_navigation_prefers_asset_serving"
6192
+ ]);
6193
+ function resolveCompatibilityFlags(declared) {
6194
+ const flags = new Set(REQUIRED_COMPATIBILITY_FLAGS);
6195
+ for (const flag of declared ?? []) {
6196
+ if (typeof flag !== "string") continue;
6197
+ const trimmed = flag.trim();
6198
+ if (!trimmed || CONTRADICTORY_COMPATIBILITY_FLAGS.has(trimmed)) continue;
6199
+ flags.add(trimmed);
6200
+ }
6201
+ return [...flags];
6202
+ }
6203
+ var SDK_RUN_WORKER_FIRST = [
6204
+ "/api/*",
6205
+ "/ws/*",
6206
+ "/internal/*",
6207
+ "/v1/*",
6208
+ "/_deepspace/*",
6209
+ "/llms.txt",
6210
+ "/llms-full.txt",
6211
+ "/.well-known/mcp",
6212
+ "/.well-known/mcp.json",
6213
+ "/.well-known/mcp/*"
6214
+ ];
6215
+ var DOCUMENTATION_PATHS = [
6216
+ "/_documentation",
6217
+ "/_documentation/*",
6218
+ "/_documentation-root",
6219
+ "/_documentation-root/*"
6220
+ ];
6221
+ var RESERVED_RUN_WORKER_FIRST = [
6222
+ ...SDK_RUN_WORKER_FIRST,
6223
+ ...DOCUMENTATION_PATHS
6224
+ ];
6225
+ function isPlatformReservedPath(pathname) {
6226
+ return RESERVED_RUN_WORKER_FIRST.some((pattern) => {
6227
+ if (!pattern.endsWith("/*")) return pathname === pattern;
6228
+ const base = pattern.slice(0, -2);
6229
+ return pathname === base || pathname.startsWith(`${base}/`);
6230
+ });
6231
+ }
6232
+
6233
+ // src/shared/platform-proxy.ts
6234
+ var BROWSER_PROXY_ROUTES = [
6235
+ // useSubscription — read state, subscribe, manage billing.
6236
+ { method: "GET", path: "/_deepspace/subscriptions/me" },
6237
+ { method: "POST", path: "/_deepspace/subscriptions/checkout" },
6238
+ { method: "POST", path: "/_deepspace/subscriptions/portal" },
6239
+ // useCheckout (one-time charges).
6240
+ { method: "POST", path: "/_deepspace/charges/create" },
6241
+ { method: "GET", path: "/_deepspace/charges/me" }
6242
+ ];
6243
+
6173
6244
  // src/server/utils/cors.ts
6174
6245
  function matchOrigin(origin, patterns) {
6175
6246
  if (!origin) return null;
@@ -6246,19 +6317,21 @@ var MAX_UPLOAD_REQUEST_BYTES = 25 * 1024 * 1024;
6246
6317
  var UPLOAD_PART_BYTES = 20 * 1024 * 1024;
6247
6318
  var MAX_UPLOAD_PARTS = Math.ceil(MAX_APP_FILE_BYTES / UPLOAD_PART_BYTES);
6248
6319
  var MAX_BASE64_UPLOAD_BYTES = Math.floor(MAX_UPLOAD_REQUEST_BYTES * 3 / 4);
6249
- var APP_STORAGE_LIMIT_BYTES = {
6320
+ var GIB = 1024 * 1024 * 1024;
6321
+ var ACCOUNT_STORAGE_LIMIT_BYTES = {
6250
6322
  test: 0,
6251
- free: 128 * 1024 * 1024,
6252
- starter: 512 * 1024 * 1024,
6253
- premium: 2 * 1024 * 1024 * 1024,
6254
- admin: 10 * 1024 * 1024 * 1024
6323
+ free: 1 * GIB,
6324
+ starter: 10 * GIB,
6325
+ premium: 30 * GIB,
6326
+ admin: 100 * GIB
6255
6327
  };
6256
6328
  function storageLimitForTier(tier) {
6257
- if (tier && Object.hasOwn(APP_STORAGE_LIMIT_BYTES, tier)) {
6258
- return APP_STORAGE_LIMIT_BYTES[tier];
6329
+ if (tier && Object.hasOwn(ACCOUNT_STORAGE_LIMIT_BYTES, tier)) {
6330
+ return ACCOUNT_STORAGE_LIMIT_BYTES[tier];
6259
6331
  }
6260
- return APP_STORAGE_LIMIT_BYTES.free;
6332
+ return ACCOUNT_STORAGE_LIMIT_BYTES.free;
6261
6333
  }
6334
+ var REPO_STORE_LIMIT_BYTES = 256 * 1024 * 1024;
6262
6335
  function storageQuotaMessage(incomingBytes, usedBytes, limitBytes) {
6263
6336
  const free = Math.max(0, limitBytes - usedBytes);
6264
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.`;
@@ -6349,7 +6422,7 @@ function declaredLength(request, what) {
6349
6422
  function isKeyWithinPrefix(key, prefix) {
6350
6423
  return key.startsWith(prefix);
6351
6424
  }
6352
- async function allocationUsage(bucket, prefix) {
6425
+ async function prefixUsage(bucket, prefix) {
6353
6426
  let total = 0;
6354
6427
  let cursor;
6355
6428
  do {
@@ -6359,6 +6432,13 @@ async function allocationUsage(bucket, prefix) {
6359
6432
  } while (cursor !== void 0);
6360
6433
  return total;
6361
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
+ }
6362
6442
  async function admitStorage(bucket, storage, incomingBytes, replacesKey) {
6363
6443
  if (!storage) return null;
6364
6444
  const limit = await storage.limitBytes();
@@ -6369,7 +6449,14 @@ async function admitStorage(bucket, storage, incomingBytes, replacesKey) {
6369
6449
  "storage_limit_unavailable"
6370
6450
  );
6371
6451
  }
6372
- 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
+ }
6373
6460
  const replaced = replacesKey === null ? 0 : (await bucket.head(replacesKey))?.size ?? 0;
6374
6461
  const used = stored - replaced;
6375
6462
  if (used + incomingBytes <= limit) return null;
@@ -6385,7 +6472,11 @@ async function admitAssembledObject(bucket, storage, key, objectBytes) {
6385
6472
  console.error("[files:quota] limit unavailable at complete; keeping", key);
6386
6473
  return null;
6387
6474
  }
6388
- 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
+ }
6389
6480
  if (stored <= limit) return null;
6390
6481
  await bucket.delete(key).catch(() => void 0);
6391
6482
  return fail(
@@ -6782,9 +6873,10 @@ async function handleList(bucket, prefix, url, scope, auth) {
6782
6873
  });
6783
6874
  let storage;
6784
6875
  if (auth.storage) {
6785
- storage = { usedBytes: await allocationUsage(bucket, auth.storage.prefix) };
6876
+ const usedBytes = await allocationUsage(bucket, auth.storage);
6877
+ if (usedBytes !== null) storage = { usedBytes };
6786
6878
  const limitBytes = await auth.storage.limitBytes();
6787
- if (limitBytes !== null) storage.limitBytes = limitBytes;
6879
+ if (storage && limitBytes !== null) storage.limitBytes = limitBytes;
6788
6880
  }
6789
6881
  return Response.json(
6790
6882
  { files, truncated: listed.truncated, ...storage ? { storage } : {} },
@@ -9391,17 +9483,19 @@ var APP_LOG_EVENT_KEYS = [
9391
9483
  "exception"
9392
9484
  ];
9393
9485
  export {
9486
+ ACCOUNT_STORAGE_LIMIT_BYTES,
9394
9487
  AI_CHATS_SCHEMA,
9395
9488
  AI_MESSAGES_SCHEMA,
9396
9489
  ALLOWED_BINDING_TYPES,
9397
9490
  APP_ID_RE,
9398
9491
  APP_LOG_EVENT_KEYS,
9399
9492
  APP_NAME_RULES,
9400
- APP_STORAGE_LIMIT_BYTES,
9493
+ ASSET_NOT_FOUND_HANDLING_VALUES,
9401
9494
  AUTO_PROVISIONABLE_TYPES,
9402
9495
  AUTO_PROVISION_SENTINEL,
9403
9496
  Awareness,
9404
9497
  BASE_USERS_SCHEMA,
9498
+ BROWSER_PROXY_ROUTES,
9405
9499
  BUILT_IN_TOOLS,
9406
9500
  BaseRoom,
9407
9501
  CANONICAL_APP_IDENTITY_MIGRATION_ID,
@@ -9446,22 +9540,29 @@ export {
9446
9540
  REACTIONS_SCHEMA,
9447
9541
  READ_RECEIPTS_SCHEMA,
9448
9542
  REGISTRY_INSTANCE,
9543
+ RELEASE_STAMP_PATH,
9544
+ REPO_STORE_LIMIT_BYTES,
9545
+ REQUIRED_COMPATIBILITY_FLAGS,
9449
9546
  RESERVED_BINDING_NAMES,
9450
9547
  RESERVED_COLLECTION_NAMES,
9548
+ RESERVED_RUN_WORKER_FIRST,
9451
9549
  RESOURCE_ID_RE,
9452
9550
  ROLE_ADMIN,
9453
9551
  ROLE_ANONYMOUS,
9454
9552
  ROLE_DEFAULT,
9455
9553
  RecordRoom,
9456
9554
  RegistryClientError,
9555
+ SDK_RUN_WORKER_FIRST,
9457
9556
  STRICT_APP_ID_RE,
9458
9557
  SYSTEM_COLLECTIONS,
9459
9558
  SYSTEM_MANAGED_COLUMNS,
9460
9559
  SchemaRegistry,
9461
9560
  TEST_ACCOUNT_EMAIL_SUFFIX,
9561
+ UNDECLARED_ASSET_NOT_FOUND_HANDLING,
9462
9562
  UPLOAD_PART_BYTES,
9463
9563
  USERS_COLUMNS,
9464
9564
  VOTING_SCHEMAS,
9565
+ WORKER_OWNED_NOT_FOUND_MIGRATION_ID,
9465
9566
  WORKSPACE_SCHEMAS,
9466
9567
  YjsRoom,
9467
9568
  analyzePermissions,
@@ -9517,9 +9618,11 @@ export {
9517
9618
  handleClientErrorReport,
9518
9619
  handleSyncMessage,
9519
9620
  hasContent,
9621
+ isAssetNotFoundHandling,
9520
9622
  isAutoProvision,
9521
9623
  isFilesVerbPath,
9522
9624
  isOwner,
9625
+ isPlatformReservedPath,
9523
9626
  isTestAccountClaims,
9524
9627
  isTestAccountEmail,
9525
9628
  isTestAccountTier,
@@ -9545,6 +9648,7 @@ export {
9545
9648
  registryStub,
9546
9649
  resolveAppName,
9547
9650
  resolveColumn,
9651
+ resolveCompatibilityFlags,
9548
9652
  resolveDeepSpaceAgentModel,
9549
9653
  rowToData,
9550
9654
  runMigrations,