Skip to content

Make files.download discoverable and add --output flag#4

Open
nori-sessions[bot] wants to merge 2 commits into
mainfrom
files-download-output
Open

Make files.download discoverable and add --output flag#4
nori-sessions[bot] wants to merge 2 commits into
mainfrom
files-download-output

Conversation

@nori-sessions

@nori-sessions nori-sessions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

files.download is 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:

  • it tripped the "not in the known methods list" warning (it isn't a real Slack method, so it was never in KNOWN_METHODS),
  • it returned a raw base64 blob with no easy way to get bytes onto disk, and
  • it gave no signal that it only works in proxy mode — in direct (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 from KNOWN_METHODS. list-methods, describe, and the unknown-method warnings (both --dry-run and pre-call) now treat files.download as known.
  • Curated metadata (src/method-metadata.ts): describe files.download now explains it's proxy-only and base64-returning, and links the README instead of a nonexistent api.slack.com page.
  • --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_method error: invoking a proxy-only method in direct mode now fails fast with a clear, actionable error before any network call.
  • Docs: new "Downloading files" section in the README (the anchor the metadata links to) and updated src/docs.md.

Scope note / follow-up

files.download is the only broker pseudo-method (confirmed against the broker's slackProxy.ts — it's the single handler with no real-method mapping), so it's the only addition to PROXY_METHODS.

Separately, files.uploadV2 is a real Bolt method the broker allows but which is missing from KNOWN_METHODS (we only have the deprecated files.upload). That's an upload concern orthogonal to this download-clarity PR; happy to add it as a small follow-up.

Test plan

  • CI green (npm installnpm run buildnpm test)
  • New test/files-download.test.ts covers: --output decodes to disk + summary omits base64; method no longer warned as unknown; direct-mode proxy_only_method rejection (no Slack call); describe reports it known/proxy-only; list-methods --namespace files includes it
  • Full suite passes locally (74/74)

CSRessel and others added 2 commits June 17, 2026 11:13
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>
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