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
import { isGoogleProvider, GOOGLE_APP_PROVIDER, googlePublicOrigin } from "./google-native-config";
import { bindGoogleApp, disconnectGoogle, runNativeGoogle, nativeGoogleStatus, googleOperations } from "./google-native";
import { integrationManage } from "./connection-manage";
import { integrationQuery, withIntegrationSelection, resolveIntegration, directConnectionValues } from "./connection-service";
import { authorizeIntegration, composioConnectionCall } from "./connection-external";
import { composioKeyKind } from "./composio";
import { callComposioConnectTool, listComposioConnectTools } from "./composio-connect";
import { IntegrationError, identity, metadataOnly, type ConnectionSelector } from "./identity";
import { importConvexCliPersonalConnection } from "./convex-cli-import";
import { listConvexCustomDomains, ensureConvexCustomDomain, getConvexCanonicalUrls, setConvexCanonicalUrl, getConvexEnvPresence, deployConvexCloudProject, importConvexCloudSnapshot } from "./convex-cloud";
import { CONVEX_OPERATION_SUPPORT } from "./types";
import { doctorInfraProvider, ensureDokployProject, listDokployApplications, listDokployDeployments, readDokployDeploymentLogs, listDokployGitProviders, listDokployGithubRepositories, ensureDokployGithubApplication, ensureDokployApplicationDomain, recoverDokployPublicGithubToHttpsGit, deployDokployApplication, configureDokployDockerfileBuild, listDokployProjects, listCloudflareZones, upsertCloudflareDns, upsertDokployPublicBuildEnv, upsertHostingerDns, listHostingerMailOrders, getHostingerMailPlan, listHostingerMail, listHostingerMailLogs, mutateHostingerMail } from "./clients";
import { isInfraProviderId, canonicalProviderId, resolveProviderId, convexDeploymentKind } from "./catalog";
import { callNamedMcpConnectionTool, listNamedMcpConnectionTools } from "./mcp-connection";
export const safeActionInput=(input:Record<string,unknown>)=>Object.fromEntries(Object.entries(input).filter(([key])=>key!=="workflow_id"));
export const selectionFrom=(a:Record<string,unknown>):ConnectionSelector=>({user:typeof a.user==="string"?a.user:undefined,connection:typeof a.connection==="string"?a.connection:undefined,cwd:typeof a.cwd==="string"?a.cwd:undefined});
export async function manageIntegrationAction(raw:Record<string,unknown>){
const a=safeActionInput(raw);
// demo.* carries a real password, so it must bypass metadataOnly; the allowlisted
// handler still rejects any other action that ships a secret-shaped key.
if(String(a.action).startsWith("demo."))return integrationManage(a);
metadataOnly(a);
if(a.action==="connection.import-convex-cli"){
if(a.confirm!==true)throw new IntegrationError("confirmation_required",403);
if(Object.keys(a).some(k=>!["action","confirm","user","provider","connection"].includes(k)))throw new IntegrationError("invalid_management_fields");
if(a.provider!=="convex"&&a.provider!=="convex-cloud")throw new IntegrationError("provider_operation_mismatch");
return importConvexCliPersonalConnection(selectionFrom(a));
}
if(a.action==="connection.authorize"&&isGoogleProvider(String(a.provider))){
if(a.confirm!==true)throw new IntegrationError("confirmation_required",403);
if(Object.keys(a).some(k=>!["action","confirm","user","provider","connection"].includes(k)))throw new IntegrationError("invalid_management_fields");
const route=await resolveIntegration(String(a.provider),selectionFrom(a));
return{user:route.user,provider:a.provider,connection:route.id,authorization:"owner-browser-required",openPath:googlePublicOrigin()+"/integrations?"+new URLSearchParams({provider:String(a.provider),user:route.user,connection:route.id})};
}
if(a.action!=="connection.authorize")return integrationManage(a);
if(a.confirm!==true)throw new IntegrationError("confirmation_required",403);
if(Object.keys(a).some(k=>!["action","confirm","user","provider","connection","authConfigId","brokerConnection","createManaged"].includes(k)))throw new IntegrationError("invalid_management_fields");
return authorizeIntegration(identity(a.provider,"provider"),selectionFrom(a),{authConfigId:typeof a.authConfigId==="string"?identity(a.authConfigId):undefined,brokerConnection:typeof a.brokerConnection==="string"?identity(a.brokerConnection):undefined,createManaged:a.createManaged===true});
}
export async function executeIntegrationAction(raw:Record<string,unknown>){
const a=safeActionInput(raw),operation=String(a.operation);
// Demo login CRUD is agent-side: no provider/connection, but a real cwd resolved by
// folder binding. It runs before metadataOnly because the password IS the payload.
if(operation.startsWith("demo.")){
if(Object.keys(a).some(k=>!["user","provider","connection","operation","arguments","tool","confirm"].includes(k)))throw new IntegrationError("invalid_execution_fields");
const demoArgs=a.arguments;if(!demoArgs||typeof demoArgs!=="object"||Array.isArray(demoArgs))throw new IntegrationError("invalid_tool_arguments");
// Spread first so the operation itself and the confirmation flag cannot be overridden.
return integrationManage({...demoArgs as Record<string,unknown>,action:operation,confirm:a.confirm===true});
}
if(operation==="dokploy.application.publicEnv.upsert"){
const {arguments:operationArgs,...meta}=a;metadataOnly(meta);
const args=operationArgs;if(!args||typeof args!=="object"||Array.isArray(args))throw new IntegrationError("invalid_tool_arguments");
if(Object.keys(args).some(k=>!["applicationId","key","value","redeploy"].includes(k)))throw new IntegrationError("invalid_tool_arguments");
}else metadataOnly(a);
if(Object.keys(a).some(k=>!["user","provider","connection","operation","arguments","tool","confirm"].includes(k)))throw new IntegrationError("invalid_execution_fields");
const user=identity(a.user,"user"),provider=identity(a.provider,"provider"),connection=identity(a.connection,"connection"),selection={user,connection};
const canonical=canonicalProviderId(provider);
const route=await resolveIntegration(provider,selection);
if(operation==="route")return route;
if(operation==="verify"&&(isGoogleProvider(provider)||provider===GOOGLE_APP_PROVIDER))return nativeGoogleStatus(provider,selection);
if(operation==="verify")return withIntegrationSelection(selection,()=>{if(!isInfraProviderId(provider))throw new IntegrationError("unknown_provider");return doctorInfraProvider(resolveProviderId(provider)!);});
if(a.confirm!==true)throw new IntegrationError("confirmation_required",403);
const args=a.arguments??{};if(!args||typeof args!=="object"||Array.isArray(args))throw new IntegrationError("invalid_tool_arguments");
if(isGoogleProvider(provider)){
if(route.source!=="direct")throw new IntegrationError("google_native_connection_required",409);
const body=args as Record<string,unknown>;
if(operation==="google.bind"){if(Object.keys(body).some(k=>k!=="appConnection"))throw new IntegrationError("invalid_tool_arguments");return bindGoogleApp(provider,selection,body.appConnection)}
if(operation==="google.disconnect"||operation==="google.operations.list"){if(Object.keys(body).length)throw new IntegrationError("invalid_tool_arguments");return operation==="google.disconnect"?disconnectGoogle(provider,selection):{operations:googleOperations(provider)}}
return runNativeGoogle(provider,selection,operation,body);
}
if(operation==="composio.tool"||operation==="composio.tools.list")return composioOperation(provider,selection,operation,String(a.tool),args as Record<string,unknown>);
const verbs:Record<string,{provider:string;fields:string[];run:()=>Promise<unknown>}>= {
"dokploy.projects.list":{provider:"dokploy",fields:[],run:()=>listDokployProjects()},
"dokploy.applications.list":{provider:"dokploy",fields:["projectId"],run:()=>listDokployApplications(String((args as Record<string,unknown>).projectId))},
"dokploy.gitProviders.list":{provider:"dokploy",fields:[],run:()=>listDokployGitProviders()},
"dokploy.github.repositories.list":{provider:"dokploy",fields:["githubId"],run:()=>listDokployGithubRepositories(String((args as Record<string,unknown>).githubId))},
"dokploy.application.ensureGithub":{provider:"dokploy",fields:["projectId","name","githubId","owner","repository","branch","buildPath"],run:()=>ensureDokployGithubApplication(args as {projectId:string;name:string;githubId:string;owner:string;repository:string;branch:string;buildPath?:string})},
"dokploy.domain.ensure":{provider:"dokploy",fields:["applicationId","host","port","https"],run:()=>ensureDokployApplicationDomain(args as {applicationId:string;host:string;port:number;https:boolean})},
"dokploy.deployments.list":{provider:"dokploy",fields:["applicationId"],run:()=>listDokployDeployments(String((args as Record<string,unknown>).applicationId))},
"dokploy.deployment.logs":{provider:"dokploy",fields:["deploymentId","tail"],run:()=>readDokployDeploymentLogs(String((args as Record<string,unknown>).deploymentId),Number((args as Record<string,unknown>).tail??160))},
"dokploy.git.recover":{provider:"dokploy",fields:["applicationId"],run:()=>recoverDokployPublicGithubToHttpsGit(String((args as Record<string,unknown>).applicationId))},
"dokploy.application.deploy":{provider:"dokploy",fields:["applicationId"],run:()=>deployDokployApplication(String((args as Record<string,unknown>).applicationId))},
"dokploy.dockerfile":{provider:"dokploy",fields:["applicationId","dockerfile","dockerContextPath"],run:()=>configureDokployDockerfileBuild(args as {applicationId:string;dockerfile?:string;dockerContextPath?:string})},
"dokploy.application.publicEnv.upsert":{provider:"dokploy",fields:["applicationId","key","value","redeploy"],run:()=>upsertDokployPublicBuildEnv(args as {applicationId:string;key:string;value:string;redeploy?:boolean})},
"dokploy.project.ensure":{provider:"dokploy",fields:["name"],run:()=>ensureDokployProject(String((args as Record<string,unknown>).name))},
"convex.customDomains.list":{provider:"convex",fields:["deploymentName"],run:()=>listConvexCustomDomains(String((args as Record<string,unknown>).deploymentName))},
"convex.customDomain.ensure":{provider:"convex",fields:["deploymentName","domain","requestDestination"],run:()=>ensureConvexCustomDomain(args as {deploymentName:string;domain:string;requestDestination:"convexCloud"|"convexSite"})},
"convex.canonical.get":{provider:"convex",fields:["deploymentName"],run:()=>getConvexCanonicalUrls(String((args as Record<string,unknown>).deploymentName))},
"convex.env.presence":{provider:"convex",fields:["deploymentName","names"],run:()=>getConvexEnvPresence(args as {deploymentName:string;names:string[]})},
"convex.canonical.set":{provider:"convex",fields:["deploymentName","requestDestination","url"],run:()=>setConvexCanonicalUrl(args as {deploymentName:string;requestDestination:"convexCloud"|"convexSite";url?:string|null})},
"convex.project.deploy":{provider:"convex",fields:["deploymentName","projectPath"],run:()=>deployConvexCloudProject(args as {deploymentName:string;projectPath:string})},
"convex.snapshot.import":{provider:"convex",fields:["deploymentName","projectPath","snapshotPath","mode"],run:()=>importConvexCloudSnapshot(args as {deploymentName:string;projectPath:string;snapshotPath:string;mode:"replace-all"|"append"})},
"cloudflare.zones.list":{provider:"cloudflare",fields:[],run:()=>listCloudflareZones()},
"cloudflare.dns.upsert":{provider:"cloudflare",fields:["name","type","content","ttl","proxied"],run:()=>upsertCloudflareDns(args as Parameters<typeof upsertCloudflareDns>[0])},
"hostinger.dns.upsert":{provider:"hostinger",fields:["name","type","content","ttl"],run:()=>upsertHostingerDns(args as Parameters<typeof upsertHostingerDns>[0])},
"hostinger.mail.orders.list":{provider:"hostinger",fields:[],run:()=>listHostingerMailOrders()},
"hostinger.mail.plan.get":{provider:"hostinger",fields:["orderId"],run:()=>getHostingerMailPlan((args as Record<string,unknown>).orderId)},
"hostinger.mail.list":{provider:"hostinger",fields:["orderId","resource","page"],run:()=>listHostingerMail((args as Record<string,unknown>).orderId,(args as Record<string,unknown>).resource,(args as Record<string,unknown>).page as number)},
"hostinger.mail.logs.list":{provider:"hostinger",fields:["orderId","kind","page"],run:()=>listHostingerMailLogs((args as Record<string,unknown>).orderId,(args as Record<string,unknown>).kind,(args as Record<string,unknown>).page as number)},
"hostinger.mail.mutate":{provider:"hostinger",fields:["orderId","mailboxId","aliasId","forwarderId","autoreplyId","catchallId","localPart","destination","keepCopy","subject","body","displayName","startsAt","endsAt","action"],run:()=>mutateHostingerMail(String((args as Record<string,unknown>).action),args as Record<string,unknown>)},
"mcp.tools.list":{provider:"mcp",fields:[],run:()=>listNamedMcpConnectionTools(selection)},
"mcp.tool":{provider:"mcp",fields:["name","arguments"],run:()=>callNamedMcpConnectionTool(selection,String((args as Record<string,unknown>).name??""),((args as Record<string,unknown>).arguments&&typeof (args as Record<string,unknown>).arguments==="object"&&!Array.isArray((args as Record<string,unknown>).arguments)?(args as Record<string,unknown>).arguments:{} ) as Record<string,unknown>)},
};
const verb=verbs[operation];if(!verb||verb.provider!==canonical)throw new IntegrationError("provider_operation_mismatch");
if(route.source!=="direct")throw new IntegrationError("external_source_requires_own_executor",409);
if(Object.keys(args).some(k=>!verb.fields.includes(k)))throw new IntegrationError("invalid_tool_arguments");
// Self-hosted Convex shares the provider id but not every operation. Refuse the
// ones CONVEX_OPERATION_SUPPORT marks unsupported for this kind by NAME instead
// of letting the runner fail obscurely or the operation disappear as a 404.
if(canonical==="convex"){
const support=CONVEX_OPERATION_SUPPORT.find(row=>row.operation===operation);
if(support){
const kind=convexDeploymentKind(await directConnectionValues(canonical,selection));
const availability=kind==="self-hosted"?support.selfHosted:support.cloud;
if(availability!=="supported"){
const error=new IntegrationError("convex_operation_unsupported_for_kind",409);
Object.assign(error,{operation,deploymentKind:kind,reason:support.reason??null});
throw error;
}
}
}
return withIntegrationSelection(selection,async()=>({identity:route,result:await verb.run()}));
}
export const queryIntegrationAction=(input:Record<string,unknown>)=>integrationQuery(safeActionInput(input));
/**
* One branch for both Composio operations so the key-kind routing cannot drift.
* Connect uses the stored provider credential directly (no connection selector,
* like doctorComposio); Platform keeps its existing /connected_accounts path.
*/
async function composioOperation(provider:string,selection:ConnectionSelector,operation:string,tool:string,args:Record<string,unknown>){
// Read the stored Composio credential for the same credential owner, the way
// doctorComposio reads it: no connection selector, no endpoint from the caller.
// A store that cannot resolve a Composio row for this owner falls through to the
// Platform path unchanged, which raises its own existing error.
let values:Record<string,string>|undefined;
try{values=await directConnectionValues("composio",{user:selection.user});}catch{values=undefined;}
if(values){
const kind=composioKeyKind(values);
if(kind==="connect"){
// Connect tools run under the Connect account; only the composio provider owns that surface.
if(provider!=="composio")throw new IntegrationError("provider_operation_mismatch");
return operation==="composio.tools.list"?listComposioConnectTools(values):callComposioConnectTool(values,tool,args);
}
if(kind===null)throw new IntegrationError("composio_project_key_required",409);
// Platform discovery is per connected account and never was this operation: refuse it clearly.
if(operation==="composio.tools.list")throw new IntegrationError("composio_tools_list_requires_connect_key",409);
}
return composioConnectionCall(provider,selection,tool,args);
}