@fortemi/core 2026.6.2 → 2026.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/aiwg-index.d.ts +31 -1
- package/dist/aiwg-index.js +177 -10
- package/dist/aiwg-index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +177 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/aiwg-index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/aiwg-index.ts"],"names":[],"mappings":";AAmOA,IAAM,sBAAA,GAAyD;AAAA,EAC7D,gBAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,WAAA,uBAAkB,GAAA,CAA2B;AAAA,EACjD,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,WAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,qBAAA,GAA+C;AAAA,EACnD,KAAA,EAAO,CAAA;AAAA,EACP,GAAA,EAAK,CAAA;AAAA,EACL,OAAA,EAAS,CAAA;AAAA,EACT,IAAA,EAAM;AACR,CAAA;AAEA,SAAS,UAAU,KAAA,EAAiC;AAClD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,GAAS,CAAA;AACrD;AAEA,SAAS,SAAA,CAAU,MAAA,EAAgD,IAAA,EAAc,KAAA,EAAe;AAC9F,EAAA,MAAA,CAAO,IAAI,MAAM,EAAC;AAClB,EAAA,MAAA,CAAO,IAAI,EAAE,KAAK,CAAA,GAAA,CAAK,OAAO,IAAI,CA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MAAA,CAAO,MAAA,GAAS,CAAA,EAAG,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,CAAA,EAAG,OAAA,CAAQ,cAAc,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAA;AAAA,EAC1F;AACA,EAAA,IAAI,QAAQ,kBAAA,EAAoB;AAC9B,IAAA,MAAM,SAAS,OAAA,CAAQ,kBAAA;AACvB,IAAA,MAAM,IAAA,GAAO,KAAK,IAAA,CAAK,MAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,CAAI,UAAA,CAAW,MAAM,CAAC,CAAA;AAC7D,IAAA,IAAI,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG,OAAO,IAAA;AAAA,EAC9B;AACA,EAAA,IAAI,IAAA,CAAK,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AACxF,EAAA,OAAO,CAAC,CAAA,KAAA,EAAQ,IAAA,CAAK,IAAI,CAAA,CAAE,CAAA;AAC7B","file":"aiwg-index.js","sourcesContent":["export type AiwgFortemiRecordType =\n | 'crm.contact'\n | 'crm.organization'\n | 'crm.event'\n | 'crm.interaction'\n | 'aiwg.artifact'\n | 'docs.page'\n\nexport type AiwgPrivacyClassification = 'private' | 'sanitized' | 'public'\nexport type AiwgProvenanceConfidence = 'source' | 'candidate' | 'reviewed' | 'rejected'\nexport type AiwgReviewAction = 'accept' | 'reject' | 'defer'\n\nexport interface AiwgFortemiRecordSource {\n path: string\n repo_relative_path: string\n locator: string\n}\n\nexport interface AiwgFortemiRelationship {\n type: string\n target_id: string\n source_path?: string\n}\n\nexport interface AiwgFortemiProvenance {\n field: string\n source: string\n path: string\n confidence: AiwgProvenanceConfidence\n privacy: AiwgPrivacyClassification\n}\n\nexport interface AiwgFortemiRecord {\n schema_version: 'aiwg.fortemi.index.record.v1'\n id: string\n type: AiwgFortemiRecordType\n source: AiwgFortemiRecordSource\n title: string\n text: string\n facets: Record<string, string[]>\n tags: string[]\n concepts: string[]\n relationships: AiwgFortemiRelationship[]\n provenance: AiwgFortemiProvenance[]\n privacy: {\n classification: AiwgPrivacyClassification\n pii: boolean\n }\n updated_at: string\n}\n\nexport interface AiwgFortemiIndexExport {\n schema_version: 'aiwg.fortemi.index.export.v1'\n generated_at: string\n source: {\n repo: string\n privacy: AiwgPrivacyClassification\n }\n items: AiwgFortemiRecord[]\n}\n\nexport interface AiwgFortemiChunkPartRef {\n href: string\n offset: number\n count: number\n}\n\nexport interface AiwgFortemiChunkManifest {\n schema_version: 'aiwg.fortemi.index.chunk-manifest.v1'\n generated_at: string\n source: AiwgFortemiIndexExport['source']\n total: number\n part_size: number\n facets?: Record<string, Record<string, number>>\n parts: AiwgFortemiChunkPartRef[]\n}\n\nexport interface AiwgFortemiChunkPart {\n schema_version: 'aiwg.fortemi.index.chunk.v1'\n manifest_schema_version: 'aiwg.fortemi.index.chunk-manifest.v1'\n offset: number\n items: AiwgFortemiRecord[]\n}\n\nexport interface AiwgIndexValidationResult {\n valid: boolean\n errors: string[]\n counts: Partial<Record<AiwgFortemiRecordType, number>>\n}\n\nexport interface AiwgChunkedIndexValidationResult {\n valid: boolean\n errors: string[]\n}\n\nexport interface AiwgIndexQueryOptions {\n types?: AiwgFortemiRecordType[]\n facets?: Record<string, string[]>\n tags?: string[]\n concepts?: string[]\n privacy?: AiwgPrivacyClassification[]\n relationshipTargetId?: string\n limit?: number\n offset?: number\n rank?: boolean\n snippets?: boolean\n snippetLength?: number\n weights?: Partial<AiwgIndexQueryWeights>\n includeMatches?: boolean\n}\n\nexport interface AiwgIndexQueryWeights {\n title: number\n text: number\n tag: number\n concept: number\n}\n\nexport interface AiwgIndexQueryMatch {\n field: 'title' | 'text' | 'tag' | 'concept'\n value: string\n}\n\nexport interface AiwgIndexQueryRankedItem {\n item: AiwgFortemiRecord\n rank: number\n snippet?: string\n matches?: AiwgIndexQueryMatch[]\n}\n\nexport interface AiwgIndexQueryResult {\n items: AiwgFortemiRecord[]\n total: number\n facets: Record<string, Record<string, number>>\n rankedItems?: AiwgIndexQueryRankedItem[]\n}\n\nexport type AiwgChunkedIndexLoader = (\n part: AiwgFortemiChunkPartRef,\n manifest: AiwgFortemiChunkManifest,\n) => Promise<unknown>\n\nexport interface AiwgChunkedIndexLoadOptions {\n maxCachedParts?: number\n}\n\nexport type AiwgChunkedIndexProgressPhase = 'part' | 'query'\n\nexport interface AiwgChunkedIndexProgress {\n phase: AiwgChunkedIndexProgressPhase\n done: number\n total: number\n href?: string\n}\n\nexport interface AiwgChunkedIndexQueryOptions extends AiwgIndexQueryOptions {\n onProgress?: (progress: AiwgChunkedIndexProgress) => void\n}\n\nexport interface AiwgChunkedIndexQueryResult extends AiwgIndexQueryResult {\n manifestTotal: number\n scannedParts: number\n fetchedParts: number\n complete: boolean\n}\n\nexport interface AiwgReviewDecision {\n item_id: string\n action: AiwgReviewAction\n reason?: string\n updated_at: string\n}\n\nexport interface AiwgReviewDecisionExport {\n schema_version: 'aiwg.fortemi.review-decisions.v1'\n generated_at: string\n source_export_schema_version: string\n decisions: AiwgReviewDecision[]\n}\n\nexport interface AiwgIndexGraphOptions {\n communityFacet?: string\n communityTagPrefix?: string\n relationshipWeights?: Record<string, number>\n includeDanglingRelationships?: boolean\n}\n\nexport interface AiwgReviewInput {\n item_id: string\n action: AiwgReviewAction\n reason?: string\n}\n\nexport interface AiwgIndexControllerSnapshot {\n index: AiwgFortemiIndexExport | null\n chunked: {\n manifest: AiwgFortemiChunkManifest\n cachedParts: number\n maxCachedParts: number\n } | null\n data: AiwgIndexQueryResult | null\n error: Error | null\n reviewDecisions: AiwgReviewDecision[]\n}\n\nexport type AiwgIndexControllerListener = (snapshot: AiwgIndexControllerSnapshot) => void\n\nexport interface AiwgIndexController {\n loadIndex(value: unknown): AiwgFortemiIndexExport\n loadChunkedIndex(\n manifest: unknown,\n loader: AiwgChunkedIndexLoader,\n options?: AiwgChunkedIndexLoadOptions,\n ): AiwgFortemiChunkManifest\n getIndex(): AiwgFortemiIndexExport | null\n getChunkedManifest(): AiwgFortemiChunkManifest | null\n getSnapshot(): AiwgIndexControllerSnapshot\n query(query?: string, options?: AiwgIndexQueryOptions): AiwgIndexQueryResult\n queryChunked(query?: string, options?: AiwgChunkedIndexQueryOptions): Promise<AiwgChunkedIndexQueryResult>\n clearChunkCache(): void\n toCommunityGraph(options?: AiwgIndexGraphOptions): ReturnType<typeof aiwgFortemiIndexToCommunityGraph>\n setReviewDecision(input: AiwgReviewInput): AiwgReviewDecision\n clearReviewDecision(itemId: string): void\n createReviewDecisionExport(generatedAt?: string): AiwgReviewDecisionExport\n subscribe(listener: AiwgIndexControllerListener): () => void\n}\n\nconst REQUIRED_RECORD_FIELDS: Array<keyof AiwgFortemiRecord> = [\n 'schema_version',\n 'id',\n 'type',\n 'source',\n 'title',\n 'text',\n 'facets',\n 'tags',\n 'concepts',\n 'relationships',\n 'provenance',\n 'privacy',\n 'updated_at',\n]\n\nconst VALID_TYPES = new Set<AiwgFortemiRecordType>([\n 'crm.contact',\n 'crm.organization',\n 'crm.event',\n 'crm.interaction',\n 'aiwg.artifact',\n 'docs.page',\n])\n\nconst DEFAULT_QUERY_WEIGHTS: AiwgIndexQueryWeights = {\n title: 4,\n tag: 3,\n concept: 2,\n text: 1,\n}\n\nfunction hasString(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0\n}\n\nfunction pushFacet(counts: Record<string, Record<string, number>>, name: string, value: string) {\n counts[name] ??= {}\n counts[name][value] = (counts[name][value] ?? 0) + 1\n}\n\nfunction hasNonNegativeInteger(value: unknown): value is number {\n return Number.isInteger(value) && typeof value === 'number' && value >= 0\n}\n\nfunction hasPositiveInteger(value: unknown): value is number {\n return Number.isInteger(value) && typeof value === 'number' && value > 0\n}\n\nfunction isFacetCounts(value: unknown): value is Record<string, Record<string, number>> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n return Object.values(value).every((counts) => (\n !!counts\n && typeof counts === 'object'\n && !Array.isArray(counts)\n && Object.values(counts).every((count) => hasNonNegativeInteger(count))\n ))\n}\n\nexport function validateAiwgFortemiIndexExport(value: unknown): AiwgIndexValidationResult {\n const errors: string[] = []\n const counts: Partial<Record<AiwgFortemiRecordType, number>> = {}\n const data = value as Partial<AiwgFortemiIndexExport>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.export.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.export.v1')\n }\n if (!hasString(data?.generated_at)) errors.push('generated_at is required')\n if (!hasString(data?.source?.repo)) errors.push('source.repo is required')\n if (!hasString(data?.source?.privacy)) errors.push('source.privacy is required')\n if (!Array.isArray(data?.items)) errors.push('items must be an array')\n\n const ids = new Set<string>()\n let previousId = ''\n for (const [index, item] of (data.items ?? []).entries()) {\n for (const field of REQUIRED_RECORD_FIELDS) {\n if (!(field in item)) errors.push('items[' + index + '].' + field + ' is required')\n }\n if (item.schema_version !== 'aiwg.fortemi.index.record.v1') {\n errors.push('items[' + index + '].schema_version must be aiwg.fortemi.index.record.v1')\n }\n if (!hasString(item.id)) errors.push('items[' + index + '].id is required')\n if (hasString(item.id) && ids.has(item.id)) errors.push('duplicate id: ' + item.id)\n if (hasString(item.id)) ids.add(item.id)\n if (previousId && hasString(item.id) && previousId.localeCompare(item.id) > 0) {\n errors.push('items must be sorted by id: ' + previousId + ' before ' + item.id)\n }\n if (hasString(item.id)) previousId = item.id\n if (!VALID_TYPES.has(item.type)) errors.push('items[' + index + '].type is invalid')\n else counts[item.type] = (counts[item.type] ?? 0) + 1\n if (!hasString(item.source?.path)) errors.push('items[' + index + '].source.path is required')\n if (!hasString(item.source?.repo_relative_path)) errors.push('items[' + index + '].source.repo_relative_path is required')\n if (!hasString(item.source?.locator)) errors.push('items[' + index + '].source.locator is required')\n if (!Array.isArray(item.tags)) errors.push('items[' + index + '].tags must be an array')\n if (!Array.isArray(item.concepts)) errors.push('items[' + index + '].concepts must be an array')\n if (!Array.isArray(item.relationships)) errors.push('items[' + index + '].relationships must be an array')\n if (!Array.isArray(item.provenance) || item.provenance.length === 0) {\n errors.push('items[' + index + '].provenance must be a non-empty array')\n }\n if (!item.privacy || typeof item.privacy.pii !== 'boolean' || !hasString(item.privacy.classification)) {\n errors.push('items[' + index + '].privacy requires classification and pii')\n }\n }\n\n return { valid: errors.length === 0, errors, counts }\n}\n\nexport function assertAiwgFortemiIndexExport(value: unknown): AiwgFortemiIndexExport {\n const result = validateAiwgFortemiIndexExport(value)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi index export:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiIndexExport\n}\n\nexport function validateAiwgFortemiChunkManifest(value: unknown): AiwgChunkedIndexValidationResult {\n const errors: string[] = []\n const data = value as Partial<AiwgFortemiChunkManifest>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.chunk-manifest.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.chunk-manifest.v1')\n }\n if (!hasString(data?.generated_at)) errors.push('generated_at is required')\n if (!hasString(data?.source?.repo)) errors.push('source.repo is required')\n if (!hasString(data?.source?.privacy)) errors.push('source.privacy is required')\n if (!hasNonNegativeInteger(data?.total)) errors.push('total must be a non-negative integer')\n if (!hasPositiveInteger(data?.part_size)) errors.push('part_size must be a positive integer')\n if (data.facets !== undefined && !isFacetCounts(data.facets)) {\n errors.push('facets must be a nested string-to-number count object')\n }\n if (!Array.isArray(data?.parts)) errors.push('parts must be an array')\n\n let expectedOffset = 0\n const parts = Array.isArray(data?.parts) ? data.parts : []\n for (const [index, part] of parts.entries()) {\n if (!hasString(part.href)) errors.push('parts[' + index + '].href is required')\n if (!hasNonNegativeInteger(part.offset)) errors.push('parts[' + index + '].offset must be a non-negative integer')\n if (!hasNonNegativeInteger(part.count)) errors.push('parts[' + index + '].count must be a non-negative integer')\n if (hasNonNegativeInteger(part.offset) && part.offset !== expectedOffset) {\n errors.push('parts[' + index + '].offset must be ' + expectedOffset)\n }\n if (hasNonNegativeInteger(part.count)) expectedOffset += part.count\n }\n if (hasNonNegativeInteger(data?.total) && expectedOffset !== data.total) {\n errors.push('parts counts must add up to total')\n }\n\n return { valid: errors.length === 0, errors }\n}\n\nexport function assertAiwgFortemiChunkManifest(value: unknown): AiwgFortemiChunkManifest {\n const result = validateAiwgFortemiChunkManifest(value)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi chunk manifest:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiChunkManifest\n}\n\nexport function validateAiwgFortemiChunkPart(\n value: unknown,\n partRef?: AiwgFortemiChunkPartRef,\n manifest?: AiwgFortemiChunkManifest,\n): AiwgChunkedIndexValidationResult {\n const errors: string[] = []\n const data = value as Partial<AiwgFortemiChunkPart>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.chunk.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.chunk.v1')\n }\n if (data?.manifest_schema_version !== 'aiwg.fortemi.index.chunk-manifest.v1') {\n errors.push('manifest_schema_version must be aiwg.fortemi.index.chunk-manifest.v1')\n }\n if (!hasNonNegativeInteger(data?.offset)) errors.push('offset must be a non-negative integer')\n if (!Array.isArray(data?.items)) errors.push('items must be an array')\n\n if (partRef && hasNonNegativeInteger(data?.offset) && data.offset !== partRef.offset) {\n errors.push('offset must match manifest part offset ' + partRef.offset)\n }\n if (partRef && Array.isArray(data?.items) && data.items.length !== partRef.count) {\n errors.push('items length must match manifest part count ' + partRef.count)\n }\n\n if (Array.isArray(data?.items)) {\n const validation = validateAiwgFortemiIndexExport({\n schema_version: 'aiwg.fortemi.index.export.v1',\n generated_at: manifest?.generated_at ?? '1970-01-01T00:00:00.000Z',\n source: manifest?.source ?? { repo: 'chunk', privacy: 'public' },\n items: data.items,\n })\n errors.push(...validation.errors.map((error) => 'items.' + error))\n }\n\n return { valid: errors.length === 0, errors }\n}\n\nexport function assertAiwgFortemiChunkPart(\n value: unknown,\n partRef?: AiwgFortemiChunkPartRef,\n manifest?: AiwgFortemiChunkManifest,\n): AiwgFortemiChunkPart {\n const result = validateAiwgFortemiChunkPart(value, partRef, manifest)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi chunk part:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiChunkPart\n}\n\nexport function createAiwgFetchChunkLoader(baseUrl?: string | URL): AiwgChunkedIndexLoader {\n return async (part) => {\n const href = baseUrl ? new URL(part.href, baseUrl).toString() : part.href\n const response = await fetch(href)\n if (!response.ok) throw new Error('Failed to fetch AIWG index chunk ' + href + ': ' + response.status)\n return response.json()\n }\n}\n\nexport function getAiwgFortemiFacets(items: AiwgFortemiRecord[]): Record<string, Record<string, number>> {\n const result: Record<string, Record<string, number>> = {}\n for (const item of items) {\n pushFacet(result, 'type', item.type)\n pushFacet(result, 'privacy', item.privacy.classification)\n for (const tag of item.tags) pushFacet(result, 'tag', tag)\n for (const concept of item.concepts) pushFacet(result, 'concept', concept)\n for (const [name, values] of Object.entries(item.facets)) {\n for (const value of values) pushFacet(result, name, value)\n }\n }\n return result\n}\n\nfunction includesAll(actual: string[], expected: string[] | undefined): boolean {\n if (!expected || expected.length === 0) return true\n const actualSet = new Set(actual)\n return expected.every((value) => actualSet.has(value))\n}\n\nfunction matchesFacetFilters(item: AiwgFortemiRecord, filters: Record<string, string[]> | undefined): boolean {\n if (!filters) return true\n return Object.entries(filters).every(([name, expected]) => includesAll(item.facets[name] ?? [], expected))\n}\n\nfunction queryMatches(item: AiwgFortemiRecord, q: string): AiwgIndexQueryMatch[] {\n if (!q) return []\n const matches: AiwgIndexQueryMatch[] = []\n if (item.title.toLowerCase().includes(q)) matches.push({ field: 'title', value: item.title })\n if (item.text.toLowerCase().includes(q)) matches.push({ field: 'text', value: item.text })\n for (const tag of item.tags) {\n if (tag.toLowerCase().includes(q)) matches.push({ field: 'tag', value: tag })\n }\n for (const concept of item.concepts) {\n if (concept.toLowerCase().includes(q)) matches.push({ field: 'concept', value: concept })\n }\n return matches\n}\n\nfunction rankMatches(matches: AiwgIndexQueryMatch[], weights: AiwgIndexQueryWeights): number {\n return matches.reduce((total, match) => total + weights[match.field], 0)\n}\n\nfunction clipSnippet(value: string, q: string, maxLength: number): string {\n const normalizedLength = Math.max(20, maxLength)\n if (!value) return ''\n if (!q) return value.length > normalizedLength ? `${value.slice(0, normalizedLength).trimEnd()}...` : value\n\n const lower = value.toLowerCase()\n const index = lower.indexOf(q)\n if (index < 0) return value.length > normalizedLength ? `${value.slice(0, normalizedLength).trimEnd()}...` : value\n\n const context = Math.max(0, Math.floor((normalizedLength - q.length) / 2))\n const start = Math.max(0, index - context)\n const end = Math.min(value.length, start + normalizedLength)\n const prefix = start > 0 ? '...' : ''\n const suffix = end < value.length ? '...' : ''\n return `${prefix}${value.slice(start, end).trim()}${suffix}`\n}\n\nfunction createSnippet(item: AiwgFortemiRecord, matches: AiwgIndexQueryMatch[], q: string, maxLength: number): string {\n const textMatch = matches.find((match) => match.field === 'text')\n const titleMatch = matches.find((match) => match.field === 'title')\n const firstMatch = textMatch ?? titleMatch ?? matches[0]\n return clipSnippet(firstMatch?.value ?? item.text, q, maxLength)\n}\n\ninterface AiwgRankedEntry {\n item: AiwgFortemiRecord\n ordinal: number\n rank: number\n matches: AiwgIndexQueryMatch[]\n}\n\nfunction createRankedEntries(\n items: AiwgFortemiRecord[],\n q: string,\n options: AiwgIndexQueryOptions,\n ordinalBase = 0,\n): AiwgRankedEntry[] {\n const weights = { ...DEFAULT_QUERY_WEIGHTS, ...options.weights }\n return items.map((item, ordinal) => ({ item, ordinal: ordinalBase + ordinal, matches: queryMatches(item, q) }))\n .filter(({ item, matches }) => {\n if (q && matches.length === 0) return false\n if (options.types && !options.types.includes(item.type)) return false\n if (options.privacy && !options.privacy.includes(item.privacy.classification)) return false\n if (!includesAll(item.tags, options.tags)) return false\n if (!includesAll(item.concepts, options.concepts)) return false\n if (!matchesFacetFilters(item, options.facets)) return false\n if (options.relationshipTargetId && !item.relationships.some((rel) => rel.target_id === options.relationshipTargetId)) {\n return false\n }\n return true\n })\n .map(({ item, ordinal, matches }) => ({\n item,\n ordinal,\n rank: rankMatches(matches, weights),\n matches,\n }))\n}\n\nfunction sortRankedEntries(entries: AiwgRankedEntry[], rank?: boolean): AiwgRankedEntry[] {\n return [...entries].sort((left, right) => {\n if (rank) return right.rank - left.rank || left.ordinal - right.ordinal\n return left.ordinal - right.ordinal\n })\n}\n\nfunction createQueryResultFromRankedEntries(\n entries: AiwgRankedEntry[],\n query: string,\n options: AiwgIndexQueryOptions,\n): AiwgIndexQueryResult {\n const ranked = sortRankedEntries(entries, options.rank)\n const offset = options.offset ?? 0\n const limit = options.limit ?? ranked.length\n const page = ranked.slice(offset, offset + limit)\n const result: AiwgIndexQueryResult = {\n items: page.map((entry) => entry.item),\n total: ranked.length,\n facets: getAiwgFortemiFacets(ranked.map((entry) => entry.item)),\n }\n if (options.rank || options.snippets || options.includeMatches) {\n const snippetLength = options.snippetLength ?? 160\n result.rankedItems = page.map((entry) => ({\n item: entry.item,\n rank: entry.rank,\n ...(options.snippets ? { snippet: createSnippet(entry.item, entry.matches, query, snippetLength) } : {}),\n ...(options.includeMatches ? { matches: entry.matches } : {}),\n }))\n }\n return result\n}\n\nexport function queryAiwgFortemiIndex(\n index: AiwgFortemiIndexExport,\n query = '',\n options: AiwgIndexQueryOptions = {},\n): AiwgIndexQueryResult {\n const q = query.trim().toLowerCase()\n return createQueryResultFromRankedEntries(createRankedEntries(index.items, q, options), q, options)\n}\n\ninterface AiwgChunkedIndexRuntime {\n manifest: AiwgFortemiChunkManifest\n loader: AiwgChunkedIndexLoader\n maxCachedParts: number\n partCache: Map<string, AiwgFortemiChunkPart>\n}\n\nfunction chunkPartCacheKey(part: AiwgFortemiChunkPartRef): string {\n return `${part.offset}:${part.href}`\n}\n\nfunction clampMaxCachedParts(value: number | undefined): number {\n if (!hasPositiveInteger(value)) return 3\n return value\n}\n\nfunction isDirectChunkBrowse(query: string, options: AiwgIndexQueryOptions): boolean {\n return query.trim() === ''\n && !options.rank\n && !options.snippets\n && !options.includeMatches\n && !options.types\n && !options.facets\n && !options.tags\n && !options.concepts\n && !options.privacy\n && !options.relationshipTargetId\n}\n\nfunction getPartsForRange(\n manifest: AiwgFortemiChunkManifest,\n offset: number,\n limit: number,\n): AiwgFortemiChunkPartRef[] {\n const end = offset + limit\n return manifest.parts.filter((part) => part.count > 0 && part.offset < end && part.offset + part.count > offset)\n}\n\nasync function loadChunkPart(\n runtime: AiwgChunkedIndexRuntime,\n part: AiwgFortemiChunkPartRef,\n): Promise<{ part: AiwgFortemiChunkPart; fetched: boolean }> {\n const key = chunkPartCacheKey(part)\n const cached = runtime.partCache.get(key)\n if (cached) {\n runtime.partCache.delete(key)\n runtime.partCache.set(key, cached)\n return { part: cached, fetched: false }\n }\n\n const parsed = assertAiwgFortemiChunkPart(await runtime.loader(part, runtime.manifest), part, runtime.manifest)\n runtime.partCache.set(key, parsed)\n while (runtime.partCache.size > runtime.maxCachedParts) {\n const oldest = runtime.partCache.keys().next().value\n if (oldest === undefined) break\n runtime.partCache.delete(oldest)\n }\n return { part: parsed, fetched: true }\n}\n\nasync function queryChunkedAiwgFortemiIndex(\n runtime: AiwgChunkedIndexRuntime,\n query = '',\n options: AiwgChunkedIndexQueryOptions = {},\n): Promise<AiwgChunkedIndexQueryResult> {\n const q = query.trim().toLowerCase()\n let scannedParts = 0\n let fetchedParts = 0\n\n if (isDirectChunkBrowse(query, options)) {\n const offset = options.offset ?? 0\n const limit = options.limit ?? runtime.manifest.total\n const parts = getPartsForRange(runtime.manifest, offset, limit)\n const items: AiwgFortemiRecord[] = []\n for (const partRef of parts) {\n const loaded = await loadChunkPart(runtime, partRef)\n if (loaded.fetched) fetchedParts += 1\n scannedParts += 1\n options.onProgress?.({ phase: 'part', done: scannedParts, total: parts.length, href: partRef.href })\n const start = Math.max(0, offset - partRef.offset)\n const end = Math.min(loaded.part.items.length, offset + limit - partRef.offset)\n items.push(...loaded.part.items.slice(start, end))\n }\n return {\n items,\n total: runtime.manifest.total,\n facets: runtime.manifest.facets ?? {},\n manifestTotal: runtime.manifest.total,\n scannedParts,\n fetchedParts,\n complete: true,\n }\n }\n\n const entries: AiwgRankedEntry[] = []\n for (const partRef of runtime.manifest.parts) {\n const loaded = await loadChunkPart(runtime, partRef)\n if (loaded.fetched) fetchedParts += 1\n scannedParts += 1\n options.onProgress?.({ phase: 'part', done: scannedParts, total: runtime.manifest.parts.length, href: partRef.href })\n entries.push(...createRankedEntries(loaded.part.items, q, options, partRef.offset))\n options.onProgress?.({ phase: 'query', done: scannedParts, total: runtime.manifest.parts.length, href: partRef.href })\n }\n\n return {\n ...createQueryResultFromRankedEntries(entries, q, options),\n manifestTotal: runtime.manifest.total,\n scannedParts,\n fetchedParts,\n complete: true,\n }\n}\n\nexport function createAiwgReviewDecisionExport(\n source: AiwgFortemiIndexExport,\n decisions: AiwgReviewDecision[],\n generatedAt = new Date().toISOString(),\n): AiwgReviewDecisionExport {\n return {\n schema_version: 'aiwg.fortemi.review-decisions.v1',\n generated_at: generatedAt,\n source_export_schema_version: source.schema_version,\n decisions: [...decisions].sort((left, right) => left.item_id.localeCompare(right.item_id)),\n }\n}\n\nexport function createAiwgIndexController(initialIndex?: AiwgFortemiIndexExport): AiwgIndexController {\n let index: AiwgFortemiIndexExport | null = initialIndex ?? null\n let chunked: AiwgChunkedIndexRuntime | null = null\n let data: AiwgIndexQueryResult | null = null\n let error: Error | null = null\n let reviewDecisions: AiwgReviewDecision[] = []\n const listeners = new Set<AiwgIndexControllerListener>()\n\n const snapshot = (): AiwgIndexControllerSnapshot => ({\n index,\n chunked: chunked\n ? {\n manifest: chunked.manifest,\n cachedParts: chunked.partCache.size,\n maxCachedParts: chunked.maxCachedParts,\n }\n : null,\n data,\n error,\n reviewDecisions: [...reviewDecisions],\n })\n const notify = () => {\n const current = snapshot()\n for (const listener of listeners) listener(current)\n }\n const requireIndex = (): AiwgFortemiIndexExport => {\n if (!index) throw new Error('No AIWG index export loaded')\n return index\n }\n\n return {\n loadIndex(value: unknown): AiwgFortemiIndexExport {\n try {\n const parsed = assertAiwgFortemiIndexExport(value)\n index = parsed\n chunked = null\n data = null\n reviewDecisions = []\n error = null\n notify()\n return parsed\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n loadChunkedIndex(\n manifest: unknown,\n loader: AiwgChunkedIndexLoader,\n options: AiwgChunkedIndexLoadOptions = {},\n ): AiwgFortemiChunkManifest {\n try {\n const parsed = assertAiwgFortemiChunkManifest(manifest)\n index = null\n chunked = {\n manifest: parsed,\n loader,\n maxCachedParts: clampMaxCachedParts(options.maxCachedParts),\n partCache: new Map(),\n }\n data = null\n reviewDecisions = []\n error = null\n notify()\n return parsed\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n getIndex(): AiwgFortemiIndexExport | null {\n return index\n },\n getChunkedManifest(): AiwgFortemiChunkManifest | null {\n return chunked?.manifest ?? null\n },\n getSnapshot(): AiwgIndexControllerSnapshot {\n return snapshot()\n },\n query(query = '', options?: AiwgIndexQueryOptions): AiwgIndexQueryResult {\n const result = queryAiwgFortemiIndex(requireIndex(), query, options)\n data = result\n error = null\n notify()\n return result\n },\n async queryChunked(query = '', options?: AiwgChunkedIndexQueryOptions): Promise<AiwgChunkedIndexQueryResult> {\n if (!chunked) throw new Error('No AIWG chunked index manifest loaded')\n try {\n const result = await queryChunkedAiwgFortemiIndex(chunked, query, options)\n data = result\n error = null\n notify()\n return result\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n clearChunkCache(): void {\n chunked?.partCache.clear()\n error = null\n notify()\n },\n toCommunityGraph(options?: AiwgIndexGraphOptions) {\n return aiwgFortemiIndexToCommunityGraph(requireIndex(), options)\n },\n setReviewDecision(input: AiwgReviewInput): AiwgReviewDecision {\n const decision: AiwgReviewDecision = {\n ...input,\n updated_at: new Date().toISOString(),\n }\n reviewDecisions = [\n ...reviewDecisions.filter((item) => item.item_id !== decision.item_id),\n decision,\n ].sort((left, right) => left.item_id.localeCompare(right.item_id))\n error = null\n notify()\n return decision\n },\n clearReviewDecision(itemId: string): void {\n reviewDecisions = reviewDecisions.filter((item) => item.item_id !== itemId)\n error = null\n notify()\n },\n createReviewDecisionExport(generatedAt?: string): AiwgReviewDecisionExport {\n return createAiwgReviewDecisionExport(requireIndex(), reviewDecisions, generatedAt)\n },\n subscribe(listener: AiwgIndexControllerListener): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n\nexport function aiwgFortemiIndexToCommunityGraph(\n index: AiwgFortemiIndexExport,\n options: AiwgIndexGraphOptions = {},\n) {\n const ids = new Set(index.items.map((item) => item.id))\n const relationshipWeights = options.relationshipWeights ?? {}\n const edgeCounts = new Map<string, { source: string; target: string; kind: string; weight: number }>()\n\n for (const item of index.items) {\n for (const relationship of item.relationships) {\n if (!ids.has(relationship.target_id) && !options.includeDanglingRelationships) continue\n const kind = relationship.type\n const baseWeight = relationshipWeights[kind] ?? 1\n const key = `${item.id}\\u0000${relationship.target_id}\\u0000${kind}`\n const existing = edgeCounts.get(key)\n if (existing) existing.weight += baseWeight\n else edgeCounts.set(key, { source: item.id, target: relationship.target_id, kind, weight: baseWeight })\n }\n }\n\n const communities = new Map<string, string[]>()\n for (const item of index.items) {\n const communityIds = communityIdsFor(item, options)\n for (const communityId of communityIds) {\n const nodes = communities.get(communityId) ?? []\n nodes.push(item.id)\n communities.set(communityId, nodes)\n }\n }\n\n return {\n nodes: index.items.map((item) => ({ id: item.id })),\n edges: Array.from(edgeCounts.values()).sort((left, right) => (\n left.source.localeCompare(right.source)\n || left.target.localeCompare(right.target)\n || left.kind.localeCompare(right.kind)\n )),\n communities: Array.from(communities.entries())\n .map(([id, nodes]) => ({ id, nodes: [...new Set(nodes)].sort() }))\n .sort((left, right) => left.id.localeCompare(right.id)),\n }\n}\n\nfunction communityIdsFor(item: AiwgFortemiRecord, options: AiwgIndexGraphOptions): string[] {\n if (options.communityFacet) {\n const values = item.facets[options.communityFacet] ?? []\n if (values.length > 0) return values.map((value) => `${options.communityFacet}:${value}`)\n }\n if (options.communityTagPrefix) {\n const prefix = options.communityTagPrefix\n const tags = item.tags.filter((tag) => tag.startsWith(prefix))\n if (tags.length > 0) return tags\n }\n if (item.concepts.length > 0) return item.concepts.map((concept) => `concept:${concept}`)\n return [`type:${item.type}`]\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/aiwg-index.ts"],"names":[],"mappings":";AAsEO,IAAM,yBAAA,GAA4D;AAAA,EACvE,gBAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAoMA,IAAM,sBAAA,GAAyD;AAAA,EAC7D,gBAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,WAAA,uBAAkB,GAAA,CAA2B;AAAA,EACjD,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,WAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,qBAAA,GAA+C;AAAA,EACnD,KAAA,EAAO,CAAA;AAAA,EACP,GAAA,EAAK,CAAA;AAAA,EACL,OAAA,EAAS,CAAA;AAAA,EACT,IAAA,EAAM;AACR,CAAA;AAEA,SAAS,UAAU,KAAA,EAAiC;AAClD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,GAAS,CAAA;AACrD;AAEA,SAAS,SAAA,CAAU,MAAA,EAAgD,IAAA,EAAc,KAAA,EAA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AAc,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAA;AAAA,EAC1F;AACA,EAAA,IAAI,QAAQ,kBAAA,EAAoB;AAC9B,IAAA,MAAM,SAAS,OAAA,CAAQ,kBAAA;AACvB,IAAA,MAAM,IAAA,GAAO,KAAK,IAAA,CAAK,MAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,CAAI,UAAA,CAAW,MAAM,CAAC,CAAA;AAC7D,IAAA,IAAI,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG,OAAO,IAAA;AAAA,EAC9B;AACA,EAAA,IAAI,IAAA,CAAK,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AACxF,EAAA,OAAO,CAAC,CAAA,KAAA,EAAQ,IAAA,CAAK,IAAI,CAAA,CAAE,CAAA;AAC7B","file":"aiwg-index.js","sourcesContent":["export type AiwgFortemiRecordType =\n | 'crm.contact'\n | 'crm.organization'\n | 'crm.event'\n | 'crm.interaction'\n | 'aiwg.artifact'\n | 'docs.page'\n\nexport type AiwgPrivacyClassification = 'private' | 'sanitized' | 'public'\nexport type AiwgProvenanceConfidence = 'source' | 'candidate' | 'reviewed' | 'rejected'\nexport type AiwgReviewAction = 'accept' | 'reject' | 'defer'\n\nexport interface AiwgFortemiRecordSource {\n path: string\n repo_relative_path: string\n locator: string\n}\n\nexport interface AiwgFortemiRelationship {\n type: string\n target_id: string\n source_path?: string\n}\n\nexport interface AiwgFortemiProvenance {\n field: string\n source: string\n path: string\n confidence: AiwgProvenanceConfidence\n privacy: AiwgPrivacyClassification\n}\n\nexport interface AiwgFortemiRecord {\n schema_version: 'aiwg.fortemi.index.record.v1'\n id: string\n type: AiwgFortemiRecordType\n source: AiwgFortemiRecordSource\n title: string\n text: string\n facets: Record<string, string[]>\n tags: string[]\n concepts: string[]\n relationships: AiwgFortemiRelationship[]\n provenance: AiwgFortemiProvenance[]\n privacy: {\n classification: AiwgPrivacyClassification\n pii: boolean\n }\n updated_at: string\n}\n\nexport interface AiwgFortemiIndexExport {\n schema_version: 'aiwg.fortemi.index.export.v1'\n generated_at: string\n source: {\n repo: string\n privacy: AiwgPrivacyClassification\n }\n items: AiwgFortemiRecord[]\n}\n\nexport interface AiwgFortemiChunkPartRef {\n href: string\n offset: number\n count: number\n}\n\n// Fields a scan part must retain for query/browse/rank/facet to work. The rest\n// (source, provenance, relationships, updated_at) are detail-only and may be\n// dropped from scan parts via `projection`, then resolved on demand by id.\nexport const AIWG_SCAN_REQUIRED_FIELDS: Array<keyof AiwgFortemiRecord> = [\n 'schema_version',\n 'id',\n 'type',\n 'title',\n 'text',\n 'facets',\n 'tags',\n 'concepts',\n 'privacy',\n]\n\n// A record as it appears in a scan part. With no manifest `projection`, this is a\n// full AiwgFortemiRecord. With a projection, detail-only fields are absent — read\n// them via the controller's getRecord(). Typed as the full record for ergonomics;\n// query/browse code guards the projectable fields.\nexport type AiwgFortemiProjectedRecord =\n Pick<AiwgFortemiRecord, 'schema_version' | 'id' | 'type' | 'title' | 'text' | 'facets' | 'tags' | 'concepts' | 'privacy'>\n & Partial<AiwgFortemiRecord>\n\n// How the controller resolves a full record by id when scan parts are projected.\nexport interface AiwgFortemiChunkDetailRef {\n // href template containing `{id}` (URL-encoded at substitution), relative to the\n // manifest base — e.g. \"detail/{id}.json\".\n href: string\n}\n\nexport interface AiwgFortemiChunkManifest {\n schema_version: 'aiwg.fortemi.index.chunk-manifest.v1'\n generated_at: string\n source: AiwgFortemiIndexExport['source']\n total: number\n part_size: number\n facets?: Record<string, Record<string, number>>\n // Field names present in scan-part items. Absent → scan parts carry whole records.\n // When set, must include AIWG_SCAN_REQUIRED_FIELDS.\n projection?: Array<keyof AiwgFortemiRecord>\n // Resolver for full records by id (used with `projection` to lazy-load detail).\n detail?: AiwgFortemiChunkDetailRef\n parts: AiwgFortemiChunkPartRef[]\n}\n\nexport interface AiwgFortemiChunkPart {\n schema_version: 'aiwg.fortemi.index.chunk.v1'\n manifest_schema_version: 'aiwg.fortemi.index.chunk-manifest.v1'\n offset: number\n items: AiwgFortemiRecord[]\n}\n\nexport interface AiwgIndexValidationResult {\n valid: boolean\n errors: string[]\n counts: Partial<Record<AiwgFortemiRecordType, number>>\n}\n\nexport interface AiwgChunkedIndexValidationResult {\n valid: boolean\n errors: string[]\n}\n\nexport interface AiwgIndexQueryOptions {\n types?: AiwgFortemiRecordType[]\n facets?: Record<string, string[]>\n tags?: string[]\n concepts?: string[]\n privacy?: AiwgPrivacyClassification[]\n relationshipTargetId?: string\n limit?: number\n offset?: number\n rank?: boolean\n snippets?: boolean\n snippetLength?: number\n weights?: Partial<AiwgIndexQueryWeights>\n includeMatches?: boolean\n}\n\nexport interface AiwgIndexQueryWeights {\n title: number\n text: number\n tag: number\n concept: number\n}\n\nexport interface AiwgIndexQueryMatch {\n field: 'title' | 'text' | 'tag' | 'concept'\n value: string\n}\n\nexport interface AiwgIndexQueryRankedItem {\n item: AiwgFortemiRecord\n rank: number\n snippet?: string\n matches?: AiwgIndexQueryMatch[]\n}\n\nexport interface AiwgIndexQueryResult {\n items: AiwgFortemiRecord[]\n total: number\n facets: Record<string, Record<string, number>>\n rankedItems?: AiwgIndexQueryRankedItem[]\n}\n\nexport type AiwgChunkedIndexLoader = (\n part: AiwgFortemiChunkPartRef,\n manifest: AiwgFortemiChunkManifest,\n) => Promise<unknown>\n\n// Resolves a full record by id (used with projected scan parts). Returns the\n// parsed record JSON; validated by the controller before use.\nexport type AiwgChunkedIndexDetailLoader = (\n id: string,\n manifest: AiwgFortemiChunkManifest,\n) => Promise<unknown>\n\nexport interface AiwgChunkedIndexLoadOptions {\n maxCachedParts?: number\n // Required to resolve detail for projected indexes via getRecord(); ignored otherwise.\n detailLoader?: AiwgChunkedIndexDetailLoader\n maxCachedDetails?: number\n}\n\nexport type AiwgChunkedIndexProgressPhase = 'part' | 'query'\n\nexport interface AiwgChunkedIndexProgress {\n phase: AiwgChunkedIndexProgressPhase\n done: number\n total: number\n href?: string\n}\n\nexport interface AiwgChunkedIndexQueryOptions extends AiwgIndexQueryOptions {\n onProgress?: (progress: AiwgChunkedIndexProgress) => void\n}\n\nexport interface AiwgChunkedIndexQueryResult extends AiwgIndexQueryResult {\n manifestTotal: number\n scannedParts: number\n fetchedParts: number\n complete: boolean\n}\n\nexport interface AiwgReviewDecision {\n item_id: string\n action: AiwgReviewAction\n reason?: string\n updated_at: string\n}\n\nexport interface AiwgReviewDecisionExport {\n schema_version: 'aiwg.fortemi.review-decisions.v1'\n generated_at: string\n source_export_schema_version: string\n decisions: AiwgReviewDecision[]\n}\n\nexport interface AiwgIndexGraphOptions {\n communityFacet?: string\n communityTagPrefix?: string\n relationshipWeights?: Record<string, number>\n includeDanglingRelationships?: boolean\n}\n\nexport interface AiwgReviewInput {\n item_id: string\n action: AiwgReviewAction\n reason?: string\n}\n\nexport interface AiwgIndexControllerSnapshot {\n index: AiwgFortemiIndexExport | null\n chunked: {\n manifest: AiwgFortemiChunkManifest\n cachedParts: number\n maxCachedParts: number\n } | null\n data: AiwgIndexQueryResult | null\n error: Error | null\n reviewDecisions: AiwgReviewDecision[]\n}\n\nexport type AiwgIndexControllerListener = (snapshot: AiwgIndexControllerSnapshot) => void\n\nexport interface AiwgIndexController {\n loadIndex(value: unknown): AiwgFortemiIndexExport\n loadChunkedIndex(\n manifest: unknown,\n loader: AiwgChunkedIndexLoader,\n options?: AiwgChunkedIndexLoadOptions,\n ): AiwgFortemiChunkManifest\n getIndex(): AiwgFortemiIndexExport | null\n getChunkedManifest(): AiwgFortemiChunkManifest | null\n getSnapshot(): AiwgIndexControllerSnapshot\n query(query?: string, options?: AiwgIndexQueryOptions): AiwgIndexQueryResult\n queryChunked(query?: string, options?: AiwgChunkedIndexQueryOptions): Promise<AiwgChunkedIndexQueryResult>\n // Resolve a full record by id. For a projected chunked index, fetches detail via\n // the detailLoader (bounded cache); for a whole-record index/parts, returns the\n // record from loaded data. Rejects if detail is unavailable.\n getRecord(id: string): Promise<AiwgFortemiRecord>\n clearChunkCache(): void\n toCommunityGraph(options?: AiwgIndexGraphOptions): ReturnType<typeof aiwgFortemiIndexToCommunityGraph>\n setReviewDecision(input: AiwgReviewInput): AiwgReviewDecision\n clearReviewDecision(itemId: string): void\n createReviewDecisionExport(generatedAt?: string): AiwgReviewDecisionExport\n subscribe(listener: AiwgIndexControllerListener): () => void\n}\n\nconst REQUIRED_RECORD_FIELDS: Array<keyof AiwgFortemiRecord> = [\n 'schema_version',\n 'id',\n 'type',\n 'source',\n 'title',\n 'text',\n 'facets',\n 'tags',\n 'concepts',\n 'relationships',\n 'provenance',\n 'privacy',\n 'updated_at',\n]\n\nconst VALID_TYPES = new Set<AiwgFortemiRecordType>([\n 'crm.contact',\n 'crm.organization',\n 'crm.event',\n 'crm.interaction',\n 'aiwg.artifact',\n 'docs.page',\n])\n\nconst DEFAULT_QUERY_WEIGHTS: AiwgIndexQueryWeights = {\n title: 4,\n tag: 3,\n concept: 2,\n text: 1,\n}\n\nfunction hasString(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0\n}\n\nfunction pushFacet(counts: Record<string, Record<string, number>>, name: string, value: string) {\n counts[name] ??= {}\n counts[name][value] = (counts[name][value] ?? 0) + 1\n}\n\nfunction hasNonNegativeInteger(value: unknown): value is number {\n return Number.isInteger(value) && typeof value === 'number' && value >= 0\n}\n\nfunction hasPositiveInteger(value: unknown): value is number {\n return Number.isInteger(value) && typeof value === 'number' && value > 0\n}\n\nfunction isFacetCounts(value: unknown): value is Record<string, Record<string, number>> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n return Object.values(value).every((counts) => (\n !!counts\n && typeof counts === 'object'\n && !Array.isArray(counts)\n && Object.values(counts).every((count) => hasNonNegativeInteger(count))\n ))\n}\n\nexport function validateAiwgFortemiIndexExport(value: unknown): AiwgIndexValidationResult {\n const errors: string[] = []\n const counts: Partial<Record<AiwgFortemiRecordType, number>> = {}\n const data = value as Partial<AiwgFortemiIndexExport>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.export.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.export.v1')\n }\n if (!hasString(data?.generated_at)) errors.push('generated_at is required')\n if (!hasString(data?.source?.repo)) errors.push('source.repo is required')\n if (!hasString(data?.source?.privacy)) errors.push('source.privacy is required')\n if (!Array.isArray(data?.items)) errors.push('items must be an array')\n\n const ids = new Set<string>()\n let previousId = ''\n for (const [index, item] of (data.items ?? []).entries()) {\n for (const field of REQUIRED_RECORD_FIELDS) {\n if (!(field in item)) errors.push('items[' + index + '].' + field + ' is required')\n }\n if (item.schema_version !== 'aiwg.fortemi.index.record.v1') {\n errors.push('items[' + index + '].schema_version must be aiwg.fortemi.index.record.v1')\n }\n if (!hasString(item.id)) errors.push('items[' + index + '].id is required')\n if (hasString(item.id) && ids.has(item.id)) errors.push('duplicate id: ' + item.id)\n if (hasString(item.id)) ids.add(item.id)\n if (previousId && hasString(item.id) && previousId.localeCompare(item.id) > 0) {\n errors.push('items must be sorted by id: ' + previousId + ' before ' + item.id)\n }\n if (hasString(item.id)) previousId = item.id\n if (!VALID_TYPES.has(item.type)) errors.push('items[' + index + '].type is invalid')\n else counts[item.type] = (counts[item.type] ?? 0) + 1\n if (!hasString(item.source?.path)) errors.push('items[' + index + '].source.path is required')\n if (!hasString(item.source?.repo_relative_path)) errors.push('items[' + index + '].source.repo_relative_path is required')\n if (!hasString(item.source?.locator)) errors.push('items[' + index + '].source.locator is required')\n if (!Array.isArray(item.tags)) errors.push('items[' + index + '].tags must be an array')\n if (!Array.isArray(item.concepts)) errors.push('items[' + index + '].concepts must be an array')\n if (!Array.isArray(item.relationships)) errors.push('items[' + index + '].relationships must be an array')\n if (!Array.isArray(item.provenance) || item.provenance.length === 0) {\n errors.push('items[' + index + '].provenance must be a non-empty array')\n }\n if (!item.privacy || typeof item.privacy.pii !== 'boolean' || !hasString(item.privacy.classification)) {\n errors.push('items[' + index + '].privacy requires classification and pii')\n }\n }\n\n return { valid: errors.length === 0, errors, counts }\n}\n\nexport function assertAiwgFortemiIndexExport(value: unknown): AiwgFortemiIndexExport {\n const result = validateAiwgFortemiIndexExport(value)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi index export:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiIndexExport\n}\n\nexport function validateAiwgFortemiChunkManifest(value: unknown): AiwgChunkedIndexValidationResult {\n const errors: string[] = []\n const data = value as Partial<AiwgFortemiChunkManifest>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.chunk-manifest.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.chunk-manifest.v1')\n }\n if (!hasString(data?.generated_at)) errors.push('generated_at is required')\n if (!hasString(data?.source?.repo)) errors.push('source.repo is required')\n if (!hasString(data?.source?.privacy)) errors.push('source.privacy is required')\n if (!hasNonNegativeInteger(data?.total)) errors.push('total must be a non-negative integer')\n if (!hasPositiveInteger(data?.part_size)) errors.push('part_size must be a positive integer')\n if (data.facets !== undefined && !isFacetCounts(data.facets)) {\n errors.push('facets must be a nested string-to-number count object')\n }\n if (data.projection !== undefined) {\n if (!Array.isArray(data.projection) || !data.projection.every((field) => typeof field === 'string')) {\n errors.push('projection must be an array of field names')\n } else {\n const present = new Set(data.projection)\n for (const field of AIWG_SCAN_REQUIRED_FIELDS) {\n if (!present.has(field)) errors.push('projection must include scan-required field ' + field)\n }\n }\n }\n if (data.detail !== undefined) {\n if (!hasString(data.detail.href)) errors.push('detail.href is required')\n else if (!data.detail.href.includes('{id}')) errors.push('detail.href must contain the {id} placeholder')\n }\n if (!Array.isArray(data?.parts)) errors.push('parts must be an array')\n\n let expectedOffset = 0\n const parts = Array.isArray(data?.parts) ? data.parts : []\n for (const [index, part] of parts.entries()) {\n if (!hasString(part.href)) errors.push('parts[' + index + '].href is required')\n if (!hasNonNegativeInteger(part.offset)) errors.push('parts[' + index + '].offset must be a non-negative integer')\n if (!hasNonNegativeInteger(part.count)) errors.push('parts[' + index + '].count must be a non-negative integer')\n if (hasNonNegativeInteger(part.offset) && part.offset !== expectedOffset) {\n errors.push('parts[' + index + '].offset must be ' + expectedOffset)\n }\n if (hasNonNegativeInteger(part.count)) expectedOffset += part.count\n }\n if (hasNonNegativeInteger(data?.total) && expectedOffset !== data.total) {\n errors.push('parts counts must add up to total')\n }\n\n return { valid: errors.length === 0, errors }\n}\n\nexport function assertAiwgFortemiChunkManifest(value: unknown): AiwgFortemiChunkManifest {\n const result = validateAiwgFortemiChunkManifest(value)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi chunk manifest:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiChunkManifest\n}\n\n// Validate projected (slim) scan-part items: scan-required fields only, ids unique + sorted.\nfunction validateProjectedRecords(items: Array<Partial<AiwgFortemiRecord>>): string[] {\n const errors: string[] = []\n const ids = new Set<string>()\n let previousId = ''\n for (const [index, item] of items.entries()) {\n if (item.schema_version !== 'aiwg.fortemi.index.record.v1') {\n errors.push('items[' + index + '].schema_version must be aiwg.fortemi.index.record.v1')\n }\n if (!hasString(item.id)) errors.push('items[' + index + '].id is required')\n if (hasString(item.id) && ids.has(item.id)) errors.push('duplicate id: ' + item.id)\n if (hasString(item.id)) ids.add(item.id)\n if (previousId && hasString(item.id) && previousId.localeCompare(item.id) > 0) {\n errors.push('items must be sorted by id: ' + previousId + ' before ' + item.id)\n }\n if (hasString(item.id)) previousId = item.id\n if (!item.type || !VALID_TYPES.has(item.type)) errors.push('items[' + index + '].type is invalid')\n if (!hasString(item.title)) errors.push('items[' + index + '].title is required')\n if (typeof item.text !== 'string') errors.push('items[' + index + '].text is required')\n if (!item.facets || typeof item.facets !== 'object' || Array.isArray(item.facets)) {\n errors.push('items[' + index + '].facets must be an object')\n }\n if (!Array.isArray(item.tags)) errors.push('items[' + index + '].tags must be an array')\n if (!Array.isArray(item.concepts)) errors.push('items[' + index + '].concepts must be an array')\n if (!item.privacy || !hasString(item.privacy.classification)) {\n errors.push('items[' + index + '].privacy.classification is required')\n }\n }\n return errors\n}\n\nexport function validateAiwgFortemiChunkPart(\n value: unknown,\n partRef?: AiwgFortemiChunkPartRef,\n manifest?: AiwgFortemiChunkManifest,\n): AiwgChunkedIndexValidationResult {\n const errors: string[] = []\n const data = value as Partial<AiwgFortemiChunkPart>\n\n if (data?.schema_version !== 'aiwg.fortemi.index.chunk.v1') {\n errors.push('schema_version must be aiwg.fortemi.index.chunk.v1')\n }\n if (data?.manifest_schema_version !== 'aiwg.fortemi.index.chunk-manifest.v1') {\n errors.push('manifest_schema_version must be aiwg.fortemi.index.chunk-manifest.v1')\n }\n if (!hasNonNegativeInteger(data?.offset)) errors.push('offset must be a non-negative integer')\n if (!Array.isArray(data?.items)) errors.push('items must be an array')\n\n if (partRef && hasNonNegativeInteger(data?.offset) && data.offset !== partRef.offset) {\n errors.push('offset must match manifest part offset ' + partRef.offset)\n }\n if (partRef && Array.isArray(data?.items) && data.items.length !== partRef.count) {\n errors.push('items length must match manifest part count ' + partRef.count)\n }\n\n if (Array.isArray(data?.items)) {\n if (manifest?.projection) {\n errors.push(...validateProjectedRecords(data.items).map((error) => 'items.' + error))\n } else {\n const validation = validateAiwgFortemiIndexExport({\n schema_version: 'aiwg.fortemi.index.export.v1',\n generated_at: manifest?.generated_at ?? '1970-01-01T00:00:00.000Z',\n source: manifest?.source ?? { repo: 'chunk', privacy: 'public' },\n items: data.items,\n })\n errors.push(...validation.errors.map((error) => 'items.' + error))\n }\n }\n\n return { valid: errors.length === 0, errors }\n}\n\nexport function assertAiwgFortemiChunkPart(\n value: unknown,\n partRef?: AiwgFortemiChunkPartRef,\n manifest?: AiwgFortemiChunkManifest,\n): AiwgFortemiChunkPart {\n const result = validateAiwgFortemiChunkPart(value, partRef, manifest)\n if (!result.valid) {\n throw new Error('Invalid AIWG Fortemi chunk part:\\n' + result.errors.join('\\n'))\n }\n return value as AiwgFortemiChunkPart\n}\n\nexport function createAiwgFetchChunkLoader(baseUrl?: string | URL): AiwgChunkedIndexLoader {\n return async (part) => {\n const href = baseUrl ? new URL(part.href, baseUrl).toString() : part.href\n const response = await fetch(href)\n if (!response.ok) throw new Error('Failed to fetch AIWG index chunk ' + href + ': ' + response.status)\n return response.json()\n }\n}\n\n// Detail loader for projected indexes: resolves the manifest's detail.href {id}\n// template (id URL-encoded) against baseUrl and fetches the full record.\nexport function createAiwgFetchDetailLoader(baseUrl?: string | URL): AiwgChunkedIndexDetailLoader {\n return async (id, manifest) => {\n if (!manifest.detail?.href) throw new Error('Manifest has no detail.href for record resolution')\n const relative = manifest.detail.href.replace('{id}', encodeURIComponent(id))\n const href = baseUrl ? new URL(relative, baseUrl).toString() : relative\n const response = await fetch(href)\n if (!response.ok) throw new Error('Failed to fetch AIWG index detail ' + href + ': ' + response.status)\n return response.json()\n }\n}\n\nexport function getAiwgFortemiFacets(items: AiwgFortemiRecord[]): Record<string, Record<string, number>> {\n const result: Record<string, Record<string, number>> = {}\n for (const item of items) {\n pushFacet(result, 'type', item.type)\n pushFacet(result, 'privacy', item.privacy.classification)\n for (const tag of item.tags) pushFacet(result, 'tag', tag)\n for (const concept of item.concepts) pushFacet(result, 'concept', concept)\n for (const [name, values] of Object.entries(item.facets)) {\n for (const value of values) pushFacet(result, name, value)\n }\n }\n return result\n}\n\nexport interface AiwgChunkedIndexBuildOptions {\n partSize?: number\n // When set, scan parts carry only these fields; full records go to `details`.\n projection?: Array<keyof AiwgFortemiRecord>\n // Detail href template (with {id}); defaults to \"detail/{id}.json\" when projecting.\n detailHref?: string\n generatedAt?: string\n}\n\nexport interface AiwgChunkedIndexBuildResult {\n manifest: AiwgFortemiChunkManifest\n parts: Array<{ href: string; part: AiwgFortemiChunkPart }>\n // Empty unless projecting. Each entry is a full record to host at the detail href.\n details: Array<{ id: string; record: AiwgFortemiRecord }>\n}\n\n// Pure builder (no I/O): project an index export into the chunked manifest + parts\n// (+ detail records when projecting). The caller writes the returned objects to disk.\n// Manifest facets are computed from the full records, so global counts are exact even\n// when scan parts are slim.\nexport function buildAiwgChunkedIndex(\n index: AiwgFortemiIndexExport,\n options: AiwgChunkedIndexBuildOptions = {},\n): AiwgChunkedIndexBuildResult {\n const partSize = hasPositiveInteger(options.partSize) ? options.partSize : 500\n const projection = options.projection\n const items = index.items\n const pad = (value: number): string => String(value).padStart(4, '0')\n const project = (record: AiwgFortemiRecord): AiwgFortemiRecord => {\n if (!projection) return record\n const slim: Record<string, unknown> = {}\n for (const field of projection) slim[field] = record[field]\n return slim as unknown as AiwgFortemiRecord\n }\n\n const parts: Array<{ href: string; part: AiwgFortemiChunkPart }> = []\n const partRefs: AiwgFortemiChunkPartRef[] = []\n for (let offset = 0, partIndex = 0; offset < items.length; offset += partSize, partIndex += 1) {\n const slice = items.slice(offset, offset + partSize)\n const href = 'part-' + pad(partIndex) + '.json'\n parts.push({\n href,\n part: {\n schema_version: 'aiwg.fortemi.index.chunk.v1',\n manifest_schema_version: 'aiwg.fortemi.index.chunk-manifest.v1',\n offset,\n items: slice.map(project),\n },\n })\n partRefs.push({ href, offset, count: slice.length })\n }\n\n const manifest: AiwgFortemiChunkManifest = {\n schema_version: 'aiwg.fortemi.index.chunk-manifest.v1',\n generated_at: options.generatedAt ?? index.generated_at,\n source: index.source,\n total: items.length,\n part_size: partSize,\n facets: getAiwgFortemiFacets(items),\n parts: partRefs,\n ...(projection ? { projection, detail: { href: options.detailHref ?? 'detail/{id}.json' } } : {}),\n }\n\n return {\n manifest,\n parts,\n details: projection ? items.map((record) => ({ id: record.id, record })) : [],\n }\n}\n\nfunction includesAll(actual: string[], expected: string[] | undefined): boolean {\n if (!expected || expected.length === 0) return true\n const actualSet = new Set(actual)\n return expected.every((value) => actualSet.has(value))\n}\n\nfunction matchesFacetFilters(item: AiwgFortemiRecord, filters: Record<string, string[]> | undefined): boolean {\n if (!filters) return true\n return Object.entries(filters).every(([name, expected]) => includesAll(item.facets[name] ?? [], expected))\n}\n\nfunction queryMatches(item: AiwgFortemiRecord, q: string): AiwgIndexQueryMatch[] {\n if (!q) return []\n const matches: AiwgIndexQueryMatch[] = []\n if (item.title.toLowerCase().includes(q)) matches.push({ field: 'title', value: item.title })\n if (item.text.toLowerCase().includes(q)) matches.push({ field: 'text', value: item.text })\n for (const tag of item.tags) {\n if (tag.toLowerCase().includes(q)) matches.push({ field: 'tag', value: tag })\n }\n for (const concept of item.concepts) {\n if (concept.toLowerCase().includes(q)) matches.push({ field: 'concept', value: concept })\n }\n return matches\n}\n\nfunction rankMatches(matches: AiwgIndexQueryMatch[], weights: AiwgIndexQueryWeights): number {\n return matches.reduce((total, match) => total + weights[match.field], 0)\n}\n\nfunction clipSnippet(value: string, q: string, maxLength: number): string {\n const normalizedLength = Math.max(20, maxLength)\n if (!value) return ''\n if (!q) return value.length > normalizedLength ? `${value.slice(0, normalizedLength).trimEnd()}...` : value\n\n const lower = value.toLowerCase()\n const index = lower.indexOf(q)\n if (index < 0) return value.length > normalizedLength ? `${value.slice(0, normalizedLength).trimEnd()}...` : value\n\n const context = Math.max(0, Math.floor((normalizedLength - q.length) / 2))\n const start = Math.max(0, index - context)\n const end = Math.min(value.length, start + normalizedLength)\n const prefix = start > 0 ? '...' : ''\n const suffix = end < value.length ? '...' : ''\n return `${prefix}${value.slice(start, end).trim()}${suffix}`\n}\n\nfunction createSnippet(item: AiwgFortemiRecord, matches: AiwgIndexQueryMatch[], q: string, maxLength: number): string {\n const textMatch = matches.find((match) => match.field === 'text')\n const titleMatch = matches.find((match) => match.field === 'title')\n const firstMatch = textMatch ?? titleMatch ?? matches[0]\n return clipSnippet(firstMatch?.value ?? item.text, q, maxLength)\n}\n\ninterface AiwgRankedEntry {\n item: AiwgFortemiRecord\n ordinal: number\n rank: number\n matches: AiwgIndexQueryMatch[]\n}\n\nfunction createRankedEntries(\n items: AiwgFortemiRecord[],\n q: string,\n options: AiwgIndexQueryOptions,\n ordinalBase = 0,\n): AiwgRankedEntry[] {\n const weights = { ...DEFAULT_QUERY_WEIGHTS, ...options.weights }\n return items.map((item, ordinal) => ({ item, ordinal: ordinalBase + ordinal, matches: queryMatches(item, q) }))\n .filter(({ item, matches }) => {\n if (q && matches.length === 0) return false\n if (options.types && !options.types.includes(item.type)) return false\n if (options.privacy && !options.privacy.includes(item.privacy.classification)) return false\n if (!includesAll(item.tags, options.tags)) return false\n if (!includesAll(item.concepts, options.concepts)) return false\n if (!matchesFacetFilters(item, options.facets)) return false\n if (options.relationshipTargetId && !(item.relationships ?? []).some((rel) => rel.target_id === options.relationshipTargetId)) {\n return false\n }\n return true\n })\n .map(({ item, ordinal, matches }) => ({\n item,\n ordinal,\n rank: rankMatches(matches, weights),\n matches,\n }))\n}\n\nfunction sortRankedEntries(entries: AiwgRankedEntry[], rank?: boolean): AiwgRankedEntry[] {\n return [...entries].sort((left, right) => {\n if (rank) return right.rank - left.rank || left.ordinal - right.ordinal\n return left.ordinal - right.ordinal\n })\n}\n\nfunction createQueryResultFromRankedEntries(\n entries: AiwgRankedEntry[],\n query: string,\n options: AiwgIndexQueryOptions,\n): AiwgIndexQueryResult {\n const ranked = sortRankedEntries(entries, options.rank)\n const offset = options.offset ?? 0\n const limit = options.limit ?? ranked.length\n const page = ranked.slice(offset, offset + limit)\n const result: AiwgIndexQueryResult = {\n items: page.map((entry) => entry.item),\n total: ranked.length,\n facets: getAiwgFortemiFacets(ranked.map((entry) => entry.item)),\n }\n if (options.rank || options.snippets || options.includeMatches) {\n const snippetLength = options.snippetLength ?? 160\n result.rankedItems = page.map((entry) => ({\n item: entry.item,\n rank: entry.rank,\n ...(options.snippets ? { snippet: createSnippet(entry.item, entry.matches, query, snippetLength) } : {}),\n ...(options.includeMatches ? { matches: entry.matches } : {}),\n }))\n }\n return result\n}\n\nexport function queryAiwgFortemiIndex(\n index: AiwgFortemiIndexExport,\n query = '',\n options: AiwgIndexQueryOptions = {},\n): AiwgIndexQueryResult {\n const q = query.trim().toLowerCase()\n return createQueryResultFromRankedEntries(createRankedEntries(index.items, q, options), q, options)\n}\n\ninterface AiwgChunkedIndexRuntime {\n manifest: AiwgFortemiChunkManifest\n loader: AiwgChunkedIndexLoader\n maxCachedParts: number\n partCache: Map<string, AiwgFortemiChunkPart>\n detailLoader?: AiwgChunkedIndexDetailLoader\n maxCachedDetails: number\n detailCache: Map<string, AiwgFortemiRecord>\n}\n\nfunction chunkPartCacheKey(part: AiwgFortemiChunkPartRef): string {\n return `${part.offset}:${part.href}`\n}\n\nfunction clampMaxCachedParts(value: number | undefined): number {\n if (!hasPositiveInteger(value)) return 3\n return value\n}\n\nfunction clampMaxCachedDetails(value: number | undefined): number {\n if (!hasPositiveInteger(value)) return 32\n return value\n}\n\nfunction isDirectChunkBrowse(query: string, options: AiwgIndexQueryOptions): boolean {\n return query.trim() === ''\n && !options.rank\n && !options.snippets\n && !options.includeMatches\n && !options.types\n && !options.facets\n && !options.tags\n && !options.concepts\n && !options.privacy\n && !options.relationshipTargetId\n}\n\nfunction getPartsForRange(\n manifest: AiwgFortemiChunkManifest,\n offset: number,\n limit: number,\n): AiwgFortemiChunkPartRef[] {\n const end = offset + limit\n return manifest.parts.filter((part) => part.count > 0 && part.offset < end && part.offset + part.count > offset)\n}\n\nasync function loadChunkPart(\n runtime: AiwgChunkedIndexRuntime,\n part: AiwgFortemiChunkPartRef,\n): Promise<{ part: AiwgFortemiChunkPart; fetched: boolean }> {\n const key = chunkPartCacheKey(part)\n const cached = runtime.partCache.get(key)\n if (cached) {\n runtime.partCache.delete(key)\n runtime.partCache.set(key, cached)\n return { part: cached, fetched: false }\n }\n\n const parsed = assertAiwgFortemiChunkPart(await runtime.loader(part, runtime.manifest), part, runtime.manifest)\n runtime.partCache.set(key, parsed)\n while (runtime.partCache.size > runtime.maxCachedParts) {\n const oldest = runtime.partCache.keys().next().value\n if (oldest === undefined) break\n runtime.partCache.delete(oldest)\n }\n return { part: parsed, fetched: true }\n}\n\nasync function getChunkRecord(runtime: AiwgChunkedIndexRuntime, id: string): Promise<AiwgFortemiRecord> {\n const cached = runtime.detailCache.get(id)\n if (cached) {\n runtime.detailCache.delete(id)\n runtime.detailCache.set(id, cached)\n return cached\n }\n // Whole-record parts already in cache: serve without a detail fetch.\n if (!runtime.manifest.projection) {\n for (const part of runtime.partCache.values()) {\n const found = part.items.find((item) => item.id === id)\n if (found) return found\n }\n }\n if (!runtime.detailLoader) {\n throw new Error('No detailLoader configured to resolve record ' + id)\n }\n const raw = await runtime.detailLoader(id, runtime.manifest)\n const record = assertAiwgFortemiIndexExport({\n schema_version: 'aiwg.fortemi.index.export.v1',\n generated_at: runtime.manifest.generated_at,\n source: runtime.manifest.source,\n items: [raw],\n }).items[0]\n if (record.id !== id) {\n throw new Error('Detail record id mismatch: expected ' + id + ', got ' + record.id)\n }\n runtime.detailCache.set(id, record)\n while (runtime.detailCache.size > runtime.maxCachedDetails) {\n const oldest = runtime.detailCache.keys().next().value\n if (oldest === undefined) break\n runtime.detailCache.delete(oldest)\n }\n return record\n}\n\nasync function queryChunkedAiwgFortemiIndex(\n runtime: AiwgChunkedIndexRuntime,\n query = '',\n options: AiwgChunkedIndexQueryOptions = {},\n): Promise<AiwgChunkedIndexQueryResult> {\n const q = query.trim().toLowerCase()\n let scannedParts = 0\n let fetchedParts = 0\n\n if (isDirectChunkBrowse(query, options)) {\n const offset = options.offset ?? 0\n const limit = options.limit ?? runtime.manifest.total\n const parts = getPartsForRange(runtime.manifest, offset, limit)\n const items: AiwgFortemiRecord[] = []\n for (const partRef of parts) {\n const loaded = await loadChunkPart(runtime, partRef)\n if (loaded.fetched) fetchedParts += 1\n scannedParts += 1\n options.onProgress?.({ phase: 'part', done: scannedParts, total: parts.length, href: partRef.href })\n const start = Math.max(0, offset - partRef.offset)\n const end = Math.min(loaded.part.items.length, offset + limit - partRef.offset)\n items.push(...loaded.part.items.slice(start, end))\n }\n return {\n items,\n total: runtime.manifest.total,\n facets: runtime.manifest.facets ?? {},\n manifestTotal: runtime.manifest.total,\n scannedParts,\n fetchedParts,\n complete: true,\n }\n }\n\n const entries: AiwgRankedEntry[] = []\n for (const partRef of runtime.manifest.parts) {\n const loaded = await loadChunkPart(runtime, partRef)\n if (loaded.fetched) fetchedParts += 1\n scannedParts += 1\n options.onProgress?.({ phase: 'part', done: scannedParts, total: runtime.manifest.parts.length, href: partRef.href })\n entries.push(...createRankedEntries(loaded.part.items, q, options, partRef.offset))\n options.onProgress?.({ phase: 'query', done: scannedParts, total: runtime.manifest.parts.length, href: partRef.href })\n }\n\n return {\n ...createQueryResultFromRankedEntries(entries, q, options),\n manifestTotal: runtime.manifest.total,\n scannedParts,\n fetchedParts,\n complete: true,\n }\n}\n\nexport function createAiwgReviewDecisionExport(\n source: AiwgFortemiIndexExport,\n decisions: AiwgReviewDecision[],\n generatedAt = new Date().toISOString(),\n): AiwgReviewDecisionExport {\n return {\n schema_version: 'aiwg.fortemi.review-decisions.v1',\n generated_at: generatedAt,\n source_export_schema_version: source.schema_version,\n decisions: [...decisions].sort((left, right) => left.item_id.localeCompare(right.item_id)),\n }\n}\n\nexport function createAiwgIndexController(initialIndex?: AiwgFortemiIndexExport): AiwgIndexController {\n let index: AiwgFortemiIndexExport | null = initialIndex ?? null\n let chunked: AiwgChunkedIndexRuntime | null = null\n let data: AiwgIndexQueryResult | null = null\n let error: Error | null = null\n let reviewDecisions: AiwgReviewDecision[] = []\n const listeners = new Set<AiwgIndexControllerListener>()\n\n const snapshot = (): AiwgIndexControllerSnapshot => ({\n index,\n chunked: chunked\n ? {\n manifest: chunked.manifest,\n cachedParts: chunked.partCache.size,\n maxCachedParts: chunked.maxCachedParts,\n }\n : null,\n data,\n error,\n reviewDecisions: [...reviewDecisions],\n })\n const notify = () => {\n const current = snapshot()\n for (const listener of listeners) listener(current)\n }\n const requireIndex = (): AiwgFortemiIndexExport => {\n if (!index) throw new Error('No AIWG index export loaded')\n return index\n }\n\n return {\n loadIndex(value: unknown): AiwgFortemiIndexExport {\n try {\n const parsed = assertAiwgFortemiIndexExport(value)\n index = parsed\n chunked = null\n data = null\n reviewDecisions = []\n error = null\n notify()\n return parsed\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n loadChunkedIndex(\n manifest: unknown,\n loader: AiwgChunkedIndexLoader,\n options: AiwgChunkedIndexLoadOptions = {},\n ): AiwgFortemiChunkManifest {\n try {\n const parsed = assertAiwgFortemiChunkManifest(manifest)\n index = null\n chunked = {\n manifest: parsed,\n loader,\n maxCachedParts: clampMaxCachedParts(options.maxCachedParts),\n partCache: new Map(),\n detailLoader: options.detailLoader,\n maxCachedDetails: clampMaxCachedDetails(options.maxCachedDetails),\n detailCache: new Map(),\n }\n data = null\n reviewDecisions = []\n error = null\n notify()\n return parsed\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n getIndex(): AiwgFortemiIndexExport | null {\n return index\n },\n getChunkedManifest(): AiwgFortemiChunkManifest | null {\n return chunked?.manifest ?? null\n },\n getSnapshot(): AiwgIndexControllerSnapshot {\n return snapshot()\n },\n query(query = '', options?: AiwgIndexQueryOptions): AiwgIndexQueryResult {\n const result = queryAiwgFortemiIndex(requireIndex(), query, options)\n data = result\n error = null\n notify()\n return result\n },\n async queryChunked(query = '', options?: AiwgChunkedIndexQueryOptions): Promise<AiwgChunkedIndexQueryResult> {\n if (!chunked) throw new Error('No AIWG chunked index manifest loaded')\n try {\n const result = await queryChunkedAiwgFortemiIndex(chunked, query, options)\n data = result\n error = null\n notify()\n return result\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n },\n async getRecord(id: string): Promise<AiwgFortemiRecord> {\n if (chunked) {\n try {\n return await getChunkRecord(chunked, id)\n } catch (err) {\n error = err instanceof Error ? err : new Error(String(err))\n notify()\n throw error\n }\n }\n const found = requireIndex().items.find((item) => item.id === id)\n if (!found) throw new Error('Record not found: ' + id)\n return found\n },\n clearChunkCache(): void {\n chunked?.partCache.clear()\n chunked?.detailCache.clear()\n error = null\n notify()\n },\n toCommunityGraph(options?: AiwgIndexGraphOptions) {\n return aiwgFortemiIndexToCommunityGraph(requireIndex(), options)\n },\n setReviewDecision(input: AiwgReviewInput): AiwgReviewDecision {\n const decision: AiwgReviewDecision = {\n ...input,\n updated_at: new Date().toISOString(),\n }\n reviewDecisions = [\n ...reviewDecisions.filter((item) => item.item_id !== decision.item_id),\n decision,\n ].sort((left, right) => left.item_id.localeCompare(right.item_id))\n error = null\n notify()\n return decision\n },\n clearReviewDecision(itemId: string): void {\n reviewDecisions = reviewDecisions.filter((item) => item.item_id !== itemId)\n error = null\n notify()\n },\n createReviewDecisionExport(generatedAt?: string): AiwgReviewDecisionExport {\n return createAiwgReviewDecisionExport(requireIndex(), reviewDecisions, generatedAt)\n },\n subscribe(listener: AiwgIndexControllerListener): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n\nexport function aiwgFortemiIndexToCommunityGraph(\n index: AiwgFortemiIndexExport,\n options: AiwgIndexGraphOptions = {},\n) {\n const ids = new Set(index.items.map((item) => item.id))\n const relationshipWeights = options.relationshipWeights ?? {}\n const edgeCounts = new Map<string, { source: string; target: string; kind: string; weight: number }>()\n\n for (const item of index.items) {\n for (const relationship of item.relationships) {\n if (!ids.has(relationship.target_id) && !options.includeDanglingRelationships) continue\n const kind = relationship.type\n const baseWeight = relationshipWeights[kind] ?? 1\n const key = `${item.id}\\u0000${relationship.target_id}\\u0000${kind}`\n const existing = edgeCounts.get(key)\n if (existing) existing.weight += baseWeight\n else edgeCounts.set(key, { source: item.id, target: relationship.target_id, kind, weight: baseWeight })\n }\n }\n\n const communities = new Map<string, string[]>()\n for (const item of index.items) {\n const communityIds = communityIdsFor(item, options)\n for (const communityId of communityIds) {\n const nodes = communities.get(communityId) ?? []\n nodes.push(item.id)\n communities.set(communityId, nodes)\n }\n }\n\n return {\n nodes: index.items.map((item) => ({ id: item.id })),\n edges: Array.from(edgeCounts.values()).sort((left, right) => (\n left.source.localeCompare(right.source)\n || left.target.localeCompare(right.target)\n || left.kind.localeCompare(right.kind)\n )),\n communities: Array.from(communities.entries())\n .map(([id, nodes]) => ({ id, nodes: [...new Set(nodes)].sort() }))\n .sort((left, right) => left.id.localeCompare(right.id)),\n }\n}\n\nfunction communityIdsFor(item: AiwgFortemiRecord, options: AiwgIndexGraphOptions): string[] {\n if (options.communityFacet) {\n const values = item.facets[options.communityFacet] ?? []\n if (values.length > 0) return values.map((value) => `${options.communityFacet}:${value}`)\n }\n if (options.communityTagPrefix) {\n const prefix = options.communityTagPrefix\n const tags = item.tags.filter((tag) => tag.startsWith(prefix))\n if (tags.length > 0) return tags\n }\n if (item.concepts.length > 0) return item.concepts.map((concept) => `concept:${concept}`)\n return [`type:${item.type}`]\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
2
|
import { z, ZodType } from 'zod';
|
|
3
|
-
export { AiwgChunkedIndexLoadOptions, AiwgChunkedIndexLoader, AiwgChunkedIndexProgress, AiwgChunkedIndexProgressPhase, AiwgChunkedIndexQueryOptions, AiwgChunkedIndexQueryResult, AiwgChunkedIndexValidationResult, AiwgFortemiChunkManifest, AiwgFortemiChunkPart, AiwgFortemiChunkPartRef, AiwgFortemiIndexExport, AiwgFortemiProvenance, AiwgFortemiRecord, AiwgFortemiRecordSource, AiwgFortemiRecordType, AiwgFortemiRelationship, AiwgIndexController, AiwgIndexControllerListener, AiwgIndexControllerSnapshot, AiwgIndexGraphOptions, AiwgIndexQueryMatch, AiwgIndexQueryOptions, AiwgIndexQueryRankedItem, AiwgIndexQueryResult, AiwgIndexQueryWeights, AiwgIndexValidationResult, AiwgPrivacyClassification, AiwgProvenanceConfidence, AiwgReviewAction, AiwgReviewDecision, AiwgReviewDecisionExport, AiwgReviewInput, aiwgFortemiIndexToCommunityGraph, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, createAiwgFetchChunkLoader, createAiwgIndexController, createAiwgReviewDecisionExport, getAiwgFortemiFacets, queryAiwgFortemiIndex, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport } from './aiwg-index.js';
|
|
3
|
+
export { AIWG_SCAN_REQUIRED_FIELDS, AiwgChunkedIndexBuildOptions, AiwgChunkedIndexBuildResult, AiwgChunkedIndexDetailLoader, AiwgChunkedIndexLoadOptions, AiwgChunkedIndexLoader, AiwgChunkedIndexProgress, AiwgChunkedIndexProgressPhase, AiwgChunkedIndexQueryOptions, AiwgChunkedIndexQueryResult, AiwgChunkedIndexValidationResult, AiwgFortemiChunkDetailRef, AiwgFortemiChunkManifest, AiwgFortemiChunkPart, AiwgFortemiChunkPartRef, AiwgFortemiIndexExport, AiwgFortemiProjectedRecord, AiwgFortemiProvenance, AiwgFortemiRecord, AiwgFortemiRecordSource, AiwgFortemiRecordType, AiwgFortemiRelationship, AiwgIndexController, AiwgIndexControllerListener, AiwgIndexControllerSnapshot, AiwgIndexGraphOptions, AiwgIndexQueryMatch, AiwgIndexQueryOptions, AiwgIndexQueryRankedItem, AiwgIndexQueryResult, AiwgIndexQueryWeights, AiwgIndexValidationResult, AiwgPrivacyClassification, AiwgProvenanceConfidence, AiwgReviewAction, AiwgReviewDecision, AiwgReviewDecisionExport, AiwgReviewInput, aiwgFortemiIndexToCommunityGraph, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, buildAiwgChunkedIndex, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, getAiwgFortemiFacets, queryAiwgFortemiIndex, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport } from './aiwg-index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Generate a RFC 9562 UUIDv7 identifier.
|
package/dist/index.js
CHANGED
|
@@ -6806,6 +6806,17 @@ function parseJsonArray(data) {
|
|
|
6806
6806
|
}
|
|
6807
6807
|
|
|
6808
6808
|
// src/aiwg-index.ts
|
|
6809
|
+
var AIWG_SCAN_REQUIRED_FIELDS = [
|
|
6810
|
+
"schema_version",
|
|
6811
|
+
"id",
|
|
6812
|
+
"type",
|
|
6813
|
+
"title",
|
|
6814
|
+
"text",
|
|
6815
|
+
"facets",
|
|
6816
|
+
"tags",
|
|
6817
|
+
"concepts",
|
|
6818
|
+
"privacy"
|
|
6819
|
+
];
|
|
6809
6820
|
var REQUIRED_RECORD_FIELDS = [
|
|
6810
6821
|
"schema_version",
|
|
6811
6822
|
"id",
|
|
@@ -6917,6 +6928,20 @@ function validateAiwgFortemiChunkManifest(value) {
|
|
|
6917
6928
|
if (data.facets !== void 0 && !isFacetCounts(data.facets)) {
|
|
6918
6929
|
errors.push("facets must be a nested string-to-number count object");
|
|
6919
6930
|
}
|
|
6931
|
+
if (data.projection !== void 0) {
|
|
6932
|
+
if (!Array.isArray(data.projection) || !data.projection.every((field) => typeof field === "string")) {
|
|
6933
|
+
errors.push("projection must be an array of field names");
|
|
6934
|
+
} else {
|
|
6935
|
+
const present = new Set(data.projection);
|
|
6936
|
+
for (const field of AIWG_SCAN_REQUIRED_FIELDS) {
|
|
6937
|
+
if (!present.has(field)) errors.push("projection must include scan-required field " + field);
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
if (data.detail !== void 0) {
|
|
6942
|
+
if (!hasString(data.detail.href)) errors.push("detail.href is required");
|
|
6943
|
+
else if (!data.detail.href.includes("{id}")) errors.push("detail.href must contain the {id} placeholder");
|
|
6944
|
+
}
|
|
6920
6945
|
if (!Array.isArray(data?.parts)) errors.push("parts must be an array");
|
|
6921
6946
|
let expectedOffset = 0;
|
|
6922
6947
|
const parts = Array.isArray(data?.parts) ? data.parts : [];
|
|
@@ -6941,6 +6966,35 @@ function assertAiwgFortemiChunkManifest(value) {
|
|
|
6941
6966
|
}
|
|
6942
6967
|
return value;
|
|
6943
6968
|
}
|
|
6969
|
+
function validateProjectedRecords(items) {
|
|
6970
|
+
const errors = [];
|
|
6971
|
+
const ids = /* @__PURE__ */ new Set();
|
|
6972
|
+
let previousId = "";
|
|
6973
|
+
for (const [index, item] of items.entries()) {
|
|
6974
|
+
if (item.schema_version !== "aiwg.fortemi.index.record.v1") {
|
|
6975
|
+
errors.push("items[" + index + "].schema_version must be aiwg.fortemi.index.record.v1");
|
|
6976
|
+
}
|
|
6977
|
+
if (!hasString(item.id)) errors.push("items[" + index + "].id is required");
|
|
6978
|
+
if (hasString(item.id) && ids.has(item.id)) errors.push("duplicate id: " + item.id);
|
|
6979
|
+
if (hasString(item.id)) ids.add(item.id);
|
|
6980
|
+
if (previousId && hasString(item.id) && previousId.localeCompare(item.id) > 0) {
|
|
6981
|
+
errors.push("items must be sorted by id: " + previousId + " before " + item.id);
|
|
6982
|
+
}
|
|
6983
|
+
if (hasString(item.id)) previousId = item.id;
|
|
6984
|
+
if (!item.type || !VALID_TYPES.has(item.type)) errors.push("items[" + index + "].type is invalid");
|
|
6985
|
+
if (!hasString(item.title)) errors.push("items[" + index + "].title is required");
|
|
6986
|
+
if (typeof item.text !== "string") errors.push("items[" + index + "].text is required");
|
|
6987
|
+
if (!item.facets || typeof item.facets !== "object" || Array.isArray(item.facets)) {
|
|
6988
|
+
errors.push("items[" + index + "].facets must be an object");
|
|
6989
|
+
}
|
|
6990
|
+
if (!Array.isArray(item.tags)) errors.push("items[" + index + "].tags must be an array");
|
|
6991
|
+
if (!Array.isArray(item.concepts)) errors.push("items[" + index + "].concepts must be an array");
|
|
6992
|
+
if (!item.privacy || !hasString(item.privacy.classification)) {
|
|
6993
|
+
errors.push("items[" + index + "].privacy.classification is required");
|
|
6994
|
+
}
|
|
6995
|
+
}
|
|
6996
|
+
return errors;
|
|
6997
|
+
}
|
|
6944
6998
|
function validateAiwgFortemiChunkPart(value, partRef, manifest) {
|
|
6945
6999
|
const errors = [];
|
|
6946
7000
|
const data = value;
|
|
@@ -6959,13 +7013,17 @@ function validateAiwgFortemiChunkPart(value, partRef, manifest) {
|
|
|
6959
7013
|
errors.push("items length must match manifest part count " + partRef.count);
|
|
6960
7014
|
}
|
|
6961
7015
|
if (Array.isArray(data?.items)) {
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
7016
|
+
if (manifest?.projection) {
|
|
7017
|
+
errors.push(...validateProjectedRecords(data.items).map((error) => "items." + error));
|
|
7018
|
+
} else {
|
|
7019
|
+
const validation = validateAiwgFortemiIndexExport({
|
|
7020
|
+
schema_version: "aiwg.fortemi.index.export.v1",
|
|
7021
|
+
generated_at: manifest?.generated_at ?? "1970-01-01T00:00:00.000Z",
|
|
7022
|
+
source: manifest?.source ?? { repo: "chunk", privacy: "public" },
|
|
7023
|
+
items: data.items
|
|
7024
|
+
});
|
|
7025
|
+
errors.push(...validation.errors.map((error) => "items." + error));
|
|
7026
|
+
}
|
|
6969
7027
|
}
|
|
6970
7028
|
return { valid: errors.length === 0, errors };
|
|
6971
7029
|
}
|
|
@@ -6984,6 +7042,16 @@ function createAiwgFetchChunkLoader(baseUrl) {
|
|
|
6984
7042
|
return response.json();
|
|
6985
7043
|
};
|
|
6986
7044
|
}
|
|
7045
|
+
function createAiwgFetchDetailLoader(baseUrl) {
|
|
7046
|
+
return async (id, manifest) => {
|
|
7047
|
+
if (!manifest.detail?.href) throw new Error("Manifest has no detail.href for record resolution");
|
|
7048
|
+
const relative = manifest.detail.href.replace("{id}", encodeURIComponent(id));
|
|
7049
|
+
const href = baseUrl ? new URL(relative, baseUrl).toString() : relative;
|
|
7050
|
+
const response = await fetch(href);
|
|
7051
|
+
if (!response.ok) throw new Error("Failed to fetch AIWG index detail " + href + ": " + response.status);
|
|
7052
|
+
return response.json();
|
|
7053
|
+
};
|
|
7054
|
+
}
|
|
6987
7055
|
function getAiwgFortemiFacets(items) {
|
|
6988
7056
|
const result = {};
|
|
6989
7057
|
for (const item of items) {
|
|
@@ -6997,6 +7065,49 @@ function getAiwgFortemiFacets(items) {
|
|
|
6997
7065
|
}
|
|
6998
7066
|
return result;
|
|
6999
7067
|
}
|
|
7068
|
+
function buildAiwgChunkedIndex(index, options = {}) {
|
|
7069
|
+
const partSize = hasPositiveInteger(options.partSize) ? options.partSize : 500;
|
|
7070
|
+
const projection = options.projection;
|
|
7071
|
+
const items = index.items;
|
|
7072
|
+
const pad = (value) => String(value).padStart(4, "0");
|
|
7073
|
+
const project = (record) => {
|
|
7074
|
+
if (!projection) return record;
|
|
7075
|
+
const slim = {};
|
|
7076
|
+
for (const field of projection) slim[field] = record[field];
|
|
7077
|
+
return slim;
|
|
7078
|
+
};
|
|
7079
|
+
const parts = [];
|
|
7080
|
+
const partRefs = [];
|
|
7081
|
+
for (let offset = 0, partIndex = 0; offset < items.length; offset += partSize, partIndex += 1) {
|
|
7082
|
+
const slice = items.slice(offset, offset + partSize);
|
|
7083
|
+
const href = "part-" + pad(partIndex) + ".json";
|
|
7084
|
+
parts.push({
|
|
7085
|
+
href,
|
|
7086
|
+
part: {
|
|
7087
|
+
schema_version: "aiwg.fortemi.index.chunk.v1",
|
|
7088
|
+
manifest_schema_version: "aiwg.fortemi.index.chunk-manifest.v1",
|
|
7089
|
+
offset,
|
|
7090
|
+
items: slice.map(project)
|
|
7091
|
+
}
|
|
7092
|
+
});
|
|
7093
|
+
partRefs.push({ href, offset, count: slice.length });
|
|
7094
|
+
}
|
|
7095
|
+
const manifest = {
|
|
7096
|
+
schema_version: "aiwg.fortemi.index.chunk-manifest.v1",
|
|
7097
|
+
generated_at: options.generatedAt ?? index.generated_at,
|
|
7098
|
+
source: index.source,
|
|
7099
|
+
total: items.length,
|
|
7100
|
+
part_size: partSize,
|
|
7101
|
+
facets: getAiwgFortemiFacets(items),
|
|
7102
|
+
parts: partRefs,
|
|
7103
|
+
...projection ? { projection, detail: { href: options.detailHref ?? "detail/{id}.json" } } : {}
|
|
7104
|
+
};
|
|
7105
|
+
return {
|
|
7106
|
+
manifest,
|
|
7107
|
+
parts,
|
|
7108
|
+
details: projection ? items.map((record) => ({ id: record.id, record })) : []
|
|
7109
|
+
};
|
|
7110
|
+
}
|
|
7000
7111
|
function includesAll(actual, expected) {
|
|
7001
7112
|
if (!expected || expected.length === 0) return true;
|
|
7002
7113
|
const actualSet = new Set(actual);
|
|
@@ -7051,7 +7162,7 @@ function createRankedEntries(items, q, options, ordinalBase = 0) {
|
|
|
7051
7162
|
if (!includesAll(item.tags, options.tags)) return false;
|
|
7052
7163
|
if (!includesAll(item.concepts, options.concepts)) return false;
|
|
7053
7164
|
if (!matchesFacetFilters(item, options.facets)) return false;
|
|
7054
|
-
if (options.relationshipTargetId && !item.relationships.some((rel) => rel.target_id === options.relationshipTargetId)) {
|
|
7165
|
+
if (options.relationshipTargetId && !(item.relationships ?? []).some((rel) => rel.target_id === options.relationshipTargetId)) {
|
|
7055
7166
|
return false;
|
|
7056
7167
|
}
|
|
7057
7168
|
return true;
|
|
@@ -7100,6 +7211,10 @@ function clampMaxCachedParts(value) {
|
|
|
7100
7211
|
if (!hasPositiveInteger(value)) return 3;
|
|
7101
7212
|
return value;
|
|
7102
7213
|
}
|
|
7214
|
+
function clampMaxCachedDetails(value) {
|
|
7215
|
+
if (!hasPositiveInteger(value)) return 32;
|
|
7216
|
+
return value;
|
|
7217
|
+
}
|
|
7103
7218
|
function isDirectChunkBrowse(query, options) {
|
|
7104
7219
|
return query.trim() === "" && !options.rank && !options.snippets && !options.includeMatches && !options.types && !options.facets && !options.tags && !options.concepts && !options.privacy && !options.relationshipTargetId;
|
|
7105
7220
|
}
|
|
@@ -7124,6 +7239,40 @@ async function loadChunkPart(runtime, part) {
|
|
|
7124
7239
|
}
|
|
7125
7240
|
return { part: parsed, fetched: true };
|
|
7126
7241
|
}
|
|
7242
|
+
async function getChunkRecord(runtime, id) {
|
|
7243
|
+
const cached = runtime.detailCache.get(id);
|
|
7244
|
+
if (cached) {
|
|
7245
|
+
runtime.detailCache.delete(id);
|
|
7246
|
+
runtime.detailCache.set(id, cached);
|
|
7247
|
+
return cached;
|
|
7248
|
+
}
|
|
7249
|
+
if (!runtime.manifest.projection) {
|
|
7250
|
+
for (const part of runtime.partCache.values()) {
|
|
7251
|
+
const found = part.items.find((item) => item.id === id);
|
|
7252
|
+
if (found) return found;
|
|
7253
|
+
}
|
|
7254
|
+
}
|
|
7255
|
+
if (!runtime.detailLoader) {
|
|
7256
|
+
throw new Error("No detailLoader configured to resolve record " + id);
|
|
7257
|
+
}
|
|
7258
|
+
const raw = await runtime.detailLoader(id, runtime.manifest);
|
|
7259
|
+
const record = assertAiwgFortemiIndexExport({
|
|
7260
|
+
schema_version: "aiwg.fortemi.index.export.v1",
|
|
7261
|
+
generated_at: runtime.manifest.generated_at,
|
|
7262
|
+
source: runtime.manifest.source,
|
|
7263
|
+
items: [raw]
|
|
7264
|
+
}).items[0];
|
|
7265
|
+
if (record.id !== id) {
|
|
7266
|
+
throw new Error("Detail record id mismatch: expected " + id + ", got " + record.id);
|
|
7267
|
+
}
|
|
7268
|
+
runtime.detailCache.set(id, record);
|
|
7269
|
+
while (runtime.detailCache.size > runtime.maxCachedDetails) {
|
|
7270
|
+
const oldest = runtime.detailCache.keys().next().value;
|
|
7271
|
+
if (oldest === void 0) break;
|
|
7272
|
+
runtime.detailCache.delete(oldest);
|
|
7273
|
+
}
|
|
7274
|
+
return record;
|
|
7275
|
+
}
|
|
7127
7276
|
async function queryChunkedAiwgFortemiIndex(runtime, query = "", options = {}) {
|
|
7128
7277
|
const q = query.trim().toLowerCase();
|
|
7129
7278
|
let scannedParts = 0;
|
|
@@ -7228,7 +7377,10 @@ function createAiwgIndexController(initialIndex) {
|
|
|
7228
7377
|
manifest: parsed,
|
|
7229
7378
|
loader,
|
|
7230
7379
|
maxCachedParts: clampMaxCachedParts(options.maxCachedParts),
|
|
7231
|
-
partCache: /* @__PURE__ */ new Map()
|
|
7380
|
+
partCache: /* @__PURE__ */ new Map(),
|
|
7381
|
+
detailLoader: options.detailLoader,
|
|
7382
|
+
maxCachedDetails: clampMaxCachedDetails(options.maxCachedDetails),
|
|
7383
|
+
detailCache: /* @__PURE__ */ new Map()
|
|
7232
7384
|
};
|
|
7233
7385
|
data = null;
|
|
7234
7386
|
reviewDecisions = [];
|
|
@@ -7271,8 +7423,23 @@ function createAiwgIndexController(initialIndex) {
|
|
|
7271
7423
|
throw error;
|
|
7272
7424
|
}
|
|
7273
7425
|
},
|
|
7426
|
+
async getRecord(id) {
|
|
7427
|
+
if (chunked) {
|
|
7428
|
+
try {
|
|
7429
|
+
return await getChunkRecord(chunked, id);
|
|
7430
|
+
} catch (err) {
|
|
7431
|
+
error = err instanceof Error ? err : new Error(String(err));
|
|
7432
|
+
notify();
|
|
7433
|
+
throw error;
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
7436
|
+
const found = requireIndex().items.find((item) => item.id === id);
|
|
7437
|
+
if (!found) throw new Error("Record not found: " + id);
|
|
7438
|
+
return found;
|
|
7439
|
+
},
|
|
7274
7440
|
clearChunkCache() {
|
|
7275
7441
|
chunked?.partCache.clear();
|
|
7442
|
+
chunked?.detailCache.clear();
|
|
7276
7443
|
error = null;
|
|
7277
7444
|
notify();
|
|
7278
7445
|
},
|
|
@@ -7355,6 +7522,6 @@ function communityIdsFor(item, options) {
|
|
|
7355
7522
|
// src/index.ts
|
|
7356
7523
|
var VERSION = "2026.6.2";
|
|
7357
7524
|
|
|
7358
|
-
export { ArchiveManager, AttachmentsRepository, CURRENT_SHARD_VERSION, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, EmbeddingSetsRepository, FallbackRouter, FortemiToolManifest, GetNoteInputSchema, GraphRepository, JOB_CAPABILITIES, JOB_PRIORITIES, JobQueueWorker, LOCAL_ENDPOINTS, LinksRepository, ListNotesInputSchema, ManageArchiveInputSchema, ManageAttachmentsInputSchema, ManageCapabilitiesInputSchema, ManageCollectionsInputSchema, ManageLinksInputSchema, ManageNoteInputSchema, ManageTagsInputSchema, MemoryBlobStore, MigrationRunner, NotesRepository, OpenAICompatibleProvider, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, ProviderRegistry, SHARD_FORMAT, SearchInputSchema, SearchRepository, SkosRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexToCommunityGraph, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, provenanceEdgeToShard, queryAiwgFortemiIndex, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateChecksums, verifySri };
|
|
7525
|
+
export { AIWG_SCAN_REQUIRED_FIELDS, ArchiveManager, AttachmentsRepository, CURRENT_SHARD_VERSION, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, EmbeddingSetsRepository, FallbackRouter, FortemiToolManifest, GetNoteInputSchema, GraphRepository, JOB_CAPABILITIES, JOB_PRIORITIES, JobQueueWorker, LOCAL_ENDPOINTS, LinksRepository, ListNotesInputSchema, ManageArchiveInputSchema, ManageAttachmentsInputSchema, ManageCapabilitiesInputSchema, ManageCollectionsInputSchema, ManageLinksInputSchema, ManageNoteInputSchema, ManageTagsInputSchema, MemoryBlobStore, MigrationRunner, NotesRepository, OpenAICompatibleProvider, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, ProviderRegistry, SHARD_FORMAT, SearchInputSchema, SearchRepository, SkosRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexToCommunityGraph, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, buildAiwgChunkedIndex, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, provenanceEdgeToShard, queryAiwgFortemiIndex, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateChecksums, verifySri };
|
|
7359
7526
|
//# sourceMappingURL=index.js.map
|
|
7360
7527
|
//# sourceMappingURL=index.js.map
|