agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
63 lines • 3.71 kB
JavaScript
;
/**
* agentfootprint/resilience — what happens when the call fails.
*
* Both halves of staying up, behind one name:
*
* • Provider decorators — `withRetry`, `withFallback`, `fallbackProvider`,
* `withCircuitBreaker`. Each preserves the `LLMProvider` interface, so
* they stack freely around any provider.
* • The rules engine — `.reliability({ postDecide: [...] })`'s typed rule
* shapes, the fail-fast error, the pure breaker state machine, and the
* schema-retry helpers.
*
* ## One name that exists twice, said out loud
*
* `CircuitOpenError` is TWO different classes: the decorator throws one
* (`src/resilience/withCircuitBreaker.ts`), the reliability gate throws
* another (`src/reliability/CircuitBreaker.ts`), and they differ in
* constructor and in `instanceof`. This door carries the DECORATOR's — the
* one a consumer catches, since it is the one that escapes a provider call.
*
* The gate's stays reachable at `agentfootprint/reliability` because it is a distinct runtime class.
* If you `instanceof`-check the error thrown by the reliability gate, keep
* importing it from there. Merging them would have changed the message text
* on one path, and this release changes packaging only.
*
* `CircuitState` also exists twice, but the two are byte-identical
* (`'closed' | 'open' | 'half-open'`), so the one re-exported here satisfies
* both and no consumer can tell the difference.
*
* @example
* ```ts
* import { withRetry, withFallback, type ReliabilityRule } from 'agentfootprint/resilience';
* ```
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationFailure = exports.lastNValidationErrorsMatch = exports.defaultStuckLoopRule = exports.initialBreakerState = exports.ReliabilityFailFastError = void 0;
// The decorators, whole. This is also where the door's `CircuitOpenError`
// and `CircuitState` come from — see the note above.
__exportStar(require("../resilience/index.js"), exports);
var types_js_1 = require("../reliability/types.js");
Object.defineProperty(exports, "ReliabilityFailFastError", { enumerable: true, get: function () { return types_js_1.ReliabilityFailFastError; } });
var CircuitBreaker_js_1 = require("../reliability/CircuitBreaker.js");
Object.defineProperty(exports, "initialBreakerState", { enumerable: true, get: function () { return CircuitBreaker_js_1.initialBreakerState; } });
var reliabilityExecution_js_1 = require("../core/agent/stages/reliabilityExecution.js");
Object.defineProperty(exports, "defaultStuckLoopRule", { enumerable: true, get: function () { return reliabilityExecution_js_1.defaultStuckLoopRule; } });
Object.defineProperty(exports, "lastNValidationErrorsMatch", { enumerable: true, get: function () { return reliabilityExecution_js_1.lastNValidationErrorsMatch; } });
Object.defineProperty(exports, "ValidationFailure", { enumerable: true, get: function () { return reliabilityExecution_js_1.ValidationFailure; } });
//# sourceMappingURL=resilience.js.map