From bed254954c51285953ea99c2135dc77ba94e4e8c Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 27 May 2026 21:31:33 -0300 Subject: [PATCH] feat(mitm): add remaining targets (cursor/zed/claudeCode/openCode/trae) (F3) Declarative MitmTarget descriptors for the remaining agent identities: - cursor: api2.cursor.sh, OpenAI Chat Completions - zed: api.zed.dev, OpenAI Chat Completions - claude-code: api.anthropic.com, Anthropic Messages format - open-code: opencode.ai, OpenAI Chat Completions - trae: viability=investigating, host trae.invalid placeholder All entries point at lazy dynamic imports of their respective handlers in src/mitm/handlers/.ts (F3 handlers commit). --- src/mitm/targets/claudeCode.ts | 37 ++++++++++++++++++++++++++++++++++ src/mitm/targets/cursor.ts | 33 ++++++++++++++++++++++++++++++ src/mitm/targets/openCode.ts | 34 +++++++++++++++++++++++++++++++ src/mitm/targets/trae.ts | 32 +++++++++++++++++++++++++++++ src/mitm/targets/zed.ts | 32 +++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+) create mode 100644 src/mitm/targets/claudeCode.ts create mode 100644 src/mitm/targets/cursor.ts create mode 100644 src/mitm/targets/openCode.ts create mode 100644 src/mitm/targets/trae.ts create mode 100644 src/mitm/targets/zed.ts diff --git a/src/mitm/targets/claudeCode.ts b/src/mitm/targets/claudeCode.ts new file mode 100644 index 0000000000..e86db2df94 --- /dev/null +++ b/src/mitm/targets/claudeCode.ts @@ -0,0 +1,37 @@ +/** + * Claude Code (Anthropic CLI) — MITM target descriptor. + * + * Hosts: `api.anthropic.com`. + * Format: Anthropic Messages API on `/v1/messages`. + * + * NOTE: shares the host `api.anthropic.com` with the Kiro target. The DNS-routing + * tutorial therefore is opt-in: the user explicitly enables interception when + * they want Claude Code traffic captured. + */ +import type { MitmTarget } from "../types"; + +export const CLAUDE_CODE_TARGET: MitmTarget = { + id: "claude-code", + name: "Claude Code", + icon: "terminal", + color: "#D97706", + hosts: ["api.anthropic.com"], + port: 443, + endpointPatterns: ["/v1/messages"], + defaultModels: [ + { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5", alias: "claude-sonnet-4.5" }, + { id: "claude-opus-4.5", name: "Claude Opus 4.5", alias: "claude-opus-4.5" }, + ], + setupTutorial: { + steps: [ + "Install Claude Code (Anthropic CLI)", + "Install OmniRoute's root certificate", + "Enable DNS routing for Claude Code", + "Run `claude` — requests are now proxied via OmniRoute", + ], + detection: { command: "which claude", platform: "all" }, + }, + handler: () => + import("../handlers/claudeCode").then((m) => ({ default: m.ClaudeCodeHandler })), + riskNoticeKey: "providers.riskNotice.oauth", +}; diff --git a/src/mitm/targets/cursor.ts b/src/mitm/targets/cursor.ts new file mode 100644 index 0000000000..2c907208ec --- /dev/null +++ b/src/mitm/targets/cursor.ts @@ -0,0 +1,33 @@ +/** + * Cursor IDE — MITM target descriptor. + * + * Hosts: `api2.cursor.sh` (chat backend). + * Format: OpenAI-compatible Chat Completions on `/v1/chat/completions`. + */ +import type { MitmTarget } from "../types"; + +export const CURSOR_TARGET: MitmTarget = { + id: "cursor", + name: "Cursor IDE", + icon: "edit_note", + color: "#0EA5E9", + hosts: ["api2.cursor.sh"], + port: 443, + endpointPatterns: ["/v1/chat/completions"], + defaultModels: [ + { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5", alias: "claude-sonnet-4.5" }, + { id: "gpt-4o", name: "GPT-4o", alias: "gpt-4o" }, + ], + setupTutorial: { + steps: [ + "Install OmniRoute's root certificate", + "Enable DNS routing for Cursor", + "Restart Cursor IDE", + "Done — Cursor traffic now routes through OmniRoute", + ], + detection: { command: "which cursor", platform: "all" }, + }, + handler: () => + import("../handlers/cursor").then((m) => ({ default: m.CursorHandler })), + riskNoticeKey: "providers.riskNotice.oauth", +}; diff --git a/src/mitm/targets/openCode.ts b/src/mitm/targets/openCode.ts new file mode 100644 index 0000000000..206adc6b3e --- /dev/null +++ b/src/mitm/targets/openCode.ts @@ -0,0 +1,34 @@ +/** + * OpenCode — MITM target descriptor. + * + * Hosts: `opencode.ai`. + * Format: OpenAI-compatible Chat Completions on `/v1/chat/completions`. + */ +import type { MitmTarget } from "../types"; + +export const OPEN_CODE_TARGET: MitmTarget = { + id: "open-code", + name: "OpenCode", + icon: "code", + color: "#22D3EE", + hosts: ["opencode.ai"], + port: 443, + endpointPatterns: ["/v1/chat/completions"], + defaultModels: [ + { id: "gpt-4o", name: "GPT-4o", alias: "gpt-4o" }, + { id: "claude-3.5-sonnet", name: "Claude 3.5 Sonnet", alias: "claude-3.5-sonnet" }, + ], + setupTutorial: { + steps: [ + "Install the OpenCode CLI/IDE", + "Install OmniRoute's root certificate", + "Enable DNS routing for OpenCode", + "Restart OpenCode", + "Done — OpenCode traffic now routes through OmniRoute", + ], + detection: { command: "which opencode", platform: "all" }, + }, + handler: () => + import("../handlers/openCode").then((m) => ({ default: m.OpenCodeHandler })), + riskNoticeKey: "providers.riskNotice.oauth", +}; diff --git a/src/mitm/targets/trae.ts b/src/mitm/targets/trae.ts new file mode 100644 index 0000000000..8561f2c42a --- /dev/null +++ b/src/mitm/targets/trae.ts @@ -0,0 +1,32 @@ +/** + * Trae — MITM target descriptor (stub). + * + * Viability is still under investigation (see plan 11 §5). The hostname + * `trae.invalid` is a deliberate non-routable placeholder so the target is + * registered (UI can list it as "investigating") without ever matching real + * traffic. The concrete host list will be filled in once we confirm the + * upstream API surface. + */ +import type { MitmTarget } from "../types"; + +export const TRAE_TARGET: MitmTarget = { + id: "trae", + name: "Trae", + icon: "construction", + color: "#94A3B8", + hosts: ["trae.invalid"], + port: 443, + endpointPatterns: [], + defaultModels: [], + setupTutorial: { + steps: [ + "Trae integration is under investigation", + "Setup steps will be published once the upstream API is confirmed", + ], + detection: { command: "which trae", platform: "all" }, + }, + handler: () => + import("../handlers/trae").then((m) => ({ default: m.TraeHandler })), + riskNoticeKey: "providers.riskNotice.investigating", + viability: "investigating", +}; diff --git a/src/mitm/targets/zed.ts b/src/mitm/targets/zed.ts new file mode 100644 index 0000000000..8833501ec4 --- /dev/null +++ b/src/mitm/targets/zed.ts @@ -0,0 +1,32 @@ +/** + * Zed IDE — MITM target descriptor. + * + * Hosts: `api.zed.dev`. + * Format: OpenAI-compatible Chat Completions on `/v1/chat/completions`. + */ +import type { MitmTarget } from "../types"; + +export const ZED_TARGET: MitmTarget = { + id: "zed", + name: "Zed", + icon: "bolt", + color: "#EF4444", + hosts: ["api.zed.dev"], + port: 443, + endpointPatterns: ["/v1/chat/completions"], + defaultModels: [ + { id: "claude-3.5-sonnet", name: "Claude 3.5 Sonnet", alias: "claude-3.5-sonnet" }, + { id: "gpt-4o", name: "GPT-4o", alias: "gpt-4o" }, + ], + setupTutorial: { + steps: [ + "Install OmniRoute's root certificate", + "Enable DNS routing for Zed", + "Restart Zed", + "Done — Zed traffic now routes through OmniRoute", + ], + detection: { command: "which zed", platform: "all" }, + }, + handler: () => import("../handlers/zed").then((m) => ({ default: m.ZedHandler })), + riskNoticeKey: "providers.riskNotice.oauth", +};