chore: test deploy snapshot

This commit is contained in:
2026-05-29 16:11:46 +09:00
parent b242d91ecb
commit 262ce4b627
16 changed files with 2766 additions and 165 deletions

View File

@@ -256,6 +256,47 @@ type PromptPreview = NonNullable<
type PromptOption = Extract<ChatMessagePart, { type: 'prompt' }>['options'][number];
type PromptStep = NonNullable<Extract<ChatMessagePart, { type: 'prompt' }>['steps']>[number];
function normalizePromptPreviewType(typeValue: string | null | undefined, url: string, content: string) {
const normalizedType = normalizeOptionalText(typeValue).toLowerCase();
if (normalizedType === 'image' || normalizedType === 'markdown' || normalizedType === 'html' || normalizedType === 'resource') {
return normalizedType;
}
if (normalizedType === 'md' || normalizedType === 'text' || normalizedType === 'txt' || normalizedType === 'plain') {
return 'markdown';
}
if (normalizedType === 'htm') {
return 'html';
}
const normalizedContent = normalizeOptionalText(content).trim();
const normalizedUrl = normalizeOptionalText(url).toLowerCase();
if (normalizedUrl.endsWith('.md') || normalizedUrl.endsWith('.markdown')) {
return 'markdown';
}
if (normalizedUrl.endsWith('.html') || normalizedUrl.endsWith('.htm')) {
return 'html';
}
if (!normalizedContent) {
return null;
}
if (/<(?:!doctype\s+html|html|head|body|main|section|article|div)\b/i.test(normalizedContent)) {
return 'html';
}
if (/^#{1,6}\s|^\s*[-*+]\s+|^\s*\d+\.\s+|^\s*>\s+|\[[^\]]+\]\([^)]+\)/m.test(normalizedContent)) {
return 'markdown';
}
return 'resource';
}
function normalizePromptPreview(
preview: {
type?: string | null;
@@ -269,9 +310,9 @@ function normalizePromptPreview(
return null;
}
const type = preview.type === 'image' || preview.type === 'markdown' || preview.type === 'html' || preview.type === 'resource'
? preview.type
: null;
const normalizedUrl = normalizeOptionalText(preview.url);
const normalizedContent = normalizeOptionalText(preview.content);
const type = normalizePromptPreviewType(preview.type, normalizedUrl, normalizedContent);
if (!type) {
return null;
@@ -279,8 +320,8 @@ function normalizePromptPreview(
return {
type,
url: normalizeOptionalText(preview.url),
content: normalizeOptionalText(preview.content),
url: normalizedUrl,
content: normalizedContent,
alt: normalizeOptionalText(preview.alt),
title: normalizeOptionalText(preview.title),
};