Skip to content

omega-brands/omega-sdk-csharp

Repository files navigation

OMEGA SDK for C#

Powered by OMEGA. Governed by Keon.

A strongly-typed .NET client library for the OMEGA Federation Core API.

Installation

dotnet add package Omega.Sdk

Quick Start

using Omega.Sdk;

// Create client with options
var client = new OmegaClient(new OmegaClientOptions
{
    FederationUrl = "http://localhost:9405",
    ApiKey = "your-api-key",
    TenantId = "my-tenant",
    ActorId = "my-actor"
});

// Check health
var health = await client.GetHealthAsync();
Console.WriteLine($"Status: {health.Status}");

// List tools
var tools = await client.Tools.ListAsync();
Console.WriteLine($"Tools: {tools.Items.Count}");

// Invoke a tool
var result = await client.Tools.InvokeAsync("my-tool", new { Input = "value" });
Console.WriteLine($"Result: {result.Result}");

Environment Variables

The SDK can be configured via environment variables:

OMEGA_FEDERATION_URL=http://localhost:9405
OMEGA_API_KEY=your-api-key
OMEGA_TENANT_ID=my-tenant
OMEGA_ACTOR_ID=my-actor
OMEGA_TIMEOUT_MS=120000
OMEGA_MAX_RETRIES=3
var client = OmegaClient.FromEnvironment();

Features

Tools API

// List tools
var tools = await client.Tools.ListAsync(new ToolListRequest
{
    Capability = "search"
});

// Get tool details
var tool = await client.Tools.GetAsync("tool-id");

// Invoke tool
var result = await client.Tools.InvokeAsync("tool-id", new { Query = "hello" });

Agents API

// List agents
var agents = await client.Agents.ListAsync(new AgentListRequest
{
    Kind = "titan"
});

// Get agent details
var agent = await client.Agents.GetAsync("agent-id");

Tasks API

// Create async task
var task = await client.Tasks.CreateAsync("workflow.run", new { Workflow = "my-wf" });

// Wait for completion
var completed = await client.Tasks.WaitForCompletionAsync(task.TaskId);

Evidence API

// List evidence packs
var packs = await client.Evidence.ListAsync();

// Verify integrity
var verification = await client.Evidence.VerifyAsync("pack-hash");

Workflows API

// Start workflow
var run = await client.Workflows.RunWorkflowAsync("council-of-titans", new
{
    Topic = "brand strategy"
});

// Wait for completion (or pause)
var result = await client.Workflows.WaitForCompletionAsync(run.RunId);

// Resume if paused at gate
if (result.Status == WorkflowStatus.Paused && result.GateInfo != null)
{
    await client.Workflows.ResumeRunAsync(
        run.RunId,
        result.GateInfo.GateId,
        decision: "approve",
        input: new Dictionary<string, object> { ["answers"] = new[] { "context" } }
    );
}

Error Handling

The SDK provides typed exceptions:

using Omega.Sdk.Exceptions;

try
{
    await client.Tools.GetAsync("nonexistent");
}
catch (ConnectionException ex)
{
    // Core is not running or unreachable
    Console.Error.WriteLine(ex.Message); // Displays helpful setup instructions
}
catch (NotFoundException ex)
{
    Console.WriteLine($"Tool not found: {ex.ResourceId}");
}
catch (RateLimitException ex)
{
    Console.WriteLine($"Rate limited, retry after: {ex.RetryAfterMs}ms");
}
catch (OmegaException ex)
{
    Console.WriteLine($"Error: {ex.Code} - {ex.Message}");
}

Troubleshooting

Connection Errors

If you get a ConnectionException when trying to use the SDK:

For local development:

  1. Verify Omega Core is running:

    curl http://localhost:9405/health
  2. Start Core if not running:

    docker compose up -d
    # or
    omega-core start
  3. Check the Federation URL in your code matches where Core is running

For production/cloud:

  1. Verify the Core instance is running and accessible
  2. Check network connectivity
  3. Verify the FederationUrl configuration is correct

Verify Connection

You can explicitly verify connectivity before making requests:

try
{
    var isConnected = await client.VerifyConnectionAsync();
    Console.WriteLine($"Connected to Omega Core: {isConnected}");
}
catch (ConnectionException ex)
{
    Console.Error.WriteLine($"Cannot connect to Core: {ex.Message}");
}

Requirements

  • .NET 8.0 or later
  • C# 12.0 or later

Related Documentation

License

MIT License


Powered by OMEGA. Governed by Keon.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors