deepspace 0.12.0 → 0.13.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.
@@ -226,6 +226,14 @@ interface DocumentationSiteProps extends DocumentationAppProps {
226
226
  type DocumentationSiteComponent = ComponentType<DocumentationSiteProps>;
227
227
  /** The polished SDK-owned documentation shell. */
228
228
  declare const DefaultDocumentation: typeof DocumentationApp;
229
+ /**
230
+ * The prose subtree has exactly one writer, and `data-prose` names it. `react`
231
+ * means the reconciler owns every node inside and only React components may
232
+ * enhance it; `html` means the compiler's markup owns it and the article's
233
+ * imperative pass may enhance it. Nothing may write across that line — moving a
234
+ * React-owned node out from under its fiber makes the next route swap fail with
235
+ * `removeChild ... not a child of this node`.
236
+ */
229
237
  declare function DocumentationContent({ data, Page, }: {
230
238
  data: DocumentationRuntimeData;
231
239
  Page?: DocumentationPageComponent;
package/dist/server.d.ts CHANGED
@@ -153,31 +153,82 @@ declare function applyAiToolDefaults(toolName: string, params: Record<string, un
153
153
  declare const BUILT_IN_TOOLS: ToolSchema[];
154
154
 
155
155
  /**
156
- * App-files limits and failure reading, shared by every caller of the files
157
- * API: the browser hook (`client/storage/useR2Files.ts`), the CLI
158
- * (`cli/lib/app-files-api.ts`), and the docs that quote them.
156
+ * App-files limits, chunk planning, and failure reading — shared by every
157
+ * caller of the files API: the browser hook (`client/storage/useR2Files.ts`),
158
+ * the CLI (`cli/lib/app-files-api.ts`), the server handler
159
+ * (`server/utils/scoped-r2-files.ts`), and the docs that quote them.
159
160
  *
160
- * The ceiling is not a product decision made here — it is what the transport
161
- * physically allows. An upload crosses Cloudflare's request-body limit before
162
- * any worker code runs, and the platform worker then reads the whole body into
163
- * a ~128 MiB isolate before writing it to R2. So an oversized upload does not
164
- * fail as a friendly JSON error; it fails as a raw Cloudflare HTML page that
165
- * every caller here used to feed straight into `JSON.parse` and report as
166
- * "Unexpected token '<' … is not valid JSON". That is the bug this module
167
- * exists to make impossible.
161
+ * There are three numbers here and they answer three different questions.
162
+ * Conflating them is what produced the old 25 MiB per-file ceiling: that was
163
+ * never a product decision, it was the size of one HTTP request leaking out as
164
+ * a rule about files. A request is bounded by physics — Cloudflare rejects an
165
+ * oversized body before any worker runs, and the worker's isolate is ~128 MiB.
166
+ * A FILE is not, once it travels as a sequence of bounded requests.
167
+ *
168
+ * The other half of this module is failure reading. An upload refused at the
169
+ * edge answers with a Cloudflare HTML page, which every caller used to feed
170
+ * straight into `JSON.parse` and report as "Unexpected token '<' … is not
171
+ * valid JSON". `describeFilesFailure` exists to make that impossible.
168
172
  */
169
173
  /**
170
174
  * The largest single file the app-files API accepts.
171
175
  *
172
- * Enforced by the shared upload handler (`server/utils/scoped-r2-files.ts`),
173
- * which is the only place it is a real limit — above it the platform worker
174
- * risks exhausting its isolate while holding the decoded file and the
175
- * multipart envelope together. Callers also check it locally, but only so the
176
- * failure is named early; skipping the client check cannot widen what is
177
- * accepted. Well above it (~100 MB) Cloudflare rejects the request before the
178
- * worker runs at all, which is why callers must read failures as text first.
176
+ * Reachable only through the multipart transport: a file above
177
+ * {@link UPLOAD_PART_BYTES} is uploaded as a sequence of parts, so no request
178
+ * and no isolate ever holds more than one part. Enforced by the shared handler
179
+ * (`server/utils/scoped-r2-files.ts`) twice — once at init against the
180
+ * declared total, so an impossible upload fails before a byte moves, and again
181
+ * at complete against the assembled object, because the declared total is
182
+ * client-supplied. Callers check it locally too, but only to fail early;
183
+ * skipping the client check cannot widen what is accepted.
179
184
  */
180
185
  declare const MAX_APP_FILE_BYTES: number;
186
+ /**
187
+ * The most any ONE request body may carry — a whole small file on the
188
+ * single-request path, or one part on the multipart path.
189
+ *
190
+ * This is the transport's real physical bound, and the only thing 25 MiB ever
191
+ * meant. Above it the worker risks exhausting its isolate holding the body;
192
+ * well above it (~100 MB) Cloudflare refuses the request before the worker
193
+ * runs at all, which is why callers must read failures as text first.
194
+ */
195
+ declare const MAX_UPLOAD_REQUEST_BYTES: number;
196
+ /**
197
+ * The part size clients chunk at, and the threshold above which they must.
198
+ *
199
+ * Below the {@link MAX_UPLOAD_REQUEST_BYTES} bound with headroom for the
200
+ * request envelope, and comfortably inside R2's own part rules: parts must be
201
+ * at least 5 MiB and every non-final part must be exactly the same size
202
+ * (R2 errors 10011 / 10048). The server advertises this at init — a client
203
+ * chunks at the size it is told, not at this constant, so the number can move
204
+ * without stranding older callers mid-upload.
205
+ */
206
+ declare const UPLOAD_PART_BYTES: number;
207
+ /**
208
+ * The highest part number the server accepts.
209
+ *
210
+ * The handler holds no per-session state, so this — not the declared total —
211
+ * is what bounds an in-flight upload. It is computed against
212
+ * {@link UPLOAD_PART_BYTES}, which is why the server refuses a part larger
213
+ * than that even though a whole small file may be 25 MiB: admitting 25 MiB
214
+ * parts would make the real in-flight bound 52 × 25 MiB = 1300 MiB while the
215
+ * advertised ceiling stayed 1 GiB. With both numbers agreeing, a session's
216
+ * worst case is 52 × 20 MiB = 1040 MiB — the ceiling plus one part.
217
+ *
218
+ * R2 allows 10,000 parts, so this is far inside what the API permits.
219
+ */
220
+ declare const MAX_UPLOAD_PARTS: number;
221
+ /**
222
+ * The largest single file a deploy may ship as a static asset.
223
+ *
224
+ * Cloudflare Static Assets refuses anything larger, so this is a hard edge of
225
+ * the platform rather than a policy dial — which is why the CLI may check it
226
+ * locally. It lives here so the deploy worker and the CLI cannot drift; the
227
+ * per-DEPLOY total is deliberately NOT here, because it is env-configurable
228
+ * per environment and only the server can know it.
229
+ */
230
+ declare const MAX_DEPLOY_ASSET_FILE_BYTES: number;
231
+ declare function formatBytes(bytes: number): string;
181
232
 
182
233
  /**
183
234
  * Shared Scoped R2 Files Handler
@@ -191,10 +242,29 @@ declare const MAX_APP_FILE_BYTES: number;
191
242
  * The security invariants are enforced here once — not per-worker.
192
243
  *
193
244
  * Routes:
194
- * POST /api/files/upload → upload (prefix + generated key)
195
- * GET /api/files → list (prefix + optional user prefix)
196
- * GET /api/files/:key → download (validated against prefix)
197
- * DELETE /api/files/:key → delete (validated against prefix)
245
+ * POST /api/files/upload → upload one file in one request
246
+ * POST /api/files/multipart → begin a chunked upload
247
+ * PUT /api/files/multipart/part → send one part
248
+ * POST /api/files/multipart/complete → assemble the parts
249
+ * DELETE /api/files/multipart → abandon a chunked upload
250
+ * GET /api/files → list (prefix + optional user prefix)
251
+ * GET /api/files/:key → download (validated against prefix)
252
+ * DELETE /api/files/:key → delete (validated against prefix)
253
+ *
254
+ * ## One transport discipline
255
+ *
256
+ * Both upload paths obey the rule the deploy asset transport established
257
+ * (`docs/projects/2026-08-05-deploy-asset-transport/README.md`): nothing here
258
+ * ever holds more than one bounded request in memory. The single-request path
259
+ * exists so a small file still costs one round trip; above
260
+ * {@link UPLOAD_PART_BYTES} a file travels as parts, each streamed into R2
261
+ * through a `FixedLengthStream` with a required `Content-Length`. That is why
262
+ * a 1 GiB file is admissible in a ~128 MiB isolate.
263
+ *
264
+ * Validation is identical on both paths and on both mounts, because it lives
265
+ * here: the prefix scoping, the traversal check, the MIME refusals, and both
266
+ * size bounds. A hand-rolled request that skips every client guard reaches
267
+ * exactly these checks.
198
268
  */
199
269
 
200
270
  interface ScopeContext {
@@ -224,6 +294,7 @@ interface ScopedR2Auth {
224
294
  userId: string | null;
225
295
  }
226
296
  type ScopedR2Handler = (request: Request, url: URL, bucket: R2Bucket, auth: ScopedR2Auth) => Promise<Response>;
297
+ declare function isFilesVerbPath(method: string, subpath: string): boolean;
227
298
  /**
228
299
  * Create a scoped R2 files handler.
229
300
  *
@@ -4543,4 +4614,4 @@ declare class RefundError extends Error {
4543
4614
  constructor(message: string, status: number);
4544
4615
  }
4545
4616
 
4546
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, 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, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, 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, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAgentDiagnosticContext, DeepSpaceAgentModelError, DeepSpaceAgentProfileError, type DeepSpaceAgentStream, type DeepSpaceAgentStreamOptions, 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 Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MAX_APP_FILE_BYTES, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESOURCE_ID_RE, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, RegistryClientError, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, STRICT_APP_ID_RE, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type SharedConnection, type StoredRecord, SubscriptionAuthError, type SubscriptionContext, type SubscriptionRead, SubscriptionRequiredError, type SubscriptionStatus, type Summarizer, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, type ToolsApiContext, USERS_COLUMNS, type User, type UserAttachment, type UserContext, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, deleteRecord, enqueueJob, executeQuery, getAllUsers, getChat, getGlobalDOSchemas, getGlobalDOType, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, registryErrorJson, registryStub, requireSubscription, resolveAppName, resolveColumn, rowToData, runMigrations, saveYjsDoc, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema };
4617
+ export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, 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, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, 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, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAgentDiagnosticContext, DeepSpaceAgentModelError, DeepSpaceAgentProfileError, type DeepSpaceAgentStream, type DeepSpaceAgentStreamOptions, 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 Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MAX_APP_FILE_BYTES, MAX_DEPLOY_ASSET_FILE_BYTES, MAX_UPLOAD_PARTS, MAX_UPLOAD_REQUEST_BYTES, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESOURCE_ID_RE, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, RegistryClientError, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, STRICT_APP_ID_RE, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type SharedConnection, type StoredRecord, SubscriptionAuthError, type SubscriptionContext, type SubscriptionRead, SubscriptionRequiredError, type SubscriptionStatus, type Summarizer, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, type ToolsApiContext, UPLOAD_PART_BYTES, USERS_COLUMNS, type User, type UserAttachment, type UserContext, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, deleteRecord, enqueueJob, executeQuery, formatBytes, getAllUsers, getChat, getGlobalDOSchemas, getGlobalDOType, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isFilesVerbPath, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, registryErrorJson, registryStub, requireSubscription, resolveAppName, resolveColumn, rowToData, runMigrations, saveYjsDoc, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema };