Skip to content

Errors ​

SDKError ​

ts
class SDKError extends Error {
  code: string
  httpStatus?: number
}

error.message and error.code are the same fixed string. httpStatus is set when the failure came from an HTTP response. The message is safe to log. The class does not attach the response body, so a log of SDKError does not contain the token or the account payload.

Unknown constructor codes are stored as SDK_ERROR.

CodeWhen
MISSING_ACCESS_TOKENaccessToken is missing or empty. Also used by the CLI when whoami has no token source.
ACCOUNT_AUTH_FAILEDGetMe failed, or HTTP 200 lacked authId and userId.
RPC_FAILEDA unary roster or transcript call failed.
INVALID_ROSTER_RESPONSEListGrokBotAgents returned no agents array.
INVALID_BOT_RECORDA roster element has no agentId.
BOT_ID_REQUIREDbotId is empty, longer than 128, or outside [A-Za-z0-9_-].
NOT_A_ROOMdeleteRoom did not find that id in the roster, or the record's kind is not ROOM. Delete was not called.
MESSAGE_INVALIDText, session, message id, or attachment arrays failed validation.
SEND_UNCONFIRMEDThe send HTTP call failed. Do not automatically send again.
SEND_REFUSEDHTTP succeeded and delivery was not a known acceptance. Integer 4 and GROK_BOT_USER_MESSAGE_DELIVERY_REFUSED are this case.
CURSOR_INVALIDCursor fields, resume encoding, or using both cursor forms.
CURSOR_SCOPE_MISMATCHresumeFrom names another bot or session.
STREAM_CONNECTION_FAILEDWatch HTTP failed, or the socket failed before a typed stream error.
STREAM_INVALID_RESPONSEWatch HTTP 200 used a content type other than application/connect+json, or the body cannot be read.
STREAM_FRAME_TOO_LARGEA frame exceeds 1 MiB, or inlineBodyMaxBytes is out of range.
STREAM_COMPRESSION_UNSUPPORTEDThe compression flag bit is set.
STREAM_FLAGS_INVALIDFlags are neither data (0) nor end (2).
STREAM_INVALID_JSONA frame is not a JSON object.
STREAM_UNEXPECTED_EOFThe body ended without an end frame.
STREAM_END_INVALIDBytes followed the end frame.
STREAM_RPC_ERRORThe end frame carried an error object. The server error body is discarded.
STREAM_PROTOCOL_ERRORAn event could not be encoded as SSE.
STREAM_CANCELLEDReserved in the code list. Aborting a watch returns from the generator.
SDK_ERRORAn SSE iterator failed with a non-SDKError. The SSE error event uses this code.

On an SSE response that has already started, these codes arrive as:

text
event: error
data: {"code":"STREAM_RPC_ERROR"}

Login and desktop errors ​

These are Error with a fixed message, thrown by pollLogin, decryptMacSecret, selectDesktopAccount, or desktopCredentials.

MessageWhen
LOGIN_POLL_FAILEDThree poll responses in a row were neither success nor HTTP 404.
LOGIN_TIMED_OUTmaxAttempts finished while the login was still pending.
SIGN_IN_POLICY_VIOLATIONPoll returned HTTP 403 { "error": "sign_in_policy_violation" }. Polling stops.
CREDENTIAL_DECRYPT_FAILEDThe blob is not a v10 secret this code can open.
ACCOUNT_STORE_INVALIDcursor-accounts is not JSON.
NO_ACTIVE_ACCOUNTThe store has no usable active account.
ACCESS_TOKEN_MISSINGThe active account has no cursor-access-token.
KEYCHAIN_ACCESS_UNAVAILABLEsecurity could not return the Grok Bot password.
TOKEN_FILE_INVALIDThe CLI token file has no string accessToken.

The CLI prints { "status": "failed", "code": "<message>" } and exits 1. Usage mistakes exit 2.

Unofficial SDK by 铁柱AGI (@cgnot996). Not an xAI or Cursor product.