feat(tools): persona selector across standalone tools + dashboard chat
Wire the legal-domain persona picker into corpus, deep-research, korrespond and the dashboard chat. Each endpoint reads the chosen profile, resolves its packages against client 57, and scopes retrieval via package_ids (falling back to family when omitted). New dashboard tenants now subscribe to all DBN domain packages so persona switching survives the subscription intersection. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -208,20 +208,40 @@ final class CorpusProvision
|
||||
return (int)$db->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugs every DBN dashboard tenant is subscribed to, so persona-scoped
|
||||
* retrieval (which intersects requested package_ids with the tenant's
|
||||
* subscriptions) resolves for any domain persona. family-legal stays the
|
||||
* default; the dbn-* packages back the other personas.
|
||||
*/
|
||||
public const DBN_PACKAGE_SLUGS = [
|
||||
'family-legal',
|
||||
'dbn-child-welfare',
|
||||
'dbn-immigration',
|
||||
'dbn-labour',
|
||||
'dbn-consumer-tenancy',
|
||||
'dbn-general',
|
||||
];
|
||||
|
||||
private static function subscribeIncludedPackages(PDO $db, int $clientId): void
|
||||
{
|
||||
$packageSlug = dbnToolsRequiredPackageSlug();
|
||||
$stmt = $db->prepare('SELECT id FROM corpus_packages WHERE slug = ? AND is_active = 1 LIMIT 1');
|
||||
$stmt->execute([$packageSlug]);
|
||||
$packageId = (int)($stmt->fetchColumn() ?: 0);
|
||||
if ($packageId === 0) {
|
||||
$placeholders = implode(',', array_fill(0, count(self::DBN_PACKAGE_SLUGS), '?'));
|
||||
$stmt = $db->prepare(
|
||||
"SELECT id FROM corpus_packages WHERE slug IN ($placeholders) AND is_active = 1"
|
||||
);
|
||||
$stmt->execute(self::DBN_PACKAGE_SLUGS);
|
||||
$packageIds = array_map('intval', $stmt->fetchAll(PDO::FETCH_COLUMN));
|
||||
if (!$packageIds) {
|
||||
return;
|
||||
}
|
||||
$db->prepare(
|
||||
$insert = $db->prepare(
|
||||
"INSERT IGNORE INTO client_corpus_subscriptions
|
||||
(client_id, package_id, is_active, source, subscribed_at)
|
||||
VALUES (?, ?, 1, 'dbn_dashboard', NOW())"
|
||||
)->execute([$clientId, $packageId]);
|
||||
);
|
||||
foreach ($packageIds as $packageId) {
|
||||
$insert->execute([$clientId, $packageId]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function uniqueSlug(PDO $db, string $base): string
|
||||
|
||||
Reference in New Issue
Block a user