@semiont/core 0.5.1 → 0.5.2

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/index.d.ts CHANGED
@@ -2223,7 +2223,7 @@ interface components {
2223
2223
  annotationId: string;
2224
2224
  operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
2225
2225
  };
2226
- /** @description Payload for mark:entity-type-added domain event */
2226
+ /** @description Payload for frame:entity-type-added domain event (system-level, no resourceId — fan-out is global) */
2227
2227
  EntityTypeAddedPayload: {
2228
2228
  entityType: string;
2229
2229
  };
@@ -3198,8 +3198,8 @@ interface components {
3198
3198
  [key: string]: number;
3199
3199
  };
3200
3200
  };
3201
- /** @description Bus command to add a new entity type tag. */
3202
- MarkAddEntityTypeCommand: {
3201
+ /** @description Bus command to add a new entity type to the KB's vocabulary. Carried on the `frame:add-entity-type` channel — Frame is the schema-layer flow that owns vocabulary writes. */
3202
+ FrameAddEntityTypeCommand: {
3203
3203
  tag: string;
3204
3204
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3205
3205
  _userId?: string;
@@ -3675,14 +3675,14 @@ type PersistedEventCatalog = {
3675
3675
  'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
3676
3676
  'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
3677
3677
  'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
3678
- 'mark:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
3678
+ 'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
3679
3679
  'job:started': components['schemas']['JobStartedPayload'];
3680
3680
  'job:progress': components['schemas']['JobProgressPayload'];
3681
3681
  'job:completed': components['schemas']['JobCompletedPayload'];
3682
3682
  'job:failed': components['schemas']['JobFailedPayload'];
3683
3683
  };
3684
3684
  /** System event types — persisted events that have no resourceId. */
3685
- type SystemEventType = 'mark:entity-type-added';
3685
+ type SystemEventType = 'frame:entity-type-added';
3686
3686
  /** Extract the concrete persisted event type for a given type string. */
3687
3687
  type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
3688
3688
  type: K;
@@ -3707,7 +3707,7 @@ type PersistedEventType = PersistedEvent['type'];
3707
3707
  * also adding it here: forgetting fails to typecheck rather than silently
3708
3708
  * dropping the event from the events-stream.
3709
3709
  */
3710
- declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "mark:entity-type-added", "job:started", "job:progress", "job:completed", "job:failed"];
3710
+ declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "frame:entity-type-added", "job:started", "job:progress", "job:completed", "job:failed"];
3711
3711
  /** Input type for appendEvent — PersistedEvent without id/timestamp (assigned at persistence time). */
3712
3712
  type EventInput = Omit<PersistedEvent, 'id' | 'timestamp'>;
3713
3713
 
