INNER CODE UNIT · TypeScript
SessionApi
agentscope-ai/agentscope-runtime · web/starter_webui/src/components/Chat/sessionApi/index.ts:6
class SessionApi implements IAgentScopeRuntimeWebUISessionAPI {
private lsKey: string;
private sessionList: IAgentScopeRuntimeWebUISession[];
constructor() {
this.lsKey = 'agent-scope-runtime-webui-sessions';
this.sessionList = [];
}
async getSessionList() {
this.sessionList = JSON.parse(localStorage.getItem(this.lsKey) || '[]');
return [...this.sessionList];
}
async getSession(sessionId: string) {
return this.sessionList.find((session) => session.id === sessionId) as IAgentScopeRuntimeWebUISession;
}