@contractspec/example.locale-jurisdiction-gate 3.7.17 → 3.7.19
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 +66 -66
- package/CHANGELOG.md +17 -0
- package/dist/browser/docs/index.js +3 -27
- package/dist/browser/docs/locale-jurisdiction-gate.docblock.js +3 -27
- package/dist/browser/entities/index.js +1 -110
- package/dist/browser/entities/models.js +1 -110
- package/dist/browser/events.js +1 -73
- package/dist/browser/example.js +1 -35
- package/dist/browser/forms/assistant-context.form.js +1 -213
- package/dist/browser/forms/index.js +1 -213
- package/dist/browser/handlers/demo.handlers.js +2 -152
- package/dist/browser/handlers/index.js +2 -152
- package/dist/browser/index.js +4 -844
- package/dist/browser/locale-jurisdiction-gate.feature.js +1 -105
- package/dist/browser/operations/assistant.js +1 -192
- package/dist/browser/operations/index.js +1 -192
- package/dist/browser/policy/assistant-gate.policy.js +1 -62
- package/dist/browser/policy/guard.js +2 -73
- package/dist/browser/policy/index.js +2 -134
- package/dist/browser/translations/assistant-gate.en-GB.translation.js +1 -48
- package/dist/browser/translations/assistant-gate.en-US.translation.js +1 -50
- package/dist/browser/translations/assistant-gate.fr-FR.translation.js +1 -52
- package/dist/browser/translations/index.js +1 -148
- package/dist/docs/index.js +3 -27
- package/dist/docs/locale-jurisdiction-gate.docblock.js +3 -27
- package/dist/entities/index.js +1 -110
- package/dist/entities/models.js +1 -110
- package/dist/events.js +1 -73
- package/dist/example.js +1 -35
- package/dist/forms/assistant-context.form.js +1 -213
- package/dist/forms/index.js +1 -213
- package/dist/handlers/demo.handlers.js +2 -152
- package/dist/handlers/index.js +2 -152
- package/dist/index.js +4 -844
- package/dist/locale-jurisdiction-gate.feature.js +1 -105
- package/dist/node/docs/index.js +3 -27
- package/dist/node/docs/locale-jurisdiction-gate.docblock.js +3 -27
- package/dist/node/entities/index.js +1 -110
- package/dist/node/entities/models.js +1 -110
- package/dist/node/events.js +1 -73
- package/dist/node/example.js +1 -35
- package/dist/node/forms/assistant-context.form.js +1 -213
- package/dist/node/forms/index.js +1 -213
- package/dist/node/handlers/demo.handlers.js +2 -152
- package/dist/node/handlers/index.js +2 -152
- package/dist/node/index.js +4 -844
- package/dist/node/locale-jurisdiction-gate.feature.js +1 -105
- package/dist/node/operations/assistant.js +1 -192
- package/dist/node/operations/index.js +1 -192
- package/dist/node/policy/assistant-gate.policy.js +1 -62
- package/dist/node/policy/guard.js +2 -73
- package/dist/node/policy/index.js +2 -134
- package/dist/node/translations/assistant-gate.en-GB.translation.js +1 -48
- package/dist/node/translations/assistant-gate.en-US.translation.js +1 -50
- package/dist/node/translations/assistant-gate.fr-FR.translation.js +1 -52
- package/dist/node/translations/index.js +1 -148
- package/dist/operations/assistant.js +1 -192
- package/dist/operations/index.js +1 -192
- package/dist/policy/assistant-gate.policy.js +1 -62
- package/dist/policy/guard.js +2 -73
- package/dist/policy/index.js +2 -134
- package/dist/translations/assistant-gate.en-GB.translation.js +1 -48
- package/dist/translations/assistant-gate.en-US.translation.js +1 -50
- package/dist/translations/assistant-gate.fr-FR.translation.js +1 -52
- package/dist/translations/index.js +1 -148
- package/package.json +5 -5
|
@@ -1,106 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
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
|
-
|
|
62
|
-
// src/locale-jurisdiction-gate.feature.ts
|
|
63
|
-
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
64
|
-
var LocaleJurisdictionGateFeature = defineFeature({
|
|
65
|
-
meta: {
|
|
66
|
-
key: "locale-jurisdiction-gate",
|
|
67
|
-
version: "1.0.0",
|
|
68
|
-
title: "Locale + Jurisdiction Gate",
|
|
69
|
-
description: "Fail-closed gating for assistant calls requiring locale/jurisdiction/snapshot/scope and citations.",
|
|
70
|
-
domain: "knowledge",
|
|
71
|
-
owners: ["@examples"],
|
|
72
|
-
tags: ["assistant", "policy", "locale", "jurisdiction", "knowledge"],
|
|
73
|
-
stability: "experimental"
|
|
74
|
-
},
|
|
75
|
-
operations: [
|
|
76
|
-
{ key: "assistant.answer", version: "1.0.0" },
|
|
77
|
-
{ key: "assistant.explainConcept", version: "1.0.0" }
|
|
78
|
-
],
|
|
79
|
-
events: [
|
|
80
|
-
{ key: "assistant.answer.requested", version: "1.0.0" },
|
|
81
|
-
{ key: "assistant.answer.blocked", version: "1.0.0" },
|
|
82
|
-
{ key: "assistant.answer.delivered", version: "1.0.0" }
|
|
83
|
-
],
|
|
84
|
-
presentations: [],
|
|
85
|
-
opToPresentation: [],
|
|
86
|
-
presentationsTargets: [],
|
|
87
|
-
capabilities: {
|
|
88
|
-
requires: [{ key: "knowledge", version: "1.0.0" }]
|
|
89
|
-
},
|
|
90
|
-
policies: [
|
|
91
|
-
{
|
|
92
|
-
key: AssistantGatePolicy.meta.key,
|
|
93
|
-
version: AssistantGatePolicy.meta.version
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
knowledge: [
|
|
97
|
-
{ key: "locale-jurisdiction-gate.knowledge.rules", version: "1.0.0" }
|
|
98
|
-
],
|
|
99
|
-
docs: [
|
|
100
|
-
"docs.examples.locale-jurisdiction-gate.goal",
|
|
101
|
-
"docs.examples.locale-jurisdiction-gate.reference"
|
|
102
|
-
]
|
|
103
|
-
});
|
|
104
|
-
export {
|
|
105
|
-
LocaleJurisdictionGateFeature
|
|
106
|
-
};
|
|
2
|
+
import{OwnersEnum as j,StabilityEnum as k,TagsEnum as q}from"@contractspec/lib.contracts-spec/ownership";import{definePolicy as v}from"@contractspec/lib.contracts-spec/policy";var h=v({meta:{key:"locale-jurisdiction-gate.policy.gate",version:"1.0.0",title:"Assistant Locale and Jurisdiction Gate",description:"Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",domain:"assistant",scope:"operation",owners:[j.PlatformFinance],tags:[q.I18n,"assistant","policy","jurisdiction"],stability:k.Experimental},rules:[{effect:"deny",actions:["assistant.answer","assistant.explainConcept"],resource:{type:"assistant-call"},conditions:[{expression:"!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"}],reason:"Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."},{effect:"deny",actions:["assistant.answer","assistant.explainConcept"],resource:{type:"assistant-call"},conditions:[{expression:"!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"}],reason:"Only the explicitly reviewed assistant locales are permitted."},{effect:"allow",actions:["assistant.answer","assistant.explainConcept"],resource:{type:"assistant-call"},conditions:[{expression:"['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"}],reason:"Explicit context is present, so the request may continue to citation and scope validation."}],pii:{fields:["kbSnapshotId"],retentionDays:30}});import{defineFeature as x}from"@contractspec/lib.contracts-spec";var I=x({meta:{key:"locale-jurisdiction-gate",version:"1.0.0",title:"Locale + Jurisdiction Gate",description:"Fail-closed gating for assistant calls requiring locale/jurisdiction/snapshot/scope and citations.",domain:"knowledge",owners:["@examples"],tags:["assistant","policy","locale","jurisdiction","knowledge"],stability:"experimental"},operations:[{key:"assistant.answer",version:"1.0.0"},{key:"assistant.explainConcept",version:"1.0.0"}],events:[{key:"assistant.answer.requested",version:"1.0.0"},{key:"assistant.answer.blocked",version:"1.0.0"},{key:"assistant.answer.delivered",version:"1.0.0"}],presentations:[],opToPresentation:[],presentationsTargets:[],capabilities:{requires:[{key:"knowledge",version:"1.0.0"}]},policies:[{key:h.meta.key,version:h.meta.version}],knowledge:[{key:"locale-jurisdiction-gate.knowledge.rules",version:"1.0.0"}],docs:["docs.examples.locale-jurisdiction-gate.goal","docs.examples.locale-jurisdiction-gate.reference"]});export{I as LocaleJurisdictionGateFeature};
|
package/dist/node/docs/index.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
|
|
3
|
-
var docBlocks = [
|
|
4
|
-
{
|
|
5
|
-
id: "docs.examples.locale-jurisdiction-gate.goal",
|
|
6
|
-
title: "Locale/Jurisdiction Gate — Goal",
|
|
7
|
-
summary: "Fail-closed gate that forces locale + jurisdiction + kbSnapshotId + allowedScope for assistant calls.",
|
|
8
|
-
kind: "goal",
|
|
9
|
-
visibility: "public",
|
|
10
|
-
route: "/docs/examples/locale-jurisdiction-gate/goal",
|
|
11
|
-
tags: ["assistant", "policy", "locale", "jurisdiction", "knowledge"],
|
|
12
|
-
body: `## Why it matters
|
|
1
|
+
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.examples.locale-jurisdiction-gate.goal",title:"Locale/Jurisdiction Gate — Goal",summary:"Fail-closed gate that forces locale + jurisdiction + kbSnapshotId + allowedScope for assistant calls.",kind:"goal",visibility:"public",route:"/docs/examples/locale-jurisdiction-gate/goal",tags:["assistant","policy","locale","jurisdiction","knowledge"],body:`## Why it matters
|
|
13
2
|
- Forces all assistant behavior to be bound to explicit inputs (no guessing).
|
|
14
3
|
- Requires KB snapshot citations to make answers traceable and regenerable.
|
|
15
4
|
|
|
16
5
|
## Guardrails
|
|
17
6
|
- Missing locale/jurisdiction/snapshot/scope => refuse (structured).
|
|
18
7
|
- Missing citations => refuse.
|
|
19
|
-
- Scope violations under education_only => refuse/escalate.`
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: "docs.examples.locale-jurisdiction-gate.reference",
|
|
23
|
-
title: "Locale/Jurisdiction Gate — Reference",
|
|
24
|
-
summary: "Contracts, models, and events exposed by the gate example.",
|
|
25
|
-
kind: "reference",
|
|
26
|
-
visibility: "public",
|
|
27
|
-
route: "/docs/examples/locale-jurisdiction-gate",
|
|
28
|
-
tags: ["assistant", "policy", "reference"],
|
|
29
|
-
body: `## Contracts
|
|
8
|
+
- Scope violations under education_only => refuse/escalate.`},{id:"docs.examples.locale-jurisdiction-gate.reference",title:"Locale/Jurisdiction Gate — Reference",summary:"Contracts, models, and events exposed by the gate example.",kind:"reference",visibility:"public",route:"/docs/examples/locale-jurisdiction-gate",tags:["assistant","policy","reference"],body:`## Contracts
|
|
30
9
|
- assistant.answer (v1)
|
|
31
10
|
- assistant.explainConcept (v1)
|
|
32
11
|
|
|
@@ -37,7 +16,4 @@ var docBlocks = [
|
|
|
37
16
|
## Events
|
|
38
17
|
- assistant.answer.requested
|
|
39
18
|
- assistant.answer.blocked
|
|
40
|
-
- assistant.answer.delivered`
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
registerDocBlocks(docBlocks);
|
|
19
|
+
- assistant.answer.delivered`}];f(h);
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
|
|
3
|
-
var docBlocks = [
|
|
4
|
-
{
|
|
5
|
-
id: "docs.examples.locale-jurisdiction-gate.goal",
|
|
6
|
-
title: "Locale/Jurisdiction Gate — Goal",
|
|
7
|
-
summary: "Fail-closed gate that forces locale + jurisdiction + kbSnapshotId + allowedScope for assistant calls.",
|
|
8
|
-
kind: "goal",
|
|
9
|
-
visibility: "public",
|
|
10
|
-
route: "/docs/examples/locale-jurisdiction-gate/goal",
|
|
11
|
-
tags: ["assistant", "policy", "locale", "jurisdiction", "knowledge"],
|
|
12
|
-
body: `## Why it matters
|
|
1
|
+
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.examples.locale-jurisdiction-gate.goal",title:"Locale/Jurisdiction Gate — Goal",summary:"Fail-closed gate that forces locale + jurisdiction + kbSnapshotId + allowedScope for assistant calls.",kind:"goal",visibility:"public",route:"/docs/examples/locale-jurisdiction-gate/goal",tags:["assistant","policy","locale","jurisdiction","knowledge"],body:`## Why it matters
|
|
13
2
|
- Forces all assistant behavior to be bound to explicit inputs (no guessing).
|
|
14
3
|
- Requires KB snapshot citations to make answers traceable and regenerable.
|
|
15
4
|
|
|
16
5
|
## Guardrails
|
|
17
6
|
- Missing locale/jurisdiction/snapshot/scope => refuse (structured).
|
|
18
7
|
- Missing citations => refuse.
|
|
19
|
-
- Scope violations under education_only => refuse/escalate.`
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: "docs.examples.locale-jurisdiction-gate.reference",
|
|
23
|
-
title: "Locale/Jurisdiction Gate — Reference",
|
|
24
|
-
summary: "Contracts, models, and events exposed by the gate example.",
|
|
25
|
-
kind: "reference",
|
|
26
|
-
visibility: "public",
|
|
27
|
-
route: "/docs/examples/locale-jurisdiction-gate",
|
|
28
|
-
tags: ["assistant", "policy", "reference"],
|
|
29
|
-
body: `## Contracts
|
|
8
|
+
- Scope violations under education_only => refuse/escalate.`},{id:"docs.examples.locale-jurisdiction-gate.reference",title:"Locale/Jurisdiction Gate — Reference",summary:"Contracts, models, and events exposed by the gate example.",kind:"reference",visibility:"public",route:"/docs/examples/locale-jurisdiction-gate",tags:["assistant","policy","reference"],body:`## Contracts
|
|
30
9
|
- assistant.answer (v1)
|
|
31
10
|
- assistant.explainConcept (v1)
|
|
32
11
|
|
|
@@ -37,7 +16,4 @@ var docBlocks = [
|
|
|
37
16
|
## Events
|
|
38
17
|
- assistant.answer.requested
|
|
39
18
|
- assistant.answer.blocked
|
|
40
|
-
- assistant.answer.delivered`
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
registerDocBlocks(docBlocks);
|
|
19
|
+
- assistant.answer.delivered`}];f(h);
|
|
@@ -1,110 +1 @@
|
|
|
1
|
-
|
|
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
|
-
export {
|
|
103
|
-
UserProfileModel,
|
|
104
|
-
RegulatoryContextModel,
|
|
105
|
-
LLMCallEnvelopeModel,
|
|
106
|
-
AssistantCitationModel,
|
|
107
|
-
AssistantAnswerSectionModel,
|
|
108
|
-
AssistantAnswerIRModel,
|
|
109
|
-
AllowedScopeEnum
|
|
110
|
-
};
|
|
1
|
+
import{defineEnum as n,defineSchemaModel as t,ScalarTypeEnum as e}from"@contractspec/lib.schema";var i=n("AllowedScope",["education_only","generic_info","escalation_required"]),l=t({name:"UserProfile",description:"User profile inputs used to derive regulatory context.",fields:{preferredLocale:{type:e.String_unsecure(),isOptional:!0},residencyCountry:{type:e.String_unsecure(),isOptional:!0},taxResidenceCountry:{type:e.String_unsecure(),isOptional:!0},clientType:{type:e.String_unsecure(),isOptional:!0}}}),s=t({name:"RegulatoryContext",description:"Explicit regulatory context (no guessing).",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},region:{type:e.String_unsecure(),isOptional:!0},clientType:{type:e.String_unsecure(),isOptional:!0},allowedScope:{type:i,isOptional:!1}}}),p=t({name:"LLMCallEnvelope",description:"Mandatory envelope for assistant calls. All fields are explicit and required for policy gating.",fields:{traceId:{type:e.String_unsecure(),isOptional:!1},locale:{type:e.String_unsecure(),isOptional:!1},regulatoryContext:{type:s,isOptional:!1},kbSnapshotId:{type:e.String_unsecure(),isOptional:!1},allowedScope:{type:i,isOptional:!1}}}),r=t({name:"AssistantCitation",description:"Citation referencing a KB snapshot + a specific item within it.",fields:{kbSnapshotId:{type:e.String_unsecure(),isOptional:!1},sourceType:{type:e.String_unsecure(),isOptional:!1},sourceId:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!0},excerpt:{type:e.String_unsecure(),isOptional:!0}}}),o=t({name:"AssistantAnswerSection",description:"Structured answer section.",fields:{heading:{type:e.String_unsecure(),isOptional:!1},body:{type:e.String_unsecure(),isOptional:!1}}}),u=t({name:"AssistantAnswerIR",description:"Structured assistant answer with mandatory citations and explicit locale/jurisdiction.",fields:{locale:{type:e.String_unsecure(),isOptional:!1},jurisdiction:{type:e.String_unsecure(),isOptional:!1},allowedScope:{type:i,isOptional:!1},sections:{type:o,isArray:!0,isOptional:!1},citations:{type:r,isArray:!0,isOptional:!1},disclaimers:{type:e.String_unsecure(),isArray:!0,isOptional:!0},riskFlags:{type:e.String_unsecure(),isArray:!0,isOptional:!0},refused:{type:e.Boolean(),isOptional:!0},refusalReason:{type:e.String_unsecure(),isOptional:!0}}});export{l as UserProfileModel,s as RegulatoryContextModel,p as LLMCallEnvelopeModel,r as AssistantCitationModel,o as AssistantAnswerSectionModel,u as AssistantAnswerIRModel,i as AllowedScopeEnum};
|
|
@@ -1,110 +1 @@
|
|
|
1
|
-
|
|
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
|
-
export {
|
|
103
|
-
UserProfileModel,
|
|
104
|
-
RegulatoryContextModel,
|
|
105
|
-
LLMCallEnvelopeModel,
|
|
106
|
-
AssistantCitationModel,
|
|
107
|
-
AssistantAnswerSectionModel,
|
|
108
|
-
AssistantAnswerIRModel,
|
|
109
|
-
AllowedScopeEnum
|
|
110
|
-
};
|
|
1
|
+
import{defineEnum as n,defineSchemaModel as t,ScalarTypeEnum as e}from"@contractspec/lib.schema";var i=n("AllowedScope",["education_only","generic_info","escalation_required"]),l=t({name:"UserProfile",description:"User profile inputs used to derive regulatory context.",fields:{preferredLocale:{type:e.String_unsecure(),isOptional:!0},residencyCountry:{type:e.String_unsecure(),isOptional:!0},taxResidenceCountry:{type:e.String_unsecure(),isOptional:!0},clientType:{type:e.String_unsecure(),isOptional:!0}}}),s=t({name:"RegulatoryContext",description:"Explicit regulatory context (no guessing).",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},region:{type:e.String_unsecure(),isOptional:!0},clientType:{type:e.String_unsecure(),isOptional:!0},allowedScope:{type:i,isOptional:!1}}}),p=t({name:"LLMCallEnvelope",description:"Mandatory envelope for assistant calls. All fields are explicit and required for policy gating.",fields:{traceId:{type:e.String_unsecure(),isOptional:!1},locale:{type:e.String_unsecure(),isOptional:!1},regulatoryContext:{type:s,isOptional:!1},kbSnapshotId:{type:e.String_unsecure(),isOptional:!1},allowedScope:{type:i,isOptional:!1}}}),r=t({name:"AssistantCitation",description:"Citation referencing a KB snapshot + a specific item within it.",fields:{kbSnapshotId:{type:e.String_unsecure(),isOptional:!1},sourceType:{type:e.String_unsecure(),isOptional:!1},sourceId:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!0},excerpt:{type:e.String_unsecure(),isOptional:!0}}}),o=t({name:"AssistantAnswerSection",description:"Structured answer section.",fields:{heading:{type:e.String_unsecure(),isOptional:!1},body:{type:e.String_unsecure(),isOptional:!1}}}),u=t({name:"AssistantAnswerIR",description:"Structured assistant answer with mandatory citations and explicit locale/jurisdiction.",fields:{locale:{type:e.String_unsecure(),isOptional:!1},jurisdiction:{type:e.String_unsecure(),isOptional:!1},allowedScope:{type:i,isOptional:!1},sections:{type:o,isArray:!0,isOptional:!1},citations:{type:r,isArray:!0,isOptional:!1},disclaimers:{type:e.String_unsecure(),isArray:!0,isOptional:!0},riskFlags:{type:e.String_unsecure(),isArray:!0,isOptional:!0},refused:{type:e.Boolean(),isOptional:!0},refusalReason:{type:e.String_unsecure(),isOptional:!0}}});export{l as UserProfileModel,s as RegulatoryContextModel,p as LLMCallEnvelopeModel,r as AssistantCitationModel,o as AssistantAnswerSectionModel,u as AssistantAnswerIRModel,i as AllowedScopeEnum};
|
package/dist/node/events.js
CHANGED
|
@@ -1,73 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
3
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
4
|
-
var AssistantAnswerRequestedPayload = defineSchemaModel({
|
|
5
|
-
name: "AssistantAnswerRequestedPayload",
|
|
6
|
-
description: "Emitted when an assistant answer is requested (pre-gate).",
|
|
7
|
-
fields: {
|
|
8
|
-
traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
-
locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
-
jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
-
kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
-
allowedScope: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
var AssistantAnswerRequestedEvent = defineEvent({
|
|
16
|
-
meta: {
|
|
17
|
-
key: "assistant.answer.requested",
|
|
18
|
-
version: "1.0.0",
|
|
19
|
-
description: "Assistant answer requested (policy gate will run).",
|
|
20
|
-
stability: "experimental",
|
|
21
|
-
owners: ["@examples"],
|
|
22
|
-
tags: ["assistant", "policy"]
|
|
23
|
-
},
|
|
24
|
-
payload: AssistantAnswerRequestedPayload
|
|
25
|
-
});
|
|
26
|
-
var AssistantAnswerBlockedPayload = defineSchemaModel({
|
|
27
|
-
name: "AssistantAnswerBlockedPayload",
|
|
28
|
-
description: "Emitted when a request is blocked by the gate.",
|
|
29
|
-
fields: {
|
|
30
|
-
traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
-
reasonCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
32
|
-
reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
var AssistantAnswerBlockedEvent = defineEvent({
|
|
36
|
-
meta: {
|
|
37
|
-
key: "assistant.answer.blocked",
|
|
38
|
-
version: "1.0.0",
|
|
39
|
-
description: "Assistant answer blocked (fail-closed).",
|
|
40
|
-
stability: "experimental",
|
|
41
|
-
owners: ["@examples"],
|
|
42
|
-
tags: ["assistant", "policy", "blocked"]
|
|
43
|
-
},
|
|
44
|
-
payload: AssistantAnswerBlockedPayload
|
|
45
|
-
});
|
|
46
|
-
var AssistantAnswerDeliveredPayload = defineSchemaModel({
|
|
47
|
-
name: "AssistantAnswerDeliveredPayload",
|
|
48
|
-
description: "Emitted when a structured, cited answer is delivered.",
|
|
49
|
-
fields: {
|
|
50
|
-
traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
51
|
-
locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
52
|
-
jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
53
|
-
kbSnapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
54
|
-
allowedScope: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
55
|
-
citationsCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
var AssistantAnswerDeliveredEvent = defineEvent({
|
|
59
|
-
meta: {
|
|
60
|
-
key: "assistant.answer.delivered",
|
|
61
|
-
version: "1.0.0",
|
|
62
|
-
description: "Assistant answer delivered (must include KB snapshot citations).",
|
|
63
|
-
stability: "experimental",
|
|
64
|
-
owners: ["@examples"],
|
|
65
|
-
tags: ["assistant", "policy", "delivered"]
|
|
66
|
-
},
|
|
67
|
-
payload: AssistantAnswerDeliveredPayload
|
|
68
|
-
});
|
|
69
|
-
export {
|
|
70
|
-
AssistantAnswerRequestedEvent,
|
|
71
|
-
AssistantAnswerDeliveredEvent,
|
|
72
|
-
AssistantAnswerBlockedEvent
|
|
73
|
-
};
|
|
1
|
+
import{defineEvent as j}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as x,ScalarTypeEnum as g}from"@contractspec/lib.schema";var z=x({name:"AssistantAnswerRequestedPayload",description:"Emitted when an assistant answer is requested (pre-gate).",fields:{traceId:{type:g.String_unsecure(),isOptional:!1},locale:{type:g.String_unsecure(),isOptional:!1},jurisdiction:{type:g.String_unsecure(),isOptional:!1},kbSnapshotId:{type:g.String_unsecure(),isOptional:!1},allowedScope:{type:g.String_unsecure(),isOptional:!1}}}),I=j({meta:{key:"assistant.answer.requested",version:"1.0.0",description:"Assistant answer requested (policy gate will run).",stability:"experimental",owners:["@examples"],tags:["assistant","policy"]},payload:z}),C=x({name:"AssistantAnswerBlockedPayload",description:"Emitted when a request is blocked by the gate.",fields:{traceId:{type:g.String_unsecure(),isOptional:!1},reasonCode:{type:g.String_unsecure(),isOptional:!1},reason:{type:g.String_unsecure(),isOptional:!1}}}),J=j({meta:{key:"assistant.answer.blocked",version:"1.0.0",description:"Assistant answer blocked (fail-closed).",stability:"experimental",owners:["@examples"],tags:["assistant","policy","blocked"]},payload:C}),F=x({name:"AssistantAnswerDeliveredPayload",description:"Emitted when a structured, cited answer is delivered.",fields:{traceId:{type:g.String_unsecure(),isOptional:!1},locale:{type:g.String_unsecure(),isOptional:!1},jurisdiction:{type:g.String_unsecure(),isOptional:!1},kbSnapshotId:{type:g.String_unsecure(),isOptional:!1},allowedScope:{type:g.String_unsecure(),isOptional:!1},citationsCount:{type:g.Int_unsecure(),isOptional:!1}}}),K=j({meta:{key:"assistant.answer.delivered",version:"1.0.0",description:"Assistant answer delivered (must include KB snapshot citations).",stability:"experimental",owners:["@examples"],tags:["assistant","policy","delivered"]},payload:F});export{I as AssistantAnswerRequestedEvent,K as AssistantAnswerDeliveredEvent,J as AssistantAnswerBlockedEvent};
|
package/dist/node/example.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineExample } from "@contractspec/lib.contracts-spec";
|
|
3
|
-
var example = defineExample({
|
|
4
|
-
meta: {
|
|
5
|
-
key: "locale-jurisdiction-gate",
|
|
6
|
-
version: "1.0.0",
|
|
7
|
-
title: "Locale / Jurisdiction Gate",
|
|
8
|
-
description: "Fail-closed gating for assistant calls: locale + jurisdiction + kbSnapshotId + allowedScope must be explicit, answers must cite a snapshot.",
|
|
9
|
-
kind: "knowledge",
|
|
10
|
-
visibility: "public",
|
|
11
|
-
stability: "experimental",
|
|
12
|
-
owners: ["@platform.core"],
|
|
13
|
-
tags: ["policy", "locale", "jurisdiction", "assistant", "gating"]
|
|
14
|
-
},
|
|
15
|
-
docs: {
|
|
16
|
-
rootDocId: "docs.examples.locale-jurisdiction-gate"
|
|
17
|
-
},
|
|
18
|
-
entrypoints: {
|
|
19
|
-
packageName: "@contractspec/example.locale-jurisdiction-gate",
|
|
20
|
-
feature: "./feature",
|
|
21
|
-
contracts: "./contracts",
|
|
22
|
-
handlers: "./handlers",
|
|
23
|
-
docs: "./docs"
|
|
24
|
-
},
|
|
25
|
-
surfaces: {
|
|
26
|
-
templates: true,
|
|
27
|
-
sandbox: { enabled: true, modes: ["markdown", "specs"] },
|
|
28
|
-
studio: { enabled: true, installable: true },
|
|
29
|
-
mcp: { enabled: true }
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
var example_default = example;
|
|
33
|
-
export {
|
|
34
|
-
example_default as default
|
|
35
|
-
};
|
|
1
|
+
import{defineExample as g}from"@contractspec/lib.contracts-spec";var h=g({meta:{key:"locale-jurisdiction-gate",version:"1.0.0",title:"Locale / Jurisdiction Gate",description:"Fail-closed gating for assistant calls: locale + jurisdiction + kbSnapshotId + allowedScope must be explicit, answers must cite a snapshot.",kind:"knowledge",visibility:"public",stability:"experimental",owners:["@platform.core"],tags:["policy","locale","jurisdiction","assistant","gating"]},docs:{rootDocId:"docs.examples.locale-jurisdiction-gate"},entrypoints:{packageName:"@contractspec/example.locale-jurisdiction-gate",feature:"./feature",contracts:"./contracts",handlers:"./handlers",docs:"./docs"},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["markdown","specs"]},studio:{enabled:!0,installable:!0},mcp:{enabled:!0}}}),q=h;export{q as default};
|