Make files.download discoverable and add --output flag#4
Open
nori-sessions[bot] wants to merge 2 commits into
Open
Make files.download discoverable and add --output flag#4nori-sessions[bot] wants to merge 2 commits into
nori-sessions[bot] wants to merge 2 commits into
Conversation
files.download is a Nori Sessions broker pseudo-method (not a real Slack Web API method), so it was undiscoverable and confusing: it triggered a "not in the known methods list" warning, returned a raw base64 blob, and gave no signal that it only works in proxy mode. - Track broker pseudo-methods in PROXY_METHODS + isKnownMethod so files.download is listed, described, and no longer warned as unknown - Add a curated describe/metadata entry pointing at the README - Add --output <path> to decode the returned bytes to disk and print a summary instead of the base64 blob - Reject proxy-only methods invoked in direct mode with a clear proxy_only_method error before any call is made - Document the behavior in README (Downloading files) and src/docs.md 🤖 Generated with [Nori](https://noriagentic.com) Co-Authored-By: Nori <contact@tilework.tech>
files.download was previously broker-only: in direct mode it failed fast with a proxy_only_method error. Rework it into a CLI convenience method that works with a plain SLACK_BOT_TOKEN by reading url_private_download from files.info and fetching the bytes directly; proxy mode delegates to the broker as before. The download logic lives in a pure, injected-IO downloadFileDirect function so it is unit-testable without a token. - Add src/download.ts (downloadFileDirect) + unit tests - Add Transport.download(); proxy delegates, direct fetches locally - Rename PROXY_METHODS -> CLI_METHODS; drop the proxy_only_method error code and the direct-mode rejection guard - Dispatch files.download via transport.download in both modes - Update method metadata, README, and docs.md to describe both modes 🤖 Generated with [Nori](https://noriagentic.com) Co-Authored-By: Nori <contact@tilework.tech>
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
files.downloadis a Nori Sessions broker pseudo-method — it is implemented by the broker's scoped Slack proxy, not the Slack Web API. That made it the one method this CLI couldn't drive cleanly:"not in the known methods list"warning (it isn't a real Slack method, so it was never inKNOWN_METHODS),SLACK_BOT_TOKEN) mode it would just fail opaquely.This PR makes it a first-class, discoverable method.
Changes
PROXY_METHODS+isKnownMethod(src/methods.ts): broker pseudo-methods are tracked separately fromKNOWN_METHODS.list-methods,describe, and the unknown-method warnings (both--dry-runand pre-call) now treatfiles.downloadas known.src/method-metadata.ts):describe files.downloadnow explains it's proxy-only and base64-returning, and links the README instead of a nonexistentapi.slack.compage.--output <path>: decodes the returned bytes and writes them to disk, printing a summary ({ ok, file: { id, name, mimetype, contentType, bytes, path } }) instead of the base64 blob. The raw-args parser strips--output(and its value) so it never leaks into the Slack call.proxy_only_methoderror: invoking a proxy-only method in direct mode now fails fast with a clear, actionable error before any network call.src/docs.md.Scope note / follow-up
files.downloadis the only broker pseudo-method (confirmed against the broker'sslackProxy.ts— it's the single handler with no real-method mapping), so it's the only addition toPROXY_METHODS.Separately,
files.uploadV2is a real Bolt method the broker allows but which is missing fromKNOWN_METHODS(we only have the deprecatedfiles.upload). That's an upload concern orthogonal to this download-clarity PR; happy to add it as a small follow-up.Test plan
npm install→npm run build→npm test)test/files-download.test.tscovers:--outputdecodes to disk + summary omits base64; method no longer warned as unknown; direct-modeproxy_only_methodrejection (no Slack call);describereports it known/proxy-only;list-methods --namespace filesincludes it