@contractspec/example.locale-jurisdiction-gate 3.7.7 → 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.
Files changed (55) hide show
  1. package/.turbo/turbo-build.log +72 -51
  2. package/CHANGELOG.md +21 -0
  3. package/README.md +13 -1
  4. package/dist/browser/forms/assistant-context.form.js +213 -0
  5. package/dist/browser/forms/index.js +213 -0
  6. package/dist/browser/index.js +327 -6
  7. package/dist/browser/locale-jurisdiction-gate.feature.js +66 -1
  8. package/dist/browser/policy/assistant-gate.policy.js +62 -0
  9. package/dist/browser/policy/index.js +62 -1
  10. package/dist/browser/translations/assistant-gate.en-GB.translation.js +48 -0
  11. package/dist/browser/translations/assistant-gate.en-US.translation.js +50 -0
  12. package/dist/browser/translations/assistant-gate.fr-FR.translation.js +52 -0
  13. package/dist/browser/translations/index.js +148 -0
  14. package/dist/contracts.test.d.ts +1 -0
  15. package/dist/forms/assistant-context.form.d.ts +22 -0
  16. package/dist/forms/assistant-context.form.js +214 -0
  17. package/dist/forms/index.d.ts +1 -0
  18. package/dist/forms/index.js +214 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +327 -6
  21. package/dist/locale-jurisdiction-gate.feature.js +66 -1
  22. package/dist/node/forms/assistant-context.form.js +213 -0
  23. package/dist/node/forms/index.js +213 -0
  24. package/dist/node/index.js +327 -6
  25. package/dist/node/locale-jurisdiction-gate.feature.js +66 -1
  26. package/dist/node/policy/assistant-gate.policy.js +62 -0
  27. package/dist/node/policy/index.js +62 -1
  28. package/dist/node/translations/assistant-gate.en-GB.translation.js +48 -0
  29. package/dist/node/translations/assistant-gate.en-US.translation.js +50 -0
  30. package/dist/node/translations/assistant-gate.fr-FR.translation.js +52 -0
  31. package/dist/node/translations/index.js +148 -0
  32. package/dist/policy/assistant-gate.policy.d.ts +1 -0
  33. package/dist/policy/assistant-gate.policy.js +63 -0
  34. package/dist/policy/index.d.ts +1 -0
  35. package/dist/policy/index.js +62 -1
  36. package/dist/translations/assistant-gate.en-GB.translation.d.ts +1 -0
  37. package/dist/translations/assistant-gate.en-GB.translation.js +49 -0
  38. package/dist/translations/assistant-gate.en-US.translation.d.ts +1 -0
  39. package/dist/translations/assistant-gate.en-US.translation.js +51 -0
  40. package/dist/translations/assistant-gate.fr-FR.translation.d.ts +1 -0
  41. package/dist/translations/assistant-gate.fr-FR.translation.js +53 -0
  42. package/dist/translations/index.d.ts +3 -0
  43. package/dist/translations/index.js +149 -0
  44. package/package.json +103 -5
  45. package/src/contracts.test.ts +32 -0
  46. package/src/forms/assistant-context.form.ts +112 -0
  47. package/src/forms/index.ts +1 -0
  48. package/src/index.ts +2 -0
  49. package/src/locale-jurisdiction-gate.feature.ts +7 -1
  50. package/src/policy/assistant-gate.policy.ts +65 -0
  51. package/src/policy/index.ts +1 -0
  52. package/src/translations/assistant-gate.en-GB.translation.ts +46 -0
  53. package/src/translations/assistant-gate.en-US.translation.ts +48 -0
  54. package/src/translations/assistant-gate.fr-FR.translation.ts +51 -0
  55. package/src/translations/index.ts +3 -0
@@ -0,0 +1,213 @@
1
+ // src/entities/models.ts
2
+ import {
3
+ defineEnum,
4
+ defineSchemaModel,
5
+ ScalarTypeEnum
6
+ } from "@contractspec/lib.schema";
7
+ var AllowedScopeEnum = defineEnum("AllowedScope", [
8
+ "education_only",
9
+ "generic_info",
10
+ "escalation_required"
11
+ ]);
12
+ var UserProfileModel = defineSchemaModel({
13
+ name: "UserProfile",
14
+ description: "User profile inputs used to derive regulatory context.",
15
+ fields: {
16
+ preferredLocale: {
17
+ type: ScalarTypeEnum.String_unsecure(),
18
+ isOptional: true
19
+ },
20
+ residencyCountry: {
21
+ type: ScalarTypeEnum.String_unsecure(),
22
+ isOptional: true
23
+ },
24
+ taxResidenceCountry: {
25
+ type: ScalarTypeEnum.String_unsecure(),
26
+ isOptional: true
27
+ },
28
+ clientType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
29
+ }
30
+ });
31
+ var RegulatoryContextModel = defineSchemaModel({
32
+ name: "RegulatoryContext",
33
+ description: "Explicit regulatory context (no guessing).",
34
+ fields: {
35
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ region: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
37
+ clientType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
38
+ allowedScope: { type: AllowedScopeEnum, isOptional: false }
39
+ }
40
+ });
41
+ var LLMCallEnvelopeModel = defineSchemaModel({
42
+ name: "LLMCallEnvelope",
43
+ description: "Mandatory envelope for assistant calls. All fields are explicit and required for policy gating.",
44
+ fields: {
45
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
47
+ regulatoryContext: { type: RegulatoryContextModel, isOptional: false },
48
+ kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
+ allowedScope: { type: AllowedScopeEnum, isOptional: false }
50
+ }
51
+ });
52
+ var AssistantCitationModel = defineSchemaModel({
53
+ name: "AssistantCitation",
54
+ description: "Citation referencing a KB snapshot + a specific item within it.",
55
+ fields: {
56
+ kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
+ sourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ sourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
60
+ excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
61
+ }
62
+ });
63
+ var AssistantAnswerSectionModel = defineSchemaModel({
64
+ name: "AssistantAnswerSection",
65
+ description: "Structured answer section.",
66
+ fields: {
67
+ heading: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
+ body: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
69
+ }
70
+ });
71
+ var AssistantAnswerIRModel = defineSchemaModel({
72
+ name: "AssistantAnswerIR",
73
+ description: "Structured assistant answer with mandatory citations and explicit locale/jurisdiction.",
74
+ fields: {
75
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
77
+ allowedScope: { type: AllowedScopeEnum, isOptional: false },
78
+ sections: {
79
+ type: AssistantAnswerSectionModel,
80
+ isArray: true,
81
+ isOptional: false
82
+ },
83
+ citations: {
84
+ type: AssistantCitationModel,
85
+ isArray: true,
86
+ isOptional: false
87
+ },
88
+ disclaimers: {
89
+ type: ScalarTypeEnum.String_unsecure(),
90
+ isArray: true,
91
+ isOptional: true
92
+ },
93
+ riskFlags: {
94
+ type: ScalarTypeEnum.String_unsecure(),
95
+ isArray: true,
96
+ isOptional: true
97
+ },
98
+ refused: { type: ScalarTypeEnum.Boolean(), isOptional: true },
99
+ refusalReason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
100
+ }
101
+ });
102
+
103
+ // src/forms/assistant-context.form.ts
104
+ import { defineFormSpec } from "@contractspec/lib.contracts-spec/forms";
105
+ import {
106
+ OwnersEnum,
107
+ StabilityEnum,
108
+ TagsEnum
109
+ } from "@contractspec/lib.contracts-spec/ownership";
110
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
111
+ var AssistantContextFormModel = defineSchemaModel2({
112
+ name: "AssistantContextFormModel",
113
+ description: "Form values required before a policy-gated assistant request can be executed.",
114
+ fields: {
115
+ locale: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
116
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
117
+ kbSnapshotId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
118
+ allowedScope: { type: AllowedScopeEnum, isOptional: false },
119
+ question: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
120
+ }
121
+ });
122
+ var AssistantContextForm = defineFormSpec({
123
+ meta: {
124
+ key: "locale-jurisdiction-gate.form.assistant-context",
125
+ version: "1.0.0",
126
+ title: "Assistant Context Gate",
127
+ description: "Collects the explicit locale, jurisdiction, scope, and knowledge snapshot required by the assistant gate.",
128
+ domain: "assistant",
129
+ owners: [OwnersEnum.PlatformFinance],
130
+ tags: [TagsEnum.I18n, "assistant", "form", "policy"],
131
+ stability: StabilityEnum.Experimental
132
+ },
133
+ model: AssistantContextFormModel,
134
+ fields: [
135
+ {
136
+ kind: "select",
137
+ name: "locale",
138
+ labelI18n: "assistantGate.locale.label",
139
+ descriptionI18n: "assistantGate.locale.description",
140
+ options: {
141
+ kind: "static",
142
+ options: [
143
+ { labelI18n: "assistantGate.locale.enUs", value: "en-US" },
144
+ { labelI18n: "assistantGate.locale.enGb", value: "en-GB" },
145
+ { labelI18n: "assistantGate.locale.frFr", value: "fr-FR" }
146
+ ]
147
+ },
148
+ required: true
149
+ },
150
+ {
151
+ kind: "text",
152
+ name: "jurisdiction",
153
+ labelI18n: "assistantGate.jurisdiction.label",
154
+ placeholderI18n: "assistantGate.jurisdiction.placeholder",
155
+ required: true
156
+ },
157
+ {
158
+ kind: "text",
159
+ name: "kbSnapshotId",
160
+ labelI18n: "assistantGate.kbSnapshotId.label",
161
+ placeholderI18n: "assistantGate.kbSnapshotId.placeholder",
162
+ required: true
163
+ },
164
+ {
165
+ kind: "radio",
166
+ name: "allowedScope",
167
+ labelI18n: "assistantGate.allowedScope.label",
168
+ options: {
169
+ kind: "static",
170
+ options: [
171
+ {
172
+ labelI18n: "assistantGate.allowedScope.educationOnly",
173
+ value: "education_only"
174
+ },
175
+ {
176
+ labelI18n: "assistantGate.allowedScope.genericInfo",
177
+ value: "generic_info"
178
+ },
179
+ {
180
+ labelI18n: "assistantGate.allowedScope.escalationRequired",
181
+ value: "escalation_required"
182
+ }
183
+ ]
184
+ },
185
+ required: true
186
+ },
187
+ {
188
+ kind: "textarea",
189
+ name: "question",
190
+ labelI18n: "assistantGate.question.label",
191
+ placeholderI18n: "assistantGate.question.placeholder",
192
+ required: true
193
+ }
194
+ ],
195
+ actions: [
196
+ {
197
+ key: "submit",
198
+ labelI18n: "assistantGate.submit.label",
199
+ op: { name: "assistant.answer", version: "1.0.0" }
200
+ }
201
+ ],
202
+ policy: {
203
+ flags: [],
204
+ pii: ["kbSnapshotId", "question"]
205
+ },
206
+ renderHints: {
207
+ ui: "custom",
208
+ form: "react-hook-form"
209
+ }
210
+ });
211
+ export {
212
+ AssistantContextForm
213
+ };
@@ -0,0 +1,213 @@
1
+ // src/entities/models.ts
2
+ import {
3
+ defineEnum,
4
+ defineSchemaModel,
5
+ ScalarTypeEnum
6
+ } from "@contractspec/lib.schema";
7
+ var AllowedScopeEnum = defineEnum("AllowedScope", [
8
+ "education_only",
9
+ "generic_info",
10
+ "escalation_required"
11
+ ]);
12
+ var UserProfileModel = defineSchemaModel({
13
+ name: "UserProfile",
14
+ description: "User profile inputs used to derive regulatory context.",
15
+ fields: {
16
+ preferredLocale: {
17
+ type: ScalarTypeEnum.String_unsecure(),
18
+ isOptional: true
19
+ },
20
+ residencyCountry: {
21
+ type: ScalarTypeEnum.String_unsecure(),
22
+ isOptional: true
23
+ },
24
+ taxResidenceCountry: {
25
+ type: ScalarTypeEnum.String_unsecure(),
26
+ isOptional: true
27
+ },
28
+ clientType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
29
+ }
30
+ });
31
+ var RegulatoryContextModel = defineSchemaModel({
32
+ name: "RegulatoryContext",
33
+ description: "Explicit regulatory context (no guessing).",
34
+ fields: {
35
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ region: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
37
+ clientType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
38
+ allowedScope: { type: AllowedScopeEnum, isOptional: false }
39
+ }
40
+ });
41
+ var LLMCallEnvelopeModel = defineSchemaModel({
42
+ name: "LLMCallEnvelope",
43
+ description: "Mandatory envelope for assistant calls. All fields are explicit and required for policy gating.",
44
+ fields: {
45
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
47
+ regulatoryContext: { type: RegulatoryContextModel, isOptional: false },
48
+ kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
+ allowedScope: { type: AllowedScopeEnum, isOptional: false }
50
+ }
51
+ });
52
+ var AssistantCitationModel = defineSchemaModel({
53
+ name: "AssistantCitation",
54
+ description: "Citation referencing a KB snapshot + a specific item within it.",
55
+ fields: {
56
+ kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
+ sourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ sourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
60
+ excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
61
+ }
62
+ });
63
+ var AssistantAnswerSectionModel = defineSchemaModel({
64
+ name: "AssistantAnswerSection",
65
+ description: "Structured answer section.",
66
+ fields: {
67
+ heading: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
+ body: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
69
+ }
70
+ });
71
+ var AssistantAnswerIRModel = defineSchemaModel({
72
+ name: "AssistantAnswerIR",
73
+ description: "Structured assistant answer with mandatory citations and explicit locale/jurisdiction.",
74
+ fields: {
75
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
77
+ allowedScope: { type: AllowedScopeEnum, isOptional: false },
78
+ sections: {
79
+ type: AssistantAnswerSectionModel,
80
+ isArray: true,
81
+ isOptional: false
82
+ },
83
+ citations: {
84
+ type: AssistantCitationModel,
85
+ isArray: true,
86
+ isOptional: false
87
+ },
88
+ disclaimers: {
89
+ type: ScalarTypeEnum.String_unsecure(),
90
+ isArray: true,
91
+ isOptional: true
92
+ },
93
+ riskFlags: {
94
+ type: ScalarTypeEnum.String_unsecure(),
95
+ isArray: true,
96
+ isOptional: true
97
+ },
98
+ refused: { type: ScalarTypeEnum.Boolean(), isOptional: true },
99
+ refusalReason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
100
+ }
101
+ });
102
+
103
+ // src/forms/assistant-context.form.ts
104
+ import { defineFormSpec } from "@contractspec/lib.contracts-spec/forms";
105
+ import {
106
+ OwnersEnum,
107
+ StabilityEnum,
108
+ TagsEnum
109
+ } from "@contractspec/lib.contracts-spec/ownership";
110
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
111
+ var AssistantContextFormModel = defineSchemaModel2({
112
+ name: "AssistantContextFormModel",
113
+ description: "Form values required before a policy-gated assistant request can be executed.",
114
+ fields: {
115
+ locale: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
116
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
117
+ kbSnapshotId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
118
+ allowedScope: { type: AllowedScopeEnum, isOptional: false },
119
+ question: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
120
+ }
121
+ });
122
+ var AssistantContextForm = defineFormSpec({
123
+ meta: {
124
+ key: "locale-jurisdiction-gate.form.assistant-context",
125
+ version: "1.0.0",
126
+ title: "Assistant Context Gate",
127
+ description: "Collects the explicit locale, jurisdiction, scope, and knowledge snapshot required by the assistant gate.",
128
+ domain: "assistant",
129
+ owners: [OwnersEnum.PlatformFinance],
130
+ tags: [TagsEnum.I18n, "assistant", "form", "policy"],
131
+ stability: StabilityEnum.Experimental
132
+ },
133
+ model: AssistantContextFormModel,
134
+ fields: [
135
+ {
136
+ kind: "select",
137
+ name: "locale",
138
+ labelI18n: "assistantGate.locale.label",
139
+ descriptionI18n: "assistantGate.locale.description",
140
+ options: {
141
+ kind: "static",
142
+ options: [
143
+ { labelI18n: "assistantGate.locale.enUs", value: "en-US" },
144
+ { labelI18n: "assistantGate.locale.enGb", value: "en-GB" },
145
+ { labelI18n: "assistantGate.locale.frFr", value: "fr-FR" }
146
+ ]
147
+ },
148
+ required: true
149
+ },
150
+ {
151
+ kind: "text",
152
+ name: "jurisdiction",
153
+ labelI18n: "assistantGate.jurisdiction.label",
154
+ placeholderI18n: "assistantGate.jurisdiction.placeholder",
155
+ required: true
156
+ },
157
+ {
158
+ kind: "text",
159
+ name: "kbSnapshotId",
160
+ labelI18n: "assistantGate.kbSnapshotId.label",
161
+ placeholderI18n: "assistantGate.kbSnapshotId.placeholder",
162
+ required: true
163
+ },
164
+ {
165
+ kind: "radio",
166
+ name: "allowedScope",
167
+ labelI18n: "assistantGate.allowedScope.label",
168
+ options: {
169
+ kind: "static",
170
+ options: [
171
+ {
172
+ labelI18n: "assistantGate.allowedScope.educationOnly",
173
+ value: "education_only"
174
+ },
175
+ {
176
+ labelI18n: "assistantGate.allowedScope.genericInfo",
177
+ value: "generic_info"
178
+ },
179
+ {
180
+ labelI18n: "assistantGate.allowedScope.escalationRequired",
181
+ value: "escalation_required"
182
+ }
183
+ ]
184
+ },
185
+ required: true
186
+ },
187
+ {
188
+ kind: "textarea",
189
+ name: "question",
190
+ labelI18n: "assistantGate.question.label",
191
+ placeholderI18n: "assistantGate.question.placeholder",
192
+ required: true
193
+ }
194
+ ],
195
+ actions: [
196
+ {
197
+ key: "submit",
198
+ labelI18n: "assistantGate.submit.label",
199
+ op: { name: "assistant.answer", version: "1.0.0" }
200
+ }
201
+ ],
202
+ policy: {
203
+ flags: [],
204
+ pii: ["kbSnapshotId", "question"]
205
+ },
206
+ renderHints: {
207
+ ui: "custom",
208
+ form: "react-hook-form"
209
+ }
210
+ });
211
+ export {
212
+ AssistantContextForm
213
+ };