trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
58 lines • 2.54 kB
TypeScript
/**
* Agent Harness — Runtime for managing agent definitions, runs, and decisions.
*
* Loads agent definitions from the graph (TrellisKernel), manages tool
* registrations, executes runs, and records decision traces as kernel entities.
*
* @module trellis/core/agents
*/
import type { TrellisKernel } from '../kernel/trellis-kernel.js';
import type { AgentDef, ToolDef, ToolHandler, ToolResult, AgentRun, DecisionTrace, AgentHarnessConfig, RunTaskOptions } from './types.js';
export declare class AgentHarness {
private kernel;
private toolHandlers;
private config;
private runCounter;
constructor(kernel: TrellisKernel, config?: AgentHarnessConfig);
/**
* Execute an autonomous task run using the configured LLM provider.
*
* When the configured contextManager is a GraphContextManager, conversations
* are automatically created (or resumed) and linked to the agent run. Pass
* `opts.conversationId` to resume an existing conversation.
*/
runAgentTask(agentId: string, input: string, opts?: RunTaskOptions): Promise<string>;
private _getAvailableTools;
createAgent(def: Omit<AgentDef, 'id' | 'capabilities' | 'tools'> & {
id?: string;
capabilities?: string[];
tools?: string[];
}): Promise<AgentDef>;
getAgent(id: string): AgentDef | null;
listAgents(status?: AgentDef['status']): AgentDef[];
registerTool(def: Omit<ToolDef, 'id'> & {
id?: string;
}, handler: ToolHandler): Promise<string>;
getToolHandler(toolId: string): ToolHandler | undefined;
listTools(): ToolDef[];
startRun(agentId: string, input?: string): Promise<string>;
completeRun(runId: string, output?: string, tokenCount?: number): Promise<void>;
failRun(runId: string, error: string): Promise<void>;
getRun(runId: string): AgentRun | null;
listRuns(agentId?: string): AgentRun[];
recordDecision(runId: string, toolName: string, input?: Record<string, unknown>, output?: string, opts?: {
rationale?: string;
alternatives?: string[];
relatedEntities?: string[];
}): Promise<string>;
/**
* Invoke a registered tool within a run, auto-recording a decision trace.
*/
invokeTool(runId: string, toolId: string, input: Record<string, unknown>, opts?: {
rationale?: string;
relatedEntities?: string[];
}): Promise<ToolResult>;
getDecisionChain(entityId: string): DecisionTrace[];
private _buildDecisionTrace;
}
//# sourceMappingURL=harness.d.ts.map