Preserve partial creation replies on stream failure
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
kdletters
2026-05-05 11:31:50 +08:00
parent 100fee7e7a
commit 995661e7cc
299 changed files with 13805 additions and 1429 deletions

View File

@@ -32,6 +32,7 @@ mod match3d;
mod migration;
mod puzzle;
mod runtime;
mod square_hole;
pub use ai::*;
pub use asset_metadata::*;
@@ -44,3 +45,4 @@ pub use gameplay::*;
pub use match3d::*;
pub use migration::*;
pub use runtime::*;
pub use square_hole::*;

View File

@@ -13,6 +13,10 @@ use crate::puzzle::{
puzzle_agent_message, puzzle_agent_session, puzzle_event, puzzle_leaderboard_entry,
puzzle_runtime_run, puzzle_work_profile,
};
use crate::square_hole::tables::{
square_hole_agent_message, square_hole_agent_session, square_hole_runtime_run,
square_hole_work_profile,
};
const MIGRATION_SCHEMA_VERSION: u32 = 1;
const MIGRATION_MAX_TABLE_NAME_LEN: usize = 96;
@@ -208,6 +212,10 @@ macro_rules! migration_tables {
match3d_agent_message,
match3d_work_profile,
match3d_runtime_run,
square_hole_agent_session,
square_hole_agent_message,
square_hole_work_profile,
square_hole_runtime_run,
big_fish_creation_session,
big_fish_agent_message,
big_fish_asset_slot,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
use crate::*;
#[spacetimedb::table(
accessor = square_hole_agent_session,
index(accessor = by_square_hole_agent_session_owner_user_id, btree(columns = [owner_user_id]))
)]
pub struct SquareHoleAgentSessionRow {
#[primary_key]
pub(crate) session_id: String,
pub(crate) owner_user_id: String,
pub(crate) seed_text: String,
pub(crate) current_turn: u32,
pub(crate) progress_percent: u32,
pub(crate) stage: String,
pub(crate) config_json: String,
pub(crate) draft_json: String,
pub(crate) last_assistant_reply: String,
pub(crate) published_profile_id: String,
pub(crate) created_at: Timestamp,
pub(crate) updated_at: Timestamp,
}
#[spacetimedb::table(
accessor = square_hole_agent_message,
index(accessor = by_square_hole_agent_message_session_id, btree(columns = [session_id]))
)]
pub struct SquareHoleAgentMessageRow {
#[primary_key]
pub(crate) message_id: String,
pub(crate) session_id: String,
pub(crate) role: String,
pub(crate) kind: String,
pub(crate) text: String,
pub(crate) created_at: Timestamp,
}
#[spacetimedb::table(
accessor = square_hole_work_profile,
index(accessor = by_square_hole_work_owner_user_id, btree(columns = [owner_user_id])),
index(accessor = by_square_hole_work_publication_status, btree(columns = [publication_status]))
)]
pub struct SquareHoleWorkProfileRow {
#[primary_key]
pub(crate) profile_id: String,
pub(crate) work_id: String,
pub(crate) owner_user_id: String,
pub(crate) source_session_id: String,
pub(crate) author_display_name: String,
pub(crate) game_name: String,
pub(crate) theme_text: String,
pub(crate) twist_rule: String,
pub(crate) summary_text: String,
pub(crate) tags_json: String,
pub(crate) cover_image_src: String,
pub(crate) shape_count: u32,
pub(crate) difficulty: u32,
pub(crate) config_json: String,
pub(crate) publication_status: String,
pub(crate) play_count: u32,
pub(crate) updated_at: Timestamp,
pub(crate) published_at: Option<Timestamp>,
}
#[spacetimedb::table(
accessor = square_hole_runtime_run,
index(accessor = by_square_hole_run_owner_user_id, btree(columns = [owner_user_id])),
index(accessor = by_square_hole_run_profile_id, btree(columns = [profile_id]))
)]
pub struct SquareHoleRuntimeRunRow {
#[primary_key]
pub(crate) run_id: String,
pub(crate) owner_user_id: String,
pub(crate) profile_id: String,
pub(crate) status: String,
pub(crate) snapshot_version: u64,
pub(crate) started_at_ms: i64,
pub(crate) duration_limit_ms: i64,
pub(crate) finished_at_ms: i64,
pub(crate) elapsed_ms: i64,
pub(crate) total_shape_count: u32,
pub(crate) completed_shape_count: u32,
pub(crate) score: u32,
pub(crate) snapshot_json: String,
pub(crate) created_at: Timestamp,
pub(crate) updated_at: Timestamp,
}

View File

