Skip to content

feat(tools): Slack history() and whoAmI() connector methods [SAP-4015] - #1254

Open
gwitwer wants to merge 2 commits into
mainfrom
feat/SAP-4015
Open

gwitwer wants to merge 2 commits into
mainfrom
feat/SAP-4015

Conversation

@gwitwer

@gwitwer gwitwer commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Primary change type

  • Bug fix
  • Documentation
  • Feature
  • Tests
  • Dependency update
  • Maintenance or refactor

Problem and motivation

Agents that read a Slack channel's top-level messages had no connector path, so they kept their own Slack bot token in the vault. The Mushroom Cloud team bot does this today: it reads channel history to find its contest threads and calls auth.test to recognise its own posts.

Summary and scope

connectors.slack gains history() (Slack conversations.history: a channel's top-level messages, paginated, with oldest / latest / inclusive) and whoAmI() (Slack auth.test: the bot's own user_id and bot_id). whoAmI is named for what it returns rather than Slack's wire name. The offline stub answers both; stubSlack now calls a no-arg override with no arguments, the one non-additive line to check in stub/index.ts.

Out of scope: conversations.join. It needs a new install scope that would make every connected workspace reinstall; inviting the app to the channel covers the case, and the README says so.

Related work

Related issue or discussion: SAP-4015. Gateway routes: sapiom/Sapiom#5923, which must be deployed before this release is useful.

Validation

pnpm --filter @sapiom/tools typecheck — clean
pnpm --filter @sapiom/tools build — clean
pnpm --filter @sapiom/tools lint — 0 errors (1 pre-existing warning in another file)
npx jest --maxWorkers=1 src/connectors/slack/index.spec.ts — 12 passed
npx jest --maxWorkers=1 src/stub/slack-mcp.spec.ts — 12 passed
npx jest --maxWorkers=1 src/smoke.spec.ts — 6 passed

Tests and documentation

Wire tests for both methods (URL, method, body), stub defaults and a no-arg override test. The Slack connector README gains both rows plus a note on not_in_channel and using whoAmI with history.

Compatibility and release impact

  • Breaking or externally visible changes: None; two new methods and two new exported result types.
  • Changeset: Added (@sapiom/tools minor).

Security

  • I have not included secrets, credentials, private data, or unsanitized logs.
  • This pull request does not publicly disclose a suspected vulnerability. I
    will follow the
    Security Policy for
    private reporting.

AI assistance

  • I did not use AI assistance for this change.
  • I used AI assistance and have described it below.

Written by Claude Code (Claude Opus 5.5) in an Agent Orchestrator session, following the existing replies / userInfo patterns, and verified with the commands above.

Checklist

  • I read CONTRIBUTING.md, and this contribution follows the direct-PR or issue-first policy.
  • This pull request addresses one focused problem and contains no unrelated cleanup.
  • I added or updated tests, or explained above why tests are not applicable.
  • I ran the relevant build, typecheck, lint, and test commands, or explained
    any N/A checks above.
  • I updated documentation for user-facing changes, or marked it N/A above.
  • I added a Changeset for a published-package change, or explained why it is not applicable.
  • I can explain and maintain every submitted change, including any AI-assisted work.

🤖 Generated with Claude Code

https://claude.ai/code/session_011DacyUn1ab7Tw2AZtWXasj

Summary by CodeRabbit

  • New Features

    • Added Slack channel history retrieval with pagination, result limits, time-range filters, and inclusive boundaries.
    • Added Slack bot identity lookup through whoAmI().
    • Exposed Slack history and identity result types for application use.
    • Channel-reading agents can now operate without providing their own Slack bot token.
  • Documentation

    • Expanded Slack connector documentation to cover channel, thread, and user data access, including the new operations.

…4015]

Agents that read a channel's top-level messages had no connector path, so
they kept their own Slack bot token in the vault. history() calls the
gateway's conversations.history route; whoAmI() calls auth.test and
returns the bot's user_id and bot_id, which an agent needs to pick out its
own posts from history. whoAmI is named for what it returns, following the
naming guide, rather than Slack's wire name.

The offline stub answers both, and a no-arg stub override is called with
no arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DacyUn1ab7Tw2AZtWXasj
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 56d02662-ce10-476a-8c19-05e2daf74aa7
📥 Commits

Reviewing files that changed from the base of the PR and between 43c6a49 and 373d14b.

