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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
docs(skill): prefer vibe remote web api
cyhe6114b9d0020
diff --git a/skills/use-vibe-remote/SKILL.md b/skills/use-vibe-remote/SKILL.mdindex 2c5ffb4d9..675a127b7 100644--- a/skills/use-vibe-remote/SKILL.md+++ b/skills/use-vibe-remote/SKILL.md@@ -2,7 +2,7 @@name: use-vibe-remoteslug: use-vibe-remotedescription: Safely inspect and modify local Vibe Remote configuration, routing, runtime settings, watches, scheduled tasks, and operational state.-version: 0.1.8+version: 0.2.2---# Use Vibe Remote@@ -11,180 +11,306 @@ Use this skill when the user asks you to configure, repair, explain, or operateTypical requests include:-- enable a Slack/Discord/Lark channel+- enable a Slack, Discord, Telegram, Lark/Feishu, or WeChat scope- route one channel or DM user to OpenCode, Claude, or Codex-- set a working directory for a channel or DM+- set a working directory for a channel or DM user- choose a backend model, subagent, or reasoning level+- show or hide intermediate message types- create, inspect, pause, resume, or remove a managed background watch with `vibe watch`- create, inspect, run, pause, resume, or remove a scheduled task with `vibe task`- queue a one-shot asynchronous hook with `vibe hook send`-- show or hide intermediate message types-- inspect logs, run doctor, restart services, or explain where Vibe Remote stores its state+- inspect logs, run doctor, check service status, or explain where Vibe Remote stores state- decide whether a requested change belongs in Vibe Remote config or in the host backend's own configFollow this skill as an operations playbook for agents, not as end-user marketing copy.## Core Rules-1. Read before editing. Inspect the current file first and preserve unrelated keys.-2. Make the smallest viable change. Do not rewrite the whole file unless necessary.-3. Treat secrets as opaque. Do not print, invent, rotate, or overwrite tokens unless the user explicitly provides replacements.-4. Back up `config.json` or `settings.json` before writing.-5. Validate JSON after editing.-6. Only touch the target platform scope in `settings.json`.-7. Do not hand-edit `sessions.json` unless the user explicitly asks for low-level recovery work.-8. Tell the user whether the change is global or scope-specific.-9. After config changes, recommend `vibe doctor` and usually `vibe restart --delay-seconds 60`.+1. Prefer the Web UI API for Vibe Remote configuration changes. Do not hand-edit config files for routine work.+2. Read current API state before mutating. Merge the user's requested change into the current payload.+3. Preserve unrelated scopes, platforms, users, and secrets.+4. Treat secrets as opaque. Do not print, invent, rotate, or overwrite tokens unless the user explicitly provides replacements.+5. Use the smallest viable API call and verify by reading back the API response.+6. For `POST /settings`, preserve every existing channel for that platform; the endpoint replaces the platform's channel map.+7. For `POST /api/users`, merge each edited user with its current user payload first; missing user fields are not a patch.+8. Do not hand-edit `sessions.json` unless the user explicitly asks for low-level recovery work.+9. Do not restart the service by default. Use `POST /doctor`, `GET /status`, and read-back checks first.+10. Only start, stop, restart, or reload Vibe Remote when the user explicitly asks or when a change cannot take effect otherwise; explain why before doing it.+11. Tell the user whether the change is global or scope-specific.++## API First Workflow++Use this order when changing Vibe Remote configuration:++1. Determine the Web UI base URL.+ - Default is `http://127.0.0.1:5123`.+ - If the user has a custom UI host or port, use that exact origin.+ - Check liveness with `GET /health` or `GET /status`.+2. Decide whether the request belongs in:+ - `POST /config` for global defaults, platform credentials, runtime config, agent defaults, UI config, or global display toggles+ - `POST /settings` for channel-level routing, working directory, visibility, enablement, and mention policy+ - `/api/users` and `/api/bind-codes` for DM user binding and user-scope settings+ - host backend config instead of Vibe Remote when the request is OpenCode, Claude Code, or Codex native behavior+3. Fetch the current state from the matching GET endpoint.+4. Merge the requested change in memory.+5. Send the mutating request through the Web UI API with CSRF protection.+6. Read back the changed resource and verify the effective payload.+7. Run `POST /doctor` only when the change affects runtime health, platform credentials, or backend availability.+8. Report the changed scope or global keys and whether a restart was avoided or still required.-## Runtime Layout+## Calling the Web UI API-Vibe Remote stores runtime data under `~/.vibe_remote/` by default. If `VIBE_REMOTE_HOME` is set, use that directory instead.+Mutating API calls require:-Important paths:+- same-origin `Origin` or `Referer` header+- CSRF cookie named `vibe_csrf_token`+- matching `X-Vibe-CSRF-Token` header-- `~/.vibe_remote/config/config.json`: global config-- `~/.vibe_remote/state/settings.json`: per-channel and per-user overrides-- `~/.vibe_remote/state/scheduled_tasks.json`: persisted scheduled tasks-- `~/.vibe_remote/state/watches.json`: persisted managed watches-- `~/.vibe_remote/state/user_preferences.md`: shared long-term preference file; prefer user-specific notes under `platform/user_id` sections and keep shared rules truly cross-user-- `~/.vibe_remote/state/task_requests/`: queued task-run and hook-send requests plus completion receipts-- `~/.vibe_remote/state/user_preferences.md`: shared long-term preference file; prefer user-specific notes under `platform/user_id` sections and keep shared rules truly cross-user-- `~/.vibe_remote/state/sessions.json`: runtime session state-- `~/.vibe_remote/logs/vibe_remote.log`: main application log-- `~/.vibe_remote/runtime/status.json`: runtime status file-- `~/.vibe_remote/runtime/doctor.json`: latest doctor result-- `~/.vibe_remote/runtime/watch_runtime.json`: live watch runtime state, including active PIDs-- `~/.vibe_remote/attachments/`: attachment staging area+Use this local curl pattern:-## Edit Workflow+```bash+BASE="http://127.0.0.1:5123"+COOKIE_JAR="$(mktemp)"+CSRF="$(+ curl -fsS -c "$COOKIE_JAR" "$BASE/api/csrf-token" \+ | python3 -c 'import json,sys; print(json.load(sys.stdin)["csrf_token"])'+)"++curl -fsS -b "$COOKIE_JAR" -c "$COOKIE_JAR" \+ -H "Origin: $BASE" \+ -H "X-Vibe-CSRF-Token: $CSRF" \+ -H "Content-Type: application/json" \+ -X POST "$BASE/doctor" \+ --data '{}'+```-When changing Vibe Remote config, use this order:+For `DELETE`, use the same cookie jar, `Origin`, and CSRF header.-1. Determine the runtime home (`VIBE_REMOTE_HOME` or `~/.vibe_remote`).-2. Decide whether the request belongs in:- - `config.json` for global defaults or platform/runtime config- - `settings.json` for channel/user overrides- - host backend config (`~/.config/opencode/opencode.json`, project `opencode.json` or `.opencode/`, `~/.claude/...`, `~/.codex/config.toml`) instead of Vibe Remote-3. Read the current target file.-4. Back it up, for example:+Do not log full request bodies when they contain tokens or secrets.-```bash-cp ~/.vibe_remote/config/config.json ~/.vibe_remote/config/config.json.bak.$(date +%s)-```+### Reusable local API helper++For multi-step maintenance, use the bundled helper at `scripts/vibe_api.py` instead of hand-writing curl commands. The helper handles CSRF, same-origin headers, cookies, JSON encoding, and readable error output.-5. Apply a minimal edit.-6. Validate the file, for example:+Resolve paths relative to this skill directory. If the skill is installed at `skills/use-vibe-remote`, run:++Usage examples:```bash-VIBE_HOME="${VIBE_REMOTE_HOME:-$HOME/.vibe_remote}"-TARGET_FILE="$VIBE_HOME/state/settings.json" # or the exact file you just edited-python3 -c "import json,sys; json.load(open(sys.argv[1]))" "$TARGET_FILE"+export VIBE_UI_BASE="http://127.0.0.1:5123"++python3 skills/use-vibe-remote/scripts/vibe_api.py GET /health+python3 skills/use-vibe-remote/scripts/vibe_api.py GET '/settings?platform=slack'+python3 skills/use-vibe-remote/scripts/vibe_api.py POST /doctor '{}'+python3 skills/use-vibe-remote/scripts/vibe_api.py POST /config '{"show_duration":true}'+python3 skills/use-vibe-remote/scripts/vibe_api.py DELETE '/api/users/U123?platform=slack'```-7. If the config change affects behavior, recommend:+Payload can be passed as inline JSON, as `@payload.json`, or as `-` to read JSON from stdin.++For scope updates, still fetch and merge first:```bash-vibe doctor-vibe restart --delay-seconds 60+API_HELPER="skills/use-vibe-remote/scripts/vibe_api.py"++python3 "$API_HELPER" GET '/settings?platform=slack' > /tmp/slack_settings.json+python3 - <<'PY'+import json+from pathlib import Path++settings = json.loads(Path("/tmp/slack_settings.json").read_text())+channels = settings.get("channels") or {}+channels["C123"] = {+ **channels.get("C123", {}),+ "enabled": True,+ "show_message_types": channels.get("C123", {}).get("show_message_types") or ["assistant"],+ "custom_cwd": channels.get("C123", {}).get("custom_cwd"),+ "require_mention": channels.get("C123", {}).get("require_mention"),+ "routing": {+ **(channels.get("C123", {}).get("routing") or {}),+ "agent_backend": "codex",+ "codex_model": "gpt-5.4",+ "codex_reasoning_effort": "high",+ },+}+Path("/tmp/slack_payload.json").write_text(json.dumps({"platform": "slack", "channels": channels}))+PY+python3 "$API_HELPER" POST /settings @/tmp/slack_payload.json+python3 "$API_HELPER" GET '/settings?platform=slack'```-Use plain `vibe restart` only when the user explicitly wants an immediate restart. For agent-triggered restarts during an active conversation, prefer the delayed form so the agent can send its final reply before the service goes down.+## Runtime Layout++Vibe Remote stores runtime data under `~/.vibe_remote/` by default. If `VIBE_REMOTE_HOME` is set, use that directory instead.++Important paths:++- `~/.vibe_remote/config/config.json`: global config persisted by `POST /config`+- `~/.vibe_remote/state/settings.json`: scope settings persisted by `/settings`, `/api/users`, and `/api/bind-codes`+- `~/.vibe_remote/state/scheduled_tasks.json`: persisted scheduled tasks created by `vibe task`+- `~/.vibe_remote/state/watches.json`: persisted managed watches+- `~/.vibe_remote/state/task_requests/`: queued task-run and hook-send requests plus completion receipts+- `~/.vibe_remote/state/user_preferences.md`: shared long-term preference file+- `~/.vibe_remote/state/sessions.json`: runtime session state; do not edit during normal config work+- `~/.vibe_remote/logs/vibe_remote.log`: main application log+- `~/.vibe_remote/runtime/status.json`: runtime status file+- `~/.vibe_remote/runtime/doctor.json`: latest doctor result+- `~/.vibe_remote/runtime/watch_runtime.json`: live watch runtime state, including active PIDs+- `~/.vibe_remote/attachments/`: attachment staging area-8. Summarize the exact keys changed.+Only use direct file editing as a recovery fallback when the Web UI API is unavailable or the user explicitly asks for low-level repair. If you must edit files directly, back up the file first, validate JSON, and explain why the API path was not usable.-## File Responsibilities+## API Endpoint Reference-### `config.json`+### Health and inspection-This is the global config. It defines the active IM platform, runtime defaults, global backend defaults, UI settings, update policy, and global display toggles.+- `GET /health`+ - returns `{"status":"ok"}` when the Web UI server is reachable+- `GET /status`+ - returns runtime status, running state, PID metadata, and last action+- `GET /doctor`+ - reads the latest persisted doctor result+- `POST /doctor`+ - runs doctor immediately and returns the result+- `POST /logs`+ - payload: `{"lines": 500, "source": "service"}`+ - `source` can be `service` or another source listed in the response; use `all` for aggregated logs+- `GET /version`+ - returns current version and update metadata-Current top-level structure:+### Global config++- `GET /config`+ - returns the current V2 config payload+- `POST /config`+ - accepts a partial object, deep-merges it with current config, validates it through `V2Config.from_payload`, then persists it+ - use for platform credentials, enabled platforms, primary platform, runtime defaults, agent defaults, UI config, update policy, and global toggles++Important config payload shape:```json{"platform": "slack",+ "platforms": {+ "enabled": ["slack", "discord", "telegram", "lark", "wechat"],+ "primary": "slack"+ },"mode": "self_host","version": "v2",- "slack": {},- "discord": null,- "lark": null,- "runtime": {},- "agents": {},- "gateway": null,- "ui": {},- "update": {},- "ack_mode": "reaction",+ "slack": {+ "bot_token": "xoxb-...",+ "app_token": "xapp-...",+ "signing_secret": "...",+ "team_id": "T...",+ "team_name": "...",+ "app_id": "A...",+ "require_mention": false+ },+ "discord": {+ "bot_token": "...",+ "application_id": "...",+ "guild_allowlist": [],+ "guild_denylist": [],+ "require_mention": false+ },+ "telegram": {+ "bot_token": "123:abc",+ "require_mention": true,+ "forum_auto_topic": true,+ "use_webhook": false,+ "webhook_url": null,+ "webhook_secret_token": null,+ "allowed_chat_ids": null,+ "allowed_user_ids": null+ },+ "lark": {+ "app_id": "...",+ "app_secret": "...",+ "require_mention": false,+ "domain": "feishu"+ },+ "wechat": {+ "bot_token": "...",+ "base_url": "https://ilinkai.weixin.qq.com",+ "cdn_base_url": "https://novac2c.cdn.weixin.qq.com/c2c",+ "proxy_url": null,+ "require_mention": false+ },+ "runtime": {+ "default_cwd": "/path/to/workdir",+ "log_level": "INFO"+ },+ "agents": {+ "default_backend": "opencode",+ "opencode": {+ "enabled": true,+ "cli_path": "opencode",+ "default_agent": null,+ "default_model": null,+ "default_reasoning_effort": null,+ "error_retry_limit": 1+ },+ "claude": {+ "enabled": true,+ "cli_path": "claude",+ "default_model": null,+ "idle_timeout_seconds": 600+ },+ "codex": {+ "enabled": true,+ "cli_path": "codex",+ "default_model": null,+ "idle_timeout_seconds": 600+ }+ },+ "ack_mode": "typing",+ "language": "en","show_duration": false,"include_user_info": true,- "reply_enhancements": true,- "language": "en"+ "reply_enhancements": true}```-Key responsibilities:--- `platform`: active IM transport; valid values are `slack`, `discord`, `lark`-- `mode`: `self_host` or `saas`-- `slack`, `discord`, `lark`: platform credentials and defaults-- `runtime.default_cwd`: global working directory fallback-- `runtime.log_level`: log verbosity-- `agents.default_backend`: default backend if no scope override applies-- `agents.opencode`, `agents.claude`, `agents.codex`: backend enablement and default model settings-- `ui`: local setup UI bind host/port-- `update`: auto-update behavior-- `ack_mode`: `reaction` or `message`-- `show_duration`, `include_user_info`, `reply_enhancements`, `language`: global UX toggles-- `gateway`: SaaS relay settings+When switching the active platform, update `platforms.primary` and make sure `platforms.enabled` contains the new primary. Keep the legacy `platform` field aligned for readability, but `platforms.primary` is the real multi-platform source of truth.-Platform sections:--- `slack`: `bot_token`, `app_token`, `signing_secret`, `team_id`, `team_name`, `app_id`, `require_mention`-- `discord`: `bot_token`, `application_id`, `guild_allowlist`, `guild_denylist`, `require_mention`-- `lark`: `app_id`, `app_secret`, `require_mention`, `domain`--Secret-bearing fields that you should not print back unless the user explicitly asks:+Secret-bearing config fields that you should not print:- `slack.bot_token`- `slack.app_token`- `slack.signing_secret`- `discord.bot_token`+- `telegram.bot_token`+- `telegram.webhook_secret_token`- `lark.app_id` (treat as a sensitive identifier)- `lark.app_secret`+- `wechat.bot_token`- `gateway.workspace_token`- `gateway.client_secret`-### `settings.json`+### Channel settings-This is the main scope-level routing file. It stores channel overrides, DM-user overrides, and bind codes.+- `GET /settings?platform=<platform>`+ - returns channel settings, user settings, and bind codes for one platform+- `POST /settings`+ - payload: `{"platform": "<platform>", "channels": {...}}`+ - validates message visibility and routing, normalizes Claude reasoning, persists the full channel map for that platform-Current schema shape:+Important: `POST /settings` replaces the entire `channels` map for the selected platform. To change one channel:-```json-{- "schema_version": 3,- "scopes": {- "channel": {- "slack": {},- "discord": {},- "lark": {}- },- "user": {- "slack": {},- "discord": {},- "lark": {}- }- },- "bind_codes": []-}-```+1. `GET /settings?platform=<platform>`+2. copy `response.channels`+3. merge or add one channel entry+4. `POST /settings` with the full merged `channels` object+5. `GET /settings?platform=<platform>` again and verify-Channel scope entry:+Channel entry shape:```json{"enabled": true,- "show_message_types": ["assistant", "toolcall"],+ "show_message_types": ["assistant"],"custom_cwd": "/path/to/repo",+ "require_mention": null,"routing": {"agent_backend": "codex","opencode_agent": null,@@ -193,14 +319,47 @@ Channel scope entry:"claude_agent": null,"claude_model": null,"claude_reasoning_effort": null,+ "codex_agent": "reviewer","codex_model": "gpt-5.4","codex_reasoning_effort": "high"- },- "require_mention": null+ }}```-User scope entry:+Field meanings:++- `enabled`: whether this channel is allowed to use Vibe Remote+- `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+- `routing.agent_backend`: `opencode`, `claude`, `codex`, or `null` to inherit default+- `routing.<backend>_agent`: backend-specific subagent+- `routing.<backend>_model`: backend-specific model+- `routing.<backend>_reasoning_effort`: backend-specific reasoning effort++### DM users and bind codes++- `GET /api/users?platform=<platform>`+ - returns bound DM users for one platform+- `POST /api/users`+ - payload: `{"platform": "<platform>", "users": {...}}`+ - merges included users into existing users and preserves each existing user's `dm_chat_id`+- `POST /api/users/<user_id>/admin`+ - payload: `{"platform": "<platform>", "is_admin": true}`+- `DELETE /api/users/<user_id>?platform=<platform>`+ - removes a bound user; this is the reliable way to revoke DM access+- `GET /api/bind-codes`+ - returns all bind codes+- `POST /api/bind-codes`+ - payload: `{"type": "one_time"}` or `{"type": "expiring", "expires_at": "2026-04-18"}`+- `DELETE /api/bind-codes/<code>`+ - deactivates a bind code+- `GET /api/setup/first-bind-code`+ - returns an existing valid setup bind code or creates a new one-time code++Important: user updates are not field patches. Before changing a user's routing, cwd, visibility, or enabled flag, read the current user object and send the merged full user entry.++User entry shape:```json{@@ -212,103 +371,234 @@ User scope entry:"custom_cwd": "/path/to/repo","routing": {"agent_backend": "claude",+ "opencode_agent": null,+ "opencode_model": null,+ "opencode_reasoning_effort": null,"claude_agent": "reviewer","claude_model": "claude-sonnet-4-6",- "claude_reasoning_effort": "high"- },- "dm_chat_id": "D123456"+ "claude_reasoning_effort": "high",+ "codex_agent": null,+ "codex_model": null,+ "codex_reasoning_effort": null+ }}```-Meaning of important fields:+DM caveat: current DM authorization checks whether the user is bound, not whether `enabled` is true. If the user wants to revoke DM access, use `DELETE /api/users/<user_id>?platform=<platform>` instead of only setting `enabled` to false.++### Platform discovery and validation++- `GET /slack/manifest`+ - returns Slack app manifest JSON for setup+- `POST /slack/auth_test`+ - payload: `{"bot_token": "xoxb-..."}`+- `POST /slack/channels`+ - payload: `{"bot_token": "xoxb-...", "browse_all": false}`+- `POST /discord/auth_test`+ - payload: `{"bot_token": "..."}`+- `POST /discord/guilds`+ - payload: `{"bot_token": "..."}`+- `POST /discord/channels`+ - payload: `{"bot_token": "...", "guild_id": "..."}`+- `POST /telegram/auth_test`+ - payload: `{"bot_token": "123:abc"}`+- `POST /telegram/chats`+ - payload: `{"include_private": false}`+- `POST /lark/auth_test`+ - payload: `{"app_id": "...", "app_secret": "...", "domain": "feishu"}`+- `POST /lark/chats`+ - payload: `{"app_id": "...", "app_secret": "...", "domain": "feishu"}`+- `POST /lark/temp_ws/start`+ - payload: `{"app_id": "...", "app_secret": "...", "domain": "feishu"}`+- `POST /lark/temp_ws/stop`+ - payload: `{}`+- `POST /wechat/qr_login/start`+ - payload: `{"base_url": "https://ilinkai.weixin.qq.com"}` or `{}`+- `POST /wechat/qr_login/poll`+ - payload: `{"session_key": "..."}`++WeChat QR login is special: when login is confirmed and a token is returned, the API auto-binds the WeChat user and schedules an internal service restart so the new token can take effect. Do not add an extra restart unless the user asks.++### Backend and local helper endpoints++- `GET /cli/detect?binary=<name-or-path>`+ - detects a CLI binary path+- `POST /agent/<name>/install`+ - `name` must be `opencode`, `claude`, or `codex`+- `POST /opencode/options`+ - payload: `{"cwd": "/path/to/repo"}`+ - returns OpenCode model, agent, and reasoning option data for that cwd+- `POST /opencode/setup-permission`+ - intentionally writes OpenCode native config to set `permission` to `allow`+- `GET /claude/agents?cwd=/path/to/repo`+- `GET /codex/agents?cwd=/path/to/repo`+- `GET /claude/models`+- `GET /codex/models`+- `POST /browse`+ - payload: `{"path": "~", "show_hidden": false}`++### Control endpoints++- `POST /control`+ - payload: `{"action": "start"}`, `{"action": "stop"}`, or `{"action": "restart"}`+- `POST /ui/reload`+ - payload: `{"host": "127.0.0.1", "port": 5123}`++Avoid these for routine configuration. `POST /control` starts, stops, or restarts the service. `POST /ui/reload` restarts only the Web UI server to apply host or port changes. Use them only with explicit user intent or a concrete need.-- `enabled`: for channel scopes, this is the enforceable on/off gate; for DM user scopes, do not treat it as the access-control source of truth-- `show_message_types`: which intermediate messages are visible; allowed values are `system`, `assistant`, `toolcall`-- `custom_cwd`: scope-level working directory override-- `routing`: backend choice and backend-specific overrides-- `require_mention`: channel-level override for mention gating; `null` means use platform global default-- `bind_codes`: DM authorization codes+## Scope and Precedence Rules-Important DM caveat: current DM authorization checks whether the user is bound, not whether `scopes.user.<platform>.<user_id>.enabled` is `true`. If the user wants to revoke DM access, do not rely on flipping `enabled` to `false`; use the supported unbind/remove-user path instead.+### Backend selection++Backend resolution priority is:++1. scope-level routing override from `/settings` or `/api/users`+2. platform router fallback+3. global default backend from `/config`++If the user names a specific channel or DM and wants a specific backend, use the scope API, not global `/config`.++### Working directory++Working directory resolution is:++1. `custom_cwd` on the target channel or user scope+2. `runtime.default_cwd` from `/config`++### Message visibility++`show_message_types` is scope-local. Preserve existing values unless the user wants an explicit replacement.If a user asks for "vault messages", "internal messages", or "tool execution messages", map that request to `show_message_types`. Current Vibe Remote does not expose a separate `vault` field.-### `sessions.json`+### Mention policy-This file stores transient-but-persisted runtime state:+`require_mention` works like this:-- session mappings-- active threads-- active OpenCode polls-- message dedup state-- last activity+- `null`: inherit platform default from `/config`+- `true`: require mention in that channel+- `false`: do not require mention in that channel-Do not edit it during normal config work. Prefer restart, doctor, or log inspection first.+## Recipes-### `scheduled_tasks.json`+### Route one Slack channel to Codex-This file stores persisted scheduled task definitions created by `vibe task`.+Goal:-Each task includes:+- enable Slack channel `C123`+- route it to Codex+- use Codex subagent `reviewer`+- use model `gpt-5.4`+- set reasoning `high`-- `id`-- `name`-- `session_key`-- `post_to`-- `deliver_key`-- `prompt`-- `schedule_type`-- `cron` or `run_at`-- `timezone`-- `enabled`-- `last_run_at`-- `last_error`+API flow:-Do not hand-edit this file during normal operations unless the user explicitly asks for low-level repair work. Prefer the CLI:+1. `GET /settings?platform=slack`+2. merge `channels.C123`+3. `POST /settings` with all Slack channels+4. read back `GET /settings?platform=slack`-- `vibe task add`-- `vibe task update <id>`-- `vibe task list`-- `vibe task list --brief`-- `vibe task list --all`-- `vibe task show <id>`-- `vibe task run <id>`-- `vibe task pause <id>`-- `vibe task resume <id>`-- `vibe task remove <id>`+Merged channel entry:-## Scope and Precedence Rules+```json+{+ "enabled": true,+ "show_message_types": ["assistant"],+ "custom_cwd": null,+ "require_mention": null,+ "routing": {+ "agent_backend": "codex",+ "opencode_agent": null,+ "opencode_model": null,+ "opencode_reasoning_effort": null,+ "claude_agent": null,+ "claude_model": null,+ "claude_reasoning_effort": null,+ "codex_agent": "reviewer",+ "codex_model": "gpt-5.4",+ "codex_reasoning_effort": "high"+ }+}+```-Use these rules when deciding where to edit.+### Route one channel to OpenCode with a subagent-### Backend selection+Use `/settings` and set:-Backend resolution priority is:+- `routing.agent_backend = "opencode"`+- `routing.opencode_agent = "<agent>"`+- `routing.opencode_model = "<model>"` if requested+- `routing.opencode_reasoning_effort = "<effort>"` if requested-1. scope-level `settings.json` routing override-2. platform router fallback-3. global default backend+If the user wants OpenCode-native defaults, providers, MCP servers, skills, plugins, or API credentials, use OpenCode config instead of Vibe Remote scope routing.-In practice, if the user names a specific channel or DM and wants a specific backend, edit `settings.json`, not `config.json`.+### Route one scope to Claude with model and reasoning-### Working directory+Use `/settings` for a channel or `/api/users` for a DM user and set:-Working directory resolution is:+- `routing.agent_backend = "claude"`+- `routing.claude_agent = "<agent>"` if requested+- `routing.claude_model = "<model>"`+- `routing.claude_reasoning_effort = "<effort>"`-1. `custom_cwd` in the target channel/user scope-2. `runtime.default_cwd` in `config.json`+The API normalizes Claude reasoning for incompatible model combinations; verify by reading back the saved payload.-### Message visibility+### Change the global default working directory-`show_message_types` is scope-local. Preserve existing values unless the user wants an explicit replacement.+Use `POST /config`:-### Mention policy+```json+{+ "runtime": {+ "default_cwd": "/path/to/workdir"+ }+}+```-`require_mention` works like this:+Do not overwrite scope-level `custom_cwd` entries.-- `null`: inherit platform default from `config.json`-- `true`: require mention in that channel-- `false`: do not require mention in that channel+### Show tool execution messages in one channel++Use `/settings` and add `toolcall` to the target channel's `show_message_types`.++Preserve existing `system` and `assistant` values unless the user asked for a full replacement.++### Switch primary platform++Use `POST /config` and keep `platforms.enabled` complete:++```json+{+ "platform": "discord",+ "platforms": {+ "enabled": ["slack", "discord"],+ "primary": "discord"+ }+}+```++Make sure the target platform config section exists and validates. Do not delete old platform config unless the user explicitly asks.++### Generate a DM bind code++Use `POST /api/bind-codes`:++```json+{+ "type": "one_time"+}+```++For an expiring code:++```json+{+ "type": "expiring",+ "expires_at": "2026-04-18"+}+```++Do not expose bind codes unless the user explicitly asks for them.## Scheduled Tasks@@ -332,7 +622,7 @@ Delivery controls:- do not combine `--post-to` and `--deliver-key` in the same command- `vibe task add` stores the text from `--prompt` or `--prompt-file` and injects it each time the task runs- `vibe hook send` queues the text from `--prompt` or `--prompt-file` once without storing a task-- `vibe watch add` uses `--prefix` as follow-up instruction text; on a successful cycle Vibe Remote prepends it before waiter stdout, joined with a blank line when both exist, and terminal failures also send a follow-up before disabling the watch+- `vibe watch add` uses `--prefix` as follow-up instruction text; on a successful cycle Vibe Remote prepends it before waiter stdout, joined with a blank line when both existSession key format:@@ -340,23 +630,15 @@ Session key format:- DM scope: `<platform>::user::<user_id>`- exact thread target: append `::thread::<thread_id>` when the user explicitly wants the task bound to that thread-Default rule:--- default to the current session key when the follow-up should continue the same conversation-- switch to a higher-level key only when the user wants a new higher-level session instead of continuing the current one-Operational guidance:- use `vibe task list` before editing or deleting an existing task-- if this is the first time using `vibe task add`, `vibe watch add`, or `vibe hook send`, read the matching `--help` output first because it explains both parameter syntax and runtime effects+- if this is the first time using `vibe task add`, `vibe watch add`, or `vibe hook send`, read the matching `--help` output first- use `vibe task update <id>` to keep the same task ID while changing name, schedule, prompt, or target-- use `vibe task list --brief` when you need a scheduling-focused summary instead of the full stored payload-- `vibe task list` hides completed one-shot tasks by default; use `vibe task list --all` when you need the full history-- use `vibe task show <id>` to inspect both the stored fields and derived scheduling state such as `next_run_at`-- use `vibe task run <id>` when the user wants to trigger one stored task immediately without changing its schedule-- use `vibe hook send` when the user wants one asynchronous turn without storing a task definition-- treat `warnings` from `vibe task add`, `vibe task update`, or `vibe hook send` as delivery-risk hints to fix proactively, not as fatal errors-- if a scheduled task fails unexpectedly, inspect `last_error` first and then check `~/.vibe_remote/logs/vibe_remote.log`+- use `vibe task list --brief` for scheduling-focused summaries+- `vibe task list` hides completed one-shot tasks by default; use `vibe task list --all` when you need full history+- use `vibe task show <id>` to inspect stored fields and derived scheduling state such as `next_run_at`+- treat `warnings` from task or hook commands as delivery-risk hints to fix proactively## Backend Capability Matrix@@ -374,7 +656,7 @@ Behavior notes:- Claude subagents are selected through `routing.claude_agent` or prefix routing.- Codex subagents are selected through `routing.codex_agent` or prefix routing.- Claude reasoning is selected through `routing.claude_reasoning_effort`; common values are `low`, `medium`, and `high`, and some models also allow `max`.-- If a Claude reasoning value is invalid for the chosen model, Vibe Remote drops that override and falls back to the backend default.+- If a Claude reasoning value is invalid for the chosen model, the API normalizes or drops that override and falls back to the backend default.## Subagent and Prefix Routing@@ -390,213 +672,6 @@ If the user asks for subagents, remember:- project `.codex/agents/`- OpenCode subagent and model defaults come from the OpenCode runtime/config rather than only from Vibe Remote's own config-## Important Caveat: OpenCode Defaults--`config.json` defines these schema fields:--- `agents.opencode.default_agent`-- `agents.opencode.default_model`-- `agents.opencode.default_reasoning_effort`--However, current runtime behavior primarily resolves effective OpenCode defaults from:--- scope-level overrides in `settings.json`-- OpenCode's own config and agent definitions-- internal fallback logic, including a fallback default agent of `build`--So when the user wants a guaranteed OpenCode agent choice inside Vibe Remote, prefer `routing.opencode_agent` on the target channel or user scope.--Use OpenCode native config mainly for OpenCode-native concerns such as:--- default model and reasoning behavior-- providers and API credentials-- skills, plugins, MCP servers, tools, and project-local OpenCode behavior--When diagnosing OpenCode behavior, inspect both global config (`~/.config/opencode/opencode.json`) and any active project-level `opencode.json` or `.opencode/` overrides.--## How to Enable a New Channel--When the user asks to enable a new Slack/Discord/Lark channel:--1. Confirm the active platform or the requested platform.-2. Read `settings.json`.-3. Create or update `scopes.channel.<platform>.<channel_id>`.-4. Set `enabled` to `true`.-5. Add only the requested overrides.-6. Preserve other platforms and other channel IDs.--Example: enable a Slack channel and route it to Codex with GPT-5.4 high reasoning.--```json-{- "scopes": {- "channel": {- "slack": {- "C1234567890": {- "enabled": true,- "show_message_types": [],- "custom_cwd": null,- "routing": {- "agent_backend": "codex",- "opencode_agent": null,- "opencode_model": null,- "opencode_reasoning_effort": null,- "claude_agent": null,- "claude_model": null,- "codex_agent": null,- "codex_model": "gpt-5.4",- "codex_reasoning_effort": "high"- },- "require_mention": null- }- }- }- }-}-```--If the user also wants a scope-specific working directory, set `custom_cwd` and verify the directory exists.--## How to Enable or Adjust a DM User Scope--DM users are stored under `scopes.user.<platform>.<user_id>`.--Normal flow:--- generate a bind code via Web UI or API-- user sends `/bind <code>` in DM-- Vibe Remote creates the user scope entry--If you must adjust an existing DM user scope:--- read the existing user entry first-- preserve `display_name`, `is_admin`, `bound_at`, and `dm_chat_id`-- only change requested keys such as `custom_cwd`, `show_message_types`, or `routing`--If the user wants to revoke an existing DM binding, treat that as a bind-state change rather than a normal settings toggle. In the current implementation, removing the user entry is the reliable way to revoke bound DM access.--Avoid creating fake bind or admin state unless the user explicitly asks for manual recovery.--## Common Recipes--### Recipe 1: Route one Slack channel to Codex--User intent:--- enable Slack channel `C...`-- backend `codex`-- optional subagent `reviewer`-- model `gpt-5.4`-- reasoning `high`--Action:--- edit `settings.json`-- target `scopes.channel.slack.<channel_id>`-- set `enabled: true`-- set `routing.agent_backend = "codex"`-- set `routing.codex_agent = "reviewer"` if requested-- set `routing.codex_model = "gpt-5.4"`-- set `routing.codex_reasoning_effort = "high"`--### Recipe 2: Route one channel to OpenCode with a subagent--User intent:--- use OpenCode in one channel-- choose subagent `plan`-- choose model `anthropic/claude-sonnet-4-5`-- set reasoning `high`--Action:--- edit `settings.json`-- set `routing.agent_backend = "opencode"`-- set `routing.opencode_agent = "plan"`-- set `routing.opencode_model = "anthropic/claude-sonnet-4-5"`-- set `routing.opencode_reasoning_effort = "high"`--If the user instead wants to change OpenCode-native defaults such as model, reasoning, providers, or MCP behavior across projects, edit OpenCode config rather than Vibe Remote. If the user wants Vibe Remote to use a specific OpenCode agent in one scope, edit `routing.opencode_agent` in `settings.json`.--### Recipe 3: Route one scope to Claude with model and reasoning--User intent:--- use Claude in one channel or DM-- choose subagent `reviewer`-- choose model `claude-sonnet-4-6`-- set reasoning `high`--Action:--- edit `settings.json`-- set `routing.agent_backend = "claude"`-- set `routing.claude_agent = "reviewer"` if requested-- set `routing.claude_model = "claude-sonnet-4-6"`-- set `routing.claude_reasoning_effort = "high"`-- keep the selected reasoning value compatible with the chosen model; common values are `low`, `medium`, and `high`, while `max` is only valid on supported models--### Recipe 4: Change the global default working directory--User intent:--- use one default working directory unless a channel overrides it--Action:--- edit `config.json`-- set `runtime.default_cwd`-- do not overwrite scope-level `custom_cwd` entries in `settings.json`--### Recipe 5: Show tool execution messages in one channel--User intent:--- show tool or internal execution messages--Action:--- edit the target scope's `show_message_types`-- add `toolcall`-- preserve existing `system` and `assistant` values unless the user asked for a full replacement--### Recipe 6: Switch the whole installation from Slack to Discord--User intent:--- run Vibe Remote on Discord instead of Slack--Action:--- edit `config.json`-- set `platform = "discord"`-- ensure `discord` config is present and valid-- do not delete `slack` or `lark` settings unless the user asked-- recommend `vibe doctor` and restart--## Operations and Troubleshooting--Main commands:--- `vibe`: start or restart Vibe Remote; preserves the OpenCode server when possible-- `vibe restart --delay-seconds 60`: preferred agent-safe restart; returns immediately and restarts later in the background-- `vibe restart`: immediate full restart; use only when the user explicitly wants it now-- `vibe status`: inspect runtime status-- `vibe stop`: stop Vibe Remote and the OpenCode server-- `vibe doctor`: validate config, CLI availability, and runtime health-- `vibe version`: print installed version-- `vibe check-update`: check for updates-- `vibe upgrade`: install latest version--Useful checks:--- config does not apply: run `vibe doctor`, then prefer `vibe restart --delay-seconds 60`-- backend missing: confirm the backend is enabled and the CLI path is executable-- channel does not respond: verify the right `settings.json` scope exists and `enabled` is `true`-- wrong repository/cwd: inspect `custom_cwd` and `runtime.default_cwd`-- startup failure: validate JSON and inspect `~/.vibe_remote/logs/vibe_remote.log`-- DM access denied: inspect bind-code state and user entry in `settings.json`-## Host Backend GuidanceWhen the request belongs to the host backend, do not force it into Vibe Remote config.@@ -628,6 +703,8 @@ Relevant docs:- plugins: `https://opencode.ai/docs/plugins/`- MCP servers: `https://opencode.ai/docs/mcp-servers/`+Inside Vibe Remote, OpenCode scope routing controls backend choice, subagent, model, and reasoning effort. Use `POST /opencode/setup-permission` only for the specific permission helper.+### Claude CodeUse Claude-native config when the user wants to change:@@ -647,7 +724,7 @@ Relevant docs:- subagents: `https://docs.anthropic.com/en/docs/claude-code/sub-agents`-Inside Vibe Remote, Claude scope routing currently controls backend choice, model, subagent, and reasoning effort.+Inside Vibe Remote, Claude scope routing controls backend choice, model, subagent, and reasoning effort.### Codex@@ -672,22 +749,59 @@ Relevant docs:- CLI overview: `https://developers.openai.com/codex/cli`- subagents: `https://developers.openai.com/codex/subagents`-Inside Vibe Remote, Codex scope routing currently controls backend choice, subagent, model, and reasoning effort.+Inside Vibe Remote, Codex scope routing controls backend choice, subagent, model, and reasoning effort.++## Troubleshooting++Start with evidence:++1. `GET /status`+2. `POST /doctor`+3. `POST /logs` with a small line count and focused source+4. read back `/config`, `/settings`, or `/api/users` for the affected scope++Common cases:++- config does not apply: verify the API read-back first; only restart if the changed field is startup-only+- backend missing: confirm backend is enabled, CLI path is executable, and `/cli/detect` finds it+- channel does not respond: verify `/settings?platform=<platform>` contains the channel and `enabled` is true+- wrong repository/cwd: inspect `custom_cwd` and `runtime.default_cwd`+- DM access denied: inspect `/api/users?platform=<platform>` and bind-code state+- startup failure: use `GET /status`, `POST /doctor`, then inspect logs++Do not use `vibe restart`, `POST /control {"action":"restart"}`, or `POST /ui/reload` as a first response to config problems.++## Direct File Recovery Fallback++Use file edits only when:++- the Web UI API is down and cannot be recovered through normal service start+- the config file is malformed and prevents the API from starting+- the user explicitly asks for low-level file repair++Recovery rules:++1. Identify `VIBE_REMOTE_HOME` or default to `~/.vibe_remote`.+2. Back up the target file before writing.+3. Preserve unrelated keys and secrets.+4. Validate JSON after editing.+5. Start or restart only when needed to bring the API back.+6. After recovery, return to the API workflow for further changes.## Safety BoundariesAlways follow these constraints:-- never delete unrelated platform scopes from `settings.json`+- never delete unrelated platform scopes- never blank out tokens or secrets as part of an unrelated config task-- never claim a backend feature exists if current Vibe Remote behavior does not actually support it+- never claim a backend feature exists if current Vibe Remote behavior does not support it- never manually rewrite `sessions.json` for routine routing changes- never expose bind codes unless the user explicitly asks- always say when a requested change actually belongs in OpenCode, Claude Code, or Codex config instead of Vibe Remote## Escalation-If the user still cannot solve a problem after normal config fixes, `vibe doctor`, restart, and log inspection, point them to the Vibe Remote repository:+If the user still cannot solve a problem after API read-back checks, doctor, and log inspection, point them to the Vibe Remote repository:- repo: `https://github.com/cyhhao/vibe-remote`@@ -703,8 +817,8 @@ If the user wants to contribute back, suggest opening an issue or a pull requestWhen you complete a Vibe Remote maintenance task, report back with:-1. which file(s) changed+1. which API endpoint changed the state2. whether the change is global or scope-specific3. which keys changed-4. any caveats, especially backend feature limitations-5. the recommended verification step, usually `vibe doctor` and/or restart+4. the read-back or doctor evidence+5. whether a restart was avoided, deferred, or still required and whydiff --git a/skills/use-vibe-remote/scripts/vibe_api.py b/skills/use-vibe-remote/scripts/vibe_api.pynew file mode 100755index 000000000..fc260937e--- /dev/null+++ b/skills/use-vibe-remote/scripts/vibe_api.py@@ -0,0 +1,121 @@+#!/usr/bin/env python3+"""Small Vibe Remote Web UI API helper for agents.++This helper intentionally uses only the Python standard library so it can run+inside local machines and regression containers without installing packages.+"""++from __future__ import annotations++import argparse+import hashlib+import json+import os+import sys+import tempfile+import urllib.error+import urllib.parse+import urllib.request+from http.cookiejar import MozillaCookieJar+from pathlib import Path+from typing import Any++MUTATING_METHODS = {"POST", "PUT", "PATCH", "DELETE"}+DEFAULT_BASE = "http://127.0.0.1:5123"+++class VibeApiClient:+ def __init__(self, base_url: str, cookie_jar_path: Path | None = None, timeout: float = 30.0):+ self.base_url = base_url.rstrip("/")+ self.timeout = timeout+ self.cookie_jar_path = cookie_jar_path or self._default_cookie_jar_path(self.base_url)+ self.cookie_jar_path.parent.mkdir(parents=True, exist_ok=True)+ self.cookie_jar = MozillaCookieJar(str(self.cookie_jar_path))+ if self.cookie_jar_path.exists():+ try:+ self.cookie_jar.load(ignore_discard=True, ignore_expires=True)+ except Exception:+ # Stale or corrupt cookie jars should not block maintenance.+ pass+ self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cookie_jar))++ @staticmethod+ def _default_cookie_jar_path(base_url: str) -> Path:+ digest = hashlib.sha256(base_url.encode("utf-8")).hexdigest()[:12]+ return Path(tempfile.gettempdir()) / f"vibe_api_{digest}.cookies"++ def call(self, method: str, path: str, payload: Any = None) -> Any:+ method = method.upper()+ url = urllib.parse.urljoin(self.base_url + "/", path.lstrip("/"))+ data = None if payload is None else json.dumps(payload).encode("utf-8")+ headers = {"Accept": "application/json"}+ if method in MUTATING_METHODS:+ headers["Origin"] = self.base_url+ headers["Content-Type"] = "application/json"+ headers["X-Vibe-CSRF-Token"] = self.get_csrf_token()++ request = urllib.request.Request(url, data=data, headers=headers, method=method)+ try:+ with self.opener.open(request, timeout=self.timeout) as response:+ body = response.read().decode("utf-8")+ self.cookie_jar.save(ignore_discard=True, ignore_expires=True)+ return json.loads(body) if body else {}+ except urllib.error.HTTPError as exc:+ body = exc.read().decode("utf-8", errors="replace")+ message = body or exc.reason+ raise SystemExit(f"HTTP {exc.code} {method} {path}: {message}") from exc+ except urllib.error.URLError as exc:+ raise SystemExit(f"Request failed {method} {path}: {exc.reason}") from exc++ def get_csrf_token(self) -> str:+ payload = self.call("GET", "/api/csrf-token")+ token = payload.get("csrf_token") if isinstance(payload, dict) else None+ if not token:+ raise SystemExit("Missing csrf_token from /api/csrf-token")+ return str(token)+++def _load_payload(value: str | None) -> Any:+ if value is None:+ return None+ if value == "-":+ return json.load(sys.stdin)+ if value.startswith("@"):+ return json.loads(Path(value[1:]).read_text(encoding="utf-8"))+ return json.loads(value)+++def main(argv: list[str] | None = None) -> int:+ parser = argparse.ArgumentParser(+ description="Call the local Vibe Remote Web UI API with CSRF handling.",+ )+ parser.add_argument("method", help="HTTP method, for example GET, POST, DELETE")+ parser.add_argument("path", help="API path, for example /settings?platform=slack")+ parser.add_argument(+ "payload",+ nargs="?",+ help="JSON payload, @file.json, or - for stdin. Omit for GET/DELETE without a body.",+ )+ parser.add_argument(+ "--base",+ default=os.environ.get("VIBE_UI_BASE", DEFAULT_BASE),+ help=f"Web UI base URL. Defaults to VIBE_UI_BASE or {DEFAULT_BASE}.",+ )+ parser.add_argument(+ "--cookie-jar",+ default=os.environ.get("VIBE_API_COOKIE_JAR"),+ help="Cookie jar path. Defaults to a per-base temp file.",+ )+ parser.add_argument("--timeout", type=float, default=30.0, help="Request timeout in seconds.")+ args = parser.parse_args(argv)++ cookie_jar_path = Path(args.cookie_jar).expanduser() if args.cookie_jar else None+ client = VibeApiClient(args.base, cookie_jar_path=cookie_jar_path, timeout=args.timeout)+ payload = _load_payload(args.payload)+ result = client.call(args.method, args.path, payload)+ print(json.dumps(result, indent=2, sort_keys=True))+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())