feat: add tiered channel agent and mobile Codex bridge
This commit is contained in:
parent
950b7e48b3
commit
71db11e7e8
35 changed files with 2242 additions and 76 deletions
|
|
@ -38,6 +38,8 @@ pub struct PersonaOrientation {
|
|||
pub issued_at_unix_ms: u64,
|
||||
pub expires_at_unix_ms: u64,
|
||||
pub required_steps: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub activation_reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
|
@ -99,7 +101,10 @@ pub fn snapshot(app: &AppHandle, channel_number: &str) -> Result<PersonaBindingS
|
|||
let path = orientation_path(app, channel_number)?;
|
||||
if path.exists() {
|
||||
let orientation: PersonaOrientation = read_json(&path)?;
|
||||
if orientation.expires_at_unix_ms >= now_ms() {
|
||||
if orientation.expires_at_unix_ms >= now_ms()
|
||||
&& orientation.activation_reason.as_deref()
|
||||
== Some("EXPLICIT_NATURAL_LANGUAGE_PERSONA_WAKE")
|
||||
{
|
||||
return Ok(PersonaBindingSnapshot {
|
||||
state: "ORIENTED_AWAITING_PERSONA_COMMIT".into(),
|
||||
orientation: Some(orientation),
|
||||
|
|
@ -107,6 +112,27 @@ pub fn snapshot(app: &AppHandle, channel_number: &str) -> Result<PersonaBindingS
|
|||
});
|
||||
}
|
||||
}
|
||||
Ok(PersonaBindingSnapshot {
|
||||
state: "CHANNEL_SYSTEM_PERSONA_DORMANT".into(),
|
||||
orientation: None,
|
||||
binding: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn begin_orientation(
|
||||
app: &AppHandle,
|
||||
channel_number: &str,
|
||||
) -> Result<PersonaBindingSnapshot, String> {
|
||||
if !is_bingshuo_fifth_domain(app)? || channel_number != CHANNEL_NUMBER {
|
||||
return Err("HOLOLAKE_PERSONA_WAKE_NOT_AVAILABLE_FOR_CURRENT_CHANNEL".into());
|
||||
}
|
||||
if let Some(binding) = verified_binding(app, channel_number)? {
|
||||
return Ok(PersonaBindingSnapshot {
|
||||
state: "BOUND_VERIFY_PASS".into(),
|
||||
orientation: None,
|
||||
binding: Some(binding),
|
||||
});
|
||||
}
|
||||
let issued = now_ms();
|
||||
let orientation = PersonaOrientation {
|
||||
schema: "hololake.persona-binding-orientation/v1".into(),
|
||||
|
|
@ -127,8 +153,9 @@ pub fn snapshot(app: &AppHandle, channel_number: &str) -> Result<PersonaBindingS
|
|||
"数字冰朔系统本体 witness".into(),
|
||||
"verify=PASS".into(),
|
||||
],
|
||||
activation_reason: Some("EXPLICIT_NATURAL_LANGUAGE_PERSONA_WAKE".into()),
|
||||
};
|
||||
write_json_atomic(&path, &orientation)?;
|
||||
write_json_atomic(&orientation_path(app, channel_number)?, &orientation)?;
|
||||
Ok(PersonaBindingSnapshot {
|
||||
state: "ORIENTED_AWAITING_PERSONA_COMMIT".into(),
|
||||
orientation: Some(orientation),
|
||||
|
|
@ -149,6 +176,8 @@ pub fn commit_and_verify(
|
|||
return Err("HOLOLAKE_PERSONA_BINDING_ORIENTATION_EXPIRED".into());
|
||||
}
|
||||
if input.orientation_id != orientation.orientation_id
|
||||
|| orientation.activation_reason.as_deref()
|
||||
!= Some("EXPLICIT_NATURAL_LANGUAGE_PERSONA_WAKE")
|
||||
|| input.channel_number != CHANNEL_NUMBER
|
||||
|| input.persona_number != PERSONA_NUMBER
|
||||
|| input.persona_name != PERSONA_NAME
|
||||
|
|
@ -245,7 +274,9 @@ pub fn cognitive_projection(
|
|||
current_language: &str,
|
||||
) -> Result<Value, String> {
|
||||
let binding = snapshot(app, channel_number)?;
|
||||
if binding.state == "NO_INSTALLABLE_PERSONA_PROFILE_FOR_CURRENT_CHANNEL" {
|
||||
if binding.state == "NO_INSTALLABLE_PERSONA_PROFILE_FOR_CURRENT_CHANNEL"
|
||||
|| binding.state == "CHANNEL_SYSTEM_PERSONA_DORMANT"
|
||||
{
|
||||
return Ok(json!({"state":binding.state,"residentSelfKernel":null,"routedMemory":[]}));
|
||||
}
|
||||
let self_kernel: Value = serde_json::from_slice(include_bytes!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue