From 98fd412851a3d326463c2ba2f22d1d0d8941305f Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:57:23 -0600 Subject: [PATCH] fix(apps): show readable Google Workspace action names on Review and Permissions (#22630) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Connectors let agents use outside apps. The Google Workspace connector gives agents Gmail, Calendar, Drive, Docs, Sheets and Slides actions. > - Each connection has a Review tab and a Permissions tab. People approve actions and turn actions on or off there. > - Google Workspace actions had no human title. These tabs showed the internal tool name, for example `gmail__get_message` and `calendar__list_events`. > - Users must not see internal names. Google's app reviewers will also look at these screens. > - This pull request gives every Google Workspace action a readable name, such as "Gmail: Read a message", for both tool transports. > - The benefit is that people and reviewers see what each action does, in plain words. ## Linked Issues or Issue Description **What happened?** On the Review tab and the Permissions tab of a Google Workspace connection, action rows showed internal tool names. Examples: `gmail__get_message` in the "Review new actions" list and the action list, and "Calendar Create Event" in the "Waiting for your OK" list. **Expected behavior** Each row shows a readable action name, for example "Gmail: Read a message" or "Calendar: List events". No row shows a `service__tool` name or a raw ID. **Steps to reproduce** 1. Connect Google Workspace. 2. Open Connectors, then the connection, then Permissions. Look at the action list. 3. Open Review. Look at "Review new actions" and "Waiting for your OK". **Paperclip version or commit** master at 78e4f4f130. ## What Changed - `server/src/google-workspace-rest-tools/`: each of the 36 Paperclip REST tool definitions now has an MCP `title` (for example `get_message` is "Read a message"). The change stays inside each tool's own file. `allowlist.test.ts` now checks that every tool has a short title. - `packages/shared`: new `googleWorkspaceToolTitle(name, title)`. For an allowlisted Google tool it returns ": ". When no title is known, it uses the action name in sentence case ("Gmail: Get message"). - `server/src/services/google-workspace-rest-dispatch.ts`: new `googleWorkspaceCatalogToolTitle`. For a Google Workspace connection it uses the Paperclip REST title when one exists, then the upstream title. It works the same for `google_mcp` and `paperclip_rest`. `GOOGLE_WORKSPACE_TOOL_TRANSPORT` does not change. - The server applies this title when it discovers the catalog, when it reads the catalog, in the review queue list (`toolTitle`), and in the gateway display name. The approval card text and preview use the display name, so new requests show the readable name too. Rows saved before a catalog refresh also get the readable name at read time. - UI: the Permissions action list, the "Review new actions" list, the agent access list, the action test dialog and the "Waiting for your OK" list use one helper, `actionLabel`. It uses the readable Google name when the server gives no title. - No API field, route, permission check or company scope changes. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed, because a pinned shared file changed. ## Verification - Red, then green: `ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx` renders the Review tab and the Permissions action list with Google rows as the server sent them before this change (no title, real UUIDs in every ID field). It checks that no `service__tool` name and no UUID is visible. - Before: the test failed. The Review tab showed `gmail__get_message` and "Calendar Create Event". The Permissions list showed `calendar__list_events` and `gmail__create_draft`. - After: the test passes. The tabs show "Gmail: Get message", "Calendar: Create event", "Calendar: List events" and "Gmail: Create draft" with this UI-only fallback. With the server change, the names are the REST titles, for example "Gmail: Read a message". - `server/src/services/google-workspace-rest-dispatch.test.ts`: every allowlisted tool of every service gets a ": " title with no underscores and no UUID, for both transports. Titles from other connections do not change. - `packages/shared/src/google-workspace-connectors.test.ts`: tests for `googleWorkspaceToolTitle`. - `server/src/google-workspace-rest-tools/allowlist.test.ts` and `boundary.test.ts` pass. - Focused runs: UI `src/pages/apps/app-detail`, `ReviewQueueCard.test.tsx`, `AppDetail.test.tsx` (141 tests pass). Server Google Workspace tests, review queue test, `tool-access-service.test.ts`, `tool-gateway-service.test.ts`, `connection-management.integration.test.ts` (2,212 tests pass). - `pnpm --filter @paperclipai/shared typecheck`, `pnpm --filter @paperclipai/ui typecheck` and `pnpm --filter @paperclipai/server typecheck` pass. - `pnpm verify` exits 2 because the pinned input registry is a global CI input. Required CI gives the broad coverage. ## Risks - Low risk. The change only affects display titles of Google Workspace actions. Tool names, policies, grants and calls do not change. - The gateway display name of a Google tool changes from its internal name to the readable name. Agents see this text as the tool title only. The tool name that agents call does not change. - Approval previews saved before this change keep their old text until the request is resolved. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), in Claude Code with tool use (shell, file edit, test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- .../src/google-workspace-connectors.test.ts | 16 +- .../shared/src/google-workspace-connectors.ts | 15 ++ .../src/google-workspace-rest-tools/README.md | 4 + .../allowlist.test.ts | 8 + .../calendar/create-event.ts | 1 + .../calendar/delete-event.ts | 1 + .../calendar/get-event.ts | 1 + .../calendar/list-calendars.ts | 1 + .../calendar/list-events.ts | 1 + .../calendar/respond-to-event.ts | 1 + .../calendar/search-events.ts | 1 + .../calendar/suggest-time.ts | 1 + .../calendar/update-event.ts | 1 + .../docs/read-doc.ts | 1 + .../docs/update-doc.ts | 1 + .../drive/copy-file.ts | 1 + .../drive/create-file.ts | 1 + .../drive/download-file-content.ts | 1 + .../drive/get-file-metadata.ts | 1 + .../drive/get-file-permissions.ts | 1 + .../drive/list-recent-files.ts | 1 + .../drive/read-file-content.ts | 1 + .../drive/search-files.ts | 1 + .../gmail/create-draft.ts | 1 + .../gmail/get-draft.ts | 1 + .../gmail/get-message.ts | 1 + .../gmail/get-thread.ts | 1 + .../gmail/list-drafts.ts | 1 + .../gmail/list-labels.ts | 1 + .../gmail/list-threads.ts | 1 + .../gmail/search-messages.ts | 1 + .../gmail/search-threads.ts | 1 + .../sheets/get-spreadsheet.ts | 1 + .../sheets/get-values.ts | 1 + .../sheets/insert-dimension.ts | 1 + .../sheets/update-formulas.ts | 1 + .../sheets/update-spreadsheet.ts | 1 + .../sheets/update-values.ts | 1 + .../slides/read-presentation.ts | 1 + .../slides/update-presentation.ts | 1 + .../google-workspace-rest-dispatch.test.ts | 30 ++++ .../google-workspace-rest-dispatch.ts | 15 ++ server/src/services/tool-access.ts | 2 + .../tool-access/activity/review-queue.ts | 3 +- .../services/tool-access/catalog/discovery.ts | 7 +- server/src/services/tool-gateway.ts | 4 +- .../runner-e2e/source-sdk-public-inputs.json | 4 +- ui/src/pages/apps/ReviewQueueCard.tsx | 4 +- .../apps/app-detail/ActionTestDialog.tsx | 7 +- .../apps/app-detail/AgentConnectionAccess.tsx | 3 +- .../GoogleWorkspaceActionLabels.test.tsx | 142 ++++++++++++++++++ .../apps/app-detail/PermissionsPanel.tsx | 7 +- ui/src/pages/apps/app-detail/SetupPanel.tsx | 3 +- .../apps/app-detail/action-permissions.ts | 6 + 54 files changed, 298 insertions(+), 18 deletions(-) create mode 100644 ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx diff --git a/packages/shared/src/google-workspace-connectors.test.ts b/packages/shared/src/google-workspace-connectors.test.ts index 07467b028d6..0021bf50e20 100644 --- a/packages/shared/src/google-workspace-connectors.test.ts +++ b/packages/shared/src/google-workspace-connectors.test.ts @@ -8,9 +8,23 @@ import { googleWorkspaceDraftRequestedScopes, GOOGLE_WORKSPACE_SERVICE_GROUPS, GOOGLE_WORKSPACE_SUBMITTED_SCOPES, GOOGLE_WORKSPACE_CONNECTOR_PROFILE_IDS, googleWorkspaceProfileWithinSubmittedScopes, GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceToolNames, googleWorkspaceSelectionForScopes, - type GoogleWorkspaceServiceSelection, + googleWorkspaceToolTitle, type GoogleWorkspaceServiceSelection, } from "./google-workspace-connectors.js"; +describe("googleWorkspaceToolTitle", () => { + it("names a Google tool by service and action, never by its internal name", () => { + expect(googleWorkspaceToolTitle("gmail__get_message")).toBe("Gmail: Get message"); + expect(googleWorkspaceToolTitle("gmail__get_message", "Read a message")).toBe("Gmail: Read a message"); + expect(googleWorkspaceToolTitle("calendar__list_events", "Calendar: List events")).toBe("Calendar: List events"); + expect(googleWorkspaceToolTitle("search__search_corpus")).toBe("Workspace search: Search corpus"); + }); + + it("returns the given title for anything that is not an allowlisted Google tool", () => { + expect(googleWorkspaceToolTitle("gmail__send_message")).toBeNull(); + expect(googleWorkspaceToolTitle("create_issue", " Create issue ")).toBe("Create issue"); + }); +}); + const scope = (value: string) => `https://www.googleapis.com/auth/${value}`; describe("combined Google Workspace consent", () => { diff --git a/packages/shared/src/google-workspace-connectors.ts b/packages/shared/src/google-workspace-connectors.ts index 3adffe189f0..270fbd40c0f 100644 --- a/packages/shared/src/google-workspace-connectors.ts +++ b/packages/shared/src/google-workspace-connectors.ts @@ -198,6 +198,21 @@ export function googleWorkspaceToolTarget(name: string) { transport: GOOGLE_WORKSPACE_TOOL_TRANSPORT[service] }; } +const GOOGLE_WORKSPACE_SERVICE_TITLES: Record = { + gmail: "Gmail", drive: "Drive", docs: "Docs", sheets: "Sheets", slides: "Slides", + calendar: "Calendar", chat: "Chat", people: "People", search: "Workspace search", +}; + +export function googleWorkspaceToolTitle(name: string, title?: string | null): string | null { + const target = googleWorkspaceToolTarget(name); + const given = title?.trim() || null; + if (!target) return given; + const service = GOOGLE_WORKSPACE_SERVICE_TITLES[target.service]; + if (given?.startsWith(`${service}: `)) return given; + const leaf = target.leaf.replace(/_/g, " "); + return `${service}: ${given ?? leaf.charAt(0).toUpperCase() + leaf.slice(1)}`; +} + export function googleWorkspaceServiceToolNames(service: GoogleWorkspaceService): string[] { return Object.keys(toolScopes[service]); } diff --git a/server/src/google-workspace-rest-tools/README.md b/server/src/google-workspace-rest-tools/README.md index 973a153a684..b84398a501b 100644 --- a/server/src/google-workspace-rest-tools/README.md +++ b/server/src/google-workspace-rest-tools/README.md @@ -72,6 +72,10 @@ so they can be deleted cleanly when that happens. - **One tool, one file.** Each tool in `gmail/`, `calendar/`, `drive/`, `docs/`, `slides/` and `sheets/` is a set of pure functions (arguments to REST request, REST response to MCP result) plus a short `run` that sequences them. The pure functions are unit tested without network. +- **Every tool has a `title`.** It is a short action name in sentence case, + such as "Read a message". The gateway shows it to people as + "Gmail: Read a message" for both transports. `allowlist.test.ts` fails if a + tool has no title. - **`server.ts` is thin MCP wiring:** `tools/list` and `tools/call`. - **The allowlist stays where it is.** `toolScopes` in `packages/shared/src/google-workspace-connectors.ts` is the single list of diff --git a/server/src/google-workspace-rest-tools/allowlist.test.ts b/server/src/google-workspace-rest-tools/allowlist.test.ts index 4dbf6898aa5..4fc0ebc145b 100644 --- a/server/src/google-workspace-rest-tools/allowlist.test.ts +++ b/server/src/google-workspace-rest-tools/allowlist.test.ts @@ -47,6 +47,14 @@ describe("tool allowlist", () => { expect(everything).not.toMatch(/label:`? takes label IDs/i); }); + it("gives every tool a short human title", () => { + for (const service of GOOGLE_WORKSPACE_REST_SERVICES) { + for (const tool of listGoogleWorkspaceRestTools(service)) { + expect(tool.title, tool.name).toMatch(/^[A-Z][a-z]+( [a-z]+)*$/); + } + } + }); + it("implements no send tool", () => { const names = GOOGLE_WORKSPACE_REST_SERVICES.flatMap((service) => listGoogleWorkspaceRestTools(service).map((tool) => tool.name)); expect(names.filter((name) => /send/i.test(name))).toEqual([]); diff --git a/server/src/google-workspace-rest-tools/calendar/create-event.ts b/server/src/google-workspace-rest-tools/calendar/create-event.ts index d814d0a843e..de0a069d693 100644 --- a/server/src/google-workspace-rest-tools/calendar/create-event.ts +++ b/server/src/google-workspace-rest-tools/calendar/create-event.ts @@ -147,6 +147,7 @@ export function createEventResult(event: RestEvent): CallToolResult { export const createEvent = defineTool({ definition: { name: "create_event", + title: "Create an event", description: "Creates an event on a calendar and returns it. By default Google emails an invitation to every attendee (notificationLevel ALL); pass notificationLevel NONE to create it silently.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/delete-event.ts b/server/src/google-workspace-rest-tools/calendar/delete-event.ts index 81a72d175af..a0fb353350f 100644 --- a/server/src/google-workspace-rest-tools/calendar/delete-event.ts +++ b/server/src/google-workspace-rest-tools/calendar/delete-event.ts @@ -52,6 +52,7 @@ export function deleteEventResult(deleted: RestEvent): CallToolResult { export const deleteEvent = defineTool({ definition: { name: "delete_event", + title: "Delete an event", description: "Deletes one event, or one occurrence of a recurring event, and returns it as it was, with status cancelled. It never deletes a whole recurring series: a series ID is refused, so pass one occurrence's ID (from list_events). By default Google emails a cancellation to every attendee (notificationLevel ALL); pass notificationLevel NONE to delete it silently.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/get-event.ts b/server/src/google-workspace-rest-tools/calendar/get-event.ts index 3a81de45256..491b033a61c 100644 --- a/server/src/google-workspace-rest-tools/calendar/get-event.ts +++ b/server/src/google-workspace-rest-tools/calendar/get-event.ts @@ -14,6 +14,7 @@ export function getEventResult(event: RestEvent): CallToolResult { export const getEvent = defineTool({ definition: { name: "get_event", + title: "Read an event", description: "Gets one event from a calendar by event ID.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/list-calendars.ts b/server/src/google-workspace-rest-tools/calendar/list-calendars.ts index ee4fcdacc79..bc5058467fc 100644 --- a/server/src/google-workspace-rest-tools/calendar/list-calendars.ts +++ b/server/src/google-workspace-rest-tools/calendar/list-calendars.ts @@ -45,6 +45,7 @@ export function calendarProbeRequest(): GoogleRequest { export const listCalendars = defineTool({ definition: { name: "list_calendars", + title: "List calendars", description: "Lists the calendars the signed-in user owns or has subscribed to, as shown in Google Calendar's calendar list. Use it to turn a name such as \"my family calendar\" into a calendar ID. Other calendars shared with the user can still be read by their ID.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/list-events.ts b/server/src/google-workspace-rest-tools/calendar/list-events.ts index 3bec582ec7b..30f5ce18260 100644 --- a/server/src/google-workspace-rest-tools/calendar/list-events.ts +++ b/server/src/google-workspace-rest-tools/calendar/list-events.ts @@ -161,6 +161,7 @@ async function readAllForDescending(input: ListEventsArgs, window: EventWindow, export const listEvents = defineTool({ definition: { name: "list_events", + title: "List events", description: "Lists events on one calendar that match all the given filters. Recurring events are returned as their individual occurrences. Set startTime or endTime only when the user asks about a specific time. For open-ended keyword or topic searches on the primary calendar, use search_events instead.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/respond-to-event.ts b/server/src/google-workspace-rest-tools/calendar/respond-to-event.ts index 7e059d56db1..0a93f50d545 100644 --- a/server/src/google-workspace-rest-tools/calendar/respond-to-event.ts +++ b/server/src/google-workspace-rest-tools/calendar/respond-to-event.ts @@ -56,6 +56,7 @@ export function respondToEventResult(event: RestEvent): CallToolResult { export const respondToEvent = defineTool({ definition: { name: "respond_to_event", + title: "Respond to an event", description: "Sets the signed-in user's response (accepted, tentative or declined) to an event they are invited to, with an optional comment, and returns the event. Passing a recurring series' ID responds for the whole series; passing one occurrence's ID (from list_events) responds for that occurrence only. The result shows which: a series has recurrence and no recurringEventId; one occurrence has recurringEventId. By default only attendees outside the organizer's domain are emailed (notificationLevel EXTERNAL_ONLY).", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/search-events.ts b/server/src/google-workspace-rest-tools/calendar/search-events.ts index 50d18c009d3..493833b6634 100644 --- a/server/src/google-workspace-rest-tools/calendar/search-events.ts +++ b/server/src/google-workspace-rest-tools/calendar/search-events.ts @@ -38,6 +38,7 @@ export function searchEventsResult(list: RestEventList): CallToolResult { export const searchEvents = defineTool({ definition: { name: "search_events", + title: "Search events", description: "Searches events on the signed-in user's primary calendar by keywords, across all dates. Matches title, description, location, attendees and organizer; every term must match. A recurring series is returned once, as the series, not as each occurrence; use list_events to see occurrences in a time range.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/suggest-time.ts b/server/src/google-workspace-rest-tools/calendar/suggest-time.ts index f13be80a28c..43f75ece091 100644 --- a/server/src/google-workspace-rest-tools/calendar/suggest-time.ts +++ b/server/src/google-workspace-rest-tools/calendar/suggest-time.ts @@ -257,6 +257,7 @@ const slotTime = { export const suggestTime = defineTool({ definition: { name: "suggest_time", + title: "Suggest a meeting time", description: "Finds periods in a time range when all the given people are free, from their calendars' busy times. Each suggestion is a whole free period at least durationMinutes long, earliest first. Free periods are not split into meeting-length slots.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/calendar/update-event.ts b/server/src/google-workspace-rest-tools/calendar/update-event.ts index 91b122ed2e5..d01a497f259 100644 --- a/server/src/google-workspace-rest-tools/calendar/update-event.ts +++ b/server/src/google-workspace-rest-tools/calendar/update-event.ts @@ -210,6 +210,7 @@ export function updateEventResult(event: RestEvent): CallToolResult { export const updateEvent = defineTool({ definition: { name: "update_event", + title: "Update an event", description: "Changes an event on a calendar and returns the updated event. Fields that are not set are left as they are. By default Google emails the change to every attendee (notificationLevel ALL); pass notificationLevel NONE to change it silently. Passing a recurring series' ID changes the whole series (every occurrence that has not been changed on its own); passing one occurrence's ID (from list_events) changes only that occurrence. The result shows which: a series has recurrence and no recurringEventId; one occurrence has recurringEventId.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/docs/read-doc.ts b/server/src/google-workspace-rest-tools/docs/read-doc.ts index fbed00b37e0..7b425386f2f 100644 --- a/server/src/google-workspace-rest-tools/docs/read-doc.ts +++ b/server/src/google-workspace-rest-tools/docs/read-doc.ts @@ -44,6 +44,7 @@ export function readDocResult(document: RestDocument, input: ReadDocArgs, view: export const readDoc = defineTool({ definition: { name: "read_doc", + title: "Read a document", description: [ "Reads a Google Doc, every tab included, and returns its content.", "content.text is the whole document as Markdown-style text: headings start with #, list items with - or their number, tables use | cells |, links are [text](url), footnote references are [^1] with the footnote text after the body, headers and footers follow the body under [Header] and [Footer], and each tab starts with === Tab: title === when there is more than one.", diff --git a/server/src/google-workspace-rest-tools/docs/update-doc.ts b/server/src/google-workspace-rest-tools/docs/update-doc.ts index 39ffc9e732f..34f968dadd6 100644 --- a/server/src/google-workspace-rest-tools/docs/update-doc.ts +++ b/server/src/google-workspace-rest-tools/docs/update-doc.ts @@ -47,6 +47,7 @@ export function updateDocResult(response: RestBatchUpdateResponse): CallToolResu export const updateDoc = defineTool({ definition: { name: "update_doc", + title: "Edit a document", description: [ "Edits an existing Google Doc with a list of Docs API batchUpdate requests (for example insertText, deleteContentRange, replaceAllText, updateTextStyle, updateParagraphStyle, createParagraphBullets, insertTable or insertInlineImage), and returns one reply per request.", "Requests are applied in the order given, all or none: if any request is invalid, nothing is changed.", diff --git a/server/src/google-workspace-rest-tools/drive/copy-file.ts b/server/src/google-workspace-rest-tools/drive/copy-file.ts index c00184a034b..8bf6c5b1ee9 100644 --- a/server/src/google-workspace-rest-tools/drive/copy-file.ts +++ b/server/src/google-workspace-rest-tools/drive/copy-file.ts @@ -33,6 +33,7 @@ export function copyFileResult(file: RestFile): CallToolResult { export const copyFile = defineTool({ definition: { name: "copy_file", + title: "Copy a file", description: "Copies a Drive file into a new file and returns the copy. The original is not changed. Folders cannot be copied. Without title the copy gets Google's default name; without parentId Google places it next to the original when it can. Writes use Drive file access (drive.file), so Google may refuse a file or folder that this app did not create or open; the call then returns an error and nothing is copied.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/drive/create-file.ts b/server/src/google-workspace-rest-tools/drive/create-file.ts index e70a04b9994..2d03b214a55 100644 --- a/server/src/google-workspace-rest-tools/drive/create-file.ts +++ b/server/src/google-workspace-rest-tools/drive/create-file.ts @@ -128,6 +128,7 @@ export function createFileResult(file: RestFile): CallToolResult { export const createFile = defineTool({ definition: { name: "create_file", + title: "Create a file", description: "Creates a new file in Google Drive and returns it. It never changes or replaces an existing file. Prefer textContent for text; use base64Content for other bytes. Content is at most 5 MB. contentMimeType is required with content. By default, content Google can convert becomes a Google file: text, Markdown, HTML, RTF and Word files become Google Docs; CSV, TSV and Excel files become Sheets; PowerPoint files become Slides. Set disableConversionToGoogleType to keep the uploaded type. Without content, contentMimeType must be application/vnd.google-apps.document, application/vnd.google-apps.spreadsheet, application/vnd.google-apps.presentation or application/vnd.google-apps.folder. With Drive file access (drive.file), parentId must be a folder this app created or was given.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/drive/download-file-content.ts b/server/src/google-workspace-rest-tools/drive/download-file-content.ts index 2066c11c393..597c19beac8 100644 --- a/server/src/google-workspace-rest-tools/drive/download-file-content.ts +++ b/server/src/google-workspace-rest-tools/drive/download-file-content.ts @@ -14,6 +14,7 @@ export function downloadFileContentResult(id: string, file: RestFile, contentTyp export const downloadFileContent = defineTool({ definition: { name: "download_file_content", + title: "Download a file", description: "Downloads a Drive file's content as base64. Google Docs, Sheets, Slides, Drawings and Apps Script files are exported: by default Docs and Slides as text/plain, Sheets as text/csv (first sheet only; pass exportMimeType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for every sheet), Drawings as image/svg+xml, Apps Script as JSON. Other files are returned as stored. The whole result has a size limit; a file too large for it is refused with an error that gives the limit, never cut short. For a readable text version of a document, use read_file_content.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/drive/get-file-metadata.ts b/server/src/google-workspace-rest-tools/drive/get-file-metadata.ts index bb1b2b28195..e02d719c696 100644 --- a/server/src/google-workspace-rest-tools/drive/get-file-metadata.ts +++ b/server/src/google-workspace-rest-tools/drive/get-file-metadata.ts @@ -26,6 +26,7 @@ export function getFileMetadataResult(file: RestFile, rich: boolean): CallToolRe export const getFileMetadata = defineTool({ definition: { name: "get_file_metadata", + title: "Read file details", description: "Gets a Drive file's metadata: title, type, size, parent folder, owner, times and link. Returns no content snippet; use read_file_content for the text. If the file is not found, find it with search_files.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/drive/get-file-permissions.ts b/server/src/google-workspace-rest-tools/drive/get-file-permissions.ts index 3ee90318f93..d48c424c4d4 100644 --- a/server/src/google-workspace-rest-tools/drive/get-file-permissions.ts +++ b/server/src/google-workspace-rest-tools/drive/get-file-permissions.ts @@ -59,6 +59,7 @@ export async function readPermissions(id: string, http: GoogleHttp): Promise ({ type: "array", items: { type: "st export const createDraft = defineTool({ definition: { name: "create_draft", + title: "Create a draft", description: "Creates a draft email in the signed-in user's Gmail and returns it. It does not send. To draft a reply, pass the original message's ID as replyToMessageId. Attachments are not supported yet.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/get-draft.ts b/server/src/google-workspace-rest-tools/gmail/get-draft.ts index bf61917fbcb..e2df82f0e98 100644 --- a/server/src/google-workspace-rest-tools/gmail/get-draft.ts +++ b/server/src/google-workspace-rest-tools/gmail/get-draft.ts @@ -61,6 +61,7 @@ export function getDraftResult(draft: GmailRestDraftFull, input: GetDraftArgs, b export const getDraft = defineTool({ definition: { name: "get_draft", + title: "Read a draft", description: "Gets one draft email from the signed-in user's Gmail by draft ID. Draft IDs come from list_drafts.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/get-message.ts b/server/src/google-workspace-rest-tools/gmail/get-message.ts index 71c635c6093..f69fd953152 100644 --- a/server/src/google-workspace-rest-tools/gmail/get-message.ts +++ b/server/src/google-workspace-rest-tools/gmail/get-message.ts @@ -53,6 +53,7 @@ async function readExternalBodies(message: GmailRestMessage, input: GetMessageAr export const getMessage = defineTool({ definition: { name: "get_message", + title: "Read a message", description: "Gets one email message from the signed-in user's Gmail by message ID.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/get-thread.ts b/server/src/google-workspace-rest-tools/gmail/get-thread.ts index d56c5fa53b4..7b82bf78d5b 100644 --- a/server/src/google-workspace-rest-tools/gmail/get-thread.ts +++ b/server/src/google-workspace-rest-tools/gmail/get-thread.ts @@ -35,6 +35,7 @@ export function getThreadResult(thread: GmailRestFullThread, input: GetThreadArg export const getThread = defineTool({ definition: { name: "get_thread", + title: "Read a thread", description: "Gets one email thread from the signed-in user's Gmail by thread ID, with its messages oldest first.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/list-drafts.ts b/server/src/google-workspace-rest-tools/gmail/list-drafts.ts index 16219a30c90..7d3c664842a 100644 --- a/server/src/google-workspace-rest-tools/gmail/list-drafts.ts +++ b/server/src/google-workspace-rest-tools/gmail/list-drafts.ts @@ -52,6 +52,7 @@ async function readDrafts(ids: string[], view: DraftView | undefined, http: Goog export const listDrafts = defineTool({ definition: { name: "list_drafts", + title: "List drafts", description: "Lists the signed-in user's Gmail drafts one page at a time, optionally filtered by a Gmail search query. Returns recipients, subject and bodies by default.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/list-labels.ts b/server/src/google-workspace-rest-tools/gmail/list-labels.ts index 7ad5fb423af..4b9256b4c57 100644 --- a/server/src/google-workspace-rest-tools/gmail/list-labels.ts +++ b/server/src/google-workspace-rest-tools/gmail/list-labels.ts @@ -52,6 +52,7 @@ export function listLabelsResult(list: GmailLabelList, input: ListLabelsArgs): C export const listLabels = defineTool({ definition: { name: "list_labels", + title: "List labels", description: "Lists the user-defined labels in the signed-in user's Gmail with their IDs and names, sorted by name. Use the IDs with list_threads, and the names (spaces written as hyphens) with `label:` in search queries. System labels are not listed; their IDs are INBOX, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, SENT, DRAFT and CHAT.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/list-threads.ts b/server/src/google-workspace-rest-tools/gmail/list-threads.ts index 5c44f7e39f9..de8ee1bc70e 100644 --- a/server/src/google-workspace-rest-tools/gmail/list-threads.ts +++ b/server/src/google-workspace-rest-tools/gmail/list-threads.ts @@ -49,6 +49,7 @@ export function listThreadsToolRequest(input: ListThreadsArgs): GoogleRequest { export const listThreads = defineTool({ definition: { name: "list_threads", + title: "List threads", description: "Lists the signed-in user's Gmail threads, newest first, one page at a time, optionally only threads that have every given label. Returns thread IDs with message summaries, not full bodies; use get_thread with a thread ID for full messages. To filter by words, senders or dates, use search_threads.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/search-messages.ts b/server/src/google-workspace-rest-tools/gmail/search-messages.ts index 057606b68fa..1c11159040c 100644 --- a/server/src/google-workspace-rest-tools/gmail/search-messages.ts +++ b/server/src/google-workspace-rest-tools/gmail/search-messages.ts @@ -69,6 +69,7 @@ async function readMessages(ids: string[], input: SearchMessagesArgs, http: Goog export const searchMessages = defineTool({ definition: { name: "search_messages", + title: "Search messages", description: "Lists the signed-in user's Gmail messages that match an optional Gmail search query, newest first, one page at a time. Returns message summaries by default; set messageFormat to FULL_CONTENT for bodies, or use get_message with a message ID.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/gmail/search-threads.ts b/server/src/google-workspace-rest-tools/gmail/search-threads.ts index 6ecd323e32e..e04a4389b7c 100644 --- a/server/src/google-workspace-rest-tools/gmail/search-threads.ts +++ b/server/src/google-workspace-rest-tools/gmail/search-threads.ts @@ -109,6 +109,7 @@ export async function readThreads(ids: string[], http: GoogleHttp): Promise; export const updateFormulas = defineTool({ definition: { name: "update_formulas", + title: "Update formulas", description: "Writes formulas into one range of a spreadsheet. Each item is entered as if typed into Google Sheets (Sheets valueInputOption USER_ENTERED): a string starting with = becomes a formula, such as \"=SUM(A1:A3)\" or \"=VLOOKUP(B2,Prices!A:B,2,FALSE)\"; other text may be turned into a number or date by the spreadsheet's locale. Use update_values to store text exactly as given. null leaves a cell unchanged; an empty string clears it. Writes at most 50,000 cells per call. The result's status says which range changed and how many cells. A failed write is never retried automatically.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/sheets/update-spreadsheet.ts b/server/src/google-workspace-rest-tools/sheets/update-spreadsheet.ts index b3b6c04a273..50a511e759d 100644 --- a/server/src/google-workspace-rest-tools/sheets/update-spreadsheet.ts +++ b/server/src/google-workspace-rest-tools/sheets/update-spreadsheet.ts @@ -211,6 +211,7 @@ export function updateSpreadsheetResult(input: UpdateSpreadsheetArgs, response: export const updateSpreadsheet = defineTool({ definition: { name: "update_spreadsheet", + title: "Edit a spreadsheet", description: "Applies one or more Sheets API batchUpdate requests to a spreadsheet, in order and all together: if any request is invalid, none is applied. Each request is an object with one operation, such as updateCells, repeatCell, mergeCells, addSheet, updateSheetProperties, addChart, sortRange or findReplace. Some operations remove content: deleteSheet, deleteDimension, deleteRange, deleteDuplicates and deleteTable delete sheets, rows, columns or cells, and cutPaste, findReplace, sortRange and pasteData overwrite cells. It never deletes the spreadsheet itself, changes who it is shared with, or creates a spreadsheet. Comment and data source operations are refused, and so is writeControl. updateCells and appendCells may write at most 50,000 cells per call. The result's status lists each operation and the range it changed. A failed update is never retried automatically.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/sheets/update-values.ts b/server/src/google-workspace-rest-tools/sheets/update-values.ts index 796d93176f0..29f80b1f3fb 100644 --- a/server/src/google-workspace-rest-tools/sheets/update-values.ts +++ b/server/src/google-workspace-rest-tools/sheets/update-values.ts @@ -9,6 +9,7 @@ export type UpdateValuesArgs = z.infer; export const updateValues = defineTool({ definition: { name: "update_values", + title: "Update cell values", description: "Writes values into one range of a spreadsheet as raw values (Sheets valueInputOption RAW): every string is stored exactly as given, so \"=SUM(A1:A3)\" stays text, and \"2026-01-05\", \"1,000\" or \"12%\" stay text rather than becoming a date or a number. Pass numbers and booleans as JSON numbers and booleans. To write formulas, use update_formulas. null leaves a cell unchanged; an empty string clears it. Writes at most 50,000 cells per call. The result's status says which range changed and how many cells. A failed write is never retried automatically.", inputSchema: { type: "object", diff --git a/server/src/google-workspace-rest-tools/slides/read-presentation.ts b/server/src/google-workspace-rest-tools/slides/read-presentation.ts index 39440c387ce..adeac284c30 100644 --- a/server/src/google-workspace-rest-tools/slides/read-presentation.ts +++ b/server/src/google-workspace-rest-tools/slides/read-presentation.ts @@ -44,6 +44,7 @@ export function readPresentationResult(presentation: RestPresentation, input: Re export const readPresentation = defineTool({ definition: { name: "read_presentation", + title: "Read a presentation", description: [ "Reads a Google Slides presentation.", "Without fields, content.text is every slide in order as Markdown-style text: each slide starts with ## Slide N, title placeholders start with ###, bullets keep their glyph, tables use | cells |, links are [text](url), and each slide's speaker notes follow under Speaker notes:.", diff --git a/server/src/google-workspace-rest-tools/slides/update-presentation.ts b/server/src/google-workspace-rest-tools/slides/update-presentation.ts index 8fabcec26ef..81cd7709a23 100644 --- a/server/src/google-workspace-rest-tools/slides/update-presentation.ts +++ b/server/src/google-workspace-rest-tools/slides/update-presentation.ts @@ -36,6 +36,7 @@ export function updatePresentationResult(response: RestBatchUpdateResponse): Cal export const updatePresentation = defineTool({ definition: { name: "update_presentation", + title: "Edit a presentation", description: [ "Edits an existing Google Slides presentation with a list of Slides API batchUpdate requests (for example insertText, deleteText, replaceAllText, createSlide, createShape, createTable, updateTextStyle, duplicateObject or deleteObject), and returns one reply per request.", "Requests are applied in the order given, all or none: if any request is invalid, nothing is changed.", diff --git a/server/src/services/google-workspace-rest-dispatch.test.ts b/server/src/services/google-workspace-rest-dispatch.test.ts index 3d1ced3d858..1052ab144d0 100644 --- a/server/src/services/google-workspace-rest-dispatch.test.ts +++ b/server/src/services/google-workspace-rest-dispatch.test.ts @@ -2,6 +2,7 @@ import { GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceToolNames } from import { describe, expect, it, vi } from "vitest"; import { callGoogleWorkspaceRest, + googleWorkspaceCatalogToolTitle, googleWorkspaceRestTransportGaps, probeGoogleWorkspaceRest, } from "./google-workspace-rest-dispatch.js"; @@ -22,6 +23,35 @@ describe("Google Workspace REST transport eligibility", () => { }); }); +describe("googleWorkspaceCatalogToolTitle", () => { + const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i; + + it("names every allowlisted tool for a person, whichever transport lists it", () => { + for (const service of Object.keys(GOOGLE_WORKSPACE_TOOL_TRANSPORT) as Array) { + for (const leaf of googleWorkspaceServiceToolNames(service)) { + const name = `${service}__${leaf}`; + const title = googleWorkspaceCatalogToolTitle("google-workspace", name, null); + expect(title, name).toMatch(/^[A-Z][A-Za-z ]+: [A-Z][a-z]+( [a-z]+)*$/); + expect(title, name).not.toMatch(UUID); + } + } + }); + + it("uses the Paperclip tool title for services with REST tools, for both transports", () => { + expect(googleWorkspaceCatalogToolTitle("google-workspace", "gmail__get_message", null)).toBe("Gmail: Read a message"); + expect(googleWorkspaceCatalogToolTitle("google-workspace", "gmail__get_message", "Get Message")).toBe("Gmail: Read a message"); + expect(googleWorkspaceCatalogToolTitle("google-workspace", "calendar__list_events", null)).toBe("Calendar: List events"); + expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", "Send a message")).toBe("Chat: Send a message"); + expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", "Chat: Send a message")).toBe("Chat: Send a message"); + expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", null)).toBe("Chat: Send message"); + }); + + it("leaves other connections' titles alone", () => { + expect(googleWorkspaceCatalogToolTitle("github", "gmail__get_message", null)).toBeNull(); + expect(googleWorkspaceCatalogToolTitle(undefined, "create_issue", "Create issue")).toBe("Create issue"); + }); +}); + describe("callGoogleWorkspaceRest", () => { it("sends only the bearer token to Google and passes the gateway's fetch and signal", async () => { const controller = new AbortController(); diff --git a/server/src/services/google-workspace-rest-dispatch.ts b/server/src/services/google-workspace-rest-dispatch.ts index f84bffa2939..535224f969c 100644 --- a/server/src/services/google-workspace-rest-dispatch.ts +++ b/server/src/services/google-workspace-rest-dispatch.ts @@ -2,6 +2,8 @@ import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js"; import { GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceToolNames, + googleWorkspaceToolTarget, + googleWorkspaceToolTitle, type GoogleWorkspaceService, type GoogleWorkspaceToolTransport, } from "@paperclipai/shared"; @@ -41,6 +43,19 @@ export function listGoogleWorkspaceRest(service: GoogleWorkspaceService): Tool[] return listGoogleWorkspaceRestTools(restService(service)); } +export function googleWorkspaceCatalogToolTitle( + sourceTemplateKey: unknown, + name: string, + title: string | null | undefined, +): string | null { + if (sourceTemplateKey !== "google-workspace") return title ?? null; + const target = googleWorkspaceToolTarget(name); + const restTitle = target && isGoogleWorkspaceRestService(target.service) + ? listGoogleWorkspaceRestTools(target.service).find((tool) => tool.name === target.leaf)?.title + : undefined; + return googleWorkspaceToolTitle(name, restTitle ?? title); +} + export async function callGoogleWorkspaceRest( input: GoogleWorkspaceRestContext & { toolName: string; arguments: unknown; maxResultBytes: number }, ): Promise { diff --git a/server/src/services/tool-access.ts b/server/src/services/tool-access.ts index 702156151e1..abf05c53451 100644 --- a/server/src/services/tool-access.ts +++ b/server/src/services/tool-access.ts @@ -151,6 +151,7 @@ import { toolAccessPolicyService } from "./tool-access-policy.js"; import { googleChatToolDescription } from "./google-chat-tool-policy.js"; import { gmailArchiveToolDescription } from "./gmail-archive-tool-policy.js"; +import { googleWorkspaceCatalogToolTitle } from "./google-workspace-rest-dispatch.js"; import { createToolRuntimeSupervisor } from "./tool-runtime-supervisor.js"; @@ -594,6 +595,7 @@ function toCatalogEntryForConnection( const rawCatalogEntry = toCatalogEntry(row); const catalogEntry = { ...rawCatalogEntry, + title: googleWorkspaceCatalogToolTitle(asRecord(connection.config).sourceTemplateKey, row.toolName, rawCatalogEntry.title), inputSchema: projectedConnectionToolInputSchema( connection, rawCatalogEntry.inputSchema ?? {}, diff --git a/server/src/services/tool-access/activity/review-queue.ts b/server/src/services/tool-access/activity/review-queue.ts index 37df9bb6c94..66b9167cac1 100644 --- a/server/src/services/tool-access/activity/review-queue.ts +++ b/server/src/services/tool-access/activity/review-queue.ts @@ -5,6 +5,7 @@ import { toolApplications, toolActionRequests, toolCatalogEntries, toolConnectio import type { ToolActionRequestListItem, ToolActionRequestStatus } from "@paperclipai/shared"; import { readSignedToolArgumentsPayload, TOOL_ACTION_REQUEST_SIGNING_GRACE_MS } from "../../tool-content-guards.js"; import { toToolActionRequest } from "./projection.js"; +import { googleWorkspaceCatalogToolTitle } from "../../google-workspace-rest-dispatch.js"; /** Pending requests stay hidden until signing completes; invalid signatures are cancelled. */ export function createToolActionReviewQueue(db: Db) { return { @@ -185,7 +186,7 @@ listActionRequests: async ( return { request: toToolActionRequest(request), toolName: invocation?.toolName ?? catalogEntry?.toolName ?? "", - toolTitle: catalogEntry?.title ?? null, + toolTitle: googleWorkspaceCatalogToolTitle(connection?.config?.sourceTemplateKey, catalogEntry?.toolName ?? invocation?.toolName ?? "", catalogEntry?.title), connectionId: connection?.id ?? invocation?.connectionId ?? null, connectionName: connection?.name ?? null, applicationName: application?.name ?? null, diff --git a/server/src/services/tool-access/catalog/discovery.ts b/server/src/services/tool-access/catalog/discovery.ts index 4d82efa010b..d026fe3ef25 100644 --- a/server/src/services/tool-access/catalog/discovery.ts +++ b/server/src/services/tool-access/catalog/discovery.ts @@ -9,7 +9,7 @@ import { oauthConfig } from "../oauth/metadata.js"; import { projectedConnectionHeaders } from "../connection-methods.js"; import { nativeProviderCatalogFor } from "../../native-provider-catalogs.js"; import { restConnectorFor } from "../../connectors/rest-registry.js"; -import { listGoogleWorkspaceRest, probeGoogleWorkspaceRest } from "../../google-workspace-rest-dispatch.js"; +import { googleWorkspaceCatalogToolTitle, listGoogleWorkspaceRest, probeGoogleWorkspaceRest } from "../../google-workspace-rest-dispatch.js"; import { GOOGLE_WORKSPACE_SERVICES, GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceGranted, googleWorkspaceToolName, googleWorkspaceGrantedScopes, isGoogleWorkspaceToolGranted, type GoogleWorkspaceService } from "@paperclipai/shared"; import { isInsufficientConnectionScope, INSUFFICIENT_CONNECTION_SCOPE_MESSAGE } from "../../connection-permission-errors.js"; import { mcpDiscoveryHttpFailure, withMcpConnectionFailure } from "../../mcp-connection-failure.js"; @@ -172,7 +172,10 @@ export function createToolCatalogDiscovery(db: Db, { now, audit, secrets, creden const tools = GOOGLE_WORKSPACE_TOOL_TRANSPORT[service] === "paperclip_rest" ? await googleWorkspaceRestTools(connection, service, headers, scopes, actor) : await remoteTools(connection, headers, actor, profile.serverUrl, [], listOptions); - return tools.map((tool) => ({ ...tool, name: googleWorkspaceToolName(service, tool.name) })) + return tools.map((tool) => { + const name = googleWorkspaceToolName(service, tool.name); + return { ...tool, name, title: googleWorkspaceCatalogToolTitle("google-workspace", name, tool.title) }; + }) .filter((tool) => isGoogleWorkspaceToolGranted(tool.name, scopes)); })); for (const [index, catalog] of catalogs.entries()) { diff --git a/server/src/services/tool-gateway.ts b/server/src/services/tool-gateway.ts index 79878e2b922..534062f2c44 100644 --- a/server/src/services/tool-gateway.ts +++ b/server/src/services/tool-gateway.ts @@ -33,7 +33,7 @@ import { connectionManagementService, type ConnectionManagementContext } from ". import { notifyDeliveryWork, DELIVERY_QUEUES } from "./delivery-work-notifications.js"; import { measureToolDiscovery, measureRunPhase, recordConnectionCatalogCounts } from "./execution-preparation-timing.js"; import { nativeProviderCatalogFor } from "./native-provider-catalogs.js"; -import { callGoogleWorkspaceRest, googleWorkspaceRestAuditEndpoint } from "./google-workspace-rest-dispatch.js"; +import { callGoogleWorkspaceRest, googleWorkspaceCatalogToolTitle, googleWorkspaceRestAuditEndpoint } from "./google-workspace-rest-dispatch.js"; import { composeConnectionInstructions } from "./connection-instructions.js"; import { googleWorkspaceToolTarget, googleWorkspaceGrantedScopes, isGoogleWorkspaceToolGranted } from "@paperclipai/shared"; import { isInsufficientConnectionScope, INSUFFICIENT_CONNECTION_SCOPE_MESSAGE } from "./connection-permission-errors.js"; @@ -2051,7 +2051,7 @@ export function createToolGatewayService( }; return { name: gatewayToolName, - displayName: catalogEntry.title ?? catalogEntry.toolName, + displayName: googleWorkspaceCatalogToolTitle(connection.config.sourceTemplateKey, catalogEntry.toolName, catalogEntry.title) ?? catalogEntry.toolName, description: gmailArchiveToolDescription( connection, diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 153f971299d..aefc53d7242 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -267,8 +267,8 @@ "packages/shared/src/github-connectors.ts": "b8448b1eddac9a9d1308b94e4d136c761cbd4a00", "packages/shared/src/github-skill-repository.ts": "b00a9963472723bcb7fcd433aae442f75d7a138b", "packages/shared/src/gitignore-runtime.test.ts": "e334ab0eca8faeab5807171983ec9102a3f1c734", - "packages/shared/src/google-workspace-connectors.test.ts": "07467b028d6c50b80171239b4a4850d4225be5ce", - "packages/shared/src/google-workspace-connectors.ts": "3adffe189f0eaf9cf258dd5193c1e89cb0305208", + "packages/shared/src/google-workspace-connectors.test.ts": "0021bf50e20076e9862b13e97f84e0e5bf5d5b35", + "packages/shared/src/google-workspace-connectors.ts": "270fbd40c0f96e8f4140c880a2c36a3150d4b9aa", "packages/shared/src/grok-bot.ts": "9de68f00e7926c397729ff62bf8e277f5a41c525", "packages/shared/src/heartbeat-inbox.ts": "227dc89705c20460ca02194091cb162e11503186", "packages/shared/src/home-paths.test.ts": "81235c17c376224e1be3abd3f034a8400f079c66", diff --git a/ui/src/pages/apps/ReviewQueueCard.tsx b/ui/src/pages/apps/ReviewQueueCard.tsx index 599777c655f..f31c3de795b 100644 --- a/ui/src/pages/apps/ReviewQueueCard.tsx +++ b/ui/src/pages/apps/ReviewQueueCard.tsx @@ -2,7 +2,7 @@ import { useMemo, useState } from "react"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { Check, Loader2, ShieldQuestion, X } from "lucide-react"; import type { ToolActionRequestListItem } from "@paperclipai/shared"; -import { humanizeConnectionDisplayName } from "@paperclipai/shared"; +import { googleWorkspaceToolTitle, humanizeConnectionDisplayName } from "@paperclipai/shared"; import { useCompany } from "@/context/CompanyContext"; import { useToast } from "@/context/ToastContext"; import { queryKeys } from "@/lib/queryKeys"; @@ -217,7 +217,7 @@ function ReviewRow({ function actionLabel(item: ToolActionRequestListItem): string { if (!item.toolTitle && !item.toolName) return "This action"; - return humanizeConnectionDisplayName(item.toolName ?? "", { title: item.toolTitle }); + return humanizeConnectionDisplayName(item.toolName ?? "", { title: googleWorkspaceToolTitle(item.toolName ?? "", item.toolTitle) }); } function failToast( diff --git a/ui/src/pages/apps/app-detail/ActionTestDialog.tsx b/ui/src/pages/apps/app-detail/ActionTestDialog.tsx index 332becb0604..a7c98e354b6 100644 --- a/ui/src/pages/apps/app-detail/ActionTestDialog.tsx +++ b/ui/src/pages/apps/app-detail/ActionTestDialog.tsx @@ -45,6 +45,7 @@ import { } from "@/components/JsonSchemaForm"; import { cn, relativeTime } from "@/lib/utils"; import { appTabHref } from "../app-tabs"; +import { actionLabel } from "./action-permissions"; import { ANALYTICS_MASK_CLASS } from "@/lib/analytics/privacy"; import { safeExternalHttpUrl } from "@/lib/safe-url"; @@ -129,7 +130,7 @@ export function ActionTestDialog({ )); return tool?.decision ?? "off"; }, [entry.toolName, selectedAgent]); - const title = entry.title ?? entry.toolName; + const title = actionLabel(entry); return ( @@ -1214,7 +1215,7 @@ function AskFirstResult({
Action
-
{entry.title ?? entry.toolName}
+
{actionLabel(entry)}
{where && (
@@ -1271,7 +1272,7 @@ function OffExplanation({ allAgents: ToolConnectionTestAgent[]; onSelectAgent: (agentId: string) => void; }) { - const title = entry.title ?? entry.toolName; + const title = actionLabel(entry); const permHref = `${appTabHref(connectionId, "permissions")}?focus=${encodeURIComponent(entry.id)}`; // Other agents are intentionally not summarized up front. Selecting one diff --git a/ui/src/pages/apps/app-detail/AgentConnectionAccess.tsx b/ui/src/pages/apps/app-detail/AgentConnectionAccess.tsx index a65eacde535..a48ae7f7968 100644 --- a/ui/src/pages/apps/app-detail/AgentConnectionAccess.tsx +++ b/ui/src/pages/apps/app-detail/AgentConnectionAccess.tsx @@ -3,6 +3,7 @@ import type { Agent, ToolCatalogEntry, ToolPolicy, ToolProfileConfiguration } fr import { AgentAvatar } from "@/components/AgentAvatar"; import { Button } from "@/components/ui/button"; import { describeError } from "@/api/errors"; +import { actionLabel } from "./action-permissions"; export function AgentConnectionAccess({ connectionId, profiles, policies, catalog, agents, canManage, onRemove }: { connectionId: string; @@ -83,7 +84,7 @@ export function AgentConnectionAccess({ connectionId, profiles, policies, catalo {tools.map(tool => { const askFirst = approvalKeys.has(`${agentId}:${tool.id}`); return
  • - {tool.title || tool.toolName} + {actionLabel(tool)} {askFirst ? "Ask first" : "Allowed"}
  • ; })} diff --git a/ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx b/ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx new file mode 100644 index 00000000000..fff8cdc8029 --- /dev/null +++ b/ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx @@ -0,0 +1,142 @@ +// @vitest-environment jsdom + +import { act } from "react"; +import { createRoot, type Root } from "react-dom/client"; +import { MemoryRouter } from "react-router-dom"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import type { ToolActionRequestListItem, ToolCatalogEntry } from "@paperclipai/shared"; +import { ActionsSection } from "./PermissionsPanel"; +import { ReviewPanel } from "./ReviewPanel"; + +const listActionRequestsMock = vi.hoisted(() => vi.fn()); + +vi.mock("@/api/tools", () => ({ + toolsApi: { listActionRequests: (...args: unknown[]) => listActionRequestsMock(...args) }, +})); + +vi.mock("@/api/issues", () => ({ + issuesApi: { listInteractions: vi.fn().mockResolvedValue([]) }, +})); + +vi.mock("@/context/CompanyContext", () => ({ + useCompany: () => ({ selectedCompanyId: COMPANY_ID, selectedCompany: { id: COMPANY_ID, issuePrefix: "PAP" } }), +})); + +vi.mock("@/context/ToastContext", () => ({ + useToast: () => ({ pushToast: vi.fn() }), +})); + +(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; + +const COMPANY_ID = "8b395da5-5593-58fb-8d9d-e2726a827b53"; +const CONNECTION_ID = "3f1c2a8e-7b4d-4e0a-9c55-1d2e3f4a5b6c"; +const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i; +const SERVICE_TOOL = /\b[a-z]+__[a-z_]+\b/; + +function googleEntry(id: string, toolName: string, riskLevel: string): ToolCatalogEntry { + return { id, toolName, title: null, description: null, riskLevel, status: "active" } as unknown as ToolCatalogEntry; +} + +function googleRequest(): ToolActionRequestListItem { + return { + request: { + id: "6a0e1d7c-3b2f-4a19-8e55-0c4d2b1a9f80", + companyId: COMPANY_ID, + invocationId: "0e9b7c6d-5a4f-4321-8bcd-ef0123456789", + issueId: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", + interactionId: null, + approvalId: null, + status: "pending", + previewMarkdown: null, + requestedByAgentId: "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e", + createdAt: new Date(Date.now() - 5 * 60_000), + updatedAt: new Date(Date.now() - 5 * 60_000), + }, + toolName: "calendar__create_event", + toolTitle: null, + connectionId: CONNECTION_ID, + connectionName: "Google Workspace", + applicationName: "Google Workspace", + riskLevel: "write", + requestedByAgentId: "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e", + } as unknown as ToolActionRequestListItem; +} + +let container: HTMLDivElement | null = null; +let root: Root | null = null; + +async function settle() { + await act(async () => { + for (let index = 0; index < 4; index += 1) { + await new Promise((resolve) => window.setTimeout(resolve, 0)); + } + }); +} + +function mount(node: React.ReactNode) { + container = document.createElement("div"); + document.body.appendChild(container); + root = createRoot(container); + const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + act(() => root!.render( + + {node} + , + )); + return container; +} + +afterEach(() => { + act(() => root?.unmount()); + container?.remove(); + container = null; + root = null; + vi.clearAllMocks(); +}); + +describe("Google Workspace action labels", () => { + it("shows readable action names and no raw IDs on the Review tab", async () => { + listActionRequestsMock.mockResolvedValue({ actionRequests: [googleRequest()] }); + const view = mount( + , + ); + await settle(); + + const text = view.textContent ?? ""; + expect(text).toContain("Gmail: Get message"); + expect(text).toContain("Calendar: Create event"); + expect(text).not.toMatch(SERVICE_TOOL); + expect(text).not.toMatch(UUID); + }); + + it("shows readable action names on the Permissions action list", () => { + const view = mount( + , + ); + + const text = view.textContent ?? ""; + expect(text).toContain("Calendar: List events"); + expect(text).toContain("Gmail: Create draft"); + expect(text).not.toMatch(SERVICE_TOOL); + expect(text).not.toMatch(UUID); + }); +}); diff --git a/ui/src/pages/apps/app-detail/PermissionsPanel.tsx b/ui/src/pages/apps/app-detail/PermissionsPanel.tsx index 96056d2d2bd..37068158453 100644 --- a/ui/src/pages/apps/app-detail/PermissionsPanel.tsx +++ b/ui/src/pages/apps/app-detail/PermissionsPanel.tsx @@ -15,6 +15,7 @@ import { QuarantinedActionsReview } from "./SetupPanel"; import { ActionTestDialog } from "./ActionTestDialog"; import { ACTION_PAGE_SIZE } from "./constants"; import { ProviderToolIcon } from "@/components/ProviderToolIcon"; +import { actionLabel } from "./action-permissions"; /** Action rows without a provider icon show none, as before. */ function NoIcon() { @@ -373,11 +374,11 @@ function FilterChip({ label, active, onClick }: { label: string; active: boolean function byName(a: ToolCatalogEntry, b: ToolCatalogEntry) { - return (a.title ?? a.toolName).localeCompare(b.title ?? b.toolName); + return actionLabel(a).localeCompare(actionLabel(b)); } function matchesAction(entry: ToolCatalogEntry, needle: string) { - return !needle || (entry.title ?? entry.toolName).toLowerCase().includes(needle) + return !needle || actionLabel(entry).toLowerCase().includes(needle) || (entry.description ?? "").toLowerCase().includes(needle); } @@ -503,7 +504,7 @@ const ActionRow = memo(function ActionRow({ }) { const rowRef = useRef(null); const [testOpen, setTestOpen] = useState(false); - const title = action.title ?? action.toolName; + const title = actionLabel(action); useEffect(() => { if (focused) rowRef.current?.scrollIntoView({ behavior: "smooth", block: "center" }); diff --git a/ui/src/pages/apps/app-detail/SetupPanel.tsx b/ui/src/pages/apps/app-detail/SetupPanel.tsx index 174966197dc..f57b2a770d0 100644 --- a/ui/src/pages/apps/app-detail/SetupPanel.tsx +++ b/ui/src/pages/apps/app-detail/SetupPanel.tsx @@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { ToggleSwitch } from "@/components/ui/toggle-switch"; import { ACTION_PAGE_SIZE } from "./constants"; +import { actionLabel } from "./action-permissions"; import { appDefinitionSlug } from "../app-definition-display"; import type { AppDetailSectionProps } from "./types"; import { googleSheetsConfigWithAllowlist, parseGoogleSheetIds } from "../google-sheets"; @@ -291,7 +292,7 @@ export function QuarantinedActionsReview({
    {entries.slice(0, visibleLimit).map((entry) => { const enabled = enabledIds.has(entry.id); - const label = entry.title ?? entry.toolName; + const label = actionLabel(entry); return (
    diff --git a/ui/src/pages/apps/app-detail/action-permissions.ts b/ui/src/pages/apps/app-detail/action-permissions.ts index b4f01cf3587..f18bf4ecd7b 100644 --- a/ui/src/pages/apps/app-detail/action-permissions.ts +++ b/ui/src/pages/apps/app-detail/action-permissions.ts @@ -1,3 +1,5 @@ +import { googleWorkspaceToolTitle } from "@paperclipai/shared"; + /** * Apply one permission to a set of actions in a single change. * @@ -25,3 +27,7 @@ export function actionPermissionMutation( } return { enabled, askFirst }; } + +export function actionLabel(entry: { toolName: string; title?: string | null }): string { + return googleWorkspaceToolTitle(entry.toolName, entry.title) ?? entry.toolName; +}