Skip to main content
Parity with the Python SDK: same methods (camelCase options), same typed errors, the same <haki_memory> block generated — zero runtime dependency (native fetch, Node ≥ 18).

Installation

Inside the Haki repository itself, building the SDK from source:

HakiClient

Promise<HealthResponse>
Promise<CaptureResponse>
events: EventInput[].
Promise<ContextResponse>
Promise<TraceResponse>
Promise<TimelineResponse>
Promise<ConsolidateResponse>
Promise<ForgetResponse>
Promise<FeedbackResponse>
Promise<ResolveConflictResponse>
Promise<KeyCreatedResponse>
Promise<KeyListResponse>
Promise<KeyRevokedResponse>
The wire format stays snake_case (contract B.1 and route schemas): the exported types (EventInput, CaptureResponse, ContextResponse…) expose fields like project_id, source_event_ids, trace_id as-is — only the method options are camelCase (projectId, subjectId…).

Typed errors

Same semantics as Python: HakiConnectionError (network), HakiApiError (statusCode, errorType, field, payload).

The two agent hooks (haki/runtime)

buildPromptContext produces text identical to the Python SDK (same fixed instruction, same - predicate: value (valid from ...; sources: ...) format). captureTurn(client, { subjectId, projectId, userMsg, assistantMsg, orgId?, agentId?, threadId?, kind? }) writes a conversation.turn event with idempotency_key: "turn-" + randomUUID().

CLI haki-ts

command
Tests /health, writes ~/.haki/config.json.
command
Full timed scenario, exit 0/1.
command
API health.
The config file (~/.haki/config.json, {api_url, api_key}) is the same as the Python CLI’s: both CLIs are interchangeable on the same machine.

Runnable example

sdk/typescript/examples/basic-agent.mjs in the repository — a complete minimal agent using HakiClient, buildPromptContext and captureTurn.