@@ -69,11 +69,19 @@ export type CatalogStore = {
6969 executableActionIds : Set < string > ;
7070} ;
7171
72- export interface LoadCatalogOptions {
72+ export interface CreateCatalogStoreOptions {
7373 executableActionIds ?: Iterable < string > ;
7474}
7575
76- export function createCatalogStore ( providers : ProviderDefinition [ ] , options : LoadCatalogOptions = { } ) : CatalogStore {
76+ export interface LoadCatalogOptions extends CreateCatalogStoreOptions {
77+ /** Mark every catalog action owned by these locally loaded provider services as executable. */
78+ executableServices ?: Iterable < string > ;
79+ }
80+
81+ export function createCatalogStore (
82+ providers : ProviderDefinition [ ] ,
83+ options : CreateCatalogStoreOptions = { } ,
84+ ) : CatalogStore {
7785 const sortedProviders = sortProviders ( providers ) ;
7886 const executableActions = new Set ( options . executableActionIds ?? [ ] ) ;
7987 const runtimeProviders = sortedProviders . map ( ( provider ) : RuntimeProviderDefinition => {
@@ -148,7 +156,26 @@ export async function loadCatalog(
148156 return JSON . parse ( content ) as ProviderDefinition ;
149157 } ) ,
150158 ) ;
151- return createCatalogStore ( providers , options ) ;
159+ return createCatalogStore ( providers , {
160+ executableActionIds : resolveExecutableActionIds ( providers , options ) ,
161+ } ) ;
162+ }
163+
164+ /** Resolve provider-level executable services into the exact action ids present in a loaded catalog. */
165+ export function resolveExecutableActionIds (
166+ providers : ProviderDefinition [ ] ,
167+ options : LoadCatalogOptions = { } ,
168+ ) : Set < string > {
169+ const actionIds = new Set ( options . executableActionIds ?? [ ] ) ;
170+ const services = new Set ( options . executableServices ?? [ ] ) ;
171+ for ( const provider of providers ) {
172+ if ( services . has ( provider . service ) ) {
173+ for ( const action of provider . actions ) {
174+ actionIds . add ( action . id ) ;
175+ }
176+ }
177+ }
178+ return actionIds ;
152179}
153180
154181function createActionExecutionStatus (
0 commit comments