@@ -0,0 +1,325 @@
use crate::*;
use serde::{Deserialize, Serialize};
pub const SQUARE_HOLE_STAGE_COLLECTING: &str = "Collecting";
pub const SQUARE_HOLE_STAGE_READY_TO_COMPILE: &str = "ReadyToCompile";
pub const SQUARE_HOLE_STAGE_DRAFT_COMPILED: &str = "DraftCompiled";
pub const SQUARE_HOLE_STAGE_PUBLISHED: &str = "Published";
pub const SQUARE_HOLE_ROLE_USER: &str = "user";
pub const SQUARE_HOLE_ROLE_ASSISTANT: &str = "assistant";
pub const SQUARE_HOLE_KIND_TEXT: &str = "text";
pub const SQUARE_HOLE_PUBLICATION_DRAFT: &str = "Draft";
pub const SQUARE_HOLE_PUBLICATION_PUBLISHED: &str = "Published";
pub const SQUARE_HOLE_RUN_RUNNING: &str = "Running";
pub const SQUARE_HOLE_RUN_WON: &str = "Won";
pub const SQUARE_HOLE_RUN_FAILED: &str = "Failed";
pub const SQUARE_HOLE_RUN_STOPPED: &str = "Stopped";
pub const SQUARE_HOLE_DROP_ACCEPTED: &str = "Accepted";
pub const SQUARE_HOLE_DROP_REJECTED: &str = "Rejected";
pub const SQUARE_HOLE_DROP_VERSION_CONFLICT: &str = "VersionConflict";
pub const SQUARE_HOLE_DROP_RUN_FINISHED: &str = "RunFinished";
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleAgentSessionCreateInput {
pub session_id: String,
pub owner_user_id: String,
pub seed_text: String,
pub welcome_message_id: String,
pub welcome_message_text: String,
pub config_json: Option<String>,
pub created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleAgentSessionGetInput {
pub session_id: String,
pub owner_user_id: String,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleAgentMessageSubmitInput {
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, SpacetimeType)]
pub struct SquareHoleAgentMessageFinalizeInput {
pub session_id: String,
pub owner_user_id: String,
pub assistant_message_id: Option<String>,
pub assistant_reply_text: Option<String>,
pub config_json: Option<String>,
pub progress_percent: u32,
pub stage: String,
pub updated_at_micros: i64,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleDraftCompileInput {
pub session_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub author_display_name: String,
pub game_name: Option<String>,
pub summary_text: Option<String>,
pub tags_json: Option<String>,
pub cover_image_src: Option<String>,
pub compiled_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorkUpdateInput {
pub profile_id: String,
pub owner_user_id: String,
pub game_name: String,
pub theme_text: String,
pub twist_rule: String,
pub summary_text: String,
pub tags_json: String,
pub cover_image_src: String,
pub shape_count: u32,
pub difficulty: u32,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorkPublishInput {
pub profile_id: String,
pub owner_user_id: String,
pub published_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorksListInput {
pub owner_user_id: String,
pub published_only: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorkGetInput {
pub profile_id: String,
pub owner_user_id: String,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorkDeleteInput {
pub profile_id: String,
pub owner_user_id: String,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunStartInput {
pub run_id: String,
pub owner_user_id: String,
pub profile_id: String,
pub started_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunGetInput {
pub run_id: String,
pub owner_user_id: String,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunDropInput {
pub run_id: String,
pub owner_user_id: String,
pub hole_id: String,
pub client_snapshot_version: u64,
pub client_event_id: String,
pub dropped_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunStopInput {
pub run_id: String,
pub owner_user_id: String,
pub stopped_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunRestartInput {
pub source_run_id: String,
pub next_run_id: String,
pub owner_user_id: String,
pub restarted_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunTimeUpInput {
pub run_id: String,
pub owner_user_id: String,
pub finished_at_ms: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleAgentSessionProcedureResult {
pub ok: bool,
pub session_json: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorkProcedureResult {
pub ok: bool,
pub work_json: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleWorksProcedureResult {
pub ok: bool,
pub items_json: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleRunProcedureResult {
pub ok: bool,
pub run_json: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct SquareHoleDropShapeProcedureResult {
pub ok: bool,
pub status: String,
pub run_json: Option<String>,
pub feedback_json: Option<String>,
pub failure_reason: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleCreatorConfigSnapshot {
pub theme_text: String,
pub twist_rule: String,
pub shape_count: u32,
pub difficulty: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleAgentMessageSnapshot {
pub message_id: String,
pub session_id: String,
pub role: String,
pub kind: String,
pub text: String,
pub created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleDraftSnapshot {
pub profile_id: String,
pub game_name: String,
pub theme_text: String,
pub twist_rule: String,
pub summary_text: String,
pub tags: Vec<String>,
pub shape_count: u32,
pub difficulty: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleAgentSessionSnapshot {
pub session_id: String,
pub owner_user_id: String,
pub seed_text: String,
pub current_turn: u32,
pub progress_percent: u32,
pub stage: String,
pub config: SquareHoleCreatorConfigSnapshot,
pub draft: Option<SquareHoleDraftSnapshot>,
pub messages: Vec<SquareHoleAgentMessageSnapshot>,
pub last_assistant_reply: String,
pub published_profile_id: Option<String>,
pub created_at_micros: i64,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleWorkSnapshot {
pub work_id: String,
pub profile_id: String,
pub owner_user_id: String,
pub source_session_id: String,
pub author_display_name: String,
pub game_name: String,
pub theme_text: String,
pub twist_rule: String,
pub summary_text: String,
pub tags: Vec<String>,
pub cover_image_src: String,
pub shape_count: u32,
pub difficulty: u32,
pub config: SquareHoleCreatorConfigSnapshot,
pub publication_status: String,
pub publish_ready: bool,
pub play_count: u32,
pub updated_at_micros: i64,
pub published_at_micros: Option<i64>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleShapeSnapshot {
pub shape_id: String,
pub shape_kind: String,
pub label: String,
pub color: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleHoleSnapshot {
pub hole_id: String,
pub hole_kind: String,
pub label: String,
pub x: f32,
pub y: f32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleDropFeedbackSnapshot {
pub accepted: bool,
pub reject_reason: Option<String>,
pub message: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SquareHoleRunSnapshot {
pub run_id: String,
pub profile_id: String,
pub owner_user_id: String,
pub status: String,
pub snapshot_version: u64,
pub started_at_ms: i64,
pub duration_limit_ms: i64,
pub server_now_ms: i64,
pub remaining_ms: i64,
pub total_shape_count: u32,
pub completed_shape_count: u32,
pub combo: u32,
pub best_combo: u32,
pub score: u32,
pub rule_label: String,
pub current_shape: Option<SquareHoleShapeSnapshot>,
pub holes: Vec<SquareHoleHoleSnapshot>,
pub last_feedback: Option<SquareHoleDropFeedbackSnapshot>,
}