Initial release: Do Better Norge Legal Tools Hub
Five MVP tools (Ask, Search, Summarize, Timeline, Redact) with email+password auth, Azure OpenAI gateway, evidence trail panel, and process-and-forget privacy default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/AzureOpenAiGateway.php';
|
||||
|
||||
dbnToolsRequireMethod('GET');
|
||||
dbnToolsRequireAuth();
|
||||
|
||||
$checks = [];
|
||||
$checks['passcode_hash'] = [
|
||||
'ok' => (bool)dbnToolsEnv('DBN_TOOLS_PASSCODE_HASH'),
|
||||
'detail' => dbnToolsEnv('DBN_TOOLS_PASSCODE_HASH') ? 'Configured' : 'Missing DBN_TOOLS_PASSCODE_HASH',
|
||||
];
|
||||
|
||||
$azure = new DbnAzureOpenAiGateway();
|
||||
$missingChat = $azure->missingChatConfig();
|
||||
$missingEmbedding = $azure->missingEmbeddingConfig();
|
||||
$checks['azure_chat_config'] = [
|
||||
'ok' => !$missingChat,
|
||||
'detail' => !$missingChat ? 'Configured' : 'Missing: ' . implode(', ', $missingChat),
|
||||
];
|
||||
$checks['azure_embedding_config'] = [
|
||||
'ok' => !$missingEmbedding,
|
||||
'detail' => !$missingEmbedding ? 'Configured' : 'Missing: ' . implode(', ', $missingEmbedding),
|
||||
];
|
||||
$checks['azure_reachability'] = [
|
||||
'ok' => false,
|
||||
'detail' => 'Not checked because chat config is incomplete',
|
||||
];
|
||||
if (!$missingChat) {
|
||||
$reachable = $azure->ping(8);
|
||||
$checks['azure_reachability'] = [
|
||||
'ok' => $reachable,
|
||||
'detail' => $reachable ? 'Azure chat deployment responded' : 'Azure chat deployment did not respond',
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
$db = dbnToolsDb();
|
||||
$db->query('SELECT 1');
|
||||
$checks['db_connectivity'] = ['ok' => true, 'detail' => 'CaveauAI admin DB reachable'];
|
||||
|
||||
$client = dbnToolsFetchClient($db);
|
||||
$checks['dave_jr_legal_client'] = [
|
||||
'ok' => (bool)$client,
|
||||
'detail' => $client ? 'Client id ' . $client['id'] . ' found' : 'Client slug ' . dbnToolsClientSlug() . ' not found',
|
||||
];
|
||||
|
||||
$package = dbnToolsFetchPackage('family-legal', $db);
|
||||
$checks['family_legal_package'] = [
|
||||
'ok' => (bool)$package,
|
||||
'detail' => $package ? 'Package id ' . $package['id'] . ' found' : 'family-legal package not found',
|
||||
];
|
||||
|
||||
$subOk = $client && $package && dbnToolsHasActiveSubscription((int)$client['id'], (int)$package['id'], $db);
|
||||
$checks['family_legal_subscription'] = [
|
||||
'ok' => (bool)$subOk,
|
||||
'detail' => $subOk ? 'Active subscription visible' : 'Active subscription not visible',
|
||||
];
|
||||
} catch (Throwable $e) {
|
||||
$checks['db_connectivity'] = ['ok' => false, 'detail' => $e->getMessage()];
|
||||
$checks['dave_jr_legal_client'] = ['ok' => false, 'detail' => 'Not checked'];
|
||||
$checks['family_legal_package'] = ['ok' => false, 'detail' => 'Not checked'];
|
||||
$checks['family_legal_subscription'] = ['ok' => false, 'detail' => 'Not checked'];
|
||||
}
|
||||
|
||||
$logPath = dbnToolsMetadataLogPath();
|
||||
$dir = dirname($logPath);
|
||||
$checks['metadata_log'] = [
|
||||
'ok' => is_dir($dir) && is_writable($dir),
|
||||
'detail' => is_dir($dir) && is_writable($dir) ? 'Metadata directory is writable' : 'Metadata directory is not writable',
|
||||
];
|
||||
|
||||
$ok = true;
|
||||
foreach ($checks as $check) {
|
||||
if (empty($check['ok'])) {
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dbnToolsRespond([
|
||||
'ok' => $ok,
|
||||
'status' => $ok ? 'ok' : 'degraded',
|
||||
'version' => DBN_TOOLS_VERSION,
|
||||
'checks' => $checks,
|
||||
], $ok ? 200 : 503);
|
||||
Reference in New Issue
Block a user