Skip to content

add ai bridge#76

Open
batuhan wants to merge 3 commits into
mainfrom
batuhan/aii
Open

add ai bridge#76
batuhan wants to merge 3 commits into
mainfrom
batuhan/aii

Conversation

@batuhan
Copy link
Copy Markdown
Member

@batuhan batuhan commented Jun 1, 2026

No description provided.

@indent
Copy link
Copy Markdown

indent Bot commented Jun 1, 2026

PR Summary

Adds bbctl support for generating configs for the new private beeper/ai-bridge (binary ai, command prefix !ai), so users can run bbctl register sh-ai && bbctl config sh-ai end-to-end without --type and get a working bridgev2-based YAML.

  • New bridgeconfig/ai.tpl.yaml template that delegates to bridgev2.tpl.yaml and sets ai-specific fields (CommandPrefix=!ai, DatabaseFileName=ai, BridgeTypeName="AI Chats", icon, DefaultPickleKey=mautrix.bridge.e2ee), with the network.* block left commented because ai-bridge owns those defaults.
  • Registers ai (aliases ai, aichats, openai) in officialBridges and marks it as a websocket bridge in cmd/bbctl/bridgeutil.go.
  • Reserves IP suffix "ai": "44" in cmd/bbctl/config.go and adds a case "ai": that prints Startup command: ai [-c <path>].
  • Documents the new bridge type and repo link in README.md.

Issues

2 potential issues found:

  • case "ai": in generateBridgeConfig leaves installInstructions empty, so bbctl config ai prints no setup-docs link (other bridgev2 bridges emit https://docs.mau.fi/bridges/go/setup.html?bridge=…). Either point at an ai-bridge docs page or confirm the omission is intentional (matches the imessagego precedent). → Autofix
  • Two-character "ai" alias placed first in officialBridges makes guessOrAskBridgeType auto-classify any bridge name containing the substring ai (e.g. sh-mail, sh-rain, sh-paid) as the new ai bridge with no prompt — workaround is -t <type> but the user gets no signal. Consider dropping the bare "ai" alias and keeping just aichats/openai, or requiring an exact-name match for short aliases. → Autofix

CI Checks

Waiting for CI checks...


⚡ Autofix All Issues

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0c3fa7a-f2dd-4653-b11a-4ff484228348

📥 Commits

Reviewing files that changed from the base of the PR and between 2688316 and 9a124e6.

📒 Files selected for processing (4)
  • README.md
  • bridgeconfig/ai.tpl.yaml
  • cmd/bbctl/bridgeutil.go
  • cmd/bbctl/config.go
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: build-docker (arm64)
  • GitHub Check: build-docker (amd64)
🧰 Additional context used
🪛 YAMLlint (1.38.0)
bridgeconfig/ai.tpl.yaml

[error] 22-22: syntax error: expected '', but found '{'

(syntax)

🔇 Additional comments (7)
cmd/bbctl/bridgeutil.go (2)

24-24: LGTM!


58-58: LGTM!

bridgeconfig/ai.tpl.yaml (2)

1-20: LGTM!


21-26: LGTM!

Note: The YAMLlint syntax error on line 22 is a false positive. This file uses Go template syntax ({{ }}) which is processed before YAML parsing, so the template directives are expected and correct.

README.md (2)

105-105: LGTM!


122-122: LGTM!

cmd/bbctl/config.go (1)

210-210: Verify ai bridge port/suffix against mau.fi/ports
cmd/bbctl/config.go sets bridgeIPSuffix["ai"] = "44" based on the comment that it should match the last 2 digits of https://mau.fi/ports (implying port 29344 / suffix 44). Search results didn’t yield an authoritative mau.fi/ports entry explicitly tying the “ai bridge” to 44, so confirm the ai row on mau.fi/ports matches 44 (otherwise this bridge may be configured to the wrong port and collide).


📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for the AI bridge with multiple identifier options (ai, aichats, openai)
  • Documentation

    • Updated README to include AI bridge details

Walkthrough

This PR adds support for a new "ai" bridge type to the bridge-manager system. The change registers the bridge with aliases, enables websocket support, configures its startup command and network address mapping, provides a configuration template, and documents the bridge in the README.

Changes

AI Bridge Type Integration

Layer / File(s) Summary
Bridge type registration
cmd/bbctl/bridgeutil.go
The ai bridge is added to officialBridges with aliases (ai, aichats, openai) for type guessing, and websocket support is enabled via websocketBridges map.
Configuration generation and template
cmd/bbctl/config.go, bridgeconfig/ai.tpl.yaml
IP suffix mapping for ai is added to derive the websocket proxy address; startup command generation includes a dedicated ai case that conditionally appends the config file path; ai.tpl.yaml defines default bridge parameters (prefix, database, type metadata, pickle key) and includes the shared bridgev2.tpl.yaml template.
Documentation
README.md
Official bridge list table is updated with the ai bridge entry and identifier aliases; link reference for the Beeper AI bridge repository is added.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose and scope of adding the AI bridge support, even a brief summary would improve clarity.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'add ai bridge' directly and clearly describes the main change: adding support for a new AI bridge type across configuration and utility files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch batuhan/aii

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

Comment thread cmd/bbctl/bridgeutil.go
}

var officialBridges = []bridgeTypeToNames{
{"ai", []string{"ai", "aichats", "openai"}},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Latent: substring auto-detection collision. guessOrAskBridgeType (lines 89-100) walks officialBridges top-down and matches via strings.Contains(bridge, name), returning the first hit. With "ai" (2 chars) at the top of the list, any user-chosen bridge name containing the substring aish-mail, sh-rain, sh-paid, sh-bait, etc. — will now silently be classified as the ai bridge type when --type is omitted, rendering ai.tpl.yaml instead of prompting for the real type.

None of the other declared aliases collide today, so this isn't a current bug, but it's a footgun the moment someone names a self-hosted bridge with ai anywhere in it. Suggested fixes: drop the bare "ai" alias and rely on "aichats"/"openai", or special-case short aliases to require exact equality rather than substring.

Comment thread cmd/bbctl/config.go
startupCommand = "ai"
if outputPath != "config.yaml" && outputPath != "<config file>" {
startupCommand += " -c " + outputPath
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: the imessage,whatsapp,discord,… branch above sets installInstructions = https://docs.mau.fi/bridges/go/setup.html?bridge=…, so users get a docs link printed to stderr. The new ai case (like imessagego) leaves it empty, so bbctl config ai only prints the startup command. If there's a public/internal docs page for ai-bridge, wiring it here would match the bridgev2 UX; otherwise this is intentional and fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant