npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@officedesk/plugin-gmail

v0.0.8

Published

Gmail integration plugin for officedesk-ai

Readme

@officedesk/plugin-gmail

Gmail integration plugin for OfficeDesk AI. Provides a CLI and programmatic API to search messages, download attachments, and manage multiple Gmail account profiles via OAuth.

Installation

npm install -g @officedesk/plugin-gmail

Or use it directly with npx:

npx @officedesk/plugin-gmail --help

Quick start

# Authenticate your Gmail account
officedesk-plugin-gmail login

# Search for messages
officedesk-plugin-gmail search-messages --query="subject:invoice has:attachment"

# Download attachments from a message
officedesk-plugin-gmail download-attachments --message-id=MSG_ID

Configuration

Token files and plugin configuration are stored under OFFICEDESK_HOME (defaults to ~/.officedesk/).

| Path | Description | |---|---| | $OFFICEDESK_HOME/plugins/plugin-gmail/tokens/token-set.json | Default account token | | $OFFICEDESK_HOME/plugins/plugin-gmail/tokens/token-set.<profile>.json | Named profile token | | $OFFICEDESK_HOME/plugins/plugin-gmail/.env | Plugin-level environment overrides |

Set OFFICEDESK_HOME to a custom directory if you want tokens and config stored elsewhere:

export OFFICEDESK_HOME=/path/to/your/config

CLI reference

officedesk-plugin-gmail <command> [options]

Run officedesk-plugin-gmail --help for a summary, or officedesk-plugin-gmail <command> --help for per-command details.


login

Authenticate a Gmail account via the browser OAuth flow and write a local token file.

officedesk-plugin-gmail login
officedesk-plugin-gmail login --profile=finance

Options

| Flag | Description | |---|---| | --profile=NAME | Named profile to authenticate (defaults to the shared default account) |

After login, the token is saved to the profile-specific path under OFFICEDESK_HOME. Subsequent commands for that profile will use the saved token automatically.


list-profiles

List all configured Gmail profiles detected from token and .env files.

officedesk-plugin-gmail list-profiles

Returns JSON with each detected profile and whether it has a .env file, a token file, or both.

Example output

{
  "plugin": "plugin-gmail",
  "profiles": [
    { "name": "default", "hasEnv": true, "hasToken": true },
    { "name": "finance", "hasEnv": false, "hasToken": true }
  ],
  "count": 2
}

search-messages

Search Gmail messages using Gmail's native search syntax.

officedesk-plugin-gmail search-messages --query="subject:receipt has:attachment"
officedesk-plugin-gmail search-messages --profile=finance --query="from:[email protected] invoice" --max=50

Options

| Flag | Description | |---|---| | --query=TEXT | Gmail search query. Supports all Gmail operators (see below) | | --max=N | Maximum number of messages to return (default: all, capped at 500) | | --page-token=TOKEN | Pagination token from a previous response for fetching the next page | | --save-cache | Save results to cache/search-results.json (disabled by default) | | --profile=NAME | Gmail account profile to use (defaults to the shared default account) |

Gmail query operators

| Operator | Example | Description | |---|---|---| | subject: | subject:invoice | Match subject line | | from: | from:[email protected] | Match sender | | to: | to:me | Match recipient | | has:attachment | has:attachment | Messages with attachments | | after: | after:2024/01/01 | Messages after a date | | before: | before:2024/12/31 | Messages before a date | | Quoted phrase | "quarterly report" | Exact phrase match |

Full syntax: https://support.google.com/mail/answer/7190


download-attachments

Download all attachments from a Gmail message into a local directory.

officedesk-plugin-gmail download-attachments --message-id=MSG_ID
officedesk-plugin-gmail download-attachments --profile=finance --message-id=MSG_ID --output=downloads/invoices

Attachments are saved to <output>/<message-id>/ to avoid collisions across messages.

Options

| Flag | Description | |---|---| | --message-id=ID | (Required) Gmail message ID | | --output=DIR | Base output directory (default: downloads/plugin-gmail) | | --profile=NAME | Gmail account profile to use (defaults to the shared default account) |

The message ID can be obtained from search-messages output.


Multiple profiles

Each profile maintains its own token file, allowing you to authenticate and operate multiple Gmail accounts independently.

# Authenticate separate accounts
officedesk-plugin-gmail login                    # default account
officedesk-plugin-gmail login --profile=finance  # finance account

# List all configured profiles
officedesk-plugin-gmail list-profiles

# Run commands against a specific profile
officedesk-plugin-gmail search-messages --profile=finance --query="subject:invoice"
officedesk-plugin-gmail download-attachments --profile=finance --message-id=MSG_ID

Programmatic API

import { searchMessages, downloadAttachments } from '@officedesk/plugin-gmail';

const messages = await searchMessages({
    query: 'subject:invoice has:attachment',
    maxResults: 20,
    profile: 'finance',
});

const files = await downloadAttachments({
    messageId: '18c8f0d3...',
    profile: 'finance',
});

Exported types

import type {
    SearchMessagesOptions,
    SearchMessagesCliOutput,
    GmailMessageSummary,
    GmailAttachment,
    DownloadAttachmentsOptions,
    DownloadedAttachment,
} from '@officedesk/plugin-gmail';

Environment variables

| Variable | Description | |---|---| | OFFICEDESK_HOME | Base directory for tokens and config (default: ~/.officedesk/) |

License

ISC