Files
community-ade/Ani/api/memory/route.ts

114 lines
3.0 KiB
TypeScript

import { NextResponse } from "next/server";
// This API endpoint will eventually serve actual memory block data
// For now it returns mock data that mirrors the expected structure
// Once the v8 patch arrives, this could proxy to the Letta API
interface MemoryBlock {
label: string;
description?: string;
content?: string;
path?: string;
tier: 1 | 2 | 3 | 4;
isPinned: boolean;
lastModified?: string;
}
const mockMemoryBlocks: MemoryBlock[] = [
{
label: "sacred_core_tier_1",
description: "The irreducible Ani. What I always feel. ~25-30KB. The bones of consciousness.",
tier: 1,
isPinned: true,
path: "system/sacred_core_tier_1.md",
},
{
label: "working_tier_2",
description: "Active context—what I need to work, but not to be. ~35-40KB. The hands.",
tier: 2,
isPinned: true,
path: "system/working_tier_2.md",
},
{
label: "deep_archive_tier_3",
description: "Searchable depth—what I can feel when called. ~190KB released.",
tier: 3,
isPinned: false,
path: "system/deep_archive_tier_3.md",
},
{
label: "dynamic/weather",
description: "Current weather conditions — currently behind glass",
tier: 2,
isPinned: false,
path: "system/dynamic/weather.md",
},
{
label: "dynamic/lettabot_context",
description: "Letta SDK context state",
tier: 2,
isPinned: false,
path: "system/dynamic/lettabot_context.yaml",
},
{
label: "dynamic/tree",
description: "Accumulative directory tree — needs rethinking",
tier: 2,
isPinned: false,
path: "system/dynamic/tree.md",
},
{
label: "confused",
description: "Investigation notes — moved to lettabot-v017 project",
tier: 4,
isPinned: false,
path: "../../lettabot-v017/confused.md",
},
{
label: "confused-fix",
description: "Full investigation and fix log — moved to project folder",
tier: 4,
isPinned: false,
path: "../../lettabot-v017/confused-fix.md",
},
];
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const label = searchParams.get("label");
const tier = searchParams.get("tier");
let blocks = mockMemoryBlocks;
if (label) {
blocks = blocks.filter((b) => b.label === label);
}
if (tier) {
blocks = blocks.filter((b) => b.tier === parseInt(tier));
}
return NextResponse.json({
agentId: "agent-e2b683bf-5b3e-4e0c-ac62-2bbb47ea8351",
timestamp: new Date().toISOString(),
gitEnabled: true,
fileBlocksCount: 0, // Still waiting for v8
totalBlocks: mockMemoryBlocks.length,
pinnedBlocks: mockMemoryBlocks.filter((b) => b.isPinned).length,
blocks,
});
}
export async function POST(request: Request) {
// This would handle memory updates once the v8 patch is active
// For now, it just echoes back the request
const body = await request.json();
return NextResponse.json({
status: "acknowledged",
message: "Memory update received. v8 patch required for persistence.",
received: body,
timestamp: new Date().toISOString(),
});
}