Agent
Construction helpers, builders, manifests, and runnable agents exported by the package root.
Agent
Access: @nylorun/harness → Agent
Creates an open agent builder from the stable identity and optional base instructions.
| Name | Type | Required | Description |
|---|---|---|---|
options.id | string | Yes | Stable programmatic agent identifier. |
options.name | string | Yes | Human-readable agent name. |
options.instructions | string or readonly string[] | No | Initial model instructions. |
| Returns | AgentBuilder | — | An open builder that accepts capabilities and middleware. |
AgentBuilder
Access: @nylorun/harness → AgentBuilder
AgentBuilder stays open until a model adapter is bound. Middleware is applied in declaration
order.
| Method | Parameters | Returns | Description |
|---|---|---|---|
use(declaration) | CapabilityDeclaration<State> | this | Adds a named capability with tools, instructions, model selection, state, or middleware. |
use(middleware) | StepMiddleware | this | Adds middleware with a generated id. |
use(id, middleware) | id: string, middleware: StepMiddleware | this | Adds middleware under an explicit stable id. |
with(adapter) | adapter: ModelAdapter | BoundAgentBuilder | Binds the one model adapter and closes the builder to later use() calls. |
BoundAgentBuilder
Access: @nylorun/harness → BoundAgentBuilder
| Method | Parameters | Returns | Description |
|---|---|---|---|
build() | None | BuiltAgent | Validates the composition and returns the built agent. A successful builder returns the same instance on later calls. |
BuiltAgent
Access: @nylorun/harness → BuiltAgent
| Member | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Built agent identifier from its manifest. |
name | string | Yes | Built agent display name from its manifest. |
middleware | readonly BoundMiddleware[] | Yes | Ordered, compiled middleware declarations. |
manifest | AgentManifest | Yes | Public id, name, and middleware-id manifest. |
run(options?) | SessionRunOptions | No | Creates 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/harness → model, middleware, tool
| Helper | Parameters | Returns | Description |
|---|---|---|---|
model(value) | ModelAdapter | The same adapter | Preserves model-adapter inference. |
middleware(value) | StepMiddleware | The same middleware | Preserves middleware inference. |
tool(value) | ToolDefinition | Prepared ToolDefinition | Preserves tool inference and prepares its synchronous Zod object schema. |
Manifest and build failures
Access: @nylorun/harness → AgentManifest, AgentBuildError, AgentLifecycleError
| Export | Properties or value | Description |
|---|---|---|
AgentManifest | id, name, middleware | Public description of a built agent; every middleware item contains its id. |
AgentBuildError | diagnostics: readonly BuildDiagnostic[] | Raised when Harness cannot build a valid composition. |
AgentLifecycleError | code: "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.