@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
39 lines • 3.7 kB
TypeScript
import { GmailAccessor } from '../../accessor/gmail.ts';
import type { DeltaHook } from '../../events/base.ts';
import type { DirListing, FileStat, PathSpec } from '../../types.ts';
import { BaseVFS } from '../base.ts';
import type { RedactedSchema } from '../secrets.ts';
import type { ConfigState, Handed } from '../types.ts';
import { GmailConfig } from './config.ts';
export declare const VFS_MD = "```text\n{prefix}\n <label>/\n <yyyy-mm-dd>/\n <subject>__<message-id>.gmail.json # the email, body included\n <subject>__<message-id>/ # its attachments, if any\n <attachment-filename>\n```\n\n- `<label>` is a Gmail label: `INBOX`, `SENT`, `DRAFT`, `IMPORTANT`,\n `STARRED`, `TRASH`, `SPAM` or any user label.\n- `<yyyy-mm-dd>` is the date the message was received. Listing one\n (`ls {prefix}/INBOX/2026-05-03/`) pushes `after:`/`before:` into the\n Gmail query, much cheaper than scanning the whole label.\n- `<subject>` is sanitized: `ls` the date directory rather than\n construct it. `<message-id>` is the Gmail message id.\n- The email body is in the `.gmail.json` file; read it with `cat`,\n `head` or `jq`, keeping the suffix. The sibling directory, the same\n name without the extension, holds attachments only: `cat` one to\n download its bytes. `grep -r` over a date directory skips these binary\n files.\n- A `grep` or `rg` hit names the `.gmail.json` file, not the attachments\n directory. To list a message's attachments, `ls` its path with\n `.gmail.json` stripped; `ENOENT` means it has none:\n `ls {prefix}/INBOX/2026-05-03/<subject>__<message-id>/`\n\nA `.gmail.json` is processed by Mirage, not the raw Gmail API response:\n\n```jsonc\n{\n \"id\": \"...\",\n \"thread_id\": \"...\",\n \"from\": { \"name\": \"...\", \"email\": \"...\" },\n \"to\": [ { \"name\": \"...\", \"email\": \"...\" } ],\n \"cc\": [ ... ],\n \"subject\": \"...\",\n \"date\": \"Mon, 3 May 2026 10:00:00 -0700\",\n \"body_text\": \"decoded plain-text body\",\n \"snippet\": \"first ~200 chars from Gmail\",\n \"labels\": [ \"INBOX\", \"IMPORTANT\", ... ],\n \"attachments\": [\n { \"id\": \"...\", \"filename\": \"invoice.pdf\",\n \"mime_type\": \"application/pdf\", \"size\": 12345 }\n ]\n}\n```\n\nUseful `jq` paths:\n\n```jq\n.subject\n.from.email\n.body_text\n.labels[]\n.attachments[] | .filename\n```\n\nTo act on messages (read by id, triage, raw API calls), use the `gws`\nCLI if installed (`gws gmail --help`).";
export declare class GmailVFS extends BaseVFS {
readonly name: string;
readonly cachesReads: boolean;
readonly sizesAlwaysKnown: boolean;
readonly indexTtl: number;
vfsMd: string;
readonly searchable: readonly string[];
readonly handed: {
readonly readdir: readonly ["entry"];
readonly read: readonly ["entry"];
readonly stat: readonly ["entry", "parent"];
};
readonly config: GmailConfig;
readonly accessor: GmailAccessor;
constructor(config: GmailConfig);
readdir(path: PathSpec, handed?: Handed): Promise<FileStat[] | DirListing>;
read(path: PathSpec, handed?: Handed): Promise<Uint8Array>;
deltaHook(): DeltaHook;
stat(path: PathSpec, handed?: Handed): Promise<FileStat>;
/**
* Whether this VFS answers `name`; with no walk limit it reads every
* file rather than ask the service's search.
*/
supports(name: string): boolean;
filesContaining(path: PathSpec, text: string, _opts: {
wholeWord: boolean;
ignoreCase: boolean;
}): Promise<PathSpec[] | null>;
getState(): Promise<ConfigState<RedactedSchema<typeof GmailConfig>>>;
}
//# sourceMappingURL=gmail.d.ts.map