@indexnetwork/protocol is a published, versioned package consumed by the Index
Network backend and by external integrators. This document defines what the
public contract is, which parts are stable, and what counts as a breaking
change. It is the reference behind the tier annotations in src/index.ts.
- The supported entry points are the package root:
import { ... } from "@indexnetwork/protocol"— and the browser-safe subpaths listed inpackage.jsonexports(as of 21.1.0: package root. There are no supported browser subpaths. exposes one shared-schema module whose only runtime dependency iszod, for consumers (the web client) that cannot load the node-only package root. The schema module's symbols are also re-exported from the root (the fixture is subpath-only, to keep test data out of the runtime barrel), and the subpaths carry the Stable tier. - Deep imports (
@indexnetwork/protocol/dist/...or/src/...) are not part of the contract and may change or disappear in any release — do not rely on them. - The contract is exactly the set of symbols re-exported from
src/index.ts. Exports are listed explicitly (noexport *wildcards), so the surface is reviewable and additions are always intentional. Nothing checks this mechanically — a removed or renamed stable export is caught in review of thesrc/index.tsdiff, and that is what triggers the major bump below. - Root exports are assembled through named capability facades. Those facades are
implementation seams, not package subpath entry points: consumers must still
import only from
@indexnetwork/protocol. A capability may state that facade as a class rather than a re-export list —intentsdoes, viaIntentsinintents/intent.module.ts— which makes the whole capability one exported symbol and its internal layout free to change without a contract change. protocol/,platform/,capabilities/, andinternal/are source-level boundaries, not consumer subpaths. The sole supported Node import remains the package root.
Each section of the barrel carries one of two tiers.
Covered by SemVer below. Breaking changes require a major bump.
| Barrel section | What it is |
|---|---|
| Public API | Model config helpers, request scope helpers (deriveAllowedNetworkIds, deriveDiscoveryNetworkIds), requestContext. |
| Interfaces | Every port you implement to inject infrastructure (databases, embedder, cache, scraper, integration, …). |
| Shared schemas | Zod schemas + inferred types that cross the boundary (underspecification, identity, network-assignment, chat-context, …). |
| Intents | Intents — the whole intent capability as one class (lifecycle graph, verification, preparation) plus IntentsDeps and the Prepare* / RecoveryField* types. Replaced the six separate intent exports in 18.0.0. |
| Agents | Structured LLM agents (OpportunityEvaluator, …). |
Negotiations, NegotiationDatabase, the opening and turn decision functions,
the observation function, and negotiationTurnSchema are stable. Hosts must
evaluate supplied decision callbacks against locked current state and commit
their effects atomically. openCounterparties takes the protocol opening callback.
Marked @experimental in src/index.ts. May change in a minor release without
a major bump. Use at your own risk and pin a version if you depend on them.
| Area | What it is |
|---|---|
| States | Advanced graph-state shapes exposed for advanced graph consumers. |
| Internal helpers | Low-level support utilities re-exported for the backend's own use (selection/eval/evidence helpers) that are not part of the recommended integration surface. |
Most symbols in the barrel are consumed by the Index Network backend itself; a symbol being absent from the backend's imports does not make it dead — it may serve external integrators. Removal therefore follows the deprecation path below, never an ad-hoc delete.
This package follows Semantic Versioning 2.0.0.
MAJOR — incompatible changes to the Stable surface:
- Removing or renaming a stable export.
- Adding a required method/field to an implemented interface, or tightening a
return type (e.g.
T | null→Tis fine;T→T | nullis breaking). - Changing the runtime behavior a documented port contract guarantees (ownership scoping, null-vs-throw semantics, lifecycle idempotency).
MINOR — backward-compatible additions:
- New exports; new optional interface members; new graph factories/agents.
- Any change to an
@experimentalsymbol.
PATCH — backward-compatible fixes:
- Bug fixes, performance, prompt/model tuning, doc and type-comment changes that do not alter the contract.
Interface ports document invariants in their TSDoc/banner comments — ownership
scoping (return null for missing or non-owned rows), null-vs-empty-array
conventions, and lifecycle idempotency (mark* transitions are no-ops once
terminal). These guarantees are part of the Stable contract: breaking them is a
major change even if the TypeScript signature is unchanged.
- Mark the symbol
@deprecatedin TSDoc with the replacement and target removal version. - Note it under
### DeprecatedinCHANGELOG.md. - Keep it working for at least one minor release.
- Remove only in a subsequent major release.
- Pushes to
devpublish an-rc.<n>prerelease under the npmrctag. - Pushes to
mainpublish the stable version underlatestwhen thepackage.jsonversion is new (already-published versions are skipped). - Bump
package.jsonand updateCHANGELOG.mdbefore promoting tomain.
See .github/workflows/publish.yml for the automation and CHANGELOG.md for the
release history.