@flow-state-dev/cursor
Classes
CursorAgentAbortedError
The caller's signal fired. A cancelled run is a throw and never a handle, and this is what tells "you stopped it" from "it broke" for a manager deciding whether to retry.
A host tells it with core's isAbortLike, whatever stopped the run: the
root of its cause chain is always an AbortError, whose message is the
signal's reason. The reason itself (a deadline's TimeoutError, a plain
Error, or none) is on reason.
Extends
Error
Constructors
Constructor
new CursorAgentAbortedError(sessionId, reason?): CursorAgentAbortedError;
Parameters
sessionId
string | null
reason?
unknown
The stopping signal's reason, as the caller gave it.
Returns
Overrides
Error.constructor
Properties
cause?
cause?: unknown;
Inherited from
Error.cause
code
readonly code: "CURSOR_AGENT_ABORTED" = "CURSOR_AGENT_ABORTED";
message
message: string;
Inherited from
Error.message
name
name: string;
Inherited from
Error.name
reason?
readonly reason?: unknown;
The stopping signal's reason, as the caller gave it.
sessionId
readonly sessionId: string | null;
stack?
stack?: string;
Inherited from
Error.stack
CursorAgentConfigError
A configuration mistake caught when the block is built: an option group carrying something the block owns rather than forwards (a working directory, an agent id), or a cloud bag this version does not drive.
Extends
Error
Constructors
Constructor
new CursorAgentConfigError(message): CursorAgentConfigError;
Parameters
message
string
Returns
Overrides
Error.constructor
Properties
cause?
cause?: unknown;
Inherited from
Error.cause
code
readonly code: "CURSOR_AGENT_CONFIG_INVALID" = "CURSOR_AGENT_CONFIG_INVALID";
message
message: string;
Inherited from
Error.message
name
name: string;
Inherited from
Error.name
stack?
stack?: string;
Inherited from
Error.stack
CursorAgentRunError
The run ended abnormally: the SDK threw creating, resuming or sending, the
stream threw, or the prompt was empty. Wraps the underlying message on
detail.cause so the caller sees a stable class without losing what the
vendor said.
Extends
Error
Implements
ClassifiedHarnessError
Constructors
Constructor
new CursorAgentRunError(
message,
detail?,
cause?,
harnessFailure?
): CursorAgentRunError;
Parameters
message
string
detail?
carries the underlying message as a string, the shape the sibling adapters use and the one a host can log.
cause?
string
cause?
unknown
the original throw, forwarded to Error's own cause so the
class and stack of whatever failed stay reachable. detail.cause alone
loses both, which is the difference between "the SDK threw" and knowing
what it threw and where.
harnessFailure?
"unknown-conversation" | null
see CursorAgentRunError.harnessFailure.
Returns
Overrides
Error.constructor
Properties
cause?
cause?: unknown;
Implementation of
ClassifiedHarnessError.cause
Inherited from
Error.cause
code
readonly code: "CURSOR_AGENT_RUN_FAILED" = "CURSOR_AGENT_RUN_FAILED";
detail?
readonly detail?: object;
cause?
cause?: string;
harnessFailure
readonly harnessFailure: "unknown-conversation" | null;
The failure in core's neutral vocabulary, read with core's
harnessFailureKind. "unknown-conversation" when Cursor refused to
resume the agent the run asked for (see isUnknownAgentFailure);
null for every other failure.
Implementation of
ClassifiedHarnessError.harnessFailure
message
message: string;
Implementation of
ClassifiedHarnessError.message
Inherited from
Error.message
name
name: string;
Implementation of
ClassifiedHarnessError.name
Inherited from
Error.name
stack?
stack?: string;
Implementation of
ClassifiedHarnessError.stack
Inherited from
Error.stack
CursorSdkNotInstalledError
The optional @cursor/sdk peer dependency is not installed. Raised on the
first RUN, not at import and not when the block is built — a block can be
constructed on a host that never runs it.
Extends
Error
Constructors
Constructor
new CursorSdkNotInstalledError(message?, detail?): CursorSdkNotInstalledError;
Parameters
message?
string
detail?
cause?
string
Returns
Overrides
Error.constructor
Properties
cause?
cause?: unknown;
Inherited from
Error.cause
code
readonly code: "CURSOR_SDK_NOT_INSTALLED" = "CURSOR_SDK_NOT_INSTALLED";
detail?
readonly detail?: object;
cause?
cause?: string;
message
message: string;
Inherited from
Error.message
name
name: string;
Inherited from
Error.name
stack?
stack?: string;
Inherited from
Error.stack
Interfaces
CursorAgentHandle
Handle for a single Cursor run.
The neutral harness handle plus Cursor's own extras. status never reaches
"dispatched"/"running": this door observes its run to completion or
throws, so a returned handle is always terminal.
outcome is "finished" on a run the SDK reports as finished and "failed"
on one it reports as errored or cancelled. Cursor reports no turn or budget
cap, so "stopped-at-limit" is never produced here — and a run stopped by the
CALLER's deadline is a throw, not a handle (the harness abort contract).
sessionId is the agent id, not the run id. That is the thing resume takes:
a Cursor agent is the durable conversation, and each send is one run inside
it.
Extends
HarnessRunHandle
Properties
cost
cost: HarnessRunCost | null;
What the run cost and how that was arrived at, or null when neither is known.
Inherited from
HarnessRunHandle.cost
cursorUsage
cursorUsage: CursorRunUsage | null;
Cursor's own usage breakdown, or null when the run reported none.
dispatchedAt
dispatchedAt: number;
Epoch millis when the handle was created.
Inherited from
HarnessRunHandle.dispatchedAt
failureMessage
failureMessage: string | null;
The message from a failed or cancelled run, or null when it neither failed nor was cancelled.
finalMessage
finalMessage: string | null;
The run's last assistant text, or null if it produced none.
Inherited from
HarnessRunHandle.finalMessage
outcome
outcome: HarnessRunOutcome | null;
How the run ended, or null while it is unknown.
Inherited from
HarnessRunHandle.outcome
sessionId
sessionId: string | null;
The harness's own session/run id, when one could be determined.
Inherited from
HarnessRunHandle.sessionId
source
source: "cursor/sdk";
Which harness and door produced this — see HarnessSource.
Overrides
HarnessRunHandle.source
status
status: "completed" | "errored";
Overrides
HarnessRunHandle.status
url
url: string | null;
Human-openable URL for the run, when the harness exposes one.
Inherited from
HarnessRunHandle.url
usage
usage: HarnessRunUsage | null;
Token usage, or null when the harness reported none.
Inherited from
HarnessRunHandle.usage
CursorAgentLike
The subset of the SDK's SDKAgent this package drives.
Properties
agentId
readonly agentId: string;
Methods
close()?
close?(): void;
Releases the local runtime. Called in a finally, so a run never leaks one.
Returns
void
send()
send(message, options?): Promise<CursorRunLike>;
The prompt alone, or with the turn's images.
Parameters
message
string | CursorUserMessage
options?
Returns
Promise<CursorRunLike>
CursorAgentOptions
Options for cursorAgent.
Properties
agent?
agent?: CursorCreateOptions;
The SDK's agent options, forwarded verbatim to Agent.create /
Agent.resume (model, api key, mode, tools, MCP servers, the rest of
local besides cwd).
model here is also the cost-estimate fallback — used when the run's own
system message does not name the model that ran. Cursor's SDK refuses to
create a local agent without one, so this is not optional in practice.
An agentId, a cloud bag, or a local.cwd in this group is refused when
the block is built: each has exactly one owner (resume, "this version is
local-only", and cwd).
cwd?
cwd?: HarnessResolver<string>;
Where the run works. Called once per invocation, before anything is
created, and its answer becomes the agent's local.cwd.
A resolver, never a field on the block's input — a correctness constraint, not a style preference. The same block is a model-facing tool through the capability, so a directory reachable from the input is one the model could choose. Omit it and the SDK picks its own default, which is almost never what a host wants.
env?
env?: Record<string, string>;
The environment Cursor's runtime sees, and all of it. Default: unset,
which runs the runtime in this process, where every command Cursor runs
inherits the server's whole process.env.
Set, the block runs Cursor's local runtime in a separate Node process whose environment is exactly this, nothing inherited, so the commands Cursor runs start with only these variables. Cursor's SDK has no environment option of its own and copies its process's environment into every shell it starts, so the process is the only lever.
Not a security boundary. The process runs as the same OS user as the
server, and on Linux a command can read any same-user process's
environment through /proc/<pid>/environ, the server's included. Use a
separate user or a container when that matters. Build it with
core's harnessEnv({ pass: [...] }). Name PATH (the run's shell commands
are found through it) and HOME (Cursor keeps its agents and its stored
login under it, so a resumed agent is found only with the same HOME), and
CURSOR_API_KEY unless agent.apiKey carries the key.
A process that cannot start, or that dies, fails the run with the reason.
It never falls back to this process. Because the options cross a process
boundary, a function anywhere in agent or send (onStep, onDelta,
custom tools) is refused when the block is built, and so is a custom
resolveCursorClient, which would bypass the separate process.
model?
model?:
| string
| CursorModelSelection
| HarnessResolver<
| string
| CursorModelSelection
| null
| undefined>;
Which model the run uses: a fixed id, or a resolver called once per
invocation, like cwd and resume, so one block can run a different
model for each run. It becomes the agent's model on Agent.create and
Agent.resume alike, and the cost-estimate fallback.
A model with settings (a Grok's effort) is named as { id, params }: the
resolver may return one per run, and a fixed one is the same value for
every run (the same as agent.model).
null, "" and undefined from the resolver all mean "no model named",
and Cursor's SDK refuses a local agent with none, so name one here or on
agent.model. Setting this beside agent.model or send.model is
refused when the block is built: one owner per value.
name?
name?: string;
Block name. Default "cursor-agent".
onActivity?
onActivity?: HarnessActivityHook;
Called with each tool call the run starts, so a host can say how the run is doing. Not awaited, and a throw is logged and swallowed. Assistant text is not reported: Cursor streams it in pieces, and a piece is not a line a person can read.
onEvent?
onEvent?: HarnessEventHook;
Called on every event the run sends, of any kind, so a host can tell a working run from a silent one. Not awaited, and a throw is logged and swallowed.
onSession?
onSession?: HarnessSessionHook;
The write side of resume: called once, with the agent id, the moment the SDK opens one — and before the prompt is sent.
This is the only carrier that survives a cancelled run. A throw returns no
handle and a status item is transient by contract, so a host
whose deadline fired would otherwise have nothing to resume from. The hook
fires on a successful create / resume and on nothing else, which is why
a REFUSED resume never reaches it: the SDK throws instead of opening an
agent, so no dead id is ever written back over a good one.
onSteerable?
onSteerable?: HarnessSteerHook;
Offered Cursor's run.steer once the prompt is sent, on a run that has
one (a local run), so the host can hand a line to the turn in flight; then
null before the block returns, on every exit. Never called for a run
that can't steer.
The steer answers "delivered" only for Cursor's complete_delivered;
revert_to_followup, a throw, or a line sent after the offer was
withdrawn are "refused", and the host sends the line its own way. A turn
that ends with an answer still owed waits for it before the block returns,
with no timer; only a run stopped from outside (its deadline) leaves one
unanswered.
recordPlan?
recordPlan?: boolean;
Record Cursor's to-do list in the run's plan record, core's
observed-plan collection, with its observed-plan-list marker. Default
false.
On, the block declares both collections and, each time Cursor confirms an
update to its list, writes the whole list it confirmed through core's
replacePlanList: a row per place, Cursor's own status words, under the
agent's conversation namespace (harnessConversationNamespace(agentId)),
so a later run of the same agent keeps the list until Cursor changes it.
Each run also leaves a pointer to that namespace under its own. The update
Cursor sent is never written; it can name only part of the list. A list
that cannot be stored in full marks the conversation's marker incomplete
and the run carries on.
Off, the block writes no plan.
recordPullRequests?
recordPullRequests?: boolean;
Record each pull request the run opens in core's pull-request record
(observed-pull-requests). Default true: the block declares the
collection and starts the request's recorder (core's
recordPullRequests), which reads Cursor's shell calls as they settle. A
gh pr create whose result names a pull request is a row; a gh pr view
is not. false declares nothing and records nothing.
resolveCursorClient?
resolveCursorClient?: ResolveCursorClient;
Host hook resolving the Cursor client. Default: lazy SDK import, or the
child process when CursorAgentOptions.env is set. Not allowed
together with env.
resume?
resume?: HarnessResolver<string | null | undefined>;
Which conversation to continue. Called once per invocation; null, ""
and undefined all mean "start a fresh agent".
Same fence as cwd, and the same reason: a session id on the input is a
model resuming any conversation it has seen into the current checkout.
send?
send?: CursorSendOptions;
The SDK's send options, forwarded verbatim to agent.send. A cloud bag
here is refused for the same reason it is refused on agent.
uses?
uses?: UsesSlot;
Capabilities forwarded to the underlying handler.
CursorCreateOptions
The SDK's AgentOptions, forwarded verbatim to Agent.create /
Agent.resume and typed locally.
Three things are deliberately ABSENT, and each is refused at build time rather than merged, because each has exactly one owner:
agentId— theresumeresolver decides which conversation continues.local.cwd— thecwdresolver decides where a run works. The rest oflocalis forwarded.cloud— v1 drives Cursor's LOCAL runtime only, so a cloud bag would be silently ignored by a code path that assumes a local checkout.
apiKey is where Cursor's credential goes. Leave it unset and the SDK reads
CURSOR_API_KEY from the environment itself.
Properties
agents?
agents?: Record<string, unknown>;
apiKey?
apiKey?: string;
disallowedTools?
disallowedTools?: string[];
idempotencyKey?
idempotencyKey?: string;
local?
local?: object;
The SDK's local-runtime bag, minus cwd.
autoReview?
autoReview?: boolean;
customTools?
customTools?: Record<string, unknown>;
dirs?
dirs?: string[];
enableAgentRetries?
enableAgentRetries?: boolean;
sandboxOptions?
sandboxOptions?: object;
sandboxOptions.enabled
enabled: boolean;
settingSources?
settingSources?: string[];
store?
store?: unknown;
mcpServers?
mcpServers?: Record<string, unknown>;
mode?
mode?: "agent" | "plan";
model?
model?: CursorModelSelection;
Which model runs. Required by the SDK for a local agent; Agent.create
throws a typed configuration error without it.
This is also what the cost estimate is priced against when the run's own messages do not name a model.
name?
name?: string;
systemPrompt?
systemPrompt?: string;
tools?
tools?: string[];
CursorModelSelection
Cursor's model selection: an id plus whatever parameters that model exposes.
Properties
id
id: string;
params?
params?: object[];
id
id: string;
value
value: string;
CursorModelVariant
One way Cursor runs a model: the settings to hand it, and Cursor's name for them.
Properties
description?
description?: string;
Cursor's description of it, when it gave one.
isDefault
isDefault: boolean;
Whether Cursor runs the model this way when no settings are named.
label
label: string;
Cursor's name for the variant.
params
params: object[];
The model's settings for this variant. Hand them as the selection's params.
id
id: string;
value
value: string;
CursorReadinessOptions
Options for checkCursorReadiness.
Properties
readInstalledSdkVersion?
readInstalledSdkVersion?: InstalledSdkVersionReader;
Which @cursor/sdk is installed. Default: the one beside this package.
A seam for a host's own check and for tests; the block itself always
reads the installed one.
CursorRunError
What the SDK says a run's failure was.
Properties
code?
code?: string;
message
message: string;
CursorRunLike
The subset of the SDK's Run this package drives.
Properties
id
readonly id: string;
Methods
cancel()
cancel(): Promise<void>;
Returns
Promise<void>
steer()?
steer?(text): Promise<string>;
Hand a line to the turn in flight. Local runs only; settles on Cursor's
terminal answer, and revert_to_followup means "send it as a follow-up".
Parameters
text
string
Returns
Promise<string>
stream()
stream(): AsyncIterable<CursorSdkMessage>;
Returns
AsyncIterable<CursorSdkMessage>
supports()?
supports?(operation): boolean;
The SDK's own capability probe. Absent on a scripted double, and then every operation is assumed supported.
Parameters
operation
string
Returns
boolean
wait()
wait(): Promise<CursorRunResult>;
Returns
Promise<CursorRunResult>
CursorRunResult
What run.wait() resolves to — the run's terminal record.
status is the SDK's own three-way terminal enum. result is the run's final
answer text; usage is cumulative across the turns that reported it.
Properties
durationMs?
durationMs?: number;
error?
error?: CursorRunError;
id?
id?: string;
model?
model?: CursorModelSelection;
result?
result?: string;
status
status: string;
usage?
usage?: CursorWireUsage;
CursorRunUsage
Cursor's full token breakdown for a run.
The neutral handle carries only inputTokens/outputTokens, which is what
every harness can fill honestly. The rest rides here so a consumer that wants
to price a run differently — or read what the cache actually saved — has the
raw numbers rather than our derivation of them.
reasoningTokens is a SUBSET of outputTokens, and totalTokens already
excludes it, as the SDK's own TokenUsage documents. Adding them would
double-count the reasoning.
Properties
cacheReadTokens
cacheReadTokens: number;
cacheWriteTokens
cacheWriteTokens: number;
inputTokens
inputTokens: number;
outputTokens
outputTokens: number;
reasoningTokens
reasoningTokens: number;
totalTokens
totalTokens: number;
CursorSandboxProbeOptions
Options for probeCursorSandbox.
Properties
cwd
cwd: string;
The directory a run would work in.
env
env: Record<string, string>;
The probe process's whole environment: pass the one the run is handed.
sdkModule?
sdkModule?: string;
The module the probe loads the SDK from. Default @cursor/sdk. A test seam.
CursorSendOptions
The SDK's SendOptions, forwarded verbatim to agent.send.
cloud is absent for the same reason it is absent from
CursorCreateOptions. onStep and onDelta are forwarded: they are
the host's own observers, and this package's item mirror is built from
run.stream() rather than from them, so a host taking both sees the same run
twice rather than a partial one.
Properties
idempotencyKey?
idempotencyKey?: string;
local?
local?: object;
customTools?
customTools?: Record<string, unknown>;
force?
force?: boolean;
mcpServers?
mcpServers?: Record<string, unknown>;
mode?
mode?: "agent" | "plan";
model?
model?: CursorModelSelection;
onDelta?
onDelta?: (args) => void | Promise<void>;
Parameters
args
update
unknown
Returns
void | Promise<void>
onStep?
onStep?: (args) => void | Promise<void>;
Parameters
args
step
unknown
Returns
void | Promise<void>
CursorUserMessage
A turn sent with images, as the SDK's SDKUserMessage takes it: the prompt
and each image's bytes as base64.
Properties
images?
images?: object[];
data
data: string;
mimeType
mimeType: string;
text
text: string;
CursorWireUsage
Cursor's per-run token report, in the SDK's own spelling.
Properties
cacheReadTokens
cacheReadTokens: number;
cacheWriteTokens
cacheWriteTokens: number;
inputTokens
inputTokens: number;
outputTokens
outputTokens: number;
reasoningTokens?
reasoningTokens?: number;
totalTokens
totalTokens: number;
ListCursorModelsOptions
Options for listCursorModels.
Properties
env
env: Readonly<Record<string, string>>;
The environment a run gets: the asking process's whole environment. Nothing else is inherited.
sdkModule?
sdkModule?: string;
The module the asking process loads the SDK from. Default @cursor/sdk. A test seam.
timeoutMs?
timeoutMs?: number;
How long to wait for Cursor's answer. Default 10 000 ms.
ResolvedCursorClient
The subset of the SDK's Agent class this package drives.
Methods
create()
create(options): Promise<CursorAgentLike>;
Parameters
options
CursorCreateOptions & object
Returns
Promise<CursorAgentLike>
resume()
resume(agentId, options): Promise<CursorAgentLike>;
Parameters
agentId
string
options
CursorCreateOptions & object
Returns
Promise<CursorAgentLike>
Type Aliases
CursorContentBlock
type CursorContentBlock =
| {
text: string;
type: "text";
}
| {
id: string;
input: unknown;
name: string;
type: "tool_use";
}
| {
type: string;
};
A block inside an assistant message: prose, or the model calling a tool.
CursorHarnessOptions
type CursorHarnessOptions = Omit<CursorAgentOptions, "cwd" | "resume" | "onSession" | "onSteerable" | "onActivity" | "onEvent">;
What cursorHarness takes: the Cursor block's options, less what each run feeds it.
CursorSandboxSupport
type CursorSandboxSupport =
| {
supported: true;
}
| {
reason: string;
supported: false;
};
Whether Cursor's sandbox can start here, and if not, Cursor's reason.
CursorSdkImporter
type CursorSdkImporter = () => Promise<{
Agent?: unknown;
}>;
How the resolver loads the SDK module. Overridable so the absent-SDK path is testable.
Returns
Promise<{
Agent?: unknown;
}>
CursorSdkMessage
type CursorSdkMessage =
| {
model?: CursorModelSelection;
subtype?: string;
tools?: string[];
type: "system";
}
| {
message: {
content: CursorContentBlock[];
role: "assistant";
};
type: "assistant";
}
| {
message: {
content: object[];
role: "user";
};
type: "user";
}
| {
args?: unknown;
call_id: string;
name: string;
result?: unknown;
status: "running" | "completed" | "error";
type: "tool_call";
}
| {
text: string;
thinking_duration_ms?: number;
type: "thinking";
}
| {
message?: string;
status: "CREATING" | "RUNNING" | "FINISHED" | "ERROR" | "CANCELLED" | "EXPIRED";
type: "status";
}
| {
request_id: string;
type: "request";
}
| {
status?: string;
text?: string;
type: "task";
}
| {
type: "usage";
usage: CursorWireUsage;
}
| {
type: string;
};
One message from run.stream().
Nine kinds on the tested wire. Every field this package READS is optional or
guarded at the point of use even inside a kind we recognise: the version gate
holds the boundary, but a vendor moving a field WITHIN a message it still
calls assistant would otherwise crash translation on a wire the gate had
already approved.
CursorSignIn
type CursorSignIn =
| {
status: "key" | "login";
}
| {
reason: string;
status: "none";
};
The sign-in cursorSignIn found.
ResolveCursorClient
type ResolveCursorClient = (ctx) =>
| ResolvedCursorClient
| Promise<ResolvedCursorClient>;
Host hook resolving the Cursor client for a block invocation.
Accepts the block context loosely so a fully parameterized execute context
passes without a cast — the same reason ResolveCodexClient does.
Parameters
ctx
BlockContext<any, any, any, any, any, any, any, any, any>
Returns
| ResolvedCursorClient
| Promise<ResolvedCursorClient>
Variables
CURSOR_PASS
const CURSOR_PASS: readonly ["PATH", "HOME", "USER", "SHELL", "TMPDIR", "HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy", "NO_PROXY", "no_proxy", "CURSOR_API_KEY", "NODE_EXTRA_CA_CERTS"];
The only variables of the server's environment a Cursor run needs, for
env: harnessEnv({ pass: CURSOR_PASS }) with harnessEnv from
@flow-state-dev/core. Without env, Cursor's runtime runs in the server's
own process and every command it starts copies the server's whole
process.env, every key, token and connection string in it.
Core's HARNESS_BASE_PASS and this harness's own names: PATH (its shell finds commands through it), HOME (Cursor keeps its
agents and its stored login there, so a resumed agent is found only under
the same home), USER, SHELL and TMPDIR (its shell), CURSOR_API_KEY,
and the proxy and CA settings a proxied network needs, in upper and lower
case.
It filters what a run starts with, not what it can read: a command the run
starts as the server's OS user can still read the server's own environment.
Pass the same environment to cursorSignIn, so it checks the sign-in the
run gets. A host that needs more passes its own list.
CURSOR_SIGN_IN_REMEDY
const CURSOR_SIGN_IN_REMEDY: "Set CURSOR_API_KEY, or sign in to Cursor" = "Set CURSOR_API_KEY, or sign in to Cursor";
What the user does when Cursor has no sign-in.
CURSOR_SOURCE
const CURSOR_SOURCE: "cursor/sdk";
This harness's <package>/<door> name — the convention every writer of a
harness handle's source owes. The suffix names the door we drive
Cursor through, and this package has exactly one: Cursor's own SDK, on its
local runtime.
cursorAgentHandleSchema
const cursorAgentHandleSchema: z.ZodObject<object & object, "strip", z.ZodTypeAny, {
cost: | {
basis: "estimated" | "reported";
usd: number;
}
| null;
cursorUsage: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage: string | null;
finalMessage: string | null;
outcome: "failed" | "finished" | "stopped-at-limit" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage: | {
inputTokens: number;
outputTokens: number;
}
| null;
}, {
cost?: | {
basis: "estimated" | "reported";
usd: number;
}
| null;
cursorUsage?: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage?: string | null;
finalMessage?: string | null;
outcome?: "failed" | "finished" | "stopped-at-limit" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage?: | {
inputTokens: number;
outputTokens: number;
}
| null;
}>;
Runtime validator for CursorAgentHandle.
The extension's own two fields default to null for the same reason the
neutral schema's four do: a handle persisted before they existed still parses.
Functions
checkCursorReadiness()
function checkCursorReadiness(env, options?): Promise<HarnessReadiness>;
Whether Cursor can run on this machine, as core's neutral readiness: an installed SDK in the range this package tested, then the answer of cursorSignIn, with what to do when there is none. An SDK that won't load, or a sign-in read that fails, is not ready with its reason; a key counts only when the SDK also loads, since a run needs both. Never throws.
Parameters
env
Readonly<Record<string, string>>
options?
Returns
Promise<HarnessReadiness>
createCursorAgentCapability()
function createCursorAgentCapability(options?): DefinedCapability<"cursor-agent", Record<string, never>, "default" | "tools", Record<string, PresetDef<any>>, undefined, {
[x: string]: DeclaredResourceEntry;
}, undefined, undefined, undefined> & object;
Create the Cursor agent capability. Forwards every agent option to the underlying handler — including the version gate, which therefore refuses here too rather than at the first run.
Parameters
options?
Returns
DefinedCapability<"cursor-agent", Record<string, never>, "default" | "tools", Record<string, PresetDef<any>>, undefined, {
[x: string]: DeclaredResourceEntry;
}, undefined, undefined, undefined> & object
createDefaultResolveCursorClient()
function createDefaultResolveCursorClient(importSdk?): ResolveCursorClient;
Build a resolver that loads the SDK via importSdk and adapts its Agent
statics to this package's client seam. Throws
CursorSdkNotInstalledError when the module cannot be loaded or does
not export a usable Agent.
The adapter is thin on purpose: create and resume are the SDK's own, and
everything this package decides about them (the directory, the resumed id, the
refused keys) is decided before they are called.
Exported mainly so a test can supply an importer that rejects; production uses the default the block installs for itself.
Parameters
importSdk?
Returns
cursorAgent()
function cursorAgent(options?): BlockDefinition<ZodObject<{
attachments: ZodOptional<ZodArray<ZodObject<{
data: ZodEffects<ZodString, string, string>;
filename: ZodOptional<ZodString>;
mediaType: ZodString;
type: ZodLiteral<"file">;
}, "strip", ZodTypeAny, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}>, "many">>;
prompt: ZodString;
}, "strip", ZodTypeAny, {
attachments?: object[];
prompt: string;
}, {
attachments?: object[];
prompt: string;
}>, ZodObject<object & object, "strip", ZodTypeAny, {
cost: | {
basis: "reported" | "estimated";
usd: number;
}
| null;
cursorUsage: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage: string | null;
finalMessage: string | null;
outcome: "finished" | "stopped-at-limit" | "failed" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage: | {
inputTokens: number;
outputTokens: number;
}
| null;
}, {
cost?: | {
basis: "reported" | "estimated";
usd: number;
}
| null;
cursorUsage?: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage?: string | null;
finalMessage?: string | null;
outcome?: "finished" | "stopped-at-limit" | "failed" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage?: | {
inputTokens: number;
outputTokens: number;
}
| null;
}>, {
attachments?: object[];
prompt: string;
}, CursorAgentHandle> & object;
Build the Cursor harness block.
Refuses to build against an installed @cursor/sdk that is not the tested
version, and against an option group carrying an agent id, a cloud bag, or a
working directory. Both are configuration errors a host sees at wiring time.
Parameters
options?
Returns
BlockDefinition<ZodObject<{
attachments: ZodOptional<ZodArray<ZodObject<{
data: ZodEffects<ZodString, string, string>;
filename: ZodOptional<ZodString>;
mediaType: ZodString;
type: ZodLiteral<"file">;
}, "strip", ZodTypeAny, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}>, "many">>;
prompt: ZodString;
}, "strip", ZodTypeAny, {
attachments?: object[];
prompt: string;
}, {
attachments?: object[];
prompt: string;
}>, ZodObject<object & object, "strip", ZodTypeAny, {
cost: | {
basis: "reported" | "estimated";
usd: number;
}
| null;
cursorUsage: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage: string | null;
finalMessage: string | null;
outcome: "finished" | "stopped-at-limit" | "failed" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage: | {
inputTokens: number;
outputTokens: number;
}
| null;
}, {
cost?: | {
basis: "reported" | "estimated";
usd: number;
}
| null;
cursorUsage?: | {
cacheReadTokens: number;
cacheWriteTokens: number;
inputTokens: number;
outputTokens: number;
reasoningTokens: number;
totalTokens: number;
}
| null;
dispatchedAt: number;
failureMessage?: string | null;
finalMessage?: string | null;
outcome?: "finished" | "stopped-at-limit" | "failed" | null;
sessionId: string | null;
source: "cursor/sdk";
status: "completed" | "errored";
url: string | null;
usage?: | {
inputTokens: number;
outputTokens: number;
}
| null;
}>, {
attachments?: object[];
prompt: string;
}, CursorAgentHandle> & object
cursorHarness()
function cursorHarness(options?): Harness;
Cursor as a harness value.
Parameters
options?
The Cursor block's options. Its environment is always Cursor's own.
Returns
Harness
cursorSignIn()
function cursorSignIn(env): Promise<CursorSignIn>;
Cursor's sign-in over env. See the file header for where each answer comes from.
Parameters
env
Readonly<Record<string, string>>
Returns
Promise<CursorSignIn>
listCursorModels()
function listCursorModels(options): Promise<HarnessModelList<HarnessModelInfo & object>>;
Ask Cursor for the models the account can run, without a run.
Parameters
options
Returns
Promise<HarnessModelList<HarnessModelInfo & object>>
models in Cursor's order, or failed with a reason. Never throws.
probeCursorSandbox()
function probeCursorSandbox(options): CursorSandboxSupport;
Ask Cursor's SDK whether its local sandbox can start for a run in cwd.
Synchronous, and takes about a second: call it once, from a host check.