Define a harness
definition to new HarnessRuntime({ definition, driver, grants }). A definition can also carry runtime bindings; see registries.
HarnessDefaults supports workspace, skillDirs, contextFiles, filesystem, subagents, fileMemory, and searchPastSessions. Use workspace: false or skillDirs: false to disable those settings. Other defaults are optional booleans. Relative workspace, skill, and context-file paths resolve against HarnessRuntime.projectRoot.
Defaults do not silently approve generated tools. Grant each intended tool name in the runtime. For a filesystem and skills Agent, names include fs_read_file, fs_list_directory, fs_file_info, list_skills, get_skill_instructions, and get_skill_reference.
Write an ability
An ability has pure validation and description functions, followed by a binding function that may acquire resources. This example adds a host-authored prompt fragment:type identifies an ability implementation; instanceId identifies one configured use. version defaults to 1 and must be a positive safe integer. Omitted instance IDs are generated; explicit IDs make composition and manifest export predictable.
AbilityBinding.tools is required, even when empty. A binding may also supply:
The runtime binds abilities sequentially for each run. It disposes acquired bindings in reverse order, including after partial initialization failure. Plain option objects and arrays are snapshotted; service instances and callbacks remain host-owned references.
Declare requirements and middleware ordering
Usedescribe().requirements for host capabilities such as filesystem:read. Supply approved capabilities through HarnessRuntime.requirements. A declaration documents and gates binding; it does not create an OS permission or authenticate a service.
Middleware IDs are unique. before and after refer to other middleware IDs. Missing ordering targets and cycles fail validation. beforeModel returns the projected messages; afterModel receives the response; afterTool receives the tool result. All hooks receive RunContext.
Duplicate tool names, prompt IDs, context-source IDs, or middleware IDs are errors. Coordinate IDs across abilities; defining a second ability does not implicitly replace the first one’s output.
Extend a definition
abilities appends uses. disable removes existing instance IDs. replaceAbilities replaces enabled instances with matching IDs; unknown IDs and replacing a disabled instance fail. Defaults and limits merge by field. Two skillDirs arrays merge with deduplication; false disables them. Extension is explicit configuration, not a runtime grant escalation.
describeHarness() returns declared tools, requirements, defaults, limits, runtime dependence, and diagnostics without binding. See exact types and portable manifests for serialization.