YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: gateway image support for all providers + auto vision routing + clear cache button + device dropdown UX
Louis Beaumont2944974cbd36
diff --git a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx b/apps/screenpipe-app-tauri/components/settings/general-settings.tsxindex 525ab30a9..f000bf760 100644--- a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx+++ b/apps/screenpipe-app-tauri/components/settings/general-settings.tsx@@ -9,15 +9,33 @@ import { Switch } from "@/components/ui/switch";import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Label } from "@/components/ui/label";import { Separator } from "@/components/ui/separator";-import { Rocket, Moon, Sun, Monitor, FlaskConical, Shield, ExternalLink, Layers, RefreshCw, Undo2, MessageSquare } from "lucide-react";+import { Rocket, Moon, Sun, Monitor, FlaskConical, Shield, ExternalLink, Layers, RefreshCw, Undo2, MessageSquare, Trash2 } from "lucide-react";import { HelpTooltip } from "@/components/ui/help-tooltip";import { useToast } from "@/components/ui/use-toast";import { Button } from "@/components/ui/button";import { Settings } from "@/lib/hooks/use-settings";import { getVersion } from "@tauri-apps/api/app";-import { commands } from "@/lib/utils/tauri";+import { commands, CacheFile } from "@/lib/utils/tauri";import { UpdateBanner } from "@/components/update-banner";import { useIsEnterpriseBuild } from "@/lib/hooks/use-is-enterprise-build";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";++function formatBytes(bytes: number): string {+ if (bytes === 0) return "0 B";+ const k = 1024;+ const sizes = ["B", "KB", "MB", "GB"];+ const i = Math.floor(Math.log(bytes) / Math.log(k));+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];+}export default function GeneralSettings() {const isEnterprise = useIsEnterpriseBuild();@@ -27,6 +45,9 @@ export default function GeneralSettings() {const [availableVersions, setAvailableVersions] = useState<string[]>([]);const [isRollingBack, setIsRollingBack] = useState(false);const [showVersions, setShowVersions] = useState(false);+ const [cacheFiles, setCacheFiles] = useState<CacheFile[]>([]);+ const [showCacheDialog, setShowCacheDialog] = useState(false);+ const [isClearing, setIsClearing] = useState(false);useEffect(() => {getVersion().then(setCurrentVersion).catch(() => {});@@ -191,6 +212,121 @@ export default function GeneralSettings() {</div>+ <Separator />++ <div className="space-y-2">+ <Card className="border-border bg-card">+ <CardContent className="px-3 py-2.5">+ <div className="flex items-center justify-between">+ <div className="flex items-center space-x-2.5">+ <Trash2 className="h-4 w-4 text-muted-foreground shrink-0" />+ <div>+ <h3 className="text-sm font-medium text-foreground">Clear cache</h3>+ <p className="text-xs text-muted-foreground">+ Remove AI agent cache, old logs, and recovery artifacts+ </p>+ </div>+ </div>+ <Button+ variant="outline"+ size="sm"+ className="ml-4 h-7 text-xs"+ disabled={isClearing}+ onClick={async () => {+ try {+ const result = await commands.listCacheFiles();+ if (result.status === "error") throw new Error(result.error);+ if (result.data.length === 0) {+ toast({ title: "nothing to clean up" });+ return;+ }+ setCacheFiles(result.data);+ setShowCacheDialog(true);+ } catch (e: any) {+ toast({ title: "failed to scan cache", description: e?.toString(), variant: "destructive" });+ }+ }}+ >+ {isClearing ? "clearing..." : "scan"}+ </Button>+ </div>+ </CardContent>+ </Card>+ </div>++ <AlertDialog open={showCacheDialog} onOpenChange={setShowCacheDialog}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>clear cache?</AlertDialogTitle>+ <AlertDialogDescription asChild>+ <div className="space-y-2">+ <p>the following files will be deleted ({formatBytes(cacheFiles.reduce((s, f) => s + Number(f.size_bytes), 0))} total):</p>+ <ul className="text-xs space-y-1 max-h-48 overflow-y-auto">+ {cacheFiles.map((f) => (+ <li key={f.path} className="flex justify-between gap-2">+ <span className="truncate">{f.label}</span>+ <span className="text-muted-foreground shrink-0">{formatBytes(Number(f.size_bytes))}</span>+ </li>+ ))}+ </ul>+ <p className="text-xs text-muted-foreground">+ AI agent will reinstall automatically on next use.+ </p>+ </div>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={async () => {+ setIsClearing(true);+ setShowCacheDialog(false);+ try {+ const paths = cacheFiles.map((f) => f.path);+ const result = await commands.deleteCacheFiles(paths);+ if (result.status === "error") throw new Error(result.error);+ toast({+ title: "cache cleared",+ description: `freed ${formatBytes(Number(result.data))}`,+ });+ } catch (e: any) {+ toast({ title: "failed to clear cache", description: e?.toString(), variant: "destructive" });+ } finally {+ setIsClearing(false);+ setCacheFiles([]);+ }+ }}+ >+ delete all+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>++ {(+ <>+ <Separator />+ <div className="space-y-2">+ <p className="text-xs text-muted-foreground font-mono">dev tools</p>+ <Button+ variant="outline"+ size="sm"+ className="text-xs"+ onClick={async () => {+ try {+ await commands.resetOnboarding();+ await commands.showOnboardingWindow();+ } catch (e) {+ console.error("failed to open onboarding:", e);+ }+ }}+ >+ reset & open onboarding+ </Button>+ </div>+ </>+ )}+</div>);}diff --git a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsxindex dcfe48d49..cdbf77402 100644--- a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx@@ -70,7 +70,7 @@ import { PublishDialog } from "@/components/pipe-store";import posthog from "posthog-js";import { MemoizedReactMarkdown } from "@/components/markdown";import { useDeviceMonitor } from "@/lib/hooks/use-device-monitor";-import { Monitor, Wifi, WifiOff, ScanSearch } from "lucide-react";+import { Monitor, ScanSearch } from "lucide-react";const PIPE_CREATION_PROMPT = `create a screenpipe pipe that does the following.@@ -1250,92 +1250,89 @@ export function PipesSection() {return (<div className="space-y-4" data-testid="section-pipes">- <div className="flex items-center justify-between">- <div className="flex items-center gap-3">- <div>- <h3 className="text-lg font-medium">My Pipes</h3>- <p className="text-sm text-muted-foreground">- {pipeTypeFilter === "scheduled"- ? "scheduled agents that run on your screen data"- : "pipes you trigger manually"}- {" · "}- <a- href="https://docs.screenpi.pe/pipes"- target="_blank"- rel="noopener noreferrer"- className="inline-flex items-center gap-1 underline underline-offset-2 hover:text-foreground transition-colors"- >- docs- <ExternalLink className="h-3 w-3" />- </a>- </p>- </div>- {/* Device selector dropdown */}- {devices.length > 0 && (+ <div className="space-y-1">+ <div className="flex items-center justify-between">+ <h3 className="text-lg font-medium">My Pipes</h3>+ <div className="flex items-center gap-2">+ {/* Device selector dropdown — always visible */}<DropdownMenu><DropdownMenuTrigger asChild><Button variant="outline" size="sm" className="gap-1.5 h-7 text-xs"><Monitor className="h-3 w-3" />{selectedDevice? devices.find((d) => d.address === selectedDevice)?.label || selectedDevice- : "This Mac"}+ : "this device"}<ChevronDown className="h-3 w-3 opacity-50" /></Button></DropdownMenuTrigger>- <DropdownMenuContent align="start">+ <DropdownMenuContent align="end"><DropdownMenuItemonClick={() => { setSelectedDevice(null); setLoading(true); }}- className={cn(!selectedDevice && "font-medium")}+ className={cn("gap-2", !selectedDevice && "font-medium")}>- <Monitor className="h-3.5 w-3.5 mr-2" />- This Mac- {!selectedDevice && <Check className="h-3.5 w-3.5 ml-auto" />}+ <Monitor className="h-3.5 w-3.5" />+ <span className="flex-1">this device</span>+ <span className="h-2 w-2 rounded-full bg-green-500 shrink-0" />+ {!selectedDevice && <Check className="h-3.5 w-3.5 ml-1" />}</DropdownMenuItem>{devices.map((d) => (<DropdownMenuItemkey={d.address}onClick={() => { setSelectedDevice(d.address); setLoading(true); }}- className={cn(selectedDevice === d.address && "font-medium")}+ className={cn("gap-2", selectedDevice === d.address && "font-medium")}>- {d.status === "online" ? (- <Wifi className="h-3.5 w-3.5 mr-2 text-green-500" />- ) : (- <WifiOff className="h-3.5 w-3.5 mr-2 text-muted-foreground" />- )}- {d.label}- {selectedDevice === d.address && <Check className="h-3.5 w-3.5 ml-auto" />}+ <Monitor className="h-3.5 w-3.5" />+ <span className="flex-1">{d.label}</span>+ <span className={cn(+ "h-2 w-2 rounded-full shrink-0",+ d.status === "online" ? "bg-green-500" : d.status === "loading" ? "bg-yellow-500 animate-pulse" : "bg-muted-foreground/40"+ )} />+ {selectedDevice === d.address && <Check className="h-3.5 w-3.5 ml-1" />}</DropdownMenuItem>))}<DropdownMenuSeparator /><DropdownMenuItem onClick={() => discoverDevices()} disabled={discovering}><ScanSearch className="h-3.5 w-3.5 mr-2" />- {discovering ? "Scanning..." : "Discover devices"}+ {discovering ? "scanning..." : "discover devices"}</DropdownMenuItem></DropdownMenuContent></DropdownMenu>- )}- </div>- <div className="flex items-center gap-2">- <Button variant="outline" size="icon" className={`h-8 w-8 ${refreshing ? "pointer-events-none opacity-70" : ""}`} onClick={async () => {- if (refreshing) return;- setRefreshing(true);- await Promise.all([- fetchPipes(),- new Promise((r) => setTimeout(r, 2000)),- ]);- setRefreshing(false);- }}>- {refreshing ? <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" /> : <RefreshCw className="h-4 w-4" />}- </Button>- <Button variant="outline" size="sm" onClick={() => {- const url = new URL(window.location.href);- url.searchParams.set("section", "connections");- window.location.href = url.toString();- }}>- <Link className="h-4 w-4 mr-1" />- connections- </Button>+ <Button variant="outline" size="icon" className={`h-7 w-7 ${refreshing ? "pointer-events-none opacity-70" : ""}`} onClick={async () => {+ if (refreshing) return;+ setRefreshing(true);+ await Promise.all([+ fetchPipes(),+ new Promise((r) => setTimeout(r, 2000)),+ ]);+ setRefreshing(false);+ }}>+ {refreshing ? <Loader2 className="h-3.5 w-3.5 animate-spin text-muted-foreground" /> : <RefreshCw className="h-3.5 w-3.5" />}+ </Button>+ <Button variant="outline" size="sm" className="h-7 text-xs" onClick={() => {+ const url = new URL(window.location.href);+ url.searchParams.set("section", "connections");+ window.location.href = url.toString();+ }}>+ <Link className="h-3.5 w-3.5 mr-1" />+ connections+ </Button>+ </div></div>+ <p className="text-sm text-muted-foreground">+ {pipeTypeFilter === "scheduled"+ ? "scheduled agents that run on your screen data"+ : "pipes you trigger manually"}+ {" · "}+ <a+ href="https://docs.screenpi.pe/pipes"+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-1 underline underline-offset-2 hover:text-foreground transition-colors"+ >+ docs+ <ExternalLink className="h-3 w-3" />+ </a>+ </p></div>{/* Scheduled / Manual sub-tabs */}diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex b1a244e7c..c664ea5f0 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -222,6 +222,22 @@ async getDiskUsage(forceRefresh: boolean | null, dataDir: string | null) : Promielse return { status: "error", error: e as any };}},+async listCacheFiles() : Promise<Result<CacheFile[], string>> {+ try {+ return { status: "ok", data: await TAURI_INVOKE("list_cache_files") };+} catch (e) {+ if(e instanceof Error) throw e;+ else return { status: "error", error: e as any };+}+},+async deleteCacheFiles(paths: string[]) : Promise<Result<bigint, string>> {+ try {+ return { status: "ok", data: await TAURI_INVOKE("delete_cache_files", { paths }) };+} catch (e) {+ if(e instanceof Error) throw e;+ else return { status: "error", error: e as any };+}+},async openPipeWindow(port: number, title: string) : Promise<Result<null, string>> {try {return { status: "ok", data: await TAURI_INVOKE("open_pipe_window", { port, title }) };@@ -939,6 +955,7 @@ export type AIPreset = { id: string; prompt: string; provider: AIProviderType; uexport type AIProviderType = "openai" | "openai-chatgpt" | "native-ollama" | "custom" | "screenpipe-cloud" | "pi" | "anthropic"export type AudioDeviceInfo = { name: string; isDefault: boolean }export type BrowserLogEntry = { level: string; message: string }+export type CacheFile = { path: string; label: string; size_bytes: bigint }export type CachedSuggestions = { suggestions: Suggestion[]; generatedAt: string; mode: string; aiGenerated: boolean; tags: string[] }export type CalendarEventItem = { id: string; title: string;/**diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex c3e57f264..eab8bc8d5 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -1761,3 +1761,170 @@ pub fn set_native_theme(app_handle: tauri::AppHandle, theme: String) -> Result<(Ok(())}++#[derive(serde::Serialize, specta::Type)]+pub struct CacheFile {+ pub path: String,+ pub label: String,+ pub size_bytes: u64,+}++#[tauri::command]+#[specta::specta]+pub async fn list_cache_files() -> Result<Vec<CacheFile>, String> {+ let data_dir = screenpipe_core::paths::default_screenpipe_data_dir();+ let home_dir = dirs::home_dir().ok_or("no home directory")?;+ let mut files = Vec::new();++ // Pi agent node_modules (~/.screenpipe/pi-agent/)+ let pi_agent = data_dir.join("pi-agent");+ if pi_agent.exists() {+ let size = dir_size(&pi_agent);+ files.push(CacheFile {+ path: pi_agent.to_string_lossy().to_string(),+ label: "AI agent cache (pi-agent)".to_string(),+ size_bytes: size,+ });+ }++ // Pi config (~/.pi/agent/)+ let pi_config = home_dir.join(".pi").join("agent");+ if pi_config.exists() {+ let size = dir_size(&pi_config);+ files.push(CacheFile {+ path: pi_config.to_string_lossy().to_string(),+ label: "AI agent config (.pi/agent)".to_string(),+ size_bytes: size,+ });+ }++ // Stale root-level node_modules (~/.screenpipe/node_modules/)+ let root_nm = data_dir.join("node_modules");+ if root_nm.exists() {+ let size = dir_size(&root_nm);+ files.push(CacheFile {+ path: root_nm.to_string_lossy().to_string(),+ label: "Legacy node_modules".to_string(),+ size_bytes: size,+ });+ }++ // DB crash recovery/backup files+ for entry in std::fs::read_dir(&data_dir).map_err(|e| e.to_string())? {+ let entry = match entry {+ Ok(e) => e,+ Err(_) => continue,+ };+ let name = entry.file_name().to_string_lossy().to_string();+ let path = entry.path();++ // *.corrupt*, *.backup files+ if name.contains(".corrupt") || name.ends_with(".backup") {+ let size = if path.is_dir() {+ dir_size(&path)+ } else {+ path.metadata().map(|m| m.len()).unwrap_or(0)+ };+ files.push(CacheFile {+ path: path.to_string_lossy().to_string(),+ label: format!("DB recovery artifact: {}", name),+ size_bytes: size,+ });+ }++ // db-recovery-* and db-hotfix-* directories+ if path.is_dir() && (name.starts_with("db-recovery-") || name.starts_with("db-hotfix-")) {+ let size = dir_size(&path);+ files.push(CacheFile {+ path: path.to_string_lossy().to_string(),+ label: format!("DB recovery artifact: {}", name),+ size_bytes: size,+ });+ }++ // Old log files (screenpipe.*.log — legacy CLI format)+ if name.starts_with("screenpipe.") && name.ends_with(".log") {+ let size = path.metadata().map(|m| m.len()).unwrap_or(0);+ files.push(CacheFile {+ path: path.to_string_lossy().to_string(),+ label: format!("Old log: {}", name),+ size_bytes: size,+ });+ }++ // Empty/stale DB files (data.db, screenpipe.db, store.sqlite)+ if matches!(name.as_str(), "data.db" | "screenpipe.db" | "store.sqlite") {+ let size = path.metadata().map(|m| m.len()).unwrap_or(0);+ if size == 0 {+ files.push(CacheFile {+ path: path.to_string_lossy().to_string(),+ label: format!("Empty DB: {}", name),+ size_bytes: size,+ });+ }+ }+ }++ // Stale root-level bun artifacts+ for name in &["bun.lock", "bun.lockb", "package.json"] {+ let path = data_dir.join(name);+ if path.exists() {+ let size = path.metadata().map(|m| m.len()).unwrap_or(0);+ files.push(CacheFile {+ path: path.to_string_lossy().to_string(),+ label: format!("Stale config: {}", name),+ size_bytes: size,+ });+ }+ }++ Ok(files)+}++#[tauri::command]+#[specta::specta]+pub async fn delete_cache_files(paths: Vec<String>) -> Result<u64, String> {+ let mut freed = 0u64;+ for p in &paths {+ let path = std::path::Path::new(p);+ if !path.exists() {+ continue;+ }+ let size = if path.is_dir() {+ dir_size(path)+ } else {+ path.metadata().map(|m| m.len()).unwrap_or(0)+ };+ let result = if path.is_dir() {+ std::fs::remove_dir_all(path)+ } else {+ std::fs::remove_file(path)+ };+ match result {+ Ok(_) => {+ info!("cache cleanup: deleted {}", p);+ freed += size;+ }+ Err(e) => warn!("cache cleanup: failed to delete {}: {}", p, e),+ }+ }+ Ok(freed)+}++fn dir_size(path: &std::path::Path) -> u64 {+ let mut total = 0u64;+ let mut stack = vec![path.to_path_buf()];+ while let Some(dir) = stack.pop() {+ if let Ok(entries) = std::fs::read_dir(&dir) {+ for entry in entries.flatten() {+ let p = entry.path();+ if p.is_dir() {+ stack.push(p);+ } else {+ total += p.metadata().map(|m| m.len()).unwrap_or(0);+ }+ }+ }+ }+ total+}diff --git a/packages/ai-gateway/src/handlers/chat.ts b/packages/ai-gateway/src/handlers/chat.tsindex e50d9e48f..14720fbee 100644--- a/packages/ai-gateway/src/handlers/chat.ts+++ b/packages/ai-gateway/src/handlers/chat.ts@@ -15,6 +15,26 @@ const AUTO_WATERFALL = ['gemini-3-flash',];+// Vision-capable models for requests containing images+const AUTO_WATERFALL_VISION = [+ 'kimi-k2.5', // free (Vertex MaaS), natively multimodal, strong vision+ 'gemini-3-flash', // near-free, excellent vision+ 'gemini-2.5-flash',+];++function hasImages(body: RequestBody): boolean {+ return body.messages.some(+ (msg) =>+ Array.isArray(msg.content) &&+ msg.content.some(+ (part) =>+ part.type === 'image' ||+ part.type === 'image_url' ||+ (part.type === 'file' && part.mimeType?.startsWith('image/'))+ )+ );+}+function addModelHeader(response: Response, model: string): Response {const newResponse = new Response(response.body, response);newResponse.headers.set('x-screenpipe-model', model);@@ -60,7 +80,8 @@ export async function handleChatCompletions(body: RequestBody, env: Env): Promis// Auto model: waterfall through free models until one succeedsif (body.model === 'auto') {let lastError: any = null;- for (const model of AUTO_WATERFALL) {+ const waterfall = hasImages(body) ? AUTO_WATERFALL_VISION : AUTO_WATERFALL;+ for (const model of waterfall) {try {const response = await tryModel(model, body, env);if (response) {diff --git a/packages/ai-gateway/src/providers/anthropic.ts b/packages/ai-gateway/src/providers/anthropic.tsindex b7c512806..f9a6e7e5e 100644--- a/packages/ai-gateway/src/providers/anthropic.ts+++ b/packages/ai-gateway/src/providers/anthropic.ts@@ -302,6 +302,17 @@ export class AnthropicProvider implements AIProvider {text: `[Image URL: ${url}]`,} as TextBlock;}+ // Handle Pi native format: { type: "image", data: "base64...", mimeType: "image/png" }+ if (part.type === 'image' && part.data && part.mimeType) {+ return {+ type: 'image',+ source: {+ type: 'base64',+ media_type: part.mimeType as 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp',+ data: part.data as string,+ },+ } as ImageBlockParam;+ }// Handle Anthropic native format (from Pi agent)// Normalize mediaType (camelCase) to media_type (snake_case)if (part.type === 'image' && part.source?.type === 'base64') {diff --git a/packages/ai-gateway/src/providers/gemini.ts b/packages/ai-gateway/src/providers/gemini.tsindex 8c494d47f..5d81111bd 100644--- a/packages/ai-gateway/src/providers/gemini.ts+++ b/packages/ai-gateway/src/providers/gemini.ts@@ -639,6 +639,22 @@ export class GeminiProvider implements AIProvider {},});}+ } else if (part.type === 'image' && part.data && part.mimeType) {+ // Pi native format+ parts.push({+ inlineData: {+ mimeType: part.mimeType,+ data: part.data as string,+ },+ });+ } else if (part.type === 'image' && part.source?.type === 'base64') {+ // Anthropic format+ parts.push({+ inlineData: {+ mimeType: (part.source.media_type || part.source.mediaType || 'image/png') as string,+ data: part.source.data as string,+ },+ });} else if (part.type === 'image' && part.image?.url) {const url = part.image.url;const dataUrlMatch = url.match(/^data:([^;]+);base64,(.+)$/);diff --git a/packages/ai-gateway/src/providers/openai.ts b/packages/ai-gateway/src/providers/openai.tsindex 9f870ac0c..4057a852a 100644--- a/packages/ai-gateway/src/providers/openai.ts+++ b/packages/ai-gateway/src/providers/openai.ts@@ -139,11 +139,42 @@ export class OpenAIProvider implements AIProvider {role: msg.role,content: Array.isArray(msg.content)? msg.content.map((part) => {- if (part.type === 'image') {+ // OpenAI image_url format (from Pi's convertToLlm)+ if (part.type === 'image_url' && part.image_url?.url) {return {type: 'image_url',image_url: {- url: part.image?.url,+ url: part.image_url.url,+ detail: part.image_url.detail || 'auto',+ },+ };+ }+ // Pi native format: { type: "image", data: "base64...", mimeType: "image/png" }+ if (part.type === 'image' && part.data && part.mimeType) {+ return {+ type: 'image_url',+ image_url: {+ url: `data:${part.mimeType};base64,${part.data}`,+ detail: 'auto',+ },+ };+ }+ // Anthropic base64 format+ if (part.type === 'image' && part.source?.type === 'base64') {+ return {+ type: 'image_url',+ image_url: {+ url: `data:${part.source.media_type || part.source.mediaType || 'image/png'};base64,${part.source.data}`,+ detail: 'auto',+ },+ };+ }+ // Legacy: { type: "image", image: { url: "..." } }+ if (part.type === 'image' && part.image?.url) {+ return {+ type: 'image_url',+ image_url: {+ url: part.image.url,detail: 'auto',},};diff --git a/packages/ai-gateway/src/providers/openrouter.ts b/packages/ai-gateway/src/providers/openrouter.tsindex 59028a048..525372b45 100644--- a/packages/ai-gateway/src/providers/openrouter.ts+++ b/packages/ai-gateway/src/providers/openrouter.ts@@ -136,11 +136,38 @@ export class OpenRouterProvider implements AIProvider {role: msg.role,content: Array.isArray(msg.content)? msg.content.map((part) => {- if (part.type === 'image' || part.type === 'image_url') {+ if (part.type === 'image_url' && part.image_url?.url) {return {type: 'image_url',image_url: {- url: part.image?.url || part.image_url?.url,+ url: part.image_url.url,+ detail: part.image_url.detail || 'auto',+ },+ };+ }+ if (part.type === 'image' && part.data && part.mimeType) {+ return {+ type: 'image_url',+ image_url: {+ url: `data:${part.mimeType};base64,${part.data}`,+ detail: 'auto',+ },+ };+ }+ if (part.type === 'image' && part.source?.type === 'base64') {+ return {+ type: 'image_url',+ image_url: {+ url: `data:${part.source.media_type || part.source.mediaType || 'image/png'};base64,${part.source.data}`,+ detail: 'auto',+ },+ };+ }+ if (part.type === 'image' && part.image?.url) {+ return {+ type: 'image_url',+ image_url: {+ url: part.image.url,detail: 'auto',},};diff --git a/packages/ai-gateway/src/providers/vertex-maas.ts b/packages/ai-gateway/src/providers/vertex-maas.tsindex d13f6c8e7..7c606b007 100644--- a/packages/ai-gateway/src/providers/vertex-maas.ts+++ b/packages/ai-gateway/src/providers/vertex-maas.ts@@ -62,7 +62,7 @@ export function resolveVertexMaasModel(model: string): { vertexId: string; regioexport class VertexMaasProvider implements AIProvider {supportsTools = true;- supportsVision = false;+ supportsVision = true;supportsJson = true;private vertexProvider: VertexAIProvider;@@ -164,6 +164,19 @@ export class VertexMaasProvider implements AIProvider {content: Array.isArray(msg.content)? msg.content.map((part) => {if (part.type === 'text') return { type: 'text', text: part.text || '' };+ // OpenAI image_url format passthrough+ if (part.type === 'image_url' && part.image_url?.url) {+ return { type: 'image_url', image_url: { url: part.image_url.url } };+ }+ // Pi native format: { type: "image", data, mimeType }+ if (part.type === 'image' && part.data && part.mimeType) {+ return { type: 'image_url', image_url: { url: `data:${part.mimeType};base64,${part.data}` } };+ }+ // Anthropic base64 format+ if (part.type === 'image' && part.source?.type === 'base64') {+ const mt = part.source.media_type || part.source.mediaType || 'image/png';+ return { type: 'image_url', image_url: { url: `data:${mt};base64,${part.source.data}` } };+ }return part;}): msg.content,diff --git a/packages/ai-gateway/src/providers/vertex.ts b/packages/ai-gateway/src/providers/vertex.tsindex f623b7f43..22800d9d4 100644--- a/packages/ai-gateway/src/providers/vertex.ts+++ b/packages/ai-gateway/src/providers/vertex.ts@@ -446,6 +446,16 @@ export class VertexAIProvider implements AIProvider {url: url,},};+ } else if (part.type === 'image' && part.data && part.mimeType) {+ // Pi native format+ return {+ type: 'image',+ source: {+ type: 'base64',+ media_type: part.mimeType,+ data: part.data,+ },+ };} else if (part.type === 'image' && part.source?.type === 'base64') {// Handle Anthropic native format (from Pi agent)// Normalize mediaType (camelCase) to media_type (snake_case)