feat(ai): complete v3.2 risk watch agent

This commit is contained in:
2026-07-08 19:57:38 +08:00
parent deebc5404a
commit e949d0f5d3
10 changed files with 445 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ import type { Priority } from './derive';
import type { Requirement, RequirementStatus, SourceType } from './requirement';
import type { TestCase, TestCaseStatus } from './test-case';
import type { VersionDataScope } from './version-data-scope';
import type { XiaobaoRiskInsightCacheItem } from './xiaobao-risk-cache';
import type {
PlanTask,
VersionPlan,
@@ -14,6 +15,11 @@ import type {
type V22DateValue = string | Date | null | undefined;
type V22XiaobaoRiskInsightCacheItem = Omit<XiaobaoRiskInsightCacheItem, 'generatedAt' | 'insight'> & {
generatedAt?: V22DateValue;
insight: XiaobaoRiskInsightCacheItem['insight'] & { generatedAt?: V22DateValue };
};
interface V22VersionRow {
id: string;
productId: string;
@@ -188,6 +194,7 @@ export interface V22XiaobaoWarningSummary {
forecastReleaseDate?: string;
riskSignature: string;
summary: unknown;
latestInsight?: XiaobaoRiskInsightCacheItem;
dirty?: boolean;
recomputedAt?: string;
updatedAt?: string;
@@ -231,10 +238,11 @@ export async function loadV22WorkspaceData(userId: string): Promise<V22Workspace
export async function loadV22XiaobaoWarnings(
query: V22XiaobaoWarningQuery,
): Promise<V22XiaobaoWarningSummary[]> {
const response = await api.get<Array<Omit<V22XiaobaoWarningSummary, 'forecastReleaseDate' | 'recomputedAt' | 'updatedAt'> & {
const response = await api.get<Array<Omit<V22XiaobaoWarningSummary, 'forecastReleaseDate' | 'recomputedAt' | 'updatedAt' | 'latestInsight'> & {
forecastReleaseDate?: V22DateValue;
recomputedAt?: V22DateValue;
updatedAt?: V22DateValue;
latestInsight?: V22XiaobaoRiskInsightCacheItem;
}>>(`/v2.2/xiaobao-warning?${queryString({
userId: query.userId,
manager: query.manager ? 'true' : undefined,
@@ -244,6 +252,7 @@ export async function loadV22XiaobaoWarnings(
forecastReleaseDate: optionalIso(row.forecastReleaseDate),
recomputedAt: optionalIso(row.recomputedAt),
updatedAt: optionalIso(row.updatedAt),
latestInsight: mapLatestXiaobaoInsight(row.latestInsight),
}));
}
@@ -421,6 +430,18 @@ function optionalIso(value: V22DateValue): string | undefined {
return trimmed;
}
function mapLatestXiaobaoInsight(value?: V22XiaobaoRiskInsightCacheItem): XiaobaoRiskInsightCacheItem | undefined {
if (!value) return undefined;
return {
...value,
generatedAt: optionalIso(value.generatedAt) ?? new Date(0).toISOString(),
insight: {
...value.insight,
generatedAt: optionalIso(value.insight.generatedAt) ?? value.insight.generatedAt ?? new Date(0).toISOString(),
},
};
}
function splitCsv(value?: string | null): string[] {
if (!value) return [];
return value.split(',').map((item) => item.trim()).filter(Boolean);