@ai-matrx/messaging 0.8.0 → 0.10.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
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ComponentType, SVGProps } from 'react';
2
- import { MatrxTransport } from '@ai-matrx/agents/matrx';
2
+ import { MatrxJsonObject, MatrxTransport } from '@ai-matrx/agents/matrx';
3
3
  import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
4
4
 
5
5
  /**
@@ -285,21 +285,47 @@ declare function createActionRegistry(): ActionRegistry;
285
285
  * every conversation it touches. Every call below sends `variables` and either
286
286
  * a short human-shaped `user_input` or none.
287
287
  *
288
- * 🚨 **AGENT DEFINITIONS LIVE IN THE DATABASE.** The package takes agent IDs as
289
- * injected identity. When an id is not configured the capability reports
290
- * `unavailable` WITH the remedy it never silently no-ops, and the UI hides
291
- * the action rather than offering a dead button (no dead ends).
288
+ * 🚨 **AGENT DEFINITIONS LIVE IN THE DATABASE.** The package takes an injected
289
+ * IDENTITY per capability the database agent id and the settings that came
290
+ * with it and nothing else. When an identity is not configured the capability
291
+ * reports `unavailable` WITH the remedy; it never silently no-ops, and the UI
292
+ * hides the action rather than offering a dead button (no dead ends).
293
+ *
294
+ * 🚨 **AN IDENTITY IS BOTH HALVES.** A host that resolves a capability's agent
295
+ * from its own switching layer resolves a PAIR: which agent, and the settings
296
+ * that layer decided for it. Taking only the id silently drops the settings
297
+ * half, so `configOverrides` rides with the id and is sent verbatim as the
298
+ * turn's `config_overrides`.
299
+ *
300
+ * 🚨 **A RUN THE USER WATCHES STREAMS.** Every call takes `onText` and reports
301
+ * the accumulated answer as it arrives. A skeleton that sits until a run
302
+ * finishes is a spinner standing in for an answer; the caller renders the
303
+ * partial text instead.
292
304
  */
293
305
 
294
306
  /**
295
- * Which platform agent backs each capability. Every field is a DATABASE row id
296
- * supplied by the host; an omitted one disables exactly that capability.
307
+ * WHO fulfils one capability, as the host resolved it. Both halves travel
308
+ * together: an id alone is half an answer whenever the host's switching layer
309
+ * also decided settings for the job.
310
+ */
311
+ interface MessagingAgentIdentity {
312
+ /** The DATABASE agent row id. Never a name, never a prompt. */
313
+ readonly agentId: string;
314
+ /**
315
+ * The settings half, in LLMParams shape, sent verbatim as the turn's
316
+ * `config_overrides`. `null`/omitted = the agent's own settings stand.
317
+ */
318
+ readonly configOverrides?: MatrxJsonObject | null | undefined;
319
+ }
320
+ /**
321
+ * Which platform agent backs each capability. Every field is an identity the
322
+ * host injects; an omitted one disables exactly that capability.
297
323
  */
298
324
  interface MessagingAgents {
299
- readonly catchUp?: string | undefined;
300
- readonly summarize?: string | undefined;
301
- readonly actionItems?: string | undefined;
302
- readonly draftReply?: string | undefined;
325
+ readonly catchUp?: MessagingAgentIdentity | undefined;
326
+ readonly summarize?: MessagingAgentIdentity | undefined;
327
+ readonly actionItems?: MessagingAgentIdentity | undefined;
328
+ readonly draftReply?: MessagingAgentIdentity | undefined;
303
329
  }
304
330
  interface MessagingAiOptions {
305
331
  transport: MatrxTransport;
@@ -317,38 +343,44 @@ interface AiResult {
317
343
  readonly text: string;
318
344
  readonly conversationId: string | null;
319
345
  }
346
+ /** What every capability takes: the conversation, and how to watch the run. */
347
+ interface AiCallArgs {
348
+ conversationId: ConversationId;
349
+ messages: readonly Message[];
350
+ participants: readonly UserSummary[];
351
+ signal?: AbortSignal | undefined;
352
+ /** The accumulated answer so far, after every streamed chunk. */
353
+ onText?: ((fullText: string) => void) | undefined;
354
+ }
320
355
  interface MessagingAi {
321
356
  /** Which capabilities this host actually configured. Drives what the UI offers. */
322
357
  available(): readonly AiCapability[];
323
358
  isAvailable(capability: AiCapability): boolean;
324
- catchMeUp(args: {
325
- conversationId: ConversationId;
326
- messages: readonly Message[];
327
- participants: readonly UserSummary[];
359
+ catchMeUp(args: AiCallArgs & {
360
+ /**
361
+ * Exclusive cutoff — only messages after it are sent. `null` means the
362
+ * caller genuinely has no read mark and the whole window applies.
363
+ */
328
364
  since: string | null;
329
- signal?: AbortSignal;
330
365
  }): Promise<AiResult>;
331
- summarize(args: {
332
- conversationId: ConversationId;
333
- messages: readonly Message[];
334
- participants: readonly UserSummary[];
335
- signal?: AbortSignal;
336
- }): Promise<AiResult>;
337
- extractActionItems(args: {
338
- conversationId: ConversationId;
339
- messages: readonly Message[];
340
- participants: readonly UserSummary[];
341
- signal?: AbortSignal;
342
- }): Promise<AiResult>;
343
- draftReply(args: {
344
- conversationId: ConversationId;
345
- messages: readonly Message[];
346
- participants: readonly UserSummary[];
366
+ summarize(args: AiCallArgs): Promise<AiResult>;
367
+ extractActionItems(args: AiCallArgs): Promise<AiResult>;
368
+ draftReply(args: AiCallArgs & {
347
369
  /** What the human asked for, if anything — this IS a human utterance. */
348
370
  instruction?: string | undefined;
349
- signal?: AbortSignal;
350
371
  }): Promise<AiResult>;
351
372
  }
373
+ /**
374
+ * The exclusive cutoff "what did I miss" means, derived from what the store
375
+ * already knows: the message just BEFORE the first unread one. No unread
376
+ * messages, or a loaded window that does not reach back that far, means there
377
+ * is no honest cutoff — the whole window applies, and the caller says so by
378
+ * passing `null` rather than guessing a timestamp.
379
+ *
380
+ * Framework-free on purpose: a Redux or React Native consumer must not have to
381
+ * re-derive what "unread" means.
382
+ */
383
+ declare function unreadCutoff(messages: readonly Message[], unreadCount: number): string | null;
352
384
  declare function createMessagingAi(options: MessagingAiOptions): MessagingAi;
353
385
 
354
386
  /**
@@ -509,12 +541,37 @@ interface SupabaseLike extends SchemaLike {
509
541
  schema(name: string): SchemaLike;
510
542
  }
511
543
  /**
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.
544
+ * 🚨 THE PUBLIC PROP TYPE IS DELIBERATELY SHALLOW.
545
+ *
546
+ * `<MessagingProvider client={supabase}>` must accept the client the host
547
+ * ALREADY HAS a `SupabaseClient<Database>` built from generated types. It did
548
+ * not: checking a fully-typed client against the rich `SupabaseLike` above
549
+ * makes tsc chase PostgREST's schema machinery until it bails with **TS2589,
550
+ * "Type instantiation is excessively deep"**, followed by a page of "not
551
+ * assignable". The first real consumer hit both on the one line the README
552
+ * tells every consumer to write, and the only escape was the cast this
553
+ * package's own header forbids.
554
+ *
555
+ * So the boundary is shallow — method names and arity, results as `unknown` —
556
+ * which a typed client satisfies without the compiler unrolling anything. The
557
+ * RICH shape (`SupabaseLike`) is still the internal contract, and the provider
558
+ * narrows to it ONCE, inside the package. That is the data 0.2.1 lesson applied
559
+ * to a client instead of a JSON column: type a public boundary over `unknown`,
560
+ * never over a strict recursive type the host's generator also produces.
561
+ *
562
+ * `supabase-shape.test.ts` proves BOTH legs at compile time: every call this
563
+ * package makes works on a real client, AND a fully-typed real client is
564
+ * assignable to this type.
516
565
  */
517
- type MessagingSupabaseClient = SupabaseLike & RealtimeClientLike;
566
+ interface MessagingSupabaseClient {
567
+ schema(name: string): unknown;
568
+ from(table: string): unknown;
569
+ rpc(fn: string, args?: Record<string, unknown>): unknown;
570
+ channel(topic: string, params?: unknown): unknown;
571
+ removeChannel(channel: never): unknown;
572
+ }
573
+ /** The internal client contract — what the repository and the manager see. */
574
+ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
518
575
 
519
576
  /**
520
577
  * THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
@@ -583,7 +640,15 @@ declare const RPCS: {
583
640
  */
584
641
  type SessionResolver = () => Promise<unknown>;
585
642
  interface RepositoryOptions {
586
- client: SupabaseLike;
643
+ /**
644
+ * The host's Supabase client. Typed over the SHALLOW public shape for the
645
+ * same reason the provider's prop is (see `supabase-shape.ts`): a fully-typed
646
+ * `SupabaseClient<Database>` checked against the rich contract makes tsc bail
647
+ * with TS2589. A service module builds this repository directly — the
648
+ * framework-free path in the README — so it hits the boundary exactly like
649
+ * the provider does.
650
+ */
651
+ client: MessagingSupabaseClient;
587
652
  identity: MessagingIdentity;
588
653
  /** Called once before a retry when a read fails with a missing session. */
589
654
  resolveSession?: SessionResolver | undefined;
@@ -914,8 +979,14 @@ interface MessagingProviderProps {
914
979
  * the AI actions then do not render at all (never a dead button).
915
980
  */
916
981
  transport?: MatrxTransport | undefined;
917
- /** Which database agent backs each AI capability. */
982
+ /** Which database agent backs each AI capability, with its settings. */
918
983
  agents?: MessagingAgents | undefined;
984
+ /**
985
+ * How much transcript rides an AI call, in messages. The package's 200 is a
986
+ * starting value, not a taste: a host with a knob for it passes the resolved
987
+ * number so an organization can decide.
988
+ */
989
+ maxTranscriptMessages?: number | undefined;
919
990
  /** Handlers for actionable messages. Registered once per handler identity. */
920
991
  actions?: readonly ActionHandler<never>[] | undefined;
921
992
  /**
@@ -1018,6 +1089,14 @@ declare function useOnlineUserIds(conversationId: ConversationId | null): Readon
1018
1089
  interface UseMessagingAiResult {
1019
1090
  available: readonly AiCapability[];
1020
1091
  isRunning: boolean;
1092
+ /**
1093
+ * The answer as it arrives, while `isRunning`. A surface renders THIS, not a
1094
+ * skeleton: a placeholder that sits until a run finishes is a spinner
1095
+ * standing in for an answer. Empty string until the first chunk lands.
1096
+ */
1097
+ partialText: string;
1098
+ /** Which capability is running (or produced `result`). */
1099
+ activeCapability: AiCapability | null;
1021
1100
  result: AiResult | null;
1022
1101
  error: string | null;
1023
1102
  run: (capability: AiCapability, args?: {
@@ -1425,4 +1504,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1425
1504
  /** Serialize picked references into a fence the platform's other readers accept. */
1426
1505
  declare function composeFence(references: readonly MatrxReference[]): string;
1427
1506
 
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 };
1507
+ export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, 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 MessagingAgentIdentity, 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, unreadCutoff, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ComponentType, SVGProps } from 'react';
2
- import { MatrxTransport } from '@ai-matrx/agents/matrx';
2
+ import { MatrxJsonObject, MatrxTransport } from '@ai-matrx/agents/matrx';
3
3
  import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
4
4
 
5
5
  /**
@@ -285,21 +285,47 @@ declare function createActionRegistry(): ActionRegistry;
285
285
  * every conversation it touches. Every call below sends `variables` and either
286
286
  * a short human-shaped `user_input` or none.
287
287
  *
288
- * 🚨 **AGENT DEFINITIONS LIVE IN THE DATABASE.** The package takes agent IDs as
289
- * injected identity. When an id is not configured the capability reports
290
- * `unavailable` WITH the remedy it never silently no-ops, and the UI hides
291
- * the action rather than offering a dead button (no dead ends).
288
+ * 🚨 **AGENT DEFINITIONS LIVE IN THE DATABASE.** The package takes an injected
289
+ * IDENTITY per capability the database agent id and the settings that came
290
+ * with it and nothing else. When an identity is not configured the capability
291
+ * reports `unavailable` WITH the remedy; it never silently no-ops, and the UI
292
+ * hides the action rather than offering a dead button (no dead ends).
293
+ *
294
+ * 🚨 **AN IDENTITY IS BOTH HALVES.** A host that resolves a capability's agent
295
+ * from its own switching layer resolves a PAIR: which agent, and the settings
296
+ * that layer decided for it. Taking only the id silently drops the settings
297
+ * half, so `configOverrides` rides with the id and is sent verbatim as the
298
+ * turn's `config_overrides`.
299
+ *
300
+ * 🚨 **A RUN THE USER WATCHES STREAMS.** Every call takes `onText` and reports
301
+ * the accumulated answer as it arrives. A skeleton that sits until a run
302
+ * finishes is a spinner standing in for an answer; the caller renders the
303
+ * partial text instead.
292
304
  */
293
305
 
294
306
  /**
295
- * Which platform agent backs each capability. Every field is a DATABASE row id
296
- * supplied by the host; an omitted one disables exactly that capability.
307
+ * WHO fulfils one capability, as the host resolved it. Both halves travel
308
+ * together: an id alone is half an answer whenever the host's switching layer
309
+ * also decided settings for the job.
310
+ */
311
+ interface MessagingAgentIdentity {
312
+ /** The DATABASE agent row id. Never a name, never a prompt. */
313
+ readonly agentId: string;
314
+ /**
315
+ * The settings half, in LLMParams shape, sent verbatim as the turn's
316
+ * `config_overrides`. `null`/omitted = the agent's own settings stand.
317
+ */
318
+ readonly configOverrides?: MatrxJsonObject | null | undefined;
319
+ }
320
+ /**
321
+ * Which platform agent backs each capability. Every field is an identity the
322
+ * host injects; an omitted one disables exactly that capability.
297
323
  */
298
324
  interface MessagingAgents {
299
- readonly catchUp?: string | undefined;
300
- readonly summarize?: string | undefined;
301
- readonly actionItems?: string | undefined;
302
- readonly draftReply?: string | undefined;
325
+ readonly catchUp?: MessagingAgentIdentity | undefined;
326
+ readonly summarize?: MessagingAgentIdentity | undefined;
327
+ readonly actionItems?: MessagingAgentIdentity | undefined;
328
+ readonly draftReply?: MessagingAgentIdentity | undefined;
303
329
  }
304
330
  interface MessagingAiOptions {
305
331
  transport: MatrxTransport;
@@ -317,38 +343,44 @@ interface AiResult {
317
343
  readonly text: string;
318
344
  readonly conversationId: string | null;
319
345
  }
346
+ /** What every capability takes: the conversation, and how to watch the run. */
347
+ interface AiCallArgs {
348
+ conversationId: ConversationId;
349
+ messages: readonly Message[];
350
+ participants: readonly UserSummary[];
351
+ signal?: AbortSignal | undefined;
352
+ /** The accumulated answer so far, after every streamed chunk. */
353
+ onText?: ((fullText: string) => void) | undefined;
354
+ }
320
355
  interface MessagingAi {
321
356
  /** Which capabilities this host actually configured. Drives what the UI offers. */
322
357
  available(): readonly AiCapability[];
323
358
  isAvailable(capability: AiCapability): boolean;
324
- catchMeUp(args: {
325
- conversationId: ConversationId;
326
- messages: readonly Message[];
327
- participants: readonly UserSummary[];
359
+ catchMeUp(args: AiCallArgs & {
360
+ /**
361
+ * Exclusive cutoff — only messages after it are sent. `null` means the
362
+ * caller genuinely has no read mark and the whole window applies.
363
+ */
328
364
  since: string | null;
329
- signal?: AbortSignal;
330
365
  }): Promise<AiResult>;
331
- summarize(args: {
332
- conversationId: ConversationId;
333
- messages: readonly Message[];
334
- participants: readonly UserSummary[];
335
- signal?: AbortSignal;
336
- }): Promise<AiResult>;
337
- extractActionItems(args: {
338
- conversationId: ConversationId;
339
- messages: readonly Message[];
340
- participants: readonly UserSummary[];
341
- signal?: AbortSignal;
342
- }): Promise<AiResult>;
343
- draftReply(args: {
344
- conversationId: ConversationId;
345
- messages: readonly Message[];
346
- participants: readonly UserSummary[];
366
+ summarize(args: AiCallArgs): Promise<AiResult>;
367
+ extractActionItems(args: AiCallArgs): Promise<AiResult>;
368
+ draftReply(args: AiCallArgs & {
347
369
  /** What the human asked for, if anything — this IS a human utterance. */
348
370
  instruction?: string | undefined;
349
- signal?: AbortSignal;
350
371
  }): Promise<AiResult>;
351
372
  }
373
+ /**
374
+ * The exclusive cutoff "what did I miss" means, derived from what the store
375
+ * already knows: the message just BEFORE the first unread one. No unread
376
+ * messages, or a loaded window that does not reach back that far, means there
377
+ * is no honest cutoff — the whole window applies, and the caller says so by
378
+ * passing `null` rather than guessing a timestamp.
379
+ *
380
+ * Framework-free on purpose: a Redux or React Native consumer must not have to
381
+ * re-derive what "unread" means.
382
+ */
383
+ declare function unreadCutoff(messages: readonly Message[], unreadCount: number): string | null;
352
384
  declare function createMessagingAi(options: MessagingAiOptions): MessagingAi;
353
385
 
354
386
  /**
@@ -509,12 +541,37 @@ interface SupabaseLike extends SchemaLike {
509
541
  schema(name: string): SchemaLike;
510
542
  }
511
543
  /**
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.
544
+ * 🚨 THE PUBLIC PROP TYPE IS DELIBERATELY SHALLOW.
545
+ *
546
+ * `<MessagingProvider client={supabase}>` must accept the client the host
547
+ * ALREADY HAS a `SupabaseClient<Database>` built from generated types. It did
548
+ * not: checking a fully-typed client against the rich `SupabaseLike` above
549
+ * makes tsc chase PostgREST's schema machinery until it bails with **TS2589,
550
+ * "Type instantiation is excessively deep"**, followed by a page of "not
551
+ * assignable". The first real consumer hit both on the one line the README
552
+ * tells every consumer to write, and the only escape was the cast this
553
+ * package's own header forbids.
554
+ *
555
+ * So the boundary is shallow — method names and arity, results as `unknown` —
556
+ * which a typed client satisfies without the compiler unrolling anything. The
557
+ * RICH shape (`SupabaseLike`) is still the internal contract, and the provider
558
+ * narrows to it ONCE, inside the package. That is the data 0.2.1 lesson applied
559
+ * to a client instead of a JSON column: type a public boundary over `unknown`,
560
+ * never over a strict recursive type the host's generator also produces.
561
+ *
562
+ * `supabase-shape.test.ts` proves BOTH legs at compile time: every call this
563
+ * package makes works on a real client, AND a fully-typed real client is
564
+ * assignable to this type.
516
565
  */
517
- type MessagingSupabaseClient = SupabaseLike & RealtimeClientLike;
566
+ interface MessagingSupabaseClient {
567
+ schema(name: string): unknown;
568
+ from(table: string): unknown;
569
+ rpc(fn: string, args?: Record<string, unknown>): unknown;
570
+ channel(topic: string, params?: unknown): unknown;
571
+ removeChannel(channel: never): unknown;
572
+ }
573
+ /** The internal client contract — what the repository and the manager see. */
574
+ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
518
575
 
519
576
  /**
520
577
  * THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
@@ -583,7 +640,15 @@ declare const RPCS: {
583
640
  */
584
641
  type SessionResolver = () => Promise<unknown>;
585
642
  interface RepositoryOptions {
586
- client: SupabaseLike;
643
+ /**
644
+ * The host's Supabase client. Typed over the SHALLOW public shape for the
645
+ * same reason the provider's prop is (see `supabase-shape.ts`): a fully-typed
646
+ * `SupabaseClient<Database>` checked against the rich contract makes tsc bail
647
+ * with TS2589. A service module builds this repository directly — the
648
+ * framework-free path in the README — so it hits the boundary exactly like
649
+ * the provider does.
650
+ */
651
+ client: MessagingSupabaseClient;
587
652
  identity: MessagingIdentity;
588
653
  /** Called once before a retry when a read fails with a missing session. */
589
654
  resolveSession?: SessionResolver | undefined;
@@ -914,8 +979,14 @@ interface MessagingProviderProps {
914
979
  * the AI actions then do not render at all (never a dead button).
915
980
  */
916
981
  transport?: MatrxTransport | undefined;
917
- /** Which database agent backs each AI capability. */
982
+ /** Which database agent backs each AI capability, with its settings. */
918
983
  agents?: MessagingAgents | undefined;
984
+ /**
985
+ * How much transcript rides an AI call, in messages. The package's 200 is a
986
+ * starting value, not a taste: a host with a knob for it passes the resolved
987
+ * number so an organization can decide.
988
+ */
989
+ maxTranscriptMessages?: number | undefined;
919
990
  /** Handlers for actionable messages. Registered once per handler identity. */
920
991
  actions?: readonly ActionHandler<never>[] | undefined;
921
992
  /**
@@ -1018,6 +1089,14 @@ declare function useOnlineUserIds(conversationId: ConversationId | null): Readon
1018
1089
  interface UseMessagingAiResult {
1019
1090
  available: readonly AiCapability[];
1020
1091
  isRunning: boolean;
1092
+ /**
1093
+ * The answer as it arrives, while `isRunning`. A surface renders THIS, not a
1094
+ * skeleton: a placeholder that sits until a run finishes is a spinner
1095
+ * standing in for an answer. Empty string until the first chunk lands.
1096
+ */
1097
+ partialText: string;
1098
+ /** Which capability is running (or produced `result`). */
1099
+ activeCapability: AiCapability | null;
1021
1100
  result: AiResult | null;
1022
1101
  error: string | null;
1023
1102
  run: (capability: AiCapability, args?: {
@@ -1425,4 +1504,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
1425
1504
  /** Serialize picked references into a fence the platform's other readers accept. */
1426
1505
  declare function composeFence(references: readonly MatrxReference[]): string;
1427
1506
 
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 };
1507
+ export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, 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 MessagingAgentIdentity, 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, unreadCutoff, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists };