mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
chore(lint): no-explicit-any in stt-manager/chat-mentions tests
This commit is contained in:
@@ -9,15 +9,16 @@ import type {
|
||||
TranscriptionResult,
|
||||
} from "../speech/speech-provider.js";
|
||||
|
||||
type SessionParams = Parameters<SpeechToTextProvider["createSession"]>[0];
|
||||
type StreamingOn = StreamingTranscriptionSession["on"];
|
||||
type StreamingOnEvent = Parameters<StreamingOn>[0];
|
||||
type StreamingOnHandler = Parameters<StreamingOn>[1];
|
||||
|
||||
class FakeStt implements SpeechToTextProvider {
|
||||
public readonly id = "fake";
|
||||
constructor(private readonly result: TranscriptionResult) {}
|
||||
|
||||
createSession(_params: {
|
||||
logger: any;
|
||||
language?: string;
|
||||
prompt?: string;
|
||||
}): StreamingTranscriptionSession {
|
||||
createSession(_params: SessionParams): StreamingTranscriptionSession {
|
||||
const emitter = new EventEmitter();
|
||||
const result = this.result;
|
||||
let segmentId = "seg-1";
|
||||
@@ -28,8 +29,8 @@ class FakeStt implements SpeechToTextProvider {
|
||||
async connect() {},
|
||||
appendPcm16() {},
|
||||
commit() {
|
||||
(emitter as any).emit("committed", { segmentId, previousSegmentId });
|
||||
(emitter as any).emit("transcript", {
|
||||
emitter.emit("committed", { segmentId, previousSegmentId });
|
||||
emitter.emit("transcript", {
|
||||
segmentId,
|
||||
transcript: result.text,
|
||||
isFinal: true,
|
||||
@@ -43,8 +44,8 @@ class FakeStt implements SpeechToTextProvider {
|
||||
},
|
||||
clear() {},
|
||||
close() {},
|
||||
on(event: any, handler: any) {
|
||||
emitter.on(event, handler);
|
||||
on(event: StreamingOnEvent, handler: StreamingOnHandler) {
|
||||
emitter.on(event, handler as (...args: unknown[]) => void);
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
@@ -55,11 +56,7 @@ class SequencedFakeStt implements SpeechToTextProvider {
|
||||
public readonly id = "fake-sequenced";
|
||||
constructor(private readonly transcripts: string[]) {}
|
||||
|
||||
createSession(_params: {
|
||||
logger: any;
|
||||
language?: string;
|
||||
prompt?: string;
|
||||
}): StreamingTranscriptionSession {
|
||||
createSession(_params: SessionParams): StreamingTranscriptionSession {
|
||||
const emitter = new EventEmitter();
|
||||
const transcripts = this.transcripts;
|
||||
let segmentId = "seg-1";
|
||||
@@ -73,8 +70,8 @@ class SequencedFakeStt implements SpeechToTextProvider {
|
||||
commit() {
|
||||
const transcript = transcripts[idx] ?? "";
|
||||
idx += 1;
|
||||
(emitter as any).emit("committed", { segmentId, previousSegmentId });
|
||||
(emitter as any).emit("transcript", {
|
||||
emitter.emit("committed", { segmentId, previousSegmentId });
|
||||
emitter.emit("transcript", {
|
||||
segmentId,
|
||||
transcript,
|
||||
isFinal: true,
|
||||
@@ -86,8 +83,8 @@ class SequencedFakeStt implements SpeechToTextProvider {
|
||||
},
|
||||
clear() {},
|
||||
close() {},
|
||||
on(event: any, handler: any) {
|
||||
emitter.on(event, handler);
|
||||
on(event: StreamingOnEvent, handler: StreamingOnHandler) {
|
||||
emitter.on(event, handler as (...args: unknown[]) => void);
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,24 +1,35 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import type pino from "pino";
|
||||
import type { StoredAgentRecord } from "../agent/agent-storage.js";
|
||||
import type { ManagedAgent } from "../agent/agent-manager.js";
|
||||
import {
|
||||
buildChatMentionNotification,
|
||||
notifyChatMentions,
|
||||
resolveChatMentionTargetAgentIds,
|
||||
} from "./chat-mentions.js";
|
||||
|
||||
function storedAgent(overrides: Partial<StoredAgentRecord> & { id: string }): StoredAgentRecord {
|
||||
return { internal: false, archivedAt: null, ...overrides } as StoredAgentRecord;
|
||||
}
|
||||
|
||||
function liveAgent(overrides: Partial<ManagedAgent> & { id: string }): ManagedAgent {
|
||||
return { internal: false, ...overrides } as ManagedAgent;
|
||||
}
|
||||
|
||||
describe("chat mentions", () => {
|
||||
test("@everyone expands to active non-archived agents", () => {
|
||||
const targets = resolveChatMentionTargetAgentIds({
|
||||
authorAgentId: "author-agent",
|
||||
mentionAgentIds: ["everyone"],
|
||||
storedAgents: [
|
||||
{ id: "agent-a", internal: false, archivedAt: null } as any,
|
||||
{ id: "agent-b", internal: false, archivedAt: "2026-03-28T00:00:00.000Z" } as any,
|
||||
{ id: "author-agent", internal: false, archivedAt: null } as any,
|
||||
{ id: "internal-agent", internal: true, archivedAt: null } as any,
|
||||
storedAgent({ id: "agent-a" }),
|
||||
storedAgent({ id: "agent-b", archivedAt: "2026-03-28T00:00:00.000Z" }),
|
||||
storedAgent({ id: "author-agent" }),
|
||||
storedAgent({ id: "internal-agent", internal: true }),
|
||||
],
|
||||
liveAgents: [
|
||||
{ id: "agent-c", internal: false } as any,
|
||||
{ id: "internal-live", internal: true } as any,
|
||||
liveAgent({ id: "agent-c" }),
|
||||
liveAgent({ id: "internal-live", internal: true }),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -29,8 +40,8 @@ describe("chat mentions", () => {
|
||||
const targets = resolveChatMentionTargetAgentIds({
|
||||
authorAgentId: "author-agent",
|
||||
mentionAgentIds: ["everyone", "agent-a", "custom-title"],
|
||||
storedAgents: [{ id: "agent-a", internal: false, archivedAt: null } as any],
|
||||
liveAgents: [{ id: "agent-b", internal: false } as any],
|
||||
storedAgents: [storedAgent({ id: "agent-a" })],
|
||||
liveAgents: [liveAgent({ id: "agent-b" })],
|
||||
});
|
||||
|
||||
expect(targets.sort()).toEqual(["agent-a", "agent-b", "custom-title"]);
|
||||
@@ -55,7 +66,7 @@ describe("chat mentions", () => {
|
||||
const sendAgentMessage = vi.fn(async () => {});
|
||||
const logger = {
|
||||
warn: vi.fn(),
|
||||
} as any;
|
||||
} as unknown as pino.Logger;
|
||||
|
||||
await notifyChatMentions({
|
||||
room: "coord-room",
|
||||
@@ -63,8 +74,8 @@ describe("chat mentions", () => {
|
||||
body: "@everyone Check status",
|
||||
mentionAgentIds: ["everyone"],
|
||||
logger,
|
||||
listStoredAgents: async () => [{ id: "agent-a", internal: false, archivedAt: null } as any],
|
||||
listLiveAgents: () => [{ id: "agent-b", internal: false } as any],
|
||||
listStoredAgents: async () => [storedAgent({ id: "agent-a" })],
|
||||
listLiveAgents: () => [liveAgent({ id: "agent-b" })],
|
||||
resolveAgentIdentifier,
|
||||
sendAgentMessage,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user