Merge branch 'feat/memory-skill-injection-v2' into release/v3.4.2

# Conflicts:
#	src/app/(dashboard)/dashboard/settings/page.tsx
This commit is contained in:
diegosouzapw
2026-04-01 02:20:40 -03:00
40 changed files with 3792 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
import { NextResponse } from "next/server";
import { deleteMemory, getMemory } from "@/lib/memory/store";
export async function DELETE(
request: Request,
props: { params: Promise<{ id: string }> }
) {
try {
const { id } = await props.params;
const success = await deleteMemory(id);
if (!success) {
return NextResponse.json({ error: "Memory not found" }, { status: 404 });
}
return NextResponse.json({ success: true });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}
export async function GET(
request: Request,
props: { params: Promise<{ id: string }> }
) {
try {
const { id } = await props.params;
const memory = await getMemory(id);
if (!memory) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
return NextResponse.json({ memory });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}

View File

@@ -0,0 +1,36 @@
import { NextResponse } from "next/server";
import { listMemories, createMemory } from "@/lib/memory/store";
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const apiKeyId = searchParams.get("apiKeyId") || undefined;
const type = searchParams.get("type") as any || undefined;
const sessionId = searchParams.get("sessionId") || undefined;
const limitParams = searchParams.get("limit");
const offsetParams = searchParams.get("offset");
const memories = await listMemories({
apiKeyId,
type,
sessionId,
limit: limitParams ? parseInt(limitParams, 10) : undefined,
offset: offsetParams ? parseInt(offsetParams, 10) : undefined,
});
return NextResponse.json({ memories });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}
export async function POST(request: Request) {
try {
const body = await request.json();
const memoryId = await createMemory(body);
return NextResponse.json({ success: true, id: memoryId });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 400 });
}
}

View File

@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { getDbInstance } from "@/lib/db/core";
import { skillRegistry } from "@/lib/skills/registry";
export async function PUT(
request: Request,
props: { params: Promise<{ id: string }> }
) {
try {
const { id } = await props.params;
const body = await request.json();
if (typeof body.enabled !== "boolean") {
return NextResponse.json({ error: "Invalid payload, missing enabled boolean" }, { status: 400 });
}
const db = getDbInstance();
db.prepare("UPDATE skills SET enabled = ? WHERE id = ?").run(
body.enabled ? 1 : 0,
id
);
await skillRegistry.loadFromDatabase();
return NextResponse.json({ success: true, enabled: body.enabled });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}

View File

@@ -0,0 +1,12 @@
import { NextResponse } from "next/server";
import { skillExecutor } from "@/lib/skills/executor";
export async function GET() {
try {
const executions = skillExecutor.listExecutions();
return NextResponse.json({ executions });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}

View File

@@ -0,0 +1,13 @@
import { NextResponse } from "next/server";
import { skillRegistry } from "@/lib/skills/registry";
export async function GET() {
try {
await skillRegistry.loadFromDatabase();
const skills = skillRegistry.list();
return NextResponse.json({ skills });
} catch (err: unknown) {
const error = err instanceof Error ? err.message : String(err);
return NextResponse.json({ error }, { status: 500 });
}
}