🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ai-team): preserve memory creation timestamps
Rudy Celekli5a25f363c052
diff --git a/plugins/ruflo-ai-team/src/store.mjs b/plugins/ruflo-ai-team/src/store.mjsindex 616817555f..574c09730a 100644--- a/plugins/ruflo-ai-team/src/store.mjs+++ b/plugins/ruflo-ai-team/src/store.mjs@@ -45,8 +45,9 @@ export class InMemoryStore {async remember(tenantId, input, actor = '-') {const bucket = this.#bucket(tenantId); const id = input.key || `mem_${randomUUID()}`;const timestamp = now();+ const createdAt = bucket.memories.get(id)?.createdAt ?? timestamp;const value = { id, teamId: input.teamId, runId: input.runId || null, text: input.text, tags: input.tags || [], provenance: input.provenance || 'user', actorHash: actor,- contentHash: createHash('sha256').update(input.text).digest('hex'), safetyStatus: input.safetyStatus || 'accepted', embeddingModel: 'feature-hash-256', embeddingVersion: '1', createdAt: timestamp, updatedAt: timestamp };+ contentHash: createHash('sha256').update(input.text).digest('hex'), safetyStatus: input.safetyStatus || 'accepted', embeddingModel: 'feature-hash-256', embeddingVersion: '1', createdAt, updatedAt: timestamp };bucket.memories.set(id, value); this.#audit(bucket, actor, 'memory.remembered', id); return clone(value);}async listMemories(tenantId, { teamId } = {}) { return [...this.#bucket(tenantId).memories.values()].filter((x) => !teamId || x.teamId === teamId).map(clone); }@@ -88,7 +89,7 @@ export class FirestoreStore {async createTask(t,i,a='-') { const run=await this.#get(t,'runs',i.runId); if(!run||run.status==='complete')return null; const v={id:`task_${randomUUID()}`,runId:i.runId,title:i.title,description:i.description,assigneeRole:i.assigneeRole,status:'open',result:null,createdAt:now(),updatedAt:now()}; await this.#put(t,'tasks',v); await this.#audit(t,a,'task.created',v.id); return v; }async listTasks(t,runId) { const snap=await this.#tenant(t).collection('tasks').where('runId','==',runId).limit(200).get(); return snap.docs.map(d=>d.data()); }async updateTask(t,id,p,a='-') { const c=await this.#get(t,'tasks',id); if(!c||(await this.#get(t,'runs',c.runId))?.status==='complete')return null; const v={...c,...p,id,updatedAt:now()}; await this.#put(t,'tasks',v); await this.#audit(t,a,'task.updated',id); return v; }- async remember(t,i,a='-') { const timestamp=now(); const v={id:i.key||`mem_${randomUUID()}`,teamId:i.teamId,runId:i.runId||null,text:i.text,tags:i.tags||[],provenance:i.provenance||'user',actorHash:a,contentHash:createHash('sha256').update(i.text).digest('hex'),safetyStatus:i.safetyStatus||'accepted',embeddingModel:'feature-hash-256',embeddingVersion:'1',createdAt:timestamp,updatedAt:timestamp}; await this.#put(t,'memories',v); await this.#audit(t,a,'memory.remembered',v.id); return v; }+ async remember(t,i,a='-') { const timestamp=now(); const id=i.key||`mem_${randomUUID()}`; const previous=await this.#get(t,'memories',id); const v={id,teamId:i.teamId,runId:i.runId||null,text:i.text,tags:i.tags||[],provenance:i.provenance||'user',actorHash:a,contentHash:createHash('sha256').update(i.text).digest('hex'),safetyStatus:i.safetyStatus||'accepted',embeddingModel:'feature-hash-256',embeddingVersion:'1',createdAt:previous?.createdAt??timestamp,updatedAt:timestamp}; await this.#put(t,'memories',v); await this.#audit(t,a,'memory.remembered',v.id); return v; }async listMemories(t,{teamId}={}) { let query=this.#tenant(t).collection('memories'); if(teamId)query=query.where('teamId','==',teamId); const snap=await query.limit(1000).get(); return snap.docs.map(d=>d.data()); }async usage(t) { const [teams,runs,tasks,memories]=await Promise.all(['teams','runs','tasks','memories'].map(k=>this.#list(t,k))); return {teams:teams.length,runs:runs.length,tasks:tasks.length,memories:memories.length,limits:{teams:1,agentsPerTeam:3,monthlyTasks:100,runBudgetUnits:100}}; }async evidence(t,runId) { const run=await this.#get(t,'runs',runId); if(!run)return null; return {schema:'ruflo.ai-team.evidence.v1',generatedAt:now(),run,team:await this.#get(t,'teams',run.teamId),tasks:await this.listTasks(t,runId),audit:(await this.#list(t,'audit')).filter(x=>x.targetId===runId||x.targetId===run.teamId)}; }diff --git a/plugins/ruflo-ai-team/test/memory-creation-time.node.mjs b/plugins/ruflo-ai-team/test/memory-creation-time.node.mjsnew file mode 100644index 0000000000..03066022de--- /dev/null+++ b/plugins/ruflo-ai-team/test/memory-creation-time.node.mjs@@ -0,0 +1,16 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { setTimeout } from 'node:timers/promises';+import { InMemoryStore } from '../src/store.mjs';++test('updating a memory key preserves its original creation timestamp', async () => {+ const store = new InMemoryStore();+ const input = {teamId:'team', key:'note', text:'first'};+ const first = await store.remember('a', input);+ await setTimeout(10);+ const next = await store.remember('a', {...input,text:'updated'});+ assert.equal(next.createdAt, first.createdAt);+ assert.notEqual(next.updatedAt, first.updatedAt);+ assert.equal(next.text, 'updated');+ assert.equal((await store.listMemories('a')).length, 1);+});