@contractspec/example.locale-jurisdiction-gate 3.7.6 → 3.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +72 -51
- package/AGENTS.md +50 -27
- package/CHANGELOG.md +21 -0
- package/README.md +87 -42
- package/dist/browser/entities/index.js +2 -2
- package/dist/browser/entities/models.js +2 -2
- package/dist/browser/events.js +1 -1
- package/dist/browser/forms/assistant-context.form.js +213 -0
- package/dist/browser/forms/index.js +213 -0
- package/dist/browser/index.js +362 -40
- package/dist/browser/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/browser/operations/assistant.js +3 -3
- package/dist/browser/operations/index.js +3 -3
- package/dist/browser/policy/assistant-gate.policy.js +62 -0
- package/dist/browser/policy/index.js +62 -1
- package/dist/browser/translations/assistant-gate.en-GB.translation.js +48 -0
- package/dist/browser/translations/assistant-gate.en-US.translation.js +50 -0
- package/dist/browser/translations/assistant-gate.fr-FR.translation.js +52 -0
- package/dist/browser/translations/index.js +148 -0
- package/dist/contracts.test.d.ts +1 -0
- package/dist/entities/index.js +2 -2
- package/dist/entities/models.js +2 -2
- package/dist/events.js +1 -1
- package/dist/forms/assistant-context.form.d.ts +22 -0
- package/dist/forms/assistant-context.form.js +214 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.js +214 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +362 -40
- package/dist/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/node/entities/index.js +2 -2
- package/dist/node/entities/models.js +2 -2
- package/dist/node/events.js +1 -1
- package/dist/node/forms/assistant-context.form.js +213 -0
- package/dist/node/forms/index.js +213 -0
- package/dist/node/index.js +362 -40
- package/dist/node/locale-jurisdiction-gate.feature.js +66 -1
- package/dist/node/operations/assistant.js +3 -3
- package/dist/node/operations/index.js +3 -3
- package/dist/node/policy/assistant-gate.policy.js +62 -0
- package/dist/node/policy/index.js +62 -1
- package/dist/node/translations/assistant-gate.en-GB.translation.js +48 -0
- package/dist/node/translations/assistant-gate.en-US.translation.js +50 -0
- package/dist/node/translations/assistant-gate.fr-FR.translation.js +52 -0
- package/dist/node/translations/index.js +148 -0
- package/dist/operations/assistant.js +3 -3
- package/dist/operations/index.js +3 -3
- package/dist/policy/assistant-gate.policy.d.ts +1 -0
- package/dist/policy/assistant-gate.policy.js +63 -0
- package/dist/policy/index.d.ts +2 -1
- package/dist/policy/index.js +62 -1
- package/dist/translations/assistant-gate.en-GB.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.en-GB.translation.js +49 -0
- package/dist/translations/assistant-gate.en-US.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.en-US.translation.js +51 -0
- package/dist/translations/assistant-gate.fr-FR.translation.d.ts +1 -0
- package/dist/translations/assistant-gate.fr-FR.translation.js +53 -0
- package/dist/translations/index.d.ts +3 -0
- package/dist/translations/index.js +149 -0
- package/package.json +105 -7
- package/src/contracts.test.ts +32 -0
- package/src/docs/locale-jurisdiction-gate.docblock.ts +21 -21
- package/src/entities/models.ts +87 -87
- package/src/events.ts +55 -55
- package/src/example.ts +28 -28
- package/src/forms/assistant-context.form.ts +112 -0
- package/src/forms/index.ts +1 -0
- package/src/handlers/demo.handlers.test.ts +46 -46
- package/src/handlers/demo.handlers.ts +133 -133
- package/src/index.ts +5 -3
- package/src/locale-jurisdiction-gate.feature.ts +40 -34
- package/src/operations/assistant.ts +82 -82
- package/src/policy/assistant-gate.policy.ts +65 -0
- package/src/policy/guard.test.ts +18 -18
- package/src/policy/guard.ts +75 -75
- package/src/policy/index.ts +2 -1
- package/src/policy/types.ts +12 -12
- package/src/translations/assistant-gate.en-GB.translation.ts +46 -0
- package/src/translations/assistant-gate.en-US.translation.ts +48 -0
- package/src/translations/assistant-gate.fr-FR.translation.ts +51 -0
- package/src/translations/index.ts +3 -0
- package/tsconfig.json +7 -15
- package/tsdown.config.js +7 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,61 +2,82 @@ $ contractspec-bun-build prebuild
|
|
|
2
2
|
$ bun run prebuild && bun run build:bundle && bun run build:types
|
|
3
3
|
$ contractspec-bun-build prebuild
|
|
4
4
|
$ contractspec-bun-build transpile
|
|
5
|
-
[contractspec-bun-build] transpile target=bun root=src entries=
|
|
6
|
-
Bundled
|
|
5
|
+
[contractspec-bun-build] transpile target=bun root=src entries=22 noBundle=false
|
|
6
|
+
Bundled 22 modules in 17ms
|
|
7
7
|
|
|
8
|
-
docs/index.js
|
|
9
|
-
./index.js
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
./
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
policy/guard.js
|
|
8
|
+
docs/index.js 1.64 KB (entry point)
|
|
9
|
+
./index.js 30.25 KB (entry point)
|
|
10
|
+
policy/index.js 4.12 KB (entry point)
|
|
11
|
+
policy/types.js 8 bytes (entry point)
|
|
12
|
+
translations/index.js 5.92 KB (entry point)
|
|
13
|
+
translations/assistant-gate.en-GB.translation.js 1.85 KB (entry point)
|
|
14
|
+
translations/assistant-gate.en-US.translation.js 2.0 KB (entry point)
|
|
15
|
+
translations/assistant-gate.fr-FR.translation.js 1.94 KB (entry point)
|
|
16
|
+
handlers/index.js 4.45 KB (entry point)
|
|
17
|
+
handlers/demo.handlers.js 4.45 KB (entry point)
|
|
18
|
+
./locale-jurisdiction-gate.feature.js 3.48 KB (entry point)
|
|
19
|
+
operations/index.js 6.95 KB (entry point)
|
|
20
|
+
operations/assistant.js 6.95 KB (entry point)
|
|
21
|
+
policy/assistant-gate.policy.js 2.10 KB (entry point)
|
|
22
|
+
policy/guard.js 2.0 KB (entry point)
|
|
23
|
+
docs/locale-jurisdiction-gate.docblock.js 1.64 KB (entry point)
|
|
24
|
+
entities/index.js 3.89 KB (entry point)
|
|
25
|
+
./events.js 2.97 KB (entry point)
|
|
26
|
+
./example.js 1.1 KB (entry point)
|
|
27
|
+
forms/index.js 7.15 KB (entry point)
|
|
28
|
+
forms/assistant-context.form.js 7.15 KB (entry point)
|
|
29
|
+
entities/models.js 3.89 KB (entry point)
|
|
23
30
|
|
|
24
|
-
[contractspec-bun-build] transpile target=node root=src entries=
|
|
25
|
-
Bundled
|
|
31
|
+
[contractspec-bun-build] transpile target=node root=src entries=22 noBundle=false
|
|
32
|
+
Bundled 22 modules in 38ms
|
|
26
33
|
|
|
27
|
-
docs/index.js
|
|
28
|
-
./index.js
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
./
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
policy/guard.js
|
|
34
|
+
docs/index.js 1.63 KB (entry point)
|
|
35
|
+
./index.js 30.21 KB (entry point)
|
|
36
|
+
policy/index.js 4.11 KB (entry point)
|
|
37
|
+
policy/types.js 0 KB (entry point)
|
|
38
|
+
translations/index.js 5.89 KB (entry point)
|
|
39
|
+
translations/assistant-gate.en-GB.translation.js 1.84 KB (entry point)
|
|
40
|
+
translations/assistant-gate.en-US.translation.js 2.0 KB (entry point)
|
|
41
|
+
translations/assistant-gate.fr-FR.translation.js 1.90 KB (entry point)
|
|
42
|
+
handlers/index.js 4.44 KB (entry point)
|
|
43
|
+
handlers/demo.handlers.js 4.44 KB (entry point)
|
|
44
|
+
./locale-jurisdiction-gate.feature.js 3.47 KB (entry point)
|
|
45
|
+
operations/index.js 6.94 KB (entry point)
|
|
46
|
+
operations/assistant.js 6.94 KB (entry point)
|
|
47
|
+
policy/assistant-gate.policy.js 2.1 KB (entry point)
|
|
48
|
+
policy/guard.js 2.0 KB (entry point)
|
|
49
|
+
docs/locale-jurisdiction-gate.docblock.js 1.63 KB (entry point)
|
|
50
|
+
entities/index.js 3.88 KB (entry point)
|
|
51
|
+
./events.js 2.96 KB (entry point)
|
|
52
|
+
./example.js 1.1 KB (entry point)
|
|
53
|
+
forms/index.js 7.14 KB (entry point)
|
|
54
|
+
forms/assistant-context.form.js 7.14 KB (entry point)
|
|
55
|
+
entities/models.js 3.88 KB (entry point)
|
|
42
56
|
|
|
43
|
-
[contractspec-bun-build] transpile target=browser root=src entries=
|
|
44
|
-
Bundled
|
|
57
|
+
[contractspec-bun-build] transpile target=browser root=src entries=22 noBundle=false
|
|
58
|
+
Bundled 22 modules in 28ms
|
|
45
59
|
|
|
46
|
-
docs/index.js
|
|
47
|
-
./index.js
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
./
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
policy/guard.js
|
|
60
|
+
docs/index.js 1.63 KB (entry point)
|
|
61
|
+
./index.js 30.21 KB (entry point)
|
|
62
|
+
policy/index.js 4.11 KB (entry point)
|
|
63
|
+
policy/types.js 0 KB (entry point)
|
|
64
|
+
translations/index.js 5.89 KB (entry point)
|
|
65
|
+
translations/assistant-gate.en-GB.translation.js 1.84 KB (entry point)
|
|
66
|
+
translations/assistant-gate.en-US.translation.js 2.0 KB (entry point)
|
|
67
|
+
translations/assistant-gate.fr-FR.translation.js 1.90 KB (entry point)
|
|
68
|
+
handlers/index.js 4.44 KB (entry point)
|
|
69
|
+
handlers/demo.handlers.js 4.44 KB (entry point)
|
|
70
|
+
./locale-jurisdiction-gate.feature.js 3.47 KB (entry point)
|
|
71
|
+
operations/index.js 6.94 KB (entry point)
|
|
72
|
+
operations/assistant.js 6.94 KB (entry point)
|
|
73
|
+
policy/assistant-gate.policy.js 2.1 KB (entry point)
|
|
74
|
+
policy/guard.js 2.0 KB (entry point)
|
|
75
|
+
docs/locale-jurisdiction-gate.docblock.js 1.63 KB (entry point)
|
|
76
|
+
entities/index.js 3.88 KB (entry point)
|
|
77
|
+
./events.js 2.96 KB (entry point)
|
|
78
|
+
./example.js 1.1 KB (entry point)
|
|
79
|
+
forms/index.js 7.14 KB (entry point)
|
|
80
|
+
forms/assistant-context.form.js 7.14 KB (entry point)
|
|
81
|
+
entities/models.js 3.88 KB (entry point)
|
|
61
82
|
|
|
62
83
|
$ contractspec-bun-build types
|
package/AGENTS.md
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
|
-
# AI Agent Guide
|
|
1
|
+
# AI Agent Guide — `@contractspec/example.locale-jurisdiction-gate`
|
|
2
2
|
|
|
3
3
|
Scope: `packages/examples/locale-jurisdiction-gate/*`
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Example: enforce locale + jurisdiction + kbSnapshotId + allowed scope for assistant calls (fail-closed).
|
|
6
6
|
|
|
7
7
|
## Quick Context
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
- `./
|
|
28
|
-
- `./locale-jurisdiction-gate.
|
|
29
|
-
- `./
|
|
9
|
+
- Layer: `example`.
|
|
10
|
+
- Package visibility: published package.
|
|
11
|
+
- Primary consumers are example explorers, template authors, and documentation readers.
|
|
12
|
+
- Related packages: `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
17
|
+
- `src/entities/` contains domain entities and value objects.
|
|
18
|
+
- `src/events.ts` is package-level event definitions.
|
|
19
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
20
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
21
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
22
|
+
- `src/locale-jurisdiction-gate.feature.ts` defines a feature entrypoint.
|
|
23
|
+
|
|
24
|
+
## Public Surface
|
|
25
|
+
|
|
26
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
27
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
28
|
+
- Export `./docs/locale-jurisdiction-gate.docblock` resolves through `./src/docs/locale-jurisdiction-gate.docblock.ts`.
|
|
29
|
+
- Export `./entities` resolves through `./src/entities/index.ts`.
|
|
30
|
+
- Export `./entities/models` resolves through `./src/entities/models.ts`.
|
|
31
|
+
- Export `./events` resolves through `./src/events.ts`.
|
|
32
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
33
|
+
- Export `./handlers` resolves through `./src/handlers/index.ts`.
|
|
34
|
+
- Export `./handlers/demo.handlers` resolves through `./src/handlers/demo.handlers.ts`.
|
|
35
|
+
- Export `./locale-jurisdiction-gate.feature` resolves through `./src/locale-jurisdiction-gate.feature.ts`.
|
|
36
|
+
- The package publishes 15 total export subpaths; keep docs aligned with `package.json`.
|
|
37
|
+
|
|
38
|
+
## Guardrails
|
|
39
|
+
|
|
40
|
+
- Keep the example package demonstrative, buildable, and aligned with the exported feature surface.
|
|
41
|
+
- Do not add hidden production assumptions that are not actually implemented in the example.
|
|
42
|
+
- Changes here can affect downstream packages such as `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
43
|
+
- Changes here can affect downstream packages such as `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
30
44
|
|
|
31
45
|
## Local Commands
|
|
32
46
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
47
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
48
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
49
|
+
- `bun run test` — bun test
|
|
50
|
+
- `bun run lint` — bun lint:fix
|
|
51
|
+
- `bun run lint:check` — biome check .
|
|
52
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
53
|
+
- `bun run typecheck` — tsc --noEmit
|
|
54
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
55
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
56
|
+
- `bun run clean` — rimraf dist .turbo
|
|
57
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
58
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
59
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @contractspec/example.locale-jurisdiction-gate
|
|
2
2
|
|
|
3
|
+
## 3.7.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1a44cb6: feat: improve examples to increase coverage of Contracts type
|
|
8
|
+
- Updated dependencies [1a44cb6]
|
|
9
|
+
- @contractspec/lib.contracts-spec@4.1.2
|
|
10
|
+
- @contractspec/lib.schema@3.7.8
|
|
11
|
+
|
|
12
|
+
## 3.7.9
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- fix: release
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @contractspec/lib.contracts-spec@4.1.1
|
|
19
|
+
- @contractspec/lib.schema@3.7.7
|
|
20
|
+
|
|
3
21
|
## 3.7.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -704,14 +722,17 @@
|
|
|
704
722
|
feat: Contract layers support (features, examples, app-configs)
|
|
705
723
|
|
|
706
724
|
### New CLI Commands
|
|
725
|
+
|
|
707
726
|
- `contractspec list layers` - List all contract layers with filtering
|
|
708
727
|
|
|
709
728
|
### Enhanced Commands
|
|
729
|
+
|
|
710
730
|
- `contractspec ci` - New `layers` check category validates features/examples/config
|
|
711
731
|
- `contractspec doctor` - New `layers` health checks
|
|
712
732
|
- `contractspec integrity` - Now shows layer statistics
|
|
713
733
|
|
|
714
734
|
### New APIs
|
|
735
|
+
|
|
715
736
|
- `discoverLayers()` - Scan workspace for all layer files
|
|
716
737
|
- `scanExampleSource()` - Parse ExampleSpec from source code
|
|
717
738
|
- `isExampleFile()` - Check if file is an example spec
|
package/README.md
CHANGED
|
@@ -1,42 +1,87 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Website: https://contractspec.io
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- `
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- `
|
|
24
|
-
- `
|
|
25
|
-
- `
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
# @contractspec/example.locale-jurisdiction-gate
|
|
2
|
+
|
|
3
|
+
Website: https://contractspec.io
|
|
4
|
+
|
|
5
|
+
**Example: enforce locale + jurisdiction + kbSnapshotId + allowed scope for assistant calls (fail-closed).**
|
|
6
|
+
|
|
7
|
+
## What This Demonstrates
|
|
8
|
+
|
|
9
|
+
- Canonical `policy` export via `AssistantGatePolicy`.
|
|
10
|
+
- Canonical `form` export via `AssistantContextForm`.
|
|
11
|
+
- Canonical `translation` exports for `en-US`, `en-GB`, and `fr-FR`.
|
|
12
|
+
- Fail-closed policy guard pattern for AI assistant calls.
|
|
13
|
+
- Entity models for locale/jurisdiction gating.
|
|
14
|
+
- Event-driven policy enforcement.
|
|
15
|
+
- Handler and operation separation with typed operations.
|
|
16
|
+
- Feature definition pattern.
|
|
17
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
18
|
+
|
|
19
|
+
## Running Locally
|
|
20
|
+
|
|
21
|
+
From `packages/examples/locale-jurisdiction-gate`:
|
|
22
|
+
- `bun run dev`
|
|
23
|
+
- `bun run build`
|
|
24
|
+
- `bun run test`
|
|
25
|
+
- `bun run typecheck`
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Use `@contractspec/example.locale-jurisdiction-gate` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
34
|
+
- `src/entities/` contains domain entities and value objects.
|
|
35
|
+
- `src/events.ts` is package-level event definitions.
|
|
36
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
37
|
+
- `src/forms/` contains the exported assistant context form spec.
|
|
38
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
39
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
40
|
+
- `src/locale-jurisdiction-gate.feature.ts` defines a feature entrypoint.
|
|
41
|
+
- `src/translations/` contains the exported locale catalogs.
|
|
42
|
+
|
|
43
|
+
## Public Entry Points
|
|
44
|
+
|
|
45
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
46
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
47
|
+
- Export `./docs/locale-jurisdiction-gate.docblock` resolves through `./src/docs/locale-jurisdiction-gate.docblock.ts`.
|
|
48
|
+
- Export `./entities` resolves through `./src/entities/index.ts`.
|
|
49
|
+
- Export `./entities/models` resolves through `./src/entities/models.ts`.
|
|
50
|
+
- Export `./events` resolves through `./src/events.ts`.
|
|
51
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
52
|
+
- Export `./forms` resolves through `./src/forms/index.ts`.
|
|
53
|
+
- Export `./forms/assistant-context.form` resolves through `./src/forms/assistant-context.form.ts`.
|
|
54
|
+
- Export `./handlers` resolves through `./src/handlers/index.ts`.
|
|
55
|
+
- Export `./handlers/demo.handlers` resolves through `./src/handlers/demo.handlers.ts`.
|
|
56
|
+
- Export `./locale-jurisdiction-gate.feature` resolves through `./src/locale-jurisdiction-gate.feature.ts`.
|
|
57
|
+
- Export `./policy/assistant-gate.policy` resolves through `./src/policy/assistant-gate.policy.ts`.
|
|
58
|
+
- Export `./translations` resolves through `./src/translations/index.ts`.
|
|
59
|
+
- Export `./translations/assistant-gate.en-GB.translation` resolves through `./src/translations/assistant-gate.en-GB.translation.ts`.
|
|
60
|
+
- Export `./translations/assistant-gate.en-US.translation` resolves through `./src/translations/assistant-gate.en-US.translation.ts`.
|
|
61
|
+
- Export `./translations/assistant-gate.fr-FR.translation` resolves through `./src/translations/assistant-gate.fr-FR.translation.ts`.
|
|
62
|
+
- The package publishes 21 total export subpaths; keep docs aligned with `package.json`.
|
|
63
|
+
|
|
64
|
+
## Local Commands
|
|
65
|
+
|
|
66
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
67
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
68
|
+
- `bun run test` — bun test
|
|
69
|
+
- `bun run lint` — bun lint:fix
|
|
70
|
+
- `bun run lint:check` — biome check .
|
|
71
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
72
|
+
- `bun run typecheck` — tsc --noEmit
|
|
73
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
74
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
75
|
+
- `bun run clean` — rimraf dist .turbo
|
|
76
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
77
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
78
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
79
|
+
|
|
80
|
+
## Recent Updates
|
|
81
|
+
|
|
82
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
83
|
+
- Missing contract layers.
|
|
84
|
+
|
|
85
|
+
## Notes
|
|
86
|
+
|
|
87
|
+
- Works alongside `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
package/dist/browser/events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/events.ts
|
|
2
2
|
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
3
|
-
import {
|
|
3
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
4
4
|
var AssistantAnswerRequestedPayload = defineSchemaModel({
|
|
5
5
|
name: "AssistantAnswerRequestedPayload",
|
|
6
6
|
description: "Emitted when an assistant answer is requested (pre-gate).",
|
|
@@ -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
|
+
};
|