summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/message-file.ts
blob: ecc74569022eec2919ee6950824cc98ba7077b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import type { FilePart } from "@opencode-ai/sdk/v2"

export function attached(part: FilePart) {
  return part.url.startsWith("data:")
}

export function inline(part: FilePart) {
  if (attached(part)) return false
  return part.source?.text?.start !== undefined && part.source?.text?.end !== undefined
}

export function kind(part: FilePart) {
  return part.mime.startsWith("image/") ? "image" : "file"
}