Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

tech(TS-GATE): 15 echte Bugs, die der kaputte tsc verdeckt hat

David44a0692a05cb
diff --git a/src/api/__tests__/app-wide-smoke.test.ts b/src/api/__tests__/app-wide-smoke.test.ts
index 34738ca2..1dfb4dd9 100644
--- a/src/api/__tests__/app-wide-smoke.test.ts
+++ b/src/api/__tests__/app-wide-smoke.test.ts
@@ -18,8 +18,6 @@ import { describe, it, expect } from 'vitest'
import {
classifyModel,
COMPONENT_REGISTRY,
- isImageModelType,
- isVideoModelType,
type ModelType,
} from '../comfyui'
import { MODEL_TYPE_DEFAULTS } from '../../stores/createStore'
@@ -61,7 +59,7 @@ function fullNodes(): CategorizedNodes {
const defaultModels: AvailableModels = {
checkpoints: ['test.safetensors'], unets: ['test_unet.safetensors'],
vaes: ['test_vae.safetensors'], clips: ['test_clip.safetensors'],
- loras: [], controlnets: [], ipadapters: [], motionModels: ['mm_sd_v15_v2.ckpt'],
+ motionModels: ['mm_sd_v15_v2.ckpt'],
}
// ── MODEL_TYPE_DEFAULTS completeness ────────────────────────────────────
diff --git a/src/api/__tests__/backend-urls.test.ts b/src/api/__tests__/backend-urls.test.ts
index 6a2c2ecd..e61034c4 100644
--- a/src/api/__tests__/backend-urls.test.ts
+++ b/src/api/__tests__/backend-urls.test.ts
@@ -1,4 +1,4 @@
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import { describe, it, expect, beforeEach, afterEach } from 'vitest'
// backend.ts reads (window as any).__TAURI__ at call time, so we need to
// provide a `window` global in node environment and then import the module.
diff --git a/src/api/__tests__/comfyui-bundles.test.ts b/src/api/__tests__/comfyui-bundles.test.ts
index 17f666c6..d75de35b 100644
--- a/src/api/__tests__/comfyui-bundles.test.ts
+++ b/src/api/__tests__/comfyui-bundles.test.ts
@@ -190,7 +190,9 @@ describe('2.5.8 specialized lane bundles (music / lipsync / motion)', () => {
it('gguf lane bundles request the gguf node pack', () => {
for (const b of laneBundles()) {
- const hasGguf = b.files.some((f) => f.filename.toLowerCase().endsWith('.gguf'))
+ // `filename` is optional on DiscoverModel (Ollama-tag entries carry
+ // none), and a file without one is not a gguf either way.
+ const hasGguf = b.files.some((f) => f.filename?.toLowerCase().endsWith('.gguf'))
if (hasGguf) expect(b.customNodes).toContain('gguf')
}
})
diff --git a/src/api/__tests__/comfyui-integration.test.ts b/src/api/__tests__/comfyui-integration.test.ts
index fcb25bef..14e15837 100644
--- a/src/api/__tests__/comfyui-integration.test.ts
+++ b/src/api/__tests__/comfyui-integration.test.ts
@@ -4,8 +4,8 @@
* WITHOUT requiring any real ComfyUI instance or model downloads.
*/
-import { getVideoBundles, getImageBundles, CUSTOM_NODE_REGISTRY, type ModelBundle } from '../discover'
-import { classifyModel, MODEL_TYPE_DEFAULTS, COMPONENT_REGISTRY as COMFYUI_REGISTRY, isVideoModelType } from '../comfyui'
+import { getVideoBundles, getImageBundles, CUSTOM_NODE_REGISTRY } from '../discover'
+import { classifyModel, MODEL_TYPE_DEFAULTS, COMPONENT_REGISTRY as COMFYUI_REGISTRY } from '../comfyui'
import { determineStrategy } from '../dynamic-workflow'
import type { CategorizedNodes, AvailableModels } from '../comfyui-nodes'
diff --git a/src/api/__tests__/comfyui-models.test.ts b/src/api/__tests__/comfyui-models.test.ts
index c6d63594..7a5f2c82 100644
--- a/src/api/__tests__/comfyui-models.test.ts
+++ b/src/api/__tests__/comfyui-models.test.ts
@@ -6,7 +6,7 @@ import {
MODEL_TYPE_DEFAULTS,
COMPONENT_REGISTRY,
} from '../comfyui'
-import { determineStrategy, type WorkflowStrategy } from '../dynamic-workflow'
+import { determineStrategy } from '../dynamic-workflow'
import type { CategorizedNodes, AvailableModels } from '../comfyui-nodes'
// ─── classifyModel ───
@@ -176,9 +176,9 @@ describe('COMPONENT_REGISTRY', () => {
it('types needing separate VAE have vae spec', () => {
for (const [type, entry] of Object.entries(COMPONENT_REGISTRY)) {
if (entry.needsSeparateVAE) {
- expect(entry.vae).toBeDefined()
- expect(entry.vae!.matchPatterns.length).toBeGreaterThan(0)
- expect(entry.vae!.downloadFilename).toBeTruthy()
+ expect(entry.vae, `${type} needs a vae spec`).toBeDefined()
+ expect(entry.vae!.matchPatterns.length, `${type} vae matchPatterns`).toBeGreaterThan(0)
+ expect(entry.vae!.downloadFilename, `${type} vae downloadFilename`).toBeTruthy()
}
}
})
@@ -186,9 +186,9 @@ describe('COMPONENT_REGISTRY', () => {
it('types needing separate CLIP have clip spec', () => {
for (const [type, entry] of Object.entries(COMPONENT_REGISTRY)) {
if (entry.needsSeparateCLIP) {
- expect(entry.clip).toBeDefined()
- expect(entry.clip!.matchPatterns.length).toBeGreaterThan(0)
- expect(entry.clip!.downloadFilename).toBeTruthy()
+ expect(entry.clip, `${type} needs a clip spec`).toBeDefined()
+ expect(entry.clip!.matchPatterns.length, `${type} clip matchPatterns`).toBeGreaterThan(0)
+ expect(entry.clip!.downloadFilename, `${type} clip downloadFilename`).toBeTruthy()
}
}
})
diff --git a/src/api/__tests__/ernie-image-workflow.test.ts b/src/api/__tests__/ernie-image-workflow.test.ts
index b0bd725d..c3fd127d 100644
--- a/src/api/__tests__/ernie-image-workflow.test.ts
+++ b/src/api/__tests__/ernie-image-workflow.test.ts
@@ -10,7 +10,7 @@
*/
import { describe, it, expect } from 'vitest'
import { classifyModel, MODEL_TYPE_DEFAULTS as COMFYUI_DEFAULTS, COMPONENT_REGISTRY, isImageModelType, type ModelType } from '../comfyui'
-import { determineStrategy, type WorkflowStrategy } from '../dynamic-workflow'
+import { determineStrategy } from '../dynamic-workflow'
import { getImageBundles } from '../discover'
import type { CategorizedNodes, AvailableModels } from '../comfyui-nodes'
@@ -31,7 +31,7 @@ function allNodes(): CategorizedNodes {
const defaultModels: AvailableModels = {
checkpoints: [], unets: ['ernie-image-turbo.safetensors'],
vaes: ['flux2-vae.safetensors'], clips: ['ministral-3-3b.safetensors'],
- loras: [], controlnets: [], ipadapters: [],
+ motionModels: [],
}
// ── Classification ──────────────────────────────────────────────────────
diff --git a/src/api/__tests__/provider-ollama.test.ts b/src/api/__tests__/provider-ollama.test.ts
index 6ebe5cae..f778e222 100644
--- a/src/api/__tests__/provider-ollama.test.ts
+++ b/src/api/__tests__/provider-ollama.test.ts
@@ -6,7 +6,7 @@
*/
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { ProviderError } from '../providers/types'
-import type { ProviderConfig } from '../providers/types'
+import type { ProviderConfig, ToolDefinition } from '../providers/types'
// Mock the backend module — Ollama uses localFetch / localFetchStream instead of bare fetch.
// Issue #31: apiUrl() now delegates to ollamaUrl() from backend.ts for a single
@@ -19,10 +19,9 @@ vi.mock('../backend', () => ({
}))
import { OllamaProvider } from '../providers/ollama-provider'
-import { localFetch, localFetchStream } from '../backend'
+import { localFetch } from '../backend'
const mockLocalFetch = localFetch as ReturnType<typeof vi.fn>
-const mockLocalFetchStream = localFetchStream as ReturnType<typeof vi.fn>
function makeConfig(overrides: Partial<ProviderConfig> = {}): ProviderConfig {
return {
@@ -30,6 +29,8 @@ function makeConfig(overrides: Partial<ProviderConfig> = {}): ProviderConfig {
name: 'Ollama',
enabled: true,
baseUrl: 'http://localhost:11434',
+ // Required by ProviderConfig; empty is what a local backend stores.
+ apiKey: '',
isLocal: true,
...overrides,
}
@@ -405,8 +406,8 @@ describe('OllamaProvider', () => {
}), { status: 200 })
)
- const tools = [{
- type: 'function' as const,
+ const tools: ToolDefinition[] = [{
+ type: 'function',
function: {
name: 'calculator',
description: 'Do math',
diff --git a/src/api/__tests__/provider-openai.test.ts b/src/api/__tests__/provider-openai.test.ts
index e7943543..7d03b7be 100644
--- a/src/api/__tests__/provider-openai.test.ts
+++ b/src/api/__tests__/provider-openai.test.ts
@@ -7,7 +7,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { OpenAIProvider } from '../providers/openai-provider'
import { ProviderError } from '../providers/types'
-import type { ProviderConfig } from '../providers/types'
+import type { ProviderConfig, ToolDefinition } from '../providers/types'
function makeConfig(overrides: Partial<ProviderConfig> = {}): ProviderConfig {
return {
@@ -749,9 +749,13 @@ describe('OpenAIProvider', () => {
// tool/function message). parseError must tag that 'tools_unsupported' so the
// chat layer shows a clean note instead of a raw status error / AbortError.
describe('tools_unsupported (model without function calling)', () => {
- const toolDef = [{
- type: 'function' as const,
- function: { name: 'web_search', description: 'x', parameters: { type: 'object', properties: {} } },
+ const toolDef: ToolDefinition[] = [{
+ type: 'function',
+ function: {
+ name: 'web_search',
+ description: 'x',
+ parameters: { type: 'object', properties: {}, required: [] },
+ },
}]
it('tags a 405 on a tool request as tools_unsupported', async () => {
diff --git a/src/api/__tests__/rag.test.ts b/src/api/__tests__/rag.test.ts
index 9da60c62..1178f233 100644
--- a/src/api/__tests__/rag.test.ts
+++ b/src/api/__tests__/rag.test.ts
@@ -9,7 +9,7 @@
*/
import { describe, it, expect } from 'vitest'
import { chunkText, searchVectors } from '../rag'
-import type { TextChunk, VectorSearchResult } from '../../types/rag'
+import type { TextChunk } from '../../types/rag'
// ── Helpers ──────────────────────────────────────────────────────
diff --git a/src/api/__tests__/wrapper-node-names.test.ts b/src/api/__tests__/wrapper-node-names.test.ts
index 480b8930..e97fc552 100644
--- a/src/api/__tests__/wrapper-node-names.test.ts
+++ b/src/api/__tests__/wrapper-node-names.test.ts
@@ -167,7 +167,7 @@ describe('lanes whose builders were removed stay closed', () => {
const models: AvailableModels = {
checkpoints: ['test.safetensors'], unets: ['test_unet.safetensors'],
vaes: ['test_vae.safetensors'], clips: ['test_clip.safetensors'],
- loras: [], controlnets: [], ipadapters: [], motionModels: [],
+ motionModels: [],
}
for (const type of ['cogvideo', 'pyramidflow', 'allegro'] as ModelType[]) {
diff --git a/src/api/agents/__tests__/sub-agent.test.ts b/src/api/agents/__tests__/sub-agent.test.ts
index 63e27294..c52fd4b3 100644
--- a/src/api/agents/__tests__/sub-agent.test.ts
+++ b/src/api/agents/__tests__/sub-agent.test.ts
@@ -10,7 +10,18 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'
const chatWithTools = vi.fn()
const toolExecute = vi.fn(async () => 'tool output')
-const auditRecord = vi.fn(() => 'audit-1')
+// Typed like the real useToolAuditStore.record, so the assertions below can
+// read what the runner passed; a bare `vi.fn(() => ...)` has an empty args
+// tuple and `calls[0][0]` does not exist on it.
+const auditRecord = vi.fn((_input: {
+ id?: string
+ convId: string
+ toolCallId: string
+ toolName: string
+ args: Record<string, unknown>
+ parentToolCallId?: string
+ startedAt?: number
+}) => 'audit-1')
const auditComplete = vi.fn()
let permLevel: 'auto' | 'confirm' | 'blocked' = 'auto'
diff --git a/src/api/agents/budget.ts b/src/api/agents/budget.ts
index 258f084f..ffc59f95 100644
--- a/src/api/agents/budget.ts
+++ b/src/api/agents/budget.ts
@@ -39,7 +39,11 @@ export class AgentBudget {
private toolCalls = 0
private iterations = 0
- constructor(private caps: BudgetCaps) {}
+ private readonly caps: BudgetCaps
+
+ constructor(caps: BudgetCaps) {
+ this.caps = caps
+ }
/** Record N new tool calls (accepts batch). */
addToolCalls(n: number): void {
diff --git a/src/api/backend.ts b/src/api/backend.ts
index aa24ae8c..0dba9478 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -781,7 +781,7 @@ export async function fetchExternalBytes(url: string): Promise<ArrayBuffer> {
* Tauri the browser can't fetch localhost directly (CORS) so we route through
* the Rust byte proxy; in dev a plain fetch works.
*/
-export async function fetchLocalhostBytes(url: string): Promise<Uint8Array> {
+export async function fetchLocalhostBytes(url: string): Promise<Uint8Array<ArrayBuffer>> {
if (isTauri()) {
const invoke = await getInvoke()
const bytes = (await invoke('proxy_localhost_stream', { url, method: 'GET', body: null })) as number[]
diff --git a/src/api/discover.ts b/src/api/discover.ts
index edf22114..04697c78 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -757,7 +757,10 @@ export interface ComponentSpec {
}
export interface ComponentRequirements {
- loader: 'UNETLoader' | 'CheckpointLoaderSimple'
+ // SVD loads through ComfyUI's ImageOnlyCheckpointLoader — the registry
+ // below has always said so, only this union (a stale copy of the one in
+ // comfyui.ts, which lists all three) had not caught up.
+ loader: 'UNETLoader' | 'CheckpointLoaderSimple' | 'ImageOnlyCheckpointLoader'
vae?: ComponentSpec
clip?: ComponentSpec
clipSecondary?: ComponentSpec
diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.ts
index ee7bdac7..d25a7105 100644
--- a/src/api/mcp/builtin-tools.ts
+++ b/src/api/mcp/builtin-tools.ts
@@ -1299,7 +1299,12 @@ async function executeRunWorkflow(args: Record<string, any>): Promise<string> {
onError: (error: string) => { finalOutput = `Workflow error: ${error}` },
}
- const initialVars = args.input ? { user_input: args.input, last_output: args.input } : {}
+ // The engine interpolates these variables into prompts as text. The schema
+ // says `input` is a string, but the value comes from a model, so a number or
+ // object reaching this line has to become text here rather than deeper in.
+ const initialVars: Record<string, string> = args.input
+ ? { user_input: String(args.input), last_output: String(args.input) }
+ : {}
_workflowDepth++
try {
const engine = new WorkflowEngine(workflow, 'tool-execution', callbacks, initialVars, _workflowDepth)
diff --git a/src/api/mcp/external-client.ts b/src/api/mcp/external-client.ts
index d29ca951..e0496aa4 100644
--- a/src/api/mcp/external-client.ts
+++ b/src/api/mcp/external-client.ts
@@ -61,7 +61,10 @@ export class MCPExternalClient {
*/
private onExit?: (serverId: string) => void
- constructor(private config: MCPServerConfig, opts?: { onExit?: (serverId: string) => void }) {
+ private readonly config: MCPServerConfig
+
+ constructor(config: MCPServerConfig, opts?: { onExit?: (serverId: string) => void }) {
+ this.config = config
this.onExit = opts?.onExit
}
diff --git a/src/api/mlx-video.ts b/src/api/mlx-video.ts
index 033aa2e0..d8be66ea 100644
--- a/src/api/mlx-video.ts
+++ b/src/api/mlx-video.ts
@@ -156,7 +156,7 @@ const DECODE_CHUNK = 4 * 1024 * 1024
/** Give the event loop a real turn (a microtask would not let anything paint). */
const yieldToRenderer = () => new Promise<void>((resolve) => setTimeout(resolve, 0))
-async function decodeBase64(b64: string): Promise<Uint8Array> {
+async function decodeBase64(b64: string): Promise<Uint8Array<ArrayBuffer>> {
const binary = atob(b64)
const bytes = new Uint8Array(binary.length)
for (let start = 0; start < binary.length; start += DECODE_CHUNK) {
diff --git a/src/api/ollama.ts b/src/api/ollama.ts
index aced6608..b47b4b92 100644
--- a/src/api/ollama.ts
+++ b/src/api/ollama.ts
@@ -115,9 +115,13 @@ export async function chatStream(
// and is a no-op on cards with headroom (Ollama already maxes layers
// when it can fit them).
const opts = { ...options }
+ // The caller's AbortSignal used to stop at this function: it was accepted
+ // and then never handed to the transport, so Stop left the HTTP request
+ // (and Ollama's generation behind it) running to completion.
const res = await localFetchStream(ollamaUrl("/chat"), {
method: "POST",
body: JSON.stringify({ model, messages, options: opts, stream: true }),
+ signal,
})
if (!res.ok) throw new Error("Failed to start chat")
return res
@@ -133,9 +137,11 @@ export async function chatStreamWithTools(
): Promise<Response> {
// v2.4.6 Bug L: see chatStream() above — same num_gpu:99 removal.
const opts = { ...options }
+ // Same dropped AbortSignal as chatStream() above.
const res = await localFetchStream(ollamaUrl("/chat"), {
method: "POST",
body: JSON.stringify({ model, messages, tools, options: opts, stream: true }),
+ signal,
})
if (!res.ok) {
// Try to extract Ollama's error message
diff --git a/src/api/providers/anthropic-provider.ts b/src/api/providers/anthropic-provider.ts
index 954fbbb7..a62b7b4f 100644
--- a/src/api/providers/anthropic-provider.ts
+++ b/src/api/providers/anthropic-provider.ts
@@ -134,7 +134,11 @@ function applyCacheControl(body: MessagesBody): void {
export class AnthropicProvider implements ProviderClient {
readonly id = 'anthropic' as const
- constructor(private config: ProviderConfig) {}
+ private readonly config: ProviderConfig
+
+ constructor(config: ProviderConfig) {
+ this.config = config
+ }
private get baseUrl(): string {
return this.config.baseUrl.replace(/\/+$/, '')
diff --git a/src/api/providers/ollama-provider.ts b/src/api/providers/ollama-provider.ts
index dd5a3a65..fb0aad19 100644
--- a/src/api/providers/ollama-provider.ts
+++ b/src/api/providers/ollama-provider.ts
@@ -57,7 +57,13 @@ interface OllamaModelEntry {
export class OllamaProvider implements ProviderClient {
readonly id = 'ollama' as const
- constructor(private config: ProviderConfig) {}
+ /**
+ * The config is accepted for a uniform provider constructor signature but
+ * deliberately not stored: every URL goes through `ollamaUrl()` (see
+ * `apiUrl()` below, Issue #31), so a stored `config.baseUrl` would only be
+ * a second, silently diverging source of truth.
+ */
+ constructor(_config: ProviderConfig) {}
/**
* Build a full Ollama API URL. Delegates to `ollamaUrl()` from backend.ts
@@ -239,7 +245,7 @@ export class OllamaProvider implements ProviderClient {
messages: ChatMessage[],
tools: ToolDefinition[],
options?: ChatOptions,
- ): Promise<{ content: string; toolCalls: ToolCall[] }> {
+ ): Promise<{ content: string; toolCalls: ToolCall[]; promptEvalCount?: number; evalCount?: number; thinking?: string }> {
// Bug B3: same contract as chatStream. A turn that really carries a
// `tools` payload keeps the native tool channel. The strategy resolution
// only sends one after Ollama itself reported the `tools` capability for
@@ -319,6 +325,11 @@ export class OllamaProvider implements ProviderClient {
content: data.message?.content || '',
thinking: data.message?.thinking || '',
toolCalls,
+ // Real token usage from the non-streaming response, same fields
+ // chatStream() already forwards — without them the agent TokenCounter
+ // falls back to a char/4 estimate for every Ollama tool turn.
+ promptEvalCount: data.prompt_eval_count,
+ evalCount: data.eval_count,
}
}
diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.ts
index 6326beac..597d87bb 100644
--- a/src/api/providers/openai-provider.ts
+++ b/src/api/providers/openai-provider.ts
@@ -240,7 +240,11 @@ export function __clearContextCatalogForTests(): void {
export class OpenAIProvider implements ProviderClient {
readonly id = 'openai' as const
- constructor(private config: ProviderConfig) {}
+ private readonly config: ProviderConfig
+
+ constructor(config: ProviderConfig) {
+ this.config = config
+ }
private catalogKey(model: string): string {
return `${this.baseUrl}|${model}`
diff --git a/src/api/voice.ts b/src/api/voice.ts
index 57fa4415..f4e19e6d 100644
--- a/src/api/voice.ts
+++ b/src/api/voice.ts
@@ -510,7 +510,10 @@ let webAudioPlayback: { source: AudioBufferSourceNode; done: () => void } | null
* playNeuralAudio). Returns null for anything that isn't such a wav. */
export function parseWavPcm(
bytes: ArrayBuffer,
-): { sampleRate: number; channels: Float32Array[] } | null {
+ // `Float32Array<ArrayBuffer>`, not the default `ArrayBufferLike`: the
+ // channels are allocated here, so they are never SharedArrayBuffer-backed,
+ // and only this precise form may be handed to AudioBuffer.copyToChannel.
+): { sampleRate: number; channels: Float32Array<ArrayBuffer>[] } | null {
const view = new DataView(bytes);
if (bytes.byteLength < 44) return null;
if (view.getUint32(0, false) !== 0x52494646) return null; // 'RIFF'
diff --git a/src/components/agents/WorkflowRunner.tsx b/src/components/agents/WorkflowRunner.tsx
index 5d6211ca..3fce8077 100644
--- a/src/components/agents/WorkflowRunner.tsx
+++ b/src/components/agents/WorkflowRunner.tsx
@@ -25,7 +25,6 @@ interface WorkflowRunnerProps {
executionId: string
workflowSteps: Array<{ id: string; label: string; type: string }>
waitingForInput: string | null
- currentStepLabel: string
onProvideInput: (input: string) => void
onCancel: () => void
}
@@ -34,7 +33,6 @@ export function WorkflowRunner({
executionId,
workflowSteps,
waitingForInput,
- currentStepLabel,
onProvideInput,
onCancel,
}: WorkflowRunnerProps) {
diff --git a/src/components/import/ChatbotImporter.tsx b/src/components/import/ChatbotImporter.tsx
index 4040572e..be72f8b2 100644
--- a/src/components/import/ChatbotImporter.tsx
+++ b/src/components/import/ChatbotImporter.tsx
@@ -23,7 +23,9 @@ const PLATFORM_LABEL: Record<ChatbotPlatform, string> = {
export function ChatbotImporter() {
const conversationId = useChatStore(s => s.activeConversationId)
- const rag = useRAG(conversationId || undefined)
+ // useRAG takes `string | null` and already handles the null case; the old
+ // `|| undefined` handed it a value its own signature does not admit.
+ const rag = useRAG(conversationId)
const uploadDocument = rag.uploadDocument
const [conversations, setConversations] = useState<NormalisedConversation[]>([])
diff --git a/src/components/three/ParticleField.tsx b/src/components/three/ParticleField.tsx
index da4cad9b..4032662c 100644
--- a/src/components/three/ParticleField.tsx
+++ b/src/components/three/ParticleField.tsx
@@ -1,16 +1,23 @@
import { useRef, useMemo } from 'react'
import { useFrame, useThree } from '@react-three/fiber'
import * as THREE from 'three'
-import { useSettingsStore } from '../../stores/settingsStore'
-import { PARTICLE_COUNTS } from '../../lib/constants'
+
+/**
+ * The field used to read a `particleDensity` setting and index a
+ * `PARTICLE_COUNTS` table with it. Neither exists any more: `Settings` has no
+ * density key and `lib/constants` exports no such table, so the lookup was
+ * `undefined[undefined]` — a TypeError on the first render of this component,
+ * masked only by the fact that nothing mounts ParticleBackground today.
+ * The count is the value the old `|| 3000` fallback would have produced.
+ */
+const PARTICLE_COUNT = 3000
export function ParticleField() {
const pointsRef = useRef<THREE.Points>(null)
const mouseRef = useRef(new THREE.Vector2(0, 0))
const { viewport } = useThree()
- const particleDensity = useSettingsStore((s) => s.settings.particleDensity)
- const count = PARTICLE_COUNTS[particleDensity] || 3000
+ const count = PARTICLE_COUNT
const { positions, colors, sizes } = useMemo(() => {
const positions = new Float32Array(count * 3)
diff --git a/src/hooks/__tests__/useCodex-prompt-contract.test.ts b/src/hooks/__tests__/useCodex-prompt-contract.test.ts
index a47dc1cc..bfa57fef 100644
--- a/src/hooks/__tests__/useCodex-prompt-contract.test.ts
+++ b/src/hooks/__tests__/useCodex-prompt-contract.test.ts
@@ -13,7 +13,7 @@
import { describe, it, expect } from 'vitest'
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
-import { dirname, join, resolve } from 'path'
+import { dirname, resolve } from 'path'
function readSource(relativePath: string): string {
const __filename = fileURLToPath(import.meta.url)
diff --git a/src/hooks/useABCompare.ts b/src/hooks/useABCompare.ts
index 824e0713..5bd64e3f 100644
--- a/src/hooks/useABCompare.ts
+++ b/src/hooks/useABCompare.ts
@@ -37,8 +37,11 @@ export function useABCompare() {
// Build messages for the providers
const persona = useSettingsStore.getState().getActivePersona()
const chatMessages: ChatMessage[] = []
- if (persona?.prompt) {
- chatMessages.push({ role: 'system', content: persona.prompt })
+ // `Persona` carries `systemPrompt`, never `prompt`: the old read was
+ // always undefined, so a comparison ran with no persona at all while the
+ // rest of the app (chat, Codex) sent one.
+ if (persona?.systemPrompt) {
+ chatMessages.push({ role: 'system', content: persona.systemPrompt })
}
// Include previous messages for context
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index bebd098c..158d1666 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -504,7 +504,9 @@ export function useCodex() {
name: activeModel,
supportsTools: pickerMeta && pickerMeta.type === 'text' ? pickerMeta.supportsTools : undefined,
})
- const modelToUse = activeModel.includes('::') ? activeModel.split('::')[1] : activeModel
+ // The registry already stripped the `provider::` prefix when it resolved
+ // the client; re-splitting the name here was a second copy of that rule.
+ const modelToUse = modelId
// G37b (R21d wire proof, 2026-08-08): the picker row is silent for the
// managed built-in engine (useModels synthesizes its rows without ever
// running listModels), so ask the server itself before the first request.
diff --git a/src/hooks/useKeyboardShortcuts.ts b/src/hooks/useKeyboardShortcuts.ts
index fb75225b..5a48e48b 100644
--- a/src/hooks/useKeyboardShortcuts.ts
+++ b/src/hooks/useKeyboardShortcuts.ts
@@ -32,7 +32,9 @@ export function useKeyboardShortcuts() {
const model = useModelStore.getState().activeModel
const persona = useSettingsStore.getState().getActivePersona()
if (model) {
- useChatStore.getState().createConversation(model, persona?.prompt || '')
+ // Same field mix-up as useABCompare had: `Persona.systemPrompt`.
+ // Ctrl+N used to open every chat with an empty system prompt.
+ useChatStore.getState().createConversation(model, persona?.systemPrompt || '')
}
useUIStore.getState().setView('chat')
}
diff --git a/src/hooks/useToolSupport.ts b/src/hooks/useToolSupport.ts
index 1903c294..bb50f37e 100644
--- a/src/hooks/useToolSupport.ts
+++ b/src/hooks/useToolSupport.ts
@@ -22,9 +22,13 @@ export interface ActiveToolSupport {
export function useToolSupport(): ActiveToolSupport {
const activeModel = useModelStore((s) => s.activeModel)
- const supportsTools = useModelStore(
- (s) => s.models.find((m) => m.name === s.activeModel)?.supportsTools,
- )
+ // Only the text variants of the AIModel union carry `supportsTools`; the
+ // image/video rows have no such field, so the picker row is narrowed the
+ // same way useCodex narrows it before asking toolStrategyFor.
+ const supportsTools = useModelStore((s) => {
+ const row = s.models.find((m) => m.name === s.activeModel)
+ return row && row.type === 'text' ? row.supportsTools : undefined
+ })
if (!activeModel) {
return { support: 'none', canUseTools: false, reason: 'Pick a model first.', modelName: null }
diff --git a/src/hooks/useWorkflow.ts b/src/hooks/useWorkflow.ts
index 69c3253e..091c1c03 100644
--- a/src/hooks/useWorkflow.ts
+++ b/src/hooks/useWorkflow.ts
@@ -51,7 +51,7 @@ export function useWorkflow() {
setCurrentStepLabel(step.label)
store.updateExecution(executionId, { currentStepIndex: stepIndex })
},
- onStepComplete: (stepIndex, result) => {
+ onStepComplete: (_stepIndex, result) => {
store.addStepResult(executionId, result)
},
onStepError: (stepIndex, error) => {
diff --git a/src/lib/__tests__/backend-detector.test.ts b/src/lib/__tests__/backend-detector.test.ts
index 5db8d4f7..10329f9e 100644
--- a/src/lib/__tests__/backend-detector.test.ts
+++ b/src/lib/__tests__/backend-detector.test.ts
@@ -15,7 +15,6 @@ vi.mock('../../api/backend', () => ({
}))
import { detectLocalBackends } from '../backend-detector'
-import type { DetectedBackend } from '../backend-detector'
import { isTauri, localFetch } from '../../api/backend'
import { PROVIDER_PRESETS } from '../../api/providers/types'
diff --git a/src/lib/__tests__/constants-validation.test.ts b/src/lib/__tests__/constants-validation.test.ts
index 990120b1..a643f501 100644
--- a/src/lib/__tests__/constants-validation.test.ts
+++ b/src/lib/__tests__/constants-validation.test.ts
@@ -302,7 +302,7 @@ describe('constants-validation', () => {
it('all flags are booleans', () => {
for (const [key, value] of Object.entries(FEATURE_FLAGS)) {
- expect(typeof value).toBe('boolean')
+ expect(typeof value, `FEATURE_FLAGS.${key}`).toBe('boolean')
}
})
})
diff --git a/src/lib/__tests__/memory-e2e.test.ts b/src/lib/__tests__/memory-e2e.test.ts
index 7ea9a098..f338a4e2 100644
--- a/src/lib/__tests__/memory-e2e.test.ts
+++ b/src/lib/__tests__/memory-e2e.test.ts
@@ -78,7 +78,7 @@ describe('Memory CRUD E2E', () => {
const id1 = addMem('user', 'Speaks German', 'User primarily communicates in German')
const id2 = addMem('feedback', 'No emojis', 'User wants no emojis in UI')
const id3 = addMem('project', 'v2.0 launch', 'Currently working on v2.0 launch')
- const id4 = addMem('reference', 'GitHub repo', 'Main repo at github.com/test/app')
+ addMem('reference', 'GitHub repo', 'Main repo at github.com/test/app')
expect(useMemoryStore.getState().entries).toHaveLength(4)
expect(id1).toBeTruthy()
diff --git a/src/lib/__tests__/systemCheck.test.ts b/src/lib/__tests__/systemCheck.test.ts
index 069ca3e1..625d43ed 100644
--- a/src/lib/__tests__/systemCheck.test.ts
+++ b/src/lib/__tests__/systemCheck.test.ts
@@ -1,4 +1,4 @@
-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+import { describe, it, expect, beforeEach, afterEach } from 'vitest'
// Provide minimal DOM mocks for node environment before importing
// systemCheck.ts needs `document.createElement('canvas')` and `navigator.deviceMemory`
diff --git a/src/lib/__tests__/utilities.test.ts b/src/lib/__tests__/utilities.test.ts
index 33cd0c2e..5db50b52 100644
--- a/src/lib/__tests__/utilities.test.ts
+++ b/src/lib/__tests__/utilities.test.ts
@@ -198,10 +198,14 @@ describe('getRecommendations', () => {
const high = getRecommendations('high')
const lowNames = low.map((r) => r.name)
+ const mediumNames = medium.map((r) => r.name)
const highNames = high.map((r) => r.name)
- // Low and high should have at least some different models
+ // Every tier recommends a different set — medium was fetched but never
+ // asserted on before, so a medium list identical to low/high slipped through.
expect(lowNames).not.toEqual(highNames)
+ expect(mediumNames).not.toEqual(lowNames)
+ expect(mediumNames).not.toEqual(highNames)
})
it('low tier recommends smaller models', () => {
diff --git a/src/lib/__tests__/workflow-e2e.test.ts b/src/lib/__tests__/workflow-e2e.test.ts
index 954f5b45..92a685a3 100644
--- a/src/lib/__tests__/workflow-e2e.test.ts
+++ b/src/lib/__tests__/workflow-e2e.test.ts
@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach } from 'vitest'
import { useAgentWorkflowStore } from '../../stores/agentWorkflowStore'
import { BUILT_IN_WORKFLOWS } from '../built-in-workflows'
import { useMemoryStore } from '../../stores/memoryStore'
-import type { AgentWorkflow, WorkflowStep } from '../../types/agent-workflows'
// ── Helpers ───────────────────────────────────────────────────
diff --git a/src/lib/render/__tests__/cloud-jobs.test.ts b/src/lib/render/__tests__/cloud-jobs.test.ts
index 785bd543..77756c8c 100644
--- a/src/lib/render/__tests__/cloud-jobs.test.ts
+++ b/src/lib/render/__tests__/cloud-jobs.test.ts
@@ -12,6 +12,15 @@ describe('intentToJob', () => {
eraser: { kind: 'image', op: 'eraser' },
video: { kind: 'video', op: 'generate' },
animate: { kind: 'video', op: 'animate' },
+ // The five 2.5.8 cloud categories. The Record<CreateIntent, ...> type
+ // says "every intent", but these were missing, so the only coverage
+ // intentToJob had for them was the switch falling through to
+ // image/generate — which is what the map now pins down.
+ character: { kind: 'image', op: 'lora-train' },
+ lipsync: { kind: 'video', op: 'lipsync' },
+ music: { kind: 'audio', op: 'music' },
+ extend: { kind: 'video', op: 'extend' },
+ motion: { kind: 'video', op: 'motion' },
}
for (const [intent, expected] of Object.entries(cases)) {
expect(intentToJob(intent as CreateIntent)).toEqual(expected)
diff --git a/src/lib/tool-timeout.ts b/src/lib/tool-timeout.ts
index 510e008b..94db38fe 100644
--- a/src/lib/tool-timeout.ts
+++ b/src/lib/tool-timeout.ts
@@ -55,7 +55,10 @@ export function raceWithToolTimeout(run: Promise<string>, name: string, capMs: n
let timer: ReturnType<typeof setTimeout> | undefined
const deadline = new Promise<string>((_, reject) => {
timer = setTimeout(
- () => reject(new Error(`Tool execution timed out (${Math.round(capMs / 1000)}s)`)),
+ // The tool name was passed in by both callers but never used, so every
+ // timeout reached the model as an anonymous "Tool execution timed out"
+ // — in a parallel batch it could not tell which tool had died.
+ () => reject(new Error(`Tool execution timed out: ${name} (${Math.round(capMs / 1000)}s)`)),
capMs,
)
})
diff --git a/src/stores/__tests__/chatStore-operations.test.ts b/src/stores/__tests__/chatStore-operations.test.ts
index 94ed0b5a..42cc1652 100644
--- a/src/stores/__tests__/chatStore-operations.test.ts
+++ b/src/stores/__tests__/chatStore-operations.test.ts
@@ -42,8 +42,11 @@ describe('chatStore — conversation CRUD', () => {
it('creates Codex conversation with correct title', () => {
const id = useChatStore.getState().createConversation('qwen3-coder:30b', '', 'codex')
- expect(useChatStore.getState().conversations[0].title).toBe('Coding Agent')
- expect(useChatStore.getState().conversations[0].mode).toBe('codex')
+ // Assert on the conversation the call actually returned, not on whatever
+ // happens to sit at index 0.
+ const conv = useChatStore.getState().conversations.find((c) => c.id === id)!
+ expect(conv.title).toBe('Coding Agent')
+ expect(conv.mode).toBe('codex')
})
it('auto-numbers remote conversations', () => {
diff --git a/src/stores/__tests__/stores.test.ts b/src/stores/__tests__/stores.test.ts
index d6209f6a..158caee5 100644
--- a/src/stores/__tests__/stores.test.ts
+++ b/src/stores/__tests__/stores.test.ts
@@ -230,8 +230,10 @@ describe('modelStore', () => {
useModelStore.setState({
models: [],
activeModel: null,
- pullProgress: null,
- isPulling: false,
+ // `pullProgress` / `isPulling` are long gone from ModelState — pulls are
+ // tracked per model in `activePulls`. Setting the dead keys wrote junk
+ // into the store instead of resetting anything.
+ activePulls: {},
categoryFilter: 'all',
})
})
@@ -457,7 +459,7 @@ describe('memoryStore', () => {
// injected prompt block, and that the manual override caps the count.
describe('getMemoriesForPrompt injection', () => {
it('injects a keyword-matching memory into the prompt block', () => {
- useMemoryStore.getState().addMemory({ type: 'user', title: 'Favorite language', description: '', content: 'My favorite programming language is Rust', tags: [] })
+ useMemoryStore.getState().addMemory({ type: 'user', title: 'Favorite language', description: '', content: 'My favorite programming language is Rust', tags: [], source: 'manual' })
const block = useMemoryStore.getState().getMemoriesForPrompt('what is my favorite programming language?', 32768)
expect(block).toContain('Rust')
})
@@ -465,7 +467,7 @@ describe('memoryStore', () => {
// Unique marker only in CONTENT (title is shared) so each memory shows
// its marker exactly once in the rendered block.
for (const m of ['uniqaaa', 'uniqbbb', 'uniqccc']) {
- useMemoryStore.getState().addMemory({ type: 'user', title: 'note', description: '', content: `shared topic ${m}`, tags: [] })
+ useMemoryStore.getState().addMemory({ type: 'user', title: 'note', description: '', content: `shared topic ${m}`, tags: [], source: 'manual' })
}
useMemoryStore.setState({ settings: { ...useMemoryStore.getState().settings, maxMemoriesOverride: 1 } })
const block = useMemoryStore.getState().getMemoriesForPrompt('shared topic', 32768)
diff --git a/src/stores/memoryStore.ts b/src/stores/memoryStore.ts
index ad829e73..5780befe 100644
--- a/src/stores/memoryStore.ts
+++ b/src/stores/memoryStore.ts
@@ -763,8 +763,12 @@ export const useMemoryStore = create<MemoryState>()(
},
getMemoryForPrompt: (query, maxChars = 2000) => {
- // Legacy: assume 8K context for backward compat
- return get().getMemoriesForPrompt(query, 8192)
+ // Legacy: the current API budgets in context TOKENS, so the 8K
+ // assumption stays. The caller's character cap used to be accepted and
+ // then silently dropped, which is the one thing this signature
+ // promises; it is honoured on the rendered block instead.
+ const block = get().getMemoriesForPrompt(query, 8192)
+ return block.length > maxChars ? block.slice(0, maxChars) : block
},
}),
{
diff --git a/src/stores/remoteStore.ts b/src/stores/remoteStore.ts
index f498f529..714c461c 100644
--- a/src/stores/remoteStore.ts
+++ b/src/stores/remoteStore.ts
@@ -2,6 +2,7 @@ import { create } from 'zustand'
import { backendCall, isTauri } from '../api/backend'
import { useMemoryStore } from './memoryStore'
import { useProviderStore } from './providerStore'
+import type { ProviderId } from '../api/providers/types'
/**
* #87: derive the backend the mobile proxy should reach for a dispatched
@@ -23,7 +24,10 @@ import { useProviderStore } from './providerStore'
export function remoteBackendArgs(
model: string | undefined,
providers: Record<string, { baseUrl?: string } | undefined>,
- getKey: (id: string) => string,
+ // `ProviderId`, not `string`: the store's own getProviderApiKey is keyed by
+ // the provider union, so a plain `string` here forced every caller to hand
+ // it an id its lookup does not accept.
+ getKey: (id: ProviderId) => string,
): { model?: string; backendKind: string; backendBase?: string; backendKey?: string } {
if (!model) return { model, backendKind: 'ollama' }
const hasPrefix = model.includes('::')
diff --git a/src/types/agent-mode.ts b/src/types/agent-mode.ts
index d197376c..e4483ff2 100644
--- a/src/types/agent-mode.ts
+++ b/src/types/agent-mode.ts
@@ -1,6 +1,8 @@
// Agent Mode — Type Definitions
// Part of the Agent Mode feature (coding-orch branch)
+import type { JSONSchemaProp } from '../api/mcp/types'
+
// Permission tiers (auto-approve reads, confirm writes)
export type ToolPermission = 'auto' | 'confirm'
@@ -8,14 +10,19 @@ export type ToolPermission = 'auto' | 'confirm'
export interface AgentToolDef {
name: string
description: string
+ /**
+ * The same schema the MCP registry hands out (`MCPToolDefinition.inputSchema`),
+ * because that is literally where these come from (tool-registry.ts maps
+ * `inputSchema` onto this field). The local copy of the shape had drifted:
+ * it forced `type: string` and a mandatory `description`, so a tool with a
+ * union type (`['string','array']`, the multi-LoRA param) or a bare property
+ * could not be described here at all.
+ */
parameters: {
type: 'object'
- properties: Record<string, {
- type: string
- description: string
- enum?: string[]
- }>
+ properties: Record<string, JSONSchemaProp>
required: string[]
+ additionalProperties?: boolean
}
permission: ToolPermission
}
diff --git a/src/types/global.d.ts b/src/types/global.d.ts
new file mode 100644
index 00000000..bed71a89
--- /dev/null
+++ b/src/types/global.d.ts
@@ -0,0 +1,19 @@
+/**
+ * Ambient declarations for globals the app reads off `window`.
+ *
+ * The Tauri runtime injects these itself — there is no import that brings
+ * them into the type system — so without this file every read had to go
+ * through an `as any` cast (or, in App.tsx, simply failed to compile).
+ * `unknown` is deliberate: these are only ever used as presence checks
+ * ("are we running inside the Tauri WebView?"), never called through.
+ */
+declare global {
+ interface Window {
+ /** Tauri v2 runtime bridge. Present only inside the Tauri WebView. */
+ __TAURI_INTERNALS__?: unknown
+ /** Tauri v1 runtime bridge / v2 `withGlobalTauri` alias. */
+ __TAURI__?: unknown
+ }
+}
+
+export {}
diff --git a/vite.config.ts b/vite.config.ts
index 0c17c892..9224633a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,8 +2,8 @@ import { defineConfig, parseAst, type Plugin } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { spawn, execSync, type ChildProcess } from 'child_process'
-import { existsSync, readdirSync, createWriteStream, mkdirSync, statSync } from 'fs'
-import { resolve, join, basename } from 'path'
+import { existsSync, readdirSync, createWriteStream, mkdirSync, statSync, type Dirent } from 'fs'
+import { resolve, join, basename, isAbsolute } from 'path'
import https from 'https'
import http from 'http'
import { config } from 'dotenv'
@@ -874,22 +874,35 @@ function comfyLauncher(): Plugin {
req.on('end', () => {
try {
const { provider } = JSON.parse(body)
- // Try common paths for LM Studio / other providers
- const { existsSync } = require('fs')
- const { join } = require('path')
- const home = require('os').homedir()
- const candidates = [
- join(home, '.cache', 'lm-studio', 'models'),
- join(home, 'AppData', 'Local', 'LM Studio', 'models'),
- join(home, '.local', 'share', 'lm-studio', 'models'),
- ]
- const found = candidates.find(p => existsSync(p))
+ const home = os.homedir()
+ // Which backend was asked about used to be read and then thrown
+ // away: every provider got LM Studio's directory back, including
+ // Ollama and the built-in engine. Mirrors the dispatch in the Rust
+ // command (src-tauri/src/commands/download.rs detect_model_path)
+ // for the backends with a conventional managed dir; everything
+ // else falls through to the LU fallback dir below, as there.
+ const asked = String(provider ?? '').toLowerCase()
+ const candidates =
+ asked === 'ollama'
+ ? [join(home, '.ollama', 'models')]
+ : asked === 'lm studio' || asked === 'lmstudio'
+ ? [
+ join(home, '.lmstudio', 'models'),
+ join(home, '.cache', 'lm-studio', 'models'),
+ join(home, 'AppData', 'Local', 'LM Studio', 'models'),
+ join(home, '.local', 'share', 'lm-studio', 'models'),
+ ]
+ : asked === 'jan'
+ ? [join(home, '.jan', 'models'), join(home, 'jan', 'models')]
+ : asked === 'gpt4all'
+ ? [join(home, '.cache', 'gpt4all')]
+ : []
+ const found = candidates.find((p) => existsSync(p))
if (found) {
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify(found))
} else {
// Fallback: create LU models directory (same as Rust backend)
- const { mkdirSync } = require('fs')
const fallback = join(home, 'locally-uncensored', 'models')
try { mkdirSync(fallback, { recursive: true }) } catch {}
res.writeHead(200, { 'Content-Type': 'application/json' })
@@ -1335,7 +1348,8 @@ function comfyLauncher(): Plugin {
const pythonBin = (() => {
if (process.platform !== 'win32') return 'python3'
try {
- const { execSync } = require('child_process')
+ // The typed execSync is already imported at the top of this
+ // file; the inline require shadowed it with an untyped one.
const paths = execSync('where python', { encoding: 'utf8' }).trim().split('\n')
const real = paths.find((p) => !p.includes('WindowsApps'))
return real ? '"' + real.trim() + '"' : 'python'
@@ -1617,18 +1631,32 @@ function comfyLauncher(): Plugin {
req.on('end', () => {
try {
const { path: dirPath, recursive } = JSON.parse(body)
- const os = require('os')
- const fs = require('fs')
- const resolved = require('path').isAbsolute(dirPath) ? dirPath : join(os.homedir(), 'agent-workspace', dirPath)
- const entries: any[] = []
- const items = fs.readdirSync(resolved, { withFileTypes: true })
- for (const item of items.slice(0, 500)) {
- const fullPath = join(resolved, item.name)
+ const resolved = isAbsolute(dirPath) ? dirPath : join(os.homedir(), 'agent-workspace', dirPath)
+ const entries: Array<{ name: string; path: string; size: number; isDir: boolean; modified: number }> = []
+ // `recursive` arrived from the caller (file_list passes the model's
+ // flag straight through) and was then ignored, so in dev mode a
+ // recursive listing silently came back one level deep. Same limits
+ // as the Rust command: depth 5, 500 entries.
+ const MAX_ENTRIES = 500
+ const MAX_DEPTH = 5
+ const walk = (dir: string, depth: number): void => {
+ let items: Dirent[]
try {
- const stat = fs.statSync(fullPath)
- entries.push({ name: item.name, path: fullPath, size: stat.size, isDir: item.isDirectory(), modified: Math.floor(stat.mtimeMs / 1000) })
- } catch { /* skip */ }
+ items = readdirSync(dir, { withFileTypes: true })
+ } catch {
+ return
+ }
+ for (const item of items) {
+ if (entries.length >= MAX_ENTRIES) return
+ const fullPath = join(dir, item.name)
+ try {
+ const stat = statSync(fullPath)
+ entries.push({ name: item.name, path: fullPath, size: stat.size, isDir: item.isDirectory(), modified: Math.floor(stat.mtimeMs / 1000) })
+ } catch { continue }
+ if (recursive && item.isDirectory() && depth < MAX_DEPTH) walk(fullPath, depth + 1)
+ }
}
+ walk(resolved, 1)
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({ entries, count: entries.length }))
} catch (err) {