@lssm/lib.contracts 0.0.0-canary-20251217062943 → 0.0.0-canary-20251217072406

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 (237) hide show
  1. package/dist/app-config/app-config.feature.js +53 -1
  2. package/dist/app-config/contracts.d.ts +50 -50
  3. package/dist/app-config/contracts.js +396 -1
  4. package/dist/app-config/docs/app-config.docblock.js +22 -220
  5. package/dist/app-config/events.js +168 -1
  6. package/dist/app-config/index.js +8 -1
  7. package/dist/app-config/lifecycle-contracts.js +441 -1
  8. package/dist/app-config/runtime.js +617 -1
  9. package/dist/app-config/spec.js +36 -1
  10. package/dist/app-config/validation.js +538 -1
  11. package/dist/capabilities/docs/capabilities.docblock.js +22 -1
  12. package/dist/capabilities/openbanking.js +92 -1
  13. package/dist/capabilities.js +50 -1
  14. package/dist/client/index.js +9 -1
  15. package/dist/client/react/drivers/rn-reusables.js +21 -1
  16. package/dist/client/react/drivers/shadcn.js +11 -1
  17. package/dist/client/react/feature-render.js +43 -1
  18. package/dist/client/react/form-render.js +298 -1
  19. package/dist/client/react/index.js +8 -1
  20. package/dist/contract-registry/index.js +3 -1
  21. package/dist/contract-registry/schemas.js +61 -1
  22. package/dist/contracts-adapter-hydration.js +41 -1
  23. package/dist/contracts-adapter-input.js +77 -1
  24. package/dist/data-views/docs/data-views.docblock.js +22 -1
  25. package/dist/data-views/query-generator.js +48 -1
  26. package/dist/data-views/runtime.js +39 -1
  27. package/dist/data-views.js +35 -1
  28. package/dist/docs/PUBLISHING.docblock.js +17 -76
  29. package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
  30. package/dist/docs/index.js +33 -1
  31. package/dist/docs/meta.docs.js +15 -2
  32. package/dist/docs/presentations.js +77 -1
  33. package/dist/docs/registry.js +51 -1
  34. package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
  35. package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
  36. package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
  37. package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
  38. package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
  39. package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
  40. package/dist/docs/tech/contracts/README.docblock.js +21 -1
  41. package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
  42. package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
  43. package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
  44. package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
  45. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
  46. package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
  47. package/dist/docs/tech/contracts/tests.docblock.js +21 -132
  48. package/dist/docs/tech/contracts/themes.docblock.js +21 -1
  49. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
  50. package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
  51. package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
  52. package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
  53. package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
  54. package/dist/docs/tech/schema/README.docblock.js +21 -262
  55. package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
  56. package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
  57. package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
  58. package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
  59. package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
  60. package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
  61. package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
  62. package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
  63. package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
  64. package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
  65. package/dist/docs/tech/templates/runtime.docblock.js +21 -1
  66. package/dist/docs/tech/vscode-extension.docblock.js +37 -3
  67. package/dist/docs/tech/workflows/overview.docblock.js +21 -1
  68. package/dist/docs/tech-contracts.docs.js +19 -2
  69. package/dist/events.js +12 -1
  70. package/dist/experiments/docs/experiments.docblock.js +22 -128
  71. package/dist/experiments/evaluator.js +101 -1
  72. package/dist/experiments/spec.js +33 -1
  73. package/dist/features.js +68 -1
  74. package/dist/forms/docs/forms.docblock.js +22 -1
  75. package/dist/forms.js +119 -1
  76. package/dist/index.js +107 -1
  77. package/dist/install.js +40 -1
  78. package/dist/integrations/contracts.d.ts +102 -102
  79. package/dist/integrations/contracts.js +388 -1
  80. package/dist/integrations/docs/integrations.docblock.js +95 -1
  81. package/dist/integrations/health.js +69 -1
  82. package/dist/integrations/index.js +23 -1
  83. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  84. package/dist/integrations/openbanking/contracts/accounts.js +237 -1
  85. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  86. package/dist/integrations/openbanking/contracts/balances.js +167 -1
  87. package/dist/integrations/openbanking/contracts/index.js +12 -1
  88. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  89. package/dist/integrations/openbanking/contracts/transactions.js +218 -1
  90. package/dist/integrations/openbanking/guards.js +32 -1
  91. package/dist/integrations/openbanking/models.d.ts +55 -55
  92. package/dist/integrations/openbanking/models.js +242 -1
  93. package/dist/integrations/openbanking/openbanking.feature.js +68 -1
  94. package/dist/integrations/openbanking/telemetry.js +39 -1
  95. package/dist/integrations/providers/elevenlabs.js +56 -1
  96. package/dist/integrations/providers/gcs-storage.js +79 -1
  97. package/dist/integrations/providers/gmail.js +91 -1
  98. package/dist/integrations/providers/google-calendar.js +70 -1
  99. package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
  100. package/dist/integrations/providers/impls/gcs-storage.js +88 -1
  101. package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
  102. package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
  103. package/dist/integrations/providers/impls/google-calendar.js +154 -1
  104. package/dist/integrations/providers/impls/index.js +16 -1
  105. package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
  106. package/dist/integrations/providers/impls/mistral-llm.js +247 -1
  107. package/dist/integrations/providers/impls/postmark-email.js +55 -1
  108. package/dist/integrations/providers/impls/powens-client.js +171 -1
  109. package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
  110. package/dist/integrations/providers/impls/provider-factory.js +142 -1
  111. package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
  112. package/dist/integrations/providers/impls/stripe-payments.js +202 -1
  113. package/dist/integrations/providers/impls/twilio-sms.js +58 -1
  114. package/dist/integrations/providers/index.js +13 -1
  115. package/dist/integrations/providers/mistral.js +72 -1
  116. package/dist/integrations/providers/postmark.js +72 -1
  117. package/dist/integrations/providers/powens.js +120 -1
  118. package/dist/integrations/providers/qdrant.js +77 -1
  119. package/dist/integrations/providers/registry.js +34 -1
  120. package/dist/integrations/providers/stripe.js +87 -1
  121. package/dist/integrations/providers/twilio-sms.js +65 -1
  122. package/dist/integrations/runtime.js +186 -1
  123. package/dist/integrations/secrets/aws-secret-manager.js +231 -1
  124. package/dist/integrations/secrets/env-secret-provider.js +81 -1
  125. package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
  126. package/dist/integrations/secrets/index.js +8 -1
  127. package/dist/integrations/secrets/manager.js +103 -1
  128. package/dist/integrations/secrets/provider.js +58 -1
  129. package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
  130. package/dist/integrations/spec.js +39 -1
  131. package/dist/jobs/define-job.js +16 -1
  132. package/dist/jobs/gcp-cloud-tasks.js +53 -1
  133. package/dist/jobs/gcp-pubsub.js +39 -1
  134. package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
  135. package/dist/jobs/handlers/index.js +12 -1
  136. package/dist/jobs/handlers/ping-handler.js +15 -1
  137. package/dist/jobs/handlers/storage-document-handler.js +14 -1
  138. package/dist/jobs/index.js +4 -1
  139. package/dist/jobs/memory-queue.js +71 -1
  140. package/dist/jobs/queue.js +33 -1
  141. package/dist/jobs/scaleway-sqs-queue.js +153 -1
  142. package/dist/jsonschema.d.ts +3 -3
  143. package/dist/jsonschema.js +32 -1
  144. package/dist/knowledge/contracts.d.ts +66 -66
  145. package/dist/knowledge/contracts.js +317 -1
  146. package/dist/knowledge/docs/knowledge.docblock.js +22 -138
  147. package/dist/knowledge/index.js +10 -1
  148. package/dist/knowledge/ingestion/document-processor.js +54 -1
  149. package/dist/knowledge/ingestion/embedding-service.js +25 -1
  150. package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
  151. package/dist/knowledge/ingestion/index.js +7 -1
  152. package/dist/knowledge/ingestion/storage-adapter.js +26 -1
  153. package/dist/knowledge/ingestion/vector-indexer.js +32 -1
  154. package/dist/knowledge/query/index.js +3 -1
  155. package/dist/knowledge/query/service.js +64 -2
  156. package/dist/knowledge/runtime.js +49 -1
  157. package/dist/knowledge/spaces/email-threads.js +38 -1
  158. package/dist/knowledge/spaces/financial-docs.js +38 -1
  159. package/dist/knowledge/spaces/financial-overview.js +42 -1
  160. package/dist/knowledge/spaces/index.js +8 -1
  161. package/dist/knowledge/spaces/product-canon.js +38 -1
  162. package/dist/knowledge/spaces/support-faq.js +41 -1
  163. package/dist/knowledge/spaces/uploaded-docs.js +38 -1
  164. package/dist/knowledge/spec.js +39 -1
  165. package/dist/llm/exporters.js +541 -8
  166. package/dist/llm/index.js +4 -1
  167. package/dist/llm/prompts.js +246 -56
  168. package/dist/markdown.js +116 -3
  169. package/dist/migrations.js +33 -1
  170. package/dist/onboarding-base.d.ts +29 -29
  171. package/dist/onboarding-base.js +196 -1
  172. package/dist/openapi.js +75 -1
  173. package/dist/openbanking/docs/openbanking.docblock.js +22 -109
  174. package/dist/ownership.js +40 -1
  175. package/dist/policy/docs/policy.docblock.js +22 -1
  176. package/dist/policy/engine.js +223 -1
  177. package/dist/policy/opa-adapter.js +71 -1
  178. package/dist/policy/spec.js +33 -1
  179. package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
  180. package/dist/presentations.backcompat.js +47 -1
  181. package/dist/presentations.d.ts +3 -3
  182. package/dist/presentations.js +66 -1
  183. package/dist/presentations.v2.js +278 -6
  184. package/dist/prompt.js +10 -1
  185. package/dist/promptRegistry.js +34 -1
  186. package/dist/regenerator/docs/regenerator.docblock.js +22 -184
  187. package/dist/regenerator/executor.js +86 -1
  188. package/dist/regenerator/index.js +6 -1
  189. package/dist/regenerator/service.js +92 -1
  190. package/dist/regenerator/sinks.js +32 -1
  191. package/dist/regenerator/utils.js +51 -1
  192. package/dist/registry.js +208 -1
  193. package/dist/resources.js +47 -1
  194. package/dist/schema/dist/EnumType.js +2 -1
  195. package/dist/schema/dist/FieldType.js +49 -1
  196. package/dist/schema/dist/ScalarTypeEnum.js +236 -1
  197. package/dist/schema/dist/SchemaModel.js +39 -1
  198. package/dist/schema/dist/entity/defineEntity.js +1 -1
  199. package/dist/schema/dist/entity/index.js +2 -1
  200. package/dist/schema/dist/entity/types.js +1 -1
  201. package/dist/schema/dist/index.js +6 -1
  202. package/dist/schema-to-markdown.js +214 -10
  203. package/dist/server/graphql-pothos.js +128 -1
  204. package/dist/server/index.js +10 -1
  205. package/dist/server/mcp/createMcpServer.js +28 -1
  206. package/dist/server/mcp/registerPresentations.js +151 -1
  207. package/dist/server/mcp/registerPrompts.js +36 -2
  208. package/dist/server/mcp/registerResources.js +35 -1
  209. package/dist/server/mcp/registerTools.js +22 -1
  210. package/dist/server/provider-mcp.js +3 -1
  211. package/dist/server/rest-elysia.js +20 -1
  212. package/dist/server/rest-express.js +39 -1
  213. package/dist/server/rest-generic.js +125 -1
  214. package/dist/server/rest-next-app.js +38 -1
  215. package/dist/server/rest-next-mcp.js +45 -1
  216. package/dist/server/rest-next-pages.js +25 -1
  217. package/dist/spec.js +35 -1
  218. package/dist/telemetry/anomaly.js +48 -1
  219. package/dist/telemetry/docs/telemetry.docblock.js +22 -139
  220. package/dist/telemetry/index.js +5 -1
  221. package/dist/telemetry/spec.js +69 -1
  222. package/dist/telemetry/tracker.js +76 -1
  223. package/dist/tests/index.js +4 -1
  224. package/dist/tests/runner.js +150 -1
  225. package/dist/tests/spec.js +33 -1
  226. package/dist/themes.js +39 -1
  227. package/dist/workflow/adapters/db-adapter.js +83 -1
  228. package/dist/workflow/adapters/file-adapter.js +11 -1
  229. package/dist/workflow/adapters/index.js +5 -1
  230. package/dist/workflow/adapters/memory-store.js +58 -1
  231. package/dist/workflow/expression.js +98 -1
  232. package/dist/workflow/index.js +9 -1
  233. package/dist/workflow/runner.js +337 -1
  234. package/dist/workflow/sla-monitor.js +47 -1
  235. package/dist/workflow/spec.js +32 -1
  236. package/dist/workflow/validation.js +175 -1
  237. package/package.json +11 -4
