@lssm/lib.communication-spec 3.1.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.
- package/README.md +201 -0
- package/dist/browser/capabilities/comms-ai.capabilities.js +1 -0
- package/dist/browser/capabilities/communication-os.capability-ids.js +1 -0
- package/dist/browser/capabilities/ecosystem-messaging.capabilities.js +1 -0
- package/dist/browser/capabilities/index.js +1 -0
- package/dist/browser/commands/comms-ai.commands.js +1 -0
- package/dist/browser/commands/index.js +1 -0
- package/dist/browser/contracts/agent-communication.js +1 -0
- package/dist/browser/contracts/agent-lifecycle-projection.js +1 -0
- package/dist/browser/contracts/agent-surface-control.js +1 -0
- package/dist/browser/contracts/ai-assistance.operations.js +1 -0
- package/dist/browser/contracts/artifact-digest.js +1 -0
- package/dist/browser/contracts/canonical-agent-conversation.js +1 -0
- package/dist/browser/contracts/channel-preferences.js +1 -0
- package/dist/browser/contracts/channel-routing.js +1 -0
- package/dist/browser/contracts/collaboration.operations.js +1 -0
- package/dist/browser/contracts/customer-live-chat-grant.operations.js +1 -0
- package/dist/browser/contracts/delivery-eligibility.js +1 -0
- package/dist/browser/contracts/delivery-fallback-eligibility-validation.js +1 -0
- package/dist/browser/contracts/delivery-fallback-validation.js +1 -0
- package/dist/browser/contracts/delivery-fallback.js +1 -0
- package/dist/browser/contracts/delivery-intent-validation.js +1 -0
- package/dist/browser/contracts/delivery-intent.js +1 -0
- package/dist/browser/contracts/delivery-progress.js +1 -0
- package/dist/browser/contracts/discord-community-intelligence.operations.js +1 -0
- package/dist/browser/contracts/discord-community.events.js +1 -0
- package/dist/browser/contracts/discord-community.models.js +1 -0
- package/dist/browser/contracts/discord-community.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-attachment.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-auth.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-binding.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-connection-subscription.events.js +1 -0
- package/dist/browser/contracts/ecosystem-governed-work-v2.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-governed-work.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-identity-v3.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-identity.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-message.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-messaging.dtos.js +0 -0
- package/dist/browser/contracts/ecosystem-messaging.events.js +1 -0
- package/dist/browser/contracts/ecosystem-messaging.models.js +1 -0
- package/dist/browser/contracts/ecosystem-navigation-v3.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-webhook.operations.js +1 -0
- package/dist/browser/contracts/ecosystem-workspace.operations.js +1 -0
- package/dist/browser/contracts/enums.js +1 -0
- package/dist/browser/contracts/erasure.operations.js +1 -0
- package/dist/browser/contracts/events.js +1 -0
- package/dist/browser/contracts/index.js +1 -0
- package/dist/browser/contracts/ingestion.js +1 -0
- package/dist/browser/contracts/ingress-admission-policy.js +1 -0
- package/dist/browser/contracts/ingress-admission.js +1 -0
- package/dist/browser/contracts/models.js +1 -0
- package/dist/browser/contracts/operations.js +1 -0
- package/dist/browser/contracts/persistence.js +1 -0
- package/dist/browser/contracts/preference-resolution.js +1 -0
- package/dist/browser/contracts/query.operations.js +1 -0
- package/dist/browser/contracts/sequence-intent.js +1 -0
- package/dist/browser/contracts/sovereignty.js +1 -0
- package/dist/browser/contracts/support-internal-note.operations.js +1 -0
- package/dist/browser/contracts/thread-link-kind.js +1 -0
- package/dist/browser/contracts/thread-message.operations.js +1 -0
- package/dist/browser/events/index.js +1 -0
- package/dist/browser/fixtures/agent-omnichannel-primitives.js +1 -0
- package/dist/browser/fixtures/agent-omnichannel.js +1 -0
- package/dist/browser/fixtures/gtm-learning-loop-neutral.parts.js +1 -0
- package/dist/browser/fixtures/index.js +1 -0
- package/dist/browser/fixtures/normalized-ingestion.js +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/queries/index.js +1 -0
- package/dist/browser/types/domain-command.js +0 -0
- package/dist/browser/types/index.js +1 -0
- package/dist/browser/validation/domain-command.js +1 -0
- package/dist/browser/validation/index.js +1 -0
- package/dist/capabilities/comms-ai.capabilities.d.ts +72 -0
- package/dist/capabilities/comms-ai.capabilities.js +2 -0
- package/dist/capabilities/communication-os-capability-boundary.test.d.ts +1 -0
- package/dist/capabilities/communication-os.capability-ids.d.ts +39 -0
- package/dist/capabilities/communication-os.capability-ids.js +2 -0
- package/dist/capabilities/communication-os.capability-ids.test.d.ts +1 -0
- package/dist/capabilities/ecosystem-messaging.capabilities.d.ts +9 -0
- package/dist/capabilities/ecosystem-messaging.capabilities.js +2 -0
- package/dist/capabilities/index.d.ts +4 -0
- package/dist/capabilities/index.js +2 -0
- package/dist/commands/comms-ai.commands.d.ts +272 -0
- package/dist/commands/comms-ai.commands.js +2 -0
- package/dist/commands/index.d.ts +10 -0
- package/dist/commands/index.js +2 -0
- package/dist/contracts/agent-communication.d.ts +108 -0
- package/dist/contracts/agent-communication.js +2 -0
- package/dist/contracts/agent-communication.test.d.ts +1 -0
- package/dist/contracts/agent-lifecycle-projection.d.ts +98 -0
- package/dist/contracts/agent-lifecycle-projection.js +2 -0
- package/dist/contracts/agent-lifecycle-projection.test.d.ts +1 -0
- package/dist/contracts/agent-surface-control.d.ts +210 -0
- package/dist/contracts/agent-surface-control.js +2 -0
- package/dist/contracts/agent-surface-control.test.d.ts +1 -0
- package/dist/contracts/ai-assistance.operations.d.ts +187 -0
- package/dist/contracts/ai-assistance.operations.js +2 -0
- package/dist/contracts/artifact-digest.d.ts +3 -0
- package/dist/contracts/artifact-digest.js +2 -0
- package/dist/contracts/canonical-agent-conversation.d.ts +46 -0
- package/dist/contracts/canonical-agent-conversation.js +2 -0
- package/dist/contracts/canonical-agent-conversation.test.d.ts +1 -0
- package/dist/contracts/channel-preferences.d.ts +115 -0
- package/dist/contracts/channel-preferences.js +2 -0
- package/dist/contracts/channel-routing.d.ts +58 -0
- package/dist/contracts/channel-routing.js +2 -0
- package/dist/contracts/channel-routing.test.d.ts +1 -0
- package/dist/contracts/collaboration.operations.d.ts +315 -0
- package/dist/contracts/collaboration.operations.js +2 -0
- package/dist/contracts/customer-live-chat-grant.operations.d.ts +132 -0
- package/dist/contracts/customer-live-chat-grant.operations.js +2 -0
- package/dist/contracts/delivery-contracts.test.d.ts +1 -0
- package/dist/contracts/delivery-eligibility.d.ts +126 -0
- package/dist/contracts/delivery-eligibility.js +2 -0
- package/dist/contracts/delivery-eligibility.test.d.ts +1 -0
- package/dist/contracts/delivery-fallback-eligibility-validation.d.ts +6 -0
- package/dist/contracts/delivery-fallback-eligibility-validation.js +2 -0
- package/dist/contracts/delivery-fallback-validation.d.ts +24 -0
- package/dist/contracts/delivery-fallback-validation.js +2 -0
- package/dist/contracts/delivery-fallback.d.ts +117 -0
- package/dist/contracts/delivery-fallback.js +2 -0
- package/dist/contracts/delivery-intent-validation.d.ts +13 -0
- package/dist/contracts/delivery-intent-validation.js +2 -0
- package/dist/contracts/delivery-intent.d.ts +137 -0
- package/dist/contracts/delivery-intent.js +2 -0
- package/dist/contracts/delivery-progress.d.ts +61 -0
- package/dist/contracts/delivery-progress.js +2 -0
- package/dist/contracts/discord-community-intelligence.operations.d.ts +405 -0
- package/dist/contracts/discord-community-intelligence.operations.js +2 -0
- package/dist/contracts/discord-community.events.d.ts +162 -0
- package/dist/contracts/discord-community.events.js +2 -0
- package/dist/contracts/discord-community.models.d.ts +167 -0
- package/dist/contracts/discord-community.models.js +2 -0
- package/dist/contracts/discord-community.operations.d.ts +663 -0
- package/dist/contracts/discord-community.operations.js +2 -0
- package/dist/contracts/discord-community.test.d.ts +1 -0
- package/dist/contracts/ecosystem-attachment.operations.d.ts +129 -0
- package/dist/contracts/ecosystem-attachment.operations.js +2 -0
- package/dist/contracts/ecosystem-auth.operations.d.ts +345 -0
- package/dist/contracts/ecosystem-auth.operations.js +2 -0
- package/dist/contracts/ecosystem-binding.operations.d.ts +231 -0
- package/dist/contracts/ecosystem-binding.operations.js +2 -0
- package/dist/contracts/ecosystem-connection-subscription.events.d.ts +332 -0
- package/dist/contracts/ecosystem-connection-subscription.events.js +2 -0
- package/dist/contracts/ecosystem-governed-work-v2.operations.d.ts +234 -0
- package/dist/contracts/ecosystem-governed-work-v2.operations.js +2 -0
- package/dist/contracts/ecosystem-governed-work.operations.d.ts +265 -0
- package/dist/contracts/ecosystem-governed-work.operations.js +2 -0
- package/dist/contracts/ecosystem-governed-work.operations.test.d.ts +1 -0
- package/dist/contracts/ecosystem-identity-v3.operations.d.ts +65 -0
- package/dist/contracts/ecosystem-identity-v3.operations.js +2 -0
- package/dist/contracts/ecosystem-identity.operations.d.ts +174 -0
- package/dist/contracts/ecosystem-identity.operations.js +2 -0
- package/dist/contracts/ecosystem-identity.operations.test.d.ts +1 -0
- package/dist/contracts/ecosystem-message.operations.d.ts +1092 -0
- package/dist/contracts/ecosystem-message.operations.js +2 -0
- package/dist/contracts/ecosystem-messaging.dtos.d.ts +68 -0
- package/dist/contracts/ecosystem-messaging.dtos.js +1 -0
- package/dist/contracts/ecosystem-messaging.dtos.test.d.ts +1 -0
- package/dist/contracts/ecosystem-messaging.events.d.ts +608 -0
- package/dist/contracts/ecosystem-messaging.events.js +2 -0
- package/dist/contracts/ecosystem-messaging.models.d.ts +386 -0
- package/dist/contracts/ecosystem-messaging.models.js +2 -0
- package/dist/contracts/ecosystem-messaging.test.d.ts +1 -0
- package/dist/contracts/ecosystem-navigation-v3.operations.d.ts +149 -0
- package/dist/contracts/ecosystem-navigation-v3.operations.js +2 -0
- package/dist/contracts/ecosystem-webhook.operations.d.ts +187 -0
- package/dist/contracts/ecosystem-webhook.operations.js +2 -0
- package/dist/contracts/ecosystem-workspace.operations.d.ts +590 -0
- package/dist/contracts/ecosystem-workspace.operations.js +2 -0
- package/dist/contracts/enums.d.ts +9 -0
- package/dist/contracts/enums.js +2 -0
- package/dist/contracts/erasure.operations.d.ts +114 -0
- package/dist/contracts/erasure.operations.js +2 -0
- package/dist/contracts/erasure.test.d.ts +1 -0
- package/dist/contracts/events.d.ts +174 -0
- package/dist/contracts/events.js +2 -0
- package/dist/contracts/index.d.ts +43 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/ingestion.d.ts +169 -0
- package/dist/contracts/ingestion.js +2 -0
- package/dist/contracts/ingress-admission-policy.d.ts +14 -0
- package/dist/contracts/ingress-admission-policy.js +2 -0
- package/dist/contracts/ingress-admission.d.ts +184 -0
- package/dist/contracts/ingress-admission.js +2 -0
- package/dist/contracts/ingress-admission.test.d.ts +1 -0
- package/dist/contracts/models.d.ts +851 -0
- package/dist/contracts/models.js +2 -0
- package/dist/contracts/operations.d.ts +5 -0
- package/dist/contracts/operations.js +2 -0
- package/dist/contracts/persistence.d.ts +353 -0
- package/dist/contracts/persistence.js +2 -0
- package/dist/contracts/persistence.test.d.ts +1 -0
- package/dist/contracts/preference-resolution.d.ts +154 -0
- package/dist/contracts/preference-resolution.js +2 -0
- package/dist/contracts/preference-resolution.test.d.ts +1 -0
- package/dist/contracts/query.operations.d.ts +600 -0
- package/dist/contracts/query.operations.js +2 -0
- package/dist/contracts/sequence-intent.d.ts +103 -0
- package/dist/contracts/sequence-intent.js +2 -0
- package/dist/contracts/sequence-intent.test.d.ts +1 -0
- package/dist/contracts/sovereignty.d.ts +164 -0
- package/dist/contracts/sovereignty.js +2 -0
- package/dist/contracts/support-internal-note.operations.d.ts +309 -0
- package/dist/contracts/support-internal-note.operations.js +2 -0
- package/dist/contracts/support-internal-note.operations.test.d.ts +1 -0
- package/dist/contracts/thread-link-kind.d.ts +20 -0
- package/dist/contracts/thread-link-kind.js +2 -0
- package/dist/contracts/thread-message.operations.d.ts +485 -0
- package/dist/contracts/thread-message.operations.js +2 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +2 -0
- package/dist/fixtures/agent-omnichannel-primitives.d.ts +240 -0
- package/dist/fixtures/agent-omnichannel-primitives.js +2 -0
- package/dist/fixtures/agent-omnichannel.d.ts +682 -0
- package/dist/fixtures/agent-omnichannel.js +2 -0
- package/dist/fixtures/agent-omnichannel.test.d.ts +1 -0
- package/dist/fixtures/gtm-learning-loop-neutral.parts.d.ts +20 -0
- package/dist/fixtures/gtm-learning-loop-neutral.parts.js +2 -0
- package/dist/fixtures/index.d.ts +3 -0
- package/dist/fixtures/index.js +2 -0
- package/dist/fixtures/normalized-ingestion.d.ts +102 -0
- package/dist/fixtures/normalized-ingestion.js +2 -0
- package/dist/fixtures/normalized-ingestion.test.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -0
- package/dist/node/capabilities/comms-ai.capabilities.js +1 -0
- package/dist/node/capabilities/communication-os.capability-ids.js +1 -0
- package/dist/node/capabilities/ecosystem-messaging.capabilities.js +1 -0
- package/dist/node/capabilities/index.js +1 -0
- package/dist/node/commands/comms-ai.commands.js +1 -0
- package/dist/node/commands/index.js +1 -0
- package/dist/node/contracts/agent-communication.js +1 -0
- package/dist/node/contracts/agent-lifecycle-projection.js +1 -0
- package/dist/node/contracts/agent-surface-control.js +1 -0
- package/dist/node/contracts/ai-assistance.operations.js +1 -0
- package/dist/node/contracts/artifact-digest.js +1 -0
- package/dist/node/contracts/canonical-agent-conversation.js +1 -0
- package/dist/node/contracts/channel-preferences.js +1 -0
- package/dist/node/contracts/channel-routing.js +1 -0
- package/dist/node/contracts/collaboration.operations.js +1 -0
- package/dist/node/contracts/customer-live-chat-grant.operations.js +1 -0
- package/dist/node/contracts/delivery-eligibility.js +1 -0
- package/dist/node/contracts/delivery-fallback-eligibility-validation.js +1 -0
- package/dist/node/contracts/delivery-fallback-validation.js +1 -0
- package/dist/node/contracts/delivery-fallback.js +1 -0
- package/dist/node/contracts/delivery-intent-validation.js +1 -0
- package/dist/node/contracts/delivery-intent.js +1 -0
- package/dist/node/contracts/delivery-progress.js +1 -0
- package/dist/node/contracts/discord-community-intelligence.operations.js +1 -0
- package/dist/node/contracts/discord-community.events.js +1 -0
- package/dist/node/contracts/discord-community.models.js +1 -0
- package/dist/node/contracts/discord-community.operations.js +1 -0
- package/dist/node/contracts/ecosystem-attachment.operations.js +1 -0
- package/dist/node/contracts/ecosystem-auth.operations.js +1 -0
- package/dist/node/contracts/ecosystem-binding.operations.js +1 -0
- package/dist/node/contracts/ecosystem-connection-subscription.events.js +1 -0
- package/dist/node/contracts/ecosystem-governed-work-v2.operations.js +1 -0
- package/dist/node/contracts/ecosystem-governed-work.operations.js +1 -0
- package/dist/node/contracts/ecosystem-identity-v3.operations.js +1 -0
- package/dist/node/contracts/ecosystem-identity.operations.js +1 -0
- package/dist/node/contracts/ecosystem-message.operations.js +1 -0
- package/dist/node/contracts/ecosystem-messaging.dtos.js +0 -0
- package/dist/node/contracts/ecosystem-messaging.events.js +1 -0
- package/dist/node/contracts/ecosystem-messaging.models.js +1 -0
- package/dist/node/contracts/ecosystem-navigation-v3.operations.js +1 -0
- package/dist/node/contracts/ecosystem-webhook.operations.js +1 -0
- package/dist/node/contracts/ecosystem-workspace.operations.js +1 -0
- package/dist/node/contracts/enums.js +1 -0
- package/dist/node/contracts/erasure.operations.js +1 -0
- package/dist/node/contracts/events.js +1 -0
- package/dist/node/contracts/index.js +1 -0
- package/dist/node/contracts/ingestion.js +1 -0
- package/dist/node/contracts/ingress-admission-policy.js +1 -0
- package/dist/node/contracts/ingress-admission.js +1 -0
- package/dist/node/contracts/models.js +1 -0
- package/dist/node/contracts/operations.js +1 -0
- package/dist/node/contracts/persistence.js +1 -0
- package/dist/node/contracts/preference-resolution.js +1 -0
- package/dist/node/contracts/query.operations.js +1 -0
- package/dist/node/contracts/sequence-intent.js +1 -0
- package/dist/node/contracts/sovereignty.js +1 -0
- package/dist/node/contracts/support-internal-note.operations.js +1 -0
- package/dist/node/contracts/thread-link-kind.js +1 -0
- package/dist/node/contracts/thread-message.operations.js +1 -0
- package/dist/node/events/index.js +1 -0
- package/dist/node/fixtures/agent-omnichannel-primitives.js +1 -0
- package/dist/node/fixtures/agent-omnichannel.js +1 -0
- package/dist/node/fixtures/gtm-learning-loop-neutral.parts.js +1 -0
- package/dist/node/fixtures/index.js +1 -0
- package/dist/node/fixtures/normalized-ingestion.js +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/queries/index.js +1 -0
- package/dist/node/types/domain-command.js +0 -0
- package/dist/node/types/index.js +1 -0
- package/dist/node/validation/domain-command.js +1 -0
- package/dist/node/validation/index.js +1 -0
- package/dist/package-exports.test.d.ts +1 -0
- package/dist/queries/index.d.ts +4 -0
- package/dist/queries/index.js +2 -0
- package/dist/types/domain-command.d.ts +54 -0
- package/dist/types/domain-command.js +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +2 -0
- package/dist/validation/domain-command.d.ts +3 -0
- package/dist/validation/domain-command.js +2 -0
- package/dist/validation/index.d.ts +53 -0
- package/dist/validation/index.js +2 -0
- package/package.json +1227 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const COMMUNICATION_CUSTOMER_LIVE_CHAT_GRANT_CAPABILITY: 'communication.support.customer-live-chat.grant';
|
|
3
|
+
export declare const COMMUNICATION_CUSTOMER_LIVE_CHAT_VERIFY_CAPABILITY: 'communication.support.customer-live-chat.verify';
|
|
4
|
+
export declare const COMMUNICATION_CUSTOMER_LIVE_CHAT_CAPABILITIES: readonly ['messages:list', 'messages:send', 'realtime:ticket'];
|
|
5
|
+
export declare const CommunicationCustomerLiveChatBindingSchema: z.ZodObject<{
|
|
6
|
+
bindingRef: z.ZodString;
|
|
7
|
+
spaceRef: z.ZodString;
|
|
8
|
+
sessionRef: z.ZodString;
|
|
9
|
+
sessionRevision: z.ZodNumber;
|
|
10
|
+
caseRef: z.ZodString;
|
|
11
|
+
caseRevision: z.ZodNumber;
|
|
12
|
+
conversationRef: z.ZodString;
|
|
13
|
+
roomRef: z.ZodString;
|
|
14
|
+
channel: z.ZodEnum<{
|
|
15
|
+
messenger: "messenger";
|
|
16
|
+
portal: "portal";
|
|
17
|
+
}>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export declare const CommunicationCustomerLiveChatGrantRequestSchema: z.ZodObject<{
|
|
20
|
+
bindingRef: z.ZodString;
|
|
21
|
+
spaceRef: z.ZodString;
|
|
22
|
+
sessionRef: z.ZodString;
|
|
23
|
+
sessionRevision: z.ZodNumber;
|
|
24
|
+
caseRef: z.ZodString;
|
|
25
|
+
caseRevision: z.ZodNumber;
|
|
26
|
+
conversationRef: z.ZodString;
|
|
27
|
+
roomRef: z.ZodString;
|
|
28
|
+
channel: z.ZodEnum<{
|
|
29
|
+
messenger: "messenger";
|
|
30
|
+
portal: "portal";
|
|
31
|
+
}>;
|
|
32
|
+
expiresAt: z.ZodString;
|
|
33
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export declare const CommunicationCustomerLiveChatVerificationRequestSchema: z.ZodObject<{
|
|
36
|
+
spaceRef: z.ZodString;
|
|
37
|
+
sessionRef: z.ZodString;
|
|
38
|
+
sessionRevision: z.ZodNumber;
|
|
39
|
+
caseRef: z.ZodString;
|
|
40
|
+
caseRevision: z.ZodNumber;
|
|
41
|
+
conversationRef: z.ZodString;
|
|
42
|
+
roomRef: z.ZodString;
|
|
43
|
+
channel: z.ZodEnum<{
|
|
44
|
+
messenger: "messenger";
|
|
45
|
+
portal: "portal";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export declare const CommunicationCustomerLiveChatVerificationResponseSchema: z.ZodObject<{
|
|
49
|
+
spaceRef: z.ZodString;
|
|
50
|
+
sessionRef: z.ZodString;
|
|
51
|
+
sessionRevision: z.ZodNumber;
|
|
52
|
+
caseRef: z.ZodString;
|
|
53
|
+
caseRevision: z.ZodNumber;
|
|
54
|
+
conversationRef: z.ZodString;
|
|
55
|
+
roomRef: z.ZodString;
|
|
56
|
+
channel: z.ZodEnum<{
|
|
57
|
+
messenger: "messenger";
|
|
58
|
+
portal: "portal";
|
|
59
|
+
}>;
|
|
60
|
+
conversationRevision: z.ZodNumber;
|
|
61
|
+
evidenceRef: z.ZodString;
|
|
62
|
+
verifiedAt: z.ZodString;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export declare const CommunicationCustomerLiveChatGrantScopeSchema: z.ZodObject<{
|
|
65
|
+
tenantId: z.ZodString;
|
|
66
|
+
workspaceId: z.ZodString;
|
|
67
|
+
spaceId: z.ZodString;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export declare const CommunicationCustomerLiveChatGrantResponseSchema: z.ZodObject<{
|
|
70
|
+
grantRef: z.ZodString;
|
|
71
|
+
accessToken: z.ZodString;
|
|
72
|
+
realtimeTicket: z.ZodString;
|
|
73
|
+
principalRef: z.ZodString;
|
|
74
|
+
scope: z.ZodObject<{
|
|
75
|
+
tenantId: z.ZodString;
|
|
76
|
+
workspaceId: z.ZodString;
|
|
77
|
+
spaceId: z.ZodString;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
binding: z.ZodObject<{
|
|
80
|
+
bindingRef: z.ZodString;
|
|
81
|
+
spaceRef: z.ZodString;
|
|
82
|
+
sessionRef: z.ZodString;
|
|
83
|
+
sessionRevision: z.ZodNumber;
|
|
84
|
+
caseRef: z.ZodString;
|
|
85
|
+
caseRevision: z.ZodNumber;
|
|
86
|
+
conversationRef: z.ZodString;
|
|
87
|
+
roomRef: z.ZodString;
|
|
88
|
+
channel: z.ZodEnum<{
|
|
89
|
+
messenger: "messenger";
|
|
90
|
+
portal: "portal";
|
|
91
|
+
}>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
inputDigest: z.ZodString;
|
|
94
|
+
expiresAt: z.ZodString;
|
|
95
|
+
capabilities: z.ZodTuple<[z.ZodLiteral<"messages:list">, z.ZodLiteral<"messages:send">, z.ZodLiteral<"realtime:ticket">], null>;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
export type CommunicationCustomerLiveChatBinding = z.infer<typeof CommunicationCustomerLiveChatBindingSchema>;
|
|
98
|
+
export type CommunicationCustomerLiveChatGrantRequest = z.infer<typeof CommunicationCustomerLiveChatGrantRequestSchema>;
|
|
99
|
+
export type CommunicationCustomerLiveChatGrantScope = z.infer<typeof CommunicationCustomerLiveChatGrantScopeSchema>;
|
|
100
|
+
export type CommunicationCustomerLiveChatVerificationRequest = z.infer<typeof CommunicationCustomerLiveChatVerificationRequestSchema>;
|
|
101
|
+
export type CommunicationCustomerLiveChatVerificationResponse = z.infer<typeof CommunicationCustomerLiveChatVerificationResponseSchema>;
|
|
102
|
+
type CommunicationCustomerLiveChatGrantResponseData = z.infer<typeof CommunicationCustomerLiveChatGrantResponseSchema>;
|
|
103
|
+
export type CommunicationCustomerLiveChatGrantResponse = Omit<CommunicationCustomerLiveChatGrantResponseData, 'capabilities'> & {
|
|
104
|
+
readonly capabilities: typeof COMMUNICATION_CUSTOMER_LIVE_CHAT_CAPABILITIES;
|
|
105
|
+
};
|
|
106
|
+
export interface CommunicationCustomerLiveChatBridgePort {
|
|
107
|
+
exchange(input: {
|
|
108
|
+
readonly scope: CommunicationCustomerLiveChatGrantScope;
|
|
109
|
+
readonly subjectRef: string;
|
|
110
|
+
readonly grantEvidenceRef: string;
|
|
111
|
+
readonly authorizedBindingRef: string;
|
|
112
|
+
readonly authorizedInputDigest: `sha256:${string}`;
|
|
113
|
+
readonly request: CommunicationCustomerLiveChatGrantRequest;
|
|
114
|
+
}): Promise<CommunicationCustomerLiveChatGrantResponse>;
|
|
115
|
+
ready(): boolean | Promise<boolean>;
|
|
116
|
+
}
|
|
117
|
+
export interface CommunicationCustomerLiveChatConversationVerifierPort {
|
|
118
|
+
verify(input: {
|
|
119
|
+
readonly scope: CommunicationCustomerLiveChatGrantScope;
|
|
120
|
+
readonly request: CommunicationCustomerLiveChatVerificationRequest;
|
|
121
|
+
}): Promise<CommunicationCustomerLiveChatVerificationResponse | undefined>;
|
|
122
|
+
ready(): boolean | Promise<boolean>;
|
|
123
|
+
}
|
|
124
|
+
export declare function digestCommunicationCustomerLiveChatGrantInput(input: {
|
|
125
|
+
readonly scope: CommunicationCustomerLiveChatGrantScope;
|
|
126
|
+
readonly request: CommunicationCustomerLiveChatGrantRequest;
|
|
127
|
+
}): Promise<`sha256:${string}`>;
|
|
128
|
+
export declare function digestCommunicationCustomerLiveChatVerificationInput(input: {
|
|
129
|
+
readonly scope: CommunicationCustomerLiveChatGrantScope;
|
|
130
|
+
readonly request: CommunicationCustomerLiveChatVerificationRequest;
|
|
131
|
+
}): Promise<`sha256:${string}`>;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{z as s}from"zod";import{z as o}from"zod";var y="1.0.0",v="1.0.0",V={id:"communication-os.agent-omnichannel.v1",title:"CommunicationOS agent omnichannel contracts",body:"Provider-neutral agent profiles and lifecycle links bind applications, runs, tasks, help requests, background results, routes, preferences, policies, and evidence through opaque references. They grant no provider access or effect authority.",kind:"reference",route:"/docs/communication-os/agent-omnichannel-v1",visibility:"public"},n=o.string().trim().min(1),l=o.string().datetime({offset:!0}),u=o.string().regex(/^sha256:[a-f0-9]{64}$/),g=o.object({ref:n,digest:u}).strict(),m=g.extend({revision:o.number().int().positive()}).strict(),h=o.object({tenantRef:n,workspaceRef:n.optional(),spaceRef:n.optional(),subjectRef:n}).strict(),x=o.object({schemaVersion:o.literal(y),profileRef:n,revision:o.number().int().positive(),agentRef:n,applicationRef:n,scope:h,routeBindings:o.array(m),connectionRefs:o.array(n),preferenceSet:m,policyRefs:o.array(n).min(1),evidenceRefs:o.array(n).min(1),createdAt:l,updatedAt:l,profileDigest:u}).strict().superRefine((e,t)=>{for(let r of["connectionRefs","policyRefs","evidenceRefs"])if(new Set(e[r]).size!==e[r].length)t.addIssue({code:o.ZodIssueCode.custom,path:[r],message:`${r} must be unique`});let i=e.routeBindings.map((r)=>r.ref);if(new Set(i).size!==i.length)t.addIssue({code:o.ZodIssueCode.custom,path:["routeBindings"],message:"route bindings must be unique"})}),I=o.object({schemaVersion:o.literal(v),linkRef:n,profile:m,agentRef:n,applicationRef:n,scope:h,runRef:n.optional(),taskRef:n.optional(),helpRequestRef:n.optional(),approvalRequestRef:n.optional(),backgroundResultRef:n.optional(),canonicalConversation:g.optional(),session:m.optional(),correlationRef:n,evidenceRefs:o.array(n).min(1)}).strict().superRefine((e,t)=>{if(new Set(e.evidenceRefs).size!==e.evidenceRefs.length)t.addIssue({code:o.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"});if(!e.runRef&&!e.taskRef&&!e.helpRequestRef&&!e.approvalRequestRef&&!e.backgroundResultRef)t.addIssue({code:o.ZodIssueCode.custom,path:["runRef"],message:"at least one run, task, help request, approval request, or background result ref is required"})});function R(e,t){return e.tenantRef===t.tenantRef&&e.workspaceRef===t.workspaceRef&&e.spaceRef===t.spaceRef&&e.subjectRef===t.subjectRef}function b(e){let t=[];for(let i of["agentRef","applicationRef"])if(e.profile[i]!==e.lifecycleLink[i])t.push(`Lifecycle ${i} does not match the agent profile`);if(e.lifecycleLink.profile.ref!==e.profile.profileRef||e.lifecycleLink.profile.revision!==e.profile.revision||e.lifecycleLink.profile.digest!==e.profile.profileDigest)t.push("Lifecycle profile binding does not match the agent profile");if(!R(e.profile.scope,e.lifecycleLink.scope))t.push("Lifecycle scope does not match the agent profile");return t}function k(e){let{intent:t,progress:i}=e,r=[];if(i.deliveryRef!==t.deliveryRef||i.intent.ref!==t.deliveryRef||i.intent.digest!==t.deliveryDigest)r.push("Progress delivery does not match the intent");if(!R(i.scope,t.scope))r.push("Progress scope does not match the intent");if(i.recipientRef!==t.recipientRefs[0])r.push("Progress recipient does not match the intent");let c=t.requestedRoutes.find((p)=>p.ref===i.route.ref);if(!c||c.revision!==i.route.revision||c.digest!==i.route.digest)r.push("Progress route was not requested by the intent");if(Date.parse(i.occurredAt)<Date.parse(t.createdAt)||Date.parse(i.occurredAt)>Date.parse(t.expiresAt))r.push("Progress occurred outside the intent validity window");return r}async function C(e){let t=new TextEncoder().encode(f(e)),i=new Uint8Array(t.byteLength);i.set(t);let r=await crypto.subtle.digest("SHA-256",i.buffer),c=Array.from(new Uint8Array(r),(p)=>p.toString(16).padStart(2,"0")).join("");return u.parse(`sha256:${c}`)}function f(e){if(Array.isArray(e))return`[${e.map(f).join(",")}]`;if(e&&typeof e==="object")return`{${Object.entries(e).sort(([t],[i])=>t.localeCompare(i)).map(([t,i])=>`${JSON.stringify(t)}:${f(i)}`).join(",")}}`;return JSON.stringify(e)}var P="communication.support.customer-live-chat.grant",D="communication.support.customer-live-chat.verify",E=["messages:list","messages:send","realtime:ticket"],a=s.string().trim().min(1).max(300),d=s.object({bindingRef:a,spaceRef:a,sessionRef:a,sessionRevision:s.number().int().positive(),caseRef:a,caseRevision:s.number().int().nonnegative(),conversationRef:a,roomRef:a,channel:s.enum(["messenger","portal"])}).strict(),G=d.extend({expiresAt:s.string().datetime({offset:!0}),evidenceRefs:s.array(a).min(1).max(20)}).strict().superRefine((e,t)=>{if(new Set(e.evidenceRefs).size!==e.evidenceRefs.length)t.addIssue({code:s.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"})}),L=d.omit({bindingRef:!0}).strict(),N=L.extend({conversationRevision:s.number().int().positive(),evidenceRef:a,verifiedAt:s.string().datetime({offset:!0})}).strict(),S=s.object({tenantId:a,workspaceId:a,spaceId:a}).strict(),z=s.object({grantRef:a,accessToken:s.string().min(16).max(8192),realtimeTicket:s.string().min(16).max(8192),principalRef:a,scope:S,binding:d,inputDigest:s.string().regex(/^sha256:[a-f0-9]{64}$/),expiresAt:s.string().datetime({offset:!0}),capabilities:s.tuple([s.literal("messages:list"),s.literal("messages:send"),s.literal("realtime:ticket")])}).strict();function M(e){return C(e)}function w(e){return C(e)}export{E as COMMUNICATION_CUSTOMER_LIVE_CHAT_CAPABILITIES,P as COMMUNICATION_CUSTOMER_LIVE_CHAT_GRANT_CAPABILITY,D as COMMUNICATION_CUSTOMER_LIVE_CHAT_VERIFY_CAPABILITY,d as CommunicationCustomerLiveChatBindingSchema,G as CommunicationCustomerLiveChatGrantRequestSchema,z as CommunicationCustomerLiveChatGrantResponseSchema,S as CommunicationCustomerLiveChatGrantScopeSchema,L as CommunicationCustomerLiveChatVerificationRequestSchema,N as CommunicationCustomerLiveChatVerificationResponseSchema,M as digestCommunicationCustomerLiveChatGrantInput,w as digestCommunicationCustomerLiveChatVerificationInput};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CommunicationDeliveryRouteV1 } from './channel-routing.js';
|
|
3
|
+
import type { CommunicationDeliveryIntentV1 } from './delivery-intent.js';
|
|
4
|
+
export declare const COMMUNICATION_DELIVERY_ELIGIBILITY_SCHEMA_VERSION: '1.0.0';
|
|
5
|
+
export declare const CommunicationDeliveryEligibilityCategoryV1Schema: z.ZodEnum<{
|
|
6
|
+
calendar_permission: "calendar_permission";
|
|
7
|
+
connection: "connection";
|
|
8
|
+
consent: "consent";
|
|
9
|
+
cost: "cost";
|
|
10
|
+
email_suppression: "email_suppression";
|
|
11
|
+
grant: "grant";
|
|
12
|
+
installation_membership: "installation_membership";
|
|
13
|
+
policy: "policy";
|
|
14
|
+
provider_health: "provider_health";
|
|
15
|
+
push_device: "push_device";
|
|
16
|
+
quiet_hours: "quiet_hours";
|
|
17
|
+
rate_limit: "rate_limit";
|
|
18
|
+
sms_opt_out: "sms_opt_out";
|
|
19
|
+
telegram_first_contact: "telegram_first_contact";
|
|
20
|
+
whatsapp_service_window: "whatsapp_service_window";
|
|
21
|
+
whatsapp_template: "whatsapp_template";
|
|
22
|
+
}>;
|
|
23
|
+
export declare const CommunicationDeliveryEligibilityCheckV1Schema: z.ZodObject<{
|
|
24
|
+
checkRef: z.ZodString;
|
|
25
|
+
category: z.ZodEnum<{
|
|
26
|
+
calendar_permission: "calendar_permission";
|
|
27
|
+
connection: "connection";
|
|
28
|
+
consent: "consent";
|
|
29
|
+
cost: "cost";
|
|
30
|
+
email_suppression: "email_suppression";
|
|
31
|
+
grant: "grant";
|
|
32
|
+
installation_membership: "installation_membership";
|
|
33
|
+
policy: "policy";
|
|
34
|
+
provider_health: "provider_health";
|
|
35
|
+
push_device: "push_device";
|
|
36
|
+
quiet_hours: "quiet_hours";
|
|
37
|
+
rate_limit: "rate_limit";
|
|
38
|
+
sms_opt_out: "sms_opt_out";
|
|
39
|
+
telegram_first_contact: "telegram_first_contact";
|
|
40
|
+
whatsapp_service_window: "whatsapp_service_window";
|
|
41
|
+
whatsapp_template: "whatsapp_template";
|
|
42
|
+
}>;
|
|
43
|
+
status: z.ZodEnum<{
|
|
44
|
+
failed: "failed";
|
|
45
|
+
not_applicable: "not_applicable";
|
|
46
|
+
passed: "passed";
|
|
47
|
+
unknown: "unknown";
|
|
48
|
+
}>;
|
|
49
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
50
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
/** Evidence-only eligibility decision. It never authorizes a provider effect. */
|
|
53
|
+
export declare const CommunicationDeliveryEligibilityDecisionV1Schema: z.ZodObject<{
|
|
54
|
+
schemaVersion: z.ZodLiteral<"1.0.0">;
|
|
55
|
+
eligibilityRef: z.ZodString;
|
|
56
|
+
eligibilityDigest: z.ZodString;
|
|
57
|
+
deliveryRef: z.ZodString;
|
|
58
|
+
intent: z.ZodObject<{
|
|
59
|
+
ref: z.ZodString;
|
|
60
|
+
digest: z.ZodString;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
scope: z.ZodObject<{
|
|
63
|
+
tenantRef: z.ZodString;
|
|
64
|
+
workspaceRef: z.ZodOptional<z.ZodString>;
|
|
65
|
+
spaceRef: z.ZodOptional<z.ZodString>;
|
|
66
|
+
subjectRef: z.ZodString;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
recipientRef: z.ZodString;
|
|
69
|
+
route: z.ZodObject<{
|
|
70
|
+
ref: z.ZodString;
|
|
71
|
+
digest: z.ZodString;
|
|
72
|
+
revision: z.ZodNumber;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
channel: z.ZodString;
|
|
75
|
+
semantic: z.ZodEnum<{
|
|
76
|
+
calendar_event: "calendar_event";
|
|
77
|
+
communication: "communication";
|
|
78
|
+
}>;
|
|
79
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
80
|
+
checkRef: z.ZodString;
|
|
81
|
+
category: z.ZodEnum<{
|
|
82
|
+
calendar_permission: "calendar_permission";
|
|
83
|
+
connection: "connection";
|
|
84
|
+
consent: "consent";
|
|
85
|
+
cost: "cost";
|
|
86
|
+
email_suppression: "email_suppression";
|
|
87
|
+
grant: "grant";
|
|
88
|
+
installation_membership: "installation_membership";
|
|
89
|
+
policy: "policy";
|
|
90
|
+
provider_health: "provider_health";
|
|
91
|
+
push_device: "push_device";
|
|
92
|
+
quiet_hours: "quiet_hours";
|
|
93
|
+
rate_limit: "rate_limit";
|
|
94
|
+
sms_opt_out: "sms_opt_out";
|
|
95
|
+
telegram_first_contact: "telegram_first_contact";
|
|
96
|
+
whatsapp_service_window: "whatsapp_service_window";
|
|
97
|
+
whatsapp_template: "whatsapp_template";
|
|
98
|
+
}>;
|
|
99
|
+
status: z.ZodEnum<{
|
|
100
|
+
failed: "failed";
|
|
101
|
+
not_applicable: "not_applicable";
|
|
102
|
+
passed: "passed";
|
|
103
|
+
unknown: "unknown";
|
|
104
|
+
}>;
|
|
105
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
106
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
result: z.ZodEnum<{
|
|
109
|
+
eligible: "eligible";
|
|
110
|
+
ineligible: "ineligible";
|
|
111
|
+
unknown: "unknown";
|
|
112
|
+
}>;
|
|
113
|
+
effectAuthority: z.ZodLiteral<"none">;
|
|
114
|
+
evaluatedAt: z.ZodString;
|
|
115
|
+
expiresAt: z.ZodString;
|
|
116
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
export type CommunicationDeliveryEligibilityCategoryV1 = z.infer<typeof CommunicationDeliveryEligibilityCategoryV1Schema>;
|
|
119
|
+
export type CommunicationDeliveryEligibilityCheckV1 = z.infer<typeof CommunicationDeliveryEligibilityCheckV1Schema>;
|
|
120
|
+
export type CommunicationDeliveryEligibilityDecisionV1 = z.infer<typeof CommunicationDeliveryEligibilityDecisionV1Schema>;
|
|
121
|
+
/** Pure replay binding validation across the route, intent, and decision. */
|
|
122
|
+
export declare function validateCommunicationDeliveryEligibilityBindingV1(input: {
|
|
123
|
+
decision: CommunicationDeliveryEligibilityDecisionV1;
|
|
124
|
+
intent: CommunicationDeliveryIntentV1;
|
|
125
|
+
route: CommunicationDeliveryRouteV1;
|
|
126
|
+
}): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{z as a}from"zod";import{z as s}from"zod";var S="1.0.0",V="1.0.0",x={id:"communication-os.agent-omnichannel.v1",title:"CommunicationOS agent omnichannel contracts",body:"Provider-neutral agent profiles and lifecycle links bind applications, runs, tasks, help requests, background results, routes, preferences, policies, and evidence through opaque references. They grant no provider access or effect authority.",kind:"reference",route:"/docs/communication-os/agent-omnichannel-v1",visibility:"public"},o=s.string().trim().min(1),v=s.string().datetime({offset:!0}),p=s.string().regex(/^sha256:[a-f0-9]{64}$/),h=s.object({ref:o,digest:p}).strict(),u=h.extend({revision:s.number().int().positive()}).strict(),f=s.object({tenantRef:o,workspaceRef:o.optional(),spaceRef:o.optional(),subjectRef:o}).strict(),L=s.object({schemaVersion:s.literal(S),profileRef:o,revision:s.number().int().positive(),agentRef:o,applicationRef:o,scope:f,routeBindings:s.array(u),connectionRefs:s.array(o),preferenceSet:u,policyRefs:s.array(o).min(1),evidenceRefs:s.array(o).min(1),createdAt:v,updatedAt:v,profileDigest:p}).strict().superRefine((e,i)=>{for(let n of["connectionRefs","policyRefs","evidenceRefs"])if(new Set(e[n]).size!==e[n].length)i.addIssue({code:s.ZodIssueCode.custom,path:[n],message:`${n} must be unique`});let t=e.routeBindings.map((n)=>n.ref);if(new Set(t).size!==t.length)i.addIssue({code:s.ZodIssueCode.custom,path:["routeBindings"],message:"route bindings must be unique"})}),w=s.object({schemaVersion:s.literal(V),linkRef:o,profile:u,agentRef:o,applicationRef:o,scope:f,runRef:o.optional(),taskRef:o.optional(),helpRequestRef:o.optional(),approvalRequestRef:o.optional(),backgroundResultRef:o.optional(),canonicalConversation:h.optional(),session:u.optional(),correlationRef:o,evidenceRefs:s.array(o).min(1)}).strict().superRefine((e,i)=>{if(new Set(e.evidenceRefs).size!==e.evidenceRefs.length)i.addIssue({code:s.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"});if(!e.runRef&&!e.taskRef&&!e.helpRequestRef&&!e.approvalRequestRef&&!e.backgroundResultRef)i.addIssue({code:s.ZodIssueCode.custom,path:["runRef"],message:"at least one run, task, help request, approval request, or background result ref is required"})});function d(e,i){return e.tenantRef===i.tenantRef&&e.workspaceRef===i.workspaceRef&&e.spaceRef===i.spaceRef&&e.subjectRef===i.subjectRef}function B(e){let i=[];for(let t of["agentRef","applicationRef"])if(e.profile[t]!==e.lifecycleLink[t])i.push(`Lifecycle ${t} does not match the agent profile`);if(e.lifecycleLink.profile.ref!==e.profile.profileRef||e.lifecycleLink.profile.revision!==e.profile.revision||e.lifecycleLink.profile.digest!==e.profile.profileDigest)i.push("Lifecycle profile binding does not match the agent profile");if(!d(e.profile.scope,e.lifecycleLink.scope))i.push("Lifecycle scope does not match the agent profile");return i}function N(e){let{intent:i,progress:t}=e,n=[];if(t.deliveryRef!==i.deliveryRef||t.intent.ref!==i.deliveryRef||t.intent.digest!==i.deliveryDigest)n.push("Progress delivery does not match the intent");if(!d(t.scope,i.scope))n.push("Progress scope does not match the intent");if(t.recipientRef!==i.recipientRefs[0])n.push("Progress recipient does not match the intent");let r=i.requestedRoutes.find((c)=>c.ref===t.route.ref);if(!r||r.revision!==t.route.revision||r.digest!==t.route.digest)n.push("Progress route was not requested by the intent");if(Date.parse(t.occurredAt)<Date.parse(i.createdAt)||Date.parse(t.occurredAt)>Date.parse(i.expiresAt))n.push("Progress occurred outside the intent validity window");return n}import{z as m}from"zod";var D="1.0.0",I=["email","calendar","sms","slack","teams","discord","telegram","whatsapp","matrix","in_app","push","webhook","web_chat","internal_chat"],g=m.string().trim().min(1),M=m.enum(I),C=m.enum(["communication","calendar_event"]),y=m.string().trim().min(1),P=m.object({schemaVersion:m.literal(D),routeRef:y,revision:m.number().int().positive(),scope:f,channel:g,destinationRef:y,connectionRef:y.optional(),semantic:C,deliveryMode:m.enum(["direct","durable_in_app"]),capabilityRefs:m.array(y),evidenceRefs:m.array(y).min(1),routeDigest:p}).strict().superRefine((e,i)=>{if(e.channel==="calendar"!==(e.semantic==="calendar_event"))i.addIssue({code:m.ZodIssueCode.custom,path:["semantic"],message:"calendar routes require calendar_event semantics and calendar_event routes require the calendar channel"});for(let t of["capabilityRefs","evidenceRefs"])if(new Set(e[t]).size!==e[t].length)i.addIssue({code:m.ZodIssueCode.custom,path:[t],message:`${t} must be unique`})});var A="1.0.0",l=a.string().trim().min(1),b=a.string().datetime({offset:!0}),k=a.enum(["connection","consent","policy","grant","quiet_hours","rate_limit","provider_health","whatsapp_service_window","whatsapp_template","telegram_first_contact","installation_membership","sms_opt_out","email_suppression","push_device","calendar_permission","cost"]),_=a.object({checkRef:l,category:k,status:a.enum(["passed","failed","unknown","not_applicable"]),reasonCodes:a.array(l).min(1),evidenceRefs:a.array(l).min(1)}).strict().superRefine((e,i)=>{for(let t of["reasonCodes","evidenceRefs"])if(new Set(e[t]).size!==e[t].length)i.addIssue({code:a.ZodIssueCode.custom,path:[t],message:`${t} must be unique`})}),H=a.object({schemaVersion:a.literal(A),eligibilityRef:l,eligibilityDigest:p,deliveryRef:l,intent:h,scope:f,recipientRef:l,route:u,channel:g,semantic:C,checks:a.array(_).min(1),result:a.enum(["eligible","ineligible","unknown"]),effectAuthority:a.literal("none"),evaluatedAt:b,expiresAt:b,evidenceRefs:a.array(l).min(1)}).strict().superRefine((e,i)=>{let t=e.checks.map((c)=>c.checkRef),n=e.checks.map((c)=>c.category);for(let[c,R]of[["checks",t],["checks",n],["evidenceRefs",e.evidenceRefs]])if(new Set(R).size!==R.length)i.addIssue({code:a.ZodIssueCode.custom,path:[c],message:`${c} must be unique`});let r=e.checks.some((c)=>c.status==="failed")?"ineligible":e.checks.some((c)=>c.status==="unknown")?"unknown":"eligible";if(e.result!==r)i.addIssue({code:a.ZodIssueCode.custom,path:["result"],message:"result must be derived from all eligibility checks"});if(e.checks.every((c)=>c.status==="not_applicable"))i.addIssue({code:a.ZodIssueCode.custom,path:["checks"],message:"at least one eligibility check must be applicable"});if(Date.parse(e.expiresAt)<=Date.parse(e.evaluatedAt))i.addIssue({code:a.ZodIssueCode.custom,path:["expiresAt"],message:"expiresAt must be later than evaluatedAt"})});function U(e){let{decision:i,intent:t,route:n}=e,r=[];if(i.deliveryRef!==t.deliveryRef||i.intent.ref!==t.deliveryRef||i.intent.digest!==t.deliveryDigest)r.push("Eligibility decision does not bind the delivery intent");if(i.route.ref!==n.routeRef||i.route.revision!==n.revision||i.route.digest!==n.routeDigest||!t.requestedRoutes.some((c)=>c.ref===n.routeRef&&c.revision===n.revision&&c.digest===n.routeDigest))r.push("Eligibility decision does not bind a requested route");if(!d(i.scope,t.scope)||!d(i.scope,n.scope))r.push("Eligibility scope does not match the intent and route");if(i.recipientRef!==t.recipientRefs[0]||i.channel!==n.channel||i.semantic!==n.semantic||i.semantic!==t.semantic)r.push("Eligibility recipient or route semantics do not match");if(Date.parse(i.evaluatedAt)<Date.parse(t.createdAt)||Date.parse(i.expiresAt)>Date.parse(t.expiresAt))r.push("Eligibility decision is outside the intent validity window");return r}export{A as COMMUNICATION_DELIVERY_ELIGIBILITY_SCHEMA_VERSION,k as CommunicationDeliveryEligibilityCategoryV1Schema,_ as CommunicationDeliveryEligibilityCheckV1Schema,H as CommunicationDeliveryEligibilityDecisionV1Schema,U as validateCommunicationDeliveryEligibilityBindingV1};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommunicationDeliveryEligibilityDecisionV1 } from './delivery-eligibility.js';
|
|
2
|
+
import type { CommunicationFallbackDecisionV1 } from './delivery-fallback.js';
|
|
3
|
+
export declare function validateCommunicationFallbackEligibilityResultsV1(input: {
|
|
4
|
+
decision: CommunicationFallbackDecisionV1;
|
|
5
|
+
eligibilityDecisions: readonly CommunicationDeliveryEligibilityDecisionV1[];
|
|
6
|
+
}): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function s(l){let t=[],o=new Map(l.eligibilityDecisions.map((i)=>[i.eligibilityRef,i]));for(let i of l.decision.consideredRoutes){let e=o.get(i.eligibilityDecision.ref);if(!e||e.eligibilityDigest!==i.eligibilityDecision.digest||e.result!==i.eligibility)t.push(`Fallback eligibility result is stale: ${i.route.ref}`)}return t}export{s as validateCommunicationFallbackEligibilityResultsV1};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CommunicationPreferenceSetV1 } from './channel-preferences.js';
|
|
2
|
+
import type { CommunicationDeliveryRouteV1 } from './channel-routing.js';
|
|
3
|
+
import type { CommunicationDeliveryEligibilityDecisionV1 } from './delivery-eligibility.js';
|
|
4
|
+
import type { CommunicationFallbackDecisionV1 } from './delivery-fallback.js';
|
|
5
|
+
import type { CommunicationDeliveryIntentV1 } from './delivery-intent.js';
|
|
6
|
+
import type { CommunicationDeliveryProgressV1 } from './delivery-progress.js';
|
|
7
|
+
import { type CommunicationPreferenceResolutionResultV1 } from './preference-resolution.js';
|
|
8
|
+
export declare function validateCommunicationFallbackPriorOutcomeBindingV1(input: {
|
|
9
|
+
decision: CommunicationFallbackDecisionV1;
|
|
10
|
+
priorProgress?: CommunicationDeliveryProgressV1;
|
|
11
|
+
}): string[];
|
|
12
|
+
export declare function validateCommunicationFallbackConsiderationsV1(input: {
|
|
13
|
+
decision: CommunicationFallbackDecisionV1;
|
|
14
|
+
orderedRouteRefs: readonly string[];
|
|
15
|
+
}): string[];
|
|
16
|
+
export declare function validateCommunicationFallbackBindingV1(input: {
|
|
17
|
+
decision: CommunicationFallbackDecisionV1;
|
|
18
|
+
intent: CommunicationDeliveryIntentV1;
|
|
19
|
+
priorProgress?: CommunicationDeliveryProgressV1;
|
|
20
|
+
preferenceResolution: CommunicationPreferenceResolutionResultV1;
|
|
21
|
+
preferenceSet: CommunicationPreferenceSetV1;
|
|
22
|
+
routes: readonly CommunicationDeliveryRouteV1[];
|
|
23
|
+
eligibilityDecisions?: readonly CommunicationDeliveryEligibilityDecisionV1[];
|
|
24
|
+
}): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{z as c}from"zod";var q="1.0.0",L="1.0.0",G={id:"communication-os.agent-omnichannel.v1",title:"CommunicationOS agent omnichannel contracts",body:"Provider-neutral agent profiles and lifecycle links bind applications, runs, tasks, help requests, background results, routes, preferences, policies, and evidence through opaque references. They grant no provider access or effect authority.",kind:"reference",route:"/docs/communication-os/agent-omnichannel-v1",visibility:"public"},s=c.string().trim().min(1),E=c.string().datetime({offset:!0}),b=c.string().regex(/^sha256:[a-f0-9]{64}$/),x=c.object({ref:s,digest:b}).strict(),v=x.extend({revision:c.number().int().positive()}).strict(),S=c.object({tenantRef:s,workspaceRef:s.optional(),spaceRef:s.optional(),subjectRef:s}).strict(),H=c.object({schemaVersion:c.literal(q),profileRef:s,revision:c.number().int().positive(),agentRef:s,applicationRef:s,scope:S,routeBindings:c.array(v),connectionRefs:c.array(s),preferenceSet:v,policyRefs:c.array(s).min(1),evidenceRefs:c.array(s).min(1),createdAt:E,updatedAt:E,profileDigest:b}).strict().superRefine((i,e)=>{for(let n of["connectionRefs","policyRefs","evidenceRefs"])if(new Set(i[n]).size!==i[n].length)e.addIssue({code:c.ZodIssueCode.custom,path:[n],message:`${n} must be unique`});let t=i.routeBindings.map((n)=>n.ref);if(new Set(t).size!==t.length)e.addIssue({code:c.ZodIssueCode.custom,path:["routeBindings"],message:"route bindings must be unique"})}),Y=c.object({schemaVersion:c.literal(L),linkRef:s,profile:v,agentRef:s,applicationRef:s,scope:S,runRef:s.optional(),taskRef:s.optional(),helpRequestRef:s.optional(),approvalRequestRef:s.optional(),backgroundResultRef:s.optional(),canonicalConversation:x.optional(),session:v.optional(),correlationRef:s,evidenceRefs:c.array(s).min(1)}).strict().superRefine((i,e)=>{if(new Set(i.evidenceRefs).size!==i.evidenceRefs.length)e.addIssue({code:c.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"});if(!i.runRef&&!i.taskRef&&!i.helpRequestRef&&!i.approvalRequestRef&&!i.backgroundResultRef)e.addIssue({code:c.ZodIssueCode.custom,path:["runRef"],message:"at least one run, task, help request, approval request, or background result ref is required"})});function m(i,e){return i.tenantRef===e.tenantRef&&i.workspaceRef===e.workspaceRef&&i.spaceRef===e.spaceRef&&i.subjectRef===e.subjectRef}function J(i){let e=[];for(let t of["agentRef","applicationRef"])if(i.profile[t]!==i.lifecycleLink[t])e.push(`Lifecycle ${t} does not match the agent profile`);if(i.lifecycleLink.profile.ref!==i.profile.profileRef||i.lifecycleLink.profile.revision!==i.profile.revision||i.lifecycleLink.profile.digest!==i.profile.profileDigest)e.push("Lifecycle profile binding does not match the agent profile");if(!m(i.profile.scope,i.lifecycleLink.scope))e.push("Lifecycle scope does not match the agent profile");return e}function A(i){let{intent:e,progress:t}=i,n=[];if(t.deliveryRef!==e.deliveryRef||t.intent.ref!==e.deliveryRef||t.intent.digest!==e.deliveryDigest)n.push("Progress delivery does not match the intent");if(!m(t.scope,e.scope))n.push("Progress scope does not match the intent");if(t.recipientRef!==e.recipientRefs[0])n.push("Progress recipient does not match the intent");let o=e.requestedRoutes.find((f)=>f.ref===t.route.ref);if(!o||o.revision!==t.route.revision||o.digest!==t.route.digest)n.push("Progress route was not requested by the intent");if(Date.parse(t.occurredAt)<Date.parse(e.createdAt)||Date.parse(t.occurredAt)>Date.parse(e.expiresAt))n.push("Progress occurred outside the intent validity window");return n}function I(i){let e=[],t=new Map(i.eligibilityDecisions.map((n)=>[n.eligibilityRef,n]));for(let n of i.decision.consideredRoutes){let o=t.get(n.eligibilityDecision.ref);if(!o||o.eligibilityDigest!==n.eligibilityDecision.digest||o.result!==n.eligibility)e.push(`Fallback eligibility result is stale: ${n.route.ref}`)}return e}import{z as a}from"zod";var N="1.0.0",z="communication:preference-target:platform-default",ie=[["event","automation"],["feature","application"],["product"],["space","person"],["platform_default"]],te=a.enum(["event","automation","feature","application","product","space","person","platform_default"]),y=a.string().trim().min(1);function g(i){return a.object({kind:a.literal(i),ref:y}).strict()}var F=a.discriminatedUnion("kind",[g("event"),g("automation"),g("feature"),g("application"),g("product"),g("space"),g("person"),a.object({kind:a.literal("platform_default"),ref:a.literal(z)}).strict()]),M=a.object({preferenceSetRef:y,revision:a.number().int().positive(),digest:b,target:F}).strict(),ne=a.object({schemaVersion:a.literal(N),resolutionRef:y,scope:S,subjectRef:y,evaluatedPreferenceSets:a.array(M).min(1),winningPreferenceSetRef:y,winningTarget:F,authority:a.literal("preference_only"),effectAuthority:a.literal("none"),resolvedAt:a.string().datetime({offset:!0}),evidenceRefs:a.array(y).min(1),resolutionDigest:b}).strict().superRefine((i,e)=>{let t=i.evaluatedPreferenceSets.map((o)=>o.preferenceSetRef);if(new Set(t).size!==t.length)R(e,"evaluatedPreferenceSets","evaluated sets must be unique");if(new Set(i.evidenceRefs).size!==i.evidenceRefs.length)R(e,"evidenceRefs","evidenceRefs must be unique");for(let o=1;o<i.evaluatedPreferenceSets.length;o+=1){let f=i.evaluatedPreferenceSets[o-1],r=i.evaluatedPreferenceSets[o];if(f&&r&&_(f.target.kind)>_(r.target.kind)){R(e,"evaluatedPreferenceSets","evaluated sets must follow the preference resolution hierarchy");break}}let n=i.evaluatedPreferenceSets.find((o)=>o.preferenceSetRef===i.winningPreferenceSetRef);if(!n)R(e,"winningPreferenceSetRef","winning preference set must have been evaluated");else if(n.preferenceSetRef!==i.evaluatedPreferenceSets[0]?.preferenceSetRef)R(e,"winningPreferenceSetRef","winning preference set must be the most specific evaluated set");else if(n.target.kind!==i.winningTarget.kind||n.target.ref!==i.winningTarget.ref)R(e,"winningTarget","winning target must match the winning preference set")});function _(i){switch(i){case"event":case"automation":return 0;case"feature":case"application":return 1;case"product":return 2;case"space":case"person":return 3;case"platform_default":return 4}}function R(i,e,t){i.addIssue({code:a.ZodIssueCode.custom,path:[e],message:t})}function w(i){let{preferenceResolution:e,preferenceSet:t}=i,n=[];if(e.subjectRef!==t.scope.subjectRef||e.winningPreferenceSetRef!==t.preferenceSetRef)n.push("Preference resolution does not match its subject and set");if(!m(e.scope,t.scope))n.push("Preference resolution scope does not match its preference set");let o=e.evaluatedPreferenceSets.find((f)=>f.preferenceSetRef===t.preferenceSetRef);if(!o||o.revision!==t.revision||o.digest!==t.preferenceSetDigest)n.push("Preference resolution binding is stale");if(e.winningTarget.kind!==t.target.kind||e.winningTarget.ref!==t.target.ref)n.push("Preference resolution target does not match its preference set");return n}function j(i){let{decision:e,priorProgress:t}=i,n=[];if(e.priorOutcome!=="not_attempted"!==Boolean(t))n.push("Fallback prior outcome and progress presence do not match");if(!t)return n;if(e.priorAttemptRef!==t.attemptRef)n.push("Fallback prior attempt does not match progress");if(e.priorProgress?.ref!==t.progressRef||e.priorProgress?.digest!==t.progressDigest)n.push("Fallback prior progress binding does not match");let o=e.priorOutcome==="definitive_failure"?"failed":"ambiguous";if(t.status!==o)n.push("Fallback prior outcome does not match progress status");if((e.priorOutcome==="ambiguous"||e.priorOutcome==="reconciled_failure")&&(t.reconciliation?.ref!==e.reconciliation.binding?.ref||t.reconciliation?.digest!==e.reconciliation.binding?.digest))n.push("Fallback reconciliation does not match ambiguous progress");return n}function U(i){let e=[],t=new Map(i.decision.eligibilityDecisions.map((n)=>[n.ref,n.digest]));if(t.size!==i.decision.consideredRoutes.length||i.decision.consideredRoutes.some((n)=>t.get(n.eligibilityDecision.ref)!==n.eligibilityDecision.digest))e.push("Fallback eligibility evidence must exactly match considerations");for(let[n,o]of i.decision.consideredRoutes.entries())if(t.get(o.eligibilityDecision.ref)!==o.eligibilityDecision.digest)e.push(`Fallback route ${o.route.ref} lacks eligibility evidence`);else if(i.orderedRouteRefs[n]!==o.route.ref){e.push("Fallback considerations do not follow the configured order");break}return e}function ae(i){let{decision:e,intent:t,priorProgress:n,preferenceResolution:o,preferenceSet:f}=i,r=[];if(e.deliveryRef!==t.deliveryRef||e.intent.ref!==t.deliveryRef||e.intent.digest!==t.deliveryDigest)r.push("Fallback delivery does not match the intent");if(!m(e.scope,t.scope))r.push("Fallback scope does not match the intent");if(e.preferenceSet.ref!==t.preferenceSet.ref||e.preferenceSet.revision!==t.preferenceSet.revision||e.preferenceSet.digest!==t.preferenceSet.digest||e.preferenceSet.ref!==f.preferenceSetRef||e.preferenceSet.revision!==f.revision||e.preferenceSet.digest!==f.preferenceSetDigest)r.push("Fallback preferences do not match the intent and resolution");if(r.push(...w({preferenceResolution:o,preferenceSet:f})),i.eligibilityDecisions)r.push(...I({decision:e,eligibilityDecisions:i.eligibilityDecisions}));if(t.preferenceResolution.ref!==o.resolutionRef||t.preferenceResolution.digest!==o.resolutionDigest)r.push("Fallback preference resolution does not match the intent");let h=new Map(i.routes.map((l)=>[l.routeRef,l]));for(let l of e.consideredRoutes){let d=h.get(l.route.ref);if(!d||l.route.revision!==d.revision||l.route.digest!==d.routeDigest||!m(e.scope,d.scope))r.push(`Fallback route binding is stale: ${l.route.ref}`)}if(!m(e.scope,f.scope))r.push("Fallback scope does not match the preference set");if(r.push(...j({decision:e,priorProgress:n}),...U({decision:e,orderedRouteRefs:t.requestedRoutes.map((l)=>l.ref)})),n)r.push(...A({intent:t,progress:n}));if(e.recipientRef!==t.recipientRefs[0])r.push("Fallback recipient does not match the intent");if(K(i,r),e.policyRefs.some((l)=>!t.policyRefs.includes(l)))r.push("Fallback policy is not bound to the delivery intent");return r}function K(i,e){let{decision:t,intent:n,preferenceSet:o,priorProgress:f}=i;if(t.state!=="selected"||!t.selectedRoute)return;let r=t.selectedRoute.ref,h=n.requestedRoutes.map((u)=>u.ref),l=h.indexOf(r),d=o.routePreferences.find((u)=>u.routeRef===r),p=i.routes.find((u)=>u.routeRef===r),C=n.requestedRoutes.find((u)=>u.ref===r),P=f?h.indexOf(f.route.ref):-1,T=t.consideredRoutes.find((u)=>{let D=i.routes.find((V)=>V.routeRef===u.route.ref),B=o.routePreferences.find((V)=>V.routeRef===u.route.ref),O=n.noticeClass==="mandatory_notice"&&D?.channel==="in_app"&&D.deliveryMode==="durable_in_app";return u.eligibility==="eligible"&&h.indexOf(u.route.ref)>P&&(o.globalEnabled&&B?.enabled||O)}),k=n.noticeClass==="mandatory_notice"&&p?.channel==="in_app"&&p?.deliveryMode==="durable_in_app";if(!o.globalEnabled&&!k||!o.fallback.enabled||l<0||!o.fallback.orderedRouteRefs.includes(r)||!C||!d?.enabled&&!k||!p||p?.channel!==d?.channel||p.semantic!==n.semantic)e.push("Selected fallback route is not requested and eligible by configuration");if(t.selectedRoute.revision!==p?.revision||t.selectedRoute.digest!==p?.routeDigest||C?.revision!==p?.revision||C?.digest!==p?.routeDigest)e.push("Selected fallback route binding is stale");if(d?.consentRef&&!n.consentRefs.includes(d.consentRef))e.push("Selected fallback route lacks required consent");if(T?.route.ref!==r||t.consideredRoutes.length!==l+1)e.push("Selected fallback route is not the first eligible ordered route");if(f&&P>=l)e.push("Selected fallback route does not follow the prior attempt")}export{ae as validateCommunicationFallbackBindingV1,U as validateCommunicationFallbackConsiderationsV1,j as validateCommunicationFallbackPriorOutcomeBindingV1};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const COMMUNICATION_FALLBACK_DECISION_SCHEMA_VERSION: '1.0.0';
|
|
3
|
+
export declare const CommunicationFallbackRouteConsiderationV1Schema: z.ZodObject<{
|
|
4
|
+
route: z.ZodObject<{
|
|
5
|
+
ref: z.ZodString;
|
|
6
|
+
digest: z.ZodString;
|
|
7
|
+
revision: z.ZodNumber;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
eligibility: z.ZodEnum<{
|
|
10
|
+
eligible: "eligible";
|
|
11
|
+
ineligible: "ineligible";
|
|
12
|
+
unknown: "unknown";
|
|
13
|
+
}>;
|
|
14
|
+
eligibilityDecision: z.ZodObject<{
|
|
15
|
+
ref: z.ZodString;
|
|
16
|
+
digest: z.ZodString;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const CommunicationFallbackReconciliationV1Schema: z.ZodObject<{
|
|
21
|
+
status: z.ZodEnum<{
|
|
22
|
+
not_required: "not_required";
|
|
23
|
+
pending: "pending";
|
|
24
|
+
resolved: "resolved";
|
|
25
|
+
}>;
|
|
26
|
+
binding: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
ref: z.ZodString;
|
|
28
|
+
digest: z.ZodString;
|
|
29
|
+
}, z.core.$strict>>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
/**
|
|
32
|
+
* A deterministic decision artifact. It cannot execute the selected route and
|
|
33
|
+
* fails closed while any prior provider outcome remains ambiguous.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CommunicationFallbackDecisionV1Schema: z.ZodObject<{
|
|
36
|
+
schemaVersion: z.ZodLiteral<"1.0.0">;
|
|
37
|
+
decisionRef: z.ZodString;
|
|
38
|
+
fallbackDecisionDigest: z.ZodString;
|
|
39
|
+
deliveryRef: z.ZodString;
|
|
40
|
+
intent: z.ZodObject<{
|
|
41
|
+
ref: z.ZodString;
|
|
42
|
+
digest: z.ZodString;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
scope: z.ZodObject<{
|
|
45
|
+
tenantRef: z.ZodString;
|
|
46
|
+
workspaceRef: z.ZodOptional<z.ZodString>;
|
|
47
|
+
spaceRef: z.ZodOptional<z.ZodString>;
|
|
48
|
+
subjectRef: z.ZodString;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
recipientRef: z.ZodString;
|
|
51
|
+
priorAttemptRef: z.ZodOptional<z.ZodString>;
|
|
52
|
+
priorProgress: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
ref: z.ZodString;
|
|
54
|
+
digest: z.ZodString;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
priorOutcome: z.ZodEnum<{
|
|
57
|
+
ambiguous: "ambiguous";
|
|
58
|
+
definitive_failure: "definitive_failure";
|
|
59
|
+
not_attempted: "not_attempted";
|
|
60
|
+
reconciled_failure: "reconciled_failure";
|
|
61
|
+
}>;
|
|
62
|
+
state: z.ZodEnum<{
|
|
63
|
+
fail_closed: "fail_closed";
|
|
64
|
+
not_required: "not_required";
|
|
65
|
+
selected: "selected";
|
|
66
|
+
}>;
|
|
67
|
+
consideredRoutes: z.ZodArray<z.ZodObject<{
|
|
68
|
+
route: z.ZodObject<{
|
|
69
|
+
ref: z.ZodString;
|
|
70
|
+
digest: z.ZodString;
|
|
71
|
+
revision: z.ZodNumber;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
eligibility: z.ZodEnum<{
|
|
74
|
+
eligible: "eligible";
|
|
75
|
+
ineligible: "ineligible";
|
|
76
|
+
unknown: "unknown";
|
|
77
|
+
}>;
|
|
78
|
+
eligibilityDecision: z.ZodObject<{
|
|
79
|
+
ref: z.ZodString;
|
|
80
|
+
digest: z.ZodString;
|
|
81
|
+
}, z.core.$strict>;
|
|
82
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
selectedRoute: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
ref: z.ZodString;
|
|
86
|
+
digest: z.ZodString;
|
|
87
|
+
revision: z.ZodNumber;
|
|
88
|
+
}, z.core.$strict>>;
|
|
89
|
+
preferenceSet: z.ZodObject<{
|
|
90
|
+
ref: z.ZodString;
|
|
91
|
+
digest: z.ZodString;
|
|
92
|
+
revision: z.ZodNumber;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
eligibilityDecisions: z.ZodArray<z.ZodObject<{
|
|
95
|
+
ref: z.ZodString;
|
|
96
|
+
digest: z.ZodString;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
policyRefs: z.ZodArray<z.ZodString>;
|
|
99
|
+
reconciliation: z.ZodObject<{
|
|
100
|
+
status: z.ZodEnum<{
|
|
101
|
+
not_required: "not_required";
|
|
102
|
+
pending: "pending";
|
|
103
|
+
resolved: "resolved";
|
|
104
|
+
}>;
|
|
105
|
+
binding: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
ref: z.ZodString;
|
|
107
|
+
digest: z.ZodString;
|
|
108
|
+
}, z.core.$strict>>;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
effectAuthority: z.ZodLiteral<"none">;
|
|
111
|
+
decidedAt: z.ZodString;
|
|
112
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
export type CommunicationFallbackRouteConsiderationV1 = z.infer<typeof CommunicationFallbackRouteConsiderationV1Schema>;
|
|
115
|
+
export type CommunicationFallbackReconciliationV1 = z.infer<typeof CommunicationFallbackReconciliationV1Schema>;
|
|
116
|
+
export type CommunicationFallbackDecisionV1 = z.infer<typeof CommunicationFallbackDecisionV1Schema>;
|
|
117
|
+
export { validateCommunicationFallbackBindingV1, validateCommunicationFallbackConsiderationsV1, validateCommunicationFallbackPriorOutcomeBindingV1, } from './delivery-fallback-validation.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{z as l}from"zod";import{z as a}from"zod";var j="1.0.0",U="1.0.0",ee={id:"communication-os.agent-omnichannel.v1",title:"CommunicationOS agent omnichannel contracts",body:"Provider-neutral agent profiles and lifecycle links bind applications, runs, tasks, help requests, background results, routes, preferences, policies, and evidence through opaque references. They grant no provider access or effect authority.",kind:"reference",route:"/docs/communication-os/agent-omnichannel-v1",visibility:"public"},c=a.string().trim().min(1),I=a.string().datetime({offset:!0}),h=a.string().regex(/^sha256:[a-f0-9]{64}$/),y=a.object({ref:c,digest:h}).strict(),R=y.extend({revision:a.number().int().positive()}).strict(),C=a.object({tenantRef:c,workspaceRef:c.optional(),spaceRef:c.optional(),subjectRef:c}).strict(),ie=a.object({schemaVersion:a.literal(j),profileRef:c,revision:a.number().int().positive(),agentRef:c,applicationRef:c,scope:C,routeBindings:a.array(R),connectionRefs:a.array(c),preferenceSet:R,policyRefs:a.array(c).min(1),evidenceRefs:a.array(c).min(1),createdAt:I,updatedAt:I,profileDigest:h}).strict().superRefine((e,i)=>{for(let n of["connectionRefs","policyRefs","evidenceRefs"])if(new Set(e[n]).size!==e[n].length)i.addIssue({code:a.ZodIssueCode.custom,path:[n],message:`${n} must be unique`});let t=e.routeBindings.map((n)=>n.ref);if(new Set(t).size!==t.length)i.addIssue({code:a.ZodIssueCode.custom,path:["routeBindings"],message:"route bindings must be unique"})}),te=a.object({schemaVersion:a.literal(U),linkRef:c,profile:R,agentRef:c,applicationRef:c,scope:C,runRef:c.optional(),taskRef:c.optional(),helpRequestRef:c.optional(),approvalRequestRef:c.optional(),backgroundResultRef:c.optional(),canonicalConversation:y.optional(),session:R.optional(),correlationRef:c,evidenceRefs:a.array(c).min(1)}).strict().superRefine((e,i)=>{if(new Set(e.evidenceRefs).size!==e.evidenceRefs.length)i.addIssue({code:a.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"});if(!e.runRef&&!e.taskRef&&!e.helpRequestRef&&!e.approvalRequestRef&&!e.backgroundResultRef)i.addIssue({code:a.ZodIssueCode.custom,path:["runRef"],message:"at least one run, task, help request, approval request, or background result ref is required"})});function b(e,i){return e.tenantRef===i.tenantRef&&e.workspaceRef===i.workspaceRef&&e.spaceRef===i.spaceRef&&e.subjectRef===i.subjectRef}function ne(e){let i=[];for(let t of["agentRef","applicationRef"])if(e.profile[t]!==e.lifecycleLink[t])i.push(`Lifecycle ${t} does not match the agent profile`);if(e.lifecycleLink.profile.ref!==e.profile.profileRef||e.lifecycleLink.profile.revision!==e.profile.revision||e.lifecycleLink.profile.digest!==e.profile.profileDigest)i.push("Lifecycle profile binding does not match the agent profile");if(!b(e.profile.scope,e.lifecycleLink.scope))i.push("Lifecycle scope does not match the agent profile");return i}function q(e){let{intent:i,progress:t}=e,n=[];if(t.deliveryRef!==i.deliveryRef||t.intent.ref!==i.deliveryRef||t.intent.digest!==i.deliveryDigest)n.push("Progress delivery does not match the intent");if(!b(t.scope,i.scope))n.push("Progress scope does not match the intent");if(t.recipientRef!==i.recipientRefs[0])n.push("Progress recipient does not match the intent");let o=i.requestedRoutes.find((s)=>s.ref===t.route.ref);if(!o||o.revision!==t.route.revision||o.digest!==t.route.digest)n.push("Progress route was not requested by the intent");if(Date.parse(t.occurredAt)<Date.parse(i.createdAt)||Date.parse(t.occurredAt)>Date.parse(i.expiresAt))n.push("Progress occurred outside the intent validity window");return n}function x(e){let i=[],t=new Map(e.eligibilityDecisions.map((n)=>[n.eligibilityRef,n]));for(let n of e.decision.consideredRoutes){let o=t.get(n.eligibilityDecision.ref);if(!o||o.eligibilityDigest!==n.eligibilityDecision.digest||o.result!==n.eligibility)i.push(`Fallback eligibility result is stale: ${n.route.ref}`)}return i}import{z as f}from"zod";var K="1.0.0",Z="communication:preference-target:platform-default",ae=[["event","automation"],["feature","application"],["product"],["space","person"],["platform_default"]],le=f.enum(["event","automation","feature","application","product","space","person","platform_default"]),V=f.string().trim().min(1);function v(e){return f.object({kind:f.literal(e),ref:V}).strict()}var w=f.discriminatedUnion("kind",[v("event"),v("automation"),v("feature"),v("application"),v("product"),v("space"),v("person"),f.object({kind:f.literal("platform_default"),ref:f.literal(Z)}).strict()]),H=f.object({preferenceSetRef:V,revision:f.number().int().positive(),digest:h,target:w}).strict(),fe=f.object({schemaVersion:f.literal(K),resolutionRef:V,scope:C,subjectRef:V,evaluatedPreferenceSets:f.array(H).min(1),winningPreferenceSetRef:V,winningTarget:w,authority:f.literal("preference_only"),effectAuthority:f.literal("none"),resolvedAt:f.string().datetime({offset:!0}),evidenceRefs:f.array(V).min(1),resolutionDigest:h}).strict().superRefine((e,i)=>{let t=e.evaluatedPreferenceSets.map((o)=>o.preferenceSetRef);if(new Set(t).size!==t.length)S(i,"evaluatedPreferenceSets","evaluated sets must be unique");if(new Set(e.evidenceRefs).size!==e.evidenceRefs.length)S(i,"evidenceRefs","evidenceRefs must be unique");for(let o=1;o<e.evaluatedPreferenceSets.length;o+=1){let s=e.evaluatedPreferenceSets[o-1],r=e.evaluatedPreferenceSets[o];if(s&&r&&O(s.target.kind)>O(r.target.kind)){S(i,"evaluatedPreferenceSets","evaluated sets must follow the preference resolution hierarchy");break}}let n=e.evaluatedPreferenceSets.find((o)=>o.preferenceSetRef===e.winningPreferenceSetRef);if(!n)S(i,"winningPreferenceSetRef","winning preference set must have been evaluated");else if(n.preferenceSetRef!==e.evaluatedPreferenceSets[0]?.preferenceSetRef)S(i,"winningPreferenceSetRef","winning preference set must be the most specific evaluated set");else if(n.target.kind!==e.winningTarget.kind||n.target.ref!==e.winningTarget.ref)S(i,"winningTarget","winning target must match the winning preference set")});function O(e){switch(e){case"event":case"automation":return 0;case"feature":case"application":return 1;case"product":return 2;case"space":case"person":return 3;case"platform_default":return 4}}function S(e,i,t){e.addIssue({code:f.ZodIssueCode.custom,path:[i],message:t})}function B(e){let{preferenceResolution:i,preferenceSet:t}=e,n=[];if(i.subjectRef!==t.scope.subjectRef||i.winningPreferenceSetRef!==t.preferenceSetRef)n.push("Preference resolution does not match its subject and set");if(!b(i.scope,t.scope))n.push("Preference resolution scope does not match its preference set");let o=i.evaluatedPreferenceSets.find((s)=>s.preferenceSetRef===t.preferenceSetRef);if(!o||o.revision!==t.revision||o.digest!==t.preferenceSetDigest)n.push("Preference resolution binding is stale");if(i.winningTarget.kind!==t.target.kind||i.winningTarget.ref!==t.target.ref)n.push("Preference resolution target does not match its preference set");return n}function T(e){let{decision:i,priorProgress:t}=e,n=[];if(i.priorOutcome!=="not_attempted"!==Boolean(t))n.push("Fallback prior outcome and progress presence do not match");if(!t)return n;if(i.priorAttemptRef!==t.attemptRef)n.push("Fallback prior attempt does not match progress");if(i.priorProgress?.ref!==t.progressRef||i.priorProgress?.digest!==t.progressDigest)n.push("Fallback prior progress binding does not match");let o=i.priorOutcome==="definitive_failure"?"failed":"ambiguous";if(t.status!==o)n.push("Fallback prior outcome does not match progress status");if((i.priorOutcome==="ambiguous"||i.priorOutcome==="reconciled_failure")&&(t.reconciliation?.ref!==i.reconciliation.binding?.ref||t.reconciliation?.digest!==i.reconciliation.binding?.digest))n.push("Fallback reconciliation does not match ambiguous progress");return n}function z(e){let i=[],t=new Map(e.decision.eligibilityDecisions.map((n)=>[n.ref,n.digest]));if(t.size!==e.decision.consideredRoutes.length||e.decision.consideredRoutes.some((n)=>t.get(n.eligibilityDecision.ref)!==n.eligibilityDecision.digest))i.push("Fallback eligibility evidence must exactly match considerations");for(let[n,o]of e.decision.consideredRoutes.entries())if(t.get(o.eligibilityDecision.ref)!==o.eligibilityDecision.digest)i.push(`Fallback route ${o.route.ref} lacks eligibility evidence`);else if(e.orderedRouteRefs[n]!==o.route.ref){i.push("Fallback considerations do not follow the configured order");break}return i}function G(e){let{decision:i,intent:t,priorProgress:n,preferenceResolution:o,preferenceSet:s}=e,r=[];if(i.deliveryRef!==t.deliveryRef||i.intent.ref!==t.deliveryRef||i.intent.digest!==t.deliveryDigest)r.push("Fallback delivery does not match the intent");if(!b(i.scope,t.scope))r.push("Fallback scope does not match the intent");if(i.preferenceSet.ref!==t.preferenceSet.ref||i.preferenceSet.revision!==t.preferenceSet.revision||i.preferenceSet.digest!==t.preferenceSet.digest||i.preferenceSet.ref!==s.preferenceSetRef||i.preferenceSet.revision!==s.revision||i.preferenceSet.digest!==s.preferenceSetDigest)r.push("Fallback preferences do not match the intent and resolution");if(r.push(...B({preferenceResolution:o,preferenceSet:s})),e.eligibilityDecisions)r.push(...x({decision:i,eligibilityDecisions:e.eligibilityDecisions}));if(t.preferenceResolution.ref!==o.resolutionRef||t.preferenceResolution.digest!==o.resolutionDigest)r.push("Fallback preference resolution does not match the intent");let P=new Map(e.routes.map((u)=>[u.routeRef,u]));for(let u of i.consideredRoutes){let p=P.get(u.route.ref);if(!p||u.route.revision!==p.revision||u.route.digest!==p.routeDigest||!b(i.scope,p.scope))r.push(`Fallback route binding is stale: ${u.route.ref}`)}if(!b(i.scope,s.scope))r.push("Fallback scope does not match the preference set");if(r.push(...T({decision:i,priorProgress:n}),...z({decision:i,orderedRouteRefs:t.requestedRoutes.map((u)=>u.ref)})),n)r.push(...q({intent:t,progress:n}));if(i.recipientRef!==t.recipientRefs[0])r.push("Fallback recipient does not match the intent");if(Y(e,r),i.policyRefs.some((u)=>!t.policyRefs.includes(u)))r.push("Fallback policy is not bound to the delivery intent");return r}function Y(e,i){let{decision:t,intent:n,preferenceSet:o,priorProgress:s}=e;if(t.state!=="selected"||!t.selectedRoute)return;let r=t.selectedRoute.ref,P=n.requestedRoutes.map((m)=>m.ref),u=P.indexOf(r),p=o.routePreferences.find((m)=>m.routeRef===r),g=e.routes.find((m)=>m.routeRef===r),D=n.requestedRoutes.find((m)=>m.ref===r),A=s?P.indexOf(s.route.ref):-1,L=t.consideredRoutes.find((m)=>{let F=e.routes.find((_)=>_.routeRef===m.route.ref),N=o.routePreferences.find((_)=>_.routeRef===m.route.ref),M=n.noticeClass==="mandatory_notice"&&F?.channel==="in_app"&&F.deliveryMode==="durable_in_app";return m.eligibility==="eligible"&&P.indexOf(m.route.ref)>A&&(o.globalEnabled&&N?.enabled||M)}),E=n.noticeClass==="mandatory_notice"&&g?.channel==="in_app"&&g?.deliveryMode==="durable_in_app";if(!o.globalEnabled&&!E||!o.fallback.enabled||u<0||!o.fallback.orderedRouteRefs.includes(r)||!D||!p?.enabled&&!E||!g||g?.channel!==p?.channel||g.semantic!==n.semantic)i.push("Selected fallback route is not requested and eligible by configuration");if(t.selectedRoute.revision!==g?.revision||t.selectedRoute.digest!==g?.routeDigest||D?.revision!==g?.revision||D?.digest!==g?.routeDigest)i.push("Selected fallback route binding is stale");if(p?.consentRef&&!n.consentRefs.includes(p.consentRef))i.push("Selected fallback route lacks required consent");if(L?.route.ref!==r||t.consideredRoutes.length!==u+1)i.push("Selected fallback route is not the first eligible ordered route");if(s&&A>=u)i.push("Selected fallback route does not follow the prior attempt")}var J="1.0.0",k=l.string().trim().min(1),Q=l.object({route:R,eligibility:l.enum(["eligible","ineligible","unknown"]),eligibilityDecision:y,reasonCodes:l.array(l.string().trim().min(1)).min(1)}).strict().superRefine((e,i)=>{if(new Set(e.reasonCodes).size!==e.reasonCodes.length)d(i,"reasonCodes","reason codes must be unique")}),W=l.object({status:l.enum(["not_required","pending","resolved"]),binding:y.optional()}).strict().superRefine((e,i)=>{if(e.status==="not_required"&&e.binding)i.addIssue({code:l.ZodIssueCode.custom,path:["binding"],message:"not_required reconciliation cannot carry a ref"});if(e.status!=="not_required"&&!e.binding)i.addIssue({code:l.ZodIssueCode.custom,path:["binding"],message:"pending or resolved reconciliation requires a ref"})}),be=l.object({schemaVersion:l.literal(J),decisionRef:k,fallbackDecisionDigest:h,deliveryRef:k,intent:y,scope:C,recipientRef:k,priorAttemptRef:k.optional(),priorProgress:y.optional(),priorOutcome:l.enum(["not_attempted","definitive_failure","ambiguous","reconciled_failure"]),state:l.enum(["selected","fail_closed","not_required"]),consideredRoutes:l.array(Q).min(1),selectedRoute:R.optional(),preferenceSet:R,eligibilityDecisions:l.array(y).min(1),policyRefs:l.array(k).min(1),reconciliation:W,effectAuthority:l.literal("none"),decidedAt:l.string().datetime({offset:!0}),evidenceRefs:l.array(k).min(1)}).strict().superRefine((e,i)=>{if(e.priorOutcome==="not_attempted"&&(e.priorAttemptRef||e.priorProgress))d(i,"priorAttemptRef","not-attempted fallback cannot reference a prior attempt");if(e.priorOutcome!=="not_attempted"&&(!e.priorAttemptRef||!e.priorProgress))d(i,"priorAttemptRef","attempted fallback outcomes require prior attempt and progress bindings");let t=e.consideredRoutes.map((o)=>o.route.ref);if(new Set(t).size!==t.length)d(i,"consideredRoutes","considered routes must be unique");for(let o of["policyRefs","evidenceRefs"])if(new Set(e[o]).size!==e[o].length)d(i,o,`${o} must be unique`);let n=e.eligibilityDecisions.map((o)=>o.ref);if(new Set(n).size!==n.length)d(i,"eligibilityDecisions","eligibility decisions must be unique");if(e.priorOutcome==="ambiguous"&&(e.state!=="fail_closed"||e.selectedRoute||e.reconciliation.status!=="pending"))d(i,"state","ambiguous delivery must remain fail closed until reclassified as a reconciled failure");if(e.priorOutcome==="reconciled_failure"&&e.reconciliation.status!=="resolved")d(i,"reconciliation","reconciled failure requires resolved reconciliation evidence");if((e.priorOutcome==="not_attempted"||e.priorOutcome==="definitive_failure")&&e.reconciliation.status!=="not_required")d(i,"reconciliation","non-ambiguous fallback must not carry reconciliation state");if(e.state==="selected"){let o=e.selectedRoute;if(!o)d(i,"selectedRoute","selected fallback requires a route");else if(!e.consideredRoutes.some((s)=>s.route.ref===o.ref&&s.route.revision===o.revision&&s.route.digest===o.digest&&s.eligibility==="eligible"))d(i,"selectedRoute","selected fallback route requires an explicit eligibility decision")}else if(e.selectedRoute)d(i,"selectedRoute","non-selected fallback decisions cannot carry a selected route")});function d(e,i,t){e.addIssue({code:l.ZodIssueCode.custom,path:[i],message:t})}export{J as COMMUNICATION_FALLBACK_DECISION_SCHEMA_VERSION,be as CommunicationFallbackDecisionV1Schema,W as CommunicationFallbackReconciliationV1Schema,Q as CommunicationFallbackRouteConsiderationV1Schema,G as validateCommunicationFallbackBindingV1,z as validateCommunicationFallbackConsiderationsV1,T as validateCommunicationFallbackPriorOutcomeBindingV1};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommunicationAgentProfileV1 } from './agent-communication.js';
|
|
2
|
+
import type { CommunicationPreferenceSetV1 } from './channel-preferences.js';
|
|
3
|
+
import type { CommunicationDeliveryRouteV1 } from './channel-routing.js';
|
|
4
|
+
import type { CommunicationDeliveryIntentV1 } from './delivery-intent.js';
|
|
5
|
+
import { type CommunicationPreferenceResolutionResultV1 } from './preference-resolution.js';
|
|
6
|
+
/** Validates an intent against the exact profile, preferences, and routes used. */
|
|
7
|
+
export declare function validateCommunicationDeliveryIntentBindingV1(input: {
|
|
8
|
+
intent: CommunicationDeliveryIntentV1;
|
|
9
|
+
profile: CommunicationAgentProfileV1;
|
|
10
|
+
preferenceSet: CommunicationPreferenceSetV1;
|
|
11
|
+
preferenceResolution: CommunicationPreferenceResolutionResultV1;
|
|
12
|
+
routes: readonly CommunicationDeliveryRouteV1[];
|
|
13
|
+
}): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{z as a}from"zod";var x="1.0.0",L="1.0.0",q={id:"communication-os.agent-omnichannel.v1",title:"CommunicationOS agent omnichannel contracts",body:"Provider-neutral agent profiles and lifecycle links bind applications, runs, tasks, help requests, background results, routes, preferences, policies, and evidence through opaque references. They grant no provider access or effect authority.",kind:"reference",route:"/docs/communication-os/agent-omnichannel-v1",visibility:"public"},s=a.string().trim().min(1),C=a.string().datetime({offset:!0}),R=a.string().regex(/^sha256:[a-f0-9]{64}$/),P=a.object({ref:s,digest:R}).strict(),h=P.extend({revision:a.number().int().positive()}).strict(),S=a.object({tenantRef:s,workspaceRef:s.optional(),spaceRef:s.optional(),subjectRef:s}).strict(),N=a.object({schemaVersion:a.literal(x),profileRef:s,revision:a.number().int().positive(),agentRef:s,applicationRef:s,scope:S,routeBindings:a.array(h),connectionRefs:a.array(s),preferenceSet:h,policyRefs:a.array(s).min(1),evidenceRefs:a.array(s).min(1),createdAt:C,updatedAt:C,profileDigest:R}).strict().superRefine((n,e)=>{for(let i of["connectionRefs","policyRefs","evidenceRefs"])if(new Set(n[i]).size!==n[i].length)e.addIssue({code:a.ZodIssueCode.custom,path:[i],message:`${i} must be unique`});let t=n.routeBindings.map((i)=>i.ref);if(new Set(t).size!==t.length)e.addIssue({code:a.ZodIssueCode.custom,path:["routeBindings"],message:"route bindings must be unique"})}),O=a.object({schemaVersion:a.literal(L),linkRef:s,profile:h,agentRef:s,applicationRef:s,scope:S,runRef:s.optional(),taskRef:s.optional(),helpRequestRef:s.optional(),approvalRequestRef:s.optional(),backgroundResultRef:s.optional(),canonicalConversation:P.optional(),session:h.optional(),correlationRef:s,evidenceRefs:a.array(s).min(1)}).strict().superRefine((n,e)=>{if(new Set(n.evidenceRefs).size!==n.evidenceRefs.length)e.addIssue({code:a.ZodIssueCode.custom,path:["evidenceRefs"],message:"evidenceRefs must be unique"});if(!n.runRef&&!n.taskRef&&!n.helpRequestRef&&!n.approvalRequestRef&&!n.backgroundResultRef)e.addIssue({code:a.ZodIssueCode.custom,path:["runRef"],message:"at least one run, task, help request, approval request, or background result ref is required"})});function p(n,e){return n.tenantRef===e.tenantRef&&n.workspaceRef===e.workspaceRef&&n.spaceRef===e.spaceRef&&n.subjectRef===e.subjectRef}function V(n){let e=[];for(let t of["agentRef","applicationRef"])if(n.profile[t]!==n.lifecycleLink[t])e.push(`Lifecycle ${t} does not match the agent profile`);if(n.lifecycleLink.profile.ref!==n.profile.profileRef||n.lifecycleLink.profile.revision!==n.profile.revision||n.lifecycleLink.profile.digest!==n.profile.profileDigest)e.push("Lifecycle profile binding does not match the agent profile");if(!p(n.profile.scope,n.lifecycleLink.scope))e.push("Lifecycle scope does not match the agent profile");return e}function z(n){let{intent:e,progress:t}=n,i=[];if(t.deliveryRef!==e.deliveryRef||t.intent.ref!==e.deliveryRef||t.intent.digest!==e.deliveryDigest)i.push("Progress delivery does not match the intent");if(!p(t.scope,e.scope))i.push("Progress scope does not match the intent");if(t.recipientRef!==e.recipientRefs[0])i.push("Progress recipient does not match the intent");let r=e.requestedRoutes.find((o)=>o.ref===t.route.ref);if(!r||r.revision!==t.route.revision||r.digest!==t.route.digest)i.push("Progress route was not requested by the intent");if(Date.parse(t.occurredAt)<Date.parse(e.createdAt)||Date.parse(t.occurredAt)>Date.parse(e.expiresAt))i.push("Progress occurred outside the intent validity window");return i}import{z as f}from"zod";var T="1.0.0",D="communication:preference-target:platform-default",F=[["event","automation"],["feature","application"],["product"],["space","person"],["platform_default"]],K=f.enum(["event","automation","feature","application","product","space","person","platform_default"]),g=f.string().trim().min(1);function m(n){return f.object({kind:f.literal(n),ref:g}).strict()}var I=f.discriminatedUnion("kind",[m("event"),m("automation"),m("feature"),m("application"),m("product"),m("space"),m("person"),f.object({kind:f.literal("platform_default"),ref:f.literal(D)}).strict()]),B=f.object({preferenceSetRef:g,revision:f.number().int().positive(),digest:R,target:I}).strict(),Z=f.object({schemaVersion:f.literal(T),resolutionRef:g,scope:S,subjectRef:g,evaluatedPreferenceSets:f.array(B).min(1),winningPreferenceSetRef:g,winningTarget:I,authority:f.literal("preference_only"),effectAuthority:f.literal("none"),resolvedAt:f.string().datetime({offset:!0}),evidenceRefs:f.array(g).min(1),resolutionDigest:R}).strict().superRefine((n,e)=>{let t=n.evaluatedPreferenceSets.map((r)=>r.preferenceSetRef);if(new Set(t).size!==t.length)d(e,"evaluatedPreferenceSets","evaluated sets must be unique");if(new Set(n.evidenceRefs).size!==n.evidenceRefs.length)d(e,"evidenceRefs","evidenceRefs must be unique");for(let r=1;r<n.evaluatedPreferenceSets.length;r+=1){let o=n.evaluatedPreferenceSets[r-1],l=n.evaluatedPreferenceSets[r];if(o&&l&&b(o.target.kind)>b(l.target.kind)){d(e,"evaluatedPreferenceSets","evaluated sets must follow the preference resolution hierarchy");break}}let i=n.evaluatedPreferenceSets.find((r)=>r.preferenceSetRef===n.winningPreferenceSetRef);if(!i)d(e,"winningPreferenceSetRef","winning preference set must have been evaluated");else if(i.preferenceSetRef!==n.evaluatedPreferenceSets[0]?.preferenceSetRef)d(e,"winningPreferenceSetRef","winning preference set must be the most specific evaluated set");else if(i.target.kind!==n.winningTarget.kind||i.target.ref!==n.winningTarget.ref)d(e,"winningTarget","winning target must match the winning preference set")});function b(n){switch(n){case"event":case"automation":return 0;case"feature":case"application":return 1;case"product":return 2;case"space":case"person":return 3;case"platform_default":return 4}}function d(n,e,t){n.addIssue({code:f.ZodIssueCode.custom,path:[e],message:t})}function A(n){let{preferenceResolution:e,preferenceSet:t}=n,i=[];if(e.subjectRef!==t.scope.subjectRef||e.winningPreferenceSetRef!==t.preferenceSetRef)i.push("Preference resolution does not match its subject and set");if(!p(e.scope,t.scope))i.push("Preference resolution scope does not match its preference set");let r=e.evaluatedPreferenceSets.find((o)=>o.preferenceSetRef===t.preferenceSetRef);if(!r||r.revision!==t.revision||r.digest!==t.preferenceSetDigest)i.push("Preference resolution binding is stale");if(e.winningTarget.kind!==t.target.kind||e.winningTarget.ref!==t.target.ref)i.push("Preference resolution target does not match its preference set");return i}function J(n){let{intent:e,profile:t,preferenceSet:i,preferenceResolution:r}=n,o=[];if(!p(e.scope,t.scope))o.push("Intent scope does not match the agent profile");if(!p(e.scope,i.scope))o.push("Intent scope does not match the preference set");if(e.lifecycleLink){if(o.push(...V({profile:t,lifecycleLink:e.lifecycleLink})),!p(e.scope,e.lifecycleLink.scope))o.push("Intent scope does not match the lifecycle link")}if(e.profile.ref!==t.profileRef||e.profile.revision!==t.revision||e.profile.digest!==t.profileDigest)o.push("Intent profile binding is stale");if(e.preferenceSet.ref!==i.preferenceSetRef||e.preferenceSet.revision!==i.revision||e.preferenceSet.digest!==i.preferenceSetDigest)o.push("Intent preference set does not match its preferences");let l=r.evaluatedPreferenceSets.find((c)=>c.preferenceSetRef===t.preferenceSet.ref);if(!l||l.revision!==t.preferenceSet.revision||l.digest!==t.preferenceSet.digest)o.push("Agent profile preference set was not evaluated");if(o.push(...A({preferenceResolution:r,preferenceSet:i})),e.preferenceResolution.ref!==r.resolutionRef||e.preferenceResolution.digest!==r.resolutionDigest)o.push("Intent preference resolution binding is stale");if(r.subjectRef!==e.scope.subjectRef)o.push("Preference resolution does not bind the intent subject");if(e.classificationRefs.applicationRef&&e.classificationRefs.applicationRef!==t.applicationRef)o.push("Intent application classification does not match the profile");if(e.policyRefs.some((c)=>!t.policyRefs.includes(c)))o.push("Intent policy is not bound to the agent profile");let E=new Map(n.routes.map((c)=>[c.routeRef,c])),k=new Map(i.routePreferences.map((c)=>[c.routeRef,c]));for(let c of e.requestedRoutes){let u=E.get(c.ref),y=t.routeBindings.find((w)=>w.ref===c.ref),v=k.get(c.ref);if(!u||!y){o.push(`Requested route ${c.ref} is not bound to the profile`);continue}if(c.revision!==u.revision||c.digest!==u.routeDigest||y.revision!==u.revision||y.digest!==u.routeDigest)o.push(`Requested route ${c.ref} binding is stale`);if(!p(e.scope,u.scope))o.push(`Requested route ${c.ref} scope does not match`);if(u.semantic!==e.semantic)o.push(`Requested route ${c.ref} has incompatible semantics`);if(!v||v.channel!==u.channel)o.push(`Requested route ${c.ref} is not configured by preferences`)}if(!i.globalEnabled&&e.noticeClass!=="mandatory_notice")o.push("Intent preference set is globally disabled");return o}export{J as validateCommunicationDeliveryIntentBindingV1};
|