agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
19 lines • 927 B
JavaScript
import { allow } from './outcomes.js';
// Only wrappers made here can promise not to inspect output. Ordinary callbacks
// can branch on either phase, so their delivery must wait for the output walk.
const phases = new WeakMap();
/** Bind a declared phase without changing the other phase's recorded allow row. */
export function messageAt(phase, middleware) {
const wrapped = {
name: middleware.name,
onMessage: (message) => (message.phase === phase ? middleware.onMessage(message) : allow()),
};
phases.set(wrapped, phase);
// Keep the declared phase inseparable from its guard; the caller's rule stays mutable.
return Object.freeze(wrapped);
}
/** Build-time knowledge, never an inference from a callback's name or source. */
export function hasOutputMiddleware(chain) {
return chain.some((middleware) => phases.get(middleware) !== 'input');
}
//# sourceMappingURL=messagePhase.js.map