agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
85 lines • 4.09 kB
JavaScript
;
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.readStoredCauseArtifacts = void 0;
const causeCapture_js_1 = require("./causeCapture.js");
const storedCauseOptions_js_1 = require("./storedCauseOptions.js");
const unknown = (reason) => ({ status: 'unknown', reason });
/**
* Admit one host-authorized saved root through the producer's public reader, without a runtime snapshot.
* Storage acknowledgement is not producer authentication. Missing source ownership remains unknown.
* Graph projection is capped at 4,096 nodes/commits and uses the producer's 256-level data depth.
* Cannot preempt a blocking host iterator; cancellation is checked before and after asynchronous admission.
*/
async function readStoredCauseArtifacts(entries, options) {
let configured;
try {
configured = (0, storedCauseOptions_js_1.storedCauseOptions)(options);
if ((0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal))
return unknown('cancelled');
}
catch {
return unknown('invalid-data');
}
if (!globalThis.crypto?.subtle)
return unknown('unavailable');
let reader;
try {
({ readStoredCapture: reader } = await Promise.resolve().then(() => __importStar(require('./storedCauseReader.js'))));
}
catch {
return unknown('unsupported');
}
if ((0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal))
return unknown('cancelled');
if (typeof reader !== 'function')
return unknown('unsupported');
try {
const result = await reader(entries, {
runId: configured.runId,
maxBytes: configured.maxBytes,
...(configured.readerLimits === undefined ? {} : { limits: configured.readerLimits }),
});
if ((0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal))
return unknown('cancelled');
if ((0, causeCapture_js_1.captureOwn)(result, 'status') !== 'acknowledged') {
const reason = (0, causeCapture_js_1.captureOwn)(result, 'reason');
return unknown(reason === 'reader-limit' || reason === 'history-too-large'
? 'reader-limit'
: 'stored-admission');
}
const history = (0, causeCapture_js_1.captureOwn)(result, 'history');
const { projectStoredCause } = await Promise.resolve().then(() => __importStar(require('./storedCauseProjection.js')));
if ((0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal))
return unknown('cancelled');
const projected = projectStoredCause(history, configured.runId, configured.maxBytes);
return (0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal) ? unknown('cancelled') : projected;
}
catch {
return unknown((0, storedCauseOptions_js_1.storedCauseCancelled)(configured.signal) ? 'cancelled' : 'unavailable');
}
}
exports.readStoredCauseArtifacts = readStoredCauseArtifacts;
//# sourceMappingURL=storedCause.js.map