Skip to main content

agentbin_core/
metadata.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5/// Well-known agent fields included in upload metadata.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct AgentInfo {
8    pub model: Option<String>,
9    pub provider: Option<String>,
10    pub tool: Option<String>,
11}
12
13/// Per-upload metadata containing well-known fields and arbitrary custom fields.
14#[derive(Debug, Clone, Default, Serialize, Deserialize)]
15pub struct Metadata {
16    pub title: Option<String>,
17    pub description: Option<String>,
18    #[serde(default)]
19    pub tags: Vec<String>,
20    pub agent: Option<AgentInfo>,
21    pub trigger: Option<String>,
22    #[serde(default)]
23    pub custom: HashMap<String, String>,
24}
25
26/// Full version metadata stored in `meta.json` alongside each uploaded file version.
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct VersionMeta {
29    pub version: u32,
30    pub filename: String,
31    pub content_type: String,
32    pub size_bytes: u64,
33    pub uploaded_at: DateTime<Utc>,
34    pub uploaded_by: String,
35    pub expires_at: Option<DateTime<Utc>>,
36    pub metadata: Metadata,
37}
38
39/// Top-level upload record stored in `upload.json`.
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct UploadRecord {
42    pub uid: String,
43    pub owner: String,
44    pub collection: Option<String>,
45    pub latest_version: u32,
46    pub created_at: DateTime<Utc>,
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub slug: Option<String>,
49}
50
51/// A single member entry within a collection.
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct CollectionMember {
54    pub uid: String,
55    pub added_at: DateTime<Utc>,
56}
57
58/// Collection record stored in `collections/{name}.json`.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct CollectionRecord {
61    pub name: String,
62    pub members: Vec<CollectionMember>,
63    pub created_at: DateTime<Utc>,
64}
65
66/// A single user entry within the users config.
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct UserRecord {
69    pub public_key: String,
70    pub display_name: Option<String>,
71    pub is_admin: bool,
72    pub created_at: DateTime<Utc>,
73}
74
75/// Full users config stored in `users.json`.
76#[derive(Debug, Clone, Serialize, Deserialize)]
77pub struct UsersConfig {
78    pub users: HashMap<String, UserRecord>,
79}