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 • 1.98 kB
JavaScript
;
/**
* search/inEffect — what ONE classified argument was, for the call that ran.
*
* Pattern: one pure reader, the first step of composition. Every other step
* asks it, so "sent", "defaulted", "no narrowing" and "unsent" have
* one meaning.
* Role: semantics/ layer, pure.
* Emits: N/A.
*
* The arguments are the ones the tool RAN with: after the inputs layer's fill
* and any before-tool rewrite. A host-filled argument never appears there —
* `hostFilled` fills it inside `execute` — so the caller names those from the
* wrapper's own declaration (`tools/hostFilled.ts` · `hostFillsOf`).
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.readArgument = void 0;
const declaration_js_1 = require("./declaration.js");
/**
* Read one argument against the arguments the call ran with.
*
* @example
* ```ts
* readArgument({ name: 'window', role: 'period', whenOmitted: '2h' }, {});
* // { kind: 'default', value: '2h' }
* ```
*/
function readArgument(arg, args, hostFilled) {
if (hostFilled !== undefined) {
if (hostFilled.credential.includes(arg.name))
return { kind: 'credential' };
const identity = Object.hasOwn(hostFilled.identity, arg.name)
? hostFilled.identity[arg.name]
: undefined;
if (identity !== undefined)
return { kind: 'host', identity };
}
if (Object.hasOwn(args, arg.name) && args[arg.name] !== undefined) {
const value = args[arg.name];
if (Array.isArray(value) && value.length === 0)
return { kind: 'empty' };
return { kind: 'sent', value };
}
const omitted = arg.whenOmitted;
if (omitted === undefined)
return { kind: 'unsent' };
if ((0, declaration_js_1.isAnyValue)(omitted))
return { kind: 'any' };
return { kind: 'default', value: omitted };
}
exports.readArgument = readArgument;
//# sourceMappingURL=inEffect.js.map