UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

62 lines • 2.59 kB
/** * provider-contract/types — the Ports of the hexagonal architecture. * * Pattern: Adapter (GoF, Design Patterns ch. 4) + Ports-and-Adapters * (Cockburn, 2005). * Role: Contracts for every external dependency the library reaches for: * LLM providers, memory stores, permission checkers, pricing tables. * Emits: N/A (interfaces only). * * Concrete adapters (AnthropicProvider, PineconeStore, PermissionPolicy, * ...) implement these contracts. `core/` and `core-flow/` depend only on * these interfaces — never on concrete adapters. */ /** * The floor every known wire supports. Used for any provider that does not * declare `carriesInMessages` — a third-party adapter is assumed to carry * only what all of them do, never more. */ export const DEFAULT_CARRIES_IN_MESSAGES = Object.freeze([ 'user', 'assistant', ]); /** * Does this checker ask to be consulted about `capability`? (9.11.0) * * `'tool_call'` is always true — it has been enforced since v2.4 and needs no * declaration. Everything else is true only when the checker named it. * Absence is NO. */ export function checkerGoverns(checker, capability) { if (!checker) return false; if (capability === 'tool_call') return true; return checker.governs?.includes(capability) === true; } /** * The environment variable an executing snippet reads its staged inputs from — * a JSON object mapping each input's NAME to the path it landed at. * * Part of {@link CodeSession.stageInputs}'s contract rather than one adapter's * convention, and named here so an adapter uses the constant instead of * retyping the string. It is what makes model-written code portable across * backends: the code reads one variable, and every adapter that stages inputs * fills it the same way. */ export const STAGED_INPUTS_ENV = 'AF_STAGED_INPUTS'; /** Can this session accept staged inputs? The feature-detection law: read the * member, never assume it from the adapter's name. */ export function canStageCodeInputs(session) { return typeof session.stageInputs === 'function'; } /** Can this session read files back out? Read the member, never the adapter's name. */ export function canReadCodeFiles(session) { return typeof session.readFile === 'function'; } /** Can this session run shell commands? Absent unless the runner was built * with `commands: true`. Read the member, never the adapter's name. */ export function canRunCodeCommands(session) { return typeof session.runCommand === 'function'; } //# sourceMappingURL=types.js.map