@contractspec/example.policy-safe-knowledge-assistant 1.57.0 → 1.58.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.
Files changed (88) hide show
  1. package/.turbo/turbo-build.log +58 -60
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +21 -0
  4. package/dist/browser/docs/index.js +38 -0
  5. package/dist/browser/docs/policy-safe-knowledge-assistant.docblock.js +38 -0
  6. package/dist/browser/example.js +37 -0
  7. package/dist/browser/handlers/index.js +334 -0
  8. package/dist/browser/handlers/policy-safe-knowledge-assistant.handlers.js +334 -0
  9. package/dist/browser/index.js +917 -0
  10. package/dist/browser/orchestrator/buildAnswer.js +73 -0
  11. package/dist/browser/policy-safe-knowledge-assistant.feature.js +57 -0
  12. package/dist/browser/seed/fixtures.js +35 -0
  13. package/dist/browser/seed/index.js +35 -0
  14. package/dist/browser/seeders/index.js +12 -0
  15. package/dist/browser/ui/PolicySafeKnowledgeAssistantDashboard.js +420 -0
  16. package/dist/browser/ui/hooks/usePolicySafeKnowledgeAssistant.js +154 -0
  17. package/dist/browser/ui/index.js +420 -0
  18. package/dist/docs/index.d.ts +2 -1
  19. package/dist/docs/index.d.ts.map +1 -0
  20. package/dist/docs/index.js +39 -1
  21. package/dist/docs/policy-safe-knowledge-assistant.docblock.d.ts +2 -1
  22. package/dist/docs/policy-safe-knowledge-assistant.docblock.d.ts.map +1 -0
  23. package/dist/docs/policy-safe-knowledge-assistant.docblock.js +37 -33
  24. package/dist/example.d.ts +2 -6
  25. package/dist/example.d.ts.map +1 -1
  26. package/dist/example.js +36 -51
  27. package/dist/handlers/index.d.ts +2 -2
  28. package/dist/handlers/index.d.ts.map +1 -0
  29. package/dist/handlers/index.js +334 -2
  30. package/dist/handlers/policy-safe-knowledge-assistant.handlers.d.ts +124 -121
  31. package/dist/handlers/policy-safe-knowledge-assistant.handlers.d.ts.map +1 -1
  32. package/dist/handlers/policy-safe-knowledge-assistant.handlers.js +325 -254
  33. package/dist/index.d.ts +11 -8
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +918 -10
  36. package/dist/integration.test.d.ts +2 -0
  37. package/dist/integration.test.d.ts.map +1 -0
  38. package/dist/node/docs/index.js +38 -0
  39. package/dist/node/docs/policy-safe-knowledge-assistant.docblock.js +38 -0
  40. package/dist/node/example.js +37 -0
  41. package/dist/node/handlers/index.js +334 -0
  42. package/dist/node/handlers/policy-safe-knowledge-assistant.handlers.js +334 -0
  43. package/dist/node/index.js +917 -0
  44. package/dist/node/orchestrator/buildAnswer.js +73 -0
  45. package/dist/node/policy-safe-knowledge-assistant.feature.js +57 -0
  46. package/dist/node/seed/fixtures.js +35 -0
  47. package/dist/node/seed/index.js +35 -0
  48. package/dist/node/seeders/index.js +12 -0
  49. package/dist/node/ui/PolicySafeKnowledgeAssistantDashboard.js +420 -0
  50. package/dist/node/ui/hooks/usePolicySafeKnowledgeAssistant.js +154 -0
  51. package/dist/node/ui/index.js +420 -0
  52. package/dist/orchestrator/buildAnswer.d.ts +40 -42
  53. package/dist/orchestrator/buildAnswer.d.ts.map +1 -1
  54. package/dist/orchestrator/buildAnswer.js +72 -75
  55. package/dist/policy-safe-knowledge-assistant.feature.d.ts +1 -6
  56. package/dist/policy-safe-knowledge-assistant.feature.d.ts.map +1 -1
  57. package/dist/policy-safe-knowledge-assistant.feature.js +56 -148
  58. package/dist/seed/fixtures.d.ts +28 -31
  59. package/dist/seed/fixtures.d.ts.map +1 -1
  60. package/dist/seed/fixtures.js +35 -33
  61. package/dist/seed/index.d.ts +2 -2
  62. package/dist/seed/index.d.ts.map +1 -0
  63. package/dist/seed/index.js +36 -3
  64. package/dist/seeders/index.d.ts +4 -8
  65. package/dist/seeders/index.d.ts.map +1 -1
  66. package/dist/seeders/index.js +11 -14
  67. package/dist/ui/PolicySafeKnowledgeAssistantDashboard.d.ts +1 -6
  68. package/dist/ui/PolicySafeKnowledgeAssistantDashboard.d.ts.map +1 -1
  69. package/dist/ui/PolicySafeKnowledgeAssistantDashboard.js +415 -225
  70. package/dist/ui/hooks/usePolicySafeKnowledgeAssistant.d.ts +49 -51
  71. package/dist/ui/hooks/usePolicySafeKnowledgeAssistant.d.ts.map +1 -1
  72. package/dist/ui/hooks/usePolicySafeKnowledgeAssistant.js +147 -185
  73. package/dist/ui/index.d.ts +2 -2
  74. package/dist/ui/index.d.ts.map +1 -0
  75. package/dist/ui/index.js +420 -2
  76. package/package.json +173 -44
  77. package/tsdown.config.js +1 -2
  78. package/.turbo/turbo-build$colon$bundle.log +0 -60
  79. package/dist/docs/policy-safe-knowledge-assistant.docblock.js.map +0 -1
  80. package/dist/example.js.map +0 -1
  81. package/dist/handlers/policy-safe-knowledge-assistant.handlers.js.map +0 -1
  82. package/dist/orchestrator/buildAnswer.js.map +0 -1
  83. package/dist/policy-safe-knowledge-assistant.feature.js.map +0 -1
  84. package/dist/seed/fixtures.js.map +0 -1
  85. package/dist/seeders/index.js.map +0 -1
  86. package/dist/ui/PolicySafeKnowledgeAssistantDashboard.js.map +0 -1
  87. package/dist/ui/hooks/usePolicySafeKnowledgeAssistant.js.map +0 -1
  88. package/tsconfig.tsbuildinfo +0 -1
