LogoLogo
  • JuliaOS Documentation Hub
  • About JuliaOS
    • Mission & Vision
    • Features and Capabilities
    • Roadmap
    • Tokenomics
  • Ecosystem
    • Overview
  • Partners
    • Heurist
    • Fetch.ai
    • Soulgraph
    • cheqd.io
    • Aethir
    • Anyone
    • TensorLabs
    • Hashpower
  • Technology
    • Overview
    • Open Source
      • Modular Framework
      • CLI Mode
    • AI Platform
      • Dashboard
      • Agent Management
      • Swarm Management
      • Marketplace
      • Mining
    • LLM
    • Launchpad
    • Robotics & IOT
      • SwarmIOT
      • Modular AI with Robotics
        • J3OS MiniLLM
          • 🔧 Use Cases
  • Technical
    • Overview
    • Developer Hub
      • Getting Started
        • Installation Guide
          • Github Guide
        • Basic Concepts
        • Quick Start Guide
          • Handling secrets
        • Examples and Use
          • Example: Using the Trading Functionality
          • Example: Using the Benchmarking Feature
          • Example: Multi-Agent Swarm Coordination
          • Example: Using the Python Wrapper for LLM Integration
          • Example: Using Cross-Chain Bridges
          • Example: Creating and Running a Swarm Optimization
          • Page 4
      • Best Practices
        • Performance Tuning
        • Agent/Swarm Design Patterns
        • Best Practices & Patterns
        • Security Best Practices
      • CLI
        • JuliaOS CLI Interface
        • Agent Management (CLI)
        • CLI Configuration
        • Cross-Chain Hub (CLI)
        • Swarm Management (CLI)
        • CLI Troubleshooting
        • Wallet Management (CLI)
      • Framework SDK
        • Modules
          • Bridge
          • Agents Module
          • Dex
          • Swarms Module
          • Wallet
        • Python Wrapper
          • LangChain Integration
          • Python Wrapper
      • Contributing Guide
      • Extending JuliaOS
      • Development Setup & Conventions
      • Testing & Debugging
      • Troubleshooting
    • Architecture
      • High Level JuliaOS
      • CLI <-> Backend Communication
      • Data Storage Architecture
      • Framework Internals
      • Architecture Deep Dive
        • Architectual Notes
    • Concepts
      • Core Features & Concepts
      • Agents
        • Agent Skills & Specializations
      • Swarms
      • Neural Networks
      • Blockchains & Chains
      • Bridges (Cross-Chain)
      • Integrations
        • Google ADK
        • LLMs
        • Price Feed
        • DEX Integration
      • Storage
      • Trading Capabilities
      • Use Cases
      • Wallets
      • Portfolio Optimization
  • Research
    • JuliaOS Research
  • API Documentation
    • API Reference
      • API Reference: Julia Backend Commands
      • API Reference: CLI Commands
      • API Reference: Node.js API
      • API Reference: Python API
      • API Reference
  • Community
    • Community & Support
  • FAQ
    • General
    • Technical
    • Community
Powered by GitBook
On this page
  • Overview
  • Request/Response Flow
  • Communication Diagram
  • Key Components
Export as PDF
  1. Technical
  2. Architecture

CLI <-> Backend Communication

This page details the communication mechanism between the JuliaOS frontends (CLI, Python Wrapper) and the Julia backend server.

Overview

Communication relies on a client-server model where frontends act as clients sending requests to the Julia backend server.

  • Server: The Julia backend (julia/julia_server.jl) runs an HTTP server (using HTTP.jl) listening on a specific port (default: 8052). A WebSocket server on port 8053 is prepared but currently disabled in the code.

  • Clients: The Node.js CLI (packages/cli/) and the Python Wrapper (packages/python-wrapper/) initiate connections to the HTTP server.

  • Bridge Component: A dedicated component within the clients (e.g., @juliaos/julia-bridge in Node.js, or internal HTTP client in Python) handles formatting requests, sending them, and parsing responses.

  • Protocol: Communication uses HTTP POST requests to the /api/command endpoint. Payloads are JSON objects containing a command string (e.g., "agents.create_agent") and a params or payload object/array containing arguments.

