Skip to content

armgit / mso

Public Imported from GitHub
0

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.

fix(integrations): repair embedded setup and complete native provider catalog

Rahmandc3d16a4eaa7
diff --git a/app/api/integrations/setup/route.ts b/app/api/integrations/setup/route.ts
index a02e1e87..c1defcea 100644
--- a/app/api/integrations/setup/route.ts
+++ b/app/api/integrations/setup/route.ts
@@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from "next/server";
import { MSO_ORIGIN, MCP_UI_DOMAIN } from "@/lib/mcp/ui-config";
import { audit } from "@/lib/host/audit-api";
import { consumeIntegrationSetup, describeIntegrationSetup, SetupError } from "@/lib/infra/setup-capability";
-import { integrationSetupPage } from "@/lib/infra/setup-page";
+import { integrationPageResponse } from "@/lib/infra/setup-page";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
const BASE_HEADERS = { "Cache-Control": "no-store, private", "Referrer-Policy": "no-referrer", "X-Content-Type-Options": "nosniff", Vary: "Origin" };
@@ -14,10 +14,7 @@ function cors(req: NextRequest): Record<string, string> | null {
if (!origin || (![MSO_ORIGIN, MCP_UI_DOMAIN].includes(origin) && !local)) return null;
return { ...BASE_HEADERS, "Access-Control-Allow-Origin": origin, "Access-Control-Allow-Methods": "POST, OPTIONS", "Access-Control-Allow-Headers": "Authorization, Content-Type" };
}
-export function GET() {
- const page = integrationSetupPage();
- return new NextResponse(page.html, { headers: { ...BASE_HEADERS, "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": page.csp, "X-Frame-Options": "DENY" } });
-}
+export const GET = integrationPageResponse;
export function OPTIONS(req: NextRequest) {
const headers = cors(req);
return new NextResponse(null, { status: headers ? 204 : 403, headers: headers ?? BASE_HEADERS });
diff --git a/app/integrations/route.test.ts b/app/integrations/route.test.ts
index b77a001a..133dbcc1 100644
--- a/app/integrations/route.test.ts
+++ b/app/integrations/route.test.ts
@@ -1,7 +1,21 @@
-import { expect, it } from "vitest";
+import { describe, expect, it, vi } from "vitest";
+import { NextRequest } from "next/server";
+vi.mock("server-only", () => ({}));
import { GET } from "./route";
-it("serves a public uncached integration document with its own matching nonce", async () => {
- const r = GET(); const html = await r.text(); expect(r.status).toBe(200);
- const nonce = html.match(/<script nonce="([^"]+)"/)![1]; expect(r.headers.get("content-security-policy")).toContain(`script-src 'nonce-${nonce}'`);
- expect(r.headers.get("cache-control")).toContain("no-store"); expect(r.headers.get("x-frame-options")).toBe("DENY");
+import { proxy } from "@/proxy";
+describe("friendly native Integrations page", () => {
+ it("renders an uncached full catalog with public instructions but no credential grant", async () => {
+ const response = GET(), html = await response.text();
+ expect(response.status).toBe(200); expect(response.headers.get("referrer-policy")).toBe("no-referrer");
+ expect(response.headers.get("cache-control")).toContain("no-store");
+ expect(html).toContain("INTEGRATIONS_CATALOG"); expect(html).toContain('"id":"supabase"');
+ expect(html).toContain("Step by step: get this credential"); expect(html).not.toContain("si-coder");
+ expect(() => new Function(html.match(/<script nonce="[^"]+">([\s\S]*)<\/script>/)![1])).not.toThrow();
+ });
+ it("lets the trusted HTML endpoint own its nonce while retaining owner mutation CSRF checks", async () => {
+ const read = await proxy(new NextRequest("https://mso.rahmanef.com/integrations", { headers: { host: "mso.rahmanef.com" } }));
+ expect(read.headers.get("content-security-policy")).toBeNull();
+ const write = await proxy(new NextRequest("https://mso.rahmanef.com/api/v1/infra/setup", { method: "POST", headers: { host: "mso.rahmanef.com", origin: "https://evil.invalid", "sec-fetch-site": "cross-site" }, body: "{}" }));
+ expect(write.status).toBe(403);
+ });
});
diff --git a/app/integrations/route.ts b/app/integrations/route.ts
index 5e494714..4c3218f0 100644
--- a/app/integrations/route.ts
+++ b/app/integrations/route.ts
@@ -1,8 +1,4 @@
-import { NextResponse } from "next/server";
-import { integrationSetupPage } from "@/lib/infra/setup-page";
+import { integrationPageResponse } from "@/lib/infra/setup-page";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
-export function GET() {
- const page = integrationSetupPage();
- return new NextResponse(page.html, { headers: { "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": page.csp, "Cache-Control": "no-store, private", "Referrer-Policy": "no-referrer", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "DENY" } });
-}
+export const GET = integrationPageResponse;
diff --git a/docs/INFRASTRUCTURE-PROVIDERS.md b/docs/INFRASTRUCTURE-PROVIDERS.md
index 390a1c40..3c2b4ca5 100644
--- a/docs/INFRASTRUCTURE-PROVIDERS.md
+++ b/docs/INFRASTRUCTURE-PROVIDERS.md
@@ -215,3 +215,8 @@ store and doctor, alongside the existing infrastructure providers. Use
for a temporary form. This verifies platform credentials; it does not authorize
every connected application or copy its OAuth tokens. See [Native Integrations](INTEGRATIONS.md)
for the owner-browser and ChatGPT Page workflows.
+
+The native Integrations catalog now also includes GitHub, Vercel, Convex Cloud,
+self-hosted Convex, Resend, Stripe, Clerk, and Supabase. This expands secure setup
+and bounded read-only credential checking; it does not automatically add every
+provider operation to the MCP catalog. Browser entrypoint: `/integrations`.
diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.md
index 9d24006a..83f2604b 100644
--- a/docs/INTEGRATIONS.md
+++ b/docs/INTEGRATIONS.md
@@ -1,17 +1,17 @@
# Native Integrations
-Connect Composio, Dokploy, Cloudflare, and Hostinger directly to MSO. No separate
+Connect Composio, Dokploy, Cloudflare, Hostinger, GitHub, Vercel, Convex Cloud,
+self-hosted Convex, Resend, Stripe, Clerk, and Supabase directly to MSO. No separate
credential application or plugin is required. Composio accepts either a project
API key or an organization API key; these are separate setup methods.
## Browser and terminal
-Open `/integrations` on your MSO origin. The page checks your live session and
-disables **Open secure form** until the device has Owner permission. Provider
-guides remain readable before sign-in. Open MSO sign-in in another tab, then return;
-focus/visibility refreshes the session, with **Check sign-in again** as a fallback.
-Choose the provider and authentication method, then open its secure form. The old
-`/api/integrations/setup` URL remains compatible. The form
+Open `/integrations` on your MSO origin. The searchable catalog and official
+credential instructions are available before signing in. Select the provider and
+authentication method, then choose **Open secure form**. Sign in as an owner in
+another tab only when creating the private form. The old `/api/integrations/setup`
+address remains compatible. The form
includes official links, expandable instructions, masked inputs with show/hide,
and **Validate & save**. Existing stored values are never displayed; blank fields
keep them unchanged. A rejected or unreachable provider does not replace them.
@@ -22,6 +22,8 @@ From an interactive terminal with an authenticated MSO session:
mso provider setup composio project
mso provider setup composio organization
mso provider setup hostinger
+mso provider setup convex-cloud personal
+mso provider setup convex-cloud deployment
```
The command prints a private ten-minute URL on the configured public MSO origin.
@@ -48,16 +50,11 @@ ChatGPT → integration_setup_open(provider, method)
provider validation → private MSO store
```
-Page v4 keeps explicit public browser links and provider guides visible even when
-a cached chat cannot call the new setup tool. A missing tool or missing private
-metadata no longer replaces the whole page with an error. A server update does
-not itself refresh the client catalog; reconnect MSO to load new actions.
-Older Page resource URIs resolve to the current resource without adding a third
-UI type.
-
The grant reaches the UI through hidden MCP `_meta`. A WeakMap keeps it out of
-ordinary result serialization and non-ChatGPT model transports. The UI supports
-standards-based MCP Apps initialization and ChatGPT's canonical metadata
+ordinary result serialization and model transports. Both generic MCP Apps and
+the compact ChatGPT transport retain the UI-only result metadata; it is not added
+to text or structured model content. The UI supports
+both standards-based MCP Apps initialization and ChatGPT's canonical metadata
envelope. Credential values never enter `tools/call`, `ui/message`, widget state,
local storage, or session storage. Buttons do not require iframe `allow-forms`;
reference links use the host's approved external-link bridge.
@@ -110,6 +107,21 @@ desktop/mobile Page rendering, standards-bridge initialization, failed validatio
and retry, input clearing, no owner cookies, and no credential in host messages.
Real provider authentication still requires the user's own valid credential.
+The organization-key probe uses Composio's organization-owner endpoint
+`/api/v3.1/org/owner/project/list` with `x-org-api-key`, not the similarly named
+user-key endpoint. Convex personal-token validation uses the explicitly PAT-scoped
+`/v1/list_personal_access_tokens?limit=1`; token inventory is discarded.
+
+The Page resource is v5. Earlier Page resource URIs resolve to the current safe
+renderer, and both standard and compatibility CSP forms advertise the exact MSO
+connection origin. Missing private metadata, an unavailable setup tool, or expired
+authorization shows a recovery message and browser entrypoint instead of a blank
+form. Browser failure/expiry never requests a secret through chat.
+
+Native MSO storage is independent of other applications. Provider registration
+and API-key checks do not imply full provider-operation parity or completion of
+an upstream OAuth flow. MSO does not silently import another tool's credentials.
+
### Deployment verification
The service release lifecycle waits for the root HTTP endpoint after observing a
diff --git a/docs/MCP.md b/docs/MCP.md
index d0c041ee..087cad4e 100644
--- a/docs/MCP.md
+++ b/docs/MCP.md
@@ -705,4 +705,5 @@ one on its own the way it does a cookie.
MSO Integrations uses the existing Page at `/integrations`. The write-scoped
`integration_setup_open` tool opens a secure form without accepting secret values.
See [Native Integrations](INTEGRATIONS.md) for browser/CLI entrypoints, scope,
-expiry, direct HTTPS submission, and verification limits.
+expiry, direct HTTPS submission, and verification limits. The friendly browser
+entrypoint is `/integrations`; Page v5 retains previous resource aliases.
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 6e558082..ace228e5 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,5 +1,40 @@
## 2026-09-05 — MCP Page preview lifecycle
+
+## 2026-09-05 — Repair native Integrations delivery and full credential catalog
+
+The initial temporary form was too narrow and could arrive without its UI-only
+setup grant when the MCP transport selected the generic profile. Preserve that
+metadata in MCP `_meta` for both profiles without making it serializable in model
+results. Page v5 shares one guided picker with `/integrations`, advertises exact
+standard/compatibility CSP origins, and keeps older resource aliases working.
+Missing grants, authorization, and cached setup tools have explicit recovery paths.
+
+Expand native setup from four providers to twelve without importing another
+application's credential library or state. Method-specific fields distinguish
+Composio project/organization and Convex personal/deployment credentials. Fix the
+Composio organization endpoint and use the dedicated read-only PAT verification
+endpoint for Convex. Schema-derived masking covers every secret field.
+
+Targeted security/contract tests and desktop/mobile browser fixtures prove catalog
+navigation, guidance before sign-in, retry, safe save, input cleanup and no key in
+MCP messages. Provider key verification and full upstream OAuth remain distinct;
+synthetic browser tests are not evidence of a user's successful authorization.
+
+Fixed a missing MCP Apps host initialization handshake, wrapped tool-result handling and
+repeated iframe remounts on unchanged globals. Page v3 now waits for an origin/source-checked
+app readiness message, displays bounded retry/direct-production actions, and preserves the
+cached v2 URI as a read-only alias. The exact reviewed iframe registry and Block-only approval
+contract remain unchanged. Targeted contracts and a desktop/mobile browser harness validate
+both standard MCP and legacy ChatGPT host paths. Toolset: `2026.09.05.1`.
+
+# mso — Progress Log
+- **Native integration preservation (2026-09-05):** merged published c164dbe without dropping the concurrent native credential setup. The short README retains its documentation link (99 lines). MCP 1.12.0 / toolset 2026.09.05.4 labels the combined maintenance, service-token, Page-readiness and native-integration contracts. This merge does not execute maintenance or reset real credentials.
+- **Concurrent main reconciliation (2026-09-05):** preserved published MCP Page initialization/readiness changes e46c417 + changelog c4856d2 in the maintenance/PR integration branch without modifying the other session's unpublished work. MCP 1.11.1 / toolset 2026.09.05.2 records the combined compatible contract. The Settings maintenance files are unchanged from the isolated desktop/mobile acceptance at 2164d29; full repository and GitHub gates are rerun for the combined source.
+- **PR integration validation (2026-09-05):** preserve the reviewed PR36/PR37 ancestry while repairing PR38 glob escaping/native Bun audit checks and PR37 code-generating visual-test fixtures. Direct-image boundary tests now cover malformed content and size/type limits. MCP server 1.11.0 / toolset 2026.09.05.1 records the compatible restricted-service-token/direct-image contract; widget resources and ordinary OAuth token behavior are unchanged. Publication still requires complete current-head local and remote gates, including late CodeQL findings—not only the workflow completion status.
+- **Reviewed 9Router network boundary (PR36, 2026-09-05):** reuse the configured internal proxy network only when it already exists; Docker host publishing remains loopback-only unless explicitly enabled. This supports a containerized reverse proxy without opening the application port to the public interface. The update adds no automatic network creation or DNS mutation. The old PR lifecycle-test failure must be rechecked against the combined current baseline before publication.
+
+
## 2026-09-05 — Integration setup recovery and complete browser navigation
The previous setup document exposed a clickable setup button before Owner sign-in,
diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.md
index c3eb1644..9f612821 100644
--- a/docs/generated/MCP-CATALOG.md
+++ b/docs/generated/MCP-CATALOG.md
@@ -10,7 +10,7 @@
|---|---:|
| MCP server | `1.12.0` |
| Toolset | `2026.09.05.5` |
-| Toolset changed at | `2026-09-05T12:36:17Z` |
+| Toolset changed at | `2026-09-05T12:32:00Z` |
| Transport tools | **91** |
| Model/operator tools | **89** |
| Read | **44** |
diff --git a/lib/infra/additional-doctor.test.ts b/lib/infra/additional-doctor.test.ts
new file mode 100644
index 00000000..dfca0ab0
--- /dev/null
+++ b/lib/infra/additional-doctor.test.ts
@@ -0,0 +1,52 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+vi.mock("server-only", () => ({}));
+import { doctorAdditionalProvider } from "./additional-doctor";
+import { integrationCatalog } from "./setup-catalog";
+import { setupFields } from "./setup-guidance";
+import { summarizeInfraProvider } from "./store";
+const KEY = "synthetic_api_credential_for_unit_test";
+afterEach(() => vi.unstubAllGlobals());
+describe("additional native credential providers", () => {
+ it("exposes twelve native providers with guided method-specific fields", () => {
+ const catalog = integrationCatalog(); expect(catalog).toHaveLength(12);
+ for (const p of catalog) for (const m of p.methods) {
+ expect(m.fields.length).toBeGreaterThan(0); expect(m.guidance.steps.length).toBeGreaterThan(1);
+ expect(m.guidance.url).toMatch(/^https:\/\//); expect(m.guidance.reference).toMatch(/^https:\/\//);
+ }
+ expect(setupFields("convex-cloud", "personal").map(f => f.key)).toEqual(["personalToken"]);
+ expect(setupFields("convex-cloud", "deployment").map(f => f.key)).toEqual(["deployKey", "deploymentName"]);
+ expect(() => setupFields("convex-cloud", "organization")).toThrow();
+ });
+ it.each([
+ ["github", "https://api.github.com/user", { apiKey: KEY }],
+ ["vercel", "https://api.vercel.com/v2/user", { apiKey: KEY }],
+ ["resend", "https://api.resend.com/domains", { apiKey: KEY }],
+ ["stripe", "https://api.stripe.com/v1/account", { apiKey: KEY }],
+ ["clerk", "https://api.clerk.com/v1/users?limit=1", { apiKey: KEY }],
+ ["supabase", "https://api.supabase.com/v1/projects", { managementToken: KEY }],
+ ["convex-cloud", "https://api.convex.dev/v1/list_personal_access_tokens?limit=1", { personalToken: KEY }],
+ ])("checks %s at a fixed provider-owned endpoint", async (id, endpoint, values) => {
+ const mock = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => new Response("[]", { status: 200 })); vi.stubGlobal("fetch", mock);
+ const result = await doctorAdditionalProvider(id as string, values as Record<string, string>);
+ expect(result).toContain("authenticated"); expect(result).not.toContain(KEY);
+ expect(mock.mock.calls[0]?.[0]).toBe(endpoint);
+ });
+ it("never echoes reflected provider errors or request secrets", async () => {
+ vi.stubGlobal("fetch", vi.fn(async () => new Response(KEY, { status: 401 })));
+ await expect(doctorAdditionalProvider("github", { apiKey: KEY })).rejects.toThrow("GitHub HTTP 401");
+ vi.stubGlobal("fetch", vi.fn(async () => { throw new Error(KEY); }));
+ await expect(doctorAdditionalProvider("github", { apiKey: KEY })).rejects.toThrow("GitHub request failed");
+ });
+ it("rejects arbitrary Convex targets before sending any key", async () => {
+ const mock = vi.fn(); vi.stubGlobal("fetch", mock);
+ for (const apiUrl of ["http://169.254.169.254/", "https://owner:[email protected]", "https://example.com/?credential=x"])
+ await expect(doctorAdditionalProvider("convex", { apiUrl, adminKey: KEY })).rejects.toThrow("invalid deployment URL");
+ await expect(doctorAdditionalProvider("convex-cloud", { deployKey: KEY, deploymentName: "test.example.com/" })).rejects.toThrow();
+ expect(mock).not.toHaveBeenCalled();
+ });
+ it("derives redaction from the field schema for every secret key name", () => {
+ expect(JSON.stringify(summarizeInfraProvider("convex-cloud", { personalToken: KEY }))).not.toContain(KEY);
+ expect(JSON.stringify(summarizeInfraProvider("convex", { adminKey: KEY, apiUrl: "https://convex.example.com" }))).not.toContain(KEY);
+ expect(JSON.stringify(summarizeInfraProvider("supabase", { managementToken: KEY }))).not.toContain(KEY);
+ });
+});
diff --git a/lib/infra/additional-doctor.ts b/lib/infra/additional-doctor.ts
new file mode 100644
index 00000000..2c67afc8
--- /dev/null
+++ b/lib/infra/additional-doctor.ts
@@ -0,0 +1,125 @@
+import { safeProviderFetch } from "@/lib/host/ssrf";
+import { obj, request, TIMEOUT_MS } from "./http";
+
+const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
+
+function present(value: string | undefined): value is string {
+ return typeof value === "string" && value.trim().length > 0;
+}
+
+/** A bounded SSRF-safe transport for an explicitly configured Convex endpoint. */
+function convexFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
+ const requestInput = new Request(input, { ...init, redirect: "error" });
+ const host = new URL(requestInput.url).hostname.replace(/^\[|\]$/g, "").toLowerCase();
+ if (LOOPBACK_HOSTS.has(host)) return fetch(requestInput);
+ return safeProviderFetch(requestInput);
+}
+
+function selfHostedDeploymentInfoUrl(rawUrl: string): string {
+ let url: URL;
+ try {
+ url = new URL(rawUrl.trim());
+ } catch {
+ throw new Error("Convex invalid deployment URL");
+ }
+ if (url.username || url.password || url.search || url.hash) throw new Error("Convex invalid deployment URL");
+ const host = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK_HOSTS.has(host))) {
+ throw new Error("Convex invalid deployment URL");
+ }
+ url.pathname = "/api/v1/deployment_info";
+ return url.toString();
+}
+
+function cloudDeploymentInfoUrl(name: string): string {
+ const clean = name.trim().toLowerCase();
+ // Deployment names are hostname labels, not URLs. This keeps the request fixed
+ // to Convex Cloud and avoids accepting an attacker-controlled authority.
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(clean)) throw new Error("Convex Cloud invalid deployment name");
+ return `https://${clean}.convex.cloud/api/v1/deployment_info`;
+}
+
+async function checked(provider: string, url: string, headers: HeadersInit, fetchImpl?: typeof fetch): Promise<Awaited<ReturnType<typeof request>>> {
+ let response;
+ try { response = await request(url, { headers }, TIMEOUT_MS, fetchImpl); }
+ catch { throw new Error(`${provider} request failed`); }
+ if (!response.ok) throw new Error(`${provider} HTTP ${response.status}`);
+ return response;
+}
+
+function countRows(body: unknown): number {
+ if (Array.isArray(body)) return body.length;
+ const value = obj(body);
+ for (const key of ["data", "domains", "projects"]) if (Array.isArray(value[key])) return value[key].length;
+ return 0;
+}
+
+/**
+ * Verifies additional provider credentials without logging secrets or exposing
+ * provider response payloads. A non-null result proves authentication at the
+ * checked endpoint, not every permission needed by a later operation.
+ */
+export async function doctorAdditionalProvider(id: string, values: Record<string, string>): Promise<string | null> {
+ switch (id) {
+ case "github": {
+ if (!present(values.apiKey)) return null;
+ await checked("GitHub", "https://api.github.com/user", {
+ authorization: `Bearer ${values.apiKey}`,
+ accept: "application/vnd.github+json",
+ "user-agent": "MSO-integration-doctor",
+ "x-github-api-version": "2022-11-28",
+ });
+ // request intentionally does not return response headers. Therefore this
+ // doctor never claims repo scope: authentication is all it can prove here.
+ return "authenticated; repository scope not verified";
+ }
+ case "vercel": {
+ if (!present(values.apiKey)) return null;
+ await checked("Vercel", "https://api.vercel.com/v2/user", { authorization: `Bearer ${values.apiKey}`, accept: "application/json" });
+ return "authenticated; account access verified";
+ }
+ case "resend": {
+ if (!present(values.apiKey)) return null;
+ const response = await checked("Resend", "https://api.resend.com/domains", { authorization: `Bearer ${values.apiKey}`, accept: "application/json" });
+ return `authenticated; ${countRows(response.body)} accessible domain(s)`;
+ }
+ case "stripe": {
+ if (!present(values.apiKey)) return null;
+ await checked("Stripe", "https://api.stripe.com/v1/account", { authorization: `Bearer ${values.apiKey}`, accept: "application/json" });
+ return "authenticated; account access verified";
+ }
+ case "clerk": {
+ if (!present(values.apiKey)) return null;
+ await checked("Clerk", "https://api.clerk.com/v1/users?limit=1", { authorization: `Bearer ${values.apiKey}`, accept: "application/json" });
+ return "authenticated; Backend API access verified";
+ }
+ case "supabase": {
+ if (!present(values.managementToken)) return null;
+ const response = await checked("Supabase", "https://api.supabase.com/v1/projects", { authorization: `Bearer ${values.managementToken}`, accept: "application/json" });
+ return `authenticated; ${countRows(response.body)} accessible project(s)`;
+ }
+ case "convex-cloud": {
+ const deployKey = values.deployKey;
+ const deploymentName = values.deploymentName;
+ if (present(deployKey) || present(deploymentName)) {
+ if (!present(deployKey) || !present(deploymentName)) return null;
+ await checked("Convex Cloud", cloudDeploymentInfoUrl(deploymentName), { authorization: `Convex ${deployKey}`, accept: "application/json" });
+ return "authenticated; deployment access verified";
+ }
+ // The official OpenAPI explicitly declares PAT authentication here.
+ // Discard token inventory immediately; only authentication status escapes.
+ if (present(values.personalToken)) {
+ await checked("Convex Cloud", "https://api.convex.dev/v1/list_personal_access_tokens?limit=1", { authorization: `Bearer ${values.personalToken}`, accept: "application/json" });
+ return "personal access token authenticated; account read access verified";
+ }
+ return null;
+ }
+ case "convex": {
+ if (!present(values.apiUrl) || !present(values.adminKey)) return null;
+ await checked("Convex", selfHostedDeploymentInfoUrl(values.apiUrl), { authorization: `Convex ${values.adminKey}`, accept: "application/json" }, convexFetch);
+ return "authenticated; deployment access verified";
+ }
+ default:
+ throw new Error("unknown additional provider");
+ }
+}
diff --git a/lib/infra/additional-providers.ts b/lib/infra/additional-providers.ts
new file mode 100644
index 00000000..b79096c0
--- /dev/null
+++ b/lib/infra/additional-providers.ts
@@ -0,0 +1,97 @@
+type AdditionalField = {
+ key: string;
+ label: string;
+ secret: boolean;
+ required: boolean;
+ description: string;
+};
+
+type AdditionalProvider = {
+ id: string;
+ title: string;
+ description: string;
+ feature: false;
+ fields: readonly AdditionalField[];
+};
+
+/**
+ * Additional native service credentials. The main registry owns all definitions.
+ */
+export const ADDITIONAL_PROVIDERS = {
+ github: {
+ id: "github",
+ title: "GitHub",
+ description: "Verify a GitHub personal access token for API access.",
+ feature: false,
+ fields: [{ key: "apiKey", label: "Personal access token (classic)", secret: true, required: true, description: "A GitHub classic personal access token. Repository access depends on the token's scopes and organization policy." }],
+ },
+ vercel: {
+ id: "vercel",
+ title: "Vercel",
+ description: "Verify a Vercel API token for the selected account.",
+ feature: false,
+ fields: [{ key: "apiKey", label: "API token", secret: true, required: true, description: "A Vercel API token. Access is limited by the token owner and any team permissions." }],
+ },
+ "convex-cloud": {
+ id: "convex-cloud",
+ title: "Convex Cloud",
+ description: "Store a Convex Cloud personal token or verify a deployment key for a named deployment.",
+ feature: false,
+ fields: [
+ { key: "personalToken", label: "Personal access token", secret: true, required: false, description: "Convex Cloud personal access token. Validated through the PAT-authenticated read-only account endpoint." },
+ { key: "deployKey", label: "Deployment key", secret: true, required: false, description: "Convex deployment key used with the deployment name below." },
+ { key: "deploymentName", label: "Deployment name", secret: false, required: false, description: "Convex deployment hostname prefix. Required together with a deployment key; method-specific requirements are enforced by the UI." },
+ ],
+ },
+ convex: {
+ id: "convex",
+ title: "Self-hosted Convex",
+ description: "Verify a self-hosted Convex deployment using its admin key.",
+ feature: false,
+ fields: [
+ { key: "apiUrl", label: "Deployment URL", secret: false, required: true, description: "HTTPS deployment URL; HTTP is allowed only for a loopback deployment on this VPS." },
+ { key: "adminKey", label: "Admin key", secret: true, required: true, description: "Convex admin key for this deployment." },
+ ],
+ },
+ resend: {
+ id: "resend",
+ title: "Resend",
+ description: "Verify a Resend API key and inspect accessible sending domains.",
+ feature: false,
+ fields: [{ key: "apiKey", label: "API key", secret: true, required: true, description: "A Resend API key. Domain access and sending permissions depend on the key's scope." }],
+ },
+ stripe: {
+ id: "stripe",
+ title: "Stripe",
+ description: "Verify a Stripe secret key for account API access.",
+ feature: false,
+ fields: [{ key: "apiKey", label: "Secret key", secret: true, required: true, description: "A Stripe secret key for the intended account and mode." }],
+ },
+ clerk: {
+ id: "clerk",
+ title: "Clerk",
+ description: "Verify a Clerk secret key for Backend API access.",
+ feature: false,
+ fields: [{ key: "apiKey", label: "Secret key", secret: true, required: true, description: "A Clerk secret key. Access remains subject to the associated Clerk instance." }],
+ },
+ supabase: {
+ id: "supabase",
+ title: "Supabase",
+ description: "Verify a Supabase management access token and list accessible projects.",
+ feature: false,
+ fields: [{ key: "managementToken", label: "Management access token", secret: true, required: true, description: "A Supabase personal access token for the Management API; it is distinct from project API keys." }],
+ },
+} as const satisfies Record<string, AdditionalProvider>;
+
+export type AdditionalProviderId = keyof typeof ADDITIONAL_PROVIDERS;
+
+export const ADDITIONAL_GUIDANCE = {
+ github: { url: "https://github.com/settings/tokens/new", reference: "https://docs.github.com/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens", steps: ["Open GitHub token settings while signed in to the intended account.", "Choose Generate new token (classic).", "Set an expiry and select only the scopes required for the intended automation; repository access generally requires the repo scope.", "Copy the token once and store it here. Organization policies can still limit its access."] },
+ vercel: { url: "https://vercel.com/account/tokens", reference: "https://vercel.com/docs/rest-api#creating-an-access-token", steps: ["Open Account Settings → Tokens in Vercel.", "Create a token with an expiry appropriate for this integration.", "Use the account or team that owns the intended Vercel resources.", "Copy the token into this form; its permissions are determined by that account or team membership."] },
+ "convex-cloud": { url: "https://dashboard.convex.dev", reference: "https://docs.convex.dev/management-api", steps: ["Open the Convex dashboard for the intended account or deployment.", "Create the personal access token or deployment key appropriate to the operation you intend to perform.", "For a deployment key, also enter its exact deployment name.", "Copy the credential once and keep it scoped to the minimum needed access."] },
+ convex: { url: "https://docs.convex.dev/self-hosting", reference: "https://docs.convex.dev/self-hosting", steps: ["Open the administration settings for your self-hosted Convex deployment.", "Generate an admin key using the official self-hosting instructions; never use a cloud project key for a different deployment.", "Enter the deployment's HTTPS URL; loopback HTTP is only suitable for a deployment on this VPS.", "Copy the admin key into this form and restrict network access to the deployment." ] },
+ resend: { url: "https://resend.com/api-keys", reference: "https://resend.com/docs/dashboard/api-keys/introduction", steps: ["Open API Keys in the Resend dashboard.", "Create a key for the intended environment.", "Choose Full access only when domain management is required. Sending-only keys cannot pass the domain-list check.", "Copy the key once; verified domains and account policy still control sending access."] },
+ stripe: { url: "https://dashboard.stripe.com/apikeys", reference: "https://docs.stripe.com/keys", steps: ["Open Developers → API keys in the intended Stripe account.", "Use a restricted key when its available permissions cover the integration.", "Confirm whether you are using test or live mode before copying the secret key.", "Copy the key once and rotate it promptly if it is exposed."] },
+ clerk: { url: "https://dashboard.clerk.com", reference: "https://clerk.com/docs/guides/development/api-keys", steps: ["Open the intended Clerk instance in the Clerk dashboard.", "Find its secret key in the API Keys or Developers settings.", "Keep the key server-side and limit access to the intended instance.", "Copy it into this form; this check only confirms Backend API authentication."] },
+ supabase: { url: "https://supabase.com/dashboard/account/tokens", reference: "https://supabase.com/docs/reference/api/introduction", steps: ["Open Account → Access Tokens in the Supabase dashboard.", "Generate a personal access token for the account that owns the intended projects.", "Give it a clear name and an appropriate expiry.", "Copy it once into this form; project API keys cannot be used as Management API tokens."] },
+} as const satisfies Record<AdditionalProviderId, { url: string; reference: string; steps: readonly string[] }>;
diff --git a/lib/infra/catalog.ts b/lib/infra/catalog.ts
index a1d6f2d1..ad04b48d 100644
--- a/lib/infra/catalog.ts
+++ b/lib/infra/catalog.ts
@@ -1,6 +1,9 @@
+import { ADDITIONAL_PROVIDERS, type AdditionalProviderId } from "./additional-providers";
import { INFRA_PROVIDER_IDS, type InfraProviderDefinition, type InfraProviderId, type InfraProviderValues } from "./types";
+const additional = Object.fromEntries(Object.entries(ADDITIONAL_PROVIDERS).map(([id, value]) => [id, { ...value, fields: value.fields.map(f => ({ ...f })) }])) as Record<AdditionalProviderId, InfraProviderDefinition>;
const definitions: Record<InfraProviderId, InfraProviderDefinition> = {
+ ...additional,
dokploy: {
id: "dokploy",
title: "Dokploy",
@@ -30,7 +33,7 @@ const definitions: Record<InfraProviderId, InfraProviderDefinition> = {
feature: false,
fields: [
{ key: "apiKey", label: "Project API key", secret: true, required: false, description: "Project key sent only as x-api-key to /api/v3.1/tools?limit=1." },
- { key: "orgApiKey", label: "Organization API key", secret: true, required: false, description: "Organization key sent only as x-org-api-key to /api/v3.1/org/project/list." },
+ { key: "orgApiKey", label: "Organization API key", secret: true, required: false, description: "Organization key sent only as x-org-api-key to /api/v3.1/org/owner/project/list." },
],
},
hostinger: {
@@ -60,6 +63,7 @@ export function normalizeInfraValues(id: InfraProviderId, raw: Record<string, un
for (const [key, value] of Object.entries(raw)) {
if (!allowed.has(key) || typeof value !== "string") continue;
const clean = value.trim();
+ if (clean.length > 4096 || /[\x00-\x1f\x7f]/.test(clean)) throw new Error("Invalid integration field format");
if (clean) out[key] = clean;
}
if (id === "dokploy" && out.apiUrl) {
@@ -86,6 +90,11 @@ export function normalizeInfraValues(id: InfraProviderId, raw: Record<string, un
if (id === "composio") {
for (const value of Object.values(out)) if (value.length < 16 || value.length > 4096 || /[\s\x00-\x1f\x7f]/.test(value)) throw new Error("Composio keys must be opaque single-line values (16–4096 characters)");
}
+ if (id === "convex-cloud" && out.deploymentName && !/^[a-z0-9][a-z0-9-]{1,62}$/.test(out.deploymentName)) throw new Error("Invalid deployment name");
+ if (id === "convex" && out.apiUrl) {
+ let url: URL; try { url = new URL(out.apiUrl); } catch { throw new Error("Invalid deployment URL"); }
+ if (url.username || url.password || url.search || url.hash || (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))) throw new Error("Invalid deployment URL");
+ }
if (id === "hostinger" && out.apiToken && out.apiToken.length < 24) throw new Error("Hostinger API token is too short");
return out;
}
diff --git a/lib/infra/clients.ts b/lib/infra/clients.ts
index c48634e9..d2ffb266 100644
--- a/lib/infra/clients.ts
+++ b/lib/infra/clients.ts
@@ -1,3 +1,5 @@
+import { doctorAdditionalProvider } from "./additional-doctor";
+import { readInfraProvider } from "./store";
import type { InfraDoctorResult, InfraProviderId, InfraProviderValues } from "./types";
import { doctorCloudflare } from "./cloudflare";
import { doctorDokploy } from "./dokploy";
@@ -16,7 +18,7 @@ export async function doctorInfraProvider(id: InfraProviderId, candidate?: Infra
? await doctorCloudflare(candidate)
: id === "composio"
? await doctorComposio(candidate)
- : await doctorHostinger(candidate);
+ : id === "hostinger" ? await doctorHostinger(candidate) : await doctorAdditionalProvider(id, candidate ?? await readInfraProvider(id));
return detail === null ? { id, ok: null, detail: "not configured" } : { id, ok: true, detail };
} catch (error) {
return { id, ok: false, detail: (error as Error).message.slice(0, 300) };
diff --git a/lib/infra/composio.ts b/lib/infra/composio.ts
index 3cfee136..024f4417 100644
--- a/lib/infra/composio.ts
+++ b/lib/infra/composio.ts
@@ -8,7 +8,7 @@ export async function doctorComposio(candidate?: InfraProviderValues): Promise<s
const key = values.apiKey;
const orgKey = values.orgApiKey;
if (!key && !orgKey) return null;
- const target = orgKey ? "/org/project/list" : "/tools?limit=1";
+ const target = orgKey ? "/org/owner/project/list" : "/tools?limit=1";
const header: Record<string, string> = orgKey ? { "x-org-api-key": orgKey } : { "x-api-key": key! };
const response = await request(`${API}${target}`, { headers: header });
if (!response.ok) throw new Error(`Composio validation failed (${response.status})`);
diff --git a/lib/infra/setup-browser.ts b/lib/infra/setup-browser.ts
new file mode 100644
index 00000000..68aa4e67
--- /dev/null
+++ b/lib/infra/setup-browser.ts
@@ -0,0 +1,46 @@
+export const INTEGRATION_BROWSER_SCRIPT = String.raw`
+(async()=>{
+ const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup";
+ let teardown=()=>{};
+ window.addEventListener("pagehide",()=>teardown(),{once:true});
+ const preset=new URLSearchParams(location.search);
+ function form(setup,token){teardown();teardown=mountIntegrationForm(root,setup,{endpoint,token,onBack:picker})||(()=>{})}
+ function picker(){
+ teardown();
+ const session={loading:true,authenticated:false,role:null};let disposed=false;const abort=new AbortController();
+ async function refreshAuth(){
+ if(disposed)return;
+ try{
+ const response=await fetch("/api/auth/me",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.any([abort.signal,AbortSignal.timeout(8000)])});
+ if(!response.ok)throw new Error("unavailable");
+ const data=await response.json();session.authenticated=data.authenticated===true;session.role=data.role;
+ }catch{session.authenticated=false;session.role=null}
+ if(disposed)return;session.loading=false;
+ const label=root.querySelector("#integration-auth-status");
+ if(label)label.textContent=session.role==="owner"?"Owner session ready. Credentials are never displayed.":session.authenticated?"This device is not an Owner. Use an approved Owner session to change credentials.":"Sign in to MSO as an owner to open a private form. The catalog and guidance remain available.";
+ for(const b of root.querySelectorAll("[data-integration-start]"))b.disabled=session.role!=="owner";
+ }
+ const visible=()=>{if(document.visibilityState!=="hidden")void refreshAuth()};
+ const disposePicker=mountIntegrationPicker(root,INTEGRATIONS_CATALOG,{
+ provider:preset.get("provider"),method:preset.get("method"),session,
+ browserLabel:"MSO sign-in",
+ openBrowser:()=>{window.open(location.origin+"/","_blank","noopener,noreferrer")},
+ openSetup:async(provider,method)=>{
+ const response=await fetch("/api/v1/infra/setup",{method:"POST",credentials:"same-origin",cache:"no-store",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider,method}),signal:AbortSignal.timeout(15000)});
+ if(response.status===401||response.status===403){await refreshAuth();throw new Error("Your Owner session is no longer available. Sign in using MSO sign-in, then return here.")}
+ if(!response.ok)throw new Error("Setup is temporarily unavailable. Check the selected method and retry.");
+ const data=await response.json();if(!data.setup||!data.token)throw new Error("Incomplete setup response. Reload this page.");form(data.setup,data.token);
+ }
+ });
+ document.addEventListener("visibilitychange",visible);window.addEventListener("focus",visible);
+ teardown=()=>{disposed=true;abort.abort();document.removeEventListener("visibilitychange",visible);window.removeEventListener("focus",visible);disposePicker()};
+ void refreshAuth();
+ }
+ let token=location.hash.slice(1);history.replaceState(null,"",location.pathname+location.search);
+ if(token){
+ try{const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"schema"}),signal:AbortSignal.timeout(12000)});if(!response.ok)throw new Error("This private form has expired or was already used. Open a new setup session below.");form(await response.json(),token);token="";return}
+ catch(error){picker();const note=integrationNode("p",error.message);note.className="picker-note";root.prepend(note);token="";return}
+ }
+ picker();
+})();
+`;
diff --git a/lib/infra/setup-capability.test.ts b/lib/infra/setup-capability.test.ts
index 22f0d74b..0ceedf37 100644
--- a/lib/infra/setup-capability.test.ts
+++ b/lib/infra/setup-capability.test.ts
@@ -61,7 +61,7 @@ describe("native integration setup capabilities", () => {
const grant = await api.openIntegrationSetup("composio", "test-owner", "organization");
await api.consumeIntegrationSetup(grant.token, { orgApiKey: KEY });
const [url, options] = vi.mocked(fetch).mock.calls[0];
- expect(String(url)).toContain("/api/v3.1/org/project/list"); expect(options?.headers).toEqual({ "x-org-api-key": KEY });
+ expect(String(url)).toContain("/api/v3.1/org/owner/project/list"); expect(options?.headers).toEqual({ "x-org-api-key": KEY });
expect(store.summarizeInfraProvider("composio", await store.readInfraProvider("composio")).values.orgApiKey).toBe("configured");
});
it("standalone page contains no grant and its inline script parses", async () => {
diff --git a/lib/infra/setup-catalog.ts b/lib/infra/setup-catalog.ts
new file mode 100644
index 00000000..304b89ed
--- /dev/null
+++ b/lib/infra/setup-catalog.ts
@@ -0,0 +1,9 @@
+import { listInfraProviderDefinitions } from "./catalog";
+import { setupFields, setupGuidance, setupMethods } from "./setup-guidance";
+// Pure display metadata only. No imports from credential storage.
+export function integrationCatalog() {
+ return listInfraProviderDefinitions().map(p => ({
+ id: p.id, title: p.title, description: p.description,
+ methods: setupMethods(p.id).map(method => ({ ...method, fields: setupFields(p.id, method.id), guidance: setupGuidance(p.id, method.id) })),
+ }));
+}
diff --git a/lib/infra/setup-guidance.ts b/lib/infra/setup-guidance.ts
index 3b0dae99..82b75030 100644
--- a/lib/infra/setup-guidance.ts
+++ b/lib/infra/setup-guidance.ts
@@ -1,8 +1,14 @@
+import { ADDITIONAL_GUIDANCE, type AdditionalProviderId } from "./additional-providers";
import { getInfraProviderDefinition } from "./catalog";
import type { InfraProviderId } from "./types";
-export type SetupMethod = "direct" | "project" | "organization";
+export type SetupMethod = "direct" | "project" | "organization" | "personal" | "deployment";
export function setupFields(provider: InfraProviderId, method: SetupMethod) {
+ if (provider === "convex-cloud") {
+ if (!["personal", "deployment"].includes(method)) throw new Error("Choose a Convex personal token or deployment key");
+ const keys = method === "personal" ? ["personalToken"] : ["deployKey", "deploymentName"];
+ return getInfraProviderDefinition(provider).fields.filter(f => keys.includes(f.key)).map(f => ({ ...f, required: true }));
+ }
if (provider === "composio") {
if (!["project", "organization"].includes(method)) throw new Error("Choose a Composio project or organization key");
return getInfraProviderDefinition(provider).fields.filter(f => f.key === (method === "project" ? "apiKey" : "orgApiKey")).map(f => ({ ...f, required: true }));
@@ -11,12 +17,18 @@ export function setupFields(provider: InfraProviderId, method: SetupMethod) {
return getInfraProviderDefinition(provider).fields;
}
export function setupMethod(provider: InfraProviderId, method?: string): SetupMethod {
- const value = method ?? (provider === "composio" ? "project" : "direct");
- if (!["direct", "project", "organization"].includes(value)) throw new Error("Unsupported authentication method");
+ const value = method ?? (provider === "composio" ? "project" : provider === "convex-cloud" ? "personal" : "direct");
+ if (!["direct", "project", "organization", "personal", "deployment"].includes(value)) throw new Error("Unsupported authentication method");
setupFields(provider, value as SetupMethod);
return value as SetupMethod;
}
+export function setupMethods(provider: InfraProviderId): Array<{id: SetupMethod; label: string}> {
+ if (provider === "composio") return [{ id: "project", label: "Project API key" }, { id: "organization", label: "Organization API key" }];
+ if (provider === "convex-cloud") return [{ id: "personal", label: "Personal access token" }, { id: "deployment", label: "Deployment key" }];
+ return [{ id: "direct", label: "Direct credential" }];
+}
export function setupGuidance(provider: InfraProviderId, method: SetupMethod) {
+ if (provider in ADDITIONAL_GUIDANCE) return ADDITIONAL_GUIDANCE[provider as AdditionalProviderId];
const guides = {
composio: {
url: "https://platform.composio.dev",
@@ -41,5 +53,5 @@ export function setupGuidance(provider: InfraProviderId, method: SetupMethod) {
steps: ["Open your own Dokploy panel, not a third-party panel.", "Open the account settings and create an API key.", "Enter the panel API URL. Use HTTPS, or loopback for a panel on this VPS.", "Copy the key into this form. MSO checks the project-list endpoint before saving."],
},
};
- return guides[provider];
+ return guides[provider as keyof typeof guides];
}
diff --git a/lib/infra/setup-hub.test.ts b/lib/infra/setup-hub.test.ts
index 01bcda01..c1c9a367 100644
--- a/lib/infra/setup-hub.test.ts
+++ b/lib/infra/setup-hub.test.ts
@@ -1,15 +1,16 @@
import { expect, it } from "vitest";
-import { setupCatalog, SETUP_HUB_SCRIPT } from "./setup-hub";
+import { integrationCatalog } from "./setup-catalog";
+import { INTEGRATION_PICKER_SCRIPT } from "./setup-picker";
import { INFRA_PROVIDER_IDS } from "./types";
import { integrationSetupPage } from "./setup-page";
it("derives the complete native setup catalog from the same provider registry", () => {
- const rows = setupCatalog(); expect(rows.map(p => p.id)).toEqual([...INFRA_PROVIDER_IDS]);
+ const rows = integrationCatalog(); expect(rows.map(p => p.id)).toEqual([...INFRA_PROVIDER_IDS]);
for (const p of rows) for (const method of p.methods) { expect(method.guidance.url).toMatch(/^https:/); expect(method.guidance.steps.length).toBeGreaterThan(1); }
expect(rows.find(p => p.id === "composio")?.methods.map(m => m.id)).toEqual(["project", "organization"]);
});
-it("public hub is usable before sign-in and offers explicit auth/expiry recovery", () => {
+it("keeps guidance before login and preserves explicit role/expiry recovery", () => {
const page = integrationSetupPage();
expect(() => new Function(page.html.match(/<script[^>]*>([\s\S]*?)<\/script>/)![1])).not.toThrow();
- for (const marker of ['"/api/auth/me"', 'start.disabled=userState.role!=="owner"', '"visibilitychange"', '"How to get this credential"', '"Open a new setup session"']) expect(page.html).toContain(marker);
- expect(SETUP_HUB_SCRIPT).not.toContain('localStorage'); expect(page.csp).toContain("form-action 'none'");
+ for (const marker of ['"/api/auth/me"', 'session.role!=="owner"', '"visibilitychange"', '"How to get this credential"', 'Open a new setup session']) expect(page.html).toContain(marker);
+ expect(INTEGRATION_PICKER_SCRIPT).not.toContain('localStorage'); expect(page.csp).toContain("form-action 'none'");
});
diff --git a/lib/infra/setup-hub.ts b/lib/infra/setup-hub.ts
deleted file mode 100644
index 80f68d9a..00000000
--- a/lib/infra/setup-hub.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { listInfraProviderDefinitions } from "./catalog";
-import { setupGuidance } from "./setup-guidance";
-
-export function setupCatalog() {
- return listInfraProviderDefinitions().map(p => ({
- id: p.id, title: p.title, description: p.description,
- methods: (p.id === "composio" ? ["project", "organization"] as const : ["direct"] as const).map(id => ({
- id, title: id === "direct" ? "API token" : `${id === "project" ? "Project" : "Organization"} API key`,
- guidance: setupGuidance(p.id, id),
- })),
- }));
-}
-export const SETUP_HUB_STYLE = String.raw`
-[hidden]{display:none!important}.integration{width:100%;min-width:0}.integration .hub-heading{display:flex;gap:16px;align-items:start;justify-content:space-between;flex-wrap:wrap}.integration .hub-layout{display:grid;grid-template-columns:minmax(180px,.75fr) minmax(0,1.8fr);gap:24px;margin-top:24px}.integration .hub-sidebar{display:grid;gap:8px;align-content:start}.integration .hub-provider{display:block;width:100%;text-align:left;font:inherit;border:1px solid var(--sep-strong);border-radius:12px;padding:12px;background:var(--field);color:var(--text);cursor:pointer}.integration .hub-provider[aria-pressed=true]{border-color:var(--os-accent);box-shadow:inset 3px 0 0 var(--os-accent)}.integration .hub-provider span{display:block;font-size:12px;color:var(--text-dim);margin-top:2px}.integration .hub-panel{min-width:0;padding:20px;border:1px solid var(--sep-strong);border-radius:16px;background:var(--field)}.integration .hub-auth{border:1px solid var(--sep-strong);border-radius:12px;padding:14px;margin:16px 0}.integration .hub-status{font-size:13px;min-height:24px}.integration .hub-search{margin-bottom:8px}.integration .hub-provider strong{font-size:14px}.integration .setup-tag{margin:0 0 12px}.integration .hub-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}.integration .hub-actions a{display:inline-flex;align-items:center;min-height:42px}.integration .hub-panel h3{margin:0 0 8px;font-size:20px}.integration .grid{grid-template-columns:repeat(2,minmax(0,1fr))}.integration .card strong{font-size:16px}.integration .card p{font-size:13px}.integration .hub-help{font-size:12px}.integration button:focus-visible,.integration a:focus-visible{outline:2px solid var(--os-accent);outline-offset:3px}@media(max-width:620px){.integration .grid{grid-template-columns:1fr}.integration .hub-layout{grid-template-columns:1fr;gap:16px}.integration .hub-sidebar{grid-template-columns:1fr 1fr}.integration .hub-search{grid-column:1/-1}.integration .hub-panel{padding:16px}.integration .hub-provider{padding:10px}}`;
-
-/** Display data only. Authentication is checked before presenting a usable Save path. */
-export const SETUP_HUB_SCRIPT = String.raw`
-function mountIntegrationHub(root,catalog){
- let userState={authenticated:false,role:null},selected=catalog.find(p=>p.id===new URLSearchParams(location.search).get("provider"))||catalog[0],busy=false,disposed=false;
- const endpoint=location.origin+"/api/integrations/setup";
- const n=integrationNode;root.replaceChildren();
- const head=n("div"),intro=n("div");head.className="hub-heading";intro.append(n("h2","Integrations"),n("p","Connect your services to MSO. Choose a provider, follow its guide, then enter the credential securely."));head.append(intro);root.append(head);
- const auth=n("div"),authText=n("p","Checking sign-in…"),authActions=n("div"),login=n("a","Sign in to MSO"),refresh=n("button","Check sign-in again");auth.className="hub-auth";authText.setAttribute("role","status");authActions.className="hub-actions";login.href="/";login.target="_blank";login.rel="noopener noreferrer";refresh.type="button";authActions.append(login,refresh);auth.append(authText,authActions);root.append(auth);
- const layout=n("div"),sidebar=n("nav"),panel=n("section"),search=n("input");layout.className="hub-layout";sidebar.className="hub-sidebar";sidebar.setAttribute("aria-label","Providers");panel.className="hub-panel";search.type="search";search.placeholder="Find a provider";search.setAttribute("aria-label","Find a provider");search.className="hub-search";sidebar.append(search);layout.append(sidebar,panel);root.append(layout);
- const buttons=[];
- for(const provider of catalog){const b=n("button"),title=n("strong",provider.title);b.type="button";b.className="hub-provider";b.append(title,n("span",provider.methods.length>1?"Choose key type":"Direct connection"));b.onclick=()=>{if(!busy){selected=provider;renderPanel()}};sidebar.append(b);buttons.push({provider,b})}
- search.oninput=()=>{for(const {provider,b} of buttons)b.hidden=!provider.title.toLowerCase().includes(search.value.toLowerCase())};
- function renderPanel(){
- if(disposed)return;panel.replaceChildren();for(const {provider,b} of buttons)b.setAttribute("aria-pressed",String(provider.id===selected.id));
- panel.append(n("h3",selected.title),n("p",selected.description));
- const label=n("label","Authentication method"),method=n("select");method.id="setup-method";label.htmlFor=method.id;
- for(const m of selected.methods){const option=n("option",m.title);option.value=m.id;method.append(option)}
- const desired=new URLSearchParams(location.search).get("method");if(selected.methods.some(m=>m.id===desired))method.value=desired;
- panel.append(label,method);
- const guide=n("details"),guideBody=n("div"),summary=n("summary","How to get this credential");guide.open=true;guide.append(summary,guideBody);panel.append(guide);
- function renderGuide(){guideBody.replaceChildren();const g=selected.methods.find(m=>m.id===method.value).guidance;for(const [url,text] of [[g.url,"Provider dashboard"],[g.reference,"Official documentation"]]){const a=n("a",text);a.href=url;a.target="_blank";a.rel="noopener noreferrer";const p=n("p");p.append(a);guideBody.append(p)}const list=n("ol");for(const step of g.steps)list.append(n("li",step));guideBody.append(list)}method.onchange=renderGuide;renderGuide();
- const actions=n("div"),start=n("button","Open secure form"),status=n("p");actions.className="hub-actions";start.type="button";start.className="primary";start.disabled=userState.role!=="owner";status.className="hub-status";status.setAttribute("role","status");status.textContent=userState.role==="owner"?"Ready. Existing keys stay hidden and are kept until validation succeeds.":"Read the guide now. Sign in with an approved Owner device to enter or change credentials.";actions.append(start);panel.append(actions,status,n("p","A form expires after ten minutes. MSO never asks you to put a key in chat."));
- start.onclick=async()=>{if(busy||start.disabled)return;busy=true;start.disabled=true;status.textContent="Opening your secure form…";try{const r=await fetch("/api/v1/infra/setup",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:selected.id,method:method.value}),signal:AbortSignal.timeout(15000)});const data=await r.json();if(!r.ok){if(r.status===403){await refreshAuth();throw new Error("Your Owner session is no longer available. Sign in again.")}throw new Error("Setup is temporarily unavailable. Retry without changing your existing credentials.")}disposed=true;removeListeners();const back=n("button","← All integrations");back.type="button";const host=n("div"),formRoot=n("div");root.replaceChildren(back,host);host.append(formRoot);let cleanup=mountIntegrationForm(formRoot,data.setup,{endpoint,token:data.token});back.onclick=()=>{cleanup?.();mountIntegrationHub(root,catalog)}}catch(e){status.textContent=e.message;start.disabled=userState.role!=="owner"}finally{busy=false}};
- }
- async function refreshAuth(){if(disposed)return;refresh.disabled=true;try{const r=await fetch("/api/auth/me",{cache:"no-store",credentials:"same-origin",signal:AbortSignal.timeout(8000)});if(!r.ok)throw new Error();userState=await r.json();authText.textContent=userState.role==="owner"?"Owner session ready. Your credentials are stored only on this MSO server.":userState.authenticated?"You are signed in, but credential changes require an approved Owner device.":"You are not signed in. Open MSO sign-in, then return to this page.";login.hidden=userState.role==="owner";renderPanel()}catch{authText.textContent="Cannot reach MSO. Check your connection, then retry."}finally{refresh.disabled=false}}
- function visible(){if(document.visibilityState==="visible")refreshAuth()}function removeListeners(){window.removeEventListener("focus",refreshAuth);document.removeEventListener("visibilitychange",visible)}
- refresh.onclick=refreshAuth;window.addEventListener("focus",refreshAuth);document.addEventListener("visibilitychange",visible);renderPanel();refreshAuth();
-}
-`;
diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.ts
index 33d91875..962b1490 100644
--- a/lib/infra/setup-page.ts
+++ b/lib/infra/setup-page.ts
@@ -1,12 +1,16 @@
import { randomBytes } from "node:crypto";
import { MSO_WIDGET_TOKENS } from "@/lib/presentation/widget-tokens";
import { INTEGRATION_FORM_SCRIPT, INTEGRATION_FORM_STYLE } from "./setup-ui";
-import { setupCatalog, SETUP_HUB_SCRIPT, SETUP_HUB_STYLE } from "./setup-hub";
-
+import { INTEGRATION_PICKER_SCRIPT, INTEGRATION_PICKER_STYLE } from "./setup-picker";
+import { INTEGRATION_BROWSER_SCRIPT } from "./setup-browser";
+import { integrationCatalog } from "./setup-catalog";
export function integrationSetupPage() {
const nonce = randomBytes(18).toString("base64");
- const catalog = JSON.stringify(setupCatalog()).replace(/</g, "\\u003c");
- const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>MSO Integrations</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_FORM_STYLE}${SETUP_HUB_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(18px,4vw,50px);font-family:var(--font-body);color:var(--text)}header{max-width:850px;margin:0 auto 24px;font-size:13px}button{border:1px solid var(--sep-strong);border-radius:10px;background:var(--field);color:var(--text);padding:9px 15px;cursor:pointer}select{margin:8px 0 16px}a{color:var(--os-accent)}</style></head><body><header>MSO / Integrations</header><main id="setup" class="integration"><p>Loading integrations…</p></main><noscript>JavaScript is needed for secure credential setup. Use the MSO terminal as an alternative.</noscript><script nonce="${nonce}">${INTEGRATION_FORM_SCRIPT}${SETUP_HUB_SCRIPT}
-(async()=>{const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup",catalog=${catalog};let token=location.hash.slice(1);history.replaceState(null,"",location.pathname+location.search);if(!token){mountIntegrationHub(root,catalog);return}root.replaceChildren(integrationNode("p","Checking secure setup session…"));try{const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"schema"}),signal:AbortSignal.timeout(12000)});if(!response.ok)throw new Error("This private setup session expired or was already used.");const setup=await response.json();const cleanup=mountIntegrationForm(root,setup,{endpoint,token});token="";window.addEventListener("pagehide",()=>cleanup?.(),{once:true})}catch{token="";root.replaceChildren(integrationNode("h2","Setup session unavailable"),integrationNode("p","The link may have expired or already been used. Your stored credentials have not changed."));const retry=integrationNode("button","Open a new setup session");retry.type="button";retry.onclick=()=>mountIntegrationHub(root,catalog);root.append(retry)}})();</script></body></html>`;
+ const catalog = JSON.stringify(integrationCatalog()).replace(/</g,"\\u003c");
+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>Integrations · MSO</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_FORM_STYLE}${INTEGRATION_PICKER_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(16px,3vw,40px);font-family:var(--font-body);color:var(--text)}.site-bar{max-width:1100px;margin:0 auto 26px;font-size:13px;display:flex;justify-content:space-between;gap:12px}.site-bar strong{font-weight:750}.site-bar span{color:var(--text-dim)}button{border:1px solid var(--sep-strong);border-radius:9px;background:var(--field);color:var(--text);padding:9px 13px;cursor:pointer}a{color:var(--os-accent)}</style></head><body><header class="site-bar"><strong>MSO / Integrations</strong><span>Native · Private credential setup</span></header><main id="setup" class="integration"><h1>Integrations</h1><p>Preparing the native provider catalog…</p><noscript>Enable JavaScript to open the secure credential form. Credentials can also be entered through the MSO terminal.</noscript></main><script nonce="${nonce}">const INTEGRATIONS_CATALOG=${catalog};${INTEGRATION_FORM_SCRIPT}${INTEGRATION_PICKER_SCRIPT}${INTEGRATION_BROWSER_SCRIPT}</script></body></html>`;
return { html, csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; form-action 'none'; base-uri 'none'; frame-ancestors 'none'` };
}
+export function integrationPageResponse() {
+ const page = integrationSetupPage();
+ return new Response(page.html,{headers:{"Content-Type":"text/html; charset=utf-8","Content-Security-Policy":page.csp,"Cache-Control":"no-store, private","Referrer-Policy":"no-referrer","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY"}});
+}
diff --git a/lib/infra/setup-picker.ts b/lib/infra/setup-picker.ts
new file mode 100644
index 00000000..9d2036b7
--- /dev/null
+++ b/lib/infra/setup-picker.ts
@@ -0,0 +1,35 @@
+export const INTEGRATION_PICKER_STYLE = String.raw`
+.integration{max-width:1100px;width:100%;margin:0 auto}.integration .picker-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px}.integration .picker-header h2{margin:0;font-size:26px}.integration .picker-header p{max-width:630px;margin:7px 0}.integration .picker-layout{display:grid;grid-template-columns:minmax(210px,280px) minmax(0,1fr);gap:22px}.integration .provider-list{display:grid;gap:7px;margin-top:12px;max-height:490px;overflow:auto;padding-right:4px}.integration .provider-option{display:block;text-align:left;width:100%;border:1px solid var(--sep-strong);background:var(--field);color:var(--text);padding:11px 12px;border-radius:10px;font:600 14px var(--font-body);cursor:pointer}.integration .provider-option[aria-pressed=true]{border-color:var(--os-accent);background:color-mix(in srgb,var(--os-accent) 12%,var(--surface))}.integration .provider-option small{margin-top:2px;font-size:11px;font-weight:400}.integration .provider-detail{border:1px solid var(--sep-strong);border-radius:14px;padding:20px;background:var(--field);min-width:0}.integration .provider-detail h3{font:700 22px var(--font-display);margin:0 0 8px}.integration .provider-detail label{font-size:13px}.integration .provider-fields{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0 18px}.integration .field-tag{font:12px var(--font-body);padding:5px 9px;border:1px solid var(--sep-strong);border-radius:7px;color:var(--text-dim)}.integration .picker-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:18px}.integration .picker-note{padding:12px 14px;border-left:3px solid var(--os-accent);background:color-mix(in srgb,var(--os-accent) 7%,var(--surface));border-radius:7px;font-size:12px}.integration .picker-feedback{min-height:22px;margin:10px 0 0;font-size:13px;overflow-wrap:anywhere}.integration .back-link{margin-bottom:14px}.integration [type=search]{font-size:15px}.integration .setup-grid{margin-top:18px}@media(max-width:640px){.integration .picker-layout{grid-template-columns:1fr;gap:14px}.integration .provider-list{grid-template-columns:repeat(2,minmax(0,1fr));max-height:220px;padding:0}.integration .provider-detail{padding:15px}.integration .picker-header{display:block}.integration .provider-option{min-height:55px}}@media(max-width:360px){.integration .provider-list{grid-template-columns:1fr}}
+`;
+export const INTEGRATION_PICKER_SCRIPT = String.raw`
+function mountIntegrationPicker(root,catalog,options={}){
+ root.replaceChildren();root.classList.add("integration");
+ const node=(tag,text,className)=>{const n=integrationNode(tag,text);if(className)n.className=className;return n};
+ const button=(label,handler,className)=>{const b=node("button",label,className);b.type="button";b.addEventListener("click",handler);return b};
+ const header=node("header",undefined,"picker-header"),head=node("div");head.append(node("h2","Integrations"),node("p","Connect services directly to MSO. Review the official steps first, then enter your credential in a private form."));header.append(head);if(options.session){const status=node("p","Checking MSO session…","picker-note");status.id="integration-auth-status";status.setAttribute("role","status");header.append(status)}root.append(header);
+ const layout=node("div",undefined,"picker-layout"),directory=node("section"),detail=node("section",undefined,"provider-detail"),list=node("div",undefined,"provider-list"),search=node("input");
+ search.type="search";search.placeholder="Search "+catalog.length+" services";search.setAttribute("aria-label","Search integrations");directory.append(search,list);layout.append(directory,detail);root.append(layout);
+ let selected=catalog.find(p=>p.id===options.provider)||catalog.find(p=>p.id==="composio")||catalog[0];
+ function trustedLink(url,text,feedback){const a=node("a",text);try{const u=new URL(url);if(u.protocol!=="https:")return node("span",text);a.href=u.href}catch{return node("span",text)}a.target="_blank";a.rel="noopener noreferrer";if(options.openLink)a.addEventListener("click",e=>{e.preventDefault();Promise.resolve(options.openLink(a.href)).catch(()=>{feedback.textContent="The chat host could not open this link. Open the provider dashboard in your browser."})});return a}
+ function drawList(){list.replaceChildren();for(const p of catalog.filter(p=>(p.title+" "+p.description).toLowerCase().includes(search.value.toLowerCase()))){const b=button("",()=>{selected=p;drawList();drawDetail()},"provider-option");b.setAttribute("aria-pressed",String(p.id===selected.id));b.append(node("span",p.title),node("small",p.methods.length>1?p.methods.length+" authentication methods":"Direct credential"));list.append(b)}if(!list.children.length)list.append(node("p","No services matched."))}
+ function drawDetail(){
+ detail.replaceChildren(node("h3",selected.title),node("p",selected.description));
+ const methodLabel=node("label","Authentication method"),select=node("select"),preview=node("div"),feedback=node("p",undefined,"picker-feedback");select.id="integration-auth-method";methodLabel.htmlFor=select.id;feedback.setAttribute("role","status");feedback.setAttribute("aria-live","polite");
+ for(const method of selected.methods){const o=node("option",method.label);o.value=method.id;select.append(o)}if(options.method&&selected.methods.some(m=>m.id===options.method)){select.value=options.method;options.method=null}
+ const actions=node("div",undefined,"picker-actions"),open=button("Open secure form",async()=>{
+ open.disabled=true;feedback.textContent="Opening private setup…";
+ try{await options.openSetup(selected.id,select.value)}catch(error){feedback.textContent=error.message||"Setup could not be opened. Sign in as an owner or refresh the connector.";open.disabled=false}
+ },"primary");open.dataset.integrationStart="true";if(options.session)open.disabled=options.session.loading||options.session.role!=="owner";actions.append(open);
+ if(options.openBrowser)actions.append(button(options.browserLabel||"Open in browser",()=>Promise.resolve(options.openBrowser()).catch(()=>{feedback.textContent="Open the MSO Integrations address in your browser."})));
+ function drawGuide(){
+ preview.replaceChildren();const method=selected.methods.find(m=>m.id===select.value),guide=method.guidance;
+ preview.append(node("label","What you will need"));const fields=node("div",undefined,"provider-fields");for(const f of method.fields)fields.append(node("span",f.label+(f.required?" *":""),"field-tag"));preview.append(fields);
+ const d=node("details"),summary=node("summary","Step by step: get this credential"),ol=node("ol");d.open=true;d.append(summary,trustedLink(guide.url,"Open official provider dashboard",feedback));for(const step of guide.steps)ol.append(node("li",step));d.append(ol,trustedLink(guide.reference,"Official documentation",feedback));preview.append(d);
+ preview.append(node("p","Ten-minute form · direct HTTPS submission · values never enter the chat. An API check proves access to that endpoint, not every future operation.","picker-note"));
+ }
+ select.addEventListener("change",drawGuide);detail.append(methodLabel,select,preview,actions,feedback);drawGuide();
+ }
+ search.addEventListener("input",drawList);drawList();drawDetail();
+ return()=>{root.replaceChildren();root.classList.remove("integration")};
+}
+`;
diff --git a/lib/infra/setup-ui.ts b/lib/infra/setup-ui.ts
index 82dbe9d5..15c688ec 100644
--- a/lib/infra/setup-ui.ts
+++ b/lib/infra/setup-ui.ts
@@ -1,6 +1,7 @@
// The same DOM-only form runs in a temporary browser page and in MSO Page.
// No input, capability, or provider response is sent through the MCP bridge.
export const INTEGRATION_FORM_STYLE = String.raw`
+[hidden]{display:none!important}
.integration{max-width:850px;margin:auto;font:14px/1.55 var(--font-body);color:var(--text)}.integration h2{font:700 24px/1.25 var(--font-display);margin:0 0 8px}.integration p{color:var(--text-dim);margin:6px 0 14px}.integration .setup-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:20px}.integration label{display:block;font-weight:650;margin-bottom:5px}.integration input,.integration select{width:100%;min-width:0;border:1px solid var(--sep-strong);border-radius:9px;background:var(--field);color:var(--text);padding:10px 12px;font:16px var(--font-body)}.integration .input-row{display:flex;gap:6px}.integration .input-row input{flex:1;width:0}.integration button{font-size:13px;min-height:42px;white-space:normal}.integration .field{margin-bottom:18px;min-width:0}.integration small{display:block;margin-top:5px;color:var(--text-dim);overflow-wrap:anywhere}.integration details{border:1px solid var(--sep-strong);border-radius:12px;padding:14px;background:var(--field);margin:12px 0}.integration summary{cursor:pointer;font-weight:650}.integration li{margin:8px 0}.integration a{color:var(--os-accent);text-underline-offset:3px;overflow-wrap:anywhere}.integration .setup-status{min-height:28px;overflow-wrap:anywhere}.integration button:disabled{cursor:not-allowed;opacity:.55}.integration .setup-tag{display:inline-block;border:1px solid var(--sep-strong);border-radius:99px;padding:3px 10px;margin-bottom:12px;font-size:12px}.integration .setup-actions{display:flex;gap:8px;flex-wrap:wrap}.integration .primary{background:var(--text);color:var(--surface);border-color:var(--text)}@media(max-width:620px){.integration .setup-grid{grid-template-columns:1fr;gap:0}.integration h2{font-size:21px}}`;
export const INTEGRATION_FORM_SCRIPT = String.raw`
@@ -8,7 +9,8 @@ function integrationNode(tag,value){const n=document.createElement(tag);if(value
function mountIntegrationForm(root,setup,access){
root.replaceChildren();root.classList.add("integration");
const token=access&&access.token,endpoint=access&&access.endpoint;
- if(!token||!endpoint){root.append(integrationNode("p","Secure setup authorization is missing. Reopen the setup form; never paste a credential into chat."));return}
+ const back=()=>{if(typeof access?.onBack==="function"){const b=integrationNode("button","← All integrations");b.type="button";b.className="back-link";b.addEventListener("click",access.onBack);root.append(b)}};back();
+ if(!token||!endpoint){root.append(integrationNode("h2","Secure form unavailable"),integrationNode("p","The chat host did not deliver private setup authorization. Reopen the form or use the browser entrypoint; never paste a credential into chat."));if(access?.openBrowser){const b=integrationNode("button","Open Integrations in browser");b.type="button";b.addEventListener("click",()=>access.openBrowser());root.append(b)}return()=>{root.replaceChildren();root.classList.remove("integration")}}
const heading=integrationNode("h2",setup.title+" connection"),tag=integrationNode("span",setup.method+" · single-use session");tag.className="setup-tag";
root.append(tag,heading,integrationNode("p","API keys go directly to your MSO server. They are not sent to ChatGPT or saved in browser storage."));
const grid=integrationNode("div"),form=integrationNode("form"),aside=integrationNode("aside");grid.className="setup-grid";form.autocomplete="off";form.setAttribute("action","#");
@@ -41,6 +43,6 @@ function mountIntegrationForm(root,setup,access){
used=true;clearTimeout(timer);inputs.forEach(f=>{f.input.value="";f.input.disabled=true});save.textContent="Saved";status.textContent="Verified and saved in MSO. This setup session is now closed.";
}catch(error){status.textContent=error.message||"Connection failed. Check MSO connectivity."}finally{if(!used)save.disabled=false;for(const key of Object.keys(values))delete values[key]}
});
- return()=>{abort.abort();clearTimeout(timer);inputs.forEach(f=>{f.input.value=""});root.replaceChildren()};
+ return()=>{abort.abort();clearTimeout(timer);inputs.forEach(f=>{f.input.value=""});root.replaceChildren();root.classList.remove("integration")};
}
`;
diff --git a/lib/infra/store.ts b/lib/infra/store.ts
index 358ed85e..ff90da53 100644
--- a/lib/infra/store.ts
+++ b/lib/infra/store.ts
@@ -7,7 +7,6 @@ import { getInfraProviderDefinition, normalizeInfraValues } from "./catalog";
import type { InfraProviderId, InfraProviderSummary, InfraProviderValues, InfraStore } from "./types";
export const INFRA_STORE_PATH = process.env.OS_INFRA_STORE ?? path.join(os.homedir(), ".mso", "private", "infra-providers.json");
-const SECRET_KEYS = new Set(["apiKey", "apiToken", "orgApiKey"]);
const MAX_STORE_BYTES = 256 * 1024;
function mask(value: string): string {
@@ -59,6 +58,7 @@ export async function setInfraProvider(id: InfraProviderId, raw: Record<string,
const def = getInfraProviderDefinition(id);
const missing = def.fields.filter((field) => field.required && !values[field.key]).map((field) => field.key);
if (id === "composio" && !values.apiKey && !values.orgApiKey) missing.push("project or organization API key");
+ if (id === "convex-cloud" && !values.personalToken && !(values.deployKey && values.deploymentName)) missing.push("personal token or deployment key and name");
if (missing.length) throw new Error(`${id} is missing required value(s): ${missing.join(", ")}`);
await writeUnlocked({ ...store, providers: { ...(store.providers ?? {}), [id]: values } });
return values;
@@ -78,8 +78,9 @@ export function summarizeInfraProvider(id: InfraProviderId, values: InfraProvide
const def = getInfraProviderDefinition(id);
const missing = def.fields.filter((field) => field.required && !values[field.key]).map((field) => field.key);
if (id === "composio" && !values.apiKey && !values.orgApiKey) missing.push("project or organization API key");
+ if (id === "convex-cloud" && !values.personalToken && !(values.deployKey && values.deploymentName)) missing.push("personal token or deployment key and name");
const safeValues = Object.fromEntries(def.fields
.filter((field) => values[field.key])
- .map((field) => [field.key, SECRET_KEYS.has(field.key) ? mask(values[field.key]) : values[field.key]]));
+ .map((field) => [field.key, field.secret ? mask(values[field.key]) : values[field.key]]));
return { id, title: def.title, description: def.description, feature: def.feature, configured: missing.length === 0, missing, values: safeValues, fields: def.fields };
}
diff --git a/lib/infra/types.ts b/lib/infra/types.ts
index 4476afcc..d0bcba5d 100644
--- a/lib/infra/types.ts
+++ b/lib/infra/types.ts
@@ -1,4 +1,4 @@
-export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio"] as const;
+export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio", "github", "vercel", "convex-cloud", "convex", "resend", "stripe", "clerk", "supabase"] as const;
export type InfraProviderId = (typeof INFRA_PROVIDER_IDS)[number];
export type InfraProviderValues = Record<string, string>;
diff --git a/lib/mcp/dispatch-tool-support.ts b/lib/mcp/dispatch-tool-support.ts
index b1b44e84..237bff52 100644
--- a/lib/mcp/dispatch-tool-support.ts
+++ b/lib/mcp/dispatch-tool-support.ts
@@ -16,7 +16,7 @@ export function structuredResult(toolName: string, result: unknown, profile: Mcp
if (isMcpDirectResult(result)) {
return {
content: result.content,
- ...(profile === "chatgpt" && capabilityPrivateMeta(result) ? { _meta: capabilityPrivateMeta(result) } : {}),
+ ...(capabilityPrivateMeta(result) ? { _meta: capabilityPrivateMeta(result) } : {}),
...((profile === "chatgpt" || tool?.outputSchema) && result.structuredContent ? { structuredContent: result.structuredContent } : {}),
...(result.isError ? { isError: true } : {}),
};
diff --git a/lib/mcp/integration-setup.test.ts b/lib/mcp/integration-setup.test.ts
index ebf8a65c..beca79a9 100644
--- a/lib/mcp/integration-setup.test.ts
+++ b/lib/mcp/integration-setup.test.ts
@@ -13,7 +13,9 @@ describe("MCP integration setup privacy", () => {
const wire = structuredResult("integration_setup_open", raw, "chatgpt");
expect(wire).toHaveProperty("_meta.integrationSetup.token", secret);
expect(JSON.stringify(wire.content)).not.toContain(secret); expect(JSON.stringify(wire.structuredContent)).not.toContain(secret);
- expect(JSON.stringify(structuredResult("integration_setup_open", raw, "full"))).not.toContain(secret);
+ expect(structuredResult("integration_setup_open", raw, "full")).toHaveProperty("_meta.integrationSetup.token", secret);
+ // Generic model transports still serialize the weak-map-free raw result.
+ expect(JSON.stringify(raw)).not.toContain(secret);
});
it("requires write scope, accepts no credential parameters, and uses the existing Page", () => {
const tool = SURFACE_TOOLS.find(t => t.name === "integration_setup_open")!;
@@ -25,6 +27,6 @@ describe("MCP integration setup privacy", () => {
expect(MSO_SURFACE_SCRIPT).toContain('credentials:"omit"');
expect(MSO_SURFACE_SCRIPT).toContain('save.type="button"');
expect(MSO_SURFACE_SCRIPT).toContain('rpcRequest("ui/open-link"');
- expect(MSO_SURFACE_SCRIPT).toContain("raw.mcp_tool_result");
+ expect(MSO_SURFACE_SCRIPT).toContain('"mcp_tool_result"');
});
});
diff --git a/lib/mcp/tools-infra.ts b/lib/mcp/tools-infra.ts
index d32ef88b..a5a29315 100644
--- a/lib/mcp/tools-infra.ts
+++ b/lib/mcp/tools-infra.ts
@@ -11,7 +11,7 @@ const dnsSchema = {
export const INFRA_TOOLS: McpTool[] = [
{
name: "infra_providers_list",
- description: "List MSO infrastructure providers (Dokploy, Cloudflare, Hostinger, Composio), showing masked configuration state and missing required fields. Raw credentials are never returned.",
+ description: "List native MSO integrations and infrastructure providers, showing masked configuration state and missing required fields. Raw credentials are never returned.",
scope: "read",
annotations: { readOnlyHint: true, idempotentHint: true },
inputSchema: S({}),
diff --git a/lib/mcp/tools-surface.ts b/lib/mcp/tools-surface.ts
index e5454005..303ba19d 100644
--- a/lib/mcp/tools-surface.ts
+++ b/lib/mcp/tools-surface.ts
@@ -57,7 +57,7 @@ export const SURFACE_TOOLS: McpTool[] = [
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false, idempotentHint: false },
audit: { action: "infra.write", targetArg: "provider" },
limit: { key: "integration.setup", max: 10, windowMs: 60_000 },
- inputSchema: S({ provider: { type: "string", enum: [...INFRA_PROVIDER_IDS] }, method: { type: "string", enum: ["direct", "project", "organization"], description: "Composio defaults to project; other providers use direct." } }, ["provider"]),
+ inputSchema: S({ provider: { type: "string", enum: [...INFRA_PROVIDER_IDS] }, method: { type: "string", enum: ["direct", "project", "organization", "personal", "deployment"], description: "Composio defaults to project; other providers use direct." } }, ["provider"]),
outputSchema: PAGE_OUTPUT,
meta: {
ui: { resourceUri: MSO_PAGE_URI, visibility: ["model", "app"] },
diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.ts
index eb20be4e..8b88d798 100644
--- a/lib/mcp/toolset.ts
+++ b/lib/mcp/toolset.ts
@@ -5,7 +5,7 @@ import { toolDescriptor, type McpToolProfile } from "./tool-contract";
export const MCP_SERVER_VERSION = "1.12.0";
export const MCP_TOOLSET_VERSION = "2026.09.05.5";
-export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T12:36:17Z";
+export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T12:32:00Z";
export type McpToolsetInfo = {
serverVersion: string;
diff --git a/lib/mcp/ui-config.ts b/lib/mcp/ui-config.ts
index 97ace731..9b948d00 100644
--- a/lib/mcp/ui-config.ts
+++ b/lib/mcp/ui-config.ts
@@ -18,6 +18,6 @@ export function widgetResourceMeta(description: string, options?: { frameDomains
"openai/widgetDomain": MCP_UI_DOMAIN,
// Standard CSP fields live only in `ui.csp`. OpenAI documents this legacy
// key as still required for trusted `openExternal` redirect destinations.
- "openai/widgetCSP": { redirect_domains: [MSO_ORIGIN, ...(options?.redirectDomains ?? [])] },
+ "openai/widgetCSP": { ...(connectDomains.length ? { connect_domains: connectDomains } : {}), ...(frameDomains.length ? { frame_domains: frameDomains } : {}), redirect_domains: [MSO_ORIGIN, ...(options?.redirectDomains ?? [])] },
};
}
diff --git a/lib/mcp/ui-page-integrations.ts b/lib/mcp/ui-page-integrations.ts
index b82bcbd4..842fe07d 100644
--- a/lib/mcp/ui-page-integrations.ts
+++ b/lib/mcp/ui-page-integrations.ts
@@ -1,43 +1,39 @@
import { INTEGRATION_FORM_SCRIPT } from "@/lib/infra/setup-ui";
-import { setupCatalog } from "@/lib/infra/setup-hub";
+import { INTEGRATION_PICKER_SCRIPT } from "@/lib/infra/setup-picker";
+import { integrationCatalog } from "@/lib/infra/setup-catalog";
import { MSO_ORIGIN } from "./ui-config";
-
export const MSO_PAGE_INTEGRATIONS_SCRIPT = String.raw`
${INTEGRATION_FORM_SCRIPT}
+${INTEGRATION_PICKER_SCRIPT}
const INTEGRATION_ENDPOINT=${JSON.stringify(MSO_ORIGIN + "/api/integrations/setup")};
const INTEGRATION_BROWSER=${JSON.stringify(MSO_ORIGIN + "/integrations")};
-const INTEGRATION_CATALOG=${JSON.stringify(setupCatalog()).replace(/</g, "\\u003c")};
+const INTEGRATION_CATALOG=${JSON.stringify(integrationCatalog()).replace(/</g,"\\u003c")};
let integrationAccess=null;
-function captureIntegrationAccess(raw){
- const envelopes=[raw,raw&&raw._meta,raw&&raw.mcp_tool_result&&raw.mcp_tool_result._meta,raw&&raw.call_tool_result&&raw.call_tool_result._meta,raw&&raw.result&&raw.result._meta];
- for(const meta of envelopes){const access=meta&&meta.integrationSetup;if(access&&typeof access.token==="string"&&/^[A-Za-z0-9_-]{43}$/.test(access.token)&&access.endpoint===INTEGRATION_ENDPOINT){integrationAccess=access;return}}
+function captureIntegrationAccess(raw,depth=0){
+ if(!raw||typeof raw!=="object"||depth>4)return;
+ const access=raw.integrationSetup;
+ if(access&&typeof access.token==="string"&&/^[A-Za-z0-9_-]{43}$/.test(access.token)&&access.endpoint===INTEGRATION_ENDPOINT){integrationAccess=access;return}
+ for(const key of ["_meta","mcp_tool_result","call_tool_result","result"])if(raw[key])captureIntegrationAccess(raw[key],depth+1);
}
async function openIntegrationReference(url){
+ if(hostConnected)return rpcRequest("ui/open-link",{url});
if(window.openai&&typeof window.openai.openExternal==="function")return window.openai.openExternal({href:url,redirectUrl:false});
return rpcRequest("ui/open-link",{url});
}
-function integrationLink(url,label,feedback){
- const a=el("a","button",label);a.href=url;a.target="_blank";a.rel="noopener noreferrer";
- a.addEventListener("click",event=>{event.preventDefault();openIntegrationReference(url).catch(()=>{feedback.textContent="The host could not open the browser. Copy this public address: "+url})});return a;
-}
function renderIntegrations(){
- if(current.setup&&integrationAccess){viewCleanup=mountIntegrationForm(body,current.setup,{...integrationAccess,openLink:openIntegrationReference})||(()=>{});return;}
- const root=el("div","integration"),feedback=el("p","setup-status");feedback.setAttribute("role","status");
- root.append(el("h2","","Integrations"),el("p","","Choose a provider below. Browser setup works independently of whether this chat has refreshed its tool catalog."));
- const external=el("div","setup-actions");external.append(integrationLink(INTEGRATION_BROWSER,"Open secure setup in browser",feedback));root.append(external,el("p","mono",INTEGRATION_BROWSER));
- if(current.setup&&!integrationAccess)feedback.textContent="The chat host did not deliver the private setup authorization. No key input is shown here. Use the secure browser page or refresh the MSO connection.";
- const list=el("div","grid");
- for(const provider of INTEGRATION_CATALOG){
- const card=el("div","card");card.append(el("strong","",provider.title),el("p","",provider.description));
- for(const method of provider.methods){
- const details=el("details"),summary=el("summary","",method.title),steps=el("ol");details.append(summary);
- for(const step of method.guidance.steps)steps.append(el("li","",step));details.append(steps,integrationLink(method.guidance.url,"Provider dashboard",feedback),integrationLink(method.guidance.reference,"Official documentation",feedback));
- const browserUrl=INTEGRATION_BROWSER+"?provider="+encodeURIComponent(provider.id)+"&method="+encodeURIComponent(method.id);
- const b=button("Set up in chat",async()=>{b.disabled=true;feedback.textContent="Opening secure form…";try{const result=await rpcCall("integration_setup_open",{provider:provider.id,method:method.id});captureIntegrationAccess(result);captureIntegrationAccess(window.openai&&window.openai.toolResponseMetadata);if(result?.isError||!unbox(result)?.setup)throw new Error("setup tool unavailable");if(!acceptPageResult(result))throw new Error("missing setup data")}catch{feedback.textContent="This chat could not open the setup tool. Refresh the MSO connection to load its new tools, or use Open in browser. Your credentials have not changed.";b.disabled=false}},"primary");
- const actions=el("div","setup-actions");actions.append(b,integrationLink(browserUrl,"Open in browser",feedback));details.append(actions);card.append(details);
- }
- list.append(card);
+ const onBack=()=>{integrationAccess=null;lastOutputKey="";current={route:"/integrations",kind:"integrations",title:"Integrations",openPath:"/integrations",catalog:[]};render()};
+ const openBrowser=()=>openIntegrationReference(INTEGRATION_BROWSER);
+ if(current.setup){
+ captureIntegrationAccess(window.openai&&window.openai.toolResponseMetadata);
+ viewCleanup=mountIntegrationForm(body,current.setup,{...(integrationAccess||{}),openLink:openIntegrationReference,onBack,openBrowser})||(()=>{});return;
}
- root.append(feedback,list);body.append(root);
+ viewCleanup=mountIntegrationPicker(body,INTEGRATION_CATALOG,{
+ openBrowser,openLink:openIntegrationReference,
+ openSetup:async(provider,method)=>{
+ const result=await rpcCall("integration_setup_open",{provider,method});
+ captureIntegrationAccess(result);captureIntegrationAccess(window.openai&&window.openai.toolResponseMetadata);
+ if(!acceptPageResult(result)||!current.setup)throw new Error("The connector could not open the secure form. Use Open in browser, or refresh the MSO connector to load the new setup action.");
+ }
+ });
}
`;
diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.ts
index 99b8c9a9..8bfafa8e 100644
--- a/lib/mcp/ui-resources.test.ts
+++ b/lib/mcp/ui-resources.test.ts
@@ -148,8 +148,8 @@ describe("MCP Apps Block and Page contract", () => {
resourceDomains: [],
frameDomains: ["https://game.rahmanef.com"],
});
- expect(content._meta["openai/widgetCSP"]).toEqual({ redirect_domains: [MSO_ORIGIN, "https://game.rahmanef.com"] });
- expect(MSO_PAGE_URI).toContain("page-v4.html");
+ expect(content._meta["openai/widgetCSP"]).toEqual({ connect_domains: [MSO_ORIGIN], frame_domains: ["https://game.rahmanef.com"], redirect_domains: [MSO_ORIGIN, "https://game.rahmanef.com"] });
+ expect(MSO_PAGE_URI).toContain("page-v5.html");
});
it("returns only redacted structured workflow state and keeps status polling out of workflow memory", async () => {
diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.ts
index 3313e3ab..181d913c 100644
--- a/lib/mcp/ui-resources.ts
+++ b/lib/mcp/ui-resources.ts
@@ -8,6 +8,7 @@ export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
// across the UI-contract migration. They are intentionally not advertised by
// resources/list: the public product contract has exactly Block and Page.
export const LEGACY_BLOCK_V1_URI = "ui://mso/block-v1.html";
+export const LEGACY_PAGE_V4_URI = "ui://mso/page-v4.html";
export const LEGACY_PAGE_V3_URI = "ui://mso/page-v3.html";
export const LEGACY_PAGE_V2_URI = "ui://mso/page-v2.html";
export const LEGACY_PAGE_V1_URI = "ui://mso/page-v1.html";
@@ -25,10 +26,11 @@ export type McpUiResource = {
const RESOURCES: readonly McpUiResource[] = [MSO_BLOCK_RESOURCE, MSO_PAGE_RESOURCE];
const LEGACY_ALIASES = new Map<string, McpUiResource>([
+ [LEGACY_PAGE_V4_URI, MSO_PAGE_RESOURCE],
+ [LEGACY_PAGE_V3_URI, MSO_PAGE_RESOURCE],
[LEGACY_BLOCK_V1_URI, MSO_BLOCK_RESOURCE],
[LEGACY_PAGE_V1_URI, MSO_PAGE_RESOURCE],
[LEGACY_PAGE_V2_URI, MSO_PAGE_RESOURCE],
- [LEGACY_PAGE_V3_URI, MSO_PAGE_RESOURCE],
[LEGACY_WORKFLOW_PROGRESS_URI, MSO_BLOCK_RESOURCE],
[LEGACY_SURFACE_URI, MSO_PAGE_RESOURCE],
]);
diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.ts
index 50c30e4c..4149bf92 100644
--- a/lib/mcp/ui-surface.ts
+++ b/lib/mcp/ui-surface.ts
@@ -1,4 +1,4 @@
-import { SETUP_HUB_STYLE } from "@/lib/infra/setup-hub";
+import { INTEGRATION_PICKER_STYLE } from "@/lib/infra/setup-picker";
import { INTEGRATION_FORM_STYLE } from "@/lib/infra/setup-ui";
import { widgetResourceMeta, MSO_ORIGIN } from "./ui-config";
import { OPEN_IN_MSO_SCRIPT, openInMsoControls } from "./ui-navigation";
@@ -6,11 +6,11 @@ import { surfaceFrameDomains } from "./surface-catalog";
import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";
import { MSO_SURFACE_STYLE } from "./ui-surface-style";
-export const MSO_PAGE_URI = "ui://mso/page-v4.html";
+export const MSO_PAGE_URI = "ui://mso/page-v5.html";
const MIME = "text/html;profile=mcp-app";
const html = String.raw`<main class="surface" aria-label="MSO Page">
-<style>${MSO_SURFACE_STYLE}${INTEGRATION_FORM_STYLE}${SETUP_HUB_STYLE}</style>
+<style>${MSO_SURFACE_STYLE}${INTEGRATION_FORM_STYLE}${INTEGRATION_PICKER_STYLE}</style>
<header class="bar">
<div class="brand" aria-hidden="true">M</div>
<div class="heading"><strong id="surface-title">MSO Page</strong><span id="surface-route">/</span></div>
diff --git a/next.config.mjs b/next.config.mjs
index ee8864c4..65bcba5f 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -130,6 +130,8 @@ const nextConfig = {
// Private API responses must never be cached by any intermediary — they
// carry host bytes (fs/read), auth state, and per-session data.
{ source: "/api/:path*", headers: [{ key: "Cache-Control", value: "no-store" }] },
+ { source: "/integrations", headers: [{ key: "Cache-Control", value: "no-store" }, { key: "Referrer-Policy", value: "no-referrer" }] },
+ { source: "/api/integrations/:path*", headers: [{ key: "Referrer-Policy", value: "no-referrer" }] },
// Named brand/wallpaper assets are effectively immutable but, unlike
// /_next chunks, are NOT content-hashed — rename or add ?v= if ever redrawn.
{ source: "/wallpapers/:path*", headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }] },
diff --git a/proxy.ts b/proxy.ts
index 64ec1220..e28228a2 100644
--- a/proxy.ts
+++ b/proxy.ts
@@ -304,8 +304,7 @@ export async function proxy(request: NextRequest) {
const isA2A =
pathname === "/a2a/v1" || pathname === "/.well-known/agent-card.json";
const isMachineProtocol = isMcp || isA2A;
- // The public integration document owns its nonce/CSP; its mutations use the guarded APIs.
- const isApi = pathname.startsWith("/api/") || isMachineProtocol || pathname === "/integrations";
+ const isApi = pathname.startsWith("/api/") || isMachineProtocol || (pathname === "/integrations" && ["GET", "HEAD"].includes(request.method));
// The historical same-origin bridge is permanently closed. noVNC is executable
// third-party code and is served only from its reserved split-origin host above.
if (pathname.startsWith("/camoufox-vnc/")) return notFound();
diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.sh
index 258e29ba..8c2689a6 100755
--- a/scripts/cli/commands.sh
+++ b/scripts/cli/commands.sh
@@ -24,7 +24,7 @@ verbs() {
U_camoufox="camoufox status|start|stop|session"
U_gateway="gateway start [--config <cloudflared.yml> --tunnel <name|uuid>]|stop|status|url|doctor|install|domain show|set <https://host>|clear"
U_doctor="doctor [--fix]"
-U_provider="provider list|show <id>|setup <id> [method]|set <dokploy|cloudflare|hostinger|composio>|rm <id>|doctor [id]|projects|zones"
+U_provider="provider list|show <id>|setup <id> [method]|set <id>|rm <id>|doctor [id]|projects|zones"
U_model="model [current|list [provider]|set <provider> <model>|set <provider/model>|<model-or-ref>]"
U_agent="agent [--continue|-c|--resume|-r <latest|index|id|title>|--yolo|-yolo] | agent --oneshot <prompt> [--json] [--approve-scope read|write|exec]"
U_mapp="mapp list|show|logs|backups|jobs|job <id> <jobId>|pending <id>|install|update|power <id> <act>|cancel <id> <jobId>"
diff --git a/scripts/mso-cli-agent.sh b/scripts/mso-cli-agent.sh
index c9a8d95a..a558a74a 100755
--- a/scripts/mso-cli-agent.sh
+++ b/scripts/mso-cli-agent.sh
@@ -347,9 +347,9 @@ run_provider() {
local -a pairs=()
case "$sub" in
setup|web)
- [ -n "$id" ] || die "usage: mso provider setup <id> [direct|project|organization]"
+ [ -n "$id" ] || die "usage: mso provider setup <id> [direct|project|organization|personal|deployment]"
tty_ok || die "secure setup links are terminal-only; MCP callers must use integration_setup_open (never exec)"
- data=$(jpost "/api/v1/infra/setup" "$(jq -nc --arg provider "$id" --arg method "${3:-$([ "$id" = composio ] && echo project || echo direct)}" '{provider:$provider,method:$method}')")
+ data=$(jpost "/api/v1/infra/setup" "$(jq -nc --arg provider "$id" --arg method "${3:-$(case "$id" in composio) echo project ;; convex-cloud) echo personal ;; *) echo direct ;; esac)}" '{provider:$provider,method:$method}')")
printf 'Open this private link in your browser (expires after 10 minutes):\n%s#%s\n' "$(jq -r '.setupUrl' <<<"$data")" "$(jq -r '.token' <<<"$data")"
unset data
;;
@@ -379,7 +379,7 @@ run_provider() {
tty_ok || die "provider setup needs a terminal because API tokens are entered with hidden input"
data=$(provider_metadata)
row=$(jq -c --arg id "$id" '.providers[] | select(.id==$id)' <<<"$data")
- [ -n "$row" ] || die "unknown provider '$id' (expected dokploy, cloudflare, hostinger, composio)"
+ [ -n "$row" ] || die "unknown provider '$id'; see mso provider list"
echo "$(jq -r '.title + " — " + .description' <<<"$row")"
pairs=()
while IFS=$'\t' read -r key label secret required description existing; do