Reference · Public API
Package entrypoints
Heddle separates customization depth from hosting assumptions. Start with the curated SDK, then opt into hosted, transport, remote-client, or advanced surfaces only when your product actually owns that layer.
Customization depth
All depths — curated SDK through deep core building blocks
Hosting depth
Node.js 20+ runtime plus an independently installable browser-safe client package
Documentation status
Canonical reference
Assumptions
- Your Node host uses ESM and Node.js 20 or newer.
- Browser applications install @roackb2/heddle-remote instead of bundling the Node runtime.
- You want explicit import boundaries so hosting and transport assumptions remain visible in code review.
- Stable public entrypoint boundaries, exported contracts, runtime implementation, and the optional assumption layers documented below.
- Curated progressive disclosure in the root SDK and browser-safe protocol correctness in the remote package.
- Selecting and installing only the necessary entrypoints, composing them in the application root, and pinning compatible package versions.
- Framework, identity, authorization, public schemas, persistence adapters, deployment topology, transport policy, and UI architecture.
Install the runtime and remote client separately
The Node runtime package requires Node.js 20 or newer:
npm install @roackb2/heddleInstall the independent remote package only in applications that consume a hosted run without embedding the Node agent runtime:
npm install @roackb2/heddle-remoteThe packages are ESM. Import from the documented package and subpath entrypoints rather than reaching into dist or internal src paths.
Entrypoint map
| Entrypoint | Environment | Owns | Does not choose |
|---|---|---|---|
@roackb2/heddle | Node.js 20+ | Curated product-host SDK: quickstart, conversation engine, tools/extensions, output, lifecycle, approvals, session and artifact ports | Server framework, transport, auth, UI |
@roackb2/heddle/hosted | Long-lived Node host | Process-local run identity, ordered events, replay, cancellation, approvals, terminal settlement | HTTP, routes, durable broker, multi-process routing |
@roackb2/heddle/hosted/http-sse | Node HTTP server | Replay cursor parsing and correct SSE framing, backpressure, disconnect cleanup | Route registration, auth, CORS, rate limits, public errors |
@roackb2/heddle/advanced | Node.js 20+ | Curated SDK plus lower-level adapters, tools, traces, memory, agent loop, heartbeat, awareness, integrations, utilities | Remote hosting or transport assumptions |
@roackb2/heddle-remote | Browser or transport client | Runtime-validated run envelope, JSON safety, cursor, duplicate/gap/terminal handling, retry calculation | Transport, timer, auth, product schemas, UI |
@roackb2/heddle-remote/http-sse | Browser-safe fetch/SSE client | Conventional REST run resource, response validation, incremental SSE parsing, identity checks | React, auth policy, retry timing, cursor persistence |
@roackb2/heddle: curated product-host SDK
The default entrypoint is organized as a five-rung progressive-disclosure ladder.
1. Start a conversation
Primary exports:
runQuickstartConversationCli;resolveQuickstartConversationCliDefaults;QuickstartConversationCliRunnerService;createConversationEngine;- built-in default model constants.
Use the quickstart runner when Heddle may own a small terminal prompt loop. Use the conversation engine when your product owns presentation, session browsing, approvals, or lifecycle.
Core contracts
The root exports common types such as RunInput, RunResult, RunFailure, ModelRunFailureCode, ToolDefinition, ToolCall, ToolResult, TraceEvent, and StopReason.
These are host-facing contracts. Import them from the package root instead of duplicating shapes.
2. Add capabilities
Primary exports include:
defineHostExtensionandConversationEngineHostExtensionService;prepareMcpHostExtension,prepareMcpHostExtensionCatalog, and MCP option/result types;ToolRegistry,ToolExecutionService,ToolBundleComposer, andRuntimeToolService;- artifact and Agent Skills toolkits and services.
The older top-level tools engine option remains deprecated; new product hosts should compose product tools through hostExtensions.tools.
3. Shape input and output
Primary exports include:
createConversationTextHostandConversationTextHostService;ConversationActivityand its handler/correlation types;HeddleEventTypeandHeddleEventTypeValue;ConversationTurnResultSummaryandConversationTurnToolResult;ToolActivitySummarizer.
Use these contracts to build custom terminal, API, telemetry, or UI adapters without importing internal runtime modules.
4. Own lifecycle and approvals
The root exports conversation engine types, session and turn service contracts, turn inputs/results, run-service contracts for compatibility, approval services and policies, remembered project rules, runtime tool-selection profiles, and EngineConversationTurnService for hosts that already own lower-level session paths.
For new hosts, prefer createConversationEngine. For hosted process code, import ConversationRunService from the explicit /hosted entrypoint even though the root compatibility export remains available.
5. Supply storage
Primary exports include:
ArtifactRepository,ArtifactService,FileArtifactRepository, and artifact record types;ChatSessionRepository,FileChatSessionRepository, revision/conflict errors, catalog inputs/results, andChatSession;RuntimeCredentialServiceand credential-source types.
Session and artifact repositories can be replaced independently. Traces and memory remain path-oriented through stateRoot today.
@roackb2/heddle/hosted: process-local active runs
Import ConversationRunService and its run address, handle, replay, stream-item, approval, projection, and error contracts here when request and subscription lifetimes differ.
import {
ConversationRunService,
ConversationRunConflictError,
ConversationRunReplayUnavailableError,
} from '@roackb2/heddle/hosted'This subpath adds no transport and no durable broker. It makes the long-lived-process assumption explicit.
@roackb2/heddle/hosted/http-sse: Node SSE correctness
Exports:
parseConversationRunSseReplayCursor;streamConversationRunSse;ConversationRunSseReplayCursorError;- SSE event, protocol, cursor-input, and streaming option types.
These helpers target Node request/response primitives, so Express and other Node frameworks can use them without making Express part of Heddle core.
@roackb2/heddle-remote: browser-safe run protocol
Primary exports:
ConversationRunProtocolCodecandConversationRunProtocolValidationError;ConversationRunConsumerService;ConversationRunSequenceGapErrorandConversationRunTerminalViolationError;- reference, envelope, event, subscription, acceptance, retry, and codec types;
ConversationRunReferenceSchemaandConversationRunReplayCursorSchema.
The codec accepts synchronous Standard Schema validators. Zod, Valibot, ArkType, and other compatible validators can define the host's public activity and result projection. This package intentionally excludes Heddle's Node runtime, model providers, server, CLI, and web control plane.
@roackb2/heddle-remote/http-sse: conventional REST/SSE client
Exports ConversationRunHttpSseClient, ConversationRunHttpSseClientError, and its option/input/error-payload types.
Use it when the host API follows the conventional start, event-subscription, and cancellation resource shape. The client owns URL/header composition, response schema validation, incremental event parsing, reader cleanup, and envelope/SSE identity agreement. The product supplies auth headers, public schemas, abort lifecycle, retry timing, and UI behavior.
@roackb2/heddle/advanced: deep core customization
The advanced entrypoint re-exports the curated root and adds lower-level building blocks:
- LLM adapters, provider registry, OpenAI-compatible discovery, and model catalogs;
- individual coding, shell, browser-research, and external-context tools;
- trace recording, review parsing, observability, and system-prompt construction;
- memory catalogs, maintenance, notes, visibility, and knowledge tools;
- awareness providers and coding-workspace snapshots;
- the lower-level agent loop and checkpoints;
- heartbeat runners, storage, scheduler, and presenters;
- optional integrations such as semantic-drift observers;
- budgets, loggers, and runtime errors.
Use this surface only when the product needs to replace or assemble lower-level runtime mechanics. Importing /advanced does not opt into /hosted, HTTP/SSE, or the remote package.
Selection rules
- Start with
@roackb2/heddlefor a Node product host. - Add
/hostedonly when work outlives one caller or needs addressable replay, cancellation, or approval resolution. - Add
/hosted/http-sseonly for a Node HTTP/SSE adapter. - Install
@roackb2/heddle-remoteonly in a remote consumer. - Add its
/http-ssesubpath only when the API actually uses the conventional REST/SSE contract. - Reach for
/advancedonly when curated SDK exports cannot express the required runtime customization. - Never import internal build paths; if a required contract is not public, open an SDK API request instead of coupling the product to implementation files.
Versioning and verification
Keep the Node runtime and remote package on compatible release lines when they exchange the canonical run envelope. Validate both directions at the public protocol boundary.
After changing versions, verify:
- a persisted session can be reopened and continued;
- public activity and result schemas still accept the intended fields and strip the rest;
- reconnect after a known sequence neither duplicates nor skips events;
- cancel and error settlement remain terminal;
- browser bundles do not include the Node runtime package;
- the chosen subpath exists in the installed package's
exportsmap.