@contractspec/example.policy-safe-knowledge-assistant 1.56.1 → 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 +59 -56
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +46 -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 +35 -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 -122
  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 +174 -45
  77. package/tsdown.config.js +1 -2
  78. package/.turbo/turbo-build$colon$bundle.log +0 -55
  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
package/dist/index.js CHANGED
@@ -1,10 +1,918 @@
1
- import example_default from "./example.js";
2
- import { PolicySafeKnowledgeAssistantFeature } from "./policy-safe-knowledge-assistant.feature.js";
3
- import { DEMO_FIXTURES } from "./seed/fixtures.js";
4
- import { buildPolicySafeAnswer } from "./orchestrator/buildAnswer.js";
5
- import { createPolicySafeKnowledgeAssistantHandlers } from "./handlers/policy-safe-knowledge-assistant.handlers.js";
6
- import { PolicySafeKnowledgeAssistantDashboard } from "./ui/PolicySafeKnowledgeAssistantDashboard.js";
7
- import "./ui/index.js";
8
- import "./docs/index.js";
9
-
10
- export { DEMO_FIXTURES, PolicySafeKnowledgeAssistantDashboard, PolicySafeKnowledgeAssistantFeature, buildPolicySafeAnswer, createPolicySafeKnowledgeAssistantHandlers, example_default as example };
1
+ // @bun
2
+ // src/docs/policy-safe-knowledge-assistant.docblock.ts
3
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
4
+ var docBlocks = [
5
+ {
6
+ id: "docs.examples.policy-safe-knowledge-assistant.goal",
7
+ title: "Policy-safe Knowledge Assistant \u2014 Goal",
8
+ summary: "End-to-end example: versioned KB snapshots + locale/jurisdiction gating + HITL pipeline + learning hub.",
9
+ kind: "goal",
10
+ visibility: "public",
11
+ route: "/docs/examples/policy-safe-knowledge-assistant/goal",
12
+ tags: ["assistant", "knowledge", "policy", "hitl", "learning"],
13
+ body: `## What this template proves
14
+ - Assistant answers are structured and must cite a KB snapshot (or refuse).
15
+ - Locale + jurisdiction are mandatory inputs for every assistant call.
16
+ - Automation proposes KB patches; humans verify; publishing stays blocked until approvals.
17
+ - Learning hub demonstrates drills + coaching + quests without spam.
18
+
19
+ ## Offline-first
20
+ - Seeded fixtures are deterministic and require no external services.
21
+ - Optional non-authoritative fallback can be added behind a single feature flag (disabled by default).`
22
+ },
23
+ {
24
+ id: "docs.examples.policy-safe-knowledge-assistant.usage",
25
+ title: "Policy-safe Knowledge Assistant \u2014 Usage",
26
+ summary: "5\u201310 minute sandbox walkthrough for developers.",
27
+ kind: "usage",
28
+ visibility: "public",
29
+ route: "/docs/examples/policy-safe-knowledge-assistant/usage",
30
+ tags: ["assistant", "knowledge", "usage"],
31
+ body: `## Demo walkthrough (high level)
32
+ 1) Onboard: set locale + jurisdiction.
33
+ 2) Publish snapshot: ingest source -> propose rule -> approve -> publish.
34
+ 3) Ask assistant: must pass gate and cite snapshot.
35
+ 4) Simulate change: watcher -> review -> publish new snapshot.
36
+ 5) Learning hub: drills session, ambient tip, quest start + step completion.`
37
+ }
38
+ ];
39
+ registerDocBlocks(docBlocks);
40
+ // src/example.ts
41
+ import { defineExample } from "@contractspec/lib.contracts";
42
+ var example = defineExample({
43
+ meta: {
44
+ key: "policy-safe-knowledge-assistant",
45
+ version: "1.0.0",
46
+ title: "Policy-safe Knowledge Assistant",
47
+ description: "All-in-one template: locale/jurisdiction gating + versioned KB snapshots + HITL update pipeline + learning hub.",
48
+ kind: "template",
49
+ visibility: "public",
50
+ stability: "experimental",
51
+ owners: ["@platform.core"],
52
+ tags: ["assistant", "knowledge", "policy", "hitl", "learning"]
53
+ },
54
+ docs: {
55
+ goalDocId: "docs.examples.policy-safe-knowledge-assistant.goal",
56
+ usageDocId: "docs.examples.policy-safe-knowledge-assistant.usage"
57
+ },
58
+ entrypoints: {
59
+ packageName: "@contractspec/example.policy-safe-knowledge-assistant",
60
+ feature: "./policy-safe-knowledge-assistant.feature",
61
+ docs: "./docs"
62
+ },
63
+ surfaces: {
64
+ templates: true,
65
+ sandbox: {
66
+ enabled: true,
67
+ modes: ["playground", "specs", "builder", "markdown", "evolution"]
68
+ },
69
+ studio: { enabled: true, installable: true },
70
+ mcp: { enabled: true }
71
+ }
72
+ });
73
+ var example_default = example;
74
+
75
+ // src/orchestrator/buildAnswer.ts
76
+ import {
77
+ enforceAllowedScope,
78
+ enforceCitations,
79
+ validateEnvelope
80
+ } from "@contractspec/example.locale-jurisdiction-gate/policy/guard";
81
+ async function buildPolicySafeAnswer(input) {
82
+ const env = validateEnvelope(input.envelope);
83
+ if (!env.ok) {
84
+ return {
85
+ locale: input.envelope.locale ?? "en-GB",
86
+ jurisdiction: input.envelope.regulatoryContext?.jurisdiction ?? "UNKNOWN",
87
+ allowedScope: input.envelope.allowedScope ?? "education_only",
88
+ sections: [{ heading: "Request blocked", body: env.error.message }],
89
+ citations: [],
90
+ disclaimers: ["This system refuses to answer without a valid envelope."],
91
+ riskFlags: [env.error.code],
92
+ refused: true,
93
+ refusalReason: env.error.code
94
+ };
95
+ }
96
+ const results = await input.kbSearch({
97
+ snapshotId: env.value.kbSnapshotId,
98
+ jurisdiction: env.value.regulatoryContext?.jurisdiction ?? "UNKNOWN",
99
+ query: input.question
100
+ });
101
+ const citations = results.items.map((item) => ({
102
+ kbSnapshotId: env.value.kbSnapshotId,
103
+ sourceType: "ruleVersion",
104
+ sourceId: item.ruleVersionId,
105
+ title: "Curated rule version",
106
+ excerpt: item.excerpt
107
+ }));
108
+ const draft = {
109
+ locale: env.value.locale,
110
+ jurisdiction: env.value.regulatoryContext?.jurisdiction ?? "UNKNOWN",
111
+ allowedScope: env.value.allowedScope,
112
+ sections: [
113
+ {
114
+ heading: "Answer (KB-derived)",
115
+ body: results.items.length > 0 ? `This answer is derived from ${results.items.length} curated rule version(s) in the referenced snapshot.` : "No curated knowledge found in the referenced snapshot."
116
+ }
117
+ ],
118
+ citations,
119
+ disclaimers: ["Educational demo only."],
120
+ riskFlags: []
121
+ };
122
+ const scope = enforceAllowedScope(env.value.allowedScope, draft);
123
+ if (!scope.ok) {
124
+ return {
125
+ ...draft,
126
+ sections: [{ heading: "Escalation required", body: scope.error.message }],
127
+ refused: true,
128
+ refusalReason: scope.error.code,
129
+ riskFlags: [...draft.riskFlags ?? [], scope.error.code]
130
+ };
131
+ }
132
+ const cited = enforceCitations(draft);
133
+ if (!cited.ok) {
134
+ return {
135
+ ...draft,
136
+ sections: [{ heading: "Request blocked", body: cited.error.message }],
137
+ citations: [],
138
+ refused: true,
139
+ refusalReason: cited.error.code,
140
+ riskFlags: [...draft.riskFlags ?? [], cited.error.code]
141
+ };
142
+ }
143
+ return draft;
144
+ }
145
+
146
+ // src/handlers/policy-safe-knowledge-assistant.handlers.ts
147
+ import { web } from "@contractspec/lib.runtime-sandbox";
148
+ var { generateId } = web;
149
+ function parseJsonArray(value) {
150
+ if (!value)
151
+ return [];
152
+ try {
153
+ const parsed = JSON.parse(value);
154
+ return Array.isArray(parsed) ? parsed.filter((v) => typeof v === "string") : [];
155
+ } catch {
156
+ return [];
157
+ }
158
+ }
159
+ function nowIso() {
160
+ return new Date().toISOString();
161
+ }
162
+ function createPolicySafeKnowledgeAssistantHandlers(db) {
163
+ async function getUserContext(input) {
164
+ const result = await db.query(`SELECT * FROM psa_user_context WHERE "projectId" = $1 LIMIT 1`, [input.projectId]);
165
+ const row = result.rows[0];
166
+ if (!row) {
167
+ return {
168
+ projectId: input.projectId,
169
+ locale: "en-GB",
170
+ jurisdiction: "EU",
171
+ allowedScope: "education_only",
172
+ kbSnapshotId: null
173
+ };
174
+ }
175
+ return {
176
+ projectId: row.projectId,
177
+ locale: row.locale,
178
+ jurisdiction: row.jurisdiction,
179
+ allowedScope: row.allowedScope,
180
+ kbSnapshotId: row.kbSnapshotId
181
+ };
182
+ }
183
+ async function setUserContext(input) {
184
+ const existing = await db.query(`SELECT "projectId" FROM psa_user_context WHERE "projectId" = $1 LIMIT 1`, [input.projectId]);
185
+ if (existing.rows.length) {
186
+ await db.execute(`UPDATE psa_user_context SET locale = $1, jurisdiction = $2, "allowedScope" = $3 WHERE "projectId" = $4`, [input.locale, input.jurisdiction, input.allowedScope, input.projectId]);
187
+ } else {
188
+ await db.execute(`INSERT INTO psa_user_context ("projectId", locale, jurisdiction, "allowedScope", "kbSnapshotId") VALUES ($1, $2, $3, $4, $5)`, [
189
+ input.projectId,
190
+ input.locale,
191
+ input.jurisdiction,
192
+ input.allowedScope,
193
+ null
194
+ ]);
195
+ }
196
+ return await getUserContext({ projectId: input.projectId });
197
+ }
198
+ async function createRule(input) {
199
+ const id = generateId("psa_rule");
200
+ await db.execute(`INSERT INTO psa_rule (id, "projectId", jurisdiction, "topicKey") VALUES ($1, $2, $3, $4)`, [id, input.projectId, input.jurisdiction, input.topicKey]);
201
+ return { id, ...input };
202
+ }
203
+ async function upsertRuleVersion(input) {
204
+ if (!input.sourceRefs.length)
205
+ throw new Error("SOURCE_REFS_REQUIRED");
206
+ const rulesResult = await db.query(`SELECT * FROM psa_rule WHERE id = $1 LIMIT 1`, [input.ruleId]);
207
+ const rule = rulesResult.rows[0];
208
+ if (!rule)
209
+ throw new Error("RULE_NOT_FOUND");
210
+ const maxResult = await db.query(`SELECT MAX(version) as maxVersion FROM psa_rule_version WHERE "ruleId" = $1`, [input.ruleId]);
211
+ const maxVersion = Number(maxResult.rows[0]?.maxVersion ?? 0);
212
+ const version = maxVersion + 1;
213
+ const id = generateId("psa_rv");
214
+ const createdAt = nowIso();
215
+ await db.execute(`INSERT INTO psa_rule_version (id, "ruleId", jurisdiction, "topicKey", version, content, status, "sourceRefsJson", "approvedBy", "approvedAt", "createdAt")
216
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`, [
217
+ id,
218
+ input.ruleId,
219
+ rule.jurisdiction,
220
+ rule.topicKey,
221
+ version,
222
+ input.content,
223
+ "draft",
224
+ JSON.stringify(input.sourceRefs),
225
+ null,
226
+ null,
227
+ createdAt
228
+ ]);
229
+ return {
230
+ id,
231
+ ruleId: input.ruleId,
232
+ jurisdiction: rule.jurisdiction,
233
+ topicKey: rule.topicKey,
234
+ version,
235
+ content: input.content,
236
+ status: "draft",
237
+ sourceRefs: input.sourceRefs,
238
+ createdAt: new Date(createdAt)
239
+ };
240
+ }
241
+ async function approveRuleVersion(input) {
242
+ const approvedAt = nowIso();
243
+ await db.execute(`UPDATE psa_rule_version SET status = $1, "approvedBy" = $2, "approvedAt" = $3 WHERE id = $4`, ["approved", input.approver, approvedAt, input.ruleVersionId]);
244
+ return { ruleVersionId: input.ruleVersionId, status: "approved" };
245
+ }
246
+ async function publishSnapshot(input) {
247
+ const approvedResult = await db.query(`SELECT id FROM psa_rule_version WHERE jurisdiction = $1 AND status = 'approved' ORDER BY id ASC`, [input.jurisdiction]);
248
+ const includedIds = approvedResult.rows.map((r) => r.id).filter(Boolean);
249
+ if (!includedIds.length)
250
+ throw new Error("NO_APPROVED_RULES");
251
+ const id = generateId("psa_snap");
252
+ const publishedAt = nowIso();
253
+ await db.execute(`INSERT INTO psa_snapshot (id, jurisdiction, "asOfDate", "includedRuleVersionIdsJson", "publishedAt")
254
+ VALUES ($1, $2, $3, $4, $5)`, [
255
+ id,
256
+ input.jurisdiction,
257
+ input.asOfDate.toISOString(),
258
+ JSON.stringify(includedIds),
259
+ publishedAt
260
+ ]);
261
+ await db.execute(`UPDATE psa_user_context SET "kbSnapshotId" = $1 WHERE "projectId" = $2`, [id, input.projectId]);
262
+ return {
263
+ id,
264
+ jurisdiction: input.jurisdiction,
265
+ includedRuleVersionIds: includedIds
266
+ };
267
+ }
268
+ async function searchKb(input) {
269
+ const snapResult = await db.query(`SELECT * FROM psa_snapshot WHERE id = $1 LIMIT 1`, [input.snapshotId]);
270
+ const snap = snapResult.rows[0];
271
+ if (!snap)
272
+ throw new Error("SNAPSHOT_NOT_FOUND");
273
+ if (snap.jurisdiction !== input.jurisdiction)
274
+ throw new Error("JURISDICTION_MISMATCH");
275
+ const includedIds = parseJsonArray(snap.includedRuleVersionIdsJson);
276
+ const tokens = input.query.toLowerCase().split(/\s+/).map((t) => t.trim()).filter(Boolean);
277
+ const items = [];
278
+ for (const id of includedIds) {
279
+ const rvResult = await db.query(`SELECT * FROM psa_rule_version WHERE id = $1 LIMIT 1`, [id]);
280
+ const rv = rvResult.rows[0];
281
+ if (!rv)
282
+ continue;
283
+ const hay = rv.content.toLowerCase();
284
+ const match = tokens.length ? tokens.every((t) => hay.includes(t)) : true;
285
+ if (!match)
286
+ continue;
287
+ items.push({ ruleVersionId: rv.id, excerpt: rv.content.slice(0, 140) });
288
+ }
289
+ return { items };
290
+ }
291
+ async function answer(input) {
292
+ const ctx = await getUserContext({ projectId: input.projectId });
293
+ if (!ctx.kbSnapshotId) {
294
+ const refused = await buildPolicySafeAnswer({
295
+ envelope: {
296
+ traceId: generateId("trace"),
297
+ locale: ctx.locale,
298
+ kbSnapshotId: "",
299
+ allowedScope: ctx.allowedScope,
300
+ regulatoryContext: { jurisdiction: ctx.jurisdiction }
301
+ },
302
+ question: input.question,
303
+ kbSearch: async () => ({ items: [] })
304
+ });
305
+ return refused;
306
+ }
307
+ return await buildPolicySafeAnswer({
308
+ envelope: {
309
+ traceId: generateId("trace"),
310
+ locale: ctx.locale,
311
+ kbSnapshotId: ctx.kbSnapshotId,
312
+ allowedScope: ctx.allowedScope,
313
+ regulatoryContext: { jurisdiction: ctx.jurisdiction }
314
+ },
315
+ question: input.question,
316
+ kbSearch: async (q) => await searchKb(q)
317
+ });
318
+ }
319
+ async function createChangeCandidate(input) {
320
+ const id = generateId("psa_change");
321
+ await db.execute(`INSERT INTO psa_change_candidate (id, "projectId", jurisdiction, "detectedAt", "diffSummary", "riskLevel", "proposedRuleVersionIdsJson")
322
+ VALUES ($1, $2, $3, $4, $5, $6, $7)`, [
323
+ id,
324
+ input.projectId,
325
+ input.jurisdiction,
326
+ nowIso(),
327
+ input.diffSummary,
328
+ input.riskLevel,
329
+ JSON.stringify(input.proposedRuleVersionIds)
330
+ ]);
331
+ return { id };
332
+ }
333
+ async function createReviewTask(input) {
334
+ const candResult = await db.query(`SELECT * FROM psa_change_candidate WHERE id = $1 LIMIT 1`, [input.changeCandidateId]);
335
+ const candidate = candResult.rows[0];
336
+ if (!candidate)
337
+ throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
338
+ const assignedRole = candidate.riskLevel === "high" ? "expert" : "curator";
339
+ const id = generateId("psa_review");
340
+ await db.execute(`INSERT INTO psa_review_task (id, "changeCandidateId", status, "assignedRole", decision, "decidedAt", "decidedBy")
341
+ VALUES ($1, $2, $3, $4, $5, $6, $7)`, [id, input.changeCandidateId, "open", assignedRole, null, null, null]);
342
+ return { id, assignedRole };
343
+ }
344
+ async function submitDecision(input) {
345
+ const reviewResult = await db.query(`SELECT * FROM psa_review_task WHERE id = $1 LIMIT 1`, [input.reviewTaskId]);
346
+ const task = reviewResult.rows[0];
347
+ if (!task)
348
+ throw new Error("REVIEW_TASK_NOT_FOUND");
349
+ const candidateResult = await db.query(`SELECT * FROM psa_change_candidate WHERE id = $1 LIMIT 1`, [task.changeCandidateId]);
350
+ const candidate = candidateResult.rows[0];
351
+ if (!candidate)
352
+ throw new Error("CHANGE_CANDIDATE_NOT_FOUND");
353
+ if (candidate.riskLevel === "high" && input.decision === "approve" && input.decidedByRole !== "expert") {
354
+ throw new Error("FORBIDDEN_ROLE");
355
+ }
356
+ const decidedAt = nowIso();
357
+ await db.execute(`UPDATE psa_review_task SET status = $1, decision = $2, "decidedAt" = $3, "decidedBy" = $4 WHERE id = $5`, [
358
+ "decided",
359
+ input.decision,
360
+ decidedAt,
361
+ input.decidedBy,
362
+ input.reviewTaskId
363
+ ]);
364
+ return { id: input.reviewTaskId, status: "decided" };
365
+ }
366
+ async function publishIfReady(input) {
367
+ const openResult = await db.query(`SELECT COUNT(*) as count FROM psa_review_task WHERE status != 'decided'`, []);
368
+ const openCount = Number(openResult.rows[0]?.count ?? 0);
369
+ if (openCount > 0)
370
+ throw new Error("NOT_READY");
371
+ const decidedResult = await db.query(`SELECT * FROM psa_review_task`, []);
372
+ for (const row of decidedResult.rows) {
373
+ if (row.decision !== "approve")
374
+ continue;
375
+ const candQueryResult = await db.query(`SELECT * FROM psa_change_candidate WHERE id = $1 LIMIT 1`, [row.changeCandidateId]);
376
+ const cand = candQueryResult.rows[0];
377
+ if (!cand)
378
+ continue;
379
+ if (cand.jurisdiction !== input.jurisdiction)
380
+ continue;
381
+ const proposedIds = parseJsonArray(cand.proposedRuleVersionIdsJson);
382
+ for (const rvId of proposedIds) {
383
+ const rvQueryResult = await db.query(`SELECT status FROM psa_rule_version WHERE id = $1 LIMIT 1`, [rvId]);
384
+ const status = String(rvQueryResult.rows[0]?.status ?? "");
385
+ if (status !== "approved")
386
+ throw new Error("NOT_READY");
387
+ }
388
+ }
389
+ return { published: true };
390
+ }
391
+ return {
392
+ getUserContext,
393
+ setUserContext,
394
+ createRule,
395
+ upsertRuleVersion,
396
+ approveRuleVersion,
397
+ publishSnapshot,
398
+ searchKb,
399
+ answer,
400
+ createChangeCandidate,
401
+ createReviewTask,
402
+ submitDecision,
403
+ publishIfReady
404
+ };
405
+ }
406
+
407
+ // src/policy-safe-knowledge-assistant.feature.ts
408
+ import { defineFeature } from "@contractspec/lib.contracts";
409
+ var PolicySafeKnowledgeAssistantFeature = defineFeature({
410
+ meta: {
411
+ key: "policy-safe-knowledge-assistant",
412
+ version: "1.0.0",
413
+ title: "Policy-safe Knowledge Assistant",
414
+ description: "All-in-one example composing locale/jurisdiction gate + versioned KB + HITL pipeline + learning hub.",
415
+ domain: "knowledge",
416
+ owners: ["@examples"],
417
+ tags: ["assistant", "knowledge", "policy", "hitl", "learning"],
418
+ stability: "experimental"
419
+ },
420
+ operations: [
421
+ { key: "assistant.answer", version: "1.0.0" },
422
+ { key: "assistant.explainConcept", version: "1.0.0" },
423
+ { key: "kb.ingestSource", version: "1.0.0" },
424
+ { key: "kb.upsertRuleVersion", version: "1.0.0" },
425
+ { key: "kb.approveRuleVersion", version: "1.0.0" },
426
+ { key: "kb.publishSnapshot", version: "1.0.0" },
427
+ { key: "kb.search", version: "1.0.0" },
428
+ { key: "kbPipeline.runWatch", version: "1.0.0" },
429
+ { key: "kbPipeline.createReviewTask", version: "1.0.0" },
430
+ { key: "kbPipeline.submitDecision", version: "1.0.0" },
431
+ { key: "kbPipeline.publishIfReady", version: "1.0.0" }
432
+ ],
433
+ events: [
434
+ { key: "assistant.answer.requested", version: "1.0.0" },
435
+ { key: "assistant.answer.blocked", version: "1.0.0" },
436
+ { key: "assistant.answer.delivered", version: "1.0.0" },
437
+ { key: "kb.source.ingested", version: "1.0.0" },
438
+ { key: "kb.ruleVersion.created", version: "1.0.0" },
439
+ { key: "kb.ruleVersion.approved", version: "1.0.0" },
440
+ { key: "kb.snapshot.published", version: "1.0.0" },
441
+ { key: "kb.change.detected", version: "1.0.0" },
442
+ { key: "kb.review.requested", version: "1.0.0" },
443
+ { key: "kb.review.decided", version: "1.0.0" }
444
+ ],
445
+ presentations: [],
446
+ opToPresentation: [],
447
+ presentationsTargets: [],
448
+ capabilities: {
449
+ requires: [
450
+ { key: "identity", version: "1.0.0" },
451
+ { key: "audit-trail", version: "1.0.0" },
452
+ { key: "notifications", version: "1.0.0" },
453
+ { key: "jobs", version: "1.0.0" },
454
+ { key: "feature-flags", version: "1.0.0" },
455
+ { key: "files", version: "1.0.0" },
456
+ { key: "metering", version: "1.0.0" },
457
+ { key: "learning-journey", version: "1.0.0" }
458
+ ]
459
+ }
460
+ });
461
+
462
+ // src/seed/fixtures.ts
463
+ var DEMO_FIXTURES = {
464
+ jurisdictions: ["EU", "FR"],
465
+ locales: ["en-GB", "fr-FR"],
466
+ demoOrgId: "org_demo",
467
+ demoUserId: "user_demo",
468
+ sources: {
469
+ EU_SOURCE_1: {
470
+ jurisdiction: "EU",
471
+ authority: "DemoAuthority",
472
+ title: "EU Demo Source v1",
473
+ fetchedAt: new Date("2026-01-01T00:00:00.000Z"),
474
+ hash: "hash_eu_v1",
475
+ fileId: "file_eu_v1"
476
+ },
477
+ EU_SOURCE_2: {
478
+ jurisdiction: "EU",
479
+ authority: "DemoAuthority",
480
+ title: "EU Demo Source v2",
481
+ fetchedAt: new Date("2026-02-01T00:00:00.000Z"),
482
+ hash: "hash_eu_v2",
483
+ fileId: "file_eu_v2"
484
+ }
485
+ },
486
+ rules: {
487
+ EU_RULE_TAX: {
488
+ id: "rule_eu_tax",
489
+ jurisdiction: "EU",
490
+ topicKey: "tax_reporting"
491
+ }
492
+ }
493
+ };
494
+ // src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
495
+ import { useCallback, useEffect, useMemo, useState } from "react";
496
+ import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
497
+ "use client";
498
+ function isCitationLike(value) {
499
+ if (!value || typeof value !== "object")
500
+ return false;
501
+ const v = value;
502
+ return typeof v.kbSnapshotId === "string" && typeof v.sourceId === "string";
503
+ }
504
+ function toCitations(value) {
505
+ if (!Array.isArray(value))
506
+ return [];
507
+ return value.filter(isCitationLike).map((c) => ({
508
+ kbSnapshotId: c.kbSnapshotId,
509
+ sourceId: c.sourceId,
510
+ excerpt: c.excerpt
511
+ }));
512
+ }
513
+ function usePolicySafeKnowledgeAssistant() {
514
+ const { handlers, projectId } = useTemplateRuntime();
515
+ const api = handlers.policySafeKnowledgeAssistant;
516
+ const [state, setState] = useState({
517
+ context: null,
518
+ loading: true,
519
+ error: null,
520
+ lastAnswer: null,
521
+ lastRuleId: null,
522
+ lastRuleVersionId: null,
523
+ lastSnapshotId: null,
524
+ lastReviewTaskId: null
525
+ });
526
+ const refreshContext = useCallback(async () => {
527
+ try {
528
+ setState((s) => ({ ...s, loading: true, error: null }));
529
+ const ctx = await api.getUserContext({ projectId });
530
+ setState((s) => ({
531
+ ...s,
532
+ context: {
533
+ locale: ctx.locale,
534
+ jurisdiction: ctx.jurisdiction,
535
+ allowedScope: ctx.allowedScope,
536
+ kbSnapshotId: ctx.kbSnapshotId
537
+ },
538
+ loading: false
539
+ }));
540
+ } catch (e) {
541
+ setState((s) => ({
542
+ ...s,
543
+ loading: false,
544
+ error: e instanceof Error ? e : new Error("Unknown error")
545
+ }));
546
+ }
547
+ }, [api, projectId]);
548
+ useEffect(() => {
549
+ refreshContext();
550
+ }, [refreshContext]);
551
+ const setContext = useCallback(async (input) => {
552
+ const ctx = await api.setUserContext({ projectId, ...input });
553
+ setState((s) => ({
554
+ ...s,
555
+ context: {
556
+ locale: ctx.locale,
557
+ jurisdiction: ctx.jurisdiction,
558
+ allowedScope: ctx.allowedScope,
559
+ kbSnapshotId: ctx.kbSnapshotId
560
+ }
561
+ }));
562
+ }, [api, projectId]);
563
+ const askAssistant = useCallback(async (question) => {
564
+ const answerUnknown = await api.answer({ projectId, question });
565
+ const answer = answerUnknown;
566
+ setState((s) => ({
567
+ ...s,
568
+ lastAnswer: {
569
+ refused: answer.refused,
570
+ refusalReason: answer.refusalReason,
571
+ sections: answer.sections,
572
+ citations: toCitations(answerUnknown.citations)
573
+ }
574
+ }));
575
+ }, [api, projectId]);
576
+ const createDemoRule = useCallback(async () => {
577
+ const rule = await api.createRule({
578
+ projectId,
579
+ jurisdiction: state.context?.jurisdiction ?? "EU",
580
+ topicKey: "tax_reporting"
581
+ });
582
+ setState((s) => ({ ...s, lastRuleId: rule.id }));
583
+ return rule.id;
584
+ }, [api, projectId, state.context?.jurisdiction]);
585
+ const upsertRuleVersion = useCallback(async (input) => {
586
+ const rv = await api.upsertRuleVersion({
587
+ projectId,
588
+ ruleId: input.ruleId,
589
+ content: input.content,
590
+ sourceRefs: [{ sourceDocumentId: "src_demo", excerpt: "demo excerpt" }]
591
+ });
592
+ setState((s) => ({ ...s, lastRuleVersionId: rv.id }));
593
+ return rv.id;
594
+ }, [api, projectId]);
595
+ const approveRuleVersion = useCallback(async (ruleVersionId) => {
596
+ await api.approveRuleVersion({ ruleVersionId, approver: "demo_expert" });
597
+ }, [api]);
598
+ const publishSnapshot = useCallback(async () => {
599
+ const snap = await api.publishSnapshot({
600
+ projectId,
601
+ jurisdiction: state.context?.jurisdiction ?? "EU",
602
+ asOfDate: new Date("2026-02-01T00:00:00.000Z")
603
+ });
604
+ setState((s) => ({ ...s, lastSnapshotId: snap.id }));
605
+ await refreshContext();
606
+ return snap.id;
607
+ }, [api, projectId, refreshContext, state.context?.jurisdiction]);
608
+ const simulateHighRiskChangeAndApprove = useCallback(async (ruleVersionId) => {
609
+ const cand = await api.createChangeCandidate({
610
+ projectId,
611
+ jurisdiction: state.context?.jurisdiction ?? "EU",
612
+ diffSummary: "Simulated change (demo)",
613
+ riskLevel: "high",
614
+ proposedRuleVersionIds: [ruleVersionId]
615
+ });
616
+ const review = await api.createReviewTask({ changeCandidateId: cand.id });
617
+ setState((s) => ({ ...s, lastReviewTaskId: review.id }));
618
+ await api.submitDecision({
619
+ reviewTaskId: review.id,
620
+ decision: "approve",
621
+ decidedByRole: "expert",
622
+ decidedBy: "demo_expert"
623
+ });
624
+ await api.publishIfReady({
625
+ jurisdiction: state.context?.jurisdiction ?? "EU"
626
+ });
627
+ return review.id;
628
+ }, [api, projectId, state.context?.jurisdiction]);
629
+ const derived = useMemo(() => ({ projectId }), [projectId]);
630
+ return {
631
+ state,
632
+ derived,
633
+ actions: {
634
+ refreshContext,
635
+ setContext,
636
+ askAssistant,
637
+ createDemoRule,
638
+ upsertRuleVersion,
639
+ approveRuleVersion,
640
+ publishSnapshot,
641
+ simulateHighRiskChangeAndApprove
642
+ }
643
+ };
644
+ }
645
+
646
+ // src/ui/PolicySafeKnowledgeAssistantDashboard.tsx
647
+ import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
648
+ import {
649
+ Button,
650
+ ErrorState,
651
+ LoaderBlock,
652
+ StatCard,
653
+ StatCardGroup
654
+ } from "@contractspec/lib.design-system";
655
+ import { Card } from "@contractspec/lib.ui-kit-web/ui/card";
656
+ import { Input } from "@contractspec/lib.ui-kit-web/ui/input";
657
+ import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
658
+ import {
659
+ Select,
660
+ SelectContent,
661
+ SelectItem,
662
+ SelectTrigger,
663
+ SelectValue
664
+ } from "@contractspec/lib.ui-kit-web/ui/select";
665
+ import { jsxDEV } from "react/jsx-dev-runtime";
666
+ "use client";
667
+ function PolicySafeKnowledgeAssistantDashboard() {
668
+ const { state, actions } = usePolicySafeKnowledgeAssistant();
669
+ const [question, setQuestion] = useState2("reporting obligations");
670
+ const [content, setContent] = useState2("EU: Reporting obligations v2 (updated)");
671
+ const [locale, setLocale] = useState2("en-GB");
672
+ const [jurisdiction, setJurisdiction] = useState2("EU");
673
+ const [allowedScope, setAllowedScope] = useState2("education_only");
674
+ const snapshotId = state.context?.kbSnapshotId ?? state.lastSnapshotId ?? null;
675
+ const stats = useMemo2(() => {
676
+ return [
677
+ { label: "Locale", value: state.context?.locale ?? "\u2014" },
678
+ { label: "Jurisdiction", value: state.context?.jurisdiction ?? "\u2014" },
679
+ { label: "Scope", value: state.context?.allowedScope ?? "\u2014" },
680
+ { label: "KB Snapshot", value: snapshotId ?? "\u2014" }
681
+ ];
682
+ }, [
683
+ snapshotId,
684
+ state.context?.allowedScope,
685
+ state.context?.jurisdiction,
686
+ state.context?.locale
687
+ ]);
688
+ const handleSetContext = useCallback2(async () => {
689
+ await actions.setContext({ locale, jurisdiction, allowedScope });
690
+ }, [actions, allowedScope, jurisdiction, locale]);
691
+ const handleAsk = useCallback2(async () => {
692
+ await actions.askAssistant(question);
693
+ }, [actions, question]);
694
+ const handleAdminPublishFlow = useCallback2(async () => {
695
+ const ruleId = state.lastRuleId ?? await actions.createDemoRule();
696
+ const rvId = await actions.upsertRuleVersion({ ruleId, content });
697
+ await actions.approveRuleVersion(rvId);
698
+ await actions.simulateHighRiskChangeAndApprove(rvId);
699
+ await actions.publishSnapshot();
700
+ }, [actions, content, state.lastRuleId]);
701
+ if (state.loading && !state.context) {
702
+ return /* @__PURE__ */ jsxDEV(LoaderBlock, {
703
+ label: "Loading demo..."
704
+ }, undefined, false, undefined, this);
705
+ }
706
+ if (state.error) {
707
+ return /* @__PURE__ */ jsxDEV(ErrorState, {
708
+ title: "Failed to load demo",
709
+ description: state.error.message,
710
+ onRetry: actions.refreshContext,
711
+ retryLabel: "Retry"
712
+ }, undefined, false, undefined, this);
713
+ }
714
+ return /* @__PURE__ */ jsxDEV("div", {
715
+ className: "space-y-6",
716
+ children: [
717
+ /* @__PURE__ */ jsxDEV(StatCardGroup, {
718
+ children: stats.map((s) => /* @__PURE__ */ jsxDEV(StatCard, {
719
+ label: s.label,
720
+ value: String(s.value)
721
+ }, s.label, false, undefined, this))
722
+ }, undefined, false, undefined, this),
723
+ /* @__PURE__ */ jsxDEV(Card, {
724
+ className: "p-4",
725
+ children: [
726
+ /* @__PURE__ */ jsxDEV("h3", {
727
+ className: "text-lg font-semibold",
728
+ children: "1) Onboarding (explicit locale + jurisdiction)"
729
+ }, undefined, false, undefined, this),
730
+ /* @__PURE__ */ jsxDEV("div", {
731
+ className: "mt-3 grid gap-3 md:grid-cols-3",
732
+ children: [
733
+ /* @__PURE__ */ jsxDEV("div", {
734
+ children: [
735
+ /* @__PURE__ */ jsxDEV("div", {
736
+ className: "text-muted-foreground mb-1 text-xs font-semibold tracking-wide uppercase",
737
+ children: "Locale"
738
+ }, undefined, false, undefined, this),
739
+ /* @__PURE__ */ jsxDEV(Input, {
740
+ value: locale,
741
+ onChange: (e) => setLocale(e.target.value)
742
+ }, undefined, false, undefined, this)
743
+ ]
744
+ }, undefined, true, undefined, this),
745
+ /* @__PURE__ */ jsxDEV("div", {
746
+ children: [
747
+ /* @__PURE__ */ jsxDEV("div", {
748
+ className: "text-muted-foreground mb-1 text-xs font-semibold tracking-wide uppercase",
749
+ children: "Jurisdiction"
750
+ }, undefined, false, undefined, this),
751
+ /* @__PURE__ */ jsxDEV(Input, {
752
+ value: jurisdiction,
753
+ onChange: (e) => setJurisdiction(e.target.value)
754
+ }, undefined, false, undefined, this)
755
+ ]
756
+ }, undefined, true, undefined, this),
757
+ /* @__PURE__ */ jsxDEV("div", {
758
+ children: [
759
+ /* @__PURE__ */ jsxDEV("div", {
760
+ className: "text-muted-foreground mb-1 text-xs font-semibold tracking-wide uppercase",
761
+ children: "Allowed scope"
762
+ }, undefined, false, undefined, this),
763
+ /* @__PURE__ */ jsxDEV(Select, {
764
+ value: allowedScope,
765
+ onValueChange: (v) => setAllowedScope(v),
766
+ children: [
767
+ /* @__PURE__ */ jsxDEV(SelectTrigger, {
768
+ children: /* @__PURE__ */ jsxDEV(SelectValue, {
769
+ placeholder: "Select scope"
770
+ }, undefined, false, undefined, this)
771
+ }, undefined, false, undefined, this),
772
+ /* @__PURE__ */ jsxDEV(SelectContent, {
773
+ children: [
774
+ /* @__PURE__ */ jsxDEV(SelectItem, {
775
+ value: "education_only",
776
+ children: "education_only"
777
+ }, undefined, false, undefined, this),
778
+ /* @__PURE__ */ jsxDEV(SelectItem, {
779
+ value: "generic_info",
780
+ children: "generic_info"
781
+ }, undefined, false, undefined, this),
782
+ /* @__PURE__ */ jsxDEV(SelectItem, {
783
+ value: "escalation_required",
784
+ children: "escalation_required"
785
+ }, undefined, false, undefined, this)
786
+ ]
787
+ }, undefined, true, undefined, this)
788
+ ]
789
+ }, undefined, true, undefined, this)
790
+ ]
791
+ }, undefined, true, undefined, this)
792
+ ]
793
+ }, undefined, true, undefined, this),
794
+ /* @__PURE__ */ jsxDEV("div", {
795
+ className: "mt-4 flex gap-2",
796
+ children: [
797
+ /* @__PURE__ */ jsxDEV(Button, {
798
+ onPress: handleSetContext,
799
+ children: "Save context"
800
+ }, undefined, false, undefined, this),
801
+ /* @__PURE__ */ jsxDEV(Button, {
802
+ variant: "outline",
803
+ onPress: actions.refreshContext,
804
+ children: "Refresh"
805
+ }, undefined, false, undefined, this)
806
+ ]
807
+ }, undefined, true, undefined, this)
808
+ ]
809
+ }, undefined, true, undefined, this),
810
+ /* @__PURE__ */ jsxDEV(Card, {
811
+ className: "p-4",
812
+ children: [
813
+ /* @__PURE__ */ jsxDEV("h3", {
814
+ className: "text-lg font-semibold",
815
+ children: "2) Ask the assistant (must cite KB snapshot)"
816
+ }, undefined, false, undefined, this),
817
+ /* @__PURE__ */ jsxDEV("div", {
818
+ className: "mt-3 flex flex-col gap-3",
819
+ children: [
820
+ /* @__PURE__ */ jsxDEV(Input, {
821
+ value: question,
822
+ onChange: (e) => setQuestion(e.target.value)
823
+ }, undefined, false, undefined, this),
824
+ /* @__PURE__ */ jsxDEV("div", {
825
+ className: "flex gap-2",
826
+ children: /* @__PURE__ */ jsxDEV(Button, {
827
+ onPress: handleAsk,
828
+ children: "Ask"
829
+ }, undefined, false, undefined, this)
830
+ }, undefined, false, undefined, this)
831
+ ]
832
+ }, undefined, true, undefined, this),
833
+ state.lastAnswer ? /* @__PURE__ */ jsxDEV("div", {
834
+ className: "mt-4 space-y-3",
835
+ children: [
836
+ state.lastAnswer.refused ? /* @__PURE__ */ jsxDEV("div", {
837
+ className: "text-sm text-red-600",
838
+ children: [
839
+ "Refused: ",
840
+ state.lastAnswer.refusalReason ?? "UNKNOWN"
841
+ ]
842
+ }, undefined, true, undefined, this) : null,
843
+ state.lastAnswer.sections.map((s, idx) => /* @__PURE__ */ jsxDEV("div", {
844
+ children: [
845
+ /* @__PURE__ */ jsxDEV("div", {
846
+ className: "text-sm font-semibold",
847
+ children: s.heading
848
+ }, undefined, false, undefined, this),
849
+ /* @__PURE__ */ jsxDEV("div", {
850
+ className: "text-muted-foreground text-sm",
851
+ children: s.body
852
+ }, undefined, false, undefined, this)
853
+ ]
854
+ }, `${s.heading}-${idx}`, true, undefined, this)),
855
+ /* @__PURE__ */ jsxDEV("div", {
856
+ className: "text-sm font-semibold",
857
+ children: "Citations"
858
+ }, undefined, false, undefined, this),
859
+ /* @__PURE__ */ jsxDEV("ul", {
860
+ className: "text-muted-foreground list-disc pl-5 text-sm",
861
+ children: state.lastAnswer.citations.map((c) => /* @__PURE__ */ jsxDEV("li", {
862
+ children: [
863
+ c.kbSnapshotId,
864
+ " \u2014 ",
865
+ c.sourceId
866
+ ]
867
+ }, `${c.kbSnapshotId}-${c.sourceId}`, true, undefined, this))
868
+ }, undefined, false, undefined, this)
869
+ ]
870
+ }, undefined, true, undefined, this) : null
871
+ ]
872
+ }, undefined, true, undefined, this),
873
+ /* @__PURE__ */ jsxDEV(Card, {
874
+ className: "p-4",
875
+ children: [
876
+ /* @__PURE__ */ jsxDEV("h3", {
877
+ className: "text-lg font-semibold",
878
+ children: "3) Admin: publish a new snapshot (HITL)"
879
+ }, undefined, false, undefined, this),
880
+ /* @__PURE__ */ jsxDEV("div", {
881
+ className: "mt-3 space-y-3",
882
+ children: [
883
+ /* @__PURE__ */ jsxDEV(Textarea, {
884
+ value: content,
885
+ onChange: (e) => setContent(e.target.value)
886
+ }, undefined, false, undefined, this),
887
+ /* @__PURE__ */ jsxDEV(Button, {
888
+ onPress: handleAdminPublishFlow,
889
+ children: "Simulate change \u2192 review \u2192 approve \u2192 publish snapshot"
890
+ }, undefined, false, undefined, this)
891
+ ]
892
+ }, undefined, true, undefined, this)
893
+ ]
894
+ }, undefined, true, undefined, this),
895
+ /* @__PURE__ */ jsxDEV(Card, {
896
+ className: "p-4",
897
+ children: [
898
+ /* @__PURE__ */ jsxDEV("h3", {
899
+ className: "text-lg font-semibold",
900
+ children: "4) Learning hub (patterns)"
901
+ }, undefined, false, undefined, this),
902
+ /* @__PURE__ */ jsxDEV("p", {
903
+ className: "text-muted-foreground mt-2 text-sm",
904
+ children: "This template includes drills, ambient coach, and quests as reusable Learning Journey tracks. The interactive learning UI is demonstrated in dedicated Learning Journey examples."
905
+ }, undefined, false, undefined, this)
906
+ ]
907
+ }, undefined, true, undefined, this)
908
+ ]
909
+ }, undefined, true, undefined, this);
910
+ }
911
+ export {
912
+ example_default as example,
913
+ createPolicySafeKnowledgeAssistantHandlers,
914
+ buildPolicySafeAnswer,
915
+ PolicySafeKnowledgeAssistantFeature,
916
+ PolicySafeKnowledgeAssistantDashboard,
917
+ DEMO_FIXTURES
918
+ };