feat(sagi): custom pets — Codex pet bundles, images, featured downloads

The mascot can wear a pet. Right-click it for Hide pet, Size (48-250
px), Choose pet (Sagi, featured, your own - deletable), Upload your
own..., Import .codex-pet bundle..., Find more on codex-pets.net and
Pet settings.... The worn pet and its size are viewer prefs
(agenthub.pet, agenthub.pet.size); the pets live on the server under
<data dir>/pets/<id>/ (server/lib/pets.js, /api/pets).

A Codex pet is the .codex-pet.zip format: pet.json + a 1536x1872
spritesheet.webp, 8x9 frames of 192x208, one row per state.
PetSprite.tsx plays the row of the mascot's mood; an uploaded image
bobs. Only the two bundle files are read, sizes are checked from the
zip directory before inflating, the sheet's WebP header must match,
uploads are raster only (no SVG), ids are made by the server, every
write is same-origin.

The four featured pets (Goku, Bac Ho, Border Collie, 11) are
codex-pets.net uploads with no redistribution licence, so none is
bundled: a pick downloads it from codex-pets.net by a fixed id.
This commit is contained in:
2026-10-03 16:25:42 +07:00
parent 8098f446b6
commit ed1bf20e6b
18 changed files with 1615 additions and 55 deletions
+34
View File
@@ -369,3 +369,37 @@
.sagi-bubble.sagi-no-anim {
animation: none;
}
/* ════════ a custom pet (PetSprite.tsx) ════════ */
/* An uploaded still image has no frames of its own: it bobs, faster while an
agent works and slower asleep. A Codex spritesheet animates by its frames. */
.sagi-pet-image {
animation: sagi-pet-bob 2.6s ease-in-out infinite;
-webkit-user-drag: none;
}
.sagi-pet-image[data-mood="thinking"] {
animation-duration: 0.9s;
}
.sagi-pet-image[data-mood="sleeping"] {
animation-duration: 5s;
}
@keyframes sagi-pet-bob {
0%,
100% {
transform: translateY(0);
}
50% {
transform: translateY(-4%);
}
}
@media (prefers-reduced-motion: reduce) {
.sagi-pet-image {
animation: none;
}
}
/* The pet menu may overlap the mascot; it sits above it while open. */
.sagi-flyout[data-front="1"] {
z-index: 42;
}