refactor(agent-attachments): use agent image mime types directly

This commit is contained in:
777genius 2026-05-26 23:41:46 +03:00
parent a7ed38e167
commit 1cae11da34
3 changed files with 8 additions and 10 deletions

View file

@ -1,7 +1,7 @@
import type {
AgentAttachmentCapability,
AgentAttachmentCapabilityTarget,
ProviderImageMimeType,
AgentImageMimeType,
} from './types';
const DEFAULT_IMAGE_BYTES_PER_PROVIDER = 4 * 1024 * 1024;
@ -18,7 +18,7 @@ export const CLAUDE_IMAGE_MIME_TYPES = [
function supportedImagesOnly(
displayText: string,
supportedImageMimeTypes: readonly ProviderImageMimeType[] = NATIVE_IMAGE_MIME_TYPES
supportedImageMimeTypes: readonly AgentImageMimeType[] = NATIVE_IMAGE_MIME_TYPES
): AgentAttachmentCapability {
return {
supportsImages: true,

View file

@ -3,7 +3,6 @@ export const AGENT_ATTACHMENT_SCHEMA_VERSION = 1 as const;
export type AgentAttachmentKind = 'image' | 'file' | 'unsupported';
export type AgentImageMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
export type ProviderImageMimeType = AgentImageMimeType;
export type ProviderFileMimeType = 'application/pdf' | 'text/*';
export type AttachmentDeliveryFailureCode =
@ -98,7 +97,7 @@ export interface AgentAttachmentCapabilityTarget {
export interface AgentAttachmentCapability {
supportsImages: boolean;
supportsFiles: boolean;
supportedImageMimeTypes: ProviderImageMimeType[];
supportedImageMimeTypes: AgentImageMimeType[];
supportedFileMimeTypes: ProviderFileMimeType[];
maxImages: number;
maxFiles: number;

View file

@ -7,7 +7,6 @@ import type {
AgentImageMimeType,
AttachmentValidationResult,
ImageOptimizationBudget,
ProviderImageMimeType,
} from './types';
const AGENT_IMAGE_MIME_TYPES = new Set<AgentImageMimeType>([
@ -23,7 +22,7 @@ const OPTIMIZABLE_AGENT_IMAGE_MIME_TYPES = new Set<Exclude<AgentImageMimeType, '
'image/webp',
]);
const PROVIDER_IMAGE_MIME_TYPES = new Set<ProviderImageMimeType>([
const PROVIDER_IMAGE_MIME_TYPES = new Set<AgentImageMimeType>([
'image/png',
'image/jpeg',
'image/gif',
@ -34,8 +33,8 @@ export function isAgentImageMimeType(mimeType: string): mimeType is AgentImageMi
return AGENT_IMAGE_MIME_TYPES.has(mimeType as AgentImageMimeType);
}
export function isProviderImageMimeType(mimeType: string): mimeType is ProviderImageMimeType {
return PROVIDER_IMAGE_MIME_TYPES.has(mimeType as ProviderImageMimeType);
export function isProviderImageMimeType(mimeType: string): mimeType is AgentImageMimeType {
return PROVIDER_IMAGE_MIME_TYPES.has(mimeType as AgentImageMimeType);
}
function isOptimizableAgentImageMimeType(
@ -54,9 +53,9 @@ function isProviderFileMimeType(mimeType: string, supported: readonly string[]):
function isCapabilityImageMimeType(
mimeType: string,
supported: readonly ProviderImageMimeType[]
supported: readonly AgentImageMimeType[]
): boolean {
return supported.includes(mimeType as ProviderImageMimeType);
return supported.includes(mimeType as AgentImageMimeType);
}
export function classifyAttachmentMime(mimeType: string): AgentAttachmentKind {