deepspace 0.25.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +7 -6
  3. package/dist/{chunk-2GUGZLAX.js → chunk-YBXIUDZJ.js} +2 -2
  4. package/dist/{chunk-2GUGZLAX.js.map → chunk-YBXIUDZJ.js.map} +1 -1
  5. package/dist/cli.js +1036 -966
  6. package/dist/cli.js.map +1 -1
  7. package/dist/documentation-client-core.js +1 -1
  8. package/dist/documentation-default-renderer.cjs +1 -1
  9. package/dist/documentation-react.js +1 -1
  10. package/dist/documentation-runtime.js +1 -1
  11. package/dist/documentation-server-core.js +1 -1
  12. package/dist/documentation.js +1 -1
  13. package/dist/documentation.js.map +1 -1
  14. package/dist/index.d.ts +26 -434
  15. package/dist/index.js +99 -864
  16. package/dist/index.js.map +1 -1
  17. package/dist/schema.d.ts +4 -41
  18. package/dist/schema.js +2 -242
  19. package/dist/schema.js.map +1 -1
  20. package/dist/server.d.ts +6 -162
  21. package/dist/server.js +13 -281
  22. package/dist/server.js.map +1 -1
  23. package/dist/worker.d.ts +4 -160
  24. package/dist/worker.js +15 -281
  25. package/dist/worker.js.map +1 -1
  26. package/features/messaging/feature.json +3 -43
  27. package/features/messaging/src/ChatPage.tsx +12 -16
  28. package/features/messaging/src/components/chat/ChatHeader.tsx +5 -13
  29. package/features/messaging/src/components/chat/MessageItem.tsx +7 -9
  30. package/features/messaging/src/components/chat/MessageList.tsx +57 -40
  31. package/features/messaging/src/components/chat/ThreadPanel.tsx +25 -11
  32. package/features/messaging/src/components/chat/UserProfilePopover.tsx +10 -29
  33. package/features/messaging/src/hooks/useChatChannel.ts +18 -23
  34. package/features/messaging/src/messaging-schema.ts +0 -2
  35. package/features/search-bar/feature.json +9 -20
  36. package/features/search-bar/src/InlineSearch.tsx +101 -0
  37. package/features/search-bar/src/__tests__/search-model.test.tsx +38 -0
  38. package/features/search-bar/src/search-model.ts +2 -149
  39. package/package.json +1 -1
  40. package/features/messaging/src/ChatMultiPage.tsx +0 -298
  41. package/features/messaging/src/components/chat-multi/AddMemberModal.tsx +0 -188
  42. package/features/messaging/src/components/chat-multi/BrowseGroupsModal.tsx +0 -163
  43. package/features/messaging/src/components/chat-multi/ChannelListItem.tsx +0 -147
  44. package/features/messaging/src/components/chat-multi/ChannelSettingsPanel.tsx +0 -344
  45. package/features/messaging/src/components/chat-multi/ChannelSidebar.tsx +0 -460
  46. package/features/messaging/src/components/chat-multi/CreateGroupModal.tsx +0 -190
  47. package/features/messaging/src/components/chat-multi/InvitationList.tsx +0 -149
  48. package/features/messaging/src/components/chat-multi/NewMessageModal.tsx +0 -159
  49. package/features/messaging/src/hooks/useMultiChannel.ts +0 -142
  50. package/features/search-bar/src/SearchOverlay.tsx +0 -566
  51. package/features/search-bar/src/__tests__/search-model.test.ts +0 -40
  52. package/features/sidebar/feature.json +0 -19
  53. package/features/sidebar/src/AppSidebar.tsx +0 -558
package/dist/server.d.ts CHANGED
@@ -530,90 +530,6 @@ interface YjsLeavePayload {
530
530
  recordId: string;
531
531
  fieldName: string;
532
532
  }
