@fortemi/core 2026.7.2 → 2026.7.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/dist/aiwg-index.d.ts +21 -7
- package/dist/aiwg-index.js +127 -10
- package/dist/aiwg-index.js.map +1 -1
- package/dist/index.d.ts +50 -32
- package/dist/index.js +163 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 { AIWG_SCAN_REQUIRED_FIELDS, AiwgChunkedIndexBuildOptions, AiwgChunkedIndexBuildResult, AiwgChunkedIndexDetailLoader, AiwgChunkedIndexLoadOptions, AiwgChunkedIndexLoader, AiwgChunkedIndexProgress, AiwgChunkedIndexProgressPhase, AiwgChunkedIndexQueryOptions, AiwgChunkedIndexQueryResult, AiwgChunkedIndexValidationResult, AiwgFortemiAttachmentReference, AiwgFortemiBinarySource, AiwgFortemiChunk, AiwgFortemiChunkDetailRef, AiwgFortemiChunkManifest, AiwgFortemiChunkPart, AiwgFortemiChunkPartRef, AiwgFortemiIndexExport, AiwgFortemiIndexExportSchemaVersion, AiwgFortemiKnownRecordType, AiwgFortemiProjectedRecord, AiwgFortemiProvenance, AiwgFortemiProvenanceEvent, AiwgFortemiRecord, AiwgFortemiRecordEmbedding, AiwgFortemiRecordSchemaVersion, AiwgFortemiRecordSource, AiwgFortemiRecordType, AiwgFortemiRelationship, AiwgFortemiRelationshipDirection, AiwgFortemiSearchProjection, AiwgFortemiSkosConcept, AiwgFortemiSkosRelation, AiwgFortemiSkosRelationType, AiwgHeadlessEmbeddingBackend, AiwgIndexController, AiwgIndexControllerListener, AiwgIndexControllerSnapshot, AiwgIndexGraphOptions, AiwgIndexQueryMatch, AiwgIndexQueryOptions, AiwgIndexQueryRankedItem, AiwgIndexQueryResult, AiwgIndexQueryWeights, AiwgIndexValidationResult, AiwgPrivacyClassification, AiwgProvenanceConfidence, AiwgRelationshipDirection, AiwgRelationshipEdgeSummary, AiwgRelationshipNodeSummary, AiwgRelationshipQueryOptions, AiwgRelationshipSetOperation, AiwgRelationshipSetOptions, AiwgRelationshipSetResult, AiwgRelationshipTraversalOptions, AiwgRelationshipTraversalResult, AiwgReviewAction, AiwgReviewDecision, AiwgReviewDecisionExport, AiwgReviewInput, AiwgStaticDuplicatePair, AiwgStaticEmbeddingRecord, AiwgStaticEmbeddingSet, AiwgStaticHybridQueryOptions, AiwgStaticSemanticQueryOptions, AiwgStaticSemanticResult, BuildAiwgStaticEmbeddingSetOptions, aiwgFortemiIndexToCommunityGraph, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, findAiwgStaticDuplicatePairs, getAiwgFortemiFacets, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet } from './aiwg-index.js';
|
|
3
|
+
export { AIWG_SCAN_REQUIRED_FIELDS, AiwgChunkedIndexBuildOptions, AiwgChunkedIndexBuildResult, AiwgChunkedIndexDetailLoader, AiwgChunkedIndexLoadOptions, AiwgChunkedIndexLoader, AiwgChunkedIndexProgress, AiwgChunkedIndexProgressPhase, AiwgChunkedIndexQueryOptions, AiwgChunkedIndexQueryResult, AiwgChunkedIndexValidationResult, AiwgFortemiAttachmentReference, AiwgFortemiBinarySource, AiwgFortemiChunk, AiwgFortemiChunkDetailRef, AiwgFortemiChunkManifest, AiwgFortemiChunkPart, AiwgFortemiChunkPartRef, AiwgFortemiIndexExport, AiwgFortemiIndexExportSchemaVersion, AiwgFortemiKnownRecordType, AiwgFortemiProjectedRecord, AiwgFortemiProvenance, AiwgFortemiProvenanceEvent, AiwgFortemiRecord, AiwgFortemiRecordEmbedding, AiwgFortemiRecordSchemaVersion, AiwgFortemiRecordSource, AiwgFortemiRecordType, AiwgFortemiRelationship, AiwgFortemiRelationshipDirection, AiwgFortemiSearchProjection, AiwgFortemiSkosConcept, AiwgFortemiSkosRelation, AiwgFortemiSkosRelationType, AiwgHeadlessEmbeddingBackend, AiwgIndexController, AiwgIndexControllerListener, AiwgIndexControllerSnapshot, AiwgIndexGraphOptions, AiwgIndexQueryMatch, AiwgIndexQueryOptions, AiwgIndexQueryRankedItem, AiwgIndexQueryResult, AiwgIndexQueryWeights, AiwgIndexValidationResult, AiwgPrivacyClassification, AiwgPrivacyFilterOptions, AiwgProvenanceConfidence, AiwgRelationshipDirection, AiwgRelationshipEdgeSummary, AiwgRelationshipNodeSummary, AiwgRelationshipQueryOptions, AiwgRelationshipSetOperation, AiwgRelationshipSetOptions, AiwgRelationshipSetResult, AiwgRelationshipTraversalOptions, AiwgRelationshipTraversalResult, AiwgReviewAction, AiwgReviewDecision, AiwgReviewDecisionExport, AiwgReviewInput, AiwgStaticDuplicatePair, AiwgStaticEmbeddingRecord, AiwgStaticEmbeddingSet, AiwgStaticHybridQueryOptions, AiwgStaticSemanticQueryOptions, AiwgStaticSemanticResult, BuildAiwgStaticEmbeddingSetOptions, aiwgFortemiIndexToCommunityGraph, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, getAiwgFortemiFacets, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet } from './aiwg-index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Generate a RFC 9562 UUIDv7 identifier.
|
|
@@ -2378,19 +2378,19 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
|
|
|
2378
2378
|
}, {
|
|
2379
2379
|
content: string;
|
|
2380
2380
|
title?: string | undefined;
|
|
2381
|
-
format?: "markdown" | "plain" | "html" | undefined;
|
|
2382
2381
|
tags?: string[] | undefined;
|
|
2382
|
+
format?: "markdown" | "plain" | "html" | undefined;
|
|
2383
2383
|
}>, "many">>;
|
|
2384
2384
|
template: z.ZodOptional<z.ZodString>;
|
|
2385
2385
|
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2386
2386
|
}, "strip", z.ZodTypeAny, {
|
|
2387
2387
|
source: string;
|
|
2388
2388
|
format: "markdown" | "plain" | "html";
|
|
2389
|
-
visibility: "private" | "
|
|
2389
|
+
visibility: "private" | "public" | "shared";
|
|
2390
2390
|
action: "create" | "bulk_create" | "from_template";
|
|
2391
2391
|
title?: string | undefined;
|
|
2392
|
-
archive_id?: string | undefined;
|
|
2393
2392
|
tags?: string[] | undefined;
|
|
2393
|
+
archive_id?: string | undefined;
|
|
2394
2394
|
content?: string | undefined;
|
|
2395
2395
|
notes?: {
|
|
2396
2396
|
format: "markdown" | "plain" | "html";
|
|
@@ -2404,16 +2404,16 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
|
|
|
2404
2404
|
action: "create" | "bulk_create" | "from_template";
|
|
2405
2405
|
source?: string | undefined;
|
|
2406
2406
|
title?: string | undefined;
|
|
2407
|
+
tags?: string[] | undefined;
|
|
2407
2408
|
archive_id?: string | undefined;
|
|
2408
2409
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
2409
|
-
visibility?: "private" | "
|
|
2410
|
-
tags?: string[] | undefined;
|
|
2410
|
+
visibility?: "private" | "public" | "shared" | undefined;
|
|
2411
2411
|
content?: string | undefined;
|
|
2412
2412
|
notes?: {
|
|
2413
2413
|
content: string;
|
|
2414
2414
|
title?: string | undefined;
|
|
2415
|
-
format?: "markdown" | "plain" | "html" | undefined;
|
|
2416
2415
|
tags?: string[] | undefined;
|
|
2416
|
+
format?: "markdown" | "plain" | "html" | undefined;
|
|
2417
2417
|
}[] | undefined;
|
|
2418
2418
|
template?: string | undefined;
|
|
2419
2419
|
variables?: Record<string, string> | undefined;
|
|
@@ -2460,17 +2460,17 @@ declare const SearchInputSchema: z.ZodObject<{
|
|
|
2460
2460
|
visibility: z.ZodOptional<z.ZodEnum<["private", "shared", "public"]>>;
|
|
2461
2461
|
include_facets: z.ZodDefault<z.ZodBoolean>;
|
|
2462
2462
|
}, "strip", z.ZodTypeAny, {
|
|
2463
|
-
|
|
2463
|
+
query: string;
|
|
2464
2464
|
offset: number;
|
|
2465
|
+
limit: number;
|
|
2465
2466
|
include_facets: boolean;
|
|
2466
|
-
mode: "
|
|
2467
|
-
query: string;
|
|
2467
|
+
mode: "text" | "auto" | "semantic" | "hybrid";
|
|
2468
2468
|
source?: string | undefined;
|
|
2469
|
+
tags?: string[] | undefined;
|
|
2469
2470
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
2470
|
-
visibility?: "private" | "
|
|
2471
|
+
visibility?: "private" | "public" | "shared" | undefined;
|
|
2471
2472
|
is_starred?: boolean | undefined;
|
|
2472
2473
|
is_archived?: boolean | undefined;
|
|
2473
|
-
tags?: string[] | undefined;
|
|
2474
2474
|
collection_id?: string | undefined;
|
|
2475
2475
|
date_from?: Date | undefined;
|
|
2476
2476
|
date_to?: Date | undefined;
|
|
@@ -2479,18 +2479,18 @@ declare const SearchInputSchema: z.ZodObject<{
|
|
|
2479
2479
|
}, {
|
|
2480
2480
|
query: string;
|
|
2481
2481
|
source?: string | undefined;
|
|
2482
|
+
tags?: string[] | undefined;
|
|
2483
|
+
offset?: number | undefined;
|
|
2484
|
+
limit?: number | undefined;
|
|
2482
2485
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
2483
|
-
visibility?: "private" | "
|
|
2486
|
+
visibility?: "private" | "public" | "shared" | undefined;
|
|
2484
2487
|
is_starred?: boolean | undefined;
|
|
2485
2488
|
is_archived?: boolean | undefined;
|
|
2486
|
-
tags?: string[] | undefined;
|
|
2487
|
-
limit?: number | undefined;
|
|
2488
|
-
offset?: number | undefined;
|
|
2489
2489
|
collection_id?: string | undefined;
|
|
2490
2490
|
date_from?: Date | undefined;
|
|
2491
2491
|
date_to?: Date | undefined;
|
|
2492
2492
|
include_facets?: boolean | undefined;
|
|
2493
|
-
mode?: "
|
|
2493
|
+
mode?: "text" | "auto" | "semantic" | "hybrid" | undefined;
|
|
2494
2494
|
embeddingSetId?: string | undefined;
|
|
2495
2495
|
query_embedding?: number[] | undefined;
|
|
2496
2496
|
}>;
|
|
@@ -2570,22 +2570,22 @@ declare const ListNotesInputSchema: z.ZodObject<{
|
|
|
2570
2570
|
collection_id: z.ZodOptional<z.ZodString>;
|
|
2571
2571
|
include_deleted: z.ZodOptional<z.ZodBoolean>;
|
|
2572
2572
|
}, "strip", z.ZodTypeAny, {
|
|
2573
|
-
sort: "
|
|
2574
|
-
limit: number;
|
|
2573
|
+
sort: "title" | "updated_at" | "created_at";
|
|
2575
2574
|
offset: number;
|
|
2575
|
+
limit: number;
|
|
2576
2576
|
order: "asc" | "desc";
|
|
2577
|
+
tags?: string[] | undefined;
|
|
2577
2578
|
is_starred?: boolean | undefined;
|
|
2578
2579
|
is_archived?: boolean | undefined;
|
|
2579
|
-
tags?: string[] | undefined;
|
|
2580
2580
|
include_deleted?: boolean | undefined;
|
|
2581
2581
|
collection_id?: string | undefined;
|
|
2582
2582
|
}, {
|
|
2583
|
-
sort?: "created_at" | "updated_at" | "title" | undefined;
|
|
2584
|
-
is_starred?: boolean | undefined;
|
|
2585
|
-
is_archived?: boolean | undefined;
|
|
2586
2583
|
tags?: string[] | undefined;
|
|
2587
|
-
|
|
2584
|
+
sort?: "title" | "updated_at" | "created_at" | undefined;
|
|
2588
2585
|
offset?: number | undefined;
|
|
2586
|
+
limit?: number | undefined;
|
|
2587
|
+
is_starred?: boolean | undefined;
|
|
2588
|
+
is_archived?: boolean | undefined;
|
|
2589
2589
|
order?: "asc" | "desc" | undefined;
|
|
2590
2590
|
include_deleted?: boolean | undefined;
|
|
2591
2591
|
collection_id?: string | undefined;
|
|
@@ -2599,12 +2599,12 @@ declare const ManageTagsInputSchema: z.ZodObject<{
|
|
|
2599
2599
|
tag: z.ZodOptional<z.ZodString>;
|
|
2600
2600
|
}, "strip", z.ZodTypeAny, {
|
|
2601
2601
|
action: "add" | "remove" | "list_for_note" | "list_all";
|
|
2602
|
-
note_id?: string | undefined;
|
|
2603
2602
|
tag?: string | undefined;
|
|
2603
|
+
note_id?: string | undefined;
|
|
2604
2604
|
}, {
|
|
2605
2605
|
action: "add" | "remove" | "list_for_note" | "list_all";
|
|
2606
|
-
note_id?: string | undefined;
|
|
2607
2606
|
tag?: string | undefined;
|
|
2607
|
+
note_id?: string | undefined;
|
|
2608
2608
|
}>;
|
|
2609
2609
|
type ManageTagsInput = z.infer<typeof ManageTagsInputSchema>;
|
|
2610
2610
|
interface ManageTagsResult {
|
|
@@ -2626,17 +2626,17 @@ declare const ManageCollectionsInputSchema: z.ZodObject<{
|
|
|
2626
2626
|
note_id: z.ZodOptional<z.ZodString>;
|
|
2627
2627
|
}, "strip", z.ZodTypeAny, {
|
|
2628
2628
|
action: "create" | "delete" | "list" | "assign" | "unassign" | "list_tree";
|
|
2629
|
-
collection_id?: string | undefined;
|
|
2630
|
-
note_id?: string | undefined;
|
|
2631
2629
|
name?: string | undefined;
|
|
2632
2630
|
description?: string | undefined;
|
|
2631
|
+
collection_id?: string | undefined;
|
|
2632
|
+
note_id?: string | undefined;
|
|
2633
2633
|
parent_id?: string | undefined;
|
|
2634
2634
|
}, {
|
|
2635
2635
|
action: "create" | "delete" | "list" | "assign" | "unassign" | "list_tree";
|
|
2636
|
-
collection_id?: string | undefined;
|
|
2637
|
-
note_id?: string | undefined;
|
|
2638
2636
|
name?: string | undefined;
|
|
2639
2637
|
description?: string | undefined;
|
|
2638
|
+
collection_id?: string | undefined;
|
|
2639
|
+
note_id?: string | undefined;
|
|
2640
2640
|
parent_id?: string | undefined;
|
|
2641
2641
|
}>;
|
|
2642
2642
|
type ManageCollectionsInput = z.infer<typeof ManageCollectionsInputSchema>;
|
|
@@ -3578,10 +3578,19 @@ declare function packTarGz(files: Map<string, Uint8Array>): Uint8Array;
|
|
|
3578
3578
|
/**
|
|
3579
3579
|
* Unpack a gzip-compressed tar archive.
|
|
3580
3580
|
*
|
|
3581
|
+
* Before decompressing, the gzip ISIZE footer (declared uncompressed size) is
|
|
3582
|
+
* checked against `maxDecompressedBytes` and rejected if it exceeds the cap.
|
|
3583
|
+
* fflate independently verifies the actual output length against ISIZE, so a
|
|
3584
|
+
* lying footer fails during decompression — together this bounds the memory a
|
|
3585
|
+
* malicious archive can force us to allocate.
|
|
3586
|
+
*
|
|
3581
3587
|
* @param data Compressed archive bytes
|
|
3588
|
+
* @param opts.maxDecompressedBytes Cap on decompressed size (default 256 MiB)
|
|
3582
3589
|
* @returns Map of filename → file contents
|
|
3583
3590
|
*/
|
|
3584
|
-
declare function unpackTarGz(data: Uint8Array
|
|
3591
|
+
declare function unpackTarGz(data: Uint8Array, opts?: {
|
|
3592
|
+
maxDecompressedBytes?: number;
|
|
3593
|
+
}): Map<string, Uint8Array>;
|
|
3585
3594
|
|
|
3586
3595
|
/**
|
|
3587
3596
|
* SHA-256 checksum utilities for shard integrity verification.
|
|
@@ -3595,6 +3604,15 @@ declare function sha256Hex(data: Uint8Array): Promise<string>;
|
|
|
3595
3604
|
/**
|
|
3596
3605
|
* Validate checksums listed in a shard manifest against actual file contents.
|
|
3597
3606
|
*
|
|
3607
|
+
* SECURITY (SEC7 — trust model): these checksums live *inside* the same archive
|
|
3608
|
+
* as the files they hash, so they detect **transport corruption**, not
|
|
3609
|
+
* **tampering**. An attacker who controls the archive controls both the file
|
|
3610
|
+
* bytes and the manifest hashes, so a passing result proves the archive is
|
|
3611
|
+
* internally consistent — nothing more. For provenance-sensitive imports, verify
|
|
3612
|
+
* integrity out-of-band: a signed manifest, or a caller-supplied expected digest
|
|
3613
|
+
* checked against the whole archive (see `prefetchShard`'s `expectedSha256`,
|
|
3614
|
+
* which is real integrity because the hash arrives on a separate channel).
|
|
3615
|
+
*
|
|
3598
3616
|
* @returns Object with `valid` flag and list of failed filenames.
|
|
3599
3617
|
*/
|
|
3600
3618
|
declare function validateChecksums(checksums: Record<string, string>, files: Map<string, Uint8Array>): Promise<{
|
|
@@ -3803,6 +3821,6 @@ declare function getPrefetchedSha256(url: string): string | undefined;
|
|
|
3803
3821
|
*/
|
|
3804
3822
|
declare function clearPrefetchedShard(url?: string): void;
|
|
3805
3823
|
|
|
3806
|
-
declare const VERSION = "2026.7.
|
|
3824
|
+
declare const VERSION = "2026.7.3";
|
|
3807
3825
|
|
|
3808
3826
|
export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, type AttachmentRow, AttachmentsRepository, type BackendCandidate, type BackendCapabilities, type BackendConcept, type BackendLink, type BackendListOptions, type BackendNote, type BackendNoteFull, type BackendProvenanceEdge, type BackendRequest, type BackendSearchHit, type BackendSearchQueryOptions, type BackendSearchResult, type BackendSelection, type BackendSemanticTier, type BackendStartupCost, type BlobStore, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionRow, CollectionsRepository, CommunitiesRepository, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConflictStrategy, type CooldownConfig, type CooldownEvent, type CosineSemanticProviderOptions, type CreatePGliteOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DB_SNAPSHOT_SCHEMA_VERSION, type DataBackend, type DatabaseClient, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, type EmbeddingCompatibilityPolicy, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EnqueueJobInput, type ErrorCategory, type EventMap, type ExportOptions, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, type ImportCounts, type ImportOptions, type ImportProgress, type ImportProgressPhase, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, LOCAL_ENDPOINTS, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryBlobStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteRevision, type NoteSkosTag, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, type OpenShardOptions, type PGliteBackendOptions, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type ProbeResult, type ProbeStatus, type ProvenanceEdge, ProvenanceRepository, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type RecordProvenanceInput, type RemoteBackendConfig, type RemoteBackendPaths, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SHARD_FORMAT, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardBackendOptions, type ShardClusterRef, type ShardCollection, type ShardComponent, type ShardComponentStore, type ShardEmbedding, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLayout, type ShardLink, type ShardListOptions, type ShardManifest, type ShardNote, type ShardNoteFull, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VectorEntry, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRemoteBackend, createRoutes, createShardBackend, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dumpDbSnapshot, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, fromPrefetched, generateId, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, provenanceEdgeToShard, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateChecksums, verifyDbSnapshotMeta, verifySri };
|
package/dist/index.js
CHANGED
|
@@ -6546,8 +6546,25 @@ function packTarGz(files) {
|
|
|
6546
6546
|
const tarData = encodeTar(files);
|
|
6547
6547
|
return gzipSync(tarData);
|
|
6548
6548
|
}
|
|
6549
|
-
|
|
6549
|
+
var DEFAULT_MAX_DECOMPRESSED_BYTES = 256 * 1024 * 1024;
|
|
6550
|
+
function unpackTarGz(data, opts) {
|
|
6551
|
+
const cap = opts?.maxDecompressedBytes ?? DEFAULT_MAX_DECOMPRESSED_BYTES;
|
|
6552
|
+
if (data.byteLength < 18) {
|
|
6553
|
+
throw new Error("Invalid gzip archive: too short");
|
|
6554
|
+
}
|
|
6555
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
6556
|
+
const declaredSize = view.getUint32(data.byteLength - 4, true);
|
|
6557
|
+
if (declaredSize > cap) {
|
|
6558
|
+
throw new Error(
|
|
6559
|
+
"Refusing to decompress archive: declared size " + declaredSize + " exceeds cap " + cap + " bytes"
|
|
6560
|
+
);
|
|
6561
|
+
}
|
|
6550
6562
|
const tarData = gunzipSync(data);
|
|
6563
|
+
if (tarData.byteLength > cap) {
|
|
6564
|
+
throw new Error(
|
|
6565
|
+
"Refusing to decompress archive: decompressed size " + tarData.byteLength + " exceeds cap " + cap + " bytes"
|
|
6566
|
+
);
|
|
6567
|
+
}
|
|
6551
6568
|
return decodeTar(tarData);
|
|
6552
6569
|
}
|
|
6553
6570
|
|
|
@@ -7174,6 +7191,8 @@ async function importShard(db, data, options) {
|
|
|
7174
7191
|
const report = options?.onProgress;
|
|
7175
7192
|
const warnings = [];
|
|
7176
7193
|
const errors = [];
|
|
7194
|
+
let droppedAttachmentCount = 0;
|
|
7195
|
+
let notesWithDroppedAttachments = 0;
|
|
7177
7196
|
const counts = {
|
|
7178
7197
|
notes: 0,
|
|
7179
7198
|
collections: 0,
|
|
@@ -7408,10 +7427,19 @@ async function importShard(db, data, options) {
|
|
|
7408
7427
|
[generateId(), note.id, tag]
|
|
7409
7428
|
);
|
|
7410
7429
|
}
|
|
7430
|
+
if (note.binary_sources?.length) {
|
|
7431
|
+
droppedAttachmentCount += note.binary_sources.length;
|
|
7432
|
+
notesWithDroppedAttachments++;
|
|
7433
|
+
}
|
|
7411
7434
|
counts.notes++;
|
|
7412
7435
|
report?.({ phase: "notes", done: index + 1, total: parsedNotes.length });
|
|
7413
7436
|
await maybeYield2(index + 1, batchSize);
|
|
7414
7437
|
}
|
|
7438
|
+
if (droppedAttachmentCount > 0) {
|
|
7439
|
+
warnings.push(
|
|
7440
|
+
`${droppedAttachmentCount} attachment(s) across ${notesWithDroppedAttachments} note(s) were not imported: shards currently carry attachment references (metadata + checksum) but not the binary content, so attachment bytes cannot be restored. Tracking: #237 (attachment round-trip) / server #1013 (binary contract).`
|
|
7441
|
+
);
|
|
7442
|
+
}
|
|
7415
7443
|
const totalSkos = parsedSkosSchemes.length + parsedSkosConcepts.length + parsedSkosRelations.length + parsedNoteSkosTags.length;
|
|
7416
7444
|
let doneSkos = 0;
|
|
7417
7445
|
report?.({ phase: "skos", done: doneSkos, total: totalSkos });
|
|
@@ -7688,6 +7716,11 @@ function parseJsonArray(data) {
|
|
|
7688
7716
|
|
|
7689
7717
|
// src/shard/shard-reader.ts
|
|
7690
7718
|
var decoder2 = new TextDecoder();
|
|
7719
|
+
function assertSafeComponentName(filename) {
|
|
7720
|
+
if (filename.length === 0 || filename.startsWith("/") || filename.includes("\\") || filename.includes("\0") || filename.includes(":") || filename.split("/").some((segment) => segment === "..")) {
|
|
7721
|
+
throw new Error(`Refusing to read unsafe shard component path: ${JSON.stringify(filename)}`);
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7691
7724
|
function parseJsonlBytes(data) {
|
|
7692
7725
|
if (!data || data.byteLength === 0) return [];
|
|
7693
7726
|
return decoder2.decode(data).split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
@@ -7723,6 +7756,7 @@ var UrlComponentStore = class {
|
|
|
7723
7756
|
this.manifest = manifest;
|
|
7724
7757
|
}
|
|
7725
7758
|
async read(filename) {
|
|
7759
|
+
assertSafeComponentName(filename);
|
|
7726
7760
|
if (this.cache.has(filename)) return this.cache.get(filename);
|
|
7727
7761
|
const response = await this.fetchImpl(`${this.baseUrl}/${filename}`);
|
|
7728
7762
|
if (!response.ok) {
|
|
@@ -8194,6 +8228,16 @@ var AIWG_SCAN_REQUIRED_FIELDS = [
|
|
|
8194
8228
|
"concepts",
|
|
8195
8229
|
"privacy"
|
|
8196
8230
|
];
|
|
8231
|
+
function isPrivacyExcluded(record, options) {
|
|
8232
|
+
const privacy = record.privacy;
|
|
8233
|
+
if (!privacy) return false;
|
|
8234
|
+
if (privacy.classification === "private" && !options?.includePrivate) return true;
|
|
8235
|
+
if (privacy.pii && !options?.includePii) return true;
|
|
8236
|
+
return false;
|
|
8237
|
+
}
|
|
8238
|
+
function filterAiwgRecordsByPrivacy(records, options) {
|
|
8239
|
+
return records.filter((record) => !isPrivacyExcluded(record, options));
|
|
8240
|
+
}
|
|
8197
8241
|
var REQUIRED_RECORD_FIELDS = [
|
|
8198
8242
|
"schema_version",
|
|
8199
8243
|
"id",
|
|
@@ -8220,8 +8264,12 @@ function hasString(value) {
|
|
|
8220
8264
|
return typeof value === "string" && value.length > 0;
|
|
8221
8265
|
}
|
|
8222
8266
|
function pushFacet(counts, name, value) {
|
|
8223
|
-
counts[name]
|
|
8224
|
-
|
|
8267
|
+
let bucket = counts[name];
|
|
8268
|
+
if (bucket === void 0) {
|
|
8269
|
+
bucket = /* @__PURE__ */ Object.create(null);
|
|
8270
|
+
counts[name] = bucket;
|
|
8271
|
+
}
|
|
8272
|
+
bucket[value] = (bucket[value] ?? 0) + 1;
|
|
8225
8273
|
}
|
|
8226
8274
|
function hasNonNegativeInteger(value) {
|
|
8227
8275
|
return Number.isInteger(value) && typeof value === "number" && value >= 0;
|
|
@@ -8343,6 +8391,57 @@ function validateOptionalRichMetadata(item, index, errors) {
|
|
|
8343
8391
|
errors.push("items[" + index + "].compatibility must be an object");
|
|
8344
8392
|
}
|
|
8345
8393
|
}
|
|
8394
|
+
function isPrivacyClassification(value) {
|
|
8395
|
+
return value === "private" || value === "sanitized" || value === "public";
|
|
8396
|
+
}
|
|
8397
|
+
function isProvenanceConfidence(value) {
|
|
8398
|
+
return value === "source" || value === "candidate" || value === "reviewed" || value === "rejected";
|
|
8399
|
+
}
|
|
8400
|
+
function validateProvenanceItems(item, index, errors) {
|
|
8401
|
+
if (!Array.isArray(item.provenance)) return;
|
|
8402
|
+
for (const [provIndex, prov] of item.provenance.entries()) {
|
|
8403
|
+
const at = "items[" + index + "].provenance[" + provIndex + "]";
|
|
8404
|
+
if (!isPlainRecord(prov)) {
|
|
8405
|
+
errors.push(at + " must be an object");
|
|
8406
|
+
continue;
|
|
8407
|
+
}
|
|
8408
|
+
if (!hasString(prov.field)) errors.push(at + ".field is required");
|
|
8409
|
+
if (!hasString(prov.source)) errors.push(at + ".source is required");
|
|
8410
|
+
if (!hasString(prov.path)) errors.push(at + ".path is required");
|
|
8411
|
+
if (!isProvenanceConfidence(prov.confidence)) errors.push(at + ".confidence must be one of source, candidate, reviewed, rejected");
|
|
8412
|
+
if (!isPrivacyClassification(prov.privacy)) errors.push(at + ".privacy must be one of private, sanitized, public");
|
|
8413
|
+
}
|
|
8414
|
+
}
|
|
8415
|
+
var V2_ONLY_RECORD_FIELDS = ["search", "chunks", "embeddings", "skos_concepts", "skos_relations", "compatibility"];
|
|
8416
|
+
var V2_ONLY_SOURCE_FIELDS = ["origin", "generated", "checksum", "updated_at"];
|
|
8417
|
+
var V2_ONLY_RELATIONSHIP_FIELDS = ["target_path", "direction", "metadata"];
|
|
8418
|
+
function forbidV2FieldsOnV1Record(item, index, errors) {
|
|
8419
|
+
if (item.schema_version !== "aiwg.fortemi.index.record.v1") return;
|
|
8420
|
+
const at = "items[" + index + "]";
|
|
8421
|
+
const bag = item;
|
|
8422
|
+
const v2msg = " is a v2-only field and must be absent on a record.v1 record";
|
|
8423
|
+
for (const field of V2_ONLY_RECORD_FIELDS) {
|
|
8424
|
+
if (bag[field] !== void 0) errors.push(at + "." + field + v2msg);
|
|
8425
|
+
}
|
|
8426
|
+
if (isPlainRecord(item.source)) {
|
|
8427
|
+
const src = item.source;
|
|
8428
|
+
for (const field of V2_ONLY_SOURCE_FIELDS) {
|
|
8429
|
+
if (src[field] !== void 0) errors.push(at + ".source." + field + v2msg);
|
|
8430
|
+
}
|
|
8431
|
+
}
|
|
8432
|
+
if (isPlainRecord(item.privacy) && item.privacy.locality !== void 0) {
|
|
8433
|
+
errors.push(at + ".privacy.locality" + v2msg);
|
|
8434
|
+
}
|
|
8435
|
+
if (Array.isArray(item.relationships)) {
|
|
8436
|
+
for (const [relIndex, rel] of item.relationships.entries()) {
|
|
8437
|
+
if (!isPlainRecord(rel)) continue;
|
|
8438
|
+
const relBag = rel;
|
|
8439
|
+
for (const field of V2_ONLY_RELATIONSHIP_FIELDS) {
|
|
8440
|
+
if (relBag[field] !== void 0) errors.push(at + ".relationships[" + relIndex + "]." + field + v2msg);
|
|
8441
|
+
}
|
|
8442
|
+
}
|
|
8443
|
+
}
|
|
8444
|
+
}
|
|
8346
8445
|
function validateAiwgFortemiIndexExport(value) {
|
|
8347
8446
|
const errors = [];
|
|
8348
8447
|
const counts = {};
|
|
@@ -8353,10 +8452,21 @@ function validateAiwgFortemiIndexExport(value) {
|
|
|
8353
8452
|
if (!hasString(data?.generated_at)) errors.push("generated_at is required");
|
|
8354
8453
|
if (!hasString(data?.source?.repo)) errors.push("source.repo is required");
|
|
8355
8454
|
if (!hasString(data?.source?.privacy)) errors.push("source.privacy is required");
|
|
8455
|
+
else if (!isPrivacyClassification(data?.source?.privacy)) {
|
|
8456
|
+
errors.push("source.privacy must be one of private, sanitized, public");
|
|
8457
|
+
}
|
|
8356
8458
|
if (!Array.isArray(data?.items)) errors.push("items must be an array");
|
|
8357
8459
|
if (data.compatibility !== void 0 && !isPlainRecord(data.compatibility)) {
|
|
8358
8460
|
errors.push("compatibility must be an object");
|
|
8359
8461
|
}
|
|
8462
|
+
if (data?.schema_version === "aiwg.fortemi.index.export.v1") {
|
|
8463
|
+
if (isPlainRecord(data.source) && data.source.graph !== void 0) {
|
|
8464
|
+
errors.push("source.graph is a v2-only field and must be absent on an export.v1 export");
|
|
8465
|
+
}
|
|
8466
|
+
if (data.compatibility !== void 0) {
|
|
8467
|
+
errors.push("compatibility is a v2-only field and must be absent on an export.v1 export");
|
|
8468
|
+
}
|
|
8469
|
+
}
|
|
8360
8470
|
const ids = /* @__PURE__ */ new Set();
|
|
8361
8471
|
let previousId = "";
|
|
8362
8472
|
for (const [index, item] of (data.items ?? []).entries()) {
|
|
@@ -8391,8 +8501,12 @@ function validateAiwgFortemiIndexExport(value) {
|
|
|
8391
8501
|
errors.push("items[" + index + "].provenance must be a non-empty array");
|
|
8392
8502
|
}
|
|
8393
8503
|
validateOptionalRichMetadata(item, index, errors);
|
|
8504
|
+
validateProvenanceItems(item, index, errors);
|
|
8505
|
+
forbidV2FieldsOnV1Record(item, index, errors);
|
|
8394
8506
|
if (!item.privacy || typeof item.privacy.pii !== "boolean" || !hasString(item.privacy.classification)) {
|
|
8395
8507
|
errors.push("items[" + index + "].privacy requires classification and pii");
|
|
8508
|
+
} else if (!isPrivacyClassification(item.privacy.classification)) {
|
|
8509
|
+
errors.push("items[" + index + "].privacy.classification must be one of private, sanitized, public");
|
|
8396
8510
|
}
|
|
8397
8511
|
}
|
|
8398
8512
|
return { valid: errors.length === 0, errors, counts };
|
|
@@ -8413,6 +8527,9 @@ function validateAiwgFortemiChunkManifest(value) {
|
|
|
8413
8527
|
if (!hasString(data?.generated_at)) errors.push("generated_at is required");
|
|
8414
8528
|
if (!hasString(data?.source?.repo)) errors.push("source.repo is required");
|
|
8415
8529
|
if (!hasString(data?.source?.privacy)) errors.push("source.privacy is required");
|
|
8530
|
+
if (data?.source_export_schema_version !== void 0 && !isSupportedIndexSchemaVersion(data.source_export_schema_version)) {
|
|
8531
|
+
errors.push("source_export_schema_version must be aiwg.fortemi.index.export.v1 or aiwg.fortemi.index.export.v2 when present");
|
|
8532
|
+
}
|
|
8416
8533
|
if (!hasNonNegativeInteger(data?.total)) errors.push("total must be a non-negative integer");
|
|
8417
8534
|
if (!hasPositiveInteger(data?.part_size)) errors.push("part_size must be a positive integer");
|
|
8418
8535
|
if (data.facets !== void 0 && !isFacetCounts(data.facets)) {
|
|
@@ -8531,9 +8648,35 @@ function assertAiwgFortemiChunkPart(value, partRef, manifest) {
|
|
|
8531
8648
|
}
|
|
8532
8649
|
return value;
|
|
8533
8650
|
}
|
|
8651
|
+
var ALLOWED_AIWG_FETCH_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "blob:", "data:"]);
|
|
8652
|
+
function tryParseUrl(value) {
|
|
8653
|
+
try {
|
|
8654
|
+
return new URL(value);
|
|
8655
|
+
} catch {
|
|
8656
|
+
return null;
|
|
8657
|
+
}
|
|
8658
|
+
}
|
|
8659
|
+
function resolveAiwgFetchUrl(href, baseUrl) {
|
|
8660
|
+
if (baseUrl === void 0) {
|
|
8661
|
+
const absolute = tryParseUrl(href);
|
|
8662
|
+
if (absolute && !ALLOWED_AIWG_FETCH_SCHEMES.has(absolute.protocol)) {
|
|
8663
|
+
throw new Error("Refusing AIWG index fetch with disallowed scheme: " + absolute.protocol);
|
|
8664
|
+
}
|
|
8665
|
+
return href;
|
|
8666
|
+
}
|
|
8667
|
+
const base = new URL(baseUrl);
|
|
8668
|
+
const resolved = new URL(href, base);
|
|
8669
|
+
if (!ALLOWED_AIWG_FETCH_SCHEMES.has(resolved.protocol)) {
|
|
8670
|
+
throw new Error("Refusing AIWG index fetch with disallowed scheme: " + resolved.protocol);
|
|
8671
|
+
}
|
|
8672
|
+
if (resolved.origin !== base.origin) {
|
|
8673
|
+
throw new Error("Refusing cross-origin AIWG index fetch: " + resolved.origin + " != " + base.origin);
|
|
8674
|
+
}
|
|
8675
|
+
return resolved.toString();
|
|
8676
|
+
}
|
|
8534
8677
|
function createAiwgFetchChunkLoader(baseUrl) {
|
|
8535
8678
|
return async (part) => {
|
|
8536
|
-
const href =
|
|
8679
|
+
const href = resolveAiwgFetchUrl(part.href, baseUrl);
|
|
8537
8680
|
const response = await fetch(href);
|
|
8538
8681
|
if (!response.ok) throw new Error("Failed to fetch AIWG index chunk " + href + ": " + response.status);
|
|
8539
8682
|
return response.json();
|
|
@@ -8553,14 +8696,14 @@ function createAiwgFetchDetailLoader(baseUrl) {
|
|
|
8553
8696
|
return async (id, manifest) => {
|
|
8554
8697
|
if (!manifest.detail?.href) throw new Error("Manifest has no detail.href for record resolution");
|
|
8555
8698
|
const relative = aiwgDetailHrefForId(manifest.detail, id);
|
|
8556
|
-
const href =
|
|
8699
|
+
const href = resolveAiwgFetchUrl(relative, baseUrl);
|
|
8557
8700
|
const response = await fetch(href);
|
|
8558
8701
|
if (!response.ok) throw new Error("Failed to fetch AIWG index detail " + href + ": " + response.status);
|
|
8559
8702
|
return response.json();
|
|
8560
8703
|
};
|
|
8561
8704
|
}
|
|
8562
8705
|
function getAiwgFortemiFacets(items) {
|
|
8563
|
-
const result =
|
|
8706
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
8564
8707
|
for (const item of items) {
|
|
8565
8708
|
pushFacet(result, "type", item.type);
|
|
8566
8709
|
pushFacet(result, "privacy", item.privacy.classification);
|
|
@@ -8596,7 +8739,7 @@ function generatedAtString(value) {
|
|
|
8596
8739
|
async function buildAiwgStaticEmbeddingSet(index, options) {
|
|
8597
8740
|
assertAiwgFortemiIndexExport(index);
|
|
8598
8741
|
const granularity = options.granularity ?? "body";
|
|
8599
|
-
const records = options.records ?? index.items;
|
|
8742
|
+
const records = filterAiwgRecordsByPrivacy(options.records ?? index.items, options.privacy);
|
|
8600
8743
|
const embeddings = [];
|
|
8601
8744
|
for (const record of records) {
|
|
8602
8745
|
const input = options.textForRecord?.(record) ?? defaultEmbeddingInput(record, granularity);
|
|
@@ -8657,7 +8800,7 @@ function buildAiwgChunkedIndex(index, options = {}) {
|
|
|
8657
8800
|
const projection = options.projection;
|
|
8658
8801
|
const idEncoding = options.idEncoding ?? "base64url";
|
|
8659
8802
|
const detailHref = options.detailHref ?? "detail/{id}.json";
|
|
8660
|
-
const items = index.items;
|
|
8803
|
+
const items = filterAiwgRecordsByPrivacy(index.items, options.privacy);
|
|
8661
8804
|
const pad = (value) => String(value).padStart(4, "0");
|
|
8662
8805
|
const project = (record) => {
|
|
8663
8806
|
if (!projection) return record;
|
|
@@ -8685,6 +8828,7 @@ function buildAiwgChunkedIndex(index, options = {}) {
|
|
|
8685
8828
|
schema_version: "aiwg.fortemi.index.chunk-manifest.v1",
|
|
8686
8829
|
generated_at: options.generatedAt ?? index.generated_at,
|
|
8687
8830
|
source: index.source,
|
|
8831
|
+
source_export_schema_version: index.schema_version,
|
|
8688
8832
|
total: items.length,
|
|
8689
8833
|
part_size: partSize,
|
|
8690
8834
|
facets: getAiwgFortemiFacets(items),
|
|
@@ -8995,8 +9139,15 @@ function queryAiwgHybridIndex(index, embeddingSet, query, queryEmbedding, option
|
|
|
8995
9139
|
};
|
|
8996
9140
|
}).filter((result) => result !== null && result.score >= (options.minScore ?? -1)).sort((left, right) => right.score - left.score || left.item.id.localeCompare(right.item.id)).slice(offset, offset + limit);
|
|
8997
9141
|
}
|
|
8998
|
-
|
|
9142
|
+
var DEFAULT_AIWG_DUPLICATE_SCAN_MAX_EMBEDDINGS = 5e3;
|
|
9143
|
+
function findAiwgStaticDuplicatePairs(index, embeddingSet, threshold = 0.9, options) {
|
|
8999
9144
|
assertAiwgStaticEmbeddingSet(embeddingSet);
|
|
9145
|
+
const maxEmbeddings = options?.maxEmbeddings ?? DEFAULT_AIWG_DUPLICATE_SCAN_MAX_EMBEDDINGS;
|
|
9146
|
+
if (embeddingSet.embeddings.length > maxEmbeddings) {
|
|
9147
|
+
throw new Error(
|
|
9148
|
+
"Embedding set too large for duplicate scan: " + embeddingSet.embeddings.length + " > " + maxEmbeddings + " (raise options.maxEmbeddings to override for trusted input)"
|
|
9149
|
+
);
|
|
9150
|
+
}
|
|
9000
9151
|
const byId = new Map(index.items.map((item) => [item.id, item]));
|
|
9001
9152
|
const pairs = [];
|
|
9002
9153
|
for (let leftIndex = 0; leftIndex < embeddingSet.embeddings.length; leftIndex += 1) {
|
|
@@ -9461,7 +9612,7 @@ function createAiwgIndexController(initialIndex) {
|
|
|
9461
9612
|
notify();
|
|
9462
9613
|
},
|
|
9463
9614
|
createReviewDecisionExport(generatedAt) {
|
|
9464
|
-
const source = index ?? (chunked ? { schema_version: "aiwg.fortemi.index.export.v1" } : null);
|
|
9615
|
+
const source = index ?? (chunked ? { schema_version: chunked.manifest.source_export_schema_version ?? "aiwg.fortemi.index.export.v1" } : null);
|
|
9465
9616
|
if (!source) throw new Error("No AIWG index export or chunked manifest loaded");
|
|
9466
9617
|
return createAiwgReviewDecisionExport(source, reviewDecisions, generatedAt);
|
|
9467
9618
|
},
|
|
@@ -9518,8 +9669,8 @@ function communityIdsFor(item, options) {
|
|
|
9518
9669
|
}
|
|
9519
9670
|
|
|
9520
9671
|
// src/index.ts
|
|
9521
|
-
var VERSION = "2026.7.
|
|
9672
|
+
var VERSION = "2026.7.3";
|
|
9522
9673
|
|
|
9523
|
-
export { AIWG_SCAN_REQUIRED_FIELDS, ArchiveManager, AttachmentsRepository, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, DB_SNAPSHOT_SCHEMA_VERSION, DbSnapshotVersionError, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, 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, ProvenanceRepository, ProviderRegistry, SHARD_FORMAT, SUPPORTED_PGLITE_VERSION, SearchInputSchema, SearchRepository, SkosRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexToCommunityGraph, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRemoteBackend, createRoutes, createShardBackend, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dumpDbSnapshot, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, findAiwgStaticDuplicatePairs, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet, validateChecksums, verifyDbSnapshotMeta, verifySri };
|
|
9674
|
+
export { AIWG_SCAN_REQUIRED_FIELDS, ArchiveManager, AttachmentsRepository, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, DB_SNAPSHOT_SCHEMA_VERSION, DbSnapshotVersionError, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, 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, ProvenanceRepository, ProviderRegistry, SHARD_FORMAT, SUPPORTED_PGLITE_VERSION, SearchInputSchema, SearchRepository, SkosRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexToCommunityGraph, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRemoteBackend, createRoutes, createShardBackend, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dumpDbSnapshot, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet, validateChecksums, verifyDbSnapshotMeta, verifySri };
|
|
9524
9675
|
//# sourceMappingURL=index.js.map
|
|
9525
9676
|
//# sourceMappingURL=index.js.map
|