@agentium/harness. Types such as ChatMessage, RunContext, and ExecutionServices come from @agentium/core. A ? marks an optional field.
Ability
export interface Ability<Options> {
(options: Options, config?: {
instanceId?: string;
}): LocalAbilityUse;
readonly type: string;
readonly version: number;
readonly factory?: AbilityFactory;
}
AbilityDefinition
export interface AbilityDefinition<Options> {
type: string;
version?: number;
/** Pure validation/snapshotting. Preserve caller-owned service references; never freeze clients. */
validate: (options: Options) => Options;
describe: (options: Options) => AbilityDescription;
bind: (options: Options, ctx: RunContext) => AbilityBinding | Promise<AbilityBinding>;
/** Explicit trusted mapping. Omit for local callbacks/services that cannot be serialized. */
portable?: {
validateOptions: (options: JsonObject) => JsonObject;
toOptions: (options: JsonObject) => Options;
toJSON: (options: Options) => JsonObject;
};
}
AbilityDescription
export interface AbilityDescription {
toolNames: readonly string[];
requirements: readonly string[];
runtimeDependent?: boolean;
}
defineAbility
/** Capture typed local options; erase only the wrapper so heterogeneous abilities compose without casts. */
export declare function defineAbility<Options>(definition: AbilityDefinition<Options>): Ability<Options>;
defineHarness
export declare function defineHarness(input: HarnessDefinitionInput): HarnessDefinition;
describeHarness
export declare function describeHarness(input: HarnessDefinition): HarnessDescription;
exportManifest
export declare function exportManifest(input: HarnessDefinition): HarnessManifest;
extendHarness
export declare function extendHarness(base: HarnessDefinition, extension: HarnessExtension): HarnessDefinition;
hashManifest
export declare function hashManifest(input: HarnessManifest): string;
loadManifest
export declare function loadManifest(input: unknown, factories: readonly AbilityFactory[], runtimeRegistry?: HarnessRuntimeRegistry): HarnessDefinition;
AbilityBinding
export interface AbilityBinding {
tools: readonly ToolDef[];
promptFragments?: readonly PromptFragment[];
contextSources?: readonly HarnessContextSource[];
middleware?: readonly HarnessMiddleware[];
dispose?: () => Promise<void>;
}
AbilityFactory
export interface AbilityFactory {
type: string;
version: number;
validateOptions: (input: JsonObject) => JsonObject;
describe: (options: JsonObject) => AbilityDescription;
bind: (options: JsonObject, ctx: RunContext) => Promise<AbilityBinding>;
}
AbilitySelection
export interface AbilitySelection {
instanceId: string;
type: string;
version: number;
options: JsonObject;
}
BoundHarness
export interface BoundHarness {
readonly tools: ToolDef[];
readonly promptFragments: PromptFragment[];
readonly contextSources: HarnessContextSource[];
readonly middleware: HarnessMiddleware[];
dispose: () => Promise<readonly HarnessDiagnostic[]>;
}
HarnessContextBudget
export interface HarnessContextBudget {
maxEntries: number;
maxBytes: number;
maxTokens?: number;
deadlineMs: number;
}
HarnessContextEntry
export interface HarnessContextEntry {
id: string;
text: string;
trust: "host" | "source";
source?: {
uri: string;
version?: string;
locator?: string;
};
expiresAt?: number;
estimatedTokens?: number;
byteLength: number;
}
HarnessContextSource
export interface HarnessContextSource {
id: string;
fetch: (query: string, ctx: RunContext, budget: HarnessContextBudget) => Promise<readonly HarnessContextEntry[]>;
}
HarnessDefaults
export interface HarnessDefaults {
workspace?: false | {
path: string;
mode: "read" | "write";
};
skillDirs?: readonly string[] | false;
contextFiles?: boolean;
filesystem?: boolean;
subagents?: boolean;
fileMemory?: boolean;
searchPastSessions?: boolean;
}
HarnessDefinition
export type HarnessDefinition = {
readonly kind: "portable";
readonly manifest: HarnessManifest;
readonly factories: readonly AbilityFactory[];
readonly runtimeRegistry?: HarnessRuntimeRegistry;
} | {
readonly kind: "local";
readonly id?: string;
readonly abilities: readonly LocalAbilityUse[];
readonly defaults?: HarnessDefaults;
readonly limits?: HarnessManifest["limits"];
readonly runtime?: HarnessRuntimeBindings;
readonly runtimeReferences?: HarnessRuntimeReferences;
readonly runtimeRegistry?: HarnessRuntimeRegistry;
};
HarnessDescription
export interface HarnessDescription {
id: string;
kind: "portable" | "local";
contractVersion: 1;
abilities: readonly (AbilityDescription & {
instanceId: string;
type?: string;
version?: number;
})[];
toolNames: readonly string[];
requirements: readonly string[];
runtimeDependent: boolean;
defaults: HarnessDefaults;
limits: NonNullable<HarnessManifest["limits"]>;
diagnostics: readonly HarnessDiagnostic[];
}
HarnessDiagnostic
export interface HarnessDiagnostic {
code: string;
path: string;
message: string;
severity: "info" | "warning" | "error";
}
HarnessExtension
export interface HarnessExtension {
runtime?: HarnessRuntimeBindings;
runtimeReferences?: HarnessRuntimeReferences;
runtimeRegistry?: HarnessRuntimeRegistry;
id?: string;
abilities?: readonly LocalAbilityUse[];
disable?: readonly string[];
replaceAbilities?: readonly LocalAbilityUse[];
defaults?: HarnessDefaults;
limits?: HarnessManifest["limits"];
}
HarnessManifest
export interface HarnessManifest {
contractVersion: 1;
runtime?: HarnessRuntimeReferences;
id: string;
abilities: readonly AbilitySelection[];
defaults?: HarnessDefaults;
limits?: {
toolRoundtrips?: number;
maxChildDepth?: number;
};
}
HarnessMiddleware
export interface HarnessMiddleware {
id: string;
before?: readonly string[];
after?: readonly string[];
beforeModel?: (messages: readonly ChatMessage[], ctx: RunContext) => Promise<ChatMessage[]>;
afterModel?: (response: ModelResponse, ctx: RunContext) => Promise<void>;
afterTool?: (result: ToolCallResult, ctx: RunContext) => Promise<void>;
}
JsonObject
export type JsonObject = {
[key: string]: JsonValue;
};
JsonValue
export type JsonValue = null | boolean | number | string | JsonValue[] | {
[key: string]: JsonValue;
};
LocalAbilityUse
export interface LocalAbilityUse {
instanceId: string;
validate: () => void;
describe: () => AbilityDescription;
bind: (ctx: RunContext) => Promise<AbilityBinding>;
portable?: AbilitySelection;
/** Trusted factory approved by the creator/host, never recovered from JSON. */
factory?: AbilityFactory;
}
PromptFragment
export interface PromptFragment {
id: string;
text: string;
}
ResolvedHarness
export interface ResolvedHarness {
readonly definition: HarnessDefinition;
readonly defaults: HarnessDefaults;
readonly limits: NonNullable<HarnessManifest["limits"]>;
readonly description: HarnessDescription;
readonly provenance: readonly HarnessProvenance[];
}
Supporting types
These shapes appear in the signatures above but are not named exports of the package entrypoint.HarnessDefinitionInput
export type HarnessDefinitionInput = HarnessDefinition | {
id?: string;
abilities?: readonly LocalAbilityUse[];
defaults?: HarnessDefaults;
limits?: HarnessManifest["limits"];
runtime?: HarnessRuntimeBindings;
runtimeReferences?: HarnessRuntimeReferences;
runtimeRegistry?: HarnessRuntimeRegistry;
};
HarnessProvenance
export interface HarnessProvenance {
path: string;
origin: string;
}