Compare commits

..

1 Commits
1.4.3 ... 1.4.4

Author SHA1 Message Date
878a8794ee Rebuild graph edges on changes
All checks were successful
Publish Library / Build NPM Project (push) Successful in 46s
Publish Library / Tag Version (push) Successful in 19s
2026-08-04 17:05:58 -04:00
3 changed files with 6 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/ai-utils",
"version": "1.4.3",
"version": "1.4.4",
"description": "AI Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -273,8 +273,6 @@ ${a.system}`,
promise = (async () => {
let tools: AiTool[] = options.tools || this.ai.options.llm?.tools || [];
const prompts: string[] = [];
// `history` is the single source of truth from here on - mutated in place by
// this call AND by any nested/delegated agent calls sharing the same array
let history = options.history || [];
if(message) history.push({role: 'user', content: message, timestamp: Date.now()});
@@ -330,7 +328,8 @@ ${r.description}
${r.content}
`).join('\n---\n')}
` : ''}${listed.length ? `
Also relevant but not preloaded (use \`memory_recall\`): ${listed.map(r => r.name).join(', ')}
Additional relevant memories (use \`memory_recall\`):
${listed.map(r => r.name).join(', ')}
` : ''}`.trim());
}
if(mem.tool) tools.push(this.memoryManager.tools.read(mem.memory));
@@ -345,8 +344,6 @@ Also relevant but not preloaded (use \`memory_recall\`): ${listed.map(r => r.nam
if(aborted) throw Object.assign(new Error('Aborted'), {name: 'AbortError'});
prompts.unshift(options.system || this.ai.options.llm?.system || '');
// Message already appended to shared `history` above - pass '' so the provider
// doesn't push a duplicate user turn
request = this.models[m].ask('', {...options, tools, system: prompts.filter(Boolean).join('\n\n')});
let resp = await request;

View File

@@ -43,6 +43,7 @@ export class MemoryCache {
add(memory: Memory): void {
this.memories.push(memory);
rebuildGraph(this.memories);
this.rebuild();
}
@@ -53,6 +54,7 @@ export class MemoryCache {
} else {
this.memories.push(memory);
}
rebuildGraph(this.memories);
this.rebuild();
}
@@ -60,6 +62,7 @@ export class MemoryCache {
const idx = this.memories.findIndex(m => m.name === name);
if (idx !== -1) {
this.memories.splice(idx, 1);
rebuildGraph(this.memories);
this.rebuild();
}
}