NSPClient is the main entry point for the nelieo-nsp SDK. Every interaction with the NSP daemon starts here. It manages the underlying httpx.AsyncClient connection pool, handles API key authentication, and exposes methods for discovering applications, reading state, and opening sessions.
Constructor
Your NSP API key. If omitted, the client reads the
NSP_API_KEY environment variable. Raises NSPAuthError on the first request if neither is set.Hostname or IP address of the NSP daemon. Override with the
NSP_HOST environment variable.Port the daemon is listening on. Override with the
NSP_PORT environment variable.Per-request timeout in seconds. Applies to all HTTP requests except the initial TCP handshake.
TCP connection timeout in seconds. Raises
NSPConnectionError if the daemon is not reachable within this window.Maximum number of simultaneous HTTP connections in the pool. Increase this if you are making many concurrent requests.
Whether to verify SSL certificates. Set to
False only for local development with a self-signed cert.Lifecycle
NSPClient is an async context manager. Use async with to ensure the underlying connection pool is cleanly closed when you are done:
Methods
health() → dict
Return daemon version, uptime, and basic health metadata. Use this to confirm the daemon is running before issuing other requests.
Daemon version string, e.g.
"1.0.0".Seconds since the daemon started.
list_apps() → list[AppSummary]
List every application currently tracked by the daemon. Returns an empty list if no apps are tracked.
list_apps() returns cached data from the daemon’s internal registry. It does not trigger a fresh probe. The daemon updates this list automatically as processes start and stop.get_state(pid, *, fresh=False) → SubstrateState
Fetch the current semantic state for a tracked process by PID.
The OS process ID of the target application.
When
True, forces the daemon to run a fresh probe cycle before returning. This adds 50 ms–90 s of latency depending on the runtime (v8 is fast; CLR and JVM are slower on first attach).NSPNotFoundError if the PID is not in the daemon’s tracked list.
attach(app_name_or_id, *, fresh=False, fuzzy=True) → NSPSession
Attach to a running application by name or stable app_id. This is the most convenient way to open a session.
The human-readable app name (e.g.
"Gmail") or the stable app_id string (e.g. "gmail-chrome-12847").Trigger a fresh probe before the session opens. Useful when you need accurate initial state immediately.
Allow partial name matching. When
True, "mail" matches "Gmail" and "mission" matches "Mission Planner".NSPNotFoundError if no tracked app matches the given name or ID.
attach_by_pid(pid, *, fresh=False) → NSPSession
Attach to a specific process by exact PID. Use this when you already know the PID from list_apps().
The exact OS process ID.
wait_for_app(app_name_or_id, *, timeout=60.0, poll_interval=2.0, fuzzy=True) → NSPSession
Poll the daemon until a matching app appears, then attach and return the session. Use this when your agent starts before the target application.
App name or stable app_id to wait for.
Maximum seconds to wait before raising
asyncio.TimeoutError.Seconds between each poll to
list_apps().Allow partial name matching.
asyncio.TimeoutError if the app does not appear within timeout seconds.
execute_action(request) → ActionResponse
Low-level action dispatch. For most use cases, prefer session.execute() — it handles PID binding and state refresh automatically.
