@ai-matrx/messaging 0.4.0 → 0.6.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
@@ -17,10 +17,22 @@ import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
17
17
  * is the JSON boundary — `metadata` and `action_data` are host/DB-generated
18
18
  * shapes this package does not own (the data 0.2.1 `Json = unknown` lesson).
19
19
  */
20
- /** Nominal id types. A conversation id can never be passed where a user id goes. */
21
- declare const brand: unique symbol;
20
+ /**
21
+ * Nominal id types. A conversation id can never be passed where a user id goes.
22
+ *
23
+ * 🚨 THE MARKER IS A NAMED PROPERTY, NOT A `unique symbol`. This package ships
24
+ * two entries built as two separate bundles, so a `declare const brand: unique
25
+ * symbol` is DECLARED TWICE — and two unique symbols are two different types.
26
+ * `ConversationId` from `@ai-matrx/messaging` then does not match
27
+ * `ConversationId` from `@ai-matrx/messaging/react`, which makes the two
28
+ * entries unusable together: the first consumer hit exactly that, calling
29
+ * `asConversationId` from the core and passing it to a hook. A structural
30
+ * marker is identical in both declarations, so the brands unify — and it still
31
+ * cannot be produced by accident, which is all nominal typing needs to do.
32
+ * (The marker is types-only; nothing writes it at runtime.)
33
+ */
22
34
  type Brand<T, B extends string> = T & {
23
- readonly [brand]: B;
35
+ readonly __mxBrand: B;
24
36
  };
25
37
  type ConversationId = Brand<string, "ConversationId">;
26
38
  type MessageId = Brand<string, "MessageId">;
@@ -1298,13 +1310,6 @@ declare function formatConversationTime(isoString: string | null, now?: number,
1298
1310
  declare function formatMessageTime(isoString: string, locale?: string): string;
1299
1311
  /** The separator between day groups in a thread. */
1300
1312
  declare function formatDateSeparator(isoString: string, now?: number, locale?: string): string;
1301
- declare function getInitials(name: string): string;
1302
- /**
1303
- * A stable palette index for an avatar with no image. Deterministic on the id,
1304
- * so the same person is the same color on every device and every reload — a
1305
- * random color per render is a surprisingly loud bug.
1306
- */
1307
- declare function avatarPaletteIndex(seed: string, buckets?: number): number;
1308
1313
  /**
1309
1314
  * Group consecutive messages by the same sender within a window, the way every
1310
1315
  * good chat UI does — one avatar and one name per burst.
@@ -1403,4 +1408,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1403
1408
  /** Serialize picked references into a fence the platform's other readers accept. */
1404
1409
  declare function composeFence(references: readonly MatrxReference[]): string;
1405
1410
 
1406
- 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_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, avatarPaletteIndex, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, getInitials, 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 };
1411
+ 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_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 };
package/dist/react.d.ts CHANGED
@@ -17,10 +17,22 @@ import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
17
17
  * is the JSON boundary — `metadata` and `action_data` are host/DB-generated
18
18
  * shapes this package does not own (the data 0.2.1 `Json = unknown` lesson).
19
19
  */
20
- /** Nominal id types. A conversation id can never be passed where a user id goes. */
21
- declare const brand: unique symbol;
20
+ /**
21
+ * Nominal id types. A conversation id can never be passed where a user id goes.
22
+ *
23
+ * 🚨 THE MARKER IS A NAMED PROPERTY, NOT A `unique symbol`. This package ships
24
+ * two entries built as two separate bundles, so a `declare const brand: unique
25
+ * symbol` is DECLARED TWICE — and two unique symbols are two different types.
26
+ * `ConversationId` from `@ai-matrx/messaging` then does not match
27
+ * `ConversationId` from `@ai-matrx/messaging/react`, which makes the two
28
+ * entries unusable together: the first consumer hit exactly that, calling
29
+ * `asConversationId` from the core and passing it to a hook. A structural
30
+ * marker is identical in both declarations, so the brands unify — and it still
31
+ * cannot be produced by accident, which is all nominal typing needs to do.
32
+ * (The marker is types-only; nothing writes it at runtime.)
33
+ */
22
34
  type Brand<T, B extends string> = T & {
23
- readonly [brand]: B;
35
+ readonly __mxBrand: B;
24
36
  };
25
37
  type ConversationId = Brand<string, "ConversationId">;
26
38
  type MessageId = Brand<string, "MessageId">;
@@ -1298,13 +1310,6 @@ declare function formatConversationTime(isoString: string | null, now?: number,
1298
1310
  declare function formatMessageTime(isoString: string, locale?: string): string;
1299
1311
  /** The separator between day groups in a thread. */
1300
1312
  declare function formatDateSeparator(isoString: string, now?: number, locale?: string): string;
1301
- declare function getInitials(name: string): string;
1302
- /**
1303
- * A stable palette index for an avatar with no image. Deterministic on the id,
1304
- * so the same person is the same color on every device and every reload — a
1305
- * random color per render is a surprisingly loud bug.
1306
- */
1307
- declare function avatarPaletteIndex(seed: string, buckets?: number): number;
1308
1313
  /**
1309
1314
  * Group consecutive messages by the same sender within a window, the way every
1310
1315
  * good chat UI does — one avatar and one name per burst.
@@ -1403,4 +1408,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1403
1408
  /** Serialize picked references into a fence the platform's other readers accept. */
1404
1409
  declare function composeFence(references: readonly MatrxReference[]): string;
1405
1410
 
1406
- 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_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, avatarPaletteIndex, composeFence, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createWebOutboxStorage, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, getInitials, 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 };
1411
+ 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_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 };
package/dist/react.js CHANGED
@@ -1907,20 +1907,6 @@ function formatDateSeparator(isoString, now = Date.now(), locale) {
1907
1907
  day: "numeric"
1908
1908
  });
1909
1909
  }
1910
- function getInitials(name) {
1911
- const parts = name.trim().split(/\s+/).filter(Boolean);
1912
- if (parts.length === 0) return "?";
1913
- const first = parts[0]?.[0] ?? "";
1914
- const last = parts.length > 1 ? parts.at(-1)?.[0] ?? "" : "";
1915
- return `${first}${last}`.toUpperCase() || "?";
1916
- }
1917
- function avatarPaletteIndex(seed, buckets = 8) {
1918
- let hash = 0;
1919
- for (let index = 0; index < seed.length; index += 1) {
1920
- hash = hash * 31 + seed.charCodeAt(index) | 0;
1921
- }
1922
- return Math.abs(hash) % buckets;
1923
- }
1924
1910
  function groupMessages(messages, args = {}) {
1925
1911
  const windowMs = args.windowMs ?? 5 * MINUTE;
1926
1912
  const now = args.now ?? Date.now();
@@ -2289,6 +2275,9 @@ function resolveActor(message, sender) {
2289
2275
  };
2290
2276
  }
2291
2277
 
2278
+ // src/react/parts.tsx
2279
+ import { avatarPaletteIndex, getInitials } from "@ai-matrx/kit/format";
2280
+
2292
2281
  // src/react/icons.tsx
2293
2282
  import { jsx as jsx2 } from "react/jsx-runtime";
2294
2283
  function Icon(props) {
@@ -3067,7 +3056,6 @@ export {
3067
3056
  asMessageId,
3068
3057
  asOrganizationId,
3069
3058
  asUserId,
3070
- avatarPaletteIndex,
3071
3059
  composeFence,
3072
3060
  conversationTopic,
3073
3061
  createActionRegistry,
@@ -3085,7 +3073,6 @@ export {
3085
3073
  formatLastSeen,
3086
3074
  formatMessageTime,
3087
3075
  formatTypists,
3088
- getInitials,
3089
3076
  groupMessages,
3090
3077
  inboxTopic,
3091
3078
  invalidResponse,