Skip to content

Public API Surface ​

This checklist is the SSOT (single source of truth) for determining whether an API is public or internal. The goal: a maintainer can make a judgment on any symbol within 10 minutes without reading the implementation.

Three tiers:

TierLabelMeaning
Stable Publicstable / experimentalUser-facing authoring surface, commits to semver (experimental may be adjusted in minor releases, with prior notice in the changelog)
InternalinternalFramework internals. Readable and debuggable, but no guarantee against breaking changes -- may change in any version
DeprecateddeprecatedMigrated/no longer recommended. Kept for compatibility for one minor cycle then removed

Annotation location: source JSDoc (@public / @internal) should be annotated in entry files first; this checklist is the complete list. When they conflict, this checklist takes precedence and a PR should be filed to correct the source.

Stable Public (semver commitment) ​

define* Authoring Functions ​

App authors should import from zhin.js/* facade subpaths (depending on zhin.js is enough). The "Implementation package" column is the Feature provider / platformFeatures mount name — do not separately pnpm add those packages.

APIStabilityAuthor importImplementationOne-liner
definePluginstablezhin.js@zhin.js/plugin-runtimeConvention-based plugin entry, default export from plugin.ts
defineCommandstablezhin.js/command@zhin.js/commandCommand module (default export in commands/)
defineAdapterstablezhin.js/adapter@zhin.js/adapterAdapter module (default export in adapters/); create(context) normally returns { client, connect, activate?, send }, while complex protocols may return an Endpoint subclass
defineComponentstablezhin.js/component@zhin.js/componentSatori/SSR component (default export in components/)
defineMiddlewarestablezhin.js/middleware@zhin.js/middlewareMiddleware module (default export in middlewares/)
defineHandlerstablezhin.js/handler@zhin.js/handlerLifecycle event handler (default export in handlers/; / → . event inference)
defineAgentToolexperimental@zhin.js/tool (tools/<name>/index.ts)@zhin.js/toolAI tool module, auto-discovered by Agent
defineAgentPromptSectionexperimental@zhin.js/prompt-section@zhin.js/prompt-sectionGeneration-owned Prompt section with layer, retention budget, and profile scope

Note: There is no defineAgentSkill. Agent skills are pure Markdown (skills/<name>/SKILL.md, parsed by parseSkillMarkdown from @zhin.js/skill), not code symbols.

Convention Directories and Files ​

ConventionStabilityConsumerOne-liner
plugin.tsstablezhin.jsPlugin root entry, default exports definePlugin(...)
commands/stable@zhin.js/command (author import: zhin.js/command)Command module directory, supports [name] / [[name]] / [...name] dynamic parameter segments
adapters/stable@zhin.js/adapter (author import: zhin.js/adapter)Adapter module directory
middlewares/stable@zhin.js/middleware (author import: zhin.js/middleware)Middleware module directory
handlers/stable@zhin.js/handler (author import: zhin.js/handler)Lifecycle event handler directory (/ localName segments; omit event → . event; runtime currently wires message.receive)
tools/experimental@zhin.js/tooltools/<name>/index.ts is public; Agent/Skill-private Tools use the same nested tools/ shape
hooks/experimentalzhin.js/agent/hookshooks/<name>/index.ts; Agent/Skill-private Hooks use the same nested hooks/ shape
skills/<name>/SKILL.mdexperimental@zhin.js/skill / Agent discoverySkill Markdown with colocated references and scripts (published with npm packages)
pages/experimental@zhin.js/console-pageConsole page module directory

Host Tokens (consumed via context.resources.use(token)) ​

TokenStabilitySource PackageOne-liner
databaseHostTokenstablezhin.jsDatabase Host capability
scheduleHostTokenstablezhin.jsScheduled task Host capability
outboundHostTokenstablezhin.jsCross-platform outbound message capability
outboundMessageTokenstable@zhin.js/core (zhin.js/core/runtime)Inbound message delivery gateway (used by adapters)
httpHostTokenstable@zhin.js/host-httpHTTP/WS Host capability (used by Console, Webhooks)

Agent Capability Resources ​

APIStabilitySource PackageOne-liner
ctx.agent / AgentResourceHubexperimental@zhin.js/agentGeneration-scoped Skill/SubAgent/MCP/Hook support resources; Tools enter ToolIndex only through context.addTool()

Removed Legacy Hooks ​

APIStabilitySource PackageOne-liner
usePlugin() / getPlugin()removednone (no longer exported)The only entry is definePlugin + zhin runtime start
MessageCommand / CommandFeatureremovednone (no longer exported)Commands use defineCommand and Runtime CommandIndex
bootstrapNode / zhin.js/noderemovednone (subpath deleted)The only startup entry is zhin runtime start
AgentMessageSenderExtra / SenderScoperemovednone (no longer exported)Participant identity lives only in UserMessage.actor
buildSenderPrefix / applySenderExtraToUserMessage / stripSenderPrefixFromTextremovednone (no longer exported)The AI boundary renders participant labels from actor and never infers identity from text or extra
buildSenderPrefixForMessageremovednone (no longer exported)Core triggers return user content without encoding Agent identity

zhin.config.yml Top-Level Keys ​

KeyStabilityConsumerOne-liner
plugins.<key>stable@zhin.js/cli assembly layerPlugin enablement and plugin-level config
endpoints[i]stable@zhin.js/cli assembly layerAdapter instance list (includes master / trusted / commandPrefix)
commandPrefixstableMessageDispatcherCommand prefix, top-level instance + per-endpoint override
aistable@zhin.js/cli AI Host assemblyAI/Agent configuration
httpstable@zhin.js/host-http assemblyHTTP Host configuration
databasestabledatabase Host assemblyDatabase configuration
speechstablespeech Host assemblySpeech configuration
log_levelstable@zhin.js/cliLog level (ZHIN_LOG_LEVEL can override)

Other Host-level keys (mcp / a2a / htmlRenderer / assistant) are also stable top-level keys; see Configuration Overview for the complete table.

CLI Commands ​

CommandStabilitySource PackageOne-liner
zhin runtime startstable@zhin.js/cliPlugin Runtime entry point (composition root)
zhin setupstable@zhin.js/cliIncremental configuration wizard for existing projects
zhin doctorstable@zhin.js/cliEnvironment/config health check
zhin agent legacy-runs <input>experimental@zhin.js/cliRead-only audit of removed legacy Run exports; file output is create-only and never writes a new Workroom Journal
zhin agent legacy-payloads <input> --kind <kind>experimental@zhin.js/cliRead-only scan of embedded legacy Workroom payloads; emits content-free quarantine audit/proposal data and never deletes or migrates automatically
pnpm create zhin-appstablecreate-zhin-appNew project scaffold

Internal (Readable but No Stability Guarantee) ​

APIStabilitySource PackageOne-liner
RootRuntime / RootControllerinternal@zhin.js/plugin-runtimeRoot controller for plugin tree and generations
CapabilitySlotinternal@zhin.js/plugin-runtimeCapability slot, carrier between features and projections
SnapshotStore / RuntimeSnapshotinternal@zhin.js/plugin-runtimeAtomic snapshot store, input for projections
AdapterIndexinternal@zhin.js/adapterAdapter projection, snapshot -> Endpoint assembly
CommandIndexinternal@zhin.js/commandCommand projection, snapshot -> command routing table
ToolIndex / SkillIndex / McpIndex / PageIndex / LayoutIndex, etc.internalVarious feature packagesOther projections, all internal mechanisms
defineFeatureProvider (Feature Provider protocol)internal@zhin.js/feature-kitProtocol for adding new feature types, aimed at framework extenders, not plugin authors
MessageDispatcherinternal@zhin.js/core/runtimeGeneration-owned message dispatcher held by InboundRuntime
EndpointRuntimeinternal@zhin.js/core/runtimeGeneration-leased Endpoint directory, control, and management boundary exposed as ImRuntime.endpoints
RuntimeMessageEventSourceinternal@zhin.js/core/runtimeRead-only message observation port exposed as ImRuntime.messageEvents; publication remains inside Core
@zhin.js/agent/runtime Workroom tokens / composition portsinternal@zhin.js/agentGeneration-owned Host assembly mechanisms, not plugin-author APIs for obtaining Run state-writing authority
basic/cli/src/plugin-runtime/*-installer.tsinternal@zhin.js/cliRoot Host installers (database / schedule / outbound / inbox / http / console / agent / speech / html-renderer / protocol); assembly details may change at any time

Deprecated / Migrated ​

ItemStabilityStatusOne-liner
Legacy usePlugin() / getPlugin() plugin systemremovedDeleted from source and the public surfaceThe only entry is definePlugin + zhin runtime start
MessageCommand / classic CommandFeatureremovedDeleted from source and the public surfaceCommands use defineCommand and Runtime CommandIndex
Core ToolFeature / SkillFeatureremovedDeleted from source and the public surfaceTool / Skill use Feature providers, generation projections, and Agent CapabilityIngress
Agent FeatureCapabilityIngressremovedDeleted from source and the public surfaceAgent retains only the CapabilityIngress that reads Runtime snapshots
@zhin.js/tools and the Agent authoring Tool bridgeremovedThe subpath and duplicate definition/context/discovery were deletedAuthor Tools through @zhin.js/tool and tools/<name>/index.ts
@zhin.js/core/tool-zodremovedThe Core subpath and Zod 3 structural compatibility were deleted@zhin.js/tool owns the single Zod 4 / JSON Schema input contract
Classic Core Adapter / Endpoint runtimeremovedClasses, capability state, lifecycle helpers, and dedicated tests were deletedAdapters use defineAdapter, Endpoint<TClient>, and the generation-owned AdapterIndex from zhin.js/adapter
Classic Core Plugin runtimeremovedThe Plugin class, Context ALS, duplicate Dispatcher, and inbound pipeline were deletedPlugin lifecycle belongs to generation snapshots; IM dispatch only uses ImRuntime
Kernel PluginBase / mutable Feature registryremovedThe Plugin tree, string DI, prototype extension registry, and self-tests were deletedLifecycle belongs to @zhin.js/plugin-runtime; discovery and projection belong to @zhin.js/feature-kit
Kernel global Schedule getters/settersremovedget/setScheduleEngine and get/setScheduler were deletedEach ScheduleJobEngine owns and disposes its scheduler; Host scheduling uses a generation-owned token
bootstrapNode / zhin.js/noderemovedNo longer exportedUse zhin runtime start
AgentOrchestrator / ResourceHubremovedCompatibility names are no longer exportedUse AgentResourceHub for capability registration; Workroom orchestration uses the Kernel and dedicated typed ports
"Host plugin" narrativedeprecatedDocumentation has been consolidatedHost capabilities are now token-based (see Host Token table above), no longer a plugin concept
examples/test-bot as a user pathdeprecatedMaintainer kitchen sinkUser paths are minimal-bot (Stable) -> full-bot (L4); do not use test-bot config as a template
plugin.yml / Core PluginManifestremovedBuild detection, source types, and the duplicate repository manifest were deletedPlugin identity and metadata come only from strictly validated package.json#zhin

Decision Rules (Which Tier for New APIs) ​

Ask three questions in order:

  1. Is this something a plugin author/user would write directly? (define* functions, convention directories, config keys, CLI commands, Host tokens) -> Yes: default to Stable Public. AI/Console and other surfaces that haven't converged yet should be labeled experimental first, then promoted to stable after convergence.
  2. Is this a mechanism in the snapshot -> projection -> assembly pipeline? (*Index, SnapshotStore, CapabilitySlot, installer, dispatcher, Feature Provider protocol) -> Yes: default to Internal. Internal mechanisms do not become public just because they are exported (for cross-package reuse).
  3. Removing/replacing an existing public API? -> First label deprecated (JSDoc @deprecated + move in this checklist + note in changelog), keep for at least one minor cycle before removal; removal itself is a breaking change, handled via major bump or per the repo's release conventions.

Fallback: when in doubt, treat it as Internal -- promoting from internal to public does not break anyone; the reverse is a breaking change.

Related docs: Code Conventions, Development Workflow & CI Gates, Plugin Model.