@autonomize/sdk v0.0.20
Autonomize SDK
The official TypeScript SDK for Autonomize platform, providing unified access to Genesis API and OpenTelemetry capabilities. This SDK bundles both @autonomize/genesis-core
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.findOne(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:
Clone the repository:
git clone https://github.com/autonomize-ai/autonomize-sdk-js.git cd autonomize-sdk-js
Set up the playground:
cd playground cp .env.example .env # Configure your environment variables pnpm install
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:
- Email: info@autonomize.ai
- Issues: GitHub Repository
Contributing
We welcome contributions! Please read our contributing guidelines for details on our code of conduct and the process for submitting pull requests.
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago