feat: port holistic node refinement contract

This commit is contained in:
“BeeRad”
2026-04-11 21:37:52 +10:00
parent 35f9ecf89c
commit 3ae46245ec
119 changed files with 6596 additions and 10982 deletions
@@ -1,62 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSQLiteClient } from '@/services/database/sqlite-client';
export interface DimensionContext {
name: string;
description: string | null;
isPriority: boolean;
nodeCount: number;
}
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ name: string }> }
) {
try {
const { name } = await params;
const decodedName = decodeURIComponent(name);
const db = getSQLiteClient();
// Get dimension metadata
const dimension = db.query<{
name: string;
description: string | null;
is_priority: number;
}>(
'SELECT name, description, is_priority FROM dimensions WHERE name = ?',
[decodedName]
).rows[0];
if (!dimension) {
return NextResponse.json(
{ success: false, error: 'Dimension not found' },
{ status: 404 }
);
}
// Count nodes in this dimension (via node_dimensions join table)
const countResult = db.query<{ count: number }>(
`SELECT COUNT(DISTINCT node_id) as count FROM node_dimensions WHERE dimension = ?`,
[decodedName]
).rows[0];
const context: DimensionContext = {
name: dimension.name,
description: dimension.description,
isPriority: false,
nodeCount: countResult?.count || 0,
};
return NextResponse.json({
success: true,
data: context,
});
} catch (error) {
console.error('Error fetching dimension context:', error);
return NextResponse.json(
{ success: false, error: 'Failed to fetch dimension context' },
{ status: 500 }
);
}
}
-76
View File
@@ -1,76 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSQLiteClient } from '@/services/database/sqlite-client';
export const runtime = 'nodejs';
export async function GET() {
try {
return getPopularDimensionsSQLite();
} catch (error) {
console.error('Error fetching popular dimensions:', error);
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Failed to fetch popular dimensions'
}, { status: 500 });
}
}
// PostgreSQL path removed in SQLite-only consolidation
async function getPopularDimensionsSQLite() {
const sqlite = getSQLiteClient();
const result = sqlite.query(`
WITH dimension_counts AS (
SELECT nd.dimension, COUNT(*) AS count
FROM node_dimensions nd
GROUP BY nd.dimension
)
SELECT d.name AS dimension,
COALESCE(dc.count, 0) AS count,
d.description
FROM dimensions d
LEFT JOIN dimension_counts dc ON dc.dimension = d.name
ORDER BY LOWER(d.name) ASC
`);
return NextResponse.json({
success: true,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: result.rows.map((row: any) => ({
dimension: row.dimension,
count: Number(row.count),
isPriority: false,
description: row.description || null
}))
});
}
export async function POST(request: NextRequest) {
try {
const { dimension } = await request.json();
if (!dimension || typeof dimension !== 'string') {
return NextResponse.json({
success: false,
error: 'Dimension name is required'
}, { status: 400 });
}
return NextResponse.json({
success: true,
data: {
dimension,
is_priority: false
},
message: 'Priority dimensions are no longer part of the product model.'
});
} catch (error) {
console.error('Error toggling dimension priority:', error);
return NextResponse.json({
success: false,
error: 'Internal server error'
}, { status: 500 });
}
}
-347
View File
@@ -1,347 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSQLiteClient } from '@/services/database/sqlite-client';
import { eventBroadcaster } from '@/services/events';
import { normalizeDimensionName, validateDimensionDescription } from '@/services/database/quality';
export const runtime = 'nodejs';
export async function GET() {
try {
const sqlite = getSQLiteClient();
// Get all dimensions with their counts
const result = sqlite.query(`
WITH dimension_counts AS (
SELECT nd.dimension, COUNT(*) AS count
FROM node_dimensions nd
GROUP BY nd.dimension
)
SELECT
d.name AS dimension,
d.description,
d.icon,
COALESCE(dc.count, 0) AS count
FROM dimensions d
LEFT JOIN dimension_counts dc ON dc.dimension = d.name
ORDER BY d.name ASC
`);
return NextResponse.json({
success: true,
data: result.rows.map((row: any) => ({
dimension: row.dimension,
description: row.description,
icon: row.icon || null,
isPriority: false,
count: Number(row.count)
}))
});
} catch (error) {
console.error('Error fetching dimensions:', error);
return NextResponse.json({
success: false,
error: 'Failed to fetch dimensions'
}, { status: 500 });
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const rawName = typeof body?.name === 'string' ? normalizeDimensionName(body.name) : '';
const description = typeof body?.description === 'string' ? body.description.trim() : null;
const icon = typeof body?.icon === 'string' ? body.icon.trim() || null : null;
if (!rawName) {
return NextResponse.json({
success: false,
error: 'Dimension name is required'
}, { status: 400 });
}
const descriptionError = description !== null
? validateDimensionDescription(description)
: null;
if (descriptionError) {
return NextResponse.json({
success: false,
error: descriptionError
}, { status: 400 });
}
const sqlite = getSQLiteClient();
const result = sqlite.query(`
INSERT INTO dimensions(name, description, icon, is_priority, updated_at)
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
ON CONFLICT(name) DO UPDATE SET
description = COALESCE(?, description),
icon = COALESCE(?, icon),
updated_at = CURRENT_TIMESTAMP
RETURNING name, description, icon, is_priority
`, [rawName, description, icon, 0, description, icon]);
if (result.rows.length === 0) {
throw new Error('Failed to create dimension');
}
const row = result.rows[0];
const dimension = row.name as string;
const descriptionValue = row.description as string | null;
const iconValue = (row.icon as string | null) || null;
eventBroadcaster.broadcast({
type: 'DIMENSION_UPDATED',
data: { dimension, isPriority: false, description: descriptionValue, icon: iconValue, count: 0 }
});
return NextResponse.json({
success: true,
data: {
dimension,
description: descriptionValue,
icon: iconValue,
isPriority: false
}
});
} catch (error) {
console.error('Error creating dimension:', error);
return NextResponse.json({
success: false,
error: 'Failed to create dimension'
}, { status: 500 });
}
}
export async function PUT(request: NextRequest) {
try {
const body = await request.json();
const currentName = typeof body?.currentName === 'string' ? normalizeDimensionName(body.currentName) : '';
const newName = typeof body?.newName === 'string' ? normalizeDimensionName(body.newName) : '';
const name = typeof body?.name === 'string' ? normalizeDimensionName(body.name) : '';
const description = typeof body?.description === 'string' ? body.description.trim() : '';
const icon = body?.icon !== undefined ? (typeof body.icon === 'string' ? body.icon.trim() || null : null) : undefined;
// Handle dimension name change
if (currentName && newName && currentName !== newName) {
if (!newName) {
return NextResponse.json({
success: false,
error: 'New dimension name is required'
}, { status: 400 });
}
const sqlite = getSQLiteClient();
// Check if new name already exists
const existingCheck = sqlite.query(`
SELECT name FROM dimensions WHERE name = ?
`, [newName]);
if (existingCheck.rows.length > 0) {
return NextResponse.json({
success: false,
error: 'A dimension with this name already exists'
}, { status: 400 });
}
// Update dimension name in transaction (also handle description and isPriority if provided)
const updateResult = sqlite.transaction(() => {
// Build update query with optional fields
const updates: string[] = ['name = ?', 'updated_at = CURRENT_TIMESTAMP'];
const values: any[] = [newName];
if (description !== '') {
updates.push('description = ?');
values.push(description || null);
}
if (icon !== undefined) {
updates.push('icon = ?');
values.push(icon);
}
values.push(currentName);
const dimUpdate = sqlite.prepare(`
UPDATE dimensions
SET ${updates.join(', ')}
WHERE name = ?
`).run(...values);
// Update node_dimensions table
const nodeDimUpdate = sqlite.prepare(`
UPDATE node_dimensions
SET dimension = ?
WHERE dimension = ?
`).run(newName, currentName);
return {
dimensionUpdated: dimUpdate.changes > 0,
nodeLinksUpdated: nodeDimUpdate.changes
};
});
if (!updateResult.dimensionUpdated) {
return NextResponse.json({
success: false,
error: 'Dimension not found'
}, { status: 404 });
}
eventBroadcaster.broadcast({
type: 'DIMENSION_UPDATED',
data: {
dimension: newName,
previousName: currentName,
description: description || undefined,
isPriority: false,
renamed: true
}
});
return NextResponse.json({
success: true,
data: {
dimension: newName,
previousName: currentName,
description: description || undefined,
isPriority: false,
nodeLinksUpdated: updateResult.nodeLinksUpdated
}
});
}
// Handle description and/or isPriority update (existing functionality)
const targetName = name || currentName;
if (!targetName) {
return NextResponse.json({
success: false,
error: 'Dimension name is required'
}, { status: 400 });
}
if (description) {
const descriptionError = validateDimensionDescription(description);
if (descriptionError) {
return NextResponse.json({
success: false,
error: descriptionError
}, { status: 400 });
}
}
if (description !== '' || icon !== undefined) {
const sqlite = getSQLiteClient();
// Build update query
const updates: string[] = ['updated_at = CURRENT_TIMESTAMP'];
const values: any[] = [];
if (description !== '') {
updates.push('description = ?');
values.push(description || null);
}
if (icon !== undefined) {
updates.push('icon = ?');
values.push(icon);
}
values.push(targetName);
const updateResult = sqlite.prepare(`
UPDATE dimensions
SET ${updates.join(', ')}
WHERE name = ?
`).run(...values);
if (updateResult.changes === 0) {
return NextResponse.json({
success: false,
error: 'Dimension not found'
}, { status: 404 });
}
} else {
return NextResponse.json({
success: false,
error: 'At least one update field (description, icon, or newName) must be provided'
}, { status: 400 });
}
eventBroadcaster.broadcast({
type: 'DIMENSION_UPDATED',
data: {
dimension: targetName,
description: description !== '' ? description : undefined,
icon: icon !== undefined ? icon : undefined,
isPriority: false
}
});
return NextResponse.json({
success: true,
data: {
dimension: targetName,
description: description !== '' ? description : undefined,
icon: icon !== undefined ? icon : undefined,
isPriority: false
}
});
} catch (error) {
console.error('Error updating dimension:', error);
return NextResponse.json({
success: false,
error: 'Failed to update dimension'
}, { status: 500 });
}
}
export async function DELETE(request: NextRequest) {
try {
const dimension = (request.nextUrl.searchParams.get('name') || '').trim();
if (!dimension) {
return NextResponse.json({
success: false,
error: 'Dimension name is required'
}, { status: 400 });
}
const sqlite = getSQLiteClient();
const removal = sqlite.transaction(() => {
const nodeDimStmt = sqlite.prepare('DELETE FROM node_dimensions WHERE dimension = ?');
const dimStmt = sqlite.prepare('DELETE FROM dimensions WHERE name = ?');
const removedLinks = nodeDimStmt.run(dimension).changes ?? 0;
const removedRow = dimStmt.run(dimension).changes ?? 0;
return {
removedLinks,
removedRow
};
});
if (!removal.removedLinks && !removal.removedRow) {
return NextResponse.json({
success: false,
error: 'Dimension not found'
}, { status: 404 });
}
eventBroadcaster.broadcast({
type: 'DIMENSION_UPDATED',
data: { dimension, deleted: true }
});
return NextResponse.json({
success: true,
data: {
dimension,
deleted: true
}
});
} catch (error) {
console.error('Error deleting dimension:', error);
return NextResponse.json({
success: false,
error: 'Failed to delete dimension'
}, { status: 500 });
}
}
-51
View File
@@ -1,51 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSQLiteClient } from '@/services/database/sqlite-client';
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
try {
const searchParams = request.nextUrl.searchParams;
const query = searchParams.get('q') || '';
if (!query.trim()) {
return NextResponse.json({
success: false,
error: 'Search query is required'
}, { status: 400 });
}
return searchDimensionsSQLite(query);
} catch (error) {
console.error('Error searching dimensions:', error);
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Failed to search dimensions'
}, { status: 500 });
}
}
// PostgreSQL path removed in SQLite-only consolidation
async function searchDimensionsSQLite(query: string) {
const sqlite = getSQLiteClient();
const result = sqlite.query(`
SELECT nd.dimension, COUNT(*) AS count
FROM node_dimensions nd
WHERE LOWER(nd.dimension) LIKE LOWER(?)
GROUP BY nd.dimension
ORDER BY count DESC, nd.dimension ASC
LIMIT 20
`, [`%${query}%`]);
return NextResponse.json({
success: true,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: result.rows.map((row: any) => ({
dimension: row.dimension,
count: Number(row.count)
}))
});
}
+472 -444
View File
File diff suppressed because it is too large Load Diff
@@ -4,7 +4,14 @@ import { generateDescription } from '@/services/database/descriptionService';
export const runtime = 'nodejs';
type NodeMetadata = { source?: string; channel_name?: string; author?: string; site_name?: string; type?: string } & Record<string, unknown>;
type NodeMetadata = {
source?: string;
channel_name?: string;
author?: string;
site_name?: string;
type?: string;
source_metadata?: Record<string, unknown>;
} & Record<string, unknown>;
function parseMetadata(raw: unknown): NodeMetadata | undefined {
if (!raw) return undefined;
@@ -27,9 +34,14 @@ async function enrichYoutubeMetadataIfMissing(link: string, metadata: NodeMetada
if (!url.includes('youtube.com') && !url.includes('youtu.be')) return metadata;
const existing = metadata || {};
const existingSourceMetadata = typeof existing.source_metadata === 'object' && existing.source_metadata
? existing.source_metadata
: {};
const hasCreatorHint = Boolean(
(typeof existing.author === 'string' && existing.author.trim()) ||
(typeof existing.channel_name === 'string' && existing.channel_name.trim())
(typeof existing.channel_name === 'string' && existing.channel_name.trim()) ||
(typeof existingSourceMetadata.author === 'string' && existingSourceMetadata.author.trim()) ||
(typeof existingSourceMetadata.channel_name === 'string' && existingSourceMetadata.channel_name.trim())
);
if (hasCreatorHint) return existing;
@@ -44,9 +56,20 @@ async function enrichYoutubeMetadataIfMissing(link: string, metadata: NodeMetada
return {
...existing,
source: typeof existing.source === 'string' && existing.source.trim().length > 0 ? existing.source : 'youtube',
channel_name: typeof existing.channel_name === 'string' && existing.channel_name.trim().length > 0 ? existing.channel_name : authorName,
site_name: typeof existing.site_name === 'string' && existing.site_name.trim().length > 0 ? existing.site_name : (providerName || 'YouTube'),
type: typeof existing.type === 'string' && existing.type.trim().length > 0 ? existing.type : 'youtube',
source_metadata: {
...existingSourceMetadata,
channel_name: typeof existing.channel_name === 'string' && existing.channel_name.trim().length > 0
? existing.channel_name
: (typeof existingSourceMetadata.channel_name === 'string' && existingSourceMetadata.channel_name.trim().length > 0
? existingSourceMetadata.channel_name
: authorName),
site_name: typeof existing.site_name === 'string' && existing.site_name.trim().length > 0
? existing.site_name
: (typeof existingSourceMetadata.site_name === 'string' && existingSourceMetadata.site_name.trim().length > 0
? existingSourceMetadata.site_name
: (providerName || 'YouTube')),
},
};
} catch {
return existing;
@@ -88,8 +111,6 @@ export async function POST(
source: node.source || node.description || undefined,
link: node.link || undefined,
metadata: enrichedMetadata,
dimensions: node.dimensions || []
});
// Update the node with the new description
+15 -20
View File
@@ -2,8 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { contextService, nodeService } from '@/services/database';
import { autoEmbedQueue } from '@/services/embedding/autoEmbedQueue';
import { hasSufficientContent } from '@/services/embedding/constants';
import { coerceDescriptionForStorage, normalizeDimensions } from '@/services/database/quality';
import { formatUnknownDimensionsError, getUnknownDimensions } from '@/services/database/dimensionValidation';
import { coerceDescriptionForStorage } from '@/services/database/quality';
import { normalizeNodeLink } from '@/utils/nodeLink';
import { mergeNodeMetadata } from '@/services/nodes/metadata';
@@ -94,26 +93,26 @@ export async function PUT(
});
}
if (Array.isArray(body.dimensions)) {
updates.dimensions = normalizeDimensions(body.dimensions, 5);
const unknownDimensions = getUnknownDimensions(updates.dimensions as string[]);
if (unknownDimensions.length > 0) {
return NextResponse.json({
success: false,
error: formatUnknownDimensionsError(unknownDimensions)
}, { status: 400 });
}
}
delete updates.notes;
delete updates.chunk;
if (Object.prototype.hasOwnProperty.call(body, 'context_id') || Object.prototype.hasOwnProperty.call(body, 'context_name')) {
if (body.metadata !== undefined) {
updates.metadata = mergeNodeMetadata(existingNode.metadata, body.metadata);
}
if (Object.prototype.hasOwnProperty.call(body, 'context_name')) {
return NextResponse.json({
success: false,
error: 'context_name is only supported on node creation. Use context_id for updates.'
}, { status: 400 });
}
if (Object.prototype.hasOwnProperty.call(body, 'context_id')) {
try {
updates.context_id = await contextService.resolveContextId({
const resolvedContextId = await contextService.resolveContextId({
context_id: body.context_id,
context_name: body.context_name,
});
updates.context_id = resolvedContextId;
} catch (error) {
return NextResponse.json({
success: false,
@@ -122,10 +121,6 @@ export async function PUT(
}
}
if (body.metadata !== undefined) {
updates.metadata = mergeNodeMetadata(existingNode.metadata, body.metadata);
}
const incomingSource = typeof body.source === 'string' ? body.source : undefined;
const existingSource = existingNode.source ?? '';
+14 -54
View File
@@ -4,11 +4,9 @@ import { Node, NodeFilters } from '@/types/database';
import { autoEmbedQueue } from '@/services/embedding/autoEmbedQueue';
import { generateDescription } from '@/services/database/descriptionService';
import { scheduleAutoEdgeCreation } from '@/services/agents/autoEdge';
import { coerceDescriptionForStorage, normalizeDimensions } from '@/services/database/quality';
import { formatUnknownDimensionsError, getUnknownDimensions } from '@/services/database/dimensionValidation';
import { coerceDescriptionForStorage } from '@/services/database/quality';
import { normalizeNodeLink } from '@/utils/nodeLink';
import { buildCanonicalNodeMetadata } from '@/services/nodes/metadata';
import { inferBestContextIdForNode } from '@/services/context/contextAssignment';
export const runtime = 'nodejs';
@@ -30,18 +28,6 @@ export async function GET(request: NextRequest) {
}
}
// Handle dimensions parameter (comma-separated)
const dimensionsParam = searchParams.get('dimensions');
if (dimensionsParam) {
filters.dimensions = dimensionsParam.split(',').map(dim => dim.trim()).filter(Boolean);
}
// Handle dimensionsMatch parameter (any|all)
const dimensionsMatchParam = searchParams.get('dimensionsMatch');
if (dimensionsMatchParam === 'all') {
filters.dimensionsMatch = 'all';
}
// Handle sortBy parameter (sortBy=edges|updated|created)
const sortByParam = searchParams.get('sortBy');
if (sortByParam === 'edges' || sortByParam === 'updated' || sortByParam === 'created' || sortByParam === 'event_date') {
@@ -115,16 +101,6 @@ export async function POST(request: NextRequest) {
}
const eventDate = typeof body.event_date === 'string' ? body.event_date : null;
// Process provided dimensions first (needed for description generation)
const trimmedProvidedDimensions = normalizeDimensions(body.dimensions, 5);
const unknownDimensions = getUnknownDimensions(trimmedProvidedDimensions);
if (unknownDimensions.length > 0) {
return NextResponse.json({
success: false,
error: formatUnknownDimensionsError(unknownDimensions)
}, { status: 400 });
}
// Use provided description if present, otherwise auto-generate
const isUserSuppliedDescription = typeof body.description === 'string' && body.description.trim().length > 0;
let nodeDescription: string | undefined = isUserSuppliedDescription
@@ -138,7 +114,6 @@ export async function POST(request: NextRequest) {
source: rawSource?.slice(0, 2000) || undefined,
link: normalizedLink || undefined,
metadata: body.metadata,
dimensions: trimmedProvidedDimensions
});
} catch (error) {
console.error('Error generating description:', error);
@@ -160,8 +135,6 @@ export async function POST(request: NextRequest) {
console.warn(`[DescriptionQuality] Weak description for node "${body.title}": "${finalDescription}"`);
}
// Use only provided dimensions (no auto-assignment)
const finalDimensions = trimmedProvidedDimensions;
const sourceToStore = rawSource || [body.title, nodeDescription].filter(Boolean).join('\n\n').trim() || null;
let chunkStatus: Node['chunk_status'];
@@ -169,6 +142,13 @@ export async function POST(request: NextRequest) {
chunkStatus = 'not_chunked';
}
const inferredType =
typeof body.metadata?.type === 'string'
? body.metadata.type
: typeof body.metadata?.source === 'string'
? body.metadata.source
: undefined;
let resolvedContextId: number | null | undefined;
try {
resolvedContextId = await contextService.resolveContextId({
@@ -176,25 +156,10 @@ export async function POST(request: NextRequest) {
context_name: body.context_name,
});
} catch (error) {
console.warn('[nodes.create] Invalid explicit context input, falling back to inheritance/inference:', error);
resolvedContextId = undefined;
}
if (resolvedContextId === undefined && typeof body.active_context_id === 'number' && Number.isInteger(body.active_context_id) && body.active_context_id > 0) {
const inherited = await contextService.getContextById(body.active_context_id);
if (inherited) {
resolvedContextId = inherited.id;
}
}
if (resolvedContextId == null) {
resolvedContextId = await inferBestContextIdForNode({
title: body.title,
description: finalDescription,
source: sourceToStore,
dimensions: finalDimensions,
metadata: body.metadata,
});
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Invalid context input'
}, { status: 400 });
}
const node = await nodeService.createNode({
@@ -203,16 +168,11 @@ export async function POST(request: NextRequest) {
source: sourceToStore ?? undefined,
event_date: eventDate ?? undefined,
link: normalizedLink ?? undefined,
dimensions: finalDimensions,
chunk_status: chunkStatus,
context_id: resolvedContextId,
metadata: buildCanonicalNodeMetadata({
metadata: body.metadata || {},
type: typeof body.metadata?.type === 'string'
? body.metadata.type
: typeof body.metadata?.source === 'string'
? body.metadata.source
: undefined,
type: inferredType,
state: body.metadata?.state === 'processed' ? 'processed' : 'not_processed',
})
});
@@ -229,7 +189,7 @@ export async function POST(request: NextRequest) {
return NextResponse.json({
success: true,
data: node,
message: `Node created successfully with dimensions: ${finalDimensions.join(', ')}`
message: `Node created successfully`
}, { status: 201 });
} catch (error) {
console.error('Error creating node:', error);
+1 -2
View File
@@ -29,7 +29,6 @@ export async function GET(request: NextRequest) {
const results = nodes.map(node => ({
id: node.id,
title: node.title,
dimensions: node.dimensions
}));
return NextResponse.json({
@@ -46,4 +45,4 @@ export async function GET(request: NextRequest) {
error: error instanceof Error ? error.message : 'Failed to search nodes'
}, { status: 500 });
}
}
}
-41
View File
@@ -1,41 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import {
getAutoContextSettings,
setAutoContextEnabled,
} from '@/services/settings/autoContextSettings';
export const runtime = 'nodejs';
export async function GET() {
try {
const settings = getAutoContextSettings();
return NextResponse.json({ success: true, data: settings });
} catch (error) {
console.error('Failed to read auto-context settings:', error);
return NextResponse.json(
{ success: false, error: 'Unable to read auto-context settings' },
{ status: 500 }
);
}
}
export async function PUT(request: NextRequest) {
try {
const body = await request.json();
if (!body || typeof body.autoContextEnabled !== 'boolean') {
return NextResponse.json(
{ success: false, error: 'autoContextEnabled boolean is required' },
{ status: 400 }
);
}
const updated = setAutoContextEnabled(body.autoContextEnabled);
return NextResponse.json({ success: true, data: updated });
} catch (error) {
console.error('Failed to update auto-context settings:', error);
return NextResponse.json(
{ success: false, error: 'Unable to update auto-context settings' },
{ status: 500 }
);
}
}
+800 -262
View File
File diff suppressed because it is too large Load Diff
+7 -5
View File
@@ -1,10 +1,11 @@
import './globals.css';
import { DimensionIconsProvider } from '@/context/DimensionIconsContext';
import { AuthProvider } from '@/context/AuthContext';
import AutoUpdateManager from '@/components/system/AutoUpdateManager';
import ExternalNavigationManager from '@/components/system/ExternalNavigationManager';
export const metadata = {
title: 'RA-H Open Source',
description: 'Local-first research workspace with a BYO-key AI orchestrator',
title: 'RA-H - Knowledge Management System',
description: 'A simplified, open-source knowledge management system',
};
export default function RootLayout({
@@ -39,10 +40,11 @@ export default function RootLayout({
/>
</head>
<body>
<DimensionIconsProvider>
<AuthProvider>
<AutoUpdateManager />
<ExternalNavigationManager />
{children}
</DimensionIconsProvider>
</AuthProvider>
</body>
</html>
);