533
- interface DirectoryConversationData {
534
- Name: string;
535
- Description: string;
536
- Type: string;
537
- Visibility: string;
538
- CreatedBy: string;
539
- ParticipantHash: string;
540
- ParticipantIds: string;
541
- Status: string;
542
- AssigneeId: string;
543
- LinkedRef: string;
544
- LastMessageAt: string;
545
- LastMessagePreview: string;
546
- LastMessageAuthor: string;
547
- MessageCount: number;
548
- }
549
- interface ConversationStateData {
550
- ConversationId: string;
551
- UserId: string;
552
- LastReadAt: string;
553
- LastReadMessageCount: number;
554
- Starred: number;
555
- Archived: number;
556
- Trashed: number;
557
- Labels: string;
558
- Folder: string;
559
- }
560
- interface DirectoryCommunityData {
561
- Name: string;
562
- Description: string;
563
- CreatedBy: string;
564
- Type: string;
565
- Visibility: string;
566
- MemberCount: number;
567
- Rules: string;
568
- IconUrl: string;
569
- CoverUrl: string;
570
- }
571
- interface DirectoryMembershipData {
572
- CommunityId: string;
573
- UserId: string;
574
- UserName: string;
575
- Role: string;
576
- JoinedAt: string;
577
- }
578
- interface DirectoryPostData {
579
- Title: string;
580
- Content: string;
581
- AuthorId: string;
582
- Type: string;
583
- CommunityId: string;
584
- ParentId: string;
585
- ConversationId: string;
586
- Status: string;
587
- Tags: string;
588
- LinkUrl: string;
589
- }
590
- interface ConvMessageData {
591
- Content: string;
592
- AuthorId: string;
593
- ParentId: string;
594
- Edited: number;
595
- MessageType: string;
596
- Metadata: string;
597
- }
598
- interface ConvReactionData {
599
- MessageId: string;
600
- Emoji: string;
601
- UserId: string;
602
- }
603
- interface ConvMemberData {
604
- UserId: string;
605
- UserName: string;
606
- Role: string;
607
- }
608
- interface ConvReadCursorData {
609
- UserId: string;
610
- LastReadAt: string;
611
- }
612
- interface ConvVoteData {
613
- TargetId: string;
614
- UserId: string;
615
- Direction: number;
616
- }
617
533
 
