Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
feat(integrations): add portable JSON transfer and standalone import adapter
Rahman67d4b3ec64a4
diff --git a/.gitignore b/.gitignoreindex bdd76e43..c5d77bc7 100644--- a/.gitignore+++ b/.gitignore@@ -45,3 +45,7 @@ camoufox-profile*/# Python icon-generator bytecode.__pycache__/*.py[cod]++# Local integration-transfer artifacts (never commit personal exports)+*.integration-bundle.json+*.integration-bundle.enc.jsondiff --git a/app/api/v1/integrations/transfer/route.test.ts b/app/api/v1/integrations/transfer/route.test.tsnew file mode 100644index 00000000..62dd2aa5--- /dev/null+++ b/app/api/v1/integrations/transfer/route.test.ts@@ -0,0 +1,14 @@+import {beforeEach,afterEach,it,expect,vi} from 'vitest';import {NextRequest} from 'next/server';+import {promises as fs} from 'node:fs';import os from 'node:os';import path from 'node:path';+import sample from '@/schemas/integration-bundle-example.json';+vi.mock('server-only',()=>({}));vi.mock('@/lib/host/audit-api',()=>({audit:vi.fn()}));+const auth=vi.hoisted(()=>({role:'owner' as string}));vi.mock('@/lib/auth/require-session',()=>({getSessionContext:async()=>({role:auth.role,session:{device_id:'test-device'}})}));+let root:string;+beforeEach(async()=>{root=await fs.mkdtemp(path.join(os.tmpdir(),'mso-transfer-route-'));process.env.OS_INFRA_STORE=path.join(root,'infra.json');auth.role='owner';vi.resetModules()});+afterEach(async()=>{delete process.env.OS_INFRA_STORE;await fs.rm(root,{recursive:true,force:true});vi.resetModules()});+const req=(body:unknown)=>new NextRequest('https://mso.rahmanef.com/api/v1/integrations/transfer',{method:'POST',headers:{'content-type':'application/json',origin:'https://mso.rahmanef.com'},body:JSON.stringify(body)});+it('refuses non-owner export and import',async()=>{const {POST}=await import('./route');auth.role='viewer';expect((await POST(req({action:'export'}))).status).toBe(403);expect((await POST(req({action:'import',document:sample}))).status).toBe(403)});+it('supports preview then confirmed application and returns only safe summaries',async()=>{const {POST}=await import('./route');const r=await POST(req({action:'import',document:sample}));expect(r.status).toBe(200);const p=await r.json();expect(p.applied).toBeUndefined();const applied=await POST(req({action:'import',document:sample,apply:true,confirm:p.planId}));expect(applied.status).toBe(200);const exportResult=await POST(req({action:'export'}));expect((await exportResult.json()).bundle.mode).toBe('metadata');expect(exportResult.headers.get('cache-control')).toContain('no-store')});+it('rejects giant, malformed, or non-JSON bodies',async()=>{const {POST}=await import('./route');expect((await POST(req({action:'import',document:'x'.repeat(3*1024*1024)}))).status).toBe(413);const request=req({action:'export'});request.headers.set('content-type','text/plain');expect((await POST(request)).status).toBe(415);expect((await POST(req({action:'export',includeSecrets:'true'}))).status).toBe(400)});++it("returns the configured public entrypoint instead of a VPS loopback URL",async()=>{const {GET}=await import("./route");const r=await GET();expect(r.status).toBe(200);expect((await r.json()).url).toBe("https://mso.rahmanef.com/integrations?transfer=1");auth.role="viewer";expect((await GET()).status).toBe(403)});diff --git a/app/api/v1/integrations/transfer/route.ts b/app/api/v1/integrations/transfer/route.tsnew file mode 100644index 00000000..db62c194--- /dev/null+++ b/app/api/v1/integrations/transfer/route.ts@@ -0,0 +1,31 @@+import {MSO_ORIGIN} from "@/lib/mcp/ui-config";+import {NextRequest,NextResponse} from 'next/server';+import {getSessionContext} from '@/lib/auth/require-session';+import {audit} from '@/lib/host/audit-api';+import {exportIntegrationData,importIntegrationData,type TransferOptions} from '@/lib/infra/portable/data';+import {transferBody} from '@/lib/infra/portable/http';+import {BundleError} from '@/lib/infra/portable/codec.js';+import {IntegrationError} from '@/lib/infra/identity';+export const runtime='nodejs';export const dynamic='force-dynamic';+const headers={'Cache-Control':'no-store, private','Referrer-Policy':'no-referrer','X-Content-Type-Options':'nosniff'};+let active=0,windowAt=0,requests=0;+export async function GET(){+ if((await getSessionContext())?.role!=="owner")return NextResponse.json({error:"owner_required"},{status:403,headers});+ return NextResponse.json({url:MSO_ORIGIN+"/integrations?transfer=1",format:"integration-bundle",version:1},{headers});+}+export async function POST(req:NextRequest){+ const ctx=await getSessionContext();if(ctx?.role!=='owner')return NextResponse.json({error:'owner_required'},{status:403,headers});+ if(Date.now()-windowAt>60000){windowAt=Date.now();requests=0}+ if(active>=2||++requests>20)return NextResponse.json({error:'transfer_rate_limited'},{status:429,headers});+ active++;+ try{+ const body=await transferBody(req);const options=body as TransferOptions;+ let result;+ if(body.action==='export')result={bundle:await exportIntegrationData(options)};+ else if(body.action==='import')result=await importIntegrationData(body.document,options);+ else throw new IntegrationError('invalid_transfer_action');+ void audit({action:'infra.write',actor:ctx.session.device_id,target:'integrations',ok:true,detail:`transfer.${body.action}.${body.apply?'apply':'prepare'}`});+ return NextResponse.json(result,{headers});+ }catch(e){const status=e instanceof IntegrationError?e.status:400;const error=e instanceof IntegrationError||e instanceof BundleError?e.message:'transfer_failed';return NextResponse.json({error},{status,headers});}+ finally{active--;}+}diff --git a/bin/mso.test.ts b/bin/mso.test.tsindex ed39fc29..c2f56637 100644--- a/bin/mso.test.ts+++ b/bin/mso.test.ts@@ -106,6 +106,7 @@ describe("bin/mso", () => {// OAuth is NOT here any more: it is a device-code POST, not a redirect, so// `mso oauth <provider> start|poll` covers it.const browserOnly = [+ "POST /api/v1/integrations/transfer", // File/passphrase input belongs to the authenticated browser, opened by mso integrations transfer.// Credential input is delegated to a write-only browser capability; the// named CLI setup verb opens that form without placing keys in shell/tool JSON."POST /api/integrations/setup",diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex d20d217b..3108e8ae 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Added**+- `integrations` add portable JSON transfer and standalone import adapter- `integrations` unify native users connections and source-aware execution- `artifacts` add private per-session screenshot storage and retention- `integrations` add native secure credential setup in browser and MCP Pagediff --git a/docs/INTEGRATION-PORTABILITY.md b/docs/INTEGRATION-PORTABILITY.mdnew file mode 100644index 00000000..976ab396--- /dev/null+++ b/docs/INTEGRATION-PORTABILITY.md@@ -0,0 +1,113 @@+# Integration Bundle v1++SC and MSO intentionally keep separate credential stores. Copying a repository,+sharing a private store file, or cloning a Git branch is not a migration. Use an+explicit, reviewed JSON transfer instead. This is a snapshot, not live sync.++## Supported workflows++SI-Coder provides `sc data export`, `sc data import`, and **Import / export JSON**+in its temporary browser manager. MSO provides the same browser workflow at+`/integrations?transfer=1`, opened from the native manager or+`mso integrations transfer`. Both use their own independent bundled codec and+native store adapter. Neither imports application code from the other product.++**Metadata is the default.** It carries user IDs/labels, named connections,+provider/source/auth identity, scope, and field names/presence. It carries **no+field values**, including public configuration values. After importing metadata,+users/connections appear but credentials still need to be configured.++**Encrypted export** carries direct credential and configuration values. It uses+AES-256-GCM with a random 12-byte IV and 16-byte authentication tag, and a 32-byte+key derived by scrypt (N=32768, r=8, p=1; random 16-byte salt). Passphrases must be+at least 12 UTF-8 bytes; the UI requires 12 characters. No passphrase CLI argument,+MCP field, browser storage, or unencrypted full export is provided. Share the+passphrase separately from the file. A forgotten passphrase cannot be recovered.++The encrypted bundle protects the transferred file; it does not add encryption+at rest to either application's existing private credential store. Metadata names+can still be confidential. Exported local files use 0600 and must not be committed.++## SC terminal++```sh+sc data export --out profiles.integration-bundle.json+sc data export --user my-user --include-secrets --out profiles.integration-bundle.enc.json+sc data import --file profiles.integration-bundle.enc.json --prefix imported-+```++The last command previews only. Review the plan, then rerun with+`--apply --confirm PREVIEW_ID`. Encrypted imports prompt for the passphrase again.+Use `--accept-warnings` only after reviewing skipped connections, unmapped fields,+and external-authorization warnings. `--policy error` makes conflicts block the+import; the default `skip` preserves existing connections. A prefix creates a+separately named copy instead of replacing the original identity.++The safe machine functions `sc.data.export` and `sc.data.import` use this same+core, but handle **metadata-only** files. Export requires `confirm: true`; import+applies only with explicit confirmation and the preview's `planId`. They do not+accept a passphrase or decrypt a credential bundle.++## Import policy++The preview hash covers the bundle, options, and destination state. Changes+require another preview. IDs, sources, methods, field names, size and protocol+version are validated before any mutation. Imports are create-only: existing+connection IDs or labels are skipped, never overwritten. An encrypted import+will not fill a pre-existing empty connection by surprise; use a distinct prefix+or explicitly remove the intended empty connection before importing again.++Imported values are **not marked verified** and are not sent to a provider during+import. Test the selected connection afterward. Defaults and folder bindings are+not transferred or automatically activated. Selecting a credential profile does+not grant an MSO Owner/Operator role.++Composio/provider-MCP accounts are imported as metadata needing fresh+authorization. OAuth access/refresh tokens, active connected-account IDs,+broker links and session capabilities are not copied across applications.++MSO applies the accepted changes under its existing atomic store transaction.+SC serializes its state writes and rolls back newly created users/connections on+ordinary write failures. SC's multi-file store is not a transactional database:+a forced process termination may leave a partial create-only import and a stale+write lock. Review that state before clearing the lock or retrying. The import+never overwrites existing credential files; symlinked/orphan destinations fail+closed or appear as skipped targets.++## Mapping and unsupported data++The wire provider ID is `cloudflare` (SC's `cf` alias maps to it). Wire field names+are stable environment identifiers, for example `GITHUB_TOKEN` maps to MSO's+`apiKey`, and `CONVEX_DEPLOY_KEY` maps to `deployKey`. Account and deployment auth+methods remain separate. Optional owner/team/domain configuration is preserved+where supported. Legacy SC profile values are exported as explicit virtual+`legacy-*` connections without changing their source store.++Unsupported providers, methods or fields appear in the preview. Their omission+requires explicit acceptance. For example, SC's `git`/`sync` local configuration+has no native MSO provider adapter. Custom provider definitions are not executed+or installed from an import. This is an **integration identity/data transfer**,+not a full backup of SC skills, project files, agent memory, logs or global settings.++## Other receiving projects++`schemas/integration-bundle-v1.schema.json` defines the public file envelope;+`schemas/integration-bundle-example.json` is a synthetic metadata example. The+bundled reference codec additionally checks aggregate limits and authenticated+encryption. Limits: 2 MiB input, 100 users, 1000 total connections, 64 fields per+connection, 4096 characters per value. Unsupported schema/KDF versions fail closed.++This is a project-owned versioned contract, **not a universal import standard**.+Baton or a connector gateway must add a receiver that validates the file, maps+identities to its own workspace/tenant, presents conflicts, and performs its own+role checks. Those services are not modified by the SC/MSO release. Do not assume+that uploading this JSON to an arbitrary endpoint imports accounts safely.++The standalone codec is bundled identically in the two repos so no runtime+cross-product dependency is required. Protocol changes require a new version and+SC↔MSO interoperability tests. Native store adapters and all conflict decisions+remain application-owned.++References: Node.js `node:crypto` documentation and the OWASP Cryptographic Storage+Cheat Sheet. The protocol uses authenticated encryption and OS randomness rather+than reversible obfuscation or an application-owned hardcoded encryption key.diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.mdindex d3ce66ae..2b6b1c11 100644--- a/docs/INTEGRATIONS.md+++ b/docs/INTEGRATIONS.md@@ -166,3 +166,11 @@ is a separate user-authorized verification step, not implied by unit tests.Official contracts: [MCP Apps](https://github.com/modelcontextprotocol/ext-apps),[OpenAI plugin UI](https://developers.openai.com/plugins/reference), and[Composio connected accounts](https://docs.composio.dev/docs/auth-configuration/connected-accounts).++## Move identities between standalone projects++Use **Import / export JSON** or `/integrations?transfer=1`. Plain JSON carries+metadata only; optional encrypted JSON can carry direct credential values. Imports+are previewed, create-only, unverified, and never change defaults or folder bindings.+See [Integration Bundle v1](INTEGRATION-PORTABILITY.md) for CLI syntax, mappings and+receiver support. There is no mandatory SC dependency or automatic data sharing.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex cb0f4488..8b2e6429 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -21,6 +21,23 @@ The actual GitHub alert inventory exposed 22 default-branch findings, unlike the## 2026-09-05 — MCP Page preview lifecycle+## 2026-09-05 — Deliberate JSON portability between independent credential stores++Users appearing in SC but not MSO were a data-transfer gap, not a Git clone issue.+Add a versioned integration-bundle contract and standalone native adapters instead+of reading SC's private storage from MSO. Default metadata export carries no field+values. Optional authenticated encrypted JSON is handled only by hidden local+input or a dedicated Owner browser endpoint, never MCP secret arguments.++Preview binds the input/options and destination state. Imports create profiles and+named connections without overwriting existing identities, activating defaults or+copying OAuth sessions. Mappings preserve provider/auth semantics and supported+fields; unsupported data is visible and requires explicit acceptance. Browser UI+and each project's CLI use their own core. Other project receivers still need an+adapter and tenant/role checks. Tests cover both encryption failures and actual+SC→MSO→SC roundtrip plus browser upload/download using isolated synthetic stores.++## 2026-09-05 — Native named-connection identity, not parallel credential formsThe provider-only Integrations store could not represent multiple deployments ordiff --git a/docs/README.md b/docs/README.mdindex 8879828b..7f3a18ca 100644--- a/docs/README.md+++ b/docs/README.md@@ -30,6 +30,7 @@ evidence and review freshness. The repository quality gate runs both automatical| [`DEVELOPMENT.md`](./DEVELOPMENT.md) | Development and release workflow || [`SECURITY-ASSURANCE.md`](./SECURITY-ASSURANCE.md) | Repeatable security verification lanes, public evidence, and claim boundaries || [`CLI.md`](./CLI.md) | Generated `mso` CLI contract |+| [`INTEGRATION-PORTABILITY.md`](./INTEGRATION-PORTABILITY.md) | Reviewed JSON identity transfers, encrypted credentials, SC interoperability and receiver limits || [`INTEGRATIONS.md`](./INTEGRATIONS.md) | Native temporary credential forms, direct HTTPS secret submission, CLI and ChatGPT Page || [`MCP.md`](./MCP.md) | MCP/OAuth internals and full external-tool security model || [`A2A.md`](./A2A.md) | A2A v1 peer discovery, delegation/task lifecycle, CLI/MCP surface and trust boundary |diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.mdindex 841142a5..bc58e18b 100644--- a/docs/generated/MCP-CATALOG.md+++ b/docs/generated/MCP-CATALOG.md@@ -4,13 +4,13 @@## Full MSO catalog-<!-- mcp-toolset: server=1.12.0 version=2026.09.05.8 tools=95 read=46 write=29 exec=20 -->+<!-- mcp-toolset: server=1.12.0 version=2026.09.05.9 tools=95 read=46 write=29 exec=20 -->| Fact | Current source value ||---|---:|| MCP server | `1.12.0` |-| Toolset | `2026.09.05.8` |-| Toolset changed at | `2026-09-05T14:05:00Z` |+| Toolset | `2026.09.05.9` |+| Toolset changed at | `2026-09-05T14:55:00Z` || Transport tools | **97** || Model/operator tools | **95** || Read | **46** |@@ -129,7 +129,7 @@## ChatGPT static profile-<!-- mcp-chatgpt-profile: server=1.12.0 version=2026.09.05.8 tools=71 read=37 write=21 exec=13 app-only=2 total=73 -->+<!-- mcp-chatgpt-profile: server=1.12.0 version=2026.09.05.9 tools=71 read=37 write=21 exec=13 app-only=2 total=73 -->The ChatGPT profile is a fail-closed static projection defined by `CHATGPT_TOOL_NAMES`. OAuth scope is still enforced independently; project-owned MCP tool names remain dynamic data behind the generic project bridge.diff --git a/lib/infra/additional-providers.ts b/lib/infra/additional-providers.tsindex b79096c0..6c131204 100644--- a/lib/infra/additional-providers.ts+++ b/lib/infra/additional-providers.ts@@ -23,14 +23,14 @@ export const ADDITIONAL_PROVIDERS = {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." }],+ fields: [{ key: "owner", label: "Repository owner", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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." }],+ fields: [{ key: "teamId", label: "Team ID", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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",@@ -58,28 +58,28 @@ export const ADDITIONAL_PROVIDERS = {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." }],+ fields: [{ key: "fromDomain", label: "Sending domain", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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." }],+ fields: [{ key: "publishableKey", label: "Publishable key", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { key: "webhookSecret", label: "Webhook signing secret", secret: true, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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." }],+ fields: [{ key: "publishableKey", label: "Publishable key", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { key: "frontendUrl", label: "Frontend API URL", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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." }],+ fields: [{ key: "organizationId", label: "Organization ID", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { 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>;diff --git a/lib/infra/connection-ui.ts b/lib/infra/connection-ui.tsindex b49e5d10..4854d38b 100644--- a/lib/infra/connection-ui.ts+++ b/lib/infra/connection-ui.ts@@ -18,7 +18,7 @@ function mountConnectionManager(root,catalog,bridge,initial={}){function draw(){root.replaceChildren();root.classList.add("integration");root.append(n("h2","Integrations"),n("p","Credential owners, named accounts and deployments — shared by MSO CLI, tools and this form."));const toolbar=n("div",undefined,"identity-bar"),label=n("label","Credential owner"),select=n("select");select.setAttribute("aria-label","Credential owner");const placeholder=n("option","Choose a user");placeholder.value="";select.append(placeholder);- for(const row of snapshot.users){const o=n("option",row.label+" ("+row.id+")"+(row.isDefault?" · default":""));o.value=row.id;select.append(o)}select.value=user||"";select.addEventListener("change",()=>{user=select.value||null;remember();void reload()});label.append(select);toolbar.append(label,b("Manage users",profiles),b("Folder bindings",bindings),b("Refresh",reload));root.append(toolbar);+ for(const row of snapshot.users){const o=n("option",row.label+" ("+row.id+")"+(row.isDefault?" · default":""));o.value=row.id;select.append(o)}select.value=user||"";select.addEventListener("change",()=>{user=select.value||null;remember();void reload()});label.append(select);toolbar.append(label,b("Manage users",profiles),b("Folder bindings",bindings),b("Refresh",reload));const transfer=b("Import / export JSON",()=>bridge.openTransfer?bridge.openTransfer():bridge.openTransferBrowser?.());transfer.disabled=!bridge.openTransfer&&!bridge.openTransferBrowser;toolbar.append(transfer);root.append(toolbar);if(!bridge.manage)root.append(n("p","Sign in as an MSO Owner to manage credentials. Device roles and credential users are different; the public guides remain available.","identity-readonly"));container=n("div",undefined,"identity-layout");const sidebar=n("nav",undefined,"identity-providers"),search=n("input");search.type="search";search.placeholder="Search services";search.setAttribute("aria-label","Search services");sidebar.append(search);const buttons=[];for(const p of catalog){const item=b(p.title,()=>{provider=p;remember();drawProvider();for(const[row,button]of buttons)button.setAttribute("aria-pressed",String(row.id===provider.id))});item.setAttribute("aria-pressed",String(p.id===provider.id));buttons.push([p,item]);sidebar.append(item)}search.addEventListener("input",()=>{for(const[p,item]of buttons)item.hidden=!(p.title+" "+p.id).toLowerCase().includes(search.value.toLowerCase())});diff --git a/lib/infra/identity.ts b/lib/infra/identity.tsindex 3e200b67..07527d92 100644--- a/lib/infra/identity.ts+++ b/lib/infra/identity.ts@@ -57,7 +57,7 @@ export function metadataOnly(value: unknown, depth = 0): void {if (depth > 12) throw new IntegrationError("metadata_too_deep");if (!value || typeof value !== "object") return;for (const [k,v] of Object.entries(value)) {- if (/^(values?|secrets?|secretValue|password|token|apiKey|apiToken|accessToken|refreshToken|authorization|headers|__proto__|constructor|prototype)$/i.test(k)) throw new IntegrationError("secret_input_forbidden");+ if (/^(values?|secrets?|secretValue|password|passphrase|token|apiKey|apiToken|accessToken|refreshToken|authorization|headers|__proto__|constructor|prototype)$/i.test(k)) throw new IntegrationError("secret_input_forbidden");metadataOnly(v,depth+1);}}diff --git a/lib/infra/portable/codec.d.ts b/lib/infra/portable/codec.d.tsnew file mode 100644index 00000000..ee5efa27--- /dev/null+++ b/lib/infra/portable/codec.d.ts@@ -0,0 +1,10 @@+export type PortableConnection={id:string;label:string;provider:string;source:'direct'|'composio'|'native-mcp';authMethod:string;scope:string;fields:Array<{key:string;secret:boolean;configured:boolean}>;values?:Record<string,string>};+export type Bundle={format:'integration-bundle';version:1;producer:{name:string;version:string};exportedAt:string;mode:'metadata'|'secrets';users:Array<{id:string;label:string;connections:PortableConnection[]}>};+export const FORMAT:string,ENCRYPTED:string,MAX_BYTES:number;+export class BundleError extends Error{code:string;}+export function id(value:unknown):string;+export function validate(value:unknown,allowSecrets?:boolean):Bundle;+export function parse(value:unknown):Record<string,unknown>;+export function payload(producer:{name:string;version:string},users:Bundle['users'],mode?:'metadata'|'secrets'):Bundle;+export function seal(payload:Bundle,passphrase:string):Promise<Record<string,unknown>>;+export function open(value:unknown,passphrase?:string):Promise<Bundle>;diff --git a/lib/infra/portable/codec.js b/lib/infra/portable/codec.jsnew file mode 100644index 00000000..e4bc1ea5--- /dev/null+++ b/lib/infra/portable/codec.js@@ -0,0 +1,76 @@+'use strict';+// integration-bundle v1 reference codec. Pure protocol code; no application store imports.+const crypto = require('node:crypto');+const { promisify } = require('node:util');+const scrypt = promisify(crypto.scrypt);+const FORMAT = 'integration-bundle', ENCRYPTED = FORMAT + '.encrypted', MAX_BYTES = 2 * 1024 * 1024;+const AAD = Buffer.from(ENCRYPTED + ':1:scrypt-32768-8-1:aes-256-gcm');+class BundleError extends Error { constructor(code) { super(code); this.code = code; } }+const fail = code => { throw new BundleError(code); };+function exact(value, keys) {+ if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(k => !keys.includes(k))) fail('invalid_bundle_shape');+}+function id(value) { if (typeof value !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(value) || ['constructor','prototype','__proto__'].includes(value)) fail('invalid_bundle_identity'); return value; }+function text(value,max=120) { if(typeof value!=='string'||!value.trim()||value.length>max||/[\x00-\x1f\x7f]/.test(value))fail('invalid_bundle_text');return value; }+function validate(payload, allowSecrets=false) {+ exact(payload,['format','version','producer','exportedAt','mode','users']);+ if(payload.format!==FORMAT||payload.version!==1)fail('unsupported_bundle_version');+ exact(payload.producer,['name','version']);text(payload.producer.name,64);text(payload.producer.version,64);+ if(typeof payload.exportedAt!=='string'||!Number.isFinite(Date.parse(payload.exportedAt)))fail('invalid_export_date');+ if(!['metadata','secrets'].includes(payload.mode)||(!allowSecrets&&payload.mode!=='metadata'))fail('plaintext_credentials_forbidden');+ if(!Array.isArray(payload.users)||payload.users.length>100)fail('bundle_user_limit');+ const seen=new Set();let count=0;+ for(const user of payload.users){+ exact(user,['id','label','connections']);id(user.id);text(user.label);if(seen.has(user.id))fail('duplicate_bundle_user');seen.add(user.id);+ if(!Array.isArray(user.connections)||(count+=user.connections.length)>1000)fail('bundle_connection_limit');+ const connections=new Set();+ for(const c of user.connections){+ exact(c,['id','label','provider','source','authMethod','scope','fields','values']);+ id(c.id);id(c.provider);id(c.authMethod);text(c.label);text(c.scope,64);+ if(!['direct','composio','native-mcp'].includes(c.source))fail('invalid_bundle_source');+ const ref=c.provider+'/'+c.id;if(connections.has(ref))fail('duplicate_bundle_connection');connections.add(ref);+ if(!Array.isArray(c.fields)||c.fields.length>64)fail('bundle_field_limit');const keys=new Set();+ for(const f of c.fields){exact(f,['key','secret','configured']);if(typeof f.key!=='string'||!/^[A-Z][A-Z0-9_]{1,127}$/.test(f.key)||keys.has(f.key)||typeof f.secret!=='boolean'||typeof f.configured!=='boolean')fail('invalid_bundle_field');keys.add(f.key);}+ if(c.values!==undefined){+ if(!allowSecrets||payload.mode!=='secrets'||c.source!=='direct')fail('plaintext_or_external_credentials_forbidden');+ exact(c.values,[...keys]);for(const v of Object.values(c.values))if(typeof v!=='string'||v.length>4096||/[\x00-\x1f\x7f]/.test(v))fail('invalid_bundle_value');+ }+ }+ }+ if(Buffer.byteLength(JSON.stringify(payload))>MAX_BYTES)fail('bundle_too_large');return payload;+}+function depthCheck(value){+ const stack=[[value,0]];let nodes=0;+ while(stack.length){const [v,depth]=stack.pop();if(depth>12||++nodes>100000)fail('bundle_structure_limit');if(v&&typeof v==='object')for(const child of Object.values(v))stack.push([child,depth+1]);}+}+function parse(input){+ if(typeof input==='string'){+ if(Buffer.byteLength(input)>MAX_BYTES)fail('bundle_too_large');+ let depth=0,quoted=false,escaped=false;+ for(const ch of input){if(escaped){escaped=false;continue}if(quoted&&ch==='\\'){escaped=true;continue}if(ch==='"'){quoted=!quoted;continue}if(!quoted&&(ch==='{'||ch==='[')&&++depth>12)fail('bundle_structure_limit');if(!quoted&&(ch==='}'||ch===']'))depth--;}+ let result;try{result=JSON.parse(input)}catch{fail('invalid_json')}depthCheck(result);return result;+ }+ depthCheck(input);if(!input||Buffer.byteLength(JSON.stringify(input))>MAX_BYTES)fail('bundle_too_large');return input;+}+function pass(value){if(typeof value!=='string'||Buffer.byteLength(value)<12||Buffer.byteLength(value)>1024)fail('passphrase_minimum_12_bytes');return value;}+function base64(value,size){if(typeof value!=='string'||value.length>MAX_BYTES||!/^[A-Za-z0-9+/]*={0,2}$/.test(value))fail('invalid_envelope');const bytes=Buffer.from(value,'base64');if(bytes.toString('base64')!==value||(size&&bytes.length!==size))fail('invalid_envelope');return bytes;}+async function seal(payload,passphrase){+ validate(payload,true);pass(passphrase);+ const salt=crypto.randomBytes(16),iv=crypto.randomBytes(12),key=await scrypt(passphrase,salt,32,{N:32768,r:8,p:1,maxmem:64*1024*1024});+ const plain=Buffer.from(JSON.stringify(payload));try{const cipher=crypto.createCipheriv('aes-256-gcm',key,iv);cipher.setAAD(AAD);const data=Buffer.concat([cipher.update(plain),cipher.final()]);+ const envelope={format:ENCRYPTED,version:1,kdf:{name:'scrypt',N:32768,r:8,p:1,salt:salt.toString('base64')},cipher:{name:'aes-256-gcm',iv:iv.toString('base64'),tag:cipher.getAuthTag().toString('base64')},data:data.toString('base64')};+ if(Buffer.byteLength(JSON.stringify(envelope))>MAX_BYTES)fail('bundle_too_large');return envelope;+ }finally{key.fill(0);plain.fill(0)}+}+async function open(input,passphrase){+ const d=parse(input);if(!d||typeof d!=='object'||Array.isArray(d))fail('invalid_bundle_shape');if(d.format!==ENCRYPTED)return validate(d,false);+ exact(d,['format','version','kdf','cipher','data']);exact(d.kdf,['name','N','r','p','salt']);exact(d.cipher,['name','iv','tag']);+ if(d.version!==1||d.kdf.name!=='scrypt'||d.kdf.N!==32768||d.kdf.r!==8||d.kdf.p!==1||d.cipher.name!=='aes-256-gcm')fail('unsupported_encryption');+ const salt=base64(d.kdf.salt,16),iv=base64(d.cipher.iv,12),tag=base64(d.cipher.tag,16),data=base64(d.data);pass(passphrase);+ const key=await scrypt(passphrase,salt,32,{N:32768,r:8,p:1,maxmem:64*1024*1024});let plain;+ try{const decipher=crypto.createDecipheriv('aes-256-gcm',key,iv);decipher.setAAD(AAD);decipher.setAuthTag(tag);try{plain=Buffer.concat([decipher.update(data),decipher.final()])}catch{fail('wrong_passphrase_or_tampered_bundle')}+ return validate(parse(plain.toString('utf8')),true);+ }finally{key.fill(0);plain?.fill(0)}+}+function payload(producer,users,mode='metadata'){return validate({format:FORMAT,version:1,producer,exportedAt:new Date().toISOString(),mode,users},mode==='secrets');}+module.exports={FORMAT,ENCRYPTED,MAX_BYTES,BundleError,id,validate,parse,seal,open,payload};diff --git a/lib/infra/portable/data.test.ts b/lib/infra/portable/data.test.tsnew file mode 100644index 00000000..76ee1df2--- /dev/null+++ b/lib/infra/portable/data.test.ts@@ -0,0 +1,39 @@+import {beforeEach,afterEach,it,expect,vi} from 'vitest';+import {promises as fs} from 'node:fs';import os from 'node:os';import path from 'node:path';+import sample from '@/schemas/integration-bundle-example.json';+vi.mock('server-only',()=>({}));+let root:string;+beforeEach(async()=>{root=await fs.mkdtemp(path.join(os.tmpdir(),'mso-transfer-'));process.env.OS_INFRA_STORE=path.join(root,'infra.json');vi.resetModules()});+afterEach(async()=>{delete process.env.OS_INFRA_STORE;await fs.rm(root,{recursive:true,force:true});vi.resetModules()});+const KEY='synthetic-transfer-test-key',PASS='long-synthetic-passphrase';+it('previews SC format without writing and imports mapped identities, not role/default settings',async()=>{+ const api=await import('./data'),{readIntegrationState}=await import('../connection-storage');+ const preview=await api.importIntegrationData(sample);expect(preview.createUsers).toEqual([{id:'sample-user',label:'Sample owner'}]);+ await expect(fs.stat(process.env.OS_INFRA_STORE!)).rejects.toMatchObject({code:'ENOENT'});+ await api.importIntegrationData(sample,{apply:true,confirm:preview.planId});const state=await readIntegrationState();+ expect(state.defaultUser).toBeNull();expect(state.bindings).toEqual([]);expect(state.users['sample-user'].defaults).toEqual({});+ expect(state.users['sample-user'].connections.github.work.authMethod).toBe('direct');expect(state.users['sample-user'].connections.github.work.values).toEqual({});+});+it('roundtrips encrypted direct fields and rejects incorrect passphrase without mutation',async()=>{+ const codec=await import('./codec.js'),api=await import('./data'),{readIntegrationState}=await import('../connection-storage');+ const payload=codec.validate({...structuredClone(sample),mode:'secrets'},true);payload.users[0].connections[0].values={GITHUB_TOKEN:KEY,GH_OWNER:'sample-org'};+ const envelope=await codec.seal(payload,PASS);expect(JSON.stringify(envelope)).not.toContain(KEY);+ await expect(api.importIntegrationData(envelope,{passphrase:'not-the-right-passphrase'})).rejects.toThrow('wrong_passphrase');+ const p=await api.importIntegrationData(envelope,{passphrase:PASS});await api.importIntegrationData(envelope,{passphrase:PASS,apply:true,confirm:p.planId});+ const state=await readIntegrationState(),c=state.users['sample-user'].connections.github.work;expect(c.values).toEqual({apiKey:KEY,owner:'sample-org'});expect(c.verifiedAt).toBeUndefined();+ const exported=await api.exportIntegrationData({includeSecrets:true,passphrase:PASS});const restored=await codec.open(exported,PASS);expect(restored.users[0].connections[0].values).toEqual(payload.users[0].connections[0].values);+ expect((await fs.stat(process.env.OS_INFRA_STORE!)).mode&0o777).toBe(0o600);+});+it('rejects unencrypted secret fields and stale previews',async()=>{+ const api=await import('./data');const plaintext=structuredClone(sample) as unknown as Record<string,unknown>;plaintext.mode='secrets';await expect(api.importIntegrationData(plaintext)).rejects.toThrow('plaintext');+ const p=await api.importIntegrationData(sample);await api.importIntegrationData(sample,{apply:true,confirm:p.planId});await expect(api.importIntegrationData(sample,{apply:true,confirm:p.planId})).rejects.toThrow('destination_changed');+});+it('requires explicit review for conflicting or unsupported entries and preserves destination values',async()=>{+ const api=await import('./data');let p=await api.importIntegrationData(sample);await api.importIntegrationData(sample,{apply:true,confirm:p.planId});p=await api.importIntegrationData(sample);expect(p.connections[0].status).toBe('skip');await expect(api.importIntegrationData(sample,{apply:true,confirm:p.planId})).rejects.toThrow('accept_import_warnings');+ expect((await api.importIntegrationData(sample,{policy:'error'})).canApply).toBe(false);+ const unknown=structuredClone(sample);unknown.users[0].connections[0].provider='uninstalled-provider';const u=await api.importIntegrationData(unknown,{prefix:'copy-'});expect(u.warnings[0].reason).toBe('unsupported_provider_or_method');+});+it('resets external authorization instead of copying session identifiers',async()=>{+ const api=await import('./data'),{readIntegrationState}=await import('../connection-storage');const bundle=structuredClone(sample);Object.assign(bundle.users[0].connections[0],{source:'composio',authMethod:'oauth2',fields:[]});+ const p=await api.importIntegrationData(bundle);expect(p.requiresWarningAcceptance).toBe(true);await api.importIntegrationData(bundle,{apply:true,confirm:p.planId,acceptWarnings:true});const c=(await readIntegrationState()).users['sample-user'].connections.github.work;expect(c.source).toBe('composio');expect(c.external).toBeUndefined();expect(c.values).toEqual({});+});diff --git a/lib/infra/portable/data.ts b/lib/infra/portable/data.tsnew file mode 100644index 00000000..494eba91--- /dev/null+++ b/lib/infra/portable/data.ts@@ -0,0 +1,57 @@+import {createHash,randomUUID} from 'node:crypto';+import * as codec from './codec.js';+import {FIELD_MAP,wireMethod,nativeMethod} from './mapping';+import {readIntegrationState,mutateIntegrationState} from '../connection-storage';+import {connectionMethod} from '../connection-registry';+import {IntegrationError,identity,type IntegrationState} from '../identity';+import {isInfraProviderId,normalizeInfraValues} from '../catalog';+export type TransferOptions={users?:string[];includeSecrets?:boolean;passphrase?:string;prefix?:string;policy?:'skip'|'error';apply?:boolean;confirm?:string;acceptWarnings?:boolean};+export async function exportIntegrationData(options:TransferOptions={}){+ const state=await readIntegrationState(),ids=options.users??Object.keys(state.users);+ if(!Array.isArray(ids)||ids.some(id=>!Object.hasOwn(state.users,identity(id))))throw new IntegrationError('unknown_export_user');+ const users=[...new Set(ids)].map(id=>({id,label:state.users[id].label,connections:Object.values(state.users[id].connections).flatMap(rows=>Object.values(rows)).map(c=>{+ const m=connectionMethod(c.provider,c.source,c.authMethod),map=FIELD_MAP[c.provider]??{},reverse=Object.fromEntries(Object.entries(map).map(([a,b])=>[b,a]));+ const fields=m.fields.map(f=>({key:reverse[f.key],secret:f.secret,configured:Boolean(c.values[f.key])}));+ if(fields.some(f=>!f.key))throw new IntegrationError('unmapped_export_field');+ return{id:c.id,label:c.label,provider:c.provider,source:c.source,authMethod:wireMethod(c.provider,c.source,c.authMethod),scope:c.scope,fields,...(options.includeSecrets&&c.source==='direct'?{values:Object.fromEntries(Object.entries(c.values).filter(([k])=>reverse[k]).map(([k,v])=>[reverse[k],v]))}:{})};+ })}));+ const payload=codec.payload({name:'mso',version:'1'},users,options.includeSecrets?'secrets':'metadata');+ return options.includeSecrets?codec.seal(payload,options.passphrase??''):payload;+}+function previewIn(bundle:codec.Bundle,options:TransferOptions,state:IntegrationState){+ const prefix=options.prefix??'',policy=options.policy??'skip';+ if(!['skip','error'].includes(policy)||typeof prefix!=='string'||(prefix&&!/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/.test(prefix)))throw new IntegrationError('invalid_import_options');+ const users:Array<{id:string;label:string}>=[],rows:Array<Record<string,unknown>>=[],warnings:Array<Record<string,unknown>>=[],pending:Array<{user:string;c:codec.PortableConnection;method:ReturnType<typeof connectionMethod>;values:Record<string,string>}>=[];+ for(const u of bundle.users){const user=identity(prefix+u.id);if(!Object.hasOwn(state.users,user))users.push({id:user,label:u.label});+ for(const c of u.connections){const ref={user,provider:c.provider,connection:c.id,label:c.label};let method:ReturnType<typeof connectionMethod>|undefined,reason='';+ try{method=connectionMethod(c.provider,c.source,nativeMethod(c.provider,c.source,c.authMethod))}catch{reason='unsupported_provider_or_method'}+ const existing=state.users[user]?.connections[c.provider];+ if(!reason&&(existing?.[c.id]||Object.values(existing??{}).some(x=>x.label.toLowerCase()===c.label.toLowerCase())))reason='existing_connection_preserved';+ if(reason||!method){rows.push({...ref,status:'skip',reason});warnings.push({...ref,reason});continue;}+ const map=FIELD_MAP[c.provider]??{},allowed=new Set(method.fields.map(f=>f.key)),unmapped=c.fields.filter(f=>!map[f.key]||!allowed.has(map[f.key]));+ if(unmapped.length)warnings.push({...ref,reason:'unsupported_fields_omitted',fields:unmapped.map(f=>f.key)});+ if(c.source!=='direct')warnings.push({...ref,reason:'external_authorization_required'});+ let values=Object.fromEntries(Object.entries(c.values??{}).filter(([k])=>map[k]&&allowed.has(map[k])).map(([k,v])=>[map[k],v]));+ if(isInfraProviderId(c.provider)&&Object.keys(values).length)try{values=normalizeInfraValues(c.provider,values)}catch{throw new IntegrationError('invalid_imported_field_format')}+ rows.push({...ref,status:'create',source:c.source,authMethod:method.id,credentialFields:Object.keys(values).length});pending.push({user,c,method,values});+ }+ }+ // Exclude random empty-store instance IDs; bind the preview to all persisted destination data.+ const planId=createHash('sha256').update(JSON.stringify([bundle,prefix,policy,state.users,state.defaultUser,state.bindings])).digest('hex');+ return{preview:{planId,mode:bundle.mode,producer:bundle.producer.name,createUsers:users,connections:rows,warnings,canApply:policy!=='error'||!rows.some(r=>r.status==='skip'),requiresWarningAcceptance:warnings.length>0,defaultsChanged:false,folderBindingsImported:false,verified:false},pending};+}+export async function importIntegrationData(document:unknown,options:TransferOptions={}){+ const bundle=await codec.open(document,options.passphrase);+ if(!options.apply)return previewIn(bundle,options,await readIntegrationState()).preview;+ return mutateIntegrationState(state=>{+ const {preview,pending}=previewIn(bundle,options,state);+ if(options.confirm!==preview.planId)throw new IntegrationError('preview_required_or_destination_changed',409);+ if(!preview.canApply)throw new IntegrationError('import_conflicts',409);+ if(preview.requiresWarningAcceptance&&options.acceptWarnings!==true)throw new IntegrationError('review_and_accept_import_warnings',409);+ for(const u of preview.createUsers)state.users[u.id]={...u,uid:randomUUID(),connections:{},defaults:{}};+ for(const{user,c,method,values}of pending){const profile=state.users[user];profile.connections[c.provider]??={};+ profile.connections[c.provider][c.id]={id:c.id,uid:randomUUID(),label:c.label,provider:c.provider,source:c.source,authMethod:method.id,scope:method.scope,revision:1,values,createdAt:Date.now(),updatedAt:Date.now()};+ }+ return{...preview,applied:true,created:pending.length};+ });+}diff --git a/lib/infra/portable/http.ts b/lib/infra/portable/http.tsnew file mode 100644index 00000000..fe820f03--- /dev/null+++ b/lib/infra/portable/http.ts@@ -0,0 +1,15 @@+import {MAX_BYTES} from './codec.js';+import {IntegrationError} from '../identity';+export async function transferBody(req:Request):Promise<Record<string,unknown>>{+ if(req.headers.get('content-type')?.split(';')[0].trim()!=='application/json')throw new IntegrationError('json_required',415);+ if(Number(req.headers.get('content-length'))>MAX_BYTES+16384)throw new IntegrationError('bundle_too_large',413);+ const reader=req.body?.getReader();if(!reader)throw new IntegrationError('invalid_transfer_request');let bytes=0;const chunks:Uint8Array[]=[];+ try{for(;;){let timer:ReturnType<typeof setTimeout>|undefined;const r=await Promise.race([reader.read(),new Promise<never>((_,reject)=>{timer=setTimeout(()=>reject(new IntegrationError('request_timeout',408)),5000)})]).finally(()=>clearTimeout(timer));if(r.done)break;bytes+=r.value.byteLength;if(bytes>MAX_BYTES+16384)throw new IntegrationError('bundle_too_large',413);chunks.push(r.value);}+ let b;try{b=JSON.parse(Buffer.concat(chunks).toString('utf8'))}catch{throw new IntegrationError('invalid_json')}+ const allowed=['action','document','users','includeSecrets','passphrase','prefix','policy','apply','confirm','acceptWarnings'];+ if(!b||typeof b!=='object'||Array.isArray(b)||Object.keys(b).some(k=>!allowed.includes(k)))throw new IntegrationError('invalid_transfer_request');+ for(const k of ['apply','includeSecrets','acceptWarnings'])if(b[k]!==undefined&&typeof b[k]!=='boolean')throw new IntegrationError('invalid_transfer_request');+ for(const k of ['passphrase','confirm','prefix','policy'])if(b[k]!==undefined&&typeof b[k]!=='string')throw new IntegrationError('invalid_transfer_request');+ return b;+ }finally{await reader.cancel().catch(()=>{});reader.releaseLock()}+}diff --git a/lib/infra/portable/mapping.ts b/lib/infra/portable/mapping.tsnew file mode 100644index 00000000..ef069295--- /dev/null+++ b/lib/infra/portable/mapping.ts@@ -0,0 +1,27 @@+// Wire names are stable environment-key identifiers; native storage remains independent.+export const FIELD_MAP:Record<string,Record<string,string>>={+ github:{GITHUB_TOKEN:'apiKey',GH_OWNER:'owner'},+ dokploy:{DOKPLOY_API_URL:'apiUrl',DOKPLOY_API_KEY:'apiKey',DOKPLOY_PUBLIC_IP:'publicIp'},+ cloudflare:{CLOUDFLARE_API_TOKEN:'apiToken',CLOUDFLARE_ZONE_ID:'zoneId',CLOUDFLARE_ACCOUNT_ID:'accountId'},+ hostinger:{HOSTINGER_API_TOKEN:'apiToken'},+ composio:{COMPOSIO_API_KEY:'apiKey',COMPOSIO_ORG_API_KEY:'orgApiKey'},+ 'convex-cloud':{CONVEX_PERSONAL_ACCESS_TOKEN:'personalToken',CONVEX_DEPLOY_KEY:'deployKey',CONVEX_DEPLOYMENT_NAME:'deploymentName'},+ convex:{CONVEX_ADMIN_KEY:'adminKey',CONVEX_URL:'apiUrl'},+ vercel:{VERCEL_TOKEN:'apiKey',VERCEL_TEAM_ID:'teamId'},+ stripe:{STRIPE_SECRET_KEY:'apiKey',STRIPE_PUBLISHABLE_KEY:'publishableKey',STRIPE_WEBHOOK_SECRET:'webhookSecret'},+ resend:{RESEND_API_KEY:'apiKey',RESEND_FROM_DOMAIN:'fromDomain'},+ clerk:{CLERK_SECRET_KEY:'apiKey',NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:'publishableKey',NEXT_PUBLIC_CLERK_FRONTEND_API_URL:'frontendUrl'},+ supabase:{SUPABASE_ACCESS_TOKEN:'managementToken',SUPABASE_ORG_ID:'organizationId'},+};+const DIRECT:Record<string,string>={github:'classic-pat',dokploy:'admin-api-key',cloudflare:'api-token',hostinger:'api-token',convex:'self-hosted-admin',vercel:'account-token',stripe:'secret-key',resend:'api-key',clerk:'instance-keys',supabase:'personal-access-token'};+export function wireMethod(provider:string,source:string,method:string){+ if(source!=='direct')return source==='native-mcp'?'provider-oauth':method;+ return provider==='composio'?(method==='organization'?'organization-token':'project-api-key'):provider==='convex-cloud'?(method==='deployment'?'deployment-key':'personal-access-token'):DIRECT[provider]??method;+}+export function nativeMethod(provider:string,source:string,method:string){+ if(source==='native-mcp')return ['provider-oauth','dcr-oauth','mcp-oauth'].includes(method)?'provider-oauth':method;+ if(source!=='direct')return method;+ if(provider==='composio')return({'project-api-key':'project','organization-token':'organization'} as Record<string,string>)[method]??method;+ if(provider==='convex-cloud')return({'deployment-key':'deployment','personal-access-token':'personal'} as Record<string,string>)[method]??method;+ return method===DIRECT[provider]?'direct':method;+}diff --git a/lib/infra/portable/ui.ts b/lib/infra/portable/ui.tsnew file mode 100644index 00000000..d8e55da9--- /dev/null+++ b/lib/infra/portable/ui.ts@@ -0,0 +1,48 @@+// Bundled independent implementation of the versioned transfer UI.+export const PORTABILITY_SCRIPT=String.raw`+function mountPortability(root,bridge){+ let disposed=false,documentData=null,preview=null;root.replaceChildren();root.classList.add('integration','portable-transfer');+ const el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n};+ const button=(text,fn)=>{const b=el('button',text);b.type='button';b.addEventListener('click',fn);return b};+ const field=(name,type='text')=>{const l=el('label',name),i=el('input');i.type=type;i.autocomplete='off';if(type==='checkbox')l.className='check identity-check';l.append(i);return{l,i}};+ const back=button('← Connections',()=>{cleanup();bridge.back()});root.append(back,el('h2','Import / export JSON'),el('p','Move credential users and named connections between independent applications. This is a one-time copy, not live synchronization. No existing connection is overwritten.'));+ const exp=el('section'),imp=el('section');exp.className=imp.className='connection-card';exp.append(el('h3','Export'));+ const owner=field('User ID (blank exports all users)'),secrets=field('Include direct credentials — encrypted JSON','checkbox'),password=field('Export passphrase (12+ characters)','password'),repeat=field('Confirm export passphrase','password');+ password.i.maxLength=repeat.i.maxLength=1024;password.l.hidden=repeat.l.hidden=true;+ secrets.i.addEventListener('change',()=>{password.l.hidden=repeat.l.hidden=!secrets.i.checked;if(!secrets.i.checked)password.i.value=repeat.i.value=''});+ const note=el('p','Metadata export includes names, source/auth methods and field status only. All field values, active OAuth sessions, defaults and folder mappings are excluded.');+ const exportStatus=el('p');exportStatus.setAttribute('role','status');+ const download=button('Export JSON',async()=>{+ download.disabled=true;exportStatus.textContent='Preparing export…';+ try{if(secrets.i.checked&&(password.i.value.length<12||password.i.value!==repeat.i.value))throw Error('Use a matching passphrase of at least 12 characters.');+ const response=await bridge.request({action:'export',...(owner.i.value.trim()?{users:[owner.i.value.trim()]}:{}),includeSecrets:secrets.i.checked,...(secrets.i.checked?{passphrase:password.i.value}:{})});+ if(disposed)return;const encrypted=response.bundle.format.endsWith('.encrypted');+ const blob=new Blob([JSON.stringify(response.bundle,null,2)+'\n'],{type:'application/json'}),url=URL.createObjectURL(blob),a=el('a','Save JSON file');+ a.href=url;a.download='connections-'+new Date().toISOString().slice(0,10)+(encrypted?'.integration-bundle.enc.json':'.integration-bundle.json');a.click();setTimeout(()=>URL.revokeObjectURL(url),1000);+ exportStatus.textContent=encrypted?'Encrypted export created. Share the passphrase through a separate channel.':'Metadata export created. It contains no credential values.';+ }catch(e){exportStatus.textContent=e.message}finally{password.i.value=repeat.i.value='';download.disabled=false}+ });exp.append(owner.l,secrets.l,password.l,repeat.l,note,download,exportStatus);+ imp.append(el('h3','Import'));const file=field('JSON bundle file','file');file.i.accept='.json,application/json';+ const decrypt=field('Import passphrase (encrypted files only)','password'),prefix=field('User ID prefix (optional, for a separate copy)'),policy=el('select'),policyLabel=el('label','Conflicts');+ decrypt.i.maxLength=1024;prefix.i.placeholder='imported-';prefix.i.maxLength=32;decrypt.l.hidden=true;+ for(const [value,text]of [['skip','Preserve existing connections; skip conflicts'],['error','Stop when a conflict exists']]){const o=el('option',text);o.value=value;policy.append(o)}policyLabel.append(policy);+ const previewBox=el('pre');previewBox.style.whiteSpace='pre-wrap';previewBox.style.overflowWrap='anywhere';const importStatus=el('p');importStatus.setAttribute('role','status');+ const reviewed=field('I reviewed the preview and accept listed skips / omitted fields','checkbox');reviewed.i.checked=false;+ function reset(){preview=null;previewBox.textContent='';apply.disabled=true;reviewed.i.checked=false;}+ file.i.addEventListener('change',async()=>{reset();documentData=null;decrypt.i.value='';const selected=file.i.files?.[0];if(!selected)return;try{if(selected.size>2*1024*1024)throw Error('JSON file exceeds 2 MiB.');documentData=JSON.parse(await selected.text());decrypt.l.hidden=documentData.format!=='integration-bundle.encrypted';importStatus.textContent='File loaded locally. Choose Preview import.'}catch(e){importStatus.textContent=e.message}});+ prefix.i.addEventListener('input',reset);policy.addEventListener('change',reset);+ const input=()=>({action:'import',document:documentData,prefix:prefix.i.value.trim(),policy:policy.value,...(!decrypt.l.hidden?{passphrase:decrypt.i.value}:{})});+ const check=button('Preview import',async()=>{if(!documentData){importStatus.textContent='Choose a JSON file first.';return}check.disabled=true;try{preview=await bridge.request(input());if(disposed)return;previewBox.textContent=JSON.stringify(preview,null,2);apply.disabled=!preview.canApply;importStatus.textContent='Preview only: nothing has been imported.'}catch(e){reset();importStatus.textContent=e.message}finally{check.disabled=false}});+ const apply=button('Apply import',async()=>{+ if(!preview||!reviewed.i.checked){importStatus.textContent='Review the preview and check the confirmation box.';return}apply.disabled=check.disabled=true;+ try{const result=await bridge.request({...input(),apply:true,confirm:preview.planId,acceptWarnings:reviewed.i.checked});if(disposed)return;previewBox.textContent=JSON.stringify(result,null,2);importStatus.textContent='Imported. Connections are not marked verified; external sources must be authorized again. Select the imported user when you return.';documentData=null;file.i.value='';decrypt.i.value='';preview=null;}+ catch(e){importStatus.textContent=e.message;apply.disabled=false}finally{check.disabled=false}+ });apply.disabled=true;+ imp.append(file.l,decrypt.l,prefix.l,policyLabel,check,previewBox,reviewed.l,apply,importStatus);const grid=el('div');grid.className='transfer-grid';grid.append(exp,imp);root.append(grid);+ function cleanup(){disposed=true;password.i.value=repeat.i.value=decrypt.i.value='';documentData=null;preview=null;root.replaceChildren();root.classList.remove('portable-transfer','integration')}+ return cleanup;+}+`;+export const PORTABILITY_STYLE=String.raw`+.portable-transfer{max-width:1100px!important;margin:auto}.portable-transfer .transfer-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px}.portable-transfer section{min-width:0;border:1px solid var(--sep-strong,var(--line,#ddd));border-radius:12px;padding:20px;background:var(--field,var(--panel,#fff))}.portable-transfer h3{margin-top:0}.portable-transfer label{display:block;margin:14px 0 6px;font-weight:600;font-size:13px}.portable-transfer input,.portable-transfer select{margin-top:6px;min-width:0;max-width:100%}.portable-transfer .identity-check{display:flex;gap:9px;align-items:center;font-weight:400}.portable-transfer .identity-check input{width:18px;height:18px;margin:0;order:-1;flex:none}.portable-transfer button{min-height:40px;margin:8px 7px 8px 0}.portable-transfer pre{max-height:330px;overflow:auto;font-size:12px;line-height:1.6}.portable-transfer [role=status]{font-size:13px;overflow-wrap:anywhere}@media(max-width:700px){.portable-transfer .transfer-grid{grid-template-columns:1fr}.portable-transfer section{padding:15px}}+`;diff --git a/lib/infra/setup-browser.ts b/lib/infra/setup-browser.tsindex 84bce593..eb8c5a2c 100644--- a/lib/infra/setup-browser.ts+++ b/lib/infra/setup-browser.ts@@ -1,19 +1,25 @@export const INTEGRATION_BROWSER_SCRIPT=String.raw`(async()=>{- const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup";let cleanup=()=>{},state={},authController;+ const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup";let cleanup=()=>{},state={},authController,wantsTransfer=new URLSearchParams(location.search).get("transfer")==="1";const error=data=>{const e=new Error(data.error||"integration_operation_failed");e.code=data.error;return e};async function json(url,init){const r=await fetch(url,{credentials:"same-origin",cache:"no-store",referrerPolicy:"no-referrer",...init});const data=await r.json();if(!r.ok)throw error(data);return data}const post=(mode,input)=>json("/api/v1/integrations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode,...input})});function showForm(setup,token){cleanup();authController?.abort();cleanup=mountIntegrationForm(root,setup,{endpoint,token,onBack:loadManager})||(()=>{})}+ function openTransfer(){+ cleanup();authController?.abort();wantsTransfer=true;+ cleanup=mountPortability(root,{back:()=>{wantsTransfer=false;void loadManager()},request:body=>json("/api/v1/integrations/transfer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)})});+ }async function loadManager(){cleanup();authController?.abort();authController=new AbortController();let owner=false;try{const auth=await json("/api/auth/me",{signal:authController.signal});owner=auth.role==="owner"}catch{}const bridge={remember:s=>state=s,openLink:url=>window.open(url,"_blank","noopener,noreferrer")};if(owner){+ bridge.openTransfer=openTransfer;bridge.query=args=>json("/api/v1/integrations?"+new URLSearchParams(args));bridge.manage=args=>post("manage",args);bridge.execute=args=>post("execute",args);bridge.openSetup=async args=>{const data=await json("/api/v1/infra/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(args)});showForm(data.setup,data.token)};}+ if(owner&&wantsTransfer){openTransfer();return}cleanup=mountConnectionManager(root,INTEGRATIONS_CATALOG,bridge,state);if(!owner){const link=integrationNode("a","Sign in to MSO as Owner");link.href="/";link.target="_blank";link.rel="noopener noreferrer";root.prepend(link);const refresh=()=>{if(document.visibilityState!=="hidden")void loadManager()};document.addEventListener("visibilitychange",refresh,{signal:authController.signal});window.addEventListener("focus",refresh,{signal:authController.signal});}}diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.tsindex d6ee3d9f..72ec036b 100644--- a/lib/infra/setup-page.ts+++ b/lib/infra/setup-page.ts@@ -1,3 +1,4 @@+import {PORTABILITY_SCRIPT,PORTABILITY_STYLE} from "./portable/ui";import { randomBytes } from "node:crypto";import { MSO_WIDGET_TOKENS } from "@/lib/presentation/widget-tokens";import { INTEGRATION_FORM_SCRIPT, INTEGRATION_FORM_STYLE } from "./setup-ui";@@ -7,7 +8,7 @@ import { connectionCatalog } from "./connection-registry";export function integrationSetupPage() {const nonce = randomBytes(18).toString("base64");const catalog = JSON.stringify(connectionCatalog()).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}${CONNECTION_MANAGER_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}${CONNECTION_MANAGER_SCRIPT}${INTEGRATION_BROWSER_SCRIPT}</script></body></html>`;+ 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}${CONNECTION_MANAGER_STYLE}${PORTABILITY_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}${CONNECTION_MANAGER_SCRIPT}${PORTABILITY_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() {diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.tsindex b2676427..685b12a4 100644--- a/lib/mcp/toolset.ts+++ b/lib/mcp/toolset.ts@@ -4,8 +4,8 @@ import type { McpTool } from "./tool-kit";import { toolDescriptor, type McpToolProfile } from "./tool-contract";export const MCP_SERVER_VERSION = "1.12.0";-export const MCP_TOOLSET_VERSION = "2026.09.05.8";-export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T14:05:00Z";+export const MCP_TOOLSET_VERSION = "2026.09.05.9";+export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T14:55:00Z";export type McpToolsetInfo = {serverVersion: string;diff --git a/lib/mcp/ui-page-integrations.ts b/lib/mcp/ui-page-integrations.tsindex 324eed89..c69e103b 100644--- a/lib/mcp/ui-page-integrations.ts+++ b/lib/mcp/ui-page-integrations.ts@@ -19,7 +19,7 @@ async function integrationTool(name,args){function renderIntegrations(){const back=()=>{integrationAccess=null;lastOutputKey="";current={route:"/integrations",kind:"integrations",title:"Integrations",openPath:"/integrations",catalog:[]};render()};if(current.setup){captureIntegrationAccess(window.openai?.toolResponseMetadata);viewCleanup=mountIntegrationForm(body,current.setup,{...(integrationAccess||{}),onBack:back,openLink:openIntegrationReference,openBrowser:()=>openIntegrationReference(INTEGRATION_BROWSER)})||(()=>{});return}- const bridge={remember:s=>integrationSelection=s,openLink:openIntegrationReference,+ const bridge={openTransferBrowser:()=>openIntegrationReference(INTEGRATION_BROWSER+"?transfer=1"),remember:s=>integrationSelection=s,openLink:openIntegrationReference,query:async args=>(await integrationTool("integration_query",args)).data,manage:async args=>{const{response,data}=await integrationTool("integration_manage",args);const meta=privateIntegrationMeta(response,"integrationAuthorization")||privateIntegrationMeta(window.openai?.toolResponseMetadata,"integrationAuthorization");return{...data,...(meta?.url?{privateUrl:meta.url}:{})}},execute:async args=>(await integrationTool("integration_execute",args)).data,diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex a5da17d5..629dfc51 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -150,7 +150,7 @@ describe("MCP Apps Block and Page contract", () => {frameDomains: ["https://game.rahmanef.com"],});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-v7.html");+ expect(MSO_PAGE_URI).toContain("page-v8.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.tsindex 16d75f9a..e6bd3662 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_V7_URI = "ui://mso/page-v7.html";export const LEGACY_PAGE_V6_URI = "ui://mso/page-v6.html";export const LEGACY_PAGE_V5_URI = "ui://mso/page-v5.html";export const LEGACY_PAGE_V4_URI = "ui://mso/page-v4.html";@@ -28,6 +29,7 @@ export type McpUiResource = {const RESOURCES: readonly McpUiResource[] = [MSO_BLOCK_RESOURCE, MSO_PAGE_RESOURCE];const LEGACY_ALIASES = new Map<string, McpUiResource>([+ [LEGACY_PAGE_V7_URI, MSO_PAGE_RESOURCE],[LEGACY_PAGE_V6_URI, MSO_PAGE_RESOURCE],[LEGACY_PAGE_V5_URI, MSO_PAGE_RESOURCE],[LEGACY_PAGE_V4_URI, MSO_PAGE_RESOURCE],diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.tsindex e7c47b54..9f4889b6 100644--- a/lib/mcp/ui-surface.ts+++ b/lib/mcp/ui-surface.ts@@ -6,7 +6,7 @@ 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-v7.html";+export const MSO_PAGE_URI = "ui://mso/page-v8.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<main class="surface" aria-label="MSO Page">diff --git a/schemas/integration-bundle-example.json b/schemas/integration-bundle-example.jsonnew file mode 100644index 00000000..b163b65d--- /dev/null+++ b/schemas/integration-bundle-example.json@@ -0,0 +1,38 @@+{+ "format": "integration-bundle",+ "version": 1,+ "producer": {+ "name": "si-coder",+ "version": "0.9.3"+ },+ "exportedAt": "2026-09-05T00:00:00.000Z",+ "mode": "metadata",+ "users": [+ {+ "id": "sample-user",+ "label": "Sample owner",+ "connections": [+ {+ "id": "work",+ "label": "Work GitHub",+ "provider": "github",+ "source": "direct",+ "authMethod": "classic-pat",+ "scope": "account",+ "fields": [+ {+ "key": "GITHUB_TOKEN",+ "secret": true,+ "configured": false+ },+ {+ "key": "GH_OWNER",+ "secret": false,+ "configured": false+ }+ ]+ }+ ]+ }+ ]+}diff --git a/schemas/integration-bundle-v1.schema.json b/schemas/integration-bundle-v1.schema.jsonnew file mode 100644index 00000000..b9b3d925--- /dev/null+++ b/schemas/integration-bundle-v1.schema.json@@ -0,0 +1,222 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "$id": "urn:integration-bundle:v1",+ "title": "Integration Bundle v1 \u2014 metadata or authenticated encrypted envelope",+ "description": "Project portability contract, not an automatically supported vendor format. Runtime validation additionally enforces total size, unique identities, fixed key-derivation costs and authenticated decryption.",+ "oneOf": [+ {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "format",+ "version",+ "producer",+ "exportedAt",+ "mode",+ "users"+ ],+ "properties": {+ "format": {+ "const": "integration-bundle"+ },+ "version": {+ "const": 1+ },+ "producer": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "version"+ ],+ "properties": {+ "name": {+ "type": "string",+ "maxLength": 64+ },+ "version": {+ "type": "string",+ "maxLength": 64+ }+ }+ },+ "exportedAt": {+ "type": "string",+ "format": "date-time"+ },+ "mode": {+ "const": "metadata"+ },+ "users": {+ "type": "array",+ "maxItems": 100,+ "items": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "id",+ "label",+ "connections"+ ],+ "properties": {+ "id": {+ "type": "string",+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"+ },+ "label": {+ "type": "string",+ "maxLength": 120+ },+ "connections": {+ "type": "array",+ "maxItems": 1000,+ "items": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "id",+ "label",+ "provider",+ "source",+ "authMethod",+ "scope",+ "fields"+ ],+ "properties": {+ "id": {+ "type": "string",+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"+ },+ "label": {+ "type": "string",+ "minLength": 1,+ "maxLength": 120+ },+ "provider": {+ "type": "string",+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"+ },+ "source": {+ "enum": [+ "direct",+ "composio",+ "native-mcp"+ ]+ },+ "authMethod": {+ "type": "string",+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"+ },+ "scope": {+ "type": "string",+ "maxLength": 64+ },+ "fields": {+ "type": "array",+ "maxItems": 64,+ "items": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "key",+ "secret",+ "configured"+ ],+ "properties": {+ "key": {+ "type": "string",+ "pattern": "^[A-Z][A-Z0-9_]{1,127}$"+ },+ "secret": {+ "type": "boolean"+ },+ "configured": {+ "type": "boolean"+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ },+ {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "format",+ "version",+ "kdf",+ "cipher",+ "data"+ ],+ "properties": {+ "format": {+ "const": "integration-bundle.encrypted"+ },+ "version": {+ "const": 1+ },+ "kdf": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "N",+ "r",+ "p",+ "salt"+ ],+ "properties": {+ "name": {+ "const": "scrypt"+ },+ "N": {+ "const": 32768+ },+ "r": {+ "const": 8+ },+ "p": {+ "const": 1+ },+ "salt": {+ "type": "string",+ "contentEncoding": "base64"+ }+ }+ },+ "cipher": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "iv",+ "tag"+ ],+ "properties": {+ "name": {+ "const": "aes-256-gcm"+ },+ "iv": {+ "type": "string",+ "contentEncoding": "base64"+ },+ "tag": {+ "type": "string",+ "contentEncoding": "base64"+ }+ }+ },+ "data": {+ "type": "string",+ "contentEncoding": "base64"+ }+ }+ }+ ]+}diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.shindex c68b8c31..27b1757a 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_integrations="integrations status|users|catalog|connections [user] [provider]|which [folder]|request|resolve <user> <provider> [connection]|create-user <id> [label]|create-connection <user> <provider> <id> <source> <auth>|manage <JSON>|setup|verify <user> <provider> <connection>|execute <JSON>"+U_integrations="integrations transfer|status|users|catalog|connections [user] [provider]|which [folder]|request|resolve <user> <provider> [connection]|create-user <id> [label]|create-connection <user> <provider> <id> <source> <auth>|manage <JSON>|setup|verify <user> <provider> <connection>|execute <JSON>"U_provider="provider list|show <id>|setup <provider> <user> <connection>|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]"diff --git a/scripts/mso-cli-integrations.sh b/scripts/mso-cli-integrations.shindex ba76163a..8ab9609d 100644--- a/scripts/mso-cli-integrations.sh+++ b/scripts/mso-cli-integrations.sh@@ -4,6 +4,7 @@ run_integrations() {local sub="${1:-status}" data user provider connection query bodyshift || truecase "$sub" in+ transfer) data=$(jget "/api/v1/integrations/transfer"); printf "Open the owner-only JSON transfer page in your browser:\n%s\n" "$(jq -r .url <<<"$data")" ;;status|users|catalog)query="snapshot"; [ "$sub" = users ] && query=users; [ "$sub" = catalog ] && query=catalogjget "/api/v1/integrations?view=$query" ;;