KF console API
This commit is contained in:
@@ -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>`)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user