Reference · Public API
Package entrypoints
Heddle separates runtime customization, topology, transport, and persistence assumptions. Start with the curated SDK, then add only the package that owns a boundary your product actually needs.
Customization depth
All depths — curated SDK through deep core building blocks
Hosting depth
Node.js 20+ packages plus language-neutral v1 adopter artifacts
Documentation status
Canonical reference
Assumptions
- Your Node host uses ESM and Node.js 20 or newer.
- Browser applications install @heddleagent/run-client instead of bundling the Node runtime.
- Non-TypeScript adopters use the versioned v1 network artifacts instead of porting the Heddle 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.
- Reusable run, adopter-lifecycle, protocol, and heartbeat-transition correctness within their documented package boundaries.
- 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 only the boundary you need
Install the finished coding-agent product globally when you want the heddle command:
npm install --global @heddleagent/cliThe Node runtime package requires Node.js 20 or newer:
npm install @heddleagent/runtimeInstall the independent remote package only in applications that consume a hosted run without embedding the Node agent runtime:
npm install @heddleagent/run-clientTypeScript control planes that call a separately deployed compatible Execution Host install the adopter package:
npm install @heddleagent/execution-host-clientAdd the official PostgreSQL adapter only when that backend persists the generic Execution Host conversation lifecycle:
npm install @heddleagent/postgres @heddleagent/execution-host-client drizzle-orm pgNon-TypeScript control planes consume the versioned OpenAPI, JSON Schema, and golden fixtures without installing or porting the Heddle runtime. The former @roackb2/* coordinates are deprecated and remain installable only for existing consumers. New heartbeat integrations use the official @heddleagent/postgres/heartbeat adapter.
The JavaScript packages use ESM. Import from documented package and subpath entrypoints rather than reaching into dist or internal src paths.
Entrypoint map
| Entrypoint | Environment | Owns | Does not choose |
|---|---|---|---|
@heddleagent/cli | Terminal, daemon, and local browser | Finished heddle coding-agent product, TUI, daemon, and browser control plane | An embeddable SDK or product backend architecture |
@heddleagent/runtime | Node.js 20+ | Curated product-host SDK: quickstart, conversation engine, tools/extensions, output, lifecycle, approvals, session and artifact ports | Server framework, transport, auth, UI |
@heddleagent/runtime/runs | Long-lived Node host | Process-local run identity, ordered events, replay, cancellation, approvals, terminal settlement | HTTP, routes, durable broker, multi-process routing |
@heddleagent/runtime/runs/http-sse | Node HTTP server | Replay cursor parsing and correct SSE framing, backpressure, disconnect cleanup | Route registration, auth, CORS, rate limits, public errors |
@heddleagent/runtime/advanced | Node.js 20+ | Curated SDK plus lower-level adapters, tools, traces, memory, agent loop, heartbeat, awareness, integrations, utilities | Remote hosting or transport assumptions |
@heddleagent/run-client | Browser or transport client | Runtime-validated run envelope, JSON safety, cursor, duplicate/gap/terminal handling, retry calculation | Transport, timer, auth, product schemas, UI |
@heddleagent/run-client/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 |
@heddleagent/execution-host-client | TypeScript product control plane | Versioned Execution Host contracts, authority, MCP verification, direct-development client, and durable conversation lifecycle over an injected store | Heddle runtime, product identity/policy, database schema, retention, UI, or a public hosted service |
@heddleagent/postgres/execution-host/conversations | TypeScript product control plane with PostgreSQL | Atomic store, constraints, and ordered SQL for the generic Execution Host conversation lifecycle | Product history/query policy, pool ownership, runtime migrations, or a universal storage layer |
@heddleagent/postgres/heartbeat | Heddle coordinator or worker with PostgreSQL | Claim-fenced task authority, leases, recovery, checkpoints, history, and operator controls | Scheduler startup, product records, pool ownership, or a universal storage layer |
@heddleagent/runtime: 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 long-lived process code, import ConversationRunService from the explicit /runs 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.
@heddleagent/runtime/runs: 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 '@heddleagent/runtime/runs'This subpath adds no transport and no durable broker. It makes the long-lived-process assumption explicit.
@heddleagent/runtime/runs/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.
@heddleagent/run-client: 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.
@heddleagent/run-client/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.
@heddleagent/execution-host-client: separate Execution Host boundary
This package is for a product control plane that invokes a separately deployed compatible Execution Host. Its subpaths separate contracts, execution authority, conversation orchestration, MCP capability verification, transport, Node edges, and testing.
The conversation surface includes a reusable durable lifecycle service. Heddle decides what requested, accepted, terminal, cancelled, interrupted, and expired transitions mean, and commits them before the matching public event. The adopter injects an atomic store and still owns IDs, schema, migrations, retention, user-scoped queries, and presentation. This prevents each product from reimplementing the generic state machine without turning Heddle into the owner of product records.
The canonical spec/v1 OpenAPI, JSON Schema, lifecycle profile, and golden fixtures shipped in the public package are the language-neutral authority. A Python implementation in the permissioned canonical source proves a clean-room adopter can satisfy those artifacts; it is not a published or supported Python SDK and does not promise TypeScript-helper parity. The compatible Execution Host remains permissioned, and Heddle does not currently offer a public hosted service.
@heddleagent/postgres/execution-host/conversations: official lifecycle storage
This adapter implements the durable lifecycle port owned by @heddleagent/execution-host-client/conversation. It ships ordered SQL migrations and an atomic, scope-fenced store while leaving the PostgreSQL service, pool, authenticated scope, product records, history queries, retention, and migration execution with the application.
Copy every shipped SQL file, in exported order, into the application's checked-in migration sequence and apply it before constructing the store. The published package README explains why libraries do not mutate production schemas at runtime and shows the exact copy command.
Deprecated @roackb2/heddle-postgres: legacy heartbeat durability
This deprecated package supplies PostgreSQL authority for existing Heddle heartbeat deployments. It owns row locking, claims, stale-writer fencing, leases, recovery, checkpoints, run history, and atomic operator controls. It deliberately does not provide product tables or an Execution Host conversation-lifecycle adapter. New package-family work should not treat it as a general database layer.
@heddleagent/runtime/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 /runs, HTTP/SSE, or the run-client package.
Selection rules
- Start with
@heddleagent/runtimefor a Node product host. - Add
/runsonly when work outlives one caller or needs addressable replay, cancellation, or approval resolution. - Add
/runs/http-sseonly for a Node HTTP/SSE adapter. - Install
@heddleagent/run-clientonly in a remote consumer. - Add its
/http-ssesubpath only when the API actually uses the conventional REST/SSE contract. - Use
@heddleagent/execution-host-clientonly when a product control plane calls a separate compatible Execution Host; non-TypeScript adopters implement the canonical v1 artifacts. - Use
@heddleagent/postgres/execution-host/conversationsonly for the generic Execution Host lifecycle, not product conversation history. - Use
@heddleagent/postgres/heartbeatfor new heartbeat persistence; treat@roackb2/heddle-postgresonly as a deprecated existing-consumer coordinate. - 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 packages on compatible release lines when they exchange public contracts. Pin the adopter v1 artifact version independently of implementation language, and run the published conformance fixtures against every store or clean-room adopter.
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;
- durable adopter transitions pass the shared store and terminal-projection fixtures;
- heartbeat PostgreSQL migrations precede code that requires them;
- the chosen subpath exists in the installed package's
exportsmap.