Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

chore(web): remove temporary /agent-debug route and agent service

Akarshan Biswas593e8c5caa1e
diff --git a/web-app/src/components/left-sidebar/NavMain.tsx b/web-app/src/components/left-sidebar/NavMain.tsx
index 703d36f64..6ad7b0822 100644
--- a/web-app/src/components/left-sidebar/NavMain.tsx
+++ b/web-app/src/components/left-sidebar/NavMain.tsx
@@ -1,5 +1,4 @@
import { LucideIcon } from 'lucide-react'
-import { IconRobot } from '@tabler/icons-react'
import { route } from '@/constants/routes'
import {
@@ -9,7 +8,6 @@ import {
} from '@/components/ui/sidebar'
import { Kbd, KbdGroup } from '@/components/ui/kbd'
import { useTranslation } from '@/i18n/react-i18next-compat'
-import { isDev } from '@/lib/utils'
import { Link, useNavigate } from '@tanstack/react-router'
import { PlatformMetaKey } from '@/containers/PlatformMetaKey'
@@ -135,16 +133,6 @@ const getNavMainItems = (
url: route.settings.general,
animatedIcon: SettingsIcon,
},
- // TEMP: smoke-test entry for the agent loop; dev builds only, remove before ship.
- ...(isDev()
- ? [
- {
- title: 'common:agentDebug.title',
- url: route.agentDebug,
- icon: IconRobot,
- },
- ]
- : []),
]
function NavMainItemWithAnimatedIcon({
diff --git a/web-app/src/constants/routes.ts b/web-app/src/constants/routes.ts
index c155050e7..2e36dddb6 100644
--- a/web-app/src/constants/routes.ts
+++ b/web-app/src/constants/routes.ts
@@ -29,5 +29,4 @@ export const route = {
localApiServerlogs: '/local-api-server/logs',
systemMonitor: '/system-monitor',
threadsDetail: '/threads/$threadId',
- agentDebug: '/agent-debug',
}
diff --git a/web-app/src/locales/en/common.json b/web-app/src/locales/en/common.json
index 7e7533d7b..e7edeb56b 100644
--- a/web-app/src/locales/en/common.json
+++ b/web-app/src/locales/en/common.json
@@ -1,28 +1,4 @@
{
- "agentDebug": {
- "title": "Agent Debug",
- "modelLabel": "Model",
- "modelAuto": "Auto (first running model)",
- "stepsLabel": "Max steps (1-400)",
- "toolsLabel": "Tools",
- "noTools": "No MCP tools available.",
- "promptLabel": "Prompt",
- "promptPlaceholder": "Type a message for the agent loop...",
- "run": "Run",
- "running": "Running...",
- "cancel": "Cancel",
- "clear": "Clear",
- "output": "Streamed output",
- "eventLog": "Event log",
- "empty": "No events yet.",
- "projectLabel": "Project root (enables built-in fs tools)",
- "projectPlaceholder": "/absolute/path/to/project",
- "permissionTitle": "Permission request",
- "permissionBody": "The agent wants to use \"{{tool}}\" ({{capability}}){{path}}.",
- "permissionAllowOnce": "Allow once",
- "permissionAllowAlways": "Allow every time",
- "permissionDeny": "Deny"
- },
"htmlArtifact": {
"code": "Code",
"preview": "Preview",
diff --git a/web-app/src/routeTree.gen.ts b/web-app/src/routeTree.gen.ts
index f418bd288..a2a333a4c 100644
--- a/web-app/src/routeTree.gen.ts
+++ b/web-app/src/routeTree.gen.ts
@@ -11,7 +11,6 @@
import { Route as rootRouteImport } from './routes/__root'
import { Route as SystemMonitorRouteImport } from './routes/system-monitor'
import { Route as LogsRouteImport } from './routes/logs'
-import { Route as AgentDebugRouteImport } from './routes/agent-debug'
import { Route as IndexRouteImport } from './routes/index'
import { Route as HubIndexRouteImport } from './routes/hub/index'
import { Route as ThreadsThreadIdRouteImport } from './routes/threads/$threadId'
@@ -44,11 +43,6 @@ const LogsRoute = LogsRouteImport.update({
path: '/logs',
getParentRoute: () => rootRouteImport,
} as any)
-const AgentDebugRoute = AgentDebugRouteImport.update({
- id: '/agent-debug',
- path: '/agent-debug',
- getParentRoute: () => rootRouteImport,
-} as any)
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
@@ -158,7 +152,6 @@ const SettingsProvidersProviderNameRoute =
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
- '/agent-debug': typeof AgentDebugRoute
'/logs': typeof LogsRoute
'/system-monitor': typeof SystemMonitorRoute
'/hub/$modelId': typeof HubModelIdRoute
@@ -184,7 +177,6 @@ export interface FileRoutesByFullPath {
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
- '/agent-debug': typeof AgentDebugRoute
'/logs': typeof LogsRoute
'/system-monitor': typeof SystemMonitorRoute
'/hub/$modelId': typeof HubModelIdRoute
@@ -211,7 +203,6 @@ export interface FileRoutesByTo {
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
- '/agent-debug': typeof AgentDebugRoute
'/logs': typeof LogsRoute
'/system-monitor': typeof SystemMonitorRoute
'/hub/$modelId': typeof HubModelIdRoute
@@ -239,7 +230,6 @@ export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths:
| '/'
- | '/agent-debug'
| '/logs'
| '/system-monitor'
| '/hub/$modelId'
@@ -265,7 +255,6 @@ export interface FileRouteTypes {
fileRoutesByTo: FileRoutesByTo
to:
| '/'
- | '/agent-debug'
| '/logs'
| '/system-monitor'
| '/hub/$modelId'
@@ -291,7 +280,6 @@ export interface FileRouteTypes {
id:
| '__root__'
| '/'
- | '/agent-debug'
| '/logs'
| '/system-monitor'
| '/hub/$modelId'
@@ -318,7 +306,6 @@ export interface FileRouteTypes {
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
- AgentDebugRoute: typeof AgentDebugRoute
LogsRoute: typeof LogsRoute
SystemMonitorRoute: typeof SystemMonitorRoute
HubModelIdRoute: typeof HubModelIdRoute
@@ -359,13 +346,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LogsRouteImport
parentRoute: typeof rootRouteImport
}
- '/agent-debug': {
- id: '/agent-debug'
- path: '/agent-debug'
- fullPath: '/agent-debug'
- preLoaderRoute: typeof AgentDebugRouteImport
- parentRoute: typeof rootRouteImport
- }
'/': {
id: '/'
path: '/'
@@ -518,7 +498,6 @@ declare module '@tanstack/react-router' {
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
- AgentDebugRoute: AgentDebugRoute,
LogsRoute: LogsRoute,
SystemMonitorRoute: SystemMonitorRoute,
HubModelIdRoute: HubModelIdRoute,
diff --git a/web-app/src/routes/agent-debug.tsx b/web-app/src/routes/agent-debug.tsx
deleted file mode 100644
index aab1193b8..000000000
--- a/web-app/src/routes/agent-debug.tsx
+++ /dev/null
@@ -1,478 +0,0 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-import { createFileRoute, redirect } from '@tanstack/react-router'
-import { useEffect, useMemo, useRef, useState } from 'react'
-import { IconRobot } from '@tabler/icons-react'
-import { route } from '@/constants/routes'
-import { isDev } from '@/lib/utils'
-import { useServiceHub } from '@/hooks/useServiceHub'
-import { useModelProvider } from '@/hooks/useModelProvider'
-import { useTranslation } from '@/i18n/react-i18next-compat'
-import type { PermissionDecision, StreamEvent } from '@/services/agent/types'
-import type { MCPTool } from '@/types/completion'
-
-type PermissionRequestEvent = Extract<
- StreamEvent,
- { type: 'permission_request' }
->
-
-/** Built-in fs tools (Rust `BUILTIN_TOOLS`). The tool selector lists only MCP
- * tools, so these must be added to `allowed_tools` when a project is set or the
- * loop's allowlist filter would prune them from advertisement. */
-const BUILTIN_TOOL_NAMES = [
- 'read',
- 'ls',
- 'find',
- 'grep',
- 'write',
- 'edit',
- 'bash',
-]
-
-export const Route = createFileRoute(route.agentDebug as any)({
- // TEMP smoke-test route: dev builds only. Packaged builds redirect home.
- beforeLoad: () => {
- if (!isDev()) throw redirect({ to: route.home })
- },
- component: AgentDebugPanel,
-})
-
-function truncate(text: string, max = 140): string {
- const flat = text.replace(/\s+/g, ' ').trim()
- return flat.length > max ? `${flat.slice(0, max)}...` : flat
-}
-
-/** Strip model reasoning from the streamed text: complete `<think>...</think>`
- * blocks (any namespace prefix, e.g. `<mm:think>`), an in-progress unclosed
- * block at the tail, and any orphan think tags. */
-function stripThink(text: string): string {
- return text
- .replace(/<(?:\w+:)?think\b[^>]*>[\s\S]*?<\/(?:\w+:)?think>/gi, '')
- .replace(/<(?:\w+:)?think\b[^>]*>[\s\S]*$/i, '')
- .replace(/<\/?(?:\w+:)?think\b[^>]*>/gi, '')
- .trimStart()
-}
-
-/** Collapse the raw event stream into a compact log: runs of token events
- * become a single live counter, tool calls/results show name + short output. */
-function condenseEvents(events: StreamEvent[]): string[] {
- const rows: string[] = []
- const toolNames = new Map<string, string>()
- let tokenRun = 0
-
- const flushTokens = () => {
- if (tokenRun > 0) {
- rows.push(`streaming... (${tokenRun} token${tokenRun === 1 ? '' : 's'})`)
- tokenRun = 0
- }
- }
-
- for (const event of events) {
- if (event.type === 'token') {
- tokenRun++
- continue
- }
- flushTokens()
- switch (event.type) {
- case 'step':
- rows.push(`step ${event.index}/${event.max}`)
- break
- case 'tool_call':
- toolNames.set(event.id, event.name)
- rows.push(`tool_call: ${event.name}`)
- break
- case 'tool_result': {
- const name = toolNames.get(event.id) ?? event.id
- const flag = event.is_error ? ' [error]' : ''
- rows.push(`tool_result: ${name}${flag} - ${truncate(event.content)}`)
- break
- }
- case 'permission_request':
- rows.push(
- `permission_request: ${event.tool_name} (${event.capability})${
- event.path ? ` ${event.path}` : ''
- }`
- )
- break
- case 'done':
- rows.push(`done: ${event.stop_reason}`)
- break
- case 'error':
- rows.push(`error [${event.code}]: ${event.message}`)
- break
- }
- }
- flushTokens()
- return rows
-}
-
-function AgentDebugPanel() {
- const { t } = useTranslation()
- const serviceHub = useServiceHub()
- const providers = useModelProvider((s) => s.providers)
-
- const [prompt, setPrompt] = useState('')
- const [modelId, setModelId] = useState('')
- const [maxTurns, setMaxTurns] = useState(8)
- const [events, setEvents] = useState<StreamEvent[]>([])
- const [running, setRunning] = useState(false)
- const [availableTools, setAvailableTools] = useState<MCPTool[]>([])
- const [selectedTools, setSelectedTools] = useState<Set<string>>(new Set())
- const [projectRoot, setProjectRoot] = useState('')
- const [pendingPermission, setPendingPermission] =
- useState<PermissionRequestEvent | null>(null)
- const runIdRef = useRef<string | null>(null)
-
- useEffect(() => {
- serviceHub
- .mcp()
- .getTools()
- .then((tools) => {
- setAvailableTools(tools)
- setSelectedTools(new Set(tools.map((tool) => tool.name)))
- })
- .catch((error) => console.error('Failed to load MCP tools:', error))
- }, [serviceHub])
-
- const toggleTool = (name: string) => {
- setSelectedTools((prev) => {
- const next = new Set(prev)
- if (next.has(name)) next.delete(name)
- else next.add(name)
- return next
- })
- }
-
- const modelOptions = useMemo(
- () =>
- providers
- .filter((p) => p.active)
- .flatMap((p) =>
- p.models.map((m) => ({ id: m.id, label: `${p.provider} / ${m.id}` }))
- ),
- [providers]
- )
-
- const streamedText = useMemo(
- () =>
- stripThink(
- events
- .filter(
- (e): e is Extract<StreamEvent, { type: 'token' }> =>
- e.type === 'token'
- )
- .map((e) => e.text)
- .join('')
- ),
- [events]
- )
-
- const logRows = useMemo(() => condenseEvents(events), [events])
-
- // Keep both panes pinned to the newest content while streaming, but stop
- // auto-scrolling once the user scrolls up (re-pins when they return to the
- // bottom). Pinned state is measured on scroll, before new content lands.
- const outputRef = useRef<HTMLPreElement>(null)
- const logRef = useRef<HTMLOListElement>(null)
- const outputPinned = useRef(true)
- const logPinned = useRef(true)
-
- const trackPinned = (pinned: React.MutableRefObject<boolean>) => (
- e: React.UIEvent<HTMLElement>
- ) => {
- const el = e.currentTarget
- pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 40
- }
-
- useEffect(() => {
- const el = outputRef.current
- if (el && outputPinned.current) el.scrollTop = el.scrollHeight
- }, [streamedText])
- useEffect(() => {
- const el = logRef.current
- if (el && logPinned.current) el.scrollTop = el.scrollHeight
- }, [logRows])
-
- const handleRun = async () => {
- if (running || !prompt.trim()) return
- const runId = crypto.randomUUID()
- runIdRef.current = runId
- setEvents([])
- setPendingPermission(null)
- setRunning(true)
- try {
- await serviceHub.agent().run(
- runId,
- {
- messages: [{ role: 'user', content: prompt }],
- max_turns: maxTurns,
- ...(modelId ? { model: modelId } : {}),
- ...(availableTools.length > 0
- ? {
- allowed_tools: [
- ...selectedTools,
- ...(projectRoot.trim() ? BUILTIN_TOOL_NAMES : []),
- ],
- }
- : {}),
- ...(projectRoot.trim() ? { project: projectRoot.trim() } : {}),
- },
- (event) => {
- setEvents((prev) => [...prev, event])
- if (event.type === 'permission_request') setPendingPermission(event)
- }
- )
- } catch (error) {
- setEvents((prev) => [
- ...prev,
- { type: 'error', code: 'invoke', message: String(error) },
- ])
- } finally {
- setRunning(false)
- runIdRef.current = null
- }
- }
-
- const handleCancel = async () => {
- if (runIdRef.current) {
- await serviceHub.agent().cancel(runIdRef.current)
- }
- }
-
- const respondPermission = async (decision: PermissionDecision) => {
- if (!pendingPermission) return
- const { request_id } = pendingPermission
- setPendingPermission(null)
- await serviceHub.agent().respondPermission(request_id, decision)
- }
-
- return (
- <div className="flex flex-col h-svh min-h-0 min-w-0 bg-background overflow-hidden p-4 gap-3">
- <div className="flex items-center gap-2 shrink-0">
- <IconRobot className="text-muted-foreground/80 size-6" />
- <h1 className="text-xl font-bold text-muted-foreground">
- {t('common:agentDebug.title')}
- </h1>
- </div>
-
- <div className="flex flex-col lg:flex-row gap-4 flex-1 min-h-0">
- {/* Controls */}
- <div className="flex flex-col gap-3 lg:w-96 lg:shrink-0 min-h-0 overflow-y-auto pr-1">
- <div className="flex flex-col gap-1 shrink-0">
- <label className="text-sm text-muted-foreground" htmlFor="agent-model">
- {t('common:agentDebug.modelLabel')}
- </label>
- <select
- id="agent-model"
- className="appearance-none bg-secondary text-foreground border border-border rounded-lg p-2 text-sm w-full [color-scheme:dark]"
- value={modelId}
- onChange={(e) => setModelId(e.target.value)}
- disabled={running}
- >
- <option value="">{t('common:agentDebug.modelAuto')}</option>
- {modelOptions.map((m) => (
- <option key={m.id} value={m.id}>
- {m.label}
- </option>
- ))}
- </select>
- </div>
-
- <div className="flex flex-col gap-1 shrink-0">
- <label className="text-sm text-muted-foreground" htmlFor="agent-steps">
- {t('common:agentDebug.stepsLabel')}
- </label>
- <input
- id="agent-steps"
- type="number"
- min={1}
- max={400}
- className="appearance-none bg-secondary text-foreground border border-border rounded-lg p-2 text-sm w-full [color-scheme:dark]"
- value={maxTurns}
- onChange={(e) =>
- setMaxTurns(
- Math.min(400, Math.max(1, Number(e.target.value) || 1))
- )
- }
- disabled={running}
- />
- </div>
-
- <div className="flex flex-col gap-1 shrink-0">
- <label
- className="text-sm text-muted-foreground"
- htmlFor="agent-project"
- >
- {t('common:agentDebug.projectLabel')}
- </label>
- <input
- id="agent-project"
- className="appearance-none bg-secondary text-foreground border border-border rounded-lg p-2 text-sm min-w-0 [color-scheme:dark]"
- placeholder={t('common:agentDebug.projectPlaceholder')}
- value={projectRoot}
- onChange={(e) => setProjectRoot(e.target.value)}
- disabled={running}
- />
- </div>
-
- <div className="flex flex-col gap-1 shrink-0">
- <span className="text-sm text-muted-foreground">
- {t('common:agentDebug.toolsLabel')}
- </span>
- <div className="bg-secondary/50 rounded-lg p-3 max-h-40 overflow-y-auto">
- {availableTools.length === 0 ? (
- <div className="text-muted-foreground text-sm">
- {t('common:agentDebug.noTools')}
- </div>
- ) : (
- <ul className="flex flex-col gap-1">
- {availableTools.map((tool) => (
- <li key={tool.name}>
- <label className="flex items-center gap-2 text-sm cursor-pointer">
- <input
- type="checkbox"
- checked={selectedTools.has(tool.name)}
- onChange={() => toggleTool(tool.name)}
- disabled={running}
- />
- <span className="text-foreground">{tool.name}</span>
- <span className="text-muted-foreground text-xs">
- {tool.server}
- </span>
- </label>
- </li>
- ))}
- </ul>
- )}
- </div>
- </div>
-
- <div className="flex flex-col gap-1 flex-1 min-h-0">
- <label
- className="text-sm text-muted-foreground shrink-0"
- htmlFor="agent-prompt"
- >
- {t('common:agentDebug.promptLabel')}
- </label>
- <textarea
- id="agent-prompt"
- className="bg-secondary/50 rounded-lg p-3 text-sm font-mono flex-1 min-h-24 w-full resize-none"
- placeholder={t('common:agentDebug.promptPlaceholder')}
- value={prompt}
- onChange={(e) => setPrompt(e.target.value)}
- disabled={running}
- />
- </div>
-
- <div className="flex gap-2 shrink-0">
- <button
- className="bg-primary text-primary-foreground rounded-md px-4 py-2 text-sm disabled:opacity-50"
- onClick={handleRun}
- disabled={running || !prompt.trim()}
- >
- {running
- ? t('common:agentDebug.running')
- : t('common:agentDebug.run')}
- </button>
- <button
- className="bg-secondary text-foreground rounded-md px-4 py-2 text-sm disabled:opacity-50"
- onClick={handleCancel}
- disabled={!running}
- >
- {t('common:agentDebug.cancel')}
- </button>
- <button
- className="text-muted-foreground rounded-md px-4 py-2 text-sm disabled:opacity-50"
- onClick={() => setEvents([])}
- disabled={running || events.length === 0}
- >
- {t('common:agentDebug.clear')}
- </button>
- </div>
- </div>
-
- {/* Results */}
- <div className="flex flex-col flex-1 min-h-0 min-w-0 gap-3">
- <div className="bg-secondary/50 rounded-lg p-3 min-w-0 flex flex-col flex-1 min-h-0">
- <h2 className="text-base font-semibold mb-2 shrink-0">
- {t('common:agentDebug.output')}
- </h2>
- <pre
- ref={outputRef}
- onScroll={trackPinned(outputPinned)}
- className="text-sm whitespace-pre-wrap [overflow-wrap:anywhere] flex-1 min-h-0 overflow-y-auto"
- >
- {streamedText}
- </pre>
- </div>
-
- <div className="bg-secondary/50 rounded-lg p-3 min-w-0 flex flex-col flex-1 min-h-0">
- <h2 className="text-base font-semibold mb-2 shrink-0">
- {t('common:agentDebug.eventLog')}
- </h2>
- {events.length === 0 ? (
- <div className="text-muted-foreground text-sm py-2">
- {t('common:agentDebug.empty')}
- </div>
- ) : (
- <ol
- ref={logRef}
- onScroll={trackPinned(logPinned)}
- className="text-xs font-mono flex flex-col gap-1 flex-1 min-h-0 overflow-y-auto overflow-x-hidden"
- >
- {logRows.map((row, i) => (
- <li
- key={i}
- className="text-foreground whitespace-pre-wrap [overflow-wrap:anywhere]"
- >
- {row}
- </li>
- ))}
- </ol>
- )}
- </div>
- </div>
- </div>
-
- {pendingPermission && (
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
- <div className="bg-background border border-border rounded-lg p-5 w-full max-w-md flex flex-col gap-4">
- <h2 className="text-base font-semibold text-foreground">
- {t('common:agentDebug.permissionTitle')}
- </h2>
- <p className="text-sm text-muted-foreground [overflow-wrap:anywhere]">
- {t('common:agentDebug.permissionBody', {
- tool: pendingPermission.tool_name,
- capability: pendingPermission.capability,
- path: pendingPermission.path
- ? `: ${pendingPermission.path}`
- : '',
- })}
- </p>
- <div className="flex gap-2 justify-end flex-wrap">
- <button
- className="bg-secondary text-foreground rounded-md px-3 py-2 text-sm"
- onClick={() => respondPermission('deny')}
- >
- {t('common:agentDebug.permissionDeny')}
- </button>
- <button
- className="bg-secondary text-foreground rounded-md px-3 py-2 text-sm"
- onClick={() => respondPermission('allow_once')}
- >
- {t('common:agentDebug.permissionAllowOnce')}
- </button>
- {pendingPermission.offers_always && (
- <button
- className="bg-primary text-primary-foreground rounded-md px-3 py-2 text-sm"
- onClick={() => respondPermission('allow_always')}
- >
- {t('common:agentDebug.permissionAllowAlways')}
- </button>
- )}
- </div>
- </div>
- </div>
- )}
- </div>
- )
-}
diff --git a/web-app/src/services/agent/default.ts b/web-app/src/services/agent/default.ts
deleted file mode 100644
index 8d2c2f28c..000000000
--- a/web-app/src/services/agent/default.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Fallback agent service for non-desktop platforms, where the in-process agent
- * loop is unavailable. `run` rejects so callers surface a clear error.
- */
-
-import type { AgentService } from './types'
-
-export class DefaultAgentService implements AgentService {
- async run(): Promise<void> {
- throw new Error('Agent service is only available in the desktop app')
- }
-
- async cancel(): Promise<void> {
- console.debug('DefaultAgentService.cancel: no desktop backend, nothing to cancel')
- }
-
- async respondPermission(): Promise<void> {
- console.debug(
- 'DefaultAgentService.respondPermission: no desktop backend, nothing to respond'
- )
- }
-}
diff --git a/web-app/src/services/agent/tauri.ts b/web-app/src/services/agent/tauri.ts
deleted file mode 100644
index 2cd3e54a9..000000000
--- a/web-app/src/services/agent/tauri.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Tauri agent service - desktop implementation. Bridges the Rust `agent_run`
- * command's `Channel<StreamEvent>` onto an `onEvent` callback.
- */
-
-import { Channel, invoke } from '@tauri-apps/api/core'
-import type { AgentRunBody, PermissionDecision, StreamEvent } from './types'
-import { DefaultAgentService } from './default'
-
-export class TauriAgentService extends DefaultAgentService {
- async run(
- runId: string,
- body: AgentRunBody,
- onEvent: (event: StreamEvent) => void
- ): Promise<void> {
- const channel = new Channel<StreamEvent>()
- channel.onmessage = onEvent
- try {
- await invoke<void>('agent_run', { runId, body, onEvent: channel })
- } catch (error) {
- console.error(`Error invoking agent_run for '${runId}':`, error)
- throw error
- }
- }
-
- async cancel(runId: string): Promise<void> {
- try {
- await invoke<void>('agent_cancel', { runId })
- } catch (error) {
- console.error(`Error invoking agent_cancel for '${runId}':`, error)
- throw error
- }
- }
-
- async respondPermission(
- requestId: string,
- decision: PermissionDecision
- ): Promise<void> {
- try {
- await invoke<void>('agent_permission_respond', { requestId, decision })
- } catch (error) {
- console.error(
- `Error invoking agent_permission_respond for '${requestId}':`,
- error
- )
- throw error
- }
- }
-}
diff --git a/web-app/src/services/agent/types.ts b/web-app/src/services/agent/types.ts
deleted file mode 100644
index 48a144522..000000000
--- a/web-app/src/services/agent/types.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Agent service types. `StreamEvent` mirrors the Rust `core::agent::events`
- * enum (serde tag = "type", snake_case) emitted over a Tauri Channel by
- * `agent_run`.
- */
-
-export interface AgentUsage {
- prompt_tokens?: number | null
- completion_tokens?: number | null
- total_tokens?: number | null
-}
-
-export type StreamEvent =
- | { type: 'token'; text: string }
- | { type: 'step'; index: number; max: number }
- | { type: 'tool_call'; id: string; name: string; args: unknown }
- | { type: 'tool_result'; id: string; content: string; is_error: boolean }
- | {
- type: 'permission_request'
- request_id: string
- tool_name: string
- capability: string
- path?: string | null
- command?: string | null
- diff?: string | null
- prompt_kind: string
- offers_always: boolean
- }
- | { type: 'done'; stop_reason: string; usage: AgentUsage | null }
- | { type: 'error'; code: string; message: string }
-
-/** Mirrors the Rust `PermissionDecision` (serde snake_case). */
-export type PermissionDecision = 'allow_once' | 'allow_always' | 'deny'
-
-export interface AgentRunMessage {
- role: string
- content: string
-}
-
-export interface AgentRunBody {
- messages: AgentRunMessage[]
- model?: string
- max_turns?: number
- /** Per-run MCP tool allowlist (by tool name). Omit for all tools; empty
- * array for none. */
- allowed_tools?: string[]
- /** Project root; enables built-in fs tools and loads agent.toml permissions. */
- project?: string
- [key: string]: unknown
-}
-
-export interface AgentService {
- /** Run the agent loop; `onEvent` fires for each streamed event until a
- * terminal `done`/`error`. Resolves when the run finishes or is cancelled. */
- run(
- runId: string,
- body: AgentRunBody,
- onEvent: (event: StreamEvent) => void
- ): Promise<void>
- /** Cancel an in-flight run by id. No-op if it already finished. */
- cancel(runId: string): Promise<void>
- /** Answer a `permission_request` event by its `request_id`. */
- respondPermission(
- requestId: string,
- decision: PermissionDecision
- ): Promise<void>
-}
diff --git a/web-app/src/services/index.ts b/web-app/src/services/index.ts
index 3d12a7e7c..99311dccc 100644
--- a/web-app/src/services/index.ts
+++ b/web-app/src/services/index.ts
@@ -31,8 +31,6 @@ import { DefaultRAGService } from './rag/default'
import type { RAGService } from './rag/types'
import { DefaultUploadsService } from './uploads/default'
import type { UploadsService } from './uploads/types'
-import { DefaultAgentService } from './agent/default'
-import type { AgentService } from './agent/types'
// Import service types
import type { ThemeService } from './theme/types'
@@ -78,7 +76,6 @@ export interface ServiceHub {
projects(): ProjectsService
rag(): RAGService
uploads(): UploadsService
- agent(): AgentService
}
class PlatformServiceHub implements ServiceHub {
@@ -103,7 +100,6 @@ class PlatformServiceHub implements ServiceHub {
private projectsService: ProjectsService = new DefaultProjectsService()
private ragService: RAGService = new DefaultRAGService()
private uploadsService: UploadsService = new DefaultUploadsService()
- private agentService: AgentService = new DefaultAgentService()
private initialized = false
/**
@@ -136,7 +132,6 @@ class PlatformServiceHub implements ServiceHub {
pathModule,
coreModule,
deepLinkModule,
- agentModule,
] = await Promise.all([
import('./theme/tauri'),
import('./window/tauri'),
@@ -151,7 +146,6 @@ class PlatformServiceHub implements ServiceHub {
import('./path/tauri'),
import('./core/tauri'),
import('./deeplink/tauri'),
- import('./agent/tauri'),
])
this.themeService = new themeModule.TauriThemeService()
@@ -167,7 +161,6 @@ class PlatformServiceHub implements ServiceHub {
this.pathService = new pathModule.TauriPathService()
this.coreService = new coreModule.TauriCoreService()
this.deepLinkService = new deepLinkModule.TauriDeepLinkService()
- this.agentService = new agentModule.TauriAgentService()
} else if (isPlatformIOS() || isPlatformAndroid()) {
const [
themeModule,
@@ -330,11 +323,6 @@ class PlatformServiceHub implements ServiceHub {
this.ensureInitialized()
return this.uploadsService
}
-
- agent(): AgentService {
- this.ensureInitialized()
- return this.agentService
- }
}
export async function initializeServiceHub(): Promise<ServiceHub> {