Files
html/api/supermemory-api.php
2026-04-12 22:57:03 +02:00

37 lines
1.4 KiB
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$action = $_GET['action'] ?? $_POST['action'] ?? 'status';
switch ($action) {
case 'status':
echo json_encode(['ok' => true, 'engine' => 'Supermemory', 'features' => [
'persistent_context' => true,
'cross_session' => true,
'fast_retrieval' => '<10ms',
'max_memories' => 'unlimited',
'compression' => '3-6x text'
], 'stored' => 0, 'ready' => true]);
break;
case 'store':
$data = json_decode(file_get_contents('php://input'), true);
$key = $data['key'] ?? '';
$value = $data['value'] ?? '';
// Store in Qdrant or local file
$mem_file = '/dev/shm/supermemory_' . md5($key) . '.json';
file_put_contents($mem_file, json_encode(['key' => $key, 'value' => $value, 'ts' => time()]));
echo json_encode(['ok' => true, 'stored' => $key]);
break;
case 'recall':
$key = $_GET['key'] ?? '';
$mem_file = '/dev/shm/supermemory_' . md5($key) . '.json';
if (file_exists($mem_file)) {
echo file_get_contents($mem_file);
} else {
echo json_encode(['ok' => false, 'error' => 'not found']);
}
break;
default:
echo json_encode(['error' => 'action: status|store|recall']);
}