0.1.1 • Published 8 months ago

@auto-genesis/sdk v0.1.1

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Autonomize SDK

The official TypeScript SDK for Autonomize platform, providing unified access to Genesis API and OpenTelemetry capabilities. This SDK bundles both @auto-genesis/core and @auto-genesis/telemetry packages for a seamless integration experience.

Installation

# Using npm
npm install @auto-genesis/sdk

# Using yarn
yarn add @auto-genesis/sdk

# Using pnpm
pnpm add @auto-genesis/sdk

Quick Start

import { Genesis, Telemetry } from '@auto-genesis/sdk';
// or
import SDK from '@auto-genesis/sdk';

// Initialize Genesis
const genesis = new Genesis({
  baseURL: 'https://api-genesis.sprint.autonomize.dev/api/v1/',
  auth: {
    baseUrl: 'https://auth.sprint.autonomize.dev/',
    realm: 'autonomize',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
  },
});

// Initialize Telemetry
const telemetry = new Telemetry({
  serviceName: 'your-service-name',
  environment: 'production',
  version: '1.0.0',
  otlpEndpoint: 'http://localhost:4318',
});

// Start services
await genesis.initialize();
await telemetry.start();

Features

Genesis Features

  • Secure Authentication
  • Keycloak integration
  • Multiple authentication flows
  • Automatic token management

  • Copilot Management

  • Assign and manage copilots
  • Customize copilot behavior
  • Monitor copilot performance

Telemetry Features

  • Unified Metrics Collection
  • Custom metrics with counters and histograms
  • Configurable export intervals
  • Pre-configured attributes

  • Distributed Tracing

  • Automatic context propagation
  • Built-in span management
  • Error recording

  • Structured Logging

  • Trace correlation
  • Multiple severity levels
  • Error stack trace handling

Package Components

Genesis Module

import { Genesis } from '@auto-genesis/sdk';

const genesis = new Genesis({
  baseURL: 'https://api.example.com',
  auth: {
    baseUrl: 'https://auth.example.com',
    realm: 'your-realm',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
  },
});

// Make API calls
const copilots = await genesis.copilots.getAssignedCopilots({
  page: 1,
  limit: 10,
});

Telemetry Module

import { Telemetry } from '@auto-genesis/sdk';

const telemetry = new Telemetry({
  serviceName: 'your-service',
  environment: 'production',
});

// Create metrics
const requestCounter = telemetry.createCounter({
  name: 'http_requests_total',
  description: 'Total HTTP requests',
  unit: 'requests',
});

// Create traces
await telemetry.createSpan('operation-name', async () => {
  // Your operation code
});

// Add logs
telemetry.info('Operation started', { type: 'process' });

Requirements

  • Node.js >= 18
  • TypeScript >= 5 (if using TypeScript)
  • Auth (Keycloak) server for Genesis features
  • OpenTelemetry collector for Telemetry features

Error Handling

The SDK provides consistent error handling across all components:

try {
  // Genesis operations
  await genesis.copilots.findOne(args);

  // Telemetry operations
  await telemetry.createSpan('operation', async () => {
    // Your code
  });
} catch (error) {
  console.error('Error:', error.message);
  console.error('Details:', error.error);
}

Playground

To test new features or debug locally:

  1. Clone the repository:

    git clone https://github.com/autonomize-ai/autonomize-sdk-js.git
    cd autonomize-sdk-js
  2. Set up the playground:

    cd playground
    cp .env.example .env   # Configure your environment variables
    pnpm install
  3. Run the playground:

    pnpm dev

This will start a development environment where you can test SDK features without publishing to npm.

Support

For support and inquiries:

Contributing

We welcome contributions! Please read our contributing guidelines for details on our code of conduct and the process for submitting pull requests.

0.1.1

8 months ago

0.1.0

8 months ago

0.0.1

8 months ago

0.0.0

8 months ago