cloudflare / cloudflare/cloudflare-os

Proposal: Add Google Drive Folder support to gatekeeper-google

Open
#156 0 comments 0 reactions 1 assignee Claimed by @ndisidore View on GitHub
Dominant language
TypeScript
Stars
9.9k
Forks
1.2k
Avg merge
1d 20h
Merged PRs (30d)
107

Description

Hi everyone,

First of all, congratulations on Cloudflare OS v2! The architecture built on top of Durable Objects, Dynamic Workers, and Cap'n Web RPC is incredibly elegant and a joy to study.

### The Problem / Motivation
Currently, the `gatekeeper-google` worker is highly focused on granular single-document access (e.g. `GOOGLE_DOC_RESOURCE`). While this is perfect for strict least-privilege security, it introduces a friction point for teams that manage dynamic sets of files.

For instance, in our company, meeting transcriptions, marketing copies, and team logs are continually added to a shared Google Drive folder. Requiring users (or agents) to manually search and connect every new document individually is tedious and breaks automation flows.

### Proposed Solution
To bridge this gap while preserving the system's strong capability-based security, I have implemented and locally verified a **Google Drive Folder** resource. It allows teams to connect a specific folder (via `https://drive.google.com/drive/folders/:folderId`) and gives agents read-only access to files inside it.

I designed the API in `drive-folder-types.d.ts` following the exact conventions of the repository:

```typescript
export type DriveFolderMetadata = {
title: string;
};

export type DriveFileSummary = {
id: string;
name: string;
mimeType: string;
lastModified: Date;
};

export interface GoogleDriveFolderSession {
getMetadata(): Promise;
listFiles(): Promise;
getFileContent(fileId: string): Promise;
}
```

### Technical Highlights of our Implementation:
1. **Strict Scope Verification (No Leakage):** In the session implementation (`getFileContent`), we fetch the file's metadata first and explicitly verify that the file's parents array includes the connected `folderId`. This prevents any malicious prompt-injection or agent bypass from reading documents outside the configured folder.
2. **Automatic Markdown Conversion:** If a file inside the folder is a native Google Doc (`application/vnd.google-apps.document`), it automatically routes through the existing `GoogleDocsApi` and `docToMarkdown` converter, delivering clean Markdown. For plain text files, it falls back to a raw `alt=media` fetch.
3. **Sharing Security (Strategy B Observer):** We implemented `hasDriveFolderAccess` in `GoogleVerifier` and `GoogleVerifierApi`, ensuring that when a Gadget is shared, collaborators are properly checked for access against the Google Drive API before observing the folder data.
4. **Clean Monorepo Integration:** It includes a TSX-based configurator UI (`google-drive-folder-configurator-ui.tsx` via `@gadgets/configurator-ui`) and is registered under Durable Object migration `v4`.

The entire implementation compiles and type-checks successfully across the workspace with zero errors (`pnpm lint` and `pnpm types:check` pass cleanly).

### Next Steps
Since we understand the repository holds a very high bar for code changes and PR reviews, I wanted to submit this idea first.

If this feature aligns with your roadmap, I would be more than happy to open a clean, beautifully formatted Pull Request with these changes. Let me know your thoughts!

Best regards,
Kelvin Rosa

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.