ArgideAgent is a facade that owns one runtime per page — it is what most integrations use. startAgentRuntime is the lower-level primitive it wraps.
ArgideAgent.init(options)
Initializes the page’s runtime. Idempotent and safe under React StrictMode — call it from anywhere, any number of times. On the server (SSR) it warns and does nothing; no session is minted until it runs in a browser.ArgideAgent.do({ goal })
Starts a task, or rejoins the running one.- Returns
Promise<{ taskId: string }>— resolves as soon as the task exists, not when it finishes. Waits internally for init and the claim first. - Rejects with
409 SESSION_BUSYwhen called with a different goal while a task is running. - Called with the same goal as the running task, it resolves with the same
taskId(rejoin).
ArgideAgent.check({ taskId })
Fetches the authoritative outcome.- Returns
Promise<{ taskId, status, summary }>.statusis one ofrunning,completed,failed, orcancelled;summaryis a string ornull. - Rejects on any non-2xx, including
404for a task that is unknown or belongs to another session.
ArgideAgent.cancel({ taskId })
Ends the task early.- The returned promise resolves with the same
{ taskId, status, summary }outcome shape ascheck(). - Rejects on any non-2xx, including
404(unknown or foreign task) and409(task already terminal).
ArgideAgent.onActivity(callback)
Subscribes to ephemeral, per-tab activity events. Returns an unsubscribe function.kind. Activity is not persisted — for the authoritative outcome use check().
ArgideAgent.session()
ReturnsPromise<{ sessionId, pairingCode, recovered }> for claiming through your own channel.
Claim only when recovered is false — a recovered session is already claimed, and re-claiming returns 409 ALREADY_CLAIMED. See Claiming Sessions.
ArgideAgent.stop()
Tears down and resets the runtime. The nextinit() starts fresh. Normal pages never call this — the runtime is designed to live as long as the tab.
- Local teardown only: it leaves a running task alive server-side. Use
cancel()to end the task.
Errors
These codes describe server-side behavior. On the client,
do(), check(), and cancel() reject with a plain Error whose message carries the HTTP status (e.g. agent task create failed: HTTP 409) — the codes themselves aren’t exposed as properties on the error.
startAgentRuntime
ArgideAgent owns one runtime per page. Drop down to the primitive it wraps when you need more than one product on a page, or you want to manage the lifecycle yourself:
recovered before claiming, and guard against starting two runtimes concurrently yourself.
Integration requirements
What your stack must support before going live
