This commit is contained in:
2026-05-08 11:44:42 +08:00
parent b08127031c
commit abf1f1ebea
249 changed files with 39411 additions and 887 deletions

View File

@@ -1672,6 +1672,118 @@ pub(crate) fn map_square_hole_drop_shape_procedure_result(
})
}
pub(crate) fn map_visual_novel_agent_session_procedure_result(
result: VisualNovelAgentSessionProcedureResult,
) -> Result<VisualNovelAgentSessionRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let session_json = result
.session_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel agent session 快照"))?;
let session =
serde_json::from_str::<VisualNovelAgentSessionJsonRecord>(&session_json).map_err(
|error| {
SpacetimeClientError::Runtime(format!(
"visual novel session_json 非法: {error}"
))
},
)?;
Ok(map_visual_novel_agent_session_snapshot(session))
}
pub(crate) fn map_visual_novel_work_procedure_result(
result: VisualNovelWorkProcedureResult,
) -> Result<VisualNovelWorkProfileRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let work_json = result
.work_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel work 快照"))?;
let work = serde_json::from_str::<VisualNovelWorkJsonRecord>(&work_json).map_err(|error| {
SpacetimeClientError::Runtime(format!("visual novel work_json 非法: {error}"))
})?;
Ok(map_visual_novel_work_snapshot(work))
}
pub(crate) fn map_visual_novel_works_procedure_result(
result: VisualNovelWorksProcedureResult,
) -> Result<Vec<VisualNovelWorkProfileRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let items_json = result
.items_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel works 快照"))?;
let items = serde_json::from_str::<Vec<VisualNovelWorkJsonRecord>>(&items_json).map_err(
|error| {
SpacetimeClientError::Runtime(format!("visual novel works items_json 非法: {error}"))
},
)?;
Ok(items.into_iter().map(map_visual_novel_work_snapshot).collect())
}
pub(crate) fn map_visual_novel_run_procedure_result(
result: VisualNovelRunProcedureResult,
) -> Result<VisualNovelRunRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let run_json = result
.run_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel run 快照"))?;
let run = serde_json::from_str::<VisualNovelRunJsonRecord>(&run_json).map_err(|error| {
SpacetimeClientError::Runtime(format!("visual novel run_json 非法: {error}"))
})?;
Ok(map_visual_novel_run_snapshot(run))
}
pub(crate) fn map_visual_novel_history_procedure_result(
result: VisualNovelHistoryProcedureResult,
) -> Result<Vec<VisualNovelHistoryEntryRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let items_json = result
.items_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel history 快照"))?;
let items = serde_json::from_str::<Vec<VisualNovelHistoryEntryJsonRecord>>(&items_json)
.map_err(|error| {
SpacetimeClientError::Runtime(format!("visual novel history items_json 非法: {error}"))
})?;
Ok(items.into_iter().map(map_visual_novel_history_entry).collect())
}
pub(crate) fn map_visual_novel_runtime_event_procedure_result(
result: VisualNovelRuntimeEventProcedureResult,
) -> Result<VisualNovelRuntimeEventRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let event_json = result
.event_json
.ok_or_else(|| SpacetimeClientError::missing_snapshot("visual novel runtime event 快照"))?;
let event = serde_json::from_str::<VisualNovelRuntimeEventJsonRecord>(&event_json).map_err(
|error| {
SpacetimeClientError::Runtime(format!("visual novel event_json 非法: {error}"))
},
)?;
Ok(map_visual_novel_runtime_event(event))
}
pub(crate) fn map_story_session_procedure_result(
result: StorySessionProcedureResult,
) -> Result<StorySessionResultRecord, SpacetimeClientError> {
@@ -2667,6 +2779,7 @@ pub(crate) fn map_puzzle_draft_level(snapshot: DomainPuzzleDraftLevel) -> Puzzle
level_id: snapshot.level_id,
level_name: snapshot.level_name,
picture_description: snapshot.picture_description,
picture_reference: snapshot.picture_reference,
candidates: snapshot
.candidates
.into_iter()
@@ -3175,6 +3288,127 @@ fn build_square_hole_anchor_item(
}
}
fn map_visual_novel_agent_session_snapshot(
snapshot: VisualNovelAgentSessionJsonRecord,
) -> VisualNovelAgentSessionRecord {
VisualNovelAgentSessionRecord {
session_id: snapshot.session_id,
owner_user_id: snapshot.owner_user_id,
source_mode: snapshot.source_mode,
status: snapshot.status,
seed_text: snapshot.seed_text,
source_asset_ids: snapshot.source_asset_ids,
current_turn: snapshot.current_turn,
progress_percent: snapshot.progress_percent,
messages: snapshot
.messages
.into_iter()
.map(map_visual_novel_agent_message)
.collect(),
draft: snapshot.draft,
pending_action: snapshot.pending_action,
last_assistant_reply: snapshot.last_assistant_reply,
published_profile_id: snapshot.published_profile_id,
created_at: format_timestamp_micros(snapshot.created_at_micros),
updated_at: format_timestamp_micros(snapshot.updated_at_micros),
}
}
fn map_visual_novel_agent_message(
snapshot: VisualNovelAgentMessageJsonRecord,
) -> VisualNovelAgentMessageRecord {
VisualNovelAgentMessageRecord {
message_id: snapshot.message_id,
session_id: snapshot.session_id,
role: snapshot.role,
kind: snapshot.kind,
text: snapshot.text,
created_at: format_timestamp_micros(snapshot.created_at_micros),
}
}
fn map_visual_novel_work_snapshot(
snapshot: VisualNovelWorkJsonRecord,
) -> VisualNovelWorkProfileRecord {
VisualNovelWorkProfileRecord {
work_id: snapshot.work_id,
profile_id: snapshot.profile_id,
owner_user_id: snapshot.owner_user_id,
source_session_id: snapshot.source_session_id,
author_display_name: snapshot.author_display_name,
work_title: snapshot.work_title,
work_description: snapshot.work_description,
tags: snapshot.tags,
cover_image_src: snapshot.cover_image_src,
source_asset_ids: snapshot.source_asset_ids,
draft: snapshot.draft,
publication_status: snapshot.publication_status,
publish_ready: snapshot.publish_ready,
play_count: snapshot.play_count,
created_at: format_timestamp_micros(snapshot.created_at_micros),
updated_at: format_timestamp_micros(snapshot.updated_at_micros),
published_at: snapshot.published_at_micros.map(format_timestamp_micros),
}
}
fn map_visual_novel_run_snapshot(snapshot: VisualNovelRunJsonRecord) -> VisualNovelRunRecord {
VisualNovelRunRecord {
run_id: snapshot.run_id,
owner_user_id: snapshot.owner_user_id,
profile_id: snapshot.profile_id,
mode: snapshot.mode,
status: snapshot.status,
current_scene_id: snapshot.current_scene_id,
current_phase_id: snapshot.current_phase_id,
visible_character_ids: snapshot.visible_character_ids,
flags: snapshot.flags,
metrics: snapshot.metrics,
history: snapshot
.history
.into_iter()
.map(map_visual_novel_history_entry)
.collect(),
available_choices: snapshot.available_choices,
text_mode_enabled: snapshot.text_mode_enabled,
created_at: format_timestamp_micros(snapshot.created_at_micros),
updated_at: format_timestamp_micros(snapshot.updated_at_micros),
}
}
fn map_visual_novel_history_entry(
snapshot: VisualNovelHistoryEntryJsonRecord,
) -> VisualNovelHistoryEntryRecord {
VisualNovelHistoryEntryRecord {
entry_id: snapshot.entry_id,
run_id: snapshot.run_id,
owner_user_id: snapshot.owner_user_id,
profile_id: snapshot.profile_id,
turn_index: snapshot.turn_index,
source: snapshot.source,
action_text: snapshot.action_text,
steps: snapshot.steps,
snapshot_before_hash: snapshot.snapshot_before_hash,
snapshot_after_hash: snapshot.snapshot_after_hash,
created_at: format_timestamp_micros(snapshot.created_at_micros),
}
}
fn map_visual_novel_runtime_event(
snapshot: VisualNovelRuntimeEventJsonRecord,
) -> VisualNovelRuntimeEventRecord {
VisualNovelRuntimeEventRecord {
event_id: snapshot.event_id,
run_id: snapshot.run_id,
owner_user_id: snapshot.owner_user_id,
profile_id: snapshot.profile_id,
event_kind: snapshot.event_kind,
client_event_id: snapshot.client_event_id,
history_entry_id: snapshot.history_entry_id,
payload: snapshot.payload,
occurred_at: format_timestamp_micros(snapshot.occurred_at_micros),
}
}
fn normalize_match3d_stage(value: &str) -> &str {
match value {
"Collecting" | "collecting" | "collecting_config" => "collecting_config",
@@ -6105,6 +6339,323 @@ pub struct SquareHoleRunTimeUpRecordInput {
pub finished_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelAgentSessionCreateRecordInput {
pub session_id: String,
pub owner_user_id: String,
pub source_mode: String,
pub seed_text: String,
pub source_asset_ids_json: String,
pub welcome_message_id: String,
pub welcome_message_text: String,
pub draft_json: Option<String>,
pub created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelAgentMessageSubmitRecordInput {
pub session_id: String,
pub owner_user_id: String,
pub user_message_id: String,
pub user_message_text: String,
pub submitted_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelAgentMessageFinalizeRecordInput {
pub session_id: String,
pub owner_user_id: String,
pub assistant_message_id: Option<String>,
pub assistant_reply_text: Option<String>,
pub draft_json: Option<String>,
pub pending_action_json: Option<String>,
pub status: String,
pub progress_percent: u32,
pub updated_at_micros: i64,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelWorkCompileRecordInput {
pub session_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub work_id: Option<String>,
pub author_display_name: String,
pub work_title: Option<String>,
pub work_description: Option<String>,
pub tags_json: Option<String>,
pub cover_image_src: Option<String>,
pub compiled_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelWorkUpdateRecordInput {
pub profile_id: String,
pub owner_user_id: String,
pub work_title: String,
pub work_description: String,
pub tags_json: String,
pub cover_image_src: Option<String>,
pub source_asset_ids_json: String,
pub draft_json: String,
pub publish_ready: bool,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelRunStartRecordInput {
pub run_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub mode: String,
pub snapshot_json: Option<String>,
pub started_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelRunSnapshotRecordInput {
pub run_id: String,
pub owner_user_id: String,
pub status: String,
pub current_scene_id: Option<String>,
pub current_phase_id: Option<String>,
pub visible_character_ids_json: String,
pub flags_json: String,
pub metrics_json: String,
pub available_choices_json: String,
pub text_mode_enabled: bool,
pub snapshot_json: Option<String>,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelHistoryEntryRecordInput {
pub entry_id: String,
pub run_id: String,
pub owner_user_id: String,
pub turn_index: u32,
pub source: String,
pub action_text: Option<String>,
pub steps_json: String,
pub snapshot_before_hash: Option<String>,
pub snapshot_after_hash: Option<String>,
pub created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VisualNovelRuntimeEventRecordInput {
pub event_id: String,
pub run_id: String,
pub owner_user_id: String,
pub profile_id: Option<String>,
pub event_kind: String,
pub client_event_id: Option<String>,
pub history_entry_id: Option<String>,
pub payload_json: String,
pub occurred_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelAgentMessageRecord {
pub message_id: String,
pub session_id: String,
pub role: String,
pub kind: String,
pub text: String,
pub created_at: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelAgentSessionRecord {
pub session_id: String,
pub owner_user_id: String,
pub source_mode: String,
pub status: String,
pub seed_text: String,
pub source_asset_ids: Vec<String>,
pub current_turn: u32,
pub progress_percent: u32,
pub messages: Vec<VisualNovelAgentMessageRecord>,
pub draft: Option<serde_json::Value>,
pub pending_action: Option<serde_json::Value>,
pub last_assistant_reply: Option<String>,
pub published_profile_id: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelWorkProfileRecord {
pub work_id: String,
pub profile_id: String,
pub owner_user_id: String,
pub source_session_id: Option<String>,
pub author_display_name: String,
pub work_title: String,
pub work_description: String,
pub tags: Vec<String>,
pub cover_image_src: Option<String>,
pub source_asset_ids: Vec<String>,
pub draft: serde_json::Value,
pub publication_status: String,
pub publish_ready: bool,
pub play_count: u32,
pub created_at: String,
pub updated_at: String,
pub published_at: Option<String>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelHistoryEntryRecord {
pub entry_id: String,
pub run_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub turn_index: u32,
pub source: String,
pub action_text: Option<String>,
pub steps: serde_json::Value,
pub snapshot_before_hash: Option<String>,
pub snapshot_after_hash: Option<String>,
pub created_at: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelRunRecord {
pub run_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub mode: String,
pub status: String,
pub current_scene_id: Option<String>,
pub current_phase_id: Option<String>,
pub visible_character_ids: Vec<String>,
pub flags: serde_json::Value,
pub metrics: serde_json::Value,
pub history: Vec<VisualNovelHistoryEntryRecord>,
pub available_choices: serde_json::Value,
pub text_mode_enabled: bool,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct VisualNovelRuntimeEventRecord {
pub event_id: String,
pub run_id: Option<String>,
pub owner_user_id: String,
pub profile_id: Option<String>,
pub event_kind: String,
pub client_event_id: Option<String>,
pub history_entry_id: Option<String>,
pub payload: serde_json::Value,
pub occurred_at: String,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelAgentMessageJsonRecord {
message_id: String,
session_id: String,
role: String,
kind: String,
text: String,
created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelAgentSessionJsonRecord {
session_id: String,
owner_user_id: String,
source_mode: String,
status: String,
seed_text: String,
source_asset_ids: Vec<String>,
current_turn: u32,
progress_percent: u32,
messages: Vec<VisualNovelAgentMessageJsonRecord>,
draft: Option<serde_json::Value>,
pending_action: Option<serde_json::Value>,
last_assistant_reply: Option<String>,
published_profile_id: Option<String>,
created_at_micros: i64,
updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelWorkJsonRecord {
work_id: String,
profile_id: String,
owner_user_id: String,
source_session_id: Option<String>,
author_display_name: String,
work_title: String,
work_description: String,
tags: Vec<String>,
cover_image_src: Option<String>,
source_asset_ids: Vec<String>,
draft: serde_json::Value,
publication_status: String,
publish_ready: bool,
play_count: u32,
created_at_micros: i64,
updated_at_micros: i64,
published_at_micros: Option<i64>,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelHistoryEntryJsonRecord {
entry_id: String,
run_id: String,
owner_user_id: String,
profile_id: String,
turn_index: u32,
source: String,
action_text: Option<String>,
steps: serde_json::Value,
snapshot_before_hash: Option<String>,
snapshot_after_hash: Option<String>,
created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelRunJsonRecord {
run_id: String,
owner_user_id: String,
profile_id: String,
mode: String,
status: String,
current_scene_id: Option<String>,
current_phase_id: Option<String>,
visible_character_ids: Vec<String>,
flags: serde_json::Value,
metrics: serde_json::Value,
history: Vec<VisualNovelHistoryEntryJsonRecord>,
available_choices: serde_json::Value,
text_mode_enabled: bool,
created_at_micros: i64,
updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct VisualNovelRuntimeEventJsonRecord {
event_id: String,
run_id: Option<String>,
owner_user_id: String,
profile_id: Option<String>,
event_kind: String,
client_event_id: Option<String>,
history_entry_id: Option<String>,
payload: serde_json::Value,
occurred_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SquareHoleAnchorItemRecord {
pub key: String,
@@ -6552,6 +7103,7 @@ pub struct PuzzleDraftLevelRecord {
pub level_id: String,
pub level_name: String,
pub picture_description: String,
pub picture_reference: Option<String>,
pub candidates: Vec<PuzzleGeneratedImageCandidateRecord>,
pub selected_candidate_id: Option<String>,
pub cover_image_src: Option<String>,