Skip to content

feat(agent): browse_local_media + import_assets — discover and batch import local media - #138

Open
nn82pcjt8f-glitch wants to merge 1 commit into
0xsline:mainfrom
nn82pcjt8f-glitch:feat/agent-local-media-discovery
Open

feat(agent): browse_local_media + import_assets — discover and batch import local media#138
nn82pcjt8f-glitch wants to merge 1 commit into
0xsline:mainfrom
nn82pcjt8f-glitch:feat/agent-local-media-discovery

Conversation

@nn82pcjt8f-glitch

Copy link
Copy Markdown

Summary / 摘要

Follow-up to #84 and #101. Today the agent can only import local media by exact path (import_asset / import_folder), so it must already know filenames, or ask the user to enumerate them (the exact friction reported in #101). This PR adds a discovery step before importing:

New tools (desktop only, same sandbox boundary as existing import tools):

  1. browse_local_media — browse or search local directories without importing: paginated listing (default 100/page), optional query (case-insensitive substring on relative path), kind filter (video/audio/image/gif/svg), recursive (bounded: ≤12 levels, ≤10,000 entries; symlinks not followed). Returns path/name/kind/size/modifiedAt plus nextOffset. Defaults to the home directory.
  2. import_assets — batch-import selected paths into the media pool in one call, reusing the existing fingerprint → copy → probe chain and content-duplicate skipping.

Together: browse_local_media (find candidates) → import_assets (import selection) → existing transcription/caption pipeline. No more guessing filenames or pasting 15-file lists into chat.

Design note re: AGENT_IMPORT_ROOTS

One deliberate change: with the discovery tool, local access defaults to enabled (home directory default), and an explicit AGENT_IMPORT_ROOTS acts as a restriction rather than a requirement — the inverse of the current gate. Rationale: #101 showed the "must configure first" path blocks normal users entirely, and discovery is read-only (listing metadata, no bytes imported without a follow-up import_assets). If you prefer to keep whitelist-required semantics, the same tools work unchanged with the gate re-enabled — happy to flip that flag; the plumbing is identical.

Implementation

  • shared/agent-local-media.ts — request/result contracts + input validation (path length ≤4096, query ≤256, limit ≤200, offset ≤10k)
  • desktop/agent-local-media.ts — main-process browse service (async fs, bounded walk, one IPC channel openchatcut:browse-local-media)
  • desktop/agent-path-import.ts — extended for batch import; desktop/main.ts / desktop/preload.ts wire the channel
  • src/agent/tools/agent-path-import-tools.ts — tool surface; assets/agent/openchatcut-tool-schemas.json regenerated
  • Browser build returns a desktop-only error, consistent with existing import tools

Verify coverage: desktop/agent-local-media.verify.ts, extended desktop/agent-path-import.e2e.verify.ts and src/agent/tools/agent-path-import-tools.verify.ts.

Testing done

  • Branch is based on current main tip (19cba6e), clean conflict surface
  • 具体场景:纪录片工程目录(数十个 mp4 + 文稿混排)中,agent 先 browse_local_media 按类型/文件名筛选候选,再 import_assets 批量导入,替代人工罗列文件名

Refs: #84, #101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant