@semiont/core 0.2.34-build.89 → 0.2.34-build.91

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
@@ -3760,52 +3760,55 @@ interface DetectionProgress {
3760
3760
  }
3761
3761
  /**
3762
3762
  * Unified event map for all application events
3763
+ *
3764
+ * Organized by workflow ("flows"):
3765
+ * 1. AttentionFlow - Annotation hover/focus/sparkle coordination
3766
+ * 2. DetectionFlow - Manual + AI annotation detection (all motivations)
3767
+ * 3. GenerationFlow - Document generation from references
3768
+ * 4. ResolutionFlow - Reference linking/resolution (search modal)
3769
+ * 5. ContextRetrievalFlow - LLM context fetching from annotations
3770
+ *
3771
+ * Plus infrastructure events (domain events, SSE, resource operations, navigation, settings)
3763
3772
  */
3764
3773
  type EventMap = {
3765
- 'make-meaning:event': ResourceEvent;
3766
- 'detection:started': Extract<ResourceEvent, {
3767
- type: 'job.started';
3768
- }>;
3769
- 'detection:entity-found': Extract<ResourceEvent, {
3770
- type: 'annotation.added';
3771
- }>;
3772
- 'detection:completed': Extract<ResourceEvent, {
3773
- type: 'job.completed';
3774
- }>;
3775
- 'detection:failed': Extract<ResourceEvent, {
3776
- type: 'job.failed';
3777
- }>;
3778
- 'detection:progress': DetectionProgress;
3779
- 'annotation:added': Extract<ResourceEvent, {
3774
+ 'annotation.added': Extract<ResourceEvent, {
3780
3775
  type: 'annotation.added';
3781
3776
  }>;
3782
- 'annotation:removed': Extract<ResourceEvent, {
3777
+ 'annotation.removed': Extract<ResourceEvent, {
3783
3778
  type: 'annotation.removed';
3784
3779
  }>;
3785
- 'annotation:updated': Extract<ResourceEvent, {
3780
+ 'annotation.body.updated': Extract<ResourceEvent, {
3786
3781
  type: 'annotation.body.updated';
3787
3782
  }>;
3788
- 'entity-tag:added': Extract<ResourceEvent, {
3783
+ 'entitytag.added': Extract<ResourceEvent, {
3789
3784
  type: 'entitytag.added';
3790
3785
  }>;
3791
- 'entity-tag:removed': Extract<ResourceEvent, {
3786
+ 'entitytag.removed': Extract<ResourceEvent, {
3792
3787
  type: 'entitytag.removed';
3793
3788
  }>;
3794
- 'resource:archived': Extract<ResourceEvent, {
3789
+ 'resource.archived': Extract<ResourceEvent, {
3795
3790
  type: 'resource.archived';
3796
3791
  }>;
3797
- 'resource:unarchived': Extract<ResourceEvent, {
3792
+ 'resource.unarchived': Extract<ResourceEvent, {
3798
3793
  type: 'resource.unarchived';
3799
3794
  }>;
3800
- 'selection:comment-requested': SelectionData;
3801
- 'selection:tag-requested': SelectionData;
3802
- 'selection:assessment-requested': SelectionData;
3803
- 'selection:reference-requested': SelectionData;
3804
- 'annotation:requested': {
3805
- selector: Selector | Selector[];
3806
- motivation: Motivation;
3807
- };
3808
- 'annotation:cancel-pending': void;
3795
+ 'job.started': Extract<ResourceEvent, {
3796
+ type: 'job.started';
3797
+ }>;
3798
+ 'job.completed': Extract<ResourceEvent, {
3799
+ type: 'job.completed';
3800
+ }>;
3801
+ 'job.failed': Extract<ResourceEvent, {
3802
+ type: 'job.failed';
3803
+ }>;
3804
+ 'representation.added': Extract<ResourceEvent, {
3805
+ type: 'representation.added';
3806
+ }>;
3807
+ 'representation.removed': Extract<ResourceEvent, {
3808
+ type: 'representation.removed';
3809
+ }>;
3810
+ 'make-meaning:event': ResourceEvent;
3811
+ 'stream-connected': void;
3809
3812
  'annotation:hover': {
3810
3813
  annotationId: string | null;
3811
3814
  };
@@ -3819,65 +3822,15 @@ type EventMap = {
3819
3822
  'annotation:sparkle': {
3820
3823
  annotationId: string;
3821
3824
  };
3822
- 'panel:toggle': {
3823
- panel: string;
3824
- };
3825
- 'panel:open': {
3826
- panel: string;
3827
- scrollToAnnotationId?: string;
3828
- motivation?: string;
3829
- };
3830
- 'panel:close': void;
3831
- 'view:mode-toggled': void;
3832
- 'toolbar:selection-changed': {
3833
- motivation: string | null;
3834
- };
3835
- 'toolbar:click-changed': {
3836
- action: string;
3837
- };
3838
- 'toolbar:shape-changed': {
3839
- shape: string;
3840
- };
3841
- 'navigation:sidebar-toggle': void;
3842
- 'navigation:resource-close': {
3843
- resourceId: string;
3844
- };
3845
- 'navigation:resource-reorder': {
3846
- oldIndex: number;
3847
- newIndex: number;
3848
- };
3849
- 'navigation:link-clicked': {
3850
- href: string;
3851
- label?: string;
3852
- };
3853
- 'navigation:router-push': {
3854
- path: string;
3855
- reason?: string;
3856
- };
3857
- 'navigation:external-navigate': {
3858
- url: string;
3859
- resourceId?: string;
3860
- cancelFallback: () => void;
3861
- };
3862
- 'navigation:reference-navigate': {
3863
- documentId: string;
3864
- };
3865
- 'navigation:entity-type-clicked': {
3866
- entityType: string;
3867
- };
3868
- 'settings:theme-changed': {
3869
- theme: 'light' | 'dark' | 'system';
3870
- };
3871
- 'settings:line-numbers-toggled': void;
3872
- 'settings:locale-changed': {
3873
- locale: string;
3874
- };
3875
- 'resource:archive': void;
3876
- 'resource:unarchive': void;
3877
- 'resource:clone': void;
3878
- 'job:cancel-requested': {
3879
- jobType: 'detection' | 'generation';
3825
+ 'selection:comment-requested': SelectionData;
3826
+ 'selection:tag-requested': SelectionData;
3827
+ 'selection:assessment-requested': SelectionData;
3828
+ 'selection:reference-requested': SelectionData;
3829
+ 'annotation:requested': {
3830
+ selector: Selector | Selector[];
3831
+ motivation: Motivation;
3880
3832
  };
3833
+ 'annotation:cancel-pending': void;
3881
3834
  'annotation:create': {
3882
3835
  motivation: Motivation;
3883
3836
  selector: Selector | Selector[];
@@ -3898,27 +3851,10 @@ type EventMap = {
3898
3851
  'annotation:delete-failed': {
3899
3852
  error: Error;
3900
3853
  };
3901
- 'annotation:update-body': {
3902
- annotationUri: string;
3903
- resourceId: string;
3904
- operations: Array<{
3905
- op: 'add' | 'remove' | 'replace';
3906
- item?: components['schemas']['AnnotationBody'];
3907
- oldItem?: components['schemas']['AnnotationBody'];
3908
- newItem?: components['schemas']['AnnotationBody'];
3909
- }>;
3910
- };
3911
- 'annotation:body-updated': {
3912
- annotationUri: string;
3913
- };
3914
- 'annotation:body-update-failed': {
3915
- error: Error;
3916
- };
3917
3854
  'detection:start': {
3918
3855
  motivation: Motivation;
3919
3856
  options: {
3920
3857
  instructions?: string;
3921
- /** Comment tone */
3922
3858
  tone?: 'scholarly' | 'explanatory' | 'conversational' | 'technical' | 'analytical' | 'critical' | 'balanced' | 'constructive';
3923
3859
  density?: number;
3924
3860
  entityTypes?: string[];
@@ -3927,13 +3863,31 @@ type EventMap = {
3927
3863
  categories?: string[];
3928
3864
  };
3929
3865
  };
3866
+ 'detection:started': Extract<ResourceEvent, {
3867
+ type: 'job.started';
3868
+ }>;
3869
+ 'detection:progress': DetectionProgress;
3870
+ 'detection:entity-found': Extract<ResourceEvent, {
3871
+ type: 'annotation.added';
3872
+ }>;
3930
3873
  'detection:complete': {
3931
3874
  motivation?: Motivation;
3932
3875
  resourceUri?: ResourceUri;
3933
3876
  progress?: DetectionProgress;
3934
3877
  };
3878
+ 'detection:completed': Extract<ResourceEvent, {
3879
+ type: 'job.completed';
3880
+ }>;
3881
+ 'detection:failed': Extract<ResourceEvent, {
3882
+ type: 'job.failed';
3883
+ }>;
3935
3884
  'detection:cancelled': void;
3936
3885
  'detection:dismiss-progress': void;
3886
+ 'generation:modal-open': {
3887
+ annotationUri: string;
3888
+ resourceUri: string;
3889
+ defaultTitle: string;
3890
+ };
3937
3891
  'generation:start': {
3938
3892
  annotationUri: string;
3939
3893
  resourceUri: string;
@@ -3946,19 +3900,17 @@ type EventMap = {
3946
3900
  context: GenerationContext;
3947
3901
  };
3948
3902
  };
3903
+ 'generation:started': Extract<ResourceEvent, {
3904
+ type: 'job.started';
3905
+ }>;
3949
3906
  'generation:progress': GenerationProgress;
3950
- 'generation:complete': {
3951
- annotationUri: string;
3952
- progress: GenerationProgress;
3953
- };
3907
+ 'generation:complete': GenerationProgress;
3908
+ 'generation:completed': Extract<ResourceEvent, {
3909
+ type: 'job.completed';
3910
+ }>;
3954
3911
  'generation:failed': {
3955
3912
  error: Error;
3956
3913
  };
3957
- 'generation:modal-open': {
3958
- annotationUri: string;
3959
- resourceUri: string;
3960
- defaultTitle: string;
3961
- };
3962
3914
  'reference:create-manual': {
3963
3915
  annotationUri: string;
3964
3916
  title: string;
@@ -3972,6 +3924,22 @@ type EventMap = {
3972
3924
  referenceId: string;
3973
3925
  searchTerm: string;
3974
3926
  };
3927
+ 'annotation:update-body': {
3928
+ annotationUri: string;
3929
+ resourceId: string;
3930
+ operations: Array<{
3931
+ op: 'add' | 'remove' | 'replace';
3932
+ item?: components['schemas']['AnnotationBody'];
3933
+ oldItem?: components['schemas']['AnnotationBody'];
3934
+ newItem?: components['schemas']['AnnotationBody'];
3935
+ }>;
3936
+ };
3937
+ 'annotation:body-updated': {
3938
+ annotationUri: string;
3939
+ };
3940
+ 'annotation:body-update-failed': {
3941
+ error: Error;
3942
+ };
3975
3943
  'context:retrieval-requested': {
3976
3944
  annotationUri: string;
3977
3945
  resourceUri: string;
@@ -3984,7 +3952,97 @@ type EventMap = {
3984
3952
  annotationUri: string;
3985
3953
  error: Error;
3986
3954
  };
3955
+ 'annotation:added': Extract<ResourceEvent, {
3956
+ type: 'annotation.added';
3957
+ }>;
3958
+ 'annotation:removed': Extract<ResourceEvent, {
3959
+ type: 'annotation.removed';
3960
+ }>;
3961
+ 'annotation:updated': Extract<ResourceEvent, {
3962
+ type: 'annotation.body.updated';
3963
+ }>;
3964
+ 'entity-tag:added': Extract<ResourceEvent, {
3965
+ type: 'entitytag.added';
3966
+ }>;
3967
+ 'entity-tag:removed': Extract<ResourceEvent, {
3968
+ type: 'entitytag.removed';
3969
+ }>;
3970
+ 'resource:archived': Extract<ResourceEvent, {
3971
+ type: 'resource.archived';
3972
+ }>;
3973
+ 'resource:unarchived': Extract<ResourceEvent, {
3974
+ type: 'resource.unarchived';
3975
+ }>;
3976
+ 'resource:archive': void;
3977
+ 'resource:unarchive': void;
3978
+ 'resource:clone': void;
3979
+ 'job:queued': {
3980
+ jobId: string;
3981
+ jobType: string;
3982
+ resourceId: string;
3983
+ };
3984
+ 'job:cancel-requested': {
3985
+ jobType: 'detection' | 'generation';
3986
+ };
3987
+ 'panel:toggle': {
3988
+ panel: string;
3989
+ };
3990
+ 'panel:open': {
3991
+ panel: string;
3992
+ scrollToAnnotationId?: string;
3993
+ motivation?: string;
3994
+ };
3995
+ 'panel:close': void;
3996
+ 'view:mode-toggled': void;
3997
+ 'toolbar:selection-changed': {
3998
+ motivation: string | null;
3999
+ };
4000
+ 'toolbar:click-changed': {
4001
+ action: string;
4002
+ };
4003
+ 'toolbar:shape-changed': {
4004
+ shape: string;
4005
+ };
4006
+ 'navigation:sidebar-toggle': void;
4007
+ 'navigation:resource-close': {
4008
+ resourceId: string;
4009
+ };
4010
+ 'navigation:resource-reorder': {
4011
+ oldIndex: number;
4012
+ newIndex: number;
4013
+ };
4014
+ 'navigation:link-clicked': {
4015
+ href: string;
4016
+ label?: string;
4017
+ };
4018
+ 'navigation:router-push': {
4019
+ path: string;
4020
+ reason?: string;
4021
+ };
4022
+ 'navigation:external-navigate': {
4023
+ url: string;
4024
+ resourceId?: string;
4025
+ cancelFallback: () => void;
4026
+ };
4027
+ 'navigation:reference-navigate': {
4028
+ documentId: string;
4029
+ };
4030
+ 'navigation:entity-type-clicked': {
4031
+ entityType: string;
4032
+ };
4033
+ 'settings:theme-changed': {
4034
+ theme: 'light' | 'dark' | 'system';
4035
+ };
4036
+ 'settings:line-numbers-toggled': void;
4037
+ 'settings:locale-changed': {
4038
+ locale: string;
4039
+ };
3987
4040
  };
4041
+ /**
4042
+ * Union type of all valid event names
4043
+ * Use this to enforce compile-time checking of event names
4044
+ */
4045
+ type EventName = keyof EventMap;
3988
4046
 
3989
4047
  /**
3990
4048
  * RxJS-based Event Bus
@@ -4062,6 +4120,56 @@ declare class EventBus {
4062
4120
  * Check if the event bus has been destroyed
4063
4121
  */
4064
4122
  get destroyed(): boolean;
4123
+ /**
4124
+ * Create a resource-scoped event bus
4125
+ *
4126
+ * Events emitted or subscribed through the scoped bus are isolated to that resource.
4127
+ * Internally, events are namespaced but the API remains identical to the parent bus.
4128
+ *
4129
+ * @param resourceId - Resource identifier to scope events to
4130
+ * @returns A scoped event bus for this resource
4131
+ *
4132
+ * @example
4133
+ * ```typescript
4134
+ * const eventBus = new EventBus();
4135
+ * const resource1 = eventBus.scope('resource-1');
4136
+ * const resource2 = eventBus.scope('resource-2');
4137
+ *
4138
+ * // These are isolated - only resource1 subscribers will fire
4139
+ * resource1.get('detection:progress').next({ status: 'started' });
4140
+ * ```
4141
+ */
4142
+ scope(resourceId: string): ScopedEventBus;
4143
+ }
4144
+ /**
4145
+ * Resource-scoped event bus
4146
+ *
4147
+ * Provides isolated event streams per resource while maintaining the same API
4148
+ * as the parent EventBus. Events are internally namespaced by resourceId.
4149
+ */
4150
+ declare class ScopedEventBus {
4151
+ private parent;
4152
+ private scopePrefix;
4153
+ constructor(parent: EventBus, scopePrefix: string);
4154
+ /**
4155
+ * Get the RxJS Subject for a scoped event
4156
+ *
4157
+ * Returns the same type as the parent bus, but events are isolated to this scope.
4158
+ * Internally uses namespaced keys but preserves type safety.
4159
+ *
4160
+ * @param event - The event name
4161
+ * @returns The RxJS Subject for this scoped event
4162
+ */
4163
+ get<E extends keyof EventMap>(event: E): Subject<EventMap[E]>;
4164
+ /**
4165
+ * Create a nested scope
4166
+ *
4167
+ * Allows hierarchical scoping like `resource-1:subsystem-a`
4168
+ *
4169
+ * @param subScope - Additional scope level
4170
+ * @returns A nested scoped event bus
4171
+ */
4172
+ scope(subScope: string): ScopedEventBus;
4065
4173
  }
4066
4174
 
4067
4175
  /**
@@ -4891,8 +4999,8 @@ declare function getAllPlatformTypes(): PlatformType[];
4891
4999
  /**
4892
5000
  * Environment Loader Module
4893
5001
  *
4894
- * Responsible for loading and merging environment configurations.
4895
- * Handles semiont.json base config and environment-specific overrides.
5002
+ * Responsible for parsing and merging environment configurations.
5003
+ * Pure functions only - callers handle filesystem I/O.
4896
5004
  */
4897
5005
 
4898
5006
  /**
@@ -4992,6 +5100,41 @@ declare function hasAWSConfig(config: EnvironmentConfig): config is EnvironmentC
4992
5100
  * @param config - Configuration to display
4993
5101
  */
4994
5102
  declare function displayConfiguration(config: EnvironmentConfig): void;
5103
+ /**
5104
+ * File reader abstraction for platform-agnostic config loading
5105
+ * Implementations provide platform-specific file I/O (Node.js, Deno, Bun, etc.)
5106
+ */
5107
+ type ConfigFileReader = {
5108
+ /** Read file if it exists, return null otherwise */
5109
+ readIfExists: (path: string) => string | null;
5110
+ /** Read file, throw error if it doesn't exist */
5111
+ readRequired: (path: string) => string;
5112
+ };
5113
+ /**
5114
+ * Create a config loader with a specific file reader implementation
5115
+ * Higher-order function that returns a platform-specific config loader
5116
+ *
5117
+ * @param reader - Platform-specific file reader implementation
5118
+ * @returns Function to load environment config from filesystem
5119
+ *
5120
+ * @example
5121
+ * ```typescript
5122
+ * import * as fs from 'fs';
5123
+ * import { createConfigLoader } from '@semiont/core';
5124
+ *
5125
+ * const nodeReader = {
5126
+ * readIfExists: (path) => fs.existsSync(path) ? fs.readFileSync(path, 'utf-8') : null,
5127
+ * readRequired: (path) => {
5128
+ * if (!fs.existsSync(path)) throw new Error(`File not found: ${path}`);
5129
+ * return fs.readFileSync(path, 'utf-8');
5130
+ * },
5131
+ * };
5132
+ *
5133
+ * const loadConfig = createConfigLoader(nodeReader);
5134
+ * const config = loadConfig('/project/root', 'production');
5135
+ * ```
5136
+ */
5137
+ declare function createConfigLoader(reader: ConfigFileReader): (projectRoot: string, environment: string) => EnvironmentConfig;
4995
5138
 
4996
5139
  /**
4997
5140
  * Environment validation utilities
@@ -5071,4 +5214,4 @@ declare class ConfigurationError extends Error {
5071
5214
  declare const CORE_TYPES_VERSION = "0.1.0";
5072
5215
  declare const SDK_VERSION = "0.1.0";
5073
5216
 
5074
- export { APIError, type AWSConfig, type AccessToken, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationRemovedEvent, type AnnotationUri, type AppConfig, type AuthCode, type BackendServiceConfig, type BaseEvent, type BaseUrl, type BodyItem, type BodyOperation, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ContentFormat$1 as ContentFormat, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type DetectionProgress, type Email, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityType, type EntityTypeStats, type Environment, type EnvironmentConfig, EventBus, type EventMap, type EventMetadata, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GenerationContext, type GenerationProgress, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type InferenceServiceConfig, type JobCompletedEvent, type JobFailedEvent, type JobId, type JobProgressEvent, type JobStartedEvent, type MCPToken, type McpServiceConfig, type Motivation$2 as Motivation, NotFoundError, type PlatformType, type ProxyServiceConfig, type RefreshToken, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, type ResourceUri, SDK_VERSION, ScriptError, type SearchQuery, type SelectionData, type Selector, type SemiontConfig, SemiontError, type ServiceConfig, type ServicePlatformConfig, type ServicesConfig, type SiteConfig, type StoredEvent, type SystemEvent, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, type ValidationResult, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, type components, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent$1 as isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, type operations, parseAndMergeConfigs, parseEnvironment, type paths, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
5217
+ export { APIError, type AWSConfig, type AccessToken, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationRemovedEvent, type AnnotationUri, type AppConfig, type AuthCode, type BackendServiceConfig, type BaseEvent, type BaseUrl, type BodyItem, type BodyOperation, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, type ConfigFileReader, ConfigurationError, ConflictError, type ContentFormat$1 as ContentFormat, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type DetectionProgress, type Email, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityType, type EntityTypeStats, type Environment, type EnvironmentConfig, EventBus, type EventMap, type EventMetadata, type EventName, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GenerationContext, type GenerationProgress, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type InferenceServiceConfig, type JobCompletedEvent, type JobFailedEvent, type JobId, type JobProgressEvent, type JobStartedEvent, type MCPToken, type McpServiceConfig, type Motivation$2 as Motivation, NotFoundError, type PlatformType, type ProxyServiceConfig, type RefreshToken, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, type SemiontConfig, SemiontError, type ServiceConfig, type ServicePlatformConfig, type ServicesConfig, type SiteConfig, type StoredEvent, type SystemEvent, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, type ValidationResult, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, type components, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent$1 as isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, type operations, parseAndMergeConfigs, parseEnvironment, type paths, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
package/dist/index.js CHANGED
@@ -236,6 +236,62 @@ var EventBus = class {
236
236
  get destroyed() {
237
237
  return this.isDestroyed;
238
238
  }
239
+ /**
240
+ * Create a resource-scoped event bus
241
+ *
242
+ * Events emitted or subscribed through the scoped bus are isolated to that resource.
243
+ * Internally, events are namespaced but the API remains identical to the parent bus.
244
+ *
245
+ * @param resourceId - Resource identifier to scope events to
246
+ * @returns A scoped event bus for this resource
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * const eventBus = new EventBus();
251
+ * const resource1 = eventBus.scope('resource-1');
252
+ * const resource2 = eventBus.scope('resource-2');
253
+ *
254
+ * // These are isolated - only resource1 subscribers will fire
255
+ * resource1.get('detection:progress').next({ status: 'started' });
256
+ * ```
257
+ */
258
+ scope(resourceId2) {
259
+ return new ScopedEventBus(this, resourceId2);
260
+ }
261
+ };
262
+ var ScopedEventBus = class _ScopedEventBus {
263
+ constructor(parent, scopePrefix) {
264
+ this.parent = parent;
265
+ this.scopePrefix = scopePrefix;
266
+ }
267
+ /**
268
+ * Get the RxJS Subject for a scoped event
269
+ *
270
+ * Returns the same type as the parent bus, but events are isolated to this scope.
271
+ * Internally uses namespaced keys but preserves type safety.
272
+ *
273
+ * @param event - The event name
274
+ * @returns The RxJS Subject for this scoped event
275
+ */
276
+ get(event) {
277
+ const scopedKey = `${this.scopePrefix}:${event}`;
278
+ const parentSubjects = this.parent.subjects;
279
+ if (!parentSubjects.has(scopedKey)) {
280
+ parentSubjects.set(scopedKey, new Subject());
281
+ }
282
+ return parentSubjects.get(scopedKey);
283
+ }
284
+ /**
285
+ * Create a nested scope
286
+ *
287
+ * Allows hierarchical scoping like `resource-1:subsystem-a`
288
+ *
289
+ * @param subScope - Additional scope level
290
+ * @returns A nested scoped event bus
291
+ */
292
+ scope(subScope) {
293
+ return new _ScopedEventBus(this.parent, `${this.scopePrefix}:${subScope}`);
294
+ }
239
295
  };
240
296
 
241
297
  // src/annotation-utils.ts
@@ -2197,6 +2253,13 @@ function displayConfiguration(config) {
2197
2253
  console.log("Environment Configuration:");
2198
2254
  console.log(JSON.stringify(config, null, 2));
2199
2255
  }
2256
+ function createConfigLoader(reader) {
2257
+ return (projectRoot, environment) => {
2258
+ const baseContent = reader.readIfExists(`${projectRoot}/semiont.json`);
2259
+ const envContent = reader.readRequired(`${projectRoot}/environments/${environment}.json`);
2260
+ return parseAndMergeConfigs(baseContent, envContent, process.env, environment, projectRoot);
2261
+ };
2262
+ }
2200
2263
 
2201
2264
  // src/config/environment-validator.ts
2202
2265
  function isValidEnvironment(value, availableEnvironments) {
@@ -2234,6 +2297,6 @@ function getAllPlatformTypes() {
2234
2297
  var CORE_TYPES_VERSION = "0.1.0";
2235
2298
  var SDK_VERSION = "0.1.0";
2236
2299
 
2237
- export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, parseAndMergeConfigs, parseEnvironment, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
2300
+ export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, parseAndMergeConfigs, parseEnvironment, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
2238
2301
  //# sourceMappingURL=index.js.map
2239
2302
  //# sourceMappingURL=index.js.map