98 lines
6.5 KiB
TypeScript
98 lines
6.5 KiB
TypeScript
import request, { type ApiResponse } from '@/utils/request';
|
|
|
|
export type HintForm = 'KEYWORD' | 'QUESTION' | 'LEAF' | 'TREE';
|
|
export type RecallAiType = 'RECALL_HINT' | 'RECALL_CHECK';
|
|
export type ScopeInput = {
|
|
type: 'TASK' | 'TAG'; taskNum: string | null; tags: string[];
|
|
combineMode: 'UNION' | 'INTERSECT' | null;
|
|
};
|
|
export type ScopeSnapshot = ScopeInput & {
|
|
normalizedTags: string[]; scopeKey: string; displayName: string; selectedAt: string;
|
|
};
|
|
export type Provenance = {
|
|
kind: 'HINT' | 'FEEDBACK'; recallNum: string;
|
|
requestTaskNum: string | null; itemId: string | null;
|
|
};
|
|
export type NodeStyle = { background: string; color: string };
|
|
export type ExpressionNode = {
|
|
id: string; title: string; notes: string; provenance: Provenance[]; style?: NodeStyle | null; children: ExpressionNode[];
|
|
};
|
|
export type Expression = { schemaVersion: 1; root: ExpressionNode };
|
|
export type EditorGuard = { editorId: string; writeToken: string };
|
|
export type Timing = { segmentActiveMs: number; segmentActualMs: number; lastInteractionAt: string | null };
|
|
export type ReferenceSummary = { status: 'AVAILABLE' | 'EMPTY' | 'REDACTED'; total: number; limitations: string[] };
|
|
export type ReferenceSourceSummary = {
|
|
sourceId: string; title: string; preview: string; role: 'PRIMARY' | 'CONTEXT';
|
|
status: 'AVAILABLE' | 'DELETED' | 'ACCESS_REVOKED';
|
|
};
|
|
export type ReferencePage = { current: number; size: number; total: number; records: ReferenceSourceSummary[] };
|
|
export type ReferenceContent = {
|
|
sourceId: string; title: string; content: string | null; role: 'PRIMARY' | 'CONTEXT';
|
|
status: 'AVAILABLE' | 'DELETED' | 'ACCESS_REVOKED';
|
|
};
|
|
export type Citation = { unitId: string; start: number; end: number; quote: string };
|
|
export type ExpressionEvidence = { nodeId: string; field: 'TITLE' | 'NOTES'; start: number; end: number; quote: string };
|
|
export type UnitAssessment = {
|
|
unitId: string; status: 'ANALYZED' | 'EXCLUDED' | 'UNANALYZED'; reason: string;
|
|
exclusion: 'OUT_OF_SCOPE' | 'NOT_KNOWLEDGE' | null; citations: Citation[];
|
|
};
|
|
export type HintNode = { id: string; parentId: string | null; text: string };
|
|
export type HintItem = { id: string; form: HintForm; clue: string; anchorNodeId: string | null; nodes: HintNode[]; citations: Citation[] };
|
|
export type Finding = {
|
|
id: string;
|
|
category: 'EXPRESSED' | 'POSSIBLY_MISSING' | 'INSUFFICIENT_EXPRESSION' | 'RECALL_CONFLICT' | 'REFERENCE_CONFLICT' | 'NOT_IN_REFERENCE';
|
|
clue: string; explanation: string; citations: Citation[]; expressionEvidence: ExpressionEvidence[];
|
|
};
|
|
export type RecallAiResult = {
|
|
schemaVersion: 1; kind: 'HINT' | 'CHECK'; model: string;
|
|
analysisStatus: 'COMPLETE' | 'PARTIAL' | 'INSUFFICIENT';
|
|
assessments: UnitAssessment[]; hints: HintItem[]; findings: Finding[]; limitations: string[];
|
|
};
|
|
export type RecallAiTask = {
|
|
taskNum: string; type: RecallAiType; targetNum: string;
|
|
status: 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED'; errorMessage: string | null;
|
|
errorCode: string | null; createdTime: string; finishedTime: string | null; result: RecallAiResult | null;
|
|
};
|
|
export type RecallRequest = Omit<RecallAiTask, 'targetNum' | 'createdTime' | 'finishedTime'> & {
|
|
requestId: string; hintForm: HintForm | null; promptVersion: string;
|
|
submittedAt: string; finishedAt: string | null;
|
|
};
|
|
export type RecallSummary = {
|
|
recallNum: string; status: 'ACTIVE' | 'ENDED'; scope: ScopeSnapshot; scopeStatus: 'VALID' | 'INVALID';
|
|
activeDurationMs: number; actualDurationMs: number | null; createdAt: string; updatedAt: string; endedAt: string | null;
|
|
};
|
|
export type RecallDetail = RecallSummary & {
|
|
editorId: string | null; writeToken: string; expression: Expression; reference: ReferenceSummary;
|
|
requests: RecallRequest[];
|
|
};
|
|
export type CreateRecallRequest = {
|
|
clientRequestId: string; editorId: string; scope: ScopeInput;
|
|
entry: { type: 'DIRECT' | 'FEED' | 'FRAGMENT' | 'REPORT' | 'LEGACY'; sourceType: 'FRAGMENT' | 'REPORT' | null; entityId: string | null } | null;
|
|
};
|
|
export type ResumeRequest = { clientRequestId: string; editorId: string; writeToken: string };
|
|
export type SaveDraftRequest = EditorGuard & { clientRequestId: string; expression: Expression; timing: Timing };
|
|
export type EndRequest = SaveDraftRequest;
|
|
export type SubmitRecallAiRequest = {
|
|
type: RecallAiType; targetNum: string;
|
|
params: EditorGuard & { schemaVersion: 1; requestId: string; hintForm: HintForm | null };
|
|
};
|
|
export type RecallPage = { current: number; size: number; total: number; records: RecallSummary[] };
|
|
export type RecallQuery = { pageNum: number; pageSize: number; status?: 'ACTIVE' | 'ENDED'; scopeType?: 'TASK' | 'TAG'; taskNum?: string; tags?: string[]; combineMode?: 'UNION' | 'INTERSECT' };
|
|
const path = (recallNum: string) => `/review/recalls/${encodeURIComponent(recallNum)}`;
|
|
export const createRecall = (body: CreateRecallRequest): Promise<ApiResponse<RecallDetail>> => request.post<RecallDetail>('/review/recalls', body);
|
|
export const listRecalls = (
|
|
query: RecallQuery,
|
|
options: { silent?: boolean } = {},
|
|
): Promise<ApiResponse<RecallPage>> => request.get<RecallPage>('/review/recalls', query, options.silent
|
|
? { paramsSerializer: { indexes: null }, silent: true }
|
|
: { paramsSerializer: { indexes: null } });
|
|
export const getRecall = (num: string): Promise<ApiResponse<RecallDetail>> => request.get<RecallDetail>(path(num));
|
|
export const resumeRecall = (num: string, body: ResumeRequest): Promise<ApiResponse<RecallDetail>> => request.post<RecallDetail>(`${path(num)}/resume`, body);
|
|
export const saveRecallDraft = (num: string, body: SaveDraftRequest): Promise<ApiResponse<RecallDetail>> => request.put<RecallDetail>(`${path(num)}/draft`, body);
|
|
export const getRecallReferences = (num: string, pageNum = 1, pageSize = 10): Promise<ApiResponse<ReferencePage>> => request.get<ReferencePage>(`${path(num)}/references`, { pageNum, pageSize });
|
|
export const getRecallSource = (num: string, sourceId: string): Promise<ApiResponse<ReferenceContent>> => request.get<ReferenceContent>(`${path(num)}/references/sources/${encodeURIComponent(sourceId)}`);
|
|
export const endRecall = (num: string, body: EndRequest): Promise<ApiResponse<RecallDetail>> => request.post<RecallDetail>(`${path(num)}/end`, body);
|
|
export const deleteRecall = (num: string): Promise<ApiResponse<null>> => request.del<null>(path(num));
|
|
export const submitRecallAi = (body: SubmitRecallAiRequest): Promise<ApiResponse<RecallAiTask>> => request.post<RecallAiTask>('/ai/tasks', body);
|
|
export const getRecallAiTask = (num: string): Promise<ApiResponse<RecallAiTask>> => request.get<RecallAiTask>(`/ai/tasks/${encodeURIComponent(num)}`);
|