Interact with Asteroid Agents using TypeScript
Installation
Create your TypeScript file (run_agent.ts)
Run the agent
Method | Purpose | Returns |
---|---|---|
executeAgent() | Start agent execution | execution_id |
waitForExecutionResult() | Wait for completion | result |
getExecutionStatus() | Check current status | status_info |
getExecutionResult() | Get final result | result |
uploadExecutionFiles() | Upload files | upload_response |
getBrowserSessionRecording() | Get recording URL | url |
getCredentialsPublicKey() | Get encryption public key | public_key |
getAgentProfiles() | List agent profiles | profiles |
getAgentProfile() | Get specific profile | profile |
createAgentProfile() | Create new profile | profile |
updateAgentProfile() | Update existing profile | profile |
deleteAgentProfile() | Delete profile | success_message |
getLastNExecutionActivities() | Get execution activities | activities |
addMessageToExecution() | Add message to execution | void |
executeAgent() - Execute an agent with prompt variables
client
: The configured API clientagentId
: The ID of the agent to executeexecutionData
: The execution parametersagent_profile_id
: Optional ID of the agent profilegetExecutionStatus() - Get the current status for an execution
client
: The configured API clientexecutionId
: The execution identifiergetExecutionResult() - Get the final result of an execution
client
: The configured API clientexecutionId
: The execution identifierwaitForExecutionResult() - Wait for an execution to reach a terminal state and return the result
client
: The configured API clientexecutionId
: The execution identifierinterval
: Polling interval in milliseconds (default is 1000)timeout
: Maximum wait time in milliseconds (default is 3600000 - 1 hour)AsteroidClient() - Create an API client with authentication
apiKey
: Your API key for authenticationuploadExecutionFiles() - Upload files to an execution
client
: The configured API clientexecutionId
: The execution identifierfiles
: Array of files to upload (Blob or File objects)getBrowserSessionRecording() - Get the browser session recording URL for a completed execution
client
: The configured API clientexecutionId
: The execution identifiergetAgentProfiles() - Get a list of agent profiles
client
: The configured API clientorganizationId
: The organization identifier (optional). Returns all agent profiles if no organizationId is provided.getAgentProfile() - Get a specific agent profile by ID
client
: The configured API clientprofileId
: The agent profile IDcreateAgentProfile() - Create a new agent profile
client
: The configured API clientpayload
: The agent profile dataupdateAgentProfile() - Update an existing agent profile
client
: The configured API clientprofileId
: The agent profile IDpayload
: The update datadeleteAgentProfile() - Delete an agent profile by ID
client
: The configured API clientprofileId
: The agent profile ID