Skip to content

Upload cloud files outside model context without storage - #3354

Closed
reachjalil wants to merge 4 commits into
different-ai:devfrom
reachjalil:codex/direct-google-drive-upload
Closed

reachjalil wants to merge 4 commits into
different-ai:devfrom
reachjalil:codex/direct-google-drive-upload

Conversation

@reachjalil

@reachjalil reachjalil commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces model-facing base64 uploads with one storage-free multipart carrier.

  • Adds local openwork-cloud-uploads actions that accept authorized workspace paths.
  • Uses the same direct carrier for Google Drive uploads and Gmail draft attachments.
  • Sends bytes from OpenWork server to Den as multipart, then immediately to Google.
  • Removes the JSON/base64 Drive upload capability.
  • Removes inline attachment bytes from the Gmail draft JSON capability.
  • Preserves source bytes, basename, and MIME type without Office conversion.
  • Enforces a truthful 4 MiB request ceiling before network I/O.
  • Rejects workspace symlinks that resolve outside authorized roots.

Why

Inline base64 expands files, consumes model context, and can be truncated before Google receives the complete file. The previous advertised 10 MiB raw limit also exceeded the current hosted proxy boundary after encoding.

The model now supplies only an authorized workspace path plus normal operation arguments. File bytes never enter tool JSON or model context.

Deliberate scope

This PR has no database migration, file-reference table, persistent staging, resumable-upload lifecycle, or convertTo behavior. Bytes exist only for the immediate provider operation and are discarded afterward.

The shared carrier can be adopted by future upload capabilities. This first PR migrates the existing Google upload surfaces: Drive file creation and Gmail draft attachments. Gmail attachment downloads are unchanged.

packages/docs/openapi.json is a generated, minified snapshot of roughly 500 KB on one line, so any semantic edit renders as replacement of the whole file in GitHub. It is intentionally restored to dev in this PR; the route source and focused contract tests carry the change.

Verification

Cleanup head: 566d2a3bccb24b95dc706906999fdc2649b7d625, based on dev@d8b869ec07a044ef35841da54526c3d17f52a2bd.

  • pnpm --filter openwork-server exec bun test src/extensions/cloud-uploads.test.ts src/extensions-connect-gating.test.ts — 9 passed, 62 expectations.
  • pnpm --filter openwork-server exec tsc --noEmit — passed.
  • pnpm --filter @openwork-ee/den-api exec tsc --noEmit — passed.
  • Pure Den Google Workspace API and route-access checks — 16 passed.
  • Exact-head GitHub Actions — Linux and macOS OpenWork tests, i18n, Helm validation, and all EE artifact builds passed.
  • node evals/runner/run.mjs --mode automation --flow google-workspace-gmail-draft-attachments — passed with Fraimz proof on the original feature head.
  • git diff --check — passed.

The database-backed Den Google Workspace suite was not rerun locally after rebase because the isolated checkout had no MySQL service on 127.0.0.1:3306. Four Vercel project checks remain red because the fork author is not authorized for those team deployments; the landing deployment passed.

Replacement

Supersedes closed #3353 with the requested storage-free scope. #3353's branch remains preserved for reference.

@reachjalil

Copy link
Copy Markdown
Member Author

fraimz — ❌ FAILED

0 passed · 1 failed · 0 skipped — run 2026-07-30T14-21-19-305Z

Full frame proof with validated screenshots: evals/results/2026-07-30T14-21-19-305Z/fraimz.html (re-run: pnpm fraimz --flow google-workspace-gmail-draft-attachments)

❌ google-workspace-gmail-draft-attachments — Google Workspace uploads carry workspace bytes outside model context without storage

Internal demo

  1. Drive and Gmail attachment actions accept authorized workspace paths and expose no upload base64 field

    🎙 I ask OpenWork to create a Google draft and attach a file from my active workspace.

    • ✅ Drive exposes a workspace-path upload action
    • ✅ Gmail attachments reuse the direct upload transport
    • ✅ The local upload action contains no inline byte field
    • ✅ Den no longer advertises the legacy Drive JSON upload schema
  2. OpenWork posts multipart files directly to Den and Den immediately calls Google without persisting them

    🎙 OpenWork finds the requested file and shows that it will be included with the draft, preserving its filename and file type.

    • ✅ The server creates multipart file parts from workspace bytes
    • ✅ Den exposes a non-capability direct Drive upload route
    • ✅ Den exposes a non-capability direct Gmail attachment route
    • ✅ The upload path has no file-reference storage
  3. Focused server and Den tests preserve Office bytes, filenames, MIME types, and Gmail attachment contents

    🎙 OpenWork creates the message as a Gmail draft—it does not send the email—and confirms the recipient, subject, and attachment.

    • ✅ The focused storage-free upload suites pass
    • ✅ The local boundary verifies Office filename, MIME type, and bytes
    • ✅ The Gmail boundary verifies exact bytes without upload base64
    • ✅ The Drive boundary verifies exact multipart bytes
    • ✅ Script frame 1 narrated: "I ask OpenWork to create a Google draft and attach a file from my active workspace."
    • ✅ Script frame 2 narrated: "OpenWork finds the requested file and shows that it will be included with the draft, pre"
    • ✅ Script frame 3 narrated: "OpenWork creates the message as a Gmail draft—it does not send the email—and confirms th"
    • ❌ Script frame 4 narrated: "In Gmail, I open the draft and see the workspace file attached and ready to review or se"
    • ❌ Script frame 5 narrated: "The same attachment flow also works when creating a reply draft in an existing Gmail thr"
    • ❌ Voice-over script coverage — Narration drifted from evals/voiceovers/google-workspace-gmail-draft-attachments.md (2 missing, 0 unapproved).

