@ai-matrx/messaging 0.15.0 → 0.15.2
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 +25 -0
- package/dist/index.cjs +33 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +41 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +24 -1
- package/dist/react.d.ts +24 -1
- package/dist/react.js +41 -4
- package/dist/react.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog — `@ai-matrx/messaging`
|
|
2
2
|
|
|
3
|
+
## 0.15.2
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/messaging/v0.15.1..npm/messaging/v0.15.2 -- apps/shared/messaging`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.15.1
|
|
10
|
+
### Unreleased
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `AiCallArgs.context` (`ConversationAiContext`) and
|
|
15
|
+
`conversationContextVariables()`: the four conversation intelligences now send
|
|
16
|
+
the `messaging.conversation` offered values by name — `conversation_type`,
|
|
17
|
+
`conversation_name`, `conversation_created_at`, `unread_count`, `is_muted`,
|
|
18
|
+
`reader_user_id`, and always `total_loaded_message_count` — beside the
|
|
19
|
+
existing variables, which are unchanged. `useMessagingAi` fills the context
|
|
20
|
+
from the inbox row and the host identity. Absent facts are omitted.
|
|
21
|
+
|
|
22
|
+
### Consumer action
|
|
23
|
+
|
|
24
|
+
- None — optional field. A host calling `createMessagingAi` directly may pass
|
|
25
|
+
`context` to supply the same facts.
|
|
26
|
+
|
|
3
27
|
## 0.15.0
|
|
4
28
|
|
|
5
29
|
### Fixed
|
|
@@ -840,3 +864,4 @@ consumer):
|
|
|
840
864
|
- This package supersedes host code that talks to `communication.dm_*` directly. Anything still
|
|
841
865
|
reading those tables outside the package should be moved onto it or deleted.
|
|
842
866
|
|
|
867
|
+
|
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
asOrganizationId: () => asOrganizationId,
|
|
35
35
|
asUserId: () => asUserId,
|
|
36
36
|
composeFence: () => composeFence,
|
|
37
|
+
conversationContextVariables: () => conversationContextVariables,
|
|
37
38
|
conversationTopic: () => conversationTopic,
|
|
38
39
|
createActionRegistry: () => createActionRegistry,
|
|
39
40
|
createMemoryOutboxStorage: () => createMemoryOutboxStorage,
|
|
@@ -395,6 +396,20 @@ ${JSON.stringify(references, null, 2)}
|
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
// src/core/ai.ts
|
|
399
|
+
function conversationContextVariables(context, loadedMessageCount) {
|
|
400
|
+
const values = {
|
|
401
|
+
total_loaded_message_count: loadedMessageCount
|
|
402
|
+
};
|
|
403
|
+
if (context === void 0) return values;
|
|
404
|
+
if (context.conversationType) values.conversation_type = context.conversationType;
|
|
405
|
+
if (context.conversationName) values.conversation_name = context.conversationName;
|
|
406
|
+
if (context.conversationCreatedAt)
|
|
407
|
+
values.conversation_created_at = context.conversationCreatedAt;
|
|
408
|
+
if (typeof context.unreadCount === "number") values.unread_count = context.unreadCount;
|
|
409
|
+
if (typeof context.isMuted === "boolean") values.is_muted = context.isMuted;
|
|
410
|
+
if (context.readerUserId) values.reader_user_id = context.readerUserId;
|
|
411
|
+
return values;
|
|
412
|
+
}
|
|
398
413
|
function unreadCutoff(messages, unreadCount) {
|
|
399
414
|
if (unreadCount <= 0) return null;
|
|
400
415
|
const index = messages.length - unreadCount - 1;
|
|
@@ -484,7 +499,8 @@ function createMessagingAi(options) {
|
|
|
484
499
|
transcript_message_count: transcript.length,
|
|
485
500
|
// Honest about the cut, so an agent can say "showing the last 200".
|
|
486
501
|
transcript_truncated: args.messages.length > transcript.length,
|
|
487
|
-
...args.since != null ? { unread_since: args.since } : {}
|
|
502
|
+
...args.since != null ? { unread_since: args.since } : {},
|
|
503
|
+
...conversationContextVariables(args.context, args.messages.length)
|
|
488
504
|
};
|
|
489
505
|
}
|
|
490
506
|
function configured(capability) {
|
|
@@ -1963,10 +1979,23 @@ function createMessagingRepository(options) {
|
|
|
1963
1979
|
});
|
|
1964
1980
|
return found;
|
|
1965
1981
|
}
|
|
1982
|
+
const conversationOrganizations = /* @__PURE__ */ new Map();
|
|
1966
1983
|
async function organizationOfExisting(conversationId) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1984
|
+
const known = conversationOrganizations.get(conversationId);
|
|
1985
|
+
if (known !== void 0) return known;
|
|
1986
|
+
const operation = "organizationOfExisting";
|
|
1987
|
+
const { data, error } = await withSessionRetry(
|
|
1988
|
+
operation,
|
|
1989
|
+
async () => db().from(TABLES.conversations).select("organization_id").eq("id", conversationId).single()
|
|
1990
|
+
);
|
|
1991
|
+
if (error !== null) throw normalizeMessagingError(error, operation);
|
|
1992
|
+
const own = data?.["organization_id"];
|
|
1993
|
+
if (typeof own !== "string" || own.length === 0) {
|
|
1994
|
+
throw invalidResponse(operation, `conversation ${conversationId} has no organization`);
|
|
1995
|
+
}
|
|
1996
|
+
const organization = own;
|
|
1997
|
+
conversationOrganizations.set(conversationId, organization);
|
|
1998
|
+
return organization;
|
|
1970
1999
|
}
|
|
1971
2000
|
const repository = {
|
|
1972
2001
|
organizationId: org,
|