@netscript/plugin@0.0.10Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
The plugin authoring contract for NetScript: a fluent definePlugin builder producing type-safe manifests that host tooling turns into runtime files, services, and Aspire resources.
Examples
Define a plugin
Define a plugin
import { definePlugin, inspectPlugin } from "@netscript/plugin"; const plugin = definePlugin("@example/plugin", "0.0.1-alpha.0").build(); console.log(inspectPlugin(plugin).summary);
Classes
Error thrown when a plugin name is registered more than once.
Fluent builder for assembling plugin manifests.
- build(): TName extends never ? never : TVersion extends never ? never : PluginManifest
Build an immutable plugin manifest.
- withAspire(aspire: ContributionInput<string, TDependencies>): PluginBuilder<TName, TVersion, TContributions & { readonly aspire: string; }, TDependencies>
Set the Aspire contribution module path.
- withAuthor(author: string): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set the plugin author.
- withBackgroundProcessor(processor: ContributionInput<BackgroundProcessorContribution, TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly backgroundProcessors: readonly BackgroundProcessorContribution[]; }Add a background processor contribution.
- withContractVersions(versions: ContributionInput<readonly ContractVersionContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly contractVersions: readonly ContractVersionContribution[]; }Add contract version contributions.
- withDbSchemas(schemas: ContributionInput<readonly DbSchemaContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly databaseSchemas: readonly DbSchemaContribution[]; }Add database schema contributions.
- withDependencies<TDeps extends PluginDependencies>(dependencies: TDeps): PluginBuilder<TName, TVersion, TContributions, TDeps>
Set typed plugin dependencies available to contribution callbacks.
- withDescription(description: string): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set the plugin description.
- withDisplayName(displayName: string): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set the display name used by UI surfaces.
- withDoctor(doctor: ContributionInput<string, TDependencies>): PluginBuilder<TName, TVersion, TContributions & { readonly doctor: string; }, TDependencies>
Set the plugin adapter module that contributes doctor checks.
- withE2e(e2e: ContributionInput<readonly E2eContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly e2e: readonly E2eContribution[]; }Add end-to-end gate contributions.
- withHooks(hooks: PluginLifecycleHooks): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set plugin lifecycle hooks.
- withLicense(license: string): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set the plugin license identifier.
- withMetadata(metadata: PluginMetadata): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set runtime-safe plugin metadata.
- withMigrations(migrations: ContributionInput<readonly MigrationContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly migrations: readonly MigrationContribution[]; }Add migration contributions.
- withName<T extends string>(name: T): PluginBuilder<T, TVersion, TContributions, TDependencies>
Set the plugin package name.
- withPermissions(permissions: readonly string[]): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set permissions requested by the plugin.
- withRuntimeConfigTopics(topics: ContributionInput<readonly RuntimeConfigTopicContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly runtimeConfigTopics: readonly RuntimeConfigTopicContribution[]; }Add runtime config topic contributions.
- withSdkClients(references: ContributionInput<readonly SdkClientContributionReference[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly sdkClients: readonly SdkClientContributionReference[]; }Add declarative SDK client-contribution factory references.
- withService(service: ContributionInput<ServiceContribution, TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly services: readonly ServiceContribution[]; }Add a service contribution.
- withStreamTopics(topics: ContributionInput<readonly StreamTopicContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly streamTopics: readonly StreamTopicContribution[]; }Add stream topic contributions.
- withTags(tags: readonly string[]): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set plugin discovery tags.
- withTelemetry(telemetry: ContributionInput<readonly TelemetryContribution[], TDependencies>): PluginBuilder<TName, TVersion,TContributions, TDependencies>
& { readonly telemetry: readonly TelemetryContribution[]; }Add telemetry contributions.
- withType(type: PluginType): PluginBuilder<TName, TVersion, TContributions, TDependencies>
Set the plugin category.
- withVersion<T extends string>(version: T): PluginBuilder<TName, T, TContributions, TDependencies>
Set the plugin semantic version.
Error thrown when a set of plugin manifests cannot be composed into one root host.
- diagnostics: readonly PluginCompositionDiagnostic[]
Structured diagnostics, in manifest order.
Base class for plugin contribution extension axes.
- axis: ContributionAxis
Contribution axis implemented by the concrete contribution.
Base error for plugin package failures.
Error thrown when a plugin definition is invalid.
Functions
Throw when a probe response is not in the 2xx range.
Start a new plugin manifest builder chain.
| InspectablePluginManifest
| InspectablePluginRegistry
Inspect a plugin manifest, registry, or path-like target.
Join a base URL and a probe path.
Normalize a probe path so it always begins with a single leading slash.
Parse and validate a plugin manifest without executing plugin code.
Resolve a service base URL from a prioritized list of environment variables.
Print a PluginVerificationResult as JSON and set the process exit code.
Summarize an HTTP response for probe diagnostics.
Verify a plugin manifest against a declarative set of expectations.
Interfaces
Background processor contributed by a plugin.
- concurrency: number
Optional processor concurrency.
- entrypoint: string
Processor entrypoint path.
- name: string
Logical processor name.
Contract version contributed by a plugin.
Database schema file contributed by a plugin.
End-to-end test contribution.
Expected Aspire contribution module path and the finding emitted on mismatch.
Expected contract version contribution, matched by version and loader.
Expected database schema contribution, matched by path and engine.
Expected plugin dependency alias and the finding emitted when it is absent.
Expected end-to-end gate contribution, matched by name and optional command.
Expected manifest-level helper function and the finding emitted when it is absent.
Expected named contribution (processor, stream topic, telemetry), matched by name.
Expected runtime config topic contribution, matched by name and optional schemaPath.
- message: string
Finding emitted when no matching topic contribution is found.
- name: string
Expected topic name.
- schemaPath: string
Expected JSON schema module path, when matched on schemaPath.
Expected service contribution, matched by name and optional entrypoint/port.
- entrypoint: string
Expected service entrypoint module path, when matched on entrypoint.
- message: string
Finding emitted when no matching service contribution is found.
- name: string
Expected contribution name.
- port: number
Expected service port, when matched on port.
Minimal plugin manifest shape accepted by the plugin inspector.
- contributions: object
Contribution groups keyed by contribution axis.
- name: string
Plugin package name.
- version: string
Plugin version.
Minimal registry shape accepted by the plugin inspector.
- list: () => readonly InspectablePluginManifest[]
List registered plugin manifests.
JSON-stable diagnostic report returned by plugin inspectors.
Data or schema migration contribution.
Immutable state accumulated by the plugin builder chain.
- author: string
Plugin author name or organization.
- contributions: PluginContributions
Contributions accumulated by builder methods.
- dependencies: TDependencies
Typed dependencies available to contribution callbacks.
- description: string
Plugin description.
- displayName: string
Display name shown in host UI surfaces.
- hooks: PluginLifecycleHooks
Lifecycle hooks supplied by the plugin.
- license: string
Plugin license identifier.
- metadata: PluginMetadata
Runtime-safe metadata attached to the manifest.
- name: string
Plugin package name.
- permissions: readonly string[]
Host permissions requested by the plugin.
- tags: readonly string[]
Discovery tags attached to the manifest.
- type: PluginType
Plugin category.
- version: string
Plugin semantic version.
Structured diagnostic describing one plugin composition failure.
- axis: string
Contribution key involved, when the failure concerns a contribution.
- code: PluginCompositionDiagnosticCode
Stable failure code.
- conflictsWith: string
Plugin that already owns the conflicting identity, for duplicates.
- identity: string
Contribution identity or dependency name involved.
- message: string
Human-readable explanation naming the plugin, axis, and identity involved.
- plugin: string
Name of the plugin manifest that carries the failing declaration.
Context supplied to plugin lifecycle hooks.
- isDev: boolean
Whether the host is running in development mode.
- logger: PluginLogger
Logger supplied by the host.
- manifest: unknown
Parsed plugin manifest.
- pluginRoot: string
Absolute plugin root path when the plugin is local.
- projectRoot: string
Absolute project root path for the host application.
Contribution groups supported by plugin manifests.
- aspire: string
Aspire contribution module reference.
- backgroundProcessors: readonly BackgroundProcessorContribution[]
Background processor contributions registered by the plugin.
- cli: { readonly doctorChecks?: readonly "auth-backend"[]; }
CLI capabilities owned by the plugin and consumed generically by the host.
- contractVersions: readonly ContractVersionContribution[]
Contract version contributions registered by the plugin.
- databaseSchemas: readonly DbSchemaContribution[]
Database schema contributions registered by the plugin.
- doctor: string
Plugin adapter module containing doctor checks.
- e2e: readonly E2eContribution[]
End-to-end test contributions registered by the plugin.
- migrations: readonly MigrationContribution[]
Migration contributions registered by the plugin.
- runtimeConfigTopics: readonly RuntimeConfigTopicContribution[]
Runtime config topic contributions registered by the plugin.
- sdkClients: readonly SdkClientContributionReference[]
Declarative SDK client-contribution factories made available by the plugin.
- services: readonly ServiceContribution[]
Service contributions registered by the plugin.
- streamTopics: readonly StreamTopicContribution[]
Stream topic contributions registered by the plugin.
- telemetry: readonly TelemetryContribution[]
Telemetry contributions registered by the plugin.
Metadata describing one runtime end-to-end gate contributed by a plugin.
- command: readonly string[]
Command used by the evaluator or CLI E2E runner.
- description: string
Human-readable gate summary.
- id: string
Stable gate identifier.
Declarative description of the manifest a plugin is expected to expose.
- aspire: ExpectedAspire
Expected Aspire contribution module path.
- backgroundProcessors: readonly ExpectedNamed[]
Expected background processor contributions.
- contractVersions: readonly ExpectedContractVersion[]
Expected contract version contributions.
- databaseSchemas: readonly ExpectedDbSchema[]
Expected database schema contributions.
- dependencies: readonly ExpectedDependency[]
Expected dependency aliases.
- e2e: readonly ExpectedE2eGate[]
Expected end-to-end gate contributions.
- helpers: readonly ExpectedHelper[]
Expected manifest-level helper functions.
- name: string
Expected plugin package name.
- runtimeConfigTopics: readonly ExpectedRuntimeConfigTopic[]
Expected runtime config topic contributions.
- services: readonly ExpectedService[]
Expected service contributions.
- streamTopics: readonly ExpectedNamed[]
Expected stream topic contributions.
- telemetry: readonly ExpectedNamed[]
Expected telemetry contributions.
- version: string
Expected plugin version (derive from the plugin's
deno.json).
Published scaffold.plugin.json contract consumed by NetScript installers.
- capabilities: PluginManifestCapabilities
Static capability summary used before plugin code executes.
- databaseRequirement: PluginDatabaseRequirement
Optional configuration-dependent SQL requirement, resolved before installation.
- description: string
Human-readable plugin description.
- displayName: string
Human-readable plugin name.
- linking: PluginManifestLinking
Resource links reconciled generically for first- and third-party plugins.
- name: string
Published plugin package name.
- officialSource: PluginManifestOfficialSource
Existing source metadata retained for first-party compatibility.
- peerDependencies: Readonly<Record<string, string>>
Peer package requirements expected by the plugin scaffolder.
- postScripts: readonly PluginManifestPostScript[]
Optional plugin-owned scripts executed after a successful scaffold.
- provider: PluginManifestProvider
Existing provider metadata retained for first-party compatibility.
- scaffolder: PluginManifestScaffolder
Plugin-owned scaffold entrypoint metadata.
- schemaVersion: PLUGIN_MANIFEST_SCHEMA_VERSION
Published protocol schema version.
- version: string
Published plugin package version.
Validation issue exposed by the plugin installer manifest schema.
Stable public validation surface for the plugin installer manifest schema.
- parse(value: unknown): PluginInstallerManifest
Parse a value or throw when it is not a valid installer manifest.
- safeParse(value: unknown):{ readonly success: true; readonly data: PluginInstallerManifest; }
| { readonly success: false; readonly error: { readonly issues: readonly PluginInstallerManifestSchemaIssue[]; }; }Parse a value without throwing.
Lifecycle hooks supported by plugin definitions.
- afterGenerate: (context: PluginContext) => void | Promise<void>
Hook called after generation tasks complete.
- beforeGenerate: (context: PluginContext) => void | Promise<void>
Hook called before generation tasks run.
- setup: (context: PluginContext) => void | Promise<void>
Hook called when the plugin is initialized.
- teardown: (context: PluginContext) => void | Promise<void>
Hook called when the plugin is torn down.
Logger shape supplied to plugin lifecycle hooks.
- debug: () => voidmessage: string,fields?: Record<string, unknown>
Emit a debug-level lifecycle message.
- error: () => voidmessage: string,fields?: Record<string, unknown>
Emit an error-level lifecycle message.
- info: () => voidmessage: string,fields?: Record<string, unknown>
Emit an info-level lifecycle message.
- warn: () => voidmessage: string,fields?: Record<string, unknown>
Emit a warning-level lifecycle message.
Plugin manifest consumed by NetScript hosts and tooling.
- author: string
Plugin author.
- contributions: PluginContributions
Contribution groups registered by the plugin.
- dependencies: PluginDependencies
Typed plugin dependencies consumed by this plugin.
- description: string
Human-readable plugin description.
- displayName: string
Display name used in UI surfaces.
- hooks: PluginLifecycleHooks
Lifecycle hooks registered by the plugin.
- license: string
Plugin license identifier.
- metadata: PluginMetadata
Runtime-safe metadata.
- name: string
Plugin package name.
- permissions: readonly string[]
Permissions requested by the plugin.
- tags: readonly string[]
Plugin tags for discovery.
- type: PluginType
Plugin category.
- version: string
Plugin semantic version.
Capability summary statically declared by a plugin manifest.
- hasBackgroundWorkers: boolean
Whether the plugin scaffolder adds background workers or processors.
- hasDatabaseMigrations: boolean
Whether the plugin scaffolder adds database migration or schema files.
- hasRoutes: boolean
Whether the plugin scaffolder adds service routes or HTTP endpoints.
- supportsMcpScaffold: boolean
Whether the plugin-owned scaffolder accepts the optional MCP scaffold request.
Declarative resource-linking contract shared by first- and third-party plugins.
- backgroundConfigKey: string
Optional background-processor configuration key owned by the plugin.
- canonicalName: string
Stable plugin identity used to resolve declared plugin dependencies.
- consumers: PluginManifestLinkingConsumers
Named service and app resources that consume this producer.
- dependencies: readonly string[]
Canonical plugin dependencies resolved to their installed resource keys.
- pluginReferences: readonly string[]
Explicit plugin resource keys referenced by this producer.
- resourceConfigKey: string
Plugin resource configuration key exposed to consumers.
Named host resources that consume a plugin producer.
Compatibility metadata for existing first-party source-copy discovery.
- backgroundDir: string
Optional background source directory name.
- backgroundEntrypoint: string
Optional background entrypoint copied or generated for the plugin.
- backgroundPort: number
Generated background worker port. Zero requests host allocation.
- canonicalName: string
Canonical first-party plugin source name.
- dependencies: readonly string[]
First-party plugin source dependencies by directory name.
- doctorEntrypoint: string
Plugin adapter module that owns static doctor checks.
- permissions: readonly string[]
Runtime permissions used by generated plugin services.
- pluginDir: string
Source plugin directory name.
- pluginReferences: readonly string[]
Generated plugin service references.
- requiresDb: boolean
Whether the plugin source requires database wiring.
- requiresKv: boolean
Whether the plugin source requires Deno KV wiring.
- serviceConfigKey: string
Generated service configuration key.
- serviceEntrypoint: string
Service entrypoint copied or generated for the plugin.
- servicePort: number
Generated service port.
Validation failure returned when a plugin manifest cannot be parsed.
Single validation issue returned by plugin manifest parsing.
Minimal parser shape for manifest validators exposed by this package.
- parse: (input: unknown) => TOutput
Parse an unknown manifest candidate into the validator output type.
Script export executed after a plugin-owned scaffold succeeds.
Compatibility metadata for existing plugin-kind provider registration.
- category: "plugin" | "background-processor"
Provider category used by the host plugin registry.
- concurrencyEnvVar: string | null
Environment variable used to configure concurrency.
- defaultConcurrency: number | null
Default concurrency when supported.
- defaultEntrypoint: string
Default background or service entrypoint.
- defaultPermissions: readonly string[]
Default runtime permissions for generated services.
- defaultRequiresDb: boolean
Whether the provider requires database wiring by default.
- defaultRequiresKv: boolean
Whether the provider requires Deno KV wiring by default.
- defaultServiceEntrypoint: string
Default service entrypoint, omitted when the plugin has no service.
- defaultTelemetry: boolean
Whether telemetry is enabled by default.
- displayName: string
Human-readable provider name.
- infrastructureOptionalDeps: readonly string[]
Optional infrastructure dependency capabilities.
- infrastructureRequires: readonly string[]
Required infrastructure capabilities.
- kind: string
Plugin kind registered by the provider.
- pluginType: "background-processor" | "api" | "frontend" | "utility"
Plugin category used by runtime tooling.
- portRangeKey: string
Port range bucket used by generated services.
- supportsConcurrency: boolean
Whether generated services support configurable concurrency.
- watchFlag: string
Optional watch flag used by generated dev commands.
Plugin-owned scaffold entrypoint declared by the manifest.
- export: string
Published export path that implements the scaffold entrypoint.
- requiredPermissions: PluginScaffolderRequiredPermissions
Static permission declaration for the scaffold entrypoint.
Declared Deno permissions required by a plugin-owned scaffolder.
Result returned by verifyPlugin.
- findings: readonly string[]
Human-readable verification findings (empty when
okistrue). - inspection: InspectionReport
Plugin inspector report for the manifest.
- ok: boolean
Whether the manifest satisfied every supplied expectation.
HTTP response summary captured by an E2E probe.
- bodyPreview: string
Response body preview for diagnostics.
- status: number
HTTP status code.
- statusText: string
HTTP status text.
- url: string
Requested URL.
Options controlling resolveProbeUrl behavior.
- stripTrailingSlash: boolean
Strip a single trailing slash from the resolved URL. Defaults to
true(the sagas/streams behavior); passfalseto preserve a URL verbatim.
Runtime config topic contributed by a plugin.
- name: string
Runtime config topic name.
- schemaPath: string
Optional path to the JSON schema for this topic.
Context supplied by the NetScript installer to a plugin-owned scaffolder.
- dryRun: boolean
Whether the scaffolder must report planned changes without writing files.
- logger: PluginLogger
Logger supplied by the host installer.
- options: Readonly<Record<string, unknown>>
Plugin-specific scaffold options passed by the installer.
- workspaceRoot: string
Absolute path to the target workspace root.
Result returned by a plugin-owned scaffolder.
- createdFiles: readonly string[]
Workspace-relative files created or planned by the scaffolder.
- databaseMigrationsAdded: boolean
Whether database migration or schema files were added or planned.
- modifiedFiles: readonly string[]
Workspace-relative files modified or planned by the scaffolder.
- status: "applied" | "planned" | "skipped" | "failed"
Whether the scaffolder applied changes, planned changes, skipped work, or failed.
- uiRegistryItems: readonly string[]
Optional first-party UI registry items required by the emitted userland surface.
Declarative reference to a published SDK client-contribution factory.
- export: string
Named factory export within the published module.
- id: `${string}:${string}`
Globally named contribution identifier exposed by the referenced factory.
- module: string
Published module specifier containing the contribution factory.
- protocol: { readonly family: "netscript.sdk-client"; readonly major: 1; }
Stable protocol discriminator supported by the SDK contribution seam.
- targets: readonly ("browser" | "server")[]
Runtime targets on which the factory is safe to load.
Service contributed by a plugin.
- entrypoint: string
Service entrypoint path.
- name: string
Logical service name.
- port: number
Optional service port.
Stream topic contributed by a plugin.
Telemetry instrumentation contribution.
Contract version contribution (fields optional for structural assignability).
Contribution axes read by verifyPlugin.
- aspire: string
Aspire contribution module path.
- backgroundProcessors: readonly VerifiableNamedContribution[]
Background processor contributions.
- contractVersions: readonly VerifiableContractContribution[]
Contract version contributions.
- databaseSchemas: readonly VerifiableDbSchemaContribution[]
Database schema contributions.
- e2e: readonly VerifiableE2eContribution[]
End-to-end gate contributions.
- runtimeConfigTopics: readonly VerifiableRuntimeConfigContribution[]
Runtime config topic contributions.
- services: readonly VerifiableNamedContribution[]
Service contributions.
- streamTopics: readonly VerifiableNamedContribution[]
Stream topic contributions.
- telemetry: readonly VerifiableNamedContribution[]
Telemetry contributions.
Database schema contribution (fields optional for structural assignability).
End-to-end gate contribution (fields optional for structural assignability).
Contribution carrying a name, optionally an entrypoint and port.
- entrypoint: string
Optional service entrypoint module path.
- name: string
Contribution name.
- port: number
Optional service port.
Manifest shape consumed by verifyPlugin.
- contributions: VerifiableContributions
Contribution groups keyed by contribution axis.
- dependencies: Readonly<Record<string, unknown>>
Plugin dependency manifest keyed by dependency alias.
Runtime config topic contribution (fields optional for structural assignability).
- name: string
Topic name.
- schemaPath: string
Optional JSON schema module path.
Type Aliases
| "sdk-client"
| "background-processor"
| "stream-topic"
| "database-schema"
| "runtime-config-topic"
| "contract-version"
| "e2e"
| "telemetry"
| "migration"
| "aspire"
Supported plugin contribution axis value.
Contribution value or callback resolved by the plugin builder.
Dependency context supplied to contribution callback inputs.
- deps: TDependencies
Typed dependencies registered on the builder.
| "unknown-contribution-key"
| "invalid-contribution"
| "duplicate-contribution"
| "missing-dependency"
| "dependency-version-mismatch"
| "invalid-version"
Stable code identifying why a root plugin composition is invalid.
Typed plugin dependency record keyed by caller-chosen aliases.
| { readonly ok: false; readonly error: PluginManifestParseError; }
Result returned by static plugin manifest parsing.
Metadata attached to plugin manifests.
| number
| boolean
| null
| readonly PluginMetadataValue[]
| { readonly [key: string]: PluginMetadataValue; }
Runtime-safe metadata values.
Entrypoint signature implemented by plugin-owned ./scaffold exports.
Supported plugin category value.
Variables
Current published schema version for scaffold.plugin.json.
Supported plugin categories.
Zod validator for the published NetScript plugin installer manifest.