// Generated using `moon info`, DON'T EDIT IT
package "wzzc-dev/moui_agent"

import {
  "moonbitlang/core/debug",
  "wzzc-dev/moui/core",
  "wzzc-dev/moui/runtime",
}

// Values

// Errors

// Types and methods
pub(all) enum AgentActionError {
  HostClosed
  StaleGeneration(@core.SemanticsGeneration, @core.SemanticsGeneration)
  TargetNotFound(@core.SemanticsTarget)
  TargetAmbiguous(@core.SemanticId)
  TargetDisabled(@core.SemanticsTarget)
  ActionUnavailable(@core.SemanticsTarget, @core.SemanticsActionKind)
  HandlerRejected(@core.SemanticsTarget, @core.SemanticsActionKind)
  ReentrantDispatch
} derive(Eq, ToJson, @debug.Debug)
pub fn AgentActionError::code(Self) -> String

pub(all) struct AgentActionReceipt {
  before : @core.SemanticsGeneration
  after : @core.SemanticsGeneration
  pending_work : Bool
} derive(Eq, ToJson, @debug.Debug)

pub(all) struct AgentActionRequest {
  target : @core.SemanticsTarget
  action : @core.SemanticsAction
  precondition : AgentGenerationPrecondition
} derive(Eq, ToJson, @debug.Debug)

pub(all) enum AgentDiagnosticsError {
  HostClosed
} derive(Eq, ToJson, @debug.Debug)
pub fn AgentDiagnosticsError::code(Self) -> String

pub(all) enum AgentGenerationPrecondition {
  Exact(@core.SemanticsGeneration)
  Latest
} derive(Eq, ToJson, @debug.Debug)

pub(all) enum AgentReadError {
  HostClosed
} derive(Eq, ToJson, @debug.Debug)
pub fn AgentReadError::code(Self) -> String

pub(all) struct AgentSemanticsDelta {
  from : @core.SemanticsGeneration
  to : @core.SemanticsGeneration
  root : @core.SemanticsNodeId?
  focused : @core.SemanticsNodeId?
  upserted : Array[@core.SemanticsNode]
  removed : Array[@core.SemanticsNodeId]
  issues : Array[AgentSemanticsIssue]
} derive(Eq, ToJson, @debug.Debug)

pub(all) enum AgentSemanticsIssue {
  DuplicateSemanticId(@core.SemanticId, Array[@core.SemanticsNodeId])
} derive(Eq, ToJson, @debug.Debug)

pub(all) enum AgentSemanticsRead {
  Full(AgentSemanticsSnapshot)
  Delta(AgentSemanticsDelta)
  Unchanged(@core.SemanticsGeneration)
} derive(Eq, ToJson, @debug.Debug)

pub(all) struct AgentSemanticsSnapshot {
  generation : @core.SemanticsGeneration
  root : @core.SemanticsNodeId?
  focused : @core.SemanticsNodeId?
  nodes : Array[@core.SemanticsNode]
  issues : Array[AgentSemanticsIssue]
} derive(Eq, ToJson, @debug.Debug)

pub(all) struct DiagnosticsDispatchResult {
  accepted : Bool
  reason : String?
} derive(Eq, ToJson, @debug.Debug)

pub(all) struct PaintSummary {
  texts : Array[String]
  draw_command_count : Int
} derive(Eq, ToJson, @debug.Debug)

pub struct RuntimeAgentHost {
  runtime : @runtime.AppRuntime
}
pub fn RuntimeAgentHost::new(@runtime.AppRuntime) -> Self
pub impl AgentDiagnosticsHost for RuntimeAgentHost
pub impl AgentHost for RuntimeAgentHost

pub(all) struct RuntimeStateSnapshot {
  dispatched_count : Int
  update_count : Int
  pending_message_count : Int
  active_subscription_count : Int
  active_effect_task_count : Int
} derive(Eq, ToJson, @debug.Debug)

// Type aliases

// Traits
pub(open) trait AgentDiagnosticsHost {
  fn runtime_state(Self) -> Result[RuntimeStateSnapshot, AgentDiagnosticsError]
  fn paint_summary(Self) -> Result[PaintSummary, AgentDiagnosticsError]
  fn dispatch_event(Self, @core.AppEvent) -> Result[DiagnosticsDispatchResult, AgentDiagnosticsError]
  fn dispatch_command(Self, @core.CommandIntent) -> Result[DiagnosticsDispatchResult, AgentDiagnosticsError]
}

pub(open) trait AgentHost {
  fn read_semantics(Self, @core.SemanticsGeneration?) -> Result[AgentSemanticsRead, AgentReadError]
  fn perform_action(Self, AgentActionRequest) -> Result[AgentActionReceipt, AgentActionError]
}