Skip to content

TRIOS A2A — Лучшая в мире Agent-to-Agent архитектура #234

@gHashTag

Description

@gHashTag

Архитектурная философия

A2A (Agent-to-Agent) — протокол прямой коммуникации между агентами без центрального брокера. Работает поверх MCP, HTTP/SSE, WebSocket, gRPC — любой транспорт, любое устройство.

Основан на Google A2A Protocol, MCP, AutoGen, CrewAI, LangGraph + законах LAWS.md.

Ключевые принципы из LAWS.md:

  • L1: Zero WebSocket в extension (разрешён в core A2A runtime)
  • L4: Все агенты общаются через typed messages, не строки
  • L7: WASM-unsafe-eval только где нужен sandbox
  • I4/I13/I14: REST-first, Accept headers обязательны

Структура репозитория

crates/
└── trios-a2a/
    ├── Cargo.toml
    ├── src/lib.rs
    ├── README.md          # Обзор A2A архитектуры
    ├── TASK.md            # Задачи и статус реализации
    ├── AGENTS.md          # Инструкции для агентов по всему crate
    └── rings/
        ├── SR-00/         # Ring 0 — Identity & Trust
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md  # Описание кольца
        │   ├── TASK.md    # Задачи кольца
        │   └── AGENTS.md  # Инструкции агента для SR-00
        ├── SR-01/         # Ring 1 — Transport Layer
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        ├── SR-02/         # Ring 2 — Message Protocol
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        ├── SR-03/         # Ring 3 — Agent Registry
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        ├── SR-04/         # Ring 4 — Task Orchestration
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        ├── SR-05/         # Ring 5 — Memory & Context
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        ├── SR-06/         # Ring 6 — Skill Marketplace
        │   ├── Cargo.toml
        │   ├── src/lib.rs
        │   ├── README.md
        │   ├── TASK.md
        │   └── AGENTS.md
        └── BR-OUTPUT/     # Binary Ring — всё генерируемое
            ├── Cargo.toml
            ├── src/lib.rs
            ├── README.md
            ├── TASK.md
            └── AGENTS.md

Инвариант I5: каждое кольцо содержит README.md + TASK.md + AGENTS.md. Без этих файлов кольцо не считается реализованным.


Кольца детально

SR-00 — Identity & Trust

Назначение: DID-based идентификация, подписи Ed25519, уровни доверия.

pub struct AgentIdentity {
    pub did: AgentDid,           // did:trios:<pubkey>
    pub public_key: [u8; 32],
    pub capabilities: Vec<Capability>,
    pub trust_level: TrustLevel,
}

pub enum TrustLevel {
    Untrusted,
    Verified,
    Trusted,
    Root,
}

SR-01 — Transport Layer

Назначение: Универсальный транспорт — HTTP/SSE, WebSocket, IPC.

# crates/trios-a2a/rings/SR-01/Cargo.toml
[dependencies]
trios-a2a-sr00 = { path = "../SR-00" }
reqwest = { version = "0.12", features = ["json", "stream"] }
async-trait = "0.2"
web-sys = { version = "0.3", optional = true }
#[async_trait]
pub trait A2ATransport: Send + Sync {
    async fn send(&self, msg: A2AEnvelope) -> Result<()>;
    async fn receive(&self) -> Result<A2AEnvelope>;
}

pub enum TransportType {
    Http,
    Sse,
    WebSocket,
    Ipc,
    InProcess,
}
Platform Transport SR-01 impl
Extension (WASM) SSE SseTransport
Native server HTTP REST HttpTransport
Mobile (WASM) WebSocket WsTransport
FPGA / embedded IPC socket IpcTransport
MCP skill via SR-06 MCP skill

SR-02 — Message Protocol

Назначение: Typed message schema, envelope format, JSON-RPC 2.0 compatible.

#[derive(Serialize, Deserialize)]
pub struct A2AEnvelope {
    pub jsonrpc: &'static str, // "2.0"
    pub from: AgentDid,
    pub to: AgentDid,
    pub timestamp: u64,
    pub payload: A2APayload,
    pub signature: Option<[u8; 64]>,
}

#[derive(Serialize, Deserialize)]
pub enum A2APayload {
    // Task management
    TaskRequest { task_id: Uuid, description: String },
    TaskCompleted { task_id: Uuid, artifacts: Vec<Artifact> },
    TaskFailed { task_id: Uuid, error: String },
    // Handshake
    Handshake { identity: AgentIdentity },
    // Streaming
    StreamChunk { task_id: Uuid, chunk: Vec<u8> },
    StreamComplete { task_id: Uuid, total_chunks: u32 },
    // Memory sync
    ContextUpdate { key: String, value: serde_json::Value },
    ContextQuery { keys: Vec<String> },
    ContextReply { entries: HashMap<String, serde_json::Value> },
}

pub struct TaskSpec {
    pub task_id: Uuid,
    pub description: String,
    pub input: serde_json::Value,
    pub required_capabilities: Vec<Capability>,
    pub parent_task: Option<Uuid>, // для суб-задач
}

SR-03 — Agent Registry

Назначение: Реестр агентов, Google A2A AgentCard spec, discovery.

