@ai-kod/api-client
v0.7.23
Published
Type-safe REST/SSE client for AI-KOD API
Readme
@ai-kod/api-client
Type-safe клиент для работы с AI-KOD API (REST + Server-Sent Events).
Установка
npm install @ai-kod/api-client
# или
pnpm add @ai-kod/api-clientБыстрый старт
import { createApiClient } from "@ai-kod/api-client";
const api = createApiClient({
baseUrl: process.env.AI_KOD_API_URL ?? "http://localhost:3010",
token: process.env.AI_KOD_API_TOKEN,
});
const workflows = await api.workflows.list();
console.log(workflows);Подписка на логи с heartbeat
const tail = api.logs.tail({ sources: ["event"], taskId: "TASK-03F", heartbeatMs: 15_000 });
for await (const event of tail) {
switch (event.type) {
case "connection":
console.info("connected", event.connectionId);
break;
case "heartbeat":
console.debug("heartbeat", event.entriesEmitted, event.lastActivityAt);
break;
case "entry":
console.log(event.entry.timestamp, event.entry.message);
break;
case "end":
console.warn("tail stopped", event.reason);
break;
}
}Скрипты
pnpm build— компиляция TypeScript вdist/pnpm test— unit-тесты (vitest)pnpm publish --access public— публикация пакета
Лицензия
Sustainable Use License (fair-code)
