You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(templates): Implement Gemini Computer Use templates for TypeScript and Python (#94)
# feat(templates): Implement Gemini Computer Use templates for
TypeScript and Python
## Summary
This PR introduces full-fledged Gemini Computer Use templates for both
TypeScript and Python. The templates implement Google's [Gemini 2.5
Computer Use](https://ai.google.dev/gemini-api/docs/computer-use) model
using Kernel's Computer Controls API for browser automation.
## Changes
### New Templates
- **TypeScript**: Complete rewrite of `gemini-computer-use` template
with native Kernel integration
- **Python**: New `gemini-computer-use` template following the same
architecture
### Architecture
Both templates follow a modular design based on Google's
[computer-use-preview
reference](https://github.com/google-gemini/computer-use-preview):
| File | Description |
|------|-------------|
| `index.ts` / `main.py` | Entry point with Kernel app registration and
action handler |
| `loop.ts` / `loop.py` | Gemini sampling loop - orchestrates model
calls and action execution |
| `session.ts` / `session.py` | Browser session management with optional
replay recording |
| `tools/computer.ts` / `tools/computer.py` | Maps Gemini actions to
Kernel's Computer Controls API |
| `tools/types/` | Type definitions for Gemini function calls |
### Supported Actions
| Action | Description |
|--------|-------------|
| `click_at` | Click at coordinates (x, y) |
| `hover_at` | Move mouse to coordinates |
| `type_text_at` | Click and type text at coordinates |
| `scroll_document` | Scroll page (up/down/left/right) |
| `scroll_at` | Scroll at specific coordinates |
| `navigate` | Navigate to a URL |
| `go_back` / `go_forward` | Browser history navigation |
| `key_combination` | Press key combinations (e.g., "ctrl+c") |
| `drag_and_drop` | Drag from one point to another |
| `wait_5_seconds` | Wait action |
### Key Features
- **Native Kernel Integration**: Uses Kernel's Computer Controls API
directly instead of third-party browser automation libraries
- **Replay Recording**: Optional video replay recording for debugging
(paid plans only)
- **Context Management**: Intelligently manages screenshot history to
stay within context limits
- **Coordinate Normalization**: Handles Gemini's normalized coordinates
(0-1000) to actual screen dimensions
- **Local Development**: Both templates support local execution via `npx
tsx index.ts` / direct Python execution
### CLI Updates
- Added `TemplateGeminiComputerUse` constant and template metadata in
`pkg/create/templates.go`
- Templates prioritized in selection list alongside Anthropic and OpenAI
computer use templates
## Usage
```bash
# Create a new project
kernel create my-app --language typescript --template gemini-computer-use
# Deploy
kernel deploy index.ts --env-file .env
# Invoke
kernel invoke ts-gemini-cua cua-task --payload '{"query": "Navigate to https://example.com and describe the page"}'
# With replay recording
kernel invoke ts-gemini-cua cua-task --payload '{"query": "...", "record_replay": true}'
```
## Requirements
- `GOOGLE_API_KEY` - [Google AI
Studio](https://aistudio.google.com/apikey)
## Testing
Templates have been manually tested with various browser automation
tasks.
## Related
- Closes KERNEL-870
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds native Gemini Computer Use support across both languages and
aligns docs/tests/CLI metadata.
>
> - **New Python template** `python/gemini-computer-use` with `main.py`,
`loop.py`, `session.py`, and `tools/` implementing Kernel Computer
Controls and Gemini sampling loop
> - **TypeScript template rewrite** `typescript/gemini-computer-use`:
replaces Stagehand with native Kernel APIs; adds `loop.ts`,
`session.ts`, `tools/`; updates `index.ts`, README, and dependencies
> - **CLI templates registry**: marks `GeminiComputerUse` as available
for Python and TypeScript; sets concrete invoke commands for both
languages
> - **QA docs**: adds `py-gemini-cua` to matrix, create/deploy steps,
invoke commands; updates totals (18 apps/21 tests)
> - **Tests**: removes "gemini-computer-use not available for python"
cases and related unavailability checks
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5e859dc. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Copy file name to clipboardExpand all lines: .cursor/commands/qa.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,7 @@ Here are all valid language + template combinations:
63
63
> **Note:** The `yutori-computer-use` template supports two modes: `computer_use` (default, full VM screenshots) and `playwright` (viewport-only screenshots via CDP). Both modes should be tested.
kernel invoke ts-anthropic-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and move the 5 items in the To Do and In Progress items to the Done section of the Kanban board. You are done successfully when the items are moved.", "record_replay": true}'
kernel invoke ts-openai-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'
265
-
kernel invoke ts-gemini-cua gemini-cua-task --payload '{"startingUrl": "https://www.magnitasks.com/", "instruction": "Click the Tasks option in the left-side bar, and move the 5 items in the To Do and In Progress items to the Done section of the Kanban board? You are done successfully when the items are moved."}'
276
+
kernel invoke ts-gemini-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and move the 5 items in the To Do and In Progress items to the Done section of the Kanban board. You are done successfully when the items are moved.", "record_replay": true}'
266
277
kernel invoke ts-claude-agent-sdk agent-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'
267
278
kernel invoke ts-yutori-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and drag the 5 items in the To Do and In Progress columns to the Done section of the Kanban board. You are done successfully when the items are dragged to Done. Do not click into the items.", "record_replay": true, "mode": "computer_use"}'
268
279
kernel invoke ts-yutori-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and drag the 5 items in the To Do and In Progress columns to the Done section of the Kanban board. You are done successfully when the items are dragged to Done. Do not click into the items.", "record_replay": true, "mode": "playwright"}'
kernel invoke python-openai-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'
276
287
kernel invoke python-openagi-cua openagi-default-task -p '{"instruction": "Navigate to https://agiopen.org and click the What is Computer Use? button"}'
277
288
kernel invoke py-claude-agent-sdk agent-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'
289
+
kernel invoke python-gemini-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and move the 5 items in the To Do and In Progress items to the Done section of the Kanban board. You are done successfully when the items are moved.", "record_replay": true}'
278
290
kernel invoke python-yutori-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and drag the 5 items in the To Do and In Progress columns to the Done section of the Kanban board. You are done successfully when the items are dragged to Done. Do not click into the items.", "record_replay": true, "mode": "computer_use"}'
279
291
kernel invoke python-yutori-cua cua-task --payload '{"query": "Go to http://magnitasks.com, Click the Tasks option in the left-side bar, and drag the 5 items in the To Do and In Progress columns to the Done section of the Kanban board. You are done successfully when the items are dragged to Done. Do not click into the items.", "record_replay": true, "mode": "playwright"}'
280
292
```
281
293
282
294
## Step 7: Automated Runtime Testing (Optional)
283
295
284
-
**STOP and ask the human:** "Would you like me to automatically invoke all 19 test cases and report back on their runtime status?"
296
+
**STOP and ask the human:** "Would you like me to automatically invoke all 21 test cases and report back on their runtime status?"
285
297
286
298
If the human agrees, invoke each template use the Kernel CLI and collect results. Present findings in this format:
287
299
@@ -310,6 +322,7 @@ If the human agrees, invoke each template use the Kernel CLI and collect results
InvokeCommand: `kernel invoke ts-gemini-cua cua-task --payload '{"query": "Navigate to http://magnitasks.com and click on Tasks in the sidebar"}'`,
205
205
},
206
206
TemplateClaudeAgentSDK: {
207
207
EntryPoint: "index.ts",
@@ -250,6 +250,11 @@ var Commands = map[string]map[string]DeployConfig{
250
250
NeedsEnvFile: true,
251
251
InvokeCommand: `kernel invoke py-claude-agent-sdk agent-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'`,
252
252
},
253
+
TemplateGeminiComputerUse: {
254
+
EntryPoint: "main.py",
255
+
NeedsEnvFile: true,
256
+
InvokeCommand: `kernel invoke python-gemini-cua cua-task --payload '{"query": "Navigate to http://magnitasks.com and click on Tasks in the sidebar"}'`,
0 commit comments