@@ -1091,17 +1091,18 @@ test("GET /api/dsh-mneme/list projects per-memory heat only when heatEnabled=tru
10911091// panel can offer a dropdown over real models, and probe connectivity with a
10921092// minimal LLM call (same harness path the consolidation uses).
10931093
1094- function setupLlm ( llm , apiToken = "" ) {
1094+ function setupLlm ( llm , apiToken = "" , extraCtx = { } , config = null ) {
10951095 const store = createStore ( ":memory:" ) ;
10961096 const service = createService ( { store, mirror : null , config : { } } ) ;
10971097 const settings = createSettings ( store . db ) ;
10981098 const commands = { add : ( ) => { } , remove : ( ) => { } , list : ( ) => [ ] } ;
10991099 const routes = [ ] ;
11001100 const ctx = {
11011101 webServer : { register ( route ) { routes . push ( route ) ; return ( ) => { } ; } } ,
1102- llm
1102+ llm,
1103+ ...extraCtx
11031104 } ;
1104- const api = createApi ( ctx , service , settings , commands , undefined , undefined , apiToken ) ;
1105+ const api = createApi ( ctx , service , settings , commands , undefined , undefined , apiToken , config ) ;
11051106 return { routes } ;
11061107}
11071108
@@ -1139,9 +1140,9 @@ test("GET /api/dsh-mneme/llm-providers lists host providers with models, per-pro
11391140 assert . equal ( res . statusCode , 200 ) ;
11401141 const data = JSON . parse ( res . body ) ;
11411142 assert . equal ( data . providers . length , 2 ) ;
1142- const deepseek = data . providers . find ( ( p ) => p . id === "deepseek" ) ;
1143+ const deepseek = data . providers . find ( ( p ) => p . provider === "deepseek" ) ;
11431144 assert . deepEqual ( deepseek . models . map ( ( m ) => m . id ) , [ "deepseek-chat" , "deepseek-reasoner" ] ) ;
1144- const broken = data . providers . find ( ( p ) => p . id === "broken" ) ;
1145+ const broken = data . providers . find ( ( p ) => p . provider === "broken" ) ;
11451146 assert . deepEqual ( broken . models , [ ] , "a provider whose model list throws degrades to empty, not a hard fail" ) ;
11461147} ) ;
11471148
@@ -1163,7 +1164,8 @@ test("POST /api/dsh-mneme/test-model succeeds and reports reply + latency", asyn
11631164 const data = JSON . parse ( res . body ) ;
11641165 assert . equal ( data . ok , true ) ;
11651166 assert . equal ( data . reply , "ok" , "reply trimmed" ) ;
1166- assert . ok ( data . latencyMs >= 0 ) ;
1167+ assert . ok ( data . durationMs >= 0 ) ;
1168+ assert . equal ( data . modelId , "deepseek:deepseek-chat" , "modelId reports the probed route" ) ;
11671169 assert . equal ( MOCK_LLM . lastOptions . provider , "deepseek" ) ;
11681170 assert . equal ( MOCK_LLM . lastOptions . purpose , "dsh-mneme-connectivity-test" ) ;
11691171 assert . equal ( "reasoningEffort" in MOCK_LLM . lastOptions , false , "no effort configured -> field omitted" ) ;
@@ -1200,12 +1202,37 @@ test("POST /api/dsh-mneme/test-model reports thrown failure with 502", async ()
12001202 assert . match ( data . error , / U N S U P P O R T E D _ R E A S O N I N G _ E F F O R T / , "throw path surfaces the harness rejection" ) ;
12011203} ) ;
12021204
1205+ test ( "POST /api/dsh-mneme/test-model resolves empty body against the consolidation route" , async ( ) => {
1206+ // Empty provider/model = "test whatever consolidation uses now": the route
1207+ // falls back to agentDefaultModel (config dreamProvider/dreamModel absent),
1208+ // the probe runs against that model, and modelId reports what was tested.
1209+ const { routes } = setupLlm ( MOCK_LLM , "" , {
1210+ agentDefaultModel : { currentSelection : ( ) => ( { provider : "sel-provider" , model : "sel-model" } ) }
1211+ } ) ;
1212+ const route = routes . find ( ( r ) => r . path === "/api/dsh-mneme/test-model" ) ;
1213+ const res = new FakeRes ( ) ;
1214+ await route . handler ( req ( "/api/dsh-mneme/test-model" , "POST" , { } ) , res ) ;
1215+ assert . equal ( res . statusCode , 200 ) ;
1216+ const data = JSON . parse ( res . body ) ;
1217+ assert . equal ( data . ok , true ) ;
1218+ assert . equal ( data . modelId , "sel-provider:sel-model" , "probe ran against the resolved consolidation route" ) ;
1219+ assert . equal ( MOCK_LLM . lastOptions . provider , "sel-provider" ) ;
1220+ assert . equal ( MOCK_LLM . lastOptions . model , "sel-model" ) ;
1221+ } ) ;
1222+
12031223test ( "POST /api/dsh-mneme/test-model validates input and llm availability" , async ( ) => {
12041224 const { routes } = setupLlm ( MOCK_LLM ) ;
12051225 const route = routes . find ( ( r ) => r . path === "/api/dsh-mneme/test-model" ) ;
12061226 let res = new FakeRes ( ) ;
1227+ await route . handler ( req ( "/api/dsh-mneme/test-model" , "POST" , { provider : "deepseek" } ) , res ) ;
1228+ assert . equal ( res . statusCode , 400 , "partial input (provider without model) rejected" ) ;
1229+ assert . equal ( JSON . parse ( res . body ) . error , "missing-provider-or-model" ) ;
1230+
1231+ // empty body with no route (no agentDefaultModel, no config route) -> no-route
1232+ res = new FakeRes ( ) ;
12071233 await route . handler ( req ( "/api/dsh-mneme/test-model" , "POST" , { } ) , res ) ;
1208- assert . equal ( res . statusCode , 400 , "missing provider+model rejected" ) ;
1234+ assert . equal ( res . statusCode , 400 , "empty body with no resolvable route rejected" ) ;
1235+ assert . equal ( JSON . parse ( res . body ) . error , "no-route" ) ;
12091236
12101237 const { routes : routesNoLlm } = setup ( ) ;
12111238 const routeNoLlm = routesNoLlm . find ( ( r ) => r . path === "/api/dsh-mneme/test-model" ) ;
0 commit comments