mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:12:42 +00:00
refactor(acp): split session tests and share rate limiter
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user