91 lines
4.8 KiB
JavaScript
91 lines
4.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.runAssistantAddressRuntime = runAssistantAddressRuntime;
|
|
const assistantAddressOrchestrationRuntimeAdapter_1 = require("./assistantAddressOrchestrationRuntimeAdapter");
|
|
const assistantAddressLaneRuntimeAdapter_1 = require("./assistantAddressLaneRuntimeAdapter");
|
|
const assistantAddressToolGateRuntimeAdapter_1 = require("./assistantAddressToolGateRuntimeAdapter");
|
|
async function runAssistantAddressRuntime(input) {
|
|
if (!input.featureAssistantAddressQueryV1) {
|
|
return {
|
|
handled: false,
|
|
response: null,
|
|
addressRuntimeMetaForDeep: null
|
|
};
|
|
}
|
|
const runAddressOrchestrationRuntimeSafe = input.runAddressOrchestrationRuntime ?? assistantAddressOrchestrationRuntimeAdapter_1.buildAssistantAddressOrchestrationRuntime;
|
|
const runAddressToolGateRuntimeSafe = input.runAddressToolGateRuntime ?? assistantAddressToolGateRuntimeAdapter_1.runAssistantAddressToolGateRuntime;
|
|
const runAddressLaneRuntimeSafe = input.runAddressLaneRuntime ?? assistantAddressLaneRuntimeAdapter_1.runAssistantAddressLaneRuntime;
|
|
const addressOrchestrationRuntime = await runAddressOrchestrationRuntimeSafe({
|
|
userMessage: input.userMessage,
|
|
sessionItems: input.sessionItems,
|
|
llmProvider: input.llmProvider,
|
|
useMock: input.useMock,
|
|
featureAddressLlmPredecomposeV1: input.featureAddressLlmPredecomposeV1,
|
|
runAddressLlmPreDecompose: input.runAddressLlmPreDecompose,
|
|
buildAddressLlmPredecomposeContractV1: input.buildAddressLlmPredecomposeContractV1,
|
|
sanitizeAddressMessageForFallback: input.sanitizeAddressMessageForFallback,
|
|
toNonEmptyString: input.toNonEmptyString,
|
|
resolveAddressFollowupCarryoverContext: input.resolveAddressFollowupCarryoverContext,
|
|
resolveAssistantOrchestrationDecision: input.resolveAssistantOrchestrationDecision,
|
|
buildAddressDialogContinuationContractV2: input.buildAddressDialogContinuationContractV2
|
|
});
|
|
const addressInputMessage = addressOrchestrationRuntime.addressInputMessage;
|
|
const carryover = addressOrchestrationRuntime.carryover;
|
|
const orchestrationDecision = addressOrchestrationRuntime.orchestrationDecision;
|
|
const addressRuntimeMeta = addressOrchestrationRuntime.addressRuntimeMeta;
|
|
const livingModeDecision = addressOrchestrationRuntime.livingModeDecision;
|
|
const addressRuntimeMetaForDeep = addressRuntimeMeta;
|
|
const toolGateRuntime = await runAddressToolGateRuntimeSafe({
|
|
sessionId: input.sessionId,
|
|
userMessage: input.userMessage,
|
|
addressInputMessage,
|
|
orchestrationDecision,
|
|
livingModeDecision,
|
|
addressRuntimeMeta,
|
|
logEvent: input.logEvent,
|
|
tryHandleLivingChat: input.tryHandleLivingChat,
|
|
nowIso: input.nowIso
|
|
});
|
|
if (toolGateRuntime.handled && toolGateRuntime.response) {
|
|
return {
|
|
handled: true,
|
|
response: toolGateRuntime.response,
|
|
addressRuntimeMetaForDeep
|
|
};
|
|
}
|
|
if (Boolean(orchestrationDecision.runAddressLane)) {
|
|
const shouldPreferContextualLane = Boolean(carryover?.followupContext);
|
|
const analysisDateHint = input.runtimeAnalysisContextAsOfDate ?? input.toNonEmptyString(input.payloadContextPeriodHint);
|
|
const canRetryWithRawUserMessage = input.compactWhitespace(String(addressInputMessage ?? "").toLowerCase()) !==
|
|
input.compactWhitespace(String(input.userMessage ?? "").toLowerCase());
|
|
const addressLaneRuntime = await runAddressLaneRuntimeSafe({
|
|
userMessage: input.userMessage,
|
|
addressInputMessage,
|
|
carryover,
|
|
llmSemanticHints: addressRuntimeMeta && typeof addressRuntimeMeta === "object"
|
|
? addressRuntimeMeta.semanticHints ?? null
|
|
: null,
|
|
shouldPreferContextualLane,
|
|
canRetryWithRawUserMessage,
|
|
runAddressLaneAttempt: (messageUsed, carryMeta, llmSemanticHints = null) => input.runAddressLaneAttempt(messageUsed, carryMeta, analysisDateHint, llmSemanticHints),
|
|
isRetryableAddressLimitedResult: input.isRetryableAddressLimitedResult
|
|
});
|
|
if (addressLaneRuntime.handled && addressLaneRuntime.selection) {
|
|
const response = input.finalizeAddressLaneResponse(addressLaneRuntime.selection.addressLane, addressLaneRuntime.selection.messageUsed, addressLaneRuntime.selection.carryMeta, {
|
|
...addressRuntimeMeta,
|
|
addressRetryAudit: { ...addressLaneRuntime.retryAudit }
|
|
});
|
|
return {
|
|
handled: true,
|
|
response,
|
|
addressRuntimeMetaForDeep
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
handled: false,
|
|
response: null,
|
|
addressRuntimeMetaForDeep
|
|
};
|
|
}
|