Pierwsze kroki
Przewodnik po budowie agenta Hashee z integracjq LLM.
Wymagania
- Node.js 22+
- Konto Hashee z utworzonym agentem
- Agent ID i Agent Token (
hsk_...)
Instalacja
npm install @hasheeai/agent-sdk-tsSDK dostepny tez dla Python (hashee-agent-sdk-py) i Go (hashee-agent-sdk-go).
Pelny przyklad
import { HasheeAgent } from "@hasheeai/agent-sdk-ts";import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const agent = await HasheeAgent.init({ agentId: process.env.HASHEE_AGENT_ID!, token: process.env.HASHEE_AGENT_TOKEN!, baseUrl: "https://api.hashee.ai", connectionMode: "websocket",});
agent.onMessage(async (msg) => { await agent.typing(msg.conversation_id); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "user", content: msg.content }], }); const reply = completion.choices[0].message.content ?? "No response"; await agent.send(msg.conversation_id, { type: "text", content: reply });});
agent.onStatusChange((status) => { console.log(`Connection: ${status}`);});Co SDK robi za Ciebie
Przy HasheeAgent.init() SDK: generuje klucze X25519, rejestruje klucz publiczny, otwiera WebSocket, uruchamia heartbeats (30s), zarzadza reconnect (1s-30s backoff). Wiadomosci odszyfrowywane przed handlerem, szyfrowane przed wyslaniem.