chore: checkpoint local workspace changes
This commit is contained in:
@@ -2622,52 +2622,71 @@ fn finalize_custom_world_agent_message_turn_tx(
|
||||
.filter(|row| row.session_id == input.session_id)
|
||||
.ok_or_else(|| "custom_world_agent_operation 不存在".to_string())?;
|
||||
|
||||
if ctx
|
||||
.db
|
||||
.custom_world_agent_message()
|
||||
.message_id()
|
||||
.find(&input.assistant_message_id)
|
||||
.is_some()
|
||||
{
|
||||
return Err("custom_world_agent_message.assistant_message_id 已存在".to_string());
|
||||
}
|
||||
|
||||
let updated_at = Timestamp::from_micros_since_unix_epoch(input.updated_at_micros);
|
||||
|
||||
ctx.db
|
||||
.custom_world_agent_message()
|
||||
.insert(CustomWorldAgentMessage {
|
||||
message_id: input.assistant_message_id.clone(),
|
||||
session_id: input.session_id.clone(),
|
||||
role: RpgAgentMessageRole::Assistant,
|
||||
kind: RpgAgentMessageKind::Chat,
|
||||
text: input.assistant_reply_text.clone(),
|
||||
related_operation_id: Some(input.operation_id.clone()),
|
||||
created_at: updated_at,
|
||||
});
|
||||
let next_session = if input.operation_status == RpgAgentOperationStatus::Failed {
|
||||
rebuild_custom_world_agent_session_row(
|
||||
&session,
|
||||
CustomWorldAgentSessionPatch {
|
||||
updated_at_micros: Some(input.updated_at_micros),
|
||||
..CustomWorldAgentSessionPatch::default()
|
||||
},
|
||||
)?
|
||||
} else {
|
||||
let assistant_message_id = input
|
||||
.assistant_message_id
|
||||
.clone()
|
||||
.ok_or_else(|| "custom_world_agent_message.assistant_message_id 不能为空".to_string())?;
|
||||
let assistant_reply_text = input
|
||||
.assistant_reply_text
|
||||
.clone()
|
||||
.ok_or_else(|| "custom_world_agent_message.text 不能为空".to_string())?;
|
||||
|
||||
let next_session = rebuild_custom_world_agent_session_row(
|
||||
&session,
|
||||
CustomWorldAgentSessionPatch {
|
||||
current_turn: Some(session.current_turn.saturating_add(1)),
|
||||
progress_percent: Some(input.progress_percent),
|
||||
stage: Some(input.stage),
|
||||
focus_card_id: Some(input.focus_card_id.clone()),
|
||||
anchor_content_json: Some(input.anchor_content_json.clone()),
|
||||
creator_intent_json: Some(input.creator_intent_json.clone()),
|
||||
creator_intent_readiness_json: Some(input.creator_intent_readiness_json.clone()),
|
||||
anchor_pack_json: Some(input.anchor_pack_json.clone()),
|
||||
draft_profile_json: Some(input.draft_profile_json.clone()),
|
||||
last_assistant_reply: Some(Some(input.assistant_reply_text.clone())),
|
||||
pending_clarifications_json: Some(input.pending_clarifications_json.clone()),
|
||||
quality_findings_json: Some(input.quality_findings_json.clone()),
|
||||
suggested_actions_json: Some(input.suggested_actions_json.clone()),
|
||||
recommended_replies_json: Some(input.recommended_replies_json.clone()),
|
||||
asset_coverage_json: Some(input.asset_coverage_json.clone()),
|
||||
updated_at_micros: Some(input.updated_at_micros),
|
||||
..CustomWorldAgentSessionPatch::default()
|
||||
},
|
||||
)?;
|
||||
if ctx
|
||||
.db
|
||||
.custom_world_agent_message()
|
||||
.message_id()
|
||||
.find(&assistant_message_id)
|
||||
.is_some()
|
||||
{
|
||||
return Err("custom_world_agent_message.assistant_message_id 已存在".to_string());
|
||||
}
|
||||
|
||||
ctx.db
|
||||
.custom_world_agent_message()
|
||||
.insert(CustomWorldAgentMessage {
|
||||
message_id: assistant_message_id,
|
||||
session_id: input.session_id.clone(),
|
||||
role: RpgAgentMessageRole::Assistant,
|
||||
kind: RpgAgentMessageKind::Chat,
|
||||
text: assistant_reply_text.clone(),
|
||||
related_operation_id: Some(input.operation_id.clone()),
|
||||
created_at: updated_at,
|
||||
});
|
||||
|
||||
rebuild_custom_world_agent_session_row(
|
||||
&session,
|
||||
CustomWorldAgentSessionPatch {
|
||||
current_turn: Some(session.current_turn.saturating_add(1)),
|
||||
progress_percent: Some(input.progress_percent),
|
||||
stage: Some(input.stage),
|
||||
focus_card_id: Some(input.focus_card_id.clone()),
|
||||
anchor_content_json: Some(input.anchor_content_json.clone()),
|
||||
creator_intent_json: Some(input.creator_intent_json.clone()),
|
||||
creator_intent_readiness_json: Some(input.creator_intent_readiness_json.clone()),
|
||||
anchor_pack_json: Some(input.anchor_pack_json.clone()),
|
||||
draft_profile_json: Some(input.draft_profile_json.clone()),
|
||||
last_assistant_reply: Some(Some(assistant_reply_text)),
|
||||
pending_clarifications_json: Some(input.pending_clarifications_json.clone()),
|
||||
quality_findings_json: Some(input.quality_findings_json.clone()),
|
||||
suggested_actions_json: Some(input.suggested_actions_json.clone()),
|
||||
recommended_replies_json: Some(input.recommended_replies_json.clone()),
|
||||
asset_coverage_json: Some(input.asset_coverage_json.clone()),
|
||||
updated_at_micros: Some(input.updated_at_micros),
|
||||
..CustomWorldAgentSessionPatch::default()
|
||||
},
|
||||
)?
|
||||
};
|
||||
replace_custom_world_agent_session(ctx, &session, next_session);
|
||||
|
||||
let next_operation = rebuild_custom_world_agent_operation_row(
|
||||
|
||||
Reference in New Issue
Block a user