@ai-matrx/messaging 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -75,6 +75,7 @@ __export(react_exports, {
75
75
  asOrganizationId: () => asOrganizationId,
76
76
  asUserId: () => asUserId,
77
77
  composeFence: () => composeFence,
78
+ conversationContextVariables: () => conversationContextVariables,
78
79
  conversationTopic: () => conversationTopic,
79
80
  createActionRegistry: () => createActionRegistry,
80
81
  createMemoryOutboxStorage: () => createMemoryOutboxStorage,
@@ -379,6 +380,20 @@ ${JSON.stringify(references, null, 2)}
379
380
  }
380
381
 
381
382
  // src/core/ai.ts
383
+ function conversationContextVariables(context, loadedMessageCount) {
384
+ const values = {
385
+ total_loaded_message_count: loadedMessageCount
386
+ };
387
+ if (context === void 0) return values;
388
+ if (context.conversationType) values.conversation_type = context.conversationType;
389
+ if (context.conversationName) values.conversation_name = context.conversationName;
390
+ if (context.conversationCreatedAt)
391
+ values.conversation_created_at = context.conversationCreatedAt;
392
+ if (typeof context.unreadCount === "number") values.unread_count = context.unreadCount;
393
+ if (typeof context.isMuted === "boolean") values.is_muted = context.isMuted;
394
+ if (context.readerUserId) values.reader_user_id = context.readerUserId;
395
+ return values;
396
+ }
382
397
  function unreadCutoff(messages, unreadCount) {
383
398
  if (unreadCount <= 0) return null;
384
399
  const index = messages.length - unreadCount - 1;
@@ -468,7 +483,8 @@ function createMessagingAi(options) {
468
483
  transcript_message_count: transcript.length,
469
484
  // Honest about the cut, so an agent can say "showing the last 200".
470
485
  transcript_truncated: args.messages.length > transcript.length,
471
- ...args.since != null ? { unread_since: args.since } : {}
486
+ ...args.since != null ? { unread_since: args.since } : {},
487
+ ...conversationContextVariables(args.context, args.messages.length)
472
488
  };
473
489
  }
474
490
  function configured(capability) {
@@ -2738,6 +2754,14 @@ function useMessagingAi(conversationId) {
2738
2754
  conversationId,
2739
2755
  messages: conversation.messages,
2740
2756
  participants: conversation.participants,
2757
+ context: {
2758
+ conversationType: conversation.summary?.conversation.type,
2759
+ conversationName: conversation.summary?.displayName,
2760
+ conversationCreatedAt: conversation.summary?.conversation.createdAt,
2761
+ unreadCount: conversation.summary?.unreadCount,
2762
+ isMuted: conversation.summary?.isMuted,
2763
+ readerUserId: host?.identity.userId || void 0
2764
+ },
2741
2765
  signal: controller.signal,
2742
2766
  // Live progress. Aborted runs stop painting immediately — a cancelled
2743
2767
  // answer must not keep growing on screen.