@@ -153,6 +153,39 @@ describe("provider local service", () => {
153153 await waitForProbeFailure ( healthUrl ) ;
154154 } ) ;
155155
156+ it ( "allows a default loopback endpoint when provider baseUrl is omitted" , async ( ) => {
157+ const port = await freePort ( ) ;
158+ const healthUrl = `http://127.0.0.1:${ port } /v1/models` ;
159+ const acquire = createConfiguredProviderLocalServiceAcquirer ( ( ) => ( {
160+ models : {
161+ providers : {
162+ "gpu-default" : {
163+ models : [ ] ,
164+ localService : {
165+ command : process . execPath ,
166+ args : [
167+ "-e" ,
168+ `const http=require("http");http.createServer((req,res)=>{res.writeHead(200);res.end("ok");}).listen(${ port } ,"127.0.0.1");` ,
169+ ] ,
170+ healthUrl,
171+ readyTimeoutMs : 5_000 ,
172+ idleStopMs : 1 ,
173+ } ,
174+ } ,
175+ } ,
176+ } ,
177+ } ) ) ;
178+
179+ const lease = await acquire ( {
180+ providerId : "gpu-default" ,
181+ baseUrl : `http://127.0.0.1:${ port } /v1` ,
182+ } ) ;
183+
184+ expect ( lease ) . toBeDefined ( ) ;
185+ lease ?. release ( ) ;
186+ await waitForProbeFailure ( healthUrl ) ;
187+ } ) ;
188+
156189 it ( "rejects plugin-selected local service probe hosts" , async ( ) => {
157190 const acquire = createConfiguredProviderLocalServiceAcquirer ( ( ) => ( {
158191 models : {
@@ -177,6 +210,29 @@ describe("provider local service", () => {
177210 ) . rejects . toThrow ( "must match models.providers.gpu-spark.baseUrl" ) ;
178211 } ) ;
179212
213+ it ( "rejects a remote endpoint when provider baseUrl is omitted" , async ( ) => {
214+ const acquire = createConfiguredProviderLocalServiceAcquirer ( ( ) => ( {
215+ models : {
216+ providers : {
217+ "gpu-default" : {
218+ models : [ ] ,
219+ localService : {
220+ command : process . execPath ,
221+ args : [ "--version" ] ,
222+ } ,
223+ } ,
224+ } ,
225+ } ,
226+ } ) ) ;
227+
228+ await expect (
229+ acquire ( {
230+ providerId : "gpu-default" ,
231+ baseUrl : "http://memory.example/v1" ,
232+ } ) ,
233+ ) . rejects . toThrow ( "must match models.providers.gpu-default.baseUrl" ) ;
234+ } ) ;
235+
180236 it ( "caps oversized local service idle stop timers" , async ( ) => {
181237 const setTimeoutSpy = vi . spyOn ( globalThis , "setTimeout" ) ;
182238 const port = await freePort ( ) ;
0 commit comments