Skip to content

DTO Field Decorators (@Text, @ListOf, @Nested…)

In AGBoss, every payload crossing a workflow path, @Agent, @Action, @Router, @Tool, or @ChannelRole boundary is a DTO class (*Dto) whose properties each carry a single field decorator from @agboss/core/dto ([dto.missing-decorator], [dto.multiple-decorators]). A single DTO class serves simultaneously as the compile-time TypeScript type, the runtime validator, the deterministic JSON Schema generator for LLM structured outputs, and the field-level PII masking contract. Runtime values are always plain object literals { ... } — never instantiate DTOs with new.

Complete DTO example with nested objects, lists, formats, and sensitive: PiiAction.*

Section titled “Complete DTO example with nested objects, lists, formats, and sensitive: PiiAction.*”

Every scalar field decorator accepts sensitive?: MaskingPiiAction (PiiAction.replaceWithKind(), PiiAction.replaceWithToken(), or PiiAction.replacePart({ keepFirst?, keepLast?, maskChar? })):

What field decorators does @agboss/core/dto provide?

Section titled “What field decorators does @agboss/core/dto provide?”
Decorator TypeScript Field Type Options Description
@Text(options?) string minLength, maxLength, pattern, prompt, optional, sensitive UTF-8 string with optional length bounds and regex pattern.
@Integer(options?) number min, max, prompt, optional, sensitive Whole integer number (Number.isInteger).
@Decimal(options?) number min, max, prompt, optional, sensitive Finite floating-point number.
@DecimalString(options?) string scale, prompt, optional, sensitive Exact base-10 decimal formatted as a string ("19.99") with at most scale fractional digits.
@Flag(options?) boolean prompt, optional, sensitive Boolean true or false.
@OneOf({ values, ... }) V[number] values: readonly [string, ...], prompt, optional, sensitive String literal union; TypeScript enforces that the property type matches values exactly.
@ListOf(Item, options?) T[] minItems, maxItems, prompt, optional, sensitive Array of scalar field factories (@ListOf(Text)) or nested DTO classes (@ListOf(LineItemDto)).
@Nested(DtoClass, options?) DtoClass prompt, optional, sensitive Embeds a child DTO object inside a parent DTO.
@Email(options?) string prompt, optional, sensitive Validated email address string.
@PhoneNumber(options?) string prompt, optional, sensitive E.164 phone number ("+14155550199").
@Url(options?) string prompt, optional, sensitive Validated http:// or https:// URL string.
@Uuid(options?) string prompt, optional, sensitive RFC 4122 UUID string.
@Date(options?) string prompt, optional, sensitive ISO 8601 calendar date ("2026-10-20").
@DateTime(options?) string prompt, optional, sensitive ISO 8601 timestamp with timezone offset or Z ("2026-10-20T09:00:00Z").
@Duration(options?) string prompt, optional, sensitive ISO 8601 duration string ("PT30M").
@CurrencyCode(options?) string prompt, optional, sensitive ISO 4217 3-letter currency code ("USD").
@CountryCode(options?) string prompt, optional, sensitive ISO 3166-1 alpha-2 country code ("US").
@TimeZone(options?) string prompt, optional, sensitive IANA time zone identifier ("America/New_York").
@MediaType(options?) string prompt, optional, sensitive MIME type string ("application/pdf").

Built-in standard DTOs and Path Scope wrappers

Section titled “Built-in standard DTOs and Path Scope wrappers”
Entity Import Path Purpose
PlainTextDto, WorkflowStartTextDto, WorkflowFinishTextDto "@agboss/core/dto" Built-in standard text DTOs ({ text: string }) for plain-text agent judges, workflow starts, and workflow finishes.
ToolCallApprovalAskDto & ToolCallApprovalDecisionDto "@agboss/core/dto" Built-in standard DTOs used by @ChannelRole({ approves }) tool approval pauses ({ approved: boolean, reason?: string, overrideArguments?: ... }).
oneOf(DtoA, DtoB), listOf(Dto), optional(Dto), historyOf(Dto, { limit }) "@agboss/core" Path Scope type wrappers used in .returns(...) and @Agent / @Action / @Router input and output contracts.
variant(DtoClass, plainObject) & isVariant(value, DtoClass) "@agboss/core" Tags and narrows union variants when returning or inspecting oneOf(DtoA, DtoB) values in deterministic code.