Skip to content

Commit 1593c3e

Browse files
authored
refactor(core): migrate MessageV2 internal Cursor to Effect Schema (#23763)
1 parent e895438 commit 1593c3e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/opencode/src/session/message-v2.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,20 @@ export type WithParts = {
638638
parts: Part[]
639639
}
640640

641-
const Cursor = z.object({
642-
id: MessageID.zod,
643-
time: z.number(),
641+
const Cursor = Schema.Struct({
642+
id: MessageID,
643+
time: Schema.Number,
644644
})
645-
type Cursor = z.infer<typeof Cursor>
645+
type Cursor = typeof Cursor.Type
646+
647+
const decodeCursor = Schema.decodeUnknownSync(Cursor)
646648

647649
export const cursor = {
648650
encode(input: Cursor) {
649651
return Buffer.from(JSON.stringify(input)).toString("base64url")
650652
},
651653
decode(input: string) {
652-
return Cursor.parse(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
654+
return decodeCursor(JSON.parse(Buffer.from(input, "base64url").toString("utf8")))
653655
},
654656
}
655657

0 commit comments

Comments
 (0)