📒 Files selected for processing: 2
  • examples/support-desk/README.md
  • packages/tools/src/stub/index.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2dcb7aee-d391-4ad2-b799-11d4a19fcb5d
📥 Commits

Reviewing files that changed from the base of the PR and between 02ca49a and 43c6a49.

📒 Files selected for processing: 8
  • .changeset/slack-history-whoami.md
  • packages/tools/src/client.ts
  • packages/tools/src/connectors/slack/README.md
  • packages/tools/src/connectors/slack/index.spec.ts
  • packages/tools/src/connectors/slack/index.ts
  • packages/tools/src/index.ts
  • packages/tools/src/stub/index.ts
  • packages/tools/src/stub/slack-mcp.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The Slack connector adds methods for paginated channel history retrieval and bot identity lookup. The public client interface and package exports expose these methods and their types. Slack stubs, tests, and documentation also cover the new methods.

Changes: Slack connector APIs

Layer / File(s) Summary
Define and expose Slack methods
packages/tools/src/connectors/slack/index.ts, packages/tools/src/client.ts, packages/tools/src/index.ts, packages/tools/src/connectors/slack/index.spec.ts, packages/tools/src/connectors/slack/README.md, .changeset/slack-history-whoami.md
The connector adds history() for conversations.history and whoAmI() for auth.test, with public request and response types. The client and package exports expose the methods and types. Tests and documentation describe their requests and responses.
Add matching Slack stubs
packages/tools/src/stub/index.ts, packages/tools/src/stub/slack-mcp.spec.ts
The Slack stubs return default history and identity responses. Argument-free overrides receive an empty argument list, which the tests verify.

Priority: ⚪ Pending latest changes

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant SlackConnector
  participant Transport
  participant SlackAPI
  Caller->>SlackConnector: Call history(args) or whoAmI()
  SlackConnector->>Transport: Send conversations.history(args) or auth.test({})
  Transport->>SlackAPI: POST method request
  SlackAPI-->>Transport: Return method response
  Transport-->>SlackConnector: Return response
  SlackConnector-->>Caller: Return result
Loading

Suggested reviewers: antoine-berger

Merge Risk: ⚪ Minimal · up to 43c6a

The new Slack methods appear ready to merge after normal checks, provided the required gateway routes are deployed.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the two primary changes: Slack history retrieval and bot identity lookup.
Description check Passed The description follows the template and covers the motivation, scope, related work, validation commands, tests, documentation, compatibility impact, changeset, security, and AI assistance. Two checkl…
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. (2 skipped: 2 u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the template and covers the motivation, scope, related work, validation commands, tests, documentation, compatibility impact, changeset, security, and AI assistance. Two checklist items remain unchecked, but the description is otherwise complete and focused.

Full details: Docstring Coverage

Explanation

Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads the channel’s flow,
Through pages where the messages go.
It asks the bot, “Which name is yours?”
Then hops past Slack’s familiar doors.
The stub replies; the hare says, “More!”

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment on lines +2472 to +2473
user: "U0STUBUSER",
text: "stub channel message",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Offline history misses the bot's posts

When local code matches history messages against whoAmI, the default message has a different user ID and no bot ID. Bot-post detection fails in local runs.

Learn more

The offline Slack client returns fake responses so workflow code can exercise its Slack branches without a network call. Its postMessage returns timestamp 1700000000.000100; the new history message uses that timestamp but credits U0STUBUSER. The whoAmI response instead identifies the bot as U0STUBBOT/B0STUBBOT. Code that uses those identifiers to recognize its own posts therefore takes a different branch locally.

Example: After postMessage({ channel: "C1", text: "hi" }), an agent scans history({ channel: "C1" }) for message.user === (await whoAmI()).user_id. Both default responses reference timestamp 1700000000.000100, but the scan finds no bot post.

Recommended fix: Make the default history message's user and bot_id agree with the default whoAmI identity, and add a stub test that matches them.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 373d14b: the default history message now has its own ts, so it reads as another user's message and no longer collides with the postMessage stub's ts.

Comment thread packages/tools/src/connectors/slack/index.ts
… support-desk note [SAP-4015]

The offline history() message reused postMessage's stub ts but named a
different author, so local code matching history against whoAmI saw the
bot's own post credited to someone else. The support-desk README said the
connector has no conversations.history; it now has one, and the remaining
gap is that the desk does not search it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DacyUn1ab7Tw2AZtWXasj
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.

2 participants