KF console API

This commit is contained in:
STEINNI
2025-12-06 21:09:09 +00:00
parent c1d0a16cf3
commit 122861dbee
5 changed files with 43 additions and 34 deletions
+15 -7
View File
@@ -38,20 +38,27 @@ app.helpers.kfConsole = {
createAgent: async (type, properties) => {
if(Array.from(this.outputs.agentsSelector.options).find(item => item.value==type)){
const defaultValues = await this.models.agents.getDefaultProps(type)
console.log('==deflt===>', defaultValues,)
return(await this.newAgent(type, { ...defaultValues, ...properties })) //TODO: deepMerge
} else {
throw(`Invalid agent type: ${type}`)
}
},
removeAgent: (aid) => {
removeAgent: async (aid) => {
if(!Object.keys(this.kfArena.agents).includes(aid)) throw(`Agent ${aid} not on scene !`)
this.kfArena.removeAgent(aid)
},
updateAgent: async (aid, properties) => {
},
updateAgent: (aid, properties) => {
selectAgent: async (aid) => {
if(!Object.keys(this.kfArena.agents).includes(aid)) throw(`Agent ${aid} not on scene !`)
this.onclickAgent(this.kfArena.scene.getObjectByName(aid))
},
listagentTypes: () => {
listAgentTypes: async () => {
return(this.agentTypes)
},
listAgentsOnScene: async () => {
return(this.kfArena.agents)
},
}
try {
@@ -81,7 +88,8 @@ app.helpers.kfConsole = {
+'</div>'
)
} catch (err) {
return(`<div class="error">${err.name}: ${err.message}</div>`)
const msg = (err && err.message) ? err.message : String(err)
return(`<div class="error">${(err && err.name) ? err.name +': ': ''}${(err && err.message) ? err.message : String(err)}</div>`)
}
},
}