MCPcopy Create free account
hub / github.com/MemTensor/MemOS / loadOrCreateSessionId

Method loadOrCreateSessionId

packages/memos-core/src/telemetry.ts:128–145  ·  view source on GitHub ↗
(stateDir: string)

Source from the content-addressed store, hash-verified

126 }
127
128 private loadOrCreateSessionId(stateDir: string): string {
129 const filePath = path.join(stateDir, "memos-local", ".session");
130 try {
131 const raw = fs.readFileSync(filePath, "utf-8").trim();
132 const sep = raw.indexOf("|");
133 if (sep > 0) {
134 const ts = parseInt(raw.slice(0, sep), 10);
135 const id = raw.slice(sep + 1);
136 if (id.length > 10 && Date.now() - ts < SESSION_TTL_MS) {
137 this.touchSession(filePath, id);
138 return id;
139 }
140 }
141 } catch {}
142 const newId = uuidv4();
143 this.touchSession(filePath, newId);
144 return newId;
145 }
146
147 private touchSession(filePath: string, id: string): void {
148 try {

Callers 1

constructorMethod · 0.95

Calls 2

touchSessionMethod · 0.95
joinMethod · 0.45

Tested by

no test coverage detected