Hapus seluruh fitur embedding/Qdrant (tidak dipakai lagi): - gateway: drop embeddingClient.ts, qdrantClient.ts, archiveEmbedder.ts dan tes qdrantEnsure.test.ts; moderationOrchestrator kembali ke exact-hash cache -> LLM (tanpa phase-2 semantic lookup); textCacheStore kehilangan findSimilarTextModeration / parseQdrantVerdict / isSemanticBandAccepted / upsertBareKeyToQdrant; cache-prune hanya menyapu Postgres. - backend: drop embed.ts + qdrant.ts, endpoint messages.semanticSearch dan schema/type terkait; kolom embedding dilepas dari schema text_analysis_cache. - frontend: hapus toggle EXACT/SEMANTIC, hook useSemanticSearch, API client + tipe SemanticSearchResult. - config: buang AI_LLM_EMBEDDING_* dan QDRANT_* (env + .env.example). - docs: ARCHITECTURE.md / AGENTS.md / README.md / diagram arsitektur disesuaikan (LLM caller - vision, cache = exact-hash saja). Verifikasi: tsc 0 (backend, gateway, frontend); bun test 135 pass + 37 pass, 0 fail; biome 0 error.
90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
import { orpc } from "@/lib/orpc/client";
|
|
import type {
|
|
AttachmentRecord,
|
|
Channel,
|
|
EditHistoryRow,
|
|
Guild,
|
|
MessageActivityBucket,
|
|
MessageRecord,
|
|
} from "@/lib/types";
|
|
|
|
export const messagesApi = {
|
|
getGuilds: () => orpc.messages.guilds() as unknown as Promise<Guild[]>,
|
|
|
|
getTextChannels: (guildId: string) =>
|
|
orpc.messages.textChannels({ guildId }) as unknown as Promise<Channel[]>,
|
|
|
|
list: (
|
|
guildId: string,
|
|
limit?: number,
|
|
channelId?: string,
|
|
cursor?: string,
|
|
) =>
|
|
orpc.messages.list({
|
|
guildId,
|
|
limit,
|
|
channelId,
|
|
cursor,
|
|
}) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getByChannel: (channelId: string, limit?: number, cursor?: string) =>
|
|
orpc.messages.byChannel({
|
|
channelId,
|
|
query: { channelId, limit, cursor },
|
|
}) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getDetail: (id: string) =>
|
|
orpc.messages.detail({ id }) as unknown as Promise<MessageRecord>,
|
|
|
|
getImages: (guildId: string, limit?: number) =>
|
|
orpc.messages.images({ guildId, limit }) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getAttachments: (
|
|
channelId: string,
|
|
limit?: number,
|
|
cursor?: string,
|
|
messageId?: string,
|
|
) =>
|
|
orpc.messages.attachmentsByChannel({
|
|
channelId,
|
|
query: { channelId, limit, cursor, messageId },
|
|
}) as unknown as Promise<{
|
|
data: AttachmentRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getReview: (limit?: number, channelId?: string) =>
|
|
orpc.messages.review({ limit, channelId }) as unknown as Promise<{
|
|
results: MessageRecord[];
|
|
limit: number;
|
|
cursor: null;
|
|
}>,
|
|
|
|
// Analysis search (formerly /api/analysis/search → oRPC analysis.search)
|
|
search: (q: string, limit?: number) =>
|
|
orpc.analysis.search({ q, limit }) as unknown as Promise<{
|
|
results: MessageRecord[];
|
|
}>,
|
|
|
|
// Public, read-only activity heatmap data (per-hour volume by channel).
|
|
getActivity: (days = 30) =>
|
|
orpc.messages.activity({ days }) as unknown as Promise<
|
|
MessageActivityBucket[]
|
|
>,
|
|
|
|
// Public, read-only recent message edits (evasion tracker).
|
|
getRecentEdits: (limit = 50, channelId?: string) =>
|
|
orpc.messages.editHistory({ limit, channelId }) as unknown as Promise<
|
|
EditHistoryRow[]
|
|
>,
|
|
};
|