Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
feat(store): unify VPS MCP and skills installation with dynamic host harness
Rahman639b41821168
diff --git a/app/api/v1/project-mcp/route.ts b/app/api/v1/project-mcp/route.tsindex 70ebece7..c3b6621b 100644--- a/app/api/v1/project-mcp/route.ts+++ b/app/api/v1/project-mcp/route.ts@@ -3,16 +3,20 @@ import { getSessionContext } from "@/lib/auth/require-session";import { readSetupJson } from "@/lib/infra/setup-http";import { executeCapabilityCall } from "@/lib/capabilities/execute";import { maxScope } from "@/lib/mcp/scope";+import { PROJECT_MCP_TOOLS } from "@/lib/mcp/tools-project-mcp";+import { IS_DEMO } from "@/lib/demo";import { PROJECT_MCP_MANAGE_TOOLS } from "@/lib/mcp/tools-project-mcp-manage";export const runtime = "nodejs";export const dynamic = "force-dynamic";export async function POST(req: NextRequest) {const headers = { "Cache-Control": "no-store, private" };const auth = await getSessionContext();- if (auth?.role !== "owner") return NextResponse.json({ error: "owner_required" }, { status: 403, headers });+ if (IS_DEMO || auth?.role !== "owner") return NextResponse.json({ error: "owner_required" }, { status: 403, headers });try {const args = await readSetupJson(req), actor = "device:" + auth.session.device_id;- const result = await executeCapabilityCall({ tool: PROJECT_MCP_MANAGE_TOOLS[0], args, actor, scope: maxScope(), context: { principal: actor } });+ const tool = args.action === "tools" ? PROJECT_MCP_TOOLS[0] : PROJECT_MCP_MANAGE_TOOLS[0];+ if (args.action === "tools") delete args.action;+ const result = await executeCapabilityCall({ tool, args, actor, scope: maxScope(), context: { principal: actor } });if (result.kind !== "success") throw new Error(result.message);return NextResponse.json(result.result, { headers });} catch (e) { return NextResponse.json({ error: e instanceof Error ? e.message.slice(0, 300) : "MCP operation failed" }, { status: 400, headers }); }diff --git a/app/api/v1/skill-market/route.test.ts b/app/api/v1/skill-market/route.test.tsnew file mode 100644index 00000000..f09f867e--- /dev/null+++ b/app/api/v1/skill-market/route.test.ts@@ -0,0 +1,24 @@+import { beforeEach, it, expect, vi } from "vitest";+import { NextRequest } from "next/server";+const state = vi.hoisted(() => ({ role: "owner" as string | null, demo: false, list: vi.fn(), manage: vi.fn(), audit: vi.fn() }));+vi.mock("@/lib/auth/require-session", () => ({ getSessionContext: async () => state.role ? { role: state.role, session: { device_id: "test-owner" } } : null }));+vi.mock("@/lib/demo", () => ({ get IS_DEMO() { return state.demo; } }));+vi.mock("@/lib/host/skill-market-api", () => ({ listSkillMarket: state.list, manageSkillMarket: state.manage }));+vi.mock("@/lib/host/audit-api", () => ({ audit: state.audit }));+import { GET, POST } from "./route";+const request = (body: unknown) => new NextRequest("https://mso.example/api/v1/skill-market", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });+beforeEach(() => { vi.clearAllMocks(); state.role = "owner"; state.demo = false; state.list.mockResolvedValue({ skills: [] }); state.manage.mockResolvedValue({ skills: [] }); });+it("only permits owner devices and keeps demo writes disabled", async () => {+ for (const role of [null, "viewer", "operator"]) { state.role = role; expect((await GET()).status).toBe(403); expect((await POST(request({ action: "install", id: "ponytail" }))).status).toBe(403); }+ state.role = "owner"; state.demo = true; expect((await GET()).status).toBe(403); expect(state.list).not.toHaveBeenCalled(); expect(state.manage).not.toHaveBeenCalled();+});+it("uses the canonical lifecycle and records the confirmed mutation", async () => {+ const body = { action: "install", id: "ponytail", revision: "a".repeat(64) };+ expect((await POST(request(body))).status).toBe(200); expect(state.manage).toHaveBeenCalledWith(body); expect(state.audit).toHaveBeenCalledWith(expect.objectContaining({ action: "fs.write", ok: true, target: "ponytail" }));+ expect((await GET()).headers.get("Cache-Control")).toContain("no-store");+});+it("requires a fresh revision and reports lifecycle refusal", async () => {+ expect((await POST(request({ action: "remove", id: "ponytail" }))).status).toBe(400); expect(state.manage).not.toHaveBeenCalled();+ state.manage.mockRejectedValue(new Error("Skill revision changed"));+ expect((await POST(request({ action: "remove", id: "ponytail", revision: "a".repeat(64) }))).status).toBe(400);+});diff --git a/app/api/v1/skill-market/route.ts b/app/api/v1/skill-market/route.tsnew file mode 100644index 00000000..6df47765--- /dev/null+++ b/app/api/v1/skill-market/route.ts@@ -0,0 +1,30 @@+import { NextRequest, NextResponse } from "next/server";+import { getSessionContext } from "@/lib/auth/require-session";+import { IS_DEMO } from "@/lib/demo";+import { readSetupJson } from "@/lib/infra/setup-http";+import { listSkillMarket, manageSkillMarket } from "@/lib/host/skill-market-api";+import { audit } from "@/lib/host/audit-api";+export const runtime = "nodejs";+export const dynamic = "force-dynamic";+const headers = { "Cache-Control": "no-store, private" };+export async function GET() {+ if (IS_DEMO || (await getSessionContext())?.role !== "owner") return NextResponse.json({ error: "owner_required" }, { status: 403, headers });+ try { return NextResponse.json(await listSkillMarket(), { headers }); }+ catch (error) { return NextResponse.json({ error: error instanceof Error ? error.message.slice(0, 300) : "Skill catalog failed" }, { status: 400, headers }); }+}+export async function POST(req: NextRequest) {+ const auth = await getSessionContext();+ if (IS_DEMO || auth?.role !== "owner") return NextResponse.json({ error: "owner_required" }, { status: 403, headers });+ let target = "skill-market";+ try {+ const args = await readSetupJson(req);+ if ((args.action !== "install" && args.action !== "remove") || typeof args.id !== "string" || typeof args.revision !== "string") throw new Error("action, id and revision required");+ target = args.id;+ const result = await manageSkillMarket({ action: args.action, id: args.id, revision: args.revision });+ await audit({ action: args.action === "remove" ? "fs.delete" : "fs.write", actor: auth.session.device_id, target, ok: true, meta: { via: "skill-market", operation: args.action } });+ return NextResponse.json(result, { headers });+ } catch (error) {+ await audit({ action: "fs.write", actor: auth.session.device_id, target, ok: false, meta: { via: "skill-market" } });+ return NextResponse.json({ error: error instanceof Error ? error.message.slice(0, 300) : "Skill operation failed" }, { status: 400, headers });+ }+}diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex cb382222..712bb464 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -88,13 +88,13 @@ MSO uses several extension concepts because they own different authority. They a| **Skill** | Trusted reusable instructions and routing policy (`SKILL.md`, optional structured contract/resources). | Skill trust (`official / verified / local / untrusted`) controls whether instructions may be model-loaded. A skill does not grant credentials or tool permission. | MCP server, Integration, executable app. || **OpenAI/Codex plugin package** | Distribution metadata for reviewed skills plus an optional registered-app mapping (`.codex-plugin/plugin.json` + `.app.json`). | Packaging only. The package does not authorize the live MSO MCP server. | MSO Project Plugin, registered app, MCP authorization. || **Registered app** | External platform identity referenced by `.app.json` when an exact real app registration exists. | Platform-owned install/connection/permission state. MSO keeps the mapping empty until an exact registration exists. | Generic MSO Integration or Project Plugin. |-| **Project Plugin** | A reviewed portable capability package that can declare skills and an MCP binding for one exact project. | Catalog presence never means installed. `project_mcp_manage` installs/removes only the selected project and uses revision guards. | Global plugin install, Skill Market entry, Integration credential. |+| **Project Plugin** | A reviewed portable capability package that can declare skills and an MCP binding for one exact project. | Catalog presence never means installed. `project_mcp_manage` installs/removes only the selected project or explicit `@host` target with revision guards; no inheritance. | Global plugin install, Skill Market entry, Integration credential. || **MCP** | Protocol/transport boundary for structured tools. This includes MSO's own `/mcp` and project-declared MCP servers. | Tool schemas are discovered from the selected server; OAuth/project policy and call-time guards remain authoritative. | Package identity or credential storage. || **Integration** | Credential identity and provider routing: credential user → provider → named connection → source/backend → auth method. | Native Integrations is the credential authority; secrets stay outside ordinary model/tool arguments. | MCP itself, Project Plugin, App. || **App** | AppShell user-interface application or feature surfaced inside the MSO workspace. | UI install/toggle state belongs to the shell/app registry. | Managed service runtime or MCP capability. || **Managed App** | External runtime/service that MSO installs or operates, such as Hermes, OpenClaw or 9Router. | Host/service lifecycle, health, version, backup/update/uninstall state. | App Store entry, Integration, Project Plugin. || **Skill Market** | Curated source of reviewed skill bundles. | Install state is local skill state (`installed / modified / conflict / not-installed`); removal refuses unmanaged content. | General app/plugin marketplace. |-| **App Store** | MSO shell catalog for UI apps/features. | Presentation/install state in the workspace. | OpenAI plugin directory, Project Plugin catalog, Managed App registry. |+| **App Store** | Apps plus shared MCP/Skills management tabs. | UI app state remains in the workspace; MCP bindings and managed skill files live on the VPS and are shared with Settings. | OpenAI plugin directory, Project Plugin catalog, Managed App registry. |OpenAI/Codex `.app.json` bindings may point at a registered app or a portable connector/template identity, and each binding declares whether it is required. `required: true` is a hard package dependency; `required: false` is an optional capability. Optional does **not** authorize a silent identity change: a fallback may change transport only when it uses an already-authorized, explicitly selected principal/connection and preserves the task's scope. Never copy provider OAuth credentials, silently switch from provider-owned MCP/OAuth to a local token, or treat fallback availability as equivalent authorization.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex e9240cf6..7445cb7c 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,5 +1,26 @@## 2026-09-17 — GitHub reference audit and optional app-binding compatibility++## 2026-09-17 — VPS-backed Store MCP/Skills and explicit host MCP harness++The former custom plugin registry lived only in browser storage while actual project+bindings and reviewed skill installation already had server-side authorities. Store now+keeps its existing Apps surface and adds MCP/Skills tabs; Settings → MCP → MSO to External+reuses the same panels. Previous browser declarations are retained for explicit review,+not silently installed. Host `@host` and exact-project targets never inherit each other.++Native manage/discover/call tools accept `@host`, so an external client can discover and+invoke an installed downstream MCP without global tool-name duplication. Check tools is+real paginated native discovery. The skill API reuses reviewed CLI payloads and its local+root, enforces owner access/revision checks and refuses modified/unmanaged/extra/symlink+content before deletion. Remote MCPs remain connection installs, not SaaS downloads;+shared runtimes and provider credentials are not uninstall-owned resources.++Verification is recorded in the release workflow: actual temporary-filesystem install,+update/removal, stale revision and unsafe-content refusals, dynamic stdio dispatch,+secret-scrubbing, post-uninstall denial, owner API and shared UI contracts. CLI/API parity+and synthetic browser release journeys were updated with isolated skill state.+Audited the saved OpenAI GitHub `0.1.12-5f7cd798dc99` package. The snapshot is package/interface metadata only, so no unobserved PR/issue/CI action semantics were invented. Its `.app.json` provides a concrete compatibility correction: GitHub binds an exact `connector_*` identity with `required:false`, while MSO's OpenAI plugin checker previously accepted only `asdk_app_*` and required every dependency to be `true`. Added a tested app-binding validator that accepts registered-app, connector and documented template binding identities plus boolean required/optional state; authorization behavior is unchanged. Also made optional capability fallback explicit in architecture and `/mso`: fallback may change transport only through an already-authorized, explicitly selected identity and must never silently switch principal, credential source, or provider-owned OAuth/MCP into a local key. Updated the living plugin-reference matrix and recorded that GitHub strengthens the target-aware resolver/dependency-contract candidates but does not yet justify a generic dependency graph or universal fallback engine.## 2026-09-17 — Plugin Management reference audit and extension taxonomydiff --git a/docs/PROJECT-MCP-CONNECTIONS.md b/docs/PROJECT-MCP-CONNECTIONS.mdindex ec19aca6..0d7cb86c 100644--- a/docs/PROJECT-MCP-CONNECTIONS.md+++ b/docs/PROJECT-MCP-CONNECTIONS.md@@ -6,7 +6,7 @@ The host capability keeps exec-scope enforcement, rate limits and audit ownershi## Default and installation boundary-A fresh project has no project MCP server and no SI-Coder/Batonly plugin. MSO's plugin catalog is only a list of available integrations. Installation always targets one exact project and writes only that project's `.mcp.json`; parent and sibling manifests are not inherited.+A fresh project has no project MCP server and no SI-Coder/Batonly plugin. MSO's plugin catalog is only a list of available integrations. Project installation targets one exact project and writes only that project's `.mcp.json`; parent and sibling manifests are not inherited. The explicit `project="@host"` target separately manages this VPS's host MCPs; host bindings are never copied into projects.Reviewed plugins use compact identities rather than copied executable/endpoint details:@@ -78,7 +78,7 @@ is treated as unsupported, not a hard failure. Modern stdio is opt-in withprotocolVersion: 2026-07-28. Rich image/audio/resource resultsare preserved; downstream UI metadata is namespaced rather than trusted as MSO UI origins.-Use **Settings → MCP → MSO Access → Project plugins** for reviewed SI-Coder/Batonly installation, or `project_mcp_manage` with revision checks. Use Integrations → Add MCP for reusable private MCP credentials. Arbitrary HTTPS project MCPs can still be registered directly with `url`. See [automation flows](AUTOMATION-FLOWS.md) for CLI, sessions and assets.+Use **Store → MCP** or **Settings → MCP → MSO to External → MCP** for reviewed SI-Coder/Batonly installation, or `project_mcp_manage` with revision checks. Use Integrations → Add MCP for reusable private MCP credentials. Arbitrary HTTPS project MCPs can still be registered directly with `url`. See [automation flows](AUTOMATION-FLOWS.md) for CLI, sessions and assets.Tool arguments are objects, bounded to 128 KiB; downstream schema validation remainsthe application's authority. Descriptions/results are untrusted tool data.@@ -99,3 +99,51 @@ Report unconfigured downstream credentials separately from implementation healthRollback the project binding or revoke/delete its dedicated connection. Do notdelete the app's data or replace an existing user's token just to test the broker.+++## Store, host scope, and dynamic harness++Store has **Apps**, **MCP**, and **Skills** tabs. The MCP and Skills panels are shared+with Settings → MCP → MSO to External; their install state is read from the VPS,+not a second browser-local installation registry. Previous browser-only custom+manifests remain available for explicit review; they are never auto-executed.++For host MCPs, choose **This MSO host** in the UI or `project: "@host"` in the existing+generic tools. The binding directory is `.mso-host-mcp` beneath the first configured+owner write root. It obeys read/write bounds and rejects symlink directories.+No private MSO credential directory is exposed through ordinary filesystem tools.++1. `project_mcp_manage({project:"@host", action:"inspect"})` returns aliases and revision.+2. Install/remove with the same tool and the fresh revision. Inspections have a separate bounded read budget; refresh does not consume the mutation quota. Reviewed SI-Coder uses+ its existing managed runtime; Batonly uses an explicitly selected private connection.+ Custom HTTPS MCP endpoints can be added without copying credentials into the manifest.+3. `project_mcp_tools({project:"@host",server:"alias",refresh:true})` discovers live schemas.+ Follow `nextCursor`; neither a successful page nor an installation proves every action.+4. `project_mcp_call({project:"@host",server:"alias",tool:"exact_name",arguments:{...}})`+ dispatches through the existing guarded transport and private authorization policy.++This is **ChatGPT → MSO → installed MCP**, without adding every downstream tool name to+MSO's global catalog. Installation changes take effect at lookup time; after uninstall,+new calls fail. Refreshing the MSO client exposes changed descriptor text, but no+per-plugin ChatGPT connection is necessary. Each downstream service still requires+its own authorization; MSO is not a permission bypass.++Remote MCP install/uninstall adds/removes a local connection manifest, not the remote+SaaS application. A managed SI-Coder binding does not own its shared runtime. Consequently+uninstall preserves shared binaries, Integrations credentials and provider data. Arbitrary+npm/OCI/archive runtime downloads are not performed by this Store panel.++## Skills on the VPS++Store → Skills and the matching Settings tab use the existing reviewed `skill-market`+catalog and repository-owned CLI. Install copies checksum-verified `SKILL.md` and its+management receipt into `MSO_SKILL_INSTALL_ROOT` (default `~/.mso/skills`). The skill+scanner uses the same root. Uninstall removes only unchanged, marker-owned contents;+modified, unmanaged, extra files and symlink targets are refused for manual review.+An unchanged older managed version can be updated through the same flow.++The browser API is Owner-only, bounded, audited and revision-checked. Local CLI commands+remain available offline. `mso skills store list` reads the server snapshot;+`mso skills store install <id> <revision>` and `mso skills store remove <id> <revision>`+use the same guarded API as the UI. Existing project, official and manual skills remain+visible but are not deleted by the Store. Installing instructions never grants tool access.diff --git a/docs/SLICE-CATALOG.md b/docs/SLICE-CATALOG.mdindex 45285250..389cc9d7 100644--- a/docs/SLICE-CATALOG.md+++ b/docs/SLICE-CATALOG.md@@ -3,12 +3,12 @@> **Current reference.** Counts are checked against the directory tree by> `scripts/check-docs.mjs`; the directory remains the final authority.-<!-- slice-catalog: slices=25 appshell-features=10 -->+<!-- slice-catalog: slices=26 appshell-features=10 -->Every application is a vertical slice under `frontend/slices/`. Host-facing slices use theshared API/host seam rather than reaching arbitrary Node host APIs from client code.-## Slices (25)+## Slices (26)| Slug | Purpose ||---|---|@@ -20,6 +20,7 @@ shared API/host seam rather than reaching arbitrary Node host APIs from client c| `code-editor` | Code/text editor with integrated terminal || `create-app` | Create App manifest authoring surface || `docs` | In-app documentation browser |+| `extensions` | Shared VPS-backed MCP and Skills Store / Settings installation panels || `files-manager` | VPS Files manager || `image-editor` | Layered raster image editor || `image-picker` | Reusable image/wallpaper picker |diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.mdindex acbd7a56..088772a6 100644--- a/docs/generated/MCP-CATALOG.md+++ b/docs/generated/MCP-CATALOG.md@@ -4,13 +4,13 @@## Full MSO catalog-<!-- mcp-toolset: server=1.15.0 version=2026.09.17.1 tools=111 read=54 write=35 exec=22 -->+<!-- mcp-toolset: server=1.15.1 version=2026.09.17.2 tools=111 read=54 write=35 exec=22 -->| Fact | Current source value ||---|---:|-| MCP server | `1.15.0` |-| Toolset | `2026.09.17.1` |-| Toolset changed at | `2026-09-17T02:50:00+07:00` |+| MCP server | `1.15.1` |+| Toolset | `2026.09.17.2` |+| Toolset changed at | `2026-09-17T17:50:58+07:00` || Transport tools | **113** || Model/operator tools | **111** || Read | **54** |@@ -145,7 +145,7 @@## ChatGPT model profile-<!-- mcp-chatgpt-profile: server=1.15.0 version=2026.09.17.1 tools=111 read=54 write=35 exec=22 app-only=2 total=113 -->+<!-- mcp-chatgpt-profile: server=1.15.1 version=2026.09.17.2 tools=111 read=54 write=35 exec=22 app-only=2 total=113 -->The ChatGPT profile automatically projects the complete MSO-owned generic model/operator catalog. OAuth scope is still enforced independently; app-only compatibility bridges stay app-only, and project-owned MCP tool names remain dynamic data behind the generic project bridge.diff --git a/frontend/slices/app-store/app.tsx b/frontend/slices/app-store/app.tsxindex ebb8ee28..1babf927 100644--- a/frontend/slices/app-store/app.tsx+++ b/frontend/slices/app-store/app.tsx@@ -1,193 +1,14 @@"use client";--import { useMemo, useState } from "react";-import { Search, Sparkles, Store } from "lucide-react";+import { useId, useState } from "react";import { ScrollArea } from "@/components/ui/scroll-area";-import { Input } from "@/components/ui/input";-import { AppFrame, useContainer, useActiveShell, useContextZone, openWindow } from "@/features/appshell";-import type { MenuItem } from "@/features/appshell";-import { UninstallConfirm } from "./components/uninstall-confirm";-import { usePublishInspector } from "./lib/host";-import {- StoreFilterChips,- StoreSidebar,- type StoreFilter,-} from "./components/store-sidebar";-import { FeaturedCard } from "./components/featured-card";-import { StoreAppCard } from "./components/store-app-card";-import { SystemCard } from "./components/system-card";-import { FEATURED_ID, mergeCatalog } from "./lib/store-catalog";-import { SYSTEM_CATALOG } from "./lib/system-catalog";-import { useApps } from "./lib/apps-store";-import { useDisabledIds } from "./lib/enabled-store";-import { useStoreInstall } from "./lib/use-store-install";--// Default export so os-shell can lazy-load it as a window app. Installing an app-// flips its localStorage row (useInstalledApps surfaces it in the dock/launchpad).-// The "Apps"/"Features" sections instead toggle the built-in apps + shell features-// on/off (enabled-store) — os-root filters the manifest by the disabled set.+import { CategoryTabs, McpStorePanel, SkillStorePanel } from "@/features/extensions";+import AppsPanel from "./components/apps-panel";export default function AppStore() {- const [query, setQuery] = useState("");- const [filter, setFilter] = useState<StoreFilter>("Featured");- // Store-level zone: a right-click anywhere in the grid gets this, and a- // right-click ON a card merges the card's items ABOVE it (nested).- const storeZone = useContextZone((): MenuItem[] => [- { label: "Suggest an app…", icon: Sparkles, onClick: () => openWindow("assistant", "Alfa") },- ]);- // Pane-width bucket (JS, not CSS): the sidebar/chip swap must share ONE- // measurement, and the chips live inside the AppFrame's own @container.- const [paneRef, pane] = useContainer<HTMLDivElement>();- const compact = pane === "xs" || pane === "sm";- // Mobile shell navigation already owns the App Store title on both mobile OSes,- // so the in-content title is desktop-only; iOS still gets its systemFill search.- const activeShell = useActiveShell();- const ios = activeShell.id === "ios";- const mobile = activeShell.surface === "mobile";-- const rows = useApps();- const disabled = useDisabledIds();- const off = useMemo(() => new Set(disabled), [disabled]);- const isSystem = filter === "Apps" || filter === "Features";-- // Merge curated catalog with live install state from localStorage.- const catalog = useMemo(() => mergeCatalog(rows), [rows]);- const featured = catalog.find((a) => a.appId === FEATURED_ID) ?? catalog[0];-- // Install state machine + destructive confirm gates (uninstall = needs prompt).- const install = useStoreInstall(off);-- const list = useMemo(() => {- const q = query.trim().toLowerCase();- return catalog.filter((a) => {- if (filter !== "Featured" && a.category !== filter) return false;- if (!q) return true;- return (- a.title.toLowerCase().includes(q) || a.desc.toLowerCase().includes(q)- );- });- }, [catalog, query, filter]);-- const systemList = useMemo(() => {- const q = query.trim().toLowerCase();- const kind = filter === "Features" ? "feature" : "app";- return SYSTEM_CATALOG.filter(- (e) =>- e.kind === kind &&- (!q || e.title.toLowerCase().includes(q) || e.desc.toLowerCase().includes(q)),- );- }, [filter, query]);-- const count = isSystem ? systemList.length : list.length;- const noun = isSystem ? (filter === "Features" ? "feature" : "app") : "app";- const installedCount = catalog.filter((a) => a.installed).length;-- // Surface store state to the shell AI Inspector.- usePublishInspector(- "app-store",- {- subject: "App Store",- props: [- { label: "Installed", value: String(installedCount) },- { label: "Catalog", value: String(catalog.length) },- { label: "Uninstalled", value: String(disabled.length) },- ],- context: `App store, ${installedCount} installed, ${disabled.length} uninstalled`,- suggestions: ["Suggest an app", "What's installed?"],- },- [installedCount, catalog.length, disabled.length],- );-- return (- <div ref={paneRef} className="flex h-full">- {!compact && <StoreSidebar value={filter} onChange={setFilter} />}-- <AppFrame- className="min-w-0 flex-1"- safeArea={false}- header={- <header className="space-y-3 p-4">- <div className="flex items-center gap-2">- {!mobile && <Store className="size-4 text-primary" />}- {!mobile && <h2 className="text-sm font-semibold">App Store</h2>}- <span className="ml-auto text-[11px] text-muted-foreground">- {count} {count === 1 ? noun : `${noun}s`}- </span>- </div>- <div className="relative">- <Search className="pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />- <Input- value={query}- onChange={(e) => setQuery(e.target.value)}- placeholder={isSystem ? `Search ${noun}s` : "Search apps"}- className={ios ? "h-9 border-0 bg-[var(--fill)] pl-8" : "h-9 pl-8"}- />- </div>- {compact && <StoreFilterChips value={filter} onChange={setFilter} />}- </header>- }- >- <ScrollArea className="h-full">- <div ref={storeZone} className="p-4 [padding-bottom:calc(1rem+var(--sai-bottom))]">- {isSystem ? (- <>- <p className="mb-3 text-xs text-muted-foreground">- Optional {filter === "Features" ? "system features" : "apps"} — install to add- them, uninstall to remove. Uninstalled items vanish from the dock, Launchpad,- and Spotlight.- </p>- <div className="grid grid-cols-1 gap-3 @md:grid-cols-2 @4xl:grid-cols-3 @7xl:grid-cols-4">- {systemList.map((e) => (- <SystemCard- key={e.id}- entry={e}- installed={!off.has(e.id)}- onToggle={install.toggleSystem}- />- ))}- </div>- </>- ) : (- <>- {filter === "Featured" && featured && !query && (- <FeaturedCard- app={featured}- onToggle={install.toggle}- />- )}-- {list.length === 0 ? (- <p className="py-12 text-center text-xs text-muted-foreground">- No apps match “{query}”.- </p>- ) : (- <div className="grid grid-cols-1 gap-3 @md:grid-cols-2 @4xl:grid-cols-3 @7xl:grid-cols-4">- {list.map((app) => (- <StoreAppCard- key={app.appId}- app={app}- onToggle={install.toggle}- />- ))}- </div>- )}- </>- )}- </div>- </ScrollArea>- </AppFrame>-- <UninstallConfirm- open={install.pendingApp !== null}- title={install.pendingApp?.title ?? null}- onCancel={install.cancelApp}- onConfirm={install.confirmUninstallApp}- />- <UninstallConfirm- open={install.pendingSystem !== null}- title={install.pendingSystem?.title ?? null}- onCancel={install.cancelSystem}- onConfirm={install.confirmUninstallSystem}- />- </div>- );+ const [tab, setTab] = useState("apps"), id = useId();+ return <div className="flex h-full min-h-0 min-w-0 flex-col">+ <div className="shrink-0 border-b px-3 py-2"><CategoryTabs id={id} label="Store categories" items={[{ id: "apps", label: "Apps" }, { id: "mcp", label: "MCP" }, { id: "skills", label: "Skills" }]} value={tab} onChange={setTab} /></div>+ <section id={`${id}-panel`} role="tabpanel" aria-labelledby={`${id}-${tab}`} className="min-h-0 flex-1">+ {tab === "apps" ? <AppsPanel /> : <ScrollArea className="h-full"><div className="@container p-4">{tab === "mcp" ? <McpStorePanel /> : <SkillStorePanel />}</div></ScrollArea>}+ </section>+ </div>;}diff --git a/frontend/slices/app-store/components/apps-panel.tsx b/frontend/slices/app-store/components/apps-panel.tsxnew file mode 100644index 00000000..f5eaa1b8--- /dev/null+++ b/frontend/slices/app-store/components/apps-panel.tsx@@ -0,0 +1,193 @@+"use client";++import { useMemo, useState } from "react";+import { Search, Sparkles, Store } from "lucide-react";+import { ScrollArea } from "@/components/ui/scroll-area";+import { Input } from "@/components/ui/input";+import { AppFrame, useContainer, useActiveShell, useContextZone, openWindow } from "@/features/appshell";+import type { MenuItem } from "@/features/appshell";+import { UninstallConfirm } from "./uninstall-confirm";+import { usePublishInspector } from "../lib/host";+import {+ StoreFilterChips,+ StoreSidebar,+ type StoreFilter,+} from "./store-sidebar";+import { FeaturedCard } from "./featured-card";+import { StoreAppCard } from "./store-app-card";+import { SystemCard } from "./system-card";+import { FEATURED_ID, mergeCatalog } from "../lib/store-catalog";+import { SYSTEM_CATALOG } from "../lib/system-catalog";+import { useApps } from "../lib/apps-store";+import { useDisabledIds } from "../lib/enabled-store";+import { useStoreInstall } from "../lib/use-store-install";++// Default export so os-shell can lazy-load it as a window app. Installing an app+// flips its localStorage row (useInstalledApps surfaces it in the dock/launchpad).+// The "Apps"/"Features" sections instead toggle the built-in apps + shell features+// on/off (enabled-store) — os-root filters the manifest by the disabled set.+export default function AppStore() {+ const [query, setQuery] = useState("");+ const [filter, setFilter] = useState<StoreFilter>("Featured");+ // Store-level zone: a right-click anywhere in the grid gets this, and a+ // right-click ON a card merges the card's items ABOVE it (nested).+ const storeZone = useContextZone((): MenuItem[] => [+ { label: "Suggest an app…", icon: Sparkles, onClick: () => openWindow("assistant", "Alfa") },+ ]);+ // Pane-width bucket (JS, not CSS): the sidebar/chip swap must share ONE+ // measurement, and the chips live inside the AppFrame's own @container.+ const [paneRef, pane] = useContainer<HTMLDivElement>();+ const compact = pane === "xs" || pane === "sm";+ // Mobile shell navigation already owns the App Store title on both mobile OSes,+ // so the in-content title is desktop-only; iOS still gets its systemFill search.+ const activeShell = useActiveShell();+ const ios = activeShell.id === "ios";+ const mobile = activeShell.surface === "mobile";++ const rows = useApps();+ const disabled = useDisabledIds();+ const off = useMemo(() => new Set(disabled), [disabled]);+ const isSystem = filter === "Apps" || filter === "Features";++ // Merge curated catalog with live install state from localStorage.+ const catalog = useMemo(() => mergeCatalog(rows), [rows]);+ const featured = catalog.find((a) => a.appId === FEATURED_ID) ?? catalog[0];++ // Install state machine + destructive confirm gates (uninstall = needs prompt).+ const install = useStoreInstall(off);++ const list = useMemo(() => {+ const q = query.trim().toLowerCase();+ return catalog.filter((a) => {+ if (filter !== "Featured" && a.category !== filter) return false;+ if (!q) return true;+ return (+ a.title.toLowerCase().includes(q) || a.desc.toLowerCase().includes(q)+ );+ });+ }, [catalog, query, filter]);++ const systemList = useMemo(() => {+ const q = query.trim().toLowerCase();+ const kind = filter === "Features" ? "feature" : "app";+ return SYSTEM_CATALOG.filter(+ (e) =>+ e.kind === kind &&+ (!q || e.title.toLowerCase().includes(q) || e.desc.toLowerCase().includes(q)),+ );+ }, [filter, query]);++ const count = isSystem ? systemList.length : list.length;+ const noun = isSystem ? (filter === "Features" ? "feature" : "app") : "app";+ const installedCount = catalog.filter((a) => a.installed).length;++ // Surface store state to the shell AI Inspector.+ usePublishInspector(+ "app-store",+ {+ subject: "App Store",+ props: [+ { label: "Installed", value: String(installedCount) },+ { label: "Catalog", value: String(catalog.length) },+ { label: "Uninstalled", value: String(disabled.length) },+ ],+ context: `App store, ${installedCount} installed, ${disabled.length} uninstalled`,+ suggestions: ["Suggest an app", "What's installed?"],+ },+ [installedCount, catalog.length, disabled.length],+ );++ return (+ <div ref={paneRef} className="flex h-full">+ {!compact && <StoreSidebar value={filter} onChange={setFilter} />}++ <AppFrame+ className="min-w-0 flex-1"+ safeArea={false}+ header={+ <header className="space-y-3 p-4">+ <div className="flex items-center gap-2">+ {!mobile && <Store className="size-4 text-primary" />}+ {!mobile && <h2 className="text-sm font-semibold">App Store</h2>}+ <span className="ml-auto text-[11px] text-muted-foreground">+ {count} {count === 1 ? noun : `${noun}s`}+ </span>+ </div>+ <div className="relative">+ <Search className="pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />+ <Input+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ placeholder={isSystem ? `Search ${noun}s` : "Search apps"}+ className={ios ? "h-9 border-0 bg-[var(--fill)] pl-8" : "h-9 pl-8"}+ />+ </div>+ {compact && <StoreFilterChips value={filter} onChange={setFilter} />}+ </header>+ }+ >+ <ScrollArea className="h-full">+ <div ref={storeZone} className="p-4 [padding-bottom:calc(1rem+var(--sai-bottom))]">+ {isSystem ? (+ <>+ <p className="mb-3 text-xs text-muted-foreground">+ Optional {filter === "Features" ? "system features" : "apps"} — install to add+ them, uninstall to remove. Uninstalled items vanish from the dock, Launchpad,+ and Spotlight.+ </p>+ <div className="grid grid-cols-1 gap-3 @md:grid-cols-2 @4xl:grid-cols-3 @7xl:grid-cols-4">+ {systemList.map((e) => (+ <SystemCard+ key={e.id}+ entry={e}+ installed={!off.has(e.id)}+ onToggle={install.toggleSystem}+ />+ ))}+ </div>+ </>+ ) : (+ <>+ {filter === "Featured" && featured && !query && (+ <FeaturedCard+ app={featured}+ onToggle={install.toggle}+ />+ )}++ {list.length === 0 ? (+ <p className="py-12 text-center text-xs text-muted-foreground">+ No apps match “{query}”.+ </p>+ ) : (+ <div className="grid grid-cols-1 gap-3 @md:grid-cols-2 @4xl:grid-cols-3 @7xl:grid-cols-4">+ {list.map((app) => (+ <StoreAppCard+ key={app.appId}+ app={app}+ onToggle={install.toggle}+ />+ ))}+ </div>+ )}+ </>+ )}+ </div>+ </ScrollArea>+ </AppFrame>++ <UninstallConfirm+ open={install.pendingApp !== null}+ title={install.pendingApp?.title ?? null}+ onCancel={install.cancelApp}+ onConfirm={install.confirmUninstallApp}+ />+ <UninstallConfirm+ open={install.pendingSystem !== null}+ title={install.pendingSystem?.title ?? null}+ onCancel={install.cancelSystem}+ onConfirm={install.confirmUninstallSystem}+ />+ </div>+ );+}diff --git a/frontend/slices/extensions/access.tsx b/frontend/slices/extensions/access.tsxnew file mode 100644index 00000000..1dfa0245--- /dev/null+++ b/frontend/slices/extensions/access.tsx@@ -0,0 +1,10 @@+"use client";+import type { ReactNode } from "react";+import { useSession } from "@/features/auth";+import { IS_DEMO } from "@/lib/demo";+export function ExtensionAccess({ children }: { children: ReactNode }) {+ const { status, role } = useSession();+ if (status === "loading") return <p role="status">Checking owner access…</p>;+ if (IS_DEMO || status !== "in" || role !== "owner") return <p className="p-4 text-sm text-muted-foreground">{IS_DEMO ? "Host installations are disabled in this demo." : "Sign in with an Owner device to manage MCPs and skills on this VPS."}</p>;+ return children;+}diff --git a/frontend/slices/extensions/category-tabs.tsx b/frontend/slices/extensions/category-tabs.tsxnew file mode 100644index 00000000..5941ffb8--- /dev/null+++ b/frontend/slices/extensions/category-tabs.tsx@@ -0,0 +1,9 @@+"use client";+import { Button } from "@/components/ui/button";+export function CategoryTabs({ id, label, items, value, onChange }: { id: string; label: string; items: readonly { id: string; label: string }[]; value: string; onChange: (value: string) => void }) {+ return <div role="tablist" aria-label={label} className="flex flex-wrap gap-1 rounded-lg bg-secondary p-1">{items.map((item, index) => <Button key={item.id} id={`${id}-${item.id}`} role="tab" aria-selected={item.id === value} aria-controls={`${id}-panel`} tabIndex={item.id === value ? 0 : -1}+ type="button" size="sm" variant={item.id === value ? "default" : "ghost"} onClick={() => onChange(item.id)} onKeyDown={event => {+ const next = event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : event.key === "ArrowRight" ? (index + 1) % items.length : event.key === "ArrowLeft" ? (index + items.length - 1) % items.length : -1;+ if (next < 0) return; event.preventDefault(); onChange(items[next].id); document.getElementById(`${id}-${items[next].id}`)?.focus();+ }}>{item.label}</Button>)}</div>;+}diff --git a/frontend/slices/extensions/index.ts b/frontend/slices/extensions/index.tsnew file mode 100644index 00000000..162568af--- /dev/null+++ b/frontend/slices/extensions/index.ts@@ -0,0 +1,4 @@+export { McpStorePanel } from "./mcp-panel";+export { SkillStorePanel } from "./skill-panel";+export { ExtensionTabs } from "./tabs";+export { CategoryTabs } from "./category-tabs";diff --git a/frontend/slices/extensions/mcp-builtin.tsx b/frontend/slices/extensions/mcp-builtin.tsxnew file mode 100644index 00000000..ae6c1672--- /dev/null+++ b/frontend/slices/extensions/mcp-builtin.tsx@@ -0,0 +1,26 @@+"use client";+import { useState } from "react";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import type { PluginManifest } from "@/lib/plugins/manifest";+import type { McpMutation, McpSnapshot } from "./use-mcp-installations";+export function BuiltinMcp({ plugin, snapshot, busy, install }: {+ plugin: PluginManifest; snapshot: McpSnapshot; busy: boolean; install: (input: McpMutation) => Promise<boolean>;+}) {+ const [user, setUser] = useState(""), [connection, setConnection] = useState("");+ const installed = snapshot.servers.some(server => server.plugin === plugin.id);+ const collision = snapshot.servers.some(server => server.name === plugin.id && server.plugin !== plugin.id);+ return <article className="min-w-0 space-y-3 rounded-lg border p-3">+ <div className="flex flex-wrap items-center justify-between gap-2"><h3 className="text-sm font-semibold">{plugin.metadata.name}</h3><span className="text-xs text-muted-foreground">{installed ? "Installed" : "Available"} · Catalog {plugin.version}</span></div>+ <p className="text-sm text-muted-foreground">{plugin.metadata.description}</p>+ <p className="text-xs text-muted-foreground">{plugin.id === "si-coder" ? "Uses MSO's managed SC runtime. Shared credentials stay in Integrations." : "Remote MCP connection; this does not download or self-host the Batonly service."}</p>+ {!installed && plugin.id === "batonly" && <div className="grid gap-2">+ <Input aria-label="Batonly connection owner" placeholder="Connection owner" value={user} disabled={busy} onChange={event => setUser(event.target.value)} />+ <Input aria-label="Batonly named MCP connection" placeholder="Named MCP connection, not a token" value={connection} disabled={busy} onChange={event => setConnection(event.target.value)} />+ </div>}+ {!installed && <Button size="sm" disabled={busy || collision || (plugin.id === "batonly" && (!user || !connection))} onClick={() => {+ if (plugin.id !== "si-coder" && plugin.id !== "batonly") return;+ if (window.confirm(`Install ${plugin.metadata.name} on ${snapshot.project}? No other target is changed.`)) void install({ server: plugin.id, plugin: plugin.id, ...(plugin.id === "batonly" ? { user, connection } : {}) });+ }}>{collision ? "Alias already in use" : "Install"}</Button>}+ </article>;+}diff --git a/frontend/slices/extensions/mcp-installed.tsx b/frontend/slices/extensions/mcp-installed.tsxnew file mode 100644index 00000000..31141e2f--- /dev/null+++ b/frontend/slices/extensions/mcp-installed.tsx@@ -0,0 +1,24 @@+"use client";+import { useState } from "react";+import { Button } from "@/components/ui/button";+import type { PublicProjectMcpServer } from "@/lib/contracts/project-mcp";+export function InstalledMcp({ target, server, busy, remove }: { target: string; server: PublicProjectMcpServer; busy: boolean; remove: () => void }) {+ const [checking, setChecking] = useState(false), [error, setError] = useState("");+ const [tools, setTools] = useState<{ name: string }[] | null>(null), [cursor, setCursor] = useState<string | undefined>();+ async function inspect(next?: string) {+ setChecking(true); setError("");+ try {+ const response = await fetch("/api/v1/project-mcp", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action: "tools", project: target, server: server.name, limit: 20, refresh: !next, ...(next ? { cursor: next } : {}) }) });+ const result = await response.json(); if (!response.ok) throw new Error(result.error || "Tool discovery failed");+ setTools(previous => next ? [...(previous ?? []), ...result.tools] : result.tools); setCursor(result.nextCursor);+ } catch (cause) { setError(cause instanceof Error ? cause.message : "Tool discovery failed"); }+ finally { setChecking(false); }+ }+ return <article className="min-w-0 space-y-3 rounded-lg border p-3">+ <div className="flex flex-wrap items-center gap-3"><div className="min-w-0 flex-1"><h3 className="break-all text-sm font-medium">{server.name}</h3><p className="text-xs text-muted-foreground">{server.transport} · {server.auth} · {tools ? "Tool discovery verified" : "Installed, not yet health-verified"}</p></div>+ <Button size="sm" variant="secondary" disabled={busy || checking} onClick={() => void inspect()}>Check tools</Button>+ <Button size="sm" variant="ghost" disabled={busy || checking} onClick={remove}>Uninstall</Button></div>+ {checking && <p role="status" className="text-xs">Discovering live tool schemas…</p>}{error && <p role="alert" className="break-words text-xs text-destructive">{error}</p>}+ {tools && <div className="space-y-2"><p className="text-xs text-muted-foreground">{tools.length} tools loaded{cursor ? "; more available" : ""}. Discovery does not prove every remote action.</p><div className="flex flex-wrap gap-1">{tools.map(tool => <code key={tool.name} className="max-w-full break-all rounded bg-muted px-1 text-xs">{tool.name}</code>)}</div>{cursor && <Button size="sm" variant="secondary" disabled={checking || tools.length >= 200} onClick={() => void inspect(cursor)}>Load more tools</Button>}</div>}+ </article>;+}diff --git a/frontend/slices/extensions/mcp-panel.tsx b/frontend/slices/extensions/mcp-panel.tsxnew file mode 100644index 00000000..6ac3f9bb--- /dev/null+++ b/frontend/slices/extensions/mcp-panel.tsx@@ -0,0 +1,43 @@+"use client";+import { useState } from "react";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { openWindow } from "@/features/appshell";+import { BUILT_IN_PLUGINS } from "@/lib/plugins/manifest";+import { ExtensionAccess } from "./access";+import { useMcpInstallations } from "./use-mcp-installations";+import { InstalledMcp } from "./mcp-installed";+import { BuiltinMcp } from "./mcp-builtin";+import { RemoteMcpForm } from "./mcp-remote-form";+export function McpStorePanel() { return <ExtensionAccess><OwnerMcpPanel /></ExtensionAccess>; }+function OwnerMcpPanel() {+ const [target, setTarget] = useState("@host"), [draft, setDraft] = useState("");+ const [query, setQuery] = useState("");+ const { snapshot, busy, error, reload, mutate } = useMcpInstallations(target);+ const q = query.trim().toLowerCase();+ return <div className="min-w-0 space-y-4">+ <section className="space-y-3 rounded-lg border p-3">+ <h2 className="text-sm font-semibold">MCP on this VPS</h2>+ <p className="text-sm text-muted-foreground">Choose this MSO host or one exact project. Host installs are not inherited by projects; removing a connection leaves provider data and credentials untouched.</p>+ <div className="flex flex-wrap items-center gap-2">+ <Button size="sm" variant={target === "@host" ? "default" : "secondary"} disabled={busy} onClick={() => setTarget("@host")}>This MSO host</Button>+ <Input className="min-w-0 flex-1 basis-40" aria-label="Exact MCP target project" placeholder="Exact project name, ID or path" value={draft} disabled={busy} onChange={event => setDraft(event.target.value)} />+ <Button size="sm" variant="secondary" disabled={busy || !draft.trim()} onClick={() => setTarget(draft.trim())}>Use project</Button>+ <Button size="sm" variant="ghost" disabled={busy} onClick={() => void reload()}>Refresh</Button>+ </div>+ <p className="break-all text-xs font-medium">Target: {target === "@host" ? "This MSO host" : target}</p>+ <Input aria-label="Search MCPs" placeholder="Search MCPs" value={query} onChange={event => setQuery(event.target.value)} />+ </section>+ {error && <p role="alert" className="break-words text-sm text-destructive">{error}</p>}+ {busy && <p role="status" className="text-sm text-muted-foreground">Updating host installation state…</p>}+ {snapshot && <>+ <section className="space-y-2"><h3 className="text-sm font-semibold">Installed on this target ({snapshot.servers.length})</h3>+ {snapshot.servers.length === 0 && <p className="text-sm text-muted-foreground">No MCP installed on this target.</p>}+ {snapshot.servers.filter(server => `${server.name} ${server.plugin ?? ""}`.toLowerCase().includes(q)).map(server => <InstalledMcp key={`${target}:${snapshot.revision}:${server.name}`} target={target} server={server} busy={busy} remove={() => { if (window.confirm(`Uninstall ${server.name} only from ${target}? Shared runtime, credentials and remote service data will not be deleted.`)) void mutate("delete", { server: server.name }); }} />)}+ </section>+ <section className="space-y-2"><h3 className="text-sm font-semibold">Available MCPs</h3><div className="grid gap-3 @lg:grid-cols-2">{BUILT_IN_PLUGINS.filter(plugin => `${plugin.metadata.name} ${plugin.metadata.description}`.toLowerCase().includes(q)).map(plugin => <BuiltinMcp key={`${target}:${plugin.id}`} plugin={plugin} snapshot={snapshot} busy={busy} install={input => mutate("upsert", input)} />)}</div></section>+ <RemoteMcpForm key={target} busy={busy} aliases={snapshot.servers.map(server => server.name)} install={input => mutate("upsert", input)} />+ </>}+ <div className="space-y-2 rounded-lg bg-muted/50 p-3"><p className="text-sm font-medium">ChatGPT → MSO → installed MCP</p><p className="text-xs text-muted-foreground">Inspect aliases with project_mcp_manage, discover live schemas with project_mcp_tools, then execute with project_mcp_call. Use project=@host for host installs. Permissions, revocation and private connections are checked on the server.</p><Button size="sm" variant="secondary" onClick={() => openWindow("integrations", "Integrations")}>Manage credentials in Integrations</Button></div>+ </div>;+}diff --git a/frontend/slices/extensions/mcp-remote-form.tsx b/frontend/slices/extensions/mcp-remote-form.tsxnew file mode 100644index 00000000..49f966f9--- /dev/null+++ b/frontend/slices/extensions/mcp-remote-form.tsx@@ -0,0 +1,37 @@+"use client";+import { useEffect, useState } from "react";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { validatePluginManifest, type PluginManifest } from "@/lib/plugins/manifest";+import type { McpMutation } from "./use-mcp-installations";+export function RemoteMcpForm({ busy, aliases, install }: { busy: boolean; aliases: string[]; install: (input: McpMutation) => Promise<boolean> }) {+ const [server, setServer] = useState(""), [url, setUrl] = useState("");+ const [user, setUser] = useState(""), [connection, setConnection] = useState("");+ const [legacy, setLegacy] = useState<PluginManifest[]>([]);+ useEffect(() => {+ const timer = window.setTimeout(() => {+ try {+ const entries: unknown = JSON.parse(localStorage.getItem("mso:custom-plugin-registry:v1") || "[]");+ if (Array.isArray(entries)) setLegacy(entries.flatMap(value => { const result = validatePluginManifest(value); return result.ok ? [result.manifest] : []; }));+ } catch { /* Browser-only declarations are never automatically installed. */ }+ }, 0);+ return () => window.clearTimeout(timer);+ }, []);+ return <section className="space-y-3 rounded-lg border p-3">+ <h3 className="text-sm font-semibold">Add an external MCP</h3>+ <p className="text-xs text-muted-foreground">Writes the selected target’s MCP manifest on this VPS. HTTPS endpoints only; use Integrations for OAuth or secrets. Existing local stdio MCPs also appear above.</p>+ {legacy.length > 0 && <div className="space-y-2"><p className="text-xs text-muted-foreground">Previous browser-only declarations remain saved. Review an endpoint before installing:</p>{legacy.map(item => {+ const remote = item.mcp?.find(mcp => mcp.transport === "https");+ return <Button key={item.id} size="sm" variant="secondary" disabled={!remote || busy} onClick={() => { if (remote?.transport === "https") { setServer(item.id); setUrl(remote.endpoint); } }}>{item.metadata.name}{!remote ? " — manual runtime review required" : " — review"}</Button>;+ })}</div>}+ <div className="grid gap-2 sm:grid-cols-2">+ <Input aria-label="MCP alias" placeholder="MCP alias" value={server} disabled={busy} onChange={event => setServer(event.target.value)} />+ <Input aria-label="MCP HTTPS endpoint" placeholder="https://service.example/mcp" value={url} disabled={busy} onChange={event => setUrl(event.target.value)} />+ <Input aria-label="MCP connection owner" placeholder="Connection owner (optional)" value={user} disabled={busy} onChange={event => setUser(event.target.value)} />+ <Input aria-label="MCP named connection" placeholder="Named connection (optional)" value={connection} disabled={busy} onChange={event => setConnection(event.target.value)} />+ </div>+ <Button size="sm" disabled={busy || !server.trim() || !url.trim() || aliases.includes(server.trim()) || Boolean(user) !== Boolean(connection)} onClick={() => {+ if (window.confirm("Install this remote MCP connection on the selected target? Its tools will be callable only with the existing MSO and provider permissions.")) void install({ server: server.trim(), url: url.trim(), ...(user && connection ? { user: user.trim(), connection: connection.trim() } : {}) });+ }}>{aliases.includes(server.trim()) ? "Choose an unused alias" : "Install remote MCP"}</Button>+ </section>;+}diff --git a/frontend/slices/extensions/skill-panel.tsx b/frontend/slices/extensions/skill-panel.tsxnew file mode 100644index 00000000..d4cee67c--- /dev/null+++ b/frontend/slices/extensions/skill-panel.tsx@@ -0,0 +1,47 @@+"use client";+import { useCallback, useEffect, useState } from "react";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import type { SkillMarketSnapshot, SkillMarketRow } from "@/lib/contracts/skill-market";+import { ExtensionAccess } from "./access";+type ExistingSkill = { id: string; name: string; source: string; trust: string; description: string };+export function SkillStorePanel() { return <ExtensionAccess><OwnerSkillPanel /></ExtensionAccess>; }+function OwnerSkillPanel() {+ const [market, setMarket] = useState<SkillMarketSnapshot | null>(null);+ const [existing, setExisting] = useState<ExistingSkill[]>([]), [partial, setPartial] = useState(false);+ const [query, setQuery] = useState(""), [busy, setBusy] = useState(false), [error, setError] = useState("");+ const reload = useCallback(async (signal?: AbortSignal) => {+ setBusy(true); setError("");+ try {+ const response = await fetch("/api/v1/skill-market", { cache: "no-store", signal });+ const data = await response.json(); if (!response.ok) throw new Error(data.error || "Skill market failed");+ setMarket(data);+ const installed = await fetch("/api/skills", { cache: "no-store", signal });+ const skills = await installed.json(); if (!installed.ok) throw new Error(skills.error || "Skill discovery failed");+ setExisting(skills.skills ?? []); setPartial(Boolean(skills.scan?.truncated));+ } catch (cause) { if (!signal?.aborted) setError(cause instanceof Error ? cause.message : "Skill catalog failed"); }+ finally { if (!signal?.aborted) setBusy(false); }+ }, []);+ useEffect(() => {+ const controller = new AbortController(); const timer = window.setTimeout(() => { void reload(controller.signal); }, 0);+ const changed = () => { void reload(controller.signal); }; window.addEventListener("mso:extensions-changed", changed);+ return () => { window.clearTimeout(timer); controller.abort(); window.removeEventListener("mso:extensions-changed", changed); };+ }, [reload]);+ async function change(action: "install" | "remove", row: SkillMarketRow) {+ if (!window.confirm(`${action === "remove" ? "Remove" : "Install"} ${row.title} ${action === "remove" ? "from" : "on"} this VPS? Only this managed skill directory will change.`)) return;+ setBusy(true); setError("");+ try {+ const response = await fetch("/api/v1/skill-market", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action, id: row.id, revision: row.revision }) });+ const data = await response.json(); if (!response.ok) throw new Error(data.error || "Skill operation failed");+ setMarket(data); window.dispatchEvent(new Event("mso:extensions-changed"));+ } catch (cause) { setError(cause instanceof Error ? cause.message : "Skill operation failed"); }+ finally { setBusy(false); }+ }+ const q = query.trim().toLowerCase();+ return <div className="min-w-0 space-y-4">+ <div className="space-y-2"><h2 className="text-sm font-semibold">Skills on this VPS</h2><p className="text-sm text-muted-foreground">Install copies a reviewed, checksum-verified skill into MSO’s local skill directory. Uninstall removes only unchanged, managed files. A skill never grants tool permissions.</p><div className="flex gap-2"><Input aria-label="Search skills" placeholder="Search skills" value={query} onChange={event => setQuery(event.target.value)} /><Button variant="secondary" disabled={busy} onClick={() => void reload()}>Refresh</Button></div></div>+ {error && <p role="alert" className="break-words text-sm text-destructive">{error}</p>}{busy && <p role="status" className="text-sm">Loading skill state…</p>}+ {market && <><p className="break-all text-xs text-muted-foreground">Install directory: {market.root}</p><div className="grid gap-3 @lg:grid-cols-2">{market.skills.filter(row => `${row.title} ${row.description}`.toLowerCase().includes(q)).map(row => <article key={row.id} className="space-y-3 rounded-lg border p-3"><div className="flex flex-wrap justify-between gap-2"><h3 className="text-sm font-semibold">{row.title}</h3><span className="text-xs text-muted-foreground">{row.state} · {row.version}</span></div><p className="text-sm text-muted-foreground">{row.description}</p><p className="text-xs text-muted-foreground">{row.source} · {row.security}</p><div className="flex flex-wrap gap-2">{row.canInstall && <Button size="sm" disabled={busy} onClick={() => void change("install", row)}>{row.state === "update-available" ? "Update" : "Install"}</Button>}{row.canRemove && <Button size="sm" variant="secondary" disabled={busy} onClick={() => void change("remove", row)}>Uninstall</Button>}{!row.canInstall && !row.canRemove && <span className="text-xs text-muted-foreground">Local changes or unmanaged files require manual review.</span>}</div></article>)}</div></>}+ <section className="space-y-2"><h3 className="text-sm font-semibold">Discovered existing skills ({existing.length})</h3><p className="text-xs text-muted-foreground">Official, project and manually installed skills remain managed by their source; Store will not delete them.</p>{partial && <p className="text-xs text-muted-foreground">Discovery is bounded; this is a partial list.</p>}{existing.filter(skill => `${skill.name} ${skill.description}`.toLowerCase().includes(q)).map(skill => <div key={skill.id} className="rounded-lg border p-3"><p className="break-all text-sm font-medium">{skill.name}</p><p className="text-xs text-muted-foreground">{skill.source} · {skill.trust}</p></div>)}</section>+ </div>;+}diff --git a/frontend/slices/extensions/tabs.tsx b/frontend/slices/extensions/tabs.tsxnew file mode 100644index 00000000..01c90856--- /dev/null+++ b/frontend/slices/extensions/tabs.tsx@@ -0,0 +1,12 @@+"use client";+import { useId, useState } from "react";+import { CategoryTabs } from "./category-tabs";+import { McpStorePanel } from "./mcp-panel";+import { SkillStorePanel } from "./skill-panel";+export function ExtensionTabs() {+ const [tab, setTab] = useState("mcp"), id = useId();+ return <div className="min-w-0 space-y-4">+ <CategoryTabs id={id} label="Installed extensions" items={[{ id: "mcp", label: "MCP" }, { id: "skills", label: "Skills" }]} value={tab} onChange={setTab} />+ <section id={`${id}-panel`} role="tabpanel" aria-labelledby={`${id}-${tab}`}>{tab === "mcp" ? <McpStorePanel /> : <SkillStorePanel />}</section>+ </div>;+}diff --git a/frontend/slices/extensions/use-mcp-installations.ts b/frontend/slices/extensions/use-mcp-installations.tsnew file mode 100644index 00000000..73ac0459--- /dev/null+++ b/frontend/slices/extensions/use-mcp-installations.ts@@ -0,0 +1,41 @@+"use client";+import { useCallback, useEffect, useRef, useState } from "react";+import type { PublicProjectMcpServer } from "@/lib/contracts/project-mcp";+export type McpSnapshot = { project: string; revision: string; installationScope: string; servers: PublicProjectMcpServer[] };+export type McpMutation = { server: string; plugin?: "si-coder" | "batonly"; url?: string; user?: string; connection?: string };+async function request(args: object, signal?: AbortSignal) {+ const response = await fetch("/api/v1/project-mcp", { method: "POST", credentials: "same-origin", cache: "no-store", signal,+ headers: { "Content-Type": "application/json" }, body: JSON.stringify(args) });+ const data = await response.json();+ if (!response.ok) throw new Error(data.error || "MCP operation failed");+ return data;+}+export function useMcpInstallations(project: string) {+ const [snapshot, setSnapshot] = useState<McpSnapshot | null>(null);+ const [busy, setBusy] = useState(false), [error, setError] = useState("");+ const generation = useRef(0), source = useRef(Symbol("mcp-installations"));+ const reload = useCallback(async (signal?: AbortSignal) => {+ const epoch = ++generation.current;+ setBusy(true); setError("");+ try { const data = await request({ project, action: "inspect" }, signal); if (!signal?.aborted && epoch === generation.current) setSnapshot(data); }+ catch (cause) { if (!signal?.aborted && epoch === generation.current) setError(cause instanceof Error ? cause.message : "MCP inspection failed"); }+ finally { if (epoch === generation.current && !signal?.aborted) setBusy(false); }+ }, [project]);+ useEffect(() => {+ const controller = new AbortController();+ const timer = window.setTimeout(() => { setSnapshot(null); void reload(controller.signal); }, 0);+ const changed = (event: Event) => { if ((event as CustomEvent).detail?.source !== source.current) void reload(controller.signal); };+ window.addEventListener("mso:extensions-changed", changed);+ return () => { window.clearTimeout(timer); controller.abort(); window.removeEventListener("mso:extensions-changed", changed); };+ }, [reload]);+ async function mutate(action: "upsert" | "delete", input: McpMutation) {+ if (!snapshot || busy) return false;+ setBusy(true); setError("");+ try {+ await request({ project, action, revision: snapshot.revision, ...input });+ await reload(); window.dispatchEvent(new CustomEvent("mso:extensions-changed", { detail: { source: source.current } })); return true;+ } catch (cause) { setError(cause instanceof Error ? cause.message : "MCP operation failed"); return false; }+ finally { setBusy(false); }+ }+ return { snapshot, busy, error, reload, mutate };+}diff --git a/frontend/slices/os-settings/components/mcp-direction-tabs.tsx b/frontend/slices/os-settings/components/mcp-direction-tabs.tsxindex 13ecceb9..f2dfc91b 100644--- a/frontend/slices/os-settings/components/mcp-direction-tabs.tsx+++ b/frontend/slices/os-settings/components/mcp-direction-tabs.tsx@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";import { cn } from "@/lib/utils";export const MCP_TABS = [{ id: "inbound", title: "Access MSO", description: "External clients → MSO" },- { id: "outbound", title: "MSO Access", description: "Connections & per-project plugins" },+ { id: "outbound", title: "MSO to External", description: "Installed MCPs, skills & connections" },{ id: "sessions", title: "Sessions", description: "Activity & handover" },] as const;export type McpTab = (typeof MCP_TABS)[number]["id"];diff --git a/frontend/slices/os-settings/components/mcp-navigation.tsx b/frontend/slices/os-settings/components/mcp-navigation.tsxindex 2b9f6494..7826e3f8 100644--- a/frontend/slices/os-settings/components/mcp-navigation.tsx+++ b/frontend/slices/os-settings/components/mcp-navigation.tsx@@ -10,7 +10,7 @@ export const MCP_PAGES = [{ id: "activity", title: "Recent activity", description: "Review the latest actions requested through MCP.", icon: ListChecks },{ id: "tools", title: "Tools & updates", description: "Check the server tool catalog and your last client refresh reminder.", icon: Wrench },{ id: "connection", title: "Connection details", description: "Server address, reachability checks, tunnels, and manual OAuth settings.", icon: Settings2 },- { id: "registry", title: "Project plugins", description: "Install SI-Coder or Batonly into one exact project. Catalog entries are not installed by default.", icon: Wrench },+ { id: "registry", title: "MCP & Skills", description: "Manage the same VPS-backed extensions as Store. Select this host or one exact project.", icon: Wrench },] as const;export type McpPage = "overview" | (typeof MCP_PAGES)[number]["id"];export type McpDirection = "inbound" | "outbound";diff --git a/frontend/slices/os-settings/components/mcp-plugin-install-contract.test.ts b/frontend/slices/os-settings/components/mcp-plugin-install-contract.test.tsindex d86572eb..0f92a0d3 100644--- a/frontend/slices/os-settings/components/mcp-plugin-install-contract.test.ts+++ b/frontend/slices/os-settings/components/mcp-plugin-install-contract.test.ts@@ -1,22 +1,27 @@import { readFileSync } from "node:fs";import { describe, expect, it } from "vitest";-const registry = readFileSync("frontend/slices/os-settings/components/mcp-plugin-registry.tsx", "utf8");-const runtime = readFileSync("frontend/slices/os-settings/components/mcp-plugin-runtime.tsx", "utf8");-const section = readFileSync("frontend/slices/os-settings/components/mcp-section.tsx", "utf8");-const navigation = readFileSync("frontend/slices/os-settings/components/mcp-navigation.tsx", "utf8");-describe("project plugin installation UX contract", () => {- it("describes built-ins as available catalog entries rather than installed defaults", () => {- expect(registry).toContain("not default project dependencies");- expect(registry).toContain('{isCustom ? "Custom catalog" : "Available"}');- expect(navigation).toContain('title: "Project plugins"');+const read = (file: string) => readFileSync(file, "utf8");+const registry = read("frontend/slices/os-settings/components/mcp-plugin-registry.tsx");+const store = read("frontend/slices/app-store/app.tsx");+const panel = read("frontend/slices/extensions/mcp-panel.tsx");+const hook = read("frontend/slices/extensions/use-mcp-installations.ts");+const builtin = read("frontend/slices/extensions/mcp-builtin.tsx");+const section = read("frontend/slices/os-settings/components/mcp-section.tsx");+describe("shared VPS plugin installation UX", () => {+ it("shares Store and Settings MCP/Skills panels, while retaining the existing Apps panel", () => {+ expect(registry).toContain('ExtensionTabs as McpPluginRegistry');});- it("uses install/uninstall language and sends plugin identity for both reviewed plugins", () => {- expect(runtime).toContain('"Install to project"'); expect(runtime).toContain(">Check installation</Button>"); expect(runtime).toContain('>Uninstall</Button>');- expect(runtime).toContain('{ plugin: "batonly", user, connection }');- expect(runtime).not.toContain('url: endpoint');+ it("has distinct Apps MCP and Skills tabs backed by the shared slice", () => {+ expect(store).toContain('"@/features/extensions"'); expect(registry).toContain('"@/features/extensions"');+ for (const label of ["Apps", "MCP", "Skills"]) expect(store).toContain(`label: "${label}"`);+ expect(store).toContain("<AppsPanel />");});- it("states that host credentials do not install or propagate project plugins", () => {- expect(section).toContain("does not install a plugin into any project");- expect(section).toContain("parent/sibling projects never inherit the binding");+ it("uses real server state and revisions rather than browser installation flags", () => {+ expect(hook).toContain('"/api/v1/project-mcp"'); expect(hook).toContain("snapshot.revision"); expect(hook).not.toContain("localStorage");+ expect(panel).toContain('useState("@host")'); expect(panel).toContain("Host installs are not inherited"); expect(panel).toContain('mutate("delete"');+ });+ it("preserves credential identity and distinguishes remote connection from runtime download", () => {+ expect(builtin).toContain('plugin: plugin.id'); expect(builtin).toContain("user, connection"); expect(builtin).toContain("does not download or self-host");+ expect(section).toContain("does not install a plugin into any project"); expect(section).toContain("parent/sibling projects never inherit the binding");});});diff --git a/frontend/slices/os-settings/components/mcp-plugin-registry.tsx b/frontend/slices/os-settings/components/mcp-plugin-registry.tsxindex f4758e99..78839638 100644--- a/frontend/slices/os-settings/components/mcp-plugin-registry.tsx+++ b/frontend/slices/os-settings/components/mcp-plugin-registry.tsx@@ -1,159 +1,3 @@"use client";--import { Button } from "@/components/ui/button";-import { Input } from "@/components/ui/input";-import { McpPluginRuntime } from "./mcp-plugin-runtime";-import { Textarea } from "@/components/ui/textarea";-import { SettingsBlock } from "@/features/shell-settings";-import {- BUILT_IN_PLUGINS,- PLUGIN_MANIFEST_SCHEMA,- type PluginManifest,- validatePluginManifest,-} from "@/lib/plugins/manifest";-import { useEffect, useState } from "react";--const STORAGE_KEY = "mso:custom-plugin-registry:v1";--function restoreCustomPlugins(raw: string | null) {- if (!raw) return [];- try {- const parsed: unknown = JSON.parse(raw);- if (!Array.isArray(parsed)) return [];- const builtInIds = new Set(BUILT_IN_PLUGINS.map((plugin) => plugin.id));- const custom: PluginManifest[] = [];- const seen = new Set<string>();- for (const candidate of parsed) {- const result = validatePluginManifest(candidate);- if (!result.ok || builtInIds.has(result.manifest.id) || seen.has(result.manifest.id)) continue;- seen.add(result.manifest.id);- custom.push(result.manifest);- }- return custom;- } catch {- return [];- }-}--export function McpPluginRegistry() {- const [custom, setCustom] = useState<PluginManifest[]>([]);- const [project, setProject] = useState("");- const [source, setSource] = useState("");- const [message, setMessage] = useState(- "Custom manifests are validated only. Registration never installs or runs plugin code.",- );-- useEffect(() => {- const restore = window.setTimeout(() => {- setCustom(restoreCustomPlugins(window.localStorage.getItem(STORAGE_KEY)));- }, 0);- return () => window.clearTimeout(restore);- }, []);-- function persist(next: PluginManifest[]) {- window.localStorage.setItem(STORAGE_KEY, JSON.stringify(next));- setCustom(next);- }-- function add() {- try {- const result = validatePluginManifest(JSON.parse(source));- if (!result.ok) {- setMessage(result.error);- return;- }- if ([...BUILT_IN_PLUGINS, ...custom].some((item) => item.id === result.manifest.id)) {- setMessage("A plugin with this id is already registered.");- return;- }- persist([...custom, result.manifest]);- setSource("");- setMessage(`Registered ${result.manifest.metadata.name} in this browser catalog. It is not installed into any project.`);- } catch {- setMessage("Enter valid JSON matching portable plugin manifest v1.");- }- }-- function remove(id: string) {- const plugin = custom.find((item) => item.id === id);- persist(custom.filter((item) => item.id !== id));- setMessage(plugin ? `Removed ${plugin.metadata.name} from this browser registry.` : "Plugin removed.");- }-- const plugins = [...BUILT_IN_PLUGINS, ...custom];-- return (- <div className="space-y-4">- <SettingsBlock className="space-y-3 py-4">- <div className="flex flex-wrap items-center gap-2">- <p className="text-sm font-medium">Project plugins</p>- <span className="rounded-full bg-secondary px-2 py-0.5 text-xs text-muted-foreground">catalog → project install</span>- </div>- <p className="text-sm text-muted-foreground">- SI-Coder and Batonly are available catalog entries, not default project dependencies. Installing one writes only the selected project’s MCP binding. Custom manifests stay browser-local declarations.- </p>- <label className="grid gap-2 text-sm">Exact target project- <Input value={project} onChange={event => setProject(event.target.value)} placeholder="Project name, ID, or absolute path" aria-label="Plugin target project" />- </label>- <p className="text-xs text-muted-foreground">Check the exact target before installing. Fresh projects are empty; no parent, sibling, or catalog entry is inherited as an installed plugin. Installation is still not a health check.</p>- <ul className="grid gap-2 sm:grid-cols-2" aria-label="Registered plugins">- {plugins.map((plugin) => {- const isCustom = custom.some((item) => item.id === plugin.id);- return (- <li key={plugin.id} className="rounded-md border border-border p-3">- <div className="flex items-start justify-between gap-3">- <div className="min-w-0">- <div className="flex flex-wrap items-center gap-2">- <p className="text-sm font-medium">{plugin.metadata.name}</p>- <span className="text-xs text-muted-foreground">Manifest v{plugin.version}</span>- <span className="rounded-full bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">- {isCustom ? "Custom catalog" : "Available"}- </span>- </div>- <p className="mt-1 text-sm text-muted-foreground">{plugin.metadata.description}</p>- <p className="mt-2 text-xs text-muted-foreground">- {plugin.skills?.length ?? 0} skill{(plugin.skills?.length ?? 0) === 1 ? "" : "s"} · {plugin.mcp?.length ?? 0} MCP- {(plugin.mcp?.length ?? 0) === 1 ? "" : "s"}- </p>- </div>- {isCustom ? (- <Button type="button" variant="ghost" size="sm" onClick={() => remove(plugin.id)} aria-label={`Remove ${plugin.metadata.name}`}>- Remove- </Button>- ) : null}- </div>- {!isCustom && <McpPluginRuntime key={`${plugin.id}:${project}`} plugin={plugin.id} project={project} />}- </li>- );- })}- </ul>- </SettingsBlock>-- <SettingsBlock className="space-y-3 py-4">- <div>- <label htmlFor="custom-plugin-manifest" className="text-sm font-medium">- Custom plugin manifest- </label>- <p className="mt-1 text-xs text-muted-foreground">- Valid custom manifests are stored in this browser only. Catalog registration never installs code or adds a project MCP binding.- </p>- </div>- <Textarea- id="custom-plugin-manifest"- value={source}- onChange={(event) => setSource(event.target.value)}- className="min-h-40 font-mono text-xs"- placeholder={`{"$schema":"${PLUGIN_MANIFEST_SCHEMA}","schemaVersion":1,"version":"1.0.0","id":"example-plugin","metadata":{"name":"Example","description":"Safe declaration"}}`}- aria-describedby="custom-plugin-status"- spellCheck={false}- />- <Button type="button" variant="secondary" onClick={add} className="min-h-11">- Validate and register- </Button>- <p id="custom-plugin-status" role="status" className="text-sm text-muted-foreground">- {message}- </p>- </SettingsBlock>- </div>- );-}+// Shared with Store: installation authority lives on the VPS, never localStorage.+export { ExtensionTabs as McpPluginRegistry } from "@/features/extensions";diff --git a/frontend/slices/os-settings/components/mcp-plugin-runtime.tsx b/frontend/slices/os-settings/components/mcp-plugin-runtime.tsxdeleted file mode 100644index 1c1c53d9..00000000--- a/frontend/slices/os-settings/components/mcp-plugin-runtime.tsx+++ /dev/null@@ -1,54 +0,0 @@-"use client";--import { useEffect, useRef, useState } from "react";-import { Button } from "@/components/ui/button";-import { Input } from "@/components/ui/input";-import { openWindow } from "@/features/appshell";--type Receipt = { revision?: string; installed: boolean };--/** Uses the existing owner-only project binding API; registration is not a health check. */-export function McpPluginRuntime({ plugin, project }: { plugin: string; project: string }) {- const [receipt, setReceipt] = useState<Receipt>({ installed: false });- const [busy, setBusy] = useState(false);- const [message, setMessage] = useState("Available in the catalog. Choose a project, then check installation.");- const [user, setUser] = useState("");- const [connection, setConnection] = useState("");- const operation = useRef<AbortController | null>(null);- useEffect(() => () => operation.current?.abort(), []);- async function run(action: "inspect" | "upsert" | "delete") {- operation.current?.abort(); const controller = new AbortController(); operation.current = controller;- setBusy(true);- try {- const args = { project, server: plugin, action, ...(action !== "inspect" ? { revision: receipt.revision } : {}),- ...(action === "upsert" ? plugin === "si-coder" ? { plugin: "si-coder" } : { plugin: "batonly", user, connection } : {}) };- const response = await fetch("/api/v1/project-mcp", { method: "POST", credentials: "same-origin", cache: "no-store", signal: controller.signal,- headers: { "Content-Type": "application/json" }, body: JSON.stringify(args) });- const data = await response.json();- if (!response.ok) throw new Error(data.error || "Plugin operation failed");- const installed = action === "inspect" ? data.servers?.some((server: { name: string; plugin?: string }) => server.name === plugin && server.plugin === plugin) === true : action === "upsert";- setReceipt({ revision: data.revision, installed });- setMessage(installed ? "Installed in this project. Tool discovery/execution are separate verification steps." : "Not installed in this project.");- } catch (error) {- if (!controller.signal.aborted) setMessage(error instanceof Error ? error.message : "Plugin operation failed");- } finally { if (!controller.signal.aborted) setBusy(false); }- }- return <div className="mt-3 space-y-3 border-t pt-3">- <p role="status" className="break-words text-xs font-medium">{busy ? "Checking project binding…" : message}</p>- <p className="text-xs text-muted-foreground">{plugin === "si-coder"- ? "Installing adds only this project's managed SC binding. Standalone SC and other projects remain unchanged. Provider credentials stay in Integrations."- : "Installing adds only this project's Batonly MCP binding. Batonly owns project/task/evidence data; the credential stays in Integrations."}</p>- {plugin === "batonly" && <div className="grid gap-2">- <Input aria-label="Batonly connection owner" placeholder="MSO connection owner" value={user} disabled={busy} onChange={event => setUser(event.target.value)} />- <Input aria-label="Batonly named MCP connection" placeholder="Named MCP connection, not a token" value={connection} disabled={busy} onChange={event => setConnection(event.target.value)} />- </div>}- <div className="flex flex-wrap gap-2">- <Button variant="secondary" size="sm" disabled={busy || !project.trim()} onClick={() => void run("inspect")}>Check installation</Button>- <Button size="sm" disabled={busy || !receipt.revision || (plugin === "batonly" && (!user || !connection))}- onClick={() => { if (!receipt.installed || window.confirm("Update this project's plugin installation?")) void run("upsert"); }}>{receipt.installed ? "Update installation" : "Install to project"}</Button>- {receipt.installed && <Button variant="ghost" size="sm" disabled={busy} onClick={() => { if (window.confirm("Uninstall only from this project? Sibling projects, standalone SC, Batonly data, and credentials remain unchanged.")) void run("delete"); }}>Uninstall</Button>}- <Button variant="ghost" size="sm" onClick={() => openWindow("integrations", "Integrations")}>Open Integrations</Button>- </div>- {receipt.installed && <p className="text-xs text-muted-foreground">Installed ≠ verified. Check this exact project with <code>project_mcp_tools</code> and server <code>{plugin}</code>{plugin === "si-coder" ? ", then call sc.version." : ". A successful catalog read does not prove every remote mutation."}</p>}- </div>;-}diff --git a/frontend/slices/os-settings/components/mcp-section.tsx b/frontend/slices/os-settings/components/mcp-section.tsxindex 3ff595f9..3c22d9b6 100644--- a/frontend/slices/os-settings/components/mcp-section.tsx+++ b/frontend/slices/os-settings/components/mcp-section.tsx@@ -46,7 +46,12 @@ function OwnerMcpSection() {}if (error) return <SettingsBlock className="space-y-3"><p role="alert" className="text-sm">{error}</p><Button variant="secondary" onClick={reload}>Try again</Button><Button asChild variant="ghost"><Link prefetch={false} href="/login?returnTo=%2Fsettings%3Fsection%3Dmcp">Sign in</Link></Button></SettingsBlock>;if (!state) return <SettingsBlock><p role="status" className="text-sm">Loading MCP settings…</p></SettingsBlock>;- if (!state.enabled) return (++ return (+ <div ref={top} tabIndex={-1} data-slot="mcp-page" className="space-y-4 outline-none">+ <McpDirectionTabs value={direction} onChange={selectDirection} />+ <div id="mcp-direction-panel" role="tabpanel" aria-labelledby={`mcp-${direction}-tab`} className="@container min-w-0 space-y-4">+ {!state.enabled && direction === "inbound" ? (<SettingsSection icon={<Plug />} title="MCP is off"><SettingsBlock className="space-y-3 py-4"><p className="text-sm">Enable MCP on this host before connecting an AI app.</p>@@ -54,26 +59,22 @@ function OwnerMcpSection() {<p className="text-sm text-muted-foreground">Apply with <code>mso update --rebuild</code>. Fresh installs allow consent up to exec; lower the ceiling to read/write before connecting clients that do not need remote command execution.</p></SettingsBlock></SettingsSection>- );- return (- <div ref={top} tabIndex={-1} data-slot="mcp-page" className="space-y-4 outline-none">- <McpDirectionTabs value={direction} onChange={selectDirection} />- <div id="mcp-direction-panel" role="tabpanel" aria-labelledby={`mcp-${direction}-tab`} className="@container min-w-0 space-y-4">- {direction === "sessions" ? <McpSessions /> : <>- <p className="text-sm text-muted-foreground">{direction === "inbound" ? "Approve how external clients and agents access this MSO host." : "Choose how MSO reaches external services and projects."}</p>+) : (+ direction === "sessions" ? <McpSessions /> : <>+ <p className="text-sm text-muted-foreground">{direction === "inbound" ? "Approve how external clients and agents access this MSO host." : "Manage installed MCPs and skills through the same VPS-backed Store."}</p>{page === "overview" && direction === "outbound" && <SettingsBlock className="space-y-3 py-4"><div><p className="text-sm font-medium">Service connections</p><p className="text-sm text-muted-foreground">Integrations owns reusable provider/MCP credentials on this MSO host. A saved credential does not install a plugin into any project.</p></div><div><p className="text-sm font-medium">Project plugins</p><p className="text-sm text-muted-foreground">Each project starts with no SI-Coder or Batonly binding. Install them separately per exact project; parent/sibling projects never inherit the binding.</p></div><Button asChild variant="secondary"><Link href="/integrations">Open Integrations</Link></Button></SettingsBlock>}- <McpNavigation active={page} onSelect={navigate} activeCount={state.tokens.filter(token => token.status === "active").length} direction={direction} />+ {direction === "inbound" && <McpNavigation active={page} onSelect={navigate} activeCount={state.tokens.filter(token => token.status === "active").length} direction={direction} />}{page === "connect" && <McpSetupGuide origin={state.origin} maxScope={state.maxScope} />}{page === "connection" && <McpConnectionSection origin={state.origin} />}{page === "access" && <McpTokenSection tokens={state.tokens} onChanged={reload} onConnect={() => navigate("connect")} />}{page === "activity" && <McpActivity />}{page === "tools" && <McpToolsetCard info={state.toolset} />}- {page === "registry" && <McpPluginRegistry />}- </>}+ {(page === "registry" || (direction === "outbound" && page === "overview")) && <McpPluginRegistry />}+ </>)}</div></div>);diff --git a/lib/capabilities/rate-limit.test.ts b/lib/capabilities/rate-limit.test.tsnew file mode 100644index 00000000..08037a32--- /dev/null+++ b/lib/capabilities/rate-limit.test.ts@@ -0,0 +1,26 @@+import { it, expect } from "vitest";+import { randomUUID } from "node:crypto";+import { capabilityRateLimited } from "./rate-limit";+import type { CapabilityTool } from "./tool";+function fixture(): CapabilityTool { return { name: "rate_fixture", scope: "write", description: "test", inputSchema: { type: "object", properties: {} }, run: async () => ({}), limit: { key: randomUUID(), max: 2, windowMs: 60_000, actionLimits: { inspect: { max: 3, windowMs: 60_000 } } } }; }+it("inspection gets its bounded budget without exhausting mutation quota", () => {+ const tool = fixture();+ for (let i = 0; i < 3; i++) expect(capabilityRateLimited(tool, { action: "inspect" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { action: "inspect" }, "owner")).toBe(true);+ expect(capabilityRateLimited(tool, { action: "upsert" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { action: "delete" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { action: "delete" }, "owner")).toBe(true);+});+it("unknown/prototype actions use the base limit and actor isolation stays intact", () => {+ const tool = fixture();+ expect(capabilityRateLimited(tool, { action: "constructor" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { action: "__proto__" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { action: "unknown" }, "owner")).toBe(true);+ expect(capabilityRateLimited(tool, { action: "delete" }, "other-owner")).toBe(false);+});+it("legacy budgets and keyArg semantics remain unchanged", () => {+ const tool = fixture(); tool.limit = { key: randomUUID(), max: 1, windowMs: 60_000, keyArg: "project" };+ expect(capabilityRateLimited(tool, { project: "one" }, "owner")).toBe(false);+ expect(capabilityRateLimited(tool, { project: "one" }, "other-owner")).toBe(true);+ expect(capabilityRateLimited(tool, { project: "two" }, "owner")).toBe(false);+});diff --git a/lib/capabilities/rate-limit.ts b/lib/capabilities/rate-limit.tsindex b8a37dd3..eb260212 100644--- a/lib/capabilities/rate-limit.ts+++ b/lib/capabilities/rate-limit.ts@@ -8,5 +8,11 @@ export function capabilityRateLimited(): boolean {if (!tool.limit) return false;const suffix = tool.limit.keyArg ? String(args[tool.limit.keyArg] ?? "") : (actor ?? "mcp");- return rateLimited(`${tool.limit.key}:${suffix}`, tool.limit.max, tool.limit.windowMs);+ // Only explicitly declared action budgets are separate. Invalid/unlisted actions+ // keep consuming the base mutation budget, including prototype-shaped names.+ const action = typeof args.action === "string" ? args.action : "";+ const overrides = tool.limit.actionLimits;+ const specific = overrides && Object.hasOwn(overrides, action) ? overrides[action] : undefined;+ const key = `${tool.limit.key}${specific ? ".action." + action : ""}:${suffix}`;+ return rateLimited(key, specific?.max ?? tool.limit.max, specific?.windowMs ?? tool.limit.windowMs);}diff --git a/lib/capabilities/tool.ts b/lib/capabilities/tool.tsindex fb9ff951..93cdb26f 100644--- a/lib/capabilities/tool.ts+++ b/lib/capabilities/tool.ts@@ -95,7 +95,7 @@ export interface CapabilityTool {outcome?: (result: unknown) => { ok: boolean; action?: AuditAction; detail?: string };};result?: { maxTextBytes?: number; overflowHint?: string };- limit?: { max: number; windowMs: number; keyArg?: string; key: string };+ limit?: { max: number; windowMs: number; keyArg?: string; key: string; actionLimits?: Readonly<Record<string, { max: number; windowMs: number }>> };}export const str = (args: Record<string, unknown>, key: string): string => {diff --git a/lib/contracts/skill-market.ts b/lib/contracts/skill-market.tsnew file mode 100644index 00000000..64ea492f--- /dev/null+++ b/lib/contracts/skill-market.ts@@ -0,0 +1,7 @@+export type SkillMarketState = "not-installed" | "installed" | "update-available" | "modified" | "conflict";+export type SkillMarketRow = {+ id: string; title: string; description: string; version: string; source: string;+ security: string; state: SkillMarketState; revision: string;+ canInstall: boolean; canRemove: boolean;+};+export type SkillMarketSnapshot = { catalogVersion: number; root: string; skills: SkillMarketRow[] };diff --git a/lib/host/mcp-install-target.test.ts b/lib/host/mcp-install-target.test.tsnew file mode 100644index 00000000..e5b5dd1e--- /dev/null+++ b/lib/host/mcp-install-target.test.ts@@ -0,0 +1,50 @@+import { beforeEach, afterEach, describe, it, expect, vi } from "vitest";+import { promises as fs } from "node:fs";+import os from "node:os";+import path from "node:path";+vi.mock("@/lib/host/projects-api", async importOriginal => ({ ...await importOriginal<object>(), resolveProjectHint: async () => null }));+import { resolveMcpInstallTarget } from "./mcp-install-target";+import { inspectProjectMcp, manageProjectMcp } from "./project-mcp-manage";+import { readProjectMcpServers } from "./project-mcp-config";+let root = "";+beforeEach(async () => { root = await fs.mkdtemp(path.join(os.tmpdir(), "mso-host-mcp-")); vi.stubEnv("OS_FS_READ_ROOTS", root); vi.stubEnv("OS_FS_WRITE_ROOTS", root); });+afterEach(async () => { vi.unstubAllEnvs(); await fs.rm(root, { recursive: true, force: true }); });+describe("explicit host MCP install target", () => {+ it("does not create a binding during inspection and does not use private credentials state", async () => {+ const target = await resolveMcpInstallTarget("@host"); expect(target).toMatchObject({ id: "@host", installationScope: "host", path: path.join(root, ".mso-host-mcp") });+ expect(await inspectProjectMcp(target.path)).toEqual({ revision: "new", servers: [] });+ await expect(fs.stat(target.path)).rejects.toMatchObject({ code: "ENOENT" });+ });+ it("installs/removes on disk without inheriting into unrelated projects", async () => {+ const target = await resolveMcpInstallTarget("@host", true), project = path.join(root, "project"); await fs.mkdir(project);+ const saved = await manageProjectMcp(target.path, { action: "upsert", server: "external", revision: "new", url: "https://example.test/mcp" });+ expect((await inspectProjectMcp(target.path)).servers[0].name).toBe("external"); expect(await readProjectMcpServers(project)).toEqual([]);+ await manageProjectMcp(target.path, { action: "delete", server: "external", revision: saved.revision });+ expect((await inspectProjectMcp(target.path)).servers).toEqual([]);+ });+ it("refuses a symlinked host directory", async () => {+ const outside = path.join(root, "outside"); await fs.mkdir(outside); await fs.symlink(outside, path.join(root, ".mso-host-mcp"));+ await expect(resolveMcpInstallTarget("@host", true)).rejects.toThrow("symlink");+ });+ it("preserves host read/write bounds and exact-project resolution", async () => {+ const target = await resolveMcpInstallTarget("@host", true); expect(target.path).toContain(root);+ const elsewhere = path.join(root, "limited"); await fs.mkdir(elsewhere); vi.stubEnv("OS_FS_READ_ROOTS", elsewhere);+ await expect(resolveMcpInstallTarget("@host")).rejects.toThrow();+ await expect(resolveMcpInstallTarget("unknown-project")).rejects.toThrow("exact project");+ });+ it("discovers and calls a new stdio plugin dynamically, then denies it after uninstall", async () => {+ vi.stubEnv("OS_SESSION_SECRET", "never-expose-this-test-secret");+ const target = await resolveMcpInstallTarget("@host", true), script = path.join(target.path, "fixture.mjs");+ await fs.writeFile(script, `import readline from 'node:readline';const r=readline.createInterface({input:process.stdin});r.on('line',l=>{const m=JSON.parse(l);if(!m.id)return;let result=m.method==='initialize'?{protocolVersion:m.params.protocolVersion,capabilities:{tools:{}},serverInfo:{name:'fixture',version:'1'}}:m.method==='tools/list'?{tools:[{name:'fixture_echo',inputSchema:{type:'object',properties:{value:{type:'string'}}}}]}:{content:[{type:'text',text:JSON.stringify({echo:m.params.arguments.value,leaked:!!process.env.OS_SESSION_SECRET})}]};process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`);+ // Test fixture provisioned explicitly by the owner, not an untrusted Store command.+ await fs.writeFile(path.join(target.path, ".mcp.json"), JSON.stringify({ mcpServers: { fixture: { command: process.execPath, args: [script] } } }));+ const { PROJECT_MCP_TOOLS } = await import("@/lib/mcp/tools-project-mcp");+ const discovered = await PROJECT_MCP_TOOLS[0].run({ project: "@host", server: "fixture", refresh: true }, {} as never);+ expect(JSON.stringify(discovered)).toContain("fixture_echo");+ const result = await PROJECT_MCP_TOOLS[1].run({ project: "@host", server: "fixture", tool: "fixture_echo", arguments: { value: "dynamic-success" } }, {} as never);+ expect(JSON.stringify(result)).toContain("dynamic-success"); expect(JSON.stringify(result)).not.toContain("never-expose-this-test-secret");+ const before = await inspectProjectMcp(target.path); await manageProjectMcp(target.path, { action: "delete", server: "fixture", revision: before.revision });+ await expect(PROJECT_MCP_TOOLS[0].run({ project: "@host", server: "fixture" }, {} as never)).rejects.toThrow("not found");+ await expect(PROJECT_MCP_TOOLS[1].run({ project: "@host", server: "fixture", tool: "fixture_echo" }, {} as never)).rejects.toThrow();+ });+});diff --git a/lib/host/mcp-install-target.ts b/lib/host/mcp-install-target.tsnew file mode 100644index 00000000..812a47a4--- /dev/null+++ b/lib/host/mcp-install-target.ts@@ -0,0 +1,25 @@+import path from "node:path";+import { promises as fs } from "node:fs";+import { makeDir } from "./fs-api";+import { resolveReadable, safeWritePath, writeRootList } from "./paths";+import { resolveProjectHint } from "./projects-api";++/** Explicit host scope, never an inherited project dependency or private credential store. */+export async function resolveMcpInstallTarget(hint: string, create = false) {+ if (hint !== "@host") {+ const project = await resolveProjectHint(hint);+ if (!project || project.matchedBy === "fuzzy") throw new Error("exact project required");+ return { id: project.id, name: project.name, path: project.path, installationScope: "project" as const };+ }+ const firstRoot = writeRootList()[0];+ if (!firstRoot || path.resolve(firstRoot) === path.parse(firstRoot).root) throw new Error("Host MCP needs an owner writable root");+ const directory = path.resolve(firstRoot, ".mso-host-mcp");+ const stat = await fs.lstat(directory).catch((error: NodeJS.ErrnoException) => {+ if (error.code === "ENOENT") return null; throw error;+ });+ if (stat && (!stat.isDirectory() || stat.isSymbolicLink())) throw new Error("Host MCP directory must not be a symlink");+ await safeWritePath(directory, Boolean(stat));+ if (!stat && create) await makeDir(directory);+ if (stat || create) await resolveReadable(directory);+ return { id: "@host", name: "This MSO host", path: directory, installationScope: "host" as const };+}diff --git a/lib/host/skill-market-api.test.ts b/lib/host/skill-market-api.test.tsnew file mode 100644index 00000000..d4ba3a2d--- /dev/null+++ b/lib/host/skill-market-api.test.ts@@ -0,0 +1,63 @@+import { beforeEach, afterEach, describe, it, expect, vi } from "vitest";+import { promises as fs } from "node:fs";+import { createHash } from "node:crypto";+import os from "node:os";+import path from "node:path";+import { listSkillMarket, manageSkillMarket } from "./skill-market-api";+let base = "", root = "";+beforeEach(async () => { base = await fs.mkdtemp(path.join(os.tmpdir(), "mso-market-api-")); root = path.join(base, "skills"); vi.stubEnv("MSO_SKILL_INSTALL_ROOT", root); });+afterEach(async () => { vi.unstubAllEnvs(); await fs.rm(base, { recursive: true, force: true }); });+const row = async () => (await listSkillMarket()).skills.find(skill => skill.id === "ponytail")!;+async function install() { const before = await row(); await manageSkillMarket({ action: "install", id: before.id, revision: before.revision }); return row(); }+describe("VPS Skills Store lifecycle", () => {+ it("installs and removes real files in the canonical CLI root", async () => {+ expect((await row()).state).toBe("not-installed");+ const current = await install(); expect(current.state).toBe("installed");+ expect(await fs.readFile(path.join(root, "ponytail/SKILL.md"), "utf8")).toContain("name: ponytail");+ expect((await fs.stat(path.join(root, "ponytail/SKILL.md"))).mode & 0o077).toBe(0);+ await manageSkillMarket({ action: "remove", id: current.id, revision: current.revision });+ expect((await row()).state).toBe("not-installed");+ await expect(fs.stat(path.join(root, "ponytail"))).rejects.toMatchObject({ code: "ENOENT" });+ });+ it("rejects stale revisions", async () => {+ const before = await row(); await install();+ await expect(manageSkillMarket({ action: "remove", id: before.id, revision: before.revision })).rejects.toThrow("revision changed");+ });+ it("preserves edited skill content", async () => {+ await install(); const file = path.join(root, "ponytail/SKILL.md"); await fs.appendFile(file, "\nuser edits\n");+ const current = await row(); expect(current).toMatchObject({ state: "modified", canInstall: false, canRemove: false });+ await expect(manageSkillMarket({ action: "remove", id: current.id, revision: current.revision })).rejects.toThrow("Refusing");+ expect(await fs.readFile(file, "utf8")).toContain("user edits");+ });+ it("preserves additional user files and unmanaged directories", async () => {+ await install(); await fs.writeFile(path.join(root, "ponytail/notes.txt"), "keep me");+ const current = await row(); expect(current.state).toBe("conflict");+ await expect(manageSkillMarket({ action: "remove", id: current.id, revision: current.revision })).rejects.toThrow("Refusing");+ expect(await fs.readFile(path.join(root, "ponytail/notes.txt"), "utf8")).toBe("keep me");+ await fs.unlink(path.join(root, "ponytail/notes.txt")); await fs.unlink(path.join(root, "ponytail/.mso-market.json"));+ expect((await row()).canRemove).toBe(false);+ });+ it("rejects a symlinked install root before invoking the CLI", async () => {+ const outside = path.join(base, "outside"); await fs.mkdir(outside); await fs.symlink(outside, root);+ await expect(listSkillMarket()).rejects.toThrow(); expect(await fs.readdir(outside)).toEqual([]);+ });+ it("will not remove a symlinked target or marker", async () => {+ await listSkillMarket(); const outside = path.join(base, "outside"); await fs.mkdir(outside); await fs.symlink(outside, path.join(root, "ponytail"));+ expect((await row()).canRemove).toBe(false); await fs.unlink(path.join(root, "ponytail"));+ await install(); const marker = path.join(root, "ponytail/.mso-market.json"), copy = path.join(base, "marker.json");+ await fs.rename(marker, copy); await fs.symlink(copy, marker); expect((await row()).canRemove).toBe(false);+ });+ it("updates an unchanged, marker-owned old version without losing unrelated skills", async () => {+ await install(); const dir = path.join(root, "ponytail"), file = path.join(dir, "SKILL.md"), marker = path.join(dir, ".mso-market.json");+ const old = (await fs.readFile(file, "utf8")) + "\nold reviewed version\n"; await fs.writeFile(file, old);+ const provenance = JSON.parse(await fs.readFile(marker, "utf8")); provenance.sha256 = createHash("sha256").update(old).digest("hex");+ await fs.writeFile(marker, JSON.stringify(provenance));+ const current = await row(); expect(current.state).toBe("update-available");+ await manageSkillMarket({ action: "install", id: current.id, revision: current.revision });+ expect((await row()).state).toBe("installed"); expect(await fs.readFile(file, "utf8")).not.toContain("old reviewed version");+ });+ it("rejects unreviewed ids and traversal", async () => {+ await expect(manageSkillMarket({ action: "remove", id: "../other", revision: "a".repeat(64) })).rejects.toThrow("Inspect");+ await expect(manageSkillMarket({ action: "install", id: "unknown", revision: "a".repeat(64) })).rejects.toThrow("revision changed");+ });+});diff --git a/lib/host/skill-market-api.ts b/lib/host/skill-market-api.tsnew file mode 100644index 00000000..9d5858f8--- /dev/null+++ b/lib/host/skill-market-api.ts@@ -0,0 +1,75 @@+import { execFile } from "node:child_process";+import { promisify } from "node:util";+import { createHash } from "node:crypto";+import { promises as fs } from "node:fs";+import os from "node:os";+import path from "node:path";+import { pinSecurityStorePath } from "@/lib/security-store-path";+import { withSecurityStoreLock } from "@/lib/security-store-lock";+import { readBoundedRegularFile } from "./bounded-read";+import type { SkillMarketRow, SkillMarketSnapshot, SkillMarketState } from "@/lib/contracts/skill-market";++const runFile = promisify(execFile);+const sha = (value: string) => createHash("sha256").update(value).digest("hex");+const installRoot = () => path.resolve(/* turbopackIgnore: true */ process.env.MSO_SKILL_INSTALL_ROOT || path.join(os.homedir(), ".mso", "skills"));+const idPattern = /^[a-z][a-z0-9-]{0,63}$/;++/** Fixed repository-owned program and argv: no manifest can supply executable code. */+async function marketCommand(args: string[]) {+ const { stdout } = await runFile(process.execPath, [path.join(process.cwd(), "scripts/skill-market.mjs"), ...args], {+ cwd: process.cwd(), encoding: "utf8", timeout: 12_000, maxBuffer: 512 * 1024,+ env: { NODE_ENV: process.env.NODE_ENV, HOME: os.homedir(), PATH: process.env.PATH, MSO_SKILL_INSTALL_ROOT: installRoot() },+ });+ return stdout;+}++async function installation(row: SkillMarketRow, root: string, catalogDigest: string) {+ const target = path.join(root, row.id);+ const stat = await fs.lstat(target).catch((error: NodeJS.ErrnoException) => { if (error.code === "ENOENT") return null; throw error; });+ let state: SkillMarketState = "not-installed", signature = "absent";+ if (stat) {+ state = "conflict"; signature = `${stat.ino}:${stat.mtimeMs}:${stat.mode}`;+ if (stat.isDirectory() && !stat.isSymbolicLink()) {+ const names = (await fs.readdir(target)).sort();+ signature += ":" + names.join(",");+ if (names.length === 2 && names.includes("SKILL.md") && names.includes(".mso-market.json")) {+ const body = await readBoundedRegularFile(path.join(target, "SKILL.md"), 256 * 1024);+ const raw = await readBoundedRegularFile(path.join(target, ".mso-market.json"), 64 * 1024);+ signature += ":" + sha((body ?? "") + "\0" + (raw ?? ""));+ let marker; try { marker = JSON.parse(raw ?? "null"); } catch { marker = null; }+ if (body && marker?.id === row.id && typeof marker.sha256 === "string") {+ state = sha(body) !== marker.sha256 ? "modified" : row.state === "installed" ? "installed" : "update-available";+ }+ }+ }+ }+ return { ...row, state, revision: sha(JSON.stringify([row.id, row.version, catalogDigest, state, signature])),+ canInstall: state === "not-installed" || state === "update-available",+ canRemove: state === "installed" || state === "update-available" };+}++export async function listSkillMarket(): Promise<SkillMarketSnapshot> {+ const root = installRoot();+ // Pins/validates every ancestor; hostile symlink roots fail before the CLI reads them.+ const pin = await pinSecurityStorePath(path.join(root, ".market-state"));+ try {+ const data = JSON.parse(await marketCommand(["list", "--json"])) as SkillMarketSnapshot;+ const catalog = await readBoundedRegularFile(path.join(process.cwd(), "skill-market/catalog.json"), 512 * 1024);+ if (!catalog) throw new Error("Reviewed skill catalog unavailable");+ if (!Array.isArray(data.skills) || data.skills.length > 200 || data.root !== root || data.skills.some(row => !idPattern.test(row.id))) throw new Error("Invalid skill market response");+ return { ...data, skills: await Promise.all(data.skills.map(row => installation(row, root, sha(catalog)))) };+ } finally { await pin.directory.close(); }+}++export async function manageSkillMarket(input: { action: "install" | "remove"; id: string; revision: string }) {+ if (!idPattern.test(input.id) || !["install", "remove"].includes(input.action) || !/^[a-f0-9]{64}$/.test(input.revision)) throw new Error("Inspect the skill before changing its installation");+ return withSecurityStoreLock(path.join(installRoot(), ".market-state"), async () => {+ const before = await listSkillMarket(), row = before.skills.find(item => item.id === input.id);+ if (!row || row.revision !== input.revision) throw new Error("Skill revision changed; refresh before retrying");+ if (!(input.action === "install" ? row.canInstall : row.canRemove)) throw new Error("Refusing to replace or remove modified, unmanaged, or unsafe skill files");+ await marketCommand([input.action, input.id, "-y", ...(input.action === "install" && row.state === "update-available" ? ["--force"] : [])]);+ const after = await listSkillMarket(), changed = after.skills.find(item => item.id === input.id);+ if (changed?.state !== (input.action === "install" ? "installed" : "not-installed")) throw new Error("Skill postcondition failed; refresh installation state");+ return after;+ });+}diff --git a/lib/mcp/tools-project-mcp-manage.ts b/lib/mcp/tools-project-mcp-manage.tsindex 768af1ab..fcd2c113 100644--- a/lib/mcp/tools-project-mcp-manage.ts+++ b/lib/mcp/tools-project-mcp-manage.ts@@ -1,31 +1,30 @@import { inspectProjectMcp, manageProjectMcp } from "@/lib/host/project-mcp-manage";-import { resolveProjectHint } from "@/lib/host/projects-api";+import { resolveMcpInstallTarget } from "@/lib/host/mcp-install-target";import { type McpTool, S, str } from "./tool-kit";export const PROJECT_MCP_MANAGE_TOOLS: McpTool[] = [{- name: "project_mcp_manage", title: "Install or Manage Project MCP", scope: "write",- description: "Inspect/install/update/uninstall one exact project's MCP binding. Fresh projects have no plugin binding and nothing is inherited from parent projects. For reviewed project plugins set plugin=si-coder or plugin=batonly; Batonly also requires an exact MSO credential user/connection. Arbitrary HTTP MCPs still use url. Inspect first for revision; mutations preserve other servers.",- chatgptDescription: "Manage MCP installation for one exact project. Plugins are absent by default and never inherited; inspect before installing or uninstalling.",+ name: "project_mcp_manage", title: "Install or Manage MCP", scope: "write",+ description: "Inspect/install/update/uninstall an MCP binding on one exact project, or project=@host for this MSO host. Host installations never propagate to projects. Fresh projects have no plugin binding and nothing is inherited from parent projects. For reviewed project plugins set plugin=si-coder or plugin=batonly; Batonly also requires an exact MSO credential user/connection. Arbitrary HTTP MCPs still use url. Inspect first for revision; mutations preserve other servers.",+ chatgptDescription: "Manage installed MCPs: project=@host selects this VPS, otherwise choose one exact project. Inspect first; then discover via project_mcp_tools and call via project_mcp_call. No inherited bindings.",meta: { ui: { visibility: ["model", "app"] }, "openai/widgetAccessible": true },annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },- limit: { key: "project.mcp.manage", max: 20, windowMs: 60_000 },+ limit: { key: "project.mcp.manage", max: 20, windowMs: 60_000, actionLimits: { inspect: { max: 120, windowMs: 60_000 } } },audit: { action: "fs.write", targetArg: "project" },inputSchema: S({- project: { type: "string", description: "Exact project id/path/name." },+ project: { type: "string", description: "Exact project id/path/name, or @host for the MSO host installation scope." },action: { type: "string", enum: ["inspect", "upsert", "delete"] },server: { type: "string", maxLength: 64, description: "Project-local server alias. Required for mutations." },revision: { type: "string", description: "Revision from inspect. Required for mutations." },- plugin: { type: "string", enum: ["si-coder", "batonly"], description: "Reviewed project plugin identity. Installation is exact-project only; no global/default activation." },+ plugin: { type: "string", enum: ["si-coder", "batonly"], description: "Reviewed project plugin identity. Installation is explicit-target only; no default activation or project inheritance." },url: { type: "string", maxLength: 4096, description: "HTTPS endpoint without credentials/query/fragment. Required for HTTP upsert; omit with plugin." },user: { type: "string", description: "Exact credential owner; use together with connection." },connection: { type: "string", description: "Exact private MCP connection; omit both for public MCP." },}, ["project", "action"]),run: async a => {if (a.plugin !== undefined && !["si-coder", "batonly"].includes(String(a.plugin))) throw new Error("unsupported project plugin");- const project = await resolveProjectHint(str(a, "project"));- if (!project || project.matchedBy === "fuzzy") throw new Error("exact project required");- if (a.action === "inspect") return { project: project.id, ...await inspectProjectMcp(project.path) };+ const project = await resolveMcpInstallTarget(str(a, "project"), a.action === "upsert");+ if (a.action === "inspect") return { project: project.id, installationScope: project.installationScope, ...await inspectProjectMcp(project.path) };if (a.action !== "upsert" && a.action !== "delete") throw new Error("invalid MCP action");- return { project: project.id, ...await manageProjectMcp(project.path, { action: a.action, server: str(a, "server"), revision: str(a, "revision"),+ return { project: project.id, installationScope: project.installationScope, ...await manageProjectMcp(project.path, { action: a.action, server: str(a, "server"), revision: str(a, "revision"),plugin: a.plugin === "si-coder" || a.plugin === "batonly" ? a.plugin : undefined, url: typeof a.url === "string" ? a.url : undefined, user: typeof a.user === "string" ? a.user : undefined, connection: typeof a.connection === "string" ? a.connection : undefined }) };},}];diff --git a/lib/mcp/tools-project-mcp.ts b/lib/mcp/tools-project-mcp.tsindex bf6c7367..d14d975d 100644--- a/lib/mcp/tools-project-mcp.ts+++ b/lib/mcp/tools-project-mcp.ts@@ -1,6 +1,7 @@+import { resolveMcpInstallTarget } from "@/lib/host/mcp-install-target";import { callManagedScProvider } from "./managed-sc-call";import { projectMcpResult, projectMcpStructuredProjection } from "@/lib/host/project-mcp-result";-import { callProjectMcpTool, listProjectMcpToolPage, publicProjectMcpServers, readProjectMcpServers, resolveProjectHint } from "@/lib/host/projects-api";+import { callProjectMcpTool, listProjectMcpToolPage, publicProjectMcpServers, readProjectMcpServers } from "@/lib/host/projects-api";import { type McpTool, S, str, mcpDirect } from "./tool-kit";export const PROJECT_MCP_TOOLS: McpTool[] = [@@ -9,20 +10,20 @@ export const PROJECT_MCP_TOOLS: McpTool[] = [result: { maxTextBytes: 64 * 1024, overflowHint: "Use limit=1 for a narrower descriptor page; preserve the exact nextCursor." },title: "List Project MCP Tools",description: "Discover tools from one MCP server declared by an explicitly selected project's .mcp.json. Server aliases and tool schemas are returned on demand; config, env, headers, and credentials are never returned and project tools never join MSO's global catalog.",- chatgptDescription: "Discover a declared project MCP through its private connection. Dynamic tools stay project-scoped.",+ chatgptDescription: "Discover live tools of an installed MCP. project=@host selects this VPS; other values select an exact project. Find aliases with project_mcp_manage inspect. Follow nextCursor; refresh bypasses descriptor cache.",scope: "exec",annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true, idempotentHint: false },actionContract: { phase: "discover", target: "project-mcp", sourceOfTruth: "provider", discover: ["project_capabilities"], validators: ["project-selection", "private-connection"], confirmation: "none", concurrency: "provider", presentation: "structured" },audit: { action: "exec.run" as const, targetArg: "server" },limit: { key: "projects.mcp.read", max: 30, windowMs: 60_000 },inputSchema: S({- project: { type: "string", description: "Exact project id/path/name from projects_list." },+ project: { type: "string", description: "Exact project id/path/name from projects_list, or @host for host-installed MCPs." },server: { type: "string", description: "MCP server alias returned by project_capabilities." },cursor: { type: "string", maxLength: 8192, description: "Exact nextCursor from the previous page." },limit: { type: "integer", minimum: 1, maximum: 100 }, refresh: { type: "boolean", description: "Bypass the 30-second HTTP descriptor cache." },}, ["project", "server"]),run: async (a) => {- const project = await resolveProjectHint(str(a, "project")); if (!project) throw new Error(`project not found: ${String(a.project)}`);+ const project = await resolveMcpInstallTarget(str(a, "project"));const servers = publicProjectMcpServers(await readProjectMcpServers(project.path));const selected = servers.find((server) => server.name === str(a, "server")); if (!selected) throw new Error("project MCP server not found");return { project: { id: project.id, name: project.name }, server: selected, ...await listProjectMcpToolPage(project.path, selected.name, { cursor: typeof a.cursor === "string" ? a.cursor : undefined, limit: Number(a.limit) || 50, refresh: a.refresh === true }) };@@ -32,7 +33,7 @@ export const PROJECT_MCP_TOOLS: McpTool[] = [name: "project_mcp_call",title: "Call Project MCP Tool",description: "Call one exact tool on one MCP server declared by a validated project's .mcp.json. The project MCP configuration stays server-side; MSO launches/calls it with credential-scrubbed process environment or a guarded remote transport and returns only the MCP tool result.",- chatgptDescription: "Call one exact tool from a selected project's MCP server. The project's MCP config and credentials stay server-side.",+ chatgptDescription: "Call one discovered tool through MSO to an installed external MCP. Use project=@host for this VPS or an exact project. Config, credentials, and authorization stay server-side; inspect and discover first.",scope: "exec",outputSchema: { type: "object", properties: { result: { type: "object" } }, required: ["result"], additionalProperties: false },annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true, idempotentHint: false },@@ -41,13 +42,13 @@ export const PROJECT_MCP_TOOLS: McpTool[] = [audit: { action: "exec.run" as const, targetArg: "server" },result: { maxTextBytes: 64 * 1024, overflowHint: "Project MCP result was compacted; request a narrower project tool call." },inputSchema: S({- project: { type: "string", description: "Exact project id/path/name from projects_list." },+ project: { type: "string", description: "Exact project id/path/name from projects_list, or @host for host-installed MCPs." },server: { type: "string", description: "Project MCP server alias from project_capabilities." },tool: { type: "string", description: "Exact tool name from project_mcp_tools." },arguments: { type: "object", description: "Arguments matching that dynamic tool's input schema.", additionalProperties: true },}, ["project", "server", "tool"]),run: async (a) => {- const project = await resolveProjectHint(str(a, "project")); if (!project) throw new Error(`project not found: ${String(a.project)}`);+ const project = await resolveMcpInstallTarget(str(a, "project"));const managed = await callManagedScProvider(project.path, str(a, "server"), str(a, "tool"), a.arguments ?? {});const out = projectMcpResult(managed.handled ? managed.result : await callProjectMcpTool(project.path, str(a, "server"), str(a, "tool"), a.arguments ?? {}));return mcpDirect(out.content, out.isError, { result: { project: project.id, server: str(a, "server"), tool: str(a, "tool"), output: projectMcpStructuredProjection(out) } }, out.meta);diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.tsindex 47954111..5edf16dd 100644--- a/lib/mcp/toolset.ts+++ b/lib/mcp/toolset.ts@@ -3,9 +3,9 @@ import type { Scope } from "./scope";import type { McpTool } from "./tool-kit";import { toolDescriptor, type McpToolProfile } from "./tool-contract";-export const MCP_SERVER_VERSION = "1.15.0";-export const MCP_TOOLSET_VERSION = "2026.09.17.1";-export const MCP_TOOLSET_CHANGED_AT = "2026-09-17T02:50:00+07:00";+export const MCP_SERVER_VERSION = "1.15.1";+export const MCP_TOOLSET_VERSION = "2026.09.17.2";+export const MCP_TOOLSET_CHANGED_AT = "2026-09-17T17:50:58+07:00";export type McpToolsetInfo = {serverVersion: string;diff --git a/lib/skills/catalog.ts b/lib/skills/catalog.tsindex bc37690a..f4ba30ce 100644--- a/lib/skills/catalog.ts+++ b/lib/skills/catalog.ts@@ -38,7 +38,7 @@ type CatalogOptions = {*/export function skillRoots(appDir = process.cwd(), homeDir = os.homedir()): RootSpec[] {return [- { path: path.join(homeDir, ".mso/skills"), source: "operator", trust: "local", priority: 120 },+ { path: process.env.MSO_SKILL_INSTALL_ROOT ? path.resolve(/* turbopackIgnore: true */ process.env.MSO_SKILL_INSTALL_ROOT) : path.join(homeDir, ".mso/skills"), source: "operator", trust: "local", priority: 120 },{ path: path.join(appDir, "claude-skills"), source: "mso", trust: "official", priority: 100 },{ path: path.join(appDir, "skills"), source: "bundled", trust: "untrusted", priority: 80, verifyClawHub: true },{ path: path.join(homeDir, ".claude/skills"), source: "claude", trust: "untrusted", priority: 20 },diff --git a/scripts/cli/commands-state.sh b/scripts/cli/commands-state.shindex 9ad55738..ed8c22fa 100755--- a/scripts/cli/commands-state.sh+++ b/scripts/cli/commands-state.sh@@ -193,6 +193,14 @@ case "$cmd" injget "/api/skills?name=$(enc "$2")" ;;search) shift; [ $# -gt 0 ] || die "usage: mso $U_skills"jget "/api/skills?q=$(enc "$*")" ;;+ store)+ case "${2:-list}" in+ list) jget "/api/v1/skill-market" ;;+ install|remove)+ [ -n "${3-}" ] && [ -n "${4-}" ] || die "usage: mso skills store install|remove <id> <revision>"+ jpost "/api/v1/skill-market" "$(jq -nc --arg action "$2" --arg id "$3" --arg revision "$4" '{action:$action,id:$id,revision:$revision}')" ;;+ *) die "usage: mso skills store list|install <id> <revision>|remove <id> <revision>" ;;+ esac ;;available) shift; node "$ROOT/scripts/skill-market.mjs" available "$@" ;;info) shift; node "$ROOT/scripts/skill-market.mjs" info "$@" ;;install) shift; node "$ROOT/scripts/skill-market.mjs" install "$@" ;;diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.shindex fcac1160..05ab94b8 100755--- a/scripts/cli/commands.sh+++ b/scripts/cli/commands.sh@@ -48,7 +48,7 @@ U_memory="memory list|add <text>|rm <id>"U_config="config show|set <json>|key <provider>|style <off|caveman|ponytail>|rm <provider>"U_prefs="prefs show|set <json>"U_models="models [status|list|add|auth <provider>|rm <provider>|catalog [provider]|test]"-U_skills="skills list|read <id>|search <query…>|available|info <id>|install <id…> [-y] [--force]|remove <id…> [-y]"+U_skills="skills list|read <id>|search <query…>|available|info <id>|install <id…> [-y] [--force]|remove <id…> [-y]|store list|store install|remove <id> <revision>"U_mcp="mcp project <JSON>|list|activity [n]|service-token --label <label> --client-id <id> --scope <read|write|exec> --tools <name,name> [--constraints-json <json>]|revoke <id>|revoke all"U_oauth="oauth <provider> start|poll OAuth currently: openai (ChatGPT Codex)"# Command families are sourced here so bin/mso remains only bootstrap + entrypoint.diff --git a/scripts/e2e/mcp-settings.mjs b/scripts/e2e/mcp-settings.mjsindex 84e4c74b..bd71b953 100644--- a/scripts/e2e/mcp-settings.mjs+++ b/scripts/e2e/mcp-settings.mjs@@ -58,20 +58,21 @@ export async function mcpOwnerJourneys(page, fixture) {await page.getByRole("button", { name: "Show expired & disconnected", exact: true }).click();await expect(page.getByText("Read data · revoked", { exact: true })).toBeVisible();await nav.getByRole("button", { name: "MCP overview", exact: true }).click();- await page.getByRole("tab", { name: /MSO Access/ }).click();- const outbound = page.getByRole("navigation", { name: "MCP navigation" });- await expect(outbound.getByRole("button", { name: /^Project plugins/ })).toBeVisible();+ await page.getByRole("tab", { name: /MSO to External/ }).click();await expect(page.getByText("Each project starts with no SI-Coder or Batonly binding.", { exact: false })).toBeVisible();- await outbound.getByRole("button", { name: /^Project plugins/ }).click();- await page.getByLabel("Plugin target project").fill(fixture.dir);- const siCoder = page.getByRole("listitem").filter({ hasText: "SI-Coder" });- await siCoder.getByRole("button", { name: "Check installation", exact: true }).click();- await expect(siCoder.getByText("Not installed in this project.", { exact: true })).toBeVisible();- await siCoder.getByRole("button", { name: "Install to project", exact: true }).click();- await expect(siCoder.getByText("Installed in this project.", { exact: false })).toBeVisible();+ await page.getByLabel("Exact MCP target project").fill(fixture.dir);+ await expect(page.getByRole("button", { name: "Use project", exact: true })).toBeEnabled();+ await page.getByRole("button", { name: "Use project", exact: true }).click();+ const siCoder = page.getByRole("article").filter({ has: page.getByRole("heading", { name: "SI-Coder", exact: true }) });+ await expect(siCoder.getByRole("button", { name: "Install", exact: true })).toBeEnabled();page.once("dialog", dialog => dialog.accept());- await siCoder.getByRole("button", { name: "Uninstall", exact: true }).click();- await expect(siCoder.getByText("Not installed in this project.", { exact: true })).toBeVisible();+ await siCoder.getByRole("button", { name: "Install", exact: true }).click();+ const installed = page.getByRole("article").filter({ has: page.getByRole("heading", { name: "si-coder", exact: true }) });+ await expect(installed.getByRole("button", { name: "Uninstall", exact: true })).toBeVisible();+ await expect(installed.getByRole("button", { name: "Uninstall", exact: true })).toBeEnabled();+ page.once("dialog", dialog => dialog.accept());+ await installed.getByRole("button", { name: "Uninstall", exact: true }).click();+ await expect(page.getByText("No MCP installed on this target.", { exact: true })).toBeVisible();await page.getByRole("tab", { name: /Access MSO/ }).click();expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);const result = await new AxeBuilder({ page }).include('[data-slot="mcp-page"]').withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze();diff --git a/scripts/e2e/release-fixture.mjs b/scripts/e2e/release-fixture.mjsindex 252512f0..d8539029 100644--- a/scripts/e2e/release-fixture.mjs+++ b/scripts/e2e/release-fixture.mjs@@ -40,7 +40,7 @@ export async function releaseFixture({ live = false } = {}) {OS_CONFIG_STORE: path.join(dir, "config.json"), OS_PREFS_PATH: path.join(dir, "prefs.json"),OS_AUDIT_LOG: path.join(dir, "audit.jsonl"), OS_LOGIN_PASSWORD: password,OS_SESSION_SECRET: randomBytes(32).toString("hex"), OS_FS_READ_ROOTS: dir, OS_FS_WRITE_ROOTS: dir,- OS_MCP_ENABLED: "1", NEXT_PUBLIC_OS_DEMO: "0", NEXT_TELEMETRY_DISABLED: "1",+ MSO_SKILL_INSTALL_ROOT: path.join(dir, "skills"), OS_MCP_ENABLED: "1", NEXT_PUBLIC_OS_DEMO: "0", NEXT_TELEMETRY_DISABLED: "1",});const mcpToken = randomBytes(32).toString("hex");const seedMcp = async (scope = "read") => {diff --git a/scripts/e2e/release.mjs b/scripts/e2e/release.mjsindex 9d32a462..8a7660b1 100644--- a/scripts/e2e/release.mjs+++ b/scripts/e2e/release.mjs@@ -7,6 +7,7 @@ import { mcpOwnerJourneys, mcpPublicJourney, settingsAccessibilityJourney } fromimport { automationJourney } from "./automation.mjs";import { organizationJourney } from "./organization.mjs";import { workflowCanvasJourney } from "./workflow-canvas.mjs";+import { storeExtensionsJourney } from "./store-extensions.mjs";import { releaseFixture } from "./release-fixture.mjs";execFileSync(process.execPath, ["scripts/e2e/mcp-page.mjs"], { stdio: "inherit" });@@ -83,6 +84,8 @@ try {await page.getByRole("button", { name: "Unlock", exact: true }).click();await expect(page).toHaveURL(fixture.base + "/integrations");await expect(page.getByRole("group", { name: "Credential owner" }).getByRole("button")).toContainText("fixture");+ await storeExtensionsJourney(page, fixture);+ await page.goto(fixture.base + "/integrations");await page.getByRole("navigation", { name: "Integrations sections", exact: true }).getByRole("button", { name: "Transfer & backup", exact: true }).click();await expect(page.getByRole("heading", { name: "Transfer & backup", exact: true })).toBeVisible();await expect(page.getByLabel("Export scope")).toHaveValue("all");diff --git a/scripts/e2e/store-extensions.mjs b/scripts/e2e/store-extensions.mjsnew file mode 100644index 00000000..99f777b4--- /dev/null+++ b/scripts/e2e/store-extensions.mjs@@ -0,0 +1,87 @@+// Store/Settings browser contract, using the release fixture and real bounded host APIs.+import { expect } from "@playwright/test";+import { readFile, writeFile, mkdir, chmod } from "node:fs/promises";+import path from "node:path";+import AxeBuilder from "@axe-core/playwright";++async function capture(page, name) {+ if (!process.env.MSO_SCREENSHOT_DIR) return;+ await mkdir(process.env.MSO_SCREENSHOT_DIR, { recursive: true, mode: 0o700 });+ const file = path.join(process.env.MSO_SCREENSHOT_DIR, name + ".png");+ await page.screenshot({ path: file, animations: "disabled" }); await chmod(file, 0o600);+}+async function select(page, label) {+ await page.getByRole("tablist", { name: "Store categories" }).getByRole("tab", { name: label, exact: true }).click();+}+async function card(page, name) {+ const article = page.getByRole("article").filter({ has: page.getByRole("heading", { name, exact: true }) });+ await expect(article).toBeVisible(); return article;+}+async function acceptedClick(page, button) {+ await expect(button).toBeEnabled(); page.once("dialog", dialog => dialog.accept()); await button.click();+}+export async function storeExtensionsJourney(page, fixture) {+ const errors = [];+ const onError = error => errors.push(error.message); page.on("pageerror", onError);+ await page.goto(fixture.base + "/store");+ const tabs = page.getByRole("tablist", { name: "Store categories" });+ await expect(tabs).toBeVisible();+ for (const name of ["Apps", "MCP", "Skills"]) await expect(tabs.getByRole("tab", { name, exact: true })).toBeVisible();+ await select(page, "MCP");+ await expect(page.getByText("No MCP installed on this target.", { exact: true })).toBeVisible();+ const available = await card(page, "SI-Coder");+ await acceptedClick(page, available.getByRole("button", { name: "Install", exact: true }));+ const installed = await card(page, "si-coder");+ await expect(installed.getByRole("button", { name: "Uninstall", exact: true })).toBeEnabled();+ const manifest = path.join(fixture.dir, ".mso-host-mcp/.mcp.json");+ expect(JSON.parse(await readFile(manifest, "utf8")).mcpServers["si-coder"].plugin).toBe("si-coder");+ await acceptedClick(page, installed.getByRole("button", { name: "Uninstall", exact: true }));+ await expect(page.getByText("No MCP installed on this target.", { exact: true })).toBeVisible();+ expect(JSON.parse(await readFile(manifest, "utf8")).mcpServers["si-coder"]).toBeUndefined();+ // A locally provisioned synthetic stdio plugin exercises real dynamic discovery without a provider account.+ const script = path.join(fixture.dir, ".mso-host-mcp/fixture.mjs");+ await writeFile(script, `import readline from 'node:readline';readline.createInterface({input:process.stdin}).on('line',l=>{const m=JSON.parse(l);if(!m.id)return;const result=m.method==='initialize'?{protocolVersion:m.params.protocolVersion,capabilities:{tools:{}},serverInfo:{name:'fixture',version:'1'}}:{tools:[{name:'fixture_read',inputSchema:{type:'object',properties:{}}}]};process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n')});`);+ await writeFile(manifest, JSON.stringify({ mcpServers: { fixture: { command: process.execPath, args: [script] } } }));+ await page.getByRole("button", { name: "Refresh", exact: true }).click();+ const dynamic = await card(page, "fixture");+ await dynamic.getByRole("button", { name: "Check tools", exact: true }).click();+ await expect(dynamic.getByText("fixture_read", { exact: true })).toBeVisible();+ await expect(dynamic.getByText(/Tool discovery verified/)).toBeVisible();+ await capture(page, "store-mcp-desktop");+ await select(page, "Skills");+ const ponytail = await card(page, "Ponytail");+ await acceptedClick(page, ponytail.getByRole("button", { name: "Install", exact: true }));+ await expect(ponytail.getByRole("button", { name: "Uninstall", exact: true })).toBeEnabled();+ const file = path.join(fixture.dir, "skills/ponytail/SKILL.md");+ expect(await readFile(file, "utf8")).toContain("name: ponytail");+ await capture(page, "store-skills-desktop");+ await page.reload(); await select(page, "Skills");+ const persisted = await card(page, "Ponytail");+ await expect(persisted.getByRole("button", { name: "Uninstall", exact: true })).toBeEnabled();+ await acceptedClick(page, persisted.getByRole("button", { name: "Uninstall", exact: true }));+ await expect(persisted.getByRole("button", { name: "Install", exact: true })).toBeEnabled();+ await expect(readFile(file, "utf8")).rejects.toMatchObject({ code: "ENOENT" });+ for (const viewport of [{ width: 390, height: 844 }, { width: 844, height: 390 }, { width: 1363, height: 936 }]) {+ await page.setViewportSize(viewport); await page.goto(fixture.base + "/store");+ for (const tab of ["MCP", "Skills"]) {+ await select(page, tab); await expect(page.getByRole("heading", { name: tab === "MCP" ? "MCP on this VPS" : "Skills on this VPS", exact: true })).toBeVisible();+ const ready = await card(page, tab === "MCP" ? "fixture" : "Ponytail");+ await expect(ready.getByRole("button", { name: tab === "MCP" ? "Check tools" : "Install", exact: true })).toBeEnabled();+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);+ if (viewport.width === 390) await capture(page, `store-${tab.toLowerCase()}-mobile`);+ const result = await new AxeBuilder({ page }).include('[role="tabpanel"]').withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze();+ expect(result.violations.map(item => ({ id: item.id, targets: item.nodes.map(node => node.target) }))).toEqual([]);+ }+ }+ await page.goto(fixture.base + "/settings");+ const sections = page.getByRole("button", { name: "Settings sections", exact: true });+ if (await sections.isVisible()) await sections.click();+ await page.getByRole("button", { name: "MCP", exact: true }).click();+ await page.getByRole("tab", { name: /MSO to External/ }).click();+ await expect(page.getByRole("tablist", { name: "Installed extensions" })).toBeVisible();+ await expect(page.getByRole("heading", { name: "fixture", exact: true })).toBeVisible();+ await page.getByRole("tablist", { name: "Installed extensions" }).getByRole("tab", { name: "Skills", exact: true }).click();+ await expect(page.getByRole("heading", { name: "Skills on this VPS", exact: true })).toBeVisible();+ expect(errors).toEqual([]); page.off("pageerror", onError);+ console.log("PASS Store MCP/Skills: real file install/remove, reload persistence, dynamic tool discovery, shared Settings, responsive layout and accessibility");+}