refactor: add Effect-returning versions of MessageV2 functions (#20374)

This commit is contained in:
Kit Langton
2026-04-01 19:48:36 -04:00
committed by GitHub
parent 4214ae205d
commit 26fb6b8788
8 changed files with 878 additions and 114 deletions
+4 -9
View File
@@ -593,15 +593,10 @@ export namespace Session {
})
const messages = Effect.fn("Session.messages")(function* (input: { sessionID: SessionID; limit?: number }) {
return yield* Effect.promise(async () => {
const result = [] as MessageV2.WithParts[]
for await (const msg of MessageV2.stream(input.sessionID)) {
if (input.limit && result.length >= input.limit) break
result.push(msg)
}
result.reverse()
return result
})
if (input.limit) {
return MessageV2.page({ sessionID: input.sessionID, limit: input.limit }).items
}
return Array.from(MessageV2.stream(input.sessionID)).reverse()
})
const removeMessage = Effect.fn("Session.removeMessage")(function* (input: {