agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
24 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasOutputMiddleware = exports.messageAt = void 0;
const outcomes_js_1 = require("./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. */
function messageAt(phase, middleware) {
const wrapped = {
name: middleware.name,
onMessage: (message) => (message.phase === phase ? middleware.onMessage(message) : (0, outcomes_js_1.allow)()),
};
phases.set(wrapped, phase);
// Keep the declared phase inseparable from its guard; the caller's rule stays mutable.
return Object.freeze(wrapped);
}
exports.messageAt = messageAt;
/** Build-time knowledge, never an inference from a callback's name or source. */
function hasOutputMiddleware(chain) {
return chain.some((middleware) => phases.get(middleware) !== 'input');
}
exports.hasOutputMiddleware = hasOutputMiddleware;
//# sourceMappingURL=messagePhase.js.map