@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
41 lines • 2.25 kB
TypeScript
import type { GoogleApiAccessor } from '../../accessor/google_api.ts';
import { Delta, type PathSpec } from '../../types.ts';
import type { DeltaHook } from '../../events/base.ts';
/** What a Drive change-feed checkpoint holds. */
export interface FeedState {
token: string;
seen?: Record<string, string>;
root?: string;
folders?: Record<string, [string, string]>;
}
/** What a Drive change-feed checkpoint holds, null for a baseline. Mirrors Python `feed_state`. */
export declare function feedState(checkpoint: string | null): FeedState | null;
/** Encode a Drive change-feed checkpoint. Mirrors Python `feed_checkpoint`. */
export declare function feedCheckpoint(state: FeedState): string;
/**
* Checkpointed delta of a Google app mount over Drive's change feed.
*
* Drive pings a channel with no body, so a ping reads `changes.list` from the
* page token the last read handed out, keeping the changes to the app's files.
* Each is placed as the app lists it: in `owned` or `shared` by its first
* owner, named by its title, id and modified day. The checkpoint keeps the
* path of each file a read placed, so an edit on another day or a new title
* moves it from the name it had, and a file deleted, trashed or no longer
* shared leaves it. A file seen for the first time is created when it is as
* Drive made it (its created and modified times agree) and updated otherwise;
* the name it had before is left to the corpus listing the update evicts.
*
* Mirrors Python `AppDeltaHook` (`core/google/events.py`).
*/
export declare class AppDeltaHook implements DeltaHook {
private readonly accessor;
private readonly mime;
private readonly makeFilename;
constructor(accessor: GoogleApiAccessor, mime: string, makeFilename: (title: string, id: string, modified?: string) => string);
pull(root: PathSpec, checkpoint: string | null): Promise<Delta>;
/** Where the app lists `item`. */
private path;
}
/** The delta hook of a Google app mount (`AppDeltaHook`). Mirrors Python's `app_delta_hook`. */
export declare function appDeltaHook(accessor: GoogleApiAccessor, mime: string, makeFilename: (title: string, id: string, modified?: string) => string): DeltaHook;
//# sourceMappingURL=events.d.ts.map