@contractspec/example.locale-jurisdiction-gate 1.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$bundle.log +56 -0
- package/.turbo/turbo-build.log +57 -0
- package/CHANGELOG.md +161 -0
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/locale-jurisdiction-gate.docblock.d.ts +1 -0
- package/dist/docs/locale-jurisdiction-gate.docblock.js +53 -0
- package/dist/docs/locale-jurisdiction-gate.docblock.js.map +1 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/index.js +3 -0
- package/dist/entities/models.d.ts +186 -0
- package/dist/entities/models.d.ts.map +1 -0
- package/dist/entities/models.js +168 -0
- package/dist/entities/models.js.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +123 -0
- package/dist/events.js.map +1 -0
- package/dist/example.d.ts +36 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +40 -0
- package/dist/example.js.map +1 -0
- package/dist/handlers/demo.handlers.d.ts +59 -0
- package/dist/handlers/demo.handlers.d.ts.map +1 -0
- package/dist/handlers/demo.handlers.js +86 -0
- package/dist/handlers/demo.handlers.js.map +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +12 -0
- package/dist/locale-jurisdiction-gate.feature.d.ts +7 -0
- package/dist/locale-jurisdiction-gate.feature.d.ts.map +1 -0
- package/dist/locale-jurisdiction-gate.feature.js +51 -0
- package/dist/locale-jurisdiction-gate.feature.js.map +1 -0
- package/dist/operations/assistant.d.ts +245 -0
- package/dist/operations/assistant.d.ts.map +1 -0
- package/dist/operations/assistant.js +115 -0
- package/dist/operations/assistant.js.map +1 -0
- package/dist/operations/index.d.ts +2 -0
- package/dist/operations/index.js +3 -0
- package/dist/policy/guard.d.ts +27 -0
- package/dist/policy/guard.d.ts.map +1 -0
- package/dist/policy/guard.js +73 -0
- package/dist/policy/guard.js.map +1 -0
- package/dist/policy/index.d.ts +3 -0
- package/dist/policy/index.js +3 -0
- package/dist/policy/types.d.ts +16 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +0 -0
- package/example.ts +1 -0
- package/package.json +80 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/locale-jurisdiction-gate.docblock.ts +46 -0
- package/src/entities/index.ts +1 -0
- package/src/entities/models.ts +110 -0
- package/src/events.ts +74 -0
- package/src/example.ts +27 -0
- package/src/handlers/demo.handlers.test.ts +54 -0
- package/src/handlers/demo.handlers.ts +160 -0
- package/src/handlers/index.ts +1 -0
- package/src/index.ts +15 -0
- package/src/locale-jurisdiction-gate.feature.ts +30 -0
- package/src/operations/assistant.ts +98 -0
- package/src/operations/index.ts +1 -0
- package/src/policy/guard.test.ts +25 -0
- package/src/policy/guard.ts +102 -0
- package/src/policy/index.ts +2 -0
- package/src/policy/types.ts +18 -0
- package/tsconfig.json +17 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +17 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AssistantAnswerBlockedEvent, AssistantAnswerDeliveredEvent, AssistantAnswerRequestedEvent } from "./events.js";
|
|
2
|
+
import example_default from "./example.js";
|
|
3
|
+
import { AllowedScopeEnum, AssistantAnswerIRModel, AssistantAnswerSectionModel, AssistantCitationModel, LLMCallEnvelopeModel, RegulatoryContextModel, UserProfileModel } from "./entities/models.js";
|
|
4
|
+
import "./entities/index.js";
|
|
5
|
+
import { AssistantAnswerContract, AssistantExplainConceptContract } from "./operations/assistant.js";
|
|
6
|
+
import "./operations/index.js";
|
|
7
|
+
import { enforceAllowedScope, enforceCitations, validateEnvelope } from "./policy/guard.js";
|
|
8
|
+
import { createDemoAssistantHandlers } from "./handlers/demo.handlers.js";
|
|
9
|
+
import { LocaleJurisdictionGateFeature } from "./locale-jurisdiction-gate.feature.js";
|
|
10
|
+
import "./docs/index.js";
|
|
11
|
+
|
|
12
|
+
export { AllowedScopeEnum, AssistantAnswerBlockedEvent, AssistantAnswerContract, AssistantAnswerDeliveredEvent, AssistantAnswerIRModel, AssistantAnswerRequestedEvent, AssistantAnswerSectionModel, AssistantCitationModel, AssistantExplainConceptContract, LLMCallEnvelopeModel, LocaleJurisdictionGateFeature, RegulatoryContextModel, UserProfileModel, createDemoAssistantHandlers, enforceAllowedScope, enforceCitations, example_default as example, validateEnvelope };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FeatureModuleSpec } from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/locale-jurisdiction-gate.feature.d.ts
|
|
4
|
+
declare const LocaleJurisdictionGateFeature: FeatureModuleSpec;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { LocaleJurisdictionGateFeature };
|
|
7
|
+
//# sourceMappingURL=locale-jurisdiction-gate.feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-jurisdiction-gate.feature.d.ts","names":[],"sources":["../src/locale-jurisdiction-gate.feature.ts"],"sourcesContent":[],"mappings":";;;cAEa,+BAA+B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/locale-jurisdiction-gate.feature.ts
|
|
2
|
+
const LocaleJurisdictionGateFeature = {
|
|
3
|
+
meta: {
|
|
4
|
+
key: "locale-jurisdiction-gate",
|
|
5
|
+
version: 1,
|
|
6
|
+
title: "Locale + Jurisdiction Gate",
|
|
7
|
+
description: "Fail-closed gating for assistant calls requiring locale/jurisdiction/snapshot/scope and citations.",
|
|
8
|
+
domain: "knowledge",
|
|
9
|
+
owners: ["@examples"],
|
|
10
|
+
tags: [
|
|
11
|
+
"assistant",
|
|
12
|
+
"policy",
|
|
13
|
+
"locale",
|
|
14
|
+
"jurisdiction",
|
|
15
|
+
"knowledge"
|
|
16
|
+
],
|
|
17
|
+
stability: "experimental"
|
|
18
|
+
},
|
|
19
|
+
operations: [{
|
|
20
|
+
key: "assistant.answer",
|
|
21
|
+
version: 1
|
|
22
|
+
}, {
|
|
23
|
+
key: "assistant.explainConcept",
|
|
24
|
+
version: 1
|
|
25
|
+
}],
|
|
26
|
+
events: [
|
|
27
|
+
{
|
|
28
|
+
key: "assistant.answer.requested",
|
|
29
|
+
version: 1
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: "assistant.answer.blocked",
|
|
33
|
+
version: 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "assistant.answer.delivered",
|
|
37
|
+
version: 1
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
presentations: [],
|
|
41
|
+
opToPresentation: [],
|
|
42
|
+
presentationsTargets: [],
|
|
43
|
+
capabilities: { requires: [{
|
|
44
|
+
key: "knowledge",
|
|
45
|
+
version: 1
|
|
46
|
+
}] }
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { LocaleJurisdictionGateFeature };
|
|
51
|
+
//# sourceMappingURL=locale-jurisdiction-gate.feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-jurisdiction-gate.feature.js","names":["LocaleJurisdictionGateFeature: FeatureModuleSpec"],"sources":["../src/locale-jurisdiction-gate.feature.ts"],"sourcesContent":["import type { FeatureModuleSpec } from '@contractspec/lib.contracts';\n\nexport const LocaleJurisdictionGateFeature: FeatureModuleSpec = {\n meta: {\n key: 'locale-jurisdiction-gate',\n version: 1,\n title: 'Locale + Jurisdiction Gate',\n description:\n 'Fail-closed gating for assistant calls requiring locale/jurisdiction/snapshot/scope and citations.',\n domain: 'knowledge',\n owners: ['@examples'],\n tags: ['assistant', 'policy', 'locale', 'jurisdiction', 'knowledge'],\n stability: 'experimental',\n },\n operations: [\n { key: 'assistant.answer', version: 1 },\n { key: 'assistant.explainConcept', version: 1 },\n ],\n events: [\n { key: 'assistant.answer.requested', version: 1 },\n { key: 'assistant.answer.blocked', version: 1 },\n { key: 'assistant.answer.delivered', version: 1 },\n ],\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n capabilities: {\n requires: [{ key: 'knowledge', version: 1 }],\n },\n};\n"],"mappings":";AAEA,MAAaA,gCAAmD;CAC9D,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,QAAQ;EACR,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAU;GAAU;GAAgB;GAAY;EACpE,WAAW;EACZ;CACD,YAAY,CACV;EAAE,KAAK;EAAoB,SAAS;EAAG,EACvC;EAAE,KAAK;EAA4B,SAAS;EAAG,CAChD;CACD,QAAQ;EACN;GAAE,KAAK;GAA8B,SAAS;GAAG;EACjD;GAAE,KAAK;GAA4B,SAAS;GAAG;EAC/C;GAAE,KAAK;GAA8B,SAAS;GAAG;EAClD;CACD,eAAe,EAAE;CACjB,kBAAkB,EAAE;CACpB,sBAAsB,EAAE;CACxB,cAAc,EACZ,UAAU,CAAC;EAAE,KAAK;EAAa,SAAS;EAAG,CAAC,EAC7C;CACF"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import * as _contractspec_lib_contracts2 from "@contractspec/lib.contracts";
|
|
2
|
+
import * as _contractspec_lib_schema63 from "@contractspec/lib.schema";
|
|
3
|
+
|
|
4
|
+
//#region src/operations/assistant.d.ts
|
|
5
|
+
declare const AssistantAnswerContract: _contractspec_lib_contracts2.OperationSpec<_contractspec_lib_schema63.SchemaModel<{
|
|
6
|
+
envelope: {
|
|
7
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
8
|
+
traceId: {
|
|
9
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
10
|
+
isOptional: false;
|
|
11
|
+
};
|
|
12
|
+
locale: {
|
|
13
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
14
|
+
isOptional: false;
|
|
15
|
+
};
|
|
16
|
+
regulatoryContext: {
|
|
17
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
18
|
+
jurisdiction: {
|
|
19
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
20
|
+
isOptional: false;
|
|
21
|
+
};
|
|
22
|
+
region: {
|
|
23
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
24
|
+
isOptional: true;
|
|
25
|
+
};
|
|
26
|
+
clientType: {
|
|
27
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
28
|
+
isOptional: true;
|
|
29
|
+
};
|
|
30
|
+
allowedScope: {
|
|
31
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
32
|
+
isOptional: false;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
isOptional: false;
|
|
36
|
+
};
|
|
37
|
+
kbSnapshotId: {
|
|
38
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
39
|
+
isOptional: false;
|
|
40
|
+
};
|
|
41
|
+
allowedScope: {
|
|
42
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
43
|
+
isOptional: false;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
isOptional: false;
|
|
47
|
+
};
|
|
48
|
+
question: {
|
|
49
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
50
|
+
isOptional: false;
|
|
51
|
+
};
|
|
52
|
+
}>, _contractspec_lib_schema63.SchemaModel<{
|
|
53
|
+
locale: {
|
|
54
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
55
|
+
isOptional: false;
|
|
56
|
+
};
|
|
57
|
+
jurisdiction: {
|
|
58
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
59
|
+
isOptional: false;
|
|
60
|
+
};
|
|
61
|
+
allowedScope: {
|
|
62
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
63
|
+
isOptional: false;
|
|
64
|
+
};
|
|
65
|
+
sections: {
|
|
66
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
67
|
+
heading: {
|
|
68
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
69
|
+
isOptional: false;
|
|
70
|
+
};
|
|
71
|
+
body: {
|
|
72
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
73
|
+
isOptional: false;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
isArray: true;
|
|
77
|
+
isOptional: false;
|
|
78
|
+
};
|
|
79
|
+
citations: {
|
|
80
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
81
|
+
kbSnapshotId: {
|
|
82
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
83
|
+
isOptional: false;
|
|
84
|
+
};
|
|
85
|
+
sourceType: {
|
|
86
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
87
|
+
isOptional: false;
|
|
88
|
+
};
|
|
89
|
+
sourceId: {
|
|
90
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
91
|
+
isOptional: false;
|
|
92
|
+
};
|
|
93
|
+
title: {
|
|
94
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
95
|
+
isOptional: true;
|
|
96
|
+
};
|
|
97
|
+
excerpt: {
|
|
98
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
99
|
+
isOptional: true;
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
isArray: true;
|
|
103
|
+
isOptional: false;
|
|
104
|
+
};
|
|
105
|
+
disclaimers: {
|
|
106
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
107
|
+
isArray: true;
|
|
108
|
+
isOptional: true;
|
|
109
|
+
};
|
|
110
|
+
riskFlags: {
|
|
111
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
112
|
+
isArray: true;
|
|
113
|
+
isOptional: true;
|
|
114
|
+
};
|
|
115
|
+
refused: {
|
|
116
|
+
type: _contractspec_lib_schema63.FieldType<boolean, boolean>;
|
|
117
|
+
isOptional: true;
|
|
118
|
+
};
|
|
119
|
+
refusalReason: {
|
|
120
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
121
|
+
isOptional: true;
|
|
122
|
+
};
|
|
123
|
+
}>, undefined>;
|
|
124
|
+
declare const AssistantExplainConceptContract: _contractspec_lib_contracts2.OperationSpec<_contractspec_lib_schema63.SchemaModel<{
|
|
125
|
+
envelope: {
|
|
126
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
127
|
+
traceId: {
|
|
128
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
129
|
+
isOptional: false;
|
|
130
|
+
};
|
|
131
|
+
locale: {
|
|
132
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
133
|
+
isOptional: false;
|
|
134
|
+
};
|
|
135
|
+
regulatoryContext: {
|
|
136
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
137
|
+
jurisdiction: {
|
|
138
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
139
|
+
isOptional: false;
|
|
140
|
+
};
|
|
141
|
+
region: {
|
|
142
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
143
|
+
isOptional: true;
|
|
144
|
+
};
|
|
145
|
+
clientType: {
|
|
146
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
147
|
+
isOptional: true;
|
|
148
|
+
};
|
|
149
|
+
allowedScope: {
|
|
150
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
151
|
+
isOptional: false;
|
|
152
|
+
};
|
|
153
|
+
}>;
|
|
154
|
+
isOptional: false;
|
|
155
|
+
};
|
|
156
|
+
kbSnapshotId: {
|
|
157
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
158
|
+
isOptional: false;
|
|
159
|
+
};
|
|
160
|
+
allowedScope: {
|
|
161
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
162
|
+
isOptional: false;
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
isOptional: false;
|
|
166
|
+
};
|
|
167
|
+
conceptKey: {
|
|
168
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
169
|
+
isOptional: false;
|
|
170
|
+
};
|
|
171
|
+
}>, _contractspec_lib_schema63.SchemaModel<{
|
|
172
|
+
locale: {
|
|
173
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
174
|
+
isOptional: false;
|
|
175
|
+
};
|
|
176
|
+
jurisdiction: {
|
|
177
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
178
|
+
isOptional: false;
|
|
179
|
+
};
|
|
180
|
+
allowedScope: {
|
|
181
|
+
type: _contractspec_lib_schema63.EnumType<[string, string, string]>;
|
|
182
|
+
isOptional: false;
|
|
183
|
+
};
|
|
184
|
+
sections: {
|
|
185
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
186
|
+
heading: {
|
|
187
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
188
|
+
isOptional: false;
|
|
189
|
+
};
|
|
190
|
+
body: {
|
|
191
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
192
|
+
isOptional: false;
|
|
193
|
+
};
|
|
194
|
+
}>;
|
|
195
|
+
isArray: true;
|
|
196
|
+
isOptional: false;
|
|
197
|
+
};
|
|
198
|
+
citations: {
|
|
199
|
+
type: _contractspec_lib_schema63.SchemaModel<{
|
|
200
|
+
kbSnapshotId: {
|
|
201
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
202
|
+
isOptional: false;
|
|
203
|
+
};
|
|
204
|
+
sourceType: {
|
|
205
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
206
|
+
isOptional: false;
|
|
207
|
+
};
|
|
208
|
+
sourceId: {
|
|
209
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
210
|
+
isOptional: false;
|
|
211
|
+
};
|
|
212
|
+
title: {
|
|
213
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
214
|
+
isOptional: true;
|
|
215
|
+
};
|
|
216
|
+
excerpt: {
|
|
217
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
218
|
+
isOptional: true;
|
|
219
|
+
};
|
|
220
|
+
}>;
|
|
221
|
+
isArray: true;
|
|
222
|
+
isOptional: false;
|
|
223
|
+
};
|
|
224
|
+
disclaimers: {
|
|
225
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
226
|
+
isArray: true;
|
|
227
|
+
isOptional: true;
|
|
228
|
+
};
|
|
229
|
+
riskFlags: {
|
|
230
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
231
|
+
isArray: true;
|
|
232
|
+
isOptional: true;
|
|
233
|
+
};
|
|
234
|
+
refused: {
|
|
235
|
+
type: _contractspec_lib_schema63.FieldType<boolean, boolean>;
|
|
236
|
+
isOptional: true;
|
|
237
|
+
};
|
|
238
|
+
refusalReason: {
|
|
239
|
+
type: _contractspec_lib_schema63.FieldType<string, string>;
|
|
240
|
+
isOptional: true;
|
|
241
|
+
};
|
|
242
|
+
}>, undefined>;
|
|
243
|
+
//#endregion
|
|
244
|
+
export { AssistantAnswerContract, AssistantExplainConceptContract };
|
|
245
|
+
//# sourceMappingURL=assistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.d.ts","names":[],"sources":["../../src/operations/assistant.ts"],"sourcesContent":[],"mappings":";;;;cA0Ba,sDAAuB,yCAAA;;;;QAAvB,IAAA,EAmDX,0BAAA,CAAA,SAAA,CAAA,MAAA,EAAA,MAAA,CAAA;QAAA,UAAA,EAAA,KAAA;;;;;;;;;;;;UAnDkC,MAAA,EAAA;;;;;;;;;;;;;;;;;yBAAA;MAAA,CAAA;MAqDvB,YAAA,EAAA;QAkBX,IAAA,qCAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;;;;;;;;;;;;IAlB0C,IAAA,EArDR,0BAAA,CAAA,SAqDQ,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;;;;;;;QAAA,IAAA,sCAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA/B,8DAA+B,yCAAA;;;;cAkB1C,0BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAlB0C,0BAAA,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AssistantAnswerIRModel, LLMCallEnvelopeModel } from "../entities/models.js";
|
|
2
|
+
import { defineCommand } from "@contractspec/lib.contracts";
|
|
3
|
+
import { ScalarTypeEnum, defineSchemaModel as defineSchemaModel$1 } from "@contractspec/lib.schema";
|
|
4
|
+
|
|
5
|
+
//#region src/operations/assistant.ts
|
|
6
|
+
const AssistantQuestionInput = defineSchemaModel$1({
|
|
7
|
+
name: "AssistantQuestionInput",
|
|
8
|
+
description: "Input for assistant calls with mandatory envelope.",
|
|
9
|
+
fields: {
|
|
10
|
+
envelope: {
|
|
11
|
+
type: LLMCallEnvelopeModel,
|
|
12
|
+
isOptional: false
|
|
13
|
+
},
|
|
14
|
+
question: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const AssistantConceptInput = defineSchemaModel$1({
|
|
21
|
+
name: "AssistantConceptInput",
|
|
22
|
+
description: "Input for explaining a concept with mandatory envelope.",
|
|
23
|
+
fields: {
|
|
24
|
+
envelope: {
|
|
25
|
+
type: LLMCallEnvelopeModel,
|
|
26
|
+
isOptional: false
|
|
27
|
+
},
|
|
28
|
+
conceptKey: {
|
|
29
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
30
|
+
isOptional: false
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const AssistantAnswerContract = defineCommand({
|
|
35
|
+
meta: {
|
|
36
|
+
key: "assistant.answer",
|
|
37
|
+
version: 1,
|
|
38
|
+
stability: "experimental",
|
|
39
|
+
owners: ["@examples"],
|
|
40
|
+
tags: [
|
|
41
|
+
"assistant",
|
|
42
|
+
"policy",
|
|
43
|
+
"locale",
|
|
44
|
+
"jurisdiction",
|
|
45
|
+
"knowledge"
|
|
46
|
+
],
|
|
47
|
+
description: "Answer a user question using a KB snapshot with strict locale/jurisdiction gating.",
|
|
48
|
+
goal: "Provide policy-safe answers that cite a KB snapshot or refuse.",
|
|
49
|
+
context: "Called by UI or workflows; must fail-closed if envelope is invalid or citations are missing."
|
|
50
|
+
},
|
|
51
|
+
io: {
|
|
52
|
+
input: AssistantQuestionInput,
|
|
53
|
+
output: AssistantAnswerIRModel,
|
|
54
|
+
errors: {
|
|
55
|
+
LOCALE_REQUIRED: {
|
|
56
|
+
description: "Locale is required and must be supported",
|
|
57
|
+
http: 400,
|
|
58
|
+
gqlCode: "LOCALE_REQUIRED",
|
|
59
|
+
when: "locale is missing or unsupported"
|
|
60
|
+
},
|
|
61
|
+
JURISDICTION_REQUIRED: {
|
|
62
|
+
description: "Jurisdiction is required",
|
|
63
|
+
http: 400,
|
|
64
|
+
gqlCode: "JURISDICTION_REQUIRED",
|
|
65
|
+
when: "jurisdiction is missing"
|
|
66
|
+
},
|
|
67
|
+
KB_SNAPSHOT_REQUIRED: {
|
|
68
|
+
description: "KB snapshot id is required",
|
|
69
|
+
http: 400,
|
|
70
|
+
gqlCode: "KB_SNAPSHOT_REQUIRED",
|
|
71
|
+
when: "kbSnapshotId is missing"
|
|
72
|
+
},
|
|
73
|
+
CITATIONS_REQUIRED: {
|
|
74
|
+
description: "Answers must include citations to a KB snapshot",
|
|
75
|
+
http: 422,
|
|
76
|
+
gqlCode: "CITATIONS_REQUIRED",
|
|
77
|
+
when: "answer has no citations"
|
|
78
|
+
},
|
|
79
|
+
SCOPE_VIOLATION: {
|
|
80
|
+
description: "Answer violates allowed scope and must be refused/escalated",
|
|
81
|
+
http: 403,
|
|
82
|
+
gqlCode: "SCOPE_VIOLATION",
|
|
83
|
+
when: "output includes forbidden content under the given allowedScope"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
policy: { auth: "user" }
|
|
88
|
+
});
|
|
89
|
+
const AssistantExplainConceptContract = defineCommand({
|
|
90
|
+
meta: {
|
|
91
|
+
key: "assistant.explainConcept",
|
|
92
|
+
version: 1,
|
|
93
|
+
stability: "experimental",
|
|
94
|
+
owners: ["@examples"],
|
|
95
|
+
tags: [
|
|
96
|
+
"assistant",
|
|
97
|
+
"policy",
|
|
98
|
+
"knowledge",
|
|
99
|
+
"concepts"
|
|
100
|
+
],
|
|
101
|
+
description: "Explain a concept using a KB snapshot with strict locale/jurisdiction gating.",
|
|
102
|
+
goal: "Explain concepts with citations or refuse.",
|
|
103
|
+
context: "Same constraints as assistant.answer."
|
|
104
|
+
},
|
|
105
|
+
io: {
|
|
106
|
+
input: AssistantConceptInput,
|
|
107
|
+
output: AssistantAnswerIRModel,
|
|
108
|
+
errors: AssistantAnswerContract.io.errors
|
|
109
|
+
},
|
|
110
|
+
policy: { auth: "user" }
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { AssistantAnswerContract, AssistantExplainConceptContract };
|
|
115
|
+
//# sourceMappingURL=assistant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.js","names":["defineSchemaModel"],"sources":["../../src/operations/assistant.ts"],"sourcesContent":["import { defineCommand } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\n\nimport {\n AssistantAnswerIRModel,\n LLMCallEnvelopeModel,\n} from '../entities/models';\n\nconst AssistantQuestionInput = defineSchemaModel({\n name: 'AssistantQuestionInput',\n description: 'Input for assistant calls with mandatory envelope.',\n fields: {\n envelope: { type: LLMCallEnvelopeModel, isOptional: false },\n question: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst AssistantConceptInput = defineSchemaModel({\n name: 'AssistantConceptInput',\n description: 'Input for explaining a concept with mandatory envelope.',\n fields: {\n envelope: { type: LLMCallEnvelopeModel, isOptional: false },\n conceptKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nexport const AssistantAnswerContract = defineCommand({\n meta: {\n key: 'assistant.answer',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['assistant', 'policy', 'locale', 'jurisdiction', 'knowledge'],\n description:\n 'Answer a user question using a KB snapshot with strict locale/jurisdiction gating.',\n goal: 'Provide policy-safe answers that cite a KB snapshot or refuse.',\n context:\n 'Called by UI or workflows; must fail-closed if envelope is invalid or citations are missing.',\n },\n io: {\n input: AssistantQuestionInput,\n output: AssistantAnswerIRModel,\n errors: {\n LOCALE_REQUIRED: {\n description: 'Locale is required and must be supported',\n http: 400,\n gqlCode: 'LOCALE_REQUIRED',\n when: 'locale is missing or unsupported',\n },\n JURISDICTION_REQUIRED: {\n description: 'Jurisdiction is required',\n http: 400,\n gqlCode: 'JURISDICTION_REQUIRED',\n when: 'jurisdiction is missing',\n },\n KB_SNAPSHOT_REQUIRED: {\n description: 'KB snapshot id is required',\n http: 400,\n gqlCode: 'KB_SNAPSHOT_REQUIRED',\n when: 'kbSnapshotId is missing',\n },\n CITATIONS_REQUIRED: {\n description: 'Answers must include citations to a KB snapshot',\n http: 422,\n gqlCode: 'CITATIONS_REQUIRED',\n when: 'answer has no citations',\n },\n SCOPE_VIOLATION: {\n description:\n 'Answer violates allowed scope and must be refused/escalated',\n http: 403,\n gqlCode: 'SCOPE_VIOLATION',\n when: 'output includes forbidden content under the given allowedScope',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const AssistantExplainConceptContract = defineCommand({\n meta: {\n key: 'assistant.explainConcept',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['assistant', 'policy', 'knowledge', 'concepts'],\n description:\n 'Explain a concept using a KB snapshot with strict locale/jurisdiction gating.',\n goal: 'Explain concepts with citations or refuse.',\n context: 'Same constraints as assistant.answer.',\n },\n io: {\n input: AssistantConceptInput,\n output: AssistantAnswerIRModel,\n errors: AssistantAnswerContract.io.errors,\n },\n policy: { auth: 'user' },\n});\n"],"mappings":";;;;;AAQA,MAAM,yBAAyBA,oBAAkB;CAC/C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM;GAAsB,YAAY;GAAO;EAC3D,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE;CACF,CAAC;AAEF,MAAM,wBAAwBA,oBAAkB;CAC9C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM;GAAsB,YAAY;GAAO;EAC3D,YAAY;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC1E;CACF,CAAC;AAEF,MAAa,0BAA0B,cAAc;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAU;GAAU;GAAgB;GAAY;EACpE,aACE;EACF,MAAM;EACN,SACE;EACH;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,QAAQ;GACN,iBAAiB;IACf,aAAa;IACb,MAAM;IACN,SAAS;IACT,MAAM;IACP;GACD,uBAAuB;IACrB,aAAa;IACb,MAAM;IACN,SAAS;IACT,MAAM;IACP;GACD,sBAAsB;IACpB,aAAa;IACb,MAAM;IACN,SAAS;IACT,MAAM;IACP;GACD,oBAAoB;IAClB,aAAa;IACb,MAAM;IACN,SAAS;IACT,MAAM;IACP;GACD,iBAAiB;IACf,aACE;IACF,MAAM;IACN,SAAS;IACT,MAAM;IACP;GACF;EACF;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC;AAEF,MAAa,kCAAkC,cAAc;CAC3D,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAU;GAAa;GAAW;EACtD,aACE;EACF,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,QAAQ,wBAAwB,GAAG;EACpC;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GateResult } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/policy/guard.d.ts
|
|
4
|
+
interface EnvelopeLike {
|
|
5
|
+
locale?: string;
|
|
6
|
+
kbSnapshotId?: string;
|
|
7
|
+
allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';
|
|
8
|
+
regulatoryContext?: {
|
|
9
|
+
jurisdiction?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface AnswerLike {
|
|
13
|
+
citations?: unknown[];
|
|
14
|
+
sections?: {
|
|
15
|
+
heading: string;
|
|
16
|
+
body: string;
|
|
17
|
+
}[];
|
|
18
|
+
refused?: boolean;
|
|
19
|
+
refusalReason?: string;
|
|
20
|
+
allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';
|
|
21
|
+
}
|
|
22
|
+
declare function validateEnvelope(envelope: EnvelopeLike): GateResult<Required<EnvelopeLike>>;
|
|
23
|
+
declare function enforceCitations(answer: AnswerLike): GateResult<AnswerLike>;
|
|
24
|
+
declare function enforceAllowedScope(allowedScope: EnvelopeLike['allowedScope'], answer: AnswerLike): GateResult<AnswerLike>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { enforceAllowedScope, enforceCitations, validateEnvelope };
|
|
27
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","names":[],"sources":["../../src/policy/guard.ts"],"sourcesContent":[],"mappings":";;;UAEU,YAAA;;EAAA,YAAA,CAAA,EAAY,MAAA;EAOZ,YAAA,CAAU,EAAA,gBAAA,GAAA,cAAA,GAAA,qBAAA;EAcJ,iBAAA,CAAA,EAAgB;IACpB,YAAA,CAAA,EAAA,MAAA;EACW,CAAA;;UAhBb,UAAA,CAgBP;EAAU,SAAA,CAAA,EAAA,OAAA,EAAA;EA4BG,QAAA,CAAA,EAAA;IAAyB,OAAA,EAAA,MAAA;IAAwB,IAAA,EAAA,MAAA;EAAX,CAAA,EAAA;EAAU,OAAA,CAAA,EAAA,OAAA;EAoBhD,aAAA,CAAA,EAAA,MAAmB;EACnB,YAAA,CAAA,EAAA,gBAAA,GAAA,cAAA,GAAA,qBAAA;;AAEF,iBArDE,gBAAA,CAqDF,QAAA,EApDF,YAoDE,CAAA,EAnDX,UAmDW,CAnDA,QAmDA,CAnDS,YAmDT,CAAA,CAAA;AAAX,iBAvBa,gBAAA,CAuBb,MAAA,EAvBsC,UAuBtC,CAAA,EAvBmD,UAuBnD,CAvB8D,UAuB9D,CAAA;AAAU,iBAHG,mBAAA,CAGH,YAAA,EAFG,YAEH,CAAA,cAAA,CAAA,EAAA,MAAA,EADH,UACG,CAAA,EAAV,UAAU,CAAC,UAAD,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/policy/guard.ts
|
|
2
|
+
const SUPPORTED_LOCALES = new Set([
|
|
3
|
+
"en-US",
|
|
4
|
+
"en-GB",
|
|
5
|
+
"fr-FR"
|
|
6
|
+
]);
|
|
7
|
+
function err(code, message) {
|
|
8
|
+
return {
|
|
9
|
+
code,
|
|
10
|
+
message
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function validateEnvelope(envelope) {
|
|
14
|
+
if (!envelope.locale || !SUPPORTED_LOCALES.has(envelope.locale)) return {
|
|
15
|
+
ok: false,
|
|
16
|
+
error: err("LOCALE_REQUIRED", "locale is required and must be supported")
|
|
17
|
+
};
|
|
18
|
+
if (!envelope.regulatoryContext?.jurisdiction) return {
|
|
19
|
+
ok: false,
|
|
20
|
+
error: err("JURISDICTION_REQUIRED", "jurisdiction is required")
|
|
21
|
+
};
|
|
22
|
+
if (!envelope.kbSnapshotId) return {
|
|
23
|
+
ok: false,
|
|
24
|
+
error: err("KB_SNAPSHOT_REQUIRED", "kbSnapshotId is required")
|
|
25
|
+
};
|
|
26
|
+
if (!envelope.allowedScope) return {
|
|
27
|
+
ok: false,
|
|
28
|
+
error: err("SCOPE_VIOLATION", "allowedScope is required")
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
value: envelope
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function enforceCitations(answer) {
|
|
36
|
+
const citations = answer.citations ?? [];
|
|
37
|
+
if (!Array.isArray(citations) || citations.length === 0) return {
|
|
38
|
+
ok: false,
|
|
39
|
+
error: err("CITATIONS_REQUIRED", "answers must include at least one citation")
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
ok: true,
|
|
43
|
+
value: answer
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const EDUCATION_ONLY_FORBIDDEN_PATTERNS = [
|
|
47
|
+
/\b(buy|sell)\b/i,
|
|
48
|
+
/\b(should\s+buy|should\s+sell)\b/i,
|
|
49
|
+
/\b(guarantee(d)?|promise(d)?)\b/i
|
|
50
|
+
];
|
|
51
|
+
function enforceAllowedScope(allowedScope, answer) {
|
|
52
|
+
if (!allowedScope) return {
|
|
53
|
+
ok: false,
|
|
54
|
+
error: err("SCOPE_VIOLATION", "allowedScope is required")
|
|
55
|
+
};
|
|
56
|
+
if (allowedScope !== "education_only") return {
|
|
57
|
+
ok: true,
|
|
58
|
+
value: answer
|
|
59
|
+
};
|
|
60
|
+
const bodies = (answer.sections ?? []).map((s) => s.body).join("\n");
|
|
61
|
+
if (EDUCATION_ONLY_FORBIDDEN_PATTERNS.some((re) => re.test(bodies))) return {
|
|
62
|
+
ok: false,
|
|
63
|
+
error: err("SCOPE_VIOLATION", "answer violates education_only scope (contains actionable or promotional language)")
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
ok: true,
|
|
67
|
+
value: answer
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { enforceAllowedScope, enforceCitations, validateEnvelope };
|
|
73
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","names":["EDUCATION_ONLY_FORBIDDEN_PATTERNS: RegExp[]"],"sources":["../../src/policy/guard.ts"],"sourcesContent":["import type { GateError, GateResult } from './types';\n\ninterface EnvelopeLike {\n locale?: string;\n kbSnapshotId?: string;\n allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';\n regulatoryContext?: { jurisdiction?: string };\n}\n\ninterface AnswerLike {\n citations?: unknown[];\n sections?: { heading: string; body: string }[];\n refused?: boolean;\n refusalReason?: string;\n allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';\n}\n\nconst SUPPORTED_LOCALES = new Set<string>(['en-US', 'en-GB', 'fr-FR']);\n\nfunction err(code: GateError['code'], message: string): GateError {\n return { code, message };\n}\n\nexport function validateEnvelope(\n envelope: EnvelopeLike\n): GateResult<Required<EnvelopeLike>> {\n if (!envelope.locale || !SUPPORTED_LOCALES.has(envelope.locale)) {\n return {\n ok: false,\n error: err('LOCALE_REQUIRED', 'locale is required and must be supported'),\n };\n }\n if (!envelope.regulatoryContext?.jurisdiction) {\n return {\n ok: false,\n error: err('JURISDICTION_REQUIRED', 'jurisdiction is required'),\n };\n }\n if (!envelope.kbSnapshotId) {\n return {\n ok: false,\n error: err('KB_SNAPSHOT_REQUIRED', 'kbSnapshotId is required'),\n };\n }\n if (!envelope.allowedScope) {\n return {\n ok: false,\n error: err('SCOPE_VIOLATION', 'allowedScope is required'),\n };\n }\n return { ok: true, value: envelope as Required<EnvelopeLike> };\n}\n\nexport function enforceCitations(answer: AnswerLike): GateResult<AnswerLike> {\n const citations = answer.citations ?? [];\n if (!Array.isArray(citations) || citations.length === 0) {\n return {\n ok: false,\n error: err(\n 'CITATIONS_REQUIRED',\n 'answers must include at least one citation'\n ),\n };\n }\n return { ok: true, value: answer };\n}\n\nconst EDUCATION_ONLY_FORBIDDEN_PATTERNS: RegExp[] = [\n /\\b(buy|sell)\\b/i,\n /\\b(should\\s+buy|should\\s+sell)\\b/i,\n /\\b(guarantee(d)?|promise(d)?)\\b/i,\n];\n\nexport function enforceAllowedScope(\n allowedScope: EnvelopeLike['allowedScope'],\n answer: AnswerLike\n): GateResult<AnswerLike> {\n if (!allowedScope) {\n return {\n ok: false,\n error: err('SCOPE_VIOLATION', 'allowedScope is required'),\n };\n }\n if (allowedScope !== 'education_only') {\n return { ok: true, value: answer };\n }\n\n const bodies = (answer.sections ?? []).map((s) => s.body).join('\\n');\n const violations = EDUCATION_ONLY_FORBIDDEN_PATTERNS.some((re) =>\n re.test(bodies)\n );\n if (violations) {\n return {\n ok: false,\n error: err(\n 'SCOPE_VIOLATION',\n 'answer violates education_only scope (contains actionable or promotional language)'\n ),\n };\n }\n return { ok: true, value: answer };\n}\n"],"mappings":";AAiBA,MAAM,oBAAoB,IAAI,IAAY;CAAC;CAAS;CAAS;CAAQ,CAAC;AAEtE,SAAS,IAAI,MAAyB,SAA4B;AAChE,QAAO;EAAE;EAAM;EAAS;;AAG1B,SAAgB,iBACd,UACoC;AACpC,KAAI,CAAC,SAAS,UAAU,CAAC,kBAAkB,IAAI,SAAS,OAAO,CAC7D,QAAO;EACL,IAAI;EACJ,OAAO,IAAI,mBAAmB,2CAA2C;EAC1E;AAEH,KAAI,CAAC,SAAS,mBAAmB,aAC/B,QAAO;EACL,IAAI;EACJ,OAAO,IAAI,yBAAyB,2BAA2B;EAChE;AAEH,KAAI,CAAC,SAAS,aACZ,QAAO;EACL,IAAI;EACJ,OAAO,IAAI,wBAAwB,2BAA2B;EAC/D;AAEH,KAAI,CAAC,SAAS,aACZ,QAAO;EACL,IAAI;EACJ,OAAO,IAAI,mBAAmB,2BAA2B;EAC1D;AAEH,QAAO;EAAE,IAAI;EAAM,OAAO;EAAoC;;AAGhE,SAAgB,iBAAiB,QAA4C;CAC3E,MAAM,YAAY,OAAO,aAAa,EAAE;AACxC,KAAI,CAAC,MAAM,QAAQ,UAAU,IAAI,UAAU,WAAW,EACpD,QAAO;EACL,IAAI;EACJ,OAAO,IACL,sBACA,6CACD;EACF;AAEH,QAAO;EAAE,IAAI;EAAM,OAAO;EAAQ;;AAGpC,MAAMA,oCAA8C;CAClD;CACA;CACA;CACD;AAED,SAAgB,oBACd,cACA,QACwB;AACxB,KAAI,CAAC,aACH,QAAO;EACL,IAAI;EACJ,OAAO,IAAI,mBAAmB,2BAA2B;EAC1D;AAEH,KAAI,iBAAiB,iBACnB,QAAO;EAAE,IAAI;EAAM,OAAO;EAAQ;CAGpC,MAAM,UAAU,OAAO,YAAY,EAAE,EAAE,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,KAAK;AAIpE,KAHmB,kCAAkC,MAAM,OACzD,GAAG,KAAK,OAAO,CAChB,CAEC,QAAO;EACL,IAAI;EACJ,OAAO,IACL,mBACA,qFACD;EACF;AAEH,QAAO;EAAE,IAAI;EAAM,OAAO;EAAQ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/policy/types.d.ts
|
|
2
|
+
type AllowedScope = 'education_only' | 'generic_info' | 'escalation_required';
|
|
3
|
+
interface GateError {
|
|
4
|
+
code: 'LOCALE_REQUIRED' | 'JURISDICTION_REQUIRED' | 'KB_SNAPSHOT_REQUIRED' | 'CITATIONS_REQUIRED' | 'SCOPE_VIOLATION';
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
type GateResult<T> = {
|
|
8
|
+
ok: true;
|
|
9
|
+
value: T;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
error: GateError;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { AllowedScope, GateError, GateResult };
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/policy/types.ts"],"sourcesContent":[],"mappings":";KAAY,YAAA;AAAA,UAKK,SAAA,CALO;EAKP,IAAA,EAAA,iBAAS,GAAA,uBAAA,GAAA,sBAAA,GAAA,oBAAA,GAAA,iBAAA;EAUd,OAAA,EAAA,MAAU;;KAAV;;SACW;;;SACC"}
|
|
File without changes
|
package/example.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './src/example';
|