ARCH: связать metadata grounding с document MCP lane
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.readAssistantMcpDiscoveryPilotScope = readAssistantMcpDiscoveryPilotScope;
|
||||
exports.readAssistantMcpDiscoveryMetadataRouteFamily = readAssistantMcpDiscoveryMetadataRouteFamily;
|
||||
exports.readAssistantMcpDiscoveryMetadataSelectedEntitySet = readAssistantMcpDiscoveryMetadataSelectedEntitySet;
|
||||
exports.readAssistantMcpDiscoveryMetadataAmbiguityDetected = readAssistantMcpDiscoveryMetadataAmbiguityDetected;
|
||||
exports.formatIsoDateForReply = formatIsoDateForReply;
|
||||
exports.readAddressDebugFilters = readAddressDebugFilters;
|
||||
exports.readAddressDebugItem = readAddressDebugItem;
|
||||
@@ -75,15 +78,32 @@ function readAssistantMcpDiscoveryActionFamily(debug, toNonEmptyString = fallbac
|
||||
function readAssistantMcpDiscoveryBridge(debug) {
|
||||
return toRecordObject(readAssistantMcpDiscoveryEntry(debug)?.bridge);
|
||||
}
|
||||
function readAssistantMcpDiscoveryDerivedMetadataSurface(debug) {
|
||||
const bridge = readAssistantMcpDiscoveryBridge(debug);
|
||||
const pilot = toRecordObject(bridge?.pilot);
|
||||
return toRecordObject(pilot?.derived_metadata_surface);
|
||||
}
|
||||
function readAssistantMcpDiscoveryPilotScope(debug, toNonEmptyString = fallbackToNonEmptyString) {
|
||||
const bridge = readAssistantMcpDiscoveryBridge(debug);
|
||||
const pilot = toRecordObject(bridge?.pilot);
|
||||
return toNonEmptyString(pilot?.pilot_scope);
|
||||
}
|
||||
function readAssistantMcpDiscoveryMetadataRouteFamily(debug, toNonEmptyString = fallbackToNonEmptyString) {
|
||||
return toNonEmptyString(readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.downstream_route_family);
|
||||
}
|
||||
function readAssistantMcpDiscoveryMetadataSelectedEntitySet(debug, toNonEmptyString = fallbackToNonEmptyString) {
|
||||
return toNonEmptyString(readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.selected_entity_set);
|
||||
}
|
||||
function readAssistantMcpDiscoveryMetadataAmbiguityDetected(debug) {
|
||||
return readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.ambiguity_detected === true;
|
||||
}
|
||||
function mapAssistantMcpDiscoveryPilotScopeToAddressIntent(pilotScope, actionFamily) {
|
||||
if (pilotScope === "counterparty_lifecycle_query_documents_v1") {
|
||||
return "counterparty_activity_lifecycle";
|
||||
}
|
||||
if (pilotScope === "counterparty_document_evidence_query_documents_v1") {
|
||||
return "list_documents_by_counterparty";
|
||||
}
|
||||
if (pilotScope === "counterparty_supplier_payout_query_movements_v1") {
|
||||
return "supplier_payouts_profile";
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ function isValueFlowPilot(pilot) {
|
||||
pilot.pilot_scope === "counterparty_supplier_payout_query_movements_v1" ||
|
||||
pilot.pilot_scope === "counterparty_bidirectional_value_flow_query_movements_v1");
|
||||
}
|
||||
function isDocumentPilot(pilot) {
|
||||
return pilot.pilot_scope === "counterparty_document_evidence_query_documents_v1";
|
||||
}
|
||||
function isMetadataPilot(pilot) {
|
||||
return pilot.pilot_scope === "metadata_inspection_v1";
|
||||
}
|
||||
@@ -109,6 +112,9 @@ function headlineFor(mode, pilot) {
|
||||
}
|
||||
return "По данным 1С найдены строки денежных движений; сумму можно называть только в рамках проверенного периода и найденных строк.";
|
||||
}
|
||||
if (isDocumentPilot(pilot) && mode === "confirmed_with_bounded_inference") {
|
||||
return "По данным 1С найдены строки документов; ответ ограничен проверенным периодом и найденными строками.";
|
||||
}
|
||||
if (mode === "confirmed_with_bounded_inference") {
|
||||
return "По данным 1С есть подтвержденная активность; длительность можно оценивать только как вывод из этих строк.";
|
||||
}
|
||||
@@ -158,6 +164,10 @@ function buildMustNotClaim(pilot) {
|
||||
claims.push("Do not claim full all-time turnover unless the checked period and coverage prove it.");
|
||||
claims.push("Do not present a derived sum as a legal/accounting final total outside the checked 1C rows.");
|
||||
}
|
||||
if (isDocumentPilot(pilot)) {
|
||||
claims.push("Do not claim full document history outside the checked period.");
|
||||
claims.push("Do not present the confirmed document rows as a complete document universe.");
|
||||
}
|
||||
if (isMetadataPilot(pilot)) {
|
||||
claims.push("Do not present metadata surface as confirmed business data rows.");
|
||||
claims.push("Do not claim a document/register exists outside the checked metadata probe results.");
|
||||
|
||||
+126
-1
@@ -107,6 +107,15 @@ function isLifecyclePilotEligible(planner) {
|
||||
return (planner.proposed_primitives.includes("query_documents") &&
|
||||
(combined.includes("lifecycle") || combined.includes("activity") || combined.includes("duration") || combined.includes("age")));
|
||||
}
|
||||
function isDocumentEvidencePilotEligible(planner) {
|
||||
const meaning = planner.discovery_plan.turn_meaning_ref;
|
||||
const domain = String(meaning?.asked_domain_family ?? "").toLowerCase();
|
||||
const action = String(meaning?.asked_action_family ?? "").toLowerCase();
|
||||
const unsupported = String(meaning?.unsupported_but_understood_family ?? "").toLowerCase();
|
||||
const combined = `${domain} ${action} ${unsupported}`;
|
||||
return (planner.proposed_primitives.includes("query_documents") &&
|
||||
(combined.includes("document") || combined.includes("list_documents")));
|
||||
}
|
||||
function isValueFlowPilotEligible(planner) {
|
||||
const meaning = planner.discovery_plan.turn_meaning_ref;
|
||||
const domain = String(meaning?.asked_domain_family ?? "").toLowerCase();
|
||||
@@ -379,6 +388,15 @@ function summarizeLifecycleRows(result) {
|
||||
}
|
||||
return `${result.fetched_rows} MCP document rows fetched, ${result.matched_rows} matched lifecycle scope`;
|
||||
}
|
||||
function summarizeDocumentRows(result) {
|
||||
if (result.error) {
|
||||
return null;
|
||||
}
|
||||
if (result.fetched_rows <= 0) {
|
||||
return "0 MCP document rows fetched";
|
||||
}
|
||||
return `${result.fetched_rows} MCP document rows fetched, ${result.matched_rows} matched document scope`;
|
||||
}
|
||||
function summarizeValueFlowRows(result) {
|
||||
if (result.error) {
|
||||
return null;
|
||||
@@ -953,6 +971,16 @@ function buildLifecycleConfirmedFacts(result, counterparty) {
|
||||
: "1C activity rows were found for the requested counterparty scope"
|
||||
];
|
||||
}
|
||||
function buildDocumentConfirmedFacts(result, counterparty) {
|
||||
if (result.error || result.matched_rows <= 0) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
counterparty
|
||||
? `1C document rows were found for counterparty ${counterparty}`
|
||||
: "1C document rows were found for the requested scope"
|
||||
];
|
||||
}
|
||||
function buildValueFlowConfirmedFacts(result, counterparty, direction) {
|
||||
if (result.error || result.matched_rows <= 0) {
|
||||
return [];
|
||||
@@ -991,6 +1019,12 @@ function buildLifecycleInferredFacts(result) {
|
||||
}
|
||||
return ["Business activity duration may be inferred from first and latest confirmed 1C activity rows"];
|
||||
}
|
||||
function buildDocumentInferredFacts(result) {
|
||||
if (result.error || result.fetched_rows <= 0) {
|
||||
return [];
|
||||
}
|
||||
return ["Counterparty document evidence is limited to confirmed 1C document rows in the checked scope"];
|
||||
}
|
||||
function buildValueFlowInferredFacts(derived) {
|
||||
if (!derived) {
|
||||
return [];
|
||||
@@ -1026,6 +1060,13 @@ function buildBidirectionalValueFlowInferredFacts(derived) {
|
||||
function buildLifecycleUnknownFacts() {
|
||||
return ["Legal registration date is not proven by this MCP discovery pilot"];
|
||||
}
|
||||
function buildDocumentUnknownFacts(periodScope) {
|
||||
return [
|
||||
periodScope
|
||||
? "Full document history outside the checked period is not proven by this MCP discovery pilot"
|
||||
: "Full document history is not proven without an explicit checked period"
|
||||
];
|
||||
}
|
||||
function buildValueFlowUnknownFacts(periodScope, direction, derived) {
|
||||
const unknownFacts = [];
|
||||
if (derived?.coverage_limited_by_probe_limit) {
|
||||
@@ -1068,6 +1109,9 @@ function pilotScopeForPlanner(planner) {
|
||||
if (isValueFlowPilotEligible(planner)) {
|
||||
return valueFlowPilotProfile(planner).scope;
|
||||
}
|
||||
if (isDocumentEvidencePilotEligible(planner)) {
|
||||
return "counterparty_document_evidence_query_documents_v1";
|
||||
}
|
||||
return "counterparty_lifecycle_query_documents_v1";
|
||||
}
|
||||
async function executeAssistantMcpDiscoveryPilot(planner, deps = DEFAULT_DEPS) {
|
||||
@@ -1129,9 +1173,10 @@ async function executeAssistantMcpDiscoveryPilot(planner, deps = DEFAULT_DEPS) {
|
||||
};
|
||||
}
|
||||
const metadataPilotEligible = isMetadataPilotEligible(planner);
|
||||
const documentPilotEligible = isDocumentEvidencePilotEligible(planner);
|
||||
const lifecyclePilotEligible = isLifecyclePilotEligible(planner);
|
||||
const valueFlowPilotEligible = isValueFlowPilotEligible(planner);
|
||||
if (!metadataPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
|
||||
if (!metadataPilotEligible && !documentPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
|
||||
pushReason(reasonCodes, "pilot_scope_unsupported_for_live_execution");
|
||||
for (const step of dryRun.execution_steps) {
|
||||
skippedPrimitives.push(step.primitive_id);
|
||||
@@ -1221,6 +1266,86 @@ async function executeAssistantMcpDiscoveryPilot(planner, deps = DEFAULT_DEPS) {
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
if (documentPilotEligible) {
|
||||
let queryResult = null;
|
||||
const filters = buildLifecycleFilters(planner);
|
||||
const selection = (0, addressRecipeCatalog_1.selectAddressRecipe)("list_documents_by_counterparty", filters);
|
||||
if (!selection.selected_recipe) {
|
||||
pushReason(reasonCodes, "pilot_document_recipe_not_available");
|
||||
const evidence = buildEmptyEvidence(planner, dryRun, probeResults, "Document-evidence recipe is not available");
|
||||
return {
|
||||
schema_version: exports.ASSISTANT_MCP_DISCOVERY_PILOT_EXECUTOR_SCHEMA_VERSION,
|
||||
policy_owner: "assistantMcpDiscoveryPilotExecutor",
|
||||
pilot_status: "unsupported",
|
||||
pilot_scope: "counterparty_document_evidence_query_documents_v1",
|
||||
dry_run: dryRun,
|
||||
mcp_execution_performed: false,
|
||||
executed_primitives: executedPrimitives,
|
||||
skipped_primitives: skippedPrimitives,
|
||||
probe_results: probeResults,
|
||||
evidence,
|
||||
source_rows_summary: null,
|
||||
derived_metadata_surface: null,
|
||||
derived_activity_period: null,
|
||||
derived_value_flow: null,
|
||||
derived_bidirectional_value_flow: null,
|
||||
query_limitations: ["Document-evidence recipe is not available"],
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
const recipePlan = (0, addressRecipeCatalog_1.buildAddressRecipePlan)(selection.selected_recipe, filters);
|
||||
for (const step of dryRun.execution_steps) {
|
||||
if (step.primitive_id !== "query_documents") {
|
||||
skippedPrimitives.push(step.primitive_id);
|
||||
probeResults.push(skippedProbeResult(step, "pilot_only_executes_query_documents"));
|
||||
continue;
|
||||
}
|
||||
queryResult = await runtimeDeps.executeAddressMcpQuery({
|
||||
query: recipePlan.query,
|
||||
limit: recipePlan.limit,
|
||||
account_scope: recipePlan.account_scope
|
||||
});
|
||||
executedPrimitives.push(step.primitive_id);
|
||||
probeResults.push(queryResultToProbeResult(step.primitive_id, queryResult));
|
||||
if (queryResult.error) {
|
||||
pushUnique(queryLimitations, queryResult.error);
|
||||
pushReason(reasonCodes, "pilot_query_documents_mcp_error");
|
||||
}
|
||||
else {
|
||||
pushReason(reasonCodes, "pilot_query_documents_mcp_executed");
|
||||
}
|
||||
}
|
||||
const sourceRowsSummary = queryResult ? summarizeDocumentRows(queryResult) : null;
|
||||
const evidence = (0, assistantMcpDiscoveryPolicy_1.resolveAssistantMcpDiscoveryEvidence)({
|
||||
plan: planner.discovery_plan,
|
||||
probeResults,
|
||||
confirmedFacts: queryResult ? buildDocumentConfirmedFacts(queryResult, counterparty) : [],
|
||||
inferredFacts: queryResult ? buildDocumentInferredFacts(queryResult) : [],
|
||||
unknownFacts: buildDocumentUnknownFacts(dateScope),
|
||||
sourceRowsSummary,
|
||||
queryLimitations,
|
||||
recommendedNextProbe: "explain_evidence_basis"
|
||||
});
|
||||
return {
|
||||
schema_version: exports.ASSISTANT_MCP_DISCOVERY_PILOT_EXECUTOR_SCHEMA_VERSION,
|
||||
policy_owner: "assistantMcpDiscoveryPilotExecutor",
|
||||
pilot_status: "executed",
|
||||
pilot_scope: "counterparty_document_evidence_query_documents_v1",
|
||||
dry_run: dryRun,
|
||||
mcp_execution_performed: executedPrimitives.length > 0,
|
||||
executed_primitives: executedPrimitives,
|
||||
skipped_primitives: skippedPrimitives,
|
||||
probe_results: probeResults,
|
||||
evidence,
|
||||
source_rows_summary: sourceRowsSummary,
|
||||
derived_metadata_surface: null,
|
||||
derived_activity_period: null,
|
||||
derived_value_flow: null,
|
||||
derived_bidirectional_value_flow: null,
|
||||
query_limitations: queryLimitations,
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
if (valueFlowPilotEligible) {
|
||||
let queryResult = null;
|
||||
const filters = buildValueFlowFilters(planner);
|
||||
|
||||
+16
@@ -75,6 +75,13 @@ function localizeLine(value) {
|
||||
if (/^1C value-flow rows were found for the requested counterparty scope$/i.test(value)) {
|
||||
return "В 1С найдены строки денежных движений по запрошенному контрагентскому контуру.";
|
||||
}
|
||||
const documentRowsMatch = value.match(/^1C document rows were found for counterparty\s+(.+)$/i);
|
||||
if (documentRowsMatch) {
|
||||
return `В 1С найдены строки документов по контрагенту ${documentRowsMatch[1]}.`;
|
||||
}
|
||||
if (/^1C document rows were found for the requested scope$/i.test(value)) {
|
||||
return "В 1С найдены строки документов по запрошенному контуру.";
|
||||
}
|
||||
const supplierPayoutMatch = value.match(/^1C supplier-payout rows were found for counterparty\s+(.+)$/i);
|
||||
if (supplierPayoutMatch) {
|
||||
return `В 1С найдены строки исходящих платежей/списаний по контрагенту ${supplierPayoutMatch[1]}.`;
|
||||
@@ -97,6 +104,9 @@ function localizeLine(value) {
|
||||
if (/^Business activity duration may be inferred from first and latest confirmed 1C activity rows$/i.test(value)) {
|
||||
return "Длительность деловой активности можно оценивать только как вывод по первой и последней подтвержденной строке активности в 1С.";
|
||||
}
|
||||
if (/^Counterparty document evidence is limited to confirmed 1C document rows in the checked scope$/i.test(value)) {
|
||||
return "Срез документов ограничен только подтвержденными строками документов в проверенном окне.";
|
||||
}
|
||||
if (/^Counterparty value-flow total was calculated from confirmed 1C movement rows$/i.test(value)) {
|
||||
return "Сумма рассчитана только по подтвержденным строкам денежных движений в 1С.";
|
||||
}
|
||||
@@ -171,6 +181,12 @@ function localizeLine(value) {
|
||||
if (/^Full all-time turnover is not proven without an explicit checked period$/i.test(value)) {
|
||||
return "Полный оборот за все время без явно проверенного периода не подтвержден.";
|
||||
}
|
||||
if (/^Full document history outside the checked period is not proven by this MCP discovery pilot$/i.test(value)) {
|
||||
return "Полный исторический срез документов вне проверенного периода этим поиском не подтвержден.";
|
||||
}
|
||||
if (/^Full document history is not proven without an explicit checked period$/i.test(value)) {
|
||||
return "Полный срез документов без явно проверенного периода не подтвержден.";
|
||||
}
|
||||
if (/^Full supplier-payout amount outside the checked period is not proven by this MCP discovery pilot$/i.test(value)) {
|
||||
return "Полный объем исходящих платежей вне проверенного периода этим поиском не подтвержден.";
|
||||
}
|
||||
|
||||
+68
-28
@@ -211,7 +211,10 @@ function collectFollowupDiscoverySeed(followupContext) {
|
||||
counterparty,
|
||||
discoveryEntity: discoveryEntities[0] ?? null,
|
||||
organization,
|
||||
dateScope
|
||||
dateScope,
|
||||
metadataRouteFamily: toNonEmptyString(followupContext?.previous_discovery_metadata_route_family),
|
||||
metadataSelectedEntitySet: toNonEmptyString(followupContext?.previous_discovery_metadata_selected_entity_set),
|
||||
metadataAmbiguityDetected: followupContext?.previous_discovery_metadata_ambiguity_detected === true
|
||||
};
|
||||
}
|
||||
function hasLifecycleSignal(text) {
|
||||
@@ -239,6 +242,9 @@ function hasMetadataSignal(text) {
|
||||
function hasMetadataObjectHint(text) {
|
||||
return /(?:\u0440\u0435\u0433\u0438\u0441\u0442\u0440(?:\u044b)?|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|\u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a(?:\u0438)?|\u043f\u043e\u043b(?:\u0435|\u044f)|registers?|documents?|catalogs?|fields?)/iu.test(text);
|
||||
}
|
||||
function hasDocumentEvidenceFollowupSignal(text) {
|
||||
return /(?:\u043f\u043e\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u0430\u043c|\u044b)?|\u0434\u0430\u0432\u0430\u0439\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|\u0438\u0449\u0438\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|\u043f\u043e\u043a\u0430\u0436\u0438\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|document(?:s)?\s+(?:then|next)?|(?:then|next)\s+documents?|go\s+to\s+documents?)/iu.test(text);
|
||||
}
|
||||
function metadataActionFromRawText(text) {
|
||||
if (/(?:\u043f\u043e\u043b(?:\u0435|\u044f)|field)/iu.test(text)) {
|
||||
return "inspect_fields";
|
||||
@@ -338,9 +344,29 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
hasMetadataObjectHint(rawText));
|
||||
const seededDomain = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.domain : null;
|
||||
const seededAction = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.action : null;
|
||||
const seededUnsupported = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.unsupported : null;
|
||||
const metadataGroundedDocumentFollowupApplicable = Boolean(followupSeed.pilotScope === "metadata_inspection_v1" &&
|
||||
followupSeed.metadataRouteFamily === "document_evidence" &&
|
||||
!followupSeed.metadataAmbiguityDetected &&
|
||||
followupSeed.counterparty &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
hasDocumentEvidenceFollowupSignal(rawText));
|
||||
const effectiveMetadataFollowupSeedApplicable = metadataFollowupSeedApplicable && !metadataGroundedDocumentFollowupApplicable;
|
||||
const seededDomain = metadataGroundedDocumentFollowupApplicable
|
||||
? "documents"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.domain
|
||||
: null;
|
||||
const seededAction = metadataGroundedDocumentFollowupApplicable
|
||||
? "list_documents"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.action
|
||||
: null;
|
||||
const seededUnsupported = metadataGroundedDocumentFollowupApplicable
|
||||
? "document_evidence"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.unsupported
|
||||
: null;
|
||||
const lifecycleSignal = rawLifecycleSignal || seededDomain === "counterparty_lifecycle";
|
||||
const bidirectionalValueFlowSignal = !lifecycleSignal &&
|
||||
(rawBidirectionalValueFlowSignal || seededAction === "net_value_flow");
|
||||
@@ -354,7 +380,7 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
unsupported: unsupported ?? seededUnsupported,
|
||||
lifecycleSignal,
|
||||
valueFlowSignal,
|
||||
metadataSignal: rawMetadataSignal || metadataFollowupSeedApplicable
|
||||
metadataSignal: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
});
|
||||
const entityCandidates = collectEntityCandidates(assistantTurnMeaning?.explicit_entity_candidates);
|
||||
pushUnique(entityCandidates, predecomposeEntities.counterparty);
|
||||
@@ -375,9 +401,11 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
? "counterparty_lifecycle"
|
||||
: valueFlowSignal
|
||||
? "counterparty_value"
|
||||
: rawMetadataSignal || metadataFollowupSeedApplicable
|
||||
? "metadata"
|
||||
: rawDomain ?? seededDomain,
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
? "documents"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? "metadata"
|
||||
: rawDomain ?? seededDomain,
|
||||
asked_action_family: lifecycleSignal
|
||||
? "activity_duration"
|
||||
: valueFlowSignal
|
||||
@@ -386,9 +414,11 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
: payoutSignal
|
||||
? "payout"
|
||||
: rawAction ?? seededAction ?? "turnover"
|
||||
: rawMetadataSignal || metadataFollowupSeedApplicable
|
||||
? metadataActionFromRawText(rawText) ?? seededAction
|
||||
: rawAction ?? seededAction,
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
? "list_documents"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? metadataActionFromRawText(rawText) ?? seededAction
|
||||
: rawAction ?? seededAction,
|
||||
asked_aggregation_axis: monthlyAggregationSignal ? "month" : rawAggregationAxis,
|
||||
explicit_entity_candidates: entityCandidates,
|
||||
explicit_organization_scope: explicitOrganizationScope,
|
||||
@@ -402,17 +432,20 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
: payoutSignal
|
||||
? "counterparty_payouts_or_outflow"
|
||||
: seededUnsupported ?? "counterparty_value_or_turnover"
|
||||
: rawMetadataSignal || metadataFollowupSeedApplicable
|
||||
? "1c_metadata_surface"
|
||||
: followupDiscoverySeedApplicable
|
||||
? seededUnsupported
|
||||
: null),
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
? "document_evidence"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? "1c_metadata_surface"
|
||||
: followupDiscoverySeedApplicable
|
||||
? seededUnsupported
|
||||
: null),
|
||||
stale_replay_forbidden: Boolean(assistantTurnMeaning?.stale_replay_forbidden ||
|
||||
unsupported ||
|
||||
lifecycleSignal ||
|
||||
valueFlowSignal ||
|
||||
metadataGroundedDocumentFollowupApplicable ||
|
||||
rawMetadataSignal ||
|
||||
metadataFollowupSeedApplicable ||
|
||||
effectiveMetadataFollowupSeedApplicable ||
|
||||
followupDiscoverySeedApplicable)
|
||||
};
|
||||
const cleanTurnMeaning = {};
|
||||
@@ -444,25 +477,29 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
unsupported: unsupported ?? seededUnsupported,
|
||||
lifecycleSignal,
|
||||
valueFlowSignal,
|
||||
metadataSignal: rawMetadataSignal || metadataFollowupSeedApplicable,
|
||||
metadataSignal: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable,
|
||||
semanticDataNeed,
|
||||
explicitIntentCandidate,
|
||||
followupDiscoverySeedApplicable: followupDiscoverySeedApplicable || metadataFollowupSeedApplicable
|
||||
followupDiscoverySeedApplicable: followupDiscoverySeedApplicable ||
|
||||
effectiveMetadataFollowupSeedApplicable ||
|
||||
metadataGroundedDocumentFollowupApplicable
|
||||
});
|
||||
const hasTurnMeaning = Object.keys(cleanTurnMeaning).length > 0;
|
||||
const sourceSignal = assistantTurnMeaning
|
||||
? "assistant_turn_meaning"
|
||||
: followupDiscoverySeedApplicable || metadataFollowupSeedApplicable
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? "followup_context"
|
||||
: predecomposeContract
|
||||
? "predecompose_contract"
|
||||
: lifecycleSignal
|
||||
? "raw_text"
|
||||
: valueFlowSignal
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
? "followup_context"
|
||||
: predecomposeContract
|
||||
? "predecompose_contract"
|
||||
: lifecycleSignal
|
||||
? "raw_text"
|
||||
: rawMetadataSignal || metadataFollowupSeedApplicable
|
||||
: valueFlowSignal
|
||||
? "raw_text"
|
||||
: "none";
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? "raw_text"
|
||||
: "none";
|
||||
if (lifecycleSignal) {
|
||||
pushReason(reasonCodes, "mcp_discovery_lifecycle_signal_detected");
|
||||
}
|
||||
@@ -484,9 +521,12 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
if (followupDiscoverySeedApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_seeded_from_followup_context");
|
||||
}
|
||||
if (metadataFollowupSeedApplicable) {
|
||||
if (effectiveMetadataFollowupSeedApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_metadata_seeded_from_followup_context");
|
||||
}
|
||||
if (metadataGroundedDocumentFollowupApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_metadata_grounded_document_followup");
|
||||
}
|
||||
if (unsupported) {
|
||||
pushReason(reasonCodes, "mcp_discovery_unsupported_but_understood_turn");
|
||||
}
|
||||
|
||||
@@ -463,6 +463,9 @@ function createAssistantTransitionPolicy(deps) {
|
||||
}
|
||||
const sourceIntent = (0, assistantContinuityPolicy_1.readAddressDebugIntent)(carryoverSourceDebug, deps.toNonEmptyString);
|
||||
const sourceDiscoveryPilotScope = (0, assistantContinuityPolicy_1.readAssistantMcpDiscoveryPilotScope)(carryoverSourceDebug, deps.toNonEmptyString);
|
||||
const sourceDiscoveryMetadataRouteFamily = (0, assistantContinuityPolicy_1.readAssistantMcpDiscoveryMetadataRouteFamily)(carryoverSourceDebug, deps.toNonEmptyString);
|
||||
const sourceDiscoveryMetadataSelectedEntitySet = (0, assistantContinuityPolicy_1.readAssistantMcpDiscoveryMetadataSelectedEntitySet)(carryoverSourceDebug, deps.toNonEmptyString);
|
||||
const sourceDiscoveryMetadataAmbiguityDetected = (0, assistantContinuityPolicy_1.readAssistantMcpDiscoveryMetadataAmbiguityDetected)(carryoverSourceDebug);
|
||||
const llmExplicitIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent);
|
||||
const llmSelectedObjectScopeDetected = llmPreDecomposeMeta?.predecomposeContract?.semantics?.selected_object_scope_detected === true;
|
||||
const resolvedPrimaryIntent = deps.resolveAddressIntent(deps.repairAddressMojibake(String(userMessage ?? ""))).intent;
|
||||
@@ -693,6 +696,9 @@ function createAssistantTransitionPolicy(deps) {
|
||||
previous_anchor_type: previousAnchorType ?? undefined,
|
||||
previous_anchor_value: previousAnchor,
|
||||
previous_discovery_pilot_scope: sourceDiscoveryPilotScope ?? undefined,
|
||||
previous_discovery_metadata_route_family: sourceDiscoveryMetadataRouteFamily ?? undefined,
|
||||
previous_discovery_metadata_selected_entity_set: sourceDiscoveryMetadataSelectedEntitySet ?? undefined,
|
||||
previous_discovery_metadata_ambiguity_detected: sourceDiscoveryMetadataAmbiguityDetected || undefined,
|
||||
resolved_counterparty_from_display: resolvedCounterpartyFromDisplay || undefined,
|
||||
root_context_only: rootScopedPivot || undefined,
|
||||
root_intent: shouldAttachInventoryRootFrame ? inventoryRootFrame?.intent ?? undefined : undefined,
|
||||
|
||||
Reference in New Issue
Block a user