@canonmsg/backend-contracts 1.7.1 → 1.8.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.
Files changed (193) hide show
  1. package/dist/agentBehaviorPolicy.d.ts +86 -45
  2. package/dist/agentBehaviorPolicy.js +53 -0
  3. package/dist/bridgeLocal.d.ts +1729 -0
  4. package/dist/bridgeLocal.js +673 -0
  5. package/dist/cjs/agentBehaviorPolicy.js +54 -1
  6. package/dist/cjs/bridgeLocal.js +676 -0
  7. package/dist/cjs/contactRequest.js +30 -0
  8. package/dist/cjs/controlSignals.js +44 -0
  9. package/dist/cjs/endpointRegistry.js +264 -0
  10. package/dist/cjs/hitl.js +0 -0
  11. package/dist/cjs/inboundFrame.js +92 -0
  12. package/dist/cjs/index.js +8 -0
  13. package/dist/cjs/media.js +13 -0
  14. package/dist/cjs/message.js +64 -0
  15. package/dist/cjs/restEndpoints.js +237 -0
  16. package/dist/cjs/runtimeCardFields.js +58 -1
  17. package/dist/cjs/sendContextual.js +92 -0
  18. package/dist/cjs/sseEvents.js +298 -0
  19. package/dist/cjs/turnProtocol.js +41 -1
  20. package/dist/contactRequest.d.ts +42 -23
  21. package/dist/contactRequest.js +29 -0
  22. package/dist/controlSignals.d.ts +55 -0
  23. package/dist/controlSignals.js +41 -0
  24. package/dist/endpointRegistry.d.ts +13 -0
  25. package/dist/endpointRegistry.js +261 -0
  26. package/dist/hitl.d.ts +303 -0
  27. package/dist/hitl.js +168 -0
  28. package/dist/inboundFrame.d.ts +229 -0
  29. package/dist/inboundFrame.js +89 -0
  30. package/dist/index.d.ts +8 -0
  31. package/dist/index.js +8 -0
  32. package/dist/media.d.ts +24 -11
  33. package/dist/media.js +12 -0
  34. package/dist/message.d.ts +133 -50
  35. package/dist/message.js +64 -1
  36. package/dist/restEndpoints.d.ts +531 -0
  37. package/dist/restEndpoints.js +234 -0
  38. package/dist/runtimeCardFields.d.ts +112 -39
  39. package/dist/runtimeCardFields.js +57 -0
  40. package/dist/schemas/agent-behavior-settings-record.schema.json +48 -0
  41. package/dist/schemas/bridge-connection-state-notification.schema.json +19 -0
  42. package/dist/schemas/bridge-get-attachment-params.schema.json +24 -0
  43. package/dist/schemas/bridge-get-attachment-result.schema.json +20 -0
  44. package/dist/schemas/bridge-hello-params.schema.json +42 -0
  45. package/dist/schemas/bridge-hello-result.schema.json +105 -0
  46. package/dist/schemas/bridge-hitl-state.schema.json +38 -0
  47. package/dist/schemas/bridge-ok-result.schema.json +15 -0
  48. package/dist/schemas/bridge-ready-notification.schema.json +79 -0
  49. package/dist/schemas/bridge-resync-reason.schema.json +9 -0
  50. package/dist/schemas/bridge-resync.schema.json +18 -0
  51. package/dist/schemas/bridge-rpc-error.schema.json +19 -0
  52. package/dist/schemas/bridge-rpc-id.schema.json +12 -0
  53. package/dist/schemas/bridge-rpc-notification.schema.json +20 -0
  54. package/dist/schemas/bridge-rpc-request.schema.json +31 -0
  55. package/dist/schemas/bridge-rpc-response.schema.json +81 -0
  56. package/dist/schemas/bridge-status-result.schema.json +76 -0
  57. package/dist/schemas/bridge-upload-media-params.schema.json +28 -0
  58. package/dist/schemas/bridge-upstream-state.schema.json +10 -0
  59. package/dist/schemas/contacts-response.schema.json +52 -0
  60. package/dist/schemas/control-channel-key.schema.json +10 -0
  61. package/dist/schemas/control-primitive-event.schema.json +30 -0
  62. package/dist/schemas/control-primitive-map.schema.json +15 -0
  63. package/dist/schemas/control-session-event.schema.json +26 -0
  64. package/dist/schemas/control-session-node.schema.json +11 -0
  65. package/dist/schemas/control-signal-event.schema.json +35 -0
  66. package/dist/schemas/control-signal-node.schema.json +22 -0
  67. package/dist/schemas/control-signal-type.schema.json +10 -0
  68. package/dist/schemas/conversations-response.schema.json +167 -0
  69. package/dist/schemas/create-contact-request-request.schema.json +17 -0
  70. package/dist/schemas/create-contact-request-response.schema.json +51 -0
  71. package/dist/schemas/create-conversation-request.schema.json +82 -0
  72. package/dist/schemas/create-conversation-response.schema.json +29 -0
  73. package/dist/schemas/delete-message-response.schema.json +11 -0
  74. package/dist/schemas/delivery-intent.schema.json +11 -0
  75. package/dist/schemas/forward-message-request.schema.json +25 -0
  76. package/dist/schemas/forward-message-response.schema.json +35 -0
  77. package/dist/schemas/forwarded-from.schema.json +18 -0
  78. package/dist/schemas/get-messages-query.schema.json +17 -0
  79. package/dist/schemas/hitl-approval-category.schema.json +15 -0
  80. package/dist/schemas/hitl-approval-detail.schema.json +21 -0
  81. package/dist/schemas/hitl-approval-outcome-record.schema.json +33 -0
  82. package/dist/schemas/hitl-approval-reply-record.schema.json +57 -0
  83. package/dist/schemas/hitl-approval-request-record.schema.json +105 -0
  84. package/dist/schemas/hitl-approval-risk.schema.json +11 -0
  85. package/dist/schemas/hitl-card-outcome-record.schema.json +48 -0
  86. package/dist/schemas/hitl-card-reply-record.schema.json +46 -0
  87. package/dist/schemas/hitl-card-request-record.schema.json +73 -0
  88. package/dist/schemas/hitl-input-answers.schema.json +23 -0
  89. package/dist/schemas/hitl-input-kind.schema.json +10 -0
  90. package/dist/schemas/hitl-input-outcome-record.schema.json +46 -0
  91. package/dist/schemas/hitl-input-question.schema.json +54 -0
  92. package/dist/schemas/hitl-input-reply-record.schema.json +44 -0
  93. package/dist/schemas/hitl-input-request-record.schema.json +134 -0
  94. package/dist/schemas/hitl-pending.schema.json +31 -0
  95. package/dist/schemas/hitl-request-accepted.schema.json +18 -0
  96. package/dist/schemas/hitl-request-kind.schema.json +10 -0
  97. package/dist/schemas/hitl-resolution-status.schema.json +10 -0
  98. package/dist/schemas/hitl-resolution.schema.json +38 -0
  99. package/dist/schemas/hitl-session-rule.schema.json +32 -0
  100. package/dist/schemas/inbound-disposition.schema.json +13 -0
  101. package/dist/schemas/inbound-frame-attachment-v1.schema.json +94 -0
  102. package/dist/schemas/inbound-frame-contact-card-v1.schema.json +59 -0
  103. package/dist/schemas/inbound-frame-group-context-v1.schema.json +96 -0
  104. package/dist/schemas/inbound-frame-reply-context-v1.schema.json +261 -0
  105. package/dist/schemas/inbound-frame-shape-v1.schema.json +12 -0
  106. package/dist/schemas/inbound-frame-v1.schema.json +506 -0
  107. package/dist/schemas/mark-read-response.schema.json +11 -0
  108. package/dist/schemas/media-attachment-kind.schema.json +11 -0
  109. package/dist/schemas/media-attachment.schema.json +42 -0
  110. package/dist/schemas/messages-page-response.schema.json +290 -0
  111. package/dist/schemas/participation-decision-input.schema.json +44 -0
  112. package/dist/schemas/participation-history-message.schema.json +23 -0
  113. package/dist/schemas/participation-history-snapshot.schema.json +37 -0
  114. package/dist/schemas/participation-style.schema.json +13 -0
  115. package/dist/schemas/react-request.schema.json +22 -0
  116. package/dist/schemas/react-response.schema.json +35 -0
  117. package/dist/schemas/resolve-admission-request.schema.json +30 -0
  118. package/dist/schemas/resolve-admission-response.schema.json +129 -0
  119. package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +81 -0
  120. package/dist/schemas/rest-contact.schema.json +40 -0
  121. package/dist/schemas/rest-conversation-last-message.schema.json +77 -0
  122. package/dist/schemas/rest-conversation.schema.json +155 -0
  123. package/dist/schemas/rest-message.schema.json +252 -0
  124. package/dist/schemas/rest-ok-response.schema.json +11 -0
  125. package/dist/schemas/rest-session-selection.schema.json +40 -0
  126. package/dist/schemas/runtime-card-field-choice.schema.json +23 -0
  127. package/dist/schemas/runtime-card-field-type.schema.json +17 -0
  128. package/dist/schemas/runtime-card-field.schema.json +180 -0
  129. package/dist/schemas/runtime-card-line-item-column-type.schema.json +12 -0
  130. package/dist/schemas/runtime-card-line-item-column.schema.json +74 -0
  131. package/dist/schemas/send-contextual-deferred-response.schema.json +39 -0
  132. package/dist/schemas/send-contextual-messaged-response.schema.json +42 -0
  133. package/dist/schemas/send-contextual-request.schema.json +103 -0
  134. package/dist/schemas/send-contextual-response.schema.json +105 -0
  135. package/dist/schemas/send-contextual-self-context.schema.json +19 -0
  136. package/dist/schemas/send-contextual-state-response.schema.json +24 -0
  137. package/dist/schemas/send-message-request.schema.json +106 -0
  138. package/dist/schemas/send-message-response.schema.json +14 -0
  139. package/dist/schemas/sender-type.schema.json +9 -0
  140. package/dist/schemas/serialize-message-input.schema.json +29 -0
  141. package/dist/schemas/serialized-agent-client-type.schema.json +12 -0
  142. package/dist/schemas/serialized-contact-card.schema.json +65 -0
  143. package/dist/schemas/serialized-contact-request-status.schema.json +11 -0
  144. package/dist/schemas/serialized-contact-request.schema.json +157 -0
  145. package/dist/schemas/serialized-content-type.schema.json +13 -0
  146. package/dist/schemas/serialized-message.schema.json +249 -0
  147. package/dist/schemas/serialized-reactions.schema.json +14 -0
  148. package/dist/schemas/serialized-sender-type.schema.json +9 -0
  149. package/dist/schemas/set-streaming-request.schema.json +67 -0
  150. package/dist/schemas/set-typing-request.schema.json +25 -0
  151. package/dist/schemas/sse-access-policy.schema.json +10 -0
  152. package/dist/schemas/sse-agent-context-payload.schema.json +57 -0
  153. package/dist/schemas/sse-connected-payload.schema.json +18 -0
  154. package/dist/schemas/sse-contact-payload.schema.json +40 -0
  155. package/dist/schemas/sse-contact-removed-payload.schema.json +14 -0
  156. package/dist/schemas/sse-contact-request-payload.schema.json +157 -0
  157. package/dist/schemas/sse-conversation-updated-payload.schema.json +48 -0
  158. package/dist/schemas/sse-error-payload.schema.json +23 -0
  159. package/dist/schemas/sse-event-envelope.schema.json +42 -0
  160. package/dist/schemas/sse-event-family.schema.json +12 -0
  161. package/dist/schemas/sse-event-type.schema.json +28 -0
  162. package/dist/schemas/sse-heartbeat-payload.schema.json +14 -0
  163. package/dist/schemas/sse-membership-change.schema.json +28 -0
  164. package/dist/schemas/sse-message-created-payload.schema.json +414 -0
  165. package/dist/schemas/sse-message-deleted-payload.schema.json +18 -0
  166. package/dist/schemas/sse-message-updated-payload.schema.json +46 -0
  167. package/dist/schemas/sse-presence-payload.schema.json +21 -0
  168. package/dist/schemas/sse-provenance.schema.json +64 -0
  169. package/dist/schemas/sse-replay-expired-payload.schema.json +21 -0
  170. package/dist/schemas/sse-runtime-control-kind.schema.json +13 -0
  171. package/dist/schemas/sse-runtime-control-payload.schema.json +44 -0
  172. package/dist/schemas/sse-runtime-updated-payload.schema.json +78 -0
  173. package/dist/schemas/sse-self-context.schema.json +45 -0
  174. package/dist/schemas/sse-turn-dispatch.schema.json +29 -0
  175. package/dist/schemas/sse-turn-updated-payload.schema.json +33 -0
  176. package/dist/schemas/sse-typing-payload.schema.json +32 -0
  177. package/dist/schemas/sse-voice-session-event-payload.schema.json +170 -0
  178. package/dist/schemas/sse-voice-session.schema.json +157 -0
  179. package/dist/schemas/trigger-decision.schema.json +27 -0
  180. package/dist/schemas/turn-lifecycle-state.schema.json +14 -0
  181. package/dist/schemas/turn-message-semantics.schema.json +10 -0
  182. package/dist/schemas/turn-metadata.schema.json +56 -0
  183. package/dist/schemas/turn-state-like.schema.json +39 -0
  184. package/dist/schemas/update-disposition-request.schema.json +22 -0
  185. package/dist/schemas/upload-media-request.schema.json +25 -0
  186. package/dist/schemas/upload-media-response.schema.json +55 -0
  187. package/dist/sendContextual.d.ts +114 -0
  188. package/dist/sendContextual.js +89 -0
  189. package/dist/sseEvents.d.ts +494 -0
  190. package/dist/sseEvents.js +295 -0
  191. package/dist/turnProtocol.d.ts +91 -24
  192. package/dist/turnProtocol.js +40 -0
  193. package/package.json +8 -5
@@ -1,48 +1,89 @@
1
- export type ParticipationStyle = 'natural' | 'collaborative' | 'mention-first' | 'approval-gated' | 'handoff-only' | 'observer';
2
- export interface AgentBehaviorSettingsRecord {
3
- participationStyle?: ParticipationStyle;
4
- allowAgentToAgent?: boolean;
5
- allowLongRunningCollaboration?: boolean;
6
- requireMentionForGroupReplies?: boolean;
7
- maxConsecutiveAgentTurns?: number | null;
8
- instructions?: string | null;
9
- }
10
- export interface ResolvedAgentBehaviorPolicyRecord {
11
- participation: {
12
- style: ParticipationStyle;
13
- allowAgentToAgent: boolean;
14
- allowHumanToAgent: boolean;
15
- allowLongRunningCollaboration: boolean;
16
- requireMentionForGroupReplies: boolean;
17
- maxConsecutiveAgentTurns?: number | null;
18
- };
19
- instructions: string[];
20
- source: {
21
- hasAgentDefault: boolean;
22
- hasConversationOverride: boolean;
23
- };
24
- }
25
- export interface ParticipationDecisionInput {
26
- conversationType: 'direct' | 'group' | 'unknown';
27
- senderType: 'human' | 'ai_agent';
28
- isOwner: boolean;
29
- mentionedAgent: boolean;
30
- recentHumanCount?: number;
31
- consecutiveAgentTurns?: number;
32
- currentAgentStreakStartedByHuman?: boolean;
33
- }
34
- export interface ParticipationHistoryMessage {
35
- senderId: string;
36
- senderType: 'human' | 'ai_agent';
37
- metadata?: unknown;
38
- }
39
- export interface ParticipationHistorySnapshot {
40
- recentSenderTypes: Array<'human' | 'ai_agent'>;
41
- recentHumanCount: number;
42
- recentAgentCount: number;
43
- consecutiveAgentTurns: number;
44
- currentAgentStreakStartedByHuman: boolean;
45
- }
1
+ import { z } from 'zod';
2
+ export declare const ParticipationStyleSchema: z.ZodEnum<{
3
+ natural: "natural";
4
+ collaborative: "collaborative";
5
+ "mention-first": "mention-first";
6
+ "approval-gated": "approval-gated";
7
+ "handoff-only": "handoff-only";
8
+ observer: "observer";
9
+ }>;
10
+ export type ParticipationStyle = z.infer<typeof ParticipationStyleSchema>;
11
+ export declare const AgentBehaviorSettingsRecordSchema: z.ZodObject<{
12
+ participationStyle: z.ZodOptional<z.ZodEnum<{
13
+ natural: "natural";
14
+ collaborative: "collaborative";
15
+ "mention-first": "mention-first";
16
+ "approval-gated": "approval-gated";
17
+ "handoff-only": "handoff-only";
18
+ observer: "observer";
19
+ }>>;
20
+ allowAgentToAgent: z.ZodOptional<z.ZodBoolean>;
21
+ allowLongRunningCollaboration: z.ZodOptional<z.ZodBoolean>;
22
+ requireMentionForGroupReplies: z.ZodOptional<z.ZodBoolean>;
23
+ maxConsecutiveAgentTurns: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
24
+ instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ }, z.core.$strip>;
26
+ export type AgentBehaviorSettingsRecord = z.infer<typeof AgentBehaviorSettingsRecordSchema>;
27
+ export declare const ResolvedAgentBehaviorPolicyRecordSchema: z.ZodObject<{
28
+ participation: z.ZodObject<{
29
+ style: z.ZodEnum<{
30
+ natural: "natural";
31
+ collaborative: "collaborative";
32
+ "mention-first": "mention-first";
33
+ "approval-gated": "approval-gated";
34
+ "handoff-only": "handoff-only";
35
+ observer: "observer";
36
+ }>;
37
+ allowAgentToAgent: z.ZodBoolean;
38
+ allowHumanToAgent: z.ZodBoolean;
39
+ allowLongRunningCollaboration: z.ZodBoolean;
40
+ requireMentionForGroupReplies: z.ZodBoolean;
41
+ maxConsecutiveAgentTurns: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
42
+ }, z.core.$strip>;
43
+ instructions: z.ZodArray<z.ZodString>;
44
+ source: z.ZodObject<{
45
+ hasAgentDefault: z.ZodBoolean;
46
+ hasConversationOverride: z.ZodBoolean;
47
+ }, z.core.$strip>;
48
+ }, z.core.$strip>;
49
+ export type ResolvedAgentBehaviorPolicyRecord = z.infer<typeof ResolvedAgentBehaviorPolicyRecordSchema>;
50
+ export declare const ParticipationDecisionInputSchema: z.ZodObject<{
51
+ conversationType: z.ZodEnum<{
52
+ unknown: "unknown";
53
+ direct: "direct";
54
+ group: "group";
55
+ }>;
56
+ senderType: z.ZodEnum<{
57
+ human: "human";
58
+ ai_agent: "ai_agent";
59
+ }>;
60
+ isOwner: z.ZodBoolean;
61
+ mentionedAgent: z.ZodBoolean;
62
+ recentHumanCount: z.ZodOptional<z.ZodNumber>;
63
+ consecutiveAgentTurns: z.ZodOptional<z.ZodNumber>;
64
+ currentAgentStreakStartedByHuman: z.ZodOptional<z.ZodBoolean>;
65
+ }, z.core.$strip>;
66
+ export type ParticipationDecisionInput = z.infer<typeof ParticipationDecisionInputSchema>;
67
+ export declare const ParticipationHistoryMessageSchema: z.ZodObject<{
68
+ senderId: z.ZodString;
69
+ senderType: z.ZodEnum<{
70
+ human: "human";
71
+ ai_agent: "ai_agent";
72
+ }>;
73
+ metadata: z.ZodOptional<z.ZodUnknown>;
74
+ }, z.core.$strip>;
75
+ export type ParticipationHistoryMessage = z.infer<typeof ParticipationHistoryMessageSchema>;
76
+ export declare const ParticipationHistorySnapshotSchema: z.ZodObject<{
77
+ recentSenderTypes: z.ZodArray<z.ZodEnum<{
78
+ human: "human";
79
+ ai_agent: "ai_agent";
80
+ }>>;
81
+ recentHumanCount: z.ZodNumber;
82
+ recentAgentCount: z.ZodNumber;
83
+ consecutiveAgentTurns: z.ZodNumber;
84
+ currentAgentStreakStartedByHuman: z.ZodBoolean;
85
+ }, z.core.$strip>;
86
+ export type ParticipationHistorySnapshot = z.infer<typeof ParticipationHistorySnapshotSchema>;
46
87
  export declare const PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
47
88
  export declare function parseAgentBehaviorSettings(raw: unknown): AgentBehaviorSettingsRecord;
48
89
  export declare function normalizeStoredAgentBehaviorPolicy(raw: Record<string, unknown> | undefined): AgentBehaviorSettingsRecord | null;
@@ -1,4 +1,57 @@
1
+ import { z } from 'zod';
1
2
  import { resolveTurnMessageSemantics } from './turnProtocol.js';
3
+ export const ParticipationStyleSchema = z.enum([
4
+ 'natural',
5
+ 'collaborative',
6
+ 'mention-first',
7
+ 'approval-gated',
8
+ 'handoff-only',
9
+ 'observer',
10
+ ]);
11
+ export const AgentBehaviorSettingsRecordSchema = z.object({
12
+ participationStyle: ParticipationStyleSchema.optional(),
13
+ allowAgentToAgent: z.boolean().optional(),
14
+ allowLongRunningCollaboration: z.boolean().optional(),
15
+ requireMentionForGroupReplies: z.boolean().optional(),
16
+ maxConsecutiveAgentTurns: z.number().nullable().optional(),
17
+ instructions: z.string().nullable().optional(),
18
+ });
19
+ export const ResolvedAgentBehaviorPolicyRecordSchema = z.object({
20
+ participation: z.object({
21
+ style: ParticipationStyleSchema,
22
+ allowAgentToAgent: z.boolean(),
23
+ allowHumanToAgent: z.boolean(),
24
+ allowLongRunningCollaboration: z.boolean(),
25
+ requireMentionForGroupReplies: z.boolean(),
26
+ maxConsecutiveAgentTurns: z.number().nullable().optional(),
27
+ }),
28
+ instructions: z.array(z.string()),
29
+ source: z.object({
30
+ hasAgentDefault: z.boolean(),
31
+ hasConversationOverride: z.boolean(),
32
+ }),
33
+ });
34
+ export const ParticipationDecisionInputSchema = z.object({
35
+ conversationType: z.enum(['direct', 'group', 'unknown']),
36
+ senderType: z.enum(['human', 'ai_agent']),
37
+ isOwner: z.boolean(),
38
+ mentionedAgent: z.boolean(),
39
+ recentHumanCount: z.number().optional(),
40
+ consecutiveAgentTurns: z.number().optional(),
41
+ currentAgentStreakStartedByHuman: z.boolean().optional(),
42
+ });
43
+ export const ParticipationHistoryMessageSchema = z.object({
44
+ senderId: z.string(),
45
+ senderType: z.enum(['human', 'ai_agent']),
46
+ metadata: z.unknown().optional(),
47
+ });
48
+ export const ParticipationHistorySnapshotSchema = z.object({
49
+ recentSenderTypes: z.array(z.enum(['human', 'ai_agent'])),
50
+ recentHumanCount: z.number(),
51
+ recentAgentCount: z.number(),
52
+ consecutiveAgentTurns: z.number(),
53
+ currentAgentStreakStartedByHuman: z.boolean(),
54
+ });
2
55
  export const PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
3
56
  const VALID_PARTICIPATION_STYLES = new Set([
4
57
  'natural',