Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(auth): gate channels to bound users with require_bind

timqi80d9b7824dd6
diff --git a/config/v2_settings.py b/config/v2_settings.py
index 71ceca26e..4ec8c0c59 100644
--- a/config/v2_settings.py
+++ b/config/v2_settings.py
@@ -161,6 +161,9 @@ class ChannelSettings:
routing: RoutingSettings = field(default_factory=RoutingSettings)
# Per-channel require_mention override: None=use global default, True=require, False=don't require
require_mention: Optional[bool] = None
+ # Per-channel require_bind gate: None/False=off (any channel member), True=only
+ # process messages from bound users; unbound senders are silently ignored.
+ require_bind: Optional[bool] = None
@dataclass
@@ -288,6 +291,7 @@ def parse_settings_payload(payload: dict) -> tuple[SettingsState, bool]:
custom_cwd=cp.get("custom_cwd"),
routing=_parse_routing(cp.get("routing") or {}),
require_mention=cp.get("require_mention"),
+ require_bind=cp.get("require_bind"),
)
raw_guild_scopes = scopes.get("guild") or {}
@@ -345,6 +349,7 @@ def parse_settings_payload(payload: dict) -> tuple[SettingsState, bool]:
custom_cwd=cp.get("custom_cwd"),
routing=_parse_routing(cp.get("routing") or {}),
require_mention=cp.get("require_mention"),
+ require_bind=cp.get("require_bind"),
)
migrated_legacy_channels = True
diff --git a/core/auth.py b/core/auth.py
index b8a55de6a..f7c89dd92 100644
--- a/core/auth.py
+++ b/core/auth.py
@@ -124,6 +124,18 @@ def check_auth(
if not ch or not ch.enabled:
return AuthResult(allowed=False, denial="unauthorized_channel", is_dm=False)
+ # 2b. Optional per-channel require_bind gate: when enabled, only bound
+ # users may drive the agent in this channel. Unbound senders are denied
+ # with a denial type that maps to no message (silent ignore), so other
+ # members' chatter does not trigger the bot or spam the channel.
+ if getattr(ch, "require_bind", None):
+ try:
+ is_bound = store.is_bound_user(user_id, platform=platform)
+ except TypeError:
+ is_bound = store.is_bound_user(user_id)
+ if not is_bound:
+ return AuthResult(allowed=False, denial="not_bound_channel", is_dm=False)
+
# 3. Admin check for protected actions
if _is_admin_protected(action):
try:
diff --git a/skills/use-avibe/SKILL.md b/skills/use-avibe/SKILL.md
index eeb5f14ed..1052081e7 100644
--- a/skills/use-avibe/SKILL.md
+++ b/skills/use-avibe/SKILL.md
@@ -386,6 +386,7 @@ Channel entry shape:
"show_message_types": ["assistant"],
"custom_cwd": "/path/to/repo",
"require_mention": null,
+ "require_bind": null,
"routing": {
"agent_backend": "codex",
"model": "gpt-5.4",
@@ -409,6 +410,7 @@ Field meanings:
- `show_message_types`: visible intermediate messages; allowed values are `system`, `assistant`, `toolcall`
- `custom_cwd`: scope-level working directory override; empty string or `null` means use global default
- `require_mention`: `null` inherits the platform default, `true` requires mention, `false` disables mention gating for that channel
+- `require_bind`: `null`/`false` lets any channel member use the bot (current default); `true` gates the channel to bound users only — messages from unbound senders are silently ignored (no denial reply), while the bot's own replies stay visible to everyone. Enforced in the shared auth pipeline, so it applies on every platform. Bind is platform-wide, so `require_bind` means "is this sender a bound user", not a per-channel allowlist.
- `routing.agent_backend`: `opencode`, `claude`, `codex`, or `null` to inherit default
- `routing.model`: canonical scope-level model override for the selected backend
- `routing.reasoning_effort`: canonical scope-level reasoning override for the selected backend
diff --git a/skills/use-vibe-remote/SKILL.md b/skills/use-vibe-remote/SKILL.md
index dce04a7b0..5c9dff62c 100644
--- a/skills/use-vibe-remote/SKILL.md
+++ b/skills/use-vibe-remote/SKILL.md
@@ -386,6 +386,7 @@ Channel entry shape:
"show_message_types": ["assistant"],
"custom_cwd": "/path/to/repo",
"require_mention": null,
+ "require_bind": null,
"routing": {
"agent_backend": "codex",
"model": "gpt-5.4",
@@ -409,6 +410,7 @@ Field meanings:
- `show_message_types`: visible intermediate messages; allowed values are `system`, `assistant`, `toolcall`
- `custom_cwd`: scope-level working directory override; empty string or `null` means use global default
- `require_mention`: `null` inherits the platform default, `true` requires mention, `false` disables mention gating for that channel
+- `require_bind`: `null`/`false` lets any channel member use the bot (current default); `true` gates the channel to bound users only — messages from unbound senders are silently ignored (no denial reply), while the bot's own replies stay visible to everyone. Enforced in the shared auth pipeline, so it applies on every platform. Bind is platform-wide, so `require_bind` means "is this sender a bound user", not a per-channel allowlist.
- `routing.agent_backend`: `opencode`, `claude`, `codex`, or `null` to inherit default
- `routing.model`: canonical scope-level model override for the selected backend
- `routing.reasoning_effort`: canonical scope-level reasoning override for the selected backend
diff --git a/storage/settings_service.py b/storage/settings_service.py
index 9dd21a98d..54ca592cf 100644
--- a/storage/settings_service.py
+++ b/storage/settings_service.py
@@ -79,6 +79,7 @@ class SQLiteSettingsService:
{
"show_message_types": item.show_message_types,
"routing": routing,
+ "require_bind": item.require_bind,
}
),
created_at=now,
@@ -237,6 +238,7 @@ class SQLiteSettingsService:
custom_cwd=row["workdir"],
routing=_routing_from_row(row, payload),
require_mention=_nullable_bool(row["require_mention"]),
+ require_bind=payload.get("require_bind"),
)
return result
diff --git a/tests/test_auth_pipeline.py b/tests/test_auth_pipeline.py
index ff338ff09..ef754189b 100644
--- a/tests/test_auth_pipeline.py
+++ b/tests/test_auth_pipeline.py
@@ -111,6 +111,53 @@ def test_admin_guard_denies_non_admin_for_protected_action():
assert result.denial == "not_admin"
+def test_require_bind_channel_denies_unbound_user():
+ store = _Store()
+ store.settings.channels["C1"] = SimpleNamespace(enabled=True, require_bind=True)
+
+ result = check_auth(
+ user_id="U-stranger",
+ channel_id="C1",
+ is_dm=False,
+ action="",
+ store=store,
+ )
+
+ assert result.allowed is False
+ assert result.denial == "not_bound_channel"
+
+
+def test_require_bind_channel_allows_bound_user():
+ store = _Store()
+ store.settings.channels["C1"] = SimpleNamespace(enabled=True, require_bind=True)
+ store._bound_users.add("U-me")
+
+ result = check_auth(
+ user_id="U-me",
+ channel_id="C1",
+ is_dm=False,
+ action="",
+ store=store,
+ )
+
+ assert result.allowed is True
+
+
+def test_require_bind_off_allows_any_channel_member():
+ store = _Store()
+ store.settings.channels["C1"] = SimpleNamespace(enabled=True, require_bind=None)
+
+ result = check_auth(
+ user_id="U-stranger",
+ channel_id="C1",
+ is_dm=False,
+ action="",
+ store=store,
+ )
+
+ assert result.allowed is True
+
+
def test_admin_guard_denies_non_admin_for_auth_setup_callback():
store = _Store()
store.settings.channels["C1"] = SimpleNamespace(enabled=True)
diff --git a/tests/test_sqlite_settings_store.py b/tests/test_sqlite_settings_store.py
index 9f34f8032..cd6bfd435 100644
--- a/tests/test_sqlite_settings_store.py
+++ b/tests/test_sqlite_settings_store.py
@@ -43,6 +43,21 @@ def test_settings_store_uses_sqlite_without_rewriting_legacy_json(tmp_path: Path
reloaded.close()
+def test_channel_require_bind_persists(tmp_path: Path) -> None:
+ settings_path = tmp_path / "settings.json"
+ store = SettingsStore(settings_path)
+ store.update_channel("C-bind", ChannelSettings(enabled=True, require_bind=True), platform="slack")
+ store.update_channel("C-open", ChannelSettings(enabled=True), platform="slack")
+ store.close()
+
+ reloaded = SettingsStore(settings_path)
+ try:
+ assert reloaded.find_channel("C-bind", platform="slack").require_bind is True
+ assert reloaded.find_channel("C-open", platform="slack").require_bind in (None, False)
+ finally:
+ reloaded.close()
+
+
def test_settings_store_reloads_external_sqlite_writes(tmp_path: Path) -> None:
settings_path = tmp_path / "settings.json"
store = SettingsStore(settings_path)
diff --git a/ui/src/components/shared/RoutingConfigPanel.tsx b/ui/src/components/shared/RoutingConfigPanel.tsx
index 818930e81..0ab5f68aa 100644
--- a/ui/src/components/shared/RoutingConfigPanel.tsx
+++ b/ui/src/components/shared/RoutingConfigPanel.tsx
@@ -31,6 +31,7 @@ export interface RoutingConfigValue {
};
show_message_types: string[];
require_mention?: boolean | null;
+ require_bind?: boolean | null;
}
export interface RoutingConfigPanelProps {
@@ -235,8 +236,8 @@ export const RoutingConfigPanel: React.FC<RoutingConfigPanelProps> = ({
return ['low', 'medium', 'high', 'xhigh'].map((value) => ({ value, label: getReasoningLabel(value, value) }));
})();
- // Top row: working dir + Vibe Agent (+ optional require_mention) — dynamic grid columns
- const topGridCols = showRequireMention ? 'md:grid-cols-3' : 'md:grid-cols-2';
+ // Top row: working dir + Vibe Agent (+ optional require_mention / require_bind) — dynamic grid columns
+ const topGridCols = showRequireMention ? 'md:grid-cols-4' : 'md:grid-cols-2';
return (
<div className={clsx('space-y-4', containerClass)}>
@@ -371,6 +372,50 @@ export const RoutingConfigPanel: React.FC<RoutingConfigPanelProps> = ({
</div>
);
})()}
+
+ {/* Require bind (channels only): when On, only bound users can drive the
+ agent here; unbound members are silently ignored. */}
+ {showRequireMention && (() => {
+ const on = value.require_bind === true;
+ const setBind = (next: boolean) => {
+ onChange({ require_bind: next ? true : null });
+ };
+ const segs: { id: 'off' | 'on'; label: string }[] = [
+ { id: 'off', label: t('channelList.requireBindOff') },
+ { id: 'on', label: t('channelList.requireBindOn') },
+ ];
+ return (
+ <div className="space-y-1">
+ <label className="text-xs font-medium uppercase text-muted">{t('channelList.requireBind')}</label>
+ <div
+ role="radiogroup"
+ aria-label={t('channelList.requireBind') as string}
+ className="flex h-9 items-stretch gap-0.5 rounded-md border border-border bg-foreground/[0.03] p-0.5"
+ >
+ {segs.map((seg) => {
+ const active = (seg.id === 'on') === on;
+ return (
+ <button
+ key={seg.id}
+ type="button"
+ role="radio"
+ aria-checked={active}
+ onClick={() => setBind(seg.id === 'on')}
+ className={clsx(
+ 'flex-1 rounded-[4px] px-2.5 text-[12px] transition-colors',
+ active
+ ? 'border border-mint/30 bg-mint-soft font-bold text-mint'
+ : 'font-medium text-muted hover:text-foreground'
+ )}
+ >
+ {seg.label}
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ );
+ })()}
</div>
{/* Scope-level overrides */}
diff --git a/ui/src/components/steps/ChannelList.tsx b/ui/src/components/steps/ChannelList.tsx
index 54b3b2eb2..b5ab1a8c4 100644
--- a/ui/src/components/steps/ChannelList.tsx
+++ b/ui/src/components/steps/ChannelList.tsx
@@ -70,6 +70,7 @@ interface ChannelConfig {
codex_reasoning_effort?: string | null;
};
require_mention?: boolean | null; // null=use global default, true=require, false=don't require
+ require_bind?: boolean | null; // null/false=off, true=only bound users may use this channel
}
interface TelegramDiscoverySummary {
@@ -731,6 +732,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
codex_reasoning_effort: null,
},
require_mention: null,
+ require_bind: null,
});
const selectedCount = channels.filter((channel) => isChannelEnabled(channel.id)).length;
@@ -1314,6 +1316,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
custom_cwd: rawConfig.custom_cwd ?? def.custom_cwd,
routing: { ...def.routing, ...(rawConfig.routing || {}) },
require_mention: rawConfig.require_mention !== undefined ? rawConfig.require_mention : def.require_mention,
+ require_bind: rawConfig.require_bind !== undefined ? rawConfig.require_bind : def.require_bind,
};
const rowKey = `${channelPlatform}::${channel.id}`;
const expanded = expandedChannelId === rowKey;
@@ -1723,6 +1726,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
},
// Preserve require_mention from rawConfig (can be null, true, or false)
require_mention: rawConfig.require_mention !== undefined ? rawConfig.require_mention : def.require_mention,
+ require_bind: rawConfig.require_bind !== undefined ? rawConfig.require_bind : def.require_bind,
};
const effectiveCwd = channelConfig.custom_cwd || config.runtime?.default_cwd || '~/work';
const opencodeOptions = opencodeOptionsByCwd[effectiveCwd];
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index d33462f36..c80c30f49 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1152,6 +1152,9 @@
"requireMention": "Require @Mention",
"requireMentionOn": "Require @mention",
"requireMentionOff": "Don't require @mention",
+ "requireBind": "Bound users only",
+ "requireBindOn": "Bound only",
+ "requireBindOff": "Anyone",
"mentionStatusOn": "Require @",
"mentionStatusOff": "Don't require @",
"allChannelsTab": "All channels",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index ad2d551c9..e47892500 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1152,6 +1152,9 @@
"requireMention": "需要 @提及",
"requireMentionOn": "需要@",
"requireMentionOff": "不用@",
+ "requireBind": "仅限已绑定用户",
+ "requireBindOn": "仅绑定用户",
+ "requireBindOff": "所有人",
"mentionStatusOn": "需要 @",
"mentionStatusOff": "不需要 @",
"allChannelsTab": "全部群组",
diff --git a/vibe/api.py b/vibe/api.py
index 33e65bf8e..817c41015 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -1268,6 +1268,7 @@ def save_settings(payload: dict) -> dict:
custom_cwd=channel_payload.get("custom_cwd"),
routing=_parse_routing(_normalize_backend_routing_payload(channel_payload.get("routing") or {})),
require_mention=channel_payload.get("require_mention"),
+ require_bind=channel_payload.get("require_bind"),
)
store.set_channels_for_platform(platform, channels)
if "guilds" in payload or "guild_allowlist" in payload:
@@ -1901,6 +1902,7 @@ def _settings_to_payload(store: SettingsStore, platform: str) -> dict:
"show_message_types": normalize_show_message_types(settings.show_message_types),
"custom_cwd": settings.custom_cwd,
"require_mention": settings.require_mention,
+ "require_bind": settings.require_bind,
"routing": routing_to_compat_dict(settings.routing),
}
payload["guild_scope_configured"] = store.has_guild_scope_for_platform(platform)