@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview Jul 31, 2026 12:35pm
openwork-den Ready Ready Preview Jul 31, 2026 12:35pm
openwork-den-worker-proxy Ready Ready Preview Jul 31, 2026 12:35pm
openwork-diagnostics Ready Ready Preview Jul 31, 2026 12:35pm
openwork-landing Ready Ready Preview, v0 Jul 31, 2026 12:35pm

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

@reachjalil

Copy link
Copy Markdown
Member Author

fraimz — ✅ PASSED

1 passed · 0 failed · 0 skipped — run 2026-07-30T14-21-50-454Z

Full frame proof with validated screenshots: evals/results/2026-07-30T14-21-50-454Z/fraimz.html (re-run: pnpm fraimz --flow google-workspace-gmail-draft-attachments)

✅ google-workspace-gmail-draft-attachments — Google Workspace uploads carry workspace bytes outside model context without storage

Internal demo

  1. Drive and Gmail attachment actions accept authorized workspace paths and expose no upload base64 field

    🎙 I give OpenWork a workspace file path for a Drive upload or Gmail draft attachment; the model never has to encode or carry the file bytes.

    • ✅ Drive exposes a workspace-path upload action
    • ✅ Gmail attachments reuse the direct upload transport
    • ✅ The local upload action contains no inline byte field
    • ✅ Den no longer advertises the legacy Drive JSON upload schema
  2. OpenWork posts multipart files directly to Den and Den immediately calls Google without persisting them

    🎙 OpenWork sends the file directly through an authenticated multipart request and immediately performs the Google operation without staging or storing a copy.

    • ✅ The server creates multipart file parts from workspace bytes
    • ✅ Den exposes a non-capability direct Drive upload route
    • ✅ Den exposes a non-capability direct Gmail attachment route
    • ✅ The upload path has no file-reference storage
  3. Focused server and Den tests preserve Office bytes, filenames, MIME types, and Gmail attachment contents

    🎙 The uploaded Drive file or Gmail attachment preserves the workspace bytes, filename, and MIME type, including Office formats, and OpenWork returns the provider result for review.

    • ✅ The focused storage-free upload suites pass
    • ✅ The local boundary verifies Office filename, MIME type, and bytes
    • ✅ The Gmail boundary verifies exact bytes without upload base64
    • ✅ The Drive boundary verifies exact multipart bytes
    • ✅ Script frame 1 narrated: "I give OpenWork a workspace file path for a Drive upload or Gmail draft attachment; the "
    • ✅ Script frame 2 narrated: "OpenWork sends the file directly through an authenticated multipart request and immediat"
    • ✅ Script frame 3 narrated: "The uploaded Drive file or Gmail attachment preserves the workspace bytes, filename, and"

benjaminshafii
benjaminshafii previously approved these changes Jul 30, 2026

@benjaminshafii benjaminshafii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjaminshafii benjaminshafii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

@reachjalil

Copy link
Copy Markdown
Member Author

Upload cloud files outside model context without storage

What does this do?

It uploads workspace files directly to Drive or Gmail—without stuffing the bytes into model context or storing them in Den.

@benjaminshafii

Copy link
Copy Markdown
Member

Superseded by #3458, which carries this work forward onto current dev (with co-authorship): #3441 rewrote the same regions of google-workspace.ts making this branch unmergeable, and the legacy flow corpus froze under the proof. The successor keeps the design exactly as authored here — storage-free multipart carrier, path-based extension actions, base64 lanes removed — resolves the conflicts, and replaces the flow with an @openwork/testkit spec (real Den boot, byte-exact mock-Google witness). Branch left untouched for reference.

benjaminshafii pushed a commit that referenced this pull request Aug 3, 2026
…ext, storage-free (#3458)

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]>
@reachjalil

Copy link
Copy Markdown
Member Author

Superseded by merged #3458, which carries forward the storage-free multipart upload design and its real Den/mock-provider journey. This follows the replacement already identified in review. The original branch remains preserved.

@reachjalil reachjalil closed this Sep 5, 2026
auto-merge was automatically disabled September 5, 2026 00:28

Pull request was closed

This branch was successfully deployed

5 active deployments
Preview – openwork-den-worker-proxy — 566d2a3b Deployed Jul 31, 2026 by vercel[bot]
Preview – openwork-den — 566d2a3b Deployed Jul 31, 2026 by vercel[bot]
Preview – openwork-diagnostics — 566d2a3b Deployed Jul 31, 2026 by vercel[bot]
Preview – openwork-app — 566d2a3b Deployed Jul 31, 2026 by vercel[bot]
Preview – openwork-landing — 566d2a3b Deployed Jul 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants