АРЧ АП11 - Архитектура после регресса: Архитектура: централизовать organization authority в continuity policy для route, living-chat и data-scope
This commit is contained in:
@@ -4,9 +4,7 @@ import {
|
||||
normalizeOrganizationScopeValue
|
||||
} from "./assistantOrganizationMatcher";
|
||||
import {
|
||||
resolveAssistantContinuitySnapshot,
|
||||
isGroundedAddressDebug,
|
||||
readAddressDebugOrganization
|
||||
resolveAssistantOrganizationAuthority
|
||||
} from "./assistantContinuityPolicy";
|
||||
|
||||
const DATA_SCOPE_CACHE_TTL_MS = 60_000;
|
||||
@@ -297,40 +295,13 @@ export function createAssistantDataScopePolicy(deps: AssistantDataScopePolicyDep
|
||||
}
|
||||
|
||||
function findLastAssistantActiveOrganization(items: unknown[]): string | null {
|
||||
const continuitySnapshot = resolveAssistantContinuitySnapshot({
|
||||
const authority = resolveAssistantOrganizationAuthority({
|
||||
sessionItems: items,
|
||||
toNonEmptyString: normalizeOrganizationScopeValue
|
||||
toNonEmptyString: normalizeOrganizationScopeValue,
|
||||
normalizeOrganizationScopeValue,
|
||||
mergeKnownOrganizations
|
||||
});
|
||||
const continuityOrganization = normalizeOrganizationScopeValue(continuitySnapshot.activeOrganization);
|
||||
|
||||
for (let index = (Array.isArray(items) ? items.length : 0) - 1; index >= 0; index -= 1) {
|
||||
const item = Array.isArray(items) ? items[index] : null;
|
||||
if (!item || typeof item !== "object" || (item as { role?: string }).role !== "assistant") {
|
||||
continue;
|
||||
}
|
||||
|
||||
const debug = (item as { debug?: Record<string, unknown> }).debug;
|
||||
if (!debug || typeof debug !== "object") {
|
||||
continue;
|
||||
}
|
||||
|
||||
const direct = normalizeOrganizationScopeValue(debug.assistant_active_organization);
|
||||
if (direct) {
|
||||
return direct;
|
||||
}
|
||||
const selected = normalizeOrganizationScopeValue(debug.living_chat_selected_organization);
|
||||
if (selected) {
|
||||
return selected;
|
||||
}
|
||||
if (isGroundedAddressDebug(debug)) {
|
||||
const groundedOrganization = normalizeOrganizationScopeValue(readAddressDebugOrganization(debug));
|
||||
if (groundedOrganization) {
|
||||
return groundedOrganization;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return continuityOrganization;
|
||||
return normalizeOrganizationScopeValue(authority.activeOrganization);
|
||||
}
|
||||
|
||||
function extractOrganizationFactsFromRows(rows: unknown[]): AssistantOrganizationFacts {
|
||||
|
||||
Reference in New Issue
Block a user