Files
gmail-hook/apps/watcher/scripts/list-messages.js
T
nsrbandCursor f270f531ea feat(watcher): add agent Gmail CLI with audit and defaults
Provide list/read/summarize plus reason-gated archive, label, draft, and forward-as-draft, with SQLite audit logging and default-mailbox resolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-22 10:09:25 +07:00

30 lines
927 B
JavaScript

#!/usr/bin/env node
/**
* List Gmail messages: id, from, subject (metadata only).
* Thin wrapper around: npm run gmail -- list …
*
* Usage:
* npm run list-messages --
* npm run list-messages -- --query 'newer_than:14d' --max 100
* npm run list-messages -- --json
*
* Options:
* --query <q> Gmail search (default: newer_than:7d)
* --user <email> Mailbox (default: resolveUser order)
* --max <n> Max messages (default 50)
* --json Print JSON lines instead of a table
*/
import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const gmailJs = resolve(__dirname, "gmail.js");
const child = spawn(
process.execPath,
[gmailJs, "list", ...process.argv.slice(2)],
{ stdio: "inherit" },
);
child.on("exit", (code) => process.exit(code ?? 1));