@canonmsg/backend-contracts 0.1.0 → 0.2.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/cjs/contactRequest.js +1 -1
- package/dist/cjs/message.js +14 -0
- package/dist/cjs/turnProtocol.js +0 -6
- package/dist/contactRequest.js +1 -1
- package/dist/message.d.ts +2 -0
- package/dist/message.js +14 -0
- package/dist/turnProtocol.js +0 -6
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ function serializeContactRequest(requestId, data) {
|
|
|
33
33
|
if (typeof data.targetId !== 'string' || data.targetId.length === 0) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
-
const kindValue = typeof data.kind === 'string' ? data.kind :
|
|
36
|
+
const kindValue = typeof data.kind === 'string' ? data.kind : null;
|
|
37
37
|
if (kindValue !== 'dm' && kindValue !== 'group_invite') {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
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')
|
package/dist/cjs/turnProtocol.js
CHANGED
|
@@ -73,11 +73,5 @@ function normalizeRuntimeTurnState(value) {
|
|
|
73
73
|
|| value.state === 'interrupted') {
|
|
74
74
|
return { state: value.state };
|
|
75
75
|
}
|
|
76
|
-
if (value.state === 'running') {
|
|
77
|
-
return { state: 'streaming' };
|
|
78
|
-
}
|
|
79
|
-
if (value.state === 'requires_action') {
|
|
80
|
-
return { state: 'waiting_input' };
|
|
81
|
-
}
|
|
82
76
|
return null;
|
|
83
77
|
}
|
package/dist/contactRequest.js
CHANGED
|
@@ -30,7 +30,7 @@ export function serializeContactRequest(requestId, data) {
|
|
|
30
30
|
if (typeof data.targetId !== 'string' || data.targetId.length === 0) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
const kindValue = typeof data.kind === 'string' ? data.kind :
|
|
33
|
+
const kindValue = typeof data.kind === 'string' ? data.kind : null;
|
|
34
34
|
if (kindValue !== 'dm' && kindValue !== 'group_invite') {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
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;
|
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')
|
package/dist/turnProtocol.js
CHANGED
|
@@ -65,11 +65,5 @@ export function normalizeRuntimeTurnState(value) {
|
|
|
65
65
|
|| value.state === 'interrupted') {
|
|
66
66
|
return { state: value.state };
|
|
67
67
|
}
|
|
68
|
-
if (value.state === 'running') {
|
|
69
|
-
return { state: 'streaming' };
|
|
70
|
-
}
|
|
71
|
-
if (value.state === 'requires_action') {
|
|
72
|
-
return { state: 'waiting_input' };
|
|
73
|
-
}
|
|
74
68
|
return null;
|
|
75
69
|
}
|