Repository navigation
feat(uploads): send workspace files to Drive/Gmail outside model context, storage-free (revives #3354) - #3458
Conversation
…ext, storage-free Revives #3354 by @reachjalil onto current dev. - apps/server: new openwork-cloud-uploads extension (drive_upload_file, gmail_create_draft_with_attachments) — authorized workspace paths in, multipart FormData out to Den; 4 MiB total enforced before network I/O; realpath containment incl. symlink escapes. - den-api: POST /v1/direct-uploads/google-workspace/{drive-files,gmail-drafts} behind new cloudTransportRoute() (MCP bearer + mcp:write + org membership); bytes forward straight to Google, never persisted. - Removes the model-facing base64 lanes: gmail-draft attachments field and the drive-files base64 upload capability. Gmail draft logic extracted into executeGmailDraft, shared by the JSON capability and the multipart route, preserving dev behavior (#3441 binary read lanes and #3449 formatting kept). - Legacy flow deleted per the frozen corpus; successor proof is evals/specs/google-workspace-direct-uploads.slow.test.ts (real Den boot, mock-Google byte-exact witness, pre-network 413, no bytes in results). - evals/tsconfig.json stops typechecking the frozen flow corpus, fixing the pre-existing red evals:typecheck (FlowContext.page in den-trim-page-headers). Co-authored-by: Jalil <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Photo roll — workspace-paths-upload-directly-to-google-without-model-visible-bytes — 0/0 frames passed · 4 facts✅ 0/0 frames passed · 4 facts · 4 expectations passed · 0 failed ℹ️ FACT — 1. Cloud upload inputs expose paths, not bytesBoth registered extension schemas contain only path and message metadata fields; the Den Gmail JSON schema has no attachments field.
ℹ️ FACT — 2. Drive receives the exact authorized workspace fileMock Drive observed witness.png as image/png with 89504e470d0a1a0a00ff8013 bytes.
ℹ️ FACT — 3. Gmail receives exact attachment bytes while the action returns metadata onlyMock Gmail observed witness.png/image/png/12; result fields were ok, draftId, messageId, draftUrl, threadUrl, to, subject, threadId, quotedHistoryIncluded, attachments, filename, mimeType, size.
ℹ️ FACT — 4. Oversize aggregate input is rejected before network I/OThe extension fetch call count was 0.
Roll created 2026-08-03T12:17:43.138Z · Source: |
There was a problem hiding this comment.
Warden security clearance: clear. No new security issues found in this diff (1172de72c8a9718e1ad6ab86873b609ee9f7ed47). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
What this is
A revival of #3354 by @reachjalil, rebased onto current dev. All design decisions are his (see also #3353, which he closed in favor of this storage-free scope); this PR ports the work across #3441 and migrates the proof to the frozen-corpus-compliant testkit path.
Problem
Attaching a workspace file through the cloud Gmail/Drive capabilities required the model to emit the file as inline base64 tool arguments. That is physically capped by model output budgets (~tens of KB), corrupts or truncates larger files, and the advertised 10 MiB limit was impossible in practice — agents silently degraded files trying to fit (observed live: a 117 KB PDF failed; a video only made it after being crushed to 13 KB).
What changed
openwork-cloud-uploadsextension:drive_upload_fileandgmail_create_draft_with_attachmentstake authorized workspace paths, read bytes locally (realpath containment, symlink-escape rejection), and POST multipart FormData to Den. 4 MiB total enforced before any network I/O with an honest 413.POST /v1/direct-uploads/google-workspace/{drive-files,gmail-drafts}behind newcloudTransportRoute()middleware (MCP bearer,mcp:writescope, org-membership resolution). Bytes forward straight to Google (Drive multipart / Gmail drafts.create) and are never persisted.attachmentsfield and thePOST /v1/capabilities/google-workspace/drive-filesbase64 capability are gone. File bytes no longer enter tool JSON or model context at all.executeGmailDraft(...), shared by the JSON capability (no attachments) and the multipart route — dev behavior preserved exactly, including feat(den-api): binary-safe capability content + MCP image delivery lanes #3441's binary read lanes, fix(den-api): preserve Gmail draft formatting #3449's formatting, and multi-accountexternalAccountIdURLs.Port notes (delta vs #3354 as authored)
google-workspace.ts+ capabilities test: all feat(den-api): binary-safe capability content + MCP image delivery lanes #3441 dual-lane read behavior kept intact.evals/flows/google-workspace-gmail-draft-attachments.flow.mjsis deleted, not edited — the legacy flow corpus is frozen (deletions only), and its witnesses asserted the removed base64 contract. Successor proof:evals/specs/google-workspace-direct-uploads.slow.test.ts— cold-boots a real Den, real OAuth connect against a mock Google, drives the production extension code, and asserts byte-for-byte attachment fidelity, metadata-only model-visible results, and pre-network oversize rejection (fetch-call counter = 0).evals/tsconfig.jsonstops typechecking the frozen flow corpus. Disclosure:pnpm evals:typecheckis red on dev today (pre-existingFlowContext.pageerrors inden-trim-page-headers.flow.ts); this change fixes it and matches the corpus freeze.packages/docs/openapi.jsonintentionally untouched (generated snapshot; not regenerated by CI), same call as the original PR.route-access-policy.test.ts:fileURLToPathfix so the suite works from checkouts with spaces in the path.Tests run
pnpm --filter openwork-server exec tsc --noEmitpnpm --filter @openwork-ee/den-api exec tsc --noEmitpnpm evals:typecheckpnpm --filter openwork-server exec bun test src/extensions/cloud-uploads.test.ts src/extensions-connect-gating.test.tsbun test --conditions=development test/google-workspace-capabilities.test.ts test/route-access-policy.test.ts(den-api)bun test --conditions=development test/google-workspace-api.test.ts test/gmail-draft.test.ts test/mcp-tool-content.test.ts(den-api)pnpm --dir evals exec vitest run --config vitest.config.ts --project stack specs/google-workspace-direct-uploads.slow.test.tsEvidence tape from the spec run will be published as the sticky PR comment.
Supersedes #3354 (unmergeable after #3441; branch preserved). Credit: @reachjalil.