Skip to content

fix(bot-browser): support preview-metaapp URIs in browser-open RPC and skill - #7

Open
WuFenG-Hub wants to merge 1 commit into
metaid-developers:mainfrom
WuFenG-Hub:fix/browser-open-preview-metaapp
Open

fix(bot-browser): support preview-metaapp URIs in browser-open RPC and skill#7
WuFenG-Hub wants to merge 1 commit into
metaid-developers:mainfrom
WuFenG-Hub:fix/browser-open-preview-metaapp

Conversation

@WuFenG-Hub

Copy link
Copy Markdown

Problem

metabot-browser-open and the local RPC POST /api/idbots/bot-browser/open rejected preview-metaapp:// URIs, so a local preview could not be opened through the skill path even though the Bot Browser renderer already supports the scheme (it is the same URI family used by bot_browser_preview_local).

Two concrete failures:

  1. The skill script's SUPPORTED_URI_RE regex (\b(metaid|pin|metaapp|map|metafile)://) matched metaapp:// inside preview-metaapp://, silently stripping the preview- prefix and navigating the Bot Browser to an invalid metaapp://localhost/... address.
  2. The RPC server whitelist BOT_BROWSER_URI_SCHEMES did not include preview-metaapp, returning unsupported Bot Browser URI scheme: preview-metaapp even when the exact URI was posted.

Changes

  • SKILLs/metabot-browser-open/scripts/index.js

    • Recognize preview-metaapp first in SUPPORTED_URI_RE so it is no longer split into metaapp://.
    • Allow preview-metaapp in normalizeSupportedUri and keep its authority/path case-sensitive (local file paths), matching how map:// is already treated.
  • src/main/services/metaidRpcServer.ts

    • Add preview-metaapp to BOT_BROWSER_URI_SCHEMES.
    • Restrict preview-metaapp to the localhost host in normalizeBotBrowserUri, matching the renderer's preview-metaapp resolver (which resolves local previews only when host is exactly localhost). This keeps the RPC from being used to point the Bot Browser at arbitrary https:// URLs.
  • SKILLs/metabot-browser-open/SKILL.md

    • Document the preview-metaapp://localhost/<absolute-path> route target.

Verification

  • Skill script dry-run normalization passes for preview-metaapp://localhost/<abs-path> (case preserved), mixed-case Preview-MetaApp:// scheme, and existing behaviors (metaapp:// pin, bare pin, bare globalMetaID).
  • normalizeBotBrowserUri edge cases: accepts preview-metaapp://localhost/..., rejects non-localhost hosts and localhost:<port>.
  • npm run compile:electron passes with 0 errors.
  • eslint on metaidRpcServer.ts passes with 0 warnings.

Notes / risk

This widens the RPC open-URI input by one scheme. Risk is bounded because preview-metaapp is only accepted with a localhost host, and the renderer only serves local disk previews for that host. The change does not alter any other whitelisted scheme.

…d skill

The metabot-browser-open skill and the /api/idbots/bot-browser/open RPC
rejected preview-metaapp:// URIs, so a local preview could not be opened
through the skill path even though the Bot Browser renderer supports the
scheme (equivalent to bot_browser_preview_local).

- skill script: the SUPPORTED_URI_RE regex matched metaapp:// inside
  preview-metaapp:// and silently stripped the preview- prefix. Recognize
  preview-metaapp first and keep its authority/path case-sensitive.
- metaidRpcServer: add preview-metaapp to BOT_BROWSER_URI_SCHEMES and
  restrict it to the localhost host (the renderer resolves local previews
  only when host === 'localhost'), so the RPC cannot be used to point the
  Bot Browser at arbitrary https URLs.
- SKILL.md: document the preview-metaapp route target.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant