feat: complete M3 runtime snapshot and profile save archive

This commit is contained in:
2026-04-22 13:22:23 +08:00
parent 997a8daada
commit 209e924403
340 changed files with 9878 additions and 4429 deletions

View File

@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
pub const RUNTIME_PLATFORM_THEME_LIGHT: &str = "light";
pub const RUNTIME_PLATFORM_THEME_DARK: &str = "dark";
pub const SAVE_SNAPSHOT_VERSION: u32 = 2;
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_SNAPSHOT_SYNC: &str = "snapshot_sync";
pub const BROWSE_HISTORY_THEME_MODE_MARTIAL: &str = "martial";
pub const BROWSE_HISTORY_THEME_MODE_ARCANE: &str = "arcane";
@@ -26,6 +27,33 @@ pub struct PutRuntimeSettingsRequest {
pub platform_theme: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct SavedGameSnapshotResponse {
pub version: u32,
pub saved_at: String,
pub game_state: serde_json::Value,
pub bottom_tab: String,
pub current_story: Option<serde_json::Value>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PutSavedGameSnapshotRequest {
pub game_state: serde_json::Value,
pub bottom_tab: String,
#[serde(default)]
pub current_story: Option<serde_json::Value>,
#[serde(default)]
pub saved_at: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct BasicOkResponse {
pub ok: bool,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PlatformBrowseHistoryEntryResponse {
@@ -135,6 +163,33 @@ pub struct ProfilePlayStatsResponse {
pub updated_at: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProfileSaveArchiveSummaryResponse {
pub world_key: String,
pub owner_user_id: Option<String>,
pub profile_id: Option<String>,
pub world_type: Option<String>,
pub world_name: String,
pub subtitle: String,
pub summary_text: String,
pub cover_image_src: Option<String>,
pub last_played_at: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProfileSaveArchiveListResponse {
pub entries: Vec<ProfileSaveArchiveSummaryResponse>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProfileSaveArchiveResumeResponse {
pub entry: ProfileSaveArchiveSummaryResponse,
pub snapshot: SavedGameSnapshotResponse,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct RuntimeInventorySlotResponse {
@@ -234,6 +289,43 @@ pub struct CustomWorldGalleryDetailResponse {
pub entry: CustomWorldLibraryEntryResponse,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldWorkSummaryResponse {
pub work_id: String,
pub source_type: String,
pub status: String,
pub title: String,
pub subtitle: String,
pub summary: String,
pub cover_image_src: Option<String>,
#[serde(default)]
pub cover_render_mode: Option<String>,
#[serde(default)]
pub cover_character_image_srcs: Vec<String>,
pub updated_at: String,
pub published_at: Option<String>,
pub stage: Option<String>,
pub stage_label: Option<String>,
pub playable_npc_count: u32,
pub landmark_count: u32,
pub role_visual_ready_count: Option<u32>,
pub role_animation_ready_count: Option<u32>,
pub role_asset_summary_label: Option<String>,
pub session_id: Option<String>,
pub profile_id: Option<String>,
pub can_resume: bool,
pub can_enter_world: bool,
pub blocker_count: u32,
pub publish_ready: bool,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldWorksResponse {
pub items: Vec<CustomWorldWorkSummaryResponse>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CreateCustomWorldAgentSessionRequest {
@@ -293,6 +385,36 @@ pub struct CustomWorldDraftCardSummaryResponse {
pub asset_status_label: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldDraftCardDetailSectionResponse {
pub id: String,
pub label: String,
pub value: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldDraftCardDetailResponse {
pub id: String,
pub kind: String,
pub title: String,
pub sections: Vec<CustomWorldDraftCardDetailSectionResponse>,
pub linked_ids: Vec<String>,
pub locked: bool,
pub editable: bool,
pub editable_section_ids: Vec<String>,
pub warning_messages: Vec<String>,
pub asset_status: Option<String>,
pub asset_status_label: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldAgentCardDetailResponse {
pub card: CustomWorldDraftCardDetailResponse,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldAgentCheckpointResponse {
@@ -309,6 +431,24 @@ pub struct CustomWorldSupportedActionResponse {
pub reason: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldResultPreviewBlockerResponse {
pub id: String,
pub code: String,
pub message: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldPublishGateResponse {
pub profile_id: String,
pub blockers: Vec<CustomWorldResultPreviewBlockerResponse>,
pub blocker_count: u32,
pub publish_ready: bool,
pub can_enter_world: bool,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CustomWorldAgentSessionSnapshotResponse {
@@ -333,6 +473,7 @@ pub struct CustomWorldAgentSessionSnapshotResponse {
pub asset_coverage: serde_json::Value,
pub checkpoints: Vec<CustomWorldAgentCheckpointResponse>,
pub supported_actions: Vec<CustomWorldSupportedActionResponse>,
pub publish_gate: Option<CustomWorldPublishGateResponse>,
pub result_preview: Option<serde_json::Value>,
pub updated_at: String,
}
@@ -343,6 +484,67 @@ pub struct CustomWorldAgentSessionResponse {
pub session: CustomWorldAgentSessionSnapshotResponse,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ExecuteCustomWorldAgentActionRequest {
pub action: String,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub draft_profile: Option<serde_json::Value>,
#[serde(default)]
pub legacy_result_profile: Option<serde_json::Value>,
#[serde(default)]
pub setting_text: Option<String>,
#[serde(default)]
pub card_id: Option<String>,
#[serde(default)]
pub sections: Option<Vec<ExecuteCustomWorldAgentDraftCardSectionPatch>>,
#[serde(default)]
pub profile: Option<serde_json::Value>,
#[serde(default)]
pub count: Option<u32>,
#[serde(default)]
pub prompt_text: Option<String>,
#[serde(default)]
pub anchor_card_ids: Option<Vec<String>>,
#[serde(default)]
pub role_ids: Option<Vec<String>>,
#[serde(default)]
pub role_id: Option<String>,
#[serde(default)]
pub portrait_path: Option<String>,
#[serde(default)]
pub generated_visual_asset_id: Option<String>,
#[serde(default)]
pub generated_animation_set_id: Option<String>,
#[serde(default)]
pub animation_map: Option<serde_json::Value>,
#[serde(default)]
pub scene_ids: Option<Vec<String>>,
#[serde(default)]
pub scene_id: Option<String>,
#[serde(default)]
pub scene_kind: Option<String>,
#[serde(default)]
pub image_src: Option<String>,
#[serde(default)]
pub generated_scene_asset_id: Option<String>,
#[serde(default)]
pub generated_scene_prompt: Option<String>,
#[serde(default)]
pub generated_scene_model: Option<String>,
#[serde(default)]
pub checkpoint_id: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ExecuteCustomWorldAgentDraftCardSectionPatch {
pub section_id: String,
pub value: String,
}
#[cfg(test)]
mod tests {
use super::*;