Skip to main content
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 a PraxaClient by passing a PraxaClientOptions object. The baseUrl and accessToken fields are required; all others are optional.
baseUrl
string
required
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.
accessToken
() => string | Promise<string>
required
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.
fetch
typeof globalThis.fetch
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.
maximumAttempts
number
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.
retryBaseDelayMs
number
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.
input
CreateMissionRequest
required
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, and maximumParallelism.
idempotencyKey
string
required
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.
signal
AbortSignal
An optional AbortSignal to cancel the in-flight request.
Returns 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.
runId
string
required
The runId of the mission to retrieve, as returned by createMission.
signal
AbortSignal
An optional AbortSignal to cancel the in-flight request.
Returns 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.
runId
string
required
The runId of the mission to stream.
opts.lastEventId
string
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.
opts.signal
AbortSignal
An optional AbortSignal to cancel the stream.
Yields AuraSseEvent — objects with id (string), event (string), and data (parsed JsonValue).
See Mission Events for a full guide including cancellation, filtering, and result collection.

signalMission

Send a named signal with an arbitrary JSON payload to a running mission.
runId
string
required
The runId of the target mission.
signalName
string
required
The name of the signal to deliver — for example, "user.approval" or "input.provided".
payload
JsonValue
required
Arbitrary JSON data to attach to the signal. Can be an object, array, string, number, boolean, or null.
idempotencyKey
string
required
A stable unique key to make this signal delivery idempotent across retries.
signal
AbortSignal
An optional AbortSignal to cancel the in-flight request.

cancelMission

Request cancellation of a running or waiting mission.
runId
string
required
The runId of the mission to cancel.
reason
string
required
A human-readable explanation for the cancellation, recorded in the mission audit trail.
idempotencyKey
string
required
A stable unique key to make this cancellation request idempotent.
signal
AbortSignal
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.
requirement
CapabilityRequirement
required
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".
signal
AbortSignal
An optional AbortSignal to cancel the in-flight request.
Returns 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.
query
MemoryQuery
required
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).
signal
AbortSignal
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.
signal
AbortSignal
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.
signal
AbortSignal
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.
skillId
string
required
The unique identifier of the skill to retrieve.
signal
AbortSignal
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.
traceId
string
required
The unique identifier of the trace to retrieve.
signal
AbortSignal
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.
signal
AbortSignal
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, and cancelMission), or
  • Is a safe read (all GET requests and searchCapabilities / queryMemory).
Unkeyed mutations are never retried. Retryable status codes: 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.
If all attempts are exhausted or a non-retryable status code is returned, the SDK throws a PraxaClientError. See Error Handling for details.