@semiont/core 0.5.24 → 0.5.26

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.
@@ -1,5 +1,5 @@
1
- import { FaultyTransport } from '../chunk-3WTQZOGO.js';
2
- import '../chunk-4JTZMWZB.js';
1
+ import { FaultyTransport } from '../chunk-I3ZOWCTH.js';
2
+ import '../chunk-FMFOBVTE.js';
3
3
  import * as fc2 from 'fast-check';
4
4
  import { Subject } from 'rxjs';
5
5
 
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- export { FaultyTransport, retryKeyOf } from './chunk-3WTQZOGO.js';
2
- import './chunk-4JTZMWZB.js';
1
+ export { FaultyTransport, retryKeyOf } from './chunk-I3ZOWCTH.js';
2
+ import './chunk-FMFOBVTE.js';
3
3
  //# sourceMappingURL=testing.js.map
4
4
  //# sourceMappingURL=testing.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semiont/core",
3
- "version": "0.5.24",
3
+ "version": "0.5.26",
4
4
  "description": "Core types and domain logic for Semiont - Resource, Annotation, and Graph models",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -73,7 +73,7 @@
73
73
  "fast-check": "^4.9.0",
74
74
  "json-schema-to-typescript": "^15.0.2",
75
75
  "openapi-typescript": "^7.10.1",
76
- "rollup": "^4.61.0",
76
+ "rollup": "^4.62.3",
77
77
  "rollup-plugin-dts": "^6.4.1",
78
78
  "tsup": "^8.5.1",
79
79
  "tsx": "^4.23.1",
@@ -84,7 +84,7 @@
84
84
  "ajv": "^8.20.0",
85
85
  "ajv-formats": "^3.0.1",
86
86
  "rxjs": "^7.8.1",
87
- "smol-toml": "^1.7.0"
87
+ "smol-toml": "^1.7.1"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "fast-check": "^4.8.0"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/branded-types.ts","../src/bus-operations.ts","../src/bridged-channels.ts","../src/bus-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IAAA,OAAO,cAAA,CAAe,IAAI,SAAS,CAAA;AAAA,EACrC;AAAA;AAAA,EAGA,eAAe,SAAA,EAAqD;AAClE,IAAA,OAAO,IAAA,CAAK,IAAI,SAA2B,CAAA;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,QAAA,EAAkC;AACtC,IAAA,OAAO,IAAI,gBAAe,IAAA,CAAK,MAAA,EAAQ,GAAG,IAAA,CAAK,WAAW,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAE,CAAA;AAAA,EAC1E;AACF","file":"chunk-4JTZMWZB.js","sourcesContent":["/**\n * Branded string types for compile-time type safety\n *\n * These types are zero-cost at runtime but prevent mixing\n * different string types at compile time.\n */\n\nimport type { components } from './types';\n\n// ============================================================================\n// OPENAPI-GENERATED TYPES (use directly from spec)\n// ============================================================================\n\nexport type Motivation = components['schemas']['Motivation'];\nexport type ContentFormat = components['schemas']['ContentFormat'];\n\n// ============================================================================\n// AUTHENTICATION & TOKENS\n// ============================================================================\n\nexport type Email = string & { readonly __brand: 'Email' };\nexport type AuthCode = string & { readonly __brand: 'AuthCode' };\nexport type GoogleCredential = string & { readonly __brand: 'GoogleCredential' };\nexport type AccessToken = string & { readonly __brand: 'AccessToken' };\nexport type RefreshToken = string & { readonly __brand: 'RefreshToken' };\nexport type MCPToken = string & { readonly __brand: 'MCPToken' };\nexport type CloneToken = string & { readonly __brand: 'CloneToken' };\n\n// ============================================================================\n// SYSTEM IDENTIFIERS\n// ============================================================================\n\nexport type JobId = string & { readonly __brand: 'JobId' };\nexport type UserDID = string & { readonly __brand: 'UserDID' };\nexport type EntityType = string & { readonly __brand: 'EntityType' };\nexport type SearchQuery = string & { readonly __brand: 'SearchQuery' };\nexport type BaseUrl = string & { readonly __brand: 'BaseUrl' };\n\n// ============================================================================\n// HELPER FUNCTIONS (minimal validation, just branding)\n// ============================================================================\n\nexport function email(value: string): Email { return value as Email; }\nexport function authCode(value: string): AuthCode { return value as AuthCode; }\nexport function googleCredential(value: string): GoogleCredential { return value as GoogleCredential; }\nexport function accessToken(value: string): AccessToken { return value as AccessToken; }\nexport function refreshToken(value: string): RefreshToken { return value as RefreshToken; }\nexport function mcpToken(value: string): MCPToken { return value as MCPToken; }\nexport function cloneToken(value: string): CloneToken { return value as CloneToken; }\nexport function jobId(value: string): JobId { return value as JobId; }\nexport function userDID(value: string): UserDID { return value as UserDID; }\nexport function entityType(value: string): EntityType { return value as EntityType; }\nexport function searchQuery(value: string): SearchQuery { return value as SearchQuery; }\nexport function baseUrl(value: string): BaseUrl { return value as BaseUrl; }\n\n// Motivation is an OpenAPI enum — use its values directly, no helper needed.\n// ContentFormat is a free-form MIME string whose base type must be a\n// SupportedMediaType; validation lives in media-types.ts, not in a brand.\n\n// ============================================================================\n// HTTP URI TYPES\n// ============================================================================\n\n// Branded type definitions for HTTP URIs returned by the API\nexport type ResourceUri = string & { readonly __brand: 'ResourceUri' };\n\n// W3C flat format for content negotiation: http://localhost:4000/annotations/{id}\nexport type AnnotationUri = string & { readonly __brand: 'AnnotationUri' };\n\n// Nested format for CRUD operations: http://localhost:4000/resources/{resourceId}/annotations/{annotationId}\nexport type ResourceAnnotationUri = string & { readonly __brand: 'ResourceAnnotationUri' };\n\n// Factory functions with runtime validation\nexport function resourceUri(uri: string): ResourceUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceUri, got: ${uri}`);\n }\n return uri as ResourceUri;\n}\n\nexport function annotationUri(uri: string): AnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected AnnotationUri, got: ${uri}`);\n }\n return uri as AnnotationUri;\n}\n\nexport function resourceAnnotationUri(uri: string): ResourceAnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceAnnotationUri, got: ${uri}`);\n }\n // Additional validation: must contain /resources/ and /annotations/\n if (!uri.includes('/resources/') || !uri.includes('/annotations/')) {\n throw new TypeError(`Expected nested ResourceAnnotationUri format, got: ${uri}`);\n }\n return uri as ResourceAnnotationUri;\n}\n","// ⚠ GENERATED FILE — do not edit.\n//\n// Authority: specs/src/bus/registry.json (channels, payloads, operations)\n// Regenerate: node scripts/bus/generate-ts.mjs\n// Go counterpart: node scripts/bus/generate-go.mjs → packages/sdk-go/bus\n//\n// Payload schemas themselves live in the OpenAPI components; the registry\n// names which one each channel carries. Add or change a channel THERE.\n\nimport type { EventName, EmittableChannel } from './bus-protocol';\n\n/**\n * BUS_OPERATIONS — the request/reply operations registry (Tier 1).\n *\n * Each entry declares ONE operation as the triple that was previously three\n * loose, independently-maintained facts spread across call sites:\n * - the request channel (the key — an `EmittableChannel`),\n * - the `result` channel (success reply),\n * - the `failure` channel,\n * - and, for a streaming op, an optional `progress` channel.\n *\n * `BridgedChannel` / `BRIDGED_CHANNELS` are DERIVED from this map\n * (bridged-channels.ts): every reply lands in the bridged fan-in set by\n * construction, so \"a reply channel forgotten from BRIDGED_CHANNELS\" — the\n * recurring bug class (gather:resource-complete, frame:*-add-failed) — is no\n * longer representable. See .plans/BUS-OPERATIONS-REGISTRY.md.\n *\n * `Partial<Record<EmittableChannel, …>>` enforces that every key is a real\n * emittable request. `result`/`failure`/`progress` stay `EventName` rather than\n * `BridgedChannel` to avoid a circular reference (BridgedChannel derives from\n * this map); the derivation closes the loop instead.\n */\nexport interface BusOperationSpec {\n result: EventName;\n failure: EventName;\n /** Streaming ops only: an intermediate channel that also bridges. */\n progress?: EventName;\n}\n\nexport const BUS_OPERATIONS = {\n // ── BIND ────────────────────────────────────────────────────────\n 'bind:update-body': { result: 'bind:body-updated', failure: 'bind:body-update-failed' },\n\n // ── BROWSE (reads) ──────────────────────────────────────────────\n 'browse:resource-requested': { result: 'browse:resource-result', failure: 'browse:resource-failed' },\n 'browse:resources-requested': { result: 'browse:resources-result', failure: 'browse:resources-failed' },\n 'browse:annotation-requested': { result: 'browse:annotation-result', failure: 'browse:annotation-failed' },\n 'browse:annotations-requested': { result: 'browse:annotations-result', failure: 'browse:annotations-failed' },\n 'browse:annotation-history-requested': { result: 'browse:annotation-history-result', failure: 'browse:annotation-history-failed' },\n 'browse:events-requested': { result: 'browse:events-result', failure: 'browse:events-failed' },\n 'browse:referenced-by-requested': { result: 'browse:referenced-by-result', failure: 'browse:referenced-by-failed' },\n 'browse:entity-types-requested': { result: 'browse:entity-types-result', failure: 'browse:entity-types-failed' },\n 'browse:tag-schemas-requested': { result: 'browse:tag-schemas-result', failure: 'browse:tag-schemas-failed' },\n 'browse:agents-requested': { result: 'browse:agents-result', failure: 'browse:agents-failed' },\n 'browse:directory-requested': { result: 'browse:directory-result', failure: 'browse:directory-failed' },\n // dormant — backend handler complete, no client caller yet (annotation-detail capability)\n 'browse:annotation-context-requested': { result: 'browse:annotation-context-result', failure: 'browse:annotation-context-failed' },\n\n // ── FRAME (KB schema writes) ────────────────────────────────────\n 'frame:add-entity-type': { result: 'frame:entity-type-add-ok', failure: 'frame:entity-type-add-failed' },\n 'frame:add-tag-schema': { result: 'frame:tag-schema-add-ok', failure: 'frame:tag-schema-add-failed' },\n\n // ── GATHER ──────────────────────────────────────────────────────\n // streaming: take-1 result + failure plus an intermediate progress channel\n 'gather:requested': { result: 'gather:complete', failure: 'gather:failed', progress: 'gather:annotation-progress' },\n 'gather:resource-requested': { result: 'gather:resource-complete', failure: 'gather:resource-failed' },\n // dormant — backend handler complete, no client caller yet (annotation summary)\n 'gather:summary-requested': { result: 'gather:summary-result', failure: 'gather:summary-failed' },\n\n // ── JOB ─────────────────────────────────────────────────────────\n 'job:create': { result: 'job:created', failure: 'job:create-failed' },\n 'job:status-requested': { result: 'job:status-result', failure: 'job:status-failed' },\n 'job:cancel-requested': { result: 'job:cancel-ok', failure: 'job:cancel-failed' },\n // worker-side: the worker claims a queued job (not an SDK call)\n 'job:claim': { result: 'job:claimed', failure: 'job:claim-failed' },\n\n // ── MARK ────────────────────────────────────────────────────────\n 'mark:create-request': { result: 'mark:create-ok', failure: 'mark:create-failed' },\n 'mark:delete': { result: 'mark:delete-ok', failure: 'mark:delete-failed' },\n 'mark:archive': { result: 'mark:archive-ok', failure: 'mark:archive-failed' },\n 'mark:unarchive': { result: 'mark:unarchive-ok', failure: 'mark:unarchive-failed' },\n 'mark:update-entity-types': { result: 'mark:update-entity-types-ok', failure: 'mark:update-entity-types-failed' },\n\n // ── MATCH ───────────────────────────────────────────────────────\n // take-1 dressed as an Observable in the SDK; no progress channel\n 'match:search-requested': { result: 'match:search-results', failure: 'match:search-failed' },\n\n // ── WEAVE ───────────────────────────────────────────────────────\n // Graph-projection rebuild, served by the Weaver (WEAVER-ISOLATION D3)\n 'weave:rebuild': { result: 'weave:rebuild-ok', failure: 'weave:rebuild-failed' },\n\n // ── YIELD ───────────────────────────────────────────────────────\n // live in-process (resource-operations.ts emits + awaits via race()); the\n // client also .on()-subscribes -ok for cache invalidation\n 'yield:create': { result: 'yield:create-ok', failure: 'yield:create-failed' },\n // dormant — handler in stower exists, no request emitter; client pre-subscribes -ok\n 'yield:update': { result: 'yield:update-ok', failure: 'yield:update-failed' },\n 'yield:clone-create': { result: 'yield:clone-created', failure: 'yield:clone-create-failed' },\n 'yield:clone-resource-requested': { result: 'yield:clone-resource-result', failure: 'yield:clone-resource-failed' },\n 'yield:clone-token-requested': { result: 'yield:clone-token-generated', failure: 'yield:clone-token-failed' },\n} as const satisfies Partial<Record<EmittableChannel, BusOperationSpec>>;\n\n/** The request-channel key of a registered operation — what `busRequest` takes. */\nexport type BusOperationKey = keyof typeof BUS_OPERATIONS;\n","// ⚠ GENERATED FILE — do not edit.\n//\n// Authority: specs/src/bus/registry.json (channels, payloads, operations)\n// Regenerate: node scripts/bus/generate-ts.mjs\n// Go counterpart: node scripts/bus/generate-go.mjs → packages/sdk-go/bus\n//\n// Payload schemas themselves live in the OpenAPI components; the registry\n// names which one each channel carries. Add or change a channel THERE.\n\nimport type { EventName } from './bus-protocol';\nimport { BUS_OPERATIONS } from './bus-operations';\n\n/**\n * BRIDGED_CHANNELS\n *\n * The set of bus channels that any concrete transport bridges into the\n * caller-supplied bus via `bridgeInto`. Transport-neutral: every concrete\n * `ITransport` shares the same set; HTTP delivers them via SSE, in-process\n * transports forward them directly from the local actor bus.\n *\n * This is the *fan-in* set — channels for events the transport receives and\n * pushes onto the client's bus. It is not the same as the channels the client\n * emits (which is open-ended).\n *\n * It is DERIVED, not hand-listed: the request/reply replies come from\n * `BUS_OPERATIONS` (bus-operations.ts), so no operation's reply can be\n * forgotten here — that was the recurring unbridged-reply bug class. The only\n * hand-maintained part is `BRIDGED_BROADCASTS`: the genuine non-request/reply\n * minority (lifecycle events and UI/infra signals that no single requester\n * owns). See .plans/BUS-OPERATIONS-REGISTRY.md.\n *\n * Resource-scoped channels (joined/left via `subscribeToResource`) are tracked\n * separately by transports that care about scope (HTTP).\n */\n\n/**\n * Bridged channels with no owning operation: job-lifecycle events (multi-viewer,\n * no single requester owns the reply), KB-global frame domain events, UI signals,\n * and SSE infrastructure. A reply channel must NOT go here — declare its\n * operation in `BUS_OPERATIONS` instead.\n */\nexport const BRIDGED_BROADCASTS = [\n 'job:report-progress',\n 'job:complete',\n 'job:fail',\n 'frame:entity-type-added',\n 'frame:tag-schema-added',\n 'beckon:focus',\n 'beckon:sparkle',\n 'bus:resume-gap',\n] as const satisfies readonly EventName[];\n\n// ── Derivation ──────────────────────────────────────────────────────────────\n// Every operation's result + failure (+ progress) channel bridges, by\n// construction. Type and runtime are derived from the same `BUS_OPERATIONS`.\n\ntype OpSpecs = (typeof BUS_OPERATIONS)[keyof typeof BUS_OPERATIONS];\n\n// Generic wrapper so the conditional distributes over each union member (a bare\n// `OpSpecs extends …` would test the whole union at once and collapse to never\n// because only the streaming ops carry `progress`).\ntype ProgressChannel<O> = O extends { progress: infer P extends EventName } ? P : never;\n\n/** The union of every reply channel declared in the registry. */\ntype RegistryReply = OpSpecs['result'] | OpSpecs['failure'] | ProgressChannel<OpSpecs>;\n\n// Iterate by typed key so each op's literal reply types survive — the element\n// type stays `RegistryReply` (no widening to `EventName`), so the composed\n// array is `BridgedChannel[]` with no narrowing assertion. The runtime proof\n// that this derived set is exactly the intended one is the equality test in\n// __tests__/bus-invariants.test.ts.\nconst REGISTRY_REPLIES = (Object.keys(BUS_OPERATIONS) as (keyof typeof BUS_OPERATIONS)[]).flatMap(\n (key) => {\n const op = BUS_OPERATIONS[key];\n return 'progress' in op ? [op.result, op.failure, op.progress] : [op.result, op.failure];\n },\n);\n\nexport const BRIDGED_CHANNELS: readonly BridgedChannel[] = [\n ...REGISTRY_REPLIES,\n ...BRIDGED_BROADCASTS,\n];\n\n/**\n * The SUBSCRIBE-side subset of `EventName` — the channels a client can receive\n * over a concrete transport. See the family note on `EventName` in\n * bus-protocol.ts (emit on an `EmittableChannel`, subscribe on a `BridgedChannel`).\n */\nexport type BridgedChannel = RegistryReply | (typeof BRIDGED_BROADCASTS)[number];\n","/**\n * Bus logging — runtime-toggleable cross-wire visibility.\n *\n * One line per event that crosses a process boundary, in a grep-able\n * format that's symmetric across frontend and backend:\n *\n * [bus EMIT] <channel> [scope=X] [cid=<first8>] <payload>\n * [bus RECV] <channel> [scope=X] [cid=<first8>] <payload>\n * [bus SSE] <channel> [scope=X] [cid=<first8>] <payload>\n *\n * Tier 1 of `.plans/OBSERVABILITY.md`. Forward-compatible with Tier 2:\n * the `cid` printed here is exactly the prefix of the W3C trace-id we\n * adopt later.\n *\n * Cost when disabled: one property read per call, zero allocations.\n *\n * Enable:\n * - Browser: `window.__SEMIONT_BUS_LOG__ = true` (DevTools or e2e init)\n * - Node: `SEMIONT_BUS_LOG=1` in the process env (read at module load)\n */\n\nimport { BRIDGED_CHANNELS } from './bridged-channels';\n\nconst NODE_BUS_LOG =\n typeof process !== 'undefined' && !!process.env?.SEMIONT_BUS_LOG;\n\nconst IS_NODE =\n typeof process !== 'undefined' && !!process.versions?.node;\n\nexport type BusOp = 'EMIT' | 'RECV' | 'SSE' | 'PUT' | 'GET';\n\nexport function busLogEnabled(): boolean {\n const g = globalThis as { __SEMIONT_BUS_LOG__?: boolean };\n if (g.__SEMIONT_BUS_LOG__) return true;\n return NODE_BUS_LOG;\n}\n\n/**\n * Optional active-span trace-id provider. When a Tier 2 OTel SDK is\n * initialized, `@semiont/observability` registers a provider here that\n * returns the active span's W3C `trace_id`. busLog appends it to each\n * emitted line so the grep-timeline correlates with the span tree in\n * an APM UI.\n *\n * Decoupling: `@semiont/core` does not depend on `@opentelemetry/api`.\n * If no provider is registered (Tier 1-only deployments, or before\n * `initObservabilityNode` runs), the field is omitted from the line —\n * same shape as before this hook existed.\n */\nlet traceIdProvider: (() => string | undefined) | undefined;\n\nexport function setBusLogTraceIdProvider(fn: (() => string | undefined) | undefined): void {\n traceIdProvider = fn;\n}\n\nexport function busLog(\n op: BusOp,\n channel: string,\n payload: unknown,\n scope?: string,\n): void {\n if (!busLogEnabled()) return;\n const cidRaw = (payload as { correlationId?: unknown } | null | undefined)?.correlationId;\n const cid = typeof cidRaw === 'string' ? cidRaw.slice(0, 8) : undefined;\n let traceId: string | undefined;\n if (traceIdProvider) {\n try { traceId = traceIdProvider(); } catch { /* noop */ }\n }\n const tag =\n `[bus ${op}] ${channel}` +\n (scope ? ` scope=${scope}` : '') +\n (cid ? ` cid=${cid}` : '') +\n (traceId ? ` trace=${traceId.slice(0, 8)}` : '');\n // eslint-disable-next-line no-console\n console.debug(tag, payload);\n}\n\n/**\n * Whether to run the unobserved-reply check on every local emit.\n *\n * On in Node (backend + worker + smelter), where a dropped reply is a real\n * delivery bug; off in the browser, where a 0-observer bridged reply just\n * means the awaiting `busRequest` already resolved/timed out (benign).\n *\n * Always-on (no env flag) by design: the failure it catches is rare and\n * high-signal, and the whole point is that it fires with zero setup — the\n * incident that motivated it (.plans/bugs/gather-resource-complete-not-bridged.md)\n * ran with bus-logging off, so a flag-gated check would have stayed silent.\n */\nexport function warnUnobservedRepliesEnabled(): boolean {\n return IS_NODE;\n}\n\n/** One line per channel per process — a missing fan-in wiring is a config\n * bug, so the first dropped reply is enough; we don't spam on retries. */\nconst unobservedReplyWarned = new Set<string>();\n\n/**\n * The silent-dropped-reply detector.\n *\n * A correlation-bearing payload is a request/reply *reply* (`*-result`,\n * `*-complete`, `*-failed`, …). If one is emitted on the backend bus with\n * **zero local observers**, nothing forwards it — no SSE subscription, no\n * in-process consumer — so the awaiting client never receives it and times\n * out 30 s later with no error logged anywhere. That is exactly how\n * `gather:resource-complete` failed when it was missing from\n * `BRIDGED_CHANNELS` (.plans/bugs/gather-resource-complete-not-bridged.md).\n *\n * Emits one WARN per channel naming the likely fix. Ignored (no warning):\n * non-reply emits (no `correlationId`), emits with observers, and — crucially —\n * channels already in `BRIDGED_CHANNELS`: a 0-observer emit there is a redundant\n * copy, not a gap (see .plans/bugs/BRIDGE-GAPS.md). So the detector fires only\n * for a genuine missing forwarder, and its remediation text is always correct.\n */\nexport function warnIfUnobservedReply(\n channel: string,\n payload: unknown,\n observerCount: number,\n): void {\n if (observerCount > 0) return;\n const cidRaw = (payload as { correlationId?: unknown } | null | undefined)?.correlationId;\n if (typeof cidRaw !== 'string' || cidRaw.length === 0) return;\n // A 0-observer emit on a *bridged* channel is a redundant copy (a global +\n // resource-scoped dual-emit, or an SSE reconnect replay), not a missing\n // forwarder — the first copy already reached the awaiting `take(1)`\n // subscriber. Only a NOT-bridged channel is a genuine drop. (`busRequest` now\n // types its reply channels `BridgedChannel`, so an unbridged reply is a\n // compile error; this runtime check covers non-`busRequest` correlation\n // emits.) See .plans/bugs/BRIDGE-GAPS.md.\n if ((BRIDGED_CHANNELS as readonly string[]).includes(channel)) return;\n if (unobservedReplyWarned.has(channel)) return;\n unobservedReplyWarned.add(channel);\n // eslint-disable-next-line no-console\n console.warn(\n `[bus DROP] ${channel} cid=${cidRaw.slice(0, 8)} emitted with 0 subscribers and not in ` +\n `BRIDGED_CHANNELS — a correlation reply with no forwarder is dropped, so the awaiting ` +\n `client times out (no error). Bridge it by declaring its operation in BUS_OPERATIONS ` +\n `(packages/core/src/bus-operations.ts) — or, if it is a non-reply broadcast, add it to ` +\n `BRIDGED_BROADCASTS (packages/core/src/bridged-channels.ts) — so transports subscribe to it.`,\n );\n}\n","/**\n * RxJS-based Event Bus\n *\n * Framework-agnostic event bus providing direct access to typed RxJS Subjects.\n *\n * Can be used in Node.js, browser, workers, CLI - anywhere RxJS runs.\n */\n\nimport { Subject } from 'rxjs';\nimport { busLog, busLogEnabled, warnIfUnobservedReply, warnUnobservedRepliesEnabled } from './bus-log';\nimport type { EventMap } from './bus-protocol';\nimport type { StoredEvent } from './event-base';\nimport type { PersistedEventType } from './persisted-events';\n\n/**\n * RxJS-based event bus\n *\n * Provides direct access to RxJS Subjects for each event type.\n * Use standard RxJS patterns for emitting and subscribing.\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n *\n * // Emit events\n * eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe to events\n * const subscription = eventBus.get('beckon:hover').subscribe(({ annotationId }) => {\n * console.log('Hover:', annotationId);\n * });\n *\n * // Use RxJS operators\n * import { debounceTime } from 'rxjs/operators';\n * eventBus.get('beckon:hover')\n * .pipe(debounceTime(100))\n * .subscribe(handleHover);\n *\n * // Cleanup\n * subscription.unsubscribe();\n * eventBus.destroy();\n * ```\n */\nexport class EventBus {\n private subjects: Map<keyof EventMap, Subject<any>>;\n private isDestroyed: boolean;\n\n constructor() {\n this.subjects = new Map();\n this.isDestroyed = false;\n }\n\n /**\n * Get the RxJS Subject for an event\n *\n * Returns a typed Subject that can be used with all RxJS operators.\n * Subjects are created lazily on first access.\n *\n * @param eventName - The event name\n * @returns The RxJS Subject for this event\n *\n * @example\n * ```typescript\n * // Emit\n * eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe\n * const sub = eventBus.get('beckon:hover').subscribe(handleHover);\n *\n * // With operators\n * eventBus.get('beckon:hover')\n * .pipe(debounceTime(100), distinctUntilChanged())\n * .subscribe(handleHover);\n * ```\n */\n get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]> {\n if (this.isDestroyed) {\n throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);\n }\n\n if (!this.subjects.has(eventName)) {\n const subject = new Subject<EventMap[K]>();\n // When bus-log is enabled (`SEMIONT_BUS_LOG=1` or\n // `window.__SEMIONT_BUS_LOG__ = true`), wrap `.next()` so every\n // local emit on this channel produces a `[bus EMIT] <channel> ...`\n // line on `console.debug` — same shape as cross-wire emits from\n // HttpTransport. This is what makes local-only fan-out signals\n // (`beckon.hover`, `beckon.sparkle`, `mark.request`, etc.)\n // visible to the e2e bus capture and to a developer's DevTools.\n // The `busLogEnabled()` check is at first-`get` time per channel;\n // setting the flag after channels are constructed won't\n // retroactively wrap them. The bus capture fixture uses\n // `addInitScript` so the flag is set before any namespace\n // construction, which is when `get()` is first called.\n //\n // Independently, on Node we wrap `.next()` to catch *dropped replies*:\n // a correlation-bearing payload emitted with zero observers (see\n // `warnIfUnobservedReply`). This needs no flag — it's how the\n // `gather:resource-complete` bridge gap stayed invisible until a 30 s\n // timeout. The two wraps share one closure when both are active.\n const wantBusLog = busLogEnabled();\n const wantDropCheck = warnUnobservedRepliesEnabled();\n if (wantBusLog || wantDropCheck) {\n const wrapped = subject;\n const originalNext = subject.next.bind(subject);\n subject.next = (value: EventMap[K]): void => {\n if (wantBusLog) busLog('EMIT', String(eventName), value as object);\n if (wantDropCheck) warnIfUnobservedReply(String(eventName), value, wrapped.observers.length);\n originalNext(value);\n };\n }\n this.subjects.set(eventName, subject);\n }\n return this.subjects.get(eventName)!;\n }\n\n /**\n * Get the RxJS Subject for a domain event type (PersistedEventType).\n *\n * Domain event channels carry `StoredEvent`. This method avoids the need\n * for `as keyof EventMap` casts when subscribing to domain event channels\n * using runtime `PersistedEventType` strings.\n */\n getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent> {\n return this.get(eventType as keyof EventMap) as unknown as Subject<StoredEvent>;\n }\n\n /**\n * Destroy the event bus and complete all subjects\n *\n * After calling destroy(), no new events can be emitted or subscribed to.\n * All active subscriptions will be completed.\n */\n destroy(): void {\n if (this.isDestroyed) {\n return;\n }\n\n for (const subject of this.subjects.values()) {\n subject.complete();\n }\n\n this.subjects.clear();\n this.isDestroyed = true;\n }\n\n /**\n * Check if the event bus has been destroyed\n */\n get destroyed(): boolean {\n return this.isDestroyed;\n }\n\n /**\n * Create a resource-scoped event bus\n *\n * Events emitted or subscribed through the scoped bus are isolated to that resource.\n * Internally, events are namespaced but the API remains identical to the parent bus.\n *\n * @param resourceId - Resource identifier to scope events to\n * @returns A scoped event bus for this resource\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n * const resource1 = eventBus.scope('resource-1');\n * const resource2 = eventBus.scope('resource-2');\n *\n * // These are isolated - only resource1 subscribers will fire\n * resource1.get('detection:progress').next({ status: 'started' });\n * ```\n */\n scope(resourceId: string): ScopedEventBus {\n return new ScopedEventBus(this, resourceId);\n }\n}\n\n/**\n * Resource-scoped event bus\n *\n * Provides isolated event streams per resource while maintaining the same API\n * as the parent EventBus. Events are internally namespaced by resourceId.\n */\nexport class ScopedEventBus {\n constructor(\n private parent: EventBus,\n private scopePrefix: string\n ) {}\n\n /**\n * Get the RxJS Subject for a scoped event\n *\n * Returns the same type as the parent bus, but events are isolated to this scope.\n * Internally uses namespaced keys but preserves type safety.\n *\n * @param event - The event name\n * @returns The RxJS Subject for this scoped event\n */\n get<E extends keyof EventMap>(event: E): Subject<EventMap[E]> {\n // Internally namespace the event key, but preserve return type\n const scopedKey = `${this.scopePrefix}:${event as string}`;\n\n // Access parent's subjects map directly (needs cast for private access)\n const parentSubjects = (this.parent as any).subjects as Map<string, Subject<any>>;\n\n if (!parentSubjects.has(scopedKey)) {\n parentSubjects.set(scopedKey, new Subject<EventMap[E]>());\n }\n return parentSubjects.get(scopedKey)!;\n }\n\n /** Get the RxJS Subject for a domain event type on this scoped bus. */\n getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent> {\n return this.get(eventType as keyof EventMap) as unknown as Subject<StoredEvent>;\n }\n\n /**\n * Create a nested scope\n *\n * Allows hierarchical scoping like `resource-1:subsystem-a`\n *\n * @param subScope - Additional scope level\n * @returns A nested scoped event bus\n */\n scope(subScope: string): ScopedEventBus {\n return new ScopedEventBus(this.parent, `${this.scopePrefix}:${subScope}`);\n }\n}\n"]}