@canonmsg/backend-contracts 1.9.0 → 2.0.0

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.
Files changed (198) hide show
  1. package/dist/agentBehaviorPolicy.d.ts +45 -86
  2. package/dist/agentBehaviorPolicy.js +0 -53
  3. package/dist/cjs/agentBehaviorPolicy.js +1 -54
  4. package/dist/cjs/contactRequest.js +0 -30
  5. package/dist/cjs/index.js +0 -8
  6. package/dist/cjs/media.js +0 -13
  7. package/dist/cjs/message.js +0 -64
  8. package/dist/cjs/runtimeCardFields.js +1 -58
  9. package/dist/cjs/turnProtocol.js +1 -41
  10. package/dist/contactRequest.d.ts +23 -42
  11. package/dist/contactRequest.js +0 -29
  12. package/dist/index.d.ts +0 -8
  13. package/dist/index.js +0 -8
  14. package/dist/media.d.ts +11 -24
  15. package/dist/media.js +0 -12
  16. package/dist/message.d.ts +50 -133
  17. package/dist/message.js +1 -64
  18. package/dist/runtimeCardFields.d.ts +39 -112
  19. package/dist/runtimeCardFields.js +0 -57
  20. package/dist/turnProtocol.d.ts +24 -91
  21. package/dist/turnProtocol.js +0 -40
  22. package/package.json +5 -8
  23. package/dist/bridgeLocal.d.ts +0 -1871
  24. package/dist/bridgeLocal.js +0 -744
  25. package/dist/cjs/bridgeLocal.js +0 -747
  26. package/dist/cjs/controlSignals.js +0 -44
  27. package/dist/cjs/endpointRegistry.js +0 -264
  28. package/dist/cjs/hitl.js +0 -171
  29. package/dist/cjs/inboundFrame.js +0 -92
  30. package/dist/cjs/restEndpoints.js +0 -237
  31. package/dist/cjs/sendContextual.js +0 -92
  32. package/dist/cjs/sseEvents.js +0 -281
  33. package/dist/controlSignals.d.ts +0 -55
  34. package/dist/controlSignals.js +0 -41
  35. package/dist/endpointRegistry.d.ts +0 -13
  36. package/dist/endpointRegistry.js +0 -261
  37. package/dist/hitl.d.ts +0 -303
  38. package/dist/hitl.js +0 -168
  39. package/dist/inboundFrame.d.ts +0 -229
  40. package/dist/inboundFrame.js +0 -89
  41. package/dist/restEndpoints.d.ts +0 -531
  42. package/dist/restEndpoints.js +0 -234
  43. package/dist/schemas/agent-behavior-settings-record.schema.json +0 -48
  44. package/dist/schemas/bridge-connection-state-notification.schema.json +0 -19
  45. package/dist/schemas/bridge-get-attachment-params.schema.json +0 -24
  46. package/dist/schemas/bridge-get-attachment-result.schema.json +0 -20
  47. package/dist/schemas/bridge-hello-params.schema.json +0 -42
  48. package/dist/schemas/bridge-hello-result.schema.json +0 -105
  49. package/dist/schemas/bridge-hitl-state.schema.json +0 -38
  50. package/dist/schemas/bridge-ok-result.schema.json +0 -15
  51. package/dist/schemas/bridge-publish-streaming-event-params.schema.json +0 -138
  52. package/dist/schemas/bridge-ready-notification.schema.json +0 -79
  53. package/dist/schemas/bridge-resync-reason.schema.json +0 -9
  54. package/dist/schemas/bridge-resync.schema.json +0 -18
  55. package/dist/schemas/bridge-rpc-error.schema.json +0 -19
  56. package/dist/schemas/bridge-rpc-id.schema.json +0 -12
  57. package/dist/schemas/bridge-rpc-notification.schema.json +0 -20
  58. package/dist/schemas/bridge-rpc-request.schema.json +0 -31
  59. package/dist/schemas/bridge-rpc-response.schema.json +0 -81
  60. package/dist/schemas/bridge-status-result.schema.json +0 -76
  61. package/dist/schemas/bridge-stream-clear-event.schema.json +0 -15
  62. package/dist/schemas/bridge-stream-event.schema.json +0 -112
  63. package/dist/schemas/bridge-stream-final-event.schema.json +0 -19
  64. package/dist/schemas/bridge-stream-text-event.schema.json +0 -31
  65. package/dist/schemas/bridge-stream-thinking-event.schema.json +0 -15
  66. package/dist/schemas/bridge-stream-tool-event.schema.json +0 -36
  67. package/dist/schemas/bridge-upload-media-params.schema.json +0 -28
  68. package/dist/schemas/bridge-upstream-state.schema.json +0 -10
  69. package/dist/schemas/contacts-response.schema.json +0 -52
  70. package/dist/schemas/control-channel-key.schema.json +0 -10
  71. package/dist/schemas/control-primitive-event.schema.json +0 -30
  72. package/dist/schemas/control-primitive-map.schema.json +0 -15
  73. package/dist/schemas/control-session-event.schema.json +0 -26
  74. package/dist/schemas/control-session-node.schema.json +0 -11
  75. package/dist/schemas/control-signal-event.schema.json +0 -35
  76. package/dist/schemas/control-signal-node.schema.json +0 -22
  77. package/dist/schemas/control-signal-type.schema.json +0 -10
  78. package/dist/schemas/conversations-response.schema.json +0 -167
  79. package/dist/schemas/create-contact-request-request.schema.json +0 -17
  80. package/dist/schemas/create-contact-request-response.schema.json +0 -51
  81. package/dist/schemas/create-conversation-request.schema.json +0 -82
  82. package/dist/schemas/create-conversation-response.schema.json +0 -29
  83. package/dist/schemas/delete-message-response.schema.json +0 -11
  84. package/dist/schemas/delivery-intent.schema.json +0 -11
  85. package/dist/schemas/forward-message-request.schema.json +0 -25
  86. package/dist/schemas/forward-message-response.schema.json +0 -35
  87. package/dist/schemas/forwarded-from.schema.json +0 -18
  88. package/dist/schemas/get-messages-query.schema.json +0 -17
  89. package/dist/schemas/hitl-approval-category.schema.json +0 -15
  90. package/dist/schemas/hitl-approval-detail.schema.json +0 -21
  91. package/dist/schemas/hitl-approval-outcome-record.schema.json +0 -33
  92. package/dist/schemas/hitl-approval-reply-record.schema.json +0 -57
  93. package/dist/schemas/hitl-approval-request-record.schema.json +0 -105
  94. package/dist/schemas/hitl-approval-risk.schema.json +0 -11
  95. package/dist/schemas/hitl-card-outcome-record.schema.json +0 -48
  96. package/dist/schemas/hitl-card-reply-record.schema.json +0 -46
  97. package/dist/schemas/hitl-card-request-record.schema.json +0 -73
  98. package/dist/schemas/hitl-input-answers.schema.json +0 -23
  99. package/dist/schemas/hitl-input-kind.schema.json +0 -10
  100. package/dist/schemas/hitl-input-outcome-record.schema.json +0 -46
  101. package/dist/schemas/hitl-input-question.schema.json +0 -54
  102. package/dist/schemas/hitl-input-reply-record.schema.json +0 -44
  103. package/dist/schemas/hitl-input-request-record.schema.json +0 -134
  104. package/dist/schemas/hitl-pending.schema.json +0 -31
  105. package/dist/schemas/hitl-request-accepted.schema.json +0 -18
  106. package/dist/schemas/hitl-request-kind.schema.json +0 -10
  107. package/dist/schemas/hitl-resolution-status.schema.json +0 -10
  108. package/dist/schemas/hitl-resolution.schema.json +0 -38
  109. package/dist/schemas/hitl-session-rule.schema.json +0 -32
  110. package/dist/schemas/inbound-disposition.schema.json +0 -13
  111. package/dist/schemas/inbound-frame-attachment-v1.schema.json +0 -94
  112. package/dist/schemas/inbound-frame-contact-card-v1.schema.json +0 -59
  113. package/dist/schemas/inbound-frame-group-context-v1.schema.json +0 -96
  114. package/dist/schemas/inbound-frame-reply-context-v1.schema.json +0 -261
  115. package/dist/schemas/inbound-frame-shape-v1.schema.json +0 -12
  116. package/dist/schemas/inbound-frame-v1.schema.json +0 -506
  117. package/dist/schemas/mark-read-response.schema.json +0 -11
  118. package/dist/schemas/media-attachment-kind.schema.json +0 -11
  119. package/dist/schemas/media-attachment.schema.json +0 -42
  120. package/dist/schemas/messages-page-response.schema.json +0 -290
  121. package/dist/schemas/participation-decision-input.schema.json +0 -44
  122. package/dist/schemas/participation-history-message.schema.json +0 -23
  123. package/dist/schemas/participation-history-snapshot.schema.json +0 -37
  124. package/dist/schemas/participation-style.schema.json +0 -13
  125. package/dist/schemas/react-request.schema.json +0 -22
  126. package/dist/schemas/react-response.schema.json +0 -35
  127. package/dist/schemas/resolve-admission-request.schema.json +0 -30
  128. package/dist/schemas/resolve-admission-response.schema.json +0 -129
  129. package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +0 -81
  130. package/dist/schemas/rest-contact.schema.json +0 -40
  131. package/dist/schemas/rest-conversation-last-message.schema.json +0 -77
  132. package/dist/schemas/rest-conversation.schema.json +0 -155
  133. package/dist/schemas/rest-message.schema.json +0 -252
  134. package/dist/schemas/rest-ok-response.schema.json +0 -11
  135. package/dist/schemas/rest-session-selection.schema.json +0 -40
  136. package/dist/schemas/runtime-card-field-choice.schema.json +0 -23
  137. package/dist/schemas/runtime-card-field-type.schema.json +0 -17
  138. package/dist/schemas/runtime-card-field.schema.json +0 -180
  139. package/dist/schemas/runtime-card-line-item-column-type.schema.json +0 -12
  140. package/dist/schemas/runtime-card-line-item-column.schema.json +0 -74
  141. package/dist/schemas/send-contextual-deferred-response.schema.json +0 -39
  142. package/dist/schemas/send-contextual-messaged-response.schema.json +0 -42
  143. package/dist/schemas/send-contextual-request.schema.json +0 -103
  144. package/dist/schemas/send-contextual-response.schema.json +0 -105
  145. package/dist/schemas/send-contextual-self-context.schema.json +0 -19
  146. package/dist/schemas/send-contextual-state-response.schema.json +0 -24
  147. package/dist/schemas/send-message-request.schema.json +0 -106
  148. package/dist/schemas/send-message-response.schema.json +0 -14
  149. package/dist/schemas/sender-type.schema.json +0 -9
  150. package/dist/schemas/serialize-message-input.schema.json +0 -29
  151. package/dist/schemas/serialized-agent-client-type.schema.json +0 -12
  152. package/dist/schemas/serialized-contact-card.schema.json +0 -65
  153. package/dist/schemas/serialized-contact-request-status.schema.json +0 -11
  154. package/dist/schemas/serialized-contact-request.schema.json +0 -157
  155. package/dist/schemas/serialized-content-type.schema.json +0 -13
  156. package/dist/schemas/serialized-message.schema.json +0 -249
  157. package/dist/schemas/serialized-reactions.schema.json +0 -14
  158. package/dist/schemas/serialized-sender-type.schema.json +0 -9
  159. package/dist/schemas/set-streaming-request.schema.json +0 -67
  160. package/dist/schemas/set-typing-request.schema.json +0 -25
  161. package/dist/schemas/sse-access-policy.schema.json +0 -10
  162. package/dist/schemas/sse-agent-context-payload.schema.json +0 -57
  163. package/dist/schemas/sse-connected-payload.schema.json +0 -18
  164. package/dist/schemas/sse-contact-payload.schema.json +0 -40
  165. package/dist/schemas/sse-contact-removed-payload.schema.json +0 -14
  166. package/dist/schemas/sse-contact-request-payload.schema.json +0 -157
  167. package/dist/schemas/sse-conversation-updated-payload.schema.json +0 -48
  168. package/dist/schemas/sse-error-payload.schema.json +0 -23
  169. package/dist/schemas/sse-event-envelope.schema.json +0 -40
  170. package/dist/schemas/sse-event-family.schema.json +0 -12
  171. package/dist/schemas/sse-event-type.schema.json +0 -26
  172. package/dist/schemas/sse-heartbeat-payload.schema.json +0 -14
  173. package/dist/schemas/sse-membership-change.schema.json +0 -28
  174. package/dist/schemas/sse-message-created-payload.schema.json +0 -414
  175. package/dist/schemas/sse-message-deleted-payload.schema.json +0 -18
  176. package/dist/schemas/sse-message-updated-payload.schema.json +0 -46
  177. package/dist/schemas/sse-presence-payload.schema.json +0 -21
  178. package/dist/schemas/sse-provenance.schema.json +0 -64
  179. package/dist/schemas/sse-replay-expired-payload.schema.json +0 -21
  180. package/dist/schemas/sse-runtime-control-kind.schema.json +0 -13
  181. package/dist/schemas/sse-runtime-control-payload.schema.json +0 -44
  182. package/dist/schemas/sse-self-context.schema.json +0 -45
  183. package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
  184. package/dist/schemas/sse-typing-payload.schema.json +0 -32
  185. package/dist/schemas/sse-voice-session-event-payload.schema.json +0 -170
  186. package/dist/schemas/sse-voice-session.schema.json +0 -157
  187. package/dist/schemas/trigger-decision.schema.json +0 -27
  188. package/dist/schemas/turn-lifecycle-state.schema.json +0 -14
  189. package/dist/schemas/turn-message-semantics.schema.json +0 -10
  190. package/dist/schemas/turn-metadata.schema.json +0 -56
  191. package/dist/schemas/turn-state-like.schema.json +0 -39
  192. package/dist/schemas/update-disposition-request.schema.json +0 -22
  193. package/dist/schemas/upload-media-request.schema.json +0 -25
  194. package/dist/schemas/upload-media-response.schema.json +0 -55
  195. package/dist/sendContextual.d.ts +0 -114
  196. package/dist/sendContextual.js +0 -89
  197. package/dist/sseEvents.d.ts +0 -474
  198. package/dist/sseEvents.js +0 -278
