@ai-matrx/messaging 0.7.0 → 0.9.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/react.d.cts CHANGED
@@ -509,12 +509,37 @@ interface SupabaseLike extends SchemaLike {
509
509
  schema(name: string): SchemaLike;
510
510
  }
511
511
  /**
512
- * What `<MessagingProvider client={...}>` actually needs: the PostgREST surface
513
- * above AND the realtime surface `@ai-matrx/realtime` accepts. A real
514
- * `SupabaseClient` satisfies both, which is the point the host passes the one
515
- * client it already has, and the package never casts to make it fit.
512
+ * 🚨 THE PUBLIC PROP TYPE IS DELIBERATELY SHALLOW.
513
+ *
514
+ * `<MessagingProvider client={supabase}>` must accept the client the host
515
+ * ALREADY HAS a `SupabaseClient<Database>` built from generated types. It did
516
+ * not: checking a fully-typed client against the rich `SupabaseLike` above
517
+ * makes tsc chase PostgREST's schema machinery until it bails with **TS2589,
518
+ * "Type instantiation is excessively deep"**, followed by a page of "not
519
+ * assignable". The first real consumer hit both on the one line the README
520
+ * tells every consumer to write, and the only escape was the cast this
521
+ * package's own header forbids.
522
+ *
523
+ * So the boundary is shallow — method names and arity, results as `unknown` —
524
+ * which a typed client satisfies without the compiler unrolling anything. The
525
+ * RICH shape (`SupabaseLike`) is still the internal contract, and the provider
526
+ * narrows to it ONCE, inside the package. That is the data 0.2.1 lesson applied
527
+ * to a client instead of a JSON column: type a public boundary over `unknown`,
528
+ * never over a strict recursive type the host's generator also produces.
529
+ *
530
+ * `supabase-shape.test.ts` proves BOTH legs at compile time: every call this
531
+ * package makes works on a real client, AND a fully-typed real client is
532
+ * assignable to this type.
516
533
  */
517
- type MessagingSupabaseClient = SupabaseLike & RealtimeClientLike;
534
+ interface MessagingSupabaseClient {
535
+ schema(name: string): unknown;
536
+ from(table: string): unknown;
537
+ rpc(fn: string, args?: Record<string, unknown>): unknown;
538
+ channel(topic: string, params?: unknown): unknown;
539
+ removeChannel(channel: never): unknown;
540
+ }
541
+ /** The internal client contract — what the repository and the manager see. */
542
+ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
518
543
 
519
544
  /**
520
545
  * THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
@@ -583,7 +608,15 @@ declare const RPCS: {
583
608
  */
584
609
  type SessionResolver = () => Promise<unknown>;
585
610
  interface RepositoryOptions {
586
- client: SupabaseLike;
611
+ /**
612
+ * The host's Supabase client. Typed over the SHALLOW public shape for the
613
+ * same reason the provider's prop is (see `supabase-shape.ts`): a fully-typed
614
+ * `SupabaseClient<Database>` checked against the rich contract makes tsc bail
615
+ * with TS2589. A service module builds this repository directly — the
616
+ * framework-free path in the README — so it hits the boundary exactly like
617
+ * the provider does.
618
+ */
619
+ client: MessagingSupabaseClient;
587
620
  identity: MessagingIdentity;
588
621
  /** Called once before a retry when a read fails with a missing session. */
589
622
  resolveSession?: SessionResolver | undefined;
@@ -1425,4 +1458,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1425
1458
  /** Serialize picked references into a fence the platform's other readers accept. */
1426
1459
  declare function composeFence(references: readonly MatrxReference[]): string;
1427
1460
 
1428
- export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type Conversation, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, splitText, summarizeText, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };
1461
+ export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type Conversation, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, splitText, summarizeText, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };
package/dist/react.d.ts CHANGED
@@ -509,12 +509,37 @@ interface SupabaseLike extends SchemaLike {
509
509
  schema(name: string): SchemaLike;
510
510
  }
511
511
  /**
512
- * What `<MessagingProvider client={...}>` actually needs: the PostgREST surface
513
- * above AND the realtime surface `@ai-matrx/realtime` accepts. A real
514
- * `SupabaseClient` satisfies both, which is the point the host passes the one
515
- * client it already has, and the package never casts to make it fit.
512
+ * 🚨 THE PUBLIC PROP TYPE IS DELIBERATELY SHALLOW.
513
+ *
514
+ * `<MessagingProvider client={supabase}>` must accept the client the host
515
+ * ALREADY HAS a `SupabaseClient<Database>` built from generated types. It did
516
+ * not: checking a fully-typed client against the rich `SupabaseLike` above
517
+ * makes tsc chase PostgREST's schema machinery until it bails with **TS2589,
518
+ * "Type instantiation is excessively deep"**, followed by a page of "not
519
+ * assignable". The first real consumer hit both on the one line the README
520
+ * tells every consumer to write, and the only escape was the cast this
521
+ * package's own header forbids.
522
+ *
523
+ * So the boundary is shallow — method names and arity, results as `unknown` —
524
+ * which a typed client satisfies without the compiler unrolling anything. The
525
+ * RICH shape (`SupabaseLike`) is still the internal contract, and the provider
526
+ * narrows to it ONCE, inside the package. That is the data 0.2.1 lesson applied
527
+ * to a client instead of a JSON column: type a public boundary over `unknown`,
528
+ * never over a strict recursive type the host's generator also produces.
529
+ *
530
+ * `supabase-shape.test.ts` proves BOTH legs at compile time: every call this
531
+ * package makes works on a real client, AND a fully-typed real client is
532
+ * assignable to this type.
516
533
  */
