Observer embryo, Maestro done
This commit is contained in:
+18
-4
@@ -11,7 +11,20 @@ export class AgentStore {
|
||||
return(this.storage.agentHashKey.replace(/\[UID\]/g, agentId))
|
||||
}
|
||||
|
||||
async exportSegment(agent, eventType) {
|
||||
async clearAll() {
|
||||
try {
|
||||
const ids = await this.cnx.redisSmembers(this.storage.agentsIndexKey)
|
||||
for(const id of ids) {
|
||||
await this.cnx.redisDel(this.agentHashKey(id))
|
||||
}
|
||||
await this.cnx.redisDel(this.storage.agentsIndexKey)
|
||||
if(this.debug) console.log(`[GPS] Cleared system agent store (${ids.length} agent(s))`)
|
||||
} catch(err) {
|
||||
console.error('[GPS] Failed to clear system agent store:', err)
|
||||
}
|
||||
}
|
||||
|
||||
async exportSegment(agent, eventType, simT = 0, simulationId = null) {
|
||||
try {
|
||||
const record = {
|
||||
eventType,
|
||||
@@ -20,7 +33,8 @@ export class AgentStore {
|
||||
vector: { ...agent.vector },
|
||||
since: agent.since,
|
||||
generation: agent.generation ?? 0,
|
||||
at: new Date().toISOString(),
|
||||
t: simT,
|
||||
simulationId,
|
||||
}
|
||||
await this.cnx.redisHset(this.agentHashKey(agent.id), 'segment', record)
|
||||
await this.cnx.redisSadd(this.storage.agentsIndexKey, agent.id)
|
||||
@@ -35,12 +49,12 @@ export class AgentStore {
|
||||
}
|
||||
}
|
||||
|
||||
async exportRemove(agentId) {
|
||||
async exportRemove(agentId, simT = 0) {
|
||||
try {
|
||||
const record = {
|
||||
eventType: 'remove',
|
||||
id: agentId,
|
||||
at: new Date().toISOString(),
|
||||
t: simT,
|
||||
}
|
||||
await this.cnx.redisDel(this.agentHashKey(agentId))
|
||||
await this.cnx.redisSrem(this.storage.agentsIndexKey, agentId)
|
||||
|
||||
Reference in New Issue
Block a user