@semiont/make-meaning 0.5.3 → 0.5.4
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/annotation-assembly.d.ts +8 -0
- package/dist/annotation-assembly.d.ts.map +1 -0
- package/dist/annotation-context.d.ts +104 -0
- package/dist/annotation-context.d.ts.map +1 -0
- package/dist/annotation-operations.d.ts +41 -0
- package/dist/annotation-operations.d.ts.map +1 -0
- package/dist/batch-utils.d.ts +14 -0
- package/dist/batch-utils.d.ts.map +1 -0
- package/dist/bootstrap/entity-types.d.ts +26 -0
- package/dist/bootstrap/entity-types.d.ts.map +1 -0
- package/dist/browser.d.ts +45 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/clone-token-manager.d.ts +31 -0
- package/dist/clone-token-manager.d.ts.map +1 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/embedding-store.d.ts +63 -0
- package/dist/embedding-store.d.ts.map +1 -0
- package/dist/event-enrichment.d.ts +5 -0
- package/dist/event-enrichment.d.ts.map +1 -0
- package/dist/exchange/backup-exporter.d.ts +43 -0
- package/dist/exchange/backup-exporter.d.ts.map +1 -0
- package/dist/exchange/backup-importer.d.ts +41 -0
- package/dist/exchange/backup-importer.d.ts.map +1 -0
- package/dist/exchange/index.d.ts +10 -0
- package/dist/exchange/index.d.ts.map +1 -0
- package/dist/exchange/linked-data-exporter.d.ts +42 -0
- package/dist/exchange/linked-data-exporter.d.ts.map +1 -0
- package/dist/exchange/linked-data-importer.d.ts +44 -0
- package/dist/exchange/linked-data-importer.d.ts.map +1 -0
- package/dist/exchange/manifest.d.ts +42 -0
- package/dist/exchange/manifest.d.ts.map +1 -0
- package/dist/exchange/replay.d.ts +37 -0
- package/dist/exchange/replay.d.ts.map +1 -0
- package/dist/exchange/tar.d.ts +34 -0
- package/dist/exchange/tar.d.ts.map +1 -0
- package/dist/gatherer.d.ts +45 -0
- package/dist/gatherer.d.ts.map +1 -0
- package/dist/generation/resource-generation.d.ts +20 -0
- package/dist/generation/resource-generation.d.ts.map +1 -0
- package/dist/graph/consumer.d.ts +104 -0
- package/dist/graph/consumer.d.ts.map +1 -0
- package/dist/graph-context.d.ts +56 -0
- package/dist/graph-context.d.ts.map +1 -0
- package/dist/handlers/annotation-assembly.d.ts +19 -0
- package/dist/handlers/annotation-assembly.d.ts.map +1 -0
- package/dist/handlers/annotation-lookups.d.ts +8 -0
- package/dist/handlers/annotation-lookups.d.ts.map +1 -0
- package/dist/handlers/bind-update-body.d.ts +19 -0
- package/dist/handlers/bind-update-body.d.ts.map +1 -0
- package/dist/handlers/index.d.ts +27 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/job-commands.d.ts +5 -0
- package/dist/handlers/job-commands.d.ts.map +1 -0
- package/dist/index.d.ts +37 -1244
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -16
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +40 -0
- package/dist/knowledge-base.d.ts.map +1 -0
- package/dist/knowledge-system.d.ts +32 -0
- package/dist/knowledge-system.d.ts.map +1 -0
- package/dist/llm-context.d.ts +26 -0
- package/dist/llm-context.d.ts.map +1 -0
- package/dist/local-content-transport.d.ts +41 -0
- package/dist/local-content-transport.d.ts.map +1 -0
- package/dist/local-transport.d.ts +80 -0
- package/dist/local-transport.d.ts.map +1 -0
- package/dist/matcher.d.ts +60 -0
- package/dist/matcher.d.ts.map +1 -0
- package/dist/resource-context.d.ts +44 -0
- package/dist/resource-context.d.ts.map +1 -0
- package/dist/resource-operations.d.ts +38 -0
- package/dist/resource-operations.d.ts.map +1 -0
- package/dist/service.d.ts +21 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/smelter-actor-state-unit.d.ts +31 -0
- package/dist/smelter-actor-state-unit.d.ts.map +1 -0
- package/dist/smelter-main.d.ts +16 -2
- package/dist/smelter-main.d.ts.map +1 -0
- package/dist/smelter-main.js +6 -2
- package/dist/smelter-main.js.map +1 -1
- package/dist/smelter.d.ts +95 -0
- package/dist/smelter.d.ts.map +1 -0
- package/dist/stower.d.ts +69 -0
- package/dist/stower.d.ts.map +1 -0
- package/dist/views/entity-types-reader.d.ts +12 -0
- package/dist/views/entity-types-reader.d.ts.map +1 -0
- package/dist/views/projection-validators.d.ts +80 -0
- package/dist/views/projection-validators.d.ts.map +1 -0
- package/dist/views/tag-schemas-reader.d.ts +14 -0
- package/dist/views/tag-schemas-reader.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation Assembly — re-exported from @semiont/core
|
|
3
|
+
*
|
|
4
|
+
* The canonical implementation lives in @semiont/core.
|
|
5
|
+
* This re-export maintains the public API of @semiont/make-meaning.
|
|
6
|
+
*/
|
|
7
|
+
export { assembleAnnotation, applyBodyOperations, type AssembledAnnotation, } from '@semiont/core';
|
|
8
|
+
//# sourceMappingURL=annotation-assembly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-assembly.d.ts","sourceRoot":"","sources":["../src/annotation-assembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation Context
|
|
3
|
+
*
|
|
4
|
+
* Assembles annotation context from view storage and content store.
|
|
5
|
+
* Provides methods for:
|
|
6
|
+
* - Getting resource annotations
|
|
7
|
+
* - Building LLM context for annotations
|
|
8
|
+
* - Extracting annotation text context
|
|
9
|
+
* - Generating AI summaries
|
|
10
|
+
*/
|
|
11
|
+
import type { InferenceClient } from '@semiont/inference';
|
|
12
|
+
import type { EmbeddingProvider } from '@semiont/vectors';
|
|
13
|
+
import type { components } from '@semiont/core';
|
|
14
|
+
import type { ResourceId, ResourceAnnotations, AnnotationId, AnnotationCategory, Logger } from '@semiont/core';
|
|
15
|
+
import type { KnowledgeBase } from './knowledge-base';
|
|
16
|
+
type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
17
|
+
import type { Annotation } from '@semiont/core';
|
|
18
|
+
type AnnotationContextResponse = components['schemas']['AnnotationContextResponse'];
|
|
19
|
+
type ContextualSummaryResponse = components['schemas']['ContextualSummaryResponse'];
|
|
20
|
+
export interface BuildContextOptions {
|
|
21
|
+
includeSourceContext?: boolean;
|
|
22
|
+
includeTargetContext?: boolean;
|
|
23
|
+
contextWindow?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class AnnotationContext {
|
|
26
|
+
/**
|
|
27
|
+
* Build LLM context for an annotation
|
|
28
|
+
*
|
|
29
|
+
* @param annotationId - Bare annotation ID
|
|
30
|
+
* @param resourceId - Source resource ID
|
|
31
|
+
* @param kb - Knowledge base stores
|
|
32
|
+
* @param options - Context building options
|
|
33
|
+
* @param inferenceClient - Optional inference client for target context summary
|
|
34
|
+
* @returns Rich context for LLM processing
|
|
35
|
+
* @throws Error if annotation or resource not found
|
|
36
|
+
*/
|
|
37
|
+
static buildLLMContext(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, options?: BuildContextOptions, inferenceClient?: InferenceClient, logger?: Logger, embeddingProvider?: EmbeddingProvider): Promise<AnnotationLLMContextResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Get resource annotations from view storage (fast path)
|
|
40
|
+
* Throws if view missing
|
|
41
|
+
*/
|
|
42
|
+
static getResourceAnnotations(resourceId: ResourceId, kb: KnowledgeBase): Promise<ResourceAnnotations>;
|
|
43
|
+
/**
|
|
44
|
+
* Get all annotations
|
|
45
|
+
* @returns Array of all annotation objects
|
|
46
|
+
*/
|
|
47
|
+
static getAllAnnotations(resourceId: ResourceId, kb: KnowledgeBase): Promise<Annotation[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Enrich reference annotations with resolved document names
|
|
50
|
+
* Adds _resolvedDocumentName property to annotations that link to documents
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private static enrichResolvedReferences;
|
|
54
|
+
/**
|
|
55
|
+
* Get resource stats (version info)
|
|
56
|
+
* @returns Version and timestamp info for the annotations
|
|
57
|
+
*/
|
|
58
|
+
static getResourceStats(resourceId: ResourceId, kb: KnowledgeBase): Promise<{
|
|
59
|
+
resourceId: ResourceId;
|
|
60
|
+
version: number;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if resource exists in view storage
|
|
65
|
+
*/
|
|
66
|
+
static resourceExists(resourceId: ResourceId, kb: KnowledgeBase): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Get a single annotation by ID
|
|
69
|
+
* O(1) lookup using resource ID to access view storage
|
|
70
|
+
*/
|
|
71
|
+
static getAnnotation(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase): Promise<Annotation | null>;
|
|
72
|
+
/**
|
|
73
|
+
* List annotations with optional filtering
|
|
74
|
+
* @param filters - Optional filters like resourceId and type
|
|
75
|
+
* @throws Error if resourceId not provided (cross-resource queries not supported in view storage)
|
|
76
|
+
*/
|
|
77
|
+
static listAnnotations(filters: {
|
|
78
|
+
resourceId?: ResourceId;
|
|
79
|
+
type?: AnnotationCategory;
|
|
80
|
+
} | undefined, kb: KnowledgeBase): Promise<Annotation[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Get annotation context (selected text with surrounding context)
|
|
83
|
+
*/
|
|
84
|
+
static getAnnotationContext(annotationId: AnnotationId, resourceId: ResourceId, contextBefore: number, contextAfter: number, kb: KnowledgeBase): Promise<AnnotationContextResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* Generate AI summary of annotation in context
|
|
87
|
+
*/
|
|
88
|
+
static generateAnnotationSummary(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, inferenceClient: InferenceClient): Promise<ContextualSummaryResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Get resource content as string
|
|
91
|
+
*/
|
|
92
|
+
private static getResourceContent;
|
|
93
|
+
/**
|
|
94
|
+
* Extract annotation context from resource content
|
|
95
|
+
*/
|
|
96
|
+
private static extractAnnotationContext;
|
|
97
|
+
/**
|
|
98
|
+
* Generate LLM summary of annotation in context
|
|
99
|
+
* Creates inference client per-request (HTTP handler context)
|
|
100
|
+
*/
|
|
101
|
+
private static generateSummary;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=annotation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-context.d.ts","sourceRoot":"","sources":["../src/annotation-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,kBAAkB,CAAC;AAG9E,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,MAAM,EACP,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,KAAK,4BAA4B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,8BAA8B,CAAC,CAAC;AAG1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,KAAK,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAAC,CAAC;AACpF,KAAK,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAAC,CAAC;AAEpF,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,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YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,aAAa,GAChB,OAAO,CAAC,yBAAyB,CAAC;IAsCrC;;OAEG;WACU,yBAAyB,CACpC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,aAAa,EACjB,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,yBAAyB,CAAC;IA4CrC;;OAEG;mBACkB,kBAAkB;IAYvC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAwBvC;;;OAGG;mBACkB,eAAe;CAiBrC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation Operations
|
|
3
|
+
*
|
|
4
|
+
* Business logic for annotation CRUD operations. All writes go through the
|
|
5
|
+
* EventBus — the Stower actor subscribes and handles persistence.
|
|
6
|
+
*
|
|
7
|
+
* In-process callers pass a `UserId` to these operations; the
|
|
8
|
+
* EventBus emits stamp it onto the gateway-injection field `_userId`,
|
|
9
|
+
* matching the wire-side convention so Stower handlers see one shape
|
|
10
|
+
* regardless of where the command originated.
|
|
11
|
+
*/
|
|
12
|
+
import type { components } from '@semiont/core';
|
|
13
|
+
import type { UserId, Logger } from '@semiont/core';
|
|
14
|
+
import { EventBus } from '@semiont/core';
|
|
15
|
+
import type { KnowledgeBase } from './knowledge-base';
|
|
16
|
+
type Agent = components['schemas']['Agent'];
|
|
17
|
+
import type { Annotation } from '@semiont/core';
|
|
18
|
+
type CreateAnnotationRequest = components['schemas']['CreateAnnotationRequest'];
|
|
19
|
+
type UpdateAnnotationBodyRequest = components['schemas']['UpdateAnnotationBodyRequest'];
|
|
20
|
+
export interface CreateAnnotationResult {
|
|
21
|
+
annotation: Annotation;
|
|
22
|
+
}
|
|
23
|
+
export interface UpdateAnnotationBodyResult {
|
|
24
|
+
annotation: Annotation;
|
|
25
|
+
}
|
|
26
|
+
export declare class AnnotationOperations {
|
|
27
|
+
/**
|
|
28
|
+
* Create a new annotation via EventBus → Stower
|
|
29
|
+
*/
|
|
30
|
+
static createAnnotation(request: CreateAnnotationRequest, userId: UserId, creator: Agent, eventBus: EventBus): Promise<CreateAnnotationResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Update annotation body via EventBus → Stower
|
|
33
|
+
*/
|
|
34
|
+
static updateAnnotationBody(id: string, request: UpdateAnnotationBodyRequest, userId: UserId, eventBus: EventBus, kb: KnowledgeBase): Promise<UpdateAnnotationBodyResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Delete an annotation via EventBus → Stower
|
|
37
|
+
*/
|
|
38
|
+
static deleteAnnotation(id: string, resourceIdStr: string, userId: UserId, eventBus: EventBus, kb: KnowledgeBase, logger?: Logger): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=annotation-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-operations.d.ts","sourceRoot":"","sources":["../src/annotation-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAEV,MAAM,EACN,MAAM,EACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAuF,MAAM,eAAe,CAAC;AAE9H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,KAAK,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,KAAK,uBAAuB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,yBAAyB,CAAC,CAAC;AAChF,KAAK,2BAA2B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,6BAA6B,CAAC,CAAC;AAExF,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,qBAAa,oBAAoB;IAC/B;;OAEG;WACU,gBAAgB,CAC3B,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,sBAAsB,CAAC;IAclC;;OAEG;WACU,oBAAoB,CAC/B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,2BAA2B,EACpC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,aAAa,GAChB,OAAO,CAAC,0BAA0B,CAAC;IA8BtC;;OAEG;WACU,gBAAgB,CAC3B,EAAE,EAAE,MAAM,EACV,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,aAAa,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;CAqBjB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared batch utilities for event-processing actors (GraphDBConsumer, Smelter).
|
|
3
|
+
*
|
|
4
|
+
* Both actors use the same pattern: burst-buffered events arrive as a batch,
|
|
5
|
+
* get partitioned into consecutive same-type runs, and each run is processed
|
|
6
|
+
* with a type-specific batch handler.
|
|
7
|
+
*/
|
|
8
|
+
import type { StoredEvent } from '@semiont/core';
|
|
9
|
+
/**
|
|
10
|
+
* Partition a batch of events into runs of consecutive same-type events.
|
|
11
|
+
* e.g. [A, A, B, B, B, A] → [[A, A], [B, B, B], [A]]
|
|
12
|
+
*/
|
|
13
|
+
export declare function partitionByType(events: StoredEvent[]): StoredEvent[][];
|
|
14
|
+
//# sourceMappingURL=batch-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-utils.d.ts","sourceRoot":"","sources":["../src/batch-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,EAAE,CActE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity Types Bootstrap
|
|
3
|
+
*
|
|
4
|
+
* On startup, seeds the KB with DEFAULT_ENTITY_TYPES by emitting
|
|
5
|
+
* frame:add-entity-type for each missing type. Reads the __system__ event
|
|
6
|
+
* stream (the durable source of truth in .semiont/events/) to determine
|
|
7
|
+
* which types already exist.
|
|
8
|
+
*
|
|
9
|
+
* Idempotent: safe to call on every startup. Only emits events for types
|
|
10
|
+
* not already in the log.
|
|
11
|
+
*
|
|
12
|
+
* Future: evolve toward a migration-based model where a `system:bootstrapped`
|
|
13
|
+
* sentinel event records that first-time init completed, and `system:migrated`
|
|
14
|
+
* events record schema version upgrades (e.g., adding new default entity types
|
|
15
|
+
* in a future release). For now, scanning the small __system__ stream is simple
|
|
16
|
+
* and correct.
|
|
17
|
+
*/
|
|
18
|
+
import { EventBus, type Logger } from '@semiont/core';
|
|
19
|
+
import type { EventStore } from '@semiont/event-sourcing';
|
|
20
|
+
/**
|
|
21
|
+
* Bootstrap entity types if any are missing from the event log.
|
|
22
|
+
* Reads the __system__ stream to find existing frame:entity-type-added events,
|
|
23
|
+
* then emits only the missing ones.
|
|
24
|
+
*/
|
|
25
|
+
export declare function bootstrapEntityTypes(eventBus: EventBus, eventStore: EventStore, logger?: Logger): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=entity-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-types.d.ts","sourceRoot":"","sources":["../../src/bootstrap/entity-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,QAAQ,EAAsB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCrH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Actor
|
|
3
|
+
*
|
|
4
|
+
* Filesystem-shaped reads and KB graph reads for the Knowledge System.
|
|
5
|
+
* Merges live filesystem state with KB metadata for tracked resources.
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - browse:resource-requested — single resource metadata (materialized from events)
|
|
9
|
+
* - browse:resources-requested — list resources
|
|
10
|
+
* - browse:annotations-requested — all annotations for a resource
|
|
11
|
+
* - browse:annotation-requested — single annotation with resolved resource
|
|
12
|
+
* - browse:events-requested — resource event history
|
|
13
|
+
* - browse:annotation-history-requested — annotation event history
|
|
14
|
+
* - browse:referenced-by-requested — find annotations in the KB graph that reference a resource
|
|
15
|
+
* - browse:entity-types-requested — list entity types from the project projection
|
|
16
|
+
* - browse:tag-schemas-requested — list tag schemas from the project projection
|
|
17
|
+
* - browse:directory-requested — list a project directory, merging fs + ViewStorage
|
|
18
|
+
*/
|
|
19
|
+
import type { SemiontProject } from '@semiont/core/node';
|
|
20
|
+
import type { Logger } from '@semiont/core';
|
|
21
|
+
import { EventBus } from '@semiont/core';
|
|
22
|
+
import type { ViewStorage } from '@semiont/event-sourcing';
|
|
23
|
+
import type { KnowledgeBase } from './knowledge-base';
|
|
24
|
+
export declare class Browser {
|
|
25
|
+
private views;
|
|
26
|
+
private kb;
|
|
27
|
+
private eventBus;
|
|
28
|
+
private project;
|
|
29
|
+
private subscriptions;
|
|
30
|
+
private readonly logger;
|
|
31
|
+
constructor(views: ViewStorage, kb: KnowledgeBase, eventBus: EventBus, project: SemiontProject, logger: Logger);
|
|
32
|
+
initialize(): Promise<void>;
|
|
33
|
+
private handleBrowseResource;
|
|
34
|
+
private handleBrowseResources;
|
|
35
|
+
private handleBrowseAnnotations;
|
|
36
|
+
private handleBrowseAnnotation;
|
|
37
|
+
private handleBrowseEvents;
|
|
38
|
+
private handleBrowseAnnotationHistory;
|
|
39
|
+
private handleReferencedBy;
|
|
40
|
+
private handleEntityTypes;
|
|
41
|
+
private handleTagSchemas;
|
|
42
|
+
private handleBrowseDirectory;
|
|
43
|
+
stop(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAY,MAAM,EAAc,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAsC,MAAM,eAAe,CAAC;AAI7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWtD,qBAAa,OAAO;IAKhB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;IAPjB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGtB,KAAK,EAAE,WAAW,EAClB,EAAE,EAAE,aAAa,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,EAC/B,MAAM,EAAE,MAAM;IAKV,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCnB,oBAAoB;YAsCpB,qBAAqB;YAwCrB,uBAAuB;YAoBvB,sBAAsB;YAsCtB,kBAAkB;YAoClB,6BAA6B;YA4C7B,kBAAkB;YAkDlB,iBAAiB;YAgBjB,gBAAgB;YAoBhB,qBAAqB;IAiH7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO5B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clone Token Manager
|
|
3
|
+
*
|
|
4
|
+
* Reactive actor that handles clone token operations via the EventBus.
|
|
5
|
+
* Manages an in-memory token store for resource cloning workflows.
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - yield:clone-token-requested — generate a clone token for a resource
|
|
9
|
+
* - yield:clone-resource-requested — look up a resource by clone token
|
|
10
|
+
* - yield:clone-create — create a new resource from a clone token
|
|
11
|
+
*
|
|
12
|
+
* From COMPLETE-EVENT-PROTOCOL.md:
|
|
13
|
+
* "Clone tokens produce new resources — that's yield."
|
|
14
|
+
*/
|
|
15
|
+
import type { Logger } from '@semiont/core';
|
|
16
|
+
import { type EventBus } from '@semiont/core';
|
|
17
|
+
import type { KnowledgeBase } from './knowledge-base';
|
|
18
|
+
export declare class CloneTokenManager {
|
|
19
|
+
private kb;
|
|
20
|
+
private eventBus;
|
|
21
|
+
private subscriptions;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly tokens;
|
|
24
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger);
|
|
25
|
+
initialize(): Promise<void>;
|
|
26
|
+
private handleGenerateToken;
|
|
27
|
+
private handleGetResource;
|
|
28
|
+
private handleCreateResource;
|
|
29
|
+
stop(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=clone-token-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-token-manager.d.ts","sourceRoot":"","sources":["../src/clone-token-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAY,MAAM,EAAc,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,KAAK,QAAQ,EAAmF,MAAM,eAAe,CAAC;AAK/H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,iBAAiB;IAM1B,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,QAAQ;IANlB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsE;gBAGnF,EAAE,EAAE,aAAa,EACjB,QAAQ,EAAE,QAAQ,EAC1B,MAAM,EAAE,MAAM;IAKV,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAwBnB,mBAAmB;YAsDnB,iBAAiB;YA+CjB,oBAAoB;IAwF5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { GraphServiceConfig, VectorsServiceConfig, EmbeddingServiceConfig } from '@semiont/core';
|
|
2
|
+
/**
|
|
3
|
+
* Inference configuration for a single actor or worker.
|
|
4
|
+
*/
|
|
5
|
+
export interface InferenceConfig {
|
|
6
|
+
type: 'anthropic' | 'ollama';
|
|
7
|
+
model: string;
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
endpoint?: string;
|
|
11
|
+
baseURL?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Per-actor inference overrides.
|
|
15
|
+
* Stower never calls an LLM, so it has no entry here.
|
|
16
|
+
*/
|
|
17
|
+
export interface ActorInferenceConfig {
|
|
18
|
+
gatherer?: InferenceConfig;
|
|
19
|
+
matcher?: InferenceConfig;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Per-worker-type inference overrides.
|
|
23
|
+
* Falls back to `workers.default` if a specific worker is not listed.
|
|
24
|
+
*/
|
|
25
|
+
export interface WorkerInferenceConfig {
|
|
26
|
+
default?: InferenceConfig;
|
|
27
|
+
'reference-annotation'?: InferenceConfig;
|
|
28
|
+
'highlight-annotation'?: InferenceConfig;
|
|
29
|
+
'assessment-annotation'?: InferenceConfig;
|
|
30
|
+
'comment-annotation'?: InferenceConfig;
|
|
31
|
+
'tag-annotation'?: InferenceConfig;
|
|
32
|
+
'generation'?: InferenceConfig;
|
|
33
|
+
}
|
|
34
|
+
/** Narrow config type — only the fields make-meaning actually reads */
|
|
35
|
+
export interface MakeMeaningConfig {
|
|
36
|
+
services: {
|
|
37
|
+
graph?: GraphServiceConfig;
|
|
38
|
+
vectors?: VectorsServiceConfig;
|
|
39
|
+
embedding?: EmbeddingServiceConfig;
|
|
40
|
+
};
|
|
41
|
+
/** Per-actor inference config */
|
|
42
|
+
actors?: ActorInferenceConfig;
|
|
43
|
+
/** Per-worker-type inference config */
|
|
44
|
+
workers?: WorkerInferenceConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve inference config for a named actor.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveActorInference(config: MakeMeaningConfig, actor: 'gatherer' | 'matcher'): InferenceConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve inference config for a named worker type.
|
|
52
|
+
* Falls back to workers.default if a specific worker is not listed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveWorkerInference(config: MakeMeaningConfig, workerType: keyof Omit<WorkerInferenceConfig, 'default'>): InferenceConfig;
|
|
55
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEtG;;GAEG;AACH,MAAM,WAAW,eA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-0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingStore
|
|
3
|
+
*
|
|
4
|
+
* Durable file-based cache for pre-computed embedding vectors.
|
|
5
|
+
* Stored under .semiont/embeddings/ — committed to git alongside events,
|
|
6
|
+
* but overwritten in place rather than appended.
|
|
7
|
+
*
|
|
8
|
+
* File layout (same 4-hex Jump Consistent Hash sharding as events):
|
|
9
|
+
*
|
|
10
|
+
* .semiont/embeddings/{ab}/{cd}/{resourceId}.jsonl
|
|
11
|
+
* Line 0: { model, dimensions } ← model header
|
|
12
|
+
* Line N: { chunkIndex, text, embedding[] } ← one chunk per line
|
|
13
|
+
*
|
|
14
|
+
* .semiont/embeddings/{ab}/{cd}/{annotationId}.json
|
|
15
|
+
* { model, dimensions, resourceId, text, embedding[], motivation, entityTypes }
|
|
16
|
+
*
|
|
17
|
+
* rebuildAll() in Smelter reads these files and upserts into Qdrant without
|
|
18
|
+
* calling the embedding provider — unless the stored model doesn't match the
|
|
19
|
+
* configured provider, in which case the file is re-embedded and overwritten.
|
|
20
|
+
*/
|
|
21
|
+
import type { ResourceId, AnnotationId } from '@semiont/core';
|
|
22
|
+
import type { SemiontProject } from '@semiont/core/node';
|
|
23
|
+
export interface StoredChunk {
|
|
24
|
+
chunkIndex: number;
|
|
25
|
+
text: string;
|
|
26
|
+
embedding: number[];
|
|
27
|
+
}
|
|
28
|
+
export interface ResourceEmbeddingFile {
|
|
29
|
+
model: string;
|
|
30
|
+
dimensions: number;
|
|
31
|
+
chunks: StoredChunk[];
|
|
32
|
+
}
|
|
33
|
+
export interface AnnotationEmbeddingFile {
|
|
34
|
+
model: string;
|
|
35
|
+
dimensions: number;
|
|
36
|
+
resourceId: string;
|
|
37
|
+
text: string;
|
|
38
|
+
embedding: number[];
|
|
39
|
+
motivation: string;
|
|
40
|
+
entityTypes: string[];
|
|
41
|
+
}
|
|
42
|
+
export declare class EmbeddingStore {
|
|
43
|
+
private readonly project;
|
|
44
|
+
constructor(project: SemiontProject);
|
|
45
|
+
private resourceFilePath;
|
|
46
|
+
private annotationFilePath;
|
|
47
|
+
writeResourceChunks(resourceId: ResourceId, model: string, dimensions: number, chunks: StoredChunk[]): Promise<void>;
|
|
48
|
+
readResourceEmbeddings(resourceId: ResourceId): Promise<ResourceEmbeddingFile | null>;
|
|
49
|
+
deleteResourceEmbeddings(resourceId: ResourceId): Promise<void>;
|
|
50
|
+
writeAnnotationEmbedding(annotationId: AnnotationId, resourceId: ResourceId, model: string, dimensions: number, text: string, embedding: number[], motivation: string, entityTypes: string[]): Promise<void>;
|
|
51
|
+
readAnnotationEmbedding(annotationId: AnnotationId): Promise<AnnotationEmbeddingFile | null>;
|
|
52
|
+
deleteAnnotationEmbedding(annotationId: AnnotationId): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Scan embeddings directory and return all resource IDs (from *.jsonl files).
|
|
55
|
+
*/
|
|
56
|
+
getAllResourceIds(): Promise<string[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Scan embeddings directory and return all annotation IDs (from *.json files).
|
|
59
|
+
*/
|
|
60
|
+
getAllAnnotationIds(): Promise<string[]>;
|
|
61
|
+
private scanIds;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=embedding-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-store.d.ts","sourceRoot":"","sources":["../src/embedding-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,U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IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAIhC,OAAO;CAgCtB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KnowledgeBase } from './knowledge-base';
|
|
2
|
+
import type { Annotation, ResourceId, StoredEvent } from '@semiont/core';
|
|
3
|
+
export declare function eventAnnotationId(event: StoredEvent): string | null;
|
|
4
|
+
export declare function readAnnotationFromView(kb: KnowledgeBase, resourceId: ResourceId, annotationId: string): Promise<Annotation | null>;
|
|
5
|
+
//# sourceMappingURL=event-enrichment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-enrichment.d.ts","sourceRoot":"","sources":["../src/event-enrichment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAWnE;AAED,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,aAAa,EACjB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAG5B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup Exporter
|
|
3
|
+
*
|
|
4
|
+
* Produces a lossless tar.gz archive of the system of record:
|
|
5
|
+
* - Event log (all streams, JSONL format)
|
|
6
|
+
* - Content store (content-addressed blobs)
|
|
7
|
+
*
|
|
8
|
+
* Reads events via EventStore and content via RepresentationStore.
|
|
9
|
+
* The archive can restore a complete knowledge base.
|
|
10
|
+
*/
|
|
11
|
+
import type { Writable } from 'node:stream';
|
|
12
|
+
import type { ResourceId, StoredEvent, Logger } from '@semiont/core';
|
|
13
|
+
import { type BackupManifestHeader } from './manifest';
|
|
14
|
+
/** Subset of EventStore used by the backup exporter. */
|
|
15
|
+
export interface BackupEventStoreReader {
|
|
16
|
+
log: {
|
|
17
|
+
storage: {
|
|
18
|
+
getAllResourceIds(): Promise<ResourceId[]>;
|
|
19
|
+
};
|
|
20
|
+
getEvents(resourceId: ResourceId): Promise<StoredEvent[]>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Subset of WorkingTreeStore used by the backup exporter. */
|
|
24
|
+
export interface BackupContentReader {
|
|
25
|
+
retrieve(storageUri: string): Promise<Buffer>;
|
|
26
|
+
}
|
|
27
|
+
export interface BackupExporterOptions {
|
|
28
|
+
eventStore: BackupEventStoreReader;
|
|
29
|
+
content: BackupContentReader;
|
|
30
|
+
sourceUrl: string;
|
|
31
|
+
logger?: Logger;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Export a full backup of the knowledge base to a tar.gz stream.
|
|
35
|
+
*
|
|
36
|
+
* Archive structure:
|
|
37
|
+
* .semiont/manifest.jsonl - Format metadata + per-stream checksums
|
|
38
|
+
* .semiont/events/__system__.jsonl - System events
|
|
39
|
+
* .semiont/events/{resourceId}.jsonl - Per-resource events
|
|
40
|
+
* {checksum}.{ext} - Content blobs (root level)
|
|
41
|
+
*/
|
|
42
|
+
export declare function exportBackup(options: BackupExporterOptions, output: Writable): Promise<BackupManifestHeader>;
|
|
43
|
+
//# sourceMappingURL=backup-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup-exporter.d.ts","sourceRoot":"","sources":["../../src/exchange/backup-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAGL,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AAEpB,wDAAwD;AACxD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE;QACH,OAAO,EAAE;YACP,iBAAiB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;SAC5C,CAAC;QACF,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;KAC3D,CAAC;CACH;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,sBAAsB,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,oBAAoB,CAAC,CAgG/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup Importer
|
|
3
|
+
*
|
|
4
|
+
* Restores a knowledge base from a backup tar.gz archive.
|
|
5
|
+
* Replays events through the EventBus → Stower pipeline so all
|
|
6
|
+
* derived state (materialized views, graph) rebuilds naturally.
|
|
7
|
+
*
|
|
8
|
+
* Accepts a Readable stream so callers can pipe directly from disk
|
|
9
|
+
* or network without buffering the entire archive first.
|
|
10
|
+
* Content blobs are resolved lazily via a closure over the parsed
|
|
11
|
+
* tar entries, avoiding a separate copy of all blob data in memory.
|
|
12
|
+
*/
|
|
13
|
+
import type { Readable } from 'node:stream';
|
|
14
|
+
import type { Logger } from '@semiont/core';
|
|
15
|
+
import { EventBus } from '@semiont/core';
|
|
16
|
+
import type { WorkingTreeStore } from '@semiont/content';
|
|
17
|
+
import { type BackupManifestHeader } from './manifest';
|
|
18
|
+
import { type ReplayStats } from './replay';
|
|
19
|
+
export interface BackupImporterOptions {
|
|
20
|
+
eventBus: EventBus;
|
|
21
|
+
contentStore: WorkingTreeStore;
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
}
|
|
24
|
+
export interface BackupImportResult {
|
|
25
|
+
manifest: BackupManifestHeader;
|
|
26
|
+
stats: ReplayStats;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Import a backup archive by replaying events through the EventBus.
|
|
30
|
+
*
|
|
31
|
+
* Flow:
|
|
32
|
+
* 1. Stream and decompress tar.gz entries
|
|
33
|
+
* 2. Parse .semiont/manifest.jsonl → validate format
|
|
34
|
+
* 3. Build blob resolver over root-level content entries
|
|
35
|
+
* 4. Replay .semiont/events/__system__.jsonl (entity types)
|
|
36
|
+
* 5. Replay each .semiont/events/{resourceId}.jsonl (resources, annotations)
|
|
37
|
+
*
|
|
38
|
+
* Events flow: importer → EventBus → Stower → EventStore + Views
|
|
39
|
+
*/
|
|
40
|
+
export declare function importBackup(archive: Readable, options: BackupImporterOptions): Promise<BackupImportResult>;
|
|
41
|
+
//# sourceMappingURL=backup-importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup-importer.d.ts","sourceRoot":"","sources":["../../src/exchange/backup-importer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAEL,KAAK,oBAAoB,EAI1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAqB,KAAK,WAAW,EAA4B,MAAM,UAAU,CAAC;AAEzF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,WAAW,CAAC;CACpB;AAyBD;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CA0E7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exchange Module — Knowledge Base Backup/Restore + Linked Data Export/Import
|
|
3
|
+
*/
|
|
4
|
+
export { exportBackup, type BackupExporterOptions, type BackupEventStoreReader, type BackupContentReader } from './backup-exporter';
|
|
5
|
+
export { importBackup, type BackupImporterOptions, type BackupImportResult } from './backup-importer';
|
|
6
|
+
export { type ReplayStats, type ContentBlobResolver } from './replay';
|
|
7
|
+
export { BACKUP_FORMAT, FORMAT_VERSION, type BackupManifestHeader, type BackupStreamSummary, isBackupManifest, validateManifestVersion, } from './manifest';
|
|
8
|
+
export { exportLinkedData, type LinkedDataExporterOptions, type LinkedDataViewReader, type LinkedDataContentReader } from './linked-data-exporter';
|
|
9
|
+
export { importLinkedData, type LinkedDataImporterOptions, type LinkedDataImportResult } from './linked-data-importer';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exchange/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACpI,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,yBAAyB,EAAE,KAAK,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACnJ,OAAO,EAAE,gBAAgB,EAAE,KAAK,yBAAyB,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linked Data Exporter
|
|
3
|
+
*
|
|
4
|
+
* Produces a JSON-LD tar.gz archive from the current state of the knowledge base.
|
|
5
|
+
* Reads materialized views (not the event log) for a fast, current-state export.
|
|
6
|
+
*
|
|
7
|
+
* Archive structure:
|
|
8
|
+
* .semiont/manifest.jsonld - JSON-LD manifest with format metadata
|
|
9
|
+
* .semiont/resources/{resourceId}.jsonld - One JSON-LD document per resource
|
|
10
|
+
* {checksum}.{ext} - Content blobs (root level)
|
|
11
|
+
*/
|
|
12
|
+
import type { Writable } from 'node:stream';
|
|
13
|
+
import type { Logger } from '@semiont/core';
|
|
14
|
+
import { type LinkedDataManifest } from './manifest';
|
|
15
|
+
import type { ResourceDescriptor } from '@semiont/core';
|
|
16
|
+
import type { Annotation } from '@semiont/core';
|
|
17
|
+
/** Subset of ViewStorage used by the linked-data exporter. */
|
|
18
|
+
export interface LinkedDataViewReader {
|
|
19
|
+
getAll(): Promise<Array<{
|
|
20
|
+
resource: ResourceDescriptor;
|
|
21
|
+
annotations: {
|
|
22
|
+
annotations: Annotation[];
|
|
23
|
+
};
|
|
24
|
+
}>>;
|
|
25
|
+
}
|
|
26
|
+
/** Subset of WorkingTreeStore used by the linked-data exporter. */
|
|
27
|
+
export interface LinkedDataContentReader {
|
|
28
|
+
retrieve(storageUri: string): Promise<Buffer>;
|
|
29
|
+
}
|
|
30
|
+
export interface LinkedDataExporterOptions {
|
|
31
|
+
views: LinkedDataViewReader;
|
|
32
|
+
content: LinkedDataContentReader;
|
|
33
|
+
sourceUrl: string;
|
|
34
|
+
entityTypes: string[];
|
|
35
|
+
includeArchived?: boolean;
|
|
36
|
+
logger?: Logger;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Export the knowledge base as a JSON-LD tar.gz archive.
|
|
40
|
+
*/
|
|
41
|
+
export declare function exportLinkedData(options: LinkedDataExporterOptions, output: Writable): Promise<LinkedDataManifest>;
|
|
42
|
+
//# sourceMappingURL=linked-data-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linked-data-exporter.d.ts","sourceRoot":"","sources":["../../src/exchange/linked-data-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC;QACtB,QAAQ,EAAE,kBAAkB,CAAC;QAC7B,WAAW,EAAE;YAAE,WAAW,EAAE,UAAU,EAAE,CAAA;SAAE,CAAC;KAC5C,CAAC,CAAC,CAAC;CACL;AAaD,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,OAAO,EAAE,uBAAuB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAwED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,kBAAkB,CAAC,CA4E7B"}
|