(inputJson: string)
| 149 | } |
| 150 | |
| 151 | export function parseTaskInputJson(inputJson: string): ParsedTaskPayload { |
| 152 | try { |
| 153 | const parsed = JSON.parse(inputJson) as Record<string, unknown>; |
| 154 | return { |
| 155 | taskId: typeof parsed.taskId === "string" ? parsed.taskId : undefined, |
| 156 | assignee: typeof parsed.assignee === "string" ? parsed.assignee : undefined, |
| 157 | title: typeof parsed.title === "string" ? parsed.title : undefined, |
| 158 | channel: typeof parsed.channel === "string" ? parsed.channel : undefined, |
| 159 | priority: typeof parsed.priority === "string" ? parsed.priority : undefined, |
| 160 | contactId: typeof parsed.contactId === "string" ? parsed.contactId : undefined, |
| 161 | channelName: typeof parsed.channelName === "string" ? parsed.channelName : undefined, |
| 162 | channelMessage: typeof parsed.channelMessage === "string" ? parsed.channelMessage : undefined, |
| 163 | externalInput: parseExternalInputPayload(parsed.externalInput), |
| 164 | sourceChannel: typeof parsed.sourceChannel === "string" ? parsed.sourceChannel : undefined, |
| 165 | sourceMessageId: typeof parsed.sourceMessageId === "string" ? parsed.sourceMessageId : undefined, |
| 166 | sourceTaskQueueId: typeof parsed.sourceTaskQueueId === "string" ? parsed.sourceTaskQueueId : undefined, |
| 167 | mentionSource: typeof parsed.mentionSource === "string" ? parsed.mentionSource : undefined, |
| 168 | initiatorAgentId: typeof parsed.initiatorAgentId === "string" ? parsed.initiatorAgentId : undefined, |
| 169 | mentionCascadeDepth: typeof parsed.mentionCascadeDepth === "number" && Number.isFinite(parsed.mentionCascadeDepth) |
| 170 | ? parsed.mentionCascadeDepth |
| 171 | : undefined, |
| 172 | mentionRootMessageId: typeof parsed.mentionRootMessageId === "string" ? parsed.mentionRootMessageId : undefined, |
| 173 | orchestrationRunId: typeof parsed.orchestrationRunId === "string" ? parsed.orchestrationRunId : undefined, |
| 174 | orchestrationStepId: typeof parsed.orchestrationStepId === "string" ? parsed.orchestrationStepId : undefined, |
| 175 | stepInstruction: typeof parsed.stepInstruction === "string" ? parsed.stepInstruction : undefined, |
| 176 | stepDependsOnIds: Array.isArray(parsed.stepDependsOnIds) |
| 177 | ? parsed.stepDependsOnIds.filter((item): item is string => typeof item === "string") |
| 178 | : undefined, |
| 179 | stepHandoffKind: typeof parsed.stepHandoffKind === "string" ? parsed.stepHandoffKind : undefined, |
| 180 | handoffDocumentIds: Array.isArray(parsed.handoffDocumentIds) |
| 181 | ? parsed.handoffDocumentIds.filter((item): item is string => typeof item === "string") |
| 182 | : undefined, |
| 183 | handoffDocumentVersionIds: Array.isArray(parsed.handoffDocumentVersionIds) |
| 184 | ? parsed.handoffDocumentVersionIds.filter((item): item is string => typeof item === "string") |
| 185 | : undefined, |
| 186 | autoContinuation: parseAutoContinuationPayload(parsed.autoContinuation), |
| 187 | mentionType: typeof parsed.mentionType === "string" ? parsed.mentionType : undefined, |
| 188 | mentionedAgentIds: Array.isArray(parsed.mentionedAgentIds) |
| 189 | ? parsed.mentionedAgentIds.filter((item): item is string => typeof item === "string") |
| 190 | : undefined, |
| 191 | mentionedAgentLabels: Array.isArray(parsed.mentionedAgentLabels) |
| 192 | ? parsed.mentionedAgentLabels.filter((item): item is string => typeof item === "string") |
| 193 | : undefined, |
| 194 | assigneeMentionToken: typeof parsed.assigneeMentionToken === "string" ? parsed.assigneeMentionToken : undefined, |
| 195 | channelHistory: Array.isArray(parsed.channelHistory) |
| 196 | ? parsed.channelHistory |
| 197 | .filter( |
| 198 | ( |
| 199 | item, |
| 200 | ): item is { |
| 201 | speaker: string; |
| 202 | role?: string; |
| 203 | summary: string; |
| 204 | time?: string; |
| 205 | status?: string; |
| 206 | kind?: string; |
| 207 | processType?: string; |
| 208 | mentions?: string[]; |
no test coverage detected