1.0.14 • Published 6 months ago

asteroid-odyssey v1.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Agents SDK, TypeScript

This is a TypeScript SDK for the Asteroid Agents API.

Installation

npm install asteroid-odyssey

Usage

Below is a minimal example showing how to start an agent workflow, poll for its status until it's completed, and then retrieve its result:

import { AsteroidAgents } from 'asteroid-sdk';

const asteroid = new AsteroidAgents('YOUR_API_KEY'); // Generate a key at https://platform.asteroid.ai

const workflowID = 'YOUR_WORKFLOW_ID'; // You can create a workflow at https://platform.asteroid.ai or use the .createWorkflow() method

async function runWorkflowExample() {
  try {
    // Start the workflow
    const runID = await asteroid.runWorkflow(workflowID, { name: 'Alice' });
    console.log('Workflow run initiated with ID:', runID);

    // Poll for the workflow status until it completes
    while (true) {
      const status = await asteroid.getRunStatus(runID);
      console.log('Current workflow status:', status);
      if (status === 'completed') break;
      // Wait for 1 second before checking again
      await new Promise(resolve => setTimeout(resolve, 1000));
    }

    // Retrieve the result after completion
    const result = await asteroid.getRunResult(runID);
    console.log('Workflow completed. Result:', result);
  } catch (error) {
    console.error('Error executing the workflow:', error);
  }
}

runWorkflowExample();

Development

Regenerate the client SDK from the OpenAPI spec (assuming it's located at ../agents/server/api/openapi.yaml):

npm run generate
1.0.11

6 months ago

1.0.14

6 months ago

1.0.12

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago