Files
deepseek-harness/packages/fs/tool-fs/src/image-error.ts
T
sjw1231 abbb742d19 refactor(tool-fs): use MODEL_DOES_NOT_SUPPORT_IMAGES for read_image model refusals
The subagent attachment path, session-controller, and client labels already
name this failure MODEL_DOES_NOT_SUPPORT_IMAGES. Rename the unreleased
ImageInputError code IMAGE_UNSUPPORTED_MODEL so one fact has one code.

Refs #7869
2026-11-09 17:44:48 +08:00

37 lines
1.4 KiB
TypeScript

/** Typed `read_image` failures. @module @deepseek-ai/dsh-tool-fs/src/image-error */
import { HarnessError } from '@deepseek-ai/dsh-error'
/**
* Every `read_image` failure the tool classifies itself, before the attachment store sees the bytes:
*
* - `MODEL_DOES_NOT_SUPPORT_IMAGES`: the calling route does not declare image input; switch to an image-capable model.
* - `IMAGE_UNSUPPORTED_FORMAT`: the extension, the file signature, or the deployment's accepted media types
* exclude the format; convert the file to an accepted format or read another file.
*
* Failures the attachment store classifies keep their `AttachmentError` codes.
*/
export const IMAGE_INPUT_ERROR_CODES = [
'MODEL_DOES_NOT_SUPPORT_IMAGES',
'IMAGE_UNSUPPORTED_FORMAT',
] as const
/** One `read_image` failure code. */
export type ImageInputErrorCode = typeof IMAGE_INPUT_ERROR_CODES[number]
/** Typed `read_image` failure; `code` is one of {@link IMAGE_INPUT_ERROR_CODES}. */
export class ImageInputError extends HarnessError {
override readonly code: ImageInputErrorCode
/**
* @param message - model-facing refusal naming the path and the safe next step.
* @param code - stable failure code.
* @param options - standard `cause` chaining.
*/
constructor(message: string, code: ImageInputErrorCode, options?: ErrorOptions) {
super(message, code, options)
this.name = 'ImageInputError'
this.code = code
}
}