@semiont/make-meaning 0.5.9 → 0.5.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/README.md +3 -3
- package/dist/index.d.ts +53 -31
- package/dist/index.js +641 -540
- package/dist/index.js.map +1 -1
- package/dist/smelter-main.js +26 -12
- package/dist/smelter-main.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ This package implements the actor model from [ACTOR-MODEL.md](../../docs/system/
|
|
|
13
13
|
Five **access actors** mediate every read and write — the bus-facing interface of the Knowledge Base:
|
|
14
14
|
|
|
15
15
|
- **Stower** (write) — the single write gateway to the Knowledge Base; handles all resource and annotation mutations and job lifecycle events
|
|
16
|
-
- **Browser** (read) — handles all KB read queries: resources, annotations, events, annotation history, referenced-by lookups, entity type and tag-schema listing, and directory browse (merging filesystem listings with KB metadata)
|
|
16
|
+
- **Browser** (read) — handles all KB read queries: resources, annotations, events, annotation history, referenced-by lookups, entity type and tag-schema listing, the collaborator directory (the KB's declared software agents, derived from the workers/actors inference config), and directory browse (merging filesystem listings with KB metadata)
|
|
17
17
|
- **Gatherer** (context assembly) — assembles gathered context for annotations (`gather:requested`) and resources (`gather:resource-requested`); searches vectors for semantically similar passages (adds `semanticContext` to `GatheredContext`)
|
|
18
18
|
- **Matcher** (search/link) — context-driven candidate search with multi-source retrieval, composite structural scoring, and optional LLM semantic scoring
|
|
19
19
|
- **CloneTokenManager** (yield) — manages clone token lifecycle for resource cloning
|
|
@@ -130,7 +130,7 @@ graph TB
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
BUS -->|"yield:create, yield:update, yield:mv<br/>mark:create, mark:delete, mark:update-body<br/>frame:add-entity-type, frame:add-tag-schema<br/>mark:archive, mark:unarchive, mark:update-entity-types<br/>job:start, job:complete, job:fail"| STOWER
|
|
133
|
-
BUS -->|"browse:resource-requested, browse:resources-requested<br/>browse:annotations-requested, browse:annotation-requested<br/>browse:events-requested, browse:annotation-history-requested<br/>browse:referenced-by-requested, browse:entity-types-requested<br/>browse:tag-schemas-requested, browse:directory-requested"| BROWSER
|
|
133
|
+
BUS -->|"browse:resource-requested, browse:resources-requested<br/>browse:annotations-requested, browse:annotation-requested<br/>browse:events-requested, browse:annotation-history-requested<br/>browse:referenced-by-requested, browse:entity-types-requested<br/>browse:tag-schemas-requested, browse:agents-requested<br/>browse:directory-requested"| BROWSER
|
|
134
134
|
BUS -->|"gather:requested<br/>gather:resource-requested"| GATHERER
|
|
135
135
|
BUS -->|"match:search-requested"| MATCHER
|
|
136
136
|
BUS -->|"domain events:<br/>yield:created, yield:updated<br/>yield:representation-added<br/>mark:added, mark:removed, mark:archived"| SMELTER
|
|
@@ -138,7 +138,7 @@ graph TB
|
|
|
138
138
|
BUS -->|"yield:clone-token-requested<br/>yield:clone-resource-requested<br/>yield:clone-create"| CTM
|
|
139
139
|
|
|
140
140
|
STOWER -->|"yield:create-ok, yield:update-ok, yield:move-ok<br/>mark:delete-ok, *-failed replies<br/>(domain events are republished onto the bus<br/>by the EventStore: yield:created, mark:added, ...)"| BUS
|
|
141
|
-
BROWSER -->|"browse:resource-result, browse:resources-result<br/>browse:annotations-result, browse:annotation-result<br/>browse:events-result, browse:annotation-history-result<br/>browse:referenced-by-result, browse:entity-types-result<br/>browse:tag-schemas-result, browse:directory-result"| BUS
|
|
141
|
+
BROWSER -->|"browse:resource-result, browse:resources-result<br/>browse:annotations-result, browse:annotation-result<br/>browse:events-result, browse:annotation-history-result<br/>browse:referenced-by-result, browse:entity-types-result<br/>browse:tag-schemas-result, browse:agents-result<br/>browse:directory-result"| BUS
|
|
142
142
|
GATHERER -->|"gather:complete, gather:failed<br/>gather:resource-complete, gather:resource-failed"| BUS
|
|
143
143
|
MATCHER -->|"match:search-results, match:search-failed"| BUS
|
|
144
144
|
CTM -->|"yield:clone-token-generated<br/>yield:clone-resource-result<br/>yield:clone-created"| BUS
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { JobQueue } from '@semiont/jobs';
|
|
2
2
|
import { SemiontProject } from '@semiont/core/node';
|
|
3
|
-
import { GraphServiceConfig, VectorsServiceConfig, EmbeddingServiceConfig, EventBus, Logger, StoredEvent, ResourceId, ResourceDescriptor, AnnotationId, components, ITransport, BaseUrl, ConnectionState, SemiontError, UserDID, EventMap, IContentTransport, PutBinaryRequest, PutBinaryOptions, AccessToken, Annotation, UserId, ResourceAnnotations, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
3
|
+
import { GraphServiceConfig, VectorsServiceConfig, EmbeddingServiceConfig, EventBus, Logger, StoredEvent, ResourceId, ResourceDescriptor, AnnotationId, components, ITransport, BaseUrl, ConnectionState, SemiontError, UserDID, EventMap, IContentTransport, PutBinaryRequest, PutBinaryOptions, AccessToken, StateUnit, BusRequestPrimitive, Annotation, UserId, GatheredContext, ResourceAnnotations, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
4
4
|
import { EventStore, ViewStorage } from '@semiont/event-sourcing';
|
|
5
5
|
import { WorkingTreeStore } from '@semiont/content';
|
|
6
6
|
import { GraphDatabase } from '@semiont/graph';
|
|
7
7
|
import { VectorStore, EmbeddingProvider, ChunkingConfig } from '@semiont/vectors';
|
|
8
8
|
import { InferenceClient } from '@semiont/inference';
|
|
9
9
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
10
|
-
import {
|
|
10
|
+
import { WorkerBus } from '@semiont/sdk';
|
|
11
11
|
import { Writable, Readable } from 'node:stream';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -49,6 +49,16 @@ interface MakeMeaningConfig {
|
|
|
49
49
|
vectors?: VectorsServiceConfig;
|
|
50
50
|
embedding?: EmbeddingServiceConfig;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* The KB's canonical identity domain — the SAME value `/api/tokens/agent`
|
|
54
|
+
* mints agent DIDs from (backend `site.domain`). The agent roster consumes
|
|
55
|
+
* it verbatim, so directory DIDs and work-stamped `generator` DIDs are
|
|
56
|
+
* equal by construction; it is never derived from service topology
|
|
57
|
+
* (.plans/bugs/agent-did-host-skew.md).
|
|
58
|
+
*/
|
|
59
|
+
site?: {
|
|
60
|
+
domain: string;
|
|
61
|
+
};
|
|
52
62
|
/** Per-actor inference config */
|
|
53
63
|
actors?: ActorInferenceConfig;
|
|
54
64
|
/** Per-worker-type inference config */
|
|
@@ -235,9 +245,10 @@ interface CreateResourceResult {
|
|
|
235
245
|
declare class Stower {
|
|
236
246
|
private kb;
|
|
237
247
|
private eventBus;
|
|
248
|
+
private project;
|
|
238
249
|
private subscription;
|
|
239
250
|
private readonly logger;
|
|
240
|
-
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger);
|
|
251
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, project: SemiontProject, logger: Logger);
|
|
241
252
|
initialize(): Promise<void>;
|
|
242
253
|
private handleYieldCreate;
|
|
243
254
|
private handleYieldUpdate;
|
|
@@ -374,6 +385,8 @@ declare class Matcher {
|
|
|
374
385
|
* - browse:referenced-by-requested — find annotations in the KB graph that reference a resource
|
|
375
386
|
* - browse:entity-types-requested — list entity types from the project projection
|
|
376
387
|
* - browse:tag-schemas-requested — list tag schemas from the project projection
|
|
388
|
+
* - browse:agents-requested — the collaborator directory: the KB's declared software
|
|
389
|
+
* agents, derived from the workers + actors inference config (COLLABORATOR-DIRECTORY)
|
|
377
390
|
* - browse:directory-requested — list a project directory, merging fs + ViewStorage
|
|
378
391
|
*/
|
|
379
392
|
|
|
@@ -382,9 +395,10 @@ declare class Browser {
|
|
|
382
395
|
private kb;
|
|
383
396
|
private eventBus;
|
|
384
397
|
private project;
|
|
398
|
+
private config;
|
|
385
399
|
private subscriptions;
|
|
386
400
|
private readonly logger;
|
|
387
|
-
constructor(views: ViewStorage, kb: KnowledgeBase, eventBus: EventBus, project: SemiontProject, logger: Logger);
|
|
401
|
+
constructor(views: ViewStorage, kb: KnowledgeBase, eventBus: EventBus, project: SemiontProject, config: MakeMeaningConfig, logger: Logger);
|
|
388
402
|
initialize(): Promise<void>;
|
|
389
403
|
private handleBrowseResource;
|
|
390
404
|
private handleBrowseResources;
|
|
@@ -395,6 +409,7 @@ declare class Browser {
|
|
|
395
409
|
private handleReferencedBy;
|
|
396
410
|
private handleEntityTypes;
|
|
397
411
|
private handleTagSchemas;
|
|
412
|
+
private handleBrowseAgents;
|
|
398
413
|
private handleBrowseDirectory;
|
|
399
414
|
stop(): Promise<void>;
|
|
400
415
|
}
|
|
@@ -847,6 +862,16 @@ declare class Smelter {
|
|
|
847
862
|
* or is empty — callers skip it.
|
|
848
863
|
*/
|
|
849
864
|
private fetchEmbeddableText;
|
|
865
|
+
/**
|
|
866
|
+
* Read a resource's current entity types from the materialized view — the
|
|
867
|
+
* authoritative source, updated before the EventBus fires to consumers — so
|
|
868
|
+
* its vectors carry the discriminator `searchResources` filters on (e.g.
|
|
869
|
+
* exclude `['Question']`). One read on every embed path, mirroring how the
|
|
870
|
+
* smelter already reads current content and annotations; a failed read
|
|
871
|
+
* propagates to the pipeline's per-resource error handler (reconcile heals),
|
|
872
|
+
* rather than silently stamping `[]` and letting the resource leak into recall.
|
|
873
|
+
*/
|
|
874
|
+
private resolveEntityTypes;
|
|
850
875
|
private embedResource;
|
|
851
876
|
private handleResourceArchived;
|
|
852
877
|
private handleAnnotationAdded;
|
|
@@ -1013,6 +1038,8 @@ interface ReplayStats {
|
|
|
1013
1038
|
|
|
1014
1039
|
interface BackupImporterOptions {
|
|
1015
1040
|
eventBus: EventBus;
|
|
1041
|
+
/** Replay appends historical events directly (facts, not commands). */
|
|
1042
|
+
eventStore: EventStore;
|
|
1016
1043
|
contentStore: WorkingTreeStore;
|
|
1017
1044
|
logger?: Logger;
|
|
1018
1045
|
}
|
|
@@ -1237,8 +1264,6 @@ declare class ResourceContext {
|
|
|
1237
1264
|
* - Generating AI summaries
|
|
1238
1265
|
*/
|
|
1239
1266
|
|
|
1240
|
-
type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
1241
|
-
|
|
1242
1267
|
type AnnotationContextResponse = components['schemas']['AnnotationContextResponse'];
|
|
1243
1268
|
type ContextualSummaryResponse = components['schemas']['ContextualSummaryResponse'];
|
|
1244
1269
|
interface BuildContextOptions {
|
|
@@ -1258,7 +1283,7 @@ declare class AnnotationContext {
|
|
|
1258
1283
|
* @returns Rich context for LLM processing
|
|
1259
1284
|
* @throws Error if annotation or resource not found
|
|
1260
1285
|
*/
|
|
1261
|
-
static buildLLMContext(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, options?: BuildContextOptions, inferenceClient?: InferenceClient, logger?: Logger, embeddingProvider?: EmbeddingProvider): Promise<
|
|
1286
|
+
static buildLLMContext(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, options?: BuildContextOptions, inferenceClient?: InferenceClient, logger?: Logger, embeddingProvider?: EmbeddingProvider): Promise<GatheredContext>;
|
|
1262
1287
|
/**
|
|
1263
1288
|
* Get resource annotations from view storage (fast path)
|
|
1264
1289
|
* Throws if view missing
|
|
@@ -1332,24 +1357,7 @@ declare class AnnotationContext {
|
|
|
1332
1357
|
* All methods require graph traversal - must use graph database.
|
|
1333
1358
|
*/
|
|
1334
1359
|
|
|
1335
|
-
|
|
1336
|
-
id: string;
|
|
1337
|
-
type: string;
|
|
1338
|
-
label: string;
|
|
1339
|
-
metadata: {
|
|
1340
|
-
entityTypes: string[];
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
interface GraphEdge {
|
|
1344
|
-
source: string;
|
|
1345
|
-
target: string;
|
|
1346
|
-
type: string;
|
|
1347
|
-
metadata: Record<string, unknown>;
|
|
1348
|
-
}
|
|
1349
|
-
interface GraphRepresentation {
|
|
1350
|
-
nodes: GraphNode[];
|
|
1351
|
-
edges: GraphEdge[];
|
|
1352
|
-
}
|
|
1360
|
+
type KnowledgeGraph = components['schemas']['KnowledgeGraph'];
|
|
1353
1361
|
declare class GraphContext {
|
|
1354
1362
|
/**
|
|
1355
1363
|
* Get all resources referencing this resource (backlinks)
|
|
@@ -1372,10 +1380,20 @@ declare class GraphContext {
|
|
|
1372
1380
|
*/
|
|
1373
1381
|
static searchResources(query: string, kb: KnowledgeBase, limit?: number): Promise<ResourceDescriptor[]>;
|
|
1374
1382
|
/**
|
|
1375
|
-
* Build
|
|
1376
|
-
*
|
|
1383
|
+
* Build the unified knowledge graph for a resource's neighborhood:
|
|
1384
|
+
* resources AND annotations as typed nodes, typed/directional edges.
|
|
1385
|
+
*
|
|
1386
|
+
* This is the single graph builder (CONTEXT-UNIFICATION D3) — both the
|
|
1387
|
+
* matcher (ranking) and the resource/viz path consume it. The flattened
|
|
1388
|
+
* signals the matcher reads today (`connections`, `citedBy`/count,
|
|
1389
|
+
* `siblingEntityTypes`, `bidirectional`) are all derivable from this:
|
|
1390
|
+
* - peer connections → resource nodes + main→peer edges carrying `bidirectional`
|
|
1391
|
+
* - inbound citations → citing-resource nodes + `citation` edges (citing→main),
|
|
1392
|
+
* so citedByCount = inbound citation-edge count
|
|
1393
|
+
* - annotations on the resource → `annotation` nodes + `annotation-of` edges,
|
|
1394
|
+
* so siblingEntityTypes = union of those nodes' entityTypes
|
|
1377
1395
|
*/
|
|
1378
|
-
static
|
|
1396
|
+
static buildKnowledgeGraph(resourceId: ResourceId, kb: KnowledgeBase): Promise<KnowledgeGraph>;
|
|
1379
1397
|
}
|
|
1380
1398
|
|
|
1381
1399
|
/**
|
|
@@ -1385,19 +1403,23 @@ declare class GraphContext {
|
|
|
1385
1403
|
* Orchestrates: ResourceContext, GraphContext, AnnotationContext, and generation functions
|
|
1386
1404
|
*/
|
|
1387
1405
|
|
|
1388
|
-
type ResourceLLMContextResponse = components['schemas']['ResourceLLMContextResponse'];
|
|
1389
1406
|
interface LLMContextOptions {
|
|
1390
1407
|
depth: number;
|
|
1391
1408
|
maxResources: number;
|
|
1392
1409
|
includeContent: boolean;
|
|
1393
1410
|
includeSummary: boolean;
|
|
1411
|
+
/**
|
|
1412
|
+
* Entity types to exclude from the resource-gather semantic recall
|
|
1413
|
+
* (caller-supplied; e.g. ['Question']). Optional; default none.
|
|
1414
|
+
*/
|
|
1415
|
+
excludeEntityTypes?: string[];
|
|
1394
1416
|
}
|
|
1395
1417
|
declare class LLMContext {
|
|
1396
1418
|
/**
|
|
1397
1419
|
* Get comprehensive LLM context for a resource
|
|
1398
1420
|
* Includes: main resource, related resources, annotations, graph, content, summary, references
|
|
1399
1421
|
*/
|
|
1400
|
-
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions, kb: KnowledgeBase, inferenceClient: InferenceClient): Promise<
|
|
1422
|
+
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions, kb: KnowledgeBase, inferenceClient: InferenceClient): Promise<GatheredContext>;
|
|
1401
1423
|
}
|
|
1402
1424
|
|
|
1403
1425
|
/**
|
|
@@ -1421,4 +1443,4 @@ declare function generateResourceSummary(resourceName: string, content: string,
|
|
|
1421
1443
|
declare function generateReferenceSuggestions(referenceTitle: string, client: InferenceClient, entityType?: string, currentContent?: string): Promise<string[] | null>;
|
|
1422
1444
|
|
|
1423
1445
|
export { AnnotationContext, AnnotationOperations, BACKUP_FORMAT, Browser, CloneTokenManager, FORMAT_VERSION, Gatherer$1 as Gatherer, GraphContext, LLMContext, LocalContentTransport, LocalTransport, Matcher, ResourceContext, ResourceOperations, Smelter, Stower, bootstrapEntityTypes, createKnowledgeBase, createSmelterActorStateUnit, exportBackup, exportLinkedData, generateReferenceSuggestions, generateResourceSummary, importBackup, importLinkedData, isBackupManifest, readEntityTypesProjection, registerAnnotationAssemblyHandler, registerAnnotationLookupHandlers, registerBindUpdateBodyHandler, registerBusHandlers, registerJobCommandHandlers, startMakeMeaning, stopKnowledgeSystem, validateManifestVersion };
|
|
1424
|
-
export type { BackupContentReader, BackupEventStoreReader, BackupExporterOptions, BackupImportResult, BackupImporterOptions, BackupManifestHeader, BackupStreamSummary, BuildContextOptions, ContentBlobResolver, CreateAnnotationResult, CreateResourceInput, CreateResourceResult,
|
|
1446
|
+
export type { BackupContentReader, BackupEventStoreReader, BackupExporterOptions, BackupImportResult, BackupImporterOptions, BackupManifestHeader, BackupStreamSummary, BuildContextOptions, ContentBlobResolver, CreateAnnotationResult, CreateResourceInput, CreateResourceResult, KnowledgeBase, KnowledgeSystem, LLMContextOptions, LinkedDataContentReader, LinkedDataExporterOptions, LinkedDataImportResult, LinkedDataImporterOptions, LinkedDataViewReader, ListResourcesFilters, LocalTransportConfig, MakeMeaningConfig, MakeMeaningService, ReconcileState, ReconcileSummary, ReplayStats, SmelterActorStateUnit, SmelterActorStateUnitOptions, SmelterEvent, SmelterInput, SmelterTiming, SmelterWorkItem, UpdateAnnotationBodyResult };
|