Initial commit: RA-H Open Source Edition

Local-first knowledge management system with BYO API keys.

Features:
- 3-panel UI (Nodes | Focus | Helpers)
- SQLite + sqlite-vec for vector search
- Agent system (Easy/Hard mode orchestrators)
- Content extraction (YouTube, PDF, web)
- Integrate workflow for connection discovery
- Dimension system with auto-assignment

Tech stack:
- Next.js 15 + TypeScript + Tailwind CSS
- Anthropic (Claude) + OpenAI (GPT) via Vercel AI SDK

Setup:
  npm install && npm rebuild better-sqlite3
  scripts/dev/bootstrap-local.sh
  npm run dev

MIT License
This commit is contained in:
“BeeRad”
2025-12-15 16:14:28 +11:00
commit 733d1c3407
226 changed files with 46231 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
import { NextRequest, NextResponse } from 'next/server';
import { edgeService } from '@/services/database';
export const runtime = 'nodejs';
export async function GET() {
try {
const edges = await edgeService.getEdges();
return NextResponse.json({
success: true,
data: edges,
count: edges.length
});
} catch (error) {
console.error('Error fetching edges:', error);
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Failed to fetch edges'
}, { status: 500 });
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
// Validate required fields
if (!body.from_node_id || !body.to_node_id) {
return NextResponse.json({
success: false,
error: 'Missing required fields: from_node_id and to_node_id are required'
}, { status: 400 });
}
// Validate node IDs are numbers
if (isNaN(parseInt(body.from_node_id)) || isNaN(parseInt(body.to_node_id))) {
return NextResponse.json({
success: false,
error: 'Invalid node IDs: must be valid numbers'
}, { status: 400 });
}
// Set default source if not provided
if (!body.source) {
body.source = 'user';
}
// Validate source value
if (!['user', 'ai_similarity', 'helper_name'].includes(body.source)) {
return NextResponse.json({
success: false,
error: 'Invalid source: must be user, ai_similarity, or helper_name'
}, { status: 400 });
}
const fromId = parseInt(body.from_node_id);
const toId = parseInt(body.to_node_id);
// Idempotency: prevent duplicate edges between same pair
try {
const exists = await edgeService.edgeExists(fromId, toId);
if (exists) {
return NextResponse.json({
success: true,
data: { from_node_id: fromId, to_node_id: toId },
message: `Edge already exists between nodes ${fromId} and ${toId}`
}, { status: 200 });
}
} catch (e) {
// Non-fatal: continue with creation if existence check fails
console.warn('edgeExists check failed; proceeding to create:', e);
}
const edge = await edgeService.createEdge({
from_node_id: fromId,
to_node_id: toId,
context: body.context || {},
source: body.source
});
return NextResponse.json({
success: true,
data: edge,
message: `Edge created successfully between nodes ${edge.from_node_id} and ${edge.to_node_id}`
}, { status: 201 });
} catch (error) {
console.error('Error creating edge:', error);
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Failed to create edge'
}, { status: 500 });
}
}