-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
enhancementNew feature or requestNew feature or requestsdkSDK/framework changesSDK/framework changes
Description
Overview
Implement a .NET SDK (Gaia.Native) that wraps the GAIA C API via P/Invoke, providing idiomatic C# types and async/await support.
Priority
P1
Dependencies
- Issue A (SDK: C API core — error codes, lifecycle, agent CRUD #429) —
GaiaHandle,GaiaError,gaia_agent_create/destroy(can start writing wrapper after A) - Issues B (SDK: C API process_query with cancellation #430), C (SDK: C API unified event callback system #431), D (SDK: C API tool registration and MCP management #432), E (SDK: C API version, ABI stability, and config #433) — needed for full test coverage
Scope
Project Structure
nuget/Gaia.Native/
├── GaiaAgent.cs # IDisposable wrapper, async process_query
├── GaiaEventArgs.cs # Event type + payload types
├── GaiaException.cs # GaiaError → .NET exception
├── NativeMethods.cs # P/Invoke declarations (internal)
├── Gaia.Native.csproj # targets net8.0; NuGet metadata
└── tests/
└── GaiaAgentTests.cs
Implementation
GaiaAgentimplementsIDisposable; finalizer callsgaia_agent_destroy()as safety netProcessQueryAsync(string query, CancellationToken ct)→ mapsCancellationTokentogaia_cancel()event EventHandler<GaiaEventArgs> OnEvent— raised fromGaiaEventCallbackmarshaling- P/Invoke error handling: copy
gaia_last_error()string before throwingGaiaException
Tests (GaiaAgentTests.cs)
- Create
GaiaAgent, drop all references withoutDispose(), force GC → no crash (finalizer safety net) ProcessQueryAsyncwithCancellationToken.Cancel()→OperationCanceledExceptionGaiaExceptionmessage matchesgaia_last_error()string
Acceptance Criteria
-
GaiaAgentisIDisposablewith finalizer safety net - Async/await API via
ProcessQueryAsync -
CancellationTokenmaps togaia_cancel() - P/Invoke error copies
gaia_last_error()before throwing - NuGet package builds (
dotnet pack) - Tests pass on Linux and Windows
Risk
R4 (Medium): ABI stability — PR1a (C API) must merge and stabilize before PR1b (.NET) starts integration testing.
Phase
Phase 1c — can start writing against capi.h after A; integration tests after B-E.
PR
PR1b (separate from C++ PR1a; different review domain).
Related
- Depends on Issues A-E
- Part of M11: Multi-Language SDK
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestsdkSDK/framework changesSDK/framework changes