Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Add Cursor CLI as a harness (#79)

Eduardo Machadof73253918a9c
diff --git a/README.md b/README.md
index fed1ad1..d1a0d07 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ They do the work. Anything that touches the real world waits for your yes.
[![Release](https://img.shields.io/github/v/release/eduwxyz/tucano?color=FF8A1F&label=release)](https://github.com/eduwxyz/tucano/releases/latest)
[![License](https://img.shields.io/badge/license-Apache--2.0-141210)](LICENSE)
[![macOS](https://img.shields.io/badge/macOS-Apple%20silicon%20%7C%20Intel-141210?logo=apple)](#install) [![Linux](https://img.shields.io/badge/Linux-x64%20%7C%20ARM64-141210?logo=linux&logoColor=white)](#install) [![Windows](https://img.shields.io/badge/Windows-10%20%7C%2011-141210)](#install)
-[![Runs on](https://img.shields.io/badge/runs%20on-Claude%20Code%20·%20Codex%20·%20OpenCode%20·%20Pi-E2541B)](#runs-on-what-you-already-have)
+[![Runs on](https://img.shields.io/badge/runs%20on-Claude%20Code%20·%20Codex%20·%20Cursor%20·%20OpenCode%20·%20Pi-E2541B)](#runs-on-what-you-already-have)
**English** · [Português](README.pt-BR.md) · [tucano.sh](https://tucano.sh) · [@tucanosh](https://x.com/tucanosh) · [Changelog](CHANGELOG.md)
@@ -28,7 +28,7 @@ Coding agents got good. Working with *several* of them is still a mess of termin
- **A team, not a prompt box.** Agents with names, roles, tools and memory. They talk in channels, call each other with `@mentions` and hand work over: one finds the bug, another fixes it, a third reviews it, and you get the result.
- **Your rules.** Each agent sees only the tools you give it, with *no access*, *read*, or *read and write* per tool. Merges, purchases, posts, emails and deletes become an approval tied to the exact action, on your computer or your phone.
-- **Runs on what you already have.** Agents think with the Claude Code, Codex, OpenCode or Pi on your computer, the way you set them up: your subscription, your company's AI gateway, or your providers. No API key to paste, no per-token bill from us, and Tucano never sees your password.
+- **Runs on what you already have.** Agents think with the Claude Code, Codex, Cursor CLI, OpenCode or Pi on your computer, the way you set them up: your subscription, your company's AI gateway, or your providers. No API key to paste, no per-token bill from us, and Tucano never sees your password.
- **Everything stays on your computer.** Conversations, memory, logins, files. There is no Tucano server.
## What it does
@@ -87,6 +87,7 @@ Give an agent the apps on your computer, such as Notes, Calendar or Spotify, eac
|---|---|---|
| [Claude Code](https://code.claude.com) | Claude Pro or Max, or your company's login | Reads only the `env` block and `apiKeyHelper` of your `~/.claude/settings.json`; hooks, plugins and permissions stay out |
| [Codex](https://github.com/openai/codex) | ChatGPT Plus, Pro or Business | Runs with a home of its own, so your skills, `AGENTS.md` and plugins don't leak in; you sign in once inside Tucano |
+| [Cursor CLI](https://cursor.com/cli) | Your Cursor account (`cursor-agent login`) | Runs with a home of its own, so your hooks, plugins, skills and `~/.cursor/mcp.json` servers don't load; Cursor's own file reads, writes and shell stay off; each reply adds about 10k tokens of Cursor's own prompt |
| [OpenCode](https://opencode.ai) | The providers you configured | Uses the models you have logins for |
| [Pi](https://pi.dev) | The providers you configured | Uses the models you have logins for |
@@ -160,7 +161,7 @@ On Linux and Windows, use **Ctrl** instead of **⌘**. Closing the window keeps
flowchart LR
subgraph Mac["Your computer"]
UI["Window<br/>(React)"] <-->|MessagePort| Core["Core process<br/>SQLite · runs · memory · routines"]
- Core -->|"one turn, isolated"| CLI["Harness CLI<br/>claude · codex · opencode · pi"]
+ Core -->|"one turn, isolated"| CLI["Harness CLI<br/>claude · codex · cursor · opencode · pi"]
CLI -->|"secret per-turn URL<br/>only this agent's tools"| GW["Tucano MCP gateway"]
GW --> Tools["Connectors (MCP)<br/>computer · browser · memory"]
GW -.->|"write action"| OK{{"Your approval"}}
diff --git a/README.pt-BR.md b/README.pt-BR.md
index 6d0f2f0..3115ebe 100644
--- a/README.pt-BR.md
+++ b/README.pt-BR.md
@@ -12,7 +12,7 @@ Eles fazem o trabalho. O que mexe no mundo espera o seu sim.
[![Release](https://img.shields.io/github/v/release/eduwxyz/tucano?color=FF8A1F&label=release)](https://github.com/eduwxyz/tucano/releases/latest)
[![Licença](https://img.shields.io/badge/licen%C3%A7a-Apache--2.0-141210)](LICENSE)
[![macOS](https://img.shields.io/badge/macOS-chip%20Apple%20%7C%20Intel-141210?logo=apple)](#instalar) [![Linux](https://img.shields.io/badge/Linux-x64%20%7C%20ARM64-141210?logo=linux&logoColor=white)](#instalar) [![Windows](https://img.shields.io/badge/Windows-10%20%7C%2011-141210)](#instalar)
-[![Roda no](https://img.shields.io/badge/roda%20no-Claude%20Code%20·%20Codex%20·%20OpenCode%20·%20Pi-E2541B)](#roda-no-que-você-já-tem)
+[![Roda no](https://img.shields.io/badge/roda%20no-Claude%20Code%20·%20Codex%20·%20Cursor%20·%20OpenCode%20·%20Pi-E2541B)](#roda-no-que-você-já-tem)
[English](README.md) · **Português** · [tucano.sh](https://tucano.sh) · [@tucanosh](https://x.com/tucanosh) · [Novidades](CHANGELOG.md)
@@ -28,7 +28,7 @@ Os agentes de código ficaram bons. Trabalhar com *vários* deles ainda é uma b
- **Um time, não uma caixa de prompt.** Agentes com nome, papel, ferramentas e memória. Eles conversam em canais, se chamam com `@menção` e passam o trabalho adiante: um acha o erro, outro corrige, um terceiro revisa, e o resultado chega pra você.
- **Suas regras.** Cada agente só enxerga as ferramentas que você deu, com *sem acesso*, *ler* ou *ler e escrever* em cada uma. Merge, compra, post, e-mail e exclusão viram um pedido de aprovação amarrado à ação exata, no computador ou no celular.
-- **Roda no que você já tem.** Os agentes pensam com o Claude Code, o Codex, o OpenCode ou o Pi do seu computador, do jeito que você configurou: na sua assinatura, no gateway de IA da sua empresa ou nos seus provedores. Sem chave de API pra colar, sem cobrança por token da nossa parte, e o Tucano nunca vê a sua senha.
+- **Roda no que você já tem.** Os agentes pensam com o Claude Code, o Codex, o Cursor CLI, o OpenCode ou o Pi do seu computador, do jeito que você configurou: na sua assinatura, no gateway de IA da sua empresa ou nos seus provedores. Sem chave de API pra colar, sem cobrança por token da nossa parte, e o Tucano nunca vê a sua senha.
- **Tudo fica no seu computador.** Conversas, memória, logins, arquivos. Não existe servidor do Tucano.
## O que ele faz
@@ -87,6 +87,7 @@ Dê a um agente os apps do seu computador, como Notas, Calendário ou Spotify, c
|---|---|---|
| [Claude Code](https://code.claude.com) | Claude Pro ou Max, ou o login da sua empresa | Lê do seu `~/.claude/settings.json` só o bloco `env` e o `apiKeyHelper`; hooks, plugins e permissões ficam de fora |
| [Codex](https://github.com/openai/codex) | ChatGPT Plus, Pro ou Business | Roda com um home próprio, pra não carregar suas skills, `AGENTS.md` e plugins; você entra uma vez dentro do Tucano |
+| [Cursor CLI](https://cursor.com/cli) | Sua conta do Cursor (`cursor-agent login`) | Roda com um home próprio, pra não carregar seus hooks, plugins, skills e os servidores do `~/.cursor/mcp.json`; a leitura, a escrita e o shell do próprio Cursor ficam desligados; cada resposta soma uns 10 mil tokens do prompt do próprio Cursor |
| [OpenCode](https://opencode.ai) | Os provedores que você configurou | Usa os modelos em que você tem login |
| [Pi](https://pi.dev) | Os provedores que você configurou | Usa os modelos em que você tem login |
@@ -160,7 +161,7 @@ No Linux e no Windows, use **Ctrl** no lugar do **⌘**. Fechar a janela deixa o
flowchart LR
subgraph Mac["Seu computador"]
UI["Janela<br/>(React)"] <-->|MessagePort| Core["Núcleo<br/>SQLite · respostas · memória · rotinas"]
- Core -->|"um turno, isolado"| CLI["CLI do harness<br/>claude · codex · opencode · pi"]
+ Core -->|"um turno, isolado"| CLI["CLI do harness<br/>claude · codex · cursor · opencode · pi"]
CLI -->|"URL secreta por turno<br/>só as ferramentas do agente"| GW["Gateway MCP do Tucano"]
GW --> Tools["Conectores (MCP)<br/>computador · navegador · memória"]
GW -.->|"ação de escrita"| OK{{"Sua aprovação"}}
diff --git a/src/core/engines/cursor.ts b/src/core/engines/cursor.ts
new file mode 100644
index 0000000..cb2f60a
--- /dev/null
+++ b/src/core/engines/cursor.ts
@@ -0,0 +1,352 @@
+import { execFile } from 'node:child_process'
+import { createHash, randomBytes } from 'node:crypto'
+import { request } from 'node:http'
+import { existsSync, mkdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
+import { homedir, tmpdir } from 'node:os'
+import { dirname, join } from 'node:path'
+import { GATEWAY_NAME } from './claude'
+import { lastLines, num, parseJson, runCli, type Parser } from './cli'
+import type { Engine, EngineEvent, Turn, Usage } from './types'
+import { isWin, osOf, spawnable } from '../platform'
+import type { Os } from '../../shared/types'
+import { L } from '../../shared/lang'
+
+// Cursor's agent CLI (`cursor-agent`, also installed as `agent`). In headless
+// mode (`-p --output-format stream-json`) it prints one JSON event per line and
+// exits. Each turn runs in a folder of its own, with two parts:
+// - a config dir (CURSOR_CONFIG_DIR) whose permissions deny Cursor's own file
+// reads, writes and shell, and allow only the gateway's tools (and the web,
+// when the agent has it). The login stays the person's: it's in the keychain.
+// - a workspace with the agent's instructions (AGENTS.md, which the CLI reads
+// as the project's rules) and the gateway as the project's MCP server.
+// - a home of its own (see cursorHomeEnv): the CLI reads the person's hooks,
+// plugins and skills from the home folder, not from CURSOR_CONFIG_DIR.
+// MCP servers load only when approved, and the turn approves only the gateway
+// (`cursor-agent mcp enable`, no --approve-mcps): the person's own servers in
+// ~/.cursor/mcp.json are listed but never load. What Cursor keeps per
+// workspace (transcripts, approvals, its worker's socket) goes in the turn's
+// folder too (CURSOR_DATA_DIR), not in ~/.cursor/projects, and goes with the
+// turn. Each run also leaves a worker process behind (it would quit after 5
+// idle minutes); the turn tells it to quit when it ends.
+
+// Cursor's stream-json events (from the CLI's output): system init; user;
+// assistant {message:{content:[{type:'text', text}]}}, which with
+// --stream-partial-output comes as deltas (timestamp_ms, no model_call_id),
+// then again whole at the end of each model call (with model_call_id) and once
+// more at the end (neither); tool_call {subtype: started|completed, tool_call:
+// {<kind>ToolCall: {args, result}}}; result {subtype, is_error, result, usage:
+// {inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens}} — the
+// terminal event. inputTokens leaves the cache out.
+
+const charsToTokens = (chars: number): number => Math.ceil(chars / 4)
+
+// `sent`: the characters the app sends (instructions and prompt), to estimate
+// the usage if the CLI doesn't tell it. The estimate is low (Cursor adds its own
+// prompt, about 10k tokens), so it's doubled.
+export function cursorParser(sent = 0): Parser {
+ let text = ''
+ let newCall = false
+ let streamed = false // deltas came in this model call
+ let finished = false
+
+ const estimate = (): Usage => ({ inputTokens: charsToTokens(sent) * 2, cacheReadTokens: 0, outputTokens: charsToTokens(text.length) })
+
+ return {
+ line(line) {
+ const ev = parseJson(line)
+ if (!ev) return []
+ const out: EngineEvent[] = []
+ const type = ev['type']
+ if (type === 'assistant') {
+ // The deltas; the whole message that comes after them only when this model
+ // call had none (an older CLI, or no partial output), and never the last
+ // repeat of it (no timestamp).
+ if (typeof ev['timestamp_ms'] !== 'number') return []
+ const whole = 'model_call_id' in ev
+ if (whole && streamed) return []
+ const content = ((ev['message'] as Record<string, unknown> | undefined)?.['content'] ?? []) as Record<string, unknown>[]
+ const delta = (Array.isArray(content) ? content : []).map((c) => (c['type'] === 'text' && typeof c['text'] === 'string' ? c['text'] : '')).join('')
+ if (!delta) return []
+ if (!whole) streamed = true
+ // Text around tool calls comes in separate model calls; keep them as paragraphs.
+ const sep = newCall && text ? '\n\n' : ''
+ newCall = false
+ text += sep + delta
+ out.push({ type: 'text', delta: sep + delta })
+ } else if (type === 'tool_call') {
+ newCall = true
+ streamed = false
+ // A web search or read shows once it ran: one the permissions refused didn't.
+ if (ev['subtype'] !== 'completed') return []
+ const call = (ev['tool_call'] ?? {}) as Record<string, Record<string, unknown> | undefined>
+ const ran = Object.values(call).some((c) => !!c && typeof c === 'object' && !!(c['result'] as Record<string, unknown> | undefined)?.['success'])
+ if (!ran) return []
+ const args = (call['webSearchToolCall']?.['args'] ?? undefined) as Record<string, unknown> | undefined
+ if (args) out.push({ type: 'web', action: 'search', detail: String(args['searchTerm'] ?? args['query'] ?? '') })
+ const fetch = call['webFetchToolCall'] ?? call['fetchToolCall']
+ const fargs = (fetch?.['args'] ?? undefined) as Record<string, unknown> | undefined
+ if (fargs) out.push({ type: 'web', action: 'fetch', detail: String(fargs['url'] ?? '') })
+ } else if (type === 'result') {
+ finished = true
+ const whole = typeof ev['result'] === 'string' ? ev['result'] : ''
+ if (ev['is_error'] === true || ev['subtype'] !== 'success') {
+ out.push({ type: 'error', message: whole || L(`O Cursor terminou com erro (${String(ev['subtype'])}).`, `Cursor ended with an error (${String(ev['subtype'])}).`) })
+ return out
+ }
+ if (!text) text = whole
+ const u = ev['usage'] as Record<string, unknown> | undefined
+ const told = u && (typeof u['inputTokens'] === 'number' || typeof u['outputTokens'] === 'number')
+ const cacheRead = num(u?.['cacheReadTokens'])
+ const usage: Usage = told
+ ? { inputTokens: num(u['inputTokens']) + cacheRead + num(u['cacheWriteTokens']), cacheReadTokens: cacheRead, outputTokens: num(u['outputTokens']) }
+ : estimate()
+ out.push({ type: 'done', text, usage })
+ }
+ return out
+ },
+ end(code, stderr) {
+ if (finished) return []
+ const detail = lastLines(stderr)
+ return [{ type: 'error', message: L(`O Cursor saiu sem resposta (código ${code ?? '?'}).`, `Cursor exited without a reply (code ${code ?? '?'}).`) + (detail ? `\n${detail}` : '') }]
+ }
+ }
+}
+
+// Headless, one shot: the prompt on stdin (big prompts don't fit an argument),
+// stream-json with deltas, the model named, and the turn's workspace trusted
+// (it's the app's own). No --force: a tool the permissions don't allow is
+// refused, never run. No --approve-mcps: only the approved gateway loads.
+// Images attached in the chat go with the prompt (--image, once per file), as
+// with Codex: the agent sees them with Cursor's own file reads still denied.
+// The CLI hides that option ("internal only"), so it may go away; see
+// imageRefused for what the turn does then.
+export function cursorArgs(turn: Pick<Turn, 'model' | 'images'>): string[] {
+ return [
+ '-p',
+ '--output-format',
+ 'stream-json',
+ '--stream-partial-output',
+ '--trust',
+ '--model',
+ turn.model,
+ ...(turn.images ?? []).filter((i) => existsSync(i.path)).flatMap((i) => ['--image', i.path])
+ ]
+}
+
+// Whether the CLI refused --image itself (an unknown option, before any reply):
+// then the turn runs again without the images.
+export const imageRefused = (message: string): boolean => /unknown option|unrecognized|unexpected argument/i.test(message) && /--image\b/.test(message)
+
+// What the agent is told when its images couldn't go along, so it says so
+// instead of answering as if it had seen them.
+export const imagesLeftOut = (): string =>
+ L(
+ '\n\n(Aviso do Tucano: as imagens anexadas nesta conversa não puderam ser mostradas a você desta vez, porque o Cursor CLI não aceitou anexá-las. Se a pessoa perguntar sobre uma imagem, diga que não conseguiu vê-la.)',
+ "\n\n(Note from Tucano: the images attached in this conversation couldn't be shown to you this time, because Cursor CLI didn't take them. If you're asked about an image, say you couldn't see it.)"
+ )
+
+// The permissions of a turn: Cursor's file reads, writes (deleting and saving
+// images included) and shell are denied; the gateway's tools are allowed and
+// run without asking (the gateway decides); web fetch and web search only with
+// the web. Deny wins over allow in Cursor, so the allow list is what's left.
+export function cursorConfig(turn: Pick<Turn, 'mcpUrl' | 'web'>): Record<string, unknown> {
+ return {
+ version: 1,
+ permissions: {
+ allow: [...(turn.mcpUrl ? [`Mcp(${GATEWAY_NAME}:*)`] : []), ...(turn.web ? ['WebFetch(*)'] : [])],
+ deny: ['Read(**)', 'Write(**)', 'Shell(*)', ...(turn.web ? [] : ['WebFetch(*)'])]
+ },
+ approvalMode: 'allowlist',
+ autoAcceptWebSearch: !!turn.web,
+ attribution: { attributeCommitsToAgent: false, attributePRsToAgent: false }
+ }
+}
+
+// Where the app keeps the Cursor turns, in its data folder.
+export const cursorAppDir = (dataDir: string): string => join(dataDir, 'cursor')
+
+export interface CursorTurnDirs {
+ root: string
+ config: string // CURSOR_CONFIG_DIR
+ data: string // CURSOR_DATA_DIR
+ workspace: string
+ home: string // HOME (USERPROFILE on Windows)
+}
+
+// The CLI reads, from the home folder and not from CURSOR_CONFIG_DIR, the
+// person's hooks (~/.cursor/hooks.json, and the ones in ~/.claude/settings.json,
+// whose format it imports), plugins (~/.claude/plugins, ~/.cursor/plugins) and
+// skills (~/.cursor, ~/.claude, ~/.codex, ~/.agents). Hooks run in headless
+// mode too: commands outside the gateway, handed the turn's prompt and tool
+// calls. So a turn gets an empty home, with only the way to the person's login:
+// - macOS: the keychain, linked in as Library/Keychains (nothing else of ~/Library);
+// - Linux: a file under XDG_CONFIG_HOME (cursor/auth.json), so that stays the person's;
+// - Windows: a file under %APPDATA% (Cursor\auth.json), which stays the person's.
+// What's left out on purpose: hooks an admin set for the machine (/Library,
+// /etc, ProgramData) or for the team, in Cursor's dashboard.
+// The CLI keeps a compile cache in the home; it goes in the app's folder, so
+// each turn doesn't start cold.
+export function cursorHomeEnv(home: string, appDir: string, os: Os = osOf(), realHome = homedir(), env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
+ const set = (v: string | undefined): string | undefined => (v && v.trim() ? v : undefined)
+ return {
+ HOME: home,
+ NODE_COMPILE_CACHE: join(appDir, 'compile-cache'),
+ ...(os === 'linux' ? { XDG_CONFIG_HOME: set(env['XDG_CONFIG_HOME']) ?? join(realHome, '.config') } : {}),
+ ...(os === 'windows'
+ ? {
+ USERPROFILE: home,
+ APPDATA: set(env['APPDATA']) ?? join(realHome, 'AppData', 'Roaming'),
+ LOCALAPPDATA: set(env['LOCALAPPDATA']) ?? join(realHome, 'AppData', 'Local')
+ }
+ : {})
+ }
+}
+
+// A folder for one turn: the config dir, the workspace (instructions and the
+// gateway) and the home (on macOS, with the keychain linked in).
+export function cursorTurnDirs(appDir: string, turn: Pick<Turn, 'system' | 'mcpUrl' | 'web'>, os: Os = osOf(), realHome = homedir()): CursorTurnDirs {
+ const root = join(appDir, randomBytes(8).toString('hex'))
+ const config = join(root, 'config')
+ const data = join(root, 'd') // short: the worker's socket path is built from it
+ const workspace = join(root, 'workspace')
+ const home = join(root, 'home')
+ mkdirSync(config, { recursive: true })
+ mkdirSync(data, { recursive: true })
+ mkdirSync(join(workspace, '.cursor'), { recursive: true })
+ mkdirSync(home, { recursive: true })
+ if (os === 'mac') {
+ mkdirSync(join(home, 'Library'), { recursive: true })
+ try {
+ symlinkSync(join(realHome, 'Library', 'Keychains'), join(home, 'Library', 'Keychains'))
+ } catch {
+ // without it the CLI says it isn't signed in, and the turn shows that
+ }
+ }
+ writeFileSync(join(config, 'cli-config.json'), JSON.stringify(cursorConfig(turn), null, 2))
+ writeFileSync(join(workspace, 'AGENTS.md'), turn.system)
+ if (turn.mcpUrl) writeFileSync(join(workspace, '.cursor', 'mcp.json'), JSON.stringify({ mcpServers: { [GATEWAY_NAME]: { url: turn.mcpUrl } } }, null, 2))
+ return { root, config, data, workspace, home }
+}
+
+// How Cursor names a workspace's folder: its real path, as a slug.
+export function cursorSlug(workspace: string): string {
+ let real = workspace
+ try {
+ real = realpathSync(workspace)
+ } catch {
+ // gone already: the path as given
+ }
+ return real.replace(/[^a-zA-Z0-9]/g, '-').replace(/-+/g, '-').replace(/^-+|-+$/g, '')
+}
+
+// Where the CLI puts its worker's socket for a workspace (the CLI's own rule,
+// which keeps the path short enough for a Unix socket): under <data>/projects,
+// or <data>, or the temp folder, cut to 83 characters plus a hash when long.
+export function cursorWorkerSocket(workspace: string, data: string, tmp = tmpdir()): string {
+ let base = join(data, 'projects')
+ if (base.length > 83) {
+ base = data
+ if (base.length > 83) base = join(tmp, '.cursor').length <= 83 ? join(tmp, '.cursor') : join('/tmp', '.cursor')
+ }
+ let dir = join(base, cursorSlug(workspace))
+ if (dir.length > 91) dir = `${dir.substring(0, 83)}-${createHash('sha256').update(dir).digest('hex').substring(0, 7)}`
+ return join(dir, 'worker.sock')
+}
+
+// Asks the turn's worker to quit (it answers, then exits). Without one, nothing happens.
+function stopWorker(socket: string): Promise<void> {
+ if (isWin || !existsSync(socket)) return Promise.resolve()
+ return new Promise((resolve) => {
+ const req = request({ socketPath: socket, path: '/kill', method: 'POST', timeout: 3_000 }, (res) => {
+ res.resume()
+ res.on('end', () => resolve())
+ })
+ req.on('error', () => resolve())
+ req.on('timeout', () => {
+ req.destroy()
+ resolve()
+ })
+ req.end()
+ })
+}
+
+// The end of a turn: the worker quits, and the turn's folder goes: the config,
+// the workspace, the home, and what Cursor kept for it (the transcript, the
+// approval, the socket). The home's link to the keychain goes as a link: what
+// it points to stays. With a long data path the socket sits in the temp folder
+// instead, in a folder named after this turn's workspace alone.
+export async function cursorCleanup(dirs: CursorTurnDirs): Promise<void> {
+ const socket = cursorWorkerSocket(dirs.workspace, dirs.data)
+ await stopWorker(socket)
+ const gone = dirname(socket).startsWith(dirs.root) ? [dirs.root] : [dirs.root, dirname(socket)]
+ for (const dir of gone)
+ try {
+ if (existsSync(dir)) rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
+ } catch {
+ // a rare leftover is a small dead folder; harmless
+ }
+}
+
+const quiet = (bin: string, args: string[], cwd: string, env: NodeJS.ProcessEnv): Promise<number> =>
+ new Promise((resolve) => {
+ const s = spawnable(bin, args)
+ execFile(s.file, s.args, { cwd, env, timeout: 30_000, windowsHide: true, windowsVerbatimArguments: s.verbatim }, (err) => resolve(err ? 1 : 0))
+ })
+
+export function cursorEngine(bin: () => string | undefined, appDir: string, shellEnv: () => Promise<NodeJS.ProcessEnv> = async () => ({})): Engine {
+ return {
+ id: 'cursor',
+ async *run(turn) {
+ const path = bin()
+ if (!path) {
+ yield { type: 'error', message: L('O Cursor CLI não está instalado. Veja em Configurações.', "Cursor CLI isn't installed. See Settings.") }
+ return
+ }
+ const model = turn.model.includes('/') ? turn.model.slice(turn.model.indexOf('/') + 1) : turn.model
+ const dirs = cursorTurnDirs(appDir, turn)
+ // CURSOR_API_KEY may live in the person's shell, which an app opened from Finder doesn't get.
+ const env: NodeJS.ProcessEnv = { ...process.env, ...(await shellEnv()), ...cursorHomeEnv(dirs.home, appDir), CURSOR_CONFIG_DIR: dirs.config, CURSOR_DATA_DIR: dirs.data, NO_OPEN_BROWSER: '1' }
+ try {
+ if (turn.mcpUrl && (await quiet(path, ['mcp', 'enable', GATEWAY_NAME], dirs.workspace, env)) !== 0) {
+ yield { type: 'error', message: L('O Cursor não aceitou as ferramentas do Tucano (cursor-agent mcp enable).', "Cursor didn't take Tucano's tools (cursor-agent mcp enable).") }
+ return
+ }
+ const sent = turn.system.length + turn.prompt.length
+ const run = (images: Turn['images'], prompt: string): AsyncIterable<EngineEvent> =>
+ runCli({ bin: path, args: cursorArgs({ model, images }), stdin: prompt, cwd: dirs.workspace, signal: turn.signal, parser: cursorParser(sent), env })
+ const withImages = (turn.images ?? []).some((i) => existsSync(i.path))
+ if (!withImages) {
+ yield* run(undefined, turn.prompt)
+ return
+ }
+ // With images, a refusal of --image (it comes before anything else) runs
+ // the turn again without them, and the agent is told why.
+ let said = false
+ let refused = false
+ for await (const ev of run(turn.images, turn.prompt)) {
+ if (!said && ev.type === 'error' && imageRefused(ev.message)) {
+ refused = true
+ break
+ }
+ said = said || ev.type === 'text'
+ yield ev
+ }
+ if (refused && !turn.signal.aborted) yield* run(undefined, turn.prompt + imagesLeftOut())
+ } finally {
+ await cursorCleanup(dirs)
+ }
+ }
+ }
+}
+
+// `cursor-agent models` prints "<id> - <label>" per line, under a title.
+export function parseCursorModels(out: string): string[] {
+ return out
+ .split('\n')
+ .map((l) => /^\s*([a-z0-9][\w.\-[\]=,]*)\s+-\s+\S/i.exec(l)?.[1])
+ .filter((id): id is string => !!id)
+}
+
+// Whether the CLI is signed in, from `cursor-agent status` (or an API key).
+export const cursorSignedIn = (statusOut: string, env: NodeJS.ProcessEnv = process.env): boolean =>
+ /logged in/i.test(statusOut) && !/not logged in/i.test(statusOut) ? true : !!env['CURSOR_API_KEY']
diff --git a/src/core/engines/detect.ts b/src/core/engines/detect.ts
index b16669b..50b7fe0 100644
--- a/src/core/engines/detect.ts
+++ b/src/core/engines/detect.ts
@@ -10,6 +10,7 @@ import { userProvider } from './claude'
import { codexEnv, userCodexProvider } from './codex'
import { opencodeMajor } from './opencode-v2'
import { geminiModels } from './gemini'
+import { cursorSignedIn, parseCursorModels } from './cursor'
function run(bin: string, args: string[], timeout = 15_000, env: NodeJS.ProcessEnv = process.env): Promise<{ code: number; stdout: string; stderr: string }> {
return new Promise((resolve) => {
@@ -246,17 +247,37 @@ export async function detectGemini(): Promise<{ status: EngineStatus; models: st
}
}
+// Cursor's agent CLI, by its unique name (it also installs a plain `agent`).
+// `status` says whether it's signed in; `models` lists what the account can run.
+export async function detectCursor(): Promise<{ status: EngineStatus; models: string[] }> {
+ const path = await which('cursor-agent')
+ if (!path) return { status: { installed: false, loggedIn: false }, models: [] }
+ const [v, st] = await Promise.all([run(path, ['--version']), run(path, ['status'], 20_000, { ...process.env, NO_OPEN_BROWSER: '1' })])
+ const signedIn = cursorSignedIn(st.stdout + st.stderr)
+ const models = signedIn ? parseCursorModels((await run(path, ['models'], 30_000, { ...process.env, NO_OPEN_BROWSER: '1' })).stdout) : []
+ return {
+ status: {
+ installed: true,
+ path,
+ version: v.stdout.trim().match(/^[\w.-]+/)?.[0] ?? version(v.stdout),
+ loggedIn: signedIn && models.length > 0,
+ ...(signedIn && models.length ? { route: 'providers' as const, account: `Cursor · ${models.length} ${L('modelos', 'models')}` } : { account: signedIn ? L('Sem modelos: confira o plano do Cursor', 'No models: check your Cursor plan') : L('Sem login: entre com cursor-agent login', 'Not signed in: sign in with cursor-agent login') })
+ },
+ models
+ }
+}
+
export async function detectEngines(codexHome: string): Promise<{ engines: Record<EngineId, EngineStatus>; listed: Partial<Record<EngineId, string[]>>; codexCatalog: CodexModel[] }> {
// A CLI installed while the app is open may have created its folder just now.
process.env['PATH'] = withInstallDirs(process.env['PATH'] ?? '')
// Codex's catalog is read alongside (it can take a couple of seconds), used once the login is known.
const catalog = which('codex').then((p) => (p ? codexModels(p, codexHome) : []))
- const [claude, codex, opencode, pi, gemini] = await Promise.all([detectClaude(), detectCodex(codexHome), detectOpenCode(), detectPi(), detectGemini()])
+ const [claude, codex, opencode, pi, gemini, cursor] = await Promise.all([detectClaude(), detectCodex(codexHome), detectOpenCode(), detectPi(), detectGemini(), detectCursor()])
// A gateway serves its own list (asked when picking); a plan or an API key gets Codex's catalog.
const codexCatalog = codex.loggedIn && codex.route !== 'gateway' ? await catalog : []
return {
- engines: { claude, codex, opencode: opencode.status, pi: pi.status, gemini: gemini.status },
- listed: { opencode: opencode.models, pi: pi.models, gemini: gemini.models, ...(codexCatalog.length ? { codex: codexCatalog.map((m) => m.slug) } : {}) },
+ engines: { claude, codex, opencode: opencode.status, pi: pi.status, gemini: gemini.status, cursor: cursor.status },
+ listed: { opencode: opencode.models, pi: pi.models, gemini: gemini.models, cursor: cursor.models, ...(codexCatalog.length ? { codex: codexCatalog.map((m) => m.slug) } : {}) },
codexCatalog
}
}
diff --git a/src/core/harness.ts b/src/core/harness.ts
index d6aac90..127a4c5 100644
--- a/src/core/harness.ts
+++ b/src/core/harness.ts
@@ -7,7 +7,7 @@ import { L } from '../shared/lang'
import type { EngineId, EngineStatus } from '../shared/types'
// The harnesses the app can run agents on; one added later is listed as coming until then.
-export const RUNNABLE: EngineId[] = ['claude', 'codex', 'opencode', 'pi', 'gemini']
+export const RUNNABLE: EngineId[] = ['claude', 'codex', 'opencode', 'pi', 'gemini', 'cursor']
// Off for a harness pointed at a gateway: its own telemetry and error reports
// would go to Anthropic or OpenAI, around the gateway.
diff --git a/src/core/index.ts b/src/core/index.ts
index 3979da2..c8f9bf7 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -18,6 +18,7 @@ import { codexEngine, userCodexProvider } from './engines/codex'
import { opencodeEngine } from './engines/opencode'
import { piEngine } from './engines/pi'
import { geminiAppDir, geminiEngine } from './engines/gemini'
+import { cursorAppDir, cursorEngine } from './engines/cursor'
import { accountDir, accountStatus, adoptLoginShellPath, detectEngines, type CodexModel } from './engines/detect'
import { fakeEngine } from './engines/fake'
import { DesktopApps, macApps, SELF } from './apps'
@@ -81,7 +82,7 @@ const DEFAULTS: Omit<Settings, 'engines'> = {
}
const unknownEngine: EngineStatus = { installed: false, loggedIn: false }
-let engines: Record<EngineId, EngineStatus> = { claude: unknownEngine, codex: unknownEngine, opencode: unknownEngine, pi: unknownEngine, gemini: unknownEngine }
+let engines: Record<EngineId, EngineStatus> = { claude: unknownEngine, codex: unknownEngine, opencode: unknownEngine, pi: unknownEngine, gemini: unknownEngine, cursor: unknownEngine }
// The models OpenCode and Pi list (what the person has logins for), from the last check.
let listed: Partial<Record<EngineId, string[]>> = {}
// Codex's own catalog for this login (names and what each model is for), from the last check.
@@ -90,7 +91,7 @@ let codexCatalog: CodexModel[] = []
const fakeStatus = (v: string): EngineStatus => ({ installed: true, loggedIn: true, path: 'fake', version: v, account: L('Motor de teste', 'Test engine'), route: 'plan' })
async function detect(): Promise<void> {
if (fake) {
- engines = { claude: fakeStatus('0.0.0'), codex: fakeStatus('0.0.0'), opencode: { ...fakeStatus('0.0.0'), route: 'providers', account: 'OpenAI, OpenCode · 3 modelos' }, pi: { installed: false, loggedIn: false }, gemini: { installed: false, loggedIn: false } }
+ engines = { claude: fakeStatus('0.0.0'), codex: fakeStatus('0.0.0'), opencode: { ...fakeStatus('0.0.0'), route: 'providers', account: 'OpenAI, OpenCode · 3 modelos' }, pi: { installed: false, loggedIn: false }, gemini: { installed: false, loggedIn: false }, cursor: { installed: false, loggedIn: false } }
listed = { opencode: ['openai/gpt-5.5', 'opencode/big-pickle', 'opencode-go/qwen3.8-max'] }
} else ({ engines, listed, codexCatalog } = await detectEngines(codexHome))
await checkAccounts()
@@ -167,13 +168,14 @@ function watchAccount(id: string): void {
const githubInfo = (): Settings['github'] => githubRef?.info()
const engineImpls: Record<EngineId, Engine> = fake
- ? { claude: fakeEngine('claude'), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ ? { claude: fakeEngine('claude'), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
: {
claude: claudeEngine(() => engines.claude.path, async () => quietClaude(userProvider())),
codex: codexEngine(() => engines.codex.path, codexHome, loginEnv, async () => quietCodex(userCodexProvider())),
opencode: opencodeEngine(() => engines.opencode.path, join(dataDir, 'opencode-home'), loginEnv, () => engines.opencode.version),
pi: piEngine(() => engines.pi.path, join(dataDir, 'pi'), loginEnv),
- gemini: geminiEngine(() => engines.gemini.path, geminiAppDir(dataDir), loginEnv)
+ gemini: geminiEngine(() => engines.gemini.path, geminiAppDir(dataDir), loginEnv),
+ cursor: cursorEngine(() => engines.cursor.path, cursorAppDir(dataDir), loginEnv)
}
// A command in the login shell, where SSO tools live; what it prints, trimmed.
diff --git a/src/core/platform.ts b/src/core/platform.ts
index f5e742a..04e6dab 100644
--- a/src/core/platform.ts
+++ b/src/core/platform.ts
@@ -120,7 +120,8 @@ export const pathDirs = (): string[] => (process.env['PATH'] ?? process.env['Pat
// the folder to PATH (Claude Code's native installer on Windows says so and moves
// on). Each one that exists and isn't on the PATH yet is appended to it.
export function withInstallDirs(path: string, os: Os = osOf(), home = homedir(), env: NodeJS.ProcessEnv = process.env, exists: (p: string) => boolean = existsSync): string {
- const dirs = [join(home, '.local', 'bin'), ...(os === 'windows' ? [env['APPDATA'] && join(env['APPDATA'], 'npm')] : [])].filter((d): d is string => !!d)
+ // Windows: npm's global folder, and Cursor's installer (%LOCALAPPDATA%\cursor-agent).
+ const dirs = [join(home, '.local', 'bin'), ...(os === 'windows' ? [env['APPDATA'] && join(env['APPDATA'], 'npm'), env['LOCALAPPDATA'] && join(env['LOCALAPPDATA'], 'cursor-agent')] : [])].filter((d): d is string => !!d)
const have = path.split(delimiter).filter(Boolean)
const same = (a: string, b: string): boolean => (os === 'windows' ? a.replace(/[\\/]+$/, '').toLowerCase() === b.replace(/[\\/]+$/, '').toLowerCase() : a.replace(/\/+$/, '') === b.replace(/\/+$/, ''))
const missing = dirs.filter((d) => exists(d) && !have.some((h) => same(h, d)))
diff --git a/src/core/tuca.ts b/src/core/tuca.ts
index 3836241..f8a25cf 100644
--- a/src/core/tuca.ts
+++ b/src/core/tuca.ts
@@ -69,14 +69,14 @@ export const PROPOR_AGENTE: ToolDef = {
}
}
-// The models agents can run on now: the listed ones of a ready plan, and what OpenCode, Pi and Gemini list.
+// The models agents can run on now: the listed ones of a ready plan, and what OpenCode, Pi, Gemini and Cursor list.
export function availableModels(s: Pick<Settings, 'engines'>, listed: Partial<Record<string, string[]>> = {}): { id: string; label: string }[] {
// Codex's own catalog when there is one (newest first); the app's list otherwise.
const codex = listed['codex']?.length ? listed['codex'].map((slug) => modelInfo(codexValue(slug)) ?? { id: slug, engine: 'codex' as const, label: slug, hint: '' }) : undefined
const plan = [...MODELS.filter((m) => m.engine !== 'codex' || !codex), ...(codex ?? []).map((m) => ({ ...m, id: codexValue(m.id) }))]
.filter((m) => s.engines[m.engine].loggedIn && s.engines[m.engine].route !== 'gateway')
.map((m) => ({ id: m.id, label: `${ENGINES[m.engine].label} · ${m.label}` }))
- const own = (['opencode', 'pi', 'gemini'] as const).flatMap((e) => (s.engines[e].loggedIn ? (listed[e] ?? []).slice(0, 12).map((name) => ({ id: `${e}:${name}`, label: `${ENGINES[e].label} · ${name}` })) : []))
+ const own = (['opencode', 'pi', 'gemini', 'cursor'] as const).flatMap((e) => (s.engines[e]?.loggedIn ? (listed[e] ?? []).slice(0, 12).map((name) => ({ id: `${e}:${name}`, label: `${ENGINES[e].label} · ${name}` })) : []))
return [...plan, ...own]
}
diff --git a/src/renderer/src/components/Pages.tsx b/src/renderer/src/components/Pages.tsx
index f89f938..d421daf 100644
--- a/src/renderer/src/components/Pages.tsx
+++ b/src/renderer/src/components/Pages.tsx
@@ -606,15 +606,18 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d
</p>
)}
<div className="grid2">
- <Field label={L('Esforço de raciocínio', 'Reasoning effort')} hint={L('Mais esforço pensa mais e gasta mais do plano.', 'More effort thinks longer and uses more of your plan.')}>
- <select value={draft.effort} onChange={(e) => patch({ effort: e.target.value as Agent['effort'] })}>
- {EFFORTS.map((ef) => (
- <option key={ef.id} value={ef.id}>
- {ef.label}
- </option>
- ))}
- </select>
- </Field>
+ {/* Cursor's models carry the effort in the name (…-high, …-xhigh): no separate pick. */}
+ {engine !== 'cursor' && (
+ <Field label={L('Esforço de raciocínio', 'Reasoning effort')} hint={L('Mais esforço pensa mais e gasta mais do plano.', 'More effort thinks longer and uses more of your plan.')}>
+ <select value={draft.effort} onChange={(e) => patch({ effort: e.target.value as Agent['effort'] })}>
+ {EFFORTS.map((ef) => (
+ <option key={ef.id} value={ef.id}>
+ {ef.label}
+ </option>
+ ))}
+ </select>
+ </Field>
+ )}
<Field label={L('Limite mensal (milhões de tokens)', 'Monthly limit (millions of tokens)')} hint={L(`Conferido antes de cada turno. No limite, ${draft.name || 'o agente'} para e avisa.`, `Checked before every turn. At the limit, ${draft.name || 'the agent'} stops and tells you.`)}>
<NumberInput
min={0}
diff --git a/src/renderer/src/store.ts b/src/renderer/src/store.ts
index 36d6836..aecc10e 100644
--- a/src/renderer/src/store.ts
+++ b/src/renderer/src/store.ts
@@ -104,7 +104,7 @@ let state: State = {
settings: {
workspaceName: '',
context: '',
- engines: { claude: { installed: false, loggedIn: false }, codex: { installed: false, loggedIn: false }, opencode: { installed: false, loggedIn: false }, pi: { installed: false, loggedIn: false }, gemini: { installed: false, loggedIn: false } },
+ engines: { claude: { installed: false, loggedIn: false }, codex: { installed: false, loggedIn: false }, opencode: { installed: false, loggedIn: false }, pi: { installed: false, loggedIn: false }, gemini: { installed: false, loggedIn: false }, cursor: { installed: false, loggedIn: false } },
routerModel: 'haiku',
memoryModel: 'haiku',
memoryLearning: 'approve',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 5a14da8..0cf5da3 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -5,7 +5,7 @@ import { L, lang, type Lang } from './lang'
export type AgentColor = 'sky' | 'indigo' | 'violet' | 'rose' | 'amber' | 'green' | 'teal' | 'graphite'
export type GrantLevel = 'none' | 'read' | 'read_write'
export type ToolClass = 'read' | 'write' | 'sensitive'
-export type EngineId = 'claude' | 'codex' | 'opencode' | 'pi' | 'gemini'
+export type EngineId = 'claude' | 'codex' | 'opencode' | 'pi' | 'gemini' | 'cursor'
export type Effort = 'low' | 'medium' | 'high' | 'xhigh'
export type MemoryMode = 'auto' | 'approve' | 'read' // how an agent's `lembrar` calls land
@@ -341,7 +341,8 @@ export const ENGINES: Record<EngineId, { label: string; cli: string; login: stri
codex: { label: 'Codex', cli: 'codex', login: 'codex login', install: 'npm install -g @openai/codex', site: 'https://github.com/openai/codex' },
opencode: { label: 'OpenCode', cli: 'opencode', login: 'opencode auth login', install: 'curl -fsSL https://opencode.ai/install | bash', windows: 'npm install -g opencode-ai', site: 'https://opencode.ai' },
pi: { label: 'Pi', cli: 'pi', login: 'pi', install: 'npm install -g @earendil-works/pi-coding-agent', site: 'https://pi.dev' },
- gemini: { label: 'Gemini CLI', cli: 'gemini', login: 'gemini', install: 'npm install -g @google/gemini-cli', site: 'https://github.com/google-gemini/gemini-cli' }
+ gemini: { label: 'Gemini CLI', cli: 'gemini', login: 'gemini', install: 'npm install -g @google/gemini-cli', site: 'https://github.com/google-gemini/gemini-cli' },
+ cursor: { label: 'Cursor CLI', cli: 'cursor-agent', login: 'cursor-agent login', install: 'curl https://cursor.com/install -fsS | bash', windows: "irm 'https://cursor.com/install?win32=true' | iex", site: 'https://cursor.com/cli' }
}
export const ENGINE_IDS = Object.keys(ENGINES) as EngineId[]
diff --git a/test/accounts.test.ts b/test/accounts.test.ts
index d1e797e..4f5512b 100644
--- a/test/accounts.test.ts
+++ b/test/accounts.test.ts
@@ -25,7 +25,7 @@ const work: Account = { id: 'w1', engine: 'claude', name: 'Trabalho', loggedIn:
function runner(): Runner {
claude = counted(fakeEngine('claude', { delayMs: 1 }))
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
return new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-work-')), dataDir: data })
}
const reply = (): Message => db.messages().find((m) => m.author.kind === 'agent')!
@@ -33,7 +33,7 @@ const reply = (): Message => db.messages().find((m) => m.author.kind === 'agent'
beforeEach(() => {
data = mkdtempSync(join(tmpdir(), 'ad-data-'))
db = new Db(join(data, 'test.db'))
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt', accounts: [work] }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt', accounts: [work] }
db.saveAgent(agent({ accountId: 'w1' }))
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
})
diff --git a/test/browser.test.ts b/test/browser.test.ts
index e0f40af..e0e0c56 100644
--- a/test/browser.test.ts
+++ b/test/browser.test.ts
@@ -245,7 +245,7 @@ describe('the runner with a browser', () => {
const fake = fakeHost()
const browser = new Browser({ host: fake.host, db, dataDir, emit: () => {}, me: () => 'Edu' })
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const gateway = new Gateway()
await gateway.start()
const results: unknown[] = []
@@ -259,7 +259,7 @@ describe('the runner with a browser', () => {
yield { type: 'done', text: 'ok', usage: { inputTokens: 1000, cacheReadTokens: 0, outputTokens: 10 } }
}
}
- const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, browser })
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, browser })
await r.send('c1', '@theo abre o studio')
await r.idle()
@@ -292,7 +292,7 @@ describe('the runner with a browser', () => {
db.createConversation({ id: 'c1', kind: 'channel', name: 'conteudo', members: ['lia-0001'] })
const browser = new Browser({ host: fakeHost().host, db, dataDir, emit: () => {}, me: () => 'Edu' })
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const gateway = new Gateway()
await gateway.start()
const claude: Engine = {
@@ -310,7 +310,7 @@ describe('the runner with a browser', () => {
yield { type: 'done', text: 'O CTR foi 1,6%.', usage: { inputTokens: 1000, cacheReadTokens: 0, outputTokens: 10 } }
}
}
- const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, browser })
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, browser })
const reply = async (text: string) => {
await r.send('c1', text)
await r.idle()
diff --git a/test/codex-models.test.ts b/test/codex-models.test.ts
index ec071f0..a1f4112 100644
--- a/test/codex-models.test.ts
+++ b/test/codex-models.test.ts
@@ -41,7 +41,7 @@ describe("Codex's own catalog", () => {
it("gives Tuca the catalog's models instead of the app's Codex list", () => {
const off = { installed: false, loggedIn: false }
- const s = { engines: { claude: off, codex: { installed: true, loggedIn: true, route: 'plan' }, opencode: off, pi: off, gemini: off } } as unknown as Pick<Settings, 'engines'>
+ const s = { engines: { claude: off, codex: { installed: true, loggedIn: true, route: 'plan' }, opencode: off, pi: off, gemini: off, cursor: off } } as unknown as Pick<Settings, 'engines'>
expect(availableModels(s, { codex: ['gpt-6-astra', 'gpt-5.6-luna'] })).toEqual([
{ id: 'codex:gpt-6-astra', label: 'Codex · GPT-6-Astra' },
{ id: 'gpt-5.6-luna', label: 'Codex · GPT-5.6 Luna' }
@@ -60,4 +60,13 @@ describe("Tuca's list of models", () => {
{ id: 'gemini:gemini-2.5-flash', label: 'Gemini CLI · gemini-2.5-flash' }
])
})
+
+ it('includes the Cursor models when the Cursor CLI is signed in', () => {
+ const off = { installed: false, loggedIn: false }
+ const s = { engines: { claude: off, codex: off, opencode: off, pi: off, gemini: off, cursor: { installed: true, loggedIn: true, route: 'providers' } } } as unknown as Pick<Settings, 'engines'>
+ expect(availableModels(s, { cursor: ['auto', 'claude-opus-5-5-high'] })).toEqual([
+ { id: 'cursor:auto', label: 'Cursor CLI · auto' },
+ { id: 'cursor:claude-opus-5-5-high', label: 'Cursor CLI · claude-opus-5-5-high' }
+ ])
+ })
})
diff --git a/test/computer.test.ts b/test/computer.test.ts
index 6afee8f..464c61e 100644
--- a/test/computer.test.ts
+++ b/test/computer.test.ts
@@ -100,7 +100,7 @@ const hasDocker = ((): boolean => {
describe.skipIf(!hasDocker)('computer (Docker)', () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const agent = (id: string, handle: string, computer: boolean): Agent => ({
id, name: handle, handle, role: '', color: 'sky', instructions: '', modelId: 'sonnet', effort: 'low', limit: 1_000_000, used: 0, grants: {}, memory: 'read', computer, archived: false
})
@@ -201,7 +201,7 @@ describe.skipIf(!hasDocker)('computer (Docker)', () => {
it('only agents with a computer get the tools', async () => {
const gateway = new Gateway()
await gateway.start()
- const engines: Record<EngineId, Engine> = { claude: fakeEngine('claude', { delayMs: 1 }), codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude: fakeEngine('claude', { delayMs: 1 }), codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const runner = new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), gateway, computers })
await runner.send('d1', 'rode `echo oi do computador`')
await runner.send('d2', 'rode `echo oi do computador`')
diff --git a/test/engines.test.ts b/test/engines.test.ts
index c885497..b7e6fff 100644
--- a/test/engines.test.ts
+++ b/test/engines.test.ts
@@ -1,11 +1,12 @@
-import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
-import { tmpdir } from 'node:os'
-import { join } from 'node:path'
+import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { homedir, tmpdir } from 'node:os'
+import { dirname, join } from 'node:path'
import { describe, expect, it } from 'vitest'
import type { Parser } from '../src/core/engines/cli'
import { claudeArgs, claudeInput, claudeParser, userProvider } from '../src/core/engines/claude'
import { CODEX_DISABLED_FEATURES, codexArgs, codexEnv, codexParser, userCodexProvider } from '../src/core/engines/codex'
import { geminiArgs, geminiEnv, geminiHome, geminiParser } from '../src/core/engines/gemini'
+import { cursorArgs, cursorCleanup, cursorConfig, cursorEngine, cursorHomeEnv, cursorParser, cursorSignedIn, cursorSlug, cursorWorkerSocket, cursorTurnDirs, imageRefused, parseCursorModels } from '../src/core/engines/cursor'
import { customModel, modelInfo, usable } from '../src/shared/types'
import type { EngineEvent } from '../src/core/engines/types'
@@ -302,3 +303,243 @@ describe('Gemini config', () => {
expect(a).not.toBe(b)
})
})
+
+describe('Cursor stream', () => {
+ const answer = 'Vou consultar a hora no servidor tucano e a versão LTS atual do Node.js.\n\nSão 21:58 no Tucano e a LTS atual do Node.js é a 26.13.0 (Lithium).\n\n— Lia'
+
+ it('streams the deltas once (not the whole message that repeats them), with paragraphs around tool calls', () => {
+ const events = feed(cursorParser(), fixture('cursor-stream.jsonl'))
+ expect(text(events)).toBe(answer)
+ expect(events.find((e) => e.type === 'done')).toMatchObject({ type: 'done', text: answer })
+ })
+
+ it('reports the usage the CLI gives, cache reads and writes counted as sent', () => {
+ const done = feed(cursorParser(), fixture('cursor-stream.jsonl')).find((e) => e.type === 'done')
+ expect(done).toMatchObject({ usage: { inputTokens: 12277 + 31744, cacheReadTokens: 31744, outputTokens: 338 } })
+ })
+
+ it("reports a web search that ran, not the gateway's tools", () => {
+ const web = feed(cursorParser(), fixture('cursor-stream.jsonl')).filter((e) => e.type === 'web')
+ expect(web).toEqual([{ type: 'web', action: 'search', detail: 'Node.js current LTS version' }])
+ })
+
+ it("doesn't report a web read the permissions refused", () => {
+ const refused = '{"type":"tool_call","subtype":"completed","tool_call":{"webFetchToolCall":{"args":{"url":"https://nodejs.org"},"result":{"permissionDenied":{}}}}}'
+ const ran = '{"type":"tool_call","subtype":"completed","tool_call":{"webFetchToolCall":{"args":{"url":"https://nodejs.org"},"result":{"success":{}}}}}'
+ expect(feed(cursorParser(), [refused]).filter((e) => e.type === 'web')).toEqual([])
+ expect(feed(cursorParser(), [ran]).filter((e) => e.type === 'web')).toEqual([{ type: 'web', action: 'fetch', detail: 'https://nodejs.org' }])
+ })
+
+ it('takes the whole message when no deltas came', () => {
+ const whole = '{"type":"assistant","message":{"content":[{"type":"text","text":"OK"}]},"model_call_id":"m1","timestamp_ms":1}'
+ const last = '{"type":"assistant","message":{"content":[{"type":"text","text":"OK"}]}}'
+ const result = '{"type":"result","subtype":"success","is_error":false,"result":"OK","usage":{"inputTokens":10,"outputTokens":1,"cacheReadTokens":0,"cacheWriteTokens":0}}'
+ const events = feed(cursorParser(), [whole, last, result])
+ expect(text(events)).toBe('OK')
+ expect(events.find((e) => e.type === 'done')).toMatchObject({ text: 'OK' })
+ })
+
+ it('estimates the usage when the CLI gives none: the characters sent and received, about 4 a token, the sent part doubled', () => {
+ const delta = '{"type":"assistant","message":{"content":[{"type":"text","text":"12345678"}]},"timestamp_ms":1}'
+ const result = '{"type":"result","subtype":"success","is_error":false,"result":"12345678"}'
+ const done = feed(cursorParser(400), [delta, result]).find((e) => e.type === 'done')
+ expect(done).toMatchObject({ usage: { inputTokens: 200, cacheReadTokens: 0, outputTokens: 2 } })
+ })
+
+ it('turns an error result into an error, and an exit without a result too', () => {
+ const bad = '{"type":"result","subtype":"error","is_error":true,"result":"You have hit your usage limit"}'
+ expect(feed(cursorParser(), [bad])).toEqual([{ type: 'error', message: 'You have hit your usage limit' }])
+ const gone = feed(cursorParser(), ['{"type":"system","subtype":"init"}'], 1, 'boom\nnot logged in')
+ expect(gone).toHaveLength(1)
+ expect((gone[0] as { message: string }).message).toContain('not logged in')
+ })
+})
+
+describe('Cursor config', () => {
+ it('runs headless with deltas, the prompt on stdin, the model named, and neither --force nor --approve-mcps', () => {
+ const args = cursorArgs({ model: 'auto' })
+ expect(args).toEqual(['-p', '--output-format', 'stream-json', '--stream-partial-output', '--trust', '--model', 'auto'])
+ expect(args).not.toContain('--force')
+ expect(args).not.toContain('--yolo')
+ expect(args).not.toContain('--approve-mcps')
+ })
+
+ it('attaches the images that exist with --image, once per file', () => {
+ const dir = mkdtempSync(join(tmpdir(), 'tucano-cursor-img-'))
+ const a = join(dir, 'a.png')
+ const b = join(dir, 'b.jpg')
+ writeFileSync(a, 'x')
+ writeFileSync(b, 'y')
+ const images = [
+ { block: 0, path: a, mime: 'image/png' },
+ { block: 1, path: join(dir, 'gone.png'), mime: 'image/png' },
+ { block: 2, path: b, mime: 'image/jpeg' }
+ ]
+ expect(cursorArgs({ model: 'auto', images }).slice(7)).toEqual(['--image', a, '--image', b])
+ })
+
+ it('knows when the CLI refused --image itself', () => {
+ expect(imageRefused("Cursor exited without a reply (code 1).\nerror: unknown option '--image'")).toBe(true)
+ expect(imageRefused("error: unknown option '--imagex'")).toBe(false)
+ expect(imageRefused('You have hit your usage limit')).toBe(false)
+ expect(imageRefused('Could not read --image file')).toBe(false)
+ })
+
+
+ it("denies Cursor's own files and shell, and allows only the gateway", () => {
+ const c = cursorConfig({ mcpUrl: 'http://127.0.0.1:1/mcp/x', web: false }) as { permissions: { allow: string[]; deny: string[] }; autoAcceptWebSearch: boolean }
+ expect(c.permissions.allow).toEqual(['Mcp(tucano:*)'])
+ expect(c.permissions.deny).toEqual(['Read(**)', 'Write(**)', 'Shell(*)', 'WebFetch(*)'])
+ expect(c.autoAcceptWebSearch).toBe(false)
+ })
+
+ it('lets the web in only when the agent has it', () => {
+ const c = cursorConfig({ mcpUrl: undefined, web: true }) as { permissions: { allow: string[]; deny: string[] }; autoAcceptWebSearch: boolean }
+ expect(c.permissions.allow).toEqual(['WebFetch(*)'])
+ expect(c.permissions.deny).toEqual(['Read(**)', 'Write(**)', 'Shell(*)'])
+ expect(c.autoAcceptWebSearch).toBe(true)
+ })
+
+ it('gives each turn its own folder: the config, the instructions as AGENTS.md, the gateway as the only MCP server', () => {
+ const appDir = mkdtempSync(join(tmpdir(), 'cu-'))
+ const a = cursorTurnDirs(appDir, { system: 'You are Iris.', mcpUrl: 'http://127.0.0.1:1/mcp/x', web: false })
+ const b = cursorTurnDirs(appDir, { system: 'You are Theo.', mcpUrl: undefined, web: false })
+ expect(a.root).not.toBe(b.root)
+ expect(a.root.startsWith(appDir)).toBe(true)
+ expect(a.data.startsWith(a.root)).toBe(true)
+ expect(readFileSync(join(a.workspace, 'AGENTS.md'), 'utf8')).toBe('You are Iris.')
+ expect(JSON.parse(readFileSync(join(a.workspace, '.cursor', 'mcp.json'), 'utf8'))).toEqual({ mcpServers: { tucano: { url: 'http://127.0.0.1:1/mcp/x' } } })
+ expect(JSON.parse(readFileSync(join(a.config, 'cli-config.json'), 'utf8')).permissions.deny).toContain('Shell(*)')
+ expect(() => readFileSync(join(b.workspace, '.cursor', 'mcp.json'))).toThrow()
+ })
+
+ // The CLI reads hooks, plugins and skills from the home folder: a turn gets one of its own.
+ it("gives each turn an empty home, with only the way to the person's login", () => {
+ const real = join('/h', 'eduar')
+ const turnHome = join('/t', 'home')
+ const app = join('/app', 'cursor')
+ const mac = cursorHomeEnv(turnHome, app, 'mac', real, {})
+ expect(mac).toEqual({ HOME: turnHome, NODE_COMPILE_CACHE: join(app, 'compile-cache') })
+ // Linux: the login is a file under XDG_CONFIG_HOME, which stays the person's.
+ expect(cursorHomeEnv(turnHome, app, 'linux', real, {})['XDG_CONFIG_HOME']).toBe(join(real, '.config'))
+ expect(cursorHomeEnv(turnHome, app, 'linux', real, { XDG_CONFIG_HOME: '/x/conf' })['XDG_CONFIG_HOME']).toBe('/x/conf')
+ expect(cursorHomeEnv(turnHome, app, 'linux', real, {})['HOME']).toBe(turnHome)
+ // Windows: the home is USERPROFILE; the login is under %APPDATA%, which stays the person's.
+ const win = cursorHomeEnv(turnHome, app, 'windows', real, { APPDATA: 'C:/Users/e/AppData/Roaming' })
+ expect(win['USERPROFILE']).toBe(turnHome)
+ expect(win['APPDATA']).toBe('C:/Users/e/AppData/Roaming')
+ expect(win['LOCALAPPDATA']).toBe(join(real, 'AppData', 'Local'))
+ expect(cursorHomeEnv(turnHome, app, 'windows', real, {})['APPDATA']).toBe(join(real, 'AppData', 'Roaming'))
+ })
+
+ // Symlinks need privileges on Windows; the link is only made on macOS.
+ it.skipIf(process.platform === 'win32')('links only the keychain into the home on macOS, and the cleanup leaves what it points to', async () => {
+ const real = mkdtempSync(join(tmpdir(), 'cu-real-'))
+ mkdirSync(join(real, 'Library', 'Keychains'), { recursive: true })
+ writeFileSync(join(real, 'Library', 'Keychains', 'login.keychain-db'), 'secret')
+ mkdirSync(join(real, '.claude'), { recursive: true })
+ const appDir = mkdtempSync(join(tmpdir(), 'cu-'))
+ const dirs = cursorTurnDirs(appDir, { system: 'x', mcpUrl: undefined, web: false }, 'mac', real)
+ expect(dirs.home.startsWith(dirs.root)).toBe(true)
+ expect(readdirSync(dirs.home)).toEqual(['Library'])
+ expect(readdirSync(join(dirs.home, 'Library'))).toEqual(['Keychains'])
+ expect(lstatSync(join(dirs.home, 'Library', 'Keychains')).isSymbolicLink()).toBe(true)
+ expect(readFileSync(join(dirs.home, 'Library', 'Keychains', 'login.keychain-db'), 'utf8')).toBe('secret')
+ await cursorCleanup(dirs)
+ expect(existsSync(dirs.root)).toBe(false)
+ expect(readFileSync(join(real, 'Library', 'Keychains', 'login.keychain-db'), 'utf8')).toBe('secret')
+ // Elsewhere the home stays empty.
+ const linux = cursorTurnDirs(appDir, { system: 'x', mcpUrl: undefined, web: false }, 'linux', real)
+ expect(readdirSync(linux.home)).toEqual([])
+ })
+
+ it('names a workspace the way the CLI does', () => {
+ expect(cursorSlug('/Users/x/Library/Application Support/Tucano/cursor/ab12/workspace')).toBe('Users-x-Library-Application-Support-Tucano-cursor-ab12-workspace')
+ })
+
+ // The worker's socket is a Unix socket: on Windows the turn doesn't look for it.
+ it.skipIf(process.platform === 'win32')('finds its worker socket the way the CLI does', () => {
+ // short: under <data>/projects
+ expect(cursorWorkerSocket('/t/w', '/t/d')).toBe(join('/t/d', 'projects', 't-w', 'worker.sock'))
+ // long: cut to 83 characters plus a hash (the CLI's rule, checked against a real run)
+ const ws = '/Users/eduardo/Library/Application Support/Tucano/cursor/0011223344556677/workspace'
+ const sock = cursorWorkerSocket(ws, '/Users/eduardo/Library/Application Support/Tucano/cursor/0011223344556677/d')
+ expect(sock.startsWith('/Users/eduardo/Library/Application Support/Tucano/cursor/0011223344556677/d/Users-')).toBe(true)
+ expect(sock).toMatch(/-[0-9a-f]{7}\/worker\.sock$/)
+ expect(sock.length).toBeLessThanOrEqual(83 + 8 + '/worker.sock'.length)
+ })
+
+ it('reads the model list and the login', () => {
+ expect(parseCursorModels('Available models\n\nauto - Auto (default)\ngpt-5.3-codex - Codex 5.3\nclaude-opus-5-5-high - Claude Opus 5.5 1M High\n\nTip: use --model')).toEqual(['auto', 'gpt-5.3-codex', 'claude-opus-5-5-high'])
+ expect(cursorSignedIn('✓ Logged in as [email protected]', {})).toBe(true)
+ expect(cursorSignedIn('Not logged in', {})).toBe(false)
+ expect(cursorSignedIn('Not logged in', { CURSOR_API_KEY: 'k' })).toBe(true)
+ })
+})
+
+describe.skipIf(process.platform === 'win32')('Cursor engine with images', () => {
+ // A stand-in CLI: it takes `mcp enable`, and answers with what it was given.
+ const fakeCli = (takesImages: boolean): string => {
+ const dir = mkdtempSync(join(tmpdir(), 'tucano-cursor-cli-'))
+ const bin = join(dir, 'cursor-agent')
+ writeFileSync(
+ bin,
+ `#!/bin/sh
+[ "$1" = mcp ] && exit 0
+images=0
+for a in "$@"; do [ "$a" = --image ] && images=$((images+1)); done
+${takesImages ? '' : `[ $images -gt 0 ] && { echo "error: unknown option '--image'" >&2; exit 1; }`}
+note=no
+cat | grep -q 'Tucano:' && note=yes
+echo '{"type":"result","subtype":"success","is_error":false,"result":"images='"$images"' note='"$note"'","usage":{"inputTokens":1,"outputTokens":1}}'
+`,
+ { mode: 0o755 }
+ )
+ return bin
+ }
+ const reply = async (bin: string, images: { block: number; path: string; mime: string }[]): Promise<EngineEvent[]> => {
+ const app = mkdtempSync(join(tmpdir(), 'tucano-cursor-app-'))
+ const turn = { model: 'auto', effort: 'medium' as const, system: 'You are Iris.', prompt: 'What is in the picture?', images, cwd: app, signal: new AbortController().signal }
+ const out: EngineEvent[] = []
+ for await (const ev of cursorEngine(() => bin, app).run(turn)) out.push(ev)
+ return out
+ }
+ const picture = (): { block: number; path: string; mime: string }[] => {
+ const p = join(mkdtempSync(join(tmpdir(), 'tucano-cursor-pic-')), 'p.png')
+ writeFileSync(p, 'x')
+ return [{ block: 0, path: p, mime: 'image/png' }]
+ }
+
+ it("runs the CLI with the turn's home, and the turn's folder goes afterwards", async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'tucano-cursor-cli-'))
+ const bin = join(dir, 'cursor-agent')
+ writeFileSync(bin, `#!/bin/sh\n[ "$1" = mcp ] && exit 0\ncat >/dev/null\necho '{"type":"result","subtype":"success","is_error":false,"result":"'"$HOME|$CURSOR_CONFIG_DIR"'","usage":{"inputTokens":1,"outputTokens":1}}'\n`, { mode: 0o755 })
+ const app = mkdtempSync(join(tmpdir(), 'tucano-cursor-app-'))
+ const turn = { model: 'auto', effort: 'medium' as const, system: 'You are Iris.', prompt: 'Hi', cwd: app, signal: new AbortController().signal }
+ const out: EngineEvent[] = []
+ for await (const ev of cursorEngine(() => bin, app).run(turn)) out.push(ev)
+ const done = out.find((e) => e.type === 'done')
+ const [home, config] = (done && done.type === 'done' ? done.text : '').split('|')
+ expect(home).not.toBe(homedir())
+ expect(home!.startsWith(app)).toBe(true)
+ expect(home).toBe(join(dirname(config!), 'home'))
+ expect(existsSync(dirname(config!))).toBe(false)
+ })
+
+ it('sends the images along when the CLI takes them', async () => {
+ const done = (await reply(fakeCli(true), picture())).find((e) => e.type === 'done')
+ expect(done && done.type === 'done' && done.text).toBe('images=1 note=no')
+ })
+
+ it('runs again without them, and tells the agent, when the CLI refuses --image', async () => {
+ const events = await reply(fakeCli(false), picture())
+ expect(events.filter((e) => e.type === 'error')).toEqual([])
+ const done = events.find((e) => e.type === 'done')
+ expect(done && done.type === 'done' && done.text).toBe('images=0 note=yes')
+ })
+
+ it('runs once, without --image, when there are no images', async () => {
+ const done = (await reply(fakeCli(false), [])).find((e) => e.type === 'done')
+ expect(done && done.type === 'done' && done.text).toBe('images=0 note=no')
+ })
+})
diff --git a/test/fixtures/cursor-stream.jsonl b/test/fixtures/cursor-stream.jsonl
new file mode 100644
index 0000000..301c403
--- /dev/null
+++ b/test/fixtures/cursor-stream.jsonl
@@ -0,0 +1,67 @@
+{"type":"system","subtype":"init","apiKeySource":"login","cwd":"/tmp/tucano/cursor/0011223344556677/workspace","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","model":"Auto","permissionMode":"default"}
+{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Diga em uma frase que vai consultar. Chame buscar_hora no servidor tucano. Depois busque na web a versão LTS atual do Node.js. Responda com as duas coisas em uma frase."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6"}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"V"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593975}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"ou"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593975}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" consultar"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" a"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" hora"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" no"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" servidor"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" t"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"uc"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"ano"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" e"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593976}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" a"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" versão"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" L"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"TS"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" atual"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" do"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" Node"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":".js"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593977}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Vou consultar a hora no servidor tucano e a versão LTS atual do Node.js."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-0-8al4","timestamp_ms":1793667593979}
+{"type":"tool_call","subtype":"started","call_id":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0","tool_call":{"getMcpToolsToolCall":{"args":{"server":"tucano","toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0"}},"hookAdditionalContexts":[],"toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0","startedAtMs":"1793667593789"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-0-8al4","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667593979}
+{"type":"tool_call","subtype":"started","call_id":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1","tool_call":{"getMcpToolsToolCall":{"args":{"server":"cursor","toolName":"WebSearch","toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1"}},"hookAdditionalContexts":[],"toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1","startedAtMs":"1793667593900"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-0-8al4","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667594105}
+{"type":"tool_call","subtype":"completed","call_id":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1","tool_call":{"getMcpToolsToolCall":{"args":{"server":"cursor","toolName":"WebSearch","toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1"},"result":{"success":{"content":"{\"tool\":\"WebSearch\",\"description\":\"Search web for real-time info on any topic; use for up-to-date facts not in training "}}},"hookAdditionalContexts":[],"toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-1\nfc_99bd18b5-f834-9059-81ee-433533f046ba_1","startedAtMs":"1793667593900","completedAtMs":"1793667593904"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-0-8al4","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667594106}
+{"type":"tool_call","subtype":"completed","call_id":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0","tool_call":{"getMcpToolsToolCall":{"args":{"server":"tucano","toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0"},"result":{"success":{"content":"{\"mode\":\"namespace\",\"namespace\":\"tucano\",\"namespaceStatus\":\"ready\",\"tools\":[{\"tool\":\"buscar_hora\",\"description\":\"Returns"}}},"hookAdditionalContexts":[],"toolCallId":"call-ddd23750-228d-4b88-8975-2282f86c7b46-0\nfc_99bd18b5-f834-9059-81ee-433533f046ba_0","startedAtMs":"1793667593789","completedAtMs":"1793667594064"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-0-8al4","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667594235}
+{"type":"tool_call","subtype":"started","call_id":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","tool_call":{"mcpToolCall":{"args":{"name":"tucano-buscar_hora","args":{},"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","providerIdentifier":"tucano","toolName":"buscar_hora","smartModeApprovalOnly":false,"skipApproval":false,"serverIdentifier":"tucano","symbolicPathArguments":[],"argumentsRepaired":false},"description":"Consulta a hora atual no servidor Tucano"},"hookAdditionalContexts":[],"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","startedAtMs":"1793667595567"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-1-lck9","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667595626}
+{"type":"tool_call","subtype":"completed","call_id":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","tool_call":{"mcpToolCall":{"args":{"name":"tucano-buscar_hora","args":{},"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","providerIdentifier":"tucano","toolName":"buscar_hora","smartModeApprovalOnly":false,"skipApproval":false,"serverIdentifier":"tucano","symbolicPathArguments":[],"argumentsRepaired":false},"result":{"success":{"content":[{"text":{"text":"São 21:58 no Tucano."}}],"isError":false,"systemReminders":[]}},"description":"Consulta a hora atual no servidor Tucano"},"hookAdditionalContexts":[],"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-2\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_0","startedAtMs":"1793667595567","completedAtMs":"1793667595899"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-1-lck9","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667595956}
+{"type":"tool_call","subtype":"started","call_id":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1","tool_call":{"webSearchToolCall":{"args":{"searchTerm":"Node.js current LTS version","toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1"}},"hookAdditionalContexts":[],"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1","startedAtMs":"1793667596039"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-1-lck9","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667596098}
+{"type":"interaction_query","subtype":"request","query_type":"webSearchRequestQuery","query":{"id":0,"webSearchRequestQuery":{"args":{"searchTerm":"Node.js current LTS version","toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1"}}},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667596100}
+{"type":"interaction_query","subtype":"response","query_type":"webSearchRequestQuery","response":{"id":0,"webSearchRequestResponse":{"approved":{}}},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667596101}
+{"type":"tool_call","subtype":"completed","call_id":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1","tool_call":{"webSearchToolCall":{"args":{"searchTerm":"Node.js current LTS version","toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1"},"result":{"success":{"references":[{"title":"Web search results","url":"","chunk":"1. [Node.js 26.13.0 (LTS)](https://nodejs.org/en/blog/release/v26.13.0)"}]}}},"hookAdditionalContexts":[],"toolCallId":"call-f9ca70cb-a3ad-4220-9d7f-314a00f5c325-3\nfc_bcd5ec7b-b5a3-95de-b945-fa7c3176d3b8_1","startedAtMs":"1793667596039","completedAtMs":"1793667598946"},"model_call_id":"73688999-50c7-4936-b72c-d1dc85127a6a-1-lck9","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667599003}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"São"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600707}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" "}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600707}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"21"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600707}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":":"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600707}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"58"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600707}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" no"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600771}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" T"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"uc"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"ano"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" e"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" a"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" L"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600772}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"TS"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600773}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" atual"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600803}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" do"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600803}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" Node"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600803}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":".js"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600803}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" é"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600804}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" a"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600804}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" "}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600860}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"26"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600860}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600860}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"13"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600860}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600862}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"0"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600862}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" ("}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600862}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Lith"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600862}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"ium"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600923}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":")."}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600923}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"\n\n"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600924}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"—"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600924}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" Lia"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","timestamp_ms":1793667600924}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"São 21:58 no Tucano e a LTS atual do Node.js é a 26.13.0 (Lithium).\n\n— Lia"}]},"session_id":"8a945d46-0817-49c4-bbca-29a086c814b6"}
+{"type":"result","subtype":"success","duration_ms":9999,"duration_api_ms":9999,"is_error":false,"result":"Vou consultar a hora no servidor tucano e a versão LTS atual do Node.js.São 21:58 no Tucano e a LTS atual do Node.js é a 26.13.0 (Lithium).\n\n— Lia","session_id":"8a945d46-0817-49c4-bbca-29a086c814b6","request_id":"73688999-50c7-4936-b72c-d1dc85127a6a","usage":{"inputTokens":12277,"outputTokens":338,"cacheReadTokens":31744,"cacheWriteTokens":0}}
diff --git a/test/github.test.ts b/test/github.test.ts
index 4dfe514..a383f04 100644
--- a/test/github.test.ts
+++ b/test/github.test.ts
@@ -121,7 +121,7 @@ describe('the proxy and the PR', () => {
it('abrir_pr becomes an approval; approved, the app opens the PR with the cost of the issue', async () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const gateway = new Gateway()
await gateway.start()
const claude: Engine = {
@@ -131,7 +131,7 @@ describe('the proxy and the PR', () => {
yield { type: 'done', text: 'ok', usage: { inputTokens: 1000, cacheReadTokens: 0, outputTokens: 10 } }
}
}
- const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, github: gh, computers: { call: async () => ({ result: { content: [] } }) } })
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'w-')), gateway, github: gh, computers: { call: async () => ({ result: { content: [] } }) } })
await r.send('c1', '@staff corrige a OAB-66')
await r.idle()
const [ap] = db.approvals()
diff --git a/test/governance.test.ts b/test/governance.test.ts
index b2dec50..8d6ac1f 100644
--- a/test/governance.test.ts
+++ b/test/governance.test.ts
@@ -66,7 +66,7 @@ const agent = (grant: GrantLevel): Agent => ({
function runner(plan: (turn: Turn, tools: string[]) => Plan, onDb: Db = db): Runner {
return new Runner({
db: onDb,
- engines: { claude: scripted(plan, seen), codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') },
+ engines: { claude: scripted(plan, seen), codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') },
settings: async () => settings,
emit: (e) => events.push(e),
workDir: join(dir, 'work'),
@@ -91,7 +91,7 @@ beforeEach(async () => {
db = new Db(join(dir, 'test.db'))
events = []
seen = { turns: [], tools: [], results: [] }
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
gateway = new Gateway()
await gateway.start()
connectors = new ConnectorManager({ db, secrets: new Secrets(db, plainCipher), emit: (e) => events.push(e), openUrl: () => {}, oauthCallbackUrl: () => gateway.url('/oauth/callback') })
@@ -323,7 +323,7 @@ describe('pausing and attributing work', () => {
db.createConversation({ id: 'c1', kind: 'channel', name: 'eng', members: ['a1', 'a2'] })
const r = new Runner({
db,
- engines: { claude: fakeEngine('claude', { delayMs: 1, reply: (t) => (t.prompt.includes('Theo · agente') ? 'feito' : '@theo dá uma olhada') }), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') },
+ engines: { claude: fakeEngine('claude', { delayMs: 1, reply: (t) => (t.prompt.includes('Theo · agente') ? 'feito' : '@theo dá uma olhada') }), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') },
settings: async () => settings,
emit: () => {},
workDir: join(dir, 'work')
diff --git a/test/harness.test.ts b/test/harness.test.ts
index ece7d67..89285d1 100644
--- a/test/harness.test.ts
+++ b/test/harness.test.ts
@@ -5,7 +5,7 @@ import { startsPicked } from '../src/shared/types'
import type { EngineId, EngineStatus } from '../src/shared/types'
const ready: EngineStatus = { installed: true, loggedIn: true, route: 'plan' }
-const engines: Record<EngineId, EngineStatus> = { claude: ready, codex: ready, opencode: { ...ready, route: 'providers' }, pi: { ...ready, route: 'providers' }, gemini: { ...ready, route: 'providers' } }
+const engines: Record<EngineId, EngineStatus> = { claude: ready, codex: ready, opencode: { ...ready, route: 'providers' }, pi: { ...ready, route: 'providers' }, gemini: { ...ready, route: 'providers' }, cursor: { ...ready, route: 'providers' } }
describe('harnesses', () => {
it('defaults the pick to the harnesses that can actually run', () => {
diff --git a/test/jev.test.ts b/test/jev.test.ts
index 5fe6719..2347803 100644
--- a/test/jev.test.ts
+++ b/test/jev.test.ts
@@ -64,7 +64,7 @@ describe('in a channel', () => {
let settings: Settings
const engines = (): Record<EngineId, Engine> => {
const base = fakeEngine('claude', { delayMs: 1 })
- return { claude: { id: 'claude', run: (t) => (t.model === 'haiku' && routerTurns++, base.run(t)) }, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ return { claude: { id: 'claude', run: (t) => (t.model === 'haiku' && routerTurns++, base.run(t)) }, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
}
const runner = (f: typeof fetch, key: string | undefined): Runner =>
new Runner({ db, engines: engines(), settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), jev: { key: async () => key, fetch: f } })
@@ -73,7 +73,7 @@ describe('in a channel', () => {
beforeEach(() => {
db = new Db(join(mkdtempSync(join(tmpdir(), 'ad-jev-')), 'test.db'))
routerTurns = 0
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'jev', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'jev', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
db.saveAgent(lia)
db.saveAgent(nina)
db.createConversation({ id: 'c1', kind: 'channel', name: 'eng', members: ['a1', 'a2'] })
diff --git a/test/limits.test.ts b/test/limits.test.ts
index fc8f21d..d8c7185 100644
--- a/test/limits.test.ts
+++ b/test/limits.test.ts
@@ -37,7 +37,7 @@ let notes: string[]
let bash: (command: string) => CallToolResult // what the agent's "computer" answers
const runner = (claude: Engine): Runner => {
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const computers = { call: async (_a: Agent, _n: string, args: Record<string, unknown>) => ({ result: bash(String(args['command'])) }) }
return new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), gateway, computers, notify: (title) => notes.push(title) })
}
@@ -46,7 +46,7 @@ const labels = () => reply().run!.steps.map((s) => s.label)
beforeEach(async () => {
db = new Db(join(mkdtempSync(join(tmpdir(), 'ad-limits-')), 'test.db'))
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
notes = []
bash = () => textResult('ok')
db.saveAgent(agent())
@@ -234,7 +234,7 @@ describe('web', () => {
describe('keeping the Mac awake', () => {
it('says when replies start and when the last one ends', async () => {
const busy: boolean[] = []
- const r = new Runner({ db, engines: { claude: fakeEngine('claude', { delayMs: 5 }), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), onBusy: (b) => busy.push(b) })
+ const r = new Runner({ db, engines: { claude: fakeEngine('claude', { delayMs: 5 }), codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), onBusy: (b) => busy.push(b) })
db.saveAgent(agent({ id: 'a2', handle: 'theo', name: 'Theo' }))
db.createConversation({ id: 'c1', kind: 'channel', name: 'eng', members: ['a1', 'a2'] })
await r.send('c1', '@lia @theo oi')
diff --git a/test/memory-search.test.ts b/test/memory-search.test.ts
index 9d9b642..1453a13 100644
--- a/test/memory-search.test.ts
+++ b/test/memory-search.test.ts
@@ -43,7 +43,7 @@ describe('memories past the prompt budget', () => {
describe('buscar_memorias', () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const lia: Agent = { id: 'a1', name: 'Lia', handle: 'lia', role: '', color: 'sky', instructions: '', modelId: 'sonnet', effort: 'low', limit: 1_000_000, used: 0, grants: {}, memory: 'auto', computer: false, archived: false }
let db: Db
let gateway: Gateway
@@ -67,7 +67,7 @@ describe('buscar_memorias', () => {
yield { type: 'done', text: 'ok', usage: { inputTokens: 10, cacheReadTokens: 0, outputTokens: 1 } }
}
}
- const engines = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const workDir = mkdtempSync(join(tmpdir(), 'ad-work-'))
const memory = new Memories({ db, engines, settings: async () => settings, emit: () => {}, workDir })
runner = new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir, gateway, memory })
diff --git a/test/memory.test.ts b/test/memory.test.ts
index 2383b18..010617f 100644
--- a/test/memory.test.ts
+++ b/test/memory.test.ts
@@ -27,7 +27,7 @@ let runner: Runner
function setup(): void {
const base = fakeEngine('claude', { delayMs: 1 })
const claude: Engine = { id: 'claude', run: (t) => (turns.push(t), base.run(t)) }
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const emit = (_: CoreEvent): void => {}
const workDir = mkdtempSync(join(tmpdir(), 'ad-work-'))
memory = new Memories({ db, engines, settings: async () => settings, emit, workDir })
@@ -52,7 +52,7 @@ const active = (scope = 'me'): string[] => db.memories({ scope, state: 'active'
beforeEach(async () => {
db = new Db(join(mkdtempSync(join(tmpdir(), 'ad-db-')), 'test.db'))
turns = []
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
db.saveAgent(agent('a1', 'lia'))
db.saveAgent(agent('a2', 'theo'))
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
diff --git a/test/platform.test.ts b/test/platform.test.ts
index 217ca85..a5f1e56 100644
--- a/test/platform.test.ts
+++ b/test/platform.test.ts
@@ -236,6 +236,13 @@ describe('folders the CLIs install into', () => {
expect(withInstallDirs('/a', 'windows', home, env, () => false)).toBe('/a')
})
+ it("adds Cursor's install folder on Windows (%LOCALAPPDATA%\\cursor-agent)", () => {
+ const cursor = join('/h', 'eduar', 'AppData', 'Local', 'cursor-agent')
+ const withLocal = { ...env, LOCALAPPDATA: join('/h', 'eduar', 'AppData', 'Local') }
+ expect(withInstallDirs('/a', 'windows', home, withLocal, (p) => p === cursor)).toBe(['/a', cursor].join(delimiter))
+ expect(withInstallDirs('/a', 'mac', home, withLocal, (p) => p === cursor)).toBe('/a')
+ })
+
it("doesn't repeat a folder already there, whatever its case or trailing slash on Windows", () => {
expect(withInstallDirs([local.toUpperCase() + '/'].join(delimiter), 'windows', home, env, (p) => p === local)).toBe(local.toUpperCase() + '/')
expect(withInstallDirs(local, 'mac', home, env, () => true)).toBe(local)
diff --git a/test/reserve-account.test.ts b/test/reserve-account.test.ts
index 2e82056..e38184b 100644
--- a/test/reserve-account.test.ts
+++ b/test/reserve-account.test.ts
@@ -39,7 +39,7 @@ const personal: Account = { id: 'p1', engine: 'claude', name: 'Pessoal', loggedI
function runner(claude: Engine): Runner {
codexTurns = []
const codex = fakeEngine('codex', { delayMs: 1 })
- const engines: Record<EngineId, Engine> = { claude, codex: { id: 'codex', run: (t) => (codexTurns.push(t), codex.run(t)) }, opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: { id: 'codex', run: (t) => (codexTurns.push(t), codex.run(t)) }, opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
return new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-work-')), dataDir: data })
}
const reply = (): Message => db.messages().filter((m) => m.author.kind === 'agent').at(-1)!
@@ -47,7 +47,7 @@ const reply = (): Message => db.messages().filter((m) => m.author.kind === 'agen
beforeEach(() => {
data = mkdtempSync(join(tmpdir(), 'ad-data-'))
db = new Db(join(data, 'test.db'))
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt', accounts: [work, personal] }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt', accounts: [work, personal] }
db.saveAgent(agent())
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
})
diff --git a/test/reserve.test.ts b/test/reserve.test.ts
index 8ac4c73..7a470c5 100644
--- a/test/reserve.test.ts
+++ b/test/reserve.test.ts
@@ -38,14 +38,14 @@ let codex: ReturnType<typeof counted>
function runner(claude: Engine): Runner {
codex = counted(fakeEngine('codex', { delayMs: 1 }))
- const engines: Record<EngineId, Engine> = { claude, codex, opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex, opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
return new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-work-')) })
}
const reply = (): Message => db.messages().find((m) => m.author.kind === 'agent')!
beforeEach(() => {
db = new Db(join(mkdtempSync(join(tmpdir(), 'ad-db-')), 'test.db'))
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
db.saveAgent(agent({ fallbackModelId: 'gpt-5.6-luna' }))
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
})
diff --git a/test/routines.test.ts b/test/routines.test.ts
index 15e7cad..207591f 100644
--- a/test/routines.test.ts
+++ b/test/routines.test.ts
@@ -36,7 +36,7 @@ describe('schedule', () => {
describe('routines', () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const agent = (id: string, handle: string, extra: Partial<Agent> = {}): Agent => ({
id, name: handle[0]!.toUpperCase() + handle.slice(1), handle, role: '', color: 'sky', instructions: '', modelId: 'sonnet', effort: 'low', limit: 1_000_000, used: 0, grants: {}, memory: 'read', computer: false, archived: false, ...extra
})
@@ -60,7 +60,7 @@ describe('routines', () => {
clock = at(2026, 10, 19, 8, 0) // a Monday
const base = fakeEngine('claude', { delayMs: 1 })
const claude: Engine = { id: 'claude', run: (t) => (turns.push(t), base.run(t)) }
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const emit = (_: CoreEvent): void => {}
gateway = new Gateway()
await gateway.start()
@@ -282,7 +282,7 @@ describe('quiet hours', () => {
// A reply that fails is tried again in place, up to twice, and then stays failed.
describe('routine retries', () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const lia: Agent = { id: 'a1', name: 'Lia', handle: 'lia', role: '', color: 'sky', instructions: '', modelId: 'sonnet', effort: 'low', limit: 1_000_000, used: 0, grants: {}, memory: 'read', computer: false, archived: false }
let db: Db
@@ -313,7 +313,7 @@ describe('routine retries', () => {
else yield { type: 'done', text: 'Feito.', usage: { inputTokens: 1, cacheReadTokens: 0, outputTokens: 1 } }
}
}
- const engines: Record<EngineId, Engine> = { claude: flaky, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude: flaky, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
gateway = new Gateway()
await gateway.start()
routines = new Routines({
diff --git a/test/runner.test.ts b/test/runner.test.ts
index 11eb638..1475a0c 100644
--- a/test/runner.test.ts
+++ b/test/runner.test.ts
@@ -29,7 +29,7 @@ let settings: Settings
function runner(engine: Engine = fakeEngine('claude', { delayMs: 1 })): Runner {
claude = counted(engine)
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
return new Runner({ db, engines, settings: async () => settings, emit: (e) => events.push(e), workDir: mkdtempSync(join(tmpdir(), 'ad-work-')) })
}
@@ -38,7 +38,7 @@ const agentMessages = (): Message[] => db.messages().filter((m) => m.author.kind
beforeEach(() => {
db = new Db(join(mkdtempSync(join(tmpdir(), 'ad-db-')), 'test.db'))
events = []
- settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
db.saveAgent(agent('a1', 'lia'))
db.saveAgent(agent('a2', 'theo', { modelId: 'gpt-5.6-luna' }))
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
@@ -66,7 +66,7 @@ describe('Runner', () => {
it('keeps the images I attach and shows them to the agent with my message', async () => {
const data = mkdtempSync(join(tmpdir(), 'ad-data-'))
claude = counted(fakeEngine('claude', { delayMs: 1 }))
- const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: (e) => events.push(e), workDir: mkdtempSync(join(tmpdir(), 'ad-work-')), dataDir: data })
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: (e) => events.push(e), workDir: mkdtempSync(join(tmpdir(), 'ad-work-')), dataDir: data })
const png = Buffer.from('fake-png').toString('base64')
await r.send('d1', '', [{ name: 'Tela do checkout.png', mime: 'image/png', data: png }, { name: 'virus.exe', mime: 'application/x-msdownload', data: png }])
await r.idle()
@@ -270,7 +270,7 @@ describe('ask_user through the gateway', () => {
claude = counted(fakeEngine('claude', { delayMs: 1 }))
const r = new Runner({
db,
- engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') },
+ engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') },
settings: async () => settings,
emit: (e) => events.push(e),
workDir: mkdtempSync(join(tmpdir(), 'ad-work-')),
@@ -308,7 +308,7 @@ describe('browser handback', () => {
claude = counted(fakeEngine('claude', { delayMs: 1 }))
return new Runner({
db,
- engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') },
+ engines: { claude, codex: fakeEngine('codex', { delayMs: 1 }), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') },
settings: async () => settings,
emit: (e) => events.push(e),
workDir: mkdtempSync(join(tmpdir(), 'ad-work-')),
@@ -363,10 +363,23 @@ describe('an agent on Gemini', () => {
db.saveAgent(agent('a9', 'gi', { modelId: customModel('gemini', 'gemini/gemini-2.5-flash') }))
db.createConversation({ id: 'd9', kind: 'dm', name: 'a9', members: ['a9'] })
const gemini = counted(fakeEngine('gemini'))
- const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-gemini-')) })
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini, cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-gemini-')) })
await r.send('d9', 'oi')
await r.idle()
expect(gemini.turns.map((t) => t.model)).toEqual(['gemini/gemini-2.5-flash'])
expect(claude.turns).toHaveLength(0)
})
})
+
+describe('an agent on Cursor', () => {
+ it('runs on Cursor, not on Claude', async () => {
+ db.saveAgent(agent('a10', 'cu', { modelId: customModel('cursor', 'auto') }))
+ db.createConversation({ id: 'd10', kind: 'dm', name: 'a10', members: ['a10'] })
+ const cursor = counted(fakeEngine('cursor'))
+ const r = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-cursor-')) })
+ await r.send('d10', 'oi')
+ await r.idle()
+ expect(cursor.turns.map((t) => t.model)).toEqual(['auto'])
+ expect(claude.turns).toHaveLength(0)
+ })
+})
diff --git a/test/skills.test.ts b/test/skills.test.ts
index 5511143..c60affc 100644
--- a/test/skills.test.ts
+++ b/test/skills.test.ts
@@ -81,7 +81,7 @@ describe('in a reply', () => {
it('the agent sees its skills in the prompt, reads one, and proposes one', async () => {
skills.save({ ...recipe, agents: ['a1'] })
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
gateway = new Gateway()
await gateway.start()
const turns: Turn[] = []
@@ -97,7 +97,7 @@ describe('in a reply', () => {
yield { type: 'done', text: 'feito', usage: { inputTokens: 10, cacheReadTokens: 0, outputTokens: 1 } }
}
}
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const r = new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')), gateway, skills })
db.createConversation({ id: 'd1', kind: 'dm', name: 'a1', members: ['a1'] })
await r.send('d1', 'roda os testes')
diff --git a/test/triggers.test.ts b/test/triggers.test.ts
index 3a3ff97..64a2c09 100644
--- a/test/triggers.test.ts
+++ b/test/triggers.test.ts
@@ -11,7 +11,7 @@ import { eventItems, Routines } from '../src/core/routines'
import { Runner } from '../src/core/runs'
const ready = { installed: true, loggedIn: true }
-const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
const pm: Agent = { id: 'a1', name: 'PM', handle: 'pm', role: '', color: 'sky', instructions: '', modelId: 'sonnet', effort: 'low', limit: 1_000_000, used: 0, grants: {}, memory: 'read', computer: false, archived: false }
const issue = (n: number, title: string) => ({ id: `uuid-${n}`, identifier: `SIM-${n}`, title, description: `detalhes ${n}` })
@@ -37,7 +37,7 @@ beforeEach(() => {
issues = [issue(1, 'Lembrete duplicado')]
failing = undefined
const base = fakeEngine('claude', { delayMs: 1 })
- const engines: Record<EngineId, Engine> = { claude: { id: 'claude', run: (t) => (turns.push(t), base.run(t)) }, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude: { id: 'claude', run: (t) => (turns.push(t), base.run(t)) }, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
const connectors = {
list: () => [{ id: 'lin', name: 'Linear' } as Connector],
call: async () => (failing ? textResult(failing, true) : textResult(JSON.stringify({ issues }))) // the shape Linear's MCP answers with
@@ -149,7 +149,7 @@ describe('trying a failed routine run again by hand', () => {
} else yield* base.run(t)
}
}
- runner = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')) })
+ runner = new Runner({ db, engines: { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-w-')) })
}
const failedReply = () => db.messages().find((m) => m.author.kind === 'agent')!
diff --git a/test/tuca.test.ts b/test/tuca.test.ts
index 0883b2d..98eb892 100644
--- a/test/tuca.test.ts
+++ b/test/tuca.test.ts
@@ -36,7 +36,7 @@ describe('the Tuca proposals', () => {
describe('the Tuca in a conversation', () => {
const ready = { installed: true, loggedIn: true }
- const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
+ const settings: Settings = { workspaceName: 'Edu', context: '', engines: { claude: ready, codex: ready, opencode: ready, pi: ready, gemini: ready, cursor: ready }, routerModel: 'haiku', memoryModel: 'haiku', memoryLearning: 'approve', defaultLimit: 1000, approvalTtlHours: 24, theme: 'system', language: 'pt' }
let db: Db
let gateway: Gateway
let runner: Runner
@@ -49,7 +49,7 @@ describe('the Tuca in a conversation', () => {
systems.length = 0
const base = fakeEngine('claude', { delayMs: 1 })
const claude: Engine = { id: 'claude', run: (t) => (systems.push(t.system), base.run(t)) }
- const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini') }
+ const engines: Record<EngineId, Engine> = { claude, codex: fakeEngine('codex'), opencode: fakeEngine('opencode'), pi: fakeEngine('pi'), gemini: fakeEngine('gemini'), cursor: fakeEngine('cursor') }
runner = new Runner({ db, engines, settings: async () => settings, emit: () => {}, workDir: mkdtempSync(join(tmpdir(), 'ad-work-')), gateway, connectors: { list: () => [linear], call: async () => ({ content: [] }) } })
})