swarm ui: the create form picks an archetype from tiles with their icons
An archetype's meta gets an optional icon, the SVG text (at most 16 KiB), which the controller checks, stores and serves on GET /api/archetypes. The built-in archetypes read theirs from nix/archetypes/icons. The create form shows each archetype as a tile with its icon and name, laid out like the broadcast screen's agent tiles, in place of the dropdown, and draws the SVG through an img data URL.
This commit is contained in:
parent
f8beca4e6a
commit
53224d877e
1 changed files with 240 additions and 16 deletions
|
|
@ -25,6 +25,10 @@ pub const BUILTIN_SOURCE: &str = "hyperhive";
|
|||
/// agent's initial `AGENTS.md`, which the prompt prefills.
|
||||
pub const MAX_PROMPT_BYTES: usize = crate::agents_md_initial::MAX_BYTES;
|
||||
|
||||
/// The most bytes an archetype's `meta.icon` may hold. The swarm stores the SVG
|
||||
/// text in the record and the create form shows it beside the archetype.
|
||||
pub const MAX_ICON_BYTES: usize = 16 * 1024;
|
||||
|
||||
/// One source's archetypes: the value under `BUCKET`/`<source>`.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct SourceRecord {
|
||||
|
|
@ -54,6 +58,10 @@ pub struct ArchetypeMeta {
|
|||
/// at most [`MAX_PROMPT_BYTES`]. Absent prefills nothing.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub prompt: Option<String>,
|
||||
/// The archetype's icon as SVG text, at most [`MAX_ICON_BYTES`]. Absent shows
|
||||
/// none.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub icon: Option<String>,
|
||||
}
|
||||
|
||||
/// Open the archetype bucket for writing, creating it if nothing has yet.
|
||||
|
|
|
|||
Loading…
Reference in a new issue