Overview
Server-side implementation of the `browse_local_media` agent tool that lists local directories and media files with query filtering and pagination.
Description
The Agent Local Media module validates requests via `isAgentLocalMediaRequest`, resolves the root path via `resolveAgentMediaPath`, then walks the directory tree with BFS. Supports query filtering, kind filtering, recursive mode, and pagination (max 10,000 entries). Re-checks agent import roots before opening each directory.
Usage
- Agent tools: Enables agents to discover and browse local media before importing.
Code Reference
Source Location
- Repository: OpenChatCut
- File: server/agent-local-media.ts
- Lines: 1-60
Signature
export async function browseLocalMedia(request: AgentLocalMediaRequest): Promise<AgentLocalMediaResult>;
Import
import { browseLocalMedia } from './agent-local-media.ts';
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| request |
AgentLocalMediaRequest |
Yes |
Root path, query, kind filter, pagination
|
Outputs
| Name |
Type |
Description
|
| browseLocalMedia() returns |
Promise<AgentLocalMediaResult> |
Directory listing with media files
|
Usage Examples
Browsing Local Media
import { browseLocalMedia } from './agent-local-media.ts';
const result = await browseLocalMedia({
root: '/home/user/videos',
kind: 'video',
recursive: false,
});
for (const file of result.files) console.log(file.name);
Related Pages
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.