Skip to content

API Reference Overview

Complete API documentation for all AIV Platform modules.

Module APIs

ModuleMain ClassFactory Function
DaemonDaemonManagercreateDaemonManager()
CronSchedulercreateScheduler()
HeartbeatHeartbeatServicecreateHeartbeatService()
ConfigConfigManagercreateConfigManager()
OnboardingOnboardingWizardcreateOnboardingWizard()

Common Patterns

Factory Functions

All modules provide factory functions that create pre-configured instances:

typescript
// Preferred way
const scheduler = createScheduler({ timezone: 'UTC' });

// Alternative
const scheduler = new Scheduler({ timezone: 'UTC' });

Event Emitters

All services extend EventEmitter with type-safe events:

typescript
// Type-safe event listeners
service.on('eventName', (data) => {
  // data is properly typed
});

// Remove listener
service.off('eventName', handler);

Validation

All inputs are validated using Zod schemas:

typescript
import { ConfigSchema, validateConfig } from '@aiversum/aiv-agents/config';

// Validate manually
const result = validateConfig(input);
if (!result.valid) {
  console.error(result.errors);
}

// Or use the schema directly
const parsed = ConfigSchema.parse(input);

Import Paths

typescript
// Individual modules
import { createDaemonManager } from '@aiversum/aiv-agents/daemon';
import { createScheduler } from '@aiversum/aiv-agents/cron';
import { createHeartbeatService } from '@aiversum/aiv-agents/heartbeat';
import { createConfigManager } from '@aiversum/aiv-agents/config';
import { createOnboardingWizard } from '@aiversum/aiv-agents/onboarding';

// Or from the main package
import {
  createDaemonManager,
  createScheduler,
  createHeartbeatService,
  createConfigManager,
  createOnboardingWizard,
} from '@aiversum/aiv-agents';

TypeScript Support

All modules are written in TypeScript with full type definitions:

typescript
import type {
  DaemonConfig,
  JobConfig,
  HealthCheckConfig,
  ConfigManagerConfig,
  WizardOptions,
} from '@aiversum/aiv-agents';

Error Handling

All modules use structured error handling:

typescript
try {
  await service.someOperation();
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Validation failed:', error.errors);
  } else if (error instanceof ConfigurationError) {
    console.error('Configuration error:', error.message);
  } else {
    throw error;
  }
}

Async/Await

All async operations return Promises:

typescript
// Async/await
const result = await service.load();

// Promise chains
service.load()
  .then(result => console.log(result))
  .catch(error => console.error(error));

Detailed Documentation

Select a module for complete API documentation:

Released under the MIT License.