mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-20 01:12:15 +00:00
refactor(core): migrate MessageV2 internal Cursor to Effect Schema (#23763)
This commit is contained in:
parent
e89543811c
commit
1593c3ed16
1 changed files with 7 additions and 5 deletions
|
|
@ -638,18 +638,20 @@ export type WithParts = {
|
|||
parts: Part[]
|
||||
}
|
||||
|
||||
const Cursor = z.object({
|
||||
id: MessageID.zod,
|
||||
time: z.number(),
|
||||
const Cursor = Schema.Struct({
|
||||
id: MessageID,
|
||||
time: Schema.Number,
|
||||
})
|
||||
type Cursor = z.infer<typeof Cursor>
|
||||
type Cursor = typeof Cursor.Type
|
||||
|
||||
const decodeCursor = Schema.decodeUnknownSync(Cursor)
|
||||
|
||||
export const cursor = {
|
||||
encode(input: Cursor) {
|
||||
return Buffer.from(JSON.stringify(input)).toString("base64url")
|
||||
},
|
||||
decode(input: string) {
|
||||
return Cursor.parse(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
|
||||
return decodeCursor(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue