ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.652.68 - сборка входов turn attempt в новый builder: assistantTurnAttemptInputBuilder.ts / адаптер на builder (убрал inline-сборку payload для address/deep): assistantTurnAttemptRuntimeAdapter.ts / сборку followupContext/options для address lane attempt в новый builder: assistantAddressLaneAttemptQueryOptionsBuilder.ts / адаптер на builder для query options: assistantAddressLaneAttemptRuntimeAdapter.ts
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildAssistantAddressLaneAttemptQueryOptions,
|
||||
resolveAssistantAddressLaneAttemptFollowupContext
|
||||
} from "../src/services/assistantAddressLaneAttemptQueryOptionsBuilder";
|
||||
|
||||
describe("assistant address lane attempt query options builder", () => {
|
||||
it("extracts followup context object from carry meta", () => {
|
||||
const followupContext = resolveAssistantAddressLaneAttemptFollowupContext({
|
||||
followupContext: {
|
||||
previous_intent: "docs_by_counterparty"
|
||||
}
|
||||
} as any);
|
||||
|
||||
expect(followupContext).toEqual({
|
||||
previous_intent: "docs_by_counterparty"
|
||||
});
|
||||
});
|
||||
|
||||
it("builds query options with scoped followup context when present", () => {
|
||||
const options = buildAssistantAddressLaneAttemptQueryOptions({
|
||||
analysisDateHint: "2020-07-31",
|
||||
scopedFollowupContext: {
|
||||
previous_intent: "docs_by_counterparty",
|
||||
active_organization: "Org A"
|
||||
}
|
||||
});
|
||||
|
||||
expect(options).toEqual({
|
||||
followupContext: {
|
||||
previous_intent: "docs_by_counterparty",
|
||||
active_organization: "Org A"
|
||||
},
|
||||
analysisDateHint: "2020-07-31"
|
||||
});
|
||||
});
|
||||
|
||||
it("builds query options with only analysis date when scoped context is missing", () => {
|
||||
const options = buildAssistantAddressLaneAttemptQueryOptions({
|
||||
analysisDateHint: null,
|
||||
scopedFollowupContext: null
|
||||
});
|
||||
|
||||
expect(options).toEqual({
|
||||
analysisDateHint: null
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildAssistantTurnAttemptAddressRuntimeInput,
|
||||
buildAssistantTurnAttemptDeepRuntimeInput
|
||||
} from "../src/services/assistantTurnAttemptInputBuilder";
|
||||
|
||||
function buildUserTurn(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
session: {
|
||||
session_id: "asst-1",
|
||||
updated_at: "2026-04-11T00:00:00.000Z",
|
||||
items: [{ role: "user", text: "msg" }],
|
||||
investigation_state: { focus: "settlements_60_62" }
|
||||
},
|
||||
sessionId: "asst-1",
|
||||
userMessageRaw: "where tail",
|
||||
userMessage: "where tail",
|
||||
runtimeAnalysisContext: {
|
||||
as_of_date: "2020-07-31"
|
||||
},
|
||||
userItem: {
|
||||
message_id: "msg-q1"
|
||||
},
|
||||
...overrides
|
||||
} as any;
|
||||
}
|
||||
|
||||
describe("assistant turn attempt input builder", () => {
|
||||
it("builds address runtime input from user turn and organization scope", () => {
|
||||
const runtimeInput = buildAssistantTurnAttemptAddressRuntimeInput({
|
||||
payload: { user_message: "where tail" },
|
||||
userTurn: buildUserTurn(),
|
||||
sessionOrganizationScope: {
|
||||
knownOrganizations: ["Org A"],
|
||||
selectedOrganization: "Org A",
|
||||
activeOrganization: "Org A"
|
||||
}
|
||||
});
|
||||
|
||||
expect(runtimeInput.sessionId).toBe("asst-1");
|
||||
expect(runtimeInput.userMessage).toBe("where tail");
|
||||
expect(runtimeInput.runtimeAnalysisContext).toEqual({ as_of_date: "2020-07-31" });
|
||||
expect(runtimeInput.sessionOrganizationScope).toEqual({
|
||||
knownOrganizations: ["Org A"],
|
||||
selectedOrganization: "Org A",
|
||||
activeOrganization: "Org A"
|
||||
});
|
||||
});
|
||||
|
||||
it("builds deep runtime input with investigation state and address meta", () => {
|
||||
const runtimeInput = buildAssistantTurnAttemptDeepRuntimeInput({
|
||||
payload: { user_message: "where tail" },
|
||||
userTurn: buildUserTurn(),
|
||||
addressRuntimeMetaForDeep: { attempted: true }
|
||||
});
|
||||
|
||||
expect(runtimeInput.sessionId).toBe("asst-1");
|
||||
expect(runtimeInput.questionId).toBe("msg-q1");
|
||||
expect(runtimeInput.userMessage).toBe("where tail");
|
||||
expect(runtimeInput.addressRuntimeMetaForDeep).toEqual({ attempted: true });
|
||||
expect(runtimeInput.sessionInvestigationState).toEqual({ focus: "settlements_60_62" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user