Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ used with the `--type` flag.
| [beeper-imessage] | imessagego |
| [mautrix-linkedin] | linkedin |
| [heisenbridge] | heisenbridge, irc |
| [ai] | ai, aichats, openai |

[mautrix-telegram]: https://github.com/mautrix/telegram
[mautrix-whatsapp]: https://github.com/mautrix/whatsapp
Expand All @@ -118,6 +119,7 @@ used with the `--type` flag.
[beeper-imessage]: https://github.com/beeper/imessage
[mautrix-linkedin]: https://github.com/mautrix/linkedin
[heisenbridge]: https://github.com/hifi/heisenbridge
[ai]: https://github.com/beeper/ai-bridge

### 3rd party bridgev2-based bridges
If you have a 3rd party bridge that's built on top of mautrix-go's bridgev2
Expand Down
26 changes: 26 additions & 0 deletions bridgeconfig/ai.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Network-specific config options.
#
# ai-bridge owns the defaults for this section. Keep these commented unless
# this generated config intentionally needs to override bridge defaults.
#
# Supported override fields:
#
# network:
# default_system_prompt: |
# Custom system prompt.
# default_reasoning_level: "off"
# fetch:
# timeout_ms: 10000
# max_bytes: 2097152
# max_chars: 20000
# compaction:
# enabled: true
# reserve_tokens: 16384
# keep_recent_tokens: 20000

{{ setfield . "CommandPrefix" "!ai" -}}
{{ setfield . "DatabaseFileName" "ai" -}}
{{ setfield . "BridgeTypeName" "AI Chats" -}}
{{ setfield . "BridgeTypeIcon" "mxc://beeper.com/51a668657dd9e0132cc823ad9402c6c2d0fc3321" -}}
{{ setfield . "DefaultPickleKey" "mautrix.bridge.e2ee" -}}
{{ template "bridgev2.tpl.yaml" . }}
2 changes: 2 additions & 0 deletions cmd/bbctl/bridgeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type bridgeTypeToNames struct {
}

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.

{"discord", []string{"discord"}},
{"meta", []string{"meta", "instagram", "facebook"}},
{"googlechat", []string{"googlechat", "gchat"}},
Expand Down Expand Up @@ -54,6 +55,7 @@ var websocketBridges = map[string]bool{
"bluesky": true,
"linkedin": true,
"telegram": true,
"ai": true,
}

func doOutputFile(ctx *cli.Context, name, data string) error {
Expand Down
6 changes: 6 additions & 0 deletions cmd/bbctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type generatedBridgeConfig struct {

// These should match the last 2 digits of https://mau.fi/ports
var bridgeIPSuffix = map[string]string{
"ai": "44",
"telegram": "17",
"whatsapp": "18",
"meta": "19",
Expand Down Expand Up @@ -352,6 +353,11 @@ func generateBridgeConfig(ctx *cli.Context) error {
startupCommand += " -c " + outputPath
}
installInstructions = fmt.Sprintf("https://docs.mau.fi/bridges/go/setup.html?bridge=%s#installation", cfg.BridgeType)
case "ai":
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.

case "imessagego":
startupCommand = "beeper-imessage"
if outputPath != "config.yaml" && outputPath != "<config file>" {
Expand Down
Loading