agent.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. export * as Agent from "./agent"
  2. import { Schema } from "effect"
  3. import { Model } from "./model"
  4. import { Permission } from "./permission"
  5. import { Provider } from "./provider"
  6. import { PositiveInt, withStatics } from "./schema"
  7. export const ID = Schema.String.pipe(Schema.brand("AgentV2.ID"))
  8. export type ID = typeof ID.Type
  9. export const Color = Schema.Union([
  10. Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/)),
  11. Schema.Literals(["primary", "secondary", "accent", "success", "warning", "error", "info"]),
  12. ])
  13. export type Color = typeof Color.Type
  14. export interface Info extends Schema.Schema.Type<typeof Info> {}
  15. export const Info = Schema.Struct({
  16. id: ID,
  17. model: Model.Ref.pipe(Schema.optional),
  18. request: Provider.Request,
  19. system: Schema.String.pipe(Schema.optional),
  20. description: Schema.String.pipe(Schema.optional),
  21. mode: Schema.Literals(["subagent", "primary", "all"]),
  22. hidden: Schema.Boolean,
  23. color: Color.pipe(Schema.optional),
  24. steps: PositiveInt.pipe(Schema.optional),
  25. permissions: Permission.Ruleset,
  26. })
  27. .annotate({ identifier: "AgentV2.Info" })
  28. .pipe(
  29. withStatics((schema) => ({
  30. empty: (id: ID) =>
  31. schema.make({ id, request: { headers: {}, body: {} }, mode: "all", hidden: false, permissions: [] }),
  32. })),
  33. )