@canonmsg/backend-contracts 1.9.0 → 2.1.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.
- package/dist/agentBehaviorPolicy.d.ts +45 -86
- package/dist/agentBehaviorPolicy.js +0 -53
- package/dist/cjs/agentBehaviorPolicy.js +1 -54
- package/dist/cjs/contactRequest.js +0 -30
- package/dist/cjs/diffRedaction.js +73 -0
- package/dist/cjs/index.js +1 -8
- package/dist/cjs/media.js +0 -13
- package/dist/cjs/message.js +44 -65
- package/dist/cjs/runtimeCardFields.js +1 -58
- package/dist/cjs/turnProtocol.js +1 -41
- package/dist/contactRequest.d.ts +23 -42
- package/dist/contactRequest.js +0 -29
- package/dist/diffRedaction.d.ts +6 -0
- package/dist/diffRedaction.js +68 -0
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -8
- package/dist/media.d.ts +11 -24
- package/dist/media.js +0 -12
- package/dist/message.d.ts +79 -132
- package/dist/message.js +45 -65
- package/dist/runtimeCardFields.d.ts +39 -112
- package/dist/runtimeCardFields.js +0 -57
- package/dist/turnProtocol.d.ts +24 -91
- package/dist/turnProtocol.js +0 -40
- package/package.json +5 -8
- package/dist/bridgeLocal.d.ts +0 -1871
- package/dist/bridgeLocal.js +0 -744
- package/dist/cjs/bridgeLocal.js +0 -747
- package/dist/cjs/controlSignals.js +0 -44
- package/dist/cjs/endpointRegistry.js +0 -264
- package/dist/cjs/hitl.js +0 -171
- package/dist/cjs/inboundFrame.js +0 -92
- package/dist/cjs/restEndpoints.js +0 -237
- package/dist/cjs/sendContextual.js +0 -92
- package/dist/cjs/sseEvents.js +0 -281
- package/dist/controlSignals.d.ts +0 -55
- package/dist/controlSignals.js +0 -41
- package/dist/endpointRegistry.d.ts +0 -13
- package/dist/endpointRegistry.js +0 -261
- package/dist/hitl.d.ts +0 -303
- package/dist/hitl.js +0 -168
- package/dist/inboundFrame.d.ts +0 -229
- package/dist/inboundFrame.js +0 -89
- package/dist/restEndpoints.d.ts +0 -531
- package/dist/restEndpoints.js +0 -234
- package/dist/schemas/agent-behavior-settings-record.schema.json +0 -48
- package/dist/schemas/bridge-connection-state-notification.schema.json +0 -19
- package/dist/schemas/bridge-get-attachment-params.schema.json +0 -24
- package/dist/schemas/bridge-get-attachment-result.schema.json +0 -20
- package/dist/schemas/bridge-hello-params.schema.json +0 -42
- package/dist/schemas/bridge-hello-result.schema.json +0 -105
- package/dist/schemas/bridge-hitl-state.schema.json +0 -38
- package/dist/schemas/bridge-ok-result.schema.json +0 -15
- package/dist/schemas/bridge-publish-streaming-event-params.schema.json +0 -138
- package/dist/schemas/bridge-ready-notification.schema.json +0 -79
- package/dist/schemas/bridge-resync-reason.schema.json +0 -9
- package/dist/schemas/bridge-resync.schema.json +0 -18
- package/dist/schemas/bridge-rpc-error.schema.json +0 -19
- package/dist/schemas/bridge-rpc-id.schema.json +0 -12
- package/dist/schemas/bridge-rpc-notification.schema.json +0 -20
- package/dist/schemas/bridge-rpc-request.schema.json +0 -31
- package/dist/schemas/bridge-rpc-response.schema.json +0 -81
- package/dist/schemas/bridge-status-result.schema.json +0 -76
- package/dist/schemas/bridge-stream-clear-event.schema.json +0 -15
- package/dist/schemas/bridge-stream-event.schema.json +0 -112
- package/dist/schemas/bridge-stream-final-event.schema.json +0 -19
- package/dist/schemas/bridge-stream-text-event.schema.json +0 -31
- package/dist/schemas/bridge-stream-thinking-event.schema.json +0 -15
- package/dist/schemas/bridge-stream-tool-event.schema.json +0 -36
- package/dist/schemas/bridge-upload-media-params.schema.json +0 -28
- package/dist/schemas/bridge-upstream-state.schema.json +0 -10
- package/dist/schemas/contacts-response.schema.json +0 -52
- package/dist/schemas/control-channel-key.schema.json +0 -10
- package/dist/schemas/control-primitive-event.schema.json +0 -30
- package/dist/schemas/control-primitive-map.schema.json +0 -15
- package/dist/schemas/control-session-event.schema.json +0 -26
- package/dist/schemas/control-session-node.schema.json +0 -11
- package/dist/schemas/control-signal-event.schema.json +0 -35
- package/dist/schemas/control-signal-node.schema.json +0 -22
- package/dist/schemas/control-signal-type.schema.json +0 -10
- package/dist/schemas/conversations-response.schema.json +0 -167
- package/dist/schemas/create-contact-request-request.schema.json +0 -17
- package/dist/schemas/create-contact-request-response.schema.json +0 -51
- package/dist/schemas/create-conversation-request.schema.json +0 -82
- package/dist/schemas/create-conversation-response.schema.json +0 -29
- package/dist/schemas/delete-message-response.schema.json +0 -11
- package/dist/schemas/delivery-intent.schema.json +0 -11
- package/dist/schemas/forward-message-request.schema.json +0 -25
- package/dist/schemas/forward-message-response.schema.json +0 -35
- package/dist/schemas/forwarded-from.schema.json +0 -18
- package/dist/schemas/get-messages-query.schema.json +0 -17
- package/dist/schemas/hitl-approval-category.schema.json +0 -15
- package/dist/schemas/hitl-approval-detail.schema.json +0 -21
- package/dist/schemas/hitl-approval-outcome-record.schema.json +0 -33
- package/dist/schemas/hitl-approval-reply-record.schema.json +0 -57
- package/dist/schemas/hitl-approval-request-record.schema.json +0 -105
- package/dist/schemas/hitl-approval-risk.schema.json +0 -11
- package/dist/schemas/hitl-card-outcome-record.schema.json +0 -48
- package/dist/schemas/hitl-card-reply-record.schema.json +0 -46
- package/dist/schemas/hitl-card-request-record.schema.json +0 -73
- package/dist/schemas/hitl-input-answers.schema.json +0 -23
- package/dist/schemas/hitl-input-kind.schema.json +0 -10
- package/dist/schemas/hitl-input-outcome-record.schema.json +0 -46
- package/dist/schemas/hitl-input-question.schema.json +0 -54
- package/dist/schemas/hitl-input-reply-record.schema.json +0 -44
- package/dist/schemas/hitl-input-request-record.schema.json +0 -134
- package/dist/schemas/hitl-pending.schema.json +0 -31
- package/dist/schemas/hitl-request-accepted.schema.json +0 -18
- package/dist/schemas/hitl-request-kind.schema.json +0 -10
- package/dist/schemas/hitl-resolution-status.schema.json +0 -10
- package/dist/schemas/hitl-resolution.schema.json +0 -38
- package/dist/schemas/hitl-session-rule.schema.json +0 -32
- package/dist/schemas/inbound-disposition.schema.json +0 -13
- package/dist/schemas/inbound-frame-attachment-v1.schema.json +0 -94
- package/dist/schemas/inbound-frame-contact-card-v1.schema.json +0 -59
- package/dist/schemas/inbound-frame-group-context-v1.schema.json +0 -96
- package/dist/schemas/inbound-frame-reply-context-v1.schema.json +0 -261
- package/dist/schemas/inbound-frame-shape-v1.schema.json +0 -12
- package/dist/schemas/inbound-frame-v1.schema.json +0 -506
- package/dist/schemas/mark-read-response.schema.json +0 -11
- package/dist/schemas/media-attachment-kind.schema.json +0 -11
- package/dist/schemas/media-attachment.schema.json +0 -42
- package/dist/schemas/messages-page-response.schema.json +0 -290
- package/dist/schemas/participation-decision-input.schema.json +0 -44
- package/dist/schemas/participation-history-message.schema.json +0 -23
- package/dist/schemas/participation-history-snapshot.schema.json +0 -37
- package/dist/schemas/participation-style.schema.json +0 -13
- package/dist/schemas/react-request.schema.json +0 -22
- package/dist/schemas/react-response.schema.json +0 -35
- package/dist/schemas/resolve-admission-request.schema.json +0 -30
- package/dist/schemas/resolve-admission-response.schema.json +0 -129
- package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +0 -81
- package/dist/schemas/rest-contact.schema.json +0 -40
- package/dist/schemas/rest-conversation-last-message.schema.json +0 -77
- package/dist/schemas/rest-conversation.schema.json +0 -155
- package/dist/schemas/rest-message.schema.json +0 -252
- package/dist/schemas/rest-ok-response.schema.json +0 -11
- package/dist/schemas/rest-session-selection.schema.json +0 -40
- package/dist/schemas/runtime-card-field-choice.schema.json +0 -23
- package/dist/schemas/runtime-card-field-type.schema.json +0 -17
- package/dist/schemas/runtime-card-field.schema.json +0 -180
- package/dist/schemas/runtime-card-line-item-column-type.schema.json +0 -12
- package/dist/schemas/runtime-card-line-item-column.schema.json +0 -74
- package/dist/schemas/send-contextual-deferred-response.schema.json +0 -39
- package/dist/schemas/send-contextual-messaged-response.schema.json +0 -42
- package/dist/schemas/send-contextual-request.schema.json +0 -103
- package/dist/schemas/send-contextual-response.schema.json +0 -105
- package/dist/schemas/send-contextual-self-context.schema.json +0 -19
- package/dist/schemas/send-contextual-state-response.schema.json +0 -24
- package/dist/schemas/send-message-request.schema.json +0 -106
- package/dist/schemas/send-message-response.schema.json +0 -14
- package/dist/schemas/sender-type.schema.json +0 -9
- package/dist/schemas/serialize-message-input.schema.json +0 -29
- package/dist/schemas/serialized-agent-client-type.schema.json +0 -12
- package/dist/schemas/serialized-contact-card.schema.json +0 -65
- package/dist/schemas/serialized-contact-request-status.schema.json +0 -11
- package/dist/schemas/serialized-contact-request.schema.json +0 -157
- package/dist/schemas/serialized-content-type.schema.json +0 -13
- package/dist/schemas/serialized-message.schema.json +0 -249
- package/dist/schemas/serialized-reactions.schema.json +0 -14
- package/dist/schemas/serialized-sender-type.schema.json +0 -9
- package/dist/schemas/set-streaming-request.schema.json +0 -67
- package/dist/schemas/set-typing-request.schema.json +0 -25
- package/dist/schemas/sse-access-policy.schema.json +0 -10
- package/dist/schemas/sse-agent-context-payload.schema.json +0 -57
- package/dist/schemas/sse-connected-payload.schema.json +0 -18
- package/dist/schemas/sse-contact-payload.schema.json +0 -40
- package/dist/schemas/sse-contact-removed-payload.schema.json +0 -14
- package/dist/schemas/sse-contact-request-payload.schema.json +0 -157
- package/dist/schemas/sse-conversation-updated-payload.schema.json +0 -48
- package/dist/schemas/sse-error-payload.schema.json +0 -23
- package/dist/schemas/sse-event-envelope.schema.json +0 -40
- package/dist/schemas/sse-event-family.schema.json +0 -12
- package/dist/schemas/sse-event-type.schema.json +0 -26
- package/dist/schemas/sse-heartbeat-payload.schema.json +0 -14
- package/dist/schemas/sse-membership-change.schema.json +0 -28
- package/dist/schemas/sse-message-created-payload.schema.json +0 -414
- package/dist/schemas/sse-message-deleted-payload.schema.json +0 -18
- package/dist/schemas/sse-message-updated-payload.schema.json +0 -46
- package/dist/schemas/sse-presence-payload.schema.json +0 -21
- package/dist/schemas/sse-provenance.schema.json +0 -64
- package/dist/schemas/sse-replay-expired-payload.schema.json +0 -21
- package/dist/schemas/sse-runtime-control-kind.schema.json +0 -13
- package/dist/schemas/sse-runtime-control-payload.schema.json +0 -44
- package/dist/schemas/sse-self-context.schema.json +0 -45
- package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
- package/dist/schemas/sse-typing-payload.schema.json +0 -32
- package/dist/schemas/sse-voice-session-event-payload.schema.json +0 -170
- package/dist/schemas/sse-voice-session.schema.json +0 -157
- package/dist/schemas/trigger-decision.schema.json +0 -27
- package/dist/schemas/turn-lifecycle-state.schema.json +0 -14
- package/dist/schemas/turn-message-semantics.schema.json +0 -10
- package/dist/schemas/turn-metadata.schema.json +0 -56
- package/dist/schemas/turn-state-like.schema.json +0 -39
- package/dist/schemas/update-disposition-request.schema.json +0 -22
- package/dist/schemas/upload-media-request.schema.json +0 -25
- package/dist/schemas/upload-media-response.schema.json +0 -55
- package/dist/sendContextual.d.ts +0 -114
- package/dist/sendContextual.js +0 -89
- package/dist/sseEvents.d.ts +0 -474
- package/dist/sseEvents.js +0 -278
|
@@ -1,89 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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>;
|
|
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
|
+
}
|
|
87
46
|
export declare const PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
|
|
88
47
|
export declare function parseAgentBehaviorSettings(raw: unknown): AgentBehaviorSettingsRecord;
|
|
89
48
|
export declare function normalizeStoredAgentBehaviorPolicy(raw: Record<string, unknown> | undefined): AgentBehaviorSettingsRecord | null;
|
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
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
|
-
});
|
|
55
2
|
export const PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
|
|
56
3
|
const VALID_PARTICIPATION_STYLES = new Set([
|
|
57
4
|
'natural',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PARTICIPATION_HISTORY_FETCH_LIMIT =
|
|
3
|
+
exports.PARTICIPATION_HISTORY_FETCH_LIMIT = void 0;
|
|
4
4
|
exports.parseAgentBehaviorSettings = parseAgentBehaviorSettings;
|
|
5
5
|
exports.normalizeStoredAgentBehaviorPolicy = normalizeStoredAgentBehaviorPolicy;
|
|
6
6
|
exports.normalizeAgentBehaviorInstructions = normalizeAgentBehaviorInstructions;
|
|
@@ -8,60 +8,7 @@ exports.resolveAgentBehaviorPolicy = resolveAgentBehaviorPolicy;
|
|
|
8
8
|
exports.buildParticipationHistorySnapshot = buildParticipationHistorySnapshot;
|
|
9
9
|
exports.appendParticipationHistoryMessage = appendParticipationHistoryMessage;
|
|
10
10
|
exports.evaluateParticipationPolicy = evaluateParticipationPolicy;
|
|
11
|
-
const zod_1 = require("zod");
|
|
12
11
|
const turnProtocol_js_1 = require("./turnProtocol.js");
|
|
13
|
-
exports.ParticipationStyleSchema = zod_1.z.enum([
|
|
14
|
-
'natural',
|
|
15
|
-
'collaborative',
|
|
16
|
-
'mention-first',
|
|
17
|
-
'approval-gated',
|
|
18
|
-
'handoff-only',
|
|
19
|
-
'observer',
|
|
20
|
-
]);
|
|
21
|
-
exports.AgentBehaviorSettingsRecordSchema = zod_1.z.object({
|
|
22
|
-
participationStyle: exports.ParticipationStyleSchema.optional(),
|
|
23
|
-
allowAgentToAgent: zod_1.z.boolean().optional(),
|
|
24
|
-
allowLongRunningCollaboration: zod_1.z.boolean().optional(),
|
|
25
|
-
requireMentionForGroupReplies: zod_1.z.boolean().optional(),
|
|
26
|
-
maxConsecutiveAgentTurns: zod_1.z.number().nullable().optional(),
|
|
27
|
-
instructions: zod_1.z.string().nullable().optional(),
|
|
28
|
-
});
|
|
29
|
-
exports.ResolvedAgentBehaviorPolicyRecordSchema = zod_1.z.object({
|
|
30
|
-
participation: zod_1.z.object({
|
|
31
|
-
style: exports.ParticipationStyleSchema,
|
|
32
|
-
allowAgentToAgent: zod_1.z.boolean(),
|
|
33
|
-
allowHumanToAgent: zod_1.z.boolean(),
|
|
34
|
-
allowLongRunningCollaboration: zod_1.z.boolean(),
|
|
35
|
-
requireMentionForGroupReplies: zod_1.z.boolean(),
|
|
36
|
-
maxConsecutiveAgentTurns: zod_1.z.number().nullable().optional(),
|
|
37
|
-
}),
|
|
38
|
-
instructions: zod_1.z.array(zod_1.z.string()),
|
|
39
|
-
source: zod_1.z.object({
|
|
40
|
-
hasAgentDefault: zod_1.z.boolean(),
|
|
41
|
-
hasConversationOverride: zod_1.z.boolean(),
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
exports.ParticipationDecisionInputSchema = zod_1.z.object({
|
|
45
|
-
conversationType: zod_1.z.enum(['direct', 'group', 'unknown']),
|
|
46
|
-
senderType: zod_1.z.enum(['human', 'ai_agent']),
|
|
47
|
-
isOwner: zod_1.z.boolean(),
|
|
48
|
-
mentionedAgent: zod_1.z.boolean(),
|
|
49
|
-
recentHumanCount: zod_1.z.number().optional(),
|
|
50
|
-
consecutiveAgentTurns: zod_1.z.number().optional(),
|
|
51
|
-
currentAgentStreakStartedByHuman: zod_1.z.boolean().optional(),
|
|
52
|
-
});
|
|
53
|
-
exports.ParticipationHistoryMessageSchema = zod_1.z.object({
|
|
54
|
-
senderId: zod_1.z.string(),
|
|
55
|
-
senderType: zod_1.z.enum(['human', 'ai_agent']),
|
|
56
|
-
metadata: zod_1.z.unknown().optional(),
|
|
57
|
-
});
|
|
58
|
-
exports.ParticipationHistorySnapshotSchema = zod_1.z.object({
|
|
59
|
-
recentSenderTypes: zod_1.z.array(zod_1.z.enum(['human', 'ai_agent'])),
|
|
60
|
-
recentHumanCount: zod_1.z.number(),
|
|
61
|
-
recentAgentCount: zod_1.z.number(),
|
|
62
|
-
consecutiveAgentTurns: zod_1.z.number(),
|
|
63
|
-
currentAgentStreakStartedByHuman: zod_1.z.boolean(),
|
|
64
|
-
});
|
|
65
12
|
exports.PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
|
|
66
13
|
const VALID_PARTICIPATION_STYLES = new Set([
|
|
67
14
|
'natural',
|
|
@@ -1,36 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SerializedContactRequestSchema = exports.SerializedContactRequestStatusSchema = void 0;
|
|
4
3
|
exports.serializeContactRequest = serializeContactRequest;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.SerializedContactRequestStatusSchema = zod_1.z.enum([
|
|
7
|
-
'pending',
|
|
8
|
-
'approved',
|
|
9
|
-
'rejected',
|
|
10
|
-
'expired',
|
|
11
|
-
]);
|
|
12
|
-
exports.SerializedContactRequestSchema = zod_1.z.object({
|
|
13
|
-
id: zod_1.z.string(),
|
|
14
|
-
requesterId: zod_1.z.string(),
|
|
15
|
-
requesterName: zod_1.z.string(),
|
|
16
|
-
requesterAvatarUrl: zod_1.z.string().nullable(),
|
|
17
|
-
targetId: zod_1.z.string(),
|
|
18
|
-
targetName: zod_1.z.string(),
|
|
19
|
-
targetAvatarUrl: zod_1.z.string().nullable(),
|
|
20
|
-
targetUserType: zod_1.z.enum(['human', 'ai_agent']),
|
|
21
|
-
targetOwnerId: zod_1.z.string().nullable().optional(),
|
|
22
|
-
approverId: zod_1.z.string(),
|
|
23
|
-
message: zod_1.z.string().nullable(),
|
|
24
|
-
status: exports.SerializedContactRequestStatusSchema,
|
|
25
|
-
kind: zod_1.z.enum(['dm', 'group_invite']),
|
|
26
|
-
groupContext: zod_1.z.object({
|
|
27
|
-
conversationId: zod_1.z.string(),
|
|
28
|
-
groupName: zod_1.z.string().nullable(),
|
|
29
|
-
}).optional(),
|
|
30
|
-
createdAt: zod_1.z.string().nullable(),
|
|
31
|
-
resolvedAt: zod_1.z.string().nullable().optional(),
|
|
32
|
-
expiresAt: zod_1.z.string().nullable().optional(),
|
|
33
|
-
});
|
|
34
4
|
function isRecord(value) {
|
|
35
5
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
36
6
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Sensitive-content protection for approval diffs.
|
|
3
|
+
//
|
|
4
|
+
// Approval diffs include PRE-IMAGE context lines and ride on a message readable
|
|
5
|
+
// by every conversation member, so a secret-bearing file would leak existing
|
|
6
|
+
// secrets. The emitting host applies this before sending (it owns the file
|
|
7
|
+
// context); the server (@canonmsg/functions) mirrors the same suppression
|
|
8
|
+
// defensively. Single-sourced here in the zero-dependency backend-contracts
|
|
9
|
+
// leaf so @canonmsg/core (client-side sanitizer) and Functions (server mirror)
|
|
10
|
+
// share one implementation — Functions deliberately does not depend on core.
|
|
11
|
+
//
|
|
12
|
+
// Two deliberately narrow mechanisms so ordinary code diffs stay readable:
|
|
13
|
+
// 1. Path suppression — files whose path screams "secret store" lose their
|
|
14
|
+
// hunk text entirely; entry/status/counts survive.
|
|
15
|
+
// 2. High-confidence token redaction — prefix-anchored credential shapes
|
|
16
|
+
// (AWS/GitHub/Slack/Google/OpenAI-style keys, JWTs) are replaced with
|
|
17
|
+
// `[redacted]` inside remaining hunks. Private-key blocks suppress the
|
|
18
|
+
// whole file (redacting a PEM body line-by-line is fragile).
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PRIVATE_KEY_BLOCK = void 0;
|
|
21
|
+
exports.isSensitiveDiffPath = isSensitiveDiffPath;
|
|
22
|
+
exports.redactSecretTokens = redactSecretTokens;
|
|
23
|
+
const SENSITIVE_DIFF_BASENAME_PATTERNS = [
|
|
24
|
+
/^\.env(\..+)?$/i,
|
|
25
|
+
/^\.npmrc$/i,
|
|
26
|
+
/^\.netrc$/i,
|
|
27
|
+
/^\.pgpass$/i,
|
|
28
|
+
/^\.git-credentials$/i,
|
|
29
|
+
/^\.htpasswd$/i,
|
|
30
|
+
/\.(pem|key|p12|pfx|keystore|jks|tfvars)$/i,
|
|
31
|
+
/^id_(rsa|dsa|ecdsa|ed25519)(\..+)?$/i,
|
|
32
|
+
// Word-bounded so "secrets.json" and "client_secret.yaml" match but
|
|
33
|
+
// "secretary.ts" does not.
|
|
34
|
+
/(^|[-_.])(credentials?|secrets?)([-_.]|$)/i,
|
|
35
|
+
/^serviceaccount.*\.json$/i,
|
|
36
|
+
/^kubeconfig(\..+)?$/i,
|
|
37
|
+
];
|
|
38
|
+
// Directory components that mark everything beneath them sensitive
|
|
39
|
+
// (~/.ssh/config, .aws/credentials, infra/secrets/db.yaml, …).
|
|
40
|
+
const SENSITIVE_DIFF_SEGMENT_PATTERNS = [
|
|
41
|
+
/^\.ssh$/i,
|
|
42
|
+
/^\.aws$/i,
|
|
43
|
+
/^\.gnupg$/i,
|
|
44
|
+
/^\.kube$/i,
|
|
45
|
+
/^secrets?$/i,
|
|
46
|
+
/^credentials?$/i,
|
|
47
|
+
];
|
|
48
|
+
const SECRET_TOKEN_PATTERNS = [
|
|
49
|
+
/AKIA[0-9A-Z]{16}/g,
|
|
50
|
+
/gh[pousr]_[A-Za-z0-9]{36,255}/g,
|
|
51
|
+
/github_pat_[A-Za-z0-9_]{22,255}/g,
|
|
52
|
+
/xox[baprs]-[A-Za-z0-9-]{10,250}/g,
|
|
53
|
+
/AIza[0-9A-Za-z_-]{35}/g,
|
|
54
|
+
/sk-[A-Za-z0-9_-]{20,250}/g,
|
|
55
|
+
/eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
|
|
56
|
+
];
|
|
57
|
+
/** Matches the header line of a PEM private-key block. */
|
|
58
|
+
exports.PRIVATE_KEY_BLOCK = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY( BLOCK)?-----/;
|
|
59
|
+
/** True when a diff file path (or rename source) matches the sensitive list. */
|
|
60
|
+
function isSensitiveDiffPath(path) {
|
|
61
|
+
const segments = path.split('/').filter(Boolean);
|
|
62
|
+
const basename = segments.pop() ?? path;
|
|
63
|
+
return SENSITIVE_DIFF_BASENAME_PATTERNS.some((pattern) => pattern.test(basename))
|
|
64
|
+
|| segments.some((segment) => SENSITIVE_DIFF_SEGMENT_PATTERNS.some((pattern) => pattern.test(segment)));
|
|
65
|
+
}
|
|
66
|
+
/** Replace high-confidence credential shapes inside hunk text with `[redacted]`. */
|
|
67
|
+
function redactSecretTokens(text) {
|
|
68
|
+
let redacted = text;
|
|
69
|
+
for (const pattern of SECRET_TOKEN_PATTERNS) {
|
|
70
|
+
redacted = redacted.replace(pattern, '[redacted]');
|
|
71
|
+
}
|
|
72
|
+
return redacted;
|
|
73
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./diffRedaction.js"), exports);
|
|
17
18
|
__exportStar(require("./media.js"), exports);
|
|
18
19
|
__exportStar(require("./message.js"), exports);
|
|
19
20
|
__exportStar(require("./runtimeCardFields.js"), exports);
|
|
@@ -21,11 +22,3 @@ __exportStar(require("./runtimeCardStorage.js"), exports);
|
|
|
21
22
|
__exportStar(require("./turnProtocol.js"), exports);
|
|
22
23
|
__exportStar(require("./agentBehaviorPolicy.js"), exports);
|
|
23
24
|
__exportStar(require("./contactRequest.js"), exports);
|
|
24
|
-
__exportStar(require("./sseEvents.js"), exports);
|
|
25
|
-
__exportStar(require("./controlSignals.js"), exports);
|
|
26
|
-
__exportStar(require("./hitl.js"), exports);
|
|
27
|
-
__exportStar(require("./inboundFrame.js"), exports);
|
|
28
|
-
__exportStar(require("./restEndpoints.js"), exports);
|
|
29
|
-
__exportStar(require("./sendContextual.js"), exports);
|
|
30
|
-
__exportStar(require("./bridgeLocal.js"), exports);
|
|
31
|
-
__exportStar(require("./endpointRegistry.js"), exports);
|
package/dist/cjs/media.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaAttachmentSchema = exports.MediaAttachmentKindSchema = void 0;
|
|
4
3
|
exports.inferMediaAttachmentKind = inferMediaAttachmentKind;
|
|
5
4
|
exports.getStoredFileExtension = getStoredFileExtension;
|
|
6
5
|
exports.normalizeStoredAttachments = normalizeStoredAttachments;
|
|
7
6
|
exports.getMessageAttachments = getMessageAttachments;
|
|
8
7
|
exports.getPrimaryAttachment = getPrimaryAttachment;
|
|
9
8
|
exports.describeAttachment = describeAttachment;
|
|
10
|
-
const zod_1 = require("zod");
|
|
11
|
-
exports.MediaAttachmentKindSchema = zod_1.z.enum(['image', 'audio', 'video', 'file']);
|
|
12
|
-
exports.MediaAttachmentSchema = zod_1.z.object({
|
|
13
|
-
kind: exports.MediaAttachmentKindSchema,
|
|
14
|
-
url: zod_1.z.string(),
|
|
15
|
-
mimeType: zod_1.z.string().optional(),
|
|
16
|
-
fileName: zod_1.z.string().optional(),
|
|
17
|
-
sizeBytes: zod_1.z.number().optional(),
|
|
18
|
-
width: zod_1.z.number().optional(),
|
|
19
|
-
height: zod_1.z.number().optional(),
|
|
20
|
-
durationMs: zod_1.z.number().optional(),
|
|
21
|
-
});
|
|
22
9
|
function inferMediaAttachmentKind(mimeType) {
|
|
23
10
|
if (mimeType.startsWith('image/'))
|
|
24
11
|
return 'image';
|
package/dist/cjs/message.js
CHANGED
|
@@ -1,72 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SerializeMessageInputSchema = exports.SerializedMessageSchema = exports.SerializedContactCardSchema = exports.SerializedReactionsSchema = exports.ForwardedFromSchema = exports.SerializedContentTypeSchema = exports.SerializedAgentClientTypeSchema = exports.SerializedSenderTypeSchema = void 0;
|
|
4
3
|
exports.serializeStoredMessage = serializeStoredMessage;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
4
|
const media_js_1 = require("./media.js");
|
|
7
5
|
const runtimeCardStorage_js_1 = require("./runtimeCardStorage.js");
|
|
8
|
-
exports.SerializedSenderTypeSchema = zod_1.z.enum(['human', 'ai_agent']);
|
|
9
|
-
exports.SerializedAgentClientTypeSchema = zod_1.z.enum([
|
|
10
|
-
'claude-code',
|
|
11
|
-
'openclaw',
|
|
12
|
-
'codex',
|
|
13
|
-
'hermes',
|
|
14
|
-
'generic',
|
|
15
|
-
]);
|
|
16
|
-
exports.SerializedContentTypeSchema = zod_1.z.enum([
|
|
17
|
-
'text',
|
|
18
|
-
'image',
|
|
19
|
-
'audio',
|
|
20
|
-
'video',
|
|
21
|
-
'file',
|
|
22
|
-
'contact_card',
|
|
23
|
-
]);
|
|
24
|
-
exports.ForwardedFromSchema = zod_1.z.object({
|
|
25
|
-
sourceConversationId: zod_1.z.string(),
|
|
26
|
-
messageId: zod_1.z.string(),
|
|
27
|
-
});
|
|
28
|
-
exports.SerializedReactionsSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string()));
|
|
29
|
-
exports.SerializedContactCardSchema = zod_1.z.object({
|
|
30
|
-
userId: zod_1.z.string(),
|
|
31
|
-
canonContactId: zod_1.z.string().optional(),
|
|
32
|
-
displayName: zod_1.z.string(),
|
|
33
|
-
avatarUrl: zod_1.z.string().nullable(),
|
|
34
|
-
userType: exports.SerializedSenderTypeSchema,
|
|
35
|
-
clientType: exports.SerializedAgentClientTypeSchema.optional(),
|
|
36
|
-
about: zod_1.z.string().optional(),
|
|
37
|
-
isActive: zod_1.z.boolean().optional(),
|
|
38
|
-
ownerId: zod_1.z.string().optional(),
|
|
39
|
-
ownerName: zod_1.z.string().optional(),
|
|
40
|
-
lifecycleState: zod_1.z.string().optional(),
|
|
41
|
-
});
|
|
42
|
-
exports.SerializedMessageSchema = zod_1.z.object({
|
|
43
|
-
id: zod_1.z.string(),
|
|
44
|
-
senderId: zod_1.z.string(),
|
|
45
|
-
senderName: zod_1.z.string().optional(),
|
|
46
|
-
senderType: exports.SerializedSenderTypeSchema,
|
|
47
|
-
isOwner: zod_1.z.boolean(),
|
|
48
|
-
contentType: exports.SerializedContentTypeSchema,
|
|
49
|
-
text: zod_1.z.string().nullable(),
|
|
50
|
-
attachments: zod_1.z.array(media_js_1.MediaAttachmentSchema),
|
|
51
|
-
mentions: zod_1.z.array(zod_1.z.string()),
|
|
52
|
-
replyTo: zod_1.z.string().nullable(),
|
|
53
|
-
replyToPosition: zod_1.z.number().nullable(),
|
|
54
|
-
forwarded: zod_1.z.boolean().optional(),
|
|
55
|
-
forwardedFrom: exports.ForwardedFromSchema.optional(),
|
|
56
|
-
status: zod_1.z.enum(['sent', 'read']),
|
|
57
|
-
createdAt: zod_1.z.string(),
|
|
58
|
-
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
59
|
-
contactCard: exports.SerializedContactCardSchema.optional(),
|
|
60
|
-
/** Durable canon.card.v1 runtime card content, passed through opaquely. */
|
|
61
|
-
runtimeCard: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
62
|
-
reactions: exports.SerializedReactionsSchema.optional(),
|
|
63
|
-
});
|
|
64
|
-
exports.SerializeMessageInputSchema = zod_1.z.object({
|
|
65
|
-
id: zod_1.z.string(),
|
|
66
|
-
data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
67
|
-
senderName: zod_1.z.string().optional(),
|
|
68
|
-
isOwner: zod_1.z.boolean(),
|
|
69
|
-
});
|
|
70
6
|
function isRecord(value) {
|
|
71
7
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
72
8
|
}
|
|
@@ -125,7 +61,8 @@ function normalizeContentType(value) {
|
|
|
125
61
|
|| value === 'audio'
|
|
126
62
|
|| value === 'video'
|
|
127
63
|
|| value === 'file'
|
|
128
|
-
|| value === 'contact_card'
|
|
64
|
+
|| value === 'contact_card'
|
|
65
|
+
|| value === 'interaction') {
|
|
129
66
|
return value;
|
|
130
67
|
}
|
|
131
68
|
throw new Error('Message is missing canonical contentType');
|
|
@@ -174,6 +111,41 @@ function normalizeContactCard(value) {
|
|
|
174
111
|
card.lifecycleState = value.lifecycleState;
|
|
175
112
|
return card;
|
|
176
113
|
}
|
|
114
|
+
const INTERACTION_KINDS = [
|
|
115
|
+
'contact', 'approval', 'input', 'plan', 'card',
|
|
116
|
+
];
|
|
117
|
+
function normalizeInteraction(value) {
|
|
118
|
+
if (!isRecord(value))
|
|
119
|
+
return undefined;
|
|
120
|
+
if (!INTERACTION_KINDS.includes(value.kind))
|
|
121
|
+
return undefined;
|
|
122
|
+
if (typeof value.requestId !== 'string' || value.requestId.length === 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
const envelope = {
|
|
125
|
+
kind: value.kind,
|
|
126
|
+
requestId: value.requestId,
|
|
127
|
+
interactive: value.interactive === true,
|
|
128
|
+
};
|
|
129
|
+
if (typeof value.responseUserId === 'string')
|
|
130
|
+
envelope.responseUserId = value.responseUserId;
|
|
131
|
+
if (typeof value.expiresAt === 'string')
|
|
132
|
+
envelope.expiresAt = value.expiresAt;
|
|
133
|
+
if (typeof value.schemaVersion === 'string')
|
|
134
|
+
envelope.schemaVersion = value.schemaVersion;
|
|
135
|
+
if (isRecord(value.preview)) {
|
|
136
|
+
const preview = {};
|
|
137
|
+
if (typeof value.preview.title === 'string')
|
|
138
|
+
preview.title = value.preview.title;
|
|
139
|
+
if (Array.isArray(value.preview.blockKinds)) {
|
|
140
|
+
preview.blockKinds = value.preview.blockKinds.filter((entry) => typeof entry === 'string');
|
|
141
|
+
}
|
|
142
|
+
envelope.preview = preview;
|
|
143
|
+
}
|
|
144
|
+
if (isRecord(value.response)) {
|
|
145
|
+
envelope.response = value.response;
|
|
146
|
+
}
|
|
147
|
+
return envelope;
|
|
148
|
+
}
|
|
177
149
|
function serializeStoredMessage(input) {
|
|
178
150
|
const { data } = input;
|
|
179
151
|
const attachments = data.attachments === undefined
|
|
@@ -217,6 +189,13 @@ function serializeStoredMessage(input) {
|
|
|
217
189
|
if (runtimeCard) {
|
|
218
190
|
result.runtimeCard = runtimeCard;
|
|
219
191
|
}
|
|
192
|
+
const interaction = normalizeInteraction(data.interaction);
|
|
193
|
+
if (interaction) {
|
|
194
|
+
result.interaction = interaction;
|
|
195
|
+
}
|
|
196
|
+
if (typeof data.body === 'string') {
|
|
197
|
+
result.body = data.body;
|
|
198
|
+
}
|
|
220
199
|
const reactions = normalizeReactions(data.reactions);
|
|
221
200
|
if (reactions) {
|
|
222
201
|
result.reactions = reactions;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RUNTIME_CARD_LIMITS = void 0;
|
|
4
4
|
exports.validateRuntimeCardFieldValues = validateRuntimeCardFieldValues;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.RuntimeCardFieldTypeSchema = zod_1.z.enum([
|
|
7
|
-
'text',
|
|
8
|
-
'textarea',
|
|
9
|
-
'select',
|
|
10
|
-
'multiSelect',
|
|
11
|
-
'boolean',
|
|
12
|
-
'date',
|
|
13
|
-
'number',
|
|
14
|
-
'currency',
|
|
15
|
-
'searchSelect',
|
|
16
|
-
'lineItems',
|
|
17
|
-
]);
|
|
18
5
|
/**
|
|
19
6
|
* Caps shared across runtime-card normalizers, response validation, and
|
|
20
7
|
* authoring tools. Keep these backend-safe so Functions can import them.
|
|
@@ -25,50 +12,6 @@ exports.RUNTIME_CARD_LIMITS = {
|
|
|
25
12
|
lineItemColumns: 8,
|
|
26
13
|
searchSelectChoices: 100,
|
|
27
14
|
};
|
|
28
|
-
exports.RuntimeCardFieldChoiceSchema = zod_1.z.object({
|
|
29
|
-
label: zod_1.z.string(),
|
|
30
|
-
value: zod_1.z.string().optional(),
|
|
31
|
-
description: zod_1.z.string().optional(),
|
|
32
|
-
preview: zod_1.z.string().optional(),
|
|
33
|
-
});
|
|
34
|
-
exports.RuntimeCardLineItemColumnTypeSchema = zod_1.z.enum([
|
|
35
|
-
'text',
|
|
36
|
-
'number',
|
|
37
|
-
'currency',
|
|
38
|
-
'date',
|
|
39
|
-
'select',
|
|
40
|
-
]);
|
|
41
|
-
exports.RuntimeCardLineItemColumnSchema = zod_1.z.object({
|
|
42
|
-
id: zod_1.z.string(),
|
|
43
|
-
label: zod_1.z.string(),
|
|
44
|
-
type: exports.RuntimeCardLineItemColumnTypeSchema,
|
|
45
|
-
required: zod_1.z.boolean().optional(),
|
|
46
|
-
choices: zod_1.z.array(exports.RuntimeCardFieldChoiceSchema).optional(),
|
|
47
|
-
min: zod_1.z.number().optional(),
|
|
48
|
-
max: zod_1.z.number().optional(),
|
|
49
|
-
step: zod_1.z.number().optional(),
|
|
50
|
-
precision: zod_1.z.number().optional(),
|
|
51
|
-
currencyCode: zod_1.z.string().optional(),
|
|
52
|
-
allowOther: zod_1.z.boolean().optional(),
|
|
53
|
-
});
|
|
54
|
-
exports.RuntimeCardFieldSchema = zod_1.z.object({
|
|
55
|
-
id: zod_1.z.string(),
|
|
56
|
-
label: zod_1.z.string(),
|
|
57
|
-
type: exports.RuntimeCardFieldTypeSchema,
|
|
58
|
-
required: zod_1.z.boolean().optional(),
|
|
59
|
-
placeholder: zod_1.z.string().optional(),
|
|
60
|
-
choices: zod_1.z.array(exports.RuntimeCardFieldChoiceSchema).optional(),
|
|
61
|
-
allowOther: zod_1.z.boolean().optional(),
|
|
62
|
-
sensitive: zod_1.z.boolean().optional(),
|
|
63
|
-
min: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).optional(),
|
|
64
|
-
max: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).optional(),
|
|
65
|
-
step: zod_1.z.number().optional(),
|
|
66
|
-
precision: zod_1.z.number().optional(),
|
|
67
|
-
currencyCode: zod_1.z.string().optional(),
|
|
68
|
-
columns: zod_1.z.array(exports.RuntimeCardLineItemColumnSchema).optional(),
|
|
69
|
-
minRows: zod_1.z.number().optional(),
|
|
70
|
-
maxRows: zod_1.z.number().optional(),
|
|
71
|
-
});
|
|
72
15
|
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
73
16
|
function isRecord(value) {
|
|
74
17
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|