@canonmsg/backend-contracts 1.2.0 → 1.3.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.
@@ -206,9 +206,6 @@ export function appendParticipationHistoryMessage(snapshot, message, limit = PAR
206
206
  export function evaluateParticipationPolicy(policy, input) {
207
207
  const consecutiveAgentTurns = Math.max(input.consecutiveAgentTurns ?? (input.senderType === 'ai_agent' ? 1 : 0), input.senderType === 'ai_agent' ? 1 : 0);
208
208
  const currentAgentStreakStartedByHuman = input.currentAgentStreakStartedByHuman === true;
209
- if (input.isOwner) {
210
- return { allow: true, reason: 'owner messages always pass through' };
211
- }
212
209
  if (input.conversationType === 'group'
213
210
  && policy.participation.requireMentionForGroupReplies
214
211
  && !input.mentionedAgent) {
@@ -217,6 +214,9 @@ export function evaluateParticipationPolicy(policy, input) {
217
214
  reason: 'group replies require a direct mention',
218
215
  };
219
216
  }
217
+ if (input.isOwner) {
218
+ return { allow: true, reason: 'owner messages pass through outside mention-required group turns' };
219
+ }
220
220
  if (input.senderType !== 'ai_agent') {
221
221
  return { allow: true, reason: 'latest sender is human' };
222
222
  }
@@ -216,9 +216,6 @@ function appendParticipationHistoryMessage(snapshot, message, limit = exports.PA
216
216
  function evaluateParticipationPolicy(policy, input) {
217
217
  const consecutiveAgentTurns = Math.max(input.consecutiveAgentTurns ?? (input.senderType === 'ai_agent' ? 1 : 0), input.senderType === 'ai_agent' ? 1 : 0);
218
218
  const currentAgentStreakStartedByHuman = input.currentAgentStreakStartedByHuman === true;
219
- if (input.isOwner) {
220
- return { allow: true, reason: 'owner messages always pass through' };
221
- }
222
219
  if (input.conversationType === 'group'
223
220
  && policy.participation.requireMentionForGroupReplies
224
221
  && !input.mentionedAgent) {
@@ -227,6 +224,9 @@ function evaluateParticipationPolicy(policy, input) {
227
224
  reason: 'group replies require a direct mention',
228
225
  };
229
226
  }
227
+ if (input.isOwner) {
228
+ return { allow: true, reason: 'owner messages pass through outside mention-required group turns' };
229
+ }
230
230
  if (input.senderType !== 'ai_agent') {
231
231
  return { allow: true, reason: 'latest sender is human' };
232
232
  }
package/dist/cjs/media.js CHANGED
@@ -11,6 +11,8 @@ function inferMediaAttachmentKind(mimeType) {
11
11
  return 'image';
12
12
  if (mimeType.startsWith('audio/'))
13
13
  return 'audio';
14
+ if (mimeType.startsWith('video/'))
15
+ return 'video';
14
16
  return 'file';
15
17
  }
16
18
  function getStoredFileExtension(input) {
@@ -26,6 +28,10 @@ function getStoredFileExtension(input) {
26
28
  'audio/mpeg': 'mp3',
27
29
  'audio/webm': 'webm',
28
30
  'audio/ogg': 'ogg',
31
+ 'video/mp4': 'mp4',
32
+ 'video/quicktime': 'mov',
33
+ 'video/webm': 'webm',
34
+ 'video/x-m4v': 'm4v',
29
35
  'application/pdf': 'pdf',
30
36
  'text/plain': 'txt',
31
37
  'application/json': 'json',
@@ -63,6 +69,7 @@ function normalizeStoredAttachments(value) {
63
69
  const candidate = item;
64
70
  if (candidate.kind !== 'image'
65
71
  && candidate.kind !== 'audio'
72
+ && candidate.kind !== 'video'
66
73
  && candidate.kind !== 'file') {
67
74
  return null;
68
75
  }
@@ -97,5 +104,7 @@ function describeAttachment(attachment) {
97
104
  return '📷 Image';
98
105
  if (attachment.kind === 'audio')
99
106
  return '🎤 Voice message';
107
+ if (attachment.kind === 'video')
108
+ return '🎬 Video';
100
109
  return attachment.fileName ? `📎 ${attachment.fileName}` : '📎 File';
101
110
  }
@@ -59,6 +59,7 @@ function normalizeContentType(value) {
59
59
  if (value === 'text'
60
60
  || value === 'image'
61
61
  || value === 'audio'
62
+ || value === 'video'
62
63
  || value === 'file'
63
64
  || value === 'contact_card') {
64
65
  return value;
package/dist/media.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type MediaAttachmentKind = 'image' | 'audio' | 'file';
1
+ export type MediaAttachmentKind = 'image' | 'audio' | 'video' | 'file';
2
2
  export interface MediaAttachment {
3
3
  kind: MediaAttachmentKind;
4
4
  url: string;
package/dist/media.js CHANGED
@@ -3,6 +3,8 @@ export function inferMediaAttachmentKind(mimeType) {
3
3
  return 'image';
4
4
  if (mimeType.startsWith('audio/'))
5
5
  return 'audio';
6
+ if (mimeType.startsWith('video/'))
7
+ return 'video';
6
8
  return 'file';
7
9
  }
8
10
  export function getStoredFileExtension(input) {
@@ -18,6 +20,10 @@ export function getStoredFileExtension(input) {
18
20
  'audio/mpeg': 'mp3',
19
21
  'audio/webm': 'webm',
20
22
  'audio/ogg': 'ogg',
23
+ 'video/mp4': 'mp4',
24
+ 'video/quicktime': 'mov',
25
+ 'video/webm': 'webm',
26
+ 'video/x-m4v': 'm4v',
21
27
  'application/pdf': 'pdf',
22
28
  'text/plain': 'txt',
23
29
  'application/json': 'json',
@@ -55,6 +61,7 @@ export function normalizeStoredAttachments(value) {
55
61
  const candidate = item;
56
62
  if (candidate.kind !== 'image'
57
63
  && candidate.kind !== 'audio'
64
+ && candidate.kind !== 'video'
58
65
  && candidate.kind !== 'file') {
59
66
  return null;
60
67
  }
@@ -89,5 +96,7 @@ export function describeAttachment(attachment) {
89
96
  return '📷 Image';
90
97
  if (attachment.kind === 'audio')
91
98
  return '🎤 Voice message';
99
+ if (attachment.kind === 'video')
100
+ return '🎬 Video';
92
101
  return attachment.fileName ? `📎 ${attachment.fileName}` : '📎 File';
93
102
  }
package/dist/message.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MediaAttachment } from './media.js';
2
2
  export type SerializedSenderType = 'human' | 'ai_agent';
3
3
  export type SerializedAgentClientType = 'claude-code' | 'openclaw' | 'codex' | 'hermes' | 'generic';
4
- export type SerializedContentType = 'text' | 'image' | 'audio' | 'file' | 'contact_card';
4
+ export type SerializedContentType = 'text' | 'image' | 'audio' | 'video' | 'file' | 'contact_card';
5
5
  export interface ForwardedFrom {
6
6
  sourceConversationId: string;
7
7
  messageId: string;
package/dist/message.js CHANGED
@@ -56,6 +56,7 @@ function normalizeContentType(value) {
56
56
  if (value === 'text'
57
57
  || value === 'image'
58
58
  || value === 'audio'
59
+ || value === 'video'
59
60
  || value === 'file'
60
61
  || value === 'contact_card') {
61
62
  return value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/backend-contracts",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Canon backend contract helpers shared by Functions and stream-service",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.0.0",
44
44
  "typescript": "~5.7.0",
45
- "vitest": "^3.0.0"
45
+ "vitest": "^4.1.8"
46
46
  },
47
47
  "license": "MIT"
48
48
  }