.
This commit is contained in:
1 parent
ae44aa03db
commit
2bb9fcf27e
34 files changed
+1524
-120
No files matched your search
@@ -3,6 +3,8 @@ import type { EvalReport } from "@eval/types";
|
||||
export const AGENT_REQUEST_SUBJECT = "lolympus-agent.request";
|
||||
export const AGENT_ALERT_SUBJECT = "lolympus-agent.alert";
|
||||
export const AGENT_EVAL_REPORT_SUBJECT = "lolympus-agent.eval.report";
|
||||
export const DISCORD_MEMBER_LOOKUP_SUBJECT =
|
||||
"lolympus.discord.lookup-members";
|
||||
|
||||
export interface AlertPayload {
|
||||
kind: "latency" | "eval-score-drop" | "llm-error-rate" | "endpoint-down";
|
||||
@@ -17,3 +19,36 @@ export interface AlertPayload {
|
||||
}
|
||||
|
||||
export type EvalReportPayload = EvalReport;
|
||||
|
||||
export type DiscordMemberMatchSource =
|
||||
| "guild-nickname"
|
||||
| "global-name"
|
||||
| "username"
|
||||
| "joined-after";
|
||||
|
||||
export interface DiscordMemberCandidate {
|
||||
memberId: string;
|
||||
joinedAt: string;
|
||||
guildNickname?: string | undefined;
|
||||
globalName?: string | undefined;
|
||||
matchedBy?: DiscordMemberMatchSource | undefined;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface DiscordMemberLookupRequest {
|
||||
chatroomId: string;
|
||||
joinedAfter: string;
|
||||
searchName?: string | undefined;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export type DiscordMemberLookupResponse =
|
||||
| {
|
||||
status: "ok";
|
||||
joinedAfterMatches: DiscordMemberCandidate[];
|
||||
nicknameMatches: DiscordMemberCandidate[];
|
||||
}
|
||||
| {
|
||||
status: "error";
|
||||
reason: string;
|
||||
};
|
||||
@@ -106,6 +106,26 @@ export class NatsClient {
|
||||
await client.flush();
|
||||
}
|
||||
|
||||
async request<TRequest = unknown, TResponse = unknown>(
|
||||
subject: string,
|
||||
data: TRequest,
|
||||
options?: { timeoutMs?: number | undefined },
|
||||
): Promise<TResponse> {
|
||||
const requestOptions =
|
||||
options?.timeoutMs !== undefined
|
||||
? {
|
||||
timeout: options.timeoutMs,
|
||||
}
|
||||
: undefined;
|
||||
const response = await this.getConnection().request(
|
||||
subject,
|
||||
this.stringCodec.encode(JSON.stringify(data)),
|
||||
requestOptions,
|
||||
);
|
||||
|
||||
return this.decodeMessage<TResponse>(response);
|
||||
}
|
||||
|
||||
respond(msg: Msg, data: unknown): Promise<void> {
|
||||
if (!msg.reply) {
|
||||
this.logger.warn(
|
||||
|
||||
Reference in new issue
Block a user