refactor(acp): split session tests and share rate limiter

This commit is contained in:
Peter Steinberger
2026-02-19 14:55:00 +01:00
parent 19348050be
commit f8b61bb4ed
6 changed files with 240 additions and 184 deletions

View File

@@ -3,6 +3,7 @@ import type { AcpSession } from "./types.js";
export type AcpSessionStore = {
createSession: (params: { sessionKey: string; cwd: string; sessionId?: string }) => AcpSession;
hasSession: (sessionId: string) => boolean;
getSession: (sessionId: string) => AcpSession | undefined;
getSessionByRunId: (runId: string) => AcpSession | undefined;
setActiveRun: (sessionId: string, runId: string, abortController: AbortController) => void;
@@ -105,6 +106,8 @@ export function createInMemorySessionStore(options: AcpSessionStoreOptions = {})
return session;
};
const hasSession: AcpSessionStore["hasSession"] = (sessionId) => sessions.has(sessionId);
const getSession: AcpSessionStore["getSession"] = (sessionId) => {
const session = sessions.get(sessionId);
if (session) {
@@ -174,6 +177,7 @@ export function createInMemorySessionStore(options: AcpSessionStoreOptions = {})
return {
createSession,
hasSession,
getSession,
getSessionByRunId,
setActiveRun,