MIRAGE shipsDocumentation Index
Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
Use this file to discover all available pages before exploring further.
SlackResource in two runtimes:
@struktoai/mirage-node, talks tohttps://slack.com/api/*directly using a bot token (and optionally a user token forsearch.messages).@struktoai/mirage-browser, stays secret-free: a small proxy server on your backend holds the token and forwards/api/slack/*tohttps://slack.com/api/*. The browser only ever sees the proxy URL.
/slack/channels/, /slack/dms/, /slack/users/) and the same shell commands (slack-post-message, slack-search, etc.).
Get a bot token
- Visit the Slack API basics page and create an app for your workspace.
- Under OAuth & Permissions, add the bot scopes you need. The minimum for read access is:
channels:history,channels:readgroups:history,groups:readim:history,im:readusers:read
- For posting messages, also add
chat:write. - For
search.messages, Slack requires a user token (xoxp-…) withsearch:read. Bot tokens (xoxb-…) getnot_allowed_token_type. Provide it via the optionalsearchTokenfield. - Install the app to your workspace and copy the Bot User OAuth Token (
xoxb-…).
Node (server-side)
Browser
https://slack.com/api/*, attaching the Authorization: Bearer … header server-side.
1. Server: minimal proxy
2. Browser: wire it up
Filesystem layout
users.profile.get. The Slack ID is embedded after __ in directory and file names so you can extract it for the resource-specific commands without an extra lookup.
Shell commands
Every standard MIRAGE shell command works on the mounted Slack tree:| Command | Notes |
|---|---|
ls | List channels, DMs, users, dates |
cat | Read .jsonl history or user .json |
head / tail | First/last N lines |
grep / rg | Pattern search (file or directory level) |
jq | Query JSON; use .[] prefix for JSONL |
wc | Line/word/byte counts |
stat | File metadata (name, size, type) |
find | Recursive search with -name, -maxdepth |
tree | Directory tree view |
pwd / cd | Navigate the virtual tree |
echo (glob) | Glob expansion via resolve_glob |
slack-post-message
| Option | Required | Description |
|---|---|---|
--channel_id | yes | Slack channel ID |
--text | yes | Message text to send |
slack-reply-to-thread
| Option | Required | Description |
|---|---|---|
--channel_id | yes | Slack channel ID |
--ts | yes | Thread parent timestamp |
--text | yes | Reply text |
slack-add-reaction
| Option | Required | Description |
|---|---|---|
--channel_id | yes | Slack channel ID |
--ts | yes | Message timestamp to react to |
--reaction | yes | Emoji name (without colons) |
slack-search
searchToken (a Slack user token, xoxp-…, with search:read). Bot tokens cannot call search.messages.
slack-get-users
slack-get-user-profile
/slack/users/<name>__<id>.json.
Troubleshooting
`not_allowed_token_type` on slack-search / rg /slack/
`not_allowed_token_type` on slack-search / rg /slack/
search.messages requires a user token (xoxp-…) with search:read scope. Set searchToken on the SlackConfig:rg and slack-search fail; channel-scope rg (e.g. rg foo /slack/channels/general__C…/) still works since it streams the JSONL files directly.CORS error in browser
CORS error in browser
The browser cannot call
https://slack.com/api/* directly, Slack does not set permissive CORS headers. You must run the proxy server shown above (or your own equivalent) and point proxyUrl at it.`rate_limited` from Slack
`rate_limited` from Slack
SlackResource uses an IndexCacheStore (default TTL 600s) to deduplicate channel / user / date listings, but high-volume reads of .jsonl files can still hit Slack’s per-method rate limits. Cache hits avoid the API entirely; tune indexTtl if your workspace changes slowly. Per Slack docs, Tier 3 methods like conversations.history allow ~50 requests / minute / workspace.Examples
examples/typescript/slack/slack.ts, shell commands against/slack/(ls,cat,grep,jq,tree,find,cd, glob).examples/typescript/slack/slack_vfs.ts,patchNodeFs(ws)so nativenode:fscalls route through the workspace.examples/typescript/slack/slack_fuse.ts, FUSE-mount the workspace so external processes can browse/slack/as a real filesystem.examples/typescript/slack/slack_browser/, proxy server +@struktoai/mirage-browserSlackResource demo.