[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F5VD97S0WAGF4XVZ0YVTFG":3,"skill-same:01M7F5VD97S0WAGF4XVZ0YVTFG":102},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":14,"repositoryHtmlUrl":55,"repositoryHomepageUrl":6,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M7F5VD97S0WAGF4XVZ0YVTFG","google-workspace",null,"Gmail, Calendar, Drive, Docs, Sheets via gws CLI or Python.","chaorenex1\u002Fhermes-home-content","chaorenex1","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F23194925?v=4","01M7F5NA1D1D02R2MEMYQN2NZT","chan chan","01M7F5NA20KTHMTY2015CYM1TZ",0,"MIT","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\r\nname: google-workspace\r\ndescription: \"Gmail, Calendar, Drive, Docs, Sheets via gws CLI or Python.\"\r\nversion: 1.2.0\r\nauthor: Nous Research\r\nlicense: MIT\r\nplatforms: [linux, macos, windows]\r\nrequired_credential_files:\r\n  - path: google_token.json\r\n    description: Google OAuth2 token (created by setup script)\r\n  - path: google_client_secret.json\r\n    description: Google OAuth2 client credentials (downloaded from Google Cloud Console)\r\nmetadata:\r\n  hermes:\r\n    tags: [Google, Gmail, Calendar, Drive, Sheets, Docs, Contacts, Email, OAuth]\r\n    homepage: https:\u002F\u002Fgithub.com\u002FNousResearch\u002Fhermes-agent\r\n    related_skills: [himalaya]\r\n---\r\n\r\n# Google Workspace\r\n\r\nGmail, Calendar, Drive, Contacts, Sheets, and Docs — through Hermes-managed OAuth and a thin CLI wrapper. When `gws` is installed, the skill uses it as the execution backend for broader Google Workspace coverage; otherwise it falls back to the bundled Python client implementation.\r\n\r\n## References\r\n\r\n- `references\u002Fgmail-search-syntax.md` — Gmail search operators (is:unread, from:, newer_than:, etc.)\r\n- `references\u002Fdaily-brief.md` — daily\u002Fmorning brief procedure: schedule + conflicts + meeting prep + urgent mail from Gmail and Calendar. Load it when the user asks for a morning brief, meeting preparation, or \"what's on my calendar and what email needs attention.\"\r\n\r\n## Scripts\r\n\r\n- `scripts\u002Fsetup.py` — OAuth2 setup (run once to authorize)\r\n- `scripts\u002Fgoogle_api.py` — compatibility wrapper CLI. It prefers `gws` for operations when available, while preserving Hermes' existing JSON output contract.\r\n\r\n## First-Time Setup\r\n\r\nThe setup is fully non-interactive — you drive it step by step so it works\r\non CLI, Telegram, Discord, or any platform.\r\n\r\nDefine a shorthand first:\r\n\r\n```bash\r\nGSETUP=\"python ${HERMES_HOME:-$HOME\u002F.hermes}\u002Fskills\u002Fproductivity\u002Fgoogle-workspace\u002Fscripts\u002Fsetup.py\"\r\n```\r\n\r\n### Step 0: Check if already set up\r\n\r\n```bash\r\n$GSETUP --check\r\n```\r\n\r\nIf it prints `AUTHENTICATED`, skip to Usage — setup is already done.\r\n\r\n### Step 1: Triage — ask the user what they need\r\n\r\nBefore starting OAuth setup, ask the user TWO questions:\r\n\r\n**Question 1: \"What Google services do you need? Just email, or also\r\nCalendar\u002FDrive\u002FSheets\u002FDocs?\"**\r\n\r\n- **Email only** → They don't need this skill at all. Use the `himalaya` skill\r\n  instead — it works with a Gmail App Password (Settings → Security → App\r\n  Passwords) and takes 2 minutes to set up. No Google Cloud project needed.\r\n  Load the himalaya skill and follow its setup instructions.\r\n\r\n- **Email + Calendar** → Continue with this skill, but use\r\n  `--services email,calendar` during auth so the consent screen only asks for\r\n  the scopes they actually need.\r\n\r\n- **Calendar\u002FDrive\u002FSheets\u002FDocs only** → Continue with this skill and use a\r\n  narrower `--services` set like `calendar,drive,sheets,docs`.\r\n\r\n- **Full Workspace access** → Continue with this skill and use the default\r\n  `all` service set.\r\n\r\n**Question 2: \"Does your Google account use Advanced Protection (hardware\r\nsecurity keys required to sign in)? If you're not sure, you probably don't\r\n— it's something you would have explicitly enrolled in.\"**\r\n\r\n- **No \u002F Not sure** → Normal setup. Continue below.\r\n- **Yes** → Their Workspace admin must add the OAuth client ID to the org's\r\n  allowed apps list before Step 4 will work. Let them know upfront.\r\n\r\n### Step 2: Create OAuth credentials (one-time, ~5 minutes)\r\n\r\nTell the user:\r\n\r\n> You need a Google Cloud OAuth client. This is a one-time setup:\r\n>\r\n> 1. Create or select a project:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fprojectselector2\u002Fhome\u002Fdashboard\r\n> 2. Enable the required APIs from the API Library:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fapis\u002Flibrary\r\n>    Enable: Gmail API, Google Calendar API, Google Drive API,\r\n>    Google Sheets API, Google Docs API, People API\r\n> 3. Create the OAuth client here:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fapis\u002Fcredentials\r\n>    Credentials → Create Credentials → OAuth 2.0 Client ID\r\n> 4. Application type: \"Desktop app\" → Create\r\n> 5. If the app is still in Testing, add the user's Google account as a test user here:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fauth\u002Faudience\r\n>    Audience → Test users → Add users\r\n> 6. Download the JSON file and tell me the file path\r\n>\r\n> Important Hermes CLI note: if the file path starts with `\u002F`, do NOT send only the bare path as its own message in the CLI, because it can be mistaken for a slash command. Send it in a sentence instead, like:\r\n> `The JSON file path is: ~\u002FDownloads\u002Fclient_secret_....json`\r\n\r\nOnce they provide the path:\r\n\r\n```bash\r\n$GSETUP --client-secret \u002Fpath\u002Fto\u002Fclient_secret.json\r\n```\r\n\r\nIf they paste the raw client ID \u002F client secret values instead of a file path,\r\nwrite a valid Desktop OAuth JSON file for them yourself, save it somewhere\r\nexplicit (for example `~\u002FDownloads\u002Fhermes-google-client-secret.json`), then run\r\n`--client-secret` against that file.\r\n\r\n### Step 3: Get authorization URL\r\n\r\nUse the service set chosen in Step 1. Examples:\r\n\r\n```bash\r\n$GSETUP --auth-url --services email,calendar --format json\r\n$GSETUP --auth-url --services calendar,drive,sheets,docs --format json\r\n$GSETUP --auth-url --services all --format json\r\n```\r\n\r\nThis returns JSON with an `auth_url` field and also saves the exact URL to\r\n`~\u002F.hermes\u002Fgoogle_oauth_last_url.txt`.\r\n\r\nAgent rules for this step:\r\n- Extract the `auth_url` field and send that exact URL to the user as a single line.\r\n- Tell the user that the browser will likely fail on `http:\u002F\u002Flocalhost:1` after approval, and that this is expected.\r\n- Tell them to copy the ENTIRE redirected URL from the browser address bar.\r\n- If the user gets `Error 403: access_denied`, send them directly to `https:\u002F\u002Fconsole.cloud.google.com\u002Fauth\u002Faudience` to add themselves as a test user.\r\n\r\n### Step 4: Exchange the code\r\n\r\nThe user will paste back either a URL like `http:\u002F\u002Flocalhost:1\u002F?code=4\u002F0A...&scope=...`\r\nor just the code string. Either works. The `--auth-url` step stores a temporary\r\npending OAuth session locally so `--auth-code` can complete the PKCE exchange\r\nlater, even on headless systems:\r\n\r\n```bash\r\n$GSETUP --auth-code \"THE_URL_OR_CODE_THE_USER_PASTED\" --format json\r\n```\r\n\r\nIf `--auth-code` fails because the code expired, was already used, or came from\r\nan older browser tab, it now returns a fresh `fresh_auth_url`. In that case,\r\nimmediately send the new URL to the user and have them retry with the newest\r\nbrowser redirect only.\r\n\r\n### Step 5: Verify\r\n\r\n```bash\r\n$GSETUP --check\r\n```\r\n\r\nShould print `AUTHENTICATED`. Setup is complete — token refreshes automatically from now on.\r\n\r\n### Notes\r\n\r\n- Token is stored at `~\u002F.hermes\u002Fgoogle_token.json` and auto-refreshes.\r\n- Pending OAuth session state\u002Fverifier are stored temporarily at `~\u002F.hermes\u002Fgoogle_oauth_pending.json` until exchange completes.\r\n- If `gws` is installed, `google_api.py` points it at the same `~\u002F.hermes\u002Fgoogle_token.json` credentials file. Users do not need to run a separate `gws auth login` flow.\r\n- To revoke: `$GSETUP --revoke`\r\n\r\n## Usage\r\n\r\nAll commands go through the API script. Set `GAPI` as a shorthand:\r\n\r\n```bash\r\nGAPI=\"python ${HERMES_HOME:-$HOME\u002F.hermes}\u002Fskills\u002Fproductivity\u002Fgoogle-workspace\u002Fscripts\u002Fgoogle_api.py\"\r\n```\r\n\r\n### Gmail\r\n\r\n```bash\r\n# Search (returns JSON array with id, from, subject, date, snippet)\r\n$GAPI gmail search \"is:unread\" --max 10\r\n$GAPI gmail search \"from:boss@company.com newer_than:1d\"\r\n$GAPI gmail search \"has:attachment filename:pdf newer_than:7d\"\r\n\r\n# Read full message (returns JSON with body text)\r\n$GAPI gmail get MESSAGE_ID\r\n\r\n# Send\r\n$GAPI gmail send --to user@example.com --subject \"Hello\" --body \"Message text\"\r\n$GAPI gmail send --to user@example.com --subject \"Report\" --body \"\u003Ch1>Q4\u003C\u002Fh1>\u003Cp>Details...\u003C\u002Fp>\" --html\r\n$GAPI gmail send --to user@example.com --subject \"Hello\" --from '\"Research Agent\" \u003Cuser@example.com>' --body \"Message text\"\r\n\r\n# Reply (automatically threads and sets In-Reply-To)\r\n$GAPI gmail reply MESSAGE_ID --body \"Thanks, that works for me.\"\r\n$GAPI gmail reply MESSAGE_ID --from '\"Support Bot\" \u003Cuser@example.com>' --body \"Thanks\"\r\n\r\n# Labels\r\n$GAPI gmail labels\r\n$GAPI gmail modify MESSAGE_ID --add-labels LABEL_ID\r\n$GAPI gmail modify MESSAGE_ID --remove-labels UNREAD\r\n```\r\n\r\n### Calendar\r\n\r\n```bash\r\n# List events (defaults to next 7 days)\r\n$GAPI calendar list\r\n$GAPI calendar list --start 2026-03-01T00:00:00Z --end 2026-03-07T23:59:59Z\r\n\r\n# Create event (ISO 8601 with timezone required)\r\n$GAPI calendar create --summary \"Team Standup\" --start 2026-03-01T10:00:00-06:00 --end 2026-03-01T10:30:00-06:00\r\n$GAPI calendar create --summary \"Lunch\" --start 2026-03-01T12:00:00Z --end 2026-03-01T13:00:00Z --location \"Cafe\"\r\n$GAPI calendar create --summary \"Review\" --start 2026-03-01T14:00:00Z --end 2026-03-01T15:00:00Z --attendees \"alice@co.com,bob@co.com\"\r\n\r\n# Delete event\r\n$GAPI calendar delete EVENT_ID\r\n```\r\n\r\n### Drive\r\n\r\n```bash\r\n# Search existing files\r\n$GAPI drive search \"quarterly report\" --max 10\r\n$GAPI drive search \"mimeType='application\u002Fpdf'\" --raw-query --max 5\r\n\r\n# Get metadata for a single file\r\n$GAPI drive get FILE_ID\r\n\r\n# Upload a local file (auto-detects MIME type)\r\n$GAPI drive upload \u002Fpath\u002Fto\u002Freport.pdf\r\n$GAPI drive upload \u002Fpath\u002Fto\u002Fimage.png --name \"Logo.png\" --parent FOLDER_ID\r\n\r\n# Download (binary files download as-is; Google-native files export to a\r\n# sensible default — Docs→pdf, Sheets→csv, Slides→pdf, Drawings→png)\r\n$GAPI drive download FILE_ID\r\n$GAPI drive download DOC_ID --output ~\u002Fdoc.pdf\r\n$GAPI drive download DOC_ID --export-mime text\u002Fplain --output ~\u002Fdoc.txt\r\n\r\n# Create a folder\r\n$GAPI drive create-folder \"Reports\"\r\n$GAPI drive create-folder \"Q4\" --parent FOLDER_ID\r\n\r\n# Share\r\n$GAPI drive share FILE_ID --email alice@example.com --role reader\r\n$GAPI drive share FILE_ID --email alice@example.com --role writer --notify\r\n$GAPI drive share FILE_ID --type anyone --role reader        # anyone with link\r\n$GAPI drive share FILE_ID --type domain --domain example.com --role reader\r\n\r\n# Delete — defaults to trash (reversible). Use --permanent to skip the trash.\r\n$GAPI drive delete FILE_ID\r\n$GAPI drive delete FILE_ID --permanent\r\n```\r\n\r\n### Contacts\r\n\r\n```bash\r\n$GAPI contacts list --max 20\r\n```\r\n\r\n### Sheets\r\n\r\n```bash\r\n# Create a new spreadsheet\r\n$GAPI sheets create --title \"Q4 Budget\"\r\n$GAPI sheets create --title \"Inventory\" --sheet-name \"Stock\"\r\n\r\n# Read\r\n$GAPI sheets get SHEET_ID \"Sheet1!A1:D10\"\r\n\r\n# Write\r\n$GAPI sheets update SHEET_ID \"Sheet1!A1:B2\" --values '[[\"Name\",\"Score\"],[\"Alice\",\"95\"]]'\r\n\r\n# Append rows\r\n$GAPI sheets append SHEET_ID \"Sheet1!A:C\" --values '[[\"new\",\"row\",\"data\"]]'\r\n```\r\n\r\n### Docs\r\n\r\n```bash\r\n# Read\r\n$GAPI docs get DOC_ID\r\n\r\n# Create a new Doc (optionally seeded with body text)\r\n$GAPI docs create --title \"Meeting Notes\"\r\n$GAPI docs create --title \"Draft\" --body \"First paragraph...\"\r\n\r\n# Append text to the end of an existing Doc\r\n$GAPI docs append DOC_ID --text \"Additional content to append\"\r\n```\r\n\r\n## Output Format\r\n\r\nAll commands return JSON. Parse with `jq` or read directly. Key fields:\r\n\r\n- **Gmail search**: `[{id, threadId, from, to, subject, date, snippet, labels}]`\r\n- **Gmail get**: `{id, threadId, from, to, subject, date, labels, body}`\r\n- **Gmail send\u002Freply**: `{status: \"sent\", id, threadId}`\r\n- **Calendar list**: `[{id, summary, start, end, location, description, htmlLink}]`\r\n- **Calendar create**: `{status: \"created\", id, summary, htmlLink}`\r\n- **Drive search**: `[{id, name, mimeType, modifiedTime, webViewLink}]`\r\n- **Drive get**: `{id, name, mimeType, modifiedTime, size, webViewLink, parents, owners}`\r\n- **Drive upload**: `{status: \"uploaded\", id, name, mimeType, webViewLink}`\r\n- **Drive download**: `{status: \"downloaded\", id, name, path, mimeType}`\r\n- **Drive create-folder**: `{status: \"created\", id, name, webViewLink}`\r\n- **Drive share**: `{status: \"shared\", permissionId, fileId, role, type}`\r\n- **Drive delete**: `{status: \"trashed\" | \"deleted\", fileId, permanent}`\r\n- **Contacts list**: `[{name, emails: [...], phones: [...]}]`\r\n- **Sheets get**: `[[cell, cell, ...], ...]`\r\n- **Sheets create**: `{status: \"created\", spreadsheetId, title, spreadsheetUrl}`\r\n- **Docs create**: `{status: \"created\", documentId, title, url}`\r\n- **Docs append**: `{status: \"appended\", documentId, inserted_at, characters}`\r\n\r\n## Rules\r\n\r\n1. **Never send email, create\u002Fdelete calendar events, delete Drive files, share files, or modify Docs\u002FSheets without confirming with the user first.** Show what will be done (recipients, file IDs, content, share role) and ask for approval. For `drive delete`, prefer the default trash (reversible) over `--permanent`.\r\n2. **Check auth before first use** — run `setup.py --check`. If it fails, guide the user through setup.\r\n3. **Use the Gmail search syntax reference** for complex queries — load it with `skill_view(\"google-workspace\", file_path=\"references\u002Fgmail-search-syntax.md\")`.\r\n4. **Calendar times must include timezone** — always use ISO 8601 with offset (e.g., `2026-03-01T10:00:00-06:00`) or UTC (`Z`).\r\n5. **Respect rate limits** — avoid rapid-fire sequential API calls. Batch reads when possible.\r\n\r\n## Troubleshooting\r\n\r\n| Problem | Fix |\r\n|---------|-----|\r\n| `NOT_AUTHENTICATED` | Run setup Steps 2-5 above |\r\n| `REFRESH_FAILED` | Token revoked or expired — redo Steps 3-5 |\r\n| `HttpError 403: Insufficient Permission` | Missing API scope — `$GSETUP --revoke` then redo Steps 3-5 |\r\n| `AUTHENTICATED (partial)` or \"Token missing scopes\" | New write capabilities (Drive write\u002Fdelete, Docs create\u002Fedit) require re-authorization. `$GSETUP --revoke` then redo Steps 3-5 to grant the upgraded scopes. |\r\n| `HttpError 403: Access Not Configured` | API not enabled — user needs to enable it in Google Cloud Console |\r\n| `ModuleNotFoundError` | Run `$GSETUP --install-deps` |\r\n| Advanced Protection blocks auth | Workspace admin must allowlist the OAuth client ID |\r\n\r\n## Revoking Access\r\n\r\n```bash\r\n$GSETUP --revoke\r\n```\r\n","# Google Workspace\r\n\r\nGmail, Calendar, Drive, Contacts, Sheets, and Docs — through Hermes-managed OAuth and a thin CLI wrapper. When `gws` is installed, the skill uses it as the execution backend for broader Google Workspace coverage; otherwise it falls back to the bundled Python client implementation.\r\n\r\n## References\r\n\r\n- `references\u002Fgmail-search-syntax.md` — Gmail search operators (is:unread, from:, newer_than:, etc.)\r\n- `references\u002Fdaily-brief.md` — daily\u002Fmorning brief procedure: schedule + conflicts + meeting prep + urgent mail from Gmail and Calendar. Load it when the user asks for a morning brief, meeting preparation, or \"what's on my calendar and what email needs attention.\"\r\n\r\n## Scripts\r\n\r\n- `scripts\u002Fsetup.py` — OAuth2 setup (run once to authorize)\r\n- `scripts\u002Fgoogle_api.py` — compatibility wrapper CLI. It prefers `gws` for operations when available, while preserving Hermes' existing JSON output contract.\r\n\r\n## First-Time Setup\r\n\r\nThe setup is fully non-interactive — you drive it step by step so it works\r\non CLI, Telegram, Discord, or any platform.\r\n\r\nDefine a shorthand first:\r\n\r\n```bash\r\nGSETUP=\"python ${HERMES_HOME:-$HOME\u002F.hermes}\u002Fskills\u002Fproductivity\u002Fgoogle-workspace\u002Fscripts\u002Fsetup.py\"\r\n```\r\n\r\n### Step 0: Check if already set up\r\n\r\n```bash\r\n$GSETUP --check\r\n```\r\n\r\nIf it prints `AUTHENTICATED`, skip to Usage — setup is already done.\r\n\r\n### Step 1: Triage — ask the user what they need\r\n\r\nBefore starting OAuth setup, ask the user TWO questions:\r\n\r\n**Question 1: \"What Google services do you need? Just email, or also\r\nCalendar\u002FDrive\u002FSheets\u002FDocs?\"**\r\n\r\n- **Email only** → They don't need this skill at all. Use the `himalaya` skill\r\n  instead — it works with a Gmail App Password (Settings → Security → App\r\n  Passwords) and takes 2 minutes to set up. No Google Cloud project needed.\r\n  Load the himalaya skill and follow its setup instructions.\r\n\r\n- **Email + Calendar** → Continue with this skill, but use\r\n  `--services email,calendar` during auth so the consent screen only asks for\r\n  the scopes they actually need.\r\n\r\n- **Calendar\u002FDrive\u002FSheets\u002FDocs only** → Continue with this skill and use a\r\n  narrower `--services` set like `calendar,drive,sheets,docs`.\r\n\r\n- **Full Workspace access** → Continue with this skill and use the default\r\n  `all` service set.\r\n\r\n**Question 2: \"Does your Google account use Advanced Protection (hardware\r\nsecurity keys required to sign in)? If you're not sure, you probably don't\r\n— it's something you would have explicitly enrolled in.\"**\r\n\r\n- **No \u002F Not sure** → Normal setup. Continue below.\r\n- **Yes** → Their Workspace admin must add the OAuth client ID to the org's\r\n  allowed apps list before Step 4 will work. Let them know upfront.\r\n\r\n### Step 2: Create OAuth credentials (one-time, ~5 minutes)\r\n\r\nTell the user:\r\n\r\n> You need a Google Cloud OAuth client. This is a one-time setup:\r\n>\r\n> 1. Create or select a project:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fprojectselector2\u002Fhome\u002Fdashboard\r\n> 2. Enable the required APIs from the API Library:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fapis\u002Flibrary\r\n>    Enable: Gmail API, Google Calendar API, Google Drive API,\r\n>    Google Sheets API, Google Docs API, People API\r\n> 3. Create the OAuth client here:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fapis\u002Fcredentials\r\n>    Credentials → Create Credentials → OAuth 2.0 Client ID\r\n> 4. Application type: \"Desktop app\" → Create\r\n> 5. If the app is still in Testing, add the user's Google account as a test user here:\r\n>    https:\u002F\u002Fconsole.cloud.google.com\u002Fauth\u002Faudience\r\n>    Audience → Test users → Add users\r\n> 6. Download the JSON file and tell me the file path\r\n>\r\n> Important Hermes CLI note: if the file path starts with `\u002F`, do NOT send only the bare path as its own message in the CLI, because it can be mistaken for a slash command. Send it in a sentence instead, like:\r\n> `The JSON file path is: ~\u002FDownloads\u002Fclient_secret_....json`\r\n\r\nOnce they provide the path:\r\n\r\n```bash\r\n$GSETUP --client-secret \u002Fpath\u002Fto\u002Fclient_secret.json\r\n```\r\n\r\nIf they paste the raw client ID \u002F client secret values instead of a file path,\r\nwrite a valid Desktop OAuth JSON file for them yourself, save it somewhere\r\nexplicit (for example `~\u002FDownloads\u002Fhermes-google-client-secret.json`), then run\r\n`--client-secret` against that file.\r\n\r\n### Step 3: Get authorization URL\r\n\r\nUse the service set chosen in Step 1. Examples:\r\n\r\n```bash\r\n$GSETUP --auth-url --services email,calendar --format json\r\n$GSETUP --auth-url --services calendar,drive,sheets,docs --format json\r\n$GSETUP --auth-url --services all --format json\r\n```\r\n\r\nThis returns JSON with an `auth_url` field and also saves the exact URL to\r\n`~\u002F.hermes\u002Fgoogle_oauth_last_url.txt`.\r\n\r\nAgent rules for this step:\r\n- Extract the `auth_url` field and send that exact URL to the user as a single line.\r\n- Tell the user that the browser will likely fail on `http:\u002F\u002Flocalhost:1` after approval, and that this is expected.\r\n- Tell them to copy the ENTIRE redirected URL from the browser address bar.\r\n- If the user gets `Error 403: access_denied`, send them directly to `https:\u002F\u002Fconsole.cloud.google.com\u002Fauth\u002Faudience` to add themselves as a test user.\r\n\r\n### Step 4: Exchange the code\r\n\r\nThe user will paste back either a URL like `http:\u002F\u002Flocalhost:1\u002F?code=4\u002F0A...&scope=...`\r\nor just the code string. Either works. The `--auth-url` step stores a temporary\r\npending OAuth session locally so `--auth-code` can complete the PKCE exchange\r\nlater, even on headless systems:\r\n\r\n```bash\r\n$GSETUP --auth-code \"THE_URL_OR_CODE_THE_USER_PASTED\" --format json\r\n```\r\n\r\nIf `--auth-code` fails because the code expired, was already used, or came from\r\nan older browser tab, it now returns a fresh `fresh_auth_url`. In that case,\r\nimmediately send the new URL to the user and have them retry with the newest\r\nbrowser redirect only.\r\n\r\n### Step 5: Verify\r\n\r\n```bash\r\n$GSETUP --check\r\n```\r\n\r\nShould print `AUTHENTICATED`. Setup is complete — token refreshes automatically from now on.\r\n\r\n### Notes\r\n\r\n- Token is stored at `~\u002F.hermes\u002Fgoogle_token.json` and auto-refreshes.\r\n- Pending OAuth session state\u002Fverifier are stored temporarily at `~\u002F.hermes\u002Fgoogle_oauth_pending.json` until exchange completes.\r\n- If `gws` is installed, `google_api.py` points it at the same `~\u002F.hermes\u002Fgoogle_token.json` credentials file. Users do not need to run a separate `gws auth login` flow.\r\n- To revoke: `$GSETUP --revoke`\r\n\r\n## Usage\r\n\r\nAll commands go through the API script. Set `GAPI` as a shorthand:\r\n\r\n```bash\r\nGAPI=\"python ${HERMES_HOME:-$HOME\u002F.hermes}\u002Fskills\u002Fproductivity\u002Fgoogle-workspace\u002Fscripts\u002Fgoogle_api.py\"\r\n```\r\n\r\n### Gmail\r\n\r\n```bash\r\n# Search (returns JSON array with id, from, subject, date, snippet)\r\n$GAPI gmail search \"is:unread\" --max 10\r\n$GAPI gmail search \"from:boss@company.com newer_than:1d\"\r\n$GAPI gmail search \"has:attachment filename:pdf newer_than:7d\"\r\n\r\n# Read full message (returns JSON with body text)\r\n$GAPI gmail get MESSAGE_ID\r\n\r\n# Send\r\n$GAPI gmail send --to user@example.com --subject \"Hello\" --body \"Message text\"\r\n$GAPI gmail send --to user@example.com --subject \"Report\" --body \"\u003Ch1>Q4\u003C\u002Fh1>\u003Cp>Details...\u003C\u002Fp>\" --html\r\n$GAPI gmail send --to user@example.com --subject \"Hello\" --from '\"Research Agent\" \u003Cuser@example.com>' --body \"Message text\"\r\n\r\n# Reply (automatically threads and sets In-Reply-To)\r\n$GAPI gmail reply MESSAGE_ID --body \"Thanks, that works for me.\"\r\n$GAPI gmail reply MESSAGE_ID --from '\"Support Bot\" \u003Cuser@example.com>' --body \"Thanks\"\r\n\r\n# Labels\r\n$GAPI gmail labels\r\n$GAPI gmail modify MESSAGE_ID --add-labels LABEL_ID\r\n$GAPI gmail modify MESSAGE_ID --remove-labels UNREAD\r\n```\r\n\r\n### Calendar\r\n\r\n```bash\r\n# List events (defaults to next 7 days)\r\n$GAPI calendar list\r\n$GAPI calendar list --start 2026-03-01T00:00:00Z --end 2026-03-07T23:59:59Z\r\n\r\n# Create event (ISO 8601 with timezone required)\r\n$GAPI calendar create --summary \"Team Standup\" --start 2026-03-01T10:00:00-06:00 --end 2026-03-01T10:30:00-06:00\r\n$GAPI calendar create --summary \"Lunch\" --start 2026-03-01T12:00:00Z --end 2026-03-01T13:00:00Z --location \"Cafe\"\r\n$GAPI calendar create --summary \"Review\" --start 2026-03-01T14:00:00Z --end 2026-03-01T15:00:00Z --attendees \"alice@co.com,bob@co.com\"\r\n\r\n# Delete event\r\n$GAPI calendar delete EVENT_ID\r\n```\r\n\r\n### Drive\r\n\r\n```bash\r\n# Search existing files\r\n$GAPI drive search \"quarterly report\" --max 10\r\n$GAPI drive search \"mimeType='application\u002Fpdf'\" --raw-query --max 5\r\n\r\n# Get metadata for a single file\r\n$GAPI drive get FILE_ID\r\n\r\n# Upload a local file (auto-detects MIME type)\r\n$GAPI drive upload \u002Fpath\u002Fto\u002Freport.pdf\r\n$GAPI drive upload \u002Fpath\u002Fto\u002Fimage.png --name \"Logo.png\" --parent FOLDER_ID\r\n\r\n# Download (binary files download as-is; Google-native files export to a\r\n# sensible default — Docs→pdf, Sheets→csv, Slides→pdf, Drawings→png)\r\n$GAPI drive download FILE_ID\r\n$GAPI drive download DOC_ID --output ~\u002Fdoc.pdf\r\n$GAPI drive download DOC_ID --export-mime text\u002Fplain --output ~\u002Fdoc.txt\r\n\r\n# Create a folder\r\n$GAPI drive create-folder \"Reports\"\r\n$GAPI drive create-folder \"Q4\" --parent FOLDER_ID\r\n\r\n# Share\r\n$GAPI drive share FILE_ID --email alice@example.com --role reader\r\n$GAPI drive share FILE_ID --email alice@example.com --role writer --notify\r\n$GAPI drive share FILE_ID --type anyone --role reader        # anyone with link\r\n$GAPI drive share FILE_ID --type domain --domain example.com --role reader\r\n\r\n# Delete — defaults to trash (reversible). Use --permanent to skip the trash.\r\n$GAPI drive delete FILE_ID\r\n$GAPI drive delete FILE_ID --permanent\r\n```\r\n\r\n### Contacts\r\n\r\n```bash\r\n$GAPI contacts list --max 20\r\n```\r\n\r\n### Sheets\r\n\r\n```bash\r\n# Create a new spreadsheet\r\n$GAPI sheets create --title \"Q4 Budget\"\r\n$GAPI sheets create --title \"Inventory\" --sheet-name \"Stock\"\r\n\r\n# Read\r\n$GAPI sheets get SHEET_ID \"Sheet1!A1:D10\"\r\n\r\n# Write\r\n$GAPI sheets update SHEET_ID \"Sheet1!A1:B2\" --values '[[\"Name\",\"Score\"],[\"Alice\",\"95\"]]'\r\n\r\n# Append rows\r\n$GAPI sheets append SHEET_ID \"Sheet1!A:C\" --values '[[\"new\",\"row\",\"data\"]]'\r\n```\r\n\r\n### Docs\r\n\r\n```bash\r\n# Read\r\n$GAPI docs get DOC_ID\r\n\r\n# Create a new Doc (optionally seeded with body text)\r\n$GAPI docs create --title \"Meeting Notes\"\r\n$GAPI docs create --title \"Draft\" --body \"First paragraph...\"\r\n\r\n# Append text to the end of an existing Doc\r\n$GAPI docs append DOC_ID --text \"Additional content to append\"\r\n```\r\n\r\n## Output Format\r\n\r\nAll commands return JSON. Parse with `jq` or read directly. Key fields:\r\n\r\n- **Gmail search**: `[{id, threadId, from, to, subject, date, snippet, labels}]`\r\n- **Gmail get**: `{id, threadId, from, to, subject, date, labels, body}`\r\n- **Gmail send\u002Freply**: `{status: \"sent\", id, threadId}`\r\n- **Calendar list**: `[{id, summary, start, end, location, description, htmlLink}]`\r\n- **Calendar create**: `{status: \"created\", id, summary, htmlLink}`\r\n- **Drive search**: `[{id, name, mimeType, modifiedTime, webViewLink}]`\r\n- **Drive get**: `{id, name, mimeType, modifiedTime, size, webViewLink, parents, owners}`\r\n- **Drive upload**: `{status: \"uploaded\", id, name, mimeType, webViewLink}`\r\n- **Drive download**: `{status: \"downloaded\", id, name, path, mimeType}`\r\n- **Drive create-folder**: `{status: \"created\", id, name, webViewLink}`\r\n- **Drive share**: `{status: \"shared\", permissionId, fileId, role, type}`\r\n- **Drive delete**: `{status: \"trashed\" | \"deleted\", fileId, permanent}`\r\n- **Contacts list**: `[{name, emails: [...], phones: [...]}]`\r\n- **Sheets get**: `[[cell, cell, ...], ...]`\r\n- **Sheets create**: `{status: \"created\", spreadsheetId, title, spreadsheetUrl}`\r\n- **Docs create**: `{status: \"created\", documentId, title, url}`\r\n- **Docs append**: `{status: \"appended\", documentId, inserted_at, characters}`\r\n\r\n## Rules\r\n\r\n1. **Never send email, create\u002Fdelete calendar events, delete Drive files, share files, or modify Docs\u002FSheets without confirming with the user first.** Show what will be done (recipients, file IDs, content, share role) and ask for approval. For `drive delete`, prefer the default trash (reversible) over `--permanent`.\r\n2. **Check auth before first use** — run `setup.py --check`. If it fails, guide the user through setup.\r\n3. **Use the Gmail search syntax reference** for complex queries — load it with `skill_view(\"google-workspace\", file_path=\"references\u002Fgmail-search-syntax.md\")`.\r\n4. **Calendar times must include timezone** — always use ISO 8601 with offset (e.g., `2026-03-01T10:00:00-06:00`) or UTC (`Z`).\r\n5. **Respect rate limits** — avoid rapid-fire sequential API calls. Batch reads when possible.\r\n\r\n## Troubleshooting\r\n\r\n| Problem | Fix |\r\n|---------|-----|\r\n| `NOT_AUTHENTICATED` | Run setup Steps 2-5 above |\r\n| `REFRESH_FAILED` | Token revoked or expired — redo Steps 3-5 |\r\n| `HttpError 403: Insufficient Permission` | Missing API scope — `$GSETUP --revoke` then redo Steps 3-5 |\r\n| `AUTHENTICATED (partial)` or \"Token missing scopes\" | New write capabilities (Drive write\u002Fdelete, Docs create\u002Fedit) require re-authorization. `$GSETUP --revoke` then redo Steps 3-5 to grant the upgraded scopes. |\r\n| `HttpError 403: Access Not Configured` | API not enabled — user needs to enable it in Google Cloud Console |\r\n| `ModuleNotFoundError` | Run `$GSETUP --install-deps` |\r\n| Advanced Protection blocks auth | Workspace admin must allowlist the OAuth client ID |\r\n\r\n## Revoking Access\r\n\r\n```bash\r\n$GSETUP --revoke\r\n```\r\n",{"name":5,"author":24,"license":15,"version":25,"metadata":26,"platforms":41,"description":7,"required_credential_files":45},"Nous Research","1.2.0",{"hermes":27},{"tags":28,"homepage":38,"related_skills":39},[29,30,31,32,33,34,35,36,37],"Google","Gmail","Calendar","Drive","Sheets","Docs","Contacts","Email","OAuth","https:\u002F\u002Fgithub.com\u002FNousResearch\u002Fhermes-agent",[40],"himalaya",[42,43,44],"linux","macos","windows",[46,49],{"path":47,"description":48},"google_token.json","Google OAuth2 token (created by setup script)",{"path":50,"description":51},"google_client_secret.json","Google OAuth2 client credentials (downloaded from Google Cloud Console)","main","a3f3199bb87ec3c91248f68a39d88527e1847ae9","skills\u002F.archive\u002Fgoogle-workspace","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content","https:\u002F\u002Fgithub.com\u002Fchaorenex1","https:\u002F\u002Fblog.aduib.com","A programmer whose only hobby in life is coding","2026-10-20 00:34:32",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add chaorenex1\u002Fhermes-home-content --skill google-workspace",{"tool":66,"command":67},"bunx","bunx skills add chaorenex1\u002Fhermes-home-content --skill google-workspace",{"tool":69,"command":70},"pnpm","pnpm dlx skills add chaorenex1\u002Fhermes-home-content --skill google-workspace","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002FSKILL.md",true,[74,80,84,90,94,98],{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Fdaily-brief.md","REFERENCE","参考文档",3272,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Freferences\u002Fdaily-brief.md",{"path":81,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fgmail-search-syntax.md",2213,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Freferences\u002Fgmail-search-syntax.md",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"scripts\u002F_hermes_home.py","SCRIPT","脚本",1678,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Fscripts\u002F_hermes_home.py",{"path":91,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":92,"sourceHtmlUrl":93},"scripts\u002Fgoogle_api.py",44778,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Fscripts\u002Fgoogle_api.py",{"path":95,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":96,"sourceHtmlUrl":97},"scripts\u002Fgws_bridge.py",4486,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Fscripts\u002Fgws_bridge.py",{"path":99,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":100,"sourceHtmlUrl":101},"scripts\u002Fsetup.py",20745,"https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002F.archive\u002Fgoogle-workspace\u002Fscripts\u002Fsetup.py",[103,110,117,124,131,138],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7F8GF32YD5MBQW2TGSRH1YP","web-retrieval-resilience","Web tools fail or search rules break: repair or fall back.","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Fweb\u002Fweb-retrieval-resilience\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":19},"01M7F8FP46QESQMCZ1KBT3TW3R","blocked-page-recovery","Use when a fetch fails: 403\u002F429, paywall, WAF, bot wall.","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Fweb\u002Fblocked-page-recovery\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":19},"01M7F8ER6VXHBNVRQBZS7X08SE","verification-loop","Run a six-phase verification of a Claude Code session's work — build, type check, lint, tests with coverage, security grep, and diff review — then produce a PASS\u002FFAIL verification report. Use when verifying work after completing a feature or refactor, before creating a PR, or when quality gates must pass.","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":19},"01M7F8E4BQJ38KVQVM3MT20PYV","unreal-world-builder","开放世界与环境专家——精通 UE5 World Partition、Landscape、程序化植被、HLOD 和大规模关卡流式加载，打造无缝开放世界体验","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Funreal-engine\u002Funreal-world-builder\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":19},"01M7F8D747SQW2FTP7GBSX38BR","unreal-technical-artist","Unreal Engine 视觉管线专家——精通材质编辑器、Niagara 特效、程序化内容生成和 UE5 项目的美术到引擎管线","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Funreal-engine\u002Funreal-technical-artist\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":19},"01M7F8CKHYJVZVBTN0321J88T2","unreal-systems-engineer","性能与混合架构专家——精通 C++\u002FBlueprint 边界、Nanite 几何体、Lumen GI 和 Gameplay Ability System，面向 AAA 级 Unreal Engine 项目","https:\u002F\u002Fgithub.com\u002Fchaorenex1\u002Fhermes-home-content\u002Fblob\u002Fmain\u002Fskills\u002Funreal-engine\u002Funreal-systems-engineer\u002FSKILL.md",[],[]]