@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
50 lines • 1.77 kB
JavaScript
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
/** What a cache entry holds. Mirrors Python's `Holds`. */
export var Holds;
(function (Holds) {
Holds["BYTES"] = "bytes";
Holds["BYTES_AND_VERSION"] = "bytes_and_version";
Holds["VERSION"] = "version";
})(Holds || (Holds = {}));
export class CacheEntry {
size;
cachedAt;
fingerprint;
ttl;
holds;
constructor(init) {
this.size = init.size;
this.cachedAt = init.cachedAt;
this.fingerprint = init.fingerprint ?? null;
this.ttl = init.ttl ?? null;
this.holds = init.holds ?? Holds.BYTES;
Object.freeze(this);
}
/** Whether the entry holds the file's bytes, not only its version. */
get hasBytes() {
return this.holds !== Holds.VERSION;
}
/**
* Whether the entry has outlived its TTL at `now`.
*
* @param now whole seconds since the unix epoch, as `cachedAt` records it.
*/
isExpired(now) {
if (this.ttl === null)
return false;
return now - this.cachedAt >= this.ttl;
}
}
//# sourceMappingURL=entry.js.map