feat(agent): browse_local_media + import_assets — discover and batch import local media - #138
Open
nn82pcjt8f-glitch wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
browse_local_media— browse or search local directories without importing: paginated listing (default 100/page), optionalquery(case-insensitive substring on relative path),kindfilter (video/audio/image/gif/svg),recursive(bounded: ≤12 levels, ≤10,000 entries; symlinks not followed). Returns path/name/kind/size/modifiedAt plusnextOffset. Defaults to the home directory.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_ROOTSacts 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-upimport_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 channelopenchatcut:browse-local-media)desktop/agent-path-import.ts— extended for batch import;desktop/main.ts/desktop/preload.tswire the channelsrc/agent/tools/agent-path-import-tools.ts— tool surface;assets/agent/openchatcut-tool-schemas.jsonregeneratedVerify coverage:
desktop/agent-local-media.verify.ts, extendeddesktop/agent-path-import.e2e.verify.tsandsrc/agent/tools/agent-path-import-tools.verify.ts.Testing done
maintip (19cba6e), clean conflict surfacebrowse_local_media按类型/文件名筛选候选,再import_assets批量导入,替代人工罗列文件名Refs: #84, #101