@contractspec/example.locale-jurisdiction-gate 3.7.6 → 3.7.10
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/.turbo/turbo-build.log +72 -51
- package/AGENTS.md +50 -27
- package/CHANGELOG.md +21 -0
- package/README.md +87 -42
- package/dist/browser/entities/index.js +2 -2
- package/dist/browser/entities/models.js +2 -2
- package/dist/browser/events.js +1 -1
- package/dist/browser/forms/assistant-context.form.js +213 -0
- package/dist/browser/forms/index.js +213 -0
- package/dist/browser/index.js +362 -40
- package/dist/browser/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/browser/operations/assistant.js +3 -3
- package/dist/browser/operations/index.js +3 -3
- package/dist/browser/policy/assistant-gate.policy.js +62 -0
- package/dist/browser/policy/index.js +62 -1
- package/dist/browser/translations/assistant-gate.en-GB.translation.js +48 -0
- package/dist/browser/translations/assistant-gate.en-US.translation.js +50 -0
- package/dist/browser/translations/assistant-gate.fr-FR.translation.js +52 -0
- package/dist/browser/translations/index.js +148 -0
- package/dist/contracts.test.d.ts +1 -0
- package/dist/entities/index.js +2 -2
- package/dist/entities/models.js +2 -2
- package/dist/events.js +1 -1
- package/dist/forms/assistant-context.form.d.ts +22 -0
- package/dist/forms/assistant-context.form.js +214 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.js +214 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +362 -40
- package/dist/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/node/entities/index.js +2 -2
- package/dist/node/entities/models.js +2 -2
- package/dist/node/events.js +1 -1
- package/dist/node/forms/assistant-context.form.js +213 -0
- package/dist/node/forms/index.js +213 -0
- package/dist/node/index.js +362 -40
- package/dist/node/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/node/operations/assistant.js +3 -3
- package/dist/node/operations/index.js +3 -3
- package/dist/node/policy/assistant-gate.policy.js +62 -0
- package/dist/node/policy/index.js +62 -1
- package/dist/node/translations/assistant-gate.en-GB.translation.js +48 -0
- package/dist/node/translations/assistant-gate.en-US.translation.js +50 -0
- package/dist/node/translations/assistant-gate.fr-FR.translation.js +52 -0
- package/dist/node/translations/index.js +148 -0
- package/dist/operations/assistant.js +3 -3
- package/dist/operations/index.js +3 -3
- package/dist/policy/assistant-gate.policy.d.ts +1 -0
- package/dist/policy/assistant-gate.policy.js +63 -0
- package/dist/policy/index.d.ts +2 -1
- package/dist/policy/index.js +62 -1
- package/dist/translations/assistant-gate.en-GB.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.en-GB.translation.js +49 -0
- package/dist/translations/assistant-gate.en-US.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.en-US.translation.js +51 -0
- package/dist/translations/assistant-gate.fr-FR.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.fr-FR.translation.js +53 -0
- package/dist/translations/index.d.ts +3 -0
- package/dist/translations/index.js +149 -0
- package/package.json +105 -7
- package/src/contracts.test.ts +32 -0
- package/src/docs/locale-jurisdiction-gate.docblock.ts +21 -21
- package/src/entities/models.ts +87 -87
- package/src/events.ts +55 -55
- package/src/example.ts +28 -28
- package/src/forms/assistant-context.form.ts +112 -0
- package/src/forms/index.ts +1 -0
- package/src/handlers/demo.handlers.test.ts +46 -46
- package/src/handlers/demo.handlers.ts +133 -133
- package/src/index.ts +5 -3
- package/src/locale-jurisdiction-gate.feature.ts +40 -34
- package/src/operations/assistant.ts +82 -82
- package/src/policy/assistant-gate.policy.ts +65 -0
- package/src/policy/guard.test.ts +18 -18
- package/src/policy/guard.ts +75 -75
- package/src/policy/index.ts +2 -1
- package/src/policy/types.ts +12 -12
- package/src/translations/assistant-gate.en-GB.translation.ts +46 -0
- package/src/translations/assistant-gate.en-US.translation.ts +48 -0
- package/src/translations/assistant-gate.fr-FR.translation.ts +51 -0
- package/src/translations/index.ts +3 -0
- package/tsconfig.json +7 -15
- package/tsdown.config.js +7 -13
|
@@ -66,8 +66,69 @@ function enforceAllowedScope(allowedScope, answer) {
|
|
|
66
66
|
}
|
|
67
67
|
return { ok: true, value: answer };
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
// src/policy/assistant-gate.policy.ts
|
|
71
|
+
import {
|
|
72
|
+
OwnersEnum,
|
|
73
|
+
StabilityEnum,
|
|
74
|
+
TagsEnum
|
|
75
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
76
|
+
import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
|
|
77
|
+
var AssistantGatePolicy = definePolicy({
|
|
78
|
+
meta: {
|
|
79
|
+
key: "locale-jurisdiction-gate.policy.gate",
|
|
80
|
+
version: "1.0.0",
|
|
81
|
+
title: "Assistant Locale and Jurisdiction Gate",
|
|
82
|
+
description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
|
|
83
|
+
domain: "assistant",
|
|
84
|
+
scope: "operation",
|
|
85
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
86
|
+
tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
|
|
87
|
+
stability: StabilityEnum.Experimental
|
|
88
|
+
},
|
|
89
|
+
rules: [
|
|
90
|
+
{
|
|
91
|
+
effect: "deny",
|
|
92
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
93
|
+
resource: { type: "assistant-call" },
|
|
94
|
+
conditions: [
|
|
95
|
+
{
|
|
96
|
+
expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
effect: "deny",
|
|
103
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
104
|
+
resource: { type: "assistant-call" },
|
|
105
|
+
conditions: [
|
|
106
|
+
{
|
|
107
|
+
expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
reason: "Only the explicitly reviewed assistant locales are permitted."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
effect: "allow",
|
|
114
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
115
|
+
resource: { type: "assistant-call" },
|
|
116
|
+
conditions: [
|
|
117
|
+
{
|
|
118
|
+
expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
reason: "Explicit context is present, so the request may continue to citation and scope validation."
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
pii: {
|
|
125
|
+
fields: ["kbSnapshotId"],
|
|
126
|
+
retentionDays: 30
|
|
127
|
+
}
|
|
128
|
+
});
|
|
69
129
|
export {
|
|
70
130
|
validateEnvelope,
|
|
71
131
|
enforceCitations,
|
|
72
|
-
enforceAllowedScope
|
|
132
|
+
enforceAllowedScope,
|
|
133
|
+
AssistantGatePolicy
|
|
73
134
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/translations/assistant-gate.en-GB.translation.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
8
|
+
var AssistantGateMessagesEnGb = defineTranslation({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
domain: "assistant",
|
|
13
|
+
description: "British English messages for the assistant locale and jurisdiction gate.",
|
|
14
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
15
|
+
stability: StabilityEnum.Experimental,
|
|
16
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
17
|
+
},
|
|
18
|
+
locale: "en-GB",
|
|
19
|
+
fallback: "en-US",
|
|
20
|
+
messages: {
|
|
21
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
22
|
+
"assistantGate.locale.description": {
|
|
23
|
+
value: "Select the reviewed locale for the assistant response."
|
|
24
|
+
},
|
|
25
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
26
|
+
"assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
|
|
27
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
28
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
29
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
30
|
+
},
|
|
31
|
+
"assistantGate.allowedScope.label": { value: "Permitted scope" },
|
|
32
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
33
|
+
value: "Educational content only"
|
|
34
|
+
},
|
|
35
|
+
"assistantGate.allowedScope.genericInfo": { value: "General information" },
|
|
36
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
37
|
+
value: "Escalation required"
|
|
38
|
+
},
|
|
39
|
+
"assistantGate.question.label": { value: "Question" },
|
|
40
|
+
"assistantGate.question.placeholder": {
|
|
41
|
+
value: "What may I say about this product in the selected jurisdiction?"
|
|
42
|
+
},
|
|
43
|
+
"assistantGate.submit.label": { value: "Generate response" }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export {
|
|
47
|
+
AssistantGateMessagesEnGb
|
|
48
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/translations/assistant-gate.en-US.translation.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
8
|
+
var AssistantGateMessagesEnUs = defineTranslation({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
domain: "assistant",
|
|
13
|
+
description: "US English messages for the assistant locale and jurisdiction gate.",
|
|
14
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
15
|
+
stability: StabilityEnum.Experimental,
|
|
16
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
17
|
+
},
|
|
18
|
+
locale: "en-US",
|
|
19
|
+
messages: {
|
|
20
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
21
|
+
"assistantGate.locale.description": {
|
|
22
|
+
value: "Choose the reviewed locale for the assistant answer."
|
|
23
|
+
},
|
|
24
|
+
"assistantGate.locale.enUs": { value: "English (United States)" },
|
|
25
|
+
"assistantGate.locale.enGb": { value: "English (United Kingdom)" },
|
|
26
|
+
"assistantGate.locale.frFr": { value: "French (France)" },
|
|
27
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
28
|
+
"assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
|
|
29
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
30
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
31
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
32
|
+
},
|
|
33
|
+
"assistantGate.allowedScope.label": { value: "Allowed scope" },
|
|
34
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
35
|
+
value: "Educational content only"
|
|
36
|
+
},
|
|
37
|
+
"assistantGate.allowedScope.genericInfo": { value: "Generic information" },
|
|
38
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
39
|
+
value: "Escalation required"
|
|
40
|
+
},
|
|
41
|
+
"assistantGate.question.label": { value: "Question" },
|
|
42
|
+
"assistantGate.question.placeholder": {
|
|
43
|
+
value: "What can I say about this product in the selected jurisdiction?"
|
|
44
|
+
},
|
|
45
|
+
"assistantGate.submit.label": { value: "Generate answer" }
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export {
|
|
49
|
+
AssistantGateMessagesEnUs
|
|
50
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/translations/assistant-gate.fr-FR.translation.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
8
|
+
var AssistantGateMessagesFrFr = defineTranslation({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.fr-FR",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
domain: "assistant",
|
|
13
|
+
description: "French messages for the assistant locale and jurisdiction gate.",
|
|
14
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
15
|
+
stability: StabilityEnum.Experimental,
|
|
16
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
17
|
+
},
|
|
18
|
+
locale: "fr-FR",
|
|
19
|
+
fallback: "en-US",
|
|
20
|
+
messages: {
|
|
21
|
+
"assistantGate.locale.label": { value: "Langue" },
|
|
22
|
+
"assistantGate.locale.description": {
|
|
23
|
+
value: "Sélectionnez la langue validée pour la réponse de l'assistant."
|
|
24
|
+
},
|
|
25
|
+
"assistantGate.jurisdiction.label": { value: "Juridiction" },
|
|
26
|
+
"assistantGate.jurisdiction.placeholder": { value: "FR-AMF" },
|
|
27
|
+
"assistantGate.kbSnapshotId.label": {
|
|
28
|
+
value: "Identifiant du snapshot documentaire"
|
|
29
|
+
},
|
|
30
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
31
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
32
|
+
},
|
|
33
|
+
"assistantGate.allowedScope.label": { value: "Périmètre autorisé" },
|
|
34
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
35
|
+
value: "Contenu éducatif uniquement"
|
|
36
|
+
},
|
|
37
|
+
"assistantGate.allowedScope.genericInfo": {
|
|
38
|
+
value: "Information générale"
|
|
39
|
+
},
|
|
40
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
41
|
+
value: "Escalade obligatoire"
|
|
42
|
+
},
|
|
43
|
+
"assistantGate.question.label": { value: "Question" },
|
|
44
|
+
"assistantGate.question.placeholder": {
|
|
45
|
+
value: "Que puis-je dire sur ce produit dans la juridiction sélectionnée ?"
|
|
46
|
+
},
|
|
47
|
+
"assistantGate.submit.label": { value: "Générer la réponse" }
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
AssistantGateMessagesFrFr
|
|
52
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// src/translations/assistant-gate.en-GB.translation.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
8
|
+
var AssistantGateMessagesEnGb = defineTranslation({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
domain: "assistant",
|
|
13
|
+
description: "British English messages for the assistant locale and jurisdiction gate.",
|
|
14
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
15
|
+
stability: StabilityEnum.Experimental,
|
|
16
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
17
|
+
},
|
|
18
|
+
locale: "en-GB",
|
|
19
|
+
fallback: "en-US",
|
|
20
|
+
messages: {
|
|
21
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
22
|
+
"assistantGate.locale.description": {
|
|
23
|
+
value: "Select the reviewed locale for the assistant response."
|
|
24
|
+
},
|
|
25
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
26
|
+
"assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
|
|
27
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
28
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
29
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
30
|
+
},
|
|
31
|
+
"assistantGate.allowedScope.label": { value: "Permitted scope" },
|
|
32
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
33
|
+
value: "Educational content only"
|
|
34
|
+
},
|
|
35
|
+
"assistantGate.allowedScope.genericInfo": { value: "General information" },
|
|
36
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
37
|
+
value: "Escalation required"
|
|
38
|
+
},
|
|
39
|
+
"assistantGate.question.label": { value: "Question" },
|
|
40
|
+
"assistantGate.question.placeholder": {
|
|
41
|
+
value: "What may I say about this product in the selected jurisdiction?"
|
|
42
|
+
},
|
|
43
|
+
"assistantGate.submit.label": { value: "Generate response" }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// src/translations/assistant-gate.en-US.translation.ts
|
|
48
|
+
import {
|
|
49
|
+
OwnersEnum as OwnersEnum2,
|
|
50
|
+
StabilityEnum as StabilityEnum2,
|
|
51
|
+
TagsEnum as TagsEnum2
|
|
52
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
53
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
54
|
+
var AssistantGateMessagesEnUs = defineTranslation2({
|
|
55
|
+
meta: {
|
|
56
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
|
|
57
|
+
version: "1.0.0",
|
|
58
|
+
domain: "assistant",
|
|
59
|
+
description: "US English messages for the assistant locale and jurisdiction gate.",
|
|
60
|
+
owners: [OwnersEnum2.PlatformFinance],
|
|
61
|
+
stability: StabilityEnum2.Experimental,
|
|
62
|
+
tags: [TagsEnum2.I18n, "assistant", "policy"]
|
|
63
|
+
},
|
|
64
|
+
locale: "en-US",
|
|
65
|
+
messages: {
|
|
66
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
67
|
+
"assistantGate.locale.description": {
|
|
68
|
+
value: "Choose the reviewed locale for the assistant answer."
|
|
69
|
+
},
|
|
70
|
+
"assistantGate.locale.enUs": { value: "English (United States)" },
|
|
71
|
+
"assistantGate.locale.enGb": { value: "English (United Kingdom)" },
|
|
72
|
+
"assistantGate.locale.frFr": { value: "French (France)" },
|
|
73
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
74
|
+
"assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
|
|
75
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
76
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
77
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
78
|
+
},
|
|
79
|
+
"assistantGate.allowedScope.label": { value: "Allowed scope" },
|
|
80
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
81
|
+
value: "Educational content only"
|
|
82
|
+
},
|
|
83
|
+
"assistantGate.allowedScope.genericInfo": { value: "Generic information" },
|
|
84
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
85
|
+
value: "Escalation required"
|
|
86
|
+
},
|
|
87
|
+
"assistantGate.question.label": { value: "Question" },
|
|
88
|
+
"assistantGate.question.placeholder": {
|
|
89
|
+
value: "What can I say about this product in the selected jurisdiction?"
|
|
90
|
+
},
|
|
91
|
+
"assistantGate.submit.label": { value: "Generate answer" }
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/translations/assistant-gate.fr-FR.translation.ts
|
|
96
|
+
import {
|
|
97
|
+
OwnersEnum as OwnersEnum3,
|
|
98
|
+
StabilityEnum as StabilityEnum3,
|
|
99
|
+
TagsEnum as TagsEnum3
|
|
100
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
101
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
102
|
+
var AssistantGateMessagesFrFr = defineTranslation3({
|
|
103
|
+
meta: {
|
|
104
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.fr-FR",
|
|
105
|
+
version: "1.0.0",
|
|
106
|
+
domain: "assistant",
|
|
107
|
+
description: "French messages for the assistant locale and jurisdiction gate.",
|
|
108
|
+
owners: [OwnersEnum3.PlatformFinance],
|
|
109
|
+
stability: StabilityEnum3.Experimental,
|
|
110
|
+
tags: [TagsEnum3.I18n, "assistant", "policy"]
|
|
111
|
+
},
|
|
112
|
+
locale: "fr-FR",
|
|
113
|
+
fallback: "en-US",
|
|
114
|
+
messages: {
|
|
115
|
+
"assistantGate.locale.label": { value: "Langue" },
|
|
116
|
+
"assistantGate.locale.description": {
|
|
117
|
+
value: "Sélectionnez la langue validée pour la réponse de l'assistant."
|
|
118
|
+
},
|
|
119
|
+
"assistantGate.jurisdiction.label": { value: "Juridiction" },
|
|
120
|
+
"assistantGate.jurisdiction.placeholder": { value: "FR-AMF" },
|
|
121
|
+
"assistantGate.kbSnapshotId.label": {
|
|
122
|
+
value: "Identifiant du snapshot documentaire"
|
|
123
|
+
},
|
|
124
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
125
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
126
|
+
},
|
|
127
|
+
"assistantGate.allowedScope.label": { value: "Périmètre autorisé" },
|
|
128
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
129
|
+
value: "Contenu éducatif uniquement"
|
|
130
|
+
},
|
|
131
|
+
"assistantGate.allowedScope.genericInfo": {
|
|
132
|
+
value: "Information générale"
|
|
133
|
+
},
|
|
134
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
135
|
+
value: "Escalade obligatoire"
|
|
136
|
+
},
|
|
137
|
+
"assistantGate.question.label": { value: "Question" },
|
|
138
|
+
"assistantGate.question.placeholder": {
|
|
139
|
+
value: "Que puis-je dire sur ce produit dans la juridiction sélectionnée ?"
|
|
140
|
+
},
|
|
141
|
+
"assistantGate.submit.label": { value: "Générer la réponse" }
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
export {
|
|
145
|
+
AssistantGateMessagesFrFr,
|
|
146
|
+
AssistantGateMessagesEnUs,
|
|
147
|
+
AssistantGateMessagesEnGb
|
|
148
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/entities/models.ts
|
|
3
3
|
import {
|
|
4
|
-
ScalarTypeEnum,
|
|
5
4
|
defineEnum,
|
|
6
|
-
defineSchemaModel
|
|
5
|
+
defineSchemaModel,
|
|
6
|
+
ScalarTypeEnum
|
|
7
7
|
} from "@contractspec/lib.schema";
|
|
8
8
|
var AllowedScopeEnum = defineEnum("AllowedScope", [
|
|
9
9
|
"education_only",
|
|
@@ -103,7 +103,7 @@ var AssistantAnswerIRModel = defineSchemaModel({
|
|
|
103
103
|
|
|
104
104
|
// src/operations/assistant.ts
|
|
105
105
|
import { defineCommand } from "@contractspec/lib.contracts-spec";
|
|
106
|
-
import {
|
|
106
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
107
107
|
var AssistantQuestionInput = defineSchemaModel2({
|
|
108
108
|
name: "AssistantQuestionInput",
|
|
109
109
|
description: "Input for assistant calls with mandatory envelope.",
|
package/dist/operations/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/entities/models.ts
|
|
3
3
|
import {
|
|
4
|
-
ScalarTypeEnum,
|
|
5
4
|
defineEnum,
|
|
6
|
-
defineSchemaModel
|
|
5
|
+
defineSchemaModel,
|
|
6
|
+
ScalarTypeEnum
|
|
7
7
|
} from "@contractspec/lib.schema";
|
|
8
8
|
var AllowedScopeEnum = defineEnum("AllowedScope", [
|
|
9
9
|
"education_only",
|
|
@@ -103,7 +103,7 @@ var AssistantAnswerIRModel = defineSchemaModel({
|
|
|
103
103
|
|
|
104
104
|
// src/operations/assistant.ts
|
|
105
105
|
import { defineCommand } from "@contractspec/lib.contracts-spec";
|
|
106
|
-
import {
|
|
106
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
107
107
|
var AssistantQuestionInput = defineSchemaModel2({
|
|
108
108
|
name: "AssistantQuestionInput",
|
|
109
109
|
description: "Input for assistant calls with mandatory envelope.",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssistantGatePolicy: import("@contractspec/lib.contracts-spec/policy").PolicySpec;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/policy/assistant-gate.policy.ts
|
|
3
|
+
import {
|
|
4
|
+
OwnersEnum,
|
|
5
|
+
StabilityEnum,
|
|
6
|
+
TagsEnum
|
|
7
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
+
import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
|
|
9
|
+
var AssistantGatePolicy = definePolicy({
|
|
10
|
+
meta: {
|
|
11
|
+
key: "locale-jurisdiction-gate.policy.gate",
|
|
12
|
+
version: "1.0.0",
|
|
13
|
+
title: "Assistant Locale and Jurisdiction Gate",
|
|
14
|
+
description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
|
|
15
|
+
domain: "assistant",
|
|
16
|
+
scope: "operation",
|
|
17
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
18
|
+
tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
|
|
19
|
+
stability: StabilityEnum.Experimental
|
|
20
|
+
},
|
|
21
|
+
rules: [
|
|
22
|
+
{
|
|
23
|
+
effect: "deny",
|
|
24
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
25
|
+
resource: { type: "assistant-call" },
|
|
26
|
+
conditions: [
|
|
27
|
+
{
|
|
28
|
+
expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
effect: "deny",
|
|
35
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
36
|
+
resource: { type: "assistant-call" },
|
|
37
|
+
conditions: [
|
|
38
|
+
{
|
|
39
|
+
expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
reason: "Only the explicitly reviewed assistant locales are permitted."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
effect: "allow",
|
|
46
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
47
|
+
resource: { type: "assistant-call" },
|
|
48
|
+
conditions: [
|
|
49
|
+
{
|
|
50
|
+
expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
reason: "Explicit context is present, so the request may continue to citation and scope validation."
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
pii: {
|
|
57
|
+
fields: ["kbSnapshotId"],
|
|
58
|
+
retentionDays: 30
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
AssistantGatePolicy
|
|
63
|
+
};
|
package/dist/policy/index.d.ts
CHANGED
package/dist/policy/index.js
CHANGED
|
@@ -67,8 +67,69 @@ function enforceAllowedScope(allowedScope, answer) {
|
|
|
67
67
|
}
|
|
68
68
|
return { ok: true, value: answer };
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
// src/policy/assistant-gate.policy.ts
|
|
72
|
+
import {
|
|
73
|
+
OwnersEnum,
|
|
74
|
+
StabilityEnum,
|
|
75
|
+
TagsEnum
|
|
76
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
77
|
+
import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
|
|
78
|
+
var AssistantGatePolicy = definePolicy({
|
|
79
|
+
meta: {
|
|
80
|
+
key: "locale-jurisdiction-gate.policy.gate",
|
|
81
|
+
version: "1.0.0",
|
|
82
|
+
title: "Assistant Locale and Jurisdiction Gate",
|
|
83
|
+
description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
|
|
84
|
+
domain: "assistant",
|
|
85
|
+
scope: "operation",
|
|
86
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
87
|
+
tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
|
|
88
|
+
stability: StabilityEnum.Experimental
|
|
89
|
+
},
|
|
90
|
+
rules: [
|
|
91
|
+
{
|
|
92
|
+
effect: "deny",
|
|
93
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
94
|
+
resource: { type: "assistant-call" },
|
|
95
|
+
conditions: [
|
|
96
|
+
{
|
|
97
|
+
expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
effect: "deny",
|
|
104
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
105
|
+
resource: { type: "assistant-call" },
|
|
106
|
+
conditions: [
|
|
107
|
+
{
|
|
108
|
+
expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
reason: "Only the explicitly reviewed assistant locales are permitted."
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
effect: "allow",
|
|
115
|
+
actions: ["assistant.answer", "assistant.explainConcept"],
|
|
116
|
+
resource: { type: "assistant-call" },
|
|
117
|
+
conditions: [
|
|
118
|
+
{
|
|
119
|
+
expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
reason: "Explicit context is present, so the request may continue to citation and scope validation."
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
pii: {
|
|
126
|
+
fields: ["kbSnapshotId"],
|
|
127
|
+
retentionDays: 30
|
|
128
|
+
}
|
|
129
|
+
});
|
|
70
130
|
export {
|
|
71
131
|
validateEnvelope,
|
|
72
132
|
enforceCitations,
|
|
73
|
-
enforceAllowedScope
|
|
133
|
+
enforceAllowedScope,
|
|
134
|
+
AssistantGatePolicy
|
|
74
135
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssistantGateMessagesEnGb: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/translations/assistant-gate.en-GB.translation.ts
|
|
3
|
+
import {
|
|
4
|
+
OwnersEnum,
|
|
5
|
+
StabilityEnum,
|
|
6
|
+
TagsEnum
|
|
7
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
9
|
+
var AssistantGateMessagesEnGb = defineTranslation({
|
|
10
|
+
meta: {
|
|
11
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
|
|
12
|
+
version: "1.0.0",
|
|
13
|
+
domain: "assistant",
|
|
14
|
+
description: "British English messages for the assistant locale and jurisdiction gate.",
|
|
15
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
16
|
+
stability: StabilityEnum.Experimental,
|
|
17
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
18
|
+
},
|
|
19
|
+
locale: "en-GB",
|
|
20
|
+
fallback: "en-US",
|
|
21
|
+
messages: {
|
|
22
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
23
|
+
"assistantGate.locale.description": {
|
|
24
|
+
value: "Select the reviewed locale for the assistant response."
|
|
25
|
+
},
|
|
26
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
27
|
+
"assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
|
|
28
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
29
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
30
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
31
|
+
},
|
|
32
|
+
"assistantGate.allowedScope.label": { value: "Permitted scope" },
|
|
33
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
34
|
+
value: "Educational content only"
|
|
35
|
+
},
|
|
36
|
+
"assistantGate.allowedScope.genericInfo": { value: "General information" },
|
|
37
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
38
|
+
value: "Escalation required"
|
|
39
|
+
},
|
|
40
|
+
"assistantGate.question.label": { value: "Question" },
|
|
41
|
+
"assistantGate.question.placeholder": {
|
|
42
|
+
value: "What may I say about this product in the selected jurisdiction?"
|
|
43
|
+
},
|
|
44
|
+
"assistantGate.submit.label": { value: "Generate response" }
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
AssistantGateMessagesEnGb
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssistantGateMessagesEnUs: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/translations/assistant-gate.en-US.translation.ts
|
|
3
|
+
import {
|
|
4
|
+
OwnersEnum,
|
|
5
|
+
StabilityEnum,
|
|
6
|
+
TagsEnum
|
|
7
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
|
|
9
|
+
var AssistantGateMessagesEnUs = defineTranslation({
|
|
10
|
+
meta: {
|
|
11
|
+
key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
|
|
12
|
+
version: "1.0.0",
|
|
13
|
+
domain: "assistant",
|
|
14
|
+
description: "US English messages for the assistant locale and jurisdiction gate.",
|
|
15
|
+
owners: [OwnersEnum.PlatformFinance],
|
|
16
|
+
stability: StabilityEnum.Experimental,
|
|
17
|
+
tags: [TagsEnum.I18n, "assistant", "policy"]
|
|
18
|
+
},
|
|
19
|
+
locale: "en-US",
|
|
20
|
+
messages: {
|
|
21
|
+
"assistantGate.locale.label": { value: "Locale" },
|
|
22
|
+
"assistantGate.locale.description": {
|
|
23
|
+
value: "Choose the reviewed locale for the assistant answer."
|
|
24
|
+
},
|
|
25
|
+
"assistantGate.locale.enUs": { value: "English (United States)" },
|
|
26
|
+
"assistantGate.locale.enGb": { value: "English (United Kingdom)" },
|
|
27
|
+
"assistantGate.locale.frFr": { value: "French (France)" },
|
|
28
|
+
"assistantGate.jurisdiction.label": { value: "Jurisdiction" },
|
|
29
|
+
"assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
|
|
30
|
+
"assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
|
|
31
|
+
"assistantGate.kbSnapshotId.placeholder": {
|
|
32
|
+
value: "kb_2026_03_20_policy_reviewed"
|
|
33
|
+
},
|
|
34
|
+
"assistantGate.allowedScope.label": { value: "Allowed scope" },
|
|
35
|
+
"assistantGate.allowedScope.educationOnly": {
|
|
36
|
+
value: "Educational content only"
|
|
37
|
+
},
|
|
38
|
+
"assistantGate.allowedScope.genericInfo": { value: "Generic information" },
|
|
39
|
+
"assistantGate.allowedScope.escalationRequired": {
|
|
40
|
+
value: "Escalation required"
|
|
41
|
+
},
|
|
42
|
+
"assistantGate.question.label": { value: "Question" },
|
|
43
|
+
"assistantGate.question.placeholder": {
|
|
44
|
+
value: "What can I say about this product in the selected jurisdiction?"
|
|
45
|
+
},
|
|
46
|
+
"assistantGate.submit.label": { value: "Generate answer" }
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export {
|
|
50
|
+
AssistantGateMessagesEnUs
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssistantGateMessagesFrFr: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;
|