Request/Response Flow

  1. Client Action: User interacts with the CLI or calls a Python API function.

  2. Bridge Formatting: The client-side bridge constructs a JSON payload.

    {
      "command": "agents.create_agent",
      // Payload format might be array or object depending on handler
      "params": ["MyAgent", "Trading", {"risk": 0.5}] 
      // or "payload": { "name": "MyAgent", ... }
    }
  3. HTTP Request: The bridge sends an HTTP POST request to http://<backend_host>:8052/api/command with the JSON payload.

  4. Server Receives: The Julia HTTP server (julia_server.jl) receives the request at the /api/command route.

  5. Command Parsing: The server parses the JSON body to extract the command string and params/payload.

  6. Command Handling: The server's command handler (likely defined in julia_server.jl or a dedicated command module) looks up the function associated with the command string in a registry (like Bridge.command_handlers).

  7. Backend Logic: The registered handler function (e.g., AgentSystem.handle_create_agent(...)) is called with the parameters from the payload.

  8. Response Formatting: The handler function returns a result (e.g., data object or error).

  9. HTTP Response: The Julia server sends an HTTP response (typically JSON) back to the client bridge, often wrapping the result.

    // Example success response format from Bridge.jl
    {
      "result": { "agent_id": "uuid-123-abc", ... }, // Actual data from handler
      "error": null,
      "id": "request-id"
    }
    // Example error response format
    {
      "result": null,
      "error": "Command execution failed: Agent name already exists",
      "id": "request-id"
    }
  10. Bridge Parsing: The client-side bridge receives the HTTP response and parses the JSON, checking for errors.

  11. Client Update: The result data or error is returned to the original caller (CLI displays message, Python function returns value or raises exception).

Communication Diagram

sequenceDiagram
    participant Client as CLI / Python Wrapper
    participant BridgeLib as Client Bridge Lib (JS/Py)
    participant JuliaServer as Julia Backend (HTTP Server @ :8052)
    participant CmdDispatcher as Command Dispatcher (Julia)
    participant HandlerFunc as Specific Handler Func (Julia)
    participant CoreModules as Core Julia Modules

    Client->>BridgeLib: User Action / API Call
    BridgeLib->>BridgeLib: Format JSON: {command, params/payload, id}
    BridgeLib->>JuliaServer: POST /api/command (JSON Payload)
    JuliaServer->>CmdDispatcher: Receive Request, Parse JSON
    CmdDispatcher->>CmdDispatcher: Lookup handler for command string
    CmdDispatcher->>HandlerFunc: Invoke handler(params)
    HandlerFunc->>CoreModules: Execute Logic (AgentSystem, etc.)
    CoreModules-->>HandlerFunc: Return data/result
    HandlerFunc-->>CmdDispatcher: Return result/error
    CmdDispatcher-->>JuliaServer: Format JSON Response: {result, error, id}
    JuliaServer-->>BridgeLib: HTTP Response (JSON Body)
    BridgeLib->>BridgeLib: Parse JSON Response, Check error field
    BridgeLib-->>Client: Return data or raise error
    Client->>Client: Process result / Display to user

Key Components

  • /julia/julia_server.jl: Contains the HTTP server (HTTP.jl), routing for /api/command, request parsing, and command dispatch logic.

  • /julia/src/Bridge.jl: Defines request/response structs, manages the command_handlers registry, provides utility functions (get_token_address, execute_trade, submit_signed_transaction), and handles the core run_command logic.

  • Client Libraries (/packages/julia-bridge/ or Python internal): Responsible for making the HTTP POST calls and handling responses on the client side.

PreviousHigh Level JuliaOSNextData Storage Architecture