API Reference

Agent

Construction helpers, builders, manifests, and runnable agents exported by the package root.

Agent

Access: @nylorun/harnessAgent

Creates an open agent builder from the stable identity and optional base instructions.

NameTypeRequiredDescription
options.idstringYesStable programmatic agent identifier.
options.namestringYesHuman-readable agent name.
options.instructionsstring or readonly string[]NoInitial model instructions.
ReturnsAgentBuilderAn open builder that accepts capabilities and middleware.

AgentBuilder

Access: @nylorun/harnessAgentBuilder

AgentBuilder stays open until a model adapter is bound. Middleware is applied in declaration order.

MethodParametersReturnsDescription
use(declaration)CapabilityDeclaration<State>thisAdds a named capability with tools, instructions, model selection, state, or middleware.
use(middleware)StepMiddlewarethisAdds middleware with a generated id.
use(id, middleware)id: string, middleware: StepMiddlewarethisAdds middleware under an explicit stable id.
with(adapter)adapter: ModelAdapterBoundAgentBuilderBinds the one model adapter and closes the builder to later use() calls.

BoundAgentBuilder

Access: @nylorun/harnessBoundAgentBuilder

MethodParametersReturnsDescription
build()NoneBuiltAgentValidates the composition and returns the built agent. A successful builder returns the same instance on later calls.

BuiltAgent

Access: @nylorun/harnessBuiltAgent

MemberTypeRequiredDescription
idstringYesBuilt agent identifier from its manifest.
namestringYesBuilt agent display name from its manifest.
middlewarereadonly BoundMiddleware[]YesOrdered, compiled middleware declarations.
manifestAgentManifestYesPublic id, name, and middleware-id manifest.
run(options?)SessionRunOptionsNoCreates and returns an in-memory Session.

run() accepts either normal session options or a seeded session option. A seed cannot be combined with top-level id, userId, or context.

Construction helpers

Access: @nylorun/harnessmodel, middleware, tool

HelperParametersReturnsDescription
model(value)ModelAdapterThe same adapterPreserves model-adapter inference.
middleware(value)StepMiddlewareThe same middlewarePreserves middleware inference.
tool(value)ToolDefinitionPrepared ToolDefinitionPreserves tool inference and prepares its synchronous Zod object schema.

Manifest and build failures

Access: @nylorun/harnessAgentManifest, AgentBuildError, AgentLifecycleError

ExportProperties or valueDescription
AgentManifestid, name, middlewarePublic description of a built agent; every middleware item contains its id.
AgentBuildErrordiagnostics: readonly BuildDiagnostic[]Raised when Harness cannot build a valid composition.
AgentLifecycleErrorcode: "agent.lifecycle-sealed"Raised when a builder is changed after with() or build().

Both error classes extend HarnessError. Use their machine-readable code instead of matching the message text.

On this page