import type { AdapterModule, InvokeInput, ModuleSetupContext, ServiceDefinition, ServiceState } from "@cyrnel/sdk";
class MyAdapter implements AdapterModule {
private state = new Map<string, ServiceState>();
async setup(_context: ModuleSetupContext) {}
async teardown() { this.state.clear(); }
async generateDefinition(input: string): Promise<ServiceDefinition> {
return {
name: "...",
description: "...",
configSchema: { type: "object", properties: {} },
secretsSchema: { type: "object", properties: {} },
adapterDomain: { /* parsed metadata */ },
tools: [
{
id: "ping",
name: "ping",
description: "Health check",
inputSchema: { type: "object" },
outputSchema: { type: "object" },
adapterDomain: { /* per-tool routing info */ },
},
],
};
}
async hydrateService(state: ServiceState): Promise<void> {
this.state.set(state.id, state);
}
async dehydrateService(id: string): Promise<void> {
this.state.delete(id);
}
async invoke(input: InvokeInput): Promise<unknown> {
const svc = this.state.get(input.serviceId);
if (!svc) throw new Error(`unknown service ${input.serviceId}`);
// ...use svc.adapterDomain / svc.config / svc.secrets to issue the call
return { ok: true };
}
}
const configSchema = { type: "object", properties: {} } as const;
const secretsSchema = { type: "null" } as const;
export default { configSchema, secretsSchema, instantiate: () => new MyAdapter() };