schema.ts 841 B

1234567891011121314151617181920212223242526
  1. import { Schema } from "effect"
  2. import { Identifier } from "@/id/id"
  3. import { Session as CoreSession } from "@opencode-ai/core/session"
  4. import { withStatics } from "@opencode-ai/core/schema"
  5. export const SessionID = CoreSession.ID
  6. export type SessionID = Schema.Schema.Type<typeof SessionID>
  7. export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(
  8. Schema.brand("MessageID"),
  9. withStatics((s) => ({
  10. ascending: (id?: string) => s.make(Identifier.ascending("message", id)),
  11. })),
  12. )
  13. export type MessageID = Schema.Schema.Type<typeof MessageID>
  14. export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
  15. Schema.brand("PartID"),
  16. withStatics((s) => ({
  17. ascending: (id?: string) => s.make(Identifier.ascending("part", id)),
  18. })),
  19. )
  20. export type PartID = Schema.Schema.Type<typeof PartID>