Skip to main content

Agent DTO Reference Deep Dive

Overview

The agent package's DTO (Data Transfer Object) layer defines the validated input and output shapes for all agent service operations. These DTOs use class-validator decorators for runtime validation, class-transformer decorators for input sanitization, and @nestjs/swagger decorators for API documentation generation. This reference covers all DTOs exported from @ever-works/agent/dto.

Architecture

DTOs sit between the API controller layer and the service layer. NestJS pipes automatically validate incoming request bodies against DTO class definitions before they reach service methods.

HTTP Request Body
|
v
ValidationPipe (class-validator)
|
v
TransformPipe (class-transformer)
|
v
DTO instance (sanitized + validated)
|
v
Service method

CreateWorkDto

Used when creating a new work manually.

Fields

FieldTypeRequiredValidationDescription
slugstringYesLowercase letters, numbers, hyphens only; regex ^[a-z0-9]+(?:-[a-z0-9]+)*$URL-friendly identifier
namestringYesMax 100 chars, sanitized via sanitizeNameDisplay name
descriptionstringYesMax 500 chars, sanitized via sanitizeDescriptionBrief description
ownerstringNoTrimmedUsername or organization for repo ownership
organizationbooleanYes--Whether the owner is an organization
gitProviderstringNoDefault: 'github', lowercasedGit provider plugin ID
deployProviderstringNoLowercasedDeploy provider (e.g., vercel)
readmeConfigMarkdownReadmeConfigDtoNoNested validationCustom README configuration

MarkdownReadmeConfigDto

FieldTypeRequiredDescription
headerstringNoCustom header content for the README
overwriteDefaultHeaderbooleanNoReplace the default header entirely
footerstringNoCustom footer content for the README
overwriteDefaultFooterbooleanNoReplace the default footer entirely

UpdateWorkDto

Used when updating work metadata.

Fields

FieldTypeRequiredDescription
namestringNoMax 100 chars
descriptionstringNoMax 500 chars
ownerstringNoRepository owner override
organizationbooleanNoOrganization flag
deployProviderstringNoDeploy provider
readmeConfigMarkdownReadmeConfigDtoNoREADME configuration
websiteTemplateAutoUpdatebooleanNoAuto-update website template
websiteTemplateUseBetabooleanNoUse beta website template
communityPrEnabledbooleanNoEnable community PR processing
communityPrAutoClosebooleanNoAuto-close processed community PRs

GenerateDataDto

Used to trigger data generation for a work.

Fields

FieldTypeRequiredDescription
slugstringYesWork slug identifier
promptstringYesGeneration prompt

ImportWorkDto

Used when importing a work from an external source.

Fields

FieldTypeRequiredDescription
sourceUrlstringYesValid URL to the source repository
sourceTypeImportSourceTypeEnumYesOne of: data_repo, awesome_readme, link_existing
namestringYesMax 100 chars, sanitized
ownerstringNoRepository owner
organizationbooleanNoOrganization flag
createMissingReposbooleanNoCreate missing markdown/website repos when linking
syncbooleanNoEnable sync schedule after import
gitProviderstringYesGit provider plugin ID
deployProviderstringNoDeploy provider
providersImportProvidersDtoNoProvider overrides (e.g., { ai: 'anthropic' })

ImportSourceTypeEnum

enum ImportSourceTypeEnum {
DATA_REPO = 'data_repo',
AWESOME_README = 'awesome_readme',
LINK_EXISTING = 'link_existing'
}

Response DTOs

AnalyzeRepositoryResponseDto -- returned by repository analysis:

FieldTypeDescription
sourceUrlstringThe analyzed URL
ownerstringRepository owner
repostringRepository name
detectedTypeImportSourceType | nullDetected repository type
isPublicbooleanWhether the repo is public
requiresAuthbooleanWhether authentication is needed
structureobjectRepository structure details (hasConfig, hasDataFolder, hasReadme, itemCount, categoryCount)
slugConflictobjectSlug conflict details if applicable
errorstringError message if analysis failed

ImportWorkResponseDto -- returned by import initiation:

FieldTypeDescription
status'pending' | 'success' | 'error'Operation status
workIdstringCreated work ID
historyIdstringGeneration history entry ID
messagestringStatus message

UpdateWorkAdvancedPromptsDto

Used to set custom AI prompts per work.

Fields

All fields are optional. null or empty strings reset the field to use the platform default.

FieldTypeMax LengthPipeline Stage
relevanceAssessmentstring | null2,000Item relevance scoring
itemGenerationstring | null2,000Item creation
itemExtractionstring | null2,000Content extraction
searchQuerystring | null2,000Search query generation
categorizationstring | null2,000Category assignment
deduplicationstring | null2,000Duplicate detection
sourceValidationstring | null2,000Source URL validation

Response DTO

WorkAdvancedPromptsResponseDto -- all fields plus workId and updatedAt (ISO string or null).

UpdateWorkScheduleDto

Used to configure scheduled work updates.

Fields

FieldTypeRequiredDescription
enablebooleanNoEnable or disable the schedule
cadenceWorkScheduleCadenceNoUpdate frequency
billingModeWorkScheduleBillingModeNoBilling mode for scheduled runs
maxFailureBeforePausenumberNoMax consecutive failures before auto-pause (1-10)
alwaysCreatePullRequestbooleanNoAlways create PRs instead of direct commits
providerOverridesProvidersDto | nullNoAI/search provider overrides for scheduled runs

WorkGenerationHistoryDto

Read-only DTO for generation history entries.

Fields

FieldTypeDescription
idstringHistory entry ID
statusGenerateStatusTypeGeneration status
generationMethodGenerationMethod | nullHow generation was triggered
startedAtstring | nullISO start timestamp
finishedAtstring | nullISO finish timestamp
durationInSecondsnumber | nullTotal duration
newItemsCountnumberItems created
updatedItemsCountnumberItems updated
totalItemsCountnumberTotal items after generation
metricsGenerationMetrics | nullToken usage and cost metrics
errorMessagestring | nullError details if failed
parametersRecord<string, any> | nullGeneration parameters
triggerRunIdstringTrigger.dev run ID

Taxonomy DTOs

CreateCategoryDto / UpdateCategoryDto

FieldTypeRequired (Create)Max LengthDescription
namestringYes100Category name, sanitized
descriptionstringNo500Category description, sanitized
icon_urlstringNo500Icon URL
prioritynumberNoMin: 0Sort priority

CreateCollectionDto / UpdateCollectionDto

Same fields as category DTOs.

CreateTagDto / UpdateTagDto

FieldTypeRequired (Create)Max LengthDescription
namestringYes50Tag name, sanitized

UpdateWebsiteSettingsDto

Configures the work website appearance and features.

Fields

FieldTypeDescription
company_namestringMax 100 chars
company_websitestringMax 200 chars
categories_enabledbooleanShow categories section
collections_enabledbooleanShow collections section
companies_enabledbooleanShow companies section
tags_enabledbooleanShow tags section
surveys_enabledbooleanEnable surveys
comparisons_enabledbooleanEnable comparisons
headerSettingsHeaderDtoHeader configuration
homepageSettingsHomepageDtoHomepage configuration
footerSettingsFooterDtoFooter configuration
custom_menuCustomMenuDtoCustom menu items (max 10 each for header/footer)

Nested Settings DTOs

SettingsHeaderDto: submit_enabled, pricing_enabled, layout_enabled, language_enabled, theme_enabled, layout_default, pagination_default, theme_default (light/dark/system)

SettingsHomepageDto: hero_enabled, search_enabled, default_view, default_sort

SettingsFooterDto: subscribe_enabled, version_enabled, theme_selector_enabled

CustomMenuItemDto: label (max 50), path (max 200), target (_self/_blank), icon (max 50)

Implementation Details

Sanitization Strategy

All DTOs use class-transformer @Transform decorators to sanitize input before validation:

  • sanitizeName(value, maxLength) -- strips control characters, collapses whitespace, trims, truncates
  • sanitizeDescription(value, maxLength) -- same as name but preserves sentence structure
  • sanitizePrompt(value, maxLength) -- strips dangerous characters while preserving prompt formatting
  • sanitizeText(value, options) -- configurable sanitization (optionally preserve newlines, spaces)

Validation Pipeline

  1. class-transformer applies @Transform decorators (sanitization)
  2. class-validator checks @Is* decorators (validation)
  3. Invalid requests receive a 400 Bad Request with detailed field-level error messages