499 lines
19 KiB
Rust
499 lines
19 KiB
Rust
use super::*;
|
|
use crate::mapper::*;
|
|
|
|
impl SpacetimeClient {
|
|
pub async fn list_custom_world_profiles(
|
|
&self,
|
|
owner_user_id: String,
|
|
) -> Result<Vec<CustomWorldLibraryEntryRecord>, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldProfileListInput { owner_user_id };
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().list_custom_world_profiles_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_profile_list_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_library_detail(
|
|
&self,
|
|
owner_user_id: String,
|
|
profile_id: String,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldLibraryDetailInput {
|
|
owner_user_id,
|
|
profile_id,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_custom_world_library_detail_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_detail_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn upsert_custom_world_profile(
|
|
&self,
|
|
input: CustomWorldProfileUpsertRecordInput,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = input.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.upsert_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_mutation_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn publish_custom_world_profile(
|
|
&self,
|
|
profile_id: String,
|
|
owner_user_id: String,
|
|
public_work_code: Option<String>,
|
|
author_public_user_code: String,
|
|
author_display_name: String,
|
|
published_at_micros: i64,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldProfilePublishInput {
|
|
profile_id,
|
|
owner_user_id,
|
|
public_work_code,
|
|
author_public_user_code,
|
|
author_display_name,
|
|
published_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.publish_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_mutation_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn unpublish_custom_world_profile(
|
|
&self,
|
|
profile_id: String,
|
|
owner_user_id: String,
|
|
author_display_name: String,
|
|
updated_at_micros: i64,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldProfileUnpublishInput {
|
|
profile_id,
|
|
owner_user_id,
|
|
author_display_name,
|
|
updated_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.unpublish_custom_world_profile_and_return_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_mutation_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn delete_custom_world_profile(
|
|
&self,
|
|
profile_id: String,
|
|
owner_user_id: String,
|
|
deleted_at_micros: i64,
|
|
) -> Result<Vec<CustomWorldLibraryEntryRecord>, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldProfileDeleteInput {
|
|
profile_id,
|
|
owner_user_id,
|
|
deleted_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.delete_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_profile_list_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn list_custom_world_gallery_entries(
|
|
&self,
|
|
) -> Result<Vec<CustomWorldGalleryEntryRecord>, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.list_custom_world_gallery_entries_then(move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_gallery_list_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_gallery_detail(
|
|
&self,
|
|
owner_user_id: String,
|
|
profile_id: String,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldGalleryDetailInput {
|
|
owner_user_id,
|
|
profile_id,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_custom_world_gallery_detail_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_mutation_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_gallery_detail_by_code(
|
|
&self,
|
|
public_work_code: String,
|
|
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldGalleryDetailByCodeInput { public_work_code };
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_custom_world_gallery_detail_by_code_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_library_mutation_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn publish_custom_world_world(
|
|
&self,
|
|
input: CustomWorldPublishWorldRecordInput,
|
|
) -> Result<CustomWorldPublishWorldRecord, SpacetimeClientError> {
|
|
let procedure_input = input.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().publish_custom_world_world_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_publish_world_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn create_custom_world_agent_session(
|
|
&self,
|
|
input: CustomWorldAgentSessionCreateRecordInput,
|
|
) -> Result<CustomWorldAgentSessionRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentSessionCreateInput {
|
|
session_id: input.session_id,
|
|
owner_user_id: input.owner_user_id,
|
|
seed_text: input.seed_text,
|
|
welcome_message_id: input.welcome_message_id,
|
|
welcome_message_text: input.welcome_message_text,
|
|
anchor_content_json: input.anchor_content_json,
|
|
creator_intent_json: input.creator_intent_json,
|
|
creator_intent_readiness_json: input.creator_intent_readiness_json,
|
|
anchor_pack_json: input.anchor_pack_json,
|
|
lock_state_json: input.lock_state_json,
|
|
draft_profile_json: input.draft_profile_json,
|
|
pending_clarifications_json: input.pending_clarifications_json,
|
|
suggested_actions_json: input.suggested_actions_json,
|
|
recommended_replies_json: input.recommended_replies_json,
|
|
quality_findings_json: input.quality_findings_json,
|
|
asset_coverage_json: input.asset_coverage_json,
|
|
checkpoints_json: input.checkpoints_json,
|
|
created_at_micros: input.created_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.create_custom_world_agent_session_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_session_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_agent_session(
|
|
&self,
|
|
session_id: String,
|
|
owner_user_id: String,
|
|
) -> Result<CustomWorldAgentSessionRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentSessionGetInput {
|
|
session_id,
|
|
owner_user_id,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_custom_world_agent_session_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_session_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn list_custom_world_works(
|
|
&self,
|
|
owner_user_id: String,
|
|
) -> Result<Vec<CustomWorldWorkSummaryRecord>, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldWorksListInput { owner_user_id };
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().list_custom_world_works_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_works_list_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_agent_card_detail(
|
|
&self,
|
|
session_id: String,
|
|
owner_user_id: String,
|
|
card_id: String,
|
|
) -> Result<CustomWorldDraftCardDetailRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentCardDetailGetInput {
|
|
session_id,
|
|
owner_user_id,
|
|
card_id,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_custom_world_agent_card_detail_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_draft_card_detail_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn execute_custom_world_agent_action(
|
|
&self,
|
|
input: CustomWorldAgentActionExecuteRecordInput,
|
|
) -> Result<CustomWorldAgentActionExecuteRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentActionExecuteInput {
|
|
session_id: input.session_id,
|
|
owner_user_id: input.owner_user_id,
|
|
operation_id: input.operation_id,
|
|
action: input.action,
|
|
payload_json: input.payload_json,
|
|
submitted_at_micros: input.submitted_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.execute_custom_world_agent_action_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_action_execute_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn submit_custom_world_agent_message(
|
|
&self,
|
|
input: CustomWorldAgentMessageSubmitRecordInput,
|
|
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentMessageSubmitInput {
|
|
session_id: input.session_id,
|
|
owner_user_id: input.owner_user_id,
|
|
user_message_id: input.user_message_id,
|
|
user_message_text: input.user_message_text,
|
|
operation_id: input.operation_id,
|
|
submitted_at_micros: input.submitted_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.submit_custom_world_agent_message_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_operation_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn finalize_custom_world_agent_message(
|
|
&self,
|
|
input: CustomWorldAgentMessageFinalizeRecordInput,
|
|
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentMessageFinalizeInput {
|
|
session_id: input.session_id,
|
|
owner_user_id: input.owner_user_id,
|
|
operation_id: input.operation_id,
|
|
assistant_message_id: input.assistant_message_id,
|
|
assistant_reply_text: input.assistant_reply_text,
|
|
phase_label: input.phase_label,
|
|
phase_detail: input.phase_detail,
|
|
operation_status: parse_rpg_agent_operation_status_record(
|
|
input.operation_status.as_str(),
|
|
)?,
|
|
operation_progress: input.operation_progress,
|
|
stage: parse_rpg_agent_stage_record(input.stage.as_str())?,
|
|
progress_percent: input.progress_percent,
|
|
focus_card_id: input.focus_card_id,
|
|
anchor_content_json: input.anchor_content_json,
|
|
creator_intent_json: input.creator_intent_json,
|
|
creator_intent_readiness_json: input.creator_intent_readiness_json,
|
|
anchor_pack_json: input.anchor_pack_json,
|
|
draft_profile_json: input.draft_profile_json,
|
|
pending_clarifications_json: input.pending_clarifications_json,
|
|
suggested_actions_json: input.suggested_actions_json,
|
|
recommended_replies_json: input.recommended_replies_json,
|
|
quality_findings_json: input.quality_findings_json,
|
|
asset_coverage_json: input.asset_coverage_json,
|
|
error_message: input.error_message,
|
|
updated_at_micros: input.updated_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.finalize_custom_world_agent_message_turn_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_operation_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn upsert_custom_world_agent_operation_progress(
|
|
&self,
|
|
input: CustomWorldAgentOperationProgressRecordInput,
|
|
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentOperationProgressInput {
|
|
session_id: input.session_id,
|
|
owner_user_id: input.owner_user_id,
|
|
operation_id: input.operation_id,
|
|
operation_type: parse_rpg_agent_operation_type_record(input.operation_type.as_str())?,
|
|
operation_status: parse_rpg_agent_operation_status_record(
|
|
input.operation_status.as_str(),
|
|
)?,
|
|
phase_label: input.phase_label,
|
|
phase_detail: input.phase_detail,
|
|
operation_progress: input.operation_progress,
|
|
error_message: input.error_message,
|
|
updated_at_micros: input.updated_at_micros,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.upsert_custom_world_agent_operation_progress_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_operation_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_custom_world_agent_operation(
|
|
&self,
|
|
session_id: String,
|
|
owner_user_id: String,
|
|
operation_id: String,
|
|
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
|
let procedure_input = CustomWorldAgentOperationGetInput {
|
|
session_id,
|
|
owner_user_id,
|
|
operation_id,
|
|
};
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_custom_world_agent_operation_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_custom_world_agent_operation_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
}
|