@mastra/core
Version:
Mastra is the Typescript framework for building AI agents and assistants. It’s used by some of the largest companies in the world to build internal AI automation tooling and customer-facing agents.
34 lines (33 loc) • 890 B
JavaScript
// src/storage/storageWithInit.ts
var isAugmentedSymbol = Symbol("isAugmented");
function augmentWithInit(storage) {
let hasInitialized = null;
const ensureInit = async () => {
if (!hasInitialized) {
hasInitialized = storage.init();
}
await hasInitialized;
};
if (storage[isAugmentedSymbol]) {
return storage;
}
const proxy = new Proxy(storage, {
get(target, prop) {
if (prop === isAugmentedSymbol) {
return true;
}
const value = target[prop];
if (typeof value === "function" && prop !== "init") {
return async (...args) => {
await ensureInit();
return Reflect.apply(value, target, args);
};
}
return Reflect.get(target, prop);
}
});
return proxy;
}
export { augmentWithInit };
//# sourceMappingURL=chunk-436FFEF6.js.map
//# sourceMappingURL=chunk-436FFEF6.js.map