@canonmsg/backend-contracts 0.2.0 → 0.2.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/dist/cjs/contactRequest.js +8 -0
- package/dist/cjs/message.js +14 -3
- package/dist/contactRequest.d.ts +4 -0
- package/dist/contactRequest.js +8 -0
- package/dist/message.d.ts +2 -1
- package/dist/message.js +14 -3
- package/package.json +1 -1
|
@@ -57,6 +57,11 @@ function serializeContactRequest(requestId, data) {
|
|
|
57
57
|
requesterName: typeof data.requesterName === 'string' ? data.requesterName : 'Unknown',
|
|
58
58
|
requesterAvatarUrl: typeof data.requesterAvatarUrl === 'string' ? data.requesterAvatarUrl : null,
|
|
59
59
|
targetId: data.targetId,
|
|
60
|
+
targetName: typeof data.targetName === 'string' ? data.targetName : null,
|
|
61
|
+
targetAvatarUrl: typeof data.targetAvatarUrl === 'string' ? data.targetAvatarUrl : null,
|
|
62
|
+
targetUserType: data.targetUserType === 'human' || data.targetUserType === 'ai_agent'
|
|
63
|
+
? data.targetUserType
|
|
64
|
+
: null,
|
|
60
65
|
approverId: data.approverId,
|
|
61
66
|
message: typeof data.message === 'string' ? data.message : null,
|
|
62
67
|
status: normalizeStatus(data.status),
|
|
@@ -68,5 +73,8 @@ function serializeContactRequest(requestId, data) {
|
|
|
68
73
|
if (groupContext) {
|
|
69
74
|
payload.groupContext = groupContext;
|
|
70
75
|
}
|
|
76
|
+
if (typeof data.targetOwnerId === 'string' && data.targetOwnerId.length > 0) {
|
|
77
|
+
payload.targetOwnerId = data.targetOwnerId;
|
|
78
|
+
}
|
|
71
79
|
return payload;
|
|
72
80
|
}
|
package/dist/cjs/message.js
CHANGED
|
@@ -30,6 +30,15 @@ function normalizeSenderType(value, fallback) {
|
|
|
30
30
|
return 'ai_agent';
|
|
31
31
|
return 'human';
|
|
32
32
|
}
|
|
33
|
+
function normalizeAgentClientType(value) {
|
|
34
|
+
if (value === 'claude-code'
|
|
35
|
+
|| value === 'openclaw'
|
|
36
|
+
|| value === 'codex'
|
|
37
|
+
|| value === 'generic') {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
33
42
|
function normalizeContentType(value, attachments) {
|
|
34
43
|
if (value === 'text'
|
|
35
44
|
|| value === 'image'
|
|
@@ -69,6 +78,11 @@ function normalizeContactCard(value) {
|
|
|
69
78
|
};
|
|
70
79
|
if (typeof value.about === 'string')
|
|
71
80
|
card.about = value.about;
|
|
81
|
+
const clientType = userType === 'ai_agent'
|
|
82
|
+
? normalizeAgentClientType(value.clientType)
|
|
83
|
+
: undefined;
|
|
84
|
+
if (clientType)
|
|
85
|
+
card.clientType = clientType;
|
|
72
86
|
if (typeof value.isActive === 'boolean')
|
|
73
87
|
card.isActive = value.isActive;
|
|
74
88
|
if (typeof value.ownerId === 'string')
|
|
@@ -108,9 +122,6 @@ function serializeStoredMessage(input) {
|
|
|
108
122
|
if (typeof input.senderName === 'string') {
|
|
109
123
|
result.senderName = input.senderName;
|
|
110
124
|
}
|
|
111
|
-
if (data.workSession !== undefined && data.workSession !== null) {
|
|
112
|
-
result.workSession = data.workSession;
|
|
113
|
-
}
|
|
114
125
|
if (isRecord(data.metadata)) {
|
|
115
126
|
result.metadata = data.metadata;
|
|
116
127
|
}
|
package/dist/contactRequest.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export interface SerializedContactRequest {
|
|
|
5
5
|
requesterName: string;
|
|
6
6
|
requesterAvatarUrl: string | null;
|
|
7
7
|
targetId: string;
|
|
8
|
+
targetName: string | null;
|
|
9
|
+
targetAvatarUrl: string | null;
|
|
10
|
+
targetUserType: 'human' | 'ai_agent' | null;
|
|
11
|
+
targetOwnerId?: string | null;
|
|
8
12
|
approverId: string;
|
|
9
13
|
message: string | null;
|
|
10
14
|
status: SerializedContactRequestStatus;
|
package/dist/contactRequest.js
CHANGED
|
@@ -54,6 +54,11 @@ export function serializeContactRequest(requestId, data) {
|
|
|
54
54
|
requesterName: typeof data.requesterName === 'string' ? data.requesterName : 'Unknown',
|
|
55
55
|
requesterAvatarUrl: typeof data.requesterAvatarUrl === 'string' ? data.requesterAvatarUrl : null,
|
|
56
56
|
targetId: data.targetId,
|
|
57
|
+
targetName: typeof data.targetName === 'string' ? data.targetName : null,
|
|
58
|
+
targetAvatarUrl: typeof data.targetAvatarUrl === 'string' ? data.targetAvatarUrl : null,
|
|
59
|
+
targetUserType: data.targetUserType === 'human' || data.targetUserType === 'ai_agent'
|
|
60
|
+
? data.targetUserType
|
|
61
|
+
: null,
|
|
57
62
|
approverId: data.approverId,
|
|
58
63
|
message: typeof data.message === 'string' ? data.message : null,
|
|
59
64
|
status: normalizeStatus(data.status),
|
|
@@ -65,5 +70,8 @@ export function serializeContactRequest(requestId, data) {
|
|
|
65
70
|
if (groupContext) {
|
|
66
71
|
payload.groupContext = groupContext;
|
|
67
72
|
}
|
|
73
|
+
if (typeof data.targetOwnerId === 'string' && data.targetOwnerId.length > 0) {
|
|
74
|
+
payload.targetOwnerId = data.targetOwnerId;
|
|
75
|
+
}
|
|
68
76
|
return payload;
|
|
69
77
|
}
|
package/dist/message.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MediaAttachment } from './media.js';
|
|
2
2
|
export type SerializedSenderType = 'human' | 'ai_agent';
|
|
3
|
+
export type SerializedAgentClientType = 'claude-code' | 'openclaw' | 'codex' | 'generic';
|
|
3
4
|
export type SerializedContentType = 'text' | 'image' | 'audio' | 'file' | 'contact_card';
|
|
4
5
|
export interface ForwardedFrom {
|
|
5
6
|
sourceConversationId: string;
|
|
@@ -10,6 +11,7 @@ export interface SerializedContactCard {
|
|
|
10
11
|
displayName: string;
|
|
11
12
|
avatarUrl: string | null;
|
|
12
13
|
userType: SerializedSenderType;
|
|
14
|
+
clientType?: SerializedAgentClientType;
|
|
13
15
|
about?: string;
|
|
14
16
|
isActive?: boolean;
|
|
15
17
|
ownerId?: string;
|
|
@@ -32,7 +34,6 @@ export interface SerializedMessage {
|
|
|
32
34
|
forwardedFrom?: ForwardedFrom;
|
|
33
35
|
status: 'sent' | 'read';
|
|
34
36
|
createdAt: string;
|
|
35
|
-
workSession?: unknown;
|
|
36
37
|
metadata?: Record<string, unknown>;
|
|
37
38
|
contactCard?: SerializedContactCard;
|
|
38
39
|
}
|
package/dist/message.js
CHANGED
|
@@ -27,6 +27,15 @@ function normalizeSenderType(value, fallback) {
|
|
|
27
27
|
return 'ai_agent';
|
|
28
28
|
return 'human';
|
|
29
29
|
}
|
|
30
|
+
function normalizeAgentClientType(value) {
|
|
31
|
+
if (value === 'claude-code'
|
|
32
|
+
|| value === 'openclaw'
|
|
33
|
+
|| value === 'codex'
|
|
34
|
+
|| value === 'generic') {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
30
39
|
function normalizeContentType(value, attachments) {
|
|
31
40
|
if (value === 'text'
|
|
32
41
|
|| value === 'image'
|
|
@@ -66,6 +75,11 @@ function normalizeContactCard(value) {
|
|
|
66
75
|
};
|
|
67
76
|
if (typeof value.about === 'string')
|
|
68
77
|
card.about = value.about;
|
|
78
|
+
const clientType = userType === 'ai_agent'
|
|
79
|
+
? normalizeAgentClientType(value.clientType)
|
|
80
|
+
: undefined;
|
|
81
|
+
if (clientType)
|
|
82
|
+
card.clientType = clientType;
|
|
69
83
|
if (typeof value.isActive === 'boolean')
|
|
70
84
|
card.isActive = value.isActive;
|
|
71
85
|
if (typeof value.ownerId === 'string')
|
|
@@ -105,9 +119,6 @@ export function serializeStoredMessage(input) {
|
|
|
105
119
|
if (typeof input.senderName === 'string') {
|
|
106
120
|
result.senderName = input.senderName;
|
|
107
121
|
}
|
|
108
|
-
if (data.workSession !== undefined && data.workSession !== null) {
|
|
109
|
-
result.workSession = data.workSession;
|
|
110
|
-
}
|
|
111
122
|
if (isRecord(data.metadata)) {
|
|
112
123
|
result.metadata = data.metadata;
|
|
113
124
|
}
|