@canonmsg/backend-contracts 0.2.1 → 0.2.3

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.
@@ -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
  }
@@ -34,6 +34,7 @@ function normalizeAgentClientType(value) {
34
34
  if (value === 'claude-code'
35
35
  || value === 'openclaw'
36
36
  || value === 'codex'
37
+ || value === 'hermes'
37
38
  || value === 'generic') {
38
39
  return value;
39
40
  }
@@ -122,9 +123,6 @@ function serializeStoredMessage(input) {
122
123
  if (typeof input.senderName === 'string') {
123
124
  result.senderName = input.senderName;
124
125
  }
125
- if (data.workSession !== undefined && data.workSession !== null) {
126
- result.workSession = data.workSession;
127
- }
128
126
  if (isRecord(data.metadata)) {
129
127
  result.metadata = data.metadata;
130
128
  }
@@ -9,6 +9,16 @@ exports.normalizeRuntimeTurnState = normalizeRuntimeTurnState;
9
9
  function isRecord(value) {
10
10
  return typeof value === 'object' && value !== null && !Array.isArray(value);
11
11
  }
12
+ function isHiddenRuntimeCardMetadata(metadata) {
13
+ if (!isRecord(metadata) || typeof metadata.type !== 'string')
14
+ return false;
15
+ return metadata.type === 'approval_reply'
16
+ || metadata.type === 'approval_outcome'
17
+ || metadata.type === 'question_reply'
18
+ || metadata.type === 'plan_approval_reply'
19
+ || metadata.type === 'runtime_input_reply'
20
+ || metadata.type === 'runtime_input_outcome';
21
+ }
12
22
  function normalizeTurnMetadata(metadata) {
13
23
  if (!isRecord(metadata))
14
24
  return null;
@@ -48,6 +58,9 @@ function resolveTurnMessageSemantics(input) {
48
58
  return isTurnOpen(input.senderTurnState) ? 'progress' : 'turn_complete';
49
59
  }
50
60
  function shouldPromoteConversationMessage(input) {
61
+ if (isHiddenRuntimeCardMetadata(input.metadata)) {
62
+ return false;
63
+ }
51
64
  return resolveTurnMessageSemantics(input) !== 'progress';
52
65
  }
53
66
  function shouldTriggerAgentTurn(input) {
@@ -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;
@@ -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,6 +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
+ export type SerializedAgentClientType = 'claude-code' | 'openclaw' | 'codex' | 'hermes' | 'generic';
4
4
  export type SerializedContentType = 'text' | 'image' | 'audio' | 'file' | 'contact_card';
5
5
  export interface ForwardedFrom {
6
6
  sourceConversationId: string;
@@ -34,7 +34,6 @@ export interface SerializedMessage {
34
34
  forwardedFrom?: ForwardedFrom;
35
35
  status: 'sent' | 'read';
36
36
  createdAt: string;
37
- workSession?: unknown;
38
37
  metadata?: Record<string, unknown>;
39
38
  contactCard?: SerializedContactCard;
40
39
  }
package/dist/message.js CHANGED
@@ -31,6 +31,7 @@ function normalizeAgentClientType(value) {
31
31
  if (value === 'claude-code'
32
32
  || value === 'openclaw'
33
33
  || value === 'codex'
34
+ || value === 'hermes'
34
35
  || value === 'generic') {
35
36
  return value;
36
37
  }
@@ -119,9 +120,6 @@ export function serializeStoredMessage(input) {
119
120
  if (typeof input.senderName === 'string') {
120
121
  result.senderName = input.senderName;
121
122
  }
122
- if (data.workSession !== undefined && data.workSession !== null) {
123
- result.workSession = data.workSession;
124
- }
125
123
  if (isRecord(data.metadata)) {
126
124
  result.metadata = data.metadata;
127
125
  }
@@ -1,6 +1,16 @@
1
1
  function isRecord(value) {
2
2
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3
3
  }
4
+ function isHiddenRuntimeCardMetadata(metadata) {
5
+ if (!isRecord(metadata) || typeof metadata.type !== 'string')
6
+ return false;
7
+ return metadata.type === 'approval_reply'
8
+ || metadata.type === 'approval_outcome'
9
+ || metadata.type === 'question_reply'
10
+ || metadata.type === 'plan_approval_reply'
11
+ || metadata.type === 'runtime_input_reply'
12
+ || metadata.type === 'runtime_input_outcome';
13
+ }
4
14
  export function normalizeTurnMetadata(metadata) {
5
15
  if (!isRecord(metadata))
6
16
  return null;
@@ -40,6 +50,9 @@ export function resolveTurnMessageSemantics(input) {
40
50
  return isTurnOpen(input.senderTurnState) ? 'progress' : 'turn_complete';
41
51
  }
42
52
  export function shouldPromoteConversationMessage(input) {
53
+ if (isHiddenRuntimeCardMetadata(input.metadata)) {
54
+ return false;
55
+ }
43
56
  return resolveTurnMessageSemantics(input) !== 'progress';
44
57
  }
45
58
  export function shouldTriggerAgentTurn(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/backend-contracts",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Canon backend contract helpers shared by Functions and stream-service",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",