square-activity-46232
03/12/2026, 8:46 PMtall-airline-16756
03/12/2026, 8:46 PMtall-airline-16756
03/12/2026, 8:47 PMsquare-activity-46232
03/12/2026, 8:48 PMtall-airline-16756
03/12/2026, 8:48 PMsquare-activity-46232
03/12/2026, 8:51 PMtall-airline-16756
03/12/2026, 8:51 PMGET /mail/inbox, POST /mail/send).
◦ The service internally runs the Google CLI or API calls and performs input validation, command whitelisting, rate limiting, and logging.
◦ The LiveKit agent calls that service with authenticated requests. This restricts actions to only what you’ve allowed.
• Use a job-runner / worker architecture
◦ Agent enqueues tasks (with required parameters) into a queue. A worker with limited permissions consumes tasks and runs the required CLI/API commands inside an isolated environment (container) and returns results. This supports auditing and retries.
• Use delegated OAuth for user-level access
◦ For per-user mailbox actions, implement standard OAuth consent so users authorize the agent. Tokens should be stored securely (short-lived refresh tokens in a secret store).
• Least-privilege and isolation
◦ Run the execution component as a non-root user in a container or dedicated VM.
◦ Limit filesystem and network access with container runtime settings and network policies.
◦ Whitelist allowed commands and parameters rather than executing arbitrary strings.
• Strong auditing and approval controls
◦ Log every command invocation, inputs, outputs, and which user triggered it.
◦ Consider requiring human approval for sensitive operations (e.g., deleting mail, sending as another user).
• Secrets & credential handling
◦ Use a secrets manager. Never store credentials in plaintext with the agent code or in logs.
◦ Prefer short-lived service account tokens and rotate them regularly.
Concrete minimal architecture (example)
1. LiveKit agent determines the user intent (e.g., “send an email”).
2. Agent calls your secured wrapper API: POST /agent/send-email with structured parameters (recipient, subject, body).
3. Wrapper service validates input, checks permissions for that user, and either:
◦ Calls Gmail API directly using OAuth-scoped token, or
◦ Executes the Google Workspace CLI inside a sandboxed container and returns the result.
1. Wrapper logs the action and response and returns a structured result to the agent/user.
When a raw shell is reasonable
• For complex, one-off administrative tasks where no API exists, a tightly controlled operator-run shell may be used. But in that case:
◦ Require human-in-the-loop approval.
◦ Restrict the commands via a wrapper and log everything.
◦ Prefer ephemeral credentials and ephemeral containers.
Next steps I can help with
• If you want, I can outline a secure wrapper API example and show minimal code for:
◦ A REST endpoint that invokes Gmail API or runs `gcloud`/`workspace` CLI safely inside a container.
◦ A job queue + worker pattern that executes CLI commands with whitelisting and logs output.
• Tell me which environment you’ll run the agent in and whether you want per-user OAuth access or a single service account — I’ll propose a concrete design and sample flow.