agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
51 lines • 2.36 kB
JavaScript
;
/**
* defineInjection — the unified injection factory (one factory, a `type`
* discriminant for the flavor).
*
* The named factories (`defineInstruction`, `defineSkill`, `defineSteering`,
* `defineFact`) are self-documenting sugar — prefer them when you know the
* flavor at author time. `defineInjection` is for the cases where the flavor is
* chosen *programmatically* (config-driven pipelines, a UI that lets users add
* any flavor, table-driven tests) — pass `type` and the same options the named
* factory takes:
*
* @example
* // these two are equivalent
* defineInstruction({ id: 'calm', prompt: '…', activeWhen });
* defineInjection({ type: 'instruction', id: 'calm', prompt: '…', activeWhen });
*
* @example // flavor decided at runtime
* const inj = defineInjection({ type: cfg.flavor, id: cfg.id, ...cfg.opts });
*
* All four flavors return the same `Injection` primitive — `type` simply routes
* to the matching named factory. RAG and Memory are NOT covered here: they are
* separate subsystems (retrieval + stores), not plain Injections.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineInjection = void 0;
const defineFact_js_1 = require("./defineFact.js");
const defineInstruction_js_1 = require("./defineInstruction.js");
const defineSkill_js_1 = require("./defineSkill.js");
const defineSteering_js_1 = require("./defineSteering.js");
function defineInjection(opts) {
// The facade owns `type`; the skill constructor validates it alongside the
// skill vocabulary on the original bag. Never spread options to remove it:
// that would read unknown getters and drop inherited/non-enumerable options.
switch (opts.type) {
case 'instruction':
return (0, defineInstruction_js_1.defineInstruction)(opts);
case 'skill':
return (0, defineSkill_js_1.defineSkillInjection)(opts);
case 'steering':
return (0, defineSteering_js_1.defineSteering)(opts);
case 'fact':
return (0, defineFact_js_1.defineFact)(opts);
default: {
const exhaustive = opts;
throw new Error(`defineInjection: unknown injection type "${String(exhaustive.type)}".`);
}
}
}
exports.defineInjection = defineInjection;
//# sourceMappingURL=defineInjection.js.map