@@ -1,126 +1,129 @@
1
- import { AssistantAnswerIR } from "../orchestrator/buildAnswer.js";
2
- import "../index.js";
3
- import { DatabasePort } from "@contractspec/lib.runtime-sandbox";
4
-
5
- //#region src/handlers/policy-safe-knowledge-assistant.handlers.d.ts
1
+ /**
2
+ * Runtime-local handlers for the Policy-safe Knowledge Assistant template.
3
+ *
4
+ * These handlers are intentionally minimal and deterministic:
5
+ * - No external LLM calls
6
+ * - No web fetching as primary truth
7
+ * - Answers are derived from KB snapshots and must include citations
8
+ */
9
+ import type { DatabasePort } from '@contractspec/lib.runtime-sandbox';
6
10
  type AllowedScope = 'education_only' | 'generic_info' | 'escalation_required';
7
11
  type RiskLevel = 'low' | 'medium' | 'high';
8
12
  type ReviewRole = 'curator' | 'expert';
9
- declare function createPolicySafeKnowledgeAssistantHandlers(db: DatabasePort): {
10
- getUserContext: (input: {
11
- projectId: string;
12
- }) => Promise<{
13
- projectId: string;
14
- locale: string;
15
- jurisdiction: string;
16
- allowedScope: AllowedScope;
17
- kbSnapshotId: string | null;
18
- }>;
19
- setUserContext: (input: {
20
- projectId: string;
21
- locale: string;
22
- jurisdiction: string;
23
- allowedScope: AllowedScope;
24
- }) => Promise<{
25
- projectId: string;
26
- locale: string;
27
- jurisdiction: string;
28
- allowedScope: AllowedScope;
29
- kbSnapshotId: string | null;
30
- }>;
31
- createRule: (input: {
32
- projectId: string;
33
- jurisdiction: string;
34
- topicKey: string;
35
- }) => Promise<{
36
- projectId: string;
37
- jurisdiction: string;
38
- topicKey: string;
39
- id: string;
40
- }>;
41
- upsertRuleVersion: (input: {
42
- projectId: string;
43
- ruleId: string;
44
- content: string;
45
- sourceRefs: {
46
- sourceDocumentId: string;
47
- excerpt?: string;
48
- }[];
49
- }) => Promise<{
50
- id: string;
51
- ruleId: string;
52
- jurisdiction: string;
53
- topicKey: string;
54
- version: number;
55
- content: string;
56
- status: string;
57
- sourceRefs: {
58
- sourceDocumentId: string;
59
- excerpt?: string;
60
- }[];
61
- createdAt: Date;
62
- }>;
63
- approveRuleVersion: (input: {
64
- ruleVersionId: string;
65
- approver: string;
66
- }) => Promise<{
67
- ruleVersionId: string;
68
- status: "approved";
69
- }>;
70
- publishSnapshot: (input: {
71
- projectId: string;
72
- jurisdiction: string;
73
- asOfDate: Date;
74
- }) => Promise<{
75
- id: string;
76
- jurisdiction: string;
77
- includedRuleVersionIds: string[];
78
- }>;
79
- searchKb: (input: {
80
- snapshotId: string;
81
- jurisdiction: string;
82
- query: string;
83
- }) => Promise<{
84
- items: {
85
- ruleVersionId: string;
86
- excerpt?: string;
87
- }[];
88
- }>;
89
- answer: (input: {
90
- projectId: string;
91
- question: string;
92
- }) => Promise<AssistantAnswerIR>;
93
- createChangeCandidate: (input: {
94
- projectId: string;
95
- jurisdiction: string;
96
- diffSummary: string;
97
- riskLevel: RiskLevel;
98
- proposedRuleVersionIds: string[];
99
- }) => Promise<{
100
- id: string;
101
- }>;
102
- createReviewTask: (input: {
103
- changeCandidateId: string;
104
- }) => Promise<{
105
- id: string;
106
- assignedRole: ReviewRole;
107
- }>;
108
- submitDecision: (input: {
109
- reviewTaskId: string;
110
- decision: "approve" | "reject";
111
- decidedByRole: ReviewRole;
112
- decidedBy: string;
113
- }) => Promise<{
114
- id: string;
115
- status: "decided";
116
- }>;
117
- publishIfReady: (input: {
118
- jurisdiction: string;
119
- }) => Promise<{
120
- published: true;
121
- }>;
13
+ export declare function createPolicySafeKnowledgeAssistantHandlers(db: DatabasePort): {
14
+ getUserContext: (input: {
15
+ projectId: string;
16
+ }) => Promise<{
17
+ projectId: string;
18
+ locale: string;
19
+ jurisdiction: string;
20
+ allowedScope: AllowedScope;
21
+ kbSnapshotId: string | null;
22
+ }>;
23
+ setUserContext: (input: {
24
+ projectId: string;
25
+ locale: string;
26
+ jurisdiction: string;
27
+ allowedScope: AllowedScope;
28
+ }) => Promise<{
29
+ projectId: string;
30
+ locale: string;
31
+ jurisdiction: string;
32
+ allowedScope: AllowedScope;
33
+ kbSnapshotId: string | null;
34
+ }>;
35
+ createRule: (input: {
36
+ projectId: string;
37
+ jurisdiction: string;
38
+ topicKey: string;
39
+ }) => Promise<{
40
+ projectId: string;
41
+ jurisdiction: string;
42
+ topicKey: string;
43
+ id: string;
44
+ }>;
45
+ upsertRuleVersion: (input: {
46
+ projectId: string;
47
+ ruleId: string;
48
+ content: string;
49
+ sourceRefs: {
50
+ sourceDocumentId: string;
51
+ excerpt?: string;
52
+ }[];
53
+ }) => Promise<{
54
+ id: string;
55
+ ruleId: string;
56
+ jurisdiction: string;
57
+ topicKey: string;
58
+ version: number;
59
+ content: string;
60
+ status: string;
61
+ sourceRefs: {
62
+ sourceDocumentId: string;
63
+ excerpt?: string;
64
+ }[];
65
+ createdAt: Date;
66
+ }>;
67
+ approveRuleVersion: (input: {
68
+ ruleVersionId: string;
69
+ approver: string;
70
+ }) => Promise<{
71
+ ruleVersionId: string;
72
+ status: "approved";
73
+ }>;
74
+ publishSnapshot: (input: {
75
+ projectId: string;
76
+ jurisdiction: string;
77
+ asOfDate: Date;
78
+ }) => Promise<{
79
+ id: string;
80
+ jurisdiction: string;
81
+ includedRuleVersionIds: string[];
82
+ }>;
83
+ searchKb: (input: {
84
+ snapshotId: string;
85
+ jurisdiction: string;
86
+ query: string;
87
+ }) => Promise<{
88
+ items: {
89
+ ruleVersionId: string;
90
+ excerpt?: string;
91
+ }[];
92
+ }>;
93
+ answer: (input: {
94
+ projectId: string;
95
+ question: string;
96
+ }) => Promise<import("..").AssistantAnswerIR>;
97
+ createChangeCandidate: (input: {
98
+ projectId: string;
99
+ jurisdiction: string;
100
+ diffSummary: string;
101
+ riskLevel: RiskLevel;
102
+ proposedRuleVersionIds: string[];
103
+ }) => Promise<{
104
+ id: string;
105
+ }>;
106
+ createReviewTask: (input: {
107
+ changeCandidateId: string;
108
+ }) => Promise<{
109
+ id: string;
110
+ assignedRole: ReviewRole;
111
+ }>;
112
+ submitDecision: (input: {
113
+ reviewTaskId: string;
114
+ decision: "approve" | "reject";
115
+ decidedByRole: ReviewRole;
116
+ decidedBy: string;
117
+ }) => Promise<{
118
+ id: string;
119
+ status: "decided";
120
+ }>;
121
+ publishIfReady: (input: {
122
+ jurisdiction: string;
123
+ }) => Promise<{
124
+ published: true;
125
+ }>;
122
126
  };
123
- type PolicySafeKnowledgeAssistantHandlers = ReturnType<typeof createPolicySafeKnowledgeAssistantHandlers>;
124
- //#endregion
125
- export { PolicySafeKnowledgeAssistantHandlers, createPolicySafeKnowledgeAssistantHandlers };
127
+ export type PolicySafeKnowledgeAssistantHandlers = ReturnType<typeof createPolicySafeKnowledgeAssistantHandlers>;
128
+ export {};
126
129
  //# sourceMappingURL=policy-safe-knowledge-assistant.handlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"policy-safe-knowledge-assistant.handlers.d.ts","names":[],"sources":["../../src/handlers/policy-safe-knowledge-assistant.handlers.ts"],"mappings":";;;;;KAcK,YAAA;AAAA,KACA,SAAA;AAAA,KACA,UAAA;AAAA,iBA2EW,0CAAA,CAA2C,EAAA,EAAI,YAAA;;IACtB,SAAA;EAAA,MAAmB,OAAA;;;;;;;;IAyBxD,SAAA;IACA,MAAA;IACA,YAAA;IACA,YAAA,EAAc,YAAA;EAAA,MACf,OAAA;;;;;;;;IA0BC,SAAA;IACA,YAAA;IACA,QAAA;EAAA,MACD,OAAA;;;;;;;IAUC,SAAA;IACA,MAAA;IACA,OAAA;IACA,UAAA;MAAc,gBAAA;MAA0B,OAAA;IAAA;EAAA,MACzC,OAAA;;;;;;;;;;;;;;;IAkDC,aAAA;IACA,QAAA;EAAA,MACD,OAAA;;;;;IAUC,SAAA;IACA,YAAA;IACA,QAAA,EAAU,IAAA;EAAA,MACX,OAAA;;;;;;IAmCC,UAAA;IACA,YAAA;IACA,KAAA;EAAA,MACD,OAAA;;;;;;;IAiC8B,SAAA;IAAmB,QAAA;EAAA,MAAkB,OAAA,CAjCnE,iBAAA;;IAgEC,SAAA;IACA,YAAA;IACA,WAAA;IACA,SAAA,EAAW,SAAA;IACX,sBAAA;EAAA,MACD,OAAA;;;;IAkBwC,iBAAA;EAAA,MAA2B,OAAA;;;;;IAmBlE,YAAA;IACA,QAAA;IACA,aAAA,EAAe,UAAA;IACf,SAAA;EAAA,MACD,OAAA;;;;;IAoCsC,YAAA;EAAA,MAAsB,OAAA;;;;KA4DnD,oCAAA,GAAuC,UAAA,QAC1C,0CAAA"}
1
+ {"version":3,"file":"policy-safe-knowledge-assistant.handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/policy-safe-knowledge-assistant.handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAS,MAAM,mCAAmC,CAAC;AAM7E,KAAK,YAAY,GAAG,gBAAgB,GAAG,cAAc,GAAG,qBAAqB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