pub struct RegisteredAgent {
    pub did: AgentDid,
    pub url: String,              // endpoint
    pub version: String,
    pub capabilities: AgentCapabilities,
    pub authentication: AuthScheme,
    pub default_input_modes: Vec<String>,
    pub default_output_modes: Vec<String>,
}

pub struct AgentRegistry {
    agents: HashMap<AgentDid, RegisteredAgent>,
    capability_index: HashMap<Capability, Vec<AgentDid>>,
}

impl AgentRegistry {
    pub fn find_by_capability(&self, cap: &Capability) -> Vec<&RegisteredAgent> { ... }
    pub fn best_agent_for_task(&self, task: &TaskSpec) -> Option<AgentDid> { ... }
}

SR-04 — Task Orchestration

Назначение: DAG-based orchestration, parallel execution, failure recovery.

pub struct TaskOrchestrator {
    registry: Arc<AgentRegistry>,
    dag: DiGraph<TaskNode, DependencyEdge>,
}

pub struct RetryPolicy {
    pub max_attempts: u32,
    pub backoff: ExponentialBackoff,
    pub on_failure: FailureAction, // Reassign | Escalate | Abort
}

SR-05 — Memory & Context

Назначение: Shared context между агентами, semantic memory, CRDT merge.

pub struct MemoryStore {
    working: HashMap<String, ContextEntry>, // in-memory
    persistent: Box<dyn PersistentStore>,   // disk-backed
    shared: Arc<RwLock<SharedMemory>>,
}

pub struct ContextEntry {
    pub value: serde_json::Value,
    pub visibility: Visibility, // Private | Session | Global
    pub vector: Option<Vec<f32>>,
    pub version: u64, // для CRDT
}

// CRDT-style merge: last-write-wins на основе version
fn merge(a: &ContextEntry, b: &ContextEntry) -> ContextEntry {
    if a.version >= b.version { a.clone() } else { b.clone() }
}

SR-06 — Skill Marketplace

Назначение: Реестр WASM skills агентов. Hot-reload, versioning.

pub struct SkillDefinition {
    pub id: SkillId,
    pub name: String,
    pub tags: Vec<String>,       // ["code-gen", "file-write"]
    pub input_schema: Schema,
    pub output_schema: Schema,
    pub runtime: SkillRuntime,
}

pub enum SkillRuntime {
    Wasm(Vec<u8>),
    Native(Box<dyn SkillFn>),
    Mcp { server_url: String, tool_name: String },
}

BR-OUTPUT — Binary Ring Output

Назначение: Генерация артефактов — WASM, FPGA bitstream, code.

br-output/
├── wasm/
│   ├── modules/   # скомпилированные .wasm
│   └── bindings/  # JS/TS glue
├── fpga/
│   └── bitstreams/
└── artifacts/     # прочие артефакты

Граф зависимостей

SR-00 (Identity)
  └── SR-01 (Transport)
        └── SR-02 (Message Protocol)
              ├── SR-03 (Agent Registry)
              │     └── SR-04 (Task Orchestration)
              ├── SR-05 (Memory & Context)
              └── SR-06 (Skill Marketplace)
                        └── BR-OUTPUT

Корневой Cargo.toml

[workspace]
members = [
    "rings/SR-00",
    "rings/SR-01",
    "rings/SR-02",
    "rings/SR-03",
    "rings/SR-04",
    "rings/SR-05",
    "rings/SR-06",
    "rings/BR-OUTPUT",
]

[dependencies]
trios-a2a-sr00 = { path = "rings/SR-00" }
trios-a2a-sr01 = { path = "rings/SR-01" }
trios-a2a-sr02 = { path = "rings/SR-02" }
trios-a2a-sr03 = { path = "rings/SR-03" }
trios-a2a-sr04 = { path = "rings/SR-04" }
trios-a2a-sr05 = { path = "rings/SR-05" }
trios-a2a-sr06 = { path = "rings/SR-06" }

Таски

  • SR-00: Реализовать AgentIdentity, DID, Ed25519 подписи + README.md + TASK.md + AGENTS.md
  • SR-01: Реализовать A2ATransport trait, HttpTransport, SseTransport + docs
  • SR-02: Реализовать A2AEnvelope, A2APayload enum, serde + docs
  • SR-03: Реализовать AgentRegistry, AgentCard discovery + docs
  • SR-04: Реализовать DAG orchestrator, RetryPolicy + docs
  • SR-05: Реализовать MemoryStore, CRDT merge, semantic search + docs
  • SR-06: Реализовать SkillMarketplace, WASM hot-reload + docs
  • BR-OUTPUT: Реализовать artifact generation pipeline + docs
  • Интеграция с trios-ext (extension использует A2A через SSE транспорт)
  • Интеграция с BrowserOS MCP (SR-06 skill для browser tools)

Инвариант документации (обязателен для каждого кольца)

README.md — что это кольцо делает

# SR-XX — <Название>
Назначение, API, примеры использования, зависимости.

TASK.md — статус задач кольца

# Tasks SR-XX
- [ ] Task 1
- [x] Task 2 (done)

AGENTS.md — инструкции агента для этого кольца

# Agent Instructions SR-XX
Что агент должен знать о кольце.
Какие файлы трогать, какие инварианты соблюдать.
Как тестировать.

⚠️ Без README.md + TASK.md + AGENTS.md кольцо не считается реализованным.


Связанные issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions