@fortemi/core 2026.7.10 → 2026.7.11
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.js +12 -12
- package/dist/aiwg-index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +96 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5066,6 +5066,8 @@ interface CollectionRecord {
|
|
|
5066
5066
|
id: string;
|
|
5067
5067
|
name: string;
|
|
5068
5068
|
description: string | null;
|
|
5069
|
+
/** Omitted only by legacy schema-v1 callers; built-in stores normalize it to null. */
|
|
5070
|
+
parent_id?: string | null;
|
|
5069
5071
|
created_at: string;
|
|
5070
5072
|
updated_at: string;
|
|
5071
5073
|
deleted_at: string | null;
|
|
@@ -5224,7 +5226,7 @@ declare class MemoryRecordStore implements RecordStore {
|
|
|
5224
5226
|
*/
|
|
5225
5227
|
|
|
5226
5228
|
/** Logical record-schema version stored in `meta` (independent of DB_VERSION). */
|
|
5227
|
-
declare const RECORD_SCHEMA_VERSION =
|
|
5229
|
+
declare const RECORD_SCHEMA_VERSION = 2;
|
|
5228
5230
|
interface CreateRecordStoreOptions {
|
|
5229
5231
|
/** Injectable factory for tests (fake-indexeddb). Defaults to the global. */
|
|
5230
5232
|
indexedDB?: IDBFactory;
|
|
@@ -5304,7 +5306,7 @@ declare class CanonicalNotesRepository {
|
|
|
5304
5306
|
softDeleteLink(linkId: string): Promise<void>;
|
|
5305
5307
|
/** Active links touching a note (either direction). */
|
|
5306
5308
|
linksOf(noteId: string): Promise<LinkRecord0[]>;
|
|
5307
|
-
createCollection(name: string, description?: string): Promise<CollectionRecord>;
|
|
5309
|
+
createCollection(name: string, description?: string, parentId?: string | null): Promise<CollectionRecord>;
|
|
5308
5310
|
addNoteToCollection(collectionId: string, noteId: string): Promise<void>;
|
|
5309
5311
|
notesInCollection(collectionId: string): Promise<NoteRecord0[]>;
|
|
5310
5312
|
}
|
|
@@ -5520,6 +5522,6 @@ declare function importShardToRecords(store: RecordStore, data: Uint8Array | Arr
|
|
|
5520
5522
|
* @created 2026-07-17
|
|
5521
5523
|
* @agent Codex
|
|
5522
5524
|
*/
|
|
5523
|
-
declare const VERSION = "2026.7.
|
|
5525
|
+
declare const VERSION = "2026.7.11";
|
|
5524
5526
|
|
|
5525
5527
|
export { AIWG_SCAN_REQUIRED_FIELDS, type AiwgChunkedIndexBuildOptions, type AiwgChunkedIndexBuildResult, type AiwgChunkedIndexDetailLoader, type AiwgChunkedIndexLoadOptions, type AiwgChunkedIndexLoader, type AiwgChunkedIndexProgress, type AiwgChunkedIndexProgressPhase, type AiwgChunkedIndexQueryOptions, type AiwgChunkedIndexQueryResult, type AiwgChunkedIndexValidationResult, type AiwgFortemiAttachmentReference, type AiwgFortemiBinarySource, type AiwgFortemiChunk, type AiwgFortemiChunkDetailRef, type AiwgFortemiChunkManifest, type AiwgFortemiChunkPart, type AiwgFortemiChunkPartRef, type AiwgFortemiIndexExport, type AiwgFortemiIndexExportSchemaVersion, type AiwgFortemiProjectedRecord, type AiwgFortemiProvenance, type AiwgFortemiProvenanceEvent, type AiwgFortemiRecord, type AiwgFortemiRecordEmbedding, type AiwgFortemiRecordSchemaVersion, type AiwgFortemiRecordSource, type AiwgFortemiRecordType, type AiwgFortemiRelationship, type AiwgFortemiRelationshipDirection, type AiwgFortemiSearchProjection, type AiwgFortemiSkosConcept, type AiwgFortemiSkosRelation, type AiwgFortemiSkosRelationType, type AiwgHeadlessEmbeddingBackend, type AiwgIndexController, type AiwgIndexControllerListener, type AiwgIndexControllerSnapshot, type AiwgIndexGraphOptions, type AiwgIndexQueryMatch, type AiwgIndexQueryOptions, type AiwgIndexQueryRankedItem, type AiwgIndexQueryResult, type AiwgIndexQueryWeights, type AiwgIndexValidationResult, type AiwgKnowledgeShardOptions, type AiwgPrivacyClassification, type AiwgPrivacyFilterOptions, type AiwgProvenanceConfidence, type AiwgRelationshipDirection, type AiwgRelationshipEdgeSummary, type AiwgRelationshipNodeSummary, type AiwgRelationshipQueryOptions, type AiwgRelationshipSetOperation, type AiwgRelationshipSetOptions, type AiwgRelationshipSetResult, type AiwgRelationshipTraversalOptions, type AiwgRelationshipTraversalResult, type AiwgReviewAction, type AiwgReviewDecision, type AiwgReviewDecisionExport, type AiwgReviewInput, type AiwgStaticDuplicatePair, type AiwgStaticEmbeddingRecord, type AiwgStaticEmbeddingSet, type AiwgStaticHybridQueryOptions, type AiwgStaticSemanticQueryOptions, type AiwgStaticSemanticResult, AllowlistTrustStore, type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRecord, type AttachmentBlobRow, type AttachmentProjectionResult, type AttachmentRecord, 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 BlobBackendKind, type BlobGcOptions, type BlobGcResult, type BlobReconcileOptions, type BlobReconcileResult, type BlobStore, type BlobStoreDiagnostics, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, type BuildAiwgStaticEmbeddingSetOptions, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, type CanonicalAttachInput, CanonicalAttachmentsRepository, type CanonicalNoteCreateInput, type CanonicalNoteUpdateInput, type CanonicalNoteView, CanonicalNotesRepository, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionNoteRecord, type CollectionRecord, 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 CreateBlobStoreOptions, type CreatePGliteOptions, type CreateRecordStoreOptions, 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, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FetchFortemiCompatibilityOptions, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiCompatibilityCapability, type FortemiCompatibilityResponse, type FortemiCompatibilityState, type FortemiCompatibilityValidationResult, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiRequiredCompatibilityCapability, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, IdbRecordStore, 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, type JournalEntry, type KnowledgeShardProfile, LOCAL_ENDPOINTS, type LegacyMigrationReport, type LinkRecord0, 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, MemoryRecordStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteOriginalRecord, type NoteProjectionResult, type NoteRecord0, type NoteRevisedCurrentRecord, type NoteRevision, type NoteSkosTag, type NoteSummary, type NoteTagRecord, 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, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, type RecommendedTier, type RecordBackendManageNoteResult, type RecordBackendOptions, type RecordCollectionName, type RecordCollections, type RecordListOptions, type RecordMutation, type RecordProjectionResult, type RecordProvenanceInput, type RecordStore, type RecordStoreCapabilities, type RemoteBackendConfig, type RemoteBackendPaths, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SHARD_FORMAT, SIGNATURE_ENTRY, SIGNING_ENVELOPE_VERSION, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardAuthorityStatus, type ShardBackend, type ShardBackendOptions, type ShardCapabilityReport, type ShardClusterRef, type ShardCollection, type ShardComponent, type ShardComponentStore, type ShardEmbedding, type ShardEmbeddingConfig, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardExportResult, type ShardLayout, type ShardLink, type ShardListOptions, type ShardLossEntry, type ShardManifest, type ShardNote, type ShardNoteFull, type ShardNoteSkosTag, type ShardOperation, type ShardProfileRegistryEntry, type ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, type ShardSignatureEnvelope, type ShardSignatureVerdict, type ShardSigner, type ShardSigningPayload, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type ShardTemplate, type ShardTrustStore, type SignShardInput, 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, type TrustedKey, TypedEventBus, VERSION, type VectorEntry, type VerifyShardSignatureInput, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, aiwgFortemiIndexFromKnowledgeShard, aiwgFortemiIndexToCommunityGraph, aiwgFortemiIndexToKnowledgeShard, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, assertShardComponentRecord, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeBlobHash, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLazyBlobStore, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, importShardToRecords, isPluginScriptAllowed, isShardPrefetched, isShardSigningSupported, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, migrateLegacyBlobStore, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, sidecarBlobDigests, signShard, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, urlLinkToShard, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet, validateChecksums, validateCoreV1ShardArchive, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifyShardSignature, verifySri };
|
package/dist/index.js
CHANGED
|
@@ -7664,7 +7664,7 @@ function createTarHeader(filename, size) {
|
|
|
7664
7664
|
writeOctal(header, 108, 0, 8);
|
|
7665
7665
|
writeOctal(header, 116, 0, 8);
|
|
7666
7666
|
writeOctal(header, 124, size, 12);
|
|
7667
|
-
writeOctal(header, 136,
|
|
7667
|
+
writeOctal(header, 136, 0, 12);
|
|
7668
7668
|
header[156] = 48;
|
|
7669
7669
|
writeString(header, 257, USTAR_MAGIC, 8);
|
|
7670
7670
|
const checksum = computeHeaderChecksum(header);
|
|
@@ -7736,7 +7736,7 @@ function packTarGz(files, opts) {
|
|
|
7736
7736
|
"Refusing to create archive: uncompressed size " + tarData.byteLength + " exceeds cap " + cap + " bytes"
|
|
7737
7737
|
);
|
|
7738
7738
|
}
|
|
7739
|
-
return gzipSync(tarData);
|
|
7739
|
+
return gzipSync(tarData, { mtime: 0 });
|
|
7740
7740
|
}
|
|
7741
7741
|
var DEFAULT_MAX_DECOMPRESSED_BYTES = 256 * 1024 * 1024;
|
|
7742
7742
|
function unpackTarGz(data, opts) {
|
|
@@ -14516,6 +14516,22 @@ function coreReferenceErrors(records) {
|
|
|
14516
14516
|
errors.push(`collections.json[${index}] parent_id does not reference a declared collection`);
|
|
14517
14517
|
}
|
|
14518
14518
|
}
|
|
14519
|
+
const collectionById = new Map(collections.map((collection) => [collection.id, collection]));
|
|
14520
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
14521
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14522
|
+
const visitCollection = (collection) => {
|
|
14523
|
+
if (visited.has(collection.id)) return;
|
|
14524
|
+
if (visiting.has(collection.id)) {
|
|
14525
|
+
errors.push(`collection hierarchy contains a cycle at ${String(collection.id)}`);
|
|
14526
|
+
return;
|
|
14527
|
+
}
|
|
14528
|
+
visiting.add(collection.id);
|
|
14529
|
+
const parent = collection.parent_id === null ? void 0 : collectionById.get(collection.parent_id);
|
|
14530
|
+
if (parent) visitCollection(parent);
|
|
14531
|
+
visiting.delete(collection.id);
|
|
14532
|
+
visited.add(collection.id);
|
|
14533
|
+
};
|
|
14534
|
+
for (const collection of collections) visitCollection(collection);
|
|
14519
14535
|
for (const [index, note] of notes.entries()) {
|
|
14520
14536
|
if (note.collection_id !== null && !collectionIds.has(note.collection_id)) {
|
|
14521
14537
|
errors.push(`notes.jsonl[${index}] collection_id does not reference a declared collection`);
|
|
@@ -20200,6 +20216,18 @@ var RECORD_STORE_CAPABILITIES = {
|
|
|
20200
20216
|
vectorSearch: false,
|
|
20201
20217
|
sqlJoins: false
|
|
20202
20218
|
};
|
|
20219
|
+
function normalizeRecordMutation(mutation) {
|
|
20220
|
+
if (mutation.op === "put" && mutation.collection === "collection") {
|
|
20221
|
+
return {
|
|
20222
|
+
...mutation,
|
|
20223
|
+
record: {
|
|
20224
|
+
...mutation.record,
|
|
20225
|
+
parent_id: mutation.record.parent_id ?? null
|
|
20226
|
+
}
|
|
20227
|
+
};
|
|
20228
|
+
}
|
|
20229
|
+
return mutation;
|
|
20230
|
+
}
|
|
20203
20231
|
|
|
20204
20232
|
// src/records/memory-record-store.ts
|
|
20205
20233
|
var MemoryRecordStore = class {
|
|
@@ -20245,7 +20273,8 @@ var MemoryRecordStore = class {
|
|
|
20245
20273
|
}
|
|
20246
20274
|
return records;
|
|
20247
20275
|
};
|
|
20248
|
-
for (const
|
|
20276
|
+
for (const rawMutation of mutations) {
|
|
20277
|
+
const mutation = normalizeRecordMutation(rawMutation);
|
|
20249
20278
|
const entry = mutation.op === "put" ? {
|
|
20250
20279
|
seq: ++stagedSeq,
|
|
20251
20280
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -20292,7 +20321,7 @@ var MemoryRecordStore = class {
|
|
|
20292
20321
|
var DB_VERSION = 1;
|
|
20293
20322
|
var JOURNAL_STORE = "journal";
|
|
20294
20323
|
var META_STORE = "meta";
|
|
20295
|
-
var RECORD_SCHEMA_VERSION =
|
|
20324
|
+
var RECORD_SCHEMA_VERSION = 2;
|
|
20296
20325
|
function requestToPromise(request) {
|
|
20297
20326
|
return new Promise((resolve, reject) => {
|
|
20298
20327
|
request.onsuccess = () => resolve(request.result);
|
|
@@ -20340,16 +20369,25 @@ var IdbRecordStore = class _IdbRecordStore {
|
|
|
20340
20369
|
return store;
|
|
20341
20370
|
}
|
|
20342
20371
|
async ensureSchemaVersion() {
|
|
20343
|
-
const tx = this.db.transaction(META_STORE, "readwrite");
|
|
20372
|
+
const tx = this.db.transaction([META_STORE, "collection"], "readwrite");
|
|
20344
20373
|
const meta = tx.objectStore(META_STORE);
|
|
20345
20374
|
const current = await requestToPromise(meta.get("schemaVersion"));
|
|
20346
|
-
if (current
|
|
20347
|
-
meta.put(RECORD_SCHEMA_VERSION, "schemaVersion");
|
|
20348
|
-
} else if (current > RECORD_SCHEMA_VERSION) {
|
|
20375
|
+
if (current !== void 0 && current > RECORD_SCHEMA_VERSION) {
|
|
20349
20376
|
throw new Error(
|
|
20350
20377
|
`IdbRecordStore: records were written by a newer schema (v${current} > v${RECORD_SCHEMA_VERSION}); refusing to open`
|
|
20351
20378
|
);
|
|
20352
20379
|
}
|
|
20380
|
+
if ((current ?? 0) < 2) {
|
|
20381
|
+
const collections = await requestToPromise(
|
|
20382
|
+
tx.objectStore("collection").getAll()
|
|
20383
|
+
);
|
|
20384
|
+
for (const collection of collections) {
|
|
20385
|
+
if (!Object.hasOwn(collection, "parent_id")) {
|
|
20386
|
+
tx.objectStore("collection").put({ ...collection, parent_id: null });
|
|
20387
|
+
}
|
|
20388
|
+
}
|
|
20389
|
+
}
|
|
20390
|
+
meta.put(RECORD_SCHEMA_VERSION, "schemaVersion");
|
|
20353
20391
|
await transactionComplete(tx);
|
|
20354
20392
|
}
|
|
20355
20393
|
async get(collection, id) {
|
|
@@ -20368,12 +20406,13 @@ var IdbRecordStore = class _IdbRecordStore {
|
|
|
20368
20406
|
}
|
|
20369
20407
|
async applyBatch(mutations) {
|
|
20370
20408
|
if (mutations.length === 0) return [];
|
|
20371
|
-
const
|
|
20409
|
+
const normalizedMutations = mutations.map(normalizeRecordMutation);
|
|
20410
|
+
const collections = [...new Set(normalizedMutations.map((mutation) => mutation.collection))];
|
|
20372
20411
|
const tx = this.db.transaction([...collections, JOURNAL_STORE], "readwrite");
|
|
20373
20412
|
const completed = transactionComplete(tx);
|
|
20374
20413
|
const pendingEntries = [];
|
|
20375
20414
|
try {
|
|
20376
|
-
for (const mutation of
|
|
20415
|
+
for (const mutation of normalizedMutations) {
|
|
20377
20416
|
const records = tx.objectStore(mutation.collection);
|
|
20378
20417
|
const pending = mutation.op === "put" ? {
|
|
20379
20418
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -20620,12 +20659,16 @@ ${revised.get(note.id) ?? ""}`.toLowerCase();
|
|
|
20620
20659
|
);
|
|
20621
20660
|
}
|
|
20622
20661
|
// ── Collections ───────────────────────────────────────────────────────────
|
|
20623
|
-
async createCollection(name, description) {
|
|
20662
|
+
async createCollection(name, description, parentId = null) {
|
|
20663
|
+
if (parentId !== null && !await this.store.get("collection", parentId)) {
|
|
20664
|
+
throw new Error(`Parent collection not found: ${parentId}`);
|
|
20665
|
+
}
|
|
20624
20666
|
const ts = nowIso();
|
|
20625
20667
|
const collection = {
|
|
20626
20668
|
id: generateId(),
|
|
20627
20669
|
name,
|
|
20628
20670
|
description: description ?? null,
|
|
20671
|
+
parent_id: parentId,
|
|
20629
20672
|
created_at: ts,
|
|
20630
20673
|
updated_at: ts,
|
|
20631
20674
|
deleted_at: null
|
|
@@ -20808,6 +20851,32 @@ async function dropAttachmentProjection(db) {
|
|
|
20808
20851
|
}
|
|
20809
20852
|
|
|
20810
20853
|
// src/records/record-projection.ts
|
|
20854
|
+
function collectionsParentFirst(collections) {
|
|
20855
|
+
const byId = new Map(collections.map((collection) => [collection.id, collection]));
|
|
20856
|
+
const ordered = [];
|
|
20857
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
20858
|
+
const visited = /* @__PURE__ */ new Set();
|
|
20859
|
+
const visit = (collection) => {
|
|
20860
|
+
if (visited.has(collection.id)) return;
|
|
20861
|
+
if (visiting.has(collection.id)) {
|
|
20862
|
+
throw new Error(`Collection hierarchy contains a cycle at ${collection.id}`);
|
|
20863
|
+
}
|
|
20864
|
+
visiting.add(collection.id);
|
|
20865
|
+
const parentId = collection.parent_id ?? null;
|
|
20866
|
+
if (parentId !== null) {
|
|
20867
|
+
const parent = byId.get(parentId);
|
|
20868
|
+
if (!parent) {
|
|
20869
|
+
throw new Error(`Collection ${collection.id} references missing parent ${parentId}`);
|
|
20870
|
+
}
|
|
20871
|
+
visit(parent);
|
|
20872
|
+
}
|
|
20873
|
+
visiting.delete(collection.id);
|
|
20874
|
+
visited.add(collection.id);
|
|
20875
|
+
ordered.push(collection);
|
|
20876
|
+
};
|
|
20877
|
+
for (const collection of collections) visit(collection);
|
|
20878
|
+
return ordered;
|
|
20879
|
+
}
|
|
20811
20880
|
async function projectNotes(db, store) {
|
|
20812
20881
|
const [noteRows, originals, revised, tags, links, collections, memberships] = await Promise.all([
|
|
20813
20882
|
store.list("note"),
|
|
@@ -20818,16 +20887,25 @@ async function projectNotes(db, store) {
|
|
|
20818
20887
|
store.list("collection"),
|
|
20819
20888
|
store.list("collection_note")
|
|
20820
20889
|
]);
|
|
20821
|
-
for (const c of collections) {
|
|
20890
|
+
for (const c of collectionsParentFirst(collections)) {
|
|
20822
20891
|
await db.query(
|
|
20823
|
-
`INSERT INTO collection (id, name, description, created_at, updated_at, deleted_at)
|
|
20824
|
-
VALUES ($1, $2, $3, $4, $5, $6)
|
|
20892
|
+
`INSERT INTO collection (id, name, description, parent_id, created_at, updated_at, deleted_at)
|
|
20893
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
20825
20894
|
ON CONFLICT (id) DO UPDATE SET
|
|
20826
20895
|
name = EXCLUDED.name,
|
|
20827
20896
|
description = EXCLUDED.description,
|
|
20897
|
+
parent_id = EXCLUDED.parent_id,
|
|
20828
20898
|
updated_at = EXCLUDED.updated_at,
|
|
20829
20899
|
deleted_at = EXCLUDED.deleted_at`,
|
|
20830
|
-
[
|
|
20900
|
+
[
|
|
20901
|
+
c.id,
|
|
20902
|
+
c.name,
|
|
20903
|
+
c.description,
|
|
20904
|
+
c.parent_id ?? null,
|
|
20905
|
+
c.created_at,
|
|
20906
|
+
c.updated_at,
|
|
20907
|
+
c.deleted_at
|
|
20908
|
+
]
|
|
20831
20909
|
);
|
|
20832
20910
|
}
|
|
20833
20911
|
for (const n of noteRows) {
|
|
@@ -21325,12 +21403,11 @@ async function buildRecordShardArchive(store, options, profile) {
|
|
|
21325
21403
|
const orderedCollections = collections.sort((a, b) => a.name.localeCompare(b.name));
|
|
21326
21404
|
const shardCollections = orderedCollections.map((c) => {
|
|
21327
21405
|
const mapped = collectionToShard(
|
|
21328
|
-
// Canonical collections are flat (no parent hierarchy yet).
|
|
21329
21406
|
{
|
|
21330
21407
|
id: c.id,
|
|
21331
21408
|
name: c.name,
|
|
21332
21409
|
description: c.description,
|
|
21333
|
-
parent_id: null,
|
|
21410
|
+
parent_id: c.parent_id ?? null,
|
|
21334
21411
|
created_at: c.created_at,
|
|
21335
21412
|
updated_at: c.updated_at,
|
|
21336
21413
|
deleted_at: c.deleted_at
|
|
@@ -21764,6 +21841,7 @@ async function importShardToRecords(store, data, options) {
|
|
|
21764
21841
|
id: col.id,
|
|
21765
21842
|
name: col.name,
|
|
21766
21843
|
description: col.description,
|
|
21844
|
+
parent_id: col.parent_id,
|
|
21767
21845
|
created_at: col.created_at,
|
|
21768
21846
|
updated_at: col.updated_at,
|
|
21769
21847
|
deleted_at: col.deleted_at
|
|
@@ -22038,7 +22116,7 @@ async function importShardToRecords(store, data, options) {
|
|
|
22038
22116
|
}
|
|
22039
22117
|
|
|
22040
22118
|
// src/index.ts
|
|
22041
|
-
var VERSION = "2026.7.
|
|
22119
|
+
var VERSION = "2026.7.11";
|
|
22042
22120
|
|
|
22043
22121
|
export { AIWG_SCAN_REQUIRED_FIELDS, AllowlistTrustStore, ArchiveManager, AttachmentsRepository, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, CanonicalAttachmentsRepository, CanonicalNotesRepository, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, DB_SNAPSHOT_SCHEMA_VERSION, DbSnapshotVersionError, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, EmbeddingSetsRepository, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, FallbackRouter, FortemiToolManifest, GetNoteInputSchema, GraphRepository, IdbRecordStore, JOB_CAPABILITIES, JOB_PRIORITIES, JobQueueWorker, LOCAL_ENDPOINTS, LinksRepository, ListNotesInputSchema, ManageArchiveInputSchema, ManageAttachmentsInputSchema, ManageCapabilitiesInputSchema, ManageCollectionsInputSchema, ManageLinksInputSchema, ManageNoteInputSchema, ManageTagsInputSchema, MemoryBlobStore, MemoryRecordStore, MigrationRunner, NotesRepository, OpenAICompatibleProvider, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, ProvenanceRepository, ProviderRegistry, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, SHARD_FORMAT, SIGNATURE_ENTRY, SIGNING_ENVELOPE_VERSION, SUPPORTED_PGLITE_VERSION, SearchInputSchema, SearchRepository, SkosRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexFromKnowledgeShard, aiwgFortemiIndexToCommunityGraph, aiwgFortemiIndexToKnowledgeShard, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, assertShardComponentRecord, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeBlobHash, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLazyBlobStore, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getAiwgFortemiIndexExportSchema, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, importShardToRecords, isPluginScriptAllowed, isShardPrefetched, isShardSigningSupported, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, migrateLegacyBlobStore, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, sidecarBlobDigests, signShard, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, urlLinkToShard, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgFortemiIndexExportSchema, validateAiwgFortemiProjectedRecordSchema, validateAiwgStaticEmbeddingSet, validateChecksums, validateCoreV1ShardArchive, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifyShardSignature, verifySri };
|
|
22044
22122
|
//# sourceMappingURL=index.js.map
|