1.15.17 • Published 1 year ago

autonomize-sdk v1.15.17

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Autonomize SDK (@autonomize/sdk)

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

Installation

# Using npm
npm install autonomize-sdk

# Using yarn
yarn add autonomize-sdk

# Using pnpm
pnpm add autonomize-sdk

Quick Start

import { Genesis, OTEL } from 'autonomize-sdk';
// or
import SDK from 'autonomize-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 OTEL
const telemetry = new OTEL({
  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

OTEL 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 'autonomize-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
});

OTEL Module

import { OTEL } from 'autonomize-sdk';

const telemetry = new OTEL({
  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 OTEL features

Error Handling

The SDK provides consistent error handling across all components:

try {
  // Genesis operations
  await genesis.copilots.getAssignedCopilots(args);
  
  // OTEL 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.

1.15.10

1 year ago

1.15.8

1 year ago

1.15.11

1 year ago

1.15.7

1 year ago

1.15.12

1 year ago

1.15.6

1 year ago

1.15.13

1 year ago

1.15.5

1 year ago

1.15.9

1 year ago

1.15.14

1 year ago

1.15.15

1 year ago

1.15.16

1 year ago

1.15.17

1 year ago

1.15.4

1 year ago

1.15.3

1 year ago

1.15.2

1 year ago

1.15.1

1 year ago

1.15.0

1 year ago

1.14.0

1 year ago

1.13.0

1 year ago

1.12.15

1 year ago

1.12.14

1 year ago

1.12.13

1 year ago

1.12.12

1 year ago

1.12.11

1 year ago

1.12.10

1 year ago

1.12.9

1 year ago

1.12.8

1 year ago

1.12.7

1 year ago

1.12.6

1 year ago

1.12.5

1 year ago

1.12.4

1 year ago

1.12.3

1 year ago

1.10.0

1 year ago

1.9.0

1 year ago

0.2.0

1 year ago