promp and memry

This commit is contained in:
legop3
2026-05-04 01:33:09 -04:00
parent d887997a5a
commit 26d59b6650
10 changed files with 205 additions and 36 deletions
@@ -1,5 +1,8 @@
const memoryRead = require('./memoryRead');
const memoryWrite = require('./memoryWrite');
const memoryNoteUpsert = require('./memoryNoteUpsert');
const memoryNoteDelete = require('./memoryNoteDelete');
const memoryEventAdd = require('./memoryEventAdd');
const liftUp = require('./liftUp');
const liftDown = require('./liftDown');
const neatoStart = require('./neatoStart');
@@ -12,6 +15,9 @@ const buttonBoxAddCount = require('./buttonBoxAddCount');
const TOOL_DEFINITIONS = [
memoryRead,
memoryWrite,
memoryNoteUpsert,
memoryNoteDelete,
memoryEventAdd,
liftUp,
liftDown,
neatoStart,
@@ -0,0 +1,34 @@
module.exports = {
id: 'memory_event_add',
signature: 'memory_event_add(text, tags?)',
description: 'Append a short recent-event memory with optional tags.',
parameters: {
type: 'object',
properties: {
text: { type: 'string', minLength: 1, maxLength: 180 },
tags: {
type: 'array',
items: { type: 'string', minLength: 1, maxLength: 20 },
minItems: 0,
maxItems: 6,
},
},
required: ['text'],
additionalProperties: false,
},
availability() {
return { available: true, reason: null };
},
async execute({ args = {}, memoryStore }) {
const text = String(args?.text || '').trim().slice(0, 180);
if (!text) throw new Error('memory_event_add requires args.text');
const tags = Array.isArray(args?.tags)
? args.tags.map((tag) => String(tag || '').trim().toLowerCase().slice(0, 20)).filter(Boolean).slice(0, 6)
: [];
const next = memoryStore && typeof memoryStore === 'object' ? { ...memoryStore } : {};
const events = Array.isArray(next.events) ? [...next.events] : [];
events.push({ at: Date.now(), text, tags });
next.events = events.slice(-20);
return { ok: true, memory: next };
},
};
@@ -0,0 +1,25 @@
module.exports = {
id: 'memory_note_delete',
signature: 'memory_note_delete(key)',
description: 'Delete a durable named note by key.',
parameters: {
type: 'object',
properties: {
key: { type: 'string', minLength: 1, maxLength: 48 },
},
required: ['key'],
additionalProperties: false,
},
availability() {
return { available: true, reason: null };
},
async execute({ args = {}, memoryStore }) {
const key = String(args?.key || '').trim().toLowerCase().replace(/[^a-z0-9_\-]/g, '_').slice(0, 48);
if (!key) throw new Error('memory_note_delete requires args.key');
const next = memoryStore && typeof memoryStore === 'object' ? { ...memoryStore } : {};
const notes = next.notes && typeof next.notes === 'object' && !Array.isArray(next.notes) ? { ...next.notes } : {};
delete notes[key];
next.notes = notes;
return { ok: true, memory: next, key };
},
};
@@ -0,0 +1,28 @@
module.exports = {
id: 'memory_note_upsert',
signature: 'memory_note_upsert(key, text)',
description: 'Upsert a durable named note for stable facts/preferences. Key is short snake_case.',
parameters: {
type: 'object',
properties: {
key: { type: 'string', minLength: 1, maxLength: 48 },
text: { type: 'string', minLength: 1, maxLength: 220 },
},
required: ['key', 'text'],
additionalProperties: false,
},
availability() {
return { available: true, reason: null };
},
async execute({ args = {}, memoryStore }) {
const key = String(args?.key || '').trim().toLowerCase().replace(/[^a-z0-9_\-]/g, '_').slice(0, 48);
const text = String(args?.text || '').trim().slice(0, 220);
if (!key) throw new Error('memory_note_upsert requires args.key');
if (!text) throw new Error('memory_note_upsert requires args.text');
const next = memoryStore && typeof memoryStore === 'object' ? { ...memoryStore } : {};
const notes = next.notes && typeof next.notes === 'object' && !Array.isArray(next.notes) ? { ...next.notes } : {};
notes[key] = text;
next.notes = notes;
return { ok: true, memory: next, key };
},
};
@@ -1,7 +1,7 @@
module.exports = {
id: 'memory_read',
signature: 'memory_read()',
description: 'Read the Overseer persistent 3-slot memory.',
description: 'Read full persistent memory (slots, notes, recent events).',
parameters: {
type: 'object',
properties: {},
@@ -11,6 +11,6 @@ module.exports = {
return { available: true, reason: null };
},
async execute({ memoryStore }) {
return { ok: true, slots: memoryStore || ['', '', ''] };
return { ok: true, memory: memoryStore };
},
};
@@ -1,7 +1,7 @@
module.exports = {
id: 'memory_write',
signature: 'memory_write(slot, text)',
description: 'Write one of 3 Overseer memory slots.',
description: 'Write one of 3 scratchpad slots for short-term reminders.',
parameters: {
type: 'object',
properties: {
@@ -19,9 +19,11 @@ module.exports = {
if (!slot) throw new Error('memory_write requires args.slot 1..3');
const text = String(args?.text || '').trim();
if (!text) throw new Error('memory_write requires args.text');
const next = Array.isArray(memoryStore) ? [...memoryStore] : ['', '', ''];
while (next.length < 3) next.push('');
next[slot - 1] = text.slice(0, 180);
return { ok: true, slots: next };
const next = memoryStore && typeof memoryStore === 'object' ? { ...memoryStore } : {};
const slots = Array.isArray(next.slots) ? [...next.slots] : ['', '', ''];
while (slots.length < 3) slots.push('');
slots[slot - 1] = text.slice(0, 180);
next.slots = slots.slice(0, 3);
return { ok: true, memory: next };
},
};