// Shared, runtime-neutral knowledge manifest data. The normal app binds its worker implementations // of the index/remove jobs; the Convex binding file (module.convex.ts) ships fail-closed for a // future wiring — the module stays Postgres-only until the search effect and the jobs have their // composed Node actions (see README.md). import { contribute, type ModuleManifest } from "@conusai-kit/core" import { repositoryBindings } from "@conusai-kit/data" import { filesProcessors } from "@conusai-kit/files" import { accountData } from "@conusai-kit/tenancy" import { knowledgeAccountData } from "./adapters/account.js" import { KNOWLEDGE_PROCEDURE_IMPLS } from "./adapters/procedures.js" import { AUTO_INDEX_CHANGED, AUTO_INDEX_CONTENT_TYPES, AUTO_INDEX_JOB, AUTO_INDEX_PROCESSOR_KEY, COLLECTION_CREATED, DOCUMENT_AI_DISABLED, DOCUMENT_AI_ENABLED, INDEX_JOB, KNOWLEDGE_COLLECTIONS, KNOWLEDGE_ENTITIES, KNOWLEDGE_FLAG_DEFAULTS, } from "./contract/index.js" import { en, lt } from "./i18n/index.js" const tables = repositoryBindings(...KNOWLEDGE_ENTITIES) export const KNOWLEDGE_MODULE_BASE: ModuleManifest = { id: "knowledge", version: "0.1.0", kit: "^0.1.0", requires: ["tenancy", "files"], serviceRequirements: [ { transport: "platform", service: "knowledge", apiRange: "=1.0.0", profiles: ["postgres"], operations: { [INDEX_JOB]: ["knowledge.collections:use"], [AUTO_INDEX_JOB]: ["knowledge.collections:use"], "knowledge.search": ["knowledge.collections:use"], }, configuration: ["ai_processing"], dependencies: ["blob", "ai"], dataClasses: ["document", "personal", "ai-input"], partitionRequired: false, remediation: "/settings/services/knowledge", }, { // The automatic PDF intake reads an uploaded PDF through the platform's document reader (core-11). transport: "platform", service: "ocr", apiRange: "=1.0.0-preview.20261103", profiles: ["postgres"], operations: { [AUTO_INDEX_JOB]: ["ocr:use"] }, configuration: ["ocr_processing"], dependencies: ["blob"], dataClasses: ["document", "personal"], partitionRequired: false, remediation: "/settings/services/ocr", }, ], permissions: { // Searching and reading the status is a member's act; the kit's member maps onto "editor". "knowledge.knowledge.search": "editor", // Managing collections, indexing and removing documents, and the enablement flow are // administrative acts. "knowledge.collection.manage": "admin", "knowledge.knowledge.manage": "admin", "knowledge.settings.manage": "admin", }, procedures: KNOWLEDGE_PROCEDURE_IMPLS, // Indexing is live (TS6.1): a change of knowledge_document reaches every member's open page. collections: [...KNOWLEDGE_COLLECTIONS], repositories: { postgres: tables }, migrations: { postgres: "migrations" }, // The module ships the Postgres profile; the Convex binding file (module.convex.ts) ships // fail-closed for a future wiring and is deliberately NOT registered in convex/ — the search // effect, the jobs and the enablement flow all leave the process and have no composed Convex // Node actions yet (see README.md). profiles: ["postgres"], audit: [COLLECTION_CREATED, DOCUMENT_AI_ENABLED, DOCUMENT_AI_DISABLED, AUTO_INDEX_CHANGED], flags: Object.fromEntries(Object.entries(KNOWLEDGE_FLAG_DEFAULTS).map(([flag, value]) => [flag, { default: value }])), ui: { nav: [{ scope: "project", label: "knowledge.title", href: "knowledge", permission: "knowledge.knowledge.search" }], }, i18n: { en, lt }, // An opted-in project's uploaded PDFs, indexed automatically (core-11): the job reads nothing for a // project that has not opted in. extends: [ contribute(accountData, [knowledgeAccountData]), contribute(filesProcessors, [ { key: AUTO_INDEX_PROCESSOR_KEY, contentTypes: [...AUTO_INDEX_CONTENT_TYPES], job: AUTO_INDEX_JOB }, ]), ], }