feat(agent): let Ask Cmdr look into a file with inspect_file, so "what's this file?" gets a real answer - #67
Closed
vdavid wants to merge 1 commit into
Closed
Conversation
…hat's this file?" gets a real answer Adds one agent-only read tool, `inspect_file`, that inspects a single file the user points at and returns everything the model needs to describe it: name, size, modified, extension, a MIME guess, the format its leading bytes really are (`detected`, so a lying extension shows beside `mime`), and a typed `content` section per kind. - Text: a character window (`offset` + `maxChars`, default 4,000, cap 16,000) with honest `totalChars` and `truncated`, so a long file is paged, never dumped into the turn. - Image: width and height from the header, plus a pointer to `image_facts` for what is in the picture. Image bytes never cross. - PDF: header version and a `pageCountEstimate` (a lower bound, counted from uncompressed page objects), with an explicit hint that text extraction isn't wired yet. - Archive, binary, and empty files: metadata and the sniffed format only. - `folder`, `missing`, `unreadable`, and `unreachable` are typed statuses; the read runs on a blocking thread under a 5 s timeout so a hung mount can't wedge a turn. Wiring: registry entry (`consumers: [Agent]`, `access: Read`), `ToolId::InspectFile`, the expected-name and 1:1 view tests, the rail label (`askCmdr.tool.inspectFile.*` in `en`, keys regenerated), and the `agent/tools` docs. The fixed prompt overhead and tool-declaration figures move by the new declaration's cost. Not done, flagged for the human side: this is the first tool that egresses arbitrary file contents to the provider, so the Ask Cmdr consent copy has to name it before release, and the non-English catalogs still fall back for the two new labels. The Rust changes are not compiled here (the cloud container lacks the GTK dev libraries Tauri needs), so CI is the first build.
Owner
Author
|
Landed on |
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.
What
One new agent-only read tool,
inspect_file, answering "what is this file?" from the file itself. One path per call, typed result:detected, the format the leading bytes really are (PDF, PNG, JPEG, GIF, WebP, HEIC, TIFF, BMP, zip, gzip, 7z, rar, tar, SQLite, Mach-O, ELF, UTF-8 text).mimeanddetectedsit side by side so a lying extension shows.offset+maxChars, default 4,000, cap 16,000) withtotalCharsandtruncated, so a long file is paged, never dumped into the turn.image_factsfor what is in the picture. Image bytes never cross.pageCountEstimate(a lower bound counted from uncompressed page objects), with an explicit hint that text extraction isn't wired yet.folder,missing,unreadable,unreachableare typed statuses (ErrorKind-based, no string matching). The read runs on a blocking thread under a 5 s timeout so a hung mount can't wedge a turn.Wiring: registry entry (
consumers: [Agent],access: Read),ToolId::InspectFile, the expected-names and 1:1 view tests, rail labels (askCmdr.tool.inspectFile.*inen, keys regenerated), the refusal copy inview.rs, and theagent/+agent/tools/docs.FIXED_PROMPT_OVERHEAD_TOKENSandTOOL_DECLARATION_TOKENSmove by the new declaration's estimated cost.Not done / needs David
askCmdr.consent.*names only the photo pair today; it has to name file contents too (andCONSENT_COPY_VERSIONbumped) before this ships. Human copy, so left for you. BothCLAUDE.mds carry a ❌ for it.pdf-extractorlopdf), which needscargo deny checkand a version check I didn't have time for. The result says so honestly instead of returning empty text.cargo checkcan't build the Tauri crate. CI is the first build; the budget figures may need a nudge fromcost_tests.rs' measured numbers.🤖 Generated with Claude Code
https://claude.ai/code/session_011RzRP12m1FGqFm7RQcvGYr
Generated by Claude Code