MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / readReadState

Function readReadState

src/core/inbox-store.ts:176–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174 }
175
176 async function readReadState(): Promise<InboxReadStateFile> {
177 let raw: string
178 try {
179 raw = await readFile(readStatePath, 'utf-8')
180 } catch (err: unknown) {
181 if (err instanceof Error && 'code' in err && (err as NodeJS.ErrnoException).code === 'ENOENT') {
182 return { ...EMPTY_READ_STATE, read: {} }
183 }
184 throw err
185 }
186 const parsed = JSON.parse(raw) as Partial<InboxReadStateFile>
187 return {
188 version: 1,
189 read: parsed.read && typeof parsed.read === 'object' ? parsed.read : {},
190 }
191 }
192
193 async function writeReadState(state: InboxReadStateFile): Promise<void> {
194 await mkdir(dirname(readStatePath), { recursive: true })

Callers 4

readFunction · 0.85
markReadFunction · 0.85
markUnreadFunction · 0.85
deleteEntryFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected