@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
54 lines • 1.97 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. =========
export class Accessor {
/** Keep this accessor's own answers under a mount's read policy. */
govern(read) {
for (const cache of this.caches?.() ?? [])
cache.govern(read);
}
/** Drop this accessor's own answers, as its mount drops its caches. */
forget() {
for (const cache of this.caches?.() ?? [])
cache.clear();
}
}
/**
* An accessor whose calls a `TokenManager` signs. The manager reads token
* expiry and times retry waits on the clock of the workspace that mounts the
* accessor. Mirrors Python's `TokenAccessor`.
*/
export class TokenAccessor extends Accessor {
/**
* Read token expiry and retry waits on `clock`.
*
* @param owner who holds it, released by the same key.
* @throws Error when a workspace on another clock mounts it.
*/
bindClock(clock, owner) {
this.tokenManager.bindClock(clock, owner);
}
/** Let `owner` go. */
releaseClock(owner) {
this.tokenManager.releaseClock(owner);
}
}
/** The accessor of a mount or CLI with no client of its own. */
export class NOOPAccessor extends Accessor {
config;
constructor(config = null) {
super();
this.config = config;
}
}
//# sourceMappingURL=base.js.map