trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
31 lines • 1.34 kB
TypeScript
/**
* Decision Auto-Capture Middleware
*
* Wraps MCP tool handlers to automatically emit vcs:decisionRecord ops
* for every tool invocation. Pre/post hooks can enrich the trace with
* rationale, alternatives, and prompt context.
*/
import type { HookRegistry } from './hooks.js';
import type { DecisionInput } from './types.js';
/** A generic MCP tool handler: receives params, returns a result. */
export type ToolHandler = (params: Record<string, unknown>) => Promise<unknown>;
/** Callback invoked after auto-capture builds the DecisionInput. */
export type DecisionRecorder = (decision: DecisionInput) => Promise<void>;
export interface AutoCaptureOpts {
/** The hook registry for pre/post enrichment. */
hooks: HookRegistry;
/** Called to persist the decision as a VcsOp. */
recorder: DecisionRecorder;
/** Tool names to exclude from auto-capture (e.g. read-only queries). */
exclude?: Set<string>;
}
/**
* Wrap an MCP tool handler for automatic decision trace capture.
*/
export declare function wrapToolHandler(toolName: string, handler: ToolHandler, opts: AutoCaptureOpts): ToolHandler;
/**
* Summarize a tool result to a concise string (max 500 chars).
*/
declare function summarize(result: unknown): string;
export { summarize as _summarizeForTest };
//# sourceMappingURL=auto-capture.d.ts.map