MCPcopy Create free account
hub / github.com/agent-tower/core / normalizeCreateTaskInput

Function normalizeCreateTaskInput

packages/server/src/services/task.service.ts:128–148  ·  view source on GitHub ↗
(input: CreateTaskInput)

Source from the content-addressed store, hash-verified

126
127function mergeDescriptionParts(parts: Array<string | null | undefined>): string | undefined {
128 const merged: string[] = [];
129 const seen = new Set<string>();
130 for (const part of parts) {
131 const trimmed = part?.trim();
132 if (!trimmed || seen.has(trimmed)) {
133 continue;
134 }
135 merged.push(part!);
136 seen.add(trimmed);
137 }
138 return merged.length > 0 ? merged.join('\n\n') : undefined;
139}
140
141function normalizeCreateTaskInput(input: CreateTaskInput): Required<Pick<CreateTaskInput, 'title'>> & Pick<CreateTaskInput, 'description' | 'priority'> {
142 const rawTitle = input.title;
143 const compactTitle = compactWhitespace(rawTitle);
144 if (compactTitle.length === 0) {
145 throw new ValidationError('Task title is required');
146 }
147
148 if (!needsBodySplit(rawTitle, compactTitle)) {
149 return {
150 title: normalizeTaskTitle(rawTitle),
151 description: input.description,

Callers 1

createMethod · 0.85

Calls 5

needsBodySplitFunction · 0.85
normalizeTaskTitleFunction · 0.85
deriveTitleFromBodyFunction · 0.85
mergeDescriptionPartsFunction · 0.85
compactWhitespaceFunction · 0.70

Tested by

no test coverage detected