import { useEffect, useState } from "react" import { OpenAPI } from "@/client" import { apiToken } from "@/lib/portal" import { cn } from "@/lib/utils" import { useBoundValue } from "./dataContext" import { config, text } from "./ui/core/config" import type { WidgetProps } from "./widgets" /** An artifact reference, as a message carries one. */ type MediaRef = { digest?: string media_type?: string name?: string size?: number } const isRef = (value: unknown): value is MediaRef => typeof value === "object" && value !== null && typeof (value as MediaRef).digest === "string" && (value as MediaRef).digest!.startsWith("sha256:") /** * A local URL for an artifact's bytes, refreshed whenever the digest changes. * * Not the endpoint itself: `/artifacts/{digest}` takes a bearer token, and no * `` or `