@semiont/core 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2223,10 +2223,14 @@ 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
  };
2230
+ /** @description Payload for frame:tag-schema-added domain event (system-level, no resourceId — fan-out is global to the KB). */
2231
+ TagSchemaAddedPayload: {
2232
+ schema: components["schemas"]["TagSchema"];
2233
+ };
2230
2234
  /** @description Payload for mark:entity-tag-added and mark:entity-tag-removed domain events */
2231
2235
  EntityTagChangedPayload: {
2232
2236
  entityType: string;
@@ -2353,6 +2357,9 @@ interface components {
2353
2357
  /** @description Annotations that reference this resource from other resources */
2354
2358
  entityReferences: components["schemas"]["Annotation"][];
2355
2359
  };
2360
+ GetTagSchemasResponse: {
2361
+ tagSchemas: components["schemas"]["TagSchema"][];
2362
+ };
2356
2363
  GoogleAuthRequest: {
2357
2364
  access_token: string;
2358
2365
  };
@@ -2894,6 +2901,15 @@ interface components {
2894
2901
  path: string;
2895
2902
  reason?: string;
2896
2903
  };
2904
+ /** @description Request to browse registered tag schemas */
2905
+ BrowseTagSchemasRequest: {
2906
+ correlationId: string;
2907
+ };
2908
+ /** @description Result of browsing tag schemas */
2909
+ BrowseTagSchemasResult: {
2910
+ correlationId: string;
2911
+ response: components["schemas"]["GetTagSchemasResponse"];
2912
+ };
2897
2913
  /** @description W3C Web Annotation FragmentSelector for media fragment identifiers (RFC 3778 for PDFs) */
2898
2914
  FragmentSelector: {
2899
2915
  /** @enum {string} */
@@ -3198,12 +3214,18 @@ interface components {
3198
3214
  [key: string]: number;
3199
3215
  };
3200
3216
  };
3201
- /** @description Bus command to add a new entity type tag. */
3202
- MarkAddEntityTypeCommand: {
3217
+ /** @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. */
3218
+ FrameAddEntityTypeCommand: {
3203
3219
  tag: string;
3204
3220
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3205
3221
  _userId?: string;
3206
3222
  };
3223
+ /** @description Bus command to register a tag schema with the KB's runtime registry. Carried on the `frame:add-tag-schema` channel — Frame is the schema-layer flow that owns vocabulary writes. Most-recent registration of a given `schema.id` wins; the projection reflects the latest content. Identical re-registrations are silent; differing content overwrites and logs a warning. */
3224
+ FrameAddTagSchemaCommand: {
3225
+ schema: components["schemas"]["TagSchema"];
3226
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3227
+ _userId?: string;
3228
+ };
3207
3229
  /** @description Bus command to archive a resource and optionally remove its file. */
3208
3230
  MarkArchiveCommand: {
3209
3231
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
@@ -3353,6 +3375,21 @@ interface components {
3353
3375
  /** @description SVG markup defining the region (must include xmlns attribute) */
3354
3376
  value: string;
3355
3377
  };
3378
+ /** @description A single category within a tag schema (e.g. 'Issue' in IRAC, 'distinguished' in legal-citation-treatment). Each category carries methodology-bound semantics: a name, a description, and examples used in the LLM prompt. */
3379
+ TagCategory: {
3380
+ name: string;
3381
+ description: string;
3382
+ examples: string[];
3383
+ };
3384
+ /** @description A structural-analysis schema (e.g. legal-irac, scientific-imrad, argument-toulmin). Defines a methodology framework as an id, name, description, domain hint, and an ordered list of categories. KBs and their skills register schemas with the runtime registry via `frame.addTagSchema(...)` at session start. */
3385
+ TagSchema: {
3386
+ id: string;
3387
+ name: string;
3388
+ description: string;
3389
+ /** @description Free-form domain hint (e.g. 'legal', 'scientific', 'general'). Used in the LLM prompt to tune the model's analysis voice. KB authors choose. */
3390
+ domain: string;
3391
+ tags: components["schemas"]["TagCategory"][];
3392
+ };
3356
3393
  /** @description Bus command to create a cloned resource from a clone token. */
3357
3394
  YieldCloneCreateCommand: {
3358
3395
  correlationId: string;
@@ -3418,22 +3455,6 @@ interface components {
3418
3455
  toUri: string;
3419
3456
  noGit?: boolean;
3420
3457
  };
3421
- /** @description Bus command to request yield (generation) of a new resource from an annotation. */
3422
- YieldRequestCommand: {
3423
- /** @description Client-supplied id used to match this command to its result event(s) on the events-stream. Generated by the route handler if absent. */
3424
- correlationId?: string;
3425
- annotationId: string;
3426
- resourceId: string;
3427
- options: {
3428
- title: string;
3429
- prompt?: string;
3430
- language?: string;
3431
- temperature?: number;
3432
- maxTokens?: number;
3433
- context?: components["schemas"]["GatheredContext"];
3434
- storageUri: string;
3435
- };
3436
- };
3437
3458
  /** @description Bus command to update a yielded resource's storage content. */
3438
3459
  YieldUpdateCommand: {
3439
3460
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
@@ -3675,14 +3696,15 @@ type PersistedEventCatalog = {
3675
3696
  'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
3676
3697
  'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
3677
3698
  'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
3678
- 'mark:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
3699
+ 'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
3700
+ 'frame:tag-schema-added': components['schemas']['TagSchemaAddedPayload'];
3679
3701
  'job:started': components['schemas']['JobStartedPayload'];
3680
3702
  'job:progress': components['schemas']['JobProgressPayload'];
3681
3703
  'job:completed': components['schemas']['JobCompletedPayload'];
3682
3704
  'job:failed': components['schemas']['JobFailedPayload'];
3683
3705
  };
3684
3706
  /** System event types — persisted events that have no resourceId. */
3685
- type SystemEventType = 'mark:entity-type-added';
3707
+ type SystemEventType = 'frame:entity-type-added' | 'frame:tag-schema-added';
3686
3708
  /** Extract the concrete persisted event type for a given type string. */
3687
3709
  type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
3688
3710
  type: K;
@@ -3707,7 +3729,7 @@ type PersistedEventType = PersistedEvent['type'];
3707
3729
  * also adding it here: forgetting fails to typecheck rather than silently
3708
3730
  * dropping the event from the events-stream.
3709
3731
  */
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"];
3732
+ 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", "frame:tag-schema-added", "job:started", "job:progress", "job:completed", "job:failed"];
3711
3733
  /** Input type for appendEvent — PersistedEvent without id/timestamp (assigned at persistence time). */
3712
3734
  type EventInput = Omit<PersistedEvent, 'id' | 'timestamp'>;
3713
3735
 
@@ -3829,7 +3851,6 @@ type EventMap = {
3829
3851
  'yield:moved': StoredEvent<EventOfType<'yield:moved'>>;
3830
3852
  'yield:representation-added': StoredEvent<EventOfType<'yield:representation-added'>>;
3831
3853
  'yield:representation-removed': StoredEvent<EventOfType<'yield:representation-removed'>>;
3832
- 'yield:request': components['schemas']['YieldRequestCommand'];
3833
3854
  'yield:create': components['schemas']['YieldCreateCommand'];
3834
3855
  'yield:update': components['schemas']['YieldUpdateCommand'];
3835
3856
  'yield:mv': components['schemas']['YieldMvCommand'];
@@ -3868,7 +3889,6 @@ type EventMap = {
3868
3889
  'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
3869
3890
  'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
3870
3891
  'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
3871
- 'mark:entity-type-added': StoredEvent<EventOfType<'mark:entity-type-added'>>;
3872
3892
  'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
3873
3893
  'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
3874
3894
  'mark:create-request': components['schemas']['MarkCreateRequest'];
@@ -3878,13 +3898,11 @@ type EventMap = {
3878
3898
  'mark:archive': components['schemas']['MarkArchiveCommand'];
3879
3899
  'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
3880
3900
  'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
3881
- 'mark:add-entity-type': components['schemas']['MarkAddEntityTypeCommand'];
3882
3901
  'mark:create-ok': components['schemas']['MarkCreateOk'];
3883
3902
  'mark:create-failed': components['schemas']['CommandError'];
3884
3903
  'mark:delete-ok': components['schemas']['MarkDeleteOk'];
3885
3904
  'mark:delete-failed': components['schemas']['CommandError'];
3886
3905
  'mark:body-update-failed': components['schemas']['CommandError'];
3887
- 'mark:entity-type-add-failed': components['schemas']['CommandError'];
3888
3906
  'mark:select-comment': components['schemas']['SelectionData'];
3889
3907
  'mark:select-tag': components['schemas']['SelectionData'];
3890
3908
  'mark:select-assessment': components['schemas']['SelectionData'];
@@ -3899,6 +3917,12 @@ type EventMap = {
3899
3917
  'mark:selection-changed': components['schemas']['MarkSelectionChangedEvent'];
3900
3918
  'mark:click-changed': components['schemas']['MarkClickChangedEvent'];
3901
3919
  'mark:shape-changed': components['schemas']['MarkShapeChangedEvent'];
3920
+ 'frame:entity-type-added': StoredEvent<EventOfType<'frame:entity-type-added'>>;
3921
+ 'frame:tag-schema-added': StoredEvent<EventOfType<'frame:tag-schema-added'>>;
3922
+ 'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
3923
+ 'frame:add-tag-schema': components['schemas']['FrameAddTagSchemaCommand'];
3924
+ 'frame:entity-type-add-failed': components['schemas']['CommandError'];
3925
+ 'frame:tag-schema-add-failed': components['schemas']['CommandError'];
3902
3926
  'bind:initiate': BindInitiateCommand;
3903
3927
  'bind:update-body': BindUpdateBodyCommand;
3904
3928
  'bind:body-updated': components['schemas']['BindBodyUpdated'];
@@ -3978,6 +4002,11 @@ type EventMap = {
3978
4002
  'browse:entity-types-failed': {
3979
4003
  correlationId: string;
3980
4004
  } & components['schemas']['CommandError'];
4005
+ 'browse:tag-schemas-requested': components['schemas']['BrowseTagSchemasRequest'];
4006
+ 'browse:tag-schemas-result': components['schemas']['BrowseTagSchemasResult'];
4007
+ 'browse:tag-schemas-failed': {
4008
+ correlationId: string;
4009
+ } & components['schemas']['CommandError'];
3981
4010
  'browse:directory-requested': components['schemas']['BrowseDirectoryRequest'];
3982
4011
  'browse:directory-result': components['schemas']['BrowseDirectoryResult'];
3983
4012
  'browse:directory-failed': {
@@ -4079,7 +4108,7 @@ type EventName = keyof EventMap;
4079
4108
  *
4080
4109
  * The frontend's `subscribeToResource(id)` wires these channels via
4081
4110
  * `scope=id&scoped=<channel>` so the SSE route delivers them to that
4082
- * participant. WorkerVM uses this list to decide which emitted events to
4111
+ * participant. WorkerStateUnit uses this list to decide which emitted events to
4083
4112
  * scope to their resource.
4084
4113
  */
4085
4114
  /**
@@ -4120,7 +4149,6 @@ declare const CHANNEL_SCHEMAS: {
4120
4149
  readonly 'yield:moved': null;
4121
4150
  readonly 'yield:representation-added': null;
4122
4151
  readonly 'yield:representation-removed': null;
4123
- readonly 'yield:request': "YieldRequestCommand";
4124
4152
  readonly 'yield:create': "YieldCreateCommand";
4125
4153
  readonly 'yield:update': "YieldUpdateCommand";
4126
4154
  readonly 'yield:mv': "YieldMvCommand";
@@ -4145,7 +4173,8 @@ declare const CHANNEL_SCHEMAS: {
4145
4173
  readonly 'mark:body-updated': null;
4146
4174
  readonly 'mark:entity-tag-added': null;
4147
4175
  readonly 'mark:entity-tag-removed': null;
4148
- readonly 'mark:entity-type-added': null;
4176
+ readonly 'frame:entity-type-added': null;
4177
+ readonly 'frame:tag-schema-added': null;
4149
4178
  readonly 'mark:archived': null;
4150
4179
  readonly 'mark:unarchived': null;
4151
4180
  readonly 'mark:create-request': "MarkCreateRequest";
@@ -4155,13 +4184,15 @@ declare const CHANNEL_SCHEMAS: {
4155
4184
  readonly 'mark:archive': "MarkArchiveCommand";
4156
4185
  readonly 'mark:unarchive': "MarkUnarchiveCommand";
4157
4186
  readonly 'mark:update-entity-types': "MarkUpdateEntityTypesCommand";
4158
- readonly 'mark:add-entity-type': "MarkAddEntityTypeCommand";
4187
+ readonly 'frame:add-entity-type': "FrameAddEntityTypeCommand";
4188
+ readonly 'frame:add-tag-schema': "FrameAddTagSchemaCommand";
4159
4189
  readonly 'mark:create-ok': "MarkCreateOk";
4160
4190
  readonly 'mark:create-failed': "CommandError";
4161
4191
  readonly 'mark:delete-ok': "MarkDeleteOk";
4162
4192
  readonly 'mark:delete-failed': "CommandError";
4163
4193
  readonly 'mark:body-update-failed': "CommandError";
4164
- readonly 'mark:entity-type-add-failed': "CommandError";
4194
+ readonly 'frame:entity-type-add-failed': "CommandError";
4195
+ readonly 'frame:tag-schema-add-failed': "CommandError";
4165
4196
  readonly 'mark:select-comment': "SelectionData";
4166
4197
  readonly 'mark:select-tag': "SelectionData";
4167
4198
  readonly 'mark:select-assessment': "SelectionData";
@@ -4223,6 +4254,9 @@ declare const CHANNEL_SCHEMAS: {
4223
4254
  readonly 'browse:entity-types-requested': "BrowseEntityTypesRequest";
4224
4255
  readonly 'browse:entity-types-result': "BrowseEntityTypesResult";
4225
4256
  readonly 'browse:entity-types-failed': null;
4257
+ readonly 'browse:tag-schemas-requested': "BrowseTagSchemasRequest";
4258
+ readonly 'browse:tag-schemas-result': "BrowseTagSchemasResult";
4259
+ readonly 'browse:tag-schemas-failed': null;
4226
4260
  readonly 'browse:directory-requested': "BrowseDirectoryRequest";
4227
4261
  readonly 'browse:directory-result': "BrowseDirectoryResult";
4228
4262
  readonly 'browse:directory-failed': null;
@@ -5000,6 +5034,54 @@ declare function getNodeEncoding(charset: string): BufferEncoding;
5000
5034
  */
5001
5035
  declare function decodeRepresentation(buffer: Buffer, mediaType: string): string;
5002
5036
 
5037
+ /**
5038
+ * Common error classes — the unified Semiont error hierarchy.
5039
+ *
5040
+ * `SemiontError` is the base every other Semiont error class extends:
5041
+ * `APIError` (api-client), `BusRequestError` and `SemiontSessionError` (sdk),
5042
+ * `ValidationError`, `ScriptError`, `NotFoundError`, `UnauthorizedError`,
5043
+ * `ConflictError` (here), and `AWSError` (cli). Subclasses tighten the
5044
+ * `code` field to a literal-union for discriminated handling.
5045
+ */
5046
+ /**
5047
+ * Transport-neutral error vocabulary. Every transport that surfaces
5048
+ * errors over `ITransport.errors$` maps its native failure modes to one
5049
+ * of these codes — HTTP `APIError` maps from status code, in-process
5050
+ * transports map from local failure shape, gRPC would map from status
5051
+ * code, etc. Routing layers (e.g. `SemiontBrowser`'s session-expired /
5052
+ * permission-denied modal routing) match on this vocabulary so they
5053
+ * stay transport-agnostic.
5054
+ *
5055
+ * - `unauthorized` — auth required / token missing or expired (HTTP 401)
5056
+ * - `forbidden` — auth ok but lacks permission (HTTP 403)
5057
+ * - `not-found` — resource missing (HTTP 404)
5058
+ * - `conflict` — concurrent modification, duplicate, etc. (HTTP 409)
5059
+ * - `bad-request` — request malformed (HTTP 400)
5060
+ * - `unavailable` — backend unreachable, network error, 5xx
5061
+ * - `error` — unclassified fallback
5062
+ */
5063
+ type TransportErrorCode = 'unauthorized' | 'forbidden' | 'not-found' | 'conflict' | 'bad-request' | 'unavailable' | 'error';
5064
+ declare class SemiontError extends Error {
5065
+ code: string;
5066
+ details?: Record<string, unknown> | undefined;
5067
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
5068
+ }
5069
+ declare class ValidationError extends SemiontError {
5070
+ constructor(message: string, details?: Record<string, unknown>);
5071
+ }
5072
+ declare class ScriptError extends SemiontError {
5073
+ constructor(message: string, code?: string, details?: Record<string, unknown>);
5074
+ }
5075
+ declare class NotFoundError extends SemiontError {
5076
+ constructor(resource: string, id?: string);
5077
+ }
5078
+ declare class UnauthorizedError extends SemiontError {
5079
+ constructor(message?: string, details?: Record<string, unknown>);
5080
+ }
5081
+ declare class ConflictError extends SemiontError {
5082
+ constructor(message: string, details?: Record<string, unknown>);
5083
+ }
5084
+
5003
5085
  /**
5004
5086
  * Transport interfaces — the shared contract for any wire-or-local
5005
5087
  * communication path consumed by `SemiontClient`. Concrete implementations
@@ -5007,10 +5089,15 @@ declare function decodeRepresentation(buffer: Buffer, mediaType: string): string
5007
5089
  * `@semiont/api-client`, in-process variants in `@semiont/make-meaning`,
5008
5090
  * etc.).
5009
5091
  *
5010
- * Two interfaces:
5092
+ * Three interfaces:
5011
5093
  *
5012
- * ITransport — full surface: bus primitives + auth + admin +
5013
- * exchange + health/status + connection state.
5094
+ * ITransport — bus primitives + lifecycle. Universal: every
5095
+ * concrete transport implements this.
5096
+ * IBackendOperations — auth, admin, exchange, system endpoints.
5097
+ * HTTP-shaped today; an in-process transport may
5098
+ * implement none, some, or a different set.
5099
+ * Optional on `SemiontClient` — passed only when
5100
+ * the host has a backend that supports them.
5014
5101
  * IContentTransport — binary I/O (putBinary / getBinary). Narrow by
5015
5102
  * design because binary has different backpressure
5016
5103
  * and streaming characteristics.
@@ -5084,6 +5171,21 @@ type ProgressEvent = {
5084
5171
  result?: Record<string, unknown>;
5085
5172
  };
5086
5173
  type ProgressCallback = (event: ProgressEvent) => void;
5174
+ /**
5175
+ * Stream-shaped return type for backend download operations
5176
+ * (`backupKnowledgeBase`, `exportKnowledgeBase`). Transport-neutral —
5177
+ * any implementation can produce a `ReadableStream<Uint8Array>` without
5178
+ * fabricating a fetch `Response`. HTTP wraps `response.body` and
5179
+ * `response.headers`; in-process implementations return their own stream.
5180
+ *
5181
+ * The same shape `IContentTransport.getBinaryStream` already uses for
5182
+ * binary downloads.
5183
+ */
5184
+ interface BackendDownload {
5185
+ stream: ReadableStream<Uint8Array>;
5186
+ contentType: string;
5187
+ filename?: string;
5188
+ }
5087
5189
  interface ITransport {
5088
5190
  /**
5089
5191
  * Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
@@ -5118,6 +5220,38 @@ interface ITransport {
5118
5220
  * an in-process transport bridges from the local actor bus.
5119
5221
  */
5120
5222
  bridgeInto(bus: EventBus): void;
5223
+ /**
5224
+ * Transport-level connection state. For HTTP, reflects the SSE
5225
+ * connection's health; for in-process transports, typically `'open'`
5226
+ * from construction onward (no connection to lose).
5227
+ */
5228
+ readonly state$: Observable<ConnectionState>;
5229
+ /**
5230
+ * Stream of transport-level errors surfaced from typed-wire methods or
5231
+ * other transport-mediated round-trips, just before they're thrown to
5232
+ * the caller. Each emission is a `SemiontError` (or subclass — HTTP
5233
+ * emits `APIError`, in-process transports emit whatever subclass is
5234
+ * appropriate). Consumers can subscribe for global error handling
5235
+ * (e.g. surfacing 401/403 as modals, logging) without wrapping every
5236
+ * call site in try/catch. Distinct from bus-level errors, which are
5237
+ * surfaced via the channel-correlation pattern in `busRequest`.
5238
+ */
5239
+ readonly errors$: Observable<SemiontError>;
5240
+ dispose(): void;
5241
+ }
5242
+ /**
5243
+ * Auth, admin, exchange, and system endpoints. HTTP-shaped today —
5244
+ * `HttpTransport` implements both this and `ITransport`; the
5245
+ * `SemiontClient` constructor takes a `IBackendOperations` argument
5246
+ * separately from the bus transport so non-HTTP transports
5247
+ * (`LocalTransport`) can implement just the bus surface and the
5248
+ * SemiontClient cleanly omits `client.auth` / `client.admin`.
5249
+ *
5250
+ * Implementations should map their native error codes to
5251
+ * `TransportErrorCode` (see `errors.ts`) so the routing layer
5252
+ * (`SemiontBrowser`) stays transport-neutral.
5253
+ */
5254
+ interface IBackendOperations {
5121
5255
  authenticatePassword(email: Email, password: string): Promise<AuthResponse>;
5122
5256
  authenticateGoogle(credential: GoogleCredential): Promise<AuthResponse>;
5123
5257
  refreshAccessToken(token: RefreshToken): Promise<TokenRefreshResponse>;
@@ -5134,21 +5268,24 @@ interface ITransport {
5134
5268
  getUserStats(): Promise<AdminUserStatsResponse>;
5135
5269
  updateUser(id: UserDID, data: UpdateUserRequest): Promise<UpdateUserResponse>;
5136
5270
  getOAuthConfig(): Promise<OAuthConfigResponse>;
5137
- backupKnowledgeBase(): Promise<Response>;
5138
- restoreKnowledgeBase(file: File, onProgress?: ProgressCallback): Promise<ProgressEvent>;
5271
+ backupKnowledgeBase(): Promise<BackendDownload>;
5272
+ /**
5273
+ * Stream of `ProgressEvent`s for a restore/import operation. The
5274
+ * Observable emits each progress event in order and completes when
5275
+ * the operation is done; the final event carries `phase: 'complete'`
5276
+ * (or `'error'` / `'failed'` followed by an Observable error).
5277
+ *
5278
+ * The SDK wraps the contract's `Observable<ProgressEvent>` as a
5279
+ * `StreamObservable<ProgressEvent>` so consumers can `await` for the
5280
+ * final event or `.subscribe(...)` to render every step.
5281
+ */
5282
+ restoreKnowledgeBase(file: File): Observable<ProgressEvent>;
5139
5283
  exportKnowledgeBase(params?: {
5140
5284
  includeArchived?: boolean;
5141
- }): Promise<Response>;
5142
- importKnowledgeBase(file: File, onProgress?: ProgressCallback): Promise<ProgressEvent>;
5285
+ }): Promise<BackendDownload>;
5286
+ importKnowledgeBase(file: File): Observable<ProgressEvent>;
5143
5287
  healthCheck(): Promise<HealthCheckResponse>;
5144
5288
  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
5289
  }
5153
5290
  interface PutBinaryRequest {
5154
5291
  name: string;
@@ -5164,10 +5301,36 @@ interface PutBinaryRequest {
5164
5301
  generator?: Agent$1 | Agent$1[];
5165
5302
  isDraft?: boolean;
5166
5303
  }
5304
+ /**
5305
+ * Optional byte-progress hook for `putBinary`. Receives raw byte counts;
5306
+ * derived shapes (percentage, ETA) are the caller's responsibility.
5307
+ *
5308
+ * `totalBytes` may be 0 when the underlying transport can't determine it
5309
+ * (chunked encoding, indeterminate streams). Consumers should render an
5310
+ * indeterminate state in that case.
5311
+ */
5312
+ type PutBinaryProgress = (event: {
5313
+ bytesUploaded: number;
5314
+ totalBytes: number;
5315
+ }) => void;
5316
+ interface PutBinaryOptions {
5317
+ auth?: AccessToken;
5318
+ /**
5319
+ * Called as bytes flow over the wire. Honored by transports that can
5320
+ * observe upload progress (HTTP via XHR). Transports that can't
5321
+ * (in-process LocalContentTransport, current `ky`-based fetch path
5322
+ * with no `onProgress`) simply ignore it.
5323
+ */
5324
+ onProgress?: PutBinaryProgress;
5325
+ /**
5326
+ * Signal that aborts the in-flight request. The XHR-based HTTP path
5327
+ * calls `xhr.abort()` when the signal fires; in-process and
5328
+ * non-XHR HTTP paths complete in the background after abort.
5329
+ */
5330
+ signal?: AbortSignal;
5331
+ }
5167
5332
  interface IContentTransport {
5168
- putBinary(request: PutBinaryRequest, options?: {
5169
- auth?: AccessToken;
5170
- }): Promise<{
5333
+ putBinary(request: PutBinaryRequest, options?: PutBinaryOptions): Promise<{
5171
5334
  resourceId: ResourceId;
5172
5335
  }>;
5173
5336
  getBinary(resourceId: ResourceId, options?: {
@@ -5202,7 +5365,7 @@ interface IContentTransport {
5202
5365
  * Resource-scoped channels (joined/left via `subscribeToResource`) are
5203
5366
  * tracked separately by transports that care about scope (HTTP).
5204
5367
  */
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"];
5368
+ 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:tag-schemas-result", "browse:tag-schemas-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", "frame:tag-schema-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
5206
5369
  type BridgedChannel = typeof BRIDGED_CHANNELS[number];
5207
5370
 
5208
5371
  /**
@@ -5590,6 +5753,33 @@ interface ResourceFilter {
5590
5753
  offset?: number;
5591
5754
  }
5592
5755
 
5756
+ /**
5757
+ * Tag-schema type aliases.
5758
+ *
5759
+ * These are type-only re-exports of the OpenAPI `TagSchema` and `TagCategory`
5760
+ * shapes. The schemas themselves do not live in `@semiont/core` — they're
5761
+ * registered at runtime per-KB via `frame.addTagSchema(...)` against a
5762
+ * per-KB projection. This module just exposes the shape so KB authors and
5763
+ * skill code can type their schema literals without the OpenAPI lookup
5764
+ * syntax (`components['schemas']['TagSchema']`).
5765
+ */
5766
+
5767
+ /**
5768
+ * A structural-analysis schema (e.g. legal-irac, scientific-imrad).
5769
+ *
5770
+ * Defines a methodology framework as an id, name, description, domain hint,
5771
+ * and an ordered list of categories. KBs and their skills register schemas
5772
+ * with the runtime registry via `frame.addTagSchema(...)` at session start.
5773
+ */
5774
+ type TagSchema = components['schemas']['TagSchema'];
5775
+ /**
5776
+ * A single category within a {@link TagSchema} (e.g. 'Issue' in IRAC).
5777
+ *
5778
+ * Each category carries methodology-bound semantics: a name, a description,
5779
+ * and examples used in the LLM prompt.
5780
+ */
5781
+ type TagCategory = components['schemas']['TagCategory'];
5782
+
5593
5783
  /**
5594
5784
  * Auth types
5595
5785
  */
@@ -5650,36 +5840,6 @@ declare function isNullish(value: unknown): value is null | undefined;
5650
5840
  */
5651
5841
  declare function isDefined<T>(value: T | null | undefined): value is T;
5652
5842
 
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
5843
  /**
5684
5844
  * DID (Decentralized Identifier) and W3C Agent utilities
5685
5845
  *
@@ -5865,4 +6025,4 @@ declare function getAllPlatformTypes(): PlatformType[];
5865
6025
  declare const CORE_TYPES_VERSION = "0.1.0";
5866
6026
  declare const SDK_VERSION = "0.1.0";
5867
6027
 
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 };
6028
+ 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 TagCategory, type TagSchema, 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 };