@@ -42,6 +42,16 @@ async function withOllamaServer<T>(
4242 remote_host : "https://ollama.com" ,
4343 details : { } ,
4444 } ,
45+ {
46+ name : "tagged-only:cloud" ,
47+ size : 1 ,
48+ details : { } ,
49+ } ,
50+ {
51+ name : "tagged-only:120b-cloud" ,
52+ size : 1 ,
53+ details : { } ,
54+ } ,
4555 {
4656 name : "chat:small" ,
4757 size : 500 ,
@@ -204,6 +214,16 @@ describe("Ollama node host inference", () => {
204214 JSON . stringify ( { model : "remote:cloud" , prompt : "hello" } ) ,
205215 ) ,
206216 ) . rejects . toThrow ( "is not a local chat model" ) ;
217+ await expect (
218+ commandByName ( baseUrl , OLLAMA_CHAT_COMMAND ) . handle (
219+ JSON . stringify ( { model : "tagged-only:cloud" , prompt : "hello" } ) ,
220+ ) ,
221+ ) . rejects . toThrow ( "is not a local chat model" ) ;
222+ await expect (
223+ commandByName ( baseUrl , OLLAMA_CHAT_COMMAND ) . handle (
224+ JSON . stringify ( { model : "tagged-only:120b-cloud" , prompt : "hello" } ) ,
225+ ) ,
226+ ) . rejects . toThrow ( "is not a local chat model" ) ;
207227 await expect (
208228 commandByName ( baseUrl , OLLAMA_CHAT_COMMAND ) . handle (
209229 JSON . stringify ( { model : "embedding:latest" , prompt : "hello" } ) ,
@@ -237,6 +257,15 @@ describe("Ollama node host inference", () => {
237257} ) ;
238258
239259describe ( "node_inference agent tool" , ( ) => {
260+ it ( "uses a flat action enum supported by local model providers" , ( ) => {
261+ const tool = createOllamaNodeInferenceTool ( createTestPluginApi ( ) ) ;
262+ const action = ( tool . parameters as { properties : { action : unknown } } ) . properties . action ;
263+
264+ expect ( action ) . toMatchObject ( { type : "string" , enum : [ "discover" , "run" ] } ) ;
265+ expect ( action ) . not . toHaveProperty ( "anyOf" ) ;
266+ expect ( action ) . not . toHaveProperty ( "oneOf" ) ;
267+ } ) ;
268+
240269 it ( "discovers models through the connected node runtime" , async ( ) => {
241270 const invoke = vi . fn ( async ( ) => ( {
242271 payload : { provider : "ollama" , models : [ { name : "chat:small" , loaded : true } ] } ,
@@ -283,6 +312,83 @@ describe("node_inference agent tool", () => {
283312 } ) ;
284313 } ) ;
285314
315+ it ( "discovers only nodes authorized for local model discovery" , async ( ) => {
316+ const invoke = vi . fn ( async ( ) => ( {
317+ payload : { provider : "ollama" , models : [ { name : "chat:small" } ] } ,
318+ } ) ) ;
319+ const api = createTestPluginApi ( {
320+ runtime : {
321+ nodes : {
322+ list : async ( ) => ( {
323+ nodes : [
324+ {
325+ nodeId : "denied-node" ,
326+ connected : true ,
327+ commands : [ OLLAMA_MODELS_COMMAND , OLLAMA_CHAT_COMMAND ] ,
328+ invocableCommands : [ ] ,
329+ } ,
330+ {
331+ nodeId : "allowed-node" ,
332+ connected : true ,
333+ commands : [ OLLAMA_MODELS_COMMAND , OLLAMA_CHAT_COMMAND ] ,
334+ invocableCommands : [ OLLAMA_MODELS_COMMAND ] ,
335+ } ,
336+ ] ,
337+ } ) ,
338+ invoke,
339+ } ,
340+ } as never ,
341+ } ) ;
342+
343+ const result = await createOllamaNodeInferenceTool ( api ) . execute ( "call-discover" , {
344+ action : "discover" ,
345+ } ) ;
346+
347+ expect ( invoke ) . toHaveBeenCalledOnce ( ) ;
348+ expect ( invoke ) . toHaveBeenCalledWith ( expect . objectContaining ( { nodeId : "allowed-node" } ) ) ;
349+ expect ( result . details ) . toMatchObject ( { nodes : [ { nodeId : "allowed-node" , ok : true } ] } ) ;
350+ } ) ;
351+
352+ it ( "routes inference to the node authorized for model discovery and chat" , async ( ) => {
353+ const invoke = vi . fn ( async ( ) => ( {
354+ payload : { provider : "ollama" , model : "chat:small" , response : "done" } ,
355+ } ) ) ;
356+ const api = createTestPluginApi ( {
357+ runtime : {
358+ nodes : {
359+ list : async ( ) => ( {
360+ nodes : [
361+ {
362+ nodeId : "denied-node" ,
363+ connected : true ,
364+ commands : [ OLLAMA_MODELS_COMMAND , OLLAMA_CHAT_COMMAND ] ,
365+ invocableCommands : [ OLLAMA_MODELS_COMMAND ] ,
366+ } ,
367+ {
368+ nodeId : "allowed-node" ,
369+ connected : true ,
370+ commands : [ OLLAMA_MODELS_COMMAND , OLLAMA_CHAT_COMMAND ] ,
371+ invocableCommands : [ OLLAMA_MODELS_COMMAND , OLLAMA_CHAT_COMMAND ] ,
372+ } ,
373+ ] ,
374+ } ) ,
375+ invoke,
376+ } ,
377+ } as never ,
378+ } ) ;
379+
380+ await createOllamaNodeInferenceTool ( api ) . execute ( "call-authorized" , {
381+ action : "run" ,
382+ model : "chat:small" ,
383+ prompt : "answer fast" ,
384+ } ) ;
385+
386+ expect ( invoke ) . toHaveBeenCalledOnce ( ) ;
387+ expect ( invoke ) . toHaveBeenCalledWith (
388+ expect . objectContaining ( { nodeId : "allowed-node" , command : OLLAMA_CHAT_COMMAND } ) ,
389+ ) ;
390+ } ) ;
391+
286392 it ( "routes a run to the sole capable node" , async ( ) => {
287393 const invoke = vi . fn ( async ( ) => ( {
288394 payload : { provider : "ollama" , model : "chat:small" , response : "done" } ,
0 commit comments