618
534
  /**
619
535
  * Server Action Types
@@ -3098,7 +3014,9 @@ declare const AI_MESSAGES_SCHEMA: CollectionSchema;
3098
3014
  * Messaging Schemas
3099
3015
  *
3100
3016
  * Pre-built collection schemas for messaging functionality.
3101
- * Any app can import these to add channels, messages, reactions, etc.
3017
+ * These schemas intentionally model public channels only. RecordRoom row
3018
+ * permissions cannot make a channel private by themselves; advertising DMs
3019
+ * or private groups here would expose their records to every room member.
3102
3020
  *
3103
3021
  * @example
3104
3022
  * ```typescript
@@ -3111,82 +3029,8 @@ declare const CHANNELS_SCHEMA: CollectionSchema;
3111
3029
  declare const MESSAGES_SCHEMA: CollectionSchema;
3112
3030
  declare const REACTIONS_SCHEMA: CollectionSchema;
3113
3031
  declare const CHANNEL_MEMBERS_SCHEMA: CollectionSchema;
3114
- declare const CHANNEL_INVITATIONS_SCHEMA: CollectionSchema;
3115
3032
  declare const READ_RECEIPTS_SCHEMA: CollectionSchema;
3116
3033
 
3117
- /**
3118
- * Shared conversation schemas for RecordRoom-based conversations.
3119
- *
3120
- * These define the collections inside a per-conversation RecordRoom DO.
3121
- * Used by apps that have messaging/conversation features (slack-clone,
3122
- * helpdesk, mail, reddit-clone, etc.).
3123
- *
3124
- * Each conversation gets its own RecordRoom DO keyed by `conv:{id}`.
3125
- */
3126
-
3127
- declare const CONVERSATION_SCHEMAS: CollectionSchema[];
3128
- /**
3129
- * Voting schemas for Reddit-style apps.
3130
- * Add these alongside CONVERSATION_SCHEMAS for apps that need voting.
3131
- */
3132
- declare const VOTING_SCHEMAS: CollectionSchema[];
3133
-
3134
- /**
3135
- * Directory DO Schemas
3136
- *
3137
- * Purpose-built collections for the `dir:{appName}` global DO type.
3138
- * This is the cross-app-visible directory layer — any app can subscribe
3139
- * to another app's directory in real-time via SHARED_CONNECTIONS.
3140
- *
3141
- * Five collections covering all standard communication/social patterns:
3142
- * - conversations: channels, DMs, email threads, support chats
3143
- * - conversation_state: per-user metadata (read cursor, stars, labels, folders)
3144
- * - communities: groups, forums, boards, projects
3145
- * - memberships: user membership in communities
3146
- * - posts: feed items, tweets, Q&A questions, announcements
3147
- *
3148
- * Domain-specific data (tickets, CRM, procurement) stays in app DOs.
3149
- * Message content stays in conv:{id} DOs (CONVERSATION_SCHEMAS).
3150
- */
3151
-
3152
- /** All directory schemas for the `dir:{appName}` global DO type. */
3153
- declare const DIRECTORY_SCHEMAS: CollectionSchema[];
3154
-
3155
- /**
3156
- * Shared Durable Object Schemas
3157
- *
3158
- * Central registry of global DO types with fixed schemas.
3159
- * Apps connect to shared DOs via SHARED_CONNECTIONS in constants.ts.
3160
- * The ScopeRegistry resolves collection names to the correct scope automatically.
3161
- *
3162
- * Scope tiers:
3163
- * - App DO (app:{appHandle}) — private to each app, app defines tables
3164
- * - Dir DO (dir:{appHandle}) — cross-app directory (conversations, communities, posts)
3165
- * - Conv DO (conv:{id}) — single conversation (messages, reactions, members)
3166
- *
3167
- * There is no platform-wide singleton scope: every global room is keyed by
3168
- * a conversation or an app, so no one DO holds data shared by all apps.
3169
- */
3170
-
3171
- interface SharedConnection {
3172
- type: string;
3173
- instanceId?: string;
3174
- }
3175
- interface GlobalDOType {
3176
- name: string;
3177
- schemas: CollectionSchema[];
3178
- description: string;
3179
- }
3180
- declare const GLOBAL_DO_TYPES: GlobalDOType[];
3181
- /** All valid global DO type names. */
3182
- declare const GLOBAL_DO_TYPE_NAMES: string[];
3183
- /** Look up a global DO type by name, returns null if not found. */
3184
- declare function getGlobalDOType(name: string): GlobalDOType | null;
3185
- /** Get the fixed schemas for a global DO type. Returns empty array if unknown type. */
3186
- declare function getGlobalDOSchemas(typeName: string): CollectionSchema[];
3187
- /** All collection names reserved by global DO types. Apps must not reuse these. */
3188
- declare const RESERVED_COLLECTION_NAMES: Set<string>;
3189
-
3190
3034
  /**
3191
3035
  * Subscription handlers for RecordRoom
3192
3036
  *
@@ -3198,8 +3042,8 @@ interface SubscriptionContext {
3198
3042
  schemaRegistry: SchemaRegistry;
3199
3043
  state: DurableObjectState;
3200
3044
  /**
3201
- * The scope this room was addressed by — `app:{appId}`, `chat:{channelId}`,
3202
- * `conv:{convId}`, `dir:{appId}`, … Records are sharded across rooms
3045
+ * The app-owned scope this room was addressed by — for example
3046
+ * `app:{appId}` or `chat:{channelId}`. Records are sharded across rooms
3203
3047
  * by scope, so the scope is what names the room in an unknown-collection
3204
3048
  * failure. Undefined only for rooms addressed by a unique id rather than a
3205
3049
  * name (`idFromName` populates `DurableObjectId.name`).
@@ -4821,4 +4665,4 @@ declare class RefundError extends Error {
4821
4665
  constructor(message: string, status: number);
4822
4666
  }
4823
4667
 
4824
- export { ACCOUNT_STORAGE_LIMIT_BYTES, 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, type BindingJsonValue, 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_DELETE_WHERE_LIMIT, 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 GetActionData, type GlobalDOType, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, type KnowledgeAddOptions, type KnowledgeAddResult, type KnowledgeClient, type KnowledgeEnv, KnowledgeError, type KnowledgeItem, type KnowledgeListOptions, type KnowledgeListResult, type KnowledgeSearchChunk, type KnowledgeSearchOptions, type KnowledgeSearchResult, type KnowledgeStatus, MAX_APP_FILE_BYTES, MAX_DELETE_WHERE_LIMIT, MAX_DEPLOY_ASSET_FILE_BYTES, MAX_ENV_VAR_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 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_ASSIGNED_COLUMNS, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MAINTAINED_COLUMNS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedKnowledgeClient, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type SharedConnection, type StorageAdmission, 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, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, armCronRoom, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastUserList, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, checkUnclaimedOwnerTransition, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, deleteRecord, enqueueJob, epochSeconds, executeQuery, folderFilter, 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, knowledge, lintSchema, lintSchemaSet, lintSchemas, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, mintAppId, mintUlid, noopPermissionContext, normalizeKnowledgeFolder, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, registryErrorJson, registryStub, requireSubscription, resolveAppName, resolveAppRole, resolveColumn, rowToData, runMigrations, saveYjsDoc, storageLimitForTier, storageQuotaMessage, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt };
4668
+ export { ACCOUNT_STORAGE_LIMIT_BYTES, 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, type BindingJsonValue, CHANNELS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, 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 CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DELETE_WHERE_LIMIT, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, 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 DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, type GetActionData, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, type KnowledgeAddOptions, type KnowledgeAddResult, type KnowledgeClient, type KnowledgeEnv, KnowledgeError, type KnowledgeItem, type KnowledgeListOptions, type KnowledgeListResult, type KnowledgeSearchChunk, type KnowledgeSearchOptions, type KnowledgeSearchResult, type KnowledgeStatus, MAX_APP_FILE_BYTES, MAX_DELETE_WHERE_LIMIT, MAX_DEPLOY_ASSET_FILE_BYTES, MAX_ENV_VAR_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 PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_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_ASSIGNED_COLUMNS, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MAINTAINED_COLUMNS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedKnowledgeClient, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type StorageAdmission, 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, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, armCronRoom, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastUserList, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, checkUnclaimedOwnerTransition, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deepSpaceAgentErrorSummary, deleteChatCascade, deleteRecord, enqueueJob, epochSeconds, executeQuery, folderFilter, formatBytes, getAllUsers, getChat, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isFilesVerbPath, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, knowledge, lintSchema, lintSchemaSet, lintSchemas, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, mintAppId, mintUlid, noopPermissionContext, normalizeKnowledgeFolder, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, registryErrorJson, registryStub, requireSubscription, resolveAppName, resolveAppRole, resolveColumn, rowToData, runMigrations, saveYjsDoc, storageLimitForTier, storageQuotaMessage, streamDeepSpaceAgent, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt };
package/dist/server.js CHANGED
@@ -1665,6 +1665,16 @@ function buildCronContext(env, ownerUserId, roomId = "default") {
1665
1665
  return { records, integrations, ownerUserId };
1666
1666
  }
1667
1667
 
1668
+ // src/shared/roles.ts
1669
+ var ROLES = {
1670
+ VIEWER: "viewer",
1671
+ MEMBER: "member",
1672
+ ADMIN: "admin"
1673
+ };
1674
+ function isWriterRole(role) {
1675
+ return role === ROLES.ADMIN || role === ROLES.MEMBER;
1676
+ }
1677
+
1668
1678
  // src/server/utils/app-role.ts
1669
1679
  async function resolveAppRole(env, userId) {
1670
1680
  if (userId === env.OWNER_USER_ID) return "admin";
@@ -1686,7 +1696,7 @@ async function resolveAppRole(env, userId) {
1686
1696
  );
1687
1697
  const json = await res.json();
1688
1698
  const role = json.data?.record?.data?.role;
1689
- return json.success && (role === "admin" || role === "member") ? role : "viewer";
1699
+ return json.success && isWriterRole(role) ? role : "viewer";
1690
1700
  } catch {
1691
1701
  return "viewer";
1692
1702
  }
@@ -5965,7 +5975,7 @@ var YjsRoom = class extends BaseRoom {
5965
5975
  // --------------------------------------------------------------------------
5966
5976
  onConnect(ws, user) {
5967
5977
  const role = user.role ?? "viewer";
5968
- const canWrite = role === "member" || role === "admin";
5978
+ const canWrite = isWriterRole(role);
5969
5979
  const attachment = {
5970
5980
  ...user,
5971
5981
  role,
@@ -6128,15 +6138,6 @@ var YjsRoom = class extends BaseRoom {
6128
6138
 
6129
6139
  // src/server/rooms/canvas-room.ts
6130
6140
  import * as Y5 from "yjs";
6131
-
6132
- // src/shared/roles.ts
6133
- var ROLES = {
6134
- VIEWER: "viewer",
6135
- MEMBER: "member",
6136
- ADMIN: "admin"
6137
- };
6138
-
6139
- // src/server/rooms/canvas-room.ts
6140
6141
  var CANVAS_WRITE_TYPES = /* @__PURE__ */ new Set([
6141
6142
  MSG.CANVAS_ADD,
6142
6143
  MSG.CANVAS_MOVE,
@@ -8143,7 +8144,7 @@ var CHANNELS_SCHEMA = {
8143
8144
  {
8144
8145
  name: "type",
8145
8146
  storage: "text",
8146
- interpretation: { kind: "select", options: ["public", "private", "dm"] }
8147
+ interpretation: { kind: "select", options: ["public"] }
8147
8148
  },
8148
8149
  {
8149
8150
  name: "createdBy",
@@ -8219,44 +8220,6 @@ var CHANNEL_MEMBERS_SCHEMA = {
8219
8220
  viewer: { read: true, create: false, update: false, delete: false }
8220
8221
  }
8221
8222
  };
8222
- var CHANNEL_INVITATIONS_SCHEMA = {
8223
- name: "channel-invitations",
8224
- columns: [
8225
- {
8226
- name: "channelId",
8227
- storage: "text",
8228
- interpretation: "plain",
8229
- required: true,
8230
- immutable: true
8231
- },
8232
- {
8233
- name: "invitedUserId",
8234
- storage: "text",
8235
- interpretation: "plain",
8236
- required: true,
8237
- immutable: true
8238
- },
8239
- {
8240
- name: "invitedBy",
8241
- storage: "text",
8242
- interpretation: "plain",
8243
- userBound: true,
8244
- immutable: true
8245
- },
8246
- {
8247
- name: "status",
8248
- storage: "text",
8249
- interpretation: { kind: "select", options: ["pending", "accepted", "declined"] },
8250
- required: true
8251
- }
8252
- ],
8253
- uniqueOn: ["channelId", "invitedUserId"],
8254
- permissions: {
8255
- admin: { read: true, create: true, update: true, delete: true },
8256
- member: { read: true, create: true, update: true, delete: false },
8257
- viewer: { read: true, create: false, update: false, delete: false }
8258
- }
8259
- };
8260
8223
  var READ_RECEIPTS_SCHEMA = {
8261
8224
  name: "read-receipts",
8262
8225
  columns: [
@@ -8273,228 +8236,6 @@ var READ_RECEIPTS_SCHEMA = {
8273
8236
  }
8274
8237
  };
8275
8238
 
8276
- // src/server/schemas/conversation.ts
8277
- var CONVERSATION_SCHEMAS = [
8278
- {
8279
- name: "conv_messages",
8280
- columns: [
8281
- { name: "Content", storage: "text", interpretation: "plain" },
8282
- { name: "AuthorId", storage: "text", interpretation: "plain" },
8283
- { name: "ParentId", storage: "text", interpretation: "plain" },
8284
- { name: "Edited", storage: "number", interpretation: "boolean" },
8285
- { name: "MessageType", storage: "text", interpretation: "plain" },
8286
- { name: "Metadata", storage: "text", interpretation: "json" }
8287
- ],
8288
- permissions: {
8289
- viewer: { read: true, create: false, update: false, delete: false },
8290
- member: { read: true, create: true, update: "own", delete: "own" },
8291
- admin: { read: true, create: true, update: true, delete: true }
8292
- },
8293
- ownerField: "AuthorId"
8294
- },
8295
- {
8296
- name: "conv_reactions",
8297
- columns: [
8298
- { name: "MessageId", storage: "text", interpretation: "plain" },
8299
- { name: "Emoji", storage: "text", interpretation: "plain" },
8300
- { name: "UserId", storage: "text", interpretation: "plain" }
8301
- ],
8302
- uniqueOn: ["MessageId", "Emoji", "UserId"],
8303
- permissions: {
8304
- viewer: { read: true, create: false, update: false, delete: false },
8305
- member: { read: true, create: true, update: false, delete: "own" },
8306
- admin: { read: true, create: true, update: false, delete: true }
8307
- },
8308
- ownerField: "UserId"
8309
- },
8310
- {
8311
- name: "conv_members",
8312
- columns: [
8313
- { name: "UserId", storage: "text", interpretation: "plain" },
8314
- { name: "UserName", storage: "text", interpretation: "plain" },
8315
- { name: "Role", storage: "text", interpretation: "plain" }
8316
- ],
8317
- uniqueOn: ["UserId"],
8318
- permissions: {
8319
- viewer: { read: true, create: false, update: false, delete: false },
8320
- member: { read: true, create: true, update: "own", delete: false },
8321
- admin: { read: true, create: true, update: true, delete: true }
8322
- },
8323
- ownerField: "UserId"
8324
- },
8325
- {
8326
- name: "conv_read_cursors",
8327
- columns: [
8328
- { name: "UserId", storage: "text", interpretation: "plain" },
8329
- { name: "LastReadAt", storage: "text", interpretation: "plain" }
8330
- ],
8331
- uniqueOn: ["UserId"],
8332
- permissions: {
8333
- viewer: { read: true, create: false, update: false, delete: false },
8334
- member: { read: true, create: true, update: "own", delete: false },
8335
- admin: { read: true, create: true, update: true, delete: true }
8336
- },
8337
- ownerField: "UserId"
8338
- }
8339
- ];
8340
- var VOTING_SCHEMAS = [
8341
- {
8342
- name: "conv_votes",
8343
- columns: [
8344
- { name: "TargetId", storage: "text", interpretation: "plain" },
8345
- { name: "UserId", storage: "text", interpretation: "plain" },
8346
- { name: "Direction", storage: "number", interpretation: "plain" }
8347
- ],
8348
- uniqueOn: ["TargetId", "UserId"],
8349
- permissions: {
8350
- viewer: { read: true, create: false, update: false, delete: false },
8351
- member: { read: true, create: true, update: "own", delete: "own" },
8352
- admin: { read: true, create: true, update: true, delete: true }
8353
- },
8354
- ownerField: "UserId"
8355
- }
8356
- ];
8357
-
8358
- // src/server/schemas/directory.ts
8359
- var conversationsSchema = {
8360
- name: "conversations",
8361
- columns: [
8362
- { name: "Name", storage: "text", interpretation: "plain" },
8363
- { name: "Description", storage: "text", interpretation: "plain" },
8364
- { name: "Type", storage: "text", interpretation: { kind: "select", options: ["public", "private", "dm", "group", "email", "outbound-email", "support", "announcement"] } },
8365
- { name: "Visibility", storage: "text", interpretation: { kind: "select", options: ["public", "private", "restricted"] } },
8366
- { name: "CreatedBy", storage: "text", interpretation: "plain" },
8367
- { name: "ParticipantHash", storage: "text", interpretation: "plain" },
8368
- { name: "ParticipantIds", storage: "text", interpretation: "json" },
8369
- { name: "Status", storage: "text", interpretation: { kind: "select", options: ["active", "archived", "resolved", "closed"] } },
8370
- { name: "AssigneeId", storage: "text", interpretation: "plain" },
8371
- { name: "LinkedRef", storage: "text", interpretation: "json" },
8372
- { name: "LastMessageAt", storage: "text", interpretation: { kind: "datetime" } },
8373
- { name: "LastMessagePreview", storage: "text", interpretation: "plain" },
8374
- { name: "LastMessageAuthor", storage: "text", interpretation: "plain" },
8375
- { name: "MessageCount", storage: "number", interpretation: "plain" }
8376
- ],
8377
- collaboratorsField: "ParticipantIds",
8378
- visibilityField: "Visibility",
8379
- permissions: {
8380
- viewer: { read: "shared", create: false, update: false, delete: false },
8381
- member: { read: "shared", create: true, update: true, delete: "own" },
8382
- admin: { read: true, create: true, update: true, delete: true }
8383
- },
8384
- ownerField: "CreatedBy"
8385
- };
8386
- var conversationStateSchema = {
8387
- name: "conversation_state",
8388
- columns: [
8389
- { name: "ConversationId", storage: "text", interpretation: "plain" },
8390
- { name: "UserId", storage: "text", interpretation: "plain" },
8391
- { name: "LastReadAt", storage: "text", interpretation: { kind: "datetime" } },
8392
- { name: "LastReadMessageCount", storage: "number", interpretation: "plain" },
8393
- { name: "Starred", storage: "number", interpretation: "boolean" },
8394
- { name: "Archived", storage: "number", interpretation: "boolean" },
8395
- { name: "Trashed", storage: "number", interpretation: "boolean" },
8396
- { name: "Labels", storage: "text", interpretation: "json" },
8397
- { name: "Folder", storage: "text", interpretation: "plain" }
8398
- ],
8399
- uniqueOn: ["ConversationId", "UserId"],
8400
- ownerField: "UserId",
8401
- permissions: {
8402
- viewer: { read: false, create: false, update: false, delete: false },
8403
- member: { read: "own", create: true, update: "own", delete: false },
8404
- admin: { read: true, create: true, update: true, delete: true }
8405
- }
8406
- };
8407
- var communitiesSchema = {
8408
- name: "communities",
8409
- columns: [
8410
- { name: "Name", storage: "text", interpretation: "plain" },
8411
- { name: "Description", storage: "text", interpretation: "plain" },
8412
- { name: "CreatedBy", storage: "text", interpretation: "plain" },
8413
- { name: "Type", storage: "text", interpretation: { kind: "select", options: ["community", "forum", "board", "project", "server"] } },
8414
- { name: "Visibility", storage: "text", interpretation: { kind: "select", options: ["public", "private", "restricted"] } },
8415
- { name: "MemberCount", storage: "number", interpretation: "plain" },
8416
- { name: "Rules", storage: "text", interpretation: "json" },
8417
- { name: "IconUrl", storage: "text", interpretation: "plain" },
8418
- { name: "CoverUrl", storage: "text", interpretation: "plain" }
8419
- ],
8420
- uniqueOn: ["Name"],
8421
- permissions: {
8422
- viewer: { read: true, create: false, update: false, delete: false },
8423
- member: { read: true, create: true, update: "own", delete: false },
8424
- admin: { read: true, create: true, update: true, delete: true }
8425
- },
8426
- ownerField: "CreatedBy"
8427
- };
8428
- var membershipsSchema = {
8429
- name: "memberships",
8430
- columns: [
8431
- { name: "CommunityId", storage: "text", interpretation: "plain" },
8432
- { name: "UserId", storage: "text", interpretation: "plain" },
8433
- { name: "UserName", storage: "text", interpretation: "plain" },
8434
- { name: "Role", storage: "text", interpretation: { kind: "select", options: ["member", "moderator", "admin"] } },
8435
- { name: "JoinedAt", storage: "text", interpretation: { kind: "datetime" } }
8436
- ],
8437
- uniqueOn: ["CommunityId", "UserId"],
8438
- permissions: {
8439
- viewer: { read: true, create: false, update: false, delete: false },
8440
- member: { read: true, create: true, update: "own", delete: "own" },
8441
- admin: { read: true, create: true, update: true, delete: true }
8442
- },
8443
- ownerField: "UserId"
8444
- };
8445
- var postsSchema = {
8446
- name: "posts",
8447
- columns: [
8448
- { name: "Title", storage: "text", interpretation: "plain" },
8449
- { name: "Content", storage: "text", interpretation: "plain" },
8450
- { name: "AuthorId", storage: "text", interpretation: "plain" },
8451
- { name: "Type", storage: "text", interpretation: { kind: "select", options: ["post", "question", "answer", "tweet", "announcement", "link"] } },
8452
- { name: "CommunityId", storage: "text", interpretation: "plain" },
8453
- { name: "ParentId", storage: "text", interpretation: "plain" },
8454
- { name: "ConversationId", storage: "text", interpretation: "plain" },
8455
- { name: "Status", storage: "text", interpretation: { kind: "select", options: ["draft", "published", "pinned", "archived", "accepted"] } },
8456
- { name: "Tags", storage: "text", interpretation: "json" },
8457
- { name: "LinkUrl", storage: "text", interpretation: "plain" }
8458
- ],
8459
- permissions: {
8460
- viewer: { read: true, create: false, update: false, delete: false },
8461
- member: { read: true, create: true, update: "own", delete: "own" },
8462
- admin: { read: true, create: true, update: true, delete: true }
8463
- },
8464
- ownerField: "AuthorId"
8465
- };
8466
- var DIRECTORY_SCHEMAS = [
8467
- conversationsSchema,
8468
- conversationStateSchema,
8469
- communitiesSchema,
8470
- membershipsSchema,
8471
- postsSchema
8472
- ];
8473
-
8474
- // src/server/schemas/shared-do.ts
8475
- var GLOBAL_DO_TYPES = [
8476
- {
8477
- name: "conv",
8478
- schemas: [...CONVERSATION_SCHEMAS, ...VOTING_SCHEMAS],
8479
- description: "Conversations (messages, reactions, members, voting)"
8480
- },
8481
- {
8482
- name: "dir",
8483
- schemas: DIRECTORY_SCHEMAS,
8484
- description: "App directory (conversations, communities, posts) \u2014 cross-app accessible"
8485
- }
8486
- ];
8487
- var GLOBAL_DO_TYPE_NAMES = GLOBAL_DO_TYPES.map((t) => t.name);
8488
- function getGlobalDOType(name) {
8489
- return GLOBAL_DO_TYPES.find((t) => t.name === name) ?? null;
8490
- }
8491
- function getGlobalDOSchemas(typeName) {
8492
- return getGlobalDOType(typeName)?.schemas ?? [];
8493
- }
8494
- var RESERVED_COLLECTION_NAMES = new Set(
8495
- GLOBAL_DO_TYPES.flatMap((t) => t.schemas.map((s) => s.name))
8496
- );
8497
-
8498
8239
  // src/server/auth/jwtVerifier.ts
8499
8240
  import { importSPKI, jwtVerify } from "jose";
8500
8241
 
@@ -8964,9 +8705,7 @@ export {
8964
8705
  BUILT_IN_TOOLS,
8965
8706
  BaseRoom,
8966
8707
  CHANNELS_SCHEMA,
8967
- CHANNEL_INVITATIONS_SCHEMA,
8968
8708
  CHANNEL_MEMBERS_SCHEMA,
8969
- CONVERSATION_SCHEMAS,
8970
8709
  COST_RATES,
8971
8710
  CancelSubscriptionError,
8972
8711
  CanvasRoom,
@@ -8976,11 +8715,8 @@ export {
8976
8715
  DEFAULT_DO_MANIFEST,
8977
8716
  DEFAULT_QUERY_LIMIT,
8978
8717
  DEPLOYED_APPS_DEFAULTS,
8979
- DIRECTORY_SCHEMAS,
8980
8718
  DeepSpaceAgentModelError,
8981
8719
  DeepSpaceAgentProfileError,
8982
- GLOBAL_DO_TYPES,
8983
- GLOBAL_DO_TYPE_NAMES,
8984
8720
  JobRoom,
8985
8721
  KnowledgeError,
8986
8722
  MAX_APP_FILE_BYTES,
@@ -8995,7 +8731,6 @@ export {
8995
8731
  READ_RECEIPTS_SCHEMA,
8996
8732
  REGISTRY_INSTANCE,
8997
8733
  RESERVED_BINDING_NAMES,
8998
- RESERVED_COLLECTION_NAMES,
8999
8734
  RESOURCE_ID_RE,
9000
8735
  RecordRoom,
9001
8736
  RefundError,
@@ -9011,7 +8746,6 @@ export {
9011
8746
  TEST_ACCOUNT_EMAIL_SUFFIX,
9012
8747
  UPLOAD_PART_BYTES,
9013
8748
  USERS_COLUMNS,
9014
- VOTING_SCHEMAS,
9015
8749
  YjsRoom,
9016
8750
  analyzePermissions,
9017
8751
  apiWorkerFetch,
@@ -9059,8 +8793,6 @@ export {
9059
8793
  formatBytes,
9060
8794
  getAllUsers,
9061
8795
  getChat,
9062
- getGlobalDOSchemas,
9063
- getGlobalDOType,
9064
8796
  getOrCreateYjsDoc,
9065
8797
  getRecord,
9066
8798
  getRolePermissions,