@@ -47,6 +47,25 @@ export function createPreparedPluginGeneration(params: {
4747 } ) ;
4848}
4949
50+ export function projectPreparedPluginGeneration ( params : {
51+ input : PreparedModelRuntimeInput ;
52+ pluginGeneration : PreparedModelRuntimePluginGeneration ;
53+ } ) : PreparedModelRuntimePluginGeneration {
54+ const { input, pluginGeneration } = params ;
55+ if ( ! input . workspaceDir ) {
56+ return pluginGeneration ;
57+ }
58+ const pluginMetadataSnapshot = projectPluginMetadataSnapshotWorkspace ( {
59+ snapshot : pluginGeneration . pluginMetadataSnapshot ,
60+ config : input . config ,
61+ env : input . env ?? process . env ,
62+ workspaceDir : input . workspaceDir ,
63+ } ) ;
64+ return pluginMetadataSnapshot === pluginGeneration . pluginMetadataSnapshot
65+ ? pluginGeneration
66+ : Object . freeze ( { ...pluginGeneration , pluginMetadataSnapshot } ) ;
67+ }
68+
5069export async function buildPreparedPluginModelCatalog ( params : {
5170 agentFacts : {
5271 credentials : Parameters < typeof buildPreparedModelCatalogSnapshot > [ 0 ] [ "authCredentials" ] ;
@@ -59,13 +78,13 @@ export async function buildPreparedPluginModelCatalog(params: {
5978 const { credentials, input } = params . agentFacts ;
6079 return await withPreparedPluginGenerationScope (
6180 { input, pluginGeneration : params . pluginGeneration } ,
62- ( ) =>
81+ ( metadataSnapshot ) =>
6382 buildPreparedModelCatalogSnapshot ( {
6483 agentDir : input . agentDir ,
6584 authCredentials : credentials ,
6685 config : input . config ,
6786 modelRegistry : params . modelRegistry ,
68- metadataSnapshot : params . pluginGeneration . pluginMetadataSnapshot ,
87+ metadataSnapshot,
6988 includeProviderPluginAugmentation : params . catalogMode === "live" ,
7089 ...( input . env ? { env : input . env } : { } ) ,
7190 ...( input . readOnly ? { readOnly : true } : { } ) ,
@@ -82,15 +101,9 @@ export function withPreparedPluginGenerationScope<T>(
82101 } ,
83102 run : ( metadataSnapshot : PreparedModelRuntimePluginGeneration [ "pluginMetadataSnapshot" ] ) => T ,
84103) : T {
85- const { input, pluginGeneration } = params ;
86- const metadataSnapshot = input . workspaceDir
87- ? projectPluginMetadataSnapshotWorkspace ( {
88- snapshot : pluginGeneration . pluginMetadataSnapshot ,
89- config : input . config ,
90- env : input . env ?? process . env ,
91- workspaceDir : input . workspaceDir ,
92- } )
93- : pluginGeneration . pluginMetadataSnapshot ;
104+ const { input } = params ;
105+ const pluginGeneration = projectPreparedPluginGeneration ( params ) ;
106+ const metadataSnapshot = pluginGeneration . pluginMetadataSnapshot ;
94107 return withPluginRuntimeGenerationScope (
95108 {
96109 config : input . config ,
0 commit comments