@semiont/core 0.5.22 → 0.5.23
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 +98 -24
- package/dist/index.js +60 -9
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +25 -2813
- package/dist/testing.js +35 -20
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1265,32 +1265,28 @@ interface paths {
|
|
|
1265
1265
|
path?: never;
|
|
1266
1266
|
cookie?: never;
|
|
1267
1267
|
};
|
|
1268
|
+
get?: never;
|
|
1269
|
+
put?: never;
|
|
1268
1270
|
/**
|
|
1269
1271
|
* Subscribe to the Semiont event bus (SSE)
|
|
1270
|
-
* @description Opens a long-lived Server-Sent Events stream over which the bus delivers events matching the requested channels
|
|
1272
|
+
* @description Opens a long-lived Server-Sent Events stream over which the bus delivers events matching the requested subscription matrix. The JSON body names unscoped `global` channels plus any number of `scoped` entries — one per resource scope — so a single connection can hold live subscriptions to many resources at once (MULTI-RESOURCE-SCOPE).
|
|
1271
1273
|
*
|
|
1272
|
-
* Each SSE frame has `event: bus-event`, a JSON-encoded `data` of the form `{ channel, payload, scope? }
|
|
1274
|
+
* Each SSE frame has `event: bus-event`, a JSON-encoded `data` of the form `{ channel, payload, scope? }` (scoped events carry their originating scope), and an `id` (a persisted event id `p-<scope>-<seq>` for domain events; an ephemeral `e-*` id for job-lifecycle / correlated-reply channels).
|
|
1273
1275
|
*
|
|
1274
|
-
*
|
|
1276
|
+
* Resumption is per scope: pass each scope's last-received persisted id as `lastEventId` on its scoped entry — the server replays that scope's missed persisted events and emits a scoped `bus:resume-gap` synthetic event when the gap cannot be covered.
|
|
1275
1277
|
*/
|
|
1276
|
-
|
|
1278
|
+
post: {
|
|
1277
1279
|
parameters: {
|
|
1278
|
-
query?:
|
|
1279
|
-
|
|
1280
|
-
channel?: string[];
|
|
1281
|
-
/** @description Resource-scoped channels to subscribe to (requires `scope`). Repeat for multiple. */
|
|
1282
|
-
scoped?: string[];
|
|
1283
|
-
/** @description Resource scope for scoped channels (typically a resourceId). */
|
|
1284
|
-
scope?: string;
|
|
1285
|
-
};
|
|
1286
|
-
header?: {
|
|
1287
|
-
/** @description Id of the last event the client received. On reconnect, the server replays persisted events after this id and emits `bus:resume-gap` if the gap exceeds the replay cap. */
|
|
1288
|
-
"Last-Event-ID"?: string;
|
|
1289
|
-
};
|
|
1280
|
+
query?: never;
|
|
1281
|
+
header?: never;
|
|
1290
1282
|
path?: never;
|
|
1291
1283
|
cookie?: never;
|
|
1292
1284
|
};
|
|
1293
|
-
requestBody
|
|
1285
|
+
requestBody: {
|
|
1286
|
+
content: {
|
|
1287
|
+
"application/json": components["schemas"]["BusSubscribeRequest"];
|
|
1288
|
+
};
|
|
1289
|
+
};
|
|
1294
1290
|
responses: {
|
|
1295
1291
|
/** @description SSE stream opened */
|
|
1296
1292
|
200: {
|
|
@@ -1301,7 +1297,7 @@ interface paths {
|
|
|
1301
1297
|
"text/event-stream": components["schemas"]["EventStreamResponse"];
|
|
1302
1298
|
};
|
|
1303
1299
|
};
|
|
1304
|
-
/** @description
|
|
1300
|
+
/** @description Malformed body, no channels requested, duplicate scopes, malformed scoped entry, or scope count above the per-connection cap */
|
|
1305
1301
|
400: {
|
|
1306
1302
|
headers: {
|
|
1307
1303
|
[name: string]: unknown;
|
|
@@ -1321,8 +1317,6 @@ interface paths {
|
|
|
1321
1317
|
};
|
|
1322
1318
|
};
|
|
1323
1319
|
};
|
|
1324
|
-
put?: never;
|
|
1325
|
-
post?: never;
|
|
1326
1320
|
delete?: never;
|
|
1327
1321
|
options?: never;
|
|
1328
1322
|
head?: never;
|
|
@@ -2124,6 +2118,22 @@ interface components {
|
|
|
2124
2118
|
/** @description Optional resource scope for broadcast channels (e.g. resourceId). Publishers only — frontends must never set this. */
|
|
2125
2119
|
scope?: string;
|
|
2126
2120
|
};
|
|
2121
|
+
/** @description Subscription matrix for the bus SSE stream (MULTI-RESOURCE-SCOPE). `global` channels are delivered unscoped; each `scoped` entry subscribes the connection to one resource scope's channels, optionally resuming replay from that scope's last-seen persisted event id. At least one global channel or one scoped entry is required. */
|
|
2122
|
+
BusSubscribeRequest: {
|
|
2123
|
+
/** @description Unscoped channels to subscribe to. */
|
|
2124
|
+
global?: string[];
|
|
2125
|
+
/** @description Correlation ids of busRequest replies this client still awaits (BUS-RESUMPTION Phase 2). The server replays any matching replies from its bounded retention buffer (TTL 60s) as normal frames with their deterministic `e-<channel>:<cid>` ids, so a reply that ALSO arrived live dedups client-side. At most 256 entries. */
|
|
2126
|
+
pendingReplies?: string[];
|
|
2127
|
+
/** @description Per-resource-scope subscriptions. Scopes must be unique across entries. */
|
|
2128
|
+
scoped?: {
|
|
2129
|
+
/** @description Resource scope (a resourceId). */
|
|
2130
|
+
scope: string;
|
|
2131
|
+
/** @description Channels to subscribe within this scope. */
|
|
2132
|
+
channels: string[];
|
|
2133
|
+
/** @description This scope's last-seen persisted event id (`p-<scope>-<seq>`). The server replays this scope's persisted events after it before joining the live tail, and emits a scoped `bus:resume-gap` when it cannot cover the gap (unparseable or mismatched id, retention exceeded, or query error). */
|
|
2134
|
+
lastEventId?: string;
|
|
2135
|
+
}[];
|
|
2136
|
+
};
|
|
2127
2137
|
CloneResourceWithTokenResponse: {
|
|
2128
2138
|
/** @description Generated clone token */
|
|
2129
2139
|
token: string;
|
|
@@ -5389,8 +5399,9 @@ interface ITransport {
|
|
|
5389
5399
|
* SDK-internal: this is the scope primitive the SDK's resource-scoped
|
|
5390
5400
|
* `browse.*` live queries drive on subscribe/teardown (freshness follows
|
|
5391
5401
|
* observation; #847) — it is not part of the application-facing surface.
|
|
5392
|
-
*
|
|
5393
|
-
*
|
|
5402
|
+
* Distinct resources COMPOSE (`.plans/MULTI-RESOURCE-SCOPE.md`): each
|
|
5403
|
+
* resource's subscriptions are ref-counted independently, and one client
|
|
5404
|
+
* may hold many resource scopes at once on its single connection.
|
|
5394
5405
|
*/
|
|
5395
5406
|
subscribeToResource(resourceId: ResourceId): () => void;
|
|
5396
5407
|
/**
|
|
@@ -5406,8 +5417,24 @@ interface ITransport {
|
|
|
5406
5417
|
* Transport-level connection state. For HTTP, reflects the SSE
|
|
5407
5418
|
* connection's health; for in-process transports, typically `'open'`
|
|
5408
5419
|
* from construction onward (no connection to lose).
|
|
5420
|
+
*
|
|
5421
|
+
* Load-bearing beyond UI: `busRequest` gates its emit on this
|
|
5422
|
+
* (`BusRequestPrimitive.state$`, .plans/BUS-ATTACH-GATE.md) — no
|
|
5423
|
+
* correlated emit before the reply path exists. Implementers back it
|
|
5424
|
+
* with a `BehaviorSubject` so the current state arrives synchronously
|
|
5425
|
+
* on subscribe.
|
|
5409
5426
|
*/
|
|
5410
5427
|
readonly state$: Observable<ConnectionState>;
|
|
5428
|
+
/**
|
|
5429
|
+
* Correlated-reply retention, client side (BUS-RESUMPTION Phase 2 /
|
|
5430
|
+
* SDK-DEBT S1). `busRequest` registers its correlationId here before
|
|
5431
|
+
* emitting and releases on settle; a wire transport includes the
|
|
5432
|
+
* tracked set as `pendingReplies` on each subscribe body so a reply
|
|
5433
|
+
* published while the connection was down replays from the server's
|
|
5434
|
+
* retention buffer. OPTIONAL: in-process transports that cannot lose
|
|
5435
|
+
* replies omit it.
|
|
5436
|
+
*/
|
|
5437
|
+
trackReply?(correlationId: string): () => void;
|
|
5411
5438
|
/**
|
|
5412
5439
|
* Stream of transport-level errors surfaced from typed-wire methods or
|
|
5413
5440
|
* other transport-mediated round-trips, just before they're thrown to
|
|
@@ -5536,6 +5563,33 @@ interface IContentTransport {
|
|
|
5536
5563
|
dispose(): void;
|
|
5537
5564
|
}
|
|
5538
5565
|
|
|
5566
|
+
/**
|
|
5567
|
+
* BUS_OPERATIONS — the request/reply operations registry (Tier 1).
|
|
5568
|
+
*
|
|
5569
|
+
* Each entry declares ONE operation as the triple that was previously three
|
|
5570
|
+
* loose, independently-maintained facts spread across call sites:
|
|
5571
|
+
* - the request channel (the key — an `EmittableChannel`),
|
|
5572
|
+
* - the `result` channel (success reply),
|
|
5573
|
+
* - the `failure` channel,
|
|
5574
|
+
* - and, for a streaming op, an optional `progress` channel.
|
|
5575
|
+
*
|
|
5576
|
+
* `BridgedChannel` / `BRIDGED_CHANNELS` are DERIVED from this map
|
|
5577
|
+
* (bridged-channels.ts): every reply lands in the bridged fan-in set by
|
|
5578
|
+
* construction, so "a reply channel forgotten from BRIDGED_CHANNELS" — the
|
|
5579
|
+
* recurring bug class (gather:resource-complete, frame:*-add-failed) — is no
|
|
5580
|
+
* longer representable. See .plans/BUS-OPERATIONS-REGISTRY.md.
|
|
5581
|
+
*
|
|
5582
|
+
* `Partial<Record<EmittableChannel, …>>` enforces that every key is a real
|
|
5583
|
+
* emittable request. `result`/`failure`/`progress` stay `EventName` rather than
|
|
5584
|
+
* `BridgedChannel` to avoid a circular reference (BridgedChannel derives from
|
|
5585
|
+
* this map); the derivation closes the loop instead.
|
|
5586
|
+
*/
|
|
5587
|
+
interface BusOperationSpec {
|
|
5588
|
+
result: EventName;
|
|
5589
|
+
failure: EventName;
|
|
5590
|
+
/** Streaming ops only: an intermediate channel that also bridges. */
|
|
5591
|
+
progress?: EventName;
|
|
5592
|
+
}
|
|
5539
5593
|
declare const BUS_OPERATIONS: {
|
|
5540
5594
|
readonly 'bind:update-body': {
|
|
5541
5595
|
readonly result: "bind:body-updated";
|
|
@@ -5744,6 +5798,26 @@ declare class BusRequestError extends SemiontError {
|
|
|
5744
5798
|
interface BusRequestPrimitive {
|
|
5745
5799
|
emit<K extends keyof EventMap>(channel: K, payload: EventMap[K]): Promise<void>;
|
|
5746
5800
|
stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
|
|
5801
|
+
/**
|
|
5802
|
+
* Connection state of the stream that carries replies. Required, not
|
|
5803
|
+
* optional (.plans/BUS-ATTACH-GATE.md D2): `busRequest` gates its emit on
|
|
5804
|
+
* this — no correlated emit before the reply path exists. Implementers back
|
|
5805
|
+
* it with a `BehaviorSubject`, so the current state arrives synchronously
|
|
5806
|
+
* on subscribe; a transport that cannot lose replies (in-process) reports
|
|
5807
|
+
* `'open'` until disposal.
|
|
5808
|
+
*/
|
|
5809
|
+
state$: Observable<ConnectionState>;
|
|
5810
|
+
/**
|
|
5811
|
+
* Correlated-reply retention, client side (.plans/BUS-RESUMPTION.md
|
|
5812
|
+
* Phase 2 / SDK-DEBT S1). `busRequest` registers its correlationId here
|
|
5813
|
+
* BEFORE emitting and calls the returned disposer on every settle path;
|
|
5814
|
+
* a wire transport includes the currently-tracked ids as
|
|
5815
|
+
* `pendingReplies` in each subscribe body, so a reply published while
|
|
5816
|
+
* the connection was down is replayed from the server's retention
|
|
5817
|
+
* buffer on reconnect. OPTIONAL: an in-process transport that cannot
|
|
5818
|
+
* lose replies omits the surface and `busRequest` behaves as before.
|
|
5819
|
+
*/
|
|
5820
|
+
trackReply?(correlationId: string): () => void;
|
|
5747
5821
|
}
|
|
5748
5822
|
/**
|
|
5749
5823
|
* Request/reply over the bus, keyed by the operation's request channel.
|
|
@@ -7373,5 +7447,5 @@ declare function retryWithBackoff<T>(fn: () => Promise<T>, isRetryable: (error:
|
|
|
7373
7447
|
*/
|
|
7374
7448
|
declare const DISCOVERY_URL_PATH = "/discovery/kbs.json";
|
|
7375
7449
|
|
|
7376
|
-
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, 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, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, kbDid, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
7377
|
-
export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorRect, AnchorSelectors, AnchorStrategy, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, BusRequestErrorCode, BusRequestPrimitive, CloneToken, CollaboratorEntry, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, DiscoveredKB, DiscoveryDocument, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, GraphViews, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, JobType, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, RetryAttemptInfo, RetryPolicy, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StateUnit, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };
|
|
7450
|
+
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BUS_OPERATIONS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, 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, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, kbDid, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
7451
|
+
export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorRect, AnchorSelectors, AnchorStrategy, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, BusOperationKey, BusOperationSpec, BusRequestErrorCode, BusRequestPrimitive, CloneToken, CollaboratorEntry, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, DiscoveredKB, DiscoveryDocument, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, GraphViews, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, JobType, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, RetryAttemptInfo, RetryPolicy, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StateUnit, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };
|
package/dist/index.js
CHANGED
|
@@ -1223,18 +1223,69 @@ async function busRequest(bus, operation, payload, timeoutMs = 3e4) {
|
|
|
1223
1223
|
})
|
|
1224
1224
|
);
|
|
1225
1225
|
const resultPromise = firstValueFrom(result$);
|
|
1226
|
-
|
|
1227
|
-
await bus.emit(operation, fullPayload);
|
|
1228
|
-
} catch (emitError) {
|
|
1226
|
+
const closedBeforeEmit = () => {
|
|
1229
1227
|
resultPromise.catch(() => {
|
|
1230
1228
|
});
|
|
1231
|
-
|
|
1229
|
+
return new BusRequestError(`Bus closed before emit on ${operation}`, "bus.closed", {
|
|
1230
|
+
channel: operation,
|
|
1231
|
+
correlationId
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
let currentState;
|
|
1235
|
+
bus.state$.subscribe((s) => {
|
|
1236
|
+
currentState = s;
|
|
1237
|
+
}).unsubscribe();
|
|
1238
|
+
if (currentState === "closed") {
|
|
1239
|
+
throw closedBeforeEmit();
|
|
1240
|
+
}
|
|
1241
|
+
let emitAllowed = currentState === "open";
|
|
1242
|
+
if (!emitAllowed) {
|
|
1243
|
+
const gate = firstValueFrom(
|
|
1244
|
+
bus.state$.pipe(
|
|
1245
|
+
filter((s) => s === "open" || s === "closed"),
|
|
1246
|
+
take(1),
|
|
1247
|
+
// `state$` completed without ever attaching: treat as closed.
|
|
1248
|
+
defaultIfEmpty("closed")
|
|
1249
|
+
)
|
|
1250
|
+
);
|
|
1251
|
+
const outcome = await Promise.race([
|
|
1252
|
+
gate,
|
|
1253
|
+
// Either settlement of the reply machinery means "stop waiting, never
|
|
1254
|
+
// emit": its timeout rejecting `bus.timeout` at `timeoutMs` (the same
|
|
1255
|
+
// moment it would fire today — D4), or its streams completing into the
|
|
1256
|
+
// `bus.closed` default above. The shared tail below carries it.
|
|
1257
|
+
resultPromise.then(
|
|
1258
|
+
() => "settled",
|
|
1259
|
+
() => "settled"
|
|
1260
|
+
)
|
|
1261
|
+
]);
|
|
1262
|
+
if (outcome === "closed") {
|
|
1263
|
+
throw closedBeforeEmit();
|
|
1264
|
+
}
|
|
1265
|
+
emitAllowed = outcome === "open";
|
|
1232
1266
|
}
|
|
1233
|
-
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1267
|
+
let releaseTracking;
|
|
1268
|
+
if (emitAllowed) {
|
|
1269
|
+
releaseTracking = bus.trackReply?.(correlationId);
|
|
1270
|
+
try {
|
|
1271
|
+
await bus.emit(operation, fullPayload);
|
|
1272
|
+
} catch (emitError) {
|
|
1273
|
+
releaseTracking?.();
|
|
1274
|
+
releaseTracking = void 0;
|
|
1275
|
+
resultPromise.catch(() => {
|
|
1276
|
+
});
|
|
1277
|
+
throw emitError;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
try {
|
|
1281
|
+
const result = await resultPromise;
|
|
1282
|
+
if (!result.ok) {
|
|
1283
|
+
throw result.error;
|
|
1284
|
+
}
|
|
1285
|
+
return result.response;
|
|
1286
|
+
} finally {
|
|
1287
|
+
releaseTracking?.();
|
|
1236
1288
|
}
|
|
1237
|
-
return result.response;
|
|
1238
1289
|
}
|
|
1239
1290
|
|
|
1240
1291
|
// src/fuzzy-anchor.ts
|
|
@@ -2472,6 +2523,6 @@ async function retryWithBackoff(fn, isRetryable, policy, onRetry) {
|
|
|
2472
2523
|
// src/discovery.ts
|
|
2473
2524
|
var DISCOVERY_URL_PATH = "/discovery/kbs.json";
|
|
2474
2525
|
|
|
2475
|
-
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, 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, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, kbDid, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
2526
|
+
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BUS_OPERATIONS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, 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, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, kbDid, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
2476
2527
|
//# sourceMappingURL=index.js.map
|
|
2477
2528
|
//# sourceMappingURL=index.js.map
|