@@ -3868,7 +3868,6 @@ type EventMap = {
3868
3868
  'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
3869
3869
  'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
3870
3870
  'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
3871
- 'mark:entity-type-added': StoredEvent<EventOfType<'mark:entity-type-added'>>;
3872
3871
  'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
3873
3872
  'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
3874
3873
  'mark:create-request': components['schemas']['MarkCreateRequest'];
@@ -3878,13 +3877,11 @@ type EventMap = {
3878
3877
  'mark:archive': components['schemas']['MarkArchiveCommand'];
3879
3878
  'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
3880
3879
  'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
3881
- 'mark:add-entity-type': components['schemas']['MarkAddEntityTypeCommand'];
3882
3880
  'mark:create-ok': components['schemas']['MarkCreateOk'];
3883
3881
  'mark:create-failed': components['schemas']['CommandError'];
3884
3882
  'mark:delete-ok': components['schemas']['MarkDeleteOk'];
3885
3883
  'mark:delete-failed': components['schemas']['CommandError'];
3886
3884
  'mark:body-update-failed': components['schemas']['CommandError'];
3887
- 'mark:entity-type-add-failed': components['schemas']['CommandError'];
3888
3885
  'mark:select-comment': components['schemas']['SelectionData'];
3889
3886
  'mark:select-tag': components['schemas']['SelectionData'];
3890
3887
  'mark:select-assessment': components['schemas']['SelectionData'];
@@ -3899,6 +3896,9 @@ type EventMap = {
3899
3896
  'mark:selection-changed': components['schemas']['MarkSelectionChangedEvent'];
3900
3897
  'mark:click-changed': components['schemas']['MarkClickChangedEvent'];
3901
3898
  'mark:shape-changed': components['schemas']['MarkShapeChangedEvent'];
3899
+ 'frame:entity-type-added': StoredEvent<EventOfType<'frame:entity-type-added'>>;
3900
+ 'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
3901
+ 'frame:entity-type-add-failed': components['schemas']['CommandError'];
3902
3902
  'bind:initiate': BindInitiateCommand;
3903
3903
  'bind:update-body': BindUpdateBodyCommand;
3904
3904
  'bind:body-updated': components['schemas']['BindBodyUpdated'];
@@ -4079,7 +4079,7 @@ type EventName = keyof EventMap;
4079
4079
  *
4080
4080
  * The frontend's `subscribeToResource(id)` wires these channels via
4081
4081
  * `scope=id&scoped=<channel>` so the SSE route delivers them to that
4082
- * participant. WorkerVM uses this list to decide which emitted events to
4082
+ * participant. WorkerStateUnit uses this list to decide which emitted events to
4083
4083
  * scope to their resource.
4084
4084
  */
4085
4085
  /**
@@ -4145,7 +4145,7 @@ declare const CHANNEL_SCHEMAS: {
4145
4145
  readonly 'mark:body-updated': null;
4146
4146
  readonly 'mark:entity-tag-added': null;
4147
4147
  readonly 'mark:entity-tag-removed': null;
4148
- readonly 'mark:entity-type-added': null;
4148
+ readonly 'frame:entity-type-added': null;
4149
4149
  readonly 'mark:archived': null;
4150
4150
  readonly 'mark:unarchived': null;
4151
4151
  readonly 'mark:create-request': "MarkCreateRequest";
@@ -4155,13 +4155,13 @@ declare const CHANNEL_SCHEMAS: {
4155
4155
  readonly 'mark:archive': "MarkArchiveCommand";
4156
4156
  readonly 'mark:unarchive': "MarkUnarchiveCommand";
4157
4157
  readonly 'mark:update-entity-types': "MarkUpdateEntityTypesCommand";
4158
- readonly 'mark:add-entity-type': "MarkAddEntityTypeCommand";
4158
+ readonly 'frame:add-entity-type': "FrameAddEntityTypeCommand";
4159
4159
  readonly 'mark:create-ok': "MarkCreateOk";
4160
4160
  readonly 'mark:create-failed': "CommandError";
4161
4161
  readonly 'mark:delete-ok': "MarkDeleteOk";
4162
4162
  readonly 'mark:delete-failed': "CommandError";
4163
4163
  readonly 'mark:body-update-failed': "CommandError";
4164
- readonly 'mark:entity-type-add-failed': "CommandError";
4164
+ readonly 'frame:entity-type-add-failed': "CommandError";
4165
4165
  readonly 'mark:select-comment': "SelectionData";
4166
4166
  readonly 'mark:select-tag': "SelectionData";
4167
4167
  readonly 'mark:select-assessment': "SelectionData";
@@ -5000,6 +5000,54 @@ declare function getNodeEncoding(charset: string): BufferEncoding;
5000
5000
  */
5001
5001
  declare function decodeRepresentation(buffer: Buffer, mediaType: string): string;
5002
5002
 
5003
+ /**
5004
+ * Common error classes — the unified Semiont error hierarchy.
5005
+ *
5006
+ * `SemiontError` is the base every other Semiont error class extends:
5007
+ * `APIError` (api-client), `BusRequestError` and `SemiontSessionError` (sdk),
5008
+ * `ValidationError`, `ScriptError`, `NotFoundError`, `UnauthorizedError`,
5009
+ * `ConflictError` (here), and `AWSError` (cli). Subclasses tighten the
5010
+ * `code` field to a literal-union for discriminated handling.
5011
+ */
5012
+ /**
5013
+ * Transport-neutral error vocabulary. Every transport that surfaces
5014
+ * errors over `ITransport.errors$` maps its native failure modes to one
5015
+ * of these codes — HTTP `APIError` maps from status code, in-process
5016
+ * transports map from local failure shape, gRPC would map from status
5017
+ * code, etc. Routing layers (e.g. `SemiontBrowser`'s session-expired /
5018
+ * permission-denied modal routing) match on this vocabulary so they
5019
+ * stay transport-agnostic.
5020
+ *
5021
+ * - `unauthorized` — auth required / token missing or expired (HTTP 401)
5022
+ * - `forbidden` — auth ok but lacks permission (HTTP 403)
5023
+ * - `not-found` — resource missing (HTTP 404)
5024
+ * - `conflict` — concurrent modification, duplicate, etc. (HTTP 409)
5025
+ * - `bad-request` — request malformed (HTTP 400)
5026
+ * - `unavailable` — backend unreachable, network error, 5xx
5027
+ * - `error` — unclassified fallback
5028
+ */
5029
+ type TransportErrorCode = 'unauthorized' | 'forbidden' | 'not-found' | 'conflict' | 'bad-request' | 'unavailable' | 'error';
5030
+ declare class SemiontError extends Error {
5031
+ code: string;
5032
+ details?: Record<string, unknown> | undefined;
5033
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
5034
+ }
5035
+ declare class ValidationError extends SemiontError {
5036
+ constructor(message: string, details?: Record<string, unknown>);
5037
+ }
5038
+ declare class ScriptError extends SemiontError {
5039
+ constructor(message: string, code?: string, details?: Record<string, unknown>);
5040
+ }
5041
+ declare class NotFoundError extends SemiontError {
5042
+ constructor(resource: string, id?: string);
5043
+ }
5044
+ declare class UnauthorizedError extends SemiontError {
5045
+ constructor(message?: string, details?: Record<string, unknown>);
5046
+ }
5047
+ declare class ConflictError extends SemiontError {
5048
+ constructor(message: string, details?: Record<string, unknown>);
5049
+ }
5050
+
5003
5051
  /**
5004
5052
  * Transport interfaces — the shared contract for any wire-or-local
5005
5053
  * communication path consumed by `SemiontClient`. Concrete implementations
@@ -5007,10 +5055,15 @@ declare function decodeRepresentation(buffer: Buffer, mediaType: string): string
5007
5055
  * `@semiont/api-client`, in-process variants in `@semiont/make-meaning`,
5008
5056
  * etc.).
5009
5057
  *
5010
- * Two interfaces:
5058
+ * Three interfaces:
5011
5059
  *
5012
- * ITransport — full surface: bus primitives + auth + admin +
5013
- * exchange + health/status + connection state.
5060
+ * ITransport — bus primitives + lifecycle. Universal: every
5061
+ * concrete transport implements this.
5062
+ * IBackendOperations — auth, admin, exchange, system endpoints.
5063
+ * HTTP-shaped today; an in-process transport may
5064
+ * implement none, some, or a different set.
5065
+ * Optional on `SemiontClient` — passed only when
5066
+ * the host has a backend that supports them.
5014
5067
  * IContentTransport — binary I/O (putBinary / getBinary). Narrow by
5015
5068
  * design because binary has different backpressure
5016
5069
  * and streaming characteristics.
@@ -5084,6 +5137,21 @@ type ProgressEvent = {
5084
5137
  result?: Record<string, unknown>;
5085
5138
  };
5086
5139
  type ProgressCallback = (event: ProgressEvent) => void;
5140
+ /**
5141
+ * Stream-shaped return type for backend download operations
5142
+ * (`backupKnowledgeBase`, `exportKnowledgeBase`). Transport-neutral —
5143
+ * any implementation can produce a `ReadableStream<Uint8Array>` without
5144
+ * fabricating a fetch `Response`. HTTP wraps `response.body` and
5145
+ * `response.headers`; in-process implementations return their own stream.
5146
+ *
5147
+ * The same shape `IContentTransport.getBinaryStream` already uses for
5148
+ * binary downloads.
5149
+ */
5150
+ interface BackendDownload {
5151
+ stream: ReadableStream<Uint8Array>;
5152
+ contentType: string;
5153
+ filename?: string;
5154
+ }
5087
5155
  interface ITransport {
5088
5156
  /**
5089
5157
  * Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
@@ -5118,6 +5186,38 @@ interface ITransport {
5118
5186
  * an in-process transport bridges from the local actor bus.
5119
5187
  */
5120
5188
  bridgeInto(bus: EventBus): void;
5189
+ /**
5190
+ * Transport-level connection state. For HTTP, reflects the SSE
5191
+ * connection's health; for in-process transports, typically `'open'`
5192
+ * from construction onward (no connection to lose).
5193
+ */
5194
+ readonly state$: Observable<ConnectionState>;
5195
+ /**
5196
+ * Stream of transport-level errors surfaced from typed-wire methods or
5197
+ * other transport-mediated round-trips, just before they're thrown to
5198
+ * the caller. Each emission is a `SemiontError` (or subclass — HTTP
5199
+ * emits `APIError`, in-process transports emit whatever subclass is
5200
+ * appropriate). Consumers can subscribe for global error handling
5201
+ * (e.g. surfacing 401/403 as modals, logging) without wrapping every
5202
+ * call site in try/catch. Distinct from bus-level errors, which are
5203
+ * surfaced via the channel-correlation pattern in `busRequest`.
5204
+ */
5205
+ readonly errors$: Observable<SemiontError>;
5206
+ dispose(): void;
5207
+ }
5208
+ /**
5209
+ * Auth, admin, exchange, and system endpoints. HTTP-shaped today —
5210
+ * `HttpTransport` implements both this and `ITransport`; the
5211
+ * `SemiontClient` constructor takes a `IBackendOperations` argument
5212
+ * separately from the bus transport so non-HTTP transports
5213
+ * (`LocalTransport`) can implement just the bus surface and the
5214
+ * SemiontClient cleanly omits `client.auth` / `client.admin`.
5215
+ *
5216
+ * Implementations should map their native error codes to
5217
+ * `TransportErrorCode` (see `errors.ts`) so the routing layer
5218
+ * (`SemiontBrowser`) stays transport-neutral.
5219
+ */
5220
+ interface IBackendOperations {
5121
5221
  authenticatePassword(email: Email, password: string): Promise<AuthResponse>;
5122
5222
  authenticateGoogle(credential: GoogleCredential): Promise<AuthResponse>;
5123
5223
  refreshAccessToken(token: RefreshToken): Promise<TokenRefreshResponse>;
@@ -5134,21 +5234,24 @@ interface ITransport {
5134
5234
  getUserStats(): Promise<AdminUserStatsResponse>;
5135
5235
  updateUser(id: UserDID, data: UpdateUserRequest): Promise<UpdateUserResponse>;
5136
5236
  getOAuthConfig(): Promise<OAuthConfigResponse>;
5137
- backupKnowledgeBase(): Promise<Response>;
5138
- restoreKnowledgeBase(file: File, onProgress?: ProgressCallback): Promise<ProgressEvent>;
5237
+ backupKnowledgeBase(): Promise<BackendDownload>;
5238
+ /**
5239
+ * Stream of `ProgressEvent`s for a restore/import operation. The
5240
+ * Observable emits each progress event in order and completes when
5241
+ * the operation is done; the final event carries `phase: 'complete'`
5242
+ * (or `'error'` / `'failed'` followed by an Observable error).
5243
+ *
5244
+ * The SDK wraps the contract's `Observable<ProgressEvent>` as a
5245
+ * `StreamObservable<ProgressEvent>` so consumers can `await` for the
5246
+ * final event or `.subscribe(...)` to render every step.
5247
+ */
5248
+ restoreKnowledgeBase(file: File): Observable<ProgressEvent>;
5139
5249
  exportKnowledgeBase(params?: {
5140
5250
  includeArchived?: boolean;
5141
- }): Promise<Response>;
5142
- importKnowledgeBase(file: File, onProgress?: ProgressCallback): Promise<ProgressEvent>;
5251
+ }): Promise<BackendDownload>;
5252
+ importKnowledgeBase(file: File): Observable<ProgressEvent>;
5143
5253
  healthCheck(): Promise<HealthCheckResponse>;
5144
5254
  getStatus(): Promise<StatusResponse>;
5145
- /**
5146
- * Transport-level connection state. For HTTP, reflects the SSE
5147
- * connection's health; for in-process transports, typically `'open'`
5148
- * from construction onward (no connection to lose).
5149
- */
5150
- readonly state$: Observable<ConnectionState>;
5151
- dispose(): void;
5152
5255
  }
5153
5256
  interface PutBinaryRequest {
5154
5257
  name: string;
@@ -5164,10 +5267,36 @@ interface PutBinaryRequest {
5164
5267
  generator?: Agent$1 | Agent$1[];
5165
5268
  isDraft?: boolean;
5166
5269
  }
5270
+ /**
5271
+ * Optional byte-progress hook for `putBinary`. Receives raw byte counts;
5272
+ * derived shapes (percentage, ETA) are the caller's responsibility.
5273
+ *
5274
+ * `totalBytes` may be 0 when the underlying transport can't determine it
5275
+ * (chunked encoding, indeterminate streams). Consumers should render an
5276
+ * indeterminate state in that case.
5277
+ */
5278
+ type PutBinaryProgress = (event: {
5279
+ bytesUploaded: number;
5280
+ totalBytes: number;
5281
+ }) => void;
5282
+ interface PutBinaryOptions {
5283
+ auth?: AccessToken;
5284
+ /**
5285
+ * Called as bytes flow over the wire. Honored by transports that can
5286
+ * observe upload progress (HTTP via XHR). Transports that can't
5287
+ * (in-process LocalContentTransport, current `ky`-based fetch path
5288
+ * with no `onProgress`) simply ignore it.
5289
+ */
5290
+ onProgress?: PutBinaryProgress;
5291
+ /**
5292
+ * Signal that aborts the in-flight request. The XHR-based HTTP path
5293
+ * calls `xhr.abort()` when the signal fires; in-process and
5294
+ * non-XHR HTTP paths complete in the background after abort.
5295
+ */
5296
+ signal?: AbortSignal;
5297
+ }
5167
5298
  interface IContentTransport {
5168
- putBinary(request: PutBinaryRequest, options?: {
5169
- auth?: AccessToken;
5170
- }): Promise<{
5299
+ putBinary(request: PutBinaryRequest, options?: PutBinaryOptions): Promise<{
5171
5300
  resourceId: ResourceId;
5172
5301
  }>;
5173
5302
  getBinary(resourceId: ResourceId, options?: {
@@ -5202,7 +5331,7 @@ interface IContentTransport {
5202
5331
  * Resource-scoped channels (joined/left via `subscribeToResource`) are
5203
5332
  * tracked separately by transports that care about scope (HTTP).
5204
5333
  */
5205
- declare const BRIDGED_CHANNELS: readonly ["browse:resources-result", "browse:resources-failed", "browse:resource-result", "browse:resource-failed", "browse:annotations-result", "browse:annotations-failed", "browse:annotation-result", "browse:annotation-failed", "browse:annotation-history-result", "browse:annotation-history-failed", "browse:events-result", "browse:events-failed", "browse:referenced-by-result", "browse:referenced-by-failed", "browse:entity-types-result", "browse:entity-types-failed", "browse:directory-result", "browse:directory-failed", "browse:annotation-context-result", "browse:annotation-context-failed", "mark:delete-ok", "mark:delete-failed", "mark:create-ok", "mark:create-failed", "match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "gather:annotation-finished", "gather:summary-result", "gather:summary-failed", "bind:body-updated", "bind:body-update-failed", "job:report-progress", "job:complete", "job:fail", "job:status-result", "job:status-failed", "job:created", "job:create-failed", "job:claimed", "job:claim-failed", "yield:clone-token-generated", "yield:clone-token-failed", "yield:clone-resource-result", "yield:clone-resource-failed", "yield:clone-created", "yield:clone-create-failed", "mark:entity-type-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
5334
+ declare const BRIDGED_CHANNELS: readonly ["browse:resources-result", "browse:resources-failed", "browse:resource-result", "browse:resource-failed", "browse:annotations-result", "browse:annotations-failed", "browse:annotation-result", "browse:annotation-failed", "browse:annotation-history-result", "browse:annotation-history-failed", "browse:events-result", "browse:events-failed", "browse:referenced-by-result", "browse:referenced-by-failed", "browse:entity-types-result", "browse:entity-types-failed", "browse:directory-result", "browse:directory-failed", "browse:annotation-context-result", "browse:annotation-context-failed", "mark:delete-ok", "mark:delete-failed", "mark:create-ok", "mark:create-failed", "match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "gather:annotation-finished", "gather:summary-result", "gather:summary-failed", "bind:body-updated", "bind:body-update-failed", "job:report-progress", "job:complete", "job:fail", "job:status-result", "job:status-failed", "job:created", "job:create-failed", "job:claimed", "job:claim-failed", "yield:create-ok", "yield:create-failed", "yield:update-ok", "yield:update-failed", "yield:clone-token-generated", "yield:clone-token-failed", "yield:clone-resource-result", "yield:clone-resource-failed", "yield:clone-created", "yield:clone-create-failed", "frame:entity-type-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
5206
5335
  type BridgedChannel = typeof BRIDGED_CHANNELS[number];
5207
5336
 
5208
5337
  /**
@@ -5650,36 +5779,6 @@ declare function isNullish(value: unknown): value is null | undefined;
5650
5779
  */
5651
5780
  declare function isDefined<T>(value: T | null | undefined): value is T;
5652
5781
 
5653
- /**
5654
- * Common error classes — the unified Semiont error hierarchy.
5655
- *
5656
- * `SemiontError` is the base every other Semiont error class extends:
5657
- * `APIError` (api-client), `BusRequestError` and `SemiontSessionError` (sdk),
5658
- * `ValidationError`, `ScriptError`, `NotFoundError`, `UnauthorizedError`,
5659
- * `ConflictError` (here), and `AWSError` (cli). Subclasses tighten the
5660
- * `code` field to a literal-union for discriminated handling.
5661
- */
5662
- declare class SemiontError extends Error {
5663
- code: string;
5664
- details?: Record<string, unknown> | undefined;
5665
- constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
5666
- }
5667
- declare class ValidationError extends SemiontError {
5668
- constructor(message: string, details?: Record<string, unknown>);
5669
- }
5670
- declare class ScriptError extends SemiontError {
5671
- constructor(message: string, code?: string, details?: Record<string, unknown>);
5672
- }
5673
- declare class NotFoundError extends SemiontError {
5674
- constructor(resource: string, id?: string);
5675
- }
5676
- declare class UnauthorizedError extends SemiontError {
5677
- constructor(message?: string, details?: Record<string, unknown>);
5678
- }
5679
- declare class ConflictError extends SemiontError {
5680
- constructor(message: string, details?: Record<string, unknown>);
5681
- }
5682
-
5683
5782
  /**
5684
5783
  * DID (Decentralized Identifier) and W3C Agent utilities
5685
5784
  *
@@ -5865,4 +5964,4 @@ declare function getAllPlatformTypes(): PlatformType[];
5865
5964
  declare const CORE_TYPES_VERSION = "0.1.0";
5866
5965
  declare const SDK_VERSION = "0.1.0";
5867
5966
 
5868
- export { type AccessToken, type Annotation, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, BRIDGED_CHANNELS, type BaseUrl, type BodyItem, type BodyItemIdentity, type BodyOperation, type BoundingBox, type Brand, type BridgedChannel, type BurstBufferOptions, type BusOp, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ConnectionState, type ContentCache, type ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EmittableChannel, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, type EventBase, EventBus, type EventInput, type EventMap, type EventMetadata, type EventName, type EventOfType, type EventQuery, type EventSignature, type FragmentSelector, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type HealthCheckResponse, type IContentTransport, type ITransport, JWTTokenSchema, type JobId, LOCALES, type ListUsersResponse, type LocaleInfo, type Logger, type MCPToken, type MatchQuality, type MimeCategory, type Motivation, NotFoundError, PERSISTED_EVENT_TYPES, type PersistedEvent, type PersistedEventType, type PlatformType, type Point, type ProgressCallback, type ProgressEvent, type PutBinaryRequest, RESOURCE_BROADCAST_TYPES, type RefreshToken, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceBroadcastType, type ResourceDescriptor, type ResourceFilter, type ResourceId, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StatusResponse, type StoredEvent, type StoredEventLike, type SvgSelector, type TextPosition, type TextPositionSelector, type TextQuoteSelector, type ActorInferenceConfig as TomlActorInferenceConfig, type TomlFileReader, type InferenceConfig as TomlInferenceConfig, type WorkerInferenceConfig as TomlWorkerInferenceConfig, UnauthorizedError, type UpdateResourceInput, type UpdateUserRequest, type UpdateUserResponse, type UserDID, type UserId, type UserResponse, type ValidatedAnnotation, ValidationError, type ValidationFailure, type ValidationResult, type ValidationSuccess, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, type components, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, type operations, parseEnvironment, parseSvgSelector, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
5967
+ export { type AccessToken, type Annotation, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, BRIDGED_CHANNELS, type BackendDownload, type BaseUrl, type BodyItem, type BodyItemIdentity, type BodyOperation, type BoundingBox, type Brand, type BridgedChannel, type BurstBufferOptions, type BusOp, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ConnectionState, type ContentCache, type ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EmittableChannel, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, type EventBase, EventBus, type EventInput, type EventMap, type EventMetadata, type EventName, type EventOfType, type EventQuery, type EventSignature, type FragmentSelector, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type HealthCheckResponse, type IBackendOperations, type IContentTransport, type ITransport, JWTTokenSchema, type JobId, LOCALES, type ListUsersResponse, type LocaleInfo, type Logger, type MCPToken, type MatchQuality, type MimeCategory, type Motivation, NotFoundError, PERSISTED_EVENT_TYPES, type PersistedEvent, type PersistedEventType, type PlatformType, type Point, type ProgressCallback, type ProgressEvent, type PutBinaryOptions, type PutBinaryProgress, type PutBinaryRequest, RESOURCE_BROADCAST_TYPES, type RefreshToken, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceBroadcastType, type ResourceDescriptor, type ResourceFilter, type ResourceId, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StatusResponse, type StoredEvent, type StoredEventLike, type SvgSelector, type TextPosition, type TextPositionSelector, type TextQuoteSelector, type ActorInferenceConfig as TomlActorInferenceConfig, type TomlFileReader, type InferenceConfig as TomlInferenceConfig, type WorkerInferenceConfig as TomlWorkerInferenceConfig, type TransportErrorCode, UnauthorizedError, type UpdateResourceInput, type UpdateUserRequest, type UpdateUserResponse, type UserDID, type UserId, type UserResponse, type ValidatedAnnotation, ValidationError, type ValidationFailure, type ValidationResult, type ValidationSuccess, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, type components, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, type operations, parseEnvironment, parseSvgSelector, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
package/dist/index.js CHANGED
@@ -109,7 +109,7 @@ var PERSISTED_EVENT_TYPES = [
109
109
  "mark:unarchived",
110
110
  "mark:entity-tag-added",
111
111
  "mark:entity-tag-removed",
112
- "mark:entity-type-added",
112
+ "frame:entity-type-added",
113
113
  "job:started",
114
114
  "job:progress",
115
115
  "job:completed",
@@ -169,7 +169,7 @@ var CHANNEL_SCHEMAS = {
169
169
  "mark:body-updated": null,
170
170
  "mark:entity-tag-added": null,
171
171
  "mark:entity-tag-removed": null,
172
- "mark:entity-type-added": null,
172
+ "frame:entity-type-added": null,
173
173
  "mark:archived": null,
174
174
  "mark:unarchived": null,
175
175
  "mark:create-request": "MarkCreateRequest",
@@ -179,13 +179,13 @@ var CHANNEL_SCHEMAS = {
179
179
  "mark:archive": "MarkArchiveCommand",
180
180
  "mark:unarchive": "MarkUnarchiveCommand",
181
181
  "mark:update-entity-types": "MarkUpdateEntityTypesCommand",
182
- "mark:add-entity-type": "MarkAddEntityTypeCommand",
182
+ "frame:add-entity-type": "FrameAddEntityTypeCommand",
183
183
  "mark:create-ok": "MarkCreateOk",
184
184
  "mark:create-failed": "CommandError",
185
185
  "mark:delete-ok": "MarkDeleteOk",
186
186
  "mark:delete-failed": "CommandError",
187
187
  "mark:body-update-failed": "CommandError",
188
- "mark:entity-type-add-failed": "CommandError",
188
+ "frame:entity-type-add-failed": "CommandError",
189
189
  "mark:select-comment": "SelectionData",
190
190
  "mark:select-tag": "SelectionData",
191
191
  "mark:select-assessment": "SelectionData",
@@ -349,6 +349,34 @@ function isEventRelatedToAnnotation(event, annotationUri2) {
349
349
  function isStoredEvent(event) {
350
350
  return event && typeof event.id === "string" && typeof event.timestamp === "string" && typeof event.type === "string" && typeof event.metadata === "object" && typeof event.metadata.sequenceNumber === "number";
351
351
  }
352
+
353
+ // src/bus-log.ts
354
+ var NODE_BUS_LOG = typeof process !== "undefined" && !!process.env?.SEMIONT_BUS_LOG;
355
+ function busLogEnabled() {
356
+ const g = globalThis;
357
+ if (g.__SEMIONT_BUS_LOG__) return true;
358
+ return NODE_BUS_LOG;
359
+ }
360
+ var traceIdProvider;
361
+ function setBusLogTraceIdProvider(fn) {
362
+ traceIdProvider = fn;
363
+ }
364
+ function busLog(op, channel, payload, scope) {
365
+ if (!busLogEnabled()) return;
366
+ const cidRaw = payload?.correlationId;
367
+ const cid = typeof cidRaw === "string" ? cidRaw.slice(0, 8) : void 0;
368
+ let traceId;
369
+ if (traceIdProvider) {
370
+ try {
371
+ traceId = traceIdProvider();
372
+ } catch {
373
+ }
374
+ }
375
+ const tag = `[bus ${op}] ${channel}` + (scope ? ` scope=${scope}` : "") + (cid ? ` cid=${cid}` : "") + (traceId ? ` trace=${traceId.slice(0, 8)}` : "");
376
+ console.debug(tag, payload);
377
+ }
378
+
379
+ // src/event-bus.ts
352
380
  var EventBus = class {
353
381
  subjects;
354
382
  isDestroyed;
@@ -384,7 +412,15 @@ var EventBus = class {
384
412
  throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);
385
413
  }
386
414
  if (!this.subjects.has(eventName)) {
387
- this.subjects.set(eventName, new Subject());
415
+ const subject = new Subject();
416
+ if (busLogEnabled()) {
417
+ const originalNext = subject.next.bind(subject);
418
+ subject.next = (value) => {
419
+ busLog("EMIT", String(eventName), value);
420
+ originalNext(value);
421
+ };
422
+ }
423
+ this.subjects.set(eventName, subject);
388
424
  }
389
425
  return this.subjects.get(eventName);
390
426
  }
@@ -592,32 +628,6 @@ function errField(error) {
592
628
  return error;
593
629
  }
594
630
 
595
- // src/bus-log.ts
596
- var NODE_BUS_LOG = typeof process !== "undefined" && !!process.env?.SEMIONT_BUS_LOG;
597
- function busLogEnabled() {
598
- const g = globalThis;
599
- if (g.__SEMIONT_BUS_LOG__) return true;
600
- return NODE_BUS_LOG;
601
- }
602
- var traceIdProvider;
603
- function setBusLogTraceIdProvider(fn) {
604
- traceIdProvider = fn;
605
- }
606
- function busLog(op, channel, payload, scope) {
607
- if (!busLogEnabled()) return;
608
- const cidRaw = payload?.correlationId;
609
- const cid = typeof cidRaw === "string" ? cidRaw.slice(0, 8) : void 0;
610
- let traceId;
611
- if (traceIdProvider) {
612
- try {
613
- traceId = traceIdProvider();
614
- } catch {
615
- }
616
- }
617
- const tag = `[bus ${op}] ${channel}` + (scope ? ` scope=${scope}` : "") + (cid ? ` cid=${cid}` : "") + (traceId ? ` trace=${traceId.slice(0, 8)}` : "");
618
- console.debug(tag, payload);
619
- }
620
-
621
631
  // src/annotation-utils.ts
622
632
  function findBodyItem(body, identity) {
623
633
  if (!Array.isArray(body)) {
@@ -1016,13 +1026,17 @@ var BRIDGED_CHANNELS = [
1016
1026
  "job:create-failed",
1017
1027
  "job:claimed",
1018
1028
  "job:claim-failed",
1029
+ "yield:create-ok",
1030
+ "yield:create-failed",
1031
+ "yield:update-ok",
1032
+ "yield:update-failed",
1019
1033
  "yield:clone-token-generated",
1020
1034
  "yield:clone-token-failed",
1021
1035
  "yield:clone-resource-result",
1022
1036
  "yield:clone-resource-failed",
1023
1037
  "yield:clone-created",
1024
1038
  "yield:clone-create-failed",
1025
- "mark:entity-type-added",
1039
+ "frame:entity-type-added",
1026
1040
  "beckon:focus",
1027
1041
  "beckon:sparkle",
1028
1042
  "bus:resume-gap"