Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt

Use this file to discover all available pages before exploring further.

GmailResource browses messages, threads, and labels via the Gmail API. Both runtimes share the same OAuth config: a Google Cloud clientId / clientSecret plus a long-lived refreshToken for the user. Setup steps live at Google Workspace Credentials.

Node

pnpm add @struktoai/mirage-node
import { GmailResource, MountMode, Workspace } from '@struktoai/mirage-node'

const gmail = new GmailResource({
  clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
  refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
})

const ws = new Workspace({ '/mail': gmail }, { mode: MountMode.READ })
await ws.execute('ls /mail/INBOX/')

Browser

pnpm add @struktoai/mirage-browser
import { GmailResource, MountMode, Workspace } from '@struktoai/mirage-browser'

const gmail = new GmailResource({
  clientId: GOOGLE_CLIENT_ID,
  clientSecret: GOOGLE_CLIENT_SECRET,
  refreshToken: localStorage.getItem('gmail.refresh_token')!,
})

const ws = new Workspace({ '/mail': gmail }, { mode: MountMode.READ })
For OAuth in a browser, prefer PKCE so secrets stay off the page; the Google setup guide shows the flow.

Config

FieldDefaultNotes
clientIdrequiredGoogle OAuth client ID.
clientSecretrequiredGoogle OAuth client secret. Redacted in snapshots.
refreshTokenrequiredUser’s refresh token. Redacted in snapshots.
refreshFnbuilt-inOptional override for the access-token refresh callback.

Mount mode

read. Partial write (drafts, labels) is exposed via Python and may land in TS in a future release. For the mounted layout (labels, dates, attachments) see the Python Gmail docs.