package/dist/index.js CHANGED
@@ -5,11 +5,3 @@ export * from './runtimeCardStorage.js';
5
5
  export * from './turnProtocol.js';
6
6
  export * from './agentBehaviorPolicy.js';
7
7
  export * from './contactRequest.js';
8
- export * from './sseEvents.js';
9
- export * from './controlSignals.js';
10
- export * from './hitl.js';
11
- export * from './inboundFrame.js';
12
- export * from './restEndpoints.js';
13
- export * from './sendContextual.js';
14
- export * from './bridgeLocal.js';
15
- export * from './endpointRegistry.js';
package/dist/media.d.ts CHANGED
@@ -1,27 +1,14 @@
1
- import { z } from 'zod';
2
- export declare const MediaAttachmentKindSchema: z.ZodEnum<{
3
- file: "file";
4
- image: "image";
5
- audio: "audio";
6
- video: "video";
7
- }>;
8
- export type MediaAttachmentKind = z.infer<typeof MediaAttachmentKindSchema>;
9
- export declare const MediaAttachmentSchema: z.ZodObject<{
10
- kind: z.ZodEnum<{
11
- file: "file";
12
- image: "image";
13
- audio: "audio";
14
- video: "video";
15
- }>;
16
- url: z.ZodString;
17
- mimeType: z.ZodOptional<z.ZodString>;
18
- fileName: z.ZodOptional<z.ZodString>;
19
- sizeBytes: z.ZodOptional<z.ZodNumber>;
20
- width: z.ZodOptional<z.ZodNumber>;
21
- height: z.ZodOptional<z.ZodNumber>;
22
- durationMs: z.ZodOptional<z.ZodNumber>;
23
- }, z.core.$strip>;
24
- export type MediaAttachment = z.infer<typeof MediaAttachmentSchema>;
1
+ export type MediaAttachmentKind = 'image' | 'audio' | 'video' | 'file';
2
+ export interface MediaAttachment {
3
+ kind: MediaAttachmentKind;
4
+ url: string;
5
+ mimeType?: string;
6
+ fileName?: string;
7
+ sizeBytes?: number;
8
+ width?: number;
9
+ height?: number;
10
+ durationMs?: number;
11
+ }
25
12
  export declare function inferMediaAttachmentKind(mimeType: string): MediaAttachmentKind;
26
13
  export declare function getStoredFileExtension(input: {
27
14
  mimeType?: string | null;
package/dist/media.js CHANGED
@@ -1,15 +1,3 @@
1
- import { z } from 'zod';
2
- export const MediaAttachmentKindSchema = z.enum(['image', 'audio', 'video', 'file']);
3
- export const MediaAttachmentSchema = z.object({
4
- kind: MediaAttachmentKindSchema,
5
- url: z.string(),
6
- mimeType: z.string().optional(),
7
- fileName: z.string().optional(),
8
- sizeBytes: z.number().optional(),
9
- width: z.number().optional(),
10
- height: z.number().optional(),
11
- durationMs: z.number().optional(),
12
- });
13
1
  export function inferMediaAttachmentKind(mimeType) {
14
2
  if (mimeType.startsWith('image/'))
15
3
  return 'image';
package/dist/message.d.ts CHANGED
@@ -1,134 +1,51 @@
1
- import { z } from 'zod';
2
- export declare const SerializedSenderTypeSchema: z.ZodEnum<{
3
- human: "human";
4
- ai_agent: "ai_agent";
5
- }>;
6
- export type SerializedSenderType = z.infer<typeof SerializedSenderTypeSchema>;
7
- export declare const SerializedAgentClientTypeSchema: z.ZodEnum<{
8
- "claude-code": "claude-code";
9
- openclaw: "openclaw";
10
- codex: "codex";
11
- hermes: "hermes";
12
- generic: "generic";
13
- }>;
14
- export type SerializedAgentClientType = z.infer<typeof SerializedAgentClientTypeSchema>;
15
- export declare const SerializedContentTypeSchema: z.ZodEnum<{
16
- file: "file";
17
- image: "image";
18
- audio: "audio";
19
- video: "video";
20
- text: "text";
21
- contact_card: "contact_card";
22
- }>;
23
- export type SerializedContentType = z.infer<typeof SerializedContentTypeSchema>;
24
- export declare const ForwardedFromSchema: z.ZodObject<{
25
- sourceConversationId: z.ZodString;
26
- messageId: z.ZodString;
27
- }, z.core.$strip>;
28
- export type ForwardedFrom = z.infer<typeof ForwardedFromSchema>;
29
- export declare const SerializedReactionsSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
30
- export type SerializedReactions = z.infer<typeof SerializedReactionsSchema>;
31
- export declare const SerializedContactCardSchema: z.ZodObject<{
32
- userId: z.ZodString;
33
- canonContactId: z.ZodOptional<z.ZodString>;
34
- displayName: z.ZodString;
35
- avatarUrl: z.ZodNullable<z.ZodString>;
36
- userType: z.ZodEnum<{
37
- human: "human";
38
- ai_agent: "ai_agent";
39
- }>;
40
- clientType: z.ZodOptional<z.ZodEnum<{
41
- "claude-code": "claude-code";
42
- openclaw: "openclaw";
43
- codex: "codex";
44
- hermes: "hermes";
45
- generic: "generic";
46
- }>>;
47
- about: z.ZodOptional<z.ZodString>;
48
- isActive: z.ZodOptional<z.ZodBoolean>;
49
- ownerId: z.ZodOptional<z.ZodString>;
50
- ownerName: z.ZodOptional<z.ZodString>;
51
- lifecycleState: z.ZodOptional<z.ZodString>;
52
- }, z.core.$strip>;
53
- export type SerializedContactCard = z.infer<typeof SerializedContactCardSchema>;
54
- export declare const SerializedMessageSchema: z.ZodObject<{
55
- id: z.ZodString;
56
- senderId: z.ZodString;
57
- senderName: z.ZodOptional<z.ZodString>;
58
- senderType: z.ZodEnum<{
59
- human: "human";
60
- ai_agent: "ai_agent";
61
- }>;
62
- isOwner: z.ZodBoolean;
63
- contentType: z.ZodEnum<{
64
- file: "file";
65
- image: "image";
66
- audio: "audio";
67
- video: "video";
68
- text: "text";
69
- contact_card: "contact_card";
70
- }>;
71
- text: z.ZodNullable<z.ZodString>;
72
- attachments: z.ZodArray<z.ZodObject<{
73
- kind: z.ZodEnum<{
74
- file: "file";
75
- image: "image";
76
- audio: "audio";
77
- video: "video";
78
- }>;
79
- url: z.ZodString;
80
- mimeType: z.ZodOptional<z.ZodString>;
81
- fileName: z.ZodOptional<z.ZodString>;
82
- sizeBytes: z.ZodOptional<z.ZodNumber>;
83
- width: z.ZodOptional<z.ZodNumber>;
84
- height: z.ZodOptional<z.ZodNumber>;
85
- durationMs: z.ZodOptional<z.ZodNumber>;
86
- }, z.core.$strip>>;
87
- mentions: z.ZodArray<z.ZodString>;
88
- replyTo: z.ZodNullable<z.ZodString>;
89
- replyToPosition: z.ZodNullable<z.ZodNumber>;
90
- forwarded: z.ZodOptional<z.ZodBoolean>;
91
- forwardedFrom: z.ZodOptional<z.ZodObject<{
92
- sourceConversationId: z.ZodString;
93
- messageId: z.ZodString;
94
- }, z.core.$strip>>;
95
- status: z.ZodEnum<{
96
- sent: "sent";
97
- read: "read";
98
- }>;
99
- createdAt: z.ZodString;
100
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
101
- contactCard: z.ZodOptional<z.ZodObject<{
102
- userId: z.ZodString;
103
- canonContactId: z.ZodOptional<z.ZodString>;
104
- displayName: z.ZodString;
105
- avatarUrl: z.ZodNullable<z.ZodString>;
106
- userType: z.ZodEnum<{
107
- human: "human";
108
- ai_agent: "ai_agent";
109
- }>;
110
- clientType: z.ZodOptional<z.ZodEnum<{
111
- "claude-code": "claude-code";
112
- openclaw: "openclaw";
113
- codex: "codex";
114
- hermes: "hermes";
115
- generic: "generic";
116
- }>>;
117
- about: z.ZodOptional<z.ZodString>;
118
- isActive: z.ZodOptional<z.ZodBoolean>;
119
- ownerId: z.ZodOptional<z.ZodString>;
120
- ownerName: z.ZodOptional<z.ZodString>;
121
- lifecycleState: z.ZodOptional<z.ZodString>;
122
- }, z.core.$strip>>;
123
- runtimeCard: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
124
- reactions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
125
- }, z.core.$strip>;
126
- export type SerializedMessage = z.infer<typeof SerializedMessageSchema>;
127
- export declare const SerializeMessageInputSchema: z.ZodObject<{
128
- id: z.ZodString;
129
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
130
- senderName: z.ZodOptional<z.ZodString>;
131
- isOwner: z.ZodBoolean;
132
- }, z.core.$strip>;
133
- export type SerializeMessageInput = z.infer<typeof SerializeMessageInputSchema>;
1
+ import { MediaAttachment } from './media.js';
2
+ export type SerializedSenderType = 'human' | 'ai_agent';
3
+ export type SerializedAgentClientType = 'claude-code' | 'openclaw' | 'codex' | 'hermes' | 'generic';
4
+ export type SerializedContentType = 'text' | 'image' | 'audio' | 'video' | 'file' | 'contact_card';
5
+ export interface ForwardedFrom {
6
+ sourceConversationId: string;
7
+ messageId: string;
8
+ }
9
+ export type SerializedReactions = Record<string, string[]>;
10
+ export interface SerializedContactCard {
11
+ userId: string;
12
+ canonContactId?: string;
13
+ displayName: string;
14
+ avatarUrl: string | null;
15
+ userType: SerializedSenderType;
16
+ clientType?: SerializedAgentClientType;
17
+ about?: string;
18
+ isActive?: boolean;
19
+ ownerId?: string;
20
+ ownerName?: string;
21
+ lifecycleState?: string;
22
+ }
23
+ export interface SerializedMessage {
24
+ id: string;
25
+ senderId: string;
26
+ senderName?: string;
27
+ senderType: SerializedSenderType;
28
+ isOwner: boolean;
29
+ contentType: SerializedContentType;
30
+ text: string | null;
31
+ attachments: MediaAttachment[];
32
+ mentions: string[];
33
+ replyTo: string | null;
34
+ replyToPosition: number | null;
35
+ forwarded?: boolean;
36
+ forwardedFrom?: ForwardedFrom;
37
+ status: 'sent' | 'read';
38
+ createdAt: string;
39
+ metadata?: Record<string, unknown>;
40
+ contactCard?: SerializedContactCard;
41
+ /** Durable canon.card.v1 runtime card content, passed through opaquely. */
42
+ runtimeCard?: Record<string, unknown>;
43
+ reactions?: SerializedReactions;
44
+ }
45
+ export interface SerializeMessageInput {
46
+ id: string;
47
+ data: Record<string, unknown>;
48
+ senderName?: string;
49
+ isOwner: boolean;
50
+ }
134
51
  export declare function serializeStoredMessage(input: SerializeMessageInput): SerializedMessage;
package/dist/message.js CHANGED
@@ -1,68 +1,5 @@
1
- import { z } from 'zod';
2
- import { MediaAttachmentSchema, normalizeStoredAttachments } from './media.js';
1
+ import { normalizeStoredAttachments } from './media.js';
3
2
  import { decodeStoredRuntimeCard } from './runtimeCardStorage.js';
4
- export const SerializedSenderTypeSchema = z.enum(['human', 'ai_agent']);
5
- export const SerializedAgentClientTypeSchema = z.enum([
6
- 'claude-code',
7
- 'openclaw',
8
- 'codex',
9
- 'hermes',
10
- 'generic',
11
- ]);
12
- export const SerializedContentTypeSchema = z.enum([
13
- 'text',
14
- 'image',
15
- 'audio',
16
- 'video',
17
- 'file',
18
- 'contact_card',
19
- ]);
20
- export const ForwardedFromSchema = z.object({
21
- sourceConversationId: z.string(),
22
- messageId: z.string(),
23
- });
24
- export const SerializedReactionsSchema = z.record(z.string(), z.array(z.string()));
25
- export const SerializedContactCardSchema = z.object({
26
- userId: z.string(),
27
- canonContactId: z.string().optional(),
28
- displayName: z.string(),
29
- avatarUrl: z.string().nullable(),
30
- userType: SerializedSenderTypeSchema,
31
- clientType: SerializedAgentClientTypeSchema.optional(),
32
- about: z.string().optional(),
33
- isActive: z.boolean().optional(),
34
- ownerId: z.string().optional(),
35
- ownerName: z.string().optional(),
36
- lifecycleState: z.string().optional(),
37
- });
38
- export const SerializedMessageSchema = z.object({
39
- id: z.string(),
40
- senderId: z.string(),
41
- senderName: z.string().optional(),
42
- senderType: SerializedSenderTypeSchema,
43
- isOwner: z.boolean(),
44
- contentType: SerializedContentTypeSchema,
45
- text: z.string().nullable(),
46
- attachments: z.array(MediaAttachmentSchema),
47
- mentions: z.array(z.string()),
48
- replyTo: z.string().nullable(),
49
- replyToPosition: z.number().nullable(),
50
- forwarded: z.boolean().optional(),
51
- forwardedFrom: ForwardedFromSchema.optional(),
52
- status: z.enum(['sent', 'read']),
53
- createdAt: z.string(),
54
- metadata: z.record(z.string(), z.unknown()).optional(),
55
- contactCard: SerializedContactCardSchema.optional(),
56
- /** Durable canon.card.v1 runtime card content, passed through opaquely. */
57
- runtimeCard: z.record(z.string(), z.unknown()).optional(),
58
- reactions: SerializedReactionsSchema.optional(),
59
- });
60
- export const SerializeMessageInputSchema = z.object({
61
- id: z.string(),
62
- data: z.record(z.string(), z.unknown()),
63
- senderName: z.string().optional(),
64
- isOwner: z.boolean(),
65
- });
66
3
  function isRecord(value) {
67
4
  return typeof value === 'object' && value !== null && !Array.isArray(value);
68
5
  }
@@ -1,17 +1,4 @@
1
- import { z } from 'zod';
2
- export declare const RuntimeCardFieldTypeSchema: z.ZodEnum<{
3
- number: "number";
4
- boolean: "boolean";
5
- date: "date";
6
- text: "text";
7
- textarea: "textarea";
8
- select: "select";
9
- multiSelect: "multiSelect";
10
- currency: "currency";
11
- searchSelect: "searchSelect";
12
- lineItems: "lineItems";
13
- }>;
14
- export type RuntimeCardFieldType = z.infer<typeof RuntimeCardFieldTypeSchema>;
1
+ export type RuntimeCardFieldType = 'text' | 'textarea' | 'select' | 'multiSelect' | 'boolean' | 'date' | 'number' | 'currency' | 'searchSelect' | 'lineItems';
15
2
  /**
16
3
  * Caps shared across runtime-card normalizers, response validation, and
17
4
  * authoring tools. Keep these backend-safe so Functions can import them.
@@ -22,104 +9,44 @@ export declare const RUNTIME_CARD_LIMITS: {
22
9
  readonly lineItemColumns: 8;
23
10
  readonly searchSelectChoices: 100;
24
11
  };
25
- export declare const RuntimeCardFieldChoiceSchema: z.ZodObject<{
26
- label: z.ZodString;
27
- value: z.ZodOptional<z.ZodString>;
28
- description: z.ZodOptional<z.ZodString>;
29
- preview: z.ZodOptional<z.ZodString>;
30
- }, z.core.$strip>;
31
- export type RuntimeCardFieldChoice = z.infer<typeof RuntimeCardFieldChoiceSchema>;
32
- export declare const RuntimeCardLineItemColumnTypeSchema: z.ZodEnum<{
33
- number: "number";
34
- date: "date";
35
- text: "text";
36
- select: "select";
37
- currency: "currency";
38
- }>;
39
- export type RuntimeCardLineItemColumnType = z.infer<typeof RuntimeCardLineItemColumnTypeSchema>;
40
- export declare const RuntimeCardLineItemColumnSchema: z.ZodObject<{
41
- id: z.ZodString;
42
- label: z.ZodString;
43
- type: z.ZodEnum<{
44
- number: "number";
45
- date: "date";
46
- text: "text";
47
- select: "select";
48
- currency: "currency";
49
- }>;
50
- required: z.ZodOptional<z.ZodBoolean>;
51
- choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
52
- label: z.ZodString;
53
- value: z.ZodOptional<z.ZodString>;
54
- description: z.ZodOptional<z.ZodString>;
55
- preview: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strip>>>;
57
- min: z.ZodOptional<z.ZodNumber>;
58
- max: z.ZodOptional<z.ZodNumber>;
59
- step: z.ZodOptional<z.ZodNumber>;
60
- precision: z.ZodOptional<z.ZodNumber>;
61
- currencyCode: z.ZodOptional<z.ZodString>;
62
- allowOther: z.ZodOptional<z.ZodBoolean>;
63
- }, z.core.$strip>;
64
- export type RuntimeCardLineItemColumn = z.infer<typeof RuntimeCardLineItemColumnSchema>;
65
- export declare const RuntimeCardFieldSchema: z.ZodObject<{
66
- id: z.ZodString;
67
- label: z.ZodString;
68
- type: z.ZodEnum<{
69
- number: "number";
70
- boolean: "boolean";
71
- date: "date";
72
- text: "text";
73
- textarea: "textarea";
74
- select: "select";
75
- multiSelect: "multiSelect";
76
- currency: "currency";
77
- searchSelect: "searchSelect";
78
- lineItems: "lineItems";
79
- }>;
80
- required: z.ZodOptional<z.ZodBoolean>;
81
- placeholder: z.ZodOptional<z.ZodString>;
82
- choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
- label: z.ZodString;
84
- value: z.ZodOptional<z.ZodString>;
85
- description: z.ZodOptional<z.ZodString>;
86
- preview: z.ZodOptional<z.ZodString>;
87
- }, z.core.$strip>>>;
88
- allowOther: z.ZodOptional<z.ZodBoolean>;
89
- sensitive: z.ZodOptional<z.ZodBoolean>;
90
- min: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
91
- max: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
92
- step: z.ZodOptional<z.ZodNumber>;
93
- precision: z.ZodOptional<z.ZodNumber>;
94
- currencyCode: z.ZodOptional<z.ZodString>;
95
- columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
- id: z.ZodString;
97
- label: z.ZodString;
98
- type: z.ZodEnum<{
99
- number: "number";
100
- date: "date";
101
- text: "text";
102
- select: "select";
103
- currency: "currency";
104
- }>;
105
- required: z.ZodOptional<z.ZodBoolean>;
106
- choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
107
- label: z.ZodString;
108
- value: z.ZodOptional<z.ZodString>;
109
- description: z.ZodOptional<z.ZodString>;
110
- preview: z.ZodOptional<z.ZodString>;
111
- }, z.core.$strip>>>;
112
- min: z.ZodOptional<z.ZodNumber>;
113
- max: z.ZodOptional<z.ZodNumber>;
114
- step: z.ZodOptional<z.ZodNumber>;
115
- precision: z.ZodOptional<z.ZodNumber>;
116
- currencyCode: z.ZodOptional<z.ZodString>;
117
- allowOther: z.ZodOptional<z.ZodBoolean>;
118
- }, z.core.$strip>>>;
119
- minRows: z.ZodOptional<z.ZodNumber>;
120
- maxRows: z.ZodOptional<z.ZodNumber>;
121
- }, z.core.$strip>;
122
- export type RuntimeCardField = z.infer<typeof RuntimeCardFieldSchema>;
12
+ export interface RuntimeCardFieldChoice {
13
+ label: string;
14
+ value?: string;
15
+ description?: string;
16
+ preview?: string;
17
+ }
18
+ export type RuntimeCardLineItemColumnType = 'text' | 'number' | 'currency' | 'date' | 'select';
19
+ export interface RuntimeCardLineItemColumn {
20
+ id: string;
21
+ label: string;
22
+ type: RuntimeCardLineItemColumnType;
23
+ required?: boolean;
24
+ choices?: RuntimeCardFieldChoice[];
25
+ min?: number;
26
+ max?: number;
27
+ step?: number;
28
+ precision?: number;
29
+ currencyCode?: string;
30
+ allowOther?: boolean;
31
+ }
32
+ export interface RuntimeCardField {
33
+ id: string;
34
+ label: string;
35
+ type: RuntimeCardFieldType;
36
+ required?: boolean;
37
+ placeholder?: string;
38
+ choices?: RuntimeCardFieldChoice[];
39
+ allowOther?: boolean;
40
+ sensitive?: boolean;
41
+ min?: number | string;
42
+ max?: number | string;
43
+ step?: number;
44
+ precision?: number;
45
+ currencyCode?: string;
46
+ columns?: RuntimeCardLineItemColumn[];
47
+ minRows?: number;
48
+ maxRows?: number;
49
+ }
123
50
  export declare function validateRuntimeCardFieldValues(input: {
124
51
  actionId: string | undefined;
125
52
  actionFields: ReadonlyArray<RuntimeCardField> | undefined;
@@ -1,16 +1,3 @@
1
- import { z } from 'zod';
2
- export const RuntimeCardFieldTypeSchema = z.enum([
3
- 'text',
4
- 'textarea',
5
- 'select',
6
- 'multiSelect',
7
- 'boolean',
8
- 'date',
9
- 'number',
10
- 'currency',
11
- 'searchSelect',
12
- 'lineItems',
13
- ]);
14
1
  /**
15
2
  * Caps shared across runtime-card normalizers, response validation, and
16
3
  * authoring tools. Keep these backend-safe so Functions can import them.
@@ -21,50 +8,6 @@ export const RUNTIME_CARD_LIMITS = {
21
8
  lineItemColumns: 8,
22
9
  searchSelectChoices: 100,
23
10
  };
24
- export const RuntimeCardFieldChoiceSchema = z.object({
25
- label: z.string(),
26
- value: z.string().optional(),
27
- description: z.string().optional(),
28
- preview: z.string().optional(),
29
- });
30
- export const RuntimeCardLineItemColumnTypeSchema = z.enum([
31
- 'text',
32
- 'number',
33
- 'currency',
34
- 'date',
35
- 'select',
36
- ]);
37
- export const RuntimeCardLineItemColumnSchema = z.object({
38
- id: z.string(),
39
- label: z.string(),
40
- type: RuntimeCardLineItemColumnTypeSchema,
41
- required: z.boolean().optional(),
42
- choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
43
- min: z.number().optional(),
44
- max: z.number().optional(),
45
- step: z.number().optional(),
46
- precision: z.number().optional(),
47
- currencyCode: z.string().optional(),
48
- allowOther: z.boolean().optional(),
49
- });
50
- export const RuntimeCardFieldSchema = z.object({
51
- id: z.string(),
52
- label: z.string(),
53
- type: RuntimeCardFieldTypeSchema,
54
- required: z.boolean().optional(),
55
- placeholder: z.string().optional(),
56
- choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
57
- allowOther: z.boolean().optional(),
58
- sensitive: z.boolean().optional(),
59
- min: z.union([z.number(), z.string()]).optional(),
60
- max: z.union([z.number(), z.string()]).optional(),
61
- step: z.number().optional(),
62
- precision: z.number().optional(),
63
- currencyCode: z.string().optional(),
64
- columns: z.array(RuntimeCardLineItemColumnSchema).optional(),
65
- minRows: z.number().optional(),
66
- maxRows: z.number().optional(),
67
- });
68
11
  const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
69
12
  function isRecord(value) {
70
13
  return typeof value === 'object' && value !== null && !Array.isArray(value);