session.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. export * as Session from "./session"
  2. import { Schema } from "effect"
  3. import { Agent } from "./agent"
  4. import { Location } from "./location"
  5. import { Model } from "./model"
  6. import { Project } from "./project"
  7. import { DateTimeUtcFromMillis, optional, RelativePath } from "./schema"
  8. import { SessionEvent } from "./session-event"
  9. import { SessionID } from "./session-id"
  10. import { Revert } from "./revert"
  11. export const ID = SessionID
  12. export type ID = SessionID
  13. export const Event = SessionEvent
  14. export interface Info extends Schema.Schema.Type<typeof Info> {}
  15. export const Info = Schema.Struct({
  16. id: ID,
  17. parentID: ID.pipe(optional),
  18. projectID: Project.ID,
  19. agent: Agent.ID.pipe(optional),
  20. model: Model.Ref.pipe(optional),
  21. cost: Schema.Finite,
  22. tokens: Schema.Struct({
  23. input: Schema.Finite,
  24. output: Schema.Finite,
  25. reasoning: Schema.Finite,
  26. cache: Schema.Struct({
  27. read: Schema.Finite,
  28. write: Schema.Finite,
  29. }),
  30. }),
  31. time: Schema.Struct({
  32. created: DateTimeUtcFromMillis,
  33. updated: DateTimeUtcFromMillis,
  34. archived: DateTimeUtcFromMillis.pipe(optional),
  35. }),
  36. title: Schema.String,
  37. location: Location.Ref,
  38. subpath: RelativePath.pipe(optional),
  39. revert: Revert.State.pipe(optional),
  40. }).annotate({ identifier: "SessionV2.Info" })
  41. export const ListAnchor = Schema.Struct({
  42. id: ID,
  43. time: Schema.Finite,
  44. direction: Schema.Literals(["previous", "next"]),
  45. }).annotate({ identifier: "Session.ListAnchor" })
  46. export interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {}