API Reference
This reference documents the key APIs for JuliaOS, including Node.js, Julia, and Python interfaces.
Node.js/TypeScript API
Julia Bridge
The Julia Bridge provides a communication channel between Node.js and the Julia backend.
import { JuliaBridge } from './packages/julia-bridge';
// Initialize
const juliaBridge = new JuliaBridge({
host: 'localhost',
port: 8052
});
// Connect
const connected = await juliaBridge.connect();
// Run a Julia command
const result = await juliaBridge.runJuliaCommand('agents.list_agents', {});
Agent Manager
import { AgentManager } from './packages/framework/agents';
// Initialize
const agentManager = new AgentManager(juliaBridge);
// Create an agent
const agent = await agentManager.createAgent({
name: 'trading_agent',
type: 'Trading',
skills: ['price_analysis'],
chains: ['Ethereum'],
config: { risk_tolerance: 0.5 }
});
// Get agent status
const status = await agentManager.getAgentStatus(agent.id);
// Start agent
await agentManager.startAgent(agent.id);
// Stop agent
await agentManager.stopAgent(agent.id);
// Delete agent
await agentManager.deleteAgent(agent.id);
Swarm Manager
import { SwarmManager } from './packages/framework/swarms';
// Initialize
const swarmManager = new SwarmManager(juliaBridge);
// Create a swarm
const swarm = await swarmManager.createSwarm({
name: 'trading_swarm',
algorithm: 'PSO',
objective: 'maximize_profit',
config: { particles: 50 }
});
// Add agent to swarm
await swarmManager.addAgentToSwarm(swarm.id, agent.id);
// Start swarm
await swarmManager.startSwarm(swarm.id);
// Stop swarm
await swarmManager.stopSwarm(swarm.id);
// Delete swarm
await swarmManager.deleteSwarm(swarm.id);
Wallet Manager
import { WalletManager } from './packages/wallets';
// Initialize
const walletManager = new WalletManager();
// Connect
await walletManager.connect();
// Get address
const address = await walletManager.getAddress();
// Send transaction
const tx = await walletManager.sendTransaction({
to: '0x...',
value: ethers.parseEther('1.0')
});
Python API
JuliaOS Client
from juliaos import JuliaOS
# Initialize
juliaos = JuliaOS(host='localhost', port=8052)
# Connect
await juliaos.connect()
Agent API
# Create an agent
agent = await juliaos.create_agent(
name="trading_agent",
specialization="trading",
skills=["price_analysis"]
)
# Start the agent
await agent.start()
# Execute a task
result = await agent.execute_task("analyze_market", data=market_data)
# Stop the agent
await agent.stop()
Swarm API
# Create a swarm
swarm = await juliaos.create_swarm(
algorithm="differential_evolution",
population_size=50,
dimensions=10,
bounds=(-10, 10)
)
# Define an objective function
def sphere(x):
return sum(xi**2 for xi in x)
# Run optimization
result = await swarm.optimize(
objective=sphere,
iterations=100,
minimize=True
)
Wallet API
# Connect a wallet
wallet = await juliaos.connect_wallet(
type="ethereum",
private_key=os.environ.get("ETH_PRIVATE_KEY")
)
# Get balance
balance = await wallet.get_balance()
# Send transaction
tx = await wallet.send_transaction(
to="0x...",
amount="1.0",
token="ETH"
)
Julia API
Julia APIs are exposed via the command handler in the Julia backend:
# Example Julia code (not directly callable from outside)
function create_agent(name::String, agent_type::String, config::Dict)
# Agent creation logic
end
function start_agent(agent_id::String)
# Agent start logic
end
function create_swarm(name::String, algorithm::String, config::Dict)
# Swarm creation logic
end
function start_swarm(swarm_id::String)
# Swarm start logic
end
Command Reference
These commands can be called via the Julia Bridge:
Agents
agents.list_agents
List all agents
None
Agents
agents.create_agent
Create a new agent
name
, type
, config
Agents
agents.get_agent
Get agent details
id
Agents
agents.start_agent
Start an agent
id
Agents
agents.stop_agent
Stop an agent
id
Agents
agents.delete_agent
Delete an agent
id
Swarms
swarms.list_swarms
List all swarms
None
Swarms
swarms.create_swarm
Create a new swarm
name
, algorithm
, config
Swarms
swarms.get_swarm
Get swarm details
id
Swarms
swarms.start_swarm
Start a swarm
id
Swarms
swarms.stop_swarm
Stop a swarm
id
Swarms
swarms.delete_swarm
Delete a swarm
id
Wallets
wallets.connect_wallet
Connect a wallet
address
, chain
Wallets
wallets.disconnect_wallet
Disconnect a wallet
address
Wallets
wallets.get_balance
Get wallet balance
address
System
system.get_status
Get system status
None
System
system.get_metrics
Get system metrics
None
Event Reference
JuliaOS components emit various events that can be listened to:
Agents
agent:created
Agent created
{ id, name, type }
Agents
agent:started
Agent started
{ id }
Agents
agent:stopped
Agent stopped
{ id }
Swarms
swarm:created
Swarm created
{ id, name, algorithm }
Swarms
swarm:started
Swarm started
{ id }
Swarms
swarm:stopped
Swarm stopped
{ id }
Wallets
wallet:connected
Wallet connected
{ address, chain }
Wallets
wallet:disconnected
Wallet disconnected
{ address }
System
system:started
System started
{ timestamp }
System
system:stopped
System stopped
{ timestamp }