AI agent instructions
AI agent instructions
await inside try/catch.
Configuration errors
NotteClient throwsAuthenticationError for a missing API key and InvalidRequestError for an unsupported API URL. HTTPS is required for remote servers; HTTP is allowed on loopback for local development.
API and execution errors
HTTP failures throw NotteAPIError, withstatusCode, path, the parsed error body, and the response when available. Request deadlines throw NotteTimeoutError. Failed actions throw ActionExecutionError; failed cloud function runs throw FailedToRunCloudFunctionError unless raiseOnFailure: false is set.
Treat caught values as unknown: check error instanceof Error before reading error.message. Do not depend on parsing error messages to identify HTTP status codes.
Session cleanup
Use Session.use for managed sessions. It starts the session before your callback and stops it when the callback finishes, including when it throws. Catch errors around the awaiteduse() call so failures reach your error handler.