@ai-matrx/messaging 0.1.3 → 0.3.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/CHANGELOG.md +75 -0
- package/README.md +53 -0
- package/dist/react.cjs +96 -26
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +98 -4
- package/dist/react.d.ts +98 -4
- package/dist/react.js +101 -27
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, SVGProps } from 'react';
|
|
1
|
+
import { ReactNode, ComponentType, SVGProps } from 'react';
|
|
2
2
|
import { MatrxTransport } from '@ai-matrx/agents/matrx';
|
|
3
3
|
import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
|
|
4
4
|
|
|
@@ -781,12 +781,85 @@ declare function messagingClientId(): string;
|
|
|
781
781
|
* resubscribe loop that looks exactly like "realtime is broken".
|
|
782
782
|
*/
|
|
783
783
|
|
|
784
|
+
/**
|
|
785
|
+
* What the host needs to decide whether to interrupt someone, and what to say.
|
|
786
|
+
*/
|
|
787
|
+
interface IncomingMessageContext {
|
|
788
|
+
/** The message landed in the conversation currently on screen. */
|
|
789
|
+
readonly isActiveConversation: boolean;
|
|
790
|
+
/** The conversation it landed in, when the inbox already holds it. */
|
|
791
|
+
readonly conversation: ConversationSummary | null;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* A host-supplied surface for ONE action kind.
|
|
795
|
+
*
|
|
796
|
+
* Chips answer a QUESTION ("Approve" / "Decline"); some actions are not
|
|
797
|
+
* questions. A shared-resource card, a link out to a report, a reminder with an
|
|
798
|
+
* app icon — those are app-shaped surfaces that only the host can draw, and a
|
|
799
|
+
* host that cannot draw them in the bubble ends up keeping its own message
|
|
800
|
+
* renderer beside this package's, which is the failure this package exists to
|
|
801
|
+
* prevent.
|
|
802
|
+
*
|
|
803
|
+
* The forward-compatibility rule is unchanged and enforced here, not by the
|
|
804
|
+
* host: a kind at a version this build does not list renders NOTHING.
|
|
805
|
+
*/
|
|
806
|
+
interface MessageActionRenderProps<TPayload = unknown> {
|
|
807
|
+
readonly message: Message;
|
|
808
|
+
readonly payload: TPayload;
|
|
809
|
+
/** The signed-in user wrote this message — bubble-side styling depends on it. */
|
|
810
|
+
readonly isOwn: boolean;
|
|
811
|
+
}
|
|
812
|
+
interface MessageActionRenderer<TPayload = unknown> {
|
|
813
|
+
readonly kind: string;
|
|
814
|
+
/** Versions this build understands. An unlisted version renders nothing. */
|
|
815
|
+
readonly versions: readonly number[];
|
|
816
|
+
readonly render: ComponentType<MessageActionRenderProps<TPayload>>;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* A host's own renderer for a Matrx reference.
|
|
820
|
+
*
|
|
821
|
+
* References are the ONE piece of a bubble an app is likely to already render
|
|
822
|
+
* everywhere else — this platform resolves a ```matrx fence through a kind
|
|
823
|
+
* registry and draws a live, openable chip. Two different treatments of the
|
|
824
|
+
* same fence in one app is the second-renderer defect, so a host may hand us
|
|
825
|
+
* theirs. Omit it and the package's own card is used, which is what a
|
|
826
|
+
* greenfield consumer wants.
|
|
827
|
+
*/
|
|
828
|
+
type ReferenceRenderer = ComponentType<{
|
|
829
|
+
reference: MatrxReference;
|
|
830
|
+
}>;
|
|
831
|
+
/**
|
|
832
|
+
* App chrome wrapped around ONE message bubble or ONE conversation row.
|
|
833
|
+
*
|
|
834
|
+
* The reason this exists is the right-click menu. A platform whose every
|
|
835
|
+
* surface answers a right-click with copy / export / attach / hand-to-an-agent
|
|
836
|
+
* cannot have messaging be the one surface that does not — and a menu is
|
|
837
|
+
* per-row app chrome that no package can own (it needs the app's surface name,
|
|
838
|
+
* its entity tokens, its clipboard primitive). Without the seam a host keeps
|
|
839
|
+
* its own message list beside this one, which is the whole failure mode.
|
|
840
|
+
*
|
|
841
|
+
* It wraps; it does not replace. The bubble it receives is the package's.
|
|
842
|
+
*/
|
|
843
|
+
interface MessageWrapperProps {
|
|
844
|
+
readonly message: Message;
|
|
845
|
+
readonly isMine: boolean;
|
|
846
|
+
readonly children: ReactNode;
|
|
847
|
+
}
|
|
848
|
+
interface ConversationRowWrapperProps {
|
|
849
|
+
readonly conversation: ConversationSummary;
|
|
850
|
+
readonly children: ReactNode;
|
|
851
|
+
}
|
|
784
852
|
interface MessagingHost {
|
|
785
853
|
readonly engine: MessagingEngine;
|
|
786
854
|
readonly actions: ActionRegistry;
|
|
787
855
|
readonly ai: MessagingAi | null;
|
|
788
856
|
readonly identity: MessagingIdentity;
|
|
789
857
|
readonly openReference: ((reference: MatrxReference) => void) | null;
|
|
858
|
+
/** Host surfaces for action kinds whose answer is a card, not a chip. */
|
|
859
|
+
readonly actionRenderers: ReadonlyMap<string, MessageActionRenderer>;
|
|
860
|
+
readonly renderReference: ReferenceRenderer | null;
|
|
861
|
+
readonly wrapMessage: ComponentType<MessageWrapperProps> | null;
|
|
862
|
+
readonly wrapConversationRow: ComponentType<ConversationRowWrapperProps> | null;
|
|
790
863
|
}
|
|
791
864
|
interface MessagingProviderProps {
|
|
792
865
|
/** Any Supabase client. `null` while the host is still resolving one. */
|
|
@@ -804,10 +877,31 @@ interface MessagingProviderProps {
|
|
|
804
877
|
agents?: MessagingAgents | undefined;
|
|
805
878
|
/** Handlers for actionable messages. Registered once per handler identity. */
|
|
806
879
|
actions?: readonly ActionHandler<never>[] | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* Host surfaces for action kinds whose answer is a CARD, not a chip — a
|
|
882
|
+
* shared-resource card, a link out, an app-shaped reminder. A kind with a
|
|
883
|
+
* renderer draws that instead of chips; every other rule is unchanged,
|
|
884
|
+
* including the one that matters: an unknown kind, or a known kind at an
|
|
885
|
+
* unlisted version, renders NOTHING.
|
|
886
|
+
*/
|
|
887
|
+
actionRenderers?: readonly MessageActionRenderer<never>[] | undefined;
|
|
807
888
|
/** Called when a reference card is clicked. Omit and cards render inert-but-labeled. */
|
|
808
889
|
onOpenReference?: ((reference: MatrxReference) => void) | undefined;
|
|
809
|
-
/**
|
|
810
|
-
|
|
890
|
+
/** Draw references with the app's own renderer instead of the package card. */
|
|
891
|
+
renderReference?: ReferenceRenderer | undefined;
|
|
892
|
+
/** App chrome (a right-click menu, a drop target) around each message bubble. */
|
|
893
|
+
wrapMessage?: ComponentType<MessageWrapperProps> | undefined;
|
|
894
|
+
/** App chrome around each conversation row. */
|
|
895
|
+
wrapConversationRow?: ComponentType<ConversationRowWrapperProps> | undefined;
|
|
896
|
+
/**
|
|
897
|
+
* A message arrived from someone else — for a toast, sound, or badge.
|
|
898
|
+
*
|
|
899
|
+
* The CONTEXT is not a courtesy. "Do not interrupt someone for the
|
|
900
|
+
* conversation they are looking at" is the rule every chat app needs and only
|
|
901
|
+
* this package can answer, and a notification names the SENDER, whose display
|
|
902
|
+
* name lives on the conversation the host cannot see from above the provider.
|
|
903
|
+
*/
|
|
904
|
+
onIncomingMessage?: ((message: Message, context: IncomingMessageContext) => void) | undefined;
|
|
811
905
|
/** Background failures, with a remedy. Defaults to a console sink. */
|
|
812
906
|
onDiagnostic?: ((event: EngineDiagnostic) => void) | undefined;
|
|
813
907
|
/** Re-resolve a session after one goes missing. Enables the single retry. */
|
|
@@ -1286,4 +1380,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
|
|
|
1286
1380
|
/** Serialize picked references into a fence the platform's other readers accept. */
|
|
1287
1381
|
declare function composeFence(references: readonly MatrxReference[]): string;
|
|
1288
1382
|
|
|
1289
|
-
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, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, 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, 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 };
|
|
1383
|
+
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 };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, SVGProps } from 'react';
|
|
1
|
+
import { ReactNode, ComponentType, SVGProps } from 'react';
|
|
2
2
|
import { MatrxTransport } from '@ai-matrx/agents/matrx';
|
|
3
3
|
import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
|
|
4
4
|
|
|
@@ -781,12 +781,85 @@ declare function messagingClientId(): string;
|
|
|
781
781
|
* resubscribe loop that looks exactly like "realtime is broken".
|
|
782
782
|
*/
|
|
783
783
|
|
|
784
|
+
/**
|
|
785
|
+
* What the host needs to decide whether to interrupt someone, and what to say.
|
|
786
|
+
*/
|
|
787
|
+
interface IncomingMessageContext {
|
|
788
|
+
/** The message landed in the conversation currently on screen. */
|
|
789
|
+
readonly isActiveConversation: boolean;
|
|
790
|
+
/** The conversation it landed in, when the inbox already holds it. */
|
|
791
|
+
readonly conversation: ConversationSummary | null;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* A host-supplied surface for ONE action kind.
|
|
795
|
+
*
|
|
796
|
+
* Chips answer a QUESTION ("Approve" / "Decline"); some actions are not
|
|
797
|
+
* questions. A shared-resource card, a link out to a report, a reminder with an
|
|
798
|
+
* app icon — those are app-shaped surfaces that only the host can draw, and a
|
|
799
|
+
* host that cannot draw them in the bubble ends up keeping its own message
|
|
800
|
+
* renderer beside this package's, which is the failure this package exists to
|
|
801
|
+
* prevent.
|
|
802
|
+
*
|
|
803
|
+
* The forward-compatibility rule is unchanged and enforced here, not by the
|
|
804
|
+
* host: a kind at a version this build does not list renders NOTHING.
|
|
805
|
+
*/
|
|
806
|
+
interface MessageActionRenderProps<TPayload = unknown> {
|
|
807
|
+
readonly message: Message;
|
|
808
|
+
readonly payload: TPayload;
|
|
809
|
+
/** The signed-in user wrote this message — bubble-side styling depends on it. */
|
|
810
|
+
readonly isOwn: boolean;
|
|
811
|
+
}
|
|
812
|
+
interface MessageActionRenderer<TPayload = unknown> {
|
|
813
|
+
readonly kind: string;
|
|
814
|
+
/** Versions this build understands. An unlisted version renders nothing. */
|
|
815
|
+
readonly versions: readonly number[];
|
|
816
|
+
readonly render: ComponentType<MessageActionRenderProps<TPayload>>;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* A host's own renderer for a Matrx reference.
|
|
820
|
+
*
|
|
821
|
+
* References are the ONE piece of a bubble an app is likely to already render
|
|
822
|
+
* everywhere else — this platform resolves a ```matrx fence through a kind
|
|
823
|
+
* registry and draws a live, openable chip. Two different treatments of the
|
|
824
|
+
* same fence in one app is the second-renderer defect, so a host may hand us
|
|
825
|
+
* theirs. Omit it and the package's own card is used, which is what a
|
|
826
|
+
* greenfield consumer wants.
|
|
827
|
+
*/
|
|
828
|
+
type ReferenceRenderer = ComponentType<{
|
|
829
|
+
reference: MatrxReference;
|
|
830
|
+
}>;
|
|
831
|
+
/**
|
|
832
|
+
* App chrome wrapped around ONE message bubble or ONE conversation row.
|
|
833
|
+
*
|
|
834
|
+
* The reason this exists is the right-click menu. A platform whose every
|
|
835
|
+
* surface answers a right-click with copy / export / attach / hand-to-an-agent
|
|
836
|
+
* cannot have messaging be the one surface that does not — and a menu is
|
|
837
|
+
* per-row app chrome that no package can own (it needs the app's surface name,
|
|
838
|
+
* its entity tokens, its clipboard primitive). Without the seam a host keeps
|
|
839
|
+
* its own message list beside this one, which is the whole failure mode.
|
|
840
|
+
*
|
|
841
|
+
* It wraps; it does not replace. The bubble it receives is the package's.
|
|
842
|
+
*/
|
|
843
|
+
interface MessageWrapperProps {
|
|
844
|
+
readonly message: Message;
|
|
845
|
+
readonly isMine: boolean;
|
|
846
|
+
readonly children: ReactNode;
|
|
847
|
+
}
|
|
848
|
+
interface ConversationRowWrapperProps {
|
|
849
|
+
readonly conversation: ConversationSummary;
|
|
850
|
+
readonly children: ReactNode;
|
|
851
|
+
}
|
|
784
852
|
interface MessagingHost {
|
|
785
853
|
readonly engine: MessagingEngine;
|
|
786
854
|
readonly actions: ActionRegistry;
|
|
787
855
|
readonly ai: MessagingAi | null;
|
|
788
856
|
readonly identity: MessagingIdentity;
|
|
789
857
|
readonly openReference: ((reference: MatrxReference) => void) | null;
|
|
858
|
+
/** Host surfaces for action kinds whose answer is a card, not a chip. */
|
|
859
|
+
readonly actionRenderers: ReadonlyMap<string, MessageActionRenderer>;
|
|
860
|
+
readonly renderReference: ReferenceRenderer | null;
|
|
861
|
+
readonly wrapMessage: ComponentType<MessageWrapperProps> | null;
|
|
862
|
+
readonly wrapConversationRow: ComponentType<ConversationRowWrapperProps> | null;
|
|
790
863
|
}
|
|
791
864
|
interface MessagingProviderProps {
|
|
792
865
|
/** Any Supabase client. `null` while the host is still resolving one. */
|
|
@@ -804,10 +877,31 @@ interface MessagingProviderProps {
|
|
|
804
877
|
agents?: MessagingAgents | undefined;
|
|
805
878
|
/** Handlers for actionable messages. Registered once per handler identity. */
|
|
806
879
|
actions?: readonly ActionHandler<never>[] | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* Host surfaces for action kinds whose answer is a CARD, not a chip — a
|
|
882
|
+
* shared-resource card, a link out, an app-shaped reminder. A kind with a
|
|
883
|
+
* renderer draws that instead of chips; every other rule is unchanged,
|
|
884
|
+
* including the one that matters: an unknown kind, or a known kind at an
|
|
885
|
+
* unlisted version, renders NOTHING.
|
|
886
|
+
*/
|
|
887
|
+
actionRenderers?: readonly MessageActionRenderer<never>[] | undefined;
|
|
807
888
|
/** Called when a reference card is clicked. Omit and cards render inert-but-labeled. */
|
|
808
889
|
onOpenReference?: ((reference: MatrxReference) => void) | undefined;
|
|
809
|
-
/**
|
|
810
|
-
|
|
890
|
+
/** Draw references with the app's own renderer instead of the package card. */
|
|
891
|
+
renderReference?: ReferenceRenderer | undefined;
|
|
892
|
+
/** App chrome (a right-click menu, a drop target) around each message bubble. */
|
|
893
|
+
wrapMessage?: ComponentType<MessageWrapperProps> | undefined;
|
|
894
|
+
/** App chrome around each conversation row. */
|
|
895
|
+
wrapConversationRow?: ComponentType<ConversationRowWrapperProps> | undefined;
|
|
896
|
+
/**
|
|
897
|
+
* A message arrived from someone else — for a toast, sound, or badge.
|
|
898
|
+
*
|
|
899
|
+
* The CONTEXT is not a courtesy. "Do not interrupt someone for the
|
|
900
|
+
* conversation they are looking at" is the rule every chat app needs and only
|
|
901
|
+
* this package can answer, and a notification names the SENDER, whose display
|
|
902
|
+
* name lives on the conversation the host cannot see from above the provider.
|
|
903
|
+
*/
|
|
904
|
+
onIncomingMessage?: ((message: Message, context: IncomingMessageContext) => void) | undefined;
|
|
811
905
|
/** Background failures, with a remedy. Defaults to a console sink. */
|
|
812
906
|
onDiagnostic?: ((event: EngineDiagnostic) => void) | undefined;
|
|
813
907
|
/** Re-resolve a session after one goes missing. Enables the single retry. */
|
|
@@ -1286,4 +1380,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
|
|
|
1286
1380
|
/** Serialize picked references into a fence the platform's other readers accept. */
|
|
1287
1381
|
declare function composeFence(references: readonly MatrxReference[]): string;
|
|
1288
1382
|
|
|
1289
|
-
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, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, 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, 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 };
|
|
1383
|
+
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 };
|
package/dist/react.js
CHANGED
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
useRef,
|
|
11
11
|
useSyncExternalStore
|
|
12
12
|
} from "react";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
RealtimeProvider,
|
|
15
|
+
useIsRealtimeProviderMounted,
|
|
16
|
+
useRealtimeManager
|
|
17
|
+
} from "@ai-matrx/realtime/react";
|
|
14
18
|
|
|
15
19
|
// src/core/actions.ts
|
|
16
20
|
function receiptKey(kind, messageId, actorId) {
|
|
@@ -1684,7 +1688,12 @@ function createMessagingRepository(options) {
|
|
|
1684
1688
|
|
|
1685
1689
|
// src/react/provider.tsx
|
|
1686
1690
|
import { jsx } from "react/jsx-runtime";
|
|
1687
|
-
|
|
1691
|
+
function messagingContext() {
|
|
1692
|
+
return globalSlot(
|
|
1693
|
+
"react-context",
|
|
1694
|
+
() => createContext(null)
|
|
1695
|
+
);
|
|
1696
|
+
}
|
|
1688
1697
|
function defaultDiagnostics(event) {
|
|
1689
1698
|
const line = `[@ai-matrx/messaging] ${event.message}${event.remedy !== void 0 ? `
|
|
1690
1699
|
\u2192 ${event.remedy}` : ""}`;
|
|
@@ -1695,6 +1704,8 @@ function defaultDiagnostics(event) {
|
|
|
1695
1704
|
function MessagingProvider(props) {
|
|
1696
1705
|
const { client, userId, organizationId } = props;
|
|
1697
1706
|
const ready = client != null && typeof userId === "string" && userId.length > 0 && typeof organizationId === "string" && organizationId.length > 0;
|
|
1707
|
+
const hostProvidesRealtime = useIsRealtimeProviderMounted();
|
|
1708
|
+
if (hostProvidesRealtime) return /* @__PURE__ */ jsx(MessagingRuntime, { ...props });
|
|
1698
1709
|
return /* @__PURE__ */ jsx(RealtimeProvider, { client: ready ? client : null, actorId: userId ?? void 0, children: /* @__PURE__ */ jsx(MessagingRuntime, { ...props }) });
|
|
1699
1710
|
}
|
|
1700
1711
|
function MessagingRuntime(props) {
|
|
@@ -1728,7 +1739,8 @@ function MessagingRuntime(props) {
|
|
|
1728
1739
|
identity,
|
|
1729
1740
|
...props.resolveSession !== void 0 ? { resolveSession: props.resolveSession } : {}
|
|
1730
1741
|
});
|
|
1731
|
-
|
|
1742
|
+
let built = null;
|
|
1743
|
+
built = createMessagingEngine({
|
|
1732
1744
|
repository,
|
|
1733
1745
|
manager,
|
|
1734
1746
|
identity,
|
|
@@ -1737,8 +1749,18 @@ function MessagingRuntime(props) {
|
|
|
1737
1749
|
onFallback: (message) => report({ level: "warn", message })
|
|
1738
1750
|
}),
|
|
1739
1751
|
onDiagnostic: report,
|
|
1740
|
-
onIncoming: (message) =>
|
|
1752
|
+
onIncoming: (message) => {
|
|
1753
|
+
const snapshot = built?.store.snapshot();
|
|
1754
|
+
if (snapshot === void 0) return;
|
|
1755
|
+
incomingRef.current?.(message, {
|
|
1756
|
+
isActiveConversation: snapshot.activeConversationId === message.conversationId,
|
|
1757
|
+
conversation: snapshot.conversations.find(
|
|
1758
|
+
(item) => item.conversation.id === message.conversationId
|
|
1759
|
+
) ?? null
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1741
1762
|
});
|
|
1763
|
+
return built;
|
|
1742
1764
|
}, [ready, manager, userId, organizationId]);
|
|
1743
1765
|
useEffect(() => {
|
|
1744
1766
|
if (engine === null) return void 0;
|
|
@@ -1763,6 +1785,17 @@ function MessagingRuntime(props) {
|
|
|
1763
1785
|
agents
|
|
1764
1786
|
});
|
|
1765
1787
|
}, [transport, agents, ready, organizationId]);
|
|
1788
|
+
const renderers = props.actionRenderers;
|
|
1789
|
+
const rendererMap = useMemo(() => {
|
|
1790
|
+
const map = /* @__PURE__ */ new Map();
|
|
1791
|
+
(renderers ?? []).forEach((renderer) => {
|
|
1792
|
+
map.set(renderer.kind, renderer);
|
|
1793
|
+
});
|
|
1794
|
+
return map;
|
|
1795
|
+
}, [renderers]);
|
|
1796
|
+
const renderReference = props.renderReference ?? null;
|
|
1797
|
+
const wrapMessage = props.wrapMessage ?? null;
|
|
1798
|
+
const wrapConversationRow = props.wrapConversationRow ?? null;
|
|
1766
1799
|
const host = useMemo(() => {
|
|
1767
1800
|
if (engine === null) return null;
|
|
1768
1801
|
return {
|
|
@@ -1770,13 +1803,18 @@ function MessagingRuntime(props) {
|
|
|
1770
1803
|
actions: actionRegistry,
|
|
1771
1804
|
ai,
|
|
1772
1805
|
identity: engine.identity,
|
|
1773
|
-
openReference: referenceRef.current ?? null
|
|
1806
|
+
openReference: referenceRef.current ?? null,
|
|
1807
|
+
actionRenderers: rendererMap,
|
|
1808
|
+
renderReference,
|
|
1809
|
+
wrapMessage,
|
|
1810
|
+
wrapConversationRow
|
|
1774
1811
|
};
|
|
1775
|
-
}, [engine, actionRegistry, ai]);
|
|
1812
|
+
}, [engine, actionRegistry, ai, rendererMap, renderReference, wrapMessage, wrapConversationRow]);
|
|
1813
|
+
const MessagingContext = messagingContext();
|
|
1776
1814
|
return /* @__PURE__ */ jsx(MessagingContext.Provider, { value: host, children });
|
|
1777
1815
|
}
|
|
1778
1816
|
function useMessagingHost() {
|
|
1779
|
-
return useContext(
|
|
1817
|
+
return useContext(messagingContext());
|
|
1780
1818
|
}
|
|
1781
1819
|
function useRequiredMessagingHost() {
|
|
1782
1820
|
const host = useMessagingHost();
|
|
@@ -2442,6 +2480,7 @@ var AI_LABELS = {
|
|
|
2442
2480
|
};
|
|
2443
2481
|
function ConversationList(props) {
|
|
2444
2482
|
const { conversations, hasMore, isInitialLoading, loadMore, select, activeConversationId } = useConversations();
|
|
2483
|
+
const RowChrome = useMessagingHost()?.wrapConversationRow ?? null;
|
|
2445
2484
|
const [query, setQuery] = useState2("");
|
|
2446
2485
|
const visible = useMemo3(() => {
|
|
2447
2486
|
const needle = query.trim().toLowerCase();
|
|
@@ -2482,17 +2521,20 @@ function ConversationList(props) {
|
|
|
2482
2521
|
title: query.length > 0 ? "No matches" : "No conversations yet",
|
|
2483
2522
|
body: query.length > 0 ? "Try a different name or word." : "Start one and it will appear here."
|
|
2484
2523
|
}
|
|
2485
|
-
) : /* @__PURE__ */ jsx4("ul", { className: "mx-msg__rows", children: visible.map((item) =>
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2524
|
+
) : /* @__PURE__ */ jsx4("ul", { className: "mx-msg__rows", children: visible.map((item) => {
|
|
2525
|
+
const row = /* @__PURE__ */ jsx4(
|
|
2526
|
+
ConversationRow,
|
|
2527
|
+
{
|
|
2528
|
+
summary: item,
|
|
2529
|
+
isActive: item.conversation.id === activeConversationId,
|
|
2530
|
+
onSelect: () => {
|
|
2531
|
+
select(item.conversation.id);
|
|
2532
|
+
props.onSelect?.(item.conversation.id);
|
|
2533
|
+
}
|
|
2493
2534
|
}
|
|
2494
|
-
|
|
2495
|
-
|
|
2535
|
+
);
|
|
2536
|
+
return /* @__PURE__ */ jsx4("li", { children: RowChrome !== null ? /* @__PURE__ */ jsx4(RowChrome, { conversation: item, children: row }) : row }, item.conversation.id);
|
|
2537
|
+
}) }),
|
|
2496
2538
|
hasMore && !isInitialLoading ? /* @__PURE__ */ jsx4(
|
|
2497
2539
|
"button",
|
|
2498
2540
|
{
|
|
@@ -2721,6 +2763,8 @@ function MessageGroupView(props) {
|
|
|
2721
2763
|
function MessageBubble(props) {
|
|
2722
2764
|
const { message, isMine } = props;
|
|
2723
2765
|
const host = useMessagingHost();
|
|
2766
|
+
const HostReference = host?.renderReference ?? null;
|
|
2767
|
+
const MessageChrome = host?.wrapMessage ?? null;
|
|
2724
2768
|
if (message.deletedAt !== null) {
|
|
2725
2769
|
return /* @__PURE__ */ jsx4("div", { className: "mx-msg__bubble mx-msg__bubble--deleted", children: "Message deleted" });
|
|
2726
2770
|
}
|
|
@@ -2731,10 +2775,16 @@ function MessageBubble(props) {
|
|
|
2731
2775
|
message.deliveryState === "sending" ? "mx-msg__bubble--pending" : "",
|
|
2732
2776
|
message.deliveryState === "failed" ? "mx-msg__bubble--failed" : ""
|
|
2733
2777
|
].filter(Boolean).join(" ");
|
|
2734
|
-
|
|
2778
|
+
const bubble = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
2735
2779
|
/* @__PURE__ */ jsxs2("div", { className: classes, children: [
|
|
2736
2780
|
splitText(message.content).map(
|
|
2737
|
-
(segment, index) => segment.type === "text" ? /* @__PURE__ */ jsx4("span", { children: segment.value }, index) : /* @__PURE__ */ jsx4(
|
|
2781
|
+
(segment, index) => segment.type === "text" ? /* @__PURE__ */ jsx4("span", { children: segment.value }, index) : HostReference !== null ? /* @__PURE__ */ jsx4(
|
|
2782
|
+
HostReference,
|
|
2783
|
+
{
|
|
2784
|
+
reference: segment.reference
|
|
2785
|
+
},
|
|
2786
|
+
`${segment.reference.entityType}:${segment.reference.entityId}`
|
|
2787
|
+
) : /* @__PURE__ */ jsx4(
|
|
2738
2788
|
ReferenceCard,
|
|
2739
2789
|
{
|
|
2740
2790
|
reference: segment.reference,
|
|
@@ -2743,14 +2793,22 @@ function MessageBubble(props) {
|
|
|
2743
2793
|
`${segment.reference.entityType}:${segment.reference.entityId}`
|
|
2744
2794
|
)
|
|
2745
2795
|
),
|
|
2746
|
-
message.references.map(
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2796
|
+
message.references.map(
|
|
2797
|
+
(reference) => HostReference !== null ? /* @__PURE__ */ jsx4(
|
|
2798
|
+
HostReference,
|
|
2799
|
+
{
|
|
2800
|
+
reference
|
|
2801
|
+
},
|
|
2802
|
+
`structured:${reference.entityType}:${reference.entityId}`
|
|
2803
|
+
) : /* @__PURE__ */ jsx4(
|
|
2804
|
+
ReferenceCard,
|
|
2805
|
+
{
|
|
2806
|
+
reference,
|
|
2807
|
+
onOpen: host?.openReference ?? null
|
|
2808
|
+
},
|
|
2809
|
+
`structured:${reference.entityType}:${reference.entityId}`
|
|
2810
|
+
)
|
|
2811
|
+
),
|
|
2754
2812
|
message.action !== null ? /* @__PURE__ */ jsx4(MessageActionChips, { message }) : null
|
|
2755
2813
|
] }),
|
|
2756
2814
|
/* @__PURE__ */ jsxs2(
|
|
@@ -2786,9 +2844,25 @@ function MessageBubble(props) {
|
|
|
2786
2844
|
}
|
|
2787
2845
|
)
|
|
2788
2846
|
] });
|
|
2847
|
+
return MessageChrome !== null ? /* @__PURE__ */ jsx4(MessageChrome, { message, isMine, children: bubble }) : bubble;
|
|
2789
2848
|
}
|
|
2790
2849
|
function MessageActionChips(props) {
|
|
2850
|
+
const host = useRequiredMessagingHost();
|
|
2791
2851
|
const action = useMessageAction(props.message);
|
|
2852
|
+
const declared = props.message.action;
|
|
2853
|
+
const renderer = declared === null ? void 0 : host.actionRenderers.get(declared.kind);
|
|
2854
|
+
if (declared !== null && renderer !== void 0) {
|
|
2855
|
+
if (!renderer.versions.includes(declared.version)) return null;
|
|
2856
|
+
const Render = renderer.render;
|
|
2857
|
+
return /* @__PURE__ */ jsx4(
|
|
2858
|
+
Render,
|
|
2859
|
+
{
|
|
2860
|
+
message: props.message,
|
|
2861
|
+
payload: declared.payload,
|
|
2862
|
+
isOwn: props.message.senderId === host.identity.userId
|
|
2863
|
+
}
|
|
2864
|
+
);
|
|
2865
|
+
}
|
|
2792
2866
|
if (action.receipt !== null) {
|
|
2793
2867
|
return /* @__PURE__ */ jsxs2("span", { className: "mx-msg__receipt", children: [
|
|
2794
2868
|
action.receipt.label,
|