agent.ts 1.3 KB

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