fix: kimi video never reached the files API
useFilesApi=kimi parks video in a faked tool response's output._media, but
prepareMedia/uploadMedia only walked the top level of msg.content. The upload
never ran, so filesApiMemoized was never set and translateContent fell through
to the base64 fallback — a data: URL where an ms:// reference belonged.
uploadKimiFile was unreachable in the only mode that calls it.
Add toolResponseMedia() as the one accessor for the nested array, and
flattenContentParts() so both media passes reach it. The strip pass now runs
before encode/upload rather than after, so videos on their way to the bin
don't burn an upload per turn.
Serialization had the same blind spot: JSON.stringify wrote the raw Uint8Array
out as {"0":26,"1":153,…}, megabytes of numbered keys that came back as untyped
objects and hit translateContent's Unreachable throw. Reduce _media to refs on
save and resolve them on load, so a restored video has bytes to upload.
ms:// handles expire server-side, so filesApiMemoized carries an uploadedAt and
anything past FilesApiHandleTtl is re-uploaded rather than gambled on. The
15-minute window is a guess — the API returns no expiry. L
Lys committed
5c7ad298a847f498b6150a59e24ed98640dbfbfa
Parent: ee8e8ce