@tunnlo/adapter-sdk
v0.1.1
Published
SDK for building custom Tunnlo adapters
Maintainers
Readme
@tunnlo/adapter-sdk
SDK for building custom Tunnlo adapters.
Part of the Tunnlo project -- a real-time data-to-agent bridge with intelligent filtering.
Installation
npm install @tunnlo/adapter-sdkUsage
import { PollingAdapter } from '@tunnlo/adapter-sdk';
import type { TunnloEvent } from '@tunnlo/core';
class MyApiAdapter extends PollingAdapter {
async poll(): Promise<TunnloEvent[]> {
const data = await fetch('https://api.example.com/events');
const items = await data.json();
return items.map((item: any) => this.createEvent('api', item));
}
}Testing Your Adapter
import { AdapterTestHarness } from '@tunnlo/adapter-sdk';
const harness = new AdapterTestHarness(MyApiAdapter, {
id: 'test',
type: 'my-api',
config: {},
});
const events = await harness.collectEvents(5);
console.log(`Received ${events.length} events`);API
PollingAdapter-- base class for adapters that periodically fetch dataPushAdapter-- base class for adapters that receive data via callbacks or streamsAdapterTestHarness-- test utility for verifying adapter behaviorcreateAdapterTemplate(name)-- generates boilerplate files for a new adapterAdapterRegistry-- registry for discovering and loading adaptersglobalRegistry-- shared global adapter registry instance
License
MIT
