agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
52 lines (51 loc) • 3.04 kB
TypeScript
/**
* Injection Engine — evaluator.
*
* Pattern: Pure function. Stateless.
* Role: Internal helper. Called once per iteration by the
* InjectionEngine subflow's compose stage. Slot subflows
* read the `active` array and filter by their slot target.
* Emits: N/A. Caller (the subflow) emits
* `agentfootprint.context.evaluated`.
*
* Behavior per trigger kind:
* • `always` → always active.
* • `rule` → predicate runs against `ctx`. Errors are
* caught + reported in `skipped`; never
* propagate. Run never crashes.
* • `on-tool-return` → active when ANY tool result of the previous
* iteration's batch (`toolResultsOf(ctx)` —
* `ctx.toolResults`, falling back to the
* singular `ctx.lastToolResult`) has a
* `toolName` matching `trigger.toolName`
* (string equal or regex test). Before 9.16.0
* only the LAST call of a parallel batch was
* consulted — earlier calls were dropped.
* • `llm-activated` → active when the Injection's `id` is in
* `ctx.activatedInjectionIds` (the LLM
* previously called `viaToolName(<id>)`).
*
* Beside the trigger kinds, ONE framework-tier admission (9.19.0): an
* injection named by `ctx.leaseActiveIds` — a `require-instruction` tool
* effect's granted lease — is active for this pass even when its own
* trigger said nothing. Declaration order is preserved (the lease admits;
* it never reorders), and an injection both triggered AND leased is active
* once. Absent `leaseActiveIds` = the loop below is byte-identical.
*
* Before everything else, the ROLE gate: a skill named by
* `ctx.hiddenSkillIds` (the caller's `skill_read` answer for this pass) is
* skipped with the reason `'hidden'`, whatever its trigger, a lease or the
* cursor says. This is where activation is decided, so it is where hidden is
* enforced. Absent `hiddenSkillIds` = the loop below is byte-identical.
*
* And ONE framework-tier suppression, the admission's mirror (9.58.0): an
* injection named by `ctx.parkedIds` — a member of a map the mount kernel
* has PARKED for lack of corroborating evidence — is skipped for this pass
* with the honest reason `'parked'`, whatever its own trigger says. Checked
* FIRST (before the lease) so the record can never claim a parked map's
* contribution was served; a lease that would collide with a park is itself
* renewal evidence upstream, so the collision does not arise. Absent
* `parkedIds` = the loop below is byte-identical.
*/
import type { Injection, InjectionContext, InjectionEvaluation } from './types.js';
export declare function evaluateInjections(injections: readonly Injection[], ctx: InjectionContext): InjectionEvaluation;