AppsScriptPulse

Securing Local Execution: From the Workspace CLI to Sandboxed Emulation with the `gas-fakes` Agent

gf_agent is an interactive automation agent for Gemini CLI that enables users to access and manupulate workspace resources conversationally.

The automation of Google Workspace is advancing rapidly. We are moving away from static scripts and rigid cloud triggers towards environments where AI agents autonomously orchestrate complex tasks. Recently, I shared a recipe exploring how we could use the Workspace CLI to call the Apps Script Execution API. I was quite pleased with it, however, a recent email exchange with Bruce Mcpherson quickly highlighted a much more efficient path.

Bruce pointed out that his new gf_agent for the Gemini CLI bypasses the need to write these intermediary scripts entirely. By using his gas-fakes emulation environment, the agent accepts plain English requests, generates the required Apps Script logic dynamically, and executes it securely on your local machine. It is a brilliant piece of work. You simply ask the agent to summarise your latest emails or resize images in a document, and it handles the heavy lifting without using the Apps Script runtime.

To illustrate this capability, Bruce shared an excerpt from a recent run demonstrating a complete web to document flow, similar to the Workspace CLI / Apps Script Execution API example. The log captures the moment the system activates the local skill, maps the available resources, and then executes the required logic directly from the terminal:

✦ I will activate the gf_agent skill to access specialized guidance for Google Workspace automation.

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓  Activate Skill "gf_agent": Specialized agent for automating Google Workspace tasks locally using gas-fakes. Gener… │
│                                                                                                                       │
│ Skill gf_agent activated. Resources loaded from /Users/brucemcpherson/.gemini/skills/gf_agent:                        │
│                                                                                                                       │
│ Showing up to 200 items (files + folders).                                                                            │
│                                                                                                                       │
│ /Users/brucemcpherson/.gemini/skills/gf_agent/                                                                        │
│ ├───documentation.md                                                                                                  │
│ ├───index.md                                                                                                          │
│ ├───README.md                                                                                                         │
│ ├───SKILL.md                                                                                                          │
│ ├───scripts/                                                                                                          │
│ │   └───builder.js                                                                                                    │
│ └───skills/                                                                                                           │
│     ├───base.md                                                                                                       │
│     ├───cache.md                                                                                                      │
│     ├───calendar.md                                                                                                   │
│     ├───charts.md                                                                                                     │
│     ├───document.md                                                                                                   │
│     ├───drive.md                                                                                                      │
│     ├───forms.md                                                                                                      │
│     ├───gmail.md                                                                                                      │
│     ├───jdbc.md                                                                                                       │
│     ├───lock.md                                                                                                       │
│     ├───properties.md                                                                                                 │
│     ├───script.md                                                                                                     │
│     ├───slides.md                                                                                                     │
│     ├───spreadsheet.md                                                                                                │
│     ├───urlfetch.md                                                                                                   │
│     ├───utilities.md                                                                                                  │
│     └───xml.md                                                                                                        │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

✦ I will use the workspace_agent to fetch the content from the URL, create a Google Document from the HTML, copy it, and then
  resize the images in the copy using the recommended Docs API workaround, as setWidth/setHeight are not supported in the
  local environment.

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓  workspace_agent (gas-fakes-mcp MCP Server) {"script":"\nconst url = 'https://ramblings.mcpher.com/resurrecting-sc… │
│                                                                                                                       │
│ 2026-04-24T11:49:08.017Z ...using env file in                                                                         │
│ /Users/brucemcpherson/Documents/repos/empty/recipe-web-to-doc-gf/scripts/.env                                         │
│ 2026-04-24T11:49:08.763Z ...gas-fakes version 2.3.9                                                                   │
│ 2026-04-24T11:49:08.763Z Fetching content from:                                                                       │
│ https://ramblings.mcpher.com/resurrecting-scriptdb-nosql-database-for-apps-script/                                    │
│ 2026-04-24T11:49:09.451Z [Worker] ...authorized backends: google via DWD ([email protected])                           │
│ 2026-04-24T11:49:09.451Z [Worker] ...using scriptId: ab9c5881-...-2bc29a0c8834 (source: env)                          │
│ 2026-04-24T11:49:14.788Z Created original document with ID: 1sQ7oGqKm9XOQzsYQF10fM6uiAoD2_OSJ6uAJgunPnbE              │
│ 2026-04-24T11:49:17.980Z Created copy document with ID: 1Labz...ZSSo                                                  │
│ 2026-04-24T11:49:19.052Z Found 12 images in the document.                                                             │
│ 2026-04-24T11:49:19.053Z Applying 24 updates to resize images...                                                      │
│ 2026-04-24T11:49:21.557Z Image resizing complete.                                                                     │
│ 2026-04-24T11:49:21.557Z Original Doc URL:                                                                            │
│ https://docs.google.com/document/d/1sQ7...PnbE/edit                                                                   │
│ 2026-04-24T11:49:21.558Z Resized Doc URL:                                                                             │
│ https://docs.google.com/document/d/1Labz...ZSSo/edit                                                                  │
│ 2026-04-24T11:49:21.563Z ...terminating worker thread                                                                 │
│                                                                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

✦ I have successfully fetched the content from the specified URL and created the requested documents.

Weighing the Approaches: Broad CLI vs Sandboxed Emulation

Let us consider the practical realities of these two approaches. The Workspace CLI generally operates under the broad OAuth scopes granted during its initial setup. If you authorise full Google Drive access, any AI agent driving that CLI inherently possesses the same unrestricted permissions. Handing an autonomous reasoning engine the keys to your entire file system is risky. A simple mis-prompt could lead to data loss or unintended modifications.

Conversely, Bruce’s gas-fakes approach offers a much tighter, sandboxed environment. Rather than relying on global credentials, gas-fakes can be explicitly configured to operate only on specific Drive files or within isolated boundaries. By functioning as a Model Context Protocol (MCP) server, it allows the LLM to write native Apps Script syntax and immediately test it against Workspace resources, but it forces the execution to happen within a securely fenced area. The primary benefit here is safe, dynamic adaptability. You do not need to pre-write a specific skill to resize an image; the agent simply authors the script on the fly and the emulator runs it safely.

It is worth mentioning that gas-fakes is still in development so not all Apps Script methods are implemented yet, but the approach provides a robust sandbox for interacting with Workspace APIs. Click through to Bruce’s post to read more.

Source: gas-fakes agent: local natural language requests against workspace resources – Desktop liberation

Leave a Reply

Your email address will not be published. Required fields are marked *