PraxaClient is the single entry point for all Praxa Integration Gateway interactions. You construct one instance per application — passing the gateway origin and an access-token provider — and then call its methods to create missions, stream their event lifecycles, search capabilities, query memory, and inspect skills, traces, and coverage. Every method returns a native Promise (or an AsyncGenerator for event streams), so you can use standard async/await patterns and AbortSignal cancellation throughout.
Constructor
Construct aPraxaClient by passing a PraxaClientOptions object. The baseUrl and accessToken fields are required; all others are optional.
The HTTPS origin of the Praxa Integration Gateway — for example,
"https://gateway.praxa.ai". Pass the origin only, not a path. URLs that use http:, contain a username, or contain a password are rejected at construction time.A function that returns a short-lived delegated OAuth access token (or a
Promise that resolves to one). The SDK calls your provider before every request, so you can rotate tokens transparently. Returned tokens must be 1–16,384 characters and must not contain carriage-return or line-feed characters.A custom
fetch implementation. Defaults to globalThis.fetch. Useful for testing with a mock fetch, for adding observability middleware, or for environments that require a custom HTTP agent.The maximum number of attempts for retryable requests. Clamped to the range 1–4. Defaults to 3. Only requests that carry an idempotency key or are safe reads are retried; unkeyed mutations are never replayed.
The base delay in milliseconds for exponential backoff between retry attempts. Clamped to the range 0–30,000. Defaults to 100. On attempt
n the SDK waits retryBaseDelayMs × 2^(n-1) ms before the next attempt.Mission Methods
createMission
Submit a new governed AI agent mission to the gateway. The mission is created synchronously; use missionEvents to stream its lifecycle.
The mission definition. Contains two fields:
goalSpec(JsonObject) — a free-form JSON object describing the task the agent should accomplish.resourceBudget(ResourceBudget) — governance limits:maximumSteps,maximumToolCalls,maximumElapsedMs, andmaximumParallelism.
A stable, unique key for this submission — typically
crypto.randomUUID(). If the network fails after the server accepts the request, the SDK retries with the same key so the mission is not created twice. Submitting the same key with a different payload returns 409 Conflict.An optional
AbortSignal to cancel the in-flight request.Promise<MissionProjection> — the initial mission snapshot with runId, status, sequence, and steps.
getMission
Fetch a point-in-time snapshot of a mission by its run ID.
The
runId of the mission to retrieve, as returned by createMission.An optional
AbortSignal to cancel the in-flight request.Promise<MissionProjection> — the current mission snapshot.
missionEvents
Open a Server-Sent Event stream and iterate over mission lifecycle events in real time. Returns an AsyncGenerator — use a for await loop to consume events.
The
runId of the mission to stream.Resume the stream from a specific event. Pass the
id field of the last event you received to replay any events you may have missed during a reconnect. The value must be 1–256 printable ASCII characters.An optional
AbortSignal to cancel the stream.AuraSseEvent — objects with id (string), event (string), and data (parsed JsonValue).
signalMission
Send a named signal with an arbitrary JSON payload to a running mission.
The
runId of the target mission.The name of the signal to deliver — for example,
"user.approval" or "input.provided".Arbitrary JSON data to attach to the signal. Can be an object, array, string, number, boolean, or null.
A stable unique key to make this signal delivery idempotent across retries.
An optional
AbortSignal to cancel the in-flight request.cancelMission
Request cancellation of a running or waiting mission.
The
runId of the mission to cancel.A human-readable explanation for the cancellation, recorded in the mission audit trail.
A stable unique key to make this cancellation request idempotent.
An optional
AbortSignal to cancel the in-flight HTTP request (not the mission itself).Discovery & Query Methods
searchCapabilities
Search for registered capabilities that satisfy a given requirement. Use this to discover which tools, APIs, skills, or agents are available for a given action family before submitting a mission.
A structured query with three required fields:
actionFamily(string) — the category of action, e.g."document.summarize".purpose(string) — a free-text description of why the capability is needed.targetType(string) — the kind of resource being acted on, e.g."text/markdown".
An optional
AbortSignal to cancel the in-flight request.Promise<readonly JsonObject[]> — an array of CapabilityManifest-shaped objects, each with capabilityId, contractHash, healthState, kind, and version.
queryMemory
Query the Praxa memory store for contextually relevant entries. The gateway performs semantic search and returns a ranked result set within the requested budget.
A structured memory query. Required fields:
classes (string array), compartment, purpose, and queryText. Optional fields: limit, maxContextBytes, maxContextTokens, and queryEmbedding (float array for vector search).An optional
AbortSignal to cancel the in-flight request.listGoals
Retrieve all active goals from the context-twin. Goals represent the high-level objectives the Praxa governance layer is currently tracking.
An optional
AbortSignal to cancel the in-flight request.listWorldModelCertificates
Retrieve the set of world-model certificates currently registered with the gateway. Certificates attest to the integrity and provenance of the world-model data used during mission execution.
An optional
AbortSignal to cancel the in-flight request.Inspection Methods
getSkill
Fetch the definition of a registered skill by its ID. Skills are reusable, versioned agent sub-routines that missions can invoke.
The unique identifier of the skill to retrieve.
An optional
AbortSignal to cancel the in-flight request.getTrace
Retrieve a full execution trace by its trace ID. Traces contain the detailed step-by-step record of a mission’s tool calls, decisions, and outcomes.
The unique identifier of the trace to retrieve.
An optional
AbortSignal to cancel the in-flight request.getReferenceCoverage
Fetch the current reference coverage report from the gateway. This report describes which parts of the world model and capability registry are covered by active reference data.
An optional
AbortSignal to cancel the in-flight request.Retry Behavior
PraxaClient automatically retries requests that fail with a retryable HTTP status code, provided the request is safe to replay. A request is considered safe to replay if it either:
- Carries an idempotency key (mutating requests such as
createMission,signalMission, andcancelMission), or - Is a safe read (all
GETrequests andsearchCapabilities/queryMemory).
408 Request Timeout, 425 Too Early, 429 Too Many Requests, 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout.
The SDK uses exponential backoff: before attempt n it waits retryBaseDelayMs × 2^(n-1) milliseconds. With the defaults of retryBaseDelayMs: 100 and maximumAttempts: 3, the delays are 0 ms (first attempt), 100 ms, and 200 ms.
The idempotency key is preserved unchanged across every retry attempt, so the gateway can detect and deduplicate replayed requests.
PraxaClientError. See Error Handling for details.