@@ -1 +1,26 @@
1
- var e=class{constructor(e,t,n){this.processor=e,this.embeddings=t,this.indexer=n}async ingestObject(e){if(!(`data`in e)||!e.data)throw Error(`Storage ingestion requires object data`);let t={id:e.key,mimeType:e.contentType??`application/octet-stream`,data:e.data,metadata:{bucket:e.bucket,checksum:e.checksum??``}},n=await this.processor.process(t),r=await this.embeddings.embedFragments(n);await this.indexer.upsert(n,r)}};export{e as StorageIngestionAdapter};
1
+ //#region src/knowledge/ingestion/storage-adapter.ts
2
+ var StorageIngestionAdapter = class {
3
+ constructor(processor, embeddings, indexer) {
4
+ this.processor = processor;
5
+ this.embeddings = embeddings;
6
+ this.indexer = indexer;
7
+ }
8
+ async ingestObject(object) {
9
+ if (!("data" in object) || !object.data) throw new Error("Storage ingestion requires object data");
10
+ const raw = {
11
+ id: object.key,
12
+ mimeType: object.contentType ?? "application/octet-stream",
13
+ data: object.data,
14
+ metadata: {
15
+ bucket: object.bucket,
16
+ checksum: object.checksum ?? ""
17
+ }
18
+ };
19
+ const fragments = await this.processor.process(raw);
20
+ const embeddings = await this.embeddings.embedFragments(fragments);
21
+ await this.indexer.upsert(fragments, embeddings);
22
+ }
23
+ };
24
+
25
+ //#endregion
26
+ export { StorageIngestionAdapter };
@@ -1 +1,32 @@
1
- var e=class{provider;config;constructor(e,t){this.provider=e,this.config=t}async upsert(e,t){let n=t.map(t=>{let n=e.find(e=>e.id===t.id);return{id:t.id,vector:t.vector,payload:{...this.config.metadata,...n?.metadata??{},documentId:n?.documentId},namespace:this.config.namespace}}),r={collection:this.config.collection,documents:n};await this.provider.upsert(r)}};export{e as VectorIndexer};
1
+ //#region src/knowledge/ingestion/vector-indexer.ts
2
+ var VectorIndexer = class {
3
+ provider;
4
+ config;
5
+ constructor(provider, config) {
6
+ this.provider = provider;
7
+ this.config = config;
8
+ }
9
+ async upsert(fragments, embeddings) {
10
+ const documents = embeddings.map((embedding) => {
11
+ const fragment = fragments.find((f) => f.id === embedding.id);
12
+ return {
13
+ id: embedding.id,
14
+ vector: embedding.vector,
15
+ payload: {
16
+ ...this.config.metadata,
17
+ ...fragment?.metadata ?? {},
18
+ documentId: fragment?.documentId
19
+ },
20
+ namespace: this.config.namespace
21
+ };
22
+ });
23
+ const request = {
24
+ collection: this.config.collection,
25
+ documents
26
+ };
27
+ await this.provider.upsert(request);
28
+ }
29
+ };
30
+
31
+ //#endregion
32
+ export { VectorIndexer };
@@ -1 +1,3 @@
1
- import{KnowledgeQueryService as e}from"./service.js";export{e as KnowledgeQueryService};
1
+ import { KnowledgeQueryService } from "./service.js";
2
+
3
+ export { KnowledgeQueryService };
@@ -1,3 +1,65 @@
1
- var e=class{embeddings;vectorStore;llm;config;constructor(e,t,n,r){this.embeddings=e,this.vectorStore=t,this.llm=n,this.config=r}async query(e){let r=await this.embeddings.embedQuery(e),i=await this.vectorStore.search({collection:this.config.collection,vector:r.vector,topK:this.config.topK??5,namespace:this.config.namespace,filter:void 0}),a=t(i),o=this.buildMessages(e,a),s=await this.llm.chat(o);return{answer:s.message.content.map(e=>`text`in e?e.text:``).join(``),references:i.map(e=>({...e,text:n(e)})),usage:s.usage}}buildMessages(e,t){return[{role:`system`,content:[{type:`text`,text:this.config.systemPrompt??`You are a knowledge assistant that answers questions using the provided context. Cite relevant sources if possible.`}]},{role:`user`,content:[{type:`text`,text:`Question:\n${e}\n\nContext:\n${t}`}]}]}};function t(e){return e.length===0?`No relevant documents found.`:e.map((e,t)=>{let r=n(e);return`Source ${t+1} (score: ${e.score.toFixed(3)}):\n${r}`}).join(`
1
+ //#region src/knowledge/query/service.ts
2
+ var KnowledgeQueryService = class {
3
+ embeddings;
4
+ vectorStore;
5
+ llm;
6
+ config;
7
+ constructor(embeddings, vectorStore, llm, config) {
8
+ this.embeddings = embeddings;
9
+ this.vectorStore = vectorStore;
10
+ this.llm = llm;
11
+ this.config = config;
12
+ }
13
+ async query(question) {
14
+ const embedding = await this.embeddings.embedQuery(question);
15
+ const results = await this.vectorStore.search({
16
+ collection: this.config.collection,
17
+ vector: embedding.vector,
18
+ topK: this.config.topK ?? 5,
19
+ namespace: this.config.namespace,
20
+ filter: void 0
21
+ });
22
+ const context = buildContext(results);
23
+ const messages = this.buildMessages(question, context);
24
+ const response = await this.llm.chat(messages);
25
+ return {
26
+ answer: response.message.content.map((part) => "text" in part ? part.text : "").join(""),
27
+ references: results.map((result) => ({
28
+ ...result,
29
+ text: extractText(result)
30
+ })),
31
+ usage: response.usage
32
+ };
33
+ }
34
+ buildMessages(question, context) {
35
+ return [{
36
+ role: "system",
37
+ content: [{
38
+ type: "text",
39
+ text: this.config.systemPrompt ?? "You are a knowledge assistant that answers questions using the provided context. Cite relevant sources if possible."
40
+ }]
41
+ }, {
42
+ role: "user",
43
+ content: [{
44
+ type: "text",
45
+ text: `Question:\n${question}\n\nContext:\n${context}`
46
+ }]
47
+ }];
48
+ }
49
+ };
50
+ function buildContext(results) {
51
+ if (results.length === 0) return "No relevant documents found.";
52
+ return results.map((result, index) => {
53
+ const text = extractText(result);
54
+ return `Source ${index + 1} (score: ${result.score.toFixed(3)}):\n${text}`;
55
+ }).join("\n\n");
56
+ }
57
+ function extractText(result) {
58
+ const payload = result.payload ?? {};
59
+ if (typeof payload.text === "string") return payload.text;
60
+ if (typeof payload.content === "string") return payload.content;
61
+ return JSON.stringify(payload);
62
+ }
2
63
 
3
- `)}function n(e){let t=e.payload??{};return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:JSON.stringify(t)}export{e as KnowledgeQueryService};
64
+ //#endregion
65
+ export { KnowledgeQueryService };
@@ -1 +1,49 @@
1
- const e=[`external`,`ephemeral`];var t=class{disallowedWrite;requireWorkflowBinding;requireAgentBinding;constructor(t={}){this.disallowedWrite=new Set(t.disallowWriteCategories??e),this.requireWorkflowBinding=t.requireWorkflowBinding??!0,this.requireAgentBinding=t.requireAgentBinding??!1}checkAccess(e,t,n){let{binding:r,space:i}=e;if(r.required!==!1&&!this.isSpaceBound(e,n))return{allowed:!1,reason:`Knowledge space "${i.meta.key}" is not bound in the resolved app config.`};if(t.operation===`write`&&this.disallowedWrite.has(i.meta.category))return{allowed:!1,reason:`Knowledge space "${i.meta.key}" is category "${i.meta.category}" and is read-only.`};if(this.requireWorkflowBinding&&t.workflowName){let e=r.scope?.workflows;if(e&&!e.includes(t.workflowName))return{allowed:!1,reason:`Workflow "${t.workflowName}" is not authorized to access knowledge space "${i.meta.key}".`}}if(this.requireAgentBinding&&t.agentName){let e=r.scope?.agents;if(e&&!e.includes(t.agentName))return{allowed:!1,reason:`Agent "${t.agentName}" is not authorized to access knowledge space "${i.meta.key}".`}}return i.meta.category===`ephemeral`?{allowed:!0,severity:`warning`,reason:`Knowledge space "${i.meta.key}" is ephemeral; results may be transient.`}:{allowed:!0}}isSpaceBound(e,t){return t.knowledge.some(t=>t.space.meta.key===e.space.meta.key&&(e.space.meta.version==null||t.space.meta.version===e.space.meta.version))}};export{t as KnowledgeAccessGuard};
1
+ //#region src/knowledge/runtime.ts
2
+ const DEFAULT_DISALLOWED_WRITE = ["external", "ephemeral"];
3
+ var KnowledgeAccessGuard = class {
4
+ disallowedWrite;
5
+ requireWorkflowBinding;
6
+ requireAgentBinding;
7
+ constructor(options = {}) {
8
+ this.disallowedWrite = new Set(options.disallowWriteCategories ?? DEFAULT_DISALLOWED_WRITE);
9
+ this.requireWorkflowBinding = options.requireWorkflowBinding ?? true;
10
+ this.requireAgentBinding = options.requireAgentBinding ?? false;
11
+ }
12
+ checkAccess(spaceBinding, context, appConfig) {
13
+ const { binding, space } = spaceBinding;
14
+ if (binding.required !== false && !this.isSpaceBound(spaceBinding, appConfig)) return {
15
+ allowed: false,
16
+ reason: `Knowledge space "${space.meta.key}" is not bound in the resolved app config.`
17
+ };
18
+ if (context.operation === "write" && this.disallowedWrite.has(space.meta.category)) return {
19
+ allowed: false,
20
+ reason: `Knowledge space "${space.meta.key}" is category "${space.meta.category}" and is read-only.`
21
+ };
22
+ if (this.requireWorkflowBinding && context.workflowName) {
23
+ const allowedWorkflows = binding.scope?.workflows;
24
+ if (allowedWorkflows && !allowedWorkflows.includes(context.workflowName)) return {
25
+ allowed: false,
26
+ reason: `Workflow "${context.workflowName}" is not authorized to access knowledge space "${space.meta.key}".`
27
+ };
28
+ }
29
+ if (this.requireAgentBinding && context.agentName) {
30
+ const allowedAgents = binding.scope?.agents;
31
+ if (allowedAgents && !allowedAgents.includes(context.agentName)) return {
32
+ allowed: false,
33
+ reason: `Agent "${context.agentName}" is not authorized to access knowledge space "${space.meta.key}".`
34
+ };
35
+ }
36
+ if (space.meta.category === "ephemeral") return {
37
+ allowed: true,
38
+ severity: "warning",
39
+ reason: `Knowledge space "${space.meta.key}" is ephemeral; results may be transient.`
40
+ };
41
+ return { allowed: true };
42
+ }
43
+ isSpaceBound(resolved, appConfig) {
44
+ return appConfig.knowledge.some((entry) => entry.space.meta.key === resolved.space.meta.key && (resolved.space.meta.version == null || entry.space.meta.version === resolved.space.meta.version));
45
+ }
46
+ };
47
+
48
+ //#endregion
49
+ export { KnowledgeAccessGuard };
@@ -1 +1,38 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.email-threads`,version:1,category:`operational`,displayName:`Email Threads`,title:`Operational Email Threads`,description:`Indexed copies of operational email threads used for support, onboarding, and workflows.`,domain:`operations`,owners:[`platform.operations`],tags:[`email`,`operations`],stability:e.Beta},retention:{ttlDays:365},access:{policy:{name:`knowledge.access.email-threads`,version:1},trustLevel:`medium`,automationWritable:!0},indexing:{embeddingModel:`mistral-embed`,chunkSize:600,vectorDbIntegration:`vectordb.qdrant`},description:`Operational email threads synchronized from Gmail to support automations and contextual assistance.`};function n(e){return e.register(t)}export{t as emailThreadsKnowledgeSpace,n as registerEmailThreadsKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/email-threads.ts
4
+ const emailThreadsKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.email-threads",
7
+ version: 1,
8
+ category: "operational",
9
+ displayName: "Email Threads",
10
+ title: "Operational Email Threads",
11
+ description: "Indexed copies of operational email threads used for support, onboarding, and workflows.",
12
+ domain: "operations",
13
+ owners: ["platform.operations"],
14
+ tags: ["email", "operations"],
15
+ stability: StabilityEnum.Beta
16
+ },
17
+ retention: { ttlDays: 365 },
18
+ access: {
19
+ policy: {
20
+ name: "knowledge.access.email-threads",
21
+ version: 1
22
+ },
23
+ trustLevel: "medium",
24
+ automationWritable: true
25
+ },
26
+ indexing: {
27
+ embeddingModel: "mistral-embed",
28
+ chunkSize: 600,
29
+ vectorDbIntegration: "vectordb.qdrant"
30
+ },
31
+ description: "Operational email threads synchronized from Gmail to support automations and contextual assistance."
32
+ };
33
+ function registerEmailThreadsKnowledgeSpace(registry) {
34
+ return registry.register(emailThreadsKnowledgeSpace);
35
+ }
36
+
37
+ //#endregion
38
+ export { emailThreadsKnowledgeSpace, registerEmailThreadsKnowledgeSpace };
@@ -1 +1,38 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.financial-docs`,version:1,category:`canonical`,displayName:`Financial Documents`,title:`Household Financial Documents`,description:`Invoices, bills, and contracts powering Pocket Family Office financial automation.`,domain:`finance`,owners:[`platform.finance`],tags:[`finance`,`documents`],stability:e.Beta},retention:{ttlDays:null},access:{policy:{name:`knowledge.access.financial-docs`,version:1},trustLevel:`high`,automationWritable:!0},indexing:{embeddingModel:`mistral-embed`,chunkSize:700,vectorDbIntegration:`vectordb.qdrant`},description:`Normalized financial documents enabling bill pay automation, reminders, and summaries.`};function n(e){return e.register(t)}export{t as financialDocsKnowledgeSpace,n as registerFinancialDocsKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/financial-docs.ts
4
+ const financialDocsKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.financial-docs",
7
+ version: 1,
8
+ category: "canonical",
9
+ displayName: "Financial Documents",
10
+ title: "Household Financial Documents",
11
+ description: "Invoices, bills, and contracts powering Pocket Family Office financial automation.",
12
+ domain: "finance",
13
+ owners: ["platform.finance"],
14
+ tags: ["finance", "documents"],
15
+ stability: StabilityEnum.Beta
16
+ },
17
+ retention: { ttlDays: null },
18
+ access: {
19
+ policy: {
20
+ name: "knowledge.access.financial-docs",
21
+ version: 1
22
+ },
23
+ trustLevel: "high",
24
+ automationWritable: true
25
+ },
26
+ indexing: {
27
+ embeddingModel: "mistral-embed",
28
+ chunkSize: 700,
29
+ vectorDbIntegration: "vectordb.qdrant"
30
+ },
31
+ description: "Normalized financial documents enabling bill pay automation, reminders, and summaries."
32
+ };
33
+ function registerFinancialDocsKnowledgeSpace(registry) {
34
+ return registry.register(financialDocsKnowledgeSpace);
35
+ }
36
+
37
+ //#endregion
38
+ export { financialDocsKnowledgeSpace, registerFinancialDocsKnowledgeSpace };
@@ -1 +1,42 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.financial-overview`,version:1,category:`operational`,displayName:`Financial Overview Summaries`,title:`Derived Financial Summaries`,description:`Aggregated cashflow summaries, category breakdowns, and balance trends derived from open banking data.`,domain:`finance`,owners:[`platform.finance`],tags:[`open-banking`,`summaries`,`cashflow`],stability:e.Experimental},retention:{ttlDays:180},access:{policy:{name:`knowledge.access.financial-overview`,version:1},trustLevel:`medium`,automationWritable:!0},indexing:{embeddingModel:`mistral-embed`,chunkSize:600,vectorDbIntegration:`vectordb.qdrant`},description:`Derived knowledge space containing weekly/monthly cashflow rollups and account health summaries. Raw transactions are excluded to respect privacy guardrails.`};function n(e){return e.register(t)}export{t as financialOverviewKnowledgeSpace,n as registerFinancialOverviewKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/financial-overview.ts
4
+ const financialOverviewKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.financial-overview",
7
+ version: 1,
8
+ category: "operational",
9
+ displayName: "Financial Overview Summaries",
10
+ title: "Derived Financial Summaries",
11
+ description: "Aggregated cashflow summaries, category breakdowns, and balance trends derived from open banking data.",
12
+ domain: "finance",
13
+ owners: ["platform.finance"],
14
+ tags: [
15
+ "open-banking",
16
+ "summaries",
17
+ "cashflow"
18
+ ],
19
+ stability: StabilityEnum.Experimental
20
+ },
21
+ retention: { ttlDays: 180 },
22
+ access: {
23
+ policy: {
24
+ name: "knowledge.access.financial-overview",
25
+ version: 1
26
+ },
27
+ trustLevel: "medium",
28
+ automationWritable: true
29
+ },
30
+ indexing: {
31
+ embeddingModel: "mistral-embed",
32
+ chunkSize: 600,
33
+ vectorDbIntegration: "vectordb.qdrant"
34
+ },
35
+ description: "Derived knowledge space containing weekly/monthly cashflow rollups and account health summaries. Raw transactions are excluded to respect privacy guardrails."
36
+ };
37
+ function registerFinancialOverviewKnowledgeSpace(registry) {
38
+ return registry.register(financialOverviewKnowledgeSpace);
39
+ }
40
+
41
+ //#endregion
42
+ export { financialOverviewKnowledgeSpace, registerFinancialOverviewKnowledgeSpace };
@@ -1 +1,8 @@
1
- import{productCanonKnowledgeSpace as e,registerProductCanonKnowledgeSpace as t}from"./product-canon.js";import{registerSupportFaqKnowledgeSpace as n,supportFaqKnowledgeSpace as r}from"./support-faq.js";import{emailThreadsKnowledgeSpace as i,registerEmailThreadsKnowledgeSpace as a}from"./email-threads.js";import{registerUploadedDocsKnowledgeSpace as o,uploadedDocsKnowledgeSpace as s}from"./uploaded-docs.js";import{financialDocsKnowledgeSpace as c,registerFinancialDocsKnowledgeSpace as l}from"./financial-docs.js";import{financialOverviewKnowledgeSpace as u,registerFinancialOverviewKnowledgeSpace as d}from"./financial-overview.js";export{i as emailThreadsKnowledgeSpace,c as financialDocsKnowledgeSpace,u as financialOverviewKnowledgeSpace,e as productCanonKnowledgeSpace,a as registerEmailThreadsKnowledgeSpace,l as registerFinancialDocsKnowledgeSpace,d as registerFinancialOverviewKnowledgeSpace,t as registerProductCanonKnowledgeSpace,n as registerSupportFaqKnowledgeSpace,o as registerUploadedDocsKnowledgeSpace,r as supportFaqKnowledgeSpace,s as uploadedDocsKnowledgeSpace};
1
+ import { productCanonKnowledgeSpace, registerProductCanonKnowledgeSpace } from "./product-canon.js";
2
+ import { registerSupportFaqKnowledgeSpace, supportFaqKnowledgeSpace } from "./support-faq.js";
3
+ import { emailThreadsKnowledgeSpace, registerEmailThreadsKnowledgeSpace } from "./email-threads.js";
4
+ import { registerUploadedDocsKnowledgeSpace, uploadedDocsKnowledgeSpace } from "./uploaded-docs.js";
5
+ import { financialDocsKnowledgeSpace, registerFinancialDocsKnowledgeSpace } from "./financial-docs.js";
6
+ import { financialOverviewKnowledgeSpace, registerFinancialOverviewKnowledgeSpace } from "./financial-overview.js";
7
+
8
+ export { emailThreadsKnowledgeSpace, financialDocsKnowledgeSpace, financialOverviewKnowledgeSpace, productCanonKnowledgeSpace, registerEmailThreadsKnowledgeSpace, registerFinancialDocsKnowledgeSpace, registerFinancialOverviewKnowledgeSpace, registerProductCanonKnowledgeSpace, registerSupportFaqKnowledgeSpace, registerUploadedDocsKnowledgeSpace, supportFaqKnowledgeSpace, uploadedDocsKnowledgeSpace };
@@ -1 +1,38 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.product-canon`,version:1,category:`canonical`,displayName:`Product Canon`,title:`Product Canon Knowledge Space`,description:`Authoritative product knowledge covering strategy, roadmap, and delivery canon.`,domain:`product`,owners:[`platform.product`],tags:[`knowledge`,`product`],stability:e.Stable},retention:{ttlDays:null},access:{policy:{name:`knowledge.access.product-canon`,version:1},trustLevel:`high`,automationWritable:!1},indexing:{embeddingModel:`text-embedding-3-large`,chunkSize:800,vectorDbIntegration:`vectordb.qdrant`},description:`Single source of truth for product canon, principles, and strategic narratives.`};function n(e){return e.register(t)}export{t as productCanonKnowledgeSpace,n as registerProductCanonKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/product-canon.ts
4
+ const productCanonKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.product-canon",
7
+ version: 1,
8
+ category: "canonical",
9
+ displayName: "Product Canon",
10
+ title: "Product Canon Knowledge Space",
11
+ description: "Authoritative product knowledge covering strategy, roadmap, and delivery canon.",
12
+ domain: "product",
13
+ owners: ["platform.product"],
14
+ tags: ["knowledge", "product"],
15
+ stability: StabilityEnum.Stable
16
+ },
17
+ retention: { ttlDays: null },
18
+ access: {
19
+ policy: {
20
+ name: "knowledge.access.product-canon",
21
+ version: 1
22
+ },
23
+ trustLevel: "high",
24
+ automationWritable: false
25
+ },
26
+ indexing: {
27
+ embeddingModel: "text-embedding-3-large",
28
+ chunkSize: 800,
29
+ vectorDbIntegration: "vectordb.qdrant"
30
+ },
31
+ description: "Single source of truth for product canon, principles, and strategic narratives."
32
+ };
33
+ function registerProductCanonKnowledgeSpace(registry) {
34
+ return registry.register(productCanonKnowledgeSpace);
35
+ }
36
+
37
+ //#endregion
38
+ export { productCanonKnowledgeSpace, registerProductCanonKnowledgeSpace };
@@ -1 +1,41 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.support-faq`,version:1,category:`operational`,displayName:`Support FAQ`,title:`Support & Success FAQ`,description:`Operational knowledge base for customer support and success.`,domain:`support`,owners:[`platform.support`],tags:[`knowledge`,`support`],stability:e.Beta},retention:{ttlDays:365,archiveAfterDays:180},access:{policy:{name:`knowledge.access.support`,version:1},trustLevel:`medium`,automationWritable:!0},indexing:{embeddingModel:`text-embedding-3-small`,chunkSize:700,vectorDbIntegration:`vectordb.qdrant`},description:`Operational FAQs, runbooks, and customer success playbooks augmented with automation updates.`};function n(e){return e.register(t)}export{n as registerSupportFaqKnowledgeSpace,t as supportFaqKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/support-faq.ts
4
+ const supportFaqKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.support-faq",
7
+ version: 1,
8
+ category: "operational",
9
+ displayName: "Support FAQ",
10
+ title: "Support & Success FAQ",
11
+ description: "Operational knowledge base for customer support and success.",
12
+ domain: "support",
13
+ owners: ["platform.support"],
14
+ tags: ["knowledge", "support"],
15
+ stability: StabilityEnum.Beta
16
+ },
17
+ retention: {
18
+ ttlDays: 365,
19
+ archiveAfterDays: 180
20
+ },
21
+ access: {
22
+ policy: {
23
+ name: "knowledge.access.support",
24
+ version: 1
25
+ },
26
+ trustLevel: "medium",
27
+ automationWritable: true
28
+ },
29
+ indexing: {
30
+ embeddingModel: "text-embedding-3-small",
31
+ chunkSize: 700,
32
+ vectorDbIntegration: "vectordb.qdrant"
33
+ },
34
+ description: "Operational FAQs, runbooks, and customer success playbooks augmented with automation updates."
35
+ };
36
+ function registerSupportFaqKnowledgeSpace(registry) {
37
+ return registry.register(supportFaqKnowledgeSpace);
38
+ }
39
+
40
+ //#endregion
41
+ export { registerSupportFaqKnowledgeSpace, supportFaqKnowledgeSpace };
@@ -1 +1,38 @@
1
- import{StabilityEnum as e}from"../../ownership.js";const t={meta:{key:`knowledge.uploaded-docs`,version:1,category:`external`,displayName:`Uploaded Documents`,title:`Uploaded Knowledge Assets`,description:`Documents uploaded by households, including invoices, contracts, and reference files.`,domain:`operations`,owners:[`platform.operations`],tags:[`documents`,`storage`],stability:e.Beta},retention:{ttlDays:null},access:{policy:{name:`knowledge.access.uploaded-docs`,version:1},trustLevel:`medium`,automationWritable:!0},indexing:{embeddingModel:`mistral-embed`,chunkSize:900,vectorDbIntegration:`vectordb.qdrant`},description:`User-provided documents normalized and embedded for retrieval augmented workflows.`};function n(e){return e.register(t)}export{n as registerUploadedDocsKnowledgeSpace,t as uploadedDocsKnowledgeSpace};
1
+ import { StabilityEnum } from "../../ownership.js";
2
+
3
+ //#region src/knowledge/spaces/uploaded-docs.ts
4
+ const uploadedDocsKnowledgeSpace = {
5
+ meta: {
6
+ key: "knowledge.uploaded-docs",
7
+ version: 1,
8
+ category: "external",
9
+ displayName: "Uploaded Documents",
10
+ title: "Uploaded Knowledge Assets",
11
+ description: "Documents uploaded by households, including invoices, contracts, and reference files.",
12
+ domain: "operations",
13
+ owners: ["platform.operations"],
14
+ tags: ["documents", "storage"],
15
+ stability: StabilityEnum.Beta
16
+ },
17
+ retention: { ttlDays: null },
18
+ access: {
19
+ policy: {
20
+ name: "knowledge.access.uploaded-docs",
21
+ version: 1
22
+ },
23
+ trustLevel: "medium",
24
+ automationWritable: true
25
+ },
26
+ indexing: {
27
+ embeddingModel: "mistral-embed",
28
+ chunkSize: 900,
29
+ vectorDbIntegration: "vectordb.qdrant"
30
+ },
31
+ description: "User-provided documents normalized and embedded for retrieval augmented workflows."
32
+ };
33
+ function registerUploadedDocsKnowledgeSpace(registry) {
34
+ return registry.register(uploadedDocsKnowledgeSpace);
35
+ }
36
+
37
+ //#endregion
38
+ export { registerUploadedDocsKnowledgeSpace, uploadedDocsKnowledgeSpace };
@@ -1 +1,39 @@
1
- const e=e=>`${e.key}.v${e.version}`;var t=class{items=new Map;register(t){let n=e(t.meta);if(this.items.has(n))throw Error(`Duplicate KnowledgeSpaceSpec ${n}`);return this.items.set(n,t),this}list(){return[...this.items.values()]}get(t,n){if(n!=null)return this.items.get(e({key:t,version:n}));let r,i=-1/0;for(let e of this.items.values())e.meta.key===t&&e.meta.version>i&&(i=e.meta.version,r=e);return r}getByCategory(e){return this.list().filter(t=>t.meta.category===e)}};function n(t){return e(t)}export{t as KnowledgeSpaceRegistry,n as makeKnowledgeSpaceKey};
1
+ //#region src/knowledge/spec.ts
2
+ const knowledgeKey = (meta) => `${meta.key}.v${meta.version}`;
3
+ var KnowledgeSpaceRegistry = class {
4
+ items = /* @__PURE__ */ new Map();
5
+ register(spec) {
6
+ const key = knowledgeKey(spec.meta);
7
+ if (this.items.has(key)) throw new Error(`Duplicate KnowledgeSpaceSpec ${key}`);
8
+ this.items.set(key, spec);
9
+ return this;
10
+ }
11
+ list() {
12
+ return [...this.items.values()];
13
+ }
14
+ get(key, version) {
15
+ if (version != null) return this.items.get(knowledgeKey({
16
+ key,
17
+ version
18
+ }));
19
+ let latest;
20
+ let maxVersion = -Infinity;
21
+ for (const spec of this.items.values()) {
22
+ if (spec.meta.key !== key) continue;
23
+ if (spec.meta.version > maxVersion) {
24
+ maxVersion = spec.meta.version;
25
+ latest = spec;
26
+ }
27
+ }
28
+ return latest;
29
+ }
30
+ getByCategory(category) {
31
+ return this.list().filter((spec) => spec.meta.category === category);
32
+ }
33
+ };
34
+ function makeKnowledgeSpaceKey(meta) {
35
+ return knowledgeKey(meta);
36
+ }
37
+
38
+ //#endregion
39
+ export { KnowledgeSpaceRegistry, makeKnowledgeSpaceKey };