Plugin manifest, validation, discovery, and host-context contracts for NetScript. Use it to author a
plugin with definePlugin, validate a root composition, and build the CLI, scaffold, service and
health surfaces a plugin contributes.
function definePlugin<TName, TVersion>(name: TName, version: TVersion): PluginBuilder
Start a new plugin manifest builder chain.
PluginBuilder
class
classPluginBuilder
Fluent builder for assembling plugin manifests.
PluginBuilderState
interface
interfacePluginBuilderState
Immutable state accumulated by the plugin builder chain.
PLUGIN_TYPES
const
variable PLUGIN_TYPES
Supported plugin categories.
Diagnostics
Symbol
Kind
Signature
Description
inspectPlugin
function
functioninspectPlugin(target): InspectionReport
Inspect a plugin manifest, registry, or path-like target.
InspectionReport
interface
interfaceInspectionReport
JSON-stable diagnostic report returned by plugin inspectors.
InspectablePluginManifest
interface
interfaceInspectablePluginManifest
Minimal plugin manifest shape accepted by the plugin inspector.
InspectablePluginRegistry
interface
interfaceInspectablePluginRegistry
Minimal registry shape accepted by the plugin inspector.
Errors
Symbol
Kind
Description
PluginError
class
Base error for plugin package failures.
PluginValidationError
class
Error thrown when a plugin definition is invalid.
PluginCompositionError
class
Error thrown when manifests cannot be composed into one root host; carries structured diagnostics.
PluginCompositionDiagnostic
interface
One structured composition failure: code, plugin, message, and optional axis, identity, conflictsWith.
PluginCompositionDiagnosticCode
type alias
Stable composition failure codes.
DuplicatePluginError
class
Error thrown when a plugin name is registered more than once.
Contributions
Symbol
Kind
Description
PluginContribution
class
Base class for plugin contribution extension axes.
ContributionAxis
type alias
Supported plugin contribution axes.
ContributionInput
type alias
Contribution value or callback resolved by the plugin builder.
PluginContributions
interface
Contribution groups supported by plugin manifests.
BackgroundProcessorContribution
interface
Background processor contributed by a plugin.
ContractVersionContribution
interface
Contract version contributed by a plugin.
DbSchemaContribution
interface
Database schema file contributed by a plugin.
E2eContribution
interface
End-to-end test contribution.
MigrationContribution
interface
Data or schema migration contribution.
RuntimeConfigTopicContribution
interface
Runtime config topic contributed by a plugin.
ServiceContribution
interface
Service contributed by a plugin.
StreamTopicContribution
interface
Stream topic contributed by a plugin.
TelemetryContribution
interface
Telemetry instrumentation contribution.
Root composition validation
validatePluginComposition(plugins) (from @netscript/plugin/config) is the one check a root host
runs over its plugin manifests. It returns { ok: true, composition } or
{ ok: false, diagnostics } and reports every failure in one pass. createPluginHostBootstrap, the
CLI host loader, loadRegisteredPlugins, and generate aspire all call it, so runtime bootstrap
and generation agree.
Diagnostic code
Rejected when
duplicate-plugin
Two manifests share a name.
unknown-contribution-key
contributions holds a key that PluginContributions does not define.
invalid-contribution
A known contribution key holds a value of the wrong shape.
duplicate-contribution
An identity repeats within one plugin, or across plugins on a root-owned axis.
missing-dependency
A declared dependency is not composed.
dependency-version-mismatch
The composed dependency version does not satisfy the declared semver range.
invalid-version
A plugin version or dependency range is not valid semver.
Each contribution key has one identity and scope:
Key
Identity
Scope
services
name
root
sdkClients
id
root
backgroundProcessors
name
root
streamTopics
name
root
runtimeConfigTopics
name
root
e2e
name
root
telemetry
name
root
cli
each doctorChecks entry
root
contractVersions
version
plugin
databaseSchemas
path
plugin
migrations
name
plugin
aspire, doctor
the module path
one per plugin
Root-scoped identities must be unique across the whole composition. Plugin-scoped identities only
need to be unique within their plugin, so every plugin can contribute contract version v1. The
composition's merged contributions holds every collection key, including cli.doctorChecks, in
one linear pass. aspire and doctor stay on each plugin's manifest, and mergeContributions
throws instead of silently keeping the last value when both inputs set one of them.
Every declared dependency must be composed. Its version is read as a semver range, so an exact
version matches only itself. Library packages that are not plugins belong in deno.json imports,
not in a manifest's dependencies.
Manifest types
Symbol
Kind
Description
PluginManifest
interface
Plugin manifest consumed by NetScript hosts and tooling.
PluginManifestParser
interface
Minimal parser shape for manifest validators exposed by this package.
PluginMetadata
type alias
Metadata attached to plugin manifests.
PluginMetadataValue
type alias
Runtime-safe metadata values.
PluginType
type alias
Supported plugin categories.
PluginDependencies
type alias
Typed plugin dependency record keyed by caller-chosen aliases.
DependencyContext
type alias
Dependency context supplied to contribution callback inputs.
Lifecycle and context
Symbol
Kind
Description
PluginLifecycleHooks
interface
Lifecycle hooks supported by plugin definitions.
PluginContext
interface
Context supplied to plugin lifecycle hooks.
PluginLogger
interface
Logger shape supplied to plugin lifecycle hooks.
@netscript/plugin/config
Symbol
Kind
Signature
Description
definePlugin
function
function definePlugin<TName, TVersion>(name, version): PluginBuilder
Return true when a plugin name is reserved by NetScript.
PluginManifestSchema
const
variable PluginManifestSchema
Zod schema for plugin manifests; contribution keys are closed.
PluginCompositionError
class
class
Error thrown when manifests cannot be composed into one root host.
CONTRIBUTION_AXES
const
variable CONTRIBUTION_AXES
Supported plugin contribution axes.
PLUGIN_TYPES
const
variable PLUGIN_TYPES
Supported plugin categories.
This entrypoint also re-exports PluginBuilder, ContributionInput, DependencyContext,
PluginBuilderState, BackgroundProcessorContribution, ContractVersionContribution,
DbSchemaContribution, E2eContribution, MigrationContribution, PluginContributions,
PluginDependencies, PluginLifecycleHooks, ContributionAxis, PluginContext, PluginLogger,
PluginType, PluginManifest, PluginMetadata, PluginMetadataValue, PluginManifestParser,
PluginComposition, PluginCompositionResult, PluginCompositionDiagnostic,
PluginCompositionDiagnosticCode, PluginError, PluginValidationError,
RuntimeConfigTopicContribution, ServiceContribution, StreamTopicContribution, and
TelemetryContribution, documented in the root sections above.
@netscript/plugin/abstracts
Symbol
Kind
Description
PluginContribution
class
Base class for plugin contribution extension axes.
PluginAspireContribution
class
Base class for Aspire contribution implementations.
PluginBackgroundProcessorContribution
class
Base class for background processor contribution implementations.
PluginContractVersionContribution
class
Base class for contract version contribution implementations.
PluginDbSchemaContribution
class
Base class for database schema contribution implementations.
PluginE2eContribution
class
Base class for end-to-end contribution implementations.
PluginMigrationContribution
class
Base class for migration contribution implementations.
PluginRuntimeConfigTopicContribution
class
Base class for runtime config topic contribution implementations.
PluginServiceContribution
class
Base class for service contribution implementations.
PluginStreamTopicContribution
class
Base class for stream topic contribution implementations.
PluginTelemetryContribution
class
Base class for telemetry contribution implementations.
PluginPayloadSchema
interface
Minimal Standard Schema-compatible shape accepted by plugin contribution contracts.
PluginSchemaIssue
interface
Validation issue reported by package-owned schema contracts.
PluginSchemaResult
type alias
Validation result returned by package-owned schema contracts.
ContributionAxis
type alias
Supported plugin contribution axes.
@netscript/plugin/adapter
Symbol
Kind
Description
DoctorCheckSpec
interface
Extra doctor check supplied by a plugin seam.
DoctorSpec
interface
Seam data consumed by the mandatory doctor algorithm.
InfoSpec
interface
Static capability summary returned by the mandatory info command.
InstallSpec
interface
Seam data consumed by the mandatory install algorithm.
InstallStarterResource
interface
Starter resource emitted by the mandatory install command.
InstallStarterSamplesPolicy
type alias
Behavior for an install starter when the host excludes samples.
NetScriptPlugin
interface
Plugin adapter contract consumed by core command logic.
PluginAdapter
interface
Adapter object produced by the plugin adapter factory.
PluginCliEntrypoint
type alias
CLI entrypoint produced by createPluginAdapter(plugin).toCli().
PluginCommandConfig
type alias
Readonly command configuration supplied by the host.
PluginCommandContext
interface
Context shared by adapter command algorithms.
PluginCommandSpec
interface
Optional plugin-owned command handler.
PluginCommandValue
type alias
Primitive value accepted in plugin command configuration.
PluginResource
interface
Optional plugin-owned resource command.
RemoveSpec
interface
Seam data consumed by the mandatory remove algorithm.
UpdateSpec
interface
Seam data consumed by the mandatory update algorithm.
createDenoFileSystem
function
Create the default Deno-backed file-system port for adapter commands.
DEFAULT_PLUGIN_HEALTH_ENDPOINT
const
Default health endpoint used by plugin doctor commands.
DEFAULT_PLUGIN_WORKSPACE_ROOT
const
Default workspace root used when no explicit root is supplied.
resolveWorkspacePath
function
Resolve a workspace-relative path against a workspace root.
createPluginAdapter
function
Create the core adapter for a plugin contract object.
RunInstallCommandOptions
interface
Input consumed by the mandatory install command.
collectInstallArtifacts
function
Emit starter artifacts from the plugin's install seams.
createInstallScaffoldEntrypoint
function
Create a scaffolder protocol entrypoint from the install command.
runInstallCommand
function
Run the core-owned plugin install algorithm.
RunDoctorCommandOptions
interface
Input consumed by the mandatory doctor command.
runDoctorCommand
function
Run the core-owned plugin doctor algorithm.
PluginInfoReport
interface
Structured report returned by the mandatory info command.
RunInfoCommandOptions
interface
Input consumed by the mandatory info command.
runInfoCommand
function
Run the core-owned plugin info algorithm.
RunUpdateCommandOptions
interface
Input consumed by the mandatory update command.
runUpdateCommand
function
Run the core-owned plugin update algorithm.
RunRemoveCommandOptions
interface
Input consumed by the mandatory remove command.
runRemoveCommand
function
Run the core-owned plugin remove algorithm.
RunPluginCliCommandOptions
interface
Input consumed by the plugin CLI runner.
runPluginCliCommand
function
Route a plugin CLI verb to mandatory logic or a plugin-owned handler.
runPluginScaffoldCli
function
Run a plugin scaffold entrypoint from the host CLI subprocess protocol.
This entrypoint also re-exports the root and CLI symbols DoctorCheck, DoctorReport,
PluginCliArgs, PluginCliCommand, PluginCliResult, PluginLogger, and FileSystemPort; the
protocol symbols PluginScaffoldEntrypoint, ScaffolderContext, and ScaffoldResult; and the
scaffold symbols ItemScaffolder, ScaffoldArtifact, ScaffoldArtifactBody, artifactText,
textArtifact, StubSource, TokenValues, defineStub, and substituteTokens, documented in their owning
sections.
@netscript/plugin/cli
Symbol
Kind
Signature
Description
PluginCli
class
classPluginCli
Abstract base class for plugin-owned CLI command groups.
PluginRuntimeConfigCli
class
classPluginRuntimeConfigCli
Abstract base for plugin runtime configuration commands.
mountPluginCli
function
functionmountPluginCli(clis)
Mount plugin CLI command groups into a flat command list.
Run plugin doctor checks and return an aggregate report.
AstExtractor
class
class
Extractor for exported plugin contribution builder call sites.
FilesystemWalker
class
class
Filesystem walker for plugin source discovery.
MemoryManifestResolver
class
class
In-memory manifest resolver used by tests and alpha SDK stubs.
ModuleManifestResolver
class
class
Manifest resolver backed by dynamic imports.
RegistryEmitter
class
class
Registry emitter that writes one generated TypeScript module per contribution axis.
EmitterPort
interface
interface
Port for emitting generated plugin registry files.
ExtractorPort
interface
interface
Port for extracting plugin contributions from walked files.
ManifestResolverPort
interface
interface
Port for resolving a plugin manifest from a package or module specifier.
WalkerPort
interface
interface
Port for discovering plugin source files.
WalkedFile
interface
interface
File discovered by a plugin source walker.
SourceGraph
interface
interface
Source graph snapshot produced by discovery.
RegistryEmission
interface
interface
Output emitted by the registry emitter.
ExtractedContribution
interface
interface
Extracted contribution candidate from source.
WatcherHandle
interface
interface
Watcher handle returned by SDK watch presets.
ModuleManifestResolverOptions
interface
interface
Options for resolving manifests from importable module specifiers.
RunWalkerPipelineOptions
interface
interface
Options for running the SDK walker pipeline.
InstrumentationBridge
interface
interface
Bridge between plugin runtime and telemetry instrumentation.
PluginHostBootstrap
interface
interface
Result of bootstrapping plugin host state.
PluginServiceContext
interface
interface
Context supplied to a plugin service at runtime.
This entrypoint also re-exports BackgroundProcessorContribution, ContractVersionContribution,
DbSchemaContribution, E2eContribution, MigrationContribution, PluginContributions,
PluginDependencies, PluginLifecycleHooks, PluginManifest, PluginMetadata,
PluginMetadataValue, PluginType, RuntimeConfigTopicContribution, ServiceContribution,
StreamTopicContribution, TelemetryContribution, PluginContext, and PluginLogger from the
root/config surface, plus DoctorCheck and DoctorReport from the CLI surface.
Run the shared plugin CLI contract against a CLI instance.
MemoryManifestResolver
class
class
In-memory manifest resolver used by tests and alpha SDK stubs.
MemoryWalker
class
class
In-memory walker for plugin source discovery.
MemoryEmitter
class
class
In-memory registry emitter for plugin tests.
MemoryFileSystemAdapter
class
class
In-memory file system adapter for plugin tests.
FileSystemPort
interface
interface
Minimal file system port used by plugin scaffolding.
This entrypoint also re-exports the root/config symbols BackgroundProcessorContribution,
ContractVersionContribution, DbSchemaContribution, E2eContribution, MigrationContribution,
PluginContext, PluginContributions, PluginDependencies, PluginLifecycleHooks,
PluginLogger, PluginManifest, PluginMetadata, PluginMetadataValue, PluginType,
RuntimeConfigTopicContribution, ServiceContribution, StreamTopicContribution, and
TelemetryContribution; the SDK symbols EmitterPort, ExtractedContribution,
ManifestResolverPort, RegistryEmission, WalkedFile, and WalkerPort; and the CLI symbols
PluginCli, PluginCliArgs, PluginCliCommand, and PluginCliResult.
@netscript/plugin/templates
Symbol
Kind
Description
PLUGIN_SKELETON_TEMPLATE_CONTENT
const
Embedded text for every default plugin skeleton template asset.
PLUGIN_SKELETON_TEMPLATES
const
Paths for plugin skeleton template assets.
PluginSkeletonTemplatePath
type alias
Plugin skeleton template path.
@netscript/plugin/contract-base
Symbol
Kind
Description
BASE_PLUGIN_ERRORS
const
Base oRPC error-map fragment shared by plugin contracts.
BasePluginErrorCode
type alias
Literal error codes guaranteed by BASE_PLUGIN_ERRORS.
BasePluginErrorDefinition
interface
One entry in a plugin contract's oRPC error map.
InternalErrorData
interface
Error payload reported for unexpected internal failures.
PluginCapabilities
interface
Marketplace-discoverable description of a running plugin.
PluginCapabilitiesSchema
const
Output schema for the mandatory plugin describe route.
PluginCapabilitiesValidator
interface
Structural validator for plugin capability documents.
BASE_PLUGIN_CONTRACT_ROUTES
const
Mandatory route fragment shared by feature plugin contracts.
BasePluginContract
interface
Minimum route surface every plugin contract must satisfy.
BasePluginDescribeProcedure
type alias
Mandatory describe procedure shape for plugin contracts.
BasePluginDescribeRoute
type alias
Explicit type of the base contract's describe route.
@netscript/plugin/service
Symbol
Kind
Description
createPluginService
function
Build a plugin service with the mandated middleware and route chain pre-applied.
PluginDatabaseConfig
interface
Options forwarded to the service builder's database configuration.
PluginRawRoute
interface
Raw HTTP route mounted directly on a plugin service.
PluginServiceConfig
interface
Data-only description of a plugin service; requires native guarded auth or a public opt-out with a nonblank reason.
BoundPluginContract
interface
Context-bound contract helpers produced by bindPluginContract.
PluginContractAssemblyConfig
interface
Data required to mount a bound contract under /vN/<plugin>.
PluginContractBinder
interface
Contract binder used before selecting a request context.
PluginContractHandlers
type alias
Handler map derived from a context-bound oRPC contract router.
PluginContractImplementer
interface
Contract implementer that binds a concrete request context.
Route implementer returned by an oRPC contract context binding.
assemblePluginContractRouter
function
Assemble a context-bound handler map under a versioned namespace.
bindPluginContract
function
Bind an implemented contract and derive typed handlers and a router.
This entrypoint also re-exports ContextFactory, CorsOptions, DbContext, HealthCheck,
ServiceConfig, ServiceHandler, ServiceMiddleware, ServiceRouteMethod, and ServiceRouter
from @netscript/service.
Plugin service authentication posture
@netscript/plugin/contract-base exports mountPluginContract(contract, mount) and the
PluginContractMount type. The mount contains non-empty version and namespace segments without
slashes; invalid segments throw TypeError. Supply the same mount value to router assembly and
createContractAuthorizer(mountPluginContract(contract, mount)). The returned contract has nested
version/namespace RPC keys and prefixed REST paths while preserving procedure metadata and errors.
The source contract is unchanged. Canonical RPC paths remain canonical; deprecated flat paths use
the existing compatibility mapping.
createPluginService(router, { name, auth }) requires an explicit posture:
auth: { authn: { authenticator }, authz: { authorizer } } installs native guards, while
auth: { public: true, reason: 'Public status API' } records a deliberate public service. The
canonical ServiceAuthPolicy, ServiceGuardedAuthPolicy and ServicePublicAuthPolicy types come
from @netscript/service/auth and are re-exported by @netscript/plugin/service. Missing,
malformed and mixed postures throw before service construction. See the
service auth reference for the validation boundary.
The factory passes native auth options unchanged and installs them after context, before RPC. The
builder installs auth middleware before deferred RPC, REST and raw routes. Its built-in health
routes retain their native public behavior. A custom nonempty anonymous-prefix list replaces the
default; the factory does not merge another policy into it.
@netscript/plugin/health
Symbol
Kind
Description
ChildHealthState
type alias
Closed child state vocabulary: starting, ready, degraded, crash-looping, stopped, failed.
ChildHealthSnapshot
type alias
State, registry/dependency readiness, restart count, and redacted fatal incident.
ChildFatalError
type alias
Fixed redacted message and epoch-millisecond capture timestamp.
CHILD_CRASH_LOOP_THRESHOLD
const
Three restarts in 60 seconds; recovery requires a clean running minute.
summarizePluginHealth
function
Shared cross-plugin precedence: unhealthy, degraded, unknown, then healthy; an empty set is unknown.
aggregatePluginHealth
function
Shared API/child aggregation: healthy, degraded, unhealthy, or unknown; missing children cannot be green.
PluginHealthSummary
interface
Plugin identity, declared names, per-resource states, and one canonical verdict.
ChildHealthMonitor
class
Tracks readiness and bounded restart history with an injectable clock.
childHealthResponse
function
Returns HTTP 200 only for ready with both readiness checks complete; otherwise 503.
runChildHealthProcess
function
Starts loopback health before bootstrap; drains owned resources and exits 0 clean, 1 failed or 2 timed out.
Workers, triggers, and sagas runtime entrypoints also re-export the shared health types. The child
health payload is bounded and excludes raw exception messages and stacks. Dependency readiness
records startup checks and listener failures. Generated AppHost probes and doctor/MCP aggregation consume the same child contract.
Registry readiness records loaded and validated definitions; runtime registration belongs to
dependency readiness. Crash-loop recovery requires a full 60 seconds of uninterrupted running with
both readiness fields true. Fatal causes remain in server stderr, while public incidents stay
redacted. The child exits with code 1 after a one-second failure grace period. Without PORT, its
listener uses an ephemeral port on Deno's default interface; AppHost wiring uses declared runtime
capabilities to add the endpoint and readiness probe.
Plugin runtime health aggregation
aggregatePluginHealth from @netscript/plugin/health is the shared verdict function for
netscript plugin doctor and the MCP doctor and get_app_status health report. Generated
appsettings.json declares API and child resource names. Discovery uses the AppHost's public entry
schemas, so installation metadata and pinned ports are optional. Enabled background processors with
Runtime: deno and RequiresKv: true use the shared child health transport, matching the AppHost
generator's capability rule. Disabled children do not participate.
The installer reconciles each child's PluginReferences to its owning API plus that API's
dependencies. Discovery finds the API whose own reference set equals the child's references minus
that API. The child resource key names the resulting plugin group; API-only groups use their API
resource key. Thus the generated workers, sagas and triggers entries retain their own children
without assigning dependency APIs to those groups. Renaming resources preserves the reference link.
An explicit InstalledFrom on a child or its API overrides the group name, without requiring
InstalledVersion. Ambiguous ownership emits a warning and still reports the child separately.
Entries are validated individually. An invalid enabled API or an invalid child that declares Deno
and KV capability emits a named warning check instead of disappearing silently. Unsupported or
disabled children do not participate. Invalid JSON, a malformed NetScript section, or non-object
plugin/processor sections still produce an inspection failure. Doctor and MCP expose these warning
checks; status polling keeps telemetry and reports warn even if no valid runtime entry remains.
API readiness
Declared child readiness
Plugin verdict
Healthy
All children healthy
healthy
Healthy
Unhealthy, starting, stopped, crash-looping, unknown, or missing
degraded
No readiness evidence
Unhealthy or missing
degraded
Unhealthy or missing
Any
unhealthy
No readiness evidence
Healthy or unknown
unknown
No API declared
Unhealthy or missing
unhealthy
No API declared
All children healthy
healthy
No API declared
Unknown readiness or no children
unknown
A ready child also needs registry and dependency readiness. A process reporting Healthy without
readiness evidence cannot certify readiness. Doctor reads each declared child endpoint with a
five-second deadline per Aspire command and bounded child timeout/payload; unavailable or malformed
payloads cannot make a wrapper green. The report names each child and retains crash-looping.
Historical traffic and error-free spans cannot override a dead child. Degraded runtime reports make
plugin doctor exit nonzero and MCP health severity fail; get_app_status also exposes the named
healthStatus and pluginHealth reports. A child-only plugin has no surviving API to degrade, so a
dead child makes it unhealthy. summarizePluginHealth owns the cross-plugin roll-up used by MCP and
available to dashboard consumers. If no runtime reports apply, telemetry retains its verdict,
including standalone MCP and no-plugin projects. Runtime inspection errors instead preserve
telemetry counts/domains and add a failed runtimeChecks finding with healthStatus: unknown.
Declared runtimes whose AppHost is absent or unavailable also produce an inspection finding; they
are not treated as no-plugin projects.
These are diagnostic reads. Child processing and its health listener run under the background
service identity, independently of a phone, browser, or owner session. Dashboard panels consume the
health report.