diff --git a/api/server/experimental.js b/api/server/experimental.js index 5978d8d26f..2f29bad154 100644 --- a/api/server/experimental.js +++ b/api/server/experimental.js @@ -61,6 +61,8 @@ const { startCodeEnvironmentLifecycleReconciler, waitForKeyvRedisClient, createCodeApiUploadRegistry, + createSdkFileHost, + createSdkModelHost, cacheConfig, createClusteredFileSweep, createRequestSanitizer, @@ -545,6 +547,8 @@ if (cluster.isMaster) { }), { priority: 50 }, ); + app.locals.sdkFileHost = createSdkFileHost(appConfig?.endpoints?.agents?.sdkHostFiles); + app.locals.sdkModelHost = createSdkModelHost(appConfig?.endpoints?.agents?.sdkHostModels); initializeFileStorage(appConfig); initializeGitHubSkillSync(appConfig); startSkillDeletionSweep(appConfig.skillDeletion); diff --git a/api/server/experimental.spec.js b/api/server/experimental.spec.js index c15eaee8b5..9908accdc7 100644 --- a/api/server/experimental.spec.js +++ b/api/server/experimental.spec.js @@ -13,6 +13,21 @@ describe('Experimental server configuration', () => { expect(listenIndex).toBeLessThan(timeoutConfigIndex); }); + it.each([ + ['File', 'Files'], + ['Model', 'Models'], + ])('installs the SDK %s host from base config before serving requests', (host, setting) => { + const configIndex = source.indexOf('await getAppConfig({ baseOnly: true });'); + const binding = `app.locals.sdk${host}Host = createSdk${host}Host(appConfig?.endpoints?.agents?.sdkHost${setting});`; + const bindingIndex = source.indexOf(binding); + const listenIndex = source.indexOf('const server = app.listen'); + + expect(configIndex).toBeGreaterThan(-1); + expect(bindingIndex).toBeGreaterThan(configIndex); + expect(listenIndex).toBeGreaterThan(bindingIndex); + expect(source.indexOf(binding, bindingIndex + 1)).toBe(-1); + }); + it('lets each worker drain registered services before cluster shutdown', () => { const listenIndex = source.indexOf('const server = app.listen'); const gracefulShutdownIndex = source.indexOf('setupGracefulShutdown(server);');