517
- type MessagingSupabaseClient = SupabaseLike & RealtimeClientLike;
534
+ interface MessagingSupabaseClient {
535
+ schema(name: string): unknown;
536
+ from(table: string): unknown;
537
+ rpc(fn: string, args?: Record<string, unknown>): unknown;
538
+ channel(topic: string, params?: unknown): unknown;
539
+ removeChannel(channel: never): unknown;
540
+ }
541
+ /** The internal client contract — what the repository and the manager see. */
542
+ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
518
543
 
519
544
  /**
520
545
  * THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
@@ -583,7 +608,15 @@ declare const RPCS: {
583
608
  */
584
609
  type SessionResolver = () => Promise<unknown>;
585
610
  interface RepositoryOptions {
586
- client: SupabaseLike;
611
+ /**
612
+ * The host's Supabase client. Typed over the SHALLOW public shape for the
613
+ * same reason the provider's prop is (see `supabase-shape.ts`): a fully-typed
614
+ * `SupabaseClient<Database>` checked against the rich contract makes tsc bail
615
+ * with TS2589. A service module builds this repository directly — the
616
+ * framework-free path in the README — so it hits the boundary exactly like
617
+ * the provider does.
618
+ */
619
+ client: MessagingSupabaseClient;
587
620
  identity: MessagingIdentity;
588
621
  /** Called once before a retry when a read fails with a missing session. */
589
622
  resolveSession?: SessionResolver | undefined;
@@ -1425,4 +1458,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1425
1458
  /** Serialize picked references into a fence the platform's other readers accept. */
1426
1459
  declare function composeFence(references: readonly MatrxReference[]): string;
1427
1460
 
1428
- export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type Conversation, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, splitText, summarizeText, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };
1461
+ export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type Conversation, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, splitText, summarizeText, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };
package/dist/react.js CHANGED
@@ -658,11 +658,13 @@ function projectParticipants(value, operation) {
658
658
  for (const entry of value) {
659
659
  if (typeof entry !== "object" || entry === null) continue;
660
660
  const record = entry;
661
- const id = str(record, "user_id") ?? str(record, "id");
661
+ const nested = typeof record["user"] === "object" && record["user"] !== null ? record["user"] : {};
662
+ const id = str(record, "user_id") ?? str(nested, "user_id") ?? str(record, "id");
662
663
  if (id === null) continue;
663
664
  summaries.push(
664
665
  projectUserSummary({
665
666
  ...record,
667
+ ...nested,
666
668
  user_id: id
667
669
  })
668
670
  );
@@ -1386,12 +1388,13 @@ function requireOrg(organizationId, operation) {
1386
1388
  return organizationId;
1387
1389
  }
1388
1390
  function createMessagingRepository(options) {
1389
- const { client, identity } = options;
1391
+ const { identity } = options;
1390
1392
  const org = requireOrg(identity.organizationId, "createMessagingRepository");
1391
1393
  const userCache = createReadCache({
1392
1394
  ttlMs: options.userTtlMs ?? 5 * 6e4,
1393
1395
  ...options.now !== void 0 ? { now: options.now } : {}
1394
1396
  });
1397
+ const client = options.client;
1395
1398
  const db = () => client.schema(MESSAGING_SCHEMA);
1396
1399
  const rpcDb = () => client.schema(MESSAGING_RPC_SCHEMA);
1397
1400
  async function withSessionRetry(operation, run) {
@@ -1719,7 +1722,14 @@ function MessagingProvider(props) {
1719
1722
  const ready = client != null && typeof userId === "string" && userId.length > 0 && typeof organizationId === "string" && organizationId.length > 0;
1720
1723
  const hostProvidesRealtime = useIsRealtimeProviderMounted();
1721
1724
  if (hostProvidesRealtime) return /* @__PURE__ */ jsx(MessagingRuntime, { ...props });
1722
- return /* @__PURE__ */ jsx(RealtimeProvider, { client: ready ? client : null, actorId: userId ?? void 0, children: /* @__PURE__ */ jsx(MessagingRuntime, { ...props }) });
1725
+ return /* @__PURE__ */ jsx(
1726
+ RealtimeProvider,
1727
+ {
1728
+ client: ready ? client : null,
1729
+ actorId: userId ?? void 0,
1730
+ children: /* @__PURE__ */ jsx(MessagingRuntime, { ...props })
1731
+ }
1732
+ );
1723
1733
  }
1724
1734
  function MessagingRuntime(props) {
1725
1735
  const { client, userId, organizationId, children } = props;
@@ -1748,6 +1758,10 @@ function MessagingRuntime(props) {
1748
1758
  (diagnosticRef.current ?? defaultDiagnostics)(event);
1749
1759
  };
1750
1760
  const repository = createMessagingRepository({
1761
+ // THE ONE NARROWING, and it lives INSIDE the package. The prop is shallow
1762
+ // so a host's fully-typed client is assignable at all (see
1763
+ // supabase-shape.ts); everything below this line works against the rich
1764
+ // contract, which `supabase-shape.test.ts` proves a real client honors.
1751
1765
  client,
1752
1766
  identity,
1753
1767
  ...props.resolveSession !== void 0 ? { resolveSession: props.resolveSession } : {}