Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.

v2: thermo-cleanup rewrite (supersedes main/v1)#37

Merged
techwithanirudh merged 255 commits into
mainfrom
codex/thermo-cleanup
Jun 23, 2026
Merged

v2: thermo-cleanup rewrite (supersedes main/v1)#37
techwithanirudh merged 255 commits into
mainfrom
codex/thermo-cleanup

Conversation

@techwithanirudh

Copy link
Copy Markdown
Collaborator

Merges the thermo-cleanup (v2) branch into main.

Merge strategy

  • main's pre-merge state is preserved on the v1 branch (backup).
  • Merged with -s ours: this branch's tree wins entirely — all conflicts resolved in our favor, and main's 8 diverging commits are intentionally not applied. The merge commit just makes the branch a clean descendant of main so this PR merges without conflicts.
  • Result tree == this branch's validated state (typecheck 6/6, biome clean, knip unchanged).

What's in here (high level)

  • Chat-SDK migration of the Slack bot (allowlist → chat state, profile/channel lookups, mention/channel handling).
  • Per-turn Pi models.json so a unique inference model id resolves to the custom endpoint instead of opencode-go.
  • !compact in-thread command, opt-in onboarding flow, read tools allowed on the current (even private) conversation, custom profile fields.
  • Dead-code / env cleanup.

Rollback

If anything's wrong, main (pre-merge) lives on v1.

🤖 Generated with Claude Code

https://claude.ai/code/session_016EYre4YJdSK9ZH3VRsaEXR

techwithanirudh and others added 30 commits June 1, 2026 03:56
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace mcp-oauth-callback.ts template-in-TypeScript with a proper
  .html template (apps/server/src/templates/) + Nitro renderer handler.
  HTML is now in a separate file; the renderer (catch-all) handles the
  /mcp/oauth/callback route so the HTML rendering is clearly separated
  from API endpoints.

- Delete toolset.ts barrel re-export. Import createMcpToolset directly
  from ./remote in tools/index.ts.

- Remove the useless try-catch wrapper loop that was wrapping all tools
  (native + MCP) in tools/index.ts. MCP tools manage their own task
  lifecycle in remote.ts; native tools handle errors themselves.

- Enable html.parser.interpolation in biome.jsonc so {{ }} template
  placeholders in .html files don't produce parse errors.

- Add docs/mcp-improvements.md: audit of security gaps and reliability
  improvements for the MCP integration (teamId scoping, approval queue
  ordering, proactive token refresh, field-level lockdown).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add optional teamId to listMcpServersByUser and listEnabledMcpServersByUser
  so Slack Enterprise Grid workspaces can't see each other's MCP servers.
  Pass context.teamId from all Slack event handlers through to queries.

- Convert publishHome and applyPrompt to dict params (AGENTS.md rule:
  >1 param → options object). Propagate teamId through all 13 call sites
  including app_home_opened, all MCP actions/views, and prompt actions.

- Convert generateResponse to dict params for the same reason.

- Move MCP empty-state user-facing string to config.ts (appHome.mcpEmptyState).

- Extract extractResultText() in remote.ts: the MCP result text-content
  narrowing was genuinely complex (multi-step type guards) and now lives
  as a named function per AGENTS.md.

- Fix save/index.ts: early-return with publishHome when createMcpServer
  returns null instead of silently skipping all follow-up DB work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The function was byte-for-byte identical in apps/bot and apps/server.
Move it to packages/utils/src/mcp-json.ts with an explicit `secret`
parameter (removing the implicit env read), then update all call sites
to pass env.MCP_TOKEN_ENCRYPTION_KEY directly. Delete both app-level
copies. Add zod to @repo/utils dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All conflicts resolved in favor of this branch; main's diverging commits are
intentionally not applied (ours wins everything).

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

* origin/main:
  fix: remove google native retry
  fix: restore summariser retry order
  fix: narrow chat retry fallbacks
  fix: prefer inference retry fallbacks
  fix: add summariser inference retry
  fix: validate inference env
  fix: use inference base url
  fix: add inference retry provider
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 262 files, which is 112 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

Upgrade to a paid plan to raise the limit.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af140c3c-de29-4b40-b84c-968cd11f0dbe

📥 Commits

Reviewing files that changed from the base of the PR and between e085b37 and 7aee427.

⛔ Files ignored due to path filters (38)
  • .agents/skills/chat-sdk/SKILL.md is excluded by !.agents/**
  • .agents/skills/coding-best-practices/SKILL.md is excluded by !.agents/**
  • .agents/skills/grill-with-docs/ADR-FORMAT.md is excluded by !.agents/**
  • .agents/skills/grill-with-docs/CONTEXT-FORMAT.md is excluded by !.agents/**
  • .agents/skills/grill-with-docs/SKILL.md is excluded by !.agents/**
  • .agents/skills/improve/SKILL.md is excluded by !.agents/**
  • .agents/skills/improve/references/audit-playbook.md is excluded by !.agents/**
  • .agents/skills/improve/references/closing-the-loop.md is excluded by !.agents/**
  • .agents/skills/improve/references/plan-template.md is excluded by !.agents/**
  • .agents/skills/neon-postgres/SKILL.md is excluded by !.agents/**
  • .agents/skills/slack-agent/.gitignore is excluded by !.agents/**
  • .agents/skills/slack-agent/LICENSE is excluded by !.agents/**
  • .agents/skills/slack-agent/README.md is excluded by !.agents/**
  • .agents/skills/slack-agent/SKILL.md is excluded by !.agents/**
  • .agents/skills/slack-agent/patterns/slack-patterns.md is excluded by !.agents/**
  • .agents/skills/slack-agent/patterns/testing-patterns.md is excluded by !.agents/**
  • .agents/skills/slack-agent/reference/agent-archetypes.md is excluded by !.agents/**
  • .agents/skills/slack-agent/reference/ai-sdk.md is excluded by !.agents/**
  • .agents/skills/slack-agent/reference/env-vars.md is excluded by !.agents/**
  • .agents/skills/slack-agent/reference/slack-setup.md is excluded by !.agents/**
  • .agents/skills/slack-agent/reference/vercel-setup.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/1-project-setup.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/1b-approve-plan.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/2-create-slack-app.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/3-configure-environment.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/4-test-locally.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/5-deploy-production.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/6-setup-testing.md is excluded by !.agents/**
  • .agents/skills/slack-agent/wizard/README.md is excluded by !.agents/**
  • .agents/skills/thermo-nuclear-code-quality-review/SKILL.md is excluded by !.agents/**
  • .claude/skills/chat-sdk is excluded by !.claude/**
  • .claude/skills/coding-best-practices is excluded by !.claude/**
  • .claude/skills/grill-with-docs is excluded by !.claude/**
  • .claude/skills/improve is excluded by !.claude/**
  • .claude/skills/neon-postgres is excluded by !.claude/**
  • .claude/skills/slack-agent is excluded by !.claude/**
  • .claude/skills/thermo-nuclear-code-quality-review is excluded by !.claude/**
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (262)
  • .cspell.jsonc
  • .gitignore
  • .vscode/settings.json
  • AGENTS.md
  • CONTEXT.md
  • DEVELOPMENT.md
  • README.md
  • REWRITE_PLAN.md
  • REWRITE_TODO.md
  • TESTING.md
  • TODO.md
  • apps/bot/.env.example
  • apps/bot/extensions/tools.ts
  • apps/bot/package.json
  • apps/bot/src/bot.ts
  • apps/bot/src/config.ts
  • apps/bot/src/env.ts
  • apps/bot/src/features/assistant/index.ts
  • apps/bot/src/features/customizations/index.ts
  • apps/bot/src/features/customizations/schema.ts
  • apps/bot/src/features/customizations/service.ts
  • apps/bot/src/features/customizations/types.ts
  • apps/bot/src/features/customizations/views.ts
  • apps/bot/src/index.ts
  • apps/bot/src/lib/abort.ts
  • apps/bot/src/lib/agent/controls.ts
  • apps/bot/src/lib/agent/index.ts
  • apps/bot/src/lib/agent/line-reply.ts
  • apps/bot/src/lib/agent/prompt.ts
  • apps/bot/src/lib/agent/steering.ts
  • apps/bot/src/lib/ai/agents/orchestrator.ts
  • apps/bot/src/lib/ai/agents/scheduled-task.ts
  • apps/bot/src/lib/ai/attachments.ts
  • apps/bot/src/lib/ai/attempts.ts
  • apps/bot/src/lib/ai/exa.ts
  • apps/bot/src/lib/ai/hints.ts
  • apps/bot/src/lib/ai/stream/index.ts
  • apps/bot/src/lib/ai/stream/tasks/chat.ts
  • apps/bot/src/lib/ai/stream/tasks/default.ts
  • apps/bot/src/lib/ai/stream/tasks/generate-image.ts
  • apps/bot/src/lib/ai/stream/tasks/get-file.ts
  • apps/bot/src/lib/ai/stream/tasks/helpers.ts
  • apps/bot/src/lib/ai/stream/tasks/index.ts
  • apps/bot/src/lib/ai/stream/tasks/leave-thread.ts
  • apps/bot/src/lib/ai/stream/tasks/mermaid.ts
  • apps/bot/src/lib/ai/stream/tasks/pi.ts
  • apps/bot/src/lib/ai/stream/tasks/schedule-reminder.ts
  • apps/bot/src/lib/ai/stream/tasks/search-slack.ts
  • apps/bot/src/lib/ai/stream/tasks/search-web.ts
  • apps/bot/src/lib/ai/stream/tasks/summarize-thread.ts
  • apps/bot/src/lib/ai/stream/tasks/types.ts
  • apps/bot/src/lib/ai/stream/tasks/upload-file.ts
  • apps/bot/src/lib/ai/telemetry.ts
  • apps/bot/src/lib/ai/tools/chat/cancel-scheduled-task.ts
  • apps/bot/src/lib/ai/tools/chat/generate-image.ts
  • apps/bot/src/lib/ai/tools/chat/get-user-info.ts
  • apps/bot/src/lib/ai/tools/chat/get-weather.ts
  • apps/bot/src/lib/ai/tools/chat/leave-channel.ts
  • apps/bot/src/lib/ai/tools/chat/list-scheduled-tasks.ts
  • apps/bot/src/lib/ai/tools/chat/mermaid.ts
  • apps/bot/src/lib/ai/tools/chat/react.ts
  • apps/bot/src/lib/ai/tools/chat/read-conversation-history.ts
  • apps/bot/src/lib/ai/tools/chat/reply.ts
  • apps/bot/src/lib/ai/tools/chat/sandbox.ts
  • apps/bot/src/lib/ai/tools/chat/schedule-reminder.ts
  • apps/bot/src/lib/ai/tools/chat/schedule-task.ts
  • apps/bot/src/lib/ai/tools/chat/search-slack.ts
  • apps/bot/src/lib/ai/tools/chat/search-web.ts
  • apps/bot/src/lib/ai/tools/chat/skip.ts
  • apps/bot/src/lib/ai/tools/chat/summarise-thread.ts
  • apps/bot/src/lib/ai/tools/generate-image.ts
  • apps/bot/src/lib/ai/tools/get-file.ts
  • apps/bot/src/lib/ai/tools/get-user.ts
  • apps/bot/src/lib/ai/tools/index.ts
  • apps/bot/src/lib/ai/tools/leave-thread.ts
  • apps/bot/src/lib/ai/tools/list-threads.ts
  • apps/bot/src/lib/ai/tools/mermaid.ts
  • apps/bot/src/lib/ai/tools/read-conversation-history.ts
  • apps/bot/src/lib/ai/tools/schedule-reminder.ts
  • apps/bot/src/lib/ai/tools/search-slack.ts
  • apps/bot/src/lib/ai/tools/search-web.ts
  • apps/bot/src/lib/ai/tools/skip.ts
  • apps/bot/src/lib/ai/tools/summarize-thread.ts
  • apps/bot/src/lib/ai/tools/tasks/send-scheduled-message.ts
  • apps/bot/src/lib/ai/tools/upload-file.ts
  • apps/bot/src/lib/ai/tools/utils.ts
  • apps/bot/src/lib/ai/toolset.ts
  • apps/bot/src/lib/ai/turn-queue.ts
  • apps/bot/src/lib/ai/utils/status.ts
  • apps/bot/src/lib/ai/utils/stream.ts
  • apps/bot/src/lib/ai/utils/task.ts
  • apps/bot/src/lib/ai/utils/title.ts
  • apps/bot/src/lib/ai/utils/tool-input.ts
  • apps/bot/src/lib/allowed-users.ts
  • apps/bot/src/lib/chat.ts
  • apps/bot/src/lib/errors.ts
  • apps/bot/src/lib/logger/chat.ts
  • apps/bot/src/lib/logger/index.ts
  • apps/bot/src/lib/mcp/guarded-fetch.ts
  • apps/bot/src/lib/mcp/oauth-provider.ts
  • apps/bot/src/lib/mcp/remote.ts
  • apps/bot/src/lib/observability/langfuse.ts
  • apps/bot/src/lib/onboarding.ts
  • apps/bot/src/lib/queue.ts
  • apps/bot/src/lib/sandbox/active.ts
  • apps/bot/src/lib/sandbox/attachments.ts
  • apps/bot/src/lib/sandbox/config/extensions/tools.ts
  • apps/bot/src/lib/sandbox/config/index.ts
  • apps/bot/src/lib/sandbox/events.ts
  • apps/bot/src/lib/sandbox/janitor.ts
  • apps/bot/src/lib/sandbox/parser.ts
  • apps/bot/src/lib/sandbox/rpc/boot.ts
  • apps/bot/src/lib/sandbox/rpc/client.ts
  • apps/bot/src/lib/sandbox/session.ts
  • apps/bot/src/lib/sandbox/show-file.ts
  • apps/bot/src/lib/sandbox/timeout.ts
  • apps/bot/src/lib/sandbox/tools.ts
  • apps/bot/src/lib/slack/ids.ts
  • apps/bot/src/lib/slack/names.ts
  • apps/bot/src/lib/tasks/cron.ts
  • apps/bot/src/lib/tasks/runner.ts
  • apps/bot/src/lib/utils/error.ts
  • apps/bot/src/lib/utils/sanitize.ts
  • apps/bot/src/lib/utils/text.ts
  • apps/bot/src/slack/app.ts
  • apps/bot/src/slack/blocks.ts
  • apps/bot/src/slack/conversations.ts
  • apps/bot/src/slack/events/app-home-opened/index.ts
  • apps/bot/src/slack/events/assistant-thread-context-changed/index.ts
  • apps/bot/src/slack/events/assistant-thread-started/index.ts
  • apps/bot/src/slack/events/message-create/index.ts
  • apps/bot/src/slack/events/message-create/utils/approval-helpers.ts
  • apps/bot/src/slack/events/message-create/utils/message-context.ts
  • apps/bot/src/slack/events/message-create/utils/respond.ts
  • apps/bot/src/slack/features/customizations/index.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/approval.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/auth-changed/index.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/auth-changed/schema.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/configure.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/connect.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/delete.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/disconnect.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/reset-tools.ts
  • apps/bot/src/slack/features/customizations/mcp/actions/toggle.ts
  • apps/bot/src/slack/features/customizations/mcp/ids.ts
  • apps/bot/src/slack/features/customizations/mcp/index.ts
  • apps/bot/src/slack/features/customizations/mcp/schema.ts
  • apps/bot/src/slack/features/customizations/mcp/types.ts
  • apps/bot/src/slack/features/customizations/mcp/view.ts
  • apps/bot/src/slack/features/customizations/mcp/views/connect-closed/index.ts
  • apps/bot/src/slack/features/customizations/mcp/views/save-bearer/index.ts
  • apps/bot/src/slack/features/customizations/mcp/views/save-tools/index.ts
  • apps/bot/src/slack/features/customizations/mcp/views/save/index.ts
  • apps/bot/src/slack/features/customizations/mcp/views/save/schema.ts
  • apps/bot/src/slack/features/customizations/prompts/index.ts
  • apps/bot/src/slack/features/customizations/prompts/schema.ts
  • apps/bot/src/slack/features/customizations/prompts/view.ts
  • apps/bot/src/slack/features/customizations/publish.ts
  • apps/bot/src/slack/features/customizations/scheduled-tasks/index.ts
  • apps/bot/src/slack/features/customizations/view/_components/custom-instructions.ts
  • apps/bot/src/slack/features/customizations/view/_components/mcp.ts
  • apps/bot/src/slack/features/customizations/view/_components/scheduled-tasks.ts
  • apps/bot/src/slack/features/customizations/view/index.ts
  • apps/bot/src/types/activity.ts
  • apps/bot/src/types/ai/orchestrator.ts
  • apps/bot/src/types/ai/status.ts
  • apps/bot/src/types/ai/task.ts
  • apps/bot/src/types/index.ts
  • apps/bot/src/types/request.ts
  • apps/bot/src/types/sandbox/config.ts
  • apps/bot/src/types/sandbox/events.ts
  • apps/bot/src/types/sandbox/rpc.ts
  • apps/bot/src/types/sandbox/runtime.ts
  • apps/bot/src/types/sandbox/tools.ts
  • apps/bot/src/types/slack.ts
  • apps/bot/src/types/slack/app.ts
  • apps/bot/src/types/slack/conversation.ts
  • apps/bot/src/types/slack/events.ts
  • apps/bot/src/types/slack/file.ts
  • apps/bot/src/types/slack/tooling.ts
  • apps/bot/src/types/slack/trigger.ts
  • apps/bot/src/types/stream.ts
  • apps/bot/src/utils/context.ts
  • apps/bot/src/utils/images.ts
  • apps/bot/src/utils/inline-commands.ts
  • apps/bot/src/utils/log.ts
  • apps/bot/src/utils/messages.ts
  • apps/bot/src/utils/parse-json.ts
  • apps/bot/src/utils/slack.ts
  • apps/bot/src/utils/triggers.ts
  • apps/bot/src/utils/users.ts
  • apps/bot/tsconfig.json
  • apps/bot/tsdown.config.ts
  • apps/server/.env.example
  • apps/server/nitro.config.ts
  • apps/server/package.json
  • apps/server/src/config.ts
  • apps/server/src/env.ts
  • apps/server/src/middleware/cors.ts
  • apps/server/src/renderer.ts
  • apps/server/src/routes/health/index.ts
  • apps/server/src/routes/ip.ts
  • apps/server/src/routes/provider/[provider]/[...].ts
  • apps/server/src/tasks/cleanup/sandbox-tokens.ts
  • apps/server/src/templates/oauth-callback.html
  • apps/server/src/utils/logger.ts
  • apps/server/src/utils/mcp-oauth-provider.ts
  • apps/server/tsconfig.json
  • apps/server/turbo.json
  • biome.jsonc
  • comments.md
  • docs/architecture.md
  • docs/index.md
  • docs/mcp-improvements.md
  • docs/reference/data-model.md
  • docs/reference/development.md
  • docs/reference/prompts.md
  • docs/reference/tools.md
  • docs/runtime/agent.md
  • docs/runtime/bot.md
  • docs/runtime/controls.md
  • docs/runtime/sandbox.md
  • docs/runtime/streaming.md
  • docs/todo.md
  • fumadocs.config.ts
  • knip.json
  • package.json
  • packages/ai/package.json
  • packages/ai/src/agent.ts
  • packages/ai/src/files/session.ts
  • packages/ai/src/files/system.ts
  • packages/ai/src/index.ts
  • packages/ai/src/keys.ts
  • packages/ai/src/prompts/chat/attachments.ts
  • packages/ai/src/prompts/chat/core.ts
  • packages/ai/src/prompts/chat/examples.ts
  • packages/ai/src/prompts/chat/index.ts
  • packages/ai/src/prompts/chat/personality.ts
  • packages/ai/src/prompts/chat/presets/index.ts
  • packages/ai/src/prompts/chat/presets/simba.ts
  • packages/ai/src/prompts/chat/tasks.ts
  • packages/ai/src/prompts/chat/tools.ts
  • packages/ai/src/prompts/context.ts
  • packages/ai/src/prompts/core.ts
  • packages/ai/src/prompts/customization.ts
  • packages/ai/src/prompts/hints.ts
  • packages/ai/src/prompts/index.ts
  • packages/ai/src/prompts/personality.ts
  • packages/ai/src/prompts/presets.ts
  • packages/ai/src/prompts/sandbox.ts
  • packages/ai/src/prompts/sandbox/context.ts
  • packages/ai/src/prompts/sandbox/core.ts
  • packages/ai/src/prompts/sandbox/environment.ts
  • packages/ai/src/prompts/sandbox/examples.ts
  • packages/ai/src/prompts/sandbox/index.ts
  • packages/ai/src/prompts/sandbox/skills.ts
  • packages/ai/src/prompts/sandbox/workflow.ts
  • packages/ai/src/prompts/slack.ts
  • packages/ai/src/providers.ts
  • packages/ai/src/providers/models.ts
  • packages/ai/src/providers/pi.ts
  • packages/ai/src/sessions.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/thermo-cleanup

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

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

@techwithanirudh techwithanirudh merged commit 4f1a065 into main Jun 23, 2026
4 of 5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant